diff --git a/.mailmap b/.mailmap index ede478c8a18..6a9362f6e4c 100644 --- a/.mailmap +++ b/.mailmap @@ -8,11 +8,14 @@ Alexander Rusakov Alex Eagle Anatoly Ressin Anders Hejlsberg unknown unknown +about-code # Andreas Martin Andrej Baran +Andrew Ochsner Andrew Z Allen Andy Hanson Andy Anil Anar Anton Tolmachev +Anubha Mathur anubmat Arnavion # Arnav Singh Arthur Ozga Arthur Ozga Arthur Ozga Arthur Ozga Arthur Ozga Asad Saeeduddin @@ -37,6 +40,7 @@ Dan Corder Dan Quirk Dan Quirk nknown Daniel Rosenwasser Daniel Rosenwasser Daniel Rosenwasser Daniel Rosenwasser Daniel Rosenwasser David Li +David Sheldrick David Souther Denis Nedelyaev Dick van den Brink unknown unknown @@ -52,6 +56,7 @@ Evan Sebastian Eyas # Eyas Sharaiha Fabian Cook falsandtru # @falsandtru +flowmemo # @flowmemo Frank Wallis František Žiacik František Žiacik Gabe Moothart @@ -62,6 +67,7 @@ Graeme Wicksted Guillaume Salles Guy Bedford guybedford Harald Niesche +Homa Wong Iain Monro Ingvar Stepanyan impinball # Isiah Meadows @@ -81,6 +87,7 @@ Jonathan Park Jonathan Turner Jonathan Turner Jonathan Toland Jesse Schalken +Joel Day Josh Abernathy joshaber Josh Kalderimis Josh Soref @@ -95,10 +102,12 @@ Kanchalai Tanglertsampan Yui T Kanchalai Tanglertsampan Yui Kanchalai Tanglertsampan Yui Kanchalai Tanglertsampan yui T +Kārlis Gaņģis Keith Mashinter kmashint Ken Howard Kevin Lang kimamula # Kenji Imamula +Klaus Meinhardt Kyle Kelley Lorant Pinter Lucien Greathouse @@ -107,6 +116,7 @@ Martin Vseticka Martin Všeticka # Marin Marinov vvakame # Masahiro Wakame Matt McCutchen +MANISH-GIRI # Manish Giri Max Deepfield Micah Zoltu Michael @@ -213,4 +223,6 @@ Tim Perry Vidar Tonaas Fauske Viktor Zozulyak rix # Richard Sentino -rohitverma007 # Rohit Verma \ No newline at end of file +rohitverma007 # Rohit Verma +rdosanjh # Raj Dosanjh +gdh1995 # Dahan Gong \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 08bd7817c79..5d6663ad6d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ branches: only: - master - release-2.1 + - release-2.2 install: - npm uninstall typescript diff --git a/AUTHORS.md b/AUTHORS.md index ae7832176ea..196f5e84542 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -12,13 +12,16 @@ TypeScript is authored by: * Aliaksandr Radzivanovich * Anatoly Ressin * Anders Hejlsberg +* Andreas Martin * Andrej Baran +* Andrew Ochsner * Andrew Z Allen * András Parditka * Andy Hanson * Anil Anar * Anton Khlynovskiy * Anton Tolmachev +* Anubha Mathur * Arnav Singh * Arthur Ozga * Asad Saeeduddin @@ -42,12 +45,14 @@ TypeScript is authored by: * Cotton Hou * Cyrus Najmabadi * Dafrok Zhang +* Dahan Gong * Dan Corder * Dan Quirk * Daniel Hollocher * Daniel Rosenwasser * David Kmenta * David Li +* David Sheldrick * David Souther * Denis Nedelyaev * Dick van den Brink @@ -66,6 +71,7 @@ TypeScript is authored by: * Eyas Sharaiha * Fabian Cook * @falsandtru +* @flowmemo * Frank Wallis * Franklin Tse * František Žiacik @@ -79,6 +85,7 @@ TypeScript is authored by: * Guy Bedford * Harald Niesche * Herrington Darkholme +* Homa Wong * Iain Monro * Ingvar Stepanyan * Isiah Meadows @@ -93,6 +100,7 @@ TypeScript is authored by: * Jeffrey Morlan * Jesse Schalken * Jiri Tobisek +* Joel Day * Joey Wilson * Johannes Rieken * John Vilk @@ -114,10 +122,13 @@ TypeScript is authored by: * Ken Howard * Kenji Imamula * Kevin Lang +* Klaus Meinhardt * Kyle Kelley +* Kārlis Gaņģis * Lorant Pinter * Lucien Greathouse * Lukas Elmer +* Manish Giri * Marin Marinov * Marius Schulz * Martin Vseticka @@ -155,6 +166,7 @@ TypeScript is authored by: * @progre * Punya Biswal * Rado Kirov +* Raj Dosanjh * Richard Knoll * Richard Sentino * Robert Coie diff --git a/Gulpfile.ts b/Gulpfile.ts index 054e99c8003..7e7f05fd9c4 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -41,7 +41,7 @@ const {runTestsInParallel} = mochaParallel; Error.stackTraceLimit = 1000; const cmdLineOptions = minimist(process.argv.slice(2), { - boolean: ["debug", "light", "colors", "lint", "soft"], + boolean: ["debug", "inspect", "light", "colors", "lint", "soft"], string: ["browser", "tests", "host", "reporter", "stackTraceLimit"], alias: { d: "debug", @@ -50,12 +50,14 @@ const cmdLineOptions = minimist(process.argv.slice(2), { r: "reporter", color: "colors", f: "files", - file: "files" + file: "files", + w: "workers", }, default: { soft: false, colors: process.env.colors || process.env.color || true, debug: process.env.debug || process.env.d, + inspect: process.env.inspect, host: process.env.TYPESCRIPT_HOST || process.env.host || "node", browser: process.env.browser || process.env.b || "IE", tests: process.env.test || process.env.tests || process.env.t, @@ -63,6 +65,7 @@ const cmdLineOptions = minimist(process.argv.slice(2), { reporter: process.env.reporter || process.env.r, lint: process.env.lint || true, files: process.env.f || process.env.file || process.env.files || "", + workers: process.env.workerCount || os.cpus().length, } }); @@ -136,6 +139,14 @@ const es2017LibrarySourceMap = es2017LibrarySource.map(function(source) { return { target: "lib." + source, sources: ["header.d.ts", source] }; }); +const esnextLibrarySource = [ + "esnext.asynciterable.d.ts" +]; + +const esnextLibrarySourceMap = esnextLibrarySource.map(function (source) { + return { target: "lib." + source, sources: ["header.d.ts", source] }; +}); + const hostsLibrarySources = ["dom.generated.d.ts", "webworker.importscripts.d.ts", "scripthost.d.ts"]; const librarySourceMap = [ @@ -150,11 +161,12 @@ const librarySourceMap = [ { target: "lib.es2015.d.ts", sources: ["header.d.ts", "es2015.d.ts"] }, { target: "lib.es2016.d.ts", sources: ["header.d.ts", "es2016.d.ts"] }, { target: "lib.es2017.d.ts", sources: ["header.d.ts", "es2017.d.ts"] }, + { target: "lib.esnext.d.ts", sources: ["header.d.ts", "esnext.d.ts"] }, // JavaScript + all host library { target: "lib.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(hostsLibrarySources) }, { target: "lib.es6.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources, "dom.iterable.d.ts") } -].concat(es2015LibrarySourceMap, es2016LibrarySourceMap, es2017LibrarySourceMap); +].concat(es2015LibrarySourceMap, es2016LibrarySourceMap, es2017LibrarySourceMap, esnextLibrarySourceMap); const libraryTargets = librarySourceMap.map(function(f) { return path.join(builtLocalDirectory, f.target); @@ -242,13 +254,14 @@ function needsUpdate(source: string | string[], dest: string | string[]): boolea return true; } +// Doing tsconfig inheritance manually. https://github.com/ivogabe/gulp-typescript/issues/459 +const tsconfigBase = JSON.parse(fs.readFileSync("src/tsconfig-base.json", "utf-8")).compilerOptions; + function getCompilerSettings(base: tsc.Settings, useBuiltCompiler?: boolean): tsc.Settings { const copy: tsc.Settings = {}; - copy.noEmitOnError = true; - copy.noImplicitAny = true; - copy.noImplicitThis = true; - copy.pretty = true; - copy.types = []; + for (const key in tsconfigBase) { + copy[key] = tsconfigBase[key]; + } for (const key in base) { copy[key] = base[key]; } @@ -256,9 +269,6 @@ function getCompilerSettings(base: tsc.Settings, useBuiltCompiler?: boolean): ts if (copy.removeComments === undefined) copy.removeComments = true; copy.newLine = "lf"; } - else { - copy.preserveConstEnums = true; - } if (useBuiltCompiler === true) { copy.typescript = require("./built/local/typescript.js"); } @@ -330,6 +340,7 @@ const builtGeneratedDiagnosticMessagesJSON = path.join(builtLocalDirectory, "dia // processDiagnosticMessages script gulp.task(processDiagnosticMessagesJs, false, [], () => { const settings: tsc.Settings = getCompilerSettings({ + target: "es5", declaration: false, removeComments: true, noResolve: false, @@ -471,7 +482,10 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => { js.pipe(prependCopyright()) .pipe(sourcemaps.write(".")) .pipe(gulp.dest(".")), - dts.pipe(prependCopyright()) + dts.pipe(prependCopyright(/*outputCopyright*/true)) + .pipe(insert.transform((content) => { + return content + "\r\nexport = ts;\r\nexport as namespace ts;"; + })) .pipe(gulp.dest(".")) ]); }); @@ -584,6 +598,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: cleanTestDirs((err) => { if (err) { console.error(err); failWithStatus(err, 1); } const debug = cmdLineOptions["debug"]; + const inspect = cmdLineOptions["inspect"]; const tests = cmdLineOptions["tests"]; const light = cmdLineOptions["light"]; const stackTraceLimit = cmdLineOptions["stackTraceLimit"]; @@ -602,7 +617,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: } while (fs.existsSync(taskConfigsFolder)); fs.mkdirSync(taskConfigsFolder); - workerCount = process.env.workerCount || os.cpus().length; + workerCount = cmdLineOptions["workers"]; } if (tests || light || taskConfigsFolder) { @@ -620,7 +635,10 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: // default timeout is 2sec which really should be enough, but maybe we just need a small amount longer if (!runInParallel) { const args = []; - if (debug) { + if (inspect) { + args.push("--inspect"); + } + if (inspect || debug) { args.push("--debug-brk"); } args.push("-R", reporter); @@ -1015,7 +1033,7 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: cb(); }, (cb) => { files = files.filter(file => fileMatcher.test(file.path)).sort((filea, fileb) => filea.stat.size - fileb.stat.size); - const workerCount = (process.env.workerCount && +process.env.workerCount) || os.cpus().length; + const workerCount = cmdLineOptions["workers"]; for (let i = 0; i < workerCount; i++) { spawnLintWorker(files, finished); } diff --git a/Jakefile.js b/Jakefile.js index 3c26003fdf0..78516f60731 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -6,6 +6,8 @@ var path = require("path"); var child_process = require("child_process"); var fold = require("travis-fold"); var runTestsInParallel = require("./scripts/mocha-parallel").runTestsInParallel; +var ts = require("./lib/typescript"); + // Variables var compilerDirectory = "src/compiler/"; @@ -13,6 +15,7 @@ var servicesDirectory = "src/services/"; var serverDirectory = "src/server/"; var typingsInstallerDirectory = "src/server/typingsInstaller"; var cancellationTokenDirectory = "src/server/cancellationToken"; +var watchGuardDirectory = "src/server/watchGuard"; var harnessDirectory = "src/harness/"; var libraryDirectory = "src/lib/"; var scriptsDirectory = "scripts/"; @@ -34,6 +37,24 @@ if (process.env.path !== undefined) { process.env.PATH = nodeModulesPathPrefix + process.env.PATH; } +function filesFromConfig(configPath) { + var configText = fs.readFileSync(configPath).toString(); + var config = ts.parseConfigFileTextToJson(configPath, configText, /*stripComments*/ true); + if (config.error) { + throw new Error(diagnosticsToString([config.error])); + } + const configFileContent = ts.parseJsonConfigFileContent(config.config, ts.sys, path.dirname(configPath)); + if (configFileContent.errors && configFileContent.errors.length) { + throw new Error(diagnosticsToString(configFileContent.errors)); + } + + return configFileContent.fileNames; + + function diagnosticsToString(s) { + return s.map(function(e) { return ts.flattenDiagnosticMessageText(e.messageText, ts.sys.newLine); }).join(ts.sys.newLine); + } +} + function toNs(diff) { return diff[0] * 1e9 + diff[1]; } @@ -56,180 +77,13 @@ function measure(marker) { console.log("travis_time:end:" + marker.id + ":start=" + toNs(marker.stamp) + ",finish=" + toNs(total) + ",duration=" + toNs(diff) + "\r"); } -var compilerSources = [ - "core.ts", - "performance.ts", - "sys.ts", - "types.ts", - "scanner.ts", - "parser.ts", - "utilities.ts", - "binder.ts", - "checker.ts", - "factory.ts", - "visitor.ts", - "transformers/destructuring.ts", - "transformers/ts.ts", - "transformers/jsx.ts", - "transformers/esnext.ts", - "transformers/es2017.ts", - "transformers/es2016.ts", - "transformers/es2015.ts", - "transformers/generators.ts", - "transformers/es5.ts", - "transformers/module/es2015.ts", - "transformers/module/system.ts", - "transformers/module/module.ts", - "transformer.ts", - "sourcemap.ts", - "comments.ts", - "declarationEmitter.ts", - "emitter.ts", - "program.ts", - "commandLineParser.ts", - "tsc.ts", - "diagnosticInformationMap.generated.ts" -].map(function (f) { - return path.join(compilerDirectory, f); -}); - -var servicesSources = [ - "core.ts", - "performance.ts", - "sys.ts", - "types.ts", - "scanner.ts", - "parser.ts", - "utilities.ts", - "binder.ts", - "checker.ts", - "factory.ts", - "visitor.ts", - "transformers/destructuring.ts", - "transformers/ts.ts", - "transformers/jsx.ts", - "transformers/esnext.ts", - "transformers/es2017.ts", - "transformers/es2016.ts", - "transformers/es2015.ts", - "transformers/generators.ts", - "transformers/es5.ts", - "transformers/module/es2015.ts", - "transformers/module/system.ts", - "transformers/module/module.ts", - "transformer.ts", - "sourcemap.ts", - "comments.ts", - "declarationEmitter.ts", - "emitter.ts", - "program.ts", - "commandLineParser.ts", - "diagnosticInformationMap.generated.ts" -].map(function (f) { - return path.join(compilerDirectory, f); -}).concat([ - "types.ts", - "utilities.ts", - "breakpoints.ts", - "classifier.ts", - "completions.ts", - "documentHighlights.ts", - "documentRegistry.ts", - "findAllReferences.ts", - "goToDefinition.ts", - "goToImplementation.ts", - "jsDoc.ts", - "jsTyping.ts", - "navigateTo.ts", - "navigationBar.ts", - "outliningElementsCollector.ts", - "patternMatcher.ts", - "preProcess.ts", - "rename.ts", - "services.ts", - "shims.ts", - "signatureHelp.ts", - "symbolDisplay.ts", - "transpile.ts", - // Formatting - "formatting/formatting.ts", - "formatting/formattingContext.ts", - "formatting/formattingRequestKind.ts", - "formatting/formattingScanner.ts", - "formatting/references.ts", - "formatting/rule.ts", - "formatting/ruleAction.ts", - "formatting/ruleDescriptor.ts", - "formatting/ruleFlag.ts", - "formatting/ruleOperation.ts", - "formatting/ruleOperationContext.ts", - "formatting/rules.ts", - "formatting/rulesMap.ts", - "formatting/rulesProvider.ts", - "formatting/smartIndenter.ts", - "formatting/tokenRange.ts", - // CodeFixes - "codeFixProvider.ts", - "codefixes/fixes.ts", - "codefixes/fixExtendsInterfaceBecomesImplements.ts", - "codefixes/fixClassIncorrectlyImplementsInterface.ts", - "codefixes/fixClassDoesntImplementInheritedAbstractMember.ts", - "codefixes/fixClassSuperMustPrecedeThisAccess.ts", - "codefixes/fixConstructorForDerivedNeedSuperCall.ts", - "codefixes/helpers.ts", - "codefixes/importFixes.ts", - "codefixes/unusedIdentifierFixes.ts" -].map(function (f) { - return path.join(servicesDirectory, f); -})); - -var serverCoreSources = [ - "types.d.ts", - "shared.ts", - "utilities.ts", - "scriptVersionCache.ts", - "typingsCache.ts", - "scriptInfo.ts", - "lsHost.ts", - "project.ts", - "editorServices.ts", - "protocol.ts", - "session.ts", - "server.ts" -].map(function (f) { - return path.join(serverDirectory, f); -}); - -var cancellationTokenSources = [ - "cancellationToken.ts" -].map(function (f) { - return path.join(cancellationTokenDirectory, f); -}); - -var typingsInstallerSources = [ - "../types.d.ts", - "../shared.ts", - "typingsInstaller.ts", - "nodeTypingsInstaller.ts" -].map(function (f) { - return path.join(typingsInstallerDirectory, f); -}); - -var serverSources = serverCoreSources.concat(servicesSources); - -var languageServiceLibrarySources = [ - "protocol.ts", - "utilities.ts", - "scriptVersionCache.ts", - "scriptInfo.ts", - "lsHost.ts", - "project.ts", - "editorServices.ts", - "session.ts", - -].map(function (f) { - return path.join(serverDirectory, f); -}).concat(servicesSources); +var compilerSources = filesFromConfig("./src/compiler/tsconfig.json"); +var servicesSources = filesFromConfig("./src/services/tsconfig.json"); +var cancellationTokenSources = filesFromConfig(path.join(serverDirectory, "cancellationToken/tsconfig.json")); +var typingsInstallerSources = filesFromConfig(path.join(serverDirectory, "typingsInstaller/tsconfig.json")); +var watchGuardSources = filesFromConfig(path.join(serverDirectory, "watchGuard/tsconfig.json")); +var serverSources = filesFromConfig(path.join(serverDirectory, "tsconfig.json")) +var languageServiceLibrarySources = filesFromConfig(path.join(serverDirectory, "tsconfig.library.json")); var harnessCoreSources = [ "harness.ts", @@ -276,6 +130,9 @@ var harnessSources = harnessCoreSources.concat([ "projectErrors.ts", "matchFiles.ts", "initializeTSConfig.ts", + "printer.ts", + "transform.ts", + "customTransforms.ts", ].map(function (f) { return path.join(unittestsDirectory, f); })).concat([ @@ -317,13 +174,21 @@ var es2016LibrarySourceMap = es2016LibrarySource.map(function (source) { var es2017LibrarySource = [ "es2017.object.d.ts", "es2017.sharedmemory.d.ts", - "es2017.string.d.ts", + "es2017.string.d.ts" ]; var es2017LibrarySourceMap = es2017LibrarySource.map(function (source) { return { target: "lib." + source, sources: ["header.d.ts", source] }; }); +var esnextLibrarySource = [ + "esnext.asynciterable.d.ts" +]; + +var esnextLibrarySourceMap = esnextLibrarySource.map(function (source) { + return { target: "lib." + source, sources: ["header.d.ts", source] }; +}); + var hostsLibrarySources = ["dom.generated.d.ts", "webworker.importscripts.d.ts", "scripthost.d.ts"]; var librarySourceMap = [ @@ -338,11 +203,12 @@ var librarySourceMap = [ { target: "lib.es2015.d.ts", sources: ["header.d.ts", "es2015.d.ts"] }, { target: "lib.es2016.d.ts", sources: ["header.d.ts", "es2016.d.ts"] }, { target: "lib.es2017.d.ts", sources: ["header.d.ts", "es2017.d.ts"] }, + { target: "lib.esnext.d.ts", sources: ["header.d.ts", "esnext.d.ts"] }, // JavaScript + all host library { target: "lib.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(hostsLibrarySources) }, { target: "lib.es6.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources, "dom.iterable.d.ts") } -].concat(es2015LibrarySourceMap, es2016LibrarySourceMap, es2017LibrarySourceMap); +].concat(es2015LibrarySourceMap, es2016LibrarySourceMap, es2017LibrarySourceMap, esnextLibrarySourceMap); var libraryTargets = librarySourceMap.map(function (f) { return path.join(builtLocalDirectory, f.target); @@ -463,7 +329,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts options += " --stripInternal"; } - options += " --target es5 --noUnusedLocals --noUnusedParameters"; + options += " --target es5 --lib es5,scripthost --noUnusedLocals --noUnusedParameters"; var cmd = host + " " + compilerPath + " " + options + " "; cmd = cmd + sources.join(" "); @@ -717,8 +583,11 @@ compileFile(cancellationTokenFile, cancellationTokenSources, [builtLocalDirector var typingsInstallerFile = path.join(builtLocalDirectory, "typingsInstaller.js"); compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: false }); +var watchGuardFile = path.join(builtLocalDirectory, "watchGuard.js"); +compileFile(watchGuardFile, watchGuardSources, [builtLocalDirectory].concat(watchGuardSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: false }); + var serverFile = path.join(builtLocalDirectory, "tsserver.js"); -compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"] }); +compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true }); var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js"); var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts"); compileFile( @@ -727,7 +596,18 @@ compileFile( [builtLocalDirectory, copyright, builtLocalCompiler].concat(languageServiceLibrarySources).concat(libraryTargets), /*prefixes*/[copyright], /*useBuiltCompiler*/ true, - { noOutFile: false, generateDeclarations: true }); + { noOutFile: false, generateDeclarations: true, stripInternal: true, preserveConstEnums: true }, + /*callback*/ function () { + prependFile(copyright, tsserverLibraryDefinitionFile); + + // Appending exports at the end of the server library + var tsserverLibraryDefinitionFileContents = + fs.readFileSync(tsserverLibraryDefinitionFile).toString() + + "\r\nexport = ts;" + + "\r\nexport as namespace ts;"; + + fs.writeFileSync(tsserverLibraryDefinitionFile, tsserverLibraryDefinitionFileContents); + }); // Local target to build the language service server library desc("Builds language service server library"); @@ -801,7 +681,7 @@ task("generate-spec", [specMd]); // Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory desc("Makes a new LKG out of the built js files"); task("LKG", ["clean", "release", "local"].concat(libraryTargets), function () { - var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile, cancellationTokenFile, typingsInstallerFile, buildProtocolDts].concat(libraryTargets); + var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile, cancellationTokenFile, typingsInstallerFile, buildProtocolDts, watchGuardFile].concat(libraryTargets); var missingFiles = expectedFiles.filter(function (f) { return !fs.existsSync(f); }); @@ -914,6 +794,7 @@ function runConsoleTests(defaultReporter, runInParallel) { } var debug = process.env.debug || process.env.d; + var inspect = process.env.inspect; tests = process.env.test || process.env.tests || process.env.t; var light = process.env.light || false; var stackTraceLimit = process.env.stackTraceLimit; @@ -943,18 +824,39 @@ function runConsoleTests(defaultReporter, runInParallel) { testTimeout = 800000; } - colors = process.env.colors || process.env.color; - colors = colors ? ' --no-colors ' : ' --colors '; - reporter = process.env.reporter || process.env.r || defaultReporter; - var bail = (process.env.bail || process.env.b) ? "--bail" : ""; + var colors = process.env.colors || process.env.color || true; + var reporter = process.env.reporter || process.env.r || defaultReporter; + var bail = process.env.bail || process.env.b; var lintFlag = process.env.lint !== 'false'; // timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally // default timeout is 2sec which really should be enough, but maybe we just need a small amount longer if (!runInParallel) { var startTime = mark(); - tests = tests ? ' -g "' + tests + '"' : ''; - var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + bail + ' -t ' + testTimeout + ' ' + run; + var args = []; + if (inspect) { + args.push("--inspect"); + } + if (inspect || debug) { + args.push("--debug-brk"); + } + args.push("-R", reporter); + if (tests) { + args.push("-g", `"${tests}"`); + } + if (colors) { + args.push("--colors"); + } + else { + args.push("--no-colors"); + } + if (bail) { + args.push("--bail"); + } + args.push("-t", testTimeout); + args.push(run); + + var cmd = "mocha " + args.join(" "); console.log(cmd); var savedNodeEnv = process.env.NODE_ENV; @@ -975,7 +877,7 @@ function runConsoleTests(defaultReporter, runInParallel) { var savedNodeEnv = process.env.NODE_ENV; process.env.NODE_ENV = "development"; var startTime = mark(); - runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: colors === " --no-colors " }, function (err) { + runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: !colors }, function (err) { process.env.NODE_ENV = savedNodeEnv; measure(startTime); // last worker clean everything and runs linter in case if there were no errors @@ -1225,13 +1127,16 @@ var lintTargets = compilerSources .concat(harnessSources) // Other harness sources .concat(["instrumenter.ts"].map(function (f) { return path.join(harnessDirectory, f) })) - .concat(serverCoreSources) + .concat(serverSources) .concat(tslintRulesFiles) .concat(servicesSources) .concat(typingsInstallerSources) .concat(cancellationTokenSources) .concat(["Gulpfile.ts"]) - .concat([nodeServerInFile, perftscPath, "tests/perfsys.ts", webhostPath]); + .concat([nodeServerInFile, perftscPath, "tests/perfsys.ts", webhostPath]) + .map(function (p) { return path.resolve(p) }); +// keep only unique items +lintTargets = Array.from(new Set(lintTargets)); function sendNextFile(files, child, callback, failures) { var file = files.pop(); diff --git a/lib/cancellationToken.js b/lib/cancellationToken.js index 003999d2e8a..378255a37ee 100644 --- a/lib/cancellationToken.js +++ b/lib/cancellationToken.js @@ -15,6 +15,15 @@ and limitations under the License. "use strict"; var fs = require("fs"); +function pipeExists(name) { + try { + fs.statSync(name); + return true; + } + catch (e) { + return false; + } +} function createCancellationToken(args) { var cancellationPipeName; for (var i = 0; i < args.length - 1; i++) { @@ -24,18 +33,39 @@ function createCancellationToken(args) { } } if (!cancellationPipeName) { - return { isCancellationRequested: function () { return false; } }; + return { + isCancellationRequested: function () { return false; }, + setRequest: function (_requestId) { return void 0; }, + resetRequest: function (_requestId) { return void 0; } + }; } - return { - isCancellationRequested: function () { - try { - fs.statSync(cancellationPipeName); - return true; - } - catch (e) { - return false; - } + if (cancellationPipeName.charAt(cancellationPipeName.length - 1) === "*") { + var namePrefix_1 = cancellationPipeName.slice(0, -1); + if (namePrefix_1.length === 0 || namePrefix_1.indexOf("*") >= 0) { + throw new Error("Invalid name for template cancellation pipe: it should have length greater than 2 characters and contain only one '*'."); } - }; + var perRequestPipeName_1; + var currentRequestId_1; + return { + isCancellationRequested: function () { return perRequestPipeName_1 !== undefined && pipeExists(perRequestPipeName_1); }, + setRequest: function (requestId) { + currentRequestId_1 = currentRequestId_1; + perRequestPipeName_1 = namePrefix_1 + requestId; + }, + resetRequest: function (requestId) { + if (currentRequestId_1 !== requestId) { + throw new Error("Mismatched request id, expected " + currentRequestId_1 + ", actual " + requestId); + } + perRequestPipeName_1 = undefined; + } + }; + } + else { + return { + isCancellationRequested: function () { return pipeExists(cancellationPipeName); }, + setRequest: function (_requestId) { return void 0; }, + resetRequest: function (_requestId) { return void 0; } + }; + } } module.exports = createCancellationToken; diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 5b1f3d7c393..126e5d82ac4 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -157,23 +157,17 @@ interface ObjectConstructor { getOwnPropertyNames(o: any): string[]; /** - * Creates an object that has null prototype. - * @param o Object to use as a prototype. May be null + * Creates an object that has the specified prototype or that has null prototype. + * @param o Object to use as a prototype. May be null. */ - create(o: null): any; - - /** - * Creates an object that has the specified prototype, and that optionally contains specified properties. - * @param o Object to use as a prototype. May be null - */ - create(o: T): T; + create(o: T | null): T | object; /** * Creates an object that has the specified prototype, and that optionally contains specified properties. * @param o Object to use as a prototype. May be null * @param properties JavaScript object that contains one or more property descriptors. */ - create(o: any, properties: PropertyDescriptorMap): any; + create(o: object | null, properties: PropertyDescriptorMap): any; /** * Adds a property to an object, or modifies attributes of an existing property. @@ -361,14 +355,14 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string that represents the regular expression. + * @param searchValue A string to search for. * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string that represents the regular expression. + * @param searchValue A string to search for. * @param replacer A function that returns the replacement text. */ replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; @@ -1191,8 +1185,9 @@ interface Array { /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. */ - splice(start: number): T[]; + splice(start: number, deleteCount?: number): T[]; /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. @@ -1335,39 +1330,27 @@ interface PromiseLike { * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ - then( - onfulfilled?: ((value: T) => T | PromiseLike) | undefined | null, - onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): PromiseLike; + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): PromiseLike; +} +/** + * Represents the completion of an asynchronous operation + */ +interface Promise { /** * Attaches callbacks for the resolution and/or rejection of the Promise. * @param onfulfilled The callback to execute when the Promise is resolved. * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ - then( - onfulfilled: ((value: T) => T | PromiseLike) | undefined | null, - onrejected: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Promise; /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. + * Attaches a callback for only the rejection of the Promise. * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. + * @returns A Promise for the completion of the callback. */ - then( - onfulfilled: (value: T) => TResult | PromiseLike, - onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): PromiseLike; - - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then( - onfulfilled: (value: T) => TResult1 | PromiseLike, - onrejected: (reason: any) => TResult2 | PromiseLike): PromiseLike; + catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; } interface ArrayLike { @@ -4200,18 +4183,50 @@ interface Date { /// IE DOM APIs ///////////////////////////// +interface Account { + rpDisplayName?: string; + displayName?: string; + id?: string; + name?: string; + imageURL?: string; +} + interface Algorithm { name: string; } -interface AriaRequestEventInit extends EventInit { - attributeName?: string; - attributeValue?: string; +interface AnimationEventInit extends EventInit { + animationName?: string; + elapsedTime?: number; } -interface CommandEventInit extends EventInit { - commandName?: string; - detail?: string; +interface AssertionOptions { + timeoutSeconds?: number; + rpId?: USVString; + allowList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface CacheQueryOptions { + ignoreSearch?: boolean; + ignoreMethod?: boolean; + ignoreVary?: boolean; + cacheName?: string; +} + +interface ClientData { + challenge?: string; + origin?: string; + rpId?: string; + hashAlg?: string | Algorithm; + tokenBinding?: string; + extensions?: WebAuthnExtensions; +} + +interface CloseEventInit extends EventInit { + wasClean?: boolean; + code?: number; + reason?: string; } interface CompositionEventInit extends UIEventInit { @@ -4251,6 +4266,13 @@ interface CustomEventInit extends EventInit { detail?: any; } +interface DOMRectInit { + x?: any; + y?: any; + width?: any; + height?: any; +} + interface DeviceAccelerationDict { x?: number; y?: number; @@ -4261,6 +4283,20 @@ interface DeviceLightEventInit extends EventInit { value?: number; } +interface DeviceMotionEventInit extends EventInit { + acceleration?: DeviceAccelerationDict; + accelerationIncludingGravity?: DeviceAccelerationDict; + rotationRate?: DeviceRotationRateDict; + interval?: number; +} + +interface DeviceOrientationEventInit extends EventInit { + alpha?: number; + beta?: number; + gamma?: number; + absolute?: boolean; +} + interface DeviceRotationRateDict { alpha?: number; beta?: number; @@ -4272,6 +4308,14 @@ interface DoubleRange { min?: number; } +interface ErrorEventInit extends EventInit { + message?: string; + filename?: string; + lineno?: number; + colno?: number; + error?: any; +} + interface EventInit { scoped?: boolean; bubbles?: boolean; @@ -4304,6 +4348,29 @@ interface FocusEventInit extends UIEventInit { relatedTarget?: EventTarget; } +interface FocusNavigationEventInit extends EventInit { + navigationReason?: string; + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface FocusNavigationOrigin { + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface GamepadEventInit extends EventInit { + gamepad?: Gamepad; +} + +interface GetNotificationOptions { + tag?: string; +} + interface HashChangeEventInit extends EventInit { newURL?: string; oldURL?: string; @@ -4319,6 +4386,20 @@ interface IDBObjectStoreParameters { keyPath?: IDBKeyPath; } +interface IntersectionObserverEntryInit { + time?: number; + rootBounds?: DOMRectInit; + boundingClientRect?: DOMRectInit; + intersectionRect?: DOMRectInit; + target?: Element; +} + +interface IntersectionObserverInit { + root?: Element; + rootMargin?: string; + threshold?: number | number[]; +} + interface KeyAlgorithm { name?: string; } @@ -4521,6 +4602,11 @@ interface MSPayloadBase extends RTCStats { payloadDescription?: string; } +interface MSPortRange { + min?: number; + max?: number; +} + interface MSRelayAddress { relayAddress?: string; port?: number; @@ -4571,7 +4657,7 @@ interface MSUtilization { } interface MSVideoPayload extends MSPayloadBase { - resoluton?: string; + resolution?: string; videoBitRateAvg?: number; videoBitRateMax?: number; videoFrameRateAvg?: number; @@ -4654,6 +4740,10 @@ interface MediaStreamErrorEventInit extends EventInit { error?: MediaStreamError; } +interface MediaStreamEventInit extends EventInit { + stream?: MediaStream; +} + interface MediaStreamTrackEventInit extends EventInit { track?: MediaStreamTrack; } @@ -4718,6 +4808,15 @@ interface MediaTrackSupportedConstraints { groupId?: boolean; } +interface MessageEventInit extends EventInit { + lastEventId?: string; + channel?: string; + data?: any; + origin?: string; + source?: Window; + ports?: MessagePort[]; +} + interface MouseEventInit extends EventModifierInit { screenX?: number; screenY?: number; @@ -4747,10 +4846,68 @@ interface MutationObserverInit { attributeFilter?: string[]; } +interface NotificationOptions { + dir?: string; + lang?: string; + body?: string; + tag?: string; + icon?: string; +} + interface ObjectURLOptions { oneTimeOnly?: boolean; } +interface PaymentCurrencyAmount { + currency?: string; + value?: string; + currencySystem?: string; +} + +interface PaymentDetails { + total?: PaymentItem; + displayItems?: PaymentItem[]; + shippingOptions?: PaymentShippingOption[]; + modifiers?: PaymentDetailsModifier[]; + error?: string; +} + +interface PaymentDetailsModifier { + supportedMethods?: string[]; + total?: PaymentItem; + additionalDisplayItems?: PaymentItem[]; + data?: any; +} + +interface PaymentItem { + label?: string; + amount?: PaymentCurrencyAmount; + pending?: boolean; +} + +interface PaymentMethodData { + supportedMethods?: string[]; + data?: any; +} + +interface PaymentOptions { + requestPayerName?: boolean; + requestPayerEmail?: boolean; + requestPayerPhone?: boolean; + requestShipping?: boolean; + shippingType?: string; +} + +interface PaymentRequestUpdateEventInit extends EventInit { +} + +interface PaymentShippingOption { + id?: string; + label?: string; + amount?: PaymentCurrencyAmount; + selected?: boolean; +} + interface PeriodicWaveConstraints { disableNormalization?: boolean; } @@ -4766,12 +4923,34 @@ interface PointerEventInit extends MouseEventInit { isPrimary?: boolean; } +interface PopStateEventInit extends EventInit { + state?: any; +} + interface PositionOptions { enableHighAccuracy?: boolean; timeout?: number; maximumAge?: number; } +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + +interface PushSubscriptionOptionsInit { + userVisibleOnly?: boolean; + applicationServerKey?: any; +} + +interface RTCConfiguration { + iceServers?: RTCIceServer[]; + iceTransportPolicy?: string; + bundlePolicy?: string; + peerIdentity?: string; +} + interface RTCDTMFToneChangeEventInit extends EventInit { tone?: string; } @@ -4786,18 +4965,6 @@ interface RTCDtlsParameters { fingerprints?: RTCDtlsFingerprint[]; } -interface RTCIceCandidate { - foundation?: string; - priority?: number; - ip?: string; - protocol?: string; - port?: number; - type?: string; - tcpType?: string; - relatedAddress?: string; - relatedPort?: number; -} - interface RTCIceCandidateAttributes extends RTCStats { ipAddress?: string; portNumber?: number; @@ -4810,9 +4977,28 @@ interface RTCIceCandidateAttributes extends RTCStats { interface RTCIceCandidateComplete { } +interface RTCIceCandidateDictionary { + foundation?: string; + priority?: number; + ip?: string; + protocol?: string; + port?: number; + type?: string; + tcpType?: string; + relatedAddress?: string; + relatedPort?: number; + msMTurnSessionId?: string; +} + +interface RTCIceCandidateInit { + candidate?: string; + sdpMid?: string; + sdpMLineIndex?: number; +} + interface RTCIceCandidatePair { - local?: RTCIceCandidate; - remote?: RTCIceCandidate; + local?: RTCIceCandidateDictionary; + remote?: RTCIceCandidateDictionary; } interface RTCIceCandidatePairStats extends RTCStats { @@ -4834,11 +5020,13 @@ interface RTCIceCandidatePairStats extends RTCStats { interface RTCIceGatherOptions { gatherPolicy?: string; iceservers?: RTCIceServer[]; + portRange?: MSPortRange; } interface RTCIceParameters { usernameFragment?: string; password?: string; + iceLite?: boolean; } interface RTCIceServer { @@ -4872,6 +5060,13 @@ interface RTCMediaStreamTrackStats extends RTCStats { echoReturnLossEnhancement?: number; } +interface RTCOfferOptions { + offerToReceiveVideo?: number; + offerToReceiveAudio?: number; + voiceActivityDetection?: boolean; + iceRestart?: boolean; +} + interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { packetsSent?: number; bytesSent?: number; @@ -4879,6 +5074,10 @@ interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { roundTripTime?: number; } +interface RTCPeerConnectionIceEventInit extends EventInit { + candidate?: RTCIceCandidate; +} + interface RTCRTPStreamStats extends RTCStats { ssrc?: string; associateStatsId?: string; @@ -4916,6 +5115,7 @@ interface RTCRtpCodecCapability { clockRate?: number; preferredPayloadType?: number; maxptime?: number; + ptime?: number; numChannels?: number; rtcpFeedback?: RTCRtcpFeedback[]; parameters?: any; @@ -4930,6 +5130,7 @@ interface RTCRtpCodecParameters { payloadType?: any; clockRate?: number; maxptime?: number; + ptime?: number; numChannels?: number; rtcpFeedback?: RTCRtcpFeedback[]; parameters?: any; @@ -4949,9 +5150,9 @@ interface RTCRtpEncodingParameters { priority?: number; maxBitrate?: number; minQuality?: number; - framerateBias?: number; resolutionScale?: number; framerateScale?: number; + maxFramerate?: number; active?: boolean; encodingId?: string; dependencyEncodingIds?: string[]; @@ -4982,6 +5183,7 @@ interface RTCRtpParameters { headerExtensions?: RTCRtpHeaderExtensionParameters[]; encodings?: RTCRtpEncodingParameters[]; rtcp?: RTCRtcpParameters; + degradationPreference?: string; } interface RTCRtpRtxParameters { @@ -4994,6 +5196,11 @@ interface RTCRtpUnhandled { muxId?: string; } +interface RTCSessionDescriptionInit { + type?: string; + sdp?: string; +} + interface RTCSrtpKeyParam { keyMethod?: string; keySalt?: string; @@ -5034,6 +5241,64 @@ interface RTCTransportStats extends RTCStats { remoteCertificateId?: string; } +interface RegistrationOptions { + scope?: string; +} + +interface RequestInit { + method?: string; + headers?: any; + body?: any; + referrer?: string; + referrerPolicy?: string; + mode?: string; + credentials?: string; + cache?: string; + redirect?: string; + integrity?: string; + keepalive?: boolean; + window?: any; +} + +interface ResponseInit { + status?: number; + statusText?: string; + headers?: any; +} + +interface ScopedCredentialDescriptor { + type?: string; + id?: any; + transports?: string[]; +} + +interface ScopedCredentialOptions { + timeoutSeconds?: number; + rpId?: USVString; + excludeList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface ScopedCredentialParameters { + type?: string; + algorithm?: string | Algorithm; +} + +interface ServiceWorkerMessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + source?: ServiceWorker | MessagePort; + ports?: MessagePort[]; +} + +interface SpeechSynthesisEventInit extends EventInit { + utterance?: SpeechSynthesisUtterance; + charIndex?: number; + elapsedTime?: number; + name?: string; +} + interface StoreExceptionsInformation extends ExceptionInformation { siteName?: string; explanationString?: string; @@ -5044,11 +5309,23 @@ interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformat arrayOfDomainStrings?: string[]; } +interface TrackEventInit extends EventInit { + track?: VideoTrack | AudioTrack | TextTrack; +} + +interface TransitionEventInit extends EventInit { + propertyName?: string; + elapsedTime?: number; +} + interface UIEventInit extends EventInit { view?: Window; detail?: number; } +interface WebAuthnExtensions { +} + interface WebGLContextAttributes { failIfMajorPerformanceCaveat?: boolean; alpha?: boolean; @@ -5074,6 +5351,18 @@ interface EventListener { (evt: Event): void; } +interface WebKitEntriesCallback { + (evt: Event): void; +} + +interface WebKitErrorCallback { + (evt: Event): void; +} + +interface WebKitFileCallback { + (evt: Event): void; +} + interface ANGLE_instanced_arrays { drawArraysInstancedANGLE(mode: number, first: number, count: number, primcount: number): void; drawElementsInstancedANGLE(mode: number, count: number, type: number, offset: number, primcount: number): void; @@ -5112,14 +5401,14 @@ interface AnimationEvent extends Event { declare var AnimationEvent: { prototype: AnimationEvent; - new(): AnimationEvent; + new(typeArg: string, eventInitDict?: AnimationEventInit): AnimationEvent; } interface ApplicationCacheEventMap { "cached": Event; "checking": Event; "downloading": Event; - "error": ErrorEvent; + "error": Event; "noupdate": Event; "obsolete": Event; "progress": ProgressEvent; @@ -5130,7 +5419,7 @@ interface ApplicationCache extends EventTarget { oncached: (this: ApplicationCache, ev: Event) => any; onchecking: (this: ApplicationCache, ev: Event) => any; ondownloading: (this: ApplicationCache, ev: Event) => any; - onerror: (this: ApplicationCache, ev: ErrorEvent) => any; + onerror: (this: ApplicationCache, ev: Event) => any; onnoupdate: (this: ApplicationCache, ev: Event) => any; onobsolete: (this: ApplicationCache, ev: Event) => any; onprogress: (this: ApplicationCache, ev: ProgressEvent) => any; @@ -5160,16 +5449,6 @@ declare var ApplicationCache: { readonly UPDATEREADY: number; } -interface AriaRequestEvent extends Event { - readonly attributeName: string; - attributeValue: string | null; -} - -declare var AriaRequestEvent: { - prototype: AriaRequestEvent; - new(type: string, eventInitDict?: AriaRequestEventInit): AriaRequestEvent; -} - interface Attr extends Node { readonly name: string; readonly ownerElement: Element; @@ -5221,12 +5500,18 @@ declare var AudioBufferSourceNode: { new(): AudioBufferSourceNode; } -interface AudioContext extends EventTarget { +interface AudioContextEventMap { + "statechange": Event; +} + +interface AudioContextBase extends EventTarget { readonly currentTime: number; readonly destination: AudioDestinationNode; readonly listener: AudioListener; + onstatechange: (this: AudioContext, ev: Event) => any; readonly sampleRate: number; - state: string; + readonly state: string; + close(): Promise; createAnalyser(): AnalyserNode; createBiquadFilter(): BiquadFilterNode; createBuffer(numberOfChannels: number, length: number, sampleRate: number): AudioBuffer; @@ -5237,6 +5522,7 @@ interface AudioContext extends EventTarget { createDelay(maxDelayTime?: number): DelayNode; createDynamicsCompressor(): DynamicsCompressorNode; createGain(): GainNode; + createIIRFilter(feedforward: number[], feedback: number[]): IIRFilterNode; createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; createMediaStreamSource(mediaStream: MediaStream): MediaStreamAudioSourceNode; createOscillator(): OscillatorNode; @@ -5245,7 +5531,14 @@ interface AudioContext extends EventTarget { createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; createStereoPanner(): StereoPannerNode; createWaveShaper(): WaveShaperNode; - decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): PromiseLike; + decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): Promise; + resume(): Promise; + addEventListener(type: K, listener: (this: AudioContext, ev: AudioContextEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface AudioContext extends AudioContextBase { + suspend(): Promise; } declare var AudioContext: { @@ -5282,7 +5575,7 @@ interface AudioNode extends EventTarget { readonly context: AudioContext; readonly numberOfInputs: number; readonly numberOfOutputs: number; - connect(destination: AudioNode, output?: number, input?: number): void; + connect(destination: AudioNode, output?: number, input?: number): AudioNode; disconnect(output?: number): void; disconnect(destination: AudioNode, output?: number, input?: number): void; disconnect(destination: AudioParam, output?: number): void; @@ -5296,12 +5589,12 @@ declare var AudioNode: { interface AudioParam { readonly defaultValue: number; value: number; - cancelScheduledValues(startTime: number): void; - exponentialRampToValueAtTime(value: number, endTime: number): void; - linearRampToValueAtTime(value: number, endTime: number): void; - setTargetAtTime(target: number, startTime: number, timeConstant: number): void; - setValueAtTime(value: number, startTime: number): void; - setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): void; + cancelScheduledValues(startTime: number): AudioParam; + exponentialRampToValueAtTime(value: number, endTime: number): AudioParam; + linearRampToValueAtTime(value: number, endTime: number): AudioParam; + setTargetAtTime(target: number, startTime: number, timeConstant: number): AudioParam; + setValueAtTime(value: number, startTime: number): AudioParam; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): AudioParam; } declare var AudioParam: { @@ -5678,10 +5971,16 @@ interface CSSStyleDeclaration { imeMode: string | null; justifyContent: string | null; kerning: string | null; + layoutGrid: string | null; + layoutGridChar: string | null; + layoutGridLine: string | null; + layoutGridMode: string | null; + layoutGridType: string | null; left: string | null; readonly length: number; letterSpacing: string | null; lightingColor: string | null; + lineBreak: string | null; lineHeight: string | null; listStyle: string | null; listStyleImage: string | null; @@ -5753,6 +6052,7 @@ interface CSSStyleDeclaration { orphans: string | null; outline: string | null; outlineColor: string | null; + outlineOffset: string | null; outlineStyle: string | null; outlineWidth: string | null; overflow: string | null; @@ -5773,9 +6073,11 @@ interface CSSStyleDeclaration { position: string | null; quotes: string | null; right: string | null; + rotate: string | null; rubyAlign: string | null; rubyOverhang: string | null; rubyPosition: string | null; + scale: string | null; stopColor: string | null; stopOpacity: string | null; stroke: string | null; @@ -5809,6 +6111,7 @@ interface CSSStyleDeclaration { transitionDuration: string | null; transitionProperty: string | null; transitionTimingFunction: string | null; + translate: string | null; unicodeBidi: string | null; verticalAlign: string | null; visibility: string | null; @@ -5869,6 +6172,9 @@ interface CSSStyleDeclaration { webkitTapHighlightColor: string | null; webkitTextFillColor: string | null; webkitTextSizeAdjust: any; + webkitTextStroke: string | null; + webkitTextStrokeColor: string | null; + webkitTextStrokeWidth: string | null; webkitTransform: string | null; webkitTransformOrigin: string | null; webkitTransformStyle: string | null; @@ -5890,6 +6196,7 @@ interface CSSStyleDeclaration { zIndex: string | null; zoom: string | null; resize: string | null; + userSelect: string | null; getPropertyPriority(propertyName: string): string; getPropertyValue(propertyName: string): string; item(index: number): string; @@ -5917,7 +6224,6 @@ declare var CSSStyleRule: { interface CSSStyleSheet extends StyleSheet { readonly cssRules: CSSRuleList; cssText: string; - readonly href: string; readonly id: string; readonly imports: StyleSheetList; readonly isAlternate: boolean; @@ -5949,6 +6255,34 @@ declare var CSSSupportsRule: { new(): CSSSupportsRule; } +interface Cache { + add(request: RequestInfo): Promise; + addAll(requests: RequestInfo[]): Promise; + delete(request: RequestInfo, options?: CacheQueryOptions): Promise; + keys(request?: RequestInfo, options?: CacheQueryOptions): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + put(request: RequestInfo, response: Response): Promise; +} + +declare var Cache: { + prototype: Cache; + new(): Cache; +} + +interface CacheStorage { + delete(cacheName: string): Promise; + has(cacheName: string): Promise; + keys(): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + open(cacheName: string): Promise; +} + +declare var CacheStorage: { + prototype: CacheStorage; + new(): CacheStorage; +} + interface CanvasGradient { addColorStop(offset: number, color: string): void; } @@ -5973,13 +6307,13 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { font: string; globalAlpha: number; globalCompositeOperation: string; + imageSmoothingEnabled: boolean; lineCap: string; lineDashOffset: number; lineJoin: string; lineWidth: number; miterLimit: number; msFillRule: string; - msImageSmoothingEnabled: boolean; shadowBlur: number; shadowColor: string; shadowOffsetX: number; @@ -5997,6 +6331,7 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; + drawFocusIfNeeded(element: Element): void; drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; fill(fillRule?: string): void; fillRect(x: number, y: number, w: number, h: number): void; @@ -6012,7 +6347,7 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { scale(x: number, y: number): void; setLineDash(segments: number[]): void; setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; - stroke(): void; + stroke(path?: Path2D): void; strokeRect(x: number, y: number, w: number, h: number): void; strokeText(text: string, x: number, y: number, maxWidth?: number): void; transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; @@ -6098,17 +6433,7 @@ interface CloseEvent extends Event { declare var CloseEvent: { prototype: CloseEvent; - new(): CloseEvent; -} - -interface CommandEvent extends Event { - readonly commandName: string; - readonly detail: string | null; -} - -declare var CommandEvent: { - prototype: CommandEvent; - new(type: string, eventInitDict?: CommandEventInit): CommandEvent; + new(typeArg: string, eventInitDict?: CloseEventInit): CloseEvent; } interface Comment extends CharacterData { @@ -6135,7 +6460,7 @@ interface Console { assert(test?: boolean, message?: string, ...optionalParams: any[]): void; clear(): void; count(countTitle?: string): void; - debug(message?: string, ...optionalParams: any[]): void; + debug(message?: any, ...optionalParams: any[]): void; dir(value?: any, ...optionalParams: any[]): void; dirxml(value: any): void; error(message?: any, ...optionalParams: any[]): void; @@ -6305,9 +6630,9 @@ declare var DOMException: { interface DOMImplementation { createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType): Document; - createDocumentType(qualifiedName: string, publicId: string | null, systemId: string | null): DocumentType; + createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; createHTMLDocument(title: string): Document; - hasFeature(feature: string | null, version: string | null): boolean; + hasFeature(): boolean; } declare var DOMImplementation: { @@ -6346,7 +6671,7 @@ declare var DOMStringList: { } interface DOMStringMap { - [name: string]: string; + [name: string]: string | undefined; } declare var DOMStringMap: { @@ -6372,7 +6697,7 @@ declare var DOMTokenList: { interface DataCue extends TextTrackCue { data: ArrayBuffer; - addEventListener(type: K, listener: (this: TextTrackCue, ev: TextTrackCueEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: DataCue, ev: TextTrackCueEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6402,6 +6727,7 @@ interface DataTransferItem { readonly type: string; getAsFile(): File | null; getAsString(_callback: FunctionStringCallback | null): void; + webkitGetAsEntry(): any; } declare var DataTransferItem: { @@ -6462,7 +6788,7 @@ interface DeviceLightEvent extends Event { declare var DeviceLightEvent: { prototype: DeviceLightEvent; - new(type: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; + new(typeArg: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; } interface DeviceMotionEvent extends Event { @@ -6475,7 +6801,7 @@ interface DeviceMotionEvent extends Event { declare var DeviceMotionEvent: { prototype: DeviceMotionEvent; - new(): DeviceMotionEvent; + new(typeArg: string, eventInitDict?: DeviceMotionEventInit): DeviceMotionEvent; } interface DeviceOrientationEvent extends Event { @@ -6488,7 +6814,7 @@ interface DeviceOrientationEvent extends Event { declare var DeviceOrientationEvent: { prototype: DeviceOrientationEvent; - new(): DeviceOrientationEvent; + new(typeArg: string, eventInitDict?: DeviceOrientationEventInit): DeviceOrientationEvent; } interface DeviceRotationRate { @@ -6570,7 +6896,7 @@ interface DocumentEventMap extends GlobalEventHandlersEventMap { "pointerlockerror": Event; "progress": ProgressEvent; "ratechange": Event; - "readystatechange": ProgressEvent; + "readystatechange": Event; "reset": Event; "scroll": UIEvent; "seeked": Event; @@ -6641,10 +6967,6 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven readonly compatMode: string; cookie: string; readonly currentScript: HTMLScriptElement | SVGScriptElement; - /** - * Gets the default character set from the current regional language settings. - */ - readonly defaultCharset: string; readonly defaultView: Window; /** * Sets or gets a value that indicates whether the document can be edited. @@ -6951,7 +7273,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Fires when the state of the object has changed. * @param ev The event */ - onreadystatechange: (this: Document, ev: ProgressEvent) => any; + onreadystatechange: (this: Document, ev: Event) => any; /** * Fires when the user resets a form. * @param ev The event. @@ -7319,8 +7641,8 @@ interface DocumentType extends Node, ChildNode { readonly internalSubset: string | null; readonly name: string; readonly notations: NamedNodeMap; - readonly publicId: string | null; - readonly systemId: string | null; + readonly publicId: string; + readonly systemId: string; } declare var DocumentType: { @@ -7343,7 +7665,7 @@ interface DynamicsCompressorNode extends AudioNode { readonly attack: AudioParam; readonly knee: AudioParam; readonly ratio: AudioParam; - readonly reduction: AudioParam; + readonly reduction: number; readonly release: AudioParam; readonly threshold: AudioParam; } @@ -7374,8 +7696,8 @@ declare var EXT_texture_filter_anisotropic: { } interface ElementEventMap extends GlobalEventHandlersEventMap { - "ariarequest": AriaRequestEvent; - "command": CommandEvent; + "ariarequest": Event; + "command": Event; "gotpointercapture": PointerEvent; "lostpointercapture": PointerEvent; "MSGestureChange": MSGestureEvent; @@ -7411,10 +7733,11 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec readonly clientTop: number; readonly clientWidth: number; id: string; + innerHTML: string; msContentZoomFactor: number; readonly msRegionOverflow: string; - onariarequest: (this: Element, ev: AriaRequestEvent) => any; - oncommand: (this: Element, ev: CommandEvent) => any; + onariarequest: (this: Element, ev: Event) => any; + oncommand: (this: Element, ev: Event) => any; ongotpointercapture: (this: Element, ev: PointerEvent) => any; onlostpointercapture: (this: Element, ev: PointerEvent) => any; onmsgesturechange: (this: Element, ev: MSGestureEvent) => any; @@ -7440,13 +7763,13 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec ontouchstart: (ev: TouchEvent) => any; onwebkitfullscreenchange: (this: Element, ev: Event) => any; onwebkitfullscreenerror: (this: Element, ev: Event) => any; + outerHTML: string; readonly prefix: string | null; readonly scrollHeight: number; scrollLeft: number; scrollTop: number; readonly scrollWidth: number; readonly tagName: string; - innerHTML: string; readonly assignedSlot: HTMLSlotElement | null; slot: string; readonly shadowRoot: ShadowRoot | null; @@ -7470,7 +7793,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec msSetPointerCapture(pointerId: number): void; msZoomTo(args: MsZoomToOptions): void; releasePointerCapture(pointerId: number): void; - removeAttribute(name?: string): void; + removeAttribute(qualifiedName: string): void; removeAttributeNS(namespaceURI: string, localName: string): void; removeAttributeNode(oldAttr: Attr): Attr; requestFullscreen(): void; @@ -7517,7 +7840,7 @@ interface ErrorEvent extends Event { declare var ErrorEvent: { prototype: ErrorEvent; - new(): ErrorEvent; + new(type: string, errorEventInitDict?: ErrorEventInit): ErrorEvent; } interface Event { @@ -7546,7 +7869,7 @@ interface Event { declare var Event: { prototype: Event; - new(type: string, eventInitDict?: EventInit): Event; + new(typeArg: string, eventInitDict?: EventInit): Event; readonly AT_TARGET: number; readonly BUBBLING_PHASE: number; readonly CAPTURING_PHASE: number; @@ -7563,6 +7886,21 @@ declare var EventTarget: { new(): EventTarget; } +interface ExtensionScriptApis { + extensionIdToShortId(extensionId: string): number; + fireExtensionApiTelemetry(functionName: string, isSucceeded: boolean, isSupported: boolean): void; + genericFunction(routerAddress: any, parameters?: string, callbackId?: number): void; + genericSynchronousFunction(functionId: number, parameters?: string): string; + getExtensionId(): string; + registerGenericFunctionCallbackHandler(callbackHandler: any): void; + registerGenericPersistentCallbackHandler(callbackHandler: any): void; +} + +declare var ExtensionScriptApis: { + prototype: ExtensionScriptApis; + new(): ExtensionScriptApis; +} + interface External { } @@ -7599,7 +7937,7 @@ interface FileReader extends EventTarget, MSBaseReader { readAsBinaryString(blob: Blob): void; readAsDataURL(blob: Blob): void; readAsText(blob: Blob, encoding?: string): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7618,6 +7956,20 @@ declare var FocusEvent: { new(typeArg: string, eventInitDict?: FocusEventInit): FocusEvent; } +interface FocusNavigationEvent extends Event { + readonly navigationReason: string; + readonly originHeight: number; + readonly originLeft: number; + readonly originTop: number; + readonly originWidth: number; + requestFocus(): void; +} + +declare var FocusNavigationEvent: { + prototype: FocusNavigationEvent; + new(type: string, eventInitDict?: FocusNavigationEventInit): FocusNavigationEvent; +} + interface FormData { append(name: any, value: any, blobName?: string): void; } @@ -7667,7 +8019,7 @@ interface GamepadEvent extends Event { declare var GamepadEvent: { prototype: GamepadEvent; - new(): GamepadEvent; + new(typeArg: string, eventInitDict?: GamepadEventInit): GamepadEvent; } interface Geolocation { @@ -7681,8 +8033,11 @@ declare var Geolocation: { new(): Geolocation; } -interface HTMLAllCollection extends HTMLCollection { - namedItem(name: string): Element; +interface HTMLAllCollection { + readonly length: number; + item(nameOrIndex?: string): HTMLCollection | Element | null; + namedItem(name: string): HTMLCollection | Element | null; + [index: number]: Element; } declare var HTMLAllCollection: { @@ -7770,7 +8125,7 @@ interface HTMLAnchorElement extends HTMLElement { * Returns a string representation of an object. */ toString(): string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAnchorElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7844,7 +8199,7 @@ interface HTMLAppletElement extends HTMLElement { useMap: string; vspace: number; width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAppletElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7912,7 +8267,7 @@ interface HTMLAreaElement extends HTMLElement { * Returns a string representation of an object. */ toString(): string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7921,15 +8276,7 @@ declare var HTMLAreaElement: { new(): HTMLAreaElement; } -interface HTMLAreasCollection extends HTMLCollection { - /** - * Adds an element to the areas, controlRange, or options collection. - */ - add(element: HTMLElement, before?: HTMLElement | number): void; - /** - * Removes an element from the collection. - */ - remove(index?: number): void; +interface HTMLAreasCollection extends HTMLCollectionBase { } declare var HTMLAreasCollection: { @@ -7938,7 +8285,7 @@ declare var HTMLAreasCollection: { } interface HTMLAudioElement extends HTMLMediaElement { - addEventListener(type: K, listener: (this: HTMLMediaElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAudioElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7952,7 +8299,7 @@ interface HTMLBRElement extends HTMLElement { * Sets or retrieves the side on which floating objects are not to be positioned when any IHTMLBlockElement is inserted into the document. */ clear: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7970,7 +8317,7 @@ interface HTMLBaseElement extends HTMLElement { * Sets or retrieves the window or frame at which to target content. */ target: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBaseElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7988,7 +8335,7 @@ interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty * Sets or retrieves the font size of the object. */ size: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBaseFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8014,6 +8361,7 @@ interface HTMLBodyElementEventMap extends HTMLElementEventMap { "pageshow": PageTransitionEvent; "popstate": PopStateEvent; "resize": UIEvent; + "scroll": UIEvent; "storage": StorageEvent; "unload": Event; } @@ -8041,6 +8389,7 @@ interface HTMLBodyElement extends HTMLElement { onpageshow: (this: HTMLBodyElement, ev: PageTransitionEvent) => any; onpopstate: (this: HTMLBodyElement, ev: PopStateEvent) => any; onresize: (this: HTMLBodyElement, ev: UIEvent) => any; + onscroll: (this: HTMLBodyElement, ev: UIEvent) => any; onstorage: (this: HTMLBodyElement, ev: StorageEvent) => any; onunload: (this: HTMLBodyElement, ev: Event) => any; text: any; @@ -8118,7 +8467,7 @@ interface HTMLButtonElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLButtonElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8153,7 +8502,7 @@ interface HTMLCanvasElement extends HTMLElement { */ toDataURL(type?: string, ...args: any[]): string; toBlob(callback: (result: Blob | null) => void, type?: string, ...arguments: any[]): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLCanvasElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8162,7 +8511,7 @@ declare var HTMLCanvasElement: { new(): HTMLCanvasElement; } -interface HTMLCollection { +interface HTMLCollectionBase { /** * Sets or retrieves the number of objects in a collection. */ @@ -8171,11 +8520,14 @@ interface HTMLCollection { * Retrieves an object from various collections. */ item(index: number): Element; + [index: number]: Element; +} + +interface HTMLCollection extends HTMLCollectionBase { /** * Retrieves a select object or an object from an options collection. */ - namedItem(name: string): Element; - [index: number]: Element; + namedItem(name: string): Element | null; } declare var HTMLCollection: { @@ -8185,7 +8537,7 @@ declare var HTMLCollection: { interface HTMLDListElement extends HTMLElement { compact: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8194,9 +8546,20 @@ declare var HTMLDListElement: { new(): HTMLDListElement; } +interface HTMLDataElement extends HTMLElement { + value: string; + addEventListener(type: K, listener: (this: HTMLDataElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDataElement: { + prototype: HTMLDataElement; + new(): HTMLDataElement; +} + interface HTMLDataListElement extends HTMLElement { options: HTMLCollectionOf; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDataListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8207,7 +8570,7 @@ declare var HTMLDataListElement: { interface HTMLDirectoryElement extends HTMLElement { compact: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDirectoryElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8225,7 +8588,7 @@ interface HTMLDivElement extends HTMLElement { * Sets or retrieves whether the browser automatically performs wordwrap. */ noWrap: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDivElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8235,7 +8598,7 @@ declare var HTMLDivElement: { } interface HTMLDocument extends Document { - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8323,7 +8686,6 @@ interface HTMLElement extends Element { draggable: boolean; hidden: boolean; hideFocus: boolean; - innerHTML: string; innerText: string; readonly isContentEditable: boolean; lang: string; @@ -8399,7 +8761,6 @@ interface HTMLElement extends Element { ontimeupdate: (this: HTMLElement, ev: Event) => any; onvolumechange: (this: HTMLElement, ev: Event) => any; onwaiting: (this: HTMLElement, ev: Event) => any; - outerHTML: string; outerText: string; spellcheck: boolean; readonly style: CSSStyleDeclaration; @@ -8410,7 +8771,6 @@ interface HTMLElement extends Element { dragDrop(): boolean; focus(): void; msGetInputContext(): MSInputMethodContext; - setActive(): void; addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8467,7 +8827,7 @@ interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { * Sets or retrieves the width of the object. */ width: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLEmbedElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8486,6 +8846,7 @@ interface HTMLFieldSetElement extends HTMLElement { * Retrieves a reference to the form that the object is embedded in. */ readonly form: HTMLFormElement; + name: string; /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. */ @@ -8507,7 +8868,7 @@ interface HTMLFieldSetElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFieldSetElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8521,7 +8882,7 @@ interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOM * Sets or retrieves the current typeface family. */ face: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8530,6 +8891,15 @@ declare var HTMLFontElement: { new(): HTMLFontElement; } +interface HTMLFormControlsCollection extends HTMLCollectionBase { + namedItem(name: string): HTMLCollection | Element | null; +} + +declare var HTMLFormControlsCollection: { + prototype: HTMLFormControlsCollection; + new(): HTMLFormControlsCollection; +} + interface HTMLFormElement extends HTMLElement { /** * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. @@ -8546,7 +8916,7 @@ interface HTMLFormElement extends HTMLElement { /** * Retrieves a collection, in source order, of all controls in a given form. */ - readonly elements: HTMLCollection; + readonly elements: HTMLFormControlsCollection; /** * Sets or retrieves the MIME encoding for the form. */ @@ -8597,7 +8967,7 @@ interface HTMLFormElement extends HTMLElement { * Fires when a FORM is about to be submitted. */ submit(): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFormElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; [name: string]: any; } @@ -8686,6 +9056,7 @@ declare var HTMLFrameElement: { } interface HTMLFrameSetElementEventMap extends HTMLElementEventMap { + "afterprint": Event; "beforeprint": Event; "beforeunload": BeforeUnloadEvent; "blur": FocusEvent; @@ -8699,7 +9070,9 @@ interface HTMLFrameSetElementEventMap extends HTMLElementEventMap { "orientationchange": Event; "pagehide": PageTransitionEvent; "pageshow": PageTransitionEvent; + "popstate": PopStateEvent; "resize": UIEvent; + "scroll": UIEvent; "storage": StorageEvent; "unload": Event; } @@ -8743,7 +9116,9 @@ interface HTMLFrameSetElement extends HTMLElement { onorientationchange: (this: HTMLFrameSetElement, ev: Event) => any; onpagehide: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; onpageshow: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; + onpopstate: (this: HTMLFrameSetElement, ev: PopStateEvent) => any; onresize: (this: HTMLFrameSetElement, ev: UIEvent) => any; + onscroll: (this: HTMLFrameSetElement, ev: UIEvent) => any; onstorage: (this: HTMLFrameSetElement, ev: StorageEvent) => any; onunload: (this: HTMLFrameSetElement, ev: Event) => any; /** @@ -8772,7 +9147,7 @@ interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2 * Sets or retrieves the width of the object. */ width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8783,7 +9158,7 @@ declare var HTMLHRElement: { interface HTMLHeadElement extends HTMLElement { profile: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHeadElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8797,7 +9172,7 @@ interface HTMLHeadingElement extends HTMLElement { * Sets or retrieves a value that indicates the table alignment. */ align: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHeadingElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8811,7 +9186,7 @@ interface HTMLHtmlElement extends HTMLElement { * Sets or retrieves the DTD version that governs the current document. */ version: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHtmlElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8830,6 +9205,7 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { */ align: string; allowFullscreen: boolean; + allowPaymentRequest: boolean; /** * Specifies the properties of a border drawn around an object. */ @@ -8925,7 +9301,7 @@ interface HTMLImageElement extends HTMLElement { * Retrieves whether the object is fully loaded. */ readonly complete: boolean; - crossOrigin: string; + crossOrigin: string | null; readonly currentSrc: string; /** * Sets or retrieves the height of the object. @@ -8990,14 +9366,13 @@ interface HTMLImageElement extends HTMLElement { readonly x: number; readonly y: number; msGetAsCastingSource(): any; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLImageElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLImageElement: { prototype: HTMLImageElement; new(): HTMLImageElement; - create(): HTMLImageElement; } interface HTMLInputElement extends HTMLElement { @@ -9203,7 +9578,7 @@ interface HTMLInputElement extends HTMLElement { * @param n Value to increment the value by. */ stepUp(n?: number): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLInputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9218,7 +9593,7 @@ interface HTMLLIElement extends HTMLElement { * Sets or retrieves the value of a list item. */ value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLIElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9236,7 +9611,7 @@ interface HTMLLabelElement extends HTMLElement { * Sets or retrieves the object to which the given label object is assigned. */ htmlFor: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLabelElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9254,7 +9629,7 @@ interface HTMLLegendElement extends HTMLElement { * Retrieves a reference to the form that the object is embedded in. */ readonly form: HTMLFormElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9299,7 +9674,7 @@ interface HTMLLinkElement extends HTMLElement, LinkStyle { type: string; import?: Document; integrity: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLinkElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9317,7 +9692,7 @@ interface HTMLMapElement extends HTMLElement { * Sets or retrieves the name of the object. */ name: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMapElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9380,7 +9755,7 @@ interface HTMLMediaElement extends HTMLElement { * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). */ controls: boolean; - crossOrigin: string; + crossOrigin: string | null; /** * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. */ @@ -9521,7 +9896,7 @@ interface HTMLMediaElement extends HTMLElement { * Loads and starts playback of a media resource. */ play(): void; - setMediaKeys(mediaKeys: MediaKeys | null): PromiseLike; + setMediaKeys(mediaKeys: MediaKeys | null): Promise; readonly HAVE_CURRENT_DATA: number; readonly HAVE_ENOUGH_DATA: number; readonly HAVE_FUTURE_DATA: number; @@ -9552,7 +9927,7 @@ declare var HTMLMediaElement: { interface HTMLMenuElement extends HTMLElement { compact: boolean; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMenuElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9586,7 +9961,7 @@ interface HTMLMetaElement extends HTMLElement { * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. */ url: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMetaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9602,7 +9977,7 @@ interface HTMLMeterElement extends HTMLElement { min: number; optimum: number; value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMeterElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9620,7 +9995,7 @@ interface HTMLModElement extends HTMLElement { * Sets or retrieves the date and time of a modification to the object. */ dateTime: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLModElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9636,7 +10011,7 @@ interface HTMLOListElement extends HTMLElement { */ start: number; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9714,10 +10089,6 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { * Sets or retrieves the name of the object. */ name: string; - /** - * Retrieves the contained object. - */ - readonly object: any; readonly readyState: number; /** * Sets or retrieves a message to be displayed while an object is loading. @@ -9757,7 +10128,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLObjectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9796,7 +10167,7 @@ interface HTMLOptGroupElement extends HTMLElement { * Sets or retrieves the value which is returned to the server when the form control is submitted. */ value: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOptGroupElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9835,14 +10206,13 @@ interface HTMLOptionElement extends HTMLElement { * Sets or retrieves the value which is returned to the server when the form control is submitted. */ value: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLOptionElement: { prototype: HTMLOptionElement; new(): HTMLOptionElement; - create(): HTMLOptionElement; } interface HTMLOptionsCollection extends HTMLCollectionOf { @@ -9857,13 +10227,35 @@ declare var HTMLOptionsCollection: { new(): HTMLOptionsCollection; } +interface HTMLOutputElement extends HTMLElement { + defaultValue: string; + readonly form: HTMLFormElement; + readonly htmlFor: DOMSettableTokenList; + name: string; + readonly type: string; + readonly validationMessage: string; + readonly validity: ValidityState; + value: string; + readonly willValidate: boolean; + checkValidity(): boolean; + reportValidity(): boolean; + setCustomValidity(error: string): void; + addEventListener(type: K, listener: (this: HTMLOutputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLOutputElement: { + prototype: HTMLOutputElement; + new(): HTMLOutputElement; +} + interface HTMLParagraphElement extends HTMLElement { /** * Sets or retrieves how the object is aligned with adjacent text. */ align: string; clear: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLParagraphElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9889,7 +10281,7 @@ interface HTMLParamElement extends HTMLElement { * Sets or retrieves the data type of the value attribute. */ valueType: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLParamElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9899,7 +10291,7 @@ declare var HTMLParamElement: { } interface HTMLPictureElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLPictureElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9913,7 +10305,7 @@ interface HTMLPreElement extends HTMLElement { * Sets or gets a value that you can use to implement your own width functionality for the object. */ width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLPreElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9939,7 +10331,7 @@ interface HTMLProgressElement extends HTMLElement { * Sets or gets the current value of a progress element. The value must be a non-negative number between 0 and the max value. */ value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLProgressElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9953,7 +10345,7 @@ interface HTMLQuoteElement extends HTMLElement { * Sets or retrieves reference information about the object. */ cite: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLQuoteElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9968,6 +10360,7 @@ interface HTMLScriptElement extends HTMLElement { * Sets or retrieves the character set used to encode the object. */ charset: string; + crossOrigin: string | null; /** * Sets or retrieves the status of the script. */ @@ -9993,7 +10386,7 @@ interface HTMLScriptElement extends HTMLElement { */ type: string; integrity: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLScriptElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10089,7 +10482,7 @@ interface HTMLSelectElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSelectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; [name: string]: any; } @@ -10115,7 +10508,7 @@ interface HTMLSourceElement extends HTMLElement { * Gets or sets the MIME type of a media resource. */ type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSourceElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10125,7 +10518,7 @@ declare var HTMLSourceElement: { } interface HTMLSpanElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSpanElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10144,7 +10537,7 @@ interface HTMLStyleElement extends HTMLElement, LinkStyle { * Retrieves the CSS language in which the style sheet is written. */ type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLStyleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10162,7 +10555,7 @@ interface HTMLTableCaptionElement extends HTMLElement { * Sets or retrieves whether the caption appears at the top or bottom of the table. */ vAlign: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableCaptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10217,7 +10610,7 @@ interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment { * Sets or retrieves the width of the object. */ width: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10239,7 +10632,7 @@ interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { * Sets or retrieves the width of the object. */ width: any; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableColElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10249,6 +10642,8 @@ declare var HTMLTableColElement: { } interface HTMLTableDataCellElement extends HTMLTableCellElement { + addEventListener(type: K, listener: (this: HTMLTableDataCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLTableDataCellElement: { @@ -10360,7 +10755,7 @@ interface HTMLTableElement extends HTMLElement { * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. */ insertRow(index?: number): HTMLTableRowElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10374,6 +10769,8 @@ interface HTMLTableHeaderCellElement extends HTMLTableCellElement { * Sets or retrieves the group of cells in a table to which the object's information applies. */ scope: string; + addEventListener(type: K, listener: (this: HTMLTableHeaderCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLTableHeaderCellElement: { @@ -10413,7 +10810,7 @@ interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment { * @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. */ insertCell(index?: number): HTMLTableDataCellElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableRowElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10441,7 +10838,7 @@ interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment { * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. */ insertRow(index?: number): HTMLTableRowElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableSectionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10452,7 +10849,7 @@ declare var HTMLTableSectionElement: { interface HTMLTemplateElement extends HTMLElement { readonly content: DocumentFragment; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTemplateElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10559,7 +10956,7 @@ interface HTMLTextAreaElement extends HTMLElement { * @param end The offset into the text field for the end of the selection. */ setSelectionRange(start: number, end: number): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTextAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10568,12 +10965,23 @@ declare var HTMLTextAreaElement: { new(): HTMLTextAreaElement; } +interface HTMLTimeElement extends HTMLElement { + dateTime: string; + addEventListener(type: K, listener: (this: HTMLTimeElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTimeElement: { + prototype: HTMLTimeElement; + new(): HTMLTimeElement; +} + interface HTMLTitleElement extends HTMLElement { /** * Retrieves or sets the text of the object as a string. */ text: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTitleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10594,7 +11002,7 @@ interface HTMLTrackElement extends HTMLElement { readonly LOADED: number; readonly LOADING: number; readonly NONE: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTrackElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10610,7 +11018,7 @@ declare var HTMLTrackElement: { interface HTMLUListElement extends HTMLElement { compact: boolean; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLUListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10620,7 +11028,7 @@ declare var HTMLUListElement: { } interface HTMLUnknownElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLUnknownElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10691,7 +11099,21 @@ interface HashChangeEvent extends Event { declare var HashChangeEvent: { prototype: HashChangeEvent; - new(type: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; + new(typeArg: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; +} + +interface Headers { + append(name: string, value: string): void; + delete(name: string): void; + forEach(callback: ForEachCallback): void; + get(name: string): string | null; + has(name: string): boolean; + set(name: string, value: string): void; +} + +declare var Headers: { + prototype: Headers; + new(init?: any): Headers; } interface History { @@ -10745,14 +11167,14 @@ declare var IDBCursorWithValue: { interface IDBDatabaseEventMap { "abort": Event; - "error": ErrorEvent; + "error": Event; } interface IDBDatabase extends EventTarget { readonly name: string; readonly objectStoreNames: DOMStringList; onabort: (this: IDBDatabase, ev: Event) => any; - onerror: (this: IDBDatabase, ev: ErrorEvent) => any; + onerror: (this: IDBDatabase, ev: Event) => any; version: number; onversionchange: (ev: IDBVersionChangeEvent) => any; close(): void; @@ -10855,13 +11277,13 @@ declare var IDBOpenDBRequest: { } interface IDBRequestEventMap { - "error": ErrorEvent; + "error": Event; "success": Event; } interface IDBRequest extends EventTarget { readonly error: DOMError; - onerror: (this: IDBRequest, ev: ErrorEvent) => any; + onerror: (this: IDBRequest, ev: Event) => any; onsuccess: (this: IDBRequest, ev: Event) => any; readonly readyState: string; readonly result: any; @@ -10879,7 +11301,7 @@ declare var IDBRequest: { interface IDBTransactionEventMap { "abort": Event; "complete": Event; - "error": ErrorEvent; + "error": Event; } interface IDBTransaction extends EventTarget { @@ -10888,7 +11310,7 @@ interface IDBTransaction extends EventTarget { readonly mode: string; onabort: (this: IDBTransaction, ev: Event) => any; oncomplete: (this: IDBTransaction, ev: Event) => any; - onerror: (this: IDBTransaction, ev: ErrorEvent) => any; + onerror: (this: IDBTransaction, ev: Event) => any; abort(): void; objectStore(name: string): IDBObjectStore; readonly READ_ONLY: string; @@ -10916,6 +11338,15 @@ declare var IDBVersionChangeEvent: { new(): IDBVersionChangeEvent; } +interface IIRFilterNode extends AudioNode { + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; +} + +declare var IIRFilterNode: { + prototype: IIRFilterNode; + new(): IIRFilterNode; +} + interface ImageData { data: Uint8ClampedArray; readonly height: number; @@ -10928,6 +11359,35 @@ declare var ImageData: { new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +interface IntersectionObserver { + readonly root: Element | null; + readonly rootMargin: string; + readonly thresholds: number[]; + disconnect(): void; + observe(target: Element): void; + takeRecords(): IntersectionObserverEntry[]; + unobserve(target: Element): void; +} + +declare var IntersectionObserver: { + prototype: IntersectionObserver; + new(callback: IntersectionObserverCallback, options?: IntersectionObserverInit): IntersectionObserver; +} + +interface IntersectionObserverEntry { + readonly boundingClientRect: ClientRect; + readonly intersectionRatio: number; + readonly intersectionRect: ClientRect; + readonly rootBounds: ClientRect; + readonly target: Element; + readonly time: number; +} + +declare var IntersectionObserverEntry: { + prototype: IntersectionObserverEntry; + new(intersectionObserverEntryInit: IntersectionObserverEntryInit): IntersectionObserverEntry; +} + interface KeyboardEvent extends UIEvent { readonly altKey: boolean; readonly char: string | null; @@ -11014,7 +11474,7 @@ interface MSApp { execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; getCurrentPriority(): string; - getHtmlPrintDocumentSourceAsync(htmlDoc: any): PromiseLike; + getHtmlPrintDocumentSourceAsync(htmlDoc: any): Promise; getViewId(view: any): any; isTaskScheduledAtPriorityOrHigher(priority: string): boolean; pageHandlesAllApplicationActivations(enabled: boolean): void; @@ -11029,13 +11489,13 @@ declare var MSApp: MSApp; interface MSAppAsyncOperationEventMap { "complete": Event; - "error": ErrorEvent; + "error": Event; } interface MSAppAsyncOperation extends EventTarget { readonly error: DOMError; oncomplete: (this: MSAppAsyncOperation, ev: Event) => any; - onerror: (this: MSAppAsyncOperation, ev: ErrorEvent) => any; + onerror: (this: MSAppAsyncOperation, ev: Event) => any; readonly readyState: number; readonly result: any; start(): void; @@ -11075,8 +11535,8 @@ declare var MSBlobBuilder: { } interface MSCredentials { - getAssertion(challenge: string, filter?: MSCredentialFilter, params?: MSSignatureParameters): PromiseLike; - makeCredential(accountInfo: MSAccountInfo, params: MSCredentialParameters[], challenge?: string): PromiseLike; + getAssertion(challenge: string, filter?: MSCredentialFilter, params?: MSSignatureParameters): Promise; + makeCredential(accountInfo: MSAccountInfo, params: MSCredentialParameters[], challenge?: string): Promise; } declare var MSCredentials: { @@ -11192,12 +11652,13 @@ interface MSHTMLWebViewElement extends HTMLElement { goForward(): void; invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; navigate(uri: string): void; + navigateFocus(navigationReason: string, origin: FocusNavigationOrigin): void; navigateToLocalStreamUri(source: string, streamResolver: any): void; navigateToString(contents: string): void; navigateWithHttpRequestMessage(requestMessage: any): void; refresh(): void; stop(): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: MSHTMLWebViewElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11389,7 +11850,7 @@ interface MSStreamReader extends EventTarget, MSBaseReader { readAsBlob(stream: MSStream, size?: number): void; readAsDataURL(stream: MSStream, size?: number): void; readAsText(stream: MSStream, encoding?: string, size?: number): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: MSStreamReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11400,13 +11861,13 @@ declare var MSStreamReader: { interface MSWebViewAsyncOperationEventMap { "complete": Event; - "error": ErrorEvent; + "error": Event; } interface MSWebViewAsyncOperation extends EventTarget { readonly error: DOMError; oncomplete: (this: MSWebViewAsyncOperation, ev: Event) => any; - onerror: (this: MSWebViewAsyncOperation, ev: ErrorEvent) => any; + onerror: (this: MSWebViewAsyncOperation, ev: Event) => any; readonly readyState: number; readonly result: any; readonly target: MSHTMLWebViewElement; @@ -11463,7 +11924,7 @@ interface MediaDevices extends EventTarget { ondevicechange: (this: MediaDevices, ev: Event) => any; enumerateDevices(): any; getSupportedConstraints(): MediaTrackSupportedConstraints; - getUserMedia(constraints: MediaStreamConstraints): PromiseLike; + getUserMedia(constraints: MediaStreamConstraints): Promise; addEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11522,15 +11983,15 @@ declare var MediaKeyMessageEvent: { } interface MediaKeySession extends EventTarget { - readonly closed: PromiseLike; + readonly closed: Promise; readonly expiration: number; readonly keyStatuses: MediaKeyStatusMap; readonly sessionId: string; - close(): PromiseLike; - generateRequest(initDataType: string, initData: any): PromiseLike; - load(sessionId: string): PromiseLike; - remove(): PromiseLike; - update(response: any): PromiseLike; + close(): Promise; + generateRequest(initDataType: string, initData: any): Promise; + load(sessionId: string): Promise; + remove(): Promise; + update(response: any): Promise; } declare var MediaKeySession: { @@ -11552,7 +12013,7 @@ declare var MediaKeyStatusMap: { interface MediaKeySystemAccess { readonly keySystem: string; - createMediaKeys(): PromiseLike; + createMediaKeys(): Promise; getConfiguration(): MediaKeySystemConfiguration; } @@ -11563,7 +12024,7 @@ declare var MediaKeySystemAccess: { interface MediaKeys { createSession(sessionType?: string): MediaKeySession; - setServerCertificate(serverCertificate: any): PromiseLike; + setServerCertificate(serverCertificate: any): Promise; } declare var MediaKeys: { @@ -11616,18 +12077,18 @@ declare var MediaSource: { interface MediaStreamEventMap { "active": Event; - "addtrack": TrackEvent; + "addtrack": MediaStreamTrackEvent; "inactive": Event; - "removetrack": TrackEvent; + "removetrack": MediaStreamTrackEvent; } interface MediaStream extends EventTarget { readonly active: boolean; readonly id: string; onactive: (this: MediaStream, ev: Event) => any; - onaddtrack: (this: MediaStream, ev: TrackEvent) => any; + onaddtrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; oninactive: (this: MediaStream, ev: Event) => any; - onremovetrack: (this: MediaStream, ev: TrackEvent) => any; + onremovetrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; addTrack(track: MediaStreamTrack): void; clone(): MediaStream; getAudioTracks(): MediaStreamTrack[]; @@ -11670,7 +12131,16 @@ interface MediaStreamErrorEvent extends Event { declare var MediaStreamErrorEvent: { prototype: MediaStreamErrorEvent; - new(type: string, eventInitDict?: MediaStreamErrorEventInit): MediaStreamErrorEvent; + new(typeArg: string, eventInitDict?: MediaStreamErrorEventInit): MediaStreamErrorEvent; +} + +interface MediaStreamEvent extends Event { + readonly stream: MediaStream | null; +} + +declare var MediaStreamEvent: { + prototype: MediaStreamEvent; + new(type: string, eventInitDict: MediaStreamEventInit): MediaStreamEvent; } interface MediaStreamTrackEventMap { @@ -11693,7 +12163,7 @@ interface MediaStreamTrack extends EventTarget { readonly readonly: boolean; readonly readyState: string; readonly remote: boolean; - applyConstraints(constraints: MediaTrackConstraints): PromiseLike; + applyConstraints(constraints: MediaTrackConstraints): Promise; clone(): MediaStreamTrack; getCapabilities(): MediaTrackCapabilities; getConstraints(): MediaTrackConstraints; @@ -11714,7 +12184,7 @@ interface MediaStreamTrackEvent extends Event { declare var MediaStreamTrackEvent: { prototype: MediaStreamTrackEvent; - new(type: string, eventInitDict?: MediaStreamTrackEventInit): MediaStreamTrackEvent; + new(typeArg: string, eventInitDict?: MediaStreamTrackEventInit): MediaStreamTrackEvent; } interface MessageChannel { @@ -11747,7 +12217,7 @@ interface MessagePortEventMap { interface MessagePort extends EventTarget { onmessage: (this: MessagePort, ev: MessageEvent) => any; close(): void; - postMessage(message?: any, ports?: any): void; + postMessage(message?: any, transfer?: any[]): void; start(): void; addEventListener(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -11909,9 +12379,10 @@ declare var NavigationEventWithReferrer: { new(): NavigationEventWithReferrer; } -interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorUserMedia { - readonly appCodeName: string; +interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorUserMedia { + readonly authentication: WebAuthentication; readonly cookieEnabled: boolean; + gamepadInputEmulation: string; readonly language: string; readonly maxTouchPoints: number; readonly mimeTypes: MimeTypeArray; @@ -11920,12 +12391,13 @@ interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorConte readonly msPointerEnabled: boolean; readonly plugins: PluginArray; readonly pointerEnabled: boolean; + readonly serviceWorker: ServiceWorkerContainer; readonly webdriver: boolean; readonly hardwareConcurrency: number; getGamepads(): Gamepad[]; javaEnabled(): boolean; msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; - requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): PromiseLike; + requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): Promise; vibrate(pattern: number | number[]): boolean; } @@ -11951,7 +12423,7 @@ interface Node extends EventTarget { readonly parentNode: Node | null; readonly previousSibling: Node | null; textContent: string | null; - appendChild(newChild: Node): Node; + appendChild(newChild: T): T; cloneNode(deep?: boolean): Node; compareDocumentPosition(other: Node): number; contains(child: Node): boolean; @@ -12058,6 +12530,36 @@ declare var NodeList: { new(): NodeList; } +interface NotificationEventMap { + "click": Event; + "close": Event; + "error": Event; + "show": Event; +} + +interface Notification extends EventTarget { + readonly body: string; + readonly dir: string; + readonly icon: string; + readonly lang: string; + onclick: (this: Notification, ev: Event) => any; + onclose: (this: Notification, ev: Event) => any; + onerror: (this: Notification, ev: Event) => any; + onshow: (this: Notification, ev: Event) => any; + readonly permission: string; + readonly tag: string; + readonly title: string; + close(): void; + addEventListener(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Notification: { + prototype: Notification; + new(title: string, options?: NotificationOptions): Notification; + requestPermission(callback?: NotificationPermissionCallback): Promise; +} + interface OES_element_index_uint { } @@ -12092,6 +12594,24 @@ declare var OES_texture_float_linear: { new(): OES_texture_float_linear; } +interface OES_texture_half_float { + readonly HALF_FLOAT_OES: number; +} + +declare var OES_texture_half_float: { + prototype: OES_texture_half_float; + new(): OES_texture_half_float; + readonly HALF_FLOAT_OES: number; +} + +interface OES_texture_half_float_linear { +} + +declare var OES_texture_half_float_linear: { + prototype: OES_texture_half_float_linear; + new(): OES_texture_half_float_linear; +} + interface OfflineAudioCompletionEvent extends Event { readonly renderedBuffer: AudioBuffer; } @@ -12101,13 +12621,15 @@ declare var OfflineAudioCompletionEvent: { new(): OfflineAudioCompletionEvent; } -interface OfflineAudioContextEventMap { - "complete": Event; +interface OfflineAudioContextEventMap extends AudioContextEventMap { + "complete": OfflineAudioCompletionEvent; } -interface OfflineAudioContext extends AudioContext { - oncomplete: (this: OfflineAudioContext, ev: Event) => any; - startRendering(): PromiseLike; +interface OfflineAudioContext extends AudioContextBase { + readonly length: number; + oncomplete: (this: OfflineAudioContext, ev: OfflineAudioCompletionEvent) => any; + startRendering(): Promise; + suspend(suspendTime: number): Promise; addEventListener(type: K, listener: (this: OfflineAudioContext, ev: OfflineAudioContextEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12183,6 +12705,82 @@ declare var PannerNode: { new(): PannerNode; } +interface Path2D extends Object, CanvasPathMethods { +} + +declare var Path2D: { + prototype: Path2D; + new(path?: Path2D): Path2D; +} + +interface PaymentAddress { + readonly addressLine: string[]; + readonly city: string; + readonly country: string; + readonly dependentLocality: string; + readonly languageCode: string; + readonly organization: string; + readonly phone: string; + readonly postalCode: string; + readonly recipient: string; + readonly region: string; + readonly sortingCode: string; + toJSON(): any; +} + +declare var PaymentAddress: { + prototype: PaymentAddress; + new(): PaymentAddress; +} + +interface PaymentRequestEventMap { + "shippingaddresschange": Event; + "shippingoptionchange": Event; +} + +interface PaymentRequest extends EventTarget { + onshippingaddresschange: (this: PaymentRequest, ev: Event) => any; + onshippingoptionchange: (this: PaymentRequest, ev: Event) => any; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + readonly shippingType: string | null; + abort(): Promise; + show(): Promise; + addEventListener(type: K, listener: (this: PaymentRequest, ev: PaymentRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var PaymentRequest: { + prototype: PaymentRequest; + new(methodData: PaymentMethodData[], details: PaymentDetails, options?: PaymentOptions): PaymentRequest; +} + +interface PaymentRequestUpdateEvent extends Event { + updateWith(d: Promise): void; +} + +declare var PaymentRequestUpdateEvent: { + prototype: PaymentRequestUpdateEvent; + new(type: string, eventInitDict?: PaymentRequestUpdateEventInit): PaymentRequestUpdateEvent; +} + +interface PaymentResponse { + readonly details: any; + readonly methodName: string; + readonly payerEmail: string | null; + readonly payerName: string | null; + readonly payerPhone: string | null; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + complete(result?: string): Promise; + toJSON(): any; +} + +declare var PaymentResponse: { + prototype: PaymentResponse; + new(): PaymentResponse; +} + interface PerfWidgetExternal { readonly activeNetworkRequestCount: number; readonly averageFrameTime: number; @@ -12448,7 +13046,7 @@ interface PopStateEvent extends Event { declare var PopStateEvent: { prototype: PopStateEvent; - new(): PopStateEvent; + new(typeArg: string, eventInitDict?: PopStateEventInit): PopStateEvent; } interface Position { @@ -12499,23 +13097,57 @@ declare var ProgressEvent: { new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } +interface PushManager { + getSubscription(): Promise; + permissionState(options?: PushSubscriptionOptionsInit): Promise; + subscribe(options?: PushSubscriptionOptionsInit): Promise; +} + +declare var PushManager: { + prototype: PushManager; + new(): PushManager; +} + +interface PushSubscription { + readonly endpoint: USVString; + readonly options: PushSubscriptionOptions; + getKey(name: string): ArrayBuffer | null; + toJSON(): any; + unsubscribe(): Promise; +} + +declare var PushSubscription: { + prototype: PushSubscription; + new(): PushSubscription; +} + +interface PushSubscriptionOptions { + readonly applicationServerKey: ArrayBuffer | null; + readonly userVisibleOnly: boolean; +} + +declare var PushSubscriptionOptions: { + prototype: PushSubscriptionOptions; + new(): PushSubscriptionOptions; +} + interface RTCDTMFToneChangeEvent extends Event { readonly tone: string; } declare var RTCDTMFToneChangeEvent: { prototype: RTCDTMFToneChangeEvent; - new(type: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; + new(typeArg: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; } interface RTCDtlsTransportEventMap { "dtlsstatechange": RTCDtlsTransportStateChangedEvent; - "error": ErrorEvent; + "error": Event; } interface RTCDtlsTransport extends RTCStatsProvider { ondtlsstatechange: ((this: RTCDtlsTransport, ev: RTCDtlsTransportStateChangedEvent) => any) | null; - onerror: ((this: RTCDtlsTransport, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCDtlsTransport, ev: Event) => any) | null; readonly state: string; readonly transport: RTCIceTransport; getLocalParameters(): RTCDtlsParameters; @@ -12562,6 +13194,18 @@ declare var RTCDtmfSender: { new(sender: RTCRtpSender): RTCDtmfSender; } +interface RTCIceCandidate { + candidate: string | null; + sdpMLineIndex: number | null; + sdpMid: string | null; + toJSON(): any; +} + +declare var RTCIceCandidate: { + prototype: RTCIceCandidate; + new(candidateInitDict?: RTCIceCandidateInit): RTCIceCandidate; +} + interface RTCIceCandidatePairChangedEvent extends Event { readonly pair: RTCIceCandidatePair; } @@ -12572,16 +13216,16 @@ declare var RTCIceCandidatePairChangedEvent: { } interface RTCIceGathererEventMap { - "error": ErrorEvent; + "error": Event; "localcandidate": RTCIceGathererEvent; } interface RTCIceGatherer extends RTCStatsProvider { readonly component: string; - onerror: ((this: RTCIceGatherer, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCIceGatherer, ev: Event) => any) | null; onlocalcandidate: ((this: RTCIceGatherer, ev: RTCIceGathererEvent) => any) | null; createAssociatedGatherer(): RTCIceGatherer; - getLocalCandidates(): RTCIceCandidate[]; + getLocalCandidates(): RTCIceCandidateDictionary[]; getLocalParameters(): RTCIceParameters; addEventListener(type: K, listener: (this: RTCIceGatherer, ev: RTCIceGathererEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -12593,7 +13237,7 @@ declare var RTCIceGatherer: { } interface RTCIceGathererEvent extends Event { - readonly candidate: RTCIceCandidate | RTCIceCandidateComplete; + readonly candidate: RTCIceCandidateDictionary | RTCIceCandidateComplete; } declare var RTCIceGathererEvent: { @@ -12613,12 +13257,12 @@ interface RTCIceTransport extends RTCStatsProvider { onicestatechange: ((this: RTCIceTransport, ev: RTCIceTransportStateChangedEvent) => any) | null; readonly role: string; readonly state: string; - addRemoteCandidate(remoteCandidate: RTCIceCandidate | RTCIceCandidateComplete): void; + addRemoteCandidate(remoteCandidate: RTCIceCandidateDictionary | RTCIceCandidateComplete): void; createAssociatedTransport(): RTCIceTransport; getNominatedCandidatePair(): RTCIceCandidatePair | null; - getRemoteCandidates(): RTCIceCandidate[]; + getRemoteCandidates(): RTCIceCandidateDictionary[]; getRemoteParameters(): RTCIceParameters | null; - setRemoteCandidates(remoteCandidates: RTCIceCandidate[]): void; + setRemoteCandidates(remoteCandidates: RTCIceCandidateDictionary[]): void; start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: string): void; stop(): void; addEventListener(type: K, listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any, useCapture?: boolean): void; @@ -12639,12 +13283,67 @@ declare var RTCIceTransportStateChangedEvent: { new(): RTCIceTransportStateChangedEvent; } +interface RTCPeerConnectionEventMap { + "addstream": MediaStreamEvent; + "icecandidate": RTCPeerConnectionIceEvent; + "iceconnectionstatechange": Event; + "icegatheringstatechange": Event; + "negotiationneeded": Event; + "removestream": MediaStreamEvent; + "signalingstatechange": Event; +} + +interface RTCPeerConnection extends EventTarget { + readonly canTrickleIceCandidates: boolean | null; + readonly iceConnectionState: string; + readonly iceGatheringState: string; + readonly localDescription: RTCSessionDescription | null; + onaddstream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onicecandidate: (this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any; + oniceconnectionstatechange: (this: RTCPeerConnection, ev: Event) => any; + onicegatheringstatechange: (this: RTCPeerConnection, ev: Event) => any; + onnegotiationneeded: (this: RTCPeerConnection, ev: Event) => any; + onremovestream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onsignalingstatechange: (this: RTCPeerConnection, ev: Event) => any; + readonly remoteDescription: RTCSessionDescription | null; + readonly signalingState: string; + addIceCandidate(candidate: RTCIceCandidate, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addStream(stream: MediaStream): void; + close(): void; + createAnswer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + createOffer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback, options?: RTCOfferOptions): Promise; + getConfiguration(): RTCConfiguration; + getLocalStreams(): MediaStream[]; + getRemoteStreams(): MediaStream[]; + getStats(selector: MediaStreamTrack | null, successCallback?: RTCStatsCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + getStreamById(streamId: string): MediaStream | null; + removeStream(stream: MediaStream): void; + setLocalDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + setRemoteDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addEventListener(type: K, listener: (this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCPeerConnection: { + prototype: RTCPeerConnection; + new(configuration: RTCConfiguration): RTCPeerConnection; +} + +interface RTCPeerConnectionIceEvent extends Event { + readonly candidate: RTCIceCandidate; +} + +declare var RTCPeerConnectionIceEvent: { + prototype: RTCPeerConnectionIceEvent; + new(type: string, eventInitDict: RTCPeerConnectionIceEventInit): RTCPeerConnectionIceEvent; +} + interface RTCRtpReceiverEventMap { - "error": ErrorEvent; + "error": Event; } interface RTCRtpReceiver extends RTCStatsProvider { - onerror: ((this: RTCRtpReceiver, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCRtpReceiver, ev: Event) => any) | null; readonly rtcpTransport: RTCDtlsTransport; readonly track: MediaStreamTrack | null; readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; @@ -12664,12 +13363,12 @@ declare var RTCRtpReceiver: { } interface RTCRtpSenderEventMap { - "error": ErrorEvent; + "error": Event; "ssrcconflict": RTCSsrcConflictEvent; } interface RTCRtpSender extends RTCStatsProvider { - onerror: ((this: RTCRtpSender, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCRtpSender, ev: Event) => any) | null; onssrcconflict: ((this: RTCRtpSender, ev: RTCSsrcConflictEvent) => any) | null; readonly rtcpTransport: RTCDtlsTransport; readonly track: MediaStreamTrack; @@ -12688,12 +13387,23 @@ declare var RTCRtpSender: { getCapabilities(kind?: string): RTCRtpCapabilities; } +interface RTCSessionDescription { + sdp: string | null; + type: string | null; + toJSON(): any; +} + +declare var RTCSessionDescription: { + prototype: RTCSessionDescription; + new(descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription; +} + interface RTCSrtpSdesTransportEventMap { - "error": ErrorEvent; + "error": Event; } interface RTCSrtpSdesTransport extends EventTarget { - onerror: ((this: RTCSrtpSdesTransport, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCSrtpSdesTransport, ev: Event) => any) | null; readonly transport: RTCIceTransport; addEventListener(type: K, listener: (this: RTCSrtpSdesTransport, ev: RTCSrtpSdesTransportEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -12715,8 +13425,8 @@ declare var RTCSsrcConflictEvent: { } interface RTCStatsProvider extends EventTarget { - getStats(): PromiseLike; - msGetStats(): PromiseLike; + getStats(): Promise; + msGetStats(): Promise; } declare var RTCStatsProvider: { @@ -12768,9 +13478,69 @@ declare var Range: { readonly START_TO_START: number; } -interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface ReadableStream { + readonly locked: boolean; + cancel(): Promise; + getReader(): ReadableStreamReader; +} + +declare var ReadableStream: { + prototype: ReadableStream; + new(): ReadableStream; +} + +interface ReadableStreamReader { + cancel(): Promise; + read(): Promise; + releaseLock(): void; +} + +declare var ReadableStreamReader: { + prototype: ReadableStreamReader; + new(): ReadableStreamReader; +} + +interface Request extends Object, Body { + readonly cache: string; + readonly credentials: string; + readonly destination: string; + readonly headers: Headers; + readonly integrity: string; + readonly keepalive: boolean; + readonly method: string; + readonly mode: string; + readonly redirect: string; + readonly referrer: string; + readonly referrerPolicy: string; + readonly type: string; + readonly url: string; + clone(): Request; +} + +declare var Request: { + prototype: Request; + new(input: Request | string, init?: RequestInit): Request; +} + +interface Response extends Object, Body { + readonly body: ReadableStream | null; + readonly headers: Headers; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly type: string; + readonly url: string; + clone(): Response; +} + +declare var Response: { + prototype: Response; + new(body?: any, init?: ResponseInit): Response; +} + +interface SVGAElement extends SVGGraphicsElement, SVGURIReference { readonly target: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12923,11 +13693,11 @@ declare var SVGAnimatedTransformList: { new(): SVGAnimatedTransformList; } -interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGCircleElement extends SVGGraphicsElement { readonly cx: SVGAnimatedLength; readonly cy: SVGAnimatedLength; readonly r: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGCircleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12936,9 +13706,9 @@ declare var SVGCircleElement: { new(): SVGCircleElement; } -interface SVGClipPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { +interface SVGClipPathElement extends SVGGraphicsElement, SVGUnitTypes { readonly clipPathUnits: SVGAnimatedEnumeration; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGClipPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12961,7 +13731,7 @@ interface SVGComponentTransferFunctionElement extends SVGElement { readonly SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; readonly SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGComponentTransferFunctionElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12976,8 +13746,8 @@ declare var SVGComponentTransferFunctionElement: { readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; } -interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGDefsElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGDefsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12986,8 +13756,8 @@ declare var SVGDefsElement: { new(): SVGDefsElement; } -interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGDescElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGDescElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13010,6 +13780,7 @@ interface SVGElementEventMap extends ElementEventMap { } interface SVGElement extends Element { + className: any; onclick: (this: SVGElement, ev: MouseEvent) => any; ondblclick: (this: SVGElement, ev: MouseEvent) => any; onfocusin: (this: SVGElement, ev: FocusEvent) => any; @@ -13021,9 +13792,9 @@ interface SVGElement extends Element { onmouseover: (this: SVGElement, ev: MouseEvent) => any; onmouseup: (this: SVGElement, ev: MouseEvent) => any; readonly ownerSVGElement: SVGSVGElement; + readonly style: CSSStyleDeclaration; readonly viewportElement: SVGElement; xmlbase: string; - className: any; addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13059,12 +13830,12 @@ declare var SVGElementInstanceList: { new(): SVGElementInstanceList; } -interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGEllipseElement extends SVGGraphicsElement { readonly cx: SVGAnimatedLength; readonly cy: SVGAnimatedLength; readonly rx: SVGAnimatedLength; readonly ry: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGEllipseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13094,7 +13865,7 @@ interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttrib readonly SVG_FEBLEND_MODE_SCREEN: number; readonly SVG_FEBLEND_MODE_SOFT_LIGHT: number; readonly SVG_FEBLEND_MODE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEBlendElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13129,7 +13900,7 @@ interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandard readonly SVG_FECOLORMATRIX_TYPE_MATRIX: number; readonly SVG_FECOLORMATRIX_TYPE_SATURATE: number; readonly SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEColorMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13145,7 +13916,7 @@ declare var SVGFEColorMatrixElement: { interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEComponentTransferElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13169,7 +13940,7 @@ interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAt readonly SVG_FECOMPOSITE_OPERATOR_OVER: number; readonly SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; readonly SVG_FECOMPOSITE_OPERATOR_XOR: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFECompositeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13202,7 +13973,7 @@ interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStand readonly SVG_EDGEMODE_NONE: number; readonly SVG_EDGEMODE_UNKNOWN: number; readonly SVG_EDGEMODE_WRAP: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEConvolveMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13221,7 +13992,7 @@ interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStan readonly kernelUnitLengthX: SVGAnimatedNumber; readonly kernelUnitLengthY: SVGAnimatedNumber; readonly surfaceScale: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDiffuseLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13241,7 +14012,7 @@ interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStan readonly SVG_CHANNEL_G: number; readonly SVG_CHANNEL_R: number; readonly SVG_CHANNEL_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDisplacementMapElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13258,7 +14029,7 @@ declare var SVGFEDisplacementMapElement: { interface SVGFEDistantLightElement extends SVGElement { readonly azimuth: SVGAnimatedNumber; readonly elevation: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDistantLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13268,7 +14039,7 @@ declare var SVGFEDistantLightElement: { } interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEFloodElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13278,6 +14049,8 @@ declare var SVGFEFloodElement: { } interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncAElement: { @@ -13286,6 +14059,8 @@ declare var SVGFEFuncAElement: { } interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncBElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncBElement: { @@ -13294,6 +14069,8 @@ declare var SVGFEFuncBElement: { } interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncGElement: { @@ -13302,6 +14079,8 @@ declare var SVGFEFuncGElement: { } interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncRElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncRElement: { @@ -13314,7 +14093,7 @@ interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandar readonly stdDeviationX: SVGAnimatedNumber; readonly stdDeviationY: SVGAnimatedNumber; setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEGaussianBlurElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13323,9 +14102,9 @@ declare var SVGFEGaussianBlurElement: { new(): SVGFEGaussianBlurElement; } -interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { +interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGURIReference { readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13335,7 +14114,7 @@ declare var SVGFEImageElement: { } interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMergeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13346,7 +14125,7 @@ declare var SVGFEMergeElement: { interface SVGFEMergeNodeElement extends SVGElement { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMergeNodeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13363,7 +14142,7 @@ interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardA readonly SVG_MORPHOLOGY_OPERATOR_DILATE: number; readonly SVG_MORPHOLOGY_OPERATOR_ERODE: number; readonly SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMorphologyElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13379,7 +14158,7 @@ interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttri readonly dx: SVGAnimatedNumber; readonly dy: SVGAnimatedNumber; readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEOffsetElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13392,7 +14171,7 @@ interface SVGFEPointLightElement extends SVGElement { readonly x: SVGAnimatedNumber; readonly y: SVGAnimatedNumber; readonly z: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEPointLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13408,7 +14187,7 @@ interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveSta readonly specularConstant: SVGAnimatedNumber; readonly specularExponent: SVGAnimatedNumber; readonly surfaceScale: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFESpecularLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13426,7 +14205,7 @@ interface SVGFESpotLightElement extends SVGElement { readonly x: SVGAnimatedNumber; readonly y: SVGAnimatedNumber; readonly z: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFESpotLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13437,7 +14216,7 @@ declare var SVGFESpotLightElement: { interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFETileElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13459,7 +14238,7 @@ interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardA readonly SVG_TURBULENCE_TYPE_FRACTALNOISE: number; readonly SVG_TURBULENCE_TYPE_TURBULENCE: number; readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFETurbulenceElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13474,7 +14253,7 @@ declare var SVGFETurbulenceElement: { readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; } -interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { +interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGURIReference { readonly filterResX: SVGAnimatedInteger; readonly filterResY: SVGAnimatedInteger; readonly filterUnits: SVGAnimatedEnumeration; @@ -13484,7 +14263,7 @@ interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLan readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; setFilterRes(filterResX: number, filterResY: number): void; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFilterElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13493,12 +14272,12 @@ declare var SVGFilterElement: { new(): SVGFilterElement; } -interface SVGForeignObjectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGForeignObjectElement extends SVGGraphicsElement { readonly height: SVGAnimatedLength; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGForeignObjectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13507,8 +14286,8 @@ declare var SVGForeignObjectElement: { new(): SVGForeignObjectElement; } -interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGGElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13517,7 +14296,7 @@ declare var SVGGElement: { new(): SVGGElement; } -interface SVGGradientElement extends SVGElement, SVGStylable, SVGExternalResourcesRequired, SVGURIReference, SVGUnitTypes { +interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGURIReference { readonly gradientTransform: SVGAnimatedTransformList; readonly gradientUnits: SVGAnimatedEnumeration; readonly spreadMethod: SVGAnimatedEnumeration; @@ -13525,7 +14304,7 @@ interface SVGGradientElement extends SVGElement, SVGStylable, SVGExternalResourc readonly SVG_SPREADMETHOD_REFLECT: number; readonly SVG_SPREADMETHOD_REPEAT: number; readonly SVG_SPREADMETHOD_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13538,13 +14317,30 @@ declare var SVGGradientElement: { readonly SVG_SPREADMETHOD_UNKNOWN: number; } -interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface SVGGraphicsElement extends SVGElement, SVGTests { + readonly farthestViewportElement: SVGElement; + readonly nearestViewportElement: SVGElement; + readonly transform: SVGAnimatedTransformList; + getBBox(): SVGRect; + getCTM(): SVGMatrix; + getScreenCTM(): SVGMatrix; + getTransformToElement(element: SVGElement): SVGMatrix; + addEventListener(type: K, listener: (this: SVGGraphicsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGraphicsElement: { + prototype: SVGGraphicsElement; + new(): SVGGraphicsElement; +} + +interface SVGImageElement extends SVGGraphicsElement, SVGURIReference { readonly height: SVGAnimatedLength; readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13605,12 +14401,12 @@ declare var SVGLengthList: { new(): SVGLengthList; } -interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGLineElement extends SVGGraphicsElement { readonly x1: SVGAnimatedLength; readonly x2: SVGAnimatedLength; readonly y1: SVGAnimatedLength; readonly y2: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGLineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13624,6 +14420,8 @@ interface SVGLinearGradientElement extends SVGGradientElement { readonly x2: SVGAnimatedLength; readonly y1: SVGAnimatedLength; readonly y2: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGLinearGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGLinearGradientElement: { @@ -13631,7 +14429,7 @@ declare var SVGLinearGradientElement: { new(): SVGLinearGradientElement; } -interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { +interface SVGMarkerElement extends SVGElement, SVGFitToViewBox { readonly markerHeight: SVGAnimatedLength; readonly markerUnits: SVGAnimatedEnumeration; readonly markerWidth: SVGAnimatedLength; @@ -13647,7 +14445,7 @@ interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExt readonly SVG_MARKER_ORIENT_ANGLE: number; readonly SVG_MARKER_ORIENT_AUTO: number; readonly SVG_MARKER_ORIENT_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMarkerElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13662,14 +14460,14 @@ declare var SVGMarkerElement: { readonly SVG_MARKER_ORIENT_UNKNOWN: number; } -interface SVGMaskElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { +interface SVGMaskElement extends SVGElement, SVGTests, SVGUnitTypes { readonly height: SVGAnimatedLength; readonly maskContentUnits: SVGAnimatedEnumeration; readonly maskUnits: SVGAnimatedEnumeration; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMaskElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13704,7 +14502,7 @@ declare var SVGMatrix: { } interface SVGMetadataElement extends SVGElement { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMetadataElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13738,7 +14536,8 @@ declare var SVGNumberList: { new(): SVGNumberList; } -interface SVGPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPathData { +interface SVGPathElement extends SVGGraphicsElement { + readonly pathSegList: SVGPathSegList; createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; createSVGPathSegClosePath(): SVGPathSegClosePath; @@ -13761,7 +14560,7 @@ interface SVGPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGT getPathSegAtLength(distance: number): number; getPointAtLength(distance: number): SVGPoint; getTotalLength(): number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14046,7 +14845,7 @@ declare var SVGPathSegMovetoRel: { new(): SVGPathSegMovetoRel; } -interface SVGPatternElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGURIReference, SVGUnitTypes { +interface SVGPatternElement extends SVGElement, SVGTests, SVGUnitTypes, SVGFitToViewBox, SVGURIReference { readonly height: SVGAnimatedLength; readonly patternContentUnits: SVGAnimatedEnumeration; readonly patternTransform: SVGAnimatedTransformList; @@ -14054,7 +14853,7 @@ interface SVGPatternElement extends SVGElement, SVGStylable, SVGTests, SVGLangSp readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGPatternElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14090,8 +14889,8 @@ declare var SVGPointList: { new(): SVGPointList; } -interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPoints { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGPolygonElement extends SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolygonElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14100,8 +14899,8 @@ declare var SVGPolygonElement: { new(): SVGPolygonElement; } -interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPoints { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGPolylineElement extends SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolylineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14154,6 +14953,8 @@ interface SVGRadialGradientElement extends SVGGradientElement { readonly fx: SVGAnimatedLength; readonly fy: SVGAnimatedLength; readonly r: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGRadialGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGRadialGradientElement: { @@ -14173,14 +14974,14 @@ declare var SVGRect: { new(): SVGRect; } -interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGRectElement extends SVGGraphicsElement { readonly height: SVGAnimatedLength; readonly rx: SVGAnimatedLength; readonly ry: SVGAnimatedLength; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGRectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14198,7 +14999,7 @@ interface SVGSVGElementEventMap extends SVGElementEventMap { "SVGZoom": SVGZoomEvent; } -interface SVGSVGElement extends SVGElement, DocumentEvent, SVGLocatable, SVGTests, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { +interface SVGSVGElement extends SVGGraphicsElement, DocumentEvent, SVGFitToViewBox, SVGZoomAndPan { contentScriptType: string; contentStyleType: string; currentScale: number; @@ -14250,9 +15051,9 @@ declare var SVGSVGElement: { new(): SVGSVGElement; } -interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { +interface SVGScriptElement extends SVGElement, SVGURIReference { type: string; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGScriptElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14261,9 +15062,9 @@ declare var SVGScriptElement: { new(): SVGScriptElement; } -interface SVGStopElement extends SVGElement, SVGStylable { +interface SVGStopElement extends SVGElement { readonly offset: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGStopElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14288,12 +15089,12 @@ declare var SVGStringList: { new(): SVGStringList; } -interface SVGStyleElement extends SVGElement, SVGLangSpace { +interface SVGStyleElement extends SVGElement { disabled: boolean; media: string; title: string; type: string; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGStyleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14302,8 +15103,8 @@ declare var SVGStyleElement: { new(): SVGStyleElement; } -interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGSwitchElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGSwitchElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14312,8 +15113,8 @@ declare var SVGSwitchElement: { new(): SVGSwitchElement; } -interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGSymbolElement extends SVGElement, SVGFitToViewBox { + addEventListener(type: K, listener: (this: SVGSymbolElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14323,6 +15124,8 @@ declare var SVGSymbolElement: { } interface SVGTSpanElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTSpanElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTSpanElement: { @@ -14330,7 +15133,7 @@ declare var SVGTSpanElement: { new(): SVGTSpanElement; } -interface SVGTextContentElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGTextContentElement extends SVGGraphicsElement { readonly lengthAdjust: SVGAnimatedEnumeration; readonly textLength: SVGAnimatedLength; getCharNumAtPosition(point: SVGPoint): number; @@ -14345,7 +15148,7 @@ interface SVGTextContentElement extends SVGElement, SVGStylable, SVGTests, SVGLa readonly LENGTHADJUST_SPACING: number; readonly LENGTHADJUST_SPACINGANDGLYPHS: number; readonly LENGTHADJUST_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGTextContentElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14357,7 +15160,9 @@ declare var SVGTextContentElement: { readonly LENGTHADJUST_UNKNOWN: number; } -interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { +interface SVGTextElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTextElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextElement: { @@ -14375,6 +15180,8 @@ interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { readonly TEXTPATH_SPACINGTYPE_AUTO: number; readonly TEXTPATH_SPACINGTYPE_EXACT: number; readonly TEXTPATH_SPACINGTYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGTextPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextPathElement: { @@ -14394,6 +15201,8 @@ interface SVGTextPositioningElement extends SVGTextContentElement { readonly rotate: SVGAnimatedNumberList; readonly x: SVGAnimatedLengthList; readonly y: SVGAnimatedLengthList; + addEventListener(type: K, listener: (this: SVGTextPositioningElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextPositioningElement: { @@ -14401,8 +15210,8 @@ declare var SVGTextPositioningElement: { new(): SVGTextPositioningElement; } -interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGTitleElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGTitleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14467,14 +15276,14 @@ interface SVGUnitTypes { } declare var SVGUnitTypes: SVGUnitTypes; -interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface SVGUseElement extends SVGGraphicsElement, SVGURIReference { readonly animatedInstanceRoot: SVGElementInstance; readonly height: SVGAnimatedLength; readonly instanceRoot: SVGElementInstance; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGUseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14483,9 +15292,9 @@ declare var SVGUseElement: { new(): SVGUseElement; } -interface SVGViewElement extends SVGElement, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { +interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox { readonly viewTarget: SVGStringList; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGViewElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14517,6 +15326,26 @@ declare var SVGZoomEvent: { new(): SVGZoomEvent; } +interface ScopedCredential { + readonly id: ArrayBuffer; + readonly type: string; +} + +declare var ScopedCredential: { + prototype: ScopedCredential; + new(): ScopedCredential; +} + +interface ScopedCredentialInfo { + readonly credential: ScopedCredential; + readonly publicKey: CryptoKey; +} + +declare var ScopedCredentialInfo: { + prototype: ScopedCredentialInfo; + new(): ScopedCredentialInfo; +} + interface ScreenEventMap { "MSOrientationChange": Event; } @@ -14578,6 +15407,10 @@ declare var ScriptProcessorNode: { interface Selection { readonly anchorNode: Node; readonly anchorOffset: number; + readonly baseNode: Node; + readonly baseOffset: number; + readonly extentNode: Node; + readonly extentOffset: number; readonly focusNode: Node; readonly focusOffset: number; readonly isCollapsed: boolean; @@ -14596,6 +15429,7 @@ interface Selection { removeRange(range: Range): void; selectAllChildren(parentNode: Node): void; setBaseAndExtent(baseNode: Node, baseOffset: number, extentNode: Node, extentOffset: number): void; + setPosition(parentNode: Node, offset: number): void; toString(): string; } @@ -14604,6 +15438,84 @@ declare var Selection: { new(): Selection; } +interface ServiceWorkerEventMap extends AbstractWorkerEventMap { + "statechange": Event; +} + +interface ServiceWorker extends EventTarget, AbstractWorker { + onstatechange: (this: ServiceWorker, ev: Event) => any; + readonly scriptURL: USVString; + readonly state: string; + postMessage(message: any, transfer?: any[]): void; + addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorker: { + prototype: ServiceWorker; + new(): ServiceWorker; +} + +interface ServiceWorkerContainerEventMap { + "controllerchange": Event; + "message": ServiceWorkerMessageEvent; +} + +interface ServiceWorkerContainer extends EventTarget { + readonly controller: ServiceWorker | null; + oncontrollerchange: (this: ServiceWorkerContainer, ev: Event) => any; + onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any; + readonly ready: Promise; + getRegistration(clientURL?: USVString): Promise; + getRegistrations(): any; + register(scriptURL: USVString, options?: RegistrationOptions): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerContainer: { + prototype: ServiceWorkerContainer; + new(): ServiceWorkerContainer; +} + +interface ServiceWorkerMessageEvent extends Event { + readonly data: any; + readonly lastEventId: string; + readonly origin: string; + readonly ports: MessagePort[] | null; + readonly source: ServiceWorker | MessagePort | null; +} + +declare var ServiceWorkerMessageEvent: { + prototype: ServiceWorkerMessageEvent; + new(type: string, eventInitDict?: ServiceWorkerMessageEventInit): ServiceWorkerMessageEvent; +} + +interface ServiceWorkerRegistrationEventMap { + "updatefound": Event; +} + +interface ServiceWorkerRegistration extends EventTarget { + readonly active: ServiceWorker | null; + readonly installing: ServiceWorker | null; + onupdatefound: (this: ServiceWorkerRegistration, ev: Event) => any; + readonly pushManager: PushManager; + readonly scope: USVString; + readonly sync: SyncManager; + readonly waiting: ServiceWorker | null; + getNotifications(filter?: GetNotificationOptions): any; + showNotification(title: string, options?: NotificationOptions): Promise; + unregister(): Promise; + update(): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerRegistration: { + prototype: ServiceWorkerRegistration; + new(): ServiceWorkerRegistration; +} + interface SourceBuffer extends EventTarget { appendWindowEnd: number; appendWindowStart: number; @@ -14635,6 +15547,87 @@ declare var SourceBufferList: { new(): SourceBufferList; } +interface SpeechSynthesisEventMap { + "voiceschanged": Event; +} + +interface SpeechSynthesis extends EventTarget { + onvoiceschanged: (this: SpeechSynthesis, ev: Event) => any; + readonly paused: boolean; + readonly pending: boolean; + readonly speaking: boolean; + cancel(): void; + getVoices(): SpeechSynthesisVoice[]; + pause(): void; + resume(): void; + speak(utterance: SpeechSynthesisUtterance): void; + addEventListener(type: K, listener: (this: SpeechSynthesis, ev: SpeechSynthesisEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesis: { + prototype: SpeechSynthesis; + new(): SpeechSynthesis; +} + +interface SpeechSynthesisEvent extends Event { + readonly charIndex: number; + readonly elapsedTime: number; + readonly name: string; + readonly utterance: SpeechSynthesisUtterance | null; +} + +declare var SpeechSynthesisEvent: { + prototype: SpeechSynthesisEvent; + new(type: string, eventInitDict?: SpeechSynthesisEventInit): SpeechSynthesisEvent; +} + +interface SpeechSynthesisUtteranceEventMap { + "boundary": Event; + "end": Event; + "error": Event; + "mark": Event; + "pause": Event; + "resume": Event; + "start": Event; +} + +interface SpeechSynthesisUtterance extends EventTarget { + lang: string; + onboundary: (this: SpeechSynthesisUtterance, ev: Event) => any; + onend: (this: SpeechSynthesisUtterance, ev: Event) => any; + onerror: (this: SpeechSynthesisUtterance, ev: Event) => any; + onmark: (this: SpeechSynthesisUtterance, ev: Event) => any; + onpause: (this: SpeechSynthesisUtterance, ev: Event) => any; + onresume: (this: SpeechSynthesisUtterance, ev: Event) => any; + onstart: (this: SpeechSynthesisUtterance, ev: Event) => any; + pitch: number; + rate: number; + text: string; + voice: SpeechSynthesisVoice; + volume: number; + addEventListener(type: K, listener: (this: SpeechSynthesisUtterance, ev: SpeechSynthesisUtteranceEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesisUtterance: { + prototype: SpeechSynthesisUtterance; + new(text?: string): SpeechSynthesisUtterance; +} + +interface SpeechSynthesisVoice { + readonly default: boolean; + readonly lang: string; + readonly localService: boolean; + readonly name: string; + readonly voiceURI: string; +} + +declare var SpeechSynthesisVoice: { + prototype: SpeechSynthesisVoice; + new(): SpeechSynthesisVoice; +} + interface StereoPannerNode extends AudioNode { readonly pan: AudioParam; } @@ -14746,6 +15739,16 @@ declare var SubtleCrypto: { new(): SubtleCrypto; } +interface SyncManager { + getTags(): any; + register(tag: string): Promise; +} + +declare var SyncManager: { + prototype: SyncManager; + new(): SyncManager; +} + interface Text extends CharacterData { readonly wholeText: string; readonly assignedSlot: HTMLSlotElement | null; @@ -14800,7 +15803,7 @@ declare var TextMetrics: { interface TextTrackEventMap { "cuechange": Event; - "error": ErrorEvent; + "error": Event; "load": Event; } @@ -14813,7 +15816,7 @@ interface TextTrack extends EventTarget { readonly language: string; mode: any; oncuechange: (this: TextTrack, ev: Event) => any; - onerror: (this: TextTrack, ev: ErrorEvent) => any; + onerror: (this: TextTrack, ev: Event) => any; onload: (this: TextTrack, ev: Event) => any; readonly readyState: number; addCue(cue: TextTrackCue): void; @@ -14925,11 +15928,14 @@ declare var Touch: { interface TouchEvent extends UIEvent { readonly altKey: boolean; readonly changedTouches: TouchList; + readonly charCode: number; readonly ctrlKey: boolean; + readonly keyCode: number; readonly metaKey: boolean; readonly shiftKey: boolean; readonly targetTouches: TouchList; readonly touches: TouchList; + readonly which: number; } declare var TouchEvent: { @@ -14949,12 +15955,12 @@ declare var TouchList: { } interface TrackEvent extends Event { - readonly track: any; + readonly track: VideoTrack | AudioTrack | TextTrack | null; } declare var TrackEvent: { prototype: TrackEvent; - new(): TrackEvent; + new(typeArg: string, eventInitDict?: TrackEventInit): TrackEvent; } interface TransitionEvent extends Event { @@ -14965,7 +15971,7 @@ interface TransitionEvent extends Event { declare var TransitionEvent: { prototype: TransitionEvent; - new(): TransitionEvent; + new(typeArg: string, eventInitDict?: TransitionEventInit): TransitionEvent; } interface TreeWalker { @@ -14996,7 +16002,7 @@ interface UIEvent extends Event { declare var UIEvent: { prototype: UIEvent; - new(type: string, eventInitDict?: UIEventInit): UIEvent; + new(typeArg: string, eventInitDict?: UIEventInit): UIEvent; } interface URL { @@ -15011,6 +16017,7 @@ interface URL { protocol: string; search: string; username: string; + readonly searchparams: URLSearchParams; toString(): string; } @@ -15147,6 +16154,28 @@ declare var WaveShaperNode: { new(): WaveShaperNode; } +interface WebAuthentication { + getAssertion(assertionChallenge: any, options?: AssertionOptions): Promise; + makeCredential(accountInformation: Account, cryptoParameters: ScopedCredentialParameters[], attestationChallenge: any, options?: ScopedCredentialOptions): Promise; +} + +declare var WebAuthentication: { + prototype: WebAuthentication; + new(): WebAuthentication; +} + +interface WebAuthnAssertion { + readonly authenticatorData: ArrayBuffer; + readonly clientData: ArrayBuffer; + readonly credential: ScopedCredential; + readonly signature: ArrayBuffer; +} + +declare var WebAuthnAssertion: { + prototype: WebAuthnAssertion; + new(): WebAuthnAssertion; +} + interface WebGLActiveInfo { readonly name: string; readonly size: number; @@ -15172,7 +16201,7 @@ interface WebGLContextEvent extends Event { declare var WebGLContextEvent: { prototype: WebGLContextEvent; - new(type: string, eventInitDict?: WebGLContextEventInit): WebGLContextEvent; + new(typeArg: string, eventInitDict?: WebGLContextEventInit): WebGLContextEvent; } interface WebGLFramebuffer extends WebGLObject { @@ -15299,7 +16328,7 @@ interface WebGLRenderingContext { isTexture(texture: WebGLTexture | null): boolean; lineWidth(width: number): void; linkProgram(program: WebGLProgram | null): void; - pixelStorei(pname: number, param: number): void; + pixelStorei(pname: number, param: number | boolean): void; polygonOffset(factor: number, units: number): void; readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView | null): void; renderbufferStorage(target: number, internalformat: number, width: number, height: number): void; @@ -16025,6 +17054,56 @@ declare var WebKitCSSMatrix: { new(text?: string): WebKitCSSMatrix; } +interface WebKitDirectoryEntry extends WebKitEntry { + createReader(): WebKitDirectoryReader; +} + +declare var WebKitDirectoryEntry: { + prototype: WebKitDirectoryEntry; + new(): WebKitDirectoryEntry; +} + +interface WebKitDirectoryReader { + readEntries(successCallback: WebKitEntriesCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitDirectoryReader: { + prototype: WebKitDirectoryReader; + new(): WebKitDirectoryReader; +} + +interface WebKitEntry { + readonly filesystem: WebKitFileSystem; + readonly fullPath: string; + readonly isDirectory: boolean; + readonly isFile: boolean; + readonly name: string; +} + +declare var WebKitEntry: { + prototype: WebKitEntry; + new(): WebKitEntry; +} + +interface WebKitFileEntry extends WebKitEntry { + file(successCallback: WebKitFileCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitFileEntry: { + prototype: WebKitFileEntry; + new(): WebKitFileEntry; +} + +interface WebKitFileSystem { + readonly name: string; + readonly root: WebKitDirectoryEntry; +} + +declare var WebKitFileSystem: { + prototype: WebKitFileSystem; + new(): WebKitFileSystem; +} + interface WebKitPoint { x: number; y: number; @@ -16037,7 +17116,7 @@ declare var WebKitPoint: { interface WebSocketEventMap { "close": CloseEvent; - "error": ErrorEvent; + "error": Event; "message": MessageEvent; "open": Event; } @@ -16047,7 +17126,7 @@ interface WebSocket extends EventTarget { readonly bufferedAmount: number; readonly extensions: string; onclose: (this: WebSocket, ev: CloseEvent) => any; - onerror: (this: WebSocket, ev: ErrorEvent) => any; + onerror: (this: WebSocket, ev: Event) => any; onmessage: (this: WebSocket, ev: MessageEvent) => any; onopen: (this: WebSocket, ev: Event) => any; readonly protocol: string; @@ -16184,8 +17263,9 @@ interface WindowEventMap extends GlobalEventHandlersEventMap { "waiting": Event; } -interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64 { +interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch { readonly applicationCache: ApplicationCache; + readonly caches: CacheStorage; readonly clientInformation: Navigator; readonly closed: boolean; readonly crypto: Crypto; @@ -16200,10 +17280,12 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly history: History; readonly innerHeight: number; readonly innerWidth: number; + readonly isSecureContext: boolean; readonly length: number; readonly location: Location; readonly locationbar: BarProp; readonly menubar: BarProp; + readonly msContentScript: ExtensionScriptApis; readonly msCredentials: MSCredentials; name: string; readonly navigator: Navigator; @@ -16317,6 +17399,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly scrollY: number; readonly scrollbars: BarProp; readonly self: Window; + readonly speechSynthesis: SpeechSynthesis; status: string; readonly statusbar: BarProp; readonly styleMedia: StyleMedia; @@ -16325,12 +17408,14 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly window: Window; URL: typeof URL; Blob: typeof Blob; + customElements: CustomElementRegistry; alert(message?: any): void; blur(): void; cancelAnimationFrame(handle: number): void; captureEvents(): void; close(): void; confirm(message?: string): boolean; + departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; focus(): void; getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -16350,6 +17435,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window scroll(x?: number, y?: number): void; scrollBy(x?: number, y?: number): void; scrollTo(x?: number, y?: number): void; + stop(): void; webkitCancelAnimationFrame(handle: number): void; webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; @@ -16372,7 +17458,7 @@ interface WorkerEventMap extends AbstractWorkerEventMap { interface Worker extends EventTarget, AbstractWorker { onmessage: (this: Worker, ev: MessageEvent) => any; - postMessage(message: any, ports?: any): void; + postMessage(message: any, transfer?: any[]): void; terminate(): void; addEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -16384,7 +17470,7 @@ declare var Worker: { } interface XMLDocument extends Document { - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: XMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16403,14 +17489,14 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly response: any; readonly responseText: string; responseType: string; - readonly responseXML: any; + readonly responseURL: string; + readonly responseXML: Document | null; readonly status: number; readonly statusText: string; timeout: number; readonly upload: XMLHttpRequestUpload; withCredentials: boolean; msCaching?: string; - readonly responseURL: string; abort(): void; getAllResponseHeaders(): string; getResponseHeader(header: string): string | null; @@ -16438,11 +17524,10 @@ declare var XMLHttpRequest: { readonly LOADING: number; readonly OPENED: number; readonly UNSENT: number; - create(): XMLHttpRequest; } interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { - addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16542,6 +17627,16 @@ declare var XSLTProcessor: { new(): XSLTProcessor; } +interface webkitRTCPeerConnection extends RTCPeerConnection { + addEventListener(type: K, listener: (this: webkitRTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var webkitRTCPeerConnection: { + prototype: webkitRTCPeerConnection; + new(configuration: RTCConfiguration): webkitRTCPeerConnection; +} + interface AbstractWorkerEventMap { "error": ErrorEvent; } @@ -16552,6 +17647,14 @@ interface AbstractWorker { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface Body { + readonly bodyUsed: boolean; + arrayBuffer(): Promise; + blob(): Promise; + json(): Promise; + text(): Promise; +} + interface CanvasPathMethods { arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; @@ -16578,12 +17681,10 @@ interface DOML2DeprecatedSizeProperty { interface DocumentEvent { createEvent(eventInterface:"AnimationEvent"): AnimationEvent; - createEvent(eventInterface:"AriaRequestEvent"): AriaRequestEvent; createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent; createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent; createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent; createEvent(eventInterface:"CloseEvent"): CloseEvent; - createEvent(eventInterface:"CommandEvent"): CommandEvent; createEvent(eventInterface:"CompositionEvent"): CompositionEvent; createEvent(eventInterface:"CustomEvent"): CustomEvent; createEvent(eventInterface:"DeviceLightEvent"): DeviceLightEvent; @@ -16594,6 +17695,7 @@ interface DocumentEvent { createEvent(eventInterface:"Event"): Event; createEvent(eventInterface:"Events"): Event; createEvent(eventInterface:"FocusEvent"): FocusEvent; + createEvent(eventInterface:"FocusNavigationEvent"): FocusNavigationEvent; createEvent(eventInterface:"GamepadEvent"): GamepadEvent; createEvent(eventInterface:"HashChangeEvent"): HashChangeEvent; createEvent(eventInterface:"IDBVersionChangeEvent"): IDBVersionChangeEvent; @@ -16609,6 +17711,7 @@ interface DocumentEvent { createEvent(eventInterface:"MediaEncryptedEvent"): MediaEncryptedEvent; createEvent(eventInterface:"MediaKeyMessageEvent"): MediaKeyMessageEvent; createEvent(eventInterface:"MediaStreamErrorEvent"): MediaStreamErrorEvent; + createEvent(eventInterface:"MediaStreamEvent"): MediaStreamEvent; createEvent(eventInterface:"MediaStreamTrackEvent"): MediaStreamTrackEvent; createEvent(eventInterface:"MessageEvent"): MessageEvent; createEvent(eventInterface:"MouseEvent"): MouseEvent; @@ -16621,6 +17724,7 @@ interface DocumentEvent { createEvent(eventInterface:"OfflineAudioCompletionEvent"): OfflineAudioCompletionEvent; createEvent(eventInterface:"OverflowEvent"): OverflowEvent; createEvent(eventInterface:"PageTransitionEvent"): PageTransitionEvent; + createEvent(eventInterface:"PaymentRequestUpdateEvent"): PaymentRequestUpdateEvent; createEvent(eventInterface:"PermissionRequestedEvent"): PermissionRequestedEvent; createEvent(eventInterface:"PointerEvent"): PointerEvent; createEvent(eventInterface:"PopStateEvent"): PopStateEvent; @@ -16630,10 +17734,13 @@ interface DocumentEvent { createEvent(eventInterface:"RTCIceCandidatePairChangedEvent"): RTCIceCandidatePairChangedEvent; createEvent(eventInterface:"RTCIceGathererEvent"): RTCIceGathererEvent; createEvent(eventInterface:"RTCIceTransportStateChangedEvent"): RTCIceTransportStateChangedEvent; + createEvent(eventInterface:"RTCPeerConnectionIceEvent"): RTCPeerConnectionIceEvent; createEvent(eventInterface:"RTCSsrcConflictEvent"): RTCSsrcConflictEvent; createEvent(eventInterface:"SVGZoomEvent"): SVGZoomEvent; createEvent(eventInterface:"SVGZoomEvents"): SVGZoomEvent; createEvent(eventInterface:"ScriptNotifyEvent"): ScriptNotifyEvent; + createEvent(eventInterface:"ServiceWorkerMessageEvent"): ServiceWorkerMessageEvent; + createEvent(eventInterface:"SpeechSynthesisEvent"): SpeechSynthesisEvent; createEvent(eventInterface:"StorageEvent"): StorageEvent; createEvent(eventInterface:"TextEvent"): TextEvent; createEvent(eventInterface:"TouchEvent"): TouchEvent; @@ -16649,10 +17756,10 @@ interface DocumentEvent { interface ElementTraversal { readonly childElementCount: number; - readonly firstElementChild: Element; - readonly lastElementChild: Element; - readonly nextElementSibling: Element; - readonly previousElementSibling: Element; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; + readonly nextElementSibling: Element | null; + readonly previousElementSibling: Element | null; } interface GetSVGDocument { @@ -16685,6 +17792,10 @@ interface GlobalEventHandlers { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface GlobalFetch { + fetch(input: RequestInfo, init?: RequestInit): Promise; +} + interface HTMLTableAlignment { /** * Sets or retrieves a value that you can use to implement your own ch functionality for the object. @@ -16748,6 +17859,14 @@ interface MSNavigatorDoNotTrack { storeWebWideTrackingException(args: StoreExceptionsInformation): void; } +interface NavigatorBeacon { + sendBeacon(url: USVString, data?: BodyInit): boolean; +} + +interface NavigatorConcurrentHardware { + readonly hardwareConcurrency: number; +} + interface NavigatorContentUtils { } @@ -16756,6 +17875,7 @@ interface NavigatorGeolocation { } interface NavigatorID { + readonly appCodeName: string; readonly appName: string; readonly appVersion: string; readonly platform: string; @@ -16789,20 +17909,12 @@ interface RandomSource { getRandomValues(array: ArrayBufferView): ArrayBufferView; } -interface SVGAnimatedPathData { - readonly pathSegList: SVGPathSegList; -} - interface SVGAnimatedPoints { readonly animatedPoints: SVGPointList; readonly points: SVGPointList; } -interface SVGExternalResourcesRequired { - readonly externalResourcesRequired: SVGAnimatedBoolean; -} - -interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { +interface SVGFilterPrimitiveStandardAttributes { readonly height: SVGAnimatedLength; readonly result: SVGAnimatedString; readonly width: SVGAnimatedLength; @@ -16815,25 +17927,6 @@ interface SVGFitToViewBox { readonly viewBox: SVGAnimatedRect; } -interface SVGLangSpace { - xmllang: string; - xmlspace: string; -} - -interface SVGLocatable { - readonly farthestViewportElement: SVGElement; - readonly nearestViewportElement: SVGElement; - getBBox(): SVGRect; - getCTM(): SVGMatrix; - getScreenCTM(): SVGMatrix; - getTransformToElement(element: SVGElement): SVGMatrix; -} - -interface SVGStylable { - className: any; - readonly style: CSSStyleDeclaration; -} - interface SVGTests { readonly requiredExtensions: SVGStringList; readonly requiredFeatures: SVGStringList; @@ -16841,10 +17934,6 @@ interface SVGTests { hasExtension(extension: string): boolean; } -interface SVGTransformable extends SVGLocatable { - readonly transform: SVGAnimatedTransformList; -} - interface SVGURIReference { readonly href: SVGAnimatedString; } @@ -16903,6 +17992,14 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface ErrorEventInit { + message?: string; + filename?: string; + lineno?: number; + conlno?: number; + error?: any; +} + interface StorageEventInit extends EventInit { key?: string; oldValue?: string; @@ -16918,6 +18015,41 @@ interface Canvas2DContextAttributes { [attribute: string]: boolean | string | undefined; } +interface URLSearchParams { + /** + * Appends a specified key/value pair as a new search parameter. + */ + append(name: string, value: string): void; + /** + * Deletes the given search parameter, and its associated value, from the list of all search parameters. + */ + delete(name: string): void; + /** + * Returns the first value associated to the given search parameter. + */ + get(name: string): string | null; + /** + * Returns all the values association with a given search parameter. + */ + getAll(name: string): string[]; + /** + * Returns a Boolean indicating if such a search parameter exists. + */ + has(name: string): boolean; + /** + * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. + */ + set(name: string, value: string): void; +} + +declare var URLSearchParams: { + prototype: URLSearchParams; + /** + * Constructor returning a URLSearchParams object. + */ + new (init?: string | URLSearchParams): URLSearchParams; +} + interface NodeListOf extends NodeList { length: number; item(index: number): TNode; @@ -16927,7 +18059,6 @@ interface NodeListOf extends NodeList { interface HTMLCollectionOf extends HTMLCollection { item(index: number): T; namedItem(name: string): T; - [index: number]: T; } interface BlobPropertyBag { @@ -16944,15 +18075,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -interface MessageEventInit extends EventInit { - data?: any; - origin?: string; - lastEventId?: string; - channel?: string; - source?: any; - ports?: MessagePort[]; -} - interface ProgressEventInit extends EventInit { lengthComputable?: boolean; loaded?: number; @@ -17154,8 +18276,8 @@ interface JsonWebKey { interface ParentNode { readonly children: HTMLCollection; - readonly firstElementChild: Element; - readonly lastElementChild: Element; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; readonly childElementCount: number; } @@ -17186,6 +18308,26 @@ interface AssignedNodesOptions { flatten?: boolean; } +interface ElementDefinitionOptions { + extends: string; +} + +interface CustomElementRegistry { + define(name: string, constructor: Function, options?: ElementDefinitionOptions): void; + get(name: string): any; + whenDefined(name: string): PromiseLike; +} + +interface PromiseRejectionEvent extends Event { + readonly promise: PromiseLike; + readonly reason: any; +} + +interface PromiseRejectionEventInit extends EventInit { + promise: PromiseLike; + reason?: any; +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -17221,6 +18363,18 @@ interface DecodeSuccessCallback { interface DecodeErrorCallback { (error: DOMException): void; } +interface VoidFunction { + (): void; +} +interface RTCSessionDescriptionCallback { + (sdp: RTCSessionDescription): void; +} +interface RTCPeerConnectionErrorCallback { + (error: DOMError): void; +} +interface RTCStatsCallback { + (report: RTCStatsReport): void; +} interface FunctionStringCallback { (data: string): void; } @@ -17233,6 +18387,12 @@ interface NavigatorUserMediaErrorCallback { interface ForEachCallback { (keyId: any, status: string): void; } +interface NotificationPermissionCallback { + (permission: string): void; +} +interface IntersectionObserverCallback { + (entries: IntersectionObserverEntry[], observer: IntersectionObserver): void; +} interface HTMLElementTagNameMap { "a": HTMLAnchorElement; "applet": HTMLAppletElement; @@ -17248,6 +18408,7 @@ interface HTMLElementTagNameMap { "caption": HTMLTableCaptionElement; "col": HTMLTableColElement; "colgroup": HTMLTableColElement; + "data": HTMLDataElement; "datalist": HTMLDataListElement; "del": HTMLModElement; "dir": HTMLDirectoryElement; @@ -17288,6 +18449,7 @@ interface HTMLElementTagNameMap { "ol": HTMLOListElement; "optgroup": HTMLOptGroupElement; "option": HTMLOptionElement; + "output": HTMLOutputElement; "p": HTMLParagraphElement; "param": HTMLParamElement; "picture": HTMLPictureElement; @@ -17307,6 +18469,7 @@ interface HTMLElementTagNameMap { "tfoot": HTMLTableSectionElement; "th": HTMLTableHeaderCellElement; "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; "title": HTMLTitleElement; "tr": HTMLTableRowElement; "track": HTMLTrackElement; @@ -17344,6 +18507,7 @@ interface ElementTagNameMap { "code": HTMLElement; "col": HTMLTableColElement; "colgroup": HTMLTableColElement; + "data": HTMLDataElement; "datalist": HTMLDataListElement; "dd": HTMLElement; "defs": SVGDefsElement; @@ -17437,6 +18601,7 @@ interface ElementTagNameMap { "ol": HTMLOListElement; "optgroup": HTMLOptGroupElement; "option": HTMLOptionElement; + "output": HTMLOutputElement; "p": HTMLParagraphElement; "param": HTMLParamElement; "path": SVGPathElement; @@ -17479,6 +18644,7 @@ interface ElementTagNameMap { "tfoot": HTMLTableSectionElement; "th": HTMLTableHeaderCellElement; "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; "title": HTMLTitleElement; "tr": HTMLTableRowElement; "track": HTMLTrackElement; @@ -17523,6 +18689,7 @@ interface ElementListTagNameMap { "code": NodeListOf; "col": NodeListOf; "colgroup": NodeListOf; + "data": NodeListOf; "datalist": NodeListOf; "dd": NodeListOf; "defs": NodeListOf; @@ -17616,6 +18783,7 @@ interface ElementListTagNameMap { "ol": NodeListOf; "optgroup": NodeListOf; "option": NodeListOf; + "output": NodeListOf; "p": NodeListOf; "param": NodeListOf; "path": NodeListOf; @@ -17658,6 +18826,7 @@ interface ElementListTagNameMap { "tfoot": NodeListOf; "th": NodeListOf; "thead": NodeListOf; + "time": NodeListOf; "title": NodeListOf; "tr": NodeListOf; "track": NodeListOf; @@ -17678,6 +18847,7 @@ declare var Audio: {new(src?: string): HTMLAudioElement; }; declare var Image: {new(width?: number, height?: number): HTMLImageElement; }; declare var Option: {new(text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; }; declare var applicationCache: ApplicationCache; +declare var caches: CacheStorage; declare var clientInformation: Navigator; declare var closed: boolean; declare var crypto: Crypto; @@ -17692,10 +18862,12 @@ declare var frames: Window; declare var history: History; declare var innerHeight: number; declare var innerWidth: number; +declare var isSecureContext: boolean; declare var length: number; declare var location: Location; declare var locationbar: BarProp; declare var menubar: BarProp; +declare var msContentScript: ExtensionScriptApis; declare var msCredentials: MSCredentials; declare const name: never; declare var navigator: Navigator; @@ -17809,18 +18981,21 @@ declare var scrollX: number; declare var scrollY: number; declare var scrollbars: BarProp; declare var self: Window; +declare var speechSynthesis: SpeechSynthesis; declare var status: string; declare var statusbar: BarProp; declare var styleMedia: StyleMedia; declare var toolbar: BarProp; declare var top: Window; declare var window: Window; +declare var customElements: CustomElementRegistry; declare function alert(message?: any): void; declare function blur(): void; declare function cancelAnimationFrame(handle: number): void; declare function captureEvents(): void; declare function close(): void; declare function confirm(message?: string): boolean; +declare function departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; declare function focus(): void; declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; declare function getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -17840,6 +19015,7 @@ declare function resizeTo(x?: number, y?: number): void; declare function scroll(x?: number, y?: number): void; declare function scrollBy(x?: number, y?: number): void; declare function scrollTo(x?: number, y?: number): void; +declare function stop(): void; declare function webkitCancelAnimationFrame(handle: number): void; declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; @@ -17874,10 +19050,13 @@ declare var onwheel: (this: Window, ev: WheelEvent) => any; declare var indexedDB: IDBFactory; declare function atob(encodedString: string): string; declare function btoa(rawString: string): string; +declare function fetch(input: RequestInfo, init?: RequestInit): Promise; declare function addEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; type AAGUID = string; type AlgorithmIdentifier = string | Algorithm; +type BodyInit = any; +type ByteString = string; type ConstrainBoolean = boolean | ConstrainBooleanParameters; type ConstrainDOMString = string | string[] | ConstrainDOMStringParameters; type ConstrainDouble = number | ConstrainDoubleRange; @@ -17897,6 +19076,7 @@ type GLsizeiptr = number; type GLubyte = number; type GLuint = number; type GLushort = number; +type HeadersInit = any; type IDBKeyPath = string; type KeyFormat = string; type KeyType = string; @@ -17904,8 +19084,10 @@ type KeyUsage = string; type MSInboundPayload = MSVideoRecvPayload | MSAudioRecvPayload; type MSLocalClientEvent = MSLocalClientEventBase | MSAudioLocalClientEvent; type MSOutboundPayload = MSVideoSendPayload | MSAudioSendPayload; -type RTCIceGatherCandidate = RTCIceCandidate | RTCIceCandidateComplete; +type RTCIceGatherCandidate = RTCIceCandidateDictionary | RTCIceCandidateComplete; type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport; +type RequestInfo = Request | string; +type USVString = string; type payloadtype = number; type ScrollBehavior = "auto" | "instant" | "smooth"; type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index 6ee35cd6589..39a0c3da684 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -23,18 +23,50 @@ and limitations under the License. /// IE DOM APIs ///////////////////////////// +interface Account { + rpDisplayName?: string; + displayName?: string; + id?: string; + name?: string; + imageURL?: string; +} + interface Algorithm { name: string; } -interface AriaRequestEventInit extends EventInit { - attributeName?: string; - attributeValue?: string; +interface AnimationEventInit extends EventInit { + animationName?: string; + elapsedTime?: number; } -interface CommandEventInit extends EventInit { - commandName?: string; - detail?: string; +interface AssertionOptions { + timeoutSeconds?: number; + rpId?: USVString; + allowList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface CacheQueryOptions { + ignoreSearch?: boolean; + ignoreMethod?: boolean; + ignoreVary?: boolean; + cacheName?: string; +} + +interface ClientData { + challenge?: string; + origin?: string; + rpId?: string; + hashAlg?: string | Algorithm; + tokenBinding?: string; + extensions?: WebAuthnExtensions; +} + +interface CloseEventInit extends EventInit { + wasClean?: boolean; + code?: number; + reason?: string; } interface CompositionEventInit extends UIEventInit { @@ -74,6 +106,13 @@ interface CustomEventInit extends EventInit { detail?: any; } +interface DOMRectInit { + x?: any; + y?: any; + width?: any; + height?: any; +} + interface DeviceAccelerationDict { x?: number; y?: number; @@ -84,6 +123,20 @@ interface DeviceLightEventInit extends EventInit { value?: number; } +interface DeviceMotionEventInit extends EventInit { + acceleration?: DeviceAccelerationDict; + accelerationIncludingGravity?: DeviceAccelerationDict; + rotationRate?: DeviceRotationRateDict; + interval?: number; +} + +interface DeviceOrientationEventInit extends EventInit { + alpha?: number; + beta?: number; + gamma?: number; + absolute?: boolean; +} + interface DeviceRotationRateDict { alpha?: number; beta?: number; @@ -95,6 +148,14 @@ interface DoubleRange { min?: number; } +interface ErrorEventInit extends EventInit { + message?: string; + filename?: string; + lineno?: number; + colno?: number; + error?: any; +} + interface EventInit { scoped?: boolean; bubbles?: boolean; @@ -127,6 +188,29 @@ interface FocusEventInit extends UIEventInit { relatedTarget?: EventTarget; } +interface FocusNavigationEventInit extends EventInit { + navigationReason?: string; + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface FocusNavigationOrigin { + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface GamepadEventInit extends EventInit { + gamepad?: Gamepad; +} + +interface GetNotificationOptions { + tag?: string; +} + interface HashChangeEventInit extends EventInit { newURL?: string; oldURL?: string; @@ -142,6 +226,20 @@ interface IDBObjectStoreParameters { keyPath?: IDBKeyPath; } +interface IntersectionObserverEntryInit { + time?: number; + rootBounds?: DOMRectInit; + boundingClientRect?: DOMRectInit; + intersectionRect?: DOMRectInit; + target?: Element; +} + +interface IntersectionObserverInit { + root?: Element; + rootMargin?: string; + threshold?: number | number[]; +} + interface KeyAlgorithm { name?: string; } @@ -344,6 +442,11 @@ interface MSPayloadBase extends RTCStats { payloadDescription?: string; } +interface MSPortRange { + min?: number; + max?: number; +} + interface MSRelayAddress { relayAddress?: string; port?: number; @@ -394,7 +497,7 @@ interface MSUtilization { } interface MSVideoPayload extends MSPayloadBase { - resoluton?: string; + resolution?: string; videoBitRateAvg?: number; videoBitRateMax?: number; videoFrameRateAvg?: number; @@ -477,6 +580,10 @@ interface MediaStreamErrorEventInit extends EventInit { error?: MediaStreamError; } +interface MediaStreamEventInit extends EventInit { + stream?: MediaStream; +} + interface MediaStreamTrackEventInit extends EventInit { track?: MediaStreamTrack; } @@ -541,6 +648,15 @@ interface MediaTrackSupportedConstraints { groupId?: boolean; } +interface MessageEventInit extends EventInit { + lastEventId?: string; + channel?: string; + data?: any; + origin?: string; + source?: Window; + ports?: MessagePort[]; +} + interface MouseEventInit extends EventModifierInit { screenX?: number; screenY?: number; @@ -570,10 +686,68 @@ interface MutationObserverInit { attributeFilter?: string[]; } +interface NotificationOptions { + dir?: string; + lang?: string; + body?: string; + tag?: string; + icon?: string; +} + interface ObjectURLOptions { oneTimeOnly?: boolean; } +interface PaymentCurrencyAmount { + currency?: string; + value?: string; + currencySystem?: string; +} + +interface PaymentDetails { + total?: PaymentItem; + displayItems?: PaymentItem[]; + shippingOptions?: PaymentShippingOption[]; + modifiers?: PaymentDetailsModifier[]; + error?: string; +} + +interface PaymentDetailsModifier { + supportedMethods?: string[]; + total?: PaymentItem; + additionalDisplayItems?: PaymentItem[]; + data?: any; +} + +interface PaymentItem { + label?: string; + amount?: PaymentCurrencyAmount; + pending?: boolean; +} + +interface PaymentMethodData { + supportedMethods?: string[]; + data?: any; +} + +interface PaymentOptions { + requestPayerName?: boolean; + requestPayerEmail?: boolean; + requestPayerPhone?: boolean; + requestShipping?: boolean; + shippingType?: string; +} + +interface PaymentRequestUpdateEventInit extends EventInit { +} + +interface PaymentShippingOption { + id?: string; + label?: string; + amount?: PaymentCurrencyAmount; + selected?: boolean; +} + interface PeriodicWaveConstraints { disableNormalization?: boolean; } @@ -589,12 +763,34 @@ interface PointerEventInit extends MouseEventInit { isPrimary?: boolean; } +interface PopStateEventInit extends EventInit { + state?: any; +} + interface PositionOptions { enableHighAccuracy?: boolean; timeout?: number; maximumAge?: number; } +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + +interface PushSubscriptionOptionsInit { + userVisibleOnly?: boolean; + applicationServerKey?: any; +} + +interface RTCConfiguration { + iceServers?: RTCIceServer[]; + iceTransportPolicy?: string; + bundlePolicy?: string; + peerIdentity?: string; +} + interface RTCDTMFToneChangeEventInit extends EventInit { tone?: string; } @@ -609,18 +805,6 @@ interface RTCDtlsParameters { fingerprints?: RTCDtlsFingerprint[]; } -interface RTCIceCandidate { - foundation?: string; - priority?: number; - ip?: string; - protocol?: string; - port?: number; - type?: string; - tcpType?: string; - relatedAddress?: string; - relatedPort?: number; -} - interface RTCIceCandidateAttributes extends RTCStats { ipAddress?: string; portNumber?: number; @@ -633,9 +817,28 @@ interface RTCIceCandidateAttributes extends RTCStats { interface RTCIceCandidateComplete { } +interface RTCIceCandidateDictionary { + foundation?: string; + priority?: number; + ip?: string; + protocol?: string; + port?: number; + type?: string; + tcpType?: string; + relatedAddress?: string; + relatedPort?: number; + msMTurnSessionId?: string; +} + +interface RTCIceCandidateInit { + candidate?: string; + sdpMid?: string; + sdpMLineIndex?: number; +} + interface RTCIceCandidatePair { - local?: RTCIceCandidate; - remote?: RTCIceCandidate; + local?: RTCIceCandidateDictionary; + remote?: RTCIceCandidateDictionary; } interface RTCIceCandidatePairStats extends RTCStats { @@ -657,11 +860,13 @@ interface RTCIceCandidatePairStats extends RTCStats { interface RTCIceGatherOptions { gatherPolicy?: string; iceservers?: RTCIceServer[]; + portRange?: MSPortRange; } interface RTCIceParameters { usernameFragment?: string; password?: string; + iceLite?: boolean; } interface RTCIceServer { @@ -695,6 +900,13 @@ interface RTCMediaStreamTrackStats extends RTCStats { echoReturnLossEnhancement?: number; } +interface RTCOfferOptions { + offerToReceiveVideo?: number; + offerToReceiveAudio?: number; + voiceActivityDetection?: boolean; + iceRestart?: boolean; +} + interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { packetsSent?: number; bytesSent?: number; @@ -702,6 +914,10 @@ interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { roundTripTime?: number; } +interface RTCPeerConnectionIceEventInit extends EventInit { + candidate?: RTCIceCandidate; +} + interface RTCRTPStreamStats extends RTCStats { ssrc?: string; associateStatsId?: string; @@ -739,6 +955,7 @@ interface RTCRtpCodecCapability { clockRate?: number; preferredPayloadType?: number; maxptime?: number; + ptime?: number; numChannels?: number; rtcpFeedback?: RTCRtcpFeedback[]; parameters?: any; @@ -753,6 +970,7 @@ interface RTCRtpCodecParameters { payloadType?: any; clockRate?: number; maxptime?: number; + ptime?: number; numChannels?: number; rtcpFeedback?: RTCRtcpFeedback[]; parameters?: any; @@ -772,9 +990,9 @@ interface RTCRtpEncodingParameters { priority?: number; maxBitrate?: number; minQuality?: number; - framerateBias?: number; resolutionScale?: number; framerateScale?: number; + maxFramerate?: number; active?: boolean; encodingId?: string; dependencyEncodingIds?: string[]; @@ -805,6 +1023,7 @@ interface RTCRtpParameters { headerExtensions?: RTCRtpHeaderExtensionParameters[]; encodings?: RTCRtpEncodingParameters[]; rtcp?: RTCRtcpParameters; + degradationPreference?: string; } interface RTCRtpRtxParameters { @@ -817,6 +1036,11 @@ interface RTCRtpUnhandled { muxId?: string; } +interface RTCSessionDescriptionInit { + type?: string; + sdp?: string; +} + interface RTCSrtpKeyParam { keyMethod?: string; keySalt?: string; @@ -857,6 +1081,64 @@ interface RTCTransportStats extends RTCStats { remoteCertificateId?: string; } +interface RegistrationOptions { + scope?: string; +} + +interface RequestInit { + method?: string; + headers?: any; + body?: any; + referrer?: string; + referrerPolicy?: string; + mode?: string; + credentials?: string; + cache?: string; + redirect?: string; + integrity?: string; + keepalive?: boolean; + window?: any; +} + +interface ResponseInit { + status?: number; + statusText?: string; + headers?: any; +} + +interface ScopedCredentialDescriptor { + type?: string; + id?: any; + transports?: string[]; +} + +interface ScopedCredentialOptions { + timeoutSeconds?: number; + rpId?: USVString; + excludeList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface ScopedCredentialParameters { + type?: string; + algorithm?: string | Algorithm; +} + +interface ServiceWorkerMessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + source?: ServiceWorker | MessagePort; + ports?: MessagePort[]; +} + +interface SpeechSynthesisEventInit extends EventInit { + utterance?: SpeechSynthesisUtterance; + charIndex?: number; + elapsedTime?: number; + name?: string; +} + interface StoreExceptionsInformation extends ExceptionInformation { siteName?: string; explanationString?: string; @@ -867,11 +1149,23 @@ interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformat arrayOfDomainStrings?: string[]; } +interface TrackEventInit extends EventInit { + track?: VideoTrack | AudioTrack | TextTrack; +} + +interface TransitionEventInit extends EventInit { + propertyName?: string; + elapsedTime?: number; +} + interface UIEventInit extends EventInit { view?: Window; detail?: number; } +interface WebAuthnExtensions { +} + interface WebGLContextAttributes { failIfMajorPerformanceCaveat?: boolean; alpha?: boolean; @@ -897,6 +1191,18 @@ interface EventListener { (evt: Event): void; } +interface WebKitEntriesCallback { + (evt: Event): void; +} + +interface WebKitErrorCallback { + (evt: Event): void; +} + +interface WebKitFileCallback { + (evt: Event): void; +} + interface ANGLE_instanced_arrays { drawArraysInstancedANGLE(mode: number, first: number, count: number, primcount: number): void; drawElementsInstancedANGLE(mode: number, count: number, type: number, offset: number, primcount: number): void; @@ -935,14 +1241,14 @@ interface AnimationEvent extends Event { declare var AnimationEvent: { prototype: AnimationEvent; - new(): AnimationEvent; + new(typeArg: string, eventInitDict?: AnimationEventInit): AnimationEvent; } interface ApplicationCacheEventMap { "cached": Event; "checking": Event; "downloading": Event; - "error": ErrorEvent; + "error": Event; "noupdate": Event; "obsolete": Event; "progress": ProgressEvent; @@ -953,7 +1259,7 @@ interface ApplicationCache extends EventTarget { oncached: (this: ApplicationCache, ev: Event) => any; onchecking: (this: ApplicationCache, ev: Event) => any; ondownloading: (this: ApplicationCache, ev: Event) => any; - onerror: (this: ApplicationCache, ev: ErrorEvent) => any; + onerror: (this: ApplicationCache, ev: Event) => any; onnoupdate: (this: ApplicationCache, ev: Event) => any; onobsolete: (this: ApplicationCache, ev: Event) => any; onprogress: (this: ApplicationCache, ev: ProgressEvent) => any; @@ -983,16 +1289,6 @@ declare var ApplicationCache: { readonly UPDATEREADY: number; } -interface AriaRequestEvent extends Event { - readonly attributeName: string; - attributeValue: string | null; -} - -declare var AriaRequestEvent: { - prototype: AriaRequestEvent; - new(type: string, eventInitDict?: AriaRequestEventInit): AriaRequestEvent; -} - interface Attr extends Node { readonly name: string; readonly ownerElement: Element; @@ -1044,12 +1340,18 @@ declare var AudioBufferSourceNode: { new(): AudioBufferSourceNode; } -interface AudioContext extends EventTarget { +interface AudioContextEventMap { + "statechange": Event; +} + +interface AudioContextBase extends EventTarget { readonly currentTime: number; readonly destination: AudioDestinationNode; readonly listener: AudioListener; + onstatechange: (this: AudioContext, ev: Event) => any; readonly sampleRate: number; - state: string; + readonly state: string; + close(): Promise; createAnalyser(): AnalyserNode; createBiquadFilter(): BiquadFilterNode; createBuffer(numberOfChannels: number, length: number, sampleRate: number): AudioBuffer; @@ -1060,6 +1362,7 @@ interface AudioContext extends EventTarget { createDelay(maxDelayTime?: number): DelayNode; createDynamicsCompressor(): DynamicsCompressorNode; createGain(): GainNode; + createIIRFilter(feedforward: number[], feedback: number[]): IIRFilterNode; createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; createMediaStreamSource(mediaStream: MediaStream): MediaStreamAudioSourceNode; createOscillator(): OscillatorNode; @@ -1068,7 +1371,14 @@ interface AudioContext extends EventTarget { createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; createStereoPanner(): StereoPannerNode; createWaveShaper(): WaveShaperNode; - decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): PromiseLike; + decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): Promise; + resume(): Promise; + addEventListener(type: K, listener: (this: AudioContext, ev: AudioContextEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface AudioContext extends AudioContextBase { + suspend(): Promise; } declare var AudioContext: { @@ -1105,7 +1415,7 @@ interface AudioNode extends EventTarget { readonly context: AudioContext; readonly numberOfInputs: number; readonly numberOfOutputs: number; - connect(destination: AudioNode, output?: number, input?: number): void; + connect(destination: AudioNode, output?: number, input?: number): AudioNode; disconnect(output?: number): void; disconnect(destination: AudioNode, output?: number, input?: number): void; disconnect(destination: AudioParam, output?: number): void; @@ -1119,12 +1429,12 @@ declare var AudioNode: { interface AudioParam { readonly defaultValue: number; value: number; - cancelScheduledValues(startTime: number): void; - exponentialRampToValueAtTime(value: number, endTime: number): void; - linearRampToValueAtTime(value: number, endTime: number): void; - setTargetAtTime(target: number, startTime: number, timeConstant: number): void; - setValueAtTime(value: number, startTime: number): void; - setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): void; + cancelScheduledValues(startTime: number): AudioParam; + exponentialRampToValueAtTime(value: number, endTime: number): AudioParam; + linearRampToValueAtTime(value: number, endTime: number): AudioParam; + setTargetAtTime(target: number, startTime: number, timeConstant: number): AudioParam; + setValueAtTime(value: number, startTime: number): AudioParam; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): AudioParam; } declare var AudioParam: { @@ -1501,10 +1811,16 @@ interface CSSStyleDeclaration { imeMode: string | null; justifyContent: string | null; kerning: string | null; + layoutGrid: string | null; + layoutGridChar: string | null; + layoutGridLine: string | null; + layoutGridMode: string | null; + layoutGridType: string | null; left: string | null; readonly length: number; letterSpacing: string | null; lightingColor: string | null; + lineBreak: string | null; lineHeight: string | null; listStyle: string | null; listStyleImage: string | null; @@ -1576,6 +1892,7 @@ interface CSSStyleDeclaration { orphans: string | null; outline: string | null; outlineColor: string | null; + outlineOffset: string | null; outlineStyle: string | null; outlineWidth: string | null; overflow: string | null; @@ -1596,9 +1913,11 @@ interface CSSStyleDeclaration { position: string | null; quotes: string | null; right: string | null; + rotate: string | null; rubyAlign: string | null; rubyOverhang: string | null; rubyPosition: string | null; + scale: string | null; stopColor: string | null; stopOpacity: string | null; stroke: string | null; @@ -1632,6 +1951,7 @@ interface CSSStyleDeclaration { transitionDuration: string | null; transitionProperty: string | null; transitionTimingFunction: string | null; + translate: string | null; unicodeBidi: string | null; verticalAlign: string | null; visibility: string | null; @@ -1692,6 +2012,9 @@ interface CSSStyleDeclaration { webkitTapHighlightColor: string | null; webkitTextFillColor: string | null; webkitTextSizeAdjust: any; + webkitTextStroke: string | null; + webkitTextStrokeColor: string | null; + webkitTextStrokeWidth: string | null; webkitTransform: string | null; webkitTransformOrigin: string | null; webkitTransformStyle: string | null; @@ -1713,6 +2036,7 @@ interface CSSStyleDeclaration { zIndex: string | null; zoom: string | null; resize: string | null; + userSelect: string | null; getPropertyPriority(propertyName: string): string; getPropertyValue(propertyName: string): string; item(index: number): string; @@ -1740,7 +2064,6 @@ declare var CSSStyleRule: { interface CSSStyleSheet extends StyleSheet { readonly cssRules: CSSRuleList; cssText: string; - readonly href: string; readonly id: string; readonly imports: StyleSheetList; readonly isAlternate: boolean; @@ -1772,6 +2095,34 @@ declare var CSSSupportsRule: { new(): CSSSupportsRule; } +interface Cache { + add(request: RequestInfo): Promise; + addAll(requests: RequestInfo[]): Promise; + delete(request: RequestInfo, options?: CacheQueryOptions): Promise; + keys(request?: RequestInfo, options?: CacheQueryOptions): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + put(request: RequestInfo, response: Response): Promise; +} + +declare var Cache: { + prototype: Cache; + new(): Cache; +} + +interface CacheStorage { + delete(cacheName: string): Promise; + has(cacheName: string): Promise; + keys(): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + open(cacheName: string): Promise; +} + +declare var CacheStorage: { + prototype: CacheStorage; + new(): CacheStorage; +} + interface CanvasGradient { addColorStop(offset: number, color: string): void; } @@ -1796,13 +2147,13 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { font: string; globalAlpha: number; globalCompositeOperation: string; + imageSmoothingEnabled: boolean; lineCap: string; lineDashOffset: number; lineJoin: string; lineWidth: number; miterLimit: number; msFillRule: string; - msImageSmoothingEnabled: boolean; shadowBlur: number; shadowColor: string; shadowOffsetX: number; @@ -1820,6 +2171,7 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; + drawFocusIfNeeded(element: Element): void; drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; fill(fillRule?: string): void; fillRect(x: number, y: number, w: number, h: number): void; @@ -1835,7 +2187,7 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { scale(x: number, y: number): void; setLineDash(segments: number[]): void; setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; - stroke(): void; + stroke(path?: Path2D): void; strokeRect(x: number, y: number, w: number, h: number): void; strokeText(text: string, x: number, y: number, maxWidth?: number): void; transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; @@ -1921,17 +2273,7 @@ interface CloseEvent extends Event { declare var CloseEvent: { prototype: CloseEvent; - new(): CloseEvent; -} - -interface CommandEvent extends Event { - readonly commandName: string; - readonly detail: string | null; -} - -declare var CommandEvent: { - prototype: CommandEvent; - new(type: string, eventInitDict?: CommandEventInit): CommandEvent; + new(typeArg: string, eventInitDict?: CloseEventInit): CloseEvent; } interface Comment extends CharacterData { @@ -1958,7 +2300,7 @@ interface Console { assert(test?: boolean, message?: string, ...optionalParams: any[]): void; clear(): void; count(countTitle?: string): void; - debug(message?: string, ...optionalParams: any[]): void; + debug(message?: any, ...optionalParams: any[]): void; dir(value?: any, ...optionalParams: any[]): void; dirxml(value: any): void; error(message?: any, ...optionalParams: any[]): void; @@ -2128,9 +2470,9 @@ declare var DOMException: { interface DOMImplementation { createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType): Document; - createDocumentType(qualifiedName: string, publicId: string | null, systemId: string | null): DocumentType; + createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; createHTMLDocument(title: string): Document; - hasFeature(feature: string | null, version: string | null): boolean; + hasFeature(): boolean; } declare var DOMImplementation: { @@ -2169,7 +2511,7 @@ declare var DOMStringList: { } interface DOMStringMap { - [name: string]: string; + [name: string]: string | undefined; } declare var DOMStringMap: { @@ -2195,7 +2537,7 @@ declare var DOMTokenList: { interface DataCue extends TextTrackCue { data: ArrayBuffer; - addEventListener(type: K, listener: (this: TextTrackCue, ev: TextTrackCueEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: DataCue, ev: TextTrackCueEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -2225,6 +2567,7 @@ interface DataTransferItem { readonly type: string; getAsFile(): File | null; getAsString(_callback: FunctionStringCallback | null): void; + webkitGetAsEntry(): any; } declare var DataTransferItem: { @@ -2285,7 +2628,7 @@ interface DeviceLightEvent extends Event { declare var DeviceLightEvent: { prototype: DeviceLightEvent; - new(type: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; + new(typeArg: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; } interface DeviceMotionEvent extends Event { @@ -2298,7 +2641,7 @@ interface DeviceMotionEvent extends Event { declare var DeviceMotionEvent: { prototype: DeviceMotionEvent; - new(): DeviceMotionEvent; + new(typeArg: string, eventInitDict?: DeviceMotionEventInit): DeviceMotionEvent; } interface DeviceOrientationEvent extends Event { @@ -2311,7 +2654,7 @@ interface DeviceOrientationEvent extends Event { declare var DeviceOrientationEvent: { prototype: DeviceOrientationEvent; - new(): DeviceOrientationEvent; + new(typeArg: string, eventInitDict?: DeviceOrientationEventInit): DeviceOrientationEvent; } interface DeviceRotationRate { @@ -2393,7 +2736,7 @@ interface DocumentEventMap extends GlobalEventHandlersEventMap { "pointerlockerror": Event; "progress": ProgressEvent; "ratechange": Event; - "readystatechange": ProgressEvent; + "readystatechange": Event; "reset": Event; "scroll": UIEvent; "seeked": Event; @@ -2464,10 +2807,6 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven readonly compatMode: string; cookie: string; readonly currentScript: HTMLScriptElement | SVGScriptElement; - /** - * Gets the default character set from the current regional language settings. - */ - readonly defaultCharset: string; readonly defaultView: Window; /** * Sets or gets a value that indicates whether the document can be edited. @@ -2774,7 +3113,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Fires when the state of the object has changed. * @param ev The event */ - onreadystatechange: (this: Document, ev: ProgressEvent) => any; + onreadystatechange: (this: Document, ev: Event) => any; /** * Fires when the user resets a form. * @param ev The event. @@ -3142,8 +3481,8 @@ interface DocumentType extends Node, ChildNode { readonly internalSubset: string | null; readonly name: string; readonly notations: NamedNodeMap; - readonly publicId: string | null; - readonly systemId: string | null; + readonly publicId: string; + readonly systemId: string; } declare var DocumentType: { @@ -3166,7 +3505,7 @@ interface DynamicsCompressorNode extends AudioNode { readonly attack: AudioParam; readonly knee: AudioParam; readonly ratio: AudioParam; - readonly reduction: AudioParam; + readonly reduction: number; readonly release: AudioParam; readonly threshold: AudioParam; } @@ -3197,8 +3536,8 @@ declare var EXT_texture_filter_anisotropic: { } interface ElementEventMap extends GlobalEventHandlersEventMap { - "ariarequest": AriaRequestEvent; - "command": CommandEvent; + "ariarequest": Event; + "command": Event; "gotpointercapture": PointerEvent; "lostpointercapture": PointerEvent; "MSGestureChange": MSGestureEvent; @@ -3234,10 +3573,11 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec readonly clientTop: number; readonly clientWidth: number; id: string; + innerHTML: string; msContentZoomFactor: number; readonly msRegionOverflow: string; - onariarequest: (this: Element, ev: AriaRequestEvent) => any; - oncommand: (this: Element, ev: CommandEvent) => any; + onariarequest: (this: Element, ev: Event) => any; + oncommand: (this: Element, ev: Event) => any; ongotpointercapture: (this: Element, ev: PointerEvent) => any; onlostpointercapture: (this: Element, ev: PointerEvent) => any; onmsgesturechange: (this: Element, ev: MSGestureEvent) => any; @@ -3263,13 +3603,13 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec ontouchstart: (ev: TouchEvent) => any; onwebkitfullscreenchange: (this: Element, ev: Event) => any; onwebkitfullscreenerror: (this: Element, ev: Event) => any; + outerHTML: string; readonly prefix: string | null; readonly scrollHeight: number; scrollLeft: number; scrollTop: number; readonly scrollWidth: number; readonly tagName: string; - innerHTML: string; readonly assignedSlot: HTMLSlotElement | null; slot: string; readonly shadowRoot: ShadowRoot | null; @@ -3293,7 +3633,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec msSetPointerCapture(pointerId: number): void; msZoomTo(args: MsZoomToOptions): void; releasePointerCapture(pointerId: number): void; - removeAttribute(name?: string): void; + removeAttribute(qualifiedName: string): void; removeAttributeNS(namespaceURI: string, localName: string): void; removeAttributeNode(oldAttr: Attr): Attr; requestFullscreen(): void; @@ -3340,7 +3680,7 @@ interface ErrorEvent extends Event { declare var ErrorEvent: { prototype: ErrorEvent; - new(): ErrorEvent; + new(type: string, errorEventInitDict?: ErrorEventInit): ErrorEvent; } interface Event { @@ -3369,7 +3709,7 @@ interface Event { declare var Event: { prototype: Event; - new(type: string, eventInitDict?: EventInit): Event; + new(typeArg: string, eventInitDict?: EventInit): Event; readonly AT_TARGET: number; readonly BUBBLING_PHASE: number; readonly CAPTURING_PHASE: number; @@ -3386,6 +3726,21 @@ declare var EventTarget: { new(): EventTarget; } +interface ExtensionScriptApis { + extensionIdToShortId(extensionId: string): number; + fireExtensionApiTelemetry(functionName: string, isSucceeded: boolean, isSupported: boolean): void; + genericFunction(routerAddress: any, parameters?: string, callbackId?: number): void; + genericSynchronousFunction(functionId: number, parameters?: string): string; + getExtensionId(): string; + registerGenericFunctionCallbackHandler(callbackHandler: any): void; + registerGenericPersistentCallbackHandler(callbackHandler: any): void; +} + +declare var ExtensionScriptApis: { + prototype: ExtensionScriptApis; + new(): ExtensionScriptApis; +} + interface External { } @@ -3422,7 +3777,7 @@ interface FileReader extends EventTarget, MSBaseReader { readAsBinaryString(blob: Blob): void; readAsDataURL(blob: Blob): void; readAsText(blob: Blob, encoding?: string): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3441,6 +3796,20 @@ declare var FocusEvent: { new(typeArg: string, eventInitDict?: FocusEventInit): FocusEvent; } +interface FocusNavigationEvent extends Event { + readonly navigationReason: string; + readonly originHeight: number; + readonly originLeft: number; + readonly originTop: number; + readonly originWidth: number; + requestFocus(): void; +} + +declare var FocusNavigationEvent: { + prototype: FocusNavigationEvent; + new(type: string, eventInitDict?: FocusNavigationEventInit): FocusNavigationEvent; +} + interface FormData { append(name: any, value: any, blobName?: string): void; } @@ -3490,7 +3859,7 @@ interface GamepadEvent extends Event { declare var GamepadEvent: { prototype: GamepadEvent; - new(): GamepadEvent; + new(typeArg: string, eventInitDict?: GamepadEventInit): GamepadEvent; } interface Geolocation { @@ -3504,8 +3873,11 @@ declare var Geolocation: { new(): Geolocation; } -interface HTMLAllCollection extends HTMLCollection { - namedItem(name: string): Element; +interface HTMLAllCollection { + readonly length: number; + item(nameOrIndex?: string): HTMLCollection | Element | null; + namedItem(name: string): HTMLCollection | Element | null; + [index: number]: Element; } declare var HTMLAllCollection: { @@ -3593,7 +3965,7 @@ interface HTMLAnchorElement extends HTMLElement { * Returns a string representation of an object. */ toString(): string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAnchorElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3667,7 +4039,7 @@ interface HTMLAppletElement extends HTMLElement { useMap: string; vspace: number; width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAppletElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3735,7 +4107,7 @@ interface HTMLAreaElement extends HTMLElement { * Returns a string representation of an object. */ toString(): string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3744,15 +4116,7 @@ declare var HTMLAreaElement: { new(): HTMLAreaElement; } -interface HTMLAreasCollection extends HTMLCollection { - /** - * Adds an element to the areas, controlRange, or options collection. - */ - add(element: HTMLElement, before?: HTMLElement | number): void; - /** - * Removes an element from the collection. - */ - remove(index?: number): void; +interface HTMLAreasCollection extends HTMLCollectionBase { } declare var HTMLAreasCollection: { @@ -3761,7 +4125,7 @@ declare var HTMLAreasCollection: { } interface HTMLAudioElement extends HTMLMediaElement { - addEventListener(type: K, listener: (this: HTMLMediaElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAudioElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3775,7 +4139,7 @@ interface HTMLBRElement extends HTMLElement { * Sets or retrieves the side on which floating objects are not to be positioned when any IHTMLBlockElement is inserted into the document. */ clear: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3793,7 +4157,7 @@ interface HTMLBaseElement extends HTMLElement { * Sets or retrieves the window or frame at which to target content. */ target: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBaseElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3811,7 +4175,7 @@ interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty * Sets or retrieves the font size of the object. */ size: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBaseFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3837,6 +4201,7 @@ interface HTMLBodyElementEventMap extends HTMLElementEventMap { "pageshow": PageTransitionEvent; "popstate": PopStateEvent; "resize": UIEvent; + "scroll": UIEvent; "storage": StorageEvent; "unload": Event; } @@ -3864,6 +4229,7 @@ interface HTMLBodyElement extends HTMLElement { onpageshow: (this: HTMLBodyElement, ev: PageTransitionEvent) => any; onpopstate: (this: HTMLBodyElement, ev: PopStateEvent) => any; onresize: (this: HTMLBodyElement, ev: UIEvent) => any; + onscroll: (this: HTMLBodyElement, ev: UIEvent) => any; onstorage: (this: HTMLBodyElement, ev: StorageEvent) => any; onunload: (this: HTMLBodyElement, ev: Event) => any; text: any; @@ -3941,7 +4307,7 @@ interface HTMLButtonElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLButtonElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3976,7 +4342,7 @@ interface HTMLCanvasElement extends HTMLElement { */ toDataURL(type?: string, ...args: any[]): string; toBlob(callback: (result: Blob | null) => void, type?: string, ...arguments: any[]): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLCanvasElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3985,7 +4351,7 @@ declare var HTMLCanvasElement: { new(): HTMLCanvasElement; } -interface HTMLCollection { +interface HTMLCollectionBase { /** * Sets or retrieves the number of objects in a collection. */ @@ -3994,11 +4360,14 @@ interface HTMLCollection { * Retrieves an object from various collections. */ item(index: number): Element; + [index: number]: Element; +} + +interface HTMLCollection extends HTMLCollectionBase { /** * Retrieves a select object or an object from an options collection. */ - namedItem(name: string): Element; - [index: number]: Element; + namedItem(name: string): Element | null; } declare var HTMLCollection: { @@ -4008,7 +4377,7 @@ declare var HTMLCollection: { interface HTMLDListElement extends HTMLElement { compact: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4017,9 +4386,20 @@ declare var HTMLDListElement: { new(): HTMLDListElement; } +interface HTMLDataElement extends HTMLElement { + value: string; + addEventListener(type: K, listener: (this: HTMLDataElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDataElement: { + prototype: HTMLDataElement; + new(): HTMLDataElement; +} + interface HTMLDataListElement extends HTMLElement { options: HTMLCollectionOf; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDataListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4030,7 +4410,7 @@ declare var HTMLDataListElement: { interface HTMLDirectoryElement extends HTMLElement { compact: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDirectoryElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4048,7 +4428,7 @@ interface HTMLDivElement extends HTMLElement { * Sets or retrieves whether the browser automatically performs wordwrap. */ noWrap: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDivElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4058,7 +4438,7 @@ declare var HTMLDivElement: { } interface HTMLDocument extends Document { - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4146,7 +4526,6 @@ interface HTMLElement extends Element { draggable: boolean; hidden: boolean; hideFocus: boolean; - innerHTML: string; innerText: string; readonly isContentEditable: boolean; lang: string; @@ -4222,7 +4601,6 @@ interface HTMLElement extends Element { ontimeupdate: (this: HTMLElement, ev: Event) => any; onvolumechange: (this: HTMLElement, ev: Event) => any; onwaiting: (this: HTMLElement, ev: Event) => any; - outerHTML: string; outerText: string; spellcheck: boolean; readonly style: CSSStyleDeclaration; @@ -4233,7 +4611,6 @@ interface HTMLElement extends Element { dragDrop(): boolean; focus(): void; msGetInputContext(): MSInputMethodContext; - setActive(): void; addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4290,7 +4667,7 @@ interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { * Sets or retrieves the width of the object. */ width: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLEmbedElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4309,6 +4686,7 @@ interface HTMLFieldSetElement extends HTMLElement { * Retrieves a reference to the form that the object is embedded in. */ readonly form: HTMLFormElement; + name: string; /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. */ @@ -4330,7 +4708,7 @@ interface HTMLFieldSetElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFieldSetElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4344,7 +4722,7 @@ interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOM * Sets or retrieves the current typeface family. */ face: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4353,6 +4731,15 @@ declare var HTMLFontElement: { new(): HTMLFontElement; } +interface HTMLFormControlsCollection extends HTMLCollectionBase { + namedItem(name: string): HTMLCollection | Element | null; +} + +declare var HTMLFormControlsCollection: { + prototype: HTMLFormControlsCollection; + new(): HTMLFormControlsCollection; +} + interface HTMLFormElement extends HTMLElement { /** * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. @@ -4369,7 +4756,7 @@ interface HTMLFormElement extends HTMLElement { /** * Retrieves a collection, in source order, of all controls in a given form. */ - readonly elements: HTMLCollection; + readonly elements: HTMLFormControlsCollection; /** * Sets or retrieves the MIME encoding for the form. */ @@ -4420,7 +4807,7 @@ interface HTMLFormElement extends HTMLElement { * Fires when a FORM is about to be submitted. */ submit(): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFormElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; [name: string]: any; } @@ -4509,6 +4896,7 @@ declare var HTMLFrameElement: { } interface HTMLFrameSetElementEventMap extends HTMLElementEventMap { + "afterprint": Event; "beforeprint": Event; "beforeunload": BeforeUnloadEvent; "blur": FocusEvent; @@ -4522,7 +4910,9 @@ interface HTMLFrameSetElementEventMap extends HTMLElementEventMap { "orientationchange": Event; "pagehide": PageTransitionEvent; "pageshow": PageTransitionEvent; + "popstate": PopStateEvent; "resize": UIEvent; + "scroll": UIEvent; "storage": StorageEvent; "unload": Event; } @@ -4566,7 +4956,9 @@ interface HTMLFrameSetElement extends HTMLElement { onorientationchange: (this: HTMLFrameSetElement, ev: Event) => any; onpagehide: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; onpageshow: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; + onpopstate: (this: HTMLFrameSetElement, ev: PopStateEvent) => any; onresize: (this: HTMLFrameSetElement, ev: UIEvent) => any; + onscroll: (this: HTMLFrameSetElement, ev: UIEvent) => any; onstorage: (this: HTMLFrameSetElement, ev: StorageEvent) => any; onunload: (this: HTMLFrameSetElement, ev: Event) => any; /** @@ -4595,7 +4987,7 @@ interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2 * Sets or retrieves the width of the object. */ width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4606,7 +4998,7 @@ declare var HTMLHRElement: { interface HTMLHeadElement extends HTMLElement { profile: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHeadElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4620,7 +5012,7 @@ interface HTMLHeadingElement extends HTMLElement { * Sets or retrieves a value that indicates the table alignment. */ align: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHeadingElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4634,7 +5026,7 @@ interface HTMLHtmlElement extends HTMLElement { * Sets or retrieves the DTD version that governs the current document. */ version: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHtmlElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4653,6 +5045,7 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { */ align: string; allowFullscreen: boolean; + allowPaymentRequest: boolean; /** * Specifies the properties of a border drawn around an object. */ @@ -4748,7 +5141,7 @@ interface HTMLImageElement extends HTMLElement { * Retrieves whether the object is fully loaded. */ readonly complete: boolean; - crossOrigin: string; + crossOrigin: string | null; readonly currentSrc: string; /** * Sets or retrieves the height of the object. @@ -4813,14 +5206,13 @@ interface HTMLImageElement extends HTMLElement { readonly x: number; readonly y: number; msGetAsCastingSource(): any; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLImageElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLImageElement: { prototype: HTMLImageElement; new(): HTMLImageElement; - create(): HTMLImageElement; } interface HTMLInputElement extends HTMLElement { @@ -5026,7 +5418,7 @@ interface HTMLInputElement extends HTMLElement { * @param n Value to increment the value by. */ stepUp(n?: number): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLInputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5041,7 +5433,7 @@ interface HTMLLIElement extends HTMLElement { * Sets or retrieves the value of a list item. */ value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLIElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5059,7 +5451,7 @@ interface HTMLLabelElement extends HTMLElement { * Sets or retrieves the object to which the given label object is assigned. */ htmlFor: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLabelElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5077,7 +5469,7 @@ interface HTMLLegendElement extends HTMLElement { * Retrieves a reference to the form that the object is embedded in. */ readonly form: HTMLFormElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5122,7 +5514,7 @@ interface HTMLLinkElement extends HTMLElement, LinkStyle { type: string; import?: Document; integrity: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLinkElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5140,7 +5532,7 @@ interface HTMLMapElement extends HTMLElement { * Sets or retrieves the name of the object. */ name: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMapElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5203,7 +5595,7 @@ interface HTMLMediaElement extends HTMLElement { * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). */ controls: boolean; - crossOrigin: string; + crossOrigin: string | null; /** * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. */ @@ -5344,7 +5736,7 @@ interface HTMLMediaElement extends HTMLElement { * Loads and starts playback of a media resource. */ play(): void; - setMediaKeys(mediaKeys: MediaKeys | null): PromiseLike; + setMediaKeys(mediaKeys: MediaKeys | null): Promise; readonly HAVE_CURRENT_DATA: number; readonly HAVE_ENOUGH_DATA: number; readonly HAVE_FUTURE_DATA: number; @@ -5375,7 +5767,7 @@ declare var HTMLMediaElement: { interface HTMLMenuElement extends HTMLElement { compact: boolean; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMenuElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5409,7 +5801,7 @@ interface HTMLMetaElement extends HTMLElement { * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. */ url: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMetaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5425,7 +5817,7 @@ interface HTMLMeterElement extends HTMLElement { min: number; optimum: number; value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMeterElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5443,7 +5835,7 @@ interface HTMLModElement extends HTMLElement { * Sets or retrieves the date and time of a modification to the object. */ dateTime: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLModElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5459,7 +5851,7 @@ interface HTMLOListElement extends HTMLElement { */ start: number; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5537,10 +5929,6 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { * Sets or retrieves the name of the object. */ name: string; - /** - * Retrieves the contained object. - */ - readonly object: any; readonly readyState: number; /** * Sets or retrieves a message to be displayed while an object is loading. @@ -5580,7 +5968,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLObjectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5619,7 +6007,7 @@ interface HTMLOptGroupElement extends HTMLElement { * Sets or retrieves the value which is returned to the server when the form control is submitted. */ value: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOptGroupElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5658,14 +6046,13 @@ interface HTMLOptionElement extends HTMLElement { * Sets or retrieves the value which is returned to the server when the form control is submitted. */ value: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLOptionElement: { prototype: HTMLOptionElement; new(): HTMLOptionElement; - create(): HTMLOptionElement; } interface HTMLOptionsCollection extends HTMLCollectionOf { @@ -5680,13 +6067,35 @@ declare var HTMLOptionsCollection: { new(): HTMLOptionsCollection; } +interface HTMLOutputElement extends HTMLElement { + defaultValue: string; + readonly form: HTMLFormElement; + readonly htmlFor: DOMSettableTokenList; + name: string; + readonly type: string; + readonly validationMessage: string; + readonly validity: ValidityState; + value: string; + readonly willValidate: boolean; + checkValidity(): boolean; + reportValidity(): boolean; + setCustomValidity(error: string): void; + addEventListener(type: K, listener: (this: HTMLOutputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLOutputElement: { + prototype: HTMLOutputElement; + new(): HTMLOutputElement; +} + interface HTMLParagraphElement extends HTMLElement { /** * Sets or retrieves how the object is aligned with adjacent text. */ align: string; clear: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLParagraphElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5712,7 +6121,7 @@ interface HTMLParamElement extends HTMLElement { * Sets or retrieves the data type of the value attribute. */ valueType: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLParamElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5722,7 +6131,7 @@ declare var HTMLParamElement: { } interface HTMLPictureElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLPictureElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5736,7 +6145,7 @@ interface HTMLPreElement extends HTMLElement { * Sets or gets a value that you can use to implement your own width functionality for the object. */ width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLPreElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5762,7 +6171,7 @@ interface HTMLProgressElement extends HTMLElement { * Sets or gets the current value of a progress element. The value must be a non-negative number between 0 and the max value. */ value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLProgressElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5776,7 +6185,7 @@ interface HTMLQuoteElement extends HTMLElement { * Sets or retrieves reference information about the object. */ cite: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLQuoteElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5791,6 +6200,7 @@ interface HTMLScriptElement extends HTMLElement { * Sets or retrieves the character set used to encode the object. */ charset: string; + crossOrigin: string | null; /** * Sets or retrieves the status of the script. */ @@ -5816,7 +6226,7 @@ interface HTMLScriptElement extends HTMLElement { */ type: string; integrity: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLScriptElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5912,7 +6322,7 @@ interface HTMLSelectElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSelectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; [name: string]: any; } @@ -5938,7 +6348,7 @@ interface HTMLSourceElement extends HTMLElement { * Gets or sets the MIME type of a media resource. */ type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSourceElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5948,7 +6358,7 @@ declare var HTMLSourceElement: { } interface HTMLSpanElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSpanElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5967,7 +6377,7 @@ interface HTMLStyleElement extends HTMLElement, LinkStyle { * Retrieves the CSS language in which the style sheet is written. */ type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLStyleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5985,7 +6395,7 @@ interface HTMLTableCaptionElement extends HTMLElement { * Sets or retrieves whether the caption appears at the top or bottom of the table. */ vAlign: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableCaptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6040,7 +6450,7 @@ interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment { * Sets or retrieves the width of the object. */ width: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6062,7 +6472,7 @@ interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { * Sets or retrieves the width of the object. */ width: any; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableColElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6072,6 +6482,8 @@ declare var HTMLTableColElement: { } interface HTMLTableDataCellElement extends HTMLTableCellElement { + addEventListener(type: K, listener: (this: HTMLTableDataCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLTableDataCellElement: { @@ -6183,7 +6595,7 @@ interface HTMLTableElement extends HTMLElement { * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. */ insertRow(index?: number): HTMLTableRowElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6197,6 +6609,8 @@ interface HTMLTableHeaderCellElement extends HTMLTableCellElement { * Sets or retrieves the group of cells in a table to which the object's information applies. */ scope: string; + addEventListener(type: K, listener: (this: HTMLTableHeaderCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLTableHeaderCellElement: { @@ -6236,7 +6650,7 @@ interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment { * @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. */ insertCell(index?: number): HTMLTableDataCellElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableRowElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6264,7 +6678,7 @@ interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment { * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. */ insertRow(index?: number): HTMLTableRowElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableSectionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6275,7 +6689,7 @@ declare var HTMLTableSectionElement: { interface HTMLTemplateElement extends HTMLElement { readonly content: DocumentFragment; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTemplateElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6382,7 +6796,7 @@ interface HTMLTextAreaElement extends HTMLElement { * @param end The offset into the text field for the end of the selection. */ setSelectionRange(start: number, end: number): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTextAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6391,12 +6805,23 @@ declare var HTMLTextAreaElement: { new(): HTMLTextAreaElement; } +interface HTMLTimeElement extends HTMLElement { + dateTime: string; + addEventListener(type: K, listener: (this: HTMLTimeElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTimeElement: { + prototype: HTMLTimeElement; + new(): HTMLTimeElement; +} + interface HTMLTitleElement extends HTMLElement { /** * Retrieves or sets the text of the object as a string. */ text: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTitleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6417,7 +6842,7 @@ interface HTMLTrackElement extends HTMLElement { readonly LOADED: number; readonly LOADING: number; readonly NONE: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTrackElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6433,7 +6858,7 @@ declare var HTMLTrackElement: { interface HTMLUListElement extends HTMLElement { compact: boolean; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLUListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6443,7 +6868,7 @@ declare var HTMLUListElement: { } interface HTMLUnknownElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLUnknownElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6514,7 +6939,21 @@ interface HashChangeEvent extends Event { declare var HashChangeEvent: { prototype: HashChangeEvent; - new(type: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; + new(typeArg: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; +} + +interface Headers { + append(name: string, value: string): void; + delete(name: string): void; + forEach(callback: ForEachCallback): void; + get(name: string): string | null; + has(name: string): boolean; + set(name: string, value: string): void; +} + +declare var Headers: { + prototype: Headers; + new(init?: any): Headers; } interface History { @@ -6568,14 +7007,14 @@ declare var IDBCursorWithValue: { interface IDBDatabaseEventMap { "abort": Event; - "error": ErrorEvent; + "error": Event; } interface IDBDatabase extends EventTarget { readonly name: string; readonly objectStoreNames: DOMStringList; onabort: (this: IDBDatabase, ev: Event) => any; - onerror: (this: IDBDatabase, ev: ErrorEvent) => any; + onerror: (this: IDBDatabase, ev: Event) => any; version: number; onversionchange: (ev: IDBVersionChangeEvent) => any; close(): void; @@ -6678,13 +7117,13 @@ declare var IDBOpenDBRequest: { } interface IDBRequestEventMap { - "error": ErrorEvent; + "error": Event; "success": Event; } interface IDBRequest extends EventTarget { readonly error: DOMError; - onerror: (this: IDBRequest, ev: ErrorEvent) => any; + onerror: (this: IDBRequest, ev: Event) => any; onsuccess: (this: IDBRequest, ev: Event) => any; readonly readyState: string; readonly result: any; @@ -6702,7 +7141,7 @@ declare var IDBRequest: { interface IDBTransactionEventMap { "abort": Event; "complete": Event; - "error": ErrorEvent; + "error": Event; } interface IDBTransaction extends EventTarget { @@ -6711,7 +7150,7 @@ interface IDBTransaction extends EventTarget { readonly mode: string; onabort: (this: IDBTransaction, ev: Event) => any; oncomplete: (this: IDBTransaction, ev: Event) => any; - onerror: (this: IDBTransaction, ev: ErrorEvent) => any; + onerror: (this: IDBTransaction, ev: Event) => any; abort(): void; objectStore(name: string): IDBObjectStore; readonly READ_ONLY: string; @@ -6739,6 +7178,15 @@ declare var IDBVersionChangeEvent: { new(): IDBVersionChangeEvent; } +interface IIRFilterNode extends AudioNode { + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; +} + +declare var IIRFilterNode: { + prototype: IIRFilterNode; + new(): IIRFilterNode; +} + interface ImageData { data: Uint8ClampedArray; readonly height: number; @@ -6751,6 +7199,35 @@ declare var ImageData: { new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +interface IntersectionObserver { + readonly root: Element | null; + readonly rootMargin: string; + readonly thresholds: number[]; + disconnect(): void; + observe(target: Element): void; + takeRecords(): IntersectionObserverEntry[]; + unobserve(target: Element): void; +} + +declare var IntersectionObserver: { + prototype: IntersectionObserver; + new(callback: IntersectionObserverCallback, options?: IntersectionObserverInit): IntersectionObserver; +} + +interface IntersectionObserverEntry { + readonly boundingClientRect: ClientRect; + readonly intersectionRatio: number; + readonly intersectionRect: ClientRect; + readonly rootBounds: ClientRect; + readonly target: Element; + readonly time: number; +} + +declare var IntersectionObserverEntry: { + prototype: IntersectionObserverEntry; + new(intersectionObserverEntryInit: IntersectionObserverEntryInit): IntersectionObserverEntry; +} + interface KeyboardEvent extends UIEvent { readonly altKey: boolean; readonly char: string | null; @@ -6837,7 +7314,7 @@ interface MSApp { execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; getCurrentPriority(): string; - getHtmlPrintDocumentSourceAsync(htmlDoc: any): PromiseLike; + getHtmlPrintDocumentSourceAsync(htmlDoc: any): Promise; getViewId(view: any): any; isTaskScheduledAtPriorityOrHigher(priority: string): boolean; pageHandlesAllApplicationActivations(enabled: boolean): void; @@ -6852,13 +7329,13 @@ declare var MSApp: MSApp; interface MSAppAsyncOperationEventMap { "complete": Event; - "error": ErrorEvent; + "error": Event; } interface MSAppAsyncOperation extends EventTarget { readonly error: DOMError; oncomplete: (this: MSAppAsyncOperation, ev: Event) => any; - onerror: (this: MSAppAsyncOperation, ev: ErrorEvent) => any; + onerror: (this: MSAppAsyncOperation, ev: Event) => any; readonly readyState: number; readonly result: any; start(): void; @@ -6898,8 +7375,8 @@ declare var MSBlobBuilder: { } interface MSCredentials { - getAssertion(challenge: string, filter?: MSCredentialFilter, params?: MSSignatureParameters): PromiseLike; - makeCredential(accountInfo: MSAccountInfo, params: MSCredentialParameters[], challenge?: string): PromiseLike; + getAssertion(challenge: string, filter?: MSCredentialFilter, params?: MSSignatureParameters): Promise; + makeCredential(accountInfo: MSAccountInfo, params: MSCredentialParameters[], challenge?: string): Promise; } declare var MSCredentials: { @@ -7015,12 +7492,13 @@ interface MSHTMLWebViewElement extends HTMLElement { goForward(): void; invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; navigate(uri: string): void; + navigateFocus(navigationReason: string, origin: FocusNavigationOrigin): void; navigateToLocalStreamUri(source: string, streamResolver: any): void; navigateToString(contents: string): void; navigateWithHttpRequestMessage(requestMessage: any): void; refresh(): void; stop(): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: MSHTMLWebViewElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7212,7 +7690,7 @@ interface MSStreamReader extends EventTarget, MSBaseReader { readAsBlob(stream: MSStream, size?: number): void; readAsDataURL(stream: MSStream, size?: number): void; readAsText(stream: MSStream, encoding?: string, size?: number): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: MSStreamReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7223,13 +7701,13 @@ declare var MSStreamReader: { interface MSWebViewAsyncOperationEventMap { "complete": Event; - "error": ErrorEvent; + "error": Event; } interface MSWebViewAsyncOperation extends EventTarget { readonly error: DOMError; oncomplete: (this: MSWebViewAsyncOperation, ev: Event) => any; - onerror: (this: MSWebViewAsyncOperation, ev: ErrorEvent) => any; + onerror: (this: MSWebViewAsyncOperation, ev: Event) => any; readonly readyState: number; readonly result: any; readonly target: MSHTMLWebViewElement; @@ -7286,7 +7764,7 @@ interface MediaDevices extends EventTarget { ondevicechange: (this: MediaDevices, ev: Event) => any; enumerateDevices(): any; getSupportedConstraints(): MediaTrackSupportedConstraints; - getUserMedia(constraints: MediaStreamConstraints): PromiseLike; + getUserMedia(constraints: MediaStreamConstraints): Promise; addEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7345,15 +7823,15 @@ declare var MediaKeyMessageEvent: { } interface MediaKeySession extends EventTarget { - readonly closed: PromiseLike; + readonly closed: Promise; readonly expiration: number; readonly keyStatuses: MediaKeyStatusMap; readonly sessionId: string; - close(): PromiseLike; - generateRequest(initDataType: string, initData: any): PromiseLike; - load(sessionId: string): PromiseLike; - remove(): PromiseLike; - update(response: any): PromiseLike; + close(): Promise; + generateRequest(initDataType: string, initData: any): Promise; + load(sessionId: string): Promise; + remove(): Promise; + update(response: any): Promise; } declare var MediaKeySession: { @@ -7375,7 +7853,7 @@ declare var MediaKeyStatusMap: { interface MediaKeySystemAccess { readonly keySystem: string; - createMediaKeys(): PromiseLike; + createMediaKeys(): Promise; getConfiguration(): MediaKeySystemConfiguration; } @@ -7386,7 +7864,7 @@ declare var MediaKeySystemAccess: { interface MediaKeys { createSession(sessionType?: string): MediaKeySession; - setServerCertificate(serverCertificate: any): PromiseLike; + setServerCertificate(serverCertificate: any): Promise; } declare var MediaKeys: { @@ -7439,18 +7917,18 @@ declare var MediaSource: { interface MediaStreamEventMap { "active": Event; - "addtrack": TrackEvent; + "addtrack": MediaStreamTrackEvent; "inactive": Event; - "removetrack": TrackEvent; + "removetrack": MediaStreamTrackEvent; } interface MediaStream extends EventTarget { readonly active: boolean; readonly id: string; onactive: (this: MediaStream, ev: Event) => any; - onaddtrack: (this: MediaStream, ev: TrackEvent) => any; + onaddtrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; oninactive: (this: MediaStream, ev: Event) => any; - onremovetrack: (this: MediaStream, ev: TrackEvent) => any; + onremovetrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; addTrack(track: MediaStreamTrack): void; clone(): MediaStream; getAudioTracks(): MediaStreamTrack[]; @@ -7493,7 +7971,16 @@ interface MediaStreamErrorEvent extends Event { declare var MediaStreamErrorEvent: { prototype: MediaStreamErrorEvent; - new(type: string, eventInitDict?: MediaStreamErrorEventInit): MediaStreamErrorEvent; + new(typeArg: string, eventInitDict?: MediaStreamErrorEventInit): MediaStreamErrorEvent; +} + +interface MediaStreamEvent extends Event { + readonly stream: MediaStream | null; +} + +declare var MediaStreamEvent: { + prototype: MediaStreamEvent; + new(type: string, eventInitDict: MediaStreamEventInit): MediaStreamEvent; } interface MediaStreamTrackEventMap { @@ -7516,7 +8003,7 @@ interface MediaStreamTrack extends EventTarget { readonly readonly: boolean; readonly readyState: string; readonly remote: boolean; - applyConstraints(constraints: MediaTrackConstraints): PromiseLike; + applyConstraints(constraints: MediaTrackConstraints): Promise; clone(): MediaStreamTrack; getCapabilities(): MediaTrackCapabilities; getConstraints(): MediaTrackConstraints; @@ -7537,7 +8024,7 @@ interface MediaStreamTrackEvent extends Event { declare var MediaStreamTrackEvent: { prototype: MediaStreamTrackEvent; - new(type: string, eventInitDict?: MediaStreamTrackEventInit): MediaStreamTrackEvent; + new(typeArg: string, eventInitDict?: MediaStreamTrackEventInit): MediaStreamTrackEvent; } interface MessageChannel { @@ -7570,7 +8057,7 @@ interface MessagePortEventMap { interface MessagePort extends EventTarget { onmessage: (this: MessagePort, ev: MessageEvent) => any; close(): void; - postMessage(message?: any, ports?: any): void; + postMessage(message?: any, transfer?: any[]): void; start(): void; addEventListener(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -7732,9 +8219,10 @@ declare var NavigationEventWithReferrer: { new(): NavigationEventWithReferrer; } -interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorUserMedia { - readonly appCodeName: string; +interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorUserMedia { + readonly authentication: WebAuthentication; readonly cookieEnabled: boolean; + gamepadInputEmulation: string; readonly language: string; readonly maxTouchPoints: number; readonly mimeTypes: MimeTypeArray; @@ -7743,12 +8231,13 @@ interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorConte readonly msPointerEnabled: boolean; readonly plugins: PluginArray; readonly pointerEnabled: boolean; + readonly serviceWorker: ServiceWorkerContainer; readonly webdriver: boolean; readonly hardwareConcurrency: number; getGamepads(): Gamepad[]; javaEnabled(): boolean; msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; - requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): PromiseLike; + requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): Promise; vibrate(pattern: number | number[]): boolean; } @@ -7774,7 +8263,7 @@ interface Node extends EventTarget { readonly parentNode: Node | null; readonly previousSibling: Node | null; textContent: string | null; - appendChild(newChild: Node): Node; + appendChild(newChild: T): T; cloneNode(deep?: boolean): Node; compareDocumentPosition(other: Node): number; contains(child: Node): boolean; @@ -7881,6 +8370,36 @@ declare var NodeList: { new(): NodeList; } +interface NotificationEventMap { + "click": Event; + "close": Event; + "error": Event; + "show": Event; +} + +interface Notification extends EventTarget { + readonly body: string; + readonly dir: string; + readonly icon: string; + readonly lang: string; + onclick: (this: Notification, ev: Event) => any; + onclose: (this: Notification, ev: Event) => any; + onerror: (this: Notification, ev: Event) => any; + onshow: (this: Notification, ev: Event) => any; + readonly permission: string; + readonly tag: string; + readonly title: string; + close(): void; + addEventListener(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Notification: { + prototype: Notification; + new(title: string, options?: NotificationOptions): Notification; + requestPermission(callback?: NotificationPermissionCallback): Promise; +} + interface OES_element_index_uint { } @@ -7915,6 +8434,24 @@ declare var OES_texture_float_linear: { new(): OES_texture_float_linear; } +interface OES_texture_half_float { + readonly HALF_FLOAT_OES: number; +} + +declare var OES_texture_half_float: { + prototype: OES_texture_half_float; + new(): OES_texture_half_float; + readonly HALF_FLOAT_OES: number; +} + +interface OES_texture_half_float_linear { +} + +declare var OES_texture_half_float_linear: { + prototype: OES_texture_half_float_linear; + new(): OES_texture_half_float_linear; +} + interface OfflineAudioCompletionEvent extends Event { readonly renderedBuffer: AudioBuffer; } @@ -7924,13 +8461,15 @@ declare var OfflineAudioCompletionEvent: { new(): OfflineAudioCompletionEvent; } -interface OfflineAudioContextEventMap { - "complete": Event; +interface OfflineAudioContextEventMap extends AudioContextEventMap { + "complete": OfflineAudioCompletionEvent; } -interface OfflineAudioContext extends AudioContext { - oncomplete: (this: OfflineAudioContext, ev: Event) => any; - startRendering(): PromiseLike; +interface OfflineAudioContext extends AudioContextBase { + readonly length: number; + oncomplete: (this: OfflineAudioContext, ev: OfflineAudioCompletionEvent) => any; + startRendering(): Promise; + suspend(suspendTime: number): Promise; addEventListener(type: K, listener: (this: OfflineAudioContext, ev: OfflineAudioContextEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8006,6 +8545,82 @@ declare var PannerNode: { new(): PannerNode; } +interface Path2D extends Object, CanvasPathMethods { +} + +declare var Path2D: { + prototype: Path2D; + new(path?: Path2D): Path2D; +} + +interface PaymentAddress { + readonly addressLine: string[]; + readonly city: string; + readonly country: string; + readonly dependentLocality: string; + readonly languageCode: string; + readonly organization: string; + readonly phone: string; + readonly postalCode: string; + readonly recipient: string; + readonly region: string; + readonly sortingCode: string; + toJSON(): any; +} + +declare var PaymentAddress: { + prototype: PaymentAddress; + new(): PaymentAddress; +} + +interface PaymentRequestEventMap { + "shippingaddresschange": Event; + "shippingoptionchange": Event; +} + +interface PaymentRequest extends EventTarget { + onshippingaddresschange: (this: PaymentRequest, ev: Event) => any; + onshippingoptionchange: (this: PaymentRequest, ev: Event) => any; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + readonly shippingType: string | null; + abort(): Promise; + show(): Promise; + addEventListener(type: K, listener: (this: PaymentRequest, ev: PaymentRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var PaymentRequest: { + prototype: PaymentRequest; + new(methodData: PaymentMethodData[], details: PaymentDetails, options?: PaymentOptions): PaymentRequest; +} + +interface PaymentRequestUpdateEvent extends Event { + updateWith(d: Promise): void; +} + +declare var PaymentRequestUpdateEvent: { + prototype: PaymentRequestUpdateEvent; + new(type: string, eventInitDict?: PaymentRequestUpdateEventInit): PaymentRequestUpdateEvent; +} + +interface PaymentResponse { + readonly details: any; + readonly methodName: string; + readonly payerEmail: string | null; + readonly payerName: string | null; + readonly payerPhone: string | null; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + complete(result?: string): Promise; + toJSON(): any; +} + +declare var PaymentResponse: { + prototype: PaymentResponse; + new(): PaymentResponse; +} + interface PerfWidgetExternal { readonly activeNetworkRequestCount: number; readonly averageFrameTime: number; @@ -8271,7 +8886,7 @@ interface PopStateEvent extends Event { declare var PopStateEvent: { prototype: PopStateEvent; - new(): PopStateEvent; + new(typeArg: string, eventInitDict?: PopStateEventInit): PopStateEvent; } interface Position { @@ -8322,23 +8937,57 @@ declare var ProgressEvent: { new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } +interface PushManager { + getSubscription(): Promise; + permissionState(options?: PushSubscriptionOptionsInit): Promise; + subscribe(options?: PushSubscriptionOptionsInit): Promise; +} + +declare var PushManager: { + prototype: PushManager; + new(): PushManager; +} + +interface PushSubscription { + readonly endpoint: USVString; + readonly options: PushSubscriptionOptions; + getKey(name: string): ArrayBuffer | null; + toJSON(): any; + unsubscribe(): Promise; +} + +declare var PushSubscription: { + prototype: PushSubscription; + new(): PushSubscription; +} + +interface PushSubscriptionOptions { + readonly applicationServerKey: ArrayBuffer | null; + readonly userVisibleOnly: boolean; +} + +declare var PushSubscriptionOptions: { + prototype: PushSubscriptionOptions; + new(): PushSubscriptionOptions; +} + interface RTCDTMFToneChangeEvent extends Event { readonly tone: string; } declare var RTCDTMFToneChangeEvent: { prototype: RTCDTMFToneChangeEvent; - new(type: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; + new(typeArg: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; } interface RTCDtlsTransportEventMap { "dtlsstatechange": RTCDtlsTransportStateChangedEvent; - "error": ErrorEvent; + "error": Event; } interface RTCDtlsTransport extends RTCStatsProvider { ondtlsstatechange: ((this: RTCDtlsTransport, ev: RTCDtlsTransportStateChangedEvent) => any) | null; - onerror: ((this: RTCDtlsTransport, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCDtlsTransport, ev: Event) => any) | null; readonly state: string; readonly transport: RTCIceTransport; getLocalParameters(): RTCDtlsParameters; @@ -8385,6 +9034,18 @@ declare var RTCDtmfSender: { new(sender: RTCRtpSender): RTCDtmfSender; } +interface RTCIceCandidate { + candidate: string | null; + sdpMLineIndex: number | null; + sdpMid: string | null; + toJSON(): any; +} + +declare var RTCIceCandidate: { + prototype: RTCIceCandidate; + new(candidateInitDict?: RTCIceCandidateInit): RTCIceCandidate; +} + interface RTCIceCandidatePairChangedEvent extends Event { readonly pair: RTCIceCandidatePair; } @@ -8395,16 +9056,16 @@ declare var RTCIceCandidatePairChangedEvent: { } interface RTCIceGathererEventMap { - "error": ErrorEvent; + "error": Event; "localcandidate": RTCIceGathererEvent; } interface RTCIceGatherer extends RTCStatsProvider { readonly component: string; - onerror: ((this: RTCIceGatherer, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCIceGatherer, ev: Event) => any) | null; onlocalcandidate: ((this: RTCIceGatherer, ev: RTCIceGathererEvent) => any) | null; createAssociatedGatherer(): RTCIceGatherer; - getLocalCandidates(): RTCIceCandidate[]; + getLocalCandidates(): RTCIceCandidateDictionary[]; getLocalParameters(): RTCIceParameters; addEventListener(type: K, listener: (this: RTCIceGatherer, ev: RTCIceGathererEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -8416,7 +9077,7 @@ declare var RTCIceGatherer: { } interface RTCIceGathererEvent extends Event { - readonly candidate: RTCIceCandidate | RTCIceCandidateComplete; + readonly candidate: RTCIceCandidateDictionary | RTCIceCandidateComplete; } declare var RTCIceGathererEvent: { @@ -8436,12 +9097,12 @@ interface RTCIceTransport extends RTCStatsProvider { onicestatechange: ((this: RTCIceTransport, ev: RTCIceTransportStateChangedEvent) => any) | null; readonly role: string; readonly state: string; - addRemoteCandidate(remoteCandidate: RTCIceCandidate | RTCIceCandidateComplete): void; + addRemoteCandidate(remoteCandidate: RTCIceCandidateDictionary | RTCIceCandidateComplete): void; createAssociatedTransport(): RTCIceTransport; getNominatedCandidatePair(): RTCIceCandidatePair | null; - getRemoteCandidates(): RTCIceCandidate[]; + getRemoteCandidates(): RTCIceCandidateDictionary[]; getRemoteParameters(): RTCIceParameters | null; - setRemoteCandidates(remoteCandidates: RTCIceCandidate[]): void; + setRemoteCandidates(remoteCandidates: RTCIceCandidateDictionary[]): void; start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: string): void; stop(): void; addEventListener(type: K, listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any, useCapture?: boolean): void; @@ -8462,12 +9123,67 @@ declare var RTCIceTransportStateChangedEvent: { new(): RTCIceTransportStateChangedEvent; } +interface RTCPeerConnectionEventMap { + "addstream": MediaStreamEvent; + "icecandidate": RTCPeerConnectionIceEvent; + "iceconnectionstatechange": Event; + "icegatheringstatechange": Event; + "negotiationneeded": Event; + "removestream": MediaStreamEvent; + "signalingstatechange": Event; +} + +interface RTCPeerConnection extends EventTarget { + readonly canTrickleIceCandidates: boolean | null; + readonly iceConnectionState: string; + readonly iceGatheringState: string; + readonly localDescription: RTCSessionDescription | null; + onaddstream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onicecandidate: (this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any; + oniceconnectionstatechange: (this: RTCPeerConnection, ev: Event) => any; + onicegatheringstatechange: (this: RTCPeerConnection, ev: Event) => any; + onnegotiationneeded: (this: RTCPeerConnection, ev: Event) => any; + onremovestream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onsignalingstatechange: (this: RTCPeerConnection, ev: Event) => any; + readonly remoteDescription: RTCSessionDescription | null; + readonly signalingState: string; + addIceCandidate(candidate: RTCIceCandidate, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addStream(stream: MediaStream): void; + close(): void; + createAnswer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + createOffer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback, options?: RTCOfferOptions): Promise; + getConfiguration(): RTCConfiguration; + getLocalStreams(): MediaStream[]; + getRemoteStreams(): MediaStream[]; + getStats(selector: MediaStreamTrack | null, successCallback?: RTCStatsCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + getStreamById(streamId: string): MediaStream | null; + removeStream(stream: MediaStream): void; + setLocalDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + setRemoteDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addEventListener(type: K, listener: (this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCPeerConnection: { + prototype: RTCPeerConnection; + new(configuration: RTCConfiguration): RTCPeerConnection; +} + +interface RTCPeerConnectionIceEvent extends Event { + readonly candidate: RTCIceCandidate; +} + +declare var RTCPeerConnectionIceEvent: { + prototype: RTCPeerConnectionIceEvent; + new(type: string, eventInitDict: RTCPeerConnectionIceEventInit): RTCPeerConnectionIceEvent; +} + interface RTCRtpReceiverEventMap { - "error": ErrorEvent; + "error": Event; } interface RTCRtpReceiver extends RTCStatsProvider { - onerror: ((this: RTCRtpReceiver, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCRtpReceiver, ev: Event) => any) | null; readonly rtcpTransport: RTCDtlsTransport; readonly track: MediaStreamTrack | null; readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; @@ -8487,12 +9203,12 @@ declare var RTCRtpReceiver: { } interface RTCRtpSenderEventMap { - "error": ErrorEvent; + "error": Event; "ssrcconflict": RTCSsrcConflictEvent; } interface RTCRtpSender extends RTCStatsProvider { - onerror: ((this: RTCRtpSender, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCRtpSender, ev: Event) => any) | null; onssrcconflict: ((this: RTCRtpSender, ev: RTCSsrcConflictEvent) => any) | null; readonly rtcpTransport: RTCDtlsTransport; readonly track: MediaStreamTrack; @@ -8511,12 +9227,23 @@ declare var RTCRtpSender: { getCapabilities(kind?: string): RTCRtpCapabilities; } +interface RTCSessionDescription { + sdp: string | null; + type: string | null; + toJSON(): any; +} + +declare var RTCSessionDescription: { + prototype: RTCSessionDescription; + new(descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription; +} + interface RTCSrtpSdesTransportEventMap { - "error": ErrorEvent; + "error": Event; } interface RTCSrtpSdesTransport extends EventTarget { - onerror: ((this: RTCSrtpSdesTransport, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCSrtpSdesTransport, ev: Event) => any) | null; readonly transport: RTCIceTransport; addEventListener(type: K, listener: (this: RTCSrtpSdesTransport, ev: RTCSrtpSdesTransportEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -8538,8 +9265,8 @@ declare var RTCSsrcConflictEvent: { } interface RTCStatsProvider extends EventTarget { - getStats(): PromiseLike; - msGetStats(): PromiseLike; + getStats(): Promise; + msGetStats(): Promise; } declare var RTCStatsProvider: { @@ -8591,9 +9318,69 @@ declare var Range: { readonly START_TO_START: number; } -interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface ReadableStream { + readonly locked: boolean; + cancel(): Promise; + getReader(): ReadableStreamReader; +} + +declare var ReadableStream: { + prototype: ReadableStream; + new(): ReadableStream; +} + +interface ReadableStreamReader { + cancel(): Promise; + read(): Promise; + releaseLock(): void; +} + +declare var ReadableStreamReader: { + prototype: ReadableStreamReader; + new(): ReadableStreamReader; +} + +interface Request extends Object, Body { + readonly cache: string; + readonly credentials: string; + readonly destination: string; + readonly headers: Headers; + readonly integrity: string; + readonly keepalive: boolean; + readonly method: string; + readonly mode: string; + readonly redirect: string; + readonly referrer: string; + readonly referrerPolicy: string; + readonly type: string; + readonly url: string; + clone(): Request; +} + +declare var Request: { + prototype: Request; + new(input: Request | string, init?: RequestInit): Request; +} + +interface Response extends Object, Body { + readonly body: ReadableStream | null; + readonly headers: Headers; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly type: string; + readonly url: string; + clone(): Response; +} + +declare var Response: { + prototype: Response; + new(body?: any, init?: ResponseInit): Response; +} + +interface SVGAElement extends SVGGraphicsElement, SVGURIReference { readonly target: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8746,11 +9533,11 @@ declare var SVGAnimatedTransformList: { new(): SVGAnimatedTransformList; } -interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGCircleElement extends SVGGraphicsElement { readonly cx: SVGAnimatedLength; readonly cy: SVGAnimatedLength; readonly r: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGCircleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8759,9 +9546,9 @@ declare var SVGCircleElement: { new(): SVGCircleElement; } -interface SVGClipPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { +interface SVGClipPathElement extends SVGGraphicsElement, SVGUnitTypes { readonly clipPathUnits: SVGAnimatedEnumeration; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGClipPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8784,7 +9571,7 @@ interface SVGComponentTransferFunctionElement extends SVGElement { readonly SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; readonly SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGComponentTransferFunctionElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8799,8 +9586,8 @@ declare var SVGComponentTransferFunctionElement: { readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; } -interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGDefsElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGDefsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8809,8 +9596,8 @@ declare var SVGDefsElement: { new(): SVGDefsElement; } -interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGDescElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGDescElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8833,6 +9620,7 @@ interface SVGElementEventMap extends ElementEventMap { } interface SVGElement extends Element { + className: any; onclick: (this: SVGElement, ev: MouseEvent) => any; ondblclick: (this: SVGElement, ev: MouseEvent) => any; onfocusin: (this: SVGElement, ev: FocusEvent) => any; @@ -8844,9 +9632,9 @@ interface SVGElement extends Element { onmouseover: (this: SVGElement, ev: MouseEvent) => any; onmouseup: (this: SVGElement, ev: MouseEvent) => any; readonly ownerSVGElement: SVGSVGElement; + readonly style: CSSStyleDeclaration; readonly viewportElement: SVGElement; xmlbase: string; - className: any; addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8882,12 +9670,12 @@ declare var SVGElementInstanceList: { new(): SVGElementInstanceList; } -interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGEllipseElement extends SVGGraphicsElement { readonly cx: SVGAnimatedLength; readonly cy: SVGAnimatedLength; readonly rx: SVGAnimatedLength; readonly ry: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGEllipseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8917,7 +9705,7 @@ interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttrib readonly SVG_FEBLEND_MODE_SCREEN: number; readonly SVG_FEBLEND_MODE_SOFT_LIGHT: number; readonly SVG_FEBLEND_MODE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEBlendElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8952,7 +9740,7 @@ interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandard readonly SVG_FECOLORMATRIX_TYPE_MATRIX: number; readonly SVG_FECOLORMATRIX_TYPE_SATURATE: number; readonly SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEColorMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8968,7 +9756,7 @@ declare var SVGFEColorMatrixElement: { interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEComponentTransferElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8992,7 +9780,7 @@ interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAt readonly SVG_FECOMPOSITE_OPERATOR_OVER: number; readonly SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; readonly SVG_FECOMPOSITE_OPERATOR_XOR: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFECompositeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9025,7 +9813,7 @@ interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStand readonly SVG_EDGEMODE_NONE: number; readonly SVG_EDGEMODE_UNKNOWN: number; readonly SVG_EDGEMODE_WRAP: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEConvolveMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9044,7 +9832,7 @@ interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStan readonly kernelUnitLengthX: SVGAnimatedNumber; readonly kernelUnitLengthY: SVGAnimatedNumber; readonly surfaceScale: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDiffuseLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9064,7 +9852,7 @@ interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStan readonly SVG_CHANNEL_G: number; readonly SVG_CHANNEL_R: number; readonly SVG_CHANNEL_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDisplacementMapElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9081,7 +9869,7 @@ declare var SVGFEDisplacementMapElement: { interface SVGFEDistantLightElement extends SVGElement { readonly azimuth: SVGAnimatedNumber; readonly elevation: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDistantLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9091,7 +9879,7 @@ declare var SVGFEDistantLightElement: { } interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEFloodElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9101,6 +9889,8 @@ declare var SVGFEFloodElement: { } interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncAElement: { @@ -9109,6 +9899,8 @@ declare var SVGFEFuncAElement: { } interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncBElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncBElement: { @@ -9117,6 +9909,8 @@ declare var SVGFEFuncBElement: { } interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncGElement: { @@ -9125,6 +9919,8 @@ declare var SVGFEFuncGElement: { } interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncRElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncRElement: { @@ -9137,7 +9933,7 @@ interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandar readonly stdDeviationX: SVGAnimatedNumber; readonly stdDeviationY: SVGAnimatedNumber; setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEGaussianBlurElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9146,9 +9942,9 @@ declare var SVGFEGaussianBlurElement: { new(): SVGFEGaussianBlurElement; } -interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { +interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGURIReference { readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9158,7 +9954,7 @@ declare var SVGFEImageElement: { } interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMergeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9169,7 +9965,7 @@ declare var SVGFEMergeElement: { interface SVGFEMergeNodeElement extends SVGElement { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMergeNodeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9186,7 +9982,7 @@ interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardA readonly SVG_MORPHOLOGY_OPERATOR_DILATE: number; readonly SVG_MORPHOLOGY_OPERATOR_ERODE: number; readonly SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMorphologyElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9202,7 +9998,7 @@ interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttri readonly dx: SVGAnimatedNumber; readonly dy: SVGAnimatedNumber; readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEOffsetElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9215,7 +10011,7 @@ interface SVGFEPointLightElement extends SVGElement { readonly x: SVGAnimatedNumber; readonly y: SVGAnimatedNumber; readonly z: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEPointLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9231,7 +10027,7 @@ interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveSta readonly specularConstant: SVGAnimatedNumber; readonly specularExponent: SVGAnimatedNumber; readonly surfaceScale: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFESpecularLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9249,7 +10045,7 @@ interface SVGFESpotLightElement extends SVGElement { readonly x: SVGAnimatedNumber; readonly y: SVGAnimatedNumber; readonly z: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFESpotLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9260,7 +10056,7 @@ declare var SVGFESpotLightElement: { interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFETileElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9282,7 +10078,7 @@ interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardA readonly SVG_TURBULENCE_TYPE_FRACTALNOISE: number; readonly SVG_TURBULENCE_TYPE_TURBULENCE: number; readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFETurbulenceElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9297,7 +10093,7 @@ declare var SVGFETurbulenceElement: { readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; } -interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { +interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGURIReference { readonly filterResX: SVGAnimatedInteger; readonly filterResY: SVGAnimatedInteger; readonly filterUnits: SVGAnimatedEnumeration; @@ -9307,7 +10103,7 @@ interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLan readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; setFilterRes(filterResX: number, filterResY: number): void; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFilterElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9316,12 +10112,12 @@ declare var SVGFilterElement: { new(): SVGFilterElement; } -interface SVGForeignObjectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGForeignObjectElement extends SVGGraphicsElement { readonly height: SVGAnimatedLength; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGForeignObjectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9330,8 +10126,8 @@ declare var SVGForeignObjectElement: { new(): SVGForeignObjectElement; } -interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGGElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9340,7 +10136,7 @@ declare var SVGGElement: { new(): SVGGElement; } -interface SVGGradientElement extends SVGElement, SVGStylable, SVGExternalResourcesRequired, SVGURIReference, SVGUnitTypes { +interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGURIReference { readonly gradientTransform: SVGAnimatedTransformList; readonly gradientUnits: SVGAnimatedEnumeration; readonly spreadMethod: SVGAnimatedEnumeration; @@ -9348,7 +10144,7 @@ interface SVGGradientElement extends SVGElement, SVGStylable, SVGExternalResourc readonly SVG_SPREADMETHOD_REFLECT: number; readonly SVG_SPREADMETHOD_REPEAT: number; readonly SVG_SPREADMETHOD_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9361,13 +10157,30 @@ declare var SVGGradientElement: { readonly SVG_SPREADMETHOD_UNKNOWN: number; } -interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface SVGGraphicsElement extends SVGElement, SVGTests { + readonly farthestViewportElement: SVGElement; + readonly nearestViewportElement: SVGElement; + readonly transform: SVGAnimatedTransformList; + getBBox(): SVGRect; + getCTM(): SVGMatrix; + getScreenCTM(): SVGMatrix; + getTransformToElement(element: SVGElement): SVGMatrix; + addEventListener(type: K, listener: (this: SVGGraphicsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGraphicsElement: { + prototype: SVGGraphicsElement; + new(): SVGGraphicsElement; +} + +interface SVGImageElement extends SVGGraphicsElement, SVGURIReference { readonly height: SVGAnimatedLength; readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9428,12 +10241,12 @@ declare var SVGLengthList: { new(): SVGLengthList; } -interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGLineElement extends SVGGraphicsElement { readonly x1: SVGAnimatedLength; readonly x2: SVGAnimatedLength; readonly y1: SVGAnimatedLength; readonly y2: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGLineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9447,6 +10260,8 @@ interface SVGLinearGradientElement extends SVGGradientElement { readonly x2: SVGAnimatedLength; readonly y1: SVGAnimatedLength; readonly y2: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGLinearGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGLinearGradientElement: { @@ -9454,7 +10269,7 @@ declare var SVGLinearGradientElement: { new(): SVGLinearGradientElement; } -interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { +interface SVGMarkerElement extends SVGElement, SVGFitToViewBox { readonly markerHeight: SVGAnimatedLength; readonly markerUnits: SVGAnimatedEnumeration; readonly markerWidth: SVGAnimatedLength; @@ -9470,7 +10285,7 @@ interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExt readonly SVG_MARKER_ORIENT_ANGLE: number; readonly SVG_MARKER_ORIENT_AUTO: number; readonly SVG_MARKER_ORIENT_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMarkerElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9485,14 +10300,14 @@ declare var SVGMarkerElement: { readonly SVG_MARKER_ORIENT_UNKNOWN: number; } -interface SVGMaskElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { +interface SVGMaskElement extends SVGElement, SVGTests, SVGUnitTypes { readonly height: SVGAnimatedLength; readonly maskContentUnits: SVGAnimatedEnumeration; readonly maskUnits: SVGAnimatedEnumeration; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMaskElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9527,7 +10342,7 @@ declare var SVGMatrix: { } interface SVGMetadataElement extends SVGElement { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMetadataElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9561,7 +10376,8 @@ declare var SVGNumberList: { new(): SVGNumberList; } -interface SVGPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPathData { +interface SVGPathElement extends SVGGraphicsElement { + readonly pathSegList: SVGPathSegList; createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; createSVGPathSegClosePath(): SVGPathSegClosePath; @@ -9584,7 +10400,7 @@ interface SVGPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGT getPathSegAtLength(distance: number): number; getPointAtLength(distance: number): SVGPoint; getTotalLength(): number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9869,7 +10685,7 @@ declare var SVGPathSegMovetoRel: { new(): SVGPathSegMovetoRel; } -interface SVGPatternElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGURIReference, SVGUnitTypes { +interface SVGPatternElement extends SVGElement, SVGTests, SVGUnitTypes, SVGFitToViewBox, SVGURIReference { readonly height: SVGAnimatedLength; readonly patternContentUnits: SVGAnimatedEnumeration; readonly patternTransform: SVGAnimatedTransformList; @@ -9877,7 +10693,7 @@ interface SVGPatternElement extends SVGElement, SVGStylable, SVGTests, SVGLangSp readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGPatternElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9913,8 +10729,8 @@ declare var SVGPointList: { new(): SVGPointList; } -interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPoints { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGPolygonElement extends SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolygonElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9923,8 +10739,8 @@ declare var SVGPolygonElement: { new(): SVGPolygonElement; } -interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPoints { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGPolylineElement extends SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolylineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9977,6 +10793,8 @@ interface SVGRadialGradientElement extends SVGGradientElement { readonly fx: SVGAnimatedLength; readonly fy: SVGAnimatedLength; readonly r: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGRadialGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGRadialGradientElement: { @@ -9996,14 +10814,14 @@ declare var SVGRect: { new(): SVGRect; } -interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGRectElement extends SVGGraphicsElement { readonly height: SVGAnimatedLength; readonly rx: SVGAnimatedLength; readonly ry: SVGAnimatedLength; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGRectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10021,7 +10839,7 @@ interface SVGSVGElementEventMap extends SVGElementEventMap { "SVGZoom": SVGZoomEvent; } -interface SVGSVGElement extends SVGElement, DocumentEvent, SVGLocatable, SVGTests, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { +interface SVGSVGElement extends SVGGraphicsElement, DocumentEvent, SVGFitToViewBox, SVGZoomAndPan { contentScriptType: string; contentStyleType: string; currentScale: number; @@ -10073,9 +10891,9 @@ declare var SVGSVGElement: { new(): SVGSVGElement; } -interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { +interface SVGScriptElement extends SVGElement, SVGURIReference { type: string; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGScriptElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10084,9 +10902,9 @@ declare var SVGScriptElement: { new(): SVGScriptElement; } -interface SVGStopElement extends SVGElement, SVGStylable { +interface SVGStopElement extends SVGElement { readonly offset: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGStopElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10111,12 +10929,12 @@ declare var SVGStringList: { new(): SVGStringList; } -interface SVGStyleElement extends SVGElement, SVGLangSpace { +interface SVGStyleElement extends SVGElement { disabled: boolean; media: string; title: string; type: string; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGStyleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10125,8 +10943,8 @@ declare var SVGStyleElement: { new(): SVGStyleElement; } -interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGSwitchElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGSwitchElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10135,8 +10953,8 @@ declare var SVGSwitchElement: { new(): SVGSwitchElement; } -interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGSymbolElement extends SVGElement, SVGFitToViewBox { + addEventListener(type: K, listener: (this: SVGSymbolElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10146,6 +10964,8 @@ declare var SVGSymbolElement: { } interface SVGTSpanElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTSpanElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTSpanElement: { @@ -10153,7 +10973,7 @@ declare var SVGTSpanElement: { new(): SVGTSpanElement; } -interface SVGTextContentElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGTextContentElement extends SVGGraphicsElement { readonly lengthAdjust: SVGAnimatedEnumeration; readonly textLength: SVGAnimatedLength; getCharNumAtPosition(point: SVGPoint): number; @@ -10168,7 +10988,7 @@ interface SVGTextContentElement extends SVGElement, SVGStylable, SVGTests, SVGLa readonly LENGTHADJUST_SPACING: number; readonly LENGTHADJUST_SPACINGANDGLYPHS: number; readonly LENGTHADJUST_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGTextContentElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10180,7 +11000,9 @@ declare var SVGTextContentElement: { readonly LENGTHADJUST_UNKNOWN: number; } -interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { +interface SVGTextElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTextElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextElement: { @@ -10198,6 +11020,8 @@ interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { readonly TEXTPATH_SPACINGTYPE_AUTO: number; readonly TEXTPATH_SPACINGTYPE_EXACT: number; readonly TEXTPATH_SPACINGTYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGTextPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextPathElement: { @@ -10217,6 +11041,8 @@ interface SVGTextPositioningElement extends SVGTextContentElement { readonly rotate: SVGAnimatedNumberList; readonly x: SVGAnimatedLengthList; readonly y: SVGAnimatedLengthList; + addEventListener(type: K, listener: (this: SVGTextPositioningElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextPositioningElement: { @@ -10224,8 +11050,8 @@ declare var SVGTextPositioningElement: { new(): SVGTextPositioningElement; } -interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGTitleElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGTitleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10290,14 +11116,14 @@ interface SVGUnitTypes { } declare var SVGUnitTypes: SVGUnitTypes; -interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface SVGUseElement extends SVGGraphicsElement, SVGURIReference { readonly animatedInstanceRoot: SVGElementInstance; readonly height: SVGAnimatedLength; readonly instanceRoot: SVGElementInstance; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGUseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10306,9 +11132,9 @@ declare var SVGUseElement: { new(): SVGUseElement; } -interface SVGViewElement extends SVGElement, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { +interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox { readonly viewTarget: SVGStringList; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGViewElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10340,6 +11166,26 @@ declare var SVGZoomEvent: { new(): SVGZoomEvent; } +interface ScopedCredential { + readonly id: ArrayBuffer; + readonly type: string; +} + +declare var ScopedCredential: { + prototype: ScopedCredential; + new(): ScopedCredential; +} + +interface ScopedCredentialInfo { + readonly credential: ScopedCredential; + readonly publicKey: CryptoKey; +} + +declare var ScopedCredentialInfo: { + prototype: ScopedCredentialInfo; + new(): ScopedCredentialInfo; +} + interface ScreenEventMap { "MSOrientationChange": Event; } @@ -10401,6 +11247,10 @@ declare var ScriptProcessorNode: { interface Selection { readonly anchorNode: Node; readonly anchorOffset: number; + readonly baseNode: Node; + readonly baseOffset: number; + readonly extentNode: Node; + readonly extentOffset: number; readonly focusNode: Node; readonly focusOffset: number; readonly isCollapsed: boolean; @@ -10419,6 +11269,7 @@ interface Selection { removeRange(range: Range): void; selectAllChildren(parentNode: Node): void; setBaseAndExtent(baseNode: Node, baseOffset: number, extentNode: Node, extentOffset: number): void; + setPosition(parentNode: Node, offset: number): void; toString(): string; } @@ -10427,6 +11278,84 @@ declare var Selection: { new(): Selection; } +interface ServiceWorkerEventMap extends AbstractWorkerEventMap { + "statechange": Event; +} + +interface ServiceWorker extends EventTarget, AbstractWorker { + onstatechange: (this: ServiceWorker, ev: Event) => any; + readonly scriptURL: USVString; + readonly state: string; + postMessage(message: any, transfer?: any[]): void; + addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorker: { + prototype: ServiceWorker; + new(): ServiceWorker; +} + +interface ServiceWorkerContainerEventMap { + "controllerchange": Event; + "message": ServiceWorkerMessageEvent; +} + +interface ServiceWorkerContainer extends EventTarget { + readonly controller: ServiceWorker | null; + oncontrollerchange: (this: ServiceWorkerContainer, ev: Event) => any; + onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any; + readonly ready: Promise; + getRegistration(clientURL?: USVString): Promise; + getRegistrations(): any; + register(scriptURL: USVString, options?: RegistrationOptions): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerContainer: { + prototype: ServiceWorkerContainer; + new(): ServiceWorkerContainer; +} + +interface ServiceWorkerMessageEvent extends Event { + readonly data: any; + readonly lastEventId: string; + readonly origin: string; + readonly ports: MessagePort[] | null; + readonly source: ServiceWorker | MessagePort | null; +} + +declare var ServiceWorkerMessageEvent: { + prototype: ServiceWorkerMessageEvent; + new(type: string, eventInitDict?: ServiceWorkerMessageEventInit): ServiceWorkerMessageEvent; +} + +interface ServiceWorkerRegistrationEventMap { + "updatefound": Event; +} + +interface ServiceWorkerRegistration extends EventTarget { + readonly active: ServiceWorker | null; + readonly installing: ServiceWorker | null; + onupdatefound: (this: ServiceWorkerRegistration, ev: Event) => any; + readonly pushManager: PushManager; + readonly scope: USVString; + readonly sync: SyncManager; + readonly waiting: ServiceWorker | null; + getNotifications(filter?: GetNotificationOptions): any; + showNotification(title: string, options?: NotificationOptions): Promise; + unregister(): Promise; + update(): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerRegistration: { + prototype: ServiceWorkerRegistration; + new(): ServiceWorkerRegistration; +} + interface SourceBuffer extends EventTarget { appendWindowEnd: number; appendWindowStart: number; @@ -10458,6 +11387,87 @@ declare var SourceBufferList: { new(): SourceBufferList; } +interface SpeechSynthesisEventMap { + "voiceschanged": Event; +} + +interface SpeechSynthesis extends EventTarget { + onvoiceschanged: (this: SpeechSynthesis, ev: Event) => any; + readonly paused: boolean; + readonly pending: boolean; + readonly speaking: boolean; + cancel(): void; + getVoices(): SpeechSynthesisVoice[]; + pause(): void; + resume(): void; + speak(utterance: SpeechSynthesisUtterance): void; + addEventListener(type: K, listener: (this: SpeechSynthesis, ev: SpeechSynthesisEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesis: { + prototype: SpeechSynthesis; + new(): SpeechSynthesis; +} + +interface SpeechSynthesisEvent extends Event { + readonly charIndex: number; + readonly elapsedTime: number; + readonly name: string; + readonly utterance: SpeechSynthesisUtterance | null; +} + +declare var SpeechSynthesisEvent: { + prototype: SpeechSynthesisEvent; + new(type: string, eventInitDict?: SpeechSynthesisEventInit): SpeechSynthesisEvent; +} + +interface SpeechSynthesisUtteranceEventMap { + "boundary": Event; + "end": Event; + "error": Event; + "mark": Event; + "pause": Event; + "resume": Event; + "start": Event; +} + +interface SpeechSynthesisUtterance extends EventTarget { + lang: string; + onboundary: (this: SpeechSynthesisUtterance, ev: Event) => any; + onend: (this: SpeechSynthesisUtterance, ev: Event) => any; + onerror: (this: SpeechSynthesisUtterance, ev: Event) => any; + onmark: (this: SpeechSynthesisUtterance, ev: Event) => any; + onpause: (this: SpeechSynthesisUtterance, ev: Event) => any; + onresume: (this: SpeechSynthesisUtterance, ev: Event) => any; + onstart: (this: SpeechSynthesisUtterance, ev: Event) => any; + pitch: number; + rate: number; + text: string; + voice: SpeechSynthesisVoice; + volume: number; + addEventListener(type: K, listener: (this: SpeechSynthesisUtterance, ev: SpeechSynthesisUtteranceEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesisUtterance: { + prototype: SpeechSynthesisUtterance; + new(text?: string): SpeechSynthesisUtterance; +} + +interface SpeechSynthesisVoice { + readonly default: boolean; + readonly lang: string; + readonly localService: boolean; + readonly name: string; + readonly voiceURI: string; +} + +declare var SpeechSynthesisVoice: { + prototype: SpeechSynthesisVoice; + new(): SpeechSynthesisVoice; +} + interface StereoPannerNode extends AudioNode { readonly pan: AudioParam; } @@ -10569,6 +11579,16 @@ declare var SubtleCrypto: { new(): SubtleCrypto; } +interface SyncManager { + getTags(): any; + register(tag: string): Promise; +} + +declare var SyncManager: { + prototype: SyncManager; + new(): SyncManager; +} + interface Text extends CharacterData { readonly wholeText: string; readonly assignedSlot: HTMLSlotElement | null; @@ -10623,7 +11643,7 @@ declare var TextMetrics: { interface TextTrackEventMap { "cuechange": Event; - "error": ErrorEvent; + "error": Event; "load": Event; } @@ -10636,7 +11656,7 @@ interface TextTrack extends EventTarget { readonly language: string; mode: any; oncuechange: (this: TextTrack, ev: Event) => any; - onerror: (this: TextTrack, ev: ErrorEvent) => any; + onerror: (this: TextTrack, ev: Event) => any; onload: (this: TextTrack, ev: Event) => any; readonly readyState: number; addCue(cue: TextTrackCue): void; @@ -10748,11 +11768,14 @@ declare var Touch: { interface TouchEvent extends UIEvent { readonly altKey: boolean; readonly changedTouches: TouchList; + readonly charCode: number; readonly ctrlKey: boolean; + readonly keyCode: number; readonly metaKey: boolean; readonly shiftKey: boolean; readonly targetTouches: TouchList; readonly touches: TouchList; + readonly which: number; } declare var TouchEvent: { @@ -10772,12 +11795,12 @@ declare var TouchList: { } interface TrackEvent extends Event { - readonly track: any; + readonly track: VideoTrack | AudioTrack | TextTrack | null; } declare var TrackEvent: { prototype: TrackEvent; - new(): TrackEvent; + new(typeArg: string, eventInitDict?: TrackEventInit): TrackEvent; } interface TransitionEvent extends Event { @@ -10788,7 +11811,7 @@ interface TransitionEvent extends Event { declare var TransitionEvent: { prototype: TransitionEvent; - new(): TransitionEvent; + new(typeArg: string, eventInitDict?: TransitionEventInit): TransitionEvent; } interface TreeWalker { @@ -10819,7 +11842,7 @@ interface UIEvent extends Event { declare var UIEvent: { prototype: UIEvent; - new(type: string, eventInitDict?: UIEventInit): UIEvent; + new(typeArg: string, eventInitDict?: UIEventInit): UIEvent; } interface URL { @@ -10834,6 +11857,7 @@ interface URL { protocol: string; search: string; username: string; + readonly searchparams: URLSearchParams; toString(): string; } @@ -10970,6 +11994,28 @@ declare var WaveShaperNode: { new(): WaveShaperNode; } +interface WebAuthentication { + getAssertion(assertionChallenge: any, options?: AssertionOptions): Promise; + makeCredential(accountInformation: Account, cryptoParameters: ScopedCredentialParameters[], attestationChallenge: any, options?: ScopedCredentialOptions): Promise; +} + +declare var WebAuthentication: { + prototype: WebAuthentication; + new(): WebAuthentication; +} + +interface WebAuthnAssertion { + readonly authenticatorData: ArrayBuffer; + readonly clientData: ArrayBuffer; + readonly credential: ScopedCredential; + readonly signature: ArrayBuffer; +} + +declare var WebAuthnAssertion: { + prototype: WebAuthnAssertion; + new(): WebAuthnAssertion; +} + interface WebGLActiveInfo { readonly name: string; readonly size: number; @@ -10995,7 +12041,7 @@ interface WebGLContextEvent extends Event { declare var WebGLContextEvent: { prototype: WebGLContextEvent; - new(type: string, eventInitDict?: WebGLContextEventInit): WebGLContextEvent; + new(typeArg: string, eventInitDict?: WebGLContextEventInit): WebGLContextEvent; } interface WebGLFramebuffer extends WebGLObject { @@ -11122,7 +12168,7 @@ interface WebGLRenderingContext { isTexture(texture: WebGLTexture | null): boolean; lineWidth(width: number): void; linkProgram(program: WebGLProgram | null): void; - pixelStorei(pname: number, param: number): void; + pixelStorei(pname: number, param: number | boolean): void; polygonOffset(factor: number, units: number): void; readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView | null): void; renderbufferStorage(target: number, internalformat: number, width: number, height: number): void; @@ -11848,6 +12894,56 @@ declare var WebKitCSSMatrix: { new(text?: string): WebKitCSSMatrix; } +interface WebKitDirectoryEntry extends WebKitEntry { + createReader(): WebKitDirectoryReader; +} + +declare var WebKitDirectoryEntry: { + prototype: WebKitDirectoryEntry; + new(): WebKitDirectoryEntry; +} + +interface WebKitDirectoryReader { + readEntries(successCallback: WebKitEntriesCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitDirectoryReader: { + prototype: WebKitDirectoryReader; + new(): WebKitDirectoryReader; +} + +interface WebKitEntry { + readonly filesystem: WebKitFileSystem; + readonly fullPath: string; + readonly isDirectory: boolean; + readonly isFile: boolean; + readonly name: string; +} + +declare var WebKitEntry: { + prototype: WebKitEntry; + new(): WebKitEntry; +} + +interface WebKitFileEntry extends WebKitEntry { + file(successCallback: WebKitFileCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitFileEntry: { + prototype: WebKitFileEntry; + new(): WebKitFileEntry; +} + +interface WebKitFileSystem { + readonly name: string; + readonly root: WebKitDirectoryEntry; +} + +declare var WebKitFileSystem: { + prototype: WebKitFileSystem; + new(): WebKitFileSystem; +} + interface WebKitPoint { x: number; y: number; @@ -11860,7 +12956,7 @@ declare var WebKitPoint: { interface WebSocketEventMap { "close": CloseEvent; - "error": ErrorEvent; + "error": Event; "message": MessageEvent; "open": Event; } @@ -11870,7 +12966,7 @@ interface WebSocket extends EventTarget { readonly bufferedAmount: number; readonly extensions: string; onclose: (this: WebSocket, ev: CloseEvent) => any; - onerror: (this: WebSocket, ev: ErrorEvent) => any; + onerror: (this: WebSocket, ev: Event) => any; onmessage: (this: WebSocket, ev: MessageEvent) => any; onopen: (this: WebSocket, ev: Event) => any; readonly protocol: string; @@ -12007,8 +13103,9 @@ interface WindowEventMap extends GlobalEventHandlersEventMap { "waiting": Event; } -interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64 { +interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch { readonly applicationCache: ApplicationCache; + readonly caches: CacheStorage; readonly clientInformation: Navigator; readonly closed: boolean; readonly crypto: Crypto; @@ -12023,10 +13120,12 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly history: History; readonly innerHeight: number; readonly innerWidth: number; + readonly isSecureContext: boolean; readonly length: number; readonly location: Location; readonly locationbar: BarProp; readonly menubar: BarProp; + readonly msContentScript: ExtensionScriptApis; readonly msCredentials: MSCredentials; name: string; readonly navigator: Navigator; @@ -12140,6 +13239,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly scrollY: number; readonly scrollbars: BarProp; readonly self: Window; + readonly speechSynthesis: SpeechSynthesis; status: string; readonly statusbar: BarProp; readonly styleMedia: StyleMedia; @@ -12148,12 +13248,14 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly window: Window; URL: typeof URL; Blob: typeof Blob; + customElements: CustomElementRegistry; alert(message?: any): void; blur(): void; cancelAnimationFrame(handle: number): void; captureEvents(): void; close(): void; confirm(message?: string): boolean; + departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; focus(): void; getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -12173,6 +13275,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window scroll(x?: number, y?: number): void; scrollBy(x?: number, y?: number): void; scrollTo(x?: number, y?: number): void; + stop(): void; webkitCancelAnimationFrame(handle: number): void; webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; @@ -12195,7 +13298,7 @@ interface WorkerEventMap extends AbstractWorkerEventMap { interface Worker extends EventTarget, AbstractWorker { onmessage: (this: Worker, ev: MessageEvent) => any; - postMessage(message: any, ports?: any): void; + postMessage(message: any, transfer?: any[]): void; terminate(): void; addEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -12207,7 +13310,7 @@ declare var Worker: { } interface XMLDocument extends Document { - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: XMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12226,14 +13329,14 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly response: any; readonly responseText: string; responseType: string; - readonly responseXML: any; + readonly responseURL: string; + readonly responseXML: Document | null; readonly status: number; readonly statusText: string; timeout: number; readonly upload: XMLHttpRequestUpload; withCredentials: boolean; msCaching?: string; - readonly responseURL: string; abort(): void; getAllResponseHeaders(): string; getResponseHeader(header: string): string | null; @@ -12261,11 +13364,10 @@ declare var XMLHttpRequest: { readonly LOADING: number; readonly OPENED: number; readonly UNSENT: number; - create(): XMLHttpRequest; } interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { - addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12365,6 +13467,16 @@ declare var XSLTProcessor: { new(): XSLTProcessor; } +interface webkitRTCPeerConnection extends RTCPeerConnection { + addEventListener(type: K, listener: (this: webkitRTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var webkitRTCPeerConnection: { + prototype: webkitRTCPeerConnection; + new(configuration: RTCConfiguration): webkitRTCPeerConnection; +} + interface AbstractWorkerEventMap { "error": ErrorEvent; } @@ -12375,6 +13487,14 @@ interface AbstractWorker { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface Body { + readonly bodyUsed: boolean; + arrayBuffer(): Promise; + blob(): Promise; + json(): Promise; + text(): Promise; +} + interface CanvasPathMethods { arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; @@ -12401,12 +13521,10 @@ interface DOML2DeprecatedSizeProperty { interface DocumentEvent { createEvent(eventInterface:"AnimationEvent"): AnimationEvent; - createEvent(eventInterface:"AriaRequestEvent"): AriaRequestEvent; createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent; createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent; createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent; createEvent(eventInterface:"CloseEvent"): CloseEvent; - createEvent(eventInterface:"CommandEvent"): CommandEvent; createEvent(eventInterface:"CompositionEvent"): CompositionEvent; createEvent(eventInterface:"CustomEvent"): CustomEvent; createEvent(eventInterface:"DeviceLightEvent"): DeviceLightEvent; @@ -12417,6 +13535,7 @@ interface DocumentEvent { createEvent(eventInterface:"Event"): Event; createEvent(eventInterface:"Events"): Event; createEvent(eventInterface:"FocusEvent"): FocusEvent; + createEvent(eventInterface:"FocusNavigationEvent"): FocusNavigationEvent; createEvent(eventInterface:"GamepadEvent"): GamepadEvent; createEvent(eventInterface:"HashChangeEvent"): HashChangeEvent; createEvent(eventInterface:"IDBVersionChangeEvent"): IDBVersionChangeEvent; @@ -12432,6 +13551,7 @@ interface DocumentEvent { createEvent(eventInterface:"MediaEncryptedEvent"): MediaEncryptedEvent; createEvent(eventInterface:"MediaKeyMessageEvent"): MediaKeyMessageEvent; createEvent(eventInterface:"MediaStreamErrorEvent"): MediaStreamErrorEvent; + createEvent(eventInterface:"MediaStreamEvent"): MediaStreamEvent; createEvent(eventInterface:"MediaStreamTrackEvent"): MediaStreamTrackEvent; createEvent(eventInterface:"MessageEvent"): MessageEvent; createEvent(eventInterface:"MouseEvent"): MouseEvent; @@ -12444,6 +13564,7 @@ interface DocumentEvent { createEvent(eventInterface:"OfflineAudioCompletionEvent"): OfflineAudioCompletionEvent; createEvent(eventInterface:"OverflowEvent"): OverflowEvent; createEvent(eventInterface:"PageTransitionEvent"): PageTransitionEvent; + createEvent(eventInterface:"PaymentRequestUpdateEvent"): PaymentRequestUpdateEvent; createEvent(eventInterface:"PermissionRequestedEvent"): PermissionRequestedEvent; createEvent(eventInterface:"PointerEvent"): PointerEvent; createEvent(eventInterface:"PopStateEvent"): PopStateEvent; @@ -12453,10 +13574,13 @@ interface DocumentEvent { createEvent(eventInterface:"RTCIceCandidatePairChangedEvent"): RTCIceCandidatePairChangedEvent; createEvent(eventInterface:"RTCIceGathererEvent"): RTCIceGathererEvent; createEvent(eventInterface:"RTCIceTransportStateChangedEvent"): RTCIceTransportStateChangedEvent; + createEvent(eventInterface:"RTCPeerConnectionIceEvent"): RTCPeerConnectionIceEvent; createEvent(eventInterface:"RTCSsrcConflictEvent"): RTCSsrcConflictEvent; createEvent(eventInterface:"SVGZoomEvent"): SVGZoomEvent; createEvent(eventInterface:"SVGZoomEvents"): SVGZoomEvent; createEvent(eventInterface:"ScriptNotifyEvent"): ScriptNotifyEvent; + createEvent(eventInterface:"ServiceWorkerMessageEvent"): ServiceWorkerMessageEvent; + createEvent(eventInterface:"SpeechSynthesisEvent"): SpeechSynthesisEvent; createEvent(eventInterface:"StorageEvent"): StorageEvent; createEvent(eventInterface:"TextEvent"): TextEvent; createEvent(eventInterface:"TouchEvent"): TouchEvent; @@ -12472,10 +13596,10 @@ interface DocumentEvent { interface ElementTraversal { readonly childElementCount: number; - readonly firstElementChild: Element; - readonly lastElementChild: Element; - readonly nextElementSibling: Element; - readonly previousElementSibling: Element; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; + readonly nextElementSibling: Element | null; + readonly previousElementSibling: Element | null; } interface GetSVGDocument { @@ -12508,6 +13632,10 @@ interface GlobalEventHandlers { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface GlobalFetch { + fetch(input: RequestInfo, init?: RequestInit): Promise; +} + interface HTMLTableAlignment { /** * Sets or retrieves a value that you can use to implement your own ch functionality for the object. @@ -12571,6 +13699,14 @@ interface MSNavigatorDoNotTrack { storeWebWideTrackingException(args: StoreExceptionsInformation): void; } +interface NavigatorBeacon { + sendBeacon(url: USVString, data?: BodyInit): boolean; +} + +interface NavigatorConcurrentHardware { + readonly hardwareConcurrency: number; +} + interface NavigatorContentUtils { } @@ -12579,6 +13715,7 @@ interface NavigatorGeolocation { } interface NavigatorID { + readonly appCodeName: string; readonly appName: string; readonly appVersion: string; readonly platform: string; @@ -12612,20 +13749,12 @@ interface RandomSource { getRandomValues(array: ArrayBufferView): ArrayBufferView; } -interface SVGAnimatedPathData { - readonly pathSegList: SVGPathSegList; -} - interface SVGAnimatedPoints { readonly animatedPoints: SVGPointList; readonly points: SVGPointList; } -interface SVGExternalResourcesRequired { - readonly externalResourcesRequired: SVGAnimatedBoolean; -} - -interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { +interface SVGFilterPrimitiveStandardAttributes { readonly height: SVGAnimatedLength; readonly result: SVGAnimatedString; readonly width: SVGAnimatedLength; @@ -12638,25 +13767,6 @@ interface SVGFitToViewBox { readonly viewBox: SVGAnimatedRect; } -interface SVGLangSpace { - xmllang: string; - xmlspace: string; -} - -interface SVGLocatable { - readonly farthestViewportElement: SVGElement; - readonly nearestViewportElement: SVGElement; - getBBox(): SVGRect; - getCTM(): SVGMatrix; - getScreenCTM(): SVGMatrix; - getTransformToElement(element: SVGElement): SVGMatrix; -} - -interface SVGStylable { - className: any; - readonly style: CSSStyleDeclaration; -} - interface SVGTests { readonly requiredExtensions: SVGStringList; readonly requiredFeatures: SVGStringList; @@ -12664,10 +13774,6 @@ interface SVGTests { hasExtension(extension: string): boolean; } -interface SVGTransformable extends SVGLocatable { - readonly transform: SVGAnimatedTransformList; -} - interface SVGURIReference { readonly href: SVGAnimatedString; } @@ -12726,6 +13832,14 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface ErrorEventInit { + message?: string; + filename?: string; + lineno?: number; + conlno?: number; + error?: any; +} + interface StorageEventInit extends EventInit { key?: string; oldValue?: string; @@ -12741,6 +13855,41 @@ interface Canvas2DContextAttributes { [attribute: string]: boolean | string | undefined; } +interface URLSearchParams { + /** + * Appends a specified key/value pair as a new search parameter. + */ + append(name: string, value: string): void; + /** + * Deletes the given search parameter, and its associated value, from the list of all search parameters. + */ + delete(name: string): void; + /** + * Returns the first value associated to the given search parameter. + */ + get(name: string): string | null; + /** + * Returns all the values association with a given search parameter. + */ + getAll(name: string): string[]; + /** + * Returns a Boolean indicating if such a search parameter exists. + */ + has(name: string): boolean; + /** + * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. + */ + set(name: string, value: string): void; +} + +declare var URLSearchParams: { + prototype: URLSearchParams; + /** + * Constructor returning a URLSearchParams object. + */ + new (init?: string | URLSearchParams): URLSearchParams; +} + interface NodeListOf extends NodeList { length: number; item(index: number): TNode; @@ -12750,7 +13899,6 @@ interface NodeListOf extends NodeList { interface HTMLCollectionOf extends HTMLCollection { item(index: number): T; namedItem(name: string): T; - [index: number]: T; } interface BlobPropertyBag { @@ -12767,15 +13915,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -interface MessageEventInit extends EventInit { - data?: any; - origin?: string; - lastEventId?: string; - channel?: string; - source?: any; - ports?: MessagePort[]; -} - interface ProgressEventInit extends EventInit { lengthComputable?: boolean; loaded?: number; @@ -12977,8 +14116,8 @@ interface JsonWebKey { interface ParentNode { readonly children: HTMLCollection; - readonly firstElementChild: Element; - readonly lastElementChild: Element; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; readonly childElementCount: number; } @@ -13009,6 +14148,26 @@ interface AssignedNodesOptions { flatten?: boolean; } +interface ElementDefinitionOptions { + extends: string; +} + +interface CustomElementRegistry { + define(name: string, constructor: Function, options?: ElementDefinitionOptions): void; + get(name: string): any; + whenDefined(name: string): PromiseLike; +} + +interface PromiseRejectionEvent extends Event { + readonly promise: PromiseLike; + readonly reason: any; +} + +interface PromiseRejectionEventInit extends EventInit { + promise: PromiseLike; + reason?: any; +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -13044,6 +14203,18 @@ interface DecodeSuccessCallback { interface DecodeErrorCallback { (error: DOMException): void; } +interface VoidFunction { + (): void; +} +interface RTCSessionDescriptionCallback { + (sdp: RTCSessionDescription): void; +} +interface RTCPeerConnectionErrorCallback { + (error: DOMError): void; +} +interface RTCStatsCallback { + (report: RTCStatsReport): void; +} interface FunctionStringCallback { (data: string): void; } @@ -13056,6 +14227,12 @@ interface NavigatorUserMediaErrorCallback { interface ForEachCallback { (keyId: any, status: string): void; } +interface NotificationPermissionCallback { + (permission: string): void; +} +interface IntersectionObserverCallback { + (entries: IntersectionObserverEntry[], observer: IntersectionObserver): void; +} interface HTMLElementTagNameMap { "a": HTMLAnchorElement; "applet": HTMLAppletElement; @@ -13071,6 +14248,7 @@ interface HTMLElementTagNameMap { "caption": HTMLTableCaptionElement; "col": HTMLTableColElement; "colgroup": HTMLTableColElement; + "data": HTMLDataElement; "datalist": HTMLDataListElement; "del": HTMLModElement; "dir": HTMLDirectoryElement; @@ -13111,6 +14289,7 @@ interface HTMLElementTagNameMap { "ol": HTMLOListElement; "optgroup": HTMLOptGroupElement; "option": HTMLOptionElement; + "output": HTMLOutputElement; "p": HTMLParagraphElement; "param": HTMLParamElement; "picture": HTMLPictureElement; @@ -13130,6 +14309,7 @@ interface HTMLElementTagNameMap { "tfoot": HTMLTableSectionElement; "th": HTMLTableHeaderCellElement; "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; "title": HTMLTitleElement; "tr": HTMLTableRowElement; "track": HTMLTrackElement; @@ -13167,6 +14347,7 @@ interface ElementTagNameMap { "code": HTMLElement; "col": HTMLTableColElement; "colgroup": HTMLTableColElement; + "data": HTMLDataElement; "datalist": HTMLDataListElement; "dd": HTMLElement; "defs": SVGDefsElement; @@ -13260,6 +14441,7 @@ interface ElementTagNameMap { "ol": HTMLOListElement; "optgroup": HTMLOptGroupElement; "option": HTMLOptionElement; + "output": HTMLOutputElement; "p": HTMLParagraphElement; "param": HTMLParamElement; "path": SVGPathElement; @@ -13302,6 +14484,7 @@ interface ElementTagNameMap { "tfoot": HTMLTableSectionElement; "th": HTMLTableHeaderCellElement; "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; "title": HTMLTitleElement; "tr": HTMLTableRowElement; "track": HTMLTrackElement; @@ -13346,6 +14529,7 @@ interface ElementListTagNameMap { "code": NodeListOf; "col": NodeListOf; "colgroup": NodeListOf; + "data": NodeListOf; "datalist": NodeListOf; "dd": NodeListOf; "defs": NodeListOf; @@ -13439,6 +14623,7 @@ interface ElementListTagNameMap { "ol": NodeListOf; "optgroup": NodeListOf; "option": NodeListOf; + "output": NodeListOf; "p": NodeListOf; "param": NodeListOf; "path": NodeListOf; @@ -13481,6 +14666,7 @@ interface ElementListTagNameMap { "tfoot": NodeListOf; "th": NodeListOf; "thead": NodeListOf; + "time": NodeListOf; "title": NodeListOf; "tr": NodeListOf; "track": NodeListOf; @@ -13501,6 +14687,7 @@ declare var Audio: {new(src?: string): HTMLAudioElement; }; declare var Image: {new(width?: number, height?: number): HTMLImageElement; }; declare var Option: {new(text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; }; declare var applicationCache: ApplicationCache; +declare var caches: CacheStorage; declare var clientInformation: Navigator; declare var closed: boolean; declare var crypto: Crypto; @@ -13515,10 +14702,12 @@ declare var frames: Window; declare var history: History; declare var innerHeight: number; declare var innerWidth: number; +declare var isSecureContext: boolean; declare var length: number; declare var location: Location; declare var locationbar: BarProp; declare var menubar: BarProp; +declare var msContentScript: ExtensionScriptApis; declare var msCredentials: MSCredentials; declare const name: never; declare var navigator: Navigator; @@ -13632,18 +14821,21 @@ declare var scrollX: number; declare var scrollY: number; declare var scrollbars: BarProp; declare var self: Window; +declare var speechSynthesis: SpeechSynthesis; declare var status: string; declare var statusbar: BarProp; declare var styleMedia: StyleMedia; declare var toolbar: BarProp; declare var top: Window; declare var window: Window; +declare var customElements: CustomElementRegistry; declare function alert(message?: any): void; declare function blur(): void; declare function cancelAnimationFrame(handle: number): void; declare function captureEvents(): void; declare function close(): void; declare function confirm(message?: string): boolean; +declare function departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; declare function focus(): void; declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; declare function getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -13663,6 +14855,7 @@ declare function resizeTo(x?: number, y?: number): void; declare function scroll(x?: number, y?: number): void; declare function scrollBy(x?: number, y?: number): void; declare function scrollTo(x?: number, y?: number): void; +declare function stop(): void; declare function webkitCancelAnimationFrame(handle: number): void; declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; @@ -13697,10 +14890,13 @@ declare var onwheel: (this: Window, ev: WheelEvent) => any; declare var indexedDB: IDBFactory; declare function atob(encodedString: string): string; declare function btoa(rawString: string): string; +declare function fetch(input: RequestInfo, init?: RequestInit): Promise; declare function addEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; type AAGUID = string; type AlgorithmIdentifier = string | Algorithm; +type BodyInit = any; +type ByteString = string; type ConstrainBoolean = boolean | ConstrainBooleanParameters; type ConstrainDOMString = string | string[] | ConstrainDOMStringParameters; type ConstrainDouble = number | ConstrainDoubleRange; @@ -13720,6 +14916,7 @@ type GLsizeiptr = number; type GLubyte = number; type GLuint = number; type GLushort = number; +type HeadersInit = any; type IDBKeyPath = string; type KeyFormat = string; type KeyType = string; @@ -13727,8 +14924,10 @@ type KeyUsage = string; type MSInboundPayload = MSVideoRecvPayload | MSAudioRecvPayload; type MSLocalClientEvent = MSLocalClientEventBase | MSAudioLocalClientEvent; type MSOutboundPayload = MSVideoSendPayload | MSAudioSendPayload; -type RTCIceGatherCandidate = RTCIceCandidate | RTCIceCandidateComplete; +type RTCIceGatherCandidate = RTCIceCandidateDictionary | RTCIceCandidateComplete; type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport; +type RequestInfo = Request | string; +type USVString = string; type payloadtype = number; type ScrollBehavior = "auto" | "instant" | "smooth"; type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; diff --git a/lib/lib.es2015.collection.d.ts b/lib/lib.es2015.collection.d.ts index 9f4a23f3254..bf36745dcf9 100644 --- a/lib/lib.es2015.collection.d.ts +++ b/lib/lib.es2015.collection.d.ts @@ -24,7 +24,7 @@ interface Map { forEach(callbackfn: (value: V, key: K, map: Map) => void, thisArg?: any): void; get(key: K): V | undefined; has(key: K): boolean; - set(key: K, value?: V): this; + set(key: K, value: V): this; readonly size: number; } @@ -42,16 +42,16 @@ interface ReadonlyMap { readonly size: number; } -interface WeakMap { +interface WeakMap { delete(key: K): boolean; get(key: K): V | undefined; has(key: K): boolean; - set(key: K, value?: V): this; + set(key: K, value: V): this; } interface WeakMapConstructor { new (): WeakMap; - new (entries?: [K, V][]): WeakMap; + new (entries?: [K, V][]): WeakMap; readonly prototype: WeakMap; } declare var WeakMap: WeakMapConstructor; diff --git a/lib/lib.es2015.core.d.ts b/lib/lib.es2015.core.d.ts index 7f03aaec04d..ae633957cd5 100644 --- a/lib/lib.es2015.core.d.ts +++ b/lib/lib.es2015.core.d.ts @@ -345,7 +345,7 @@ interface ObjectConstructor { * @param o The object to change its prototype. * @param proto The value of the new prototype or null. */ - setPrototypeOf(o: any, proto: any): any; + setPrototypeOf(o: any, proto: object | null): any; /** * Gets the own property descriptor of the specified object. diff --git a/lib/lib.es2015.iterable.d.ts b/lib/lib.es2015.iterable.d.ts index 02c72a5ee36..3f9ffc62f3c 100644 --- a/lib/lib.es2015.iterable.d.ts +++ b/lib/lib.es2015.iterable.d.ts @@ -119,10 +119,10 @@ interface MapConstructor { new (iterable: Iterable<[K, V]>): Map; } -interface WeakMap { } +interface WeakMap { } interface WeakMapConstructor { - new (iterable: Iterable<[K, V]>): WeakMap; + new (iterable: Iterable<[K, V]>): WeakMap; } interface Set { @@ -462,4 +462,4 @@ interface Float64ArrayConstructor { * @param thisArg Value of 'this' used to invoke the mapfn. */ from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; -} \ No newline at end of file +} diff --git a/lib/lib.es2015.promise.d.ts b/lib/lib.es2015.promise.d.ts index 99df9263ea1..b628cb89015 100644 --- a/lib/lib.es2015.promise.d.ts +++ b/lib/lib.es2015.promise.d.ts @@ -18,57 +18,6 @@ and limitations under the License. /// -/** - * Represents the completion of an asynchronous operation - */ -interface Promise { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled?: ((value: T) => T | PromiseLike) | undefined | null, onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): Promise; - - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled: ((value: T) => T | PromiseLike) | undefined | null, onrejected: (reason: any) => TResult | PromiseLike): Promise; - - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled: (value: T) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; - - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled: (value: T) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; - - /** - * Attaches a callback for only the rejection of the Promise. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of the callback. - */ - catch(onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): Promise; - - /** - * Attaches a callback for only the rejection of the Promise. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of the callback. - */ - catch(onrejected: (reason: any) => TResult | PromiseLike): Promise; -} - interface PromiseConstructor { /** * A reference to the prototype. diff --git a/lib/lib.es2015.proxy.d.ts b/lib/lib.es2015.proxy.d.ts index d935cdf9781..3b1d8828575 100644 --- a/lib/lib.es2015.proxy.d.ts +++ b/lib/lib.es2015.proxy.d.ts @@ -19,7 +19,7 @@ and limitations under the License. interface ProxyHandler { - getPrototypeOf? (target: T): {} | null; + getPrototypeOf? (target: T): object | null; setPrototypeOf? (target: T, v: any): boolean; isExtensible? (target: T): boolean; preventExtensions? (target: T): boolean; @@ -32,7 +32,7 @@ interface ProxyHandler { enumerate? (target: T): PropertyKey[]; ownKeys? (target: T): PropertyKey[]; apply? (target: T, thisArg: any, argArray?: any): any; - construct? (target: T, argArray: any, newTarget?: any): {}; + construct? (target: T, argArray: any, newTarget?: any): object } interface ProxyConstructor { diff --git a/lib/lib.es2015.symbol.d.ts b/lib/lib.es2015.symbol.d.ts index 3776a44670d..f1a87d316a0 100644 --- a/lib/lib.es2015.symbol.d.ts +++ b/lib/lib.es2015.symbol.d.ts @@ -23,7 +23,7 @@ interface Symbol { toString(): string; /** Returns the primitive value of the specified object. */ - valueOf(): Object; + valueOf(): symbol; } interface SymbolConstructor { diff --git a/lib/lib.es2015.symbol.wellknown.d.ts b/lib/lib.es2015.symbol.wellknown.d.ts index e95f324131a..4668862af5f 100644 --- a/lib/lib.es2015.symbol.wellknown.d.ts +++ b/lib/lib.es2015.symbol.wellknown.d.ts @@ -130,7 +130,7 @@ interface Map { readonly [Symbol.toStringTag]: "Map"; } -interface WeakMap{ +interface WeakMap{ readonly [Symbol.toStringTag]: "WeakMap"; } @@ -344,4 +344,4 @@ interface Float32Array { */ interface Float64Array { readonly [Symbol.toStringTag]: "Float64Array"; -} \ No newline at end of file +} diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index 4d48fed85ed..f0c6e9fb861 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -157,23 +157,17 @@ interface ObjectConstructor { getOwnPropertyNames(o: any): string[]; /** - * Creates an object that has null prototype. - * @param o Object to use as a prototype. May be null + * Creates an object that has the specified prototype or that has null prototype. + * @param o Object to use as a prototype. May be null. */ - create(o: null): any; - - /** - * Creates an object that has the specified prototype, and that optionally contains specified properties. - * @param o Object to use as a prototype. May be null - */ - create(o: T): T; + create(o: T | null): T | object; /** * Creates an object that has the specified prototype, and that optionally contains specified properties. * @param o Object to use as a prototype. May be null * @param properties JavaScript object that contains one or more property descriptors. */ - create(o: any, properties: PropertyDescriptorMap): any; + create(o: object | null, properties: PropertyDescriptorMap): any; /** * Adds a property to an object, or modifies attributes of an existing property. @@ -361,14 +355,14 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string that represents the regular expression. + * @param searchValue A string to search for. * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string that represents the regular expression. + * @param searchValue A string to search for. * @param replacer A function that returns the replacement text. */ replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; @@ -1191,8 +1185,9 @@ interface Array { /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. */ - splice(start: number): T[]; + splice(start: number, deleteCount?: number): T[]; /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. @@ -1335,39 +1330,27 @@ interface PromiseLike { * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ - then( - onfulfilled?: ((value: T) => T | PromiseLike) | undefined | null, - onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): PromiseLike; + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): PromiseLike; +} +/** + * Represents the completion of an asynchronous operation + */ +interface Promise { /** * Attaches callbacks for the resolution and/or rejection of the Promise. * @param onfulfilled The callback to execute when the Promise is resolved. * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ - then( - onfulfilled: ((value: T) => T | PromiseLike) | undefined | null, - onrejected: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Promise; /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. + * Attaches a callback for only the rejection of the Promise. * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. + * @returns A Promise for the completion of the callback. */ - then( - onfulfilled: (value: T) => TResult | PromiseLike, - onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): PromiseLike; - - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then( - onfulfilled: (value: T) => TResult1 | PromiseLike, - onrejected: (reason: any) => TResult2 | PromiseLike): PromiseLike; + catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; } interface ArrayLike { diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 9530bf7bfbc..777141c0dba 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -157,23 +157,17 @@ interface ObjectConstructor { getOwnPropertyNames(o: any): string[]; /** - * Creates an object that has null prototype. - * @param o Object to use as a prototype. May be null + * Creates an object that has the specified prototype or that has null prototype. + * @param o Object to use as a prototype. May be null. */ - create(o: null): any; - - /** - * Creates an object that has the specified prototype, and that optionally contains specified properties. - * @param o Object to use as a prototype. May be null - */ - create(o: T): T; + create(o: T | null): T | object; /** * Creates an object that has the specified prototype, and that optionally contains specified properties. * @param o Object to use as a prototype. May be null * @param properties JavaScript object that contains one or more property descriptors. */ - create(o: any, properties: PropertyDescriptorMap): any; + create(o: object | null, properties: PropertyDescriptorMap): any; /** * Adds a property to an object, or modifies attributes of an existing property. @@ -361,14 +355,14 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string that represents the regular expression. + * @param searchValue A string to search for. * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string that represents the regular expression. + * @param searchValue A string to search for. * @param replacer A function that returns the replacement text. */ replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; @@ -1191,8 +1185,9 @@ interface Array { /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. */ - splice(start: number): T[]; + splice(start: number, deleteCount?: number): T[]; /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. @@ -1335,39 +1330,27 @@ interface PromiseLike { * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ - then( - onfulfilled?: ((value: T) => T | PromiseLike) | undefined | null, - onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): PromiseLike; + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): PromiseLike; +} +/** + * Represents the completion of an asynchronous operation + */ +interface Promise { /** * Attaches callbacks for the resolution and/or rejection of the Promise. * @param onfulfilled The callback to execute when the Promise is resolved. * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ - then( - onfulfilled: ((value: T) => T | PromiseLike) | undefined | null, - onrejected: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Promise; /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. + * Attaches a callback for only the rejection of the Promise. * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. + * @returns A Promise for the completion of the callback. */ - then( - onfulfilled: (value: T) => TResult | PromiseLike, - onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): PromiseLike; - - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then( - onfulfilled: (value: T) => TResult1 | PromiseLike, - onrejected: (reason: any) => TResult2 | PromiseLike): PromiseLike; + catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; } interface ArrayLike { @@ -4522,7 +4505,7 @@ interface ObjectConstructor { * @param o The object to change its prototype. * @param proto The value of the new prototype or null. */ - setPrototypeOf(o: any, proto: any): any; + setPrototypeOf(o: any, proto: object | null): any; /** * Gets the own property descriptor of the specified object. @@ -4727,7 +4710,7 @@ interface Map { forEach(callbackfn: (value: V, key: K, map: Map) => void, thisArg?: any): void; get(key: K): V | undefined; has(key: K): boolean; - set(key: K, value?: V): this; + set(key: K, value: V): this; readonly size: number; } @@ -4745,16 +4728,16 @@ interface ReadonlyMap { readonly size: number; } -interface WeakMap { +interface WeakMap { delete(key: K): boolean; get(key: K): V | undefined; has(key: K): boolean; - set(key: K, value?: V): this; + set(key: K, value: V): this; } interface WeakMapConstructor { new (): WeakMap; - new (entries?: [K, V][]): WeakMap; + new (entries?: [K, V][]): WeakMap; readonly prototype: WeakMap; } declare var WeakMap: WeakMapConstructor; @@ -4910,10 +4893,10 @@ interface MapConstructor { new (iterable: Iterable<[K, V]>): Map; } -interface WeakMap { } +interface WeakMap { } interface WeakMapConstructor { - new (iterable: Iterable<[K, V]>): WeakMap; + new (iterable: Iterable<[K, V]>): WeakMap; } interface Set { @@ -5255,56 +5238,6 @@ interface Float64ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } -/** - * Represents the completion of an asynchronous operation - */ -interface Promise { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled?: ((value: T) => T | PromiseLike) | undefined | null, onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): Promise; - - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled: ((value: T) => T | PromiseLike) | undefined | null, onrejected: (reason: any) => TResult | PromiseLike): Promise; - - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled: (value: T) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; - - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled: (value: T) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; - - /** - * Attaches a callback for only the rejection of the Promise. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of the callback. - */ - catch(onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): Promise; - - /** - * Attaches a callback for only the rejection of the Promise. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of the callback. - */ - catch(onrejected: (reason: any) => TResult | PromiseLike): Promise; -} interface PromiseConstructor { /** @@ -5511,7 +5444,7 @@ interface PromiseConstructor { declare var Promise: PromiseConstructor; interface ProxyHandler { - getPrototypeOf? (target: T): {} | null; + getPrototypeOf? (target: T): object | null; setPrototypeOf? (target: T, v: any): boolean; isExtensible? (target: T): boolean; preventExtensions? (target: T): boolean; @@ -5524,7 +5457,7 @@ interface ProxyHandler { enumerate? (target: T): PropertyKey[]; ownKeys? (target: T): PropertyKey[]; apply? (target: T, thisArg: any, argArray?: any): any; - construct? (target: T, argArray: any, newTarget?: any): {}; + construct? (target: T, argArray: any, newTarget?: any): object } interface ProxyConstructor { @@ -5555,7 +5488,7 @@ interface Symbol { toString(): string; /** Returns the primitive value of the specified object. */ - valueOf(): Object; + valueOf(): symbol; } interface SymbolConstructor { @@ -5699,7 +5632,7 @@ interface Map { readonly [Symbol.toStringTag]: "Map"; } -interface WeakMap{ +interface WeakMap{ readonly [Symbol.toStringTag]: "WeakMap"; } @@ -5916,22 +5849,55 @@ interface Float64Array { } + ///////////////////////////// /// IE DOM APIs ///////////////////////////// +interface Account { + rpDisplayName?: string; + displayName?: string; + id?: string; + name?: string; + imageURL?: string; +} + interface Algorithm { name: string; } -interface AriaRequestEventInit extends EventInit { - attributeName?: string; - attributeValue?: string; +interface AnimationEventInit extends EventInit { + animationName?: string; + elapsedTime?: number; } -interface CommandEventInit extends EventInit { - commandName?: string; - detail?: string; +interface AssertionOptions { + timeoutSeconds?: number; + rpId?: USVString; + allowList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface CacheQueryOptions { + ignoreSearch?: boolean; + ignoreMethod?: boolean; + ignoreVary?: boolean; + cacheName?: string; +} + +interface ClientData { + challenge?: string; + origin?: string; + rpId?: string; + hashAlg?: string | Algorithm; + tokenBinding?: string; + extensions?: WebAuthnExtensions; +} + +interface CloseEventInit extends EventInit { + wasClean?: boolean; + code?: number; + reason?: string; } interface CompositionEventInit extends UIEventInit { @@ -5971,6 +5937,13 @@ interface CustomEventInit extends EventInit { detail?: any; } +interface DOMRectInit { + x?: any; + y?: any; + width?: any; + height?: any; +} + interface DeviceAccelerationDict { x?: number; y?: number; @@ -5981,6 +5954,20 @@ interface DeviceLightEventInit extends EventInit { value?: number; } +interface DeviceMotionEventInit extends EventInit { + acceleration?: DeviceAccelerationDict; + accelerationIncludingGravity?: DeviceAccelerationDict; + rotationRate?: DeviceRotationRateDict; + interval?: number; +} + +interface DeviceOrientationEventInit extends EventInit { + alpha?: number; + beta?: number; + gamma?: number; + absolute?: boolean; +} + interface DeviceRotationRateDict { alpha?: number; beta?: number; @@ -5992,6 +5979,14 @@ interface DoubleRange { min?: number; } +interface ErrorEventInit extends EventInit { + message?: string; + filename?: string; + lineno?: number; + colno?: number; + error?: any; +} + interface EventInit { scoped?: boolean; bubbles?: boolean; @@ -6024,6 +6019,29 @@ interface FocusEventInit extends UIEventInit { relatedTarget?: EventTarget; } +interface FocusNavigationEventInit extends EventInit { + navigationReason?: string; + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface FocusNavigationOrigin { + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface GamepadEventInit extends EventInit { + gamepad?: Gamepad; +} + +interface GetNotificationOptions { + tag?: string; +} + interface HashChangeEventInit extends EventInit { newURL?: string; oldURL?: string; @@ -6039,6 +6057,20 @@ interface IDBObjectStoreParameters { keyPath?: IDBKeyPath; } +interface IntersectionObserverEntryInit { + time?: number; + rootBounds?: DOMRectInit; + boundingClientRect?: DOMRectInit; + intersectionRect?: DOMRectInit; + target?: Element; +} + +interface IntersectionObserverInit { + root?: Element; + rootMargin?: string; + threshold?: number | number[]; +} + interface KeyAlgorithm { name?: string; } @@ -6241,6 +6273,11 @@ interface MSPayloadBase extends RTCStats { payloadDescription?: string; } +interface MSPortRange { + min?: number; + max?: number; +} + interface MSRelayAddress { relayAddress?: string; port?: number; @@ -6291,7 +6328,7 @@ interface MSUtilization { } interface MSVideoPayload extends MSPayloadBase { - resoluton?: string; + resolution?: string; videoBitRateAvg?: number; videoBitRateMax?: number; videoFrameRateAvg?: number; @@ -6374,6 +6411,10 @@ interface MediaStreamErrorEventInit extends EventInit { error?: MediaStreamError; } +interface MediaStreamEventInit extends EventInit { + stream?: MediaStream; +} + interface MediaStreamTrackEventInit extends EventInit { track?: MediaStreamTrack; } @@ -6438,6 +6479,15 @@ interface MediaTrackSupportedConstraints { groupId?: boolean; } +interface MessageEventInit extends EventInit { + lastEventId?: string; + channel?: string; + data?: any; + origin?: string; + source?: Window; + ports?: MessagePort[]; +} + interface MouseEventInit extends EventModifierInit { screenX?: number; screenY?: number; @@ -6467,10 +6517,68 @@ interface MutationObserverInit { attributeFilter?: string[]; } +interface NotificationOptions { + dir?: string; + lang?: string; + body?: string; + tag?: string; + icon?: string; +} + interface ObjectURLOptions { oneTimeOnly?: boolean; } +interface PaymentCurrencyAmount { + currency?: string; + value?: string; + currencySystem?: string; +} + +interface PaymentDetails { + total?: PaymentItem; + displayItems?: PaymentItem[]; + shippingOptions?: PaymentShippingOption[]; + modifiers?: PaymentDetailsModifier[]; + error?: string; +} + +interface PaymentDetailsModifier { + supportedMethods?: string[]; + total?: PaymentItem; + additionalDisplayItems?: PaymentItem[]; + data?: any; +} + +interface PaymentItem { + label?: string; + amount?: PaymentCurrencyAmount; + pending?: boolean; +} + +interface PaymentMethodData { + supportedMethods?: string[]; + data?: any; +} + +interface PaymentOptions { + requestPayerName?: boolean; + requestPayerEmail?: boolean; + requestPayerPhone?: boolean; + requestShipping?: boolean; + shippingType?: string; +} + +interface PaymentRequestUpdateEventInit extends EventInit { +} + +interface PaymentShippingOption { + id?: string; + label?: string; + amount?: PaymentCurrencyAmount; + selected?: boolean; +} + interface PeriodicWaveConstraints { disableNormalization?: boolean; } @@ -6486,12 +6594,34 @@ interface PointerEventInit extends MouseEventInit { isPrimary?: boolean; } +interface PopStateEventInit extends EventInit { + state?: any; +} + interface PositionOptions { enableHighAccuracy?: boolean; timeout?: number; maximumAge?: number; } +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + +interface PushSubscriptionOptionsInit { + userVisibleOnly?: boolean; + applicationServerKey?: any; +} + +interface RTCConfiguration { + iceServers?: RTCIceServer[]; + iceTransportPolicy?: string; + bundlePolicy?: string; + peerIdentity?: string; +} + interface RTCDTMFToneChangeEventInit extends EventInit { tone?: string; } @@ -6506,18 +6636,6 @@ interface RTCDtlsParameters { fingerprints?: RTCDtlsFingerprint[]; } -interface RTCIceCandidate { - foundation?: string; - priority?: number; - ip?: string; - protocol?: string; - port?: number; - type?: string; - tcpType?: string; - relatedAddress?: string; - relatedPort?: number; -} - interface RTCIceCandidateAttributes extends RTCStats { ipAddress?: string; portNumber?: number; @@ -6530,9 +6648,28 @@ interface RTCIceCandidateAttributes extends RTCStats { interface RTCIceCandidateComplete { } +interface RTCIceCandidateDictionary { + foundation?: string; + priority?: number; + ip?: string; + protocol?: string; + port?: number; + type?: string; + tcpType?: string; + relatedAddress?: string; + relatedPort?: number; + msMTurnSessionId?: string; +} + +interface RTCIceCandidateInit { + candidate?: string; + sdpMid?: string; + sdpMLineIndex?: number; +} + interface RTCIceCandidatePair { - local?: RTCIceCandidate; - remote?: RTCIceCandidate; + local?: RTCIceCandidateDictionary; + remote?: RTCIceCandidateDictionary; } interface RTCIceCandidatePairStats extends RTCStats { @@ -6554,11 +6691,13 @@ interface RTCIceCandidatePairStats extends RTCStats { interface RTCIceGatherOptions { gatherPolicy?: string; iceservers?: RTCIceServer[]; + portRange?: MSPortRange; } interface RTCIceParameters { usernameFragment?: string; password?: string; + iceLite?: boolean; } interface RTCIceServer { @@ -6592,6 +6731,13 @@ interface RTCMediaStreamTrackStats extends RTCStats { echoReturnLossEnhancement?: number; } +interface RTCOfferOptions { + offerToReceiveVideo?: number; + offerToReceiveAudio?: number; + voiceActivityDetection?: boolean; + iceRestart?: boolean; +} + interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { packetsSent?: number; bytesSent?: number; @@ -6599,6 +6745,10 @@ interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { roundTripTime?: number; } +interface RTCPeerConnectionIceEventInit extends EventInit { + candidate?: RTCIceCandidate; +} + interface RTCRTPStreamStats extends RTCStats { ssrc?: string; associateStatsId?: string; @@ -6636,6 +6786,7 @@ interface RTCRtpCodecCapability { clockRate?: number; preferredPayloadType?: number; maxptime?: number; + ptime?: number; numChannels?: number; rtcpFeedback?: RTCRtcpFeedback[]; parameters?: any; @@ -6650,6 +6801,7 @@ interface RTCRtpCodecParameters { payloadType?: any; clockRate?: number; maxptime?: number; + ptime?: number; numChannels?: number; rtcpFeedback?: RTCRtcpFeedback[]; parameters?: any; @@ -6669,9 +6821,9 @@ interface RTCRtpEncodingParameters { priority?: number; maxBitrate?: number; minQuality?: number; - framerateBias?: number; resolutionScale?: number; framerateScale?: number; + maxFramerate?: number; active?: boolean; encodingId?: string; dependencyEncodingIds?: string[]; @@ -6702,6 +6854,7 @@ interface RTCRtpParameters { headerExtensions?: RTCRtpHeaderExtensionParameters[]; encodings?: RTCRtpEncodingParameters[]; rtcp?: RTCRtcpParameters; + degradationPreference?: string; } interface RTCRtpRtxParameters { @@ -6714,6 +6867,11 @@ interface RTCRtpUnhandled { muxId?: string; } +interface RTCSessionDescriptionInit { + type?: string; + sdp?: string; +} + interface RTCSrtpKeyParam { keyMethod?: string; keySalt?: string; @@ -6754,6 +6912,64 @@ interface RTCTransportStats extends RTCStats { remoteCertificateId?: string; } +interface RegistrationOptions { + scope?: string; +} + +interface RequestInit { + method?: string; + headers?: any; + body?: any; + referrer?: string; + referrerPolicy?: string; + mode?: string; + credentials?: string; + cache?: string; + redirect?: string; + integrity?: string; + keepalive?: boolean; + window?: any; +} + +interface ResponseInit { + status?: number; + statusText?: string; + headers?: any; +} + +interface ScopedCredentialDescriptor { + type?: string; + id?: any; + transports?: string[]; +} + +interface ScopedCredentialOptions { + timeoutSeconds?: number; + rpId?: USVString; + excludeList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface ScopedCredentialParameters { + type?: string; + algorithm?: string | Algorithm; +} + +interface ServiceWorkerMessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + source?: ServiceWorker | MessagePort; + ports?: MessagePort[]; +} + +interface SpeechSynthesisEventInit extends EventInit { + utterance?: SpeechSynthesisUtterance; + charIndex?: number; + elapsedTime?: number; + name?: string; +} + interface StoreExceptionsInformation extends ExceptionInformation { siteName?: string; explanationString?: string; @@ -6764,11 +6980,23 @@ interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformat arrayOfDomainStrings?: string[]; } +interface TrackEventInit extends EventInit { + track?: VideoTrack | AudioTrack | TextTrack; +} + +interface TransitionEventInit extends EventInit { + propertyName?: string; + elapsedTime?: number; +} + interface UIEventInit extends EventInit { view?: Window; detail?: number; } +interface WebAuthnExtensions { +} + interface WebGLContextAttributes { failIfMajorPerformanceCaveat?: boolean; alpha?: boolean; @@ -6794,6 +7022,18 @@ interface EventListener { (evt: Event): void; } +interface WebKitEntriesCallback { + (evt: Event): void; +} + +interface WebKitErrorCallback { + (evt: Event): void; +} + +interface WebKitFileCallback { + (evt: Event): void; +} + interface ANGLE_instanced_arrays { drawArraysInstancedANGLE(mode: number, first: number, count: number, primcount: number): void; drawElementsInstancedANGLE(mode: number, count: number, type: number, offset: number, primcount: number): void; @@ -6832,14 +7072,14 @@ interface AnimationEvent extends Event { declare var AnimationEvent: { prototype: AnimationEvent; - new(): AnimationEvent; + new(typeArg: string, eventInitDict?: AnimationEventInit): AnimationEvent; } interface ApplicationCacheEventMap { "cached": Event; "checking": Event; "downloading": Event; - "error": ErrorEvent; + "error": Event; "noupdate": Event; "obsolete": Event; "progress": ProgressEvent; @@ -6850,7 +7090,7 @@ interface ApplicationCache extends EventTarget { oncached: (this: ApplicationCache, ev: Event) => any; onchecking: (this: ApplicationCache, ev: Event) => any; ondownloading: (this: ApplicationCache, ev: Event) => any; - onerror: (this: ApplicationCache, ev: ErrorEvent) => any; + onerror: (this: ApplicationCache, ev: Event) => any; onnoupdate: (this: ApplicationCache, ev: Event) => any; onobsolete: (this: ApplicationCache, ev: Event) => any; onprogress: (this: ApplicationCache, ev: ProgressEvent) => any; @@ -6880,16 +7120,6 @@ declare var ApplicationCache: { readonly UPDATEREADY: number; } -interface AriaRequestEvent extends Event { - readonly attributeName: string; - attributeValue: string | null; -} - -declare var AriaRequestEvent: { - prototype: AriaRequestEvent; - new(type: string, eventInitDict?: AriaRequestEventInit): AriaRequestEvent; -} - interface Attr extends Node { readonly name: string; readonly ownerElement: Element; @@ -6941,12 +7171,18 @@ declare var AudioBufferSourceNode: { new(): AudioBufferSourceNode; } -interface AudioContext extends EventTarget { +interface AudioContextEventMap { + "statechange": Event; +} + +interface AudioContextBase extends EventTarget { readonly currentTime: number; readonly destination: AudioDestinationNode; readonly listener: AudioListener; + onstatechange: (this: AudioContext, ev: Event) => any; readonly sampleRate: number; - state: string; + readonly state: string; + close(): Promise; createAnalyser(): AnalyserNode; createBiquadFilter(): BiquadFilterNode; createBuffer(numberOfChannels: number, length: number, sampleRate: number): AudioBuffer; @@ -6957,6 +7193,7 @@ interface AudioContext extends EventTarget { createDelay(maxDelayTime?: number): DelayNode; createDynamicsCompressor(): DynamicsCompressorNode; createGain(): GainNode; + createIIRFilter(feedforward: number[], feedback: number[]): IIRFilterNode; createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; createMediaStreamSource(mediaStream: MediaStream): MediaStreamAudioSourceNode; createOscillator(): OscillatorNode; @@ -6965,7 +7202,14 @@ interface AudioContext extends EventTarget { createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; createStereoPanner(): StereoPannerNode; createWaveShaper(): WaveShaperNode; - decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): PromiseLike; + decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): Promise; + resume(): Promise; + addEventListener(type: K, listener: (this: AudioContext, ev: AudioContextEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface AudioContext extends AudioContextBase { + suspend(): Promise; } declare var AudioContext: { @@ -7002,7 +7246,7 @@ interface AudioNode extends EventTarget { readonly context: AudioContext; readonly numberOfInputs: number; readonly numberOfOutputs: number; - connect(destination: AudioNode, output?: number, input?: number): void; + connect(destination: AudioNode, output?: number, input?: number): AudioNode; disconnect(output?: number): void; disconnect(destination: AudioNode, output?: number, input?: number): void; disconnect(destination: AudioParam, output?: number): void; @@ -7016,12 +7260,12 @@ declare var AudioNode: { interface AudioParam { readonly defaultValue: number; value: number; - cancelScheduledValues(startTime: number): void; - exponentialRampToValueAtTime(value: number, endTime: number): void; - linearRampToValueAtTime(value: number, endTime: number): void; - setTargetAtTime(target: number, startTime: number, timeConstant: number): void; - setValueAtTime(value: number, startTime: number): void; - setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): void; + cancelScheduledValues(startTime: number): AudioParam; + exponentialRampToValueAtTime(value: number, endTime: number): AudioParam; + linearRampToValueAtTime(value: number, endTime: number): AudioParam; + setTargetAtTime(target: number, startTime: number, timeConstant: number): AudioParam; + setValueAtTime(value: number, startTime: number): AudioParam; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): AudioParam; } declare var AudioParam: { @@ -7398,10 +7642,16 @@ interface CSSStyleDeclaration { imeMode: string | null; justifyContent: string | null; kerning: string | null; + layoutGrid: string | null; + layoutGridChar: string | null; + layoutGridLine: string | null; + layoutGridMode: string | null; + layoutGridType: string | null; left: string | null; readonly length: number; letterSpacing: string | null; lightingColor: string | null; + lineBreak: string | null; lineHeight: string | null; listStyle: string | null; listStyleImage: string | null; @@ -7473,6 +7723,7 @@ interface CSSStyleDeclaration { orphans: string | null; outline: string | null; outlineColor: string | null; + outlineOffset: string | null; outlineStyle: string | null; outlineWidth: string | null; overflow: string | null; @@ -7493,9 +7744,11 @@ interface CSSStyleDeclaration { position: string | null; quotes: string | null; right: string | null; + rotate: string | null; rubyAlign: string | null; rubyOverhang: string | null; rubyPosition: string | null; + scale: string | null; stopColor: string | null; stopOpacity: string | null; stroke: string | null; @@ -7529,6 +7782,7 @@ interface CSSStyleDeclaration { transitionDuration: string | null; transitionProperty: string | null; transitionTimingFunction: string | null; + translate: string | null; unicodeBidi: string | null; verticalAlign: string | null; visibility: string | null; @@ -7589,6 +7843,9 @@ interface CSSStyleDeclaration { webkitTapHighlightColor: string | null; webkitTextFillColor: string | null; webkitTextSizeAdjust: any; + webkitTextStroke: string | null; + webkitTextStrokeColor: string | null; + webkitTextStrokeWidth: string | null; webkitTransform: string | null; webkitTransformOrigin: string | null; webkitTransformStyle: string | null; @@ -7610,6 +7867,7 @@ interface CSSStyleDeclaration { zIndex: string | null; zoom: string | null; resize: string | null; + userSelect: string | null; getPropertyPriority(propertyName: string): string; getPropertyValue(propertyName: string): string; item(index: number): string; @@ -7637,7 +7895,6 @@ declare var CSSStyleRule: { interface CSSStyleSheet extends StyleSheet { readonly cssRules: CSSRuleList; cssText: string; - readonly href: string; readonly id: string; readonly imports: StyleSheetList; readonly isAlternate: boolean; @@ -7669,6 +7926,34 @@ declare var CSSSupportsRule: { new(): CSSSupportsRule; } +interface Cache { + add(request: RequestInfo): Promise; + addAll(requests: RequestInfo[]): Promise; + delete(request: RequestInfo, options?: CacheQueryOptions): Promise; + keys(request?: RequestInfo, options?: CacheQueryOptions): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + put(request: RequestInfo, response: Response): Promise; +} + +declare var Cache: { + prototype: Cache; + new(): Cache; +} + +interface CacheStorage { + delete(cacheName: string): Promise; + has(cacheName: string): Promise; + keys(): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + open(cacheName: string): Promise; +} + +declare var CacheStorage: { + prototype: CacheStorage; + new(): CacheStorage; +} + interface CanvasGradient { addColorStop(offset: number, color: string): void; } @@ -7693,13 +7978,13 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { font: string; globalAlpha: number; globalCompositeOperation: string; + imageSmoothingEnabled: boolean; lineCap: string; lineDashOffset: number; lineJoin: string; lineWidth: number; miterLimit: number; msFillRule: string; - msImageSmoothingEnabled: boolean; shadowBlur: number; shadowColor: string; shadowOffsetX: number; @@ -7717,6 +8002,7 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; + drawFocusIfNeeded(element: Element): void; drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; fill(fillRule?: string): void; fillRect(x: number, y: number, w: number, h: number): void; @@ -7732,7 +8018,7 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { scale(x: number, y: number): void; setLineDash(segments: number[]): void; setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; - stroke(): void; + stroke(path?: Path2D): void; strokeRect(x: number, y: number, w: number, h: number): void; strokeText(text: string, x: number, y: number, maxWidth?: number): void; transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; @@ -7818,17 +8104,7 @@ interface CloseEvent extends Event { declare var CloseEvent: { prototype: CloseEvent; - new(): CloseEvent; -} - -interface CommandEvent extends Event { - readonly commandName: string; - readonly detail: string | null; -} - -declare var CommandEvent: { - prototype: CommandEvent; - new(type: string, eventInitDict?: CommandEventInit): CommandEvent; + new(typeArg: string, eventInitDict?: CloseEventInit): CloseEvent; } interface Comment extends CharacterData { @@ -7855,7 +8131,7 @@ interface Console { assert(test?: boolean, message?: string, ...optionalParams: any[]): void; clear(): void; count(countTitle?: string): void; - debug(message?: string, ...optionalParams: any[]): void; + debug(message?: any, ...optionalParams: any[]): void; dir(value?: any, ...optionalParams: any[]): void; dirxml(value: any): void; error(message?: any, ...optionalParams: any[]): void; @@ -8025,9 +8301,9 @@ declare var DOMException: { interface DOMImplementation { createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType): Document; - createDocumentType(qualifiedName: string, publicId: string | null, systemId: string | null): DocumentType; + createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; createHTMLDocument(title: string): Document; - hasFeature(feature: string | null, version: string | null): boolean; + hasFeature(): boolean; } declare var DOMImplementation: { @@ -8066,7 +8342,7 @@ declare var DOMStringList: { } interface DOMStringMap { - [name: string]: string; + [name: string]: string | undefined; } declare var DOMStringMap: { @@ -8092,7 +8368,7 @@ declare var DOMTokenList: { interface DataCue extends TextTrackCue { data: ArrayBuffer; - addEventListener(type: K, listener: (this: TextTrackCue, ev: TextTrackCueEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: DataCue, ev: TextTrackCueEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8122,6 +8398,7 @@ interface DataTransferItem { readonly type: string; getAsFile(): File | null; getAsString(_callback: FunctionStringCallback | null): void; + webkitGetAsEntry(): any; } declare var DataTransferItem: { @@ -8182,7 +8459,7 @@ interface DeviceLightEvent extends Event { declare var DeviceLightEvent: { prototype: DeviceLightEvent; - new(type: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; + new(typeArg: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; } interface DeviceMotionEvent extends Event { @@ -8195,7 +8472,7 @@ interface DeviceMotionEvent extends Event { declare var DeviceMotionEvent: { prototype: DeviceMotionEvent; - new(): DeviceMotionEvent; + new(typeArg: string, eventInitDict?: DeviceMotionEventInit): DeviceMotionEvent; } interface DeviceOrientationEvent extends Event { @@ -8208,7 +8485,7 @@ interface DeviceOrientationEvent extends Event { declare var DeviceOrientationEvent: { prototype: DeviceOrientationEvent; - new(): DeviceOrientationEvent; + new(typeArg: string, eventInitDict?: DeviceOrientationEventInit): DeviceOrientationEvent; } interface DeviceRotationRate { @@ -8290,7 +8567,7 @@ interface DocumentEventMap extends GlobalEventHandlersEventMap { "pointerlockerror": Event; "progress": ProgressEvent; "ratechange": Event; - "readystatechange": ProgressEvent; + "readystatechange": Event; "reset": Event; "scroll": UIEvent; "seeked": Event; @@ -8361,10 +8638,6 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven readonly compatMode: string; cookie: string; readonly currentScript: HTMLScriptElement | SVGScriptElement; - /** - * Gets the default character set from the current regional language settings. - */ - readonly defaultCharset: string; readonly defaultView: Window; /** * Sets or gets a value that indicates whether the document can be edited. @@ -8671,7 +8944,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Fires when the state of the object has changed. * @param ev The event */ - onreadystatechange: (this: Document, ev: ProgressEvent) => any; + onreadystatechange: (this: Document, ev: Event) => any; /** * Fires when the user resets a form. * @param ev The event. @@ -9039,8 +9312,8 @@ interface DocumentType extends Node, ChildNode { readonly internalSubset: string | null; readonly name: string; readonly notations: NamedNodeMap; - readonly publicId: string | null; - readonly systemId: string | null; + readonly publicId: string; + readonly systemId: string; } declare var DocumentType: { @@ -9063,7 +9336,7 @@ interface DynamicsCompressorNode extends AudioNode { readonly attack: AudioParam; readonly knee: AudioParam; readonly ratio: AudioParam; - readonly reduction: AudioParam; + readonly reduction: number; readonly release: AudioParam; readonly threshold: AudioParam; } @@ -9094,8 +9367,8 @@ declare var EXT_texture_filter_anisotropic: { } interface ElementEventMap extends GlobalEventHandlersEventMap { - "ariarequest": AriaRequestEvent; - "command": CommandEvent; + "ariarequest": Event; + "command": Event; "gotpointercapture": PointerEvent; "lostpointercapture": PointerEvent; "MSGestureChange": MSGestureEvent; @@ -9131,10 +9404,11 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec readonly clientTop: number; readonly clientWidth: number; id: string; + innerHTML: string; msContentZoomFactor: number; readonly msRegionOverflow: string; - onariarequest: (this: Element, ev: AriaRequestEvent) => any; - oncommand: (this: Element, ev: CommandEvent) => any; + onariarequest: (this: Element, ev: Event) => any; + oncommand: (this: Element, ev: Event) => any; ongotpointercapture: (this: Element, ev: PointerEvent) => any; onlostpointercapture: (this: Element, ev: PointerEvent) => any; onmsgesturechange: (this: Element, ev: MSGestureEvent) => any; @@ -9160,13 +9434,13 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec ontouchstart: (ev: TouchEvent) => any; onwebkitfullscreenchange: (this: Element, ev: Event) => any; onwebkitfullscreenerror: (this: Element, ev: Event) => any; + outerHTML: string; readonly prefix: string | null; readonly scrollHeight: number; scrollLeft: number; scrollTop: number; readonly scrollWidth: number; readonly tagName: string; - innerHTML: string; readonly assignedSlot: HTMLSlotElement | null; slot: string; readonly shadowRoot: ShadowRoot | null; @@ -9190,7 +9464,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec msSetPointerCapture(pointerId: number): void; msZoomTo(args: MsZoomToOptions): void; releasePointerCapture(pointerId: number): void; - removeAttribute(name?: string): void; + removeAttribute(qualifiedName: string): void; removeAttributeNS(namespaceURI: string, localName: string): void; removeAttributeNode(oldAttr: Attr): Attr; requestFullscreen(): void; @@ -9237,7 +9511,7 @@ interface ErrorEvent extends Event { declare var ErrorEvent: { prototype: ErrorEvent; - new(): ErrorEvent; + new(type: string, errorEventInitDict?: ErrorEventInit): ErrorEvent; } interface Event { @@ -9266,7 +9540,7 @@ interface Event { declare var Event: { prototype: Event; - new(type: string, eventInitDict?: EventInit): Event; + new(typeArg: string, eventInitDict?: EventInit): Event; readonly AT_TARGET: number; readonly BUBBLING_PHASE: number; readonly CAPTURING_PHASE: number; @@ -9283,6 +9557,21 @@ declare var EventTarget: { new(): EventTarget; } +interface ExtensionScriptApis { + extensionIdToShortId(extensionId: string): number; + fireExtensionApiTelemetry(functionName: string, isSucceeded: boolean, isSupported: boolean): void; + genericFunction(routerAddress: any, parameters?: string, callbackId?: number): void; + genericSynchronousFunction(functionId: number, parameters?: string): string; + getExtensionId(): string; + registerGenericFunctionCallbackHandler(callbackHandler: any): void; + registerGenericPersistentCallbackHandler(callbackHandler: any): void; +} + +declare var ExtensionScriptApis: { + prototype: ExtensionScriptApis; + new(): ExtensionScriptApis; +} + interface External { } @@ -9319,7 +9608,7 @@ interface FileReader extends EventTarget, MSBaseReader { readAsBinaryString(blob: Blob): void; readAsDataURL(blob: Blob): void; readAsText(blob: Blob, encoding?: string): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9338,6 +9627,20 @@ declare var FocusEvent: { new(typeArg: string, eventInitDict?: FocusEventInit): FocusEvent; } +interface FocusNavigationEvent extends Event { + readonly navigationReason: string; + readonly originHeight: number; + readonly originLeft: number; + readonly originTop: number; + readonly originWidth: number; + requestFocus(): void; +} + +declare var FocusNavigationEvent: { + prototype: FocusNavigationEvent; + new(type: string, eventInitDict?: FocusNavigationEventInit): FocusNavigationEvent; +} + interface FormData { append(name: any, value: any, blobName?: string): void; } @@ -9387,7 +9690,7 @@ interface GamepadEvent extends Event { declare var GamepadEvent: { prototype: GamepadEvent; - new(): GamepadEvent; + new(typeArg: string, eventInitDict?: GamepadEventInit): GamepadEvent; } interface Geolocation { @@ -9401,8 +9704,11 @@ declare var Geolocation: { new(): Geolocation; } -interface HTMLAllCollection extends HTMLCollection { - namedItem(name: string): Element; +interface HTMLAllCollection { + readonly length: number; + item(nameOrIndex?: string): HTMLCollection | Element | null; + namedItem(name: string): HTMLCollection | Element | null; + [index: number]: Element; } declare var HTMLAllCollection: { @@ -9490,7 +9796,7 @@ interface HTMLAnchorElement extends HTMLElement { * Returns a string representation of an object. */ toString(): string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAnchorElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9564,7 +9870,7 @@ interface HTMLAppletElement extends HTMLElement { useMap: string; vspace: number; width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAppletElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9632,7 +9938,7 @@ interface HTMLAreaElement extends HTMLElement { * Returns a string representation of an object. */ toString(): string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9641,15 +9947,7 @@ declare var HTMLAreaElement: { new(): HTMLAreaElement; } -interface HTMLAreasCollection extends HTMLCollection { - /** - * Adds an element to the areas, controlRange, or options collection. - */ - add(element: HTMLElement, before?: HTMLElement | number): void; - /** - * Removes an element from the collection. - */ - remove(index?: number): void; +interface HTMLAreasCollection extends HTMLCollectionBase { } declare var HTMLAreasCollection: { @@ -9658,7 +9956,7 @@ declare var HTMLAreasCollection: { } interface HTMLAudioElement extends HTMLMediaElement { - addEventListener(type: K, listener: (this: HTMLMediaElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAudioElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9672,7 +9970,7 @@ interface HTMLBRElement extends HTMLElement { * Sets or retrieves the side on which floating objects are not to be positioned when any IHTMLBlockElement is inserted into the document. */ clear: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9690,7 +9988,7 @@ interface HTMLBaseElement extends HTMLElement { * Sets or retrieves the window or frame at which to target content. */ target: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBaseElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9708,7 +10006,7 @@ interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty * Sets or retrieves the font size of the object. */ size: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBaseFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9734,6 +10032,7 @@ interface HTMLBodyElementEventMap extends HTMLElementEventMap { "pageshow": PageTransitionEvent; "popstate": PopStateEvent; "resize": UIEvent; + "scroll": UIEvent; "storage": StorageEvent; "unload": Event; } @@ -9761,6 +10060,7 @@ interface HTMLBodyElement extends HTMLElement { onpageshow: (this: HTMLBodyElement, ev: PageTransitionEvent) => any; onpopstate: (this: HTMLBodyElement, ev: PopStateEvent) => any; onresize: (this: HTMLBodyElement, ev: UIEvent) => any; + onscroll: (this: HTMLBodyElement, ev: UIEvent) => any; onstorage: (this: HTMLBodyElement, ev: StorageEvent) => any; onunload: (this: HTMLBodyElement, ev: Event) => any; text: any; @@ -9838,7 +10138,7 @@ interface HTMLButtonElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLButtonElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9873,7 +10173,7 @@ interface HTMLCanvasElement extends HTMLElement { */ toDataURL(type?: string, ...args: any[]): string; toBlob(callback: (result: Blob | null) => void, type?: string, ...arguments: any[]): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLCanvasElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9882,7 +10182,7 @@ declare var HTMLCanvasElement: { new(): HTMLCanvasElement; } -interface HTMLCollection { +interface HTMLCollectionBase { /** * Sets or retrieves the number of objects in a collection. */ @@ -9891,11 +10191,14 @@ interface HTMLCollection { * Retrieves an object from various collections. */ item(index: number): Element; + [index: number]: Element; +} + +interface HTMLCollection extends HTMLCollectionBase { /** * Retrieves a select object or an object from an options collection. */ - namedItem(name: string): Element; - [index: number]: Element; + namedItem(name: string): Element | null; } declare var HTMLCollection: { @@ -9905,7 +10208,7 @@ declare var HTMLCollection: { interface HTMLDListElement extends HTMLElement { compact: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9914,9 +10217,20 @@ declare var HTMLDListElement: { new(): HTMLDListElement; } +interface HTMLDataElement extends HTMLElement { + value: string; + addEventListener(type: K, listener: (this: HTMLDataElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDataElement: { + prototype: HTMLDataElement; + new(): HTMLDataElement; +} + interface HTMLDataListElement extends HTMLElement { options: HTMLCollectionOf; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDataListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9927,7 +10241,7 @@ declare var HTMLDataListElement: { interface HTMLDirectoryElement extends HTMLElement { compact: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDirectoryElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9945,7 +10259,7 @@ interface HTMLDivElement extends HTMLElement { * Sets or retrieves whether the browser automatically performs wordwrap. */ noWrap: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDivElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9955,7 +10269,7 @@ declare var HTMLDivElement: { } interface HTMLDocument extends Document { - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10043,7 +10357,6 @@ interface HTMLElement extends Element { draggable: boolean; hidden: boolean; hideFocus: boolean; - innerHTML: string; innerText: string; readonly isContentEditable: boolean; lang: string; @@ -10119,7 +10432,6 @@ interface HTMLElement extends Element { ontimeupdate: (this: HTMLElement, ev: Event) => any; onvolumechange: (this: HTMLElement, ev: Event) => any; onwaiting: (this: HTMLElement, ev: Event) => any; - outerHTML: string; outerText: string; spellcheck: boolean; readonly style: CSSStyleDeclaration; @@ -10130,7 +10442,6 @@ interface HTMLElement extends Element { dragDrop(): boolean; focus(): void; msGetInputContext(): MSInputMethodContext; - setActive(): void; addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10187,7 +10498,7 @@ interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { * Sets or retrieves the width of the object. */ width: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLEmbedElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10206,6 +10517,7 @@ interface HTMLFieldSetElement extends HTMLElement { * Retrieves a reference to the form that the object is embedded in. */ readonly form: HTMLFormElement; + name: string; /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. */ @@ -10227,7 +10539,7 @@ interface HTMLFieldSetElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFieldSetElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10241,7 +10553,7 @@ interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOM * Sets or retrieves the current typeface family. */ face: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10250,6 +10562,15 @@ declare var HTMLFontElement: { new(): HTMLFontElement; } +interface HTMLFormControlsCollection extends HTMLCollectionBase { + namedItem(name: string): HTMLCollection | Element | null; +} + +declare var HTMLFormControlsCollection: { + prototype: HTMLFormControlsCollection; + new(): HTMLFormControlsCollection; +} + interface HTMLFormElement extends HTMLElement { /** * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. @@ -10266,7 +10587,7 @@ interface HTMLFormElement extends HTMLElement { /** * Retrieves a collection, in source order, of all controls in a given form. */ - readonly elements: HTMLCollection; + readonly elements: HTMLFormControlsCollection; /** * Sets or retrieves the MIME encoding for the form. */ @@ -10317,7 +10638,7 @@ interface HTMLFormElement extends HTMLElement { * Fires when a FORM is about to be submitted. */ submit(): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFormElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; [name: string]: any; } @@ -10406,6 +10727,7 @@ declare var HTMLFrameElement: { } interface HTMLFrameSetElementEventMap extends HTMLElementEventMap { + "afterprint": Event; "beforeprint": Event; "beforeunload": BeforeUnloadEvent; "blur": FocusEvent; @@ -10419,7 +10741,9 @@ interface HTMLFrameSetElementEventMap extends HTMLElementEventMap { "orientationchange": Event; "pagehide": PageTransitionEvent; "pageshow": PageTransitionEvent; + "popstate": PopStateEvent; "resize": UIEvent; + "scroll": UIEvent; "storage": StorageEvent; "unload": Event; } @@ -10463,7 +10787,9 @@ interface HTMLFrameSetElement extends HTMLElement { onorientationchange: (this: HTMLFrameSetElement, ev: Event) => any; onpagehide: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; onpageshow: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; + onpopstate: (this: HTMLFrameSetElement, ev: PopStateEvent) => any; onresize: (this: HTMLFrameSetElement, ev: UIEvent) => any; + onscroll: (this: HTMLFrameSetElement, ev: UIEvent) => any; onstorage: (this: HTMLFrameSetElement, ev: StorageEvent) => any; onunload: (this: HTMLFrameSetElement, ev: Event) => any; /** @@ -10492,7 +10818,7 @@ interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2 * Sets or retrieves the width of the object. */ width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10503,7 +10829,7 @@ declare var HTMLHRElement: { interface HTMLHeadElement extends HTMLElement { profile: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHeadElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10517,7 +10843,7 @@ interface HTMLHeadingElement extends HTMLElement { * Sets or retrieves a value that indicates the table alignment. */ align: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHeadingElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10531,7 +10857,7 @@ interface HTMLHtmlElement extends HTMLElement { * Sets or retrieves the DTD version that governs the current document. */ version: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHtmlElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10550,6 +10876,7 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { */ align: string; allowFullscreen: boolean; + allowPaymentRequest: boolean; /** * Specifies the properties of a border drawn around an object. */ @@ -10645,7 +10972,7 @@ interface HTMLImageElement extends HTMLElement { * Retrieves whether the object is fully loaded. */ readonly complete: boolean; - crossOrigin: string; + crossOrigin: string | null; readonly currentSrc: string; /** * Sets or retrieves the height of the object. @@ -10710,14 +11037,13 @@ interface HTMLImageElement extends HTMLElement { readonly x: number; readonly y: number; msGetAsCastingSource(): any; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLImageElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLImageElement: { prototype: HTMLImageElement; new(): HTMLImageElement; - create(): HTMLImageElement; } interface HTMLInputElement extends HTMLElement { @@ -10923,7 +11249,7 @@ interface HTMLInputElement extends HTMLElement { * @param n Value to increment the value by. */ stepUp(n?: number): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLInputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10938,7 +11264,7 @@ interface HTMLLIElement extends HTMLElement { * Sets or retrieves the value of a list item. */ value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLIElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10956,7 +11282,7 @@ interface HTMLLabelElement extends HTMLElement { * Sets or retrieves the object to which the given label object is assigned. */ htmlFor: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLabelElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10974,7 +11300,7 @@ interface HTMLLegendElement extends HTMLElement { * Retrieves a reference to the form that the object is embedded in. */ readonly form: HTMLFormElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11019,7 +11345,7 @@ interface HTMLLinkElement extends HTMLElement, LinkStyle { type: string; import?: Document; integrity: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLinkElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11037,7 +11363,7 @@ interface HTMLMapElement extends HTMLElement { * Sets or retrieves the name of the object. */ name: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMapElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11100,7 +11426,7 @@ interface HTMLMediaElement extends HTMLElement { * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). */ controls: boolean; - crossOrigin: string; + crossOrigin: string | null; /** * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. */ @@ -11241,7 +11567,7 @@ interface HTMLMediaElement extends HTMLElement { * Loads and starts playback of a media resource. */ play(): void; - setMediaKeys(mediaKeys: MediaKeys | null): PromiseLike; + setMediaKeys(mediaKeys: MediaKeys | null): Promise; readonly HAVE_CURRENT_DATA: number; readonly HAVE_ENOUGH_DATA: number; readonly HAVE_FUTURE_DATA: number; @@ -11272,7 +11598,7 @@ declare var HTMLMediaElement: { interface HTMLMenuElement extends HTMLElement { compact: boolean; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMenuElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11306,7 +11632,7 @@ interface HTMLMetaElement extends HTMLElement { * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. */ url: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMetaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11322,7 +11648,7 @@ interface HTMLMeterElement extends HTMLElement { min: number; optimum: number; value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMeterElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11340,7 +11666,7 @@ interface HTMLModElement extends HTMLElement { * Sets or retrieves the date and time of a modification to the object. */ dateTime: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLModElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11356,7 +11682,7 @@ interface HTMLOListElement extends HTMLElement { */ start: number; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11434,10 +11760,6 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { * Sets or retrieves the name of the object. */ name: string; - /** - * Retrieves the contained object. - */ - readonly object: any; readonly readyState: number; /** * Sets or retrieves a message to be displayed while an object is loading. @@ -11477,7 +11799,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLObjectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11516,7 +11838,7 @@ interface HTMLOptGroupElement extends HTMLElement { * Sets or retrieves the value which is returned to the server when the form control is submitted. */ value: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOptGroupElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11555,14 +11877,13 @@ interface HTMLOptionElement extends HTMLElement { * Sets or retrieves the value which is returned to the server when the form control is submitted. */ value: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLOptionElement: { prototype: HTMLOptionElement; new(): HTMLOptionElement; - create(): HTMLOptionElement; } interface HTMLOptionsCollection extends HTMLCollectionOf { @@ -11577,13 +11898,35 @@ declare var HTMLOptionsCollection: { new(): HTMLOptionsCollection; } +interface HTMLOutputElement extends HTMLElement { + defaultValue: string; + readonly form: HTMLFormElement; + readonly htmlFor: DOMSettableTokenList; + name: string; + readonly type: string; + readonly validationMessage: string; + readonly validity: ValidityState; + value: string; + readonly willValidate: boolean; + checkValidity(): boolean; + reportValidity(): boolean; + setCustomValidity(error: string): void; + addEventListener(type: K, listener: (this: HTMLOutputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLOutputElement: { + prototype: HTMLOutputElement; + new(): HTMLOutputElement; +} + interface HTMLParagraphElement extends HTMLElement { /** * Sets or retrieves how the object is aligned with adjacent text. */ align: string; clear: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLParagraphElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11609,7 +11952,7 @@ interface HTMLParamElement extends HTMLElement { * Sets or retrieves the data type of the value attribute. */ valueType: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLParamElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11619,7 +11962,7 @@ declare var HTMLParamElement: { } interface HTMLPictureElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLPictureElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11633,7 +11976,7 @@ interface HTMLPreElement extends HTMLElement { * Sets or gets a value that you can use to implement your own width functionality for the object. */ width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLPreElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11659,7 +12002,7 @@ interface HTMLProgressElement extends HTMLElement { * Sets or gets the current value of a progress element. The value must be a non-negative number between 0 and the max value. */ value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLProgressElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11673,7 +12016,7 @@ interface HTMLQuoteElement extends HTMLElement { * Sets or retrieves reference information about the object. */ cite: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLQuoteElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11688,6 +12031,7 @@ interface HTMLScriptElement extends HTMLElement { * Sets or retrieves the character set used to encode the object. */ charset: string; + crossOrigin: string | null; /** * Sets or retrieves the status of the script. */ @@ -11713,7 +12057,7 @@ interface HTMLScriptElement extends HTMLElement { */ type: string; integrity: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLScriptElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11809,7 +12153,7 @@ interface HTMLSelectElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSelectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; [name: string]: any; } @@ -11835,7 +12179,7 @@ interface HTMLSourceElement extends HTMLElement { * Gets or sets the MIME type of a media resource. */ type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSourceElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11845,7 +12189,7 @@ declare var HTMLSourceElement: { } interface HTMLSpanElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSpanElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11864,7 +12208,7 @@ interface HTMLStyleElement extends HTMLElement, LinkStyle { * Retrieves the CSS language in which the style sheet is written. */ type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLStyleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11882,7 +12226,7 @@ interface HTMLTableCaptionElement extends HTMLElement { * Sets or retrieves whether the caption appears at the top or bottom of the table. */ vAlign: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableCaptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11937,7 +12281,7 @@ interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment { * Sets or retrieves the width of the object. */ width: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11959,7 +12303,7 @@ interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { * Sets or retrieves the width of the object. */ width: any; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableColElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11969,6 +12313,8 @@ declare var HTMLTableColElement: { } interface HTMLTableDataCellElement extends HTMLTableCellElement { + addEventListener(type: K, listener: (this: HTMLTableDataCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLTableDataCellElement: { @@ -12080,7 +12426,7 @@ interface HTMLTableElement extends HTMLElement { * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. */ insertRow(index?: number): HTMLTableRowElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12094,6 +12440,8 @@ interface HTMLTableHeaderCellElement extends HTMLTableCellElement { * Sets or retrieves the group of cells in a table to which the object's information applies. */ scope: string; + addEventListener(type: K, listener: (this: HTMLTableHeaderCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLTableHeaderCellElement: { @@ -12133,7 +12481,7 @@ interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment { * @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. */ insertCell(index?: number): HTMLTableDataCellElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableRowElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12161,7 +12509,7 @@ interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment { * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. */ insertRow(index?: number): HTMLTableRowElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableSectionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12172,7 +12520,7 @@ declare var HTMLTableSectionElement: { interface HTMLTemplateElement extends HTMLElement { readonly content: DocumentFragment; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTemplateElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12279,7 +12627,7 @@ interface HTMLTextAreaElement extends HTMLElement { * @param end The offset into the text field for the end of the selection. */ setSelectionRange(start: number, end: number): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTextAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12288,12 +12636,23 @@ declare var HTMLTextAreaElement: { new(): HTMLTextAreaElement; } +interface HTMLTimeElement extends HTMLElement { + dateTime: string; + addEventListener(type: K, listener: (this: HTMLTimeElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTimeElement: { + prototype: HTMLTimeElement; + new(): HTMLTimeElement; +} + interface HTMLTitleElement extends HTMLElement { /** * Retrieves or sets the text of the object as a string. */ text: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTitleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12314,7 +12673,7 @@ interface HTMLTrackElement extends HTMLElement { readonly LOADED: number; readonly LOADING: number; readonly NONE: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTrackElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12330,7 +12689,7 @@ declare var HTMLTrackElement: { interface HTMLUListElement extends HTMLElement { compact: boolean; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLUListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12340,7 +12699,7 @@ declare var HTMLUListElement: { } interface HTMLUnknownElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLUnknownElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12411,7 +12770,21 @@ interface HashChangeEvent extends Event { declare var HashChangeEvent: { prototype: HashChangeEvent; - new(type: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; + new(typeArg: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; +} + +interface Headers { + append(name: string, value: string): void; + delete(name: string): void; + forEach(callback: ForEachCallback): void; + get(name: string): string | null; + has(name: string): boolean; + set(name: string, value: string): void; +} + +declare var Headers: { + prototype: Headers; + new(init?: any): Headers; } interface History { @@ -12465,14 +12838,14 @@ declare var IDBCursorWithValue: { interface IDBDatabaseEventMap { "abort": Event; - "error": ErrorEvent; + "error": Event; } interface IDBDatabase extends EventTarget { readonly name: string; readonly objectStoreNames: DOMStringList; onabort: (this: IDBDatabase, ev: Event) => any; - onerror: (this: IDBDatabase, ev: ErrorEvent) => any; + onerror: (this: IDBDatabase, ev: Event) => any; version: number; onversionchange: (ev: IDBVersionChangeEvent) => any; close(): void; @@ -12575,13 +12948,13 @@ declare var IDBOpenDBRequest: { } interface IDBRequestEventMap { - "error": ErrorEvent; + "error": Event; "success": Event; } interface IDBRequest extends EventTarget { readonly error: DOMError; - onerror: (this: IDBRequest, ev: ErrorEvent) => any; + onerror: (this: IDBRequest, ev: Event) => any; onsuccess: (this: IDBRequest, ev: Event) => any; readonly readyState: string; readonly result: any; @@ -12599,7 +12972,7 @@ declare var IDBRequest: { interface IDBTransactionEventMap { "abort": Event; "complete": Event; - "error": ErrorEvent; + "error": Event; } interface IDBTransaction extends EventTarget { @@ -12608,7 +12981,7 @@ interface IDBTransaction extends EventTarget { readonly mode: string; onabort: (this: IDBTransaction, ev: Event) => any; oncomplete: (this: IDBTransaction, ev: Event) => any; - onerror: (this: IDBTransaction, ev: ErrorEvent) => any; + onerror: (this: IDBTransaction, ev: Event) => any; abort(): void; objectStore(name: string): IDBObjectStore; readonly READ_ONLY: string; @@ -12636,6 +13009,15 @@ declare var IDBVersionChangeEvent: { new(): IDBVersionChangeEvent; } +interface IIRFilterNode extends AudioNode { + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; +} + +declare var IIRFilterNode: { + prototype: IIRFilterNode; + new(): IIRFilterNode; +} + interface ImageData { data: Uint8ClampedArray; readonly height: number; @@ -12648,6 +13030,35 @@ declare var ImageData: { new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +interface IntersectionObserver { + readonly root: Element | null; + readonly rootMargin: string; + readonly thresholds: number[]; + disconnect(): void; + observe(target: Element): void; + takeRecords(): IntersectionObserverEntry[]; + unobserve(target: Element): void; +} + +declare var IntersectionObserver: { + prototype: IntersectionObserver; + new(callback: IntersectionObserverCallback, options?: IntersectionObserverInit): IntersectionObserver; +} + +interface IntersectionObserverEntry { + readonly boundingClientRect: ClientRect; + readonly intersectionRatio: number; + readonly intersectionRect: ClientRect; + readonly rootBounds: ClientRect; + readonly target: Element; + readonly time: number; +} + +declare var IntersectionObserverEntry: { + prototype: IntersectionObserverEntry; + new(intersectionObserverEntryInit: IntersectionObserverEntryInit): IntersectionObserverEntry; +} + interface KeyboardEvent extends UIEvent { readonly altKey: boolean; readonly char: string | null; @@ -12734,7 +13145,7 @@ interface MSApp { execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; getCurrentPriority(): string; - getHtmlPrintDocumentSourceAsync(htmlDoc: any): PromiseLike; + getHtmlPrintDocumentSourceAsync(htmlDoc: any): Promise; getViewId(view: any): any; isTaskScheduledAtPriorityOrHigher(priority: string): boolean; pageHandlesAllApplicationActivations(enabled: boolean): void; @@ -12749,13 +13160,13 @@ declare var MSApp: MSApp; interface MSAppAsyncOperationEventMap { "complete": Event; - "error": ErrorEvent; + "error": Event; } interface MSAppAsyncOperation extends EventTarget { readonly error: DOMError; oncomplete: (this: MSAppAsyncOperation, ev: Event) => any; - onerror: (this: MSAppAsyncOperation, ev: ErrorEvent) => any; + onerror: (this: MSAppAsyncOperation, ev: Event) => any; readonly readyState: number; readonly result: any; start(): void; @@ -12795,8 +13206,8 @@ declare var MSBlobBuilder: { } interface MSCredentials { - getAssertion(challenge: string, filter?: MSCredentialFilter, params?: MSSignatureParameters): PromiseLike; - makeCredential(accountInfo: MSAccountInfo, params: MSCredentialParameters[], challenge?: string): PromiseLike; + getAssertion(challenge: string, filter?: MSCredentialFilter, params?: MSSignatureParameters): Promise; + makeCredential(accountInfo: MSAccountInfo, params: MSCredentialParameters[], challenge?: string): Promise; } declare var MSCredentials: { @@ -12912,12 +13323,13 @@ interface MSHTMLWebViewElement extends HTMLElement { goForward(): void; invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; navigate(uri: string): void; + navigateFocus(navigationReason: string, origin: FocusNavigationOrigin): void; navigateToLocalStreamUri(source: string, streamResolver: any): void; navigateToString(contents: string): void; navigateWithHttpRequestMessage(requestMessage: any): void; refresh(): void; stop(): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: MSHTMLWebViewElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13109,7 +13521,7 @@ interface MSStreamReader extends EventTarget, MSBaseReader { readAsBlob(stream: MSStream, size?: number): void; readAsDataURL(stream: MSStream, size?: number): void; readAsText(stream: MSStream, encoding?: string, size?: number): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: MSStreamReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13120,13 +13532,13 @@ declare var MSStreamReader: { interface MSWebViewAsyncOperationEventMap { "complete": Event; - "error": ErrorEvent; + "error": Event; } interface MSWebViewAsyncOperation extends EventTarget { readonly error: DOMError; oncomplete: (this: MSWebViewAsyncOperation, ev: Event) => any; - onerror: (this: MSWebViewAsyncOperation, ev: ErrorEvent) => any; + onerror: (this: MSWebViewAsyncOperation, ev: Event) => any; readonly readyState: number; readonly result: any; readonly target: MSHTMLWebViewElement; @@ -13183,7 +13595,7 @@ interface MediaDevices extends EventTarget { ondevicechange: (this: MediaDevices, ev: Event) => any; enumerateDevices(): any; getSupportedConstraints(): MediaTrackSupportedConstraints; - getUserMedia(constraints: MediaStreamConstraints): PromiseLike; + getUserMedia(constraints: MediaStreamConstraints): Promise; addEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13242,15 +13654,15 @@ declare var MediaKeyMessageEvent: { } interface MediaKeySession extends EventTarget { - readonly closed: PromiseLike; + readonly closed: Promise; readonly expiration: number; readonly keyStatuses: MediaKeyStatusMap; readonly sessionId: string; - close(): PromiseLike; - generateRequest(initDataType: string, initData: any): PromiseLike; - load(sessionId: string): PromiseLike; - remove(): PromiseLike; - update(response: any): PromiseLike; + close(): Promise; + generateRequest(initDataType: string, initData: any): Promise; + load(sessionId: string): Promise; + remove(): Promise; + update(response: any): Promise; } declare var MediaKeySession: { @@ -13272,7 +13684,7 @@ declare var MediaKeyStatusMap: { interface MediaKeySystemAccess { readonly keySystem: string; - createMediaKeys(): PromiseLike; + createMediaKeys(): Promise; getConfiguration(): MediaKeySystemConfiguration; } @@ -13283,7 +13695,7 @@ declare var MediaKeySystemAccess: { interface MediaKeys { createSession(sessionType?: string): MediaKeySession; - setServerCertificate(serverCertificate: any): PromiseLike; + setServerCertificate(serverCertificate: any): Promise; } declare var MediaKeys: { @@ -13336,18 +13748,18 @@ declare var MediaSource: { interface MediaStreamEventMap { "active": Event; - "addtrack": TrackEvent; + "addtrack": MediaStreamTrackEvent; "inactive": Event; - "removetrack": TrackEvent; + "removetrack": MediaStreamTrackEvent; } interface MediaStream extends EventTarget { readonly active: boolean; readonly id: string; onactive: (this: MediaStream, ev: Event) => any; - onaddtrack: (this: MediaStream, ev: TrackEvent) => any; + onaddtrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; oninactive: (this: MediaStream, ev: Event) => any; - onremovetrack: (this: MediaStream, ev: TrackEvent) => any; + onremovetrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; addTrack(track: MediaStreamTrack): void; clone(): MediaStream; getAudioTracks(): MediaStreamTrack[]; @@ -13390,7 +13802,16 @@ interface MediaStreamErrorEvent extends Event { declare var MediaStreamErrorEvent: { prototype: MediaStreamErrorEvent; - new(type: string, eventInitDict?: MediaStreamErrorEventInit): MediaStreamErrorEvent; + new(typeArg: string, eventInitDict?: MediaStreamErrorEventInit): MediaStreamErrorEvent; +} + +interface MediaStreamEvent extends Event { + readonly stream: MediaStream | null; +} + +declare var MediaStreamEvent: { + prototype: MediaStreamEvent; + new(type: string, eventInitDict: MediaStreamEventInit): MediaStreamEvent; } interface MediaStreamTrackEventMap { @@ -13413,7 +13834,7 @@ interface MediaStreamTrack extends EventTarget { readonly readonly: boolean; readonly readyState: string; readonly remote: boolean; - applyConstraints(constraints: MediaTrackConstraints): PromiseLike; + applyConstraints(constraints: MediaTrackConstraints): Promise; clone(): MediaStreamTrack; getCapabilities(): MediaTrackCapabilities; getConstraints(): MediaTrackConstraints; @@ -13434,7 +13855,7 @@ interface MediaStreamTrackEvent extends Event { declare var MediaStreamTrackEvent: { prototype: MediaStreamTrackEvent; - new(type: string, eventInitDict?: MediaStreamTrackEventInit): MediaStreamTrackEvent; + new(typeArg: string, eventInitDict?: MediaStreamTrackEventInit): MediaStreamTrackEvent; } interface MessageChannel { @@ -13467,7 +13888,7 @@ interface MessagePortEventMap { interface MessagePort extends EventTarget { onmessage: (this: MessagePort, ev: MessageEvent) => any; close(): void; - postMessage(message?: any, ports?: any): void; + postMessage(message?: any, transfer?: any[]): void; start(): void; addEventListener(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -13629,9 +14050,10 @@ declare var NavigationEventWithReferrer: { new(): NavigationEventWithReferrer; } -interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorUserMedia { - readonly appCodeName: string; +interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorUserMedia { + readonly authentication: WebAuthentication; readonly cookieEnabled: boolean; + gamepadInputEmulation: string; readonly language: string; readonly maxTouchPoints: number; readonly mimeTypes: MimeTypeArray; @@ -13640,12 +14062,13 @@ interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorConte readonly msPointerEnabled: boolean; readonly plugins: PluginArray; readonly pointerEnabled: boolean; + readonly serviceWorker: ServiceWorkerContainer; readonly webdriver: boolean; readonly hardwareConcurrency: number; getGamepads(): Gamepad[]; javaEnabled(): boolean; msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; - requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): PromiseLike; + requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): Promise; vibrate(pattern: number | number[]): boolean; } @@ -13671,7 +14094,7 @@ interface Node extends EventTarget { readonly parentNode: Node | null; readonly previousSibling: Node | null; textContent: string | null; - appendChild(newChild: Node): Node; + appendChild(newChild: T): T; cloneNode(deep?: boolean): Node; compareDocumentPosition(other: Node): number; contains(child: Node): boolean; @@ -13778,6 +14201,36 @@ declare var NodeList: { new(): NodeList; } +interface NotificationEventMap { + "click": Event; + "close": Event; + "error": Event; + "show": Event; +} + +interface Notification extends EventTarget { + readonly body: string; + readonly dir: string; + readonly icon: string; + readonly lang: string; + onclick: (this: Notification, ev: Event) => any; + onclose: (this: Notification, ev: Event) => any; + onerror: (this: Notification, ev: Event) => any; + onshow: (this: Notification, ev: Event) => any; + readonly permission: string; + readonly tag: string; + readonly title: string; + close(): void; + addEventListener(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Notification: { + prototype: Notification; + new(title: string, options?: NotificationOptions): Notification; + requestPermission(callback?: NotificationPermissionCallback): Promise; +} + interface OES_element_index_uint { } @@ -13812,6 +14265,24 @@ declare var OES_texture_float_linear: { new(): OES_texture_float_linear; } +interface OES_texture_half_float { + readonly HALF_FLOAT_OES: number; +} + +declare var OES_texture_half_float: { + prototype: OES_texture_half_float; + new(): OES_texture_half_float; + readonly HALF_FLOAT_OES: number; +} + +interface OES_texture_half_float_linear { +} + +declare var OES_texture_half_float_linear: { + prototype: OES_texture_half_float_linear; + new(): OES_texture_half_float_linear; +} + interface OfflineAudioCompletionEvent extends Event { readonly renderedBuffer: AudioBuffer; } @@ -13821,13 +14292,15 @@ declare var OfflineAudioCompletionEvent: { new(): OfflineAudioCompletionEvent; } -interface OfflineAudioContextEventMap { - "complete": Event; +interface OfflineAudioContextEventMap extends AudioContextEventMap { + "complete": OfflineAudioCompletionEvent; } -interface OfflineAudioContext extends AudioContext { - oncomplete: (this: OfflineAudioContext, ev: Event) => any; - startRendering(): PromiseLike; +interface OfflineAudioContext extends AudioContextBase { + readonly length: number; + oncomplete: (this: OfflineAudioContext, ev: OfflineAudioCompletionEvent) => any; + startRendering(): Promise; + suspend(suspendTime: number): Promise; addEventListener(type: K, listener: (this: OfflineAudioContext, ev: OfflineAudioContextEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13903,6 +14376,82 @@ declare var PannerNode: { new(): PannerNode; } +interface Path2D extends Object, CanvasPathMethods { +} + +declare var Path2D: { + prototype: Path2D; + new(path?: Path2D): Path2D; +} + +interface PaymentAddress { + readonly addressLine: string[]; + readonly city: string; + readonly country: string; + readonly dependentLocality: string; + readonly languageCode: string; + readonly organization: string; + readonly phone: string; + readonly postalCode: string; + readonly recipient: string; + readonly region: string; + readonly sortingCode: string; + toJSON(): any; +} + +declare var PaymentAddress: { + prototype: PaymentAddress; + new(): PaymentAddress; +} + +interface PaymentRequestEventMap { + "shippingaddresschange": Event; + "shippingoptionchange": Event; +} + +interface PaymentRequest extends EventTarget { + onshippingaddresschange: (this: PaymentRequest, ev: Event) => any; + onshippingoptionchange: (this: PaymentRequest, ev: Event) => any; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + readonly shippingType: string | null; + abort(): Promise; + show(): Promise; + addEventListener(type: K, listener: (this: PaymentRequest, ev: PaymentRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var PaymentRequest: { + prototype: PaymentRequest; + new(methodData: PaymentMethodData[], details: PaymentDetails, options?: PaymentOptions): PaymentRequest; +} + +interface PaymentRequestUpdateEvent extends Event { + updateWith(d: Promise): void; +} + +declare var PaymentRequestUpdateEvent: { + prototype: PaymentRequestUpdateEvent; + new(type: string, eventInitDict?: PaymentRequestUpdateEventInit): PaymentRequestUpdateEvent; +} + +interface PaymentResponse { + readonly details: any; + readonly methodName: string; + readonly payerEmail: string | null; + readonly payerName: string | null; + readonly payerPhone: string | null; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + complete(result?: string): Promise; + toJSON(): any; +} + +declare var PaymentResponse: { + prototype: PaymentResponse; + new(): PaymentResponse; +} + interface PerfWidgetExternal { readonly activeNetworkRequestCount: number; readonly averageFrameTime: number; @@ -14168,7 +14717,7 @@ interface PopStateEvent extends Event { declare var PopStateEvent: { prototype: PopStateEvent; - new(): PopStateEvent; + new(typeArg: string, eventInitDict?: PopStateEventInit): PopStateEvent; } interface Position { @@ -14219,23 +14768,57 @@ declare var ProgressEvent: { new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } +interface PushManager { + getSubscription(): Promise; + permissionState(options?: PushSubscriptionOptionsInit): Promise; + subscribe(options?: PushSubscriptionOptionsInit): Promise; +} + +declare var PushManager: { + prototype: PushManager; + new(): PushManager; +} + +interface PushSubscription { + readonly endpoint: USVString; + readonly options: PushSubscriptionOptions; + getKey(name: string): ArrayBuffer | null; + toJSON(): any; + unsubscribe(): Promise; +} + +declare var PushSubscription: { + prototype: PushSubscription; + new(): PushSubscription; +} + +interface PushSubscriptionOptions { + readonly applicationServerKey: ArrayBuffer | null; + readonly userVisibleOnly: boolean; +} + +declare var PushSubscriptionOptions: { + prototype: PushSubscriptionOptions; + new(): PushSubscriptionOptions; +} + interface RTCDTMFToneChangeEvent extends Event { readonly tone: string; } declare var RTCDTMFToneChangeEvent: { prototype: RTCDTMFToneChangeEvent; - new(type: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; + new(typeArg: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; } interface RTCDtlsTransportEventMap { "dtlsstatechange": RTCDtlsTransportStateChangedEvent; - "error": ErrorEvent; + "error": Event; } interface RTCDtlsTransport extends RTCStatsProvider { ondtlsstatechange: ((this: RTCDtlsTransport, ev: RTCDtlsTransportStateChangedEvent) => any) | null; - onerror: ((this: RTCDtlsTransport, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCDtlsTransport, ev: Event) => any) | null; readonly state: string; readonly transport: RTCIceTransport; getLocalParameters(): RTCDtlsParameters; @@ -14282,6 +14865,18 @@ declare var RTCDtmfSender: { new(sender: RTCRtpSender): RTCDtmfSender; } +interface RTCIceCandidate { + candidate: string | null; + sdpMLineIndex: number | null; + sdpMid: string | null; + toJSON(): any; +} + +declare var RTCIceCandidate: { + prototype: RTCIceCandidate; + new(candidateInitDict?: RTCIceCandidateInit): RTCIceCandidate; +} + interface RTCIceCandidatePairChangedEvent extends Event { readonly pair: RTCIceCandidatePair; } @@ -14292,16 +14887,16 @@ declare var RTCIceCandidatePairChangedEvent: { } interface RTCIceGathererEventMap { - "error": ErrorEvent; + "error": Event; "localcandidate": RTCIceGathererEvent; } interface RTCIceGatherer extends RTCStatsProvider { readonly component: string; - onerror: ((this: RTCIceGatherer, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCIceGatherer, ev: Event) => any) | null; onlocalcandidate: ((this: RTCIceGatherer, ev: RTCIceGathererEvent) => any) | null; createAssociatedGatherer(): RTCIceGatherer; - getLocalCandidates(): RTCIceCandidate[]; + getLocalCandidates(): RTCIceCandidateDictionary[]; getLocalParameters(): RTCIceParameters; addEventListener(type: K, listener: (this: RTCIceGatherer, ev: RTCIceGathererEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -14313,7 +14908,7 @@ declare var RTCIceGatherer: { } interface RTCIceGathererEvent extends Event { - readonly candidate: RTCIceCandidate | RTCIceCandidateComplete; + readonly candidate: RTCIceCandidateDictionary | RTCIceCandidateComplete; } declare var RTCIceGathererEvent: { @@ -14333,12 +14928,12 @@ interface RTCIceTransport extends RTCStatsProvider { onicestatechange: ((this: RTCIceTransport, ev: RTCIceTransportStateChangedEvent) => any) | null; readonly role: string; readonly state: string; - addRemoteCandidate(remoteCandidate: RTCIceCandidate | RTCIceCandidateComplete): void; + addRemoteCandidate(remoteCandidate: RTCIceCandidateDictionary | RTCIceCandidateComplete): void; createAssociatedTransport(): RTCIceTransport; getNominatedCandidatePair(): RTCIceCandidatePair | null; - getRemoteCandidates(): RTCIceCandidate[]; + getRemoteCandidates(): RTCIceCandidateDictionary[]; getRemoteParameters(): RTCIceParameters | null; - setRemoteCandidates(remoteCandidates: RTCIceCandidate[]): void; + setRemoteCandidates(remoteCandidates: RTCIceCandidateDictionary[]): void; start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: string): void; stop(): void; addEventListener(type: K, listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any, useCapture?: boolean): void; @@ -14359,12 +14954,67 @@ declare var RTCIceTransportStateChangedEvent: { new(): RTCIceTransportStateChangedEvent; } +interface RTCPeerConnectionEventMap { + "addstream": MediaStreamEvent; + "icecandidate": RTCPeerConnectionIceEvent; + "iceconnectionstatechange": Event; + "icegatheringstatechange": Event; + "negotiationneeded": Event; + "removestream": MediaStreamEvent; + "signalingstatechange": Event; +} + +interface RTCPeerConnection extends EventTarget { + readonly canTrickleIceCandidates: boolean | null; + readonly iceConnectionState: string; + readonly iceGatheringState: string; + readonly localDescription: RTCSessionDescription | null; + onaddstream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onicecandidate: (this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any; + oniceconnectionstatechange: (this: RTCPeerConnection, ev: Event) => any; + onicegatheringstatechange: (this: RTCPeerConnection, ev: Event) => any; + onnegotiationneeded: (this: RTCPeerConnection, ev: Event) => any; + onremovestream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onsignalingstatechange: (this: RTCPeerConnection, ev: Event) => any; + readonly remoteDescription: RTCSessionDescription | null; + readonly signalingState: string; + addIceCandidate(candidate: RTCIceCandidate, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addStream(stream: MediaStream): void; + close(): void; + createAnswer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + createOffer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback, options?: RTCOfferOptions): Promise; + getConfiguration(): RTCConfiguration; + getLocalStreams(): MediaStream[]; + getRemoteStreams(): MediaStream[]; + getStats(selector: MediaStreamTrack | null, successCallback?: RTCStatsCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + getStreamById(streamId: string): MediaStream | null; + removeStream(stream: MediaStream): void; + setLocalDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + setRemoteDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addEventListener(type: K, listener: (this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCPeerConnection: { + prototype: RTCPeerConnection; + new(configuration: RTCConfiguration): RTCPeerConnection; +} + +interface RTCPeerConnectionIceEvent extends Event { + readonly candidate: RTCIceCandidate; +} + +declare var RTCPeerConnectionIceEvent: { + prototype: RTCPeerConnectionIceEvent; + new(type: string, eventInitDict: RTCPeerConnectionIceEventInit): RTCPeerConnectionIceEvent; +} + interface RTCRtpReceiverEventMap { - "error": ErrorEvent; + "error": Event; } interface RTCRtpReceiver extends RTCStatsProvider { - onerror: ((this: RTCRtpReceiver, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCRtpReceiver, ev: Event) => any) | null; readonly rtcpTransport: RTCDtlsTransport; readonly track: MediaStreamTrack | null; readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; @@ -14384,12 +15034,12 @@ declare var RTCRtpReceiver: { } interface RTCRtpSenderEventMap { - "error": ErrorEvent; + "error": Event; "ssrcconflict": RTCSsrcConflictEvent; } interface RTCRtpSender extends RTCStatsProvider { - onerror: ((this: RTCRtpSender, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCRtpSender, ev: Event) => any) | null; onssrcconflict: ((this: RTCRtpSender, ev: RTCSsrcConflictEvent) => any) | null; readonly rtcpTransport: RTCDtlsTransport; readonly track: MediaStreamTrack; @@ -14408,12 +15058,23 @@ declare var RTCRtpSender: { getCapabilities(kind?: string): RTCRtpCapabilities; } +interface RTCSessionDescription { + sdp: string | null; + type: string | null; + toJSON(): any; +} + +declare var RTCSessionDescription: { + prototype: RTCSessionDescription; + new(descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription; +} + interface RTCSrtpSdesTransportEventMap { - "error": ErrorEvent; + "error": Event; } interface RTCSrtpSdesTransport extends EventTarget { - onerror: ((this: RTCSrtpSdesTransport, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCSrtpSdesTransport, ev: Event) => any) | null; readonly transport: RTCIceTransport; addEventListener(type: K, listener: (this: RTCSrtpSdesTransport, ev: RTCSrtpSdesTransportEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -14435,8 +15096,8 @@ declare var RTCSsrcConflictEvent: { } interface RTCStatsProvider extends EventTarget { - getStats(): PromiseLike; - msGetStats(): PromiseLike; + getStats(): Promise; + msGetStats(): Promise; } declare var RTCStatsProvider: { @@ -14488,9 +15149,69 @@ declare var Range: { readonly START_TO_START: number; } -interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface ReadableStream { + readonly locked: boolean; + cancel(): Promise; + getReader(): ReadableStreamReader; +} + +declare var ReadableStream: { + prototype: ReadableStream; + new(): ReadableStream; +} + +interface ReadableStreamReader { + cancel(): Promise; + read(): Promise; + releaseLock(): void; +} + +declare var ReadableStreamReader: { + prototype: ReadableStreamReader; + new(): ReadableStreamReader; +} + +interface Request extends Object, Body { + readonly cache: string; + readonly credentials: string; + readonly destination: string; + readonly headers: Headers; + readonly integrity: string; + readonly keepalive: boolean; + readonly method: string; + readonly mode: string; + readonly redirect: string; + readonly referrer: string; + readonly referrerPolicy: string; + readonly type: string; + readonly url: string; + clone(): Request; +} + +declare var Request: { + prototype: Request; + new(input: Request | string, init?: RequestInit): Request; +} + +interface Response extends Object, Body { + readonly body: ReadableStream | null; + readonly headers: Headers; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly type: string; + readonly url: string; + clone(): Response; +} + +declare var Response: { + prototype: Response; + new(body?: any, init?: ResponseInit): Response; +} + +interface SVGAElement extends SVGGraphicsElement, SVGURIReference { readonly target: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14643,11 +15364,11 @@ declare var SVGAnimatedTransformList: { new(): SVGAnimatedTransformList; } -interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGCircleElement extends SVGGraphicsElement { readonly cx: SVGAnimatedLength; readonly cy: SVGAnimatedLength; readonly r: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGCircleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14656,9 +15377,9 @@ declare var SVGCircleElement: { new(): SVGCircleElement; } -interface SVGClipPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { +interface SVGClipPathElement extends SVGGraphicsElement, SVGUnitTypes { readonly clipPathUnits: SVGAnimatedEnumeration; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGClipPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14681,7 +15402,7 @@ interface SVGComponentTransferFunctionElement extends SVGElement { readonly SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; readonly SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGComponentTransferFunctionElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14696,8 +15417,8 @@ declare var SVGComponentTransferFunctionElement: { readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; } -interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGDefsElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGDefsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14706,8 +15427,8 @@ declare var SVGDefsElement: { new(): SVGDefsElement; } -interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGDescElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGDescElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14730,6 +15451,7 @@ interface SVGElementEventMap extends ElementEventMap { } interface SVGElement extends Element { + className: any; onclick: (this: SVGElement, ev: MouseEvent) => any; ondblclick: (this: SVGElement, ev: MouseEvent) => any; onfocusin: (this: SVGElement, ev: FocusEvent) => any; @@ -14741,9 +15463,9 @@ interface SVGElement extends Element { onmouseover: (this: SVGElement, ev: MouseEvent) => any; onmouseup: (this: SVGElement, ev: MouseEvent) => any; readonly ownerSVGElement: SVGSVGElement; + readonly style: CSSStyleDeclaration; readonly viewportElement: SVGElement; xmlbase: string; - className: any; addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14779,12 +15501,12 @@ declare var SVGElementInstanceList: { new(): SVGElementInstanceList; } -interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGEllipseElement extends SVGGraphicsElement { readonly cx: SVGAnimatedLength; readonly cy: SVGAnimatedLength; readonly rx: SVGAnimatedLength; readonly ry: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGEllipseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14814,7 +15536,7 @@ interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttrib readonly SVG_FEBLEND_MODE_SCREEN: number; readonly SVG_FEBLEND_MODE_SOFT_LIGHT: number; readonly SVG_FEBLEND_MODE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEBlendElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14849,7 +15571,7 @@ interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandard readonly SVG_FECOLORMATRIX_TYPE_MATRIX: number; readonly SVG_FECOLORMATRIX_TYPE_SATURATE: number; readonly SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEColorMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14865,7 +15587,7 @@ declare var SVGFEColorMatrixElement: { interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEComponentTransferElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14889,7 +15611,7 @@ interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAt readonly SVG_FECOMPOSITE_OPERATOR_OVER: number; readonly SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; readonly SVG_FECOMPOSITE_OPERATOR_XOR: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFECompositeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14922,7 +15644,7 @@ interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStand readonly SVG_EDGEMODE_NONE: number; readonly SVG_EDGEMODE_UNKNOWN: number; readonly SVG_EDGEMODE_WRAP: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEConvolveMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14941,7 +15663,7 @@ interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStan readonly kernelUnitLengthX: SVGAnimatedNumber; readonly kernelUnitLengthY: SVGAnimatedNumber; readonly surfaceScale: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDiffuseLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14961,7 +15683,7 @@ interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStan readonly SVG_CHANNEL_G: number; readonly SVG_CHANNEL_R: number; readonly SVG_CHANNEL_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDisplacementMapElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14978,7 +15700,7 @@ declare var SVGFEDisplacementMapElement: { interface SVGFEDistantLightElement extends SVGElement { readonly azimuth: SVGAnimatedNumber; readonly elevation: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDistantLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14988,7 +15710,7 @@ declare var SVGFEDistantLightElement: { } interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEFloodElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -14998,6 +15720,8 @@ declare var SVGFEFloodElement: { } interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncAElement: { @@ -15006,6 +15730,8 @@ declare var SVGFEFuncAElement: { } interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncBElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncBElement: { @@ -15014,6 +15740,8 @@ declare var SVGFEFuncBElement: { } interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncGElement: { @@ -15022,6 +15750,8 @@ declare var SVGFEFuncGElement: { } interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncRElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncRElement: { @@ -15034,7 +15764,7 @@ interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandar readonly stdDeviationX: SVGAnimatedNumber; readonly stdDeviationY: SVGAnimatedNumber; setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEGaussianBlurElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15043,9 +15773,9 @@ declare var SVGFEGaussianBlurElement: { new(): SVGFEGaussianBlurElement; } -interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { +interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGURIReference { readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15055,7 +15785,7 @@ declare var SVGFEImageElement: { } interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMergeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15066,7 +15796,7 @@ declare var SVGFEMergeElement: { interface SVGFEMergeNodeElement extends SVGElement { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMergeNodeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15083,7 +15813,7 @@ interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardA readonly SVG_MORPHOLOGY_OPERATOR_DILATE: number; readonly SVG_MORPHOLOGY_OPERATOR_ERODE: number; readonly SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMorphologyElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15099,7 +15829,7 @@ interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttri readonly dx: SVGAnimatedNumber; readonly dy: SVGAnimatedNumber; readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEOffsetElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15112,7 +15842,7 @@ interface SVGFEPointLightElement extends SVGElement { readonly x: SVGAnimatedNumber; readonly y: SVGAnimatedNumber; readonly z: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEPointLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15128,7 +15858,7 @@ interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveSta readonly specularConstant: SVGAnimatedNumber; readonly specularExponent: SVGAnimatedNumber; readonly surfaceScale: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFESpecularLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15146,7 +15876,7 @@ interface SVGFESpotLightElement extends SVGElement { readonly x: SVGAnimatedNumber; readonly y: SVGAnimatedNumber; readonly z: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFESpotLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15157,7 +15887,7 @@ declare var SVGFESpotLightElement: { interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFETileElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15179,7 +15909,7 @@ interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardA readonly SVG_TURBULENCE_TYPE_FRACTALNOISE: number; readonly SVG_TURBULENCE_TYPE_TURBULENCE: number; readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFETurbulenceElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15194,7 +15924,7 @@ declare var SVGFETurbulenceElement: { readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; } -interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { +interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGURIReference { readonly filterResX: SVGAnimatedInteger; readonly filterResY: SVGAnimatedInteger; readonly filterUnits: SVGAnimatedEnumeration; @@ -15204,7 +15934,7 @@ interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLan readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; setFilterRes(filterResX: number, filterResY: number): void; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFilterElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15213,12 +15943,12 @@ declare var SVGFilterElement: { new(): SVGFilterElement; } -interface SVGForeignObjectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGForeignObjectElement extends SVGGraphicsElement { readonly height: SVGAnimatedLength; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGForeignObjectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15227,8 +15957,8 @@ declare var SVGForeignObjectElement: { new(): SVGForeignObjectElement; } -interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGGElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15237,7 +15967,7 @@ declare var SVGGElement: { new(): SVGGElement; } -interface SVGGradientElement extends SVGElement, SVGStylable, SVGExternalResourcesRequired, SVGURIReference, SVGUnitTypes { +interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGURIReference { readonly gradientTransform: SVGAnimatedTransformList; readonly gradientUnits: SVGAnimatedEnumeration; readonly spreadMethod: SVGAnimatedEnumeration; @@ -15245,7 +15975,7 @@ interface SVGGradientElement extends SVGElement, SVGStylable, SVGExternalResourc readonly SVG_SPREADMETHOD_REFLECT: number; readonly SVG_SPREADMETHOD_REPEAT: number; readonly SVG_SPREADMETHOD_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15258,13 +15988,30 @@ declare var SVGGradientElement: { readonly SVG_SPREADMETHOD_UNKNOWN: number; } -interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface SVGGraphicsElement extends SVGElement, SVGTests { + readonly farthestViewportElement: SVGElement; + readonly nearestViewportElement: SVGElement; + readonly transform: SVGAnimatedTransformList; + getBBox(): SVGRect; + getCTM(): SVGMatrix; + getScreenCTM(): SVGMatrix; + getTransformToElement(element: SVGElement): SVGMatrix; + addEventListener(type: K, listener: (this: SVGGraphicsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGraphicsElement: { + prototype: SVGGraphicsElement; + new(): SVGGraphicsElement; +} + +interface SVGImageElement extends SVGGraphicsElement, SVGURIReference { readonly height: SVGAnimatedLength; readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15325,12 +16072,12 @@ declare var SVGLengthList: { new(): SVGLengthList; } -interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGLineElement extends SVGGraphicsElement { readonly x1: SVGAnimatedLength; readonly x2: SVGAnimatedLength; readonly y1: SVGAnimatedLength; readonly y2: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGLineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15344,6 +16091,8 @@ interface SVGLinearGradientElement extends SVGGradientElement { readonly x2: SVGAnimatedLength; readonly y1: SVGAnimatedLength; readonly y2: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGLinearGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGLinearGradientElement: { @@ -15351,7 +16100,7 @@ declare var SVGLinearGradientElement: { new(): SVGLinearGradientElement; } -interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { +interface SVGMarkerElement extends SVGElement, SVGFitToViewBox { readonly markerHeight: SVGAnimatedLength; readonly markerUnits: SVGAnimatedEnumeration; readonly markerWidth: SVGAnimatedLength; @@ -15367,7 +16116,7 @@ interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExt readonly SVG_MARKER_ORIENT_ANGLE: number; readonly SVG_MARKER_ORIENT_AUTO: number; readonly SVG_MARKER_ORIENT_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMarkerElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15382,14 +16131,14 @@ declare var SVGMarkerElement: { readonly SVG_MARKER_ORIENT_UNKNOWN: number; } -interface SVGMaskElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { +interface SVGMaskElement extends SVGElement, SVGTests, SVGUnitTypes { readonly height: SVGAnimatedLength; readonly maskContentUnits: SVGAnimatedEnumeration; readonly maskUnits: SVGAnimatedEnumeration; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMaskElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15424,7 +16173,7 @@ declare var SVGMatrix: { } interface SVGMetadataElement extends SVGElement { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMetadataElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15458,7 +16207,8 @@ declare var SVGNumberList: { new(): SVGNumberList; } -interface SVGPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPathData { +interface SVGPathElement extends SVGGraphicsElement { + readonly pathSegList: SVGPathSegList; createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; createSVGPathSegClosePath(): SVGPathSegClosePath; @@ -15481,7 +16231,7 @@ interface SVGPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGT getPathSegAtLength(distance: number): number; getPointAtLength(distance: number): SVGPoint; getTotalLength(): number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15766,7 +16516,7 @@ declare var SVGPathSegMovetoRel: { new(): SVGPathSegMovetoRel; } -interface SVGPatternElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGURIReference, SVGUnitTypes { +interface SVGPatternElement extends SVGElement, SVGTests, SVGUnitTypes, SVGFitToViewBox, SVGURIReference { readonly height: SVGAnimatedLength; readonly patternContentUnits: SVGAnimatedEnumeration; readonly patternTransform: SVGAnimatedTransformList; @@ -15774,7 +16524,7 @@ interface SVGPatternElement extends SVGElement, SVGStylable, SVGTests, SVGLangSp readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGPatternElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15810,8 +16560,8 @@ declare var SVGPointList: { new(): SVGPointList; } -interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPoints { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGPolygonElement extends SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolygonElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15820,8 +16570,8 @@ declare var SVGPolygonElement: { new(): SVGPolygonElement; } -interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPoints { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGPolylineElement extends SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolylineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15874,6 +16624,8 @@ interface SVGRadialGradientElement extends SVGGradientElement { readonly fx: SVGAnimatedLength; readonly fy: SVGAnimatedLength; readonly r: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGRadialGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGRadialGradientElement: { @@ -15893,14 +16645,14 @@ declare var SVGRect: { new(): SVGRect; } -interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGRectElement extends SVGGraphicsElement { readonly height: SVGAnimatedLength; readonly rx: SVGAnimatedLength; readonly ry: SVGAnimatedLength; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGRectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15918,7 +16670,7 @@ interface SVGSVGElementEventMap extends SVGElementEventMap { "SVGZoom": SVGZoomEvent; } -interface SVGSVGElement extends SVGElement, DocumentEvent, SVGLocatable, SVGTests, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { +interface SVGSVGElement extends SVGGraphicsElement, DocumentEvent, SVGFitToViewBox, SVGZoomAndPan { contentScriptType: string; contentStyleType: string; currentScale: number; @@ -15970,9 +16722,9 @@ declare var SVGSVGElement: { new(): SVGSVGElement; } -interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { +interface SVGScriptElement extends SVGElement, SVGURIReference { type: string; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGScriptElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -15981,9 +16733,9 @@ declare var SVGScriptElement: { new(): SVGScriptElement; } -interface SVGStopElement extends SVGElement, SVGStylable { +interface SVGStopElement extends SVGElement { readonly offset: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGStopElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16008,12 +16760,12 @@ declare var SVGStringList: { new(): SVGStringList; } -interface SVGStyleElement extends SVGElement, SVGLangSpace { +interface SVGStyleElement extends SVGElement { disabled: boolean; media: string; title: string; type: string; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGStyleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16022,8 +16774,8 @@ declare var SVGStyleElement: { new(): SVGStyleElement; } -interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGSwitchElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGSwitchElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16032,8 +16784,8 @@ declare var SVGSwitchElement: { new(): SVGSwitchElement; } -interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGSymbolElement extends SVGElement, SVGFitToViewBox { + addEventListener(type: K, listener: (this: SVGSymbolElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16043,6 +16795,8 @@ declare var SVGSymbolElement: { } interface SVGTSpanElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTSpanElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTSpanElement: { @@ -16050,7 +16804,7 @@ declare var SVGTSpanElement: { new(): SVGTSpanElement; } -interface SVGTextContentElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGTextContentElement extends SVGGraphicsElement { readonly lengthAdjust: SVGAnimatedEnumeration; readonly textLength: SVGAnimatedLength; getCharNumAtPosition(point: SVGPoint): number; @@ -16065,7 +16819,7 @@ interface SVGTextContentElement extends SVGElement, SVGStylable, SVGTests, SVGLa readonly LENGTHADJUST_SPACING: number; readonly LENGTHADJUST_SPACINGANDGLYPHS: number; readonly LENGTHADJUST_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGTextContentElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16077,7 +16831,9 @@ declare var SVGTextContentElement: { readonly LENGTHADJUST_UNKNOWN: number; } -interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { +interface SVGTextElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTextElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextElement: { @@ -16095,6 +16851,8 @@ interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { readonly TEXTPATH_SPACINGTYPE_AUTO: number; readonly TEXTPATH_SPACINGTYPE_EXACT: number; readonly TEXTPATH_SPACINGTYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGTextPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextPathElement: { @@ -16114,6 +16872,8 @@ interface SVGTextPositioningElement extends SVGTextContentElement { readonly rotate: SVGAnimatedNumberList; readonly x: SVGAnimatedLengthList; readonly y: SVGAnimatedLengthList; + addEventListener(type: K, listener: (this: SVGTextPositioningElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextPositioningElement: { @@ -16121,8 +16881,8 @@ declare var SVGTextPositioningElement: { new(): SVGTextPositioningElement; } -interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGTitleElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGTitleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16187,14 +16947,14 @@ interface SVGUnitTypes { } declare var SVGUnitTypes: SVGUnitTypes; -interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface SVGUseElement extends SVGGraphicsElement, SVGURIReference { readonly animatedInstanceRoot: SVGElementInstance; readonly height: SVGAnimatedLength; readonly instanceRoot: SVGElementInstance; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGUseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16203,9 +16963,9 @@ declare var SVGUseElement: { new(): SVGUseElement; } -interface SVGViewElement extends SVGElement, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { +interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox { readonly viewTarget: SVGStringList; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGViewElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -16237,6 +16997,26 @@ declare var SVGZoomEvent: { new(): SVGZoomEvent; } +interface ScopedCredential { + readonly id: ArrayBuffer; + readonly type: string; +} + +declare var ScopedCredential: { + prototype: ScopedCredential; + new(): ScopedCredential; +} + +interface ScopedCredentialInfo { + readonly credential: ScopedCredential; + readonly publicKey: CryptoKey; +} + +declare var ScopedCredentialInfo: { + prototype: ScopedCredentialInfo; + new(): ScopedCredentialInfo; +} + interface ScreenEventMap { "MSOrientationChange": Event; } @@ -16298,6 +17078,10 @@ declare var ScriptProcessorNode: { interface Selection { readonly anchorNode: Node; readonly anchorOffset: number; + readonly baseNode: Node; + readonly baseOffset: number; + readonly extentNode: Node; + readonly extentOffset: number; readonly focusNode: Node; readonly focusOffset: number; readonly isCollapsed: boolean; @@ -16316,6 +17100,7 @@ interface Selection { removeRange(range: Range): void; selectAllChildren(parentNode: Node): void; setBaseAndExtent(baseNode: Node, baseOffset: number, extentNode: Node, extentOffset: number): void; + setPosition(parentNode: Node, offset: number): void; toString(): string; } @@ -16324,6 +17109,84 @@ declare var Selection: { new(): Selection; } +interface ServiceWorkerEventMap extends AbstractWorkerEventMap { + "statechange": Event; +} + +interface ServiceWorker extends EventTarget, AbstractWorker { + onstatechange: (this: ServiceWorker, ev: Event) => any; + readonly scriptURL: USVString; + readonly state: string; + postMessage(message: any, transfer?: any[]): void; + addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorker: { + prototype: ServiceWorker; + new(): ServiceWorker; +} + +interface ServiceWorkerContainerEventMap { + "controllerchange": Event; + "message": ServiceWorkerMessageEvent; +} + +interface ServiceWorkerContainer extends EventTarget { + readonly controller: ServiceWorker | null; + oncontrollerchange: (this: ServiceWorkerContainer, ev: Event) => any; + onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any; + readonly ready: Promise; + getRegistration(clientURL?: USVString): Promise; + getRegistrations(): any; + register(scriptURL: USVString, options?: RegistrationOptions): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerContainer: { + prototype: ServiceWorkerContainer; + new(): ServiceWorkerContainer; +} + +interface ServiceWorkerMessageEvent extends Event { + readonly data: any; + readonly lastEventId: string; + readonly origin: string; + readonly ports: MessagePort[] | null; + readonly source: ServiceWorker | MessagePort | null; +} + +declare var ServiceWorkerMessageEvent: { + prototype: ServiceWorkerMessageEvent; + new(type: string, eventInitDict?: ServiceWorkerMessageEventInit): ServiceWorkerMessageEvent; +} + +interface ServiceWorkerRegistrationEventMap { + "updatefound": Event; +} + +interface ServiceWorkerRegistration extends EventTarget { + readonly active: ServiceWorker | null; + readonly installing: ServiceWorker | null; + onupdatefound: (this: ServiceWorkerRegistration, ev: Event) => any; + readonly pushManager: PushManager; + readonly scope: USVString; + readonly sync: SyncManager; + readonly waiting: ServiceWorker | null; + getNotifications(filter?: GetNotificationOptions): any; + showNotification(title: string, options?: NotificationOptions): Promise; + unregister(): Promise; + update(): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerRegistration: { + prototype: ServiceWorkerRegistration; + new(): ServiceWorkerRegistration; +} + interface SourceBuffer extends EventTarget { appendWindowEnd: number; appendWindowStart: number; @@ -16355,6 +17218,87 @@ declare var SourceBufferList: { new(): SourceBufferList; } +interface SpeechSynthesisEventMap { + "voiceschanged": Event; +} + +interface SpeechSynthesis extends EventTarget { + onvoiceschanged: (this: SpeechSynthesis, ev: Event) => any; + readonly paused: boolean; + readonly pending: boolean; + readonly speaking: boolean; + cancel(): void; + getVoices(): SpeechSynthesisVoice[]; + pause(): void; + resume(): void; + speak(utterance: SpeechSynthesisUtterance): void; + addEventListener(type: K, listener: (this: SpeechSynthesis, ev: SpeechSynthesisEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesis: { + prototype: SpeechSynthesis; + new(): SpeechSynthesis; +} + +interface SpeechSynthesisEvent extends Event { + readonly charIndex: number; + readonly elapsedTime: number; + readonly name: string; + readonly utterance: SpeechSynthesisUtterance | null; +} + +declare var SpeechSynthesisEvent: { + prototype: SpeechSynthesisEvent; + new(type: string, eventInitDict?: SpeechSynthesisEventInit): SpeechSynthesisEvent; +} + +interface SpeechSynthesisUtteranceEventMap { + "boundary": Event; + "end": Event; + "error": Event; + "mark": Event; + "pause": Event; + "resume": Event; + "start": Event; +} + +interface SpeechSynthesisUtterance extends EventTarget { + lang: string; + onboundary: (this: SpeechSynthesisUtterance, ev: Event) => any; + onend: (this: SpeechSynthesisUtterance, ev: Event) => any; + onerror: (this: SpeechSynthesisUtterance, ev: Event) => any; + onmark: (this: SpeechSynthesisUtterance, ev: Event) => any; + onpause: (this: SpeechSynthesisUtterance, ev: Event) => any; + onresume: (this: SpeechSynthesisUtterance, ev: Event) => any; + onstart: (this: SpeechSynthesisUtterance, ev: Event) => any; + pitch: number; + rate: number; + text: string; + voice: SpeechSynthesisVoice; + volume: number; + addEventListener(type: K, listener: (this: SpeechSynthesisUtterance, ev: SpeechSynthesisUtteranceEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesisUtterance: { + prototype: SpeechSynthesisUtterance; + new(text?: string): SpeechSynthesisUtterance; +} + +interface SpeechSynthesisVoice { + readonly default: boolean; + readonly lang: string; + readonly localService: boolean; + readonly name: string; + readonly voiceURI: string; +} + +declare var SpeechSynthesisVoice: { + prototype: SpeechSynthesisVoice; + new(): SpeechSynthesisVoice; +} + interface StereoPannerNode extends AudioNode { readonly pan: AudioParam; } @@ -16466,6 +17410,16 @@ declare var SubtleCrypto: { new(): SubtleCrypto; } +interface SyncManager { + getTags(): any; + register(tag: string): Promise; +} + +declare var SyncManager: { + prototype: SyncManager; + new(): SyncManager; +} + interface Text extends CharacterData { readonly wholeText: string; readonly assignedSlot: HTMLSlotElement | null; @@ -16520,7 +17474,7 @@ declare var TextMetrics: { interface TextTrackEventMap { "cuechange": Event; - "error": ErrorEvent; + "error": Event; "load": Event; } @@ -16533,7 +17487,7 @@ interface TextTrack extends EventTarget { readonly language: string; mode: any; oncuechange: (this: TextTrack, ev: Event) => any; - onerror: (this: TextTrack, ev: ErrorEvent) => any; + onerror: (this: TextTrack, ev: Event) => any; onload: (this: TextTrack, ev: Event) => any; readonly readyState: number; addCue(cue: TextTrackCue): void; @@ -16645,11 +17599,14 @@ declare var Touch: { interface TouchEvent extends UIEvent { readonly altKey: boolean; readonly changedTouches: TouchList; + readonly charCode: number; readonly ctrlKey: boolean; + readonly keyCode: number; readonly metaKey: boolean; readonly shiftKey: boolean; readonly targetTouches: TouchList; readonly touches: TouchList; + readonly which: number; } declare var TouchEvent: { @@ -16669,12 +17626,12 @@ declare var TouchList: { } interface TrackEvent extends Event { - readonly track: any; + readonly track: VideoTrack | AudioTrack | TextTrack | null; } declare var TrackEvent: { prototype: TrackEvent; - new(): TrackEvent; + new(typeArg: string, eventInitDict?: TrackEventInit): TrackEvent; } interface TransitionEvent extends Event { @@ -16685,7 +17642,7 @@ interface TransitionEvent extends Event { declare var TransitionEvent: { prototype: TransitionEvent; - new(): TransitionEvent; + new(typeArg: string, eventInitDict?: TransitionEventInit): TransitionEvent; } interface TreeWalker { @@ -16716,7 +17673,7 @@ interface UIEvent extends Event { declare var UIEvent: { prototype: UIEvent; - new(type: string, eventInitDict?: UIEventInit): UIEvent; + new(typeArg: string, eventInitDict?: UIEventInit): UIEvent; } interface URL { @@ -16731,6 +17688,7 @@ interface URL { protocol: string; search: string; username: string; + readonly searchparams: URLSearchParams; toString(): string; } @@ -16867,6 +17825,28 @@ declare var WaveShaperNode: { new(): WaveShaperNode; } +interface WebAuthentication { + getAssertion(assertionChallenge: any, options?: AssertionOptions): Promise; + makeCredential(accountInformation: Account, cryptoParameters: ScopedCredentialParameters[], attestationChallenge: any, options?: ScopedCredentialOptions): Promise; +} + +declare var WebAuthentication: { + prototype: WebAuthentication; + new(): WebAuthentication; +} + +interface WebAuthnAssertion { + readonly authenticatorData: ArrayBuffer; + readonly clientData: ArrayBuffer; + readonly credential: ScopedCredential; + readonly signature: ArrayBuffer; +} + +declare var WebAuthnAssertion: { + prototype: WebAuthnAssertion; + new(): WebAuthnAssertion; +} + interface WebGLActiveInfo { readonly name: string; readonly size: number; @@ -16892,7 +17872,7 @@ interface WebGLContextEvent extends Event { declare var WebGLContextEvent: { prototype: WebGLContextEvent; - new(type: string, eventInitDict?: WebGLContextEventInit): WebGLContextEvent; + new(typeArg: string, eventInitDict?: WebGLContextEventInit): WebGLContextEvent; } interface WebGLFramebuffer extends WebGLObject { @@ -17019,7 +17999,7 @@ interface WebGLRenderingContext { isTexture(texture: WebGLTexture | null): boolean; lineWidth(width: number): void; linkProgram(program: WebGLProgram | null): void; - pixelStorei(pname: number, param: number): void; + pixelStorei(pname: number, param: number | boolean): void; polygonOffset(factor: number, units: number): void; readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView | null): void; renderbufferStorage(target: number, internalformat: number, width: number, height: number): void; @@ -17745,6 +18725,56 @@ declare var WebKitCSSMatrix: { new(text?: string): WebKitCSSMatrix; } +interface WebKitDirectoryEntry extends WebKitEntry { + createReader(): WebKitDirectoryReader; +} + +declare var WebKitDirectoryEntry: { + prototype: WebKitDirectoryEntry; + new(): WebKitDirectoryEntry; +} + +interface WebKitDirectoryReader { + readEntries(successCallback: WebKitEntriesCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitDirectoryReader: { + prototype: WebKitDirectoryReader; + new(): WebKitDirectoryReader; +} + +interface WebKitEntry { + readonly filesystem: WebKitFileSystem; + readonly fullPath: string; + readonly isDirectory: boolean; + readonly isFile: boolean; + readonly name: string; +} + +declare var WebKitEntry: { + prototype: WebKitEntry; + new(): WebKitEntry; +} + +interface WebKitFileEntry extends WebKitEntry { + file(successCallback: WebKitFileCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitFileEntry: { + prototype: WebKitFileEntry; + new(): WebKitFileEntry; +} + +interface WebKitFileSystem { + readonly name: string; + readonly root: WebKitDirectoryEntry; +} + +declare var WebKitFileSystem: { + prototype: WebKitFileSystem; + new(): WebKitFileSystem; +} + interface WebKitPoint { x: number; y: number; @@ -17757,7 +18787,7 @@ declare var WebKitPoint: { interface WebSocketEventMap { "close": CloseEvent; - "error": ErrorEvent; + "error": Event; "message": MessageEvent; "open": Event; } @@ -17767,7 +18797,7 @@ interface WebSocket extends EventTarget { readonly bufferedAmount: number; readonly extensions: string; onclose: (this: WebSocket, ev: CloseEvent) => any; - onerror: (this: WebSocket, ev: ErrorEvent) => any; + onerror: (this: WebSocket, ev: Event) => any; onmessage: (this: WebSocket, ev: MessageEvent) => any; onopen: (this: WebSocket, ev: Event) => any; readonly protocol: string; @@ -17904,8 +18934,9 @@ interface WindowEventMap extends GlobalEventHandlersEventMap { "waiting": Event; } -interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64 { +interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch { readonly applicationCache: ApplicationCache; + readonly caches: CacheStorage; readonly clientInformation: Navigator; readonly closed: boolean; readonly crypto: Crypto; @@ -17920,10 +18951,12 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly history: History; readonly innerHeight: number; readonly innerWidth: number; + readonly isSecureContext: boolean; readonly length: number; readonly location: Location; readonly locationbar: BarProp; readonly menubar: BarProp; + readonly msContentScript: ExtensionScriptApis; readonly msCredentials: MSCredentials; name: string; readonly navigator: Navigator; @@ -18037,6 +19070,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly scrollY: number; readonly scrollbars: BarProp; readonly self: Window; + readonly speechSynthesis: SpeechSynthesis; status: string; readonly statusbar: BarProp; readonly styleMedia: StyleMedia; @@ -18045,12 +19079,14 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly window: Window; URL: typeof URL; Blob: typeof Blob; + customElements: CustomElementRegistry; alert(message?: any): void; blur(): void; cancelAnimationFrame(handle: number): void; captureEvents(): void; close(): void; confirm(message?: string): boolean; + departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; focus(): void; getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -18070,6 +19106,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window scroll(x?: number, y?: number): void; scrollBy(x?: number, y?: number): void; scrollTo(x?: number, y?: number): void; + stop(): void; webkitCancelAnimationFrame(handle: number): void; webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; @@ -18092,7 +19129,7 @@ interface WorkerEventMap extends AbstractWorkerEventMap { interface Worker extends EventTarget, AbstractWorker { onmessage: (this: Worker, ev: MessageEvent) => any; - postMessage(message: any, ports?: any): void; + postMessage(message: any, transfer?: any[]): void; terminate(): void; addEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -18104,7 +19141,7 @@ declare var Worker: { } interface XMLDocument extends Document { - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: XMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -18123,14 +19160,14 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly response: any; readonly responseText: string; responseType: string; - readonly responseXML: any; + readonly responseURL: string; + readonly responseXML: Document | null; readonly status: number; readonly statusText: string; timeout: number; readonly upload: XMLHttpRequestUpload; withCredentials: boolean; msCaching?: string; - readonly responseURL: string; abort(): void; getAllResponseHeaders(): string; getResponseHeader(header: string): string | null; @@ -18158,11 +19195,10 @@ declare var XMLHttpRequest: { readonly LOADING: number; readonly OPENED: number; readonly UNSENT: number; - create(): XMLHttpRequest; } interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { - addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -18262,6 +19298,16 @@ declare var XSLTProcessor: { new(): XSLTProcessor; } +interface webkitRTCPeerConnection extends RTCPeerConnection { + addEventListener(type: K, listener: (this: webkitRTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var webkitRTCPeerConnection: { + prototype: webkitRTCPeerConnection; + new(configuration: RTCConfiguration): webkitRTCPeerConnection; +} + interface AbstractWorkerEventMap { "error": ErrorEvent; } @@ -18272,6 +19318,14 @@ interface AbstractWorker { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface Body { + readonly bodyUsed: boolean; + arrayBuffer(): Promise; + blob(): Promise; + json(): Promise; + text(): Promise; +} + interface CanvasPathMethods { arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; @@ -18298,12 +19352,10 @@ interface DOML2DeprecatedSizeProperty { interface DocumentEvent { createEvent(eventInterface:"AnimationEvent"): AnimationEvent; - createEvent(eventInterface:"AriaRequestEvent"): AriaRequestEvent; createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent; createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent; createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent; createEvent(eventInterface:"CloseEvent"): CloseEvent; - createEvent(eventInterface:"CommandEvent"): CommandEvent; createEvent(eventInterface:"CompositionEvent"): CompositionEvent; createEvent(eventInterface:"CustomEvent"): CustomEvent; createEvent(eventInterface:"DeviceLightEvent"): DeviceLightEvent; @@ -18314,6 +19366,7 @@ interface DocumentEvent { createEvent(eventInterface:"Event"): Event; createEvent(eventInterface:"Events"): Event; createEvent(eventInterface:"FocusEvent"): FocusEvent; + createEvent(eventInterface:"FocusNavigationEvent"): FocusNavigationEvent; createEvent(eventInterface:"GamepadEvent"): GamepadEvent; createEvent(eventInterface:"HashChangeEvent"): HashChangeEvent; createEvent(eventInterface:"IDBVersionChangeEvent"): IDBVersionChangeEvent; @@ -18329,6 +19382,7 @@ interface DocumentEvent { createEvent(eventInterface:"MediaEncryptedEvent"): MediaEncryptedEvent; createEvent(eventInterface:"MediaKeyMessageEvent"): MediaKeyMessageEvent; createEvent(eventInterface:"MediaStreamErrorEvent"): MediaStreamErrorEvent; + createEvent(eventInterface:"MediaStreamEvent"): MediaStreamEvent; createEvent(eventInterface:"MediaStreamTrackEvent"): MediaStreamTrackEvent; createEvent(eventInterface:"MessageEvent"): MessageEvent; createEvent(eventInterface:"MouseEvent"): MouseEvent; @@ -18341,6 +19395,7 @@ interface DocumentEvent { createEvent(eventInterface:"OfflineAudioCompletionEvent"): OfflineAudioCompletionEvent; createEvent(eventInterface:"OverflowEvent"): OverflowEvent; createEvent(eventInterface:"PageTransitionEvent"): PageTransitionEvent; + createEvent(eventInterface:"PaymentRequestUpdateEvent"): PaymentRequestUpdateEvent; createEvent(eventInterface:"PermissionRequestedEvent"): PermissionRequestedEvent; createEvent(eventInterface:"PointerEvent"): PointerEvent; createEvent(eventInterface:"PopStateEvent"): PopStateEvent; @@ -18350,10 +19405,13 @@ interface DocumentEvent { createEvent(eventInterface:"RTCIceCandidatePairChangedEvent"): RTCIceCandidatePairChangedEvent; createEvent(eventInterface:"RTCIceGathererEvent"): RTCIceGathererEvent; createEvent(eventInterface:"RTCIceTransportStateChangedEvent"): RTCIceTransportStateChangedEvent; + createEvent(eventInterface:"RTCPeerConnectionIceEvent"): RTCPeerConnectionIceEvent; createEvent(eventInterface:"RTCSsrcConflictEvent"): RTCSsrcConflictEvent; createEvent(eventInterface:"SVGZoomEvent"): SVGZoomEvent; createEvent(eventInterface:"SVGZoomEvents"): SVGZoomEvent; createEvent(eventInterface:"ScriptNotifyEvent"): ScriptNotifyEvent; + createEvent(eventInterface:"ServiceWorkerMessageEvent"): ServiceWorkerMessageEvent; + createEvent(eventInterface:"SpeechSynthesisEvent"): SpeechSynthesisEvent; createEvent(eventInterface:"StorageEvent"): StorageEvent; createEvent(eventInterface:"TextEvent"): TextEvent; createEvent(eventInterface:"TouchEvent"): TouchEvent; @@ -18369,10 +19427,10 @@ interface DocumentEvent { interface ElementTraversal { readonly childElementCount: number; - readonly firstElementChild: Element; - readonly lastElementChild: Element; - readonly nextElementSibling: Element; - readonly previousElementSibling: Element; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; + readonly nextElementSibling: Element | null; + readonly previousElementSibling: Element | null; } interface GetSVGDocument { @@ -18405,6 +19463,10 @@ interface GlobalEventHandlers { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface GlobalFetch { + fetch(input: RequestInfo, init?: RequestInit): Promise; +} + interface HTMLTableAlignment { /** * Sets or retrieves a value that you can use to implement your own ch functionality for the object. @@ -18468,6 +19530,14 @@ interface MSNavigatorDoNotTrack { storeWebWideTrackingException(args: StoreExceptionsInformation): void; } +interface NavigatorBeacon { + sendBeacon(url: USVString, data?: BodyInit): boolean; +} + +interface NavigatorConcurrentHardware { + readonly hardwareConcurrency: number; +} + interface NavigatorContentUtils { } @@ -18476,6 +19546,7 @@ interface NavigatorGeolocation { } interface NavigatorID { + readonly appCodeName: string; readonly appName: string; readonly appVersion: string; readonly platform: string; @@ -18509,20 +19580,12 @@ interface RandomSource { getRandomValues(array: ArrayBufferView): ArrayBufferView; } -interface SVGAnimatedPathData { - readonly pathSegList: SVGPathSegList; -} - interface SVGAnimatedPoints { readonly animatedPoints: SVGPointList; readonly points: SVGPointList; } -interface SVGExternalResourcesRequired { - readonly externalResourcesRequired: SVGAnimatedBoolean; -} - -interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { +interface SVGFilterPrimitiveStandardAttributes { readonly height: SVGAnimatedLength; readonly result: SVGAnimatedString; readonly width: SVGAnimatedLength; @@ -18535,25 +19598,6 @@ interface SVGFitToViewBox { readonly viewBox: SVGAnimatedRect; } -interface SVGLangSpace { - xmllang: string; - xmlspace: string; -} - -interface SVGLocatable { - readonly farthestViewportElement: SVGElement; - readonly nearestViewportElement: SVGElement; - getBBox(): SVGRect; - getCTM(): SVGMatrix; - getScreenCTM(): SVGMatrix; - getTransformToElement(element: SVGElement): SVGMatrix; -} - -interface SVGStylable { - className: any; - readonly style: CSSStyleDeclaration; -} - interface SVGTests { readonly requiredExtensions: SVGStringList; readonly requiredFeatures: SVGStringList; @@ -18561,10 +19605,6 @@ interface SVGTests { hasExtension(extension: string): boolean; } -interface SVGTransformable extends SVGLocatable { - readonly transform: SVGAnimatedTransformList; -} - interface SVGURIReference { readonly href: SVGAnimatedString; } @@ -18623,6 +19663,14 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface ErrorEventInit { + message?: string; + filename?: string; + lineno?: number; + conlno?: number; + error?: any; +} + interface StorageEventInit extends EventInit { key?: string; oldValue?: string; @@ -18638,6 +19686,41 @@ interface Canvas2DContextAttributes { [attribute: string]: boolean | string | undefined; } +interface URLSearchParams { + /** + * Appends a specified key/value pair as a new search parameter. + */ + append(name: string, value: string): void; + /** + * Deletes the given search parameter, and its associated value, from the list of all search parameters. + */ + delete(name: string): void; + /** + * Returns the first value associated to the given search parameter. + */ + get(name: string): string | null; + /** + * Returns all the values association with a given search parameter. + */ + getAll(name: string): string[]; + /** + * Returns a Boolean indicating if such a search parameter exists. + */ + has(name: string): boolean; + /** + * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. + */ + set(name: string, value: string): void; +} + +declare var URLSearchParams: { + prototype: URLSearchParams; + /** + * Constructor returning a URLSearchParams object. + */ + new (init?: string | URLSearchParams): URLSearchParams; +} + interface NodeListOf extends NodeList { length: number; item(index: number): TNode; @@ -18647,7 +19730,6 @@ interface NodeListOf extends NodeList { interface HTMLCollectionOf extends HTMLCollection { item(index: number): T; namedItem(name: string): T; - [index: number]: T; } interface BlobPropertyBag { @@ -18664,15 +19746,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -interface MessageEventInit extends EventInit { - data?: any; - origin?: string; - lastEventId?: string; - channel?: string; - source?: any; - ports?: MessagePort[]; -} - interface ProgressEventInit extends EventInit { lengthComputable?: boolean; loaded?: number; @@ -18874,8 +19947,8 @@ interface JsonWebKey { interface ParentNode { readonly children: HTMLCollection; - readonly firstElementChild: Element; - readonly lastElementChild: Element; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; readonly childElementCount: number; } @@ -18906,6 +19979,26 @@ interface AssignedNodesOptions { flatten?: boolean; } +interface ElementDefinitionOptions { + extends: string; +} + +interface CustomElementRegistry { + define(name: string, constructor: Function, options?: ElementDefinitionOptions): void; + get(name: string): any; + whenDefined(name: string): PromiseLike; +} + +interface PromiseRejectionEvent extends Event { + readonly promise: PromiseLike; + readonly reason: any; +} + +interface PromiseRejectionEventInit extends EventInit { + promise: PromiseLike; + reason?: any; +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -18941,6 +20034,18 @@ interface DecodeSuccessCallback { interface DecodeErrorCallback { (error: DOMException): void; } +interface VoidFunction { + (): void; +} +interface RTCSessionDescriptionCallback { + (sdp: RTCSessionDescription): void; +} +interface RTCPeerConnectionErrorCallback { + (error: DOMError): void; +} +interface RTCStatsCallback { + (report: RTCStatsReport): void; +} interface FunctionStringCallback { (data: string): void; } @@ -18953,6 +20058,12 @@ interface NavigatorUserMediaErrorCallback { interface ForEachCallback { (keyId: any, status: string): void; } +interface NotificationPermissionCallback { + (permission: string): void; +} +interface IntersectionObserverCallback { + (entries: IntersectionObserverEntry[], observer: IntersectionObserver): void; +} interface HTMLElementTagNameMap { "a": HTMLAnchorElement; "applet": HTMLAppletElement; @@ -18968,6 +20079,7 @@ interface HTMLElementTagNameMap { "caption": HTMLTableCaptionElement; "col": HTMLTableColElement; "colgroup": HTMLTableColElement; + "data": HTMLDataElement; "datalist": HTMLDataListElement; "del": HTMLModElement; "dir": HTMLDirectoryElement; @@ -19008,6 +20120,7 @@ interface HTMLElementTagNameMap { "ol": HTMLOListElement; "optgroup": HTMLOptGroupElement; "option": HTMLOptionElement; + "output": HTMLOutputElement; "p": HTMLParagraphElement; "param": HTMLParamElement; "picture": HTMLPictureElement; @@ -19027,6 +20140,7 @@ interface HTMLElementTagNameMap { "tfoot": HTMLTableSectionElement; "th": HTMLTableHeaderCellElement; "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; "title": HTMLTitleElement; "tr": HTMLTableRowElement; "track": HTMLTrackElement; @@ -19064,6 +20178,7 @@ interface ElementTagNameMap { "code": HTMLElement; "col": HTMLTableColElement; "colgroup": HTMLTableColElement; + "data": HTMLDataElement; "datalist": HTMLDataListElement; "dd": HTMLElement; "defs": SVGDefsElement; @@ -19157,6 +20272,7 @@ interface ElementTagNameMap { "ol": HTMLOListElement; "optgroup": HTMLOptGroupElement; "option": HTMLOptionElement; + "output": HTMLOutputElement; "p": HTMLParagraphElement; "param": HTMLParamElement; "path": SVGPathElement; @@ -19199,6 +20315,7 @@ interface ElementTagNameMap { "tfoot": HTMLTableSectionElement; "th": HTMLTableHeaderCellElement; "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; "title": HTMLTitleElement; "tr": HTMLTableRowElement; "track": HTMLTrackElement; @@ -19243,6 +20360,7 @@ interface ElementListTagNameMap { "code": NodeListOf; "col": NodeListOf; "colgroup": NodeListOf; + "data": NodeListOf; "datalist": NodeListOf; "dd": NodeListOf; "defs": NodeListOf; @@ -19336,6 +20454,7 @@ interface ElementListTagNameMap { "ol": NodeListOf; "optgroup": NodeListOf; "option": NodeListOf; + "output": NodeListOf; "p": NodeListOf; "param": NodeListOf; "path": NodeListOf; @@ -19378,6 +20497,7 @@ interface ElementListTagNameMap { "tfoot": NodeListOf; "th": NodeListOf; "thead": NodeListOf; + "time": NodeListOf; "title": NodeListOf; "tr": NodeListOf; "track": NodeListOf; @@ -19398,6 +20518,7 @@ declare var Audio: {new(src?: string): HTMLAudioElement; }; declare var Image: {new(width?: number, height?: number): HTMLImageElement; }; declare var Option: {new(text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; }; declare var applicationCache: ApplicationCache; +declare var caches: CacheStorage; declare var clientInformation: Navigator; declare var closed: boolean; declare var crypto: Crypto; @@ -19412,10 +20533,12 @@ declare var frames: Window; declare var history: History; declare var innerHeight: number; declare var innerWidth: number; +declare var isSecureContext: boolean; declare var length: number; declare var location: Location; declare var locationbar: BarProp; declare var menubar: BarProp; +declare var msContentScript: ExtensionScriptApis; declare var msCredentials: MSCredentials; declare const name: never; declare var navigator: Navigator; @@ -19529,18 +20652,21 @@ declare var scrollX: number; declare var scrollY: number; declare var scrollbars: BarProp; declare var self: Window; +declare var speechSynthesis: SpeechSynthesis; declare var status: string; declare var statusbar: BarProp; declare var styleMedia: StyleMedia; declare var toolbar: BarProp; declare var top: Window; declare var window: Window; +declare var customElements: CustomElementRegistry; declare function alert(message?: any): void; declare function blur(): void; declare function cancelAnimationFrame(handle: number): void; declare function captureEvents(): void; declare function close(): void; declare function confirm(message?: string): boolean; +declare function departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; declare function focus(): void; declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; declare function getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -19560,6 +20686,7 @@ declare function resizeTo(x?: number, y?: number): void; declare function scroll(x?: number, y?: number): void; declare function scrollBy(x?: number, y?: number): void; declare function scrollTo(x?: number, y?: number): void; +declare function stop(): void; declare function webkitCancelAnimationFrame(handle: number): void; declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; @@ -19594,10 +20721,13 @@ declare var onwheel: (this: Window, ev: WheelEvent) => any; declare var indexedDB: IDBFactory; declare function atob(encodedString: string): string; declare function btoa(rawString: string): string; +declare function fetch(input: RequestInfo, init?: RequestInit): Promise; declare function addEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; type AAGUID = string; type AlgorithmIdentifier = string | Algorithm; +type BodyInit = any; +type ByteString = string; type ConstrainBoolean = boolean | ConstrainBooleanParameters; type ConstrainDOMString = string | string[] | ConstrainDOMStringParameters; type ConstrainDouble = number | ConstrainDoubleRange; @@ -19617,6 +20747,7 @@ type GLsizeiptr = number; type GLubyte = number; type GLuint = number; type GLushort = number; +type HeadersInit = any; type IDBKeyPath = string; type KeyFormat = string; type KeyType = string; @@ -19624,8 +20755,10 @@ type KeyUsage = string; type MSInboundPayload = MSVideoRecvPayload | MSAudioRecvPayload; type MSLocalClientEvent = MSLocalClientEventBase | MSAudioLocalClientEvent; type MSOutboundPayload = MSVideoSendPayload | MSAudioSendPayload; -type RTCIceGatherCandidate = RTCIceCandidate | RTCIceCandidateComplete; +type RTCIceGatherCandidate = RTCIceCandidateDictionary | RTCIceCandidateComplete; type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport; +type RequestInfo = Request | string; +type USVString = string; type payloadtype = number; type ScrollBehavior = "auto" | "instant" | "smooth"; type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index 4ee2566928d..e20455cf59e 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -27,12 +27,29 @@ interface Algorithm { name: string; } +interface CacheQueryOptions { + ignoreSearch?: boolean; + ignoreMethod?: boolean; + ignoreVary?: boolean; + cacheName?: string; +} + +interface CloseEventInit extends EventInit { + wasClean?: boolean; + code?: number; + reason?: string; +} + interface EventInit { scoped?: boolean; bubbles?: boolean; cancelable?: boolean; } +interface GetNotificationOptions { + tag?: string; +} + interface IDBIndexParameters { multiEntry?: boolean; unique?: boolean; @@ -47,10 +64,101 @@ interface KeyAlgorithm { name?: string; } +interface MessageEventInit extends EventInit { + lastEventId?: string; + channel?: string; + data?: any; + origin?: string; + source?: any; + ports?: MessagePort[]; +} + +interface NotificationOptions { + dir?: string; + lang?: string; + body?: string; + tag?: string; + icon?: string; +} + +interface PushSubscriptionOptionsInit { + userVisibleOnly?: boolean; + applicationServerKey?: any; +} + +interface RequestInit { + method?: string; + headers?: any; + body?: any; + referrer?: string; + referrerPolicy?: string; + mode?: string; + credentials?: string; + cache?: string; + redirect?: string; + integrity?: string; + keepalive?: boolean; + window?: any; +} + +interface ResponseInit { + status?: number; + statusText?: string; + headers?: any; +} + +interface ClientQueryOptions { + includeUncontrolled?: boolean; + type?: string; +} + +interface ExtendableEventInit extends EventInit { +} + +interface ExtendableMessageEventInit extends ExtendableEventInit { + data?: any; + origin?: string; + lastEventId?: string; + source?: Client | ServiceWorker | MessagePort; + ports?: MessagePort[]; +} + +interface FetchEventInit extends ExtendableEventInit { + request?: Request; + clientId?: string; + isReload?: boolean; +} + +interface NotificationEventInit extends ExtendableEventInit { + notification?: Notification; + action?: string; +} + +interface PushEventInit extends ExtendableEventInit { + data?: any; +} + +interface SyncEventInit extends ExtendableEventInit { + tag?: string; + lastChance?: boolean; +} + interface EventListener { (evt: Event): void; } +interface WebKitEntriesCallback { + (evt: Event): void; +} + +interface WebKitErrorCallback { + (evt: Event): void; +} + +interface WebKitFileCallback { + (evt: Event): void; +} + interface AudioBuffer { readonly duration: number; readonly length: number; @@ -79,6 +187,34 @@ declare var Blob: { new (blobParts?: any[], options?: BlobPropertyBag): Blob; } +interface Cache { + add(request: RequestInfo): Promise; + addAll(requests: RequestInfo[]): Promise; + delete(request: RequestInfo, options?: CacheQueryOptions): Promise; + keys(request?: RequestInfo, options?: CacheQueryOptions): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + put(request: RequestInfo, response: Response): Promise; +} + +declare var Cache: { + prototype: Cache; + new(): Cache; +} + +interface CacheStorage { + delete(cacheName: string): Promise; + has(cacheName: string): Promise; + keys(): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + open(cacheName: string): Promise; +} + +declare var CacheStorage: { + prototype: CacheStorage; + new(): CacheStorage; +} + interface CloseEvent extends Event { readonly code: number; readonly reason: string; @@ -88,14 +224,14 @@ interface CloseEvent extends Event { declare var CloseEvent: { prototype: CloseEvent; - new(): CloseEvent; + new(typeArg: string, eventInitDict?: CloseEventInit): CloseEvent; } interface Console { assert(test?: boolean, message?: string, ...optionalParams: any[]): void; clear(): void; count(countTitle?: string): void; - debug(message?: string, ...optionalParams: any[]): void; + debug(message?: any, ...optionalParams: any[]): void; dir(value?: any, ...optionalParams: any[]): void; dirxml(value: any): void; error(message?: any, ...optionalParams: any[]): void; @@ -247,7 +383,7 @@ interface ErrorEvent extends Event { declare var ErrorEvent: { prototype: ErrorEvent; - new(): ErrorEvent; + new(type: string, errorEventInitDict?: ErrorEventInit): ErrorEvent; } interface Event { @@ -276,7 +412,7 @@ interface Event { declare var Event: { prototype: Event; - new(type: string, eventInitDict?: EventInit): Event; + new(typeArg: string, eventInitDict?: EventInit): Event; readonly AT_TARGET: number; readonly BUBBLING_PHASE: number; readonly CAPTURING_PHASE: number; @@ -321,7 +457,7 @@ interface FileReader extends EventTarget, MSBaseReader { readAsBinaryString(blob: Blob): void; readAsDataURL(blob: Blob): void; readAsText(blob: Blob, encoding?: string): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -330,6 +466,20 @@ declare var FileReader: { new(): FileReader; } +interface Headers { + append(name: string, value: string): void; + delete(name: string): void; + forEach(callback: ForEachCallback): void; + get(name: string): string | null; + has(name: string): boolean; + set(name: string, value: string): void; +} + +declare var Headers: { + prototype: Headers; + new(init?: any): Headers; +} + interface IDBCursor { readonly direction: string; key: IDBKeyRange | IDBValidKey; @@ -365,14 +515,14 @@ declare var IDBCursorWithValue: { interface IDBDatabaseEventMap { "abort": Event; - "error": ErrorEvent; + "error": Event; } interface IDBDatabase extends EventTarget { readonly name: string; readonly objectStoreNames: DOMStringList; onabort: (this: IDBDatabase, ev: Event) => any; - onerror: (this: IDBDatabase, ev: ErrorEvent) => any; + onerror: (this: IDBDatabase, ev: Event) => any; version: number; onversionchange: (ev: IDBVersionChangeEvent) => any; close(): void; @@ -475,13 +625,13 @@ declare var IDBOpenDBRequest: { } interface IDBRequestEventMap { - "error": ErrorEvent; + "error": Event; "success": Event; } interface IDBRequest extends EventTarget { readonly error: DOMError; - onerror: (this: IDBRequest, ev: ErrorEvent) => any; + onerror: (this: IDBRequest, ev: Event) => any; onsuccess: (this: IDBRequest, ev: Event) => any; readonly readyState: string; readonly result: any; @@ -499,7 +649,7 @@ declare var IDBRequest: { interface IDBTransactionEventMap { "abort": Event; "complete": Event; - "error": ErrorEvent; + "error": Event; } interface IDBTransaction extends EventTarget { @@ -508,7 +658,7 @@ interface IDBTransaction extends EventTarget { readonly mode: string; onabort: (this: IDBTransaction, ev: Event) => any; oncomplete: (this: IDBTransaction, ev: Event) => any; - onerror: (this: IDBTransaction, ev: ErrorEvent) => any; + onerror: (this: IDBTransaction, ev: Event) => any; abort(): void; objectStore(name: string): IDBObjectStore; readonly READ_ONLY: string; @@ -548,105 +698,6 @@ declare var ImageData: { new(array: Uint8ClampedArray, width: number, height: number): ImageData; } -interface MSApp { - clearTemporaryWebDataAsync(): MSAppAsyncOperation; - createBlobFromRandomAccessStream(type: string, seeker: any): Blob; - createDataPackage(object: any): any; - createDataPackageFromSelection(): any; - createFileFromStorageFile(storageFile: any): File; - createStreamFromInputStream(type: string, inputStream: any): MSStream; - execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; - execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; - getCurrentPriority(): string; - getHtmlPrintDocumentSourceAsync(htmlDoc: any): PromiseLike; - getViewId(view: any): any; - isTaskScheduledAtPriorityOrHigher(priority: string): boolean; - pageHandlesAllApplicationActivations(enabled: boolean): void; - suppressSubdownloadCredentialPrompts(suppress: boolean): void; - terminateApp(exceptionObject: any): void; - readonly CURRENT: string; - readonly HIGH: string; - readonly IDLE: string; - readonly NORMAL: string; -} -declare var MSApp: MSApp; - -interface MSAppAsyncOperationEventMap { - "complete": Event; - "error": ErrorEvent; -} - -interface MSAppAsyncOperation extends EventTarget { - readonly error: DOMError; - oncomplete: (this: MSAppAsyncOperation, ev: Event) => any; - onerror: (this: MSAppAsyncOperation, ev: ErrorEvent) => any; - readonly readyState: number; - readonly result: any; - start(): void; - readonly COMPLETED: number; - readonly ERROR: number; - readonly STARTED: number; - addEventListener(type: K, listener: (this: MSAppAsyncOperation, ev: MSAppAsyncOperationEventMap[K]) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var MSAppAsyncOperation: { - prototype: MSAppAsyncOperation; - new(): MSAppAsyncOperation; - readonly COMPLETED: number; - readonly ERROR: number; - readonly STARTED: number; -} - -interface MSBlobBuilder { - append(data: any, endings?: string): void; - getBlob(contentType?: string): Blob; -} - -declare var MSBlobBuilder: { - prototype: MSBlobBuilder; - new(): MSBlobBuilder; -} - -interface MSStream { - readonly type: string; - msClose(): void; - msDetachStream(): any; -} - -declare var MSStream: { - prototype: MSStream; - new(): MSStream; -} - -interface MSStreamReader extends EventTarget, MSBaseReader { - readonly error: DOMError; - readAsArrayBuffer(stream: MSStream, size?: number): void; - readAsBinaryString(stream: MSStream, size?: number): void; - readAsBlob(stream: MSStream, size?: number): void; - readAsDataURL(stream: MSStream, size?: number): void; - readAsText(stream: MSStream, encoding?: string, size?: number): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var MSStreamReader: { - prototype: MSStreamReader; - new(): MSStreamReader; -} - -interface MediaQueryList { - readonly matches: boolean; - readonly media: string; - addListener(listener: MediaQueryListListener): void; - removeListener(listener: MediaQueryListListener): void; -} - -declare var MediaQueryList: { - prototype: MediaQueryList; - new(): MediaQueryList; -} - interface MessageChannel { readonly port1: MessagePort; readonly port2: MessagePort; @@ -677,7 +728,7 @@ interface MessagePortEventMap { interface MessagePort extends EventTarget { onmessage: (this: MessagePort, ev: MessageEvent) => any; close(): void; - postMessage(message?: any, ports?: any): void; + postMessage(message?: any, transfer?: any[]): void; start(): void; addEventListener(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -688,6 +739,109 @@ declare var MessagePort: { new(): MessagePort; } +interface NotificationEventMap { + "click": Event; + "close": Event; + "error": Event; + "show": Event; +} + +interface Notification extends EventTarget { + readonly body: string; + readonly dir: string; + readonly icon: string; + readonly lang: string; + onclick: (this: Notification, ev: Event) => any; + onclose: (this: Notification, ev: Event) => any; + onerror: (this: Notification, ev: Event) => any; + onshow: (this: Notification, ev: Event) => any; + readonly permission: string; + readonly tag: string; + readonly title: string; + close(): void; + addEventListener(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Notification: { + prototype: Notification; + new(title: string, options?: NotificationOptions): Notification; + requestPermission(callback?: NotificationPermissionCallback): Promise; +} + +interface Performance { + readonly navigation: PerformanceNavigation; + readonly timing: PerformanceTiming; + clearMarks(markName?: string): void; + clearMeasures(measureName?: string): void; + clearResourceTimings(): void; + getEntries(): any; + getEntriesByName(name: string, entryType?: string): any; + getEntriesByType(entryType: string): any; + getMarks(markName?: string): any; + getMeasures(measureName?: string): any; + mark(markName: string): void; + measure(measureName: string, startMarkName?: string, endMarkName?: string): void; + now(): number; + setResourceTimingBufferSize(maxSize: number): void; + toJSON(): any; +} + +declare var Performance: { + prototype: Performance; + new(): Performance; +} + +interface PerformanceNavigation { + readonly redirectCount: number; + readonly type: number; + toJSON(): any; + readonly TYPE_BACK_FORWARD: number; + readonly TYPE_NAVIGATE: number; + readonly TYPE_RELOAD: number; + readonly TYPE_RESERVED: number; +} + +declare var PerformanceNavigation: { + prototype: PerformanceNavigation; + new(): PerformanceNavigation; + readonly TYPE_BACK_FORWARD: number; + readonly TYPE_NAVIGATE: number; + readonly TYPE_RELOAD: number; + readonly TYPE_RESERVED: number; +} + +interface PerformanceTiming { + readonly connectEnd: number; + readonly connectStart: number; + readonly domComplete: number; + readonly domContentLoadedEventEnd: number; + readonly domContentLoadedEventStart: number; + readonly domInteractive: number; + readonly domLoading: number; + readonly domainLookupEnd: number; + readonly domainLookupStart: number; + readonly fetchStart: number; + readonly loadEventEnd: number; + readonly loadEventStart: number; + readonly msFirstPaint: number; + readonly navigationStart: number; + readonly redirectEnd: number; + readonly redirectStart: number; + readonly requestStart: number; + readonly responseEnd: number; + readonly responseStart: number; + readonly unloadEventEnd: number; + readonly unloadEventStart: number; + readonly secureConnectionStart: number; + toJSON(): any; +} + +declare var PerformanceTiming: { + prototype: PerformanceTiming; + new(): PerformanceTiming; +} + interface Position { readonly coords: Coordinates; readonly timestamp: number; @@ -727,9 +881,156 @@ declare var ProgressEvent: { new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } +interface PushManager { + getSubscription(): Promise; + permissionState(options?: PushSubscriptionOptionsInit): Promise; + subscribe(options?: PushSubscriptionOptionsInit): Promise; +} + +declare var PushManager: { + prototype: PushManager; + new(): PushManager; +} + +interface PushSubscription { + readonly endpoint: USVString; + readonly options: PushSubscriptionOptions; + getKey(name: string): ArrayBuffer | null; + toJSON(): any; + unsubscribe(): Promise; +} + +declare var PushSubscription: { + prototype: PushSubscription; + new(): PushSubscription; +} + +interface PushSubscriptionOptions { + readonly applicationServerKey: ArrayBuffer | null; + readonly userVisibleOnly: boolean; +} + +declare var PushSubscriptionOptions: { + prototype: PushSubscriptionOptions; + new(): PushSubscriptionOptions; +} + +interface ReadableStream { + readonly locked: boolean; + cancel(): Promise; + getReader(): ReadableStreamReader; +} + +declare var ReadableStream: { + prototype: ReadableStream; + new(): ReadableStream; +} + +interface ReadableStreamReader { + cancel(): Promise; + read(): Promise; + releaseLock(): void; +} + +declare var ReadableStreamReader: { + prototype: ReadableStreamReader; + new(): ReadableStreamReader; +} + +interface Request extends Object, Body { + readonly cache: string; + readonly credentials: string; + readonly destination: string; + readonly headers: Headers; + readonly integrity: string; + readonly keepalive: boolean; + readonly method: string; + readonly mode: string; + readonly redirect: string; + readonly referrer: string; + readonly referrerPolicy: string; + readonly type: string; + readonly url: string; + clone(): Request; +} + +declare var Request: { + prototype: Request; + new(input: Request | string, init?: RequestInit): Request; +} + +interface Response extends Object, Body { + readonly body: ReadableStream | null; + readonly headers: Headers; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly type: string; + readonly url: string; + clone(): Response; +} + +declare var Response: { + prototype: Response; + new(body?: any, init?: ResponseInit): Response; +} + +interface ServiceWorkerEventMap extends AbstractWorkerEventMap { + "statechange": Event; +} + +interface ServiceWorker extends EventTarget, AbstractWorker { + onstatechange: (this: ServiceWorker, ev: Event) => any; + readonly scriptURL: USVString; + readonly state: string; + postMessage(message: any, transfer?: any[]): void; + addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorker: { + prototype: ServiceWorker; + new(): ServiceWorker; +} + +interface ServiceWorkerRegistrationEventMap { + "updatefound": Event; +} + +interface ServiceWorkerRegistration extends EventTarget { + readonly active: ServiceWorker | null; + readonly installing: ServiceWorker | null; + onupdatefound: (this: ServiceWorkerRegistration, ev: Event) => any; + readonly pushManager: PushManager; + readonly scope: USVString; + readonly sync: SyncManager; + readonly waiting: ServiceWorker | null; + getNotifications(filter?: GetNotificationOptions): any; + showNotification(title: string, options?: NotificationOptions): Promise; + unregister(): Promise; + update(): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerRegistration: { + prototype: ServiceWorkerRegistration; + new(): ServiceWorkerRegistration; +} + +interface SyncManager { + getTags(): any; + register(tag: string): Promise; +} + +declare var SyncManager: { + prototype: SyncManager; + new(): SyncManager; +} + interface WebSocketEventMap { "close": CloseEvent; - "error": ErrorEvent; + "error": Event; "message": MessageEvent; "open": Event; } @@ -739,7 +1040,7 @@ interface WebSocket extends EventTarget { readonly bufferedAmount: number; readonly extensions: string; onclose: (this: WebSocket, ev: CloseEvent) => any; - onerror: (this: WebSocket, ev: ErrorEvent) => any; + onerror: (this: WebSocket, ev: Event) => any; onmessage: (this: WebSocket, ev: MessageEvent) => any; onopen: (this: WebSocket, ev: Event) => any; readonly protocol: string; @@ -770,7 +1071,7 @@ interface WorkerEventMap extends AbstractWorkerEventMap { interface Worker extends EventTarget, AbstractWorker { onmessage: (this: Worker, ev: MessageEvent) => any; - postMessage(message: any, ports?: any): void; + postMessage(message: any, transfer?: any[]): void; terminate(): void; addEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -791,6 +1092,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly response: any; readonly responseText: string; responseType: string; + readonly responseURL: string; readonly responseXML: any; readonly status: number; readonly statusText: string; @@ -798,7 +1100,6 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly upload: XMLHttpRequestUpload; withCredentials: boolean; msCaching?: string; - readonly responseURL: string; abort(): void; getAllResponseHeaders(): string; getResponseHeader(header: string): string | null; @@ -825,11 +1126,10 @@ declare var XMLHttpRequest: { readonly LOADING: number; readonly OPENED: number; readonly UNSENT: number; - create(): XMLHttpRequest; } interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { - addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -848,6 +1148,18 @@ interface AbstractWorker { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface Body { + readonly bodyUsed: boolean; + arrayBuffer(): Promise; + blob(): Promise; + json(): Promise; + text(): Promise; +} + +interface GlobalFetch { + fetch(input: RequestInfo, init?: RequestInit): Promise; +} + interface MSBaseReaderEventMap { "abort": Event; "error": ErrorEvent; @@ -874,7 +1186,16 @@ interface MSBaseReader { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface NavigatorBeacon { + sendBeacon(url: USVString, data?: BodyInit): boolean; +} + +interface NavigatorConcurrentHardware { + readonly hardwareConcurrency: number; +} + interface NavigatorID { + readonly appCodeName: string; readonly appName: string; readonly appVersion: string; readonly platform: string; @@ -920,6 +1241,81 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface Client { + readonly frameType: string; + readonly id: string; + readonly url: USVString; + postMessage(message: any, transfer?: any[]): void; +} + +declare var Client: { + prototype: Client; + new(): Client; +} + +interface Clients { + claim(): Promise; + get(id: string): Promise; + matchAll(options?: ClientQueryOptions): any; + openWindow(url: USVString): Promise; +} + +declare var Clients: { + prototype: Clients; + new(): Clients; +} + +interface DedicatedWorkerGlobalScopeEventMap extends WorkerGlobalScopeEventMap { + "message": MessageEvent; +} + +interface DedicatedWorkerGlobalScope extends WorkerGlobalScope { + onmessage: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any; + close(): void; + postMessage(message: any, transfer?: any[]): void; + addEventListener(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var DedicatedWorkerGlobalScope: { + prototype: DedicatedWorkerGlobalScope; + new(): DedicatedWorkerGlobalScope; +} + +interface ExtendableEvent extends Event { + waitUntil(f: Promise): void; +} + +declare var ExtendableEvent: { + prototype: ExtendableEvent; + new(type: string, eventInitDict?: ExtendableEventInit): ExtendableEvent; +} + +interface ExtendableMessageEvent extends ExtendableEvent { + readonly data: any; + readonly lastEventId: string; + readonly origin: string; + readonly ports: MessagePort[] | null; + readonly source: Client | ServiceWorker | MessagePort | null; +} + +declare var ExtendableMessageEvent: { + prototype: ExtendableMessageEvent; + new(type: string, eventInitDict?: ExtendableMessageEventInit): ExtendableMessageEvent; +} + +interface FetchEvent extends ExtendableEvent { + readonly clientId: string | null; + readonly isReload: boolean; + readonly request: Request; + respondWith(r: Promise): void; +} + +declare var FetchEvent: { + prototype: FetchEvent; + new(type: string, eventInitDict: FetchEventInit): FetchEvent; +} + interface FileReaderSync { readAsArrayBuffer(blob: Blob): any; readAsBinaryString(blob: Blob): void; @@ -932,17 +1328,105 @@ declare var FileReaderSync: { new(): FileReaderSync; } -interface WorkerGlobalScopeEventMap extends DedicatedWorkerGlobalScopeEventMap { +interface NotificationEvent extends ExtendableEvent { + readonly action: string; + readonly notification: Notification; +} + +declare var NotificationEvent: { + prototype: NotificationEvent; + new(type: string, eventInitDict: NotificationEventInit): NotificationEvent; +} + +interface PushEvent extends ExtendableEvent { + readonly data: PushMessageData | null; +} + +declare var PushEvent: { + prototype: PushEvent; + new(type: string, eventInitDict?: PushEventInit): PushEvent; +} + +interface PushMessageData { + arrayBuffer(): ArrayBuffer; + blob(): Blob; + json(): JSON; + text(): USVString; +} + +declare var PushMessageData: { + prototype: PushMessageData; + new(): PushMessageData; +} + +interface ServiceWorkerGlobalScopeEventMap extends WorkerGlobalScopeEventMap { + "activate": ExtendableEvent; + "fetch": FetchEvent; + "install": ExtendableEvent; + "message": ExtendableMessageEvent; + "notificationclick": NotificationEvent; + "notificationclose": NotificationEvent; + "push": PushEvent; + "pushsubscriptionchange": ExtendableEvent; + "sync": SyncEvent; +} + +interface ServiceWorkerGlobalScope extends WorkerGlobalScope { + readonly clients: Clients; + onactivate: (this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any; + onfetch: (this: ServiceWorkerGlobalScope, ev: FetchEvent) => any; + oninstall: (this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any; + onmessage: (this: ServiceWorkerGlobalScope, ev: ExtendableMessageEvent) => any; + onnotificationclick: (this: ServiceWorkerGlobalScope, ev: NotificationEvent) => any; + onnotificationclose: (this: ServiceWorkerGlobalScope, ev: NotificationEvent) => any; + onpush: (this: ServiceWorkerGlobalScope, ev: PushEvent) => any; + onpushsubscriptionchange: (this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any; + onsync: (this: ServiceWorkerGlobalScope, ev: SyncEvent) => any; + readonly registration: ServiceWorkerRegistration; + skipWaiting(): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerGlobalScope: { + prototype: ServiceWorkerGlobalScope; + new(): ServiceWorkerGlobalScope; +} + +interface SyncEvent extends ExtendableEvent { + readonly lastChance: boolean; + readonly tag: string; +} + +declare var SyncEvent: { + prototype: SyncEvent; + new(type: string, init: SyncEventInit): SyncEvent; +} + +interface WindowClient extends Client { + readonly focused: boolean; + readonly visibilityState: string; + focus(): Promise; + navigate(url: USVString): Promise; +} + +declare var WindowClient: { + prototype: WindowClient; + new(): WindowClient; +} + +interface WorkerGlobalScopeEventMap { "error": ErrorEvent; } -interface WorkerGlobalScope extends EventTarget, WorkerUtils, DedicatedWorkerGlobalScope, WindowConsole { +interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, GlobalFetch { + readonly caches: CacheStorage; + readonly isSecureContext: boolean; readonly location: WorkerLocation; onerror: (this: WorkerGlobalScope, ev: ErrorEvent) => any; + readonly performance: Performance; readonly self: WorkerGlobalScope; - close(): void; msWriteProfilerMark(profilerMarkName: string): void; - toString(): string; addEventListener(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -957,6 +1441,7 @@ interface WorkerLocation { readonly host: string; readonly hostname: string; readonly href: string; + readonly origin: string; readonly pathname: string; readonly port: string; readonly protocol: string; @@ -969,7 +1454,7 @@ declare var WorkerLocation: { new(): WorkerLocation; } -interface WorkerNavigator extends Object, NavigatorID, NavigatorOnLine { +interface WorkerNavigator extends Object, NavigatorID, NavigatorOnLine, NavigatorBeacon, NavigatorConcurrentHardware { readonly hardwareConcurrency: number; } @@ -978,17 +1463,6 @@ declare var WorkerNavigator: { new(): WorkerNavigator; } -interface DedicatedWorkerGlobalScopeEventMap { - "message": MessageEvent; -} - -interface DedicatedWorkerGlobalScope { - onmessage: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any; - postMessage(data: any): void; - addEventListener(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - interface WorkerUtils extends Object, WindowBase64 { readonly indexedDB: IDBFactory; readonly msIndexedDB: IDBFactory; @@ -1005,6 +1479,14 @@ interface WorkerUtils extends Object, WindowBase64 { setTimeout(handler: any, timeout?: any, ...args: any[]): number; } +interface ErrorEventInit { + message?: string; + filename?: string; + lineno?: number; + conlno?: number; + error?: any; +} + interface BlobPropertyBag { type?: string; endings?: string; @@ -1019,15 +1501,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -interface MessageEventInit extends EventInit { - data?: any; - origin?: string; - lastEventId?: string; - channel?: string; - source?: any; - ports?: MessagePort[]; -} - interface ProgressEventInit extends EventInit { lengthComputable?: boolean; loaded?: number; @@ -1219,18 +1692,6 @@ interface PositionCallback { interface PositionErrorCallback { (error: PositionError): void; } -interface MediaQueryListListener { - (mql: MediaQueryList): void; -} -interface MSLaunchUriCallback { - (): void; -} -interface MSUnsafeFunctionCallback { - (): any; -} -interface MSExecAtPriorityFunctionCallback { - (...args: any[]): any; -} interface DecodeSuccessCallback { (decodedData: AudioBuffer): void; } @@ -1240,12 +1701,22 @@ interface DecodeErrorCallback { interface FunctionStringCallback { (data: string): void; } -declare var location: WorkerLocation; -declare var onerror: (this: WorkerGlobalScope, ev: ErrorEvent) => any; -declare var self: WorkerGlobalScope; +interface ForEachCallback { + (keyId: any, status: string): void; +} +interface NotificationPermissionCallback { + (permission: string): void; +} +declare var onmessage: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any; declare function close(): void; +declare function postMessage(message: any, transfer?: any[]): void; +declare var caches: CacheStorage; +declare var isSecureContext: boolean; +declare var location: WorkerLocation; +declare var onerror: (this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any; +declare var performance: Performance; +declare var self: WorkerGlobalScope; declare function msWriteProfilerMark(profilerMarkName: string): void; -declare function toString(): string; declare function dispatchEvent(evt: Event): boolean; declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; declare var indexedDB: IDBFactory; @@ -1263,12 +1734,16 @@ declare function setTimeout(handler: (...args: any[]) => void, timeout: number): declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; declare function atob(encodedString: string): string; declare function btoa(rawString: string): string; -declare var onmessage: (this: WorkerGlobalScope, ev: MessageEvent) => any; -declare function postMessage(data: any): void; declare var console: Console; -declare function addEventListener(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; +declare function fetch(input: RequestInfo, init?: RequestInit): Promise; +declare function dispatchEvent(evt: Event): boolean; +declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function addEventListener(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; type AlgorithmIdentifier = string | Algorithm; +type BodyInit = any; type IDBKeyPath = string; +type RequestInfo = Request | string; +type USVString = string; type IDBValidKey = number | string | Date | IDBArrayKey; type BufferSource = ArrayBuffer | ArrayBufferView; \ No newline at end of file diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index f3737c76c46..2fc15c3a256 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -734,9 +734,9 @@ declare namespace ts.server.protocol { */ formatOptions?: FormatCodeSettings; /** - * The host's additional supported file extensions + * The host's additional supported .js file extensions */ - extraFileExtensions?: FileExtensionInfo[]; + extraFileExtensions?: JsFileExtensionInfo[]; } /** * Configure request; value of command field is "configure". Specifies @@ -905,6 +905,10 @@ declare namespace ts.server.protocol { * List of files names that should be recompiled */ fileNames: string[]; + /** + * true if project uses outFile or out compiler option + */ + projectUsesOutFile: boolean; } /** * Response for CompileOnSaveAffectedFileListRequest request; @@ -1352,6 +1356,17 @@ declare namespace ts.server.protocol { command: CommandTypes.Geterr; arguments: GeterrRequestArgs; } + type RequestCompletedEventName = "requestCompleted"; + /** + * Event that is sent when server have finished processing request with specified id. + */ + interface RequestCompletedEvent extends Event { + event: RequestCompletedEventName; + body: RequestCompletedEventBody; + } + interface RequestCompletedEventBody { + request_seq: number; + } /** * Item of diagnostic information found in a DiagnosticEvent message. */ @@ -1722,12 +1737,14 @@ declare namespace ts.server.protocol { insertSpaceAfterCommaDelimiter?: boolean; insertSpaceAfterSemicolonInForStatements?: boolean; insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterConstructor?: boolean; insertSpaceAfterKeywordsInControlFlowStatements?: boolean; insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + insertSpaceBeforeFunctionParenthesis?: boolean; placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; } @@ -1773,6 +1790,7 @@ declare namespace ts.server.protocol { outDir?: string; outFile?: string; paths?: MapLike; + plugins?: PluginImport[]; preserveConstEnums?: boolean; project?: string; reactNamespace?: string; @@ -1796,9 +1814,10 @@ declare namespace ts.server.protocol { namespace JsxEmit { type None = "None"; type Preserve = "Preserve"; + type ReactNative = "ReactNative"; type React = "React"; } - type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React; + type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React | JsxEmit.ReactNative; namespace ModuleKind { type None = "None"; type CommonJS = "CommonJS"; @@ -1854,17 +1873,25 @@ declare namespace ts.server.protocol { [option: string]: string[] | boolean | undefined; } - interface FileExtensionInfo { + interface JsFileExtensionInfo { extension: string; - scriptKind: ScriptKind; isMixedContent: boolean; } + /** + * Type of objects whose values are all of the same type. + * The `in` and `for-in` operators can *not* be safely used, + * since `Object.prototype` may be modified by outside code. + */ interface MapLike { [index: string]: T; } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; + interface PluginImport { + name: string; + } + + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[]; } declare namespace ts { // these types are empty stubs for types from services and should not be used directly diff --git a/lib/tsc.js b/lib/tsc.js index 840e832f3bf..be8abfb4a0d 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -88,32 +88,32 @@ var ts; var measures; function mark(markName) { if (enabled) { - marks[markName] = ts.timestamp(); - counts[markName] = (counts[markName] || 0) + 1; + marks.set(markName, ts.timestamp()); + counts.set(markName, (counts.get(markName) || 0) + 1); profilerEvent(markName); } } performance.mark = mark; function measure(measureName, startMarkName, endMarkName) { if (enabled) { - var end = endMarkName && marks[endMarkName] || ts.timestamp(); - var start = startMarkName && marks[startMarkName] || profilerStart; - measures[measureName] = (measures[measureName] || 0) + (end - start); + var end = endMarkName && marks.get(endMarkName) || ts.timestamp(); + var start = startMarkName && marks.get(startMarkName) || profilerStart; + measures.set(measureName, (measures.get(measureName) || 0) + (end - start)); } } performance.measure = measure; function getCount(markName) { - return counts && counts[markName] || 0; + return counts && counts.get(markName) || 0; } performance.getCount = getCount; function getDuration(measureName) { - return measures && measures[measureName] || 0; + return measures && measures.get(measureName) || 0; } performance.getDuration = getDuration; function forEachMeasure(cb) { - for (var key in measures) { - cb(key, measures[key]); - } + measures.forEach(function (measure, key) { + cb(key, measure); + }); } performance.forEachMeasure = forEachMeasure; function enable() { @@ -132,22 +132,96 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.2.0"; + ts.version = "2.3.0"; })(ts || (ts = {})); (function (ts) { - var createObject = Object.create; - ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - function createMap(template) { - var map = createObject(null); + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(undefined, { usage: "sort", sensitivity: "accent" }) : undefined; + ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + function createDictionaryObject() { + var map = Object.create(null); map["__"] = undefined; delete map["__"]; + return map; + } + function createMap() { + return new MapCtr(); + } + ts.createMap = createMap; + function createMapFromTemplate(template) { + var map = new MapCtr(); for (var key in template) if (hasOwnProperty.call(template, key)) { - map[key] = template[key]; + map.set(key, template[key]); } return map; } - ts.createMap = createMap; + ts.createMapFromTemplate = createMapFromTemplate; + var MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); + function shimMap() { + var MapIterator = (function () { + function MapIterator(data, selector) { + this.index = 0; + this.data = data; + this.selector = selector; + this.keys = Object.keys(data); + } + MapIterator.prototype.next = function () { + var index = this.index; + if (index < this.keys.length) { + this.index++; + return { value: this.selector(this.data, this.keys[index]), done: false }; + } + return { value: undefined, done: true }; + }; + return MapIterator; + }()); + return (function () { + function class_1() { + this.data = createDictionaryObject(); + this.size = 0; + } + class_1.prototype.get = function (key) { + return this.data[key]; + }; + class_1.prototype.set = function (key, value) { + if (!this.has(key)) { + this.size++; + } + this.data[key] = value; + return this; + }; + class_1.prototype.has = function (key) { + return key in this.data; + }; + class_1.prototype.delete = function (key) { + if (this.has(key)) { + this.size--; + delete this.data[key]; + return true; + } + return false; + }; + class_1.prototype.clear = function () { + this.data = createDictionaryObject(); + this.size = 0; + }; + class_1.prototype.keys = function () { + return new MapIterator(this.data, function (_data, key) { return key; }); + }; + class_1.prototype.values = function () { + return new MapIterator(this.data, function (data, key) { return data[key]; }); + }; + class_1.prototype.entries = function () { + return new MapIterator(this.data, function (data, key) { return [key, data[key]]; }); + }; + class_1.prototype.forEach = function (action) { + for (var key in this.data) { + action(this.data[key], key); + } + }; + return class_1; + }()); + } function createFileMap(keyMapper) { var files = createMap(); return { @@ -160,32 +234,27 @@ var ts; clear: clear, }; function forEachValueInMap(f) { - for (var key in files) { - f(key, files[key]); - } + files.forEach(function (file, key) { + f(key, file); + }); } function getKeys() { - var keys = []; - for (var key in files) { - keys.push(key); - } - return keys; + return arrayFrom(files.keys()); } function get(path) { - return files[toKey(path)]; + return files.get(toKey(path)); } function set(path, value) { - files[toKey(path)] = value; + files.set(toKey(path), value); } function contains(path) { - return toKey(path) in files; + return files.has(toKey(path)); } function remove(path) { - var key = toKey(path); - delete files[key]; + files.delete(toKey(path)); } function clear() { - files = createMap(); + files.clear(); } function toKey(path) { return keyMapper ? keyMapper(path) : path; @@ -199,9 +268,13 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + function length(array) { + return array ? array.length : 0; + } + ts.length = length; function forEach(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -220,7 +293,7 @@ var ts; ts.zipWith = zipWith; function every(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -230,7 +303,7 @@ var ts; } ts.every = every; function find(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -239,8 +312,17 @@ var ts; return undefined; } ts.find = find; + function findIndex(array, predicate) { + for (var i = 0; i < array.length; i++) { + if (predicate(array[i], i)) { + return i; + } + } + return -1; + } + ts.findIndex = findIndex; function findMap(array, callback) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -263,7 +345,7 @@ var ts; ts.contains = contains; function indexOf(array, value) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -273,7 +355,7 @@ var ts; } ts.indexOf = indexOf; function indexOfAnyCharCode(text, charCodes, start) { - for (var i = start || 0, len = text.length; i < len; i++) { + for (var i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -460,21 +542,18 @@ var ts; return result; } ts.spanMap = spanMap; - function mapObject(object, f) { - var result; - if (object) { - result = {}; - for (var _i = 0, _a = getOwnKeys(object); _i < _a.length; _i++) { - var v = _a[_i]; - var _b = f(v, object[v]) || [undefined, undefined], key = _b[0], value = _b[1]; - if (key !== undefined) { - result[key] = value; - } - } + function mapEntries(map, f) { + if (!map) { + return undefined; } + var result = createMap(); + map.forEach(function (value, key) { + var _a = f(key, value), newKey = _a[0], newValue = _a[1]; + result.set(newKey, newValue); + }); return result; } - ts.mapObject = mapObject; + ts.mapEntries = mapEntries; function some(array, predicate) { if (array) { if (predicate) { @@ -758,38 +837,55 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; - function forEachProperty(map, callback) { - var result; - for (var key in map) { - if (result = callback(map[key], key)) - break; + function arrayFrom(iterator) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(value); } return result; + var _b; } - ts.forEachProperty = forEachProperty; - function someProperties(map, predicate) { - for (var key in map) { - if (!predicate || predicate(map[key], key)) - return true; + ts.arrayFrom = arrayFrom; + function convertToArray(iterator, f) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(f(value)); } - return false; + return result; + var _b; } - ts.someProperties = someProperties; - function copyProperties(source, target) { - for (var key in source) { - target[key] = source[key]; + ts.convertToArray = convertToArray; + function forEachEntry(map, callback) { + var iterator = map.entries(); + for (var _a = iterator.next(), pair = _a.value, done = _a.done; !done; _b = iterator.next(), pair = _b.value, done = _b.done, _b) { + var key = pair[0], value = pair[1]; + var result = callback(value, key); + if (result) { + return result; + } } + return undefined; + var _b; } - ts.copyProperties = copyProperties; - function appendProperty(map, key, value) { - if (key === undefined || value === undefined) - return map; - if (map === undefined) - map = createMap(); - map[key] = value; - return map; + ts.forEachEntry = forEachEntry; + function forEachKey(map, callback) { + var iterator = map.keys(); + for (var _a = iterator.next(), key = _a.value, done = _a.done; !done; _b = iterator.next(), key = _b.value, done = _b.done, _b) { + var result = callback(key); + if (result) { + return result; + } + } + return undefined; + var _b; } - ts.appendProperty = appendProperty; + ts.forEachKey = forEachKey; + function copyEntries(source, target) { + source.forEach(function (value, key) { + target.set(key, value); + }); + } + ts.copyEntries = copyEntries; function assign(t) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -805,14 +901,6 @@ var ts; return t; } ts.assign = assign; - function reduceProperties(map, callback, initial) { - var result = initial; - for (var key in map) { - result = callback(result, map[key], String(key)); - } - return result; - } - ts.reduceProperties = reduceProperties; function equalOwnProperties(left, right, equalityComparer) { if (left === right) return true; @@ -837,23 +925,14 @@ var ts; var result = createMap(); for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { var value = array_8[_i]; - result[makeKey(value)] = makeValue ? makeValue(value) : value; + result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; } ts.arrayToMap = arrayToMap; - function isEmpty(map) { - for (var id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - ts.isEmpty = isEmpty; function cloneMap(map) { var clone = createMap(); - copyProperties(map, clone); + copyEntries(map, clone); return clone; } ts.cloneMap = cloneMap; @@ -880,27 +959,32 @@ var ts; return result; } ts.extend = extend; - function multiMapAdd(map, key, value) { - var values = map[key]; + function createMultiMap() { + var map = createMap(); + map.add = multiMapAdd; + map.remove = multiMapRemove; + return map; + } + ts.createMultiMap = createMultiMap; + function multiMapAdd(key, value) { + var values = this.get(key); if (values) { values.push(value); - return values; } else { - return map[key] = [value]; + this.set(key, values = [value]); } + return values; } - ts.multiMapAdd = multiMapAdd; - function multiMapRemove(map, key, value) { - var values = map[key]; + function multiMapRemove(key, value) { + var values = this.get(key); if (values) { unorderedRemoveItem(values, value); if (!values.length) { - delete map[key]; + this.delete(key); } } } - ts.multiMapRemove = multiMapRemove; function isArray(value) { return Array.isArray ? Array.isArray(value) : value instanceof Array; } @@ -976,6 +1060,7 @@ var ts; baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } + ts.formatStringFromArgs = formatStringFromArgs; ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; @@ -1077,8 +1162,10 @@ var ts; if (b === undefined) return 1; if (ignoreCase) { - if (ts.collator && String.prototype.localeCompare) { - var result = a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); + if (ts.collator) { + var result = ts.localeCompareIsCorrect ? + ts.collator.compare(a, b) : + a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 : result > 0 ? 1 : 0; } a = a.toUpperCase(); @@ -1460,36 +1547,26 @@ var ts; var singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; var singleAsteriskRegexFragmentOther = "[^/]*"; function getRegularExpressionForWildcard(specs, basePath, usage) { + var patterns = getRegularExpressionsForWildcards(specs, basePath, usage); + if (!patterns || !patterns.length) { + return undefined; + } + var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var terminator = usage === "exclude" ? "($|/)" : "$"; + return "^(" + pattern + ")" + terminator; + } + ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; + function getRegularExpressionsForWildcards(specs, basePath, usage) { if (specs === undefined || specs.length === 0) { return undefined; } var replaceWildcardCharacter = usage === "files" ? replaceWildCardCharacterFiles : replaceWildCardCharacterOther; var singleAsteriskRegexFragment = usage === "files" ? singleAsteriskRegexFragmentFiles : singleAsteriskRegexFragmentOther; var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; - var pattern = ""; - var hasWrittenSubpattern = false; - for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { - var spec = specs_1[_i]; - if (!spec) { - continue; - } - var subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); - if (subPattern === undefined) { - continue; - } - if (hasWrittenSubpattern) { - pattern += "|"; - } - pattern += "(" + subPattern + ")"; - hasWrittenSubpattern = true; - } - if (!pattern) { - return undefined; - } - var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return flatMap(specs, function (spec) { + return spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + }); } - ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function isImplicitGlob(lastPathComponent) { return !/[.*?]/.test(lastPathComponent); } @@ -1559,6 +1636,7 @@ var ts; currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); return { + includeFilePatterns: map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -1571,34 +1649,48 @@ var ts; currentDirectory = normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; - var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); + var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return new RegExp(pattern, regexFlag); }); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); var excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); - var result = []; + var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]]; + var comparer = useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive; for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; visitDirectory(basePath, combinePaths(currentDirectory, basePath)); } - return result; + return flatten(results); function visitDirectory(path, absolutePath) { var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; + files = files.slice().sort(comparer); + directories = directories.slice().sort(comparer); + var _loop_1 = function (current) { + var name = combinePaths(path, current); + var absoluteName = combinePaths(absolutePath, current); + if (extensions && !fileExtensionIsAny(name, extensions)) + return "continue"; + if (excludeRegex && excludeRegex.test(absoluteName)) + return "continue"; + if (!includeFileRegexes) { + results[0].push(name); + } + else { + var includeIndex = findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); }); + if (includeIndex !== -1) { + results[includeIndex].push(name); + } + } + }; for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var current = files_1[_i]; - var name_1 = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); - if ((!extensions || fileExtensionIsAny(name_1, extensions)) && - (!includeFileRegex || includeFileRegex.test(absoluteName)) && - (!excludeRegex || !excludeRegex.test(absoluteName))) { - result.push(name_1); - } + _loop_1(current); } for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var current = directories_1[_b]; - var name_2 = combinePaths(path, current); + var name = combinePaths(path, current); var absoluteName = combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { - visitDirectory(name_2, absoluteName); + visitDirectory(name, absoluteName); } } } @@ -1614,14 +1706,14 @@ var ts; includeBasePaths.push(getIncludeBasePath(absolute)); } includeBasePaths.sort(useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); - var _loop_1 = function (includeBasePath) { + var _loop_2 = function (includeBasePath) { if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { basePaths.push(includeBasePath); } }; for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) { var includeBasePath = includeBasePaths_1[_a]; - _loop_1(includeBasePath); + _loop_2(includeBasePath); } } return basePaths; @@ -1661,13 +1753,13 @@ var ts; var allSupportedExtensions = ts.supportedTypeScriptExtensions.concat(ts.supportedJavascriptExtensions); function getSupportedExtensions(options, extraFileExtensions) { var needAllExtensions = options && options.allowJs; - if (!extraFileExtensions || extraFileExtensions.length === 0) { + if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } - var extensions = (needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions).slice(0); + var extensions = allSupportedExtensions.slice(0); for (var _i = 0, extraFileExtensions_1 = extraFileExtensions; _i < extraFileExtensions_1.length; _i++) { var extInfo = extraFileExtensions_1[_i]; - if (needAllExtensions || extInfo.scriptKind === 3) { + if (extensions.indexOf(extInfo.extension) === -1) { extensions.push(extInfo.extension); } } @@ -1698,30 +1790,30 @@ var ts; function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { - return adjustExtensionPriority(i); + return adjustExtensionPriority(i, supportedExtensions); } } return 0; } ts.getExtensionPriority = getExtensionPriority; - function adjustExtensionPriority(extensionPriority) { + function adjustExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2) { return 0; } - else if (extensionPriority < 5) { + else if (extensionPriority < supportedExtensions.length) { return 2; } else { - return 5; + return supportedExtensions.length; } } ts.adjustExtensionPriority = adjustExtensionPriority; - function getNextLowestExtensionPriority(extensionPriority) { + function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2) { return 2; } else { - return 5; + return supportedExtensions.length; } } ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority; @@ -2068,32 +2160,32 @@ var ts; var useNonPollingWatchers = process.env["TSC_NONPOLLING_WATCHER"]; function createWatchedFileSet() { var dirWatchers = ts.createMap(); - var fileWatcherCallbacks = ts.createMap(); + var fileWatcherCallbacks = ts.createMultiMap(); return { addFile: addFile, removeFile: removeFile }; function reduceDirWatcherRefCountForFile(fileName) { var dirName = ts.getDirectoryPath(fileName); - var watcher = dirWatchers[dirName]; + var watcher = dirWatchers.get(dirName); if (watcher) { watcher.referenceCount -= 1; if (watcher.referenceCount <= 0) { watcher.close(); - delete dirWatchers[dirName]; + dirWatchers.delete(dirName); } } } function addDirWatcher(dirPath) { - var watcher = dirWatchers[dirPath]; + var watcher = dirWatchers.get(dirPath); if (watcher) { watcher.referenceCount += 1; return; } watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); watcher.referenceCount = 1; - dirWatchers[dirPath] = watcher; + dirWatchers.set(dirPath, watcher); return; } function addFileWatcherCallback(filePath, callback) { - ts.multiMapAdd(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.add(filePath, callback); } function addFile(fileName, callback) { addFileWatcherCallback(fileName, callback); @@ -2105,16 +2197,19 @@ var ts; reduceDirWatcherRefCountForFile(watchedFile.fileName); } function removeFileWatcherCallback(filePath, callback) { - ts.multiMapRemove(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.remove(filePath, callback); } function fileEventHandler(eventName, relativeFileName, baseDirPath) { var fileName = typeof relativeFileName !== "string" ? undefined : ts.getNormalizedAbsolutePath(relativeFileName, baseDirPath); - if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks[fileName]) { - for (var _i = 0, _a = fileWatcherCallbacks[fileName]; _i < _a.length; _i++) { - var fileCallback = _a[_i]; - fileCallback(fileName); + if ((eventName === "change" || eventName === "rename")) { + var callbacks = fileWatcherCallbacks.get(fileName); + if (callbacks) { + for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) { + var fileCallback = callbacks_1[_i]; + fileCallback(fileName); + } } } } @@ -2179,10 +2274,10 @@ var ts; if (entry === "." || entry === "..") { continue; } - var name_3 = ts.combinePaths(path, entry); + var name = ts.combinePaths(path, entry); var stat = void 0; try { - stat = _fs.statSync(name_3); + stat = _fs.statSync(name); } catch (e) { continue; @@ -2256,7 +2351,7 @@ var ts; }, watchDirectory: function (directoryName, callback, recursive) { var options; - if (!directoryExists(directoryName)) { + if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { return noOpFileWatcher; } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { @@ -2271,6 +2366,9 @@ var ts; } ; }); + function isUNCPath(s) { + return s.length > 2 && s.charCodeAt(0) === 47 && s.charCodeAt(1) === 47; + } }, resolvePath: function (path) { return _path.resolve(path); @@ -2470,7 +2568,7 @@ var ts; _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, 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." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." }, 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." }, @@ -2581,6 +2679,7 @@ var ts; 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." }, + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", message: "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules." }, 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_Set_the_experimentalDecorators_option_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_Set_t_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", message: "Generators are only available when targeting ECMAScript 2015 or higher." }, @@ -2627,6 +2726,7 @@ var ts; Global_module_exports_may_only_appear_at_top_level: { code: 1316, category: ts.DiagnosticCategory.Error, key: "Global_module_exports_may_only_appear_at_top_level_1316", message: "Global module exports may only appear at top level." }, A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, 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." }, @@ -2856,6 +2956,10 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, + A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: { code: 2545, category: ts.DiagnosticCategory.Error, key: "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", message: "A mixin class must have a constructor with a single rest parameter of type 'any[]'." }, + Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: { code: 2546, category: ts.DiagnosticCategory.Error, key: "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", message: "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union 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." }, @@ -2865,6 +2969,8 @@ var ts; 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" }, + JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, + Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: { code: 2649, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", message: "Cannot augment module '{0}' with value exports because it resolves to a non-module entity." }, 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." }, @@ -2913,9 +3019,15 @@ var ts; The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { code: 2696, category: ts.DiagnosticCategory.Error, key: "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", message: "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?" }, An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, + Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: { code: 2699, category: ts.DiagnosticCategory.Error, key: "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", message: "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'." }, Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, + An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: { code: 2705, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", message: "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option." }, + Required_type_parameters_may_not_follow_optional_type_parameters: { code: 2706, category: ts.DiagnosticCategory.Error, key: "Required_type_parameters_may_not_follow_optional_type_parameters_2706", message: "Required type parameters may not follow optional type parameters." }, + Generic_type_0_requires_between_1_and_2_type_arguments: { code: 2707, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_between_1_and_2_type_arguments_2707", message: "Generic type '{0}' requires between {1} and {2} type arguments." }, 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}'." }, @@ -2926,8 +3038,8 @@ var ts; 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}'." }, + 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}'." }, @@ -2990,6 +3102,7 @@ var ts; Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { code: 4090, category: ts.DiagnosticCategory.Message, key: "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", message: "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", message: "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4092, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", message: "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'." }, + extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced: { code: 4093, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced_4093", message: "'extends' clause of exported class '{0}' refers to a type whose name cannot be referenced." }, 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." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, @@ -3035,7 +3148,7 @@ var ts; 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." }, + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'" }, 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" }, @@ -3050,6 +3163,7 @@ var ts; LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION_6037", message: "LOCATION" }, DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY_6038", message: "DIRECTORY" }, STRATEGY: { code: 6039, category: ts.DiagnosticCategory.Message, key: "STRATEGY_6039", message: "STRATEGY" }, + FILE_OR_DIRECTORY: { code: 6040, category: ts.DiagnosticCategory.Message, key: "FILE_OR_DIRECTORY_6040", message: "FILE OR 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." }, @@ -3083,7 +3197,8 @@ var ts; 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_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, - 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'" }, + Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'" }, + File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, @@ -3097,12 +3212,12 @@ var ts; Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, - Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", message: "Loading module as file / folder, candidate module location '{0}', target file type '{1}'." }, File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, - Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, - package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, + package_json_does_not_have_a_0_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_0_field_6100", message: "'package.json' does not have a '{0}' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, @@ -3139,7 +3254,6 @@ var ts; Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, - No_types_specified_in_package_json_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json', so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, @@ -3149,6 +3263,8 @@ var ts; Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, + Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, + Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, 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." }, @@ -3190,7 +3306,7 @@ var ts; 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." }, 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." }, - 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." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: { 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' clause." }, 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." }, Language_service_is_disabled: { code: 9004, category: ts.DiagnosticCategory.Error, key: "Language_service_is_disabled_9004", message: "Language service is disabled." }, 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'." }, @@ -3205,22 +3321,26 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, - Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, - Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, - Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, + Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: {0}" }, + Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, + Add_this_to_unresolved_variable: { code: 90008, category: ts.DiagnosticCategory.Message, key: "Add_this_to_unresolved_variable_90008", message: "Add 'this.' to unresolved variable." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, }; })(ts || (ts = {})); var ts; @@ -3229,7 +3349,7 @@ var ts; return token >= 70; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = ts.createMap({ + var textToToken = ts.createMapFromTemplate({ "abstract": 116, "any": 118, "as": 117, @@ -3253,7 +3373,7 @@ var ts; "false": 85, "finally": 86, "for": 87, - "from": 138, + "from": 139, "function": 88, "get": 124, "if": 89, @@ -3271,27 +3391,28 @@ var ts; "new": 93, "null": 94, "number": 132, + "object": 133, "package": 110, "private": 111, "protected": 112, "public": 113, "readonly": 130, "require": 131, - "global": 139, + "global": 140, "return": 95, - "set": 133, + "set": 134, "static": 114, - "string": 134, + "string": 135, "super": 96, "switch": 97, - "symbol": 135, + "symbol": 136, "this": 98, "throw": 99, "true": 100, "try": 101, - "type": 136, + "type": 137, "typeof": 102, - "undefined": 137, + "undefined": 138, "var": 103, "void": 104, "while": 105, @@ -3299,7 +3420,7 @@ var ts; "yield": 115, "async": 119, "await": 120, - "of": 140, + "of": 141, "{": 16, "}": 17, "(": 18, @@ -3394,9 +3515,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var name_4 in source) { - result[source[name_4]] = name_4; - } + source.forEach(function (value, name) { + result[value] = name; + }); return result; } var tokenStrings = makeReverseMap(textToToken); @@ -3405,7 +3526,7 @@ var ts; } ts.tokenToString = tokenToString; function stringToToken(s) { - return textToToken[s]; + return textToToken.get(s); } ts.stringToToken = stringToToken; function computeLineStarts(text) { @@ -3465,7 +3586,6 @@ var ts; return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - var hasOwnProperty = Object.prototype.hasOwnProperty; function isWhiteSpace(ch) { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } @@ -3601,7 +3721,7 @@ var ts; 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++) { + for (var i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -3787,7 +3907,7 @@ var ts; if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { return false; } - for (var i = 1, n = name.length; i < n; i++) { + for (var i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -4124,8 +4244,11 @@ var ts; 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]; + if (ch >= 97 && ch <= 122) { + token = textToToken.get(tokenValue); + if (token !== undefined) { + return token; + } } } return token = 70; @@ -4791,6 +4914,19 @@ var ts; return undefined; } ts.getDeclarationOfKind = getDeclarationOfKind; + function findDeclaration(symbol, predicate) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; + if (predicate(declaration)) { + return declaration; + } + } + } + return undefined; + } + ts.findDeclaration = findDeclaration; var stringWriters = []; function getSingleLineStringWriter() { if (stringWriters.length === 0) { @@ -4811,7 +4947,8 @@ var ts; decreaseIndent: ts.noop, clear: function () { return str_1 = ""; }, trackSymbol: ts.noop, - reportInaccessibleThisError: ts.noop + reportInaccessibleThisError: ts.noop, + reportIllegalExtends: ts.noop }; } return stringWriters.pop(); @@ -4827,25 +4964,25 @@ var ts; } ts.getFullWidth = getFullWidth; function hasResolvedModule(sourceFile, moduleNameText) { - return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); + return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText)); } ts.hasResolvedModule = hasResolvedModule; function getResolvedModule(sourceFile, moduleNameText) { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules.get(moduleNameText) : undefined; } ts.getResolvedModule = getResolvedModule; function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { if (!sourceFile.resolvedModules) { sourceFile.resolvedModules = ts.createMap(); } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; + sourceFile.resolvedModules.set(moduleNameText, resolvedModule); } ts.setResolvedModule = setResolvedModule; function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { if (!sourceFile.resolvedTypeReferenceDirectiveNames) { sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); } - sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; + sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective); } ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; function moduleResolutionIsEqualTo(oldResolution, newResolution) { @@ -4864,7 +5001,7 @@ var ts; } for (var i = 0; i < names.length; i++) { var newResolution = newResolutions[i]; - var oldResolution = oldResolutions && oldResolutions[names[i]]; + var oldResolution = oldResolutions && oldResolutions.get(names[i]); var changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) : newResolution; @@ -4891,7 +5028,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 261) { + while (node && node.kind !== 264) { node = node.parent; } return node; @@ -4899,11 +5036,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 204: - case 232: - case 211: - case 212: + case 206: + case 234: case 213: + case 214: + case 215: return true; } return false; @@ -4968,18 +5105,18 @@ var ts; if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 292 && node._children.length > 0) { + if (node.kind === 296 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 262 && node.kind <= 288; + return node.kind >= 266 && node.kind <= 295; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 278 && node.kind <= 291; + return node.kind >= 282 && node.kind <= 295; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -5039,18 +5176,36 @@ var ts; } ts.getLiteralText = getLiteralText; function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 && text.length > 1) { + return node.kind === 8 + && (getNumericLiteralFlags(text, 6) & 6) !== 0; + } + ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + function getNumericLiteralFlags(text, hint) { + if (text.length > 1) { switch (text.charCodeAt(1)) { case 98: case 66: + return 2; case 111: case 79: - return true; + return 4; + case 120: + case 88: + return 1; + } + if (hint & 8) { + for (var i = text.length - 1; i >= 0; i--) { + switch (text.charCodeAt(i)) { + case 101: + case 69: + return 8; + } + } } } - return false; + return 0; } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + ts.getNumericLiteralFlags = getNumericLiteralFlags; function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; } @@ -5058,10 +5213,6 @@ var ts; 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, "_"); } @@ -5073,11 +5224,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 223 && node.parent.kind === 256; + return node.kind === 225 && node.parent.kind === 259; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 230 && + return node && node.kind === 232 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -5086,11 +5237,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node.kind === 230 && (!node.body); + return node && node.kind === 232 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 261 || - node.kind === 230 || + return node.kind === 264 || + node.kind === 232 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -5103,9 +5254,9 @@ var ts; return false; } switch (node.parent.kind) { - case 261: + case 264: return ts.isExternalModule(node.parent); - case 231: + case 233: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -5117,22 +5268,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 261: + case 264: + case 234: + case 259: case 232: - case 256: - case 230: - case 211: - case 212: case 213: - case 150: - case 149: + case 214: + case 215: case 151: + case 150: case 152: - case 225: - case 184: + case 153: + case 227: case 185: + case 186: return true; - case 204: + case 206: return parentNode && !isFunctionLike(parentNode); } return false; @@ -5159,7 +5310,7 @@ var ts; case 9: case 8: return name.text; - case 142: + case 143: if (isStringOrNumericLiteral(name.expression)) { return name.expression.text; } @@ -5170,10 +5321,10 @@ var ts; function entityNameToString(name) { switch (name.kind) { case 70: - return getFullWidth(name) === 0 ? unescapeIdentifier(name.text) : getTextOfNode(name); - case 141: + return getFullWidth(name) === 0 ? ts.unescapeIdentifier(name.text) : getTextOfNode(name); + case 142: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 177: + case 178: return entityNameToString(name.expression) + "." + entityNameToString(name.name); } } @@ -5210,7 +5361,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 204) { + if (node.body && node.body.kind === 206) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -5222,29 +5373,29 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 261: + case 264: 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 223: - case 174: - case 226: - case 197: - case 227: - case 230: - case 229: - case 260: case 225: - case 184: - case 149: - case 151: - case 152: + case 175: case 228: + case 198: + case 229: + case 232: + case 231: + case 263: + case 227: + case 185: + case 150: + case 152: + case 153: + case 230: errorNode = node.name; break; - case 185: + case 186: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -5265,7 +5416,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 229 && isConst(node); + return node.kind === 231 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -5278,11 +5429,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 179 && n.expression.kind === 96; + return n.kind === 180 && n.expression.kind === 96; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 207 + return node.kind === 209 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; @@ -5295,10 +5446,10 @@ var ts; } ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 144 || - node.kind === 143 || - node.kind === 184 || - node.kind === 185) ? + var commentRanges = (node.kind === 145 || + node.kind === 144 || + node.kind === 185 || + node.kind === 186) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, function (comment) { @@ -5312,96 +5463,110 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (156 <= node.kind && node.kind <= 171) { + if (157 <= node.kind && node.kind <= 172) { return true; } switch (node.kind) { case 118: case 132: - case 134: - case 121: case 135: - case 137: + case 121: + case 136: + case 138: case 129: return true; case 104: - return node.parent.kind !== 188; - case 199: + return node.parent.kind !== 189; + case 200: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 70: - if (node.parent.kind === 141 && node.parent.right === node) { + if (node.parent.kind === 142 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 177 && node.parent.name === node) { + else if (node.parent.kind === 178 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 70 || node.kind === 141 || node.kind === 177, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 141: - case 177: + ts.Debug.assert(node.kind === 70 || node.kind === 142 || node.kind === 178, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 142: + case 178: case 98: - var parent_1 = node.parent; - if (parent_1.kind === 160) { + var parent = node.parent; + if (parent.kind === 161) { return false; } - if (156 <= parent_1.kind && parent_1.kind <= 171) { + if (157 <= parent.kind && parent.kind <= 172) { return true; } - switch (parent_1.kind) { - case 199: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 143: - return node === parent_1.constraint; - case 147: - case 146: + switch (parent.kind) { + case 200: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 144: - case 223: - return node === parent_1.type; + return node === parent.constraint; + case 148: + case 147: + case 145: case 225: - case 184: + return node === parent.type; + case 227: case 185: + case 186: + case 151: case 150: case 149: - case 148: - case 151: case 152: - return node === parent_1.type; case 153: + return node === parent.type; case 154: case 155: - return node === parent_1.type; - case 182: - return node === parent_1.type; - case 179: + case 156: + return node === parent.type; + case 183: + return node === parent.type; case 180: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 181: + return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; + case 182: return false; } } return false; } ts.isPartOfTypeNode = isPartOfTypeNode; + function isChildOfNodeWithKind(node, kind) { + while (node) { + if (node.kind === kind) { + return true; + } + node = node.parent; + } + return false; + } + ts.isChildOfNodeWithKind = isChildOfNodeWithKind; + function isPrefixUnaryExpression(node) { + return node.kind === 191; + } + ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 216: + case 218: return visitor(node); - case 232: - case 204: - case 208: - case 209: + case 234: + case 206: case 210: case 211: case 212: case 213: - case 217: - case 218: - case 253: - case 254: + case 214: + case 215: case 219: - case 221: + case 220: case 256: + case 257: + case 221: + case 223: + case 259: return ts.forEachChild(node, traverse); } } @@ -5411,24 +5576,24 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 195: + case 196: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } + case 231: case 229: - case 227: + case 232: case 230: case 228: - case 226: - case 197: + case 198: return; default: if (isFunctionLike(node)) { - var name_5 = node.name; - if (name_5 && name_5.kind === 142) { - traverse(name_5.expression); + var name = node.name; + if (name && name.kind === 143) { + traverse(name.expression); return; } } @@ -5440,10 +5605,10 @@ var ts; } ts.forEachYieldExpression = forEachYieldExpression; function getRestParameterElementType(node) { - if (node && node.kind === 162) { + if (node && node.kind === 163) { return node.elementType; } - else if (node && node.kind === 157) { + else if (node && node.kind === 158) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -5454,14 +5619,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 174: + case 175: + case 263: + case 145: case 260: - case 144: - case 257: + case 148: case 147: - case 146: - case 258: - case 223: + case 261: + case 225: return true; } } @@ -5469,11 +5634,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 151 || node.kind === 152); + return node && (node.kind === 152 || node.kind === 153); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 226 || node.kind === 197); + return node && (node.kind === 228 || node.kind === 198); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -5482,19 +5647,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 150: - case 184: - case 225: - case 185: - case 149: - case 148: case 151: + case 185: + case 227: + case 186: + case 150: + case 149: case 152: case 153: case 154: case 155: - case 158: + case 156: case 159: + case 160: return true; } return false; @@ -5502,13 +5667,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 225: - case 184: + case 153: + case 227: + case 185: return true; } return false; @@ -5516,30 +5681,42 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { + case 213: + case 214: + case 215: case 211: case 212: - case 213: - case 209: - case 210: return true; - case 219: + case 221: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; + function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + while (true) { + if (beforeUnwrapLabelCallback) { + beforeUnwrapLabelCallback(node); + } + if (node.statement.kind !== 221) { + return node.statement; + } + node = node.statement; + } + } + ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; function isFunctionBlock(node) { - return node && node.kind === 204 && isFunctionLike(node.parent); + return node && node.kind === 206 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 149 && node.parent.kind === 176; + return node && node.kind === 150 && node.parent.kind === 177; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 149 && - (node.parent.kind === 176 || - node.parent.kind === 197); + return node.kind === 150 && + (node.parent.kind === 177 || + node.parent.kind === 198); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -5575,44 +5752,57 @@ var ts; return undefined; } switch (node.kind) { - case 142: + case 143: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 145: - if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { + case 146: + if (node.parent.kind === 145 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 185: + case 186: if (!includeArrowFunctions) { continue; } - case 225: - case 184: - case 230: - case 147: - case 146: - case 149: + case 227: + case 185: + case 232: case 148: + case 147: case 150: + case 149: case 151: case 152: case 153: case 154: case 155: - case 229: - case 261: + case 156: + case 231: + case 264: return node; } } } ts.getThisContainer = getThisContainer; + function getNewTargetContainer(node) { + var container = getThisContainer(node, false); + if (container) { + switch (container.kind) { + case 151: + case 227: + case 185: + return container; + } + } + return undefined; + } + ts.getNewTargetContainer = getNewTargetContainer; function getSuperContainer(node, stopOnFunctions) { while (true) { node = node.parent; @@ -5620,25 +5810,25 @@ var ts; return node; } switch (node.kind) { - case 142: + case 143: node = node.parent; break; - case 225: - case 184: + case 227: case 185: + case 186: if (!stopOnFunctions) { continue; } - case 147: - case 146: - case 149: case 148: + case 147: case 150: + case 149: case 151: case 152: + case 153: return node; - case 145: - if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { + case 146: + if (node.parent.kind === 145 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { @@ -5650,36 +5840,36 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 184 || func.kind === 185) { + if (func.kind === 185 || func.kind === 186) { var prev = func; - var parent_2 = func.parent; - while (parent_2.kind === 183) { - prev = parent_2; - parent_2 = parent_2.parent; + var parent = func.parent; + while (parent.kind === 184) { + prev = parent; + parent = parent.parent; } - if (parent_2.kind === 179 && parent_2.expression === prev) { - return parent_2; + if (parent.kind === 180 && parent.expression === prev) { + return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 177 || kind === 178) + return (kind === 178 || kind === 179) && node.expression.kind === 96; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 157: - case 272: + case 158: + case 276: return node.typeName; - case 199: + case 200: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 70: - case 141: + case 142: return node; } return undefined; @@ -5687,10 +5877,12 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 179: + case 250: + case 249: case 180: case 181: - case 145: + case 182: + case 146: return true; default: return false; @@ -5698,29 +5890,32 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 181) { + if (node.kind === 182) { return node.tag; } + else if (isJsxOpeningLikeElement(node)) { + return node.tagName; + } return node.expression; } ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 226: + case 228: return true; - case 147: - return node.parent.kind === 226; - case 151: + case 148: + return node.parent.kind === 228; case 152: - case 149: + case 153: + case 150: return node.body !== undefined - && node.parent.kind === 226; - case 144: + && node.parent.kind === 228; + case 145: return node.parent.body !== undefined - && (node.parent.kind === 150 - || node.parent.kind === 149 - || node.parent.kind === 152) - && node.parent.parent.kind === 226; + && (node.parent.kind === 151 + || node.parent.kind === 150 + || node.parent.kind === 153) + && node.parent.parent.kind === 228; } return false; } @@ -5736,19 +5931,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 226: + case 228: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 149: - case 152: + case 150: + case 153: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 248 || - parent.kind === 247 || - parent.kind === 249) { + if (parent.kind === 250 || + parent.kind === 249 || + parent.kind === 251) { return parent.tagName === node; } return false; @@ -5762,95 +5957,96 @@ var ts; case 100: case 85: case 11: - case 175: case 176: case 177: case 178: case 179: case 180: case 181: - case 200: case 182: case 201: case 183: + case 202: case 184: - case 197: case 185: - case 188: + case 198: case 186: + case 189: case 187: - case 190: + case 188: case 191: case 192: case 193: - case 196: case 194: - case 12: - case 198: - case 246: - case 247: + case 197: case 195: - case 189: + case 12: + case 199: + case 248: + case 249: + case 196: + case 190: + case 203: return true; - case 141: - while (node.parent.kind === 141) { + case 142: + while (node.parent.kind === 142) { node = node.parent; } - return node.parent.kind === 160 || isJSXTagName(node); + return node.parent.kind === 161 || isJSXTagName(node); case 70: - if (node.parent.kind === 160 || isJSXTagName(node)) { + if (node.parent.kind === 161 || isJSXTagName(node)) { return true; } case 8: case 9: case 98: - var parent_3 = node.parent; - switch (parent_3.kind) { - case 223: - case 144: + var parent = node.parent; + switch (parent.kind) { + case 225: + case 145: + case 148: case 147: - case 146: + case 263: case 260: - case 257: - case 174: - return parent_3.initializer === node; - case 207: - case 208: + case 175: + return parent.initializer === node; case 209: case 210: - case 216: - case 217: - case 218: - case 253: - case 220: - case 218: - return parent_3.expression === node; case 211: - var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 224) || + case 212: + case 218: + case 219: + case 220: + case 256: + case 222: + case 220: + return parent.expression === node; + case 213: + var forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== 226) || forStatement.condition === node || forStatement.incrementor === node; - case 212: - case 213: - var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224) || + case 214: + case 215: + var forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 226) || forInStatement.expression === node; - case 182: - case 200: - return node === parent_3.expression; - case 202: - return node === parent_3.expression; - case 142: - return node === parent_3.expression; - case 145: - case 252: - case 251: - case 259: + case 183: + case 201: + return node === parent.expression; + case 204: + return node === parent.expression; + case 143: + return node === parent.expression; + case 146: + case 255: + case 254: + case 262: return true; - case 199: - return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); + case 200: + return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: - if (isPartOfExpression(parent_3)) { + if (isPartOfExpression(parent)) { return true; } } @@ -5865,7 +6061,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 && node.moduleReference.kind === 245; + return node.kind === 236 && node.moduleReference.kind === 247; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5874,7 +6070,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 && node.moduleReference.kind !== 245; + return node.kind === 236 && node.moduleReference.kind !== 247; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -5886,7 +6082,7 @@ var ts; } ts.isInJavaScriptFile = isInJavaScriptFile; function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 179 && + var isRequire = expression.kind === 180 && expression.expression.kind === 70 && expression.expression.text === "require" && expression.arguments.length === 1; @@ -5898,9 +6094,9 @@ var ts; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 223) { + if (s.valueDeclaration && s.valueDeclaration.kind === 225) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 184; + return declaration.initializer && declaration.initializer.kind === 185; } return false; } @@ -5909,11 +6105,11 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0; } - if (expression.kind !== 192) { + if (expression.kind !== 193) { return 0; } var expr = expression; - if (expr.operatorToken.kind !== 57 || expr.left.kind !== 177) { + if (expr.operatorToken.kind !== 57 || expr.left.kind !== 178) { return 0; } var lhs = expr.left; @@ -5929,7 +6125,7 @@ var ts; else if (lhs.expression.kind === 98) { return 4; } - else if (lhs.expression.kind === 177) { + else if (lhs.expression.kind === 178) { var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 70) { var innerPropertyAccessIdentifier = innerPropertyAccess.expression; @@ -5945,35 +6141,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 235) { + if (node.kind === 237) { return node.moduleSpecifier; } - if (node.kind === 234) { + if (node.kind === 236) { var reference = node.moduleReference; - if (reference.kind === 245) { + if (reference.kind === 247) { return reference.expression; } } - if (node.kind === 241) { + if (node.kind === 243) { return node.moduleSpecifier; } - if (node.kind === 230 && node.name.kind === 9) { + if (node.kind === 232 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 234) { + if (node.kind === 236) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 239) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 235 + return node.kind === 237 && node.importClause && !!node.importClause.name; } @@ -5981,13 +6177,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 144: + case 145: + case 150: case 149: + case 261: + case 260: case 148: - case 258: - case 257: case 147: - case 146: return node.questionToken !== undefined; } } @@ -5995,22 +6191,27 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 274 && + return node.kind === 278 && node.parameters.length > 0 && - node.parameters[0].type.kind === 276; + node.parameters[0].type.kind === 280; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { return ts.map(getJSDocs(node), function (doc) { return doc.comment; }); } ts.getCommentsFromJSDoc = getCommentsFromJSDoc; + function hasJSDocParameterTags(node) { + var parameterTags = getJSDocTags(node, 285); + return parameterTags && parameterTags.length > 0; + } + ts.hasJSDocParameterTags = hasJSDocParameterTags; function getJSDocTags(node, kind) { var docs = getJSDocs(node); if (docs) { var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 281) { + if (doc.kind === 285) { if (doc.kind === kind) { result.push(doc); } @@ -6036,9 +6237,9 @@ var ts; var parent = node.parent; var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 205; + parent.parent.parent.kind === 207; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 205; + parent.parent.kind === 207; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -6046,19 +6247,19 @@ var ts; getJSDocsWorker(variableStatementNode); } var isSourceOfAssignmentExpressionStatement = parent && parent.parent && - parent.kind === 192 && + parent.kind === 193 && parent.operatorToken.kind === 57 && - parent.parent.kind === 207; + parent.parent.kind === 209; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 230 && - parent && parent.kind === 230; - var isPropertyAssignmentExpression = parent && parent.kind === 257; + var isModuleDeclaration = node.kind === 232 && + parent && parent.kind === 232; + var isPropertyAssignmentExpression = parent && parent.kind === 260; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } - if (node.kind === 144) { + if (node.kind === 145) { cache = ts.concatenate(cache, getJSDocParameterTags(node)); } if (isVariableLike(node) && node.initializer) { @@ -6072,17 +6273,17 @@ var ts; return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 281); + var tags = getJSDocTags(func, 285); if (!param.name) { var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 281; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 285; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70) { - var name_6 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 281 && tag.parameterName.text === name_6; }); + var name_1 = param.name.text; + return ts.filter(tags, function (tag) { return tag.kind === 285 && tag.parameterName.text === name_1; }); } else { return undefined; @@ -6090,8 +6291,8 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 283); - if (!tag && node.kind === 144) { + var tag = getFirstJSDocTag(node, 287); + if (!tag && node.kind === 145) { var paramTags = getJSDocParameterTags(node); if (paramTags) { tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); @@ -6101,15 +6302,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 280); + return getFirstJSDocTag(node, 284); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 282); + return getFirstJSDocTag(node, 286); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 284); + return getFirstJSDocTag(node, 288); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -6122,8 +6323,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536)) { - if (node.type && node.type.kind === 275 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275; })) { + if (node.type && node.type.kind === 279 || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 279; })) { return true; } } @@ -6138,28 +6339,33 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 192: + case 193: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 57 ? 1 : 2 : 0; - case 190: case 191: + case 192: var unaryOperator = parent.operator; return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; - case 212: - case 213: + case 214: + case 215: return parent.initializer === node ? 1 : 0; - case 183: - case 175: - case 196: + case 184: + case 176: + case 197: node = parent; break; - case 258: + case 261: if (parent.name !== node) { return 0; } - case 257: + node = parent.parent; + break; + case 260: + if (parent.name === node) { + return 0; + } node = parent.parent; break; default: @@ -6173,6 +6379,17 @@ var ts; return getAssignmentTargetKind(node) !== 0; } ts.isAssignmentTarget = isAssignmentTarget; + function isDeleteTarget(node) { + if (node.kind !== 178 && node.kind !== 179) { + return false; + } + node = node.parent; + while (node && node.kind === 184) { + node = node.parent; + } + return node && node.kind === 187; + } + ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { while (node) { if (node === ancestor) @@ -6184,7 +6401,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2) || (node.kind === 261 && node.isDeclarationFile)) { + if (hasModifier(node, 2) || (node.kind === 264 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -6197,7 +6414,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 239 || parent.kind === 243) { + if (parent.kind === 241 || parent.kind === 245) { if (parent.propertyName) { return true; } @@ -6210,48 +6427,48 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 142 && + node.parent.kind === 143 && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 147: - case 146: - case 149: case 148: - case 151: + case 147: + case 150: + case 149: case 152: + case 153: + case 263: case 260: - case 257: - case 177: + case 178: return parent.name === node; - case 141: + case 142: if (parent.right === node) { - while (parent.kind === 141) { + while (parent.kind === 142) { parent = parent.parent; } - return parent.kind === 160; + return parent.kind === 161; } return false; - case 174: - case 239: + case 175: + case 241: return parent.propertyName === node; - case 243: + case 245: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 234 || - node.kind === 233 || - node.kind === 236 && !!node.name || - node.kind === 237 || + return node.kind === 236 || + node.kind === 235 || + node.kind === 238 && !!node.name || node.kind === 239 || - node.kind === 243 || - node.kind === 240 && exportAssignmentIsAlias(node); + node.kind === 241 || + node.kind === 245 || + node.kind === 242 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -6337,7 +6554,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 71 <= token && token <= 140; + return 71 <= token && token <= 141; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -6359,7 +6576,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 142 && + return name.kind === 143 && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -6369,10 +6586,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 144) { + if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 145) { return name.text; } - if (name.kind === 142) { + if (name.kind === 143) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -6417,11 +6634,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 144; + return root.kind === 145; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 174) { + while (node.kind === 175) { node = node.parent.parent; } return node; @@ -6429,15 +6646,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 150 - || kind === 184 - || kind === 225 + return kind === 151 || kind === 185 - || kind === 149 - || kind === 151 + || kind === 227 + || kind === 186 + || kind === 150 || kind === 152 - || kind === 230 - || kind === 261; + || kind === 153 + || kind === 232 + || kind === 264; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -6445,66 +6662,44 @@ var ts; || ts.positionIsSynthesized(node.end); } ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node, nodeTest) { - if (node) { - while (node.original !== undefined) { - node = node.original; - } + function getOriginalSourceFileOrBundle(sourceFileOrBundle) { + if (sourceFileOrBundle.kind === 265) { + return ts.updateBundle(sourceFileOrBundle, ts.sameMap(sourceFileOrBundle.sourceFiles, getOriginalSourceFile)); } - return !nodeTest || nodeTest(node) ? node : undefined; + return getOriginalSourceFile(sourceFileOrBundle); } - ts.getOriginalNode = getOriginalNode; - function isParseTreeNode(node) { - return (node.flags & 8) === 0; + ts.getOriginalSourceFileOrBundle = getOriginalSourceFileOrBundle; + function getOriginalSourceFile(sourceFile) { + return ts.getParseTreeNode(sourceFile, isSourceFile) || sourceFile; } - ts.isParseTreeNode = isParseTreeNode; - function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { - return node; - } - node = getOriginalNode(node); - if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { - return node; - } - return undefined; - } - ts.getParseTreeNode = getParseTreeNode; function getOriginalSourceFiles(sourceFiles) { - var originalSourceFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); - if (originalSourceFile) { - originalSourceFiles.push(originalSourceFile); - } - } - return originalSourceFiles; + return ts.sameMap(sourceFiles, getOriginalSourceFile); } ts.getOriginalSourceFiles = getOriginalSourceFiles; function getOriginalNodeId(node) { - node = getOriginalNode(node); + node = ts.getOriginalNode(node); return node ? ts.getNodeId(node) : 0; } ts.getOriginalNodeId = getOriginalNodeId; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 180 && expression.arguments !== undefined; + var hasArguments = expression.kind === 181 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 180: + case 181: return hasArguments ? 0 : 1; - case 190: - case 187: + case 191: case 188: - case 186: case 189: - case 193: - case 195: + case 187: + case 190: + case 194: + case 196: return 1; - case 192: + case 193: switch (operator) { case 39: case 57: @@ -6528,15 +6723,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 180 && expression.arguments !== undefined; + var hasArguments = expression.kind === 181 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 192) { + if (expression.kind === 193) { return expression.operatorToken.kind; } - else if (expression.kind === 190 || expression.kind === 191) { + else if (expression.kind === 191 || expression.kind === 192) { return expression.operator; } else { @@ -6554,37 +6749,36 @@ var ts; case 85: case 8: case 9: - case 175: case 176: - case 184: + case 177: case 185: - case 197: - case 246: - case 247: + case 186: + case 198: + case 248: + case 249: case 11: case 12: - case 194: - case 183: - case 198: - case 297: + case 195: + case 184: + case 199: return 19; - case 181: - case 177: + case 182: case 178: - return 18; - case 180: - return hasArguments ? 18 : 17; case 179: + return 18; + case 181: + return hasArguments ? 18 : 17; + case 180: return 17; - case 191: - return 16; - case 190: - case 187: - case 188: - case 186: - case 189: - return 15; case 192: + return 16; + case 191: + case 188: + case 189: + case 187: + case 190: + return 15; + case 193: switch (operatorKind) { case 50: case 51: @@ -6642,11 +6836,11 @@ var ts; default: return -1; } - case 193: + case 194: return 4; - case 195: - return 2; case 196: + return 2; + case 197: return 1; default: return -1; @@ -6669,21 +6863,15 @@ var ts; 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; - } + ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); } function add(diagnostic) { var diagnostics; if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); if (!diagnostics) { diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; + fileDiagnostics.set(diagnostic.file.fileName, diagnostics); } } else { @@ -6700,16 +6888,16 @@ var ts; function getDiagnostics(fileName) { sortAndDeduplicate(); if (fileName) { - return fileDiagnostics[fileName] || []; + return fileDiagnostics.get(fileName) || []; } var allDiagnostics = []; function pushDiagnostic(d) { allDiagnostics.push(d); } ts.forEach(nonFileDiagnostics, pushDiagnostic); - for (var key in fileDiagnostics) { - ts.forEach(fileDiagnostics[key], pushDiagnostic); - } + fileDiagnostics.forEach(function (diagnostics) { + ts.forEach(diagnostics, pushDiagnostic); + }); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function sortAndDeduplicate() { @@ -6718,14 +6906,14 @@ var ts; } diagnosticsModified = false; nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (var key in fileDiagnostics) { - fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } + fileDiagnostics.forEach(function (diagnostics, key) { + fileDiagnostics.set(key, ts.sortAndDeduplicateDiagnostics(diagnostics)); + }); } } ts.createDiagnosticCollection = createDiagnosticCollection; var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = ts.createMap({ + var escapedCharsMap = ts.createMapFromTemplate({ "\0": "\\0", "\t": "\\t", "\v": "\\v", @@ -6740,13 +6928,12 @@ var ts; "\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)); - } + return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; + function getReplacement(c) { + return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } function isIntrinsicJsxName(name) { var ch = name.substr(0, 1); return ch.toLowerCase() === ch; @@ -6889,129 +7076,62 @@ var ts; ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); + var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); }; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); - var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = getAllEmittableSourceFiles(); - return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); + var moduleEmitEnabled_1 = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; + return ts.filter(host.getSourceFiles(), function (sourceFile) { + return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); + }); } else { - var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; - return filterSourceFilesInDirectory(sourceFiles, function (file) { return host.isSourceFileFromExternalLibrary(file); }); - } - function getAllEmittableSourceFiles() { - return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); + var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); }); } } ts.getSourceFilesToEmit = getSourceFilesToEmit; - function filterSourceFilesInDirectory(sourceFiles, isSourceFileFromExternalLibrary) { - return ts.filter(sourceFiles, function (file) { return shouldEmitInDirectory(file, isSourceFileFromExternalLibrary); }); + function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary) { + return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !isDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); } - ts.filterSourceFilesInDirectory = filterSourceFilesInDirectory; - function isNonDeclarationFile(sourceFile) { - return !isDeclarationFile(sourceFile); - } - function shouldEmitInDirectory(sourceFile, isSourceFileFromExternalLibrary) { - return isNonDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); - } - function isBundleEmitNonExternalModule(sourceFile) { - return isNonDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); - } - function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { + ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { - onBundledEmit(sourceFiles); - } - else { - for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { - var sourceFile = sourceFiles_2[_i]; - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } - } - } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); - } - function onBundledEmit(sourceFiles) { if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, true); + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, ts.createBundle(sourceFiles), emitOnlyDtsFiles); + } + } + else { + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, sourceFile, emitOnlyDtsFiles); } } } - ts.forEachTransformedEmitFile = forEachTransformedEmitFile; + ts.forEachEmittedFile = forEachEmittedFile; function getSourceMapFilePath(jsFilePath, options) { return options.sourceMap ? jsFilePath + ".map" : undefined; } - function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - onBundledEmit(host); - } - else { - var sourceFiles = targetSourceFile === undefined ? getSourceFilesToEmit(host) : [targetSourceFile]; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; - if (shouldEmitInDirectory(sourceFile, function (file) { return host.isSourceFileFromExternalLibrary(file); })) { - onSingleFileEmit(host, sourceFile); + function getOutputExtension(sourceFile, options) { + if (options.jsx === 1) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + return ".jsx"; } } - } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: declarationFilePath - }; - action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); - } - function onBundledEmit(host) { - var bundledSources = ts.filter(getSourceFilesToEmit(host), function (sourceFile) { return !isDeclarationFile(sourceFile) && - !host.isSourceFileFromExternalLibrary(sourceFile) && - (!ts.isExternalModule(sourceFile) || - !!ts.getEmitModuleKind(options)); }); - if (bundledSources.length) { - var jsFilePath = options.outFile || options.out; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined - }; - action(emitFileNames, bundledSources, true, emitOnlyDtsFiles); + else if (sourceFile.languageVariant === 1) { + return ".jsx"; } } + return ".js"; } - ts.forEachExpectedEmitFile = forEachExpectedEmitFile; function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); var commonSourceDirectory = host.getCommonSourceDirectory(); @@ -7036,7 +7156,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 150 && nodeIsPresent(member.body)) { + if (member.kind === 151 && nodeIsPresent(member.body)) { return member; } }); @@ -7077,10 +7197,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 151) { + if (accessor.kind === 152) { getAccessor = accessor; } - else if (accessor.kind === 152) { + else if (accessor.kind === 153) { setAccessor = accessor; } else { @@ -7089,7 +7209,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 151 || member.kind === 152) + if ((member.kind === 152 || member.kind === 153) && hasModifier(member, 32) === hasModifier(accessor, 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -7100,10 +7220,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 151 && !getAccessor) { + if (member.kind === 152 && !getAccessor) { getAccessor = member; } - if (member.kind === 152 && !setAccessor) { + if (member.kind === 153 && !setAccessor) { setAccessor = member; } } @@ -7321,7 +7441,7 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 199 && + if (node.kind === 200 && node.parent.token === 84 && isClassLike(node.parent.parent)) { return node.parent.parent; @@ -7339,8 +7459,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, true)) { var kind = node.left.kind; - return kind === 176 - || kind === 175; + return kind === 177 + || kind === 176; } return false; } @@ -7366,29 +7486,33 @@ var ts; ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { return node.kind === 70 || - node.kind === 177 && isEntityNameExpression(node.expression); + node.kind === 178 && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 141 && node.parent.right === node) || - (node.parent.kind === 177 && node.parent.name === node); + return (node.parent.kind === 142 && node.parent.right === node) || + (node.parent.kind === 178 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 176) { + if (kind === 177) { return expression.properties.length === 0; } - if (kind === 175) { + if (kind === 176) { return expression.elements.length === 0; } return false; } ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512) ? symbol.valueDeclaration.localSymbol : undefined; + return isExportDefaultSymbol(symbol) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function isExportDefaultSymbol(symbol) { + return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512); + } + ts.isExportDefaultSymbol = isExportDefaultSymbol; function tryExtractTypeScriptExtension(fileName) { return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); } @@ -7480,39 +7604,39 @@ var ts; || kind === 94) { return true; } - else if (kind === 177) { + else if (kind === 178) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 178) { + else if (kind === 179) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 190 - || kind === 191) { + else if (kind === 191 + || kind === 192) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 192) { + else if (kind === 193) { return node.operatorToken.kind !== 39 && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 193) { + else if (kind === 194) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 188 - || kind === 187 - || kind === 186) { + else if (kind === 189 + || kind === 188 + || kind === 187) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 175) { + else if (kind === 176) { return node.elements.length === 0; } - else if (kind === 176) { + else if (kind === 177) { return node.properties.length === 0; } - else if (kind === 179) { + else if (kind === 180) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -7527,16 +7651,19 @@ var ts; } return false; } - var syntaxKindCache = ts.createMap(); + var syntaxKindCache = []; function formatSyntaxKind(kind) { var syntaxKindEnum = ts.SyntaxKind; if (syntaxKindEnum) { - if (syntaxKindCache[kind]) { - return syntaxKindCache[kind]; + var cached = syntaxKindCache[kind]; + if (cached !== undefined) { + return cached; } - for (var name_7 in syntaxKindEnum) { - if (syntaxKindEnum[name_7] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_7 + ")"; + for (var name in syntaxKindEnum) { + if (syntaxKindEnum[name] === kind) { + var result = kind + " (" + name + ")"; + syntaxKindCache[kind] = result; + return result; } } } @@ -7545,6 +7672,14 @@ var ts; } } ts.formatSyntaxKind = formatSyntaxKind; + function getRangePos(range) { + return range ? range.pos : -1; + } + ts.getRangePos = getRangePos; + function getRangeEnd(range) { + return range ? range.end : -1; + } + ts.getRangeEnd = getRangeEnd; function movePos(pos, value) { return ts.positionIsSynthesized(pos) ? -1 : pos + value; } @@ -7619,11 +7754,11 @@ var ts; } ts.getStartPositionOfRange = getStartPositionOfRange; function isDeclarationNameOfEnumOrNamespace(node) { - var parseNode = getParseTreeNode(node); + var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 229: - case 230: + case 231: + case 232: return parseNode === parseNode.parent.name; } } @@ -7641,7 +7776,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 && declaration !== node) { + if (declaration.kind === 228 && declaration !== node) { return true; } } @@ -7692,6 +7827,10 @@ var ts; return node.kind === 70; } ts.isIdentifier = isIdentifier; + function isVoidExpression(node) { + return node.kind === 189; + } + ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { return isIdentifier(node) && node.autoGenerateKind > 0; } @@ -7701,16 +7840,16 @@ var ts; } ts.isModifier = isModifier; function isQualifiedName(node) { - return node.kind === 141; + return node.kind === 142; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 142; + return node.kind === 143; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 141 + return kind === 142 || kind === 70; } ts.isEntityName = isEntityName; @@ -7719,7 +7858,7 @@ var ts; return kind === 70 || kind === 9 || kind === 8 - || kind === 142; + || kind === 143; } ts.isPropertyName = isPropertyName; function isModuleName(node) { @@ -7731,101 +7870,101 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 70 - || kind === 172 - || kind === 173; + || kind === 173 + || kind === 174; } ts.isBindingName = isBindingName; function isTypeParameter(node) { - return node.kind === 143; + return node.kind === 144; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 144; + return node.kind === 145; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 145; + return node.kind === 146; } ts.isDecorator = isDecorator; function isMethodDeclaration(node) { - return node.kind === 149; + return node.kind === 150; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 150 - || kind === 147 - || kind === 149 - || kind === 151 + return kind === 151 + || kind === 148 + || kind === 150 || kind === 152 - || kind === 155 - || kind === 203; + || kind === 153 + || kind === 156 + || kind === 205; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 257 - || kind === 258 - || kind === 259 - || kind === 149 - || kind === 151 + return kind === 260 + || kind === 261 + || kind === 262 + || kind === 150 || kind === 152 - || kind === 244; + || kind === 153 + || kind === 246; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 156 && kind <= 171) + return (kind >= 157 && kind <= 172) || kind === 118 || kind === 132 || kind === 121 - || kind === 134 || kind === 135 + || kind === 136 || kind === 104 || kind === 129 - || kind === 199; + || kind === 200; } function isTypeNode(node) { return isTypeNodeKind(node.kind); } ts.isTypeNode = isTypeNode; function isArrayBindingPattern(node) { - return node.kind === 173; + return node.kind === 174; } ts.isArrayBindingPattern = isArrayBindingPattern; function isObjectBindingPattern(node) { - return node.kind === 172; + return node.kind === 173; } ts.isObjectBindingPattern = isObjectBindingPattern; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 173 - || kind === 172; + return kind === 174 + || kind === 173; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 175 - || kind === 176; + return kind === 176 + || kind === 177; } ts.isAssignmentPattern = isAssignmentPattern; function isBindingElement(node) { - return node.kind === 174; + return node.kind === 175; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 174 - || kind === 198; + return kind === 175 + || kind === 199; } ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 223: - case 144: - case 174: + case 225: + case 145: + case 175: return true; } return false; @@ -7838,8 +7977,8 @@ var ts; ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 172: - case 176: + case 173: + case 177: return true; } return false; @@ -7847,94 +7986,94 @@ var ts; ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 173: - case 175: + case 174: + case 176: return true; } return false; } ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; function isArrayLiteralExpression(node) { - return node.kind === 175; + return node.kind === 176; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 176; + return node.kind === 177; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 177; + return node.kind === 178; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 178; + return node.kind === 179; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 192; + return node.kind === 193; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 193; + return node.kind === 194; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 179; + return node.kind === 180; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 194 + return kind === 195 || kind === 12; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadExpression(node) { - return node.kind === 196; + return node.kind === 197; } ts.isSpreadExpression = isSpreadExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 199; + return node.kind === 200; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 177 - || kind === 178 - || kind === 180 + return kind === 178 || kind === 179 - || kind === 246 - || kind === 247 || kind === 181 - || kind === 175 - || kind === 183 + || kind === 180 + || kind === 248 + || kind === 249 + || kind === 182 || kind === 176 - || kind === 197 || kind === 184 + || kind === 177 + || kind === 198 + || kind === 185 || kind === 70 || kind === 11 || kind === 8 || kind === 9 || kind === 12 - || kind === 194 + || kind === 195 || kind === 85 || kind === 94 || kind === 98 || kind === 100 || kind === 96 - || kind === 201 - || kind === 297; + || kind === 202 + || kind === 203; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 190 - || kind === 191 - || kind === 186 + return kind === 191 + || kind === 192 || kind === 187 || kind === 188 || kind === 189 - || kind === 182 + || kind === 190 + || kind === 183 || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -7942,14 +8081,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 193 - || kind === 195 - || kind === 185 - || kind === 192 + return kind === 194 || kind === 196 - || kind === 200 - || kind === 198 - || kind === 297 + || kind === 186 + || kind === 193 + || kind === 197 + || kind === 201 + || kind === 199 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -7958,16 +8096,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 182 - || kind === 200; + return kind === 183 + || kind === 201; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 294; + return node.kind === 298; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 293; + return node.kind === 297; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -7976,15 +8114,15 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 198; + return node.kind === 199; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 202; + return node.kind === 204; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 204; + return node.kind === 206; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -8002,121 +8140,135 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 223; + return node.kind === 225; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 224; + return node.kind === 226; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 232; + return node.kind === 234; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 231 - || kind === 230; + return kind === 233 + || kind === 232 + || kind === 70; } ts.isModuleBody = isModuleBody; + function isNamespaceBody(node) { + var kind = node.kind; + return kind === 233 + || kind === 232; + } + ts.isNamespaceBody = isNamespaceBody; + function isJSDocNamespaceBody(node) { + var kind = node.kind; + return kind === 70 + || kind === 232; + } + ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isImportEqualsDeclaration(node) { - return node.kind === 234; + return node.kind === 236; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 236; + return node.kind === 238; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 238 - || kind === 237; + return kind === 240 + || kind === 239; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 239; + return node.kind === 241; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 242; + return node.kind === 244; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 243; + return node.kind === 245; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 230 || node.kind === 229; + return node.kind === 232 || node.kind === 231; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 185 - || kind === 174 - || kind === 226 - || kind === 197 - || kind === 150 - || kind === 229 - || kind === 260 - || kind === 243 - || kind === 225 - || kind === 184 - || kind === 151 - || kind === 236 - || kind === 234 - || kind === 239 - || kind === 227 - || kind === 149 - || kind === 148 - || kind === 230 - || kind === 233 - || kind === 237 - || kind === 144 - || kind === 257 - || kind === 147 - || kind === 146 - || kind === 152 - || kind === 258 + return kind === 186 + || kind === 175 || kind === 228 - || kind === 143 - || kind === 223 - || kind === 285; + || kind === 198 + || kind === 151 + || kind === 231 + || kind === 263 + || kind === 245 + || kind === 227 + || kind === 185 + || kind === 152 + || kind === 238 + || kind === 236 + || kind === 241 + || kind === 229 + || kind === 252 + || kind === 150 + || kind === 149 + || kind === 232 + || kind === 235 + || kind === 239 + || kind === 145 + || kind === 260 + || kind === 148 + || kind === 147 + || kind === 153 + || kind === 261 + || kind === 230 + || kind === 144 + || kind === 225 + || kind === 289; } function isDeclarationStatementKind(kind) { - return kind === 225 - || kind === 244 - || kind === 226 - || kind === 227 + return kind === 227 + || kind === 246 || kind === 228 || kind === 229 || kind === 230 - || kind === 235 - || kind === 234 - || kind === 241 - || kind === 240 - || kind === 233; + || kind === 231 + || kind === 232 + || kind === 237 + || kind === 236 + || kind === 243 + || kind === 242 + || kind === 235; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 215 - || kind === 214 - || kind === 222 - || kind === 209 - || kind === 207 - || kind === 206 - || kind === 212 - || kind === 213 - || kind === 211 - || kind === 208 - || kind === 219 + return kind === 217 || kind === 216 + || kind === 224 + || kind === 211 + || kind === 209 + || kind === 208 + || kind === 214 + || kind === 215 + || kind === 213 + || kind === 210 + || kind === 221 || kind === 218 || kind === 220 - || kind === 221 - || kind === 205 - || kind === 210 - || kind === 217 - || kind === 293 - || kind === 296 - || kind === 295; + || kind === 222 + || kind === 223 + || kind === 207 + || kind === 212 + || kind === 219 + || kind === 297 + || kind === 300 + || kind === 299; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -8134,87 +8286,96 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 204; + || kind === 206; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 245 - || kind === 141 + return kind === 247 + || kind === 142 || kind === 70; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 248; + return node.kind === 250; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 249; + return node.kind === 251; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; return kind === 98 || kind === 70 - || kind === 177; + || kind === 178; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 246 - || kind === 252 - || kind === 247 + return kind === 248 + || kind === 255 + || kind === 249 || kind === 10; } ts.isJsxChild = isJsxChild; + function isJsxAttributes(node) { + var kind = node.kind; + return kind === 253; + } + ts.isJsxAttributes = isJsxAttributes; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 250 - || kind === 251; + return kind === 252 + || kind === 254; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 251; + return node.kind === 254; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 250; + return node.kind === 252; } ts.isJsxAttribute = isJsxAttribute; + function isJsxOpeningLikeElement(node) { + return node.kind === 250 || node.kind === 249; + } + ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 252; + || kind === 255; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 253 - || kind === 254; + return kind === 256 + || kind === 257; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 255; + return node.kind === 258; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 256; + return node.kind === 259; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 257; + return node.kind === 260; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 258; + return node.kind === 261; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isEnumMember(node) { - return node.kind === 260; + return node.kind === 263; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 261; + return node.kind === 264; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -8353,9 +8514,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 143) { + if (d && d.kind === 144) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 227) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 229) { return current; } } @@ -8363,11 +8524,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 150 && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92) && node.parent.kind === 151 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 174 || ts.isBindingPattern(node))) { + while (node && (node.kind === 175 || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -8375,14 +8536,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 223) { + if (node.kind === 225) { node = node.parent; } - if (node && node.kind === 224) { + if (node && node.kind === 226) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 205) { + if (node && node.kind === 207) { flags |= ts.getModifierFlags(node); } return flags; @@ -8391,14 +8552,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 223) { + if (node.kind === 225) { node = node.parent; } - if (node && node.kind === 224) { + if (node && node.kind === 226) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 205) { + if (node && node.kind === 207) { flags |= node.flags; } return flags; @@ -8451,24 +8612,46 @@ var ts; } } ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage; + function getOriginalNode(node, nodeTest) { + if (node) { + while (node.original !== undefined) { + node = node.original; + } + } + return !nodeTest || nodeTest(node) ? node : undefined; + } + ts.getOriginalNode = getOriginalNode; + function isParseTreeNode(node) { + return (node.flags & 8) === 0; + } + ts.isParseTreeNode = isParseTreeNode; + function getParseTreeNode(node, nodeTest) { + if (isParseTreeNode(node)) { + return node; + } + node = getOriginalNode(node); + if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { + return node; + } + return undefined; + } + ts.getParseTreeNode = getParseTreeNode; + 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; })(ts || (ts = {})); var ts; (function (ts) { - var NodeConstructor; - var SourceFileConstructor; - function createNode(kind, location, flags) { - var ConstructorForKind = kind === 261 - ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) - : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); - var node = location - ? new ConstructorForKind(kind, location.pos, location.end) - : new ConstructorForKind(kind, -1, -1); - node.flags = flags | 8; + function createSynthesizedNode(kind) { + var node = ts.createNode(kind, -1, -1); + node.flags |= 8; return node; } function updateNode(updated, original) { if (updated !== original) { setOriginalNode(updated, original); + setTextRange(updated, original); if (original.startsOnNewLine) { updated.startsOnNewLine = true; } @@ -8477,7 +8660,7 @@ var ts; return updated; } ts.updateNode = updateNode; - function createNodeArray(elements, location, hasTrailingComma) { + function createNodeArray(elements, hasTrailingComma) { if (elements) { if (ts.isNodeArray(elements)) { return elements; @@ -8487,32 +8670,15 @@ var ts; elements = []; } var array = elements; - if (location) { - array.pos = location.pos; - array.end = location.end; - } - else { - array.pos = -1; - array.end = -1; - } - if (hasTrailingComma) { - array.hasTrailingComma = true; - } + array.pos = -1; + array.end = -1; + array.hasTrailingComma = hasTrailingComma; return array; } ts.createNodeArray = createNodeArray; - function createSynthesizedNode(kind, startsOnNewLine) { - var node = createNode(kind, undefined); - node.startsOnNewLine = startsOnNewLine; - return node; - } - ts.createSynthesizedNode = createSynthesizedNode; - function createSynthesizedNodeArray(elements) { - return createNodeArray(elements, undefined); - } - ts.createSynthesizedNodeArray = createSynthesizedNodeArray; function getSynthesizedClone(node) { - var clone = createNode(node.kind, undefined, node.flags); + var clone = createSynthesizedNode(node.kind); + clone.flags |= node.flags; setOriginalNode(clone, node); for (var key in node) { if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) { @@ -8523,50 +8689,47 @@ var ts; return clone; } ts.getSynthesizedClone = getSynthesizedClone; - function getMutableClone(node) { - var clone = getSynthesizedClone(node); - clone.pos = node.pos; - clone.end = node.end; - clone.parent = node.parent; - return clone; - } - ts.getMutableClone = getMutableClone; - function createLiteral(value, location) { + function createLiteral(value) { if (typeof value === "number") { - var node = createNode(8, location, undefined); - node.text = value.toString(); - return node; + return createNumericLiteral(value + ""); } - else if (typeof value === "boolean") { - return createNode(value ? 100 : 85, location, undefined); + if (typeof value === "boolean") { + return value ? createTrue() : createFalse(); } - else if (typeof value === "string") { - var node = createNode(9, location, undefined); - node.text = value; - return node; - } - else if (value) { - var node = createNode(9, location, undefined); - node.textSourceNode = value; - node.text = value.text; - return node; + if (typeof value === "string") { + return createStringLiteral(value); } + return createLiteralFromNode(value); } ts.createLiteral = createLiteral; - var nextAutoGenerateId = 0; - function createIdentifier(text, location) { - var node = createNode(70, location); + function createNumericLiteral(value) { + var node = createSynthesizedNode(8); + node.text = value; + return node; + } + ts.createNumericLiteral = createNumericLiteral; + function createStringLiteral(text) { + var node = createSynthesizedNode(9); + node.text = text; + return node; + } + function createLiteralFromNode(sourceNode) { + var node = createStringLiteral(sourceNode.text); + node.textSourceNode = sourceNode; + return node; + } + function createIdentifier(text) { + var node = createSynthesizedNode(70); node.text = ts.escapeIdentifier(text); - node.originalKeywordKind = ts.stringToToken(text); + node.originalKeywordKind = text ? ts.stringToToken(text) : 0; node.autoGenerateKind = 0; node.autoGenerateId = 0; return node; } ts.createIdentifier = createIdentifier; - function createTempVariable(recordTempVariable, location) { - var name = createNode(70, location); - name.text = ""; - name.originalKeywordKind = 0; + var nextAutoGenerateId = 0; + function createTempVariable(recordTempVariable) { + var name = createIdentifier(""); name.autoGenerateKind = 1; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; @@ -8576,93 +8739,121 @@ var ts; return name; } ts.createTempVariable = createTempVariable; - function createLoopVariable(location) { - var name = createNode(70, location); - name.text = ""; - name.originalKeywordKind = 0; + function createLoopVariable() { + var name = createIdentifier(""); name.autoGenerateKind = 2; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createLoopVariable = createLoopVariable; - function createUniqueName(text, location) { - var name = createNode(70, location); - name.text = text; - name.originalKeywordKind = 0; + function createUniqueName(text) { + var name = createIdentifier(text); name.autoGenerateKind = 3; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createUniqueName = createUniqueName; - function getGeneratedNameForNode(node, location) { - var name = createNode(70, location); - name.original = node; - name.text = ""; - name.originalKeywordKind = 0; + function getGeneratedNameForNode(node) { + var name = createIdentifier(""); name.autoGenerateKind = 4; name.autoGenerateId = nextAutoGenerateId; + name.original = node; nextAutoGenerateId++; return name; } ts.getGeneratedNameForNode = getGeneratedNameForNode; function createToken(token) { - return createNode(token); + return createSynthesizedNode(token); } ts.createToken = createToken; function createSuper() { - var node = createNode(96); - return node; + return createSynthesizedNode(96); } ts.createSuper = createSuper; - function createThis(location) { - var node = createNode(98, location); - return node; + function createThis() { + return createSynthesizedNode(98); } ts.createThis = createThis; function createNull() { - var node = createNode(94); - return node; + return createSynthesizedNode(94); } ts.createNull = createNull; - function createComputedPropertyName(expression, location) { - var node = createNode(142, location); + function createTrue() { + return createSynthesizedNode(100); + } + ts.createTrue = createTrue; + function createFalse() { + return createSynthesizedNode(85); + } + ts.createFalse = createFalse; + function createQualifiedName(left, right) { + var node = createSynthesizedNode(142); + node.left = left; + node.right = asName(right); + return node; + } + ts.createQualifiedName = createQualifiedName; + function updateQualifiedName(node, left, right) { + return node.left !== left + || node.right !== right + ? updateNode(createQualifiedName(left, right), node) + : node; + } + ts.updateQualifiedName = updateQualifiedName; + function createComputedPropertyName(expression) { + var node = createSynthesizedNode(143); node.expression = expression; return node; } ts.createComputedPropertyName = createComputedPropertyName; function updateComputedPropertyName(node, expression) { - if (node.expression !== expression) { - return updateNode(createComputedPropertyName(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createComputedPropertyName(expression), node) + : node; } ts.updateComputedPropertyName = updateComputedPropertyName; - function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(144, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { + var node = createSynthesizedNode(145); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.questionToken = questionToken; node.type = type; - node.initializer = initializer ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createParameter = createParameter; function updateParameter(node, decorators, modifiers, dotDotDotToken, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) + : node; } ts.updateParameter = updateParameter; - function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(147, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createDecorator(expression) { + var node = createSynthesizedNode(146); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createDecorator = createDecorator; + function updateDecorator(node, expression) { + return node.expression !== expression + ? updateNode(createDecorator(expression), node) + : node; + } + ts.updateDecorator = updateDecorator; + function createProperty(decorators, modifiers, name, questionToken, type, initializer) { + var node = createSynthesizedNode(148); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.questionToken = questionToken; node.type = type; node.initializer = initializer; @@ -8670,19 +8861,22 @@ var ts; } ts.createProperty = createProperty; function updateProperty(node, decorators, modifiers, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer), node) + : node; } ts.updateProperty = updateProperty; - function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(149, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(150); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -8690,16 +8884,21 @@ var ts; } ts.createMethod = createMethod; function updateMethod(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateMethod = updateMethod; - function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(150, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createConstructor(decorators, modifiers, parameters, body) { + var node = createSynthesizedNode(151); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = undefined; @@ -8708,17 +8907,19 @@ var ts; } ts.createConstructor = createConstructor; function updateConstructor(node, decorators, modifiers, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.parameters !== parameters || node.body !== body) { - return updateNode(createConstructor(decorators, modifiers, parameters, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.parameters !== parameters + || node.body !== body + ? updateNode(createConstructor(decorators, modifiers, parameters, body), node) + : node; } ts.updateConstructor = updateConstructor; - function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(151, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createGetAccessor(decorators, modifiers, name, parameters, type, body) { + var node = createSynthesizedNode(152); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = type; @@ -8727,17 +8928,21 @@ var ts; } ts.createGetAccessor = createGetAccessor; function updateGetAccessor(node, decorators, modifiers, name, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body), node) + : node; } ts.updateGetAccessor = updateGetAccessor; - function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(152, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createSetAccessor(decorators, modifiers, name, parameters, body) { + var node = createSynthesizedNode(153); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.body = body; @@ -8745,57 +8950,60 @@ var ts; } ts.createSetAccessor = createSetAccessor; function updateSetAccessor(node, decorators, modifiers, name, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.body !== body) { - return updateNode(createSetAccessor(decorators, modifiers, name, parameters, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.body !== body + ? updateNode(createSetAccessor(decorators, modifiers, name, parameters, body), node) + : node; } ts.updateSetAccessor = updateSetAccessor; - function createObjectBindingPattern(elements, location) { - var node = createNode(172, location); + function createObjectBindingPattern(elements) { + var node = createSynthesizedNode(173); node.elements = createNodeArray(elements); return node; } ts.createObjectBindingPattern = createObjectBindingPattern; function updateObjectBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createObjectBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createObjectBindingPattern(elements), node) + : node; } ts.updateObjectBindingPattern = updateObjectBindingPattern; - function createArrayBindingPattern(elements, location) { - var node = createNode(173, location); + function createArrayBindingPattern(elements) { + var node = createSynthesizedNode(174); node.elements = createNodeArray(elements); return node; } ts.createArrayBindingPattern = createArrayBindingPattern; function updateArrayBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayBindingPattern(elements), node) + : node; } ts.updateArrayBindingPattern = updateArrayBindingPattern; - function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(174, location); - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createBindingElement(propertyName, dotDotDotToken, name, initializer) { + var node = createSynthesizedNode(175); + node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.initializer = initializer; return node; } ts.createBindingElement = createBindingElement; function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) { - if (node.propertyName !== propertyName || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.initializer !== initializer) { - return updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer, node), node); - } - return node; + return node.propertyName !== propertyName + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.initializer !== initializer + ? updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer), node) + : node; } ts.updateBindingElement = updateBindingElement; - function createArrayLiteral(elements, location, multiLine) { - var node = createNode(175, location); - node.elements = parenthesizeListElements(createNodeArray(elements)); + function createArrayLiteral(elements, multiLine) { + var node = createSynthesizedNode(176); + node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; } @@ -8803,14 +9011,13 @@ var ts; } ts.createArrayLiteral = createArrayLiteral; function updateArrayLiteral(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayLiteral(elements, node, node.multiLine), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayLiteral(elements, node.multiLine), node) + : node; } ts.updateArrayLiteral = updateArrayLiteral; - function createObjectLiteral(properties, location, multiLine) { - var node = createNode(176, location); + function createObjectLiteral(properties, multiLine) { + var node = createSynthesizedNode(177); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -8819,108 +9026,118 @@ var ts; } ts.createObjectLiteral = createObjectLiteral; function updateObjectLiteral(node, properties) { - if (node.properties !== properties) { - return updateNode(createObjectLiteral(properties, node, node.multiLine), node); - } - return node; + return node.properties !== properties + ? updateNode(createObjectLiteral(properties, node.multiLine), node) + : node; } ts.updateObjectLiteral = updateObjectLiteral; - function createPropertyAccess(expression, name, location, flags) { - var node = createNode(177, location, flags); - node.expression = parenthesizeForAccess(expression); - (node.emitNode || (node.emitNode = {})).flags |= 65536; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAccess(expression, name) { + var node = createSynthesizedNode(178); + node.expression = ts.parenthesizeForAccess(expression); + node.name = asName(name); + setEmitFlags(node, 65536); return node; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { - if (node.expression !== expression || node.name !== name) { - var propertyAccess = createPropertyAccess(expression, name, node, node.flags); - (propertyAccess.emitNode || (propertyAccess.emitNode = {})).flags = getEmitFlags(node); - return updateNode(propertyAccess, node); - } - return node; + return node.expression !== expression + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccess(expression, name), getEmitFlags(node)), node) + : node; } ts.updatePropertyAccess = updatePropertyAccess; - function createElementAccess(expression, index, location) { - var node = createNode(178, location); - node.expression = parenthesizeForAccess(expression); - node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; + function createElementAccess(expression, index) { + var node = createSynthesizedNode(179); + node.expression = ts.parenthesizeForAccess(expression); + node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { - if (node.expression !== expression || node.argumentExpression !== argumentExpression) { - return updateNode(createElementAccess(expression, argumentExpression, node), node); - } - return node; + return node.expression !== expression + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccess(expression, argumentExpression), node) + : node; } ts.updateElementAccess = updateElementAccess; - function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(179, location, flags); - node.expression = parenthesizeForAccess(expression); - if (typeArguments) { - node.typeArguments = createNodeArray(typeArguments); - } - node.arguments = parenthesizeListElements(createNodeArray(argumentsArray)); + function createCall(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(180); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); return node; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { - if (expression !== node.expression || typeArguments !== node.typeArguments || argumentsArray !== node.arguments) { - return updateNode(createCall(expression, typeArguments, argumentsArray, node, node.flags), node); - } - return node; + return expression !== node.expression + || typeArguments !== node.typeArguments + || argumentsArray !== node.arguments + ? updateNode(createCall(expression, typeArguments, argumentsArray), node) + : node; } ts.updateCall = updateCall; - function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(180, location, flags); - node.expression = parenthesizeForNew(expression); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; + function createNew(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(181); + node.expression = ts.parenthesizeForNew(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; return node; } ts.createNew = createNew; function updateNew(node, expression, typeArguments, argumentsArray) { - if (node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray) { - return updateNode(createNew(expression, typeArguments, argumentsArray, node, node.flags), node); - } - return node; + return node.expression !== expression + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createNew(expression, typeArguments, argumentsArray), node) + : node; } ts.updateNew = updateNew; - function createTaggedTemplate(tag, template, location) { - var node = createNode(181, location); - node.tag = parenthesizeForAccess(tag); + function createTaggedTemplate(tag, template) { + var node = createSynthesizedNode(182); + node.tag = ts.parenthesizeForAccess(tag); node.template = template; return node; } ts.createTaggedTemplate = createTaggedTemplate; function updateTaggedTemplate(node, tag, template) { - if (node.tag !== tag || node.template !== template) { - return updateNode(createTaggedTemplate(tag, template, node), node); - } - return node; + return node.tag !== tag + || node.template !== template + ? updateNode(createTaggedTemplate(tag, template), node) + : node; } ts.updateTaggedTemplate = updateTaggedTemplate; - function createParen(expression, location) { - var node = createNode(183, location); + function createTypeAssertion(type, expression) { + var node = createSynthesizedNode(183); + node.type = type; + node.expression = ts.parenthesizePrefixOperand(expression); + return node; + } + ts.createTypeAssertion = createTypeAssertion; + function updateTypeAssertion(node, type, expression) { + return node.type !== type + || node.expression !== expression + ? updateNode(createTypeAssertion(type, expression), node) + : node; + } + ts.updateTypeAssertion = updateTypeAssertion; + function createParen(expression) { + var node = createSynthesizedNode(184); node.expression = expression; return node; } ts.createParen = createParen; function updateParen(node, expression) { - if (node.expression !== expression) { - return updateNode(createParen(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createParen(expression), node) + : node; } ts.updateParen = updateParen; - function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(184, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(185); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -8928,322 +9145,340 @@ var ts; } ts.createFunctionExpression = createFunctionExpression; function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); - } - return node; + return node.name !== name + || node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionExpression = updateFunctionExpression; - function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(185, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { + var node = createSynthesizedNode(186); + node.modifiers = asNodeArray(modifiers); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35); - node.body = parenthesizeConciseBody(body); + node.body = ts.parenthesizeConciseBody(body); return node; } ts.createArrowFunction = createArrowFunction; function updateArrowFunction(node, modifiers, typeParameters, parameters, type, body) { - if (node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body, node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body), node) + : node; } ts.updateArrowFunction = updateArrowFunction; - function createDelete(expression, location) { - var node = createNode(186, location); - node.expression = parenthesizePrefixOperand(expression); + function createDelete(expression) { + var node = createSynthesizedNode(187); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createDelete = createDelete; function updateDelete(node, expression) { - if (node.expression !== expression) { - return updateNode(createDelete(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createDelete(expression), node) + : node; } ts.updateDelete = updateDelete; - function createTypeOf(expression, location) { - var node = createNode(187, location); - node.expression = parenthesizePrefixOperand(expression); + function createTypeOf(expression) { + var node = createSynthesizedNode(188); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createTypeOf = createTypeOf; function updateTypeOf(node, expression) { - if (node.expression !== expression) { - return updateNode(createTypeOf(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createTypeOf(expression), node) + : node; } ts.updateTypeOf = updateTypeOf; - function createVoid(expression, location) { - var node = createNode(188, location); - node.expression = parenthesizePrefixOperand(expression); + function createVoid(expression) { + var node = createSynthesizedNode(189); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createVoid = createVoid; function updateVoid(node, expression) { - if (node.expression !== expression) { - return updateNode(createVoid(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createVoid(expression), node) + : node; } ts.updateVoid = updateVoid; - function createAwait(expression, location) { - var node = createNode(189, location); - node.expression = parenthesizePrefixOperand(expression); + function createAwait(expression) { + var node = createSynthesizedNode(190); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createAwait = createAwait; function updateAwait(node, expression) { - if (node.expression !== expression) { - return updateNode(createAwait(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createAwait(expression), node) + : node; } ts.updateAwait = updateAwait; - function createPrefix(operator, operand, location) { - var node = createNode(190, location); + function createPrefix(operator, operand) { + var node = createSynthesizedNode(191); node.operator = operator; - node.operand = parenthesizePrefixOperand(operand); + node.operand = ts.parenthesizePrefixOperand(operand); return node; } ts.createPrefix = createPrefix; function updatePrefix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPrefix(node.operator, operand, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPrefix(node.operator, operand), node) + : node; } ts.updatePrefix = updatePrefix; - function createPostfix(operand, operator, location) { - var node = createNode(191, location); - node.operand = parenthesizePostfixOperand(operand); + function createPostfix(operand, operator) { + var node = createSynthesizedNode(192); + node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; } ts.createPostfix = createPostfix; function updatePostfix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPostfix(operand, node.operator, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPostfix(operand, node.operator), node) + : node; } ts.updatePostfix = updatePostfix; - function createBinary(left, operator, right, location) { - var operatorToken = typeof operator === "number" ? createToken(operator) : operator; + function createBinary(left, operator, right) { + var node = createSynthesizedNode(193); + var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; - var node = createNode(192, location); - node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); + node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined); node.operatorToken = operatorToken; - node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); + node.right = ts.parenthesizeBinaryOperand(operatorKind, right, false, node.left); return node; } ts.createBinary = createBinary; function updateBinary(node, left, right) { - if (node.left !== left || node.right !== right) { - return updateNode(createBinary(left, node.operatorToken, right, node), node); - } - return node; + return node.left !== left + || node.right !== right + ? updateNode(createBinary(left, node.operatorToken, right), node) + : node; } ts.updateBinary = updateBinary; - function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonTokenOrLocation, whenFalse, location) { - var node = createNode(193, whenFalse ? location : colonTokenOrLocation); - node.condition = parenthesizeForConditionalHead(condition); - if (whenFalse) { - node.questionToken = questionTokenOrWhenTrue; - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - node.colonToken = colonTokenOrLocation; - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenFalse); - } - else { - node.questionToken = createToken(54); - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(questionTokenOrWhenTrue); - node.colonToken = createToken(55); - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - } + function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { + var node = createSynthesizedNode(194); + node.condition = ts.parenthesizeForConditionalHead(condition); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(54); + node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); + node.colonToken = whenFalse ? colonToken : createToken(55); + node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } ts.createConditional = createConditional; function updateConditional(node, condition, whenTrue, whenFalse) { - if (node.condition !== condition || node.whenTrue !== whenTrue || node.whenFalse !== whenFalse) { - return updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse, node), node); - } - return node; + return node.condition !== condition + || node.whenTrue !== whenTrue + || node.whenFalse !== whenFalse + ? updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse), node) + : node; } ts.updateConditional = updateConditional; - function createTemplateExpression(head, templateSpans, location) { - var node = createNode(194, location); + function createTemplateExpression(head, templateSpans) { + var node = createSynthesizedNode(195); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; } ts.createTemplateExpression = createTemplateExpression; function updateTemplateExpression(node, head, templateSpans) { - if (node.head !== head || node.templateSpans !== templateSpans) { - return updateNode(createTemplateExpression(head, templateSpans, node), node); - } - return node; + return node.head !== head + || node.templateSpans !== templateSpans + ? updateNode(createTemplateExpression(head, templateSpans), node) + : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createYield(asteriskToken, expression, location) { - var node = createNode(195, location); - node.asteriskToken = asteriskToken; - node.expression = expression; + function createYield(asteriskTokenOrExpression, expression) { + var node = createSynthesizedNode(196); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 38 ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 38 ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; function updateYield(node, expression) { - if (node.expression !== expression) { - return updateNode(createYield(node.asteriskToken, expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createYield(node.asteriskToken, expression), node) + : node; } ts.updateYield = updateYield; - function createSpread(expression, location) { - var node = createNode(196, location); - node.expression = parenthesizeExpressionForList(expression); + function createSpread(expression) { + var node = createSynthesizedNode(197); + node.expression = ts.parenthesizeExpressionForList(expression); return node; } ts.createSpread = createSpread; function updateSpread(node, expression) { - if (node.expression !== expression) { - return updateNode(createSpread(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createSpread(expression), node) + : node; } ts.updateSpread = updateSpread; - function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(197, location); + function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(198); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassExpression = createClassExpression; function updateClassExpression(node, modifiers, name, typeParameters, heritageClauses, members) { - if (node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassExpression = updateClassExpression; - function createOmittedExpression(location) { - var node = createNode(198, location); - return node; + function createOmittedExpression() { + return createSynthesizedNode(199); } ts.createOmittedExpression = createOmittedExpression; - function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(199, location); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.expression = parenthesizeForAccess(expression); + function createExpressionWithTypeArguments(typeArguments, expression) { + var node = createSynthesizedNode(200); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); return node; } ts.createExpressionWithTypeArguments = createExpressionWithTypeArguments; function updateExpressionWithTypeArguments(node, typeArguments, expression) { - if (node.typeArguments !== typeArguments || node.expression !== expression) { - return updateNode(createExpressionWithTypeArguments(typeArguments, expression, node), node); - } - return node; + return node.typeArguments !== typeArguments + || node.expression !== expression + ? updateNode(createExpressionWithTypeArguments(typeArguments, expression), node) + : node; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; - function createTemplateSpan(expression, literal, location) { - var node = createNode(202, location); + function createAsExpression(expression, type) { + var node = createSynthesizedNode(201); + node.expression = expression; + node.type = type; + return node; + } + ts.createAsExpression = createAsExpression; + function updateAsExpression(node, expression, type) { + return node.expression !== expression + || node.type !== type + ? updateNode(createAsExpression(expression, type), node) + : node; + } + ts.updateAsExpression = updateAsExpression; + function createNonNullExpression(expression) { + var node = createSynthesizedNode(202); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createNonNullExpression = createNonNullExpression; + function updateNonNullExpression(node, expression) { + return node.expression !== expression + ? updateNode(createNonNullExpression(expression), node) + : node; + } + ts.updateNonNullExpression = updateNonNullExpression; + function createTemplateSpan(expression, literal) { + var node = createSynthesizedNode(204); node.expression = expression; node.literal = literal; return node; } ts.createTemplateSpan = createTemplateSpan; function updateTemplateSpan(node, expression, literal) { - if (node.expression !== expression || node.literal !== literal) { - return updateNode(createTemplateSpan(expression, literal, node), node); - } - return node; + return node.expression !== expression + || node.literal !== literal + ? updateNode(createTemplateSpan(expression, literal), node) + : node; } ts.updateTemplateSpan = updateTemplateSpan; - function createBlock(statements, location, multiLine, flags) { - var block = createNode(204, location, flags); + function createBlock(statements, multiLine) { + var block = createSynthesizedNode(206); block.statements = createNodeArray(statements); - if (multiLine) { - block.multiLine = true; - } + if (multiLine) + block.multiLine = multiLine; return block; } ts.createBlock = createBlock; function updateBlock(node, statements) { - if (statements !== node.statements) { - return updateNode(createBlock(statements, node, node.multiLine, node.flags), node); - } - return node; + return statements !== node.statements + ? updateNode(createBlock(statements, node.multiLine), node) + : node; } ts.updateBlock = updateBlock; - function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(205, location, flags); + function createVariableStatement(modifiers, declarationList) { + var node = createSynthesizedNode(207); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; return node; } ts.createVariableStatement = createVariableStatement; function updateVariableStatement(node, modifiers, declarationList) { - if (node.modifiers !== modifiers || node.declarationList !== declarationList) { - return updateNode(createVariableStatement(modifiers, declarationList, node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.declarationList !== declarationList + ? updateNode(createVariableStatement(modifiers, declarationList), node) + : node; } ts.updateVariableStatement = updateVariableStatement; - function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(224, location, flags); + function createVariableDeclarationList(declarations, flags) { + var node = createSynthesizedNode(226); + node.flags |= flags; node.declarations = createNodeArray(declarations); return node; } ts.createVariableDeclarationList = createVariableDeclarationList; function updateVariableDeclarationList(node, declarations) { - if (node.declarations !== declarations) { - return updateNode(createVariableDeclarationList(declarations, node, node.flags), node); - } - return node; + return node.declarations !== declarations + ? updateNode(createVariableDeclarationList(declarations, node.flags), node) + : node; } ts.updateVariableDeclarationList = updateVariableDeclarationList; - function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(223, location, flags); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createVariableDeclaration(name, type, initializer) { + var node = createSynthesizedNode(225); + node.name = asName(name); node.type = type; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createVariableDeclaration = createVariableDeclaration; function updateVariableDeclaration(node, name, type, initializer) { - if (node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createVariableDeclaration(name, type, initializer, node, node.flags), node); - } - return node; + return node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createVariableDeclaration(name, type, initializer), node) + : node; } ts.updateVariableDeclaration = updateVariableDeclaration; - function createEmptyStatement(location) { - return createNode(206, location); + function createEmptyStatement() { + return createSynthesizedNode(208); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression, location, flags) { - var node = createNode(207, location, flags); - node.expression = parenthesizeExpressionForExpressionStatement(expression); + function createStatement(expression) { + var node = createSynthesizedNode(209); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } ts.createStatement = createStatement; function updateStatement(node, expression) { - if (node.expression !== expression) { - return updateNode(createStatement(expression, node, node.flags), node); - } - return node; + return node.expression !== expression + ? updateNode(createStatement(expression), node) + : node; } ts.updateStatement = updateStatement; - function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(208, location); + function createIf(expression, thenStatement, elseStatement) { + var node = createSynthesizedNode(210); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -9251,42 +9486,43 @@ var ts; } ts.createIf = createIf; function updateIf(node, expression, thenStatement, elseStatement) { - if (node.expression !== expression || node.thenStatement !== thenStatement || node.elseStatement !== elseStatement) { - return updateNode(createIf(expression, thenStatement, elseStatement, node), node); - } - return node; + return node.expression !== expression + || node.thenStatement !== thenStatement + || node.elseStatement !== elseStatement + ? updateNode(createIf(expression, thenStatement, elseStatement), node) + : node; } ts.updateIf = updateIf; - function createDo(statement, expression, location) { - var node = createNode(209, location); + function createDo(statement, expression) { + var node = createSynthesizedNode(211); node.statement = statement; node.expression = expression; return node; } ts.createDo = createDo; function updateDo(node, statement, expression) { - if (node.statement !== statement || node.expression !== expression) { - return updateNode(createDo(statement, expression, node), node); - } - return node; + return node.statement !== statement + || node.expression !== expression + ? updateNode(createDo(statement, expression), node) + : node; } ts.updateDo = updateDo; - function createWhile(expression, statement, location) { - var node = createNode(210, location); + function createWhile(expression, statement) { + var node = createSynthesizedNode(212); node.expression = expression; node.statement = statement; return node; } ts.createWhile = createWhile; function updateWhile(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWhile(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWhile(expression, statement), node) + : node; } ts.updateWhile = updateWhile; - function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(211, location, undefined); + function createFor(initializer, condition, incrementor, statement) { + var node = createSynthesizedNode(213); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -9295,14 +9531,16 @@ var ts; } ts.createFor = createFor; function updateFor(node, initializer, condition, incrementor, statement) { - if (node.initializer !== initializer || node.condition !== condition || node.incrementor !== incrementor || node.statement !== statement) { - return updateNode(createFor(initializer, condition, incrementor, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.condition !== condition + || node.incrementor !== incrementor + || node.statement !== statement + ? updateNode(createFor(initializer, condition, incrementor, statement), node) + : node; } ts.updateFor = updateFor; - function createForIn(initializer, expression, statement, location) { - var node = createNode(212, location); + function createForIn(initializer, expression, statement) { + var node = createSynthesizedNode(214); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -9310,14 +9548,15 @@ var ts; } ts.createForIn = createForIn; function updateForIn(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForIn(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForIn(initializer, expression, statement), node) + : node; } ts.updateForIn = updateForIn; - function createForOf(initializer, expression, statement, location) { - var node = createNode(213, location); + function createForOf(initializer, expression, statement) { + var node = createSynthesizedNode(215); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -9325,112 +9564,105 @@ var ts; } ts.createForOf = createForOf; function updateForOf(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForOf(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForOf(initializer, expression, statement), node) + : node; } ts.updateForOf = updateForOf; - function createContinue(label, location) { - var node = createNode(214, location); - if (label) { - node.label = label; - } + function createContinue(label) { + var node = createSynthesizedNode(216); + node.label = asName(label); return node; } ts.createContinue = createContinue; function updateContinue(node, label) { - if (node.label !== label) { - return updateNode(createContinue(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createContinue(label), node) + : node; } ts.updateContinue = updateContinue; - function createBreak(label, location) { - var node = createNode(215, location); - if (label) { - node.label = label; - } + function createBreak(label) { + var node = createSynthesizedNode(217); + node.label = asName(label); return node; } ts.createBreak = createBreak; function updateBreak(node, label) { - if (node.label !== label) { - return updateNode(createBreak(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createBreak(label), node) + : node; } ts.updateBreak = updateBreak; - function createReturn(expression, location) { - var node = createNode(216, location); + function createReturn(expression) { + var node = createSynthesizedNode(218); node.expression = expression; return node; } ts.createReturn = createReturn; function updateReturn(node, expression) { - if (node.expression !== expression) { - return updateNode(createReturn(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createReturn(expression), node) + : node; } ts.updateReturn = updateReturn; - function createWith(expression, statement, location) { - var node = createNode(217, location); + function createWith(expression, statement) { + var node = createSynthesizedNode(219); node.expression = expression; node.statement = statement; return node; } ts.createWith = createWith; function updateWith(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWith(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWith(expression, statement), node) + : node; } ts.updateWith = updateWith; - function createSwitch(expression, caseBlock, location) { - var node = createNode(218, location); - node.expression = parenthesizeExpressionForList(expression); + function createSwitch(expression, caseBlock) { + var node = createSynthesizedNode(220); + node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; } ts.createSwitch = createSwitch; function updateSwitch(node, expression, caseBlock) { - if (node.expression !== expression || node.caseBlock !== caseBlock) { - return updateNode(createSwitch(expression, caseBlock, node), node); - } - return node; + return node.expression !== expression + || node.caseBlock !== caseBlock + ? updateNode(createSwitch(expression, caseBlock), node) + : node; } ts.updateSwitch = updateSwitch; - function createLabel(label, statement, location) { - var node = createNode(219, location); - node.label = typeof label === "string" ? createIdentifier(label) : label; + function createLabel(label, statement) { + var node = createSynthesizedNode(221); + node.label = asName(label); node.statement = statement; return node; } ts.createLabel = createLabel; function updateLabel(node, label, statement) { - if (node.label !== label || node.statement !== statement) { - return updateNode(createLabel(label, statement, node), node); - } - return node; + return node.label !== label + || node.statement !== statement + ? updateNode(createLabel(label, statement), node) + : node; } ts.updateLabel = updateLabel; - function createThrow(expression, location) { - var node = createNode(220, location); + function createThrow(expression) { + var node = createSynthesizedNode(222); node.expression = expression; return node; } ts.createThrow = createThrow; function updateThrow(node, expression) { - if (node.expression !== expression) { - return updateNode(createThrow(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createThrow(expression), node) + : node; } ts.updateThrow = updateThrow; - function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(221, location); + function createTry(tryBlock, catchClause, finallyBlock) { + var node = createSynthesizedNode(223); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -9438,32 +9670,20 @@ var ts; } ts.createTry = createTry; function updateTry(node, tryBlock, catchClause, finallyBlock) { - if (node.tryBlock !== tryBlock || node.catchClause !== catchClause || node.finallyBlock !== finallyBlock) { - return updateNode(createTry(tryBlock, catchClause, finallyBlock, node), node); - } - return node; + return node.tryBlock !== tryBlock + || node.catchClause !== catchClause + || node.finallyBlock !== finallyBlock + ? updateNode(createTry(tryBlock, catchClause, finallyBlock), node) + : node; } ts.updateTry = updateTry; - function createCaseBlock(clauses, location) { - var node = createNode(232, location); - node.clauses = createNodeArray(clauses); - return node; - } - ts.createCaseBlock = createCaseBlock; - function updateCaseBlock(node, clauses) { - if (node.clauses !== clauses) { - return updateNode(createCaseBlock(clauses, node), node); - } - return node; - } - ts.updateCaseBlock = updateCaseBlock; - function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(225, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(227); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -9471,161 +9691,261 @@ var ts; } ts.createFunctionDeclaration = createFunctionDeclaration; function updateFunctionDeclaration(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionDeclaration = updateFunctionDeclaration; - function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(226, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(228); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassDeclaration = createClassDeclaration; function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassDeclaration = updateClassDeclaration; - function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(235, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createEnumDeclaration(decorators, modifiers, name, members) { + var node = createSynthesizedNode(231); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.members = createNodeArray(members); + return node; + } + ts.createEnumDeclaration = createEnumDeclaration; + function updateEnumDeclaration(node, decorators, modifiers, name, members) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.members !== members + ? updateNode(createEnumDeclaration(decorators, modifiers, name, members), node) + : node; + } + ts.updateEnumDeclaration = updateEnumDeclaration; + function createModuleDeclaration(decorators, modifiers, name, body, flags) { + var node = createSynthesizedNode(232); + node.flags |= flags; + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = name; + node.body = body; + return node; + } + ts.createModuleDeclaration = createModuleDeclaration; + function updateModuleDeclaration(node, decorators, modifiers, name, body) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.body !== body + ? updateNode(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node) + : node; + } + ts.updateModuleDeclaration = updateModuleDeclaration; + function createModuleBlock(statements) { + var node = createSynthesizedNode(234); + node.statements = createNodeArray(statements); + return node; + } + ts.createModuleBlock = createModuleBlock; + function updateModuleBlock(node, statements) { + return node.statements !== statements + ? updateNode(createModuleBlock(statements), node) + : node; + } + ts.updateModuleBlock = updateModuleBlock; + function createCaseBlock(clauses) { + var node = createSynthesizedNode(234); + node.clauses = createNodeArray(clauses); + return node; + } + ts.createCaseBlock = createCaseBlock; + function updateCaseBlock(node, clauses) { + return node.clauses !== clauses + ? updateNode(createCaseBlock(clauses), node) + : node; + } + ts.updateCaseBlock = updateCaseBlock; + function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { + var node = createSynthesizedNode(236); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.moduleReference = moduleReference; + return node; + } + ts.createImportEqualsDeclaration = createImportEqualsDeclaration; + function updateImportEqualsDeclaration(node, decorators, modifiers, name, moduleReference) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.moduleReference !== moduleReference + ? updateNode(createImportEqualsDeclaration(decorators, modifiers, name, moduleReference), node) + : node; + } + ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; + function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { + var node = createSynthesizedNode(237); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createImportDeclaration = createImportDeclaration; function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node) + : node; } ts.updateImportDeclaration = updateImportDeclaration; - function createImportClause(name, namedBindings, location) { - var node = createNode(236, location); + function createImportClause(name, namedBindings) { + var node = createSynthesizedNode(238); node.name = name; node.namedBindings = namedBindings; return node; } ts.createImportClause = createImportClause; function updateImportClause(node, name, namedBindings) { - if (node.name !== name || node.namedBindings !== namedBindings) { - return updateNode(createImportClause(name, namedBindings, node), node); - } - return node; + return node.name !== name + || node.namedBindings !== namedBindings + ? updateNode(createImportClause(name, namedBindings), node) + : node; } ts.updateImportClause = updateImportClause; - function createNamespaceImport(name, location) { - var node = createNode(237, location); + function createNamespaceImport(name) { + var node = createSynthesizedNode(239); node.name = name; return node; } ts.createNamespaceImport = createNamespaceImport; function updateNamespaceImport(node, name) { - if (node.name !== name) { - return updateNode(createNamespaceImport(name, node), node); - } - return node; + return node.name !== name + ? updateNode(createNamespaceImport(name), node) + : node; } ts.updateNamespaceImport = updateNamespaceImport; - function createNamedImports(elements, location) { - var node = createNode(238, location); + function createNamedImports(elements) { + var node = createSynthesizedNode(240); node.elements = createNodeArray(elements); return node; } ts.createNamedImports = createNamedImports; function updateNamedImports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedImports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedImports(elements), node) + : node; } ts.updateNamedImports = updateNamedImports; - function createImportSpecifier(propertyName, name, location) { - var node = createNode(239, location); + function createImportSpecifier(propertyName, name) { + var node = createSynthesizedNode(241); node.propertyName = propertyName; node.name = name; return node; } ts.createImportSpecifier = createImportSpecifier; function updateImportSpecifier(node, propertyName, name) { - if (node.propertyName !== propertyName || node.name !== name) { - return updateNode(createImportSpecifier(propertyName, name, node), node); - } - return node; + return node.propertyName !== propertyName + || node.name !== name + ? updateNode(createImportSpecifier(propertyName, name), node) + : node; } ts.updateImportSpecifier = updateImportSpecifier; - function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(240, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportAssignment(decorators, modifiers, isExportEquals, expression) { + var node = createSynthesizedNode(242); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; node.expression = expression; return node; } ts.createExportAssignment = createExportAssignment; function updateExportAssignment(node, decorators, modifiers, expression) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.expression !== expression) { - return updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.expression !== expression + ? updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node) + : node; } ts.updateExportAssignment = updateExportAssignment; - function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(241, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { + var node = createSynthesizedNode(243); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createExportDeclaration = createExportDeclaration; function updateExportDeclaration(node, decorators, modifiers, exportClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.exportClause !== exportClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.exportClause !== exportClause + || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier), node) + : node; } ts.updateExportDeclaration = updateExportDeclaration; - function createNamedExports(elements, location) { - var node = createNode(242, location); + function createNamedExports(elements) { + var node = createSynthesizedNode(244); node.elements = createNodeArray(elements); return node; } ts.createNamedExports = createNamedExports; function updateNamedExports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedExports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedExports(elements), node) + : node; } ts.updateNamedExports = updateNamedExports; - function createExportSpecifier(name, propertyName, location) { - var node = createNode(243, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createExportSpecifier(name, propertyName) { + var node = createSynthesizedNode(245); + node.name = asName(name); + node.propertyName = asName(propertyName); return node; } ts.createExportSpecifier = createExportSpecifier; function updateExportSpecifier(node, name, propertyName) { - if (node.name !== name || node.propertyName !== propertyName) { - return updateNode(createExportSpecifier(name, propertyName, node), node); - } - return node; + return node.name !== name || node.propertyName !== propertyName + ? updateNode(createExportSpecifier(name, propertyName), node) + : node; } ts.updateExportSpecifier = updateExportSpecifier; - function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(246, location); + function createExternalModuleReference(expression) { + var node = createSynthesizedNode(247); + node.expression = expression; + return node; + } + ts.createExternalModuleReference = createExternalModuleReference; + function updateExternalModuleReference(node, expression) { + return node.expression !== expression + ? updateNode(createExternalModuleReference(expression), node) + : node; + } + ts.updateExternalModuleReference = updateExternalModuleReference; + function createJsxElement(openingElement, children, closingElement) { + var node = createSynthesizedNode(248); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -9633,95 +9953,107 @@ var ts; } ts.createJsxElement = createJsxElement; function updateJsxElement(node, openingElement, children, closingElement) { - if (node.openingElement !== openingElement || node.children !== children || node.closingElement !== closingElement) { - return updateNode(createJsxElement(openingElement, children, closingElement, node), node); - } - return node; + return node.openingElement !== openingElement + || node.children !== children + || node.closingElement !== closingElement + ? updateNode(createJsxElement(openingElement, children, closingElement), node) + : node; } ts.updateJsxElement = updateJsxElement; - function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(247, location); + function createJsxSelfClosingElement(tagName, attributes) { + var node = createSynthesizedNode(249); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxSelfClosingElement = createJsxSelfClosingElement; function updateJsxSelfClosingElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxSelfClosingElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxSelfClosingElement(tagName, attributes), node) + : node; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; - function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(248, location); + function createJsxOpeningElement(tagName, attributes) { + var node = createSynthesizedNode(250); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxOpeningElement = createJsxOpeningElement; function updateJsxOpeningElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxOpeningElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxOpeningElement(tagName, attributes), node) + : node; } ts.updateJsxOpeningElement = updateJsxOpeningElement; - function createJsxClosingElement(tagName, location) { - var node = createNode(249, location); + function createJsxClosingElement(tagName) { + var node = createSynthesizedNode(251); node.tagName = tagName; return node; } ts.createJsxClosingElement = createJsxClosingElement; function updateJsxClosingElement(node, tagName) { - if (node.tagName !== tagName) { - return updateNode(createJsxClosingElement(tagName, node), node); - } - return node; + return node.tagName !== tagName + ? updateNode(createJsxClosingElement(tagName), node) + : node; } ts.updateJsxClosingElement = updateJsxClosingElement; - function createJsxAttribute(name, initializer, location) { - var node = createNode(250, location); + function createJsxAttributes(properties) { + var jsxAttributes = createSynthesizedNode(253); + jsxAttributes.properties = createNodeArray(properties); + return jsxAttributes; + } + ts.createJsxAttributes = createJsxAttributes; + function updateJsxAttributes(jsxAttributes, properties) { + if (jsxAttributes.properties !== properties) { + return updateNode(createJsxAttributes(properties), jsxAttributes); + } + return jsxAttributes; + } + ts.updateJsxAttributes = updateJsxAttributes; + function createJsxAttribute(name, initializer) { + var node = createSynthesizedNode(252); node.name = name; node.initializer = initializer; return node; } ts.createJsxAttribute = createJsxAttribute; function updateJsxAttribute(node, name, initializer) { - if (node.name !== name || node.initializer !== initializer) { - return updateNode(createJsxAttribute(name, initializer, node), node); - } - return node; + return node.name !== name + || node.initializer !== initializer + ? updateNode(createJsxAttribute(name, initializer), node) + : node; } ts.updateJsxAttribute = updateJsxAttribute; - function createJsxSpreadAttribute(expression, location) { - var node = createNode(251, location); + function createJsxSpreadAttribute(expression) { + var node = createSynthesizedNode(254); node.expression = expression; return node; } ts.createJsxSpreadAttribute = createJsxSpreadAttribute; function updateJsxSpreadAttribute(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxSpreadAttribute(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxSpreadAttribute(expression), node) + : node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, location) { - var node = createNode(252, location); + function createJsxExpression(expression, dotDotDotToken) { + var node = createSynthesizedNode(255); + node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxExpression(expression, node.dotDotDotToken), node) + : node; } ts.updateJsxExpression = updateJsxExpression; - function createHeritageClause(token, types, location) { - var node = createNode(255, location); + function createHeritageClause(token, types) { + var node = createSynthesizedNode(258); node.token = token; node.types = createNodeArray(types); return node; @@ -9729,40 +10061,40 @@ var ts; ts.createHeritageClause = createHeritageClause; function updateHeritageClause(node, types) { if (node.types !== types) { - return updateNode(createHeritageClause(node.token, types, node), node); + return updateNode(createHeritageClause(node.token, types), node); } return node; } ts.updateHeritageClause = updateHeritageClause; - function createCaseClause(expression, statements, location) { - var node = createNode(253, location); - node.expression = parenthesizeExpressionForList(expression); + function createCaseClause(expression, statements) { + var node = createSynthesizedNode(256); + node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; } ts.createCaseClause = createCaseClause; function updateCaseClause(node, expression, statements) { if (node.expression !== expression || node.statements !== statements) { - return updateNode(createCaseClause(expression, statements, node), node); + return updateNode(createCaseClause(expression, statements), node); } return node; } ts.updateCaseClause = updateCaseClause; - function createDefaultClause(statements, location) { - var node = createNode(254, location); + function createDefaultClause(statements) { + var node = createSynthesizedNode(257); node.statements = createNodeArray(statements); return node; } ts.createDefaultClause = createDefaultClause; function updateDefaultClause(node, statements) { if (node.statements !== statements) { - return updateNode(createDefaultClause(statements, node), node); + return updateNode(createDefaultClause(statements), node); } return node; } ts.updateDefaultClause = updateDefaultClause; - function createCatchClause(variableDeclaration, block, location) { - var node = createNode(256, location); + function createCatchClause(variableDeclaration, block) { + var node = createSynthesizedNode(259); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -9770,56 +10102,71 @@ var ts; ts.createCatchClause = createCatchClause; function updateCatchClause(node, variableDeclaration, block) { if (node.variableDeclaration !== variableDeclaration || node.block !== block) { - return updateNode(createCatchClause(variableDeclaration, block, node), node); + return updateNode(createCatchClause(variableDeclaration, block), node); } return node; } ts.updateCatchClause = updateCatchClause; - function createPropertyAssignment(name, initializer, location) { - var node = createNode(257, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAssignment(name, initializer) { + var node = createSynthesizedNode(260); + node.name = asName(name); node.questionToken = undefined; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createPropertyAssignment = createPropertyAssignment; function updatePropertyAssignment(node, name, initializer) { if (node.name !== name || node.initializer !== initializer) { - return updateNode(createPropertyAssignment(name, initializer, node), node); + return updateNode(createPropertyAssignment(name, initializer), node); } return node; } ts.updatePropertyAssignment = updatePropertyAssignment; - function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(258, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; + function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { + var node = createSynthesizedNode(261); + node.name = asName(name); + node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; - function createSpreadAssignment(expression, location) { - var node = createNode(259, location); - node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; + function createSpreadAssignment(expression) { + var node = createSynthesizedNode(262); + node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; return node; } ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { - return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node); + return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node); } return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function updateSpreadAssignment(node, expression) { if (node.expression !== expression) { - return updateNode(createSpreadAssignment(expression, node), node); + return updateNode(createSpreadAssignment(expression), node); } return node; } ts.updateSpreadAssignment = updateSpreadAssignment; + function createEnumMember(name, initializer) { + var node = createSynthesizedNode(263); + node.name = asName(name); + node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); + return node; + } + ts.createEnumMember = createEnumMember; + function updateEnumMember(node, name, initializer) { + return node.name !== name + || node.initializer !== initializer + ? updateNode(createEnumMember(name, initializer), node) + : node; + } + ts.updateEnumMember = updateEnumMember; function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(261, node, node.flags); + var updated = createSynthesizedNode(264); + updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -9878,56 +10225,73 @@ var ts; return node; } ts.updateSourceFileNode = updateSourceFileNode; + function getMutableClone(node) { + var clone = getSynthesizedClone(node); + clone.pos = node.pos; + clone.end = node.end; + clone.parent = node.parent; + return clone; + } + ts.getMutableClone = getMutableClone; function createNotEmittedStatement(original) { - var node = createNode(293, original); + var node = createSynthesizedNode(297); node.original = original; + setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createNode(296); + var node = createSynthesizedNode(300); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createNode(295); + var node = createSynthesizedNode(299); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; - function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(294, location || original); + function createPartiallyEmittedExpression(expression, original) { + var node = createSynthesizedNode(298); node.expression = expression; node.original = original; + setTextRange(node, original); return node; } ts.createPartiallyEmittedExpression = createPartiallyEmittedExpression; function updatePartiallyEmittedExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createPartiallyEmittedExpression(expression, node.original, node), node); + return updateNode(createPartiallyEmittedExpression(expression, node.original), node); } return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; - function createRawExpression(text) { - var node = createNode(297); - node.text = text; + function createBundle(sourceFiles) { + var node = ts.createNode(265); + node.sourceFiles = sourceFiles; return node; } - ts.createRawExpression = createRawExpression; + ts.createBundle = createBundle; + function updateBundle(node, sourceFiles) { + if (node.sourceFiles !== sourceFiles) { + return createBundle(sourceFiles); + } + return node; + } + ts.updateBundle = updateBundle; function createComma(left, right) { return createBinary(left, 25, right); } ts.createComma = createComma; - function createLessThan(left, right, location) { - return createBinary(left, 26, right, location); + function createLessThan(left, right) { + return createBinary(left, 26, right); } ts.createLessThan = createLessThan; - function createAssignment(left, right, location) { - return createBinary(left, 57, right, location); + function createAssignment(left, right) { + return createBinary(left, 57, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { @@ -9946,8 +10310,8 @@ var ts; return createBinary(left, 37, right); } ts.createSubtract = createSubtract; - function createPostfixIncrement(operand, location) { - return createPostfix(operand, 42, location); + function createPostfixIncrement(operand) { + return createPostfix(operand, 42); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { @@ -9966,97 +10330,6 @@ var ts; return createVoid(createLiteral(0)); } ts.createVoidZero = createVoidZero; - function createTypeCheck(value, tag) { - return tag === "undefined" - ? createStrictEquality(value, createVoidZero()) - : createStrictEquality(createTypeOf(value), createLiteral(tag)); - } - ts.createTypeCheck = createTypeCheck; - function createMemberAccessForPropertyName(target, memberName, location) { - if (ts.isComputedPropertyName(memberName)) { - return createElementAccess(target, memberName.expression, location); - } - else { - var expression = ts.isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); - (expression.emitNode || (expression.emitNode = {})).flags |= 64; - return expression; - } - } - ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; - function createFunctionCall(func, thisArg, argumentsList, location) { - return createCall(createPropertyAccess(func, "call"), undefined, [ - thisArg - ].concat(argumentsList), location); - } - ts.createFunctionCall = createFunctionCall; - function createFunctionApply(func, thisArg, argumentsExpression, location) { - return createCall(createPropertyAccess(func, "apply"), undefined, [ - thisArg, - argumentsExpression - ], location); - } - ts.createFunctionApply = createFunctionApply; - function createArraySlice(array, start) { - var argumentsList = []; - if (start !== undefined) { - argumentsList.push(typeof start === "number" ? createLiteral(start) : start); - } - return createCall(createPropertyAccess(array, "slice"), undefined, argumentsList); - } - ts.createArraySlice = createArraySlice; - function createArrayConcat(array, values) { - return createCall(createPropertyAccess(array, "concat"), undefined, values); - } - ts.createArrayConcat = createArrayConcat; - function createMathPow(left, right, location) { - return createCall(createPropertyAccess(createIdentifier("Math"), "pow"), undefined, [left, right], location); - } - ts.createMathPow = createMathPow; - function createReactNamespace(reactNamespace, parent) { - var react = createIdentifier(reactNamespace || "React"); - react.flags &= ~8; - react.parent = ts.getParseTreeNode(parent); - return react; - } - function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { - if (ts.isQualifiedName(jsxFactory)) { - var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent); - var right = createSynthesizedNode(70); - right.text = jsxFactory.right.text; - return createPropertyAccess(left, right); - } - else { - return createReactNamespace(jsxFactory.text, parent); - } - } - function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { - return jsxFactoryEntity ? - createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : - createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); - } - function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { - var argumentsList = [tagName]; - if (props) { - argumentsList.push(props); - } - if (children && children.length > 0) { - if (!props) { - argumentsList.push(createNull()); - } - if (children.length > 1) { - for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { - var child = children_1[_i]; - child.startsOnNewLine = true; - argumentsList.push(child); - } - } - else { - argumentsList.push(children[0]); - } - } - return createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList, location); - } - ts.createExpressionForJsxElement = createExpressionForJsxElement; function createExportDefault(expression) { return createExportAssignment(undefined, undefined, false, expression); } @@ -10065,573 +10338,17 @@ var ts; return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(exportName)])); } ts.createExternalModuleExport = createExternalModuleExport; - function createLetStatement(name, initializer, location) { - return createVariableStatement(undefined, createLetDeclarationList([createVariableDeclaration(name, undefined, initializer)]), location); + function asName(name) { + return typeof name === "string" ? createIdentifier(name) : name; } - ts.createLetStatement = createLetStatement; - function createLetDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 1); + function asExpression(value) { + return typeof value === "string" || typeof value === "number" ? createLiteral(value) : value; } - ts.createLetDeclarationList = createLetDeclarationList; - function createConstDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 2); + function asNodeArray(array) { + return array ? createNodeArray(array) : undefined; } - ts.createConstDeclarationList = createConstDeclarationList; - function getHelperName(name) { - return setEmitFlags(createIdentifier(name), 4096 | 2); - } - ts.getHelperName = getHelperName; - function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { - var target = skipParentheses(node); - switch (target.kind) { - case 70: - return cacheIdentifiers; - case 98: - case 8: - case 9: - return false; - case 175: - var elements = target.elements; - if (elements.length === 0) { - return false; - } - return true; - case 176: - return target.properties.length > 0; - default: - return true; - } - } - function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { - var callee = skipOuterExpressions(expression, 7); - var thisArg; - var target; - if (ts.isSuperProperty(callee)) { - thisArg = createThis(); - target = callee; - } - else if (callee.kind === 96) { - thisArg = createThis(); - target = languageVersion < 2 ? createIdentifier("_super", callee) : callee; - } - else { - switch (callee.kind) { - case 177: { - if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { - thisArg = createTempVariable(recordTempVariable); - target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); - } - else { - thisArg = callee.expression; - target = callee; - } - break; - } - case 178: { - if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { - thisArg = createTempVariable(recordTempVariable); - target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); - } - else { - thisArg = callee.expression; - target = callee; - } - break; - } - default: { - thisArg = createVoidZero(); - target = parenthesizeForAccess(expression); - break; - } - } - } - return { target: target, thisArg: thisArg }; - } - ts.createCallBinding = createCallBinding; - function inlineExpressions(expressions) { - return ts.reduceLeft(expressions, createComma); - } - ts.inlineExpressions = inlineExpressions; - function createExpressionFromEntityName(node) { - if (ts.isQualifiedName(node)) { - var left = createExpressionFromEntityName(node.left); - var right = getMutableClone(node.right); - return createPropertyAccess(left, right, node); - } - else { - return getMutableClone(node); - } - } - ts.createExpressionFromEntityName = createExpressionFromEntityName; - function createExpressionForPropertyName(memberName) { - if (ts.isIdentifier(memberName)) { - return createLiteral(memberName, undefined); - } - else if (ts.isComputedPropertyName(memberName)) { - return getMutableClone(memberName.expression); - } - else { - return getMutableClone(memberName); - } - } - ts.createExpressionForPropertyName = createExpressionForPropertyName; - function createExpressionForObjectLiteralElementLike(node, property, receiver) { - switch (property.kind) { - case 151: - case 152: - return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 257: - return createExpressionForPropertyAssignment(property, receiver); - case 258: - return createExpressionForShorthandPropertyAssignment(property, receiver); - case 149: - return createExpressionForMethodDeclaration(property, receiver); - } - } - ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike; - function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { - var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; - if (property === firstAccessor) { - var properties_1 = []; - if (getAccessor) { - var getterFunction = createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body, getAccessor); - setOriginalNode(getterFunction, getAccessor); - var getter = createPropertyAssignment("get", getterFunction); - properties_1.push(getter); - } - if (setAccessor) { - var setterFunction = createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body, setAccessor); - setOriginalNode(setterFunction, setAccessor); - var setter = createPropertyAssignment("set", setterFunction); - properties_1.push(setter); - } - properties_1.push(createPropertyAssignment("enumerable", createLiteral(true))); - properties_1.push(createPropertyAssignment("configurable", createLiteral(true))); - var expression = createCall(createPropertyAccess(createIdentifier("Object"), "defineProperty"), undefined, [ - receiver, - createExpressionForPropertyName(property.name), - createObjectLiteral(properties_1, undefined, multiLine) - ], firstAccessor); - return ts.aggregateTransformFlags(expression); - } - return undefined; - } - function createExpressionForPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), property.initializer, property), property)); - } - function createExpressionForShorthandPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), getSynthesizedClone(property.name), property), property)); - } - function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); - } - function getLocalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384); - } - ts.getLocalName = getLocalName; - function isLocalName(node) { - return (getEmitFlags(node) & 16384) !== 0; - } - ts.isLocalName = isLocalName; - function getExportName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 8192); - } - ts.getExportName = getExportName; - function isExportName(node) { - return (getEmitFlags(node) & 8192) !== 0; - } - ts.isExportName = isExportName; - function getDeclarationName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps); - } - ts.getDeclarationName = getDeclarationName; - function getName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { - var name_8 = getMutableClone(node.name); - emitFlags |= getEmitFlags(node.name); - if (!allowSourceMaps) - emitFlags |= 48; - if (!allowComments) - emitFlags |= 1536; - if (emitFlags) - setEmitFlags(name_8, emitFlags); - return name_8; - } - return getGeneratedNameForNode(node); - } - function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && ts.hasModifier(node, 1)) { - return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); - } - return getExportName(node, allowComments, allowSourceMaps); - } - ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName; - function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { - var qualifiedName = createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : getSynthesizedClone(name), name); - var emitFlags; - if (!allowSourceMaps) - emitFlags |= 48; - if (!allowComments) - emitFlags |= 1536; - if (emitFlags) - setEmitFlags(qualifiedName, emitFlags); - return qualifiedName; - } - ts.getNamespaceMemberName = getNamespaceMemberName; - function convertToFunctionBody(node, multiLine) { - return ts.isBlock(node) ? node : createBlock([createReturn(node, node)], node, multiLine); - } - ts.convertToFunctionBody = convertToFunctionBody; - function isUseStrictPrologue(node) { - return node.expression.text === "use strict"; - } - function addPrologueDirectives(target, source, ensureUseStrict, visitor) { - ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); - var foundUseStrict = false; - var statementOffset = 0; - var numStatements = source.length; - while (statementOffset < numStatements) { - var statement = source[statementOffset]; - if (ts.isPrologueDirective(statement)) { - if (isUseStrictPrologue(statement)) { - foundUseStrict = true; - } - target.push(statement); - } - else { - break; - } - statementOffset++; - } - if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); - } - while (statementOffset < numStatements) { - var statement = source[statementOffset]; - if (getEmitFlags(statement) & 524288) { - target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); - } - else { - break; - } - statementOffset++; - } - return statementOffset; - } - ts.addPrologueDirectives = addPrologueDirectives; - function startsWithUseStrict(statements) { - var firstStatement = ts.firstOrUndefined(statements); - return firstStatement !== undefined - && ts.isPrologueDirective(firstStatement) - && isUseStrictPrologue(firstStatement); - } - ts.startsWithUseStrict = startsWithUseStrict; - function ensureUseStrict(statements) { - var foundUseStrict = false; - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; - if (ts.isPrologueDirective(statement)) { - if (isUseStrictPrologue(statement)) { - foundUseStrict = true; - break; - } - } - else { - break; - } - } - if (!foundUseStrict) { - return createNodeArray([ - startOnNewLine(createStatement(createLiteral("use strict"))) - ].concat(statements), statements); - } - return statements; - } - ts.ensureUseStrict = ensureUseStrict; - function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 183) { - return operand; - } - return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) - ? createParen(operand) - : operand; - } - ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; - function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(192, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(192, binaryOperator); - var emittedOperand = skipPartiallyEmittedExpressions(operand); - var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); - switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { - case -1: - if (!isLeftSideOfBinary - && binaryOperatorAssociativity === 1 - && operand.kind === 195) { - return false; - } - return true; - case 1: - return false; - case 0: - if (isLeftSideOfBinary) { - return binaryOperatorAssociativity === 1; - } - else { - if (ts.isBinaryExpression(emittedOperand) - && emittedOperand.operatorToken.kind === binaryOperator) { - if (operatorHasAssociativeProperty(binaryOperator)) { - return false; - } - if (binaryOperator === 36) { - var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; - if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { - return false; - } - } - } - var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); - return operandAssociativity === 0; - } - } - } - function operatorHasAssociativeProperty(binaryOperator) { - return binaryOperator === 38 - || binaryOperator === 48 - || binaryOperator === 47 - || binaryOperator === 49; - } - function getLiteralKindOfBinaryPlusOperand(node) { - node = skipPartiallyEmittedExpressions(node); - if (ts.isLiteralKind(node.kind)) { - return node.kind; - } - if (node.kind === 192 && node.operatorToken.kind === 36) { - if (node.cachedLiteralKind !== undefined) { - return node.cachedLiteralKind; - } - var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0; - node.cachedLiteralKind = literalKind; - return literalKind; - } - return 0; - } - function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(193, 54); - var emittedCondition = skipPartiallyEmittedExpressions(condition); - var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { - return createParen(condition); - } - return condition; - } - ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; - function parenthesizeSubexpressionOfConditionalExpression(e) { - return e.kind === 192 && e.operatorToken.kind === 25 - ? createParen(e) - : e; - } - function parenthesizeForNew(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - switch (emittedExpression.kind) { - case 179: - return createParen(expression); - case 180: - return emittedExpression.arguments - ? expression - : createParen(expression); - } - return parenthesizeForAccess(expression); - } - ts.parenthesizeForNew = parenthesizeForNew; - function parenthesizeForAccess(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 180 || emittedExpression.arguments) - && emittedExpression.kind !== 8) { - return expression; - } - return createParen(expression, expression); - } - ts.parenthesizeForAccess = parenthesizeForAccess; - function parenthesizePostfixOperand(operand) { - return ts.isLeftHandSideExpression(operand) - ? operand - : createParen(operand, operand); - } - ts.parenthesizePostfixOperand = parenthesizePostfixOperand; - function parenthesizePrefixOperand(operand) { - return ts.isUnaryExpression(operand) - ? operand - : createParen(operand, operand); - } - ts.parenthesizePrefixOperand = parenthesizePrefixOperand; - function parenthesizeListElements(elements) { - var result; - for (var i = 0; i < elements.length; i++) { - var element = parenthesizeExpressionForList(elements[i]); - if (result !== undefined || element !== elements[i]) { - if (result === undefined) { - result = elements.slice(0, i); - } - result.push(element); - } - } - if (result !== undefined) { - return createNodeArray(result, elements, elements.hasTrailingComma); - } - return elements; - } - function parenthesizeExpressionForList(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(192, 25); - return expressionPrecedence > commaPrecedence - ? expression - : createParen(expression, expression); - } - ts.parenthesizeExpressionForList = parenthesizeExpressionForList; - function parenthesizeExpressionForExpressionStatement(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - if (ts.isCallExpression(emittedExpression)) { - var callee = emittedExpression.expression; - var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 184 || kind === 185) { - var mutableCall = getMutableClone(emittedExpression); - mutableCall.expression = createParen(callee, callee); - return recreatePartiallyEmittedExpressions(expression, mutableCall); - } - } - else { - var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 176 || leftmostExpressionKind === 184) { - return createParen(expression, expression); - } - } - return expression; - } - ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; - function recreatePartiallyEmittedExpressions(originalOuterExpression, newInnerExpression) { - if (ts.isPartiallyEmittedExpression(originalOuterExpression)) { - var clone_1 = getMutableClone(originalOuterExpression); - clone_1.expression = recreatePartiallyEmittedExpressions(clone_1.expression, newInnerExpression); - return clone_1; - } - return newInnerExpression; - } - function getLeftmostExpression(node) { - while (true) { - switch (node.kind) { - case 191: - node = node.operand; - continue; - case 192: - node = node.left; - continue; - case 193: - node = node.condition; - continue; - case 179: - case 178: - case 177: - node = node.expression; - continue; - case 294: - node = node.expression; - continue; - } - return node; - } - } - function parenthesizeConciseBody(body) { - var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 176) { - return createParen(body, body); - } - return body; - } - ts.parenthesizeConciseBody = parenthesizeConciseBody; - function skipOuterExpressions(node, kinds) { - if (kinds === void 0) { kinds = 7; } - var previousNode; - do { - previousNode = node; - if (kinds & 1) { - node = skipParentheses(node); - } - if (kinds & 2) { - node = skipAssertions(node); - } - if (kinds & 4) { - node = skipPartiallyEmittedExpressions(node); - } - } while (previousNode !== node); - return node; - } - ts.skipOuterExpressions = skipOuterExpressions; - function skipParentheses(node) { - while (node.kind === 183) { - node = node.expression; - } - return node; - } - ts.skipParentheses = skipParentheses; - function skipAssertions(node) { - while (ts.isAssertionExpression(node)) { - node = node.expression; - } - return node; - } - ts.skipAssertions = skipAssertions; - function skipPartiallyEmittedExpressions(node) { - while (node.kind === 294) { - node = node.expression; - } - return node; - } - ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; - function startOnNewLine(node) { - node.startsOnNewLine = true; - return node; - } - ts.startOnNewLine = startOnNewLine; - function setOriginalNode(node, original) { - node.original = original; - if (original) { - var emitNode = original.emitNode; - if (emitNode) - node.emitNode = mergeEmitNode(emitNode, node.emitNode); - } - return node; - } - ts.setOriginalNode = setOriginalNode; - function mergeEmitNode(sourceEmitNode, destEmitNode) { - var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; - if (!destEmitNode) - destEmitNode = {}; - if (flags) - destEmitNode.flags = flags; - if (commentRange) - destEmitNode.commentRange = commentRange; - if (sourceMapRange) - destEmitNode.sourceMapRange = sourceMapRange; - if (tokenSourceMapRanges) - destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); - if (constantValue !== undefined) - destEmitNode.constantValue = constantValue; - if (helpers) - destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); - return destEmitNode; - } - function mergeTokenSourceMapRanges(sourceRanges, destRanges) { - if (!destRanges) - destRanges = ts.createMap(); - ts.copyProperties(sourceRanges, destRanges); - return destRanges; + function asToken(value) { + return typeof value === "number" ? createToken(value) : value; } function disposeEmitNodes(sourceFile) { sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); @@ -10648,7 +10365,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 261) { + if (node.kind === 264) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -10659,6 +10376,14 @@ var ts; return node.emitNode; } ts.getOrCreateEmitNode = getOrCreateEmitNode; + function setTextRange(range, location) { + if (location) { + range.pos = location.pos; + range.end = location.end; + } + return range; + } + ts.setTextRange = setTextRange; function getEmitFlags(node) { var emitNode = node.emitNode; return emitNode && emitNode.flags; @@ -10687,7 +10412,7 @@ var ts; ts.getTokenSourceMapRange = getTokenSourceMapRange; function setTokenSourceMapRange(node, token, range) { var emitNode = getOrCreateEmitNode(node); - var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = ts.createMap()); + var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = []); tokenSourceMapRanges[token] = range; return node; } @@ -10713,32 +10438,6 @@ var ts; return node; } ts.setConstantValue = setConstantValue; - function getExternalHelpersModuleName(node) { - var parseNode = ts.getOriginalNode(node, ts.isSourceFile); - var emitNode = parseNode && parseNode.emitNode; - return emitNode && emitNode.externalHelpersModuleName; - } - ts.getExternalHelpersModuleName = getExternalHelpersModuleName; - function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions) { - if (compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { - var externalHelpersModuleName = getExternalHelpersModuleName(node); - if (externalHelpersModuleName) { - return externalHelpersModuleName; - } - var helpers = getEmitHelpers(node); - if (helpers) { - for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { - var helper = helpers_1[_i]; - if (!helper.scoped) { - var parseNode = ts.getOriginalNode(node, ts.isSourceFile); - var emitNode = getOrCreateEmitNode(parseNode); - return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = createUniqueName(ts.externalHelpersModuleNameText)); - } - } - } - } - } - ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded; function addEmitHelper(node, helper) { var emitNode = getOrCreateEmitNode(node); emitNode.helpers = ts.append(emitNode.helpers, helper); @@ -10748,8 +10447,8 @@ var ts; function addEmitHelpers(node, helpers) { if (ts.some(helpers)) { var emitNode = getOrCreateEmitNode(node); - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; + for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { + var helper = helpers_1[_i]; if (!ts.contains(emitNode.helpers, helper)) { emitNode.helpers = ts.append(emitNode.helpers, helper); } @@ -10810,40 +10509,718 @@ var ts; return ts.compareValues(x.priority, y.priority); } ts.compareEmitHelpers = compareEmitHelpers; - function setTextRange(node, location) { - if (location) { - node.pos = location.pos; - node.end = location.end; + function setOriginalNode(node, original) { + node.original = original; + if (original) { + var emitNode = original.emitNode; + if (emitNode) + node.emitNode = mergeEmitNode(emitNode, node.emitNode); } return node; } - ts.setTextRange = setTextRange; - function setNodeFlags(node, flags) { - node.flags = flags; + ts.setOriginalNode = setOriginalNode; + function mergeEmitNode(sourceEmitNode, destEmitNode) { + var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; + if (!destEmitNode) + destEmitNode = {}; + if (flags) + destEmitNode.flags = flags; + if (commentRange) + destEmitNode.commentRange = commentRange; + if (sourceMapRange) + destEmitNode.sourceMapRange = sourceMapRange; + if (tokenSourceMapRanges) + destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); + if (constantValue !== undefined) + destEmitNode.constantValue = constantValue; + if (helpers) + destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); + return destEmitNode; + } + function mergeTokenSourceMapRanges(sourceRanges, destRanges) { + if (!destRanges) + destRanges = []; + for (var key in sourceRanges) { + destRanges[key] = sourceRanges[key]; + } + return destRanges; + } +})(ts || (ts = {})); +(function (ts) { + function createTypeCheck(value, tag) { + return tag === "undefined" + ? ts.createStrictEquality(value, ts.createVoidZero()) + : ts.createStrictEquality(ts.createTypeOf(value), ts.createLiteral(tag)); + } + ts.createTypeCheck = createTypeCheck; + function createMemberAccessForPropertyName(target, memberName, location) { + if (ts.isComputedPropertyName(memberName)) { + return ts.setTextRange(ts.createElementAccess(target, memberName.expression), location); + } + else { + var expression = ts.setTextRange(ts.isIdentifier(memberName) + ? ts.createPropertyAccess(target, memberName) + : ts.createElementAccess(target, memberName), memberName); + ts.getOrCreateEmitNode(expression).flags |= 64; + return expression; + } + } + ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; + function createFunctionCall(func, thisArg, argumentsList, location) { + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), undefined, [ + thisArg + ].concat(argumentsList)), location); + } + ts.createFunctionCall = createFunctionCall; + function createFunctionApply(func, thisArg, argumentsExpression, location) { + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "apply"), undefined, [ + thisArg, + argumentsExpression + ]), location); + } + ts.createFunctionApply = createFunctionApply; + function createArraySlice(array, start) { + var argumentsList = []; + if (start !== undefined) { + argumentsList.push(typeof start === "number" ? ts.createLiteral(start) : start); + } + return ts.createCall(ts.createPropertyAccess(array, "slice"), undefined, argumentsList); + } + ts.createArraySlice = createArraySlice; + function createArrayConcat(array, values) { + return ts.createCall(ts.createPropertyAccess(array, "concat"), undefined, values); + } + ts.createArrayConcat = createArrayConcat; + function createMathPow(left, right, location) { + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Math"), "pow"), undefined, [left, right]), location); + } + ts.createMathPow = createMathPow; + function createReactNamespace(reactNamespace, parent) { + var react = ts.createIdentifier(reactNamespace || "React"); + react.flags &= ~8; + react.parent = ts.getParseTreeNode(parent); + return react; + } + function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { + if (ts.isQualifiedName(jsxFactory)) { + var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent); + var right = ts.createIdentifier(jsxFactory.right.text); + right.text = jsxFactory.right.text; + return ts.createPropertyAccess(left, right); + } + else { + return createReactNamespace(jsxFactory.text, parent); + } + } + function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { + return jsxFactoryEntity ? + createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : + ts.createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); + } + function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { + var argumentsList = [tagName]; + if (props) { + argumentsList.push(props); + } + if (children && children.length > 0) { + if (!props) { + argumentsList.push(ts.createNull()); + } + if (children.length > 1) { + for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { + var child = children_1[_i]; + child.startsOnNewLine = true; + argumentsList.push(child); + } + } + else { + argumentsList.push(children[0]); + } + } + return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList), location); + } + ts.createExpressionForJsxElement = createExpressionForJsxElement; + function getHelperName(name) { + return ts.setEmitFlags(ts.createIdentifier(name), 4096 | 2); + } + ts.getHelperName = getHelperName; + function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { + if (!outermostLabeledStatement) { + return node; + } + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 221 + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + ts.restoreEnclosingLabel = restoreEnclosingLabel; + function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { + var target = skipParentheses(node); + switch (target.kind) { + case 70: + return cacheIdentifiers; + case 98: + case 8: + case 9: + return false; + case 176: + var elements = target.elements; + if (elements.length === 0) { + return false; + } + return true; + case 177: + return target.properties.length > 0; + default: + return true; + } + } + function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { + var callee = skipOuterExpressions(expression, 7); + var thisArg; + var target; + if (ts.isSuperProperty(callee)) { + thisArg = ts.createThis(); + target = callee; + } + else if (callee.kind === 96) { + thisArg = ts.createThis(); + target = languageVersion < 2 + ? ts.setTextRange(ts.createIdentifier("_super"), callee) + : callee; + } + else { + switch (callee.kind) { + case 178: { + if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); + ts.setTextRange(target, callee); + } + else { + thisArg = callee.expression; + target = callee; + } + break; + } + case 179: { + if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); + ts.setTextRange(target, callee); + } + else { + thisArg = callee.expression; + target = callee; + } + break; + } + default: { + thisArg = ts.createVoidZero(); + target = parenthesizeForAccess(expression); + break; + } + } + } + return { target: target, thisArg: thisArg }; + } + ts.createCallBinding = createCallBinding; + function inlineExpressions(expressions) { + return ts.reduceLeft(expressions, ts.createComma); + } + ts.inlineExpressions = inlineExpressions; + function createExpressionFromEntityName(node) { + if (ts.isQualifiedName(node)) { + var left = createExpressionFromEntityName(node.left); + var right = ts.getMutableClone(node.right); + return ts.setTextRange(ts.createPropertyAccess(left, right), node); + } + else { + return ts.getMutableClone(node); + } + } + ts.createExpressionFromEntityName = createExpressionFromEntityName; + function createExpressionForPropertyName(memberName) { + if (ts.isIdentifier(memberName)) { + return ts.createLiteral(memberName); + } + else if (ts.isComputedPropertyName(memberName)) { + return ts.getMutableClone(memberName.expression); + } + else { + return ts.getMutableClone(memberName); + } + } + ts.createExpressionForPropertyName = createExpressionForPropertyName; + function createExpressionForObjectLiteralElementLike(node, property, receiver) { + switch (property.kind) { + case 152: + case 153: + return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); + case 260: + return createExpressionForPropertyAssignment(property, receiver); + case 261: + return createExpressionForShorthandPropertyAssignment(property, receiver); + case 150: + return createExpressionForMethodDeclaration(property, receiver); + } + } + ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike; + function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { + var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + if (property === firstAccessor) { + var properties_1 = []; + if (getAccessor) { + var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body); + ts.setTextRange(getterFunction, getAccessor); + ts.setOriginalNode(getterFunction, getAccessor); + var getter = ts.createPropertyAssignment("get", getterFunction); + properties_1.push(getter); + } + if (setAccessor) { + var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body); + ts.setTextRange(setterFunction, setAccessor); + ts.setOriginalNode(setterFunction, setAccessor); + var setter = ts.createPropertyAssignment("set", setterFunction); + properties_1.push(setter); + } + properties_1.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_1.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + receiver, + createExpressionForPropertyName(property.name), + ts.createObjectLiteral(properties_1, multiLine) + ]), firstAccessor); + return ts.aggregateTransformFlags(expression); + } + return undefined; + } + function createExpressionForPropertyAssignment(property, receiver) { + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), property.initializer), property), property)); + } + function createExpressionForShorthandPropertyAssignment(property, receiver) { + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), ts.getSynthesizedClone(property.name)), property), property)); + } + function createExpressionForMethodDeclaration(method, receiver) { + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body), method), method)), method), method)); + } + function getLocalName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 16384); + } + ts.getLocalName = getLocalName; + function isLocalName(node) { + return (ts.getEmitFlags(node) & 16384) !== 0; + } + ts.isLocalName = isLocalName; + function getExportName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 8192); + } + ts.getExportName = getExportName; + function isExportName(node) { + return (ts.getEmitFlags(node) & 8192) !== 0; + } + ts.isExportName = isExportName; + function getDeclarationName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps); + } + ts.getDeclarationName = getDeclarationName; + function getName(node, allowComments, allowSourceMaps, emitFlags) { + if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { + var name = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); + if (!allowSourceMaps) + emitFlags |= 48; + if (!allowComments) + emitFlags |= 1536; + if (emitFlags) + ts.setEmitFlags(name, emitFlags); + return name; + } + return ts.getGeneratedNameForNode(node); + } + function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { + if (ns && ts.hasModifier(node, 1)) { + return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); + } + return getExportName(node, allowComments, allowSourceMaps); + } + ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName; + function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { + var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name)); + ts.setTextRange(qualifiedName, name); + var emitFlags; + if (!allowSourceMaps) + emitFlags |= 48; + if (!allowComments) + emitFlags |= 1536; + if (emitFlags) + ts.setEmitFlags(qualifiedName, emitFlags); + return qualifiedName; + } + ts.getNamespaceMemberName = getNamespaceMemberName; + function convertToFunctionBody(node, multiLine) { + return ts.isBlock(node) ? node : ts.setTextRange(ts.createBlock([ts.setTextRange(ts.createReturn(node), node)], multiLine), node); + } + ts.convertToFunctionBody = convertToFunctionBody; + function isUseStrictPrologue(node) { + return node.expression.text === "use strict"; + } + function addPrologueDirectives(target, source, ensureUseStrict, visitor) { + ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); + var foundUseStrict = false; + var statementOffset = 0; + var numStatements = source.length; + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + } + target.push(statement); + } + else { + break; + } + statementOffset++; + } + if (ensureUseStrict && !foundUseStrict) { + target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))); + } + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (ts.getEmitFlags(statement) & 524288) { + target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); + } + else { + break; + } + statementOffset++; + } + return statementOffset; + } + ts.addPrologueDirectives = addPrologueDirectives; + function startsWithUseStrict(statements) { + var firstStatement = ts.firstOrUndefined(statements); + return firstStatement !== undefined + && ts.isPrologueDirective(firstStatement) + && isUseStrictPrologue(firstStatement); + } + ts.startsWithUseStrict = startsWithUseStrict; + function ensureUseStrict(statements) { + var foundUseStrict = false; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + break; + } + } + else { + break; + } + } + if (!foundUseStrict) { + return ts.setTextRange(ts.createNodeArray([ + startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) + ].concat(statements)), statements); + } + return statements; + } + ts.ensureUseStrict = ensureUseStrict; + function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { + var skipped = skipPartiallyEmittedExpressions(operand); + if (skipped.kind === 184) { + return operand; + } + return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) + ? ts.createParen(operand) + : operand; + } + ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; + function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { + var binaryOperatorPrecedence = ts.getOperatorPrecedence(193, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(193, binaryOperator); + var emittedOperand = skipPartiallyEmittedExpressions(operand); + var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); + switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { + case -1: + if (!isLeftSideOfBinary + && binaryOperatorAssociativity === 1 + && operand.kind === 196) { + return false; + } + return true; + case 1: + return false; + case 0: + if (isLeftSideOfBinary) { + return binaryOperatorAssociativity === 1; + } + else { + if (ts.isBinaryExpression(emittedOperand) + && emittedOperand.operatorToken.kind === binaryOperator) { + if (operatorHasAssociativeProperty(binaryOperator)) { + return false; + } + if (binaryOperator === 36) { + var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; + if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { + return false; + } + } + } + var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); + return operandAssociativity === 0; + } + } + } + function operatorHasAssociativeProperty(binaryOperator) { + return binaryOperator === 38 + || binaryOperator === 48 + || binaryOperator === 47 + || binaryOperator === 49; + } + function getLiteralKindOfBinaryPlusOperand(node) { + node = skipPartiallyEmittedExpressions(node); + if (ts.isLiteralKind(node.kind)) { + return node.kind; + } + if (node.kind === 193 && node.operatorToken.kind === 36) { + if (node.cachedLiteralKind !== undefined) { + return node.cachedLiteralKind; + } + var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); + var literalKind = ts.isLiteralKind(leftKind) + && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) + ? leftKind + : 0; + node.cachedLiteralKind = literalKind; + return literalKind; + } + return 0; + } + function parenthesizeForConditionalHead(condition) { + var conditionalPrecedence = ts.getOperatorPrecedence(194, 54); + var emittedCondition = skipPartiallyEmittedExpressions(condition); + var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { + return ts.createParen(condition); + } + return condition; + } + ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; + function parenthesizeSubexpressionOfConditionalExpression(e) { + return e.kind === 193 && e.operatorToken.kind === 25 + ? ts.createParen(e) + : e; + } + ts.parenthesizeSubexpressionOfConditionalExpression = parenthesizeSubexpressionOfConditionalExpression; + function parenthesizeForNew(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + switch (emittedExpression.kind) { + case 180: + return ts.createParen(expression); + case 181: + return emittedExpression.arguments + ? expression + : ts.createParen(expression); + } + return parenthesizeForAccess(expression); + } + ts.parenthesizeForNew = parenthesizeForNew; + function parenthesizeForAccess(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + if (ts.isLeftHandSideExpression(emittedExpression) + && (emittedExpression.kind !== 181 || emittedExpression.arguments) + && emittedExpression.kind !== 8) { + return expression; + } + return ts.setTextRange(ts.createParen(expression), expression); + } + ts.parenthesizeForAccess = parenthesizeForAccess; + function parenthesizePostfixOperand(operand) { + return ts.isLeftHandSideExpression(operand) + ? operand + : ts.setTextRange(ts.createParen(operand), operand); + } + ts.parenthesizePostfixOperand = parenthesizePostfixOperand; + function parenthesizePrefixOperand(operand) { + return ts.isUnaryExpression(operand) + ? operand + : ts.setTextRange(ts.createParen(operand), operand); + } + ts.parenthesizePrefixOperand = parenthesizePrefixOperand; + function parenthesizeListElements(elements) { + var result; + for (var i = 0; i < elements.length; i++) { + var element = parenthesizeExpressionForList(elements[i]); + if (result !== undefined || element !== elements[i]) { + if (result === undefined) { + result = elements.slice(0, i); + } + result.push(element); + } + } + if (result !== undefined) { + return ts.setTextRange(ts.createNodeArray(result, elements.hasTrailingComma), elements); + } + return elements; + } + ts.parenthesizeListElements = parenthesizeListElements; + function parenthesizeExpressionForList(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); + var commaPrecedence = ts.getOperatorPrecedence(193, 25); + return expressionPrecedence > commaPrecedence + ? expression + : ts.setTextRange(ts.createParen(expression), expression); + } + ts.parenthesizeExpressionForList = parenthesizeExpressionForList; + function parenthesizeExpressionForExpressionStatement(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + if (ts.isCallExpression(emittedExpression)) { + var callee = emittedExpression.expression; + var kind = skipPartiallyEmittedExpressions(callee).kind; + if (kind === 185 || kind === 186) { + var mutableCall = ts.getMutableClone(emittedExpression); + mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); + return recreatePartiallyEmittedExpressions(expression, mutableCall); + } + } + else { + var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; + if (leftmostExpressionKind === 177 || leftmostExpressionKind === 185) { + return ts.setTextRange(ts.createParen(expression), expression); + } + } + return expression; + } + ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; + function recreatePartiallyEmittedExpressions(originalOuterExpression, newInnerExpression) { + if (ts.isPartiallyEmittedExpression(originalOuterExpression)) { + var clone_1 = ts.getMutableClone(originalOuterExpression); + clone_1.expression = recreatePartiallyEmittedExpressions(clone_1.expression, newInnerExpression); + return clone_1; + } + return newInnerExpression; + } + function getLeftmostExpression(node) { + while (true) { + switch (node.kind) { + case 192: + node = node.operand; + continue; + case 193: + node = node.left; + continue; + case 194: + node = node.condition; + continue; + case 180: + case 179: + case 178: + node = node.expression; + continue; + case 298: + node = node.expression; + continue; + } + return node; + } + } + function parenthesizeConciseBody(body) { + var emittedBody = skipPartiallyEmittedExpressions(body); + if (emittedBody.kind === 177) { + return ts.setTextRange(ts.createParen(body), body); + } + return body; + } + ts.parenthesizeConciseBody = parenthesizeConciseBody; + function skipOuterExpressions(node, kinds) { + if (kinds === void 0) { kinds = 7; } + var previousNode; + do { + previousNode = node; + if (kinds & 1) { + node = skipParentheses(node); + } + if (kinds & 2) { + node = skipAssertions(node); + } + if (kinds & 4) { + node = skipPartiallyEmittedExpressions(node); + } + } while (previousNode !== node); return node; } - ts.setNodeFlags = setNodeFlags; - function setMultiLine(node, multiLine) { - node.multiLine = multiLine; + ts.skipOuterExpressions = skipOuterExpressions; + function skipParentheses(node) { + while (node.kind === 184) { + node = node.expression; + } return node; } - ts.setMultiLine = setMultiLine; - function setHasTrailingComma(nodes, hasTrailingComma) { - nodes.hasTrailingComma = hasTrailingComma; - return nodes; + ts.skipParentheses = skipParentheses; + function skipAssertions(node) { + while (ts.isAssertionExpression(node)) { + node = node.expression; + } + return node; } - ts.setHasTrailingComma = setHasTrailingComma; + ts.skipAssertions = skipAssertions; + function skipPartiallyEmittedExpressions(node) { + while (node.kind === 298) { + node = node.expression; + } + return node; + } + ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; + function startOnNewLine(node) { + node.startsOnNewLine = true; + return node; + } + ts.startOnNewLine = startOnNewLine; + function getExternalHelpersModuleName(node) { + var parseNode = ts.getOriginalNode(node, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return emitNode && emitNode.externalHelpersModuleName; + } + ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions) { + if (compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { + var externalHelpersModuleName = getExternalHelpersModuleName(node); + if (externalHelpersModuleName) { + return externalHelpersModuleName; + } + var helpers = ts.getEmitHelpers(node); + if (helpers) { + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!helper.scoped) { + var parseNode = ts.getOriginalNode(node, ts.isSourceFile); + var emitNode = ts.getOrCreateEmitNode(parseNode); + return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = ts.createUniqueName(ts.externalHelpersModuleNameText)); + } + } + } + } + } + ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_9 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 235 && node.importClause) { - return getGeneratedNameForNode(node); + if (node.kind === 237 && node.importClause) { + return ts.getGeneratedNameForNode(node); } - if (node.kind === 241 && node.moduleSpecifier) { - return getGeneratedNameForNode(node); + if (node.kind === 243 && node.moduleSpecifier) { + return ts.getGeneratedNameForNode(node); } return undefined; } @@ -10853,26 +11230,24 @@ var ts; if (moduleName.kind === 9) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) - || getSynthesizedClone(moduleName); + || ts.getSynthesizedClone(moduleName); } return undefined; } ts.getExternalModuleNameLiteral = getExternalModuleNameLiteral; function tryRenameExternalModule(moduleName, sourceFile) { - if (sourceFile.renamedDependencies && ts.hasProperty(sourceFile.renamedDependencies, moduleName.text)) { - return createLiteral(sourceFile.renamedDependencies[moduleName.text]); - } - return undefined; + var rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text); + return rename && ts.createLiteral(rename); } function tryGetModuleNameFromFile(file, host, options) { if (!file) { return undefined; } if (file.moduleName) { - return createLiteral(file.moduleName); + return ts.createLiteral(file.moduleName); } if (!ts.isDeclarationFile(file) && (options.out || options.outFile)) { - return createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); + return ts.createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); } return undefined; } @@ -10906,11 +11281,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 257: + case 260: return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 258: + case 261: return bindingElement.name; - case 259: + case 262: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -10926,11 +11301,11 @@ var ts; ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 144: - case 174: + case 145: + case 175: return bindingElement.dotDotDotToken; - case 196: - case 259: + case 197: + case 262: return bindingElement; } return undefined; @@ -10938,7 +11313,7 @@ var ts; ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement; function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 174: + case 175: if (bindingElement.propertyName) { var propertyName = bindingElement.propertyName; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -10946,7 +11321,7 @@ var ts; : propertyName; } break; - case 257: + case 260: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -10954,7 +11329,7 @@ var ts; : propertyName; } break; - case 259: + case 262: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -10968,11 +11343,11 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 172: case 173: - case 175: - return name.elements; + case 174: case 176: + return name.elements; + case 177: return name.properties; } } @@ -10981,10 +11356,12 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpread(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpread(element.name), element), element); } var expression = convertToAssignmentElementTarget(element.name); - return element.initializer ? setOriginalNode(createAssignment(expression, element.initializer, element), element) : expression; + return element.initializer + ? ts.setOriginalNode(ts.setTextRange(ts.createAssignment(expression, element.initializer), element), element) + : expression; } ts.Debug.assertNode(element, ts.isExpression); return element; @@ -10994,14 +11371,14 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpreadAssignment(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpreadAssignment(element.name), element), element); } if (element.propertyName) { var expression = convertToAssignmentElementTarget(element.name); - return setOriginalNode(createPropertyAssignment(element.propertyName, element.initializer ? createAssignment(expression, element.initializer) : expression, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createPropertyAssignment(element.propertyName, element.initializer ? ts.createAssignment(expression, element.initializer) : expression), element), element); } ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createShorthandPropertyAssignment(element.name, element.initializer, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createShorthandPropertyAssignment(element.name, element.initializer), element), element); } ts.Debug.assertNode(element, ts.isObjectLiteralElementLike); return element; @@ -11009,18 +11386,18 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 173: - case 175: - return convertToArrayAssignmentPattern(node); - case 172: + case 174: case 176: + return convertToArrayAssignmentPattern(node); + case 173: + case 177: return convertToObjectAssignmentPattern(node); } } ts.convertToAssignmentPattern = convertToAssignmentPattern; function convertToObjectAssignmentPattern(node) { if (ts.isObjectBindingPattern(node)) { - return setOriginalNode(createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isObjectLiteralExpression); return node; @@ -11028,7 +11405,7 @@ var ts; ts.convertToObjectAssignmentPattern = convertToObjectAssignmentPattern; function convertToArrayAssignmentPattern(node) { if (ts.isArrayBindingPattern(node)) { - return setOriginalNode(createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isArrayLiteralExpression); return node; @@ -11044,30 +11421,30 @@ var ts; ts.convertToAssignmentElementTarget = convertToAssignmentElementTarget; function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) { var externalImports = []; - var exportSpecifiers = ts.createMap(); - var exportedBindings = ts.createMap(); + var exportSpecifiers = ts.createMultiMap(); + var exportedBindings = []; var uniqueExports = ts.createMap(); var exportedNames; var hasExportDefault = false; var exportEquals = undefined; var hasExportStarsToExportValues = false; var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions); - var externalHelpersImportDeclaration = externalHelpersModuleName && createImportDeclaration(undefined, undefined, createImportClause(undefined, createNamespaceImport(externalHelpersModuleName)), createLiteral(ts.externalHelpersModuleNameText)); + var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); if (externalHelpersImportDeclaration) { externalImports.push(externalHelpersImportDeclaration); } for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 235: + case 237: externalImports.push(node); break; - case 234: - if (node.moduleReference.kind === 245) { + case 236: + if (node.moduleReference.kind === 247) { externalImports.push(node); } break; - case 241: + case 243: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -11080,26 +11457,26 @@ var ts; else { for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - if (!uniqueExports[specifier.name.text]) { - var name_10 = specifier.propertyName || specifier.name; - ts.multiMapAdd(exportSpecifiers, name_10.text, specifier); - var decl = resolver.getReferencedImportDeclaration(name_10) - || resolver.getReferencedValueDeclaration(name_10); + if (!uniqueExports.get(specifier.name.text)) { + var name = specifier.propertyName || specifier.name; + exportSpecifiers.add(name.text, specifier); + var decl = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); if (decl) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); } - uniqueExports[specifier.name.text] = true; + uniqueExports.set(specifier.name.text, true); exportedNames = ts.append(exportedNames, specifier.name); } } } break; - case 240: + case 242: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 205: + case 207: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -11107,38 +11484,38 @@ var ts; } } break; - case 225: + case 227: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { - var name_11 = node.name; - if (!uniqueExports[name_11.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_11); - uniqueExports[name_11.text] = true; - exportedNames = ts.append(exportedNames, name_11); + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); } } } break; - case 226: + case 228: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { - var name_12 = node.name; - if (!uniqueExports[name_12.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_12); - uniqueExports[name_12.text] = true; - exportedNames = ts.append(exportedNames, name_12); + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); } } } @@ -11158,13 +11535,23 @@ var ts; } } else if (!ts.isGeneratedIdentifier(decl.name)) { - if (!uniqueExports[decl.name.text]) { - uniqueExports[decl.name.text] = true; + if (!uniqueExports.get(decl.name.text)) { + uniqueExports.set(decl.name.text, true); exportedNames = ts.append(exportedNames, decl.name); } } return exportedNames; } + function multiMapSparseArrayAdd(map, key, value) { + var values = map[key]; + if (values) { + values.push(value); + } + else { + map[key] = values = [value]; + } + return values; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -11173,13 +11560,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 261) { + if (kind === 264) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 141) { + else if (kind < 142) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -11215,28 +11602,29 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 141: + case 142: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 143: + case 144: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || + visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 258: + case 261: 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 259: + case 262: return visitNode(cbNode, node.expression); - case 144: + case 145: + case 148: case 147: - case 146: - case 257: - case 223: - case 174: + case 260: + case 225: + case 175: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -11245,24 +11633,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 158: case 159: - case 153: + case 160: case 154: case 155: + case 156: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 184: - case 225: + case 153: case 185: + case 227: + case 186: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -11273,320 +11661,325 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 157: + case 158: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 156: + case 157: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 160: - return visitNode(cbNode, node.exprName); case 161: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 162: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 163: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 164: + return visitNodes(cbNodes, node.elementTypes); case 165: - return visitNodes(cbNodes, node.types); case 166: - case 168: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); + case 167: case 169: + return visitNode(cbNode, node.type); + case 170: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 170: + case 171: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 171: - return visitNode(cbNode, node.literal); case 172: + return visitNode(cbNode, node.literal); case 173: - return visitNodes(cbNodes, node.elements); - case 175: + case 174: return visitNodes(cbNodes, node.elements); case 176: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 177: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.name); + return visitNodes(cbNodes, node.properties); case 178: return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); + visitNode(cbNode, node.name); case 179: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); case 180: + case 181: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 181: + case 182: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 182: + case 183: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 183: - return visitNode(cbNode, node.expression); - case 186: + case 184: return visitNode(cbNode, node.expression); case 187: return visitNode(cbNode, node.expression); case 188: return visitNode(cbNode, node.expression); - case 190: - return visitNode(cbNode, node.operand); - case 195: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 189: return visitNode(cbNode, node.expression); case 191: return visitNode(cbNode, node.operand); + case 196: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 190: + return visitNode(cbNode, node.expression); case 192: + return visitNode(cbNode, node.operand); + case 193: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 200: + case 201: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 201: + case 202: return visitNode(cbNode, node.expression); - case 193: + case 203: + return visitNode(cbNode, node.name); + case 194: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 196: + case 197: return visitNode(cbNode, node.expression); - case 204: - case 231: + case 206: + case 233: return visitNodes(cbNodes, node.statements); - case 261: + case 264: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 205: + case 207: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 224: + case 226: return visitNodes(cbNodes, node.declarations); - case 207: + case 209: return visitNode(cbNode, node.expression); - case 208: + case 210: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 209: + case 211: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 210: + case 212: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 211: + case 213: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 212: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 213: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 214: - case 215: - return visitNode(cbNode, node.label); - case 216: - return visitNode(cbNode, node.expression); - case 217: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 215: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 216: + case 217: + return visitNode(cbNode, node.label); case 218: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 232: - return visitNodes(cbNodes, node.clauses); - case 253: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 254: - return visitNodes(cbNodes, node.statements); + return visitNode(cbNode, node.expression); case 219: - return visitNode(cbNode, node.label) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 220: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 234: + return visitNodes(cbNodes, node.clauses); + case 256: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 257: + return visitNodes(cbNodes, node.statements); case 221: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 222: + return visitNode(cbNode, node.expression); + case 223: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 256: + case 259: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 145: + case 146: return visitNode(cbNode, node.expression); - case 226: - case 197: - 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 227: - 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 228: + case 198: 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 229: 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 260: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); case 230: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 231: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 263: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 232: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 234: + case 236: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 235: + case 237: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 236: + case 238: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 233: + case 235: return visitNode(cbNode, node.name); - case 237: + case 239: return visitNode(cbNode, node.name); - case 238: - case 242: + case 240: + case 244: return visitNodes(cbNodes, node.elements); - case 241: + case 243: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 239: - case 243: + case 241: + case 245: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 240: + case 242: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 194: + case 195: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 202: + case 204: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 142: + case 143: return visitNode(cbNode, node.expression); - case 255: + case 258: return visitNodes(cbNodes, node.types); - case 199: + case 200: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 245: + case 247: return visitNode(cbNode, node.expression); - case 244: - return visitNodes(cbNodes, node.decorators); case 246: + return visitNodes(cbNodes, node.decorators); + case 248: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 247: - case 248: - return visitNode(cbNode, node.tagName) || - visitNodes(cbNodes, node.attributes); + case 249: case 250: + return visitNode(cbNode, node.tagName) || + visitNode(cbNode, node.attributes); + case 253: + return visitNodes(cbNodes, node.properties); + case 252: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); + case 254: + return visitNode(cbNode, node.expression); + case 255: + return visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.expression); case 251: - return visitNode(cbNode, node.expression); - case 252: - return visitNode(cbNode, node.expression); - case 249: return visitNode(cbNode, node.tagName); - case 262: - return visitNode(cbNode, node.type); case 266: - return visitNodes(cbNodes, node.types); - case 267: - return visitNodes(cbNodes, node.types); - case 265: - return visitNode(cbNode, node.elementType); - case 269: - return visitNode(cbNode, node.type); - case 268: return visitNode(cbNode, node.type); case 270: - return visitNode(cbNode, node.literal); - case 272: - return visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeArguments); + return visitNodes(cbNodes, node.types); + case 271: + return visitNodes(cbNodes, node.types); + case 269: + return visitNode(cbNode, node.elementType); case 273: return visitNode(cbNode, node.type); + case 272: + return visitNode(cbNode, node.type); case 274: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 275: - return visitNode(cbNode, node.type); + return visitNode(cbNode, node.literal); case 276: - return visitNode(cbNode, node.type); + return visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeArguments); case 277: return visitNode(cbNode, node.type); - case 271: + case 278: + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 279: + return visitNode(cbNode, node.type); + case 280: + return visitNode(cbNode, node.type); + case 281: + return visitNode(cbNode, node.type); + case 275: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 278: + case 282: return visitNodes(cbNodes, node.tags); - case 281: + case 285: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 282: + case 286: return visitNode(cbNode, node.typeExpression); - case 283: - return visitNode(cbNode, node.typeExpression); - case 280: + case 287: return visitNode(cbNode, node.typeExpression); case 284: + return visitNode(cbNode, node.typeExpression); + case 288: return visitNodes(cbNodes, node.typeParameters); - case 285: + case 289: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 287: + case 291: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 286: + case 290: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 294: + case 298: return visitNode(cbNode, node.expression); - case 288: + case 292: return visitNode(cbNode, node.literal); } } @@ -11750,7 +12143,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(261, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(264, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -11977,7 +12370,7 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 141 ? new NodeConstructor(kind, pos, pos) : + return kind >= 142 ? new NodeConstructor(kind, pos, pos) : kind === 70 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } @@ -12014,7 +12407,11 @@ var ts; } function internIdentifier(text) { text = ts.escapeIdentifier(text); - return identifiers[text] || (identifiers[text] = text); + var identifier = identifiers.get(text); + if (identifier === undefined) { + identifiers.set(text, identifier = text); + } + return identifier; } function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; @@ -12059,7 +12456,7 @@ var ts; return token() === 9 || token() === 8 || ts.tokenIsIdentifierOrKeyword(token()); } function parseComputedPropertyName() { - var node = createNode(142); + var node = createNode(143); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); @@ -12364,14 +12761,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 150: - case 155: case 151: + case 156: case 152: - case 147: - case 203: + case 153: + case 148: + case 205: return true; - case 149: + case 150: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 70 && methodDeclaration.name.originalKeywordKind === 122; @@ -12383,8 +12780,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 253: - case 254: + case 256: + case 257: return true; } } @@ -12393,65 +12790,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 225: - case 205: - case 204: - case 208: + case 227: case 207: - case 220: - case 216: - case 218: - case 215: - case 214: - case 212: - case 213: - case 211: - case 210: - case 217: case 206: - case 221: - case 219: + case 210: case 209: case 222: - case 235: - case 234: - case 241: - case 240: - case 230: - case 226: - case 227: - case 229: + case 218: + case 220: + case 217: + case 216: + case 214: + case 215: + case 213: + case 212: + case 219: + case 208: + case 223: + case 221: + case 211: + case 224: + case 237: + case 236: + case 243: + case 242: + case 232: case 228: + case 229: + case 231: + case 230: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 260; + return node.kind === 263; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 154: - case 148: case 155: - case 146: - case 153: + case 149: + case 156: + case 147: + case 154: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 223) { + if (node.kind !== 225) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 144) { + if (node.kind !== 145) { return false; } var parameter = node; @@ -12547,7 +12944,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(22)) { - var node = createNode(141, entity.pos); + var node = createNode(142, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -12564,7 +12961,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(194); + var template = createNode(195); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -12576,7 +12973,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(202); + var span = createNode(204); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17) { @@ -12624,7 +13021,7 @@ var ts; } function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(157, typeName.pos); + var node = createNode(158, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token() === 26) { node.typeArguments = parseBracketedList(19, parseType, 26, 28); @@ -12633,24 +13030,24 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(156, lhs.pos); + var node = createNode(157, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(167); + var node = createNode(168); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(160); + var node = createNode(161); parseExpected(102); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(143); + var node = createNode(144); node.name = parseIdentifier(); if (parseOptional(84)) { if (isStartOfType() || !isStartOfExpression()) { @@ -12660,6 +13057,9 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } + if (parseOptional(57)) { + node.default = parseType(); + } return finishNode(node); } function parseTypeParameters() { @@ -12677,7 +13077,7 @@ var ts; return token() === 23 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 || token() === 98; } function parseParameter() { - var node = createNode(144); + var node = createNode(145); if (token() === 98) { node.name = createIdentifier(true, undefined); node.type = parseParameterType(); @@ -12737,7 +13137,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 154) { + if (kind === 155) { parseExpected(93); } fillSignature(55, false, false, false, node); @@ -12777,7 +13177,7 @@ var ts; return token() === 55 || token() === 25 || token() === 21; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(155, fullStart); + var node = createNode(156, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.parameters = parseBracketedList(16, parseParameter, 20, 21); @@ -12789,7 +13189,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(54); if (token() === 18 || token() === 26) { - var method = createNode(148, fullStart); + var method = createNode(149, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; @@ -12798,7 +13198,7 @@ var ts; return addJSDocComment(finishNode(method)); } else { - var property = createNode(146, fullStart); + var property = createNode(147, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; @@ -12838,10 +13238,10 @@ var ts; } function parseTypeMember() { if (token() === 18 || token() === 26) { - return parseSignatureMember(153); + return parseSignatureMember(154); } if (token() === 93 && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(154); + return parseSignatureMember(155); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -12855,7 +13255,7 @@ var ts; return token() === 18 || token() === 26; } function parseTypeLiteral() { - var node = createNode(161); + var node = createNode(162); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -12878,14 +13278,14 @@ var ts; return token() === 20 && nextTokenIsIdentifier() && nextToken() === 91; } function parseMappedTypeParameter() { - var node = createNode(143); + var node = createNode(144); node.name = parseIdentifier(); parseExpected(91); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(170); + var node = createNode(171); parseExpected(16); node.readonlyToken = parseOptionalToken(130); parseExpected(20); @@ -12898,12 +13298,12 @@ var ts; return finishNode(node); } function parseTupleType() { - var node = createNode(163); + var node = createNode(164); node.elementTypes = parseBracketedList(20, parseType, 20, 21); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(166); + var node = createNode(167); parseExpected(18); node.type = parseType(); parseExpected(19); @@ -12911,7 +13311,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 159) { + if (kind === 160) { parseExpected(93); } fillSignature(35, false, false, false, node); @@ -12922,7 +13322,7 @@ var ts; return token() === 22 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(171); + var node = createNode(172); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -12933,12 +13333,13 @@ var ts; function parseNonArrayType() { switch (token()) { case 118: - case 134: + case 135: case 132: case 121: - case 135: - case 137: + case 136: + case 138: case 129: + case 133: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: @@ -12975,12 +13376,12 @@ var ts; function isStartOfType() { switch (token()) { case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 136: case 104: - case 137: + case 138: case 94: case 98: case 102: @@ -12995,6 +13396,7 @@ var ts; case 8: case 100: case 85: + case 133: return true; case 37: return lookAhead(nextTokenIsNumericLiteral); @@ -13012,14 +13414,14 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(20)) { if (isStartOfType()) { - var node = createNode(169, type.pos); + var node = createNode(170, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(21); type = finishNode(node); } else { - var node = createNode(162, type.pos); + var node = createNode(163, type.pos); node.elementType = type; parseExpected(21); type = finishNode(node); @@ -13028,7 +13430,7 @@ var ts; return type; } function parseTypeOperator(operator) { - var node = createNode(168); + var node = createNode(169); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); @@ -13057,10 +13459,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(165, parseTypeOperatorOrHigher, 47); + return parseUnionOrIntersectionType(166, parseTypeOperatorOrHigher, 47); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(164, parseIntersectionTypeOrHigher, 48); + return parseUnionOrIntersectionType(165, parseIntersectionTypeOrHigher, 48); } function isStartOfFunctionType() { if (token() === 26) { @@ -13106,7 +13508,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(156, typePredicateVariable.pos); + var node = createNode(157, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -13127,10 +13529,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(158); + return parseFunctionOrConstructorType(159); } if (token() === 93) { - return parseFunctionOrConstructorType(159); + return parseFunctionOrConstructorType(160); } return parseUnionTypeOrHigher(); } @@ -13249,7 +13651,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(195); + var node = createNode(196); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 38 || isStartOfExpression())) { @@ -13265,13 +13667,13 @@ var ts; ts.Debug.assert(token() === 35, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(185, asyncModifier.pos); + node = createNode(186, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(185, identifier.pos); + node = createNode(186, identifier.pos); } - var parameter = createNode(144, identifier.pos); + var parameter = createNode(145, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); @@ -13405,7 +13807,7 @@ var ts; return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(185); + var node = createNode(186); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); fillSignature(55, false, isAsync, !allowAmbiguity, node); @@ -13437,7 +13839,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(193, leftOperand.pos); + var node = createNode(194, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -13450,7 +13852,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 || t === 140; + return t === 91 || t === 141; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -13528,43 +13930,43 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(192, left.pos); + var node = createNode(193, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(200, left.pos); + var node = createNode(201, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(190); + var node = createNode(191); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(186); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(187); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(188); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(189); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { if (token() === 120) { if (inAwaitContext()) { @@ -13575,7 +13977,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(189); + var node = createNode(190); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -13591,7 +13993,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === 39) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 182) { + if (simpleUnaryExpression.kind === 183) { 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 { @@ -13644,7 +14046,7 @@ var ts; } function parseIncrementExpression() { if (token() === 42 || token() === 43) { - var node = createNode(190); + var node = createNode(191); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -13656,7 +14058,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 42 || token() === 43) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(191, expression.pos); + var node = createNode(192, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -13679,7 +14081,7 @@ var ts; if (token() === 18 || token() === 22 || token() === 20) { return expression; } - var node = createNode(177, expression.pos); + var node = createNode(178, expression.pos); node.expression = expression; parseExpectedToken(22, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -13701,8 +14103,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 248) { - var node = createNode(246, opening.pos); + if (opening.kind === 250) { + var node = createNode(248, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -13712,14 +14114,14 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 247); + ts.Debug.assert(opening.kind === 249); result = opening; } if (inExpressionContext && token() === 26) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(192, result.pos); + var badNode = createNode(193, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -13765,14 +14167,19 @@ var ts; parsingContext = saveParsingContext; return result; } + function parseJsxAttributes() { + var jsxAttributes = createNode(253); + jsxAttributes.properties = parseList(13, parseJsxAttribute); + return finishNode(jsxAttributes); + } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); parseExpected(26); var tagName = parseJsxElementName(); - var attributes = parseList(13, parseJsxAttribute); + var attributes = parseJsxAttributes(); var node; if (token() === 28) { - node = createNode(248, fullStart); + node = createNode(250, fullStart); scanJsxText(); } else { @@ -13784,7 +14191,7 @@ var ts; parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(247, fullStart); + node = createNode(249, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -13795,7 +14202,7 @@ var ts; var expression = token() === 98 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22)) { - var propertyAccess = createNode(177, expression.pos); + var propertyAccess = createNode(178, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -13803,9 +14210,10 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(252); + var node = createNode(255); parseExpected(16); if (token() !== 17) { + node.dotDotDotToken = parseOptionalToken(23); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { @@ -13822,7 +14230,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(250); + var node = createNode(252); node.name = parseIdentifierName(); if (token() === 57) { switch (scanJsxAttributeValue()) { @@ -13837,7 +14245,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(251); + var node = createNode(254); parseExpected(16); parseExpected(23); node.expression = parseExpression(); @@ -13845,7 +14253,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(249); + var node = createNode(251); parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -13858,7 +14266,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(182); + var node = createNode(183); parseExpected(26); node.type = parseType(); parseExpected(28); @@ -13869,7 +14277,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22); if (dotToken) { - var propertyAccess = createNode(177, expression.pos); + var propertyAccess = createNode(178, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -13877,13 +14285,13 @@ var ts; } if (token() === 50 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(201, expression.pos); + var nonNullExpression = createNode(202, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } if (!inDecoratorContext() && parseOptional(20)) { - var indexedAccess = createNode(178, expression.pos); + var indexedAccess = createNode(179, expression.pos); indexedAccess.expression = expression; if (token() !== 21) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -13897,7 +14305,7 @@ var ts; continue; } if (token() === 12 || token() === 13) { - var tagExpression = createNode(181, expression.pos); + var tagExpression = createNode(182, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 ? parseLiteralNode() @@ -13916,7 +14324,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(179, expression.pos); + var callExpr = createNode(180, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -13924,7 +14332,7 @@ var ts; continue; } else if (token() === 18) { - var callExpr = createNode(179, expression.pos); + var callExpr = createNode(180, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -14019,28 +14427,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(183); + var node = createNode(184); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); return finishNode(node); } function parseSpreadElement() { - var node = createNode(196); + var node = createNode(197); parseExpected(23); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 23 ? parseSpreadElement() : - token() === 25 ? createNode(198) : + token() === 25 ? createNode(199) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(175); + var node = createNode(176); parseExpected(20); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -14051,18 +14459,18 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(124)) { - return parseAccessorDeclaration(151, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(133)) { return parseAccessorDeclaration(152, fullStart, decorators, modifiers); } + else if (parseContextualModifier(134)) { + return parseAccessorDeclaration(153, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23); if (dotDotDotToken) { - var spreadElement = createNode(259, fullStart); + var spreadElement = createNode(262, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -14081,7 +14489,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(258, fullStart); + var shorthandDeclaration = createNode(261, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57); @@ -14092,7 +14500,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(257, fullStart); + var propertyAssignment = createNode(260, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -14102,7 +14510,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(176); + var node = createNode(177); parseExpected(16); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -14116,7 +14524,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(184); + var node = createNode(185); node.modifiers = parseModifiers(); parseExpected(88); node.asteriskToken = parseOptionalToken(38); @@ -14138,8 +14546,15 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(180); + var fullStart = scanner.getStartPos(); parseExpected(93); + if (parseOptional(22)) { + var node_1 = createNode(203, fullStart); + node_1.keywordToken = 93; + node_1.name = parseIdentifierName(); + return finishNode(node_1); + } + var node = createNode(181, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18) { @@ -14148,7 +14563,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(204); + var node = createNode(206); if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -14179,12 +14594,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(206); + var node = createNode(208); parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(208); + var node = createNode(210); parseExpected(89); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14194,7 +14609,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(209); + var node = createNode(211); parseExpected(80); node.statement = parseStatement(); parseExpected(105); @@ -14205,7 +14620,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(210); + var node = createNode(212); parseExpected(105); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14228,21 +14643,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91)) { - var forInStatement = createNode(212, pos); + var forInStatement = createNode(214, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(140)) { - var forOfStatement = createNode(213, pos); + else if (parseOptional(141)) { + var forOfStatement = createNode(215, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(211, pos); + var forStatement = createNode(213, pos); forStatement.initializer = initializer; parseExpected(24); if (token() !== 24 && token() !== 19) { @@ -14260,7 +14675,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 215 ? 71 : 76); + parseExpected(kind === 217 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -14268,7 +14683,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(216); + var node = createNode(218); parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -14277,7 +14692,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(217); + var node = createNode(219); parseExpected(106); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14286,7 +14701,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(253); + var node = createNode(256); parseExpected(72); node.expression = allowInAnd(parseExpression); parseExpected(55); @@ -14294,7 +14709,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(254); + var node = createNode(257); parseExpected(78); parseExpected(55); node.statements = parseList(3, parseStatement); @@ -14304,12 +14719,12 @@ var ts; return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(218); + var node = createNode(220); parseExpected(97); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); - var caseBlock = createNode(232, scanner.getStartPos()); + var caseBlock = createNode(234, scanner.getStartPos()); parseExpected(16); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(17); @@ -14317,14 +14732,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(220); + var node = createNode(222); parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(221); + var node = createNode(223); parseExpected(101); node.tryBlock = parseBlock(false); node.catchClause = token() === 73 ? parseCatchClause() : undefined; @@ -14335,7 +14750,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(256); + var result = createNode(259); parseExpected(73); if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); @@ -14345,7 +14760,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(222); + var node = createNode(224); parseExpected(77); parseSemicolon(); return finishNode(node); @@ -14354,13 +14769,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 && parseOptional(55)) { - var labeledStatement = createNode(219, fullStart); + var labeledStatement = createNode(221, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(207, fullStart); + var expressionStatement = createNode(209, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -14389,7 +14804,7 @@ var ts; case 82: return true; case 108: - case 136: + case 137: return nextTokenIsIdentifierOnSameLine(); case 127: case 128: @@ -14406,7 +14821,7 @@ var ts; return false; } continue; - case 139: + case 140: nextToken(); return token() === 16 || token() === 70 || token() === 83; case 90: @@ -14466,8 +14881,8 @@ var ts; case 108: case 127: case 128: - case 136: - case 139: + case 137: + case 140: return true; case 113: case 111: @@ -14512,9 +14927,9 @@ var ts; case 87: return parseForOrForInOrForOfStatement(); case 76: - return parseBreakOrContinueStatement(214); + return parseBreakOrContinueStatement(216); case 71: - return parseBreakOrContinueStatement(215); + return parseBreakOrContinueStatement(217); case 95: return parseReturnStatement(); case 106: @@ -14533,7 +14948,7 @@ var ts; return parseDeclaration(); case 119: case 108: - case 136: + case 137: case 127: case 128: case 123: @@ -14547,7 +14962,7 @@ var ts; case 116: case 114: case 130: - case 139: + case 140: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -14570,11 +14985,11 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 108: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 136: + case 137: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 82: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 139: + case 140: case 127: case 128: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -14593,7 +15008,7 @@ var ts; } default: if (decorators || modifiers) { - var node = createMissingNode(244, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(246, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -14614,16 +15029,16 @@ var ts; } function parseArrayBindingElement() { if (token() === 25) { - return createNode(198); + return createNode(199); } - var node = createNode(174); + var node = createNode(175); node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(174); + var node = createNode(175); node.dotDotDotToken = parseOptionalToken(23); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -14639,14 +15054,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(172); + var node = createNode(173); parseExpected(16); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(17); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(173); + var node = createNode(174); parseExpected(20); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(21); @@ -14665,7 +15080,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(223); + var node = createNode(225); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -14674,7 +15089,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(224); + var node = createNode(226); switch (token()) { case 103: break; @@ -14688,7 +15103,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token() === 140 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 141 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -14703,7 +15118,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(205, fullStart); + var node = createNode(207, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -14711,7 +15126,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(227, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88); @@ -14724,7 +15139,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(150, pos); + var node = createNode(151, pos); node.decorators = decorators; node.modifiers = modifiers; parseExpected(122); @@ -14733,7 +15148,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(149, fullStart); + var method = createNode(150, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -14746,7 +15161,7 @@ var ts; return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(147, fullStart); + var property = createNode(148, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -14816,7 +15231,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 133 || idToken === 124) { + if (!ts.isKeyword(idToken) || idToken === 134 || idToken === 124) { return true; } switch (token()) { @@ -14839,7 +15254,7 @@ var ts; if (!parseOptional(56)) { break; } - var decorator = createNode(145, decoratorStart); + var decorator = createNode(146, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -14896,7 +15311,7 @@ var ts; } function parseClassElement() { if (token() === 24) { - var result = createNode(203); + var result = createNode(205); nextToken(); return finishNode(result); } @@ -14921,16 +15336,16 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_13 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_13, undefined); + var name = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 197); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 198); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 228); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -14965,7 +15380,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 || token() === 107) { - var node = createNode(255); + var node = createNode(258); node.token = token(); nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -14974,7 +15389,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(199); + var node = createNode(200); node.expression = parseLeftHandSideExpressionOrHigher(); if (token() === 26) { node.typeArguments = parseBracketedList(19, parseType, 26, 28); @@ -14988,7 +15403,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227, fullStart); + var node = createNode(229, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108); @@ -14999,10 +15414,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(136); + parseExpected(137); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57); @@ -15011,13 +15426,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(260, scanner.getStartPos()); + var node = createNode(263, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82); @@ -15032,7 +15447,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(231, scanner.getStartPos()); + var node = createNode(233, scanner.getStartPos()); if (parseExpected(16)) { node.statements = parseList(1, parseStatement); parseExpected(17); @@ -15043,7 +15458,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(230, fullStart); + var node = createNode(232, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; @@ -15055,10 +15470,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(232, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 139) { + if (token() === 140) { node.name = parseIdentifier(); node.flags |= 512; } @@ -15075,7 +15490,7 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 139) { + if (token() === 140) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } else if (parseOptional(128)) { @@ -15100,7 +15515,7 @@ var ts; return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(233, fullStart); + var exportDeclaration = createNode(235, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117); @@ -15115,8 +15530,8 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 && token() !== 138) { - var importEqualsDeclaration = createNode(234, fullStart); + if (token() !== 25 && token() !== 139) { + var importEqualsDeclaration = createNode(236, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -15126,27 +15541,27 @@ var ts; return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(235, fullStart); + var importDeclaration = createNode(237, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || token() === 38 || token() === 16) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(138); + parseExpected(139); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(236, fullStart); + var importClause = createNode(238, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(238); + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(240); } return finishNode(importClause); } @@ -15156,7 +15571,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(245); + var node = createNode(247); parseExpected(131); parseExpected(18); node.expression = parseModuleSpecifier(); @@ -15174,7 +15589,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(237); + var namespaceImport = createNode(239); parseExpected(38); parseExpected(117); namespaceImport.name = parseIdentifier(); @@ -15182,14 +15597,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 238 ? parseImportSpecifier : parseExportSpecifier, 16, 17); + node.elements = parseBracketedList(22, kind === 240 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(243); + return parseImportOrExportSpecifier(245); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(239); + return parseImportOrExportSpecifier(241); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -15208,23 +15623,23 @@ var ts; else { node.name = identifierName; } - if (kind === 239 && checkIdentifierIsKeyword) { + if (kind === 241 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(241, fullStart); + var node = createNode(243, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38)) { - parseExpected(138); + parseExpected(139); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(242); - if (token() === 138 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(138); + node.exportClause = parseNamedImportsOrExports(244); + if (token() === 139 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(139); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -15232,7 +15647,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(240, fullStart); + var node = createNode(242, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57)) { @@ -15311,10 +15726,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 234 && node.moduleReference.kind === 245 - || node.kind === 235 - || node.kind === 240 - || node.kind === 241 + || node.kind === 236 && node.moduleReference.kind === 247 + || node.kind === 237 + || node.kind === 242 + || node.kind === 243 ? node : undefined; }); @@ -15350,7 +15765,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(262, scanner.getTokenPos()); + var result = createNode(266, scanner.getTokenPos()); parseExpected(16); result.type = parseJSDocTopLevelType(); parseExpected(17); @@ -15361,12 +15776,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48) { - var unionType = createNode(266, type.pos); + var unionType = createNode(270, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57) { - var optionalType = createNode(273, type.pos); + var optionalType = createNode(277, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -15377,20 +15792,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20) { - var arrayType = createNode(265, type.pos); + var arrayType = createNode(269, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21); type = finishNode(arrayType); } else if (token() === 54) { - var nullableType = createNode(268, type.pos); + var nullableType = createNode(272, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50) { - var nonNullableType = createNode(269, type.pos); + var nonNullableType = createNode(273, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -15424,14 +15839,15 @@ var ts; case 98: return parseJSDocThisType(); case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 136: case 104: case 94: - case 137: + case 138: case 129: + case 133: return parseTokenNode(); case 9: case 8: @@ -15442,27 +15858,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(277); + var result = createNode(281); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(276); + var result = createNode(280); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(275); + var result = createNode(279); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(274); + var result = createNode(278); nextToken(); parseExpected(18); result.parameters = parseDelimitedList(23, parseJSDocParameter); @@ -15475,7 +15891,7 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(144); + var parameter = createNode(145); parameter.type = parseJSDocType(); if (parseOptional(57)) { parameter.questionToken = createNode(57); @@ -15483,7 +15899,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(272); + var result = createNode(276); result.name = parseSimplePropertyName(); if (token() === 26) { result.typeArguments = parseTypeArguments(); @@ -15517,24 +15933,24 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(141, left.pos); + var result = createNode(142, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(270); + var result = createNode(274); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(269); + var result = createNode(273); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(267); + var result = createNode(271); nextToken(); result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); @@ -15548,7 +15964,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(266); + var result = createNode(270); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19); @@ -15564,12 +15980,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(263); + var result = createNode(267); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(288); + var result = createNode(292); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -15582,11 +15998,11 @@ var ts; token() === 28 || token() === 57 || token() === 48) { - var result = createNode(264, pos); + var result = createNode(268, pos); return finishNode(result); } else { - var result = createNode(268, pos); + var result = createNode(272, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -15730,7 +16146,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(278, start); + var result = createNode(282, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -15840,7 +16256,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(279, atToken.pos); + var result = createNode(283, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -15895,7 +16311,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(281, atToken.pos); + var result = createNode(285, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -15906,20 +16322,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 282; })) { + if (ts.forEach(tags, function (t) { return t.kind === 286; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(282, atToken.pos); + var result = createNode(286, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283; })) { + if (ts.forEach(tags, function (t) { return t.kind === 287; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283, atToken.pos); + var result = createNode(287, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -15934,7 +16350,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(286, atToken.pos); + var result = createNode(290, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -15943,7 +16359,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(280, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -15952,25 +16368,28 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(285, atToken.pos); + var typedefTag = createNode(289, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); if (typedefTag.fullName) { var rightNode = typedefTag.fullName; - while (rightNode.kind !== 70) { + while (true) { + if (rightNode.kind === 70 || !rightNode.body) { + typedefTag.name = rightNode.kind === 70 ? rightNode : rightNode.name; + break; + } rightNode = rightNode.body; } - typedefTag.name = rightNode; } typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 272) { + if (typeExpression.type.kind === 276) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { - var name_14 = jsDocTypeReference.name; - if (name_14.text === "Object") { + var name = jsDocTypeReference.name; + if (name.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -15984,7 +16403,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(287, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(291, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -16025,7 +16444,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22)) { - var jsDocNamespaceNode = createNode(230, pos); + var jsDocNamespaceNode = createNode(232, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); @@ -16069,19 +16488,19 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284; })) { + if (ts.forEach(tags, function (t) { return t.kind === 288; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); while (true) { - var name_15 = parseJSDocIdentifierName(); + var name = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_15) { + if (!name) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(143, name_15.pos); - typeParameter.name = name_15; + var typeParameter = createNode(144, name.pos); + typeParameter.name = name; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25) { @@ -16092,7 +16511,7 @@ var ts; break; } } - var result = createNode(284, atToken.pos); + var result = createNode(288, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -16384,7 +16803,7 @@ var ts; } function visitArray(array) { if (position >= array.pos && position < array.end) { - for (var i = 0, n = array.length; i < n; i++) { + for (var i = 0; i < array.length; i++) { var child = array[i]; if (child) { if (child.pos === position) { @@ -16411,16 +16830,16 @@ var ts; var ts; (function (ts) { function getModuleInstanceState(node) { - if (node.kind === 227 || node.kind === 228) { + if (node.kind === 229 || node.kind === 230) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 235 || node.kind === 234) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 237 || node.kind === 236) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 231) { + else if (node.kind === 233) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -16436,7 +16855,7 @@ var ts; }); return state_1; } - else if (node.kind === 230) { + else if (node.kind === 232) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -16545,7 +16964,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 230)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 232)) { symbol.valueDeclaration = node; } } @@ -16555,7 +16974,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 142) { + if (node.name.kind === 143) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression)) { return nameExpression.text; @@ -16566,21 +16985,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 150: + case 151: return "__constructor"; - case 158: - case 153: - return "__call"; case 159: case 154: - return "__new"; + return "__call"; + case 160: case 155: + return "__new"; + case 156: return "__index"; - case 241: + case 243: return "__export"; - case 240: + case 242: return node.isExportEquals ? "export=" : "default"; - case 192: + case 193: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -16592,20 +17011,20 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 225: - case 226: + case 227: + case 228: return ts.hasModifier(node, 512) ? "default" : undefined; - case 274: + case 278: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 144: - ts.Debug.assert(node.parent.kind === 274); + case 145: + ts.Debug.assert(node.parent.kind === 278); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 285: + case 289: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 205) { + if (parentNode && parentNode.kind === 207) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -16628,13 +17047,16 @@ var ts; symbol = createSymbol(0, "__missing"); } else { - symbol = symbolTable[name] || (symbolTable[name] = createSymbol(0, name)); + symbol = symbolTable.get(name); + if (!symbol) { + symbolTable.set(name, symbol = createSymbol(0, name)); + } if (name && (includes & 788448)) { - classifiableNames[name] = name; + classifiableNames.set(name, name); } if (symbol.flags & excludes) { if (symbol.isReplaceableByMethod) { - symbol = symbolTable[name] = createSymbol(0, name); + symbolTable.set(name, symbol = createSymbol(0, name)); } else { if (node.name) { @@ -16649,7 +17071,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 240 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 242 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -16669,7 +17091,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 243 || (node.kind === 234 && hasExportModifier)) { + if (node.kind === 245 || (node.kind === 236 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -16677,7 +17099,7 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 285 && + var isJSDocTypedefInJSDocNamespace = node.kind === 289 && node.name && node.name.kind === 70 && node.name.isInJSDocNamespace; @@ -16738,7 +17160,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 261) { + if (node.kind === 264) { node.flags |= emitFlags; } if (isIIFE) { @@ -16814,64 +17236,64 @@ var ts; return; } switch (node.kind) { - case 210: + case 212: bindWhileStatement(node); break; - case 209: + case 211: bindDoStatement(node); break; - case 211: + case 213: bindForStatement(node); break; - case 212: - case 213: + case 214: + case 215: bindForInOrForOfStatement(node); break; - case 208: + case 210: bindIfStatement(node); break; - case 216: - case 220: + case 218: + case 222: bindReturnOrThrow(node); break; - case 215: - case 214: + case 217: + case 216: bindBreakOrContinueStatement(node); break; - case 221: + case 223: bindTryStatement(node); break; - case 218: + case 220: bindSwitchStatement(node); break; - case 232: + case 234: bindCaseBlock(node); break; - case 253: + case 256: bindCaseClause(node); break; - case 219: + case 221: bindLabeledStatement(node); break; - case 190: + case 191: bindPrefixUnaryExpressionFlow(node); break; - case 191: + case 192: bindPostfixUnaryExpressionFlow(node); break; - case 192: + case 193: bindBinaryExpressionFlow(node); break; - case 186: + case 187: bindDeleteExpressionFlow(node); break; - case 193: + case 194: bindConditionalExpressionFlow(node); break; - case 223: + case 225: bindVariableDeclarationFlow(node); break; - case 179: + case 180: bindCallExpressionFlow(node); break; default: @@ -16883,15 +17305,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 177: + case 178: return isNarrowableReference(expr); - case 179: + case 180: return hasNarrowableArgument(expr); - case 183: + case 184: return isNarrowingExpression(expr.expression); - case 192: + case 193: return isNarrowingBinaryExpression(expr); - case 190: + case 191: return expr.operator === 50 && isNarrowingExpression(expr.operand); } return false; @@ -16899,7 +17321,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 || expr.kind === 98 || - expr.kind === 177 && isNarrowableReference(expr.expression); + expr.kind === 178 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -16910,14 +17332,14 @@ var ts; } } } - if (expr.expression.kind === 177 && + if (expr.expression.kind === 178 && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 187 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; + return expr1.kind === 188 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -16938,9 +17360,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 183: + case 184: return isNarrowableOperand(expr.expression); - case 192: + case 193: switch (expr.operatorToken.kind) { case 57: return isNarrowableOperand(expr.left); @@ -17034,33 +17456,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 208: case 210: - case 209: - return parent.expression === node; + case 212: case 211: - case 193: + return parent.expression === node; + case 213: + case 194: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 183) { + if (node.kind === 184) { node = node.expression; } - else if (node.kind === 190 && node.operator === 50) { + else if (node.kind === 191 && node.operator === 50) { node = node.operand; } else { - return node.kind === 192 && (node.operatorToken.kind === 52 || + return node.kind === 193 && (node.operatorToken.kind === 52 || node.operatorToken.kind === 53); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 183 || - node.parent.kind === 190 && + while (node.parent.kind === 184 || + node.parent.kind === 191 && node.parent.operator === 50) { node = node.parent; } @@ -17102,7 +17524,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 219 + var enclosingLabeledStatement = node.parent.kind === 221 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -17137,7 +17559,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 224) { + if (node.initializer.kind !== 226) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -17159,7 +17581,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 216) { + if (node.kind === 218) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -17179,7 +17601,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 215 ? breakTarget : continueTarget; + var flowLabel = node.kind === 217 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -17212,7 +17634,8 @@ var ts; flowAfterCatch = currentFlow; } if (node.finallyBlock) { - addAntecedent(preFinallyLabel, preTryFlow); + var preFinallyFlow = { flags: 2048, antecedent: preTryFlow, lock: {} }; + addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); if (!(currentFlow.flags & 1)) { @@ -17222,6 +17645,11 @@ var ts; : unreachableFlow; } } + if (!(currentFlow.flags & 1)) { + var afterFinallyFlow = { flags: 4096, antecedent: currentFlow }; + preFinallyFlow.lock = afterFinallyFlow; + currentFlow = afterFinallyFlow; + } } else { currentFlow = finishFlowLabel(preFinallyLabel); @@ -17236,7 +17664,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 254; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 257; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -17301,13 +17729,13 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 209) { + if (!node.statement || node.statement.kind !== 211) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 192 && node.operatorToken.kind === 57) { + if (node.kind === 193 && node.operatorToken.kind === 57) { bindAssignmentTargetFlow(node.left); } else { @@ -17318,10 +17746,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 175) { + else if (node.kind === 176) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 196) { + if (e.kind === 197) { bindAssignmentTargetFlow(e.expression); } else { @@ -17329,16 +17757,16 @@ var ts; } } } - else if (node.kind === 176) { + else if (node.kind === 177) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 257) { + if (p.kind === 260) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 258) { + else if (p.kind === 261) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 259) { + else if (p.kind === 262) { bindAssignmentTargetFlow(p.expression); } } @@ -17394,7 +17822,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 57 && node.left.kind === 178) { + if (operator === 57 && node.left.kind === 179) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -17405,7 +17833,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 177) { + if (node.expression.kind === 178) { bindAssignmentTargetFlow(node.expression); } } @@ -17438,16 +17866,16 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 212 || node.parent.parent.kind === 213) { + if (node.initializer || node.parent.parent.kind === 214 || node.parent.parent.kind === 215) { bindInitializedVariableFlow(node); } } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 183) { + while (expr.kind === 184) { expr = expr.expression; } - if (expr.kind === 184 || expr.kind === 185) { + if (expr.kind === 185 || expr.kind === 186) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -17455,7 +17883,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 177) { + if (node.expression.kind === 178) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -17464,52 +17892,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 197: - case 226: - case 229: - case 176: - case 161: - case 287: - case 270: - return 1; - case 227: - return 1 | 64; - case 274: - case 230: + case 198: case 228: - case 170: + case 231: + case 177: + case 162: + case 291: + case 274: + case 253: + return 1; + case 229: + return 1 | 64; + case 278: + case 232: + case 230: + case 171: return 1 | 32; - case 261: + case 264: return 1 | 4 | 32; - case 149: + case 150: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 150: - case 225: - case 148: case 151: + case 227: + case 149: case 152: case 153: case 154: case 155: - case 158: + case 156: case 159: + case 160: return 1 | 4 | 32 | 8; - case 184: case 185: + case 186: return 1 | 4 | 32 | 8 | 16; - case 231: + case 233: return 4; - case 147: + case 148: return node.initializer ? 4 : 0; - case 256: - case 211: - case 212: + case 259: case 213: - case 232: + case 214: + case 215: + case 234: return 2; - case 204: + case 206: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -17525,37 +17954,38 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 230: + case 232: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 261: + case 264: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 197: - case 226: + case 198: + case 228: return declareClassMember(node, symbolFlags, symbolExcludes); - case 229: + case 231: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 161: - case 176: - case 227: - case 270: - case 287: + case 162: + case 177: + case 229: + case 274: + case 291: + case 253: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 158: case 159: - case 153: + case 160: case 154: case 155: - case 149: - case 148: + case 156: case 150: + case 149: case 151: case 152: - case 225: - case 184: + case 153: + case 227: case 185: - case 274: - case 228: - case 170: + case 186: + case 278: + case 230: + case 171: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -17570,11 +18000,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 261 ? node : node.body; - if (body && (body.kind === 261 || body.kind === 231)) { + var body = node.kind === 264 ? node : node.body; + if (body && (body.kind === 264 || body.kind === 233)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 241 || stat.kind === 240) { + if (stat.kind === 243 || stat.kind === 242) { return true; } } @@ -17596,7 +18026,7 @@ var ts; errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isExternalModuleAugmentation(node)) { - declareSymbolAndAddToSymbolTable(node, 1024, 0); + declareModuleSymbol(node); } else { var pattern = void 0; @@ -17616,12 +18046,8 @@ var ts; } } else { - var state = getModuleInstanceState(node); - if (state === 0) { - declareSymbolAndAddToSymbolTable(node, 1024, 0); - } - else { - declareSymbolAndAddToSymbolTable(node, 512, 106639); + var state = declareModuleSymbol(node); + if (state !== 0) { if (node.symbol.flags & (16 | 32 | 256)) { node.symbol.constEnumOnlyModule = false; } @@ -17637,29 +18063,35 @@ var ts; } } } + function declareModuleSymbol(node) { + var state = getModuleInstanceState(node); + var instantiated = state !== 0; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 : 1024, instantiated ? 106639 : 0); + return state; + } function bindFunctionOrConstructorType(node) { var symbol = createSymbol(131072, getDeclarationName(node)); addDeclarationToSymbol(symbol, node, 131072); var typeLiteralSymbol = createSymbol(2048, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, 2048); typeLiteralSymbol.members = ts.createMap(); - typeLiteralSymbol.members[symbol.name] = symbol; + typeLiteralSymbol.members.set(symbol.name, symbol); } function bindObjectLiteralExpression(node) { if (inStrictMode) { var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 || prop.name.kind !== 70) { + if (prop.kind === 262 || prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 257 || prop.kind === 258 || prop.kind === 149 + var currentKind = prop.kind === 260 || prop.kind === 261 || prop.kind === 150 ? 1 : 2; - var existingKind = seen[identifier.text]; + var existingKind = seen.get(identifier.text); if (!existingKind) { - seen[identifier.text] = currentKind; + seen.set(identifier.text, currentKind); continue; } if (currentKind === 1 && existingKind === 1) { @@ -17670,16 +18102,22 @@ var ts; } return bindAnonymousDeclaration(node, 4096, "__object"); } + function bindJsxAttributes(node) { + return bindAnonymousDeclaration(node, 4096, "__jsxAttributes"); + } + function bindJsxAttribute(node, symbolFlags, symbolExcludes) { + return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); + } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 230: + case 232: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 261: + case 264: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -17769,8 +18207,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 261 && - blockScopeContainer.kind !== 230 && + if (blockScopeContainer.kind !== 264 && + blockScopeContainer.kind !== 232 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -17813,7 +18251,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 140) { + if (node.kind > 141) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -17853,23 +18291,23 @@ var ts; case 70: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 285) { + while (parentNode && parentNode.kind !== 289) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); break; } case 98: - if (currentFlow && (ts.isExpression(node) || parent.kind === 258)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 261)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 177: + case 178: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 192: + case 193: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -17892,48 +18330,48 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 256: + case 259: return checkStrictModeCatchClause(node); - case 186: + case 187: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 191: + case 192: return checkStrictModePostfixUnaryExpression(node); - case 190: + case 191: return checkStrictModePrefixUnaryExpression(node); - case 217: + case 219: return checkStrictModeWithStatement(node); - case 167: + case 168: seenThisKeyword = true; return; - case 156: + case 157: return checkTypePredicate(node); - case 143: - return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 144: + return declareSymbolAndAddToSymbolTable(node, 262144, 530920); + case 145: return bindParameter(node); - case 223: - case 174: + case 225: + case 175: return bindVariableDeclarationOrBindingElement(node); + case 148: case 147: - case 146: - case 271: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 286: + case 275: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 67108864 : 0), 0); + case 290: return bindJSDocProperty(node); - case 257: - case 258: - return bindPropertyOrMethodOrAccessor(node, 4, 0); case 260: + case 261: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 263: return bindPropertyOrMethodOrAccessor(node, 8, 900095); - case 259: - case 251: + case 262: + case 254: var root = container; var hasRest = false; while (root.parent) { - if (root.kind === 176 && - root.parent.kind === 192 && + if (root.kind === 177 && + root.parent.kind === 193 && root.parent.operatorToken.kind === 57 && root.parent.left === root) { hasRest = true; @@ -17942,78 +18380,82 @@ var ts; root = root.parent; } return; - case 153: case 154: case 155: + case 156: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 149: - case 148: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 225: - return bindFunctionDeclaration(node); case 150: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 149: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 67108864 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); + case 227: + return bindFunctionDeclaration(node); case 151: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 152: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 153: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 158: case 159: - case 274: + case 160: + case 278: return bindFunctionOrConstructorType(node); - case 161: - case 170: - case 287: - case 270: + case 162: + case 171: + case 291: + case 274: return bindAnonymousDeclaration(node, 2048, "__type"); - case 176: + case 177: return bindObjectLiteralExpression(node); - case 184: case 185: + case 186: return bindFunctionExpression(node); - case 179: + case 180: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 197: - case 226: + case 198: + case 228: inStrictMode = true; return bindClassLikeDeclaration(node); - case 227: + case 229: return bindBlockScopedDeclaration(node, 64, 792968); - case 285: + case 289: if (!node.fullName || node.fullName.kind === 70) { return bindBlockScopedDeclaration(node, 524288, 793064); } break; - case 228: - return bindBlockScopedDeclaration(node, 524288, 793064); - case 229: - return bindEnumDeclaration(node); case 230: + return bindBlockScopedDeclaration(node, 524288, 793064); + case 231: + return bindEnumDeclaration(node); + case 232: return bindModuleDeclaration(node); - case 234: - case 237: - case 239: - case 243: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 233: - return bindNamespaceExportDeclaration(node); + case 253: + return bindJsxAttributes(node); + case 252: + return bindJsxAttribute(node, 4, 0); case 236: - return bindImportClause(node); + case 239: case 241: + case 245: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 235: + return bindNamespaceExportDeclaration(node); + case 238: + return bindImportClause(node); + case 243: return bindExportDeclaration(node); - case 240: + case 242: return bindExportAssignment(node); - case 261: + case 264: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 204: + case 206: if (!ts.isFunctionLike(node.parent)) { return; } - case 231: + case 233: return updateStrictModeStatementList(node.statements); } } @@ -18022,7 +18464,7 @@ var ts; if (parameterName && parameterName.kind === 70) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 167) { + if (parameterName && parameterName.kind === 168) { seenThisKeyword = true; } bind(type); @@ -18041,7 +18483,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 240 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 242 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -18051,17 +18493,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 261) { + if (node.parent.kind !== 264) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_4 = node.parent; - if (!ts.isExternalModule(parent_4)) { + var parent_1 = node.parent; + if (!ts.isExternalModule(parent_1)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_4.isDeclarationFile) { + if (!parent_1.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -18071,10 +18513,10 @@ var ts; } function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { - bindAnonymousDeclaration(node, 1073741824, getDeclarationName(node)); + bindAnonymousDeclaration(node, 33554432, getDeclarationName(node)); } else if (!node.exportClause) { - declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); + declareSymbol(container.symbol.exports, container.symbol, node, 33554432, 0); } } function bindImportClause(node) { @@ -18100,11 +18542,11 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 225 || container.kind === 184) { + if (container.kind === 227 || container.kind === 185) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } - else if (container.kind === 150) { + else if (container.kind === 151) { var saveContainer = container; container = container.parent; var symbol = bindPropertyOrMethodOrAccessor(node, 4, 0); @@ -18121,7 +18563,7 @@ var ts; leftSideOfAssignment.parent = node; constructorFunction.parent = classPrototype; classPrototype.parent = leftSideOfAssignment; - var funcSymbol = container.locals[constructorFunction.text]; + var funcSymbol = container.locals.get(constructorFunction.text); if (!funcSymbol || !(funcSymbol.flags & 16 || ts.isDeclarationOfFunctionExpression(funcSymbol))) { return; } @@ -18136,25 +18578,26 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 226) { + if (node.kind === 228) { 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; + classifiableNames.set(node.name.text, node.name.text); } } var symbol = node.symbol; - var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); - if (symbol.exports[prototypeSymbol.name]) { + var prototypeSymbol = createSymbol(4 | 16777216, "prototype"); + var symbolExport = symbol.exports.get(prototypeSymbol.name); + if (symbolExport) { 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)); + file.bindDiagnostics.push(ts.createDiagnosticForNode(symbolExport.declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; + symbol.exports.set(prototypeSymbol.name, prototypeSymbol); prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { @@ -18190,7 +18633,7 @@ var ts; } if (ts.isParameterPropertyDeclaration(node)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 536870912 : 0), 0); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 67108864 : 0), 0); } } function bindFunctionDeclaration(node) { @@ -18246,15 +18689,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 206) || - node.kind === 226 || - (node.kind === 230 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 229 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 208) || + node.kind === 228 || + (node.kind === 232 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 231 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 205 || + (node.kind !== 207 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -18268,56 +18711,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 179: - return computeCallExpression(node, subtreeFlags); case 180: + return computeCallExpression(node, subtreeFlags); + case 181: return computeNewExpression(node, subtreeFlags); - case 230: + case 232: return computeModuleDeclaration(node, subtreeFlags); - case 183: - return computeParenthesizedExpression(node, subtreeFlags); - case 192: - return computeBinaryExpression(node, subtreeFlags); - case 207: - return computeExpressionStatement(node, subtreeFlags); - case 144: - return computeParameter(node, subtreeFlags); - case 185: - return computeArrowFunction(node, subtreeFlags); case 184: + return computeParenthesizedExpression(node, subtreeFlags); + case 193: + return computeBinaryExpression(node, subtreeFlags); + case 209: + return computeExpressionStatement(node, subtreeFlags); + case 145: + return computeParameter(node, subtreeFlags); + case 186: + return computeArrowFunction(node, subtreeFlags); + case 185: return computeFunctionExpression(node, subtreeFlags); - case 225: + case 227: return computeFunctionDeclaration(node, subtreeFlags); - case 223: + case 225: return computeVariableDeclaration(node, subtreeFlags); - case 224: - return computeVariableDeclarationList(node, subtreeFlags); - case 205: - return computeVariableStatement(node, subtreeFlags); - case 219: - return computeLabeledStatement(node, subtreeFlags); case 226: + return computeVariableDeclarationList(node, subtreeFlags); + case 207: + return computeVariableStatement(node, subtreeFlags); + case 221: + return computeLabeledStatement(node, subtreeFlags); + case 228: return computeClassDeclaration(node, subtreeFlags); - case 197: + case 198: return computeClassExpression(node, subtreeFlags); - case 255: + case 258: return computeHeritageClause(node, subtreeFlags); - case 256: + case 259: return computeCatchClause(node, subtreeFlags); - case 199: + case 200: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 150: - return computeConstructor(node, subtreeFlags); - case 147: - return computePropertyDeclaration(node, subtreeFlags); - case 149: - return computeMethod(node, subtreeFlags); case 151: + return computeConstructor(node, subtreeFlags); + case 148: + return computePropertyDeclaration(node, subtreeFlags); + case 150: + return computeMethod(node, subtreeFlags); case 152: + case 153: return computeAccessor(node, subtreeFlags); - case 234: + case 236: return computeImportEquals(node, subtreeFlags); - case 177: + case 178: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -18342,8 +18785,8 @@ var ts; switch (kind) { case 96: return true; - case 177: case 178: + case 179: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96; @@ -18365,10 +18808,10 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 && leftKind === 176) { + if (operatorTokenKind === 57 && leftKind === 177) { transformFlags |= 8 | 192 | 3072; } - else if (operatorTokenKind === 57 && leftKind === 175) { + else if (operatorTokenKind === 57 && leftKind === 176) { transformFlags |= 192 | 3072; } else if (operatorTokenKind === 39 @@ -18407,8 +18850,8 @@ var ts; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 200 - || expressionKind === 182) { + if (expressionKind === 201 + || expressionKind === 183) { transformFlags |= 3; } if (expressionTransformFlags & 1024) { @@ -18694,7 +19137,7 @@ var ts; var excludeFlags = 536872257; switch (kind) { case 119: - case 189: + case 190: transformFlags |= 16; break; case 113: @@ -18703,50 +19146,52 @@ var ts; case 116: case 123: case 75: - case 229: - case 260: - case 182: - case 200: + case 231: + case 263: + case 183: case 201: + case 202: case 130: transformFlags |= 3; break; - case 246: - case 247: case 248: - case 10: case 249: case 250: + case 10: case 251: case 252: + case 253: + case 254: + case 255: transformFlags |= 4; break; - case 213: + case 215: transformFlags |= 8; case 12: case 13: case 14: case 15: - case 194: - case 181: - case 258: + case 195: + case 182: + case 261: case 114: + case 203: transformFlags |= 192; break; - case 195: + case 196: transformFlags |= 192 | 16777216; break; case 118: case 132: case 129: - case 134: - case 121: + case 133: case 135: + case 121: + case 136: case 104: - case 143: - case 146: - case 148: - case 153: + case 144: + case 147: + case 149: case 154: case 155: case 156: @@ -18760,26 +19205,27 @@ var ts; case 164: case 165: case 166: - case 227: - case 228: case 167: + case 229: + case 230: case 168: case 169: case 170: case 171: + case 172: transformFlags = 3; excludeFlags = -3; break; - case 142: + case 143: transformFlags |= 2097152; if (subtreeFlags & 16384) { transformFlags |= 65536; } break; - case 196: + case 197: transformFlags |= 192 | 524288; break; - case 259: + case 262: transformFlags |= 8 | 1048576; break; case 96: @@ -18788,27 +19234,27 @@ var ts; case 98: transformFlags |= 16384; break; - case 172: + case 173: transformFlags |= 192 | 8388608; if (subtreeFlags & 524288) { transformFlags |= 8 | 1048576; } excludeFlags = 537396545; break; - case 173: + case 174: transformFlags |= 192 | 8388608; excludeFlags = 537396545; break; - case 174: + case 175: transformFlags |= 192; if (node.dotDotDotToken) { transformFlags |= 524288; } break; - case 145: + case 146: transformFlags |= 3 | 4096; break; - case 176: + case 177: excludeFlags = 540087617; if (subtreeFlags & 2097152) { transformFlags |= 192; @@ -18820,29 +19266,29 @@ var ts; transformFlags |= 8; } break; - case 175: - case 180: + case 176: + case 181: excludeFlags = 537396545; if (subtreeFlags & 524288) { transformFlags |= 192; } break; - case 209: - case 210: case 211: case 212: + case 213: + case 214: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 261: + case 264: if (subtreeFlags & 32768) { transformFlags |= 192; } break; + case 218: case 216: - case 214: - case 215: + case 217: transformFlags |= 33554432; break; } @@ -18850,56 +19296,57 @@ var ts; return transformFlags & ~excludeFlags; } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 156 && kind <= 171) { + if (kind >= 157 && kind <= 172) { return -3; } switch (kind) { - case 179: case 180: - case 175: + case 181: + case 176: return 537396545; - case 230: + case 232: return 574674241; - case 144: + case 145: return 536872257; - case 185: + case 186: return 601249089; - case 184: - case 225: + case 185: + case 227: return 601281857; - case 224: - return 546309441; case 226: - case 197: + return 546309441; + case 228: + case 198: return 539358529; - case 150: - return 601015617; - case 149: case 151: + return 601015617; + case 150: case 152: + case 153: return 601015617; case 118: case 132: case 129: - case 134: - case 121: case 135: + case 133: + case 121: + case 136: case 104: - case 143: - case 146: - case 148: - case 153: + case 144: + case 147: + case 149: case 154: case 155: - case 227: - case 228: + case 156: + case 229: + case 230: return -3; - case 176: + case 177: return 540087617; - case 256: + case 259: return 537920833; - case 172: case 173: + case 174: return 537396545; default: return 536872257; @@ -18917,6 +19364,12 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; + var Extensions; + (function (Extensions) { + Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; + Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; + Extensions[Extensions["DtsOnly"] = 2] = "DtsOnly"; + })(Extensions || (Extensions = {})); function resolvedTypeScriptOnly(resolved) { if (!resolved) { return undefined; @@ -18924,9 +19377,6 @@ var ts; ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); return resolved.path; } - function resolvedFromAnyFile(path) { - return { path: path, extension: ts.extensionFromPath(path) }; - } function resolvedModuleFromResolved(_a, isExternalLibraryImport) { var path = _a.path, extension = _a.extension; return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; @@ -18938,37 +19388,28 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { + function tryReadPackageJsonFields(readTypes, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); - switch (extensions) { - case 2: - case 0: - return tryReadFromField("typings") || tryReadFromField("types"); - case 1: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; - } + return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); - } - return typesFilePath; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } + if (!ts.hasProperty(jsonContent, fieldName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName); } + return; } + var fileName = jsonContent[fieldName]; + if (typeof fileName !== "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof fileName); + } + return; + } + var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path); + } + return path; } } function readJson(path, host) { @@ -19006,6 +19447,7 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } + return undefined; }); return typeRoots; } @@ -19060,7 +19502,11 @@ var ts; return ts.forEach(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); }); } else { @@ -19076,7 +19522,8 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -19117,31 +19564,116 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); + if (!perModuleNameCache) { + perModuleNameCache = createPerModuleNameCache(); + moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent = ts.getDirectoryPath(current); + if (parent === current || directoryPathMap.contains(parent)) { + break; + } + directoryPathMap.set(parent, result); + current = parent; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache.get(moduleName); + if (result) { if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache.set(moduleName, result); + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; } if (traceEnabled) { if (result.resolvedModule) { @@ -19266,37 +19798,43 @@ var ts; return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, false); + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, jsOnly) { + if (jsOnly === void 0) { jsOnly = false; } var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(0) || tryResolve(1); - if (result) { - var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + var result = jsOnly ? tryResolve(Extensions.JavaScript) : (tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript)); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { - var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); + var loader = function (extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, true); }; + var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); if (resolved) { - return { resolved: resolved, isExternalLibraryImport: false }; + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); - return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); - return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state, true); + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } - ts.nodeModuleNameResolver = nodeModuleNameResolver; + ts.nodeModuleNameResolverWorker = nodeModuleNameResolverWorker; function realpath(path, host, traceEnabled) { if (!host.realpath) { return path; @@ -19307,12 +19845,35 @@ var ts; } return real; } - function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } - var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson); } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); @@ -19340,11 +19901,11 @@ var ts; } } switch (extensions) { - case 2: + case Extensions.DtsOnly: return tryExtension(".d.ts", ts.Extension.Dts); - case 0: + case Extensions.TypeScript: return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case 1: + case Extensions.JavaScript: return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } function tryExtension(ext, extension) { @@ -19353,113 +19914,168 @@ var ts; } } function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); - } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); - } - failedLookupLocations.push(fileName); - return undefined; - } - } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromFile) { - return resolvedFromAnyFile(fromFile); - } - var x = tryAddingExtensions(typesFile, 0, failedLookupLocations, onlyRecordFailures_1, state); - if (x) { - return x; + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); } + return fileName; } else { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); } } } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + failedLookupLocations.push(fileName); + return undefined; + } + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { + if (considerPackageJson === void 0) { considerPackageJson = true; } + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (considerPackageJson) { + var packageJsonPath = pathToPackageJson(candidate); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + var fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; + } + } + else { + if (directoryExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + } + failedLookupLocations.push(packageJsonPath); } - failedLookupLocations.push(packageJsonPath); } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + if (!file) { + return undefined; + } + var onlyRecordFailures = !directoryProbablyExists(ts.getDirectoryPath(file), state.host); + var fromFile = tryFile(file, failedLookupLocations, onlyRecordFailures, state); + if (fromFile) { + var resolved = fromFile && resolvedIfExtensionMatches(extensions, fromFile); + if (resolved) { + return resolved; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile); + } + } + var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; + return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, false); + } + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false, cache); } function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(2, moduleName, directory, failedLookupLocations, state, true); + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, true, undefined); } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); } }); } function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { if (typesOnly === void 0) { typesOnly = false; } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); if (packageResult) { return packageResult; } - if (extensions !== 1) { - return loadModuleFromNodeModulesFolder(2, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(0) || tryResolve(1); - return createResolvedModuleWithFailedLookupLocations(resolved, false, failedLookupLocations); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); if (resolvedUsingSettings) { - return resolvedUsingSettings; + return { value: resolvedUsingSettings }; } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); }); if (resolved_3) { return resolved_3; } - if (extensions === 0) { + if (extensions === Extensions.TypeScript) { return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state)); } } } @@ -19471,10 +20087,13 @@ var ts; } var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(2, moduleName, globalCache, failedLookupLocations, state); + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } function forEachAncestorDirectory(directory, callback) { while (true) { var result = callback(directory); @@ -19530,9 +20149,9 @@ var ts; var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; var strictNullChecks = compilerOptions.strictNullChecks; var emitResolver = createResolver(); - var undefinedSymbol = createSymbol(4 | 67108864, "undefined"); + var undefinedSymbol = createSymbol(4, "undefined"); undefinedSymbol.declarations = []; - var argumentsSymbol = createSymbol(4 | 67108864, "arguments"); + var argumentsSymbol = createSymbol(4, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, @@ -19548,9 +20167,12 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, + getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, + getTypeFromTypeNode: getTypeFromTypeNode, + getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -19559,6 +20181,7 @@ var ts; getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, + signatureToString: signatureToString, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -19574,14 +20197,16 @@ var ts; getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, + getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getAmbientModules: getAmbientModules, - getJsxElementAttributesType: getJsxElementAttributesType, + getAllAttributesTypeFromJsxOpeningLikeElement: getAllAttributesTypeFromJsxOpeningLikeElement, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, isOptionalParameter: isOptionalParameter, tryGetMemberInModuleExports: tryGetMemberInModuleExports, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { return tryFindAmbientModule(moduleName, false); - } + }, + getApparentType: getApparentType }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -19590,8 +20215,8 @@ var ts; var numericLiteralTypes = ts.createMap(); var indexedAccessTypes = ts.createMap(); var evolvingArrayTypes = []; - var unknownSymbol = createSymbol(4 | 67108864, "unknown"); - var resolvingSymbol = createSymbol(67108864, "__resolving__"); + var unknownSymbol = createSymbol(4, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__"); var anyType = createIntrinsicType(1, "any"); var autoType = createIntrinsicType(1, "any"); var unknownType = createIntrinsicType(1, "unknown"); @@ -19608,8 +20233,9 @@ var ts; var voidType = createIntrinsicType(1024, "void"); var neverType = createIntrinsicType(8192, "never"); var silentNeverType = createIntrinsicType(8192, "never"); + var nonPrimitiveType = createIntrinsicType(16777216, "object"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var emptyTypeLiteralSymbol = createSymbol(2048 | 67108864, "__type"); + var emptyTypeLiteralSymbol = createSymbol(2048, "__type"); emptyTypeLiteralSymbol.members = ts.createMap(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -19617,6 +20243,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); anyFunctionType.flags |= 8388608; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); var resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false); @@ -19675,9 +20302,10 @@ var ts; var visitedFlowNodes = []; var visitedFlowTypes = []; var potentialThisCollisions = []; + var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - var typeofEQFacts = ts.createMap({ + var typeofEQFacts = ts.createMapFromTemplate({ "string": 1, "number": 2, "boolean": 4, @@ -19686,7 +20314,7 @@ var ts; "object": 16, "function": 32 }); - var typeofNEFacts = ts.createMap({ + var typeofNEFacts = ts.createMapFromTemplate({ "string": 128, "number": 256, "boolean": 512, @@ -19695,13 +20323,14 @@ var ts; "object": 2048, "function": 4096 }); - var typeofTypesByName = ts.createMap({ + var typeofTypesByName = ts.createMapFromTemplate({ "string": stringType, "number": numberType, "boolean": booleanType, "symbol": esSymbolType, "undefined": undefinedType }); + var typeofType = createTypeofType(); var jsxElementType; var _jsxNamespace; var _jsxFactoryEntity; @@ -19722,7 +20351,7 @@ var ts; var enumRelation = ts.createMap(); var _displayBuilder; var builtinGlobals = ts.createMap(); - builtinGlobals[undefinedSymbol.name] = undefinedSymbol; + builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); initializeTypeChecker(); return checker; function getJsxNamespace() { @@ -19752,7 +20381,9 @@ var ts; } function createSymbol(flags, name) { symbolCount++; - return new Symbol(flags, name); + var symbol = (new Symbol(flags | 134217728, name)); + symbol.checkFlags = 0; + return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; @@ -19798,7 +20429,7 @@ var ts; mergedSymbols[source.mergeId] = target; } function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 33554432, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); result.declarations = symbol.declarations.slice(0); result.parent = symbol.parent; if (symbol.valueDeclaration) @@ -19820,7 +20451,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 230 && source.valueDeclaration.kind !== 230))) { + (target.valueDeclaration.kind === 232 && source.valueDeclaration.kind !== 232))) { target.valueDeclaration = source.valueDeclaration; } ts.addRange(target.declarations, source.declarations); @@ -19836,6 +20467,9 @@ var ts; } recordMergedSymbol(target, source); } + else if (target.flags & 1024) { + error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + } else { var message_2 = target.flags & 2 || source.flags & 2 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -19848,18 +20482,19 @@ var ts; } } function mergeSymbolTable(target, source) { - for (var id in source) { - var targetSymbol = target[id]; + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); if (!targetSymbol) { - target[id] = source[id]; + target.set(id, sourceSymbol); } else { - if (!(targetSymbol.flags & 33554432)) { - target[id] = targetSymbol = cloneSymbol(targetSymbol); + if (!(targetSymbol.flags & 134217728)) { + targetSymbol = cloneSymbol(targetSymbol); + target.set(id, targetSymbol); } - mergeSymbol(targetSymbol, source[id]); + mergeSymbol(targetSymbol, sourceSymbol); } - } + }); } function mergeModuleAugmentation(moduleName) { var moduleAugmentation = moduleName.parent; @@ -19880,7 +20515,7 @@ var ts; } mainModule = resolveExternalModuleSymbol(mainModule); if (mainModule.flags & 1920) { - mainModule = mainModule.flags & 33554432 ? mainModule : cloneSymbol(mainModule); + mainModule = mainModule.flags & 134217728 ? mainModule : cloneSymbol(mainModule); mergeSymbol(mainModule, moduleAugmentation.symbol); } else { @@ -19889,20 +20524,21 @@ var ts; } } function addToSymbolTable(target, source, message) { - for (var id in source) { - if (target[id]) { - ts.forEach(target[id].declarations, addDeclarationDiagnostic(id, message)); + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); + if (targetSymbol) { + ts.forEach(targetSymbol.declarations, addDeclarationDiagnostic(id, message)); } else { - target[id] = source[id]; + target.set(id, sourceSymbol); } - } + }); function addDeclarationDiagnostic(id, message) { return function (declaration) { return diagnostics.add(ts.createDiagnosticForNode(declaration, message, id)); }; } } function getSymbolLinks(symbol) { - if (symbol.flags & 67108864) + if (symbol.flags & 134217728) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = {}); @@ -19914,14 +20550,17 @@ var ts; function getObjectFlags(type) { return type.flags & 32768 ? type.objectFlags : 0; } + function getCheckFlags(symbol) { + return symbol.flags & 134217728 ? symbol.checkFlags : 0; + } function isGlobalSourceFile(node) { - return node.kind === 261 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 264 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { - var symbol = symbols[name]; + var symbol = symbols.get(name); if (symbol) { - ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } @@ -19952,39 +20591,50 @@ var ts; (!compilerOptions.outFile && !compilerOptions.out)) { return true; } - if (isUsedInFunctionOrNonStaticProperty(usage)) { + if (isUsedInFunctionOrInstanceProperty(usage)) { return true; } var sourceFiles = host.getSourceFiles(); return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 223 || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + if (declaration.kind === 175) { + var errorBindingElement = ts.getAncestor(usage, 175); + if (errorBindingElement) { + return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + declaration.pos < errorBindingElement.pos; + } + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 225), usage); + } + else if (declaration.kind === 225) { + return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); - return isUsedInFunctionOrNonStaticProperty(usage, container); + var isInstanceProperty = declaration.kind === 148 && !(ts.getModifierFlags(declaration) & 32); + return isUsedInFunctionOrInstanceProperty(usage, isInstanceProperty, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 205: - case 211: + case 207: case 213: + case 215: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 212: - case 213: + case 214: + case 215: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } } return false; } - function isUsedInFunctionOrNonStaticProperty(usage, container) { + function isUsedInFunctionOrInstanceProperty(usage, isDeclarationInstanceProperty, container) { var current = usage; while (current) { if (current === container) { @@ -19993,17 +20643,26 @@ var ts; if (ts.isFunctionLike(current)) { return true; } - var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 147 && + var initializerOfInstanceProperty = current.parent && + current.parent.kind === 148 && (ts.getModifierFlags(current.parent) & 32) === 0 && current.parent.initializer === current; - if (initializerOfNonStaticProperty) { - return true; + if (initializerOfInstanceProperty) { + return !isDeclarationInstanceProperty; } current = current.parent; } return false; } + function getAncestorBindingPattern(node) { + while (node) { + if (ts.isBindingPattern(node)) { + return node; + } + node = node.parent; + } + return undefined; + } } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { var result; @@ -20017,18 +20676,18 @@ var ts; if (result = getSymbol(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 793064 && lastLocation.kind !== 278) { + if (meaning & result.flags & 793064 && lastLocation.kind !== 282) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 144 || - lastLocation.kind === 143 + lastLocation.kind === 145 || + lastLocation.kind === 144 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 144 || + lastLocation.kind === 145 || (lastLocation === location.type && - result.valueDeclaration.kind === 144); + result.valueDeclaration.kind === 145); } } if (useResult) { @@ -20040,23 +20699,24 @@ var ts; } } switch (location.kind) { - case 261: + case 264: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 230: + case 232: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 261 || ts.isAmbientModule(location)) { - if (result = moduleExports["default"]) { + if (location.kind === 264 || ts.isAmbientModule(location)) { + if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } - if (moduleExports[name] && - moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 243)) { + var moduleExport = moduleExports.get(name); + if (moduleExport && + moduleExport.flags === 8388608 && + ts.getDeclarationOfKind(moduleExport, 245)) { break; } } @@ -20064,13 +20724,13 @@ var ts; break loop; } break; - case 229: + case 231: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 148: case 147: - case 146: if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -20080,17 +20740,21 @@ var ts; } } break; - case 226: - case 197: - case 227: + case 228: + case 198: + case 229: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { + if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { + result = undefined; + break; + } if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; } break loop; } - if (location.kind === 197 && meaning & 32) { + if (location.kind === 198 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -20098,28 +20762,28 @@ var ts; } } break; - case 142: + case 143: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 227) { + if (ts.isClassLike(grandparent) || grandparent.kind === 229) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 225: - case 185: + case 153: + case 227: + case 186: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 184: + case 185: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -20132,8 +20796,8 @@ var ts; } } break; - case 145: - if (location.parent && location.parent.kind === 144) { + case 146: + if (location.parent && location.parent.kind === 145) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -20176,13 +20840,22 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 233) { + if (decls && decls.length === 1 && decls[0].kind === 235) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } } return result; } + function isTypeParameterSymbolDeclaredInContainer(symbol, container) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.kind === 144 && decl.parent === container) { + return true; + } + } + return false; + } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { if ((errorLocation.kind === 70 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; @@ -20223,9 +20896,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70: - case 177: + case 178: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 199: + case 200: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -20256,7 +20929,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 223), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -20273,10 +20946,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 234) { + if (node.kind === 236) { return node; } - while (node && node.kind !== 235) { + while (node && node.kind !== 237) { node = node.parent; } return node; @@ -20286,7 +20959,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 245) { + if (node.moduleReference.kind === 247) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -20294,11 +20967,16 @@ var ts; function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { - var exportDefaultSymbol = ts.isShorthandAmbientModuleSymbol(moduleSymbol) ? - moduleSymbol : - moduleSymbol.exports["export="] ? - getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") : - resolveSymbol(moduleSymbol.exports["default"]); + var exportDefaultSymbol = void 0; + if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { + exportDefaultSymbol = moduleSymbol; + } + else { + var exportValue = moduleSymbol.exports.get("export="); + exportDefaultSymbol = exportValue + ? getPropertyOfType(getTypeOfSymbol(exportValue), "default") + : resolveSymbol(moduleSymbol.exports.get("default")); + } if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } @@ -20329,7 +21007,7 @@ var ts; } function getExportOfModule(symbol, name) { if (symbol.flags & 1536) { - var exportedSymbol = getExportsOfSymbol(symbol)[name]; + var exportedSymbol = getExportsOfSymbol(symbol).get(name); if (exportedSymbol) { return resolveSymbol(exportedSymbol); } @@ -20347,28 +21025,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_16 = specifier.propertyName || specifier.name; - if (name_16.text) { + var name = specifier.propertyName || specifier.name; + if (name.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_16.text); + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) { + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_16.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_16.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_16.text === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name.text); + if (!symbolFromModule && allowSyntheticDefaultImports && name.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_16, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_16)); + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name)); } return symbol; } @@ -20390,19 +21068,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 234: - return getTargetOfImportEqualsDeclaration(node); case 236: + return getTargetOfImportEqualsDeclaration(node); + case 238: return getTargetOfImportClause(node); - case 237: - return getTargetOfNamespaceImport(node); case 239: + return getTargetOfNamespaceImport(node); + case 241: return getTargetOfImportSpecifier(node); - case 243: + case 245: return getTargetOfExportSpecifier(node); - case 240: + case 242: return getTargetOfExportAssignment(node); - case 233: + case 235: return getTargetOfNamespaceExportDeclaration(node); } } @@ -20446,10 +21124,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 240) { + if (node.kind === 242) { checkExpressionCached(node.expression); } - else if (node.kind === 243) { + else if (node.kind === 245) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -20461,11 +21139,11 @@ var ts; if (entityName.kind === 70 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 70 || entityName.parent.kind === 141) { + if (entityName.kind === 70 || entityName.parent.kind === 142) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 234); + ts.Debug.assert(entityName.parent.kind === 236); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -20484,9 +21162,9 @@ var ts; return undefined; } } - else if (name.kind === 141 || name.kind === 177) { - var left = name.kind === 141 ? name.left : name.expression; - var right = name.kind === 141 ? name.right : name.name; + else if (name.kind === 142 || name.kind === 178) { + var left = name.kind === 142 ? name.left : name.expression; + var right = name.kind === 142 ? name.right : name.name; var namespace = resolveEntityName(left, 1920, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -20505,7 +21183,7 @@ var ts; else { ts.Debug.fail("Unknown entity name kind."); } - ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); } function resolveExternalModuleName(location, moduleReferenceExpression) { @@ -20576,7 +21254,7 @@ var ts; return undefined; } function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports["export="])) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="))) || moduleSymbol; } function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { var symbol = resolveExternalModuleSymbol(moduleSymbol); @@ -20587,15 +21265,23 @@ var ts; return symbol; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["export="] !== undefined; + return moduleSymbol.exports.get("export=") !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); } + function getExportsAndPropertiesOfModule(moduleSymbol) { + var exports = getExportsOfModuleAsArray(moduleSymbol); + var exportEquals = resolveExternalModuleSymbol(moduleSymbol); + if (exportEquals !== moduleSymbol) { + ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + } + return exports; + } function tryGetMemberInModuleExports(memberName, moduleSymbol) { var symbolTable = getExportsOfModule(moduleSymbol); if (symbolTable) { - return symbolTable[memberName]; + return symbolTable.get(memberName); } } function getExportsOfSymbol(symbol) { @@ -20606,24 +21292,28 @@ var ts; return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol)); } function extendExportSymbols(target, source, lookupTable, exportNode) { - for (var id in source) { - if (id !== "default" && !target[id]) { - target[id] = source[id]; + source && source.forEach(function (sourceSymbol, id) { + if (id === "default") + return; + var targetSymbol = target.get(id); + if (!targetSymbol) { + target.set(id, sourceSymbol); if (lookupTable && exportNode) { - lookupTable[id] = { + lookupTable.set(id, { specifierText: ts.getTextOfNode(exportNode.moduleSpecifier) - }; + }); } } - else if (lookupTable && exportNode && id !== "default" && target[id] && resolveSymbol(target[id]) !== resolveSymbol(source[id])) { - if (!lookupTable[id].exportsWithDuplicate) { - lookupTable[id].exportsWithDuplicate = [exportNode]; + else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) { + var collisionTracker = lookupTable.get(id); + if (!collisionTracker.exportsWithDuplicate) { + collisionTracker.exportsWithDuplicate = [exportNode]; } else { - lookupTable[id].exportsWithDuplicate.push(exportNode); + collisionTracker.exportsWithDuplicate.push(exportNode); } } - } + }); } function getExportsForModule(moduleSymbol) { var visitedSymbols = []; @@ -20635,26 +21325,26 @@ var ts; } visitedSymbols.push(symbol); var symbols = ts.cloneMap(symbol.exports); - var exportStars = symbol.exports["__export"]; + var exportStars = symbol.exports.get("__export"); if (exportStars) { var nestedSymbols = ts.createMap(); - var lookupTable = ts.createMap(); + var lookupTable_1 = ts.createMap(); for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { var node = _a[_i]; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); var exportedSymbols = visit(resolvedModule); - extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable, node); + extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); } - for (var id in lookupTable) { - var exportsWithDuplicate = lookupTable[id].exportsWithDuplicate; - if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols[id]) { - continue; + lookupTable_1.forEach(function (_a, id) { + var exportsWithDuplicate = _a.exportsWithDuplicate; + if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) { + return; } - for (var _b = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _b < exportsWithDuplicate_1.length; _b++) { - var node = exportsWithDuplicate_1[_b]; - diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable[id].specifierText, id)); + for (var _i = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _i < exportsWithDuplicate_1.length; _i++) { + var node = exportsWithDuplicate_1[_i]; + diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable_1.get(id).specifierText, id)); } - } + }); extendExportSymbols(symbols, nestedSymbols); } return symbols; @@ -20676,22 +21366,13 @@ var ts; : 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; + return !!(symbol.flags & 107455 || symbol.flags & 8388608 && resolveAlias(symbol).flags & 107455); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 150 && ts.nodeIsPresent(member.body)) { + if (member.kind === 151 && ts.nodeIsPresent(member.body)) { return member; } } @@ -20719,6 +21400,9 @@ var ts; type.symbol = symbol; return type; } + function createTypeofType() { + return getUnionType(ts.convertToArray(typeofEQFacts.keys(), function (s) { return getLiteralTypeForText(32, s); })); + } function isReservedMemberName(name) { return name.charCodeAt(0) === 95 && name.charCodeAt(1) === 95 && @@ -20727,16 +21411,15 @@ var ts; } function getNamedMembers(members) { var result; - for (var id in members) { + members.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { if (!result) result = []; - var symbol = members[id]; if (symbolIsValue(symbol)) { result.push(symbol); } } - } + }); return result || emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -20755,19 +21438,19 @@ var ts; } 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)) { + for (var location = enclosingDeclaration; location; location = location.parent) { + if (location.locals && !isGlobalSourceFile(location)) { + if (result = callback(location.locals)) { return result; } } - switch (location_1.kind) { - case 261: - if (!ts.isExternalOrCommonJsModule(location_1)) { + switch (location.kind) { + case 264: + if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230: - if (result = callback(getSymbolOfNode(location_1).exports)) { + case 232: + if (result = callback(getSymbolOfNode(location).exports)) { return result; } break; @@ -20804,13 +21487,13 @@ var ts; } } function trySymbolTable(symbols) { - if (isAccessible(symbols[symbol.name])) { + if (isAccessible(symbols.get(symbol.name))) { return [symbol]; } - return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { + return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -20835,14 +21518,14 @@ var ts; function needsQualification(symbol, enclosingDeclaration, meaning) { var qualify = false; forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { - var symbolFromSymbolTable = symbolTable[symbol.name]; + var symbolFromSymbolTable = symbolTable.get(symbol.name); if (!symbolFromSymbolTable) { return false; } if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -20856,10 +21539,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 147: - case 149: - case 151: + case 148: + case 150: case 152: + case 153: continue; default: return false; @@ -20915,7 +21598,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 261 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 264 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -20949,11 +21632,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 160 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 161 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning = 107455 | 1048576; } - else if (entityName.kind === 141 || entityName.kind === 177 || - entityName.parent.kind === 234) { + else if (entityName.kind === 142 || entityName.kind === 178 || + entityName.parent.kind === 236) { meaning = 1920; } else { @@ -21045,10 +21728,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 166) { + while (node.kind === 167) { node = node.parent; } - if (node.kind === 228) { + if (node.kind === 230) { return getSymbolOfNode(node); } } @@ -21056,29 +21739,29 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 231 && + node.parent.kind === 233 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { return type.flags & 32 ? "\"" + ts.escapeString(type.text) + "\"" : type.text; } - 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 197: - return "(Anonymous class)"; - case 184: - case 185: - return "(Anonymous function)"; - } + 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 198: + return "(Anonymous class)"; + case 185: + case 186: + return "(Anonymous function)"; } - return symbol.name; } + return symbol.name; + } + function getSymbolDisplayBuilder() { function appendSymbolNameOnly(symbol, writer) { writer.writeSymbol(getNameOfSymbol(symbol), symbol); } @@ -21106,7 +21789,7 @@ var ts; function appendParentTypeArgumentsAndSymbolName(symbol) { if (parentSymbol) { if (flags & 1) { - if (symbol.flags & 16777216) { + if (getCheckFlags(symbol) & 1) { buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); } else { @@ -21125,9 +21808,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_5 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_5) { - walkSymbol(parent_5, getQualifiedLeftMeaning(meaning), false); + var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + walkSymbol(parent, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -21157,7 +21840,7 @@ var ts; return writeType(type, globalFlags); function writeType(type, flags) { var nextFlags = flags & ~512; - if (type.flags & 16015) { + if (type.flags & 16793231) { writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) ? "any" : type.intrinsicName); @@ -21182,7 +21865,7 @@ var ts; else if (!(flags & 512) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) { var typeArguments = type.aliasTypeArguments; - writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); + writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, ts.length(typeArguments), nextFlags); } else if (type.flags & 196608) { writeUnionOrIntersectionType(type, nextFlags); @@ -21260,12 +21943,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_6 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_6); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_6, typeArguments, start, i, flags); + writeSymbolTypeReference(parent, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -21291,7 +21974,8 @@ var ts; function writeAnonymousType(type, flags) { var symbol = type.symbol; if (symbol) { - if (symbol.flags & (32 | 384 | 512)) { + if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (384 | 512)) { writeTypeOfSymbol(type, flags); } else if (shouldWriteTypeOfFunctionSymbol()) { @@ -21324,7 +22008,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 261 || declaration.parent.kind === 231; + return declaration.parent.kind === 264 || declaration.parent.kind === 233; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -21337,32 +22021,13 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } - function writeIndexSignature(info, keyword) { - if (info) { - if (info.isReadonly) { - writeKeyword(writer, 130); - writeSpace(writer); - } - writePunctuation(writer, 20); - writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55); - writeSpace(writer); - writeKeyword(writer, keyword); - writePunctuation(writer, 21); - writePunctuation(writer, 55); - writeSpace(writer); - writeType(info.type, 0); - writePunctuation(writer, 24); - writer.writeLine(); - } - } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { writeKeyword(writer, 130); writeSpace(writer); } buildSymbolDisplay(prop, writer); - if (prop.flags & 536870912) { + if (prop.flags & 67108864) { writePunctuation(writer, 54); } } @@ -21438,8 +22103,8 @@ var ts; writePunctuation(writer, 24); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 134); - writeIndexSignature(resolved.numberIndexInfo, 132); + buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0, enclosingDeclaration, globalFlags, symbolStack); + buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, 1, enclosingDeclaration, globalFlags, symbolStack); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -21505,6 +22170,13 @@ var ts; writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } + var defaultType = getDefaultFromTypeParameter(tp); + if (defaultType) { + writeSpace(writer); + writePunctuation(writer, 57); + writeSpace(writer); + buildTypeDisplay(defaultType, writer, enclosingDeclaration, flags, symbolStack); + } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; @@ -21522,15 +22194,19 @@ var ts; } writePunctuation(writer, 55); writeSpace(writer); - buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); + var type = getTypeOfSymbol(p); + if (isRequiredInitializedParameter(parameterNode)) { + type = includeFalsyTypes(type, 2048); + } + buildTypeDisplay(type, writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 172) { + if (bindingPattern.kind === 173) { writePunctuation(writer, 16); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); writePunctuation(writer, 17); } - else if (bindingPattern.kind === 173) { + else if (bindingPattern.kind === 174) { writePunctuation(writer, 20); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -21544,7 +22220,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 174); + ts.Debug.assert(bindingElement.kind === 175); if (bindingElement.propertyName) { writer.writeProperty(ts.getTextOfNode(bindingElement.propertyName)); writePunctuation(writer, 55); @@ -21618,6 +22294,10 @@ var ts; buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + var returnType = getReturnTypeOfSignature(signature); + if (flags & 2048 && isTypeAny(returnType)) { + return; + } if (flags & 8) { writeSpace(writer); writePunctuation(writer, 35); @@ -21630,7 +22310,6 @@ var ts; buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); } else { - var returnType = getReturnTypeOfSignature(signature); buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } } @@ -21648,6 +22327,32 @@ var ts; buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } + function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 130); + writeSpace(writer); + } + writePunctuation(writer, 20); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 55); + writeSpace(writer); + switch (kind) { + case 1: + writeKeyword(writer, 132); + break; + case 0: + writeKeyword(writer, 135); + break; + } + writePunctuation(writer, 21); + writePunctuation(writer, 55); + writeSpace(writer); + buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); + writePunctuation(writer, 24); + writer.writeLine(); + } + } return _displayBuilder || (_displayBuilder = { buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, @@ -21658,6 +22363,7 @@ var ts; buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, + buildIndexSignatureDisplay: buildIndexSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay }); } @@ -21672,63 +22378,63 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 174: + case 175: return isDeclarationVisible(node.parent.parent); - case 223: + case 225: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 230: - case 226: - case 227: + case 232: case 228: - case 225: case 229: - case 234: + case 230: + case 227: + case 231: + case 236: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_7 = getDeclarationContainer(node); + var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 234 && parent_7.kind !== 261 && ts.isInAmbientContext(parent_7))) { - return isGlobalSourceFile(parent_7); + !(node.kind !== 236 && parent.kind !== 264 && ts.isInAmbientContext(parent))) { + return isGlobalSourceFile(parent); } - return isDeclarationVisible(parent_7); - case 147: - case 146: - case 151: - case 152: - case 149: + return isDeclarationVisible(parent); case 148: + case 147: + case 152: + case 153: + case 150: + case 149: if (ts.getModifierFlags(node) & (8 | 16)) { return false; } - case 150: - case 154: - case 153: + case 151: case 155: - case 144: - case 231: - case 158: + case 154: + case 156: + case 145: + case 233: case 159: - case 161: - case 157: + case 160: case 162: + case 158: case 163: case 164: case 165: case 166: + case 167: return isDeclarationVisible(node.parent); - case 236: - case 237: + case 238: case 239: + case 241: return false; - case 143: - case 261: - case 233: + case 144: + case 264: + case 235: return true; - case 240: + case 242: return false; default: return false; @@ -21737,10 +22443,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 240) { + if (node.parent && node.parent.kind === 242) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 243) { + else if (node.parent.kind === 245) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -21818,12 +22524,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 223: - case 224: + case 225: + case 226: + case 241: + case 240: case 239: case 238: - case 237: - case 236: node = node.parent; break; default: @@ -21842,15 +22548,12 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1) !== 0; } - function isTypeNever(type) { - return type && (type.flags & 8192) !== 0; - } function getTypeForBindingElementParent(node) { var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } function isComputedNonLiteralName(name) { - return name.kind === 142 && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 143 && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 6144); }); @@ -21863,17 +22566,16 @@ var ts; var members = ts.createMap(); var names = ts.createMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name_17 = properties_2[_i]; - names[ts.getTextOfPropertyName(name_17)] = true; + var name = properties_2[_i]; + names.set(ts.getTextOfPropertyName(name), true); } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - var inNamesToRemove = prop.name in names; + var inNamesToRemove = names.has(prop.name); var isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16); - var isMethod = prop.flags & 8192; var isSetOnlyAccessor = prop.flags & 65536 && !(prop.flags & 32768); - if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { - members[prop.name] = prop; + if (!inNamesToRemove && !isPrivate && !isClassMethod(prop) && !isSetOnlyAccessor) { + members.set(prop.name, prop); } } var stringIndexInfo = getIndexInfoOfType(source, 0); @@ -21893,7 +22595,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 172) { + if (pattern.kind === 173) { if (declaration.dotDotDotToken) { if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -21909,19 +22611,19 @@ var ts; type = getRestType(parentType, literalMembers, declaration.symbol); } else { - var name_18 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_18)) { + var name = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name)) { return anyType; } if (declaration.initializer) { getContextualType(declaration.initializer); } - var text = ts.getTextOfPropertyName(name_18); + var text = ts.getTextOfPropertyName(name); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(name_18, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_18)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); return unknownType; } } @@ -21954,7 +22656,7 @@ var ts; getUnionType([type, checkExpressionCached(declaration.initializer)], true) : type; } - function getTypeForVariableLikeDeclarationFromJSDocComment(declaration) { + function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); if (jsdocType) { return getTypeFromTypeNode(jsdocType); @@ -21967,33 +22669,42 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 175 && expr.elements.length === 0; + return expr.kind === 176 && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; } + function removeOptionalityFromAnnotation(annotatedType, declaration) { + var annotationIncludesUndefined = strictNullChecks && + declaration.kind === 145 && + declaration.initializer && + getFalsyFlags(annotatedType) & 2048 && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048); + return annotationIncludesUndefined ? getNonNullableType(annotatedType) : annotatedType; + } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { if (declaration.flags & 65536) { - var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); + var type = getTypeForDeclarationFromJSDocComment(declaration); if (type && type !== unknownType) { return type; } } - if (declaration.parent.parent.kind === 212) { + if (declaration.parent.parent.kind === 214) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 | 262144) ? indexType : stringType; } - if (declaration.parent.parent.kind === 213) { + if (declaration.parent.parent.kind === 215) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } if (declaration.type) { - return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); + var declaredType = removeOptionalityFromAnnotation(getTypeFromTypeNode(declaration.type), declaration); + return addOptionality(declaredType, declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536) && - declaration.kind === 223 && !ts.isBindingPattern(declaration.name) && + declaration.kind === 225 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -22002,10 +22713,10 @@ var ts; return autoArrayType; } } - if (declaration.kind === 144) { + if (declaration.kind === 145) { var func = declaration.parent; - if (func.kind === 152 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 151); + if (func.kind === 153 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 152); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -22031,7 +22742,10 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, declaration.questionToken && includeOptionality); } - if (declaration.kind === 258) { + if (ts.isJsxAttribute(declaration)) { + return trueType; + } + if (declaration.kind === 261) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -22039,6 +22753,21 @@ var ts; } return undefined; } + function getTypeForJSSpecialPropertyDeclaration(declaration) { + var expression = declaration.kind === 193 ? declaration : + declaration.kind === 178 ? ts.getAncestor(declaration, 193) : + undefined; + if (!expression) { + return unknownType; + } + if (expression.flags & 65536) { + var type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type && type !== unknownType) { + return getWidenedType(type); + } + } + return getWidenedLiteralType(checkExpressionCached(expression.right)); + } function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { return checkDeclarationInitializer(element); @@ -22066,11 +22795,11 @@ var ts; return; } var text = ts.getTextOfPropertyName(name); - var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); + var flags = 4 | (e.initializer ? 67108864 : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; - members[symbol.name] = symbol; + members.set(symbol.name, symbol); }); var result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); if (includePatternInType) { @@ -22096,7 +22825,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 172 + return pattern.kind === 173 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -22106,7 +22835,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 257) { + if (declaration.kind === 260) { return type; } return getWidenedType(type); @@ -22121,41 +22850,32 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 144 ? root.parent : root; + var memberDeclaration = root.kind === 145 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.flags & 134217728) { + if (symbol.flags & 16777216) { return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 240) { + if (declaration.kind === 242) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 && declaration.kind === 286 && declaration.typeExpression) { + if (declaration.flags & 65536 && declaration.kind === 290 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { return unknownType; } var type = void 0; - if (declaration.kind === 192 || - declaration.kind === 177 && declaration.parent.kind === 192) { - if (declaration.flags & 65536) { - var jsdocType = ts.getJSDocType(declaration.parent); - if (jsdocType) { - return links.type = getTypeFromTypeNode(jsdocType); - } - } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 192 ? - checkExpressionCached(decl.right) : - checkExpressionCached(decl.parent.right); }); - type = getUnionType(declaredTypes, true); + if (declaration.kind === 193 || + declaration.kind === 178 && declaration.parent.kind === 193) { + type = getWidenedType(getUnionType(ts.map(symbol.declarations, getTypeForJSSpecialPropertyDeclaration), true)); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -22169,7 +22889,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 151) { + if (accessor.kind === 152) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -22189,10 +22909,10 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 151); - var setter = ts.getDeclarationOfKind(symbol, 152); + var getter = ts.getDeclarationOfKind(symbol, 152); + var setter = ts.getDeclarationOfKind(symbol, 153); if (getter && getter.flags & 65536) { - var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); + var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; } @@ -22231,7 +22951,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 151); + var getter_1 = ts.getDeclarationOfKind(symbol, 152); 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)); } } @@ -22239,6 +22959,10 @@ var ts; } return links.type; } + function getBaseTypeVariableOfClass(symbol) { + var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); + return baseConstructorType.flags & 540672 ? baseConstructorType : undefined; + } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { @@ -22247,8 +22971,13 @@ var ts; } else { var type = createObjectType(16, symbol); - links.type = strictNullChecks && symbol.flags & 536870912 ? - includeFalsyTypes(type, 2048) : type; + if (symbol.flags & 32) { + var baseTypeVariable = getBaseTypeVariableOfClass(symbol); + links.type = baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; + } + else { + links.type = strictNullChecks && symbol.flags & 67108864 ? includeFalsyTypes(type, 2048) : type; + } } } return links.type; @@ -22295,7 +23024,7 @@ var ts; return anyType; } function getTypeOfSymbol(symbol) { - if (symbol.flags & 16777216) { + if (getCheckFlags(symbol) & 1) { return getTypeOfInstantiatedSymbol(symbol); } if (symbol.flags & (3 | 4)) { @@ -22321,13 +23050,18 @@ var ts; function hasBaseType(type, checkBase) { return check(type); function check(type) { - var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); + if (getObjectFlags(type) & (3 | 4)) { + var target = getTargetType(type); + return target === checkBase || ts.forEach(getBaseTypes(target), check); + } + else if (type.flags & 131072) { + return ts.forEach(type.types, check); + } } } function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { - var declaration = declarations_2[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -22344,9 +23078,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 226 || node.kind === 197 || - node.kind === 225 || node.kind === 184 || - node.kind === 149 || node.kind === 185) { + if (node.kind === 228 || node.kind === 198 || + node.kind === 227 || node.kind === 185 || + node.kind === 150 || node.kind === 186) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -22355,15 +23089,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 227); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 229); 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 === 227 || node.kind === 226 || - node.kind === 197 || node.kind === 228) { + if (node.kind === 229 || node.kind === 228 || + node.kind === 198 || node.kind === 230) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -22375,15 +23109,30 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } + function isMixinConstructorType(type) { + var signatures = getSignaturesOfType(type, 1); + if (signatures.length === 1) { + var s = signatures[0]; + return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + } + return false; + } function isConstructorType(type) { - return type.flags & 32768 && getSignaturesOfType(type, 1).length > 0; + if (isValidBaseType(type) && getSignaturesOfType(type, 1).length > 0) { + return true; + } + if (type.flags & 540672) { + var constraint = getBaseConstraintOfType(type); + return isValidBaseType(constraint) && isMixinConstructorType(constraint); + } + return false; } 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; }); + var typeArgCount = ts.length(typeArgumentNodes); + return ts.filter(getSignaturesOfType(type, 1), function (sig) { return typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); @@ -22403,7 +23152,7 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 32768) { + if (baseConstructorType.flags & (32768 | 131072)) { resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { @@ -22439,8 +23188,8 @@ var ts; } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - var baseConstructorType = getBaseConstructorTypeOfClass(type); - if (!(baseConstructorType.flags & 32768)) { + var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); + if (!(baseConstructorType.flags & (32768 | 131072))) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -22468,7 +23217,7 @@ var ts; if (baseType === unknownType) { return; } - if (!(getObjectFlags(getTargetType(baseType)) & 3)) { + if (!isValidBaseType(baseType)) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } @@ -22492,16 +23241,20 @@ var ts; } return true; } + function isValidBaseType(type) { + return type.flags & (32768 | 16777216) && !isGenericMappedType(type) || + type.flags & 131072 && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); + } 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 === 227 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 229 && 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 (getObjectFlags(getTargetType(baseType)) & 3) { + if (isValidBaseType(baseType)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; @@ -22525,7 +23278,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227) { + if (declaration.kind === 229) { if (declaration.flags & 64) { return false; } @@ -22558,7 +23311,7 @@ var ts; type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384); @@ -22575,7 +23328,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 285); + var declaration = ts.getDeclarationOfKind(symbol, 289); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -22586,7 +23339,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 228); + declaration = ts.getDeclarationOfKind(symbol, 230); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -22594,7 +23347,7 @@ var ts; if (typeParameters) { links.typeParameters = typeParameters; links.instantiations = ts.createMap(); - links.instantiations[getTypeListId(typeParameters)] = type; + links.instantiations.set(getTypeListId(typeParameters), type); } } else { @@ -22611,14 +23364,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 190 && expr.operator === 37 && + expr.kind === 191 && expr.operator === 37 && expr.operand.kind === 8 || - expr.kind === 70 && !!symbol.exports[expr.text]; + expr.kind === 70 && !!symbol.exports.get(expr.text); } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 231) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -22643,10 +23396,10 @@ var ts; enumType.symbol = symbol; if (enumHasLiteralMembers(symbol)) { var memberTypeList = []; - var memberTypes = ts.createMap(); + var memberTypes = []; for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 231) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -22663,7 +23416,7 @@ var ts; if (memberTypeList.length > 1) { enumType.flags |= 65536; enumType.types = memberTypeList; - unionTypes[getTypeListId(memberTypeList)] = enumType; + unionTypes.set(getTypeListId(memberTypeList), enumType); } } } @@ -22684,9 +23437,6 @@ var ts; if (!links.declaredType) { var type = createType(16384); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 143).constraint) { - type.constraint = noConstraintType; - } links.declaredType = type; } return links.declaredType; @@ -22699,7 +23449,6 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 16777216) === 0); if (symbol.flags & (32 | 64)) { return getDeclaredTypeOfClassOrInterface(symbol); } @@ -22734,19 +23483,20 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 136: + case 133: case 104: - case 137: + case 138: case 94: case 129: - case 171: + case 172: return true; - case 162: + case 163: return isIndependentType(node.elementType); - case 157: + case 158: return isIndependentTypeReference(node); } return false; @@ -22755,7 +23505,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 150 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 151 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -22771,12 +23521,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 147: - case 146: - return isIndependentVariableLikeDeclaration(declaration); - case 149: case 148: + case 147: + return isIndependentVariableLikeDeclaration(declaration); case 150: + case 149: + case 151: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -22787,7 +23537,7 @@ var ts; var result = ts.createMap(); for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { var symbol = symbols_1[_i]; - result[symbol.name] = symbol; + result.set(symbol.name, symbol); } return result; } @@ -22795,15 +23545,15 @@ var ts; var result = ts.createMap(); 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); + result.set(symbol.name, mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; } function addInheritedMembers(symbols, baseSymbols) { for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) { var s = baseSymbols_1[_i]; - if (!symbols[s.name]) { - symbols[s.name] = s; + if (!symbols.has(s.name)) { + symbols.set(s.name, s); } } } @@ -22811,8 +23561,8 @@ var ts; 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.declaredCallSignatures = getSignaturesOfSymbol(symbol.members.get("__call")); + type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members.get("__new")); type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0); type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1); } @@ -22820,7 +23570,14 @@ var ts; } function getTypeWithThisArgument(type, thisArgument) { if (getObjectFlags(type) & 4) { - return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + var target = type.target; + var typeArguments = type.typeArguments; + if (ts.length(target.typeParameters) === ts.length(typeArguments)) { + return createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); + } + } + else if (type.flags & 131072) { + return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument); })); } return type; } @@ -22856,7 +23613,7 @@ var ts; 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)); + addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0); @@ -22899,13 +23656,14 @@ var ts; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); - var typeArgCount = typeArguments ? typeArguments.length : 0; + var typeArgCount = ts.length(typeArguments); var result = []; for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { var baseSig = baseSignatures_1[_i]; - var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; - if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); + var typeParamCount = ts.length(baseSig.typeParameters); + if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) { + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -22959,7 +23717,7 @@ var ts; s = cloneSignature(signature); if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) { var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return getTypeOfSymbol(sig.thisParameter) || anyType; }), true); - s.thisParameter = createTransientSymbol(signature.thisParameter, thisType); + s.thisParameter = createSymbolWithType(signature.thisParameter, thisType); } s.resolvedReturnType = undefined; s.unionSignatures = unionSignatures; @@ -23001,17 +23759,44 @@ var ts; function unionSpreadIndexInfos(info1, info2) { return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly); } + function includeMixinType(type, types, index) { + var mixedTypes = []; + for (var i = 0; i < types.length; i++) { + if (i === index) { + mixedTypes.push(type); + } + else if (isMixinConstructorType(types[i])) { + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1)[0])); + } + } + return getIntersectionType(mixedTypes); + } function resolveIntersectionTypeMembers(type) { var callSignatures = emptyArray; var constructSignatures = emptyArray; - var stringIndexInfo = undefined; - var numberIndexInfo = undefined; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + var stringIndexInfo; + var numberIndexInfo; + var types = type.types; + var mixinCount = ts.countWhere(types, isMixinConstructorType); + var _loop_3 = function (i) { + var t = type.types[i]; + if (mixinCount === 0 || mixinCount === types.length && i === 0 || !isMixinConstructorType(t)) { + var signatures = getSignaturesOfType(t, 1); + if (signatures.length && mixinCount > 0) { + signatures = ts.map(signatures, function (s) { + var clone = cloneSignature(s); + clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, i); + return clone; + }); + } + constructSignatures = ts.concatenate(constructSignatures, signatures); + } callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1)); stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0)); numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1)); + }; + for (var i = 0; i < types.length; i++) { + _loop_3(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } @@ -23027,8 +23812,8 @@ var ts; } else if (symbol.flags & 2048) { var members = symbol.members; - var callSignatures = getSignaturesOfSymbol(members["__call"]); - var constructSignatures = getSignaturesOfSymbol(members["__new"]); + var callSignatures = getSignaturesOfSymbol(members.get("__call")); + var constructSignatures = getSignaturesOfSymbol(members.get("__new")); var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0); var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1); setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -23041,14 +23826,14 @@ var ts; } if (symbol.flags & 32) { var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); + constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 32768) { + if (baseConstructorType.flags & (32768 | 131072 | 540672)) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); + addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } } var numberIndexInfo = symbol.flags & 384 ? enumNumberIndexInfo : undefined; @@ -23068,8 +23853,11 @@ var ts; var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); var templateReadonly = !!type.declaration.readonlyToken; var templateOptional = !!type.declaration.questionToken; - if (type.declaration.typeParameter.constraint.kind === 168) { - forEachType(getLiteralTypeFromPropertyNames(modifiersType), addMemberForKeyType); + if (type.declaration.typeParameter.constraint.kind === 169) { + for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { + var propertySymbol = _a[_i]; + addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol); + } if (getIndexInfoOfType(modifiersType, 0)) { addMemberForKeyType(stringType); } @@ -23080,18 +23868,21 @@ var ts; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, undefined); - function addMemberForKeyType(t) { - var iterationMapper = createUnaryTypeMapper(typeParameter, t); + function addMemberForKeyType(t, propertySymbol) { + var iterationMapper = createTypeMapper([typeParameter], [t]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; var propType = instantiateType(templateType, templateMapper); if (t.flags & 32) { var propName = t.text; var modifiersProp = getPropertyOfType(modifiersType, propName); - var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 536870912); - var prop = createSymbol(4 | 67108864 | (isOptional ? 536870912 : 0), propName); + var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 67108864); + var prop = createSymbol(4 | (isOptional ? 67108864 : 0), propName); + prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 4 : 0; prop.type = propType; - prop.isReadonly = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp); - members[propName] = prop; + if (propertySymbol) { + prop.mappedTypeOrigin = propertySymbol; + } + members.set(propName, prop); } else if (t.flags & 2) { stringIndexInfo = createIndexInfo(propType, templateReadonly); @@ -23115,21 +23906,18 @@ var ts; function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { var constraintDeclaration = type.declaration.typeParameter.constraint; - if (constraintDeclaration.kind === 168) { + if (constraintDeclaration.kind === 169) { type.modifiersType = instantiateType(getTypeFromTypeNode(constraintDeclaration.type), type.mapper || identityMapper); } else { var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint.flags & 16384 ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint.flags & 262144 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 16384 ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 262144 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; } - function getErasedTemplateTypeFromMappedType(type) { - return instantiateType(getTemplateTypeFromMappedType(type), createUnaryTypeMapper(getTypeParameterFromMappedType(type), anyType)); - } function isGenericMappedType(type) { if (getObjectFlags(type) & 32) { var constraintType = getConstraintTypeFromMappedType(type); @@ -23171,35 +23959,33 @@ var ts; function getPropertyOfObjectType(type, name) { if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && 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]; - getUnionOrIntersectionProperty(type, prop.name); - } - if (type.flags & 65536) { - break; - } - } - var props = type.resolvedProperties; - if (props) { - var result = []; - for (var key in props) { - var prop = props[key]; - if (!(prop.flags & 268435456 && prop.isPartial)) { - result.push(prop); + if (!type.resolvedProperties) { + var members = ts.createMap(); + 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]; + if (!members.has(prop.name)) { + var combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.name); + if (combinedProp) { + members.set(prop.name, combinedProp); + } + } + } + if (type.flags & 65536) { + break; } } - return result; + type.resolvedProperties = getNamedMembers(members); } - return emptyArray; + return type.resolvedProperties; } function getPropertiesOfType(type) { type = getApparentType(type); @@ -23207,36 +23993,110 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } - function getApparentTypeOfTypeVariable(type) { - if (!type.resolvedApparentType) { - var constraintType = getConstraintOfTypeVariable(type); - while (constraintType && constraintType.flags & 16384) { - constraintType = getConstraintOfTypeVariable(constraintType); - } - type.resolvedApparentType = getTypeWithThisArgument(constraintType || emptyObjectType, type); + function getConstraintOfType(type) { + return type.flags & 16384 ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + } + function getConstraintOfTypeParameter(typeParameter) { + return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; + } + function getBaseConstraintOfType(type) { + var constraint = getResolvedBaseConstraint(type); + return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + } + function hasNonCircularBaseConstraint(type) { + return getResolvedBaseConstraint(type) !== circularConstraintType; + } + function getResolvedBaseConstraint(type) { + var typeStack; + var circular; + if (!type.resolvedBaseConstraint) { + typeStack = []; + var constraint = getBaseConstraint(type); + type.resolvedBaseConstraint = circular ? circularConstraintType : getTypeWithThisArgument(constraint || noConstraintType, type); } - return type.resolvedApparentType; + return type.resolvedBaseConstraint; + function getBaseConstraint(t) { + if (ts.contains(typeStack, t)) { + circular = true; + return undefined; + } + typeStack.push(t); + var result = computeBaseConstraint(t); + typeStack.pop(); + return result; + } + function computeBaseConstraint(t) { + if (t.flags & 16384) { + var constraint = getConstraintFromTypeParameter(t); + return t.isThisType ? constraint : + constraint ? getBaseConstraint(constraint) : undefined; + } + if (t.flags & 196608) { + var types = t.types; + var baseTypes = []; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var type_1 = types_2[_i]; + var baseType = getBaseConstraint(type_1); + if (baseType) { + baseTypes.push(baseType); + } + } + return t.flags & 65536 && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 131072 && baseTypes.length ? getIntersectionType(baseTypes) : + undefined; + } + if (t.flags & 262144) { + return stringType; + } + if (t.flags & 524288) { + var baseObjectType = getBaseConstraint(t.objectType); + var baseIndexType = getBaseConstraint(t.indexType); + var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; + return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + } + return t; + } + } + function getApparentTypeOfIntersectionType(type) { + return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type)); + } + function getDefaultFromTypeParameter(typeParameter) { + if (!typeParameter.default) { + if (typeParameter.target) { + var targetDefault = getDefaultFromTypeParameter(typeParameter.target); + typeParameter.default = targetDefault ? instantiateType(targetDefault, typeParameter.mapper) : noConstraintType; + } + else { + var defaultDeclaration = typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameter(decl) && decl.default; }); + typeParameter.default = defaultDeclaration ? getTypeFromTypeNode(defaultDeclaration) : noConstraintType; + } + } + return typeParameter.default === noConstraintType ? undefined : typeParameter.default; } function getApparentType(type) { - var t = type.flags & 540672 ? getApparentTypeOfTypeVariable(type) : type; - return t.flags & 262178 ? globalStringType : - t.flags & 340 ? globalNumberType : - t.flags & 136 ? globalBooleanType : - t.flags & 512 ? getGlobalESSymbolType() : - t; + var t = type.flags & 540672 ? getBaseConstraintOfType(type) || emptyObjectType : type; + return t.flags & 131072 ? getApparentTypeOfIntersectionType(t) : + t.flags & 262178 ? globalStringType : + t.flags & 340 ? globalNumberType : + t.flags & 136 ? globalBooleanType : + t.flags & 512 ? getGlobalESSymbolType() : + t.flags & 16777216 ? emptyObjectType : + t; } function createUnionOrIntersectionProperty(containingType, name) { - var types = containingType.types; var props; - var commonFlags = (containingType.flags & 131072) ? 536870912 : 0; - var isReadonly = false; - var isPartial = false; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var current = types_2[_i]; + var types = containingType.types; + var isUnion = containingType.flags & 65536; + var excludeModifiers = isUnion ? 24 : 0; + var commonFlags = isUnion ? 0 : 67108864; + var checkFlags = 2; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var current = types_3[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16))) { + var modifiers = prop ? getDeclarationModifierFlagsFromSymbol(prop) : 0; + if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; if (!props) { props = [prop]; @@ -23244,25 +24104,26 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } - if (isReadonlySymbol(prop)) { - isReadonly = true; - } + checkFlags |= (isReadonlySymbol(prop) ? 4 : 0) | + (!(modifiers & 24) ? 32 : 0) | + (modifiers & 16 ? 64 : 0) | + (modifiers & 8 ? 128 : 0) | + (modifiers & 32 ? 256 : 0); } - else if (containingType.flags & 65536) { - isPartial = true; + else if (isUnion) { + checkFlags |= 8; } } } if (!props) { return undefined; } - if (props.length === 1 && !isPartial) { + if (props.length === 1 && !(checkFlags & 8)) { return props[0]; } var propTypes = []; var declarations = []; var commonType = undefined; - var hasNonUniformType = false; for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { var prop = props_1[_a]; if (prop.declarations) { @@ -23273,39 +24134,37 @@ var ts; commonType = type; } else if (type !== commonType) { - hasNonUniformType = true; + checkFlags |= 16; } propTypes.push(type); } - var result = createSymbol(4 | 67108864 | 268435456 | commonFlags, name); + var result = createSymbol(4 | commonFlags, name); + result.checkFlags = checkFlags; result.containingType = containingType; - result.hasNonUniformType = hasNonUniformType; - result.isPartial = isPartial; result.declarations = declarations; - result.isReadonly = isReadonly; - result.type = containingType.flags & 65536 ? getUnionType(propTypes) : getIntersectionType(propTypes); + result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } function getUnionOrIntersectionProperty(type, name) { - var properties = type.resolvedProperties || (type.resolvedProperties = ts.createMap()); - var property = properties[name]; + var properties = type.propertyCache || (type.propertyCache = ts.createMap()); + var property = properties.get(name); if (!property) { property = createUnionOrIntersectionProperty(type, name); if (property) { - properties[name] = property; + properties.set(name, property); } } return property; } function getPropertyOfUnionOrIntersectionType(type, name) { var property = getUnionOrIntersectionProperty(type, name); - return property && !(property.flags & 268435456 && property.isPartial) ? property : undefined; + return property && !(getCheckFlags(property) & 8) ? property : undefined; } function getPropertyOfType(type, name) { type = getApparentType(type); if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } @@ -23384,16 +24243,16 @@ var ts; } function symbolsToArray(symbols) { var result = []; - for (var id in symbols) { + symbols.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { - result.push(symbols[id]); + result.push(symbol); } - } + }); return result; } function isJSDocOptionalParameter(node) { if (node.flags & 65536) { - if (node.type && node.type.kind === 273) { + if (node.type && node.type.kind === 277) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -23404,7 +24263,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 273; + return paramTag.typeExpression.type.kind === 277; } } } @@ -23428,6 +24287,12 @@ var ts; ts.Debug.assert(parameterIndex >= 0); return parameterIndex >= signature.minArgumentCount; } + var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); + if (iife) { + return !node.type && + !node.dotDotDotToken && + ts.indexOf(node.parent.parameters, node) >= iife.arguments.length; + } return false; } function createTypePredicateFromTypePredicateNode(node) { @@ -23447,16 +24312,49 @@ var ts; }; } } + function getMinTypeArgumentCount(typeParameters) { + var minTypeArgumentCount = 0; + if (typeParameters) { + for (var i = 0; i < typeParameters.length; i++) { + if (!getDefaultFromTypeParameter(typeParameters[i])) { + minTypeArgumentCount = i + 1; + } + } + } + return minTypeArgumentCount; + } + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount) { + var numTypeParameters = ts.length(typeParameters); + if (numTypeParameters) { + var numTypeArguments = ts.length(typeArguments); + if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) { + if (!typeArguments) { + typeArguments = []; + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + typeArguments[i] = emptyObjectType; + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + var mapper = createTypeMapper(typeParameters, typeArguments); + var defaultType = getDefaultFromTypeParameter(typeParameters[i]); + typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType; + } + } + } + return typeArguments; + } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; var hasLiteralTypes = false; - var minArgumentCount = -1; + var minArgumentCount = 0; var thisParameter = undefined; var hasThisParameter = void 0; + var iife = ts.getImmediatelyInvokedFunctionExpression(declaration); var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); - for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { + var isUntypedSignatureInJSFile = !iife && !isJSConstructSignature && ts.isInJavaScriptFile(declaration) && !ts.hasJSDocParameterTags(declaration); + for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) { @@ -23470,41 +24368,34 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 171) { + if (param.type && param.type.kind === 172) { hasLiteralTypes = true; } - if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { - if (minArgumentCount < 0) { - minArgumentCount = i - (hasThisParameter ? 1 : 0); - } - } - else { - minArgumentCount = -1; + var isOptionalParameter_1 = param.initializer || param.questionToken || param.dotDotDotToken || + iife && parameters.length > iife.arguments.length && !param.type || + isJSDocOptionalParameter(param) || + isUntypedSignatureInJSFile; + if (!isOptionalParameter_1) { + minArgumentCount = parameters.length; } } - if ((declaration.kind === 151 || declaration.kind === 152) && + if ((declaration.kind === 152 || declaration.kind === 153) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 151 ? 152 : 151; + var otherKind = declaration.kind === 152 ? 153 : 152; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); - } - if (isJSConstructSignature) { - minArgumentCount--; - } - var classType = declaration.kind === 150 ? + var classType = declaration.kind === 151 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 156 ? + var typePredicate = declaration.type && declaration.type.kind === 157 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -23527,8 +24418,8 @@ var ts; return type; } } - if (declaration.kind === 151 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 152); + if (declaration.kind === 152 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 153); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -23539,23 +24430,23 @@ var ts; if (!symbol) return emptyArray; var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { + for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 158: case 159: - case 225: - case 149: - case 148: + case 160: + case 227: case 150: - case 153: + case 149: + case 151: case 154: case 155: - case 151: + case 156: case 152: - case 184: + case 153: case 185: - case 274: + case 186: + case 278: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -23623,9 +24514,14 @@ var ts; return anyType; } function getSignatureInstantiation(signature, typeArguments) { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); - return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments)); + var instantiation = instantiations.get(id); + if (!instantiation) { + instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments)); + } + return instantiation; } function createSignatureInstantiation(signature, typeArguments) { return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); @@ -23640,7 +24536,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 150 || signature.declaration.kind === 154; + var isConstructor = signature.declaration.kind === 151 || signature.declaration.kind === 155; var type = createObjectType(16); type.members = emptySymbols; type.properties = emptyArray; @@ -23651,10 +24547,10 @@ var ts; return signature.isolatedSignatureType; } function getIndexSymbol(symbol) { - return symbol.members["__index"]; + return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 132 : 134; + var syntaxKind = kind === 1 ? 132 : 135; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -23681,21 +24577,9 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 143).constraint; + return ts.getDeclarationOfKind(type.symbol, 144).constraint; } - function hasConstraintReferenceTo(type, target) { - var checked; - while (type && type.flags & 16384 && !(type.isThisType) && !ts.contains(checked, type)) { - if (type === target) { - return true; - } - (checked || (checked = [])).push(type); - var constraintDeclaration = getConstraintDeclaration(type); - type = constraintDeclaration && getTypeFromTypeNode(constraintDeclaration); - } - return false; - } - function getConstraintOfTypeParameter(typeParameter) { + function getConstraintFromTypeParameter(typeParameter) { if (!typeParameter.constraint) { if (typeParameter.target) { var targetConstraint = getConstraintOfTypeParameter(typeParameter.target); @@ -23703,23 +24587,13 @@ var ts; } else { var constraintDeclaration = getConstraintDeclaration(typeParameter); - var constraint = getTypeFromTypeNode(constraintDeclaration); - if (hasConstraintReferenceTo(constraint, typeParameter)) { - error(constraintDeclaration, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); - constraint = unknownType; - } - typeParameter.constraint = constraint; + typeParameter.constraint = constraintDeclaration ? getTypeFromTypeNode(constraintDeclaration) : noConstraintType; } } return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } - function getConstraintOfTypeVariable(type) { - return type.flags & 16384 ? getConstraintOfTypeParameter(type) : - type.flags & 524288 ? type.constraint : - undefined; - } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 143).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 144).parent); } function getTypeListId(types) { var result = ""; @@ -23746,8 +24620,8 @@ var ts; } function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var type = types_3[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -23756,9 +24630,10 @@ var ts; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); - var type = target.instantiations[id]; + var type = target.instantiations.get(id); if (!type) { - type = target.instantiations[id] = createObjectType(4, target.symbol); + type = createObjectType(4, target.symbol); + target.instantiations.set(id, type); type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0; type.target = target; type.typeArguments = typeArguments; @@ -23774,17 +24649,22 @@ var ts; return type; } function getTypeReferenceArity(type) { - return type.target.typeParameters ? type.target.typeParameters.length : 0; + return ts.length(type.target.typeParameters); } function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(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); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, undefined, 1), minTypeArgumentCount, typeParameters.length); return unknownType; } - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount)); + return createTypeReference(type, typeArguments); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); @@ -23797,14 +24677,22 @@ var ts; var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + var instantiation = links.instantiations.get(id); + if (!instantiation) { + links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + } + return instantiation; } function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).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); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return unknownType; } var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); @@ -23825,11 +24713,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 157: + case 158: return node.typeName; - case 272: + case 276: return node.name; - case 199: + case 200: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -23853,7 +24741,7 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 272) { + if (symbol.flags & 107455 && node.kind === 276) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); @@ -23863,13 +24751,13 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 272) { + if (node.kind === 276) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { - var typeNameOrExpression = node.kind === 157 + var typeNameOrExpression = node.kind === 158 ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -23895,12 +24783,12 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var declaration = declarations_4[_i]; switch (declaration.kind) { - case 226: - case 227: + case 228: case 229: + case 231: return declaration; } } @@ -23913,7 +24801,7 @@ var ts; 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) { + if (ts.length(type.typeParameters) !== arity) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); return arity ? emptyGenericType : emptyObjectType; } @@ -23968,7 +24856,7 @@ var ts; for (var i = 0; i < arity; i++) { var typeParameter = createType(16384); typeParameters.push(typeParameter); - var property = createSymbol(4 | 67108864, "" + i); + var property = createSymbol(4, "" + i); property.type = typeParameter; properties.push(property); } @@ -23977,7 +24865,7 @@ var ts; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384); @@ -24059,14 +24947,14 @@ var ts; } } function addTypesToUnion(typeSet, types) { - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var t = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var t = types_6[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -24074,8 +24962,9 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; + if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } } @@ -24153,10 +25042,11 @@ var ts; return types[0]; } var id = getTypeListId(types); - var type = unionTypes[id]; + var type = unionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(types, 6144); - type = unionTypes[id] = createType(65536 | propagatedFlags); + type = createType(65536 | propagatedFlags); + unionTypes.set(id, type); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -24181,12 +25071,15 @@ var ts; if (type.flags & 65536 && typeSet.unionIndex === undefined) { typeSet.unionIndex = typeSet.length; } - typeSet.push(type); + if (!(type.flags & 32768 && type.objectFlags & 16 && + type.symbol && type.symbol.flags & (16 | 8192) && containsIdenticalType(typeSet, type))) { + typeSet.push(type); + } } } function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; addTypeToIntersection(typeSet, type); } } @@ -24208,10 +25101,11 @@ var ts; return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex, t)); }), false, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); - var type = intersectionTypes[id]; + var type = intersectionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, 6144); - type = intersectionTypes[id] = createType(131072 | propagatedFlags); + type = createType(131072 | propagatedFlags); + intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -24261,21 +25155,10 @@ var ts; var type = createType(524288); type.objectType = objectType; type.indexType = indexType; - if (type.objectType.flags & 229376) { - type.constraint = getIndexTypeOfType(type.objectType, 0); - } - else if (type.objectType.flags & 540672) { - var apparentType = getApparentTypeOfTypeVariable(type.objectType); - if (apparentType !== emptyObjectType) { - type.constraint = isTypeOfKind(type.indexType, 262178) ? - getIndexedAccessType(apparentType, type.indexType) : - getIndexTypeOfType(apparentType, 0); - } - } return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 178 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 ? accessNode : undefined; var propName = indexType.flags & (32 | 64 | 256) ? indexType.text : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? @@ -24304,7 +25187,7 @@ var ts; getIndexInfoOfType(objectType, 0) || undefined; if (indexInfo) { - if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); return unknownType; } @@ -24323,7 +25206,7 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 178 ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 179 ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (32 | 64)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); } @@ -24337,33 +25220,31 @@ var ts; return unknownType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 178 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 ? accessNode : undefined; if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); return unknownType; } - var mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); + var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } function getIndexedAccessType(objectType, indexType, accessNode) { if (maybeTypeOfKind(indexType, 540672 | 262144) || - maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 178) || + maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 179) || isGenericMappedType(objectType)) { if (objectType.flags & 1) { return objectType; } - if (accessNode) { - if (!isTypeAssignableTo(indexType, getIndexType(objectType))) { - error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); - return unknownType; - } - } if (isGenericMappedType(objectType)) { return getIndexedAccessForMappedType(objectType, indexType, accessNode); } var id = objectType.id + "," + indexType.id; - return indexedAccessTypes[id] || (indexedAccessTypes[id] = createIndexedAccessType(objectType, indexType)); + var type = indexedAccessTypes.get(id); + if (!type) { + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType)); + } + return type; } var apparentObjectType = getApparentType(objectType); if (indexType.flags & 65536 && !(indexType.flags & 8190)) { @@ -24403,7 +25284,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); - if (ts.isEmpty(node.symbol.members) && !aliasSymbol) { + if (node.symbol.members.size === 0 && !aliasSymbol) { links.resolvedType = emptyTypeLiteralType; } else { @@ -24416,13 +25297,13 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 228 ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 230 ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } - function getSpreadType(left, right, isFromObjectLiteral) { + function getSpreadType(left, right) { if (left.flags & 1 || right.flags & 1) { return anyType; } @@ -24435,10 +25316,13 @@ var ts; return left; } if (left.flags & 65536) { - return mapType(left, function (t) { return getSpreadType(t, right, isFromObjectLiteral); }); + return mapType(left, function (t) { return getSpreadType(t, right); }); } if (right.flags & 65536) { - return mapType(right, function (t) { return getSpreadType(left, t, isFromObjectLiteral); }); + return mapType(right, function (t) { return getSpreadType(left, t); }); + } + if (right.flags & 16777216) { + return emptyObjectType; } var members = ts.createMap(); var skippedPrivateMembers = ts.createMap(); @@ -24454,42 +25338,45 @@ var ts; } for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; - var isOwnProperty = !(rightProp.flags & 8192) || isFromObjectLiteral; var isSetterWithoutGetter = rightProp.flags & 65536 && !(rightProp.flags & 32768); if (getDeclarationModifierFlagsFromSymbol(rightProp) & (8 | 16)) { - skippedPrivateMembers[rightProp.name] = true; + skippedPrivateMembers.set(rightProp.name, true); } - else if (isOwnProperty && !isSetterWithoutGetter) { - members[rightProp.name] = rightProp; + else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { + members.set(rightProp.name, rightProp); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { var leftProp = _c[_b]; if (leftProp.flags & 65536 && !(leftProp.flags & 32768) - || leftProp.name in skippedPrivateMembers) { + || skippedPrivateMembers.has(leftProp.name) + || isClassMethod(leftProp)) { continue; } - if (leftProp.name in members) { - var rightProp = members[leftProp.name]; + if (members.has(leftProp.name)) { + var rightProp = members.get(leftProp.name); var rightType = getTypeOfSymbol(rightProp); - if (maybeTypeOfKind(rightType, 2048) || rightProp.flags & 536870912) { + if (maybeTypeOfKind(rightType, 2048) || rightProp.flags & 67108864) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 | 67108864 | (leftProp.flags & 536870912); + var flags = 4 | (leftProp.flags & 67108864); var result = createSymbol(flags, leftProp.name); + result.checkFlags = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp) ? 4 : 0; result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072)]); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; - result.isReadonly = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp); - members[leftProp.name] = result; + members.set(leftProp.name, result); } } else { - members[leftProp.name] = leftProp; + members.set(leftProp.name, leftProp); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } + function isClassMethod(prop) { + return prop.flags & 8192 && ts.find(prop.declarations, function (decl) { return ts.isClassLike(decl.parent); }); + } function createLiteralType(flags, text) { var type = createType(flags); type.text = text; @@ -24511,7 +25398,11 @@ var ts; } function getLiteralTypeForText(flags, text) { var map = flags & 32 ? stringLiteralTypes : numericLiteralTypes; - return map[text] || (map[text] = createLiteralType(flags, text)); + var type = map.get(text); + if (!type) { + map.set(text, type = createLiteralType(flags, text)); + } + return type; } function getTypeFromLiteralTypeNode(node) { var links = getNodeLinks(node); @@ -24539,9 +25430,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 227)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 229)) { if (!(ts.getModifierFlags(container) & 32) && - (container.kind !== 150 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 151 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -24558,85 +25449,87 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118: - case 263: - case 264: + case 267: + case 268: return anyType; - case 134: + case 135: return stringType; case 132: return numberType; case 121: return booleanType; - case 135: + case 136: return esSymbolType; case 104: return voidType; - case 137: + case 138: return undefinedType; case 94: return nullType; case 129: return neverType; - case 289: + case 133: + return nonPrimitiveType; + case 293: return nullType; - case 290: + case 294: return undefinedType; - case 291: + case 295: return neverType; - case 167: + case 168: case 98: return getTypeFromThisTypeNode(node); - case 171: + case 172: return getTypeFromLiteralTypeNode(node); - case 288: + case 292: return getTypeFromLiteralTypeNode(node.literal); - case 157: - case 272: - return getTypeFromTypeReference(node); - case 156: - return booleanType; - case 199: - return getTypeFromTypeReference(node); - case 160: - return getTypeFromTypeQueryNode(node); - case 162: - case 265: - return getTypeFromArrayTypeNode(node); - case 163: - return getTypeFromTupleTypeNode(node); - case 164: - case 266: - return getTypeFromUnionTypeNode(node); - case 165: - return getTypeFromIntersectionTypeNode(node); - case 166: - case 268: - case 269: - case 276: - case 277: - case 273: - return getTypeFromTypeNode(node.type); - case 270: - return getTypeFromTypeNode(node.literal); case 158: - case 159: + case 276: + return getTypeFromTypeReference(node); + case 157: + return booleanType; + case 200: + return getTypeFromTypeReference(node); case 161: - case 287: + return getTypeFromTypeQueryNode(node); + case 163: + case 269: + return getTypeFromArrayTypeNode(node); + case 164: + return getTypeFromTupleTypeNode(node); + case 165: + case 270: + return getTypeFromUnionTypeNode(node); + case 166: + return getTypeFromIntersectionTypeNode(node); + case 167: + case 272: + case 273: + case 280: + case 281: + case 277: + return getTypeFromTypeNode(node.type); case 274: + return getTypeFromTypeNode(node.literal); + case 159: + case 160: + case 162: + case 291: + case 278: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 168: - return getTypeFromTypeOperatorNode(node); case 169: - return getTypeFromIndexedAccessTypeNode(node); + return getTypeFromTypeOperatorNode(node); case 170: + return getTypeFromIndexedAccessTypeNode(node); + case 171: return getTypeFromMappedTypeNode(node); case 70: - case 141: + case 142: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 267: + case 271: return getTypeFromJSDocTupleType(node); - case 275: + case 279: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -24663,13 +25556,13 @@ var ts; var instantiations = mapper.instantiations || (mapper.instantiations = []); return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); } - function createUnaryTypeMapper(source, target) { + function makeUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } - function createBinaryTypeMapper(source1, target1, source2, target2) { + function makeBinaryTypeMapper(source1, target1, source2, target2) { return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; } - function createArrayTypeMapper(sources, targets) { + function makeArrayTypeMapper(sources, targets) { return function (t) { for (var i = 0; i < sources.length; i++) { if (t === sources[i]) { @@ -24680,16 +25573,20 @@ var ts; }; } function createTypeMapper(sources, targets) { - var count = sources.length; - var mapper = count == 1 ? createUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : - count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : - createArrayTypeMapper(sources, targets); + var mapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : + makeArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; return mapper; } function createTypeEraser(sources) { return createTypeMapper(sources, undefined); } + function createBackreferenceMapper(typeParameters, index) { + var mapper = function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; + mapper.mappedTypes = typeParameters; + return mapper; + } function getInferenceMapper(context) { if (!context.mapper) { var mapper = function (t) { @@ -24713,7 +25610,12 @@ var ts; } function combineTypeMappers(mapper1, mapper2) { var mapper = function (t) { return instantiateType(mapper1(t), mapper2); }; - mapper.mappedTypes = mapper1.mappedTypes; + mapper.mappedTypes = ts.concatenate(mapper1.mappedTypes, mapper2.mappedTypes); + return mapper; + } + function createReplacementMapper(source, target, baseMapper) { + var mapper = function (t) { return t === source ? target : baseMapper(t); }; + mapper.mappedTypes = baseMapper.mappedTypes; return mapper; } function cloneTypeParameter(typeParameter) { @@ -24758,12 +25660,13 @@ var ts; return result; } function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 16777216) { + if (getCheckFlags(symbol) & 1) { var links = getSymbolLinks(symbol); symbol = links.target; mapper = combineTypeMappers(links.mapper, mapper); } - var result = createSymbol(16777216 | 67108864 | symbol.flags, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); + result.checkFlags = 1; result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -24785,17 +25688,16 @@ var ts; var constraintType = getConstraintTypeFromMappedType(type); if (constraintType.flags & 262144) { var typeVariable_1 = constraintType.type; - var mappedTypeVariable = instantiateType(typeVariable_1, mapper); - if (typeVariable_1 !== mappedTypeVariable) { - return mapType(mappedTypeVariable, function (t) { - if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); - } - return t; - }); + if (typeVariable_1.flags & 16384) { + var mappedTypeVariable = instantiateType(typeVariable_1, mapper); + if (typeVariable_1 !== mappedTypeVariable) { + return mapType(mappedTypeVariable, function (t) { + if (isMappableType(t)) { + return instantiateMappedObjectType(type, createReplacementMapper(typeVariable_1, t, mapper)); + } + return t; + }); + } } } return instantiateMappedObjectType(type, mapper); @@ -24816,26 +25718,26 @@ var ts; return false; } var mappedTypes = mapper.mappedTypes; - var node = symbol.declarations[0].parent; + var node = symbol.declarations[0]; while (node) { switch (node.kind) { - case 158: case 159: - case 225: - case 149: - case 148: + case 160: + case 227: case 150: - case 153: + case 149: + case 151: case 154: case 155: - case 151: + case 156: case 152: - case 184: + case 153: case 185: - case 226: - case 197: - case 227: + case 186: case 228: + case 198: + case 229: + case 230: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -24845,15 +25747,29 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 227) { + if (ts.isClassLike(node) || node.kind === 229) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 230: - case 261: + case 171: + if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { + return true; + } + break; + case 278: + var func = node; + for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { + var p = _c[_b]; + if (ts.contains(mappedTypes, getTypeOfNode(p))) { + return true; + } + } + break; + case 232: + case 264: return false; } node = node.parent; @@ -24863,7 +25779,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 261 || parentKind === 231; + return parentKind === 264 || parentKind === 233; } return false; } @@ -24915,28 +25831,34 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 184: case 185: + case 186: return isContextSensitiveFunctionLikeDeclaration(node); - case 176: + case 177: return ts.forEach(node.properties, isContextSensitive); - case 175: + case 176: return ts.forEach(node.elements, isContextSensitive); - case 193: + case 194: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 192: + case 193: return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 257: + case 260: return isContextSensitive(node.initializer); + case 150: case 149: - case 148: return isContextSensitiveFunctionLikeDeclaration(node); - case 183: + case 184: return isContextSensitive(node.expression); + case 253: + return ts.forEach(node.properties, isContextSensitive); + case 252: + return node.initializer && isContextSensitive(node.initializer); + case 255: + return node.expression && isContextSensitive(node.expression); } return false; } @@ -24947,7 +25869,7 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !p.type; })) { return true; } - if (node.kind === 185) { + if (node.kind === 186) { return false; } var parameter = ts.firstOrUndefined(node.parameters); @@ -24965,9 +25887,12 @@ var ts; result.properties = resolved.properties; result.callSignatures = emptyArray; result.constructSignatures = emptyArray; - type = result; + return result; } } + else if (type.flags & 131072) { + return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); + } return type; } function isTypeIdenticalTo(source, target) { @@ -24986,7 +25911,7 @@ var ts; return isTypeRelatedTo(source, target, assignableRelation); } function isTypeInstanceOf(source, target) { - return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + return getTargetType(source) === getTargetType(target) || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); } function isTypeComparableTo(source, target) { return isTypeRelatedTo(source, target, comparableRelation); @@ -25134,13 +26059,15 @@ var ts; return true; } var id = source.id + "," + target.id; - if (enumRelation[id] !== undefined) { - return enumRelation[id]; + var relation = enumRelation.get(id); + if (relation !== undefined) { + return relation; } if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & 256) || !(target.symbol.flags & 256) || (source.flags & 65536) !== (target.flags & 65536)) { - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } var targetEnumType = getTypeOfSymbol(target.symbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(source.symbol)); _i < _a.length; _i++) { @@ -25151,11 +26078,13 @@ var ts; if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, property.name, typeToString(target, undefined, 128)); } - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } } } - return enumRelation[id] = true; + enumRelation.set(id, true); + return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { if (target.flags & 8192) @@ -25176,6 +26105,8 @@ var ts; return true; if (source.flags & 4096 && (!strictNullChecks || target.flags & 4096)) return true; + if (source.flags & 32768 && target.flags & 16777216) + return true; if (relation === assignableRelation || relation === comparableRelation) { if (source.flags & 1) return true; @@ -25207,12 +26138,12 @@ var ts; } if (source.flags & 32768 && target.flags & 32768) { var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { return related === 1; } } - if (source.flags & 507904 || target.flags & 507904) { + if (source.flags & 1032192 || target.flags & 1032192) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -25351,14 +26282,6 @@ var ts; } } } - else { - var constraint = getConstraintOfTypeParameter(target); - if (constraint && constraint.flags & 262144) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - return result; - } - } - } } else if (target.flags & 262144) { if (source.flags & 262144) { @@ -25366,12 +26289,10 @@ var ts; return result; } } - if (target.type.flags & 540672) { - var constraint = getConstraintOfTypeVariable(target.type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } + var constraint = getConstraintOfType(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; } } } @@ -25381,8 +26302,9 @@ var ts; return result; } } - if (target.constraint) { - if (result = isRelatedTo(source, target.constraint, reportErrors)) { + var constraint = getBaseConstraintOfType(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -25399,20 +26321,23 @@ var ts; } else { var constraint = getConstraintOfTypeParameter(source); - if (!constraint || constraint.flags & 1) { - constraint = emptyObjectType; - } - constraint = getTypeWithThisArgument(constraint, source); - var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; + if (constraint || !(target.flags & 16777216)) { + if (!constraint || constraint.flags & 1) { + constraint = emptyObjectType; + } + constraint = getTypeWithThisArgument(constraint, source); + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } } else if (source.flags & 524288) { - if (source.constraint) { - if (result = isRelatedTo(source.constraint, target, reportErrors)) { + var constraint = getBaseConstraintOfType(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -25464,42 +26389,55 @@ var ts; } return 0; } - function isKnownProperty(type, name) { + function isKnownProperty(type, name, isComparingJsxAttributes) { if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) || - resolved.stringIndexInfo || - (resolved.numberIndexInfo && isNumericLiteralName(name)) || - getPropertyOfType(type, name)) { + if ((relation === assignableRelation || relation === comparableRelation) && + (type === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(resolved)))) { + return true; + } + else if (resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name))) { + return true; + } + else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) { return true; } } else if (type.flags & 196608) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (isKnownProperty(t, name)) { + if (isKnownProperty(t, name, isComparingJsxAttributes)) { return true; } } } return false; } - function isEmptyObjectType(t) { + function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && t.constructSignatures.length === 0 && !t.stringIndexInfo && !t.numberIndexInfo; } + function isEmptyObjectType(type) { + return type.flags & 32768 && isEmptyResolvedType(resolveStructuredTypeMembers(type)); + } function hasExcessProperties(source, target, reportErrors) { if (maybeTypeOfKind(target, 32768) && !(getObjectFlags(target) & 512)) { + var isComparingJsxAttributes = !!(source.flags & 33554432); for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; - if (!isKnownProperty(target, prop.name)) { + if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) { if (reportErrors) { ts.Debug.assert(!!errorNode); - 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)); + if (ts.isJsxAttributes(errorNode)) { + reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); + } + else { + 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; } @@ -25525,20 +26463,42 @@ var ts; if (target.flags & 65536 && containsType(targetTypes, source)) { return -1; } - var len = targetTypes.length; - for (var i = 0; i < len; i++) { - var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); + for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { + var type = targetTypes_1[_i]; + var related = isRelatedTo(source, type, false); if (related) { return related; } } + if (reportErrors) { + var discriminantType = findMatchingDiscriminantType(source, target); + isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], true); + } return 0; } + function findMatchingDiscriminantType(source, target) { + var sourceProperties = getPropertiesOfObjectType(source); + if (sourceProperties) { + for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { + var sourceProperty = sourceProperties_1[_i]; + if (isDiscriminantProperty(target, sourceProperty.name)) { + var sourceType = getTypeOfSymbol(sourceProperty); + for (var _a = 0, _b = target.types; _a < _b.length; _a++) { + var type = _b[_a]; + var targetType = getTypeOfPropertyOfType(type, sourceProperty.name); + if (targetType && isRelatedTo(sourceType, targetType)) { + return type; + } + } + } + } + } + } function typeRelatedToEachType(source, target, reportErrors) { var result = -1; var targetTypes = target.types; - for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { - var targetType = targetTypes_1[_i]; + for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { + var targetType = targetTypes_2[_i]; var related = isRelatedTo(source, targetType, reportErrors); if (!related) { return 0; @@ -25596,10 +26556,10 @@ var ts; return 0; } var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2) { - relation[id] = 3; + relation.set(id, 3); } else { return related === 1 ? -1 : 0; @@ -25607,7 +26567,7 @@ var ts; } if (depth > 0) { for (var i = 0; i < depth; i++) { - if (maybeStack[i][id]) { + if (maybeStack[i].get(id)) { return 1; } } @@ -25625,7 +26585,7 @@ var ts; sourceStack[depth] = source; targetStack[depth] = target; maybeStack[depth] = ts.createMap(); - maybeStack[depth][id] = 1; + maybeStack[depth].set(id, 1); depth++; var saveExpandingFlags = expandingFlags; if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) @@ -25659,37 +26619,40 @@ var ts; if (result) { var maybeCache = maybeStack[depth]; var destinationCache = (result === -1 || depth === 0) ? relation : maybeStack[depth - 1]; - ts.copyProperties(maybeCache, destinationCache); + ts.copyEntries(maybeCache, destinationCache); } else { - relation[id] = reportErrors ? 3 : 2; + relation.set(id, reportErrors ? 3 : 2); } return result; } function mappedTypeRelatedTo(source, target, reportErrors) { if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { - var result_2; - if (relation === identityRelation) { - var readonlyMatches = !source.declaration.readonlyToken === !target.declaration.readonlyToken; - var optionalMatches = !source.declaration.questionToken === !target.declaration.questionToken; - if (readonlyMatches && optionalMatches) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getErasedTemplateTypeFromMappedType(source), getErasedTemplateTypeFromMappedType(target), reportErrors); - } - } - } - else { - if (relation === comparableRelation || !source.declaration.questionToken || target.declaration.questionToken) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors); - } + var sourceReadonly = !!source.declaration.readonlyToken; + var sourceOptional = !!source.declaration.questionToken; + var targetReadonly = !!target.declaration.readonlyToken; + var targetOptional = !!target.declaration.questionToken; + var modifiersRelated = relation === identityRelation ? + sourceReadonly === targetReadonly && sourceOptional === targetOptional : + relation === comparableRelation || !sourceOptional || targetOptional; + if (modifiersRelated) { + var result_2; + if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { + var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); + return result_2 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } + else if (target.declaration.questionToken && isEmptyObjectType(source)) { + return -1; + } } - else if (relation !== identityRelation && isEmptyObjectType(resolveStructuredTypeMembers(target))) { - return -1; + else if (relation !== identityRelation) { + var resolved = resolveStructuredTypeMembers(target); + if (isEmptyResolvedType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1) { + return -1; + } } return 0; } @@ -25705,17 +26668,23 @@ var ts; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { - if (!(targetProp.flags & 536870912) || requireOptionalProperties) { + if (!(targetProp.flags & 67108864) || requireOptionalProperties) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); } return 0; } } - else if (!(targetProp.flags & 134217728)) { + else if (!(targetProp.flags & 16777216)) { var sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 || targetPropFlags & 8) { + if (getCheckFlags(sourceProp) & 128) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); + } + return 0; + } if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { if (sourcePropFlags & 8 && targetPropFlags & 8) { @@ -25729,12 +26698,9 @@ var ts; } } else if (targetPropFlags & 16) { - var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(getParentOfSymbol(sourceProp)) : undefined; - var targetClass = getDeclaredTypeOfSymbol(getParentOfSymbol(targetProp)); - if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { + if (!isValidOverrideOf(sourceProp, targetProp)) { 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)); + reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } return 0; } @@ -25753,7 +26719,7 @@ var ts; return 0; } result &= related; - if (relation !== comparableRelation && sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { + if (relation !== comparableRelation && sourceProp.flags & 67108864 && !(targetProp.flags & 67108864)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -25774,8 +26740,8 @@ var ts; return 0; } var result = -1; - for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { - var sourceProp = sourceProperties_1[_i]; + for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) { + var sourceProp = sourceProperties_2[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return 0; @@ -25840,7 +26806,7 @@ var ts; return 0; } var result = -1; - for (var i = 0, len = sourceSignatures.length; i < len; i++) { + for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], false, false, false, isRelatedTo); if (!related) { return 0; @@ -25936,6 +26902,37 @@ var ts; return false; } } + function forEachProperty(prop, callback) { + if (getCheckFlags(prop) & 2) { + for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var p = getPropertyOfType(t, prop.name); + var result = p && forEachProperty(p, callback); + if (result) { + return result; + } + } + return undefined; + } + return callback(prop); + } + function getDeclaringClass(prop) { + return prop.parent && prop.parent.flags & 32 ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + } + function isPropertyInClassDerivedFrom(prop, baseClass) { + return forEachProperty(prop, function (sp) { + var sourceClass = getDeclaringClass(sp); + return sourceClass ? hasBaseType(sourceClass, baseClass) : false; + }); + } + function isValidOverrideOf(sourceProp, targetProp) { + return !forEachProperty(targetProp, function (tp) { return getDeclarationModifierFlagsFromSymbol(tp) & 16 ? + !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); + } + function isClassDerivedFromDeclaringClasses(checkClass, prop) { + return forEachProperty(prop, function (p) { return getDeclarationModifierFlagsFromSymbol(p) & 16 ? + !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; + } function isAbstractConstructorType(type) { if (getObjectFlags(type) & 16) { var symbol = type.symbol; @@ -25981,7 +26978,7 @@ var ts; } } else { - if ((sourceProp.flags & 536870912) !== (targetProp.flags & 536870912)) { + if ((sourceProp.flags & 67108864) !== (targetProp.flags & 67108864)) { return 0; } } @@ -26011,7 +27008,7 @@ var ts; if (!(isMatchingSignature(source, target, partialMatch))) { return 0; } - if ((source.typeParameters ? source.typeParameters.length : 0) !== (target.typeParameters ? target.typeParameters.length : 0)) { + if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { return 0; } source = getErasedSignature(source); @@ -26049,8 +27046,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var t = types_7[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -26058,8 +27055,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -26150,8 +27147,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getFalsyFlags(t); } return result; @@ -26180,7 +27177,7 @@ var ts; types.push(undefinedType); if (flags & 4096) types.push(nullType); - return getUnionType(types, true); + return getUnionType(types); } function removeDefinitelyFalsyTypes(type) { return getFalsyFlags(type) & 7392 ? @@ -26195,8 +27192,8 @@ var ts; getSignaturesOfType(type, 0).length === 0 && getSignaturesOfType(type, 1).length === 0; } - function createTransientSymbol(source, type) { - var symbol = createSymbol(source.flags | 67108864, source.name); + function createSymbolWithType(source, type) { + var symbol = createSymbol(source.flags, source.name); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -26212,7 +27209,7 @@ var ts; var property = _a[_i]; var original = getTypeOfSymbol(property); var updated = f(original); - members[property.name] = updated === original ? property : createTransientSymbol(property, updated); + members.set(property.name, updated === original ? property : createSymbolWithType(property, updated)); } ; return members; @@ -26298,25 +27295,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 148: case 147: - case 146: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 144: + case 145: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 174: + case 175: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 225: + case 227: + case 150: case 149: - case 148: - case 151: case 152: - case 184: + case 153: case 185: + case 186: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -26401,7 +27398,7 @@ var ts; var typeInferencesArray = [typeInferences]; var templateType = getTemplateTypeFromMappedType(target); var readonlyMask = target.declaration.readonlyToken ? false : true; - var optionalMask = target.declaration.questionToken ? 0 : 536870912; + var optionalMask = target.declaration.questionToken ? 0 : 67108864; var members = createSymbolTable(properties); for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var prop = properties_4[_i]; @@ -26409,11 +27406,11 @@ var ts; if (!inferredPropType) { return undefined; } - var inferredProp = createSymbol(4 | 67108864 | prop.flags & optionalMask, prop.name); + var inferredProp = createSymbol(4 | prop.flags & optionalMask, prop.name); + inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 4 : 0; inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; - inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop); - members[prop.name] = inferredProp; + members.set(prop.name, inferredProp); } if (indexInfo) { var inferredIndexType = inferTargetType(indexInfo.type); @@ -26523,8 +27520,8 @@ var ts; var targetTypes = target.types; var typeVariableCount = 0; var typeVariable = void 0; - for (var _d = 0, targetTypes_2 = targetTypes; _d < targetTypes_2.length; _d++) { - var t = targetTypes_2[_d]; + for (var _d = 0, targetTypes_3 = targetTypes; _d < targetTypes_3.length; _d++) { + var t = targetTypes_3[_d]; if (t.flags & 540672 && ts.contains(typeVariables, t)) { typeVariable = t; typeVariableCount++; @@ -26556,10 +27553,10 @@ var ts; return; } var key = source.id + "," + target.id; - if (visited[key]) { + if (visited.get(key)) { return; } - visited[key] = true; + visited.set(key, true); if (depth === 0) { sourceStack = []; targetStack = []; @@ -26651,8 +27648,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -26693,7 +27690,13 @@ var ts; inferenceSucceeded = !!unionOrSuperType; } else { - inferredType = emptyObjectType; + var defaultType = getDefaultFromTypeParameter(context.signature.typeParameters[index]); + if (defaultType) { + inferredType = instantiateType(defaultType, combineTypeMappers(createBackreferenceMapper(context.signature.typeParameters, index), getInferenceMapper(context))); + } + else { + inferredType = emptyObjectType; + } inferenceSucceeded = true; } context.inferredTypes[index] = inferredType; @@ -26728,10 +27731,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 160: + case 161: return true; case 70: - case 141: + case 142: node = node.parent; continue; default: @@ -26748,7 +27751,7 @@ var ts; if (node.kind === 98) { return "0"; } - if (node.kind === 177) { + if (node.kind === 178) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -26759,7 +27762,7 @@ var ts; case 70: case 98: return node; - case 177: + case 178: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -26768,19 +27771,19 @@ var ts; switch (source.kind) { case 70: return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 223 || target.kind === 174) && + (target.kind === 225 || target.kind === 175) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98: return target.kind === 98; - case 177: - return target.kind === 177 && + case 178: + return target.kind === 178 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 177) { + while (source.kind === 178) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -26789,7 +27792,7 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 177 && + return target.kind === 178 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -26797,7 +27800,7 @@ var ts; if (expr.kind === 70) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 177) { + if (expr.kind === 178) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -26806,9 +27809,9 @@ var ts; function isDiscriminantProperty(type, name) { if (type && type.flags & 65536) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && prop.flags & 268435456) { + if (prop && getCheckFlags(prop) & 2) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.hasNonUniformType && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.checkFlags & 16 && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -26827,7 +27830,7 @@ var ts; } } } - if (callExpression.expression.kind === 177 && + if (callExpression.expression.kind === 178 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -26866,8 +27869,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -26875,7 +27878,7 @@ var ts; function isFunctionObjectType(type) { var resolved = resolveStructuredTypeMembers(type); return !!(resolved.callSignatures.length || resolved.constructSignatures.length || - resolved.members["bind"] && isTypeSubtypeOf(type, globalFunctionType)); + resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type) { var flags = type.flags; @@ -26918,6 +27921,9 @@ var ts; if (flags & 512) { return strictNullChecks ? 1981320 : 4193160; } + if (flags & 16777216) { + return strictNullChecks ? 6166480 : 8378320; + } if (flags & 16384) { var constraint = getConstraintOfTypeParameter(type); return getTypeFacts(constraint || emptyObjectType); @@ -26953,10 +27959,16 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 || node.parent.kind === 257 ? + var isDestructuringDefaultAssignment = node.parent.kind === 176 && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 260 && isDestructuringAssignmentTarget(node.parent.parent); + return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } + function isDestructuringAssignmentTarget(parent) { + return parent.parent.kind === 193 && parent.parent.left === parent || + parent.parent.kind === 215 && parent.parent.initializer === parent; + } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); } @@ -26972,21 +27984,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 212: + case 214: return stringType; - case 213: + case 215: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 192: + case 193: return getAssignedTypeOfBinaryExpression(parent); - case 186: + case 187: return undefinedType; - case 175: + case 176: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 196: + case 197: return getAssignedTypeOfSpreadExpression(parent); - case 257: + case 260: return getAssignedTypeOfPropertyAssignment(parent); - case 258: + case 261: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -26994,7 +28006,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 172 ? + var type = pattern.kind === 173 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -27009,35 +28021,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 212) { + if (node.parent.parent.kind === 214) { return stringType; } - if (node.parent.parent.kind === 213) { + if (node.parent.parent.kind === 215) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 223 ? + return node.kind === 225 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 223 || node.kind === 174 ? + return node.kind === 225 || node.kind === 175 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 223 && node.initializer && + return node.kind === 225 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 174 && node.parent.kind === 192 && + node.kind !== 175 && node.parent.kind === 193 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 183: + case 184: return getReferenceCandidate(node.expression); - case 192: + case 193: switch (node.operatorToken.kind) { case 57: return getReferenceCandidate(node.left); @@ -27049,13 +28061,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 183 || - parent.kind === 192 && parent.operatorToken.kind === 57 && parent.left === node || - parent.kind === 192 && parent.operatorToken.kind === 25 && parent.right === node ? + return parent.kind === 184 || + parent.kind === 193 && parent.operatorToken.kind === 57 && parent.left === node || + parent.kind === 193 && parent.operatorToken.kind === 25 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 253) { + if (clause.kind === 256) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -27157,8 +28169,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; if (!(t.flags & 8192)) { if (!(getObjectFlags(t) & 256)) { return false; @@ -27176,11 +28188,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 177 && (parent.name.text === "length" || - parent.parent.kind === 179 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 178 && + var isLengthPushOrUnshift = parent.kind === 178 && (parent.name.text === "length" || + parent.parent.kind === 180 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 179 && parent.expression === root && - parent.parent.kind === 192 && + parent.parent.kind === 193 && parent.parent.operatorToken.kind === 57 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -27209,7 +28221,7 @@ var ts; } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 17810431)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -27219,7 +28231,7 @@ var ts; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; var resultType = getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 201 && getTypeWithFacts(resultType, 524288).flags & 8192) { + if (reference.parent.kind === 202 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } return resultType; @@ -27233,7 +28245,16 @@ var ts; } } var type = void 0; - if (flow.flags & 16) { + if (flow.flags & 4096) { + flow.locked = true; + type = getTypeAtFlowNode(flow.antecedent); + flow.locked = false; + } + else if (flow.flags & 2048) { + flow = flow.antecedent; + continue; + } + else if (flow.flags & 16) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; @@ -27264,7 +28285,7 @@ var ts; } else if (flow.flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 177) { + if (container && container !== flowContainer && reference.kind !== 178) { flow = container.flowNode; continue; } @@ -27307,7 +28328,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 179 ? + var expr = node.kind === 180 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -27315,7 +28336,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 179) { + if (node.kind === 180) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -27367,6 +28388,9 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; + if (antecedent.flags & 2048 && antecedent.lock.locked) { + continue; + } var flowType = getTypeAtFlowNode(antecedent); var type = getTypeFromFlowType(flowType); if (type === declaredType && declaredType === initialType) { @@ -27390,8 +28414,9 @@ var ts; if (!key) { key = getFlowCacheKey(reference); } - if (cache[key]) { - return cache[key]; + var cached = cache.get(key); + if (cached) { + return cached; } for (var i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { @@ -27413,8 +28438,9 @@ var ts; firstAntecedentType = flowType; } var type = getTypeFromFlowType(flowType); - if (cache[key]) { - return cache[key]; + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; } if (!ts.contains(antecedentTypes, type)) { antecedentTypes.push(type); @@ -27430,10 +28456,11 @@ var ts; if (isIncomplete(firstAntecedentType)) { return createFlowType(result, true); } - return cache[key] = result; + cache.set(key, result); + return result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 177 && + return expr.kind === 178 && declaredType.flags & 65536 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -27467,10 +28494,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 187 && right_1.kind === 9) { + if (left_1.kind === 188 && right_1.kind === 9) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 187 && left_1.kind === 9) { + if (right_1.kind === 188 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -27516,7 +28543,7 @@ var ts; assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); } - if (type.flags & 33281) { + if (type.flags & 16810497) { return type; } if (assumeTrue) { @@ -27541,14 +28568,14 @@ var ts; assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 65536)) { - var targetType = typeofTypesByName[literal.text]; + var targetType = typeofTypesByName.get(literal.text); if (targetType && isTypeSubtypeOf(targetType, type)) { return targetType; } } var facts = assumeTrue ? - typeofEQFacts[literal.text] || 64 : - typeofNEFacts[literal.text] || 8192; + typeofEQFacts.get(literal.text) || 64 : + typeofNEFacts.get(literal.text) || 8192; return getTypeWithFacts(type, facts); } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { @@ -27648,7 +28675,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 178 || invokedExpression.kind === 177) { + if (invokedExpression.kind === 179 || invokedExpression.kind === 178) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -27665,15 +28692,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 177: + case 178: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 179: + case 180: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 183: + case 184: return narrowType(type, expr.expression, assumeTrue); - case 192: + case 193: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 190: + case 191: if (expr.operator === 50) { return narrowType(type, expr.operand, !assumeTrue); } @@ -27700,9 +28727,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 231 || - node.kind === 261 || - node.kind === 147) { + node.kind === 233 || + node.kind === 264 || + node.kind === 148) { return node; } } @@ -27733,7 +28760,7 @@ var ts; if (node.kind === 70) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 144) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 145) { symbol.isAssigned = true; } } @@ -27753,7 +28780,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 185) { + if (container.kind === 186) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256)) { @@ -27771,7 +28798,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; - if (declaration_1.kind === 226 + if (declaration_1.kind === 228 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -27783,11 +28810,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 197) { + else if (declaration_1.kind === 198) { var container = ts.getThisContainer(node, false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 147 && ts.hasModifier(container, 32)) { + if (container.kind === 148 && ts.hasModifier(container, 32)) { getNodeLinks(declaration_1).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -27799,6 +28826,7 @@ var ts; } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkCollisionWithCapturedNewTargetVariable(node, node); checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; @@ -27816,17 +28844,17 @@ var ts; if (!(localOrExportSymbol.flags & 3) || assignmentKind === 1 || !declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 144; + var isParameter = ts.getRootDeclaration(declaration).kind === 145; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - while (flowContainer !== declarationContainer && (flowContainer.kind === 184 || - flowContainer.kind === 185 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 185 || + flowContainer.kind === 186 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0 || isInTypeQuery(node)) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); if (type === autoType || type === autoArrayType) { @@ -27857,7 +28885,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 256) { + symbol.valueDeclaration.parent.kind === 259) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -27875,8 +28903,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 211 && - ts.getAncestor(symbol.valueDeclaration, 224).parent === container && + if (container.kind === 213 && + ts.getAncestor(symbol.valueDeclaration, 226).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -27888,14 +28916,14 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 183) { + while (current.parent.kind === 184) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 190 || current.parent.kind === 191)) { + else if ((current.parent.kind === 191 || current.parent.kind === 192)) { var expr = current.parent; isAssigned = expr.operator === 42 || expr.operator === 43; } @@ -27914,7 +28942,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 147 || container.kind === 150) { + if (container.kind === 148 || container.kind === 151) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -27958,32 +28986,32 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 150) { + if (container.kind === 151) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } - if (container.kind === 185) { + if (container.kind === 186) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 230: + case 232: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 229: + case 231: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 150: + case 151: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 148: case 147: - case 146: if (ts.getModifierFlags(container) & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 142: + case 143: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -27992,7 +29020,7 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 184 && + if (container.kind === 185 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent @@ -28027,27 +29055,27 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 274) { + if (jsdocType && jsdocType.kind === 278) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 277) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 281) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 144) { + if (n.kind === 145) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 179 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 180 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 185) { + while (container && container.kind === 186) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -28056,16 +29084,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 142) { + while (current && current !== container && current.kind !== 143) { current = current.parent; } - if (current && current.kind === 142) { + if (current && current.kind === 143) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 176)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 177)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -28073,7 +29101,7 @@ var ts; } return unknownType; } - if (!isCallExpression && container.kind === 150) { + if (!isCallExpression && container.kind === 151) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if ((ts.getModifierFlags(container) & 32) || isCallExpression) { @@ -28083,7 +29111,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 149 && ts.getModifierFlags(container) & 256) { + if (container.kind === 150 && ts.getModifierFlags(container) & 256) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -28094,7 +29122,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 176) { + if (container.parent.kind === 177) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -28112,7 +29140,7 @@ var ts; } return unknownType; } - if (container.kind === 150 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 151 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -28124,24 +29152,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 150; + return container.kind === 151; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 176) { + if (ts.isClassLike(container.parent) || container.parent.kind === 177) { if (ts.getModifierFlags(container) & 32) { - return container.kind === 149 || - container.kind === 148 || - container.kind === 151 || - container.kind === 152; + return container.kind === 150 || + container.kind === 149 || + container.kind === 152 || + container.kind === 153; } else { - return container.kind === 149 || - container.kind === 148 || - container.kind === 151 || + return container.kind === 150 || + container.kind === 149 || container.kind === 152 || + container.kind === 153 || + container.kind === 148 || container.kind === 147 || - container.kind === 146 || - container.kind === 150; + container.kind === 151; } } } @@ -28149,7 +29177,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 185) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 186) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -28164,23 +29192,23 @@ var ts; var func = parameter.parent; if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { var iife = ts.getImmediatelyInvokedFunctionExpression(func); - if (iife) { + if (iife && iife.arguments) { var indexOfParameter = ts.indexOf(func.parameters, parameter); - if (iife.arguments && indexOfParameter < iife.arguments.length) { - if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return createArrayType(getUnionType(restTypes)); + if (parameter.dotDotDotToken) { + var restTypes = []; + for (var i = indexOfParameter; i < iife.arguments.length; i++) { + restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); } - var links = getNodeLinks(iife); - var cached = links.resolvedSignature; - links.resolvedSignature = anySignature; - var type = getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])); - links.resolvedSignature = cached; - return type; + return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; } + var links = getNodeLinks(iife); + var cached = links.resolvedSignature; + links.resolvedSignature = anySignature; + var type = indexOfParameter < iife.arguments.length ? + getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + parameter.initializer ? undefined : undefinedWideningType; + links.resolvedSignature = cached; + return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -28205,7 +29233,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 144) { + if (declaration.kind === 145) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -28216,11 +29244,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_19 = declaration.propertyName || declaration.name; + var name = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_19)) { - var text = ts.getTextOfPropertyName(name_19); + !ts.isBindingPattern(name)) { + var text = ts.getTextOfPropertyName(name); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -28257,7 +29285,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 144 && node.parent.initializer === node) { + if (node.parent.kind === 145 && node.parent.initializer === node) { return true; } node = node.parent; @@ -28266,8 +29294,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 150 || - functionDecl.kind === 151 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 152))) { + functionDecl.kind === 151 || + functionDecl.kind === 152 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 153))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -28286,7 +29314,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 181) { + if (template.parent.kind === 182) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -28323,8 +29351,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -28391,19 +29419,16 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxAttribute(attribute) { - var kind = attribute.kind; - var jsxElement = attribute.parent; - var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 250) { - if (!attrsType || isTypeAny(attrsType)) { + var attributesType = getContextualType(attribute.parent); + if (ts.isJsxAttribute(attribute)) { + if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfType(attrsType, attribute.name.text); + return getTypeOfPropertyOfType(attributesType, attribute.name.text); } - else if (attribute.kind === 251) { - return attrsType; + else { + return attributesType; } - ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); } function getApparentTypeOfContextualType(node) { var type = getContextualType(node); @@ -28418,42 +29443,45 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 223: - case 144: + case 225: + case 145: + case 148: case 147: - case 146: - case 174: - return getContextualTypeForInitializerExpression(node); - case 185: - case 216: - return getContextualTypeForReturnExpression(node); - case 195: - return getContextualTypeForYieldOperand(parent); - case 179: - case 180: - return getContextualTypeForArgument(parent, node); - case 182: - case 200: - return getTypeFromTypeNode(parent.type); - case 192: - return getContextualTypeForBinaryOperand(node); - case 257: - case 258: - return getContextualTypeForObjectLiteralElement(parent); case 175: - return getContextualTypeForElementExpression(node); - case 193: - return getContextualTypeForConditionalOperand(node); - case 202: - ts.Debug.assert(parent.parent.kind === 194); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 186: + case 218: + return getContextualTypeForReturnExpression(node); + case 196: + return getContextualTypeForYieldOperand(parent); + case 180: + case 181: + return getContextualTypeForArgument(parent, node); case 183: + case 201: + return getTypeFromTypeNode(parent.type); + case 193: + return getContextualTypeForBinaryOperand(node); + case 260: + case 261: + return getContextualTypeForObjectLiteralElement(parent); + case 176: + return getContextualTypeForElementExpression(node); + case 194: + return getContextualTypeForConditionalOperand(node); + case 204: + ts.Debug.assert(parent.parent.kind === 195); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 184: + return getContextualType(parent); + case 255: return getContextualType(parent); case 252: - return getContextualType(parent); - case 250: - case 251: + case 254: return getContextualTypeForJsxAttribute(parent); + case 250: + case 249: + return getAttributesTypeFromJsxOpeningLikeElement(parent); } return undefined; } @@ -28481,7 +29509,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 184 || node.kind === 185; + return node.kind === 185 || node.kind === 186; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -28494,7 +29522,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -28504,8 +29532,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -28535,8 +29563,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 174 && !!node.initializer) || - (node.kind === 192 && node.operatorToken.kind === 57); + return (node.kind === 175 && !!node.initializer) || + (node.kind === 193 && node.operatorToken.kind === 57); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -28545,7 +29573,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 196) { + if (inDestructuringPattern && e.kind === 197) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -28557,7 +29585,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 196; + hasSpreadElement = hasSpreadElement || e.kind === 197; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -28568,7 +29596,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 173 || pattern.kind === 175)) { + if (pattern && (pattern.kind === 174 || pattern.kind === 176)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -28576,7 +29604,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 198) { + if (patternElement.kind !== 199) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -28593,7 +29621,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 142 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 143 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 340); @@ -28639,7 +29667,7 @@ var ts; var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 172 || contextualType.pattern.kind === 176); + (contextualType.pattern.kind === 173 || contextualType.pattern.kind === 177); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -28648,27 +29676,27 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 257 || - memberDecl.kind === 258 || + if (memberDecl.kind === 260 || + memberDecl.kind === 261 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 257) { + if (memberDecl.kind === 260) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 149) { + else if (memberDecl.kind === 150) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 258); + ts.Debug.assert(memberDecl.kind === 261); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; - var prop = createSymbol(4 | 67108864 | member.flags, member.name); + var prop = createSymbol(4 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 257 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 258 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 260 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 261 && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 536870912; + prop.flags |= 67108864; } if (ts.hasDynamicName(memberDecl)) { patternWithComputedProperties = true; @@ -28677,7 +29705,7 @@ var ts; else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & 512)) { var impliedProp = getPropertyOfType(contextualType, member.name); if (impliedProp) { - prop.flags |= impliedProp.flags & 536870912; + prop.flags |= impliedProp.flags & 67108864; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -28692,12 +29720,12 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 259) { - if (languageVersion < 5) { + else if (memberDecl.kind === 262) { + if (languageVersion < 2) { checkExternalEmitHelpers(memberDecl, 2); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), true); + spread = getSpreadType(spread, createObjectLiteralType()); propertiesArray = []; propertiesTable = ts.createMap(); hasComputedStringProperty = false; @@ -28709,12 +29737,12 @@ var ts; error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } - spread = getSpreadType(spread, type, false); + spread = getSpreadType(spread, type); offset = i + 1; continue; } else { - ts.Debug.assert(memberDecl.kind === 151 || memberDecl.kind === 152); + ts.Debug.assert(memberDecl.kind === 152 || memberDecl.kind === 153); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -28726,25 +29754,25 @@ var ts; } } else { - propertiesTable[member.name] = member; + propertiesTable.set(member.name, member); } propertiesArray.push(member); } if (contextualTypeHasPattern) { for (var _i = 0, _a = getPropertiesOfType(contextualType); _i < _a.length; _i++) { var prop = _a[_i]; - if (!propertiesTable[prop.name]) { - if (!(prop.flags & 536870912)) { + if (!propertiesTable.get(prop.name)) { + if (!(prop.flags & 67108864)) { 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; + propertiesTable.set(prop.name, prop); propertiesArray.push(prop); } } } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), true); + spread = getSpreadType(spread, createObjectLiteralType()); } if (spread.flags & 32768) { spread.flags |= propagatedFlags; @@ -28773,7 +29801,7 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (1 | 4096 | 2048) || + return !!(type.flags & (1 | 4096 | 2048 | 16777216) || type.flags & 32768 && !isGenericMappedType(type) || type.flags & 196608 && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } @@ -28792,13 +29820,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 252: + case 255: checkJsxExpression(child); break; - case 246: + case 248: checkJsxElement(child); break; - case 247: + case 249: checkJsxSelfClosingElement(child); break; } @@ -28809,71 +29837,88 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 177 || tagName.kind === 98) { + if (tagName.kind === 178 || tagName.kind === 98) { 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 attributeType = getTypeOfPropertyOfType(elementAttributesType, ts.getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0); - if (attributeType) { - correspondingPropType = attributeType; + function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, contextualMapper) { + var attributes = openingLikeElement.attributes; + var attributesTable = ts.createMap(); + var spread = emptyObjectType; + var attributesArray = []; + for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { + var attributeDecl = _a[_i]; + var member = attributeDecl.symbol; + if (ts.isJsxAttribute(attributeDecl)) { + var exprType = attributeDecl.initializer ? + checkExpression(attributeDecl.initializer, contextualMapper) : + trueType; + var attributeSymbol = createSymbol(4 | 134217728 | member.flags, member.name); + attributeSymbol.declarations = member.declarations; + attributeSymbol.parent = member.parent; + if (member.valueDeclaration) { + attributeSymbol.valueDeclaration = member.valueDeclaration; } - else { - if (!correspondingPropType) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; - } + attributeSymbol.type = exprType; + attributeSymbol.target = member; + attributesTable.set(attributeSymbol.name, attributeSymbol); + attributesArray.push(attributeSymbol); + } + else { + ts.Debug.assert(attributeDecl.kind === 254); + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); } + var exprType = checkExpression(attributeDecl.expression); + if (!(exprType.flags & (32768 | 1))) { + error(attributeDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + return anyType; + } + if (isTypeAny(exprType)) { + return anyType; + } + spread = getSpreadType(spread, exprType); } } - var exprType; - if (node.initializer) { - exprType = checkExpression(node.initializer); + if (spread !== emptyObjectType) { + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); + } + attributesArray = getPropertiesOfType(spread); } - else { - exprType = booleanType; + attributesTable = ts.createMap(); + if (attributesArray) { + ts.forEach(attributesArray, function (attr) { + if (!filter || filter(attr)) { + attributesTable.set(attr.name, attr); + } + }); } - if (correspondingPropType) { - checkTypeAssignableTo(exprType, correspondingPropType, node); + return createJsxAttributesType(attributes.symbol, attributesTable); + function createJsxAttributesType(symbol, attributesTable) { + var result = createAnonymousType(symbol, attributesTable, emptyArray, emptyArray, undefined, undefined); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; + result.flags |= 33554432 | 4194304 | freshObjectLiteralFlag; + result.objectFlags |= 128; + return result; } - nameTable[node.name.text] = true; - return exprType; } - function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { - if (compilerOptions.jsx === 2) { - checkExternalEmitHelpers(node, 2); - } - var type = checkExpression(node.expression); - var props = getPropertiesOfType(type); - 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) { - 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 checkJsxAttributes(node, contextualMapper) { + return createJsxAttributesTypeFromAttributesProperty(node.parent, undefined, contextualMapper); } function getJsxType(name) { - if (jsxTypes[name] === undefined) { - return jsxTypes[name] = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType; + var jsxType = jsxTypes.get(name); + if (jsxType === undefined) { + jsxTypes.set(name, jsxType = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType); } - return jsxTypes[name]; + return jsxType; } function getIntrinsicTagSymbol(node) { var links = getNodeLinks(node); @@ -28938,23 +29983,84 @@ var ts; return undefined; } } - function getResolvedJsxType(node, elemType, elemClassType) { - if (!elemType) { - elemType = checkExpression(node.tagName); + function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + if (jsxElementType) { + var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, undefined); + if (callSignature !== unknownSignature) { + var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); + var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + paramType = intersectTypes(intrinsicAttributes, paramType); + } + return paramType; + } + } + } } - if (elemType.flags & 65536) { - var types = elemType.types; - return getUnionType(ts.map(types, function (type) { - return getResolvedJsxType(node, type, elemClassType); + return undefined; + } + function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + if (jsxElementType) { + var candidatesOutArray = []; + getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); + var result = void 0; + var allMatchingAttributesType = void 0; + for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { + var candidate = candidatesOutArray_1[_i]; + var callReturnType = getReturnTypeOfSignature(candidate); + var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + var shouldBeCandidate = true; + for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { + var attribute = _b[_a]; + if (ts.isJsxAttribute(attribute) && + isUnhyphenatedJsxName(attribute.name.text) && + !getPropertyOfType(paramType, attribute.name.text)) { + shouldBeCandidate = false; + break; + } + } + if (shouldBeCandidate) { + result = intersectTypes(result, paramType); + } + allMatchingAttributesType = intersectTypes(allMatchingAttributesType, paramType); + } + } + if (!result) { + result = allMatchingAttributesType; + } + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + result = intersectTypes(intrinsicAttributes, result); + } + return result; + } + } + return undefined; + } + function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { + if (!elementType) { + elementType = checkExpression(openingLikeElement.tagName); + } + if (elementType.flags & 65536) { + var types = elementType.types; + return getUnionType(types.map(function (type) { + return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); }), true); } - if (elemType.flags & 2) { + if (elementType.flags & 2) { return anyType; } - else if (elemType.flags & 32) { + else if (elementType.flags & 32) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); if (intrinsicElementsType !== unknownType) { - var stringLiteralTypeName = elemType.text; + var stringLiteralTypeName = elementType.text; var intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName); if (intrinsicProp) { return getTypeOfSymbol(intrinsicProp); @@ -28963,28 +30069,19 @@ var ts; if (indexSignatureType) { return indexSignatureType; } - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); + error(openingLikeElement, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); } return anyType; } - var elemInstanceType = getJsxElementInstanceType(node, elemType); - if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { - if (jsxElementType) { - var callSignatures = elemType && getSignaturesOfType(elemType, 0); - var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); - if (intrinsicAttributes !== unknownType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } - } + var elemInstanceType = getJsxElementInstanceType(openingLikeElement, elementType); + var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? + tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : + defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); + if (statelessAttributesType) { + return statelessAttributesType; } - if (elemClassType) { - checkTypeRelatedTo(elemInstanceType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + if (elementClassType) { + checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } if (isTypeAny(elemInstanceType)) { return elemInstanceType; @@ -29005,7 +30102,7 @@ var ts; return attributesType; } else if (attributesType.flags & 65536) { - error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); + error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); return anyType; } else { @@ -29030,30 +30127,49 @@ var ts; } } } - function getJsxElementAttributesType(node) { + function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) { + ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName)); var links = getNodeLinks(node); - if (!links.resolvedJsxType) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1) { - return links.resolvedJsxType = getTypeOfSymbol(symbol); - } - else if (links.jsxFlags & 2) { - return links.resolvedJsxType = getIndexInfoOfSymbol(symbol, 0).type; - } - else { - return links.resolvedJsxType = unknownType; - } + if (!links.resolvedJsxElementAttributesType) { + var symbol = getIntrinsicTagSymbol(node); + if (links.jsxFlags & 1) { + return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol); + } + else if (links.jsxFlags & 2) { + return links.resolvedJsxElementAttributesType = getIndexInfoOfSymbol(symbol, 0).type; } else { - var elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxType = getResolvedJsxType(node, undefined, elemClassType); + return links.resolvedJsxElementAttributesType = unknownType; } } - return links.resolvedJsxType; + return links.resolvedJsxElementAttributesType; + } + function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { + var links = getNodeLinks(node); + if (!links.resolvedJsxElementAttributesType) { + var elemClassType = getJsxGlobalElementClassType(); + return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); + } + return links.resolvedJsxElementAttributesType; + } + function getAllAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + return getCustomJsxElementAttributesType(node, true); + } + } + function getAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + return getCustomJsxElementAttributesType(node, false); + } } function getJsxAttributePropertySymbol(attrib) { - var attributesType = getJsxElementAttributesType(attrib.parent); + var attributesType = getAttributesTypeFromJsxOpeningLikeElement(attrib.parent.parent); var prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } @@ -29089,61 +30205,77 @@ var ts; markAliasSymbolAsReferenced(reactSym); } } - var targetAttributesType = getJsxElementAttributesType(node); - var nameTable = ts.createMap(); - var sawSpreadedAny = false; - for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 250) { - checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); - } - else { - ts.Debug.assert(node.attributes[i].kind === 251); - var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); - if (isTypeAny(spreadType)) { - sawSpreadedAny = true; - } - } + checkJsxAttributesAssignableToTagNameAttributes(node); + } + function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement) { + var targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? + getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : + getCustomJsxElementAttributesType(openingLikeElement, false); + var sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement, function (attribute) { + return isUnhyphenatedJsxName(attribute.name) || !!(getPropertyOfType(targetAttributesType, attribute.name)); + }); + if (targetAttributesType === emptyObjectType && (isTypeAny(sourceAttributesType) || sourceAttributesType.properties.length > 0)) { + error(openingLikeElement, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); } - if (targetAttributesType && !sawSpreadedAny) { - var targetProperties = getPropertiesOfType(targetAttributesType); - for (var i = 0; i < targetProperties.length; i++) { - if (!(targetProperties[i].flags & 536870912) && - !nameTable[targetProperties[i].name]) { - error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); - } - } + else { + checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.attributes.properties.length > 0 ? openingLikeElement.attributes : openingLikeElement); } } - function checkJsxExpression(node) { + function checkJsxExpression(node, contextualMapper) { if (node.expression) { - return checkExpression(node.expression); + var type = checkExpression(node.expression, contextualMapper); + if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { + error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); + } + return type; } else { return unknownType; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 147; + return s.valueDeclaration ? s.valueDeclaration.kind : 148; } function getDeclarationModifierFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 ? 4 | 32 : 0; + if (s.valueDeclaration) { + var flags = ts.getCombinedModifierFlags(s.valueDeclaration); + return s.parent && s.parent.flags & 32 ? flags : flags & ~28; + } + if (getCheckFlags(s) & 2) { + var checkFlags = s.checkFlags; + var accessModifier = checkFlags & 128 ? 8 : + checkFlags & 32 ? 4 : + 16; + var staticModifier = checkFlags & 256 ? 32 : 0; + return accessModifier | staticModifier; + } + if (s.flags & 16777216) { + return 4 | 32; + } + return 0; } function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; } - function checkClassPropertyAccess(node, left, type, prop) { + function checkPropertyAccessibility(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); - var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 || node.kind === 223 ? + var errorNode = node.kind === 178 || node.kind === 225 ? node.name : node.right; + if (getCheckFlags(prop) & 128) { + error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); + return false; + } if (left.kind === 96) { - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 149) { - error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - return false; + if (languageVersion < 2) { + var propKind = getDeclarationKindFromSymbol(prop); + if (propKind !== 150 && propKind !== 149) { + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } } if (flags & 128) { - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } } @@ -29153,7 +30285,7 @@ var ts; if (flags & 8) { var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } return true; @@ -29163,10 +30295,10 @@ var ts; } var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); - return hasBaseType(enclosingClass, declaringClass) ? enclosingClass : undefined; + return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; }); if (!enclosingClass) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); return false; } if (flags & 32) { @@ -29182,16 +30314,17 @@ var ts; return true; } function checkNonNullExpression(node) { - var type = checkExpression(node); - if (strictNullChecks) { - var kind = getFalsyFlags(type) & 6144; - if (kind) { - error(node, kind & 2048 ? kind & 4096 ? - ts.Diagnostics.Object_is_possibly_null_or_undefined : - ts.Diagnostics.Object_is_possibly_undefined : - ts.Diagnostics.Object_is_possibly_null); - } - return getNonNullableType(type); + return checkNonNullType(checkExpression(node), node); + } + function checkNonNullType(type, errorNode) { + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 6144; + if (kind) { + error(errorNode, kind & 2048 ? kind & 4096 ? + ts.Diagnostics.Object_is_possibly_null_or_undefined : + ts.Diagnostics.Object_is_possibly_undefined : + ts.Diagnostics.Object_is_possibly_null); + var t = getNonNullableType(type); + return t.flags & (6144 | 8192) ? unknownType : t; } return type; } @@ -29220,7 +30353,7 @@ var ts; noUnusedIdentifiers && (prop.flags & 106500) && prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8)) { - if (prop.flags & 16777216) { + if (getCheckFlags(prop) & 1) { getSymbolLinks(prop).target.isReferenced = true; } else { @@ -29228,6 +30361,15 @@ var ts; } } } + function isInPropertyInitializer(node) { + while (node) { + if (node.parent && node.parent.kind === 148 && node.parent.initializer === node) { + return true; + } + node = node.parent; + } + return false; + } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { var type = checkNonNullExpression(left); if (isTypeAny(type) || type === silentNeverType) { @@ -29239,16 +30381,23 @@ var ts; } var prop = getPropertyOfType(apparentType, right.text); if (!prop) { + var stringIndexType = getIndexTypeOfType(apparentType, 0); + if (stringIndexType) { + return stringIndexType; + } if (right.text && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, type.flags & 16384 && type.isThisType ? apparentType : type); } return unknownType; } + if (prop.valueDeclaration && + isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + } markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; - if (prop.parent && prop.parent.flags & 32) { - checkClassPropertyAccess(node, left, apparentType, prop); - } + checkPropertyAccessibility(node, left, apparentType, prop); var propType = getTypeOfSymbol(prop); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { @@ -29257,7 +30406,7 @@ var ts; return unknownType; } } - if (node.kind !== 177 || assignmentKind === 1 || + if (node.kind !== 178 || assignmentKind === 1 || !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 65536)) { return propType; @@ -29266,21 +30415,21 @@ var ts; return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 177 + var left = node.kind === 178 ? 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); + if (prop) { + return checkPropertyAccessibility(node, left, type, prop); } } return true; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 224) { + if (initializer.kind === 226) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -29302,7 +30451,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 212 && + if (node.kind === 214 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -29320,7 +30469,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 180 && node.parent.expression === node) { + if (node.parent.kind === 181 && 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); @@ -29340,7 +30489,7 @@ var ts; error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } - return getIndexedAccessType(objectType, indexType, node); + return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === unknownType) { @@ -29373,10 +30522,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 181) { + if (node.kind === 182) { checkExpression(node.template); } - else if (node.kind !== 145) { + else if (node.kind !== 146) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -29398,19 +30547,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_8 = signature.declaration && signature.declaration.parent; + var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_8 === lastParent) { + if (lastParent && parent === lastParent) { index++; } else { - lastParent = parent_8; + lastParent = parent; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_8; + lastParent = parent; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -29427,7 +30576,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 196) { + if (arg && arg.kind === 197) { return i; } } @@ -29440,11 +30589,14 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 181) { + if (ts.isJsxOpeningLikeElement(node)) { + return true; + } + if (node.kind === 182) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 194) { + if (tagExpression.template.kind === 195) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -29456,7 +30608,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 145) { + else if (node.kind === 146) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); @@ -29464,7 +30616,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 180); + ts.Debug.assert(callExpression.kind === 181); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -29472,8 +30624,10 @@ var ts; typeArguments = callExpression.typeArguments; spreadArgIndex = getSpreadArgumentIndex(args); } + var numTypeParameters = ts.length(signature.typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters); var hasRightNumberOfTypeArgs = !typeArguments || - (signature.typeParameters && typeArguments.length === signature.typeParameters.length); + (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters); if (!hasRightNumberOfTypeArgs) { return false; } @@ -29523,7 +30677,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 !== 198) { + if (arg === undefined || arg.kind !== 199) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -29548,7 +30702,7 @@ var ts; var typeParameters = signature.typeParameters; var typeArgumentsAreAssignable = true; var mapper; - for (var i = 0; i < typeParameters.length; i++) { + for (var i = 0; i < typeArgumentNodes.length; i++) { if (typeArgumentsAreAssignable) { var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { @@ -29568,9 +30722,29 @@ var ts; } return typeArgumentsAreAssignable; } + function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation) { + var callIsIncomplete = node.attributes.end === node.end; + if (callIsIncomplete) { + return true; + } + var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + var paramType = getTypeAtPosition(signature, 0); + var attributesType = checkExpressionWithContextualType(node.attributes, paramType, undefined); + var argProperties = getPropertiesOfType(attributesType); + for (var _i = 0, argProperties_1 = argProperties; _i < argProperties_1.length; _i++) { + var arg = argProperties_1[_i]; + if (!getPropertyOfType(paramType, arg.name) && isUnhyphenatedJsxName(arg.name)) { + return false; + } + } + return checkTypeRelatedTo(attributesType, paramType, relation, undefined, headMessage); + } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { + if (ts.isJsxOpeningLikeElement(node)) { + return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); + } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 180) { + if (thisType && thisType !== voidType && node.kind !== 181) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -29583,7 +30757,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 !== 198) { + if (arg === undefined || arg.kind !== 199) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -29598,51 +30772,54 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 179) { + if (node.kind === 180) { var callee = node.expression; - if (callee.kind === 177) { + if (callee.kind === 178) { return callee.expression; } - else if (callee.kind === 178) { + else if (callee.kind === 179) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 181) { + if (node.kind === 182) { var template = node.template; args = [undefined]; - if (template.kind === 194) { + if (template.kind === 195) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 145) { + else if (node.kind === 146) { return undefined; } + else if (ts.isJsxOpeningLikeElement(node)) { + args = node.attributes.properties.length > 0 ? [node.attributes] : emptyArray; + } else { args = node.arguments || emptyArray; } return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 145) { + if (node.kind === 146) { switch (node.parent.kind) { - case 226: - case 197: + case 228: + case 198: return 1; - case 147: + case 148: return 2; - case 149: - case 151: + case 150: case 152: + case 153: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 144: + case 145: return 3; } } @@ -29651,48 +30828,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 228) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 144) { + if (node.kind === 145) { node = node.parent; - if (node.kind === 150) { + if (node.kind === 151) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 147 || - node.kind === 149 || - node.kind === 151 || - node.kind === 152) { + if (node.kind === 148 || + node.kind === 150 || + node.kind === 152 || + node.kind === 153) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 228) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 144) { + if (node.kind === 145) { node = node.parent; - if (node.kind === 150) { + if (node.kind === 151) { return anyType; } } - if (node.kind === 147 || - node.kind === 149 || - node.kind === 151 || - node.kind === 152) { + if (node.kind === 148 || + node.kind === 150 || + node.kind === 152 || + node.kind === 153) { var element = node; switch (element.name.kind) { case 70: case 8: case 9: return getLiteralTypeForText(32, element.name.text); - case 142: + case 143: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512)) { return nameType; @@ -29709,20 +30886,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 228) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 144) { + if (node.kind === 145) { return numberType; } - if (node.kind === 147) { + if (node.kind === 148) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 149 || - node.kind === 151 || - node.kind === 152) { + if (node.kind === 150 || + node.kind === 152 || + node.kind === 153) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -29743,26 +30920,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex) { - if (node.kind === 145) { + if (node.kind === 146) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 181) { + else if (argIndex === 0 && node.kind === 182) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 145 || - (argIndex === 0 && node.kind === 181)) { + if (node.kind === 146 || + (argIndex === 0 && node.kind === 182)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 145) { + if (node.kind === 146) { return node.expression; } - else if (argIndex === 0 && node.kind === 181) { + else if (argIndex === 0 && node.kind === 182) { return node.template; } else { @@ -29770,10 +30947,11 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 181; - var isDecorator = node.kind === 145; + var isTaggedTemplate = node.kind === 182; + var isDecorator = node.kind === 146; + var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; - if (!isTaggedTemplate && !isDecorator) { + if (!isTaggedTemplate && !isDecorator && !isJsxOpeningOrSelfClosingElement) { typeArguments = node.typeArguments; if (node.expression.kind !== 96) { ts.forEach(typeArguments, checkSourceElement); @@ -29801,7 +30979,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 179 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 180 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -29815,6 +30993,9 @@ var ts; return result; } if (candidateForArgumentError) { + if (isJsxOpeningOrSelfClosingElement) { + return candidateForArgumentError; + } checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); } else if (candidateForTypeArgumentError) { @@ -29830,7 +31011,7 @@ var ts; if (headMessage) { diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); } - reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); + reportNoCommonSupertypeError(inferenceCandidates, node.tagName || node.expression || node.tag, diagnosticChainHead); } } else { @@ -29873,13 +31054,13 @@ var ts; if (candidate.typeParameters) { var typeArgumentTypes = void 0; if (typeArguments) { - typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNode); + typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); } else { inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); - typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; typeArgumentTypes = inferenceContext.inferredTypes; + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; } if (!typeArgumentsAreValid) { break; @@ -30070,16 +31251,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 226: - case 197: + case 228: + case 198: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 144: + case 145: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 147: + case 148: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 149: - case 151: + case 150: case 152: + case 153: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -30104,16 +31285,42 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray, headMessage); } + function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray) { + ts.Debug.assert(!(elementType.flags & 65536)); + var callSignature = resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray); + return callSignature; + } + function resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray) { + if (elementType.flags & 65536) { + var types = elementType.types; + var result = void 0; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; + result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); + } + return result; + } + var callSignatures = elementType && getSignaturesOfType(elementType, 0); + if (callSignatures && callSignatures.length > 0) { + var callSignature = void 0; + callSignature = resolveCall(openingLikeElement, callSignatures, candidatesOutArray); + return callSignature; + } + return undefined; + } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 179: - return resolveCallExpression(node, candidatesOutArray); case 180: - return resolveNewExpression(node, candidatesOutArray); + return resolveCallExpression(node, candidatesOutArray); case 181: + return resolveNewExpression(node, candidatesOutArray); + case 182: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 145: + case 146: return resolveDecorator(node, candidatesOutArray); + case 250: + case 249: + return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); } @@ -30144,12 +31351,12 @@ var ts; if (node.expression.kind === 96) { return voidType; } - if (node.kind === 180) { + if (node.kind === 181) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 150 && - declaration.kind !== 154 && - declaration.kind !== 159 && + declaration.kind !== 151 && + declaration.kind !== 155 && + declaration.kind !== 160 && !ts.isJSDocConstructSignature(declaration)) { var funcSymbol = node.expression.kind === 70 ? getResolvedSymbol(node.expression) : @@ -30180,9 +31387,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 225 + ? 227 : resolvedRequire.flags & 3 - ? 223 + ? 225 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -30208,6 +31415,23 @@ var ts; function checkNonNullAssertion(node) { return getNonNullableType(checkExpression(node.expression)); } + function checkMetaProperty(node) { + checkGrammarMetaProperty(node); + ts.Debug.assert(node.keywordToken === 93 && node.name.text === "target", "Unrecognized meta-property."); + var container = ts.getNewTargetContainer(node); + if (!container) { + error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); + return unknownType; + } + else if (container.kind === 151) { + var symbol = getSymbolOfNode(container.parent); + return getTypeOfSymbol(symbol); + } + else { + var symbol = getSymbolOfNode(container); + return getTypeOfSymbol(symbol); + } + } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks) { @@ -30237,7 +31461,7 @@ var ts; var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { if (!parameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + signature.thisParameter = createSymbolWithType(context.thisParameter, undefined); } assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } @@ -30275,8 +31499,8 @@ var ts; if (!links.type) { links.type = instantiateType(contextualType, mapper); if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 172 || - parameter.valueDeclaration.name.kind === 173)) { + (parameter.valueDeclaration.name.kind === 173 || + parameter.valueDeclaration.name.kind === 174)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -30306,6 +31530,9 @@ var ts; error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } + else if (!getGlobalPromiseConstructorSymbol()) { + error(func, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } return promiseType; } function getReturnTypeFromBody(func, contextualMapper) { @@ -30315,7 +31542,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 204) { + if (func.body.kind !== 206) { 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); @@ -30394,7 +31621,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 218 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 220 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -30423,7 +31650,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 184 || func.kind === 185)) { + func.kind === 185 || func.kind === 186)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -30440,7 +31667,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 204 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 206 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -30467,9 +31694,9 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 184) { + if (!hasGrammarError && node.kind === 185) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -30503,14 +31730,15 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 149) { + if (produceDiagnostics && node.kind !== 150) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -30520,7 +31748,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 204) { + if (node.body.kind === 206) { checkSourceElement(node.body); } else { @@ -30546,19 +31774,19 @@ var ts; return true; } function isReadonlySymbol(symbol) { - return symbol.isReadonly || - symbol.flags & 4 && (getDeclarationModifierFlagsFromSymbol(symbol) & 64) !== 0 || - symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 || + return !!(getCheckFlags(symbol) & 4 || + symbol.flags & 4 && getDeclarationModifierFlagsFromSymbol(symbol) & 64 || + symbol.flags & 3 && getDeclarationNodeFlagsFromSymbol(symbol) & 2 || symbol.flags & 98304 && !(symbol.flags & 65536) || - (symbol.flags & 8) !== 0; + symbol.flags & 8); } function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 177 || expr.kind === 178) && + (expr.kind === 178 || expr.kind === 179) && expr.expression.kind === 98) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 150)) + if (!(func && func.kind === 151)) return true; return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); } @@ -30567,13 +31795,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 177 || expr.kind === 178) { + if (expr.kind === 178 || expr.kind === 179) { var node = ts.skipParentheses(expr.expression); if (node.kind === 70) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 237; + return declaration && declaration.kind === 239; } } } @@ -30581,7 +31809,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage) { var node = ts.skipParentheses(expr); - if (node.kind !== 70 && node.kind !== 177 && node.kind !== 178) { + if (node.kind !== 70 && node.kind !== 178 && node.kind !== 179) { error(expr, invalidReferenceMessage); return false; } @@ -30589,11 +31817,21 @@ var ts; } function checkDeleteExpression(node) { checkExpression(node.expression); + var expr = ts.skipParentheses(node.expression); + if (expr.kind !== 178 && expr.kind !== 179) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); + return booleanType; + } + var links = getNodeLinks(expr); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol && isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } return booleanType; } function checkTypeOfExpression(node) { checkExpression(node.expression); - return stringType; + return typeofType; } function checkVoidExpression(node) { checkExpression(node.expression); @@ -30623,6 +31861,7 @@ var ts; case 36: case 37: case 51: + checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 512)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } @@ -30634,7 +31873,7 @@ var ts; booleanType; case 42: case 43: - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); } @@ -30647,7 +31886,7 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); } @@ -30659,8 +31898,8 @@ var ts; } if (type.flags & 196608) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -30674,8 +31913,8 @@ var ts; } if (type.flags & 65536) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var t = types_19[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -30684,8 +31923,8 @@ var ts; } if (type.flags & 131072) { var types = type.types; - for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { - var t = types_17[_a]; + for (var _a = 0, types_20 = types; _a < types_20.length; _a++) { + var t = types_20[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -30706,7 +31945,10 @@ var ts; if (isTypeOfKind(leftType, 8190)) { 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))) { + if (!(isTypeAny(rightType) || + getSignaturesOfType(rightType, 0).length || + getSignaturesOfType(rightType, 1).length || + 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; @@ -30715,6 +31957,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 340 | 512))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } @@ -30732,22 +31976,22 @@ var ts; return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 257 || property.kind === 258) { - var name_20 = property.name; - if (name_20.kind === 142) { - checkComputedPropertyName(name_20); + if (property.kind === 260 || property.kind === 261) { + var name = property.name; + if (name.kind === 143) { + checkComputedPropertyName(name); } - if (isComputedNonLiteralName(name_20)) { + if (isComputedNonLiteralName(name)) { return undefined; } - var text = ts.getTextOfPropertyName(name_20); + var text = ts.getTextOfPropertyName(name); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 258) { + if (property.kind === 261) { return checkDestructuringAssignment(property, type); } else { @@ -30755,10 +31999,10 @@ var ts; } } else { - error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 259) { + else if (property.kind === 262) { if (languageVersion < 5) { checkExternalEmitHelpers(property, 4); } @@ -30786,8 +32030,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 198) { - if (element.kind !== 196) { + if (element.kind !== 199) { + if (element.kind !== 197) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -30813,7 +32057,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 192 && restExpression.operatorToken.kind === 57) { + if (restExpression.kind === 193 && restExpression.operatorToken.kind === 57) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -30826,7 +32070,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 258) { + if (exprOrAssignment.kind === 261) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -30840,21 +32084,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 192 && target.operatorToken.kind === 57) { + if (target.kind === 193 && target.operatorToken.kind === 57) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 176) { + if (target.kind === 177) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 175) { + if (target.kind === 176) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 259 ? + var error = target.parent.kind === 262 ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -30868,35 +32112,35 @@ var ts; case 70: case 9: case 11: - case 181: - case 194: + case 182: + case 195: case 12: case 8: case 100: case 85: case 94: - case 137: - case 184: - case 197: + case 138: case 185: - case 175: + case 198: + case 186: case 176: - case 187: - case 201: - case 247: - case 246: + case 177: + case 188: + case 202: + case 249: + case 248: return true; - case 193: + case 194: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 192: + case 193: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 190: case 191: + case 192: switch (node.operator) { case 50: case 36: @@ -30905,9 +32149,9 @@ var ts; return true; } return false; - case 188: - case 182: - case 200: + case 189: + case 183: + case 201: default: return false; } @@ -30927,7 +32171,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 57 && (left.kind === 176 || left.kind === 175)) { + if (operator === 57 && (left.kind === 177 || left.kind === 176)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -30958,12 +32202,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (leftType.flags & 6144) - leftType = rightType; - if (rightType.flags & 6144) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); var suggestedOperator = void 0; if ((leftType.flags & 136) && (rightType.flags & 136) && @@ -30983,12 +32223,10 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (leftType.flags & 6144) - leftType = rightType; - if (rightType.flags & 6144) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + if (!isTypeOfKind(leftType, 1 | 262178) && !isTypeOfKind(rightType, 1 | 262178)) { + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); + } var resultType = void 0; if (isTypeOfKind(leftType, 340) && isTypeOfKind(rightType, 340)) { resultType = numberType; @@ -31017,8 +32255,8 @@ var ts; case 29: case 30: if (checkForDisallowedESSymbolOperand(operator)) { - leftType = getBaseTypeOfLiteralType(leftType); - rightType = getBaseTypeOfLiteralType(rightType); + leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); + rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } @@ -31187,7 +32425,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 182 || node.kind === 200; + return node.kind === 183 || node.kind === 201; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -31198,11 +32436,11 @@ var ts; function isLiteralContextualType(contextualType) { if (contextualType) { if (contextualType.flags & 540672) { - var apparentType = getApparentTypeOfTypeVariable(contextualType); - if (apparentType.flags & (2 | 4 | 8 | 16)) { + var constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; + if (constraint.flags & (2 | 4 | 8 | 16)) { return true; } - contextualType = apparentType; + contextualType = constraint; } return maybeTypeOfKind(contextualType, (480 | 262144)); } @@ -31213,14 +32451,14 @@ var ts; return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -31242,7 +32480,7 @@ var ts; return type; } function getTypeOfExpression(node) { - if (node.kind === 179 && node.expression.kind !== 96) { + if (node.kind === 180 && node.expression.kind !== 96) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -31253,7 +32491,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 141) { + if (node.kind === 142) { type = checkQualifiedName(node); } else { @@ -31261,9 +32499,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 177 && node.parent.expression === node) || - (node.parent.kind === 178 && node.parent.expression === node) || - ((node.kind === 70 || node.kind === 141) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 178 && node.parent.expression === node) || + (node.parent.kind === 179 && node.parent.expression === node) || + ((node.kind === 70 || node.kind === 142) && 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); } @@ -31285,66 +32523,70 @@ var ts; case 100: case 85: return checkLiteralExpression(node); - case 194: + case 195: return checkTemplateExpression(node); case 12: return stringType; case 11: return globalRegExpType; - case 175: - return checkArrayLiteral(node, contextualMapper); case 176: - return checkObjectLiteral(node, contextualMapper); + return checkArrayLiteral(node, contextualMapper); case 177: - return checkPropertyAccessExpression(node); + return checkObjectLiteral(node, contextualMapper); case 178: - return checkIndexedAccess(node); + return checkPropertyAccessExpression(node); case 179: + return checkIndexedAccess(node); case 180: - return checkCallExpression(node); case 181: - return checkTaggedTemplateExpression(node); - case 183: - return checkExpression(node.expression, contextualMapper); - case 197: - return checkClassExpression(node); - case 184: - case 185: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 187: - return checkTypeOfExpression(node); + return checkCallExpression(node); case 182: - case 200: - return checkAssertion(node); - case 201: - return checkNonNullAssertion(node); - case 186: - return checkDeleteExpression(node); - case 188: - return checkVoidExpression(node); - case 189: - return checkAwaitExpression(node); - case 190: - return checkPrefixUnaryExpression(node); - case 191: - return checkPostfixUnaryExpression(node); - case 192: - return checkBinaryExpression(node, contextualMapper); - case 193: - return checkConditionalExpression(node, contextualMapper); - case 196: - return checkSpreadExpression(node, contextualMapper); + return checkTaggedTemplateExpression(node); + case 184: + return checkExpression(node.expression, contextualMapper); case 198: + return checkClassExpression(node); + case 185: + case 186: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 188: + return checkTypeOfExpression(node); + case 183: + case 201: + return checkAssertion(node); + case 202: + return checkNonNullAssertion(node); + case 203: + return checkMetaProperty(node); + case 187: + return checkDeleteExpression(node); + case 189: + return checkVoidExpression(node); + case 190: + return checkAwaitExpression(node); + case 191: + return checkPrefixUnaryExpression(node); + case 192: + return checkPostfixUnaryExpression(node); + case 193: + return checkBinaryExpression(node, contextualMapper); + case 194: + return checkConditionalExpression(node, contextualMapper); + case 197: + return checkSpreadExpression(node, contextualMapper); + case 199: return undefinedWideningType; - case 195: + case 196: return checkYieldExpression(node); - case 252: - return checkJsxExpression(node); - case 246: - return checkJsxElement(node); - case 247: - return checkJsxSelfClosingElement(node); + case 255: + return checkJsxExpression(node, contextualMapper); case 248: + return checkJsxElement(node); + case 249: + return checkJsxSelfClosingElement(node); + case 253: + return checkJsxAttributes(node, contextualMapper); + case 250: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -31354,7 +32596,16 @@ var ts; grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); } checkSourceElement(node.constraint); - getConstraintOfTypeParameter(getDeclaredTypeOfTypeParameter(getSymbolOfNode(node))); + checkSourceElement(node.default); + var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); + if (!hasNonCircularBaseConstraint(typeParameter)) { + error(node.constraint, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); + } + var constraintType = getConstraintOfTypeParameter(typeParameter); + var defaultType = getDefaultFromTypeParameter(typeParameter); + if (constraintType && defaultType) { + checkTypeAssignableTo(defaultType, getTypeWithThisArgument(constraintType, defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } @@ -31365,7 +32616,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92) { func = ts.getContainingFunction(node); - if (!(func.kind === 150 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 151 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -31376,7 +32627,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 150 || func.kind === 154 || func.kind === 159) { + if (func.kind === 151 || func.kind === 155 || func.kind === 160) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -31388,9 +32639,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 149 || - node.kind === 225 || - node.kind === 184; + return node.kind === 150 || + node.kind === 227 || + node.kind === 185; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -31431,9 +32682,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_21 = _a[_i].name; - if (ts.isBindingPattern(name_21) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_21, parameterName, typePredicate.parameterName)) { + var name = _a[_i].name; + if (ts.isBindingPattern(name) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -31446,16 +32697,16 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 186: + case 154: + case 227: case 185: - case 153: - case 225: - case 184: - case 158: + case 159: + case 150: case 149: - case 148: - var parent_9 = node.parent; - if (node === parent_9.type) { - return parent_9; + var parent = node.parent; + if (node === parent.type) { + return parent; } } } @@ -31465,27 +32716,27 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_22 = element.name; - if (name_22.kind === 70 && - name_22.text === predicateVariableName) { + var name = element.name; + if (name.kind === 70 && + name.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_22.kind === 173 || - name_22.kind === 172) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, predicateVariableNode, predicateVariableName)) { + else if (name.kind === 174 || + name.kind === 173) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } } } } function checkSignatureDeclaration(node) { - if (node.kind === 155) { + if (node.kind === 156) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 || node.kind === 225 || node.kind === 159 || - node.kind === 153 || node.kind === 150 || - node.kind === 154) { + else if (node.kind === 159 || node.kind === 227 || node.kind === 160 || + node.kind === 154 || node.kind === 151 || + node.kind === 155) { checkGrammarFunctionLikeDeclaration(node); } if (ts.isAsyncFunctionLike(node) && languageVersion < 4) { @@ -31503,10 +32754,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 154: + case 155: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 153: + case 154: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -31537,7 +32788,7 @@ var ts; var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150) { + if (member.kind === 151) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -31546,36 +32797,65 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114; }); + var isStatic = ts.getModifierFlags(member) & 32; var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 151: + case 152: addName(names, member.name, memberName, 1); break; - case 152: + case 153: addName(names, member.name, memberName, 2); break; - case 147: + case 148: addName(names, member.name, memberName, 3); break; + case 150: + addName(names, member.name, memberName, 4); + break; } } } } function addName(names, location, name, meaning) { - var prev = names[name]; + var prev = names.get(name); if (prev) { - if (prev & meaning) { + if (prev & 4) { + if (meaning !== 4) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + } + else if (prev & meaning) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { - names[name] = prev | meaning; + names.set(name, prev | meaning); } } else { - names[name] = meaning; + names.set(name, meaning); + } + } + } + function checkClassForStaticPropertyNameConflicts(node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + var memberNameNode = member.name; + var isStatic = ts.getModifierFlags(member) & 32; + if (isStatic && memberNameNode) { + var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode); + switch (memberName) { + case "name": + case "length": + case "caller": + case "arguments": + case "prototype": + var message = ts.Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1; + var className = getNameOfSymbol(getSymbolOfNode(node)); + error(memberNameNode, message, memberName, className); + break; + } } } } @@ -31583,7 +32863,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 146) { + if (member.kind == 147) { var memberName = void 0; switch (member.name.kind) { case 9: @@ -31594,18 +32874,18 @@ var ts; default: continue; } - if (names[memberName]) { + if (names.get(memberName)) { error(member.symbol.valueDeclaration.name, ts.Diagnostics.Duplicate_identifier_0, memberName); error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName); } else { - names[memberName] = true; + names.set(memberName, true); } } } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 227) { + if (node.kind === 229) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -31620,7 +32900,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 134: + case 135: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -31687,12 +32967,12 @@ var ts; if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 && n.kind !== 225) { + else if (n.kind !== 185 && n.kind !== 227) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 147 && + return n.kind === 148 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -31712,7 +32992,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -31735,18 +33015,18 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 151) { + if (node.kind === 152) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 151 ? 152 : 151; + var otherKind = node.kind === 152 ? 153 : 152; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { @@ -31760,11 +33040,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 151) { + if (node.kind === 152) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 176) { + if (node.parent.kind !== 177) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -31787,6 +33067,7 @@ var ts; checkDecorators(node); } function checkTypeArgumentConstraints(typeParameters, typeArgumentNodes) { + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); var typeArguments; var mapper; var result = true; @@ -31794,7 +33075,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -31845,25 +33126,42 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessIndexType(type, accessNode) { + if (!(type.flags & 524288)) { + return type; + } + var objectType = type.objectType; + var indexType = type.indexType; + if (isTypeAssignableTo(indexType, getIndexType(objectType))) { + return type; + } + if (maybeTypeOfKind(objectType, 540672) && isTypeOfKind(indexType, 340)) { + var constraint = getBaseConstraintOfType(objectType); + if (constraint && getIndexInfoOfType(constraint, 1)) { + return type; + } + } + error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); + return type; + } function checkIndexedAccessType(node) { - getTypeFromIndexedAccessTypeNode(node); + checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node) { checkSourceElement(node.typeParameter); checkSourceElement(node.type); var type = getTypeFromMappedTypeNode(node); var constraintType = getConstraintTypeFromMappedType(type); - var keyType = constraintType.flags & 540672 ? getApparentTypeOfTypeVariable(constraintType) : constraintType; - checkTypeAssignableTo(keyType, stringType, node.typeParameter.constraint); + checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node) { return (ts.getModifierFlags(node) & 8) && ts.isInAmbientContext(node); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 227 && - n.parent.kind !== 226 && - n.parent.kind !== 197 && + if (n.parent.kind !== 229 && + n.parent.kind !== 228 && + n.parent.kind !== 198 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -31940,7 +33238,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 149 || node.kind === 148) && + var reportError = (node.kind === 150 || node.kind === 149) && (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); if (reportError) { var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -31969,15 +33267,15 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var current = declarations_4[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var current = declarations_5[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 227 || node.parent.kind === 161 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 229 || node.parent.kind === 162 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 225 || node.kind === 149 || node.kind === 148 || node.kind === 150) { + if (node.kind === 227 || node.kind === 150 || node.kind === 149 || node.kind === 151) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -32088,16 +33386,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 227: + case 229: return 2097152; - case 230: + case 232: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 226: - case 229: + case 228: + case 231: return 2097152 | 1048576; - case 234: + case 236: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -32109,7 +33407,8 @@ var ts; } function checkNonThenableType(type, location, message) { type = getWidenedType(type); - if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + var apparentType = getApparentType(type); + if ((apparentType.flags & (1 | 8192)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -32214,7 +33513,12 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455, true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; if (promiseConstructorType === unknownType) { - error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + if (promiseConstructorName.kind === 70 && promiseConstructorName.text === "Promise" && getTargetType(returnType) === tryGetGlobalPromiseType()) { + error(node.type, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } + else { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + } return unknownType; } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); @@ -32244,22 +33548,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 226: + case 228: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 144: + case 145: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 147: + case 148: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 149: - case 151: + case 150: case 152: + case 153: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -32293,13 +33597,13 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8); - if (node.kind === 144) { + if (node.kind === 145) { checkExternalEmitHelpers(firstDecorator, 32); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 226: + case 228: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -32308,19 +33612,19 @@ var ts; } } break; - case 149: - case 151: + case 150: case 152: + case 153: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markTypeNodeAsReferenced(node.type); break; - case 147: + case 148: markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); break; - case 144: + case 145: markTypeNodeAsReferenced(node.type); break; } @@ -32332,6 +33636,7 @@ var ts; checkFunctionOrMethodDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -32340,7 +33645,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 142) { + if (node.name && node.name.kind === 143) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -32382,43 +33687,43 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 261: - case 230: + case 264: + case 232: checkUnusedModuleMembers(node); break; - case 226: - case 197: + case 228: + case 198: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 227: + case 229: checkUnusedTypeParameters(node); break; - case 204: - case 232: - case 211: - case 212: + case 206: + case 234: case 213: + case 214: + case 215: checkUnusedLocalsAndParameters(node); break; - case 150: - case 184: - case 225: - case 185: - case 149: case 151: + case 185: + case 227: + case 186: + case 150: case 152: + case 153: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 148: - case 153: + case 149: case 154: case 155: - case 158: + case 156: case 159: + case 160: checkUnusedTypeParameters(node); break; } @@ -32427,11 +33732,10 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 227 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_2 = function (key) { - var local = node.locals[key]; + if (node.parent.kind !== 229 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + node.locals.forEach(function (local) { if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 145) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -32444,10 +33748,7 @@ var ts; ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d.name || d, local.name); }); } } - }; - for (var key in node.locals) { - _loop_2(key); - } + }); } } function isRemovedPropertyFromObjectSpread(node) { @@ -32460,9 +33761,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 223 && - (declaration.parent.parent.kind === 212 || - declaration.parent.parent.kind === 213)) { + if (declaration.kind === 225 && + (declaration.parent.parent.kind === 214 || + declaration.parent.parent.kind === 215)) { return; } } @@ -32481,12 +33782,12 @@ var ts; if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149 || member.kind === 147) { + if (member.kind === 150 || member.kind === 148) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 150) { + else if (member.kind === 151) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { @@ -32517,21 +33818,20 @@ var ts; } function checkUnusedModuleMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { - for (var key in node.locals) { - var local = node.locals[key]; + node.locals.forEach(function (local) { if (!local.isReferenced && !local.exportSymbol) { for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - error(declaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + errorUnusedLocal(declaration.name, local.name); } } } - } + }); } } function checkBlock(node) { - if (node.kind === 204) { + if (node.kind === 206) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -32553,19 +33853,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 147 || - node.kind === 146 || + if (node.kind === 148 || + node.kind === 147 || + node.kind === 150 || node.kind === 149 || - node.kind === 148 || - node.kind === 151 || - node.kind === 152) { + node.kind === 152 || + node.kind === 153) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 144 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 145 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -32575,6 +33875,11 @@ var ts; potentialThisCollisions.push(node); } } + function checkCollisionWithCapturedNewTargetVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_newTarget")) { + potentialNewTargetCollisions.push(node); + } + } function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; while (current) { @@ -32591,6 +33896,22 @@ var ts; current = current.parent; } } + function checkIfNewTargetIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 8) { + var isDeclaration_2 = node.kind !== 70; + if (isDeclaration_2) { + error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); + } + return; + } + current = current.parent; + } + } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; @@ -32600,8 +33921,8 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 70; - if (isDeclaration_2) { + var isDeclaration_3 = node.kind !== 70; + if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } else { @@ -32616,11 +33937,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 232 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 264 && 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)); } } @@ -32628,11 +33949,11 @@ var ts; if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 232 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 264 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -32640,7 +33961,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 223 && !node.initializer) { + if (node.kind === 225 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -32650,25 +33971,25 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 224); - var container = varDeclList.parent.kind === 205 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 226); + var container = varDeclList.parent.kind === 207 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 204 && ts.isFunctionLike(container.parent) || - container.kind === 231 || - container.kind === 230 || - container.kind === 261); + (container.kind === 206 && ts.isFunctionLike(container.parent) || + container.kind === 233 || + container.kind === 232 || + container.kind === 264); if (!namesShareScope) { - var name_23 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_23, name_23); + var name = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 144) { + if (ts.getRootDeclaration(node).kind !== 145) { return; } var func = ts.getContainingFunction(node); @@ -32677,7 +33998,7 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 177) { + if (n.kind === 178) { return visit(n.expression); } else if (n.kind === 70) { @@ -32691,7 +34012,8 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144) { + if (symbol.valueDeclaration.kind === 145 || + symbol.valueDeclaration.kind === 175) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -32700,7 +34022,7 @@ var ts; if (ts.isFunctionLike(current.parent)) { return; } - if (current.parent.kind === 147 && + if (current.parent.kind === 148 && !(ts.hasModifier(current.parent, 32)) && ts.isClassLike(current.parent.parent)) { return; @@ -32722,37 +34044,37 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 174) { - if (node.parent.kind === 172 && languageVersion < 5) { + if (node.kind === 175) { + if (node.parent.kind === 173 && languageVersion < 5 && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4); } - if (node.propertyName && node.propertyName.kind === 142) { + if (node.propertyName && node.propertyName.kind === 143) { checkComputedPropertyName(node.propertyName); } - var parent_10 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_10); - var name_24 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_24)); + var parent = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent); + var name = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); markPropertyAsReferenced(property); - if (parent_10.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_10, parent_10.initializer, parentType, property); + if (parent.initializer && property) { + checkPropertyAccessibility(parent, parent.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 144 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 145 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 212) { + if (node.initializer && node.parent.parent.kind !== 214) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -32761,7 +34083,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 212) { + if (node.initializer && node.parent.parent.kind !== 214) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -32779,20 +34101,21 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 147 && node.kind !== 146) { + if (node.kind !== 148 && node.kind !== 147) { checkExportsOnMergedDeclarations(node); - if (node.kind === 223 || node.kind === 174) { + if (node.kind === 225 || node.kind === 175) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 && right.kind === 223) || - (left.kind === 223 && right.kind === 144)) { + if ((left.kind === 145 && right.kind === 225) || + (left.kind === 225 && right.kind === 145)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -32819,7 +34142,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 176) { + if (node.modifiers && node.parent.kind === 177) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -32838,7 +34161,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 206) { + if (node.thenStatement.kind === 208) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -32855,12 +34178,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 224) { + if (node.initializer && node.initializer.kind === 226) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 224) { + if (node.initializer.kind === 226) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -32878,13 +34201,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 224) { + if (node.initializer.kind === 226) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 175 || varExpr.kind === 176) { + if (varExpr.kind === 176 || varExpr.kind === 177) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -32903,7 +34226,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 224) { + if (node.initializer.kind === 226) { 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); @@ -32913,7 +34236,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 175 || varExpr.kind === 176) { + if (varExpr.kind === 176 || varExpr.kind === 177) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -33089,7 +34412,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 151 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 152))); + return !!(node.kind === 152 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 153))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -33111,30 +34434,30 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 152) { + if (func.kind === 153) { if (node.expression) { - error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); + error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 150) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { - error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); + else if (func.kind === 151) { + if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node.expression || node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); if (promisedType) { - checkTypeAssignableTo(awaitedType, promisedType, node.expression || node); + checkTypeAssignableTo(awaitedType, promisedType, node); } } else { - checkTypeAssignableTo(exprType, returnType, node.expression || node); + checkTypeAssignableTo(exprType, returnType, node); } } } - else if (func.kind !== 150 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 151 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -33160,7 +34483,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 254 && !hasDuplicateDefaultClause) { + if (clause.kind === 257 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -33172,7 +34495,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 253) { + if (produceDiagnostics && clause.kind === 256) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); var caseIsLiteral = isLiteralType(caseType); @@ -33198,7 +34521,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 219 && current.label.text === node.label.text) { + if (current.kind === 221 && 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; @@ -33231,14 +34554,14 @@ var ts; grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { - var blockLocals = catchClause.block.locals; - if (blockLocals) { - for (var caughtName in catchClause.locals) { - var blockLocal = blockLocals[caughtName]; + var blockLocals_1 = catchClause.block.locals; + if (blockLocals_1) { + ts.forEachKey(catchClause.locals, function (caughtName) { + var blockLocal = blockLocals_1.get(caughtName); if (blockLocal && (blockLocal.flags & 2) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } - } + }); } } } @@ -33286,12 +34609,13 @@ var ts; if (!indexType) { return; } - if (indexKind === 1 && !isNumericName(prop.valueDeclaration.name)) { + var propDeclaration = prop.valueDeclaration; + if (indexKind === 1 && !(propDeclaration ? isNumericName(propDeclaration.name) : isNumericLiteralName(prop.name))) { return; } var errorNode; - if (prop.valueDeclaration.name.kind === 142 || prop.parent === containingType.symbol) { - errorNode = prop.valueDeclaration; + if (propDeclaration && (propDeclaration.name.kind === 143 || prop.parent === containingType.symbol)) { + errorNode = propDeclaration; } else if (indexDeclaration) { errorNode = indexDeclaration; @@ -33316,15 +34640,23 @@ var ts; case "string": case "symbol": case "void": + case "object": error(name, message, name.text); } } function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + var seenDefault = false; + for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { + if (node.default) { + seenDefault = true; + } + else if (seenDefault) { + error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters); + } 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)); @@ -33334,23 +34666,57 @@ var ts; } } } - function checkTypeParameterListsIdentical(node, symbol) { + function checkTypeParameterListsIdentical(symbol) { if (symbol.declarations.length === 1) { return; } - var firstDecl; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 226 || declaration.kind === 227) { - if (!firstDecl) { - firstDecl = declaration; - } - else if (!areTypeParametersIdentical(firstDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); + var links = getSymbolLinks(symbol); + if (!links.typeParametersChecked) { + links.typeParametersChecked = true; + var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); + if (declarations.length <= 1) { + return; + } + var type = getDeclaredTypeOfSymbol(symbol); + if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { + var name = symbolToString(symbol); + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; + error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } } } + function areTypeParametersIdentical(declarations, typeParameters) { + var maxTypeArgumentCount = ts.length(typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; + var numTypeParameters = ts.length(declaration.typeParameters); + if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { + return false; + } + for (var i = 0; i < numTypeParameters; i++) { + var source = declaration.typeParameters[i]; + var target = typeParameters[i]; + if (source.name.text !== target.symbol.name) { + return false; + } + var sourceConstraint = source.constraint && getTypeFromTypeNode(source.constraint); + var targetConstraint = getConstraintFromTypeParameter(target); + if ((sourceConstraint || targetConstraint) && + (!sourceConstraint || !targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint))) { + return false; + } + var sourceDefault = source.default && getTypeFromTypeNode(source.default); + var targetDefault = getDefaultFromTypeParameter(target); + if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) { + return false; + } + } + } + return true; + } function checkClassExpression(node) { checkClassLikeDeclaration(node); checkNodeDeferred(node); @@ -33374,6 +34740,7 @@ var ts; if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -33383,8 +34750,11 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); - checkTypeParameterListsIdentical(node, symbol); + checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); + if (!ts.isInAmbientContext(node)) { + checkClassForStaticPropertyNameConflicts(node); + } var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { if (languageVersion < 2 && !ts.isInAmbientContext(node)) { @@ -33393,7 +34763,8 @@ var ts; var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType_1 = baseTypes[0]; - var staticBaseType = getBaseConstructorTypeOfClass(type); + var baseConstructorType = getBaseConstructorTypeOfClass(type); + var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { @@ -33407,14 +34778,17 @@ var ts; } checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType_1, 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 (baseType_1.symbol.valueDeclaration && + if (baseConstructorType.flags & 540672 && !isMixinConstructorType(staticType)) { + error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); + } + if (baseType_1.symbol && baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 226) { + baseType_1.symbol.valueDeclaration.kind === 228) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 540672)) { var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType_1; })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); @@ -33434,8 +34808,7 @@ var ts; if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - var declaredType = getObjectFlags(t) & 4 ? t.target : t; - if (getObjectFlags(declaredType) & 3) { + if (isValidBaseType(t)) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { @@ -33463,17 +34836,22 @@ var ts; } } function getTargetSymbol(s) { - return s.flags & 16777216 ? getSymbolLinks(s).target : s; + return getCheckFlags(s) & 1 ? s.target : s; } function getClassLikeDeclarationOfSymbol(symbol) { return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); } + function getClassOrInterfaceDeclarationsOfSymbol(symbol) { + return ts.filter(symbol.declarations, function (d) { + return d.kind === 228 || d.kind === 229; + }); + } function checkKindsOfPropertyMemberOverrides(type, baseType) { - var baseProperties = getPropertiesOfObjectType(baseType); + var baseProperties = getPropertiesOfType(baseType); 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) { + if (base.flags & 16777216) { continue; } var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); @@ -33483,7 +34861,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { - if (derivedClassDecl.kind === 197) { + if (derivedClassDecl.kind === 198) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -33527,32 +34905,7 @@ var ts; } } function isAccessor(kind) { - return kind === 151 || kind === 152; - } - 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; + return kind === 152 || kind === 153; } function checkInheritedPropertiesAreIdentical(type, typeNode) { var baseTypes = getBaseTypes(type); @@ -33560,16 +34913,16 @@ var ts; return true; } var seen = ts.createMap(); - ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.name, { prop: p, containingType: type }); }); var ok = true; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; - var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); + var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { var prop = properties_7[_a]; - var existing = seen[prop.name]; + var existing = seen.get(prop.name); if (!existing) { - seen[prop.name] = { prop: prop, containingType: base }; + seen.set(prop.name, { prop: prop, containingType: base }); } else { var isInheritedProperty = existing.containingType !== type; @@ -33593,8 +34946,8 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 227); + checkTypeParameterListsIdentical(symbol); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 229); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -33690,7 +35043,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 190: + case 191: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -33701,7 +35054,7 @@ var ts; case 51: return ~value_1; } return undefined; - case 192: + case 193: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -33725,12 +35078,13 @@ var ts; } return undefined; case 8: + checkGrammarNumericLiteral(e); return +e.text; - case 183: + case 184: return evalConstant(e.expression); case 70: + case 179: case 178: - case 177: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -33741,7 +35095,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 178) { + if (e.kind === 179) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -33758,7 +35112,7 @@ var ts; if (current.kind === 70) { break; } - else if (current.kind === 177) { + else if (current.kind === 178) { current = current.expression; } else { @@ -33798,6 +35152,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); @@ -33818,7 +35173,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 229) { + if (declaration.kind !== 231) { return false; } var enumDeclaration = declaration; @@ -33839,10 +35194,10 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var declaration = declarations_5[_i]; - if ((declaration.kind === 226 || - (declaration.kind === 225 && ts.nodeIsPresent(declaration.body))) && + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 228 || + (declaration.kind === 227 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -33901,7 +35256,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, 226); + var mergedClass = ts.getDeclarationOfKind(symbol, 228); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -33909,7 +35264,7 @@ var ts; } if (isAmbientExternalModule) { if (ts.isExternalModuleAugmentation(node)) { - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 134217728); if (checkBody && node.body) { for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { var statement = _a[_i]; @@ -33944,42 +35299,42 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 205: + case 207: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 240: - case 241: + case 242: + case 243: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 234: - case 235: + case 236: + case 237: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 174: - case 223: - var name_25 = node.name; - if (ts.isBindingPattern(name_25)) { - for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { + case 175: + case 225: + var name = node.name; + if (ts.isBindingPattern(name)) { + for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } - case 226: - case 229: - case 225: - case 227: - case 230: case 228: + case 231: + case 227: + case 229: + case 232: + case 230: if (isGlobalAugmentation) { return; } var symbol = getSymbolOfNode(node); if (symbol) { - var reportError = !(symbol.flags & 33554432); + var reportError = !(symbol.flags & 134217728); if (!reportError) { reportError = ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } @@ -33991,12 +35346,12 @@ var ts; switch (node.kind) { case 70: return node; - case 141: + case 142: do { node = node.left; } while (node.kind !== 70); return node; - case 177: + case 178: do { node = node.expression; } while (node.kind !== 70); @@ -34009,9 +35364,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 231 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 && !inAmbientExternalModule) { - error(moduleName, node.kind === 241 ? + var inAmbientExternalModule = node.parent.kind === 233 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 264 && !inAmbientExternalModule) { + error(moduleName, node.kind === 243 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -34032,7 +35387,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 243 ? + var message = node.kind === 245 ? 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)); @@ -34059,7 +35414,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237) { + if (importClause.namedBindings.kind === 239) { checkImportBinding(importClause.namedBindings); } else { @@ -34110,8 +35465,10 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 231 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 233 && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 233 && + !node.moduleSpecifier && ts.isInAmbientContext(node); + if (node.parent.kind !== 264 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -34124,7 +35481,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 261 || node.parent.kind === 231 || node.parent.kind === 230; + var isInAppropriateContext = node.parent.kind === 264 || node.parent.kind === 233 || node.parent.kind === 232; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -34147,9 +35504,14 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 261 ? node.parent : node.parent.parent; - if (container.kind === 230 && !ts.isAmbientModule(container)) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + var container = node.parent.kind === 264 ? node.parent : node.parent.parent; + if (container.kind === 232 && !ts.isAmbientModule(container)) { + if (node.isExportEquals) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + } + else { + error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); + } return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { @@ -34172,18 +35534,13 @@ var ts; } } function hasExportedMembers(moduleSymbol) { - for (var id in moduleSymbol.exports) { - if (id !== "export=") { - return true; - } - } - return false; + return ts.forEachEntry(moduleSymbol.exports, function (_, id) { return id !== "export="; }); } function checkExternalModuleExports(node) { var moduleSymbol = getSymbolOfNode(node); var links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - var exportEqualsSymbol = moduleSymbol.exports["export="]; + var exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; if (!isTopLevelInExternalModuleAugmentation(declaration)) { @@ -34191,31 +35548,31 @@ var ts; } } var exports = getExportsOfModule(moduleSymbol); - for (var id in exports) { + exports && exports.forEach(function (_a, id) { + var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { - continue; + return; } - var _a = exports[id], declarations = _a.declarations, flags = _a.flags; if (flags & (1920 | 64 | 384)) { - continue; + return; } var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); if (flags & 524288 && exportedDeclarationsCount <= 2) { - continue; + return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, id)); } } } - } + }); links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 225 && declaration.kind !== 149) || + return (declaration.kind !== 227 && declaration.kind !== 150) || !!declaration.body; } } @@ -34226,123 +35583,123 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 230: - case 226: + case 232: + case 228: + case 229: case 227: - case 225: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 143: - return checkTypeParameter(node); case 144: + return checkTypeParameter(node); + case 145: return checkParameter(node); + case 148: case 147: - case 146: return checkPropertyDeclaration(node); - case 158: case 159: - case 153: + case 160: case 154: - return checkSignatureDeclaration(node); case 155: return checkSignatureDeclaration(node); - case 149: - case 148: - return checkMethodDeclaration(node); - case 150: - return checkConstructorDeclaration(node); - case 151: - case 152: - return checkAccessorDeclaration(node); - case 157: - return checkTypeReferenceNode(node); case 156: + return checkSignatureDeclaration(node); + case 150: + case 149: + return checkMethodDeclaration(node); + case 151: + return checkConstructorDeclaration(node); + case 152: + case 153: + return checkAccessorDeclaration(node); + case 158: + return checkTypeReferenceNode(node); + case 157: return checkTypePredicate(node); - case 160: - return checkTypeQuery(node); case 161: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 162: - return checkArrayType(node); + return checkTypeLiteral(node); case 163: - return checkTupleType(node); + return checkArrayType(node); case 164: + return checkTupleType(node); case 165: - return checkUnionOrIntersectionType(node); case 166: - case 168: - return checkSourceElement(node.type); + return checkUnionOrIntersectionType(node); + case 167: case 169: - return checkIndexedAccessType(node); + return checkSourceElement(node.type); case 170: + return checkIndexedAccessType(node); + case 171: return checkMappedType(node); - case 225: - return checkFunctionDeclaration(node); - case 204: - case 231: - return checkBlock(node); - case 205: - return checkVariableStatement(node); - case 207: - return checkExpressionStatement(node); - case 208: - return checkIfStatement(node); - case 209: - return checkDoStatement(node); - case 210: - return checkWhileStatement(node); - case 211: - return checkForStatement(node); - case 212: - return checkForInStatement(node); - case 213: - return checkForOfStatement(node); - case 214: - case 215: - return checkBreakOrContinueStatement(node); - case 216: - return checkReturnStatement(node); - case 217: - return checkWithStatement(node); - case 218: - return checkSwitchStatement(node); - case 219: - return checkLabeledStatement(node); - case 220: - return checkThrowStatement(node); - case 221: - return checkTryStatement(node); - case 223: - return checkVariableDeclaration(node); - case 174: - return checkBindingElement(node); - case 226: - return checkClassDeclaration(node); case 227: - return checkInterfaceDeclaration(node); - case 228: - return checkTypeAliasDeclaration(node); - case 229: - return checkEnumDeclaration(node); - case 230: - return checkModuleDeclaration(node); - case 235: - return checkImportDeclaration(node); - case 234: - return checkImportEqualsDeclaration(node); - case 241: - return checkExportDeclaration(node); - case 240: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); case 206: - checkGrammarStatementInAmbientContext(node); - return; + case 233: + return checkBlock(node); + case 207: + return checkVariableStatement(node); + case 209: + return checkExpressionStatement(node); + case 210: + return checkIfStatement(node); + case 211: + return checkDoStatement(node); + case 212: + return checkWhileStatement(node); + case 213: + return checkForStatement(node); + case 214: + return checkForInStatement(node); + case 215: + return checkForOfStatement(node); + case 216: + case 217: + return checkBreakOrContinueStatement(node); + case 218: + return checkReturnStatement(node); + case 219: + return checkWithStatement(node); + case 220: + return checkSwitchStatement(node); + case 221: + return checkLabeledStatement(node); case 222: + return checkThrowStatement(node); + case 223: + return checkTryStatement(node); + case 225: + return checkVariableDeclaration(node); + case 175: + return checkBindingElement(node); + case 228: + return checkClassDeclaration(node); + case 229: + return checkInterfaceDeclaration(node); + case 230: + return checkTypeAliasDeclaration(node); + case 231: + return checkEnumDeclaration(node); + case 232: + return checkModuleDeclaration(node); + case 237: + return checkImportDeclaration(node); + case 236: + return checkImportEqualsDeclaration(node); + case 243: + return checkExportDeclaration(node); + case 242: + return checkExportAssignment(node); + case 208: checkGrammarStatementInAmbientContext(node); return; - case 244: + case 224: + checkGrammarStatementInAmbientContext(node); + return; + case 246: return checkMissingDeclaration(node); } } @@ -34355,17 +35712,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 184: case 185: + case 186: + case 150: case 149: - case 148: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 151: case 152: + case 153: checkAccessorDeferred(node); break; - case 197: + case 198: checkClassExpressionDeferred(node); break; } @@ -34385,6 +35742,7 @@ var ts; } checkGrammarSourceFile(node); potentialThisCollisions.length = 0; + potentialNewTargetCollisions.length = 0; deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; ts.forEach(node.statements, checkSourceElement); @@ -34404,6 +35762,10 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } + if (potentialNewTargetCollisions.length) { + ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); + potentialNewTargetCollisions.length = 0; + } links.flags |= 1; } } @@ -34448,7 +35810,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 217 && node.parent.statement === node) { + if (node.parent.kind === 219 && node.parent.statement === node) { return true; } node = node.parent; @@ -34470,28 +35832,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 261: + case 264: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230: + case 232: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 229: + case 231: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 197: + case 198: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 226: - case 227: + case 228: + case 229: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 184: + case 185: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -34509,17 +35871,16 @@ var ts; function copySymbol(symbol, meaning) { if (symbol.flags & meaning) { var id = symbol.name; - if (!symbols[id]) { - symbols[id] = symbol; + if (!symbols.has(id)) { + symbols.set(id, symbol); } } } function copySymbols(source, meaning) { if (meaning) { - for (var id in source) { - var symbol = source[id]; + source.forEach(function (symbol) { copySymbol(symbol, meaning); - } + }); } } } @@ -34530,27 +35891,27 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 143: - case 226: - case 227: + case 144: case 228: case 229: + case 230: + case 231: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 141) { + while (node.parent && node.parent.kind === 142) { node = node.parent; } - return node.parent && (node.parent.kind === 157 || node.parent.kind === 272); + return node.parent && (node.parent.kind === 158 || node.parent.kind === 276); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 177) { + while (node.parent && node.parent.kind === 178) { node = node.parent; } - return node.parent && node.parent.kind === 199; + return node.parent && node.parent.kind === 200; } function forEachEnclosingClass(node, callback) { var result; @@ -34567,13 +35928,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 141) { + while (nodeOnRightSide.parent.kind === 142) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 234) { + if (nodeOnRightSide.parent.kind === 236) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 240) { + if (nodeOnRightSide.parent.kind === 242) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -34585,7 +35946,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 177) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 178) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1: @@ -34597,11 +35958,11 @@ var ts; default: } } - if (entityName.parent.kind === 240 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 242 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } - if (entityName.kind !== 177 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 234); + if (entityName.kind !== 178 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 236); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -34610,7 +35971,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 199) { + if (entityName.parent.kind === 200) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -34632,14 +35993,14 @@ var ts; } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 177) { + else if (entityName.kind === 178) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 141) { + else if (entityName.kind === 142) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -34648,19 +36009,19 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 272) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 158 || entityName.parent.kind === 276) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 250) { + else if (entityName.parent.kind === 252) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 156) { + if (entityName.parent.kind === 157) { return resolveEntityName(entityName, 1); } return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 261) { + if (node.kind === 264) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -34676,8 +36037,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 174 && - node.parent.parent.kind === 172 && + else if (node.parent.kind === 175 && + node.parent.parent.kind === 173 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -34688,8 +36049,8 @@ var ts; } switch (node.kind) { case 70: - case 177: - case 141: + case 178: + case 142: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98: var container = ts.getThisContainer(node, false); @@ -34702,18 +36063,18 @@ var ts; case 96: var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 167: + case 168: return getTypeFromTypeNode(node).symbol; case 122: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 150) { + if (constructorDeclaration && constructorDeclaration.kind === 151) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 235 || node.parent.kind === 241) && + ((node.parent.kind === 237 || node.parent.kind === 243) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -34721,7 +36082,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 178 && node.parent.argumentExpression === node) { + if (node.parent.kind === 179 && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -34735,7 +36096,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 258) { + if (location && location.kind === 261) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -34785,20 +36146,20 @@ var ts; return unknownType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 176 || expr.kind === 175); - if (expr.parent.kind === 213) { + ts.Debug.assert(expr.kind === 177 || expr.kind === 176); + if (expr.parent.kind === 215) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 192) { + if (expr.parent.kind === 193) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 257) { + if (expr.parent.kind === 260) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 175); + ts.Debug.assert(expr.parent.kind === 176); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); @@ -34824,30 +36185,33 @@ var ts; var propsByName = createSymbolTable(getPropertiesOfType(type)); if (getSignaturesOfType(type, 0).length || getSignaturesOfType(type, 1).length) { ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { - if (!propsByName[p.name]) { - propsByName[p.name] = p; + if (!propsByName.has(p.name)) { + propsByName.set(p.name, p); } }); } return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (symbol.flags & 268435456) { + if (getCheckFlags(symbol) & 2) { var symbols_3 = []; - var name_26 = symbol.name; + var name_2 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_26); + var symbol = getPropertyOfType(t, name_2); if (symbol) { symbols_3.push(symbol); } }); return symbols_3; } - else if (symbol.flags & 67108864) { + else if (symbol.flags & 134217728) { if (symbol.leftSpread) { var links = symbol; return [links.leftSpread, links.rightSpread]; } + if (symbol.mappedTypeOrigin) { + return getRootSymbols(symbol.mappedTypeOrigin); + } var target = void 0; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -34863,7 +36227,8 @@ var ts; if (!ts.isGeneratedIdentifier(node)) { node = ts.getParseTreeNode(node, ts.isIdentifier); if (node) { - return getReferencedValueSymbol(node) === argumentsSymbol; + var isPropertyName_1 = node.parent.kind === 178 && node.parent.name === node; + return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } return false; @@ -34879,7 +36244,7 @@ var ts; if (symbolLinks.exportsSomeValue === undefined) { symbolLinks.exportsSomeValue = hasExportAssignment ? !!(moduleSymbol.flags & 107455) - : ts.forEachProperty(getExportsOfModule(moduleSymbol), isValue); + : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { @@ -34905,7 +36270,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 261) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 264) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -34943,7 +36308,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 204 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 206 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -34983,16 +36348,16 @@ var ts; return true; } switch (node.kind) { - case 234: case 236: - case 237: + case 238: case 239: - case 243: - return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); case 241: + case 245: + return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); + case 243: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 240: + case 242: return node.expression && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -35002,7 +36367,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 261 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 264 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -35044,6 +36409,12 @@ var ts; } return false; } + function isRequiredInitializedParameter(parameter) { + return strictNullChecks && + !isOptionalParameter(parameter) && + parameter.initializer && + !(ts.getModifierFlags(parameter) & 92); + } function getNodeCheckFlags(node) { node = ts.getParseTreeNode(node); return node ? getNodeLinks(node).flags : undefined; @@ -35053,7 +36424,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 260) { + if (node.kind === 263) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -35069,15 +36440,17 @@ var ts; } function getTypeReferenceSerializationKind(typeName, location) { var valueSymbol = resolveEntityName(typeName, 107455, true, false, location); - var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); - if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { - return ts.TypeReferenceSerializationKind.Promise; - } - var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; - if (constructorType && isConstructorType(constructorType)) { - return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; - } var typeSymbol = resolveEntityName(typeName, 793064, true, false, location); + if (valueSymbol && valueSymbol === typeSymbol) { + var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); + if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { + return ts.TypeReferenceSerializationKind.Promise; + } + var constructorType = getTypeOfSymbol(valueSymbol); + if (constructorType && isConstructorType(constructorType)) { + return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + } if (!typeSymbol) { return ts.TypeReferenceSerializationKind.ObjectType; } @@ -35121,6 +36494,9 @@ var ts; var type = symbol && !(symbol.flags & (2048 | 131072)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : unknownType; + if (flags & 4096) { + type = includeFalsyTypes(type, 2048); + } getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { @@ -35135,10 +36511,13 @@ var ts; var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(node)); resolveBaseTypesOfClass(classType); var baseType = classType.resolvedBaseTypes.length ? classType.resolvedBaseTypes[0] : unknownType; + if (!baseType.symbol) { + writer.reportIllegalExtends(); + } getSymbolDisplayBuilder().buildTypeDisplay(baseType, writer, enclosingDeclaration, flags); } function hasGlobalName(name) { - return !!globals[name]; + return globals.has(name); } function getReferencedValueSymbol(reference, startInDeclarationContainer) { var resolvedSymbol = getNodeLinks(reference).resolvedSymbol; @@ -35147,9 +36526,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_11 = reference.parent; - if (ts.isDeclaration(parent_11) && reference === parent_11.name) { - location = getDeclarationContainer(parent_11); + var parent = reference.parent; + if (ts.isDeclaration(parent) && reference === parent.name) { + location = getDeclarationContainer(parent); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -35182,14 +36561,13 @@ var ts; var fileToDirective; if (resolvedTypeReferenceDirectives) { fileToDirective = ts.createFileMap(); - for (var key in resolvedTypeReferenceDirectives) { - var resolvedDirective = resolvedTypeReferenceDirectives[key]; + resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) { if (!resolvedDirective) { - continue; + return; } var file = host.getSourceFile(resolvedDirective.resolvedFileName); fileToDirective.set(file.path, key); - } + }); } return { getReferencedExportContainer: getReferencedExportContainer, @@ -35203,6 +36581,7 @@ var ts; isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, + isRequiredInitializedParameter: isRequiredInitializedParameter, writeTypeOfDeclaration: writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, writeTypeOfExpression: writeTypeOfExpression, @@ -35227,7 +36606,7 @@ var ts; if (!fileToDirective) { return undefined; } - var meaning = (node.kind === 177) || (node.kind === 70 && isInTypeQuery(node)) + var meaning = (node.kind === 178) || (node.kind === 70 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -35262,15 +36641,15 @@ var ts; } var current = symbol; while (true) { - var parent_12 = getParentOfSymbol(current); - if (parent_12) { - current = parent_12; + var parent = getParentOfSymbol(current); + if (parent) { + current = parent; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 261 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 264 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -35289,7 +36668,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 261); + return ts.getDeclarationOfKind(moduleSymbol, 264); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -35310,11 +36689,11 @@ var ts; } if (file.symbol && file.symbol.globalExports) { var source = file.symbol.globalExports; - for (var id in source) { - if (!(id in globals)) { - globals[id] = source[id]; + source.forEach(function (sourceSymbol, id) { + if (!globals.has(id)) { + globals.set(id, sourceSymbol); } - } + }); } } if (augmentations) { @@ -35380,10 +36759,10 @@ var ts; var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1; helper <= 128; helper <<= 1) { if (uncheckedHelpers & helper) { - var name_27 = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_27), 107455); + var name = getHelperName(helper); + var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name), 107455); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_27); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); } } } @@ -35418,7 +36797,7 @@ var ts; return emptyObjectType; } function createThenableType() { - var thenPropertySymbol = createSymbol(67108864 | 4, "then"); + var thenPropertySymbol = createSymbol(4, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; var thenableType = createObjectType(16); thenableType.properties = [thenPropertySymbol]; @@ -35432,14 +36811,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 149 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 150 && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 151 || node.kind === 152) { + else if (node.kind === 152 || node.kind === 153) { 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); @@ -35457,16 +36836,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 130) { - if (node.kind === 146 || node.kind === 148) { + if (node.kind === 147 || node.kind === 149) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 155) { + if (node.kind === 156) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 75: - if (node.kind !== 229 && node.parent.kind === 226) { + if (node.kind !== 231 && node.parent.kind === 228) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; @@ -35492,7 +36871,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 231 || node.parent.kind === 261) { + else if (node.parent.kind === 233 || node.parent.kind === 264) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -35515,10 +36894,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 231 || node.parent.kind === 261) { + else if (node.parent.kind === 233 || node.parent.kind === 264) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -35531,7 +36910,7 @@ var ts; if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 147 && node.kind !== 146 && node.kind !== 155 && node.kind !== 144) { + else if (node.kind !== 148 && node.kind !== 147 && node.kind !== 156 && node.kind !== 145) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; @@ -35550,10 +36929,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 228) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; @@ -35565,13 +36944,13 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 228) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 231) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 233) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -35581,14 +36960,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 226) { - if (node.kind !== 149 && - node.kind !== 147 && - node.kind !== 151 && - node.kind !== 152) { + if (node.kind !== 228) { + if (node.kind !== 150 && + node.kind !== 148 && + node.kind !== 152 && + node.kind !== 153) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 226 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 228 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -35607,7 +36986,7 @@ var ts; 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 === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -35615,7 +36994,7 @@ var ts; break; } } - if (node.kind === 150) { + if (node.kind === 151) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -35630,13 +37009,13 @@ var ts; } return; } - else if ((node.kind === 235 || node.kind === 234) && flags & 2) { + else if ((node.kind === 237 || node.kind === 236) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 144 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 145 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 144 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 145 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -35652,37 +37031,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 151: case 152: - case 150: - case 147: - case 146: - case 149: + case 153: + case 151: case 148: - case 155: - case 230: - case 235: - case 234: - case 241: - case 240: - case 184: + case 147: + case 150: + case 149: + case 156: + case 232: + case 237: + case 236: + case 243: + case 242: case 185: - case 144: + case 186: + case 145: return false; default: - if (node.parent.kind === 231 || node.parent.kind === 261) { + if (node.parent.kind === 233 || node.parent.kind === 264) { return false; } switch (node.kind) { - case 225: - return nodeHasAnyModifiersExcept(node, 119); - case 226: - return nodeHasAnyModifiersExcept(node, 116); case 227: - case 205: + return nodeHasAnyModifiersExcept(node, 119); case 228: - return true; + return nodeHasAnyModifiersExcept(node, 116); case 229: + case 207: + case 230: + return true; + case 231: return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); @@ -35695,10 +37074,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 149: - case 225: - case 184: + case 150: + case 227: case 185: + case 186: if (!node.asteriskToken) { return false; } @@ -35760,7 +37139,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 185) { + if (node.kind === 186) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -35795,7 +37174,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 !== 134 && parameter.type.kind !== 132) { + if (parameter.type.kind !== 135 && parameter.type.kind !== 132) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -35822,7 +37201,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 198) { + if (arg.kind === 199) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -35892,19 +37271,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 142) { + if (node.kind !== 143) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 192 && computedPropertyName.expression.operatorToken.kind === 25) { + if (computedPropertyName.expression.kind === 193 && computedPropertyName.expression.operatorToken.kind === 25) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 225 || - node.kind === 184 || - node.kind === 149); + ts.Debug.assert(node.kind === 227 || + node.kind === 185 || + node.kind === 150); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -35929,87 +37308,87 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259) { + if (prop.kind === 262) { continue; } - var name_28 = prop.name; - if (name_28.kind === 142) { - checkGrammarComputedPropertyName(name_28); + var name = prop.name; + if (name.kind === 143) { + checkGrammarComputedPropertyName(name); } - if (prop.kind === 258 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 261 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 || prop.kind !== 149) { + if (mod.kind !== 119 || prop.kind !== 150) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; - if (prop.kind === 257 || prop.kind === 258) { + if (prop.kind === 260 || prop.kind === 261) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_28.kind === 8) { - checkGrammarNumericLiteral(name_28); + if (name.kind === 8) { + checkGrammarNumericLiteral(name); } currentKind = Property; } - else if (prop.kind === 149) { + else if (prop.kind === 150) { currentKind = Property; } - else if (prop.kind === 151) { + else if (prop.kind === 152) { currentKind = GetAccessor; } - else if (prop.kind === 152) { + else if (prop.kind === 153) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_28); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { continue; } - if (!seen[effectiveName]) { - seen[effectiveName] = currentKind; + var existingKind = seen.get(effectiveName); + if (!existingKind) { + seen.set(effectiveName, currentKind); } else { - var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_28, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_28)); + grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[effectiveName] = currentKind | existingKind; + seen.set(effectiveName, currentKind | existingKind); } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } } function checkGrammarJsxElement(node) { var seen = ts.createMap(); - for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { + for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 251) { + if (attr.kind === 254) { continue; } var jsxAttr = attr; - var name_29 = jsxAttr.name; - if (!seen[name_29.text]) { - seen[name_29.text] = true; + var name = jsxAttr.name; + if (!seen.get(name.text)) { + seen.set(name.text, true); } else { - return grammarErrorOnNode(name_29, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 252 && !initializer.expression) { + if (initializer && initializer.kind === 255 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -36018,7 +37397,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 224) { + if (forInOrOfStatement.initializer.kind === 226) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -36026,20 +37405,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 214 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 214 ? 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 === 212 + var diagnostic = forInOrOfStatement.kind === 214 ? 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); @@ -36066,11 +37445,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 151 ? + return grammarErrorOnNode(accessor.name, kind === 152 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 152) { + else if (kind === 153) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -36089,10 +37468,10 @@ var ts; } } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 151 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 152 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 151 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 152 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -36107,7 +37486,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 176) { + if (node.parent.kind === 177) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -36123,10 +37502,10 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 229) { 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 === 161) { + else if (node.parent.kind === 162) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -36137,9 +37516,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 219: + case 221: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 214 + var isMisplacedContinueLabel = node.kind === 216 && !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); @@ -36147,8 +37526,8 @@ var ts; return false; } break; - case 218: - if (node.kind === 215 && !node.label) { + case 220: + if (node.kind === 217 && !node.label) { return false; } break; @@ -36161,13 +37540,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 215 + var message = node.kind === 217 ? 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 === 215 + var message = node.kind === 217 ? 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); @@ -36179,7 +37558,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 173 || node.name.kind === 172) { + if (node.name.kind === 174 || node.name.kind === 173) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -36189,11 +37568,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 190 && expr.operator === 37 && + expr.kind === 191 && expr.operator === 37 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 212 && node.parent.parent.kind !== 213) { + if (node.parent.parent.kind !== 214 && node.parent.parent.kind !== 215) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -36220,9 +37599,29 @@ var ts; } } } + if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && + !ts.isInAmbientContext(node.parent.parent) && ts.hasModifier(node.parent.parent, 1)) { + checkESModuleMarker(node.name); + } var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } + function checkESModuleMarker(name) { + if (name.kind === 70) { + if (ts.unescapeIdentifier(name.text) === "__esModule") { + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); + } + } + else { + var elements = name.elements; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; + if (!ts.isOmittedExpression(element)) { + return checkESModuleMarker(element.name); + } + } + } + } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 70) { if (name.originalKeywordKind === 109) { @@ -36231,8 +37630,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { - var element = elements_2[_i]; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var element = elements_3[_i]; if (!ts.isOmittedExpression(element)) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -36250,15 +37649,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 208: - case 209: case 210: - case 217: case 211: case 212: - case 213: - return false; case 219: + case 213: + case 214: + case 215: + return false; + case 221: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -36273,6 +37672,13 @@ var ts; } } } + function checkGrammarMetaProperty(node) { + if (node.keywordToken === 93) { + if (node.name.text !== "target") { + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + } + } + } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -36313,7 +37719,7 @@ var ts; return true; } } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 229) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -36321,7 +37727,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 161) { + else if (node.parent.kind === 162) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -36334,13 +37740,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 227 || - node.kind === 228 || + if (node.kind === 229 || + node.kind === 230 || + node.kind === 237 || + node.kind === 236 || + node.kind === 243 || + node.kind === 242 || node.kind === 235 || - node.kind === 234 || - node.kind === 241 || - node.kind === 240 || - node.kind === 233 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -36349,7 +37755,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 === 205) { + if (ts.isDeclaration(decl) || decl.kind === 207) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -36368,7 +37774,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 === 204 || node.parent.kind === 231 || node.parent.kind === 261) { + if (node.parent.kind === 206 || node.parent.kind === 233 || node.parent.kind === 264) { 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); @@ -36379,8 +37785,22 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.isOctalLiteral && languageVersion >= 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + if (node.isOctalLiteral) { + var diagnosticMessage = void 0; + if (languageVersion >= 1) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 172)) { + diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 263)) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; + } + if (diagnosticMessage) { + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37; + var literal = (withMinus ? "-" : "") + "0o" + node.text; + return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); + } } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -36393,11 +37813,11 @@ var ts; } function getAmbientModules() { var result = []; - for (var sym in globals) { + globals.forEach(function (global, sym) { if (ambientModuleSymbolRegex.test(sym)) { - result.push(globals[sym]); + result.push(global); } - } + }); return result; } } @@ -36405,55 +37825,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ; - var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[141] = [ - { name: "left", test: ts.isEntityName }, - { name: "right", test: ts.isIdentifier } - ], - _a[145] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[182] = [ - { name: "type", test: ts.isTypeNode }, - { name: "expression", test: ts.isUnaryExpression } - ], - _a[200] = [ - { name: "expression", test: ts.isExpression }, - { name: "type", test: ts.isTypeNode } - ], - _a[201] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[229] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "members", test: ts.isEnumMember } - ], - _a[230] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isModuleName }, - { name: "body", test: ts.isModuleBody } - ], - _a[231] = [ - { name: "statements", test: ts.isStatement } - ], - _a[234] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "moduleReference", test: ts.isModuleReference } - ], - _a[245] = [ - { name: "expression", test: ts.isExpression, optional: true } - ], - _a[260] = [ - { name: "name", test: ts.isPropertyName }, - { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } - ], - _a)); function reduceNode(node, f, initial) { return node ? f(initial, node) : initial; } @@ -36467,41 +37838,45 @@ var ts; var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; - if ((kind > 0 && kind <= 140)) { + if ((kind > 0 && kind <= 141)) { return initial; } - if ((kind >= 156 && kind <= 171)) { + if ((kind >= 157 && kind <= 172)) { return initial; } var result = initial; switch (node.kind) { - case 203: - case 206: - case 198: - case 222: - case 293: + case 205: + case 208: + case 199: + case 224: + case 297: break; case 142: - result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); break; - case 144: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); + case 143: + result = reduceNode(node.expression, cbNode, result); break; case 145: - result = reduceNode(node.expression, cbNode, result); - break; - case 147: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 149: + case 146: + result = reduceNode(node.expression, cbNode, result); + break; + case 148: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 150: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -36510,53 +37885,48 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 150: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); - break; case 151: - result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; case 152: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 153: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 172: case 173: + case 174: result = reduceNodes(node.elements, cbNodes, result); break; - case 174: + case 175: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 175: + case 176: result = reduceNodes(node.elements, cbNodes, result); break; - case 176: - result = reduceNodes(node.properties, cbNodes, result); - break; case 177: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.properties, cbNodes, result); break; case 178: result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.argumentExpression, cbNode, result); + result = reduceNode(node.name, cbNode, result); break; case 179: result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); + result = reduceNode(node.argumentExpression, cbNode, result); break; case 180: result = reduceNode(node.expression, cbNode, result); @@ -36564,10 +37934,19 @@ var ts; result = reduceNodes(node.arguments, cbNodes, result); break; case 181: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 182: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 184: + case 183: + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 185: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -36575,117 +37954,124 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 185: + case 186: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 183: - case 186: + case 184: case 187: case 188: case 189: - case 195: + case 190: case 196: - case 201: + case 197: + case 202: result = reduceNode(node.expression, cbNode, result); break; - case 190: case 191: + case 192: result = reduceNode(node.operand, cbNode, result); break; - case 192: + case 193: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 193: + case 194: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 194: + case 195: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 197: + case 198: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 199: + case 200: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; + case 201: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.type, cbNode, result); + break; case 202: + result = reduceNode(node.expression, cbNode, result); + break; + case 204: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 204: + case 206: result = reduceNodes(node.statements, cbNodes, result); break; - case 205: + case 207: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 207: + case 209: result = reduceNode(node.expression, cbNode, result); break; - case 208: + case 210: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 209: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 210: - case 217: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; case 211: + result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 212: + case 219: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 213: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 212: - case 213: + case 214: + case 215: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 216: - case 220: + case 218: + case 222: result = reduceNode(node.expression, cbNode, result); break; - case 218: + case 220: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 219: + case 221: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 221: + case 223: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 223: + case 225: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 224: + case 226: result = reduceNodes(node.declarations, cbNodes, result); break; - case 225: + case 227: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -36694,7 +38080,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 226: + case 228: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -36702,113 +38088,131 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; + case 231: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.members, cbNodes, result); + break; case 232: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 233: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 234: result = reduceNodes(node.clauses, cbNodes, result); break; - case 235: + case 236: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.moduleReference, cbNode, result); + break; + case 237: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 236: + case 238: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 237: - result = reduceNode(node.name, cbNode, result); - break; - case 238: - case 242: - result = reduceNodes(node.elements, cbNodes, result); - break; case 239: - case 243: - result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; case 240: + case 244: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 241: + case 245: + result = reduceNode(node.propertyName, cbNode, result); + result = reduceNode(node.name, cbNode, result); + break; + case 242: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 241: + case 243: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 246: + case 247: + result = reduceNode(node.expression, cbNode, result); + break; + case 248: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 247: - case 248: - result = reduceNode(node.tagName, cbNode, result); - result = reduceNodes(node.attributes, cbNodes, result); - break; case 249: + case 250: + result = reduceNode(node.tagName, cbNode, result); + result = reduceNode(node.attributes, cbNode, result); + break; + case 251: result = reduceNode(node.tagName, cbNode, result); break; - case 250: + case 253: + result = reduceNodes(node.properties, cbNodes, result); + break; + case 252: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 251: - result = reduceNode(node.expression, cbNode, result); - break; - case 252: - result = reduceNode(node.expression, cbNode, result); - break; - case 253: - result = reduceNode(node.expression, cbNode, result); case 254: - result = reduceNodes(node.statements, cbNodes, result); + result = reduceNode(node.expression, cbNode, result); break; case 255: - result = reduceNodes(node.types, cbNodes, result); + result = reduceNode(node.expression, cbNode, result); break; case 256: + result = reduceNode(node.expression, cbNode, result); + case 257: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 258: + result = reduceNodes(node.types, cbNodes, result); + break; + case 259: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 257: + case 260: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 258: + case 261: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 259: + case 262: result = reduceNode(node.expression, cbNode, result); break; - case 261: + case 263: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + case 264: result = reduceNodes(node.statements, cbNodes, result); break; - case 294: + case 298: result = reduceNode(node.expression, cbNode, result); break; default: - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_1 = edgeTraversalPath; _i < edgeTraversalPath_1.length; _i++) { - var edge = edgeTraversalPath_1[_i]; - var value = node[edge.name]; - if (value !== undefined) { - result = ts.isArray(value) - ? reduceNodes(value, cbNodes, result) - : cbNode(result, value); - } - } - } break; } return result; } ts.reduceEachChild = reduceEachChild; - function visitNode(node, visitor, test, optional, lift, parenthesize, parentNode) { + function visitNode(node, visitor, test, optional, lift) { if (node === undefined || visitor === undefined) { return node; } @@ -36830,15 +38234,12 @@ var ts; else { visitedNode = visited; } - if (parenthesize !== undefined) { - visitedNode = parenthesize(visitedNode, parentNode); - } Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); return visitedNode; } ts.visitNode = visitNode; - function visitNodes(nodes, visitor, test, start, count, parenthesize, parentNode) { + function visitNodes(nodes, visitor, test, start, count) { if (nodes === undefined) { return undefined; } @@ -36851,7 +38252,7 @@ var ts; count = length - start; } if (start > 0 || count < length) { - updated = ts.createNodeArray([], undefined, nodes.hasTrailingComma && start + count === length); + updated = ts.createNodeArray([], nodes.hasTrailingComma && start + count === length); } for (var i = 0; i < count; i++) { var node = nodes[i + start]; @@ -36859,27 +38260,22 @@ var ts; var visited = node !== undefined ? visitor(node) : undefined; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { - updated = ts.createNodeArray(nodes.slice(0, i), nodes, nodes.hasTrailingComma); + updated = ts.createNodeArray(nodes.slice(0, i), nodes.hasTrailingComma); + ts.setTextRange(updated, nodes); } if (visited) { if (ts.isArray(visited)) { for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) { var visitedNode = visited_1[_i]; - visitedNode = parenthesize - ? parenthesize(visitedNode, parentNode) - : visitedNode; Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); updated.push(visitedNode); } } else { - var visitedNode = parenthesize - ? parenthesize(visited, parentNode) - : visited; - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); - updated.push(visitedNode); + Debug.assertNode(visited, test); + aggregateTransformFlags(visited); + updated.push(visited); } } } @@ -36891,10 +38287,10 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); - return ts.createNodeArray(ts.concatenate(statements, declarations), statements); + return ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements); } ts.visitLexicalEnvironment = visitLexicalEnvironment; function visitParameterList(nodes, visitor, context) { @@ -36921,203 +38317,206 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 140)) { + if ((kind > 0 && kind <= 141)) { return node; } - if ((kind >= 156 && kind <= 171)) { + if ((kind >= 157 && kind <= 172)) { return node; } switch (node.kind) { - case 203: - case 206: - case 198: - case 222: + case 205: + case 208: + case 199: + case 224: return node; case 142: + return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); + case 143: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 144: + case 145: return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), node.dotDotDotToken, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 147: + case 146: + return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); + case 148: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 149: - return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 150: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); + return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 151: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); case 152: + return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + case 153: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); - case 172: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 173: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); + return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 174: - return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); + return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); case 175: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); + return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); case 176: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); + return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); case 177: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); case 178: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); case 179: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); case 180: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); case 181: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 182: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); case 183: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 184: - return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 185: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 186: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 187: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 188: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); case 189: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); case 190: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 191: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); case 193: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + case 191: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 192: + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); case 194: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); case 195: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); case 196: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); case 197: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 198: return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 199: + case 200: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 201: + return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); case 202: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 204: + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + case 206: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 205: - return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); case 207: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 208: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); + return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); case 209: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 210: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); case 211: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); case 212: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 213: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 214: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 215: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 216: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 217: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 218: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); case 219: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 220: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); case 221: - return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 222: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); case 223: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 224: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); case 225: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 226: + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + case 227: + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + case 228: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); + case 231: + return ts.updateEnumDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNodes(node.members, visitor, ts.isEnumMember)); case 232: + return ts.updateModuleDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); + case 233: + return ts.updateModuleBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 234: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 235: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 236: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); + return ts.updateImportEqualsDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); case 237: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 238: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); case 239: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 240: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 241: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 242: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 243: + return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + case 244: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + case 245: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 246: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 247: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); case 248: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 249: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 250: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 251: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 252: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 253: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxAttributes(node, visitNodes(node.properties, visitor, ts.isJsxAttributeLike)); + case 249: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 250: + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 251: + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + case 252: + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 254: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 255: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 256: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); case 257: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); case 258: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); case 259: - return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + case 260: + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); case 261: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 262: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + case 263: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 264: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 294: + case 298: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: - var updated = void 0; - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_2 = edgeTraversalPath; _i < edgeTraversalPath_2.length; _i++) { - var edge = edgeTraversalPath_2[_i]; - var value = node[edge.name]; - if (value !== undefined) { - var visited = ts.isArray(value) - ? visitNodes(value, visitor, edge.test, 0, value.length, edge.parenthesize, node) - : visitNode(value, visitor, edge.test, edge.optional, edge.lift, edge.parenthesize, node); - if (updated !== undefined || visited !== value) { - if (updated === undefined) { - updated = ts.getMutableClone(node); - } - if (visited !== value) { - updated[edge.name] = visited; - } - } - } - } - } - return updated ? ts.updateNode(updated, node) : node; + return node; } } ts.visitEachChild = visitEachChild; @@ -37126,17 +38525,17 @@ var ts; return statements; } return ts.isNodeArray(statements) - ? ts.createNodeArray(ts.concatenate(statements, declarations), statements) + ? ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements) : ts.addRange(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; function mergeFunctionBodyLexicalEnvironment(body, declarations) { if (body && declarations !== undefined && declarations.length > 0) { if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.createNodeArray(ts.concatenate(body.statements, declarations), body.statements)); + return ts.updateBlock(body, ts.setTextRange(ts.createNodeArray(ts.concatenate(body.statements, declarations)), body.statements)); } else { - return ts.createBlock(ts.createNodeArray([ts.createReturn(body, body)].concat(declarations), body), body, true); + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray([ts.setTextRange(ts.createReturn(body), body)].concat(declarations)), body), true), body); } } return body; @@ -37181,7 +38580,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || ts.isTypeNode(node)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 200)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -37229,7 +38628,6 @@ var ts; } } })(Debug = ts.Debug || (ts.Debug = {})); - var _a; })(ts || (ts = {})); var ts; (function (ts) { @@ -37286,7 +38684,7 @@ var ts; ts.Debug.assertNode(target, createAssignmentCallback ? ts.isIdentifier : ts.isExpression); var expression = createAssignmentCallback ? createAssignmentCallback(target, value, location) - : ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value, location); + : ts.setTextRange(ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value), location); expression.original = original; emitExpression(expression); } @@ -37324,10 +38722,11 @@ var ts; } } for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) { - var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_30 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; - var variable = ts.createVariableDeclaration(name_30, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); + var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name = _a.name, value = _a.value, location = _a.location, original = _a.original; + var variable = ts.createVariableDeclaration(name, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value); variable.original = original; - if (ts.isIdentifier(name_30)) { + ts.setTextRange(variable, location); + if (ts.isIdentifier(name)) { ts.setEmitFlags(variable, 64); } ts.aggregateTransformFlags(variable); @@ -37473,8 +38872,8 @@ var ts; return ts.createElementAccess(value, argumentExpression); } else { - var name_31 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); - return ts.createPropertyAccess(value, name_31); + var name = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); + return ts.createPropertyAccess(value, name); } } function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) { @@ -37485,7 +38884,7 @@ var ts; var temp = ts.createTempVariable(undefined); if (flattenContext.hoistTempVariables) { flattenContext.context.hoistVariableDeclaration(temp); - flattenContext.emitExpression(ts.createAssignment(temp, value, location)); + flattenContext.emitExpression(ts.setTextRange(ts.createAssignment(temp, value), location)); } else { flattenContext.emitBindingOrAssignment(temp, value, location, undefined); @@ -37535,7 +38934,10 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), undefined, [value, ts.createArrayLiteral(propertyNames, location)]); + return ts.createCall(ts.getHelperName("__rest"), undefined, [ + value, + ts.setTextRange(ts.createArrayLiteral(propertyNames), location) + ]); } })(ts || (ts = {})); var ts; @@ -37551,8 +38953,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(177); context.enableSubstitution(178); + context.enableSubstitution(179); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -37585,15 +38987,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 261: - case 232: - case 231: - case 204: + case 264: + case 234: + case 233: + case 206: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 226: - case 225: + case 228: + case 227: if (ts.hasModifier(node, 2)) { break; } @@ -37618,13 +39020,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 235: + case 237: return visitImportDeclaration(node); - case 234: + case 236: return visitImportEqualsDeclaration(node); - case 240: + case 242: return visitExportAssignment(node); - case 241: + case 243: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -37634,11 +39036,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 241 || - node.kind === 235 || - node.kind === 236 || - (node.kind === 234 && - node.moduleReference.kind === 245)) { + if (node.kind === 243 || + node.kind === 237 || + node.kind === 238 || + (node.kind === 236 && + node.moduleReference.kind === 247)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -37654,15 +39056,15 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 150: - return undefined; - case 147: - case 155: case 151: + return undefined; + case 148: + case 156: case 152: - case 149: + case 153: + case 150: return visitorWorker(node); - case 203: + case 205: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -37693,23 +39095,22 @@ var ts; case 75: case 123: case 130: - case 162: case 163: - case 161: - case 156: - case 143: + case 164: + case 162: + case 157: + case 144: case 118: case 121: - case 134: + case 135: case 132: case 129: case 104: - case 135: - case 159: - case 158: + case 136: case 160: - case 157: - case 164: + case 159: + case 161: + case 158: case 165: case 166: case 167: @@ -37717,57 +39118,58 @@ var ts; case 169: case 170: case 171: - case 155: - case 145: - case 228: - case 147: - return undefined; - case 150: - return visitConstructor(node); - case 227: - return ts.createNotEmittedStatement(node); - case 226: - return visitClassDeclaration(node); - case 197: - return visitClassExpression(node); - case 255: - return visitHeritageClause(node); - case 199: - return visitExpressionWithTypeArguments(node); - case 149: - return visitMethodDeclaration(node); - case 151: - return visitGetAccessor(node); - case 152: - return visitSetAccessor(node); - case 225: - return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); - case 185: - return visitArrowFunction(node); - case 144: - return visitParameter(node); - case 183: - return visitParenthesizedExpression(node); - case 182: - case 200: - return visitAssertionExpression(node); - case 179: - return visitCallExpression(node); - case 180: - return visitNewExpression(node); - case 201: - return visitNonNullExpression(node); - case 229: - return visitEnumDeclaration(node); - case 205: - return visitVariableStatement(node); - case 223: - return visitVariableDeclaration(node); + case 172: + case 156: + case 146: case 230: + case 148: + return undefined; + case 151: + return visitConstructor(node); + case 229: + return ts.createNotEmittedStatement(node); + case 228: + return visitClassDeclaration(node); + case 198: + return visitClassExpression(node); + case 258: + return visitHeritageClause(node); + case 200: + return visitExpressionWithTypeArguments(node); + case 150: + return visitMethodDeclaration(node); + case 152: + return visitGetAccessor(node); + case 153: + return visitSetAccessor(node); + case 227: + return visitFunctionDeclaration(node); + case 185: + return visitFunctionExpression(node); + case 186: + return visitArrowFunction(node); + case 145: + return visitParameter(node); + case 184: + return visitParenthesizedExpression(node); + case 183: + case 201: + return visitAssertionExpression(node); + case 180: + return visitCallExpression(node); + case 181: + return visitNewExpression(node); + case 202: + return visitNonNullExpression(node); + case 231: + return visitEnumDeclaration(node); + case 207: + return visitVariableStatement(node); + case 225: + return visitVariableDeclaration(node); + case 232: return visitModuleDeclaration(node); - case 234: + case 236: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -37827,11 +39229,12 @@ var ts; return ts.singleOrMany(statements); } function createClassDeclarationHeadWithoutDecorators(node, name, hasExtendsClause, hasStaticProperties) { - var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); + var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause)); var emitFlags = ts.getEmitFlags(node); if (hasStaticProperties) { emitFlags |= 32; } + ts.setTextRange(classDeclaration, node); ts.setOriginalNode(classDeclaration, node); ts.setEmitFlags(classDeclaration, emitFlags); return classDeclaration; @@ -37842,10 +39245,14 @@ var ts; var declName = ts.getLocalName(node, false, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, hasExtendsClause); - var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members, location); + var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); - var statement = ts.createLetStatement(declName, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression, location); + ts.setTextRange(classExpression, location); + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(declName, undefined, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression) + ], 1)); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, location); ts.setCommentRange(statement, node); return statement; } @@ -37853,7 +39260,9 @@ var ts; var staticProperties = getInitializedProperties(node, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84; })); - var classExpression = ts.setOriginalNode(ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members, node), node); + var classExpression = ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members); + ts.setOriginalNode(classExpression, node); + ts.setTextRange(classExpression, node); if (staticProperties.length > 0) { var expressions = []; var temp = ts.createTempVariable(hoistVariableDeclaration); @@ -37876,7 +39285,7 @@ var ts; members.push(constructor); } ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement)); - return ts.createNodeArray(members, node.members); + return ts.setTextRange(ts.createNodeArray(members), node.members); } function transformConstructor(node, hasExtendsClause) { var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); @@ -37887,7 +39296,7 @@ var ts; } var parameters = transformConstructorParameters(constructor); var body = transformConstructorBody(node, constructor, hasExtendsClause); - return ts.startOnNewLine(ts.setOriginalNode(ts.createConstructor(undefined, undefined, parameters, body, constructor || node), constructor)); + return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(ts.createConstructor(undefined, undefined, parameters, body), constructor || node), constructor)); } function transformConstructorParameters(constructor) { return ts.visitParameterList(constructor && constructor.parameters, visitor, context) @@ -37911,7 +39320,7 @@ var ts; ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } ts.addRange(statements, endLexicalEnvironment()); - return ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : undefined, true); + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined); } function addPrologueDirectivesAndInitialSuperCall(ctor, result) { if (ctor.body) { @@ -37921,7 +39330,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -37943,7 +39352,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 | 48); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536); - return ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), propertyName, node.name), localName), ts.moveRangePos(node, -1))); + return ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1))); } function getInitializedProperties(node, isStatic) { return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); @@ -37955,7 +39364,7 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 147 + return member.kind === 148 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } @@ -38028,12 +39437,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 151: case 152: + case 153: return getAllDecoratorsOfAccessors(node, member); - case 149: + case 150: return getAllDecoratorsOfMethod(member); - case 147: + case 148: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -38112,7 +39521,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 147 + ? member.kind === 148 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -38190,43 +39599,43 @@ var ts; (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeReturnTypeOfNode(node)))); } if (properties) { - decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, undefined, true))); + decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, true))); } } } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 149 - || kind === 151 + return kind === 150 || kind === 152 - || kind === 147; + || kind === 153 + || kind === 148; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 149; + return node.kind === 150; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 226: - case 197: + case 228: + case 198: return ts.getFirstConstructorWithBody(node) !== undefined; - case 149: - case 151: + case 150: case 152: + case 153: return true; } return false; } function serializeTypeOfNode(node) { switch (node.kind) { - case 147: - case 144: - case 151: - return serializeTypeNode(node.type); + case 148: + case 145: case 152: + return serializeTypeNode(node.type); + case 153: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 226: - case 197: - case 149: + case 228: + case 198: + case 150: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -38258,7 +39667,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 151) { + if (container && node.kind === 152) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -38281,21 +39690,24 @@ var ts; } switch (node.kind) { case 104: + case 138: + case 94: + case 129: return ts.createVoidZero(); - case 166: + case 167: return serializeTypeNode(node.type); - case 158: case 159: + case 160: return ts.createIdentifier("Function"); - case 162: case 163: + case 164: return ts.createIdentifier("Array"); - case 156: + case 157: case 121: return ts.createIdentifier("Boolean"); - case 134: + case 135: return ts.createIdentifier("String"); - case 171: + case 172: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); @@ -38311,44 +39723,22 @@ var ts; break; case 132: return ts.createIdentifier("Number"); - case 135: + case 136: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 157: + case 158: return serializeTypeReferenceNode(node); + case 166: case 165: - case 164: - { - var unionOrIntersection = node; - var serializedUnion = void 0; - for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - var serializedIndividual = serializeTypeNode(typeNode); - if (serializedIndividual.kind !== 70) { - serializedUnion = undefined; - break; - } - if (serializedIndividual.text === "Object") { - return serializedIndividual; - } - if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { - serializedUnion = undefined; - break; - } - serializedUnion = serializedIndividual; - } - if (serializedUnion) { - return serializedUnion; - } - } - case 160: - case 168: + return serializeUnionOrIntersectionType(node); + case 161: case 169: case 170: - case 161: + case 171: + case 162: case 118: - case 167: + case 168: break; default: ts.Debug.failBadSyntaxKind(node); @@ -38356,6 +39746,32 @@ var ts; } return ts.createIdentifier("Object"); } + function serializeUnionOrIntersectionType(node) { + var serializedUnion; + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + if (ts.isVoidExpression(serializedIndividual)) { + if (!serializedUnion) { + serializedUnion = serializedIndividual; + } + } + else if (ts.isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") { + return serializedIndividual; + } + else if (serializedUnion && !ts.isVoidExpression(serializedUnion)) { + if (!ts.isIdentifier(serializedUnion) || + !ts.isIdentifier(serializedIndividual) || + serializedUnion.text !== serializedIndividual.text) { + return ts.createIdentifier("Object"); + } + } + else { + serializedUnion = serializedIndividual; + } + } + return serializedUnion; + } function serializeTypeReferenceNode(node) { switch (resolver.getTypeReferenceSerializationKind(node.typeName, currentScope)) { case ts.TypeReferenceSerializationKind.Unknown: @@ -38390,15 +39806,15 @@ var ts; function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { case 70: - var name_32 = ts.getMutableClone(node); - name_32.flags &= ~8; - name_32.original = undefined; - name_32.parent = currentScope; + var name = ts.getMutableClone(node); + name.flags &= ~8; + name.original = undefined; + name.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_32), ts.createLiteral("undefined")), name_32); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } - return name_32; - case 141: + return name; + case 142: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -38442,7 +39858,7 @@ var ts; hoistVariableDeclaration(generatedName); expression = ts.createAssignment(generatedName, expression); } - return ts.setOriginalNode(ts.createComputedPropertyName(expression, name), name); + return ts.updateComputedPropertyName(name, expression); } else { return name; @@ -38451,13 +39867,12 @@ var ts; function visitHeritageClause(node) { if (node.token === 84) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(84, types, node); + return ts.setTextRange(ts.createHeritageClause(84, types), node); } return undefined; } function visitExpressionWithTypeArguments(node) { - var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); - return ts.createExpressionWithTypeArguments(undefined, expression, node); + return ts.updateExpressionWithTypeArguments(node, undefined, ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); } function shouldEmitFunctionLikeDeclaration(node) { return !ts.nodeIsMissing(node.body); @@ -38531,8 +39946,9 @@ var ts; if (ts.parameterIsThisKeyword(node)) { return undefined; } - var parameter = ts.createParameter(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), ts.moveRangePastModifiers(node)); + var parameter = ts.createParameter(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); ts.setOriginalNode(parameter, node); + ts.setTextRange(parameter, ts.moveRangePastModifiers(node)); ts.setCommentRange(parameter, node); ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); ts.setEmitFlags(parameter.name, 32); @@ -38544,7 +39960,7 @@ var ts; if (variables.length === 0) { return undefined; } - return ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); + return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -38556,7 +39972,7 @@ var ts; return ts.flattenDestructuringAssignment(node, visitor, context, 0, false, createNamespaceExportExpression); } else { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), node); + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node); } } function visitVariableDeclaration(node) { @@ -38610,8 +40026,9 @@ var ts; var localName = ts.getLocalName(node, false, true); moduleArg = ts.createAssignment(localName, moduleArg); } - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg]), node); + var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg])); ts.setOriginalNode(enumStatement, node); + ts.setTextRange(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); statements.push(ts.createEndOfDeclarationMarker(node)); @@ -38625,11 +40042,11 @@ var ts; ts.addRange(statements, ts.map(node.members, transformEnumMember)); ts.addRange(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceLocalName; - return ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); + return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true); } function transformEnumMember(member) { var name = getExpressionForPropertyName(member, false); - return ts.createStatement(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name, member), member); + return ts.setTextRange(ts.createStatement(ts.setTextRange(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name), member)), member); } function transformEnumMemberDeclarationValue(member) { var value = resolver.getConstantValue(member); @@ -38661,16 +40078,16 @@ var ts; if (!currentScopeFirstDeclarationsOfName) { currentScopeFirstDeclarationsOfName = ts.createMap(); } - if (!(name in currentScopeFirstDeclarationsOfName)) { - currentScopeFirstDeclarationsOfName[name] = node; + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_33 = node.symbol && node.symbol.name; - if (name_33) { - return currentScopeFirstDeclarationsOfName[name_33] === node; + var name = node.symbol && node.symbol.name; + if (name) { + return currentScopeFirstDeclarationsOfName.get(name) === node; } } return false; @@ -38682,7 +40099,7 @@ var ts; ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 229) { + if (node.kind === 231) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -38723,8 +40140,9 @@ var ts; var localName = ts.getLocalName(node, false, true); moduleArg = ts.createAssignment(localName, moduleArg); } - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); + var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg])); ts.setOriginalNode(moduleStatement, node); + ts.setTextRange(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); statements.push(ts.createEndOfDeclarationMarker(node)); @@ -38742,8 +40160,8 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 231) { - ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); + if (body.kind === 233) { + saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; } @@ -38764,14 +40182,15 @@ var ts; currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 231) { + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true); + ts.setTextRange(block, blockLocation); + if (body.kind !== 233) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 230) { + if (moduleDeclaration.body.kind === 232) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -38791,7 +40210,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 237) { + if (node.kind === 239) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -38843,9 +40262,9 @@ var ts; var moduleReference = ts.createExpressionFromEntityName(node.moduleReference); ts.setEmitFlags(moduleReference, 1536 | 2048); if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { - return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ + return ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.setOriginalNode(ts.createVariableDeclaration(node.name, undefined, moduleReference), node) - ]), node), node); + ])), node), node); } else { return ts.setOriginalNode(createNamespaceExport(node.name, moduleReference, node), node); @@ -38866,7 +40285,7 @@ var ts; && ts.hasModifier(node, 512); } function expressionToStatement(expression) { - return ts.createStatement(expression, undefined); + return ts.createStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), ts.getLocalName(node)); @@ -38876,10 +40295,10 @@ var ts; statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue), location); + return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue, location); + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); } function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) { return ts.getNamespaceMemberName(currentNamespaceContainerName, name, false, true); @@ -38895,7 +40314,7 @@ var ts; function getClassAliasIfNeeded(node) { if (resolver.getNodeCheckFlags(node) & 8388608) { enableSubstitutionForClassAliases(); - var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); + var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.unescapeIdentifier(node.name.text) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; hoistVariableDeclaration(classAlias); return classAlias; @@ -38919,24 +40338,24 @@ var ts; if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; context.enableSubstitution(70); - classAliases = ts.createMap(); + classAliases = []; } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(70); - context.enableSubstitution(258); - context.enableEmitNotification(230); + context.enableSubstitution(261); + context.enableEmitNotification(232); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 230; + return ts.getOriginalNode(node).kind === 232; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 229; + return ts.getOriginalNode(node).kind === 231; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2; @@ -38944,12 +40363,12 @@ var ts; if (enabledSubstitutions & 8 && isTransformedEnumDeclaration(node)) { applicableSubstitutions |= 8; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -38959,14 +40378,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_34 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_34); + var name = node.name; + var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_34, initializer, node); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); } - return ts.createPropertyAssignment(name_34, exportedName, node); + return ts.setTextRange(ts.createPropertyAssignment(name, exportedName), node); } } return node; @@ -38975,9 +40394,9 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 177: - return substitutePropertyAccessExpression(node); case 178: + return substitutePropertyAccessExpression(node); + case 179: return substituteElementAccessExpression(node); } return node; @@ -39007,11 +40426,11 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 261) { - var substitute = (applicableSubstitutions & 2 && container.kind === 230) || - (applicableSubstitutions & 8 && container.kind === 229); + if (container && container.kind !== 264) { + var substitute = (applicableSubstitutions & 2 && container.kind === 232) || + (applicableSubstitutions & 8 && container.kind === 231); if (substitute) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node); } } } @@ -39058,10 +40477,10 @@ var ts; }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(paramHelper); - return ts.createCall(ts.getHelperName("__param"), undefined, [ + return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), undefined, [ ts.createLiteral(parameterOffset), expression - ], location); + ]), location); } var metadataHelper = { name: "typescript:metadata", @@ -39085,7 +40504,7 @@ var ts; function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) { context.requestEmitHelper(decorateHelper); var argumentsArray = []; - argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, undefined, true)); + argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, true)); argumentsArray.push(target); if (memberName) { argumentsArray.push(memberName); @@ -39093,7 +40512,7 @@ var ts; argumentsArray.push(descriptor); } } - return ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray, location); + return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray), location); } })(ts || (ts = {})); var ts; @@ -39120,37 +40539,37 @@ var ts; return node; } switch (node.kind) { - case 176: + case 177: return visitObjectLiteralExpression(node); - case 192: + case 193: return visitBinaryExpression(node, noDestructuringValue); - case 223: - return visitVariableDeclaration(node); - case 213: - return visitForOfStatement(node); - case 211: - return visitForStatement(node); - case 188: - return visitVoidExpression(node); - case 150: - return visitConstructorDeclaration(node); - case 149: - return visitMethodDeclaration(node); - case 151: - return visitGetAccessorDeclaration(node); - case 152: - return visitSetAccessorDeclaration(node); case 225: + return visitVariableDeclaration(node); + case 215: + return visitForOfStatement(node); + case 213: + return visitForStatement(node); + case 189: + return visitVoidExpression(node); + case 151: + return visitConstructorDeclaration(node); + case 150: + return visitMethodDeclaration(node); + case 152: + return visitGetAccessorDeclaration(node); + case 153: + return visitSetAccessorDeclaration(node); + case 227: return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); case 185: + return visitFunctionExpression(node); + case 186: return visitArrowFunction(node); - case 144: + case 145: return visitParameter(node); - case 207: + case 209: return visitExpressionStatement(node); - case 183: + case 184: return visitParenthesizedExpression(node, noDestructuringValue); default: return ts.visitEachChild(node, visitor, context); @@ -39159,9 +40578,9 @@ var ts; function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; - for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { - var e = elements_3[_i]; - if (e.kind === 259) { + for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { + var e = elements_4[_i]; + if (e.kind === 262) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -39173,7 +40592,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 257) { + if (e.kind === 260) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -39190,7 +40609,7 @@ var ts; function visitObjectLiteralExpression(node) { if (node.transformFlags & 1048576) { var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 176) { + if (objects.length && objects[0].kind !== 177) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -39234,25 +40653,26 @@ var ts; var firstDeclaration = ts.firstOrUndefined(initializer.declarations); var declarations = ts.flattenDestructuringBinding(firstDeclaration, visitor, context, 1, temp, false, true); if (ts.some(declarations)) { - var statement = ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(initializer, declarations), initializer); + var statement = ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(initializer, declarations)); + ts.setTextRange(statement, initializer); leadingStatements = ts.append(leadingStatements, statement); } } else if (ts.isAssignmentPattern(initializer)) { temp = ts.createTempVariable(undefined); - var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.createAssignment(initializer, temp, node.initializer)), visitor, context, 1); - leadingStatements = ts.append(leadingStatements, ts.createStatement(expression, node.initializer)); + var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.setTextRange(ts.createAssignment(initializer, temp), node.initializer)), visitor, context, 1); + leadingStatements = ts.append(leadingStatements, ts.setTextRange(ts.createStatement(expression), node.initializer)); } } if (temp) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var statement = ts.visitNode(node.statement, visitor, ts.isStatement); var block = ts.isBlock(statement) - ? ts.updateBlock(statement, ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements), statement.statements)) - : ts.createBlock(ts.append(leadingStatements, statement), statement, true); - return ts.updateForOf(node, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, undefined, undefined, node.initializer) - ], node.initializer, 1), expression, block); + ? ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements)), statement.statements)) + : ts.setTextRange(ts.createBlock(ts.append(leadingStatements, statement), true), statement); + return ts.updateForOf(node, ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer) + ], 1), node.initializer), expression, block); } return ts.visitEachChild(node, visitor, context); } @@ -39302,7 +40722,7 @@ var ts; var trailingStatements = endLexicalEnvironment(); if (ts.some(leadingStatements) || ts.some(trailingStatements)) { var block = ts.convertToFunctionBody(body, true); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements)), block.statements)); } return body; } @@ -39315,6 +40735,9 @@ var ts; text: "\n var __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };" }; function createAssignHelper(context, attributesSegments) { + if (context.getCompilerOptions().target >= 2) { + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), undefined, attributesSegments); + } context.requestEmitHelper(assignHelper); return ts.createCall(ts.getHelperName("__assign"), undefined, attributesSegments); } @@ -39346,11 +40769,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 246: + case 248: return visitJsxElement(node, false); - case 247: + case 249: return visitJsxSelfClosingElement(node, false); - case 252: + case 255: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -39360,11 +40783,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 252: + case 255: return visitJsxExpression(node); - case 246: + case 248: return visitJsxElement(node, true); - case 247: + case 249: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -39380,7 +40803,7 @@ var ts; function visitJsxOpeningLikeElement(node, children, isChild, location) { var tagName = getTagName(node); var objectProperties; - var attrs = node.attributes; + var attrs = node.attributes.properties; if (attrs.length === 0) { objectProperties = ts.createNull(); } @@ -39412,13 +40835,16 @@ var ts; } function transformJsxAttributeInitializer(node) { if (node === undefined) { - return ts.createLiteral(true); + return ts.createTrue(); } else if (node.kind === 9) { var decoded = tryDecodeEntities(node.text); - return decoded ? ts.createLiteral(decoded, node) : node; + return decoded ? ts.setTextRange(ts.createLiteral(decoded), node) : node; } - else if (node.kind === 252) { + else if (node.kind === 255) { + if (node.expression === undefined) { + return ts.createTrue(); + } return visitJsxExpression(node); } else { @@ -39426,43 +40852,35 @@ var ts; } } function visitJsxText(node) { - var text = ts.getTextOfNode(node, true); - var parts; + var fixed = fixupWhitespaceAndDecodeEntities(ts.getTextOfNode(node, true)); + return fixed === undefined ? undefined : ts.createLiteral(fixed); + } + function fixupWhitespaceAndDecodeEntities(text) { + var acc; 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); - if (!parts) { - parts = []; - } - parts.push(ts.createLiteral(decodeEntities(part))); + if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) { + acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1)); } firstNonWhitespace = -1; } - else if (!ts.isWhiteSpace(c)) { + else if (!ts.isWhiteSpaceSingleLine(c)) { lastNonWhitespace = i; if (firstNonWhitespace === -1) { firstNonWhitespace = i; } } } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - if (!parts) { - parts = []; - } - parts.push(ts.createLiteral(decodeEntities(part))); - } - if (parts) { - return ts.reduceLeft(parts, aggregateJsxTextParts); - } - return undefined; + return firstNonWhitespace !== -1 + ? addLineOfJsxText(acc, text.substr(firstNonWhitespace)) + : acc; } - function aggregateJsxTextParts(left, right) { - return ts.createAdd(ts.createAdd(left, ts.createLiteral(" ")), right); + function addLineOfJsxText(acc, trimmedLine) { + var decoded = decodeEntities(trimmedLine); + return acc === undefined ? decoded : acc + " " + decoded; } function decodeEntities(text) { return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) { @@ -39473,7 +40891,7 @@ var ts; return String.fromCharCode(parseInt(hex, 16)); } else { - var ch = entities[word]; + var ch = entities.get(word); return ch ? String.fromCharCode(ch) : match; } }); @@ -39483,16 +40901,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 246) { + if (node.kind === 248) { return getTagName(node.openingElement); } else { - var name_35 = node.tagName; - if (ts.isIdentifier(name_35) && ts.isIntrinsicJsxName(name_35.text)) { - return ts.createLiteral(name_35.text); + var name = node.tagName; + if (ts.isIdentifier(name) && ts.isIntrinsicJsxName(name.text)) { + return ts.createLiteral(name.text); } else { - return ts.createExpressionFromEntityName(name_35); + return ts.createExpressionFromEntityName(name); } } } @@ -39510,7 +40928,7 @@ var ts; } } ts.transformJsx = transformJsx; - var entities = ts.createMap({ + var entities = ts.createMapFromTemplate({ "quot": 0x0022, "amp": 0x0026, "apos": 0x0027, @@ -39798,22 +41216,22 @@ var ts; switch (node.kind) { case 119: return undefined; - case 189: + case 190: return visitAwaitExpression(node); - case 149: + case 150: return visitMethodDeclaration(node); - case 225: + case 227: return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); case 185: + return visitFunctionExpression(node); + case 186: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); } } function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); } function visitMethodDeclaration(node) { return ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) @@ -39843,14 +41261,15 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 185; + var isArrowFunction = node.kind === 186; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(statements, node.body, true); + var block = ts.createBlock(statements, true); + ts.setTextRange(block, node.body); if (languageVersion >= 2) { if (resolver.getNodeCheckFlags(node) & 4096) { enableSubstitutionForAsyncMethodsWithSuper(); @@ -39868,7 +41287,7 @@ var ts; var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(block.statements, declarations), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); } return expression; } @@ -39881,7 +41300,7 @@ var ts; startLexicalEnvironment(); var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); var declarations = endLexicalEnvironment(); - return ts.updateBlock(visited, ts.createNodeArray(ts.concatenate(visited.statements, declarations), visited.statements)); + return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); } } function getPromiseConstructor(type) { @@ -39898,23 +41317,23 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(179); - context.enableSubstitution(177); + context.enableSubstitution(180); context.enableSubstitution(178); - context.enableEmitNotification(226); - context.enableEmitNotification(149); - context.enableEmitNotification(151); - context.enableEmitNotification(152); + context.enableSubstitution(179); + context.enableEmitNotification(228); context.enableEmitNotification(150); + context.enableEmitNotification(152); + context.enableEmitNotification(153); + context.enableEmitNotification(151); } } function substituteExpression(node) { switch (node.kind) { - case 177: - return substitutePropertyAccessExpression(node); case 178: - return substituteElementAccessExpression(node); + return substitutePropertyAccessExpression(node); case 179: + return substituteElementAccessExpression(node); + case 180: if (enabledSubstitutions & 1) { return substituteCallExpression(node); } @@ -39957,36 +41376,36 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 226 - || kind === 150 - || kind === 149 + return kind === 228 || kind === 151 - || kind === 152; + || kind === 150 + || kind === 152 + || kind === 153; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { if (enabledSubstitutions & 1 && isSuperContainer(node)) { var savedCurrentSuperContainer = currentSuperContainer; currentSuperContainer = node; - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSuperContainer = savedCurrentSuperContainer; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } return node; } function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { if (flags & 4096) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value"), location); } else { - return ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression], location); + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), location); } } function getSuperContainerAsyncMethodFlags() { @@ -40039,7 +41458,7 @@ var ts; return node; } switch (node.kind) { - case 192: + case 193: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -40063,19 +41482,19 @@ var ts; if (ts.isElementAccessExpression(left)) { var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createElementAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), ts.createAssignment(argumentExpressionTemp, left.argumentExpression, left.argumentExpression), left); - value = ts.createElementAccess(expressionTemp, argumentExpressionTemp, left); + target = ts.setTextRange(ts.createElementAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), ts.setTextRange(ts.createAssignment(argumentExpressionTemp, left.argumentExpression), left.argumentExpression)), left); + value = ts.setTextRange(ts.createElementAccess(expressionTemp, argumentExpressionTemp), left); } else if (ts.isPropertyAccessExpression(left)) { var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createPropertyAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), left.name, left); - value = ts.createPropertyAccess(expressionTemp, left.name, left); + target = ts.setTextRange(ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), left.name), left); + value = ts.setTextRange(ts.createPropertyAccess(expressionTemp, left.name), left); } else { target = left; value = left; } - return ts.createAssignment(target, ts.createMathPow(value, right, node), node); + return ts.setTextRange(ts.createAssignment(target, ts.createMathPow(value, right, node)), node); } function visitExponentiationExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); @@ -40096,15 +41515,7 @@ var ts; context.onSubstituteNode = onSubstituteNode; var currentSourceFile; var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - var isInConstructorWithCapturedSuper; + var hierarchyFacts; var convertedLoopState; var enabledSubstitutions; return transformSourceFile; @@ -40114,247 +41525,202 @@ var ts; } currentSourceFile = node; currentText = node.text; - var visited = saveStateAndInvoke(node, visitSourceFile); + var visited = visitSourceFile(node); ts.addEmitHelpers(visited, context.readEmitHelpers()); currentSourceFile = undefined; currentText = undefined; + hierarchyFacts = 0; return visited; } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); + function enterSubtree(excludeFacts, includeFacts) { + var ancestorFacts = hierarchyFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383; + return ancestorFacts; } - function dispatcher(node) { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - function saveStateAndInvoke(node, f) { - var savedEnclosingFunction = enclosingFunction; - var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - var savedEnclosingVariableStatement = enclosingVariableStatement; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var savedConvertedLoopState = convertedLoopState; - var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - isInConstructorWithCapturedSuper = false; - convertedLoopState = undefined; - } - onBeforeVisitNode(node); - var visited = f(node); - isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 185) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 131072)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - switch (currentNode.kind) { - case 205: - enclosingVariableStatement = currentNode; - break; - case 224: - case 223: - case 174: - case 172: - case 173: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - function returnCapturedThis(node) { - return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 216 && !node.expression; + return hierarchyFacts & 4096 + && node.kind === 218 + && !node.expression; } - function shouldCheckNode(node) { - return (node.transformFlags & 64) !== 0 || - node.kind === 219 || - (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); + function shouldVisitNode(node) { + return (node.transformFlags & 128) !== 0 + || convertedLoopState !== undefined + || (hierarchyFacts & 4096 && ts.isStatement(node)) + || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } - function visitorWorker(node) { - if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { - return returnCapturedThis(node); - } - else if (shouldCheckNode(node)) { + function visitor(node) { + if (shouldVisitNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { - return ts.visitEachChild(node, visitor, context); - } else { return node; } } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); + function functionBodyVisitor(node) { + if (shouldVisitNode(node)) { + return visitBlock(node, true); } - else { - result = visitNodesInConvertedLoop(node); - } - return result; + return node; } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 216: - node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; - return visitReturnStatement(node); - case 205: - return visitVariableStatement(node); - case 218: - return visitSwitchStatement(node); - case 215: - case 214: - return visitBreakOrContinueStatement(node); - case 98: - return visitThisKeyword(node); - case 70: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); + function callExpressionVisitor(node) { + if (node.kind === 96) { + return visitSuperKeyword(true); } + return visitor(node); } function visitJavaScript(node) { switch (node.kind) { case 114: return undefined; - case 226: + case 228: return visitClassDeclaration(node); - case 197: + case 198: return visitClassExpression(node); - case 144: + case 145: return visitParameter(node); - case 225: + case 227: return visitFunctionDeclaration(node); - case 185: + case 186: return visitArrowFunction(node); - case 184: + case 185: return visitFunctionExpression(node); - case 223: + case 225: return visitVariableDeclaration(node); case 70: return visitIdentifier(node); - case 224: + case 226: return visitVariableDeclarationList(node); - case 219: + case 220: + return visitSwitchStatement(node); + case 234: + return visitCaseBlock(node); + case 206: + return visitBlock(node, false); + case 217: + case 216: + return visitBreakOrContinueStatement(node); + case 221: return visitLabeledStatement(node); - case 209: - return visitDoStatement(node); - case 210: - return visitWhileStatement(node); case 211: - return visitForStatement(node); case 212: - return visitForInStatement(node); + return visitDoOrWhileStatement(node, undefined); case 213: - return visitForOfStatement(node); - case 207: + return visitForStatement(node, undefined); + case 214: + return visitForInStatement(node, undefined); + case 215: + return visitForOfStatement(node, undefined); + case 209: return visitExpressionStatement(node); - case 176: + case 177: return visitObjectLiteralExpression(node); - case 256: + case 259: return visitCatchClause(node); - case 258: + case 261: return visitShorthandPropertyAssignment(node); - case 175: + case 143: + return visitComputedPropertyName(node); + case 176: return visitArrayLiteralExpression(node); - case 179: - return visitCallExpression(node); case 180: + return visitCallExpression(node); + case 181: return visitNewExpression(node); - case 183: + case 184: return visitParenthesizedExpression(node, true); - case 192: + case 193: return visitBinaryExpression(node, true); case 12: case 13: case 14: case 15: return visitTemplateLiteral(node); - case 181: + case 182: return visitTaggedTemplateExpression(node); - case 194: - return visitTemplateExpression(node); case 195: - return visitYieldExpression(node); + return visitTemplateExpression(node); case 196: + return visitYieldExpression(node); + case 197: return visitSpreadElement(node); case 96: - return visitSuperKeyword(); - case 195: - return ts.visitEachChild(node, visitor, context); - case 149: + return visitSuperKeyword(false); + case 98: + return visitThisKeyword(node); + case 203: + return visitMetaProperty(node); + case 150: return visitMethodDeclaration(node); - case 205: + case 152: + case 153: + return visitAccessorDeclaration(node); + case 207: return visitVariableStatement(node); + case 218: + return visitReturnStatement(node); default: - ts.Debug.failBadSyntaxKind(node); return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { + var ancestorFacts = enterSubtree(3968, 64); var statements = []; startLexicalEnvironment(); var statementOffset = ts.addPrologueDirectives(statements, node.statements, false, visitor); addCaptureThisForNodeIfNeeded(statements, node); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + exitSubtree(ancestorFacts, 0, 0); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } function visitSwitchStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps |= 2; - var result = ts.visitEachChild(node, visitor, context); - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; + if (convertedLoopState !== undefined) { + var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps |= 2; + var result = ts.visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + return ts.visitEachChild(node, visitor, context); + } + function visitCaseBlock(node) { + var ancestorFacts = enterSubtree(4032, 0); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0, 0); + return updated; + } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function visitReturnStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - convertedLoopState.nonLocalJumps |= 8; - return ts.createReturn(ts.createObjectLiteral([ - ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression - ? ts.visitNode(node.expression, visitor, ts.isExpression) - : ts.createVoidZero()) - ])); + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8; + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + node = returnCapturedThis(node); + } + return ts.createReturn(ts.createObjectLiteral([ + ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression + ? ts.visitNode(node.expression, visitor, ts.isExpression) + : ts.createVoidZero()) + ])); + } + else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 185) { - convertedLoopState.containsLexicalThis = true; - return node; + if (convertedLoopState) { + if (hierarchyFacts & 2) { + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + return node; } function visitIdentifier(node) { if (!convertedLoopState) { @@ -40363,20 +41729,20 @@ var ts; if (ts.isGeneratedIdentifier(node)) { return node; } - if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + if (node.text !== "arguments" || !resolver.isArgumentsLocalBinding(node)) { return node; } return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 215 ? 2 : 4; - var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + var jump = node.kind === 217 ? 2 : 4; + var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(node.label.text)) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 215) { + if (node.kind === 217) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -40386,7 +41752,7 @@ var ts; } } else { - if (node.kind === 215) { + if (node.kind === 217) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -40419,8 +41785,9 @@ var ts; var variable = ts.createVariableDeclaration(ts.getLocalName(node, true), undefined, transformClassLikeDeclarationToExpression(node)); ts.setOriginalNode(variable, node); var statements = []; - var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable]), node); + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable])); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, node); ts.startOnNewLine(statement); statements.push(statement); if (ts.hasModifier(node, 1)) { @@ -40475,23 +41842,29 @@ var ts; ts.setEmitFlags(statement, 1536 | 384); statements.push(statement); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true); ts.setEmitFlags(block, 1536); return block; } function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node)), extendsClauseElement)); + statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node))), extendsClauseElement)); } } function addConstructor(statements, node, extendsClauseElement) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16278, 73); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); + var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); + ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { ts.setEmitFlags(constructorFunction, 8); } statements.push(constructorFunction); + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; } function transformConstructorParameters(constructor, hasSynthesizedSuper) { return ts.visitParameterList(constructor && !hasSynthesizedSuper && constructor.parameters, visitor, context) @@ -40512,41 +41885,45 @@ var ts; addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94; + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); if (superCaptureStatus === 1 || superCaptureStatus === 2) { statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { - isInConstructorWithCapturedSuper = superCaptureStatus === 1; - return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); - }); - ts.addRange(statements, body); + if (superCaptureStatus === 1) { + hierarchyFacts |= 4096; + } + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset)); } - if (extendsClauseElement + if (isDerivedClass && superCaptureStatus !== 2 && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createIdentifier("_this"))); } ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); + if (constructor) { + prependCaptureNewTargetIfNeeded(statements, constructor, false); + } + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true); + ts.setTextRange(block, constructor ? constructor.body : node); if (!constructor) { ts.setEmitFlags(block, 1536); } return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 216) { + if (statement.kind === 218) { return true; } - else if (statement.kind === 208) { + else if (statement.kind === 210) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 204) { + else if (statement.kind === 206) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -40554,8 +41931,8 @@ var ts; } return false; } - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { - if (!hasExtendsClause) { + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, isDerivedClass, hasSynthesizedSuper, statementOffset) { + if (!isDerivedClass) { if (ctor) { addCaptureThisForNodeIfNeeded(statements, ctor); } @@ -40575,44 +41952,43 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 207 && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + if (firstStatement.kind === 209 && ts.isSuperCall(firstStatement.expression)) { + superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } if (superCallExpression && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 | 32768))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 192 - || superCallExpression.left.kind !== 179) { + if (superCallExpression.kind !== 193 + || superCallExpression.left.kind !== 180) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } ts.setCommentRange(returnStatement, ts.getCommentRange(ts.setEmitFlags(superCallExpression.left, 1536))); statements.push(returnStatement); return 2; } - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement); if (superCallExpression) { return 1; } return 0; } + function createActualThis() { + return ts.setEmitFlags(ts.createThis(), 4); + } function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 4); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); + return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createIdentifier("_super"), ts.createNull()), ts.createFunctionApply(ts.createIdentifier("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis()); } function visitParameter(node) { if (node.dotDotDotToken) { return undefined; } else if (ts.isBindingPattern(node.name)) { - return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined, node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined), node), node); } else if (node.initializer) { - return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined, node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined), node), node); } else { return node; @@ -40627,15 +42003,15 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_36 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_36)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_36, initializer); + if (ts.isBindingPattern(name)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_36, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer); } } } @@ -40650,10 +42026,11 @@ var ts; } function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer)), parameter)) - ], parameter), 1 | 32 | 384), undefined, parameter); + var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([ + ts.createStatement(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer))), parameter)) + ]), parameter), 1 | 32 | 384)); statement.startsOnNewLine = true; + ts.setTextRange(statement, parameter); ts.setEmitFlags(statement, 384 | 32 | 524288); statements.push(statement); } @@ -40670,22 +42047,22 @@ var ts; var expressionName = ts.getSynthesizedClone(parameter.name); var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) - ]), parameter), 524288)); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ])), parameter), 524288)); + var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) - ], parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), parameter), ts.createPostfixIncrement(temp, parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 + ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([ + ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp - : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), parameter)) + : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), parameter)) ])); ts.setEmitFlags(forStatement, 524288); ts.startOnNewLine(forStatement); statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 && node.kind !== 185) { + if (node.transformFlags & 32768 && node.kind !== 186) { captureThisForNode(statements, node, ts.createThis()); } } @@ -40693,29 +42070,62 @@ var ts; enableSubstitutionsForCapturedThis(); var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration("_this", undefined, initializer) - ]), originalStatement); + ])); ts.setEmitFlags(captureThisStatement, 1536 | 524288); + ts.setTextRange(captureThisStatement, originalStatement); ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } + function prependCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { + if (hierarchyFacts & 16384) { + var newTarget = void 0; + switch (node.kind) { + case 186: + return statements; + case 150: + case 152: + case 153: + newTarget = ts.createVoidZero(); + break; + case 151: + newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); + break; + case 227: + case 185: + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 92, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + var captureNewTargetStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_newTarget", undefined, newTarget) + ])); + if (copyOnWrite) { + return [captureNewTargetStatement].concat(statements); + } + statements.unshift(captureNewTargetStatement); + } + return statements; + } function addClassMembers(statements, node) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 203: + case 205: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 149: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + case 150: + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 151: case 152: + case 153: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 150: + case 151: break; default: ts.Debug.failBadSyntaxKind(node); @@ -40724,28 +42134,32 @@ var ts; } } function transformSemicolonClassElementToStatement(member) { - return ts.createEmptyStatement(member); + return ts.setTextRange(ts.createEmptyStatement(), member); } - function transformClassMethodDeclarationToStatement(receiver, member) { + function transformClassMethodDeclarationToStatement(receiver, member, container) { + var ancestorFacts = enterSubtree(0, 0); var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name); - var memberFunction = transformFunctionLikeToExpression(member, member, undefined); + var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container); ts.setEmitFlags(memberFunction, 1536); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), member); + var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); ts.setEmitFlags(statement, 48); + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return statement; } - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), ts.getSourceMapRange(accessors.firstAccessor)); + function transformAccessorsToStatement(receiver, accessors, container) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, false)); ts.setEmitFlags(statement, 1536); + ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + var ancestorFacts = enterSubtree(0, 0); var target = ts.getMutableClone(receiver); ts.setEmitFlags(target, 1536 | 32); ts.setSourceMapRange(target, firstAccessor.name); @@ -40754,7 +42168,7 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); + var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); ts.setEmitFlags(getterFunction, 512); var getter = ts.createPropertyAssignment("get", getterFunction); @@ -40762,51 +42176,86 @@ var ts; properties.push(getter); } if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); + var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); ts.setEmitFlags(setterFunction, 512); var setter = ts.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } - properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); + properties.push(ts.createPropertyAssignment("enumerable", ts.createTrue()), ts.createPropertyAssignment("configurable", ts.createTrue())); var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ target, propertyName, - ts.createObjectLiteral(properties, undefined, true) + ts.createObjectLiteral(properties, true) ]); if (startsOnNewLine) { call.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return call; } function visitArrowFunction(node) { if (node.transformFlags & 16384) { enableSubstitutionsForCapturedThis(); } - var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node), node); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16256, 66); + var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + ts.setTextRange(func, node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8); + exitSubtree(ancestorFacts, 0, 0); + convertedLoopState = savedConvertedLoopState; return func; } function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + var ancestorFacts = ts.getEmitFlags(node) & 131072 + ? enterSubtree(16278, 69) + : enterSubtree(16286, 65); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionExpression(node, undefined, name, undefined, parameters, undefined, body); } function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286, 65); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, undefined, parameters, undefined, body); } - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 185) { - enclosingNonArrowFunction = node; + function transformFunctionLikeToExpression(node, location, name, container) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32) + ? enterSubtree(16286, 65 | 8) + : enterSubtree(16286, 65); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (hierarchyFacts & 16384 && !name && (node.kind === 227 || node.kind === 185)) { + name = ts.getGeneratedNameForNode(node); } - var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body), location), node); } function transformFunctionBody(node) { var multiLine = false; @@ -40834,7 +42283,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 185); + ts.Debug.assert(node.kind === 186); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -40846,17 +42295,20 @@ var ts; } } var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, body); + var returnStatement = ts.createReturn(expression); + ts.setTextRange(returnStatement, body); ts.setEmitFlags(returnStatement, 384 | 32 | 1024); statements.push(returnStatement); closeBraceLocation = body; } var lexicalEnvironment = context.endLexicalEnvironment(); ts.addRange(statements, lexicalEnvironment); + prependCaptureNewTargetIfNeeded(statements, node, false); if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), multiLine); + ts.setTextRange(block, node.body); if (!multiLine && singleLine) { ts.setEmitFlags(block, 1); } @@ -40866,11 +42318,26 @@ var ts; ts.setOriginalNode(block, node.body); return block; } + function visitFunctionBodyDownLevel(node) { + var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); + return ts.updateBlock(updated, ts.setTextRange(ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, true)), updated.statements)); + } + function visitBlock(node, isFunctionBody) { + if (isFunctionBody) { + return ts.visitEachChild(node, visitor, context); + } + var ancestorFacts = hierarchyFacts & 256 + ? enterSubtree(4032, 512) + : enterSubtree(3904, 128); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0, 0); + return updated; + } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 183: + case 184: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 192: + case 193: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -40878,9 +42345,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (!needsDestructuringValue) { switch (node.expression.kind) { - case 183: + case 184: return ts.updateParen(node, visitParenthesizedExpression(node.expression, false)); - case 192: + case 193: return ts.updateParen(node, visitBinaryExpression(node.expression, false)); } } @@ -40890,9 +42357,12 @@ var ts; if (ts.isDestructuringAssignment(node)) { return ts.flattenDestructuringAssignment(node, visitor, context, 0, needsDestructuringValue); } + return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3) == 0) { + var ancestorFacts = enterSubtree(0, ts.hasModifier(node, 1) ? 32 : 0); + var updated; + if (convertedLoopState && (node.declarationList.flags & 3) === 0) { var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; @@ -40909,49 +42379,55 @@ var ts; } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); + updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); })), node); } else { - return undefined; + updated = undefined; } } - return ts.visitEachChild(node, visitor, context); + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0, 0); + return updated; } function visitVariableDeclarationList(node) { - if (node.flags & 3) { - enableSubstitutionsForBlockScopedBindings(); + if (node.transformFlags & 64) { + if (node.flags & 3) { + enableSubstitutionsForBlockScopedBindings(); + } + var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + var declarationList = ts.createVariableDeclarationList(declarations); + ts.setOriginalNode(declarationList, node); + ts.setTextRange(declarationList, node); + ts.setCommentRange(declarationList, node); + if (node.transformFlags & 8388608 + && (ts.isBindingPattern(node.declarations[0].name) + || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + var firstDeclaration = ts.firstOrUndefined(declarations); + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } + return declarationList; } - var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, node); - ts.setOriginalNode(declarationList, node); - ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { - var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - } - return declarationList; + return ts.visitEachChild(node, visitor, context); } function shouldEmitExplicitInitializerForLetDeclaration(node) { var flags = resolver.getNodeCheckFlags(node); var isCapturedInFunction = flags & 131072; var isDeclaredInLoop = flags & 262144; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + var emittedAsTopLevel = (hierarchyFacts & 64) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); + && (hierarchyFacts & 512) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 212 - && enclosingBlockScopeContainer.kind !== 213 + && (hierarchyFacts & 2048) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, false))); + && (hierarchyFacts & (1024 | 2048)) === 0)); return emitExplicitInitializer; } function visitVariableDeclarationInLetDeclarationList(node) { @@ -40967,54 +42443,57 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableDeclaration(node) { + var ancestorFacts = enterSubtree(32, 0); + var updated; if (ts.isBindingPattern(node.name)) { - var hoistTempVariables = enclosingVariableStatement - && ts.hasModifier(enclosingVariableStatement, 1); - return ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, hoistTempVariables); - } - return ts.visitEachChild(node, visitor, context); - } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; - } - var result; - if (ts.isIterationStatement(node.statement, false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, (ancestorFacts & 32) !== 0); } else { - result = ts.visitEachChild(node, visitor, context); + updated = ts.visitEachChild(node, visitor, context); } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + exitSubtree(ancestorFacts, 0, 0); + return updated; + } + function recordLabel(node) { + convertedLoopState.labels.set(node.label.text, node.label.text); + } + function resetLabel(node) { + convertedLoopState.labels.set(node.label.text, undefined); + } + function visitLabeledStatement(node) { + if (convertedLoopState && !convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); } - return result; + var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, false) && shouldConvertIterationStatementBody(statement) + ? visitIterationStatement(statement, node) + : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { + var ancestorFacts = enterSubtree(excludeFacts, includeFacts); + var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); + exitSubtree(ancestorFacts, 0, 0); + return updated; } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitDoOrWhileStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(0, 256, node, outermostLabeledStatement); } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(3008, 1280, node, outermostLabeledStatement); } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForInStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement); } - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function visitForOfStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement, convertForOfToFor); } - function convertForOfToFor(node, convertedLoopBodyStatements) { + function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var initializer = node.initializer; var statements = []; var counter = ts.createLoopVariable(); var rhsReference = expression.kind === 70 - ? ts.createUniqueName(expression.text) + ? ts.createUniqueName(ts.unescapeIdentifier(expression.text)) : ts.createTempVariable(undefined); var elementAccess = ts.createElementAccess(rhsReference, counter); if (ts.isVariableDeclarationList(initializer)) { @@ -41024,17 +42503,18 @@ var ts; var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, elementAccess); - var declarationList = ts.createVariableDeclarationList(declarations, initializer); + var declarationList = ts.createVariableDeclarationList(declarations); ts.setOriginalNode(declarationList, initializer); + ts.setTextRange(declarationList, initializer); var firstDeclaration = declarations[0]; var lastDeclaration = ts.lastOrUndefined(declarations); ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); statements.push(ts.createVariableStatement(undefined, declarationList)); } else { - statements.push(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.createVariableDeclarationList([ + statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, ts.createElementAccess(rhsReference, counter)) - ], ts.moveRangePos(initializer, -1)), initializer), ts.moveRangeEnd(initializer, -1))); + ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); } } else { @@ -41044,7 +42524,7 @@ var ts; } else { assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createStatement(assignment), ts.moveRangeEnd(initializer, -1))); } } var bodyLocation; @@ -41053,7 +42533,7 @@ var ts; ts.addRange(statements, convertedLoopBodyStatements); } else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + var statement = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -41064,38 +42544,62 @@ var ts; } } ts.setEmitFlags(expression, 48 | ts.getEmitFlags(expression)); - var body = ts.createBlock(ts.createNodeArray(statements, statementsLocation), bodyLocation); + var body = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation)); + ts.setTextRange(body, bodyLocation); ts.setEmitFlags(body, 48 | 384); - var forStatement = ts.createFor(ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0), ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) - ], node.expression), 1048576), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); + var forStatement = ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)), + ts.setTextRange(ts.createVariableDeclaration(rhsReference, undefined, expression), node.expression) + ]), node.expression), 1048576), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), body); ts.setEmitFlags(forStatement, 256); - return forStatement; + ts.setTextRange(forStatement, node); + return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); + } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 211: + case 212: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 213: + return visitForStatement(node, outermostLabeledStatement); + case 214: + return visitForInStatement(node, outermostLabeledStatement); + case 215: + return visitForOfStatement(node, outermostLabeledStatement); + } } function visitObjectLiteralExpression(node) { var properties = node.properties; var numProperties = properties.length; var numInitialProperties = numProperties; + var numInitialPropertiesWithoutYield = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 - || property.name.kind === 142) { + if ((property.transformFlags & 16777216 && hierarchyFacts & 4) + && i < numInitialPropertiesWithoutYield) { + numInitialPropertiesWithoutYield = i; + } + if (property.name.kind === 143) { numInitialProperties = i; break; } } - ts.Debug.assert(numInitialProperties !== numProperties); - var temp = ts.createTempVariable(hoistVariableDeclaration); - var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); - if (node.multiLine) { - assignment.startsOnNewLine = true; + if (numInitialProperties !== numProperties) { + if (numInitialPropertiesWithoutYield < numInitialProperties) { + numInitialProperties = numInitialPropertiesWithoutYield; + } + var temp = ts.createTempVariable(hoistVariableDeclaration); + var expressions = []; + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 32768)); + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + expressions.push(assignment); + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); + return ts.inlineExpressions(expressions); } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); + return ts.visitEachChild(node, visitor, context); } function shouldConvertIterationStatementBody(node) { return (resolver.getNodeCheckFlags(node) & 65536) !== 0; @@ -41119,14 +42623,16 @@ var ts; } } } - function convertIterationStatementBodyIfNecessary(node, convert) { + function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) { if (!shouldConvertIterationStatementBody(node)) { var saveAllowedNonLabeledJumps = void 0; if (convertedLoopState) { saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; convertedLoopState.allowedNonLabeledJumps = 2 | 4; } - var result = convert ? convert(node, undefined) : ts.visitEachChild(node, visitor, context); + var result = convert + ? convert(node, outermostLabeledStatement, undefined) + : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel); if (convertedLoopState) { convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } @@ -41135,11 +42641,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 211: - case 212: case 213: + case 214: + case 215: var initializer = node.initializer; - if (initializer && initializer.kind === 224) { + if (initializer && initializer.kind === 226) { loopInitializer = initializer; } break; @@ -41166,7 +42672,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -41176,13 +42682,15 @@ var ts; copyOutParameters(loopOutParameters, 1, statements_4); } ts.addRange(statements_4, lexicalEnvironment); - loopBody = ts.createBlock(statements_4, undefined, true); + loopBody = ts.createBlock(statements_4, true); } - if (!ts.isBlock(loopBody)) { - loopBody = ts.createBlock([loopBody], undefined, true); + if (ts.isBlock(loopBody)) { + loopBody.multiLine = true; } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 131072) !== 0 + else { + loopBody = ts.createBlock([loopBody], true); + } + var isAsyncBlockContainingAwait = hierarchyFacts & 4 && (node.statement.transformFlags & 16777216) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -41241,19 +42749,18 @@ var ts; var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); var loop; if (convert) { - loop = convert(node, convertedLoopBodyStatements); + loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); } else { - loop = ts.getMutableClone(node); - loop.statement = undefined; - loop = ts.visitEachChild(loop, visitor, context); - loop.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); + var clone_4 = ts.getMutableClone(node); + clone_4.statement = undefined; + clone_4 = ts.visitEachChild(clone_4, visitor, context); + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, true); + clone_4.transformFlags = 0; + ts.aggregateTransformFlags(clone_4); + loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } - statements.push(currentParent.kind === 219 - ? ts.createLabel(currentParent.label, loop) - : loop); + statements.push(loop); return statements; } function copyOutParameter(outParam, copyDirection) { @@ -41312,23 +42819,22 @@ var ts; if (!state.labeledNonLocalBreaks) { state.labeledNonLocalBreaks = ts.createMap(); } - state.labeledNonLocalBreaks[labelText] = labelMarker; + state.labeledNonLocalBreaks.set(labelText, labelMarker); } else { if (!state.labeledNonLocalContinues) { state.labeledNonLocalContinues = ts.createMap(); } - state.labeledNonLocalContinues[labelText] = labelMarker; + state.labeledNonLocalContinues.set(labelText, labelMarker); } } function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { if (!table) { return; } - for (var labelText in table) { - var labelMarker = table[labelText]; + table.forEach(function (labelMarker, labelText) { var statements = []; - if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { + if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) { var label = ts.createIdentifier(labelText); statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); } @@ -41337,7 +42843,7 @@ var ts; statements.push(ts.createReturn(loopResultName)); } caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); - } + }); } function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { var name = decl.name; @@ -41352,7 +42858,7 @@ var ts; else { loopParameters.push(ts.createParameter(undefined, undefined, undefined, name)); if (resolver.getNodeCheckFlags(decl) & 2097152) { - var outParamName = ts.createUniqueName("out_" + name.text); + var outParamName = ts.createUniqueName("out_" + ts.unescapeIdentifier(name.text)); loopOutParameters.push({ originalName: name, outParamName: outParamName }); } } @@ -41363,22 +42869,22 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 151: case 152: + case 153: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 257: + case 150: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); + break; + case 260: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 258: + case 261: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 149: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); - break; default: ts.Debug.failBadSyntaxKind(node); break; @@ -41386,34 +42892,49 @@ var ts; } } function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } return expression; } function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } return expression; } - function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined), method); + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { + var ancestorFacts = enterSubtree(0, 0); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container)); + ts.setTextRange(expression, method); if (startsOnNewLine) { expression.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return expression; } function visitCatchClause(node) { - ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); - var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); - var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); - var destructure = ts.createVariableStatement(undefined, list); - return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + var ancestorFacts = enterSubtree(4032, 0); + var updated; + if (ts.isBindingPattern(node.variableDeclaration.name)) { + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp); + ts.setTextRange(newVariableDeclaration, node.variableDeclaration); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); + var list = ts.createVariableDeclarationList(vars); + ts.setTextRange(list, node.variableDeclaration); + var destructure = ts.createVariableStatement(undefined, list); + updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0, 0); + return updated; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); @@ -41421,21 +42942,43 @@ var ts; } function visitMethodDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); + var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined); ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression)); - return ts.createPropertyAssignment(node.name, functionExpression, node); + return ts.setTextRange(ts.createPropertyAssignment(node.name, functionExpression), node); + } + function visitAccessorDeclaration(node) { + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286, 65); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return updated; } function visitShorthandPropertyAssignment(node) { - return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), node); + return ts.setTextRange(ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name)), node); + } + function visitComputedPropertyName(node) { + var ancestorFacts = enterSubtree(0, 8192); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 32768 : 0); + return updated; } function visitYieldExpression(node) { return ts.visitEachChild(node, visitor, context); } function visitArrayLiteralExpression(node) { - return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + if (node.transformFlags & 64) { + return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + } + return ts.visitEachChild(node, visitor, context); } function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + if (node.transformFlags & 64) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + } + return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); } function visitImmediateSuperCallInBody(node) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, false); @@ -41447,25 +42990,27 @@ var ts; } var resultingCall; if (node.transformFlags & 524288) { - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } if (node.expression.kind === 96) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4); var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis + resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createIdentifier("_this"), initializer) : initializer; } - return resultingCall; + return ts.setOriginalNode(resultingCall, node); } function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 524288) !== 0); - var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + if (node.transformFlags & 524288) { + var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + } + return ts.visitEachChild(node, visitor, context); } function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { var numElements = elements.length; @@ -41474,7 +43019,7 @@ var ts; })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 175 + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 176 ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -41489,7 +43034,7 @@ var ts; return ts.map(chunk, visitExpressionOfSpread); } function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) { - return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, undefined, hasTrailingComma), visitor, ts.isExpression), undefined, multiLine); + return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -41498,7 +43043,7 @@ var ts; return ts.visitNode(node.expression, visitor, ts.isExpression); } function visitTemplateLiteral(node) { - return ts.createLiteral(node.text, node); + return ts.setTextRange(ts.createLiteral(node.text), node); } function visitTaggedTemplateExpression(node) { var tag = ts.visitNode(node.tag, visitor, ts.isExpression); @@ -41532,7 +43077,7 @@ var ts; var isLast = node.kind === 12 || node.kind === 15; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); - return ts.createLiteral(text, node); + return ts.setTextRange(ts.createLiteral(text), node); } function visitTemplateExpression(node) { var expressions = []; @@ -41540,7 +43085,8 @@ var ts; addTemplateSpans(expressions, node); var expression = ts.reduceLeft(expressions, ts.createAdd); if (ts.nodeIsSynthesized(expression)) { - ts.setTextRange(expression, node); + expression.pos = node.pos; + expression.end = node.end; } return expression; } @@ -41563,21 +43109,34 @@ var ts; } } } - function visitSuperKeyword() { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 179 + function visitSuperKeyword(isExpressionOfCall) { + return hierarchyFacts & 8 + && !isExpressionOfCall ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } - function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; - if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { - enclosingFunction = node; + function visitMetaProperty(node) { + if (node.keywordToken === 93 && node.name.text === "target") { + if (hierarchyFacts & 8192) { + hierarchyFacts |= 32768; + } + else { + hierarchyFacts |= 16384; + } + return ts.createIdentifier("_newTarget"); } - previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; + return node; + } + function onEmitNode(hint, node, emitCallback) { + if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { + var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8 + ? 65 | 16 + : 65); + previousOnEmitNode(hint, node, emitCallback); + exitSubtree(ancestorFacts, 0, 0); + return; + } + previousOnEmitNode(hint, node, emitCallback); } function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { @@ -41589,18 +43148,18 @@ var ts; if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; context.enableSubstitution(98); - context.enableEmitNotification(150); - context.enableEmitNotification(149); context.enableEmitNotification(151); + context.enableEmitNotification(150); context.enableEmitNotification(152); + context.enableEmitNotification(153); + context.enableEmitNotification(186); context.enableEmitNotification(185); - context.enableEmitNotification(184); - context.enableEmitNotification(225); + context.enableEmitNotification(227); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -41620,10 +43179,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 174: - case 226: - case 229: - case 223: + case 175: + case 228: + case 231: + case 225: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -41649,9 +43208,8 @@ var ts; } function substituteThisKeyword(node) { if (enabledSubstitutions & 1 - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 8) { - return ts.createIdentifier("_this", node); + && hierarchyFacts & 16) { + return ts.setTextRange(ts.createIdentifier("_this"), node); } return node; } @@ -41667,11 +43225,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 207) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 209) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 179) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 180) { return false; } var callTarget = statementExpression.expression; @@ -41679,7 +43237,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 196) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 197) { return false; } var expression = callArgument.expression; @@ -41698,18 +43256,90 @@ var ts; name: "typescript:extends", scoped: false, priority: 0, - text: "\n var __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 };" + text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; })(ts || (ts = {})); var ts; (function (ts) { - var instructionNames = ts.createMap((_a = {}, - _a[2] = "return", - _a[3] = "break", - _a[4] = "yield", - _a[5] = "yield*", - _a[7] = "endfinally", - _a)); + function transformES5(context) { + var compilerOptions = context.getCompilerOptions(); + var previousOnEmitNode; + var noSubstitution; + if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) { + previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.enableEmitNotification(250); + context.enableEmitNotification(251); + context.enableEmitNotification(249); + noSubstitution = []; + } + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(178); + context.enableSubstitution(260); + return transformSourceFile; + function transformSourceFile(node) { + return node; + } + function onEmitNode(hint, node, emitCallback) { + switch (node.kind) { + case 250: + case 251: + case 249: + var tagName = node.tagName; + noSubstitution[ts.getOriginalNodeId(tagName)] = true; + break; + } + previousOnEmitNode(hint, node, emitCallback); + } + function onSubstituteNode(hint, node) { + if (node.id && noSubstitution && noSubstitution[node.id]) { + return previousOnSubstituteNode(hint, node); + } + node = previousOnSubstituteNode(hint, node); + if (ts.isPropertyAccessExpression(node)) { + return substitutePropertyAccessExpression(node); + } + else if (ts.isPropertyAssignment(node)) { + return substitutePropertyAssignment(node); + } + return node; + } + function substitutePropertyAccessExpression(node) { + var literalName = trySubstituteReservedName(node.name); + if (literalName) { + return ts.setTextRange(ts.createElementAccess(node.expression, literalName), node); + } + return node; + } + function substitutePropertyAssignment(node) { + var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); + if (literalName) { + return ts.updatePropertyAssignment(node, literalName, node.initializer); + } + return node; + } + function trySubstituteReservedName(name) { + var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); + if (token >= 71 && token <= 106) { + return ts.setTextRange(ts.createLiteral(name), name); + } + return undefined; + } + } + ts.transformES5 = transformES5; +})(ts || (ts = {})); +var ts; +(function (ts) { + function getInstructionName(instruction) { + switch (instruction) { + case 2: return "return"; + case 3: return "break"; + case 4: return "yield"; + case 5: return "yield*"; + case 7: return "endfinally"; + } + } function transformGenerators(context) { var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); @@ -41775,13 +43405,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 209: + case 211: return visitDoStatement(node); - case 210: + case 212: return visitWhileStatement(node); - case 218: + case 220: return visitSwitchStatement(node); - case 219: + case 221: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -41789,24 +43419,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 225: + case 227: return visitFunctionDeclaration(node); - case 184: + case 185: return visitFunctionExpression(node); - case 151: case 152: + case 153: return visitAccessorDeclaration(node); - case 205: + case 207: return visitVariableStatement(node); - case 211: + case 213: return visitForStatement(node); - case 212: - return visitForInStatement(node); - case 215: - return visitBreakStatement(node); case 214: - return visitContinueStatement(node); + return visitForInStatement(node); + case 217: + return visitBreakStatement(node); case 216: + return visitContinueStatement(node); + case 218: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -41822,21 +43452,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 192: - return visitBinaryExpression(node); case 193: + return visitBinaryExpression(node); + case 194: return visitConditionalExpression(node); - case 195: + case 196: return visitYieldExpression(node); - case 175: - return visitArrayLiteralExpression(node); case 176: + return visitArrayLiteralExpression(node); + case 177: return visitObjectLiteralExpression(node); - case 178: - return visitElementAccessExpression(node); case 179: - return visitCallExpression(node); + return visitElementAccessExpression(node); case 180: + return visitCallExpression(node); + case 181: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -41844,9 +43474,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 225: + case 227: return visitFunctionDeclaration(node); - case 184: + case 185: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -41855,7 +43485,7 @@ var ts; } function visitFunctionDeclaration(node) { if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { - node = ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body), node), node); + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration(undefined, node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -41876,7 +43506,7 @@ var ts; } function visitFunctionExpression(node) { if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { - node = ts.setOriginalNode(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body), node), node); + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -41946,7 +43576,7 @@ var ts; operationArguments = savedOperationArguments; operationLocations = savedOperationLocations; state = savedState; - return ts.createBlock(statements, body, body.multiLine); + return ts.setTextRange(ts.createBlock(statements, body.multiLine), body); } function visitVariableStatement(node) { if (node.transformFlags & 16777216) { @@ -42003,10 +43633,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 177: + case 178: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 178: + case 179: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -42015,7 +43645,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 57, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.setTextRange(ts.createAssignment(target, ts.setTextRange(ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression)), node)), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -42031,10 +43661,10 @@ var ts; else if (node.operatorToken.kind === 25) { return visitCommaExpression(node); } - var clone_4 = ts.getMutableClone(node); - clone_4.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_4.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_4; + var clone_5 = ts.getMutableClone(node); + clone_5.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_5.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_5; } return ts.visitEachChild(node, visitor, context); } @@ -42096,7 +43726,7 @@ var ts; emitYield(expression, node); } markLabel(resumeLabel); - return createGeneratorResume(); + return createGeneratorResume(node); } function visitArrayLiteralExpression(node) { return visitElements(node.elements, undefined, undefined, node.multiLine); @@ -42114,13 +43744,13 @@ var ts; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, location, multiLine); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { emitAssignment(temp, hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, undefined, multiLine)); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); hasAssignedTemp = true; leadingElement = undefined; expressions = []; @@ -42134,7 +43764,7 @@ var ts; var multiLine = node.multiLine; var numInitialProperties = countInitialNodesWithoutYield(properties); var temp = declareLocal(); - emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, multiLine)); + emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), multiLine)); var expressions = ts.reduceLeft(properties, reduceProperty, [], numInitialProperties); expressions.push(multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); return ts.inlineExpressions(expressions); @@ -42156,10 +43786,10 @@ var ts; } function visitElementAccessExpression(node) { if (containsYield(node.argumentExpression)) { - var clone_5 = ts.getMutableClone(node); - clone_5.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_5.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_5; + var clone_6 = ts.getMutableClone(node); + clone_6.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_6.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -42173,7 +43803,7 @@ var ts; function visitNewExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, ts.createVoidZero())), undefined, [], node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, ts.createVoidZero())), undefined, []), node), node); } return ts.visitEachChild(node, visitor, context); } @@ -42202,35 +43832,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 204: + case 206: return transformAndEmitBlock(node); - case 207: - return transformAndEmitExpressionStatement(node); - case 208: - return transformAndEmitIfStatement(node); case 209: - return transformAndEmitDoStatement(node); + return transformAndEmitExpressionStatement(node); case 210: - return transformAndEmitWhileStatement(node); + return transformAndEmitIfStatement(node); case 211: - return transformAndEmitForStatement(node); + return transformAndEmitDoStatement(node); case 212: - return transformAndEmitForInStatement(node); + return transformAndEmitWhileStatement(node); + case 213: + return transformAndEmitForStatement(node); case 214: - return transformAndEmitContinueStatement(node); - case 215: - return transformAndEmitBreakStatement(node); + return transformAndEmitForInStatement(node); case 216: - return transformAndEmitReturnStatement(node); + return transformAndEmitContinueStatement(node); case 217: - return transformAndEmitWithStatement(node); + return transformAndEmitBreakStatement(node); case 218: - return transformAndEmitSwitchStatement(node); + return transformAndEmitReturnStatement(node); case 219: - return transformAndEmitLabeledStatement(node); + return transformAndEmitWithStatement(node); case 220: - return transformAndEmitThrowStatement(node); + return transformAndEmitSwitchStatement(node); case 221: + return transformAndEmitLabeledStatement(node); + case 222: + return transformAndEmitThrowStatement(node); + case 223: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -42250,7 +43880,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - hoistVariableDeclaration(variable.name); + var name = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name, variable.name); + hoistVariableDeclaration(name); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -42280,7 +43912,7 @@ var ts; if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) { var endLabel = defineLabel(); var elseLabel = node.elseStatement ? defineLabel() : undefined; - emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression)); + emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), node.expression); transformAndEmitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { emitBreak(endLabel); @@ -42359,7 +43991,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression), initializer)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -42369,7 +44001,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression), node.incrementor)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -42514,7 +44146,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 254 && defaultClauseIndex === -1) { + if (clause.kind === 257 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -42524,7 +44156,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 253) { + if (clause.kind === 256) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -42626,9 +44258,9 @@ var ts; } return -1; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } return node; @@ -42640,17 +44272,17 @@ var ts; return node; } function substituteExpressionIdentifier(node) { - if (renamedCatchVariables && ts.hasProperty(renamedCatchVariables, node.text)) { + if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { var original = ts.getOriginalNode(node); if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_37) { - var clone_6 = ts.getMutableClone(name_37); - ts.setSourceMapRange(clone_6, node); - ts.setCommentRange(clone_6, node); - return clone_6; + var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; + if (name) { + var clone_7 = ts.getMutableClone(name); + ts.setSourceMapRange(clone_7, node); + ts.setCommentRange(clone_7, node); + return clone_7; } } } @@ -42755,10 +44387,10 @@ var ts; var name = declareLocal(text); if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); - renamedCatchVariableDeclarations = ts.createMap(); + renamedCatchVariableDeclarations = []; context.enableSubstitution(70); } - renamedCatchVariables[text] = true; + renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; var exception = peekBlock(); ts.Debug.assert(exception.state < 1); @@ -42959,23 +44591,23 @@ var ts; } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); - literal.trailingComment = instructionNames[instruction]; + literal.trailingComment = getInstructionName(instruction); return literal; } function createInlineBreak(label, location) { ts.Debug.assert(label > 0, "Invalid label: " + label); - return ts.createReturn(ts.createArrayLiteral([ + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), location); + ])), location); } function createInlineReturn(expression, location) { - return ts.createReturn(ts.createArrayLiteral(expression + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2), expression] - : [createInstruction(2)]), location); + : [createInstruction(2)])), location); } function createGeneratorResume(location) { - return ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, [], location); + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, []), location); } function emitNop() { emitWorker(0); @@ -43041,7 +44673,7 @@ var ts; currentExceptionBlock = undefined; withBlockStack = undefined; var buildResult = buildStatements(); - return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 262144)); + return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, buildResult.length > 0)), 262144)); } function buildStatements() { if (operations) { @@ -43250,51 +44882,51 @@ var ts; } } function writeAssign(left, right, operationLocation) { - writeStatement(ts.createStatement(ts.createAssignment(left, right), operationLocation)); + writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); } function writeThrow(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createThrow(expression, operationLocation)); + writeStatement(ts.setTextRange(ts.createThrow(expression), operationLocation)); } function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2), expression] - : [createInstruction(2)]), operationLocation)); + : [createInstruction(2)])), operationLocation), 384)); } function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation)); + ])), operationLocation), 384)); } function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation))); + ])), operationLocation), 384)), 1)); } function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation))); + ])), operationLocation), 384)), 1)); } function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4), expression] - : [createInstruction(4)]), operationLocation)); + : [createInstruction(4)])), operationLocation), 384)); } function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(5), expression - ]), operationLocation)); + ])), operationLocation), 384)); } function writeEndfinally() { lastOperationWasAbrupt = true; @@ -43314,110 +44946,586 @@ var ts; priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; - var _a; })(ts || (ts = {})); var ts; (function (ts) { - function transformES5(context) { - var previousOnSubstituteNode = context.onSubstituteNode; - context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(177); - context.enableSubstitution(257); - return transformSourceFile; - function transformSourceFile(node) { - return node; - } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (ts.isPropertyAccessExpression(node)) { - return substitutePropertyAccessExpression(node); + function transformModule(context) { + function getTransformModuleDelegate(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.AMD: return transformAMDModule; + case ts.ModuleKind.UMD: return transformUMDModule; + default: return transformCommonJSModule; } - else if (ts.isPropertyAssignment(node)) { - return substitutePropertyAssignment(node); - } - return node; } - function substitutePropertyAccessExpression(node) { - var literalName = trySubstituteReservedName(node.name); - if (literalName) { - return ts.createElementAccess(node.expression, literalName, node); - } - return node; - } - function substitutePropertyAssignment(node) { - var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); - if (literalName) { - return ts.updatePropertyAssignment(node, literalName, node.initializer); - } - return node; - } - function trySubstituteReservedName(name) { - var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); - if (token >= 71 && token <= 106) { - return ts.createLiteral(name, name); - } - return undefined; - } - } - ts.transformES5 = transformES5; -})(ts || (ts = {})); -var ts; -(function (ts) { - function transformES2015Module(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var compilerOptions = context.getCompilerOptions(); - var previousOnEmitNode = context.onEmitNode; + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var moduleKind = ts.getEmitModuleKind(compilerOptions); var previousOnSubstituteNode = context.onSubstituteNode; - context.onEmitNode = onEmitNode; + var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(261); + context.onEmitNode = onEmitNode; context.enableSubstitution(70); + context.enableSubstitution(193); + context.enableSubstitution(191); + context.enableSubstitution(192); + context.enableSubstitution(261); + context.enableEmitNotification(264); + var moduleInfoMap = []; + var deferredExports = []; var currentSourceFile; + var currentModuleInfo; + var noSubstitution; return transformSourceFile; function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { + if (ts.isDeclarationFile(node) + || !(ts.isExternalModule(node) + || compilerOptions.isolatedModules)) { return node; } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); - if (externalHelpersModuleName) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements); - ts.append(statements, ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + currentSourceFile = node; + currentModuleInfo = ts.collectExternalModuleInfo(node, resolver, compilerOptions); + moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo; + var transformModule = getTransformModuleDelegate(moduleKind); + var updated = transformModule(node); + currentSourceFile = undefined; + currentModuleInfo = undefined; + return ts.aggregateTransformFlags(updated); + } + function transformCommonJSModule(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + ts.addRange(statements, endLexicalEnvironment()); + addExportEqualsIfNeeded(statements, false); + var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); + if (currentModuleInfo.hasExportStarsToExportValues) { + ts.addEmitHelper(updated, exportStarHelper); + } + return updated; + } + function transformAMDModule(node) { + var define = ts.createIdentifier("define"); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ + ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter(undefined, undefined, undefined, "require"), + ts.createParameter(undefined, undefined, undefined, "exports") + ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ]))) + ]), node.statements)); + } + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.setTextRange(ts.createBlock([ + ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ + ts.createVariableStatement(undefined, [ + ts.createVariableDeclaration("v", undefined, ts.createCall(ts.createIdentifier("factory"), undefined, [ + ts.createIdentifier("require"), + ts.createIdentifier("exports") + ])) + ]), + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1) + ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), undefined, [ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createIdentifier("factory") + ])) + ]))) + ], true), undefined)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ + ts.createStatement(ts.createCall(umdHeader, undefined, [ + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter(undefined, undefined, undefined, "require"), + ts.createParameter(undefined, undefined, undefined, "exports") + ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ])) + ]), node.statements)); + } + function collectAsynchronousDependencies(node, includeNonAmdDependencies) { + var aliasedModuleNames = []; + var unaliasedModuleNames = []; + var importAliasNames = []; + for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { + var amdDependency = _a[_i]; + if (amdDependency.name) { + aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + importAliasNames.push(ts.createParameter(undefined, undefined, undefined, amdDependency.name)); } else { - return ts.visitEachChild(node, visitor, context); + unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); } } - return node; - } - function visitor(node) { - switch (node.kind) { - case 234: - return undefined; - case 240: - return visitExportAssignment(node); + for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) { + var importNode = _c[_b]; + var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); + if (includeNonAmdDependencies && importAliasName) { + ts.setEmitFlags(importAliasName, 4); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(undefined, undefined, undefined, importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } } - return node; + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; } - function visitExportAssignment(node) { - return node.isExportEquals ? undefined : node; + function transformAsynchronousModuleBody(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + ts.addRange(statements, endLexicalEnvironment()); + addExportEqualsIfNeeded(statements, true); + var body = ts.createBlock(statements, true); + if (currentModuleInfo.hasExportStarsToExportValues) { + ts.addEmitHelper(body, exportStarHelper); + } + return body; } - function onEmitNode(emitContext, node, emitCallback) { - if (ts.isSourceFile(node)) { - currentSourceFile = node; - previousOnEmitNode(emitContext, node, emitCallback); - currentSourceFile = undefined; + function addExportEqualsIfNeeded(statements, emitAsReturn) { + if (currentModuleInfo.exportEquals) { + if (emitAsReturn) { + var statement = ts.createReturn(currentModuleInfo.exportEquals.expression); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 384 | 1536); + statements.push(statement); + } + else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression)); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 1536); + statements.push(statement); + } + } + } + function sourceElementVisitor(node) { + switch (node.kind) { + case 237: + return visitImportDeclaration(node); + case 236: + return visitImportEqualsDeclaration(node); + case 243: + return visitExportDeclaration(node); + case 242: + return visitExportAssignment(node); + case 207: + return visitVariableStatement(node); + case 227: + return visitFunctionDeclaration(node); + case 228: + return visitClassDeclaration(node); + case 299: + return visitMergeDeclarationMarker(node); + case 300: + return visitEndOfDeclarationMarker(node); + default: + return node; + } + } + function visitImportDeclaration(node) { + var statements; + var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); + if (moduleKind !== ts.ModuleKind.AMD) { + if (!node.importClause) { + return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); + } + else { + var variables = []; + if (namespaceDeclaration && !ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, createRequireCall(node))); + } + else { + variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), undefined, createRequireCall(node))); + if (namespaceDeclaration && ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node))); + } + } + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, languageVersion >= 2 ? 2 : 0)), node)); + } + } + else if (namespaceDeclaration && ts.isDefaultImport(node)) { + statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node)), node) + ], languageVersion >= 2 ? 2 : 0))); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); } else { - previousOnEmitNode(emitContext, node, emitCallback); + statements = appendExportsOfImportDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + function createRequireCall(importNode) { + var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var args = []; + if (moduleName) { + args.push(moduleName); + } + return ts.createCall(ts.createIdentifier("require"), undefined, args); + } + function visitImportEqualsDeclaration(node) { + ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); + var statements; + if (moduleKind !== ts.ModuleKind.AMD) { + if (ts.hasModifier(node, 1)) { + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(node.name, createRequireCall(node))), node)); + } + else { + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node)) + ], languageVersion >= 2 ? 2 : 0)), node)); + } + } + else { + if (ts.hasModifier(node, 1)) { + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); + } + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportEqualsDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + function visitExportDeclaration(node) { + if (!node.moduleSpecifier) { + return undefined; + } + var generatedName = ts.getGeneratedNameForNode(node); + if (node.exportClause) { + var statements = []; + if (moduleKind !== ts.ModuleKind.AMD) { + statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(generatedName, undefined, createRequireCall(node)) + ])), node)); + } + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); + } + return ts.singleOrMany(statements); + } + else { + return ts.setTextRange(ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ + moduleKind !== ts.ModuleKind.AMD + ? createRequireCall(node) + : generatedName + ])), node); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (ts.isIdentifier(node) && emitContext === 1) { - return substituteExpressionIdentifier(node); + function visitExportAssignment(node) { + if (node.isExportEquals) { + return undefined; + } + var statements; + var original = node.original; + if (original && hasAssociatedEndOfDeclarationMarker(original)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), node.expression, node, true); + } + else { + statements = appendExportStatement(statements, ts.createIdentifier("default"), node.expression, node, true); + } + return ts.singleOrMany(statements); + } + function visitFunctionDeclaration(node) { + var statements; + if (ts.hasModifier(node, 1)) { + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, node.parameters, undefined, node.body), node), node)); + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + function visitClassDeclaration(node) { + var statements; + if (ts.hasModifier(node, 1)) { + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, node.heritageClauses, node.members), node), node)); + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + function visitVariableStatement(node) { + var statements; + var variables; + var expressions; + if (ts.hasModifier(node, 1)) { + var modifiers = void 0; + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { + if (!modifiers) { + modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); + } + variables = ts.append(variables, variable); + } + else if (variable.initializer) { + expressions = ts.append(expressions, transformInitializedVariable(variable)); + } + } + if (variables) { + statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); + } + if (expressions) { + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + } + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); + } + else { + statements = appendExportsOfVariableStatement(statements, node); + } + return ts.singleOrMany(statements); + } + function transformInitializedVariable(node) { + if (ts.isBindingPattern(node.name)) { + return ts.flattenDestructuringAssignment(node, undefined, context, 0, false, createExportExpression); + } + else { + return ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name), node.name), node.initializer); + } + } + function visitMergeDeclarationMarker(node) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); + } + return node; + } + function hasAssociatedEndOfDeclarationMarker(node) { + return (ts.getEmitFlags(node) & 2097152) !== 0; + } + function visitEndOfDeclarationMarker(node) { + var id = ts.getOriginalNodeId(node); + var statements = deferredExports[id]; + if (statements) { + delete deferredExports[id]; + return ts.append(statements, node); + } + return node; + } + function appendExportsOfImportDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + var importClause = decl.importClause; + if (!importClause) { + return statements; + } + if (importClause.name) { + statements = appendExportsOfDeclaration(statements, importClause); + } + var namedBindings = importClause.namedBindings; + if (namedBindings) { + switch (namedBindings.kind) { + case 239: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 240: + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var importBinding = _a[_i]; + statements = appendExportsOfDeclaration(statements, importBinding); + } + break; + } + } + return statements; + } + function appendExportsOfImportEqualsDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + return appendExportsOfDeclaration(statements, decl); + } + function appendExportsOfVariableStatement(statements, node) { + if (currentModuleInfo.exportEquals) { + return statements; + } + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + statements = appendExportsOfBindingElement(statements, decl); + } + return statements; + } + function appendExportsOfBindingElement(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + statements = appendExportsOfBindingElement(statements, element); + } + } + } + else if (!ts.isGeneratedIdentifier(decl.name)) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + function appendExportsOfHoistedDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.hasModifier(decl, 1)) { + var exportName = ts.hasModifier(decl, 512) ? ts.createIdentifier("default") : decl.name; + statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), decl); + } + if (decl.name) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + function appendExportsOfDeclaration(statements, decl) { + var name = ts.getDeclarationName(decl); + var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(name.text); + if (exportSpecifiers) { + for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { + var exportSpecifier = exportSpecifiers_1[_i]; + statements = appendExportStatement(statements, exportSpecifier.name, name, exportSpecifier.name); + } + } + return statements; + } + function appendExportStatement(statements, exportName, expression, location, allowComments) { + statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); + return statements; + } + function createUnderscoreUnderscoreESModule() { + var statement; + if (languageVersion === 0) { + statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true))); + } + else { + statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ])); + } + ts.setEmitFlags(statement, 524288); + return statement; + } + function createExportStatement(name, value, location, allowComments) { + var statement = ts.setTextRange(ts.createStatement(createExportExpression(name, value)), location); + ts.startOnNewLine(statement); + if (!allowComments) { + ts.setEmitFlags(statement, 1536); + } + return statement; + } + function createExportExpression(name, value, location) { + return ts.setTextRange(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value), location); + } + function modifierVisitor(node) { + switch (node.kind) { + case 83: + case 78: + return undefined; + } + return node; + } + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264) { + currentSourceFile = node; + currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; + noSubstitution = []; + previousOnEmitNode(hint, node, emitCallback); + currentSourceFile = undefined; + currentModuleInfo = undefined; + noSubstitution = undefined; + } + else { + previousOnEmitNode(hint, node, emitCallback); + } + } + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (node.id && noSubstitution[node.id]) { + return node; + } + if (hint === 1) { + return substituteExpression(node); + } + else if (ts.isShorthandPropertyAssignment(node)) { + return substituteShorthandPropertyAssignment(node); + } + return node; + } + function substituteShorthandPropertyAssignment(node) { + var name = node.name; + var exportedOrImportedName = substituteExpressionIdentifier(name); + if (exportedOrImportedName !== name) { + if (node.objectAssignmentInitializer) { + var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); + } + return ts.setTextRange(ts.createPropertyAssignment(name, exportedOrImportedName), node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 70: + return substituteExpressionIdentifier(node); + case 193: + return substituteBinaryExpression(node); + case 192: + case 191: + return substituteUnaryExpression(node); } return node; } @@ -43427,11 +45535,83 @@ var ts; if (externalHelpersModuleName) { return ts.createPropertyAccess(externalHelpersModuleName, node); } + return node; + } + if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { + var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); + if (exportContainer && exportContainer.kind === 264) { + return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node); + } + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + if (ts.isImportClause(importDeclaration)) { + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node); + } + else if (ts.isImportSpecifier(importDeclaration)) { + var name = importDeclaration.propertyName || importDeclaration.name; + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name)), node); + } + } } return node; } + function substituteBinaryExpression(node) { + if (ts.isAssignmentOperator(node.operatorToken.kind) + && ts.isIdentifier(node.left) + && !ts.isGeneratedIdentifier(node.left) + && !ts.isLocalName(node.left) + && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { + var exportedNames = getExports(node.left); + if (exportedNames) { + var expression = node; + for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { + var exportName = exportedNames_1[_i]; + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression, node); + } + return expression; + } + } + return node; + } + function substituteUnaryExpression(node) { + if ((node.operator === 42 || node.operator === 43) + && ts.isIdentifier(node.operand) + && !ts.isGeneratedIdentifier(node.operand) + && !ts.isLocalName(node.operand) + && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var expression = node.kind === 192 + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 42 ? 58 : 59), ts.createLiteral(1)), node) + : node; + for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { + var exportName = exportedNames_2[_i]; + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression); + } + return expression; + } + } + return node; + } + function getExports(name) { + if (!ts.isGeneratedIdentifier(name)) { + var valueDeclaration = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); + if (valueDeclaration) { + return currentModuleInfo + && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; + } + } + } } - ts.transformES2015Module = transformES2015Module; + ts.transformModule = transformModule; + var exportStarHelper = { + name: "typescript:export-star", + scoped: true, + text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" + }; })(ts || (ts = {})); var ts; (function (ts) { @@ -43445,14 +45625,14 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(70); - context.enableSubstitution(192); - context.enableSubstitution(190); + context.enableSubstitution(193); context.enableSubstitution(191); - context.enableEmitNotification(261); - var moduleInfoMap = ts.createMap(); - var deferredExports = ts.createMap(); - var exportFunctionsMap = ts.createMap(); - var noSubstitutionMap = ts.createMap(); + context.enableSubstitution(192); + context.enableEmitNotification(264); + var moduleInfoMap = []; + var deferredExports = []; + var exportFunctionsMap = []; + var noSubstitutionMap = []; var currentSourceFile; var moduleInfo; var exportFunction; @@ -43471,7 +45651,8 @@ var ts; currentSourceFile = node; enclosingBlockScopedContainer = node; moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); - exportFunction = exportFunctionsMap[id] = ts.createUniqueName("exports"); + exportFunction = ts.createUniqueName("exports"); + exportFunctionsMap[id] = exportFunction; contextObject = ts.createUniqueName("context"); var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); @@ -43481,11 +45662,11 @@ var ts; ], undefined, moduleBodyBlock); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); - var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.createNodeArray([ + var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ], node.statements)), 1024); + ]), node.statements)), 1024); if (!(compilerOptions.outFile || compilerOptions.out)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -43508,12 +45689,12 @@ var ts; var externalImport = externalImports[i]; var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { - var groupIndex = groupIndices[text]; + var groupIndex = groupIndices.get(text); + if (groupIndex !== undefined) { dependencyGroups[groupIndex].externalImports.push(externalImport); } else { - groupIndices[text] = dependencyGroups.length; + groupIndices.set(text, dependencyGroups.length); dependencyGroups.push({ name: externalModuleName, externalImports: [externalImport] @@ -43534,21 +45715,23 @@ var ts; ts.addRange(statements, hoistedStatements); ts.addRange(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + var moduleObject = ts.createObjectLiteral([ ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) - ]), true))); - return ts.createBlock(statements, undefined, true); + ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, true))) + ]); + moduleObject.multiLine = true; + statements.push(ts.createReturn(moduleObject)); + return ts.createBlock(statements, true); } function addExportStarIfNeeded(statements) { if (!moduleInfo.hasExportStarsToExportValues) { return; } - if (!moduleInfo.exportedNames && ts.isEmpty(moduleInfo.exportSpecifiers)) { + if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) { var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 241 && externalImport.exportClause) { + if (externalImport.kind === 243 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -43566,12 +45749,12 @@ var ts; if (exportedLocalName.text === "default") { continue; } - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createTrue())); } } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 241) { + if (externalImport.kind !== 243) { continue; } var exportDecl = externalImport; @@ -43580,12 +45763,12 @@ var ts; } for (var _f = 0, _g = exportDecl.exportClause.elements; _f < _g.length; _f++) { var element = _g[_f]; - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createTrue())); } } var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, undefined, true)) + ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, true)) ]))); var exportStarFunction = createExportStarFunction(exportedNamesStorageRef); statements.push(exportStarFunction); @@ -43610,7 +45793,7 @@ var ts; ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1) ])), ts.createStatement(ts.createCall(exportFunction, undefined, [exports])) - ], undefined, true)); + ], true)); } function createSettersArray(exportStarFunction, dependencyGroups) { var setters = []; @@ -43623,15 +45806,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 235: + case 237: if (!entry.importClause) { break; } - case 234: + case 236: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 241: + case 243: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -43639,7 +45822,7 @@ var ts; var e = _d[_c]; properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); } - statements.push(ts.createStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, undefined, true)]))); + statements.push(ts.createStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, true)]))); } else { statements.push(ts.createStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); @@ -43647,19 +45830,19 @@ var ts; break; } } - setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, undefined, true))); + setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, true))); } - return ts.createArrayLiteral(setters, undefined, true); + return ts.createArrayLiteral(setters, true); } function sourceElementVisitor(node) { switch (node.kind) { - case 235: + case 237: return visitImportDeclaration(node); - case 234: + case 236: return visitImportEqualsDeclaration(node); - case 241: + case 243: return undefined; - case 240: + case 242: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -43726,7 +45909,7 @@ var ts; var statements; var name = ts.getLocalName(node); hoistVariableDeclaration(name); - statements = ts.append(statements, ts.createStatement(ts.createAssignment(name, ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement), node)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); @@ -43754,7 +45937,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { var id = ts.getOriginalNodeId(node); @@ -43780,7 +45963,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 1048576) === 0 - && (enclosingBlockScopedContainer.kind === 261 + && (enclosingBlockScopedContainer.kind === 264 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -43798,11 +45981,11 @@ var ts; function createVariableAssignment(name, value, location, isExportedDeclaration) { hoistVariableDeclaration(ts.getSynthesizedClone(name)); return isExportedDeclaration - ? createExportExpression(name, preventSubstitution(ts.createAssignment(name, value, location))) - : preventSubstitution(ts.createAssignment(name, value, location)); + ? createExportExpression(name, preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location))) + : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -43835,10 +46018,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237: + case 239: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238: + case 240: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -43908,10 +46091,10 @@ var ts; return statements; } var name = ts.getDeclarationName(decl); - var exportSpecifiers = moduleInfo.exportSpecifiers[name.text]; + var exportSpecifiers = moduleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { - for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { - var exportSpecifier = exportSpecifiers_1[_i]; + for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { + var exportSpecifier = exportSpecifiers_2[_i]; if (exportSpecifier.name.text !== excludeName) { statements = appendExportStatement(statements, exportSpecifier.name, name); } @@ -43937,43 +46120,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 205: + case 207: return visitVariableStatement(node); - case 225: + case 227: return visitFunctionDeclaration(node); - case 226: + case 228: return visitClassDeclaration(node); - case 211: - return visitForStatement(node); - case 212: - return visitForInStatement(node); case 213: + return visitForStatement(node); + case 214: + return visitForInStatement(node); + case 215: return visitForOfStatement(node); - case 209: + case 211: return visitDoStatement(node); - case 210: + case 212: return visitWhileStatement(node); - case 219: - return visitLabeledStatement(node); - case 217: - return visitWithStatement(node); - case 218: - return visitSwitchStatement(node); - case 232: - return visitCaseBlock(node); - case 253: - return visitCaseClause(node); - case 254: - return visitDefaultClause(node); case 221: - return visitTryStatement(node); + return visitLabeledStatement(node); + case 219: + return visitWithStatement(node); + case 220: + return visitSwitchStatement(node); + case 234: + return visitCaseBlock(node); case 256: + return visitCaseClause(node); + case 257: + return visitDefaultClause(node); + case 223: + return visitTryStatement(node); + case 259: return visitCatchClause(node); - case 204: + case 206: return visitBlock(node); - case 295: + case 299: return visitMergeDeclarationMarker(node); - case 296: + case 300: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -44064,7 +46247,7 @@ var ts; } function destructuringVisitor(node) { if (node.transformFlags & 1024 - && node.kind === 192) { + && node.kind === 193) { return visitDestructuringAssignment(node); } else if (node.transformFlags & 2048) { @@ -44101,7 +46284,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 261; + return container !== undefined && container.kind === 264; } else { return false; @@ -44115,8 +46298,8 @@ var ts; } return node; } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261) { + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -44125,22 +46308,22 @@ var ts; if (noSubstitution) { delete noSubstitutionMap[id]; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); if (isSubstitutionPrevented(node)) { return node; } - if (emitContext === 1) { + if (hint === 1) { return substituteExpression(node); } return node; @@ -44149,10 +46332,10 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 192: + case 193: return substituteBinaryExpression(node); - case 190: case 191: + case 192: return substituteUnaryExpression(node); } return node; @@ -44169,655 +46352,10 @@ var ts; var importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node); } else if (ts.isImportSpecifier(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name), node); - } - } - } - return node; - } - function substituteBinaryExpression(node) { - if (ts.isAssignmentOperator(node.operatorToken.kind) - && ts.isIdentifier(node.left) - && !ts.isGeneratedIdentifier(node.left) - && !ts.isLocalName(node.left) - && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { - var exportedNames = getExports(node.left); - if (exportedNames) { - var expression = node; - for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { - var exportName = exportedNames_1[_i]; - expression = createExportExpression(exportName, preventSubstitution(expression)); - } - return expression; - } - } - return node; - } - function substituteUnaryExpression(node) { - if ((node.operator === 42 || node.operator === 43) - && ts.isIdentifier(node.operand) - && !ts.isGeneratedIdentifier(node.operand) - && !ts.isLocalName(node.operand) - && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { - var exportedNames = getExports(node.operand); - if (exportedNames) { - var expression = node.kind === 191 - ? ts.createPrefix(node.operator, node.operand, node) - : node; - for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { - var exportName = exportedNames_2[_i]; - expression = createExportExpression(exportName, preventSubstitution(expression)); - } - if (node.kind === 191) { - expression = node.operator === 42 - ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) - : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); - } - return expression; - } - } - return node; - } - function getExports(name) { - var exportedNames; - if (!ts.isGeneratedIdentifier(name)) { - var valueDeclaration = resolver.getReferencedImportDeclaration(name) - || resolver.getReferencedValueDeclaration(name); - if (valueDeclaration) { - var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 261) { - exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); - } - exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); - } - } - return exportedNames; - } - function preventSubstitution(node) { - if (noSubstitution === undefined) - noSubstitution = ts.createMap(); - noSubstitution[ts.getNodeId(node)] = true; - return node; - } - function isSubstitutionPrevented(node) { - return noSubstitution && node.id && noSubstitution[node.id]; - } - } - ts.transformSystemModule = transformSystemModule; -})(ts || (ts = {})); -var ts; -(function (ts) { - function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var moduleKind = ts.getEmitModuleKind(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(70); - context.enableSubstitution(192); - context.enableSubstitution(190); - context.enableSubstitution(191); - context.enableSubstitution(258); - context.enableEmitNotification(261); - var moduleInfoMap = ts.createMap(); - var deferredExports = ts.createMap(); - var currentSourceFile; - var currentModuleInfo; - var noSubstitution; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node) - || !(ts.isExternalModule(node) - || compilerOptions.isolatedModules)) { - return node; - } - currentSourceFile = node; - currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(node)] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); - var transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; - var updated = transformModule(node); - currentSourceFile = undefined; - currentModuleInfo = undefined; - return ts.aggregateTransformFlags(updated); - } - function transformCommonJSModule(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); - ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, false); - var updated = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); - if (currentModuleInfo.hasExportStarsToExportValues) { - ts.addEmitHelper(updated, exportStarHelper); - } - return updated; - } - function transformAMDModule(node) { - var define = ts.createIdentifier("define"); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, true); - } - function transformUMDModule(node) { - var define = ts.createRawExpression(umdHelper); - return transformAsynchronousModule(node, define, undefined, false); - } - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - return ts.updateSourceFileNode(node, ts.createNodeArray([ - ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral([ - ts.createLiteral("require"), - ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), - ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ - ts.createParameter(undefined, undefined, undefined, "require"), - ts.createParameter(undefined, undefined, undefined, "exports") - ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) - ]))) - ], node.statements)); - } - function collectAsynchronousDependencies(node, includeNonAmdDependencies) { - var aliasedModuleNames = []; - var unaliasedModuleNames = []; - var importAliasNames = []; - for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { - var amdDependency = _a[_i]; - if (amdDependency.name) { - aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - importAliasNames.push(ts.createParameter(undefined, undefined, undefined, amdDependency.name)); - } - else { - unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - } - } - for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) { - var importNode = _c[_b]; - var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - ts.setEmitFlags(importAliasName, 4); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(undefined, undefined, undefined, importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; - } - function transformAsynchronousModuleBody(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); - ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, true); - var body = ts.createBlock(statements, undefined, true); - if (currentModuleInfo.hasExportStarsToExportValues) { - ts.addEmitHelper(body, exportStarHelper); - } - return body; - } - function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (currentModuleInfo.exportEquals) { - if (emitAsReturn) { - var statement = ts.createReturn(currentModuleInfo.exportEquals.expression, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 | 1536); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression), currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536); - statements.push(statement); - } - } - } - function sourceElementVisitor(node) { - switch (node.kind) { - case 235: - return visitImportDeclaration(node); - case 234: - return visitImportEqualsDeclaration(node); - case 241: - return visitExportDeclaration(node); - case 240: - return visitExportAssignment(node); - case 205: - return visitVariableStatement(node); - case 225: - return visitFunctionDeclaration(node); - case 226: - return visitClassDeclaration(node); - case 295: - return visitMergeDeclarationMarker(node); - case 296: - return visitEndOfDeclarationMarker(node); - default: - return node; - } - } - function visitImportDeclaration(node) { - var statements; - var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); - if (moduleKind !== ts.ModuleKind.AMD) { - if (!node.importClause) { - return ts.createStatement(createRequireCall(node), node); - } - else { - var variables = []; - if (namespaceDeclaration && !ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, createRequireCall(node))); - } - else { - variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), undefined, createRequireCall(node))); - if (namespaceDeclaration && ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node))); - } - } - statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, undefined, languageVersion >= 2 ? 2 : 0), node)); - } - } - else if (namespaceDeclaration && ts.isDefaultImport(node)) { - statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node), node) - ], undefined, languageVersion >= 2 ? 2 : 0))); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfImportDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - function createRequireCall(importNode) { - var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var args = []; - if (moduleName) { - args.push(moduleName); - } - return ts.createCall(ts.createIdentifier("require"), undefined, args); - } - function visitImportEqualsDeclaration(node) { - ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); - var statements; - if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(node.name, createRequireCall(node)), node)); - } - else { - statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node)) - ], undefined, languageVersion >= 2 ? 2 : 0), node)); - } - } - else { - if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node)), node)); - } - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfImportEqualsDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - function visitExportDeclaration(node) { - if (!node.moduleSpecifier) { - return undefined; - } - var generatedName = ts.getGeneratedNameForNode(node); - if (node.exportClause) { - var statements = []; - if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(generatedName, undefined, createRequireCall(node)) - ]), node)); - } - for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { - var specifier = _a[_i]; - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue), specifier)); - } - return ts.singleOrMany(statements); - } - else { - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ - moduleKind !== ts.ModuleKind.AMD - ? createRequireCall(node) - : generatedName - ]), node); - } - } - function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; - } - var statements; - var original = node.original; - if (original && hasAssociatedEndOfDeclarationMarker(original)) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), node.expression, node, true); - } - else { - statements = appendExportStatement(statements, ts.createIdentifier("default"), node.expression, node, true); - } - return ts.singleOrMany(statements); - } - function visitFunctionDeclaration(node) { - var statements; - if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, node.parameters, undefined, node.body, node), node)); - } - else { - statements = ts.append(statements, node); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfHoistedDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - function visitClassDeclaration(node) { - var statements; - if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, node.heritageClauses, node.members, node), node)); - } - else { - statements = ts.append(statements, node); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfHoistedDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - function visitVariableStatement(node) { - var statements; - var variables; - var expressions; - if (ts.hasModifier(node, 1)) { - var modifiers = void 0; - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { - if (!modifiers) { - modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); - } - variables = ts.append(variables, variable); - } - else if (variable.initializer) { - expressions = ts.append(expressions, transformInitializedVariable(variable)); - } - } - if (variables) { - statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); - } - if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), node)); - } - } - else { - statements = ts.append(statements, node); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); - } - else { - statements = appendExportsOfVariableStatement(statements, node); - } - return ts.singleOrMany(statements); - } - function transformInitializedVariable(node) { - if (ts.isBindingPattern(node.name)) { - return ts.flattenDestructuringAssignment(node, undefined, context, 0, false, createExportExpression); - } - else { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name, node.name), node.initializer); - } - } - function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); - } - return node; - } - function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 2097152) !== 0; - } - function visitEndOfDeclarationMarker(node) { - var id = ts.getOriginalNodeId(node); - var statements = deferredExports[id]; - if (statements) { - delete deferredExports[id]; - return ts.append(statements, node); - } - return node; - } - function appendExportsOfImportDeclaration(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - var importClause = decl.importClause; - if (!importClause) { - return statements; - } - if (importClause.name) { - statements = appendExportsOfDeclaration(statements, importClause); - } - var namedBindings = importClause.namedBindings; - if (namedBindings) { - switch (namedBindings.kind) { - case 237: - statements = appendExportsOfDeclaration(statements, namedBindings); - break; - case 238: - for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { - var importBinding = _a[_i]; - statements = appendExportsOfDeclaration(statements, importBinding); - } - break; - } - } - return statements; - } - function appendExportsOfImportEqualsDeclaration(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - return appendExportsOfDeclaration(statements, decl); - } - function appendExportsOfVariableStatement(statements, node) { - if (currentModuleInfo.exportEquals) { - return statements; - } - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - statements = appendExportsOfBindingElement(statements, decl); - } - return statements; - } - function appendExportsOfBindingElement(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - if (ts.isBindingPattern(decl.name)) { - for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - statements = appendExportsOfBindingElement(statements, element); - } - } - } - else if (!ts.isGeneratedIdentifier(decl.name)) { - statements = appendExportsOfDeclaration(statements, decl); - } - return statements; - } - function appendExportsOfHoistedDeclaration(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - if (ts.hasModifier(decl, 1)) { - var exportName = ts.hasModifier(decl, 512) ? ts.createIdentifier("default") : decl.name; - statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), decl); - } - if (decl.name) { - statements = appendExportsOfDeclaration(statements, decl); - } - return statements; - } - function appendExportsOfDeclaration(statements, decl) { - var name = ts.getDeclarationName(decl); - var exportSpecifiers = currentModuleInfo.exportSpecifiers[name.text]; - if (exportSpecifiers) { - for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { - var exportSpecifier = exportSpecifiers_2[_i]; - statements = appendExportStatement(statements, exportSpecifier.name, name, exportSpecifier.name); - } - } - return statements; - } - function appendExportStatement(statements, exportName, expression, location, allowComments) { - if (exportName.text === "default") { - var sourceFile = ts.getOriginalNode(currentSourceFile, ts.isSourceFile); - if (sourceFile && !sourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 0) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); - } - else { - statements = ts.append(statements, ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); - } - } - } - statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); - return statements; - } - function createExportStatement(name, value, location, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value), location); - ts.startOnNewLine(statement); - if (!allowComments) { - ts.setEmitFlags(statement, 1536); - } - return statement; - } - function createExportExpression(name, value, location) { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value, location); - } - function modifierVisitor(node) { - switch (node.kind) { - case 83: - case 78: - return undefined; - } - return node; - } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261) { - currentSourceFile = node; - currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; - noSubstitution = ts.createMap(); - previousOnEmitNode(emitContext, node, emitCallback); - currentSourceFile = undefined; - currentModuleInfo = undefined; - noSubstitution = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (node.id && noSubstitution[node.id]) { - return node; - } - if (emitContext === 1) { - return substituteExpression(node); - } - else if (ts.isShorthandPropertyAssignment(node)) { - return substituteShorthandPropertyAssignment(node); - } - return node; - } - function substituteShorthandPropertyAssignment(node) { - var name = node.name; - var exportedOrImportedName = substituteExpressionIdentifier(name); - if (exportedOrImportedName !== name) { - if (node.objectAssignmentInitializer) { - var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, node); - } - return ts.createPropertyAssignment(name, exportedOrImportedName, node); - } - return node; - } - function substituteExpression(node) { - switch (node.kind) { - case 70: - return substituteExpressionIdentifier(node); - case 192: - return substituteBinaryExpression(node); - case 191: - case 190: - return substituteUnaryExpression(node); - } - return node; - } - function substituteExpressionIdentifier(node) { - if (ts.getEmitFlags(node) & 4096) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) { - return ts.createPropertyAccess(externalHelpersModuleName, node); - } - return node; - } - if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { - var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 261) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); - } - var importDeclaration = resolver.getReferencedImportDeclaration(node); - if (importDeclaration) { - if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); - } - else if (ts.isImportSpecifier(importDeclaration)) { - var name_38 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_38), node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name)), node); } } } @@ -44834,8 +46372,7 @@ var ts; var expression = node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { var exportName = exportedNames_3[_i]; - noSubstitution[ts.getNodeId(expression)] = true; - expression = createExportExpression(exportName, expression, node); + expression = createExportExpression(exportName, preventSubstitution(expression)); } return expression; } @@ -44850,13 +46387,17 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 191 - ? ts.createBinary(node.operand, ts.createToken(node.operator === 42 ? 58 : 59), ts.createLiteral(1), node) + var expression = node.kind === 192 + ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { var exportName = exportedNames_4[_i]; - noSubstitution[ts.getNodeId(expression)] = true; - expression = createExportExpression(exportName, expression); + expression = createExportExpression(exportName, preventSubstitution(expression)); + } + if (node.kind === 192) { + expression = node.operator === 42 + ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) + : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } return expression; } @@ -44864,35 +46405,116 @@ var ts; return node; } function getExports(name) { + var exportedNames; if (!ts.isGeneratedIdentifier(name)) { var valueDeclaration = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { - return currentModuleInfo - && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; + var exportContainer = resolver.getReferencedExportContainer(name, false); + if (exportContainer && exportContainer.kind === 264) { + exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); + } + exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); } } + return exportedNames; + } + function preventSubstitution(node) { + if (noSubstitution === undefined) + noSubstitution = []; + noSubstitution[ts.getNodeId(node)] = true; + return node; + } + function isSubstitutionPrevented(node) { + return noSubstitution && node.id && noSubstitution[node.id]; } - var _a; } - ts.transformModule = transformModule; - var exportStarHelper = { - name: "typescript:export-star", - scoped: true, - text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" - }; - var umdHelper = "\n (function (dependencies, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(dependencies, factory);\n }\n })"; + ts.transformSystemModule = transformSystemModule; })(ts || (ts = {})); var ts; (function (ts) { - var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, - _a[ts.ModuleKind.System] = ts.transformSystemModule, - _a[ts.ModuleKind.AMD] = ts.transformModule, - _a[ts.ModuleKind.CommonJS] = ts.transformModule, - _a[ts.ModuleKind.UMD] = ts.transformModule, - _a[ts.ModuleKind.None] = ts.transformModule, - _a)); + function transformES2015Module(context) { + var compilerOptions = context.getCompilerOptions(); + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.enableEmitNotification(264); + context.enableSubstitution(70); + var currentSourceFile; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); + if (externalHelpersModuleName) { + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements); + ts.append(statements, ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); + } + else { + return ts.visitEachChild(node, visitor, context); + } + } + return node; + } + function visitor(node) { + switch (node.kind) { + case 236: + return undefined; + case 242: + return visitExportAssignment(node); + } + return node; + } + function visitExportAssignment(node) { + return node.isExportEquals ? undefined : node; + } + function onEmitNode(hint, node, emitCallback) { + if (ts.isSourceFile(node)) { + currentSourceFile = node; + previousOnEmitNode(hint, node, emitCallback); + currentSourceFile = undefined; + } + else { + previousOnEmitNode(hint, node, emitCallback); + } + } + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (ts.isIdentifier(node) && hint === 1) { + return substituteExpressionIdentifier(node); + } + return node; + } + function substituteExpressionIdentifier(node) { + if (ts.getEmitFlags(node) & 4096) { + var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); + if (externalHelpersModuleName) { + return ts.createPropertyAccess(externalHelpersModuleName, node); + } + } + return node; + } + } + ts.transformES2015Module = transformES2015Module; +})(ts || (ts = {})); +var ts; +(function (ts) { + function getModuleTransformer(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.ES2015: + return ts.transformES2015Module; + case ts.ModuleKind.System: + return ts.transformSystemModule; + default: + return ts.transformModule; + } + } function getTransformers(compilerOptions) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -44915,7 +46537,7 @@ var ts; transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } - transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); + transformers.push(getModuleTransformer(moduleKind)); if (languageVersion < 1) { transformers.push(ts.transformES5); } @@ -44923,7 +46545,7 @@ var ts; } ts.getTransformers = getTransformers; function transformFiles(resolver, host, sourceFiles, transformers) { - var enabledSyntaxKindFeatures = new Array(298); + var enabledSyntaxKindFeatures = new Array(301); var lexicalEnvironmentDisabled = false; var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; @@ -44944,16 +46566,19 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, - onSubstituteNode: function (_emitContext, node) { return node; }, + onSubstituteNode: function (_, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, + onEmitNode: function (hint, node, callback) { return callback(hint, node); }, enableEmitNotification: enableEmitNotification, isEmitNotificationEnabled: isEmitNotificationEnabled }; + ts.performance.mark("beforeTransform"); var transformation = ts.chain.apply(void 0, transformers)(context); var transformed = ts.map(sourceFiles, transformSourceFile); lexicalEnvironmentDisabled = true; + ts.performance.mark("afterTransform"); + ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { transformed: transformed, emitNodeWithSubstitution: emitNodeWithSubstitution, @@ -44972,16 +46597,12 @@ var ts; return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0 && (ts.getEmitFlags(node) & 4) === 0; } - function emitNodeWithSubstitution(emitContext, node, emitCallback) { + function emitNodeWithSubstitution(hint, node, emitCallback) { if (node) { if (isSubstitutionEnabled(node)) { - var substitute = context.onSubstituteNode(emitContext, node); - if (substitute && substitute !== node) { - emitCallback(emitContext, substitute); - return; - } + node = context.onSubstituteNode(hint, node) || node; } - emitCallback(emitContext, node); + emitCallback(hint, node); } } function enableEmitNotification(kind) { @@ -44991,13 +46612,13 @@ var ts; return (enabledSyntaxKindFeatures[node.kind] & 2) !== 0 || (ts.getEmitFlags(node) & 2) !== 0; } - function emitNodeWithNotification(emitContext, node, emitCallback) { + function emitNodeWithNotification(hint, node, emitCallback) { if (node) { if (isEmitNotificationEnabled(node)) { - context.onEmitNode(emitContext, node, emitCallback); + context.onEmitNode(hint, node, emitCallback); } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } } @@ -45079,7 +46700,6 @@ var ts; } } ts.transformFiles = transformFiles; - var _a; })(ts || (ts = {})); var ts; (function (ts) { @@ -45113,7 +46733,7 @@ var ts; getText: getText, getSourceMappingURL: getSourceMappingURL, }; - function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { + function initialize(filePath, sourceMapFilePath, sourceFileOrBundle) { if (disabled) { return; } @@ -45144,9 +46764,8 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (!isBundledEmit) { - ts.Debug.assert(sourceFiles.length === 1); - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFiles[0], host, sourceMapDir)); + if (sourceFileOrBundle.kind === 264) { + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); @@ -45237,28 +46856,28 @@ var ts; ts.performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); } } - function emitNodeWithSourceMap(emitContext, node, emitCallback) { + function emitNodeWithSourceMap(hint, node, emitCallback) { if (disabled) { - return emitCallback(emitContext, node); + return emitCallback(hint, node); } if (node) { var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 293 + if (node.kind !== 297 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); } if (emitFlags & 64) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } - if (node.kind !== 293 + if (node.kind !== 297 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -45359,11 +46978,10 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function createCommentWriter(host, writer, sourceMap) { - var compilerOptions = host.getCompilerOptions(); - var extendedDiagnostics = compilerOptions.extendedDiagnostics; - var newLine = host.getNewLine(); - var emitPos = sourceMap.emitPos; + function createCommentWriter(printerOptions, emitPos) { + var extendedDiagnostics = printerOptions.extendedDiagnostics; + var newLine = ts.getNewLineCharacter(printerOptions); + var writer; var containerPos = -1; var containerEnd = -1; var declarationListContainerEnd = -1; @@ -45372,17 +46990,19 @@ var ts; var currentLineMap; var detachedCommentsInfo; var hasWrittenComment = false; - var disabled = compilerOptions.removeComments; + var disabled = printerOptions.removeComments; return { reset: reset, + setWriter: setWriter, setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, + emitLeadingCommentsOfPosition: emitLeadingCommentsOfPosition, }; - function emitNodeWithComments(emitContext, node, emitCallback) { + function emitNodeWithComments(hint, node, emitCallback) { if (disabled) { - emitCallback(emitContext, node); + emitCallback(hint, node); return; } if (node) { @@ -45391,18 +47011,18 @@ var ts; if ((pos < 0 && end < 0) || (pos === end)) { if (emitFlags & 2048) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } else { if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 293; + var isEmittedNode = node.kind !== 297; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0; if (!skipLeadingComments) { @@ -45416,7 +47036,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 224) { + if (node.kind === 226) { declarationListContainerEnd = end; } } @@ -45425,11 +47045,11 @@ var ts; } if (emitFlags & 2048) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } if (extendedDiagnostics) { ts.performance.mark("beginEmitNodeWithComment"); @@ -45500,9 +47120,11 @@ var ts; ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); hasWrittenComment = true; } - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -45510,6 +47132,12 @@ var ts; writer.write(" "); } } + function emitLeadingCommentsOfPosition(pos) { + if (disabled || pos === -1) { + return; + } + emitLeadingComments(pos, true); + } function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } @@ -45517,9 +47145,11 @@ var ts; if (!writer.isAtStartOfLine()) { writer.write(" "); } - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -45537,9 +47167,11 @@ var ts; } } function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -45568,6 +47200,9 @@ var ts; currentLineMap = undefined; detachedCommentsInfo = undefined; } + function setWriter(output) { + writer = output; + } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; currentText = currentSourceFile.text; @@ -45599,9 +47234,11 @@ var ts; } } function writeComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); } function isTripleSlashComment(commentPos, commentEnd) { if (currentText.charCodeAt(commentPos + 1) === 47 && @@ -45621,15 +47258,17 @@ var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, targetSourceFile) { var declarationDiagnostics = ts.createDiagnosticCollection(); - ts.forEachExpectedEmitFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); + ts.forEachEmittedFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined); - function getDeclarationDiagnosticsFromFile(_a, sources, isBundledEmit) { + function getDeclarationDiagnosticsFromFile(_a, sourceFileOrBundle) { var declarationFilePath = _a.declarationFilePath; - emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit, false); + emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sourceFileOrBundle, false); } } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles) { + function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles) { + var sourceFiles = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var isBundledEmit = sourceFileOrBundle.kind === 265; var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -45691,7 +47330,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 235); + ts.Debug.assert(aliasEmitInfo.node.kind === 237); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -45714,9 +47353,9 @@ var ts; } }); if (usedTypeDirectiveReferences) { - for (var directive in usedTypeDirectiveReferences) { + ts.forEachKey(usedTypeDirectiveReferences, function (directive) { referencesOutput += "/// " + newLine; - } + }); } return { reportedDeclarationError: reportedDeclarationError, @@ -45741,6 +47380,7 @@ var ts; var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; writer.reportInaccessibleThisError = reportInaccessibleThisError; + writer.reportIllegalExtends = reportIllegalExtends; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -45763,10 +47403,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 223) { + if (declaration.kind === 225) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 238 || declaration.kind === 239 || declaration.kind === 236) { + else if (declaration.kind === 240 || declaration.kind === 241 || declaration.kind === 238) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -45777,7 +47417,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 235) { + if (moduleElementEmitInfo.node.kind === 237) { moduleElementEmitInfo.isVisible = true; } else { @@ -45785,12 +47425,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 230) { + if (nodeToCheck.kind === 232) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 230) { + if (nodeToCheck.kind === 232) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -45809,8 +47449,8 @@ var ts; } for (var _i = 0, typeReferenceDirectives_1 = typeReferenceDirectives; _i < typeReferenceDirectives_1.length; _i++) { var directive = typeReferenceDirectives_1[_i]; - if (!(directive in usedTypeDirectiveReferences)) { - usedTypeDirectiveReferences[directive] = directive; + if (!usedTypeDirectiveReferences.has(directive)) { + usedTypeDirectiveReferences.set(directive, directive); } } } @@ -45837,6 +47477,12 @@ var ts; handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); } + function reportIllegalExtends() { + if (errorNameNode) { + reportedDeclarationError = true; + emitterDiagnostics.add(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced, ts.declarationNameToString(errorNameNode))); + } + } function reportInaccessibleThisError() { if (errorNameNode) { reportedDeclarationError = true; @@ -45846,12 +47492,16 @@ var ts; function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); - if (type) { + var shouldUseResolverType = declaration.kind === 145 && + resolver.isRequiredInitializedParameter(declaration); + if (type && !shouldUseResolverType) { emitType(type); } else { errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 | 1024, writer); + var format = 2 | 1024 | + (shouldUseResolverType ? 4096 : 0); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer); errorNameNode = undefined; } } @@ -45903,49 +47553,50 @@ var ts; function emitType(type) { switch (type.kind) { case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 133: + case 136: case 104: - case 137: + case 138: case 94: case 129: - case 167: - case 171: - return writeTextOfNode(currentText, type); - case 199: - return emitExpressionWithTypeArguments(type); - case 157: - return emitTypeReference(type); - case 160: - return emitTypeQuery(type); - case 162: - return emitArrayType(type); - case 163: - return emitTupleType(type); - case 164: - return emitUnionType(type); - case 165: - return emitIntersectionType(type); - case 166: - return emitParenType(type); case 168: - return emitTypeOperator(type); - case 169: - return emitIndexedAccessType(type); - case 170: - return emitMappedType(type); + case 172: + return writeTextOfNode(currentText, type); + case 200: + return emitExpressionWithTypeArguments(type); case 158: - case 159: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 161: + return emitTypeQuery(type); + case 163: + return emitArrayType(type); + case 164: + return emitTupleType(type); + case 165: + return emitUnionType(type); + case 166: + return emitIntersectionType(type); + case 167: + return emitParenType(type); + case 169: + return emitTypeOperator(type); + case 170: + return emitIndexedAccessType(type); + case 171: + return emitMappedType(type); + case 159: + case 160: + return emitSignatureDeclarationWithJsDocComments(type); + case 162: return emitTypeLiteral(type); case 70: return emitEntityName(type); - case 141: + case 142: return emitEntityName(type); - case 156: + case 157: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -45953,22 +47604,22 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 141 ? entityName.left : entityName.expression; - var right = entityName.kind === 141 ? entityName.right : entityName.name; + var left = entityName.kind === 142 ? entityName.left : entityName.expression; + var right = entityName.kind === 142 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 234 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 236 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 177); + ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 178); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -46072,15 +47723,15 @@ var ts; } function getExportDefaultTempVariableName() { var baseName = "_default"; - if (!(baseName in currentIdentifiers)) { + if (!currentIdentifiers.has(baseName)) { return baseName; } var count = 0; while (true) { count++; - var name_39 = baseName + "_" + count; - if (!(name_39 in currentIdentifiers)) { - return name_39; + var name = baseName + "_" + count; + if (!currentIdentifiers.has(name)) { + return name; } } } @@ -46124,10 +47775,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 234 || - (node.parent.kind === 261 && isCurrentFileExternalModule)) { + else if (node.kind === 236 || + (node.parent.kind === 264 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 264) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -46136,7 +47787,7 @@ var ts; }); } else { - if (node.kind === 235) { + if (node.kind === 237) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -46154,30 +47805,30 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 225: - return writeFunctionDeclaration(node); - case 205: - return writeVariableStatement(node); case 227: - return writeInterfaceDeclaration(node); - case 226: - return writeClassDeclaration(node); - case 228: - return writeTypeAliasDeclaration(node); + return writeFunctionDeclaration(node); + case 207: + return writeVariableStatement(node); case 229: - return writeEnumDeclaration(node); + return writeInterfaceDeclaration(node); + case 228: + return writeClassDeclaration(node); case 230: + return writeTypeAliasDeclaration(node); + case 231: + return writeEnumDeclaration(node); + case 232: return writeModuleDeclaration(node); - case 234: + case 236: return writeImportEqualsDeclaration(node); - case 235: + case 237: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 261) { + if (node.parent.kind === 264) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -46185,7 +47836,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 227 && !noDeclare) { + else if (node.kind !== 229 && !noDeclare) { write("declare "); } } @@ -46235,7 +47886,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 237) { + if (namedBindings.kind === 239) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -46258,7 +47909,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 237) { + if (node.importClause.namedBindings.kind === 239) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -46275,13 +47926,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 230; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 232; var moduleSpecifier; - if (parent.kind === 234) { + if (parent.kind === 236) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 230) { + else if (parent.kind === 232) { moduleSpecifier = parent.name; } else { @@ -46349,7 +48000,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 231) { + while (node.body && node.body.kind !== 233) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -46419,7 +48070,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 149 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 150 && ts.hasModifier(node.parent, 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -46429,52 +48080,69 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 158 || - node.parent.kind === 159 || - (node.parent.parent && node.parent.parent.kind === 161)) { - ts.Debug.assert(node.parent.kind === 149 || - node.parent.kind === 148 || - node.parent.kind === 158 || + if (node.parent.kind === 159 || + node.parent.kind === 160 || + (node.parent.parent && node.parent.parent.kind === 162)) { + ts.Debug.assert(node.parent.kind === 150 || + node.parent.kind === 149 || node.parent.kind === 159 || - node.parent.kind === 153 || - node.parent.kind === 154); + node.parent.kind === 160 || + node.parent.kind === 154 || + node.parent.kind === 155); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } + if (node.default && !isPrivateMethodTypeParameter(node)) { + write(" = "); + if (node.parent.kind === 159 || + node.parent.kind === 160 || + (node.parent.parent && node.parent.parent.kind === 162)) { + ts.Debug.assert(node.parent.kind === 150 || + node.parent.kind === 149 || + node.parent.kind === 159 || + node.parent.kind === 160 || + node.parent.kind === 154 || + node.parent.kind === 155); + emitType(node.default); + } + else { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.default, getTypeParameterConstraintVisibilityError); + } + } function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 226: + case 228: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 227: + case 229: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 154: + case 155: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 153: + case 154: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 150: case 149: - case 148: if (ts.hasModifier(node.parent, 32)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 226) { + else if (node.parent.parent.kind === 228) { 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 225: + case 227: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 228: + case 230: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -46493,7 +48161,7 @@ var ts; write(">"); } } - function emitHeritageClause(typeReferences, isImplementsList) { + function emitHeritageClause(className, typeReferences, isImplementsList) { if (typeReferences) { write(isImplementsList ? " implements " : " extends "); emitCommaList(typeReferences, emitTypeOfTypeReference); @@ -46507,17 +48175,19 @@ var ts; } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; + errorNameNode = className; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 | 1024, writer); + errorNameNode = undefined; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 226) { + if (node.parent.parent.kind === 228) { 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; + 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; + diagnosticMessage = ts.Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; } return { diagnosticMessage: diagnosticMessage, @@ -46549,9 +48219,10 @@ var ts; emitTypeParameters(node.typeParameters); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); + node.name; + emitHeritageClause(node.name, [baseTypeNode], false); } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), true); + emitHeritageClause(node.name, ts.getClassImplementsHeritageClauseElements(node), true); write(" {"); writeLine(); increaseIndent(); @@ -46572,7 +48243,7 @@ var ts; emitTypeParameters(node.typeParameters); var interfaceExtendsTypes = ts.filter(ts.getInterfaceBaseTypeNodes(node), function (base) { return ts.isEntityNameExpression(base.expression); }); if (interfaceExtendsTypes && interfaceExtendsTypes.length) { - emitHeritageClause(interfaceExtendsTypes, false); + emitHeritageClause(node.name, interfaceExtendsTypes, false); } write(" {"); writeLine(); @@ -46594,17 +48265,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 223 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 225 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 147 || node.kind === 146 || - (node.kind === 144 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 148 || node.kind === 147 || + (node.kind === 145 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 147 || node.kind === 146) && node.parent.kind === 161) { + if ((node.kind === 148 || node.kind === 147) && node.parent.kind === 162) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -46617,14 +48288,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 223) { + if (node.kind === 225) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 147 || node.kind === 146) { + else if (node.kind === 148 || node.kind === 147) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -46632,7 +48303,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 === 226) { + else if (node.parent.kind === 228) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -46658,7 +48329,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 198) { + if (element.kind !== 199) { elements.push(element); } } @@ -46724,7 +48395,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 151 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 152 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -46737,7 +48408,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 151 + return accessor.kind === 152 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -46746,7 +48417,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 152) { + if (accessorWithTypeAnnotation.kind === 153) { if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -46792,17 +48463,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 225) { + if (node.kind === 227) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 149 || node.kind === 150) { + else if (node.kind === 150 || node.kind === 151) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 225) { + if (node.kind === 227) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 150) { + else if (node.kind === 151) { write("constructor"); } else { @@ -46822,15 +48493,15 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 155) { + if (node.kind === 156) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { - if (node.kind === 154 || node.kind === 159) { + if (node.kind === 155 || node.kind === 160) { write("new "); } - else if (node.kind === 158) { + else if (node.kind === 159) { var currentOutput = writer.getText(); if (node.typeParameters && currentOutput.charAt(currentOutput.length - 1) === "<") { closeParenthesizedFunctionType = true; @@ -46841,20 +48512,20 @@ var ts; write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 155) { + if (node.kind === 156) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 158 || node.kind === 159; - if (isFunctionTypeOrConstructorType || node.parent.kind === 161) { + var isFunctionTypeOrConstructorType = node.kind === 159 || node.kind === 160; + if (isFunctionTypeOrConstructorType || node.parent.kind === 162) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 150 && !ts.hasModifier(node, 8)) { + else if (node.kind !== 151 && !ts.hasModifier(node, 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -46868,23 +48539,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 154: + case 155: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 153: + case 154: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 155: + case 156: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; + case 150: case 149: - case 148: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -46892,7 +48563,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 === 226) { + else if (node.parent.kind === 228) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -46905,7 +48576,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 225: + case 227: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -46937,9 +48608,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 158 || - node.parent.kind === 159 || - node.parent.parent.kind === 161) { + if (node.parent.kind === 159 || + node.parent.kind === 160 || + node.parent.parent.kind === 162) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8)) { @@ -46955,26 +48626,26 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 150: + case 151: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 154: + case 155: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 153: + case 154: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 155: + case 156: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; + case 150: case 149: - case 148: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -46982,7 +48653,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 === 226) { + else if (node.parent.parent.kind === 228) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -46994,7 +48665,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 225: + case 227: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47005,12 +48676,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 172) { + if (bindingPattern.kind === 173) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 173) { + else if (bindingPattern.kind === 174) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -47021,10 +48692,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 198) { + if (bindingElement.kind === 199) { write(" "); } - else if (bindingElement.kind === 174) { + else if (bindingElement.kind === 175) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -47046,39 +48717,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 225: - case 230: - case 234: case 227: - case 226: - case 228: + case 232: + case 236: case 229: + case 228: + case 230: + case 231: return emitModuleElement(node, isModuleElementVisible(node)); - case 205: + case 207: return emitModuleElement(node, isVariableStatementVisible(node)); - case 235: + case 237: return emitModuleElement(node, !node.importClause); - case 241: + case 243: return emitExportDeclaration(node); + case 151: case 150: case 149: - case 148: return writeFunctionDeclaration(node); - case 154: - case 153: case 155: + case 154: + case 156: return emitSignatureDeclarationWithJsDocComments(node); - case 151: case 152: + case 153: return emitAccessorDeclaration(node); + case 148: case 147: - case 146: return emitPropertyDeclaration(node); - case 260: + case 263: return emitEnumMemberDeclaration(node); - case 240: + case 242: return emitExportAssignment(node); - case 261: + case 264: return emitSourceFile(node); } } @@ -47089,14 +48760,15 @@ var ts; declFileName = referencedFile.fileName; } else { - ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); } if (declFileName) { declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(declarationFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, sourceFileOrBundle) { + var isBundledEmit = sourceFileOrBundle.kind === 265; if (isBundledEmit && !addBundledFileReference) { return; } @@ -47106,10 +48778,11 @@ var ts; } } } - function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { - var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles); + function writeDeclarationFile(declarationFilePath, sourceFileOrBundle, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { + var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { + var sourceFiles = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; var declarationOutput = emitDeclarationResult.referencesOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); ts.writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM, sourceFiles); @@ -47133,44 +48806,39 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var id = function (s) { return s; }; - var nullTransformers = [function (_) { return id; }]; + var delimiters = createDelimiterMap(); + var brackets = createBracketsMap(); function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { - var delimiters = createDelimiterMap(); - var brackets = createBracketsMap(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = emitOnlyDtsFiles ? nullTransformers : ts.getTransformers(compilerOptions); + var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); - var write = writer.write, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var sourceMap = ts.createSourceMapWriter(host, writer); - var emitNodeWithSourceMap = sourceMap.emitNodeWithSourceMap, emitTokenWithSourceMap = sourceMap.emitTokenWithSourceMap; - var comments = ts.createCommentWriter(host, writer, sourceMap); - var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition; - var nodeIdToGeneratedName; - var autoGeneratedIdToGeneratedName; - var generatedNameSet; - var tempFlags; var currentSourceFile; - var currentText; - var currentFileIdentifiers; var bundledHelpers; var isOwnFileEmit; var emitSkipped = false; var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); - ts.performance.mark("beforeTransform"); - var _a = ts.transformFiles(resolver, host, sourceFiles, transformers), transformed = _a.transformed, emitNodeWithSubstitution = _a.emitNodeWithSubstitution, emitNodeWithNotification = _a.emitNodeWithNotification; - ts.performance.measure("transformTime", "beforeTransform"); + var transform = ts.transformFiles(resolver, host, sourceFiles, transformers); + var printer = createPrinter(compilerOptions, { + hasGlobalName: resolver.hasGlobalName, + onEmitNode: transform.emitNodeWithNotification, + onSubstituteNode: transform.emitNodeWithSubstitution, + onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, + onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, + onEmitSourceMapOfPosition: sourceMap.emitPos, + onEmitHelpers: emitHelpers, + onSetSourceFile: setSourceFile, + }); ts.performance.mark("beforePrint"); - ts.forEachTransformedEmitFile(host, transformed, emitFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, emitSourceFileOrBundle, transform.transformed, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); - for (var _b = 0, sourceFiles_4 = sourceFiles; _b < sourceFiles_4.length; _b++) { - var sourceFile = sourceFiles_4[_b]; + for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { + var sourceFile = sourceFiles_2[_a]; ts.disposeEmitNodes(sourceFile); } return { @@ -47179,17 +48847,18 @@ var ts; emittedFiles: emittedFilesList, sourceMaps: sourceMapDataList }; - function emitFile(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, isBundledEmit) { + function emitSourceFileOrBundle(_a, sourceFileOrBundle) { + var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath; if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { if (!emitOnlyDtsFiles) { - printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle); } } else { emitSkipped = true; } if (declarationFilePath) { - emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; + emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFileOrBundle(sourceFileOrBundle), host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; } if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { @@ -47203,24 +48872,24 @@ var ts; } } } - function printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit) { - sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); - nodeIdToGeneratedName = []; - autoGeneratedIdToGeneratedName = []; - generatedNameSet = ts.createMap(); - bundledHelpers = isBundledEmit ? ts.createMap() : undefined; - isOwnFileEmit = !isBundledEmit; - if (isBundledEmit && moduleKind) { - for (var _a = 0, sourceFiles_5 = sourceFiles; _a < sourceFiles_5.length; _a++) { - var sourceFile = sourceFiles_5[_a]; - emitHelpers(sourceFile, true); - } + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle) { + var bundle = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 264 ? sourceFileOrBundle : undefined; + var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; + sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFileOrBundle); + if (bundle) { + bundledHelpers = ts.createMap(); + isOwnFileEmit = false; + printer.writeBundle(bundle, writer); } - ts.forEach(sourceFiles, printSourceFile); - writeLine(); + else { + isOwnFileEmit = true; + printer.writeFile(sourceFile, writer); + } + writer.writeLine(); var sourceMappingURL = sourceMap.getSourceMappingURL(); if (sourceMappingURL) { - write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); + writer.write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); } if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) { ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), false, sourceFiles); @@ -47230,23 +48899,165 @@ var ts; } ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM, sourceFiles); sourceMap.reset(); - comments.reset(); writer.reset(); - tempFlags = 0; currentSourceFile = undefined; - currentText = undefined; + bundledHelpers = undefined; isOwnFileEmit = false; } - function printSourceFile(node) { + function setSourceFile(node) { currentSourceFile = node; - currentText = node.text; - currentFileIdentifiers = node.identifiers; sourceMap.setSourceFile(node); - comments.setSourceFile(node); - pipelineEmitWithNotification(0, node); } - function emit(node) { - pipelineEmitWithNotification(3, node); + function emitHelpers(node, writeLines) { + var helpersEmitted = false; + var bundle = node.kind === 265 ? node : undefined; + if (bundle && moduleKind === ts.ModuleKind.None) { + return; + } + var numNodes = bundle ? bundle.sourceFiles.length : 1; + for (var i = 0; i < numNodes; i++) { + var currentNode = bundle ? bundle.sourceFiles[i] : node; + var sourceFile = ts.isSourceFile(currentNode) ? currentNode : currentSourceFile; + var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldBundle = ts.isSourceFile(currentNode) && !isOwnFileEmit; + var helpers = ts.getEmitHelpers(currentNode); + if (helpers) { + for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { + var helper = _b[_a]; + if (!helper.scoped) { + if (shouldSkip) + continue; + if (shouldBundle) { + if (bundledHelpers.get(helper.name)) { + continue; + } + bundledHelpers.set(helper.name, true); + } + } + else if (bundle) { + continue; + } + writeLines(helper.text); + helpersEmitted = true; + } + } + } + return helpersEmitted; + } + } + ts.emitFiles = emitFiles; + function createPrinter(printerOptions, handlers) { + if (printerOptions === void 0) { printerOptions = {}; } + if (handlers === void 0) { handlers = {}; } + var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, onSubstituteNode = handlers.onSubstituteNode; + var newLine = ts.getNewLineCharacter(printerOptions); + var languageVersion = ts.getEmitScriptTarget(printerOptions); + var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); + var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; + var currentSourceFile; + var nodeIdToGeneratedName; + var autoGeneratedIdToGeneratedName; + var generatedNames; + var tempFlagsStack; + var tempFlags; + var writer; + var ownWriter; + reset(); + return { + printNode: printNode, + printFile: printFile, + printBundle: printBundle, + writeNode: writeNode, + writeFile: writeFile, + writeBundle: writeBundle + }; + function printNode(hint, node, sourceFile) { + switch (hint) { + case 0: + ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); + break; + case 2: + ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); + break; + case 1: + ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); + break; + } + switch (node.kind) { + case 264: return printFile(node); + case 265: return printBundle(node); + } + writeNode(hint, node, sourceFile, beginPrint()); + return endPrint(); + } + function printBundle(bundle) { + writeBundle(bundle, beginPrint()); + return endPrint(); + } + function printFile(sourceFile) { + writeFile(sourceFile, beginPrint()); + return endPrint(); + } + function writeNode(hint, node, sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(hint, node, sourceFile); + reset(); + writer = previousWriter; + } + function writeBundle(bundle, output) { + var previousWriter = writer; + setWriter(output); + emitHelpersIndirect(bundle); + for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + print(0, sourceFile, sourceFile); + } + reset(); + writer = previousWriter; + } + function writeFile(sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(0, sourceFile, sourceFile); + reset(); + writer = previousWriter; + } + function beginPrint() { + return ownWriter || (ownWriter = ts.createTextWriter(newLine)); + } + function endPrint() { + var text = ownWriter.getText(); + ownWriter.reset(); + return text; + } + function print(hint, node, sourceFile) { + setSourceFile(sourceFile); + pipelineEmitWithNotification(hint, node); + } + function setSourceFile(sourceFile) { + currentSourceFile = sourceFile; + comments.setSourceFile(sourceFile); + if (onSetSourceFile) { + onSetSourceFile(sourceFile); + } + } + function setWriter(output) { + writer = output; + comments.setWriter(output); + } + function reset() { + nodeIdToGeneratedName = []; + autoGeneratedIdToGeneratedName = []; + generatedNames = ts.createMap(); + tempFlagsStack = []; + tempFlags = 0; + comments.reset(); + setWriter(undefined); + } + function emit(node, hint) { + if (hint === void 0) { hint = 3; } + pipelineEmitWithNotification(hint, node); } function emitIdentifierName(node) { pipelineEmitWithNotification(2, node); @@ -47254,51 +49065,60 @@ var ts; function emitExpression(node) { pipelineEmitWithNotification(1, node); } - function pipelineEmitWithNotification(emitContext, node) { - emitNodeWithNotification(emitContext, node, pipelineEmitWithComments); + function pipelineEmitWithNotification(hint, node) { + if (onEmitNode) { + onEmitNode(hint, node, pipelineEmitWithComments); + } + else { + pipelineEmitWithComments(hint, node); + } } - function pipelineEmitWithComments(emitContext, node) { - if (emitContext === 0) { - pipelineEmitWithSourceMap(emitContext, node); + function pipelineEmitWithComments(hint, node) { + if (emitNodeWithComments && hint !== 0) { + emitNodeWithComments(hint, node, pipelineEmitWithSourceMap); + } + else { + pipelineEmitWithSourceMap(hint, node); + } + } + function pipelineEmitWithSourceMap(hint, node) { + if (onEmitSourceMapOfNode && hint !== 0 && hint !== 2) { + onEmitSourceMapOfNode(hint, node, pipelineEmitWithSubstitution); + } + else { + pipelineEmitWithSubstitution(hint, node); + } + } + function pipelineEmitWithSubstitution(hint, node) { + if (onSubstituteNode) { + onSubstituteNode(hint, node, pipelineEmitWithHint); + } + else { + pipelineEmitWithHint(hint, node); + } + } + function pipelineEmitWithHint(hint, node) { + switch (hint) { + case 0: return pipelineEmitSourceFile(node); + case 2: return pipelineEmitIdentifierName(node); + case 1: return pipelineEmitExpression(node); + case 3: return pipelineEmitUnspecified(node); + } + } + function pipelineEmitSourceFile(node) { + ts.Debug.assertNode(node, ts.isSourceFile); + emitSourceFile(node); + } + function pipelineEmitIdentifierName(node) { + ts.Debug.assertNode(node, ts.isIdentifier); + emitIdentifier(node); + } + function pipelineEmitUnspecified(node) { + var kind = node.kind; + if (ts.isKeyword(kind)) { + writeTokenText(kind); return; } - emitNodeWithComments(emitContext, node, pipelineEmitWithSourceMap); - } - function pipelineEmitWithSourceMap(emitContext, node) { - if (emitContext === 0 - || emitContext === 2) { - pipelineEmitWithSubstitution(emitContext, node); - return; - } - emitNodeWithSourceMap(emitContext, node, pipelineEmitWithSubstitution); - } - function pipelineEmitWithSubstitution(emitContext, node) { - emitNodeWithSubstitution(emitContext, node, pipelineEmitForContext); - } - function pipelineEmitForContext(emitContext, node) { - switch (emitContext) { - case 0: return pipelineEmitInSourceFileContext(node); - case 2: return pipelineEmitInIdentifierNameContext(node); - case 3: return pipelineEmitInUnspecifiedContext(node); - case 1: return pipelineEmitInExpressionContext(node); - } - } - function pipelineEmitInSourceFileContext(node) { - var kind = node.kind; - switch (kind) { - case 261: - return emitSourceFile(node); - } - } - function pipelineEmitInIdentifierNameContext(node) { - var kind = node.kind; - switch (kind) { - case 70: - return emitIdentifier(node); - } - } - function pipelineEmitInUnspecifiedContext(node) { - var kind = node.kind; switch (kind) { case 13: case 14: @@ -47306,229 +49126,197 @@ var ts; return emitLiteral(node); case 70: return emitIdentifier(node); - case 75: - case 78: - case 83: - case 104: - case 111: - case 112: - case 113: - case 114: - case 116: - case 117: - case 118: - case 119: - case 120: - case 121: - case 122: - case 123: - case 124: - case 125: - case 127: - case 128: - case 129: - case 130: - case 131: - case 132: - case 133: - case 134: - case 135: - case 136: - case 137: - case 138: - case 139: - case 140: - writeTokenText(kind); - return; - case 141: - return emitQualifiedName(node); case 142: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 143: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 144: - return emitParameter(node); + return emitTypeParameter(node); case 145: - return emitDecorator(node); + return emitParameter(node); case 146: - return emitPropertySignature(node); + return emitDecorator(node); case 147: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 148: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 149: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 150: - return emitConstructor(node); + return emitMethodDeclaration(node); case 151: + return emitConstructor(node); case 152: - return emitAccessorDeclaration(node); case 153: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 154: - return emitConstructSignature(node); + return emitCallSignature(node); case 155: - return emitIndexSignature(node); + return emitConstructSignature(node); case 156: - return emitTypePredicate(node); + return emitIndexSignature(node); case 157: - return emitTypeReference(node); + return emitTypePredicate(node); case 158: - return emitFunctionType(node); + return emitTypeReference(node); case 159: - return emitConstructorType(node); + return emitFunctionType(node); case 160: - return emitTypeQuery(node); + return emitConstructorType(node); case 161: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 162: - return emitArrayType(node); + return emitTypeLiteral(node); case 163: - return emitTupleType(node); + return emitArrayType(node); case 164: - return emitUnionType(node); + return emitTupleType(node); case 165: - return emitIntersectionType(node); + return emitUnionType(node); case 166: - return emitParenthesizedType(node); - case 199: - return emitExpressionWithTypeArguments(node); + return emitIntersectionType(node); case 167: - return emitThisType(); + return emitParenthesizedType(node); + case 200: + return emitExpressionWithTypeArguments(node); case 168: - return emitTypeOperator(node); + return emitThisType(); case 169: - return emitIndexedAccessType(node); + return emitTypeOperator(node); case 170: - return emitMappedType(node); + return emitIndexedAccessType(node); case 171: - return emitLiteralType(node); + return emitMappedType(node); case 172: - return emitObjectBindingPattern(node); + return emitLiteralType(node); case 173: - return emitArrayBindingPattern(node); + return emitObjectBindingPattern(node); case 174: + return emitArrayBindingPattern(node); + case 175: return emitBindingElement(node); - case 202: - return emitTemplateSpan(node); - case 203: - return emitSemicolonClassElement(); case 204: - return emitBlock(node); + return emitTemplateSpan(node); case 205: - return emitVariableStatement(node); + return emitSemicolonClassElement(); case 206: - return emitEmptyStatement(); + return emitBlock(node); case 207: - return emitExpressionStatement(node); + return emitVariableStatement(node); case 208: - return emitIfStatement(node); + return emitEmptyStatement(); case 209: - return emitDoStatement(node); + return emitExpressionStatement(node); case 210: - return emitWhileStatement(node); + return emitIfStatement(node); case 211: - return emitForStatement(node); + return emitDoStatement(node); case 212: - return emitForInStatement(node); + return emitWhileStatement(node); case 213: - return emitForOfStatement(node); + return emitForStatement(node); case 214: - return emitContinueStatement(node); + return emitForInStatement(node); case 215: - return emitBreakStatement(node); + return emitForOfStatement(node); case 216: - return emitReturnStatement(node); + return emitContinueStatement(node); case 217: - return emitWithStatement(node); + return emitBreakStatement(node); case 218: - return emitSwitchStatement(node); + return emitReturnStatement(node); case 219: - return emitLabeledStatement(node); + return emitWithStatement(node); case 220: - return emitThrowStatement(node); + return emitSwitchStatement(node); case 221: - return emitTryStatement(node); + return emitLabeledStatement(node); case 222: - return emitDebuggerStatement(node); + return emitThrowStatement(node); case 223: - return emitVariableDeclaration(node); + return emitTryStatement(node); case 224: - return emitVariableDeclarationList(node); + return emitDebuggerStatement(node); case 225: - return emitFunctionDeclaration(node); + return emitVariableDeclaration(node); case 226: - return emitClassDeclaration(node); + return emitVariableDeclarationList(node); case 227: - return emitInterfaceDeclaration(node); + return emitFunctionDeclaration(node); case 228: - return emitTypeAliasDeclaration(node); + return emitClassDeclaration(node); case 229: - return emitEnumDeclaration(node); + return emitInterfaceDeclaration(node); case 230: - return emitModuleDeclaration(node); + return emitTypeAliasDeclaration(node); case 231: - return emitModuleBlock(node); + return emitEnumDeclaration(node); case 232: - return emitCaseBlock(node); + return emitModuleDeclaration(node); + case 233: + return emitModuleBlock(node); case 234: - return emitImportEqualsDeclaration(node); - case 235: - return emitImportDeclaration(node); + return emitCaseBlock(node); case 236: - return emitImportClause(node); + return emitImportEqualsDeclaration(node); case 237: - return emitNamespaceImport(node); + return emitImportDeclaration(node); case 238: - return emitNamedImports(node); + return emitImportClause(node); case 239: - return emitImportSpecifier(node); + return emitNamespaceImport(node); case 240: - return emitExportAssignment(node); + return emitNamedImports(node); case 241: - return emitExportDeclaration(node); + return emitImportSpecifier(node); case 242: - return emitNamedExports(node); + return emitExportAssignment(node); case 243: - return emitExportSpecifier(node); + return emitExportDeclaration(node); case 244: - return; + return emitNamedExports(node); case 245: + return emitExportSpecifier(node); + case 246: + return; + case 247: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 248: - return emitJsxOpeningElement(node); - case 249: - return emitJsxClosingElement(node); case 250: - return emitJsxAttribute(node); + return emitJsxOpeningElement(node); case 251: - return emitJsxSpreadAttribute(node); + return emitJsxClosingElement(node); case 252: - return emitJsxExpression(node); + return emitJsxAttribute(node); case 253: - return emitCaseClause(node); + return emitJsxAttributes(node); case 254: - return emitDefaultClause(node); + return emitJsxSpreadAttribute(node); case 255: - return emitHeritageClause(node); + return emitJsxExpression(node); case 256: - return emitCatchClause(node); + return emitCaseClause(node); case 257: - return emitPropertyAssignment(node); + return emitDefaultClause(node); case 258: - return emitShorthandPropertyAssignment(node); + return emitHeritageClause(node); case 259: - return emitSpreadAssignment(node); + return emitCatchClause(node); case 260: + return emitPropertyAssignment(node); + case 261: + return emitShorthandPropertyAssignment(node); + case 262: + return emitSpreadAssignment(node); + case 263: return emitEnumMember(node); } if (ts.isExpression(node)) { return pipelineEmitWithSubstitution(1, node); } } - function pipelineEmitInExpressionContext(node) { + function pipelineEmitExpression(node) { var kind = node.kind; switch (kind) { case 8: @@ -47546,66 +49334,79 @@ var ts; case 98: writeTokenText(kind); return; - case 175: - return emitArrayLiteralExpression(node); case 176: - return emitObjectLiteralExpression(node); + return emitArrayLiteralExpression(node); case 177: - return emitPropertyAccessExpression(node); + return emitObjectLiteralExpression(node); case 178: - return emitElementAccessExpression(node); + return emitPropertyAccessExpression(node); case 179: - return emitCallExpression(node); + return emitElementAccessExpression(node); case 180: - return emitNewExpression(node); + return emitCallExpression(node); case 181: - return emitTaggedTemplateExpression(node); + return emitNewExpression(node); case 182: - return emitTypeAssertionExpression(node); + return emitTaggedTemplateExpression(node); case 183: - return emitParenthesizedExpression(node); + return emitTypeAssertionExpression(node); case 184: - return emitFunctionExpression(node); + return emitParenthesizedExpression(node); case 185: - return emitArrowFunction(node); + return emitFunctionExpression(node); case 186: - return emitDeleteExpression(node); + return emitArrowFunction(node); case 187: - return emitTypeOfExpression(node); + return emitDeleteExpression(node); case 188: - return emitVoidExpression(node); + return emitTypeOfExpression(node); case 189: - return emitAwaitExpression(node); + return emitVoidExpression(node); case 190: - return emitPrefixUnaryExpression(node); + return emitAwaitExpression(node); case 191: - return emitPostfixUnaryExpression(node); + return emitPrefixUnaryExpression(node); case 192: - return emitBinaryExpression(node); + return emitPostfixUnaryExpression(node); case 193: - return emitConditionalExpression(node); + return emitBinaryExpression(node); case 194: - return emitTemplateExpression(node); + return emitConditionalExpression(node); case 195: - return emitYieldExpression(node); + return emitTemplateExpression(node); case 196: - return emitSpreadExpression(node); + return emitYieldExpression(node); case 197: - return emitClassExpression(node); + return emitSpreadExpression(node); case 198: + return emitClassExpression(node); + case 199: return; - case 200: - return emitAsExpression(node); case 201: + return emitAsExpression(node); + case 202: return emitNonNullExpression(node); - case 246: + case 203: + return emitMetaProperty(node); + case 248: return emitJsxElement(node); - case 247: + case 249: return emitJsxSelfClosingElement(node); - case 294: + case 298: return emitPartiallyEmittedExpression(node); - case 297: - return writeLines(node.text); + } + } + function emitBodyIndirect(node, elements, emitCallback) { + if (emitBodyWithDetachedComments) { + emitBodyWithDetachedComments(node, elements, emitCallback); + } + else { + emitCallback(node); + } + } + function emitHelpersIndirect(node) { + if (onEmitHelpers) { + onEmitHelpers(node, writeLines); } } function emitNumericLiteral(node) { @@ -47616,7 +49417,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralTextOfNode(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) + if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } @@ -47703,7 +49504,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 151 ? "get " : "set "); + write(node.kind === 152 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -47803,17 +49604,13 @@ var ts; write("{"); writeLine(); increaseIndent(); - if (node.readonlyToken) { - write("readonly "); - } + writeIfPresent(node.readonlyToken, "readonly "); write("["); emit(node.typeParameter.name); write(" in "); emit(node.typeParameter.constraint); write("]"); - if (node.questionToken) { - write("?"); - } + writeIfPresent(node.questionToken, "?"); write(": "); emit(node.type); write(";"); @@ -47885,7 +49682,7 @@ var ts; var indentAfterDot = false; if (!(ts.getEmitFlags(node) & 65536)) { var dotRangeStart = node.expression.end; - var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; + var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; var dotToken = { kind: 22, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); @@ -47901,13 +49698,15 @@ var ts; function needsDotDotForPropertyAccess(expression) { if (expression.kind === 8) { var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(22)) < 0; + return ts.getNumericLiteralFlags(text, 15) === 0 + && !expression.isOctalLiteral + && text.indexOf(ts.tokenToString(22)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { var constantValue = ts.getConstantValue(expression); return isFinite(constantValue) && Math.floor(constantValue) === constantValue - && compilerOptions.removeComments; + && printerOptions.removeComments; } } function emitElementAccessExpression(node) { @@ -47933,11 +49732,9 @@ var ts; emitExpression(node.template); } function emitTypeAssertionExpression(node) { - if (node.type) { - write("<"); - emit(node.type); - write(">"); - } + write("<"); + emit(node.type); + write(">"); emitExpression(node.expression); } function emitParenthesizedExpression(node) { @@ -47984,7 +49781,7 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 190 + return operand.kind === 191 && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); } @@ -48050,6 +49847,11 @@ var ts; emitExpression(node.expression); write("!"); } + function emitMetaProperty(node) { + writeToken(node.keywordToken, node.pos); + write("."); + emit(node.name); + } function emitTemplateSpan(node) { emitExpression(node.expression); emit(node.literal); @@ -48063,6 +49865,9 @@ var ts; else { writeToken(16, node.pos, node); emitBlockStatements(node); + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); writeToken(17, node.statements.end, node); } } @@ -48092,27 +49897,27 @@ var ts; writeToken(18, openParenPos, node); emitExpression(node.expression); writeToken(19, node.expression.end, node); - emitEmbeddedStatement(node.thenStatement); + emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { - writeLine(); + writeLineOrSpace(node); writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 208) { + if (node.elseStatement.kind === 210) { write(" "); emit(node.elseStatement); } else { - emitEmbeddedStatement(node.elseStatement); + emitEmbeddedStatement(node, node.elseStatement); } } } function emitDoStatement(node) { write("do"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { write(" "); } else { - writeLine(); + writeLineOrSpace(node); } write("while ("); emitExpression(node.expression); @@ -48122,7 +49927,7 @@ var ts; write("while ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -48134,7 +49939,7 @@ var ts; write(";"); emitExpressionWithPrefix(" ", node.incrementor); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -48144,7 +49949,7 @@ var ts; write(" in "); emitExpression(node.expression); writeToken(19, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -48154,11 +49959,11 @@ var ts; write(" of "); emitExpression(node.expression); writeToken(19, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 224) { + if (node.kind === 226) { emit(node); } else { @@ -48185,7 +49990,7 @@ var ts; write("with ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { var openParenPos = writeToken(97, node.pos); @@ -48209,9 +50014,12 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchClause); + if (node.catchClause) { + writeLineOrSpace(node); + emit(node.catchClause); + } if (node.finallyBlock) { - writeLine(); + writeLineOrSpace(node); write("finally "); emit(node.finallyBlock); } @@ -48252,11 +50060,10 @@ var ts; emitBlockFunctionBody(body); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); emitSignatureHead(node); emitBlockFunctionBody(body); - tempFlags = savedTempFlags; + popNameGenerationScope(); } if (indentedFlag) { decreaseIndent(); @@ -48305,9 +50112,10 @@ var ts; function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) + var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine - : emitBlockFunctionBodyWorker); + : emitBlockFunctionBodyWorker; + emitBodyIndirect(body, body.statements, emitBlockFunctionBody); decreaseIndent(); writeToken(17, body.statements.end, body); } @@ -48316,8 +50124,9 @@ var ts; } function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) { var statementOffset = emitPrologueDirectives(body.statements, true); - var helpersEmitted = emitHelpers(body); - if (statementOffset === 0 && !helpersEmitted && emitBlockFunctionBodyOnSingleLine) { + var pos = writer.getTextPos(); + emitHelpersIndirect(body); + if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); emitList(body, body.statements, 384); increaseIndent(); @@ -48340,15 +50149,14 @@ var ts; } emitTypeParameters(node, node.typeParameters); emitList(node, node.heritageClauses, 256); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 65); write("}"); + popNameGenerationScope(); if (indentedFlag) { decreaseIndent(); } - tempFlags = savedTempFlags; } function emitInterfaceDeclaration(node) { emitDecorators(node, node.decorators); @@ -48375,19 +50183,18 @@ var ts; emitModifiers(node, node.modifiers); write("enum "); emit(node.name); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 81); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 230) { + while (body.kind === 232) { write("."); emit(body.name); body = body.body; @@ -48400,13 +50207,12 @@ var ts; write("{ }"); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write("{"); increaseIndent(); emitBlockStatements(node); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } } function emitCaseBlock(node) { @@ -48508,14 +50314,18 @@ var ts; write("<"); emitJsxTagName(node.tagName); write(" "); - emitList(node, node.attributes, 131328); + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write("/>"); } function emitJsxOpeningElement(node) { write("<"); emitJsxTagName(node.tagName); - writeIfAny(node.attributes, " "); - emitList(node, node.attributes, 131328); + writeIfAny(node.attributes.properties, " "); + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write(">"); } function emitJsxText(node) { @@ -48526,6 +50336,9 @@ var ts; emitJsxTagName(node.tagName); write(">"); } + function emitJsxAttributes(node) { + emitList(node, node.properties, 131328); + } function emitJsxAttribute(node) { emit(node.name); emitWithPrefix("=", node.initializer); @@ -48538,6 +50351,9 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); + if (node.dotDotDotToken) { + write("..."); + } emitExpression(node.expression); write("}"); } @@ -48580,7 +50396,6 @@ var ts; emitList(node, node.types, 272); } function emitCatchClause(node) { - writeLine(); var openParenPos = writeToken(73, node.pos); write(" "); writeToken(18, openParenPos); @@ -48593,7 +50408,7 @@ var ts; emit(node.name); write(": "); var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512) === 0) { + if (emitTrailingCommentsOfPosition && (ts.getEmitFlags(initializer) & 512) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -48619,16 +50434,15 @@ var ts; function emitSourceFile(node) { writeLine(); emitShebang(); - emitBodyWithDetachedComments(node, node.statements, emitSourceFileWorker); + emitBodyIndirect(node, node.statements, emitSourceFileWorker); } function emitSourceFileWorker(node) { var statements = node.statements; var statementOffset = emitPrologueDirectives(statements); - var savedTempFlags = tempFlags; - tempFlags = 0; - emitHelpers(node); + pushNameGenerationScope(); + emitHelpersIndirect(node); emitList(node, statements, 1, statementOffset); - tempFlags = savedTempFlags; + popNameGenerationScope(); } function emitPartiallyEmittedExpression(node) { emitExpression(node.expression); @@ -48647,67 +50461,8 @@ var ts; } return statements.length; } - function emitHelpers(node, isBundle) { - var sourceFile = ts.isSourceFile(node) ? node : currentSourceFile; - var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); - var shouldBundle = ts.isSourceFile(node) && !isOwnFileEmit; - var helpersEmitted = false; - var helpers = ts.getEmitHelpers(node); - if (helpers) { - for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { - var helper = _b[_a]; - if (!helper.scoped) { - if (shouldSkip) - continue; - if (shouldBundle) { - if (bundledHelpers[helper.name]) { - continue; - } - bundledHelpers[helper.name] = true; - } - } - else if (isBundle) { - continue; - } - writeLines(helper.text); - helpersEmitted = true; - } - } - if (helpersEmitted) { - writeLine(); - } - return helpersEmitted; - } - function writeLines(text) { - var lines = text.split(/\r\n?|\n/g); - var indentation = guessIndentation(lines); - for (var i = 0; i < lines.length; i++) { - var line = indentation ? lines[i].slice(indentation) : lines[i]; - if (line.length) { - if (i > 0) { - writeLine(); - } - write(line); - } - } - } - function guessIndentation(lines) { - var indentation; - for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { - var line = lines_1[_a]; - for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { - if (!ts.isWhiteSpace(line.charCodeAt(i))) { - if (indentation === undefined || i < indentation) { - indentation = i; - break; - } - } - } - } - return indentation; - } function emitShebang() { - var shebang = ts.getShebang(currentText); + var shebang = ts.getShebang(currentSourceFile.text); if (shebang) { write(shebang); writeLine(); @@ -48737,8 +50492,8 @@ var ts; write(suffix); } } - function emitEmbeddedStatement(node) { - if (ts.isBlock(node)) { + function emitEmbeddedStatement(parent, node) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1) { write(" "); emit(node); } @@ -48822,6 +50577,9 @@ var ts; for (var i = 0; i < count; i++) { var child = children[start + i]; if (previousSibling) { + if (delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } write(delimiter); if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { if ((format & (3 | 64)) === 0) { @@ -48836,8 +50594,10 @@ var ts; } } if (shouldEmitInterveningComments) { - var commentRange = ts.getCommentRange(child); - emitTrailingCommentsOfPosition(commentRange.pos); + if (emitTrailingCommentsOfPosition) { + var commentRange = ts.getCommentRange(child); + emitTrailingCommentsOfPosition(commentRange.pos); + } } else { shouldEmitInterveningComments = mayEmitInterveningComments; @@ -48853,6 +50613,9 @@ var ts; if (format & 16 && hasTrailingComma) { write(","); } + if (previousSibling && delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } if (format & 64) { decreaseIndent(); } @@ -48867,24 +50630,73 @@ var ts; write(getClosingBracket(format)); } } + function write(s) { + writer.write(s); + } + function writeLine() { + writer.writeLine(); + } + function increaseIndent() { + writer.increaseIndent(); + } + function decreaseIndent() { + writer.decreaseIndent(); + } function writeIfAny(nodes, text) { - if (nodes && nodes.length > 0) { + if (ts.some(nodes)) { write(text); } } function writeIfPresent(node, text) { - if (node !== undefined) { + if (node) { write(text); } } function writeToken(token, pos, contextNode) { - return emitTokenWithSourceMap(contextNode, token, pos, writeTokenText); + return onEmitSourceMapOfToken + ? onEmitSourceMapOfToken(contextNode, token, pos, writeTokenText) + : writeTokenText(token, pos); } function writeTokenText(token, pos) { var tokenString = ts.tokenToString(token); write(tokenString); return pos < 0 ? pos : pos + tokenString.length; } + function writeLineOrSpace(node) { + if (ts.getEmitFlags(node) & 1) { + write(" "); + } + else { + writeLine(); + } + } + function writeLines(text) { + var lines = text.split(/\r\n?|\n/g); + var indentation = guessIndentation(lines); + for (var i = 0; i < lines.length; i++) { + var line = indentation ? lines[i].slice(indentation) : lines[i]; + if (line.length) { + writeLine(); + write(line); + writeLine(); + } + } + } + function guessIndentation(lines) { + var indentation; + for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { + var line = lines_1[_a]; + for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { + if (!ts.isWhiteSpace(line.charCodeAt(i))) { + if (indentation === undefined || i < indentation) { + indentation = i; + break; + } + } + } + } + return indentation; + } function increaseIndentIf(value, valueToWriteWhenNotIndenting) { if (value) { increaseIndent(); @@ -48989,15 +50801,23 @@ var ts; && !ts.nodeIsSynthesized(node2) && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } + function isSingleLineEmptyBlock(block) { + return !block.multiLine + && isEmptyBlock(block); + } + function isEmptyBlock(block) { + return block.statements.length === 0 + && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + } function skipSynthesizedParentheses(node) { - while (node.kind === 183 && ts.nodeIsSynthesized(node)) { + while (node.kind === 184 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; } function getTextOfNode(node, includeTrivia) { if (ts.isGeneratedIdentifier(node)) { - return getGeneratedIdentifier(node); + return generateName(node); } else if (ts.isIdentifier(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { return ts.unescapeIdentifier(node.text); @@ -49022,23 +50842,37 @@ var ts; } return ts.getLiteralText(node, currentSourceFile, languageVersion); } - function isSingleLineEmptyBlock(block) { - return !block.multiLine - && isEmptyBlock(block); + function pushNameGenerationScope() { + tempFlagsStack.push(tempFlags); + tempFlags = 0; } - function isEmptyBlock(block) { - return block.statements.length === 0 - && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + function popNameGenerationScope() { + tempFlags = tempFlagsStack.pop(); + } + function generateName(name) { + if (name.autoGenerateKind === 4) { + var node = getNodeForGeneratedName(name); + return generateNameCached(node); + } + else { + var autoGenerateId = name.autoGenerateId; + return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(makeName(name))); + } + } + function generateNameCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); } function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentFileIdentifiers, name) && - !ts.hasProperty(generatedNameSet, name); + return !(hasGlobalName && hasGlobalName(name)) + && !currentSourceFile.identifiers.has(name) + && !generatedNames.has(name); } function isUniqueLocalName(name, container) { for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { + if (node.locals) { + var local = node.locals.get(name); + if (local && local.flags & (107455 | 1048576 | 8388608)) { return false; } } @@ -49047,21 +50881,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_40 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_40)) { + var name = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name)) { tempFlags |= flags; - return name_40; + return name; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_41 = count < 26 + var name = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_41)) { - return name_41; + if (isUniqueName(name)) { + return name; } } } @@ -49074,7 +50908,8 @@ var ts; while (true) { var generatedName = baseName + i; if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; + generatedNames.set(generatedName, generatedName); + return generatedName; } i++; } @@ -49095,34 +50930,44 @@ var ts; function generateNameForClassExpression() { return makeUniqueName("class"); } + function generateNameForMethodOrAccessor(node) { + if (ts.isIdentifier(node.name)) { + return generateNameCached(node.name); + } + return makeTempVariableName(0); + } function generateNameForNode(node) { switch (node.kind) { case 70: return makeUniqueName(getTextOfNode(node)); - case 230: - case 229: + case 232: + case 231: return generateNameForModuleOrEnum(node); - case 235: - case 241: + case 237: + case 243: return generateNameForImportOrExportDeclaration(node); - case 225: - case 226: - case 240: + case 227: + case 228: + case 242: return generateNameForExportDefault(); - case 197: + case 198: return generateNameForClassExpression(); + case 150: + case 152: + case 153: + return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0); } } - function generateName(name) { + function makeName(name) { switch (name.autoGenerateKind) { case 1: return makeTempVariableName(0); case 2: return makeTempVariableName(268435456); case 3: - return makeUniqueName(name.text); + return makeUniqueName(ts.unescapeIdentifier(name.text)); } ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } @@ -49141,44 +50986,33 @@ var ts; } return node; } - function getGeneratedIdentifier(name) { - if (name.autoGenerateKind === 4) { - var node = getNodeForGeneratedName(name); - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); - } - else { - var autoGenerateId = name.autoGenerateId; - return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(generateName(name))); - } - } - function createDelimiterMap() { - var delimiters = []; - delimiters[0] = ""; - delimiters[16] = ","; - delimiters[4] = " |"; - delimiters[8] = " &"; - return delimiters; - } - function getDelimiter(format) { - return delimiters[format & 28]; - } - function createBracketsMap() { - var brackets = []; - brackets[512] = ["{", "}"]; - brackets[1024] = ["(", ")"]; - brackets[2048] = ["<", ">"]; - brackets[4096] = ["[", "]"]; - return brackets; - } - function getOpeningBracket(format) { - return brackets[format & 7680][0]; - } - function getClosingBracket(format) { - return brackets[format & 7680][1]; - } } - ts.emitFiles = emitFiles; + ts.createPrinter = createPrinter; + function createDelimiterMap() { + var delimiters = []; + delimiters[0] = ""; + delimiters[16] = ","; + delimiters[4] = " |"; + delimiters[8] = " &"; + return delimiters; + } + function getDelimiter(format) { + return delimiters[format & 28]; + } + function createBracketsMap() { + var brackets = []; + brackets[512] = ["{", "}"]; + brackets[1024] = ["(", ")"]; + brackets[2048] = ["<", ">"]; + brackets[4096] = ["[", "]"]; + return brackets; + } + function getOpeningBracket(format) { + return brackets[format & 7680][0]; + } + function getClosingBracket(format) { + return brackets[format & 7680][1]; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -49214,7 +51048,8 @@ var ts; commonPathComponents = sourcePathComponents; return; } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + var n = Math.min(commonPathComponents.length, sourcePathComponents.length); + for (var i = 0; i < n; i++) { if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { if (i === 0) { return true; @@ -49261,11 +51096,11 @@ var ts; return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; } function directoryExists(directoryPath) { - if (directoryPath in existingDirectories) { + if (existingDirectories.has(directoryPath)) { return true; } if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; + existingDirectories.set(directoryPath, true); return true; } return false; @@ -49284,9 +51119,10 @@ var ts; } var hash = ts.sys.createHash(data); var mtimeBefore = ts.sys.getModifiedTime(fileName); - if (mtimeBefore && fileName in outputFingerprints) { - var fingerprint = outputFingerprints[fileName]; - if (fingerprint.byteOrderMark === writeByteOrderMark && + if (mtimeBefore) { + var fingerprint = outputFingerprints.get(fileName); + if (fingerprint && + fingerprint.byteOrderMark === writeByteOrderMark && fingerprint.hash === hash && fingerprint.mtime.getTime() === mtimeBefore.getTime()) { return; @@ -49294,11 +51130,11 @@ var ts; } ts.sys.writeFile(fileName, data, writeByteOrderMark); var mtimeAfter = ts.sys.getModifiedTime(fileName); - outputFingerprints[fileName] = { + outputFingerprints.set(fileName, { hash: hash, byteOrderMark: writeByteOrderMark, mtime: mtimeAfter - }; + }); } function writeFile(fileName, data, writeByteOrderMark, onError) { try { @@ -49397,10 +51233,14 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_42 = names_1[_i]; - var result = name_42 in cache - ? cache[name_42] - : cache[name_42] = loader(name_42, containingFile); + var name = names_1[_i]; + var result = void 0; + if (cache.has(name)) { + result = cache.get(name); + } + else { + cache.set(name, result = loader(name, containingFile)); + } resolutions.push(result); } return resolutions; @@ -49425,6 +51265,7 @@ var ts; var currentDirectory = host.getCurrentDirectory(); var supportedExtensions = ts.getSupportedExtensions(options); var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); + var moduleResolutionCache; var resolveModuleNamesWorker; if (host.resolveModuleNames) { resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { @@ -49437,7 +51278,8 @@ var ts; }); }; } else { - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -49473,6 +51315,7 @@ var ts; } } } + moduleResolutionCache = undefined; oldProgram = undefined; program = { getRootFileNames: function () { return rootNames; }, @@ -49506,7 +51349,7 @@ var ts; return program; function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filterSourceFilesInDirectory(files, isSourceFileFromExternalLibrary); + var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); } @@ -49525,7 +51368,7 @@ var ts; classifiableNames = ts.createMap(); for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { var sourceFile = files_2[_i]; - ts.copyProperties(sourceFile.classifiableNames, classifiableNames); + ts.copyEntries(sourceFile.classifiableNames, classifiableNames); } } return classifiableNames; @@ -49679,7 +51522,7 @@ var ts; newSourceFile.resolvedModules = oldSourceFile.resolvedModules; newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } - for (var i = 0, len = newSourceFiles.length; i < len; i++) { + for (var i = 0; i < newSourceFiles.length; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; @@ -49708,7 +51551,7 @@ var ts; }; } function isSourceFileFromExternalLibrary(file) { - return sourceFilesFoundSearchingNodeModules[file.path]; + return sourceFilesFoundSearchingNodeModules.get(file.path); } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); @@ -49825,57 +51668,57 @@ var ts; return diagnostics; function walk(node) { switch (parent.kind) { - case 144: - case 147: + case 145: + case 148: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 184: - case 225: + case 153: case 185: + case 227: + case 186: + case 227: case 225: - case 223: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 234: + case 236: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 240: + case 242: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 255: + case 258: var heritageClause = node; if (heritageClause.token === 107) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 227: + case 229: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 230: + case 232: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 228: + case 230: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 229: + case 231: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 182: + case 183: var typeAssertionExpression = node; diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; @@ -49890,26 +51733,26 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 226: - case 149: - case 148: + case 228: case 150: + case 149: case 151: case 152: - case 184: - case 225: + case 153: case 185: - case 225: + case 227: + case 186: + case 227: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 205: + case 207: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 205); + return checkModifiers(nodes, parent.kind === 207); } break; - case 147: + case 148: if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; @@ -49920,15 +51763,15 @@ var ts; return; } break; - case 144: + case 145: if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 179: case 180: - case 199: + case 181: + case 200: if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); return; @@ -50016,11 +51859,10 @@ var ts; if (options.importHelpers && (options.isolatedModules || isExternalModuleFile) && !file.isDeclarationFile) { - var externalHelpersModuleReference = ts.createSynthesizedNode(9); - externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(235); - importDecl.parent = file; + var externalHelpersModuleReference = ts.createLiteral(ts.externalHelpersModuleNameText); + var importDecl = ts.createImportDeclaration(undefined, undefined, undefined); externalHelpersModuleReference.parent = importDecl; + importDecl.parent = file; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -50036,9 +51878,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 235: - case 234: - case 241: + case 237: + case 236: + case 243: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -50050,7 +51892,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 230: + case 232: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -50134,18 +51976,18 @@ var ts; if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd); } - if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { - sourceFilesFoundSearchingNodeModules[file_1.path] = false; + if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth == 0) { + sourceFilesFoundSearchingNodeModules.set(file_1.path, false); if (!options.noResolve) { processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } - else if (file_1 && modulesWithElidedImports[file_1.path]) { + else if (file_1 && modulesWithElidedImports.get(file_1.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } } @@ -50161,7 +52003,7 @@ var ts; }); filesByName.set(path, file); if (file) { - sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0); + sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; if (host.useCaseSensitiveFileNames()) { var existingFile = filesByNameIgnoreCase.get(path); @@ -50205,7 +52047,7 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { - var previousResolution = resolvedTypeReferenceDirectives[typeReferenceDirective]; + var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { return; } @@ -50233,7 +52075,7 @@ var ts; fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { - resolvedTypeReferenceDirectives[typeReferenceDirective] = resolvedTypeReferenceDirective; + resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); } } function createDiagnostic(refFile, refPos, refEnd, message) { @@ -50274,7 +52116,7 @@ var ts; var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { - modulesWithElidedImports[file.path] = true; + modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = ts.toPath(resolvedFileName, currentDirectory, getCanonicalFileName); @@ -50292,8 +52134,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var file = sourceFiles_6[_i]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var file = sourceFiles_3[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -50304,8 +52146,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -50456,7 +52298,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { + ts.forEachEmittedFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -50569,12 +52411,13 @@ var ts; }, { name: "jsx", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "preserve": 1, + "react-native": 3, "react": 2 }), paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, }, { name: "reactNamespace", @@ -50604,7 +52447,7 @@ var ts; { name: "module", shortName: "m", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "none": ts.ModuleKind.None, "commonjs": ts.ModuleKind.CommonJS, "amd": ts.ModuleKind.AMD, @@ -50618,7 +52461,7 @@ var ts; }, { name: "newLine", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "crlf": 0, "lf": 1 }), @@ -50715,8 +52558,8 @@ var ts; shortName: "p", type: "string", isFilePath: true, - description: ts.Diagnostics.Compile_the_project_in_the_given_directory, - paramType: ts.Diagnostics.DIRECTORY + description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY }, { name: "removeComments", @@ -50766,7 +52609,7 @@ var ts; { name: "target", shortName: "t", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "es3": 0, "es5": 1, "es6": 2, @@ -50803,7 +52646,7 @@ var ts; }, { name: "moduleResolution", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "node": ts.ModuleResolutionKind.NodeJs, "classic": ts.ModuleResolutionKind.Classic, }), @@ -50908,7 +52751,7 @@ var ts; type: "list", element: { name: "lib", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "es5": "lib.es5.d.ts", "es6": "lib.es2015.d.ts", "es2015": "lib.es2015.d.ts", @@ -50954,6 +52797,15 @@ var ts; name: "alwaysStrict", type: "boolean", description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + }, + { + name: "plugins", + type: "list", + isTSConfigOnly: true, + element: { + name: "plugin", + type: "object" + } } ]; ts.typeAcquisitionDeclarations = [ @@ -51008,9 +52860,9 @@ var ts; var optionNameMap = ts.createMap(); var shortOptionNames = ts.createMap(); ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; + optionNameMap.set(option.name.toLowerCase(), option); if (option.shortName) { - shortOptionNames[option.shortName] = option.name; + shortOptionNames.set(option.shortName, option.name); } }); optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; @@ -51018,7 +52870,7 @@ var ts; } ts.getOptionNameMap = getOptionNameMap; function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; @@ -51067,11 +52919,12 @@ var ts; } else if (s.charCodeAt(0) === 45) { s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); - if (s in shortOptionNames) { - s = shortOptionNames[s]; + var short = shortOptionNames.get(s); + if (short !== undefined) { + s = short; } - if (s in optionNameMap) { - var opt = optionNameMap[s]; + var opt = optionNameMap.get(s); + if (opt) { if (opt.isTSConfigOnly) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); } @@ -51197,19 +53050,18 @@ var ts; } } function getNameOfCompilerOptionValue(value, customTypeMap) { - for (var key in customTypeMap) { - if (customTypeMap[key] === value) { + return ts.forEachEntry(customTypeMap, function (mapValue, key) { + if (mapValue === value) { return key; } - } - return undefined; + }); } function serializeCompilerOptions(options) { - var result = ts.createMap(); + var result = {}; var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_43 in options) { - if (ts.hasProperty(options, name_43)) { - switch (name_43) { + for (var name in options) { + if (ts.hasProperty(options, name)) { + switch (name) { case "init": case "watch": case "version": @@ -51217,12 +53069,12 @@ var ts; case "project": break; default: - var value = options[name_43]; - var optionDefinition = optionsNameMap[name_43.toLowerCase()]; + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { - result[name_43] = value; + result[name] = value; } else { if (optionDefinition.type === "list") { @@ -51231,10 +53083,10 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_43] = convertedValue; + result[name] = convertedValue; } else { - result[name_43] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -51268,6 +53120,7 @@ var ts; if (resolutionStack === void 0) { resolutionStack = []; } if (extraFileExtensions === void 0) { extraFileExtensions = []; } var errors = []; + basePath = ts.normalizeSlashes(basePath); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -51440,8 +53293,8 @@ var ts; } var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); for (var id in jsonOptions) { - if (id in optionNameMap) { - var opt = optionNameMap[id]; + var opt = optionNameMap.get(id); + if (opt) { defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); } else { @@ -51475,8 +53328,9 @@ var ts; } function convertJsonOptionOfCustomType(opt, value, errors) { var key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; + var val = opt.type.get(key); + if (val !== undefined) { + return val; } else { errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); @@ -51510,7 +53364,7 @@ var ts; for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { var fileName = fileNames_1[_i]; var file = ts.combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; + literalFileMap.set(keyMapper(file), file); } } if (include && include.length > 0) { @@ -51521,14 +53375,13 @@ var ts; } removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); var key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; + if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) { + wildcardFileMap.set(key, file); } } } - var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); - var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); + var literalFiles = ts.arrayFrom(literalFileMap.values()); + var wildcardFiles = ts.arrayFrom(wildcardFileMap.values()); return { fileNames: literalFiles.concat(wildcardFiles), wildcardDirectories: wildcardDirectories @@ -51536,8 +53389,8 @@ var ts; } function validateSpecs(specs, errors, allowTrailingRecursion) { var validSpecs = []; - for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { - var spec = specs_2[_i]; + for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { + var spec = specs_1[_i]; if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); } @@ -51556,7 +53409,7 @@ var ts; function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - var wildcardDirectories = ts.createMap(); + var wildcardDirectories = {}; if (include !== undefined) { var recursiveKeys = []; for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { @@ -51577,14 +53430,16 @@ var ts; } } } - for (var key in wildcardDirectories) { - for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { - var recursiveKey = recursiveKeys_1[_a]; - if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; + for (var key in wildcardDirectories) + if (ts.hasProperty(wildcardDirectories, key)) { + for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { + var recursiveKey = recursiveKeys_1[_a]; + if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; + } } } - } + ; } return wildcardDirectories; } @@ -51603,11 +53458,11 @@ var ts; } function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); + var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions); for (var i = 0; i < adjustedExtensionPriority; i++) { var higherPriorityExtension = extensions[i]; var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { return true; } } @@ -51615,17 +53470,13 @@ var ts; } function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); + var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions); for (var i = nextExtensionPriority; i < extensions.length; i++) { var lowerPriorityExtension = extensions[i]; var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; + wildcardFiles.delete(lowerPriorityPath); } } - function addFileToOutput(output, file) { - output.push(file); - return output; - } function caseSensitiveKeyMapper(key) { return key; } @@ -51686,11 +53537,13 @@ var ts; var gutterSeparator = " "; var resetEscapeSequence = "\u001b[0m"; var ellipsis = "..."; - var categoryFormatMap = ts.createMap((_a = {}, - _a[ts.DiagnosticCategory.Warning] = yellowForegroundEscapeSequence, - _a[ts.DiagnosticCategory.Error] = redForegroundEscapeSequence, - _a[ts.DiagnosticCategory.Message] = blueForegroundEscapeSequence, - _a)); + function getCategoryFormat(category) { + switch (category) { + case ts.DiagnosticCategory.Warning: return yellowForegroundEscapeSequence; + case ts.DiagnosticCategory.Error: return redForegroundEscapeSequence; + case ts.DiagnosticCategory.Message: return blueForegroundEscapeSequence; + } + } function formatAndReset(text, formatStyle) { return formatStyle + text + resetEscapeSequence; } @@ -51739,7 +53592,7 @@ var ts; output += ts.sys.newLine; output += relativeFileName + "(" + (firstLine + 1) + "," + (firstLineChar + 1) + "): "; } - var categoryColor = categoryFormatMap[diagnostic.category]; + var categoryColor = getCategoryFormat(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; @@ -51751,7 +53604,7 @@ var ts; 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; + output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine) + (ts.sys.newLine + ts.sys.newLine + ts.sys.newLine); ts.sys.write(output); } function padLeft(s, length) { @@ -51930,9 +53783,11 @@ var ts; reportWatchDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Compilation_complete_Watching_for_file_changes)); } function cachedFileExists(fileName) { - return fileName in cachedExistingFiles - ? cachedExistingFiles[fileName] - : cachedExistingFiles[fileName] = hostFileExists(fileName); + var fileExists = cachedExistingFiles.get(fileName); + if (fileExists === undefined) { + cachedExistingFiles.set(fileName, fileExists = hostFileExists(fileName)); + } + return fileExists; } function getSourceFile(fileName, languageVersion, onError) { if (cachedProgram) { @@ -52084,17 +53939,17 @@ var ts; var nameSize = 0; var valueSize = 0; for (var _i = 0, statistics_1 = statistics; _i < statistics_1.length; _i++) { - var _a = statistics_1[_i], name_44 = _a.name, value = _a.value; - if (name_44.length > nameSize) { - nameSize = name_44.length; + var _a = statistics_1[_i], name = _a.name, value = _a.value; + if (name.length > nameSize) { + nameSize = name.length; } if (value.length > valueSize) { valueSize = value.length; } } for (var _b = 0, statistics_2 = statistics; _b < statistics_2.length; _b++) { - var _c = statistics_2[_b], name_45 = _c.name, value = _c.value; - ts.sys.write(padRight(name_45 + ":", nameSize + 2) + padLeft(value.toString(), valueSize) + ts.sys.newLine); + var _c = statistics_2[_b], name = _c.name, value = _c.value; + ts.sys.write(padRight(name + ":", nameSize + 2) + padLeft(value.toString(), valueSize) + ts.sys.newLine); } } function reportStatisticalValue(name, value) { @@ -52148,13 +54003,9 @@ var ts; var description = void 0; if (option.name === "lib") { description = getDiagnosticText(option.description); - var options = []; var element = option.element; var typeMap = element.type; - for (var key in typeMap) { - options.push("'" + key + "'"); - } - optionsDescriptionMap[description] = options; + optionsDescriptionMap.set(description, ts.arrayFrom(typeMap.keys()).map(function (key) { return "'" + key + "'"; })); } else { description = getDiagnosticText(option.description); @@ -52169,7 +54020,7 @@ var ts; for (var i = 0; i < usageColumn.length; i++) { var usage = usageColumn[i]; var description = descriptionColumn[i]; - var kindsList = optionsDescriptionMap[description]; + var kindsList = optionsDescriptionMap.get(description); output.push(usage + makePadding(marginLength - usage.length + 2) + description + ts.sys.newLine); if (kindsList) { output.push(makePadding(marginLength + 4)); @@ -52207,7 +54058,6 @@ var ts; } return; } - var _a; })(ts || (ts = {})); if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) { ts.sys.tryEnableSourceMapsForHost(); diff --git a/lib/tsserver.js b/lib/tsserver.js index 9c17684ed0a..04ad7e50ce9 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -13,13 +13,440 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ts; (function (ts) { + var SyntaxKind; + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 126] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 127] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 128] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 129] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 130] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 131] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 132] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 133] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 134] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 135] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 136] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 137] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 138] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 139] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 140] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 141] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 142] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 143] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 144] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 145] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 146] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 147] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 148] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 149] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 150] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 151] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 152] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 153] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 154] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 155] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 156] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypePredicate"] = 157] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 158] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 159] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 160] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 161] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 162] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 163] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 164] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 165] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 166] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 167] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 168] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 169] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 170] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 171] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 172] = "LiteralType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 173] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 174] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 175] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 176] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 177] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 178] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 179] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 180] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 181] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 182] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 183] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 184] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 185] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 186] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 187] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 188] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 189] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 190] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 191] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 192] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 193] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 194] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 195] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 196] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 197] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 198] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 199] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 200] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 201] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 202] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 203] = "MetaProperty"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 204] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 205] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["Block"] = 206] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 207] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 208] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 209] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 210] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 211] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 212] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 213] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 214] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 215] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 216] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 217] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 218] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 219] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 220] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 221] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 222] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 223] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 224] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 225] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 226] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 227] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 228] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 229] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 230] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 231] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 232] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 233] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 234] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 235] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 236] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 237] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 238] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 239] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 240] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 241] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 242] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 243] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 244] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 245] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 246] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 247] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["JsxElement"] = 248] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 249] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 250] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 251] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 252] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 253] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 254] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 255] = "JsxExpression"; + SyntaxKind[SyntaxKind["CaseClause"] = 256] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 257] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 258] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 259] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 260] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 261] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 262] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 263] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 264] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 265] = "Bundle"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 266] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 267] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 268] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 269] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 270] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 271] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 272] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 273] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 274] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 275] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 276] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 277] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 278] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 279] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 280] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 281] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 282] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 283] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 284] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 285] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 286] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 287] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 288] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 289] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 290] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 291] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 292] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 293] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 294] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 295] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["SyntaxList"] = 296] = "SyntaxList"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 297] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 298] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 299] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 300] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["Count"] = 301] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 141] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 157] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 172] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = 141] = "LastToken"; + SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 142] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 266] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 295] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 282] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 295] = "LastJSDocTagNode"; + })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); + var NodeFlags; + (function (NodeFlags) { + NodeFlags[NodeFlags["None"] = 0] = "None"; + NodeFlags[NodeFlags["Let"] = 1] = "Let"; + NodeFlags[NodeFlags["Const"] = 2] = "Const"; + NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; + NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; + NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 96256] = "ContextFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags"; + })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); + var ModifierFlags; + (function (ModifierFlags) { + ModifierFlags[ModifierFlags["None"] = 0] = "None"; + ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; + ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; + ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; + ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; + ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; + ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; + ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; + ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; + ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; + ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; + ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; + ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + ModifierFlags[ModifierFlags["ExportDefault"] = 513] = "ExportDefault"; + })(ModifierFlags = ts.ModifierFlags || (ts.ModifierFlags = {})); + var JsxFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(JsxFlags = ts.JsxFlags || (ts.JsxFlags = {})); + var RelationComparisonResult; + (function (RelationComparisonResult) { + RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; + RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; + RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); + var GeneratedIdentifierKind; + (function (GeneratedIdentifierKind) { + GeneratedIdentifierKind[GeneratedIdentifierKind["None"] = 0] = "None"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Auto"] = 1] = "Auto"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Loop"] = 2] = "Loop"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; + })(GeneratedIdentifierKind = ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + var FlowFlags; + (function (FlowFlags) { + FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; + FlowFlags[FlowFlags["Start"] = 2] = "Start"; + FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; + FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; + FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; + FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; + FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; + FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; + FlowFlags[FlowFlags["Label"] = 12] = "Label"; + FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; + })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); var OperationCanceledException = (function () { function OperationCanceledException() { } @@ -32,6 +459,45 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + var TypeFormatFlags; + (function (TypeFormatFlags) { + TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; + TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; + TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 2] = "UseTypeOfFunction"; + TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 4] = "NoTruncation"; + TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 8] = "WriteArrowStyleSignature"; + TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 16] = "WriteOwnNameForAnyLike"; + TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; + TypeFormatFlags[TypeFormatFlags["InElementType"] = 64] = "InElementType"; + TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; + TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; + TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; + TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; + TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 2048] = "SuppressAnyReturnType"; + TypeFormatFlags[TypeFormatFlags["AddUndefined"] = 4096] = "AddUndefined"; + })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var SymbolFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; + })(SymbolFormatFlags = ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolAccessibility; + (function (SymbolAccessibility) { + SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; + SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; + SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; + })(SymbolAccessibility = ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); + var SyntheticSymbolKind; + (function (SyntheticSymbolKind) { + SyntheticSymbolKind[SyntheticSymbolKind["UnionOrIntersection"] = 0] = "UnionOrIntersection"; + SyntheticSymbolKind[SyntheticSymbolKind["Spread"] = 1] = "Spread"; + })(SyntheticSymbolKind = ts.SyntheticSymbolKind || (ts.SyntheticSymbolKind = {})); + var TypePredicateKind; + (function (TypePredicateKind) { + TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; + TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; @@ -46,6 +512,189 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 9] = "TypeWithCallSignature"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); + var SymbolFlags; + (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["Prototype"] = 16777216] = "Prototype"; + SymbolFlags[SymbolFlags["ExportStar"] = 33554432] = "ExportStar"; + SymbolFlags[SymbolFlags["Optional"] = 67108864] = "Optional"; + SymbolFlags[SymbolFlags["Transient"] = 134217728] = "Transient"; + SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; + SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; + SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 793064] = "Type"; + SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; + SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; + SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792968] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; + SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530920] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793064] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["AliasExcludes"] = 8388608] = "AliasExcludes"; + SymbolFlags[SymbolFlags["ModuleMember"] = 8914931] = "ModuleMember"; + SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; + SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; + SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; + SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; + SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; + SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; + })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); + var CheckFlags; + (function (CheckFlags) { + CheckFlags[CheckFlags["Instantiated"] = 1] = "Instantiated"; + CheckFlags[CheckFlags["SyntheticProperty"] = 2] = "SyntheticProperty"; + CheckFlags[CheckFlags["Readonly"] = 4] = "Readonly"; + CheckFlags[CheckFlags["Partial"] = 8] = "Partial"; + CheckFlags[CheckFlags["HasNonUniformType"] = 16] = "HasNonUniformType"; + CheckFlags[CheckFlags["ContainsPublic"] = 32] = "ContainsPublic"; + CheckFlags[CheckFlags["ContainsProtected"] = 64] = "ContainsProtected"; + CheckFlags[CheckFlags["ContainsPrivate"] = 128] = "ContainsPrivate"; + CheckFlags[CheckFlags["ContainsStatic"] = 256] = "ContainsStatic"; + })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); + var NodeCheckFlags; + (function (NodeCheckFlags) { + NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; + NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["CaptureNewTarget"] = 8] = "CaptureNewTarget"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; + NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; + NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; + NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; + NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; + NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; + })(NodeCheckFlags = ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); + var TypeFlags; + (function (TypeFlags) { + TypeFlags[TypeFlags["Any"] = 1] = "Any"; + TypeFlags[TypeFlags["String"] = 2] = "String"; + TypeFlags[TypeFlags["Number"] = 4] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; + TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; + TypeFlags[TypeFlags["Void"] = 1024] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 2048] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 4096] = "Null"; + TypeFlags[TypeFlags["Never"] = 8192] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; + TypeFlags[TypeFlags["Object"] = 32768] = "Object"; + TypeFlags[TypeFlags["Union"] = 65536] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 131072] = "Intersection"; + TypeFlags[TypeFlags["Index"] = 262144] = "Index"; + TypeFlags[TypeFlags["IndexedAccess"] = 524288] = "IndexedAccess"; + TypeFlags[TypeFlags["FreshLiteral"] = 1048576] = "FreshLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 2097152] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; + TypeFlags[TypeFlags["JsxAttributes"] = 33554432] = "JsxAttributes"; + TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; + TypeFlags[TypeFlags["Intrinsic"] = 16793231] = "Intrinsic"; + TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 262178] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 340] = "NumberLike"; + TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 196608] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 229376] = "StructuredType"; + TypeFlags[TypeFlags["StructuredOrTypeVariable"] = 1032192] = "StructuredOrTypeVariable"; + TypeFlags[TypeFlags["TypeVariable"] = 540672] = "TypeVariable"; + TypeFlags[TypeFlags["Narrowable"] = 17810431] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 16810497] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; + TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "PropagatingFlags"; + })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); + var ObjectFlags; + (function (ObjectFlags) { + ObjectFlags[ObjectFlags["Class"] = 1] = "Class"; + ObjectFlags[ObjectFlags["Interface"] = 2] = "Interface"; + ObjectFlags[ObjectFlags["Reference"] = 4] = "Reference"; + ObjectFlags[ObjectFlags["Tuple"] = 8] = "Tuple"; + ObjectFlags[ObjectFlags["Anonymous"] = 16] = "Anonymous"; + ObjectFlags[ObjectFlags["Mapped"] = 32] = "Mapped"; + ObjectFlags[ObjectFlags["Instantiated"] = 64] = "Instantiated"; + ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; + ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; + ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; + ObjectFlags[ObjectFlags["NonPrimitive"] = 1024] = "NonPrimitive"; + ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; + })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); + var SignatureKind; + (function (SignatureKind) { + SignatureKind[SignatureKind["Call"] = 0] = "Call"; + SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; + })(SignatureKind = ts.SignatureKind || (ts.SignatureKind = {})); + var IndexKind; + (function (IndexKind) { + IndexKind[IndexKind["String"] = 0] = "String"; + IndexKind[IndexKind["Number"] = 1] = "Number"; + })(IndexKind = ts.IndexKind || (ts.IndexKind = {})); + var SpecialPropertyAssignmentKind; + (function (SpecialPropertyAssignmentKind) { + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; + })(SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); var DiagnosticCategory; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; @@ -66,6 +715,179 @@ var ts; ModuleKind[ModuleKind["System"] = 4] = "System"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); + var JsxEmit; + (function (JsxEmit) { + JsxEmit[JsxEmit["None"] = 0] = "None"; + JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; + JsxEmit[JsxEmit["React"] = 2] = "React"; + JsxEmit[JsxEmit["ReactNative"] = 3] = "ReactNative"; + })(JsxEmit = ts.JsxEmit || (ts.JsxEmit = {})); + var NewLineKind; + (function (NewLineKind) { + NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; + NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; + })(NewLineKind = ts.NewLineKind || (ts.NewLineKind = {})); + var ScriptKind; + (function (ScriptKind) { + ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; + ScriptKind[ScriptKind["JS"] = 1] = "JS"; + ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; + ScriptKind[ScriptKind["TS"] = 3] = "TS"; + ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + ScriptKind[ScriptKind["External"] = 5] = "External"; + })(ScriptKind = ts.ScriptKind || (ts.ScriptKind = {})); + var ScriptTarget; + (function (ScriptTarget) { + ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; + ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; + ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; + ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; + ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; + ScriptTarget[ScriptTarget["ESNext"] = 5] = "ESNext"; + ScriptTarget[ScriptTarget["Latest"] = 5] = "Latest"; + })(ScriptTarget = ts.ScriptTarget || (ts.ScriptTarget = {})); + var LanguageVariant; + (function (LanguageVariant) { + LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; + LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; + })(LanguageVariant = ts.LanguageVariant || (ts.LanguageVariant = {})); + var DiagnosticStyle; + (function (DiagnosticStyle) { + DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; + DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; + })(DiagnosticStyle = ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var WatchDirectoryFlags; + (function (WatchDirectoryFlags) { + WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; + WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; + })(WatchDirectoryFlags = ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); + var CharacterCodes; + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; + CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; + CharacterCodes[CharacterCodes["space"] = 32] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; + CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; + CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; + CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; + CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; + CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; + CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; + CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["j"] = 106] = "j"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["B"] = 66] = "B"; + CharacterCodes[CharacterCodes["C"] = 67] = "C"; + CharacterCodes[CharacterCodes["D"] = 68] = "D"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["G"] = 71] = "G"; + CharacterCodes[CharacterCodes["H"] = 72] = "H"; + CharacterCodes[CharacterCodes["I"] = 73] = "I"; + CharacterCodes[CharacterCodes["J"] = 74] = "J"; + CharacterCodes[CharacterCodes["K"] = 75] = "K"; + CharacterCodes[CharacterCodes["L"] = 76] = "L"; + CharacterCodes[CharacterCodes["M"] = 77] = "M"; + CharacterCodes[CharacterCodes["N"] = 78] = "N"; + CharacterCodes[CharacterCodes["O"] = 79] = "O"; + CharacterCodes[CharacterCodes["P"] = 80] = "P"; + CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; + CharacterCodes[CharacterCodes["R"] = 82] = "R"; + CharacterCodes[CharacterCodes["S"] = 83] = "S"; + CharacterCodes[CharacterCodes["T"] = 84] = "T"; + CharacterCodes[CharacterCodes["U"] = 85] = "U"; + CharacterCodes[CharacterCodes["V"] = 86] = "V"; + CharacterCodes[CharacterCodes["W"] = 87] = "W"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(CharacterCodes = ts.CharacterCodes || (ts.CharacterCodes = {})); var Extension; (function (Extension) { Extension[Extension["Ts"] = 0] = "Ts"; @@ -75,6 +897,111 @@ var ts; Extension[Extension["Jsx"] = 4] = "Jsx"; Extension[Extension["LastTypeScriptExtension"] = 2] = "LastTypeScriptExtension"; })(Extension = ts.Extension || (ts.Extension = {})); + var TransformFlags; + (function (TransformFlags) { + TransformFlags[TransformFlags["None"] = 0] = "None"; + TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript"; + TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; + TransformFlags[TransformFlags["ContainsJsx"] = 4] = "ContainsJsx"; + TransformFlags[TransformFlags["ContainsESNext"] = 8] = "ContainsESNext"; + TransformFlags[TransformFlags["ContainsES2017"] = 16] = "ContainsES2017"; + TransformFlags[TransformFlags["ContainsES2016"] = 32] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 64] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 128] = "ContainsES2015"; + TransformFlags[TransformFlags["Generator"] = 256] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 512] = "ContainsGenerator"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; + TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 2048] = "ContainsDestructuringAssignment"; + TransformFlags[TransformFlags["ContainsDecorators"] = 4096] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 8192] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 16384] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 32768] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 65536] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 131072] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 262144] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpread"] = 524288] = "ContainsSpread"; + TransformFlags[TransformFlags["ContainsObjectSpread"] = 1048576] = "ContainsObjectSpread"; + TransformFlags[TransformFlags["ContainsRest"] = 524288] = "ContainsRest"; + TransformFlags[TransformFlags["ContainsObjectRest"] = 1048576] = "ContainsObjectRest"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; + TransformFlags[TransformFlags["AssertJsx"] = 4] = "AssertJsx"; + TransformFlags[TransformFlags["AssertESNext"] = 8] = "AssertESNext"; + TransformFlags[TransformFlags["AssertES2017"] = 16] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 32] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 192] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 768] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 3072] = "AssertDestructuringAssignment"; + TransformFlags[TransformFlags["NodeExcludes"] = 536872257] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 601249089] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 601281857] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 601015617] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 601015617] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 539358529] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 574674241] = "ModuleExcludes"; + TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 540087617] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537396545] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 546309441] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 536872257] = "ParameterExcludes"; + TransformFlags[TransformFlags["CatchClauseExcludes"] = 537920833] = "CatchClauseExcludes"; + TransformFlags[TransformFlags["BindingPatternExcludes"] = 537396545] = "BindingPatternExcludes"; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 274432] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 163840] = "ES2015FunctionSyntaxMask"; + })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); + var EmitFlags; + (function (EmitFlags) { + EmitFlags[EmitFlags["SingleLine"] = 1] = "SingleLine"; + EmitFlags[EmitFlags["AdviseOnEmitNode"] = 2] = "AdviseOnEmitNode"; + EmitFlags[EmitFlags["NoSubstitution"] = 4] = "NoSubstitution"; + EmitFlags[EmitFlags["CapturesThis"] = 8] = "CapturesThis"; + EmitFlags[EmitFlags["NoLeadingSourceMap"] = 16] = "NoLeadingSourceMap"; + EmitFlags[EmitFlags["NoTrailingSourceMap"] = 32] = "NoTrailingSourceMap"; + EmitFlags[EmitFlags["NoSourceMap"] = 48] = "NoSourceMap"; + EmitFlags[EmitFlags["NoNestedSourceMaps"] = 64] = "NoNestedSourceMaps"; + EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 128] = "NoTokenLeadingSourceMaps"; + EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 256] = "NoTokenTrailingSourceMaps"; + EmitFlags[EmitFlags["NoTokenSourceMaps"] = 384] = "NoTokenSourceMaps"; + EmitFlags[EmitFlags["NoLeadingComments"] = 512] = "NoLeadingComments"; + EmitFlags[EmitFlags["NoTrailingComments"] = 1024] = "NoTrailingComments"; + EmitFlags[EmitFlags["NoComments"] = 1536] = "NoComments"; + EmitFlags[EmitFlags["NoNestedComments"] = 2048] = "NoNestedComments"; + EmitFlags[EmitFlags["HelperName"] = 4096] = "HelperName"; + EmitFlags[EmitFlags["ExportName"] = 8192] = "ExportName"; + EmitFlags[EmitFlags["LocalName"] = 16384] = "LocalName"; + EmitFlags[EmitFlags["Indented"] = 32768] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 65536] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 131072] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 262144] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 524288] = "CustomPrologue"; + EmitFlags[EmitFlags["NoHoisting"] = 1048576] = "NoHoisting"; + EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 2097152] = "HasEndOfDeclarationMarker"; + })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); + var ExternalEmitHelpers; + (function (ExternalEmitHelpers) { + ExternalEmitHelpers[ExternalEmitHelpers["Extends"] = 1] = "Extends"; + ExternalEmitHelpers[ExternalEmitHelpers["Assign"] = 2] = "Assign"; + ExternalEmitHelpers[ExternalEmitHelpers["Rest"] = 4] = "Rest"; + ExternalEmitHelpers[ExternalEmitHelpers["Decorate"] = 8] = "Decorate"; + ExternalEmitHelpers[ExternalEmitHelpers["Metadata"] = 16] = "Metadata"; + ExternalEmitHelpers[ExternalEmitHelpers["Param"] = 32] = "Param"; + ExternalEmitHelpers[ExternalEmitHelpers["Awaiter"] = 64] = "Awaiter"; + ExternalEmitHelpers[ExternalEmitHelpers["Generator"] = 128] = "Generator"; + ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper"; + ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 128] = "LastEmitHelper"; + })(ExternalEmitHelpers = ts.ExternalEmitHelpers || (ts.ExternalEmitHelpers = {})); + var EmitHint; + (function (EmitHint) { + EmitHint[EmitHint["SourceFile"] = 0] = "SourceFile"; + EmitHint[EmitHint["Expression"] = 1] = "Expression"; + EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; + EmitHint[EmitHint["Unspecified"] = 3] = "Unspecified"; + })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -93,32 +1020,32 @@ var ts; var measures; function mark(markName) { if (enabled) { - marks[markName] = ts.timestamp(); - counts[markName] = (counts[markName] || 0) + 1; + marks.set(markName, ts.timestamp()); + counts.set(markName, (counts.get(markName) || 0) + 1); profilerEvent(markName); } } performance.mark = mark; function measure(measureName, startMarkName, endMarkName) { if (enabled) { - var end = endMarkName && marks[endMarkName] || ts.timestamp(); - var start = startMarkName && marks[startMarkName] || profilerStart; - measures[measureName] = (measures[measureName] || 0) + (end - start); + var end = endMarkName && marks.get(endMarkName) || ts.timestamp(); + var start = startMarkName && marks.get(startMarkName) || profilerStart; + measures.set(measureName, (measures.get(measureName) || 0) + (end - start)); } } performance.measure = measure; function getCount(markName) { - return counts && counts[markName] || 0; + return counts && counts.get(markName) || 0; } performance.getCount = getCount; function getDuration(measureName) { - return measures && measures[measureName] || 0; + return measures && measures.get(measureName) || 0; } performance.getDuration = getDuration; function forEachMeasure(cb) { - for (var key in measures) { - cb(key, measures[key]); - } + measures.forEach(function (measure, key) { + cb(key, measure); + }); } performance.forEachMeasure = forEachMeasure; function enable() { @@ -137,22 +1064,102 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.2.0"; + ts.version = "2.3.0"; })(ts || (ts = {})); (function (ts) { - var createObject = Object.create; - ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - function createMap(template) { - var map = createObject(null); + var Ternary; + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(Ternary = ts.Ternary || (ts.Ternary = {})); + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(undefined, { usage: "sort", sensitivity: "accent" }) : undefined; + ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + function createDictionaryObject() { + var map = Object.create(null); map["__"] = undefined; delete map["__"]; + return map; + } + function createMap() { + return new MapCtr(); + } + ts.createMap = createMap; + function createMapFromTemplate(template) { + var map = new MapCtr(); for (var key in template) if (hasOwnProperty.call(template, key)) { - map[key] = template[key]; + map.set(key, template[key]); } return map; } - ts.createMap = createMap; + ts.createMapFromTemplate = createMapFromTemplate; + var MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); + function shimMap() { + var MapIterator = (function () { + function MapIterator(data, selector) { + this.index = 0; + this.data = data; + this.selector = selector; + this.keys = Object.keys(data); + } + MapIterator.prototype.next = function () { + var index = this.index; + if (index < this.keys.length) { + this.index++; + return { value: this.selector(this.data, this.keys[index]), done: false }; + } + return { value: undefined, done: true }; + }; + return MapIterator; + }()); + return (function () { + function class_1() { + this.data = createDictionaryObject(); + this.size = 0; + } + class_1.prototype.get = function (key) { + return this.data[key]; + }; + class_1.prototype.set = function (key, value) { + if (!this.has(key)) { + this.size++; + } + this.data[key] = value; + return this; + }; + class_1.prototype.has = function (key) { + return key in this.data; + }; + class_1.prototype.delete = function (key) { + if (this.has(key)) { + this.size--; + delete this.data[key]; + return true; + } + return false; + }; + class_1.prototype.clear = function () { + this.data = createDictionaryObject(); + this.size = 0; + }; + class_1.prototype.keys = function () { + return new MapIterator(this.data, function (_data, key) { return key; }); + }; + class_1.prototype.values = function () { + return new MapIterator(this.data, function (data, key) { return data[key]; }); + }; + class_1.prototype.entries = function () { + return new MapIterator(this.data, function (data, key) { return [key, data[key]]; }); + }; + class_1.prototype.forEach = function (action) { + for (var key in this.data) { + action(this.data[key], key); + } + }; + return class_1; + }()); + } function createFileMap(keyMapper) { var files = createMap(); return { @@ -165,32 +1172,27 @@ var ts; clear: clear, }; function forEachValueInMap(f) { - for (var key in files) { - f(key, files[key]); - } + files.forEach(function (file, key) { + f(key, file); + }); } function getKeys() { - var keys = []; - for (var key in files) { - keys.push(key); - } - return keys; + return arrayFrom(files.keys()); } function get(path) { - return files[toKey(path)]; + return files.get(toKey(path)); } function set(path, value) { - files[toKey(path)] = value; + files.set(toKey(path), value); } function contains(path) { - return toKey(path) in files; + return files.has(toKey(path)); } function remove(path) { - var key = toKey(path); - delete files[key]; + files.delete(toKey(path)); } function clear() { - files = createMap(); + files.clear(); } function toKey(path) { return keyMapper ? keyMapper(path) : path; @@ -204,9 +1206,19 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + var Comparison; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(Comparison = ts.Comparison || (ts.Comparison = {})); + function length(array) { + return array ? array.length : 0; + } + ts.length = length; function forEach(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -225,7 +1237,7 @@ var ts; ts.zipWith = zipWith; function every(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -235,7 +1247,7 @@ var ts; } ts.every = every; function find(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -244,8 +1256,17 @@ var ts; return undefined; } ts.find = find; + function findIndex(array, predicate) { + for (var i = 0; i < array.length; i++) { + if (predicate(array[i], i)) { + return i; + } + } + return -1; + } + ts.findIndex = findIndex; function findMap(array, callback) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -268,7 +1289,7 @@ var ts; ts.contains = contains; function indexOf(array, value) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -278,7 +1299,7 @@ var ts; } ts.indexOf = indexOf; function indexOfAnyCharCode(text, charCodes, start) { - for (var i = start || 0, len = text.length; i < len; i++) { + for (var i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -465,21 +1486,18 @@ var ts; return result; } ts.spanMap = spanMap; - function mapObject(object, f) { - var result; - if (object) { - result = {}; - for (var _i = 0, _a = getOwnKeys(object); _i < _a.length; _i++) { - var v = _a[_i]; - var _b = f(v, object[v]) || [undefined, undefined], key = _b[0], value = _b[1]; - if (key !== undefined) { - result[key] = value; - } - } + function mapEntries(map, f) { + if (!map) { + return undefined; } + var result = createMap(); + map.forEach(function (value, key) { + var _a = f(key, value), newKey = _a[0], newValue = _a[1]; + result.set(newKey, newValue); + }); return result; } - ts.mapObject = mapObject; + ts.mapEntries = mapEntries; function some(array, predicate) { if (array) { if (predicate) { @@ -763,38 +1781,55 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; - function forEachProperty(map, callback) { - var result; - for (var key in map) { - if (result = callback(map[key], key)) - break; + function arrayFrom(iterator) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(value); } return result; + var _b; } - ts.forEachProperty = forEachProperty; - function someProperties(map, predicate) { - for (var key in map) { - if (!predicate || predicate(map[key], key)) - return true; + ts.arrayFrom = arrayFrom; + function convertToArray(iterator, f) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(f(value)); } - return false; + return result; + var _b; } - ts.someProperties = someProperties; - function copyProperties(source, target) { - for (var key in source) { - target[key] = source[key]; + ts.convertToArray = convertToArray; + function forEachEntry(map, callback) { + var iterator = map.entries(); + for (var _a = iterator.next(), pair = _a.value, done = _a.done; !done; _b = iterator.next(), pair = _b.value, done = _b.done, _b) { + var key = pair[0], value = pair[1]; + var result = callback(value, key); + if (result) { + return result; + } } + return undefined; + var _b; } - ts.copyProperties = copyProperties; - function appendProperty(map, key, value) { - if (key === undefined || value === undefined) - return map; - if (map === undefined) - map = createMap(); - map[key] = value; - return map; + ts.forEachEntry = forEachEntry; + function forEachKey(map, callback) { + var iterator = map.keys(); + for (var _a = iterator.next(), key = _a.value, done = _a.done; !done; _b = iterator.next(), key = _b.value, done = _b.done, _b) { + var result = callback(key); + if (result) { + return result; + } + } + return undefined; + var _b; } - ts.appendProperty = appendProperty; + ts.forEachKey = forEachKey; + function copyEntries(source, target) { + source.forEach(function (value, key) { + target.set(key, value); + }); + } + ts.copyEntries = copyEntries; function assign(t) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -810,14 +1845,6 @@ var ts; return t; } ts.assign = assign; - function reduceProperties(map, callback, initial) { - var result = initial; - for (var key in map) { - result = callback(result, map[key], String(key)); - } - return result; - } - ts.reduceProperties = reduceProperties; function equalOwnProperties(left, right, equalityComparer) { if (left === right) return true; @@ -842,23 +1869,14 @@ var ts; var result = createMap(); for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { var value = array_8[_i]; - result[makeKey(value)] = makeValue ? makeValue(value) : value; + result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; } ts.arrayToMap = arrayToMap; - function isEmpty(map) { - for (var id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - ts.isEmpty = isEmpty; function cloneMap(map) { var clone = createMap(); - copyProperties(map, clone); + copyEntries(map, clone); return clone; } ts.cloneMap = cloneMap; @@ -885,27 +1903,32 @@ var ts; return result; } ts.extend = extend; - function multiMapAdd(map, key, value) { - var values = map[key]; + function createMultiMap() { + var map = createMap(); + map.add = multiMapAdd; + map.remove = multiMapRemove; + return map; + } + ts.createMultiMap = createMultiMap; + function multiMapAdd(key, value) { + var values = this.get(key); if (values) { values.push(value); - return values; } else { - return map[key] = [value]; + this.set(key, values = [value]); } + return values; } - ts.multiMapAdd = multiMapAdd; - function multiMapRemove(map, key, value) { - var values = map[key]; + function multiMapRemove(key, value) { + var values = this.get(key); if (values) { unorderedRemoveItem(values, value); if (!values.length) { - delete map[key]; + this.delete(key); } } } - ts.multiMapRemove = multiMapRemove; function isArray(value) { return Array.isArray ? Array.isArray(value) : value instanceof Array; } @@ -981,6 +2004,7 @@ var ts; baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } + ts.formatStringFromArgs = formatStringFromArgs; ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; @@ -1082,8 +2106,10 @@ var ts; if (b === undefined) return 1; if (ignoreCase) { - if (ts.collator && String.prototype.localeCompare) { - var result = a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); + if (ts.collator) { + var result = ts.localeCompareIsCorrect ? + ts.collator.compare(a, b) : + a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 : result > 0 ? 1 : 0; } a = a.toUpperCase(); @@ -1465,36 +2491,26 @@ var ts; var singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; var singleAsteriskRegexFragmentOther = "[^/]*"; function getRegularExpressionForWildcard(specs, basePath, usage) { + var patterns = getRegularExpressionsForWildcards(specs, basePath, usage); + if (!patterns || !patterns.length) { + return undefined; + } + var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var terminator = usage === "exclude" ? "($|/)" : "$"; + return "^(" + pattern + ")" + terminator; + } + ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; + function getRegularExpressionsForWildcards(specs, basePath, usage) { if (specs === undefined || specs.length === 0) { return undefined; } var replaceWildcardCharacter = usage === "files" ? replaceWildCardCharacterFiles : replaceWildCardCharacterOther; var singleAsteriskRegexFragment = usage === "files" ? singleAsteriskRegexFragmentFiles : singleAsteriskRegexFragmentOther; var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; - var pattern = ""; - var hasWrittenSubpattern = false; - for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { - var spec = specs_1[_i]; - if (!spec) { - continue; - } - var subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); - if (subPattern === undefined) { - continue; - } - if (hasWrittenSubpattern) { - pattern += "|"; - } - pattern += "(" + subPattern + ")"; - hasWrittenSubpattern = true; - } - if (!pattern) { - return undefined; - } - var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return flatMap(specs, function (spec) { + return spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + }); } - ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function isImplicitGlob(lastPathComponent) { return !/[.*?]/.test(lastPathComponent); } @@ -1564,6 +2580,7 @@ var ts; currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); return { + includeFilePatterns: map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -1576,34 +2593,48 @@ var ts; currentDirectory = normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; - var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); + var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return new RegExp(pattern, regexFlag); }); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); var excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); - var result = []; + var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]]; + var comparer = useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive; for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; visitDirectory(basePath, combinePaths(currentDirectory, basePath)); } - return result; + return flatten(results); function visitDirectory(path, absolutePath) { var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; + files = files.slice().sort(comparer); + directories = directories.slice().sort(comparer); + var _loop_1 = function (current) { + var name = combinePaths(path, current); + var absoluteName = combinePaths(absolutePath, current); + if (extensions && !fileExtensionIsAny(name, extensions)) + return "continue"; + if (excludeRegex && excludeRegex.test(absoluteName)) + return "continue"; + if (!includeFileRegexes) { + results[0].push(name); + } + else { + var includeIndex = findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); }); + if (includeIndex !== -1) { + results[includeIndex].push(name); + } + } + }; for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var current = files_1[_i]; - var name_1 = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); - if ((!extensions || fileExtensionIsAny(name_1, extensions)) && - (!includeFileRegex || includeFileRegex.test(absoluteName)) && - (!excludeRegex || !excludeRegex.test(absoluteName))) { - result.push(name_1); - } + _loop_1(current); } for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var current = directories_1[_b]; - var name_2 = combinePaths(path, current); + var name = combinePaths(path, current); var absoluteName = combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { - visitDirectory(name_2, absoluteName); + visitDirectory(name, absoluteName); } } } @@ -1619,14 +2650,14 @@ var ts; includeBasePaths.push(getIncludeBasePath(absolute)); } includeBasePaths.sort(useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); - var _loop_1 = function (includeBasePath) { + var _loop_2 = function (includeBasePath) { if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { basePaths.push(includeBasePath); } }; for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) { var includeBasePath = includeBasePaths_1[_a]; - _loop_1(includeBasePath); + _loop_2(includeBasePath); } } return basePaths; @@ -1666,13 +2697,13 @@ var ts; var allSupportedExtensions = ts.supportedTypeScriptExtensions.concat(ts.supportedJavascriptExtensions); function getSupportedExtensions(options, extraFileExtensions) { var needAllExtensions = options && options.allowJs; - if (!extraFileExtensions || extraFileExtensions.length === 0) { + if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } - var extensions = (needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions).slice(0); + var extensions = allSupportedExtensions.slice(0); for (var _i = 0, extraFileExtensions_1 = extraFileExtensions; _i < extraFileExtensions_1.length; _i++) { var extInfo = extraFileExtensions_1[_i]; - if (needAllExtensions || extInfo.scriptKind === 3) { + if (extensions.indexOf(extInfo.extension) === -1) { extensions.push(extInfo.extension); } } @@ -1700,33 +2731,40 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + var ExtensionPriority; + (function (ExtensionPriority) { + ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; + ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; + ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; + ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; + })(ExtensionPriority = ts.ExtensionPriority || (ts.ExtensionPriority = {})); function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { - return adjustExtensionPriority(i); + return adjustExtensionPriority(i, supportedExtensions); } } return 0; } ts.getExtensionPriority = getExtensionPriority; - function adjustExtensionPriority(extensionPriority) { + function adjustExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2) { return 0; } - else if (extensionPriority < 5) { + else if (extensionPriority < supportedExtensions.length) { return 2; } else { - return 5; + return supportedExtensions.length; } } ts.adjustExtensionPriority = adjustExtensionPriority; - function getNextLowestExtensionPriority(extensionPriority) { + function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2) { return 2; } else { - return 5; + return supportedExtensions.length; } } ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority; @@ -1784,6 +2822,13 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; + var AssertionLevel; + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(AssertionLevel = ts.AssertionLevel || (ts.AssertionLevel = {})); var Debug; (function (Debug) { Debug.currentAssertionLevel = 0; @@ -2073,32 +3118,32 @@ var ts; var useNonPollingWatchers = process.env["TSC_NONPOLLING_WATCHER"]; function createWatchedFileSet() { var dirWatchers = ts.createMap(); - var fileWatcherCallbacks = ts.createMap(); + var fileWatcherCallbacks = ts.createMultiMap(); return { addFile: addFile, removeFile: removeFile }; function reduceDirWatcherRefCountForFile(fileName) { var dirName = ts.getDirectoryPath(fileName); - var watcher = dirWatchers[dirName]; + var watcher = dirWatchers.get(dirName); if (watcher) { watcher.referenceCount -= 1; if (watcher.referenceCount <= 0) { watcher.close(); - delete dirWatchers[dirName]; + dirWatchers.delete(dirName); } } } function addDirWatcher(dirPath) { - var watcher = dirWatchers[dirPath]; + var watcher = dirWatchers.get(dirPath); if (watcher) { watcher.referenceCount += 1; return; } watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); watcher.referenceCount = 1; - dirWatchers[dirPath] = watcher; + dirWatchers.set(dirPath, watcher); return; } function addFileWatcherCallback(filePath, callback) { - ts.multiMapAdd(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.add(filePath, callback); } function addFile(fileName, callback) { addFileWatcherCallback(fileName, callback); @@ -2110,16 +3155,19 @@ var ts; reduceDirWatcherRefCountForFile(watchedFile.fileName); } function removeFileWatcherCallback(filePath, callback) { - ts.multiMapRemove(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.remove(filePath, callback); } function fileEventHandler(eventName, relativeFileName, baseDirPath) { var fileName = typeof relativeFileName !== "string" ? undefined : ts.getNormalizedAbsolutePath(relativeFileName, baseDirPath); - if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks[fileName]) { - for (var _i = 0, _a = fileWatcherCallbacks[fileName]; _i < _a.length; _i++) { - var fileCallback = _a[_i]; - fileCallback(fileName); + if ((eventName === "change" || eventName === "rename")) { + var callbacks = fileWatcherCallbacks.get(fileName); + if (callbacks) { + for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) { + var fileCallback = callbacks_1[_i]; + fileCallback(fileName); + } } } } @@ -2184,10 +3232,10 @@ var ts; if (entry === "." || entry === "..") { continue; } - var name_3 = ts.combinePaths(path, entry); + var name = ts.combinePaths(path, entry); var stat = void 0; try { - stat = _fs.statSync(name_3); + stat = _fs.statSync(name); } catch (e) { continue; @@ -2208,6 +3256,11 @@ var ts; function readDirectory(path, extensions, excludes, includes) { return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), getAccessibleFileSystemEntries); } + var FileSystemEntryKind; + (function (FileSystemEntryKind) { + FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; + FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; + })(FileSystemEntryKind || (FileSystemEntryKind = {})); function fileSystemEntryExists(path, entryKind) { try { var stat = _fs.statSync(path); @@ -2261,7 +3314,7 @@ var ts; }, watchDirectory: function (directoryName, callback, recursive) { var options; - if (!directoryExists(directoryName)) { + if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { return noOpFileWatcher; } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { @@ -2276,6 +3329,9 @@ var ts; } ; }); + function isUNCPath(s) { + return s.length > 2 && s.charCodeAt(0) === 47 && s.charCodeAt(1) === 47; + } }, resolvePath: function (path) { return _path.resolve(path); @@ -2475,7 +3531,7 @@ var ts; _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, 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." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." }, 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." }, @@ -2586,6 +3642,7 @@ var ts; 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." }, + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", message: "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules." }, 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_Set_the_experimentalDecorators_option_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_Set_t_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", message: "Generators are only available when targeting ECMAScript 2015 or higher." }, @@ -2632,6 +3689,7 @@ var ts; Global_module_exports_may_only_appear_at_top_level: { code: 1316, category: ts.DiagnosticCategory.Error, key: "Global_module_exports_may_only_appear_at_top_level_1316", message: "Global module exports may only appear at top level." }, A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, 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." }, @@ -2861,6 +3919,10 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, + A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: { code: 2545, category: ts.DiagnosticCategory.Error, key: "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", message: "A mixin class must have a constructor with a single rest parameter of type 'any[]'." }, + Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: { code: 2546, category: ts.DiagnosticCategory.Error, key: "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", message: "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union 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." }, @@ -2870,6 +3932,8 @@ var ts; 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" }, + JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, + Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: { code: 2649, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", message: "Cannot augment module '{0}' with value exports because it resolves to a non-module entity." }, 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." }, @@ -2918,9 +3982,15 @@ var ts; The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { code: 2696, category: ts.DiagnosticCategory.Error, key: "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", message: "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?" }, An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, + Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: { code: 2699, category: ts.DiagnosticCategory.Error, key: "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", message: "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'." }, Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, + An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: { code: 2705, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", message: "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option." }, + Required_type_parameters_may_not_follow_optional_type_parameters: { code: 2706, category: ts.DiagnosticCategory.Error, key: "Required_type_parameters_may_not_follow_optional_type_parameters_2706", message: "Required type parameters may not follow optional type parameters." }, + Generic_type_0_requires_between_1_and_2_type_arguments: { code: 2707, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_between_1_and_2_type_arguments_2707", message: "Generic type '{0}' requires between {1} and {2} type arguments." }, 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}'." }, @@ -2931,8 +4001,8 @@ var ts; 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}'." }, + 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}'." }, @@ -2995,6 +4065,7 @@ var ts; Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { code: 4090, category: ts.DiagnosticCategory.Message, key: "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", message: "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", message: "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4092, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", message: "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'." }, + extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced: { code: 4093, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced_4093", message: "'extends' clause of exported class '{0}' refers to a type whose name cannot be referenced." }, 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." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, @@ -3040,7 +4111,7 @@ var ts; 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." }, + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'" }, 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" }, @@ -3055,6 +4126,7 @@ var ts; LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION_6037", message: "LOCATION" }, DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY_6038", message: "DIRECTORY" }, STRATEGY: { code: 6039, category: ts.DiagnosticCategory.Message, key: "STRATEGY_6039", message: "STRATEGY" }, + FILE_OR_DIRECTORY: { code: 6040, category: ts.DiagnosticCategory.Message, key: "FILE_OR_DIRECTORY_6040", message: "FILE OR 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." }, @@ -3088,7 +4160,8 @@ var ts; 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_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, - 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'" }, + Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'" }, + File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, @@ -3102,12 +4175,12 @@ var ts; Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, - Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", message: "Loading module as file / folder, candidate module location '{0}', target file type '{1}'." }, File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, - Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, - package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, + package_json_does_not_have_a_0_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_0_field_6100", message: "'package.json' does not have a '{0}' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, @@ -3144,7 +4217,6 @@ var ts; Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, - No_types_specified_in_package_json_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json', so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, @@ -3154,6 +4226,8 @@ var ts; Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, + Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, + Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, 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." }, @@ -3195,7 +4269,7 @@ var ts; 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." }, 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." }, - 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." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: { 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' clause." }, 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." }, Language_service_is_disabled: { code: 9004, category: ts.DiagnosticCategory.Error, key: "Language_service_is_disabled_9004", message: "Language service is disabled." }, 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'." }, @@ -3210,31 +4284,4554 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, - Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, - Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, - Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, + Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: {0}" }, + Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, + Add_this_to_unresolved_variable: { code: 90008, category: ts.DiagnosticCategory.Message, key: "Add_this_to_unresolved_variable_90008", message: "Add 'this.' to unresolved variable." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, }; })(ts || (ts = {})); var ts; +(function (ts) { + function trace(host) { + host.trace(ts.formatMessage.apply(undefined, arguments)); + } + ts.trace = trace; + function isTraceEnabled(compilerOptions, host) { + return compilerOptions.traceResolution && host.trace !== undefined; + } + ts.isTraceEnabled = isTraceEnabled; + var Extensions; + (function (Extensions) { + Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; + Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; + Extensions[Extensions["DtsOnly"] = 2] = "DtsOnly"; + })(Extensions || (Extensions = {})); + function resolvedTypeScriptOnly(resolved) { + if (!resolved) { + return undefined; + } + ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); + return resolved.path; + } + function resolvedModuleFromResolved(_a, isExternalLibraryImport) { + var path = _a.path, extension = _a.extension; + return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; + } + function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolved && resolvedModuleFromResolved(resolved, isExternalLibraryImport), failedLookupLocations: failedLookupLocations }; + } + function moduleHasNonRelativeName(moduleName) { + return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); + } + ts.moduleHasNonRelativeName = moduleHasNonRelativeName; + function tryReadPackageJsonFields(readTypes, packageJsonPath, baseDirectory, state) { + var jsonContent = readJson(packageJsonPath, state.host); + return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); + function tryReadFromField(fieldName) { + if (!ts.hasProperty(jsonContent, fieldName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName); + } + return; + } + var fileName = jsonContent[fieldName]; + if (typeof fileName !== "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof fileName); + } + return; + } + var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path); + } + return path; + } + } + function readJson(path, host) { + try { + var jsonText = host.readFile(path); + return jsonText ? JSON.parse(jsonText) : {}; + } + catch (e) { + return {}; + } + } + function getEffectiveTypeRoots(options, host) { + if (options.typeRoots) { + return options.typeRoots; + } + var currentDirectory; + if (options.configFilePath) { + currentDirectory = ts.getDirectoryPath(options.configFilePath); + } + else if (host.getCurrentDirectory) { + currentDirectory = host.getCurrentDirectory(); + } + if (currentDirectory !== undefined) { + return getDefaultTypeRoots(currentDirectory, host); + } + } + ts.getEffectiveTypeRoots = getEffectiveTypeRoots; + function getDefaultTypeRoots(currentDirectory, host) { + if (!host.directoryExists) { + return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; + } + var typeRoots; + forEachAncestorDirectory(currentDirectory, function (directory) { + var atTypes = ts.combinePaths(directory, nodeModulesAtTypes); + if (host.directoryExists(atTypes)) { + (typeRoots || (typeRoots = [])).push(atTypes); + } + return undefined; + }); + return typeRoots; + } + var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { + var traceEnabled = isTraceEnabled(options, host); + var moduleResolutionState = { + compilerOptions: options, + host: host, + traceEnabled: traceEnabled + }; + var typeRoots = getEffectiveTypeRoots(options, host); + if (traceEnabled) { + if (containingFile === undefined) { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); + } + } + else { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); + } + } + } + var failedLookupLocations = []; + var resolved = primaryLookup(); + var primary = true; + if (!resolved) { + resolved = secondaryLookup(); + primary = false; + } + var resolvedTypeReferenceDirective; + if (resolved) { + resolved = realpath(resolved, host, traceEnabled); + if (traceEnabled) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); + } + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved }; + } + return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + function primaryLookup() { + if (typeRoots && typeRoots.length) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + } + return ts.forEach(typeRoots, function (typeRoot) { + var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); + var candidateDirectory = ts.getDirectoryPath(candidate); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); + }); + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); + } + } + } + function secondaryLookup() { + var resolvedFile; + var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile); + if (initialLocationForSecondaryLookup !== undefined) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); + } + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); + if (!resolvedFile && traceEnabled) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } + return resolvedFile; + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); + } + } + } + } + ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; + function getAutomaticTypeDirectiveNames(options, host) { + if (options.types) { + return options.types; + } + var result = []; + if (host.directoryExists && host.getDirectories) { + var typeRoots = getEffectiveTypeRoots(options, host); + if (typeRoots) { + for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { + var root = typeRoots_1[_i]; + if (host.directoryExists(root)) { + for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { + var typeDirectivePath = _b[_a]; + var normalized = ts.normalizePath(typeDirectivePath); + var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); + var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; + if (!isNotNeededPackage) { + result.push(ts.getBaseFileName(normalized)); + } + } + } + } + } + } + return result; + } + ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); + if (!perModuleNameCache) { + perModuleNameCache = createPerModuleNameCache(); + moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent = ts.getDirectoryPath(current); + if (parent === current || directoryPathMap.contains(parent)) { + break; + } + directoryPathMap.set(parent, result); + current = parent; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + } + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache.get(moduleName); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + } + else { + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache.set(moduleName, result); + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } + } + } + if (traceEnabled) { + if (result.resolvedModule) { + trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); + } + else { + trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); + } + } + return result; + } + ts.resolveModuleName = resolveModuleName; + function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { + if (moduleHasNonRelativeName(moduleName)) { + return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state); + } + else { + return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); + } + } + function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { + if (!state.compilerOptions.rootDirs) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); + } + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var matchedRootDir; + var matchedNormalizedPrefix; + for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { + var rootDir = _a[_i]; + var normalizedRoot = ts.normalizePath(rootDir); + if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { + normalizedRoot += ts.directorySeparator; + } + var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && + (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); + } + if (isLongestMatchingPrefix) { + matchedNormalizedPrefix = normalizedRoot; + matchedRootDir = rootDir; + } + } + if (matchedNormalizedPrefix) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); + } + var suffix = candidate.substr(matchedNormalizedPrefix.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); + } + var resolvedFileName = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); + } + for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { + var rootDir = _c[_b]; + if (rootDir === matchedRootDir) { + continue; + } + var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); + } + var baseDirectory = ts.getDirectoryPath(candidate_1); + var resolvedFileName_1 = loader(extensions, candidate_1, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + if (resolvedFileName_1) { + return resolvedFileName_1; + } + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); + } + } + return undefined; + } + function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state) { + if (!state.compilerOptions.baseUrl) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); + } + var matchedPattern = undefined; + if (state.compilerOptions.paths) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); + } + if (matchedPattern) { + var matchedStar_1 = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); + var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); + } + return ts.forEach(state.compilerOptions.paths[matchedPatternText], function (subst) { + var path = matchedStar_1 ? subst.replace("*", matchedStar_1) : subst; + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); + } + var tsExtension = ts.tryGetExtensionFromPath(candidate); + if (tsExtension !== undefined) { + var path_1 = tryFile(candidate, failedLookupLocations, false, state); + return path_1 && { path: path_1, extension: tsExtension }; + } + return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + }); + } + else { + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); + } + return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + } + } + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, false); + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, jsOnly) { + if (jsOnly === void 0) { jsOnly = false; } + var containingDirectory = ts.getDirectoryPath(containingFile); + var traceEnabled = isTraceEnabled(compilerOptions, host); + var failedLookupLocations = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; + var result = jsOnly ? tryResolve(Extensions.JavaScript) : (tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript)); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; + return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); + } + return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + function tryResolve(extensions) { + var loader = function (extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, true); }; + var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); + if (resolved) { + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); + } + if (moduleHasNonRelativeName(moduleName)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); + } + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state, true); + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); + } + } + } + ts.nodeModuleNameResolverWorker = nodeModuleNameResolverWorker; + function realpath(path, host, traceEnabled) { + if (!host.realpath) { + return path; + } + var real = ts.normalizePath(host.realpath(path)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); + } + return real; + } + function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); + } + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson); + } + function directoryProbablyExists(directoryName, host) { + return !host.directoryExists || host.directoryExists(directoryName); + } + ts.directoryProbablyExists = directoryProbablyExists; + function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); + if (resolvedByAddingExtension) { + return resolvedByAddingExtension; + } + if (ts.hasJavaScriptFileExtension(candidate)) { + var extensionless = ts.removeFileExtension(candidate); + if (state.traceEnabled) { + var extension = candidate.substring(extensionless.length); + trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); + } + return tryAddingExtensions(extensionless, extensions, failedLookupLocations, onlyRecordFailures, state); + } + } + function tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state) { + if (!onlyRecordFailures) { + var directory = ts.getDirectoryPath(candidate); + if (directory) { + onlyRecordFailures = !directoryProbablyExists(directory, state.host); + } + } + switch (extensions) { + case Extensions.DtsOnly: + return tryExtension(".d.ts", ts.Extension.Dts); + case Extensions.TypeScript: + return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); + case Extensions.JavaScript: + return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); + } + function tryExtension(ext, extension) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); + return path && { path: path, extension: extension }; + } + } + function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } + } + } + failedLookupLocations.push(fileName); + return undefined; + } + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { + if (considerPackageJson === void 0) { considerPackageJson = true; } + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (considerPackageJson) { + var packageJsonPath = pathToPackageJson(candidate); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + var fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; + } + } + else { + if (directoryExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + } + failedLookupLocations.push(packageJsonPath); + } + } + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); + } + function loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + if (!file) { + return undefined; + } + var onlyRecordFailures = !directoryProbablyExists(ts.getDirectoryPath(file), state.host); + var fromFile = tryFile(file, failedLookupLocations, onlyRecordFailures, state); + if (fromFile) { + var resolved = fromFile && resolvedIfExtensionMatches(extensions, fromFile); + if (resolved) { + return resolved; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile); + } + } + var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; + return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, false); + } + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } + function pathToPackageJson(directory) { + return ts.combinePaths(directory, "package.json"); + } + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + } + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false, cache); + } + function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, true, undefined); + } + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); + return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { + if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); + } + }); + } + function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + if (typesOnly === void 0) { typesOnly = false; } + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); + if (packageResult) { + return packageResult; + } + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); + } + } + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; + var failedLookupLocations = []; + var containingDirectory = ts.getDirectoryPath(containingFile); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations); + function tryResolve(extensions) { + var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); + if (resolvedUsingSettings) { + return { value: resolvedUsingSettings }; + } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); + if (moduleHasNonRelativeName(moduleName)) { + var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } + var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); + }); + if (resolved_3) { + return resolved_3; + } + if (extensions === Extensions.TypeScript) { + return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); + } + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state)); + } + } + } + ts.classicNameResolver = classicNameResolver; + function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); + } + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; + var failedLookupLocations = []; + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); + return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); + } + ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } + function forEachAncestorDirectory(directory, callback) { + while (true) { + var result = callback(directory); + if (result !== undefined) { + return result; + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + return undefined; + } + directory = parentPath; + } + } +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.externalHelpersModuleNameText = "tslib"; + function getDeclarationOfKind(symbol, kind) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { + var declaration = declarations_1[_i]; + if (declaration.kind === kind) { + return declaration; + } + } + } + return undefined; + } + ts.getDeclarationOfKind = getDeclarationOfKind; + function findDeclaration(symbol, predicate) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; + if (predicate(declaration)) { + return declaration; + } + } + } + return undefined; + } + ts.findDeclaration = findDeclaration; + var stringWriters = []; + function getSingleLineStringWriter() { + if (stringWriters.length === 0) { + var str_1 = ""; + var writeText = function (text) { return str_1 += text; }; + return { + string: function () { return str_1; }, + writeKeyword: writeText, + writeOperator: writeText, + writePunctuation: writeText, + writeSpace: writeText, + writeStringLiteral: writeText, + writeParameter: writeText, + writeProperty: writeText, + writeSymbol: writeText, + writeLine: function () { return str_1 += " "; }, + increaseIndent: ts.noop, + decreaseIndent: ts.noop, + clear: function () { return str_1 = ""; }, + trackSymbol: ts.noop, + reportInaccessibleThisError: ts.noop, + reportIllegalExtends: ts.noop + }; + } + 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 hasResolvedModule(sourceFile, moduleNameText) { + return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText)); + } + ts.hasResolvedModule = hasResolvedModule; + function getResolvedModule(sourceFile, moduleNameText) { + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules.get(moduleNameText) : undefined; + } + ts.getResolvedModule = getResolvedModule; + function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = ts.createMap(); + } + sourceFile.resolvedModules.set(moduleNameText, resolvedModule); + } + ts.setResolvedModule = setResolvedModule; + function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { + if (!sourceFile.resolvedTypeReferenceDirectiveNames) { + sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); + } + sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective); + } + ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; + function moduleResolutionIsEqualTo(oldResolution, newResolution) { + return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && + oldResolution.extension === newResolution.extension && + oldResolution.resolvedFileName === newResolution.resolvedFileName; + } + ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; + function typeDirectiveIsEqualTo(oldResolution, newResolution) { + return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; + } + ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; + function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { + if (names.length !== newResolutions.length) { + return false; + } + for (var i = 0; i < names.length; i++) { + var newResolution = newResolutions[i]; + var oldResolution = oldResolutions && oldResolutions.get(names[i]); + var changed = oldResolution + ? !newResolution || !comparer(oldResolution, newResolution) + : newResolution; + if (changed) { + return true; + } + } + return false; + } + ts.hasChangesInResolutions = hasChangesInResolutions; + function containsParseError(node) { + aggregateChildData(node); + return (node.flags & 131072) !== 0; + } + ts.containsParseError = containsParseError; + function aggregateChildData(node) { + if (!(node.flags & 262144)) { + var thisNodeOrAnySubNodesHasError = ((node.flags & 32768) !== 0) || + ts.forEachChild(node, containsParseError); + if (thisNodeOrAnySubNodesHasError) { + node.flags |= 131072; + } + node.flags |= 262144; + } + } + function getSourceFileOfNode(node) { + while (node && node.kind !== 264) { + node = node.parent; + } + return node; + } + ts.getSourceFileOfNode = getSourceFileOfNode; + function isStatementWithLocals(node) { + switch (node.kind) { + case 206: + case 234: + case 213: + case 214: + case 215: + return true; + } + return false; + } + ts.isStatementWithLocals = isStatementWithLocals; + 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 isDefined(value) { + return value !== undefined; + } + ts.isDefined = isDefined; + function getEndLinePosition(line, sourceFile) { + ts.Debug.assert(line >= 0); + var lineStarts = ts.getLineStarts(sourceFile); + var lineIndex = line; + var sourceText = sourceFile.text; + if (lineIndex + 1 === lineStarts.length) { + return sourceText.length - 1; + } + else { + var start = lineStarts[lineIndex]; + var pos = lineStarts[lineIndex + 1] - 1; + ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos))); + while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) { + pos--; + } + return pos; + } + } + ts.getEndLinePosition = getEndLinePosition; + function nodeIsMissing(node) { + if (node === undefined) { + 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, includeJsDoc) { + if (nodeIsMissing(node)) { + return node.pos; + } + if (isJSDocNode(node)) { + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true); + } + if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { + return getTokenPosOfNode(node.jsDoc[0]); + } + if (node.kind === 296 && node._children.length > 0) { + return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); + } + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); + } + ts.getTokenPosOfNode = getTokenPosOfNode; + function isJSDocNode(node) { + return node.kind >= 266 && node.kind <= 295; + } + ts.isJSDocNode = isJSDocNode; + function isJSDocTag(node) { + return node.kind >= 282 && node.kind <= 295; + } + ts.isJSDocTag = isJSDocTag; + 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 getLiteralText(node, sourceFile, languageVersion) { + if (languageVersion < 2 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + return getQuotedEscapedLiteralText('"', node.text, '"'); + } + if (!nodeIsSynthesized(node) && node.parent) { + var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); + if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { + return node.text; + } + return text; + } + switch (node.kind) { + case 9: + return getQuotedEscapedLiteralText('"', node.text, '"'); + case 12: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 13: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 14: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 15: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8: + return node.text; + } + ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + } + ts.getLiteralText = getLiteralText; + function isBinaryOrOctalIntegerLiteral(node, text) { + return node.kind === 8 + && (getNumericLiteralFlags(text, 6) & 6) !== 0; + } + ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + var NumericLiteralFlags; + (function (NumericLiteralFlags) { + NumericLiteralFlags[NumericLiteralFlags["None"] = 0] = "None"; + NumericLiteralFlags[NumericLiteralFlags["Hexadecimal"] = 1] = "Hexadecimal"; + NumericLiteralFlags[NumericLiteralFlags["Binary"] = 2] = "Binary"; + NumericLiteralFlags[NumericLiteralFlags["Octal"] = 4] = "Octal"; + NumericLiteralFlags[NumericLiteralFlags["Scientific"] = 8] = "Scientific"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctal"] = 6] = "BinaryOrOctal"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctalOrHexadecimal"] = 7] = "BinaryOrOctalOrHexadecimal"; + NumericLiteralFlags[NumericLiteralFlags["All"] = 15] = "All"; + })(NumericLiteralFlags = ts.NumericLiteralFlags || (ts.NumericLiteralFlags = {})); + function getNumericLiteralFlags(text, hint) { + if (text.length > 1) { + switch (text.charCodeAt(1)) { + case 98: + case 66: + return 2; + case 111: + case 79: + return 4; + case 120: + case 88: + return 1; + } + if (hint & 8) { + for (var i = text.length - 1; i >= 0; i--) { + switch (text.charCodeAt(i)) { + case 101: + case 69: + return 8; + } + } + } + } + return 0; + } + ts.getNumericLiteralFlags = getNumericLiteralFlags; + function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { + return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; + } + function escapeIdentifier(identifier) { + return identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier; + } + ts.escapeIdentifier = escapeIdentifier; + function makeIdentifierFromModuleName(moduleName) { + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); + } + ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; + function isBlockOrCatchScoped(declaration) { + return (ts.getCombinedNodeFlags(declaration) & 3) !== 0 || + isCatchClauseVariableDeclarationOrBindingElement(declaration); + } + ts.isBlockOrCatchScoped = isBlockOrCatchScoped; + function isCatchClauseVariableDeclarationOrBindingElement(declaration) { + var node = getRootDeclaration(declaration); + return node.kind === 225 && node.parent.kind === 259; + } + ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; + function isAmbientModule(node) { + return node && node.kind === 232 && + (node.name.kind === 9 || isGlobalScopeAugmentation(node)); + } + ts.isAmbientModule = isAmbientModule; + function isShorthandAmbientModuleSymbol(moduleSymbol) { + return isShorthandAmbientModule(moduleSymbol.valueDeclaration); + } + ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; + function isShorthandAmbientModule(node) { + return node && node.kind === 232 && (!node.body); + } + function isBlockScopedContainerTopLevel(node) { + return node.kind === 264 || + node.kind === 232 || + isFunctionLike(node); + } + ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; + function isGlobalScopeAugmentation(module) { + return !!(module.flags & 512); + } + ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; + function isExternalModuleAugmentation(node) { + if (!node || !isAmbientModule(node)) { + return false; + } + switch (node.parent.kind) { + case 264: + return ts.isExternalModule(node.parent); + case 233: + return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); + } + return false; + } + ts.isExternalModuleAugmentation = isExternalModuleAugmentation; + function isEffectiveExternalModule(node, compilerOptions) { + return ts.isExternalModule(node) || compilerOptions.isolatedModules; + } + ts.isEffectiveExternalModule = isEffectiveExternalModule; + function isBlockScope(node, parentNode) { + switch (node.kind) { + case 264: + case 234: + case 259: + case 232: + case 213: + case 214: + case 215: + case 151: + case 150: + case 152: + case 153: + case 227: + case 185: + case 186: + return true; + case 206: + return parentNode && !isFunctionLike(parentNode); + } + return false; + } + ts.isBlockScope = isBlockScope; + function getEnclosingBlockScopeContainer(node) { + var current = node.parent; + while (current) { + if (isBlockScope(current, current.parent)) { + return current; + } + current = current.parent; + } + } + ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; + function declarationNameToString(name) { + return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + } + ts.declarationNameToString = declarationNameToString; + function getTextOfPropertyName(name) { + switch (name.kind) { + case 70: + return name.text; + case 9: + case 8: + return name.text; + case 143: + if (isStringOrNumericLiteral(name.expression)) { + return name.expression.text; + } + } + return undefined; + } + ts.getTextOfPropertyName = getTextOfPropertyName; + function entityNameToString(name) { + switch (name.kind) { + case 70: + return getFullWidth(name) === 0 ? ts.unescapeIdentifier(name.text) : getTextOfNode(name); + case 142: + return entityNameToString(name.left) + "." + entityNameToString(name.right); + case 178: + return entityNameToString(name.expression) + "." + entityNameToString(name.name); + } + } + ts.entityNameToString = entityNameToString; + function createDiagnosticForNode(node, message, arg0, arg1, arg2) { + var sourceFile = getSourceFileOfNode(node); + return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2); + } + ts.createDiagnosticForNode = createDiagnosticForNode; + function createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2) { + var span = getErrorSpanForNode(sourceFile, node); + return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); + } + ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile; + 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 getErrorSpanForArrowFunction(sourceFile, node) { + var pos = ts.skipTrivia(sourceFile.text, node.pos); + if (node.body && node.body.kind === 206) { + var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; + var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; + if (startLine < endLine) { + return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1); + } + } + return ts.createTextSpanFromBounds(pos, node.end); + } + function getErrorSpanForNode(sourceFile, node) { + var errorNode = node; + switch (node.kind) { + case 264: + 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 225: + case 175: + case 228: + case 198: + case 229: + case 232: + case 231: + case 263: + case 227: + case 185: + case 150: + case 152: + case 153: + case 230: + errorNode = node.name; + break; + case 186: + return getErrorSpanForArrowFunction(sourceFile, node); + } + 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 isExternalOrCommonJsModule(file) { + return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; + } + ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; + function isDeclarationFile(file) { + return file.isDeclarationFile; + } + ts.isDeclarationFile = isDeclarationFile; + function isConstEnumDeclaration(node) { + return node.kind === 231 && isConst(node); + } + ts.isConstEnumDeclaration = isConstEnumDeclaration; + function isConst(node) { + return !!(ts.getCombinedNodeFlags(node) & 2) + || !!(ts.getCombinedModifierFlags(node) & 2048); + } + ts.isConst = isConst; + function isLet(node) { + return !!(ts.getCombinedNodeFlags(node) & 1); + } + ts.isLet = isLet; + function isSuperCall(n) { + return n.kind === 180 && n.expression.kind === 96; + } + ts.isSuperCall = isSuperCall; + function isPrologueDirective(node) { + return node.kind === 209 + && node.expression.kind === 9; + } + ts.isPrologueDirective = isPrologueDirective; + function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + } + ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; + function getLeadingCommentRangesOfNodeFromText(node, text) { + return ts.getLeadingCommentRanges(text, node.pos); + } + ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; + function getJSDocCommentRanges(node, text) { + var commentRanges = (node.kind === 145 || + node.kind === 144 || + node.kind === 185 || + node.kind === 186) ? + ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : + getLeadingCommentRangesOfNodeFromText(node, text); + return ts.filter(commentRanges, function (comment) { + return text.charCodeAt(comment.pos + 1) === 42 && + text.charCodeAt(comment.pos + 2) === 42 && + text.charCodeAt(comment.pos + 3) !== 47; + }); + } + ts.getJSDocCommentRanges = getJSDocCommentRanges; + ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + function isPartOfTypeNode(node) { + if (157 <= node.kind && node.kind <= 172) { + return true; + } + switch (node.kind) { + case 118: + case 132: + case 135: + case 121: + case 136: + case 138: + case 129: + return true; + case 104: + return node.parent.kind !== 189; + case 200: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); + case 70: + if (node.parent.kind === 142 && node.parent.right === node) { + node = node.parent; + } + else if (node.parent.kind === 178 && node.parent.name === node) { + node = node.parent; + } + ts.Debug.assert(node.kind === 70 || node.kind === 142 || node.kind === 178, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 142: + case 178: + case 98: + var parent = node.parent; + if (parent.kind === 161) { + return false; + } + if (157 <= parent.kind && parent.kind <= 172) { + return true; + } + switch (parent.kind) { + case 200: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); + case 144: + return node === parent.constraint; + case 148: + case 147: + case 145: + case 225: + return node === parent.type; + case 227: + case 185: + case 186: + case 151: + case 150: + case 149: + case 152: + case 153: + return node === parent.type; + case 154: + case 155: + case 156: + return node === parent.type; + case 183: + return node === parent.type; + case 180: + case 181: + return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; + case 182: + return false; + } + } + return false; + } + ts.isPartOfTypeNode = isPartOfTypeNode; + function isChildOfNodeWithKind(node, kind) { + while (node) { + if (node.kind === kind) { + return true; + } + node = node.parent; + } + return false; + } + ts.isChildOfNodeWithKind = isChildOfNodeWithKind; + function isPrefixUnaryExpression(node) { + return node.kind === 191; + } + ts.isPrefixUnaryExpression = isPrefixUnaryExpression; + function forEachReturnStatement(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 218: + return visitor(node); + case 234: + case 206: + case 210: + case 211: + case 212: + case 213: + case 214: + case 215: + case 219: + case 220: + case 256: + case 257: + case 221: + case 223: + case 259: + return ts.forEachChild(node, traverse); + } + } + } + ts.forEachReturnStatement = forEachReturnStatement; + function forEachYieldExpression(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 196: + visitor(node); + var operand = node.expression; + if (operand) { + traverse(operand); + } + case 231: + case 229: + case 232: + case 230: + case 228: + case 198: + return; + default: + if (isFunctionLike(node)) { + var name = node.name; + if (name && name.kind === 143) { + traverse(name.expression); + return; + } + } + else if (!isPartOfTypeNode(node)) { + ts.forEachChild(node, traverse); + } + } + } + } + ts.forEachYieldExpression = forEachYieldExpression; + function getRestParameterElementType(node) { + if (node && node.kind === 163) { + return node.elementType; + } + else if (node && node.kind === 158) { + return ts.singleOrUndefined(node.typeArguments); + } + else { + return undefined; + } + } + ts.getRestParameterElementType = getRestParameterElementType; + function isVariableLike(node) { + if (node) { + switch (node.kind) { + case 175: + case 263: + case 145: + case 260: + case 148: + case 147: + case 261: + case 225: + return true; + } + } + return false; + } + ts.isVariableLike = isVariableLike; + function isAccessor(node) { + return node && (node.kind === 152 || node.kind === 153); + } + ts.isAccessor = isAccessor; + function isClassLike(node) { + return node && (node.kind === 228 || node.kind === 198); + } + ts.isClassLike = isClassLike; + function isFunctionLike(node) { + return node && isFunctionLikeKind(node.kind); + } + ts.isFunctionLike = isFunctionLike; + function isFunctionLikeKind(kind) { + switch (kind) { + case 151: + case 185: + case 227: + case 186: + case 150: + case 149: + case 152: + case 153: + case 154: + case 155: + case 156: + case 159: + case 160: + return true; + } + return false; + } + ts.isFunctionLikeKind = isFunctionLikeKind; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 150: + case 149: + case 151: + case 152: + case 153: + case 227: + case 185: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; + function isIterationStatement(node, lookInLabeledStatements) { + switch (node.kind) { + case 213: + case 214: + case 215: + case 211: + case 212: + return true; + case 221: + return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); + } + return false; + } + ts.isIterationStatement = isIterationStatement; + function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + while (true) { + if (beforeUnwrapLabelCallback) { + beforeUnwrapLabelCallback(node); + } + if (node.statement.kind !== 221) { + return node.statement; + } + node = node.statement; + } + } + ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; + function isFunctionBlock(node) { + return node && node.kind === 206 && isFunctionLike(node.parent); + } + ts.isFunctionBlock = isFunctionBlock; + function isObjectLiteralMethod(node) { + return node && node.kind === 150 && node.parent.kind === 177; + } + ts.isObjectLiteralMethod = isObjectLiteralMethod; + function isObjectLiteralOrClassExpressionMethod(node) { + return node.kind === 150 && + (node.parent.kind === 177 || + node.parent.kind === 198); + } + ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; + function isIdentifierTypePredicate(predicate) { + return predicate && predicate.kind === 1; + } + ts.isIdentifierTypePredicate = isIdentifierTypePredicate; + function isThisTypePredicate(predicate) { + return predicate && predicate.kind === 0; + } + ts.isThisTypePredicate = isThisTypePredicate; + 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 143: + if (isClassLike(node.parent.parent)) { + return node; + } + node = node.parent; + break; + case 146: + if (node.parent.kind === 145 && isClassElement(node.parent.parent)) { + node = node.parent.parent; + } + else if (isClassElement(node.parent)) { + node = node.parent; + } + break; + case 186: + if (!includeArrowFunctions) { + continue; + } + case 227: + case 185: + case 232: + case 148: + case 147: + case 150: + case 149: + case 151: + case 152: + case 153: + case 154: + case 155: + case 156: + case 231: + case 264: + return node; + } + } + } + ts.getThisContainer = getThisContainer; + function getNewTargetContainer(node) { + var container = getThisContainer(node, false); + if (container) { + switch (container.kind) { + case 151: + case 227: + case 185: + return container; + } + } + return undefined; + } + ts.getNewTargetContainer = getNewTargetContainer; + function getSuperContainer(node, stopOnFunctions) { + while (true) { + node = node.parent; + if (!node) { + return node; + } + switch (node.kind) { + case 143: + node = node.parent; + break; + case 227: + case 185: + case 186: + if (!stopOnFunctions) { + continue; + } + case 148: + case 147: + case 150: + case 149: + case 151: + case 152: + case 153: + return node; + case 146: + if (node.parent.kind === 145 && isClassElement(node.parent.parent)) { + node = node.parent.parent; + } + else if (isClassElement(node.parent)) { + node = node.parent; + } + break; + } + } + } + ts.getSuperContainer = getSuperContainer; + function getImmediatelyInvokedFunctionExpression(func) { + if (func.kind === 185 || func.kind === 186) { + var prev = func; + var parent = func.parent; + while (parent.kind === 184) { + prev = parent; + parent = parent.parent; + } + if (parent.kind === 180 && parent.expression === prev) { + return parent; + } + } + } + ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; + function isSuperProperty(node) { + var kind = node.kind; + return (kind === 178 || kind === 179) + && node.expression.kind === 96; + } + ts.isSuperProperty = isSuperProperty; + function getEntityNameFromTypeNode(node) { + switch (node.kind) { + case 158: + case 276: + return node.typeName; + case 200: + return isEntityNameExpression(node.expression) + ? node.expression + : undefined; + case 70: + case 142: + return node; + } + return undefined; + } + ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; + function isCallLikeExpression(node) { + switch (node.kind) { + case 250: + case 249: + case 180: + case 181: + case 182: + case 146: + return true; + default: + return false; + } + } + ts.isCallLikeExpression = isCallLikeExpression; + function getInvokedExpression(node) { + if (node.kind === 182) { + return node.tag; + } + else if (isJsxOpeningLikeElement(node)) { + return node.tagName; + } + return node.expression; + } + ts.getInvokedExpression = getInvokedExpression; + function nodeCanBeDecorated(node) { + switch (node.kind) { + case 228: + return true; + case 148: + return node.parent.kind === 228; + case 152: + case 153: + case 150: + return node.body !== undefined + && node.parent.kind === 228; + case 145: + return node.parent.body !== undefined + && (node.parent.kind === 151 + || node.parent.kind === 150 + || node.parent.kind === 153) + && node.parent.parent.kind === 228; + } + return false; + } + ts.nodeCanBeDecorated = nodeCanBeDecorated; + function nodeIsDecorated(node) { + return node.decorators !== undefined + && nodeCanBeDecorated(node); + } + ts.nodeIsDecorated = nodeIsDecorated; + function nodeOrChildIsDecorated(node) { + return nodeIsDecorated(node) || childIsDecorated(node); + } + ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function childIsDecorated(node) { + switch (node.kind) { + case 228: + return ts.forEach(node.members, nodeOrChildIsDecorated); + case 150: + case 153: + return ts.forEach(node.parameters, nodeIsDecorated); + } + } + ts.childIsDecorated = childIsDecorated; + function isJSXTagName(node) { + var parent = node.parent; + if (parent.kind === 250 || + parent.kind === 249 || + parent.kind === 251) { + return parent.tagName === node; + } + return false; + } + ts.isJSXTagName = isJSXTagName; + function isPartOfExpression(node) { + switch (node.kind) { + case 98: + case 96: + case 94: + case 100: + case 85: + case 11: + case 176: + case 177: + case 178: + case 179: + case 180: + case 181: + case 182: + case 201: + case 183: + case 202: + case 184: + case 185: + case 198: + case 186: + case 189: + case 187: + case 188: + case 191: + case 192: + case 193: + case 194: + case 197: + case 195: + case 12: + case 199: + case 248: + case 249: + case 196: + case 190: + case 203: + return true; + case 142: + while (node.parent.kind === 142) { + node = node.parent; + } + return node.parent.kind === 161 || isJSXTagName(node); + case 70: + if (node.parent.kind === 161 || isJSXTagName(node)) { + return true; + } + case 8: + case 9: + case 98: + var parent = node.parent; + switch (parent.kind) { + case 225: + case 145: + case 148: + case 147: + case 263: + case 260: + case 175: + return parent.initializer === node; + case 209: + case 210: + case 211: + case 212: + case 218: + case 219: + case 220: + case 256: + case 222: + case 220: + return parent.expression === node; + case 213: + var forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== 226) || + forStatement.condition === node || + forStatement.incrementor === node; + case 214: + case 215: + var forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 226) || + forInStatement.expression === node; + case 183: + case 201: + return node === parent.expression; + case 204: + return node === parent.expression; + case 143: + return node === parent.expression; + case 146: + case 255: + case 254: + case 262: + return true; + case 200: + return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); + default: + if (isPartOfExpression(parent)) { + return true; + } + } + } + return false; + } + ts.isPartOfExpression = isPartOfExpression; + function isInstantiatedModule(node, preserveConstEnums) { + var moduleState = ts.getModuleInstanceState(node); + return moduleState === 1 || + (preserveConstEnums && moduleState === 2); + } + ts.isInstantiatedModule = isInstantiatedModule; + function isExternalModuleImportEqualsDeclaration(node) { + return node.kind === 236 && node.moduleReference.kind === 247; + } + ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; + function getExternalModuleImportEqualsDeclarationExpression(node) { + ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); + return node.moduleReference.expression; + } + ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; + function isInternalModuleImportEqualsDeclaration(node) { + return node.kind === 236 && node.moduleReference.kind !== 247; + } + ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; + function isSourceFileJavaScript(file) { + return isInJavaScriptFile(file); + } + ts.isSourceFileJavaScript = isSourceFileJavaScript; + function isInJavaScriptFile(node) { + return node && !!(node.flags & 65536); + } + ts.isInJavaScriptFile = isInJavaScriptFile; + function isRequireCall(expression, checkArgumentIsStringLiteral) { + var isRequire = expression.kind === 180 && + expression.expression.kind === 70 && + expression.expression.text === "require" && + expression.arguments.length === 1; + return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); + } + ts.isRequireCall = isRequireCall; + function isSingleOrDoubleQuote(charCode) { + return charCode === 39 || charCode === 34; + } + ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; + function isDeclarationOfFunctionExpression(s) { + if (s.valueDeclaration && s.valueDeclaration.kind === 225) { + var declaration = s.valueDeclaration; + return declaration.initializer && declaration.initializer.kind === 185; + } + return false; + } + ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression; + function getSpecialPropertyAssignmentKind(expression) { + if (!isInJavaScriptFile(expression)) { + return 0; + } + if (expression.kind !== 193) { + return 0; + } + var expr = expression; + if (expr.operatorToken.kind !== 57 || expr.left.kind !== 178) { + return 0; + } + var lhs = expr.left; + if (lhs.expression.kind === 70) { + var lhsId = lhs.expression; + if (lhsId.text === "exports") { + return 1; + } + else if (lhsId.text === "module" && lhs.name.text === "exports") { + return 2; + } + } + else if (lhs.expression.kind === 98) { + return 4; + } + else if (lhs.expression.kind === 178) { + var innerPropertyAccess = lhs.expression; + if (innerPropertyAccess.expression.kind === 70) { + var innerPropertyAccessIdentifier = innerPropertyAccess.expression; + if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { + return 1; + } + if (innerPropertyAccess.name.text === "prototype") { + return 3; + } + } + } + return 0; + } + ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + function getExternalModuleName(node) { + if (node.kind === 237) { + return node.moduleSpecifier; + } + if (node.kind === 236) { + var reference = node.moduleReference; + if (reference.kind === 247) { + return reference.expression; + } + } + if (node.kind === 243) { + return node.moduleSpecifier; + } + if (node.kind === 232 && node.name.kind === 9) { + return node.name; + } + } + ts.getExternalModuleName = getExternalModuleName; + function getNamespaceDeclarationNode(node) { + if (node.kind === 236) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 239) { + return importClause.namedBindings; + } + } + ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; + function isDefaultImport(node) { + return node.kind === 237 + && node.importClause + && !!node.importClause.name; + } + ts.isDefaultImport = isDefaultImport; + function hasQuestionToken(node) { + if (node) { + switch (node.kind) { + case 145: + case 150: + case 149: + case 261: + case 260: + case 148: + case 147: + return node.questionToken !== undefined; + } + } + return false; + } + ts.hasQuestionToken = hasQuestionToken; + function isJSDocConstructSignature(node) { + return node.kind === 278 && + node.parameters.length > 0 && + node.parameters[0].type.kind === 280; + } + ts.isJSDocConstructSignature = isJSDocConstructSignature; + function getCommentsFromJSDoc(node) { + return ts.map(getJSDocs(node), function (doc) { return doc.comment; }); + } + ts.getCommentsFromJSDoc = getCommentsFromJSDoc; + function hasJSDocParameterTags(node) { + var parameterTags = getJSDocTags(node, 285); + return parameterTags && parameterTags.length > 0; + } + ts.hasJSDocParameterTags = hasJSDocParameterTags; + function getJSDocTags(node, kind) { + var docs = getJSDocs(node); + if (docs) { + var result = []; + for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { + var doc = docs_1[_i]; + if (doc.kind === 285) { + if (doc.kind === kind) { + result.push(doc); + } + } + else { + result.push.apply(result, ts.filter(doc.tags, function (tag) { return tag.kind === kind; })); + } + } + return result; + } + } + function getFirstJSDocTag(node, kind) { + return node && ts.firstOrUndefined(getJSDocTags(node, kind)); + } + function getJSDocs(node) { + var cache = node.jsDocCache; + if (!cache) { + getJSDocsWorker(node); + node.jsDocCache = cache; + } + return cache; + function getJSDocsWorker(node) { + var parent = node.parent; + var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && + parent.initializer === node && + parent.parent.parent.kind === 207; + var isVariableOfVariableDeclarationStatement = isVariableLike(node) && + parent.parent.kind === 207; + var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : + isVariableOfVariableDeclarationStatement ? parent.parent : + undefined; + if (variableStatementNode) { + getJSDocsWorker(variableStatementNode); + } + var isSourceOfAssignmentExpressionStatement = parent && parent.parent && + parent.kind === 193 && + parent.operatorToken.kind === 57 && + parent.parent.kind === 209; + if (isSourceOfAssignmentExpressionStatement) { + getJSDocsWorker(parent.parent); + } + var isModuleDeclaration = node.kind === 232 && + parent && parent.kind === 232; + var isPropertyAssignmentExpression = parent && parent.kind === 260; + if (isModuleDeclaration || isPropertyAssignmentExpression) { + getJSDocsWorker(parent); + } + if (node.kind === 145) { + cache = ts.concatenate(cache, getJSDocParameterTags(node)); + } + if (isVariableLike(node) && node.initializer) { + cache = ts.concatenate(cache, node.initializer.jsDoc); + } + cache = ts.concatenate(cache, node.jsDoc); + } + } + function getJSDocParameterTags(param) { + if (!isParameter(param)) { + return undefined; + } + var func = param.parent; + var tags = getJSDocTags(func, 285); + if (!param.name) { + var i = func.parameters.indexOf(param); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 285; }); + if (paramTags && 0 <= i && i < paramTags.length) { + return [paramTags[i]]; + } + } + else if (param.name.kind === 70) { + var name_1 = param.name.text; + return ts.filter(tags, function (tag) { return tag.kind === 285 && tag.parameterName.text === name_1; }); + } + else { + return undefined; + } + } + ts.getJSDocParameterTags = getJSDocParameterTags; + function getJSDocType(node) { + var tag = getFirstJSDocTag(node, 287); + if (!tag && node.kind === 145) { + var paramTags = getJSDocParameterTags(node); + if (paramTags) { + tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); + } + } + return tag && tag.typeExpression && tag.typeExpression.type; + } + ts.getJSDocType = getJSDocType; + function getJSDocAugmentsTag(node) { + return getFirstJSDocTag(node, 284); + } + ts.getJSDocAugmentsTag = getJSDocAugmentsTag; + function getJSDocReturnTag(node) { + return getFirstJSDocTag(node, 286); + } + ts.getJSDocReturnTag = getJSDocReturnTag; + function getJSDocTemplateTag(node) { + return getFirstJSDocTag(node, 288); + } + ts.getJSDocTemplateTag = getJSDocTemplateTag; + function hasRestParameter(s) { + return isRestParameter(ts.lastOrUndefined(s.parameters)); + } + ts.hasRestParameter = hasRestParameter; + function hasDeclaredRestParameter(s) { + return isDeclaredRestParam(ts.lastOrUndefined(s.parameters)); + } + ts.hasDeclaredRestParameter = hasDeclaredRestParameter; + function isRestParameter(node) { + if (node && (node.flags & 65536)) { + if (node.type && node.type.kind === 279 || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 279; })) { + return true; + } + } + return isDeclaredRestParam(node); + } + ts.isRestParameter = isRestParameter; + function isDeclaredRestParam(node) { + return node && node.dotDotDotToken !== undefined; + } + ts.isDeclaredRestParam = isDeclaredRestParam; + var AssignmentKind; + (function (AssignmentKind) { + AssignmentKind[AssignmentKind["None"] = 0] = "None"; + AssignmentKind[AssignmentKind["Definite"] = 1] = "Definite"; + AssignmentKind[AssignmentKind["Compound"] = 2] = "Compound"; + })(AssignmentKind = ts.AssignmentKind || (ts.AssignmentKind = {})); + function getAssignmentTargetKind(node) { + var parent = node.parent; + while (true) { + switch (parent.kind) { + case 193: + var binaryOperator = parent.operatorToken.kind; + return isAssignmentOperator(binaryOperator) && parent.left === node ? + binaryOperator === 57 ? 1 : 2 : + 0; + case 191: + case 192: + var unaryOperator = parent.operator; + return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; + case 214: + case 215: + return parent.initializer === node ? 1 : 0; + case 184: + case 176: + case 197: + node = parent; + break; + case 261: + if (parent.name !== node) { + return 0; + } + node = parent.parent; + break; + case 260: + if (parent.name === node) { + return 0; + } + node = parent.parent; + break; + default: + return 0; + } + parent = node.parent; + } + } + ts.getAssignmentTargetKind = getAssignmentTargetKind; + function isAssignmentTarget(node) { + return getAssignmentTargetKind(node) !== 0; + } + ts.isAssignmentTarget = isAssignmentTarget; + function isDeleteTarget(node) { + if (node.kind !== 178 && node.kind !== 179) { + return false; + } + node = node.parent; + while (node && node.kind === 184) { + node = node.parent; + } + return node && node.kind === 187; + } + ts.isDeleteTarget = isDeleteTarget; + function isNodeDescendantOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + ts.isNodeDescendantOf = isNodeDescendantOf; + function isInAmbientContext(node) { + while (node) { + if (hasModifier(node, 2) || (node.kind === 264 && node.isDeclarationFile)) { + return true; + } + node = node.parent; + } + return false; + } + ts.isInAmbientContext = isInAmbientContext; + function isDeclarationName(name) { + if (name.kind !== 70 && name.kind !== 9 && name.kind !== 8) { + return false; + } + var parent = name.parent; + if (parent.kind === 241 || parent.kind === 245) { + if (parent.propertyName) { + return true; + } + } + if (isDeclaration(parent)) { + return parent.name === name; + } + return false; + } + ts.isDeclarationName = isDeclarationName; + function isLiteralComputedPropertyDeclarationName(node) { + return (node.kind === 9 || node.kind === 8) && + node.parent.kind === 143 && + isDeclaration(node.parent.parent); + } + ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; + function isIdentifierName(node) { + var parent = node.parent; + switch (parent.kind) { + case 148: + case 147: + case 150: + case 149: + case 152: + case 153: + case 263: + case 260: + case 178: + return parent.name === node; + case 142: + if (parent.right === node) { + while (parent.kind === 142) { + parent = parent.parent; + } + return parent.kind === 161; + } + return false; + case 175: + case 241: + return parent.propertyName === node; + case 245: + return true; + } + return false; + } + ts.isIdentifierName = isIdentifierName; + function isAliasSymbolDeclaration(node) { + return node.kind === 236 || + node.kind === 235 || + node.kind === 238 && !!node.name || + node.kind === 239 || + node.kind === 241 || + node.kind === 245 || + node.kind === 242 && exportAssignmentIsAlias(node); + } + ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; + function exportAssignmentIsAlias(node) { + return isEntityNameExpression(node.expression); + } + ts.exportAssignmentIsAlias = exportAssignmentIsAlias; + function getClassExtendsHeritageClauseElement(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 84); + return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; + } + ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + function getClassImplementsHeritageClauseElements(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 107); + return heritageClause ? heritageClause.types : undefined; + } + ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; + function getInterfaceBaseTypeNodes(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 84); + return heritageClause ? heritageClause.types : undefined; + } + ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; + function getHeritageClause(clauses, kind) { + if (clauses) { + for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { + var clause = clauses_1[_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); + 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.test(comment)) { + if (isNoDefaultLibRegEx.test(comment)) { + return { + isNoDefaultLib: true + }; + } + else { + var refMatchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); + var refLibResult = !refMatchResult && ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); + if (refMatchResult || refLibResult) { + var start = commentRange.pos; + var end = commentRange.end; + return { + fileReference: { + pos: start, + end: end, + fileName: (refMatchResult || refLibResult)[3] + }, + isNoDefaultLib: false, + isTypeReferenceDirective: !!refLibResult + }; + } + return { + diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, + isNoDefaultLib: false + }; + } + } + return undefined; + } + ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; + function isKeyword(token) { + return 71 <= token && token <= 141; + } + ts.isKeyword = isKeyword; + function isTrivia(token) { + return 2 <= token && token <= 7; + } + ts.isTrivia = isTrivia; + function isAsyncFunctionLike(node) { + return isFunctionLike(node) && hasModifier(node, 256) && !isAccessor(node); + } + ts.isAsyncFunctionLike = isAsyncFunctionLike; + function isStringOrNumericLiteral(node) { + var kind = node.kind; + return kind === 9 + || kind === 8; + } + ts.isStringOrNumericLiteral = isStringOrNumericLiteral; + function hasDynamicName(declaration) { + return declaration.name && isDynamicName(declaration.name); + } + ts.hasDynamicName = hasDynamicName; + function isDynamicName(name) { + return name.kind === 143 && + !isStringOrNumericLiteral(name.expression) && + !isWellKnownSymbolSyntactically(name.expression); + } + ts.isDynamicName = isDynamicName; + function isWellKnownSymbolSyntactically(node) { + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); + } + ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; + function getPropertyNameForPropertyNameNode(name) { + if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 145) { + return name.text; + } + if (name.kind === 143) { + var nameExpression = name.expression; + if (isWellKnownSymbolSyntactically(nameExpression)) { + var rightHandSideName = nameExpression.name.text; + return getPropertyNameForKnownSymbolName(rightHandSideName); + } + else if (nameExpression.kind === 9 || nameExpression.kind === 8) { + return nameExpression.text; + } + } + return undefined; + } + ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; + function getPropertyNameForKnownSymbolName(symbolName) { + return "__@" + symbolName; + } + ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; + function isESSymbolIdentifier(node) { + return node.kind === 70 && node.text === "Symbol"; + } + ts.isESSymbolIdentifier = isESSymbolIdentifier; + function isPushOrUnshiftIdentifier(node) { + return node.text === "push" || node.text === "unshift"; + } + ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; + function isModifierKind(token) { + switch (token) { + case 116: + case 119: + case 75: + case 123: + case 78: + case 83: + case 113: + case 111: + case 112: + case 130: + case 114: + return true; + } + return false; + } + ts.isModifierKind = isModifierKind; + function isParameterDeclaration(node) { + var root = getRootDeclaration(node); + return root.kind === 145; + } + ts.isParameterDeclaration = isParameterDeclaration; + function getRootDeclaration(node) { + while (node.kind === 175) { + node = node.parent.parent; + } + return node; + } + ts.getRootDeclaration = getRootDeclaration; + function nodeStartsNewLexicalEnvironment(node) { + var kind = node.kind; + return kind === 151 + || kind === 185 + || kind === 227 + || kind === 186 + || kind === 150 + || kind === 152 + || kind === 153 + || kind === 232 + || kind === 264; + } + ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function nodeIsSynthesized(node) { + return ts.positionIsSynthesized(node.pos) + || ts.positionIsSynthesized(node.end); + } + ts.nodeIsSynthesized = nodeIsSynthesized; + function getOriginalSourceFileOrBundle(sourceFileOrBundle) { + if (sourceFileOrBundle.kind === 265) { + return ts.updateBundle(sourceFileOrBundle, ts.sameMap(sourceFileOrBundle.sourceFiles, getOriginalSourceFile)); + } + return getOriginalSourceFile(sourceFileOrBundle); + } + ts.getOriginalSourceFileOrBundle = getOriginalSourceFileOrBundle; + function getOriginalSourceFile(sourceFile) { + return ts.getParseTreeNode(sourceFile, isSourceFile) || sourceFile; + } + function getOriginalSourceFiles(sourceFiles) { + return ts.sameMap(sourceFiles, getOriginalSourceFile); + } + ts.getOriginalSourceFiles = getOriginalSourceFiles; + function getOriginalNodeId(node) { + node = ts.getOriginalNode(node); + return node ? ts.getNodeId(node) : 0; + } + ts.getOriginalNodeId = getOriginalNodeId; + var Associativity; + (function (Associativity) { + Associativity[Associativity["Left"] = 0] = "Left"; + Associativity[Associativity["Right"] = 1] = "Right"; + })(Associativity = ts.Associativity || (ts.Associativity = {})); + function getExpressionAssociativity(expression) { + var operator = getOperator(expression); + var hasArguments = expression.kind === 181 && expression.arguments !== undefined; + return getOperatorAssociativity(expression.kind, operator, hasArguments); + } + ts.getExpressionAssociativity = getExpressionAssociativity; + function getOperatorAssociativity(kind, operator, hasArguments) { + switch (kind) { + case 181: + return hasArguments ? 0 : 1; + case 191: + case 188: + case 189: + case 187: + case 190: + case 194: + case 196: + return 1; + case 193: + switch (operator) { + case 39: + case 57: + case 58: + case 59: + case 61: + case 60: + case 62: + case 63: + case 64: + case 65: + case 66: + case 67: + case 69: + case 68: + return 1; + } + } + return 0; + } + ts.getOperatorAssociativity = getOperatorAssociativity; + function getExpressionPrecedence(expression) { + var operator = getOperator(expression); + var hasArguments = expression.kind === 181 && expression.arguments !== undefined; + return getOperatorPrecedence(expression.kind, operator, hasArguments); + } + ts.getExpressionPrecedence = getExpressionPrecedence; + function getOperator(expression) { + if (expression.kind === 193) { + return expression.operatorToken.kind; + } + else if (expression.kind === 191 || expression.kind === 192) { + return expression.operator; + } + else { + return expression.kind; + } + } + ts.getOperator = getOperator; + function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { + switch (nodeKind) { + case 98: + case 96: + case 70: + case 94: + case 100: + case 85: + case 8: + case 9: + case 176: + case 177: + case 185: + case 186: + case 198: + case 248: + case 249: + case 11: + case 12: + case 195: + case 184: + case 199: + return 19; + case 182: + case 178: + case 179: + return 18; + case 181: + return hasArguments ? 18 : 17; + case 180: + return 17; + case 192: + return 16; + case 191: + case 188: + case 189: + case 187: + case 190: + return 15; + case 193: + switch (operatorKind) { + case 50: + case 51: + return 15; + case 39: + case 38: + case 40: + case 41: + return 14; + case 36: + case 37: + return 13; + case 44: + case 45: + case 46: + return 12; + case 26: + case 29: + case 28: + case 30: + case 91: + case 92: + return 11; + case 31: + case 33: + case 32: + case 34: + return 10; + case 47: + return 9; + case 49: + return 8; + case 48: + return 7; + case 52: + return 6; + case 53: + return 5; + case 57: + case 58: + case 59: + case 61: + case 60: + case 62: + case 63: + case 64: + case 65: + case 66: + case 67: + case 69: + case 68: + return 3; + case 25: + return 0; + default: + return -1; + } + case 194: + return 4; + case 196: + return 2; + case 197: + return 1; + default: + return -1; + } + } + ts.getOperatorPrecedence = getOperatorPrecedence; + function createDiagnosticCollection() { + var nonFileDiagnostics = []; + var fileDiagnostics = ts.createMap(); + var diagnosticsModified = false; + var modificationCount = 0; + return { + add: add, + getGlobalDiagnostics: getGlobalDiagnostics, + getDiagnostics: getDiagnostics, + getModificationCount: getModificationCount, + reattachFileDiagnostics: reattachFileDiagnostics + }; + function getModificationCount() { + return modificationCount; + } + function reattachFileDiagnostics(newFile) { + ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); + } + function add(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); + if (!diagnostics) { + diagnostics = []; + fileDiagnostics.set(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.get(fileName) || []; + } + var allDiagnostics = []; + function pushDiagnostic(d) { + allDiagnostics.push(d); + } + ts.forEach(nonFileDiagnostics, pushDiagnostic); + fileDiagnostics.forEach(function (diagnostics) { + ts.forEach(diagnostics, pushDiagnostic); + }); + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function sortAndDeduplicate() { + if (!diagnosticsModified) { + return; + } + diagnosticsModified = false; + nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); + fileDiagnostics.forEach(function (diagnostics, key) { + fileDiagnostics.set(key, ts.sortAndDeduplicateDiagnostics(diagnostics)); + }); + } + } + ts.createDiagnosticCollection = createDiagnosticCollection; + var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var escapedCharsMap = ts.createMapFromTemplate({ + "\0": "\\0", + "\t": "\\t", + "\v": "\\v", + "\f": "\\f", + "\b": "\\b", + "\r": "\\r", + "\n": "\\n", + "\\": "\\\\", + "\"": "\\\"", + "\u2028": "\\u2028", + "\u2029": "\\u2029", + "\u0085": "\\u0085" + }); + function escapeString(s) { + return s.replace(escapedCharsRegExp, getReplacement); + } + ts.escapeString = escapeString; + function getReplacement(c) { + return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } + 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; + var lineStart; + var lineCount; + var linePos; + function write(s) { + if (s && s.length) { + if (lineStart) { + output += getIndentString(indent); + lineStart = false; + } + output += s; + } + } + function reset() { + output = ""; + indent = 0; + lineStart = true; + lineCount = 0; + linePos = 0; + } + 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(text, node) { + write(getTextOfNodeFromSourceText(text, node)); + } + reset(); + return { + write: write, + rawWrite: rawWrite, + writeTextOfNode: writeTextOfNode, + writeLiteral: writeLiteral, + writeLine: writeLine, + increaseIndent: function () { indent++; }, + decreaseIndent: function () { 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; }, + isAtStartOfLine: function () { return lineStart; }, + reset: reset + }; + } + ts.createTextWriter = createTextWriter; + function getResolvedExternalModuleName(host, file) { + return file.moduleName || getExternalModuleNameFromPath(host, file.fileName); + } + ts.getResolvedExternalModuleName = getResolvedExternalModuleName; + function getExternalModuleNameFromDeclaration(host, resolver, declaration) { + var file = resolver.getExternalModuleFileFromDeclaration(declaration); + if (!file || isDeclarationFile(file)) { + return undefined; + } + return getResolvedExternalModuleName(host, file); + } + ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; + function getExternalModuleNameFromPath(host, fileName) { + var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; + var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); + var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); + var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false); + return ts.removeFileExtension(relativePath); + } + ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; + 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 getDeclarationEmitOutputFilePath(sourceFile, host) { + var options = host.getCompilerOptions(); + var outputDir = options.declarationDir || options.outDir; + var path = outputDir + ? getSourceFilePathInNewDir(sourceFile, host, outputDir) + : sourceFile.fileName; + return ts.removeFileExtension(path) + ".d.ts"; + } + ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; + function getSourceFilesToEmit(host, targetSourceFile) { + var options = host.getCompilerOptions(); + var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); }; + if (options.outFile || options.out) { + var moduleKind = ts.getEmitModuleKind(options); + var moduleEmitEnabled_1 = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; + return ts.filter(host.getSourceFiles(), function (sourceFile) { + return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); + }); + } + else { + var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); }); + } + } + ts.getSourceFilesToEmit = getSourceFilesToEmit; + function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary) { + return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !isDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); + } + ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); + var options = host.getCompilerOptions(); + if (options.outFile || options.out) { + if (sourceFiles.length) { + var jsFilePath = options.outFile || options.out; + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, ts.createBundle(sourceFiles), emitOnlyDtsFiles); + } + } + else { + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, sourceFile, emitOnlyDtsFiles); + } + } + } + ts.forEachEmittedFile = forEachEmittedFile; + function getSourceMapFilePath(jsFilePath, options) { + return options.sourceMap ? jsFilePath + ".map" : undefined; + } + function getOutputExtension(sourceFile, options) { + if (options.jsx === 1) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + return ".jsx"; + } + } + else if (sourceFile.languageVariant === 1) { + return ".jsx"; + } + } + return ".js"; + } + function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { + var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); + var commonSourceDirectory = host.getCommonSourceDirectory(); + var isSourceFileInCommonSourceDirectory = host.getCanonicalFileName(sourceFilePath).indexOf(host.getCanonicalFileName(commonSourceDirectory)) === 0; + sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath; + return ts.combinePaths(newDirPath, sourceFilePath); + } + ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; + function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) { + host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); + }, sourceFiles); + } + ts.writeFile = writeFile; + function getLineOfLocalPosition(currentSourceFile, pos) { + return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; + } + ts.getLineOfLocalPosition = getLineOfLocalPosition; + function getLineOfLocalPositionFromLineMap(lineMap, pos) { + return ts.computeLineAndCharacterOfPosition(lineMap, pos).line; + } + ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; + function getFirstConstructorWithBody(node) { + return ts.forEach(node.members, function (member) { + if (member.kind === 151 && nodeIsPresent(member.body)) { + return member; + } + }); + } + ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + function getSetAccessorTypeAnnotationNode(accessor) { + if (accessor && accessor.parameters.length > 0) { + var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]); + return accessor.parameters[hasThis ? 1 : 0].type; + } + } + ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; + function getThisParameter(signature) { + if (signature.parameters.length) { + var thisParameter = signature.parameters[0]; + if (parameterIsThisKeyword(thisParameter)) { + return thisParameter; + } + } + } + ts.getThisParameter = getThisParameter; + function parameterIsThisKeyword(parameter) { + return isThisIdentifier(parameter.name); + } + ts.parameterIsThisKeyword = parameterIsThisKeyword; + function isThisIdentifier(node) { + return node && node.kind === 70 && identifierIsThisKeyword(node); + } + ts.isThisIdentifier = isThisIdentifier; + function identifierIsThisKeyword(id) { + return id.originalKeywordKind === 98; + } + ts.identifierIsThisKeyword = identifierIsThisKeyword; + function getAllAccessorDeclarations(declarations, accessor) { + var firstAccessor; + var secondAccessor; + var getAccessor; + var setAccessor; + if (hasDynamicName(accessor)) { + firstAccessor = accessor; + if (accessor.kind === 152) { + getAccessor = accessor; + } + else if (accessor.kind === 153) { + setAccessor = accessor; + } + else { + ts.Debug.fail("Accessor has wrong kind"); + } + } + else { + ts.forEach(declarations, function (member) { + if ((member.kind === 152 || member.kind === 153) + && hasModifier(member, 32) === hasModifier(accessor, 32)) { + 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 === 152 && !getAccessor) { + getAccessor = member; + } + if (member.kind === 153 && !setAccessor) { + setAccessor = member; + } + } + } + }); + } + return { + firstAccessor: firstAccessor, + secondAccessor: secondAccessor, + getAccessor: getAccessor, + setAccessor: setAccessor + }; + } + ts.getAllAccessorDeclarations = getAllAccessorDeclarations; + function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) { + emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments); + } + ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; + function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) { + if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos && + getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) { + writer.writeLine(); + } + } + ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition; + function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) { + if (pos !== commentPos && + getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) { + writer.writeLine(); + } + } + ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition; + function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) { + if (comments && comments.length > 0) { + if (leadingSeparator) { + writer.write(" "); + } + var emitInterveningSeparator = false; + for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { + var comment = comments_1[_i]; + if (emitInterveningSeparator) { + writer.write(" "); + emitInterveningSeparator = false; + } + writeComment(text, lineMap, writer, comment.pos, comment.end, newLine); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + else { + emitInterveningSeparator = true; + } + } + if (emitInterveningSeparator && trailingSeparator) { + writer.write(" "); + } + } + } + ts.emitComments = emitComments; + function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) { + var leadingComments; + var currentDetachedCommentInfo; + if (removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); + } + } + else { + leadingComments = ts.getLeadingCommentRanges(text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment = void 0; + for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { + var comment = leadingComments_1[_i]; + if (lastComment) { + var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end); + var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos); + if (commentLine >= lastCommentLine + 2) { + break; + } + } + detachedComments.push(comment); + lastComment = comment; + } + if (detachedComments.length) { + var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); + var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); + emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment); + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + } + } + } + return currentDetachedCommentInfo; + function isPinnedComment(comment) { + return text.charCodeAt(comment.pos + 1) === 42 && + text.charCodeAt(comment.pos + 2) === 33; + } + } + ts.emitDetachedComments = emitDetachedComments; + function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { + if (text.charCodeAt(commentPos + 1) === 42) { + var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); + var lineCount = lineMap.length; + var firstCommentLineIndent = void 0; + for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) { + var nextLineStart = (currentLine + 1) === lineCount + ? text.length + 1 + : lineMap[currentLine + 1]; + if (pos !== commentPos) { + if (firstCommentLineIndent === undefined) { + firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos); + } + var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); + var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, 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(text, commentEnd, writer, newLine, pos, nextLineStart); + pos = nextLineStart; + } + } + else { + writer.write(text.substring(commentPos, commentEnd)); + } + } + ts.writeCommentRange = writeCommentRange; + function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { + var end = Math.min(commentEnd, nextLineStart - 1); + var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); + if (currentLineText) { + writer.write(currentLineText); + if (end !== commentEnd) { + writer.writeLine(); + } + } + else { + writer.writeLiteral(newLine); + } + } + function calculateIndent(text, pos, end) { + var currentLineIndent = 0; + for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { + if (text.charCodeAt(pos) === 9) { + currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); + } + else { + currentLineIndent++; + } + } + return currentLineIndent; + } + function hasModifiers(node) { + return getModifierFlags(node) !== 0; + } + ts.hasModifiers = hasModifiers; + function hasModifier(node, flags) { + return (getModifierFlags(node) & flags) !== 0; + } + ts.hasModifier = hasModifier; + function getModifierFlags(node) { + if (node.modifierFlagsCache & 536870912) { + return node.modifierFlagsCache & ~536870912; + } + var flags = 0; + if (node.modifiers) { + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var modifier = _a[_i]; + flags |= modifierToFlag(modifier.kind); + } + } + if (node.flags & 4 || (node.kind === 70 && node.isInJSDocNamespace)) { + flags |= 1; + } + node.modifierFlagsCache = flags | 536870912; + return flags; + } + ts.getModifierFlags = getModifierFlags; + function modifierToFlag(token) { + switch (token) { + case 114: return 32; + case 113: return 4; + case 112: return 16; + case 111: return 8; + case 116: return 128; + case 83: return 1; + case 123: return 2; + case 75: return 2048; + case 78: return 512; + case 119: return 256; + case 130: return 64; + } + return 0; + } + ts.modifierToFlag = modifierToFlag; + function isLogicalOperator(token) { + return token === 53 + || token === 52 + || token === 50; + } + ts.isLogicalOperator = isLogicalOperator; + function isAssignmentOperator(token) { + return token >= 57 && token <= 69; + } + ts.isAssignmentOperator = isAssignmentOperator; + function tryGetClassExtendingExpressionWithTypeArguments(node) { + if (node.kind === 200 && + node.parent.token === 84 && + isClassLike(node.parent.parent)) { + return node.parent.parent; + } + } + ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; + function isAssignmentExpression(node, excludeCompoundAssignment) { + return isBinaryExpression(node) + && (excludeCompoundAssignment + ? node.operatorToken.kind === 57 + : isAssignmentOperator(node.operatorToken.kind)) + && isLeftHandSideExpression(node.left); + } + ts.isAssignmentExpression = isAssignmentExpression; + function isDestructuringAssignment(node) { + if (isAssignmentExpression(node, true)) { + var kind = node.left.kind; + return kind === 177 + || kind === 176; + } + return false; + } + ts.isDestructuringAssignment = isDestructuringAssignment; + function isSupportedExpressionWithTypeArguments(node) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); + } + ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; + function isSupportedExpressionWithTypeArgumentsRest(node) { + if (node.kind === 70) { + return true; + } + else if (isPropertyAccessExpression(node)) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); + } + else { + return false; + } + } + function isExpressionWithTypeArgumentsInClassExtendsClause(node) { + return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; + } + ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; + function isEntityNameExpression(node) { + return node.kind === 70 || + node.kind === 178 && isEntityNameExpression(node.expression); + } + ts.isEntityNameExpression = isEntityNameExpression; + function isRightSideOfQualifiedNameOrPropertyAccess(node) { + return (node.parent.kind === 142 && node.parent.right === node) || + (node.parent.kind === 178 && node.parent.name === node); + } + ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 177) { + return expression.properties.length === 0; + } + if (kind === 176) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; + function getLocalSymbolForExportDefault(symbol) { + return isExportDefaultSymbol(symbol) ? symbol.valueDeclaration.localSymbol : undefined; + } + ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function isExportDefaultSymbol(symbol) { + return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512); + } + ts.isExportDefaultSymbol = isExportDefaultSymbol; + function tryExtractTypeScriptExtension(fileName) { + return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); + } + ts.tryExtractTypeScriptExtension = tryExtractTypeScriptExtension; + 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; + function isSimpleExpression(node) { + return isSimpleExpressionWorker(node, 0); + } + ts.isSimpleExpression = isSimpleExpression; + function isSimpleExpressionWorker(node, depth) { + if (depth <= 5) { + var kind = node.kind; + if (kind === 9 + || kind === 8 + || kind === 11 + || kind === 12 + || kind === 70 + || kind === 98 + || kind === 96 + || kind === 100 + || kind === 85 + || kind === 94) { + return true; + } + else if (kind === 178) { + return isSimpleExpressionWorker(node.expression, depth + 1); + } + else if (kind === 179) { + return isSimpleExpressionWorker(node.expression, depth + 1) + && isSimpleExpressionWorker(node.argumentExpression, depth + 1); + } + else if (kind === 191 + || kind === 192) { + return isSimpleExpressionWorker(node.operand, depth + 1); + } + else if (kind === 193) { + return node.operatorToken.kind !== 39 + && isSimpleExpressionWorker(node.left, depth + 1) + && isSimpleExpressionWorker(node.right, depth + 1); + } + else if (kind === 194) { + return isSimpleExpressionWorker(node.condition, depth + 1) + && isSimpleExpressionWorker(node.whenTrue, depth + 1) + && isSimpleExpressionWorker(node.whenFalse, depth + 1); + } + else if (kind === 189 + || kind === 188 + || kind === 187) { + return isSimpleExpressionWorker(node.expression, depth + 1); + } + else if (kind === 176) { + return node.elements.length === 0; + } + else if (kind === 177) { + return node.properties.length === 0; + } + else if (kind === 180) { + if (!isSimpleExpressionWorker(node.expression, depth + 1)) { + return false; + } + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var argument = _a[_i]; + if (!isSimpleExpressionWorker(argument, depth + 1)) { + return false; + } + } + return true; + } + } + return false; + } + var syntaxKindCache = []; + function formatSyntaxKind(kind) { + var syntaxKindEnum = ts.SyntaxKind; + if (syntaxKindEnum) { + var cached = syntaxKindCache[kind]; + if (cached !== undefined) { + return cached; + } + for (var name in syntaxKindEnum) { + if (syntaxKindEnum[name] === kind) { + var result = kind + " (" + name + ")"; + syntaxKindCache[kind] = result; + return result; + } + } + } + else { + return kind.toString(); + } + } + ts.formatSyntaxKind = formatSyntaxKind; + function getRangePos(range) { + return range ? range.pos : -1; + } + ts.getRangePos = getRangePos; + function getRangeEnd(range) { + return range ? range.end : -1; + } + ts.getRangeEnd = getRangeEnd; + function movePos(pos, value) { + return ts.positionIsSynthesized(pos) ? -1 : pos + value; + } + ts.movePos = movePos; + function createRange(pos, end) { + return { pos: pos, end: end }; + } + ts.createRange = createRange; + function moveRangeEnd(range, end) { + return createRange(range.pos, end); + } + ts.moveRangeEnd = moveRangeEnd; + function moveRangePos(range, pos) { + return createRange(pos, range.end); + } + ts.moveRangePos = moveRangePos; + function moveRangePastDecorators(node) { + return node.decorators && node.decorators.length > 0 + ? moveRangePos(node, node.decorators.end) + : node; + } + ts.moveRangePastDecorators = moveRangePastDecorators; + function moveRangePastModifiers(node) { + return node.modifiers && node.modifiers.length > 0 + ? moveRangePos(node, node.modifiers.end) + : moveRangePastDecorators(node); + } + ts.moveRangePastModifiers = moveRangePastModifiers; + function isCollapsedRange(range) { + return range.pos === range.end; + } + ts.isCollapsedRange = isCollapsedRange; + function collapseRangeToStart(range) { + return isCollapsedRange(range) ? range : moveRangeEnd(range, range.pos); + } + ts.collapseRangeToStart = collapseRangeToStart; + function collapseRangeToEnd(range) { + return isCollapsedRange(range) ? range : moveRangePos(range, range.end); + } + ts.collapseRangeToEnd = collapseRangeToEnd; + function createTokenRange(pos, token) { + return createRange(pos, pos + ts.tokenToString(token).length); + } + ts.createTokenRange = createTokenRange; + function rangeIsOnSingleLine(range, sourceFile) { + return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile); + } + ts.rangeIsOnSingleLine = rangeIsOnSingleLine; + function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) { + return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), getStartPositionOfRange(range2, sourceFile), sourceFile); + } + ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine; + function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) { + return positionsAreOnSameLine(range1.end, range2.end, sourceFile); + } + ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine; + function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) { + return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), range2.end, sourceFile); + } + ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd; + function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) { + return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile), sourceFile); + } + ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart; + function positionsAreOnSameLine(pos1, pos2, sourceFile) { + return pos1 === pos2 || + getLineOfLocalPosition(sourceFile, pos1) === getLineOfLocalPosition(sourceFile, pos2); + } + ts.positionsAreOnSameLine = positionsAreOnSameLine; + function getStartPositionOfRange(range, sourceFile) { + return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); + } + ts.getStartPositionOfRange = getStartPositionOfRange; + function isDeclarationNameOfEnumOrNamespace(node) { + var parseNode = ts.getParseTreeNode(node); + if (parseNode) { + switch (parseNode.parent.kind) { + case 231: + case 232: + return parseNode === parseNode.parent.name; + } + } + return false; + } + ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace; + function getInitializedVariables(node) { + return ts.filter(node.declarations, isInitializedVariable); + } + ts.getInitializedVariables = getInitializedVariables; + function isInitializedVariable(node) { + return node.initializer !== undefined; + } + function isMergedWithClass(node) { + if (node.symbol) { + for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 228 && declaration !== node) { + return true; + } + } + } + return false; + } + ts.isMergedWithClass = isMergedWithClass; + function isFirstDeclarationOfKind(node, kind) { + return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; + } + ts.isFirstDeclarationOfKind = isFirstDeclarationOfKind; + function isNodeArray(array) { + return array.hasOwnProperty("pos") + && array.hasOwnProperty("end"); + } + ts.isNodeArray = isNodeArray; + function isNoSubstitutionTemplateLiteral(node) { + return node.kind === 12; + } + ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; + function isLiteralKind(kind) { + return 8 <= kind && kind <= 12; + } + ts.isLiteralKind = isLiteralKind; + function isTextualLiteralKind(kind) { + return kind === 9 || kind === 12; + } + ts.isTextualLiteralKind = isTextualLiteralKind; + function isLiteralExpression(node) { + return isLiteralKind(node.kind); + } + ts.isLiteralExpression = isLiteralExpression; + function isTemplateLiteralKind(kind) { + return 12 <= kind && kind <= 15; + } + ts.isTemplateLiteralKind = isTemplateLiteralKind; + function isTemplateHead(node) { + return node.kind === 13; + } + ts.isTemplateHead = isTemplateHead; + function isTemplateMiddleOrTemplateTail(node) { + var kind = node.kind; + return kind === 14 + || kind === 15; + } + ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; + function isIdentifier(node) { + return node.kind === 70; + } + ts.isIdentifier = isIdentifier; + function isVoidExpression(node) { + return node.kind === 189; + } + ts.isVoidExpression = isVoidExpression; + function isGeneratedIdentifier(node) { + return isIdentifier(node) && node.autoGenerateKind > 0; + } + ts.isGeneratedIdentifier = isGeneratedIdentifier; + function isModifier(node) { + return isModifierKind(node.kind); + } + ts.isModifier = isModifier; + function isQualifiedName(node) { + return node.kind === 142; + } + ts.isQualifiedName = isQualifiedName; + function isComputedPropertyName(node) { + return node.kind === 143; + } + ts.isComputedPropertyName = isComputedPropertyName; + function isEntityName(node) { + var kind = node.kind; + return kind === 142 + || kind === 70; + } + ts.isEntityName = isEntityName; + function isPropertyName(node) { + var kind = node.kind; + return kind === 70 + || kind === 9 + || kind === 8 + || kind === 143; + } + ts.isPropertyName = isPropertyName; + function isModuleName(node) { + var kind = node.kind; + return kind === 70 + || kind === 9; + } + ts.isModuleName = isModuleName; + function isBindingName(node) { + var kind = node.kind; + return kind === 70 + || kind === 173 + || kind === 174; + } + ts.isBindingName = isBindingName; + function isTypeParameter(node) { + return node.kind === 144; + } + ts.isTypeParameter = isTypeParameter; + function isParameter(node) { + return node.kind === 145; + } + ts.isParameter = isParameter; + function isDecorator(node) { + return node.kind === 146; + } + ts.isDecorator = isDecorator; + function isMethodDeclaration(node) { + return node.kind === 150; + } + ts.isMethodDeclaration = isMethodDeclaration; + function isClassElement(node) { + var kind = node.kind; + return kind === 151 + || kind === 148 + || kind === 150 + || kind === 152 + || kind === 153 + || kind === 156 + || kind === 205; + } + ts.isClassElement = isClassElement; + function isObjectLiteralElementLike(node) { + var kind = node.kind; + return kind === 260 + || kind === 261 + || kind === 262 + || kind === 150 + || kind === 152 + || kind === 153 + || kind === 246; + } + ts.isObjectLiteralElementLike = isObjectLiteralElementLike; + function isTypeNodeKind(kind) { + return (kind >= 157 && kind <= 172) + || kind === 118 + || kind === 132 + || kind === 121 + || kind === 135 + || kind === 136 + || kind === 104 + || kind === 129 + || kind === 200; + } + function isTypeNode(node) { + return isTypeNodeKind(node.kind); + } + ts.isTypeNode = isTypeNode; + function isArrayBindingPattern(node) { + return node.kind === 174; + } + ts.isArrayBindingPattern = isArrayBindingPattern; + function isObjectBindingPattern(node) { + return node.kind === 173; + } + ts.isObjectBindingPattern = isObjectBindingPattern; + function isBindingPattern(node) { + if (node) { + var kind = node.kind; + return kind === 174 + || kind === 173; + } + return false; + } + ts.isBindingPattern = isBindingPattern; + function isAssignmentPattern(node) { + var kind = node.kind; + return kind === 176 + || kind === 177; + } + ts.isAssignmentPattern = isAssignmentPattern; + function isBindingElement(node) { + return node.kind === 175; + } + ts.isBindingElement = isBindingElement; + function isArrayBindingElement(node) { + var kind = node.kind; + return kind === 175 + || kind === 199; + } + ts.isArrayBindingElement = isArrayBindingElement; + function isDeclarationBindingElement(bindingElement) { + switch (bindingElement.kind) { + case 225: + case 145: + case 175: + return true; + } + return false; + } + ts.isDeclarationBindingElement = isDeclarationBindingElement; + function isBindingOrAssignmentPattern(node) { + return isObjectBindingOrAssignmentPattern(node) + || isArrayBindingOrAssignmentPattern(node); + } + ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; + function isObjectBindingOrAssignmentPattern(node) { + switch (node.kind) { + case 173: + case 177: + return true; + } + return false; + } + ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; + function isArrayBindingOrAssignmentPattern(node) { + switch (node.kind) { + case 174: + case 176: + return true; + } + return false; + } + ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; + function isArrayLiteralExpression(node) { + return node.kind === 176; + } + ts.isArrayLiteralExpression = isArrayLiteralExpression; + function isObjectLiteralExpression(node) { + return node.kind === 177; + } + ts.isObjectLiteralExpression = isObjectLiteralExpression; + function isPropertyAccessExpression(node) { + return node.kind === 178; + } + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 179; + } + ts.isElementAccessExpression = isElementAccessExpression; + function isBinaryExpression(node) { + return node.kind === 193; + } + ts.isBinaryExpression = isBinaryExpression; + function isConditionalExpression(node) { + return node.kind === 194; + } + ts.isConditionalExpression = isConditionalExpression; + function isCallExpression(node) { + return node.kind === 180; + } + ts.isCallExpression = isCallExpression; + function isTemplateLiteral(node) { + var kind = node.kind; + return kind === 195 + || kind === 12; + } + ts.isTemplateLiteral = isTemplateLiteral; + function isSpreadExpression(node) { + return node.kind === 197; + } + ts.isSpreadExpression = isSpreadExpression; + function isExpressionWithTypeArguments(node) { + return node.kind === 200; + } + ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; + function isLeftHandSideExpressionKind(kind) { + return kind === 178 + || kind === 179 + || kind === 181 + || kind === 180 + || kind === 248 + || kind === 249 + || kind === 182 + || kind === 176 + || kind === 184 + || kind === 177 + || kind === 198 + || kind === 185 + || kind === 70 + || kind === 11 + || kind === 8 + || kind === 9 + || kind === 12 + || kind === 195 + || kind === 85 + || kind === 94 + || kind === 98 + || kind === 100 + || kind === 96 + || kind === 202 + || kind === 203; + } + function isLeftHandSideExpression(node) { + return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); + } + ts.isLeftHandSideExpression = isLeftHandSideExpression; + function isUnaryExpressionKind(kind) { + return kind === 191 + || kind === 192 + || kind === 187 + || kind === 188 + || kind === 189 + || kind === 190 + || kind === 183 + || isLeftHandSideExpressionKind(kind); + } + function isUnaryExpression(node) { + return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); + } + ts.isUnaryExpression = isUnaryExpression; + function isExpressionKind(kind) { + return kind === 194 + || kind === 196 + || kind === 186 + || kind === 193 + || kind === 197 + || kind === 201 + || kind === 199 + || isUnaryExpressionKind(kind); + } + function isExpression(node) { + return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); + } + ts.isExpression = isExpression; + function isAssertionExpression(node) { + var kind = node.kind; + return kind === 183 + || kind === 201; + } + ts.isAssertionExpression = isAssertionExpression; + function isPartiallyEmittedExpression(node) { + return node.kind === 298; + } + ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; + function isNotEmittedStatement(node) { + return node.kind === 297; + } + ts.isNotEmittedStatement = isNotEmittedStatement; + function isNotEmittedOrPartiallyEmittedNode(node) { + return isNotEmittedStatement(node) + || isPartiallyEmittedExpression(node); + } + ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; + function isOmittedExpression(node) { + return node.kind === 199; + } + ts.isOmittedExpression = isOmittedExpression; + function isTemplateSpan(node) { + return node.kind === 204; + } + ts.isTemplateSpan = isTemplateSpan; + function isBlock(node) { + return node.kind === 206; + } + ts.isBlock = isBlock; + function isConciseBody(node) { + return isBlock(node) + || isExpression(node); + } + ts.isConciseBody = isConciseBody; + function isFunctionBody(node) { + return isBlock(node); + } + ts.isFunctionBody = isFunctionBody; + function isForInitializer(node) { + return isVariableDeclarationList(node) + || isExpression(node); + } + ts.isForInitializer = isForInitializer; + function isVariableDeclaration(node) { + return node.kind === 225; + } + ts.isVariableDeclaration = isVariableDeclaration; + function isVariableDeclarationList(node) { + return node.kind === 226; + } + ts.isVariableDeclarationList = isVariableDeclarationList; + function isCaseBlock(node) { + return node.kind === 234; + } + ts.isCaseBlock = isCaseBlock; + function isModuleBody(node) { + var kind = node.kind; + return kind === 233 + || kind === 232 + || kind === 70; + } + ts.isModuleBody = isModuleBody; + function isNamespaceBody(node) { + var kind = node.kind; + return kind === 233 + || kind === 232; + } + ts.isNamespaceBody = isNamespaceBody; + function isJSDocNamespaceBody(node) { + var kind = node.kind; + return kind === 70 + || kind === 232; + } + ts.isJSDocNamespaceBody = isJSDocNamespaceBody; + function isImportEqualsDeclaration(node) { + return node.kind === 236; + } + ts.isImportEqualsDeclaration = isImportEqualsDeclaration; + function isImportClause(node) { + return node.kind === 238; + } + ts.isImportClause = isImportClause; + function isNamedImportBindings(node) { + var kind = node.kind; + return kind === 240 + || kind === 239; + } + ts.isNamedImportBindings = isNamedImportBindings; + function isImportSpecifier(node) { + return node.kind === 241; + } + ts.isImportSpecifier = isImportSpecifier; + function isNamedExports(node) { + return node.kind === 244; + } + ts.isNamedExports = isNamedExports; + function isExportSpecifier(node) { + return node.kind === 245; + } + ts.isExportSpecifier = isExportSpecifier; + function isModuleOrEnumDeclaration(node) { + return node.kind === 232 || node.kind === 231; + } + ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; + function isDeclarationKind(kind) { + return kind === 186 + || kind === 175 + || kind === 228 + || kind === 198 + || kind === 151 + || kind === 231 + || kind === 263 + || kind === 245 + || kind === 227 + || kind === 185 + || kind === 152 + || kind === 238 + || kind === 236 + || kind === 241 + || kind === 229 + || kind === 252 + || kind === 150 + || kind === 149 + || kind === 232 + || kind === 235 + || kind === 239 + || kind === 145 + || kind === 260 + || kind === 148 + || kind === 147 + || kind === 153 + || kind === 261 + || kind === 230 + || kind === 144 + || kind === 225 + || kind === 289; + } + function isDeclarationStatementKind(kind) { + return kind === 227 + || kind === 246 + || kind === 228 + || kind === 229 + || kind === 230 + || kind === 231 + || kind === 232 + || kind === 237 + || kind === 236 + || kind === 243 + || kind === 242 + || kind === 235; + } + function isStatementKindButNotDeclarationKind(kind) { + return kind === 217 + || kind === 216 + || kind === 224 + || kind === 211 + || kind === 209 + || kind === 208 + || kind === 214 + || kind === 215 + || kind === 213 + || kind === 210 + || kind === 221 + || kind === 218 + || kind === 220 + || kind === 222 + || kind === 223 + || kind === 207 + || kind === 212 + || kind === 219 + || kind === 297 + || kind === 300 + || kind === 299; + } + function isDeclaration(node) { + return isDeclarationKind(node.kind); + } + ts.isDeclaration = isDeclaration; + function isDeclarationStatement(node) { + return isDeclarationStatementKind(node.kind); + } + ts.isDeclarationStatement = isDeclarationStatement; + function isStatementButNotDeclaration(node) { + return isStatementKindButNotDeclarationKind(node.kind); + } + ts.isStatementButNotDeclaration = isStatementButNotDeclaration; + function isStatement(node) { + var kind = node.kind; + return isStatementKindButNotDeclarationKind(kind) + || isDeclarationStatementKind(kind) + || kind === 206; + } + ts.isStatement = isStatement; + function isModuleReference(node) { + var kind = node.kind; + return kind === 247 + || kind === 142 + || kind === 70; + } + ts.isModuleReference = isModuleReference; + function isJsxOpeningElement(node) { + return node.kind === 250; + } + ts.isJsxOpeningElement = isJsxOpeningElement; + function isJsxClosingElement(node) { + return node.kind === 251; + } + ts.isJsxClosingElement = isJsxClosingElement; + function isJsxTagNameExpression(node) { + var kind = node.kind; + return kind === 98 + || kind === 70 + || kind === 178; + } + ts.isJsxTagNameExpression = isJsxTagNameExpression; + function isJsxChild(node) { + var kind = node.kind; + return kind === 248 + || kind === 255 + || kind === 249 + || kind === 10; + } + ts.isJsxChild = isJsxChild; + function isJsxAttributes(node) { + var kind = node.kind; + return kind === 253; + } + ts.isJsxAttributes = isJsxAttributes; + function isJsxAttributeLike(node) { + var kind = node.kind; + return kind === 252 + || kind === 254; + } + ts.isJsxAttributeLike = isJsxAttributeLike; + function isJsxSpreadAttribute(node) { + return node.kind === 254; + } + ts.isJsxSpreadAttribute = isJsxSpreadAttribute; + function isJsxAttribute(node) { + return node.kind === 252; + } + ts.isJsxAttribute = isJsxAttribute; + function isJsxOpeningLikeElement(node) { + return node.kind === 250 || node.kind === 249; + } + ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; + function isStringLiteralOrJsxExpression(node) { + var kind = node.kind; + return kind === 9 + || kind === 255; + } + ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; + function isCaseOrDefaultClause(node) { + var kind = node.kind; + return kind === 256 + || kind === 257; + } + ts.isCaseOrDefaultClause = isCaseOrDefaultClause; + function isHeritageClause(node) { + return node.kind === 258; + } + ts.isHeritageClause = isHeritageClause; + function isCatchClause(node) { + return node.kind === 259; + } + ts.isCatchClause = isCatchClause; + function isPropertyAssignment(node) { + return node.kind === 260; + } + ts.isPropertyAssignment = isPropertyAssignment; + function isShorthandPropertyAssignment(node) { + return node.kind === 261; + } + ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; + function isEnumMember(node) { + return node.kind === 263; + } + ts.isEnumMember = isEnumMember; + function isSourceFile(node) { + return node.kind === 264; + } + ts.isSourceFile = isSourceFile; + function isWatchSet(options) { + return options.watch && options.hasOwnProperty("watch"); + } + ts.isWatchSet = isWatchSet; +})(ts || (ts = {})); +(function (ts) { + function getDefaultLibFileName(options) { + switch (options.target) { + case 5: + case 4: + return "lib.es2017.d.ts"; + case 3: + return "lib.es2016.d.ts"; + case 2: + return "lib.es6.d.ts"; + default: + return "lib.d.ts"; + } + } + ts.getDefaultLibFileName = getDefaultLibFileName; + function textSpanEnd(span) { + 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 === 144) { + for (var current = d; current; current = current.parent) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 229) { + return current; + } + } + } + } + ts.getTypeParameterOwner = getTypeParameterOwner; + function isParameterPropertyDeclaration(node) { + return ts.hasModifier(node, 92) && node.parent.kind === 151 && ts.isClassLike(node.parent.parent); + } + ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; + function walkUpBindingElementsAndPatterns(node) { + while (node && (node.kind === 175 || ts.isBindingPattern(node))) { + node = node.parent; + } + return node; + } + function getCombinedModifierFlags(node) { + node = walkUpBindingElementsAndPatterns(node); + var flags = ts.getModifierFlags(node); + if (node.kind === 225) { + node = node.parent; + } + if (node && node.kind === 226) { + flags |= ts.getModifierFlags(node); + node = node.parent; + } + if (node && node.kind === 207) { + flags |= ts.getModifierFlags(node); + } + return flags; + } + ts.getCombinedModifierFlags = getCombinedModifierFlags; + function getCombinedNodeFlags(node) { + node = walkUpBindingElementsAndPatterns(node); + var flags = node.flags; + if (node.kind === 225) { + node = node.parent; + } + if (node && node.kind === 226) { + flags |= node.flags; + node = node.parent; + } + if (node && node.kind === 207) { + flags |= node.flags; + } + return flags; + } + ts.getCombinedNodeFlags = getCombinedNodeFlags; + function validateLocaleAndSetLanguage(locale, sys, errors) { + var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); + if (!matchResult) { + if (errors) { + 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; + } + var language = matchResult[1]; + var territory = matchResult[3]; + if (!trySetLanguageAndTerritory(language, territory, errors)) { + trySetLanguageAndTerritory(language, undefined, errors); + } + function trySetLanguageAndTerritory(language, territory, errors) { + var compilerFilePath = ts.normalizePath(sys.getExecutingFilePath()); + var containingDirectoryPath = ts.getDirectoryPath(compilerFilePath); + var filePath = ts.combinePaths(containingDirectoryPath, language); + if (territory) { + filePath = filePath + "-" + territory; + } + filePath = sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json")); + if (!sys.fileExists(filePath)) { + return false; + } + var fileContents = ""; + try { + fileContents = sys.readFile(filePath); + } + catch (e) { + if (errors) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, filePath)); + } + return false; + } + try { + ts.localizedDiagnosticMessages = JSON.parse(fileContents); + } + catch (e) { + if (errors) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath)); + } + return false; + } + return true; + } + } + ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage; + function getOriginalNode(node, nodeTest) { + if (node) { + while (node.original !== undefined) { + node = node.original; + } + } + return !nodeTest || nodeTest(node) ? node : undefined; + } + ts.getOriginalNode = getOriginalNode; + function isParseTreeNode(node) { + return (node.flags & 8) === 0; + } + ts.isParseTreeNode = isParseTreeNode; + function getParseTreeNode(node, nodeTest) { + if (isParseTreeNode(node)) { + return node; + } + node = getOriginalNode(node); + if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { + return node; + } + return undefined; + } + ts.getParseTreeNode = getParseTreeNode; + 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; +})(ts || (ts = {})); +var ts; (function (ts) { function tokenIsIdentifierOrKeyword(token) { return token >= 70; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = ts.createMap({ + var textToToken = ts.createMapFromTemplate({ "abstract": 116, "any": 118, "as": 117, @@ -3258,7 +8855,7 @@ var ts; "false": 85, "finally": 86, "for": 87, - "from": 138, + "from": 139, "function": 88, "get": 124, "if": 89, @@ -3276,27 +8873,28 @@ var ts; "new": 93, "null": 94, "number": 132, + "object": 133, "package": 110, "private": 111, "protected": 112, "public": 113, "readonly": 130, "require": 131, - "global": 139, + "global": 140, "return": 95, - "set": 133, + "set": 134, "static": 114, - "string": 134, + "string": 135, "super": 96, "switch": 97, - "symbol": 135, + "symbol": 136, "this": 98, "throw": 99, "true": 100, "try": 101, - "type": 136, + "type": 137, "typeof": 102, - "undefined": 137, + "undefined": 138, "var": 103, "void": 104, "while": 105, @@ -3304,7 +8902,7 @@ var ts; "yield": 115, "async": 119, "await": 120, - "of": 140, + "of": 141, "{": 16, "}": 17, "(": 18, @@ -3399,9 +8997,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var name_4 in source) { - result[source[name_4]] = name_4; - } + source.forEach(function (value, name) { + result[value] = name; + }); return result; } var tokenStrings = makeReverseMap(textToToken); @@ -3410,7 +9008,7 @@ var ts; } ts.tokenToString = tokenToString; function stringToToken(s) { - return textToToken[s]; + return textToToken.get(s); } ts.stringToToken = stringToToken; function computeLineStarts(text) { @@ -3470,7 +9068,6 @@ var ts; return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - var hasOwnProperty = Object.prototype.hasOwnProperty; function isWhiteSpace(ch) { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } @@ -3606,7 +9203,7 @@ var ts; 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++) { + for (var i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -3792,7 +9389,7 @@ var ts; if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { return false; } - for (var i = 1, n = name.length; i < n; i++) { + for (var i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -4129,8 +9726,11 @@ var ts; 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]; + if (ch >= 97 && ch <= 122) { + token = textToToken.get(tokenValue); + if (token !== undefined) { + return token; + } } } return token = 70; @@ -4782,5783 +10382,15 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; - ts.optionDeclarations = [ - { - name: "charset", - type: "string", - }, - ts.compileOnSaveCommandLineOption, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file, - }, - { - name: "declarationDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "diagnostics", - type: "boolean", - }, - { - name: "extendedDiagnostics", - type: "boolean", - experimental: true - }, - { - name: "emitBOM", - type: "boolean" - }, - { - name: "help", - shortName: "h", - type: "boolean", - description: ts.Diagnostics.Print_this_message, - }, - { - name: "help", - shortName: "?", - type: "boolean" - }, - { - name: "init", - type: "boolean", - description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, - }, - { - name: "inlineSourceMap", - type: "boolean", - }, - { - name: "inlineSources", - type: "boolean", - }, - { - name: "jsx", - type: ts.createMap({ - "preserve": 1, - "react": 2 - }), - paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, - }, - { - name: "reactNamespace", - type: "string", - description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit - }, - { - name: "jsxFactory", - type: "string", - description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h - }, - { - name: "listFiles", - type: "boolean", - }, - { - name: "locale", - type: "string", - }, - { - name: "mapRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION, - }, - { - name: "module", - shortName: "m", - type: ts.createMap({ - "none": ts.ModuleKind.None, - "commonjs": ts.ModuleKind.CommonJS, - "amd": ts.ModuleKind.AMD, - "system": ts.ModuleKind.System, - "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES2015, - "es2015": ts.ModuleKind.ES2015, - }), - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND, - }, - { - name: "newLine", - type: ts.createMap({ - "crlf": 0, - "lf": 1 - }), - description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE, - }, - { - name: "noEmit", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs, - }, - { - name: "noEmitHelpers", - type: "boolean" - }, - { - name: "noEmitOnError", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, - }, - { - name: "noErrorTruncation", - type: "boolean" - }, - { - name: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, - }, - { - name: "noImplicitThis", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, - }, - { - name: "noUnusedLocals", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals, - }, - { - name: "noUnusedParameters", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters, - }, - { - name: "noLib", - type: "boolean", - }, - { - name: "noResolve", - type: "boolean", - }, - { - name: "skipDefaultLibCheck", - type: "boolean", - }, - { - name: "skipLibCheck", - type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files, - }, - { - name: "out", - type: "string", - isFilePath: false, - paramType: ts.Diagnostics.FILE, - }, - { - name: "outFile", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE, - }, - { - name: "outDir", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "preserveConstEnums", - type: "boolean", - description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, - { - name: "pretty", - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, - type: "boolean" - }, - { - name: "project", - shortName: "p", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Compile_the_project_in_the_given_directory, - paramType: ts.Diagnostics.DIRECTORY - }, - { - name: "removeComments", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output, - }, - { - name: "rootDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, - }, - { - name: "isolatedModules", - type: "boolean", - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file, - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION, - }, - { - name: "suppressExcessPropertyErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, - experimental: true - }, - { - name: "suppressImplicitAnyIndexErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, - }, - { - name: "stripInternal", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, - experimental: true - }, - { - name: "target", - shortName: "t", - type: ts.createMap({ - "es3": 0, - "es5": 1, - "es6": 2, - "es2015": 2, - "es2016": 3, - "es2017": 4, - "esnext": 5, - }), - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, - paramType: ts.Diagnostics.VERSION, - }, - { - name: "version", - shortName: "v", - type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version, - }, - { - name: "watch", - shortName: "w", - type: "boolean", - description: ts.Diagnostics.Watch_input_files, - }, - { - name: "experimentalDecorators", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators - }, - { - name: "emitDecoratorMetadata", - type: "boolean", - experimental: true, - description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators - }, - { - name: "moduleResolution", - type: ts.createMap({ - "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic, - }), - description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY, - }, - { - name: "allowUnusedLabels", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unused_labels - }, - { - name: "noImplicitReturns", - type: "boolean", - description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value - }, - { - name: "noFallthroughCasesInSwitch", - type: "boolean", - description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement - }, - { - name: "allowUnreachableCode", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code - }, - { - name: "forceConsistentCasingInFileNames", - type: "boolean", - description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, - { - name: "baseUrl", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names - }, - { - name: "paths", - type: "object", - isTSConfigOnly: true - }, - { - name: "rootDirs", - type: "list", - isTSConfigOnly: true, - element: { - name: "rootDirs", - type: "string", - isFilePath: true - } - }, - { - name: "typeRoots", - type: "list", - element: { - name: "typeRoots", - type: "string", - isFilePath: true - } - }, - { - name: "types", - type: "list", - element: { - name: "types", - type: "string" - }, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation - }, - { - name: "traceResolution", - type: "boolean", - description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process - }, - { - name: "allowJs", - type: "boolean", - description: ts.Diagnostics.Allow_javascript_files_to_be_compiled - }, - { - name: "allowSyntheticDefaultImports", - type: "boolean", - description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking - }, - { - name: "noImplicitUseStrict", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output - }, - { - name: "maxNodeModuleJsDepth", - type: "number", - description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files - }, - { - name: "listEmittedFiles", - type: "boolean" - }, - { - name: "lib", - type: "list", - element: { - name: "lib", - type: ts.createMap({ - "es5": "lib.es5.d.ts", - "es6": "lib.es2015.d.ts", - "es2015": "lib.es2015.d.ts", - "es7": "lib.es2016.d.ts", - "es2016": "lib.es2016.d.ts", - "es2017": "lib.es2017.d.ts", - "dom": "lib.dom.d.ts", - "dom.iterable": "lib.dom.iterable.d.ts", - "webworker": "lib.webworker.d.ts", - "scripthost": "lib.scripthost.d.ts", - "es2015.core": "lib.es2015.core.d.ts", - "es2015.collection": "lib.es2015.collection.d.ts", - "es2015.generator": "lib.es2015.generator.d.ts", - "es2015.iterable": "lib.es2015.iterable.d.ts", - "es2015.promise": "lib.es2015.promise.d.ts", - "es2015.proxy": "lib.es2015.proxy.d.ts", - "es2015.reflect": "lib.es2015.reflect.d.ts", - "es2015.symbol": "lib.es2015.symbol.d.ts", - "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", - "es2016.array.include": "lib.es2016.array.include.d.ts", - "es2017.object": "lib.es2017.object.d.ts", - "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", - "es2017.string": "lib.es2017.string.d.ts", - }), - }, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon - }, - { - name: "disableSizeLimit", - type: "boolean" - }, - { - name: "strictNullChecks", - type: "boolean", - description: ts.Diagnostics.Enable_strict_null_checks - }, - { - name: "importHelpers", - type: "boolean", - description: ts.Diagnostics.Import_emit_helpers_from_tslib - }, - { - name: "alwaysStrict", - type: "boolean", - description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file - } - ]; - ts.typeAcquisitionDeclarations = [ - { - name: "enableAutoDiscovery", - type: "boolean", - }, - { - name: "enable", - type: "boolean", - }, - { - name: "include", - type: "list", - element: { - name: "include", - type: "string" - } - }, - { - name: "exclude", - type: "list", - element: { - name: "exclude", - type: "string" - } - } - ]; - ts.defaultInitCompilerOptions = { - module: ts.ModuleKind.CommonJS, - target: 1, - noImplicitAny: false, - sourceMap: false, - }; - var optionNameMapCache; - function convertEnableAutoDiscoveryToEnable(typeAcquisition) { - if (typeAcquisition && typeAcquisition.enableAutoDiscovery !== undefined && typeAcquisition.enable === undefined) { - var result = { - enable: typeAcquisition.enableAutoDiscovery, - include: typeAcquisition.include || [], - exclude: typeAcquisition.exclude || [] - }; - return result; - } - return typeAcquisition; - } - ts.convertEnableAutoDiscoveryToEnable = convertEnableAutoDiscoveryToEnable; - function getOptionNameMap() { - if (optionNameMapCache) { - return optionNameMapCache; - } - var optionNameMap = ts.createMap(); - var shortOptionNames = ts.createMap(); - ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; - if (option.shortName) { - shortOptionNames[option.shortName] = option.name; - } - }); - optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; - return optionNameMapCache; - } - ts.getOptionNameMap = getOptionNameMap; - function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); - return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); - } - ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; - function parseCustomTypeOption(opt, value, errors) { - return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors); - } - ts.parseCustomTypeOption = parseCustomTypeOption; - function parseListTypeOption(opt, value, errors) { - if (value === void 0) { value = ""; } - value = trimString(value); - if (ts.startsWith(value, "-")) { - return undefined; - } - if (value === "") { - return []; - } - var values = value.split(","); - switch (opt.element.type) { - case "number": - return ts.map(values, parseInt); - case "string": - return ts.map(values, function (v) { return v || ""; }); - default: - return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); - } - } - ts.parseListTypeOption = parseListTypeOption; - function parseCommandLine(commandLine, readFile) { - var options = {}; - var fileNames = []; - var errors = []; - var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; - parseStrings(commandLine); - return { - options: options, - fileNames: fileNames, - errors: errors - }; - function parseStrings(args) { - var i = 0; - while (i < args.length) { - var s = args[i]; - i++; - if (s.charCodeAt(0) === 64) { - parseResponseFile(s.slice(1)); - } - else if (s.charCodeAt(0) === 45) { - s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); - if (s in shortOptionNames) { - s = shortOptionNames[s]; - } - if (s in optionNameMap) { - var opt = optionNameMap[s]; - if (opt.isTSConfigOnly) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); - } - else { - if (!args[i] && opt.type !== "boolean") { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); - } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i]); - i++; - break; - case "boolean": - var optValue = args[i]; - options[opt.name] = optValue !== "false"; - if (optValue === "false" || optValue === "true") { - i++; - } - break; - case "string": - options[opt.name] = args[i] || ""; - i++; - break; - case "list": - var result = parseListTypeOption(opt, args[i], errors); - options[opt.name] = result || []; - if (result) { - i++; - } - break; - default: - options[opt.name] = parseCustomTypeOption(opt, args[i], errors); - i++; - break; - } - } - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s)); - } - } - else { - fileNames.push(s); - } - } - } - function parseResponseFile(fileName) { - var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); - if (!text) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); - return; - } - var args = []; - var pos = 0; - while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32) - pos++; - if (pos >= text.length) - break; - var start = pos; - if (text.charCodeAt(start) === 34) { - pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34) - pos++; - if (pos < text.length) { - args.push(text.substring(start + 1, pos)); - pos++; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName)); - } - } - else { - while (text.charCodeAt(pos) > 32) - pos++; - args.push(text.substring(start, pos)); - } - } - parseStrings(args); - } - } - ts.parseCommandLine = parseCommandLine; - function readConfigFile(fileName, readFile) { - var text = ""; - try { - text = readFile(fileName); - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; - } - return parseConfigFileTextToJson(fileName, text); - } - ts.readConfigFile = readConfigFile; - function parseConfigFileTextToJson(fileName, jsonText, stripComments) { - if (stripComments === void 0) { stripComments = true; } - try { - var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; - return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; - } - } - ts.parseConfigFileTextToJson = parseConfigFileTextToJson; - function generateTSConfig(options, fileNames) { - var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); - var configurations = { - compilerOptions: serializeCompilerOptions(compilerOptions) - }; - if (fileNames && fileNames.length) { - configurations.files = fileNames; - } - return configurations; - function getCustomTypeMapOfCommandLineOption(optionDefinition) { - if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { - return undefined; - } - else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); - } - else { - return optionDefinition.type; - } - } - function getNameOfCompilerOptionValue(value, customTypeMap) { - for (var key in customTypeMap) { - if (customTypeMap[key] === value) { - return key; - } - } - return undefined; - } - function serializeCompilerOptions(options) { - var result = ts.createMap(); - var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_5 in options) { - if (ts.hasProperty(options, name_5)) { - switch (name_5) { - case "init": - case "watch": - case "version": - case "help": - case "project": - break; - default: - var value = options[name_5]; - var optionDefinition = optionsNameMap[name_5.toLowerCase()]; - if (optionDefinition) { - var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap) { - result[name_5] = value; - } - else { - if (optionDefinition.type === "list") { - var convertedValue = []; - for (var _i = 0, _a = value; _i < _a.length; _i++) { - var element = _a[_i]; - convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); - } - result[name_5] = convertedValue; - } - else { - result[name_5] = getNameOfCompilerOptionValue(value, customTypeMap); - } - } - } - break; - } - } - } - return result; - } - } - ts.generateTSConfig = generateTSConfig; - function removeComments(jsonText) { - var output = ""; - var scanner = ts.createScanner(1, false, 0, jsonText); - var token; - while ((token = scanner.scan()) !== 1) { - switch (token) { - case 2: - case 3: - output += scanner.getTokenText().replace(/\S/g, " "); - break; - default: - output += scanner.getTokenText(); - break; - } - } - return output; - } - function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions) { - if (existingOptions === void 0) { existingOptions = {}; } - if (resolutionStack === void 0) { resolutionStack = []; } - if (extraFileExtensions === void 0) { extraFileExtensions = []; } - var errors = []; - var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); - if (resolutionStack.indexOf(resolvedPath) >= 0) { - return { - options: {}, - fileNames: [], - typeAcquisition: {}, - raw: json, - errors: [ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))], - wildcardDirectories: {} - }; - } - var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); - var jsonOptions = json["typeAcquisition"] || json["typingOptions"]; - var typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); - if (json["extends"]) { - var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; - if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); - } - if (include && !json["include"]) { - json["include"] = include; - } - if (exclude && !json["exclude"]) { - json["exclude"] = exclude; - } - if (files && !json["files"]) { - json["files"] = files; - } - options = ts.assign({}, baseOptions, options); - } - options = ts.extend(existingOptions, options); - options.configFilePath = configFileName; - var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; - var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); - return { - options: options, - fileNames: fileNames, - typeAcquisition: typeAcquisition, - raw: json, - errors: errors, - wildcardDirectories: wildcardDirectories, - compileOnSave: compileOnSave - }; - function tryExtendsName(extendedConfig) { - if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig)); - return; - } - var extendedConfigPath = ts.toPath(extendedConfig, basePath, getCanonicalFileName); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { - extendedConfigPath = extendedConfigPath + ".json"; - if (!host.fileExists(extendedConfigPath)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); - return; - } - } - var extendedResult = readConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); - if (extendedResult.error) { - errors.push(extendedResult.error); - return; - } - var extendedDirname = ts.getDirectoryPath(extendedConfigPath); - var relativeDifference = ts.convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); - var updatePath = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference, path); }; - var result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, undefined, ts.getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath])); - errors.push.apply(errors, result.errors); - var _a = ts.map(["include", "exclude", "files"], function (key) { - if (!json[key] && extendedResult.config[key]) { - return ts.map(extendedResult.config[key], updatePath); - } - }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; - } - function getFileNames(errors) { - var fileNames; - if (ts.hasProperty(json, "files")) { - if (ts.isArray(json["files"])) { - fileNames = json["files"]; - if (fileNames.length === 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json")); - } - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); - } - } - var includeSpecs; - if (ts.hasProperty(json, "include")) { - if (ts.isArray(json["include"])) { - includeSpecs = json["include"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array")); - } - } - var excludeSpecs; - if (ts.hasProperty(json, "exclude")) { - if (ts.isArray(json["exclude"])) { - excludeSpecs = json["exclude"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array")); - } - } - else if (ts.hasProperty(json, "excludes")) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); - } - else { - excludeSpecs = includeSpecs ? [] : ["node_modules", "bower_components", "jspm_packages"]; - var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; - if (outDir) { - excludeSpecs.push(outDir); - } - } - if (fileNames === undefined && includeSpecs === undefined) { - includeSpecs = ["**/*"]; - } - var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions); - if (result.fileNames.length === 0 && !ts.hasProperty(json, "files") && resolutionStack.length === 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, configFileName || "tsconfig.json", JSON.stringify(includeSpecs || []), JSON.stringify(excludeSpecs || []))); - } - return result; - } - var _b; - } - ts.parseJsonConfigFileContent = parseJsonConfigFileContent; - function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { - if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { - return false; - } - var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); - if (typeof result === "boolean" && result) { - return result; - } - return false; - } - ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; - function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { - var errors = []; - var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); - return { options: options, errors: errors }; - } - ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; - function convertTypeAcquisitionFromJson(jsonOptions, basePath, configFileName) { - var errors = []; - var options = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); - return { options: options, errors: errors }; - } - ts.convertTypeAcquisitionFromJson = convertTypeAcquisitionFromJson; - function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } - : {}; - convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); - return options; - } - function convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = { enable: ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; - var typeAcquisition = convertEnableAutoDiscoveryToEnable(jsonOptions); - convertOptionsFromJson(ts.typeAcquisitionDeclarations, typeAcquisition, basePath, options, ts.Diagnostics.Unknown_type_acquisition_option_0, errors); - return options; - } - function convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, defaultOptions, diagnosticMessage, errors) { - if (!jsonOptions) { - return; - } - var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); - for (var id in jsonOptions) { - if (id in optionNameMap) { - var opt = optionNameMap[id]; - defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); - } - else { - errors.push(ts.createCompilerDiagnostic(diagnosticMessage, id)); - } - } - } - function convertJsonOption(opt, value, basePath, errors) { - var optType = opt.type; - var expectedType = typeof optType === "string" ? optType : "string"; - if (optType === "list" && ts.isArray(value)) { - return convertJsonOptionOfListType(opt, value, basePath, errors); - } - else if (typeof value === expectedType) { - if (typeof optType !== "string") { - return convertJsonOptionOfCustomType(opt, value, errors); - } - else { - if (opt.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); - if (value === "") { - value = "."; - } - } - } - return value; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType)); - } - } - function convertJsonOptionOfCustomType(opt, value, errors) { - var key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; - } - else { - errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); - } - } - function convertJsonOptionOfListType(option, values, basePath, errors) { - return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); - } - function trimString(s) { - return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); - } - var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; - var invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/; - var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; - var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; - var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/; - function matchFileNames(fileNames, include, exclude, basePath, options, host, errors, extraFileExtensions) { - basePath = ts.normalizePath(basePath); - var keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper; - var literalFileMap = ts.createMap(); - var wildcardFileMap = ts.createMap(); - if (include) { - include = validateSpecs(include, errors, false); - } - if (exclude) { - exclude = validateSpecs(exclude, errors, true); - } - var wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); - var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions); - if (fileNames) { - for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { - var fileName = fileNames_1[_i]; - var file = ts.combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; - } - } - if (include && include.length > 0) { - for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, exclude, include); _a < _b.length; _a++) { - var file = _b[_a]; - if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) { - continue; - } - removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); - var key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; - } - } - } - var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); - var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); - return { - fileNames: literalFiles.concat(wildcardFiles), - wildcardDirectories: wildcardDirectories - }; - } - function validateSpecs(specs, errors, allowTrailingRecursion) { - var validSpecs = []; - for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { - var spec = specs_2[_i]; - if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidMultipleRecursionPatterns.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else { - validSpecs.push(spec); - } - } - return validSpecs; - } - function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { - var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); - var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - var wildcardDirectories = ts.createMap(); - if (include !== undefined) { - var recursiveKeys = []; - for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { - var file = include_1[_i]; - var spec = ts.normalizePath(ts.combinePaths(path, file)); - if (excludeRegex && excludeRegex.test(spec)) { - continue; - } - var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames); - if (match) { - var key = match.key, flags = match.flags; - var existingFlags = wildcardDirectories[key]; - if (existingFlags === undefined || existingFlags < flags) { - wildcardDirectories[key] = flags; - if (flags === 1) { - recursiveKeys.push(key); - } - } - } - } - for (var key in wildcardDirectories) { - for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { - var recursiveKey = recursiveKeys_1[_a]; - if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; - } - } - } - } - return wildcardDirectories; - } - function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) { - var match = wildcardDirectoryPattern.exec(spec); - if (match) { - return { - key: useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(), - flags: watchRecursivePattern.test(spec) ? 1 : 0 - }; - } - if (ts.isImplicitGlob(spec)) { - return { key: spec, flags: 1 }; - } - return undefined; - } - function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { - var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); - for (var i = 0; i < adjustedExtensionPriority; i++) { - var higherPriorityExtension = extensions[i]; - var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { - return true; - } - } - return false; - } - function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { - var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); - for (var i = nextExtensionPriority; i < extensions.length; i++) { - var lowerPriorityExtension = extensions[i]; - var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; - } - } - function addFileToOutput(output, file) { - output.push(file); - return output; - } - function caseSensitiveKeyMapper(key) { - return key; - } - function caseInsensitiveKeyMapper(key) { - return key.toLowerCase(); - } -})(ts || (ts = {})); -var ts; -(function (ts) { - var JsTyping; - (function (JsTyping) { - ; - ; - var safeList; - var EmptySafeList = ts.createMap(); - JsTyping.nodeCoreModuleList = [ - "buffer", "querystring", "events", "http", "cluster", - "zlib", "os", "https", "punycode", "repl", "readline", - "vm", "child_process", "url", "dns", "net", - "dgram", "fs", "path", "string_decoder", "tls", - "crypto", "stream", "util", "assert", "tty", "domain", - "constants", "process", "v8", "timers", "console" - ]; - var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typeAcquisition, unresolvedImports) { - var inferredTypings = ts.createMap(); - if (!typeAcquisition || !typeAcquisition.enable) { - return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; - } - fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { - var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); - return kind === 1 || kind === 2; - }); - if (!safeList) { - var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); - safeList = result.config ? ts.createMap(result.config) : EmptySafeList; - } - var filesToWatch = []; - var searchDirs = []; - var exclude = []; - mergeTypings(typeAcquisition.include); - exclude = typeAcquisition.exclude || []; - var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); - if (projectRootPath) { - possibleSearchDirs.push(projectRootPath); - } - searchDirs = ts.deduplicate(possibleSearchDirs); - for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { - var searchDir = searchDirs_1[_i]; - var packageJsonPath = ts.combinePaths(searchDir, "package.json"); - getTypingNamesFromJson(packageJsonPath, filesToWatch); - var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); - getTypingNamesFromJson(bowerJsonPath, filesToWatch); - var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); - getTypingNamesFromNodeModuleFolder(nodeModulesPath); - } - getTypingNamesFromSourceFileNames(fileNames); - if (unresolvedImports) { - for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { - var moduleId = unresolvedImports_1[_a]; - var typingName = moduleId in nodeCoreModules ? "node" : moduleId; - if (!(typingName in inferredTypings)) { - inferredTypings[typingName] = undefined; - } - } - } - for (var name_6 in packageNameToTypingLocation) { - if (name_6 in inferredTypings && !inferredTypings[name_6]) { - inferredTypings[name_6] = packageNameToTypingLocation[name_6]; - } - } - for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { - var excludeTypingName = exclude_1[_b]; - delete inferredTypings[excludeTypingName]; - } - var newTypingNames = []; - var cachedTypingPaths = []; - for (var typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); - } - else { - newTypingNames.push(typing); - } - } - return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; - function mergeTypings(typingNames) { - if (!typingNames) { - return; - } - for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { - var typing = typingNames_1[_i]; - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; - } - } - } - function getTypingNamesFromJson(jsonPath, filesToWatch) { - if (host.fileExists(jsonPath)) { - filesToWatch.push(jsonPath); - } - var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); - if (result.config) { - var jsonConfig = result.config; - if (jsonConfig.dependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); - } - if (jsonConfig.devDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); - } - if (jsonConfig.optionalDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); - } - if (jsonConfig.peerDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); - } - } - } - function getTypingNamesFromSourceFileNames(fileNames) { - var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); - var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); - var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); - if (safeList !== EmptySafeList) { - mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); - } - var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); - if (hasJsxFile) { - mergeTypings(["react"]); - } - } - function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { - if (!host.directoryExists(nodeModulesPath)) { - return; - } - var typingNames = []; - var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); - for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { - var fileName = fileNames_2[_i]; - var normalizedFileName = ts.normalizePath(fileName); - if (ts.getBaseFileName(normalizedFileName) !== "package.json") { - continue; - } - var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); - if (!result.config) { - continue; - } - var packageJson = result.config; - if (packageJson._requiredBy && - ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { - continue; - } - if (!packageJson.name) { - continue; - } - if (packageJson.typings) { - var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; - } - else { - typingNames.push(packageJson.name); - } - } - mergeTypings(typingNames); - } - } - JsTyping.discoverTypings = discoverTypings; - })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - server.ActionSet = "action::set"; - server.ActionInvalidate = "action::invalidate"; - server.EventBeginInstallTypes = "event::beginInstallTypes"; - server.EventEndInstallTypes = "event::endInstallTypes"; - var Arguments; - (function (Arguments) { - Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation"; - Arguments.LogFile = "--logFile"; - Arguments.EnableTelemetry = "--enableTelemetry"; - })(Arguments = server.Arguments || (server.Arguments = {})); - function hasArgument(argumentName) { - return ts.sys.args.indexOf(argumentName) >= 0; - } - server.hasArgument = hasArgument; - function findArgument(argumentName) { - var index = ts.sys.args.indexOf(argumentName); - return index >= 0 && index < ts.sys.args.length - 1 - ? ts.sys.args[index + 1] - : undefined; - } - server.findArgument = findArgument; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - var LogLevel; - (function (LogLevel) { - LogLevel[LogLevel["terse"] = 0] = "terse"; - LogLevel[LogLevel["normal"] = 1] = "normal"; - LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; - LogLevel[LogLevel["verbose"] = 3] = "verbose"; - })(LogLevel = server.LogLevel || (server.LogLevel = {})); - server.emptyArray = []; - var Msg; - (function (Msg) { - Msg.Err = "Err"; - Msg.Info = "Info"; - Msg.Perf = "Perf"; - })(Msg = server.Msg || (server.Msg = {})); - function getProjectRootPath(project) { - switch (project.projectKind) { - case server.ProjectKind.Configured: - return ts.getDirectoryPath(project.getProjectName()); - case server.ProjectKind.Inferred: - return ""; - case server.ProjectKind.External: - var projectName = ts.normalizeSlashes(project.getProjectName()); - return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; - } - } - function createInstallTypingsRequest(project, typeAcquisition, unresolvedImports, cachePath) { - return { - projectName: project.getProjectName(), - fileNames: project.getFileNames(true), - compilerOptions: project.getCompilerOptions(), - typeAcquisition: typeAcquisition, - unresolvedImports: unresolvedImports, - projectRootPath: getProjectRootPath(project), - cachePath: cachePath, - kind: "discover" - }; - } - server.createInstallTypingsRequest = createInstallTypingsRequest; - var Errors; - (function (Errors) { - function ThrowNoProject() { - throw new Error("No Project."); - } - Errors.ThrowNoProject = ThrowNoProject; - function ThrowProjectLanguageServiceDisabled() { - throw new Error("The project's language service is disabled."); - } - Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; - function ThrowProjectDoesNotContainDocument(fileName, project) { - throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); - } - Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; - })(Errors = server.Errors || (server.Errors = {})); - function getDefaultFormatCodeSettings(host) { - return { - indentSize: 4, - tabSize: 4, - newLineCharacter: host.newLine || "\n", - convertTabsToSpaces: true, - indentStyle: ts.IndentStyle.Smart, - insertSpaceAfterCommaDelimiter: true, - insertSpaceAfterSemicolonInForStatements: true, - insertSpaceBeforeAndAfterBinaryOperators: true, - insertSpaceAfterKeywordsInControlFlowStatements: true, - insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, - placeOpenBraceOnNewLineForFunctions: false, - placeOpenBraceOnNewLineForControlBlocks: false, - }; - } - server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; - function mergeMaps(target, source) { - for (var key in source) { - if (ts.hasProperty(source, key)) { - target[key] = source[key]; - } - } - } - server.mergeMaps = mergeMaps; - function removeItemFromSet(items, itemToRemove) { - if (items.length === 0) { - return; - } - var index = items.indexOf(itemToRemove); - if (index < 0) { - return; - } - if (index === items.length - 1) { - items.pop(); - } - else { - items[index] = items.pop(); - } - } - server.removeItemFromSet = removeItemFromSet; - function toNormalizedPath(fileName) { - return ts.normalizePath(fileName); - } - server.toNormalizedPath = toNormalizedPath; - function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { - var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); - return getCanonicalFileName(f); - } - server.normalizedPathToPath = normalizedPathToPath; - function asNormalizedPath(fileName) { - return fileName; - } - server.asNormalizedPath = asNormalizedPath; - function createNormalizedPathMap() { - var map = Object.create(null); - return { - get: function (path) { - return map[path]; - }, - set: function (path, value) { - map[path] = value; - }, - contains: function (path) { - return ts.hasProperty(map, path); - }, - remove: function (path) { - delete map[path]; - } - }; - } - server.createNormalizedPathMap = createNormalizedPathMap; - function isInferredProjectName(name) { - return /dev\/null\/inferredProject\d+\*/.test(name); - } - server.isInferredProjectName = isInferredProjectName; - function makeInferredProjectName(counter) { - return "/dev/null/inferredProject" + counter + "*"; - } - server.makeInferredProjectName = makeInferredProjectName; - function toSortedReadonlyArray(arr) { - arr.sort(); - return arr; - } - server.toSortedReadonlyArray = toSortedReadonlyArray; - var ThrottledOperations = (function () { - function ThrottledOperations(host) { - this.host = host; - this.pendingTimeouts = ts.createMap(); - } - ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { - if (ts.hasProperty(this.pendingTimeouts, operationId)) { - this.host.clearTimeout(this.pendingTimeouts[operationId]); - } - this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); - }; - ThrottledOperations.run = function (self, operationId, cb) { - delete self.pendingTimeouts[operationId]; - cb(); - }; - return ThrottledOperations; - }()); - server.ThrottledOperations = ThrottledOperations; - var GcTimer = (function () { - function GcTimer(host, delay, logger) { - this.host = host; - this.delay = delay; - this.logger = logger; - } - GcTimer.prototype.scheduleCollect = function () { - if (!this.host.gc || this.timerId != undefined) { - return; - } - this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); - }; - GcTimer.run = function (self) { - self.timerId = undefined; - var log = self.logger.hasLevel(LogLevel.requestTime); - var before = log && self.host.getMemoryUsage(); - self.host.gc(); - if (log) { - var after = self.host.getMemoryUsage(); - self.logger.perftrc("GC::before " + before + ", after " + after); - } - }; - return GcTimer; - }()); - server.GcTimer = GcTimer; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - function trace(host) { - host.trace(ts.formatMessage.apply(undefined, arguments)); - } - ts.trace = trace; - function isTraceEnabled(compilerOptions, host) { - return compilerOptions.traceResolution && host.trace !== undefined; - } - ts.isTraceEnabled = isTraceEnabled; - function resolvedTypeScriptOnly(resolved) { - if (!resolved) { - return undefined; - } - ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); - return resolved.path; - } - function resolvedFromAnyFile(path) { - return { path: path, extension: ts.extensionFromPath(path) }; - } - function resolvedModuleFromResolved(_a, isExternalLibraryImport) { - var path = _a.path, extension = _a.extension; - return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; - } - function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { - return { resolvedModule: resolved && resolvedModuleFromResolved(resolved, isExternalLibraryImport), failedLookupLocations: failedLookupLocations }; - } - function moduleHasNonRelativeName(moduleName) { - return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); - } - ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { - var jsonContent = readJson(packageJsonPath, state.host); - switch (extensions) { - case 2: - case 0: - return tryReadFromField("typings") || tryReadFromField("types"); - case 1: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; - } - function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); - } - return typesFilePath; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } - } - } - } - } - function readJson(path, host) { - try { - var jsonText = host.readFile(path); - return jsonText ? JSON.parse(jsonText) : {}; - } - catch (e) { - return {}; - } - } - function getEffectiveTypeRoots(options, host) { - if (options.typeRoots) { - return options.typeRoots; - } - var currentDirectory; - if (options.configFilePath) { - currentDirectory = ts.getDirectoryPath(options.configFilePath); - } - else if (host.getCurrentDirectory) { - currentDirectory = host.getCurrentDirectory(); - } - if (currentDirectory !== undefined) { - return getDefaultTypeRoots(currentDirectory, host); - } - } - ts.getEffectiveTypeRoots = getEffectiveTypeRoots; - function getDefaultTypeRoots(currentDirectory, host) { - if (!host.directoryExists) { - return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; - } - var typeRoots; - forEachAncestorDirectory(currentDirectory, function (directory) { - var atTypes = ts.combinePaths(directory, nodeModulesAtTypes); - if (host.directoryExists(atTypes)) { - (typeRoots || (typeRoots = [])).push(atTypes); - } - }); - return typeRoots; - } - var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { - var traceEnabled = isTraceEnabled(options, host); - var moduleResolutionState = { - compilerOptions: options, - host: host, - traceEnabled: traceEnabled - }; - var typeRoots = getEffectiveTypeRoots(options, host); - if (traceEnabled) { - if (containingFile === undefined) { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); - } - } - else { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); - } - } - } - var failedLookupLocations = []; - var resolved = primaryLookup(); - var primary = true; - if (!resolved) { - resolved = secondaryLookup(); - primary = false; - } - var resolvedTypeReferenceDirective; - if (resolved) { - resolved = realpath(resolved, host, traceEnabled); - if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); - } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved }; - } - return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; - function primaryLookup() { - if (typeRoots && typeRoots.length) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); - } - return ts.forEach(typeRoots, function (typeRoot) { - var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); - var candidateDirectory = ts.getDirectoryPath(candidate); - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); - }); - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); - } - } - } - function secondaryLookup() { - var resolvedFile; - var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile); - if (initialLocationForSecondaryLookup !== undefined) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); - } - resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); - if (!resolvedFile && traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); - } - return resolvedFile; - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); - } - } - } - } - ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; - function getAutomaticTypeDirectiveNames(options, host) { - if (options.types) { - return options.types; - } - var result = []; - if (host.directoryExists && host.getDirectories) { - var typeRoots = getEffectiveTypeRoots(options, host); - if (typeRoots) { - for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { - var root = typeRoots_1[_i]; - if (host.directoryExists(root)) { - for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { - var typeDirectivePath = _b[_a]; - var normalized = ts.normalizePath(typeDirectivePath); - var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); - var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; - if (!isNotNeededPackage) { - result.push(ts.getBaseFileName(normalized)); - } - } - } - } - } - } - return result; - } - ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); - } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; - if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); - } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; - } - if (traceEnabled) { - if (result.resolvedModule) { - trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); - } - else { - trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); - } - } - return result; - } - ts.resolveModuleName = resolveModuleName; - function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { - if (moduleHasNonRelativeName(moduleName)) { - return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state); - } - else { - return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); - } - } - function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { - if (!state.compilerOptions.rootDirs) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); - } - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var matchedRootDir; - var matchedNormalizedPrefix; - for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { - var rootDir = _a[_i]; - var normalizedRoot = ts.normalizePath(rootDir); - if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { - normalizedRoot += ts.directorySeparator; - } - var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && - (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); - } - if (isLongestMatchingPrefix) { - matchedNormalizedPrefix = normalizedRoot; - matchedRootDir = rootDir; - } - } - if (matchedNormalizedPrefix) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); - } - var suffix = candidate.substr(matchedNormalizedPrefix.length); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); - } - var resolvedFileName = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); - if (resolvedFileName) { - return resolvedFileName; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); - } - for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { - var rootDir = _c[_b]; - if (rootDir === matchedRootDir) { - continue; - } - var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); - } - var baseDirectory = ts.getDirectoryPath(candidate_1); - var resolvedFileName_1 = loader(extensions, candidate_1, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); - if (resolvedFileName_1) { - return resolvedFileName_1; - } - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); - } - } - return undefined; - } - function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state) { - if (!state.compilerOptions.baseUrl) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); - } - var matchedPattern = undefined; - if (state.compilerOptions.paths) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); - } - matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); - } - if (matchedPattern) { - var matchedStar_1 = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); - var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); - } - return ts.forEach(state.compilerOptions.paths[matchedPatternText], function (subst) { - var path = matchedStar_1 ? subst.replace("*", matchedStar_1) : subst; - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); - } - var tsExtension = ts.tryGetExtensionFromPath(candidate); - if (tsExtension !== undefined) { - var path_1 = tryFile(candidate, failedLookupLocations, false, state); - return path_1 && { path: path_1, extension: tsExtension }; - } - return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - }); - } - else { - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); - } - return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - } - } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { - var containingDirectory = ts.getDirectoryPath(containingFile); - var traceEnabled = isTraceEnabled(compilerOptions, host); - var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(0) || tryResolve(1); - if (result) { - var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; - return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); - } - return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - function tryResolve(extensions) { - var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); - if (resolved) { - return { resolved: resolved, isExternalLibraryImport: false }; - } - if (moduleHasNonRelativeName(moduleName)) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); - } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); - return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); - return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; - } - } - } - ts.nodeModuleNameResolver = nodeModuleNameResolver; - function realpath(path, host, traceEnabled) { - if (!host.realpath) { - return path; - } - var real = ts.normalizePath(host.realpath(path)); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); - } - return real; - } - function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); - } - var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - } - function directoryProbablyExists(directoryName, host) { - return !host.directoryExists || host.directoryExists(directoryName); - } - ts.directoryProbablyExists = directoryProbablyExists; - function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { - var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); - if (resolvedByAddingExtension) { - return resolvedByAddingExtension; - } - if (ts.hasJavaScriptFileExtension(candidate)) { - var extensionless = ts.removeFileExtension(candidate); - if (state.traceEnabled) { - var extension = candidate.substring(extensionless.length); - trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); - } - return tryAddingExtensions(extensionless, extensions, failedLookupLocations, onlyRecordFailures, state); - } - } - function tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures) { - var directory = ts.getDirectoryPath(candidate); - if (directory) { - onlyRecordFailures = !directoryProbablyExists(directory, state.host); - } - } - switch (extensions) { - case 2: - return tryExtension(".d.ts", ts.Extension.Dts); - case 0: - return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case 1: - return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); - } - function tryExtension(ext, extension) { - var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); - return path && { path: path, extension: extension }; - } - } - function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); - } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); - } - failedLookupLocations.push(fileName); - return undefined; - } - } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromFile) { - return resolvedFromAnyFile(fromFile); - } - var x = tryAddingExtensions(typesFile, 0, failedLookupLocations, onlyRecordFailures_1, state); - if (x) { - return x; - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); - } - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - failedLookupLocations.push(packageJsonPath); - } - return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); - } - function pathToPackageJson(directory) { - return ts.combinePaths(directory, "package.json"); - } - function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); - var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || - loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); - } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false); - } - function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(2, moduleName, directory, failedLookupLocations, state, true); - } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { - return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { - if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); - } - }); - } - function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { - if (typesOnly === void 0) { typesOnly = false; } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); - if (packageResult) { - return packageResult; - } - if (extensions !== 1) { - return loadModuleFromNodeModulesFolder(2, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); - } - } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var failedLookupLocations = []; - var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(0) || tryResolve(1); - return createResolvedModuleWithFailedLookupLocations(resolved, false, failedLookupLocations); - function tryResolve(extensions) { - var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); - if (resolvedUsingSettings) { - return resolvedUsingSettings; - } - if (moduleHasNonRelativeName(moduleName)) { - var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { - var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state); - }); - if (resolved_3) { - return resolved_3; - } - if (extensions === 0) { - return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); - } - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state); - } - } - } - ts.classicNameResolver = classicNameResolver; - function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - if (traceEnabled) { - trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); - } - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(2, moduleName, globalCache, failedLookupLocations, state); - return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); - } - ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; - function forEachAncestorDirectory(directory, callback) { - while (true) { - var result = callback(directory); - if (result !== undefined) { - return result; - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory) { - return undefined; - } - directory = parentPath; - } - } -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.externalHelpersModuleNameText = "tslib"; - function getDeclarationOfKind(symbol, kind) { - var declarations = symbol.declarations; - if (declarations) { - for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { - var declaration = declarations_1[_i]; - if (declaration.kind === kind) { - return declaration; - } - } - } - return undefined; - } - ts.getDeclarationOfKind = getDeclarationOfKind; - var stringWriters = []; - function getSingleLineStringWriter() { - if (stringWriters.length === 0) { - var str_1 = ""; - var writeText = function (text) { return str_1 += text; }; - return { - string: function () { return str_1; }, - writeKeyword: writeText, - writeOperator: writeText, - writePunctuation: writeText, - writeSpace: writeText, - writeStringLiteral: writeText, - writeParameter: writeText, - writeProperty: writeText, - writeSymbol: writeText, - writeLine: function () { return str_1 += " "; }, - increaseIndent: ts.noop, - decreaseIndent: ts.noop, - clear: function () { return str_1 = ""; }, - trackSymbol: ts.noop, - reportInaccessibleThisError: ts.noop - }; - } - 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 hasResolvedModule(sourceFile, moduleNameText) { - return !!(sourceFile && sourceFile.resolvedModules && 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 = ts.createMap(); - } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; - } - ts.setResolvedModule = setResolvedModule; - function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { - if (!sourceFile.resolvedTypeReferenceDirectiveNames) { - sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); - } - sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; - } - ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; - function moduleResolutionIsEqualTo(oldResolution, newResolution) { - return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && - oldResolution.extension === newResolution.extension && - oldResolution.resolvedFileName === newResolution.resolvedFileName; - } - ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; - function typeDirectiveIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; - } - ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; - function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { - if (names.length !== newResolutions.length) { - return false; - } - for (var i = 0; i < names.length; i++) { - var newResolution = newResolutions[i]; - var oldResolution = oldResolutions && oldResolutions[names[i]]; - var changed = oldResolution - ? !newResolution || !comparer(oldResolution, newResolution) - : newResolution; - if (changed) { - return true; - } - } - return false; - } - ts.hasChangesInResolutions = hasChangesInResolutions; - function containsParseError(node) { - aggregateChildData(node); - return (node.flags & 131072) !== 0; - } - ts.containsParseError = containsParseError; - function aggregateChildData(node) { - if (!(node.flags & 262144)) { - var thisNodeOrAnySubNodesHasError = ((node.flags & 32768) !== 0) || - ts.forEachChild(node, containsParseError); - if (thisNodeOrAnySubNodesHasError) { - node.flags |= 131072; - } - node.flags |= 262144; - } - } - function getSourceFileOfNode(node) { - while (node && node.kind !== 261) { - node = node.parent; - } - return node; - } - ts.getSourceFileOfNode = getSourceFileOfNode; - function isStatementWithLocals(node) { - switch (node.kind) { - case 204: - case 232: - case 211: - case 212: - case 213: - return true; - } - return false; - } - ts.isStatementWithLocals = isStatementWithLocals; - 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 isDefined(value) { - return value !== undefined; - } - ts.isDefined = isDefined; - function getEndLinePosition(line, sourceFile) { - ts.Debug.assert(line >= 0); - var lineStarts = ts.getLineStarts(sourceFile); - var lineIndex = line; - var sourceText = sourceFile.text; - if (lineIndex + 1 === lineStarts.length) { - return sourceText.length - 1; - } - else { - var start = lineStarts[lineIndex]; - var pos = lineStarts[lineIndex + 1] - 1; - ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos))); - while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) { - pos--; - } - return pos; - } - } - ts.getEndLinePosition = getEndLinePosition; - function nodeIsMissing(node) { - if (node === undefined) { - 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, includeJsDoc) { - if (nodeIsMissing(node)) { - return node.pos; - } - if (isJSDocNode(node)) { - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true); - } - if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { - return getTokenPosOfNode(node.jsDoc[0]); - } - if (node.kind === 292 && node._children.length > 0) { - return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); - } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); - } - ts.getTokenPosOfNode = getTokenPosOfNode; - function isJSDocNode(node) { - return node.kind >= 262 && node.kind <= 288; - } - ts.isJSDocNode = isJSDocNode; - function isJSDocTag(node) { - return node.kind >= 278 && node.kind <= 291; - } - ts.isJSDocTag = isJSDocTag; - 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 getLiteralText(node, sourceFile, languageVersion) { - if (languageVersion < 2 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); - } - if (!nodeIsSynthesized(node) && node.parent) { - var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); - if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { - return node.text; - } - return text; - } - switch (node.kind) { - case 9: - return getQuotedEscapedLiteralText('"', node.text, '"'); - case 12: - return getQuotedEscapedLiteralText("`", node.text, "`"); - case 13: - return getQuotedEscapedLiteralText("`", node.text, "${"); - case 14: - return getQuotedEscapedLiteralText("}", node.text, "${"); - case 15: - return getQuotedEscapedLiteralText("}", node.text, "`"); - case 8: - return node.text; - } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); - } - ts.getLiteralText = getLiteralText; - 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; - } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; - function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { - return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; - } - 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 (ts.getCombinedNodeFlags(declaration) & 3) !== 0 || - isCatchClauseVariableDeclarationOrBindingElement(declaration); - } - ts.isBlockOrCatchScoped = isBlockOrCatchScoped; - function isCatchClauseVariableDeclarationOrBindingElement(declaration) { - var node = getRootDeclaration(declaration); - return node.kind === 223 && node.parent.kind === 256; - } - ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; - function isAmbientModule(node) { - return node && node.kind === 230 && - (node.name.kind === 9 || isGlobalScopeAugmentation(node)); - } - ts.isAmbientModule = isAmbientModule; - function isShorthandAmbientModuleSymbol(moduleSymbol) { - return isShorthandAmbientModule(moduleSymbol.valueDeclaration); - } - ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; - function isShorthandAmbientModule(node) { - return node.kind === 230 && (!node.body); - } - function isBlockScopedContainerTopLevel(node) { - return node.kind === 261 || - node.kind === 230 || - isFunctionLike(node); - } - ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; - function isGlobalScopeAugmentation(module) { - return !!(module.flags & 512); - } - ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; - function isExternalModuleAugmentation(node) { - if (!node || !isAmbientModule(node)) { - return false; - } - switch (node.parent.kind) { - case 261: - return ts.isExternalModule(node.parent); - case 231: - return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); - } - return false; - } - ts.isExternalModuleAugmentation = isExternalModuleAugmentation; - function isEffectiveExternalModule(node, compilerOptions) { - return ts.isExternalModule(node) || compilerOptions.isolatedModules; - } - ts.isEffectiveExternalModule = isEffectiveExternalModule; - function isBlockScope(node, parentNode) { - switch (node.kind) { - case 261: - case 232: - case 256: - case 230: - case 211: - case 212: - case 213: - case 150: - case 149: - case 151: - case 152: - case 225: - case 184: - case 185: - return true; - case 204: - return parentNode && !isFunctionLike(parentNode); - } - return false; - } - ts.isBlockScope = isBlockScope; - function getEnclosingBlockScopeContainer(node) { - var current = node.parent; - while (current) { - if (isBlockScope(current, current.parent)) { - return current; - } - current = current.parent; - } - } - ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; - function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); - } - ts.declarationNameToString = declarationNameToString; - function getTextOfPropertyName(name) { - switch (name.kind) { - case 70: - return name.text; - case 9: - case 8: - return name.text; - case 142: - if (isStringOrNumericLiteral(name.expression)) { - return name.expression.text; - } - } - return undefined; - } - ts.getTextOfPropertyName = getTextOfPropertyName; - function entityNameToString(name) { - switch (name.kind) { - case 70: - return getFullWidth(name) === 0 ? unescapeIdentifier(name.text) : getTextOfNode(name); - case 141: - return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 177: - return entityNameToString(name.expression) + "." + entityNameToString(name.name); - } - } - ts.entityNameToString = entityNameToString; - function createDiagnosticForNode(node, message, arg0, arg1, arg2) { - var sourceFile = getSourceFileOfNode(node); - return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2); - } - ts.createDiagnosticForNode = createDiagnosticForNode; - function createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2) { - var span = getErrorSpanForNode(sourceFile, node); - return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); - } - ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile; - 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 getErrorSpanForArrowFunction(sourceFile, node) { - var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 204) { - var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; - var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; - if (startLine < endLine) { - return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1); - } - } - return ts.createTextSpanFromBounds(pos, node.end); - } - function getErrorSpanForNode(sourceFile, node) { - var errorNode = node; - switch (node.kind) { - case 261: - 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 223: - case 174: - case 226: - case 197: - case 227: - case 230: - case 229: - case 260: - case 225: - case 184: - case 149: - case 151: - case 152: - case 228: - errorNode = node.name; - break; - case 185: - return getErrorSpanForArrowFunction(sourceFile, node); - } - 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 isExternalOrCommonJsModule(file) { - return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; - } - ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; - function isDeclarationFile(file) { - return file.isDeclarationFile; - } - ts.isDeclarationFile = isDeclarationFile; - function isConstEnumDeclaration(node) { - return node.kind === 229 && isConst(node); - } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function isConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2) - || !!(ts.getCombinedModifierFlags(node) & 2048); - } - ts.isConst = isConst; - function isLet(node) { - return !!(ts.getCombinedNodeFlags(node) & 1); - } - ts.isLet = isLet; - function isSuperCall(n) { - return n.kind === 179 && n.expression.kind === 96; - } - ts.isSuperCall = isSuperCall; - function isPrologueDirective(node) { - return node.kind === 207 - && node.expression.kind === 9; - } - ts.isPrologueDirective = isPrologueDirective; - function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } - ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; - function getLeadingCommentRangesOfNodeFromText(node, text) { - return ts.getLeadingCommentRanges(text, node.pos); - } - ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; - function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 144 || - node.kind === 143 || - node.kind === 184 || - node.kind === 185) ? - ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : - getLeadingCommentRangesOfNodeFromText(node, text); - return ts.filter(commentRanges, function (comment) { - return text.charCodeAt(comment.pos + 1) === 42 && - text.charCodeAt(comment.pos + 2) === 42 && - text.charCodeAt(comment.pos + 3) !== 47; - }); - } - ts.getJSDocCommentRanges = getJSDocCommentRanges; - ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; - function isPartOfTypeNode(node) { - if (156 <= node.kind && node.kind <= 171) { - return true; - } - switch (node.kind) { - case 118: - case 132: - case 134: - case 121: - case 135: - case 137: - case 129: - return true; - case 104: - return node.parent.kind !== 188; - case 199: - return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 70: - if (node.parent.kind === 141 && node.parent.right === node) { - node = node.parent; - } - else if (node.parent.kind === 177 && node.parent.name === node) { - node = node.parent; - } - ts.Debug.assert(node.kind === 70 || node.kind === 141 || node.kind === 177, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 141: - case 177: - case 98: - var parent_1 = node.parent; - if (parent_1.kind === 160) { - return false; - } - if (156 <= parent_1.kind && parent_1.kind <= 171) { - return true; - } - switch (parent_1.kind) { - case 199: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 143: - return node === parent_1.constraint; - case 147: - case 146: - case 144: - case 223: - return node === parent_1.type; - case 225: - case 184: - case 185: - case 150: - case 149: - case 148: - case 151: - case 152: - return node === parent_1.type; - case 153: - case 154: - case 155: - return node === parent_1.type; - case 182: - return node === parent_1.type; - case 179: - case 180: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 181: - return false; - } - } - return false; - } - ts.isPartOfTypeNode = isPartOfTypeNode; - function forEachReturnStatement(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 216: - return visitor(node); - case 232: - case 204: - case 208: - case 209: - case 210: - case 211: - case 212: - case 213: - case 217: - case 218: - case 253: - case 254: - case 219: - case 221: - case 256: - return ts.forEachChild(node, traverse); - } - } - } - ts.forEachReturnStatement = forEachReturnStatement; - function forEachYieldExpression(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 195: - visitor(node); - var operand = node.expression; - if (operand) { - traverse(operand); - } - case 229: - case 227: - case 230: - case 228: - case 226: - case 197: - return; - default: - if (isFunctionLike(node)) { - var name_7 = node.name; - if (name_7 && name_7.kind === 142) { - traverse(name_7.expression); - return; - } - } - else if (!isPartOfTypeNode(node)) { - ts.forEachChild(node, traverse); - } - } - } - } - ts.forEachYieldExpression = forEachYieldExpression; - function getRestParameterElementType(node) { - if (node && node.kind === 162) { - return node.elementType; - } - else if (node && node.kind === 157) { - return ts.singleOrUndefined(node.typeArguments); - } - else { - return undefined; - } - } - ts.getRestParameterElementType = getRestParameterElementType; - function isVariableLike(node) { - if (node) { - switch (node.kind) { - case 174: - case 260: - case 144: - case 257: - case 147: - case 146: - case 258: - case 223: - return true; - } - } - return false; - } - ts.isVariableLike = isVariableLike; - function isAccessor(node) { - return node && (node.kind === 151 || node.kind === 152); - } - ts.isAccessor = isAccessor; - function isClassLike(node) { - return node && (node.kind === 226 || node.kind === 197); - } - ts.isClassLike = isClassLike; - function isFunctionLike(node) { - return node && isFunctionLikeKind(node.kind); - } - ts.isFunctionLike = isFunctionLike; - function isFunctionLikeKind(kind) { - switch (kind) { - case 150: - case 184: - case 225: - case 185: - case 149: - case 148: - case 151: - case 152: - case 153: - case 154: - case 155: - case 158: - case 159: - return true; - } - return false; - } - ts.isFunctionLikeKind = isFunctionLikeKind; - function introducesArgumentsExoticObject(node) { - switch (node.kind) { - case 149: - case 148: - case 150: - case 151: - case 152: - case 225: - case 184: - return true; - } - return false; - } - ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; - function isIterationStatement(node, lookInLabeledStatements) { - switch (node.kind) { - case 211: - case 212: - case 213: - case 209: - case 210: - return true; - case 219: - return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); - } - return false; - } - ts.isIterationStatement = isIterationStatement; - function isFunctionBlock(node) { - return node && node.kind === 204 && isFunctionLike(node.parent); - } - ts.isFunctionBlock = isFunctionBlock; - function isObjectLiteralMethod(node) { - return node && node.kind === 149 && node.parent.kind === 176; - } - ts.isObjectLiteralMethod = isObjectLiteralMethod; - function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 149 && - (node.parent.kind === 176 || - node.parent.kind === 197); - } - ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; - function isIdentifierTypePredicate(predicate) { - return predicate && predicate.kind === 1; - } - ts.isIdentifierTypePredicate = isIdentifierTypePredicate; - function isThisTypePredicate(predicate) { - return predicate && predicate.kind === 0; - } - ts.isThisTypePredicate = isThisTypePredicate; - 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 142: - if (isClassLike(node.parent.parent)) { - return node; - } - node = node.parent; - break; - case 145: - if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - node = node.parent; - } - break; - case 185: - if (!includeArrowFunctions) { - continue; - } - case 225: - case 184: - case 230: - case 147: - case 146: - case 149: - case 148: - case 150: - case 151: - case 152: - case 153: - case 154: - case 155: - case 229: - case 261: - return node; - } - } - } - ts.getThisContainer = getThisContainer; - function getSuperContainer(node, stopOnFunctions) { - while (true) { - node = node.parent; - if (!node) { - return node; - } - switch (node.kind) { - case 142: - node = node.parent; - break; - case 225: - case 184: - case 185: - if (!stopOnFunctions) { - continue; - } - case 147: - case 146: - case 149: - case 148: - case 150: - case 151: - case 152: - return node; - case 145: - if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - node = node.parent; - } - break; - } - } - } - ts.getSuperContainer = getSuperContainer; - function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 184 || func.kind === 185) { - var prev = func; - var parent_2 = func.parent; - while (parent_2.kind === 183) { - prev = parent_2; - parent_2 = parent_2.parent; - } - if (parent_2.kind === 179 && parent_2.expression === prev) { - return parent_2; - } - } - } - ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; - function isSuperProperty(node) { - var kind = node.kind; - return (kind === 177 || kind === 178) - && node.expression.kind === 96; - } - ts.isSuperProperty = isSuperProperty; - function getEntityNameFromTypeNode(node) { - switch (node.kind) { - case 157: - case 272: - return node.typeName; - case 199: - return isEntityNameExpression(node.expression) - ? node.expression - : undefined; - case 70: - case 141: - return node; - } - return undefined; - } - ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; - function isCallLikeExpression(node) { - switch (node.kind) { - case 179: - case 180: - case 181: - case 145: - return true; - default: - return false; - } - } - ts.isCallLikeExpression = isCallLikeExpression; - function getInvokedExpression(node) { - if (node.kind === 181) { - return node.tag; - } - return node.expression; - } - ts.getInvokedExpression = getInvokedExpression; - function nodeCanBeDecorated(node) { - switch (node.kind) { - case 226: - return true; - case 147: - return node.parent.kind === 226; - case 151: - case 152: - case 149: - return node.body !== undefined - && node.parent.kind === 226; - case 144: - return node.parent.body !== undefined - && (node.parent.kind === 150 - || node.parent.kind === 149 - || node.parent.kind === 152) - && node.parent.parent.kind === 226; - } - return false; - } - ts.nodeCanBeDecorated = nodeCanBeDecorated; - function nodeIsDecorated(node) { - return node.decorators !== undefined - && nodeCanBeDecorated(node); - } - ts.nodeIsDecorated = nodeIsDecorated; - function nodeOrChildIsDecorated(node) { - return nodeIsDecorated(node) || childIsDecorated(node); - } - ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; - function childIsDecorated(node) { - switch (node.kind) { - case 226: - return ts.forEach(node.members, nodeOrChildIsDecorated); - case 149: - case 152: - return ts.forEach(node.parameters, nodeIsDecorated); - } - } - ts.childIsDecorated = childIsDecorated; - function isJSXTagName(node) { - var parent = node.parent; - if (parent.kind === 248 || - parent.kind === 247 || - parent.kind === 249) { - return parent.tagName === node; - } - return false; - } - ts.isJSXTagName = isJSXTagName; - function isPartOfExpression(node) { - switch (node.kind) { - case 98: - case 96: - case 94: - case 100: - case 85: - case 11: - case 175: - case 176: - case 177: - case 178: - case 179: - case 180: - case 181: - case 200: - case 182: - case 201: - case 183: - case 184: - case 197: - case 185: - case 188: - case 186: - case 187: - case 190: - case 191: - case 192: - case 193: - case 196: - case 194: - case 12: - case 198: - case 246: - case 247: - case 195: - case 189: - return true; - case 141: - while (node.parent.kind === 141) { - node = node.parent; - } - return node.parent.kind === 160 || isJSXTagName(node); - case 70: - if (node.parent.kind === 160 || isJSXTagName(node)) { - return true; - } - case 8: - case 9: - case 98: - var parent_3 = node.parent; - switch (parent_3.kind) { - case 223: - case 144: - case 147: - case 146: - case 260: - case 257: - case 174: - return parent_3.initializer === node; - case 207: - case 208: - case 209: - case 210: - case 216: - case 217: - case 218: - case 253: - case 220: - case 218: - return parent_3.expression === node; - case 211: - var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 224) || - forStatement.condition === node || - forStatement.incrementor === node; - case 212: - case 213: - var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224) || - forInStatement.expression === node; - case 182: - case 200: - return node === parent_3.expression; - case 202: - return node === parent_3.expression; - case 142: - return node === parent_3.expression; - case 145: - case 252: - case 251: - case 259: - return true; - case 199: - return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); - default: - if (isPartOfExpression(parent_3)) { - return true; - } - } - } - return false; - } - ts.isPartOfExpression = isPartOfExpression; - function isInstantiatedModule(node, preserveConstEnums) { - var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 || - (preserveConstEnums && moduleState === 2); - } - ts.isInstantiatedModule = isInstantiatedModule; - function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 && node.moduleReference.kind === 245; - } - ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; - function getExternalModuleImportEqualsDeclarationExpression(node) { - ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); - return node.moduleReference.expression; - } - ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; - function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 && node.moduleReference.kind !== 245; - } - ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; - function isSourceFileJavaScript(file) { - return isInJavaScriptFile(file); - } - ts.isSourceFileJavaScript = isSourceFileJavaScript; - function isInJavaScriptFile(node) { - return node && !!(node.flags & 65536); - } - ts.isInJavaScriptFile = isInJavaScriptFile; - function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 179 && - expression.expression.kind === 70 && - expression.expression.text === "require" && - expression.arguments.length === 1; - return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); - } - ts.isRequireCall = isRequireCall; - function isSingleOrDoubleQuote(charCode) { - return charCode === 39 || charCode === 34; - } - ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; - function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 223) { - var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 184; - } - return false; - } - ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression; - function getSpecialPropertyAssignmentKind(expression) { - if (!isInJavaScriptFile(expression)) { - return 0; - } - if (expression.kind !== 192) { - return 0; - } - var expr = expression; - if (expr.operatorToken.kind !== 57 || expr.left.kind !== 177) { - return 0; - } - var lhs = expr.left; - if (lhs.expression.kind === 70) { - var lhsId = lhs.expression; - if (lhsId.text === "exports") { - return 1; - } - else if (lhsId.text === "module" && lhs.name.text === "exports") { - return 2; - } - } - else if (lhs.expression.kind === 98) { - return 4; - } - else if (lhs.expression.kind === 177) { - var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 70) { - var innerPropertyAccessIdentifier = innerPropertyAccess.expression; - if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { - return 1; - } - if (innerPropertyAccess.name.text === "prototype") { - return 3; - } - } - } - return 0; - } - ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; - function getExternalModuleName(node) { - if (node.kind === 235) { - return node.moduleSpecifier; - } - if (node.kind === 234) { - var reference = node.moduleReference; - if (reference.kind === 245) { - return reference.expression; - } - } - if (node.kind === 241) { - return node.moduleSpecifier; - } - if (node.kind === 230 && node.name.kind === 9) { - return node.name; - } - } - ts.getExternalModuleName = getExternalModuleName; - function getNamespaceDeclarationNode(node) { - if (node.kind === 234) { - return node; - } - var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237) { - return importClause.namedBindings; - } - } - ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; - function isDefaultImport(node) { - return node.kind === 235 - && node.importClause - && !!node.importClause.name; - } - ts.isDefaultImport = isDefaultImport; - function hasQuestionToken(node) { - if (node) { - switch (node.kind) { - case 144: - case 149: - case 148: - case 258: - case 257: - case 147: - case 146: - return node.questionToken !== undefined; - } - } - return false; - } - ts.hasQuestionToken = hasQuestionToken; - function isJSDocConstructSignature(node) { - return node.kind === 274 && - node.parameters.length > 0 && - node.parameters[0].type.kind === 276; - } - ts.isJSDocConstructSignature = isJSDocConstructSignature; - function getCommentsFromJSDoc(node) { - return ts.map(getJSDocs(node), function (doc) { return doc.comment; }); - } - ts.getCommentsFromJSDoc = getCommentsFromJSDoc; - function getJSDocTags(node, kind) { - var docs = getJSDocs(node); - if (docs) { - var result = []; - for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { - var doc = docs_1[_i]; - if (doc.kind === 281) { - if (doc.kind === kind) { - result.push(doc); - } - } - else { - result.push.apply(result, ts.filter(doc.tags, function (tag) { return tag.kind === kind; })); - } - } - return result; - } - } - function getFirstJSDocTag(node, kind) { - return node && ts.firstOrUndefined(getJSDocTags(node, kind)); - } - function getJSDocs(node) { - var cache = node.jsDocCache; - if (!cache) { - getJSDocsWorker(node); - node.jsDocCache = cache; - } - return cache; - function getJSDocsWorker(node) { - var parent = node.parent; - var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && - parent.initializer === node && - parent.parent.parent.kind === 205; - var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 205; - var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : - isVariableOfVariableDeclarationStatement ? parent.parent : - undefined; - if (variableStatementNode) { - getJSDocsWorker(variableStatementNode); - } - var isSourceOfAssignmentExpressionStatement = parent && parent.parent && - parent.kind === 192 && - parent.operatorToken.kind === 57 && - parent.parent.kind === 207; - if (isSourceOfAssignmentExpressionStatement) { - getJSDocsWorker(parent.parent); - } - var isModuleDeclaration = node.kind === 230 && - parent && parent.kind === 230; - var isPropertyAssignmentExpression = parent && parent.kind === 257; - if (isModuleDeclaration || isPropertyAssignmentExpression) { - getJSDocsWorker(parent); - } - if (node.kind === 144) { - cache = ts.concatenate(cache, getJSDocParameterTags(node)); - } - if (isVariableLike(node) && node.initializer) { - cache = ts.concatenate(cache, node.initializer.jsDoc); - } - cache = ts.concatenate(cache, node.jsDoc); - } - } - function getJSDocParameterTags(param) { - if (!isParameter(param)) { - return undefined; - } - var func = param.parent; - var tags = getJSDocTags(func, 281); - if (!param.name) { - var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 281; }); - if (paramTags && 0 <= i && i < paramTags.length) { - return [paramTags[i]]; - } - } - else if (param.name.kind === 70) { - var name_8 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 281 && tag.parameterName.text === name_8; }); - } - else { - return undefined; - } - } - ts.getJSDocParameterTags = getJSDocParameterTags; - function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 283); - if (!tag && node.kind === 144) { - var paramTags = getJSDocParameterTags(node); - if (paramTags) { - tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); - } - } - return tag && tag.typeExpression && tag.typeExpression.type; - } - ts.getJSDocType = getJSDocType; - function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 280); - } - ts.getJSDocAugmentsTag = getJSDocAugmentsTag; - function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 282); - } - ts.getJSDocReturnTag = getJSDocReturnTag; - function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 284); - } - ts.getJSDocTemplateTag = getJSDocTemplateTag; - function hasRestParameter(s) { - return isRestParameter(ts.lastOrUndefined(s.parameters)); - } - ts.hasRestParameter = hasRestParameter; - function hasDeclaredRestParameter(s) { - return isDeclaredRestParam(ts.lastOrUndefined(s.parameters)); - } - ts.hasDeclaredRestParameter = hasDeclaredRestParameter; - function isRestParameter(node) { - if (node && (node.flags & 65536)) { - if (node.type && node.type.kind === 275 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275; })) { - return true; - } - } - return isDeclaredRestParam(node); - } - ts.isRestParameter = isRestParameter; - function isDeclaredRestParam(node) { - return node && node.dotDotDotToken !== undefined; - } - ts.isDeclaredRestParam = isDeclaredRestParam; - function getAssignmentTargetKind(node) { - var parent = node.parent; - while (true) { - switch (parent.kind) { - case 192: - var binaryOperator = parent.operatorToken.kind; - return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 57 ? 1 : 2 : - 0; - case 190: - case 191: - var unaryOperator = parent.operator; - return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; - case 212: - case 213: - return parent.initializer === node ? 1 : 0; - case 183: - case 175: - case 196: - node = parent; - break; - case 258: - if (parent.name !== node) { - return 0; - } - case 257: - node = parent.parent; - break; - default: - return 0; - } - parent = node.parent; - } - } - ts.getAssignmentTargetKind = getAssignmentTargetKind; - function isAssignmentTarget(node) { - return getAssignmentTargetKind(node) !== 0; - } - ts.isAssignmentTarget = isAssignmentTarget; - function isNodeDescendantOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } - ts.isNodeDescendantOf = isNodeDescendantOf; - function isInAmbientContext(node) { - while (node) { - if (hasModifier(node, 2) || (node.kind === 261 && node.isDeclarationFile)) { - return true; - } - node = node.parent; - } - return false; - } - ts.isInAmbientContext = isInAmbientContext; - function isDeclarationName(name) { - if (name.kind !== 70 && name.kind !== 9 && name.kind !== 8) { - return false; - } - var parent = name.parent; - if (parent.kind === 239 || parent.kind === 243) { - if (parent.propertyName) { - return true; - } - } - if (isDeclaration(parent)) { - return parent.name === name; - } - return false; - } - ts.isDeclarationName = isDeclarationName; - function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 142 && - isDeclaration(node.parent.parent); - } - ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; - function isIdentifierName(node) { - var parent = node.parent; - switch (parent.kind) { - case 147: - case 146: - case 149: - case 148: - case 151: - case 152: - case 260: - case 257: - case 177: - return parent.name === node; - case 141: - if (parent.right === node) { - while (parent.kind === 141) { - parent = parent.parent; - } - return parent.kind === 160; - } - return false; - case 174: - case 239: - return parent.propertyName === node; - case 243: - return true; - } - return false; - } - ts.isIdentifierName = isIdentifierName; - function isAliasSymbolDeclaration(node) { - return node.kind === 234 || - node.kind === 233 || - node.kind === 236 && !!node.name || - node.kind === 237 || - node.kind === 239 || - node.kind === 243 || - node.kind === 240 && exportAssignmentIsAlias(node); - } - ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function exportAssignmentIsAlias(node) { - return isEntityNameExpression(node.expression); - } - ts.exportAssignmentIsAlias = exportAssignmentIsAlias; - function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 84); - return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; - } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; - function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 107); - return heritageClause ? heritageClause.types : undefined; - } - ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; - function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 84); - return heritageClause ? heritageClause.types : undefined; - } - ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; - function getHeritageClause(clauses, kind) { - if (clauses) { - for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { - var clause = clauses_1[_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); - 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.test(comment)) { - if (isNoDefaultLibRegEx.test(comment)) { - return { - isNoDefaultLib: true - }; - } - else { - var refMatchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); - var refLibResult = !refMatchResult && ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); - if (refMatchResult || refLibResult) { - var start = commentRange.pos; - var end = commentRange.end; - return { - fileReference: { - pos: start, - end: end, - fileName: (refMatchResult || refLibResult)[3] - }, - isNoDefaultLib: false, - isTypeReferenceDirective: !!refLibResult - }; - } - return { - diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, - isNoDefaultLib: false - }; - } - } - return undefined; - } - ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; - function isKeyword(token) { - return 71 <= token && token <= 140; - } - ts.isKeyword = isKeyword; - function isTrivia(token) { - return 2 <= token && token <= 7; - } - ts.isTrivia = isTrivia; - function isAsyncFunctionLike(node) { - return isFunctionLike(node) && hasModifier(node, 256) && !isAccessor(node); - } - ts.isAsyncFunctionLike = isAsyncFunctionLike; - function isStringOrNumericLiteral(node) { - var kind = node.kind; - return kind === 9 - || kind === 8; - } - ts.isStringOrNumericLiteral = isStringOrNumericLiteral; - function hasDynamicName(declaration) { - return declaration.name && isDynamicName(declaration.name); - } - ts.hasDynamicName = hasDynamicName; - function isDynamicName(name) { - return name.kind === 142 && - !isStringOrNumericLiteral(name.expression) && - !isWellKnownSymbolSyntactically(name.expression); - } - ts.isDynamicName = isDynamicName; - function isWellKnownSymbolSyntactically(node) { - return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); - } - ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; - function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 144) { - return name.text; - } - if (name.kind === 142) { - var nameExpression = name.expression; - if (isWellKnownSymbolSyntactically(nameExpression)) { - var rightHandSideName = nameExpression.name.text; - return getPropertyNameForKnownSymbolName(rightHandSideName); - } - else if (nameExpression.kind === 9 || nameExpression.kind === 8) { - return nameExpression.text; - } - } - return undefined; - } - ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; - function getPropertyNameForKnownSymbolName(symbolName) { - return "__@" + symbolName; - } - ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; - function isESSymbolIdentifier(node) { - return node.kind === 70 && node.text === "Symbol"; - } - ts.isESSymbolIdentifier = isESSymbolIdentifier; - function isPushOrUnshiftIdentifier(node) { - return node.text === "push" || node.text === "unshift"; - } - ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; - function isModifierKind(token) { - switch (token) { - case 116: - case 119: - case 75: - case 123: - case 78: - case 83: - case 113: - case 111: - case 112: - case 130: - case 114: - return true; - } - return false; - } - ts.isModifierKind = isModifierKind; - function isParameterDeclaration(node) { - var root = getRootDeclaration(node); - return root.kind === 144; - } - ts.isParameterDeclaration = isParameterDeclaration; - function getRootDeclaration(node) { - while (node.kind === 174) { - node = node.parent.parent; - } - return node; - } - ts.getRootDeclaration = getRootDeclaration; - function nodeStartsNewLexicalEnvironment(node) { - var kind = node.kind; - return kind === 150 - || kind === 184 - || kind === 225 - || kind === 185 - || kind === 149 - || kind === 151 - || kind === 152 - || kind === 230 - || kind === 261; - } - ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; - function nodeIsSynthesized(node) { - return ts.positionIsSynthesized(node.pos) - || ts.positionIsSynthesized(node.end); - } - ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node, nodeTest) { - if (node) { - while (node.original !== undefined) { - node = node.original; - } - } - return !nodeTest || nodeTest(node) ? node : undefined; - } - ts.getOriginalNode = getOriginalNode; - function isParseTreeNode(node) { - return (node.flags & 8) === 0; - } - ts.isParseTreeNode = isParseTreeNode; - function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { - return node; - } - node = getOriginalNode(node); - if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { - return node; - } - return undefined; - } - ts.getParseTreeNode = getParseTreeNode; - function getOriginalSourceFiles(sourceFiles) { - var originalSourceFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); - if (originalSourceFile) { - originalSourceFiles.push(originalSourceFile); - } - } - return originalSourceFiles; - } - ts.getOriginalSourceFiles = getOriginalSourceFiles; - function getOriginalNodeId(node) { - node = getOriginalNode(node); - return node ? ts.getNodeId(node) : 0; - } - ts.getOriginalNodeId = getOriginalNodeId; - function getExpressionAssociativity(expression) { - var operator = getOperator(expression); - var hasArguments = expression.kind === 180 && expression.arguments !== undefined; - return getOperatorAssociativity(expression.kind, operator, hasArguments); - } - ts.getExpressionAssociativity = getExpressionAssociativity; - function getOperatorAssociativity(kind, operator, hasArguments) { - switch (kind) { - case 180: - return hasArguments ? 0 : 1; - case 190: - case 187: - case 188: - case 186: - case 189: - case 193: - case 195: - return 1; - case 192: - switch (operator) { - case 39: - case 57: - case 58: - case 59: - case 61: - case 60: - case 62: - case 63: - case 64: - case 65: - case 66: - case 67: - case 69: - case 68: - return 1; - } - } - return 0; - } - ts.getOperatorAssociativity = getOperatorAssociativity; - function getExpressionPrecedence(expression) { - var operator = getOperator(expression); - var hasArguments = expression.kind === 180 && expression.arguments !== undefined; - return getOperatorPrecedence(expression.kind, operator, hasArguments); - } - ts.getExpressionPrecedence = getExpressionPrecedence; - function getOperator(expression) { - if (expression.kind === 192) { - return expression.operatorToken.kind; - } - else if (expression.kind === 190 || expression.kind === 191) { - return expression.operator; - } - else { - return expression.kind; - } - } - ts.getOperator = getOperator; - function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { - switch (nodeKind) { - case 98: - case 96: - case 70: - case 94: - case 100: - case 85: - case 8: - case 9: - case 175: - case 176: - case 184: - case 185: - case 197: - case 246: - case 247: - case 11: - case 12: - case 194: - case 183: - case 198: - case 297: - return 19; - case 181: - case 177: - case 178: - return 18; - case 180: - return hasArguments ? 18 : 17; - case 179: - return 17; - case 191: - return 16; - case 190: - case 187: - case 188: - case 186: - case 189: - return 15; - case 192: - switch (operatorKind) { - case 50: - case 51: - return 15; - case 39: - case 38: - case 40: - case 41: - return 14; - case 36: - case 37: - return 13; - case 44: - case 45: - case 46: - return 12; - case 26: - case 29: - case 28: - case 30: - case 91: - case 92: - return 11; - case 31: - case 33: - case 32: - case 34: - return 10; - case 47: - return 9; - case 49: - return 8; - case 48: - return 7; - case 52: - return 6; - case 53: - return 5; - case 57: - case 58: - case 59: - case 61: - case 60: - case 62: - case 63: - case 64: - case 65: - case 66: - case 67: - case 69: - case 68: - return 3; - case 25: - return 0; - default: - return -1; - } - case 193: - return 4; - case 195: - return 2; - case 196: - return 1; - default: - return -1; - } - } - ts.getOperatorPrecedence = getOperatorPrecedence; - function createDiagnosticCollection() { - var nonFileDiagnostics = []; - var fileDiagnostics = ts.createMap(); - 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) { - 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) { - 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 = ts.createMap({ - "\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; - var lineStart; - var lineCount; - var linePos; - function write(s) { - if (s && s.length) { - if (lineStart) { - output += getIndentString(indent); - lineStart = false; - } - output += s; - } - } - function reset() { - output = ""; - indent = 0; - lineStart = true; - lineCount = 0; - linePos = 0; - } - 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(text, node) { - write(getTextOfNodeFromSourceText(text, node)); - } - reset(); - return { - write: write, - rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, - writeLiteral: writeLiteral, - writeLine: writeLine, - increaseIndent: function () { indent++; }, - decreaseIndent: function () { 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; }, - isAtStartOfLine: function () { return lineStart; }, - reset: reset - }; - } - ts.createTextWriter = createTextWriter; - function getResolvedExternalModuleName(host, file) { - return file.moduleName || getExternalModuleNameFromPath(host, file.fileName); - } - ts.getResolvedExternalModuleName = getResolvedExternalModuleName; - function getExternalModuleNameFromDeclaration(host, resolver, declaration) { - var file = resolver.getExternalModuleFileFromDeclaration(declaration); - if (!file || isDeclarationFile(file)) { - return undefined; - } - return getResolvedExternalModuleName(host, file); - } - ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; - function getExternalModuleNameFromPath(host, fileName) { - var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; - var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); - var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false); - return ts.removeFileExtension(relativePath); - } - ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; - 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 getDeclarationEmitOutputFilePath(sourceFile, host) { - var options = host.getCompilerOptions(); - var outputDir = options.declarationDir || options.outDir; - var path = outputDir - ? getSourceFilePathInNewDir(sourceFile, host, outputDir) - : sourceFile.fileName; - return ts.removeFileExtension(path) + ".d.ts"; - } - ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; - function getSourceFilesToEmit(host, targetSourceFile) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - var moduleKind = ts.getEmitModuleKind(options); - var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = getAllEmittableSourceFiles(); - return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); - } - else { - var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; - return filterSourceFilesInDirectory(sourceFiles, function (file) { return host.isSourceFileFromExternalLibrary(file); }); - } - function getAllEmittableSourceFiles() { - return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); - } - } - ts.getSourceFilesToEmit = getSourceFilesToEmit; - function filterSourceFilesInDirectory(sourceFiles, isSourceFileFromExternalLibrary) { - return ts.filter(sourceFiles, function (file) { return shouldEmitInDirectory(file, isSourceFileFromExternalLibrary); }); - } - ts.filterSourceFilesInDirectory = filterSourceFilesInDirectory; - function isNonDeclarationFile(sourceFile) { - return !isDeclarationFile(sourceFile); - } - function shouldEmitInDirectory(sourceFile, isSourceFileFromExternalLibrary) { - return isNonDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); - } - function isBundleEmitNonExternalModule(sourceFile) { - return isNonDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); - } - function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - onBundledEmit(sourceFiles); - } - else { - for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { - var sourceFile = sourceFiles_2[_i]; - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } - } - } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); - } - function onBundledEmit(sourceFiles) { - if (sourceFiles.length) { - var jsFilePath = options.outFile || options.out; - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, true); - } - } - } - ts.forEachTransformedEmitFile = forEachTransformedEmitFile; - function getSourceMapFilePath(jsFilePath, options) { - return options.sourceMap ? jsFilePath + ".map" : undefined; - } - function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - onBundledEmit(host); - } - else { - var sourceFiles = targetSourceFile === undefined ? getSourceFilesToEmit(host) : [targetSourceFile]; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; - if (shouldEmitInDirectory(sourceFile, function (file) { return host.isSourceFileFromExternalLibrary(file); })) { - onSingleFileEmit(host, sourceFile); - } - } - } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: declarationFilePath - }; - action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); - } - function onBundledEmit(host) { - var bundledSources = ts.filter(getSourceFilesToEmit(host), function (sourceFile) { return !isDeclarationFile(sourceFile) && - !host.isSourceFileFromExternalLibrary(sourceFile) && - (!ts.isExternalModule(sourceFile) || - !!ts.getEmitModuleKind(options)); }); - if (bundledSources.length) { - var jsFilePath = options.outFile || options.out; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined - }; - action(emitFileNames, bundledSources, true, emitOnlyDtsFiles); - } - } - } - ts.forEachExpectedEmitFile = forEachExpectedEmitFile; - function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); - var commonSourceDirectory = host.getCommonSourceDirectory(); - var isSourceFileInCommonSourceDirectory = host.getCanonicalFileName(sourceFilePath).indexOf(host.getCanonicalFileName(commonSourceDirectory)) === 0; - sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath; - return ts.combinePaths(newDirPath, sourceFilePath); - } - ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }, sourceFiles); - } - ts.writeFile = writeFile; - function getLineOfLocalPosition(currentSourceFile, pos) { - return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; - } - ts.getLineOfLocalPosition = getLineOfLocalPosition; - function getLineOfLocalPositionFromLineMap(lineMap, pos) { - return ts.computeLineAndCharacterOfPosition(lineMap, pos).line; - } - ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; - function getFirstConstructorWithBody(node) { - return ts.forEach(node.members, function (member) { - if (member.kind === 150 && nodeIsPresent(member.body)) { - return member; - } - }); - } - ts.getFirstConstructorWithBody = getFirstConstructorWithBody; - function getSetAccessorTypeAnnotationNode(accessor) { - if (accessor && accessor.parameters.length > 0) { - var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]); - return accessor.parameters[hasThis ? 1 : 0].type; - } - } - ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; - function getThisParameter(signature) { - if (signature.parameters.length) { - var thisParameter = signature.parameters[0]; - if (parameterIsThisKeyword(thisParameter)) { - return thisParameter; - } - } - } - ts.getThisParameter = getThisParameter; - function parameterIsThisKeyword(parameter) { - return isThisIdentifier(parameter.name); - } - ts.parameterIsThisKeyword = parameterIsThisKeyword; - function isThisIdentifier(node) { - return node && node.kind === 70 && identifierIsThisKeyword(node); - } - ts.isThisIdentifier = isThisIdentifier; - function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 98; - } - ts.identifierIsThisKeyword = identifierIsThisKeyword; - function getAllAccessorDeclarations(declarations, accessor) { - var firstAccessor; - var secondAccessor; - var getAccessor; - var setAccessor; - if (hasDynamicName(accessor)) { - firstAccessor = accessor; - if (accessor.kind === 151) { - getAccessor = accessor; - } - else if (accessor.kind === 152) { - setAccessor = accessor; - } - else { - ts.Debug.fail("Accessor has wrong kind"); - } - } - else { - ts.forEach(declarations, function (member) { - if ((member.kind === 151 || member.kind === 152) - && hasModifier(member, 32) === hasModifier(accessor, 32)) { - 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 === 151 && !getAccessor) { - getAccessor = member; - } - if (member.kind === 152 && !setAccessor) { - setAccessor = member; - } - } - } - }); - } - return { - firstAccessor: firstAccessor, - secondAccessor: secondAccessor, - getAccessor: getAccessor, - setAccessor: setAccessor - }; - } - ts.getAllAccessorDeclarations = getAllAccessorDeclarations; - function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) { - emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments); - } - ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; - function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) { - if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos && - getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) { - writer.writeLine(); - } - } - ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition; - function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) { - if (pos !== commentPos && - getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) { - writer.writeLine(); - } - } - ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition; - function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) { - if (comments && comments.length > 0) { - if (leadingSeparator) { - writer.write(" "); - } - var emitInterveningSeparator = false; - for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { - var comment = comments_1[_i]; - if (emitInterveningSeparator) { - writer.write(" "); - emitInterveningSeparator = false; - } - writeComment(text, lineMap, writer, comment.pos, comment.end, newLine); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - else { - emitInterveningSeparator = true; - } - } - if (emitInterveningSeparator && trailingSeparator) { - writer.write(" "); - } - } - } - ts.emitComments = emitComments; - function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) { - var leadingComments; - var currentDetachedCommentInfo; - if (removeComments) { - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); - } - } - else { - leadingComments = ts.getLeadingCommentRanges(text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment = void 0; - for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { - var comment = leadingComments_1[_i]; - if (lastComment) { - var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end); - var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos); - if (commentLine >= lastCommentLine + 2) { - break; - } - } - detachedComments.push(comment); - lastComment = comment; - } - if (detachedComments.length) { - var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); - var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); - emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment); - currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - } - } - } - return currentDetachedCommentInfo; - function isPinnedComment(comment) { - return text.charCodeAt(comment.pos + 1) === 42 && - text.charCodeAt(comment.pos + 2) === 33; - } - } - ts.emitDetachedComments = emitDetachedComments; - function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (text.charCodeAt(commentPos + 1) === 42) { - var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); - var lineCount = lineMap.length; - var firstCommentLineIndent = void 0; - for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) { - var nextLineStart = (currentLine + 1) === lineCount - ? text.length + 1 - : lineMap[currentLine + 1]; - if (pos !== commentPos) { - if (firstCommentLineIndent === undefined) { - firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos); - } - var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); - var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, 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(text, commentEnd, writer, newLine, pos, nextLineStart); - pos = nextLineStart; - } - } - else { - writer.write(text.substring(commentPos, commentEnd)); - } - } - ts.writeCommentRange = writeCommentRange; - function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { - var end = Math.min(commentEnd, nextLineStart - 1); - var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); - if (currentLineText) { - writer.write(currentLineText); - if (end !== commentEnd) { - writer.writeLine(); - } - } - else { - writer.writeLiteral(newLine); - } - } - function calculateIndent(text, pos, end) { - var currentLineIndent = 0; - for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { - if (text.charCodeAt(pos) === 9) { - currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); - } - else { - currentLineIndent++; - } - } - return currentLineIndent; - } - function hasModifiers(node) { - return getModifierFlags(node) !== 0; - } - ts.hasModifiers = hasModifiers; - function hasModifier(node, flags) { - return (getModifierFlags(node) & flags) !== 0; - } - ts.hasModifier = hasModifier; - function getModifierFlags(node) { - if (node.modifierFlagsCache & 536870912) { - return node.modifierFlagsCache & ~536870912; - } - var flags = 0; - if (node.modifiers) { - for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { - var modifier = _a[_i]; - flags |= modifierToFlag(modifier.kind); - } - } - if (node.flags & 4 || (node.kind === 70 && node.isInJSDocNamespace)) { - flags |= 1; - } - node.modifierFlagsCache = flags | 536870912; - return flags; - } - ts.getModifierFlags = getModifierFlags; - function modifierToFlag(token) { - switch (token) { - case 114: return 32; - case 113: return 4; - case 112: return 16; - case 111: return 8; - case 116: return 128; - case 83: return 1; - case 123: return 2; - case 75: return 2048; - case 78: return 512; - case 119: return 256; - case 130: return 64; - } - return 0; - } - ts.modifierToFlag = modifierToFlag; - function isLogicalOperator(token) { - return token === 53 - || token === 52 - || token === 50; - } - ts.isLogicalOperator = isLogicalOperator; - function isAssignmentOperator(token) { - return token >= 57 && token <= 69; - } - ts.isAssignmentOperator = isAssignmentOperator; - function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 199 && - node.parent.token === 84 && - isClassLike(node.parent.parent)) { - return node.parent.parent; - } - } - ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; - function isAssignmentExpression(node, excludeCompoundAssignment) { - return isBinaryExpression(node) - && (excludeCompoundAssignment - ? node.operatorToken.kind === 57 - : isAssignmentOperator(node.operatorToken.kind)) - && isLeftHandSideExpression(node.left); - } - ts.isAssignmentExpression = isAssignmentExpression; - function isDestructuringAssignment(node) { - if (isAssignmentExpression(node, true)) { - var kind = node.left.kind; - return kind === 176 - || kind === 175; - } - return false; - } - ts.isDestructuringAssignment = isDestructuringAssignment; - function isSupportedExpressionWithTypeArguments(node) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; - function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 70) { - return true; - } - else if (isPropertyAccessExpression(node)) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - else { - return false; - } - } - function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; - } - ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; - function isEntityNameExpression(node) { - return node.kind === 70 || - node.kind === 177 && isEntityNameExpression(node.expression); - } - ts.isEntityNameExpression = isEntityNameExpression; - function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 141 && node.parent.right === node) || - (node.parent.kind === 177 && node.parent.name === node); - } - ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; - function isEmptyObjectLiteralOrArrayLiteral(expression) { - var kind = expression.kind; - if (kind === 176) { - return expression.properties.length === 0; - } - if (kind === 175) { - return expression.elements.length === 0; - } - return false; - } - ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; - function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512) ? symbol.valueDeclaration.localSymbol : undefined; - } - ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function tryExtractTypeScriptExtension(fileName) { - return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); - } - ts.tryExtractTypeScriptExtension = tryExtractTypeScriptExtension; - 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; - function isSimpleExpression(node) { - return isSimpleExpressionWorker(node, 0); - } - ts.isSimpleExpression = isSimpleExpression; - function isSimpleExpressionWorker(node, depth) { - if (depth <= 5) { - var kind = node.kind; - if (kind === 9 - || kind === 8 - || kind === 11 - || kind === 12 - || kind === 70 - || kind === 98 - || kind === 96 - || kind === 100 - || kind === 85 - || kind === 94) { - return true; - } - else if (kind === 177) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 178) { - return isSimpleExpressionWorker(node.expression, depth + 1) - && isSimpleExpressionWorker(node.argumentExpression, depth + 1); - } - else if (kind === 190 - || kind === 191) { - return isSimpleExpressionWorker(node.operand, depth + 1); - } - else if (kind === 192) { - return node.operatorToken.kind !== 39 - && isSimpleExpressionWorker(node.left, depth + 1) - && isSimpleExpressionWorker(node.right, depth + 1); - } - else if (kind === 193) { - return isSimpleExpressionWorker(node.condition, depth + 1) - && isSimpleExpressionWorker(node.whenTrue, depth + 1) - && isSimpleExpressionWorker(node.whenFalse, depth + 1); - } - else if (kind === 188 - || kind === 187 - || kind === 186) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 175) { - return node.elements.length === 0; - } - else if (kind === 176) { - return node.properties.length === 0; - } - else if (kind === 179) { - if (!isSimpleExpressionWorker(node.expression, depth + 1)) { - return false; - } - for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { - var argument = _a[_i]; - if (!isSimpleExpressionWorker(argument, depth + 1)) { - return false; - } - } - return true; - } - } - return false; - } - var syntaxKindCache = ts.createMap(); - function formatSyntaxKind(kind) { - var syntaxKindEnum = ts.SyntaxKind; - if (syntaxKindEnum) { - if (syntaxKindCache[kind]) { - return syntaxKindCache[kind]; - } - for (var name_9 in syntaxKindEnum) { - if (syntaxKindEnum[name_9] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_9 + ")"; - } - } - } - else { - return kind.toString(); - } - } - ts.formatSyntaxKind = formatSyntaxKind; - function movePos(pos, value) { - return ts.positionIsSynthesized(pos) ? -1 : pos + value; - } - ts.movePos = movePos; - function createRange(pos, end) { - return { pos: pos, end: end }; - } - ts.createRange = createRange; - function moveRangeEnd(range, end) { - return createRange(range.pos, end); - } - ts.moveRangeEnd = moveRangeEnd; - function moveRangePos(range, pos) { - return createRange(pos, range.end); - } - ts.moveRangePos = moveRangePos; - function moveRangePastDecorators(node) { - return node.decorators && node.decorators.length > 0 - ? moveRangePos(node, node.decorators.end) - : node; - } - ts.moveRangePastDecorators = moveRangePastDecorators; - function moveRangePastModifiers(node) { - return node.modifiers && node.modifiers.length > 0 - ? moveRangePos(node, node.modifiers.end) - : moveRangePastDecorators(node); - } - ts.moveRangePastModifiers = moveRangePastModifiers; - function isCollapsedRange(range) { - return range.pos === range.end; - } - ts.isCollapsedRange = isCollapsedRange; - function collapseRangeToStart(range) { - return isCollapsedRange(range) ? range : moveRangeEnd(range, range.pos); - } - ts.collapseRangeToStart = collapseRangeToStart; - function collapseRangeToEnd(range) { - return isCollapsedRange(range) ? range : moveRangePos(range, range.end); - } - ts.collapseRangeToEnd = collapseRangeToEnd; - function createTokenRange(pos, token) { - return createRange(pos, pos + ts.tokenToString(token).length); - } - ts.createTokenRange = createTokenRange; - function rangeIsOnSingleLine(range, sourceFile) { - return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile); - } - ts.rangeIsOnSingleLine = rangeIsOnSingleLine; - function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) { - return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), getStartPositionOfRange(range2, sourceFile), sourceFile); - } - ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine; - function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) { - return positionsAreOnSameLine(range1.end, range2.end, sourceFile); - } - ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine; - function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) { - return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), range2.end, sourceFile); - } - ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd; - function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) { - return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile), sourceFile); - } - ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart; - function positionsAreOnSameLine(pos1, pos2, sourceFile) { - return pos1 === pos2 || - getLineOfLocalPosition(sourceFile, pos1) === getLineOfLocalPosition(sourceFile, pos2); - } - ts.positionsAreOnSameLine = positionsAreOnSameLine; - function getStartPositionOfRange(range, sourceFile) { - return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); - } - ts.getStartPositionOfRange = getStartPositionOfRange; - function isDeclarationNameOfEnumOrNamespace(node) { - var parseNode = getParseTreeNode(node); - if (parseNode) { - switch (parseNode.parent.kind) { - case 229: - case 230: - return parseNode === parseNode.parent.name; - } - } - return false; - } - ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace; - function getInitializedVariables(node) { - return ts.filter(node.declarations, isInitializedVariable); - } - ts.getInitializedVariables = getInitializedVariables; - function isInitializedVariable(node) { - return node.initializer !== undefined; - } - function isMergedWithClass(node) { - if (node.symbol) { - for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 226 && declaration !== node) { - return true; - } - } - } - return false; - } - ts.isMergedWithClass = isMergedWithClass; - function isFirstDeclarationOfKind(node, kind) { - return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; - } - ts.isFirstDeclarationOfKind = isFirstDeclarationOfKind; - function isNodeArray(array) { - return array.hasOwnProperty("pos") - && array.hasOwnProperty("end"); - } - ts.isNodeArray = isNodeArray; - function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 12; - } - ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; - function isLiteralKind(kind) { - return 8 <= kind && kind <= 12; - } - ts.isLiteralKind = isLiteralKind; - function isTextualLiteralKind(kind) { - return kind === 9 || kind === 12; - } - ts.isTextualLiteralKind = isTextualLiteralKind; - function isLiteralExpression(node) { - return isLiteralKind(node.kind); - } - ts.isLiteralExpression = isLiteralExpression; - function isTemplateLiteralKind(kind) { - return 12 <= kind && kind <= 15; - } - ts.isTemplateLiteralKind = isTemplateLiteralKind; - function isTemplateHead(node) { - return node.kind === 13; - } - ts.isTemplateHead = isTemplateHead; - function isTemplateMiddleOrTemplateTail(node) { - var kind = node.kind; - return kind === 14 - || kind === 15; - } - ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; - function isIdentifier(node) { - return node.kind === 70; - } - ts.isIdentifier = isIdentifier; - function isGeneratedIdentifier(node) { - return isIdentifier(node) && node.autoGenerateKind > 0; - } - ts.isGeneratedIdentifier = isGeneratedIdentifier; - function isModifier(node) { - return isModifierKind(node.kind); - } - ts.isModifier = isModifier; - function isQualifiedName(node) { - return node.kind === 141; - } - ts.isQualifiedName = isQualifiedName; - function isComputedPropertyName(node) { - return node.kind === 142; - } - ts.isComputedPropertyName = isComputedPropertyName; - function isEntityName(node) { - var kind = node.kind; - return kind === 141 - || kind === 70; - } - ts.isEntityName = isEntityName; - function isPropertyName(node) { - var kind = node.kind; - return kind === 70 - || kind === 9 - || kind === 8 - || kind === 142; - } - ts.isPropertyName = isPropertyName; - function isModuleName(node) { - var kind = node.kind; - return kind === 70 - || kind === 9; - } - ts.isModuleName = isModuleName; - function isBindingName(node) { - var kind = node.kind; - return kind === 70 - || kind === 172 - || kind === 173; - } - ts.isBindingName = isBindingName; - function isTypeParameter(node) { - return node.kind === 143; - } - ts.isTypeParameter = isTypeParameter; - function isParameter(node) { - return node.kind === 144; - } - ts.isParameter = isParameter; - function isDecorator(node) { - return node.kind === 145; - } - ts.isDecorator = isDecorator; - function isMethodDeclaration(node) { - return node.kind === 149; - } - ts.isMethodDeclaration = isMethodDeclaration; - function isClassElement(node) { - var kind = node.kind; - return kind === 150 - || kind === 147 - || kind === 149 - || kind === 151 - || kind === 152 - || kind === 155 - || kind === 203; - } - ts.isClassElement = isClassElement; - function isObjectLiteralElementLike(node) { - var kind = node.kind; - return kind === 257 - || kind === 258 - || kind === 259 - || kind === 149 - || kind === 151 - || kind === 152 - || kind === 244; - } - ts.isObjectLiteralElementLike = isObjectLiteralElementLike; - function isTypeNodeKind(kind) { - return (kind >= 156 && kind <= 171) - || kind === 118 - || kind === 132 - || kind === 121 - || kind === 134 - || kind === 135 - || kind === 104 - || kind === 129 - || kind === 199; - } - function isTypeNode(node) { - return isTypeNodeKind(node.kind); - } - ts.isTypeNode = isTypeNode; - function isArrayBindingPattern(node) { - return node.kind === 173; - } - ts.isArrayBindingPattern = isArrayBindingPattern; - function isObjectBindingPattern(node) { - return node.kind === 172; - } - ts.isObjectBindingPattern = isObjectBindingPattern; - function isBindingPattern(node) { - if (node) { - var kind = node.kind; - return kind === 173 - || kind === 172; - } - return false; - } - ts.isBindingPattern = isBindingPattern; - function isAssignmentPattern(node) { - var kind = node.kind; - return kind === 175 - || kind === 176; - } - ts.isAssignmentPattern = isAssignmentPattern; - function isBindingElement(node) { - return node.kind === 174; - } - ts.isBindingElement = isBindingElement; - function isArrayBindingElement(node) { - var kind = node.kind; - return kind === 174 - || kind === 198; - } - ts.isArrayBindingElement = isArrayBindingElement; - function isDeclarationBindingElement(bindingElement) { - switch (bindingElement.kind) { - case 223: - case 144: - case 174: - return true; - } - return false; - } - ts.isDeclarationBindingElement = isDeclarationBindingElement; - function isBindingOrAssignmentPattern(node) { - return isObjectBindingOrAssignmentPattern(node) - || isArrayBindingOrAssignmentPattern(node); - } - ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; - function isObjectBindingOrAssignmentPattern(node) { - switch (node.kind) { - case 172: - case 176: - return true; - } - return false; - } - ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; - function isArrayBindingOrAssignmentPattern(node) { - switch (node.kind) { - case 173: - case 175: - return true; - } - return false; - } - ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; - function isArrayLiteralExpression(node) { - return node.kind === 175; - } - ts.isArrayLiteralExpression = isArrayLiteralExpression; - function isObjectLiteralExpression(node) { - return node.kind === 176; - } - ts.isObjectLiteralExpression = isObjectLiteralExpression; - function isPropertyAccessExpression(node) { - return node.kind === 177; - } - ts.isPropertyAccessExpression = isPropertyAccessExpression; - function isElementAccessExpression(node) { - return node.kind === 178; - } - ts.isElementAccessExpression = isElementAccessExpression; - function isBinaryExpression(node) { - return node.kind === 192; - } - ts.isBinaryExpression = isBinaryExpression; - function isConditionalExpression(node) { - return node.kind === 193; - } - ts.isConditionalExpression = isConditionalExpression; - function isCallExpression(node) { - return node.kind === 179; - } - ts.isCallExpression = isCallExpression; - function isTemplateLiteral(node) { - var kind = node.kind; - return kind === 194 - || kind === 12; - } - ts.isTemplateLiteral = isTemplateLiteral; - function isSpreadExpression(node) { - return node.kind === 196; - } - ts.isSpreadExpression = isSpreadExpression; - function isExpressionWithTypeArguments(node) { - return node.kind === 199; - } - ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; - function isLeftHandSideExpressionKind(kind) { - return kind === 177 - || kind === 178 - || kind === 180 - || kind === 179 - || kind === 246 - || kind === 247 - || kind === 181 - || kind === 175 - || kind === 183 - || kind === 176 - || kind === 197 - || kind === 184 - || kind === 70 - || kind === 11 - || kind === 8 - || kind === 9 - || kind === 12 - || kind === 194 - || kind === 85 - || kind === 94 - || kind === 98 - || kind === 100 - || kind === 96 - || kind === 201 - || kind === 297; - } - function isLeftHandSideExpression(node) { - return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); - } - ts.isLeftHandSideExpression = isLeftHandSideExpression; - function isUnaryExpressionKind(kind) { - return kind === 190 - || kind === 191 - || kind === 186 - || kind === 187 - || kind === 188 - || kind === 189 - || kind === 182 - || isLeftHandSideExpressionKind(kind); - } - function isUnaryExpression(node) { - return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); - } - ts.isUnaryExpression = isUnaryExpression; - function isExpressionKind(kind) { - return kind === 193 - || kind === 195 - || kind === 185 - || kind === 192 - || kind === 196 - || kind === 200 - || kind === 198 - || kind === 297 - || isUnaryExpressionKind(kind); - } - function isExpression(node) { - return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); - } - ts.isExpression = isExpression; - function isAssertionExpression(node) { - var kind = node.kind; - return kind === 182 - || kind === 200; - } - ts.isAssertionExpression = isAssertionExpression; - function isPartiallyEmittedExpression(node) { - return node.kind === 294; - } - ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; - function isNotEmittedStatement(node) { - return node.kind === 293; - } - ts.isNotEmittedStatement = isNotEmittedStatement; - function isNotEmittedOrPartiallyEmittedNode(node) { - return isNotEmittedStatement(node) - || isPartiallyEmittedExpression(node); - } - ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; - function isOmittedExpression(node) { - return node.kind === 198; - } - ts.isOmittedExpression = isOmittedExpression; - function isTemplateSpan(node) { - return node.kind === 202; - } - ts.isTemplateSpan = isTemplateSpan; - function isBlock(node) { - return node.kind === 204; - } - ts.isBlock = isBlock; - function isConciseBody(node) { - return isBlock(node) - || isExpression(node); - } - ts.isConciseBody = isConciseBody; - function isFunctionBody(node) { - return isBlock(node); - } - ts.isFunctionBody = isFunctionBody; - function isForInitializer(node) { - return isVariableDeclarationList(node) - || isExpression(node); - } - ts.isForInitializer = isForInitializer; - function isVariableDeclaration(node) { - return node.kind === 223; - } - ts.isVariableDeclaration = isVariableDeclaration; - function isVariableDeclarationList(node) { - return node.kind === 224; - } - ts.isVariableDeclarationList = isVariableDeclarationList; - function isCaseBlock(node) { - return node.kind === 232; - } - ts.isCaseBlock = isCaseBlock; - function isModuleBody(node) { - var kind = node.kind; - return kind === 231 - || kind === 230; - } - ts.isModuleBody = isModuleBody; - function isImportEqualsDeclaration(node) { - return node.kind === 234; - } - ts.isImportEqualsDeclaration = isImportEqualsDeclaration; - function isImportClause(node) { - return node.kind === 236; - } - ts.isImportClause = isImportClause; - function isNamedImportBindings(node) { - var kind = node.kind; - return kind === 238 - || kind === 237; - } - ts.isNamedImportBindings = isNamedImportBindings; - function isImportSpecifier(node) { - return node.kind === 239; - } - ts.isImportSpecifier = isImportSpecifier; - function isNamedExports(node) { - return node.kind === 242; - } - ts.isNamedExports = isNamedExports; - function isExportSpecifier(node) { - return node.kind === 243; - } - ts.isExportSpecifier = isExportSpecifier; - function isModuleOrEnumDeclaration(node) { - return node.kind === 230 || node.kind === 229; - } - ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; - function isDeclarationKind(kind) { - return kind === 185 - || kind === 174 - || kind === 226 - || kind === 197 - || kind === 150 - || kind === 229 - || kind === 260 - || kind === 243 - || kind === 225 - || kind === 184 - || kind === 151 - || kind === 236 - || kind === 234 - || kind === 239 - || kind === 227 - || kind === 149 - || kind === 148 - || kind === 230 - || kind === 233 - || kind === 237 - || kind === 144 - || kind === 257 - || kind === 147 - || kind === 146 - || kind === 152 - || kind === 258 - || kind === 228 - || kind === 143 - || kind === 223 - || kind === 285; - } - function isDeclarationStatementKind(kind) { - return kind === 225 - || kind === 244 - || kind === 226 - || kind === 227 - || kind === 228 - || kind === 229 - || kind === 230 - || kind === 235 - || kind === 234 - || kind === 241 - || kind === 240 - || kind === 233; - } - function isStatementKindButNotDeclarationKind(kind) { - return kind === 215 - || kind === 214 - || kind === 222 - || kind === 209 - || kind === 207 - || kind === 206 - || kind === 212 - || kind === 213 - || kind === 211 - || kind === 208 - || kind === 219 - || kind === 216 - || kind === 218 - || kind === 220 - || kind === 221 - || kind === 205 - || kind === 210 - || kind === 217 - || kind === 293 - || kind === 296 - || kind === 295; - } - function isDeclaration(node) { - return isDeclarationKind(node.kind); - } - ts.isDeclaration = isDeclaration; - function isDeclarationStatement(node) { - return isDeclarationStatementKind(node.kind); - } - ts.isDeclarationStatement = isDeclarationStatement; - function isStatementButNotDeclaration(node) { - return isStatementKindButNotDeclarationKind(node.kind); - } - ts.isStatementButNotDeclaration = isStatementButNotDeclaration; - function isStatement(node) { - var kind = node.kind; - return isStatementKindButNotDeclarationKind(kind) - || isDeclarationStatementKind(kind) - || kind === 204; - } - ts.isStatement = isStatement; - function isModuleReference(node) { - var kind = node.kind; - return kind === 245 - || kind === 141 - || kind === 70; - } - ts.isModuleReference = isModuleReference; - function isJsxOpeningElement(node) { - return node.kind === 248; - } - ts.isJsxOpeningElement = isJsxOpeningElement; - function isJsxClosingElement(node) { - return node.kind === 249; - } - ts.isJsxClosingElement = isJsxClosingElement; - function isJsxTagNameExpression(node) { - var kind = node.kind; - return kind === 98 - || kind === 70 - || kind === 177; - } - ts.isJsxTagNameExpression = isJsxTagNameExpression; - function isJsxChild(node) { - var kind = node.kind; - return kind === 246 - || kind === 252 - || kind === 247 - || kind === 10; - } - ts.isJsxChild = isJsxChild; - function isJsxAttributeLike(node) { - var kind = node.kind; - return kind === 250 - || kind === 251; - } - ts.isJsxAttributeLike = isJsxAttributeLike; - function isJsxSpreadAttribute(node) { - return node.kind === 251; - } - ts.isJsxSpreadAttribute = isJsxSpreadAttribute; - function isJsxAttribute(node) { - return node.kind === 250; - } - ts.isJsxAttribute = isJsxAttribute; - function isStringLiteralOrJsxExpression(node) { - var kind = node.kind; - return kind === 9 - || kind === 252; - } - ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; - function isCaseOrDefaultClause(node) { - var kind = node.kind; - return kind === 253 - || kind === 254; - } - ts.isCaseOrDefaultClause = isCaseOrDefaultClause; - function isHeritageClause(node) { - return node.kind === 255; - } - ts.isHeritageClause = isHeritageClause; - function isCatchClause(node) { - return node.kind === 256; - } - ts.isCatchClause = isCatchClause; - function isPropertyAssignment(node) { - return node.kind === 257; - } - ts.isPropertyAssignment = isPropertyAssignment; - function isShorthandPropertyAssignment(node) { - return node.kind === 258; - } - ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; - function isEnumMember(node) { - return node.kind === 260; - } - ts.isEnumMember = isEnumMember; - function isSourceFile(node) { - return node.kind === 261; - } - ts.isSourceFile = isSourceFile; - function isWatchSet(options) { - return options.watch && options.hasOwnProperty("watch"); - } - ts.isWatchSet = isWatchSet; -})(ts || (ts = {})); -(function (ts) { - function getDefaultLibFileName(options) { - switch (options.target) { - case 5: - case 4: - return "lib.es2017.d.ts"; - case 3: - return "lib.es2016.d.ts"; - case 2: - return "lib.es6.d.ts"; - default: - return "lib.d.ts"; - } - } - ts.getDefaultLibFileName = getDefaultLibFileName; - function textSpanEnd(span) { - 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 === 143) { - for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 227) { - return current; - } - } - } - } - ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 150 && ts.isClassLike(node.parent.parent); - } - ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 174 || ts.isBindingPattern(node))) { - node = node.parent; - } - return node; - } - function getCombinedModifierFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = ts.getModifierFlags(node); - if (node.kind === 223) { - node = node.parent; - } - if (node && node.kind === 224) { - flags |= ts.getModifierFlags(node); - node = node.parent; - } - if (node && node.kind === 205) { - flags |= ts.getModifierFlags(node); - } - return flags; - } - ts.getCombinedModifierFlags = getCombinedModifierFlags; - function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 223) { - node = node.parent; - } - if (node && node.kind === 224) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 205) { - flags |= node.flags; - } - return flags; - } - ts.getCombinedNodeFlags = getCombinedNodeFlags; - function validateLocaleAndSetLanguage(locale, sys, errors) { - var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); - if (!matchResult) { - if (errors) { - 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; - } - var language = matchResult[1]; - var territory = matchResult[3]; - if (!trySetLanguageAndTerritory(language, territory, errors)) { - trySetLanguageAndTerritory(language, undefined, errors); - } - function trySetLanguageAndTerritory(language, territory, errors) { - var compilerFilePath = ts.normalizePath(sys.getExecutingFilePath()); - var containingDirectoryPath = ts.getDirectoryPath(compilerFilePath); - var filePath = ts.combinePaths(containingDirectoryPath, language); - if (territory) { - filePath = filePath + "-" + territory; - } - filePath = sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json")); - if (!sys.fileExists(filePath)) { - return false; - } - var fileContents = ""; - try { - fileContents = sys.readFile(filePath); - } - catch (e) { - if (errors) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, filePath)); - } - return false; - } - try { - ts.localizedDiagnosticMessages = JSON.parse(fileContents); - } - catch (e) { - if (errors) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath)); - } - return false; - } - return true; - } - } - ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage; -})(ts || (ts = {})); -var ts; -(function (ts) { - var NodeConstructor; - var SourceFileConstructor; - function createNode(kind, location, flags) { - var ConstructorForKind = kind === 261 - ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) - : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); - var node = location - ? new ConstructorForKind(kind, location.pos, location.end) - : new ConstructorForKind(kind, -1, -1); - node.flags = flags | 8; + function createSynthesizedNode(kind) { + var node = ts.createNode(kind, -1, -1); + node.flags |= 8; return node; } function updateNode(updated, original) { if (updated !== original) { setOriginalNode(updated, original); + setTextRange(updated, original); if (original.startsOnNewLine) { updated.startsOnNewLine = true; } @@ -10567,7 +10399,7 @@ var ts; return updated; } ts.updateNode = updateNode; - function createNodeArray(elements, location, hasTrailingComma) { + function createNodeArray(elements, hasTrailingComma) { if (elements) { if (ts.isNodeArray(elements)) { return elements; @@ -10577,32 +10409,15 @@ var ts; elements = []; } var array = elements; - if (location) { - array.pos = location.pos; - array.end = location.end; - } - else { - array.pos = -1; - array.end = -1; - } - if (hasTrailingComma) { - array.hasTrailingComma = true; - } + array.pos = -1; + array.end = -1; + array.hasTrailingComma = hasTrailingComma; return array; } ts.createNodeArray = createNodeArray; - function createSynthesizedNode(kind, startsOnNewLine) { - var node = createNode(kind, undefined); - node.startsOnNewLine = startsOnNewLine; - return node; - } - ts.createSynthesizedNode = createSynthesizedNode; - function createSynthesizedNodeArray(elements) { - return createNodeArray(elements, undefined); - } - ts.createSynthesizedNodeArray = createSynthesizedNodeArray; function getSynthesizedClone(node) { - var clone = createNode(node.kind, undefined, node.flags); + var clone = createSynthesizedNode(node.kind); + clone.flags |= node.flags; setOriginalNode(clone, node); for (var key in node) { if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) { @@ -10613,50 +10428,47 @@ var ts; return clone; } ts.getSynthesizedClone = getSynthesizedClone; - function getMutableClone(node) { - var clone = getSynthesizedClone(node); - clone.pos = node.pos; - clone.end = node.end; - clone.parent = node.parent; - return clone; - } - ts.getMutableClone = getMutableClone; - function createLiteral(value, location) { + function createLiteral(value) { if (typeof value === "number") { - var node = createNode(8, location, undefined); - node.text = value.toString(); - return node; + return createNumericLiteral(value + ""); } - else if (typeof value === "boolean") { - return createNode(value ? 100 : 85, location, undefined); + if (typeof value === "boolean") { + return value ? createTrue() : createFalse(); } - else if (typeof value === "string") { - var node = createNode(9, location, undefined); - node.text = value; - return node; - } - else if (value) { - var node = createNode(9, location, undefined); - node.textSourceNode = value; - node.text = value.text; - return node; + if (typeof value === "string") { + return createStringLiteral(value); } + return createLiteralFromNode(value); } ts.createLiteral = createLiteral; - var nextAutoGenerateId = 0; - function createIdentifier(text, location) { - var node = createNode(70, location); + function createNumericLiteral(value) { + var node = createSynthesizedNode(8); + node.text = value; + return node; + } + ts.createNumericLiteral = createNumericLiteral; + function createStringLiteral(text) { + var node = createSynthesizedNode(9); + node.text = text; + return node; + } + function createLiteralFromNode(sourceNode) { + var node = createStringLiteral(sourceNode.text); + node.textSourceNode = sourceNode; + return node; + } + function createIdentifier(text) { + var node = createSynthesizedNode(70); node.text = ts.escapeIdentifier(text); - node.originalKeywordKind = ts.stringToToken(text); + node.originalKeywordKind = text ? ts.stringToToken(text) : 0; node.autoGenerateKind = 0; node.autoGenerateId = 0; return node; } ts.createIdentifier = createIdentifier; - function createTempVariable(recordTempVariable, location) { - var name = createNode(70, location); - name.text = ""; - name.originalKeywordKind = 0; + var nextAutoGenerateId = 0; + function createTempVariable(recordTempVariable) { + var name = createIdentifier(""); name.autoGenerateKind = 1; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; @@ -10666,93 +10478,121 @@ var ts; return name; } ts.createTempVariable = createTempVariable; - function createLoopVariable(location) { - var name = createNode(70, location); - name.text = ""; - name.originalKeywordKind = 0; + function createLoopVariable() { + var name = createIdentifier(""); name.autoGenerateKind = 2; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createLoopVariable = createLoopVariable; - function createUniqueName(text, location) { - var name = createNode(70, location); - name.text = text; - name.originalKeywordKind = 0; + function createUniqueName(text) { + var name = createIdentifier(text); name.autoGenerateKind = 3; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createUniqueName = createUniqueName; - function getGeneratedNameForNode(node, location) { - var name = createNode(70, location); - name.original = node; - name.text = ""; - name.originalKeywordKind = 0; + function getGeneratedNameForNode(node) { + var name = createIdentifier(""); name.autoGenerateKind = 4; name.autoGenerateId = nextAutoGenerateId; + name.original = node; nextAutoGenerateId++; return name; } ts.getGeneratedNameForNode = getGeneratedNameForNode; function createToken(token) { - return createNode(token); + return createSynthesizedNode(token); } ts.createToken = createToken; function createSuper() { - var node = createNode(96); - return node; + return createSynthesizedNode(96); } ts.createSuper = createSuper; - function createThis(location) { - var node = createNode(98, location); - return node; + function createThis() { + return createSynthesizedNode(98); } ts.createThis = createThis; function createNull() { - var node = createNode(94); - return node; + return createSynthesizedNode(94); } ts.createNull = createNull; - function createComputedPropertyName(expression, location) { - var node = createNode(142, location); + function createTrue() { + return createSynthesizedNode(100); + } + ts.createTrue = createTrue; + function createFalse() { + return createSynthesizedNode(85); + } + ts.createFalse = createFalse; + function createQualifiedName(left, right) { + var node = createSynthesizedNode(142); + node.left = left; + node.right = asName(right); + return node; + } + ts.createQualifiedName = createQualifiedName; + function updateQualifiedName(node, left, right) { + return node.left !== left + || node.right !== right + ? updateNode(createQualifiedName(left, right), node) + : node; + } + ts.updateQualifiedName = updateQualifiedName; + function createComputedPropertyName(expression) { + var node = createSynthesizedNode(143); node.expression = expression; return node; } ts.createComputedPropertyName = createComputedPropertyName; function updateComputedPropertyName(node, expression) { - if (node.expression !== expression) { - return updateNode(createComputedPropertyName(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createComputedPropertyName(expression), node) + : node; } ts.updateComputedPropertyName = updateComputedPropertyName; - function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(144, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { + var node = createSynthesizedNode(145); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.questionToken = questionToken; node.type = type; - node.initializer = initializer ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createParameter = createParameter; function updateParameter(node, decorators, modifiers, dotDotDotToken, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) + : node; } ts.updateParameter = updateParameter; - function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(147, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createDecorator(expression) { + var node = createSynthesizedNode(146); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createDecorator = createDecorator; + function updateDecorator(node, expression) { + return node.expression !== expression + ? updateNode(createDecorator(expression), node) + : node; + } + ts.updateDecorator = updateDecorator; + function createProperty(decorators, modifiers, name, questionToken, type, initializer) { + var node = createSynthesizedNode(148); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.questionToken = questionToken; node.type = type; node.initializer = initializer; @@ -10760,19 +10600,22 @@ var ts; } ts.createProperty = createProperty; function updateProperty(node, decorators, modifiers, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer), node) + : node; } ts.updateProperty = updateProperty; - function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(149, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(150); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -10780,16 +10623,21 @@ var ts; } ts.createMethod = createMethod; function updateMethod(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateMethod = updateMethod; - function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(150, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createConstructor(decorators, modifiers, parameters, body) { + var node = createSynthesizedNode(151); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = undefined; @@ -10798,17 +10646,19 @@ var ts; } ts.createConstructor = createConstructor; function updateConstructor(node, decorators, modifiers, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.parameters !== parameters || node.body !== body) { - return updateNode(createConstructor(decorators, modifiers, parameters, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.parameters !== parameters + || node.body !== body + ? updateNode(createConstructor(decorators, modifiers, parameters, body), node) + : node; } ts.updateConstructor = updateConstructor; - function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(151, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createGetAccessor(decorators, modifiers, name, parameters, type, body) { + var node = createSynthesizedNode(152); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = type; @@ -10817,17 +10667,21 @@ var ts; } ts.createGetAccessor = createGetAccessor; function updateGetAccessor(node, decorators, modifiers, name, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body), node) + : node; } ts.updateGetAccessor = updateGetAccessor; - function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(152, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createSetAccessor(decorators, modifiers, name, parameters, body) { + var node = createSynthesizedNode(153); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.body = body; @@ -10835,57 +10689,60 @@ var ts; } ts.createSetAccessor = createSetAccessor; function updateSetAccessor(node, decorators, modifiers, name, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.body !== body) { - return updateNode(createSetAccessor(decorators, modifiers, name, parameters, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.body !== body + ? updateNode(createSetAccessor(decorators, modifiers, name, parameters, body), node) + : node; } ts.updateSetAccessor = updateSetAccessor; - function createObjectBindingPattern(elements, location) { - var node = createNode(172, location); + function createObjectBindingPattern(elements) { + var node = createSynthesizedNode(173); node.elements = createNodeArray(elements); return node; } ts.createObjectBindingPattern = createObjectBindingPattern; function updateObjectBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createObjectBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createObjectBindingPattern(elements), node) + : node; } ts.updateObjectBindingPattern = updateObjectBindingPattern; - function createArrayBindingPattern(elements, location) { - var node = createNode(173, location); + function createArrayBindingPattern(elements) { + var node = createSynthesizedNode(174); node.elements = createNodeArray(elements); return node; } ts.createArrayBindingPattern = createArrayBindingPattern; function updateArrayBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayBindingPattern(elements), node) + : node; } ts.updateArrayBindingPattern = updateArrayBindingPattern; - function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(174, location); - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createBindingElement(propertyName, dotDotDotToken, name, initializer) { + var node = createSynthesizedNode(175); + node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.initializer = initializer; return node; } ts.createBindingElement = createBindingElement; function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) { - if (node.propertyName !== propertyName || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.initializer !== initializer) { - return updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer, node), node); - } - return node; + return node.propertyName !== propertyName + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.initializer !== initializer + ? updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer), node) + : node; } ts.updateBindingElement = updateBindingElement; - function createArrayLiteral(elements, location, multiLine) { - var node = createNode(175, location); - node.elements = parenthesizeListElements(createNodeArray(elements)); + function createArrayLiteral(elements, multiLine) { + var node = createSynthesizedNode(176); + node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; } @@ -10893,14 +10750,13 @@ var ts; } ts.createArrayLiteral = createArrayLiteral; function updateArrayLiteral(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayLiteral(elements, node, node.multiLine), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayLiteral(elements, node.multiLine), node) + : node; } ts.updateArrayLiteral = updateArrayLiteral; - function createObjectLiteral(properties, location, multiLine) { - var node = createNode(176, location); + function createObjectLiteral(properties, multiLine) { + var node = createSynthesizedNode(177); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -10909,108 +10765,118 @@ var ts; } ts.createObjectLiteral = createObjectLiteral; function updateObjectLiteral(node, properties) { - if (node.properties !== properties) { - return updateNode(createObjectLiteral(properties, node, node.multiLine), node); - } - return node; + return node.properties !== properties + ? updateNode(createObjectLiteral(properties, node.multiLine), node) + : node; } ts.updateObjectLiteral = updateObjectLiteral; - function createPropertyAccess(expression, name, location, flags) { - var node = createNode(177, location, flags); - node.expression = parenthesizeForAccess(expression); - (node.emitNode || (node.emitNode = {})).flags |= 65536; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAccess(expression, name) { + var node = createSynthesizedNode(178); + node.expression = ts.parenthesizeForAccess(expression); + node.name = asName(name); + setEmitFlags(node, 65536); return node; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { - if (node.expression !== expression || node.name !== name) { - var propertyAccess = createPropertyAccess(expression, name, node, node.flags); - (propertyAccess.emitNode || (propertyAccess.emitNode = {})).flags = getEmitFlags(node); - return updateNode(propertyAccess, node); - } - return node; + return node.expression !== expression + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccess(expression, name), getEmitFlags(node)), node) + : node; } ts.updatePropertyAccess = updatePropertyAccess; - function createElementAccess(expression, index, location) { - var node = createNode(178, location); - node.expression = parenthesizeForAccess(expression); - node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; + function createElementAccess(expression, index) { + var node = createSynthesizedNode(179); + node.expression = ts.parenthesizeForAccess(expression); + node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { - if (node.expression !== expression || node.argumentExpression !== argumentExpression) { - return updateNode(createElementAccess(expression, argumentExpression, node), node); - } - return node; + return node.expression !== expression + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccess(expression, argumentExpression), node) + : node; } ts.updateElementAccess = updateElementAccess; - function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(179, location, flags); - node.expression = parenthesizeForAccess(expression); - if (typeArguments) { - node.typeArguments = createNodeArray(typeArguments); - } - node.arguments = parenthesizeListElements(createNodeArray(argumentsArray)); + function createCall(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(180); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); return node; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { - if (expression !== node.expression || typeArguments !== node.typeArguments || argumentsArray !== node.arguments) { - return updateNode(createCall(expression, typeArguments, argumentsArray, node, node.flags), node); - } - return node; + return expression !== node.expression + || typeArguments !== node.typeArguments + || argumentsArray !== node.arguments + ? updateNode(createCall(expression, typeArguments, argumentsArray), node) + : node; } ts.updateCall = updateCall; - function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(180, location, flags); - node.expression = parenthesizeForNew(expression); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; + function createNew(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(181); + node.expression = ts.parenthesizeForNew(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; return node; } ts.createNew = createNew; function updateNew(node, expression, typeArguments, argumentsArray) { - if (node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray) { - return updateNode(createNew(expression, typeArguments, argumentsArray, node, node.flags), node); - } - return node; + return node.expression !== expression + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createNew(expression, typeArguments, argumentsArray), node) + : node; } ts.updateNew = updateNew; - function createTaggedTemplate(tag, template, location) { - var node = createNode(181, location); - node.tag = parenthesizeForAccess(tag); + function createTaggedTemplate(tag, template) { + var node = createSynthesizedNode(182); + node.tag = ts.parenthesizeForAccess(tag); node.template = template; return node; } ts.createTaggedTemplate = createTaggedTemplate; function updateTaggedTemplate(node, tag, template) { - if (node.tag !== tag || node.template !== template) { - return updateNode(createTaggedTemplate(tag, template, node), node); - } - return node; + return node.tag !== tag + || node.template !== template + ? updateNode(createTaggedTemplate(tag, template), node) + : node; } ts.updateTaggedTemplate = updateTaggedTemplate; - function createParen(expression, location) { - var node = createNode(183, location); + function createTypeAssertion(type, expression) { + var node = createSynthesizedNode(183); + node.type = type; + node.expression = ts.parenthesizePrefixOperand(expression); + return node; + } + ts.createTypeAssertion = createTypeAssertion; + function updateTypeAssertion(node, type, expression) { + return node.type !== type + || node.expression !== expression + ? updateNode(createTypeAssertion(type, expression), node) + : node; + } + ts.updateTypeAssertion = updateTypeAssertion; + function createParen(expression) { + var node = createSynthesizedNode(184); node.expression = expression; return node; } ts.createParen = createParen; function updateParen(node, expression) { - if (node.expression !== expression) { - return updateNode(createParen(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createParen(expression), node) + : node; } ts.updateParen = updateParen; - function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(184, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(185); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -11018,322 +10884,340 @@ var ts; } ts.createFunctionExpression = createFunctionExpression; function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); - } - return node; + return node.name !== name + || node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionExpression = updateFunctionExpression; - function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(185, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { + var node = createSynthesizedNode(186); + node.modifiers = asNodeArray(modifiers); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35); - node.body = parenthesizeConciseBody(body); + node.body = ts.parenthesizeConciseBody(body); return node; } ts.createArrowFunction = createArrowFunction; function updateArrowFunction(node, modifiers, typeParameters, parameters, type, body) { - if (node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body, node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body), node) + : node; } ts.updateArrowFunction = updateArrowFunction; - function createDelete(expression, location) { - var node = createNode(186, location); - node.expression = parenthesizePrefixOperand(expression); + function createDelete(expression) { + var node = createSynthesizedNode(187); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createDelete = createDelete; function updateDelete(node, expression) { - if (node.expression !== expression) { - return updateNode(createDelete(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createDelete(expression), node) + : node; } ts.updateDelete = updateDelete; - function createTypeOf(expression, location) { - var node = createNode(187, location); - node.expression = parenthesizePrefixOperand(expression); + function createTypeOf(expression) { + var node = createSynthesizedNode(188); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createTypeOf = createTypeOf; function updateTypeOf(node, expression) { - if (node.expression !== expression) { - return updateNode(createTypeOf(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createTypeOf(expression), node) + : node; } ts.updateTypeOf = updateTypeOf; - function createVoid(expression, location) { - var node = createNode(188, location); - node.expression = parenthesizePrefixOperand(expression); + function createVoid(expression) { + var node = createSynthesizedNode(189); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createVoid = createVoid; function updateVoid(node, expression) { - if (node.expression !== expression) { - return updateNode(createVoid(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createVoid(expression), node) + : node; } ts.updateVoid = updateVoid; - function createAwait(expression, location) { - var node = createNode(189, location); - node.expression = parenthesizePrefixOperand(expression); + function createAwait(expression) { + var node = createSynthesizedNode(190); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createAwait = createAwait; function updateAwait(node, expression) { - if (node.expression !== expression) { - return updateNode(createAwait(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createAwait(expression), node) + : node; } ts.updateAwait = updateAwait; - function createPrefix(operator, operand, location) { - var node = createNode(190, location); + function createPrefix(operator, operand) { + var node = createSynthesizedNode(191); node.operator = operator; - node.operand = parenthesizePrefixOperand(operand); + node.operand = ts.parenthesizePrefixOperand(operand); return node; } ts.createPrefix = createPrefix; function updatePrefix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPrefix(node.operator, operand, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPrefix(node.operator, operand), node) + : node; } ts.updatePrefix = updatePrefix; - function createPostfix(operand, operator, location) { - var node = createNode(191, location); - node.operand = parenthesizePostfixOperand(operand); + function createPostfix(operand, operator) { + var node = createSynthesizedNode(192); + node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; } ts.createPostfix = createPostfix; function updatePostfix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPostfix(operand, node.operator, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPostfix(operand, node.operator), node) + : node; } ts.updatePostfix = updatePostfix; - function createBinary(left, operator, right, location) { - var operatorToken = typeof operator === "number" ? createToken(operator) : operator; + function createBinary(left, operator, right) { + var node = createSynthesizedNode(193); + var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; - var node = createNode(192, location); - node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); + node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined); node.operatorToken = operatorToken; - node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); + node.right = ts.parenthesizeBinaryOperand(operatorKind, right, false, node.left); return node; } ts.createBinary = createBinary; function updateBinary(node, left, right) { - if (node.left !== left || node.right !== right) { - return updateNode(createBinary(left, node.operatorToken, right, node), node); - } - return node; + return node.left !== left + || node.right !== right + ? updateNode(createBinary(left, node.operatorToken, right), node) + : node; } ts.updateBinary = updateBinary; - function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonTokenOrLocation, whenFalse, location) { - var node = createNode(193, whenFalse ? location : colonTokenOrLocation); - node.condition = parenthesizeForConditionalHead(condition); - if (whenFalse) { - node.questionToken = questionTokenOrWhenTrue; - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - node.colonToken = colonTokenOrLocation; - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenFalse); - } - else { - node.questionToken = createToken(54); - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(questionTokenOrWhenTrue); - node.colonToken = createToken(55); - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - } + function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { + var node = createSynthesizedNode(194); + node.condition = ts.parenthesizeForConditionalHead(condition); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(54); + node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); + node.colonToken = whenFalse ? colonToken : createToken(55); + node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } ts.createConditional = createConditional; function updateConditional(node, condition, whenTrue, whenFalse) { - if (node.condition !== condition || node.whenTrue !== whenTrue || node.whenFalse !== whenFalse) { - return updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse, node), node); - } - return node; + return node.condition !== condition + || node.whenTrue !== whenTrue + || node.whenFalse !== whenFalse + ? updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse), node) + : node; } ts.updateConditional = updateConditional; - function createTemplateExpression(head, templateSpans, location) { - var node = createNode(194, location); + function createTemplateExpression(head, templateSpans) { + var node = createSynthesizedNode(195); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; } ts.createTemplateExpression = createTemplateExpression; function updateTemplateExpression(node, head, templateSpans) { - if (node.head !== head || node.templateSpans !== templateSpans) { - return updateNode(createTemplateExpression(head, templateSpans, node), node); - } - return node; + return node.head !== head + || node.templateSpans !== templateSpans + ? updateNode(createTemplateExpression(head, templateSpans), node) + : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createYield(asteriskToken, expression, location) { - var node = createNode(195, location); - node.asteriskToken = asteriskToken; - node.expression = expression; + function createYield(asteriskTokenOrExpression, expression) { + var node = createSynthesizedNode(196); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 38 ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 38 ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; function updateYield(node, expression) { - if (node.expression !== expression) { - return updateNode(createYield(node.asteriskToken, expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createYield(node.asteriskToken, expression), node) + : node; } ts.updateYield = updateYield; - function createSpread(expression, location) { - var node = createNode(196, location); - node.expression = parenthesizeExpressionForList(expression); + function createSpread(expression) { + var node = createSynthesizedNode(197); + node.expression = ts.parenthesizeExpressionForList(expression); return node; } ts.createSpread = createSpread; function updateSpread(node, expression) { - if (node.expression !== expression) { - return updateNode(createSpread(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createSpread(expression), node) + : node; } ts.updateSpread = updateSpread; - function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(197, location); + function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(198); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassExpression = createClassExpression; function updateClassExpression(node, modifiers, name, typeParameters, heritageClauses, members) { - if (node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassExpression = updateClassExpression; - function createOmittedExpression(location) { - var node = createNode(198, location); - return node; + function createOmittedExpression() { + return createSynthesizedNode(199); } ts.createOmittedExpression = createOmittedExpression; - function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(199, location); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.expression = parenthesizeForAccess(expression); + function createExpressionWithTypeArguments(typeArguments, expression) { + var node = createSynthesizedNode(200); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); return node; } ts.createExpressionWithTypeArguments = createExpressionWithTypeArguments; function updateExpressionWithTypeArguments(node, typeArguments, expression) { - if (node.typeArguments !== typeArguments || node.expression !== expression) { - return updateNode(createExpressionWithTypeArguments(typeArguments, expression, node), node); - } - return node; + return node.typeArguments !== typeArguments + || node.expression !== expression + ? updateNode(createExpressionWithTypeArguments(typeArguments, expression), node) + : node; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; - function createTemplateSpan(expression, literal, location) { - var node = createNode(202, location); + function createAsExpression(expression, type) { + var node = createSynthesizedNode(201); + node.expression = expression; + node.type = type; + return node; + } + ts.createAsExpression = createAsExpression; + function updateAsExpression(node, expression, type) { + return node.expression !== expression + || node.type !== type + ? updateNode(createAsExpression(expression, type), node) + : node; + } + ts.updateAsExpression = updateAsExpression; + function createNonNullExpression(expression) { + var node = createSynthesizedNode(202); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createNonNullExpression = createNonNullExpression; + function updateNonNullExpression(node, expression) { + return node.expression !== expression + ? updateNode(createNonNullExpression(expression), node) + : node; + } + ts.updateNonNullExpression = updateNonNullExpression; + function createTemplateSpan(expression, literal) { + var node = createSynthesizedNode(204); node.expression = expression; node.literal = literal; return node; } ts.createTemplateSpan = createTemplateSpan; function updateTemplateSpan(node, expression, literal) { - if (node.expression !== expression || node.literal !== literal) { - return updateNode(createTemplateSpan(expression, literal, node), node); - } - return node; + return node.expression !== expression + || node.literal !== literal + ? updateNode(createTemplateSpan(expression, literal), node) + : node; } ts.updateTemplateSpan = updateTemplateSpan; - function createBlock(statements, location, multiLine, flags) { - var block = createNode(204, location, flags); + function createBlock(statements, multiLine) { + var block = createSynthesizedNode(206); block.statements = createNodeArray(statements); - if (multiLine) { - block.multiLine = true; - } + if (multiLine) + block.multiLine = multiLine; return block; } ts.createBlock = createBlock; function updateBlock(node, statements) { - if (statements !== node.statements) { - return updateNode(createBlock(statements, node, node.multiLine, node.flags), node); - } - return node; + return statements !== node.statements + ? updateNode(createBlock(statements, node.multiLine), node) + : node; } ts.updateBlock = updateBlock; - function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(205, location, flags); + function createVariableStatement(modifiers, declarationList) { + var node = createSynthesizedNode(207); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; return node; } ts.createVariableStatement = createVariableStatement; function updateVariableStatement(node, modifiers, declarationList) { - if (node.modifiers !== modifiers || node.declarationList !== declarationList) { - return updateNode(createVariableStatement(modifiers, declarationList, node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.declarationList !== declarationList + ? updateNode(createVariableStatement(modifiers, declarationList), node) + : node; } ts.updateVariableStatement = updateVariableStatement; - function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(224, location, flags); + function createVariableDeclarationList(declarations, flags) { + var node = createSynthesizedNode(226); + node.flags |= flags; node.declarations = createNodeArray(declarations); return node; } ts.createVariableDeclarationList = createVariableDeclarationList; function updateVariableDeclarationList(node, declarations) { - if (node.declarations !== declarations) { - return updateNode(createVariableDeclarationList(declarations, node, node.flags), node); - } - return node; + return node.declarations !== declarations + ? updateNode(createVariableDeclarationList(declarations, node.flags), node) + : node; } ts.updateVariableDeclarationList = updateVariableDeclarationList; - function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(223, location, flags); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createVariableDeclaration(name, type, initializer) { + var node = createSynthesizedNode(225); + node.name = asName(name); node.type = type; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createVariableDeclaration = createVariableDeclaration; function updateVariableDeclaration(node, name, type, initializer) { - if (node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createVariableDeclaration(name, type, initializer, node, node.flags), node); - } - return node; + return node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createVariableDeclaration(name, type, initializer), node) + : node; } ts.updateVariableDeclaration = updateVariableDeclaration; - function createEmptyStatement(location) { - return createNode(206, location); + function createEmptyStatement() { + return createSynthesizedNode(208); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression, location, flags) { - var node = createNode(207, location, flags); - node.expression = parenthesizeExpressionForExpressionStatement(expression); + function createStatement(expression) { + var node = createSynthesizedNode(209); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } ts.createStatement = createStatement; function updateStatement(node, expression) { - if (node.expression !== expression) { - return updateNode(createStatement(expression, node, node.flags), node); - } - return node; + return node.expression !== expression + ? updateNode(createStatement(expression), node) + : node; } ts.updateStatement = updateStatement; - function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(208, location); + function createIf(expression, thenStatement, elseStatement) { + var node = createSynthesizedNode(210); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11341,42 +11225,43 @@ var ts; } ts.createIf = createIf; function updateIf(node, expression, thenStatement, elseStatement) { - if (node.expression !== expression || node.thenStatement !== thenStatement || node.elseStatement !== elseStatement) { - return updateNode(createIf(expression, thenStatement, elseStatement, node), node); - } - return node; + return node.expression !== expression + || node.thenStatement !== thenStatement + || node.elseStatement !== elseStatement + ? updateNode(createIf(expression, thenStatement, elseStatement), node) + : node; } ts.updateIf = updateIf; - function createDo(statement, expression, location) { - var node = createNode(209, location); + function createDo(statement, expression) { + var node = createSynthesizedNode(211); node.statement = statement; node.expression = expression; return node; } ts.createDo = createDo; function updateDo(node, statement, expression) { - if (node.statement !== statement || node.expression !== expression) { - return updateNode(createDo(statement, expression, node), node); - } - return node; + return node.statement !== statement + || node.expression !== expression + ? updateNode(createDo(statement, expression), node) + : node; } ts.updateDo = updateDo; - function createWhile(expression, statement, location) { - var node = createNode(210, location); + function createWhile(expression, statement) { + var node = createSynthesizedNode(212); node.expression = expression; node.statement = statement; return node; } ts.createWhile = createWhile; function updateWhile(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWhile(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWhile(expression, statement), node) + : node; } ts.updateWhile = updateWhile; - function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(211, location, undefined); + function createFor(initializer, condition, incrementor, statement) { + var node = createSynthesizedNode(213); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11385,14 +11270,16 @@ var ts; } ts.createFor = createFor; function updateFor(node, initializer, condition, incrementor, statement) { - if (node.initializer !== initializer || node.condition !== condition || node.incrementor !== incrementor || node.statement !== statement) { - return updateNode(createFor(initializer, condition, incrementor, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.condition !== condition + || node.incrementor !== incrementor + || node.statement !== statement + ? updateNode(createFor(initializer, condition, incrementor, statement), node) + : node; } ts.updateFor = updateFor; - function createForIn(initializer, expression, statement, location) { - var node = createNode(212, location); + function createForIn(initializer, expression, statement) { + var node = createSynthesizedNode(214); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11400,14 +11287,15 @@ var ts; } ts.createForIn = createForIn; function updateForIn(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForIn(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForIn(initializer, expression, statement), node) + : node; } ts.updateForIn = updateForIn; - function createForOf(initializer, expression, statement, location) { - var node = createNode(213, location); + function createForOf(initializer, expression, statement) { + var node = createSynthesizedNode(215); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11415,112 +11303,105 @@ var ts; } ts.createForOf = createForOf; function updateForOf(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForOf(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForOf(initializer, expression, statement), node) + : node; } ts.updateForOf = updateForOf; - function createContinue(label, location) { - var node = createNode(214, location); - if (label) { - node.label = label; - } + function createContinue(label) { + var node = createSynthesizedNode(216); + node.label = asName(label); return node; } ts.createContinue = createContinue; function updateContinue(node, label) { - if (node.label !== label) { - return updateNode(createContinue(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createContinue(label), node) + : node; } ts.updateContinue = updateContinue; - function createBreak(label, location) { - var node = createNode(215, location); - if (label) { - node.label = label; - } + function createBreak(label) { + var node = createSynthesizedNode(217); + node.label = asName(label); return node; } ts.createBreak = createBreak; function updateBreak(node, label) { - if (node.label !== label) { - return updateNode(createBreak(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createBreak(label), node) + : node; } ts.updateBreak = updateBreak; - function createReturn(expression, location) { - var node = createNode(216, location); + function createReturn(expression) { + var node = createSynthesizedNode(218); node.expression = expression; return node; } ts.createReturn = createReturn; function updateReturn(node, expression) { - if (node.expression !== expression) { - return updateNode(createReturn(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createReturn(expression), node) + : node; } ts.updateReturn = updateReturn; - function createWith(expression, statement, location) { - var node = createNode(217, location); + function createWith(expression, statement) { + var node = createSynthesizedNode(219); node.expression = expression; node.statement = statement; return node; } ts.createWith = createWith; function updateWith(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWith(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWith(expression, statement), node) + : node; } ts.updateWith = updateWith; - function createSwitch(expression, caseBlock, location) { - var node = createNode(218, location); - node.expression = parenthesizeExpressionForList(expression); + function createSwitch(expression, caseBlock) { + var node = createSynthesizedNode(220); + node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; } ts.createSwitch = createSwitch; function updateSwitch(node, expression, caseBlock) { - if (node.expression !== expression || node.caseBlock !== caseBlock) { - return updateNode(createSwitch(expression, caseBlock, node), node); - } - return node; + return node.expression !== expression + || node.caseBlock !== caseBlock + ? updateNode(createSwitch(expression, caseBlock), node) + : node; } ts.updateSwitch = updateSwitch; - function createLabel(label, statement, location) { - var node = createNode(219, location); - node.label = typeof label === "string" ? createIdentifier(label) : label; + function createLabel(label, statement) { + var node = createSynthesizedNode(221); + node.label = asName(label); node.statement = statement; return node; } ts.createLabel = createLabel; function updateLabel(node, label, statement) { - if (node.label !== label || node.statement !== statement) { - return updateNode(createLabel(label, statement, node), node); - } - return node; + return node.label !== label + || node.statement !== statement + ? updateNode(createLabel(label, statement), node) + : node; } ts.updateLabel = updateLabel; - function createThrow(expression, location) { - var node = createNode(220, location); + function createThrow(expression) { + var node = createSynthesizedNode(222); node.expression = expression; return node; } ts.createThrow = createThrow; function updateThrow(node, expression) { - if (node.expression !== expression) { - return updateNode(createThrow(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createThrow(expression), node) + : node; } ts.updateThrow = updateThrow; - function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(221, location); + function createTry(tryBlock, catchClause, finallyBlock) { + var node = createSynthesizedNode(223); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11528,32 +11409,20 @@ var ts; } ts.createTry = createTry; function updateTry(node, tryBlock, catchClause, finallyBlock) { - if (node.tryBlock !== tryBlock || node.catchClause !== catchClause || node.finallyBlock !== finallyBlock) { - return updateNode(createTry(tryBlock, catchClause, finallyBlock, node), node); - } - return node; + return node.tryBlock !== tryBlock + || node.catchClause !== catchClause + || node.finallyBlock !== finallyBlock + ? updateNode(createTry(tryBlock, catchClause, finallyBlock), node) + : node; } ts.updateTry = updateTry; - function createCaseBlock(clauses, location) { - var node = createNode(232, location); - node.clauses = createNodeArray(clauses); - return node; - } - ts.createCaseBlock = createCaseBlock; - function updateCaseBlock(node, clauses) { - if (node.clauses !== clauses) { - return updateNode(createCaseBlock(clauses, node), node); - } - return node; - } - ts.updateCaseBlock = updateCaseBlock; - function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(225, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(227); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -11561,161 +11430,261 @@ var ts; } ts.createFunctionDeclaration = createFunctionDeclaration; function updateFunctionDeclaration(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionDeclaration = updateFunctionDeclaration; - function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(226, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(228); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassDeclaration = createClassDeclaration; function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassDeclaration = updateClassDeclaration; - function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(235, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createEnumDeclaration(decorators, modifiers, name, members) { + var node = createSynthesizedNode(231); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.members = createNodeArray(members); + return node; + } + ts.createEnumDeclaration = createEnumDeclaration; + function updateEnumDeclaration(node, decorators, modifiers, name, members) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.members !== members + ? updateNode(createEnumDeclaration(decorators, modifiers, name, members), node) + : node; + } + ts.updateEnumDeclaration = updateEnumDeclaration; + function createModuleDeclaration(decorators, modifiers, name, body, flags) { + var node = createSynthesizedNode(232); + node.flags |= flags; + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = name; + node.body = body; + return node; + } + ts.createModuleDeclaration = createModuleDeclaration; + function updateModuleDeclaration(node, decorators, modifiers, name, body) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.body !== body + ? updateNode(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node) + : node; + } + ts.updateModuleDeclaration = updateModuleDeclaration; + function createModuleBlock(statements) { + var node = createSynthesizedNode(234); + node.statements = createNodeArray(statements); + return node; + } + ts.createModuleBlock = createModuleBlock; + function updateModuleBlock(node, statements) { + return node.statements !== statements + ? updateNode(createModuleBlock(statements), node) + : node; + } + ts.updateModuleBlock = updateModuleBlock; + function createCaseBlock(clauses) { + var node = createSynthesizedNode(234); + node.clauses = createNodeArray(clauses); + return node; + } + ts.createCaseBlock = createCaseBlock; + function updateCaseBlock(node, clauses) { + return node.clauses !== clauses + ? updateNode(createCaseBlock(clauses), node) + : node; + } + ts.updateCaseBlock = updateCaseBlock; + function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { + var node = createSynthesizedNode(236); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.moduleReference = moduleReference; + return node; + } + ts.createImportEqualsDeclaration = createImportEqualsDeclaration; + function updateImportEqualsDeclaration(node, decorators, modifiers, name, moduleReference) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.moduleReference !== moduleReference + ? updateNode(createImportEqualsDeclaration(decorators, modifiers, name, moduleReference), node) + : node; + } + ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; + function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { + var node = createSynthesizedNode(237); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createImportDeclaration = createImportDeclaration; function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node) + : node; } ts.updateImportDeclaration = updateImportDeclaration; - function createImportClause(name, namedBindings, location) { - var node = createNode(236, location); + function createImportClause(name, namedBindings) { + var node = createSynthesizedNode(238); node.name = name; node.namedBindings = namedBindings; return node; } ts.createImportClause = createImportClause; function updateImportClause(node, name, namedBindings) { - if (node.name !== name || node.namedBindings !== namedBindings) { - return updateNode(createImportClause(name, namedBindings, node), node); - } - return node; + return node.name !== name + || node.namedBindings !== namedBindings + ? updateNode(createImportClause(name, namedBindings), node) + : node; } ts.updateImportClause = updateImportClause; - function createNamespaceImport(name, location) { - var node = createNode(237, location); + function createNamespaceImport(name) { + var node = createSynthesizedNode(239); node.name = name; return node; } ts.createNamespaceImport = createNamespaceImport; function updateNamespaceImport(node, name) { - if (node.name !== name) { - return updateNode(createNamespaceImport(name, node), node); - } - return node; + return node.name !== name + ? updateNode(createNamespaceImport(name), node) + : node; } ts.updateNamespaceImport = updateNamespaceImport; - function createNamedImports(elements, location) { - var node = createNode(238, location); + function createNamedImports(elements) { + var node = createSynthesizedNode(240); node.elements = createNodeArray(elements); return node; } ts.createNamedImports = createNamedImports; function updateNamedImports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedImports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedImports(elements), node) + : node; } ts.updateNamedImports = updateNamedImports; - function createImportSpecifier(propertyName, name, location) { - var node = createNode(239, location); + function createImportSpecifier(propertyName, name) { + var node = createSynthesizedNode(241); node.propertyName = propertyName; node.name = name; return node; } ts.createImportSpecifier = createImportSpecifier; function updateImportSpecifier(node, propertyName, name) { - if (node.propertyName !== propertyName || node.name !== name) { - return updateNode(createImportSpecifier(propertyName, name, node), node); - } - return node; + return node.propertyName !== propertyName + || node.name !== name + ? updateNode(createImportSpecifier(propertyName, name), node) + : node; } ts.updateImportSpecifier = updateImportSpecifier; - function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(240, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportAssignment(decorators, modifiers, isExportEquals, expression) { + var node = createSynthesizedNode(242); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; node.expression = expression; return node; } ts.createExportAssignment = createExportAssignment; function updateExportAssignment(node, decorators, modifiers, expression) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.expression !== expression) { - return updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.expression !== expression + ? updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node) + : node; } ts.updateExportAssignment = updateExportAssignment; - function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(241, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { + var node = createSynthesizedNode(243); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createExportDeclaration = createExportDeclaration; function updateExportDeclaration(node, decorators, modifiers, exportClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.exportClause !== exportClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.exportClause !== exportClause + || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier), node) + : node; } ts.updateExportDeclaration = updateExportDeclaration; - function createNamedExports(elements, location) { - var node = createNode(242, location); + function createNamedExports(elements) { + var node = createSynthesizedNode(244); node.elements = createNodeArray(elements); return node; } ts.createNamedExports = createNamedExports; function updateNamedExports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedExports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedExports(elements), node) + : node; } ts.updateNamedExports = updateNamedExports; - function createExportSpecifier(name, propertyName, location) { - var node = createNode(243, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createExportSpecifier(name, propertyName) { + var node = createSynthesizedNode(245); + node.name = asName(name); + node.propertyName = asName(propertyName); return node; } ts.createExportSpecifier = createExportSpecifier; function updateExportSpecifier(node, name, propertyName) { - if (node.name !== name || node.propertyName !== propertyName) { - return updateNode(createExportSpecifier(name, propertyName, node), node); - } - return node; + return node.name !== name || node.propertyName !== propertyName + ? updateNode(createExportSpecifier(name, propertyName), node) + : node; } ts.updateExportSpecifier = updateExportSpecifier; - function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(246, location); + function createExternalModuleReference(expression) { + var node = createSynthesizedNode(247); + node.expression = expression; + return node; + } + ts.createExternalModuleReference = createExternalModuleReference; + function updateExternalModuleReference(node, expression) { + return node.expression !== expression + ? updateNode(createExternalModuleReference(expression), node) + : node; + } + ts.updateExternalModuleReference = updateExternalModuleReference; + function createJsxElement(openingElement, children, closingElement) { + var node = createSynthesizedNode(248); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11723,95 +11692,107 @@ var ts; } ts.createJsxElement = createJsxElement; function updateJsxElement(node, openingElement, children, closingElement) { - if (node.openingElement !== openingElement || node.children !== children || node.closingElement !== closingElement) { - return updateNode(createJsxElement(openingElement, children, closingElement, node), node); - } - return node; + return node.openingElement !== openingElement + || node.children !== children + || node.closingElement !== closingElement + ? updateNode(createJsxElement(openingElement, children, closingElement), node) + : node; } ts.updateJsxElement = updateJsxElement; - function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(247, location); + function createJsxSelfClosingElement(tagName, attributes) { + var node = createSynthesizedNode(249); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxSelfClosingElement = createJsxSelfClosingElement; function updateJsxSelfClosingElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxSelfClosingElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxSelfClosingElement(tagName, attributes), node) + : node; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; - function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(248, location); + function createJsxOpeningElement(tagName, attributes) { + var node = createSynthesizedNode(250); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxOpeningElement = createJsxOpeningElement; function updateJsxOpeningElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxOpeningElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxOpeningElement(tagName, attributes), node) + : node; } ts.updateJsxOpeningElement = updateJsxOpeningElement; - function createJsxClosingElement(tagName, location) { - var node = createNode(249, location); + function createJsxClosingElement(tagName) { + var node = createSynthesizedNode(251); node.tagName = tagName; return node; } ts.createJsxClosingElement = createJsxClosingElement; function updateJsxClosingElement(node, tagName) { - if (node.tagName !== tagName) { - return updateNode(createJsxClosingElement(tagName, node), node); - } - return node; + return node.tagName !== tagName + ? updateNode(createJsxClosingElement(tagName), node) + : node; } ts.updateJsxClosingElement = updateJsxClosingElement; - function createJsxAttribute(name, initializer, location) { - var node = createNode(250, location); + function createJsxAttributes(properties) { + var jsxAttributes = createSynthesizedNode(253); + jsxAttributes.properties = createNodeArray(properties); + return jsxAttributes; + } + ts.createJsxAttributes = createJsxAttributes; + function updateJsxAttributes(jsxAttributes, properties) { + if (jsxAttributes.properties !== properties) { + return updateNode(createJsxAttributes(properties), jsxAttributes); + } + return jsxAttributes; + } + ts.updateJsxAttributes = updateJsxAttributes; + function createJsxAttribute(name, initializer) { + var node = createSynthesizedNode(252); node.name = name; node.initializer = initializer; return node; } ts.createJsxAttribute = createJsxAttribute; function updateJsxAttribute(node, name, initializer) { - if (node.name !== name || node.initializer !== initializer) { - return updateNode(createJsxAttribute(name, initializer, node), node); - } - return node; + return node.name !== name + || node.initializer !== initializer + ? updateNode(createJsxAttribute(name, initializer), node) + : node; } ts.updateJsxAttribute = updateJsxAttribute; - function createJsxSpreadAttribute(expression, location) { - var node = createNode(251, location); + function createJsxSpreadAttribute(expression) { + var node = createSynthesizedNode(254); node.expression = expression; return node; } ts.createJsxSpreadAttribute = createJsxSpreadAttribute; function updateJsxSpreadAttribute(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxSpreadAttribute(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxSpreadAttribute(expression), node) + : node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, location) { - var node = createNode(252, location); + function createJsxExpression(expression, dotDotDotToken) { + var node = createSynthesizedNode(255); + node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxExpression(expression, node.dotDotDotToken), node) + : node; } ts.updateJsxExpression = updateJsxExpression; - function createHeritageClause(token, types, location) { - var node = createNode(255, location); + function createHeritageClause(token, types) { + var node = createSynthesizedNode(258); node.token = token; node.types = createNodeArray(types); return node; @@ -11819,40 +11800,40 @@ var ts; ts.createHeritageClause = createHeritageClause; function updateHeritageClause(node, types) { if (node.types !== types) { - return updateNode(createHeritageClause(node.token, types, node), node); + return updateNode(createHeritageClause(node.token, types), node); } return node; } ts.updateHeritageClause = updateHeritageClause; - function createCaseClause(expression, statements, location) { - var node = createNode(253, location); - node.expression = parenthesizeExpressionForList(expression); + function createCaseClause(expression, statements) { + var node = createSynthesizedNode(256); + node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; } ts.createCaseClause = createCaseClause; function updateCaseClause(node, expression, statements) { if (node.expression !== expression || node.statements !== statements) { - return updateNode(createCaseClause(expression, statements, node), node); + return updateNode(createCaseClause(expression, statements), node); } return node; } ts.updateCaseClause = updateCaseClause; - function createDefaultClause(statements, location) { - var node = createNode(254, location); + function createDefaultClause(statements) { + var node = createSynthesizedNode(257); node.statements = createNodeArray(statements); return node; } ts.createDefaultClause = createDefaultClause; function updateDefaultClause(node, statements) { if (node.statements !== statements) { - return updateNode(createDefaultClause(statements, node), node); + return updateNode(createDefaultClause(statements), node); } return node; } ts.updateDefaultClause = updateDefaultClause; - function createCatchClause(variableDeclaration, block, location) { - var node = createNode(256, location); + function createCatchClause(variableDeclaration, block) { + var node = createSynthesizedNode(259); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11860,56 +11841,71 @@ var ts; ts.createCatchClause = createCatchClause; function updateCatchClause(node, variableDeclaration, block) { if (node.variableDeclaration !== variableDeclaration || node.block !== block) { - return updateNode(createCatchClause(variableDeclaration, block, node), node); + return updateNode(createCatchClause(variableDeclaration, block), node); } return node; } ts.updateCatchClause = updateCatchClause; - function createPropertyAssignment(name, initializer, location) { - var node = createNode(257, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAssignment(name, initializer) { + var node = createSynthesizedNode(260); + node.name = asName(name); node.questionToken = undefined; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createPropertyAssignment = createPropertyAssignment; function updatePropertyAssignment(node, name, initializer) { if (node.name !== name || node.initializer !== initializer) { - return updateNode(createPropertyAssignment(name, initializer, node), node); + return updateNode(createPropertyAssignment(name, initializer), node); } return node; } ts.updatePropertyAssignment = updatePropertyAssignment; - function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(258, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; + function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { + var node = createSynthesizedNode(261); + node.name = asName(name); + node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; - function createSpreadAssignment(expression, location) { - var node = createNode(259, location); - node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; + function createSpreadAssignment(expression) { + var node = createSynthesizedNode(262); + node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; return node; } ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { - return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node); + return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node); } return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function updateSpreadAssignment(node, expression) { if (node.expression !== expression) { - return updateNode(createSpreadAssignment(expression, node), node); + return updateNode(createSpreadAssignment(expression), node); } return node; } ts.updateSpreadAssignment = updateSpreadAssignment; + function createEnumMember(name, initializer) { + var node = createSynthesizedNode(263); + node.name = asName(name); + node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); + return node; + } + ts.createEnumMember = createEnumMember; + function updateEnumMember(node, name, initializer) { + return node.name !== name + || node.initializer !== initializer + ? updateNode(createEnumMember(name, initializer), node) + : node; + } + ts.updateEnumMember = updateEnumMember; function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(261, node, node.flags); + var updated = createSynthesizedNode(264); + updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -11968,56 +11964,73 @@ var ts; return node; } ts.updateSourceFileNode = updateSourceFileNode; + function getMutableClone(node) { + var clone = getSynthesizedClone(node); + clone.pos = node.pos; + clone.end = node.end; + clone.parent = node.parent; + return clone; + } + ts.getMutableClone = getMutableClone; function createNotEmittedStatement(original) { - var node = createNode(293, original); + var node = createSynthesizedNode(297); node.original = original; + setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createNode(296); + var node = createSynthesizedNode(300); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createNode(295); + var node = createSynthesizedNode(299); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; - function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(294, location || original); + function createPartiallyEmittedExpression(expression, original) { + var node = createSynthesizedNode(298); node.expression = expression; node.original = original; + setTextRange(node, original); return node; } ts.createPartiallyEmittedExpression = createPartiallyEmittedExpression; function updatePartiallyEmittedExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createPartiallyEmittedExpression(expression, node.original, node), node); + return updateNode(createPartiallyEmittedExpression(expression, node.original), node); } return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; - function createRawExpression(text) { - var node = createNode(297); - node.text = text; + function createBundle(sourceFiles) { + var node = ts.createNode(265); + node.sourceFiles = sourceFiles; return node; } - ts.createRawExpression = createRawExpression; + ts.createBundle = createBundle; + function updateBundle(node, sourceFiles) { + if (node.sourceFiles !== sourceFiles) { + return createBundle(sourceFiles); + } + return node; + } + ts.updateBundle = updateBundle; function createComma(left, right) { return createBinary(left, 25, right); } ts.createComma = createComma; - function createLessThan(left, right, location) { - return createBinary(left, 26, right, location); + function createLessThan(left, right) { + return createBinary(left, 26, right); } ts.createLessThan = createLessThan; - function createAssignment(left, right, location) { - return createBinary(left, 57, right, location); + function createAssignment(left, right) { + return createBinary(left, 57, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { @@ -12036,8 +12049,8 @@ var ts; return createBinary(left, 37, right); } ts.createSubtract = createSubtract; - function createPostfixIncrement(operand, location) { - return createPostfix(operand, 42, location); + function createPostfixIncrement(operand) { + return createPostfix(operand, 42); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { @@ -12056,97 +12069,6 @@ var ts; return createVoid(createLiteral(0)); } ts.createVoidZero = createVoidZero; - function createTypeCheck(value, tag) { - return tag === "undefined" - ? createStrictEquality(value, createVoidZero()) - : createStrictEquality(createTypeOf(value), createLiteral(tag)); - } - ts.createTypeCheck = createTypeCheck; - function createMemberAccessForPropertyName(target, memberName, location) { - if (ts.isComputedPropertyName(memberName)) { - return createElementAccess(target, memberName.expression, location); - } - else { - var expression = ts.isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); - (expression.emitNode || (expression.emitNode = {})).flags |= 64; - return expression; - } - } - ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; - function createFunctionCall(func, thisArg, argumentsList, location) { - return createCall(createPropertyAccess(func, "call"), undefined, [ - thisArg - ].concat(argumentsList), location); - } - ts.createFunctionCall = createFunctionCall; - function createFunctionApply(func, thisArg, argumentsExpression, location) { - return createCall(createPropertyAccess(func, "apply"), undefined, [ - thisArg, - argumentsExpression - ], location); - } - ts.createFunctionApply = createFunctionApply; - function createArraySlice(array, start) { - var argumentsList = []; - if (start !== undefined) { - argumentsList.push(typeof start === "number" ? createLiteral(start) : start); - } - return createCall(createPropertyAccess(array, "slice"), undefined, argumentsList); - } - ts.createArraySlice = createArraySlice; - function createArrayConcat(array, values) { - return createCall(createPropertyAccess(array, "concat"), undefined, values); - } - ts.createArrayConcat = createArrayConcat; - function createMathPow(left, right, location) { - return createCall(createPropertyAccess(createIdentifier("Math"), "pow"), undefined, [left, right], location); - } - ts.createMathPow = createMathPow; - function createReactNamespace(reactNamespace, parent) { - var react = createIdentifier(reactNamespace || "React"); - react.flags &= ~8; - react.parent = ts.getParseTreeNode(parent); - return react; - } - function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { - if (ts.isQualifiedName(jsxFactory)) { - var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent); - var right = createSynthesizedNode(70); - right.text = jsxFactory.right.text; - return createPropertyAccess(left, right); - } - else { - return createReactNamespace(jsxFactory.text, parent); - } - } - function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { - return jsxFactoryEntity ? - createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : - createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); - } - function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { - var argumentsList = [tagName]; - if (props) { - argumentsList.push(props); - } - if (children && children.length > 0) { - if (!props) { - argumentsList.push(createNull()); - } - if (children.length > 1) { - for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { - var child = children_1[_i]; - child.startsOnNewLine = true; - argumentsList.push(child); - } - } - else { - argumentsList.push(children[0]); - } - } - return createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList, location); - } - ts.createExpressionForJsxElement = createExpressionForJsxElement; function createExportDefault(expression) { return createExportAssignment(undefined, undefined, false, expression); } @@ -12155,573 +12077,17 @@ var ts; return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(exportName)])); } ts.createExternalModuleExport = createExternalModuleExport; - function createLetStatement(name, initializer, location) { - return createVariableStatement(undefined, createLetDeclarationList([createVariableDeclaration(name, undefined, initializer)]), location); + function asName(name) { + return typeof name === "string" ? createIdentifier(name) : name; } - ts.createLetStatement = createLetStatement; - function createLetDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 1); + function asExpression(value) { + return typeof value === "string" || typeof value === "number" ? createLiteral(value) : value; } - ts.createLetDeclarationList = createLetDeclarationList; - function createConstDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 2); + function asNodeArray(array) { + return array ? createNodeArray(array) : undefined; } - ts.createConstDeclarationList = createConstDeclarationList; - function getHelperName(name) { - return setEmitFlags(createIdentifier(name), 4096 | 2); - } - ts.getHelperName = getHelperName; - function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { - var target = skipParentheses(node); - switch (target.kind) { - case 70: - return cacheIdentifiers; - case 98: - case 8: - case 9: - return false; - case 175: - var elements = target.elements; - if (elements.length === 0) { - return false; - } - return true; - case 176: - return target.properties.length > 0; - default: - return true; - } - } - function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { - var callee = skipOuterExpressions(expression, 7); - var thisArg; - var target; - if (ts.isSuperProperty(callee)) { - thisArg = createThis(); - target = callee; - } - else if (callee.kind === 96) { - thisArg = createThis(); - target = languageVersion < 2 ? createIdentifier("_super", callee) : callee; - } - else { - switch (callee.kind) { - case 177: { - if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { - thisArg = createTempVariable(recordTempVariable); - target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); - } - else { - thisArg = callee.expression; - target = callee; - } - break; - } - case 178: { - if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { - thisArg = createTempVariable(recordTempVariable); - target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); - } - else { - thisArg = callee.expression; - target = callee; - } - break; - } - default: { - thisArg = createVoidZero(); - target = parenthesizeForAccess(expression); - break; - } - } - } - return { target: target, thisArg: thisArg }; - } - ts.createCallBinding = createCallBinding; - function inlineExpressions(expressions) { - return ts.reduceLeft(expressions, createComma); - } - ts.inlineExpressions = inlineExpressions; - function createExpressionFromEntityName(node) { - if (ts.isQualifiedName(node)) { - var left = createExpressionFromEntityName(node.left); - var right = getMutableClone(node.right); - return createPropertyAccess(left, right, node); - } - else { - return getMutableClone(node); - } - } - ts.createExpressionFromEntityName = createExpressionFromEntityName; - function createExpressionForPropertyName(memberName) { - if (ts.isIdentifier(memberName)) { - return createLiteral(memberName, undefined); - } - else if (ts.isComputedPropertyName(memberName)) { - return getMutableClone(memberName.expression); - } - else { - return getMutableClone(memberName); - } - } - ts.createExpressionForPropertyName = createExpressionForPropertyName; - function createExpressionForObjectLiteralElementLike(node, property, receiver) { - switch (property.kind) { - case 151: - case 152: - return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 257: - return createExpressionForPropertyAssignment(property, receiver); - case 258: - return createExpressionForShorthandPropertyAssignment(property, receiver); - case 149: - return createExpressionForMethodDeclaration(property, receiver); - } - } - ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike; - function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { - var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; - if (property === firstAccessor) { - var properties_1 = []; - if (getAccessor) { - var getterFunction = createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body, getAccessor); - setOriginalNode(getterFunction, getAccessor); - var getter = createPropertyAssignment("get", getterFunction); - properties_1.push(getter); - } - if (setAccessor) { - var setterFunction = createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body, setAccessor); - setOriginalNode(setterFunction, setAccessor); - var setter = createPropertyAssignment("set", setterFunction); - properties_1.push(setter); - } - properties_1.push(createPropertyAssignment("enumerable", createLiteral(true))); - properties_1.push(createPropertyAssignment("configurable", createLiteral(true))); - var expression = createCall(createPropertyAccess(createIdentifier("Object"), "defineProperty"), undefined, [ - receiver, - createExpressionForPropertyName(property.name), - createObjectLiteral(properties_1, undefined, multiLine) - ], firstAccessor); - return ts.aggregateTransformFlags(expression); - } - return undefined; - } - function createExpressionForPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), property.initializer, property), property)); - } - function createExpressionForShorthandPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), getSynthesizedClone(property.name), property), property)); - } - function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); - } - function getLocalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384); - } - ts.getLocalName = getLocalName; - function isLocalName(node) { - return (getEmitFlags(node) & 16384) !== 0; - } - ts.isLocalName = isLocalName; - function getExportName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 8192); - } - ts.getExportName = getExportName; - function isExportName(node) { - return (getEmitFlags(node) & 8192) !== 0; - } - ts.isExportName = isExportName; - function getDeclarationName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps); - } - ts.getDeclarationName = getDeclarationName; - function getName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { - var name_10 = getMutableClone(node.name); - emitFlags |= getEmitFlags(node.name); - if (!allowSourceMaps) - emitFlags |= 48; - if (!allowComments) - emitFlags |= 1536; - if (emitFlags) - setEmitFlags(name_10, emitFlags); - return name_10; - } - return getGeneratedNameForNode(node); - } - function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && ts.hasModifier(node, 1)) { - return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); - } - return getExportName(node, allowComments, allowSourceMaps); - } - ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName; - function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { - var qualifiedName = createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : getSynthesizedClone(name), name); - var emitFlags; - if (!allowSourceMaps) - emitFlags |= 48; - if (!allowComments) - emitFlags |= 1536; - if (emitFlags) - setEmitFlags(qualifiedName, emitFlags); - return qualifiedName; - } - ts.getNamespaceMemberName = getNamespaceMemberName; - function convertToFunctionBody(node, multiLine) { - return ts.isBlock(node) ? node : createBlock([createReturn(node, node)], node, multiLine); - } - ts.convertToFunctionBody = convertToFunctionBody; - function isUseStrictPrologue(node) { - return node.expression.text === "use strict"; - } - function addPrologueDirectives(target, source, ensureUseStrict, visitor) { - ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); - var foundUseStrict = false; - var statementOffset = 0; - var numStatements = source.length; - while (statementOffset < numStatements) { - var statement = source[statementOffset]; - if (ts.isPrologueDirective(statement)) { - if (isUseStrictPrologue(statement)) { - foundUseStrict = true; - } - target.push(statement); - } - else { - break; - } - statementOffset++; - } - if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); - } - while (statementOffset < numStatements) { - var statement = source[statementOffset]; - if (getEmitFlags(statement) & 524288) { - target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); - } - else { - break; - } - statementOffset++; - } - return statementOffset; - } - ts.addPrologueDirectives = addPrologueDirectives; - function startsWithUseStrict(statements) { - var firstStatement = ts.firstOrUndefined(statements); - return firstStatement !== undefined - && ts.isPrologueDirective(firstStatement) - && isUseStrictPrologue(firstStatement); - } - ts.startsWithUseStrict = startsWithUseStrict; - function ensureUseStrict(statements) { - var foundUseStrict = false; - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; - if (ts.isPrologueDirective(statement)) { - if (isUseStrictPrologue(statement)) { - foundUseStrict = true; - break; - } - } - else { - break; - } - } - if (!foundUseStrict) { - return createNodeArray([ - startOnNewLine(createStatement(createLiteral("use strict"))) - ].concat(statements), statements); - } - return statements; - } - ts.ensureUseStrict = ensureUseStrict; - function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 183) { - return operand; - } - return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) - ? createParen(operand) - : operand; - } - ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; - function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(192, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(192, binaryOperator); - var emittedOperand = skipPartiallyEmittedExpressions(operand); - var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); - switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { - case -1: - if (!isLeftSideOfBinary - && binaryOperatorAssociativity === 1 - && operand.kind === 195) { - return false; - } - return true; - case 1: - return false; - case 0: - if (isLeftSideOfBinary) { - return binaryOperatorAssociativity === 1; - } - else { - if (ts.isBinaryExpression(emittedOperand) - && emittedOperand.operatorToken.kind === binaryOperator) { - if (operatorHasAssociativeProperty(binaryOperator)) { - return false; - } - if (binaryOperator === 36) { - var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; - if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { - return false; - } - } - } - var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); - return operandAssociativity === 0; - } - } - } - function operatorHasAssociativeProperty(binaryOperator) { - return binaryOperator === 38 - || binaryOperator === 48 - || binaryOperator === 47 - || binaryOperator === 49; - } - function getLiteralKindOfBinaryPlusOperand(node) { - node = skipPartiallyEmittedExpressions(node); - if (ts.isLiteralKind(node.kind)) { - return node.kind; - } - if (node.kind === 192 && node.operatorToken.kind === 36) { - if (node.cachedLiteralKind !== undefined) { - return node.cachedLiteralKind; - } - var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0; - node.cachedLiteralKind = literalKind; - return literalKind; - } - return 0; - } - function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(193, 54); - var emittedCondition = skipPartiallyEmittedExpressions(condition); - var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { - return createParen(condition); - } - return condition; - } - ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; - function parenthesizeSubexpressionOfConditionalExpression(e) { - return e.kind === 192 && e.operatorToken.kind === 25 - ? createParen(e) - : e; - } - function parenthesizeForNew(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - switch (emittedExpression.kind) { - case 179: - return createParen(expression); - case 180: - return emittedExpression.arguments - ? expression - : createParen(expression); - } - return parenthesizeForAccess(expression); - } - ts.parenthesizeForNew = parenthesizeForNew; - function parenthesizeForAccess(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 180 || emittedExpression.arguments) - && emittedExpression.kind !== 8) { - return expression; - } - return createParen(expression, expression); - } - ts.parenthesizeForAccess = parenthesizeForAccess; - function parenthesizePostfixOperand(operand) { - return ts.isLeftHandSideExpression(operand) - ? operand - : createParen(operand, operand); - } - ts.parenthesizePostfixOperand = parenthesizePostfixOperand; - function parenthesizePrefixOperand(operand) { - return ts.isUnaryExpression(operand) - ? operand - : createParen(operand, operand); - } - ts.parenthesizePrefixOperand = parenthesizePrefixOperand; - function parenthesizeListElements(elements) { - var result; - for (var i = 0; i < elements.length; i++) { - var element = parenthesizeExpressionForList(elements[i]); - if (result !== undefined || element !== elements[i]) { - if (result === undefined) { - result = elements.slice(0, i); - } - result.push(element); - } - } - if (result !== undefined) { - return createNodeArray(result, elements, elements.hasTrailingComma); - } - return elements; - } - function parenthesizeExpressionForList(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(192, 25); - return expressionPrecedence > commaPrecedence - ? expression - : createParen(expression, expression); - } - ts.parenthesizeExpressionForList = parenthesizeExpressionForList; - function parenthesizeExpressionForExpressionStatement(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - if (ts.isCallExpression(emittedExpression)) { - var callee = emittedExpression.expression; - var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 184 || kind === 185) { - var mutableCall = getMutableClone(emittedExpression); - mutableCall.expression = createParen(callee, callee); - return recreatePartiallyEmittedExpressions(expression, mutableCall); - } - } - else { - var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 176 || leftmostExpressionKind === 184) { - return createParen(expression, expression); - } - } - return expression; - } - ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; - function recreatePartiallyEmittedExpressions(originalOuterExpression, newInnerExpression) { - if (ts.isPartiallyEmittedExpression(originalOuterExpression)) { - var clone_1 = getMutableClone(originalOuterExpression); - clone_1.expression = recreatePartiallyEmittedExpressions(clone_1.expression, newInnerExpression); - return clone_1; - } - return newInnerExpression; - } - function getLeftmostExpression(node) { - while (true) { - switch (node.kind) { - case 191: - node = node.operand; - continue; - case 192: - node = node.left; - continue; - case 193: - node = node.condition; - continue; - case 179: - case 178: - case 177: - node = node.expression; - continue; - case 294: - node = node.expression; - continue; - } - return node; - } - } - function parenthesizeConciseBody(body) { - var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 176) { - return createParen(body, body); - } - return body; - } - ts.parenthesizeConciseBody = parenthesizeConciseBody; - function skipOuterExpressions(node, kinds) { - if (kinds === void 0) { kinds = 7; } - var previousNode; - do { - previousNode = node; - if (kinds & 1) { - node = skipParentheses(node); - } - if (kinds & 2) { - node = skipAssertions(node); - } - if (kinds & 4) { - node = skipPartiallyEmittedExpressions(node); - } - } while (previousNode !== node); - return node; - } - ts.skipOuterExpressions = skipOuterExpressions; - function skipParentheses(node) { - while (node.kind === 183) { - node = node.expression; - } - return node; - } - ts.skipParentheses = skipParentheses; - function skipAssertions(node) { - while (ts.isAssertionExpression(node)) { - node = node.expression; - } - return node; - } - ts.skipAssertions = skipAssertions; - function skipPartiallyEmittedExpressions(node) { - while (node.kind === 294) { - node = node.expression; - } - return node; - } - ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; - function startOnNewLine(node) { - node.startsOnNewLine = true; - return node; - } - ts.startOnNewLine = startOnNewLine; - function setOriginalNode(node, original) { - node.original = original; - if (original) { - var emitNode = original.emitNode; - if (emitNode) - node.emitNode = mergeEmitNode(emitNode, node.emitNode); - } - return node; - } - ts.setOriginalNode = setOriginalNode; - function mergeEmitNode(sourceEmitNode, destEmitNode) { - var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; - if (!destEmitNode) - destEmitNode = {}; - if (flags) - destEmitNode.flags = flags; - if (commentRange) - destEmitNode.commentRange = commentRange; - if (sourceMapRange) - destEmitNode.sourceMapRange = sourceMapRange; - if (tokenSourceMapRanges) - destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); - if (constantValue !== undefined) - destEmitNode.constantValue = constantValue; - if (helpers) - destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); - return destEmitNode; - } - function mergeTokenSourceMapRanges(sourceRanges, destRanges) { - if (!destRanges) - destRanges = ts.createMap(); - ts.copyProperties(sourceRanges, destRanges); - return destRanges; + function asToken(value) { + return typeof value === "number" ? createToken(value) : value; } function disposeEmitNodes(sourceFile) { sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); @@ -12738,7 +12104,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 261) { + if (node.kind === 264) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -12749,6 +12115,14 @@ var ts; return node.emitNode; } ts.getOrCreateEmitNode = getOrCreateEmitNode; + function setTextRange(range, location) { + if (location) { + range.pos = location.pos; + range.end = location.end; + } + return range; + } + ts.setTextRange = setTextRange; function getEmitFlags(node) { var emitNode = node.emitNode; return emitNode && emitNode.flags; @@ -12777,7 +12151,7 @@ var ts; ts.getTokenSourceMapRange = getTokenSourceMapRange; function setTokenSourceMapRange(node, token, range) { var emitNode = getOrCreateEmitNode(node); - var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = ts.createMap()); + var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = []); tokenSourceMapRanges[token] = range; return node; } @@ -12803,32 +12177,6 @@ var ts; return node; } ts.setConstantValue = setConstantValue; - function getExternalHelpersModuleName(node) { - var parseNode = ts.getOriginalNode(node, ts.isSourceFile); - var emitNode = parseNode && parseNode.emitNode; - return emitNode && emitNode.externalHelpersModuleName; - } - ts.getExternalHelpersModuleName = getExternalHelpersModuleName; - function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions) { - if (compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { - var externalHelpersModuleName = getExternalHelpersModuleName(node); - if (externalHelpersModuleName) { - return externalHelpersModuleName; - } - var helpers = getEmitHelpers(node); - if (helpers) { - for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { - var helper = helpers_1[_i]; - if (!helper.scoped) { - var parseNode = ts.getOriginalNode(node, ts.isSourceFile); - var emitNode = getOrCreateEmitNode(parseNode); - return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = createUniqueName(ts.externalHelpersModuleNameText)); - } - } - } - } - } - ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded; function addEmitHelper(node, helper) { var emitNode = getOrCreateEmitNode(node); emitNode.helpers = ts.append(emitNode.helpers, helper); @@ -12838,8 +12186,8 @@ var ts; function addEmitHelpers(node, helpers) { if (ts.some(helpers)) { var emitNode = getOrCreateEmitNode(node); - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; + for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { + var helper = helpers_1[_i]; if (!ts.contains(emitNode.helpers, helper)) { emitNode.helpers = ts.append(emitNode.helpers, helper); } @@ -12900,40 +12248,725 @@ var ts; return ts.compareValues(x.priority, y.priority); } ts.compareEmitHelpers = compareEmitHelpers; - function setTextRange(node, location) { - if (location) { - node.pos = location.pos; - node.end = location.end; + function setOriginalNode(node, original) { + node.original = original; + if (original) { + var emitNode = original.emitNode; + if (emitNode) + node.emitNode = mergeEmitNode(emitNode, node.emitNode); } return node; } - ts.setTextRange = setTextRange; - function setNodeFlags(node, flags) { - node.flags = flags; + ts.setOriginalNode = setOriginalNode; + function mergeEmitNode(sourceEmitNode, destEmitNode) { + var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; + if (!destEmitNode) + destEmitNode = {}; + if (flags) + destEmitNode.flags = flags; + if (commentRange) + destEmitNode.commentRange = commentRange; + if (sourceMapRange) + destEmitNode.sourceMapRange = sourceMapRange; + if (tokenSourceMapRanges) + destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); + if (constantValue !== undefined) + destEmitNode.constantValue = constantValue; + if (helpers) + destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); + return destEmitNode; + } + function mergeTokenSourceMapRanges(sourceRanges, destRanges) { + if (!destRanges) + destRanges = []; + for (var key in sourceRanges) { + destRanges[key] = sourceRanges[key]; + } + return destRanges; + } +})(ts || (ts = {})); +(function (ts) { + function createTypeCheck(value, tag) { + return tag === "undefined" + ? ts.createStrictEquality(value, ts.createVoidZero()) + : ts.createStrictEquality(ts.createTypeOf(value), ts.createLiteral(tag)); + } + ts.createTypeCheck = createTypeCheck; + function createMemberAccessForPropertyName(target, memberName, location) { + if (ts.isComputedPropertyName(memberName)) { + return ts.setTextRange(ts.createElementAccess(target, memberName.expression), location); + } + else { + var expression = ts.setTextRange(ts.isIdentifier(memberName) + ? ts.createPropertyAccess(target, memberName) + : ts.createElementAccess(target, memberName), memberName); + ts.getOrCreateEmitNode(expression).flags |= 64; + return expression; + } + } + ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; + function createFunctionCall(func, thisArg, argumentsList, location) { + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), undefined, [ + thisArg + ].concat(argumentsList)), location); + } + ts.createFunctionCall = createFunctionCall; + function createFunctionApply(func, thisArg, argumentsExpression, location) { + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "apply"), undefined, [ + thisArg, + argumentsExpression + ]), location); + } + ts.createFunctionApply = createFunctionApply; + function createArraySlice(array, start) { + var argumentsList = []; + if (start !== undefined) { + argumentsList.push(typeof start === "number" ? ts.createLiteral(start) : start); + } + return ts.createCall(ts.createPropertyAccess(array, "slice"), undefined, argumentsList); + } + ts.createArraySlice = createArraySlice; + function createArrayConcat(array, values) { + return ts.createCall(ts.createPropertyAccess(array, "concat"), undefined, values); + } + ts.createArrayConcat = createArrayConcat; + function createMathPow(left, right, location) { + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Math"), "pow"), undefined, [left, right]), location); + } + ts.createMathPow = createMathPow; + function createReactNamespace(reactNamespace, parent) { + var react = ts.createIdentifier(reactNamespace || "React"); + react.flags &= ~8; + react.parent = ts.getParseTreeNode(parent); + return react; + } + function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { + if (ts.isQualifiedName(jsxFactory)) { + var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent); + var right = ts.createIdentifier(jsxFactory.right.text); + right.text = jsxFactory.right.text; + return ts.createPropertyAccess(left, right); + } + else { + return createReactNamespace(jsxFactory.text, parent); + } + } + function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { + return jsxFactoryEntity ? + createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : + ts.createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); + } + function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { + var argumentsList = [tagName]; + if (props) { + argumentsList.push(props); + } + if (children && children.length > 0) { + if (!props) { + argumentsList.push(ts.createNull()); + } + if (children.length > 1) { + for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { + var child = children_1[_i]; + child.startsOnNewLine = true; + argumentsList.push(child); + } + } + else { + argumentsList.push(children[0]); + } + } + return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList), location); + } + ts.createExpressionForJsxElement = createExpressionForJsxElement; + function getHelperName(name) { + return ts.setEmitFlags(ts.createIdentifier(name), 4096 | 2); + } + ts.getHelperName = getHelperName; + function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { + if (!outermostLabeledStatement) { + return node; + } + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 221 + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + ts.restoreEnclosingLabel = restoreEnclosingLabel; + function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { + var target = skipParentheses(node); + switch (target.kind) { + case 70: + return cacheIdentifiers; + case 98: + case 8: + case 9: + return false; + case 176: + var elements = target.elements; + if (elements.length === 0) { + return false; + } + return true; + case 177: + return target.properties.length > 0; + default: + return true; + } + } + function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { + var callee = skipOuterExpressions(expression, 7); + var thisArg; + var target; + if (ts.isSuperProperty(callee)) { + thisArg = ts.createThis(); + target = callee; + } + else if (callee.kind === 96) { + thisArg = ts.createThis(); + target = languageVersion < 2 + ? ts.setTextRange(ts.createIdentifier("_super"), callee) + : callee; + } + else { + switch (callee.kind) { + case 178: { + if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); + ts.setTextRange(target, callee); + } + else { + thisArg = callee.expression; + target = callee; + } + break; + } + case 179: { + if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); + ts.setTextRange(target, callee); + } + else { + thisArg = callee.expression; + target = callee; + } + break; + } + default: { + thisArg = ts.createVoidZero(); + target = parenthesizeForAccess(expression); + break; + } + } + } + return { target: target, thisArg: thisArg }; + } + ts.createCallBinding = createCallBinding; + function inlineExpressions(expressions) { + return ts.reduceLeft(expressions, ts.createComma); + } + ts.inlineExpressions = inlineExpressions; + function createExpressionFromEntityName(node) { + if (ts.isQualifiedName(node)) { + var left = createExpressionFromEntityName(node.left); + var right = ts.getMutableClone(node.right); + return ts.setTextRange(ts.createPropertyAccess(left, right), node); + } + else { + return ts.getMutableClone(node); + } + } + ts.createExpressionFromEntityName = createExpressionFromEntityName; + function createExpressionForPropertyName(memberName) { + if (ts.isIdentifier(memberName)) { + return ts.createLiteral(memberName); + } + else if (ts.isComputedPropertyName(memberName)) { + return ts.getMutableClone(memberName.expression); + } + else { + return ts.getMutableClone(memberName); + } + } + ts.createExpressionForPropertyName = createExpressionForPropertyName; + function createExpressionForObjectLiteralElementLike(node, property, receiver) { + switch (property.kind) { + case 152: + case 153: + return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); + case 260: + return createExpressionForPropertyAssignment(property, receiver); + case 261: + return createExpressionForShorthandPropertyAssignment(property, receiver); + case 150: + return createExpressionForMethodDeclaration(property, receiver); + } + } + ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike; + function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { + var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + if (property === firstAccessor) { + var properties_1 = []; + if (getAccessor) { + var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body); + ts.setTextRange(getterFunction, getAccessor); + ts.setOriginalNode(getterFunction, getAccessor); + var getter = ts.createPropertyAssignment("get", getterFunction); + properties_1.push(getter); + } + if (setAccessor) { + var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body); + ts.setTextRange(setterFunction, setAccessor); + ts.setOriginalNode(setterFunction, setAccessor); + var setter = ts.createPropertyAssignment("set", setterFunction); + properties_1.push(setter); + } + properties_1.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_1.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + receiver, + createExpressionForPropertyName(property.name), + ts.createObjectLiteral(properties_1, multiLine) + ]), firstAccessor); + return ts.aggregateTransformFlags(expression); + } + return undefined; + } + function createExpressionForPropertyAssignment(property, receiver) { + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), property.initializer), property), property)); + } + function createExpressionForShorthandPropertyAssignment(property, receiver) { + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), ts.getSynthesizedClone(property.name)), property), property)); + } + function createExpressionForMethodDeclaration(method, receiver) { + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body), method), method)), method), method)); + } + function getLocalName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 16384); + } + ts.getLocalName = getLocalName; + function isLocalName(node) { + return (ts.getEmitFlags(node) & 16384) !== 0; + } + ts.isLocalName = isLocalName; + function getExportName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 8192); + } + ts.getExportName = getExportName; + function isExportName(node) { + return (ts.getEmitFlags(node) & 8192) !== 0; + } + ts.isExportName = isExportName; + function getDeclarationName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps); + } + ts.getDeclarationName = getDeclarationName; + function getName(node, allowComments, allowSourceMaps, emitFlags) { + if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { + var name = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); + if (!allowSourceMaps) + emitFlags |= 48; + if (!allowComments) + emitFlags |= 1536; + if (emitFlags) + ts.setEmitFlags(name, emitFlags); + return name; + } + return ts.getGeneratedNameForNode(node); + } + function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { + if (ns && ts.hasModifier(node, 1)) { + return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); + } + return getExportName(node, allowComments, allowSourceMaps); + } + ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName; + function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { + var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name)); + ts.setTextRange(qualifiedName, name); + var emitFlags; + if (!allowSourceMaps) + emitFlags |= 48; + if (!allowComments) + emitFlags |= 1536; + if (emitFlags) + ts.setEmitFlags(qualifiedName, emitFlags); + return qualifiedName; + } + ts.getNamespaceMemberName = getNamespaceMemberName; + function convertToFunctionBody(node, multiLine) { + return ts.isBlock(node) ? node : ts.setTextRange(ts.createBlock([ts.setTextRange(ts.createReturn(node), node)], multiLine), node); + } + ts.convertToFunctionBody = convertToFunctionBody; + function isUseStrictPrologue(node) { + return node.expression.text === "use strict"; + } + function addPrologueDirectives(target, source, ensureUseStrict, visitor) { + ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); + var foundUseStrict = false; + var statementOffset = 0; + var numStatements = source.length; + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + } + target.push(statement); + } + else { + break; + } + statementOffset++; + } + if (ensureUseStrict && !foundUseStrict) { + target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))); + } + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (ts.getEmitFlags(statement) & 524288) { + target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); + } + else { + break; + } + statementOffset++; + } + return statementOffset; + } + ts.addPrologueDirectives = addPrologueDirectives; + function startsWithUseStrict(statements) { + var firstStatement = ts.firstOrUndefined(statements); + return firstStatement !== undefined + && ts.isPrologueDirective(firstStatement) + && isUseStrictPrologue(firstStatement); + } + ts.startsWithUseStrict = startsWithUseStrict; + function ensureUseStrict(statements) { + var foundUseStrict = false; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + break; + } + } + else { + break; + } + } + if (!foundUseStrict) { + return ts.setTextRange(ts.createNodeArray([ + startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) + ].concat(statements)), statements); + } + return statements; + } + ts.ensureUseStrict = ensureUseStrict; + function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { + var skipped = skipPartiallyEmittedExpressions(operand); + if (skipped.kind === 184) { + return operand; + } + return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) + ? ts.createParen(operand) + : operand; + } + ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; + function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { + var binaryOperatorPrecedence = ts.getOperatorPrecedence(193, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(193, binaryOperator); + var emittedOperand = skipPartiallyEmittedExpressions(operand); + var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); + switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { + case -1: + if (!isLeftSideOfBinary + && binaryOperatorAssociativity === 1 + && operand.kind === 196) { + return false; + } + return true; + case 1: + return false; + case 0: + if (isLeftSideOfBinary) { + return binaryOperatorAssociativity === 1; + } + else { + if (ts.isBinaryExpression(emittedOperand) + && emittedOperand.operatorToken.kind === binaryOperator) { + if (operatorHasAssociativeProperty(binaryOperator)) { + return false; + } + if (binaryOperator === 36) { + var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; + if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { + return false; + } + } + } + var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); + return operandAssociativity === 0; + } + } + } + function operatorHasAssociativeProperty(binaryOperator) { + return binaryOperator === 38 + || binaryOperator === 48 + || binaryOperator === 47 + || binaryOperator === 49; + } + function getLiteralKindOfBinaryPlusOperand(node) { + node = skipPartiallyEmittedExpressions(node); + if (ts.isLiteralKind(node.kind)) { + return node.kind; + } + if (node.kind === 193 && node.operatorToken.kind === 36) { + if (node.cachedLiteralKind !== undefined) { + return node.cachedLiteralKind; + } + var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); + var literalKind = ts.isLiteralKind(leftKind) + && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) + ? leftKind + : 0; + node.cachedLiteralKind = literalKind; + return literalKind; + } + return 0; + } + function parenthesizeForConditionalHead(condition) { + var conditionalPrecedence = ts.getOperatorPrecedence(194, 54); + var emittedCondition = skipPartiallyEmittedExpressions(condition); + var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { + return ts.createParen(condition); + } + return condition; + } + ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; + function parenthesizeSubexpressionOfConditionalExpression(e) { + return e.kind === 193 && e.operatorToken.kind === 25 + ? ts.createParen(e) + : e; + } + ts.parenthesizeSubexpressionOfConditionalExpression = parenthesizeSubexpressionOfConditionalExpression; + function parenthesizeForNew(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + switch (emittedExpression.kind) { + case 180: + return ts.createParen(expression); + case 181: + return emittedExpression.arguments + ? expression + : ts.createParen(expression); + } + return parenthesizeForAccess(expression); + } + ts.parenthesizeForNew = parenthesizeForNew; + function parenthesizeForAccess(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + if (ts.isLeftHandSideExpression(emittedExpression) + && (emittedExpression.kind !== 181 || emittedExpression.arguments) + && emittedExpression.kind !== 8) { + return expression; + } + return ts.setTextRange(ts.createParen(expression), expression); + } + ts.parenthesizeForAccess = parenthesizeForAccess; + function parenthesizePostfixOperand(operand) { + return ts.isLeftHandSideExpression(operand) + ? operand + : ts.setTextRange(ts.createParen(operand), operand); + } + ts.parenthesizePostfixOperand = parenthesizePostfixOperand; + function parenthesizePrefixOperand(operand) { + return ts.isUnaryExpression(operand) + ? operand + : ts.setTextRange(ts.createParen(operand), operand); + } + ts.parenthesizePrefixOperand = parenthesizePrefixOperand; + function parenthesizeListElements(elements) { + var result; + for (var i = 0; i < elements.length; i++) { + var element = parenthesizeExpressionForList(elements[i]); + if (result !== undefined || element !== elements[i]) { + if (result === undefined) { + result = elements.slice(0, i); + } + result.push(element); + } + } + if (result !== undefined) { + return ts.setTextRange(ts.createNodeArray(result, elements.hasTrailingComma), elements); + } + return elements; + } + ts.parenthesizeListElements = parenthesizeListElements; + function parenthesizeExpressionForList(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); + var commaPrecedence = ts.getOperatorPrecedence(193, 25); + return expressionPrecedence > commaPrecedence + ? expression + : ts.setTextRange(ts.createParen(expression), expression); + } + ts.parenthesizeExpressionForList = parenthesizeExpressionForList; + function parenthesizeExpressionForExpressionStatement(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + if (ts.isCallExpression(emittedExpression)) { + var callee = emittedExpression.expression; + var kind = skipPartiallyEmittedExpressions(callee).kind; + if (kind === 185 || kind === 186) { + var mutableCall = ts.getMutableClone(emittedExpression); + mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); + return recreatePartiallyEmittedExpressions(expression, mutableCall); + } + } + else { + var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; + if (leftmostExpressionKind === 177 || leftmostExpressionKind === 185) { + return ts.setTextRange(ts.createParen(expression), expression); + } + } + return expression; + } + ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; + function recreatePartiallyEmittedExpressions(originalOuterExpression, newInnerExpression) { + if (ts.isPartiallyEmittedExpression(originalOuterExpression)) { + var clone_1 = ts.getMutableClone(originalOuterExpression); + clone_1.expression = recreatePartiallyEmittedExpressions(clone_1.expression, newInnerExpression); + return clone_1; + } + return newInnerExpression; + } + function getLeftmostExpression(node) { + while (true) { + switch (node.kind) { + case 192: + node = node.operand; + continue; + case 193: + node = node.left; + continue; + case 194: + node = node.condition; + continue; + case 180: + case 179: + case 178: + node = node.expression; + continue; + case 298: + node = node.expression; + continue; + } + return node; + } + } + function parenthesizeConciseBody(body) { + var emittedBody = skipPartiallyEmittedExpressions(body); + if (emittedBody.kind === 177) { + return ts.setTextRange(ts.createParen(body), body); + } + return body; + } + ts.parenthesizeConciseBody = parenthesizeConciseBody; + var OuterExpressionKinds; + (function (OuterExpressionKinds) { + OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; + OuterExpressionKinds[OuterExpressionKinds["Assertions"] = 2] = "Assertions"; + OuterExpressionKinds[OuterExpressionKinds["PartiallyEmittedExpressions"] = 4] = "PartiallyEmittedExpressions"; + OuterExpressionKinds[OuterExpressionKinds["All"] = 7] = "All"; + })(OuterExpressionKinds = ts.OuterExpressionKinds || (ts.OuterExpressionKinds = {})); + function skipOuterExpressions(node, kinds) { + if (kinds === void 0) { kinds = 7; } + var previousNode; + do { + previousNode = node; + if (kinds & 1) { + node = skipParentheses(node); + } + if (kinds & 2) { + node = skipAssertions(node); + } + if (kinds & 4) { + node = skipPartiallyEmittedExpressions(node); + } + } while (previousNode !== node); return node; } - ts.setNodeFlags = setNodeFlags; - function setMultiLine(node, multiLine) { - node.multiLine = multiLine; + ts.skipOuterExpressions = skipOuterExpressions; + function skipParentheses(node) { + while (node.kind === 184) { + node = node.expression; + } return node; } - ts.setMultiLine = setMultiLine; - function setHasTrailingComma(nodes, hasTrailingComma) { - nodes.hasTrailingComma = hasTrailingComma; - return nodes; + ts.skipParentheses = skipParentheses; + function skipAssertions(node) { + while (ts.isAssertionExpression(node)) { + node = node.expression; + } + return node; } - ts.setHasTrailingComma = setHasTrailingComma; + ts.skipAssertions = skipAssertions; + function skipPartiallyEmittedExpressions(node) { + while (node.kind === 298) { + node = node.expression; + } + return node; + } + ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; + function startOnNewLine(node) { + node.startsOnNewLine = true; + return node; + } + ts.startOnNewLine = startOnNewLine; + function getExternalHelpersModuleName(node) { + var parseNode = ts.getOriginalNode(node, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return emitNode && emitNode.externalHelpersModuleName; + } + ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions) { + if (compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { + var externalHelpersModuleName = getExternalHelpersModuleName(node); + if (externalHelpersModuleName) { + return externalHelpersModuleName; + } + var helpers = ts.getEmitHelpers(node); + if (helpers) { + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!helper.scoped) { + var parseNode = ts.getOriginalNode(node, ts.isSourceFile); + var emitNode = ts.getOrCreateEmitNode(parseNode); + return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = ts.createUniqueName(ts.externalHelpersModuleNameText)); + } + } + } + } + } + ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_11 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_11) ? name_11 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 235 && node.importClause) { - return getGeneratedNameForNode(node); + if (node.kind === 237 && node.importClause) { + return ts.getGeneratedNameForNode(node); } - if (node.kind === 241 && node.moduleSpecifier) { - return getGeneratedNameForNode(node); + if (node.kind === 243 && node.moduleSpecifier) { + return ts.getGeneratedNameForNode(node); } return undefined; } @@ -12943,26 +12976,24 @@ var ts; if (moduleName.kind === 9) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) - || getSynthesizedClone(moduleName); + || ts.getSynthesizedClone(moduleName); } return undefined; } ts.getExternalModuleNameLiteral = getExternalModuleNameLiteral; function tryRenameExternalModule(moduleName, sourceFile) { - if (sourceFile.renamedDependencies && ts.hasProperty(sourceFile.renamedDependencies, moduleName.text)) { - return createLiteral(sourceFile.renamedDependencies[moduleName.text]); - } - return undefined; + var rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text); + return rename && ts.createLiteral(rename); } function tryGetModuleNameFromFile(file, host, options) { if (!file) { return undefined; } if (file.moduleName) { - return createLiteral(file.moduleName); + return ts.createLiteral(file.moduleName); } if (!ts.isDeclarationFile(file) && (options.out || options.outFile)) { - return createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); + return ts.createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); } return undefined; } @@ -12996,11 +13027,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 257: + case 260: return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 258: + case 261: return bindingElement.name; - case 259: + case 262: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -13016,11 +13047,11 @@ var ts; ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 144: - case 174: + case 145: + case 175: return bindingElement.dotDotDotToken; - case 196: - case 259: + case 197: + case 262: return bindingElement; } return undefined; @@ -13028,7 +13059,7 @@ var ts; ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement; function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 174: + case 175: if (bindingElement.propertyName) { var propertyName = bindingElement.propertyName; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -13036,7 +13067,7 @@ var ts; : propertyName; } break; - case 257: + case 260: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -13044,7 +13075,7 @@ var ts; : propertyName; } break; - case 259: + case 262: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -13058,11 +13089,11 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 172: case 173: - case 175: - return name.elements; + case 174: case 176: + return name.elements; + case 177: return name.properties; } } @@ -13071,10 +13102,12 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpread(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpread(element.name), element), element); } var expression = convertToAssignmentElementTarget(element.name); - return element.initializer ? setOriginalNode(createAssignment(expression, element.initializer, element), element) : expression; + return element.initializer + ? ts.setOriginalNode(ts.setTextRange(ts.createAssignment(expression, element.initializer), element), element) + : expression; } ts.Debug.assertNode(element, ts.isExpression); return element; @@ -13084,14 +13117,14 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpreadAssignment(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpreadAssignment(element.name), element), element); } if (element.propertyName) { var expression = convertToAssignmentElementTarget(element.name); - return setOriginalNode(createPropertyAssignment(element.propertyName, element.initializer ? createAssignment(expression, element.initializer) : expression, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createPropertyAssignment(element.propertyName, element.initializer ? ts.createAssignment(expression, element.initializer) : expression), element), element); } ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createShorthandPropertyAssignment(element.name, element.initializer, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createShorthandPropertyAssignment(element.name, element.initializer), element), element); } ts.Debug.assertNode(element, ts.isObjectLiteralElementLike); return element; @@ -13099,18 +13132,18 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 173: - case 175: - return convertToArrayAssignmentPattern(node); - case 172: + case 174: case 176: + return convertToArrayAssignmentPattern(node); + case 173: + case 177: return convertToObjectAssignmentPattern(node); } } ts.convertToAssignmentPattern = convertToAssignmentPattern; function convertToObjectAssignmentPattern(node) { if (ts.isObjectBindingPattern(node)) { - return setOriginalNode(createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isObjectLiteralExpression); return node; @@ -13118,7 +13151,7 @@ var ts; ts.convertToObjectAssignmentPattern = convertToObjectAssignmentPattern; function convertToArrayAssignmentPattern(node) { if (ts.isArrayBindingPattern(node)) { - return setOriginalNode(createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isArrayLiteralExpression); return node; @@ -13134,30 +13167,30 @@ var ts; ts.convertToAssignmentElementTarget = convertToAssignmentElementTarget; function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) { var externalImports = []; - var exportSpecifiers = ts.createMap(); - var exportedBindings = ts.createMap(); + var exportSpecifiers = ts.createMultiMap(); + var exportedBindings = []; var uniqueExports = ts.createMap(); var exportedNames; var hasExportDefault = false; var exportEquals = undefined; var hasExportStarsToExportValues = false; var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions); - var externalHelpersImportDeclaration = externalHelpersModuleName && createImportDeclaration(undefined, undefined, createImportClause(undefined, createNamespaceImport(externalHelpersModuleName)), createLiteral(ts.externalHelpersModuleNameText)); + var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); if (externalHelpersImportDeclaration) { externalImports.push(externalHelpersImportDeclaration); } for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 235: + case 237: externalImports.push(node); break; - case 234: - if (node.moduleReference.kind === 245) { + case 236: + if (node.moduleReference.kind === 247) { externalImports.push(node); } break; - case 241: + case 243: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -13170,26 +13203,26 @@ var ts; else { for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - if (!uniqueExports[specifier.name.text]) { - var name_12 = specifier.propertyName || specifier.name; - ts.multiMapAdd(exportSpecifiers, name_12.text, specifier); - var decl = resolver.getReferencedImportDeclaration(name_12) - || resolver.getReferencedValueDeclaration(name_12); + if (!uniqueExports.get(specifier.name.text)) { + var name = specifier.propertyName || specifier.name; + exportSpecifiers.add(name.text, specifier); + var decl = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); if (decl) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); } - uniqueExports[specifier.name.text] = true; + uniqueExports.set(specifier.name.text, true); exportedNames = ts.append(exportedNames, specifier.name); } } } break; - case 240: + case 242: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 205: + case 207: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -13197,38 +13230,38 @@ var ts; } } break; - case 225: + case 227: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { - var name_13 = node.name; - if (!uniqueExports[name_13.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_13); - uniqueExports[name_13.text] = true; - exportedNames = ts.append(exportedNames, name_13); + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); } } } break; - case 226: + case 228: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { - var name_14 = node.name; - if (!uniqueExports[name_14.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_14); - uniqueExports[name_14.text] = true; - exportedNames = ts.append(exportedNames, name_14); + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); } } } @@ -13248,13 +13281,23 @@ var ts; } } else if (!ts.isGeneratedIdentifier(decl.name)) { - if (!uniqueExports[decl.name.text]) { - uniqueExports[decl.name.text] = true; + if (!uniqueExports.get(decl.name.text)) { + uniqueExports.set(decl.name.text, true); exportedNames = ts.append(exportedNames, decl.name); } } return exportedNames; } + function multiMapSparseArrayAdd(map, key, value) { + var values = map[key]; + if (values) { + values.push(value); + } + else { + map[key] = values = [value]; + } + return values; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -13263,13 +13306,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 261) { + if (kind === 264) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 141) { + else if (kind < 142) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -13305,28 +13348,29 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 141: + case 142: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 143: + case 144: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || + visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 258: + case 261: 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 259: + case 262: return visitNode(cbNode, node.expression); - case 144: + case 145: + case 148: case 147: - case 146: - case 257: - case 223: - case 174: + case 260: + case 225: + case 175: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -13335,24 +13379,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 158: case 159: - case 153: + case 160: case 154: case 155: + case 156: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 184: - case 225: + case 153: case 185: + case 227: + case 186: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -13363,320 +13407,325 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 157: + case 158: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 156: + case 157: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 160: - return visitNode(cbNode, node.exprName); case 161: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 162: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 163: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 164: + return visitNodes(cbNodes, node.elementTypes); case 165: - return visitNodes(cbNodes, node.types); case 166: - case 168: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); + case 167: case 169: + return visitNode(cbNode, node.type); + case 170: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 170: + case 171: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 171: - return visitNode(cbNode, node.literal); case 172: + return visitNode(cbNode, node.literal); case 173: - return visitNodes(cbNodes, node.elements); - case 175: + case 174: return visitNodes(cbNodes, node.elements); case 176: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 177: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.name); + return visitNodes(cbNodes, node.properties); case 178: return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); + visitNode(cbNode, node.name); case 179: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); case 180: + case 181: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 181: + case 182: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 182: + case 183: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 183: - return visitNode(cbNode, node.expression); - case 186: + case 184: return visitNode(cbNode, node.expression); case 187: return visitNode(cbNode, node.expression); case 188: return visitNode(cbNode, node.expression); - case 190: - return visitNode(cbNode, node.operand); - case 195: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 189: return visitNode(cbNode, node.expression); case 191: return visitNode(cbNode, node.operand); + case 196: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 190: + return visitNode(cbNode, node.expression); case 192: + return visitNode(cbNode, node.operand); + case 193: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 200: + case 201: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 201: + case 202: return visitNode(cbNode, node.expression); - case 193: + case 203: + return visitNode(cbNode, node.name); + case 194: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 196: + case 197: return visitNode(cbNode, node.expression); - case 204: - case 231: + case 206: + case 233: return visitNodes(cbNodes, node.statements); - case 261: + case 264: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 205: + case 207: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 224: + case 226: return visitNodes(cbNodes, node.declarations); - case 207: + case 209: return visitNode(cbNode, node.expression); - case 208: + case 210: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 209: + case 211: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 210: + case 212: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 211: + case 213: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 212: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 213: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 214: - case 215: - return visitNode(cbNode, node.label); - case 216: - return visitNode(cbNode, node.expression); - case 217: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 215: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 216: + case 217: + return visitNode(cbNode, node.label); case 218: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 232: - return visitNodes(cbNodes, node.clauses); - case 253: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 254: - return visitNodes(cbNodes, node.statements); + return visitNode(cbNode, node.expression); case 219: - return visitNode(cbNode, node.label) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 220: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 234: + return visitNodes(cbNodes, node.clauses); + case 256: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 257: + return visitNodes(cbNodes, node.statements); case 221: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 222: + return visitNode(cbNode, node.expression); + case 223: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 256: + case 259: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 145: + case 146: return visitNode(cbNode, node.expression); - case 226: - case 197: - 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 227: - 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 228: + case 198: 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 229: 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 260: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); case 230: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 231: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 263: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 232: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 234: + case 236: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 235: + case 237: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 236: + case 238: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 233: + case 235: return visitNode(cbNode, node.name); - case 237: + case 239: return visitNode(cbNode, node.name); - case 238: - case 242: + case 240: + case 244: return visitNodes(cbNodes, node.elements); - case 241: + case 243: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 239: - case 243: + case 241: + case 245: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 240: + case 242: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 194: + case 195: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 202: + case 204: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 142: + case 143: return visitNode(cbNode, node.expression); - case 255: + case 258: return visitNodes(cbNodes, node.types); - case 199: + case 200: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 245: + case 247: return visitNode(cbNode, node.expression); - case 244: - return visitNodes(cbNodes, node.decorators); case 246: + return visitNodes(cbNodes, node.decorators); + case 248: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 247: - case 248: - return visitNode(cbNode, node.tagName) || - visitNodes(cbNodes, node.attributes); + case 249: case 250: + return visitNode(cbNode, node.tagName) || + visitNode(cbNode, node.attributes); + case 253: + return visitNodes(cbNodes, node.properties); + case 252: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); + case 254: + return visitNode(cbNode, node.expression); + case 255: + return visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.expression); case 251: - return visitNode(cbNode, node.expression); - case 252: - return visitNode(cbNode, node.expression); - case 249: return visitNode(cbNode, node.tagName); - case 262: - return visitNode(cbNode, node.type); case 266: - return visitNodes(cbNodes, node.types); - case 267: - return visitNodes(cbNodes, node.types); - case 265: - return visitNode(cbNode, node.elementType); - case 269: - return visitNode(cbNode, node.type); - case 268: return visitNode(cbNode, node.type); case 270: - return visitNode(cbNode, node.literal); - case 272: - return visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeArguments); + return visitNodes(cbNodes, node.types); + case 271: + return visitNodes(cbNodes, node.types); + case 269: + return visitNode(cbNode, node.elementType); case 273: return visitNode(cbNode, node.type); + case 272: + return visitNode(cbNode, node.type); case 274: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 275: - return visitNode(cbNode, node.type); + return visitNode(cbNode, node.literal); case 276: - return visitNode(cbNode, node.type); + return visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeArguments); case 277: return visitNode(cbNode, node.type); - case 271: + case 278: + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 279: + return visitNode(cbNode, node.type); + case 280: + return visitNode(cbNode, node.type); + case 281: + return visitNode(cbNode, node.type); + case 275: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 278: + case 282: return visitNodes(cbNodes, node.tags); - case 281: + case 285: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 282: + case 286: return visitNode(cbNode, node.typeExpression); - case 283: - return visitNode(cbNode, node.typeExpression); - case 280: + case 287: return visitNode(cbNode, node.typeExpression); case 284: + return visitNode(cbNode, node.typeExpression); + case 288: return visitNodes(cbNodes, node.typeParameters); - case 285: + case 289: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 287: + case 291: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 286: + case 290: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 294: + case 298: return visitNode(cbNode, node.expression); - case 288: + case 292: return visitNode(cbNode, node.literal); } } @@ -13840,7 +13889,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(261, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(264, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -14067,7 +14116,7 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 141 ? new NodeConstructor(kind, pos, pos) : + return kind >= 142 ? new NodeConstructor(kind, pos, pos) : kind === 70 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } @@ -14104,7 +14153,11 @@ var ts; } function internIdentifier(text) { text = ts.escapeIdentifier(text); - return identifiers[text] || (identifiers[text] = text); + var identifier = identifiers.get(text); + if (identifier === undefined) { + identifiers.set(text, identifier = text); + } + return identifier; } function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; @@ -14149,7 +14202,7 @@ var ts; return token() === 9 || token() === 8 || ts.tokenIsIdentifierOrKeyword(token()); } function parseComputedPropertyName() { - var node = createNode(142); + var node = createNode(143); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); @@ -14454,14 +14507,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 150: - case 155: case 151: + case 156: case 152: - case 147: - case 203: + case 153: + case 148: + case 205: return true; - case 149: + case 150: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 70 && methodDeclaration.name.originalKeywordKind === 122; @@ -14473,8 +14526,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 253: - case 254: + case 256: + case 257: return true; } } @@ -14483,65 +14536,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 225: - case 205: - case 204: - case 208: + case 227: case 207: - case 220: - case 216: - case 218: - case 215: - case 214: - case 212: - case 213: - case 211: - case 210: - case 217: case 206: - case 221: - case 219: + case 210: case 209: case 222: - case 235: - case 234: - case 241: - case 240: - case 230: - case 226: - case 227: - case 229: + case 218: + case 220: + case 217: + case 216: + case 214: + case 215: + case 213: + case 212: + case 219: + case 208: + case 223: + case 221: + case 211: + case 224: + case 237: + case 236: + case 243: + case 242: + case 232: case 228: + case 229: + case 231: + case 230: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 260; + return node.kind === 263; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 154: - case 148: case 155: - case 146: - case 153: + case 149: + case 156: + case 147: + case 154: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 223) { + if (node.kind !== 225) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 144) { + if (node.kind !== 145) { return false; } var parameter = node; @@ -14637,7 +14690,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(22)) { - var node = createNode(141, entity.pos); + var node = createNode(142, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -14654,7 +14707,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(194); + var template = createNode(195); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -14666,7 +14719,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(202); + var span = createNode(204); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17) { @@ -14714,7 +14767,7 @@ var ts; } function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(157, typeName.pos); + var node = createNode(158, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token() === 26) { node.typeArguments = parseBracketedList(19, parseType, 26, 28); @@ -14723,24 +14776,24 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(156, lhs.pos); + var node = createNode(157, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(167); + var node = createNode(168); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(160); + var node = createNode(161); parseExpected(102); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(143); + var node = createNode(144); node.name = parseIdentifier(); if (parseOptional(84)) { if (isStartOfType() || !isStartOfExpression()) { @@ -14750,6 +14803,9 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } + if (parseOptional(57)) { + node.default = parseType(); + } return finishNode(node); } function parseTypeParameters() { @@ -14767,7 +14823,7 @@ var ts; return token() === 23 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 || token() === 98; } function parseParameter() { - var node = createNode(144); + var node = createNode(145); if (token() === 98) { node.name = createIdentifier(true, undefined); node.type = parseParameterType(); @@ -14827,7 +14883,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 154) { + if (kind === 155) { parseExpected(93); } fillSignature(55, false, false, false, node); @@ -14867,7 +14923,7 @@ var ts; return token() === 55 || token() === 25 || token() === 21; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(155, fullStart); + var node = createNode(156, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.parameters = parseBracketedList(16, parseParameter, 20, 21); @@ -14879,7 +14935,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(54); if (token() === 18 || token() === 26) { - var method = createNode(148, fullStart); + var method = createNode(149, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; @@ -14888,7 +14944,7 @@ var ts; return addJSDocComment(finishNode(method)); } else { - var property = createNode(146, fullStart); + var property = createNode(147, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; @@ -14928,10 +14984,10 @@ var ts; } function parseTypeMember() { if (token() === 18 || token() === 26) { - return parseSignatureMember(153); + return parseSignatureMember(154); } if (token() === 93 && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(154); + return parseSignatureMember(155); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -14945,7 +15001,7 @@ var ts; return token() === 18 || token() === 26; } function parseTypeLiteral() { - var node = createNode(161); + var node = createNode(162); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -14968,14 +15024,14 @@ var ts; return token() === 20 && nextTokenIsIdentifier() && nextToken() === 91; } function parseMappedTypeParameter() { - var node = createNode(143); + var node = createNode(144); node.name = parseIdentifier(); parseExpected(91); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(170); + var node = createNode(171); parseExpected(16); node.readonlyToken = parseOptionalToken(130); parseExpected(20); @@ -14988,12 +15044,12 @@ var ts; return finishNode(node); } function parseTupleType() { - var node = createNode(163); + var node = createNode(164); node.elementTypes = parseBracketedList(20, parseType, 20, 21); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(166); + var node = createNode(167); parseExpected(18); node.type = parseType(); parseExpected(19); @@ -15001,7 +15057,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 159) { + if (kind === 160) { parseExpected(93); } fillSignature(35, false, false, false, node); @@ -15012,7 +15068,7 @@ var ts; return token() === 22 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(171); + var node = createNode(172); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -15023,12 +15079,13 @@ var ts; function parseNonArrayType() { switch (token()) { case 118: - case 134: + case 135: case 132: case 121: - case 135: - case 137: + case 136: + case 138: case 129: + case 133: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: @@ -15065,12 +15122,12 @@ var ts; function isStartOfType() { switch (token()) { case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 136: case 104: - case 137: + case 138: case 94: case 98: case 102: @@ -15085,6 +15142,7 @@ var ts; case 8: case 100: case 85: + case 133: return true; case 37: return lookAhead(nextTokenIsNumericLiteral); @@ -15102,14 +15160,14 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(20)) { if (isStartOfType()) { - var node = createNode(169, type.pos); + var node = createNode(170, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(21); type = finishNode(node); } else { - var node = createNode(162, type.pos); + var node = createNode(163, type.pos); node.elementType = type; parseExpected(21); type = finishNode(node); @@ -15118,7 +15176,7 @@ var ts; return type; } function parseTypeOperator(operator) { - var node = createNode(168); + var node = createNode(169); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); @@ -15147,10 +15205,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(165, parseTypeOperatorOrHigher, 47); + return parseUnionOrIntersectionType(166, parseTypeOperatorOrHigher, 47); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(164, parseIntersectionTypeOrHigher, 48); + return parseUnionOrIntersectionType(165, parseIntersectionTypeOrHigher, 48); } function isStartOfFunctionType() { if (token() === 26) { @@ -15196,7 +15254,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(156, typePredicateVariable.pos); + var node = createNode(157, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -15217,10 +15275,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(158); + return parseFunctionOrConstructorType(159); } if (token() === 93) { - return parseFunctionOrConstructorType(159); + return parseFunctionOrConstructorType(160); } return parseUnionTypeOrHigher(); } @@ -15339,7 +15397,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(195); + var node = createNode(196); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 38 || isStartOfExpression())) { @@ -15355,13 +15413,13 @@ var ts; ts.Debug.assert(token() === 35, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(185, asyncModifier.pos); + node = createNode(186, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(185, identifier.pos); + node = createNode(186, identifier.pos); } - var parameter = createNode(144, identifier.pos); + var parameter = createNode(145, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); @@ -15495,7 +15553,7 @@ var ts; return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(185); + var node = createNode(186); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); fillSignature(55, false, isAsync, !allowAmbiguity, node); @@ -15527,7 +15585,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(193, leftOperand.pos); + var node = createNode(194, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -15540,7 +15598,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 || t === 140; + return t === 91 || t === 141; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -15618,43 +15676,43 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(192, left.pos); + var node = createNode(193, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(200, left.pos); + var node = createNode(201, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(190); + var node = createNode(191); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(186); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(187); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(188); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(189); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { if (token() === 120) { if (inAwaitContext()) { @@ -15665,7 +15723,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(189); + var node = createNode(190); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15681,7 +15739,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === 39) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 182) { + if (simpleUnaryExpression.kind === 183) { 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 { @@ -15734,7 +15792,7 @@ var ts; } function parseIncrementExpression() { if (token() === 42 || token() === 43) { - var node = createNode(190); + var node = createNode(191); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -15746,7 +15804,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 42 || token() === 43) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(191, expression.pos); + var node = createNode(192, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -15769,7 +15827,7 @@ var ts; if (token() === 18 || token() === 22 || token() === 20) { return expression; } - var node = createNode(177, expression.pos); + var node = createNode(178, expression.pos); node.expression = expression; parseExpectedToken(22, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -15791,8 +15849,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 248) { - var node = createNode(246, opening.pos); + if (opening.kind === 250) { + var node = createNode(248, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -15802,14 +15860,14 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 247); + ts.Debug.assert(opening.kind === 249); result = opening; } if (inExpressionContext && token() === 26) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(192, result.pos); + var badNode = createNode(193, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -15855,14 +15913,19 @@ var ts; parsingContext = saveParsingContext; return result; } + function parseJsxAttributes() { + var jsxAttributes = createNode(253); + jsxAttributes.properties = parseList(13, parseJsxAttribute); + return finishNode(jsxAttributes); + } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); parseExpected(26); var tagName = parseJsxElementName(); - var attributes = parseList(13, parseJsxAttribute); + var attributes = parseJsxAttributes(); var node; if (token() === 28) { - node = createNode(248, fullStart); + node = createNode(250, fullStart); scanJsxText(); } else { @@ -15874,7 +15937,7 @@ var ts; parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(247, fullStart); + node = createNode(249, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -15885,7 +15948,7 @@ var ts; var expression = token() === 98 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22)) { - var propertyAccess = createNode(177, expression.pos); + var propertyAccess = createNode(178, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -15893,9 +15956,10 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(252); + var node = createNode(255); parseExpected(16); if (token() !== 17) { + node.dotDotDotToken = parseOptionalToken(23); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { @@ -15912,7 +15976,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(250); + var node = createNode(252); node.name = parseIdentifierName(); if (token() === 57) { switch (scanJsxAttributeValue()) { @@ -15927,7 +15991,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(251); + var node = createNode(254); parseExpected(16); parseExpected(23); node.expression = parseExpression(); @@ -15935,7 +15999,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(249); + var node = createNode(251); parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -15948,7 +16012,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(182); + var node = createNode(183); parseExpected(26); node.type = parseType(); parseExpected(28); @@ -15959,7 +16023,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22); if (dotToken) { - var propertyAccess = createNode(177, expression.pos); + var propertyAccess = createNode(178, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -15967,13 +16031,13 @@ var ts; } if (token() === 50 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(201, expression.pos); + var nonNullExpression = createNode(202, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } if (!inDecoratorContext() && parseOptional(20)) { - var indexedAccess = createNode(178, expression.pos); + var indexedAccess = createNode(179, expression.pos); indexedAccess.expression = expression; if (token() !== 21) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -15987,7 +16051,7 @@ var ts; continue; } if (token() === 12 || token() === 13) { - var tagExpression = createNode(181, expression.pos); + var tagExpression = createNode(182, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 ? parseLiteralNode() @@ -16006,7 +16070,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(179, expression.pos); + var callExpr = createNode(180, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -16014,7 +16078,7 @@ var ts; continue; } else if (token() === 18) { - var callExpr = createNode(179, expression.pos); + var callExpr = createNode(180, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -16109,28 +16173,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(183); + var node = createNode(184); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); return finishNode(node); } function parseSpreadElement() { - var node = createNode(196); + var node = createNode(197); parseExpected(23); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 23 ? parseSpreadElement() : - token() === 25 ? createNode(198) : + token() === 25 ? createNode(199) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(175); + var node = createNode(176); parseExpected(20); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16141,18 +16205,18 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(124)) { - return parseAccessorDeclaration(151, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(133)) { return parseAccessorDeclaration(152, fullStart, decorators, modifiers); } + else if (parseContextualModifier(134)) { + return parseAccessorDeclaration(153, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23); if (dotDotDotToken) { - var spreadElement = createNode(259, fullStart); + var spreadElement = createNode(262, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -16171,7 +16235,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(258, fullStart); + var shorthandDeclaration = createNode(261, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57); @@ -16182,7 +16246,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(257, fullStart); + var propertyAssignment = createNode(260, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -16192,7 +16256,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(176); + var node = createNode(177); parseExpected(16); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16206,7 +16270,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(184); + var node = createNode(185); node.modifiers = parseModifiers(); parseExpected(88); node.asteriskToken = parseOptionalToken(38); @@ -16228,8 +16292,15 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(180); + var fullStart = scanner.getStartPos(); parseExpected(93); + if (parseOptional(22)) { + var node_1 = createNode(203, fullStart); + node_1.keywordToken = 93; + node_1.name = parseIdentifierName(); + return finishNode(node_1); + } + var node = createNode(181, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18) { @@ -16238,7 +16309,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(204); + var node = createNode(206); if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16269,12 +16340,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(206); + var node = createNode(208); parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(208); + var node = createNode(210); parseExpected(89); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16284,7 +16355,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(209); + var node = createNode(211); parseExpected(80); node.statement = parseStatement(); parseExpected(105); @@ -16295,7 +16366,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(210); + var node = createNode(212); parseExpected(105); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16318,21 +16389,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91)) { - var forInStatement = createNode(212, pos); + var forInStatement = createNode(214, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(140)) { - var forOfStatement = createNode(213, pos); + else if (parseOptional(141)) { + var forOfStatement = createNode(215, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(211, pos); + var forStatement = createNode(213, pos); forStatement.initializer = initializer; parseExpected(24); if (token() !== 24 && token() !== 19) { @@ -16350,7 +16421,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 215 ? 71 : 76); + parseExpected(kind === 217 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16358,7 +16429,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(216); + var node = createNode(218); parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -16367,7 +16438,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(217); + var node = createNode(219); parseExpected(106); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16376,7 +16447,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(253); + var node = createNode(256); parseExpected(72); node.expression = allowInAnd(parseExpression); parseExpected(55); @@ -16384,7 +16455,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(254); + var node = createNode(257); parseExpected(78); parseExpected(55); node.statements = parseList(3, parseStatement); @@ -16394,12 +16465,12 @@ var ts; return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(218); + var node = createNode(220); parseExpected(97); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); - var caseBlock = createNode(232, scanner.getStartPos()); + var caseBlock = createNode(234, scanner.getStartPos()); parseExpected(16); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(17); @@ -16407,14 +16478,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(220); + var node = createNode(222); parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(221); + var node = createNode(223); parseExpected(101); node.tryBlock = parseBlock(false); node.catchClause = token() === 73 ? parseCatchClause() : undefined; @@ -16425,7 +16496,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(256); + var result = createNode(259); parseExpected(73); if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); @@ -16435,7 +16506,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(222); + var node = createNode(224); parseExpected(77); parseSemicolon(); return finishNode(node); @@ -16444,13 +16515,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 && parseOptional(55)) { - var labeledStatement = createNode(219, fullStart); + var labeledStatement = createNode(221, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(207, fullStart); + var expressionStatement = createNode(209, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -16479,7 +16550,7 @@ var ts; case 82: return true; case 108: - case 136: + case 137: return nextTokenIsIdentifierOnSameLine(); case 127: case 128: @@ -16496,7 +16567,7 @@ var ts; return false; } continue; - case 139: + case 140: nextToken(); return token() === 16 || token() === 70 || token() === 83; case 90: @@ -16556,8 +16627,8 @@ var ts; case 108: case 127: case 128: - case 136: - case 139: + case 137: + case 140: return true; case 113: case 111: @@ -16602,9 +16673,9 @@ var ts; case 87: return parseForOrForInOrForOfStatement(); case 76: - return parseBreakOrContinueStatement(214); + return parseBreakOrContinueStatement(216); case 71: - return parseBreakOrContinueStatement(215); + return parseBreakOrContinueStatement(217); case 95: return parseReturnStatement(); case 106: @@ -16623,7 +16694,7 @@ var ts; return parseDeclaration(); case 119: case 108: - case 136: + case 137: case 127: case 128: case 123: @@ -16637,7 +16708,7 @@ var ts; case 116: case 114: case 130: - case 139: + case 140: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -16660,11 +16731,11 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 108: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 136: + case 137: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 82: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 139: + case 140: case 127: case 128: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -16683,7 +16754,7 @@ var ts; } default: if (decorators || modifiers) { - var node = createMissingNode(244, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(246, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -16704,16 +16775,16 @@ var ts; } function parseArrayBindingElement() { if (token() === 25) { - return createNode(198); + return createNode(199); } - var node = createNode(174); + var node = createNode(175); node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(174); + var node = createNode(175); node.dotDotDotToken = parseOptionalToken(23); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -16729,14 +16800,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(172); + var node = createNode(173); parseExpected(16); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(17); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(173); + var node = createNode(174); parseExpected(20); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(21); @@ -16755,7 +16826,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(223); + var node = createNode(225); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -16764,7 +16835,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(224); + var node = createNode(226); switch (token()) { case 103: break; @@ -16778,7 +16849,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token() === 140 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 141 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -16793,7 +16864,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(205, fullStart); + var node = createNode(207, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -16801,7 +16872,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(227, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88); @@ -16814,7 +16885,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(150, pos); + var node = createNode(151, pos); node.decorators = decorators; node.modifiers = modifiers; parseExpected(122); @@ -16823,7 +16894,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(149, fullStart); + var method = createNode(150, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -16836,7 +16907,7 @@ var ts; return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(147, fullStart); + var property = createNode(148, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -16906,7 +16977,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 133 || idToken === 124) { + if (!ts.isKeyword(idToken) || idToken === 134 || idToken === 124) { return true; } switch (token()) { @@ -16929,7 +17000,7 @@ var ts; if (!parseOptional(56)) { break; } - var decorator = createNode(145, decoratorStart); + var decorator = createNode(146, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -16986,7 +17057,7 @@ var ts; } function parseClassElement() { if (token() === 24) { - var result = createNode(203); + var result = createNode(205); nextToken(); return finishNode(result); } @@ -17011,16 +17082,16 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_15 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_15, undefined); + var name = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 197); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 198); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 228); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -17055,7 +17126,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 || token() === 107) { - var node = createNode(255); + var node = createNode(258); node.token = token(); nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -17064,7 +17135,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(199); + var node = createNode(200); node.expression = parseLeftHandSideExpressionOrHigher(); if (token() === 26) { node.typeArguments = parseBracketedList(19, parseType, 26, 28); @@ -17078,7 +17149,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227, fullStart); + var node = createNode(229, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108); @@ -17089,10 +17160,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(136); + parseExpected(137); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57); @@ -17101,13 +17172,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(260, scanner.getStartPos()); + var node = createNode(263, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82); @@ -17122,7 +17193,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(231, scanner.getStartPos()); + var node = createNode(233, scanner.getStartPos()); if (parseExpected(16)) { node.statements = parseList(1, parseStatement); parseExpected(17); @@ -17133,7 +17204,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(230, fullStart); + var node = createNode(232, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; @@ -17145,10 +17216,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(232, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 139) { + if (token() === 140) { node.name = parseIdentifier(); node.flags |= 512; } @@ -17165,7 +17236,7 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 139) { + if (token() === 140) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } else if (parseOptional(128)) { @@ -17190,7 +17261,7 @@ var ts; return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(233, fullStart); + var exportDeclaration = createNode(235, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117); @@ -17205,8 +17276,8 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 && token() !== 138) { - var importEqualsDeclaration = createNode(234, fullStart); + if (token() !== 25 && token() !== 139) { + var importEqualsDeclaration = createNode(236, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -17216,27 +17287,27 @@ var ts; return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(235, fullStart); + var importDeclaration = createNode(237, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || token() === 38 || token() === 16) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(138); + parseExpected(139); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(236, fullStart); + var importClause = createNode(238, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(238); + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(240); } return finishNode(importClause); } @@ -17246,7 +17317,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(245); + var node = createNode(247); parseExpected(131); parseExpected(18); node.expression = parseModuleSpecifier(); @@ -17264,7 +17335,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(237); + var namespaceImport = createNode(239); parseExpected(38); parseExpected(117); namespaceImport.name = parseIdentifier(); @@ -17272,14 +17343,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 238 ? parseImportSpecifier : parseExportSpecifier, 16, 17); + node.elements = parseBracketedList(22, kind === 240 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(243); + return parseImportOrExportSpecifier(245); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(239); + return parseImportOrExportSpecifier(241); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17298,23 +17369,23 @@ var ts; else { node.name = identifierName; } - if (kind === 239 && checkIdentifierIsKeyword) { + if (kind === 241 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(241, fullStart); + var node = createNode(243, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38)) { - parseExpected(138); + parseExpected(139); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(242); - if (token() === 138 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(138); + node.exportClause = parseNamedImportsOrExports(244); + if (token() === 139 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(139); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -17322,7 +17393,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(240, fullStart); + var node = createNode(242, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57)) { @@ -17401,14 +17472,51 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 234 && node.moduleReference.kind === 245 - || node.kind === 235 - || node.kind === 240 - || node.kind === 241 + || node.kind === 236 && node.moduleReference.kind === 247 + || node.kind === 237 + || node.kind === 242 + || node.kind === 243 ? node : undefined; }); } + var ParsingContext; + (function (ParsingContext) { + ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; + ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; + ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; + ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; + ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; + ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; + ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; + ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; + ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; + ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; + ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; + ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; + ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; + ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes"; + ParsingContext[ParsingContext["JsxChildren"] = 14] = "JsxChildren"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 16] = "Parameters"; + ParsingContext[ParsingContext["RestProperties"] = 17] = "RestProperties"; + ParsingContext[ParsingContext["TypeParameters"] = 18] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 19] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 20] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 21] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 22] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["JSDocFunctionParameters"] = 23] = "JSDocFunctionParameters"; + ParsingContext[ParsingContext["JSDocTypeArguments"] = 24] = "JSDocTypeArguments"; + ParsingContext[ParsingContext["JSDocRecordMembers"] = 25] = "JSDocRecordMembers"; + ParsingContext[ParsingContext["JSDocTupleTypes"] = 26] = "JSDocTupleTypes"; + ParsingContext[ParsingContext["Count"] = 27] = "Count"; + })(ParsingContext || (ParsingContext = {})); + var Tristate; + (function (Tristate) { + Tristate[Tristate["False"] = 0] = "False"; + Tristate[Tristate["True"] = 1] = "True"; + Tristate[Tristate["Unknown"] = 2] = "Unknown"; + })(Tristate || (Tristate = {})); var JSDocParser; (function (JSDocParser) { function isJSDocType() { @@ -17440,7 +17548,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(262, scanner.getTokenPos()); + var result = createNode(266, scanner.getTokenPos()); parseExpected(16); result.type = parseJSDocTopLevelType(); parseExpected(17); @@ -17451,12 +17559,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48) { - var unionType = createNode(266, type.pos); + var unionType = createNode(270, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57) { - var optionalType = createNode(273, type.pos); + var optionalType = createNode(277, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -17467,20 +17575,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20) { - var arrayType = createNode(265, type.pos); + var arrayType = createNode(269, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21); type = finishNode(arrayType); } else if (token() === 54) { - var nullableType = createNode(268, type.pos); + var nullableType = createNode(272, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50) { - var nonNullableType = createNode(269, type.pos); + var nonNullableType = createNode(273, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -17514,14 +17622,15 @@ var ts; case 98: return parseJSDocThisType(); case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 136: case 104: case 94: - case 137: + case 138: case 129: + case 133: return parseTokenNode(); case 9: case 8: @@ -17532,27 +17641,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(277); + var result = createNode(281); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(276); + var result = createNode(280); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(275); + var result = createNode(279); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(274); + var result = createNode(278); nextToken(); parseExpected(18); result.parameters = parseDelimitedList(23, parseJSDocParameter); @@ -17565,7 +17674,7 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(144); + var parameter = createNode(145); parameter.type = parseJSDocType(); if (parseOptional(57)) { parameter.questionToken = createNode(57); @@ -17573,7 +17682,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(272); + var result = createNode(276); result.name = parseSimplePropertyName(); if (token() === 26) { result.typeArguments = parseTypeArguments(); @@ -17607,24 +17716,24 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(141, left.pos); + var result = createNode(142, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(270); + var result = createNode(274); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(269); + var result = createNode(273); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(267); + var result = createNode(271); nextToken(); result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); @@ -17638,7 +17747,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(266); + var result = createNode(270); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19); @@ -17654,12 +17763,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(263); + var result = createNode(267); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(288); + var result = createNode(292); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -17672,11 +17781,11 @@ var ts; token() === 28 || token() === 57 || token() === 48) { - var result = createNode(264, pos); + var result = createNode(268, pos); return finishNode(result); } else { - var result = createNode(268, pos); + var result = createNode(272, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -17704,6 +17813,12 @@ var ts; return comment; } JSDocParser.parseJSDocComment = parseJSDocComment; + var JSDocState; + (function (JSDocState) { + JSDocState[JSDocState["BeginningOfLine"] = 0] = "BeginningOfLine"; + JSDocState[JSDocState["SawAsterisk"] = 1] = "SawAsterisk"; + JSDocState[JSDocState["SavingComments"] = 2] = "SavingComments"; + })(JSDocState || (JSDocState = {})); function parseJSDocCommentWorker(start, length) { var content = sourceText; start = start || 0; @@ -17820,7 +17935,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(278, start); + var result = createNode(282, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -17930,7 +18045,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(279, atToken.pos); + var result = createNode(283, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -17985,7 +18100,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(281, atToken.pos); + var result = createNode(285, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -17996,20 +18111,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 282; })) { + if (ts.forEach(tags, function (t) { return t.kind === 286; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(282, atToken.pos); + var result = createNode(286, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283; })) { + if (ts.forEach(tags, function (t) { return t.kind === 287; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283, atToken.pos); + var result = createNode(287, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -18024,7 +18139,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(286, atToken.pos); + var result = createNode(290, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -18033,7 +18148,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(280, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -18042,25 +18157,28 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(285, atToken.pos); + var typedefTag = createNode(289, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); if (typedefTag.fullName) { var rightNode = typedefTag.fullName; - while (rightNode.kind !== 70) { + while (true) { + if (rightNode.kind === 70 || !rightNode.body) { + typedefTag.name = rightNode.kind === 70 ? rightNode : rightNode.name; + break; + } rightNode = rightNode.body; } - typedefTag.name = rightNode; } typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 272) { + if (typeExpression.type.kind === 276) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { - var name_16 = jsDocTypeReference.name; - if (name_16.text === "Object") { + var name = jsDocTypeReference.name; + if (name.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -18074,7 +18192,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(287, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(291, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -18115,7 +18233,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22)) { - var jsDocNamespaceNode = createNode(230, pos); + var jsDocNamespaceNode = createNode(232, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); @@ -18159,19 +18277,19 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284; })) { + if (ts.forEach(tags, function (t) { return t.kind === 288; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); while (true) { - var name_17 = parseJSDocIdentifierName(); + var name = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_17) { + if (!name) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(143, name_17.pos); - typeParameter.name = name_17; + var typeParameter = createNode(144, name.pos); + typeParameter.name = name; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25) { @@ -18182,7 +18300,7 @@ var ts; break; } } - var result = createNode(284, atToken.pos); + var result = createNode(288, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -18474,7 +18592,7 @@ var ts; } function visitArray(array) { if (position >= array.pos && position < array.end) { - for (var i = 0, n = array.length; i < n; i++) { + for (var i = 0; i < array.length; i++) { var child = array[i]; if (child) { if (child.pos === position) { @@ -18496,21 +18614,31 @@ var ts; } } } + var InvalidPosition; + (function (InvalidPosition) { + InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; + })(InvalidPosition || (InvalidPosition = {})); })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); var ts; (function (ts) { + var ModuleInstanceState; + (function (ModuleInstanceState) { + ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; + ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; + ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; + })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); function getModuleInstanceState(node) { - if (node.kind === 227 || node.kind === 228) { + if (node.kind === 229 || node.kind === 230) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 235 || node.kind === 234) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 237 || node.kind === 236) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 231) { + else if (node.kind === 233) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -18526,7 +18654,7 @@ var ts; }); return state_1; } - else if (node.kind === 230) { + else if (node.kind === 232) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -18538,6 +18666,18 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; + var ContainerFlags; + (function (ContainerFlags) { + ContainerFlags[ContainerFlags["None"] = 0] = "None"; + ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; + ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; + ContainerFlags[ContainerFlags["IsControlFlowContainer"] = 4] = "IsControlFlowContainer"; + ContainerFlags[ContainerFlags["IsFunctionLike"] = 8] = "IsFunctionLike"; + ContainerFlags[ContainerFlags["IsFunctionExpression"] = 16] = "IsFunctionExpression"; + ContainerFlags[ContainerFlags["HasLocals"] = 32] = "HasLocals"; + ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; + ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; + })(ContainerFlags || (ContainerFlags = {})); var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -18635,7 +18775,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 230)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 232)) { symbol.valueDeclaration = node; } } @@ -18645,7 +18785,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 142) { + if (node.name.kind === 143) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression)) { return nameExpression.text; @@ -18656,21 +18796,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 150: + case 151: return "__constructor"; - case 158: - case 153: - return "__call"; case 159: case 154: - return "__new"; + return "__call"; + case 160: case 155: + return "__new"; + case 156: return "__index"; - case 241: + case 243: return "__export"; - case 240: + case 242: return node.isExportEquals ? "export=" : "default"; - case 192: + case 193: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -18682,20 +18822,20 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 225: - case 226: + case 227: + case 228: return ts.hasModifier(node, 512) ? "default" : undefined; - case 274: + case 278: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 144: - ts.Debug.assert(node.parent.kind === 274); + case 145: + ts.Debug.assert(node.parent.kind === 278); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 285: + case 289: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 205) { + if (parentNode && parentNode.kind === 207) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -18718,13 +18858,16 @@ var ts; symbol = createSymbol(0, "__missing"); } else { - symbol = symbolTable[name] || (symbolTable[name] = createSymbol(0, name)); + symbol = symbolTable.get(name); + if (!symbol) { + symbolTable.set(name, symbol = createSymbol(0, name)); + } if (name && (includes & 788448)) { - classifiableNames[name] = name; + classifiableNames.set(name, name); } if (symbol.flags & excludes) { if (symbol.isReplaceableByMethod) { - symbol = symbolTable[name] = createSymbol(0, name); + symbolTable.set(name, symbol = createSymbol(0, name)); } else { if (node.name) { @@ -18739,7 +18882,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 240 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 242 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -18759,7 +18902,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 243 || (node.kind === 234 && hasExportModifier)) { + if (node.kind === 245 || (node.kind === 236 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -18767,7 +18910,7 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 285 && + var isJSDocTypedefInJSDocNamespace = node.kind === 289 && node.name && node.name.kind === 70 && node.name.isInJSDocNamespace; @@ -18828,7 +18971,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 261) { + if (node.kind === 264) { node.flags |= emitFlags; } if (isIIFE) { @@ -18904,64 +19047,64 @@ var ts; return; } switch (node.kind) { - case 210: + case 212: bindWhileStatement(node); break; - case 209: + case 211: bindDoStatement(node); break; - case 211: + case 213: bindForStatement(node); break; - case 212: - case 213: + case 214: + case 215: bindForInOrForOfStatement(node); break; - case 208: + case 210: bindIfStatement(node); break; - case 216: - case 220: + case 218: + case 222: bindReturnOrThrow(node); break; - case 215: - case 214: + case 217: + case 216: bindBreakOrContinueStatement(node); break; - case 221: + case 223: bindTryStatement(node); break; - case 218: + case 220: bindSwitchStatement(node); break; - case 232: + case 234: bindCaseBlock(node); break; - case 253: + case 256: bindCaseClause(node); break; - case 219: + case 221: bindLabeledStatement(node); break; - case 190: + case 191: bindPrefixUnaryExpressionFlow(node); break; - case 191: + case 192: bindPostfixUnaryExpressionFlow(node); break; - case 192: + case 193: bindBinaryExpressionFlow(node); break; - case 186: + case 187: bindDeleteExpressionFlow(node); break; - case 193: + case 194: bindConditionalExpressionFlow(node); break; - case 223: + case 225: bindVariableDeclarationFlow(node); break; - case 179: + case 180: bindCallExpressionFlow(node); break; default: @@ -18973,15 +19116,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 177: + case 178: return isNarrowableReference(expr); - case 179: + case 180: return hasNarrowableArgument(expr); - case 183: + case 184: return isNarrowingExpression(expr.expression); - case 192: + case 193: return isNarrowingBinaryExpression(expr); - case 190: + case 191: return expr.operator === 50 && isNarrowingExpression(expr.operand); } return false; @@ -18989,7 +19132,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 || expr.kind === 98 || - expr.kind === 177 && isNarrowableReference(expr.expression); + expr.kind === 178 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -19000,14 +19143,14 @@ var ts; } } } - if (expr.expression.kind === 177 && + if (expr.expression.kind === 178 && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 187 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; + return expr1.kind === 188 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -19028,9 +19171,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 183: + case 184: return isNarrowableOperand(expr.expression); - case 192: + case 193: switch (expr.operatorToken.kind) { case 57: return isNarrowableOperand(expr.left); @@ -19124,33 +19267,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 208: case 210: - case 209: - return parent.expression === node; + case 212: case 211: - case 193: + return parent.expression === node; + case 213: + case 194: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 183) { + if (node.kind === 184) { node = node.expression; } - else if (node.kind === 190 && node.operator === 50) { + else if (node.kind === 191 && node.operator === 50) { node = node.operand; } else { - return node.kind === 192 && (node.operatorToken.kind === 52 || + return node.kind === 193 && (node.operatorToken.kind === 52 || node.operatorToken.kind === 53); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 183 || - node.parent.kind === 190 && + while (node.parent.kind === 184 || + node.parent.kind === 191 && node.parent.operator === 50) { node = node.parent; } @@ -19192,7 +19335,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 219 + var enclosingLabeledStatement = node.parent.kind === 221 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -19227,7 +19370,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 224) { + if (node.initializer.kind !== 226) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -19249,7 +19392,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 216) { + if (node.kind === 218) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -19269,7 +19412,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 215 ? breakTarget : continueTarget; + var flowLabel = node.kind === 217 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -19302,7 +19445,8 @@ var ts; flowAfterCatch = currentFlow; } if (node.finallyBlock) { - addAntecedent(preFinallyLabel, preTryFlow); + var preFinallyFlow = { flags: 2048, antecedent: preTryFlow, lock: {} }; + addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); if (!(currentFlow.flags & 1)) { @@ -19312,6 +19456,11 @@ var ts; : unreachableFlow; } } + if (!(currentFlow.flags & 1)) { + var afterFinallyFlow = { flags: 4096, antecedent: currentFlow }; + preFinallyFlow.lock = afterFinallyFlow; + currentFlow = afterFinallyFlow; + } } else { currentFlow = finishFlowLabel(preFinallyLabel); @@ -19326,7 +19475,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 254; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 257; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -19391,13 +19540,13 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 209) { + if (!node.statement || node.statement.kind !== 211) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 192 && node.operatorToken.kind === 57) { + if (node.kind === 193 && node.operatorToken.kind === 57) { bindAssignmentTargetFlow(node.left); } else { @@ -19408,10 +19557,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 175) { + else if (node.kind === 176) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 196) { + if (e.kind === 197) { bindAssignmentTargetFlow(e.expression); } else { @@ -19419,16 +19568,16 @@ var ts; } } } - else if (node.kind === 176) { + else if (node.kind === 177) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 257) { + if (p.kind === 260) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 258) { + else if (p.kind === 261) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 259) { + else if (p.kind === 262) { bindAssignmentTargetFlow(p.expression); } } @@ -19484,7 +19633,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 57 && node.left.kind === 178) { + if (operator === 57 && node.left.kind === 179) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -19495,7 +19644,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 177) { + if (node.expression.kind === 178) { bindAssignmentTargetFlow(node.expression); } } @@ -19528,16 +19677,16 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 212 || node.parent.parent.kind === 213) { + if (node.initializer || node.parent.parent.kind === 214 || node.parent.parent.kind === 215) { bindInitializedVariableFlow(node); } } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 183) { + while (expr.kind === 184) { expr = expr.expression; } - if (expr.kind === 184 || expr.kind === 185) { + if (expr.kind === 185 || expr.kind === 186) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -19545,7 +19694,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 177) { + if (node.expression.kind === 178) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -19554,52 +19703,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 197: - case 226: - case 229: - case 176: - case 161: - case 287: - case 270: - return 1; - case 227: - return 1 | 64; - case 274: - case 230: + case 198: case 228: - case 170: + case 231: + case 177: + case 162: + case 291: + case 274: + case 253: + return 1; + case 229: + return 1 | 64; + case 278: + case 232: + case 230: + case 171: return 1 | 32; - case 261: + case 264: return 1 | 4 | 32; - case 149: + case 150: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 150: - case 225: - case 148: case 151: + case 227: + case 149: case 152: case 153: case 154: case 155: - case 158: + case 156: case 159: + case 160: return 1 | 4 | 32 | 8; - case 184: case 185: + case 186: return 1 | 4 | 32 | 8 | 16; - case 231: + case 233: return 4; - case 147: + case 148: return node.initializer ? 4 : 0; - case 256: - case 211: - case 212: + case 259: case 213: - case 232: + case 214: + case 215: + case 234: return 2; - case 204: + case 206: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -19615,37 +19765,38 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 230: + case 232: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 261: + case 264: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 197: - case 226: + case 198: + case 228: return declareClassMember(node, symbolFlags, symbolExcludes); - case 229: + case 231: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 161: - case 176: - case 227: - case 270: - case 287: + case 162: + case 177: + case 229: + case 274: + case 291: + case 253: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 158: case 159: - case 153: + case 160: case 154: case 155: - case 149: - case 148: + case 156: case 150: + case 149: case 151: case 152: - case 225: - case 184: + case 153: + case 227: case 185: - case 274: - case 228: - case 170: + case 186: + case 278: + case 230: + case 171: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -19660,11 +19811,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 261 ? node : node.body; - if (body && (body.kind === 261 || body.kind === 231)) { + var body = node.kind === 264 ? node : node.body; + if (body && (body.kind === 264 || body.kind === 233)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 241 || stat.kind === 240) { + if (stat.kind === 243 || stat.kind === 242) { return true; } } @@ -19686,7 +19837,7 @@ var ts; errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isExternalModuleAugmentation(node)) { - declareSymbolAndAddToSymbolTable(node, 1024, 0); + declareModuleSymbol(node); } else { var pattern = void 0; @@ -19706,12 +19857,8 @@ var ts; } } else { - var state = getModuleInstanceState(node); - if (state === 0) { - declareSymbolAndAddToSymbolTable(node, 1024, 0); - } - else { - declareSymbolAndAddToSymbolTable(node, 512, 106639); + var state = declareModuleSymbol(node); + if (state !== 0) { if (node.symbol.flags & (16 | 32 | 256)) { node.symbol.constEnumOnlyModule = false; } @@ -19727,29 +19874,40 @@ var ts; } } } + function declareModuleSymbol(node) { + var state = getModuleInstanceState(node); + var instantiated = state !== 0; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 : 1024, instantiated ? 106639 : 0); + return state; + } function bindFunctionOrConstructorType(node) { var symbol = createSymbol(131072, getDeclarationName(node)); addDeclarationToSymbol(symbol, node, 131072); var typeLiteralSymbol = createSymbol(2048, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, 2048); typeLiteralSymbol.members = ts.createMap(); - typeLiteralSymbol.members[symbol.name] = symbol; + typeLiteralSymbol.members.set(symbol.name, symbol); } function bindObjectLiteralExpression(node) { + var ElementKind; + (function (ElementKind) { + ElementKind[ElementKind["Property"] = 1] = "Property"; + ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; + })(ElementKind || (ElementKind = {})); if (inStrictMode) { var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 || prop.name.kind !== 70) { + if (prop.kind === 262 || prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 257 || prop.kind === 258 || prop.kind === 149 + var currentKind = prop.kind === 260 || prop.kind === 261 || prop.kind === 150 ? 1 : 2; - var existingKind = seen[identifier.text]; + var existingKind = seen.get(identifier.text); if (!existingKind) { - seen[identifier.text] = currentKind; + seen.set(identifier.text, currentKind); continue; } if (currentKind === 1 && existingKind === 1) { @@ -19760,16 +19918,22 @@ var ts; } return bindAnonymousDeclaration(node, 4096, "__object"); } + function bindJsxAttributes(node) { + return bindAnonymousDeclaration(node, 4096, "__jsxAttributes"); + } + function bindJsxAttribute(node, symbolFlags, symbolExcludes) { + return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); + } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 230: + case 232: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 261: + case 264: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -19859,8 +20023,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 261 && - blockScopeContainer.kind !== 230 && + if (blockScopeContainer.kind !== 264 && + blockScopeContainer.kind !== 232 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -19903,7 +20067,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 140) { + if (node.kind > 141) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -19943,23 +20107,23 @@ var ts; case 70: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 285) { + while (parentNode && parentNode.kind !== 289) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); break; } case 98: - if (currentFlow && (ts.isExpression(node) || parent.kind === 258)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 261)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 177: + case 178: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 192: + case 193: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -19982,48 +20146,48 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 256: + case 259: return checkStrictModeCatchClause(node); - case 186: + case 187: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 191: + case 192: return checkStrictModePostfixUnaryExpression(node); - case 190: + case 191: return checkStrictModePrefixUnaryExpression(node); - case 217: + case 219: return checkStrictModeWithStatement(node); - case 167: + case 168: seenThisKeyword = true; return; - case 156: + case 157: return checkTypePredicate(node); - case 143: - return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 144: + return declareSymbolAndAddToSymbolTable(node, 262144, 530920); + case 145: return bindParameter(node); - case 223: - case 174: + case 225: + case 175: return bindVariableDeclarationOrBindingElement(node); + case 148: case 147: - case 146: - case 271: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 286: + case 275: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 67108864 : 0), 0); + case 290: return bindJSDocProperty(node); - case 257: - case 258: - return bindPropertyOrMethodOrAccessor(node, 4, 0); case 260: + case 261: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 263: return bindPropertyOrMethodOrAccessor(node, 8, 900095); - case 259: - case 251: + case 262: + case 254: var root = container; var hasRest = false; while (root.parent) { - if (root.kind === 176 && - root.parent.kind === 192 && + if (root.kind === 177 && + root.parent.kind === 193 && root.parent.operatorToken.kind === 57 && root.parent.left === root) { hasRest = true; @@ -20032,78 +20196,82 @@ var ts; root = root.parent; } return; - case 153: case 154: case 155: + case 156: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 149: - case 148: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 225: - return bindFunctionDeclaration(node); case 150: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 149: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 67108864 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); + case 227: + return bindFunctionDeclaration(node); case 151: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 152: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 153: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 158: case 159: - case 274: + case 160: + case 278: return bindFunctionOrConstructorType(node); - case 161: - case 170: - case 287: - case 270: + case 162: + case 171: + case 291: + case 274: return bindAnonymousDeclaration(node, 2048, "__type"); - case 176: + case 177: return bindObjectLiteralExpression(node); - case 184: case 185: + case 186: return bindFunctionExpression(node); - case 179: + case 180: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 197: - case 226: + case 198: + case 228: inStrictMode = true; return bindClassLikeDeclaration(node); - case 227: + case 229: return bindBlockScopedDeclaration(node, 64, 792968); - case 285: + case 289: if (!node.fullName || node.fullName.kind === 70) { return bindBlockScopedDeclaration(node, 524288, 793064); } break; - case 228: - return bindBlockScopedDeclaration(node, 524288, 793064); - case 229: - return bindEnumDeclaration(node); case 230: + return bindBlockScopedDeclaration(node, 524288, 793064); + case 231: + return bindEnumDeclaration(node); + case 232: return bindModuleDeclaration(node); - case 234: - case 237: - case 239: - case 243: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 233: - return bindNamespaceExportDeclaration(node); + case 253: + return bindJsxAttributes(node); + case 252: + return bindJsxAttribute(node, 4, 0); case 236: - return bindImportClause(node); + case 239: case 241: + case 245: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 235: + return bindNamespaceExportDeclaration(node); + case 238: + return bindImportClause(node); + case 243: return bindExportDeclaration(node); - case 240: + case 242: return bindExportAssignment(node); - case 261: + case 264: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 204: + case 206: if (!ts.isFunctionLike(node.parent)) { return; } - case 231: + case 233: return updateStrictModeStatementList(node.statements); } } @@ -20112,7 +20280,7 @@ var ts; if (parameterName && parameterName.kind === 70) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 167) { + if (parameterName && parameterName.kind === 168) { seenThisKeyword = true; } bind(type); @@ -20131,7 +20299,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 240 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 242 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -20141,17 +20309,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 261) { + if (node.parent.kind !== 264) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_4 = node.parent; - if (!ts.isExternalModule(parent_4)) { + var parent_1 = node.parent; + if (!ts.isExternalModule(parent_1)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_4.isDeclarationFile) { + if (!parent_1.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -20161,10 +20329,10 @@ var ts; } function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { - bindAnonymousDeclaration(node, 1073741824, getDeclarationName(node)); + bindAnonymousDeclaration(node, 33554432, getDeclarationName(node)); } else if (!node.exportClause) { - declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); + declareSymbol(container.symbol.exports, container.symbol, node, 33554432, 0); } } function bindImportClause(node) { @@ -20190,11 +20358,11 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 225 || container.kind === 184) { + if (container.kind === 227 || container.kind === 185) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } - else if (container.kind === 150) { + else if (container.kind === 151) { var saveContainer = container; container = container.parent; var symbol = bindPropertyOrMethodOrAccessor(node, 4, 0); @@ -20211,7 +20379,7 @@ var ts; leftSideOfAssignment.parent = node; constructorFunction.parent = classPrototype; classPrototype.parent = leftSideOfAssignment; - var funcSymbol = container.locals[constructorFunction.text]; + var funcSymbol = container.locals.get(constructorFunction.text); if (!funcSymbol || !(funcSymbol.flags & 16 || ts.isDeclarationOfFunctionExpression(funcSymbol))) { return; } @@ -20226,25 +20394,26 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 226) { + if (node.kind === 228) { 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; + classifiableNames.set(node.name.text, node.name.text); } } var symbol = node.symbol; - var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); - if (symbol.exports[prototypeSymbol.name]) { + var prototypeSymbol = createSymbol(4 | 16777216, "prototype"); + var symbolExport = symbol.exports.get(prototypeSymbol.name); + if (symbolExport) { 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)); + file.bindDiagnostics.push(ts.createDiagnosticForNode(symbolExport.declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; + symbol.exports.set(prototypeSymbol.name, prototypeSymbol); prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { @@ -20280,7 +20449,7 @@ var ts; } if (ts.isParameterPropertyDeclaration(node)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 536870912 : 0), 0); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 67108864 : 0), 0); } } function bindFunctionDeclaration(node) { @@ -20336,15 +20505,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 206) || - node.kind === 226 || - (node.kind === 230 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 229 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 208) || + node.kind === 228 || + (node.kind === 232 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 231 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 205 || + (node.kind !== 207 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -20358,56 +20527,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 179: - return computeCallExpression(node, subtreeFlags); case 180: + return computeCallExpression(node, subtreeFlags); + case 181: return computeNewExpression(node, subtreeFlags); - case 230: + case 232: return computeModuleDeclaration(node, subtreeFlags); - case 183: - return computeParenthesizedExpression(node, subtreeFlags); - case 192: - return computeBinaryExpression(node, subtreeFlags); - case 207: - return computeExpressionStatement(node, subtreeFlags); - case 144: - return computeParameter(node, subtreeFlags); - case 185: - return computeArrowFunction(node, subtreeFlags); case 184: + return computeParenthesizedExpression(node, subtreeFlags); + case 193: + return computeBinaryExpression(node, subtreeFlags); + case 209: + return computeExpressionStatement(node, subtreeFlags); + case 145: + return computeParameter(node, subtreeFlags); + case 186: + return computeArrowFunction(node, subtreeFlags); + case 185: return computeFunctionExpression(node, subtreeFlags); - case 225: + case 227: return computeFunctionDeclaration(node, subtreeFlags); - case 223: + case 225: return computeVariableDeclaration(node, subtreeFlags); - case 224: - return computeVariableDeclarationList(node, subtreeFlags); - case 205: - return computeVariableStatement(node, subtreeFlags); - case 219: - return computeLabeledStatement(node, subtreeFlags); case 226: + return computeVariableDeclarationList(node, subtreeFlags); + case 207: + return computeVariableStatement(node, subtreeFlags); + case 221: + return computeLabeledStatement(node, subtreeFlags); + case 228: return computeClassDeclaration(node, subtreeFlags); - case 197: + case 198: return computeClassExpression(node, subtreeFlags); - case 255: + case 258: return computeHeritageClause(node, subtreeFlags); - case 256: + case 259: return computeCatchClause(node, subtreeFlags); - case 199: + case 200: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 150: - return computeConstructor(node, subtreeFlags); - case 147: - return computePropertyDeclaration(node, subtreeFlags); - case 149: - return computeMethod(node, subtreeFlags); case 151: + return computeConstructor(node, subtreeFlags); + case 148: + return computePropertyDeclaration(node, subtreeFlags); + case 150: + return computeMethod(node, subtreeFlags); case 152: + case 153: return computeAccessor(node, subtreeFlags); - case 234: + case 236: return computeImportEquals(node, subtreeFlags); - case 177: + case 178: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -20432,8 +20601,8 @@ var ts; switch (kind) { case 96: return true; - case 177: case 178: + case 179: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96; @@ -20455,10 +20624,10 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 && leftKind === 176) { + if (operatorTokenKind === 57 && leftKind === 177) { transformFlags |= 8 | 192 | 3072; } - else if (operatorTokenKind === 57 && leftKind === 175) { + else if (operatorTokenKind === 57 && leftKind === 176) { transformFlags |= 192 | 3072; } else if (operatorTokenKind === 39 @@ -20497,8 +20666,8 @@ var ts; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 200 - || expressionKind === 182) { + if (expressionKind === 201 + || expressionKind === 183) { transformFlags |= 3; } if (expressionTransformFlags & 1024) { @@ -20784,7 +20953,7 @@ var ts; var excludeFlags = 536872257; switch (kind) { case 119: - case 189: + case 190: transformFlags |= 16; break; case 113: @@ -20793,50 +20962,52 @@ var ts; case 116: case 123: case 75: - case 229: - case 260: - case 182: - case 200: + case 231: + case 263: + case 183: case 201: + case 202: case 130: transformFlags |= 3; break; - case 246: - case 247: case 248: - case 10: case 249: case 250: + case 10: case 251: case 252: + case 253: + case 254: + case 255: transformFlags |= 4; break; - case 213: + case 215: transformFlags |= 8; case 12: case 13: case 14: case 15: - case 194: - case 181: - case 258: + case 195: + case 182: + case 261: case 114: + case 203: transformFlags |= 192; break; - case 195: + case 196: transformFlags |= 192 | 16777216; break; case 118: case 132: case 129: - case 134: - case 121: + case 133: case 135: + case 121: + case 136: case 104: - case 143: - case 146: - case 148: - case 153: + case 144: + case 147: + case 149: case 154: case 155: case 156: @@ -20850,26 +21021,27 @@ var ts; case 164: case 165: case 166: - case 227: - case 228: case 167: + case 229: + case 230: case 168: case 169: case 170: case 171: + case 172: transformFlags = 3; excludeFlags = -3; break; - case 142: + case 143: transformFlags |= 2097152; if (subtreeFlags & 16384) { transformFlags |= 65536; } break; - case 196: + case 197: transformFlags |= 192 | 524288; break; - case 259: + case 262: transformFlags |= 8 | 1048576; break; case 96: @@ -20878,27 +21050,27 @@ var ts; case 98: transformFlags |= 16384; break; - case 172: + case 173: transformFlags |= 192 | 8388608; if (subtreeFlags & 524288) { transformFlags |= 8 | 1048576; } excludeFlags = 537396545; break; - case 173: + case 174: transformFlags |= 192 | 8388608; excludeFlags = 537396545; break; - case 174: + case 175: transformFlags |= 192; if (node.dotDotDotToken) { transformFlags |= 524288; } break; - case 145: + case 146: transformFlags |= 3 | 4096; break; - case 176: + case 177: excludeFlags = 540087617; if (subtreeFlags & 2097152) { transformFlags |= 192; @@ -20910,29 +21082,29 @@ var ts; transformFlags |= 8; } break; - case 175: - case 180: + case 176: + case 181: excludeFlags = 537396545; if (subtreeFlags & 524288) { transformFlags |= 192; } break; - case 209: - case 210: case 211: case 212: + case 213: + case 214: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 261: + case 264: if (subtreeFlags & 32768) { transformFlags |= 192; } break; + case 218: case 216: - case 214: - case 215: + case 217: transformFlags |= 33554432; break; } @@ -20940,56 +21112,57 @@ var ts; return transformFlags & ~excludeFlags; } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 156 && kind <= 171) { + if (kind >= 157 && kind <= 172) { return -3; } switch (kind) { - case 179: case 180: - case 175: + case 181: + case 176: return 537396545; - case 230: + case 232: return 574674241; - case 144: + case 145: return 536872257; - case 185: + case 186: return 601249089; - case 184: - case 225: + case 185: + case 227: return 601281857; - case 224: - return 546309441; case 226: - case 197: + return 546309441; + case 228: + case 198: return 539358529; - case 150: - return 601015617; - case 149: case 151: + return 601015617; + case 150: case 152: + case 153: return 601015617; case 118: case 132: case 129: - case 134: - case 121: case 135: + case 133: + case 121: + case 136: case 104: - case 143: - case 146: - case 148: - case 153: + case 144: + case 147: + case 149: case 154: case 155: - case 227: - case 228: + case 156: + case 229: + case 230: return -3; - case 176: + case 177: return 540087617; - case 256: + case 259: return 537920833; - case 172: case 173: + case 174: return 537396545; default: return 536872257; @@ -21038,9 +21211,9 @@ var ts; var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; var strictNullChecks = compilerOptions.strictNullChecks; var emitResolver = createResolver(); - var undefinedSymbol = createSymbol(4 | 67108864, "undefined"); + var undefinedSymbol = createSymbol(4, "undefined"); undefinedSymbol.declarations = []; - var argumentsSymbol = createSymbol(4 | 67108864, "arguments"); + var argumentsSymbol = createSymbol(4, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, @@ -21056,9 +21229,12 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, + getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, + getTypeFromTypeNode: getTypeFromTypeNode, + getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -21067,6 +21243,7 @@ var ts; getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, + signatureToString: signatureToString, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -21082,14 +21259,16 @@ var ts; getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, + getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getAmbientModules: getAmbientModules, - getJsxElementAttributesType: getJsxElementAttributesType, + getAllAttributesTypeFromJsxOpeningLikeElement: getAllAttributesTypeFromJsxOpeningLikeElement, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, isOptionalParameter: isOptionalParameter, tryGetMemberInModuleExports: tryGetMemberInModuleExports, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { return tryFindAmbientModule(moduleName, false); - } + }, + getApparentType: getApparentType }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -21098,8 +21277,8 @@ var ts; var numericLiteralTypes = ts.createMap(); var indexedAccessTypes = ts.createMap(); var evolvingArrayTypes = []; - var unknownSymbol = createSymbol(4 | 67108864, "unknown"); - var resolvingSymbol = createSymbol(67108864, "__resolving__"); + var unknownSymbol = createSymbol(4, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__"); var anyType = createIntrinsicType(1, "any"); var autoType = createIntrinsicType(1, "any"); var unknownType = createIntrinsicType(1, "unknown"); @@ -21116,8 +21295,9 @@ var ts; var voidType = createIntrinsicType(1024, "void"); var neverType = createIntrinsicType(8192, "never"); var silentNeverType = createIntrinsicType(8192, "never"); + var nonPrimitiveType = createIntrinsicType(16777216, "object"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var emptyTypeLiteralSymbol = createSymbol(2048 | 67108864, "__type"); + var emptyTypeLiteralSymbol = createSymbol(2048, "__type"); emptyTypeLiteralSymbol.members = ts.createMap(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -21125,6 +21305,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); anyFunctionType.flags |= 8388608; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); var resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false); @@ -21183,9 +21364,70 @@ var ts; var visitedFlowNodes = []; var visitedFlowTypes = []; var potentialThisCollisions = []; + var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - var typeofEQFacts = ts.createMap({ + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; + TypeFacts[TypeFacts["Discriminatable"] = 4194304] = "Discriminatable"; + TypeFacts[TypeFacts["All"] = 8388607] = "All"; + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; + TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; + TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; + TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 6166480] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 8378320] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 6164448] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 8376288] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; + })(TypeFacts || (TypeFacts = {})); + var typeofEQFacts = ts.createMapFromTemplate({ "string": 1, "number": 2, "boolean": 4, @@ -21194,7 +21436,7 @@ var ts; "object": 16, "function": 32 }); - var typeofNEFacts = ts.createMap({ + var typeofNEFacts = ts.createMapFromTemplate({ "string": 128, "number": 256, "boolean": 512, @@ -21203,13 +21445,14 @@ var ts; "object": 2048, "function": 4096 }); - var typeofTypesByName = ts.createMap({ + var typeofTypesByName = ts.createMapFromTemplate({ "string": stringType, "number": numberType, "boolean": booleanType, "symbol": esSymbolType, "undefined": undefinedType }); + var typeofType = createTypeofType(); var jsxElementType; var _jsxNamespace; var _jsxFactoryEntity; @@ -21229,8 +21472,15 @@ var ts; var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); var _displayBuilder; + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var builtinGlobals = ts.createMap(); - builtinGlobals[undefinedSymbol.name] = undefinedSymbol; + builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); initializeTypeChecker(); return checker; function getJsxNamespace() { @@ -21260,7 +21510,9 @@ var ts; } function createSymbol(flags, name) { symbolCount++; - return new Symbol(flags, name); + var symbol = (new Symbol(flags | 134217728, name)); + symbol.checkFlags = 0; + return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; @@ -21306,7 +21558,7 @@ var ts; mergedSymbols[source.mergeId] = target; } function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 33554432, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); result.declarations = symbol.declarations.slice(0); result.parent = symbol.parent; if (symbol.valueDeclaration) @@ -21328,7 +21580,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 230 && source.valueDeclaration.kind !== 230))) { + (target.valueDeclaration.kind === 232 && source.valueDeclaration.kind !== 232))) { target.valueDeclaration = source.valueDeclaration; } ts.addRange(target.declarations, source.declarations); @@ -21344,6 +21596,9 @@ var ts; } recordMergedSymbol(target, source); } + else if (target.flags & 1024) { + error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + } else { var message_2 = target.flags & 2 || source.flags & 2 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -21356,18 +21611,19 @@ var ts; } } function mergeSymbolTable(target, source) { - for (var id in source) { - var targetSymbol = target[id]; + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); if (!targetSymbol) { - target[id] = source[id]; + target.set(id, sourceSymbol); } else { - if (!(targetSymbol.flags & 33554432)) { - target[id] = targetSymbol = cloneSymbol(targetSymbol); + if (!(targetSymbol.flags & 134217728)) { + targetSymbol = cloneSymbol(targetSymbol); + target.set(id, targetSymbol); } - mergeSymbol(targetSymbol, source[id]); + mergeSymbol(targetSymbol, sourceSymbol); } - } + }); } function mergeModuleAugmentation(moduleName) { var moduleAugmentation = moduleName.parent; @@ -21388,7 +21644,7 @@ var ts; } mainModule = resolveExternalModuleSymbol(mainModule); if (mainModule.flags & 1920) { - mainModule = mainModule.flags & 33554432 ? mainModule : cloneSymbol(mainModule); + mainModule = mainModule.flags & 134217728 ? mainModule : cloneSymbol(mainModule); mergeSymbol(mainModule, moduleAugmentation.symbol); } else { @@ -21397,20 +21653,21 @@ var ts; } } function addToSymbolTable(target, source, message) { - for (var id in source) { - if (target[id]) { - ts.forEach(target[id].declarations, addDeclarationDiagnostic(id, message)); + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); + if (targetSymbol) { + ts.forEach(targetSymbol.declarations, addDeclarationDiagnostic(id, message)); } else { - target[id] = source[id]; + target.set(id, sourceSymbol); } - } + }); function addDeclarationDiagnostic(id, message) { return function (declaration) { return diagnostics.add(ts.createDiagnosticForNode(declaration, message, id)); }; } } function getSymbolLinks(symbol) { - if (symbol.flags & 67108864) + if (symbol.flags & 134217728) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = {}); @@ -21422,14 +21679,17 @@ var ts; function getObjectFlags(type) { return type.flags & 32768 ? type.objectFlags : 0; } + function getCheckFlags(symbol) { + return symbol.flags & 134217728 ? symbol.checkFlags : 0; + } function isGlobalSourceFile(node) { - return node.kind === 261 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 264 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { - var symbol = symbols[name]; + var symbol = symbols.get(name); if (symbol) { - ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } @@ -21460,39 +21720,50 @@ var ts; (!compilerOptions.outFile && !compilerOptions.out)) { return true; } - if (isUsedInFunctionOrNonStaticProperty(usage)) { + if (isUsedInFunctionOrInstanceProperty(usage)) { return true; } var sourceFiles = host.getSourceFiles(); return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 223 || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + if (declaration.kind === 175) { + var errorBindingElement = ts.getAncestor(usage, 175); + if (errorBindingElement) { + return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + declaration.pos < errorBindingElement.pos; + } + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 225), usage); + } + else if (declaration.kind === 225) { + return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); - return isUsedInFunctionOrNonStaticProperty(usage, container); + var isInstanceProperty = declaration.kind === 148 && !(ts.getModifierFlags(declaration) & 32); + return isUsedInFunctionOrInstanceProperty(usage, isInstanceProperty, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 205: - case 211: + case 207: case 213: + case 215: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 212: - case 213: + case 214: + case 215: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } } return false; } - function isUsedInFunctionOrNonStaticProperty(usage, container) { + function isUsedInFunctionOrInstanceProperty(usage, isDeclarationInstanceProperty, container) { var current = usage; while (current) { if (current === container) { @@ -21501,17 +21772,26 @@ var ts; if (ts.isFunctionLike(current)) { return true; } - var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 147 && + var initializerOfInstanceProperty = current.parent && + current.parent.kind === 148 && (ts.getModifierFlags(current.parent) & 32) === 0 && current.parent.initializer === current; - if (initializerOfNonStaticProperty) { - return true; + if (initializerOfInstanceProperty) { + return !isDeclarationInstanceProperty; } current = current.parent; } return false; } + function getAncestorBindingPattern(node) { + while (node) { + if (ts.isBindingPattern(node)) { + return node; + } + node = node.parent; + } + return undefined; + } } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { var result; @@ -21525,18 +21805,18 @@ var ts; if (result = getSymbol(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 793064 && lastLocation.kind !== 278) { + if (meaning & result.flags & 793064 && lastLocation.kind !== 282) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 144 || - lastLocation.kind === 143 + lastLocation.kind === 145 || + lastLocation.kind === 144 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 144 || + lastLocation.kind === 145 || (lastLocation === location.type && - result.valueDeclaration.kind === 144); + result.valueDeclaration.kind === 145); } } if (useResult) { @@ -21548,23 +21828,24 @@ var ts; } } switch (location.kind) { - case 261: + case 264: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 230: + case 232: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 261 || ts.isAmbientModule(location)) { - if (result = moduleExports["default"]) { + if (location.kind === 264 || ts.isAmbientModule(location)) { + if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } - if (moduleExports[name] && - moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 243)) { + var moduleExport = moduleExports.get(name); + if (moduleExport && + moduleExport.flags === 8388608 && + ts.getDeclarationOfKind(moduleExport, 245)) { break; } } @@ -21572,13 +21853,13 @@ var ts; break loop; } break; - case 229: + case 231: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 148: case 147: - case 146: if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -21588,17 +21869,21 @@ var ts; } } break; - case 226: - case 197: - case 227: + case 228: + case 198: + case 229: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { + if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { + result = undefined; + break; + } if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; } break loop; } - if (location.kind === 197 && meaning & 32) { + if (location.kind === 198 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -21606,28 +21891,28 @@ var ts; } } break; - case 142: + case 143: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 227) { + if (ts.isClassLike(grandparent) || grandparent.kind === 229) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 225: - case 185: + case 153: + case 227: + case 186: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 184: + case 185: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -21640,8 +21925,8 @@ var ts; } } break; - case 145: - if (location.parent && location.parent.kind === 144) { + case 146: + if (location.parent && location.parent.kind === 145) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -21684,13 +21969,22 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 233) { + if (decls && decls.length === 1 && decls[0].kind === 235) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } } return result; } + function isTypeParameterSymbolDeclaredInContainer(symbol, container) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.kind === 144 && decl.parent === container) { + return true; + } + } + return false; + } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { if ((errorLocation.kind === 70 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; @@ -21731,9 +22025,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70: - case 177: + case 178: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 199: + case 200: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -21764,7 +22058,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 223), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -21781,10 +22075,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 234) { + if (node.kind === 236) { return node; } - while (node && node.kind !== 235) { + while (node && node.kind !== 237) { node = node.parent; } return node; @@ -21794,7 +22088,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 245) { + if (node.moduleReference.kind === 247) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -21802,11 +22096,16 @@ var ts; function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { - var exportDefaultSymbol = ts.isShorthandAmbientModuleSymbol(moduleSymbol) ? - moduleSymbol : - moduleSymbol.exports["export="] ? - getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") : - resolveSymbol(moduleSymbol.exports["default"]); + var exportDefaultSymbol = void 0; + if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { + exportDefaultSymbol = moduleSymbol; + } + else { + var exportValue = moduleSymbol.exports.get("export="); + exportDefaultSymbol = exportValue + ? getPropertyOfType(getTypeOfSymbol(exportValue), "default") + : resolveSymbol(moduleSymbol.exports.get("default")); + } if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } @@ -21837,7 +22136,7 @@ var ts; } function getExportOfModule(symbol, name) { if (symbol.flags & 1536) { - var exportedSymbol = getExportsOfSymbol(symbol)[name]; + var exportedSymbol = getExportsOfSymbol(symbol).get(name); if (exportedSymbol) { return resolveSymbol(exportedSymbol); } @@ -21855,28 +22154,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_18 = specifier.propertyName || specifier.name; - if (name_18.text) { + var name = specifier.propertyName || specifier.name; + if (name.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_18.text); + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) { + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_18.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_18.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_18.text === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name.text); + if (!symbolFromModule && allowSyntheticDefaultImports && name.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_18, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_18)); + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name)); } return symbol; } @@ -21898,19 +22197,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 234: - return getTargetOfImportEqualsDeclaration(node); case 236: + return getTargetOfImportEqualsDeclaration(node); + case 238: return getTargetOfImportClause(node); - case 237: - return getTargetOfNamespaceImport(node); case 239: + return getTargetOfNamespaceImport(node); + case 241: return getTargetOfImportSpecifier(node); - case 243: + case 245: return getTargetOfExportSpecifier(node); - case 240: + case 242: return getTargetOfExportAssignment(node); - case 233: + case 235: return getTargetOfNamespaceExportDeclaration(node); } } @@ -21954,10 +22253,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 240) { + if (node.kind === 242) { checkExpressionCached(node.expression); } - else if (node.kind === 243) { + else if (node.kind === 245) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -21969,11 +22268,11 @@ var ts; if (entityName.kind === 70 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 70 || entityName.parent.kind === 141) { + if (entityName.kind === 70 || entityName.parent.kind === 142) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 234); + ts.Debug.assert(entityName.parent.kind === 236); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -21992,9 +22291,9 @@ var ts; return undefined; } } - else if (name.kind === 141 || name.kind === 177) { - var left = name.kind === 141 ? name.left : name.expression; - var right = name.kind === 141 ? name.right : name.name; + else if (name.kind === 142 || name.kind === 178) { + var left = name.kind === 142 ? name.left : name.expression; + var right = name.kind === 142 ? name.right : name.name; var namespace = resolveEntityName(left, 1920, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -22013,7 +22312,7 @@ var ts; else { ts.Debug.fail("Unknown entity name kind."); } - ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); } function resolveExternalModuleName(location, moduleReferenceExpression) { @@ -22084,7 +22383,7 @@ var ts; return undefined; } function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports["export="])) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="))) || moduleSymbol; } function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { var symbol = resolveExternalModuleSymbol(moduleSymbol); @@ -22095,15 +22394,23 @@ var ts; return symbol; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["export="] !== undefined; + return moduleSymbol.exports.get("export=") !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); } + function getExportsAndPropertiesOfModule(moduleSymbol) { + var exports = getExportsOfModuleAsArray(moduleSymbol); + var exportEquals = resolveExternalModuleSymbol(moduleSymbol); + if (exportEquals !== moduleSymbol) { + ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + } + return exports; + } function tryGetMemberInModuleExports(memberName, moduleSymbol) { var symbolTable = getExportsOfModule(moduleSymbol); if (symbolTable) { - return symbolTable[memberName]; + return symbolTable.get(memberName); } } function getExportsOfSymbol(symbol) { @@ -22114,24 +22421,28 @@ var ts; return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol)); } function extendExportSymbols(target, source, lookupTable, exportNode) { - for (var id in source) { - if (id !== "default" && !target[id]) { - target[id] = source[id]; + source && source.forEach(function (sourceSymbol, id) { + if (id === "default") + return; + var targetSymbol = target.get(id); + if (!targetSymbol) { + target.set(id, sourceSymbol); if (lookupTable && exportNode) { - lookupTable[id] = { + lookupTable.set(id, { specifierText: ts.getTextOfNode(exportNode.moduleSpecifier) - }; + }); } } - else if (lookupTable && exportNode && id !== "default" && target[id] && resolveSymbol(target[id]) !== resolveSymbol(source[id])) { - if (!lookupTable[id].exportsWithDuplicate) { - lookupTable[id].exportsWithDuplicate = [exportNode]; + else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) { + var collisionTracker = lookupTable.get(id); + if (!collisionTracker.exportsWithDuplicate) { + collisionTracker.exportsWithDuplicate = [exportNode]; } else { - lookupTable[id].exportsWithDuplicate.push(exportNode); + collisionTracker.exportsWithDuplicate.push(exportNode); } } - } + }); } function getExportsForModule(moduleSymbol) { var visitedSymbols = []; @@ -22143,26 +22454,26 @@ var ts; } visitedSymbols.push(symbol); var symbols = ts.cloneMap(symbol.exports); - var exportStars = symbol.exports["__export"]; + var exportStars = symbol.exports.get("__export"); if (exportStars) { var nestedSymbols = ts.createMap(); - var lookupTable = ts.createMap(); + var lookupTable_1 = ts.createMap(); for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { var node = _a[_i]; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); var exportedSymbols = visit(resolvedModule); - extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable, node); + extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); } - for (var id in lookupTable) { - var exportsWithDuplicate = lookupTable[id].exportsWithDuplicate; - if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols[id]) { - continue; + lookupTable_1.forEach(function (_a, id) { + var exportsWithDuplicate = _a.exportsWithDuplicate; + if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) { + return; } - for (var _b = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _b < exportsWithDuplicate_1.length; _b++) { - var node = exportsWithDuplicate_1[_b]; - diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable[id].specifierText, id)); + for (var _i = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _i < exportsWithDuplicate_1.length; _i++) { + var node = exportsWithDuplicate_1[_i]; + diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable_1.get(id).specifierText, id)); } - } + }); extendExportSymbols(symbols, nestedSymbols); } return symbols; @@ -22184,22 +22495,13 @@ var ts; : 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; + return !!(symbol.flags & 107455 || symbol.flags & 8388608 && resolveAlias(symbol).flags & 107455); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 150 && ts.nodeIsPresent(member.body)) { + if (member.kind === 151 && ts.nodeIsPresent(member.body)) { return member; } } @@ -22227,6 +22529,9 @@ var ts; type.symbol = symbol; return type; } + function createTypeofType() { + return getUnionType(ts.convertToArray(typeofEQFacts.keys(), function (s) { return getLiteralTypeForText(32, s); })); + } function isReservedMemberName(name) { return name.charCodeAt(0) === 95 && name.charCodeAt(1) === 95 && @@ -22235,16 +22540,15 @@ var ts; } function getNamedMembers(members) { var result; - for (var id in members) { + members.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { if (!result) result = []; - var symbol = members[id]; if (symbolIsValue(symbol)) { result.push(symbol); } } - } + }); return result || emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -22263,19 +22567,19 @@ var ts; } 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)) { + for (var location = enclosingDeclaration; location; location = location.parent) { + if (location.locals && !isGlobalSourceFile(location)) { + if (result = callback(location.locals)) { return result; } } - switch (location_1.kind) { - case 261: - if (!ts.isExternalOrCommonJsModule(location_1)) { + switch (location.kind) { + case 264: + if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230: - if (result = callback(getSymbolOfNode(location_1).exports)) { + case 232: + if (result = callback(getSymbolOfNode(location).exports)) { return result; } break; @@ -22312,13 +22616,13 @@ var ts; } } function trySymbolTable(symbols) { - if (isAccessible(symbols[symbol.name])) { + if (isAccessible(symbols.get(symbol.name))) { return [symbol]; } - return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { + return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -22343,14 +22647,14 @@ var ts; function needsQualification(symbol, enclosingDeclaration, meaning) { var qualify = false; forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { - var symbolFromSymbolTable = symbolTable[symbol.name]; + var symbolFromSymbolTable = symbolTable.get(symbol.name); if (!symbolFromSymbolTable) { return false; } if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -22364,10 +22668,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 147: - case 149: - case 151: + case 148: + case 150: case 152: + case 153: continue; default: return false; @@ -22423,7 +22727,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 261 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 264 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -22457,11 +22761,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 160 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 161 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning = 107455 | 1048576; } - else if (entityName.kind === 141 || entityName.kind === 177 || - entityName.parent.kind === 234) { + else if (entityName.kind === 142 || entityName.kind === 178 || + entityName.parent.kind === 236) { meaning = 1920; } else { @@ -22553,10 +22857,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 166) { + while (node.kind === 167) { node = node.parent; } - if (node.kind === 228) { + if (node.kind === 230) { return getSymbolOfNode(node); } } @@ -22564,29 +22868,29 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 231 && + node.parent.kind === 233 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { return type.flags & 32 ? "\"" + ts.escapeString(type.text) + "\"" : type.text; } - 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 197: - return "(Anonymous class)"; - case 184: - case 185: - return "(Anonymous function)"; - } + 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 198: + return "(Anonymous class)"; + case 185: + case 186: + return "(Anonymous function)"; } - return symbol.name; } + return symbol.name; + } + function getSymbolDisplayBuilder() { function appendSymbolNameOnly(symbol, writer) { writer.writeSymbol(getNameOfSymbol(symbol), symbol); } @@ -22614,7 +22918,7 @@ var ts; function appendParentTypeArgumentsAndSymbolName(symbol) { if (parentSymbol) { if (flags & 1) { - if (symbol.flags & 16777216) { + if (getCheckFlags(symbol) & 1) { buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); } else { @@ -22633,9 +22937,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_5 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_5) { - walkSymbol(parent_5, getQualifiedLeftMeaning(meaning), false); + var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + walkSymbol(parent, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -22665,7 +22969,7 @@ var ts; return writeType(type, globalFlags); function writeType(type, flags) { var nextFlags = flags & ~512; - if (type.flags & 16015) { + if (type.flags & 16793231) { writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) ? "any" : type.intrinsicName); @@ -22690,7 +22994,7 @@ var ts; else if (!(flags & 512) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) { var typeArguments = type.aliasTypeArguments; - writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); + writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, ts.length(typeArguments), nextFlags); } else if (type.flags & 196608) { writeUnionOrIntersectionType(type, nextFlags); @@ -22768,12 +23072,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_6 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_6); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_6, typeArguments, start, i, flags); + writeSymbolTypeReference(parent, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -22799,7 +23103,8 @@ var ts; function writeAnonymousType(type, flags) { var symbol = type.symbol; if (symbol) { - if (symbol.flags & (32 | 384 | 512)) { + if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (384 | 512)) { writeTypeOfSymbol(type, flags); } else if (shouldWriteTypeOfFunctionSymbol()) { @@ -22832,7 +23137,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 261 || declaration.parent.kind === 231; + return declaration.parent.kind === 264 || declaration.parent.kind === 233; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -22845,32 +23150,13 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } - function writeIndexSignature(info, keyword) { - if (info) { - if (info.isReadonly) { - writeKeyword(writer, 130); - writeSpace(writer); - } - writePunctuation(writer, 20); - writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55); - writeSpace(writer); - writeKeyword(writer, keyword); - writePunctuation(writer, 21); - writePunctuation(writer, 55); - writeSpace(writer); - writeType(info.type, 0); - writePunctuation(writer, 24); - writer.writeLine(); - } - } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { writeKeyword(writer, 130); writeSpace(writer); } buildSymbolDisplay(prop, writer); - if (prop.flags & 536870912) { + if (prop.flags & 67108864) { writePunctuation(writer, 54); } } @@ -22946,8 +23232,8 @@ var ts; writePunctuation(writer, 24); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 134); - writeIndexSignature(resolved.numberIndexInfo, 132); + buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0, enclosingDeclaration, globalFlags, symbolStack); + buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, 1, enclosingDeclaration, globalFlags, symbolStack); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -23013,6 +23299,13 @@ var ts; writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } + var defaultType = getDefaultFromTypeParameter(tp); + if (defaultType) { + writeSpace(writer); + writePunctuation(writer, 57); + writeSpace(writer); + buildTypeDisplay(defaultType, writer, enclosingDeclaration, flags, symbolStack); + } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; @@ -23030,15 +23323,19 @@ var ts; } writePunctuation(writer, 55); writeSpace(writer); - buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); + var type = getTypeOfSymbol(p); + if (isRequiredInitializedParameter(parameterNode)) { + type = includeFalsyTypes(type, 2048); + } + buildTypeDisplay(type, writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 172) { + if (bindingPattern.kind === 173) { writePunctuation(writer, 16); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); writePunctuation(writer, 17); } - else if (bindingPattern.kind === 173) { + else if (bindingPattern.kind === 174) { writePunctuation(writer, 20); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -23052,7 +23349,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 174); + ts.Debug.assert(bindingElement.kind === 175); if (bindingElement.propertyName) { writer.writeProperty(ts.getTextOfNode(bindingElement.propertyName)); writePunctuation(writer, 55); @@ -23126,6 +23423,10 @@ var ts; buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + var returnType = getReturnTypeOfSignature(signature); + if (flags & 2048 && isTypeAny(returnType)) { + return; + } if (flags & 8) { writeSpace(writer); writePunctuation(writer, 35); @@ -23138,7 +23439,6 @@ var ts; buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); } else { - var returnType = getReturnTypeOfSignature(signature); buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } } @@ -23156,6 +23456,32 @@ var ts; buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } + function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 130); + writeSpace(writer); + } + writePunctuation(writer, 20); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 55); + writeSpace(writer); + switch (kind) { + case 1: + writeKeyword(writer, 132); + break; + case 0: + writeKeyword(writer, 135); + break; + } + writePunctuation(writer, 21); + writePunctuation(writer, 55); + writeSpace(writer); + buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); + writePunctuation(writer, 24); + writer.writeLine(); + } + } return _displayBuilder || (_displayBuilder = { buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, @@ -23166,6 +23492,7 @@ var ts; buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, + buildIndexSignatureDisplay: buildIndexSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay }); } @@ -23180,63 +23507,63 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 174: + case 175: return isDeclarationVisible(node.parent.parent); - case 223: + case 225: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 230: - case 226: - case 227: + case 232: case 228: - case 225: case 229: - case 234: + case 230: + case 227: + case 231: + case 236: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_7 = getDeclarationContainer(node); + var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 234 && parent_7.kind !== 261 && ts.isInAmbientContext(parent_7))) { - return isGlobalSourceFile(parent_7); + !(node.kind !== 236 && parent.kind !== 264 && ts.isInAmbientContext(parent))) { + return isGlobalSourceFile(parent); } - return isDeclarationVisible(parent_7); - case 147: - case 146: - case 151: - case 152: - case 149: + return isDeclarationVisible(parent); case 148: + case 147: + case 152: + case 153: + case 150: + case 149: if (ts.getModifierFlags(node) & (8 | 16)) { return false; } - case 150: - case 154: - case 153: + case 151: case 155: - case 144: - case 231: - case 158: + case 154: + case 156: + case 145: + case 233: case 159: - case 161: - case 157: + case 160: case 162: + case 158: case 163: case 164: case 165: case 166: + case 167: return isDeclarationVisible(node.parent); - case 236: - case 237: + case 238: case 239: + case 241: return false; - case 143: - case 261: - case 233: + case 144: + case 264: + case 235: return true; - case 240: + case 242: return false; default: return false; @@ -23245,10 +23572,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 240) { + if (node.parent && node.parent.kind === 242) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 243) { + else if (node.parent.kind === 245) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -23326,12 +23653,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 223: - case 224: + case 225: + case 226: + case 241: + case 240: case 239: case 238: - case 237: - case 236: node = node.parent; break; default: @@ -23350,15 +23677,12 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1) !== 0; } - function isTypeNever(type) { - return type && (type.flags & 8192) !== 0; - } function getTypeForBindingElementParent(node) { var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } function isComputedNonLiteralName(name) { - return name.kind === 142 && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 143 && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 6144); }); @@ -23371,17 +23695,16 @@ var ts; var members = ts.createMap(); var names = ts.createMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name_19 = properties_2[_i]; - names[ts.getTextOfPropertyName(name_19)] = true; + var name = properties_2[_i]; + names.set(ts.getTextOfPropertyName(name), true); } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - var inNamesToRemove = prop.name in names; + var inNamesToRemove = names.has(prop.name); var isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16); - var isMethod = prop.flags & 8192; var isSetOnlyAccessor = prop.flags & 65536 && !(prop.flags & 32768); - if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { - members[prop.name] = prop; + if (!inNamesToRemove && !isPrivate && !isClassMethod(prop) && !isSetOnlyAccessor) { + members.set(prop.name, prop); } } var stringIndexInfo = getIndexInfoOfType(source, 0); @@ -23401,7 +23724,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 172) { + if (pattern.kind === 173) { if (declaration.dotDotDotToken) { if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -23417,19 +23740,19 @@ var ts; type = getRestType(parentType, literalMembers, declaration.symbol); } else { - var name_20 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_20)) { + var name = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name)) { return anyType; } if (declaration.initializer) { getContextualType(declaration.initializer); } - var text = ts.getTextOfPropertyName(name_20); + var text = ts.getTextOfPropertyName(name); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_20)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); return unknownType; } } @@ -23462,7 +23785,7 @@ var ts; getUnionType([type, checkExpressionCached(declaration.initializer)], true) : type; } - function getTypeForVariableLikeDeclarationFromJSDocComment(declaration) { + function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); if (jsdocType) { return getTypeFromTypeNode(jsdocType); @@ -23475,33 +23798,42 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 175 && expr.elements.length === 0; + return expr.kind === 176 && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; } + function removeOptionalityFromAnnotation(annotatedType, declaration) { + var annotationIncludesUndefined = strictNullChecks && + declaration.kind === 145 && + declaration.initializer && + getFalsyFlags(annotatedType) & 2048 && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048); + return annotationIncludesUndefined ? getNonNullableType(annotatedType) : annotatedType; + } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { if (declaration.flags & 65536) { - var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); + var type = getTypeForDeclarationFromJSDocComment(declaration); if (type && type !== unknownType) { return type; } } - if (declaration.parent.parent.kind === 212) { + if (declaration.parent.parent.kind === 214) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 | 262144) ? indexType : stringType; } - if (declaration.parent.parent.kind === 213) { + if (declaration.parent.parent.kind === 215) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } if (declaration.type) { - return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); + var declaredType = removeOptionalityFromAnnotation(getTypeFromTypeNode(declaration.type), declaration); + return addOptionality(declaredType, declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536) && - declaration.kind === 223 && !ts.isBindingPattern(declaration.name) && + declaration.kind === 225 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -23510,10 +23842,10 @@ var ts; return autoArrayType; } } - if (declaration.kind === 144) { + if (declaration.kind === 145) { var func = declaration.parent; - if (func.kind === 152 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 151); + if (func.kind === 153 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 152); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -23539,7 +23871,10 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, declaration.questionToken && includeOptionality); } - if (declaration.kind === 258) { + if (ts.isJsxAttribute(declaration)) { + return trueType; + } + if (declaration.kind === 261) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -23547,6 +23882,21 @@ var ts; } return undefined; } + function getTypeForJSSpecialPropertyDeclaration(declaration) { + var expression = declaration.kind === 193 ? declaration : + declaration.kind === 178 ? ts.getAncestor(declaration, 193) : + undefined; + if (!expression) { + return unknownType; + } + if (expression.flags & 65536) { + var type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type && type !== unknownType) { + return getWidenedType(type); + } + } + return getWidenedLiteralType(checkExpressionCached(expression.right)); + } function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { return checkDeclarationInitializer(element); @@ -23574,11 +23924,11 @@ var ts; return; } var text = ts.getTextOfPropertyName(name); - var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); + var flags = 4 | (e.initializer ? 67108864 : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; - members[symbol.name] = symbol; + members.set(symbol.name, symbol); }); var result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); if (includePatternInType) { @@ -23604,7 +23954,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 172 + return pattern.kind === 173 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -23614,7 +23964,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 257) { + if (declaration.kind === 260) { return type; } return getWidenedType(type); @@ -23629,41 +23979,32 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 144 ? root.parent : root; + var memberDeclaration = root.kind === 145 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.flags & 134217728) { + if (symbol.flags & 16777216) { return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 240) { + if (declaration.kind === 242) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 && declaration.kind === 286 && declaration.typeExpression) { + if (declaration.flags & 65536 && declaration.kind === 290 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { return unknownType; } var type = void 0; - if (declaration.kind === 192 || - declaration.kind === 177 && declaration.parent.kind === 192) { - if (declaration.flags & 65536) { - var jsdocType = ts.getJSDocType(declaration.parent); - if (jsdocType) { - return links.type = getTypeFromTypeNode(jsdocType); - } - } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 192 ? - checkExpressionCached(decl.right) : - checkExpressionCached(decl.parent.right); }); - type = getUnionType(declaredTypes, true); + if (declaration.kind === 193 || + declaration.kind === 178 && declaration.parent.kind === 193) { + type = getWidenedType(getUnionType(ts.map(symbol.declarations, getTypeForJSSpecialPropertyDeclaration), true)); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -23677,7 +24018,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 151) { + if (accessor.kind === 152) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -23697,10 +24038,10 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 151); - var setter = ts.getDeclarationOfKind(symbol, 152); + var getter = ts.getDeclarationOfKind(symbol, 152); + var setter = ts.getDeclarationOfKind(symbol, 153); if (getter && getter.flags & 65536) { - var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); + var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; } @@ -23739,7 +24080,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 151); + var getter_1 = ts.getDeclarationOfKind(symbol, 152); 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)); } } @@ -23747,6 +24088,10 @@ var ts; } return links.type; } + function getBaseTypeVariableOfClass(symbol) { + var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); + return baseConstructorType.flags & 540672 ? baseConstructorType : undefined; + } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { @@ -23755,8 +24100,13 @@ var ts; } else { var type = createObjectType(16, symbol); - links.type = strictNullChecks && symbol.flags & 536870912 ? - includeFalsyTypes(type, 2048) : type; + if (symbol.flags & 32) { + var baseTypeVariable = getBaseTypeVariableOfClass(symbol); + links.type = baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; + } + else { + links.type = strictNullChecks && symbol.flags & 67108864 ? includeFalsyTypes(type, 2048) : type; + } } } return links.type; @@ -23803,7 +24153,7 @@ var ts; return anyType; } function getTypeOfSymbol(symbol) { - if (symbol.flags & 16777216) { + if (getCheckFlags(symbol) & 1) { return getTypeOfInstantiatedSymbol(symbol); } if (symbol.flags & (3 | 4)) { @@ -23829,13 +24179,18 @@ var ts; function hasBaseType(type, checkBase) { return check(type); function check(type) { - var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); + if (getObjectFlags(type) & (3 | 4)) { + var target = getTargetType(type); + return target === checkBase || ts.forEach(getBaseTypes(target), check); + } + else if (type.flags & 131072) { + return ts.forEach(type.types, check); + } } } function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { - var declaration = declarations_2[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -23852,9 +24207,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 226 || node.kind === 197 || - node.kind === 225 || node.kind === 184 || - node.kind === 149 || node.kind === 185) { + if (node.kind === 228 || node.kind === 198 || + node.kind === 227 || node.kind === 185 || + node.kind === 150 || node.kind === 186) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -23863,15 +24218,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 227); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 229); 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 === 227 || node.kind === 226 || - node.kind === 197 || node.kind === 228) { + if (node.kind === 229 || node.kind === 228 || + node.kind === 198 || node.kind === 230) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -23883,15 +24238,30 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } + function isMixinConstructorType(type) { + var signatures = getSignaturesOfType(type, 1); + if (signatures.length === 1) { + var s = signatures[0]; + return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + } + return false; + } function isConstructorType(type) { - return type.flags & 32768 && getSignaturesOfType(type, 1).length > 0; + if (isValidBaseType(type) && getSignaturesOfType(type, 1).length > 0) { + return true; + } + if (type.flags & 540672) { + var constraint = getBaseConstraintOfType(type); + return isValidBaseType(constraint) && isMixinConstructorType(constraint); + } + return false; } 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; }); + var typeArgCount = ts.length(typeArgumentNodes); + return ts.filter(getSignaturesOfType(type, 1), function (sig) { return typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); @@ -23911,7 +24281,7 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 32768) { + if (baseConstructorType.flags & (32768 | 131072)) { resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { @@ -23947,8 +24317,8 @@ var ts; } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - var baseConstructorType = getBaseConstructorTypeOfClass(type); - if (!(baseConstructorType.flags & 32768)) { + var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); + if (!(baseConstructorType.flags & (32768 | 131072))) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -23976,7 +24346,7 @@ var ts; if (baseType === unknownType) { return; } - if (!(getObjectFlags(getTargetType(baseType)) & 3)) { + if (!isValidBaseType(baseType)) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } @@ -24000,16 +24370,20 @@ var ts; } return true; } + function isValidBaseType(type) { + return type.flags & (32768 | 16777216) && !isGenericMappedType(type) || + type.flags & 131072 && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); + } 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 === 227 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 229 && 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 (getObjectFlags(getTargetType(baseType)) & 3) { + if (isValidBaseType(baseType)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; @@ -24033,7 +24407,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227) { + if (declaration.kind === 229) { if (declaration.flags & 64) { return false; } @@ -24066,7 +24440,7 @@ var ts; type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384); @@ -24083,7 +24457,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 285); + var declaration = ts.getDeclarationOfKind(symbol, 289); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -24094,7 +24468,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 228); + declaration = ts.getDeclarationOfKind(symbol, 230); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -24102,7 +24476,7 @@ var ts; if (typeParameters) { links.typeParameters = typeParameters; links.instantiations = ts.createMap(); - links.instantiations[getTypeListId(typeParameters)] = type; + links.instantiations.set(getTypeListId(typeParameters), type); } } else { @@ -24119,14 +24493,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 190 && expr.operator === 37 && + expr.kind === 191 && expr.operator === 37 && expr.operand.kind === 8 || - expr.kind === 70 && !!symbol.exports[expr.text]; + expr.kind === 70 && !!symbol.exports.get(expr.text); } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 231) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -24151,10 +24525,10 @@ var ts; enumType.symbol = symbol; if (enumHasLiteralMembers(symbol)) { var memberTypeList = []; - var memberTypes = ts.createMap(); + var memberTypes = []; for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 231) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -24171,7 +24545,7 @@ var ts; if (memberTypeList.length > 1) { enumType.flags |= 65536; enumType.types = memberTypeList; - unionTypes[getTypeListId(memberTypeList)] = enumType; + unionTypes.set(getTypeListId(memberTypeList), enumType); } } } @@ -24192,9 +24566,6 @@ var ts; if (!links.declaredType) { var type = createType(16384); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 143).constraint) { - type.constraint = noConstraintType; - } links.declaredType = type; } return links.declaredType; @@ -24207,7 +24578,6 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 16777216) === 0); if (symbol.flags & (32 | 64)) { return getDeclaredTypeOfClassOrInterface(symbol); } @@ -24242,19 +24612,20 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 136: + case 133: case 104: - case 137: + case 138: case 94: case 129: - case 171: + case 172: return true; - case 162: + case 163: return isIndependentType(node.elementType); - case 157: + case 158: return isIndependentTypeReference(node); } return false; @@ -24263,7 +24634,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 150 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 151 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -24279,12 +24650,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 147: - case 146: - return isIndependentVariableLikeDeclaration(declaration); - case 149: case 148: + case 147: + return isIndependentVariableLikeDeclaration(declaration); case 150: + case 149: + case 151: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -24295,7 +24666,7 @@ var ts; var result = ts.createMap(); for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { var symbol = symbols_1[_i]; - result[symbol.name] = symbol; + result.set(symbol.name, symbol); } return result; } @@ -24303,15 +24674,15 @@ var ts; var result = ts.createMap(); 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); + result.set(symbol.name, mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; } function addInheritedMembers(symbols, baseSymbols) { for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) { var s = baseSymbols_1[_i]; - if (!symbols[s.name]) { - symbols[s.name] = s; + if (!symbols.has(s.name)) { + symbols.set(s.name, s); } } } @@ -24319,8 +24690,8 @@ var ts; 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.declaredCallSignatures = getSignaturesOfSymbol(symbol.members.get("__call")); + type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members.get("__new")); type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0); type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1); } @@ -24328,7 +24699,14 @@ var ts; } function getTypeWithThisArgument(type, thisArgument) { if (getObjectFlags(type) & 4) { - return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + var target = type.target; + var typeArguments = type.typeArguments; + if (ts.length(target.typeParameters) === ts.length(typeArguments)) { + return createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); + } + } + else if (type.flags & 131072) { + return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument); })); } return type; } @@ -24364,7 +24742,7 @@ var ts; 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)); + addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0); @@ -24407,13 +24785,14 @@ var ts; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); - var typeArgCount = typeArguments ? typeArguments.length : 0; + var typeArgCount = ts.length(typeArguments); var result = []; for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { var baseSig = baseSignatures_1[_i]; - var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; - if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); + var typeParamCount = ts.length(baseSig.typeParameters); + if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) { + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -24467,7 +24846,7 @@ var ts; s = cloneSignature(signature); if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) { var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return getTypeOfSymbol(sig.thisParameter) || anyType; }), true); - s.thisParameter = createTransientSymbol(signature.thisParameter, thisType); + s.thisParameter = createSymbolWithType(signature.thisParameter, thisType); } s.resolvedReturnType = undefined; s.unionSignatures = unionSignatures; @@ -24509,17 +24888,44 @@ var ts; function unionSpreadIndexInfos(info1, info2) { return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly); } + function includeMixinType(type, types, index) { + var mixedTypes = []; + for (var i = 0; i < types.length; i++) { + if (i === index) { + mixedTypes.push(type); + } + else if (isMixinConstructorType(types[i])) { + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1)[0])); + } + } + return getIntersectionType(mixedTypes); + } function resolveIntersectionTypeMembers(type) { var callSignatures = emptyArray; var constructSignatures = emptyArray; - var stringIndexInfo = undefined; - var numberIndexInfo = undefined; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + var stringIndexInfo; + var numberIndexInfo; + var types = type.types; + var mixinCount = ts.countWhere(types, isMixinConstructorType); + var _loop_3 = function (i) { + var t = type.types[i]; + if (mixinCount === 0 || mixinCount === types.length && i === 0 || !isMixinConstructorType(t)) { + var signatures = getSignaturesOfType(t, 1); + if (signatures.length && mixinCount > 0) { + signatures = ts.map(signatures, function (s) { + var clone = cloneSignature(s); + clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, i); + return clone; + }); + } + constructSignatures = ts.concatenate(constructSignatures, signatures); + } callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1)); stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0)); numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1)); + }; + for (var i = 0; i < types.length; i++) { + _loop_3(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } @@ -24535,8 +24941,8 @@ var ts; } else if (symbol.flags & 2048) { var members = symbol.members; - var callSignatures = getSignaturesOfSymbol(members["__call"]); - var constructSignatures = getSignaturesOfSymbol(members["__new"]); + var callSignatures = getSignaturesOfSymbol(members.get("__call")); + var constructSignatures = getSignaturesOfSymbol(members.get("__new")); var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0); var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1); setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -24549,14 +24955,14 @@ var ts; } if (symbol.flags & 32) { var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); + constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 32768) { + if (baseConstructorType.flags & (32768 | 131072 | 540672)) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); + addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } } var numberIndexInfo = symbol.flags & 384 ? enumNumberIndexInfo : undefined; @@ -24576,8 +24982,11 @@ var ts; var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); var templateReadonly = !!type.declaration.readonlyToken; var templateOptional = !!type.declaration.questionToken; - if (type.declaration.typeParameter.constraint.kind === 168) { - forEachType(getLiteralTypeFromPropertyNames(modifiersType), addMemberForKeyType); + if (type.declaration.typeParameter.constraint.kind === 169) { + for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { + var propertySymbol = _a[_i]; + addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol); + } if (getIndexInfoOfType(modifiersType, 0)) { addMemberForKeyType(stringType); } @@ -24588,18 +24997,21 @@ var ts; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, undefined); - function addMemberForKeyType(t) { - var iterationMapper = createUnaryTypeMapper(typeParameter, t); + function addMemberForKeyType(t, propertySymbol) { + var iterationMapper = createTypeMapper([typeParameter], [t]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; var propType = instantiateType(templateType, templateMapper); if (t.flags & 32) { var propName = t.text; var modifiersProp = getPropertyOfType(modifiersType, propName); - var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 536870912); - var prop = createSymbol(4 | 67108864 | (isOptional ? 536870912 : 0), propName); + var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 67108864); + var prop = createSymbol(4 | (isOptional ? 67108864 : 0), propName); + prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 4 : 0; prop.type = propType; - prop.isReadonly = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp); - members[propName] = prop; + if (propertySymbol) { + prop.mappedTypeOrigin = propertySymbol; + } + members.set(propName, prop); } else if (t.flags & 2) { stringIndexInfo = createIndexInfo(propType, templateReadonly); @@ -24623,21 +25035,18 @@ var ts; function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { var constraintDeclaration = type.declaration.typeParameter.constraint; - if (constraintDeclaration.kind === 168) { + if (constraintDeclaration.kind === 169) { type.modifiersType = instantiateType(getTypeFromTypeNode(constraintDeclaration.type), type.mapper || identityMapper); } else { var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint.flags & 16384 ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint.flags & 262144 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 16384 ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 262144 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; } - function getErasedTemplateTypeFromMappedType(type) { - return instantiateType(getTemplateTypeFromMappedType(type), createUnaryTypeMapper(getTypeParameterFromMappedType(type), anyType)); - } function isGenericMappedType(type) { if (getObjectFlags(type) & 32) { var constraintType = getConstraintTypeFromMappedType(type); @@ -24679,35 +25088,33 @@ var ts; function getPropertyOfObjectType(type, name) { if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && 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]; - getUnionOrIntersectionProperty(type, prop.name); - } - if (type.flags & 65536) { - break; - } - } - var props = type.resolvedProperties; - if (props) { - var result = []; - for (var key in props) { - var prop = props[key]; - if (!(prop.flags & 268435456 && prop.isPartial)) { - result.push(prop); + if (!type.resolvedProperties) { + var members = ts.createMap(); + 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]; + if (!members.has(prop.name)) { + var combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.name); + if (combinedProp) { + members.set(prop.name, combinedProp); + } + } + } + if (type.flags & 65536) { + break; } } - return result; + type.resolvedProperties = getNamedMembers(members); } - return emptyArray; + return type.resolvedProperties; } function getPropertiesOfType(type) { type = getApparentType(type); @@ -24715,36 +25122,110 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } - function getApparentTypeOfTypeVariable(type) { - if (!type.resolvedApparentType) { - var constraintType = getConstraintOfTypeVariable(type); - while (constraintType && constraintType.flags & 16384) { - constraintType = getConstraintOfTypeVariable(constraintType); - } - type.resolvedApparentType = getTypeWithThisArgument(constraintType || emptyObjectType, type); + function getConstraintOfType(type) { + return type.flags & 16384 ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + } + function getConstraintOfTypeParameter(typeParameter) { + return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; + } + function getBaseConstraintOfType(type) { + var constraint = getResolvedBaseConstraint(type); + return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + } + function hasNonCircularBaseConstraint(type) { + return getResolvedBaseConstraint(type) !== circularConstraintType; + } + function getResolvedBaseConstraint(type) { + var typeStack; + var circular; + if (!type.resolvedBaseConstraint) { + typeStack = []; + var constraint = getBaseConstraint(type); + type.resolvedBaseConstraint = circular ? circularConstraintType : getTypeWithThisArgument(constraint || noConstraintType, type); } - return type.resolvedApparentType; + return type.resolvedBaseConstraint; + function getBaseConstraint(t) { + if (ts.contains(typeStack, t)) { + circular = true; + return undefined; + } + typeStack.push(t); + var result = computeBaseConstraint(t); + typeStack.pop(); + return result; + } + function computeBaseConstraint(t) { + if (t.flags & 16384) { + var constraint = getConstraintFromTypeParameter(t); + return t.isThisType ? constraint : + constraint ? getBaseConstraint(constraint) : undefined; + } + if (t.flags & 196608) { + var types = t.types; + var baseTypes = []; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var type_1 = types_2[_i]; + var baseType = getBaseConstraint(type_1); + if (baseType) { + baseTypes.push(baseType); + } + } + return t.flags & 65536 && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 131072 && baseTypes.length ? getIntersectionType(baseTypes) : + undefined; + } + if (t.flags & 262144) { + return stringType; + } + if (t.flags & 524288) { + var baseObjectType = getBaseConstraint(t.objectType); + var baseIndexType = getBaseConstraint(t.indexType); + var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; + return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + } + return t; + } + } + function getApparentTypeOfIntersectionType(type) { + return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type)); + } + function getDefaultFromTypeParameter(typeParameter) { + if (!typeParameter.default) { + if (typeParameter.target) { + var targetDefault = getDefaultFromTypeParameter(typeParameter.target); + typeParameter.default = targetDefault ? instantiateType(targetDefault, typeParameter.mapper) : noConstraintType; + } + else { + var defaultDeclaration = typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameter(decl) && decl.default; }); + typeParameter.default = defaultDeclaration ? getTypeFromTypeNode(defaultDeclaration) : noConstraintType; + } + } + return typeParameter.default === noConstraintType ? undefined : typeParameter.default; } function getApparentType(type) { - var t = type.flags & 540672 ? getApparentTypeOfTypeVariable(type) : type; - return t.flags & 262178 ? globalStringType : - t.flags & 340 ? globalNumberType : - t.flags & 136 ? globalBooleanType : - t.flags & 512 ? getGlobalESSymbolType() : - t; + var t = type.flags & 540672 ? getBaseConstraintOfType(type) || emptyObjectType : type; + return t.flags & 131072 ? getApparentTypeOfIntersectionType(t) : + t.flags & 262178 ? globalStringType : + t.flags & 340 ? globalNumberType : + t.flags & 136 ? globalBooleanType : + t.flags & 512 ? getGlobalESSymbolType() : + t.flags & 16777216 ? emptyObjectType : + t; } function createUnionOrIntersectionProperty(containingType, name) { - var types = containingType.types; var props; - var commonFlags = (containingType.flags & 131072) ? 536870912 : 0; - var isReadonly = false; - var isPartial = false; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var current = types_2[_i]; + var types = containingType.types; + var isUnion = containingType.flags & 65536; + var excludeModifiers = isUnion ? 24 : 0; + var commonFlags = isUnion ? 0 : 67108864; + var checkFlags = 2; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var current = types_3[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16))) { + var modifiers = prop ? getDeclarationModifierFlagsFromSymbol(prop) : 0; + if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; if (!props) { props = [prop]; @@ -24752,25 +25233,26 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } - if (isReadonlySymbol(prop)) { - isReadonly = true; - } + checkFlags |= (isReadonlySymbol(prop) ? 4 : 0) | + (!(modifiers & 24) ? 32 : 0) | + (modifiers & 16 ? 64 : 0) | + (modifiers & 8 ? 128 : 0) | + (modifiers & 32 ? 256 : 0); } - else if (containingType.flags & 65536) { - isPartial = true; + else if (isUnion) { + checkFlags |= 8; } } } if (!props) { return undefined; } - if (props.length === 1 && !isPartial) { + if (props.length === 1 && !(checkFlags & 8)) { return props[0]; } var propTypes = []; var declarations = []; var commonType = undefined; - var hasNonUniformType = false; for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { var prop = props_1[_a]; if (prop.declarations) { @@ -24781,39 +25263,37 @@ var ts; commonType = type; } else if (type !== commonType) { - hasNonUniformType = true; + checkFlags |= 16; } propTypes.push(type); } - var result = createSymbol(4 | 67108864 | 268435456 | commonFlags, name); + var result = createSymbol(4 | commonFlags, name); + result.checkFlags = checkFlags; result.containingType = containingType; - result.hasNonUniformType = hasNonUniformType; - result.isPartial = isPartial; result.declarations = declarations; - result.isReadonly = isReadonly; - result.type = containingType.flags & 65536 ? getUnionType(propTypes) : getIntersectionType(propTypes); + result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } function getUnionOrIntersectionProperty(type, name) { - var properties = type.resolvedProperties || (type.resolvedProperties = ts.createMap()); - var property = properties[name]; + var properties = type.propertyCache || (type.propertyCache = ts.createMap()); + var property = properties.get(name); if (!property) { property = createUnionOrIntersectionProperty(type, name); if (property) { - properties[name] = property; + properties.set(name, property); } } return property; } function getPropertyOfUnionOrIntersectionType(type, name) { var property = getUnionOrIntersectionProperty(type, name); - return property && !(property.flags & 268435456 && property.isPartial) ? property : undefined; + return property && !(getCheckFlags(property) & 8) ? property : undefined; } function getPropertyOfType(type, name) { type = getApparentType(type); if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } @@ -24892,16 +25372,16 @@ var ts; } function symbolsToArray(symbols) { var result = []; - for (var id in symbols) { + symbols.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { - result.push(symbols[id]); + result.push(symbol); } - } + }); return result; } function isJSDocOptionalParameter(node) { if (node.flags & 65536) { - if (node.type && node.type.kind === 273) { + if (node.type && node.type.kind === 277) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -24912,7 +25392,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 273; + return paramTag.typeExpression.type.kind === 277; } } } @@ -24936,6 +25416,12 @@ var ts; ts.Debug.assert(parameterIndex >= 0); return parameterIndex >= signature.minArgumentCount; } + var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); + if (iife) { + return !node.type && + !node.dotDotDotToken && + ts.indexOf(node.parent.parameters, node) >= iife.arguments.length; + } return false; } function createTypePredicateFromTypePredicateNode(node) { @@ -24955,16 +25441,49 @@ var ts; }; } } + function getMinTypeArgumentCount(typeParameters) { + var minTypeArgumentCount = 0; + if (typeParameters) { + for (var i = 0; i < typeParameters.length; i++) { + if (!getDefaultFromTypeParameter(typeParameters[i])) { + minTypeArgumentCount = i + 1; + } + } + } + return minTypeArgumentCount; + } + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount) { + var numTypeParameters = ts.length(typeParameters); + if (numTypeParameters) { + var numTypeArguments = ts.length(typeArguments); + if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) { + if (!typeArguments) { + typeArguments = []; + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + typeArguments[i] = emptyObjectType; + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + var mapper = createTypeMapper(typeParameters, typeArguments); + var defaultType = getDefaultFromTypeParameter(typeParameters[i]); + typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType; + } + } + } + return typeArguments; + } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; var hasLiteralTypes = false; - var minArgumentCount = -1; + var minArgumentCount = 0; var thisParameter = undefined; var hasThisParameter = void 0; + var iife = ts.getImmediatelyInvokedFunctionExpression(declaration); var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); - for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { + var isUntypedSignatureInJSFile = !iife && !isJSConstructSignature && ts.isInJavaScriptFile(declaration) && !ts.hasJSDocParameterTags(declaration); + for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) { @@ -24978,41 +25497,34 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 171) { + if (param.type && param.type.kind === 172) { hasLiteralTypes = true; } - if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { - if (minArgumentCount < 0) { - minArgumentCount = i - (hasThisParameter ? 1 : 0); - } - } - else { - minArgumentCount = -1; + var isOptionalParameter_1 = param.initializer || param.questionToken || param.dotDotDotToken || + iife && parameters.length > iife.arguments.length && !param.type || + isJSDocOptionalParameter(param) || + isUntypedSignatureInJSFile; + if (!isOptionalParameter_1) { + minArgumentCount = parameters.length; } } - if ((declaration.kind === 151 || declaration.kind === 152) && + if ((declaration.kind === 152 || declaration.kind === 153) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 151 ? 152 : 151; + var otherKind = declaration.kind === 152 ? 153 : 152; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); - } - if (isJSConstructSignature) { - minArgumentCount--; - } - var classType = declaration.kind === 150 ? + var classType = declaration.kind === 151 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 156 ? + var typePredicate = declaration.type && declaration.type.kind === 157 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -25035,8 +25547,8 @@ var ts; return type; } } - if (declaration.kind === 151 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 152); + if (declaration.kind === 152 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 153); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -25047,23 +25559,23 @@ var ts; if (!symbol) return emptyArray; var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { + for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 158: case 159: - case 225: - case 149: - case 148: + case 160: + case 227: case 150: - case 153: + case 149: + case 151: case 154: case 155: - case 151: + case 156: case 152: - case 184: + case 153: case 185: - case 274: + case 186: + case 278: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -25131,9 +25643,14 @@ var ts; return anyType; } function getSignatureInstantiation(signature, typeArguments) { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); - return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments)); + var instantiation = instantiations.get(id); + if (!instantiation) { + instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments)); + } + return instantiation; } function createSignatureInstantiation(signature, typeArguments) { return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); @@ -25148,7 +25665,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 150 || signature.declaration.kind === 154; + var isConstructor = signature.declaration.kind === 151 || signature.declaration.kind === 155; var type = createObjectType(16); type.members = emptySymbols; type.properties = emptyArray; @@ -25159,10 +25676,10 @@ var ts; return signature.isolatedSignatureType; } function getIndexSymbol(symbol) { - return symbol.members["__index"]; + return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 132 : 134; + var syntaxKind = kind === 1 ? 132 : 135; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -25189,21 +25706,9 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 143).constraint; + return ts.getDeclarationOfKind(type.symbol, 144).constraint; } - function hasConstraintReferenceTo(type, target) { - var checked; - while (type && type.flags & 16384 && !(type.isThisType) && !ts.contains(checked, type)) { - if (type === target) { - return true; - } - (checked || (checked = [])).push(type); - var constraintDeclaration = getConstraintDeclaration(type); - type = constraintDeclaration && getTypeFromTypeNode(constraintDeclaration); - } - return false; - } - function getConstraintOfTypeParameter(typeParameter) { + function getConstraintFromTypeParameter(typeParameter) { if (!typeParameter.constraint) { if (typeParameter.target) { var targetConstraint = getConstraintOfTypeParameter(typeParameter.target); @@ -25211,23 +25716,13 @@ var ts; } else { var constraintDeclaration = getConstraintDeclaration(typeParameter); - var constraint = getTypeFromTypeNode(constraintDeclaration); - if (hasConstraintReferenceTo(constraint, typeParameter)) { - error(constraintDeclaration, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); - constraint = unknownType; - } - typeParameter.constraint = constraint; + typeParameter.constraint = constraintDeclaration ? getTypeFromTypeNode(constraintDeclaration) : noConstraintType; } } return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } - function getConstraintOfTypeVariable(type) { - return type.flags & 16384 ? getConstraintOfTypeParameter(type) : - type.flags & 524288 ? type.constraint : - undefined; - } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 143).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 144).parent); } function getTypeListId(types) { var result = ""; @@ -25254,8 +25749,8 @@ var ts; } function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var type = types_3[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -25264,9 +25759,10 @@ var ts; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); - var type = target.instantiations[id]; + var type = target.instantiations.get(id); if (!type) { - type = target.instantiations[id] = createObjectType(4, target.symbol); + type = createObjectType(4, target.symbol); + target.instantiations.set(id, type); type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0; type.target = target; type.typeArguments = typeArguments; @@ -25282,17 +25778,22 @@ var ts; return type; } function getTypeReferenceArity(type) { - return type.target.typeParameters ? type.target.typeParameters.length : 0; + return ts.length(type.target.typeParameters); } function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(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); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, undefined, 1), minTypeArgumentCount, typeParameters.length); return unknownType; } - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount)); + return createTypeReference(type, typeArguments); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); @@ -25305,14 +25806,22 @@ var ts; var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + var instantiation = links.instantiations.get(id); + if (!instantiation) { + links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + } + return instantiation; } function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).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); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return unknownType; } var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); @@ -25333,11 +25842,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 157: + case 158: return node.typeName; - case 272: + case 276: return node.name; - case 199: + case 200: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -25361,7 +25870,7 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 272) { + if (symbol.flags & 107455 && node.kind === 276) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); @@ -25371,13 +25880,13 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 272) { + if (node.kind === 276) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { - var typeNameOrExpression = node.kind === 157 + var typeNameOrExpression = node.kind === 158 ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -25403,12 +25912,12 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var declaration = declarations_4[_i]; switch (declaration.kind) { - case 226: - case 227: + case 228: case 229: + case 231: return declaration; } } @@ -25421,7 +25930,7 @@ var ts; 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) { + if (ts.length(type.typeParameters) !== arity) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); return arity ? emptyGenericType : emptyObjectType; } @@ -25476,7 +25985,7 @@ var ts; for (var i = 0; i < arity; i++) { var typeParameter = createType(16384); typeParameters.push(typeParameter); - var property = createSymbol(4 | 67108864, "" + i); + var property = createSymbol(4, "" + i); property.type = typeParameter; properties.push(property); } @@ -25485,7 +25994,7 @@ var ts; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384); @@ -25567,14 +26076,14 @@ var ts; } } function addTypesToUnion(typeSet, types) { - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var t = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var t = types_6[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -25582,8 +26091,9 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; + if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } } @@ -25661,10 +26171,11 @@ var ts; return types[0]; } var id = getTypeListId(types); - var type = unionTypes[id]; + var type = unionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(types, 6144); - type = unionTypes[id] = createType(65536 | propagatedFlags); + type = createType(65536 | propagatedFlags); + unionTypes.set(id, type); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -25689,12 +26200,15 @@ var ts; if (type.flags & 65536 && typeSet.unionIndex === undefined) { typeSet.unionIndex = typeSet.length; } - typeSet.push(type); + if (!(type.flags & 32768 && type.objectFlags & 16 && + type.symbol && type.symbol.flags & (16 | 8192) && containsIdenticalType(typeSet, type))) { + typeSet.push(type); + } } } function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; addTypeToIntersection(typeSet, type); } } @@ -25716,10 +26230,11 @@ var ts; return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex, t)); }), false, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); - var type = intersectionTypes[id]; + var type = intersectionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, 6144); - type = intersectionTypes[id] = createType(131072 | propagatedFlags); + type = createType(131072 | propagatedFlags); + intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -25769,21 +26284,10 @@ var ts; var type = createType(524288); type.objectType = objectType; type.indexType = indexType; - if (type.objectType.flags & 229376) { - type.constraint = getIndexTypeOfType(type.objectType, 0); - } - else if (type.objectType.flags & 540672) { - var apparentType = getApparentTypeOfTypeVariable(type.objectType); - if (apparentType !== emptyObjectType) { - type.constraint = isTypeOfKind(type.indexType, 262178) ? - getIndexedAccessType(apparentType, type.indexType) : - getIndexTypeOfType(apparentType, 0); - } - } return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 178 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 ? accessNode : undefined; var propName = indexType.flags & (32 | 64 | 256) ? indexType.text : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? @@ -25812,7 +26316,7 @@ var ts; getIndexInfoOfType(objectType, 0) || undefined; if (indexInfo) { - if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); return unknownType; } @@ -25831,7 +26335,7 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 178 ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 179 ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (32 | 64)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); } @@ -25845,33 +26349,31 @@ var ts; return unknownType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 178 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 ? accessNode : undefined; if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); return unknownType; } - var mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); + var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } function getIndexedAccessType(objectType, indexType, accessNode) { if (maybeTypeOfKind(indexType, 540672 | 262144) || - maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 178) || + maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 179) || isGenericMappedType(objectType)) { if (objectType.flags & 1) { return objectType; } - if (accessNode) { - if (!isTypeAssignableTo(indexType, getIndexType(objectType))) { - error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); - return unknownType; - } - } if (isGenericMappedType(objectType)) { return getIndexedAccessForMappedType(objectType, indexType, accessNode); } var id = objectType.id + "," + indexType.id; - return indexedAccessTypes[id] || (indexedAccessTypes[id] = createIndexedAccessType(objectType, indexType)); + var type = indexedAccessTypes.get(id); + if (!type) { + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType)); + } + return type; } var apparentObjectType = getApparentType(objectType); if (indexType.flags & 65536 && !(indexType.flags & 8190)) { @@ -25911,7 +26413,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); - if (ts.isEmpty(node.symbol.members) && !aliasSymbol) { + if (node.symbol.members.size === 0 && !aliasSymbol) { links.resolvedType = emptyTypeLiteralType; } else { @@ -25924,13 +26426,13 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 228 ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 230 ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } - function getSpreadType(left, right, isFromObjectLiteral) { + function getSpreadType(left, right) { if (left.flags & 1 || right.flags & 1) { return anyType; } @@ -25943,10 +26445,13 @@ var ts; return left; } if (left.flags & 65536) { - return mapType(left, function (t) { return getSpreadType(t, right, isFromObjectLiteral); }); + return mapType(left, function (t) { return getSpreadType(t, right); }); } if (right.flags & 65536) { - return mapType(right, function (t) { return getSpreadType(left, t, isFromObjectLiteral); }); + return mapType(right, function (t) { return getSpreadType(left, t); }); + } + if (right.flags & 16777216) { + return emptyObjectType; } var members = ts.createMap(); var skippedPrivateMembers = ts.createMap(); @@ -25962,42 +26467,45 @@ var ts; } for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; - var isOwnProperty = !(rightProp.flags & 8192) || isFromObjectLiteral; var isSetterWithoutGetter = rightProp.flags & 65536 && !(rightProp.flags & 32768); if (getDeclarationModifierFlagsFromSymbol(rightProp) & (8 | 16)) { - skippedPrivateMembers[rightProp.name] = true; + skippedPrivateMembers.set(rightProp.name, true); } - else if (isOwnProperty && !isSetterWithoutGetter) { - members[rightProp.name] = rightProp; + else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { + members.set(rightProp.name, rightProp); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { var leftProp = _c[_b]; if (leftProp.flags & 65536 && !(leftProp.flags & 32768) - || leftProp.name in skippedPrivateMembers) { + || skippedPrivateMembers.has(leftProp.name) + || isClassMethod(leftProp)) { continue; } - if (leftProp.name in members) { - var rightProp = members[leftProp.name]; + if (members.has(leftProp.name)) { + var rightProp = members.get(leftProp.name); var rightType = getTypeOfSymbol(rightProp); - if (maybeTypeOfKind(rightType, 2048) || rightProp.flags & 536870912) { + if (maybeTypeOfKind(rightType, 2048) || rightProp.flags & 67108864) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 | 67108864 | (leftProp.flags & 536870912); + var flags = 4 | (leftProp.flags & 67108864); var result = createSymbol(flags, leftProp.name); + result.checkFlags = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp) ? 4 : 0; result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072)]); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; - result.isReadonly = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp); - members[leftProp.name] = result; + members.set(leftProp.name, result); } } else { - members[leftProp.name] = leftProp; + members.set(leftProp.name, leftProp); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } + function isClassMethod(prop) { + return prop.flags & 8192 && ts.find(prop.declarations, function (decl) { return ts.isClassLike(decl.parent); }); + } function createLiteralType(flags, text) { var type = createType(flags); type.text = text; @@ -26019,7 +26527,11 @@ var ts; } function getLiteralTypeForText(flags, text) { var map = flags & 32 ? stringLiteralTypes : numericLiteralTypes; - return map[text] || (map[text] = createLiteralType(flags, text)); + var type = map.get(text); + if (!type) { + map.set(text, type = createLiteralType(flags, text)); + } + return type; } function getTypeFromLiteralTypeNode(node) { var links = getNodeLinks(node); @@ -26047,9 +26559,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 227)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 229)) { if (!(ts.getModifierFlags(container) & 32) && - (container.kind !== 150 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 151 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -26066,85 +26578,87 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118: - case 263: - case 264: + case 267: + case 268: return anyType; - case 134: + case 135: return stringType; case 132: return numberType; case 121: return booleanType; - case 135: + case 136: return esSymbolType; case 104: return voidType; - case 137: + case 138: return undefinedType; case 94: return nullType; case 129: return neverType; - case 289: + case 133: + return nonPrimitiveType; + case 293: return nullType; - case 290: + case 294: return undefinedType; - case 291: + case 295: return neverType; - case 167: + case 168: case 98: return getTypeFromThisTypeNode(node); - case 171: + case 172: return getTypeFromLiteralTypeNode(node); - case 288: + case 292: return getTypeFromLiteralTypeNode(node.literal); - case 157: - case 272: - return getTypeFromTypeReference(node); - case 156: - return booleanType; - case 199: - return getTypeFromTypeReference(node); - case 160: - return getTypeFromTypeQueryNode(node); - case 162: - case 265: - return getTypeFromArrayTypeNode(node); - case 163: - return getTypeFromTupleTypeNode(node); - case 164: - case 266: - return getTypeFromUnionTypeNode(node); - case 165: - return getTypeFromIntersectionTypeNode(node); - case 166: - case 268: - case 269: - case 276: - case 277: - case 273: - return getTypeFromTypeNode(node.type); - case 270: - return getTypeFromTypeNode(node.literal); case 158: - case 159: + case 276: + return getTypeFromTypeReference(node); + case 157: + return booleanType; + case 200: + return getTypeFromTypeReference(node); case 161: - case 287: + return getTypeFromTypeQueryNode(node); + case 163: + case 269: + return getTypeFromArrayTypeNode(node); + case 164: + return getTypeFromTupleTypeNode(node); + case 165: + case 270: + return getTypeFromUnionTypeNode(node); + case 166: + return getTypeFromIntersectionTypeNode(node); + case 167: + case 272: + case 273: + case 280: + case 281: + case 277: + return getTypeFromTypeNode(node.type); case 274: + return getTypeFromTypeNode(node.literal); + case 159: + case 160: + case 162: + case 291: + case 278: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 168: - return getTypeFromTypeOperatorNode(node); case 169: - return getTypeFromIndexedAccessTypeNode(node); + return getTypeFromTypeOperatorNode(node); case 170: + return getTypeFromIndexedAccessTypeNode(node); + case 171: return getTypeFromMappedTypeNode(node); case 70: - case 141: + case 142: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 267: + case 271: return getTypeFromJSDocTupleType(node); - case 275: + case 279: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -26171,13 +26685,13 @@ var ts; var instantiations = mapper.instantiations || (mapper.instantiations = []); return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); } - function createUnaryTypeMapper(source, target) { + function makeUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } - function createBinaryTypeMapper(source1, target1, source2, target2) { + function makeBinaryTypeMapper(source1, target1, source2, target2) { return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; } - function createArrayTypeMapper(sources, targets) { + function makeArrayTypeMapper(sources, targets) { return function (t) { for (var i = 0; i < sources.length; i++) { if (t === sources[i]) { @@ -26188,16 +26702,20 @@ var ts; }; } function createTypeMapper(sources, targets) { - var count = sources.length; - var mapper = count == 1 ? createUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : - count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : - createArrayTypeMapper(sources, targets); + var mapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : + makeArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; return mapper; } function createTypeEraser(sources) { return createTypeMapper(sources, undefined); } + function createBackreferenceMapper(typeParameters, index) { + var mapper = function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; + mapper.mappedTypes = typeParameters; + return mapper; + } function getInferenceMapper(context) { if (!context.mapper) { var mapper = function (t) { @@ -26221,7 +26739,12 @@ var ts; } function combineTypeMappers(mapper1, mapper2) { var mapper = function (t) { return instantiateType(mapper1(t), mapper2); }; - mapper.mappedTypes = mapper1.mappedTypes; + mapper.mappedTypes = ts.concatenate(mapper1.mappedTypes, mapper2.mappedTypes); + return mapper; + } + function createReplacementMapper(source, target, baseMapper) { + var mapper = function (t) { return t === source ? target : baseMapper(t); }; + mapper.mappedTypes = baseMapper.mappedTypes; return mapper; } function cloneTypeParameter(typeParameter) { @@ -26266,12 +26789,13 @@ var ts; return result; } function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 16777216) { + if (getCheckFlags(symbol) & 1) { var links = getSymbolLinks(symbol); symbol = links.target; mapper = combineTypeMappers(links.mapper, mapper); } - var result = createSymbol(16777216 | 67108864 | symbol.flags, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); + result.checkFlags = 1; result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -26293,17 +26817,16 @@ var ts; var constraintType = getConstraintTypeFromMappedType(type); if (constraintType.flags & 262144) { var typeVariable_1 = constraintType.type; - var mappedTypeVariable = instantiateType(typeVariable_1, mapper); - if (typeVariable_1 !== mappedTypeVariable) { - return mapType(mappedTypeVariable, function (t) { - if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); - } - return t; - }); + if (typeVariable_1.flags & 16384) { + var mappedTypeVariable = instantiateType(typeVariable_1, mapper); + if (typeVariable_1 !== mappedTypeVariable) { + return mapType(mappedTypeVariable, function (t) { + if (isMappableType(t)) { + return instantiateMappedObjectType(type, createReplacementMapper(typeVariable_1, t, mapper)); + } + return t; + }); + } } } return instantiateMappedObjectType(type, mapper); @@ -26324,26 +26847,26 @@ var ts; return false; } var mappedTypes = mapper.mappedTypes; - var node = symbol.declarations[0].parent; + var node = symbol.declarations[0]; while (node) { switch (node.kind) { - case 158: case 159: - case 225: - case 149: - case 148: + case 160: + case 227: case 150: - case 153: + case 149: + case 151: case 154: case 155: - case 151: + case 156: case 152: - case 184: + case 153: case 185: - case 226: - case 197: - case 227: + case 186: case 228: + case 198: + case 229: + case 230: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -26353,15 +26876,29 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 227) { + if (ts.isClassLike(node) || node.kind === 229) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 230: - case 261: + case 171: + if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { + return true; + } + break; + case 278: + var func = node; + for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { + var p = _c[_b]; + if (ts.contains(mappedTypes, getTypeOfNode(p))) { + return true; + } + } + break; + case 232: + case 264: return false; } node = node.parent; @@ -26371,7 +26908,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 261 || parentKind === 231; + return parentKind === 264 || parentKind === 233; } return false; } @@ -26423,28 +26960,34 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 184: case 185: + case 186: return isContextSensitiveFunctionLikeDeclaration(node); - case 176: + case 177: return ts.forEach(node.properties, isContextSensitive); - case 175: + case 176: return ts.forEach(node.elements, isContextSensitive); - case 193: + case 194: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 192: + case 193: return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 257: + case 260: return isContextSensitive(node.initializer); + case 150: case 149: - case 148: return isContextSensitiveFunctionLikeDeclaration(node); - case 183: + case 184: return isContextSensitive(node.expression); + case 253: + return ts.forEach(node.properties, isContextSensitive); + case 252: + return node.initializer && isContextSensitive(node.initializer); + case 255: + return node.expression && isContextSensitive(node.expression); } return false; } @@ -26455,7 +26998,7 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !p.type; })) { return true; } - if (node.kind === 185) { + if (node.kind === 186) { return false; } var parameter = ts.firstOrUndefined(node.parameters); @@ -26473,9 +27016,12 @@ var ts; result.properties = resolved.properties; result.callSignatures = emptyArray; result.constructSignatures = emptyArray; - type = result; + return result; } } + else if (type.flags & 131072) { + return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); + } return type; } function isTypeIdenticalTo(source, target) { @@ -26494,7 +27040,7 @@ var ts; return isTypeRelatedTo(source, target, assignableRelation); } function isTypeInstanceOf(source, target) { - return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + return getTargetType(source) === getTargetType(target) || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); } function isTypeComparableTo(source, target) { return isTypeRelatedTo(source, target, comparableRelation); @@ -26642,13 +27188,15 @@ var ts; return true; } var id = source.id + "," + target.id; - if (enumRelation[id] !== undefined) { - return enumRelation[id]; + var relation = enumRelation.get(id); + if (relation !== undefined) { + return relation; } if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & 256) || !(target.symbol.flags & 256) || (source.flags & 65536) !== (target.flags & 65536)) { - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } var targetEnumType = getTypeOfSymbol(target.symbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(source.symbol)); _i < _a.length; _i++) { @@ -26659,11 +27207,13 @@ var ts; if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, property.name, typeToString(target, undefined, 128)); } - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } } } - return enumRelation[id] = true; + enumRelation.set(id, true); + return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { if (target.flags & 8192) @@ -26684,6 +27234,8 @@ var ts; return true; if (source.flags & 4096 && (!strictNullChecks || target.flags & 4096)) return true; + if (source.flags & 32768 && target.flags & 16777216) + return true; if (relation === assignableRelation || relation === comparableRelation) { if (source.flags & 1) return true; @@ -26715,12 +27267,12 @@ var ts; } if (source.flags & 32768 && target.flags & 32768) { var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { return related === 1; } } - if (source.flags & 507904 || target.flags & 507904) { + if (source.flags & 1032192 || target.flags & 1032192) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -26859,14 +27411,6 @@ var ts; } } } - else { - var constraint = getConstraintOfTypeParameter(target); - if (constraint && constraint.flags & 262144) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - return result; - } - } - } } else if (target.flags & 262144) { if (source.flags & 262144) { @@ -26874,12 +27418,10 @@ var ts; return result; } } - if (target.type.flags & 540672) { - var constraint = getConstraintOfTypeVariable(target.type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } + var constraint = getConstraintOfType(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; } } } @@ -26889,8 +27431,9 @@ var ts; return result; } } - if (target.constraint) { - if (result = isRelatedTo(source, target.constraint, reportErrors)) { + var constraint = getBaseConstraintOfType(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -26907,20 +27450,23 @@ var ts; } else { var constraint = getConstraintOfTypeParameter(source); - if (!constraint || constraint.flags & 1) { - constraint = emptyObjectType; - } - constraint = getTypeWithThisArgument(constraint, source); - var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; + if (constraint || !(target.flags & 16777216)) { + if (!constraint || constraint.flags & 1) { + constraint = emptyObjectType; + } + constraint = getTypeWithThisArgument(constraint, source); + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } } else if (source.flags & 524288) { - if (source.constraint) { - if (result = isRelatedTo(source.constraint, target, reportErrors)) { + var constraint = getBaseConstraintOfType(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -26972,42 +27518,55 @@ var ts; } return 0; } - function isKnownProperty(type, name) { + function isKnownProperty(type, name, isComparingJsxAttributes) { if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) || - resolved.stringIndexInfo || - (resolved.numberIndexInfo && isNumericLiteralName(name)) || - getPropertyOfType(type, name)) { + if ((relation === assignableRelation || relation === comparableRelation) && + (type === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(resolved)))) { + return true; + } + else if (resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name))) { + return true; + } + else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) { return true; } } else if (type.flags & 196608) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (isKnownProperty(t, name)) { + if (isKnownProperty(t, name, isComparingJsxAttributes)) { return true; } } } return false; } - function isEmptyObjectType(t) { + function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && t.constructSignatures.length === 0 && !t.stringIndexInfo && !t.numberIndexInfo; } + function isEmptyObjectType(type) { + return type.flags & 32768 && isEmptyResolvedType(resolveStructuredTypeMembers(type)); + } function hasExcessProperties(source, target, reportErrors) { if (maybeTypeOfKind(target, 32768) && !(getObjectFlags(target) & 512)) { + var isComparingJsxAttributes = !!(source.flags & 33554432); for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; - if (!isKnownProperty(target, prop.name)) { + if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) { if (reportErrors) { ts.Debug.assert(!!errorNode); - 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)); + if (ts.isJsxAttributes(errorNode)) { + reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); + } + else { + 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; } @@ -27033,20 +27592,42 @@ var ts; if (target.flags & 65536 && containsType(targetTypes, source)) { return -1; } - var len = targetTypes.length; - for (var i = 0; i < len; i++) { - var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); + for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { + var type = targetTypes_1[_i]; + var related = isRelatedTo(source, type, false); if (related) { return related; } } + if (reportErrors) { + var discriminantType = findMatchingDiscriminantType(source, target); + isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], true); + } return 0; } + function findMatchingDiscriminantType(source, target) { + var sourceProperties = getPropertiesOfObjectType(source); + if (sourceProperties) { + for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { + var sourceProperty = sourceProperties_1[_i]; + if (isDiscriminantProperty(target, sourceProperty.name)) { + var sourceType = getTypeOfSymbol(sourceProperty); + for (var _a = 0, _b = target.types; _a < _b.length; _a++) { + var type = _b[_a]; + var targetType = getTypeOfPropertyOfType(type, sourceProperty.name); + if (targetType && isRelatedTo(sourceType, targetType)) { + return type; + } + } + } + } + } + } function typeRelatedToEachType(source, target, reportErrors) { var result = -1; var targetTypes = target.types; - for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { - var targetType = targetTypes_1[_i]; + for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { + var targetType = targetTypes_2[_i]; var related = isRelatedTo(source, targetType, reportErrors); if (!related) { return 0; @@ -27104,10 +27685,10 @@ var ts; return 0; } var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2) { - relation[id] = 3; + relation.set(id, 3); } else { return related === 1 ? -1 : 0; @@ -27115,7 +27696,7 @@ var ts; } if (depth > 0) { for (var i = 0; i < depth; i++) { - if (maybeStack[i][id]) { + if (maybeStack[i].get(id)) { return 1; } } @@ -27133,7 +27714,7 @@ var ts; sourceStack[depth] = source; targetStack[depth] = target; maybeStack[depth] = ts.createMap(); - maybeStack[depth][id] = 1; + maybeStack[depth].set(id, 1); depth++; var saveExpandingFlags = expandingFlags; if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) @@ -27167,37 +27748,40 @@ var ts; if (result) { var maybeCache = maybeStack[depth]; var destinationCache = (result === -1 || depth === 0) ? relation : maybeStack[depth - 1]; - ts.copyProperties(maybeCache, destinationCache); + ts.copyEntries(maybeCache, destinationCache); } else { - relation[id] = reportErrors ? 3 : 2; + relation.set(id, reportErrors ? 3 : 2); } return result; } function mappedTypeRelatedTo(source, target, reportErrors) { if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { - var result_2; - if (relation === identityRelation) { - var readonlyMatches = !source.declaration.readonlyToken === !target.declaration.readonlyToken; - var optionalMatches = !source.declaration.questionToken === !target.declaration.questionToken; - if (readonlyMatches && optionalMatches) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getErasedTemplateTypeFromMappedType(source), getErasedTemplateTypeFromMappedType(target), reportErrors); - } - } - } - else { - if (relation === comparableRelation || !source.declaration.questionToken || target.declaration.questionToken) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors); - } + var sourceReadonly = !!source.declaration.readonlyToken; + var sourceOptional = !!source.declaration.questionToken; + var targetReadonly = !!target.declaration.readonlyToken; + var targetOptional = !!target.declaration.questionToken; + var modifiersRelated = relation === identityRelation ? + sourceReadonly === targetReadonly && sourceOptional === targetOptional : + relation === comparableRelation || !sourceOptional || targetOptional; + if (modifiersRelated) { + var result_2; + if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { + var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); + return result_2 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } + else if (target.declaration.questionToken && isEmptyObjectType(source)) { + return -1; + } } - else if (relation !== identityRelation && isEmptyObjectType(resolveStructuredTypeMembers(target))) { - return -1; + else if (relation !== identityRelation) { + var resolved = resolveStructuredTypeMembers(target); + if (isEmptyResolvedType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1) { + return -1; + } } return 0; } @@ -27213,17 +27797,23 @@ var ts; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { - if (!(targetProp.flags & 536870912) || requireOptionalProperties) { + if (!(targetProp.flags & 67108864) || requireOptionalProperties) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); } return 0; } } - else if (!(targetProp.flags & 134217728)) { + else if (!(targetProp.flags & 16777216)) { var sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 || targetPropFlags & 8) { + if (getCheckFlags(sourceProp) & 128) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); + } + return 0; + } if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { if (sourcePropFlags & 8 && targetPropFlags & 8) { @@ -27237,12 +27827,9 @@ var ts; } } else if (targetPropFlags & 16) { - var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(getParentOfSymbol(sourceProp)) : undefined; - var targetClass = getDeclaredTypeOfSymbol(getParentOfSymbol(targetProp)); - if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { + if (!isValidOverrideOf(sourceProp, targetProp)) { 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)); + reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } return 0; } @@ -27261,7 +27848,7 @@ var ts; return 0; } result &= related; - if (relation !== comparableRelation && sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { + if (relation !== comparableRelation && sourceProp.flags & 67108864 && !(targetProp.flags & 67108864)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -27282,8 +27869,8 @@ var ts; return 0; } var result = -1; - for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { - var sourceProp = sourceProperties_1[_i]; + for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) { + var sourceProp = sourceProperties_2[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return 0; @@ -27348,7 +27935,7 @@ var ts; return 0; } var result = -1; - for (var i = 0, len = sourceSignatures.length; i < len; i++) { + for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], false, false, false, isRelatedTo); if (!related) { return 0; @@ -27444,6 +28031,37 @@ var ts; return false; } } + function forEachProperty(prop, callback) { + if (getCheckFlags(prop) & 2) { + for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var p = getPropertyOfType(t, prop.name); + var result = p && forEachProperty(p, callback); + if (result) { + return result; + } + } + return undefined; + } + return callback(prop); + } + function getDeclaringClass(prop) { + return prop.parent && prop.parent.flags & 32 ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + } + function isPropertyInClassDerivedFrom(prop, baseClass) { + return forEachProperty(prop, function (sp) { + var sourceClass = getDeclaringClass(sp); + return sourceClass ? hasBaseType(sourceClass, baseClass) : false; + }); + } + function isValidOverrideOf(sourceProp, targetProp) { + return !forEachProperty(targetProp, function (tp) { return getDeclarationModifierFlagsFromSymbol(tp) & 16 ? + !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); + } + function isClassDerivedFromDeclaringClasses(checkClass, prop) { + return forEachProperty(prop, function (p) { return getDeclarationModifierFlagsFromSymbol(p) & 16 ? + !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; + } function isAbstractConstructorType(type) { if (getObjectFlags(type) & 16) { var symbol = type.symbol; @@ -27489,7 +28107,7 @@ var ts; } } else { - if ((sourceProp.flags & 536870912) !== (targetProp.flags & 536870912)) { + if ((sourceProp.flags & 67108864) !== (targetProp.flags & 67108864)) { return 0; } } @@ -27519,7 +28137,7 @@ var ts; if (!(isMatchingSignature(source, target, partialMatch))) { return 0; } - if ((source.typeParameters ? source.typeParameters.length : 0) !== (target.typeParameters ? target.typeParameters.length : 0)) { + if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { return 0; } source = getErasedSignature(source); @@ -27557,8 +28175,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var t = types_7[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -27566,8 +28184,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -27658,8 +28276,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getFalsyFlags(t); } return result; @@ -27688,7 +28306,7 @@ var ts; types.push(undefinedType); if (flags & 4096) types.push(nullType); - return getUnionType(types, true); + return getUnionType(types); } function removeDefinitelyFalsyTypes(type) { return getFalsyFlags(type) & 7392 ? @@ -27703,8 +28321,8 @@ var ts; getSignaturesOfType(type, 0).length === 0 && getSignaturesOfType(type, 1).length === 0; } - function createTransientSymbol(source, type) { - var symbol = createSymbol(source.flags | 67108864, source.name); + function createSymbolWithType(source, type) { + var symbol = createSymbol(source.flags, source.name); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -27720,7 +28338,7 @@ var ts; var property = _a[_i]; var original = getTypeOfSymbol(property); var updated = f(original); - members[property.name] = updated === original ? property : createTransientSymbol(property, updated); + members.set(property.name, updated === original ? property : createSymbolWithType(property, updated)); } ; return members; @@ -27806,25 +28424,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 148: case 147: - case 146: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 144: + case 145: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 174: + case 175: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 225: + case 227: + case 150: case 149: - case 148: - case 151: case 152: - case 184: + case 153: case 185: + case 186: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -27909,7 +28527,7 @@ var ts; var typeInferencesArray = [typeInferences]; var templateType = getTemplateTypeFromMappedType(target); var readonlyMask = target.declaration.readonlyToken ? false : true; - var optionalMask = target.declaration.questionToken ? 0 : 536870912; + var optionalMask = target.declaration.questionToken ? 0 : 67108864; var members = createSymbolTable(properties); for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var prop = properties_4[_i]; @@ -27917,11 +28535,11 @@ var ts; if (!inferredPropType) { return undefined; } - var inferredProp = createSymbol(4 | 67108864 | prop.flags & optionalMask, prop.name); + var inferredProp = createSymbol(4 | prop.flags & optionalMask, prop.name); + inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 4 : 0; inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; - inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop); - members[prop.name] = inferredProp; + members.set(prop.name, inferredProp); } if (indexInfo) { var inferredIndexType = inferTargetType(indexInfo.type); @@ -28031,8 +28649,8 @@ var ts; var targetTypes = target.types; var typeVariableCount = 0; var typeVariable = void 0; - for (var _d = 0, targetTypes_2 = targetTypes; _d < targetTypes_2.length; _d++) { - var t = targetTypes_2[_d]; + for (var _d = 0, targetTypes_3 = targetTypes; _d < targetTypes_3.length; _d++) { + var t = targetTypes_3[_d]; if (t.flags & 540672 && ts.contains(typeVariables, t)) { typeVariable = t; typeVariableCount++; @@ -28064,10 +28682,10 @@ var ts; return; } var key = source.id + "," + target.id; - if (visited[key]) { + if (visited.get(key)) { return; } - visited[key] = true; + visited.set(key, true); if (depth === 0) { sourceStack = []; targetStack = []; @@ -28159,8 +28777,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -28201,7 +28819,13 @@ var ts; inferenceSucceeded = !!unionOrSuperType; } else { - inferredType = emptyObjectType; + var defaultType = getDefaultFromTypeParameter(context.signature.typeParameters[index]); + if (defaultType) { + inferredType = instantiateType(defaultType, combineTypeMappers(createBackreferenceMapper(context.signature.typeParameters, index), getInferenceMapper(context))); + } + else { + inferredType = emptyObjectType; + } inferenceSucceeded = true; } context.inferredTypes[index] = inferredType; @@ -28236,10 +28860,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 160: + case 161: return true; case 70: - case 141: + case 142: node = node.parent; continue; default: @@ -28256,7 +28880,7 @@ var ts; if (node.kind === 98) { return "0"; } - if (node.kind === 177) { + if (node.kind === 178) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -28267,7 +28891,7 @@ var ts; case 70: case 98: return node; - case 177: + case 178: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -28276,19 +28900,19 @@ var ts; switch (source.kind) { case 70: return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 223 || target.kind === 174) && + (target.kind === 225 || target.kind === 175) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98: return target.kind === 98; - case 177: - return target.kind === 177 && + case 178: + return target.kind === 178 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 177) { + while (source.kind === 178) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -28297,7 +28921,7 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 177 && + return target.kind === 178 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -28305,7 +28929,7 @@ var ts; if (expr.kind === 70) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 177) { + if (expr.kind === 178) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -28314,9 +28938,9 @@ var ts; function isDiscriminantProperty(type, name) { if (type && type.flags & 65536) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && prop.flags & 268435456) { + if (prop && getCheckFlags(prop) & 2) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.hasNonUniformType && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.checkFlags & 16 && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -28335,7 +28959,7 @@ var ts; } } } - if (callExpression.expression.kind === 177 && + if (callExpression.expression.kind === 178 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -28374,8 +28998,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -28383,7 +29007,7 @@ var ts; function isFunctionObjectType(type) { var resolved = resolveStructuredTypeMembers(type); return !!(resolved.callSignatures.length || resolved.constructSignatures.length || - resolved.members["bind"] && isTypeSubtypeOf(type, globalFunctionType)); + resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type) { var flags = type.flags; @@ -28426,6 +29050,9 @@ var ts; if (flags & 512) { return strictNullChecks ? 1981320 : 4193160; } + if (flags & 16777216) { + return strictNullChecks ? 6166480 : 8378320; + } if (flags & 16384) { var constraint = getConstraintOfTypeParameter(type); return getTypeFacts(constraint || emptyObjectType); @@ -28461,10 +29088,16 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 || node.parent.kind === 257 ? + var isDestructuringDefaultAssignment = node.parent.kind === 176 && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 260 && isDestructuringAssignmentTarget(node.parent.parent); + return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } + function isDestructuringAssignmentTarget(parent) { + return parent.parent.kind === 193 && parent.parent.left === parent || + parent.parent.kind === 215 && parent.parent.initializer === parent; + } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); } @@ -28480,21 +29113,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 212: + case 214: return stringType; - case 213: + case 215: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 192: + case 193: return getAssignedTypeOfBinaryExpression(parent); - case 186: + case 187: return undefinedType; - case 175: + case 176: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 196: + case 197: return getAssignedTypeOfSpreadExpression(parent); - case 257: + case 260: return getAssignedTypeOfPropertyAssignment(parent); - case 258: + case 261: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -28502,7 +29135,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 172 ? + var type = pattern.kind === 173 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -28517,35 +29150,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 212) { + if (node.parent.parent.kind === 214) { return stringType; } - if (node.parent.parent.kind === 213) { + if (node.parent.parent.kind === 215) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 223 ? + return node.kind === 225 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 223 || node.kind === 174 ? + return node.kind === 225 || node.kind === 175 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 223 && node.initializer && + return node.kind === 225 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 174 && node.parent.kind === 192 && + node.kind !== 175 && node.parent.kind === 193 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 183: + case 184: return getReferenceCandidate(node.expression); - case 192: + case 193: switch (node.operatorToken.kind) { case 57: return getReferenceCandidate(node.left); @@ -28557,13 +29190,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 183 || - parent.kind === 192 && parent.operatorToken.kind === 57 && parent.left === node || - parent.kind === 192 && parent.operatorToken.kind === 25 && parent.right === node ? + return parent.kind === 184 || + parent.kind === 193 && parent.operatorToken.kind === 57 && parent.left === node || + parent.kind === 193 && parent.operatorToken.kind === 25 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 253) { + if (clause.kind === 256) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -28665,8 +29298,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; if (!(t.flags & 8192)) { if (!(getObjectFlags(t) & 256)) { return false; @@ -28684,11 +29317,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 177 && (parent.name.text === "length" || - parent.parent.kind === 179 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 178 && + var isLengthPushOrUnshift = parent.kind === 178 && (parent.name.text === "length" || + parent.parent.kind === 180 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 179 && parent.expression === root && - parent.parent.kind === 192 && + parent.parent.kind === 193 && parent.parent.operatorToken.kind === 57 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -28717,7 +29350,7 @@ var ts; } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 17810431)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -28727,7 +29360,7 @@ var ts; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; var resultType = getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 201 && getTypeWithFacts(resultType, 524288).flags & 8192) { + if (reference.parent.kind === 202 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } return resultType; @@ -28741,7 +29374,16 @@ var ts; } } var type = void 0; - if (flow.flags & 16) { + if (flow.flags & 4096) { + flow.locked = true; + type = getTypeAtFlowNode(flow.antecedent); + flow.locked = false; + } + else if (flow.flags & 2048) { + flow = flow.antecedent; + continue; + } + else if (flow.flags & 16) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; @@ -28772,7 +29414,7 @@ var ts; } else if (flow.flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 177) { + if (container && container !== flowContainer && reference.kind !== 178) { flow = container.flowNode; continue; } @@ -28815,7 +29457,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 179 ? + var expr = node.kind === 180 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -28823,7 +29465,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 179) { + if (node.kind === 180) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -28875,6 +29517,9 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; + if (antecedent.flags & 2048 && antecedent.lock.locked) { + continue; + } var flowType = getTypeAtFlowNode(antecedent); var type = getTypeFromFlowType(flowType); if (type === declaredType && declaredType === initialType) { @@ -28898,8 +29543,9 @@ var ts; if (!key) { key = getFlowCacheKey(reference); } - if (cache[key]) { - return cache[key]; + var cached = cache.get(key); + if (cached) { + return cached; } for (var i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { @@ -28921,8 +29567,9 @@ var ts; firstAntecedentType = flowType; } var type = getTypeFromFlowType(flowType); - if (cache[key]) { - return cache[key]; + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; } if (!ts.contains(antecedentTypes, type)) { antecedentTypes.push(type); @@ -28938,10 +29585,11 @@ var ts; if (isIncomplete(firstAntecedentType)) { return createFlowType(result, true); } - return cache[key] = result; + cache.set(key, result); + return result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 177 && + return expr.kind === 178 && declaredType.flags & 65536 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -28975,10 +29623,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 187 && right_1.kind === 9) { + if (left_1.kind === 188 && right_1.kind === 9) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 187 && left_1.kind === 9) { + if (right_1.kind === 188 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -29024,7 +29672,7 @@ var ts; assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); } - if (type.flags & 33281) { + if (type.flags & 16810497) { return type; } if (assumeTrue) { @@ -29049,14 +29697,14 @@ var ts; assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 65536)) { - var targetType = typeofTypesByName[literal.text]; + var targetType = typeofTypesByName.get(literal.text); if (targetType && isTypeSubtypeOf(targetType, type)) { return targetType; } } var facts = assumeTrue ? - typeofEQFacts[literal.text] || 64 : - typeofNEFacts[literal.text] || 8192; + typeofEQFacts.get(literal.text) || 64 : + typeofNEFacts.get(literal.text) || 8192; return getTypeWithFacts(type, facts); } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { @@ -29156,7 +29804,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 178 || invokedExpression.kind === 177) { + if (invokedExpression.kind === 179 || invokedExpression.kind === 178) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -29173,15 +29821,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 177: + case 178: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 179: + case 180: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 183: + case 184: return narrowType(type, expr.expression, assumeTrue); - case 192: + case 193: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 190: + case 191: if (expr.operator === 50) { return narrowType(type, expr.operand, !assumeTrue); } @@ -29208,9 +29856,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 231 || - node.kind === 261 || - node.kind === 147) { + node.kind === 233 || + node.kind === 264 || + node.kind === 148) { return node; } } @@ -29241,7 +29889,7 @@ var ts; if (node.kind === 70) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 144) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 145) { symbol.isAssigned = true; } } @@ -29261,7 +29909,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 185) { + if (container.kind === 186) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256)) { @@ -29279,7 +29927,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; - if (declaration_1.kind === 226 + if (declaration_1.kind === 228 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -29291,11 +29939,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 197) { + else if (declaration_1.kind === 198) { var container = ts.getThisContainer(node, false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 147 && ts.hasModifier(container, 32)) { + if (container.kind === 148 && ts.hasModifier(container, 32)) { getNodeLinks(declaration_1).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -29307,6 +29955,7 @@ var ts; } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkCollisionWithCapturedNewTargetVariable(node, node); checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; @@ -29324,17 +29973,17 @@ var ts; if (!(localOrExportSymbol.flags & 3) || assignmentKind === 1 || !declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 144; + var isParameter = ts.getRootDeclaration(declaration).kind === 145; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - while (flowContainer !== declarationContainer && (flowContainer.kind === 184 || - flowContainer.kind === 185 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 185 || + flowContainer.kind === 186 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0 || isInTypeQuery(node)) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); if (type === autoType || type === autoArrayType) { @@ -29365,7 +30014,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 256) { + symbol.valueDeclaration.parent.kind === 259) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -29383,8 +30032,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 211 && - ts.getAncestor(symbol.valueDeclaration, 224).parent === container && + if (container.kind === 213 && + ts.getAncestor(symbol.valueDeclaration, 226).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -29396,14 +30045,14 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 183) { + while (current.parent.kind === 184) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 190 || current.parent.kind === 191)) { + else if ((current.parent.kind === 191 || current.parent.kind === 192)) { var expr = current.parent; isAssigned = expr.operator === 42 || expr.operator === 43; } @@ -29422,7 +30071,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 147 || container.kind === 150) { + if (container.kind === 148 || container.kind === 151) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -29466,32 +30115,32 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 150) { + if (container.kind === 151) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } - if (container.kind === 185) { + if (container.kind === 186) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 230: + case 232: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 229: + case 231: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 150: + case 151: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 148: case 147: - case 146: if (ts.getModifierFlags(container) & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 142: + case 143: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -29500,7 +30149,7 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 184 && + if (container.kind === 185 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent @@ -29535,27 +30184,27 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 274) { + if (jsdocType && jsdocType.kind === 278) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 277) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 281) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 144) { + if (n.kind === 145) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 179 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 180 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 185) { + while (container && container.kind === 186) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -29564,16 +30213,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 142) { + while (current && current !== container && current.kind !== 143) { current = current.parent; } - if (current && current.kind === 142) { + if (current && current.kind === 143) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 176)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 177)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -29581,7 +30230,7 @@ var ts; } return unknownType; } - if (!isCallExpression && container.kind === 150) { + if (!isCallExpression && container.kind === 151) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if ((ts.getModifierFlags(container) & 32) || isCallExpression) { @@ -29591,7 +30240,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 149 && ts.getModifierFlags(container) & 256) { + if (container.kind === 150 && ts.getModifierFlags(container) & 256) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -29602,7 +30251,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 176) { + if (container.parent.kind === 177) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -29620,7 +30269,7 @@ var ts; } return unknownType; } - if (container.kind === 150 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 151 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -29632,24 +30281,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 150; + return container.kind === 151; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 176) { + if (ts.isClassLike(container.parent) || container.parent.kind === 177) { if (ts.getModifierFlags(container) & 32) { - return container.kind === 149 || - container.kind === 148 || - container.kind === 151 || - container.kind === 152; + return container.kind === 150 || + container.kind === 149 || + container.kind === 152 || + container.kind === 153; } else { - return container.kind === 149 || - container.kind === 148 || - container.kind === 151 || + return container.kind === 150 || + container.kind === 149 || container.kind === 152 || + container.kind === 153 || + container.kind === 148 || container.kind === 147 || - container.kind === 146 || - container.kind === 150; + container.kind === 151; } } } @@ -29657,7 +30306,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 185) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 186) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -29672,23 +30321,23 @@ var ts; var func = parameter.parent; if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { var iife = ts.getImmediatelyInvokedFunctionExpression(func); - if (iife) { + if (iife && iife.arguments) { var indexOfParameter = ts.indexOf(func.parameters, parameter); - if (iife.arguments && indexOfParameter < iife.arguments.length) { - if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return createArrayType(getUnionType(restTypes)); + if (parameter.dotDotDotToken) { + var restTypes = []; + for (var i = indexOfParameter; i < iife.arguments.length; i++) { + restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); } - var links = getNodeLinks(iife); - var cached = links.resolvedSignature; - links.resolvedSignature = anySignature; - var type = getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])); - links.resolvedSignature = cached; - return type; + return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; } + var links = getNodeLinks(iife); + var cached = links.resolvedSignature; + links.resolvedSignature = anySignature; + var type = indexOfParameter < iife.arguments.length ? + getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + parameter.initializer ? undefined : undefinedWideningType; + links.resolvedSignature = cached; + return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -29713,7 +30362,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 144) { + if (declaration.kind === 145) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -29724,11 +30373,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_21 = declaration.propertyName || declaration.name; + var name = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_21)) { - var text = ts.getTextOfPropertyName(name_21); + !ts.isBindingPattern(name)) { + var text = ts.getTextOfPropertyName(name); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -29765,7 +30414,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 144 && node.parent.initializer === node) { + if (node.parent.kind === 145 && node.parent.initializer === node) { return true; } node = node.parent; @@ -29774,8 +30423,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 150 || - functionDecl.kind === 151 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 152))) { + functionDecl.kind === 151 || + functionDecl.kind === 152 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 153))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -29794,7 +30443,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 181) { + if (template.parent.kind === 182) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -29831,8 +30480,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -29899,19 +30548,16 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxAttribute(attribute) { - var kind = attribute.kind; - var jsxElement = attribute.parent; - var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 250) { - if (!attrsType || isTypeAny(attrsType)) { + var attributesType = getContextualType(attribute.parent); + if (ts.isJsxAttribute(attribute)) { + if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfType(attrsType, attribute.name.text); + return getTypeOfPropertyOfType(attributesType, attribute.name.text); } - else if (attribute.kind === 251) { - return attrsType; + else { + return attributesType; } - ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); } function getApparentTypeOfContextualType(node) { var type = getContextualType(node); @@ -29926,42 +30572,45 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 223: - case 144: + case 225: + case 145: + case 148: case 147: - case 146: - case 174: - return getContextualTypeForInitializerExpression(node); - case 185: - case 216: - return getContextualTypeForReturnExpression(node); - case 195: - return getContextualTypeForYieldOperand(parent); - case 179: - case 180: - return getContextualTypeForArgument(parent, node); - case 182: - case 200: - return getTypeFromTypeNode(parent.type); - case 192: - return getContextualTypeForBinaryOperand(node); - case 257: - case 258: - return getContextualTypeForObjectLiteralElement(parent); case 175: - return getContextualTypeForElementExpression(node); - case 193: - return getContextualTypeForConditionalOperand(node); - case 202: - ts.Debug.assert(parent.parent.kind === 194); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 186: + case 218: + return getContextualTypeForReturnExpression(node); + case 196: + return getContextualTypeForYieldOperand(parent); + case 180: + case 181: + return getContextualTypeForArgument(parent, node); case 183: + case 201: + return getTypeFromTypeNode(parent.type); + case 193: + return getContextualTypeForBinaryOperand(node); + case 260: + case 261: + return getContextualTypeForObjectLiteralElement(parent); + case 176: + return getContextualTypeForElementExpression(node); + case 194: + return getContextualTypeForConditionalOperand(node); + case 204: + ts.Debug.assert(parent.parent.kind === 195); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 184: + return getContextualType(parent); + case 255: return getContextualType(parent); case 252: - return getContextualType(parent); - case 250: - case 251: + case 254: return getContextualTypeForJsxAttribute(parent); + case 250: + case 249: + return getAttributesTypeFromJsxOpeningLikeElement(parent); } return undefined; } @@ -29989,7 +30638,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 184 || node.kind === 185; + return node.kind === 185 || node.kind === 186; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -30002,7 +30651,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -30012,8 +30661,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -30043,8 +30692,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 174 && !!node.initializer) || - (node.kind === 192 && node.operatorToken.kind === 57); + return (node.kind === 175 && !!node.initializer) || + (node.kind === 193 && node.operatorToken.kind === 57); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -30053,7 +30702,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 196) { + if (inDestructuringPattern && e.kind === 197) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -30065,7 +30714,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 196; + hasSpreadElement = hasSpreadElement || e.kind === 197; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -30076,7 +30725,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 173 || pattern.kind === 175)) { + if (pattern && (pattern.kind === 174 || pattern.kind === 176)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -30084,7 +30733,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 198) { + if (patternElement.kind !== 199) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -30101,7 +30750,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 142 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 143 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 340); @@ -30147,7 +30796,7 @@ var ts; var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 172 || contextualType.pattern.kind === 176); + (contextualType.pattern.kind === 173 || contextualType.pattern.kind === 177); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -30156,27 +30805,27 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 257 || - memberDecl.kind === 258 || + if (memberDecl.kind === 260 || + memberDecl.kind === 261 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 257) { + if (memberDecl.kind === 260) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 149) { + else if (memberDecl.kind === 150) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 258); + ts.Debug.assert(memberDecl.kind === 261); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; - var prop = createSymbol(4 | 67108864 | member.flags, member.name); + var prop = createSymbol(4 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 257 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 258 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 260 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 261 && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 536870912; + prop.flags |= 67108864; } if (ts.hasDynamicName(memberDecl)) { patternWithComputedProperties = true; @@ -30185,7 +30834,7 @@ var ts; else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & 512)) { var impliedProp = getPropertyOfType(contextualType, member.name); if (impliedProp) { - prop.flags |= impliedProp.flags & 536870912; + prop.flags |= impliedProp.flags & 67108864; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -30200,12 +30849,12 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 259) { - if (languageVersion < 5) { + else if (memberDecl.kind === 262) { + if (languageVersion < 2) { checkExternalEmitHelpers(memberDecl, 2); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), true); + spread = getSpreadType(spread, createObjectLiteralType()); propertiesArray = []; propertiesTable = ts.createMap(); hasComputedStringProperty = false; @@ -30217,12 +30866,12 @@ var ts; error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } - spread = getSpreadType(spread, type, false); + spread = getSpreadType(spread, type); offset = i + 1; continue; } else { - ts.Debug.assert(memberDecl.kind === 151 || memberDecl.kind === 152); + ts.Debug.assert(memberDecl.kind === 152 || memberDecl.kind === 153); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -30234,25 +30883,25 @@ var ts; } } else { - propertiesTable[member.name] = member; + propertiesTable.set(member.name, member); } propertiesArray.push(member); } if (contextualTypeHasPattern) { for (var _i = 0, _a = getPropertiesOfType(contextualType); _i < _a.length; _i++) { var prop = _a[_i]; - if (!propertiesTable[prop.name]) { - if (!(prop.flags & 536870912)) { + if (!propertiesTable.get(prop.name)) { + if (!(prop.flags & 67108864)) { 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; + propertiesTable.set(prop.name, prop); propertiesArray.push(prop); } } } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), true); + spread = getSpreadType(spread, createObjectLiteralType()); } if (spread.flags & 32768) { spread.flags |= propagatedFlags; @@ -30281,7 +30930,7 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (1 | 4096 | 2048) || + return !!(type.flags & (1 | 4096 | 2048 | 16777216) || type.flags & 32768 && !isGenericMappedType(type) || type.flags & 196608 && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } @@ -30300,13 +30949,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 252: + case 255: checkJsxExpression(child); break; - case 246: + case 248: checkJsxElement(child); break; - case 247: + case 249: checkJsxSelfClosingElement(child); break; } @@ -30317,71 +30966,88 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 177 || tagName.kind === 98) { + if (tagName.kind === 178 || tagName.kind === 98) { 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 attributeType = getTypeOfPropertyOfType(elementAttributesType, ts.getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0); - if (attributeType) { - correspondingPropType = attributeType; + function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, contextualMapper) { + var attributes = openingLikeElement.attributes; + var attributesTable = ts.createMap(); + var spread = emptyObjectType; + var attributesArray = []; + for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { + var attributeDecl = _a[_i]; + var member = attributeDecl.symbol; + if (ts.isJsxAttribute(attributeDecl)) { + var exprType = attributeDecl.initializer ? + checkExpression(attributeDecl.initializer, contextualMapper) : + trueType; + var attributeSymbol = createSymbol(4 | 134217728 | member.flags, member.name); + attributeSymbol.declarations = member.declarations; + attributeSymbol.parent = member.parent; + if (member.valueDeclaration) { + attributeSymbol.valueDeclaration = member.valueDeclaration; } - else { - if (!correspondingPropType) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; - } + attributeSymbol.type = exprType; + attributeSymbol.target = member; + attributesTable.set(attributeSymbol.name, attributeSymbol); + attributesArray.push(attributeSymbol); + } + else { + ts.Debug.assert(attributeDecl.kind === 254); + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); } + var exprType = checkExpression(attributeDecl.expression); + if (!(exprType.flags & (32768 | 1))) { + error(attributeDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + return anyType; + } + if (isTypeAny(exprType)) { + return anyType; + } + spread = getSpreadType(spread, exprType); } } - var exprType; - if (node.initializer) { - exprType = checkExpression(node.initializer); + if (spread !== emptyObjectType) { + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); + } + attributesArray = getPropertiesOfType(spread); } - else { - exprType = booleanType; + attributesTable = ts.createMap(); + if (attributesArray) { + ts.forEach(attributesArray, function (attr) { + if (!filter || filter(attr)) { + attributesTable.set(attr.name, attr); + } + }); } - if (correspondingPropType) { - checkTypeAssignableTo(exprType, correspondingPropType, node); + return createJsxAttributesType(attributes.symbol, attributesTable); + function createJsxAttributesType(symbol, attributesTable) { + var result = createAnonymousType(symbol, attributesTable, emptyArray, emptyArray, undefined, undefined); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; + result.flags |= 33554432 | 4194304 | freshObjectLiteralFlag; + result.objectFlags |= 128; + return result; } - nameTable[node.name.text] = true; - return exprType; } - function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { - if (compilerOptions.jsx === 2) { - checkExternalEmitHelpers(node, 2); - } - var type = checkExpression(node.expression); - var props = getPropertiesOfType(type); - 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) { - 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 checkJsxAttributes(node, contextualMapper) { + return createJsxAttributesTypeFromAttributesProperty(node.parent, undefined, contextualMapper); } function getJsxType(name) { - if (jsxTypes[name] === undefined) { - return jsxTypes[name] = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType; + var jsxType = jsxTypes.get(name); + if (jsxType === undefined) { + jsxTypes.set(name, jsxType = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType); } - return jsxTypes[name]; + return jsxType; } function getIntrinsicTagSymbol(node) { var links = getNodeLinks(node); @@ -30446,23 +31112,84 @@ var ts; return undefined; } } - function getResolvedJsxType(node, elemType, elemClassType) { - if (!elemType) { - elemType = checkExpression(node.tagName); + function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + if (jsxElementType) { + var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, undefined); + if (callSignature !== unknownSignature) { + var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); + var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + paramType = intersectTypes(intrinsicAttributes, paramType); + } + return paramType; + } + } + } } - if (elemType.flags & 65536) { - var types = elemType.types; - return getUnionType(ts.map(types, function (type) { - return getResolvedJsxType(node, type, elemClassType); + return undefined; + } + function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + if (jsxElementType) { + var candidatesOutArray = []; + getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); + var result = void 0; + var allMatchingAttributesType = void 0; + for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { + var candidate = candidatesOutArray_1[_i]; + var callReturnType = getReturnTypeOfSignature(candidate); + var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + var shouldBeCandidate = true; + for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { + var attribute = _b[_a]; + if (ts.isJsxAttribute(attribute) && + isUnhyphenatedJsxName(attribute.name.text) && + !getPropertyOfType(paramType, attribute.name.text)) { + shouldBeCandidate = false; + break; + } + } + if (shouldBeCandidate) { + result = intersectTypes(result, paramType); + } + allMatchingAttributesType = intersectTypes(allMatchingAttributesType, paramType); + } + } + if (!result) { + result = allMatchingAttributesType; + } + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + result = intersectTypes(intrinsicAttributes, result); + } + return result; + } + } + return undefined; + } + function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { + if (!elementType) { + elementType = checkExpression(openingLikeElement.tagName); + } + if (elementType.flags & 65536) { + var types = elementType.types; + return getUnionType(types.map(function (type) { + return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); }), true); } - if (elemType.flags & 2) { + if (elementType.flags & 2) { return anyType; } - else if (elemType.flags & 32) { + else if (elementType.flags & 32) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); if (intrinsicElementsType !== unknownType) { - var stringLiteralTypeName = elemType.text; + var stringLiteralTypeName = elementType.text; var intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName); if (intrinsicProp) { return getTypeOfSymbol(intrinsicProp); @@ -30471,28 +31198,19 @@ var ts; if (indexSignatureType) { return indexSignatureType; } - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); + error(openingLikeElement, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); } return anyType; } - var elemInstanceType = getJsxElementInstanceType(node, elemType); - if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { - if (jsxElementType) { - var callSignatures = elemType && getSignaturesOfType(elemType, 0); - var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); - if (intrinsicAttributes !== unknownType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } - } + var elemInstanceType = getJsxElementInstanceType(openingLikeElement, elementType); + var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? + tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : + defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); + if (statelessAttributesType) { + return statelessAttributesType; } - if (elemClassType) { - checkTypeRelatedTo(elemInstanceType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + if (elementClassType) { + checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } if (isTypeAny(elemInstanceType)) { return elemInstanceType; @@ -30513,7 +31231,7 @@ var ts; return attributesType; } else if (attributesType.flags & 65536) { - error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); + error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); return anyType; } else { @@ -30538,30 +31256,49 @@ var ts; } } } - function getJsxElementAttributesType(node) { + function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) { + ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName)); var links = getNodeLinks(node); - if (!links.resolvedJsxType) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1) { - return links.resolvedJsxType = getTypeOfSymbol(symbol); - } - else if (links.jsxFlags & 2) { - return links.resolvedJsxType = getIndexInfoOfSymbol(symbol, 0).type; - } - else { - return links.resolvedJsxType = unknownType; - } + if (!links.resolvedJsxElementAttributesType) { + var symbol = getIntrinsicTagSymbol(node); + if (links.jsxFlags & 1) { + return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol); + } + else if (links.jsxFlags & 2) { + return links.resolvedJsxElementAttributesType = getIndexInfoOfSymbol(symbol, 0).type; } else { - var elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxType = getResolvedJsxType(node, undefined, elemClassType); + return links.resolvedJsxElementAttributesType = unknownType; } } - return links.resolvedJsxType; + return links.resolvedJsxElementAttributesType; + } + function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { + var links = getNodeLinks(node); + if (!links.resolvedJsxElementAttributesType) { + var elemClassType = getJsxGlobalElementClassType(); + return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); + } + return links.resolvedJsxElementAttributesType; + } + function getAllAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + return getCustomJsxElementAttributesType(node, true); + } + } + function getAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + return getCustomJsxElementAttributesType(node, false); + } } function getJsxAttributePropertySymbol(attrib) { - var attributesType = getJsxElementAttributesType(attrib.parent); + var attributesType = getAttributesTypeFromJsxOpeningLikeElement(attrib.parent.parent); var prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } @@ -30597,61 +31334,77 @@ var ts; markAliasSymbolAsReferenced(reactSym); } } - var targetAttributesType = getJsxElementAttributesType(node); - var nameTable = ts.createMap(); - var sawSpreadedAny = false; - for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 250) { - checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); - } - else { - ts.Debug.assert(node.attributes[i].kind === 251); - var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); - if (isTypeAny(spreadType)) { - sawSpreadedAny = true; - } - } + checkJsxAttributesAssignableToTagNameAttributes(node); + } + function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement) { + var targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? + getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : + getCustomJsxElementAttributesType(openingLikeElement, false); + var sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement, function (attribute) { + return isUnhyphenatedJsxName(attribute.name) || !!(getPropertyOfType(targetAttributesType, attribute.name)); + }); + if (targetAttributesType === emptyObjectType && (isTypeAny(sourceAttributesType) || sourceAttributesType.properties.length > 0)) { + error(openingLikeElement, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); } - if (targetAttributesType && !sawSpreadedAny) { - var targetProperties = getPropertiesOfType(targetAttributesType); - for (var i = 0; i < targetProperties.length; i++) { - if (!(targetProperties[i].flags & 536870912) && - !nameTable[targetProperties[i].name]) { - error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); - } - } + else { + checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.attributes.properties.length > 0 ? openingLikeElement.attributes : openingLikeElement); } } - function checkJsxExpression(node) { + function checkJsxExpression(node, contextualMapper) { if (node.expression) { - return checkExpression(node.expression); + var type = checkExpression(node.expression, contextualMapper); + if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { + error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); + } + return type; } else { return unknownType; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 147; + return s.valueDeclaration ? s.valueDeclaration.kind : 148; } function getDeclarationModifierFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 ? 4 | 32 : 0; + if (s.valueDeclaration) { + var flags = ts.getCombinedModifierFlags(s.valueDeclaration); + return s.parent && s.parent.flags & 32 ? flags : flags & ~28; + } + if (getCheckFlags(s) & 2) { + var checkFlags = s.checkFlags; + var accessModifier = checkFlags & 128 ? 8 : + checkFlags & 32 ? 4 : + 16; + var staticModifier = checkFlags & 256 ? 32 : 0; + return accessModifier | staticModifier; + } + if (s.flags & 16777216) { + return 4 | 32; + } + return 0; } function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; } - function checkClassPropertyAccess(node, left, type, prop) { + function checkPropertyAccessibility(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); - var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 || node.kind === 223 ? + var errorNode = node.kind === 178 || node.kind === 225 ? node.name : node.right; + if (getCheckFlags(prop) & 128) { + error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); + return false; + } if (left.kind === 96) { - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 149) { - error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - return false; + if (languageVersion < 2) { + var propKind = getDeclarationKindFromSymbol(prop); + if (propKind !== 150 && propKind !== 149) { + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } } if (flags & 128) { - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } } @@ -30661,7 +31414,7 @@ var ts; if (flags & 8) { var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } return true; @@ -30671,10 +31424,10 @@ var ts; } var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); - return hasBaseType(enclosingClass, declaringClass) ? enclosingClass : undefined; + return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; }); if (!enclosingClass) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); return false; } if (flags & 32) { @@ -30690,16 +31443,17 @@ var ts; return true; } function checkNonNullExpression(node) { - var type = checkExpression(node); - if (strictNullChecks) { - var kind = getFalsyFlags(type) & 6144; - if (kind) { - error(node, kind & 2048 ? kind & 4096 ? - ts.Diagnostics.Object_is_possibly_null_or_undefined : - ts.Diagnostics.Object_is_possibly_undefined : - ts.Diagnostics.Object_is_possibly_null); - } - return getNonNullableType(type); + return checkNonNullType(checkExpression(node), node); + } + function checkNonNullType(type, errorNode) { + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 6144; + if (kind) { + error(errorNode, kind & 2048 ? kind & 4096 ? + ts.Diagnostics.Object_is_possibly_null_or_undefined : + ts.Diagnostics.Object_is_possibly_undefined : + ts.Diagnostics.Object_is_possibly_null); + var t = getNonNullableType(type); + return t.flags & (6144 | 8192) ? unknownType : t; } return type; } @@ -30728,7 +31482,7 @@ var ts; noUnusedIdentifiers && (prop.flags & 106500) && prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8)) { - if (prop.flags & 16777216) { + if (getCheckFlags(prop) & 1) { getSymbolLinks(prop).target.isReferenced = true; } else { @@ -30736,6 +31490,15 @@ var ts; } } } + function isInPropertyInitializer(node) { + while (node) { + if (node.parent && node.parent.kind === 148 && node.parent.initializer === node) { + return true; + } + node = node.parent; + } + return false; + } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { var type = checkNonNullExpression(left); if (isTypeAny(type) || type === silentNeverType) { @@ -30747,16 +31510,23 @@ var ts; } var prop = getPropertyOfType(apparentType, right.text); if (!prop) { + var stringIndexType = getIndexTypeOfType(apparentType, 0); + if (stringIndexType) { + return stringIndexType; + } if (right.text && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, type.flags & 16384 && type.isThisType ? apparentType : type); } return unknownType; } + if (prop.valueDeclaration && + isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + } markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; - if (prop.parent && prop.parent.flags & 32) { - checkClassPropertyAccess(node, left, apparentType, prop); - } + checkPropertyAccessibility(node, left, apparentType, prop); var propType = getTypeOfSymbol(prop); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { @@ -30765,7 +31535,7 @@ var ts; return unknownType; } } - if (node.kind !== 177 || assignmentKind === 1 || + if (node.kind !== 178 || assignmentKind === 1 || !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 65536)) { return propType; @@ -30774,21 +31544,21 @@ var ts; return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 177 + var left = node.kind === 178 ? 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); + if (prop) { + return checkPropertyAccessibility(node, left, type, prop); } } return true; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 224) { + if (initializer.kind === 226) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -30810,7 +31580,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 212 && + if (node.kind === 214 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -30828,7 +31598,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 180 && node.parent.expression === node) { + if (node.parent.kind === 181 && 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); @@ -30848,7 +31618,7 @@ var ts; error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } - return getIndexedAccessType(objectType, indexType, node); + return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === unknownType) { @@ -30881,10 +31651,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 181) { + if (node.kind === 182) { checkExpression(node.template); } - else if (node.kind !== 145) { + else if (node.kind !== 146) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -30906,19 +31676,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_8 = signature.declaration && signature.declaration.parent; + var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_8 === lastParent) { + if (lastParent && parent === lastParent) { index++; } else { - lastParent = parent_8; + lastParent = parent; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_8; + lastParent = parent; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -30935,7 +31705,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 196) { + if (arg && arg.kind === 197) { return i; } } @@ -30948,11 +31718,14 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 181) { + if (ts.isJsxOpeningLikeElement(node)) { + return true; + } + if (node.kind === 182) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 194) { + if (tagExpression.template.kind === 195) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -30964,7 +31737,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 145) { + else if (node.kind === 146) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); @@ -30972,7 +31745,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 180); + ts.Debug.assert(callExpression.kind === 181); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -30980,8 +31753,10 @@ var ts; typeArguments = callExpression.typeArguments; spreadArgIndex = getSpreadArgumentIndex(args); } + var numTypeParameters = ts.length(signature.typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters); var hasRightNumberOfTypeArgs = !typeArguments || - (signature.typeParameters && typeArguments.length === signature.typeParameters.length); + (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters); if (!hasRightNumberOfTypeArgs) { return false; } @@ -31031,7 +31806,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 !== 198) { + if (arg === undefined || arg.kind !== 199) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -31056,7 +31831,7 @@ var ts; var typeParameters = signature.typeParameters; var typeArgumentsAreAssignable = true; var mapper; - for (var i = 0; i < typeParameters.length; i++) { + for (var i = 0; i < typeArgumentNodes.length; i++) { if (typeArgumentsAreAssignable) { var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { @@ -31076,9 +31851,29 @@ var ts; } return typeArgumentsAreAssignable; } + function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation) { + var callIsIncomplete = node.attributes.end === node.end; + if (callIsIncomplete) { + return true; + } + var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + var paramType = getTypeAtPosition(signature, 0); + var attributesType = checkExpressionWithContextualType(node.attributes, paramType, undefined); + var argProperties = getPropertiesOfType(attributesType); + for (var _i = 0, argProperties_1 = argProperties; _i < argProperties_1.length; _i++) { + var arg = argProperties_1[_i]; + if (!getPropertyOfType(paramType, arg.name) && isUnhyphenatedJsxName(arg.name)) { + return false; + } + } + return checkTypeRelatedTo(attributesType, paramType, relation, undefined, headMessage); + } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { + if (ts.isJsxOpeningLikeElement(node)) { + return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); + } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 180) { + if (thisType && thisType !== voidType && node.kind !== 181) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -31091,7 +31886,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 !== 198) { + if (arg === undefined || arg.kind !== 199) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -31106,51 +31901,54 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 179) { + if (node.kind === 180) { var callee = node.expression; - if (callee.kind === 177) { + if (callee.kind === 178) { return callee.expression; } - else if (callee.kind === 178) { + else if (callee.kind === 179) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 181) { + if (node.kind === 182) { var template = node.template; args = [undefined]; - if (template.kind === 194) { + if (template.kind === 195) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 145) { + else if (node.kind === 146) { return undefined; } + else if (ts.isJsxOpeningLikeElement(node)) { + args = node.attributes.properties.length > 0 ? [node.attributes] : emptyArray; + } else { args = node.arguments || emptyArray; } return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 145) { + if (node.kind === 146) { switch (node.parent.kind) { - case 226: - case 197: + case 228: + case 198: return 1; - case 147: + case 148: return 2; - case 149: - case 151: + case 150: case 152: + case 153: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 144: + case 145: return 3; } } @@ -31159,48 +31957,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 228) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 144) { + if (node.kind === 145) { node = node.parent; - if (node.kind === 150) { + if (node.kind === 151) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 147 || - node.kind === 149 || - node.kind === 151 || - node.kind === 152) { + if (node.kind === 148 || + node.kind === 150 || + node.kind === 152 || + node.kind === 153) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 228) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 144) { + if (node.kind === 145) { node = node.parent; - if (node.kind === 150) { + if (node.kind === 151) { return anyType; } } - if (node.kind === 147 || - node.kind === 149 || - node.kind === 151 || - node.kind === 152) { + if (node.kind === 148 || + node.kind === 150 || + node.kind === 152 || + node.kind === 153) { var element = node; switch (element.name.kind) { case 70: case 8: case 9: return getLiteralTypeForText(32, element.name.text); - case 142: + case 143: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512)) { return nameType; @@ -31217,20 +32015,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 228) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 144) { + if (node.kind === 145) { return numberType; } - if (node.kind === 147) { + if (node.kind === 148) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 149 || - node.kind === 151 || - node.kind === 152) { + if (node.kind === 150 || + node.kind === 152 || + node.kind === 153) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -31251,26 +32049,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex) { - if (node.kind === 145) { + if (node.kind === 146) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 181) { + else if (argIndex === 0 && node.kind === 182) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 145 || - (argIndex === 0 && node.kind === 181)) { + if (node.kind === 146 || + (argIndex === 0 && node.kind === 182)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 145) { + if (node.kind === 146) { return node.expression; } - else if (argIndex === 0 && node.kind === 181) { + else if (argIndex === 0 && node.kind === 182) { return node.template; } else { @@ -31278,10 +32076,11 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 181; - var isDecorator = node.kind === 145; + var isTaggedTemplate = node.kind === 182; + var isDecorator = node.kind === 146; + var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; - if (!isTaggedTemplate && !isDecorator) { + if (!isTaggedTemplate && !isDecorator && !isJsxOpeningOrSelfClosingElement) { typeArguments = node.typeArguments; if (node.expression.kind !== 96) { ts.forEach(typeArguments, checkSourceElement); @@ -31309,7 +32108,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 179 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 180 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -31323,6 +32122,9 @@ var ts; return result; } if (candidateForArgumentError) { + if (isJsxOpeningOrSelfClosingElement) { + return candidateForArgumentError; + } checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); } else if (candidateForTypeArgumentError) { @@ -31338,7 +32140,7 @@ var ts; if (headMessage) { diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); } - reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); + reportNoCommonSupertypeError(inferenceCandidates, node.tagName || node.expression || node.tag, diagnosticChainHead); } } else { @@ -31381,13 +32183,13 @@ var ts; if (candidate.typeParameters) { var typeArgumentTypes = void 0; if (typeArguments) { - typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNode); + typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); } else { inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); - typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; typeArgumentTypes = inferenceContext.inferredTypes; + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; } if (!typeArgumentsAreValid) { break; @@ -31578,16 +32380,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 226: - case 197: + case 228: + case 198: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 144: + case 145: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 147: + case 148: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 149: - case 151: + case 150: case 152: + case 153: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -31612,16 +32414,42 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray, headMessage); } + function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray) { + ts.Debug.assert(!(elementType.flags & 65536)); + var callSignature = resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray); + return callSignature; + } + function resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray) { + if (elementType.flags & 65536) { + var types = elementType.types; + var result = void 0; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; + result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); + } + return result; + } + var callSignatures = elementType && getSignaturesOfType(elementType, 0); + if (callSignatures && callSignatures.length > 0) { + var callSignature = void 0; + callSignature = resolveCall(openingLikeElement, callSignatures, candidatesOutArray); + return callSignature; + } + return undefined; + } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 179: - return resolveCallExpression(node, candidatesOutArray); case 180: - return resolveNewExpression(node, candidatesOutArray); + return resolveCallExpression(node, candidatesOutArray); case 181: + return resolveNewExpression(node, candidatesOutArray); + case 182: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 145: + case 146: return resolveDecorator(node, candidatesOutArray); + case 250: + case 249: + return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); } @@ -31652,12 +32480,12 @@ var ts; if (node.expression.kind === 96) { return voidType; } - if (node.kind === 180) { + if (node.kind === 181) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 150 && - declaration.kind !== 154 && - declaration.kind !== 159 && + declaration.kind !== 151 && + declaration.kind !== 155 && + declaration.kind !== 160 && !ts.isJSDocConstructSignature(declaration)) { var funcSymbol = node.expression.kind === 70 ? getResolvedSymbol(node.expression) : @@ -31688,9 +32516,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 225 + ? 227 : resolvedRequire.flags & 3 - ? 223 + ? 225 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -31716,6 +32544,23 @@ var ts; function checkNonNullAssertion(node) { return getNonNullableType(checkExpression(node.expression)); } + function checkMetaProperty(node) { + checkGrammarMetaProperty(node); + ts.Debug.assert(node.keywordToken === 93 && node.name.text === "target", "Unrecognized meta-property."); + var container = ts.getNewTargetContainer(node); + if (!container) { + error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); + return unknownType; + } + else if (container.kind === 151) { + var symbol = getSymbolOfNode(container.parent); + return getTypeOfSymbol(symbol); + } + else { + var symbol = getSymbolOfNode(container); + return getTypeOfSymbol(symbol); + } + } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks) { @@ -31745,7 +32590,7 @@ var ts; var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { if (!parameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + signature.thisParameter = createSymbolWithType(context.thisParameter, undefined); } assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } @@ -31783,8 +32628,8 @@ var ts; if (!links.type) { links.type = instantiateType(contextualType, mapper); if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 172 || - parameter.valueDeclaration.name.kind === 173)) { + (parameter.valueDeclaration.name.kind === 173 || + parameter.valueDeclaration.name.kind === 174)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -31814,6 +32659,9 @@ var ts; error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } + else if (!getGlobalPromiseConstructorSymbol()) { + error(func, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } return promiseType; } function getReturnTypeFromBody(func, contextualMapper) { @@ -31823,7 +32671,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 204) { + if (func.body.kind !== 206) { 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); @@ -31902,7 +32750,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 218 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 220 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -31931,7 +32779,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 184 || func.kind === 185)) { + func.kind === 185 || func.kind === 186)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -31948,7 +32796,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 204 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 206 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -31975,9 +32823,9 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 184) { + if (!hasGrammarError && node.kind === 185) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -32011,14 +32859,15 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 149) { + if (produceDiagnostics && node.kind !== 150) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -32028,7 +32877,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 204) { + if (node.body.kind === 206) { checkSourceElement(node.body); } else { @@ -32054,19 +32903,19 @@ var ts; return true; } function isReadonlySymbol(symbol) { - return symbol.isReadonly || - symbol.flags & 4 && (getDeclarationModifierFlagsFromSymbol(symbol) & 64) !== 0 || - symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 || + return !!(getCheckFlags(symbol) & 4 || + symbol.flags & 4 && getDeclarationModifierFlagsFromSymbol(symbol) & 64 || + symbol.flags & 3 && getDeclarationNodeFlagsFromSymbol(symbol) & 2 || symbol.flags & 98304 && !(symbol.flags & 65536) || - (symbol.flags & 8) !== 0; + symbol.flags & 8); } function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 177 || expr.kind === 178) && + (expr.kind === 178 || expr.kind === 179) && expr.expression.kind === 98) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 150)) + if (!(func && func.kind === 151)) return true; return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); } @@ -32075,13 +32924,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 177 || expr.kind === 178) { + if (expr.kind === 178 || expr.kind === 179) { var node = ts.skipParentheses(expr.expression); if (node.kind === 70) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 237; + return declaration && declaration.kind === 239; } } } @@ -32089,7 +32938,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage) { var node = ts.skipParentheses(expr); - if (node.kind !== 70 && node.kind !== 177 && node.kind !== 178) { + if (node.kind !== 70 && node.kind !== 178 && node.kind !== 179) { error(expr, invalidReferenceMessage); return false; } @@ -32097,11 +32946,21 @@ var ts; } function checkDeleteExpression(node) { checkExpression(node.expression); + var expr = ts.skipParentheses(node.expression); + if (expr.kind !== 178 && expr.kind !== 179) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); + return booleanType; + } + var links = getNodeLinks(expr); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol && isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } return booleanType; } function checkTypeOfExpression(node) { checkExpression(node.expression); - return stringType; + return typeofType; } function checkVoidExpression(node) { checkExpression(node.expression); @@ -32131,6 +32990,7 @@ var ts; case 36: case 37: case 51: + checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 512)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } @@ -32142,7 +33002,7 @@ var ts; booleanType; case 42: case 43: - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); } @@ -32155,7 +33015,7 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); } @@ -32167,8 +33027,8 @@ var ts; } if (type.flags & 196608) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -32182,8 +33042,8 @@ var ts; } if (type.flags & 65536) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var t = types_19[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -32192,8 +33052,8 @@ var ts; } if (type.flags & 131072) { var types = type.types; - for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { - var t = types_17[_a]; + for (var _a = 0, types_20 = types; _a < types_20.length; _a++) { + var t = types_20[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -32214,7 +33074,10 @@ var ts; if (isTypeOfKind(leftType, 8190)) { 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))) { + if (!(isTypeAny(rightType) || + getSignaturesOfType(rightType, 0).length || + getSignaturesOfType(rightType, 1).length || + 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; @@ -32223,6 +33086,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 340 | 512))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } @@ -32240,22 +33105,22 @@ var ts; return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 257 || property.kind === 258) { - var name_22 = property.name; - if (name_22.kind === 142) { - checkComputedPropertyName(name_22); + if (property.kind === 260 || property.kind === 261) { + var name = property.name; + if (name.kind === 143) { + checkComputedPropertyName(name); } - if (isComputedNonLiteralName(name_22)) { + if (isComputedNonLiteralName(name)) { return undefined; } - var text = ts.getTextOfPropertyName(name_22); + var text = ts.getTextOfPropertyName(name); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 258) { + if (property.kind === 261) { return checkDestructuringAssignment(property, type); } else { @@ -32263,10 +33128,10 @@ var ts; } } else { - error(name_22, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_22)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 259) { + else if (property.kind === 262) { if (languageVersion < 5) { checkExternalEmitHelpers(property, 4); } @@ -32294,8 +33159,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 198) { - if (element.kind !== 196) { + if (element.kind !== 199) { + if (element.kind !== 197) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -32321,7 +33186,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 192 && restExpression.operatorToken.kind === 57) { + if (restExpression.kind === 193 && restExpression.operatorToken.kind === 57) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -32334,7 +33199,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 258) { + if (exprOrAssignment.kind === 261) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -32348,21 +33213,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 192 && target.operatorToken.kind === 57) { + if (target.kind === 193 && target.operatorToken.kind === 57) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 176) { + if (target.kind === 177) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 175) { + if (target.kind === 176) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 259 ? + var error = target.parent.kind === 262 ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -32376,35 +33241,35 @@ var ts; case 70: case 9: case 11: - case 181: - case 194: + case 182: + case 195: case 12: case 8: case 100: case 85: case 94: - case 137: - case 184: - case 197: + case 138: case 185: - case 175: + case 198: + case 186: case 176: - case 187: - case 201: - case 247: - case 246: + case 177: + case 188: + case 202: + case 249: + case 248: return true; - case 193: + case 194: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 192: + case 193: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 190: case 191: + case 192: switch (node.operator) { case 50: case 36: @@ -32413,9 +33278,9 @@ var ts; return true; } return false; - case 188: - case 182: - case 200: + case 189: + case 183: + case 201: default: return false; } @@ -32435,7 +33300,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 57 && (left.kind === 176 || left.kind === 175)) { + if (operator === 57 && (left.kind === 177 || left.kind === 176)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -32466,12 +33331,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (leftType.flags & 6144) - leftType = rightType; - if (rightType.flags & 6144) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); var suggestedOperator = void 0; if ((leftType.flags & 136) && (rightType.flags & 136) && @@ -32491,12 +33352,10 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (leftType.flags & 6144) - leftType = rightType; - if (rightType.flags & 6144) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + if (!isTypeOfKind(leftType, 1 | 262178) && !isTypeOfKind(rightType, 1 | 262178)) { + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); + } var resultType = void 0; if (isTypeOfKind(leftType, 340) && isTypeOfKind(rightType, 340)) { resultType = numberType; @@ -32525,8 +33384,8 @@ var ts; case 29: case 30: if (checkForDisallowedESSymbolOperand(operator)) { - leftType = getBaseTypeOfLiteralType(leftType); - rightType = getBaseTypeOfLiteralType(rightType); + leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); + rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } @@ -32695,7 +33554,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 182 || node.kind === 200; + return node.kind === 183 || node.kind === 201; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -32706,11 +33565,11 @@ var ts; function isLiteralContextualType(contextualType) { if (contextualType) { if (contextualType.flags & 540672) { - var apparentType = getApparentTypeOfTypeVariable(contextualType); - if (apparentType.flags & (2 | 4 | 8 | 16)) { + var constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; + if (constraint.flags & (2 | 4 | 8 | 16)) { return true; } - contextualType = apparentType; + contextualType = constraint; } return maybeTypeOfKind(contextualType, (480 | 262144)); } @@ -32721,14 +33580,14 @@ var ts; return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -32750,7 +33609,7 @@ var ts; return type; } function getTypeOfExpression(node) { - if (node.kind === 179 && node.expression.kind !== 96) { + if (node.kind === 180 && node.expression.kind !== 96) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -32761,7 +33620,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 141) { + if (node.kind === 142) { type = checkQualifiedName(node); } else { @@ -32769,9 +33628,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 177 && node.parent.expression === node) || - (node.parent.kind === 178 && node.parent.expression === node) || - ((node.kind === 70 || node.kind === 141) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 178 && node.parent.expression === node) || + (node.parent.kind === 179 && node.parent.expression === node) || + ((node.kind === 70 || node.kind === 142) && 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); } @@ -32793,66 +33652,70 @@ var ts; case 100: case 85: return checkLiteralExpression(node); - case 194: + case 195: return checkTemplateExpression(node); case 12: return stringType; case 11: return globalRegExpType; - case 175: - return checkArrayLiteral(node, contextualMapper); case 176: - return checkObjectLiteral(node, contextualMapper); + return checkArrayLiteral(node, contextualMapper); case 177: - return checkPropertyAccessExpression(node); + return checkObjectLiteral(node, contextualMapper); case 178: - return checkIndexedAccess(node); + return checkPropertyAccessExpression(node); case 179: + return checkIndexedAccess(node); case 180: - return checkCallExpression(node); case 181: - return checkTaggedTemplateExpression(node); - case 183: - return checkExpression(node.expression, contextualMapper); - case 197: - return checkClassExpression(node); - case 184: - case 185: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 187: - return checkTypeOfExpression(node); + return checkCallExpression(node); case 182: - case 200: - return checkAssertion(node); - case 201: - return checkNonNullAssertion(node); - case 186: - return checkDeleteExpression(node); - case 188: - return checkVoidExpression(node); - case 189: - return checkAwaitExpression(node); - case 190: - return checkPrefixUnaryExpression(node); - case 191: - return checkPostfixUnaryExpression(node); - case 192: - return checkBinaryExpression(node, contextualMapper); - case 193: - return checkConditionalExpression(node, contextualMapper); - case 196: - return checkSpreadExpression(node, contextualMapper); + return checkTaggedTemplateExpression(node); + case 184: + return checkExpression(node.expression, contextualMapper); case 198: + return checkClassExpression(node); + case 185: + case 186: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 188: + return checkTypeOfExpression(node); + case 183: + case 201: + return checkAssertion(node); + case 202: + return checkNonNullAssertion(node); + case 203: + return checkMetaProperty(node); + case 187: + return checkDeleteExpression(node); + case 189: + return checkVoidExpression(node); + case 190: + return checkAwaitExpression(node); + case 191: + return checkPrefixUnaryExpression(node); + case 192: + return checkPostfixUnaryExpression(node); + case 193: + return checkBinaryExpression(node, contextualMapper); + case 194: + return checkConditionalExpression(node, contextualMapper); + case 197: + return checkSpreadExpression(node, contextualMapper); + case 199: return undefinedWideningType; - case 195: + case 196: return checkYieldExpression(node); - case 252: - return checkJsxExpression(node); - case 246: - return checkJsxElement(node); - case 247: - return checkJsxSelfClosingElement(node); + case 255: + return checkJsxExpression(node, contextualMapper); case 248: + return checkJsxElement(node); + case 249: + return checkJsxSelfClosingElement(node); + case 253: + return checkJsxAttributes(node, contextualMapper); + case 250: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -32862,7 +33725,16 @@ var ts; grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); } checkSourceElement(node.constraint); - getConstraintOfTypeParameter(getDeclaredTypeOfTypeParameter(getSymbolOfNode(node))); + checkSourceElement(node.default); + var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); + if (!hasNonCircularBaseConstraint(typeParameter)) { + error(node.constraint, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); + } + var constraintType = getConstraintOfTypeParameter(typeParameter); + var defaultType = getDefaultFromTypeParameter(typeParameter); + if (constraintType && defaultType) { + checkTypeAssignableTo(defaultType, getTypeWithThisArgument(constraintType, defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } @@ -32873,7 +33745,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92) { func = ts.getContainingFunction(node); - if (!(func.kind === 150 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 151 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -32884,7 +33756,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 150 || func.kind === 154 || func.kind === 159) { + if (func.kind === 151 || func.kind === 155 || func.kind === 160) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -32896,9 +33768,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 149 || - node.kind === 225 || - node.kind === 184; + return node.kind === 150 || + node.kind === 227 || + node.kind === 185; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -32939,9 +33811,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_23 = _a[_i].name; - if (ts.isBindingPattern(name_23) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_23, parameterName, typePredicate.parameterName)) { + var name = _a[_i].name; + if (ts.isBindingPattern(name) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -32954,16 +33826,16 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 186: + case 154: + case 227: case 185: - case 153: - case 225: - case 184: - case 158: + case 159: + case 150: case 149: - case 148: - var parent_9 = node.parent; - if (node === parent_9.type) { - return parent_9; + var parent = node.parent; + if (node === parent.type) { + return parent; } } } @@ -32973,27 +33845,27 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_24 = element.name; - if (name_24.kind === 70 && - name_24.text === predicateVariableName) { + var name = element.name; + if (name.kind === 70 && + name.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_24.kind === 173 || - name_24.kind === 172) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_24, predicateVariableNode, predicateVariableName)) { + else if (name.kind === 174 || + name.kind === 173) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } } } } function checkSignatureDeclaration(node) { - if (node.kind === 155) { + if (node.kind === 156) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 || node.kind === 225 || node.kind === 159 || - node.kind === 153 || node.kind === 150 || - node.kind === 154) { + else if (node.kind === 159 || node.kind === 227 || node.kind === 160 || + node.kind === 154 || node.kind === 151 || + node.kind === 155) { checkGrammarFunctionLikeDeclaration(node); } if (ts.isAsyncFunctionLike(node) && languageVersion < 4) { @@ -33011,10 +33883,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 154: + case 155: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 153: + case 154: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -33041,11 +33913,18 @@ var ts; } } function checkClassForDuplicateDeclarations(node) { + var Declaration; + (function (Declaration) { + Declaration[Declaration["Getter"] = 1] = "Getter"; + Declaration[Declaration["Setter"] = 2] = "Setter"; + Declaration[Declaration["Method"] = 4] = "Method"; + Declaration[Declaration["Property"] = 3] = "Property"; + })(Declaration || (Declaration = {})); var instanceNames = ts.createMap(); var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150) { + if (member.kind === 151) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -33054,36 +33933,65 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114; }); + var isStatic = ts.getModifierFlags(member) & 32; var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 151: + case 152: addName(names, member.name, memberName, 1); break; - case 152: + case 153: addName(names, member.name, memberName, 2); break; - case 147: + case 148: addName(names, member.name, memberName, 3); break; + case 150: + addName(names, member.name, memberName, 4); + break; } } } } function addName(names, location, name, meaning) { - var prev = names[name]; + var prev = names.get(name); if (prev) { - if (prev & meaning) { + if (prev & 4) { + if (meaning !== 4) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + } + else if (prev & meaning) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { - names[name] = prev | meaning; + names.set(name, prev | meaning); } } else { - names[name] = meaning; + names.set(name, meaning); + } + } + } + function checkClassForStaticPropertyNameConflicts(node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + var memberNameNode = member.name; + var isStatic = ts.getModifierFlags(member) & 32; + if (isStatic && memberNameNode) { + var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode); + switch (memberName) { + case "name": + case "length": + case "caller": + case "arguments": + case "prototype": + var message = ts.Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1; + var className = getNameOfSymbol(getSymbolOfNode(node)); + error(memberNameNode, message, memberName, className); + break; + } } } } @@ -33091,7 +33999,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 146) { + if (member.kind == 147) { var memberName = void 0; switch (member.name.kind) { case 9: @@ -33102,18 +34010,18 @@ var ts; default: continue; } - if (names[memberName]) { + if (names.get(memberName)) { error(member.symbol.valueDeclaration.name, ts.Diagnostics.Duplicate_identifier_0, memberName); error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName); } else { - names[memberName] = true; + names.set(memberName, true); } } } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 227) { + if (node.kind === 229) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -33128,7 +34036,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 134: + case 135: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -33195,12 +34103,12 @@ var ts; if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 && n.kind !== 225) { + else if (n.kind !== 185 && n.kind !== 227) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 147 && + return n.kind === 148 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -33220,7 +34128,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -33243,18 +34151,18 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 151) { + if (node.kind === 152) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 151 ? 152 : 151; + var otherKind = node.kind === 152 ? 153 : 152; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { @@ -33268,11 +34176,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 151) { + if (node.kind === 152) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 176) { + if (node.parent.kind !== 177) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -33295,6 +34203,7 @@ var ts; checkDecorators(node); } function checkTypeArgumentConstraints(typeParameters, typeArgumentNodes) { + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); var typeArguments; var mapper; var result = true; @@ -33302,7 +34211,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -33353,25 +34262,42 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessIndexType(type, accessNode) { + if (!(type.flags & 524288)) { + return type; + } + var objectType = type.objectType; + var indexType = type.indexType; + if (isTypeAssignableTo(indexType, getIndexType(objectType))) { + return type; + } + if (maybeTypeOfKind(objectType, 540672) && isTypeOfKind(indexType, 340)) { + var constraint = getBaseConstraintOfType(objectType); + if (constraint && getIndexInfoOfType(constraint, 1)) { + return type; + } + } + error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); + return type; + } function checkIndexedAccessType(node) { - getTypeFromIndexedAccessTypeNode(node); + checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node) { checkSourceElement(node.typeParameter); checkSourceElement(node.type); var type = getTypeFromMappedTypeNode(node); var constraintType = getConstraintTypeFromMappedType(type); - var keyType = constraintType.flags & 540672 ? getApparentTypeOfTypeVariable(constraintType) : constraintType; - checkTypeAssignableTo(keyType, stringType, node.typeParameter.constraint); + checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node) { return (ts.getModifierFlags(node) & 8) && ts.isInAmbientContext(node); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 227 && - n.parent.kind !== 226 && - n.parent.kind !== 197 && + if (n.parent.kind !== 229 && + n.parent.kind !== 228 && + n.parent.kind !== 198 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -33448,7 +34374,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 149 || node.kind === 148) && + var reportError = (node.kind === 150 || node.kind === 149) && (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); if (reportError) { var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -33477,15 +34403,15 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var current = declarations_4[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var current = declarations_5[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 227 || node.parent.kind === 161 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 229 || node.parent.kind === 162 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 225 || node.kind === 149 || node.kind === 148 || node.kind === 150) { + if (node.kind === 227 || node.kind === 150 || node.kind === 149 || node.kind === 151) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -33596,16 +34522,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 227: + case 229: return 2097152; - case 230: + case 232: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 226: - case 229: + case 228: + case 231: return 2097152 | 1048576; - case 234: + case 236: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -33617,7 +34543,8 @@ var ts; } function checkNonThenableType(type, location, message) { type = getWidenedType(type); - if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + var apparentType = getApparentType(type); + if ((apparentType.flags & (1 | 8192)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -33722,7 +34649,12 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455, true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; if (promiseConstructorType === unknownType) { - error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + if (promiseConstructorName.kind === 70 && promiseConstructorName.text === "Promise" && getTargetType(returnType) === tryGetGlobalPromiseType()) { + error(node.type, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } + else { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + } return unknownType; } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); @@ -33752,22 +34684,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 226: + case 228: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 144: + case 145: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 147: + case 148: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 149: - case 151: + case 150: case 152: + case 153: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -33801,13 +34733,13 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8); - if (node.kind === 144) { + if (node.kind === 145) { checkExternalEmitHelpers(firstDecorator, 32); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 226: + case 228: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -33816,19 +34748,19 @@ var ts; } } break; - case 149: - case 151: + case 150: case 152: + case 153: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markTypeNodeAsReferenced(node.type); break; - case 147: + case 148: markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); break; - case 144: + case 145: markTypeNodeAsReferenced(node.type); break; } @@ -33840,6 +34772,7 @@ var ts; checkFunctionOrMethodDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -33848,7 +34781,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 142) { + if (node.name && node.name.kind === 143) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -33890,43 +34823,43 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 261: - case 230: + case 264: + case 232: checkUnusedModuleMembers(node); break; - case 226: - case 197: + case 228: + case 198: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 227: + case 229: checkUnusedTypeParameters(node); break; - case 204: - case 232: - case 211: - case 212: + case 206: + case 234: case 213: + case 214: + case 215: checkUnusedLocalsAndParameters(node); break; - case 150: - case 184: - case 225: - case 185: - case 149: case 151: + case 185: + case 227: + case 186: + case 150: case 152: + case 153: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 148: - case 153: + case 149: case 154: case 155: - case 158: + case 156: case 159: + case 160: checkUnusedTypeParameters(node); break; } @@ -33935,11 +34868,10 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 227 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_2 = function (key) { - var local = node.locals[key]; + if (node.parent.kind !== 229 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + node.locals.forEach(function (local) { if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 145) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -33952,10 +34884,7 @@ var ts; ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d.name || d, local.name); }); } } - }; - for (var key in node.locals) { - _loop_2(key); - } + }); } } function isRemovedPropertyFromObjectSpread(node) { @@ -33968,9 +34897,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 223 && - (declaration.parent.parent.kind === 212 || - declaration.parent.parent.kind === 213)) { + if (declaration.kind === 225 && + (declaration.parent.parent.kind === 214 || + declaration.parent.parent.kind === 215)) { return; } } @@ -33989,12 +34918,12 @@ var ts; if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149 || member.kind === 147) { + if (member.kind === 150 || member.kind === 148) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 150) { + else if (member.kind === 151) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { @@ -34025,21 +34954,20 @@ var ts; } function checkUnusedModuleMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { - for (var key in node.locals) { - var local = node.locals[key]; + node.locals.forEach(function (local) { if (!local.isReferenced && !local.exportSymbol) { for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - error(declaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + errorUnusedLocal(declaration.name, local.name); } } } - } + }); } } function checkBlock(node) { - if (node.kind === 204) { + if (node.kind === 206) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -34061,19 +34989,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 147 || - node.kind === 146 || + if (node.kind === 148 || + node.kind === 147 || + node.kind === 150 || node.kind === 149 || - node.kind === 148 || - node.kind === 151 || - node.kind === 152) { + node.kind === 152 || + node.kind === 153) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 144 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 145 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -34083,6 +35011,11 @@ var ts; potentialThisCollisions.push(node); } } + function checkCollisionWithCapturedNewTargetVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_newTarget")) { + potentialNewTargetCollisions.push(node); + } + } function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; while (current) { @@ -34099,6 +35032,22 @@ var ts; current = current.parent; } } + function checkIfNewTargetIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 8) { + var isDeclaration_2 = node.kind !== 70; + if (isDeclaration_2) { + error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); + } + return; + } + current = current.parent; + } + } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; @@ -34108,8 +35057,8 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 70; - if (isDeclaration_2) { + var isDeclaration_3 = node.kind !== 70; + if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } else { @@ -34124,11 +35073,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 232 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 264 && 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)); } } @@ -34136,11 +35085,11 @@ var ts; if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 232 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 264 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -34148,7 +35097,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 223 && !node.initializer) { + if (node.kind === 225 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -34158,25 +35107,25 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 224); - var container = varDeclList.parent.kind === 205 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 226); + var container = varDeclList.parent.kind === 207 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 204 && ts.isFunctionLike(container.parent) || - container.kind === 231 || - container.kind === 230 || - container.kind === 261); + (container.kind === 206 && ts.isFunctionLike(container.parent) || + container.kind === 233 || + container.kind === 232 || + container.kind === 264); if (!namesShareScope) { - var name_25 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_25, name_25); + var name = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 144) { + if (ts.getRootDeclaration(node).kind !== 145) { return; } var func = ts.getContainingFunction(node); @@ -34185,7 +35134,7 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 177) { + if (n.kind === 178) { return visit(n.expression); } else if (n.kind === 70) { @@ -34199,7 +35148,8 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144) { + if (symbol.valueDeclaration.kind === 145 || + symbol.valueDeclaration.kind === 175) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -34208,7 +35158,7 @@ var ts; if (ts.isFunctionLike(current.parent)) { return; } - if (current.parent.kind === 147 && + if (current.parent.kind === 148 && !(ts.hasModifier(current.parent, 32)) && ts.isClassLike(current.parent.parent)) { return; @@ -34230,37 +35180,37 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 174) { - if (node.parent.kind === 172 && languageVersion < 5) { + if (node.kind === 175) { + if (node.parent.kind === 173 && languageVersion < 5 && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4); } - if (node.propertyName && node.propertyName.kind === 142) { + if (node.propertyName && node.propertyName.kind === 143) { checkComputedPropertyName(node.propertyName); } - var parent_10 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_10); - var name_26 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_26)); + var parent = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent); + var name = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); markPropertyAsReferenced(property); - if (parent_10.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_10, parent_10.initializer, parentType, property); + if (parent.initializer && property) { + checkPropertyAccessibility(parent, parent.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 144 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 145 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 212) { + if (node.initializer && node.parent.parent.kind !== 214) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -34269,7 +35219,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 212) { + if (node.initializer && node.parent.parent.kind !== 214) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -34287,20 +35237,21 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 147 && node.kind !== 146) { + if (node.kind !== 148 && node.kind !== 147) { checkExportsOnMergedDeclarations(node); - if (node.kind === 223 || node.kind === 174) { + if (node.kind === 225 || node.kind === 175) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 && right.kind === 223) || - (left.kind === 223 && right.kind === 144)) { + if ((left.kind === 145 && right.kind === 225) || + (left.kind === 225 && right.kind === 145)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -34327,7 +35278,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 176) { + if (node.modifiers && node.parent.kind === 177) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -34346,7 +35297,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 206) { + if (node.thenStatement.kind === 208) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -34363,12 +35314,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 224) { + if (node.initializer && node.initializer.kind === 226) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 224) { + if (node.initializer.kind === 226) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -34386,13 +35337,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 224) { + if (node.initializer.kind === 226) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 175 || varExpr.kind === 176) { + if (varExpr.kind === 176 || varExpr.kind === 177) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -34411,7 +35362,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 224) { + if (node.initializer.kind === 226) { 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); @@ -34421,7 +35372,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 175 || varExpr.kind === 176) { + if (varExpr.kind === 176 || varExpr.kind === 177) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -34597,7 +35548,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 151 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 152))); + return !!(node.kind === 152 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 153))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -34619,30 +35570,30 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 152) { + if (func.kind === 153) { if (node.expression) { - error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); + error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 150) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { - error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); + else if (func.kind === 151) { + if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node.expression || node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); if (promisedType) { - checkTypeAssignableTo(awaitedType, promisedType, node.expression || node); + checkTypeAssignableTo(awaitedType, promisedType, node); } } else { - checkTypeAssignableTo(exprType, returnType, node.expression || node); + checkTypeAssignableTo(exprType, returnType, node); } } } - else if (func.kind !== 150 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 151 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -34668,7 +35619,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 254 && !hasDuplicateDefaultClause) { + if (clause.kind === 257 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -34680,7 +35631,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 253) { + if (produceDiagnostics && clause.kind === 256) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); var caseIsLiteral = isLiteralType(caseType); @@ -34706,7 +35657,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 219 && current.label.text === node.label.text) { + if (current.kind === 221 && 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; @@ -34739,14 +35690,14 @@ var ts; grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { - var blockLocals = catchClause.block.locals; - if (blockLocals) { - for (var caughtName in catchClause.locals) { - var blockLocal = blockLocals[caughtName]; + var blockLocals_1 = catchClause.block.locals; + if (blockLocals_1) { + ts.forEachKey(catchClause.locals, function (caughtName) { + var blockLocal = blockLocals_1.get(caughtName); if (blockLocal && (blockLocal.flags & 2) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } - } + }); } } } @@ -34794,12 +35745,13 @@ var ts; if (!indexType) { return; } - if (indexKind === 1 && !isNumericName(prop.valueDeclaration.name)) { + var propDeclaration = prop.valueDeclaration; + if (indexKind === 1 && !(propDeclaration ? isNumericName(propDeclaration.name) : isNumericLiteralName(prop.name))) { return; } var errorNode; - if (prop.valueDeclaration.name.kind === 142 || prop.parent === containingType.symbol) { - errorNode = prop.valueDeclaration; + if (propDeclaration && (propDeclaration.name.kind === 143 || prop.parent === containingType.symbol)) { + errorNode = propDeclaration; } else if (indexDeclaration) { errorNode = indexDeclaration; @@ -34824,15 +35776,23 @@ var ts; case "string": case "symbol": case "void": + case "object": error(name, message, name.text); } } function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + var seenDefault = false; + for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { + if (node.default) { + seenDefault = true; + } + else if (seenDefault) { + error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters); + } 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)); @@ -34842,23 +35802,57 @@ var ts; } } } - function checkTypeParameterListsIdentical(node, symbol) { + function checkTypeParameterListsIdentical(symbol) { if (symbol.declarations.length === 1) { return; } - var firstDecl; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 226 || declaration.kind === 227) { - if (!firstDecl) { - firstDecl = declaration; - } - else if (!areTypeParametersIdentical(firstDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); + var links = getSymbolLinks(symbol); + if (!links.typeParametersChecked) { + links.typeParametersChecked = true; + var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); + if (declarations.length <= 1) { + return; + } + var type = getDeclaredTypeOfSymbol(symbol); + if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { + var name = symbolToString(symbol); + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; + error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } } } + function areTypeParametersIdentical(declarations, typeParameters) { + var maxTypeArgumentCount = ts.length(typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; + var numTypeParameters = ts.length(declaration.typeParameters); + if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { + return false; + } + for (var i = 0; i < numTypeParameters; i++) { + var source = declaration.typeParameters[i]; + var target = typeParameters[i]; + if (source.name.text !== target.symbol.name) { + return false; + } + var sourceConstraint = source.constraint && getTypeFromTypeNode(source.constraint); + var targetConstraint = getConstraintFromTypeParameter(target); + if ((sourceConstraint || targetConstraint) && + (!sourceConstraint || !targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint))) { + return false; + } + var sourceDefault = source.default && getTypeFromTypeNode(source.default); + var targetDefault = getDefaultFromTypeParameter(target); + if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) { + return false; + } + } + } + return true; + } function checkClassExpression(node) { checkClassLikeDeclaration(node); checkNodeDeferred(node); @@ -34882,6 +35876,7 @@ var ts; if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -34891,8 +35886,11 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); - checkTypeParameterListsIdentical(node, symbol); + checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); + if (!ts.isInAmbientContext(node)) { + checkClassForStaticPropertyNameConflicts(node); + } var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { if (languageVersion < 2 && !ts.isInAmbientContext(node)) { @@ -34901,7 +35899,8 @@ var ts; var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType_1 = baseTypes[0]; - var staticBaseType = getBaseConstructorTypeOfClass(type); + var baseConstructorType = getBaseConstructorTypeOfClass(type); + var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { @@ -34915,14 +35914,17 @@ var ts; } checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType_1, 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 (baseType_1.symbol.valueDeclaration && + if (baseConstructorType.flags & 540672 && !isMixinConstructorType(staticType)) { + error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); + } + if (baseType_1.symbol && baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 226) { + baseType_1.symbol.valueDeclaration.kind === 228) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 540672)) { var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType_1; })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); @@ -34942,8 +35944,7 @@ var ts; if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - var declaredType = getObjectFlags(t) & 4 ? t.target : t; - if (getObjectFlags(declaredType) & 3) { + if (isValidBaseType(t)) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { @@ -34971,17 +35972,22 @@ var ts; } } function getTargetSymbol(s) { - return s.flags & 16777216 ? getSymbolLinks(s).target : s; + return getCheckFlags(s) & 1 ? s.target : s; } function getClassLikeDeclarationOfSymbol(symbol) { return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); } + function getClassOrInterfaceDeclarationsOfSymbol(symbol) { + return ts.filter(symbol.declarations, function (d) { + return d.kind === 228 || d.kind === 229; + }); + } function checkKindsOfPropertyMemberOverrides(type, baseType) { - var baseProperties = getPropertiesOfObjectType(baseType); + var baseProperties = getPropertiesOfType(baseType); 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) { + if (base.flags & 16777216) { continue; } var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); @@ -34991,7 +35997,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { - if (derivedClassDecl.kind === 197) { + if (derivedClassDecl.kind === 198) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -35035,32 +36041,7 @@ var ts; } } function isAccessor(kind) { - return kind === 151 || kind === 152; - } - 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; + return kind === 152 || kind === 153; } function checkInheritedPropertiesAreIdentical(type, typeNode) { var baseTypes = getBaseTypes(type); @@ -35068,16 +36049,16 @@ var ts; return true; } var seen = ts.createMap(); - ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.name, { prop: p, containingType: type }); }); var ok = true; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; - var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); + var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { var prop = properties_7[_a]; - var existing = seen[prop.name]; + var existing = seen.get(prop.name); if (!existing) { - seen[prop.name] = { prop: prop, containingType: base }; + seen.set(prop.name, { prop: prop, containingType: base }); } else { var isInheritedProperty = existing.containingType !== type; @@ -35101,8 +36082,8 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 227); + checkTypeParameterListsIdentical(symbol); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 229); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -35198,7 +36179,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 190: + case 191: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -35209,7 +36190,7 @@ var ts; case 51: return ~value_1; } return undefined; - case 192: + case 193: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -35233,12 +36214,13 @@ var ts; } return undefined; case 8: + checkGrammarNumericLiteral(e); return +e.text; - case 183: + case 184: return evalConstant(e.expression); case 70: + case 179: case 178: - case 177: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -35249,7 +36231,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 178) { + if (e.kind === 179) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -35266,7 +36248,7 @@ var ts; if (current.kind === 70) { break; } - else if (current.kind === 177) { + else if (current.kind === 178) { current = current.expression; } else { @@ -35306,6 +36288,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); @@ -35326,7 +36309,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 229) { + if (declaration.kind !== 231) { return false; } var enumDeclaration = declaration; @@ -35347,10 +36330,10 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var declaration = declarations_5[_i]; - if ((declaration.kind === 226 || - (declaration.kind === 225 && ts.nodeIsPresent(declaration.body))) && + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 228 || + (declaration.kind === 227 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -35409,7 +36392,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, 226); + var mergedClass = ts.getDeclarationOfKind(symbol, 228); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -35417,7 +36400,7 @@ var ts; } if (isAmbientExternalModule) { if (ts.isExternalModuleAugmentation(node)) { - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 134217728); if (checkBody && node.body) { for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { var statement = _a[_i]; @@ -35452,42 +36435,42 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 205: + case 207: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 240: - case 241: + case 242: + case 243: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 234: - case 235: + case 236: + case 237: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 174: - case 223: - var name_27 = node.name; - if (ts.isBindingPattern(name_27)) { - for (var _b = 0, _c = name_27.elements; _b < _c.length; _b++) { + case 175: + case 225: + var name = node.name; + if (ts.isBindingPattern(name)) { + for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } - case 226: - case 229: - case 225: - case 227: - case 230: case 228: + case 231: + case 227: + case 229: + case 232: + case 230: if (isGlobalAugmentation) { return; } var symbol = getSymbolOfNode(node); if (symbol) { - var reportError = !(symbol.flags & 33554432); + var reportError = !(symbol.flags & 134217728); if (!reportError) { reportError = ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } @@ -35499,12 +36482,12 @@ var ts; switch (node.kind) { case 70: return node; - case 141: + case 142: do { node = node.left; } while (node.kind !== 70); return node; - case 177: + case 178: do { node = node.expression; } while (node.kind !== 70); @@ -35517,9 +36500,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 231 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 && !inAmbientExternalModule) { - error(moduleName, node.kind === 241 ? + var inAmbientExternalModule = node.parent.kind === 233 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 264 && !inAmbientExternalModule) { + error(moduleName, node.kind === 243 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -35540,7 +36523,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 243 ? + var message = node.kind === 245 ? 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)); @@ -35567,7 +36550,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237) { + if (importClause.namedBindings.kind === 239) { checkImportBinding(importClause.namedBindings); } else { @@ -35618,8 +36601,10 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 231 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 233 && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 233 && + !node.moduleSpecifier && ts.isInAmbientContext(node); + if (node.parent.kind !== 264 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -35632,7 +36617,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 261 || node.parent.kind === 231 || node.parent.kind === 230; + var isInAppropriateContext = node.parent.kind === 264 || node.parent.kind === 233 || node.parent.kind === 232; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -35655,9 +36640,14 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 261 ? node.parent : node.parent.parent; - if (container.kind === 230 && !ts.isAmbientModule(container)) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + var container = node.parent.kind === 264 ? node.parent : node.parent.parent; + if (container.kind === 232 && !ts.isAmbientModule(container)) { + if (node.isExportEquals) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + } + else { + error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); + } return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { @@ -35680,18 +36670,13 @@ var ts; } } function hasExportedMembers(moduleSymbol) { - for (var id in moduleSymbol.exports) { - if (id !== "export=") { - return true; - } - } - return false; + return ts.forEachEntry(moduleSymbol.exports, function (_, id) { return id !== "export="; }); } function checkExternalModuleExports(node) { var moduleSymbol = getSymbolOfNode(node); var links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - var exportEqualsSymbol = moduleSymbol.exports["export="]; + var exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; if (!isTopLevelInExternalModuleAugmentation(declaration)) { @@ -35699,31 +36684,31 @@ var ts; } } var exports_1 = getExportsOfModule(moduleSymbol); - for (var id in exports_1) { + exports_1 && exports_1.forEach(function (_a, id) { + var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { - continue; + return; } - var _a = exports_1[id], declarations = _a.declarations, flags = _a.flags; if (flags & (1920 | 64 | 384)) { - continue; + return; } var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); if (flags & 524288 && exportedDeclarationsCount <= 2) { - continue; + return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, id)); } } } - } + }); links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 225 && declaration.kind !== 149) || + return (declaration.kind !== 227 && declaration.kind !== 150) || !!declaration.body; } } @@ -35734,123 +36719,123 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 230: - case 226: + case 232: + case 228: + case 229: case 227: - case 225: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 143: - return checkTypeParameter(node); case 144: + return checkTypeParameter(node); + case 145: return checkParameter(node); + case 148: case 147: - case 146: return checkPropertyDeclaration(node); - case 158: case 159: - case 153: + case 160: case 154: - return checkSignatureDeclaration(node); case 155: return checkSignatureDeclaration(node); - case 149: - case 148: - return checkMethodDeclaration(node); - case 150: - return checkConstructorDeclaration(node); - case 151: - case 152: - return checkAccessorDeclaration(node); - case 157: - return checkTypeReferenceNode(node); case 156: + return checkSignatureDeclaration(node); + case 150: + case 149: + return checkMethodDeclaration(node); + case 151: + return checkConstructorDeclaration(node); + case 152: + case 153: + return checkAccessorDeclaration(node); + case 158: + return checkTypeReferenceNode(node); + case 157: return checkTypePredicate(node); - case 160: - return checkTypeQuery(node); case 161: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 162: - return checkArrayType(node); + return checkTypeLiteral(node); case 163: - return checkTupleType(node); + return checkArrayType(node); case 164: + return checkTupleType(node); case 165: - return checkUnionOrIntersectionType(node); case 166: - case 168: - return checkSourceElement(node.type); + return checkUnionOrIntersectionType(node); + case 167: case 169: - return checkIndexedAccessType(node); + return checkSourceElement(node.type); case 170: + return checkIndexedAccessType(node); + case 171: return checkMappedType(node); - case 225: - return checkFunctionDeclaration(node); - case 204: - case 231: - return checkBlock(node); - case 205: - return checkVariableStatement(node); - case 207: - return checkExpressionStatement(node); - case 208: - return checkIfStatement(node); - case 209: - return checkDoStatement(node); - case 210: - return checkWhileStatement(node); - case 211: - return checkForStatement(node); - case 212: - return checkForInStatement(node); - case 213: - return checkForOfStatement(node); - case 214: - case 215: - return checkBreakOrContinueStatement(node); - case 216: - return checkReturnStatement(node); - case 217: - return checkWithStatement(node); - case 218: - return checkSwitchStatement(node); - case 219: - return checkLabeledStatement(node); - case 220: - return checkThrowStatement(node); - case 221: - return checkTryStatement(node); - case 223: - return checkVariableDeclaration(node); - case 174: - return checkBindingElement(node); - case 226: - return checkClassDeclaration(node); case 227: - return checkInterfaceDeclaration(node); - case 228: - return checkTypeAliasDeclaration(node); - case 229: - return checkEnumDeclaration(node); - case 230: - return checkModuleDeclaration(node); - case 235: - return checkImportDeclaration(node); - case 234: - return checkImportEqualsDeclaration(node); - case 241: - return checkExportDeclaration(node); - case 240: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); case 206: - checkGrammarStatementInAmbientContext(node); - return; + case 233: + return checkBlock(node); + case 207: + return checkVariableStatement(node); + case 209: + return checkExpressionStatement(node); + case 210: + return checkIfStatement(node); + case 211: + return checkDoStatement(node); + case 212: + return checkWhileStatement(node); + case 213: + return checkForStatement(node); + case 214: + return checkForInStatement(node); + case 215: + return checkForOfStatement(node); + case 216: + case 217: + return checkBreakOrContinueStatement(node); + case 218: + return checkReturnStatement(node); + case 219: + return checkWithStatement(node); + case 220: + return checkSwitchStatement(node); + case 221: + return checkLabeledStatement(node); case 222: + return checkThrowStatement(node); + case 223: + return checkTryStatement(node); + case 225: + return checkVariableDeclaration(node); + case 175: + return checkBindingElement(node); + case 228: + return checkClassDeclaration(node); + case 229: + return checkInterfaceDeclaration(node); + case 230: + return checkTypeAliasDeclaration(node); + case 231: + return checkEnumDeclaration(node); + case 232: + return checkModuleDeclaration(node); + case 237: + return checkImportDeclaration(node); + case 236: + return checkImportEqualsDeclaration(node); + case 243: + return checkExportDeclaration(node); + case 242: + return checkExportAssignment(node); + case 208: checkGrammarStatementInAmbientContext(node); return; - case 244: + case 224: + checkGrammarStatementInAmbientContext(node); + return; + case 246: return checkMissingDeclaration(node); } } @@ -35863,17 +36848,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 184: case 185: + case 186: + case 150: case 149: - case 148: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 151: case 152: + case 153: checkAccessorDeferred(node); break; - case 197: + case 198: checkClassExpressionDeferred(node); break; } @@ -35893,6 +36878,7 @@ var ts; } checkGrammarSourceFile(node); potentialThisCollisions.length = 0; + potentialNewTargetCollisions.length = 0; deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; ts.forEach(node.statements, checkSourceElement); @@ -35912,6 +36898,10 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } + if (potentialNewTargetCollisions.length) { + ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); + potentialNewTargetCollisions.length = 0; + } links.flags |= 1; } } @@ -35956,7 +36946,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 217 && node.parent.statement === node) { + if (node.parent.kind === 219 && node.parent.statement === node) { return true; } node = node.parent; @@ -35978,28 +36968,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 261: + case 264: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230: + case 232: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 229: + case 231: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 197: + case 198: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 226: - case 227: + case 228: + case 229: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 184: + case 185: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -36017,17 +37007,16 @@ var ts; function copySymbol(symbol, meaning) { if (symbol.flags & meaning) { var id = symbol.name; - if (!symbols[id]) { - symbols[id] = symbol; + if (!symbols.has(id)) { + symbols.set(id, symbol); } } } function copySymbols(source, meaning) { if (meaning) { - for (var id in source) { - var symbol = source[id]; + source.forEach(function (symbol) { copySymbol(symbol, meaning); - } + }); } } } @@ -36038,27 +37027,27 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 143: - case 226: - case 227: + case 144: case 228: case 229: + case 230: + case 231: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 141) { + while (node.parent && node.parent.kind === 142) { node = node.parent; } - return node.parent && (node.parent.kind === 157 || node.parent.kind === 272); + return node.parent && (node.parent.kind === 158 || node.parent.kind === 276); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 177) { + while (node.parent && node.parent.kind === 178) { node = node.parent; } - return node.parent && node.parent.kind === 199; + return node.parent && node.parent.kind === 200; } function forEachEnclosingClass(node, callback) { var result; @@ -36075,13 +37064,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 141) { + while (nodeOnRightSide.parent.kind === 142) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 234) { + if (nodeOnRightSide.parent.kind === 236) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 240) { + if (nodeOnRightSide.parent.kind === 242) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -36093,7 +37082,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 177) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 178) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1: @@ -36105,11 +37094,11 @@ var ts; default: } } - if (entityName.parent.kind === 240 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 242 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } - if (entityName.kind !== 177 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 234); + if (entityName.kind !== 178 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 236); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -36118,7 +37107,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 199) { + if (entityName.parent.kind === 200) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -36140,14 +37129,14 @@ var ts; } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 177) { + else if (entityName.kind === 178) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 141) { + else if (entityName.kind === 142) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -36156,19 +37145,19 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 272) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 158 || entityName.parent.kind === 276) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 250) { + else if (entityName.parent.kind === 252) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 156) { + if (entityName.parent.kind === 157) { return resolveEntityName(entityName, 1); } return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 261) { + if (node.kind === 264) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -36184,8 +37173,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 174 && - node.parent.parent.kind === 172 && + else if (node.parent.kind === 175 && + node.parent.parent.kind === 173 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -36196,8 +37185,8 @@ var ts; } switch (node.kind) { case 70: - case 177: - case 141: + case 178: + case 142: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98: var container = ts.getThisContainer(node, false); @@ -36210,18 +37199,18 @@ var ts; case 96: var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 167: + case 168: return getTypeFromTypeNode(node).symbol; case 122: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 150) { + if (constructorDeclaration && constructorDeclaration.kind === 151) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 235 || node.parent.kind === 241) && + ((node.parent.kind === 237 || node.parent.kind === 243) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -36229,7 +37218,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 178 && node.parent.argumentExpression === node) { + if (node.parent.kind === 179 && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -36243,7 +37232,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 258) { + if (location && location.kind === 261) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -36293,20 +37282,20 @@ var ts; return unknownType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 176 || expr.kind === 175); - if (expr.parent.kind === 213) { + ts.Debug.assert(expr.kind === 177 || expr.kind === 176); + if (expr.parent.kind === 215) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 192) { + if (expr.parent.kind === 193) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 257) { + if (expr.parent.kind === 260) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 175); + ts.Debug.assert(expr.parent.kind === 176); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); @@ -36332,30 +37321,33 @@ var ts; var propsByName = createSymbolTable(getPropertiesOfType(type)); if (getSignaturesOfType(type, 0).length || getSignaturesOfType(type, 1).length) { ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { - if (!propsByName[p.name]) { - propsByName[p.name] = p; + if (!propsByName.has(p.name)) { + propsByName.set(p.name, p); } }); } return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (symbol.flags & 268435456) { + if (getCheckFlags(symbol) & 2) { var symbols_3 = []; - var name_28 = symbol.name; + var name_2 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_28); + var symbol = getPropertyOfType(t, name_2); if (symbol) { symbols_3.push(symbol); } }); return symbols_3; } - else if (symbol.flags & 67108864) { + else if (symbol.flags & 134217728) { if (symbol.leftSpread) { var links = symbol; return [links.leftSpread, links.rightSpread]; } + if (symbol.mappedTypeOrigin) { + return getRootSymbols(symbol.mappedTypeOrigin); + } var target = void 0; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -36371,7 +37363,8 @@ var ts; if (!ts.isGeneratedIdentifier(node)) { node = ts.getParseTreeNode(node, ts.isIdentifier); if (node) { - return getReferencedValueSymbol(node) === argumentsSymbol; + var isPropertyName_1 = node.parent.kind === 178 && node.parent.name === node; + return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } return false; @@ -36387,7 +37380,7 @@ var ts; if (symbolLinks.exportsSomeValue === undefined) { symbolLinks.exportsSomeValue = hasExportAssignment ? !!(moduleSymbol.flags & 107455) - : ts.forEachProperty(getExportsOfModule(moduleSymbol), isValue); + : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { @@ -36413,7 +37406,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 261) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 264) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -36451,7 +37444,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 204 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 206 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -36491,16 +37484,16 @@ var ts; return true; } switch (node.kind) { - case 234: case 236: - case 237: + case 238: case 239: - case 243: - return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); case 241: + case 245: + return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); + case 243: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 240: + case 242: return node.expression && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -36510,7 +37503,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 261 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 264 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -36552,6 +37545,12 @@ var ts; } return false; } + function isRequiredInitializedParameter(parameter) { + return strictNullChecks && + !isOptionalParameter(parameter) && + parameter.initializer && + !(ts.getModifierFlags(parameter) & 92); + } function getNodeCheckFlags(node) { node = ts.getParseTreeNode(node); return node ? getNodeLinks(node).flags : undefined; @@ -36561,7 +37560,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 260) { + if (node.kind === 263) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -36577,15 +37576,17 @@ var ts; } function getTypeReferenceSerializationKind(typeName, location) { var valueSymbol = resolveEntityName(typeName, 107455, true, false, location); - var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); - if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { - return ts.TypeReferenceSerializationKind.Promise; - } - var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; - if (constructorType && isConstructorType(constructorType)) { - return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; - } var typeSymbol = resolveEntityName(typeName, 793064, true, false, location); + if (valueSymbol && valueSymbol === typeSymbol) { + var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); + if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { + return ts.TypeReferenceSerializationKind.Promise; + } + var constructorType = getTypeOfSymbol(valueSymbol); + if (constructorType && isConstructorType(constructorType)) { + return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + } if (!typeSymbol) { return ts.TypeReferenceSerializationKind.ObjectType; } @@ -36629,6 +37630,9 @@ var ts; var type = symbol && !(symbol.flags & (2048 | 131072)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : unknownType; + if (flags & 4096) { + type = includeFalsyTypes(type, 2048); + } getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { @@ -36643,10 +37647,13 @@ var ts; var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(node)); resolveBaseTypesOfClass(classType); var baseType = classType.resolvedBaseTypes.length ? classType.resolvedBaseTypes[0] : unknownType; + if (!baseType.symbol) { + writer.reportIllegalExtends(); + } getSymbolDisplayBuilder().buildTypeDisplay(baseType, writer, enclosingDeclaration, flags); } function hasGlobalName(name) { - return !!globals[name]; + return globals.has(name); } function getReferencedValueSymbol(reference, startInDeclarationContainer) { var resolvedSymbol = getNodeLinks(reference).resolvedSymbol; @@ -36655,9 +37662,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_11 = reference.parent; - if (ts.isDeclaration(parent_11) && reference === parent_11.name) { - location = getDeclarationContainer(parent_11); + var parent = reference.parent; + if (ts.isDeclaration(parent) && reference === parent.name) { + location = getDeclarationContainer(parent); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -36690,14 +37697,13 @@ var ts; var fileToDirective; if (resolvedTypeReferenceDirectives) { fileToDirective = ts.createFileMap(); - for (var key in resolvedTypeReferenceDirectives) { - var resolvedDirective = resolvedTypeReferenceDirectives[key]; + resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) { if (!resolvedDirective) { - continue; + return; } var file = host.getSourceFile(resolvedDirective.resolvedFileName); fileToDirective.set(file.path, key); - } + }); } return { getReferencedExportContainer: getReferencedExportContainer, @@ -36711,6 +37717,7 @@ var ts; isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, + isRequiredInitializedParameter: isRequiredInitializedParameter, writeTypeOfDeclaration: writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, writeTypeOfExpression: writeTypeOfExpression, @@ -36735,7 +37742,7 @@ var ts; if (!fileToDirective) { return undefined; } - var meaning = (node.kind === 177) || (node.kind === 70 && isInTypeQuery(node)) + var meaning = (node.kind === 178) || (node.kind === 70 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -36770,15 +37777,15 @@ var ts; } var current = symbol; while (true) { - var parent_12 = getParentOfSymbol(current); - if (parent_12) { - current = parent_12; + var parent = getParentOfSymbol(current); + if (parent) { + current = parent; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 261 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 264 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -36797,7 +37804,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 261); + return ts.getDeclarationOfKind(moduleSymbol, 264); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -36818,11 +37825,11 @@ var ts; } if (file.symbol && file.symbol.globalExports) { var source = file.symbol.globalExports; - for (var id in source) { - if (!(id in globals)) { - globals[id] = source[id]; + source.forEach(function (sourceSymbol, id) { + if (!globals.has(id)) { + globals.set(id, sourceSymbol); } - } + }); } } if (augmentations) { @@ -36888,10 +37895,10 @@ var ts; var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1; helper <= 128; helper <<= 1) { if (uncheckedHelpers & helper) { - var name_29 = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_29), 107455); + var name = getHelperName(helper); + var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name), 107455); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_29); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); } } } @@ -36926,7 +37933,7 @@ var ts; return emptyObjectType; } function createThenableType() { - var thenPropertySymbol = createSymbol(67108864 | 4, "then"); + var thenPropertySymbol = createSymbol(4, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; var thenableType = createObjectType(16); thenableType.properties = [thenPropertySymbol]; @@ -36940,14 +37947,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 149 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 150 && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 151 || node.kind === 152) { + else if (node.kind === 152 || node.kind === 153) { 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); @@ -36965,16 +37972,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 130) { - if (node.kind === 146 || node.kind === 148) { + if (node.kind === 147 || node.kind === 149) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 155) { + if (node.kind === 156) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 75: - if (node.kind !== 229 && node.parent.kind === 226) { + if (node.kind !== 231 && node.parent.kind === 228) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; @@ -37000,7 +38007,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 231 || node.parent.kind === 261) { + else if (node.parent.kind === 233 || node.parent.kind === 264) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -37023,10 +38030,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 231 || node.parent.kind === 261) { + else if (node.parent.kind === 233 || node.parent.kind === 264) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -37039,7 +38046,7 @@ var ts; if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 147 && node.kind !== 146 && node.kind !== 155 && node.kind !== 144) { + else if (node.kind !== 148 && node.kind !== 147 && node.kind !== 156 && node.kind !== 145) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; @@ -37058,10 +38065,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 228) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; @@ -37073,13 +38080,13 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 228) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 231) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 233) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -37089,14 +38096,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 226) { - if (node.kind !== 149 && - node.kind !== 147 && - node.kind !== 151 && - node.kind !== 152) { + if (node.kind !== 228) { + if (node.kind !== 150 && + node.kind !== 148 && + node.kind !== 152 && + node.kind !== 153) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 226 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 228 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -37115,7 +38122,7 @@ var ts; 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 === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -37123,7 +38130,7 @@ var ts; break; } } - if (node.kind === 150) { + if (node.kind === 151) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -37138,13 +38145,13 @@ var ts; } return; } - else if ((node.kind === 235 || node.kind === 234) && flags & 2) { + else if ((node.kind === 237 || node.kind === 236) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 144 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 145 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 144 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 145 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -37160,37 +38167,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 151: case 152: - case 150: - case 147: - case 146: - case 149: + case 153: + case 151: case 148: - case 155: - case 230: - case 235: - case 234: - case 241: - case 240: - case 184: + case 147: + case 150: + case 149: + case 156: + case 232: + case 237: + case 236: + case 243: + case 242: case 185: - case 144: + case 186: + case 145: return false; default: - if (node.parent.kind === 231 || node.parent.kind === 261) { + if (node.parent.kind === 233 || node.parent.kind === 264) { return false; } switch (node.kind) { - case 225: - return nodeHasAnyModifiersExcept(node, 119); - case 226: - return nodeHasAnyModifiersExcept(node, 116); case 227: - case 205: + return nodeHasAnyModifiersExcept(node, 119); case 228: - return true; + return nodeHasAnyModifiersExcept(node, 116); case 229: + case 207: + case 230: + return true; + case 231: return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); @@ -37203,10 +38210,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 149: - case 225: - case 184: + case 150: + case 227: case 185: + case 186: if (!node.asteriskToken) { return false; } @@ -37268,7 +38275,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 185) { + if (node.kind === 186) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -37303,7 +38310,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 !== 134 && parameter.type.kind !== 132) { + if (parameter.type.kind !== 135 && parameter.type.kind !== 132) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -37330,7 +38337,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 198) { + if (arg.kind === 199) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -37400,19 +38407,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 142) { + if (node.kind !== 143) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 192 && computedPropertyName.expression.operatorToken.kind === 25) { + if (computedPropertyName.expression.kind === 193 && computedPropertyName.expression.operatorToken.kind === 25) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 225 || - node.kind === 184 || - node.kind === 149); + ts.Debug.assert(node.kind === 227 || + node.kind === 185 || + node.kind === 150); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -37437,87 +38444,87 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259) { + if (prop.kind === 262) { continue; } - var name_30 = prop.name; - if (name_30.kind === 142) { - checkGrammarComputedPropertyName(name_30); + var name = prop.name; + if (name.kind === 143) { + checkGrammarComputedPropertyName(name); } - if (prop.kind === 258 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 261 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 || prop.kind !== 149) { + if (mod.kind !== 119 || prop.kind !== 150) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; - if (prop.kind === 257 || prop.kind === 258) { + if (prop.kind === 260 || prop.kind === 261) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_30.kind === 8) { - checkGrammarNumericLiteral(name_30); + if (name.kind === 8) { + checkGrammarNumericLiteral(name); } currentKind = Property; } - else if (prop.kind === 149) { + else if (prop.kind === 150) { currentKind = Property; } - else if (prop.kind === 151) { + else if (prop.kind === 152) { currentKind = GetAccessor; } - else if (prop.kind === 152) { + else if (prop.kind === 153) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_30); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { continue; } - if (!seen[effectiveName]) { - seen[effectiveName] = currentKind; + var existingKind = seen.get(effectiveName); + if (!existingKind) { + seen.set(effectiveName, currentKind); } else { - var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_30, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_30)); + grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[effectiveName] = currentKind | existingKind; + seen.set(effectiveName, currentKind | existingKind); } else { - return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } } function checkGrammarJsxElement(node) { var seen = ts.createMap(); - for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { + for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 251) { + if (attr.kind === 254) { continue; } var jsxAttr = attr; - var name_31 = jsxAttr.name; - if (!seen[name_31.text]) { - seen[name_31.text] = true; + var name = jsxAttr.name; + if (!seen.get(name.text)) { + seen.set(name.text, true); } else { - return grammarErrorOnNode(name_31, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 252 && !initializer.expression) { + if (initializer && initializer.kind === 255 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -37526,7 +38533,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 224) { + if (forInOrOfStatement.initializer.kind === 226) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -37534,20 +38541,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 214 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 214 ? 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 === 212 + var diagnostic = forInOrOfStatement.kind === 214 ? 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); @@ -37574,11 +38581,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 151 ? + return grammarErrorOnNode(accessor.name, kind === 152 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 152) { + else if (kind === 153) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -37597,10 +38604,10 @@ var ts; } } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 151 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 152 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 151 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 152 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -37615,7 +38622,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 176) { + if (node.parent.kind === 177) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -37631,10 +38638,10 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 229) { 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 === 161) { + else if (node.parent.kind === 162) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -37645,9 +38652,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 219: + case 221: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 214 + var isMisplacedContinueLabel = node.kind === 216 && !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); @@ -37655,8 +38662,8 @@ var ts; return false; } break; - case 218: - if (node.kind === 215 && !node.label) { + case 220: + if (node.kind === 217 && !node.label) { return false; } break; @@ -37669,13 +38676,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 215 + var message = node.kind === 217 ? 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 === 215 + var message = node.kind === 217 ? 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); @@ -37687,7 +38694,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 173 || node.name.kind === 172) { + if (node.name.kind === 174 || node.name.kind === 173) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -37697,11 +38704,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 190 && expr.operator === 37 && + expr.kind === 191 && expr.operator === 37 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 212 && node.parent.parent.kind !== 213) { + if (node.parent.parent.kind !== 214 && node.parent.parent.kind !== 215) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -37728,9 +38735,29 @@ var ts; } } } + if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && + !ts.isInAmbientContext(node.parent.parent) && ts.hasModifier(node.parent.parent, 1)) { + checkESModuleMarker(node.name); + } var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } + function checkESModuleMarker(name) { + if (name.kind === 70) { + if (ts.unescapeIdentifier(name.text) === "__esModule") { + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); + } + } + else { + var elements = name.elements; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; + if (!ts.isOmittedExpression(element)) { + return checkESModuleMarker(element.name); + } + } + } + } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 70) { if (name.originalKeywordKind === 109) { @@ -37739,8 +38766,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { - var element = elements_2[_i]; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var element = elements_3[_i]; if (!ts.isOmittedExpression(element)) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -37758,15 +38785,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 208: - case 209: case 210: - case 217: case 211: case 212: - case 213: - return false; case 219: + case 213: + case 214: + case 215: + return false; + case 221: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -37781,6 +38808,13 @@ var ts; } } } + function checkGrammarMetaProperty(node) { + if (node.keywordToken === 93) { + if (node.name.text !== "target") { + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + } + } + } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -37821,7 +38855,7 @@ var ts; return true; } } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 229) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -37829,7 +38863,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 161) { + else if (node.parent.kind === 162) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -37842,13 +38876,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 227 || - node.kind === 228 || + if (node.kind === 229 || + node.kind === 230 || + node.kind === 237 || + node.kind === 236 || + node.kind === 243 || + node.kind === 242 || node.kind === 235 || - node.kind === 234 || - node.kind === 241 || - node.kind === 240 || - node.kind === 233 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -37857,7 +38891,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 === 205) { + if (ts.isDeclaration(decl) || decl.kind === 207) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -37876,7 +38910,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 === 204 || node.parent.kind === 231 || node.parent.kind === 261) { + if (node.parent.kind === 206 || node.parent.kind === 233 || node.parent.kind === 264) { 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); @@ -37887,8 +38921,22 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.isOctalLiteral && languageVersion >= 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + if (node.isOctalLiteral) { + var diagnosticMessage = void 0; + if (languageVersion >= 1) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 172)) { + diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 263)) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; + } + if (diagnosticMessage) { + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37; + var literal = (withMinus ? "-" : "") + "0o" + node.text; + return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); + } } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -37901,11 +38949,11 @@ var ts; } function getAmbientModules() { var result = []; - for (var sym in globals) { + globals.forEach(function (global, sym) { if (ambientModuleSymbolRegex.test(sym)) { - result.push(globals[sym]); + result.push(global); } - } + }); return result; } } @@ -37913,55 +38961,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ; - var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[141] = [ - { name: "left", test: ts.isEntityName }, - { name: "right", test: ts.isIdentifier } - ], - _a[145] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[182] = [ - { name: "type", test: ts.isTypeNode }, - { name: "expression", test: ts.isUnaryExpression } - ], - _a[200] = [ - { name: "expression", test: ts.isExpression }, - { name: "type", test: ts.isTypeNode } - ], - _a[201] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[229] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "members", test: ts.isEnumMember } - ], - _a[230] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isModuleName }, - { name: "body", test: ts.isModuleBody } - ], - _a[231] = [ - { name: "statements", test: ts.isStatement } - ], - _a[234] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "moduleReference", test: ts.isModuleReference } - ], - _a[245] = [ - { name: "expression", test: ts.isExpression, optional: true } - ], - _a[260] = [ - { name: "name", test: ts.isPropertyName }, - { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } - ], - _a)); function reduceNode(node, f, initial) { return node ? f(initial, node) : initial; } @@ -37975,41 +38974,45 @@ var ts; var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; - if ((kind > 0 && kind <= 140)) { + if ((kind > 0 && kind <= 141)) { return initial; } - if ((kind >= 156 && kind <= 171)) { + if ((kind >= 157 && kind <= 172)) { return initial; } var result = initial; switch (node.kind) { - case 203: - case 206: - case 198: - case 222: - case 293: + case 205: + case 208: + case 199: + case 224: + case 297: break; case 142: - result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); break; - case 144: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); + case 143: + result = reduceNode(node.expression, cbNode, result); break; case 145: - result = reduceNode(node.expression, cbNode, result); - break; - case 147: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 149: + case 146: + result = reduceNode(node.expression, cbNode, result); + break; + case 148: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 150: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -38018,53 +39021,48 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 150: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); - break; case 151: - result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; case 152: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 153: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 172: case 173: + case 174: result = reduceNodes(node.elements, cbNodes, result); break; - case 174: + case 175: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 175: + case 176: result = reduceNodes(node.elements, cbNodes, result); break; - case 176: - result = reduceNodes(node.properties, cbNodes, result); - break; case 177: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.properties, cbNodes, result); break; case 178: result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.argumentExpression, cbNode, result); + result = reduceNode(node.name, cbNode, result); break; case 179: result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); + result = reduceNode(node.argumentExpression, cbNode, result); break; case 180: result = reduceNode(node.expression, cbNode, result); @@ -38072,10 +39070,19 @@ var ts; result = reduceNodes(node.arguments, cbNodes, result); break; case 181: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 182: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 184: + case 183: + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 185: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -38083,117 +39090,124 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 185: + case 186: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 183: - case 186: + case 184: case 187: case 188: case 189: - case 195: + case 190: case 196: - case 201: + case 197: + case 202: result = reduceNode(node.expression, cbNode, result); break; - case 190: case 191: + case 192: result = reduceNode(node.operand, cbNode, result); break; - case 192: + case 193: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 193: + case 194: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 194: + case 195: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 197: + case 198: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 199: + case 200: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; + case 201: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.type, cbNode, result); + break; case 202: + result = reduceNode(node.expression, cbNode, result); + break; + case 204: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 204: + case 206: result = reduceNodes(node.statements, cbNodes, result); break; - case 205: + case 207: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 207: + case 209: result = reduceNode(node.expression, cbNode, result); break; - case 208: + case 210: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 209: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 210: - case 217: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; case 211: + result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 212: + case 219: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 213: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 212: - case 213: + case 214: + case 215: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 216: - case 220: + case 218: + case 222: result = reduceNode(node.expression, cbNode, result); break; - case 218: + case 220: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 219: + case 221: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 221: + case 223: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 223: + case 225: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 224: + case 226: result = reduceNodes(node.declarations, cbNodes, result); break; - case 225: + case 227: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -38202,7 +39216,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 226: + case 228: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -38210,113 +39224,131 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; + case 231: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.members, cbNodes, result); + break; case 232: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 233: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 234: result = reduceNodes(node.clauses, cbNodes, result); break; - case 235: + case 236: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.moduleReference, cbNode, result); + break; + case 237: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 236: + case 238: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 237: - result = reduceNode(node.name, cbNode, result); - break; - case 238: - case 242: - result = reduceNodes(node.elements, cbNodes, result); - break; case 239: - case 243: - result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; case 240: + case 244: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 241: + case 245: + result = reduceNode(node.propertyName, cbNode, result); + result = reduceNode(node.name, cbNode, result); + break; + case 242: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 241: + case 243: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 246: + case 247: + result = reduceNode(node.expression, cbNode, result); + break; + case 248: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 247: - case 248: - result = reduceNode(node.tagName, cbNode, result); - result = reduceNodes(node.attributes, cbNodes, result); - break; case 249: + case 250: + result = reduceNode(node.tagName, cbNode, result); + result = reduceNode(node.attributes, cbNode, result); + break; + case 251: result = reduceNode(node.tagName, cbNode, result); break; - case 250: + case 253: + result = reduceNodes(node.properties, cbNodes, result); + break; + case 252: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 251: - result = reduceNode(node.expression, cbNode, result); - break; - case 252: - result = reduceNode(node.expression, cbNode, result); - break; - case 253: - result = reduceNode(node.expression, cbNode, result); case 254: - result = reduceNodes(node.statements, cbNodes, result); + result = reduceNode(node.expression, cbNode, result); break; case 255: - result = reduceNodes(node.types, cbNodes, result); + result = reduceNode(node.expression, cbNode, result); break; case 256: + result = reduceNode(node.expression, cbNode, result); + case 257: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 258: + result = reduceNodes(node.types, cbNodes, result); + break; + case 259: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 257: + case 260: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 258: + case 261: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 259: + case 262: result = reduceNode(node.expression, cbNode, result); break; - case 261: + case 263: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + case 264: result = reduceNodes(node.statements, cbNodes, result); break; - case 294: + case 298: result = reduceNode(node.expression, cbNode, result); break; default: - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_1 = edgeTraversalPath; _i < edgeTraversalPath_1.length; _i++) { - var edge = edgeTraversalPath_1[_i]; - var value = node[edge.name]; - if (value !== undefined) { - result = ts.isArray(value) - ? reduceNodes(value, cbNodes, result) - : cbNode(result, value); - } - } - } break; } return result; } ts.reduceEachChild = reduceEachChild; - function visitNode(node, visitor, test, optional, lift, parenthesize, parentNode) { + function visitNode(node, visitor, test, optional, lift) { if (node === undefined || visitor === undefined) { return node; } @@ -38338,15 +39370,12 @@ var ts; else { visitedNode = visited; } - if (parenthesize !== undefined) { - visitedNode = parenthesize(visitedNode, parentNode); - } Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); return visitedNode; } ts.visitNode = visitNode; - function visitNodes(nodes, visitor, test, start, count, parenthesize, parentNode) { + function visitNodes(nodes, visitor, test, start, count) { if (nodes === undefined) { return undefined; } @@ -38359,7 +39388,7 @@ var ts; count = length - start; } if (start > 0 || count < length) { - updated = ts.createNodeArray([], undefined, nodes.hasTrailingComma && start + count === length); + updated = ts.createNodeArray([], nodes.hasTrailingComma && start + count === length); } for (var i = 0; i < count; i++) { var node = nodes[i + start]; @@ -38367,27 +39396,22 @@ var ts; var visited = node !== undefined ? visitor(node) : undefined; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { - updated = ts.createNodeArray(nodes.slice(0, i), nodes, nodes.hasTrailingComma); + updated = ts.createNodeArray(nodes.slice(0, i), nodes.hasTrailingComma); + ts.setTextRange(updated, nodes); } if (visited) { if (ts.isArray(visited)) { for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) { var visitedNode = visited_1[_i]; - visitedNode = parenthesize - ? parenthesize(visitedNode, parentNode) - : visitedNode; Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); updated.push(visitedNode); } } else { - var visitedNode = parenthesize - ? parenthesize(visited, parentNode) - : visited; - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); - updated.push(visitedNode); + Debug.assertNode(visited, test); + aggregateTransformFlags(visited); + updated.push(visited); } } } @@ -38399,10 +39423,10 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); - return ts.createNodeArray(ts.concatenate(statements, declarations), statements); + return ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements); } ts.visitLexicalEnvironment = visitLexicalEnvironment; function visitParameterList(nodes, visitor, context) { @@ -38429,203 +39453,206 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 140)) { + if ((kind > 0 && kind <= 141)) { return node; } - if ((kind >= 156 && kind <= 171)) { + if ((kind >= 157 && kind <= 172)) { return node; } switch (node.kind) { - case 203: - case 206: - case 198: - case 222: + case 205: + case 208: + case 199: + case 224: return node; case 142: + return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); + case 143: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 144: + case 145: return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), node.dotDotDotToken, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 147: + case 146: + return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); + case 148: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 149: - return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 150: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); + return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 151: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); case 152: + return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + case 153: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); - case 172: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 173: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); + return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 174: - return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); + return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); case 175: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); + return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); case 176: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); + return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); case 177: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); case 178: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); case 179: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); case 180: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); case 181: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 182: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); case 183: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 184: - return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 185: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 186: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 187: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 188: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); case 189: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); case 190: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 191: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); case 193: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + case 191: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 192: + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); case 194: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); case 195: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); case 196: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); case 197: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 198: return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 199: + case 200: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 201: + return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); case 202: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 204: + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + case 206: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 205: - return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); case 207: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 208: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); + return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); case 209: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 210: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); case 211: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); case 212: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 213: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 214: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 215: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 216: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 217: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 218: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); case 219: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 220: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); case 221: - return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 222: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); case 223: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 224: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); case 225: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 226: + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + case 227: + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + case 228: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); + case 231: + return ts.updateEnumDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNodes(node.members, visitor, ts.isEnumMember)); case 232: + return ts.updateModuleDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); + case 233: + return ts.updateModuleBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 234: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 235: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 236: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); + return ts.updateImportEqualsDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); case 237: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 238: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); case 239: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 240: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 241: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 242: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 243: + return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + case 244: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + case 245: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 246: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 247: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); case 248: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 249: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 250: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 251: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 252: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 253: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxAttributes(node, visitNodes(node.properties, visitor, ts.isJsxAttributeLike)); + case 249: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 250: + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 251: + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + case 252: + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 254: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 255: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 256: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); case 257: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); case 258: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); case 259: - return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + case 260: + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); case 261: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 262: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + case 263: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 264: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 294: + case 298: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: - var updated = void 0; - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_2 = edgeTraversalPath; _i < edgeTraversalPath_2.length; _i++) { - var edge = edgeTraversalPath_2[_i]; - var value = node[edge.name]; - if (value !== undefined) { - var visited = ts.isArray(value) - ? visitNodes(value, visitor, edge.test, 0, value.length, edge.parenthesize, node) - : visitNode(value, visitor, edge.test, edge.optional, edge.lift, edge.parenthesize, node); - if (updated !== undefined || visited !== value) { - if (updated === undefined) { - updated = ts.getMutableClone(node); - } - if (visited !== value) { - updated[edge.name] = visited; - } - } - } - } - } - return updated ? ts.updateNode(updated, node) : node; + return node; } } ts.visitEachChild = visitEachChild; @@ -38634,17 +39661,17 @@ var ts; return statements; } return ts.isNodeArray(statements) - ? ts.createNodeArray(ts.concatenate(statements, declarations), statements) + ? ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements) : ts.addRange(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; function mergeFunctionBodyLexicalEnvironment(body, declarations) { if (body && declarations !== undefined && declarations.length > 0) { if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.createNodeArray(ts.concatenate(body.statements, declarations), body.statements)); + return ts.updateBlock(body, ts.setTextRange(ts.createNodeArray(ts.concatenate(body.statements, declarations)), body.statements)); } else { - return ts.createBlock(ts.createNodeArray([ts.createReturn(body, body)].concat(declarations), body), body, true); + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray([ts.setTextRange(ts.createReturn(body), body)].concat(declarations)), body), true), body); } } return body; @@ -38689,7 +39716,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || ts.isTypeNode(node)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 200)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -38737,10 +39764,14 @@ var ts; } } })(Debug = ts.Debug || (ts.Debug = {})); - var _a; })(ts || (ts = {})); var ts; (function (ts) { + var FlattenLevel; + (function (FlattenLevel) { + FlattenLevel[FlattenLevel["All"] = 0] = "All"; + FlattenLevel[FlattenLevel["ObjectRest"] = 1] = "ObjectRest"; + })(FlattenLevel = ts.FlattenLevel || (ts.FlattenLevel = {})); function flattenDestructuringAssignment(node, visitor, context, level, needsValue, createAssignmentCallback) { var location = node; var value; @@ -38794,7 +39825,7 @@ var ts; ts.Debug.assertNode(target, createAssignmentCallback ? ts.isIdentifier : ts.isExpression); var expression = createAssignmentCallback ? createAssignmentCallback(target, value, location) - : ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value, location); + : ts.setTextRange(ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value), location); expression.original = original; emitExpression(expression); } @@ -38832,10 +39863,11 @@ var ts; } } for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) { - var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_32 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; - var variable = ts.createVariableDeclaration(name_32, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); + var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name = _a.name, value = _a.value, location = _a.location, original = _a.original; + var variable = ts.createVariableDeclaration(name, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value); variable.original = original; - if (ts.isIdentifier(name_32)) { + ts.setTextRange(variable, location); + if (ts.isIdentifier(name)) { ts.setEmitFlags(variable, 64); } ts.aggregateTransformFlags(variable); @@ -38981,8 +40013,8 @@ var ts; return ts.createElementAccess(value, argumentExpression); } else { - var name_33 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); - return ts.createPropertyAccess(value, name_33); + var name = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); + return ts.createPropertyAccess(value, name); } } function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) { @@ -38993,7 +40025,7 @@ var ts; var temp = ts.createTempVariable(undefined); if (flattenContext.hoistTempVariables) { flattenContext.context.hoistVariableDeclaration(temp); - flattenContext.emitExpression(ts.createAssignment(temp, value, location)); + flattenContext.emitExpression(ts.setTextRange(ts.createAssignment(temp, value), location)); } else { flattenContext.emitBindingOrAssignment(temp, value, location, undefined); @@ -39043,12 +40075,21 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), undefined, [value, ts.createArrayLiteral(propertyNames, location)]); + return ts.createCall(ts.getHelperName("__rest"), undefined, [ + value, + ts.setTextRange(ts.createArrayLiteral(propertyNames), location) + ]); } })(ts || (ts = {})); var ts; (function (ts) { var USE_NEW_TYPE_METADATA_FORMAT = false; + var TypeScriptSubstitutionFlags; + (function (TypeScriptSubstitutionFlags) { + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; + })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); function transformTypeScript(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -39059,8 +40100,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(177); context.enableSubstitution(178); + context.enableSubstitution(179); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -39093,15 +40134,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 261: - case 232: - case 231: - case 204: + case 264: + case 234: + case 233: + case 206: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 226: - case 225: + case 228: + case 227: if (ts.hasModifier(node, 2)) { break; } @@ -39126,13 +40167,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 235: + case 237: return visitImportDeclaration(node); - case 234: + case 236: return visitImportEqualsDeclaration(node); - case 240: + case 242: return visitExportAssignment(node); - case 241: + case 243: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -39142,11 +40183,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 241 || - node.kind === 235 || - node.kind === 236 || - (node.kind === 234 && - node.moduleReference.kind === 245)) { + if (node.kind === 243 || + node.kind === 237 || + node.kind === 238 || + (node.kind === 236 && + node.moduleReference.kind === 247)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -39162,15 +40203,15 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 150: - return undefined; - case 147: - case 155: case 151: + return undefined; + case 148: + case 156: case 152: - case 149: + case 153: + case 150: return visitorWorker(node); - case 203: + case 205: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -39201,23 +40242,22 @@ var ts; case 75: case 123: case 130: - case 162: case 163: - case 161: - case 156: - case 143: + case 164: + case 162: + case 157: + case 144: case 118: case 121: - case 134: + case 135: case 132: case 129: case 104: - case 135: - case 159: - case 158: + case 136: case 160: - case 157: - case 164: + case 159: + case 161: + case 158: case 165: case 166: case 167: @@ -39225,57 +40265,58 @@ var ts; case 169: case 170: case 171: - case 155: - case 145: - case 228: - case 147: - return undefined; - case 150: - return visitConstructor(node); - case 227: - return ts.createNotEmittedStatement(node); - case 226: - return visitClassDeclaration(node); - case 197: - return visitClassExpression(node); - case 255: - return visitHeritageClause(node); - case 199: - return visitExpressionWithTypeArguments(node); - case 149: - return visitMethodDeclaration(node); - case 151: - return visitGetAccessor(node); - case 152: - return visitSetAccessor(node); - case 225: - return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); - case 185: - return visitArrowFunction(node); - case 144: - return visitParameter(node); - case 183: - return visitParenthesizedExpression(node); - case 182: - case 200: - return visitAssertionExpression(node); - case 179: - return visitCallExpression(node); - case 180: - return visitNewExpression(node); - case 201: - return visitNonNullExpression(node); - case 229: - return visitEnumDeclaration(node); - case 205: - return visitVariableStatement(node); - case 223: - return visitVariableDeclaration(node); + case 172: + case 156: + case 146: case 230: + case 148: + return undefined; + case 151: + return visitConstructor(node); + case 229: + return ts.createNotEmittedStatement(node); + case 228: + return visitClassDeclaration(node); + case 198: + return visitClassExpression(node); + case 258: + return visitHeritageClause(node); + case 200: + return visitExpressionWithTypeArguments(node); + case 150: + return visitMethodDeclaration(node); + case 152: + return visitGetAccessor(node); + case 153: + return visitSetAccessor(node); + case 227: + return visitFunctionDeclaration(node); + case 185: + return visitFunctionExpression(node); + case 186: + return visitArrowFunction(node); + case 145: + return visitParameter(node); + case 184: + return visitParenthesizedExpression(node); + case 183: + case 201: + return visitAssertionExpression(node); + case 180: + return visitCallExpression(node); + case 181: + return visitNewExpression(node); + case 202: + return visitNonNullExpression(node); + case 231: + return visitEnumDeclaration(node); + case 207: + return visitVariableStatement(node); + case 225: + return visitVariableDeclaration(node); + case 232: return visitModuleDeclaration(node); - case 234: + case 236: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39335,11 +40376,12 @@ var ts; return ts.singleOrMany(statements); } function createClassDeclarationHeadWithoutDecorators(node, name, hasExtendsClause, hasStaticProperties) { - var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); + var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause)); var emitFlags = ts.getEmitFlags(node); if (hasStaticProperties) { emitFlags |= 32; } + ts.setTextRange(classDeclaration, node); ts.setOriginalNode(classDeclaration, node); ts.setEmitFlags(classDeclaration, emitFlags); return classDeclaration; @@ -39350,10 +40392,14 @@ var ts; var declName = ts.getLocalName(node, false, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, hasExtendsClause); - var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members, location); + var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); - var statement = ts.createLetStatement(declName, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression, location); + ts.setTextRange(classExpression, location); + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(declName, undefined, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression) + ], 1)); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, location); ts.setCommentRange(statement, node); return statement; } @@ -39361,7 +40407,9 @@ var ts; var staticProperties = getInitializedProperties(node, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84; })); - var classExpression = ts.setOriginalNode(ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members, node), node); + var classExpression = ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members); + ts.setOriginalNode(classExpression, node); + ts.setTextRange(classExpression, node); if (staticProperties.length > 0) { var expressions = []; var temp = ts.createTempVariable(hoistVariableDeclaration); @@ -39384,7 +40432,7 @@ var ts; members.push(constructor); } ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement)); - return ts.createNodeArray(members, node.members); + return ts.setTextRange(ts.createNodeArray(members), node.members); } function transformConstructor(node, hasExtendsClause) { var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); @@ -39395,7 +40443,7 @@ var ts; } var parameters = transformConstructorParameters(constructor); var body = transformConstructorBody(node, constructor, hasExtendsClause); - return ts.startOnNewLine(ts.setOriginalNode(ts.createConstructor(undefined, undefined, parameters, body, constructor || node), constructor)); + return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(ts.createConstructor(undefined, undefined, parameters, body), constructor || node), constructor)); } function transformConstructorParameters(constructor) { return ts.visitParameterList(constructor && constructor.parameters, visitor, context) @@ -39419,7 +40467,7 @@ var ts; ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } ts.addRange(statements, endLexicalEnvironment()); - return ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : undefined, true); + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined); } function addPrologueDirectivesAndInitialSuperCall(ctor, result) { if (ctor.body) { @@ -39429,7 +40477,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -39451,7 +40499,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 | 48); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536); - return ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), propertyName, node.name), localName), ts.moveRangePos(node, -1))); + return ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1))); } function getInitializedProperties(node, isStatic) { return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); @@ -39463,7 +40511,7 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 147 + return member.kind === 148 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } @@ -39536,12 +40584,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 151: case 152: + case 153: return getAllDecoratorsOfAccessors(node, member); - case 149: + case 150: return getAllDecoratorsOfMethod(member); - case 147: + case 148: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -39620,7 +40668,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 147 + ? member.kind === 148 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -39698,43 +40746,43 @@ var ts; (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeReturnTypeOfNode(node)))); } if (properties) { - decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, undefined, true))); + decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, true))); } } } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 149 - || kind === 151 + return kind === 150 || kind === 152 - || kind === 147; + || kind === 153 + || kind === 148; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 149; + return node.kind === 150; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 226: - case 197: + case 228: + case 198: return ts.getFirstConstructorWithBody(node) !== undefined; - case 149: - case 151: + case 150: case 152: + case 153: return true; } return false; } function serializeTypeOfNode(node) { switch (node.kind) { - case 147: - case 144: - case 151: - return serializeTypeNode(node.type); + case 148: + case 145: case 152: + return serializeTypeNode(node.type); + case 153: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 226: - case 197: - case 149: + case 228: + case 198: + case 150: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -39766,7 +40814,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 151) { + if (container && node.kind === 152) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -39789,21 +40837,24 @@ var ts; } switch (node.kind) { case 104: + case 138: + case 94: + case 129: return ts.createVoidZero(); - case 166: + case 167: return serializeTypeNode(node.type); - case 158: case 159: + case 160: return ts.createIdentifier("Function"); - case 162: case 163: + case 164: return ts.createIdentifier("Array"); - case 156: + case 157: case 121: return ts.createIdentifier("Boolean"); - case 134: + case 135: return ts.createIdentifier("String"); - case 171: + case 172: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); @@ -39819,44 +40870,22 @@ var ts; break; case 132: return ts.createIdentifier("Number"); - case 135: + case 136: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 157: + case 158: return serializeTypeReferenceNode(node); + case 166: case 165: - case 164: - { - var unionOrIntersection = node; - var serializedUnion = void 0; - for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - var serializedIndividual = serializeTypeNode(typeNode); - if (serializedIndividual.kind !== 70) { - serializedUnion = undefined; - break; - } - if (serializedIndividual.text === "Object") { - return serializedIndividual; - } - if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { - serializedUnion = undefined; - break; - } - serializedUnion = serializedIndividual; - } - if (serializedUnion) { - return serializedUnion; - } - } - case 160: - case 168: + return serializeUnionOrIntersectionType(node); + case 161: case 169: case 170: - case 161: + case 171: + case 162: case 118: - case 167: + case 168: break; default: ts.Debug.failBadSyntaxKind(node); @@ -39864,6 +40893,32 @@ var ts; } return ts.createIdentifier("Object"); } + function serializeUnionOrIntersectionType(node) { + var serializedUnion; + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + if (ts.isVoidExpression(serializedIndividual)) { + if (!serializedUnion) { + serializedUnion = serializedIndividual; + } + } + else if (ts.isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") { + return serializedIndividual; + } + else if (serializedUnion && !ts.isVoidExpression(serializedUnion)) { + if (!ts.isIdentifier(serializedUnion) || + !ts.isIdentifier(serializedIndividual) || + serializedUnion.text !== serializedIndividual.text) { + return ts.createIdentifier("Object"); + } + } + else { + serializedUnion = serializedIndividual; + } + } + return serializedUnion; + } function serializeTypeReferenceNode(node) { switch (resolver.getTypeReferenceSerializationKind(node.typeName, currentScope)) { case ts.TypeReferenceSerializationKind.Unknown: @@ -39898,15 +40953,15 @@ var ts; function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { case 70: - var name_34 = ts.getMutableClone(node); - name_34.flags &= ~8; - name_34.original = undefined; - name_34.parent = currentScope; + var name = ts.getMutableClone(node); + name.flags &= ~8; + name.original = undefined; + name.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_34), ts.createLiteral("undefined")), name_34); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } - return name_34; - case 141: + return name; + case 142: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -39950,7 +41005,7 @@ var ts; hoistVariableDeclaration(generatedName); expression = ts.createAssignment(generatedName, expression); } - return ts.setOriginalNode(ts.createComputedPropertyName(expression, name), name); + return ts.updateComputedPropertyName(name, expression); } else { return name; @@ -39959,13 +41014,12 @@ var ts; function visitHeritageClause(node) { if (node.token === 84) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(84, types, node); + return ts.setTextRange(ts.createHeritageClause(84, types), node); } return undefined; } function visitExpressionWithTypeArguments(node) { - var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); - return ts.createExpressionWithTypeArguments(undefined, expression, node); + return ts.updateExpressionWithTypeArguments(node, undefined, ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); } function shouldEmitFunctionLikeDeclaration(node) { return !ts.nodeIsMissing(node.body); @@ -40039,8 +41093,9 @@ var ts; if (ts.parameterIsThisKeyword(node)) { return undefined; } - var parameter = ts.createParameter(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), ts.moveRangePastModifiers(node)); + var parameter = ts.createParameter(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); ts.setOriginalNode(parameter, node); + ts.setTextRange(parameter, ts.moveRangePastModifiers(node)); ts.setCommentRange(parameter, node); ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); ts.setEmitFlags(parameter.name, 32); @@ -40052,7 +41107,7 @@ var ts; if (variables.length === 0) { return undefined; } - return ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); + return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -40064,7 +41119,7 @@ var ts; return ts.flattenDestructuringAssignment(node, visitor, context, 0, false, createNamespaceExportExpression); } else { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), node); + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node); } } function visitVariableDeclaration(node) { @@ -40118,8 +41173,9 @@ var ts; var localName = ts.getLocalName(node, false, true); moduleArg = ts.createAssignment(localName, moduleArg); } - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg]), node); + var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg])); ts.setOriginalNode(enumStatement, node); + ts.setTextRange(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); statements.push(ts.createEndOfDeclarationMarker(node)); @@ -40133,11 +41189,11 @@ var ts; ts.addRange(statements, ts.map(node.members, transformEnumMember)); ts.addRange(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceLocalName; - return ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); + return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true); } function transformEnumMember(member) { var name = getExpressionForPropertyName(member, false); - return ts.createStatement(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name, member), member); + return ts.setTextRange(ts.createStatement(ts.setTextRange(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name), member)), member); } function transformEnumMemberDeclarationValue(member) { var value = resolver.getConstantValue(member); @@ -40169,16 +41225,16 @@ var ts; if (!currentScopeFirstDeclarationsOfName) { currentScopeFirstDeclarationsOfName = ts.createMap(); } - if (!(name in currentScopeFirstDeclarationsOfName)) { - currentScopeFirstDeclarationsOfName[name] = node; + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_35 = node.symbol && node.symbol.name; - if (name_35) { - return currentScopeFirstDeclarationsOfName[name_35] === node; + var name = node.symbol && node.symbol.name; + if (name) { + return currentScopeFirstDeclarationsOfName.get(name) === node; } } return false; @@ -40190,7 +41246,7 @@ var ts; ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 229) { + if (node.kind === 231) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -40231,8 +41287,9 @@ var ts; var localName = ts.getLocalName(node, false, true); moduleArg = ts.createAssignment(localName, moduleArg); } - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); + var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg])); ts.setOriginalNode(moduleStatement, node); + ts.setTextRange(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); statements.push(ts.createEndOfDeclarationMarker(node)); @@ -40250,8 +41307,8 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 231) { - ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); + if (body.kind === 233) { + saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; } @@ -40272,14 +41329,15 @@ var ts; currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 231) { + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true); + ts.setTextRange(block, blockLocation); + if (body.kind !== 233) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 230) { + if (moduleDeclaration.body.kind === 232) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -40299,7 +41357,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 237) { + if (node.kind === 239) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -40351,9 +41409,9 @@ var ts; var moduleReference = ts.createExpressionFromEntityName(node.moduleReference); ts.setEmitFlags(moduleReference, 1536 | 2048); if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { - return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ + return ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.setOriginalNode(ts.createVariableDeclaration(node.name, undefined, moduleReference), node) - ]), node), node); + ])), node), node); } else { return ts.setOriginalNode(createNamespaceExport(node.name, moduleReference, node), node); @@ -40374,7 +41432,7 @@ var ts; && ts.hasModifier(node, 512); } function expressionToStatement(expression) { - return ts.createStatement(expression, undefined); + return ts.createStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), ts.getLocalName(node)); @@ -40384,10 +41442,10 @@ var ts; statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue), location); + return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue, location); + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); } function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) { return ts.getNamespaceMemberName(currentNamespaceContainerName, name, false, true); @@ -40403,7 +41461,7 @@ var ts; function getClassAliasIfNeeded(node) { if (resolver.getNodeCheckFlags(node) & 8388608) { enableSubstitutionForClassAliases(); - var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); + var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.unescapeIdentifier(node.name.text) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; hoistVariableDeclaration(classAlias); return classAlias; @@ -40427,24 +41485,24 @@ var ts; if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; context.enableSubstitution(70); - classAliases = ts.createMap(); + classAliases = []; } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(70); - context.enableSubstitution(258); - context.enableEmitNotification(230); + context.enableSubstitution(261); + context.enableEmitNotification(232); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 230; + return ts.getOriginalNode(node).kind === 232; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 229; + return ts.getOriginalNode(node).kind === 231; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2; @@ -40452,12 +41510,12 @@ var ts; if (enabledSubstitutions & 8 && isTransformedEnumDeclaration(node)) { applicableSubstitutions |= 8; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -40467,14 +41525,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_36 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_36); + var name = node.name; + var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_36, initializer, node); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); } - return ts.createPropertyAssignment(name_36, exportedName, node); + return ts.setTextRange(ts.createPropertyAssignment(name, exportedName), node); } } return node; @@ -40483,9 +41541,9 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 177: - return substitutePropertyAccessExpression(node); case 178: + return substitutePropertyAccessExpression(node); + case 179: return substituteElementAccessExpression(node); } return node; @@ -40515,11 +41573,11 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 261) { - var substitute = (applicableSubstitutions & 2 && container.kind === 230) || - (applicableSubstitutions & 8 && container.kind === 229); + if (container && container.kind !== 264) { + var substitute = (applicableSubstitutions & 2 && container.kind === 232) || + (applicableSubstitutions & 8 && container.kind === 231); if (substitute) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node); } } } @@ -40566,10 +41624,10 @@ var ts; }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(paramHelper); - return ts.createCall(ts.getHelperName("__param"), undefined, [ + return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), undefined, [ ts.createLiteral(parameterOffset), expression - ], location); + ]), location); } var metadataHelper = { name: "typescript:metadata", @@ -40593,7 +41651,7 @@ var ts; function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) { context.requestEmitHelper(decorateHelper); var argumentsArray = []; - argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, undefined, true)); + argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, true)); argumentsArray.push(target); if (memberName) { argumentsArray.push(memberName); @@ -40601,7 +41659,7 @@ var ts; argumentsArray.push(descriptor); } } - return ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray, location); + return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray), location); } })(ts || (ts = {})); var ts; @@ -40628,37 +41686,37 @@ var ts; return node; } switch (node.kind) { - case 176: + case 177: return visitObjectLiteralExpression(node); - case 192: + case 193: return visitBinaryExpression(node, noDestructuringValue); - case 223: - return visitVariableDeclaration(node); - case 213: - return visitForOfStatement(node); - case 211: - return visitForStatement(node); - case 188: - return visitVoidExpression(node); - case 150: - return visitConstructorDeclaration(node); - case 149: - return visitMethodDeclaration(node); - case 151: - return visitGetAccessorDeclaration(node); - case 152: - return visitSetAccessorDeclaration(node); case 225: + return visitVariableDeclaration(node); + case 215: + return visitForOfStatement(node); + case 213: + return visitForStatement(node); + case 189: + return visitVoidExpression(node); + case 151: + return visitConstructorDeclaration(node); + case 150: + return visitMethodDeclaration(node); + case 152: + return visitGetAccessorDeclaration(node); + case 153: + return visitSetAccessorDeclaration(node); + case 227: return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); case 185: + return visitFunctionExpression(node); + case 186: return visitArrowFunction(node); - case 144: + case 145: return visitParameter(node); - case 207: + case 209: return visitExpressionStatement(node); - case 183: + case 184: return visitParenthesizedExpression(node, noDestructuringValue); default: return ts.visitEachChild(node, visitor, context); @@ -40667,9 +41725,9 @@ var ts; function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; - for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { - var e = elements_3[_i]; - if (e.kind === 259) { + for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { + var e = elements_4[_i]; + if (e.kind === 262) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -40681,7 +41739,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 257) { + if (e.kind === 260) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -40698,7 +41756,7 @@ var ts; function visitObjectLiteralExpression(node) { if (node.transformFlags & 1048576) { var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 176) { + if (objects.length && objects[0].kind !== 177) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -40742,25 +41800,26 @@ var ts; var firstDeclaration = ts.firstOrUndefined(initializer.declarations); var declarations = ts.flattenDestructuringBinding(firstDeclaration, visitor, context, 1, temp, false, true); if (ts.some(declarations)) { - var statement = ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(initializer, declarations), initializer); + var statement = ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(initializer, declarations)); + ts.setTextRange(statement, initializer); leadingStatements = ts.append(leadingStatements, statement); } } else if (ts.isAssignmentPattern(initializer)) { temp = ts.createTempVariable(undefined); - var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.createAssignment(initializer, temp, node.initializer)), visitor, context, 1); - leadingStatements = ts.append(leadingStatements, ts.createStatement(expression, node.initializer)); + var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.setTextRange(ts.createAssignment(initializer, temp), node.initializer)), visitor, context, 1); + leadingStatements = ts.append(leadingStatements, ts.setTextRange(ts.createStatement(expression), node.initializer)); } } if (temp) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var statement = ts.visitNode(node.statement, visitor, ts.isStatement); var block = ts.isBlock(statement) - ? ts.updateBlock(statement, ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements), statement.statements)) - : ts.createBlock(ts.append(leadingStatements, statement), statement, true); - return ts.updateForOf(node, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, undefined, undefined, node.initializer) - ], node.initializer, 1), expression, block); + ? ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements)), statement.statements)) + : ts.setTextRange(ts.createBlock(ts.append(leadingStatements, statement), true), statement); + return ts.updateForOf(node, ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer) + ], 1), node.initializer), expression, block); } return ts.visitEachChild(node, visitor, context); } @@ -40810,7 +41869,7 @@ var ts; var trailingStatements = endLexicalEnvironment(); if (ts.some(leadingStatements) || ts.some(trailingStatements)) { var block = ts.convertToFunctionBody(body, true); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements)), block.statements)); } return body; } @@ -40823,6 +41882,9 @@ var ts; text: "\n var __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };" }; function createAssignHelper(context, attributesSegments) { + if (context.getCompilerOptions().target >= 2) { + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), undefined, attributesSegments); + } context.requestEmitHelper(assignHelper); return ts.createCall(ts.getHelperName("__assign"), undefined, attributesSegments); } @@ -40854,11 +41916,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 246: + case 248: return visitJsxElement(node, false); - case 247: + case 249: return visitJsxSelfClosingElement(node, false); - case 252: + case 255: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -40868,11 +41930,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 252: + case 255: return visitJsxExpression(node); - case 246: + case 248: return visitJsxElement(node, true); - case 247: + case 249: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -40888,7 +41950,7 @@ var ts; function visitJsxOpeningLikeElement(node, children, isChild, location) { var tagName = getTagName(node); var objectProperties; - var attrs = node.attributes; + var attrs = node.attributes.properties; if (attrs.length === 0) { objectProperties = ts.createNull(); } @@ -40920,13 +41982,16 @@ var ts; } function transformJsxAttributeInitializer(node) { if (node === undefined) { - return ts.createLiteral(true); + return ts.createTrue(); } else if (node.kind === 9) { var decoded = tryDecodeEntities(node.text); - return decoded ? ts.createLiteral(decoded, node) : node; + return decoded ? ts.setTextRange(ts.createLiteral(decoded), node) : node; } - else if (node.kind === 252) { + else if (node.kind === 255) { + if (node.expression === undefined) { + return ts.createTrue(); + } return visitJsxExpression(node); } else { @@ -40934,43 +41999,35 @@ var ts; } } function visitJsxText(node) { - var text = ts.getTextOfNode(node, true); - var parts; + var fixed = fixupWhitespaceAndDecodeEntities(ts.getTextOfNode(node, true)); + return fixed === undefined ? undefined : ts.createLiteral(fixed); + } + function fixupWhitespaceAndDecodeEntities(text) { + var acc; 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); - if (!parts) { - parts = []; - } - parts.push(ts.createLiteral(decodeEntities(part))); + if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) { + acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1)); } firstNonWhitespace = -1; } - else if (!ts.isWhiteSpace(c)) { + else if (!ts.isWhiteSpaceSingleLine(c)) { lastNonWhitespace = i; if (firstNonWhitespace === -1) { firstNonWhitespace = i; } } } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - if (!parts) { - parts = []; - } - parts.push(ts.createLiteral(decodeEntities(part))); - } - if (parts) { - return ts.reduceLeft(parts, aggregateJsxTextParts); - } - return undefined; + return firstNonWhitespace !== -1 + ? addLineOfJsxText(acc, text.substr(firstNonWhitespace)) + : acc; } - function aggregateJsxTextParts(left, right) { - return ts.createAdd(ts.createAdd(left, ts.createLiteral(" ")), right); + function addLineOfJsxText(acc, trimmedLine) { + var decoded = decodeEntities(trimmedLine); + return acc === undefined ? decoded : acc + " " + decoded; } function decodeEntities(text) { return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) { @@ -40981,7 +42038,7 @@ var ts; return String.fromCharCode(parseInt(hex, 16)); } else { - var ch = entities[word]; + var ch = entities.get(word); return ch ? String.fromCharCode(ch) : match; } }); @@ -40991,16 +42048,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 246) { + if (node.kind === 248) { return getTagName(node.openingElement); } else { - var name_37 = node.tagName; - if (ts.isIdentifier(name_37) && ts.isIntrinsicJsxName(name_37.text)) { - return ts.createLiteral(name_37.text); + var name = node.tagName; + if (ts.isIdentifier(name) && ts.isIntrinsicJsxName(name.text)) { + return ts.createLiteral(name.text); } else { - return ts.createExpressionFromEntityName(name_37); + return ts.createExpressionFromEntityName(name); } } } @@ -41018,7 +42075,7 @@ var ts; } } ts.transformJsx = transformJsx; - var entities = ts.createMap({ + var entities = ts.createMapFromTemplate({ "quot": 0x0022, "amp": 0x0026, "apos": 0x0027, @@ -41276,6 +42333,10 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); function transformES2017(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var resolver = context.getEmitResolver(); @@ -41306,22 +42367,22 @@ var ts; switch (node.kind) { case 119: return undefined; - case 189: + case 190: return visitAwaitExpression(node); - case 149: + case 150: return visitMethodDeclaration(node); - case 225: + case 227: return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); case 185: + return visitFunctionExpression(node); + case 186: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); } } function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); } function visitMethodDeclaration(node) { return ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) @@ -41351,14 +42412,15 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 185; + var isArrowFunction = node.kind === 186; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(statements, node.body, true); + var block = ts.createBlock(statements, true); + ts.setTextRange(block, node.body); if (languageVersion >= 2) { if (resolver.getNodeCheckFlags(node) & 4096) { enableSubstitutionForAsyncMethodsWithSuper(); @@ -41376,7 +42438,7 @@ var ts; var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(block.statements, declarations), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); } return expression; } @@ -41389,7 +42451,7 @@ var ts; startLexicalEnvironment(); var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); var declarations = endLexicalEnvironment(); - return ts.updateBlock(visited, ts.createNodeArray(ts.concatenate(visited.statements, declarations), visited.statements)); + return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); } } function getPromiseConstructor(type) { @@ -41406,23 +42468,23 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(179); - context.enableSubstitution(177); + context.enableSubstitution(180); context.enableSubstitution(178); - context.enableEmitNotification(226); - context.enableEmitNotification(149); - context.enableEmitNotification(151); - context.enableEmitNotification(152); + context.enableSubstitution(179); + context.enableEmitNotification(228); context.enableEmitNotification(150); + context.enableEmitNotification(152); + context.enableEmitNotification(153); + context.enableEmitNotification(151); } } function substituteExpression(node) { switch (node.kind) { - case 177: - return substitutePropertyAccessExpression(node); case 178: - return substituteElementAccessExpression(node); + return substitutePropertyAccessExpression(node); case 179: + return substituteElementAccessExpression(node); + case 180: if (enabledSubstitutions & 1) { return substituteCallExpression(node); } @@ -41465,36 +42527,36 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 226 - || kind === 150 - || kind === 149 + return kind === 228 || kind === 151 - || kind === 152; + || kind === 150 + || kind === 152 + || kind === 153; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { if (enabledSubstitutions & 1 && isSuperContainer(node)) { var savedCurrentSuperContainer = currentSuperContainer; currentSuperContainer = node; - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSuperContainer = savedCurrentSuperContainer; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } return node; } function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { if (flags & 4096) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value"), location); } else { - return ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression], location); + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), location); } } function getSuperContainerAsyncMethodFlags() { @@ -41547,7 +42609,7 @@ var ts; return node; } switch (node.kind) { - case 192: + case 193: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -41571,19 +42633,19 @@ var ts; if (ts.isElementAccessExpression(left)) { var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createElementAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), ts.createAssignment(argumentExpressionTemp, left.argumentExpression, left.argumentExpression), left); - value = ts.createElementAccess(expressionTemp, argumentExpressionTemp, left); + target = ts.setTextRange(ts.createElementAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), ts.setTextRange(ts.createAssignment(argumentExpressionTemp, left.argumentExpression), left.argumentExpression)), left); + value = ts.setTextRange(ts.createElementAccess(expressionTemp, argumentExpressionTemp), left); } else if (ts.isPropertyAccessExpression(left)) { var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createPropertyAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), left.name, left); - value = ts.createPropertyAccess(expressionTemp, left.name, left); + target = ts.setTextRange(ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), left.name), left); + value = ts.setTextRange(ts.createPropertyAccess(expressionTemp, left.name), left); } else { target = left; value = left; } - return ts.createAssignment(target, ts.createMathPow(value, right, node), node); + return ts.setTextRange(ts.createAssignment(target, ts.createMathPow(value, right, node)), node); } function visitExponentiationExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); @@ -41595,6 +42657,75 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var ES2015SubstitutionFlags; + (function (ES2015SubstitutionFlags) { + ES2015SubstitutionFlags[ES2015SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; + ES2015SubstitutionFlags[ES2015SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; + })(ES2015SubstitutionFlags || (ES2015SubstitutionFlags = {})); + var CopyDirection; + (function (CopyDirection) { + CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; + CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; + })(CopyDirection || (CopyDirection = {})); + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); + var SuperCaptureResult; + (function (SuperCaptureResult) { + SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; + SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; + SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; + })(SuperCaptureResult || (SuperCaptureResult = {})); + var HierarchyFacts; + (function (HierarchyFacts) { + HierarchyFacts[HierarchyFacts["None"] = 0] = "None"; + HierarchyFacts[HierarchyFacts["Function"] = 1] = "Function"; + HierarchyFacts[HierarchyFacts["ArrowFunction"] = 2] = "ArrowFunction"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBody"] = 4] = "AsyncFunctionBody"; + HierarchyFacts[HierarchyFacts["NonStaticClassElement"] = 8] = "NonStaticClassElement"; + HierarchyFacts[HierarchyFacts["CapturesThis"] = 16] = "CapturesThis"; + HierarchyFacts[HierarchyFacts["ExportedVariableStatement"] = 32] = "ExportedVariableStatement"; + HierarchyFacts[HierarchyFacts["TopLevel"] = 64] = "TopLevel"; + HierarchyFacts[HierarchyFacts["Block"] = 128] = "Block"; + HierarchyFacts[HierarchyFacts["IterationStatement"] = 256] = "IterationStatement"; + HierarchyFacts[HierarchyFacts["IterationStatementBlock"] = 512] = "IterationStatementBlock"; + HierarchyFacts[HierarchyFacts["ForStatement"] = 1024] = "ForStatement"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 2048] = "ForInOrForOfStatement"; + HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 4096] = "ConstructorWithCapturedSuper"; + HierarchyFacts[HierarchyFacts["ComputedPropertyName"] = 8192] = "ComputedPropertyName"; + HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 16383] = "AncestorFactsMask"; + HierarchyFacts[HierarchyFacts["BlockScopeIncludes"] = 0] = "BlockScopeIncludes"; + HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 4032] = "BlockScopeExcludes"; + HierarchyFacts[HierarchyFacts["SourceFileIncludes"] = 64] = "SourceFileIncludes"; + HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 3968] = "SourceFileExcludes"; + HierarchyFacts[HierarchyFacts["FunctionIncludes"] = 65] = "FunctionIncludes"; + HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 16286] = "FunctionExcludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyIncludes"] = 69] = "AsyncFunctionBodyIncludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 16278] = "AsyncFunctionBodyExcludes"; + HierarchyFacts[HierarchyFacts["ArrowFunctionIncludes"] = 66] = "ArrowFunctionIncludes"; + HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 16256] = "ArrowFunctionExcludes"; + HierarchyFacts[HierarchyFacts["ConstructorIncludes"] = 73] = "ConstructorIncludes"; + HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 16278] = "ConstructorExcludes"; + HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 256] = "DoOrWhileStatementIncludes"; + HierarchyFacts[HierarchyFacts["DoOrWhileStatementExcludes"] = 0] = "DoOrWhileStatementExcludes"; + HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 1280] = "ForStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 3008] = "ForStatementExcludes"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 2304] = "ForInOrForOfStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 1984] = "ForInOrForOfStatementExcludes"; + HierarchyFacts[HierarchyFacts["BlockIncludes"] = 128] = "BlockIncludes"; + HierarchyFacts[HierarchyFacts["BlockExcludes"] = 3904] = "BlockExcludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockIncludes"] = 512] = "IterationStatementBlockIncludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 4032] = "IterationStatementBlockExcludes"; + HierarchyFacts[HierarchyFacts["ComputedPropertyNameIncludes"] = 8192] = "ComputedPropertyNameIncludes"; + HierarchyFacts[HierarchyFacts["ComputedPropertyNameExcludes"] = 0] = "ComputedPropertyNameExcludes"; + HierarchyFacts[HierarchyFacts["NewTarget"] = 16384] = "NewTarget"; + HierarchyFacts[HierarchyFacts["NewTargetInComputedPropertyName"] = 32768] = "NewTargetInComputedPropertyName"; + HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -16384] = "SubtreeFactsMask"; + HierarchyFacts[HierarchyFacts["PropagateNewTargetMask"] = 49152] = "PropagateNewTargetMask"; + })(HierarchyFacts || (HierarchyFacts = {})); function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -41604,15 +42735,7 @@ var ts; context.onSubstituteNode = onSubstituteNode; var currentSourceFile; var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - var isInConstructorWithCapturedSuper; + var hierarchyFacts; var convertedLoopState; var enabledSubstitutions; return transformSourceFile; @@ -41622,247 +42745,202 @@ var ts; } currentSourceFile = node; currentText = node.text; - var visited = saveStateAndInvoke(node, visitSourceFile); + var visited = visitSourceFile(node); ts.addEmitHelpers(visited, context.readEmitHelpers()); currentSourceFile = undefined; currentText = undefined; + hierarchyFacts = 0; return visited; } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); + function enterSubtree(excludeFacts, includeFacts) { + var ancestorFacts = hierarchyFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383; + return ancestorFacts; } - function dispatcher(node) { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - function saveStateAndInvoke(node, f) { - var savedEnclosingFunction = enclosingFunction; - var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - var savedEnclosingVariableStatement = enclosingVariableStatement; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var savedConvertedLoopState = convertedLoopState; - var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - isInConstructorWithCapturedSuper = false; - convertedLoopState = undefined; - } - onBeforeVisitNode(node); - var visited = f(node); - isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 185) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 131072)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - switch (currentNode.kind) { - case 205: - enclosingVariableStatement = currentNode; - break; - case 224: - case 223: - case 174: - case 172: - case 173: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - function returnCapturedThis(node) { - return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 216 && !node.expression; + return hierarchyFacts & 4096 + && node.kind === 218 + && !node.expression; } - function shouldCheckNode(node) { - return (node.transformFlags & 64) !== 0 || - node.kind === 219 || - (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); + function shouldVisitNode(node) { + return (node.transformFlags & 128) !== 0 + || convertedLoopState !== undefined + || (hierarchyFacts & 4096 && ts.isStatement(node)) + || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } - function visitorWorker(node) { - if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { - return returnCapturedThis(node); - } - else if (shouldCheckNode(node)) { + function visitor(node) { + if (shouldVisitNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { - return ts.visitEachChild(node, visitor, context); - } else { return node; } } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); + function functionBodyVisitor(node) { + if (shouldVisitNode(node)) { + return visitBlock(node, true); } - else { - result = visitNodesInConvertedLoop(node); - } - return result; + return node; } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 216: - node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; - return visitReturnStatement(node); - case 205: - return visitVariableStatement(node); - case 218: - return visitSwitchStatement(node); - case 215: - case 214: - return visitBreakOrContinueStatement(node); - case 98: - return visitThisKeyword(node); - case 70: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); + function callExpressionVisitor(node) { + if (node.kind === 96) { + return visitSuperKeyword(true); } + return visitor(node); } function visitJavaScript(node) { switch (node.kind) { case 114: return undefined; - case 226: + case 228: return visitClassDeclaration(node); - case 197: + case 198: return visitClassExpression(node); - case 144: + case 145: return visitParameter(node); - case 225: + case 227: return visitFunctionDeclaration(node); - case 185: + case 186: return visitArrowFunction(node); - case 184: + case 185: return visitFunctionExpression(node); - case 223: + case 225: return visitVariableDeclaration(node); case 70: return visitIdentifier(node); - case 224: + case 226: return visitVariableDeclarationList(node); - case 219: + case 220: + return visitSwitchStatement(node); + case 234: + return visitCaseBlock(node); + case 206: + return visitBlock(node, false); + case 217: + case 216: + return visitBreakOrContinueStatement(node); + case 221: return visitLabeledStatement(node); - case 209: - return visitDoStatement(node); - case 210: - return visitWhileStatement(node); case 211: - return visitForStatement(node); case 212: - return visitForInStatement(node); + return visitDoOrWhileStatement(node, undefined); case 213: - return visitForOfStatement(node); - case 207: + return visitForStatement(node, undefined); + case 214: + return visitForInStatement(node, undefined); + case 215: + return visitForOfStatement(node, undefined); + case 209: return visitExpressionStatement(node); - case 176: + case 177: return visitObjectLiteralExpression(node); - case 256: + case 259: return visitCatchClause(node); - case 258: + case 261: return visitShorthandPropertyAssignment(node); - case 175: + case 143: + return visitComputedPropertyName(node); + case 176: return visitArrayLiteralExpression(node); - case 179: - return visitCallExpression(node); case 180: + return visitCallExpression(node); + case 181: return visitNewExpression(node); - case 183: + case 184: return visitParenthesizedExpression(node, true); - case 192: + case 193: return visitBinaryExpression(node, true); case 12: case 13: case 14: case 15: return visitTemplateLiteral(node); - case 181: + case 182: return visitTaggedTemplateExpression(node); - case 194: - return visitTemplateExpression(node); case 195: - return visitYieldExpression(node); + return visitTemplateExpression(node); case 196: + return visitYieldExpression(node); + case 197: return visitSpreadElement(node); case 96: - return visitSuperKeyword(); - case 195: - return ts.visitEachChild(node, visitor, context); - case 149: + return visitSuperKeyword(false); + case 98: + return visitThisKeyword(node); + case 203: + return visitMetaProperty(node); + case 150: return visitMethodDeclaration(node); - case 205: + case 152: + case 153: + return visitAccessorDeclaration(node); + case 207: return visitVariableStatement(node); + case 218: + return visitReturnStatement(node); default: - ts.Debug.failBadSyntaxKind(node); return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { + var ancestorFacts = enterSubtree(3968, 64); var statements = []; startLexicalEnvironment(); var statementOffset = ts.addPrologueDirectives(statements, node.statements, false, visitor); addCaptureThisForNodeIfNeeded(statements, node); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + exitSubtree(ancestorFacts, 0, 0); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } function visitSwitchStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps |= 2; - var result = ts.visitEachChild(node, visitor, context); - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; + if (convertedLoopState !== undefined) { + var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps |= 2; + var result = ts.visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + return ts.visitEachChild(node, visitor, context); + } + function visitCaseBlock(node) { + var ancestorFacts = enterSubtree(4032, 0); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0, 0); + return updated; + } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function visitReturnStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - convertedLoopState.nonLocalJumps |= 8; - return ts.createReturn(ts.createObjectLiteral([ - ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression - ? ts.visitNode(node.expression, visitor, ts.isExpression) - : ts.createVoidZero()) - ])); + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8; + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + node = returnCapturedThis(node); + } + return ts.createReturn(ts.createObjectLiteral([ + ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression + ? ts.visitNode(node.expression, visitor, ts.isExpression) + : ts.createVoidZero()) + ])); + } + else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 185) { - convertedLoopState.containsLexicalThis = true; - return node; + if (convertedLoopState) { + if (hierarchyFacts & 2) { + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + return node; } function visitIdentifier(node) { if (!convertedLoopState) { @@ -41871,20 +42949,20 @@ var ts; if (ts.isGeneratedIdentifier(node)) { return node; } - if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + if (node.text !== "arguments" || !resolver.isArgumentsLocalBinding(node)) { return node; } return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 215 ? 2 : 4; - var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + var jump = node.kind === 217 ? 2 : 4; + var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(node.label.text)) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 215) { + if (node.kind === 217) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -41894,7 +42972,7 @@ var ts; } } else { - if (node.kind === 215) { + if (node.kind === 217) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -41927,8 +43005,9 @@ var ts; var variable = ts.createVariableDeclaration(ts.getLocalName(node, true), undefined, transformClassLikeDeclarationToExpression(node)); ts.setOriginalNode(variable, node); var statements = []; - var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable]), node); + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable])); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, node); ts.startOnNewLine(statement); statements.push(statement); if (ts.hasModifier(node, 1)) { @@ -41983,23 +43062,29 @@ var ts; ts.setEmitFlags(statement, 1536 | 384); statements.push(statement); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true); ts.setEmitFlags(block, 1536); return block; } function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node)), extendsClauseElement)); + statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node))), extendsClauseElement)); } } function addConstructor(statements, node, extendsClauseElement) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16278, 73); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); + var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); + ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { ts.setEmitFlags(constructorFunction, 8); } statements.push(constructorFunction); + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; } function transformConstructorParameters(constructor, hasSynthesizedSuper) { return ts.visitParameterList(constructor && !hasSynthesizedSuper && constructor.parameters, visitor, context) @@ -42020,41 +43105,45 @@ var ts; addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94; + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); if (superCaptureStatus === 1 || superCaptureStatus === 2) { statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { - isInConstructorWithCapturedSuper = superCaptureStatus === 1; - return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); - }); - ts.addRange(statements, body); + if (superCaptureStatus === 1) { + hierarchyFacts |= 4096; + } + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset)); } - if (extendsClauseElement + if (isDerivedClass && superCaptureStatus !== 2 && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createIdentifier("_this"))); } ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); + if (constructor) { + prependCaptureNewTargetIfNeeded(statements, constructor, false); + } + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true); + ts.setTextRange(block, constructor ? constructor.body : node); if (!constructor) { ts.setEmitFlags(block, 1536); } return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 216) { + if (statement.kind === 218) { return true; } - else if (statement.kind === 208) { + else if (statement.kind === 210) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 204) { + else if (statement.kind === 206) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -42062,8 +43151,8 @@ var ts; } return false; } - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { - if (!hasExtendsClause) { + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, isDerivedClass, hasSynthesizedSuper, statementOffset) { + if (!isDerivedClass) { if (ctor) { addCaptureThisForNodeIfNeeded(statements, ctor); } @@ -42083,44 +43172,43 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 207 && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + if (firstStatement.kind === 209 && ts.isSuperCall(firstStatement.expression)) { + superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } if (superCallExpression && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 | 32768))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 192 - || superCallExpression.left.kind !== 179) { + if (superCallExpression.kind !== 193 + || superCallExpression.left.kind !== 180) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } ts.setCommentRange(returnStatement, ts.getCommentRange(ts.setEmitFlags(superCallExpression.left, 1536))); statements.push(returnStatement); return 2; } - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement); if (superCallExpression) { return 1; } return 0; } + function createActualThis() { + return ts.setEmitFlags(ts.createThis(), 4); + } function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 4); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); + return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createIdentifier("_super"), ts.createNull()), ts.createFunctionApply(ts.createIdentifier("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis()); } function visitParameter(node) { if (node.dotDotDotToken) { return undefined; } else if (ts.isBindingPattern(node.name)) { - return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined, node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined), node), node); } else if (node.initializer) { - return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined, node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined), node), node); } else { return node; @@ -42135,15 +43223,15 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_38 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_38)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_38, initializer); + if (ts.isBindingPattern(name)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_38, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer); } } } @@ -42158,10 +43246,11 @@ var ts; } function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer)), parameter)) - ], parameter), 1 | 32 | 384), undefined, parameter); + var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([ + ts.createStatement(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer))), parameter)) + ]), parameter), 1 | 32 | 384)); statement.startsOnNewLine = true; + ts.setTextRange(statement, parameter); ts.setEmitFlags(statement, 384 | 32 | 524288); statements.push(statement); } @@ -42178,22 +43267,22 @@ var ts; var expressionName = ts.getSynthesizedClone(parameter.name); var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) - ]), parameter), 524288)); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ])), parameter), 524288)); + var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) - ], parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), parameter), ts.createPostfixIncrement(temp, parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 + ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([ + ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp - : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), parameter)) + : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), parameter)) ])); ts.setEmitFlags(forStatement, 524288); ts.startOnNewLine(forStatement); statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 && node.kind !== 185) { + if (node.transformFlags & 32768 && node.kind !== 186) { captureThisForNode(statements, node, ts.createThis()); } } @@ -42201,29 +43290,62 @@ var ts; enableSubstitutionsForCapturedThis(); var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration("_this", undefined, initializer) - ]), originalStatement); + ])); ts.setEmitFlags(captureThisStatement, 1536 | 524288); + ts.setTextRange(captureThisStatement, originalStatement); ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } + function prependCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { + if (hierarchyFacts & 16384) { + var newTarget = void 0; + switch (node.kind) { + case 186: + return statements; + case 150: + case 152: + case 153: + newTarget = ts.createVoidZero(); + break; + case 151: + newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); + break; + case 227: + case 185: + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 92, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + var captureNewTargetStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_newTarget", undefined, newTarget) + ])); + if (copyOnWrite) { + return [captureNewTargetStatement].concat(statements); + } + statements.unshift(captureNewTargetStatement); + } + return statements; + } function addClassMembers(statements, node) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 203: + case 205: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 149: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + case 150: + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 151: case 152: + case 153: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 150: + case 151: break; default: ts.Debug.failBadSyntaxKind(node); @@ -42232,28 +43354,32 @@ var ts; } } function transformSemicolonClassElementToStatement(member) { - return ts.createEmptyStatement(member); + return ts.setTextRange(ts.createEmptyStatement(), member); } - function transformClassMethodDeclarationToStatement(receiver, member) { + function transformClassMethodDeclarationToStatement(receiver, member, container) { + var ancestorFacts = enterSubtree(0, 0); var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name); - var memberFunction = transformFunctionLikeToExpression(member, member, undefined); + var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container); ts.setEmitFlags(memberFunction, 1536); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), member); + var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); ts.setEmitFlags(statement, 48); + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return statement; } - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), ts.getSourceMapRange(accessors.firstAccessor)); + function transformAccessorsToStatement(receiver, accessors, container) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, false)); ts.setEmitFlags(statement, 1536); + ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + var ancestorFacts = enterSubtree(0, 0); var target = ts.getMutableClone(receiver); ts.setEmitFlags(target, 1536 | 32); ts.setSourceMapRange(target, firstAccessor.name); @@ -42262,7 +43388,7 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); + var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); ts.setEmitFlags(getterFunction, 512); var getter = ts.createPropertyAssignment("get", getterFunction); @@ -42270,51 +43396,86 @@ var ts; properties.push(getter); } if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); + var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); ts.setEmitFlags(setterFunction, 512); var setter = ts.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } - properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); + properties.push(ts.createPropertyAssignment("enumerable", ts.createTrue()), ts.createPropertyAssignment("configurable", ts.createTrue())); var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ target, propertyName, - ts.createObjectLiteral(properties, undefined, true) + ts.createObjectLiteral(properties, true) ]); if (startsOnNewLine) { call.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return call; } function visitArrowFunction(node) { if (node.transformFlags & 16384) { enableSubstitutionsForCapturedThis(); } - var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node), node); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16256, 66); + var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + ts.setTextRange(func, node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8); + exitSubtree(ancestorFacts, 0, 0); + convertedLoopState = savedConvertedLoopState; return func; } function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + var ancestorFacts = ts.getEmitFlags(node) & 131072 + ? enterSubtree(16278, 69) + : enterSubtree(16286, 65); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionExpression(node, undefined, name, undefined, parameters, undefined, body); } function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286, 65); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, undefined, parameters, undefined, body); } - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 185) { - enclosingNonArrowFunction = node; + function transformFunctionLikeToExpression(node, location, name, container) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32) + ? enterSubtree(16286, 65 | 8) + : enterSubtree(16286, 65); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (hierarchyFacts & 16384 && !name && (node.kind === 227 || node.kind === 185)) { + name = ts.getGeneratedNameForNode(node); } - var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body), location), node); } function transformFunctionBody(node) { var multiLine = false; @@ -42342,7 +43503,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 185); + ts.Debug.assert(node.kind === 186); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -42354,17 +43515,20 @@ var ts; } } var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, body); + var returnStatement = ts.createReturn(expression); + ts.setTextRange(returnStatement, body); ts.setEmitFlags(returnStatement, 384 | 32 | 1024); statements.push(returnStatement); closeBraceLocation = body; } var lexicalEnvironment = context.endLexicalEnvironment(); ts.addRange(statements, lexicalEnvironment); + prependCaptureNewTargetIfNeeded(statements, node, false); if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), multiLine); + ts.setTextRange(block, node.body); if (!multiLine && singleLine) { ts.setEmitFlags(block, 1); } @@ -42374,11 +43538,26 @@ var ts; ts.setOriginalNode(block, node.body); return block; } + function visitFunctionBodyDownLevel(node) { + var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); + return ts.updateBlock(updated, ts.setTextRange(ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, true)), updated.statements)); + } + function visitBlock(node, isFunctionBody) { + if (isFunctionBody) { + return ts.visitEachChild(node, visitor, context); + } + var ancestorFacts = hierarchyFacts & 256 + ? enterSubtree(4032, 512) + : enterSubtree(3904, 128); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0, 0); + return updated; + } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 183: + case 184: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 192: + case 193: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -42386,9 +43565,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (!needsDestructuringValue) { switch (node.expression.kind) { - case 183: + case 184: return ts.updateParen(node, visitParenthesizedExpression(node.expression, false)); - case 192: + case 193: return ts.updateParen(node, visitBinaryExpression(node.expression, false)); } } @@ -42398,9 +43577,12 @@ var ts; if (ts.isDestructuringAssignment(node)) { return ts.flattenDestructuringAssignment(node, visitor, context, 0, needsDestructuringValue); } + return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3) == 0) { + var ancestorFacts = enterSubtree(0, ts.hasModifier(node, 1) ? 32 : 0); + var updated; + if (convertedLoopState && (node.declarationList.flags & 3) === 0) { var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; @@ -42417,49 +43599,55 @@ var ts; } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); + updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); })), node); } else { - return undefined; + updated = undefined; } } - return ts.visitEachChild(node, visitor, context); + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0, 0); + return updated; } function visitVariableDeclarationList(node) { - if (node.flags & 3) { - enableSubstitutionsForBlockScopedBindings(); + if (node.transformFlags & 64) { + if (node.flags & 3) { + enableSubstitutionsForBlockScopedBindings(); + } + var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + var declarationList = ts.createVariableDeclarationList(declarations); + ts.setOriginalNode(declarationList, node); + ts.setTextRange(declarationList, node); + ts.setCommentRange(declarationList, node); + if (node.transformFlags & 8388608 + && (ts.isBindingPattern(node.declarations[0].name) + || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + var firstDeclaration = ts.firstOrUndefined(declarations); + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } + return declarationList; } - var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, node); - ts.setOriginalNode(declarationList, node); - ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { - var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - } - return declarationList; + return ts.visitEachChild(node, visitor, context); } function shouldEmitExplicitInitializerForLetDeclaration(node) { var flags = resolver.getNodeCheckFlags(node); var isCapturedInFunction = flags & 131072; var isDeclaredInLoop = flags & 262144; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + var emittedAsTopLevel = (hierarchyFacts & 64) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); + && (hierarchyFacts & 512) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 212 - && enclosingBlockScopeContainer.kind !== 213 + && (hierarchyFacts & 2048) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, false))); + && (hierarchyFacts & (1024 | 2048)) === 0)); return emitExplicitInitializer; } function visitVariableDeclarationInLetDeclarationList(node) { @@ -42475,54 +43663,57 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableDeclaration(node) { + var ancestorFacts = enterSubtree(32, 0); + var updated; if (ts.isBindingPattern(node.name)) { - var hoistTempVariables = enclosingVariableStatement - && ts.hasModifier(enclosingVariableStatement, 1); - return ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, hoistTempVariables); - } - return ts.visitEachChild(node, visitor, context); - } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; - } - var result; - if (ts.isIterationStatement(node.statement, false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, (ancestorFacts & 32) !== 0); } else { - result = ts.visitEachChild(node, visitor, context); + updated = ts.visitEachChild(node, visitor, context); } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + exitSubtree(ancestorFacts, 0, 0); + return updated; + } + function recordLabel(node) { + convertedLoopState.labels.set(node.label.text, node.label.text); + } + function resetLabel(node) { + convertedLoopState.labels.set(node.label.text, undefined); + } + function visitLabeledStatement(node) { + if (convertedLoopState && !convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); } - return result; + var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, false) && shouldConvertIterationStatementBody(statement) + ? visitIterationStatement(statement, node) + : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { + var ancestorFacts = enterSubtree(excludeFacts, includeFacts); + var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); + exitSubtree(ancestorFacts, 0, 0); + return updated; } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitDoOrWhileStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(0, 256, node, outermostLabeledStatement); } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(3008, 1280, node, outermostLabeledStatement); } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForInStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement); } - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function visitForOfStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement, convertForOfToFor); } - function convertForOfToFor(node, convertedLoopBodyStatements) { + function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var initializer = node.initializer; var statements = []; var counter = ts.createLoopVariable(); var rhsReference = expression.kind === 70 - ? ts.createUniqueName(expression.text) + ? ts.createUniqueName(ts.unescapeIdentifier(expression.text)) : ts.createTempVariable(undefined); var elementAccess = ts.createElementAccess(rhsReference, counter); if (ts.isVariableDeclarationList(initializer)) { @@ -42532,17 +43723,18 @@ var ts; var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, elementAccess); - var declarationList = ts.createVariableDeclarationList(declarations, initializer); + var declarationList = ts.createVariableDeclarationList(declarations); ts.setOriginalNode(declarationList, initializer); + ts.setTextRange(declarationList, initializer); var firstDeclaration = declarations[0]; var lastDeclaration = ts.lastOrUndefined(declarations); ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); statements.push(ts.createVariableStatement(undefined, declarationList)); } else { - statements.push(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.createVariableDeclarationList([ + statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, ts.createElementAccess(rhsReference, counter)) - ], ts.moveRangePos(initializer, -1)), initializer), ts.moveRangeEnd(initializer, -1))); + ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); } } else { @@ -42552,7 +43744,7 @@ var ts; } else { assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createStatement(assignment), ts.moveRangeEnd(initializer, -1))); } } var bodyLocation; @@ -42561,7 +43753,7 @@ var ts; ts.addRange(statements, convertedLoopBodyStatements); } else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + var statement = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -42572,38 +43764,62 @@ var ts; } } ts.setEmitFlags(expression, 48 | ts.getEmitFlags(expression)); - var body = ts.createBlock(ts.createNodeArray(statements, statementsLocation), bodyLocation); + var body = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation)); + ts.setTextRange(body, bodyLocation); ts.setEmitFlags(body, 48 | 384); - var forStatement = ts.createFor(ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0), ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) - ], node.expression), 1048576), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); + var forStatement = ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)), + ts.setTextRange(ts.createVariableDeclaration(rhsReference, undefined, expression), node.expression) + ]), node.expression), 1048576), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), body); ts.setEmitFlags(forStatement, 256); - return forStatement; + ts.setTextRange(forStatement, node); + return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); + } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 211: + case 212: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 213: + return visitForStatement(node, outermostLabeledStatement); + case 214: + return visitForInStatement(node, outermostLabeledStatement); + case 215: + return visitForOfStatement(node, outermostLabeledStatement); + } } function visitObjectLiteralExpression(node) { var properties = node.properties; var numProperties = properties.length; var numInitialProperties = numProperties; + var numInitialPropertiesWithoutYield = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 - || property.name.kind === 142) { + if ((property.transformFlags & 16777216 && hierarchyFacts & 4) + && i < numInitialPropertiesWithoutYield) { + numInitialPropertiesWithoutYield = i; + } + if (property.name.kind === 143) { numInitialProperties = i; break; } } - ts.Debug.assert(numInitialProperties !== numProperties); - var temp = ts.createTempVariable(hoistVariableDeclaration); - var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); - if (node.multiLine) { - assignment.startsOnNewLine = true; + if (numInitialProperties !== numProperties) { + if (numInitialPropertiesWithoutYield < numInitialProperties) { + numInitialProperties = numInitialPropertiesWithoutYield; + } + var temp = ts.createTempVariable(hoistVariableDeclaration); + var expressions = []; + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 32768)); + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + expressions.push(assignment); + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); + return ts.inlineExpressions(expressions); } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); + return ts.visitEachChild(node, visitor, context); } function shouldConvertIterationStatementBody(node) { return (resolver.getNodeCheckFlags(node) & 65536) !== 0; @@ -42627,14 +43843,16 @@ var ts; } } } - function convertIterationStatementBodyIfNecessary(node, convert) { + function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) { if (!shouldConvertIterationStatementBody(node)) { var saveAllowedNonLabeledJumps = void 0; if (convertedLoopState) { saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; convertedLoopState.allowedNonLabeledJumps = 2 | 4; } - var result = convert ? convert(node, undefined) : ts.visitEachChild(node, visitor, context); + var result = convert + ? convert(node, outermostLabeledStatement, undefined) + : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel); if (convertedLoopState) { convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } @@ -42643,11 +43861,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 211: - case 212: case 213: + case 214: + case 215: var initializer = node.initializer; - if (initializer && initializer.kind === 224) { + if (initializer && initializer.kind === 226) { loopInitializer = initializer; } break; @@ -42674,7 +43892,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -42684,13 +43902,15 @@ var ts; copyOutParameters(loopOutParameters, 1, statements_4); } ts.addRange(statements_4, lexicalEnvironment); - loopBody = ts.createBlock(statements_4, undefined, true); + loopBody = ts.createBlock(statements_4, true); } - if (!ts.isBlock(loopBody)) { - loopBody = ts.createBlock([loopBody], undefined, true); + if (ts.isBlock(loopBody)) { + loopBody.multiLine = true; } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 131072) !== 0 + else { + loopBody = ts.createBlock([loopBody], true); + } + var isAsyncBlockContainingAwait = hierarchyFacts & 4 && (node.statement.transformFlags & 16777216) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -42749,19 +43969,18 @@ var ts; var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); var loop; if (convert) { - loop = convert(node, convertedLoopBodyStatements); + loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); } else { - loop = ts.getMutableClone(node); - loop.statement = undefined; - loop = ts.visitEachChild(loop, visitor, context); - loop.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); + var clone_4 = ts.getMutableClone(node); + clone_4.statement = undefined; + clone_4 = ts.visitEachChild(clone_4, visitor, context); + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, true); + clone_4.transformFlags = 0; + ts.aggregateTransformFlags(clone_4); + loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } - statements.push(currentParent.kind === 219 - ? ts.createLabel(currentParent.label, loop) - : loop); + statements.push(loop); return statements; } function copyOutParameter(outParam, copyDirection) { @@ -42820,23 +44039,22 @@ var ts; if (!state.labeledNonLocalBreaks) { state.labeledNonLocalBreaks = ts.createMap(); } - state.labeledNonLocalBreaks[labelText] = labelMarker; + state.labeledNonLocalBreaks.set(labelText, labelMarker); } else { if (!state.labeledNonLocalContinues) { state.labeledNonLocalContinues = ts.createMap(); } - state.labeledNonLocalContinues[labelText] = labelMarker; + state.labeledNonLocalContinues.set(labelText, labelMarker); } } function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { if (!table) { return; } - for (var labelText in table) { - var labelMarker = table[labelText]; + table.forEach(function (labelMarker, labelText) { var statements = []; - if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { + if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) { var label = ts.createIdentifier(labelText); statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); } @@ -42845,7 +44063,7 @@ var ts; statements.push(ts.createReturn(loopResultName)); } caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); - } + }); } function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { var name = decl.name; @@ -42860,7 +44078,7 @@ var ts; else { loopParameters.push(ts.createParameter(undefined, undefined, undefined, name)); if (resolver.getNodeCheckFlags(decl) & 2097152) { - var outParamName = ts.createUniqueName("out_" + name.text); + var outParamName = ts.createUniqueName("out_" + ts.unescapeIdentifier(name.text)); loopOutParameters.push({ originalName: name, outParamName: outParamName }); } } @@ -42871,22 +44089,22 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 151: case 152: + case 153: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 257: + case 150: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); + break; + case 260: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 258: + case 261: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 149: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); - break; default: ts.Debug.failBadSyntaxKind(node); break; @@ -42894,34 +44112,49 @@ var ts; } } function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } return expression; } function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } return expression; } - function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined), method); + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { + var ancestorFacts = enterSubtree(0, 0); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container)); + ts.setTextRange(expression, method); if (startsOnNewLine) { expression.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return expression; } function visitCatchClause(node) { - ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); - var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); - var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); - var destructure = ts.createVariableStatement(undefined, list); - return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + var ancestorFacts = enterSubtree(4032, 0); + var updated; + if (ts.isBindingPattern(node.variableDeclaration.name)) { + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp); + ts.setTextRange(newVariableDeclaration, node.variableDeclaration); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); + var list = ts.createVariableDeclarationList(vars); + ts.setTextRange(list, node.variableDeclaration); + var destructure = ts.createVariableStatement(undefined, list); + updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0, 0); + return updated; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); @@ -42929,21 +44162,43 @@ var ts; } function visitMethodDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); + var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined); ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression)); - return ts.createPropertyAssignment(node.name, functionExpression, node); + return ts.setTextRange(ts.createPropertyAssignment(node.name, functionExpression), node); + } + function visitAccessorDeclaration(node) { + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286, 65); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return updated; } function visitShorthandPropertyAssignment(node) { - return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), node); + return ts.setTextRange(ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name)), node); + } + function visitComputedPropertyName(node) { + var ancestorFacts = enterSubtree(0, 8192); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 32768 : 0); + return updated; } function visitYieldExpression(node) { return ts.visitEachChild(node, visitor, context); } function visitArrayLiteralExpression(node) { - return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + if (node.transformFlags & 64) { + return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + } + return ts.visitEachChild(node, visitor, context); } function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + if (node.transformFlags & 64) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + } + return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); } function visitImmediateSuperCallInBody(node) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, false); @@ -42955,25 +44210,27 @@ var ts; } var resultingCall; if (node.transformFlags & 524288) { - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } if (node.expression.kind === 96) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4); var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis + resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createIdentifier("_this"), initializer) : initializer; } - return resultingCall; + return ts.setOriginalNode(resultingCall, node); } function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 524288) !== 0); - var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + if (node.transformFlags & 524288) { + var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + } + return ts.visitEachChild(node, visitor, context); } function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { var numElements = elements.length; @@ -42982,7 +44239,7 @@ var ts; })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 175 + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 176 ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -42997,7 +44254,7 @@ var ts; return ts.map(chunk, visitExpressionOfSpread); } function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) { - return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, undefined, hasTrailingComma), visitor, ts.isExpression), undefined, multiLine); + return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -43006,7 +44263,7 @@ var ts; return ts.visitNode(node.expression, visitor, ts.isExpression); } function visitTemplateLiteral(node) { - return ts.createLiteral(node.text, node); + return ts.setTextRange(ts.createLiteral(node.text), node); } function visitTaggedTemplateExpression(node) { var tag = ts.visitNode(node.tag, visitor, ts.isExpression); @@ -43040,7 +44297,7 @@ var ts; var isLast = node.kind === 12 || node.kind === 15; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); - return ts.createLiteral(text, node); + return ts.setTextRange(ts.createLiteral(text), node); } function visitTemplateExpression(node) { var expressions = []; @@ -43048,7 +44305,8 @@ var ts; addTemplateSpans(expressions, node); var expression = ts.reduceLeft(expressions, ts.createAdd); if (ts.nodeIsSynthesized(expression)) { - ts.setTextRange(expression, node); + expression.pos = node.pos; + expression.end = node.end; } return expression; } @@ -43071,21 +44329,34 @@ var ts; } } } - function visitSuperKeyword() { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 179 + function visitSuperKeyword(isExpressionOfCall) { + return hierarchyFacts & 8 + && !isExpressionOfCall ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } - function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; - if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { - enclosingFunction = node; + function visitMetaProperty(node) { + if (node.keywordToken === 93 && node.name.text === "target") { + if (hierarchyFacts & 8192) { + hierarchyFacts |= 32768; + } + else { + hierarchyFacts |= 16384; + } + return ts.createIdentifier("_newTarget"); } - previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; + return node; + } + function onEmitNode(hint, node, emitCallback) { + if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { + var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8 + ? 65 | 16 + : 65); + previousOnEmitNode(hint, node, emitCallback); + exitSubtree(ancestorFacts, 0, 0); + return; + } + previousOnEmitNode(hint, node, emitCallback); } function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { @@ -43097,18 +44368,18 @@ var ts; if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; context.enableSubstitution(98); - context.enableEmitNotification(150); - context.enableEmitNotification(149); context.enableEmitNotification(151); + context.enableEmitNotification(150); context.enableEmitNotification(152); + context.enableEmitNotification(153); + context.enableEmitNotification(186); context.enableEmitNotification(185); - context.enableEmitNotification(184); - context.enableEmitNotification(225); + context.enableEmitNotification(227); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -43128,10 +44399,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 174: - case 226: - case 229: - case 223: + case 175: + case 228: + case 231: + case 225: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -43157,9 +44428,8 @@ var ts; } function substituteThisKeyword(node) { if (enabledSubstitutions & 1 - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 8) { - return ts.createIdentifier("_this", node); + && hierarchyFacts & 16) { + return ts.setTextRange(ts.createIdentifier("_this"), node); } return node; } @@ -43175,11 +44445,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 207) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 209) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 179) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 180) { return false; } var callTarget = statementExpression.expression; @@ -43187,7 +44457,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 196) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 197) { return false; } var expression = callArgument.expression; @@ -43206,18 +44476,65 @@ var ts; name: "typescript:extends", scoped: false, priority: 0, - text: "\n var __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 };" + text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; })(ts || (ts = {})); var ts; (function (ts) { - var instructionNames = ts.createMap((_a = {}, - _a[2] = "return", - _a[3] = "break", - _a[4] = "yield", - _a[5] = "yield*", - _a[7] = "endfinally", - _a)); + var OpCode; + (function (OpCode) { + OpCode[OpCode["Nop"] = 0] = "Nop"; + OpCode[OpCode["Statement"] = 1] = "Statement"; + OpCode[OpCode["Assign"] = 2] = "Assign"; + OpCode[OpCode["Break"] = 3] = "Break"; + OpCode[OpCode["BreakWhenTrue"] = 4] = "BreakWhenTrue"; + OpCode[OpCode["BreakWhenFalse"] = 5] = "BreakWhenFalse"; + OpCode[OpCode["Yield"] = 6] = "Yield"; + OpCode[OpCode["YieldStar"] = 7] = "YieldStar"; + OpCode[OpCode["Return"] = 8] = "Return"; + OpCode[OpCode["Throw"] = 9] = "Throw"; + OpCode[OpCode["Endfinally"] = 10] = "Endfinally"; + })(OpCode || (OpCode = {})); + var BlockAction; + (function (BlockAction) { + BlockAction[BlockAction["Open"] = 0] = "Open"; + BlockAction[BlockAction["Close"] = 1] = "Close"; + })(BlockAction || (BlockAction = {})); + var CodeBlockKind; + (function (CodeBlockKind) { + CodeBlockKind[CodeBlockKind["Exception"] = 0] = "Exception"; + CodeBlockKind[CodeBlockKind["With"] = 1] = "With"; + CodeBlockKind[CodeBlockKind["Switch"] = 2] = "Switch"; + CodeBlockKind[CodeBlockKind["Loop"] = 3] = "Loop"; + CodeBlockKind[CodeBlockKind["Labeled"] = 4] = "Labeled"; + })(CodeBlockKind || (CodeBlockKind = {})); + var ExceptionBlockState; + (function (ExceptionBlockState) { + ExceptionBlockState[ExceptionBlockState["Try"] = 0] = "Try"; + ExceptionBlockState[ExceptionBlockState["Catch"] = 1] = "Catch"; + ExceptionBlockState[ExceptionBlockState["Finally"] = 2] = "Finally"; + ExceptionBlockState[ExceptionBlockState["Done"] = 3] = "Done"; + })(ExceptionBlockState || (ExceptionBlockState = {})); + var Instruction; + (function (Instruction) { + Instruction[Instruction["Next"] = 0] = "Next"; + Instruction[Instruction["Throw"] = 1] = "Throw"; + Instruction[Instruction["Return"] = 2] = "Return"; + Instruction[Instruction["Break"] = 3] = "Break"; + Instruction[Instruction["Yield"] = 4] = "Yield"; + Instruction[Instruction["YieldStar"] = 5] = "YieldStar"; + Instruction[Instruction["Catch"] = 6] = "Catch"; + Instruction[Instruction["Endfinally"] = 7] = "Endfinally"; + })(Instruction || (Instruction = {})); + function getInstructionName(instruction) { + switch (instruction) { + case 2: return "return"; + case 3: return "break"; + case 4: return "yield"; + case 5: return "yield*"; + case 7: return "endfinally"; + } + } function transformGenerators(context) { var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); @@ -43283,13 +44600,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 209: + case 211: return visitDoStatement(node); - case 210: + case 212: return visitWhileStatement(node); - case 218: + case 220: return visitSwitchStatement(node); - case 219: + case 221: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -43297,24 +44614,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 225: + case 227: return visitFunctionDeclaration(node); - case 184: + case 185: return visitFunctionExpression(node); - case 151: case 152: + case 153: return visitAccessorDeclaration(node); - case 205: + case 207: return visitVariableStatement(node); - case 211: + case 213: return visitForStatement(node); - case 212: - return visitForInStatement(node); - case 215: - return visitBreakStatement(node); case 214: - return visitContinueStatement(node); + return visitForInStatement(node); + case 217: + return visitBreakStatement(node); case 216: + return visitContinueStatement(node); + case 218: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -43330,21 +44647,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 192: - return visitBinaryExpression(node); case 193: + return visitBinaryExpression(node); + case 194: return visitConditionalExpression(node); - case 195: + case 196: return visitYieldExpression(node); - case 175: - return visitArrayLiteralExpression(node); case 176: + return visitArrayLiteralExpression(node); + case 177: return visitObjectLiteralExpression(node); - case 178: - return visitElementAccessExpression(node); case 179: - return visitCallExpression(node); + return visitElementAccessExpression(node); case 180: + return visitCallExpression(node); + case 181: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -43352,9 +44669,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 225: + case 227: return visitFunctionDeclaration(node); - case 184: + case 185: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -43363,7 +44680,7 @@ var ts; } function visitFunctionDeclaration(node) { if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { - node = ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body), node), node); + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration(undefined, node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -43384,7 +44701,7 @@ var ts; } function visitFunctionExpression(node) { if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { - node = ts.setOriginalNode(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body), node), node); + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -43454,7 +44771,7 @@ var ts; operationArguments = savedOperationArguments; operationLocations = savedOperationLocations; state = savedState; - return ts.createBlock(statements, body, body.multiLine); + return ts.setTextRange(ts.createBlock(statements, body.multiLine), body); } function visitVariableStatement(node) { if (node.transformFlags & 16777216) { @@ -43511,10 +44828,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 177: + case 178: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 178: + case 179: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -43523,7 +44840,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 57, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.setTextRange(ts.createAssignment(target, ts.setTextRange(ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression)), node)), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -43539,10 +44856,10 @@ var ts; else if (node.operatorToken.kind === 25) { return visitCommaExpression(node); } - var clone_4 = ts.getMutableClone(node); - clone_4.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_4.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_4; + var clone_5 = ts.getMutableClone(node); + clone_5.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_5.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_5; } return ts.visitEachChild(node, visitor, context); } @@ -43604,7 +44921,7 @@ var ts; emitYield(expression, node); } markLabel(resumeLabel); - return createGeneratorResume(); + return createGeneratorResume(node); } function visitArrayLiteralExpression(node) { return visitElements(node.elements, undefined, undefined, node.multiLine); @@ -43622,13 +44939,13 @@ var ts; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, location, multiLine); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { emitAssignment(temp, hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, undefined, multiLine)); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); hasAssignedTemp = true; leadingElement = undefined; expressions = []; @@ -43642,7 +44959,7 @@ var ts; var multiLine = node.multiLine; var numInitialProperties = countInitialNodesWithoutYield(properties); var temp = declareLocal(); - emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, multiLine)); + emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), multiLine)); var expressions = ts.reduceLeft(properties, reduceProperty, [], numInitialProperties); expressions.push(multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); return ts.inlineExpressions(expressions); @@ -43664,10 +44981,10 @@ var ts; } function visitElementAccessExpression(node) { if (containsYield(node.argumentExpression)) { - var clone_5 = ts.getMutableClone(node); - clone_5.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_5.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_5; + var clone_6 = ts.getMutableClone(node); + clone_6.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_6.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -43681,7 +44998,7 @@ var ts; function visitNewExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, ts.createVoidZero())), undefined, [], node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, ts.createVoidZero())), undefined, []), node), node); } return ts.visitEachChild(node, visitor, context); } @@ -43710,35 +45027,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 204: + case 206: return transformAndEmitBlock(node); - case 207: - return transformAndEmitExpressionStatement(node); - case 208: - return transformAndEmitIfStatement(node); case 209: - return transformAndEmitDoStatement(node); + return transformAndEmitExpressionStatement(node); case 210: - return transformAndEmitWhileStatement(node); + return transformAndEmitIfStatement(node); case 211: - return transformAndEmitForStatement(node); + return transformAndEmitDoStatement(node); case 212: - return transformAndEmitForInStatement(node); + return transformAndEmitWhileStatement(node); + case 213: + return transformAndEmitForStatement(node); case 214: - return transformAndEmitContinueStatement(node); - case 215: - return transformAndEmitBreakStatement(node); + return transformAndEmitForInStatement(node); case 216: - return transformAndEmitReturnStatement(node); + return transformAndEmitContinueStatement(node); case 217: - return transformAndEmitWithStatement(node); + return transformAndEmitBreakStatement(node); case 218: - return transformAndEmitSwitchStatement(node); + return transformAndEmitReturnStatement(node); case 219: - return transformAndEmitLabeledStatement(node); + return transformAndEmitWithStatement(node); case 220: - return transformAndEmitThrowStatement(node); + return transformAndEmitSwitchStatement(node); case 221: + return transformAndEmitLabeledStatement(node); + case 222: + return transformAndEmitThrowStatement(node); + case 223: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -43758,7 +45075,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - hoistVariableDeclaration(variable.name); + var name = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name, variable.name); + hoistVariableDeclaration(name); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -43788,7 +45107,7 @@ var ts; if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) { var endLabel = defineLabel(); var elseLabel = node.elseStatement ? defineLabel() : undefined; - emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression)); + emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), node.expression); transformAndEmitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { emitBreak(endLabel); @@ -43867,7 +45186,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression), initializer)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -43877,7 +45196,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression), node.incrementor)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -44022,7 +45341,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 254 && defaultClauseIndex === -1) { + if (clause.kind === 257 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -44032,7 +45351,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 253) { + if (clause.kind === 256) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -44134,9 +45453,9 @@ var ts; } return -1; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } return node; @@ -44148,17 +45467,17 @@ var ts; return node; } function substituteExpressionIdentifier(node) { - if (renamedCatchVariables && ts.hasProperty(renamedCatchVariables, node.text)) { + if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { var original = ts.getOriginalNode(node); if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_39 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_39) { - var clone_6 = ts.getMutableClone(name_39); - ts.setSourceMapRange(clone_6, node); - ts.setCommentRange(clone_6, node); - return clone_6; + var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; + if (name) { + var clone_7 = ts.getMutableClone(name); + ts.setSourceMapRange(clone_7, node); + ts.setCommentRange(clone_7, node); + return clone_7; } } } @@ -44263,10 +45582,10 @@ var ts; var name = declareLocal(text); if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); - renamedCatchVariableDeclarations = ts.createMap(); + renamedCatchVariableDeclarations = []; context.enableSubstitution(70); } - renamedCatchVariables[text] = true; + renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; var exception = peekBlock(); ts.Debug.assert(exception.state < 1); @@ -44467,23 +45786,23 @@ var ts; } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); - literal.trailingComment = instructionNames[instruction]; + literal.trailingComment = getInstructionName(instruction); return literal; } function createInlineBreak(label, location) { ts.Debug.assert(label > 0, "Invalid label: " + label); - return ts.createReturn(ts.createArrayLiteral([ + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), location); + ])), location); } function createInlineReturn(expression, location) { - return ts.createReturn(ts.createArrayLiteral(expression + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2), expression] - : [createInstruction(2)]), location); + : [createInstruction(2)])), location); } function createGeneratorResume(location) { - return ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, [], location); + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, []), location); } function emitNop() { emitWorker(0); @@ -44549,7 +45868,7 @@ var ts; currentExceptionBlock = undefined; withBlockStack = undefined; var buildResult = buildStatements(); - return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 262144)); + return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, buildResult.length > 0)), 262144)); } function buildStatements() { if (operations) { @@ -44758,51 +46077,51 @@ var ts; } } function writeAssign(left, right, operationLocation) { - writeStatement(ts.createStatement(ts.createAssignment(left, right), operationLocation)); + writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); } function writeThrow(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createThrow(expression, operationLocation)); + writeStatement(ts.setTextRange(ts.createThrow(expression), operationLocation)); } function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2), expression] - : [createInstruction(2)]), operationLocation)); + : [createInstruction(2)])), operationLocation), 384)); } function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation)); + ])), operationLocation), 384)); } function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation))); + ])), operationLocation), 384)), 1)); } function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation))); + ])), operationLocation), 384)), 1)); } function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4), expression] - : [createInstruction(4)]), operationLocation)); + : [createInstruction(4)])), operationLocation), 384)); } function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(5), expression - ]), operationLocation)); + ])), operationLocation), 384)); } function writeEndfinally() { lastOperationWasAbrupt = true; @@ -44822,21 +46141,45 @@ var ts; priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; - var _a; })(ts || (ts = {})); var ts; (function (ts) { function transformES5(context) { + var compilerOptions = context.getCompilerOptions(); + var previousOnEmitNode; + var noSubstitution; + if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) { + previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.enableEmitNotification(250); + context.enableEmitNotification(251); + context.enableEmitNotification(249); + noSubstitution = []; + } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(177); - context.enableSubstitution(257); + context.enableSubstitution(178); + context.enableSubstitution(260); return transformSourceFile; function transformSourceFile(node) { return node; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); + function onEmitNode(hint, node, emitCallback) { + switch (node.kind) { + case 250: + case 251: + case 249: + var tagName = node.tagName; + noSubstitution[ts.getOriginalNodeId(tagName)] = true; + break; + } + previousOnEmitNode(hint, node, emitCallback); + } + function onSubstituteNode(hint, node) { + if (node.id && noSubstitution && noSubstitution[node.id]) { + return previousOnSubstituteNode(hint, node); + } + node = previousOnSubstituteNode(hint, node); if (ts.isPropertyAccessExpression(node)) { return substitutePropertyAccessExpression(node); } @@ -44848,7 +46191,7 @@ var ts; function substitutePropertyAccessExpression(node) { var literalName = trySubstituteReservedName(node.name); if (literalName) { - return ts.createElementAccess(node.expression, literalName, node); + return ts.setTextRange(ts.createElementAccess(node.expression, literalName), node); } return node; } @@ -44862,7 +46205,7 @@ var ts; function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); if (token >= 71 && token <= 106) { - return ts.createLiteral(name, name); + return ts.setTextRange(ts.createLiteral(name), name); } return undefined; } @@ -44872,12 +46215,13 @@ var ts; var ts; (function (ts) { function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); + function getTransformModuleDelegate(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.AMD: return transformAMDModule; + case ts.ModuleKind.UMD: return transformUMDModule; + default: return transformCommonJSModule; + } + } var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); @@ -44889,13 +46233,13 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(70); - context.enableSubstitution(192); - context.enableSubstitution(190); + context.enableSubstitution(193); context.enableSubstitution(191); - context.enableSubstitution(258); - context.enableEmitNotification(261); - var moduleInfoMap = ts.createMap(); - var deferredExports = ts.createMap(); + context.enableSubstitution(192); + context.enableSubstitution(261); + context.enableEmitNotification(264); + var moduleInfoMap = []; + var deferredExports = []; var currentSourceFile; var currentModuleInfo; var noSubstitution; @@ -44907,8 +46251,9 @@ var ts; return node; } currentSourceFile = node; - currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(node)] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); - var transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; + currentModuleInfo = ts.collectExternalModuleInfo(node, resolver, compilerOptions); + moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo; + var transformModule = getTransformModuleDelegate(moduleKind); var updated = transformModule(node); currentSourceFile = undefined; currentModuleInfo = undefined; @@ -44918,11 +46263,14 @@ var ts; startLexicalEnvironment(); var statements = []; var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, false); - var updated = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); if (currentModuleInfo.hasExportStarsToExportValues) { ts.addEmitHelper(updated, exportStarHelper); } @@ -44931,15 +46279,8 @@ var ts; function transformAMDModule(node) { var define = ts.createIdentifier("define"); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, true); - } - function transformUMDModule(node) { - var define = ts.createRawExpression(umdHelper); - return transformAsynchronousModule(node, define, undefined, false); - } - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - return ts.updateSourceFileNode(node, ts.createNodeArray([ + var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), @@ -44950,7 +46291,37 @@ var ts; ts.createParameter(undefined, undefined, undefined, "exports") ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) ]))) - ], node.statements)); + ]), node.statements)); + } + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.setTextRange(ts.createBlock([ + ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ + ts.createVariableStatement(undefined, [ + ts.createVariableDeclaration("v", undefined, ts.createCall(ts.createIdentifier("factory"), undefined, [ + ts.createIdentifier("require"), + ts.createIdentifier("exports") + ])) + ]), + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1) + ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), undefined, [ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createIdentifier("factory") + ])) + ]))) + ], true), undefined)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ + ts.createStatement(ts.createCall(umdHeader, undefined, [ + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter(undefined, undefined, undefined, "require"), + ts.createParameter(undefined, undefined, undefined, "exports") + ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ])) + ]), node.statements)); } function collectAsynchronousDependencies(node, includeNonAmdDependencies) { var aliasedModuleNames = []; @@ -44985,11 +46356,14 @@ var ts; startLexicalEnvironment(); var statements = []; var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, true); - var body = ts.createBlock(statements, undefined, true); + var body = ts.createBlock(statements, true); if (currentModuleInfo.hasExportStarsToExportValues) { ts.addEmitHelper(body, exportStarHelper); } @@ -44998,12 +46372,14 @@ var ts; function addExportEqualsIfNeeded(statements, emitAsReturn) { if (currentModuleInfo.exportEquals) { if (emitAsReturn) { - var statement = ts.createReturn(currentModuleInfo.exportEquals.expression, currentModuleInfo.exportEquals); + var statement = ts.createReturn(currentModuleInfo.exportEquals.expression); + ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 384 | 1536); statements.push(statement); } else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression), currentModuleInfo.exportEquals); + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression)); + ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 1536); statements.push(statement); } @@ -45011,23 +46387,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 235: + case 237: return visitImportDeclaration(node); - case 234: + case 236: return visitImportEqualsDeclaration(node); - case 241: + case 243: return visitExportDeclaration(node); - case 240: + case 242: return visitExportAssignment(node); - case 205: + case 207: return visitVariableStatement(node); - case 225: + case 227: return visitFunctionDeclaration(node); - case 226: + case 228: return visitClassDeclaration(node); - case 295: + case 299: return visitMergeDeclarationMarker(node); - case 296: + case 300: return visitEndOfDeclarationMarker(node); default: return node; @@ -45038,7 +46414,7 @@ var ts; var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (moduleKind !== ts.ModuleKind.AMD) { if (!node.importClause) { - return ts.createStatement(createRequireCall(node), node); + return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); } else { var variables = []; @@ -45051,13 +46427,13 @@ var ts; variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node))); } } - statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, undefined, languageVersion >= 2 ? 2 : 0), node)); + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, languageVersion >= 2 ? 2 : 0)), node)); } } else if (namespaceDeclaration && ts.isDefaultImport(node)) { statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node), node) - ], undefined, languageVersion >= 2 ? 2 : 0))); + ts.setTextRange(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node)), node) + ], languageVersion >= 2 ? 2 : 0))); } if (hasAssociatedEndOfDeclarationMarker(node)) { var id = ts.getOriginalNodeId(node); @@ -45081,17 +46457,17 @@ var ts; var statements; if (moduleKind !== ts.ModuleKind.AMD) { if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(node.name, createRequireCall(node)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(node.name, createRequireCall(node))), node)); } else { - statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node)) - ], undefined, languageVersion >= 2 ? 2 : 0), node)); + ], languageVersion >= 2 ? 2 : 0)), node)); } } else { if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); } } if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -45111,23 +46487,23 @@ var ts; if (node.exportClause) { var statements = []; if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(generatedName, undefined, createRequireCall(node)) - ]), node)); + ])), node)); } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue), specifier)); + statements.push(ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); } return ts.singleOrMany(statements); } else { - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ + return ts.setTextRange(ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName - ]), node); + ])), node); } } function visitExportAssignment(node) { @@ -45148,7 +46524,7 @@ var ts; function visitFunctionDeclaration(node) { var statements; if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, node.parameters, undefined, node.body, node), node)); + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, node.parameters, undefined, node.body), node), node)); } else { statements = ts.append(statements, node); @@ -45165,7 +46541,7 @@ var ts; function visitClassDeclaration(node) { var statements; if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, node.heritageClauses, node.members, node), node)); + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, node.heritageClauses, node.members), node), node)); } else { statements = ts.append(statements, node); @@ -45201,7 +46577,7 @@ var ts; statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); } if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); } } else { @@ -45221,11 +46597,11 @@ var ts; return ts.flattenDestructuringAssignment(node, undefined, context, 0, false, createExportExpression); } else { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name, node.name), node.initializer); + return ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name), node.name), node.initializer); } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -45257,10 +46633,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237: + case 239: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238: + case 240: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -45318,7 +46694,7 @@ var ts; } function appendExportsOfDeclaration(statements, decl) { var name = ts.getDeclarationName(decl); - var exportSpecifiers = currentModuleInfo.exportSpecifiers[name.text]; + var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { var exportSpecifier = exportSpecifiers_1[_i]; @@ -45328,28 +46704,28 @@ var ts; return statements; } function appendExportStatement(statements, exportName, expression, location, allowComments) { - if (exportName.text === "default") { - var sourceFile = ts.getOriginalNode(currentSourceFile, ts.isSourceFile); - if (sourceFile && !sourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 0) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); - } - else { - statements = ts.append(statements, ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); - } - } - } statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); return statements; } + function createUnderscoreUnderscoreESModule() { + var statement; + if (languageVersion === 0) { + statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true))); + } + else { + statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ])); + } + ts.setEmitFlags(statement, 524288); + return statement; + } function createExportStatement(name, value, location, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value), location); + var statement = ts.setTextRange(ts.createStatement(createExportExpression(name, value)), location); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536); @@ -45357,7 +46733,7 @@ var ts; return statement; } function createExportExpression(name, value, location) { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value, location); + return ts.setTextRange(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value), location); } function modifierVisitor(node) { switch (node.kind) { @@ -45367,26 +46743,26 @@ var ts; } return node; } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261) { + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; - noSubstitution = ts.createMap(); - previousOnEmitNode(emitContext, node, emitCallback); + noSubstitution = []; + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; currentModuleInfo = undefined; noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); if (node.id && noSubstitution[node.id]) { return node; } - if (emitContext === 1) { + if (hint === 1) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -45400,9 +46776,9 @@ var ts; if (exportedOrImportedName !== name) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, node); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); } - return ts.createPropertyAssignment(name, exportedOrImportedName, node); + return ts.setTextRange(ts.createPropertyAssignment(name, exportedOrImportedName), node); } return node; } @@ -45410,10 +46786,10 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 192: + case 193: return substituteBinaryExpression(node); + case 192: case 191: - case 190: return substituteUnaryExpression(node); } return node; @@ -45428,17 +46804,17 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 261) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); + if (exportContainer && exportContainer.kind === 264) { + return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_40 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_40), node); + var name = importDeclaration.propertyName || importDeclaration.name; + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name)), node); } } } @@ -45471,8 +46847,8 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 191 - ? ts.createBinary(node.operand, ts.createToken(node.operator === 42 ? 58 : 59), ts.createLiteral(1), node) + var expression = node.kind === 192 + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 42 ? 58 : 59), ts.createLiteral(1)), node) : node; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { var exportName = exportedNames_2[_i]; @@ -45494,7 +46870,6 @@ var ts; } } } - var _a; } ts.transformModule = transformModule; var exportStarHelper = { @@ -45502,7 +46877,6 @@ var ts; scoped: true, text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" }; - var umdHelper = "\n (function (dependencies, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(dependencies, factory);\n }\n })"; })(ts || (ts = {})); var ts; (function (ts) { @@ -45516,14 +46890,14 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(70); - context.enableSubstitution(192); - context.enableSubstitution(190); + context.enableSubstitution(193); context.enableSubstitution(191); - context.enableEmitNotification(261); - var moduleInfoMap = ts.createMap(); - var deferredExports = ts.createMap(); - var exportFunctionsMap = ts.createMap(); - var noSubstitutionMap = ts.createMap(); + context.enableSubstitution(192); + context.enableEmitNotification(264); + var moduleInfoMap = []; + var deferredExports = []; + var exportFunctionsMap = []; + var noSubstitutionMap = []; var currentSourceFile; var moduleInfo; var exportFunction; @@ -45542,7 +46916,8 @@ var ts; currentSourceFile = node; enclosingBlockScopedContainer = node; moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); - exportFunction = exportFunctionsMap[id] = ts.createUniqueName("exports"); + exportFunction = ts.createUniqueName("exports"); + exportFunctionsMap[id] = exportFunction; contextObject = ts.createUniqueName("context"); var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); @@ -45552,11 +46927,11 @@ var ts; ], undefined, moduleBodyBlock); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); - var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.createNodeArray([ + var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ], node.statements)), 1024); + ]), node.statements)), 1024); if (!(compilerOptions.outFile || compilerOptions.out)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -45579,12 +46954,12 @@ var ts; var externalImport = externalImports[i]; var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { - var groupIndex = groupIndices[text]; + var groupIndex = groupIndices.get(text); + if (groupIndex !== undefined) { dependencyGroups[groupIndex].externalImports.push(externalImport); } else { - groupIndices[text] = dependencyGroups.length; + groupIndices.set(text, dependencyGroups.length); dependencyGroups.push({ name: externalModuleName, externalImports: [externalImport] @@ -45605,21 +46980,23 @@ var ts; ts.addRange(statements, hoistedStatements); ts.addRange(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + var moduleObject = ts.createObjectLiteral([ ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) - ]), true))); - return ts.createBlock(statements, undefined, true); + ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, true))) + ]); + moduleObject.multiLine = true; + statements.push(ts.createReturn(moduleObject)); + return ts.createBlock(statements, true); } function addExportStarIfNeeded(statements) { if (!moduleInfo.hasExportStarsToExportValues) { return; } - if (!moduleInfo.exportedNames && ts.isEmpty(moduleInfo.exportSpecifiers)) { + if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) { var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 241 && externalImport.exportClause) { + if (externalImport.kind === 243 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -45637,12 +47014,12 @@ var ts; if (exportedLocalName.text === "default") { continue; } - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createTrue())); } } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 241) { + if (externalImport.kind !== 243) { continue; } var exportDecl = externalImport; @@ -45651,12 +47028,12 @@ var ts; } for (var _f = 0, _g = exportDecl.exportClause.elements; _f < _g.length; _f++) { var element = _g[_f]; - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createTrue())); } } var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, undefined, true)) + ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, true)) ]))); var exportStarFunction = createExportStarFunction(exportedNamesStorageRef); statements.push(exportStarFunction); @@ -45681,7 +47058,7 @@ var ts; ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1) ])), ts.createStatement(ts.createCall(exportFunction, undefined, [exports])) - ], undefined, true)); + ], true)); } function createSettersArray(exportStarFunction, dependencyGroups) { var setters = []; @@ -45694,15 +47071,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 235: + case 237: if (!entry.importClause) { break; } - case 234: + case 236: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 241: + case 243: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -45710,7 +47087,7 @@ var ts; var e = _d[_c]; properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); } - statements.push(ts.createStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, undefined, true)]))); + statements.push(ts.createStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, true)]))); } else { statements.push(ts.createStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); @@ -45718,19 +47095,19 @@ var ts; break; } } - setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, undefined, true))); + setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, true))); } - return ts.createArrayLiteral(setters, undefined, true); + return ts.createArrayLiteral(setters, true); } function sourceElementVisitor(node) { switch (node.kind) { - case 235: + case 237: return visitImportDeclaration(node); - case 234: + case 236: return visitImportEqualsDeclaration(node); - case 241: + case 243: return undefined; - case 240: + case 242: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -45797,7 +47174,7 @@ var ts; var statements; var name = ts.getLocalName(node); hoistVariableDeclaration(name); - statements = ts.append(statements, ts.createStatement(ts.createAssignment(name, ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement), node)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); @@ -45825,7 +47202,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { var id = ts.getOriginalNodeId(node); @@ -45851,7 +47228,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 1048576) === 0 - && (enclosingBlockScopedContainer.kind === 261 + && (enclosingBlockScopedContainer.kind === 264 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -45869,11 +47246,11 @@ var ts; function createVariableAssignment(name, value, location, isExportedDeclaration) { hoistVariableDeclaration(ts.getSynthesizedClone(name)); return isExportedDeclaration - ? createExportExpression(name, preventSubstitution(ts.createAssignment(name, value, location))) - : preventSubstitution(ts.createAssignment(name, value, location)); + ? createExportExpression(name, preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location))) + : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -45906,10 +47283,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237: + case 239: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238: + case 240: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -45979,7 +47356,7 @@ var ts; return statements; } var name = ts.getDeclarationName(decl); - var exportSpecifiers = moduleInfo.exportSpecifiers[name.text]; + var exportSpecifiers = moduleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { var exportSpecifier = exportSpecifiers_2[_i]; @@ -46008,43 +47385,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 205: + case 207: return visitVariableStatement(node); - case 225: + case 227: return visitFunctionDeclaration(node); - case 226: + case 228: return visitClassDeclaration(node); - case 211: - return visitForStatement(node); - case 212: - return visitForInStatement(node); case 213: + return visitForStatement(node); + case 214: + return visitForInStatement(node); + case 215: return visitForOfStatement(node); - case 209: + case 211: return visitDoStatement(node); - case 210: + case 212: return visitWhileStatement(node); - case 219: - return visitLabeledStatement(node); - case 217: - return visitWithStatement(node); - case 218: - return visitSwitchStatement(node); - case 232: - return visitCaseBlock(node); - case 253: - return visitCaseClause(node); - case 254: - return visitDefaultClause(node); case 221: - return visitTryStatement(node); + return visitLabeledStatement(node); + case 219: + return visitWithStatement(node); + case 220: + return visitSwitchStatement(node); + case 234: + return visitCaseBlock(node); case 256: + return visitCaseClause(node); + case 257: + return visitDefaultClause(node); + case 223: + return visitTryStatement(node); + case 259: return visitCatchClause(node); - case 204: + case 206: return visitBlock(node); - case 295: + case 299: return visitMergeDeclarationMarker(node); - case 296: + case 300: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -46135,7 +47512,7 @@ var ts; } function destructuringVisitor(node) { if (node.transformFlags & 1024 - && node.kind === 192) { + && node.kind === 193) { return visitDestructuringAssignment(node); } else if (node.transformFlags & 2048) { @@ -46172,7 +47549,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 261; + return container !== undefined && container.kind === 264; } else { return false; @@ -46186,8 +47563,8 @@ var ts; } return node; } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261) { + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -46196,22 +47573,22 @@ var ts; if (noSubstitution) { delete noSubstitutionMap[id]; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); if (isSubstitutionPrevented(node)) { return node; } - if (emitContext === 1) { + if (hint === 1) { return substituteExpression(node); } return node; @@ -46220,10 +47597,10 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 192: + case 193: return substituteBinaryExpression(node); - case 190: case 191: + case 192: return substituteUnaryExpression(node); } return node; @@ -46240,10 +47617,10 @@ var ts; var importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node); } else if (ts.isImportSpecifier(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name), node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name)), node); } } } @@ -46275,14 +47652,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 191 - ? ts.createPrefix(node.operator, node.operand, node) + var expression = node.kind === 192 + ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { var exportName = exportedNames_4[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 191) { + if (node.kind === 192) { expression = node.operator === 42 ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -46299,7 +47676,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 261) { + if (exportContainer && exportContainer.kind === 264) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -46309,7 +47686,7 @@ var ts; } function preventSubstitution(node) { if (noSubstitution === undefined) - noSubstitution = ts.createMap(); + noSubstitution = []; noSubstitution[ts.getNodeId(node)] = true; return node; } @@ -46327,7 +47704,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(261); + context.enableEmitNotification(264); context.enableSubstitution(70); var currentSourceFile; return transformSourceFile; @@ -46342,7 +47719,7 @@ var ts; var statementOffset = ts.addPrologueDirectives(statements, node.statements); ts.append(statements, ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } else { return ts.visitEachChild(node, visitor, context); @@ -46352,9 +47729,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 234: + case 236: return undefined; - case 240: + case 242: return visitExportAssignment(node); } return node; @@ -46362,19 +47739,19 @@ var ts; function visitExportAssignment(node) { return node.isExportEquals ? undefined : node; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { if (ts.isSourceFile(node)) { currentSourceFile = node; - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (ts.isIdentifier(node) && emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (ts.isIdentifier(node) && hint === 1) { return substituteExpressionIdentifier(node); } return node; @@ -46393,14 +47770,21 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, - _a[ts.ModuleKind.System] = ts.transformSystemModule, - _a[ts.ModuleKind.AMD] = ts.transformModule, - _a[ts.ModuleKind.CommonJS] = ts.transformModule, - _a[ts.ModuleKind.UMD] = ts.transformModule, - _a[ts.ModuleKind.None] = ts.transformModule, - _a)); + function getModuleTransformer(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.ES2015: + return ts.transformES2015Module; + case ts.ModuleKind.System: + return ts.transformSystemModule; + default: + return ts.transformModule; + } + } + var SyntaxKindFeatureFlags; + (function (SyntaxKindFeatureFlags) { + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["EmitNotifications"] = 2] = "EmitNotifications"; + })(SyntaxKindFeatureFlags || (SyntaxKindFeatureFlags = {})); function getTransformers(compilerOptions) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -46423,7 +47807,7 @@ var ts; transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } - transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); + transformers.push(getModuleTransformer(moduleKind)); if (languageVersion < 1) { transformers.push(ts.transformES5); } @@ -46431,7 +47815,7 @@ var ts; } ts.getTransformers = getTransformers; function transformFiles(resolver, host, sourceFiles, transformers) { - var enabledSyntaxKindFeatures = new Array(298); + var enabledSyntaxKindFeatures = new Array(301); var lexicalEnvironmentDisabled = false; var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; @@ -46452,16 +47836,19 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, - onSubstituteNode: function (_emitContext, node) { return node; }, + onSubstituteNode: function (_, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, + onEmitNode: function (hint, node, callback) { return callback(hint, node); }, enableEmitNotification: enableEmitNotification, isEmitNotificationEnabled: isEmitNotificationEnabled }; + ts.performance.mark("beforeTransform"); var transformation = ts.chain.apply(void 0, transformers)(context); var transformed = ts.map(sourceFiles, transformSourceFile); lexicalEnvironmentDisabled = true; + ts.performance.mark("afterTransform"); + ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { transformed: transformed, emitNodeWithSubstitution: emitNodeWithSubstitution, @@ -46480,16 +47867,12 @@ var ts; return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0 && (ts.getEmitFlags(node) & 4) === 0; } - function emitNodeWithSubstitution(emitContext, node, emitCallback) { + function emitNodeWithSubstitution(hint, node, emitCallback) { if (node) { if (isSubstitutionEnabled(node)) { - var substitute = context.onSubstituteNode(emitContext, node); - if (substitute && substitute !== node) { - emitCallback(emitContext, substitute); - return; - } + node = context.onSubstituteNode(hint, node) || node; } - emitCallback(emitContext, node); + emitCallback(hint, node); } } function enableEmitNotification(kind) { @@ -46499,13 +47882,13 @@ var ts; return (enabledSyntaxKindFeatures[node.kind] & 2) !== 0 || (ts.getEmitFlags(node) & 2) !== 0; } - function emitNodeWithNotification(emitContext, node, emitCallback) { + function emitNodeWithNotification(hint, node, emitCallback) { if (node) { if (isEmitNotificationEnabled(node)) { - context.onEmitNode(emitContext, node, emitCallback); + context.onEmitNode(hint, node, emitCallback); } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } } @@ -46587,21 +47970,22 @@ var ts; } } ts.transformFiles = transformFiles; - var _a; })(ts || (ts = {})); var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, targetSourceFile) { var declarationDiagnostics = ts.createDiagnosticCollection(); - ts.forEachExpectedEmitFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); + ts.forEachEmittedFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined); - function getDeclarationDiagnosticsFromFile(_a, sources, isBundledEmit) { + function getDeclarationDiagnosticsFromFile(_a, sourceFileOrBundle) { var declarationFilePath = _a.declarationFilePath; - emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit, false); + emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sourceFileOrBundle, false); } } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles) { + function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles) { + var sourceFiles = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var isBundledEmit = sourceFileOrBundle.kind === 265; var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -46663,7 +48047,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 235); + ts.Debug.assert(aliasEmitInfo.node.kind === 237); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -46686,9 +48070,9 @@ var ts; } }); if (usedTypeDirectiveReferences) { - for (var directive in usedTypeDirectiveReferences) { + ts.forEachKey(usedTypeDirectiveReferences, function (directive) { referencesOutput += "/// " + newLine; - } + }); } return { reportedDeclarationError: reportedDeclarationError, @@ -46713,6 +48097,7 @@ var ts; var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; writer.reportInaccessibleThisError = reportInaccessibleThisError; + writer.reportIllegalExtends = reportIllegalExtends; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -46735,10 +48120,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 223) { + if (declaration.kind === 225) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 238 || declaration.kind === 239 || declaration.kind === 236) { + else if (declaration.kind === 240 || declaration.kind === 241 || declaration.kind === 238) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -46749,7 +48134,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 235) { + if (moduleElementEmitInfo.node.kind === 237) { moduleElementEmitInfo.isVisible = true; } else { @@ -46757,12 +48142,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 230) { + if (nodeToCheck.kind === 232) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 230) { + if (nodeToCheck.kind === 232) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -46781,8 +48166,8 @@ var ts; } for (var _i = 0, typeReferenceDirectives_1 = typeReferenceDirectives; _i < typeReferenceDirectives_1.length; _i++) { var directive = typeReferenceDirectives_1[_i]; - if (!(directive in usedTypeDirectiveReferences)) { - usedTypeDirectiveReferences[directive] = directive; + if (!usedTypeDirectiveReferences.has(directive)) { + usedTypeDirectiveReferences.set(directive, directive); } } } @@ -46809,6 +48194,12 @@ var ts; handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); } + function reportIllegalExtends() { + if (errorNameNode) { + reportedDeclarationError = true; + emitterDiagnostics.add(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced, ts.declarationNameToString(errorNameNode))); + } + } function reportInaccessibleThisError() { if (errorNameNode) { reportedDeclarationError = true; @@ -46818,12 +48209,16 @@ var ts; function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); - if (type) { + var shouldUseResolverType = declaration.kind === 145 && + resolver.isRequiredInitializedParameter(declaration); + if (type && !shouldUseResolverType) { emitType(type); } else { errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 | 1024, writer); + var format = 2 | 1024 | + (shouldUseResolverType ? 4096 : 0); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer); errorNameNode = undefined; } } @@ -46875,49 +48270,50 @@ var ts; function emitType(type) { switch (type.kind) { case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 133: + case 136: case 104: - case 137: + case 138: case 94: case 129: - case 167: - case 171: - return writeTextOfNode(currentText, type); - case 199: - return emitExpressionWithTypeArguments(type); - case 157: - return emitTypeReference(type); - case 160: - return emitTypeQuery(type); - case 162: - return emitArrayType(type); - case 163: - return emitTupleType(type); - case 164: - return emitUnionType(type); - case 165: - return emitIntersectionType(type); - case 166: - return emitParenType(type); case 168: - return emitTypeOperator(type); - case 169: - return emitIndexedAccessType(type); - case 170: - return emitMappedType(type); + case 172: + return writeTextOfNode(currentText, type); + case 200: + return emitExpressionWithTypeArguments(type); case 158: - case 159: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 161: + return emitTypeQuery(type); + case 163: + return emitArrayType(type); + case 164: + return emitTupleType(type); + case 165: + return emitUnionType(type); + case 166: + return emitIntersectionType(type); + case 167: + return emitParenType(type); + case 169: + return emitTypeOperator(type); + case 170: + return emitIndexedAccessType(type); + case 171: + return emitMappedType(type); + case 159: + case 160: + return emitSignatureDeclarationWithJsDocComments(type); + case 162: return emitTypeLiteral(type); case 70: return emitEntityName(type); - case 141: + case 142: return emitEntityName(type); - case 156: + case 157: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -46925,22 +48321,22 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 141 ? entityName.left : entityName.expression; - var right = entityName.kind === 141 ? entityName.right : entityName.name; + var left = entityName.kind === 142 ? entityName.left : entityName.expression; + var right = entityName.kind === 142 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 234 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 236 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 177); + ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 178); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -47044,15 +48440,15 @@ var ts; } function getExportDefaultTempVariableName() { var baseName = "_default"; - if (!(baseName in currentIdentifiers)) { + if (!currentIdentifiers.has(baseName)) { return baseName; } var count = 0; while (true) { count++; - var name_41 = baseName + "_" + count; - if (!(name_41 in currentIdentifiers)) { - return name_41; + var name = baseName + "_" + count; + if (!currentIdentifiers.has(name)) { + return name; } } } @@ -47096,10 +48492,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 234 || - (node.parent.kind === 261 && isCurrentFileExternalModule)) { + else if (node.kind === 236 || + (node.parent.kind === 264 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 264) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -47108,7 +48504,7 @@ var ts; }); } else { - if (node.kind === 235) { + if (node.kind === 237) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -47126,30 +48522,30 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 225: - return writeFunctionDeclaration(node); - case 205: - return writeVariableStatement(node); case 227: - return writeInterfaceDeclaration(node); - case 226: - return writeClassDeclaration(node); - case 228: - return writeTypeAliasDeclaration(node); + return writeFunctionDeclaration(node); + case 207: + return writeVariableStatement(node); case 229: - return writeEnumDeclaration(node); + return writeInterfaceDeclaration(node); + case 228: + return writeClassDeclaration(node); case 230: + return writeTypeAliasDeclaration(node); + case 231: + return writeEnumDeclaration(node); + case 232: return writeModuleDeclaration(node); - case 234: + case 236: return writeImportEqualsDeclaration(node); - case 235: + case 237: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 261) { + if (node.parent.kind === 264) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -47157,7 +48553,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 227 && !noDeclare) { + else if (node.kind !== 229 && !noDeclare) { write("declare "); } } @@ -47207,7 +48603,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 237) { + if (namedBindings.kind === 239) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -47230,7 +48626,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 237) { + if (node.importClause.namedBindings.kind === 239) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -47247,13 +48643,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 230; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 232; var moduleSpecifier; - if (parent.kind === 234) { + if (parent.kind === 236) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 230) { + else if (parent.kind === 232) { moduleSpecifier = parent.name; } else { @@ -47321,7 +48717,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 231) { + while (node.body && node.body.kind !== 233) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -47391,7 +48787,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 149 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 150 && ts.hasModifier(node.parent, 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -47401,52 +48797,69 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 158 || - node.parent.kind === 159 || - (node.parent.parent && node.parent.parent.kind === 161)) { - ts.Debug.assert(node.parent.kind === 149 || - node.parent.kind === 148 || - node.parent.kind === 158 || + if (node.parent.kind === 159 || + node.parent.kind === 160 || + (node.parent.parent && node.parent.parent.kind === 162)) { + ts.Debug.assert(node.parent.kind === 150 || + node.parent.kind === 149 || node.parent.kind === 159 || - node.parent.kind === 153 || - node.parent.kind === 154); + node.parent.kind === 160 || + node.parent.kind === 154 || + node.parent.kind === 155); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } + if (node.default && !isPrivateMethodTypeParameter(node)) { + write(" = "); + if (node.parent.kind === 159 || + node.parent.kind === 160 || + (node.parent.parent && node.parent.parent.kind === 162)) { + ts.Debug.assert(node.parent.kind === 150 || + node.parent.kind === 149 || + node.parent.kind === 159 || + node.parent.kind === 160 || + node.parent.kind === 154 || + node.parent.kind === 155); + emitType(node.default); + } + else { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.default, getTypeParameterConstraintVisibilityError); + } + } function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 226: + case 228: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 227: + case 229: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 154: + case 155: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 153: + case 154: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 150: case 149: - case 148: if (ts.hasModifier(node.parent, 32)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 226) { + else if (node.parent.parent.kind === 228) { 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 225: + case 227: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 228: + case 230: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -47465,7 +48878,7 @@ var ts; write(">"); } } - function emitHeritageClause(typeReferences, isImplementsList) { + function emitHeritageClause(className, typeReferences, isImplementsList) { if (typeReferences) { write(isImplementsList ? " implements " : " extends "); emitCommaList(typeReferences, emitTypeOfTypeReference); @@ -47479,17 +48892,19 @@ var ts; } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; + errorNameNode = className; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 | 1024, writer); + errorNameNode = undefined; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 226) { + if (node.parent.parent.kind === 228) { 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; + 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; + diagnosticMessage = ts.Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; } return { diagnosticMessage: diagnosticMessage, @@ -47521,9 +48936,10 @@ var ts; emitTypeParameters(node.typeParameters); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); + node.name; + emitHeritageClause(node.name, [baseTypeNode], false); } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), true); + emitHeritageClause(node.name, ts.getClassImplementsHeritageClauseElements(node), true); write(" {"); writeLine(); increaseIndent(); @@ -47544,7 +48960,7 @@ var ts; emitTypeParameters(node.typeParameters); var interfaceExtendsTypes = ts.filter(ts.getInterfaceBaseTypeNodes(node), function (base) { return ts.isEntityNameExpression(base.expression); }); if (interfaceExtendsTypes && interfaceExtendsTypes.length) { - emitHeritageClause(interfaceExtendsTypes, false); + emitHeritageClause(node.name, interfaceExtendsTypes, false); } write(" {"); writeLine(); @@ -47566,17 +48982,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 223 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 225 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 147 || node.kind === 146 || - (node.kind === 144 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 148 || node.kind === 147 || + (node.kind === 145 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 147 || node.kind === 146) && node.parent.kind === 161) { + if ((node.kind === 148 || node.kind === 147) && node.parent.kind === 162) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -47589,14 +49005,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 223) { + if (node.kind === 225) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 147 || node.kind === 146) { + else if (node.kind === 148 || node.kind === 147) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -47604,7 +49020,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 === 226) { + else if (node.parent.kind === 228) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47630,7 +49046,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 198) { + if (element.kind !== 199) { elements.push(element); } } @@ -47696,7 +49112,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 151 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 152 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -47709,7 +49125,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 151 + return accessor.kind === 152 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -47718,7 +49134,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 152) { + if (accessorWithTypeAnnotation.kind === 153) { if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -47764,17 +49180,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 225) { + if (node.kind === 227) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 149 || node.kind === 150) { + else if (node.kind === 150 || node.kind === 151) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 225) { + if (node.kind === 227) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 150) { + else if (node.kind === 151) { write("constructor"); } else { @@ -47794,15 +49210,15 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 155) { + if (node.kind === 156) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { - if (node.kind === 154 || node.kind === 159) { + if (node.kind === 155 || node.kind === 160) { write("new "); } - else if (node.kind === 158) { + else if (node.kind === 159) { var currentOutput = writer.getText(); if (node.typeParameters && currentOutput.charAt(currentOutput.length - 1) === "<") { closeParenthesizedFunctionType = true; @@ -47813,20 +49229,20 @@ var ts; write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 155) { + if (node.kind === 156) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 158 || node.kind === 159; - if (isFunctionTypeOrConstructorType || node.parent.kind === 161) { + var isFunctionTypeOrConstructorType = node.kind === 159 || node.kind === 160; + if (isFunctionTypeOrConstructorType || node.parent.kind === 162) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 150 && !ts.hasModifier(node, 8)) { + else if (node.kind !== 151 && !ts.hasModifier(node, 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -47840,23 +49256,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 154: + case 155: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 153: + case 154: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 155: + case 156: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; + case 150: case 149: - case 148: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -47864,7 +49280,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 === 226) { + else if (node.parent.kind === 228) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -47877,7 +49293,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 225: + case 227: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -47909,9 +49325,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 158 || - node.parent.kind === 159 || - node.parent.parent.kind === 161) { + if (node.parent.kind === 159 || + node.parent.kind === 160 || + node.parent.parent.kind === 162) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8)) { @@ -47927,26 +49343,26 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 150: + case 151: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 154: + case 155: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 153: + case 154: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 155: + case 156: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; + case 150: case 149: - case 148: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -47954,7 +49370,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 === 226) { + else if (node.parent.parent.kind === 228) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47966,7 +49382,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 225: + case 227: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47977,12 +49393,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 172) { + if (bindingPattern.kind === 173) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 173) { + else if (bindingPattern.kind === 174) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -47993,10 +49409,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 198) { + if (bindingElement.kind === 199) { write(" "); } - else if (bindingElement.kind === 174) { + else if (bindingElement.kind === 175) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -48018,39 +49434,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 225: - case 230: - case 234: case 227: - case 226: - case 228: + case 232: + case 236: case 229: + case 228: + case 230: + case 231: return emitModuleElement(node, isModuleElementVisible(node)); - case 205: + case 207: return emitModuleElement(node, isVariableStatementVisible(node)); - case 235: + case 237: return emitModuleElement(node, !node.importClause); - case 241: + case 243: return emitExportDeclaration(node); + case 151: case 150: case 149: - case 148: return writeFunctionDeclaration(node); - case 154: - case 153: case 155: + case 154: + case 156: return emitSignatureDeclarationWithJsDocComments(node); - case 151: case 152: + case 153: return emitAccessorDeclaration(node); + case 148: case 147: - case 146: return emitPropertyDeclaration(node); - case 260: + case 263: return emitEnumMemberDeclaration(node); - case 240: + case 242: return emitExportAssignment(node); - case 261: + case 264: return emitSourceFile(node); } } @@ -48061,14 +49477,15 @@ var ts; declFileName = referencedFile.fileName; } else { - ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); } if (declFileName) { declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(declarationFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, sourceFileOrBundle) { + var isBundledEmit = sourceFileOrBundle.kind === 265; if (isBundledEmit && !addBundledFileReference) { return; } @@ -48078,10 +49495,11 @@ var ts; } } } - function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { - var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles); + function writeDeclarationFile(declarationFilePath, sourceFileOrBundle, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { + var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { + var sourceFiles = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; var declarationOutput = emitDeclarationResult.referencesOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); ts.writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM, sourceFiles); @@ -48135,7 +49553,7 @@ var ts; getText: getText, getSourceMappingURL: getSourceMappingURL, }; - function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { + function initialize(filePath, sourceMapFilePath, sourceFileOrBundle) { if (disabled) { return; } @@ -48166,9 +49584,8 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (!isBundledEmit) { - ts.Debug.assert(sourceFiles.length === 1); - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFiles[0], host, sourceMapDir)); + if (sourceFileOrBundle.kind === 264) { + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); @@ -48259,28 +49676,28 @@ var ts; ts.performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); } } - function emitNodeWithSourceMap(emitContext, node, emitCallback) { + function emitNodeWithSourceMap(hint, node, emitCallback) { if (disabled) { - return emitCallback(emitContext, node); + return emitCallback(hint, node); } if (node) { var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 293 + if (node.kind !== 297 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); } if (emitFlags & 64) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } - if (node.kind !== 293 + if (node.kind !== 297 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -48381,11 +49798,10 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function createCommentWriter(host, writer, sourceMap) { - var compilerOptions = host.getCompilerOptions(); - var extendedDiagnostics = compilerOptions.extendedDiagnostics; - var newLine = host.getNewLine(); - var emitPos = sourceMap.emitPos; + function createCommentWriter(printerOptions, emitPos) { + var extendedDiagnostics = printerOptions.extendedDiagnostics; + var newLine = ts.getNewLineCharacter(printerOptions); + var writer; var containerPos = -1; var containerEnd = -1; var declarationListContainerEnd = -1; @@ -48394,17 +49810,19 @@ var ts; var currentLineMap; var detachedCommentsInfo; var hasWrittenComment = false; - var disabled = compilerOptions.removeComments; + var disabled = printerOptions.removeComments; return { reset: reset, + setWriter: setWriter, setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, + emitLeadingCommentsOfPosition: emitLeadingCommentsOfPosition, }; - function emitNodeWithComments(emitContext, node, emitCallback) { + function emitNodeWithComments(hint, node, emitCallback) { if (disabled) { - emitCallback(emitContext, node); + emitCallback(hint, node); return; } if (node) { @@ -48413,18 +49831,18 @@ var ts; if ((pos < 0 && end < 0) || (pos === end)) { if (emitFlags & 2048) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } else { if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 293; + var isEmittedNode = node.kind !== 297; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0; if (!skipLeadingComments) { @@ -48438,7 +49856,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 224) { + if (node.kind === 226) { declarationListContainerEnd = end; } } @@ -48447,11 +49865,11 @@ var ts; } if (emitFlags & 2048) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } if (extendedDiagnostics) { ts.performance.mark("beginEmitNodeWithComment"); @@ -48522,9 +49940,11 @@ var ts; ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); hasWrittenComment = true; } - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -48532,6 +49952,12 @@ var ts; writer.write(" "); } } + function emitLeadingCommentsOfPosition(pos) { + if (disabled || pos === -1) { + return; + } + emitLeadingComments(pos, true); + } function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } @@ -48539,9 +49965,11 @@ var ts; if (!writer.isAtStartOfLine()) { writer.write(" "); } - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -48559,9 +49987,11 @@ var ts; } } function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -48590,6 +50020,9 @@ var ts; currentLineMap = undefined; detachedCommentsInfo = undefined; } + function setWriter(output) { + writer = output; + } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; currentText = currentSourceFile.text; @@ -48621,9 +50054,11 @@ var ts; } } function writeComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); } function isTripleSlashComment(commentPos, commentEnd) { if (currentText.charCodeAt(commentPos + 1) === 47 && @@ -48641,44 +50076,39 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var id = function (s) { return s; }; - var nullTransformers = [function (_) { return id; }]; + var delimiters = createDelimiterMap(); + var brackets = createBracketsMap(); function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { - var delimiters = createDelimiterMap(); - var brackets = createBracketsMap(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = emitOnlyDtsFiles ? nullTransformers : ts.getTransformers(compilerOptions); + var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); - var write = writer.write, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var sourceMap = ts.createSourceMapWriter(host, writer); - var emitNodeWithSourceMap = sourceMap.emitNodeWithSourceMap, emitTokenWithSourceMap = sourceMap.emitTokenWithSourceMap; - var comments = ts.createCommentWriter(host, writer, sourceMap); - var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition; - var nodeIdToGeneratedName; - var autoGeneratedIdToGeneratedName; - var generatedNameSet; - var tempFlags; var currentSourceFile; - var currentText; - var currentFileIdentifiers; var bundledHelpers; var isOwnFileEmit; var emitSkipped = false; var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); - ts.performance.mark("beforeTransform"); - var _a = ts.transformFiles(resolver, host, sourceFiles, transformers), transformed = _a.transformed, emitNodeWithSubstitution = _a.emitNodeWithSubstitution, emitNodeWithNotification = _a.emitNodeWithNotification; - ts.performance.measure("transformTime", "beforeTransform"); + var transform = ts.transformFiles(resolver, host, sourceFiles, transformers); + var printer = createPrinter(compilerOptions, { + hasGlobalName: resolver.hasGlobalName, + onEmitNode: transform.emitNodeWithNotification, + onSubstituteNode: transform.emitNodeWithSubstitution, + onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, + onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, + onEmitSourceMapOfPosition: sourceMap.emitPos, + onEmitHelpers: emitHelpers, + onSetSourceFile: setSourceFile, + }); ts.performance.mark("beforePrint"); - ts.forEachTransformedEmitFile(host, transformed, emitFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, emitSourceFileOrBundle, transform.transformed, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); - for (var _b = 0, sourceFiles_4 = sourceFiles; _b < sourceFiles_4.length; _b++) { - var sourceFile = sourceFiles_4[_b]; + for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { + var sourceFile = sourceFiles_2[_a]; ts.disposeEmitNodes(sourceFile); } return { @@ -48687,17 +50117,18 @@ var ts; emittedFiles: emittedFilesList, sourceMaps: sourceMapDataList }; - function emitFile(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, isBundledEmit) { + function emitSourceFileOrBundle(_a, sourceFileOrBundle) { + var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath; if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { if (!emitOnlyDtsFiles) { - printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle); } } else { emitSkipped = true; } if (declarationFilePath) { - emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; + emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFileOrBundle(sourceFileOrBundle), host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; } if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { @@ -48711,24 +50142,24 @@ var ts; } } } - function printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit) { - sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); - nodeIdToGeneratedName = []; - autoGeneratedIdToGeneratedName = []; - generatedNameSet = ts.createMap(); - bundledHelpers = isBundledEmit ? ts.createMap() : undefined; - isOwnFileEmit = !isBundledEmit; - if (isBundledEmit && moduleKind) { - for (var _a = 0, sourceFiles_5 = sourceFiles; _a < sourceFiles_5.length; _a++) { - var sourceFile = sourceFiles_5[_a]; - emitHelpers(sourceFile, true); - } + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle) { + var bundle = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 264 ? sourceFileOrBundle : undefined; + var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; + sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFileOrBundle); + if (bundle) { + bundledHelpers = ts.createMap(); + isOwnFileEmit = false; + printer.writeBundle(bundle, writer); } - ts.forEach(sourceFiles, printSourceFile); - writeLine(); + else { + isOwnFileEmit = true; + printer.writeFile(sourceFile, writer); + } + writer.writeLine(); var sourceMappingURL = sourceMap.getSourceMappingURL(); if (sourceMappingURL) { - write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); + writer.write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); } if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) { ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), false, sourceFiles); @@ -48738,23 +50169,165 @@ var ts; } ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM, sourceFiles); sourceMap.reset(); - comments.reset(); writer.reset(); - tempFlags = 0; currentSourceFile = undefined; - currentText = undefined; + bundledHelpers = undefined; isOwnFileEmit = false; } - function printSourceFile(node) { + function setSourceFile(node) { currentSourceFile = node; - currentText = node.text; - currentFileIdentifiers = node.identifiers; sourceMap.setSourceFile(node); - comments.setSourceFile(node); - pipelineEmitWithNotification(0, node); } - function emit(node) { - pipelineEmitWithNotification(3, node); + function emitHelpers(node, writeLines) { + var helpersEmitted = false; + var bundle = node.kind === 265 ? node : undefined; + if (bundle && moduleKind === ts.ModuleKind.None) { + return; + } + var numNodes = bundle ? bundle.sourceFiles.length : 1; + for (var i = 0; i < numNodes; i++) { + var currentNode = bundle ? bundle.sourceFiles[i] : node; + var sourceFile = ts.isSourceFile(currentNode) ? currentNode : currentSourceFile; + var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldBundle = ts.isSourceFile(currentNode) && !isOwnFileEmit; + var helpers = ts.getEmitHelpers(currentNode); + if (helpers) { + for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { + var helper = _b[_a]; + if (!helper.scoped) { + if (shouldSkip) + continue; + if (shouldBundle) { + if (bundledHelpers.get(helper.name)) { + continue; + } + bundledHelpers.set(helper.name, true); + } + } + else if (bundle) { + continue; + } + writeLines(helper.text); + helpersEmitted = true; + } + } + } + return helpersEmitted; + } + } + ts.emitFiles = emitFiles; + function createPrinter(printerOptions, handlers) { + if (printerOptions === void 0) { printerOptions = {}; } + if (handlers === void 0) { handlers = {}; } + var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, onSubstituteNode = handlers.onSubstituteNode; + var newLine = ts.getNewLineCharacter(printerOptions); + var languageVersion = ts.getEmitScriptTarget(printerOptions); + var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); + var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; + var currentSourceFile; + var nodeIdToGeneratedName; + var autoGeneratedIdToGeneratedName; + var generatedNames; + var tempFlagsStack; + var tempFlags; + var writer; + var ownWriter; + reset(); + return { + printNode: printNode, + printFile: printFile, + printBundle: printBundle, + writeNode: writeNode, + writeFile: writeFile, + writeBundle: writeBundle + }; + function printNode(hint, node, sourceFile) { + switch (hint) { + case 0: + ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); + break; + case 2: + ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); + break; + case 1: + ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); + break; + } + switch (node.kind) { + case 264: return printFile(node); + case 265: return printBundle(node); + } + writeNode(hint, node, sourceFile, beginPrint()); + return endPrint(); + } + function printBundle(bundle) { + writeBundle(bundle, beginPrint()); + return endPrint(); + } + function printFile(sourceFile) { + writeFile(sourceFile, beginPrint()); + return endPrint(); + } + function writeNode(hint, node, sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(hint, node, sourceFile); + reset(); + writer = previousWriter; + } + function writeBundle(bundle, output) { + var previousWriter = writer; + setWriter(output); + emitHelpersIndirect(bundle); + for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + print(0, sourceFile, sourceFile); + } + reset(); + writer = previousWriter; + } + function writeFile(sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(0, sourceFile, sourceFile); + reset(); + writer = previousWriter; + } + function beginPrint() { + return ownWriter || (ownWriter = ts.createTextWriter(newLine)); + } + function endPrint() { + var text = ownWriter.getText(); + ownWriter.reset(); + return text; + } + function print(hint, node, sourceFile) { + setSourceFile(sourceFile); + pipelineEmitWithNotification(hint, node); + } + function setSourceFile(sourceFile) { + currentSourceFile = sourceFile; + comments.setSourceFile(sourceFile); + if (onSetSourceFile) { + onSetSourceFile(sourceFile); + } + } + function setWriter(output) { + writer = output; + comments.setWriter(output); + } + function reset() { + nodeIdToGeneratedName = []; + autoGeneratedIdToGeneratedName = []; + generatedNames = ts.createMap(); + tempFlagsStack = []; + tempFlags = 0; + comments.reset(); + setWriter(undefined); + } + function emit(node, hint) { + if (hint === void 0) { hint = 3; } + pipelineEmitWithNotification(hint, node); } function emitIdentifierName(node) { pipelineEmitWithNotification(2, node); @@ -48762,51 +50335,60 @@ var ts; function emitExpression(node) { pipelineEmitWithNotification(1, node); } - function pipelineEmitWithNotification(emitContext, node) { - emitNodeWithNotification(emitContext, node, pipelineEmitWithComments); + function pipelineEmitWithNotification(hint, node) { + if (onEmitNode) { + onEmitNode(hint, node, pipelineEmitWithComments); + } + else { + pipelineEmitWithComments(hint, node); + } } - function pipelineEmitWithComments(emitContext, node) { - if (emitContext === 0) { - pipelineEmitWithSourceMap(emitContext, node); + function pipelineEmitWithComments(hint, node) { + if (emitNodeWithComments && hint !== 0) { + emitNodeWithComments(hint, node, pipelineEmitWithSourceMap); + } + else { + pipelineEmitWithSourceMap(hint, node); + } + } + function pipelineEmitWithSourceMap(hint, node) { + if (onEmitSourceMapOfNode && hint !== 0 && hint !== 2) { + onEmitSourceMapOfNode(hint, node, pipelineEmitWithSubstitution); + } + else { + pipelineEmitWithSubstitution(hint, node); + } + } + function pipelineEmitWithSubstitution(hint, node) { + if (onSubstituteNode) { + onSubstituteNode(hint, node, pipelineEmitWithHint); + } + else { + pipelineEmitWithHint(hint, node); + } + } + function pipelineEmitWithHint(hint, node) { + switch (hint) { + case 0: return pipelineEmitSourceFile(node); + case 2: return pipelineEmitIdentifierName(node); + case 1: return pipelineEmitExpression(node); + case 3: return pipelineEmitUnspecified(node); + } + } + function pipelineEmitSourceFile(node) { + ts.Debug.assertNode(node, ts.isSourceFile); + emitSourceFile(node); + } + function pipelineEmitIdentifierName(node) { + ts.Debug.assertNode(node, ts.isIdentifier); + emitIdentifier(node); + } + function pipelineEmitUnspecified(node) { + var kind = node.kind; + if (ts.isKeyword(kind)) { + writeTokenText(kind); return; } - emitNodeWithComments(emitContext, node, pipelineEmitWithSourceMap); - } - function pipelineEmitWithSourceMap(emitContext, node) { - if (emitContext === 0 - || emitContext === 2) { - pipelineEmitWithSubstitution(emitContext, node); - return; - } - emitNodeWithSourceMap(emitContext, node, pipelineEmitWithSubstitution); - } - function pipelineEmitWithSubstitution(emitContext, node) { - emitNodeWithSubstitution(emitContext, node, pipelineEmitForContext); - } - function pipelineEmitForContext(emitContext, node) { - switch (emitContext) { - case 0: return pipelineEmitInSourceFileContext(node); - case 2: return pipelineEmitInIdentifierNameContext(node); - case 3: return pipelineEmitInUnspecifiedContext(node); - case 1: return pipelineEmitInExpressionContext(node); - } - } - function pipelineEmitInSourceFileContext(node) { - var kind = node.kind; - switch (kind) { - case 261: - return emitSourceFile(node); - } - } - function pipelineEmitInIdentifierNameContext(node) { - var kind = node.kind; - switch (kind) { - case 70: - return emitIdentifier(node); - } - } - function pipelineEmitInUnspecifiedContext(node) { - var kind = node.kind; switch (kind) { case 13: case 14: @@ -48814,229 +50396,197 @@ var ts; return emitLiteral(node); case 70: return emitIdentifier(node); - case 75: - case 78: - case 83: - case 104: - case 111: - case 112: - case 113: - case 114: - case 116: - case 117: - case 118: - case 119: - case 120: - case 121: - case 122: - case 123: - case 124: - case 125: - case 127: - case 128: - case 129: - case 130: - case 131: - case 132: - case 133: - case 134: - case 135: - case 136: - case 137: - case 138: - case 139: - case 140: - writeTokenText(kind); - return; - case 141: - return emitQualifiedName(node); case 142: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 143: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 144: - return emitParameter(node); + return emitTypeParameter(node); case 145: - return emitDecorator(node); + return emitParameter(node); case 146: - return emitPropertySignature(node); + return emitDecorator(node); case 147: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 148: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 149: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 150: - return emitConstructor(node); + return emitMethodDeclaration(node); case 151: + return emitConstructor(node); case 152: - return emitAccessorDeclaration(node); case 153: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 154: - return emitConstructSignature(node); + return emitCallSignature(node); case 155: - return emitIndexSignature(node); + return emitConstructSignature(node); case 156: - return emitTypePredicate(node); + return emitIndexSignature(node); case 157: - return emitTypeReference(node); + return emitTypePredicate(node); case 158: - return emitFunctionType(node); + return emitTypeReference(node); case 159: - return emitConstructorType(node); + return emitFunctionType(node); case 160: - return emitTypeQuery(node); + return emitConstructorType(node); case 161: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 162: - return emitArrayType(node); + return emitTypeLiteral(node); case 163: - return emitTupleType(node); + return emitArrayType(node); case 164: - return emitUnionType(node); + return emitTupleType(node); case 165: - return emitIntersectionType(node); + return emitUnionType(node); case 166: - return emitParenthesizedType(node); - case 199: - return emitExpressionWithTypeArguments(node); + return emitIntersectionType(node); case 167: - return emitThisType(); + return emitParenthesizedType(node); + case 200: + return emitExpressionWithTypeArguments(node); case 168: - return emitTypeOperator(node); + return emitThisType(); case 169: - return emitIndexedAccessType(node); + return emitTypeOperator(node); case 170: - return emitMappedType(node); + return emitIndexedAccessType(node); case 171: - return emitLiteralType(node); + return emitMappedType(node); case 172: - return emitObjectBindingPattern(node); + return emitLiteralType(node); case 173: - return emitArrayBindingPattern(node); + return emitObjectBindingPattern(node); case 174: + return emitArrayBindingPattern(node); + case 175: return emitBindingElement(node); - case 202: - return emitTemplateSpan(node); - case 203: - return emitSemicolonClassElement(); case 204: - return emitBlock(node); + return emitTemplateSpan(node); case 205: - return emitVariableStatement(node); + return emitSemicolonClassElement(); case 206: - return emitEmptyStatement(); + return emitBlock(node); case 207: - return emitExpressionStatement(node); + return emitVariableStatement(node); case 208: - return emitIfStatement(node); + return emitEmptyStatement(); case 209: - return emitDoStatement(node); + return emitExpressionStatement(node); case 210: - return emitWhileStatement(node); + return emitIfStatement(node); case 211: - return emitForStatement(node); + return emitDoStatement(node); case 212: - return emitForInStatement(node); + return emitWhileStatement(node); case 213: - return emitForOfStatement(node); + return emitForStatement(node); case 214: - return emitContinueStatement(node); + return emitForInStatement(node); case 215: - return emitBreakStatement(node); + return emitForOfStatement(node); case 216: - return emitReturnStatement(node); + return emitContinueStatement(node); case 217: - return emitWithStatement(node); + return emitBreakStatement(node); case 218: - return emitSwitchStatement(node); + return emitReturnStatement(node); case 219: - return emitLabeledStatement(node); + return emitWithStatement(node); case 220: - return emitThrowStatement(node); + return emitSwitchStatement(node); case 221: - return emitTryStatement(node); + return emitLabeledStatement(node); case 222: - return emitDebuggerStatement(node); + return emitThrowStatement(node); case 223: - return emitVariableDeclaration(node); + return emitTryStatement(node); case 224: - return emitVariableDeclarationList(node); + return emitDebuggerStatement(node); case 225: - return emitFunctionDeclaration(node); + return emitVariableDeclaration(node); case 226: - return emitClassDeclaration(node); + return emitVariableDeclarationList(node); case 227: - return emitInterfaceDeclaration(node); + return emitFunctionDeclaration(node); case 228: - return emitTypeAliasDeclaration(node); + return emitClassDeclaration(node); case 229: - return emitEnumDeclaration(node); + return emitInterfaceDeclaration(node); case 230: - return emitModuleDeclaration(node); + return emitTypeAliasDeclaration(node); case 231: - return emitModuleBlock(node); + return emitEnumDeclaration(node); case 232: - return emitCaseBlock(node); + return emitModuleDeclaration(node); + case 233: + return emitModuleBlock(node); case 234: - return emitImportEqualsDeclaration(node); - case 235: - return emitImportDeclaration(node); + return emitCaseBlock(node); case 236: - return emitImportClause(node); + return emitImportEqualsDeclaration(node); case 237: - return emitNamespaceImport(node); + return emitImportDeclaration(node); case 238: - return emitNamedImports(node); + return emitImportClause(node); case 239: - return emitImportSpecifier(node); + return emitNamespaceImport(node); case 240: - return emitExportAssignment(node); + return emitNamedImports(node); case 241: - return emitExportDeclaration(node); + return emitImportSpecifier(node); case 242: - return emitNamedExports(node); + return emitExportAssignment(node); case 243: - return emitExportSpecifier(node); + return emitExportDeclaration(node); case 244: - return; + return emitNamedExports(node); case 245: + return emitExportSpecifier(node); + case 246: + return; + case 247: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 248: - return emitJsxOpeningElement(node); - case 249: - return emitJsxClosingElement(node); case 250: - return emitJsxAttribute(node); + return emitJsxOpeningElement(node); case 251: - return emitJsxSpreadAttribute(node); + return emitJsxClosingElement(node); case 252: - return emitJsxExpression(node); + return emitJsxAttribute(node); case 253: - return emitCaseClause(node); + return emitJsxAttributes(node); case 254: - return emitDefaultClause(node); + return emitJsxSpreadAttribute(node); case 255: - return emitHeritageClause(node); + return emitJsxExpression(node); case 256: - return emitCatchClause(node); + return emitCaseClause(node); case 257: - return emitPropertyAssignment(node); + return emitDefaultClause(node); case 258: - return emitShorthandPropertyAssignment(node); + return emitHeritageClause(node); case 259: - return emitSpreadAssignment(node); + return emitCatchClause(node); case 260: + return emitPropertyAssignment(node); + case 261: + return emitShorthandPropertyAssignment(node); + case 262: + return emitSpreadAssignment(node); + case 263: return emitEnumMember(node); } if (ts.isExpression(node)) { return pipelineEmitWithSubstitution(1, node); } } - function pipelineEmitInExpressionContext(node) { + function pipelineEmitExpression(node) { var kind = node.kind; switch (kind) { case 8: @@ -49054,66 +50604,79 @@ var ts; case 98: writeTokenText(kind); return; - case 175: - return emitArrayLiteralExpression(node); case 176: - return emitObjectLiteralExpression(node); + return emitArrayLiteralExpression(node); case 177: - return emitPropertyAccessExpression(node); + return emitObjectLiteralExpression(node); case 178: - return emitElementAccessExpression(node); + return emitPropertyAccessExpression(node); case 179: - return emitCallExpression(node); + return emitElementAccessExpression(node); case 180: - return emitNewExpression(node); + return emitCallExpression(node); case 181: - return emitTaggedTemplateExpression(node); + return emitNewExpression(node); case 182: - return emitTypeAssertionExpression(node); + return emitTaggedTemplateExpression(node); case 183: - return emitParenthesizedExpression(node); + return emitTypeAssertionExpression(node); case 184: - return emitFunctionExpression(node); + return emitParenthesizedExpression(node); case 185: - return emitArrowFunction(node); + return emitFunctionExpression(node); case 186: - return emitDeleteExpression(node); + return emitArrowFunction(node); case 187: - return emitTypeOfExpression(node); + return emitDeleteExpression(node); case 188: - return emitVoidExpression(node); + return emitTypeOfExpression(node); case 189: - return emitAwaitExpression(node); + return emitVoidExpression(node); case 190: - return emitPrefixUnaryExpression(node); + return emitAwaitExpression(node); case 191: - return emitPostfixUnaryExpression(node); + return emitPrefixUnaryExpression(node); case 192: - return emitBinaryExpression(node); + return emitPostfixUnaryExpression(node); case 193: - return emitConditionalExpression(node); + return emitBinaryExpression(node); case 194: - return emitTemplateExpression(node); + return emitConditionalExpression(node); case 195: - return emitYieldExpression(node); + return emitTemplateExpression(node); case 196: - return emitSpreadExpression(node); + return emitYieldExpression(node); case 197: - return emitClassExpression(node); + return emitSpreadExpression(node); case 198: + return emitClassExpression(node); + case 199: return; - case 200: - return emitAsExpression(node); case 201: + return emitAsExpression(node); + case 202: return emitNonNullExpression(node); - case 246: + case 203: + return emitMetaProperty(node); + case 248: return emitJsxElement(node); - case 247: + case 249: return emitJsxSelfClosingElement(node); - case 294: + case 298: return emitPartiallyEmittedExpression(node); - case 297: - return writeLines(node.text); + } + } + function emitBodyIndirect(node, elements, emitCallback) { + if (emitBodyWithDetachedComments) { + emitBodyWithDetachedComments(node, elements, emitCallback); + } + else { + emitCallback(node); + } + } + function emitHelpersIndirect(node) { + if (onEmitHelpers) { + onEmitHelpers(node, writeLines); } } function emitNumericLiteral(node) { @@ -49124,7 +50687,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralTextOfNode(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) + if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } @@ -49211,7 +50774,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 151 ? "get " : "set "); + write(node.kind === 152 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -49311,17 +50874,13 @@ var ts; write("{"); writeLine(); increaseIndent(); - if (node.readonlyToken) { - write("readonly "); - } + writeIfPresent(node.readonlyToken, "readonly "); write("["); emit(node.typeParameter.name); write(" in "); emit(node.typeParameter.constraint); write("]"); - if (node.questionToken) { - write("?"); - } + writeIfPresent(node.questionToken, "?"); write(": "); emit(node.type); write(";"); @@ -49393,7 +50952,7 @@ var ts; var indentAfterDot = false; if (!(ts.getEmitFlags(node) & 65536)) { var dotRangeStart = node.expression.end; - var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; + var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; var dotToken = { kind: 22, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); @@ -49409,13 +50968,15 @@ var ts; function needsDotDotForPropertyAccess(expression) { if (expression.kind === 8) { var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(22)) < 0; + return ts.getNumericLiteralFlags(text, 15) === 0 + && !expression.isOctalLiteral + && text.indexOf(ts.tokenToString(22)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { var constantValue = ts.getConstantValue(expression); return isFinite(constantValue) && Math.floor(constantValue) === constantValue - && compilerOptions.removeComments; + && printerOptions.removeComments; } } function emitElementAccessExpression(node) { @@ -49441,11 +51002,9 @@ var ts; emitExpression(node.template); } function emitTypeAssertionExpression(node) { - if (node.type) { - write("<"); - emit(node.type); - write(">"); - } + write("<"); + emit(node.type); + write(">"); emitExpression(node.expression); } function emitParenthesizedExpression(node) { @@ -49492,7 +51051,7 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 190 + return operand.kind === 191 && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); } @@ -49558,6 +51117,11 @@ var ts; emitExpression(node.expression); write("!"); } + function emitMetaProperty(node) { + writeToken(node.keywordToken, node.pos); + write("."); + emit(node.name); + } function emitTemplateSpan(node) { emitExpression(node.expression); emit(node.literal); @@ -49571,6 +51135,9 @@ var ts; else { writeToken(16, node.pos, node); emitBlockStatements(node); + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); writeToken(17, node.statements.end, node); } } @@ -49600,27 +51167,27 @@ var ts; writeToken(18, openParenPos, node); emitExpression(node.expression); writeToken(19, node.expression.end, node); - emitEmbeddedStatement(node.thenStatement); + emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { - writeLine(); + writeLineOrSpace(node); writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 208) { + if (node.elseStatement.kind === 210) { write(" "); emit(node.elseStatement); } else { - emitEmbeddedStatement(node.elseStatement); + emitEmbeddedStatement(node, node.elseStatement); } } } function emitDoStatement(node) { write("do"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { write(" "); } else { - writeLine(); + writeLineOrSpace(node); } write("while ("); emitExpression(node.expression); @@ -49630,7 +51197,7 @@ var ts; write("while ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -49642,7 +51209,7 @@ var ts; write(";"); emitExpressionWithPrefix(" ", node.incrementor); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -49652,7 +51219,7 @@ var ts; write(" in "); emitExpression(node.expression); writeToken(19, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -49662,11 +51229,11 @@ var ts; write(" of "); emitExpression(node.expression); writeToken(19, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 224) { + if (node.kind === 226) { emit(node); } else { @@ -49693,7 +51260,7 @@ var ts; write("with ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { var openParenPos = writeToken(97, node.pos); @@ -49717,9 +51284,12 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchClause); + if (node.catchClause) { + writeLineOrSpace(node); + emit(node.catchClause); + } if (node.finallyBlock) { - writeLine(); + writeLineOrSpace(node); write("finally "); emit(node.finallyBlock); } @@ -49760,11 +51330,10 @@ var ts; emitBlockFunctionBody(body); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); emitSignatureHead(node); emitBlockFunctionBody(body); - tempFlags = savedTempFlags; + popNameGenerationScope(); } if (indentedFlag) { decreaseIndent(); @@ -49813,9 +51382,10 @@ var ts; function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) + var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine - : emitBlockFunctionBodyWorker); + : emitBlockFunctionBodyWorker; + emitBodyIndirect(body, body.statements, emitBlockFunctionBody); decreaseIndent(); writeToken(17, body.statements.end, body); } @@ -49824,8 +51394,9 @@ var ts; } function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) { var statementOffset = emitPrologueDirectives(body.statements, true); - var helpersEmitted = emitHelpers(body); - if (statementOffset === 0 && !helpersEmitted && emitBlockFunctionBodyOnSingleLine) { + var pos = writer.getTextPos(); + emitHelpersIndirect(body); + if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); emitList(body, body.statements, 384); increaseIndent(); @@ -49848,15 +51419,14 @@ var ts; } emitTypeParameters(node, node.typeParameters); emitList(node, node.heritageClauses, 256); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 65); write("}"); + popNameGenerationScope(); if (indentedFlag) { decreaseIndent(); } - tempFlags = savedTempFlags; } function emitInterfaceDeclaration(node) { emitDecorators(node, node.decorators); @@ -49883,19 +51453,18 @@ var ts; emitModifiers(node, node.modifiers); write("enum "); emit(node.name); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 81); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 230) { + while (body.kind === 232) { write("."); emit(body.name); body = body.body; @@ -49908,13 +51477,12 @@ var ts; write("{ }"); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write("{"); increaseIndent(); emitBlockStatements(node); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } } function emitCaseBlock(node) { @@ -50016,14 +51584,18 @@ var ts; write("<"); emitJsxTagName(node.tagName); write(" "); - emitList(node, node.attributes, 131328); + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write("/>"); } function emitJsxOpeningElement(node) { write("<"); emitJsxTagName(node.tagName); - writeIfAny(node.attributes, " "); - emitList(node, node.attributes, 131328); + writeIfAny(node.attributes.properties, " "); + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write(">"); } function emitJsxText(node) { @@ -50034,6 +51606,9 @@ var ts; emitJsxTagName(node.tagName); write(">"); } + function emitJsxAttributes(node) { + emitList(node, node.properties, 131328); + } function emitJsxAttribute(node) { emit(node.name); emitWithPrefix("=", node.initializer); @@ -50046,6 +51621,9 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); + if (node.dotDotDotToken) { + write("..."); + } emitExpression(node.expression); write("}"); } @@ -50088,7 +51666,6 @@ var ts; emitList(node, node.types, 272); } function emitCatchClause(node) { - writeLine(); var openParenPos = writeToken(73, node.pos); write(" "); writeToken(18, openParenPos); @@ -50101,7 +51678,7 @@ var ts; emit(node.name); write(": "); var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512) === 0) { + if (emitTrailingCommentsOfPosition && (ts.getEmitFlags(initializer) & 512) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -50127,16 +51704,15 @@ var ts; function emitSourceFile(node) { writeLine(); emitShebang(); - emitBodyWithDetachedComments(node, node.statements, emitSourceFileWorker); + emitBodyIndirect(node, node.statements, emitSourceFileWorker); } function emitSourceFileWorker(node) { var statements = node.statements; var statementOffset = emitPrologueDirectives(statements); - var savedTempFlags = tempFlags; - tempFlags = 0; - emitHelpers(node); + pushNameGenerationScope(); + emitHelpersIndirect(node); emitList(node, statements, 1, statementOffset); - tempFlags = savedTempFlags; + popNameGenerationScope(); } function emitPartiallyEmittedExpression(node) { emitExpression(node.expression); @@ -50155,67 +51731,8 @@ var ts; } return statements.length; } - function emitHelpers(node, isBundle) { - var sourceFile = ts.isSourceFile(node) ? node : currentSourceFile; - var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); - var shouldBundle = ts.isSourceFile(node) && !isOwnFileEmit; - var helpersEmitted = false; - var helpers = ts.getEmitHelpers(node); - if (helpers) { - for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { - var helper = _b[_a]; - if (!helper.scoped) { - if (shouldSkip) - continue; - if (shouldBundle) { - if (bundledHelpers[helper.name]) { - continue; - } - bundledHelpers[helper.name] = true; - } - } - else if (isBundle) { - continue; - } - writeLines(helper.text); - helpersEmitted = true; - } - } - if (helpersEmitted) { - writeLine(); - } - return helpersEmitted; - } - function writeLines(text) { - var lines = text.split(/\r\n?|\n/g); - var indentation = guessIndentation(lines); - for (var i = 0; i < lines.length; i++) { - var line = indentation ? lines[i].slice(indentation) : lines[i]; - if (line.length) { - if (i > 0) { - writeLine(); - } - write(line); - } - } - } - function guessIndentation(lines) { - var indentation; - for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { - var line = lines_1[_a]; - for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { - if (!ts.isWhiteSpace(line.charCodeAt(i))) { - if (indentation === undefined || i < indentation) { - indentation = i; - break; - } - } - } - } - return indentation; - } function emitShebang() { - var shebang = ts.getShebang(currentText); + var shebang = ts.getShebang(currentSourceFile.text); if (shebang) { write(shebang); writeLine(); @@ -50245,8 +51762,8 @@ var ts; write(suffix); } } - function emitEmbeddedStatement(node) { - if (ts.isBlock(node)) { + function emitEmbeddedStatement(parent, node) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1) { write(" "); emit(node); } @@ -50330,6 +51847,9 @@ var ts; for (var i = 0; i < count; i++) { var child = children[start + i]; if (previousSibling) { + if (delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } write(delimiter); if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { if ((format & (3 | 64)) === 0) { @@ -50344,8 +51864,10 @@ var ts; } } if (shouldEmitInterveningComments) { - var commentRange = ts.getCommentRange(child); - emitTrailingCommentsOfPosition(commentRange.pos); + if (emitTrailingCommentsOfPosition) { + var commentRange = ts.getCommentRange(child); + emitTrailingCommentsOfPosition(commentRange.pos); + } } else { shouldEmitInterveningComments = mayEmitInterveningComments; @@ -50361,6 +51883,9 @@ var ts; if (format & 16 && hasTrailingComma) { write(","); } + if (previousSibling && delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } if (format & 64) { decreaseIndent(); } @@ -50375,24 +51900,73 @@ var ts; write(getClosingBracket(format)); } } + function write(s) { + writer.write(s); + } + function writeLine() { + writer.writeLine(); + } + function increaseIndent() { + writer.increaseIndent(); + } + function decreaseIndent() { + writer.decreaseIndent(); + } function writeIfAny(nodes, text) { - if (nodes && nodes.length > 0) { + if (ts.some(nodes)) { write(text); } } function writeIfPresent(node, text) { - if (node !== undefined) { + if (node) { write(text); } } function writeToken(token, pos, contextNode) { - return emitTokenWithSourceMap(contextNode, token, pos, writeTokenText); + return onEmitSourceMapOfToken + ? onEmitSourceMapOfToken(contextNode, token, pos, writeTokenText) + : writeTokenText(token, pos); } function writeTokenText(token, pos) { var tokenString = ts.tokenToString(token); write(tokenString); return pos < 0 ? pos : pos + tokenString.length; } + function writeLineOrSpace(node) { + if (ts.getEmitFlags(node) & 1) { + write(" "); + } + else { + writeLine(); + } + } + function writeLines(text) { + var lines = text.split(/\r\n?|\n/g); + var indentation = guessIndentation(lines); + for (var i = 0; i < lines.length; i++) { + var line = indentation ? lines[i].slice(indentation) : lines[i]; + if (line.length) { + writeLine(); + write(line); + writeLine(); + } + } + } + function guessIndentation(lines) { + var indentation; + for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { + var line = lines_1[_a]; + for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { + if (!ts.isWhiteSpace(line.charCodeAt(i))) { + if (indentation === undefined || i < indentation) { + indentation = i; + break; + } + } + } + } + return indentation; + } function increaseIndentIf(value, valueToWriteWhenNotIndenting) { if (value) { increaseIndent(); @@ -50497,15 +52071,23 @@ var ts; && !ts.nodeIsSynthesized(node2) && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } + function isSingleLineEmptyBlock(block) { + return !block.multiLine + && isEmptyBlock(block); + } + function isEmptyBlock(block) { + return block.statements.length === 0 + && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + } function skipSynthesizedParentheses(node) { - while (node.kind === 183 && ts.nodeIsSynthesized(node)) { + while (node.kind === 184 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; } function getTextOfNode(node, includeTrivia) { if (ts.isGeneratedIdentifier(node)) { - return getGeneratedIdentifier(node); + return generateName(node); } else if (ts.isIdentifier(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { return ts.unescapeIdentifier(node.text); @@ -50530,23 +52112,37 @@ var ts; } return ts.getLiteralText(node, currentSourceFile, languageVersion); } - function isSingleLineEmptyBlock(block) { - return !block.multiLine - && isEmptyBlock(block); + function pushNameGenerationScope() { + tempFlagsStack.push(tempFlags); + tempFlags = 0; } - function isEmptyBlock(block) { - return block.statements.length === 0 - && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + function popNameGenerationScope() { + tempFlags = tempFlagsStack.pop(); + } + function generateName(name) { + if (name.autoGenerateKind === 4) { + var node = getNodeForGeneratedName(name); + return generateNameCached(node); + } + else { + var autoGenerateId = name.autoGenerateId; + return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(makeName(name))); + } + } + function generateNameCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); } function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentFileIdentifiers, name) && - !ts.hasProperty(generatedNameSet, name); + return !(hasGlobalName && hasGlobalName(name)) + && !currentSourceFile.identifiers.has(name) + && !generatedNames.has(name); } function isUniqueLocalName(name, container) { for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { + if (node.locals) { + var local = node.locals.get(name); + if (local && local.flags & (107455 | 1048576 | 8388608)) { return false; } } @@ -50555,21 +52151,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_42 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_42)) { + var name = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name)) { tempFlags |= flags; - return name_42; + return name; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_43 = count < 26 + var name = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_43)) { - return name_43; + if (isUniqueName(name)) { + return name; } } } @@ -50582,7 +52178,8 @@ var ts; while (true) { var generatedName = baseName + i; if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; + generatedNames.set(generatedName, generatedName); + return generatedName; } i++; } @@ -50603,34 +52200,44 @@ var ts; function generateNameForClassExpression() { return makeUniqueName("class"); } + function generateNameForMethodOrAccessor(node) { + if (ts.isIdentifier(node.name)) { + return generateNameCached(node.name); + } + return makeTempVariableName(0); + } function generateNameForNode(node) { switch (node.kind) { case 70: return makeUniqueName(getTextOfNode(node)); - case 230: - case 229: + case 232: + case 231: return generateNameForModuleOrEnum(node); - case 235: - case 241: + case 237: + case 243: return generateNameForImportOrExportDeclaration(node); - case 225: - case 226: - case 240: + case 227: + case 228: + case 242: return generateNameForExportDefault(); - case 197: + case 198: return generateNameForClassExpression(); + case 150: + case 152: + case 153: + return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0); } } - function generateName(name) { + function makeName(name) { switch (name.autoGenerateKind) { case 1: return makeTempVariableName(0); case 2: return makeTempVariableName(268435456); case 3: - return makeUniqueName(name.text); + return makeUniqueName(ts.unescapeIdentifier(name.text)); } ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } @@ -50649,44 +52256,101 @@ var ts; } return node; } - function getGeneratedIdentifier(name) { - if (name.autoGenerateKind === 4) { - var node = getNodeForGeneratedName(name); - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); - } - else { - var autoGenerateId = name.autoGenerateId; - return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(generateName(name))); - } - } - function createDelimiterMap() { - var delimiters = []; - delimiters[0] = ""; - delimiters[16] = ","; - delimiters[4] = " |"; - delimiters[8] = " &"; - return delimiters; - } - function getDelimiter(format) { - return delimiters[format & 28]; - } - function createBracketsMap() { - var brackets = []; - brackets[512] = ["{", "}"]; - brackets[1024] = ["(", ")"]; - brackets[2048] = ["<", ">"]; - brackets[4096] = ["[", "]"]; - return brackets; - } - function getOpeningBracket(format) { - return brackets[format & 7680][0]; - } - function getClosingBracket(format) { - return brackets[format & 7680][1]; - } } - ts.emitFiles = emitFiles; + ts.createPrinter = createPrinter; + function createDelimiterMap() { + var delimiters = []; + delimiters[0] = ""; + delimiters[16] = ","; + delimiters[4] = " |"; + delimiters[8] = " &"; + return delimiters; + } + function getDelimiter(format) { + return delimiters[format & 28]; + } + function createBracketsMap() { + var brackets = []; + brackets[512] = ["{", "}"]; + brackets[1024] = ["(", ")"]; + brackets[2048] = ["<", ">"]; + brackets[4096] = ["[", "]"]; + return brackets; + } + function getOpeningBracket(format) { + return brackets[format & 7680][0]; + } + function getClosingBracket(format) { + return brackets[format & 7680][1]; + } + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + })(TempFlags || (TempFlags = {})); + var ListFormat; + (function (ListFormat) { + ListFormat[ListFormat["None"] = 0] = "None"; + ListFormat[ListFormat["SingleLine"] = 0] = "SingleLine"; + ListFormat[ListFormat["MultiLine"] = 1] = "MultiLine"; + ListFormat[ListFormat["PreserveLines"] = 2] = "PreserveLines"; + ListFormat[ListFormat["LinesMask"] = 3] = "LinesMask"; + ListFormat[ListFormat["NotDelimited"] = 0] = "NotDelimited"; + ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; + ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; + ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; + ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; + ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; + ListFormat[ListFormat["Indented"] = 64] = "Indented"; + ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; + ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; + ListFormat[ListFormat["Braces"] = 512] = "Braces"; + ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; + ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; + ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; + ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; + ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; + ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; + ListFormat[ListFormat["Optional"] = 24576] = "Optional"; + ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; + ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; + ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; + ListFormat[ListFormat["Modifiers"] = 256] = "Modifiers"; + ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; + ListFormat[ListFormat["TypeLiteralMembers"] = 65] = "TypeLiteralMembers"; + ListFormat[ListFormat["TupleTypeElements"] = 336] = "TupleTypeElements"; + ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; + ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; + ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; + ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; + ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; + ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; + ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; + ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; + ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; + ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; + ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; + ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; + ListFormat[ListFormat["ClassHeritageClauses"] = 256] = "ClassHeritageClauses"; + ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; + ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; + ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; + ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; + ListFormat[ListFormat["NamedImportsOrExportsElements"] = 432] = "NamedImportsOrExportsElements"; + ListFormat[ListFormat["JsxElementChildren"] = 131072] = "JsxElementChildren"; + ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; + ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; + ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; + ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; + ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; + ListFormat[ListFormat["TypeArguments"] = 26960] = "TypeArguments"; + ListFormat[ListFormat["TypeParameters"] = 26960] = "TypeParameters"; + ListFormat[ListFormat["Parameters"] = 1360] = "Parameters"; + ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; + })(ListFormat || (ListFormat = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -50722,7 +52386,8 @@ var ts; commonPathComponents = sourcePathComponents; return; } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + var n = Math.min(commonPathComponents.length, sourcePathComponents.length); + for (var i = 0; i < n; i++) { if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { if (i === 0) { return true; @@ -50769,11 +52434,11 @@ var ts; return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; } function directoryExists(directoryPath) { - if (directoryPath in existingDirectories) { + if (existingDirectories.has(directoryPath)) { return true; } if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; + existingDirectories.set(directoryPath, true); return true; } return false; @@ -50792,9 +52457,10 @@ var ts; } var hash = ts.sys.createHash(data); var mtimeBefore = ts.sys.getModifiedTime(fileName); - if (mtimeBefore && fileName in outputFingerprints) { - var fingerprint = outputFingerprints[fileName]; - if (fingerprint.byteOrderMark === writeByteOrderMark && + if (mtimeBefore) { + var fingerprint = outputFingerprints.get(fileName); + if (fingerprint && + fingerprint.byteOrderMark === writeByteOrderMark && fingerprint.hash === hash && fingerprint.mtime.getTime() === mtimeBefore.getTime()) { return; @@ -50802,11 +52468,11 @@ var ts; } ts.sys.writeFile(fileName, data, writeByteOrderMark); var mtimeAfter = ts.sys.getModifiedTime(fileName); - outputFingerprints[fileName] = { + outputFingerprints.set(fileName, { hash: hash, byteOrderMark: writeByteOrderMark, mtime: mtimeAfter - }; + }); } function writeFile(fileName, data, writeByteOrderMark, onError) { try { @@ -50905,10 +52571,14 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_44 = names_1[_i]; - var result = name_44 in cache - ? cache[name_44] - : cache[name_44] = loader(name_44, containingFile); + var name = names_1[_i]; + var result = void 0; + if (cache.has(name)) { + result = cache.get(name); + } + else { + cache.set(name, result = loader(name, containingFile)); + } resolutions.push(result); } return resolutions; @@ -50933,6 +52603,7 @@ var ts; var currentDirectory = host.getCurrentDirectory(); var supportedExtensions = ts.getSupportedExtensions(options); var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); + var moduleResolutionCache; var resolveModuleNamesWorker; if (host.resolveModuleNames) { resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { @@ -50945,7 +52616,8 @@ var ts; }); }; } else { - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -50981,6 +52653,7 @@ var ts; } } } + moduleResolutionCache = undefined; oldProgram = undefined; program = { getRootFileNames: function () { return rootNames; }, @@ -51014,7 +52687,7 @@ var ts; return program; function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filterSourceFilesInDirectory(files, isSourceFileFromExternalLibrary); + var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); } @@ -51033,7 +52706,7 @@ var ts; classifiableNames = ts.createMap(); for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { var sourceFile = files_2[_i]; - ts.copyProperties(sourceFile.classifiableNames, classifiableNames); + ts.copyEntries(sourceFile.classifiableNames, classifiableNames); } } return classifiableNames; @@ -51187,7 +52860,7 @@ var ts; newSourceFile.resolvedModules = oldSourceFile.resolvedModules; newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } - for (var i = 0, len = newSourceFiles.length; i < len; i++) { + for (var i = 0; i < newSourceFiles.length; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; @@ -51216,7 +52889,7 @@ var ts; }; } function isSourceFileFromExternalLibrary(file) { - return sourceFilesFoundSearchingNodeModules[file.path]; + return sourceFilesFoundSearchingNodeModules.get(file.path); } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); @@ -51333,57 +53006,57 @@ var ts; return diagnostics; function walk(node) { switch (parent.kind) { - case 144: - case 147: + case 145: + case 148: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 184: - case 225: + case 153: case 185: + case 227: + case 186: + case 227: case 225: - case 223: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 234: + case 236: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 240: + case 242: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 255: + case 258: var heritageClause = node; if (heritageClause.token === 107) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 227: + case 229: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 230: + case 232: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 228: + case 230: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 229: + case 231: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 182: + case 183: var typeAssertionExpression = node; diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; @@ -51398,26 +53071,26 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 226: - case 149: - case 148: + case 228: case 150: + case 149: case 151: case 152: - case 184: - case 225: + case 153: case 185: - case 225: + case 227: + case 186: + case 227: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 205: + case 207: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 205); + return checkModifiers(nodes, parent.kind === 207); } break; - case 147: + case 148: if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; @@ -51428,15 +53101,15 @@ var ts; return; } break; - case 144: + case 145: if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 179: case 180: - case 199: + case 181: + case 200: if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); return; @@ -51524,11 +53197,10 @@ var ts; if (options.importHelpers && (options.isolatedModules || isExternalModuleFile) && !file.isDeclarationFile) { - var externalHelpersModuleReference = ts.createSynthesizedNode(9); - externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(235); - importDecl.parent = file; + var externalHelpersModuleReference = ts.createLiteral(ts.externalHelpersModuleNameText); + var importDecl = ts.createImportDeclaration(undefined, undefined, undefined); externalHelpersModuleReference.parent = importDecl; + importDecl.parent = file; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -51544,9 +53216,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 235: - case 234: - case 241: + case 237: + case 236: + case 243: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -51558,7 +53230,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 230: + case 232: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -51642,18 +53314,18 @@ var ts; if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd); } - if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { - sourceFilesFoundSearchingNodeModules[file_1.path] = false; + if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth == 0) { + sourceFilesFoundSearchingNodeModules.set(file_1.path, false); if (!options.noResolve) { processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } - else if (file_1 && modulesWithElidedImports[file_1.path]) { + else if (file_1 && modulesWithElidedImports.get(file_1.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } } @@ -51669,7 +53341,7 @@ var ts; }); filesByName.set(path, file); if (file) { - sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0); + sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; if (host.useCaseSensitiveFileNames()) { var existingFile = filesByNameIgnoreCase.get(path); @@ -51713,7 +53385,7 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { - var previousResolution = resolvedTypeReferenceDirectives[typeReferenceDirective]; + var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { return; } @@ -51741,7 +53413,7 @@ var ts; fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { - resolvedTypeReferenceDirectives[typeReferenceDirective] = resolvedTypeReferenceDirective; + resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); } } function createDiagnostic(refFile, refPos, refEnd, message) { @@ -51782,7 +53454,7 @@ var ts; var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { - modulesWithElidedImports[file.path] = true; + modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = ts.toPath(resolvedFileName, currentDirectory, getCanonicalFileName); @@ -51800,8 +53472,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var file = sourceFiles_6[_i]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var file = sourceFiles_3[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -51812,8 +53484,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -51964,7 +53636,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { + ts.forEachEmittedFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -52018,6 +53690,1139 @@ var ts; ts.getResolutionDiagnostic = getResolutionDiagnostic; })(ts || (ts = {})); var ts; +(function (ts) { + ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; + ts.optionDeclarations = [ + { + name: "charset", + type: "string", + }, + ts.compileOnSaveCommandLineOption, + { + name: "declaration", + shortName: "d", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_d_ts_file, + }, + { + name: "declarationDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + }, + { + name: "diagnostics", + type: "boolean", + }, + { + name: "extendedDiagnostics", + type: "boolean", + experimental: true + }, + { + name: "emitBOM", + type: "boolean" + }, + { + name: "help", + shortName: "h", + type: "boolean", + description: ts.Diagnostics.Print_this_message, + }, + { + name: "help", + shortName: "?", + type: "boolean" + }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, + }, + { + name: "inlineSourceMap", + type: "boolean", + }, + { + name: "inlineSources", + type: "boolean", + }, + { + name: "jsx", + type: ts.createMapFromTemplate({ + "preserve": 1, + "react-native": 3, + "react": 2 + }), + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, + }, + { + name: "reactNamespace", + type: "string", + description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit + }, + { + name: "jsxFactory", + type: "string", + description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + }, + { + name: "listFiles", + type: "boolean", + }, + { + name: "locale", + type: "string", + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + paramType: ts.Diagnostics.LOCATION, + }, + { + name: "module", + shortName: "m", + type: ts.createMapFromTemplate({ + "none": ts.ModuleKind.None, + "commonjs": ts.ModuleKind.CommonJS, + "amd": ts.ModuleKind.AMD, + "system": ts.ModuleKind.System, + "umd": ts.ModuleKind.UMD, + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, + }), + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, + paramType: ts.Diagnostics.KIND, + }, + { + name: "newLine", + type: ts.createMapFromTemplate({ + "crlf": 0, + "lf": 1 + }), + description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + paramType: ts.Diagnostics.NEWLINE, + }, + { + name: "noEmit", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_outputs, + }, + { + name: "noEmitHelpers", + type: "boolean" + }, + { + name: "noEmitOnError", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + }, + { + name: "noErrorTruncation", + type: "boolean" + }, + { + name: "noImplicitAny", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, + }, + { + name: "noImplicitThis", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, + }, + { + name: "noUnusedLocals", + type: "boolean", + description: ts.Diagnostics.Report_errors_on_unused_locals, + }, + { + name: "noUnusedParameters", + type: "boolean", + description: ts.Diagnostics.Report_errors_on_unused_parameters, + }, + { + name: "noLib", + type: "boolean", + }, + { + name: "noResolve", + type: "boolean", + }, + { + name: "skipDefaultLibCheck", + type: "boolean", + }, + { + name: "skipLibCheck", + type: "boolean", + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, + }, + { + name: "out", + type: "string", + isFilePath: false, + paramType: ts.Diagnostics.FILE, + }, + { + name: "outFile", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + paramType: ts.Diagnostics.FILE, + }, + { + name: "outDir", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Redirect_output_structure_to_the_directory, + paramType: ts.Diagnostics.DIRECTORY, + }, + { + name: "preserveConstEnums", + type: "boolean", + description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, + { + name: "pretty", + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, + type: "boolean" + }, + { + name: "project", + shortName: "p", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY + }, + { + name: "removeComments", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_comments_to_output, + }, + { + name: "rootDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + }, + { + name: "isolatedModules", + type: "boolean", + }, + { + name: "sourceMap", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_map_file, + }, + { + name: "sourceRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + paramType: ts.Diagnostics.LOCATION, + }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, + }, + { + name: "stripInternal", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, + experimental: true + }, + { + name: "target", + shortName: "t", + type: ts.createMapFromTemplate({ + "es3": 0, + "es5": 1, + "es6": 2, + "es2015": 2, + "es2016": 3, + "es2017": 4, + "esnext": 5, + }), + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, + paramType: ts.Diagnostics.VERSION, + }, + { + name: "version", + shortName: "v", + type: "boolean", + description: ts.Diagnostics.Print_the_compiler_s_version, + }, + { + name: "watch", + shortName: "w", + type: "boolean", + description: ts.Diagnostics.Watch_input_files, + }, + { + name: "experimentalDecorators", + type: "boolean", + description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + }, + { + name: "emitDecoratorMetadata", + type: "boolean", + experimental: true, + description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: ts.createMapFromTemplate({ + "node": ts.ModuleResolutionKind.NodeJs, + "classic": ts.ModuleResolutionKind.Classic, + }), + description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + paramType: ts.Diagnostics.STRATEGY, + }, + { + name: "allowUnusedLabels", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "noImplicitReturns", + type: "boolean", + description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + { + name: "allowUnreachableCode", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + { + name: "baseUrl", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names + }, + { + name: "paths", + type: "object", + isTSConfigOnly: true + }, + { + name: "rootDirs", + type: "list", + isTSConfigOnly: true, + element: { + name: "rootDirs", + type: "string", + isFilePath: true + } + }, + { + name: "typeRoots", + type: "list", + element: { + name: "typeRoots", + type: "string", + isFilePath: true + } + }, + { + name: "types", + type: "list", + element: { + name: "types", + type: "string" + }, + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + }, + { + name: "traceResolution", + type: "boolean", + description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process + }, + { + name: "allowJs", + type: "boolean", + description: ts.Diagnostics.Allow_javascript_files_to_be_compiled + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + { + name: "noImplicitUseStrict", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output + }, + { + name: "maxNodeModuleJsDepth", + type: "number", + description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files + }, + { + name: "listEmittedFiles", + type: "boolean" + }, + { + name: "lib", + type: "list", + element: { + name: "lib", + type: ts.createMapFromTemplate({ + "es5": "lib.es5.d.ts", + "es6": "lib.es2015.d.ts", + "es2015": "lib.es2015.d.ts", + "es7": "lib.es2016.d.ts", + "es2016": "lib.es2016.d.ts", + "es2017": "lib.es2017.d.ts", + "dom": "lib.dom.d.ts", + "dom.iterable": "lib.dom.iterable.d.ts", + "webworker": "lib.webworker.d.ts", + "scripthost": "lib.scripthost.d.ts", + "es2015.core": "lib.es2015.core.d.ts", + "es2015.collection": "lib.es2015.collection.d.ts", + "es2015.generator": "lib.es2015.generator.d.ts", + "es2015.iterable": "lib.es2015.iterable.d.ts", + "es2015.promise": "lib.es2015.promise.d.ts", + "es2015.proxy": "lib.es2015.proxy.d.ts", + "es2015.reflect": "lib.es2015.reflect.d.ts", + "es2015.symbol": "lib.es2015.symbol.d.ts", + "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", + "es2016.array.include": "lib.es2016.array.include.d.ts", + "es2017.object": "lib.es2017.object.d.ts", + "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", + "es2017.string": "lib.es2017.string.d.ts", + }), + }, + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon + }, + { + name: "disableSizeLimit", + type: "boolean" + }, + { + name: "strictNullChecks", + type: "boolean", + description: ts.Diagnostics.Enable_strict_null_checks + }, + { + name: "importHelpers", + type: "boolean", + description: ts.Diagnostics.Import_emit_helpers_from_tslib + }, + { + name: "alwaysStrict", + type: "boolean", + description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + }, + { + name: "plugins", + type: "list", + isTSConfigOnly: true, + element: { + name: "plugin", + type: "object" + } + } + ]; + ts.typeAcquisitionDeclarations = [ + { + name: "enableAutoDiscovery", + type: "boolean", + }, + { + name: "enable", + type: "boolean", + }, + { + name: "include", + type: "list", + element: { + name: "include", + type: "string" + } + }, + { + name: "exclude", + type: "list", + element: { + name: "exclude", + type: "string" + } + } + ]; + ts.defaultInitCompilerOptions = { + module: ts.ModuleKind.CommonJS, + target: 1, + noImplicitAny: false, + sourceMap: false, + }; + var optionNameMapCache; + function convertEnableAutoDiscoveryToEnable(typeAcquisition) { + if (typeAcquisition && typeAcquisition.enableAutoDiscovery !== undefined && typeAcquisition.enable === undefined) { + var result = { + enable: typeAcquisition.enableAutoDiscovery, + include: typeAcquisition.include || [], + exclude: typeAcquisition.exclude || [] + }; + return result; + } + return typeAcquisition; + } + ts.convertEnableAutoDiscoveryToEnable = convertEnableAutoDiscoveryToEnable; + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } + var optionNameMap = ts.createMap(); + var shortOptionNames = ts.createMap(); + ts.forEach(ts.optionDeclarations, function (option) { + optionNameMap.set(option.name.toLowerCase(), option); + if (option.shortName) { + shortOptionNames.set(option.shortName, option.name); + } + }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function createCompilerDiagnosticForInvalidCustomType(opt) { + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); + return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + } + ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; + function parseCustomTypeOption(opt, value, errors) { + return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors); + } + ts.parseCustomTypeOption = parseCustomTypeOption; + function parseListTypeOption(opt, value, errors) { + if (value === void 0) { value = ""; } + value = trimString(value); + if (ts.startsWith(value, "-")) { + return undefined; + } + if (value === "") { + return []; + } + var values = value.split(","); + switch (opt.element.type) { + case "number": + return ts.map(values, parseInt); + case "string": + return ts.map(values, function (v) { return v || ""; }); + default: + return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); + } + } + ts.parseListTypeOption = parseListTypeOption; + function parseCommandLine(commandLine, readFile) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; + parseStrings(commandLine); + return { + options: options, + fileNames: fileNames, + errors: errors + }; + function parseStrings(args) { + var i = 0; + while (i < args.length) { + var s = args[i]; + i++; + if (s.charCodeAt(0) === 64) { + parseResponseFile(s.slice(1)); + } + else if (s.charCodeAt(0) === 45) { + s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); + var short = shortOptionNames.get(s); + if (short !== undefined) { + s = short; + } + var opt = optionNameMap.get(s); + if (opt) { + if (opt.isTSConfigOnly) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); + } + else { + if (!args[i] && opt.type !== "boolean") { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); + } + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i]); + i++; + break; + case "boolean": + var optValue = args[i]; + options[opt.name] = optValue !== "false"; + if (optValue === "false" || optValue === "true") { + i++; + } + break; + case "string": + options[opt.name] = args[i] || ""; + i++; + break; + case "list": + var result = parseListTypeOption(opt, args[i], errors); + options[opt.name] = result || []; + if (result) { + i++; + } + break; + default: + options[opt.name] = parseCustomTypeOption(opt, args[i], errors); + i++; + break; + } + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s)); + } + } + else { + fileNames.push(s); + } + } + } + function parseResponseFile(fileName) { + var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); + if (!text) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); + return; + } + var args = []; + var pos = 0; + while (true) { + while (pos < text.length && text.charCodeAt(pos) <= 32) + pos++; + if (pos >= text.length) + break; + var start = pos; + if (text.charCodeAt(start) === 34) { + pos++; + while (pos < text.length && text.charCodeAt(pos) !== 34) + pos++; + if (pos < text.length) { + args.push(text.substring(start + 1, pos)); + pos++; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName)); + } + } + else { + while (text.charCodeAt(pos) > 32) + pos++; + args.push(text.substring(start, pos)); + } + } + parseStrings(args); + } + } + ts.parseCommandLine = parseCommandLine; + function readConfigFile(fileName, readFile) { + var text = ""; + try { + text = readFile(fileName); + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; + } + return parseConfigFileTextToJson(fileName, text); + } + ts.readConfigFile = readConfigFile; + function parseConfigFileTextToJson(fileName, jsonText, stripComments) { + if (stripComments === void 0) { stripComments = true; } + try { + var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; + return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; + } + } + ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + function generateTSConfig(options, fileNames) { + var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); + var configurations = { + compilerOptions: serializeCompilerOptions(compilerOptions) + }; + if (fileNames && fileNames.length) { + configurations.files = fileNames; + } + return configurations; + function getCustomTypeMapOfCommandLineOption(optionDefinition) { + if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { + return undefined; + } + else if (optionDefinition.type === "list") { + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); + } + else { + return optionDefinition.type; + } + } + function getNameOfCompilerOptionValue(value, customTypeMap) { + return ts.forEachEntry(customTypeMap, function (mapValue, key) { + if (mapValue === value) { + return key; + } + }); + } + function serializeCompilerOptions(options) { + var result = {}; + var optionsNameMap = getOptionNameMap().optionNameMap; + for (var name in options) { + if (ts.hasProperty(options, name)) { + switch (name) { + case "init": + case "watch": + case "version": + case "help": + case "project": + break; + default: + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); + if (optionDefinition) { + var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap) { + result[name] = value; + } + else { + if (optionDefinition.type === "list") { + var convertedValue = []; + for (var _i = 0, _a = value; _i < _a.length; _i++) { + var element = _a[_i]; + convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); + } + result[name] = convertedValue; + } + else { + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); + } + } + } + break; + } + } + } + return result; + } + } + ts.generateTSConfig = generateTSConfig; + function removeComments(jsonText) { + var output = ""; + var scanner = ts.createScanner(1, false, 0, jsonText); + var token; + while ((token = scanner.scan()) !== 1) { + switch (token) { + case 2: + case 3: + output += scanner.getTokenText().replace(/\S/g, " "); + break; + default: + output += scanner.getTokenText(); + break; + } + } + return output; + } + function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions) { + if (existingOptions === void 0) { existingOptions = {}; } + if (resolutionStack === void 0) { resolutionStack = []; } + if (extraFileExtensions === void 0) { extraFileExtensions = []; } + var errors = []; + basePath = ts.normalizeSlashes(basePath); + var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); + if (resolutionStack.indexOf(resolvedPath) >= 0) { + return { + options: {}, + fileNames: [], + typeAcquisition: {}, + raw: json, + errors: [ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))], + wildcardDirectories: {} + }; + } + var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); + var jsonOptions = json["typeAcquisition"] || json["typingOptions"]; + var typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); + if (json["extends"]) { + var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; + if (typeof json["extends"] === "string") { + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); + } + if (include && !json["include"]) { + json["include"] = include; + } + if (exclude && !json["exclude"]) { + json["exclude"] = exclude; + } + if (files && !json["files"]) { + json["files"] = files; + } + options = ts.assign({}, baseOptions, options); + } + options = ts.extend(existingOptions, options); + options.configFilePath = configFileName; + var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; + var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + return { + options: options, + fileNames: fileNames, + typeAcquisition: typeAcquisition, + raw: json, + errors: errors, + wildcardDirectories: wildcardDirectories, + compileOnSave: compileOnSave + }; + function tryExtendsName(extendedConfig) { + if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig)); + return; + } + var extendedConfigPath = ts.toPath(extendedConfig, basePath, getCanonicalFileName); + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { + extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return; + } + } + var extendedResult = readConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); + if (extendedResult.error) { + errors.push(extendedResult.error); + return; + } + var extendedDirname = ts.getDirectoryPath(extendedConfigPath); + var relativeDifference = ts.convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); + var updatePath = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference, path); }; + var result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, undefined, ts.getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath])); + errors.push.apply(errors, result.errors); + var _a = ts.map(["include", "exclude", "files"], function (key) { + if (!json[key] && extendedResult.config[key]) { + return ts.map(extendedResult.config[key], updatePath); + } + }), include = _a[0], exclude = _a[1], files = _a[2]; + return [include, exclude, files, result.options]; + } + function getFileNames(errors) { + var fileNames; + if (ts.hasProperty(json, "files")) { + if (ts.isArray(json["files"])) { + fileNames = json["files"]; + if (fileNames.length === 0) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json")); + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } + } + var includeSpecs; + if (ts.hasProperty(json, "include")) { + if (ts.isArray(json["include"])) { + includeSpecs = json["include"]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array")); + } + } + var excludeSpecs; + if (ts.hasProperty(json, "exclude")) { + if (ts.isArray(json["exclude"])) { + excludeSpecs = json["exclude"]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array")); + } + } + else if (ts.hasProperty(json, "excludes")) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); + } + else { + excludeSpecs = includeSpecs ? [] : ["node_modules", "bower_components", "jspm_packages"]; + var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; + if (outDir) { + excludeSpecs.push(outDir); + } + } + if (fileNames === undefined && includeSpecs === undefined) { + includeSpecs = ["**/*"]; + } + var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions); + if (result.fileNames.length === 0 && !ts.hasProperty(json, "files") && resolutionStack.length === 0) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, configFileName || "tsconfig.json", JSON.stringify(includeSpecs || []), JSON.stringify(excludeSpecs || []))); + } + return result; + } + var _b; + } + ts.parseJsonConfigFileContent = parseJsonConfigFileContent; + function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { + if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { + return false; + } + var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); + if (typeof result === "boolean" && result) { + return result; + } + return false; + } + ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; + function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { + var errors = []; + var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); + return { options: options, errors: errors }; + } + ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; + function convertTypeAcquisitionFromJson(jsonOptions, basePath, configFileName) { + var errors = []; + var options = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); + return { options: options, errors: errors }; + } + ts.convertTypeAcquisitionFromJson = convertTypeAcquisitionFromJson; + function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { + var options = ts.getBaseFileName(configFileName) === "jsconfig.json" + ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } + : {}; + convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); + return options; + } + function convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName) { + var options = { enable: ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; + var typeAcquisition = convertEnableAutoDiscoveryToEnable(jsonOptions); + convertOptionsFromJson(ts.typeAcquisitionDeclarations, typeAcquisition, basePath, options, ts.Diagnostics.Unknown_type_acquisition_option_0, errors); + return options; + } + function convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, defaultOptions, diagnosticMessage, errors) { + if (!jsonOptions) { + return; + } + var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); + for (var id in jsonOptions) { + var opt = optionNameMap.get(id); + if (opt) { + defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); + } + else { + errors.push(ts.createCompilerDiagnostic(diagnosticMessage, id)); + } + } + } + function convertJsonOption(opt, value, basePath, errors) { + var optType = opt.type; + var expectedType = typeof optType === "string" ? optType : "string"; + if (optType === "list" && ts.isArray(value)) { + return convertJsonOptionOfListType(opt, value, basePath, errors); + } + else if (typeof value === expectedType) { + if (typeof optType !== "string") { + return convertJsonOptionOfCustomType(opt, value, errors); + } + else { + if (opt.isFilePath) { + value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } + } + } + return value; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType)); + } + } + function convertJsonOptionOfCustomType(opt, value, errors) { + var key = value.toLowerCase(); + var val = opt.type.get(key); + if (val !== undefined) { + return val; + } + else { + errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); + } + } + function convertJsonOptionOfListType(option, values, basePath, errors) { + return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); + } + function trimString(s) { + return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); + } + var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; + var invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/; + var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; + var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; + var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/; + function matchFileNames(fileNames, include, exclude, basePath, options, host, errors, extraFileExtensions) { + basePath = ts.normalizePath(basePath); + var keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper; + var literalFileMap = ts.createMap(); + var wildcardFileMap = ts.createMap(); + if (include) { + include = validateSpecs(include, errors, false); + } + if (exclude) { + exclude = validateSpecs(exclude, errors, true); + } + var wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); + var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions); + if (fileNames) { + for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { + var fileName = fileNames_1[_i]; + var file = ts.combinePaths(basePath, fileName); + literalFileMap.set(keyMapper(file), file); + } + } + if (include && include.length > 0) { + for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, exclude, include); _a < _b.length; _a++) { + var file = _b[_a]; + if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) { + continue; + } + removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); + var key = keyMapper(file); + if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) { + wildcardFileMap.set(key, file); + } + } + } + var literalFiles = ts.arrayFrom(literalFileMap.values()); + var wildcardFiles = ts.arrayFrom(wildcardFileMap.values()); + return { + fileNames: literalFiles.concat(wildcardFiles), + wildcardDirectories: wildcardDirectories + }; + } + function validateSpecs(specs, errors, allowTrailingRecursion) { + var validSpecs = []; + for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { + var spec = specs_1[_i]; + if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + } + else if (invalidMultipleRecursionPatterns.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); + } + else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + } + else { + validSpecs.push(spec); + } + } + return validSpecs; + } + function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { + var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); + var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); + var wildcardDirectories = {}; + if (include !== undefined) { + var recursiveKeys = []; + for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { + var file = include_1[_i]; + var spec = ts.normalizePath(ts.combinePaths(path, file)); + if (excludeRegex && excludeRegex.test(spec)) { + continue; + } + var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames); + if (match) { + var key = match.key, flags = match.flags; + var existingFlags = wildcardDirectories[key]; + if (existingFlags === undefined || existingFlags < flags) { + wildcardDirectories[key] = flags; + if (flags === 1) { + recursiveKeys.push(key); + } + } + } + } + for (var key in wildcardDirectories) + if (ts.hasProperty(wildcardDirectories, key)) { + for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { + var recursiveKey = recursiveKeys_1[_a]; + if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; + } + } + } + ; + } + return wildcardDirectories; + } + function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) { + var match = wildcardDirectoryPattern.exec(spec); + if (match) { + return { + key: useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(), + flags: watchRecursivePattern.test(spec) ? 1 : 0 + }; + } + if (ts.isImplicitGlob(spec)) { + return { key: spec, flags: 1 }; + } + return undefined; + } + function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { + var extensionPriority = ts.getExtensionPriority(file, extensions); + var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions); + for (var i = 0; i < adjustedExtensionPriority; i++) { + var higherPriorityExtension = extensions[i]; + var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); + if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { + return true; + } + } + return false; + } + function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { + var extensionPriority = ts.getExtensionPriority(file, extensions); + var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions); + for (var i = nextExtensionPriority; i < extensions.length; i++) { + var lowerPriorityExtension = extensions[i]; + var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); + wildcardFiles.delete(lowerPriorityPath); + } + } + function caseSensitiveKeyMapper(key) { + return key; + } + function caseInsensitiveKeyMapper(key) { + return key.toLowerCase(); + } +})(ts || (ts = {})); +var ts; (function (ts) { var ScriptSnapshot; (function (ScriptSnapshot) { @@ -52087,6 +54892,22 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + var OutputFileType; + (function (OutputFileType) { + OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; + OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; + OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; + })(OutputFileType = ts.OutputFileType || (ts.OutputFileType = {})); + var EndOfLineState; + (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"; + })(EndOfLineState = ts.EndOfLineState || (ts.EndOfLineState = {})); var TokenClass; (function (TokenClass) { TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; @@ -52133,6 +54954,7 @@ var ts; ScriptElementKind.letElement = "let"; ScriptElementKind.directory = "directory"; ScriptElementKind.externalModuleName = "external module name"; + ScriptElementKind.jsxAttribute = "JSX attribute"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; (function (ScriptElementKindModifier) { @@ -52174,40 +54996,76 @@ var ts; ClassificationTypeNames.jsxText = "jsx text"; ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; ts.ClassificationTypeNames = ClassificationTypeNames; + var ClassificationType; + (function (ClassificationType) { + ClassificationType[ClassificationType["comment"] = 1] = "comment"; + ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; + ClassificationType[ClassificationType["keyword"] = 3] = "keyword"; + ClassificationType[ClassificationType["numericLiteral"] = 4] = "numericLiteral"; + ClassificationType[ClassificationType["operator"] = 5] = "operator"; + ClassificationType[ClassificationType["stringLiteral"] = 6] = "stringLiteral"; + ClassificationType[ClassificationType["regularExpressionLiteral"] = 7] = "regularExpressionLiteral"; + ClassificationType[ClassificationType["whiteSpace"] = 8] = "whiteSpace"; + ClassificationType[ClassificationType["text"] = 9] = "text"; + ClassificationType[ClassificationType["punctuation"] = 10] = "punctuation"; + ClassificationType[ClassificationType["className"] = 11] = "className"; + ClassificationType[ClassificationType["enumName"] = 12] = "enumName"; + ClassificationType[ClassificationType["interfaceName"] = 13] = "interfaceName"; + ClassificationType[ClassificationType["moduleName"] = 14] = "moduleName"; + ClassificationType[ClassificationType["typeParameterName"] = 15] = "typeParameterName"; + ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName"; + ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName"; + ClassificationType[ClassificationType["docCommentTagName"] = 18] = "docCommentTagName"; + ClassificationType[ClassificationType["jsxOpenTagName"] = 19] = "jsxOpenTagName"; + ClassificationType[ClassificationType["jsxCloseTagName"] = 20] = "jsxCloseTagName"; + ClassificationType[ClassificationType["jsxSelfClosingTagName"] = 21] = "jsxSelfClosingTagName"; + ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; + ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; + ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; + })(ClassificationType = ts.ClassificationType || (ts.ClassificationType = {})); })(ts || (ts = {})); var ts; (function (ts) { ts.scanner = ts.createScanner(5, true); ts.emptyArray = []; + 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 = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 144: - case 223: - case 174: - case 147: - case 146: - case 257: - case 258: - case 260: - case 149: + case 145: + case 225: + case 175: case 148: + case 147: + case 260: + case 261: + case 263: case 150: + case 149: case 151: case 152: - case 225: - case 184: - case 185: - case 256: - return 1; - case 143: + case 153: case 227: - case 228: - case 161: - return 2; - case 226: + case 185: + case 186: + case 259: + case 252: + return 1; + case 144: case 229: - return 1 | 2; case 230: + case 162: + return 2; + case 228: + case 231: + return 1 | 2; + case 232: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -52217,21 +55075,24 @@ var ts; else { return 4; } - case 238: - case 239: - case 234: - case 235: case 240: case 241: + case 236: + case 237: + case 242: + case 243: return 1 | 2 | 4; - case 261: + case 264: return 4 | 1; } return 1 | 2 | 4; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 240) { + if (node.kind === 264) { + return 1; + } + else if (node.parent.kind === 242) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -52253,15 +55114,15 @@ var ts; ts.getMeaningFromLocation = getMeaningFromLocation; function getMeaningFromRightHandSideOfImportEquals(node) { ts.Debug.assert(node.kind === 70); - if (node.parent.kind === 141 && + if (node.parent.kind === 142 && node.parent.right === node && - node.parent.parent.kind === 234) { + node.parent.parent.kind === 236) { return 1 | 2 | 4; } return 4; } function isInRightSideOfImport(node) { - while (node.parent.kind === 141) { + while (node.parent.kind === 142) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -52272,27 +55133,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 141) { - while (root.parent && root.parent.kind === 141) { + if (root.parent.kind === 142) { + while (root.parent && root.parent.kind === 142) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 157 && !isLastClause; + return root.parent.kind === 158 && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 177) { - while (root.parent && root.parent.kind === 177) { + if (root.parent.kind === 178) { + while (root.parent && root.parent.kind === 178) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 199 && root.parent.parent.kind === 255) { + if (!isLastClause && root.parent.kind === 200 && root.parent.parent.kind === 258) { var decl = root.parent.parent.parent; - return (decl.kind === 226 && root.parent.parent.token === 107) || - (decl.kind === 227 && root.parent.parent.token === 84); + return (decl.kind === 228 && root.parent.parent.token === 107) || + (decl.kind === 229 && root.parent.parent.token === 84); } return false; } @@ -52300,17 +55161,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 157 || - (node.parent.kind === 199 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + return node.parent.kind === 158 || + (node.parent.kind === 200 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || (node.kind === 98 && !ts.isPartOfExpression(node)) || - node.kind === 167; + node.kind === 168; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 179); + return isCallOrNewExpressionTarget(node, 180); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 180); + return isCallOrNewExpressionTarget(node, 181); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -52323,7 +55184,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 219 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 221 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -52333,13 +55194,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 && - (node.parent.kind === 215 || node.parent.kind === 214) && + (node.parent.kind === 217 || node.parent.kind === 216) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 && - node.parent.kind === 219 && + node.parent.kind === 221 && node.parent.label === node; } function isLabelName(node) { @@ -52347,15 +55208,15 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 141 && node.parent.right === node; + return node.parent.kind === 142 && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 177 && node.parent.name === node; + return node && node.parent && node.parent.kind === 178 && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 230 && node.parent.name === node; + return node.parent.kind === 232 && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -52366,19 +55227,19 @@ var ts; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { - case 147: - case 146: - case 257: - case 260: - case 149: case 148: - case 151: + case 147: + case 260: + case 263: + case 150: + case 149: case 152: - case 230: + case 153: + case 232: return node.parent.name === node; - case 178: + case 179: return node.parent.argumentExpression === node; - case 142: + case 143: return true; } } @@ -52422,17 +55283,17 @@ var ts; return undefined; } switch (node.kind) { - case 261: + case 264: + case 150: case 149: - case 148: - case 225: - case 184: - case 151: - case 152: - case 226: case 227: + case 185: + case 152: + case 153: + case 228: case 229: - case 230: + case 231: + case 232: return node; } } @@ -52440,46 +55301,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 261: + case 264: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 230: + case 232: return ts.ScriptElementKind.moduleElement; - case 226: - case 197: + case 228: + case 198: return ts.ScriptElementKind.classElement; - case 227: return ts.ScriptElementKind.interfaceElement; - case 228: return ts.ScriptElementKind.typeElement; - case 229: return ts.ScriptElementKind.enumElement; - case 223: - return getKindOfVariableDeclaration(node); - case 174: - return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 185: + case 229: return ts.ScriptElementKind.interfaceElement; + case 230: return ts.ScriptElementKind.typeElement; + case 231: return ts.ScriptElementKind.enumElement; case 225: - case 184: + return getKindOfVariableDeclaration(node); + case 175: + return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); + case 186: + case 227: + case 185: return ts.ScriptElementKind.functionElement; - case 151: return ts.ScriptElementKind.memberGetAccessorElement; - case 152: return ts.ScriptElementKind.memberSetAccessorElement; + case 152: return ts.ScriptElementKind.memberGetAccessorElement; + case 153: return ts.ScriptElementKind.memberSetAccessorElement; + case 150: case 149: - case 148: return ts.ScriptElementKind.memberFunctionElement; + case 148: case 147: - case 146: return ts.ScriptElementKind.memberVariableElement; - case 155: return ts.ScriptElementKind.indexSignatureElement; - case 154: return ts.ScriptElementKind.constructSignatureElement; - case 153: return ts.ScriptElementKind.callSignatureElement; - case 150: return ts.ScriptElementKind.constructorImplementationElement; - case 143: return ts.ScriptElementKind.typeParameterElement; - case 260: return ts.ScriptElementKind.enumMemberElement; - case 144: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 234: - case 239: + case 156: return ts.ScriptElementKind.indexSignatureElement; + case 155: return ts.ScriptElementKind.constructSignatureElement; + case 154: return ts.ScriptElementKind.callSignatureElement; + case 151: return ts.ScriptElementKind.constructorImplementationElement; + case 144: return ts.ScriptElementKind.typeParameterElement; + case 263: return ts.ScriptElementKind.enumMemberElement; + case 145: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; case 236: - case 243: - case 237: + case 241: + case 238: + case 245: + case 239: return ts.ScriptElementKind.alias; - case 285: + case 289: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -52494,7 +55355,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 171 ? node.parent : node; + var searchNode = node.parent.kind === 172 ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32) { return type; @@ -52507,7 +55368,7 @@ var ts; case 98: return true; case 70: - return ts.identifierIsThisKeyword(node) && node.parent.kind === 144; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 145; default: return false; } @@ -52551,41 +55412,41 @@ var ts; return false; } switch (n.kind) { - case 226: - case 227: + case 228: case 229: - case 176: - case 172: - case 161: - case 204: case 231: - case 232: - case 238: - case 242: + case 177: + case 173: + case 162: + case 206: + case 233: + case 234: + case 240: + case 244: return nodeEndsWith(n, 17, sourceFile); - case 256: + case 259: return isCompletedNode(n.block, sourceFile); - case 180: + case 181: if (!n.arguments) { return true; } - case 179: - case 183: - case 166: + case 180: + case 184: + case 167: return nodeEndsWith(n, 19, sourceFile); - case 158: case 159: + case 160: return isCompletedNode(n.type, sourceFile); - case 150: case 151: case 152: - case 225: - case 184: - case 149: - case 148: - case 154: case 153: + case 227: case 185: + case 150: + case 149: + case 155: + case 154: + case 186: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -52593,65 +55454,65 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19, sourceFile); - case 230: + case 232: return n.body && isCompletedNode(n.body, sourceFile); - case 208: + case 210: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 207: + case 209: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24); - case 175: - case 173: - case 178: - case 142: - case 163: + case 176: + case 174: + case 179: + case 143: + case 164: return nodeEndsWith(n, 21, sourceFile); - case 155: + case 156: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21, sourceFile); - case 253: - case 254: + case 256: + case 257: return false; - case 211: - case 212: case 213: - case 210: + case 214: + case 215: + case 212: return isCompletedNode(n.statement, sourceFile); - case 209: + case 211: var hasWhileKeyword = findChildOfKind(n, 105, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 19, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 160: + case 161: return isCompletedNode(n.exprName, sourceFile); - case 187: - case 186: case 188: - case 195: + case 187: + case 189: case 196: + case 197: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 181: + case 182: return isCompletedNode(n.template, sourceFile); - case 194: + case 195: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 202: + case 204: return ts.nodeIsPresent(n.literal); - case 241: - case 235: + case 243: + case 237: return ts.nodeIsPresent(n.moduleSpecifier); - case 190: + case 191: return isCompletedNode(n.operand, sourceFile); - case 192: - return isCompletedNode(n.right, sourceFile); case 193: + return isCompletedNode(n.right, sourceFile); + case 194: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -52694,7 +55555,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 292 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 296 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -52749,8 +55610,8 @@ var ts; } } } - for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { - var child = current.getChildAt(i); + for (var _a = 0, _b = current.getChildren(); _a < _b.length; _a++) { + var child = _b[_a]; if (ts.isJSDocNode(child)) { continue; } @@ -52814,7 +55675,7 @@ var ts; return n; } var children = n.getChildren(); - for (var i = 0, len = children.length; i < len; i++) { + for (var i = 0; i < children.length; i++) { var child = children[i]; if (position < child.end && (nodeHasTokens(child) || child.kind === 10)) { var start = child.getStart(sourceFile); @@ -52829,7 +55690,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 261); + ts.Debug.assert(startNode !== undefined || n.kind === 264); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -52874,13 +55735,13 @@ var ts; if (token.kind === 26 && token.parent.kind === 10) { return true; } - if (token.kind === 26 && token.parent.kind === 252) { + if (token.kind === 26 && token.parent.kind === 255) { return true; } - if (token && token.kind === 17 && token.parent.kind === 252) { + if (token && token.kind === 17 && token.parent.kind === 255) { return true; } - if (token.kind === 26 && token.parent.kind === 249) { + if (token.kind === 26 && token.parent.kind === 251) { return true; } return false; @@ -52971,17 +55832,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 157 || node.kind === 179) { + if (node.kind === 158 || node.kind === 180) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 226 || node.kind === 227) { + if (ts.isFunctionLike(node) || node.kind === 228 || node.kind === 229) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 140; + return n.kind >= 0 && n.kind <= 141; } ts.isToken = isToken; function isWord(kind) { @@ -53040,18 +55901,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 175 || - node.kind === 176) { - if (node.parent.kind === 192 && + if (node.kind === 176 || + node.kind === 177) { + if (node.parent.kind === 193 && node.parent.left === node && node.parent.operatorToken.kind === 57) { return true; } - if (node.parent.kind === 213 && + if (node.parent.kind === 215 && node.parent.initializer === node) { return true; } - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 257 ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 260 ? node.parent.parent : node.parent)) { return true; } } @@ -53079,10 +55940,30 @@ var ts; } } ts.isInNonReferenceComment = isInNonReferenceComment; + function createTextSpanFromNode(node, sourceFile) { + return ts.createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); + } + ts.createTextSpanFromNode = createTextSpanFromNode; + function isTypeKeyword(kind) { + switch (kind) { + case 118: + case 121: + case 129: + case 132: + case 133: + case 135: + case 136: + case 104: + return true; + default: + return false; + } + } + ts.isTypeKeyword = isTypeKeyword; })(ts || (ts = {})); (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 144; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 145; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -53106,7 +55987,8 @@ var ts; decreaseIndent: function () { indent--; }, clear: resetWriter, trackSymbol: ts.noop, - reportInaccessibleThisError: ts.noop + reportInaccessibleThisError: ts.noop, + reportIllegalExtends: ts.noop }; function writeIndent() { if (lineStart) { @@ -53258,7 +56140,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location) && - location.parent.kind === 142) { + location.parent.kind === 143) { return location.text; } var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); @@ -53268,7 +56150,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 239 || location.parent.kind === 243) && + (location.parent.kind === 241 || location.parent.kind === 245) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -53325,6 +56207,10 @@ var ts; }; } ts.sanitizeConfigFile = sanitizeConfigFile; + function getOpenBraceEnd(constructor, sourceFile) { + return constructor.body.getFirstToken(sourceFile).getEnd(); + } + ts.getOpenBraceEnd = getOpenBraceEnd; })(ts || (ts = {})); var ts; (function (ts) { @@ -53373,89 +56259,89 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 205: + case 207: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 223: - case 147: - case 146: - return spanInVariableDeclaration(node); - case 144: - return spanInParameterDeclaration(node); case 225: - case 149: case 148: - case 151: - case 152: + case 147: + return spanInVariableDeclaration(node); + case 145: + return spanInParameterDeclaration(node); + case 227: case 150: - case 184: + case 149: + case 152: + case 153: + case 151: case 185: + case 186: return spanInFunctionDeclaration(node); - case 204: + case 206: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 231: + case 233: return spanInBlock(node); - case 256: + case 259: return spanInBlock(node.block); - case 207: - return textSpan(node.expression); - case 216: - return textSpan(node.getChildAt(0), node.expression); - case 210: - return textSpanEndingAtNextToken(node, node.expression); case 209: - return spanInNode(node.statement); - case 222: - return textSpan(node.getChildAt(0)); - case 208: - return textSpanEndingAtNextToken(node, node.expression); - case 219: - return spanInNode(node.statement); - case 215: - case 214: - return textSpan(node.getChildAt(0), node.label); - case 211: - return spanInForStatement(node); + return textSpan(node.expression); + case 218: + return textSpan(node.getChildAt(0), node.expression); case 212: return textSpanEndingAtNextToken(node, node.expression); - case 213: - return spanInInitializerOfForLike(node); - case 218: + case 211: + return spanInNode(node.statement); + case 224: + return textSpan(node.getChildAt(0)); + case 210: return textSpanEndingAtNextToken(node, node.expression); - case 253: - case 254: - return spanInNode(node.statements[0]); case 221: - return spanInBlock(node.tryBlock); + return spanInNode(node.statement); + case 217: + case 216: + return textSpan(node.getChildAt(0), node.label); + case 213: + return spanInForStatement(node); + case 214: + return textSpanEndingAtNextToken(node, node.expression); + case 215: + return spanInInitializerOfForLike(node); case 220: + return textSpanEndingAtNextToken(node, node.expression); + case 256: + case 257: + return spanInNode(node.statements[0]); + case 223: + return spanInBlock(node.tryBlock); + case 222: return textSpan(node, node.expression); - case 240: + case 242: return textSpan(node, node.expression); - case 234: + case 236: return textSpan(node, node.moduleReference); - case 235: + case 237: return textSpan(node, node.moduleSpecifier); - case 241: + case 243: return textSpan(node, node.moduleSpecifier); - case 230: + case 232: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 226: - case 229: - case 260: - case 174: - return textSpan(node); - case 217: - return spanInNode(node.statement); - case 145: - return spanInNodeArray(node.parent.decorators); - case 172: - case 173: - return spanInBindingPattern(node); - case 227: case 228: + case 231: + case 263: + case 175: + return textSpan(node); + case 219: + return spanInNode(node.statement); + case 146: + return spanInNodeArray(node.parent.decorators); + case 173: + case 174: + return spanInBindingPattern(node); + case 229: + case 230: return undefined; case 24: case 1: @@ -53483,20 +56369,20 @@ var ts; case 73: case 86: return spanInNextNode(node); - case 140: + case 141: return spanInOfKeyword(node); default: if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node); } if ((node.kind === 70 || - node.kind == 196 || - node.kind === 257 || - node.kind === 258) && + node.kind == 197 || + node.kind === 260 || + node.kind === 261) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 192) { + if (node.kind === 193) { var binaryExpression = node; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); @@ -53511,38 +56397,38 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 209: - return spanInPreviousNode(node); - case 145: - return spanInNode(node.parent); case 211: + return spanInPreviousNode(node); + case 146: + return spanInNode(node.parent); case 213: + case 215: return textSpan(node); - case 192: + case 193: if (node.parent.operatorToken.kind === 25) { return textSpan(node); } break; - case 185: + case 186: if (node.parent.body === node) { return textSpan(node); } break; } } - if (node.parent.kind === 257 && + if (node.parent.kind === 260 && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 182 && node.parent.type === node) { + if (node.parent.kind === 183 && node.parent.type === node) { return spanInNextNode(node.parent.type); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { return spanInPreviousNode(node); } - if ((node.parent.kind === 223 || - node.parent.kind === 144)) { + if ((node.parent.kind === 225 || + node.parent.kind === 145)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -53550,7 +56436,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 192) { + if (node.parent.kind === 193) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -53571,7 +56457,7 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 212) { + if (variableDeclaration.parent.parent.kind === 214) { return spanInNode(variableDeclaration.parent.parent); } if (ts.isBindingPattern(variableDeclaration.name)) { @@ -53579,7 +56465,7 @@ var ts; } if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 213) { + variableDeclaration.parent.parent.kind === 215) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -53611,7 +56497,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 226 && functionDeclaration.kind !== 150); + (functionDeclaration.parent.kind === 228 && functionDeclaration.kind !== 151); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -53631,22 +56517,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 230: + case 232: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 210: - case 208: case 212: + case 210: + case 214: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 211: case 213: + case 215: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 224) { + if (forLikeStatement.initializer.kind === 226) { var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -53668,62 +56554,62 @@ var ts; } } function spanInBindingPattern(bindingPattern) { - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 198 ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 199 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - if (bindingPattern.parent.kind === 174) { + if (bindingPattern.parent.kind === 175) { return textSpan(bindingPattern.parent); } return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 173 && node.kind !== 172); - var elements = node.kind === 175 ? + ts.Debug.assert(node.kind !== 174 && node.kind !== 173); + var elements = node.kind === 176 ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 198 ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 199 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - return textSpan(node.parent.kind === 192 ? node.parent : node); + return textSpan(node.parent.kind === 193 ? node.parent : node); } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 229: + case 231: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 226: + case 228: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 232: + case 234: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 231: + case 233: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 229: - case 226: + case 231: + case 228: return textSpan(node); - case 204: + case 206: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 256: + case 259: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 232: + case 234: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 172: + case 173: var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -53736,7 +56622,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 173: + case 174: var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -53748,33 +56634,33 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 209 || - node.parent.kind === 179 || - node.parent.kind === 180) { + if (node.parent.kind === 211 || + node.parent.kind === 180 || + node.parent.kind === 181) { return spanInPreviousNode(node); } - if (node.parent.kind === 183) { + if (node.parent.kind === 184) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 184: - case 225: case 185: - case 149: - case 148: - case 151: - case 152: + case 227: + case 186: case 150: - case 210: - case 209: + case 149: + case 152: + case 153: + case 151: + case 212: case 211: case 213: - case 179: + case 215: case 180: - case 183: + case 181: + case 184: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -53782,26 +56668,26 @@ var ts; } function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || - node.parent.kind === 257 || - node.parent.kind === 144) { + node.parent.kind === 260 || + node.parent.kind === 145) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 182) { + if (node.parent.kind === 183) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 209) { + if (node.parent.kind === 211) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 213) { + if (node.parent.kind === 215) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -53832,7 +56718,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 124 || - keyword2 === 133 || + keyword2 === 134 || keyword2 === 122 || keyword2 === 114) { return true; @@ -53845,7 +56731,7 @@ var ts; var entries = []; var dense = classifications.spans; var lastEnd = 0; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; var length_4 = dense[i + 1]; var type = dense[i + 2]; @@ -53948,10 +56834,10 @@ var ts; angleBracketStack--; } else if (token === 118 || - token === 134 || + token === 135 || token === 132 || token === 121 || - token === 135) { + token === 136) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { token = 70; } @@ -54106,7 +56992,7 @@ var ts; } } function isKeyword(token) { - return token >= 71 && token <= 140; + return token >= 71 && token <= 141; } function classFromKind(token) { if (isKeyword(token)) { @@ -54152,10 +57038,10 @@ var ts; ts.getSemanticClassifications = getSemanticClassifications; function checkForClassificationCancellation(cancellationToken, kind) { switch (kind) { - case 230: - case 226: + case 232: + case 228: + case 229: case 227: - case 225: cancellationToken.throwIfCancellationRequested(); } } @@ -54199,7 +57085,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 230 && + return declaration.kind === 232 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -54210,7 +57096,7 @@ var ts; checkForClassificationCancellation(cancellationToken, kind); if (kind === 70 && !ts.nodeIsMissing(node)) { var identifier = node; - if (classifiableNames[identifier.text]) { + if (classifiableNames.get(identifier.text)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { var type = classifySymbol(symbol, ts.getMeaningFromLocation(node)); @@ -54256,7 +57142,7 @@ var ts; 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) { + for (var i = 0; i < dense.length; i += 3) { result.push({ textSpan: ts.createTextSpan(dense[i], dense[i + 1]), classificationType: getClassificationTypeName(dense[i + 2]) @@ -54340,16 +57226,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 281: + case 285: processJSDocParameterTag(tag); break; - case 284: + case 288: processJSDocTemplateTag(tag); break; - case 283: + case 287: processElement(tag.typeExpression); break; - case 282: + case 286: processElement(tag.typeExpression); break; } @@ -54430,22 +57316,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 248: + case 250: if (token.parent.tagName === token) { return 19; } break; - case 249: + case 251: if (token.parent.tagName === token) { return 20; } break; - case 247: + case 249: if (token.parent.tagName === token) { return 21; } break; - case 250: + case 252: if (token.parent.name === token) { return 22; } @@ -54465,17 +57351,17 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { if (tokenKind === 57) { - if (token.parent.kind === 223 || - token.parent.kind === 147 || - token.parent.kind === 144 || - token.parent.kind === 250) { + if (token.parent.kind === 225 || + token.parent.kind === 148 || + token.parent.kind === 145 || + token.parent.kind === 252) { return 5; } } - if (token.parent.kind === 192 || - token.parent.kind === 190 || + if (token.parent.kind === 193 || token.parent.kind === 191 || - token.parent.kind === 193) { + token.parent.kind === 192 || + token.parent.kind === 194) { return 5; } } @@ -54485,7 +57371,7 @@ var ts; return 4; } else if (tokenKind === 9) { - return token.parent.kind === 250 ? 24 : 6; + return token.parent.kind === 252 ? 24 : 6; } else if (tokenKind === 11) { return 6; @@ -54499,32 +57385,32 @@ var ts; else if (tokenKind === 70) { if (token) { switch (token.parent.kind) { - case 226: + case 228: if (token.parent.name === token) { return 11; } return; - case 143: + case 144: if (token.parent.name === token) { return 15; } return; - case 227: + case 229: if (token.parent.name === token) { return 13; } return; - case 229: + case 231: if (token.parent.name === token) { return 12; } return; - case 230: + case 232: if (token.parent.name === token) { return 14; } return; - case 144: + case 145: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 : 17; } @@ -54540,9 +57426,8 @@ var ts; } if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { checkForClassificationCancellation(cancellationToken, element.kind); - var children = element.getChildren(sourceFile); - for (var i = 0, n = children.length; i < n; i++) { - var child = children[i]; + for (var _i = 0, _a = element.getChildren(sourceFile); _i < _a.length; _i++) { + var child = _a[_i]; if (!tryClassifyNode(child)) { processElement(child); } @@ -54558,10 +57443,10 @@ var ts; (function (Completions) { function getCompletionsAtPosition(host, typeChecker, log, compilerOptions, sourceFile, position) { if (ts.isInReferenceComment(sourceFile, position)) { - return getTripleSlashReferenceCompletion(sourceFile, position); + return getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); } if (ts.isInString(sourceFile, position)) { - return getStringLiteralCompletionEntries(sourceFile, position); + return getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log); } var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (!completionData) { @@ -54573,13 +57458,13 @@ var ts; } var entries = []; if (ts.isSourceFileJavaScript(sourceFile)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, true); - ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, true, typeChecker, compilerOptions.target, log); + ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target)); } else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 && - location.parent && location.parent.kind === 249) { + location.parent && location.parent.kind === 251) { var tagName = location.parent.parent.openingElement.tagName; entries.push({ name: tagName.text, @@ -54592,528 +57477,535 @@ var ts; return undefined; } } - getCompletionEntriesFromSymbols(symbols, entries, location, true); + getCompletionEntriesFromSymbols(symbols, entries, location, true, typeChecker, compilerOptions.target, log); } if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { - var entries = []; - var nameTable = ts.getNameTable(sourceFile); - for (var name_45 in nameTable) { - if (nameTable[name_45] === position) { - continue; + } + Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames, target) { + var entries = []; + var nameTable = ts.getNameTable(sourceFile); + nameTable.forEach(function (pos, name) { + if (pos === position) { + return; + } + if (!uniqueNames.get(name)) { + uniqueNames.set(name, name); + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name), target, true); + if (displayName) { + var entry = { + name: displayName, + kind: ts.ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } - if (!uniqueNames[name_45]) { - uniqueNames[name_45] = name_45; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_45), compilerOptions.target, true); - if (displayName) { - var entry = { - name: displayName, - kind: ts.ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; + } + }); + return entries; + } + function createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target) { + var displayName = getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, target, performCharacterChecks, location); + if (!displayName) { + return undefined; + } + return { + name: displayName, + kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), + kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), + sortText: "0", + }; + } + function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks, typeChecker, target, log) { + var start = ts.timestamp(); + var uniqueNames = ts.createMap(); + if (symbols) { + for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { + var symbol = symbols_4[_i]; + var entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target); + if (entry) { + var id = ts.escapeIdentifier(entry.name); + if (!uniqueNames.get(id)) { entries.push(entry); + uniqueNames.set(id, id); } } } - return entries; } - function createCompletionEntry(symbol, location, performCharacterChecks) { - var displayName = getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, compilerOptions.target, performCharacterChecks, location); - if (!displayName) { - return undefined; + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); + return uniqueNames; + } + function getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log) { + var node = ts.findPrecedingToken(position, sourceFile); + if (!node || node.kind !== 9) { + return undefined; + } + if (node.parent.kind === 260 && + node.parent.parent.kind === 177 && + node.parent.name === node) { + return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent, typeChecker, compilerOptions.target, log); + } + else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { + return getStringLiteralCompletionEntriesFromElementAccess(node.parent, typeChecker, compilerOptions.target, log); + } + else if (node.parent.kind === 237 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + return getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker); + } + else if (isEqualityExpression(node.parent)) { + return getStringLiteralCompletionEntriesFromType(typeChecker.getTypeAtLocation(node.parent.left === node ? node.parent.right : node.parent.left), typeChecker); + } + else if (ts.isCaseOrDefaultClause(node.parent)) { + return getStringLiteralCompletionEntriesFromType(typeChecker.getTypeAtLocation(node.parent.parent.parent.expression), typeChecker); + } + else { + var argumentInfo = ts.SignatureHelp.getImmediatelyContainingArgumentInfo(node, position, sourceFile); + if (argumentInfo) { + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker); } - return { - name: displayName, - kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0", - }; + return getStringLiteralCompletionEntriesFromType(typeChecker.getContextualType(node), typeChecker); } - function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks) { - var start = ts.timestamp(); - var uniqueNames = ts.createMap(); - if (symbols) { - for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { - var symbol = symbols_4[_i]; - var entry = createCompletionEntry(symbol, location, performCharacterChecks); - if (entry) { - var id = ts.escapeIdentifier(entry.name); - if (!uniqueNames[id]) { - entries.push(entry); - uniqueNames[id] = id; + } + function getStringLiteralCompletionEntriesFromPropertyAssignment(element, typeChecker, target, log) { + var type = typeChecker.getContextualType(element.parent); + var entries = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + } + } + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker) { + var candidates = []; + var entries = []; + typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); + for (var _i = 0, candidates_3 = candidates; _i < candidates_3.length; _i++) { + var candidate = candidates_3[_i]; + addStringLiteralCompletionsFromType(typeChecker.getParameterType(candidate, argumentInfo.argumentIndex), entries, typeChecker); + } + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; + } + return undefined; + } + function getStringLiteralCompletionEntriesFromElementAccess(node, typeChecker, target, log) { + var type = typeChecker.getTypeAtLocation(node.expression); + var entries = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + } + return undefined; + } + function getStringLiteralCompletionEntriesFromType(type, typeChecker) { + if (type) { + var entries = []; + addStringLiteralCompletionsFromType(type, entries, typeChecker); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; + } + } + return undefined; + } + function addStringLiteralCompletionsFromType(type, result, typeChecker) { + if (type && type.flags & 16384) { + type = typeChecker.getApparentType(type); + } + if (!type) { + return; + } + if (type.flags & 65536) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + addStringLiteralCompletionsFromType(t, result, typeChecker); + } + } + else if (type.flags & 32) { + result.push({ + name: type.text, + kindModifiers: ts.ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.variableElement, + sortText: "0" + }); + } + } + function getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker) { + var literalValue = ts.normalizeSlashes(node.text); + var scriptPath = node.getSourceFile().path; + var scriptDirectory = ts.getDirectoryPath(scriptPath); + var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); + var entries; + if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { + var extensions = ts.getSupportedExtensions(compilerOptions); + if (compilerOptions.rootDirs) { + entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, false, span, compilerOptions, host, scriptPath); + } + else { + entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensions, false, span, host, scriptPath); + } + } + else { + entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span, compilerOptions, host, typeChecker); + } + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: entries + }; + } + function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { + rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); + var relativeDirectory; + for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { + var rootDirectory = rootDirs_1[_i]; + if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { + relativeDirectory = scriptPath.substr(rootDirectory.length); + break; + } + } + return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); + } + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, compilerOptions, host, exclude) { + var basePath = compilerOptions.project || host.getCurrentDirectory(); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); + var result = []; + for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { + var baseDirectory = baseDirectories_1[_i]; + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, host, exclude, result); + } + return result; + } + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, host, exclude, result) { + if (result === void 0) { result = []; } + if (fragment === undefined) { + fragment = ""; + } + fragment = ts.normalizeSlashes(fragment); + fragment = ts.getDirectoryPath(fragment); + if (fragment === "") { + fragment = "." + ts.directorySeparator; + } + fragment = ts.ensureTrailingDirectorySeparator(fragment); + var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); + var baseDirectory = ts.getDirectoryPath(absolutePath); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + if (tryDirectoryExists(host, baseDirectory)) { + var files = tryReadDirectory(host, baseDirectory, extensions, undefined, ["./*"]); + if (files) { + var foundFiles = ts.createMap(); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var filePath = files_3[_i]; + filePath = ts.normalizePath(filePath); + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0) { + continue; + } + var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); + if (!foundFiles.get(foundFileName)) { + foundFiles.set(foundFileName, true); + } + } + ts.forEachKey(foundFiles, function (foundFile) { + result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); + }); + } + var directories = tryGetDirectories(host, baseDirectory); + if (directories) { + for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { + var directory = directories_2[_a]; + var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); + result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); + } + } + } + return result; + } + function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span, compilerOptions, host, typeChecker) { + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; + var result; + if (baseUrl) { + var fileExtensions = ts.getSupportedExtensions(compilerOptions); + var projectDir = compilerOptions.project || host.getCurrentDirectory(); + var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); + result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, false, span, host); + if (paths) { + for (var path in paths) { + if (paths.hasOwnProperty(path)) { + if (path === "*") { + if (paths[path]) { + for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { + var pattern = _a[_i]; + for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host); _b < _c.length; _b++) { + var match = _c[_b]; + result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + else if (ts.startsWith(path, fragment)) { + var entry = paths[path] && paths[path].length === 1 && paths[path][0]; + if (entry) { + result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); + } } } } } - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); - return uniqueNames; } - function getStringLiteralCompletionEntries(sourceFile, position) { - var node = ts.findPrecedingToken(position, sourceFile); - if (!node || node.kind !== 9) { - return undefined; + else { + result = []; + } + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); + for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host); _d < _e.length; _d++) { + var moduleName = _e[_d]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + return result; + } + function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { + if (host.readDirectory) { + var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; + if (parsed) { + var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); + var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); + var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); + var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; + var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; + var normalizedSuffix = ts.normalizePath(parsed.suffix); + var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); + var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + var includeGlob = normalizedSuffix ? "**/*" : "./*"; + var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); + if (matches) { + var result = []; + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; + var normalizedMatch = ts.normalizePath(match); + if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { + continue; + } + var start = completePrefix.length; + var length_5 = normalizedMatch.length - start - normalizedSuffix.length; + result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); + } + return result; + } } - if (node.parent.kind === 257 && - node.parent.parent.kind === 176 && - node.parent.name === node) { - return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); + } + return undefined; + } + function enumeratePotentialNonRelativeModules(fragment, scriptPath, options, typeChecker, host) { + var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; + var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; + var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); + var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); + if (isNestedModule) { + var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); + nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { + if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { + return moduleName.substr(moduleNameWithSeperator_1.length); + } + return moduleName; + }); + } + if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { + for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { + var visibleModule = _a[_i]; + if (!isNestedModule) { + nonRelativeModules.push(visibleModule.moduleName); + } + else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { + var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, undefined, ["./*"]); + if (nestedFiles) { + for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { + var f = nestedFiles_1[_b]; + f = ts.normalizePath(f); + var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); + nonRelativeModules.push(nestedModule); + } + } + } } - else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { - return getStringLiteralCompletionEntriesFromElementAccess(node.parent); - } - else if (node.parent.kind === 235 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { - return getStringLiteralCompletionEntriesFromModuleNames(node); + } + return ts.deduplicate(nonRelativeModules); + } + function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { + var token = ts.getTokenAtPosition(sourceFile, position); + if (!token) { + return undefined; + } + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + if (!commentRanges || !commentRanges.length) { + return undefined; + } + var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); + if (!range) { + return undefined; + } + var completionInfo = { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: [] + }; + var text = sourceFile.text.substr(range.pos, position - range.pos); + var match = tripleSlashDirectiveFragmentRegex.exec(text); + if (match) { + var prefix = match[1]; + var kind = match[2]; + var toComplete = match[3]; + var scriptPath = ts.getDirectoryPath(sourceFile.path); + if (kind === "path") { + var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), true, span_10, host, sourceFile.path); } else { - var argumentInfo = ts.SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); - if (argumentInfo) { - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); - } - return getStringLiteralCompletionEntriesFromContextualType(node); + var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); } } - function getStringLiteralCompletionEntriesFromPropertyAssignment(element) { - var type = typeChecker.getContextualType(element.parent); - var entries = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + return completionInfo; + } + function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { + if (result === void 0) { result = []; } + if (options.types) { + for (var _i = 0, _a = options.types; _i < _a.length; _i++) { + var moduleName = _a[_i]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + } + else if (host.getDirectories) { + var typeRoots = void 0; + try { + typeRoots = ts.getEffectiveTypeRoots(options, host); + } + catch (e) { } + if (typeRoots) { + for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { + var root = typeRoots_2[_b]; + getCompletionEntriesFromDirectories(host, root, span, result); } } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo) { - var candidates = []; - var entries = []; - typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); - for (var _i = 0, candidates_3 = candidates; _i < candidates_3.length; _i++) { - var candidate = candidates_3[_i]; - if (candidate.parameters.length > argumentInfo.argumentIndex) { - var parameter = candidate.parameters[argumentInfo.argumentIndex]; - addStringLiteralCompletionsFromType(typeChecker.getTypeAtLocation(parameter.valueDeclaration), entries); + if (host.getDirectories) { + for (var _c = 0, _d = findPackageJsons(scriptPath, host); _c < _d.length; _c++) { + var packageJson = _d[_c]; + var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(host, typesDir, span, result); + } + } + return result; + } + function getCompletionEntriesFromDirectories(host, directory, span, result) { + if (host.getDirectories && tryDirectoryExists(host, directory)) { + var directories = tryGetDirectories(host, directory); + if (directories) { + for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { + var typeDirectory = directories_3[_i]; + typeDirectory = ts.normalizePath(typeDirectory); + result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); } } - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; - } - return undefined; } - function getStringLiteralCompletionEntriesFromElementAccess(node) { - var type = typeChecker.getTypeAtLocation(node.expression); - var entries = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + function findPackageJsons(currentDir, host) { + var paths = []; + var currentConfigPath; + while (true) { + currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + currentDir = ts.getDirectoryPath(currentConfigPath); + var parent = ts.getDirectoryPath(currentDir); + if (currentDir === parent) { + break; } - } - return undefined; - } - function getStringLiteralCompletionEntriesFromContextualType(node) { - var type = typeChecker.getContextualType(node); - if (type) { - var entries_2 = []; - addStringLiteralCompletionsFromType(type, entries_2); - if (entries_2.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries_2 }; - } - } - return undefined; - } - function addStringLiteralCompletionsFromType(type, result) { - if (!type) { - return; - } - if (type.flags & 65536) { - ts.forEach(type.types, function (t) { return addStringLiteralCompletionsFromType(t, result); }); + currentDir = parent; } else { - if (type.flags & 32) { + break; + } + } + return paths; + } + function enumerateNodeModulesVisibleToScript(host, scriptPath) { + var result = []; + if (host.readFile && host.fileExists) { + for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + var packageJson = _a[_i]; + var contents = tryReadingPackageJson(packageJson); + if (!contents) { + return; + } + var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); + var foundModuleNames = []; + for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { + var key = nodeModulesDependencyKeys_1[_b]; + addPotentialPackageNames(contents[key], foundModuleNames); + } + for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { + var moduleName = foundModuleNames_1[_c]; + var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); result.push({ - name: type.text, - kindModifiers: ts.ScriptElementKindModifier.none, - kind: ts.ScriptElementKind.variableElement, - sortText: "0" + moduleName: moduleName, + moduleDir: moduleDir }); } } } - function getStringLiteralCompletionEntriesFromModuleNames(node) { - var literalValue = ts.normalizeSlashes(node.text); - var scriptPath = node.getSourceFile().path; - var scriptDirectory = ts.getDirectoryPath(scriptPath); - var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); - var entries; - if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { - if (compilerOptions.rootDirs) { - entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), false, span, scriptPath); - } - else { - entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), false, span, scriptPath); - } + return result; + function tryReadingPackageJson(filePath) { + try { + var fileText = tryReadFile(host, filePath); + return fileText ? JSON.parse(fileText) : undefined; } - else { - entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); - } - return { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: entries - }; - } - function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { - rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); - var relativeDirectory; - for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { - var rootDirectory = rootDirs_1[_i]; - if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { - relativeDirectory = scriptPath.substr(rootDirectory.length); - break; - } - } - return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); - } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, exclude) { - var basePath = compilerOptions.project || host.getCurrentDirectory(); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); - var result = []; - for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { - var baseDirectory = baseDirectories_1[_i]; - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, exclude, result); - } - return result; - } - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, exclude, result) { - if (result === void 0) { result = []; } - if (fragment === undefined) { - fragment = ""; - } - fragment = ts.normalizeSlashes(fragment); - fragment = ts.getDirectoryPath(fragment); - if (fragment === "") { - fragment = "." + ts.directorySeparator; - } - fragment = ts.ensureTrailingDirectorySeparator(fragment); - var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); - var baseDirectory = ts.getDirectoryPath(absolutePath); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (tryDirectoryExists(host, baseDirectory)) { - var files = tryReadDirectory(host, baseDirectory, extensions, undefined, ["./*"]); - if (files) { - var foundFiles = ts.createMap(); - for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { - var filePath = files_3[_i]; - filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0) { - continue; - } - var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); - if (!foundFiles[foundFileName]) { - foundFiles[foundFileName] = true; - } - } - for (var foundFile in foundFiles) { - result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); - } - } - var directories = tryGetDirectories(host, baseDirectory); - if (directories) { - for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { - var directory = directories_2[_a]; - var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); - } - } - } - return result; - } - function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span) { - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var result; - if (baseUrl) { - var fileExtensions = ts.getSupportedExtensions(compilerOptions); - var projectDir = compilerOptions.project || host.getCurrentDirectory(); - var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); - result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, false, span); - if (paths) { - for (var path in paths) { - if (paths.hasOwnProperty(path)) { - if (path === "*") { - if (paths[path]) { - for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { - var pattern = _a[_i]; - for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions); _b < _c.length; _b++) { - var match = _c[_b]; - result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - else if (ts.startsWith(path, fragment)) { - var entry = paths[path] && paths[path].length === 1 && paths[path][0]; - if (entry) { - result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - } - } - else { - result = []; - } - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); - for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions); _d < _e.length; _d++) { - var moduleName = _e[_d]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - return result; - } - function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions) { - if (host.readDirectory) { - var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; - if (parsed) { - var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); - var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); - var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); - var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; - var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; - var normalizedSuffix = ts.normalizePath(parsed.suffix); - var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); - var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); - if (matches) { - var result = []; - for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { - var match = matches_1[_i]; - var normalizedMatch = ts.normalizePath(match); - if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { - continue; - } - var start = completePrefix.length; - var length_5 = normalizedMatch.length - start - normalizedSuffix.length; - result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); - } - return result; - } - } - } - return undefined; - } - function enumeratePotentialNonRelativeModules(fragment, scriptPath, options) { - var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; - var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; - var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); - var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); - if (isNestedModule) { - var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); - nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { - if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { - return moduleName.substr(moduleNameWithSeperator_1.length); - } - return moduleName; - }); - } - if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { - for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { - var visibleModule = _a[_i]; - if (!isNestedModule) { - nonRelativeModules.push(visibleModule.moduleName); - } - else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { - var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, undefined, ["./*"]); - if (nestedFiles) { - for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { - var f = nestedFiles_1[_b]; - f = ts.normalizePath(f); - var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); - nonRelativeModules.push(nestedModule); - } - } - } - } - } - return ts.deduplicate(nonRelativeModules); - } - function getTripleSlashReferenceCompletion(sourceFile, position) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (!token) { + catch (e) { return undefined; } - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - if (!commentRanges || !commentRanges.length) { - return undefined; - } - var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); - if (!range) { - return undefined; - } - var completionInfo = { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: [] - }; - var text = sourceFile.text.substr(range.pos, position - range.pos); - var match = tripleSlashDirectiveFragmentRegex.exec(text); - if (match) { - var prefix = match[1]; - var kind = match[2]; - var toComplete = match[3]; - var scriptPath = ts.getDirectoryPath(sourceFile.path); - if (kind === "path") { - var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), true, span_10, sourceFile.path); - } - else { - var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); - } - } - return completionInfo; } - function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { - if (result === void 0) { result = []; } - if (options.types) { - for (var _i = 0, _a = options.types; _i < _a.length; _i++) { - var moduleName = _a[_i]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - } - else if (host.getDirectories) { - var typeRoots = void 0; - try { - typeRoots = ts.getEffectiveTypeRoots(options, host); - } - catch (e) { } - if (typeRoots) { - for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { - var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, root, span, result); + function addPotentialPackageNames(dependencies, result) { + if (dependencies) { + for (var dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { + result.push(dep); } } } - if (host.getDirectories) { - for (var _c = 0, _d = findPackageJsons(scriptPath); _c < _d.length; _c++) { - var packageJson = _d[_c]; - var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, typesDir, span, result); - } - } - return result; - } - function getCompletionEntriesFromDirectories(host, directory, span, result) { - if (host.getDirectories && tryDirectoryExists(host, directory)) { - var directories = tryGetDirectories(host, directory); - if (directories) { - for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { - var typeDirectory = directories_3[_i]; - typeDirectory = ts.normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - function findPackageJsons(currentDir) { - var paths = []; - var currentConfigPath; - while (true) { - currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); - currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_13 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_13) { - break; - } - currentDir = parent_13; - } - else { - break; - } - } - return paths; - } - function enumerateNodeModulesVisibleToScript(host, scriptPath) { - var result = []; - if (host.readFile && host.fileExists) { - for (var _i = 0, _a = findPackageJsons(scriptPath); _i < _a.length; _i++) { - var packageJson = _a[_i]; - var contents = tryReadingPackageJson(packageJson); - if (!contents) { - return; - } - var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); - var foundModuleNames = []; - for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { - var key = nodeModulesDependencyKeys_1[_b]; - addPotentialPackageNames(contents[key], foundModuleNames); - } - for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { - var moduleName = foundModuleNames_1[_c]; - var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName: moduleName, - moduleDir: moduleDir - }); - } - } - } - return result; - function tryReadingPackageJson(filePath) { - try { - var fileText = tryReadFile(host, filePath); - return fileText ? JSON.parse(fileText) : undefined; - } - catch (e) { - return undefined; - } - } - function addPotentialPackageNames(dependencies, result) { - if (dependencies) { - for (var dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { - result.push(dep); - } - } - } - } - } - function createCompletionEntryForModule(name, kind, replacementSpan) { - return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; - } - function getDirectoryFragmentTextSpan(text, textStart) { - var index = text.lastIndexOf(ts.directorySeparator); - var offset = index !== -1 ? index + 1 : 0; - return { start: textStart + offset, length: text.length - offset }; - } - function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 ? 2 : 1; - var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 || slashCharCode === 92; - } - return false; - } - function normalizeAndPreserveTrailingSlash(path) { - return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); } } - Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function createCompletionEntryForModule(name, kind, replacementSpan) { + return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; + } + function getDirectoryFragmentTextSpan(text, textStart) { + var index = text.lastIndexOf(ts.directorySeparator); + var offset = index !== -1 ? index + 1 : 0; + return { start: textStart + offset, length: text.length - offset }; + } + function isPathRelativeToScript(path) { + if (path && path.length >= 2 && path.charCodeAt(0) === 46) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 ? 2 : 1; + var slashCharCode = path.charCodeAt(slashIndex); + return slashCharCode === 47 || slashCharCode === 92; + } + return false; + } + function normalizeAndPreserveTrailingSlash(path) { + return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); + } function getCompletionEntryDetails(typeChecker, log, compilerOptions, sourceFile, position, entryName) { var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_3 = completionData.location; - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_3) === entryName ? s : undefined; }); + var symbols = completionData.symbols, location_1 = completionData.location; + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_1) === entryName ? s : undefined; }); if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_3, location_3, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { name: entryName, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), @@ -55139,8 +58031,8 @@ var ts; function getCompletionEntrySymbol(typeChecker, log, compilerOptions, sourceFile, position, entryName) { var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_4 = completionData.location; - return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_4) === entryName ? s : undefined; }); + var symbols = completionData.symbols, location_2 = completionData.location; + return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_2) === entryName ? s : undefined; }); } return undefined; } @@ -55165,9 +58057,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 283: - case 281: - case 282: + case 287: + case 285: + case 286: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -55202,13 +58094,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_14 = contextToken.parent, kind = contextToken.kind; + var parent = contextToken.parent, kind = contextToken.kind; if (kind === 22) { - if (parent_14.kind === 177) { + if (parent.kind === 178) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_14.kind === 141) { + else if (parent.kind === 142) { node = contextToken.parent.left; isRightOfDot = true; } @@ -55217,13 +58109,25 @@ var ts; } } else if (sourceFile.languageVariant === 1) { - if (kind === 26) { - isRightOfOpenTag = true; - location = contextToken; - } - else if (kind === 40 && contextToken.parent.kind === 249) { - isStartingCloseTag = true; - location = contextToken; + switch (contextToken.parent.kind) { + case 251: + if (kind === 40) { + isStartingCloseTag = true; + location = contextToken; + } + break; + case 193: + if (!(contextToken.parent.left.flags & 32768)) { + break; + } + case 249: + case 248: + case 250: + if (kind === 26) { + isRightOfOpenTag = true; + location = contextToken; + } + break; } } } @@ -55266,7 +58170,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 70 || node.kind === 141 || node.kind === 177) { + if (node.kind === 70 || node.kind === 142 || node.kind === 178) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -55312,10 +58216,10 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 247) || (jsxContainer.kind === 248)) { - attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + if ((jsxContainer.kind === 249) || (jsxContainer.kind === 250)) { + attrsType = typeChecker.getAllAttributesTypeFromJsxOpeningLikeElement(jsxContainer); if (attrsType) { - symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); + symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes.properties); isMemberCompletion = true; isNewIdentifierLocation = false; return true; @@ -55333,9 +58237,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 261 || - scopeNode.kind === 194 || - scopeNode.kind === 252 || + scopeNode.kind === 264 || + scopeNode.kind === 195 || + scopeNode.kind === 255 || ts.isStatement(scopeNode); } var symbolMeanings = 793064 | 107455 | 1920 | 8388608; @@ -55363,11 +58267,11 @@ var ts; return true; } if (contextToken.kind === 28 && contextToken.parent) { - if (contextToken.parent.kind === 248) { + if (contextToken.parent.kind === 250) { return true; } - if (contextToken.parent.kind === 249 || contextToken.parent.kind === 247) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 246; + if (contextToken.parent.kind === 251 || contextToken.parent.kind === 249) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 248; } } return false; @@ -55377,40 +58281,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 25: - return containingNodeKind === 179 - || containingNodeKind === 150 - || containingNodeKind === 180 - || containingNodeKind === 175 - || containingNodeKind === 192 - || containingNodeKind === 158; + return containingNodeKind === 180 + || containingNodeKind === 151 + || containingNodeKind === 181 + || containingNodeKind === 176 + || containingNodeKind === 193 + || containingNodeKind === 159; case 18: - return containingNodeKind === 179 - || containingNodeKind === 150 - || containingNodeKind === 180 - || containingNodeKind === 183 - || containingNodeKind === 166; + return containingNodeKind === 180 + || containingNodeKind === 151 + || containingNodeKind === 181 + || containingNodeKind === 184 + || containingNodeKind === 167; case 20: - return containingNodeKind === 175 - || containingNodeKind === 155 - || containingNodeKind === 142; + return containingNodeKind === 176 + || containingNodeKind === 156 + || containingNodeKind === 143; case 127: case 128: return true; case 22: - return containingNodeKind === 230; + return containingNodeKind === 232; case 16: - return containingNodeKind === 226; + return containingNodeKind === 228; case 57: - return containingNodeKind === 223 - || containingNodeKind === 192; + return containingNodeKind === 225 + || containingNodeKind === 193; case 13: - return containingNodeKind === 194; + return containingNodeKind === 195; case 14: - return containingNodeKind === 202; + return containingNodeKind === 204; case 113: case 111: case 112: - return containingNodeKind === 147; + return containingNodeKind === 148; } switch (previousToken.getText()) { case "public": @@ -55441,22 +58345,22 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 176) { + if (objectLikeContainer.kind === 177) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 172) { + else if (objectLikeContainer.kind === 173) { isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); if (ts.isVariableLike(rootDeclaration)) { var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 144) { + if (!canGetType && rootDeclaration.kind === 145) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 149 || rootDeclaration.parent.kind === 152) { + else if (rootDeclaration.parent.kind === 150 || rootDeclaration.parent.kind === 153) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -55482,9 +58386,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 238 ? - 235 : - 241; + var declarationKind = namedImportsOrExports.kind === 240 ? + 237 : + 243; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -55492,12 +58396,13 @@ var ts; } isMemberCompletion = true; isNewIdentifierLocation = false; - var exports; - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); + if (!moduleSpecifierSymbol) { + symbols = ts.emptyArray; + return true; } - symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : ts.emptyArray; + var exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); + symbols = filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements); return true; } function tryGetObjectLikeCompletionContainer(contextToken) { @@ -55505,9 +58410,9 @@ var ts; switch (contextToken.kind) { case 16: case 25: - var parent_15 = contextToken.parent; - if (parent_15 && (parent_15.kind === 176 || parent_15.kind === 172)) { - return parent_15; + var parent = contextToken.parent; + if (parent && (parent.kind === 177 || parent.kind === 173)) { + return parent; } break; } @@ -55520,8 +58425,8 @@ var ts; case 16: case 25: switch (contextToken.parent.kind) { - case 238: - case 242: + case 240: + case 244: return contextToken.parent; } } @@ -55530,34 +58435,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_16 = contextToken.parent; + var parent = contextToken.parent; switch (contextToken.kind) { case 27: case 40: case 70: - case 250: - case 251: - if (parent_16 && (parent_16.kind === 247 || parent_16.kind === 248)) { - return parent_16; + case 253: + case 252: + case 254: + if (parent && (parent.kind === 249 || parent.kind === 250)) { + return parent; } - else if (parent_16.kind === 250) { - return parent_16.parent; + else if (parent.kind === 252) { + return parent.parent.parent; } break; case 9: - if (parent_16 && ((parent_16.kind === 250) || (parent_16.kind === 251))) { - return parent_16.parent; + if (parent && ((parent.kind === 252) || (parent.kind === 254))) { + return parent.parent.parent; } break; case 17: - if (parent_16 && - parent_16.kind === 252 && - parent_16.parent && - (parent_16.parent.kind === 250)) { - return parent_16.parent.parent; + if (parent && + parent.kind === 255 && + parent.parent && parent.parent.kind === 252) { + return parent.parent.parent.parent; } - if (parent_16 && parent_16.kind === 251) { - return parent_16.parent; + if (parent && parent.kind === 254) { + return parent.parent.parent; } break; } @@ -55566,16 +58471,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 184: case 185: - case 225: + case 186: + case 227: + case 150: case 149: - case 148: - case 151: case 152: case 153: case 154: case 155: + case 156: return true; } return false; @@ -55584,66 +58489,66 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25: - return containingNodeKind === 223 || - containingNodeKind === 224 || - containingNodeKind === 205 || - containingNodeKind === 229 || - isFunction(containingNodeKind) || + return containingNodeKind === 225 || containingNodeKind === 226 || - containingNodeKind === 197 || - containingNodeKind === 227 || - containingNodeKind === 173 || - containingNodeKind === 228; + containingNodeKind === 207 || + containingNodeKind === 231 || + isFunction(containingNodeKind) || + containingNodeKind === 228 || + containingNodeKind === 198 || + containingNodeKind === 229 || + containingNodeKind === 174 || + containingNodeKind === 230; case 22: - return containingNodeKind === 173; - case 55: return containingNodeKind === 174; + case 55: + return containingNodeKind === 175; case 20: - return containingNodeKind === 173; + return containingNodeKind === 174; case 18: - return containingNodeKind === 256 || + return containingNodeKind === 259 || isFunction(containingNodeKind); case 16: - return containingNodeKind === 229 || - containingNodeKind === 227 || - containingNodeKind === 161; + return containingNodeKind === 231 || + containingNodeKind === 229 || + containingNodeKind === 162; case 24: - return containingNodeKind === 146 && + return containingNodeKind === 147 && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 227 || - contextToken.parent.parent.kind === 161); + (contextToken.parent.parent.kind === 229 || + contextToken.parent.parent.kind === 162); case 26: - return containingNodeKind === 226 || - containingNodeKind === 197 || - containingNodeKind === 227 || - containingNodeKind === 228 || + return containingNodeKind === 228 || + containingNodeKind === 198 || + containingNodeKind === 229 || + containingNodeKind === 230 || isFunction(containingNodeKind); case 114: - return containingNodeKind === 147; + return containingNodeKind === 148; case 23: - return containingNodeKind === 144 || + return containingNodeKind === 145 || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 173); + contextToken.parent.parent.kind === 174); case 113: case 111: case 112: - return containingNodeKind === 144; + return containingNodeKind === 145; case 117: - return containingNodeKind === 239 || - containingNodeKind === 243 || - containingNodeKind === 237; + return containingNodeKind === 241 || + containingNodeKind === 245 || + containingNodeKind === 239; case 74: case 82: case 108: case 88: case 103: case 124: - case 133: + case 134: case 90: case 109: case 75: case 115: - case 136: + case 137: return true; } switch (contextToken.getText()) { @@ -55680,13 +58585,13 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_46 = element.propertyName || element.name; - existingImportsOrExports[name_46.text] = true; + var name = element.propertyName || element.name; + existingImportsOrExports.set(name.text, true); } - if (!ts.someProperties(existingImportsOrExports)) { + if (existingImportsOrExports.size === 0) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); } - return ts.filter(exportsOfModule, function (e) { return e.name !== "default" && !existingImportsOrExports[e.name]; }); + return ts.filter(exportsOfModule, function (e) { return e.name !== "default" && !existingImportsOrExports.get(e.name); }); } function filterObjectMembersList(contextualMemberSymbols, existingMembers) { if (!existingMembers || existingMembers.length === 0) { @@ -55695,19 +58600,19 @@ var ts; var existingMemberNames = ts.createMap(); for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; - if (m.kind !== 257 && - m.kind !== 258 && - m.kind !== 174 && - m.kind !== 149 && - m.kind !== 151 && - m.kind !== 152) { + if (m.kind !== 260 && + m.kind !== 261 && + m.kind !== 175 && + m.kind !== 150 && + m.kind !== 152 && + m.kind !== 153) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 174 && m.propertyName) { + if (m.kind === 175 && m.propertyName) { if (m.propertyName.kind === 70) { existingName = m.propertyName.text; } @@ -55715,9 +58620,9 @@ var ts; else { existingName = m.name.text; } - existingMemberNames[existingName] = true; + existingMemberNames.set(existingName, true); } - return ts.filter(contextualMemberSymbols, function (m) { return !existingMemberNames[m.name]; }); + return ts.filter(contextualMemberSymbols, function (m) { return !existingMemberNames.get(m.name); }); } function filterJsxAttributes(symbols, attributes) { var seenNames = ts.createMap(); @@ -55726,11 +58631,11 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 250) { - seenNames[attr.name.text] = true; + if (attr.kind === 252) { + seenNames.set(attr.name.text, true); } } - return ts.filter(symbols, function (a) { return !seenNames[a.name]; }); + return ts.filter(symbols, function (a) { return !seenNames.get(a.name); }); } } function getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, target, performCharacterChecks, location) { @@ -55759,7 +58664,7 @@ var ts; return name; } var keywordCompletions = []; - for (var i = 71; i <= 140; i++) { + for (var i = 71; i <= 141; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -55799,6 +58704,15 @@ var ts; catch (e) { } return undefined; } + function isEqualityExpression(node) { + return ts.isBinaryExpression(node) && isEqualityOperatorKind(node.operatorToken.kind); + } + function isEqualityOperatorKind(kind) { + return kind == 31 || + kind === 32 || + kind === 33 || + kind === 34; + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); var ts; @@ -55807,495 +58721,480 @@ var ts; (function (DocumentHighlights) { function getDocumentHighlights(typeChecker, cancellationToken, sourceFile, position, sourceFilesToSearch) { var node = ts.getTouchingWord(sourceFile, position); + return node && (getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) || getSyntacticDocumentHighlights(node, sourceFile)); + } + DocumentHighlights.getDocumentHighlights = getDocumentHighlights; + function getHighlightSpanForNode(node, sourceFile) { + var start = node.getStart(sourceFile); + var end = node.getEnd(); + return { + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(start, end), + kind: ts.HighlightSpanKind.none + }; + } + function getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) { + var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch); + return referencedSymbols && convertReferencedSymbols(referencedSymbols); + } + function convertReferencedSymbols(referencedSymbols) { + var fileNameToDocumentHighlights = ts.createMap(); + var result = []; + 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 = referenceEntry.fileName; + var documentHighlights = fileNameToDocumentHighlights.get(fileName); + if (!documentHighlights) { + documentHighlights = { fileName: fileName, highlightSpans: [] }; + fileNameToDocumentHighlights.set(fileName, documentHighlights); + result.push(documentHighlights); + } + documentHighlights.highlightSpans.push({ + textSpan: referenceEntry.textSpan, + kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference + }); + } + } + return result; + } + function getSyntacticDocumentHighlights(node, sourceFile) { + var highlightSpans = getHighlightSpans(node, sourceFile); + if (!highlightSpans || highlightSpans.length === 0) { + return undefined; + } + return [{ fileName: sourceFile.fileName, highlightSpans: highlightSpans }]; + } + function hasKind(node, kind) { + return node !== undefined && node.kind === kind; + } + function parent(node) { + return node && node.parent; + } + function getHighlightSpans(node, sourceFile) { 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: ts.HighlightSpanKind.none - }; + switch (node.kind) { + case 89: + case 81: + if (hasKind(node.parent, 210)) { + return getIfElseOccurrences(node.parent, sourceFile); + } + break; + case 95: + if (hasKind(node.parent, 218)) { + return highlightSpans(getReturnOccurrences(node.parent)); + } + break; + case 99: + if (hasKind(node.parent, 222)) { + return highlightSpans(getThrowOccurrences(node.parent)); + } + break; + case 101: + case 73: + case 86: + var tryStatement = node.kind === 73 ? parent(parent(node)) : parent(node); + if (hasKind(tryStatement, 223)) { + return highlightSpans(getTryCatchFinallyOccurrences(tryStatement, sourceFile)); + } + break; + case 97: + if (hasKind(node.parent, 220)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent)); + } + break; + case 72: + case 78: + if (hasKind(parent(parent(parent(node))), 220)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent.parent.parent)); + } + break; + case 71: + case 76: + if (hasKind(node.parent, 217) || hasKind(node.parent, 216)) { + return highlightSpans(getBreakOrContinueStatementOccurrences(node.parent)); + } + break; + case 87: + if (hasKind(node.parent, 213) || + hasKind(node.parent, 214) || + hasKind(node.parent, 215)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case 105: + case 80: + if (hasKind(node.parent, 212) || hasKind(node.parent, 211)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case 122: + if (hasKind(node.parent, 151)) { + return highlightSpans(getConstructorOccurrences(node.parent)); + } + break; + case 124: + case 134: + if (hasKind(node.parent, 152) || hasKind(node.parent, 153)) { + return highlightSpans(getGetAndSetOccurrences(node.parent)); + } + break; + default: + if (ts.isModifierKind(node.kind) && node.parent && + (ts.isDeclaration(node.parent) || node.parent.kind === 207)) { + return highlightSpans(getModifierOccurrences(node.kind, node.parent)); + } } - function getSemanticDocumentHighlights(node) { - if (node.kind === 70 || - node.kind === 98 || - node.kind === 167 || - node.kind === 96 || - node.kind === 9 || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, false, false, false); - return convertReferencedSymbols(referencedSymbols); - } - return undefined; - function convertReferencedSymbols(referencedSymbols) { - if (!referencedSymbols) { - return undefined; - } - var fileNameToDocumentHighlights = ts.createMap(); - var result = []; - 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 = referenceEntry.fileName; - var documentHighlights = fileNameToDocumentHighlights[fileName]; - if (!documentHighlights) { - documentHighlights = { fileName: fileName, highlightSpans: [] }; - fileNameToDocumentHighlights[fileName] = documentHighlights; - result.push(documentHighlights); - } - documentHighlights.highlightSpans.push({ - textSpan: referenceEntry.textSpan, - kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference - }); - } - } - return result; - } + function highlightSpans(nodes) { + return nodes && nodes.map(function (node) { return getHighlightSpanForNode(node, sourceFile); }); } - function getSyntacticDocumentHighlights(node) { - var fileName = sourceFile.fileName; - var highlightSpans = getHighlightSpans(node); - if (!highlightSpans || highlightSpans.length === 0) { - return undefined; + } + function aggregateOwnedThrowStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 222) { + statementAccumulator.push(node); } - 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 89: - case 81: - if (hasKind(node.parent, 208)) { - return getIfElseOccurrences(node.parent); - } - break; - case 95: - if (hasKind(node.parent, 216)) { - return getReturnOccurrences(node.parent); - } - break; - case 99: - if (hasKind(node.parent, 220)) { - return getThrowOccurrences(node.parent); - } - break; - case 73: - if (hasKind(parent(parent(node)), 221)) { - return getTryCatchFinallyOccurrences(node.parent.parent); - } - break; - case 101: - case 86: - if (hasKind(parent(node), 221)) { - return getTryCatchFinallyOccurrences(node.parent); - } - break; - case 97: - if (hasKind(node.parent, 218)) { - return getSwitchCaseDefaultOccurrences(node.parent); - } - break; - case 72: - case 78: - if (hasKind(parent(parent(parent(node))), 218)) { - return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); - } - break; - case 71: - case 76: - if (hasKind(node.parent, 215) || hasKind(node.parent, 214)) { - return getBreakOrContinueStatementOccurrences(node.parent); - } - break; - case 87: - if (hasKind(node.parent, 211) || - hasKind(node.parent, 212) || - hasKind(node.parent, 213)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 105: - case 80: - if (hasKind(node.parent, 210) || hasKind(node.parent, 209)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 122: - if (hasKind(node.parent, 150)) { - return getConstructorOccurrences(node.parent); - } - break; - case 124: - case 133: - if (hasKind(node.parent, 151) || hasKind(node.parent, 152)) { - return getGetAndSetOccurrences(node.parent); - } - break; - default: - if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 205)) { - return getModifierOccurrences(node.kind, node.parent); - } - } - } - return undefined; - } - function aggregateOwnedThrowStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 220) { - statementAccumulator.push(node); - } - else if (node.kind === 221) { - 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_17 = child.parent; - if (ts.isFunctionBlock(parent_17) || parent_17.kind === 261) { - return parent_17; - } - if (parent_17.kind === 221) { - var tryStatement = parent_17; - if (tryStatement.tryBlock === child && tryStatement.catchClause) { - return child; - } - } - child = parent_17; - } - return undefined; - } - function aggregateAllBreakAndContinueStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 215 || node.kind === 214) { - 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_1 = statement.parent; node_1; node_1 = node_1.parent) { - switch (node_1.kind) { - case 218: - if (statement.kind === 214) { - continue; - } - case 211: - case 212: - case 213: - case 210: - case 209: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; - } - break; - default: - if (ts.isFunctionLike(node_1)) { - return undefined; - } - break; - } - } - return undefined; - } - function getModifierOccurrences(modifier, declaration) { - var container = declaration.parent; - if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 226 || - container.kind === 197 || - (declaration.kind === 144 && hasKind(container, 150)))) { - return undefined; - } - } - else if (modifier === 114) { - if (!(container.kind === 226 || container.kind === 197)) { - return undefined; - } - } - else if (modifier === 83 || modifier === 123) { - if (!(container.kind === 231 || container.kind === 261)) { - return undefined; - } - } - else if (modifier === 116) { - if (!(container.kind === 226 || declaration.kind === 226)) { - return undefined; - } + else if (node.kind === 223) { + var tryStatement = node; + if (tryStatement.catchClause) { + aggregate(tryStatement.catchClause); } else { - return undefined; - } - var keywords = []; - var modifierFlag = getFlagFromModifier(modifier); - var nodes; - switch (container.kind) { - case 231: - case 261: - if (modifierFlag & 128) { - nodes = declaration.members.concat(declaration); - } - else { - nodes = container.statements; - } - break; - case 150: - nodes = container.parameters.concat(container.parent.members); - break; - case 226: - case 197: - nodes = container.members; - if (modifierFlag & 28) { - var constructor = ts.forEach(container.members, function (member) { - return member.kind === 150 && member; - }); - if (constructor) { - nodes = nodes.concat(constructor.parameters); - } - } - else if (modifierFlag & 128) { - nodes = nodes.concat(container); - } - break; - default: - ts.Debug.fail("Invalid container kind."); - } - ts.forEach(nodes, function (node) { - if (ts.getModifierFlags(node) & modifierFlag) { - ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - function getFlagFromModifier(modifier) { - switch (modifier) { - case 113: - return 4; - case 111: - return 8; - case 112: - return 16; - case 114: - return 32; - case 83: - return 1; - case 123: - return 2; - case 116: - return 128; - 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, 151); - tryPushAccessorKeyword(accessorDeclaration.symbol, 152); - 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, 124, 133); }); - } - } - } - 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, 122); - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getLoopBreakContinueOccurrences(loopNode) { - var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { - if (loopNode.kind === 209) { - var loopTokens = loopNode.getChildren(); - for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 105)) { - break; - } - } - } - } - var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71, 76); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { - var owner = getBreakOrContinueOwner(breakOrContinueStatement); - if (owner) { - switch (owner.kind) { - case 211: - case 212: - case 213: - case 209: - case 210: - return getLoopBreakContinueOccurrences(owner); - case 218: - return getSwitchCaseDefaultOccurrences(owner); - } - } - return undefined; - } - function getSwitchCaseDefaultOccurrences(switchStatement) { - var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 97); - ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 72, 78); - var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71); - } - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getTryCatchFinallyOccurrences(tryStatement) { - var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 101); - if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73); + aggregate(tryStatement.tryBlock); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 86); + aggregate(tryStatement.finallyBlock); } - 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(), 99); - }); - if (ts.isFunctionBlock(owner)) { - ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); - }); - } - return ts.map(keywords, getHighlightSpanForNode); - } - function getReturnOccurrences(returnStatement) { - var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 204))) { - return undefined; - } - var keywords = []; - ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); - }); - ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getIfElseOccurrences(ifStatement) { - var keywords = []; - while (hasKind(ifStatement.parent, 208) && ifStatement.parent.elseStatement === ifStatement) { - ifStatement = ifStatement.parent; - } - while (ifStatement) { - var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 89); - for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 81)) { - break; - } - } - if (!hasKind(ifStatement.elseStatement, 208)) { - break; - } - ifStatement = ifStatement.elseStatement; - } - var result = []; - for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 81 && 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.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { - shouldCombindElseAndIf = false; - break; - } - } - if (shouldCombindElseAndIf) { - result.push({ - fileName: fileName, - textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: ts.HighlightSpanKind.reference - }); - i++; - continue; - } - } - result.push(getHighlightSpanForNode(keywords[i])); - } - return result; + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); } } } - DocumentHighlights.getDocumentHighlights = getDocumentHighlights; + function getThrowStatementOwner(throwStatement) { + var child = throwStatement; + while (child.parent) { + var parent_2 = child.parent; + if (ts.isFunctionBlock(parent_2) || parent_2.kind === 264) { + return parent_2; + } + if (parent_2.kind === 223) { + var tryStatement = parent_2; + if (tryStatement.tryBlock === child && tryStatement.catchClause) { + return child; + } + } + child = parent_2; + } + return undefined; + } + function aggregateAllBreakAndContinueStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 217 || node.kind === 216) { + 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 = statement.parent; node; node = node.parent) { + switch (node.kind) { + case 220: + if (statement.kind === 216) { + continue; + } + case 213: + case 214: + case 215: + case 212: + case 211: + if (!statement.label || isLabeledBy(node, statement.label.text)) { + return node; + } + break; + default: + if (ts.isFunctionLike(node)) { + return undefined; + } + break; + } + } + return undefined; + } + function getModifierOccurrences(modifier, declaration) { + var container = declaration.parent; + if (ts.isAccessibilityModifier(modifier)) { + if (!(container.kind === 228 || + container.kind === 198 || + (declaration.kind === 145 && hasKind(container, 151)))) { + return undefined; + } + } + else if (modifier === 114) { + if (!(container.kind === 228 || container.kind === 198)) { + return undefined; + } + } + else if (modifier === 83 || modifier === 123) { + if (!(container.kind === 233 || container.kind === 264)) { + return undefined; + } + } + else if (modifier === 116) { + if (!(container.kind === 228 || declaration.kind === 228)) { + return undefined; + } + } + else { + return undefined; + } + var keywords = []; + var modifierFlag = getFlagFromModifier(modifier); + var nodes; + switch (container.kind) { + case 233: + case 264: + if (modifierFlag & 128) { + nodes = declaration.members.concat(declaration); + } + else { + nodes = container.statements; + } + break; + case 151: + nodes = container.parameters.concat(container.parent.members); + break; + case 228: + case 198: + nodes = container.members; + if (modifierFlag & 28) { + var constructor = ts.forEach(container.members, function (member) { + return member.kind === 151 && member; + }); + if (constructor) { + nodes = nodes.concat(constructor.parameters); + } + } + else if (modifierFlag & 128) { + nodes = nodes.concat(container); + } + break; + default: + ts.Debug.fail("Invalid container kind."); + } + ts.forEach(nodes, function (node) { + if (ts.getModifierFlags(node) & modifierFlag) { + ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); + } + }); + return keywords; + function getFlagFromModifier(modifier) { + switch (modifier) { + case 113: + return 4; + case 111: + return 8; + case 112: + return 16; + case 114: + return 32; + case 83: + return 1; + case 123: + return 2; + case 116: + return 128; + 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, 152); + tryPushAccessorKeyword(accessorDeclaration.symbol, 153); + return keywords; + function tryPushAccessorKeyword(accessorSymbol, accessorKind) { + var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); + if (accessor) { + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124, 134); }); + } + } + } + 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, 122); + }); + }); + return keywords; + } + function getLoopBreakContinueOccurrences(loopNode) { + var keywords = []; + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { + if (loopNode.kind === 211) { + var loopTokens = loopNode.getChildren(); + for (var i = loopTokens.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, loopTokens[i], 105)) { + break; + } + } + } + } + var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(loopNode, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 71, 76); + } + }); + return keywords; + } + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { + var owner = getBreakOrContinueOwner(breakOrContinueStatement); + if (owner) { + switch (owner.kind) { + case 213: + case 214: + case 215: + case 211: + case 212: + return getLoopBreakContinueOccurrences(owner); + case 220: + return getSwitchCaseDefaultOccurrences(owner); + } + } + return undefined; + } + function getSwitchCaseDefaultOccurrences(switchStatement) { + var keywords = []; + pushKeywordIf(keywords, switchStatement.getFirstToken(), 97); + ts.forEach(switchStatement.caseBlock.clauses, function (clause) { + pushKeywordIf(keywords, clause.getFirstToken(), 72, 78); + var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(switchStatement, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 71); + } + }); + }); + return keywords; + } + function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { + var keywords = []; + pushKeywordIf(keywords, tryStatement.getFirstToken(), 101); + if (tryStatement.catchClause) { + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73); + } + if (tryStatement.finallyBlock) { + var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 86); + } + return keywords; + } + function getThrowOccurrences(throwStatement) { + var owner = getThrowStatementOwner(throwStatement); + if (!owner) { + return undefined; + } + var keywords = []; + ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); + }); + if (ts.isFunctionBlock(owner)) { + ts.forEachReturnStatement(owner, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); + }); + } + return keywords; + } + function getReturnOccurrences(returnStatement) { + var func = ts.getContainingFunction(returnStatement); + if (!(func && hasKind(func.body, 206))) { + return undefined; + } + var keywords = []; + ts.forEachReturnStatement(func.body, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); + }); + ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); + }); + return keywords; + } + function getIfElseOccurrences(ifStatement, sourceFile) { + var keywords = []; + while (hasKind(ifStatement.parent, 210) && ifStatement.parent.elseStatement === ifStatement) { + ifStatement = ifStatement.parent; + } + while (ifStatement) { + var children = ifStatement.getChildren(); + pushKeywordIf(keywords, children[0], 89); + for (var i = children.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, children[i], 81)) { + break; + } + } + if (!hasKind(ifStatement.elseStatement, 210)) { + break; + } + ifStatement = ifStatement.elseStatement; + } + var result = []; + for (var i = 0; i < keywords.length; i++) { + if (keywords[i].kind === 81 && 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.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { + shouldCombindElseAndIf = false; + break; + } + } + if (shouldCombindElseAndIf) { + result.push({ + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), + kind: ts.HighlightSpanKind.reference + }); + i++; + continue; + } + } + result.push(getHighlightSpanForNode(keywords[i], sourceFile)); + } + return result; + } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 219; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 221; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -56314,15 +59213,15 @@ var ts; return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + "|" + settings.allowJs + "|" + settings.baseUrl + "|" + JSON.stringify(settings.typeRoots) + "|" + JSON.stringify(settings.rootDirs) + "|" + JSON.stringify(settings.paths); } function getBucketForCompilationSettings(key, createIfMissing) { - var bucket = buckets[key]; + var bucket = buckets.get(key); if (!bucket && createIfMissing) { - buckets[key] = bucket = ts.createFileMap(); + buckets.set(key, bucket = ts.createFileMap()); } return bucket; } function reportStats() { - var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { - var entries = buckets[name]; + var bucketInfoArray = ts.arrayFrom(buckets.keys()).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { + var entries = buckets.get(name); var sourceFiles = []; entries.forEachValue(function (key, entry) { sourceFiles.push({ @@ -56410,881 +59309,937 @@ var ts; (function (ts) { var FindAllReferences; (function (FindAllReferences) { - function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments) { + function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments, isForRename) { var node = ts.getTouchingPropertyName(sourceFile, position, true); - if (node === sourceFile) { - return undefined; - } - switch (node.kind) { - case 8: - if (!ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - break; - } - case 70: - case 98: - case 122: - case 9: - return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, false); - } - return undefined; + return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename); } FindAllReferences.findReferencedSymbols = findReferencedSymbols; - function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, implementations) { + function convertReferences(referenceSymbols) { + return referenceSymbols && ts.flatMap(referenceSymbols, function (r) { return r.references; }); + } + FindAllReferences.convertReferences = convertReferences; + function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename, implementations) { if (!implementations) { - if (ts.isLabelName(node)) { - if (ts.isJumpStatementTarget(node)) { - var labelDefinition = ts.getTargetLabel(node.parent, node.text); - return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; - } - else { - return getLabelReferencesInNode(node.parent, node); - } - } - if (ts.isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles); - } - if (node.kind === 96) { - return getReferencesForSuperKeyword(node); + var special = getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken); + if (special) { + return special; } } var symbol = typeChecker.getSymbolAtLocation(node); - if (!implementations && !symbol && node.kind === 9) { - return getReferencesForStringLiteral(node, sourceFiles); - } if (!symbol) { + if (!implementations && node.kind === 9) { + return getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken); + } return undefined; } var declarations = symbol.declarations; if (!declarations || !declarations.length) { return undefined; } - var result; + var _a = followAliases(symbol, node, typeChecker, isForRename), aliasedSymbol = _a.symbol, shorthandModuleSymbol = _a.shorthandModuleSymbol; + symbol = aliasedSymbol; + var searchSymbols = populateSearchSymbolSet(symbol, node, typeChecker, implementations); + if (shorthandModuleSymbol) { + searchSymbols.push(shorthandModuleSymbol); + } var searchMeaning = getIntersectingMeaningFromDeclarations(ts.getMeaningFromLocation(node), declarations); + var result = []; + var symbolToIndex = []; + var inheritsFromCache = ts.createMap(); 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); + getRefs(scope, declaredName); } else { - var internedName = getInternedName(symbol, node); - for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { - var sourceFile = sourceFiles_8[_i]; + var isDefault = ts.isExportDefaultSymbol(symbol); + var internedName = isDefault ? symbol.valueDeclaration.localSymbol.name : getInternedName(symbol, node); + for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { + var sourceFile = sourceFiles_5[_i]; cancellationToken.throwIfCancellationRequested(); - var nameTable = ts.getNameTable(sourceFile); - if (nameTable[internedName] !== undefined) { - result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + var searchName = (isDefault ? getDefaultImportName(symbol, sourceFile, typeChecker) : undefined) || + (sourceFileHasName(sourceFile, internedName) ? declaredName : undefined); + if (searchName !== undefined) { + getRefs(sourceFile, searchName); } } } return result; - function getDefinition(symbol) { - var info = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.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), - displayParts: info.displayParts - }; + function getRefs(scope, searchName) { + getReferencesInNode(scope, symbol, searchName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache); } - function getAliasSymbolForPropertyNameSymbol(symbol, location) { - if (symbol.flags & 8388608) { - var defaultImport = ts.getDeclarationOfKind(symbol, 236); - if (defaultImport) { - return typeChecker.getAliasedSymbol(symbol); - } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 239 || - declaration.kind === 243) ? declaration : undefined; }); - if (importOrExportSpecifier && - (!importOrExportSpecifier.propertyName || - importOrExportSpecifier.propertyName === location)) { - return importOrExportSpecifier.kind === 239 ? - typeChecker.getAliasedSymbol(symbol) : - typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); - } + } + FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; + function getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken) { + if (ts.isTypeKeyword(node.kind)) { + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + } + if (ts.isLabelName(node)) { + if (ts.isJumpStatementTarget(node)) { + var labelDefinition = ts.getTargetLabel(node.parent, node.text); + return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition, cancellationToken); } + else { + return getLabelReferencesInNode(node.parent, node, cancellationToken); + } + } + if (ts.isThis(node)) { + return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken); + } + if (node.kind === 96) { + return getReferencesForSuperKeyword(node, typeChecker, cancellationToken); + } + return undefined; + } + function followAliases(symbol, node, typeChecker, isForRename) { + while (true) { + if (isForRename && isImportDefaultSymbol(symbol)) { + return { symbol: symbol }; + } + var aliasedSymbol = getAliasSymbolForPropertyNameSymbol(symbol, node, typeChecker); + if (!aliasedSymbol || !aliasedSymbol.declarations) { + return { symbol: symbol }; + } + if (ts.isShorthandAmbientModuleSymbol(aliasedSymbol)) { + return { symbol: symbol, shorthandModuleSymbol: aliasedSymbol }; + } + symbol = aliasedSymbol; + } + } + function sourceFileHasName(sourceFile, name) { + return ts.getNameTable(sourceFile).get(name) !== undefined; + } + function getDefaultImportName(symbol, sourceFile, checker) { + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var importSpecifier = _a[_i]; + var importDecl = importSpecifier.parent; + ts.Debug.assert(importDecl.moduleSpecifier === importSpecifier); + var defaultName = importDecl.importClause.name; + var defaultReferencedSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName)); + if (symbol === defaultReferencedSymbol) { + return defaultName.text; + } + } + return undefined; + } + function getDefinition(symbol, node, typeChecker) { + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.getContainerNode(node), node), displayParts = _a.displayParts, symbolKind = _a.symbolKind; + var name = displayParts.map(function (p) { return p.text; }).join(""); + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { return undefined; } - function followAliasIfNecessary(symbol, location) { - return getAliasSymbolForPropertyNameSymbol(symbol, location) || symbol; - } - function getPropertySymbolOfDestructuringAssignment(location) { - return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - typeChecker.getPropertySymbolOfDestructuringAssignment(location); - } - function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 174); - return bindingElement && - bindingElement.parent.kind === 172 && - !bindingElement.propertyName; - } - function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 174); - var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); - return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); - } + return { + containerKind: "", + containerName: "", + name: name, + kind: symbolKind, + fileName: declarations[0].getSourceFile().fileName, + textSpan: ts.createTextSpan(declarations[0].getStart(), 0), + displayParts: displayParts + }; + } + function getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) { + if (!(symbol.flags & 8388608)) { return undefined; } - function getInternedName(symbol, location) { - if (ts.isImportOrExportSpecifierName(location)) { - return location.getText(); - } - var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); - symbol = localExportDefaultSymbol || symbol; - return ts.stripQuotes(symbol.name); + var defaultImport = ts.getDeclarationOfKind(symbol, 238); + if (defaultImport) { + return typeChecker.getAliasedSymbol(symbol); } - function getSymbolScope(symbol) { - var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 184 || valueDeclaration.kind === 197)) { - return valueDeclaration; - } - if (symbol.flags & (4 | 8192)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8) ? d : undefined; }); - if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 226); - } - } - if (symbol.flags & 8388608) { - return undefined; - } - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - return undefined; - } - if (symbol.parent || (symbol.flags & 268435456)) { - return undefined; - } - var scope; - var declarations = symbol.getDeclarations(); - if (declarations) { - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; - var container = ts.getContainerNode(declaration); - if (!container) { - return undefined; - } - if (scope && scope !== container) { - return undefined; - } - if (container.kind === 261 && !ts.isExternalModule(container)) { - return undefined; - } - scope = container; - } - } - return scope; + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 241 || + declaration.kind === 245) ? declaration : undefined; }); + if (importOrExportSpecifier && + (!importOrExportSpecifier.propertyName || + importOrExportSpecifier.propertyName === location)) { + return importOrExportSpecifier.kind === 241 ? + typeChecker.getAliasedSymbol(symbol) : + typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } - function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { - var positions = []; - if (!symbolName || !symbolName.length) { - return positions; + } + function followAliasIfNecessary(symbol, location, typeChecker) { + return getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) || symbol; + } + function getPropertySymbolOfDestructuringAssignment(location, typeChecker) { + return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && + typeChecker.getPropertySymbolOfDestructuringAssignment(location); + } + function isObjectBindingPatternElementWithoutPropertyName(symbol) { + var bindingElement = ts.getDeclarationOfKind(symbol, 175); + return bindingElement && + bindingElement.parent.kind === 173 && + !bindingElement.propertyName; + } + function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker) { + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + var bindingElement = ts.getDeclarationOfKind(symbol, 175); + var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); + return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + } + return undefined; + } + function getInternedName(symbol, location) { + if (ts.isImportOrExportSpecifierName(location)) { + return location.text; + } + return ts.stripQuotes(symbol.name); + } + function getSymbolScope(symbol) { + var valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && (valueDeclaration.kind === 185 || valueDeclaration.kind === 198)) { + return valueDeclaration; + } + if (symbol.flags & (4 | 8192)) { + var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8) ? d : undefined; }); + if (privateDeclaration) { + return ts.getAncestor(privateDeclaration, 228); } - 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), 5)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5))) { - positions.push(position); + } + if (symbol.flags & 8388608) { + return undefined; + } + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + return undefined; + } + if (symbol.parent || (symbol.flags & 134217728 && symbol.checkFlags & 2)) { + return undefined; + } + var scope; + var declarations = symbol.getDeclarations(); + if (declarations) { + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; + var container = ts.getContainerNode(declaration); + if (!container) { + return undefined; } - position = text.indexOf(symbolName, position + symbolNameLength + 1); + if (scope && scope !== container) { + return undefined; + } + if (container.kind === 264 && !ts.isExternalModule(container)) { + return undefined; + } + scope = container; } + } + return scope; + } + function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end, cancellationToken) { + var positions = []; + if (!symbolName || !symbolName.length) { 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 || - (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ts.ScriptElementKind.label, - name: labelName, - textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()), - displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] - }; - return [{ definition: definition, references: references }]; + 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), 5)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5))) { + positions.push(position); + } + position = text.indexOf(symbolName, position + symbolNameLength + 1); } - function isValidReferencePosition(node, searchSymbolName) { - if (node) { - switch (node.kind) { - case 70: - return node.getWidth() === searchSymbolName.length; - case 9: - if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isNameOfExternalModuleImportOrDeclaration(node)) { - return node.getWidth() === searchSymbolName.length + 2; + return positions; + } + function getLabelReferencesInNode(container, targetLabel, cancellationToken) { + var references = []; + var sourceFile = container.getSourceFile(); + var labelName = targetLabel.text; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd(), cancellationToken); + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { + return; + } + if (node === targetLabel || + (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { + references.push(getReferenceEntryFromNode(node)); + } + }); + var definition = { + containerKind: "", + containerName: "", + fileName: targetLabel.getSourceFile().fileName, + kind: ts.ScriptElementKind.label, + name: labelName, + textSpan: ts.createTextSpanFromNode(targetLabel, sourceFile), + displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] + }; + return [{ definition: definition, references: references }]; + } + function isValidReferencePosition(node, searchSymbolName) { + switch (node && node.kind) { + case 70: + return node.getWidth() === searchSymbolName.length; + case 9: + return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && + node.getWidth() === searchSymbolName.length + 2; + case 8: + return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; + default: + return false; + } + } + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + var name = ts.tokenToString(keywordKind); + var references = []; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var sourceFile = sourceFiles_6[_i]; + cancellationToken.throwIfCancellationRequested(); + addReferencesForKeywordInFile(sourceFile, keywordKind, name, cancellationToken, references); + } + if (!references.length) + return undefined; + var definition = { + containerKind: "", + containerName: "", + fileName: references[0].fileName, + kind: ts.ScriptElementKind.keyword, + name: name, + textSpan: references[0].textSpan, + displayParts: [{ text: name, kind: ts.ScriptElementKind.keyword }] + }; + return [{ definition: definition, references: references }]; + } + function addReferencesForKeywordInFile(sourceFile, kind, searchText, cancellationToken, references) { + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { + var position = possiblePositions_1[_i]; + cancellationToken.throwIfCancellationRequested(); + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (referenceLocation.kind === kind) { + references.push({ + textSpan: ts.createTextSpanFromNode(referenceLocation), + fileName: sourceFile.fileName, + isWriteAccess: false, + isDefinition: false, + }); + } + } + } + function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache) { + var sourceFile = container.getSourceFile(); + var start = findInComments ? container.getFullStart() : container.getStart(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd(), cancellationToken); + var parents = getParentSymbolsOfPropertyAccess(); + for (var _i = 0, possiblePositions_2 = possiblePositions; _i < possiblePositions_2.length; _i++) { + var position = possiblePositions_2[_i]; + cancellationToken.throwIfCancellationRequested(); + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (!isValidReferencePosition(referenceLocation, searchText)) { + if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || + (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { + result.push({ + definition: undefined, + references: [{ + fileName: sourceFile.fileName, + textSpan: ts.createTextSpan(position, searchText.length), + isWriteAccess: false, + isDefinition: false + }] + }); + } + continue; + } + if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { + continue; + } + var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); + if (referenceSymbol) { + var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); + var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocation.kind === 122, parents, inheritsFromCache, typeChecker); + if (relatedSymbol) { + addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); + } + else if (!(referenceSymbol.flags & 134217728) && ts.contains(searchSymbols, shorthandValueSymbol)) { + addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); + } + else if (searchLocation.kind === 122) { + findAdditionalConstructorReferences(referenceSymbol, referenceLocation); + } + } + } + return; + function getParentSymbolsOfPropertyAccess() { + if (implementations) { + var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); + if (propertyAccessExpression) { + var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); + if (localParentType) { + if (localParentType.symbol && localParentType.symbol.flags & (32 | 64) && localParentType.symbol !== searchSymbol.parent) { + return [localParentType.symbol]; } - break; - case 8: - if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - return node.getWidth() === searchSymbolName.length; + else if (localParentType.flags & 196608) { + return getSymbolsForClassAndInterfaceComponents(localParentType); } - break; + } + } + } + } + function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { + ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); + var referenceClass = referenceLocation.parent; + if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { + ts.Debug.assert(referenceClass.name === referenceLocation); + addReferences(findOwnConstructorCalls(searchSymbol, sourceFile)); + } + else { + var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); + if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation, typeChecker) === searchSymbol) { + addReferences(superConstructorAccesses(classExtending)); + } + } + } + function addReferences(references) { + if (references.length) { + var referencedSymbol = getReferencedSymbol(searchSymbol); + ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); + } + } + 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, searchLocation, typeChecker), + references: [] + }); + } + return result[index]; + } + function addReferenceToRelatedSymbol(node, relatedSymbol) { + var references = getReferencedSymbol(relatedSymbol).references; + if (implementations) { + getImplementationReferenceEntryForNode(node, references, typeChecker); + } + else { + references.push(getReferenceEntryFromNode(node)); + } + } + } + function getPropertyAccessExpressionFromRightHandSide(node) { + return ts.isRightSideOfPropertyAccess(node) && node.parent; + } + function findOwnConstructorCalls(classSymbol, sourceFile) { + var result = []; + for (var _i = 0, _a = classSymbol.members.get("__constructor").declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var ctrKeyword = ts.findChildOfKind(decl, 122, sourceFile); + ts.Debug.assert(decl.kind === 151 && !!ctrKeyword); + result.push(ctrKeyword); + } + classSymbol.exports.forEach(function (member) { + var decl = member.valueDeclaration; + if (decl && decl.kind === 150) { + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 98, function (thisKeyword) { + if (ts.isNewExpressionTarget(thisKeyword)) { + result.push(thisKeyword); + } + }); + } + } + }); + return result; + } + function superConstructorAccesses(cls) { + var symbol = cls.symbol; + var ctr = symbol.members.get("__constructor"); + if (!ctr) { + return []; + } + var result = []; + for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.Debug.assert(decl.kind === 151); + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 96, function (node) { + if (ts.isCallExpressionTarget(node)) { + result.push(node); + } + }); + } + } + ; + return result; + } + function getImplementationReferenceEntryForNode(refNode, result, typeChecker) { + if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { + result.push(getReferenceEntryFromNode(refNode.parent)); + } + else if (refNode.kind === 70) { + if (refNode.parent.kind === 261) { + getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); + } + var containingClass = getContainingClassIfInHeritageClause(refNode); + if (containingClass) { + result.push(getReferenceEntryFromNode(containingClass)); + return; + } + var containingTypeReference = getContainingTypeReference(refNode); + if (containingTypeReference) { + var parent = containingTypeReference.parent; + if (ts.isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent.initializer)); + } + else if (ts.isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { + if (parent.body.kind === 206) { + ts.forEachReturnStatement(parent.body, function (returnStatement) { + if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { + maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); + } + }); + } + else if (isImplementationExpression(parent.body)) { + maybeAdd(getReferenceEntryFromNode(parent.body)); + } + } + else if (ts.isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { + maybeAdd(getReferenceEntryFromNode(parent.expression)); + } + } + } + function maybeAdd(a) { + if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { + result.push(a); + } + } + } + function getSymbolsForClassAndInterfaceComponents(type, result) { + if (result === void 0) { result = []; } + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var componentType = _a[_i]; + if (componentType.symbol && componentType.symbol.getFlags() & (32 | 64)) { + result.push(componentType.symbol); + } + if (componentType.getFlags() & 196608) { + getSymbolsForClassAndInterfaceComponents(componentType, result); + } + } + return result; + } + function getContainingTypeReference(node) { + var topLevelTypeReference = undefined; + while (node) { + if (ts.isTypeNode(node)) { + topLevelTypeReference = node; + } + node = node.parent; + } + return topLevelTypeReference; + } + function getContainingClassIfInHeritageClause(node) { + if (node && node.parent) { + if (node.kind === 200 + && node.parent.kind === 258 + && ts.isClassLike(node.parent.parent)) { + return node.parent.parent; + } + else if (node.kind === 70 || node.kind === 178) { + return getContainingClassIfInHeritageClause(node.parent); + } + } + return undefined; + } + function isImplementationExpression(node) { + switch (node.kind) { + case 184: + return isImplementationExpression(node.expression); + case 186: + case 185: + case 177: + case 198: + case 176: + return true; + default: + return false; + } + } + function explicitlyInheritsFrom(child, parent, cachedResults, typeChecker) { + var parentIsInterface = parent.getFlags() & 64; + return searchHierarchy(child); + function searchHierarchy(symbol) { + if (symbol === parent) { + return true; + } + var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); + var cached = cachedResults.get(key); + if (cached !== undefined) { + return cached; + } + cachedResults.set(key, false); + var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + if (parentIsInterface) { + var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); + if (interfaceReferences) { + for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { + var typeReference = interfaceReferences_1[_i]; + if (searchTypeReference(typeReference)) { + return true; + } + } + } + } + return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + } + else if (declaration.kind === 229) { + if (parentIsInterface) { + return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); + } + } + return false; + }); + cachedResults.set(key, inherits); + return inherits; + } + function searchTypeReference(typeReference) { + if (typeReference) { + var type = typeChecker.getTypeAtLocation(typeReference); + if (type && type.symbol) { + return searchHierarchy(type.symbol); } } return false; } - function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex) { - var sourceFile = container.getSourceFile(); - var start = findInComments ? container.getFullStart() : container.getStart(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd()); - var parents = getParentSymbolsOfPropertyAccess(); - var inheritsFromCache = ts.createMap(); - if (possiblePositions.length) { - var searchSymbols_1 = populateSearchSymbolSet(searchSymbol, searchLocation); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); - if (!isValidReferencePosition(referenceLocation, searchText)) { - if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || - (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { - result.push({ - definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: ts.createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] - }); - } - return; - } - if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { - return; - } - var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); - if (referenceSymbol) { - var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, searchLocation.kind === 122, parents, inheritsFromCache); - if (relatedSymbol) { - addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); - } - else if (!(referenceSymbol.flags & 67108864) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { - addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); - } - else if (searchLocation.kind === 122) { - findAdditionalConstructorReferences(referenceSymbol, referenceLocation); - } - } - }); - } - return; - function getParentSymbolsOfPropertyAccess() { - if (implementations) { - var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); - if (propertyAccessExpression) { - var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); - if (localParentType) { - if (localParentType.symbol && localParentType.symbol.flags & (32 | 64) && localParentType.symbol !== searchSymbol.parent) { - return [localParentType.symbol]; - } - else if (localParentType.flags & 196608) { - return getSymbolsForClassAndInterfaceComponents(localParentType); - } - } - } - } - } - function getPropertyAccessExpressionFromRightHandSide(node) { - return ts.isRightSideOfPropertyAccess(node) && node.parent; - } - function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { - ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); - var referenceClass = referenceLocation.parent; - if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { - ts.Debug.assert(referenceClass.name === referenceLocation); - addReferences(findOwnConstructorCalls(searchSymbol)); - } - else { - var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); - if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation) === searchSymbol) { - addReferences(superConstructorAccesses(classExtending)); - } - } - } - function addReferences(references) { - if (references.length) { - var referencedSymbol = getReferencedSymbol(searchSymbol); - ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); - } - } - function findOwnConstructorCalls(classSymbol) { - var result = []; - for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 150); - var ctrKeyword = decl.getChildAt(0); - ts.Debug.assert(ctrKeyword.kind === 122); - result.push(ctrKeyword); - } - ts.forEachProperty(classSymbol.exports, function (member) { - var decl = member.valueDeclaration; - if (decl && decl.kind === 149) { - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 98, function (thisKeyword) { - if (ts.isNewExpressionTarget(thisKeyword)) { - result.push(thisKeyword); - } - }); - } - } - }); - return result; - } - function superConstructorAccesses(cls) { - var symbol = cls.symbol; - var ctr = symbol.members["__constructor"]; - if (!ctr) { - return []; - } - var result = []; - for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 150); - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 96, function (node) { - if (ts.isCallExpressionTarget(node)) { - result.push(node); - } - }); - } - } - ; - return result; - } - 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 addReferenceToRelatedSymbol(node, relatedSymbol) { - var references = getReferencedSymbol(relatedSymbol).references; - if (implementations) { - getImplementationReferenceEntryForNode(node, references); - } - else { - references.push(getReferenceEntryFromNode(node)); - } - } - } - function getImplementationReferenceEntryForNode(refNode, result) { - if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { - result.push(getReferenceEntryFromNode(refNode.parent)); - } - else if (refNode.kind === 70) { - if (refNode.parent.kind === 258) { - getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); - } - var containingClass = getContainingClassIfInHeritageClause(refNode); - if (containingClass) { - result.push(getReferenceEntryFromNode(containingClass)); - return; - } - var containingTypeReference = getContainingTypeReference(refNode); - if (containingTypeReference) { - var parent_18 = containingTypeReference.parent; - if (ts.isVariableLike(parent_18) && parent_18.type === containingTypeReference && parent_18.initializer && isImplementationExpression(parent_18.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_18.initializer)); - } - else if (ts.isFunctionLike(parent_18) && parent_18.type === containingTypeReference && parent_18.body) { - if (parent_18.body.kind === 204) { - ts.forEachReturnStatement(parent_18.body, function (returnStatement) { - if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { - maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); - } - }); - } - else if (isImplementationExpression(parent_18.body)) { - maybeAdd(getReferenceEntryFromNode(parent_18.body)); - } - } - else if (ts.isAssertionExpression(parent_18) && isImplementationExpression(parent_18.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_18.expression)); - } - } - } - function maybeAdd(a) { - if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { - result.push(a); - } - } - } - function getSymbolsForClassAndInterfaceComponents(type, result) { - if (result === void 0) { result = []; } - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var componentType = _a[_i]; - if (componentType.symbol && componentType.symbol.getFlags() & (32 | 64)) { - result.push(componentType.symbol); - } - if (componentType.getFlags() & 196608) { - getSymbolsForClassAndInterfaceComponents(componentType, result); - } - } - return result; - } - function getContainingTypeReference(node) { - var topLevelTypeReference = undefined; - while (node) { - if (ts.isTypeNode(node)) { - topLevelTypeReference = node; - } - node = node.parent; - } - return topLevelTypeReference; - } - function getContainingClassIfInHeritageClause(node) { - if (node && node.parent) { - if (node.kind === 199 - && node.parent.kind === 255 - && ts.isClassLike(node.parent.parent)) { - return node.parent.parent; - } - else if (node.kind === 70 || node.kind === 177) { - return getContainingClassIfInHeritageClause(node.parent); - } - } + } + function getReferencesForSuperKeyword(superKeyword, typeChecker, cancellationToken) { + var searchSpaceNode = ts.getSuperContainer(superKeyword, false); + if (!searchSpaceNode) { return undefined; } - function isImplementationExpression(node) { - if (node.kind === 183) { - return isImplementationExpression(node.expression); - } - return node.kind === 185 || - node.kind === 184 || - node.kind === 176 || - node.kind === 197 || - node.kind === 175; - } - function explicitlyInheritsFrom(child, parent, cachedResults) { - var parentIsInterface = parent.getFlags() & 64; - return searchHierarchy(child); - function searchHierarchy(symbol) { - if (symbol === parent) { - return true; - } - var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); - if (key in cachedResults) { - return cachedResults[key]; - } - cachedResults[key] = false; - var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - if (parentIsInterface) { - var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); - if (interfaceReferences) { - for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { - var typeReference = interfaceReferences_1[_i]; - if (searchTypeReference(typeReference)) { - return true; - } - } - } - } - return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - } - else if (declaration.kind === 227) { - if (parentIsInterface) { - return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); - } - } - return false; - }); - cachedResults[key] = inherits; - return inherits; - } - function searchTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type && type.symbol) { - return searchHierarchy(type.symbol); - } - } - return false; - } - } - function getReferencesForSuperKeyword(superKeyword) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, false); - if (!searchSpaceNode) { + var staticFlag = 32; + switch (searchSpaceNode.kind) { + case 148: + case 147: + case 150: + case 149: + case 151: + case 152: + case 153: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; + break; + default: return undefined; + } + var references = []; + var sourceFile = searchSpaceNode.getSourceFile(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + for (var _i = 0, possiblePositions_3 = possiblePositions; _i < possiblePositions_3.length; _i++) { + var position = possiblePositions_3[_i]; + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 96) { + continue; } - var staticFlag = 32; - switch (searchSpaceNode.kind) { - case 147: - case 146: - case 149: - case 148: - case 150: - case 151: - case 152: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; + var container = ts.getSuperContainer(node, false); + if (container && (32 & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + references.push(getReferenceEntryFromNode(node)); + } + } + var definition = getDefinition(searchSpaceNode.symbol, superKeyword, typeChecker); + return [{ definition: definition, references: references }]; + } + function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, typeChecker, cancellationToken) { + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); + var staticFlag = 32; + switch (searchSpaceNode.kind) { + case 150: + case 149: + if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; - default: + } + case 148: + case 147: + case 151: + case 152: + case 153: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; + break; + case 264: + if (ts.isExternalModule(searchSpaceNode)) { return undefined; - } - var references = []; + } + case 227: + case 185: + break; + default: + return undefined; + } + var references = []; + var possiblePositions; + if (searchSpaceNode.kind === 264) { + ts.forEach(sourceFiles, function (sourceFile) { + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); + } + else { var sourceFile = searchSpaceNode.getSourceFile(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); + } + var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); + var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: thisOrSuperKeyword.getSourceFile().fileName, + kind: ts.ScriptElementKind.variableElement, + name: "this", + textSpan: ts.createTextSpanFromNode(thisOrSuperKeyword), + displayParts: displayParts + }, + 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 !== 96) { + if (!node || !ts.isThis(node)) { return; } - var container = ts.getSuperContainer(node, false); - if (container && (32 & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); + var container = ts.getThisContainer(node, false); + switch (searchSpaceNode.kind) { + case 185: + case 227: + if (searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 150: + case 149: + if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 198: + case 228: + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 264: + if (container.kind === 264 && !ts.isExternalModule(container)) { + result.push(getReferenceEntryFromNode(node)); + } + break; } }); - var definition = getDefinition(searchSpaceNode.symbol); - return [{ definition: definition, references: references }]; } - function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); - var staticFlag = 32; - switch (searchSpaceNode.kind) { - case 149: - case 148: - if (ts.isObjectLiteralMethod(searchSpaceNode)) { - break; + } + function getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken) { + var type = ts.getStringLiteralTypeForNode(node, typeChecker); + if (!type) { + return undefined; + } + var references = []; + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); + } + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ts.ScriptElementKind.variableElement, + name: type.text, + textSpan: ts.createTextSpanFromNode(node), + displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] + }, + references: references + }]; + function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { + for (var _i = 0, possiblePositions_4 = possiblePositions; _i < possiblePositions_4.length; _i++) { + var position = possiblePositions_4[_i]; + cancellationToken.throwIfCancellationRequested(); + var node_2 = ts.getTouchingWord(sourceFile, position); + if (!node_2 || node_2.kind !== 9) { + return; + } + var type_2 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + if (type_2 === searchType) { + references.push(getReferenceEntryFromNode(node_2)); + } + } + } + } + function populateSearchSymbolSet(symbol, location, typeChecker, implementations) { + var result = [symbol]; + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(location); + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 261) { + var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, typeChecker); + if (propertySymbol) { + result.push(propertySymbol); + } + } + if (containingObjectLiteralElement) { + ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { + ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); + }); + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); + if (shorthandValueSymbol) { + result.push(shorthandValueSymbol); + } + } + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 145 && + ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + ts.addRange(result, typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); + } + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker); + if (bindingElementPropertySymbol) { + result.push(bindingElementPropertySymbol); + } + for (var _i = 0, _a = typeChecker.getRootSymbols(symbol); _i < _a.length; _i++) { + var rootSymbol = _a[_i]; + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap(), typeChecker); + } + } + return result; + } + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache, typeChecker) { + if (!symbol) { + return; + } + if (previousIterationSymbolsCache.has(symbol.name)) { + return; + } + if (symbol.flags & (32 | 64)) { + ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === 229) { + 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.apply(result, typeChecker.getRootSymbols(propertySymbol)); } - case 147: - case 146: - case 150: - case 151: - case 152: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; - break; - case 261: - if (ts.isExternalModule(searchSpaceNode)) { + previousIterationSymbolsCache.set(symbol.name, symbol); + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, typeChecker); + } + } + } + } + function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker) { + if (ts.contains(searchSymbols, referenceSymbol)) { + return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) ? referenceSymbol : undefined; + } + var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation, typeChecker); + if (aliasSymbol) { + return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker); + } + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(referenceLocation); + if (containingObjectLiteralElement) { + var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { + return ts.find(typeChecker.getRootSymbols(contextualSymbol), function (symbol) { return ts.contains(searchSymbols, symbol); }); + }); + if (contextualSymbol) { + return contextualSymbol; + } + var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, typeChecker); + if (propertySymbol && ts.contains(searchSymbols, propertySymbol)) { + return propertySymbol; + } + } + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, typeChecker); + if (bindingElementPropertySymbol && ts.contains(searchSymbols, bindingElementPropertySymbol)) { + return bindingElementPropertySymbol; + } + return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { + if (ts.contains(searchSymbols, rootSymbol)) { + return rootSymbol; + } + if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + if (parents) { + if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache, typeChecker); })) { return undefined; } - case 225: - case 184: - break; - default: - return undefined; - } - var references = []; - var possiblePositions; - if (searchSpaceNode.kind === 261) { - 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); - } - var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); - var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: "this", - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: displayParts - }, - references: references - }]; - function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || !ts.isThis(node)) { - return; - } - var container = ts.getThisContainer(node, false); - switch (searchSpaceNode.kind) { - case 184: - case 225: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 149: - case 148: - if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 197: - case 226: - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 261: - if (container.kind === 261 && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); - } - } - function getReferencesForStringLiteral(node, sourceFiles) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (!type) { - return undefined; - } - var references = []; - for (var _i = 0, sourceFiles_9 = sourceFiles; _i < sourceFiles_9.length; _i++) { - var sourceFile = sourceFiles_9[_i]; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd()); - getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); - } - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: type.text, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] - }, - references: references - }]; - function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { - for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { - var position = possiblePositions_1[_i]; - cancellationToken.throwIfCancellationRequested(); - var node_2 = ts.getTouchingWord(sourceFile, position); - if (!node_2 || node_2.kind !== 9) { - return; - } - var type_1 = ts.getStringLiteralTypeForNode(node_2, typeChecker); - if (type_1 === searchType) { - references.push(getReferenceEntryFromNode(node_2)); - } } + var result = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap(), typeChecker); + return ts.find(result, function (symbol) { return ts.contains(searchSymbols, symbol); }); } - } - function populateSearchSymbolSet(symbol, location) { - var result = [symbol]; - var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 258) { - var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); - if (propertySymbol) { - result.push(propertySymbol); - } - } - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(symbol, location); - if (aliasSymbol) { - result = result.concat(populateSearchSymbolSet(aliasSymbol, location)); - } - if (containingObjectLiteralElement) { - ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), function (contextualSymbol) { - ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); - }); - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); - if (shorthandValueSymbol) { - result.push(shorthandValueSymbol); - } - } - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 144 && - ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { - result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); - } - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol); - if (bindingElementPropertySymbol) { - result.push(bindingElementPropertySymbol); - } - ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap()); - } - }); - return result; - } - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache) { - if (!symbol) { - return; - } - if (symbol.name in previousIterationSymbolsCache) { - return; - } - if (symbol.flags & (32 | 64)) { - ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === 227) { - 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.apply(result, typeChecker.getRootSymbols(propertySymbol)); - } - previousIterationSymbolsCache[symbol.name] = symbol; - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache); - } - } - } - } - function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache) { - if (ts.contains(searchSymbols, referenceSymbol)) { - return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) && referenceSymbol; - } - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation); - if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache); - } - var containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation); - if (containingObjectLiteralElement) { - var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), function (contextualSymbol) { - return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - }); - if (contextualSymbol) { - return contextualSymbol; - } - var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation); - if (propertySymbol && searchSymbols.indexOf(propertySymbol) >= 0) { - return propertySymbol; - } - } - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol); - if (bindingElementPropertySymbol && searchSymbols.indexOf(bindingElementPropertySymbol) >= 0) { - return bindingElementPropertySymbol; - } - return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { - if (searchSymbols.indexOf(rootSymbol) >= 0) { - return rootSymbol; - } - if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - if (parents) { - if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache); })) { - return undefined; - } - } - var result_4 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_4, ts.createMap()); - return ts.forEach(result_4, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - } - return undefined; - }); - } - function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 142) { - var nameExpression = node.name.expression; - if (ts.isStringOrNumericLiteral(nameExpression)) { - return nameExpression.text; - } - return undefined; - } - return node.name.text; - } - function getPropertySymbolsFromContextualType(node) { - var objectLiteral = node.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - var name = getNameFromObjectLiteralElement(node); - if (name && contextualType) { - var result_5 = []; - var symbol_2 = contextualType.getProperty(name); - if (symbol_2) { - result_5.push(symbol_2); - } - if (contextualType.flags & 65536) { - ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name); - if (symbol) { - result_5.push(symbol); - } - }); - } - return result_5; + return undefined; + }); + } + function getNameFromObjectLiteralElement(node) { + if (node.name.kind === 143) { + var nameExpression = node.name.expression; + if (ts.isStringOrNumericLiteral(nameExpression)) { + return nameExpression.text; } return undefined; } - function getIntersectingMeaningFromDeclarations(meaning, declarations) { - if (declarations) { - var lastIterationMeaning = void 0; - do { - lastIterationMeaning = meaning; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; - var declarationMeaning = ts.getMeaningFromDeclaration(declaration); - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; - } - } - } while (meaning !== lastIterationMeaning); + return node.name.text; + } + function getPropertySymbolsFromContextualType(node, typeChecker) { + var objectLiteral = node.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name = getNameFromObjectLiteralElement(node); + if (name && contextualType) { + var result_4 = []; + var symbol = contextualType.getProperty(name); + if (symbol) { + result_4.push(symbol); } - return meaning; + if (contextualType.flags & 65536) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_4.push(symbol); + } + }); + } + return result_4; } + return undefined; } - FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; - function convertReferences(referenceSymbols) { - if (!referenceSymbols) { - return undefined; + function getIntersectingMeaningFromDeclarations(meaning, declarations) { + if (declarations) { + var lastIterationMeaning = void 0; + do { + lastIterationMeaning = meaning; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; + var declarationMeaning = ts.getMeaningFromDeclaration(declaration); + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; + } + } + } while (meaning !== lastIterationMeaning); } - var referenceEntries = []; - for (var _i = 0, referenceSymbols_1 = referenceSymbols; _i < referenceSymbols_1.length; _i++) { - var referenceSymbol = referenceSymbols_1[_i]; - ts.addRange(referenceEntries, referenceSymbol.references); - } - return referenceEntries; + return meaning; } - FindAllReferences.convertReferences = convertReferences; function isImplementation(node) { if (!node) { return false; @@ -57293,7 +60248,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 223) { + else if (node.kind === 225) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2); } @@ -57303,18 +60258,18 @@ var ts; } else { switch (node.kind) { - case 226: - case 197: - case 229: - case 230: + case 228: + case 198: + case 231: + case 232: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 205) { - ts.Debug.assert(node.parent.kind === 224); + if (node.parent && node.parent.parent && node.parent.parent.kind === 207) { + ts.Debug.assert(node.parent.kind === 226); return node.parent.parent; } } @@ -57352,10 +60307,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 191 || parent.kind === 190) { + if (parent.kind === 192 || parent.kind === 191) { return true; } - else if (parent.kind === 192 && parent.left === node) { + else if (parent.kind === 193 && parent.left === node) { var operator = parent.operatorToken.kind; return 57 <= operator && operator <= 69; } @@ -57370,29 +60325,6 @@ var ts; forEachDescendantOfKind(child, kind, action); }); } - function getContainingObjectLiteralElement(node) { - switch (node.kind) { - case 9: - case 8: - if (node.parent.kind === 142) { - return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; - } - case 70: - return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; - } - return undefined; - } - function isObjectLiteralPropertyDeclaration(node) { - switch (node.kind) { - case 257: - case 258: - case 149: - case 151: - case 152: - return true; - } - return false; - } function tryGetClassByExtendingIdentifier(node) { return ts.tryGetClassExtendingExpressionWithTypeArguments(ts.climbPastPropertyAccess(node).parent); } @@ -57402,6 +60334,9 @@ var ts; } return false; } + function isImportDefaultSymbol(symbol) { + return symbol.declarations[0].kind === 238; + } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); var ts; @@ -57419,11 +60354,9 @@ var ts; } var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { - var referenceFile = program.getResolvedTypeReferenceDirectives()[typeReferenceDirective.fileName]; - if (referenceFile && referenceFile.resolvedFileName) { - return [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; - } - return undefined; + var referenceFile = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); + return referenceFile && referenceFile.resolvedFileName && + [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; } var node = ts.getTouchingPropertyName(sourceFile, position); if (node === sourceFile) { @@ -57432,7 +60365,7 @@ var ts; if (ts.isJumpStatementTarget(node)) { var labelName = node.text; var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ts.ScriptElementKind.label, labelName, undefined)] : undefined; + return label ? [createDefinitionInfoFromName(label, ts.ScriptElementKind.label, labelName, undefined)] : undefined; } var typeChecker = program.getTypeChecker(); var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); @@ -57447,11 +60380,11 @@ var ts; var declaration = symbol.declarations[0]; if (node.kind === 70 && (node.parent === declaration || - (declaration.kind === 239 && declaration.parent && declaration.parent.kind === 238))) { + (declaration.kind === 241 && declaration.parent && declaration.parent.kind === 240))) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 258) { + if (node.parent.kind === 261) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -57462,6 +60395,22 @@ var ts; var shorthandContainerName_1 = typeChecker.symbolToString(symbol.parent, node); return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind_1, shorthandSymbolName_1, shorthandContainerName_1); }); } + if (ts.isJsxOpeningLikeElement(node.parent)) { + var _a = getSymbolInfo(typeChecker, symbol, node), symbolName = _a.symbolName, symbolKind = _a.symbolKind, containerName = _a.containerName; + return [createDefinitionInfo(symbol.valueDeclaration, symbolKind, symbolName, containerName)]; + } + var element = ts.getContainingObjectLiteralElement(node); + if (element) { + if (typeChecker.getContextualType(element.parent)) { + var result = []; + var propertySymbols = ts.getPropertySymbolsFromContextualType(typeChecker, element); + for (var _i = 0, propertySymbols_1 = propertySymbols; _i < propertySymbols_1.length; _i++) { + var propertySymbol = propertySymbols_1[_i]; + result.push.apply(result, getDefinitionFromSymbol(typeChecker, propertySymbol, node)); + } + return result; + } + } return getDefinitionFromSymbol(typeChecker, symbol, node); } GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; @@ -57479,13 +60428,13 @@ var ts; return undefined; } if (type.flags & 65536 && !(type.flags & 16)) { - var result_6 = []; + var result_5 = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(result_6, getDefinitionFromSymbol(typeChecker, t.symbol, node)); + ts.addRange(result_5, getDefinitionFromSymbol(typeChecker, t.symbol, node)); } }); - return result_6; + return result_5; } if (!type.symbol) { return undefined; @@ -57527,29 +60476,40 @@ var ts; function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { var declarations = []; var definition; - ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 150) || - (!selectConstructors && (d.kind === 225 || d.kind === 149 || d.kind === 148))) { + for (var _i = 0, signatureDeclarations_1 = signatureDeclarations; _i < signatureDeclarations_1.length; _i++) { + var d = signatureDeclarations_1[_i]; + if (selectConstructors ? d.kind === 151 : isSignatureDeclaration(d)) { 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)); + if (declarations.length) { + result.push(createDefinitionInfo(definition || ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); return true; } return false; } } + function isSignatureDeclaration(node) { + switch (node.kind) { + case 151: + case 227: + case 150: + case 149: + return true; + default: + return false; + } + } function createDefinitionInfo(node, symbolKind, symbolName, containerName) { + return createDefinitionInfoFromName(node.name || node, symbolKind, symbolName, containerName); + } + function createDefinitionInfoFromName(name, symbolKind, symbolName, containerName) { + var sourceFile = name.getSourceFile(); return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromNode(name, sourceFile), kind: symbolKind, name: symbolName, containerKind: undefined, @@ -57596,7 +60556,14 @@ var ts; } function tryGetSignatureDeclaration(typeChecker, node) { var callLike = getAncestorCallLikeExpression(node); - return callLike && typeChecker.getResolvedSignature(callLike).declaration; + var signature = callLike && typeChecker.getResolvedSignature(callLike); + if (signature) { + var decl = signature.declaration; + if (decl && isSignatureDeclaration(decl)) { + return decl; + } + } + return undefined; } })(GoToDefinition = ts.GoToDefinition || (ts.GoToDefinition = {})); })(ts || (ts = {})); @@ -57605,7 +60572,7 @@ var ts; var GoToImplementation; (function (GoToImplementation) { function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { - if (node.parent.kind === 258) { + if (node.parent.kind === 261) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -57615,7 +60582,7 @@ var ts; return symbol.valueDeclaration && [ts.FindAllReferences.getReferenceEntryFromNode(symbol.valueDeclaration)]; } else { - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, false, false, true); + var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, false, false, false, true); var result = ts.flatMap(referencedSymbols, function (symbol) { return ts.map(symbol.references, function (_a) { var textSpan = _a.textSpan, fileName = _a.fileName; @@ -57697,7 +60664,7 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function forEachUnique(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (ts.indexOf(array, array[i]) === i) { var result = callback(array[i], i); if (result) { @@ -57731,16 +60698,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 225: - case 149: + case 227: case 150: - case 226: - case 205: + case 151: + case 228: + case 207: break findOwner; - case 261: + case 264: return undefined; - case 230: - if (commentOwner.parent.kind === 230) { + case 232: + if (commentOwner.parent.kind === 232) { return undefined; } break findOwner; @@ -57755,7 +60722,7 @@ var ts; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; - for (var i = 0, numParams = parameters.length; i < numParams; i++) { + for (var i = 0; i < parameters.length; i++) { var currentName = parameters[i].name; var paramName = currentName.kind === 70 ? currentName.text : @@ -57780,7 +60747,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 205) { + if (commentOwner.kind === 207) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -57790,17 +60757,17 @@ var ts; return ts.emptyArray; } function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 183) { + while (rightHandSide.kind === 184) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 184: case 185: + case 186: return rightHandSide.parameters; - case 197: + case 198: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150) { + if (member.kind === 151) { return member.parameters; } } @@ -57811,47 +60778,210 @@ var ts; })(JsDoc = ts.JsDoc || (ts.JsDoc = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var JsTyping; + (function (JsTyping) { + ; + ; + var safeList; + var EmptySafeList = ts.createMap(); + JsTyping.nodeCoreModuleList = [ + "buffer", "querystring", "events", "http", "cluster", + "zlib", "os", "https", "punycode", "repl", "readline", + "vm", "child_process", "url", "dns", "net", + "dgram", "fs", "path", "string_decoder", "tls", + "crypto", "stream", "util", "assert", "tty", "domain", + "constants", "process", "v8", "timers", "console" + ]; + var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typeAcquisition, unresolvedImports) { + var inferredTypings = ts.createMap(); + if (!typeAcquisition || !typeAcquisition.enable) { + return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; + } + fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { + var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); + return kind === 1 || kind === 2; + }); + if (!safeList) { + var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); + safeList = result.config ? ts.createMapFromTemplate(result.config) : EmptySafeList; + } + var filesToWatch = []; + var searchDirs = []; + var exclude = []; + mergeTypings(typeAcquisition.include); + exclude = typeAcquisition.exclude || []; + var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); + if (projectRootPath) { + possibleSearchDirs.push(projectRootPath); + } + searchDirs = ts.deduplicate(possibleSearchDirs); + for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { + var searchDir = searchDirs_1[_i]; + var packageJsonPath = ts.combinePaths(searchDir, "package.json"); + getTypingNamesFromJson(packageJsonPath, filesToWatch); + var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); + getTypingNamesFromJson(bowerJsonPath, filesToWatch); + var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); + getTypingNamesFromNodeModuleFolder(nodeModulesPath); + } + getTypingNamesFromSourceFileNames(fileNames); + if (unresolvedImports) { + for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { + var moduleId = unresolvedImports_1[_a]; + var typingName = nodeCoreModules.has(moduleId) ? "node" : moduleId; + if (!inferredTypings.has(typingName)) { + inferredTypings.set(typingName, undefined); + } + } + } + packageNameToTypingLocation.forEach(function (typingLocation, name) { + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined) { + inferredTypings.set(name, typingLocation); + } + }); + for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { + var excludeTypingName = exclude_1[_b]; + inferredTypings.delete(excludeTypingName); + } + var newTypingNames = []; + var cachedTypingPaths = []; + inferredTypings.forEach(function (inferred, typing) { + if (inferred !== undefined) { + cachedTypingPaths.push(inferred); + } + else { + newTypingNames.push(typing); + } + }); + return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; + function mergeTypings(typingNames) { + if (!typingNames) { + return; + } + for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { + var typing = typingNames_1[_i]; + if (!inferredTypings.has(typing)) { + inferredTypings.set(typing, undefined); + } + } + } + function getTypingNamesFromJson(jsonPath, filesToWatch) { + if (host.fileExists(jsonPath)) { + filesToWatch.push(jsonPath); + } + var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); + if (result.config) { + var jsonConfig = result.config; + if (jsonConfig.dependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); + } + if (jsonConfig.devDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); + } + if (jsonConfig.optionalDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); + } + if (jsonConfig.peerDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); + } + } + } + function getTypingNamesFromSourceFileNames(fileNames) { + var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); + var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); + var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); + if (safeList !== EmptySafeList) { + mergeTypings(ts.filter(cleanedTypingNames, function (f) { return safeList.has(f); })); + } + var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); + if (hasJsxFile) { + mergeTypings(["react"]); + } + } + function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { + if (!host.directoryExists(nodeModulesPath)) { + return; + } + var typingNames = []; + var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); + for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { + var fileName = fileNames_2[_i]; + var normalizedFileName = ts.normalizePath(fileName); + if (ts.getBaseFileName(normalizedFileName) !== "package.json") { + continue; + } + var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); + if (!result.config) { + continue; + } + var packageJson = result.config; + if (packageJson._requiredBy && + ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { + continue; + } + if (!packageJson.name) { + continue; + } + if (packageJson.typings) { + var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); + inferredTypings.set(packageJson.name, absolutePath); + } + else { + typingNames.push(packageJson.name); + } + } + mergeTypings(typingNames); + } + } + JsTyping.discoverTypings = discoverTypings; + })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var NavigateTo; (function (NavigateTo) { function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; - ts.forEach(sourceFiles, function (sourceFile) { + var _loop_4 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) { - return; + return "continue"; } - var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_47 in nameToDeclarations) { - var declarations = nameToDeclarations[name_47]; + ts.forEachEntry(sourceFile.getNamedDeclarations(), function (declarations, name) { if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_47); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); if (!matches) { - continue; + return; } - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { + var declaration = declarations_12[_i]; if (patternMatcher.patternContainsDots) { var containers = getContainers(declaration); if (!containers) { - return undefined; + return true; } - matches = patternMatcher.getMatches(containers, name_47); + matches = patternMatcher.getMatches(containers, name); if (!matches) { - continue; + return; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_47, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } - } - }); + }); + }; + for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { + var sourceFile = sourceFiles_8[_i]; + _loop_4(sourceFile); + } rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 236 || decl.kind === 239 || decl.kind === 234) { + if (decl.kind === 238 || decl.kind === 241 || decl.kind === 236) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -57892,7 +61022,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 142) { + else if (declaration.name.kind === 143) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -57909,7 +61039,7 @@ var ts; } return true; } - if (expression.kind === 177) { + if (expression.kind === 178) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -57920,7 +61050,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 142) { + if (declaration.name.kind === 143) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -57961,7 +61091,7 @@ var ts; matchKind: ts.PatternMatchKind[rawItem.matchKind], isCaseSensitive: rawItem.isCaseSensitive, fileName: rawItem.fileName, - textSpan: ts.createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), + textSpan: ts.createTextSpanFromNode(declaration), containerName: container && container.name ? container.name.text : "", containerKind: container && container.name ? ts.getNodeKind(container) : "" }; @@ -58052,7 +61182,7 @@ var ts; return; } switch (node.kind) { - case 150: + case 151: var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { @@ -58062,28 +61192,28 @@ var ts; } } break; - case 149: - case 151: + case 150: case 152: - case 148: + case 153: + case 149: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; + case 148: case 147: - case 146: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 236: + case 238: var importClause = node; if (importClause.name) { addLeafNode(importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 237) { + if (namedBindings.kind === 239) { addLeafNode(namedBindings); } else { @@ -58094,12 +61224,12 @@ var ts; } } break; - case 174: - case 223: + case 175: + case 225: var decl = node; - var name_48 = decl.name; - if (ts.isBindingPattern(name_48)) { - addChildrenRecursively(name_48); + var name = decl.name; + if (ts.isBindingPattern(name)) { + addChildrenRecursively(name); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { addChildrenRecursively(decl.initializer); @@ -58108,12 +61238,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; + case 186: + case 227: case 185: - case 225: - case 184: addNodeWithRecursiveChild(node, node.body); break; - case 229: + case 231: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -58123,9 +61253,9 @@ var ts; } endNode(); break; - case 226: - case 197: - case 227: + case 228: + case 198: + case 229: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -58133,21 +61263,21 @@ var ts; } endNode(); break; - case 230: + case 232: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 243: - case 234: - case 155: - case 153: + case 245: + case 236: + case 156: case 154: - case 228: + case 155: + case 230: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 285) { + if (tag.kind === 289) { addLeafNode(tag); } }); @@ -58163,9 +61293,9 @@ var ts; if (!name) { return true; } - var itemsWithSameName = nameToItems[name]; + var itemsWithSameName = nameToItems.get(name); if (!itemsWithSameName) { - nameToItems[name] = child; + nameToItems.set(name, child); return true; } if (itemsWithSameName instanceof Array) { @@ -58183,7 +61313,7 @@ var ts; if (tryMerge(itemWithSameName, child)) { return false; } - nameToItems[name] = [itemWithSameName, child]; + nameToItems.set(name, [itemWithSameName, child]); return true; } function tryMerge(a, b) { @@ -58195,12 +61325,12 @@ var ts; } }); function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 230 || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 232 || areSameModule(a, b)); function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 230) { + if (a.body.kind !== 232) { return true; } return areSameModule(a.body, b.body); @@ -58226,32 +61356,15 @@ var ts; function compareChildren(child1, child2) { var name1 = tryGetName(child1.node), name2 = tryGetName(child2.node); if (name1 && name2) { - var cmp = localeCompareFix(name1, name2); + var cmp = ts.compareStringsCaseInsensitive(name1, name2); return cmp !== 0 ? cmp : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } else { return name1 ? 1 : name2 ? -1 : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } } - var localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; - var localeCompareFix = localeCompareIsCorrect ? ts.collator.compare : function (a, b) { - for (var i = 0; i < Math.min(a.length, b.length); i++) { - var chA = a.charAt(i), chB = b.charAt(i); - if (chA === "\"" && chB === "'") { - return 1; - } - if (chA === "'" && chB === "\"") { - return -1; - } - var cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); - if (cmp !== 0) { - return cmp; - } - } - return a.length - b.length; - }; function tryGetName(node) { - if (node.kind === 230) { + if (node.kind === 232) { return getModuleName(node); } var decl = node; @@ -58259,18 +61372,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 184: case 185: - case 197: + case 186: + case 198: return getFunctionOrClassName(node); - case 285: + case 289: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 230) { + if (node.kind === 232) { return getModuleName(node); } var name = node.name; @@ -58281,29 +61394,29 @@ var ts; } } switch (node.kind) { - case 261: + case 264: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; + case 186: + case 227: case 185: - case 225: - case 184: - case 226: - case 197: + case 228: + case 198: if (ts.getModifierFlags(node) & 512) { return "default"; } return getFunctionOrClassName(node); - case 150: + case 151: return "constructor"; - case 154: - return "new()"; - case 153: - return "()"; case 155: + return "new()"; + case 154: + return "()"; + case 156: return "[]"; - case 285: + case 289: return getJSDocTypedefTagName(node); default: return ""; @@ -58315,7 +61428,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 205) { + if (parentNode && parentNode.kind === 207) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -58343,24 +61456,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 226: - case 197: - case 229: - case 227: - case 230: - case 261: case 228: - case 285: + case 198: + case 231: + case 229: + case 232: + case 264: + case 230: + case 289: return true; - case 150: - case 149: case 151: + case 150: case 152: - case 223: - return hasSomeImportantChild(item); - case 185: + case 153: case 225: - case 184: + return hasSomeImportantChild(item); + case 186: + case 227: + case 185: return isTopLevelFunctionDeclaration(item); default: return false; @@ -58370,10 +61483,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 231: - case 261: - case 149: + case 233: + case 264: case 150: + case 151: return true; default: return hasSomeImportantChild(item); @@ -58382,7 +61495,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 223 && childKind !== 174; + return childKind !== 225 && childKind !== 175; }); } } @@ -58392,7 +61505,7 @@ var ts; return { text: getItemName(n.node), kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: ts.map(n.children, convertToTree) }; @@ -58401,7 +61514,7 @@ var ts; return { text: getItemName(n.node), kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, indent: n.indent, @@ -58437,35 +61550,41 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 230) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 232) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } return result.join("."); } function getInteriorModule(decl) { - return decl.body.kind === 230 ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 232 ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 142; + return !member.name || member.name.kind === 143; } function getNodeSpan(node) { - return node.kind === 261 + return node.kind === 264 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) - : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); + : ts.createTextSpanFromNode(node, curSourceFile); + } + function getModifiers(node) { + if (node.parent && node.parent.kind === 225) { + node = node.parent; + } + return ts.getNodeModifiers(node); } function getFunctionOrClassName(node) { if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 223) { + else if (node.parent.kind === 225) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 192 && + else if (node.parent.kind === 193 && node.parent.operatorToken.kind === 57) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 257 && node.parent.name) { + else if (node.parent.kind === 260 && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512) { @@ -58476,7 +61595,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 184 || node.kind === 185 || node.kind === 197; + return node.kind === 185 || node.kind === 186 || node.kind === 198; } var whiteSpaceRegex = /\s+/g; })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); @@ -58492,7 +61611,7 @@ var ts; if (hintSpanNode && startElement && endElement) { var span_12 = { textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), - hintSpan: ts.createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), + hintSpan: ts.createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse }; @@ -58549,7 +61668,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 185; + return ts.isFunctionBlock(node) && node.parent.kind !== 186; } var depth = 0; var maxDepth = 20; @@ -58561,26 +61680,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 204: + case 206: if (!ts.isFunctionBlock(n)) { - var parent_19 = n.parent; + var parent = n.parent; var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); - if (parent_19.kind === 209 || - parent_19.kind === 212 || - parent_19.kind === 213 || - parent_19.kind === 211 || - parent_19.kind === 208 || - parent_19.kind === 210 || - parent_19.kind === 217 || - parent_19.kind === 256) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + if (parent.kind === 211 || + parent.kind === 214 || + parent.kind === 215 || + parent.kind === 213 || + parent.kind === 210 || + parent.kind === 212 || + parent.kind === 219 || + parent.kind === 259) { + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_19.kind === 221) { - var tryStatement = parent_19; + if (parent.kind === 223) { + var tryStatement = parent; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -58591,7 +61710,7 @@ var ts; } } } - var span_14 = ts.createTextSpanFromBounds(n.getStart(), n.end); + var span_14 = ts.createTextSpanFromNode(n); elements.push({ textSpan: span_14, hintSpan: span_14, @@ -58600,23 +61719,23 @@ var ts; }); break; } - case 231: { + case 233: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 226: - case 227: + case 228: case 229: - case 176: - case 232: { + case 231: + case 177: + case 234: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 175: + case 176: var openBracket = ts.findChildOfKind(n, 20, sourceFile); var closeBracket = ts.findChildOfKind(n, 21, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -58693,10 +61812,11 @@ var ts; return totalMatch; } function getWordSpans(word) { - if (!(word in stringToWordSpans)) { - stringToWordSpans[word] = breakIntoWordSpans(word); + var spans = stringToWordSpans.get(word); + if (!spans) { + stringToWordSpans.set(word, spans = breakIntoWordSpans(word)); } - return stringToWordSpans[word]; + return spans; } function matchTextChunk(candidate, chunk, punctuationStripped) { var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); @@ -58878,7 +61998,8 @@ var ts; return str === str.toLowerCase(); } function indexOfIgnoringCase(string, value) { - for (var i = 0, n = string.length - value.length; i <= n; i++) { + var n = string.length - value.length; + for (var i = 0; i <= n; i++) { if (startsWithIgnoringCase(string, value, i)) { return i; } @@ -58886,7 +62007,7 @@ var ts; return -1; } function startsWithIgnoringCase(string, value, start) { - for (var i = 0, n = value.length; i < n; i++) { + for (var i = 0; i < value.length; i++) { var ch1 = toLowerCase(string.charCodeAt(i + start)); var ch2 = value.charCodeAt(i); if (ch1 !== ch2) { @@ -58954,7 +62075,7 @@ var ts; function breakIntoSpans(identifier, word) { var result = []; var wordStart = 0; - for (var i = 1, n = identifier.length; i < n; i++) { + for (var i = 1; i < identifier.length; i++) { var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); var currentIsDigit = isDigit(identifier.charCodeAt(i)); var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); @@ -59128,7 +62249,7 @@ var ts; else { if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59154,7 +62275,7 @@ var ts; } if (token === 17) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59168,7 +62289,7 @@ var ts; token = nextToken(); if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59194,7 +62315,7 @@ var ts; } if (token === 17) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59204,7 +62325,7 @@ var ts; } else if (token === 38) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59331,90 +62452,82 @@ var ts; var Rename; (function (Rename) { function getRenameInfo(typeChecker, defaultLibFileName, getCanonicalFileName, sourceFile, position) { - var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); + var getCanonicalDefaultLibName = ts.memoize(function () { return getCanonicalFileName(ts.normalizePath(defaultLibFileName)); }); var node = ts.getTouchingWord(sourceFile, position, true); - if (node) { - if (node.kind === 70 || - node.kind === 9 || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - ts.isThis(node)) { - var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol) { - var declarations = symbol.getDeclarations(); - if (declarations && declarations.length > 0) { - if (ts.forEach(declarations, isDefinedInLibraryFile)) { - 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 = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - if (kind) { - return { - canRename: true, - kind: kind, - displayName: displayName, - localizedErrorMessage: undefined, - fullDisplayName: typeChecker.getFullyQualifiedName(symbol), - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - else if (node.kind === 9) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (type) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } - else { - var displayName = ts.stripQuotes(type.text); - return { - canRename: true, - kind: ts.ScriptElementKind.variableElement, - displayName: displayName, - localizedErrorMessage: undefined, - fullDisplayName: displayName, - kindModifiers: ts.ScriptElementKindModifier.none, - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - } - } - 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 - }; - } + var renameInfo = node && nodeIsEligibleForRename(node) + ? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) + : undefined; + return renameInfo || getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); function isDefinedInLibraryFile(declaration) { - if (defaultLibFileName) { - var sourceFile_1 = declaration.getSourceFile(); - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_1.fileName)); - if (canonicalName === canonicalDefaultLibName) { - return true; - } + if (!defaultLibFileName) { + return false; } - return false; - } - function createTriggerSpanForNode(node, sourceFile) { - var start = node.getStart(sourceFile); - var width = node.getWidth(sourceFile); - if (node.kind === 9) { - start += 1; - width -= 2; - } - return ts.createTextSpan(start, width); + var sourceFile = declaration.getSourceFile(); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); + return canonicalName === getCanonicalDefaultLibName(); } } Rename.getRenameInfo = getRenameInfo; + function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol) { + var declarations = symbol.getDeclarations(); + if (declarations && declarations.length > 0) { + if (ts.some(declarations, isDefinedInLibraryFile)) { + return getRenameInfoError(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 = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); + return kind ? getRenameInfoSuccess(displayName, typeChecker.getFullyQualifiedName(symbol), kind, ts.SymbolDisplay.getSymbolModifiers(symbol), node, sourceFile) : undefined; + } + } + else if (node.kind === 9) { + var type = ts.getStringLiteralTypeForNode(node, typeChecker); + if (type) { + if (isDefinedInLibraryFile(node)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); + } + var displayName = ts.stripQuotes(type.text); + return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); + } + } + } + function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { + return { + canRename: true, + kind: kind, + displayName: displayName, + localizedErrorMessage: undefined, + fullDisplayName: fullDisplayName, + kindModifiers: kindModifiers, + triggerSpan: createTriggerSpanForNode(node, sourceFile) + }; + } + function getRenameInfoError(diagnostic) { + return { + canRename: false, + localizedErrorMessage: ts.getLocaleSpecificMessage(diagnostic), + displayName: undefined, + fullDisplayName: undefined, + kind: undefined, + kindModifiers: undefined, + triggerSpan: undefined + }; + } + function createTriggerSpanForNode(node, sourceFile) { + var start = node.getStart(sourceFile); + var width = node.getWidth(sourceFile); + if (node.kind === 9) { + start += 1; + width -= 2; + } + return ts.createTextSpan(start, width); + } + function nodeIsEligibleForRename(node) { + return node.kind === 70 || node.kind === 9 || + ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + ts.isThis(node); + } })(Rename = ts.Rename || (ts.Rename = {})); })(ts || (ts = {})); var ts; @@ -59422,6 +62535,13 @@ var ts; var SignatureHelp; (function (SignatureHelp) { var emptyArray = []; + var ArgumentListKind; + (function (ArgumentListKind) { + ArgumentListKind[ArgumentListKind["TypeArguments"] = 0] = "TypeArguments"; + ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; + ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; + ArgumentListKind[ArgumentListKind["JSXAttributesArguments"] = 3] = "JSXAttributesArguments"; + })(ArgumentListKind = SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); @@ -59447,14 +62567,14 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 179) { + if (argumentInfo.invocation.kind !== 180) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; var name = expression.kind === 70 ? expression - : expression.kind === 177 + : expression.kind === 178 ? expression.name : undefined; if (!name || !name.text) { @@ -59464,10 +62584,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameToDeclarations = sourceFile.getNamedDeclarations(); - var declarations = nameToDeclarations[name.text]; + var declarations = nameToDeclarations.get(name.text); if (declarations) { - for (var _b = 0, declarations_10 = declarations; _b < declarations_10.length; _b++) { - var declaration = declarations_10[_b]; + for (var _b = 0, declarations_13 = declarations; _b < declarations_13.length; _b++) { + var declaration = declarations_13[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -59483,7 +62603,7 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 179 || node.parent.kind === 180) { + if (node.parent.kind === 180 || node.parent.kind === 181) { var callExpression = node.parent; if (node.kind === 26 || node.kind === 18) { @@ -59515,23 +62635,23 @@ var ts; } return undefined; } - else if (node.kind === 12 && node.parent.kind === 181) { + else if (node.kind === 12 && node.parent.kind === 182) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0, sourceFile); } } - else if (node.kind === 13 && node.parent.parent.kind === 181) { + else if (node.kind === 13 && node.parent.parent.kind === 182) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 194); + ts.Debug.assert(templateExpression.kind === 195); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 202 && node.parent.parent.parent.kind === 181) { + else if (node.parent.kind === 204 && node.parent.parent.parent.kind === 182) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 194); + ts.Debug.assert(templateExpression.kind === 195); if (node.kind === 15 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } @@ -59539,8 +62659,20 @@ var ts; var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position); return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } + else if (node.parent && ts.isJsxOpeningLikeElement(node.parent)) { + var attributeSpanStart = node.parent.attributes.getFullStart(); + var attributeSpanEnd = ts.skipTrivia(sourceFile.text, node.parent.attributes.getEnd(), false); + return { + kind: 3, + invocation: node.parent, + argumentsSpan: ts.createTextSpan(attributeSpanStart, attributeSpanEnd - attributeSpanStart), + argumentIndex: 0, + argumentCount: 1 + }; + } return undefined; } + SignatureHelp.getImmediatelyContainingArgumentInfo = getImmediatelyContainingArgumentInfo; function getArgumentIndex(argumentsList, node) { var argumentIndex = 0; var listChildren = argumentsList.getChildren(); @@ -59595,7 +62727,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 194) { + if (template.kind === 195) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -59604,7 +62736,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 261; n = n.parent) { + for (var n = node; n.kind !== 264; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -59736,7 +62868,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 197) ? + return ts.getDeclarationOfKind(symbol, 198) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384) return ts.ScriptElementKind.enumElement; @@ -59793,7 +62925,7 @@ var ts; if (flags & 16384) return ts.ScriptElementKind.constructorImplementationElement; if (flags & 4) { - if (flags & 268435456) { + if (flags & 134217728 && symbol.checkFlags & 2) { var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); if (rootSymbolFlags & (98308 | 3)) { @@ -59810,6 +62942,9 @@ var ts; } return unionPropertyKind; } + if (location.parent && ts.isJsxAttribute(location.parent)) { + return ts.ScriptElementKind.jsxAttribute; + } return ts.ScriptElementKind.memberVariableElement; } return ts.ScriptElementKind.unknown; @@ -59836,26 +62971,29 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 177) { + if (location.parent && location.parent.kind === 178) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } - var callExpression = void 0; - if (location.kind === 179 || location.kind === 180) { - callExpression = location; + var callExpressionLike = void 0; + if (location.kind === 180 || location.kind === 181) { + callExpressionLike = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { - callExpression = location.parent; + callExpressionLike = location.parent; } - if (callExpression) { + else if (location.parent && ts.isJsxOpeningLikeElement(location.parent) && ts.isFunctionLike(symbol.valueDeclaration)) { + callExpressionLike = location.parent; + } + if (callExpressionLike) { var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures); + signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 180 || callExpression.expression.kind === 96; + var useConstructSignatures = callExpressionLike.kind === 181 || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 96); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -59879,6 +63017,7 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { + case ts.ScriptElementKind.jsxAttribute: case ts.ScriptElementKind.memberVariableElement: case ts.ScriptElementKind.variableElement: case ts.ScriptElementKind.constElement: @@ -59903,21 +63042,21 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 122 && location.parent.kind === 150)) { + (location.kind === 122 && location.parent.kind === 151)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 150 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 151 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 150) { + if (functionDeclaration.kind === 151) { symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 153 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 154 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -59926,7 +63065,7 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 197)) { + if (ts.getDeclarationOfKind(symbol, 198)) { pushTypePart(ts.ScriptElementKind.localClassElement); } else { @@ -59945,7 +63084,7 @@ var ts; } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(136)); + displayParts.push(ts.keywordPart(137)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); @@ -59966,7 +63105,7 @@ var ts; } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 230); + var declaration = ts.getDeclarationOfKind(symbol, 232); var isNamespace = declaration && declaration.name && declaration.name.kind === 70; displayParts.push(ts.keywordPart(isNamespace ? 128 : 127)); displayParts.push(ts.spacePart()); @@ -59985,25 +63124,25 @@ var ts; writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var declaration = ts.getDeclarationOfKind(symbol, 143); + var declaration = ts.getDeclarationOfKind(symbol, 144); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 154) { + if (declaration.kind === 155) { displayParts.push(ts.keywordPart(93)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 153 && declaration.name) { + else if (declaration.kind !== 154 && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } - else if (declaration.kind === 228) { + else if (declaration.kind === 230) { addInPrefix(); - displayParts.push(ts.keywordPart(136)); + displayParts.push(ts.keywordPart(137)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -60014,7 +63153,7 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 260) { + if (declaration.kind === 263) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -60026,7 +63165,7 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 233) { + if (symbol.declarations[0].kind === 235) { displayParts.push(ts.keywordPart(83)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(128)); @@ -60037,7 +63176,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 234) { + if (declaration.kind === 236) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -60072,6 +63211,7 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } if (symbolKind === ts.ScriptElementKind.memberVariableElement || + symbolKind === ts.ScriptElementKind.jsxAttribute || symbolFlags & 3 || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { @@ -60105,10 +63245,10 @@ var ts; if (!documentation) { documentation = symbol.getDocumentationComment(); if (documentation.length === 0 && symbol.flags & 4) { - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 261; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 264; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 192) { + if (!declaration.parent || declaration.parent.kind !== 193) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -60188,14 +63328,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 184) { + if (declaration.kind === 185) { return true; } - if (declaration.kind !== 223 && declaration.kind !== 225) { + if (declaration.kind !== 225 && declaration.kind !== 227) { return false; } - for (var parent_20 = declaration.parent; !ts.isFunctionBlock(parent_20); parent_20 = parent_20.parent) { - if (parent_20.kind === 261 || parent_20.kind === 231) { + for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { + if (parent.kind === 264 || parent.kind === 233) { return false; } } @@ -60230,7 +63370,7 @@ var ts; sourceFile.moduleName = transpileOptions.moduleName; } if (transpileOptions.renamedDependencies) { - sourceFile.renamedDependencies = ts.createMap(transpileOptions.renamedDependencies); + sourceFile.renamedDependencies = ts.createMapFromTemplate(transpileOptions.renamedDependencies); } var newLine = ts.getNewLineCharacter(options); var outputText; @@ -60276,10 +63416,10 @@ var ts; var commandLineOptionsStringToEnum; function fixupCompilerOptions(options, diagnostics) { commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { - return typeof o.type === "object" && !ts.forEachProperty(o.type, function (v) { return typeof v !== "number"; }); + return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_3 = function (opt) { + var _loop_5 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -60288,14 +63428,14 @@ var ts; options[opt.name] = ts.parseCustomTypeOption(opt, value, diagnostics); } else { - if (!ts.forEachProperty(opt.type, function (v) { return v === value; })) { + if (!ts.forEachEntry(opt.type, function (v) { return v === value; })) { diagnostics.push(ts.createCompilerDiagnosticForInvalidCustomType(opt)); } } }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_3(opt); + _loop_5(opt); } return options; } @@ -60307,6 +63447,15 @@ var ts; var standardScanner = ts.createScanner(5, false, 0); var jsxScanner = ts.createScanner(5, false, 1); var scanner; + var ScanAction; + (function (ScanAction) { + ScanAction[ScanAction["Scan"] = 0] = "Scan"; + ScanAction[ScanAction["RescanGreaterThanToken"] = 1] = "RescanGreaterThanToken"; + ScanAction[ScanAction["RescanSlashToken"] = 2] = "RescanSlashToken"; + ScanAction[ScanAction["RescanTemplateToken"] = 3] = "RescanTemplateToken"; + ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; + ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; + })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); scanner = sourceFile.languageVariant === 1 ? jsxScanner : standardScanner; @@ -60386,10 +63535,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { + case 252: case 250: - case 248: + case 251: case 249: - case 247: return node.kind === 70; } } @@ -60600,6 +63749,20 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + var FormattingRequestKind; + (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"; + })(FormattingRequestKind = formatting.FormattingRequestKind || (formatting.FormattingRequestKind = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -60621,6 +63784,19 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleAction; + (function (RuleAction) { + RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; + RuleAction[RuleAction["Space"] = 2] = "Space"; + RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; + RuleAction[RuleAction["Delete"] = 8] = "Delete"; + })(RuleAction = formatting.RuleAction || (formatting.RuleAction = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -60651,6 +63827,17 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleFlags; + (function (RuleFlags) { + RuleFlags[RuleFlags["None"] = 0] = "None"; + RuleFlags[RuleFlags["CanDeleteNewLines"] = 1] = "CanDeleteNewLines"; + })(RuleFlags = formatting.RuleFlags || (formatting.RuleFlags = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -60722,10 +63909,10 @@ var ts; this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromRange(0, 141, [19])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17, 81), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17, 105), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromTokens([19, 21, 25, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromTokens([21, 25, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); @@ -60736,10 +63923,10 @@ var ts; this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19, 3, 80, 101, 86, 81]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8)); this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8)); this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); @@ -60759,18 +63946,20 @@ var ts; this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([109, 75]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2)); this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([19, 80, 81, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2)); this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101, 86]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 133]), 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 134]), 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([127, 131]), 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 133, 114, 136, 138]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84, 107, 138])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 130, 134, 114, 137, 139, 126]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84, 107, 139])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(35, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); @@ -60784,7 +63973,7 @@ var ts; this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116, 70, 83, 78, 74, 114, 113, 111, 112, 124, 133, 20, 38])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116, 70, 83, 78, 74, 114, 113, 111, 112, 124, 134, 20, 38])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38, formatting.Shared.TokenRange.FromTokens([70, 18])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); @@ -60797,6 +63986,7 @@ var ts; this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40, 28), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, @@ -60825,7 +64015,7 @@ var ts; this.NoSpaceBetweenTagAndTemplateString, this.SpaceBeforeJsxAttribute, this.SpaceBeforeSlashInJsxOpeningElement, this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement, this.NoSpaceBeforeEqualInJsxAttribute, this.NoSpaceAfterEqualInJsxAttribute, - this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, + this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, this.SpaceBeforeArrow, this.SpaceAfterArrow, @@ -60840,6 +64030,7 @@ var ts; this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, + this.NoSpaceBeforeNonNullAssertionOperator ]; this.LowPriorityCommonRules = [ this.NoSpaceBeforeSemicolon, @@ -60848,7 +64039,6 @@ var ts; this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, - this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2)); @@ -60889,43 +64079,44 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_49 in o) { - if (o[name_49] === rule) { - return name_49; + for (var name in o) { + if (o[name] === rule) { + return name; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 211; + return context.contextNode.kind === 213; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 192: case 193: - case 200: - case 243: - case 239: - case 156: - case 164: + case 194: + case 201: + case 245: + case 241: + case 157: case 165: + case 166: return true; - case 174: - case 228: - case 234: - case 223: - case 144: - case 260: + case 175: + case 230: + case 236: + case 225: + case 145: + case 263: + case 148: case 147: - case 146: return context.currentTokenSpan.kind === 57 || context.nextTokenSpan.kind === 57; - case 212: + case 214: + case 144: return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; - case 213: - return context.currentTokenSpan.kind === 140 || context.nextTokenSpan.kind === 140; + case 215: + return context.currentTokenSpan.kind === 141 || context.nextTokenSpan.kind === 141; } return false; }; @@ -60933,11 +64124,14 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 193; + return context.contextNode.kind === 194; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; + Rules.IsBraceWrappedContext = function (context) { + return context.contextNode.kind === 173 || Rules.IsSingleLineBlockContext(context); + }; Rules.IsBeforeMultilineBlockContext = function (context) { return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); }; @@ -60958,90 +64152,96 @@ var ts; return true; } switch (node.kind) { - case 204: - case 232: - case 176: - case 231: + case 206: + case 234: + case 177: + case 233: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 225: + case 227: + case 150: case 149: - case 148: - case 151: case 152: case 153: - case 184: - case 150: + case 154: case 185: - case 227: + case 151: + case 186: + case 229: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 225 || context.contextNode.kind === 184; + return context.contextNode.kind === 227 || context.contextNode.kind === 185; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 226: - case 197: - case 227: + case 228: + case 198: case 229: - case 161: - case 230: - case 241: - case 242: - case 235: - case 238: + case 231: + case 162: + case 232: + case 243: + case 244: + case 237: + case 240: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 226: - case 230: - case 229: - case 204: - case 256: + case 228: + case 232: case 231: - case 218: + case 259: + case 233: + case 220: return true; + case 206: { + var blockParent = context.currentTokenParent.parent; + if (blockParent.kind !== 186 && + blockParent.kind !== 185) { + return true; + } + } } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 208: - case 218: - case 211: - case 212: - case 213: case 210: - case 221: - case 209: - case 217: - case 256: + case 220: + case 213: + case 214: + case 215: + case 212: + case 223: + case 211: + case 219: + case 259: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 176; + return context.contextNode.kind === 177; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 179; + return context.contextNode.kind === 180; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 180; + return context.contextNode.kind === 181; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -61053,25 +64253,25 @@ var ts; return context.nextTokenSpan.kind !== 21; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 185; + return context.contextNode.kind === 186; }; Rules.IsNonJsxSameLineTokenContext = function (context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 246; + return context.contextNode.kind !== 248; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 252; + return context.contextNode.kind === 255; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 250; + return context.nextTokenParent.kind === 252; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 250; + return context.contextNode.kind === 252; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 247; + return context.contextNode.kind === 249; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -61086,41 +64286,42 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 145; + return node.kind === 146; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 224 && + return context.currentTokenParent.kind === 226 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 230; + return context.contextNode.kind === 232; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 161; + return context.contextNode.kind === 162; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 26 && token.kind !== 28) { return false; } switch (parent.kind) { - case 157: - case 182: - case 226: - case 197: + case 158: + case 183: + case 230: + case 228: + case 198: + case 229: case 227: - case 225: - case 184: case 185: + case 186: + case 150: case 149: - case 148: - case 153: case 154: - case 179: + case 155: case 180: - case 199: + case 181: + case 200: return true; default: return false; @@ -61131,13 +64332,16 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 182; + return context.contextNode.kind === 183; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 188; + return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 189; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 195 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 196 && context.contextNode.expression !== undefined; + }; + Rules.IsNonNullAssertionContext = function (context) { + return context.contextNode.kind === 202; }; return Rules; }()); @@ -61159,7 +64363,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 140 + 1; + this.mapRowLength = 141 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -61172,7 +64376,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - ts.Debug.assert(row <= 140 && column <= 140, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 141 && column <= 141, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -61336,7 +64540,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 140; token++) { + for (var token = 0; token <= 141; token++) { result.push(token); } return result; @@ -61380,9 +64584,9 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(71, 140); + TokenRange.Keywords = TokenRange.FromRange(71, 141); TokenRange.BinaryOperators = TokenRange.FromRange(26, 69); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91, 92, 140, 117, 125]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91, 92, 141, 117, 125]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42, 43, 51, 50]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 70, 18, 20, 16, 98, 93]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); @@ -61390,7 +64594,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70, 19, 21, 93]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([70, 132, 134, 121, 135, 104, 118]); + TokenRange.TypeNames = TokenRange.FromTokens([70, 132, 135, 121, 136, 104, 118]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -61423,6 +64627,12 @@ var ts; }; RulesProvider.prototype.createActiveRules = function (options) { var rules = this.globalRules.HighPriorityCommonRules.slice(0); + if (options.insertSpaceAfterConstructor) { + rules.push(this.globalRules.SpaceAfterConstructor); + } + else { + rules.push(this.globalRules.NoSpaceAfterConstructor); + } if (options.insertSpaceAfterCommaDelimiter) { rules.push(this.globalRules.SpaceAfterComma); } @@ -61501,6 +64711,12 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); rules.push(this.globalRules.NoSpaceAfterBinaryOperator); } + if (options.insertSpaceBeforeFunctionParenthesis) { + rules.push(this.globalRules.SpaceBeforeOpenParenInFuncDecl); + } + else { + rules.push(this.globalRules.NoSpaceBeforeOpenParenInFuncDecl); + } if (options.placeOpenBraceOnNewLineForControlBlocks) { rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); } @@ -61526,6 +64742,10 @@ var ts; (function (ts) { var formatting; (function (formatting) { + var Constants; + (function (Constants) { + Constants[Constants["Unknown"] = -1] = "Unknown"; + })(Constants || (Constants = {})); function formatOnEnter(position, sourceFile, rulesProvider, options) { var line = sourceFile.getLineAndCharacterOfPosition(position).line; if (line === 0) { @@ -61598,17 +64818,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 226: - case 227: + case 228: + case 229: return ts.rangeContainsRange(parent.members, node); - case 230: + case 232: var body = parent.body; - return body && body.kind === 231 && ts.rangeContainsRange(body.statements, node); - case 261: - case 204: - case 231: + return body && body.kind === 233 && ts.rangeContainsRange(body.statements, node); + case 264: + case 206: + case 233: return ts.rangeContainsRange(parent.statements, node); - case 256: + case 259: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -61764,18 +64984,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 226: return 74; - case 227: return 108; - case 225: return 88; - case 229: return 229; - case 151: return 124; - case 152: return 133; - case 149: + case 228: return 74; + case 229: return 108; + case 227: return 88; + case 231: return 231; + case 152: return 124; + case 153: return 134; + case 150: if (node.asteriskToken) { return 38; } - case 147: - case 144: + case 148: + case 145: return node.name.kind; } } @@ -61799,17 +65019,30 @@ var ts; switch (kind) { case 16: case 17: - case 20: - case 21: case 18: case 19: case 81: case 105: case 56: return indentation; - default: - return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; + case 40: + case 28: { + if (container.kind === 250 || + container.kind === 251 || + container.kind === 249) { + return indentation; + } + break; + } + case 20: + case 21: { + if (container.kind !== 171) { + return indentation; + } + break; + } } + return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; }, getIndentation: function () { return indentation; }, getDelta: function (child) { return getEffectiveDelta(delta, child); }, @@ -61850,7 +65083,7 @@ var ts; if (tokenInfo.token.end > node.end) { break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); @@ -61880,7 +65113,7 @@ var ts; if (tokenInfo.token.end > childStartPos) { break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, node); } if (!formattingScanner.isOnToken()) { return inheritedIndentation; @@ -61891,11 +65124,11 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 145 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 146 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 175 && inheritedIndentation === -1) { + if (isFirstListItem && parent.kind === 176 && inheritedIndentation === -1) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -61915,10 +65148,10 @@ var ts; 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); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } else { - consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); } } } @@ -61931,7 +65164,7 @@ var ts; if (formattingScanner.isOnToken()) { var tokenInfo = formattingScanner.readTokenInfo(parent); if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } } } @@ -62121,7 +65354,7 @@ var ts; startLine++; } var delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; i++, startLine++) { + for (var i = startIndex; i < parts.length; i++, startLine++) { var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart @@ -62211,12 +65444,12 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 150: - case 225: - case 184: - case 149: - case 148: + case 151: + case 227: case 185: + case 150: + case 149: + case 186: if (node.typeParameters === list) { return 26; } @@ -62224,8 +65457,8 @@ var ts; return 18; } break; - case 179: case 180: + case 181: if (node.typeArguments === list) { return 26; } @@ -62233,7 +65466,7 @@ var ts; return 18; } break; - case 157: + case 158: if (node.typeArguments === list) { return 26; } @@ -62306,6 +65539,10 @@ var ts; (function (formatting) { var SmartIndenter; (function (SmartIndenter) { + var Value; + (function (Value) { + Value[Value["Unknown"] = -1] = "Unknown"; + })(Value || (Value = {})); function getIndentation(position, sourceFile, options) { if (position > sourceFile.text.length) { return getBaseIndentation(options); @@ -62334,7 +65571,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 25 && precedingToken.parent.kind !== 192) { + if (precedingToken.kind === 25 && precedingToken.parent.kind !== 193) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -62436,7 +65673,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 261 || !parentAndChildShareLine); + (parent.kind === 264 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -62460,7 +65697,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 208 && parent.elseStatement === child) { + if (parent.kind === 210 && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -62472,23 +65709,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 157: + case 158: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 176: + case 177: return node.parent.properties; - case 175: + case 176: return node.parent.elements; - case 225: - case 184: + case 227: case 185: + case 186: + case 150: case 149: - case 148: - case 153: - case 154: { + case 154: + case 155: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -62499,8 +65736,8 @@ var ts; } break; } - case 180: - case 179: { + case 181: + case 180: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -62528,8 +65765,8 @@ var ts; if (node.kind === 19) { return -1; } - if (node.parent && (node.parent.kind === 179 || - node.parent.kind === 180) && + if (node.parent && (node.parent.kind === 180 || + node.parent.kind === 181) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -62547,10 +65784,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 179: case 180: - case 177: + case 181: case 178: + case 179: node = node.expression; break; default: @@ -62604,48 +65841,49 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 207: - case 226: - case 197: - case 227: - case 229: + case 209: case 228: - case 175: - case 204: + case 198: + case 229: case 231: + case 230: case 176: - case 161: - case 163: - case 232: - case 254: - case 253: - case 183: + case 206: + case 233: case 177: - case 179: + case 162: + case 171: + case 164: + case 234: + case 257: + case 256: + case 184: + case 178: case 180: - case 205: - case 223: - case 240: - case 216: - case 193: - case 173: - case 172: - case 248: - case 247: - case 252: - case 148: - case 153: - case 154: - case 144: - case 158: - case 159: - case 166: case 181: - case 189: + case 207: + case 225: case 242: - case 238: - case 243: - case 239: + case 218: + case 194: + case 174: + case 173: + case 250: + case 249: + case 255: + case 149: + case 154: + case 155: + case 145: + case 159: + case 160: + case 167: + case 182: + case 190: + case 244: + case 240: + case 245: + case 241: return true; } return false; @@ -62653,27 +65891,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0; switch (parent.kind) { - case 209: - case 210: - case 212: - case 213: case 211: - case 208: - case 225: - case 184: - case 149: + case 212: + case 214: + case 215: + case 213: + case 210: + case 227: case 185: case 150: + case 186: case 151: case 152: - return childKind !== 204; - case 241: - return childKind !== 242; - case 235: - return childKind !== 236 || - (child.namedBindings && child.namedBindings.kind !== 238); - case 246: - return childKind !== 249; + case 153: + return childKind !== 206; + case 243: + return childKind !== 244; + case 237: + return childKind !== 238 || + (child.namedBindings && child.namedBindings.kind !== 240); + case 248: + return childKind !== 251; } return indentByDefault; } @@ -62689,7 +65927,7 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var codeFixes = ts.createMap(); + var codeFixes = []; function registerCodeFix(action) { ts.forEach(action.errorCodes, function (error) { var fixes = codeFixes[error]; @@ -62723,24 +65961,120 @@ var ts; (function (ts) { var codefix; (function (codefix) { - function getOpenBraceEnd(constructor, sourceFile) { - return constructor.body.getFirstToken(sourceFile).getEnd(); - } codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 122) { - return undefined; - } - var newPosition = getOpenBraceEnd(token.parent, sourceFile); - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] - }]; - } + errorCodes: [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code], + getCodeActions: getActionForClassLikeIncorrectImplementsInterface }); + function getActionForClassLikeIncorrectImplementsInterface(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + var classDecl = ts.getContainingClass(token); + if (!classDecl) { + return undefined; + } + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDecl); + var hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, 1); + var hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, 0); + var result = []; + for (var _i = 0, implementedTypeNodes_2 = implementedTypeNodes; _i < implementedTypeNodes_2.length; _i++) { + var implementedTypeNode = implementedTypeNodes_2[_i]; + var implementedType = checker.getTypeFromTypeNode(implementedTypeNode); + var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); + var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8); }); + var insertion = getMissingIndexSignatureInsertion(implementedType, 1, classDecl, hasNumericIndexSignature); + insertion += getMissingIndexSignatureInsertion(implementedType, 0, classDecl, hasStringIndexSignature); + insertion += codefix.getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); + var message = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); + if (insertion) { + pushAction(result, insertion, message); + } + } + return result; + function getMissingIndexSignatureInsertion(type, kind, enclosingDeclaration, hasIndexSigOfKind) { + if (!hasIndexSigOfKind) { + var IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); + if (IndexInfoOfKind) { + var writer = ts.getSingleLineStringWriter(); + checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); + var result_6 = writer.string(); + ts.releaseStringWriter(writer); + return result_6; + } + } + return ""; + } + function pushAction(result, insertion, description) { + var newAction = { + description: description, + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }; + result.push(newAction); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + function getActionForClassLikeMissingAbstractMember(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + if (ts.isClassLike(token.parent)) { + var classDecl = token.parent; + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + var extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); + var abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); + var insertion = codefix.getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); + if (insertion.length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_inherited_abstract_class), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }]; + } + } + return undefined; + } + function symbolPointsToNonPrivateAndAbstractMember(symbol) { + var decls = symbol.getDeclarations(); + ts.Debug.assert(!!(decls && decls.length > 0)); + var flags = ts.getModifierFlags(decls[0]); + return !(flags & 8) && !!(flags & 128); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { codefix.registerCodeFix({ errorCodes: [ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], getCodeActions: function (context) { @@ -62754,7 +66088,7 @@ var ts; if (!superCall) { return undefined; } - if (superCall.expression && superCall.expression.kind == 179) { + if (superCall.expression && superCall.expression.kind == 180) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -62762,7 +66096,7 @@ var ts; } } } - var newPosition = getOpenBraceEnd(constructor, sourceFile); + var newPosition = ts.getOpenBraceEnd(constructor, sourceFile); var changes = [{ fileName: sourceFile.fileName, textChanges: [{ newText: superCall.getText(sourceFile), @@ -62778,7 +66112,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 207 && ts.isSuperCall(n.expression)) { + if (n.kind === 209 && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -62791,6 +66125,257 @@ var ts; })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 122) { + return undefined; + } + var newPosition = ts.getOpenBraceEnd(token.parent, sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var classDeclNode = ts.getContainingClass(token); + if (!(token.kind === 70 && ts.isClassLike(classDeclNode))) { + return undefined; + } + var heritageClauses = classDeclNode.heritageClauses; + if (!(heritageClauses && heritageClauses.length > 0)) { + return undefined; + } + var extendsToken = heritageClauses[0].getFirstToken(); + if (!(extendsToken && extendsToken.kind === 84)) { + return undefined; + } + var changeStart = extendsToken.getStart(sourceFile); + var changeEnd = extendsToken.getEnd(); + var textChanges = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + for (var i = 1; i < heritageClauses.length; i++) { + var keywordToken = heritageClauses[i].getFirstToken(); + if (keywordToken) { + changeStart = keywordToken.getStart(sourceFile); + changeEnd = keywordToken.getEnd(); + textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + } + } + var result = [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Change_extends_to_implements), + changes: [{ + fileName: sourceFile.fileName, + textChanges: textChanges + }] + }]; + return result; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + var start = token.getStart(sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_this_to_unresolved_variable), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "this.", span: { start: start, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ + ts.Diagnostics._0_is_declared_but_never_used.code, + ts.Diagnostics.Property_0_is_declared_but_never_used.code + ], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + if (token.kind === 20) { + token = ts.getTokenAtPosition(sourceFile, start + 1); + } + switch (token.kind) { + case 70: + switch (token.parent.kind) { + case 225: + switch (token.parent.parent.parent.kind) { + case 213: + var forStatement = token.parent.parent.parent; + var forInitializer = forStatement.initializer; + if (forInitializer.declarations.length === 1) { + return createCodeFixToRemoveNode(forInitializer); + } + else { + return removeSingleItem(forInitializer.declarations, token); + } + case 215: + var forOfStatement = token.parent.parent.parent; + if (forOfStatement.initializer.kind === 226) { + var forOfInitializer = forOfStatement.initializer; + return createCodeFix("{}", forOfInitializer.declarations[0].getStart(), forOfInitializer.declarations[0].getWidth()); + } + break; + case 214: + return undefined; + case 259: + var catchClause = token.parent.parent; + var parameter = catchClause.variableDeclaration.getChildren()[0]; + return createCodeFixToRemoveNode(parameter); + default: + var variableStatement = token.parent.parent.parent; + if (variableStatement.declarationList.declarations.length === 1) { + return createCodeFixToRemoveNode(variableStatement); + } + else { + var declarations = variableStatement.declarationList.declarations; + return removeSingleItem(declarations, token); + } + } + case 144: + var typeParameters = token.parent.parent.typeParameters; + if (typeParameters.length === 1) { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + } + else { + return removeSingleItem(typeParameters, token); + } + case 145: + var functionDeclaration = token.parent.parent; + if (functionDeclaration.parameters.length === 1) { + return createCodeFixToRemoveNode(token.parent); + } + else { + return removeSingleItem(functionDeclaration.parameters, token); + } + case 236: + var importEquals = findImportDeclaration(token); + return createCodeFixToRemoveNode(importEquals); + case 241: + var namedImports = token.parent.parent; + if (namedImports.elements.length === 1) { + var importSpec = findImportDeclaration(token); + return createCodeFixToRemoveNode(importSpec); + } + else { + return removeSingleItem(namedImports.elements, token); + } + case 238: + var importClause = token.parent; + if (!importClause.namedBindings) { + var importDecl = findImportDeclaration(importClause); + return createCodeFixToRemoveNode(importDecl); + } + else { + var start_4 = importClause.name.getStart(); + var end = findFirstNonSpaceCharPosStarting(importClause.name.end); + if (sourceFile.text.charCodeAt(end) === 44) { + end = findFirstNonSpaceCharPosStarting(end + 1); + } + return createCodeFix("", start_4, end - start_4); + } + case 239: + var namespaceImport = token.parent; + if (namespaceImport.name == token && !namespaceImport.parent.name) { + var importDecl = findImportDeclaration(namespaceImport); + return createCodeFixToRemoveNode(importDecl); + } + else { + var start_5 = namespaceImport.parent.name.end; + return createCodeFix("", start_5, namespaceImport.parent.namedBindings.end - start_5); + } + } + break; + case 148: + case 239: + return createCodeFixToRemoveNode(token.parent); + } + if (ts.isDeclarationName(token)) { + return createCodeFixToRemoveNode(token.parent); + } + else if (ts.isLiteralComputedPropertyDeclarationName(token)) { + return createCodeFixToRemoveNode(token.parent.parent); + } + else { + return undefined; + } + function findImportDeclaration(token) { + var importDecl = token; + while (importDecl.kind != 237 && importDecl.parent) { + importDecl = importDecl.parent; + } + return importDecl; + } + function createCodeFixToRemoveNode(node) { + var end = node.getEnd(); + var endCharCode = sourceFile.text.charCodeAt(end); + var afterEndCharCode = sourceFile.text.charCodeAt(end + 1); + if (ts.isLineBreak(endCharCode)) { + end += 1; + } + if (ts.isLineBreak(afterEndCharCode) && endCharCode !== afterEndCharCode) { + end += 1; + } + var start = node.getStart(); + return createCodeFix("", start, end - start); + } + function findFirstNonSpaceCharPosStarting(start) { + while (ts.isWhiteSpace(sourceFile.text.charCodeAt(start))) { + start += 1; + } + return start; + } + function createCodeFix(newText, start, length) { + return [{ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ newText: newText, span: { start: start, length: length } }] + }] + }]; + } + function removeSingleItem(elements, token) { + if (elements[0] === token.parent) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + } + else { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + } + } + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var codefix; (function (codefix) { @@ -62802,18 +66387,19 @@ var ts; })(ModuleSpecifierComparison || (ModuleSpecifierComparison = {})); var ImportCodeActionMap = (function () { function ImportCodeActionMap() { - this.symbolIdToActionMap = ts.createMap(); + this.symbolIdToActionMap = []; } ImportCodeActionMap.prototype.addAction = function (symbolId, newAction) { if (!newAction) { return; } - if (!this.symbolIdToActionMap[symbolId]) { + var actions = this.symbolIdToActionMap[symbolId]; + if (!actions) { this.symbolIdToActionMap[symbolId] = [newAction]; return; } if (newAction.kind === "CodeChange") { - this.symbolIdToActionMap[symbolId].push(newAction); + actions.push(newAction); return; } var updatedNewImports = []; @@ -62846,8 +66432,8 @@ var ts; }; ImportCodeActionMap.prototype.getAllActions = function () { var result = []; - for (var symbolId in this.symbolIdToActionMap) { - result = ts.concatenate(result, this.symbolIdToActionMap[symbolId]); + for (var key in this.symbolIdToActionMap) { + result = ts.concatenate(result, this.symbolIdToActionMap[key]); } return result; }; @@ -62876,7 +66462,11 @@ var ts; return ImportCodeActionMap; }()); codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Cannot_find_name_0.code], + errorCodes: [ + ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics.Cannot_find_namespace_0.code, + ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ], getCodeActions: function (context) { var sourceFile = context.sourceFile; var checker = context.program.getTypeChecker(); @@ -62885,8 +66475,13 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, context.span.start); var name = token.getText(); var symbolIdActionMap = new ImportCodeActionMap(); - var cachedImportDeclarations = ts.createMap(); + var cachedImportDeclarations = []; var cachedNewImportInsertPosition; + var currentTokenMeaning = ts.getMeaningFromLocation(token); + if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { + var symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); + return getCodeActionForImport(symbol, false, true); + } var allPotentialModules = checker.getAmbientModules(); for (var _i = 0, allSourceFiles_1 = allSourceFiles; _i < allSourceFiles_1.length; _i++) { var otherSourceFile = allSourceFiles_1[_i]; @@ -62894,7 +66489,6 @@ var ts; allPotentialModules.push(otherSourceFile.symbol); } } - var currentTokenMeaning = ts.getMeaningFromLocation(token); for (var _a = 0, allPotentialModules_1 = allPotentialModules; _a < allPotentialModules_1.length; _a++) { var moduleSymbol = allPotentialModules_1[_a]; context.cancellationToken.throwIfCancellationRequested(); @@ -62915,8 +66509,9 @@ var ts; return symbolIdActionMap.getAllActions(); function getImportDeclarations(moduleSymbol) { var moduleSymbolId = getUniqueSymbolId(moduleSymbol); - if (cachedImportDeclarations[moduleSymbolId]) { - return cachedImportDeclarations[moduleSymbolId]; + var cached = cachedImportDeclarations[moduleSymbolId]; + if (cached) { + return cached; } var existingDeclarations = []; for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { @@ -62931,10 +66526,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 235) { + if (node.kind === 237) { return node; } - if (node.kind === 234) { + if (node.kind === 236) { return node; } node = node.parent; @@ -62952,7 +66547,7 @@ var ts; var declarations = symbol.getDeclarations(); return declarations ? ts.some(symbol.declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }) : false; } - function getCodeActionForImport(moduleSymbol, isDefault) { + function getCodeActionForImport(moduleSymbol, isDefault, isNamespaceImport) { var existingDeclarations = getImportDeclarations(moduleSymbol); if (existingDeclarations.length > 0) { return getCodeActionsForExistingImport(existingDeclarations); @@ -62965,11 +66560,11 @@ var ts; var namespaceImportDeclaration; var namedImportDeclaration; var existingModuleSpecifier; - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; - if (declaration.kind === 235) { + for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { + var declaration = declarations_14[_i]; + if (declaration.kind === 237) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 237) { + if (namedBindings && namedBindings.kind === 239) { namespaceImportDeclaration = declaration; } else { @@ -62985,7 +66580,7 @@ var ts; if (namespaceImportDeclaration) { actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration)); } - if (namedImportDeclaration && namedImportDeclaration.importClause && + if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause && (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { var textChange = getTextChangeForImportClause(namedImportDeclaration.importClause); var moduleSpecifierWithoutQuotes = ts.stripQuotes(namedImportDeclaration.moduleSpecifier.getText()); @@ -62996,7 +66591,7 @@ var ts; } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 245) { + if (declaration.moduleReference && declaration.moduleReference.kind === 247) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); @@ -63029,7 +66624,7 @@ var ts; } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 235) { + if (declaration.kind === 237) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { @@ -63055,24 +66650,26 @@ var ts; var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); var importStatementText = isDefault ? "import " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" - : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; + : isNamespaceImport + ? "import * as " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" + : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; var newText = cachedNewImportInsertPosition === sourceFile.getStart() ? importStatementText + ";" + context.newLineCharacter + context.newLineCharacter : "" + context.newLineCharacter + importStatementText + ";"; return createCodeAction(ts.Diagnostics.Import_0_from_1, [name, "\"" + moduleSpecifierWithoutQuotes + "\""], newText, { start: cachedNewImportInsertPosition, length: 0 }, sourceFile.fileName, "NewImport", moduleSpecifierWithoutQuotes); function getModuleSpecifierForNewImport() { - var fileName = sourceFile.path; - var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().path; + var fileName = sourceFile.fileName; + var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; var sourceDirectory = ts.getDirectoryPath(fileName); var options = context.program.getCompilerOptions(); return tryGetModuleNameFromAmbientModule() || - tryGetModuleNameFromBaseUrl() || - tryGetModuleNameFromRootDirs() || tryGetModuleNameFromTypeRoots() || tryGetModuleNameAsNodeModule() || + tryGetModuleNameFromBaseUrl() || + tryGetModuleNameFromRootDirs() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 261) { + if (moduleSymbol.valueDeclaration.kind !== 264) { return moduleSymbol.name; } } @@ -63080,11 +66677,11 @@ var ts; if (!options.baseUrl) { return undefined; } - var normalizedBaseUrl = ts.toPath(options.baseUrl, ts.getDirectoryPath(options.baseUrl), getCanonicalFileName); - var relativeName = tryRemoveParentDirectoryName(moduleFileName, normalizedBaseUrl); + var relativeName = getRelativePathIfInDirectory(moduleFileName, options.baseUrl); if (!relativeName) { return undefined; } + var relativeNameWithIndex = ts.removeFileExtension(relativeName); relativeName = removeExtensionAndIndexPostFix(relativeName); if (options.paths) { for (var key in options.paths) { @@ -63104,7 +66701,7 @@ var ts; return key.replace("\*", matchedStar); } } - else if (pattern === relativeName) { + else if (pattern === relativeName || pattern === relativeNameWithIndex) { return key; } } @@ -63114,9 +66711,8 @@ var ts; } function tryGetModuleNameFromRootDirs() { if (options.rootDirs) { - var normalizedRootDirs = ts.map(options.rootDirs, function (rootDir) { return ts.toPath(rootDir, undefined, getCanonicalFileName); }); - var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, normalizedRootDirs); - var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, normalizedRootDirs); + var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, options.rootDirs); + var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, options.rootDirs); if (normalizedTargetPath !== undefined) { var relativePath = normalizedSourcePath !== undefined ? getRelativePath(normalizedTargetPath, normalizedSourcePath) : normalizedTargetPath; return ts.removeFileExtension(relativePath); @@ -63178,7 +66774,7 @@ var ts; function getPathRelativeToRootDirs(path, rootDirs) { for (var _i = 0, rootDirs_2 = rootDirs; _i < rootDirs_2.length; _i++) { var rootDir = rootDirs_2[_i]; - var relativeName = tryRemoveParentDirectoryName(path, rootDir); + var relativeName = getRelativePathIfInDirectory(path, rootDir); if (relativeName !== undefined) { return relativeName; } @@ -63192,19 +66788,14 @@ var ts; } return fileName; } + function getRelativePathIfInDirectory(path, directoryPath) { + var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); + return ts.isRootedDiskPath(relativePath) || ts.startsWith(relativePath, "..") ? undefined : relativePath; + } function getRelativePath(path, directoryPath) { var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); return ts.moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath; } - function tryRemoveParentDirectoryName(path, parentDirectory) { - var index = path.indexOf(parentDirectory); - if (index === 0) { - return ts.endsWith(parentDirectory, ts.directorySeparator) - ? path.substring(parentDirectory.length) - : path.substring(parentDirectory.length + 1); - } - return undefined; - } } } function createCodeAction(description, diagnosticArgs, newText, span, fileName, kind, moduleSpecifier) { @@ -63223,151 +66814,127 @@ var ts; (function (ts) { var codefix; (function (codefix) { - codefix.registerCodeFix({ - errorCodes: [ - ts.Diagnostics._0_is_declared_but_never_used.code, - ts.Diagnostics.Property_0_is_declared_but_never_used.code - ], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var start = context.span.start; - var token = ts.getTokenAtPosition(sourceFile, start); - if (token.kind === 20) { - token = ts.getTokenAtPosition(sourceFile, start + 1); - } - switch (token.kind) { - case 70: - switch (token.parent.kind) { - case 223: - switch (token.parent.parent.parent.kind) { - case 211: - var forStatement = token.parent.parent.parent; - var forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); - } - else { - return removeSingleItem(forInitializer.declarations, token); - } - case 213: - var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 224) { - var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); - } - break; - case 212: - return undefined; - case 256: - var catchClause = token.parent.parent; - var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFix("", parameter.pos, parameter.end - parameter.pos); - default: - var variableStatement = token.parent.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); - } - else { - var declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); - } - } - case 143: - var typeParameters = token.parent.parent.typeParameters; - if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); - } - else { - return removeSingleItem(typeParameters, token); - } - case 144: - var functionDeclaration = token.parent.parent; - if (functionDeclaration.parameters.length === 1) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else { - return removeSingleItem(functionDeclaration.parameters, token); - } - case 234: - var importEquals = findImportDeclaration(token); - return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); - case 239: - var namedImports = token.parent.parent; - if (namedImports.elements.length === 1) { - var importSpec = findImportDeclaration(token); - return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); - } - else { - return removeSingleItem(namedImports.elements, token); - } - case 236: - var importClause = token.parent; - if (!importClause.namedBindings) { - var importDecl = findImportDeclaration(importClause); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); - } - case 237: - var namespaceImport = token.parent; - if (namespaceImport.name == token && !namespaceImport.parent.name) { - var importDecl = findImportDeclaration(namespaceImport); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - var start_4 = namespaceImport.parent.name.end; - return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); - } - } - break; - case 147: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - case 237: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - if (ts.isDeclarationName(token)) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); - } - else { - return undefined; - } - function findImportDeclaration(token) { - var importDecl = token; - while (importDecl.kind != 235 && importDecl.parent) { - importDecl = importDecl.parent; + function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { + var classMembers = classDeclaration.symbol.members; + var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !classMembers.has(symbol.getName()); }); + var insertion = ""; + for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { + var symbol = missingMembers_1[_i]; + insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + } + return insertion; + } + codefix.getMissingMembersInsertion = getMissingMembersInsertion; + function getInsertionForMemberSymbol(symbol, enclosingDeclaration, checker, newlineChar) { + var type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + var declarations = symbol.getDeclarations(); + if (!(declarations && declarations.length)) { + return ""; + } + var declaration = declarations[0]; + var name = declaration.name ? declaration.name.getText() : undefined; + var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); + switch (declaration.kind) { + case 152: + case 153: + case 147: + case 148: + var typeString = checker.typeToString(type, enclosingDeclaration, 0); + return "" + visibility + name + ": " + typeString + ";" + newlineChar; + case 149: + case 150: + var signatures = checker.getSignaturesOfType(type, 0); + if (!(signatures && signatures.length > 0)) { + return ""; } - return importDecl; - } - function createCodeFix(newText, start, length) { - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText: newText, span: { start: start, length: length } }] - }] - }]; - } - function removeSingleItem(elements, token) { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + if (declarations.length === 1) { + ts.Debug.assert(signatures.length === 1); + var sigString_1 = checker.signatureToString(signatures[0], enclosingDeclaration, 2048, 0); + return "" + visibility + name + sigString_1 + getMethodBodyStub(newlineChar); + } + var result = ""; + for (var i = 0; i < signatures.length; i++) { + var sigString_2 = checker.signatureToString(signatures[i], enclosingDeclaration, 2048, 0); + result += "" + visibility + name + sigString_2 + ";" + newlineChar; + } + var bodySig = undefined; + if (declarations.length > signatures.length) { + bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); } else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + ts.Debug.assert(declarations.length === signatures.length); + bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); } + var sigString = checker.signatureToString(bodySig, enclosingDeclaration, 2048, 0); + result += "" + visibility + name + sigString + getMethodBodyStub(newlineChar); + return result; + default: + return ""; + } + } + function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { + var newSignatureDeclaration = ts.createNode(154); + newSignatureDeclaration.parent = enclosingDeclaration; + newSignatureDeclaration.name = signatures[0].getDeclaration().name; + var maxNonRestArgs = -1; + var maxArgsIndex = 0; + var minArgumentCount = signatures[0].minArgumentCount; + var hasRestParameter = false; + for (var i = 0; i < signatures.length; i++) { + var sig = signatures[i]; + minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); + hasRestParameter = hasRestParameter || sig.hasRestParameter; + var nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); + if (nonRestLength > maxNonRestArgs) { + maxNonRestArgs = nonRestLength; + maxArgsIndex = i; } } - }); + var maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(function (symbol) { return symbol.getName(); }); + var optionalToken = ts.createToken(54); + newSignatureDeclaration.parameters = ts.createNodeArray(); + for (var i = 0; i < maxNonRestArgs; i++) { + var newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); + newSignatureDeclaration.parameters.push(newParameter); + } + if (hasRestParameter) { + var restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); + restParameter.dotDotDotToken = ts.createToken(23); + newSignatureDeclaration.parameters.push(restParameter); + } + return checker.getSignatureFromDeclaration(newSignatureDeclaration); + function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { + var newParameter = ts.createNode(145); + newParameter.symbol = new SymbolConstructor(1, maxArgsParameterSymbolNames[index] || "rest"); + newParameter.symbol.valueDeclaration = newParameter; + newParameter.symbol.declarations = [newParameter]; + newParameter.parent = enclosingSignatureDeclaration; + if (index >= minArgCount) { + newParameter.questionToken = optionalToken; + } + return newParameter; + } + } + function getMethodBodyStub(newLineChar) { + return " {" + newLineChar + "throw new Error('Method not implemented.');" + newLineChar + "}" + newLineChar; + } + function getVisibilityPrefix(flags) { + if (flags & 4) { + return "public "; + } + else if (flags & 16) { + return "protected "; + } + return ""; + } + var SymbolConstructor = ts.objectAllocator.getSymbolConstructor(); })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; (function (ts) { ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 141 ? new NodeObject(kind, pos, end) : + var node = kind >= 142 ? new NodeObject(kind, pos, end) : kind === 70 ? new IdentifierObject(70, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; @@ -63425,7 +66992,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(292, nodes.pos, nodes.end, this); + var list = createNode(296, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -63444,11 +67011,11 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 141) { + if (this.kind >= 142) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 278 && this.kind <= 291; + var useJSDocScanner_1 = this.kind >= 282 && this.kind <= 295; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -63501,8 +67068,10 @@ var ts; if (!children.length) { return undefined; } - var child = children[0]; - return child.kind < 141 ? child : child.getFirstToken(sourceFile); + var child = ts.find(children, function (kid) { return kid.kind < 266 || kid.kind > 295; }); + return child.kind < 142 ? + child : + child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -63510,7 +67079,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 141 ? child : child.getLastToken(sourceFile); + return child.kind < 142 ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -63707,17 +67276,21 @@ var ts; return this.namedDeclarations; }; SourceFileObject.prototype.computeNamedDeclarations = function () { - var result = ts.createMap(); + var result = ts.createMultiMap(); ts.forEachChild(this, visit); return result; function addDeclaration(declaration) { var name = getDeclarationName(declaration); if (name) { - ts.multiMapAdd(result, name, declaration); + result.add(name, declaration); } } function getDeclarations(name) { - return result[name] || (result[name] = []); + var declarations = result.get(name); + if (!declarations) { + result.set(name, declarations = []); + } + return declarations; } function getDeclarationName(declaration) { if (declaration.name) { @@ -63725,9 +67298,9 @@ var ts; if (result_7 !== undefined) { return result_7; } - if (declaration.name.kind === 142) { + if (declaration.name.kind === 143) { var expr = declaration.name.expression; - if (expr.kind === 177) { + if (expr.kind === 178) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -63747,10 +67320,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 225: - case 184: + case 227: + case 185: + case 150: case 149: - case 148: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -63767,30 +67340,30 @@ var ts; } ts.forEachChild(node, visit); break; - case 226: - case 197: - case 227: case 228: + case 198: case 229: case 230: - case 234: - case 243: - case 239: - case 234: + case 231: + case 232: case 236: - case 237: - case 151: + case 245: + case 241: + case 236: + case 238: + case 239: case 152: - case 161: + case 153: + case 162: addDeclaration(node); ts.forEachChild(node, visit); break; - case 144: + case 145: if (!ts.hasModifier(node, 92)) { break; } - case 223: - case 174: { + case 225: + case 175: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -63799,24 +67372,24 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 260: + case 263: + case 148: case 147: - case 146: addDeclaration(node); break; - case 241: + case 243: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 235: + case 237: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237) { + if (importClause.namedBindings.kind === 239) { addDeclaration(importClause.namedBindings); } else { @@ -64259,10 +67832,10 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { switch (node.kind) { case 70: - case 177: - case 141: + case 178: + case 142: case 98: - case 167: + case 168: case 96: var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -64301,8 +67874,8 @@ var ts; function getOccurrencesAtPosition(fileName, position) { var results = getOccurrencesAtPositionCore(fileName, position); if (results) { - var sourceFile_2 = getCanonicalFileName(ts.normalizeSlashes(fileName)); - results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_2; }); + var sourceFile_1 = getCanonicalFileName(ts.normalizeSlashes(fileName)); + results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_1; }); } return results; } @@ -64336,20 +67909,20 @@ var ts; } } function findRenameLocations(fileName, position, findInStrings, findInComments) { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments, true); return ts.FindAllReferences.convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, false, false, false); return ts.FindAllReferences.convertReferences(referencedSymbols); } function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, false, false, false); return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); } - function findReferencedSymbols(fileName, position, findInStrings, findInComments) { + function findReferencedSymbols(fileName, position, findInStrings, findInComments, isForRename) { synchronizeHostData(); - return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments); + return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments, isForRename); } function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { synchronizeHostData(); @@ -64391,15 +67964,15 @@ var ts; return; } switch (node.kind) { - case 177: - case 141: + case 178: + case 142: case 9: case 85: case 100: case 94: case 96: case 98: - case 167: + case 168: case 70: break; default: @@ -64411,7 +67984,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 230 && + if (nodeForStartPos.parent.parent.kind === 232 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -64543,7 +68116,7 @@ var ts; var span = { start: start, length: end - start }; var newLineChar = ts.getNewLineOrDefaultFromHost(host); var allFixes = []; - ts.forEach(errorCodes, function (error) { + ts.forEach(ts.deduplicate(errorCodes), function (error) { cancellationToken.throwIfCancellationRequested(); var context = { errorCode: error, @@ -64600,7 +68173,7 @@ var ts; continue; } var descriptor = undefined; - for (var i = 0, n = descriptors.length; i < n; i++) { + for (var i = 0; i < descriptors.length; i++) { if (matchArray[i + firstDescriptorCaptureIndex]) { descriptor = descriptors[i]; } @@ -64704,15 +68277,15 @@ var ts; function walk(node) { switch (node.kind) { case 70: - nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; + setNameTable(node.text, node); break; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 245 || + node.parent.kind === 247 || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { - nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; + setNameTable(node.text, node); } break; default: @@ -64725,11 +68298,66 @@ var ts; } } } + function setNameTable(text, node) { + nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); + } } + function isObjectLiteralElement(node) { + switch (node.kind) { + case 252: + case 254: + case 260: + case 261: + case 150: + case 152: + case 153: + return true; + } + return false; + } + function getContainingObjectLiteralElement(node) { + switch (node.kind) { + case 9: + case 8: + if (node.parent.kind === 143) { + return isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; + } + case 70: + return isObjectLiteralElement(node.parent) && + (node.parent.parent.kind === 177 || node.parent.parent.kind === 253) && + node.parent.name === node ? node.parent : undefined; + } + return undefined; + } + ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; + function getPropertySymbolsFromContextualType(typeChecker, node) { + var objectLiteral = node.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name = ts.getTextOfPropertyName(node.name); + if (name && contextualType) { + var result_8 = []; + var symbol = contextualType.getProperty(name); + if (contextualType.flags & 65536) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_8.push(symbol); + } + }); + return result_8; + } + if (symbol) { + result_8.push(symbol); + return result_8; + } + } + return undefined; + } + ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 178 && + node.parent.kind === 179 && node.parent.argumentExpression === node; } function getDefaultLibFilePath(options) { @@ -64739,10 +68367,923 @@ var ts; throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); } ts.getDefaultLibFilePath = getDefaultLibFilePath; - function initializeServices() { - ts.objectAllocator = getServicesObjectAllocator(); + ts.objectAllocator = getServicesObjectAllocator(); +})(ts || (ts = {})); +var debugObjectHost = (function () { return this; })(); +var ts; +(function (ts) { + function logInternalError(logger, err) { + if (logger) { + logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); + } } - initializeServices(); + var ScriptSnapshotShimAdapter = (function () { + function ScriptSnapshotShimAdapter(scriptSnapshotShim) { + this.scriptSnapshotShim = scriptSnapshotShim; + } + ScriptSnapshotShimAdapter.prototype.getText = function (start, end) { + return this.scriptSnapshotShim.getText(start, end); + }; + ScriptSnapshotShimAdapter.prototype.getLength = function () { + return this.scriptSnapshotShim.getLength(); + }; + ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { + var oldSnapshotShim = oldSnapshot; + var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + if (encoded == null) { + return null; + } + var decoded = JSON.parse(encoded); + return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); + }; + ScriptSnapshotShimAdapter.prototype.dispose = function () { + if ("dispose" in this.scriptSnapshotShim) { + this.scriptSnapshotShim.dispose(); + } + }; + return ScriptSnapshotShimAdapter; + }()); + var LanguageServiceShimHostAdapter = (function () { + function LanguageServiceShimHostAdapter(shimHost) { + var _this = this; + this.shimHost = shimHost; + this.loggingEnabled = false; + this.tracingEnabled = false; + if ("getModuleResolutionsForFile" in this.shimHost) { + this.resolveModuleNames = function (moduleNames, containingFile) { + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + return ts.map(moduleNames, function (name) { + var result = ts.getProperty(resolutionsInFile, name); + return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; + }); + }; + } + if ("directoryExists" in this.shimHost) { + this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; + } + if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { + this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { + var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); + return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); + }; + } + } + LanguageServiceShimHostAdapter.prototype.log = function (s) { + if (this.loggingEnabled) { + this.shimHost.log(s); + } + }; + LanguageServiceShimHostAdapter.prototype.trace = function (s) { + if (this.tracingEnabled) { + this.shimHost.trace(s); + } + }; + LanguageServiceShimHostAdapter.prototype.error = function (s) { + this.shimHost.error(s); + }; + LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { + if (!this.shimHost.getProjectVersion) { + return undefined; + } + return this.shimHost.getProjectVersion(); + }; + LanguageServiceShimHostAdapter.prototype.getTypeRootsVersion = function () { + if (!this.shimHost.getTypeRootsVersion) { + return 0; + } + return this.shimHost.getTypeRootsVersion(); + }; + LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { + return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + }; + LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { + var settingsJson = this.shimHost.getCompilationSettings(); + if (settingsJson == null || settingsJson == "") { + throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); + } + var compilerOptions = JSON.parse(settingsJson); + compilerOptions.allowNonTsExtensions = true; + return compilerOptions; + }; + LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { + var encoded = this.shimHost.getScriptFileNames(); + return this.files = JSON.parse(encoded); + }; + LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { + var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); + return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); + }; + LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { + if ("getScriptKind" in this.shimHost) { + return this.shimHost.getScriptKind(fileName); + } + else { + return 0; + } + }; + LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { + return this.shimHost.getScriptVersion(fileName); + }; + LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); + if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { + return null; + } + try { + return JSON.parse(diagnosticMessagesJson); + } + catch (e) { + this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); + return null; + } + }; + LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { + var hostCancellationToken = this.shimHost.getCancellationToken(); + return new ThrottledCancellationToken(hostCancellationToken); + }; + LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { + return this.shimHost.getCurrentDirectory(); + }; + LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) { + return JSON.parse(this.shimHost.getDirectories(path)); + }; + LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) { + return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); + }; + LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { + var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); + }; + LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { + return this.shimHost.readFile(path, encoding); + }; + LanguageServiceShimHostAdapter.prototype.fileExists = function (path) { + return this.shimHost.fileExists(path); + }; + return LanguageServiceShimHostAdapter; + }()); + ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; + var ThrottledCancellationToken = (function () { + function ThrottledCancellationToken(hostCancellationToken) { + this.hostCancellationToken = hostCancellationToken; + this.lastCancellationCheckTime = 0; + } + ThrottledCancellationToken.prototype.isCancellationRequested = function () { + var time = ts.timestamp(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration > 10) { + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + return false; + }; + return ThrottledCancellationToken; + }()); + var CoreServicesShimHostAdapter = (function () { + function CoreServicesShimHostAdapter(shimHost) { + var _this = this; + this.shimHost = shimHost; + this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + if ("directoryExists" in this.shimHost) { + this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; + } + if ("realpath" in this.shimHost) { + this.realpath = function (path) { return _this.shimHost.realpath(path); }; + } + } + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { + try { + var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); + } + catch (e) { + var results = []; + for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { + var extension = extensions_2[_i]; + for (var _a = 0, _b = this.readDirectoryFallback(rootDir, extension, exclude); _a < _b.length; _a++) { + var file = _b[_a]; + if (!ts.contains(results, file)) { + results.push(file); + } + } + } + return results; + } + }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; + CoreServicesShimHostAdapter.prototype.readDirectoryFallback = function (rootDir, extension, exclude) { + return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude))); + }; + CoreServicesShimHostAdapter.prototype.getDirectories = function (path) { + return JSON.parse(this.shimHost.getDirectories(path)); + }; + return CoreServicesShimHostAdapter; + }()); + ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; + function simpleForwardCall(logger, actionDescription, action, logPerformance) { + var start; + if (logPerformance) { + logger.log(actionDescription); + start = ts.timestamp(); + } + var result = action(); + if (logPerformance) { + var end = ts.timestamp(); + logger.log(actionDescription + " completed in " + (end - start) + " msec"); + if (typeof result === "string") { + var str = result; + if (str.length > 128) { + str = str.substring(0, 128) + "..."; + } + logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + } + } + return result; + } + function forwardJSONCall(logger, actionDescription, action, logPerformance) { + return forwardCall(logger, actionDescription, true, action, logPerformance); + } + function forwardCall(logger, actionDescription, returnJson, action, logPerformance) { + try { + var result = simpleForwardCall(logger, actionDescription, action, logPerformance); + return returnJson ? JSON.stringify({ result: result }) : result; + } + catch (err) { + if (err instanceof ts.OperationCanceledException) { + return JSON.stringify({ canceled: true }); + } + logInternalError(logger, err); + err.description = actionDescription; + return JSON.stringify({ error: err }); + } + } + var ShimBase = (function () { + function ShimBase(factory) { + this.factory = factory; + factory.registerShim(this); + } + ShimBase.prototype.dispose = function (_dummy) { + this.factory.unregisterShim(this); + }; + return ShimBase; + }()); + function realizeDiagnostics(diagnostics, newLine) { + return diagnostics.map(function (d) { return realizeDiagnostic(d, newLine); }); + } + ts.realizeDiagnostics = realizeDiagnostics; + function realizeDiagnostic(diagnostic, newLine) { + return { + message: ts.flattenDiagnosticMessageText(diagnostic.messageText, newLine), + start: diagnostic.start, + length: diagnostic.length, + category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), + code: diagnostic.code + }; + } + var LanguageServiceShimObject = (function (_super) { + __extends(LanguageServiceShimObject, _super); + function LanguageServiceShimObject(factory, host, languageService) { + var _this = _super.call(this, factory) || this; + _this.host = host; + _this.languageService = languageService; + _this.logPerformance = false; + _this.logger = _this.host; + return _this; + } + LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + LanguageServiceShimObject.prototype.dispose = function (dummy) { + this.logger.log("dispose()"); + this.languageService.dispose(); + this.languageService = null; + if (debugObjectHost && debugObjectHost.CollectGarbage) { + debugObjectHost.CollectGarbage(); + this.logger.log("CollectGarbage()"); + } + this.logger = null; + _super.prototype.dispose.call(this, dummy); + }; + LanguageServiceShimObject.prototype.refresh = function (throwOnError) { + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + }; + LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { + var _this = this; + this.forwardJSONCall("cleanupSemanticCache()", function () { + _this.languageService.cleanupSemanticCache(); + return null; + }); + }; + LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { + var newLine = ts.getNewLineOrDefaultFromHost(this.host); + return ts.realizeDiagnostics(diagnostics, newLine); + }; + LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); + }; + LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); + }; + LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); + }; + LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); + }; + LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { + var _this = this; + return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { + var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { + var _this = this; + return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { + var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { + var _this = this; + return this.forwardJSONCall("getCompilerOptionsDiagnostics()", function () { + var diagnostics = _this.languageService.getCompilerOptionsDiagnostics(); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { + var _this = this; + return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); + }; + LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position); }); + }; + LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments) { + var _this = this; + return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); }); + }; + LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { + var _this = this; + return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); + }; + LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { + var _this = this; + return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { + var _this = this; + return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { + var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); + }); + }; + LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { + var _this = this; + return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { return _this.languageService.getCompletionEntryDetails(fileName, position, entryName); }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { + var _this = this; + return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); + }; + LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); + }; + LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + }; + LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { + var _this = this; + return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); + }; + LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { + var _this = this; + return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); + }; + LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { + var _this = this; + return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); }); + }; + LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { + var _this = this; + return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); + }; + return LanguageServiceShimObject; + }(ShimBase)); + function convertClassifications(classifications) { + return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; + } + var ClassifierShimObject = (function (_super) { + __extends(ClassifierShimObject, _super); + function ClassifierShimObject(factory, logger) { + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.logPerformance = false; + _this.classifier = ts.createClassifier(); + return _this; + } + ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { + var _this = this; + return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); + }; + ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { + var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); + var result = ""; + for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { + var item = _a[_i]; + result += item.length + "\n"; + result += item.classification + "\n"; + } + result += classification.finalLexState; + return result; + }; + return ClassifierShimObject; + }(ShimBase)); + var CoreServicesShimObject = (function (_super) { + __extends(CoreServicesShimObject, _super); + function CoreServicesShimObject(factory, logger, host) { + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.host = host; + _this.logPerformance = false; + return _this; + } + CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; + return { + resolvedFileName: resolvedFileName, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; + CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + return { + resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : undefined, + primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; + CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { + var _this = this; + return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), true, true); + return { + referencedFiles: _this.convertFileReferences(result.referencedFiles), + importedFiles: _this.convertFileReferences(result.importedFiles), + ambientExternalModules: result.ambientExternalModules, + isLibFile: result.isLibFile, + typeReferenceDirectives: _this.convertFileReferences(result.typeReferenceDirectives) + }; + }); + }; + CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); + }); + }; + CoreServicesShimObject.prototype.convertFileReferences = function (refs) { + if (!refs) { + return undefined; + } + var result = []; + for (var _i = 0, refs_2 = refs; _i < refs_2.length; _i++) { + var ref = refs_2[_i]; + result.push({ + path: ts.normalizeSlashes(ref.fileName), + position: ref.pos, + length: ref.end - ref.pos + }); + } + return result; + }; + CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { + var _this = this; + return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { + var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); + var result = ts.parseConfigFileTextToJson(fileName, text); + if (result.error) { + return { + options: {}, + typeAcquisition: {}, + files: [], + raw: {}, + errors: [realizeDiagnostic(result.error, "\r\n")] + }; + } + var normalizedFileName = ts.normalizeSlashes(fileName); + var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), {}, normalizedFileName); + return { + options: configFile.options, + typeAcquisition: configFile.typeAcquisition, + files: configFile.fileNames, + raw: configFile.raw, + errors: realizeDiagnostics(configFile.errors, "\r\n") + }; + }); + }; + CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { + return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); }); + }; + CoreServicesShimObject.prototype.discoverTypings = function (discoverTypingsJson) { + var _this = this; + var getCanonicalFileName = ts.createGetCanonicalFileName(false); + return this.forwardJSONCall("discoverTypings()", function () { + var info = JSON.parse(discoverTypingsJson); + return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typeAcquisition, info.unresolvedImports); + }); + }; + return CoreServicesShimObject; + }(ShimBase)); + var TypeScriptServicesFactory = (function () { + function TypeScriptServicesFactory() { + this._shims = []; + } + TypeScriptServicesFactory.prototype.getServicesVersion = function () { + return ts.servicesVersion; + }; + TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { + try { + if (this.documentRegistry === undefined) { + this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); + } + var hostAdapter = new LanguageServiceShimHostAdapter(host); + var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); + return new LanguageServiceShimObject(this, host, languageService); + } + catch (err) { + logInternalError(host, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.createClassifierShim = function (logger) { + try { + return new ClassifierShimObject(this, logger); + } + catch (err) { + logInternalError(logger, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.createCoreServicesShim = function (host) { + try { + var adapter = new CoreServicesShimHostAdapter(host); + return new CoreServicesShimObject(this, host, adapter); + } + catch (err) { + logInternalError(host, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.close = function () { + this._shims = []; + this.documentRegistry = undefined; + }; + TypeScriptServicesFactory.prototype.registerShim = function (shim) { + this._shims.push(shim); + }; + TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { + for (var i = 0; i < this._shims.length; i++) { + if (this._shims[i] === shim) { + delete this._shims[i]; + return; + } + } + throw new Error("Invalid operation"); + }; + return TypeScriptServicesFactory; + }()); + ts.TypeScriptServicesFactory = TypeScriptServicesFactory; + if (typeof module !== "undefined" && module.exports) { + module.exports = ts; + } +})(ts || (ts = {})); +var TypeScript; +(function (TypeScript) { + var Services; + (function (Services) { + Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; + })(Services = TypeScript.Services || (TypeScript.Services = {})); +})(TypeScript || (TypeScript = {})); +var toolsVersion = "2.3"; +var ts; +(function (ts) { + var server; + (function (server) { + server.ActionSet = "action::set"; + server.ActionInvalidate = "action::invalidate"; + server.EventBeginInstallTypes = "event::beginInstallTypes"; + server.EventEndInstallTypes = "event::endInstallTypes"; + var Arguments; + (function (Arguments) { + Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation"; + Arguments.LogFile = "--logFile"; + Arguments.EnableTelemetry = "--enableTelemetry"; + })(Arguments = server.Arguments || (server.Arguments = {})); + function hasArgument(argumentName) { + return ts.sys.args.indexOf(argumentName) >= 0; + } + server.hasArgument = hasArgument; + function findArgument(argumentName) { + var index = ts.sys.args.indexOf(argumentName); + return index >= 0 && index < ts.sys.args.length - 1 + ? ts.sys.args[index + 1] + : undefined; + } + server.findArgument = findArgument; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var LogLevel; + (function (LogLevel) { + LogLevel[LogLevel["terse"] = 0] = "terse"; + LogLevel[LogLevel["normal"] = 1] = "normal"; + LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; + LogLevel[LogLevel["verbose"] = 3] = "verbose"; + })(LogLevel = server.LogLevel || (server.LogLevel = {})); + server.emptyArray = []; + var Msg; + (function (Msg) { + Msg.Err = "Err"; + Msg.Info = "Info"; + Msg.Perf = "Perf"; + })(Msg = server.Msg || (server.Msg = {})); + function getProjectRootPath(project) { + switch (project.projectKind) { + case server.ProjectKind.Configured: + return ts.getDirectoryPath(project.getProjectName()); + case server.ProjectKind.Inferred: + return ""; + case server.ProjectKind.External: + var projectName = ts.normalizeSlashes(project.getProjectName()); + return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; + } + } + function createInstallTypingsRequest(project, typeAcquisition, unresolvedImports, cachePath) { + return { + projectName: project.getProjectName(), + fileNames: project.getFileNames(true), + compilerOptions: project.getCompilerOptions(), + typeAcquisition: typeAcquisition, + unresolvedImports: unresolvedImports, + projectRootPath: getProjectRootPath(project), + cachePath: cachePath, + kind: "discover" + }; + } + server.createInstallTypingsRequest = createInstallTypingsRequest; + var Errors; + (function (Errors) { + function ThrowNoProject() { + throw new Error("No Project."); + } + Errors.ThrowNoProject = ThrowNoProject; + function ThrowProjectLanguageServiceDisabled() { + throw new Error("The project's language service is disabled."); + } + Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; + function ThrowProjectDoesNotContainDocument(fileName, project) { + throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); + } + Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; + })(Errors = server.Errors || (server.Errors = {})); + function getDefaultFormatCodeSettings(host) { + return { + indentSize: 4, + tabSize: 4, + newLineCharacter: host.newLine || "\n", + convertTabsToSpaces: true, + indentStyle: ts.IndentStyle.Smart, + insertSpaceAfterConstructor: false, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + insertSpaceBeforeFunctionParenthesis: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false, + }; + } + server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; + function mergeMapLikes(target, source) { + for (var key in source) { + if (ts.hasProperty(source, key)) { + target[key] = source[key]; + } + } + } + server.mergeMapLikes = mergeMapLikes; + function removeItemFromSet(items, itemToRemove) { + if (items.length === 0) { + return; + } + var index = items.indexOf(itemToRemove); + if (index < 0) { + return; + } + if (index === items.length - 1) { + items.pop(); + } + else { + items[index] = items.pop(); + } + } + server.removeItemFromSet = removeItemFromSet; + function toNormalizedPath(fileName) { + return ts.normalizePath(fileName); + } + server.toNormalizedPath = toNormalizedPath; + function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { + var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); + return getCanonicalFileName(f); + } + server.normalizedPathToPath = normalizedPathToPath; + function asNormalizedPath(fileName) { + return fileName; + } + server.asNormalizedPath = asNormalizedPath; + function createNormalizedPathMap() { + var map = ts.createMap(); + return { + get: function (path) { + return map.get(path); + }, + set: function (path, value) { + map.set(path, value); + }, + contains: function (path) { + return map.has(path); + }, + remove: function (path) { + map.delete(path); + } + }; + } + server.createNormalizedPathMap = createNormalizedPathMap; + function isInferredProjectName(name) { + return /dev\/null\/inferredProject\d+\*/.test(name); + } + server.isInferredProjectName = isInferredProjectName; + function makeInferredProjectName(counter) { + return "/dev/null/inferredProject" + counter + "*"; + } + server.makeInferredProjectName = makeInferredProjectName; + function toSortedReadonlyArray(arr) { + arr.sort(); + return arr; + } + server.toSortedReadonlyArray = toSortedReadonlyArray; + var ThrottledOperations = (function () { + function ThrottledOperations(host) { + this.host = host; + this.pendingTimeouts = ts.createMap(); + } + ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { + var pendingTimeout = this.pendingTimeouts.get(operationId); + if (pendingTimeout) { + this.host.clearTimeout(pendingTimeout); + } + this.pendingTimeouts.set(operationId, this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb)); + }; + ThrottledOperations.run = function (self, operationId, cb) { + self.pendingTimeouts.delete(operationId); + cb(); + }; + return ThrottledOperations; + }()); + server.ThrottledOperations = ThrottledOperations; + var GcTimer = (function () { + function GcTimer(host, delay, logger) { + this.host = host; + this.delay = delay; + this.logger = logger; + } + GcTimer.prototype.scheduleCollect = function () { + if (!this.host.gc || this.timerId != undefined) { + return; + } + this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); + }; + GcTimer.run = function (self) { + self.timerId = undefined; + var log = self.logger.hasLevel(LogLevel.requestTime); + var before = log && self.host.getMemoryUsage(); + self.host.gc(); + if (log) { + var after = self.host.getMemoryUsage(); + self.logger.perftrc("GC::before " + before + ", after " + after); + } + }; + return GcTimer; + }()); + server.GcTimer = GcTimer; + })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -64966,7 +69507,7 @@ var ts; if (!this.formatCodeSettings) { this.formatCodeSettings = server.getDefaultFormatCodeSettings(this.host); } - server.mergeMaps(this.formatCodeSettings, formatSettings); + server.mergeMapLikes(this.formatCodeSettings, formatSettings); } }; ScriptInfo.prototype.setWatcher = function (watcher) { @@ -65021,6 +69562,9 @@ var ts; ScriptInfo.prototype.positionToLineOffset = function (position) { return this.textStorage.positionToLineOffset(position); }; + ScriptInfo.prototype.isJavaScript = function () { + return this.scriptKind === 1 || this.scriptKind === 2; + }; return ScriptInfo; }()); server.ScriptInfo = ScriptInfo; @@ -65047,7 +69591,7 @@ var ts; ? _this.project.projectService.typingsInstaller.globalTypingsCacheLocation : undefined; var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host); - if (!(primaryResult.resolvedModule && ts.extensionIsTypeScript(primaryResult.resolvedModule.extension)) && globalCache !== undefined) { + if (ts.moduleHasNonRelativeName(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTypeScript(primaryResult.resolvedModule.extension)) && globalCache !== undefined) { var _a = ts.loadModuleFromGlobalCache(moduleName, _this.project.getProjectName(), compilerOptions, host, globalCache), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (resolvedModule) { return { resolvedModule: resolvedModule, failedLookupLocations: primaryResult.failedLookupLocations.concat(failedLookupLocations) }; @@ -65075,15 +69619,16 @@ var ts; var compilerOptions = this.getCompilationSettings(); var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_50 = names_2[_i]; - var resolution = newResolutions[name_50]; + var name = names_2[_i]; + var resolution = newResolutions.get(name); if (!resolution) { - var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_50]; + var existingResolution = currentResolutionsInFile && currentResolutionsInFile.get(name); if (moduleResolutionIsValid(existingResolution)) { resolution = existingResolution; } else { - newResolutions[name_50] = resolution = loader(name_50, containingFile, compilerOptions, this); + resolution = loader(name, containingFile, compilerOptions, this); + newResolutions.set(name, resolution); } if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { this.filesWithChangedSetOfUnresolvedImports.push(path); @@ -65123,6 +69668,9 @@ var ts; return resolution.failedLookupLocations.length === 0; } }; + LSHost.prototype.getNewLine = function () { + return this.host.newLine; + }; LSHost.prototype.getProjectVersion = function () { return this.project.getProjectVersion(); }; @@ -65228,18 +69776,19 @@ var ts; var unique = 0; for (var _i = 0, arr1_1 = arr1; _i < arr1_1.length; _i++) { var v = arr1_1[_i]; - if (set[v] !== true) { - set[v] = true; + if (set.get(v) !== true) { + set.set(v, true); unique++; } } for (var _a = 0, arr2_1 = arr2; _a < arr2_1.length; _a++) { var v = arr2_1[_a]; - if (!ts.hasProperty(set, v)) { + var isSet = set.get(v); + if (isSet === undefined) { return false; } - if (set[v] === true) { - set[v] = false; + if (isSet === true) { + set.set(v, false); unique--; } } @@ -65269,38 +69818,38 @@ var ts; if (!typeAcquisition || !typeAcquisition.enable) { return server.emptyArray; } - var entry = this.perProjectCache[project.getProjectName()]; + var entry = this.perProjectCache.get(project.getProjectName()); var result = entry ? entry.typings : server.emptyArray; if (forceRefresh || !entry || typeAcquisitionChanged(typeAcquisition, entry.typeAcquisition) || compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions) || unresolvedImportsChanged(unresolvedImports, entry.unresolvedImports)) { - this.perProjectCache[project.getProjectName()] = { + this.perProjectCache.set(project.getProjectName(), { compilerOptions: project.getCompilerOptions(), typeAcquisition: typeAcquisition, typings: result, unresolvedImports: unresolvedImports, poisoned: true - }; + }); this.installer.enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports); } return result; }; TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typeAcquisition, unresolvedImports, newTypings) { - this.perProjectCache[projectName] = { + this.perProjectCache.set(projectName, { compilerOptions: compilerOptions, typeAcquisition: typeAcquisition, typings: server.toSortedReadonlyArray(newTypings), unresolvedImports: unresolvedImports, poisoned: false - }; + }); }; TypingsCache.prototype.deleteTypingsForProject = function (projectName) { - delete this.perProjectCache[projectName]; + this.perProjectCache.delete(projectName); }; TypingsCache.prototype.onProjectClosed = function (project) { - delete this.perProjectCache[project.getProjectName()]; + this.perProjectCache.delete(project.getProjectName()); this.installer.onProjectClosed(project); }; return TypingsCache; @@ -65328,7 +69877,7 @@ var ts; BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - if (statement.kind !== 230 || statement.name.kind !== 9) { + if (statement.kind !== 232 || statement.name.kind !== 9) { return false; } } @@ -65439,7 +69988,7 @@ var ts; var ModuleBuilderFileInfo = (function (_super) { __extends(ModuleBuilderFileInfo, _super); function ModuleBuilderFileInfo() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.references = []; _this.referencedBy = []; return _this; @@ -65581,25 +70130,25 @@ var ts; } var queue = fileInfo.referencedBy.slice(0); var fileNameSet = ts.createMap(); - fileNameSet[scriptInfo.fileName] = scriptInfo; + fileNameSet.set(scriptInfo.fileName, scriptInfo); while (queue.length > 0) { var processingFileInfo = queue.pop(); if (processingFileInfo.updateShapeSignature() && processingFileInfo.referencedBy.length > 0) { for (var _i = 0, _a = processingFileInfo.referencedBy; _i < _a.length; _i++) { var potentialFileInfo = _a[_i]; - if (!fileNameSet[potentialFileInfo.scriptInfo.fileName]) { + if (!fileNameSet.has(potentialFileInfo.scriptInfo.fileName)) { queue.push(potentialFileInfo); } } } - fileNameSet[processingFileInfo.scriptInfo.fileName] = processingFileInfo.scriptInfo; + fileNameSet.set(processingFileInfo.scriptInfo.fileName, processingFileInfo.scriptInfo); } var result = []; - for (var fileName in fileNameSet) { - if (shouldEmitFile(fileNameSet[fileName])) { + fileNameSet.forEach(function (scriptInfo, fileName) { + if (shouldEmitFile(scriptInfo)) { result.push(fileName); } - } + }); return result; }; return ModuleBuilder; @@ -65716,7 +70265,7 @@ var ts; this.compilerOptions.allowNonTsExtensions = true; this.compilerOptions.allowJs = true; } - else if (hasExplicitListOfFiles) { + else if (hasExplicitListOfFiles || this.compilerOptions.allowJs) { this.compilerOptions.allowNonTsExtensions = true; } this.setInternalCompilerOptionsForEmittingJsFiles(); @@ -65740,6 +70289,16 @@ var ts; Project.prototype.getCachedUnresolvedImportsPerFile_TestOnly = function () { return this.cachedUnresolvedImportsPerFile; }; + Project.resolveModule = function (moduleName, initialDir, host, log) { + var resolvedPath = ts.normalizeSlashes(host.resolvePath(ts.combinePaths(initialDir, "node_modules"))); + log("Loading " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")"); + var result = host.require(resolvedPath, moduleName); + if (result.error) { + log("Failed to load module: " + JSON.stringify(result.error)); + return undefined; + } + return result.module; + }; Project.prototype.setInternalCompilerOptionsForEmittingJsFiles = function () { if (this.projectKind === ProjectKind.Inferred || this.projectKind === ProjectKind.External) { this.compilerOptions.noEmitForJsFiles = true; @@ -65783,6 +70342,9 @@ var ts; Project.prototype.getProjectName = function () { return this.projectName; }; + Project.prototype.getExternalFiles = function () { + return []; + }; Project.prototype.getSourceFile = function (path) { if (!this.program) { return undefined; @@ -65802,7 +70364,7 @@ var ts; info.detachFromProject(this); } } - else { + if (!this.program || !this.languageServiceEnabled) { for (var _b = 0, _c = this.rootFiles; _b < _c.length; _b++) { var root = _c[_b]; root.detachFromProject(this); @@ -65923,7 +70485,9 @@ var ts; }; Project.prototype.removeFile = function (info, detachFromProject) { if (detachFromProject === void 0) { detachFromProject = true; } - this.removeRootFileIfNecessary(info); + if (this.isRoot(info)) { + this.removeRoot(info); + } this.lsHost.notifyFileRemoved(info); this.cachedUnresolvedImportsPerFile.remove(info.path); if (detachFromProject) { @@ -65932,7 +70496,7 @@ var ts; this.markAsDirty(); }; Project.prototype.registerFileUpdate = function (fileName) { - (this.updatedFileNames || (this.updatedFileNames = ts.createMap()))[fileName] = fileName; + (this.updatedFileNames || (this.updatedFileNames = ts.createMap())).set(fileName, fileName); }; Project.prototype.markAsDirty = function () { this.projectStateVersion++; @@ -65940,17 +70504,17 @@ var ts; Project.prototype.extractUnresolvedImportsFromSourceFile = function (file, result) { var cached = this.cachedUnresolvedImportsPerFile.get(file.path); if (cached) { - for (var _i = 0, cached_1 = cached; _i < cached_1.length; _i++) { - var f = cached_1[_i]; + for (var _i = 0, cached_2 = cached; _i < cached_2.length; _i++) { + var f = cached_2[_i]; result.push(f); } return; } var unresolvedImports; if (file.resolvedModules) { - for (var name_51 in file.resolvedModules) { - if (!file.resolvedModules[name_51] && !ts.isExternalModuleNameRelative(name_51)) { - var trimmed = name_51.trim(); + file.resolvedModules.forEach(function (resolvedModule, name) { + if (!resolvedModule && !ts.isExternalModuleNameRelative(name)) { + var trimmed = name.trim(); var i = trimmed.indexOf("/"); if (i !== -1 && trimmed.charCodeAt(0) === 64) { i = trimmed.indexOf("/", i + 1); @@ -65961,7 +70525,7 @@ var ts; (unresolvedImports || (unresolvedImports = [])).push(trimmed); result.push(trimmed); } - } + }); } this.cachedUnresolvedImportsPerFile.set(file.path, unresolvedImports || server.emptyArray); }; @@ -66057,9 +70621,6 @@ var ts; }; Project.prototype.setCompilerOptions = function (compilerOptions) { if (compilerOptions) { - if (this.projectKind === ProjectKind.Inferred) { - compilerOptions.allowJs = true; - } compilerOptions.allowNonTsExtensions = true; if (ts.changesAffectModuleResolution(this.compilerOptions, compilerOptions)) { this.cachedUnresolvedImportsPerFile.clear(); @@ -66095,24 +70656,24 @@ var ts; if (this.projectStructureVersion == this.lastReportedVersion && !updatedFileNames) { return { info: info, projectErrors: this.projectErrors }; } - var lastReportedFileNames = this.lastReportedFileNames; - var currentFiles = ts.arrayToMap(this.getFileNames(), function (x) { return x; }); - var added = []; - var removed = []; - var updated = ts.getOwnKeys(updatedFileNames); - for (var id in currentFiles) { - if (!ts.hasProperty(lastReportedFileNames, id)) { - added.push(id); + var lastReportedFileNames_1 = this.lastReportedFileNames; + var currentFiles_1 = ts.arrayToMap(this.getFileNames(), function (x) { return x; }); + var added_1 = []; + var removed_1 = []; + var updated = ts.arrayFrom(updatedFileNames.keys()); + ts.forEachKey(currentFiles_1, function (id) { + if (!lastReportedFileNames_1.has(id)) { + added_1.push(id); } - } - for (var id in lastReportedFileNames) { - if (!ts.hasProperty(currentFiles, id)) { - removed.push(id); + }); + ts.forEachKey(lastReportedFileNames_1, function (id) { + if (!currentFiles_1.has(id)) { + removed_1.push(id); } - } - this.lastReportedFileNames = currentFiles; + }); + this.lastReportedFileNames = currentFiles_1; this.lastReportedVersion = this.projectStructureVersion; - return { info: info, changes: { added: added, removed: removed, updated: updated }, projectErrors: this.projectErrors }; + return { info: info, changes: { added: added_1, removed: removed_1, updated: updated }, projectErrors: this.projectErrors }; } else { var projectFileNames = this.getFileNames(); @@ -66139,7 +70700,7 @@ var ts; if (symbol && symbol.declarations && symbol.declarations[0]) { var declarationSourceFile = symbol.declarations[0].getSourceFile(); if (declarationSourceFile) { - referencedFiles[declarationSourceFile.path] = true; + referencedFiles.set(declarationSourceFile.path, true); } } } @@ -66150,28 +70711,25 @@ var ts; for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) { var referencedFile = _c[_b]; var referencedPath = ts.toPath(referencedFile.fileName, currentDirectory, getCanonicalFileName); - referencedFiles[referencedPath] = true; + referencedFiles.set(referencedPath, true); } } if (sourceFile.resolvedTypeReferenceDirectiveNames) { - for (var typeName in sourceFile.resolvedTypeReferenceDirectiveNames) { - var resolvedTypeReferenceDirective = sourceFile.resolvedTypeReferenceDirectiveNames[typeName]; + sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (resolvedTypeReferenceDirective) { if (!resolvedTypeReferenceDirective) { - continue; + return; } var fileName = resolvedTypeReferenceDirective.resolvedFileName; var typeFilePath = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - referencedFiles[typeFilePath] = true; - } + referencedFiles.set(typeFilePath, true); + }); } - var allFileNames = ts.map(Object.keys(referencedFiles), function (key) { return key; }); + var allFileNames = ts.arrayFrom(referencedFiles.keys()); return ts.filter(allFileNames, function (file) { return _this.projectService.host.fileExists(file); }); }; - Project.prototype.removeRootFileIfNecessary = function (info) { - if (this.isRoot(info)) { - remove(this.rootFiles, info); - this.rootFilesMap.remove(info.path); - } + Project.prototype.removeRoot = function (info) { + remove(this.rootFiles, info); + this.rootFilesMap.remove(info.path); }; return Project; }()); @@ -66180,9 +70738,44 @@ var ts; __extends(InferredProject, _super); function InferredProject(projectService, documentRegistry, compilerOptions) { var _this = _super.call(this, InferredProject.newName(), ProjectKind.Inferred, projectService, documentRegistry, undefined, true, compilerOptions, false) || this; + _this._isJsInferredProject = false; _this.directoriesWatchedForTsconfig = []; return _this; } + InferredProject.prototype.toggleJsInferredProject = function (isJsInferredProject) { + if (isJsInferredProject !== this._isJsInferredProject) { + this._isJsInferredProject = isJsInferredProject; + this.setCompilerOptions(); + } + }; + InferredProject.prototype.setCompilerOptions = function (options) { + var newOptions = options ? ts.clone(options) : this.getCompilerOptions(); + if (!newOptions) { + return; + } + if (this._isJsInferredProject && typeof newOptions.maxNodeModuleJsDepth !== "number") { + newOptions.maxNodeModuleJsDepth = 2; + } + else if (!this._isJsInferredProject) { + newOptions.maxNodeModuleJsDepth = undefined; + } + newOptions.allowJs = true; + _super.prototype.setCompilerOptions.call(this, newOptions); + }; + InferredProject.prototype.addRoot = function (info) { + if (!this._isJsInferredProject && info.isJavaScript()) { + this.toggleJsInferredProject(true); + } + _super.prototype.addRoot.call(this, info); + }; + InferredProject.prototype.removeRoot = function (info) { + if (this._isJsInferredProject && info.isJavaScript()) { + if (ts.filter(this.getRootScriptInfos(), function (info) { return info.isJavaScript(); }).length === 0) { + this.toggleJsInferredProject(false); + } + } + _super.prototype.removeRoot.call(this, info); + }; InferredProject.prototype.getProjectRootPath = function () { if (this.projectService.useSingleInferredProject) { return undefined; @@ -66219,15 +70812,63 @@ var ts; __extends(ConfiguredProject, _super); function ConfiguredProject(configFileName, projectService, documentRegistry, hasExplicitListOfFiles, compilerOptions, wildcardDirectories, languageServiceEnabled, compileOnSaveEnabled) { var _this = _super.call(this, configFileName, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.configFileName = configFileName; _this.wildcardDirectories = wildcardDirectories; _this.compileOnSaveEnabled = compileOnSaveEnabled; + _this.plugins = []; _this.openRefCount = 0; _this.canonicalConfigFilePath = server.asNormalizedPath(projectService.toCanonicalFileName(configFileName)); + _this.enablePlugins(); return _this; } ConfiguredProject.prototype.getConfigFilePath = function () { return this.getProjectName(); }; + ConfiguredProject.prototype.enablePlugins = function () { + var _this = this; + var host = this.projectService.host; + var options = this.getCompilerOptions(); + var log = function (message) { + _this.projectService.logger.info(message); + }; + if (!(options.plugins && options.plugins.length)) { + this.projectService.logger.info("No plugins exist"); + return; + } + if (!host.require) { + this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); + return; + } + for (var _i = 0, _a = options.plugins; _i < _a.length; _i++) { + var pluginConfigEntry = _a[_i]; + var searchPath = ts.getDirectoryPath(this.configFileName); + var resolvedModule = Project.resolveModule(pluginConfigEntry.name, searchPath, host, log); + if (resolvedModule) { + this.enableProxy(resolvedModule, pluginConfigEntry); + } + } + }; + ConfiguredProject.prototype.enableProxy = function (pluginModuleFactory, configEntry) { + try { + if (typeof pluginModuleFactory !== "function") { + this.projectService.logger.info("Skipped loading plugin " + configEntry.name + " because it did expose a proper factory function"); + return; + } + var info = { + config: configEntry, + project: this, + languageService: this.languageService, + languageServiceHost: this.lsHost, + serverHost: this.projectService.host + }; + var pluginModule = pluginModuleFactory({ typescript: ts }); + this.languageService = pluginModule.create(info); + this.plugins.push(pluginModule); + } + catch (e) { + this.projectService.logger.info("Plugin activation failed: " + e); + } + }; ConfiguredProject.prototype.getProjectRootPath = function () { return ts.getDirectoryPath(this.getConfigFilePath()); }; @@ -66240,6 +70881,21 @@ var ts; ConfiguredProject.prototype.getTypeAcquisition = function () { return this.typeAcquisition; }; + ConfiguredProject.prototype.getExternalFiles = function () { + var items = []; + for (var _i = 0, _a = this.plugins; _i < _a.length; _i++) { + var plugin = _a[_i]; + if (typeof plugin.getExternalFiles === "function") { + try { + items.push.apply(items, plugin.getExternalFiles(this)); + } + catch (e) { + this.projectService.logger.info("A plugin threw an exception in getExternalFiles: " + e); + } + } + } + return items; + }; ConfiguredProject.prototype.watchConfigFile = function (callback) { var _this = this; this.projectFileWatcher = this.projectService.host.watchFile(this.getConfigFilePath(), function (_) { return callback(_this); }); @@ -66270,14 +70926,14 @@ var ts; return; } var configDirectoryPath = ts.getDirectoryPath(this.getConfigFilePath()); - this.directoriesWatchedForWildcards = ts.reduceProperties(this.wildcardDirectories, function (watchers, flag, directory) { + this.directoriesWatchedForWildcards = ts.createMap(); + this.wildcardDirectories.forEach(function (flag, directory) { if (ts.comparePaths(configDirectoryPath, directory, ".", !_this.projectService.host.useCaseSensitiveFileNames) !== 0) { var recursive = (flag & 1) !== 0; _this.projectService.logger.info("Add " + (recursive ? "recursive " : "") + "watcher for: " + directory); - watchers[directory] = _this.projectService.host.watchDirectory(directory, function (path) { return callback(_this, path); }, recursive); + _this.directoriesWatchedForWildcards.set(directory, _this.projectService.host.watchDirectory(directory, function (path) { return callback(_this, path); }, recursive)); } - return watchers; - }, {}); + }); }; ConfiguredProject.prototype.stopWatchingDirectory = function () { if (this.directoryWatcher) { @@ -66297,9 +70953,9 @@ var ts; } this.typeRootsWatchers = undefined; } - for (var id in this.directoriesWatchedForWildcards) { - this.directoriesWatchedForWildcards[id].close(); - } + this.directoriesWatchedForWildcards.forEach(function (watcher) { + watcher.close(); + }); this.directoriesWatchedForWildcards = undefined; this.stopWatchingDirectory(); }; @@ -66376,36 +71032,35 @@ var ts; var option = commandLineOptions_1[_i]; if (typeof option.type === "object") { var optionMap = option.type; - for (var id in optionMap) { - ts.Debug.assert(typeof optionMap[id] === "number"); - } - map[option.name] = optionMap; + optionMap.forEach(function (value) { + ts.Debug.assert(typeof value === "number"); + }); + map.set(option.name, optionMap); } } return map; } var compilerOptionConverters = prepareConvertersForEnumLikeCompilerOptions(ts.optionDeclarations); - var indentStyle = ts.createMap({ + var indentStyle = ts.createMapFromTemplate({ "none": ts.IndentStyle.None, "block": ts.IndentStyle.Block, "smart": ts.IndentStyle.Smart }); function convertFormatOptions(protocolOptions) { if (typeof protocolOptions.indentStyle === "string") { - protocolOptions.indentStyle = indentStyle[protocolOptions.indentStyle.toLowerCase()]; + protocolOptions.indentStyle = indentStyle.get(protocolOptions.indentStyle.toLowerCase()); ts.Debug.assert(protocolOptions.indentStyle !== undefined); } return protocolOptions; } server.convertFormatOptions = convertFormatOptions; function convertCompilerOptions(protocolOptions) { - for (var id in compilerOptionConverters) { + compilerOptionConverters.forEach(function (mappedValues, id) { var propertyValue = protocolOptions[id]; if (typeof propertyValue === "string") { - var mappedValues = compilerOptionConverters[id]; - protocolOptions[id] = mappedValues[propertyValue.toLowerCase()]; + protocolOptions[id] = mappedValues.get(propertyValue.toLowerCase()); } - } + }); return protocolOptions; } server.convertCompilerOptions = convertCompilerOptions; @@ -66472,24 +71127,25 @@ var ts; this.directoryWatchersRefCount = ts.createMap(); } DirectoryWatchers.prototype.stopWatchingDirectory = function (directory) { - this.directoryWatchersRefCount[directory]--; - if (this.directoryWatchersRefCount[directory] === 0) { + var refCount = this.directoryWatchersRefCount.get(directory) - 1; + this.directoryWatchersRefCount.set(directory, refCount); + if (refCount === 0) { this.projectService.logger.info("Close directory watcher for: " + directory); - this.directoryWatchersForTsconfig[directory].close(); - delete this.directoryWatchersForTsconfig[directory]; + this.directoryWatchersForTsconfig.get(directory).close(); + this.directoryWatchersForTsconfig.delete(directory); } }; DirectoryWatchers.prototype.startWatchingContainingDirectoriesForFile = function (fileName, project, callback) { var currentPath = ts.getDirectoryPath(fileName); var parentPath = ts.getDirectoryPath(currentPath); while (currentPath != parentPath) { - if (!this.directoryWatchersForTsconfig[currentPath]) { + if (!this.directoryWatchersForTsconfig.has(currentPath)) { this.projectService.logger.info("Add watcher for: " + currentPath); - this.directoryWatchersForTsconfig[currentPath] = this.projectService.host.watchDirectory(currentPath, callback); - this.directoryWatchersRefCount[currentPath] = 1; + this.directoryWatchersForTsconfig.set(currentPath, this.projectService.host.watchDirectory(currentPath, callback)); + this.directoryWatchersRefCount.set(currentPath, 1); } else { - this.directoryWatchersRefCount[currentPath] += 1; + this.directoryWatchersRefCount.set(currentPath, this.directoryWatchersRefCount.get(currentPath) + 1); } project.directoriesWatchedForTsconfig.push(currentPath); currentPath = parentPath; @@ -66936,7 +71592,7 @@ var ts; files: parsedCommandLine.fileNames, compilerOptions: parsedCommandLine.options, configHasFilesProperty: config["files"] !== undefined, - wildcardDirectories: ts.createMap(parsedCommandLine.wildcardDirectories), + wildcardDirectories: ts.createMapFromTemplate(parsedCommandLine.wildcardDirectories), typeAcquisition: parsedCommandLine.typeAcquisition, compileOnSave: parsedCommandLine.compileOnSave }; @@ -67194,7 +71850,7 @@ var ts; this.logger.info("Host information " + args.hostInfo); } if (args.formatOptions) { - server.mergeMaps(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); + server.mergeMapLikes(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); this.logger.info("Format host information updated"); } if (args.extraFileExtensions) { @@ -67274,13 +71930,13 @@ var ts; this.printProjects(); }; ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_4 = function (proj) { + var _loop_6 = function (proj) { var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); }; for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { var proj = currentProjects_1[_i]; - _loop_4(proj); + _loop_6(proj); } }; ProjectService.prototype.synchronizeProjectList = function (knownProjects) { @@ -67339,7 +71995,7 @@ var ts; ProjectService.prototype.closeExternalProject = function (uncheckedFileName, suppressRefresh) { if (suppressRefresh === void 0) { suppressRefresh = false; } var fileName = server.toNormalizedPath(uncheckedFileName); - var configFiles = this.externalProjectToConfiguredProjectMap[fileName]; + var configFiles = this.externalProjectToConfiguredProjectMap.get(fileName); if (configFiles) { var shouldRefreshInferredProjects = false; for (var _i = 0, configFiles_1 = configFiles; _i < configFiles_1.length; _i++) { @@ -67348,7 +72004,7 @@ var ts; shouldRefreshInferredProjects = true; } } - delete this.externalProjectToConfiguredProjectMap[fileName]; + this.externalProjectToConfiguredProjectMap.delete(fileName); if (shouldRefreshInferredProjects && !suppressRefresh) { this.refreshInferredProjects(); } @@ -67364,18 +72020,19 @@ var ts; } }; ProjectService.prototype.openExternalProjects = function (projects) { + var _this = this; var projectsToClose = ts.arrayToMap(this.externalProjects, function (p) { return p.getProjectName(); }, function (_) { return true; }); - for (var externalProjectName in this.externalProjectToConfiguredProjectMap) { - projectsToClose[externalProjectName] = true; - } + ts.forEachKey(this.externalProjectToConfiguredProjectMap, function (externalProjectName) { + projectsToClose.set(externalProjectName, true); + }); for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { var externalProject = projects_4[_i]; this.openExternalProject(externalProject, true); - delete projectsToClose[externalProject.projectFileName]; - } - for (var externalProjectName in projectsToClose) { - this.closeExternalProject(externalProjectName, true); + projectsToClose.delete(externalProject.projectFileName); } + ts.forEachKey(projectsToClose, function (externalProjectName) { + _this.closeExternalProject(externalProjectName, true); + }); this.refreshInferredProjects(); }; ProjectService.prototype.openExternalProject = function (proj, suppressRefreshOfInferredProjects) { @@ -67417,12 +72074,12 @@ var ts; } this.closeExternalProject(proj.projectFileName, true); } - else if (this.externalProjectToConfiguredProjectMap[proj.projectFileName]) { + else if (this.externalProjectToConfiguredProjectMap.get(proj.projectFileName)) { if (!tsConfigFiles) { this.closeExternalProject(proj.projectFileName, true); } else { - var oldConfigFiles = this.externalProjectToConfiguredProjectMap[proj.projectFileName]; + var oldConfigFiles = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName); var iNew = 0; var iOld = 0; while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) { @@ -67447,7 +72104,7 @@ var ts; } } if (tsConfigFiles) { - this.externalProjectToConfiguredProjectMap[proj.projectFileName] = tsConfigFiles; + this.externalProjectToConfiguredProjectMap.set(proj.projectFileName, tsConfigFiles); for (var _b = 0, tsConfigFiles_1 = tsConfigFiles; _b < tsConfigFiles_1.length; _b++) { var tsconfigFile = tsConfigFiles_1[_b]; var project = this.findConfiguredProjectByProjectName(tsconfigFile); @@ -67461,7 +72118,7 @@ var ts; } } else { - delete this.externalProjectToConfiguredProjectMap[proj.projectFileName]; + this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName); this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition); } if (!suppressRefreshOfInferredProjects) { @@ -67477,6 +72134,11 @@ var ts; (function (ts) { var server; (function (server) { + server.nullCancellationToken = { + isCancellationRequested: function () { return false; }, + setRequest: function () { return void 0; }, + resetRequest: function () { return void 0; } + }; function hrTimeToMilliseconds(time) { var seconds = time[0]; var nanoseconds = time[1]; @@ -67616,17 +72278,100 @@ var ts; return "Content-Length: " + (1 + len) + "\r\n\r\n" + json + newLine; } server.formatMessage = formatMessage; + var MultistepOperation = (function () { + function MultistepOperation(operationHost) { + var _this = this; + this.operationHost = operationHost; + this.completed = true; + this.next = { + immediate: function (action) { return _this.immediate(action); }, + delay: function (ms, action) { return _this.delay(ms, action); } + }; + } + MultistepOperation.prototype.startNew = function (action) { + this.complete(); + this.requestId = this.operationHost.getCurrentRequestId(); + this.completed = false; + this.executeAction(action); + }; + MultistepOperation.prototype.complete = function () { + if (!this.completed) { + if (this.requestId) { + this.operationHost.sendRequestCompletedEvent(this.requestId); + } + this.completed = true; + } + this.setTimerHandle(undefined); + this.setImmediateId(undefined); + }; + MultistepOperation.prototype.immediate = function (action) { + var _this = this; + var requestId = this.requestId; + ts.Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "immediate: incorrect request id"); + this.setImmediateId(this.operationHost.getServerHost().setImmediate(function () { + _this.immediateId = undefined; + _this.operationHost.executeWithRequestId(requestId, function () { return _this.executeAction(action); }); + })); + }; + MultistepOperation.prototype.delay = function (ms, action) { + var _this = this; + var requestId = this.requestId; + ts.Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "delay: incorrect request id"); + this.setTimerHandle(this.operationHost.getServerHost().setTimeout(function () { + _this.timerHandle = undefined; + _this.operationHost.executeWithRequestId(requestId, function () { return _this.executeAction(action); }); + }, ms)); + }; + MultistepOperation.prototype.executeAction = function (action) { + var stop = false; + try { + if (this.operationHost.isCancellationRequested()) { + stop = true; + } + else { + action(this.next); + } + } + catch (e) { + stop = true; + if (!(e instanceof ts.OperationCanceledException)) { + this.operationHost.logError(e, "delayed processing of request " + this.requestId); + } + } + if (stop || !this.hasPendingWork()) { + this.complete(); + } + }; + MultistepOperation.prototype.setTimerHandle = function (timerHandle) { + ; + if (this.timerHandle !== undefined) { + this.operationHost.getServerHost().clearTimeout(this.timerHandle); + } + this.timerHandle = timerHandle; + }; + MultistepOperation.prototype.setImmediateId = function (immediateId) { + if (this.immediateId !== undefined) { + this.operationHost.getServerHost().clearImmediate(this.immediateId); + } + this.immediateId = immediateId; + }; + MultistepOperation.prototype.hasPendingWork = function () { + return !!this.timerHandle || !!this.immediateId; + }; + return MultistepOperation; + }()); var Session = (function () { function Session(host, cancellationToken, useSingleInferredProject, typingsInstaller, byteLength, hrtime, logger, canUseEvents, eventHandler) { var _this = this; this.host = host; + this.cancellationToken = cancellationToken; this.typingsInstaller = typingsInstaller; this.byteLength = byteLength; this.hrtime = hrtime; this.logger = logger; this.canUseEvents = canUseEvents; this.changeSeq = 0; - this.handlers = ts.createMap((_a = {}, + this.handlers = ts.createMapFromTemplate((_a = {}, _a[CommandNames.OpenExternalProject] = function (request) { _this.projectService.openExternalProject(request.arguments, false); return _this.requiredResponse(true); @@ -67780,12 +72525,12 @@ var ts; return _this.requiredResponse(_this.getSyntacticDiagnosticsSync(request.arguments)); }, _a[CommandNames.Geterr] = function (request) { - var geterrArgs = request.arguments; - return { response: _this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false }; + _this.errorCheck.startNew(function (next) { return _this.getDiagnostics(next, request.arguments.delay, request.arguments.files); }); + return _this.notRequired(); }, _a[CommandNames.GeterrForProject] = function (request) { - var _a = request.arguments, file = _a.file, delay = _a.delay; - return { response: _this.getDiagnosticsForProject(delay, file), responseRequired: false }; + _this.errorCheck.startNew(function (next) { return _this.getDiagnosticsForProject(next, request.arguments.delay, request.arguments.file); }); + return _this.notRequired(); }, _a[CommandNames.Change] = function (request) { _this.change(request.arguments); @@ -67867,17 +72612,35 @@ var ts; this.eventHander = canUseEvents ? eventHandler || (function (event) { return _this.defaultEventHandler(event); }) : undefined; + var multistepOperationHost = { + executeWithRequestId: function (requestId, action) { return _this.executeWithRequestId(requestId, action); }, + getCurrentRequestId: function () { return _this.currentRequestId; }, + getServerHost: function () { return _this.host; }, + logError: function (err, cmd) { return _this.logError(err, cmd); }, + sendRequestCompletedEvent: function (requestId) { return _this.sendRequestCompletedEvent(requestId); }, + isCancellationRequested: function () { return cancellationToken.isCancellationRequested(); } + }; + this.errorCheck = new MultistepOperation(multistepOperationHost); this.projectService = new server.ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); this.gcTimer = new server.GcTimer(host, 7000, logger); var _a; } + Session.prototype.sendRequestCompletedEvent = function (requestId) { + var event = { + seq: 0, + type: "event", + event: "requestCompleted", + body: { request_seq: requestId } + }; + this.send(event); + }; Session.prototype.defaultEventHandler = function (event) { var _this = this; switch (event.eventName) { case server.ContextEvent: - var _a = event.data, project = _a.project, fileName = _a.fileName; - this.projectService.logger.info("got context event, updating diagnostics for " + fileName); - this.updateErrorCheck([{ fileName: fileName, project: project }], this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); + var _a = event.data, project_1 = _a.project, fileName_1 = _a.fileName; + this.projectService.logger.info("got context event, updating diagnostics for " + fileName_1); + this.errorCheck.startNew(function (next) { return _this.updateErrorCheck(next, [{ fileName: fileName_1, project: project_1 }], _this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); }); break; case server.ConfigFileDiagEvent: var _b = event.data, triggerFile = _b.triggerFile, configFileName = _b.configFileName, diagnostics = _b.diagnostics; @@ -67930,7 +72693,7 @@ var ts; seq: 0, type: "event", event: eventName, - body: info, + body: info }; this.send(ev); }; @@ -67985,7 +72748,7 @@ var ts; } }, ms); }; - Session.prototype.updateErrorCheck = function (checkList, seq, matchSeq, ms, followMs, requireOpen) { + Session.prototype.updateErrorCheck = function (next, checkList, seq, matchSeq, ms, followMs, requireOpen) { var _this = this; if (ms === void 0) { ms = 1500; } if (followMs === void 0) { followMs = 200; } @@ -67993,13 +72756,6 @@ var ts; if (followMs > ms) { followMs = ms; } - if (this.errorTimer) { - this.host.clearTimeout(this.errorTimer); - } - if (this.immediateId) { - this.host.clearImmediate(this.immediateId); - this.immediateId = undefined; - } var index = 0; var checkOne = function () { if (matchSeq(seq)) { @@ -68007,21 +72763,17 @@ var ts; index++; if (checkSpec_1.project.containsFile(checkSpec_1.fileName, requireOpen)) { _this.syntacticCheck(checkSpec_1.fileName, checkSpec_1.project); - _this.immediateId = _this.host.setImmediate(function () { + next.immediate(function () { _this.semanticCheck(checkSpec_1.fileName, checkSpec_1.project); - _this.immediateId = undefined; if (checkList.length > index) { - _this.errorTimer = _this.host.setTimeout(checkOne, followMs); - } - else { - _this.errorTimer = undefined; + next.delay(followMs, checkOne); } }); } } }; if ((checkList.length > index) && (matchSeq(seq))) { - this.errorTimer = this.host.setTimeout(checkOne, ms); + next.delay(ms, checkOne); } }; Session.prototype.cleanProjects = function (caption, projects) { @@ -68118,18 +72870,21 @@ var ts; }; Session.prototype.getImplementation = function (args, simplifiedResult) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); var implementations = project.getLanguageService().getImplementationAtPosition(file, position); if (!implementations) { return []; } if (simplifiedResult) { - return implementations.map(function (impl) { return ({ - file: impl.fileName, - start: scriptInfo.positionToLineOffset(impl.textSpan.start), - end: scriptInfo.positionToLineOffset(ts.textSpanEnd(impl.textSpan)) - }); }); + return implementations.map(function (_a) { + var fileName = _a.fileName, textSpan = _a.textSpan; + var scriptInfo = project.getScriptInfo(fileName); + return { + file: fileName, + start: scriptInfo.positionToLineOffset(textSpan.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)) + }; + }); } else { return implementations; @@ -68539,9 +73294,9 @@ var ts; if (simplifiedResult) { return completions.entries.reduce(function (result, entry) { if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - var name_52 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; + var name = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; var convertedSpan = replacementSpan ? _this.decorateSpan(replacementSpan, scriptInfo) : undefined; - result.push({ name: name_52, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); + result.push({ name: name, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); } return result; }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); @@ -68574,7 +73329,8 @@ var ts; if (project.compileOnSaveEnabled && project.languageServiceEnabled) { result.push({ projectFileName: project.getProjectName(), - fileNames: project.getCompileOnSaveAffectedFileList(info) + fileNames: project.getCompileOnSaveAffectedFileList(info), + projectUsesOutFile: !!project.getCompilerOptions().outFile || !!project.getCompilerOptions().out }); } } @@ -68617,7 +73373,7 @@ var ts; return helpItems; } }; - Session.prototype.getDiagnostics = function (delay, fileNames) { + Session.prototype.getDiagnostics = function (next, delay, fileNames) { var _this = this; var checkList = fileNames.reduce(function (accum, uncheckedFileName) { var fileName = server.toNormalizedPath(uncheckedFileName); @@ -68628,7 +73384,7 @@ var ts; return accum; }, []); if (checkList.length > 0) { - this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay); + this.updateErrorCheck(next, checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay); } }; Session.prototype.change = function (args) { @@ -68835,7 +73591,7 @@ var ts; ? spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }) : spans; }; - Session.prototype.getDiagnosticsForProject = function (delay, fileName) { + Session.prototype.getDiagnosticsForProject = function (next, delay, fileName) { var _this = this; var _a = this.getProjectInfoWorker(fileName, undefined, true), fileNames = _a.fileNames, languageServiceDisabled = _a.languageServiceDisabled; if (languageServiceDisabled) { @@ -68867,7 +73623,7 @@ var ts; fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); if (fileNamesInProject.length > 0) { var checkList = fileNamesInProject.map(function (fileName) { return ({ fileName: fileName, project: project }); }); - this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); + this.updateErrorCheck(next, checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); } }; Session.prototype.getCanonicalFileName = function (fileName) { @@ -68883,15 +73639,34 @@ var ts; return { response: response, responseRequired: true }; }; Session.prototype.addProtocolHandler = function (command, handler) { - if (command in this.handlers) { + if (this.handlers.has(command)) { throw new Error("Protocol handler already exists for command \"" + command + "\""); } - this.handlers[command] = handler; + this.handlers.set(command, handler); + }; + Session.prototype.setCurrentRequest = function (requestId) { + ts.Debug.assert(this.currentRequestId === undefined); + this.currentRequestId = requestId; + this.cancellationToken.setRequest(requestId); + }; + Session.prototype.resetCurrentRequest = function (requestId) { + ts.Debug.assert(this.currentRequestId === requestId); + this.currentRequestId = undefined; + this.cancellationToken.resetRequest(requestId); + }; + Session.prototype.executeWithRequestId = function (requestId, f) { + try { + this.setCurrentRequest(requestId); + return f(); + } + finally { + this.resetCurrentRequest(requestId); + } }; Session.prototype.executeCommand = function (request) { - var handler = this.handlers[request.command]; + var handler = this.handlers.get(request.command); if (handler) { - return handler(request); + return this.executeWithRequestId(request.seq, function () { return handler(request); }); } else { this.logger.msg("Unrecognized JSON command: " + JSON.stringify(request), server.Msg.Err); @@ -69022,7 +73797,7 @@ var ts; if (len > 1) { var insertedNodes = new Array(len - 1); var startNode = leafNode; - for (var i = 1, len_1 = lines.length; i < len_1; i++) { + for (var i = 1; i < lines.length; i++) { insertedNodes[i - 1] = new LineLeaf(lines[i]); } var pathIndex = this.startPath.length - 2; @@ -69219,8 +73994,8 @@ var ts; var snap = this.versions[this.currentVersionToIndex()]; if (this.changes.length > 0) { var snapIndex = snap.index; - for (var i = 0, len = this.changes.length; i < len; i++) { - var change = this.changes[i]; + for (var _i = 0, _a = this.changes; _i < _a.length; _i++) { + var change = _a[_i]; snapIndex = snapIndex.edit(change.pos, change.deleteLen, change.insertedText); } snap = new LineIndexSnapshot(this.currentVersion + 1, this); @@ -69241,8 +74016,8 @@ var ts; var textChangeRanges = []; for (var i = oldVersion + 1; i <= newVersion; i++) { var snap = this.versions[this.versionToIndex(i)]; - for (var j = 0, len = snap.changesSincePreviousVersion.length; j < len; j++) { - var textChange = snap.changesSincePreviousVersion[j]; + for (var _i = 0, _a = snap.changesSincePreviousVersion; _i < _a.length; _i++) { + var textChange = _a[_i]; textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); } } @@ -69342,7 +74117,7 @@ var ts; LineIndex.prototype.load = function (lines) { if (lines.length > 0) { var leaves = []; - for (var i = 0, len = lines.length; i < len; i++) { + for (var i = 0; i < lines.length; i++) { leaves[i] = new LineLeaf(lines[i]); } this.root = LineIndex.buildTreeFromBottom(leaves); @@ -69502,8 +74277,8 @@ var ts; 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]; + for (var _i = 0, _a = this.children; _i < _a.length; _i++) { + var child = _a[_i]; this.totalChars += child.charCount(); this.totalLines += child.lineCount(); } @@ -70044,7 +74819,7 @@ var ts; var IOSession = (function (_super) { __extends(IOSession, _super); function IOSession(host, cancellationToken, installerEventPort, canUseEvents, useSingleInferredProject, disableAutomaticTypingAcquisition, globalTypingsCacheLocation, telemetryEnabled, logger) { - var _this; + var _this = this; var typingsInstaller = disableAutomaticTypingAcquisition ? undefined : new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, host.newLine); @@ -70074,7 +74849,8 @@ var ts; function parseLoggingEnvironmentString(logEnvStr) { var logEnv = { logToFile: true }; var args = logEnvStr.split(" "); - for (var i = 0, len = args.length; i < (len - 1); i += 2) { + var len = args.length - 1; + for (var i = 0; i < len; i += 2) { var option = args[i]; var value = args[i + 1]; if (option && value) { @@ -70219,15 +74995,22 @@ var ts; if (typeof global !== "undefined" && global.gc) { sys.gc = function () { return global.gc(); }; } + sys.require = function (initialDir, moduleName) { + var result = ts.nodeModuleNameResolverWorker(moduleName, initialDir + "/program.ts", { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, sys, undefined, true); + try { + return { module: require(result.resolvedModule.resolvedFileName), error: undefined }; + } + catch (e) { + return { module: undefined, error: e }; + } + }; var cancellationToken; try { var factory = require("./cancellationToken"); cancellationToken = factory(sys.args); } catch (e) { - cancellationToken = { - isCancellationRequested: function () { return false; } - }; + cancellationToken = server.nullCancellationToken; } ; var eventPort; @@ -70253,701 +75036,3 @@ var ts; ioSession.listen(); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); -var debugObjectHost = (function () { return this; })(); -var ts; -(function (ts) { - function logInternalError(logger, err) { - if (logger) { - logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); - } - } - var ScriptSnapshotShimAdapter = (function () { - function ScriptSnapshotShimAdapter(scriptSnapshotShim) { - this.scriptSnapshotShim = scriptSnapshotShim; - } - ScriptSnapshotShimAdapter.prototype.getText = function (start, end) { - return this.scriptSnapshotShim.getText(start, end); - }; - ScriptSnapshotShimAdapter.prototype.getLength = function () { - return this.scriptSnapshotShim.getLength(); - }; - ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { - var oldSnapshotShim = oldSnapshot; - var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); - if (encoded == null) { - return null; - } - var decoded = JSON.parse(encoded); - return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); - }; - ScriptSnapshotShimAdapter.prototype.dispose = function () { - if ("dispose" in this.scriptSnapshotShim) { - this.scriptSnapshotShim.dispose(); - } - }; - return ScriptSnapshotShimAdapter; - }()); - var LanguageServiceShimHostAdapter = (function () { - function LanguageServiceShimHostAdapter(shimHost) { - var _this = this; - this.shimHost = shimHost; - this.loggingEnabled = false; - this.tracingEnabled = false; - if ("getModuleResolutionsForFile" in this.shimHost) { - this.resolveModuleNames = function (moduleNames, containingFile) { - var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); - return ts.map(moduleNames, function (name) { - var result = ts.getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; - }); - }; - } - if ("directoryExists" in this.shimHost) { - this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; - } - if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { - this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); - return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); - }; - } - } - LanguageServiceShimHostAdapter.prototype.log = function (s) { - if (this.loggingEnabled) { - this.shimHost.log(s); - } - }; - LanguageServiceShimHostAdapter.prototype.trace = function (s) { - if (this.tracingEnabled) { - this.shimHost.trace(s); - } - }; - LanguageServiceShimHostAdapter.prototype.error = function (s) { - this.shimHost.error(s); - }; - LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { - if (!this.shimHost.getProjectVersion) { - return undefined; - } - return this.shimHost.getProjectVersion(); - }; - LanguageServiceShimHostAdapter.prototype.getTypeRootsVersion = function () { - if (!this.shimHost.getTypeRootsVersion) { - return 0; - } - return this.shimHost.getTypeRootsVersion(); - }; - LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { - return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; - }; - LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { - var settingsJson = this.shimHost.getCompilationSettings(); - if (settingsJson == null || settingsJson == "") { - throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); - } - return JSON.parse(settingsJson); - }; - LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { - var encoded = this.shimHost.getScriptFileNames(); - return this.files = JSON.parse(encoded); - }; - LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { - var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); - return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); - }; - LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { - if ("getScriptKind" in this.shimHost) { - return this.shimHost.getScriptKind(fileName); - } - else { - return 0; - } - }; - LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { - return this.shimHost.getScriptVersion(fileName); - }; - LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { - var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); - if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { - return null; - } - try { - return JSON.parse(diagnosticMessagesJson); - } - catch (e) { - this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); - return null; - } - }; - LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { - var hostCancellationToken = this.shimHost.getCancellationToken(); - return new ThrottledCancellationToken(hostCancellationToken); - }; - LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { - return this.shimHost.getCurrentDirectory(); - }; - LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) { - return JSON.parse(this.shimHost.getDirectories(path)); - }; - LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) { - return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); - }; - LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { - var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); - return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); - }; - LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { - return this.shimHost.readFile(path, encoding); - }; - LanguageServiceShimHostAdapter.prototype.fileExists = function (path) { - return this.shimHost.fileExists(path); - }; - return LanguageServiceShimHostAdapter; - }()); - ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - var ThrottledCancellationToken = (function () { - function ThrottledCancellationToken(hostCancellationToken) { - this.hostCancellationToken = hostCancellationToken; - this.lastCancellationCheckTime = 0; - } - ThrottledCancellationToken.prototype.isCancellationRequested = function () { - var time = ts.timestamp(); - var duration = Math.abs(time - this.lastCancellationCheckTime); - if (duration > 10) { - this.lastCancellationCheckTime = time; - return this.hostCancellationToken.isCancellationRequested(); - } - return false; - }; - return ThrottledCancellationToken; - }()); - var CoreServicesShimHostAdapter = (function () { - function CoreServicesShimHostAdapter(shimHost) { - var _this = this; - this.shimHost = shimHost; - this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; - if ("directoryExists" in this.shimHost) { - this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; - } - if ("realpath" in this.shimHost) { - this.realpath = function (path) { return _this.shimHost.realpath(path); }; - } - } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { - try { - var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); - return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); - } - catch (e) { - var results = []; - for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { - var extension = extensions_2[_i]; - for (var _a = 0, _b = this.readDirectoryFallback(rootDir, extension, exclude); _a < _b.length; _a++) { - var file = _b[_a]; - if (!ts.contains(results, file)) { - results.push(file); - } - } - } - return results; - } - }; - CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { - return this.shimHost.fileExists(fileName); - }; - CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { - return this.shimHost.readFile(fileName); - }; - CoreServicesShimHostAdapter.prototype.readDirectoryFallback = function (rootDir, extension, exclude) { - return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude))); - }; - CoreServicesShimHostAdapter.prototype.getDirectories = function (path) { - return JSON.parse(this.shimHost.getDirectories(path)); - }; - return CoreServicesShimHostAdapter; - }()); - ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; - function simpleForwardCall(logger, actionDescription, action, logPerformance) { - var start; - if (logPerformance) { - logger.log(actionDescription); - start = ts.timestamp(); - } - var result = action(); - if (logPerformance) { - var end = ts.timestamp(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); - if (typeof result === "string") { - var str = result; - if (str.length > 128) { - str = str.substring(0, 128) + "..."; - } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); - } - } - return result; - } - function forwardJSONCall(logger, actionDescription, action, logPerformance) { - return forwardCall(logger, actionDescription, true, action, logPerformance); - } - function forwardCall(logger, actionDescription, returnJson, action, logPerformance) { - try { - var result = simpleForwardCall(logger, actionDescription, action, logPerformance); - return returnJson ? JSON.stringify({ result: result }) : result; - } - catch (err) { - if (err instanceof ts.OperationCanceledException) { - return JSON.stringify({ canceled: true }); - } - logInternalError(logger, err); - err.description = actionDescription; - return JSON.stringify({ error: err }); - } - } - var ShimBase = (function () { - function ShimBase(factory) { - this.factory = factory; - factory.registerShim(this); - } - ShimBase.prototype.dispose = function (_dummy) { - this.factory.unregisterShim(this); - }; - return ShimBase; - }()); - function realizeDiagnostics(diagnostics, newLine) { - return diagnostics.map(function (d) { return realizeDiagnostic(d, newLine); }); - } - ts.realizeDiagnostics = realizeDiagnostics; - function realizeDiagnostic(diagnostic, newLine) { - return { - message: ts.flattenDiagnosticMessageText(diagnostic.messageText, newLine), - start: diagnostic.start, - length: diagnostic.length, - category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), - code: diagnostic.code - }; - } - var LanguageServiceShimObject = (function (_super) { - __extends(LanguageServiceShimObject, _super); - function LanguageServiceShimObject(factory, host, languageService) { - var _this = _super.call(this, factory) || this; - _this.host = host; - _this.languageService = languageService; - _this.logPerformance = false; - _this.logger = _this.host; - return _this; - } - LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); - }; - LanguageServiceShimObject.prototype.dispose = function (dummy) { - this.logger.log("dispose()"); - this.languageService.dispose(); - this.languageService = null; - if (debugObjectHost && debugObjectHost.CollectGarbage) { - debugObjectHost.CollectGarbage(); - this.logger.log("CollectGarbage()"); - } - this.logger = null; - _super.prototype.dispose.call(this, dummy); - }; - LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); - }; - LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { - var _this = this; - this.forwardJSONCall("cleanupSemanticCache()", function () { - _this.languageService.cleanupSemanticCache(); - return null; - }); - }; - LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { - var newLine = ts.getNewLineOrDefaultFromHost(this.host); - return ts.realizeDiagnostics(diagnostics, newLine); - }; - LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); - }; - LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); - }; - LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); - }; - LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); - }; - LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { - var _this = this; - return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { - var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { - var _this = this; - return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { - var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { - var _this = this; - return this.forwardJSONCall("getCompilerOptionsDiagnostics()", function () { - var diagnostics = _this.languageService.getCompilerOptionsDiagnostics(); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { - var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); - }; - LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position); }); - }; - LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments) { - var _this = this; - return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); }); - }; - LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { - var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); - }; - LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { - var _this = this; - return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { - var _this = this; - return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { - var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); - var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); - return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); - }); - }; - LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { - var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { return _this.languageService.getCompletionEntryDetails(fileName, position, entryName); }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { - var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); - }; - LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); - }; - LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); - }; - LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { - var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); - }; - LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { - var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); - }; - LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { - var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); }); - }; - LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { - var _this = this; - return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); - }; - return LanguageServiceShimObject; - }(ShimBase)); - function convertClassifications(classifications) { - return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; - } - var ClassifierShimObject = (function (_super) { - __extends(ClassifierShimObject, _super); - function ClassifierShimObject(factory, logger) { - var _this = _super.call(this, factory) || this; - _this.logger = logger; - _this.logPerformance = false; - _this.classifier = ts.createClassifier(); - return _this; - } - ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { - var _this = this; - return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); - }; - ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { - var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); - var result = ""; - for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { - var item = _a[_i]; - result += item.length + "\n"; - result += item.classification + "\n"; - } - result += classification.finalLexState; - return result; - }; - return ClassifierShimObject; - }(ShimBase)); - var CoreServicesShimObject = (function (_super) { - __extends(CoreServicesShimObject, _super); - function CoreServicesShimObject(factory, logger, host) { - var _this = _super.call(this, factory) || this; - _this.logger = logger; - _this.host = host; - _this.logPerformance = false; - return _this; - } - CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); - }; - CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); - var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (resolvedFileName && !compilerOptions.allowJs && ts.fileExtensionIs(resolvedFileName, ".js")) { - return { - resolvedFileName: undefined, - failedLookupLocations: [] - }; - } - return { - resolvedFileName: resolvedFileName, - failedLookupLocations: result.failedLookupLocations - }; - }); - }; - CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); - return { - resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : undefined, - primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true, - failedLookupLocations: result.failedLookupLocations - }; - }); - }; - CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { - var _this = this; - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { - var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), true, true); - return { - referencedFiles: _this.convertFileReferences(result.referencedFiles), - importedFiles: _this.convertFileReferences(result.importedFiles), - ambientExternalModules: result.ambientExternalModules, - isLibFile: result.isLibFile, - typeReferenceDirectives: _this.convertFileReferences(result.typeReferenceDirectives) - }; - }); - }; - CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); - }); - }; - CoreServicesShimObject.prototype.convertFileReferences = function (refs) { - if (!refs) { - return undefined; - } - var result = []; - for (var _i = 0, refs_2 = refs; _i < refs_2.length; _i++) { - var ref = refs_2[_i]; - result.push({ - path: ts.normalizeSlashes(ref.fileName), - position: ref.pos, - length: ref.end - ref.pos - }); - } - return result; - }; - CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { - var _this = this; - return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { - var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); - var result = ts.parseConfigFileTextToJson(fileName, text); - if (result.error) { - return { - options: {}, - typeAcquisition: {}, - files: [], - raw: {}, - errors: [realizeDiagnostic(result.error, "\r\n")] - }; - } - var normalizedFileName = ts.normalizeSlashes(fileName); - var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), {}, normalizedFileName); - return { - options: configFile.options, - typeAcquisition: configFile.typeAcquisition, - files: configFile.fileNames, - raw: configFile.raw, - errors: realizeDiagnostics(configFile.errors, "\r\n") - }; - }); - }; - CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { - return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); }); - }; - CoreServicesShimObject.prototype.discoverTypings = function (discoverTypingsJson) { - var _this = this; - var getCanonicalFileName = ts.createGetCanonicalFileName(false); - return this.forwardJSONCall("discoverTypings()", function () { - var info = JSON.parse(discoverTypingsJson); - return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typeAcquisition, info.unresolvedImports); - }); - }; - return CoreServicesShimObject; - }(ShimBase)); - var TypeScriptServicesFactory = (function () { - function TypeScriptServicesFactory() { - this._shims = []; - } - TypeScriptServicesFactory.prototype.getServicesVersion = function () { - return ts.servicesVersion; - }; - TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { - try { - if (this.documentRegistry === undefined) { - this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); - } - var hostAdapter = new LanguageServiceShimHostAdapter(host); - var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); - return new LanguageServiceShimObject(this, host, languageService); - } - catch (err) { - logInternalError(host, err); - throw err; - } - }; - TypeScriptServicesFactory.prototype.createClassifierShim = function (logger) { - try { - return new ClassifierShimObject(this, logger); - } - catch (err) { - logInternalError(logger, err); - throw err; - } - }; - TypeScriptServicesFactory.prototype.createCoreServicesShim = function (host) { - try { - var adapter = new CoreServicesShimHostAdapter(host); - return new CoreServicesShimObject(this, host, adapter); - } - catch (err) { - logInternalError(host, err); - throw err; - } - }; - TypeScriptServicesFactory.prototype.close = function () { - this._shims = []; - this.documentRegistry = undefined; - }; - TypeScriptServicesFactory.prototype.registerShim = function (shim) { - this._shims.push(shim); - }; - TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0, n = this._shims.length; i < n; i++) { - if (this._shims[i] === shim) { - delete this._shims[i]; - return; - } - } - throw new Error("Invalid operation"); - }; - return TypeScriptServicesFactory; - }()); - ts.TypeScriptServicesFactory = TypeScriptServicesFactory; - if (typeof module !== "undefined" && module.exports) { - module.exports = ts; - } -})(ts || (ts = {})); -var TypeScript; -(function (TypeScript) { - var Services; - (function (Services) { - Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; - })(Services = TypeScript.Services || (TypeScript.Services = {})); -})(TypeScript || (TypeScript = {})); -var toolsVersion = "2.2"; diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index e01f4393032..90350104cae 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -1,879 +1,42 @@ -/// -declare namespace ts.server.protocol { - namespace CommandTypes { - type Brace = "brace"; - type BraceFull = "brace-full"; - type BraceCompletion = "braceCompletion"; - type Change = "change"; - type Close = "close"; - type Completions = "completions"; - type CompletionsFull = "completions-full"; - type CompletionDetails = "completionEntryDetails"; - type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; - type CompileOnSaveEmitFile = "compileOnSaveEmitFile"; - type Configure = "configure"; - type Definition = "definition"; - type DefinitionFull = "definition-full"; - type Implementation = "implementation"; - type ImplementationFull = "implementation-full"; - type Exit = "exit"; - type Format = "format"; - type Formatonkey = "formatonkey"; - type FormatFull = "format-full"; - type FormatonkeyFull = "formatonkey-full"; - type FormatRangeFull = "formatRange-full"; - type Geterr = "geterr"; - type GeterrForProject = "geterrForProject"; - type SemanticDiagnosticsSync = "semanticDiagnosticsSync"; - type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; - type NavBar = "navbar"; - type NavBarFull = "navbar-full"; - type Navto = "navto"; - type NavtoFull = "navto-full"; - type NavTree = "navtree"; - type NavTreeFull = "navtree-full"; - type Occurrences = "occurrences"; - type DocumentHighlights = "documentHighlights"; - type DocumentHighlightsFull = "documentHighlights-full"; - type Open = "open"; - type Quickinfo = "quickinfo"; - type QuickinfoFull = "quickinfo-full"; - type References = "references"; - type ReferencesFull = "references-full"; - type Reload = "reload"; - type Rename = "rename"; - type RenameInfoFull = "rename-full"; - type RenameLocationsFull = "renameLocations-full"; - type Saveto = "saveto"; - type SignatureHelp = "signatureHelp"; - type SignatureHelpFull = "signatureHelp-full"; - type TypeDefinition = "typeDefinition"; - type ProjectInfo = "projectInfo"; - type ReloadProjects = "reloadProjects"; - type Unknown = "unknown"; - type OpenExternalProject = "openExternalProject"; - type OpenExternalProjects = "openExternalProjects"; - type CloseExternalProject = "closeExternalProject"; - type SynchronizeProjectList = "synchronizeProjectList"; - type ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; - type EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; - type Cleanup = "cleanup"; - type OutliningSpans = "outliningSpans"; - type TodoComments = "todoComments"; - type Indentation = "indentation"; - type DocCommentTemplate = "docCommentTemplate"; - type CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; - type NameOrDottedNameSpan = "nameOrDottedNameSpan"; - type BreakpointStatement = "breakpointStatement"; - type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; - type GetCodeFixes = "getCodeFixes"; - type GetCodeFixesFull = "getCodeFixes-full"; - type GetSupportedCodeFixes = "getSupportedCodeFixes"; - } - interface Message { - seq: number; - type: "request" | "response" | "event"; - } - interface Request extends Message { - command: string; - arguments?: any; - } - interface ReloadProjectsRequest extends Message { - command: CommandTypes.ReloadProjects; - } - interface Event extends Message { - event: string; - body?: any; - } - interface Response extends Message { - request_seq: number; - success: boolean; - command: string; - message?: string; - body?: any; - } - interface FileRequestArgs { - file: string; - projectFileName?: string; - } - interface DocCommentTemplateRequest extends FileLocationRequest { - command: CommandTypes.DocCommentTemplate; - } - interface DocCommandTemplateResponse extends Response { - body?: TextInsertion; - } - interface TodoCommentRequest extends FileRequest { - command: CommandTypes.TodoComments; - arguments: TodoCommentRequestArgs; - } - interface TodoCommentRequestArgs extends FileRequestArgs { - descriptors: TodoCommentDescriptor[]; - } - interface TodoCommentsResponse extends Response { - body?: TodoComment[]; - } - interface OutliningSpansRequest extends FileRequest { - command: CommandTypes.OutliningSpans; - } - interface OutliningSpansResponse extends Response { - body?: OutliningSpan[]; - } - interface IndentationRequest extends FileLocationRequest { - command: CommandTypes.Indentation; - arguments: IndentationRequestArgs; - } - interface IndentationResponse extends Response { - body?: IndentationResult; - } - interface IndentationResult { - position: number; - indentation: number; - } - interface IndentationRequestArgs extends FileLocationRequestArgs { - options?: EditorSettings; - } - interface ProjectInfoRequestArgs extends FileRequestArgs { - needFileNameList: boolean; - } - interface ProjectInfoRequest extends Request { - command: CommandTypes.ProjectInfo; - arguments: ProjectInfoRequestArgs; - } - interface CompilerOptionsDiagnosticsRequest extends Request { - arguments: CompilerOptionsDiagnosticsRequestArgs; - } - interface CompilerOptionsDiagnosticsRequestArgs { - projectFileName: string; - } - interface ProjectInfo { - configFileName: string; - fileNames?: string[]; - languageServiceDisabled?: boolean; - } - interface DiagnosticWithLinePosition { - message: string; - start: number; - length: number; - startLocation: Location; - endLocation: Location; - category: string; - code: number; - } - interface ProjectInfoResponse extends Response { - body?: ProjectInfo; - } - interface FileRequest extends Request { - arguments: FileRequestArgs; - } - interface FileLocationRequestArgs extends FileRequestArgs { - line: number; - offset: number; - position?: number; - } - interface CodeFixRequest extends Request { - command: CommandTypes.GetCodeFixes; - arguments: CodeFixRequestArgs; - } - interface CodeFixRequestArgs extends FileRequestArgs { - startLine: number; - startOffset: number; - startPosition?: number; - endLine: number; - endOffset: number; - endPosition?: number; - errorCodes?: number[]; - } - interface GetCodeFixesResponse extends Response { - body?: CodeAction[]; - } - interface FileLocationRequest extends FileRequest { - arguments: FileLocationRequestArgs; - } - interface GetSupportedCodeFixesRequest extends Request { - command: CommandTypes.GetSupportedCodeFixes; - } - interface GetSupportedCodeFixesResponse extends Response { - body?: string[]; - } - interface EncodedSemanticClassificationsRequest extends FileRequest { - arguments: EncodedSemanticClassificationsRequestArgs; - } - interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { - start: number; - length: number; - } - interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { - filesToSearch: string[]; - } - interface DefinitionRequest extends FileLocationRequest { - command: CommandTypes.Definition; - } - interface TypeDefinitionRequest extends FileLocationRequest { - command: CommandTypes.TypeDefinition; - } - interface ImplementationRequest extends FileLocationRequest { - command: CommandTypes.Implementation; - } - interface Location { - line: number; - offset: number; - } - interface TextSpan { - start: Location; - end: Location; - } - interface FileSpan extends TextSpan { - file: string; - } - interface DefinitionResponse extends Response { - body?: FileSpan[]; - } - interface TypeDefinitionResponse extends Response { - body?: FileSpan[]; - } - interface ImplementationResponse extends Response { - body?: FileSpan[]; - } - interface BraceCompletionRequest extends FileLocationRequest { - command: CommandTypes.BraceCompletion; - arguments: BraceCompletionRequestArgs; - } - interface BraceCompletionRequestArgs extends FileLocationRequestArgs { - openingBrace: string; - } - interface OccurrencesRequest extends FileLocationRequest { - command: CommandTypes.Occurrences; - } - interface OccurrencesResponseItem extends FileSpan { - isWriteAccess: boolean; - } - interface OccurrencesResponse extends Response { - body?: OccurrencesResponseItem[]; - } - interface DocumentHighlightsRequest extends FileLocationRequest { - command: CommandTypes.DocumentHighlights; - arguments: DocumentHighlightsRequestArgs; - } - interface HighlightSpan extends TextSpan { - kind: string; - } - interface DocumentHighlightsItem { - file: string; - highlightSpans: HighlightSpan[]; - } - interface DocumentHighlightsResponse extends Response { - body?: DocumentHighlightsItem[]; - } - interface ReferencesRequest extends FileLocationRequest { - command: CommandTypes.References; - } - interface ReferencesResponseItem extends FileSpan { - lineText: string; - isWriteAccess: boolean; - isDefinition: boolean; - } - interface ReferencesResponseBody { - refs: ReferencesResponseItem[]; - symbolName: string; - symbolStartOffset: number; - symbolDisplayString: string; - } - interface ReferencesResponse extends Response { - body?: ReferencesResponseBody; - } - interface RenameRequestArgs extends FileLocationRequestArgs { - findInComments?: boolean; - findInStrings?: boolean; - } - interface RenameRequest extends FileLocationRequest { - command: CommandTypes.Rename; - arguments: RenameRequestArgs; - } - interface RenameInfo { - canRename: boolean; - localizedErrorMessage?: string; - displayName: string; - fullDisplayName: string; - kind: string; - kindModifiers: string; - } - interface SpanGroup { - file: string; - locs: TextSpan[]; - } - interface RenameResponseBody { - info: RenameInfo; - locs: SpanGroup[]; - } - interface RenameResponse extends Response { - body?: RenameResponseBody; - } - interface ExternalFile { - fileName: string; - scriptKind?: ScriptKindName | ts.ScriptKind; - hasMixedContent?: boolean; - content?: string; - } - interface ExternalProject { - projectFileName: string; - rootFiles: ExternalFile[]; - options: ExternalProjectCompilerOptions; - typingOptions?: TypeAcquisition; - typeAcquisition?: TypeAcquisition; - } - interface CompileOnSaveMixin { - compileOnSave?: boolean; - } - type ExternalProjectCompilerOptions = CompilerOptions & CompileOnSaveMixin; - interface ProjectVersionInfo { - projectName: string; - isInferred: boolean; - version: number; - options: ts.CompilerOptions; - languageServiceDisabled: boolean; - } - interface ProjectChanges { - added: string[]; - removed: string[]; - updated: string[]; - } - interface ProjectFiles { - info?: ProjectVersionInfo; - files?: string[]; - changes?: ProjectChanges; - } - interface ProjectFilesWithDiagnostics extends ProjectFiles { - projectErrors: DiagnosticWithLinePosition[]; - } - interface ChangedOpenFile { - fileName: string; - changes: ts.TextChange[]; - } - interface ConfigureRequestArguments { - hostInfo?: string; - file?: string; - formatOptions?: FormatCodeSettings; - extraFileExtensions?: FileExtensionInfo[]; - } - interface ConfigureRequest extends Request { - command: CommandTypes.Configure; - arguments: ConfigureRequestArguments; - } - interface ConfigureResponse extends Response { - } - interface OpenRequestArgs extends FileRequestArgs { - fileContent?: string; - scriptKindName?: ScriptKindName; - } - type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; - interface OpenRequest extends Request { - command: CommandTypes.Open; - arguments: OpenRequestArgs; - } - interface OpenExternalProjectRequest extends Request { - command: CommandTypes.OpenExternalProject; - arguments: OpenExternalProjectArgs; - } - type OpenExternalProjectArgs = ExternalProject; - interface OpenExternalProjectsRequest extends Request { - command: CommandTypes.OpenExternalProjects; - arguments: OpenExternalProjectsArgs; - } - interface OpenExternalProjectsArgs { - projects: ExternalProject[]; - } - interface OpenExternalProjectResponse extends Response { - } - interface OpenExternalProjectsResponse extends Response { - } - interface CloseExternalProjectRequest extends Request { - command: CommandTypes.CloseExternalProject; - arguments: CloseExternalProjectRequestArgs; - } - interface CloseExternalProjectRequestArgs { - projectFileName: string; - } - interface CloseExternalProjectResponse extends Response { - } - interface SynchronizeProjectListRequest extends Request { - arguments: SynchronizeProjectListRequestArgs; - } - interface SynchronizeProjectListRequestArgs { - knownProjects: protocol.ProjectVersionInfo[]; - } - interface ApplyChangedToOpenFilesRequest extends Request { - arguments: ApplyChangedToOpenFilesRequestArgs; - } - interface ApplyChangedToOpenFilesRequestArgs { - openFiles?: ExternalFile[]; - changedFiles?: ChangedOpenFile[]; - closedFiles?: string[]; - } - interface SetCompilerOptionsForInferredProjectsRequest extends Request { - command: CommandTypes.CompilerOptionsForInferredProjects; - arguments: SetCompilerOptionsForInferredProjectsArgs; - } - interface SetCompilerOptionsForInferredProjectsArgs { - options: ExternalProjectCompilerOptions; - } - interface SetCompilerOptionsForInferredProjectsResponse extends Response { - } - interface ExitRequest extends Request { - command: CommandTypes.Exit; - } - interface CloseRequest extends FileRequest { - command: CommandTypes.Close; - } - interface CompileOnSaveAffectedFileListRequest extends FileRequest { - command: CommandTypes.CompileOnSaveAffectedFileList; - } - interface CompileOnSaveAffectedFileListSingleProject { - projectFileName: string; - fileNames: string[]; - } - interface CompileOnSaveAffectedFileListResponse extends Response { - body: CompileOnSaveAffectedFileListSingleProject[]; - } - interface CompileOnSaveEmitFileRequest extends FileRequest { - command: CommandTypes.CompileOnSaveEmitFile; - arguments: CompileOnSaveEmitFileRequestArgs; - } - interface CompileOnSaveEmitFileRequestArgs extends FileRequestArgs { - forced?: boolean; - } - interface QuickInfoRequest extends FileLocationRequest { - command: CommandTypes.Quickinfo; - } - interface QuickInfoResponseBody { - kind: string; - kindModifiers: string; - start: Location; - end: Location; - displayString: string; - documentation: string; - } - interface QuickInfoResponse extends Response { - body?: QuickInfoResponseBody; - } - interface FormatRequestArgs extends FileLocationRequestArgs { - endLine: number; - endOffset: number; - endPosition?: number; - options?: FormatCodeSettings; - } - interface FormatRequest extends FileLocationRequest { - command: CommandTypes.Format; - arguments: FormatRequestArgs; - } - interface CodeEdit { - start: Location; - end: Location; - newText: string; - } - interface FileCodeEdits { - fileName: string; - textChanges: CodeEdit[]; - } - interface CodeFixResponse extends Response { - body?: CodeAction[]; - } - interface CodeAction { - description: string; - changes: FileCodeEdits[]; - } - interface FormatResponse extends Response { - body?: CodeEdit[]; - } - interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { - key: string; - options?: FormatCodeSettings; - } - interface FormatOnKeyRequest extends FileLocationRequest { - command: CommandTypes.Formatonkey; - arguments: FormatOnKeyRequestArgs; - } - interface CompletionsRequestArgs extends FileLocationRequestArgs { - prefix?: string; - } - interface CompletionsRequest extends FileLocationRequest { - command: CommandTypes.Completions; - arguments: CompletionsRequestArgs; - } - interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { - entryNames: string[]; - } - interface CompletionDetailsRequest extends FileLocationRequest { - command: CommandTypes.CompletionDetails; - arguments: CompletionDetailsRequestArgs; - } - interface SymbolDisplayPart { - text: string; - kind: string; - } - interface CompletionEntry { - name: string; - kind: string; - kindModifiers: string; - sortText: string; - replacementSpan?: TextSpan; - } - interface CompletionEntryDetails { - name: string; - kind: string; - kindModifiers: string; - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - } - interface CompletionsResponse extends Response { - body?: CompletionEntry[]; - } - interface CompletionDetailsResponse extends Response { - body?: CompletionEntryDetails[]; - } - interface SignatureHelpParameter { - name: string; - documentation: SymbolDisplayPart[]; - displayParts: SymbolDisplayPart[]; - isOptional: boolean; - } - interface SignatureHelpItem { - isVariadic: boolean; - prefixDisplayParts: SymbolDisplayPart[]; - suffixDisplayParts: SymbolDisplayPart[]; - separatorDisplayParts: SymbolDisplayPart[]; - parameters: SignatureHelpParameter[]; - documentation: SymbolDisplayPart[]; - } - interface SignatureHelpItems { - items: SignatureHelpItem[]; - applicableSpan: TextSpan; - selectedItemIndex: number; - argumentIndex: number; - argumentCount: number; - } - interface SignatureHelpRequestArgs extends FileLocationRequestArgs { - } - interface SignatureHelpRequest extends FileLocationRequest { - command: CommandTypes.SignatureHelp; - arguments: SignatureHelpRequestArgs; - } - interface SignatureHelpResponse extends Response { - body?: SignatureHelpItems; - } - interface SemanticDiagnosticsSyncRequest extends FileRequest { - command: CommandTypes.SemanticDiagnosticsSync; - arguments: SemanticDiagnosticsSyncRequestArgs; - } - interface SemanticDiagnosticsSyncRequestArgs extends FileRequestArgs { - includeLinePosition?: boolean; - } - interface SemanticDiagnosticsSyncResponse extends Response { - body?: Diagnostic[] | DiagnosticWithLinePosition[]; - } - interface SyntacticDiagnosticsSyncRequest extends FileRequest { - command: CommandTypes.SyntacticDiagnosticsSync; - arguments: SyntacticDiagnosticsSyncRequestArgs; - } - interface SyntacticDiagnosticsSyncRequestArgs extends FileRequestArgs { - includeLinePosition?: boolean; - } - interface SyntacticDiagnosticsSyncResponse extends Response { - body?: Diagnostic[] | DiagnosticWithLinePosition[]; - } - interface GeterrForProjectRequestArgs { - file: string; - delay: number; - } - interface GeterrForProjectRequest extends Request { - command: CommandTypes.GeterrForProject; - arguments: GeterrForProjectRequestArgs; - } - interface GeterrRequestArgs { - files: string[]; - delay: number; - } - interface GeterrRequest extends Request { - command: CommandTypes.Geterr; - arguments: GeterrRequestArgs; - } - interface Diagnostic { - start: Location; - end: Location; - text: string; - code?: number; - } - interface DiagnosticEventBody { - file: string; - diagnostics: Diagnostic[]; - } - interface DiagnosticEvent extends Event { - body?: DiagnosticEventBody; - } - interface ConfigFileDiagnosticEventBody { - triggerFile: string; - configFile: string; - diagnostics: Diagnostic[]; - } - interface ConfigFileDiagnosticEvent extends Event { - body?: ConfigFileDiagnosticEventBody; - event: "configFileDiag"; - } - type ProjectLanguageServiceStateEventName = "projectLanguageServiceState"; - interface ProjectLanguageServiceStateEvent extends Event { - event: ProjectLanguageServiceStateEventName; - body?: ProjectLanguageServiceStateEventBody; - } - interface ProjectLanguageServiceStateEventBody { - projectName: string; - languageServiceEnabled: boolean; - } - interface ReloadRequestArgs extends FileRequestArgs { - tmpfile: string; - } - interface ReloadRequest extends FileRequest { - command: CommandTypes.Reload; - arguments: ReloadRequestArgs; - } - interface ReloadResponse extends Response { - } - interface SavetoRequestArgs extends FileRequestArgs { - tmpfile: string; - } - interface SavetoRequest extends FileRequest { - command: CommandTypes.Saveto; - arguments: SavetoRequestArgs; - } - interface NavtoRequestArgs extends FileRequestArgs { - searchValue: string; - maxResultCount?: number; - currentFileOnly?: boolean; - projectFileName?: string; - } - interface NavtoRequest extends FileRequest { - command: CommandTypes.Navto; - arguments: NavtoRequestArgs; - } - interface NavtoItem { - name: string; - kind: string; - matchKind?: string; - isCaseSensitive?: boolean; - kindModifiers?: string; - file: string; - start: Location; - end: Location; - containerName?: string; - containerKind?: string; - } - interface NavtoResponse extends Response { - body?: NavtoItem[]; - } - interface ChangeRequestArgs extends FormatRequestArgs { - insertString?: string; - } - interface ChangeRequest extends FileLocationRequest { - command: CommandTypes.Change; - arguments: ChangeRequestArgs; - } - interface BraceResponse extends Response { - body?: TextSpan[]; - } - interface BraceRequest extends FileLocationRequest { - command: CommandTypes.Brace; - } - interface NavBarRequest extends FileRequest { - command: CommandTypes.NavBar; - } - interface NavTreeRequest extends FileRequest { - command: CommandTypes.NavTree; - } - interface NavigationBarItem { - text: string; - kind: string; - kindModifiers?: string; - spans: TextSpan[]; - childItems?: NavigationBarItem[]; - indent: number; - } - interface NavigationTree { - text: string; - kind: string; - kindModifiers: string; - spans: TextSpan[]; - childItems?: NavigationTree[]; - } - type TelemetryEventName = "telemetry"; - interface TelemetryEvent extends Event { - event: TelemetryEventName; - body: TelemetryEventBody; - } - interface TelemetryEventBody { - telemetryEventName: string; - payload: any; - } - type TypingsInstalledTelemetryEventName = "typingsInstalled"; - interface TypingsInstalledTelemetryEventBody extends TelemetryEventBody { - telemetryEventName: TypingsInstalledTelemetryEventName; - payload: TypingsInstalledTelemetryEventPayload; - } - interface TypingsInstalledTelemetryEventPayload { - installedPackages: string; - installSuccess: boolean; - typingsInstallerVersion: string; - } - type BeginInstallTypesEventName = "beginInstallTypes"; - type EndInstallTypesEventName = "endInstallTypes"; - interface BeginInstallTypesEvent extends Event { - event: BeginInstallTypesEventName; - body: BeginInstallTypesEventBody; - } - interface EndInstallTypesEvent extends Event { - event: EndInstallTypesEventName; - body: EndInstallTypesEventBody; - } - interface InstallTypesEventBody { - eventId: number; - packages: ReadonlyArray; - } - interface BeginInstallTypesEventBody extends InstallTypesEventBody { - } - interface EndInstallTypesEventBody extends InstallTypesEventBody { - success: boolean; - } - interface NavBarResponse extends Response { - body?: NavigationBarItem[]; - } - interface NavTreeResponse extends Response { - body?: NavigationTree; - } - namespace IndentStyle { - type None = "None"; - type Block = "Block"; - type Smart = "Smart"; - } - type IndentStyle = IndentStyle.None | IndentStyle.Block | IndentStyle.Smart; - interface EditorSettings { - baseIndentSize?: number; - indentSize?: number; - tabSize?: number; - newLineCharacter?: string; - convertTabsToSpaces?: boolean; - indentStyle?: IndentStyle | ts.IndentStyle; - } - interface FormatCodeSettings extends EditorSettings { - insertSpaceAfterCommaDelimiter?: boolean; - insertSpaceAfterSemicolonInForStatements?: boolean; - insertSpaceBeforeAndAfterBinaryOperators?: boolean; - insertSpaceAfterKeywordsInControlFlowStatements?: boolean; - insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; - placeOpenBraceOnNewLineForFunctions?: boolean; - placeOpenBraceOnNewLineForControlBlocks?: boolean; - } - interface CompilerOptions { - allowJs?: boolean; - allowSyntheticDefaultImports?: boolean; - allowUnreachableCode?: boolean; - allowUnusedLabels?: boolean; - baseUrl?: string; - charset?: string; - declaration?: boolean; - declarationDir?: string; - disableSizeLimit?: boolean; - emitBOM?: boolean; - emitDecoratorMetadata?: boolean; - experimentalDecorators?: boolean; - forceConsistentCasingInFileNames?: boolean; - inlineSourceMap?: boolean; - inlineSources?: boolean; - isolatedModules?: boolean; - jsx?: JsxEmit | ts.JsxEmit; - lib?: string[]; - locale?: string; - mapRoot?: string; - maxNodeModuleJsDepth?: number; - module?: ModuleKind | ts.ModuleKind; - moduleResolution?: ModuleResolutionKind | ts.ModuleResolutionKind; - newLine?: NewLineKind | ts.NewLineKind; - noEmit?: boolean; - noEmitHelpers?: boolean; - noEmitOnError?: boolean; - noErrorTruncation?: boolean; - noFallthroughCasesInSwitch?: boolean; - noImplicitAny?: boolean; - noImplicitReturns?: boolean; - noImplicitThis?: boolean; - noUnusedLocals?: boolean; - noUnusedParameters?: boolean; - noImplicitUseStrict?: boolean; - noLib?: boolean; - noResolve?: boolean; - out?: string; - outDir?: string; - outFile?: string; - paths?: MapLike; - preserveConstEnums?: boolean; - project?: string; - reactNamespace?: string; - removeComments?: boolean; - rootDir?: string; - rootDirs?: string[]; - skipLibCheck?: boolean; - skipDefaultLibCheck?: boolean; - sourceMap?: boolean; - sourceRoot?: string; - strictNullChecks?: boolean; - suppressExcessPropertyErrors?: boolean; - suppressImplicitAnyIndexErrors?: boolean; - target?: ScriptTarget | ts.ScriptTarget; - traceResolution?: boolean; - types?: string[]; - typeRoots?: string[]; - [option: string]: CompilerOptionsValue | undefined; - } - namespace JsxEmit { - type None = "None"; - type Preserve = "Preserve"; - type React = "React"; - } - type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React; - namespace ModuleKind { - type None = "None"; - type CommonJS = "CommonJS"; - type AMD = "AMD"; - type UMD = "UMD"; - type System = "System"; - type ES6 = "ES6"; - type ES2015 = "ES2015"; - } - type ModuleKind = ModuleKind.None | ModuleKind.CommonJS | ModuleKind.AMD | ModuleKind.UMD | ModuleKind.System | ModuleKind.ES6 | ModuleKind.ES2015; - namespace ModuleResolutionKind { - type Classic = "Classic"; - type Node = "Node"; - } - type ModuleResolutionKind = ModuleResolutionKind.Classic | ModuleResolutionKind.Node; - namespace NewLineKind { - type Crlf = "Crlf"; - type Lf = "Lf"; - } - type NewLineKind = NewLineKind.Crlf | NewLineKind.Lf; - namespace ScriptTarget { - type ES3 = "ES3"; - type ES5 = "ES5"; - type ES6 = "ES6"; - type ES2015 = "ES2015"; - } - type ScriptTarget = ScriptTarget.ES3 | ScriptTarget.ES5 | ScriptTarget.ES6 | ScriptTarget.ES2015; -} +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + declare namespace ts { interface MapLike { [index: string]: T; } - interface Map extends MapLike { - __mapBrand: any; + interface Map { + get(key: string): T; + has(key: string): boolean; + set(key: string, value: T): this; + delete(key: string): boolean; + clear(): void; + forEach(action: (value: T, key: string) => void): void; + readonly size: number; + keys(): Iterator; + values(): Iterator; + entries(): Iterator<[string, T]>; + } + interface Iterator { + next(): { + value: T; + done: false; + } | { + value: never; + done: true; + }; } type Path = string & { __pathBrand: any; @@ -1025,172 +188,175 @@ declare namespace ts { ReadonlyKeyword = 130, RequireKeyword = 131, NumberKeyword = 132, - SetKeyword = 133, - StringKeyword = 134, - SymbolKeyword = 135, - TypeKeyword = 136, - UndefinedKeyword = 137, - FromKeyword = 138, - GlobalKeyword = 139, - OfKeyword = 140, - QualifiedName = 141, - ComputedPropertyName = 142, - TypeParameter = 143, - Parameter = 144, - Decorator = 145, - PropertySignature = 146, - PropertyDeclaration = 147, - MethodSignature = 148, - MethodDeclaration = 149, - Constructor = 150, - GetAccessor = 151, - SetAccessor = 152, - CallSignature = 153, - ConstructSignature = 154, - IndexSignature = 155, - TypePredicate = 156, - TypeReference = 157, - FunctionType = 158, - ConstructorType = 159, - TypeQuery = 160, - TypeLiteral = 161, - ArrayType = 162, - TupleType = 163, - UnionType = 164, - IntersectionType = 165, - ParenthesizedType = 166, - ThisType = 167, - TypeOperator = 168, - IndexedAccessType = 169, - MappedType = 170, - LiteralType = 171, - ObjectBindingPattern = 172, - ArrayBindingPattern = 173, - BindingElement = 174, - ArrayLiteralExpression = 175, - ObjectLiteralExpression = 176, - PropertyAccessExpression = 177, - ElementAccessExpression = 178, - CallExpression = 179, - NewExpression = 180, - TaggedTemplateExpression = 181, - TypeAssertionExpression = 182, - ParenthesizedExpression = 183, - FunctionExpression = 184, - ArrowFunction = 185, - DeleteExpression = 186, - TypeOfExpression = 187, - VoidExpression = 188, - AwaitExpression = 189, - PrefixUnaryExpression = 190, - PostfixUnaryExpression = 191, - BinaryExpression = 192, - ConditionalExpression = 193, - TemplateExpression = 194, - YieldExpression = 195, - SpreadElement = 196, - ClassExpression = 197, - OmittedExpression = 198, - ExpressionWithTypeArguments = 199, - AsExpression = 200, - NonNullExpression = 201, - TemplateSpan = 202, - SemicolonClassElement = 203, - Block = 204, - VariableStatement = 205, - EmptyStatement = 206, - ExpressionStatement = 207, - IfStatement = 208, - DoStatement = 209, - WhileStatement = 210, - ForStatement = 211, - ForInStatement = 212, - ForOfStatement = 213, - ContinueStatement = 214, - BreakStatement = 215, - ReturnStatement = 216, - WithStatement = 217, - SwitchStatement = 218, - LabeledStatement = 219, - ThrowStatement = 220, - TryStatement = 221, - DebuggerStatement = 222, - VariableDeclaration = 223, - VariableDeclarationList = 224, - FunctionDeclaration = 225, - ClassDeclaration = 226, - InterfaceDeclaration = 227, - TypeAliasDeclaration = 228, - EnumDeclaration = 229, - ModuleDeclaration = 230, - ModuleBlock = 231, - CaseBlock = 232, - NamespaceExportDeclaration = 233, - ImportEqualsDeclaration = 234, - ImportDeclaration = 235, - ImportClause = 236, - NamespaceImport = 237, - NamedImports = 238, - ImportSpecifier = 239, - ExportAssignment = 240, - ExportDeclaration = 241, - NamedExports = 242, - ExportSpecifier = 243, - MissingDeclaration = 244, - ExternalModuleReference = 245, - JsxElement = 246, - JsxSelfClosingElement = 247, - JsxOpeningElement = 248, - JsxClosingElement = 249, - JsxAttribute = 250, - JsxSpreadAttribute = 251, - JsxExpression = 252, - CaseClause = 253, - DefaultClause = 254, - HeritageClause = 255, - CatchClause = 256, - PropertyAssignment = 257, - ShorthandPropertyAssignment = 258, - SpreadAssignment = 259, - EnumMember = 260, - SourceFile = 261, - JSDocTypeExpression = 262, - JSDocAllType = 263, - JSDocUnknownType = 264, - JSDocArrayType = 265, - JSDocUnionType = 266, - JSDocTupleType = 267, - JSDocNullableType = 268, - JSDocNonNullableType = 269, - JSDocRecordType = 270, - JSDocRecordMember = 271, - JSDocTypeReference = 272, - JSDocOptionalType = 273, - JSDocFunctionType = 274, - JSDocVariadicType = 275, - JSDocConstructorType = 276, - JSDocThisType = 277, - JSDocComment = 278, - JSDocTag = 279, - JSDocAugmentsTag = 280, - JSDocParameterTag = 281, - JSDocReturnTag = 282, - JSDocTypeTag = 283, - JSDocTemplateTag = 284, - JSDocTypedefTag = 285, - JSDocPropertyTag = 286, - JSDocTypeLiteral = 287, - JSDocLiteralType = 288, - JSDocNullKeyword = 289, - JSDocUndefinedKeyword = 290, - JSDocNeverKeyword = 291, - SyntaxList = 292, - NotEmittedStatement = 293, - PartiallyEmittedExpression = 294, - MergeDeclarationMarker = 295, - EndOfDeclarationMarker = 296, - RawExpression = 297, - Count = 298, + ObjectKeyword = 133, + SetKeyword = 134, + StringKeyword = 135, + SymbolKeyword = 136, + TypeKeyword = 137, + UndefinedKeyword = 138, + FromKeyword = 139, + GlobalKeyword = 140, + OfKeyword = 141, + QualifiedName = 142, + ComputedPropertyName = 143, + TypeParameter = 144, + Parameter = 145, + Decorator = 146, + PropertySignature = 147, + PropertyDeclaration = 148, + MethodSignature = 149, + MethodDeclaration = 150, + Constructor = 151, + GetAccessor = 152, + SetAccessor = 153, + CallSignature = 154, + ConstructSignature = 155, + IndexSignature = 156, + TypePredicate = 157, + TypeReference = 158, + FunctionType = 159, + ConstructorType = 160, + TypeQuery = 161, + TypeLiteral = 162, + ArrayType = 163, + TupleType = 164, + UnionType = 165, + IntersectionType = 166, + ParenthesizedType = 167, + ThisType = 168, + TypeOperator = 169, + IndexedAccessType = 170, + MappedType = 171, + LiteralType = 172, + ObjectBindingPattern = 173, + ArrayBindingPattern = 174, + BindingElement = 175, + ArrayLiteralExpression = 176, + ObjectLiteralExpression = 177, + PropertyAccessExpression = 178, + ElementAccessExpression = 179, + CallExpression = 180, + NewExpression = 181, + TaggedTemplateExpression = 182, + TypeAssertionExpression = 183, + ParenthesizedExpression = 184, + FunctionExpression = 185, + ArrowFunction = 186, + DeleteExpression = 187, + TypeOfExpression = 188, + VoidExpression = 189, + AwaitExpression = 190, + PrefixUnaryExpression = 191, + PostfixUnaryExpression = 192, + BinaryExpression = 193, + ConditionalExpression = 194, + TemplateExpression = 195, + YieldExpression = 196, + SpreadElement = 197, + ClassExpression = 198, + OmittedExpression = 199, + ExpressionWithTypeArguments = 200, + AsExpression = 201, + NonNullExpression = 202, + MetaProperty = 203, + TemplateSpan = 204, + SemicolonClassElement = 205, + Block = 206, + VariableStatement = 207, + EmptyStatement = 208, + ExpressionStatement = 209, + IfStatement = 210, + DoStatement = 211, + WhileStatement = 212, + ForStatement = 213, + ForInStatement = 214, + ForOfStatement = 215, + ContinueStatement = 216, + BreakStatement = 217, + ReturnStatement = 218, + WithStatement = 219, + SwitchStatement = 220, + LabeledStatement = 221, + ThrowStatement = 222, + TryStatement = 223, + DebuggerStatement = 224, + VariableDeclaration = 225, + VariableDeclarationList = 226, + FunctionDeclaration = 227, + ClassDeclaration = 228, + InterfaceDeclaration = 229, + TypeAliasDeclaration = 230, + EnumDeclaration = 231, + ModuleDeclaration = 232, + ModuleBlock = 233, + CaseBlock = 234, + NamespaceExportDeclaration = 235, + ImportEqualsDeclaration = 236, + ImportDeclaration = 237, + ImportClause = 238, + NamespaceImport = 239, + NamedImports = 240, + ImportSpecifier = 241, + ExportAssignment = 242, + ExportDeclaration = 243, + NamedExports = 244, + ExportSpecifier = 245, + MissingDeclaration = 246, + ExternalModuleReference = 247, + JsxElement = 248, + JsxSelfClosingElement = 249, + JsxOpeningElement = 250, + JsxClosingElement = 251, + JsxAttribute = 252, + JsxAttributes = 253, + JsxSpreadAttribute = 254, + JsxExpression = 255, + CaseClause = 256, + DefaultClause = 257, + HeritageClause = 258, + CatchClause = 259, + PropertyAssignment = 260, + ShorthandPropertyAssignment = 261, + SpreadAssignment = 262, + EnumMember = 263, + SourceFile = 264, + Bundle = 265, + JSDocTypeExpression = 266, + JSDocAllType = 267, + JSDocUnknownType = 268, + JSDocArrayType = 269, + JSDocUnionType = 270, + JSDocTupleType = 271, + JSDocNullableType = 272, + JSDocNonNullableType = 273, + JSDocRecordType = 274, + JSDocRecordMember = 275, + JSDocTypeReference = 276, + JSDocOptionalType = 277, + JSDocFunctionType = 278, + JSDocVariadicType = 279, + JSDocConstructorType = 280, + JSDocThisType = 281, + JSDocComment = 282, + JSDocTag = 283, + JSDocAugmentsTag = 284, + JSDocParameterTag = 285, + JSDocReturnTag = 286, + JSDocTypeTag = 287, + JSDocTemplateTag = 288, + JSDocTypedefTag = 289, + JSDocPropertyTag = 290, + JSDocTypeLiteral = 291, + JSDocLiteralType = 292, + JSDocNullKeyword = 293, + JSDocUndefinedKeyword = 294, + JSDocNeverKeyword = 295, + SyntaxList = 296, + NotEmittedStatement = 297, + PartiallyEmittedExpression = 298, + MergeDeclarationMarker = 299, + EndOfDeclarationMarker = 300, + Count = 301, FirstAssignment = 57, LastAssignment = 69, FirstCompoundAssignment = 58, @@ -1198,15 +364,15 @@ declare namespace ts { FirstReservedWord = 71, LastReservedWord = 106, FirstKeyword = 71, - LastKeyword = 140, + LastKeyword = 141, FirstFutureReservedWord = 107, LastFutureReservedWord = 115, - FirstTypeNode = 156, - LastTypeNode = 171, + FirstTypeNode = 157, + LastTypeNode = 172, FirstPunctuation = 16, LastPunctuation = 69, FirstToken = 0, - LastToken = 140, + LastToken = 141, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -1215,11 +381,11 @@ declare namespace ts { LastTemplateToken = 15, FirstBinaryOperator = 26, LastBinaryOperator = 69, - FirstNode = 141, - FirstJSDocNode = 262, - LastJSDocNode = 288, - FirstJSDocTagNode = 278, - LastJSDocTagNode = 291, + FirstNode = 142, + FirstJSDocNode = 266, + LastJSDocNode = 295, + FirstJSDocTagNode = 282, + LastJSDocTagNode = 295, } const enum NodeFlags { None = 0, @@ -1274,34 +440,15 @@ declare namespace ts { IntrinsicIndexedElement = 2, IntrinsicElement = 3, } - const enum RelationComparisonResult { - Succeeded = 1, - Failed = 2, - FailedAndReported = 3, - } interface Node extends TextRange { kind: SyntaxKind; flags: NodeFlags; - modifierFlagsCache?: ModifierFlags; - transformFlags?: TransformFlags; decorators?: NodeArray; modifiers?: ModifiersArray; - id?: number; parent?: Node; - original?: Node; - startsOnNewLine?: boolean; - jsDoc?: JSDoc[]; - jsDocCache?: (JSDoc | JSDocTag)[]; - symbol?: Symbol; - locals?: SymbolTable; - nextContainer?: Node; - localSymbol?: Symbol; - flowNode?: FlowNode; - emitNode?: EmitNode; } interface NodeArray extends Array, TextRange { hasTrailingComma?: boolean; - transformFlags?: TransformFlags; } interface Token extends Node { kind: TKind; @@ -1317,27 +464,15 @@ declare namespace ts { type ReadonlyToken = Token; type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; type ModifiersArray = NodeArray; - const enum GeneratedIdentifierKind { - None = 0, - Auto = 1, - Loop = 2, - Unique = 3, - Node = 4, - } interface Identifier extends PrimaryExpression { kind: SyntaxKind.Identifier; text: string; originalKeywordKind?: SyntaxKind; - autoGenerateKind?: GeneratedIdentifierKind; - autoGenerateId?: number; isInJSDocNamespace?: boolean; } interface TransientIdentifier extends Identifier { resolvedSymbol: Symbol; } - interface GeneratedIdentifier extends Identifier { - autoGenerateKind: GeneratedIdentifierKind.Auto | GeneratedIdentifierKind.Loop | GeneratedIdentifierKind.Unique | GeneratedIdentifierKind.Node; - } interface QualifiedName extends Node { kind: SyntaxKind.QualifiedName; left: EntityName; @@ -1365,6 +500,7 @@ declare namespace ts { kind: SyntaxKind.TypeParameter; name: Identifier; constraint?: TypeNode; + default?: TypeNode; expression?: Expression; } interface SignatureDeclaration extends Declaration { @@ -1508,7 +644,7 @@ declare namespace ts { _typeNodeBrand: any; } interface KeywordTypeNode extends TypeNode { - kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; + kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; } interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; @@ -1585,7 +721,6 @@ declare namespace ts { } interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; - textSourceNode?: Identifier | StringLiteral | NumericLiteral; } interface Expression extends Node { _expressionBrand: any; @@ -1727,7 +862,6 @@ declare namespace ts { text: string; isUnterminated?: boolean; hasExtendedUnicodeEscape?: boolean; - isOctalLiteral?: boolean; } interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { _literalExpressionBrand: any; @@ -1769,7 +903,6 @@ declare namespace ts { interface ArrayLiteralExpression extends PrimaryExpression { kind: SyntaxKind.ArrayLiteralExpression; elements: NodeArray; - multiLine?: boolean; } interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; @@ -1780,7 +913,6 @@ declare namespace ts { } interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { kind: SyntaxKind.ObjectLiteralExpression; - multiLine?: boolean; } type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; @@ -1830,7 +962,7 @@ declare namespace ts { tag: LeftHandSideExpression; template: TemplateLiteral; } - type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; + type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; interface AsExpression extends Expression { kind: SyntaxKind.AsExpression; expression: Expression; @@ -1846,31 +978,38 @@ declare namespace ts { kind: SyntaxKind.NonNullExpression; expression: Expression; } + interface MetaProperty extends PrimaryExpression { + kind: SyntaxKind.MetaProperty; + keywordToken: SyntaxKind; + name: Identifier; + } interface JsxElement extends PrimaryExpression { kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; children: NodeArray; closingElement: JsxClosingElement; } + type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; + interface JsxAttributes extends ObjectLiteralExpressionBase { + } interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; tagName: JsxTagNameExpression; - attributes: NodeArray; + attributes: JsxAttributes; } interface JsxSelfClosingElement extends PrimaryExpression { kind: SyntaxKind.JsxSelfClosingElement; tagName: JsxTagNameExpression; - attributes: NodeArray; + attributes: JsxAttributes; } - type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; - type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - interface JsxAttribute extends Node { + interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; name: Identifier; initializer?: StringLiteral | JsxExpression; } - interface JsxSpreadAttribute extends Node { + interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; expression: Expression; } @@ -1880,6 +1019,7 @@ declare namespace ts { } interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; + dotDotDotToken?: Token; expression?: Expression; } interface JsxText extends Node { @@ -1892,16 +1032,6 @@ declare namespace ts { interface NotEmittedStatement extends Statement { kind: SyntaxKind.NotEmittedStatement; } - interface EndOfDeclarationMarker extends Statement { - kind: SyntaxKind.EndOfDeclarationMarker; - } - interface RawExpression extends PrimaryExpression { - kind: SyntaxKind.RawExpression; - text: string; - } - interface MergeDeclarationMarker extends Statement { - kind: SyntaxKind.MergeDeclarationMarker; - } interface EmptyStatement extends Statement { kind: SyntaxKind.EmptyStatement; } @@ -1912,11 +1042,10 @@ declare namespace ts { kind: SyntaxKind.MissingDeclaration; name?: Identifier; } - type BlockLike = SourceFile | Block | ModuleBlock | CaseClause; + type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; - multiLine?: boolean; } interface VariableStatement extends Statement { kind: SyntaxKind.VariableStatement; @@ -1926,9 +1055,6 @@ declare namespace ts { kind: SyntaxKind.ExpressionStatement; expression: Expression; } - interface PrologueDirective extends ExpressionStatement { - expression: StringLiteral; - } interface IfStatement extends Statement { kind: SyntaxKind.IfStatement; expression: Expression; @@ -2072,20 +1198,22 @@ declare namespace ts { name: Identifier; members: NodeArray; } - type ModuleBody = ModuleBlock | ModuleDeclaration; type ModuleName = Identifier | StringLiteral; + type ModuleBody = NamespaceBody | JSDocNamespaceBody; interface ModuleDeclaration extends DeclarationStatement { kind: SyntaxKind.ModuleDeclaration; name: Identifier | StringLiteral; - body?: ModuleBlock | NamespaceDeclaration | JSDocNamespaceDeclaration | Identifier; + body?: ModuleBody | JSDocNamespaceDeclaration | Identifier; } + type NamespaceBody = ModuleBlock | NamespaceDeclaration; interface NamespaceDeclaration extends ModuleDeclaration { name: Identifier; - body: ModuleBlock | NamespaceDeclaration; + body: NamespaceBody; } + type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; interface JSDocNamespaceDeclaration extends ModuleDeclaration { name: Identifier; - body: JSDocNamespaceDeclaration | Identifier; + body: JSDocNamespaceBody; } interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; @@ -2297,9 +1425,21 @@ declare namespace ts { ArrayMutation = 256, Referenced = 512, Shared = 1024, + PreFinally = 2048, + AfterFinally = 4096, Label = 12, Condition = 96, } + interface FlowLock { + locked?: boolean; + } + interface AfterFinallyFlow extends FlowNode, FlowLock { + antecedent: FlowNode; + } + interface PreFinallyFlow extends FlowNode { + antecedent: FlowNode; + lock: FlowLock; + } interface FlowNode { flags: FlowFlags; id?: number; @@ -2350,27 +1490,12 @@ declare namespace ts { typeReferenceDirectives: FileReference[]; languageVariant: LanguageVariant; isDeclarationFile: boolean; - renamedDependencies?: Map; hasNoDefaultLib: boolean; languageVersion: ScriptTarget; - scriptKind: ScriptKind; - externalModuleIndicator: Node; - commonJsModuleIndicator: Node; - identifiers: Map; - nodeCount: number; - identifierCount: number; - symbolCount: number; - parseDiagnostics: Diagnostic[]; - additionalSyntacticDiagnostics?: Diagnostic[]; - bindDiagnostics: Diagnostic[]; - lineMap: number[]; - classifiableNames?: Map; - resolvedModules: Map; - resolvedTypeReferenceDirectiveNames: Map; - imports: LiteralExpression[]; - moduleAugmentations: LiteralExpression[]; - patternAmbientModules?: PatternAmbientModule[]; - ambientModuleNames: string[]; + } + interface Bundle extends Node { + kind: SyntaxKind.Bundle; + sourceFiles: SourceFile[]; } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; @@ -2403,18 +1528,6 @@ declare namespace ts { getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; getTypeChecker(): TypeChecker; - getCommonSourceDirectory(): string; - getDiagnosticsProducingTypeChecker(): TypeChecker; - dropDiagnosticsProducingTypeChecker(): void; - getClassifiableNames(): Map; - getNodeCount(): number; - getIdentifierCount(): number; - getSymbolCount(): number; - getTypeCount(): number; - getFileProcessingDiagnostics(): DiagnosticCollection; - getResolvedTypeReferenceDirectives(): Map; - isSourceFileFromExternalLibrary(file: SourceFile): boolean; - structureIsReused?: boolean; } interface SourceMapSpan { emittedLine: number; @@ -2445,22 +1558,16 @@ declare namespace ts { emitSkipped: boolean; diagnostics: Diagnostic[]; emittedFiles: string[]; - sourceMaps: SourceMapData[]; - } - interface TypeCheckerHost { - getCompilerOptions(): CompilerOptions; - getSourceFiles(): SourceFile[]; - getSourceFile(fileName: string): SourceFile; - getResolvedTypeReferenceDirectives(): Map; } interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol; + getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; - getBaseTypes(type: InterfaceType): ObjectType[]; + getBaseTypes(type: InterfaceType): BaseType[]; getReturnTypeOfSignature(signature: Signature): Type; getNonNullableType(type: Type): Type; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; @@ -2470,6 +1577,8 @@ declare namespace ts { getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol; getTypeAtLocation(node: Node): Type; + getTypeFromTypeNode(node: TypeNode): Type; + signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string; typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; getSymbolDisplayBuilder(): SymbolDisplayBuilder; @@ -2487,24 +1596,18 @@ declare namespace ts { isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; - getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; + getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; - tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol; - getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - getGlobalDiagnostics(): Diagnostic[]; - getEmitResolver(sourceFile?: SourceFile, cancellationToken?: CancellationToken): EmitResolver; - getNodeCount(): number; - getIdentifierCount(): number; - getSymbolCount(): number; - getTypeCount(): number; + getApparentType(type: Type): Type; } 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, kind?: SignatureKind): void; + buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -2528,6 +1631,7 @@ declare namespace ts { clear(): void; trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; reportInaccessibleThisError(): void; + reportIllegalExtends(): void; } const enum TypeFormatFlags { None = 0, @@ -2542,21 +1646,14 @@ declare namespace ts { InFirstTypeArgument = 256, InTypeAlias = 512, UseTypeAliasValue = 1024, + SuppressAnyReturnType = 2048, + AddUndefined = 4096, } const enum SymbolFormatFlags { None = 0, WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, } - const enum SymbolAccessibility { - Accessible = 0, - NotAccessible = 1, - CannotBeNamed = 2, - } - const enum SyntheticSymbolKind { - UnionOrIntersection = 0, - Spread = 1, - } const enum TypePredicateKind { This = 0, Identifier = 1, @@ -2574,61 +1671,6 @@ declare namespace ts { parameterIndex: number; } type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; - type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; - interface SymbolVisibilityResult { - accessibility: SymbolAccessibility; - aliasesToMakeVisible?: AnyImportSyntax[]; - errorSymbolName?: string; - errorNode?: Node; - } - interface SymbolAccessibilityResult extends SymbolVisibilityResult { - errorModuleName?: string; - } - enum TypeReferenceSerializationKind { - Unknown = 0, - TypeWithConstructSignatureAndValue = 1, - VoidNullableOrNeverType = 2, - NumberLikeType = 3, - StringLikeType = 4, - BooleanType = 5, - ArrayLikeType = 6, - ESSymbolType = 7, - Promise = 8, - TypeWithCallSignature = 9, - ObjectType = 10, - } - interface EmitResolver { - hasGlobalName(name: string): boolean; - getReferencedExportContainer(node: Identifier, prefixLocals?: boolean): SourceFile | ModuleDeclaration | EnumDeclaration; - getReferencedImportDeclaration(node: Identifier): Declaration; - getReferencedDeclarationWithCollidingName(node: Identifier): Declaration; - isDeclarationWithCollidingName(node: Declaration): boolean; - isValueAliasDeclaration(node: Node): boolean; - isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; - isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; - getNodeCheckFlags(node: Node): NodeCheckFlags; - isDeclarationVisible(node: Declaration): boolean; - collectLinkedAliases(node: Identifier): Node[]; - isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; - writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - writeBaseConstructorTypeOfClass(node: ClassLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult; - isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult; - getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; - getReferencedValueDeclaration(reference: Identifier): Declaration; - getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind; - isOptionalParameter(node: ParameterDeclaration): boolean; - moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean; - isArgumentsLocalBinding(node: Identifier): boolean; - getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): SourceFile; - getTypeReferenceDirectivesForEntityName(name: EntityNameOrEntityNameExpression): string[]; - getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): string[]; - isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean; - writeLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration, writer: SymbolWriter): void; - getJsxFactoryEntity(): EntityName; - } const enum SymbolFlags { None = 0, FunctionScopedVariable = 1, @@ -2655,13 +1697,10 @@ declare namespace ts { ExportType = 2097152, ExportNamespace = 4194304, Alias = 8388608, - Instantiated = 16777216, - Merged = 33554432, - Transient = 67108864, - Prototype = 134217728, - SyntheticProperty = 268435456, - Optional = 536870912, - ExportStar = 1073741824, + Prototype = 16777216, + ExportStar = 33554432, + Optional = 67108864, + Transient = 134217728, Enum = 384, Variable = 3, Value = 107455, @@ -2695,7 +1734,6 @@ declare namespace ts { PropertyOrAccessor = 98308, Export = 7340032, ClassMember = 106500, - Classifiable = 788448, } interface Symbol { flags: SymbolFlags; @@ -2705,86 +1743,8 @@ declare namespace ts { members?: SymbolTable; exports?: SymbolTable; globalExports?: SymbolTable; - isReadonly?: boolean; - id?: number; - mergeId?: number; - parent?: Symbol; - exportSymbol?: Symbol; - constEnumOnlyModule?: boolean; - isReferenced?: boolean; - isReplaceableByMethod?: boolean; - isAssigned?: boolean; - } - interface SymbolLinks { - target?: Symbol; - type?: Type; - declaredType?: Type; - typeParameters?: TypeParameter[]; - inferredClassType?: Type; - instantiations?: Map; - mapper?: TypeMapper; - referenced?: boolean; - containingType?: UnionOrIntersectionType; - leftSpread?: Symbol; - rightSpread?: Symbol; - hasNonUniformType?: boolean; - isPartial?: boolean; - isDiscriminantProperty?: boolean; - resolvedExports?: SymbolTable; - exportsChecked?: boolean; - isDeclarationWithCollidingName?: boolean; - bindingElement?: BindingElement; - exportsSomeValue?: boolean; - } - interface TransientSymbol extends Symbol, SymbolLinks { } type SymbolTable = Map; - interface Pattern { - prefix: string; - suffix: string; - } - interface PatternAmbientModule { - pattern: Pattern; - symbol: Symbol; - } - const enum NodeCheckFlags { - TypeChecked = 1, - LexicalThis = 2, - CaptureThis = 4, - SuperInstance = 256, - SuperStatic = 512, - ContextChecked = 1024, - AsyncMethodWithSuper = 2048, - AsyncMethodWithSuperBinding = 4096, - CaptureArguments = 8192, - EnumValuesComputed = 16384, - LexicalModuleMergesWithClass = 32768, - LoopWithCapturedBlockScopedBinding = 65536, - CapturedBlockScopedBinding = 131072, - BlockScopedBindingInLoop = 262144, - ClassWithBodyScopedClassBinding = 524288, - BodyScopedClassBinding = 1048576, - NeedsLoopOutParameter = 2097152, - AssignmentsMarked = 4194304, - ClassWithConstructorReference = 8388608, - ConstructorReferenceInClass = 16777216, - } - interface NodeLinks { - flags?: NodeCheckFlags; - resolvedType?: Type; - resolvedSignature?: Signature; - resolvedSymbol?: Symbol; - resolvedIndexInfo?: IndexInfo; - maybeTypePredicate?: boolean; - enumMemberValue?: number; - isVisible?: boolean; - hasReportedStatementInAmbientContext?: boolean; - jsxFlags?: JsxFlags; - resolvedJsxType?: Type; - hasSuperCall?: boolean; - superCall?: ExpressionStatement; - switchTypes?: Type[]; - } const enum TypeFlags { Any = 1, String = 2, @@ -2806,49 +1766,36 @@ declare namespace ts { Intersection = 131072, Index = 262144, IndexedAccess = 524288, - FreshLiteral = 1048576, - ContainsWideningType = 2097152, - ContainsObjectLiteral = 4194304, - ContainsAnyFunctionType = 8388608, - Nullable = 6144, + NonPrimitive = 16777216, Literal = 480, StringOrNumberLiteral = 96, - DefinitelyFalsy = 7392, PossiblyFalsy = 7406, - Intrinsic = 16015, - Primitive = 8190, StringLike = 262178, NumberLike = 340, BooleanLike = 136, EnumLike = 272, UnionOrIntersection = 196608, StructuredType = 229376, - StructuredOrTypeParameter = 507904, + StructuredOrTypeVariable = 1032192, TypeVariable = 540672, - Narrowable = 1033215, - NotUnionOrUnit = 33281, - RequiresWidening = 6291456, - PropagatingFlags = 14680064, + Narrowable = 17810431, + NotUnionOrUnit = 16810497, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { flags: TypeFlags; - id: number; symbol?: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; aliasTypeArguments?: Type[]; } - interface IntrinsicType extends Type { - intrinsicName: string; - } interface LiteralType extends Type { text: string; freshType?: LiteralType; regularType?: LiteralType; } interface EnumType extends Type { - memberTypes: Map; + memberTypes: EnumLiteralType[]; } interface EnumLiteralType extends LiteralType { baseType: EnumType & UnionType; @@ -2864,6 +1811,7 @@ declare namespace ts { ObjectLiteral = 128, EvolvingArray = 256, ObjectLiteralPatternWithComputedProperties = 512, + NonPrimitive = 1024, ClassOrInterface = 3, } interface ObjectType extends Type { @@ -2874,9 +1822,8 @@ declare namespace ts { outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; thisType: TypeParameter; - resolvedBaseConstructorType?: Type; - resolvedBaseTypes: ObjectType[]; } + type BaseType = ObjectType | IntersectionType; interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; @@ -2889,59 +1836,24 @@ declare namespace ts { typeArguments: Type[]; } interface GenericType extends InterfaceType, TypeReference { - instantiations: Map; } interface UnionOrIntersectionType extends Type { types: Type[]; - resolvedProperties: SymbolTable; - resolvedIndexType: IndexType; - couldContainTypeVariables: boolean; } interface UnionType extends UnionOrIntersectionType { } interface IntersectionType extends UnionOrIntersectionType { } type StructuredType = ObjectType | UnionType | IntersectionType; - interface AnonymousType extends ObjectType { - target?: AnonymousType; - mapper?: TypeMapper; - } - interface MappedType extends ObjectType { - declaration: MappedTypeNode; - typeParameter?: TypeParameter; - constraintType?: Type; - templateType?: Type; - modifiersType?: Type; - mapper?: TypeMapper; - } interface EvolvingArrayType extends ObjectType { elementType: Type; finalArrayType?: Type; } - interface ResolvedType extends ObjectType, UnionOrIntersectionType { - members: SymbolTable; - properties: Symbol[]; - callSignatures: Signature[]; - constructSignatures: Signature[]; - stringIndexInfo?: IndexInfo; - numberIndexInfo?: IndexInfo; - } - interface FreshObjectLiteralType extends ResolvedType { - regularType: ResolvedType; - } - interface IterableOrIteratorType extends ObjectType, UnionType { - iterableElementType?: Type; - iteratorElementType?: Type; - } interface TypeVariable extends Type { - resolvedApparentType: Type; - resolvedIndexType: IndexType; } interface TypeParameter extends TypeVariable { constraint: Type; - target?: TypeParameter; - mapper?: TypeMapper; - isThisType?: boolean; + default?: Type; } interface IndexedAccessType extends TypeVariable { objectType: Type; @@ -2959,18 +1871,6 @@ declare namespace ts { declaration: SignatureDeclaration; typeParameters: TypeParameter[]; parameters: Symbol[]; - thisParameter?: Symbol; - resolvedReturnType: Type; - minArgumentCount: number; - hasRestParameter: boolean; - hasLiteralTypes: boolean; - target?: Signature; - mapper?: TypeMapper; - unionSignatures?: Signature[]; - erasedSignatureCache?: Signature; - isolatedSignatureType?: ObjectType; - typePredicate?: TypePredicate; - instantiations?: Map; } const enum IndexKind { String = 0, @@ -2981,36 +1881,8 @@ declare namespace ts { isReadonly: boolean; declaration?: SignatureDeclaration; } - interface TypeMapper { - (t: TypeParameter): Type; - mappedTypes?: Type[]; - instantiations?: Type[]; - context?: InferenceContext; - } - interface TypeInferences { - primary: Type[]; - secondary: Type[]; - topLevel: boolean; - isFixed: boolean; - } - interface InferenceContext { - signature: Signature; - inferUnionTypes: boolean; - inferences: TypeInferences[]; - inferredTypes: Type[]; - mapper?: TypeMapper; - failedTypeParameterIndex?: number; - } - const enum SpecialPropertyAssignmentKind { - None = 0, - ExportsProperty = 1, - ModuleExports = 2, - PrototypeProperty = 3, - ThisProperty = 4, - } - interface FileExtensionInfo { + interface JsFileExtensionInfo { extension: string; - scriptKind: ScriptKind; isMixedContent: boolean; } interface DiagnosticMessage { @@ -3042,36 +1914,31 @@ declare namespace ts { Classic = 1, NodeJs = 2, } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; + interface PluginImport { + name: string; + } + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[]; interface CompilerOptions { allowJs?: boolean; - allowNonTsExtensions?: boolean; allowSyntheticDefaultImports?: boolean; allowUnreachableCode?: boolean; allowUnusedLabels?: boolean; alwaysStrict?: boolean; baseUrl?: string; charset?: string; - configFilePath?: string; declaration?: boolean; declarationDir?: string; - diagnostics?: boolean; - extendedDiagnostics?: boolean; disableSizeLimit?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; experimentalDecorators?: boolean; forceConsistentCasingInFileNames?: boolean; - help?: boolean; importHelpers?: boolean; - init?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; isolatedModules?: boolean; jsx?: JsxEmit; lib?: string[]; - listEmittedFiles?: boolean; - listFiles?: boolean; locale?: string; mapRoot?: string; maxNodeModuleJsDepth?: number; @@ -3079,7 +1946,6 @@ declare namespace ts { moduleResolution?: ModuleResolutionKind; newLine?: NewLineKind; noEmit?: boolean; - noEmitForJsFiles?: boolean; noEmitHelpers?: boolean; noEmitOnError?: boolean; noErrorTruncation?: boolean; @@ -3098,7 +1964,6 @@ declare namespace ts { paths?: MapLike; preserveConstEnums?: boolean; project?: string; - pretty?: DiagnosticStyle; reactNamespace?: string; jsxFactory?: string; removeComments?: boolean; @@ -3109,16 +1974,12 @@ declare namespace ts { sourceMap?: boolean; sourceRoot?: string; strictNullChecks?: boolean; - stripInternal?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; - suppressOutputPathCheck?: boolean; target?: ScriptTarget; traceResolution?: boolean; types?: string[]; typeRoots?: string[]; - version?: boolean; - watch?: boolean; [option: string]: CompilerOptionsValue | undefined; } interface TypeAcquisition { @@ -3149,6 +2010,7 @@ declare namespace ts { None = 0, Preserve = 1, React = 2, + ReactNative = 3, } const enum NewLineKind { CarriageReturnLineFeed = 0, @@ -3164,6 +2026,7 @@ declare namespace ts { JSX = 2, TS = 3, TSX = 4, + External = 5, } const enum ScriptTarget { ES3 = 0, @@ -3178,10 +2041,6 @@ declare namespace ts { Standard = 0, JSX = 1, } - const enum DiagnosticStyle { - Simple = 0, - Pretty = 1, - } interface ParsedCommandLine { options: CompilerOptions; typeAcquisition?: TypeAcquisition; @@ -3199,156 +2058,6 @@ declare namespace ts { fileNames: string[]; wildcardDirectories: MapLike; } - interface CommandLineOptionBase { - name: string; - type: "string" | "number" | "boolean" | "object" | "list" | Map; - isFilePath?: boolean; - shortName?: string; - description?: DiagnosticMessage; - paramType?: DiagnosticMessage; - experimental?: boolean; - isTSConfigOnly?: boolean; - } - interface CommandLineOptionOfPrimitiveType extends CommandLineOptionBase { - type: "string" | "number" | "boolean"; - } - interface CommandLineOptionOfCustomType extends CommandLineOptionBase { - type: Map; - } - interface TsConfigOnlyOption extends CommandLineOptionBase { - type: "object"; - } - interface CommandLineOptionOfListType extends CommandLineOptionBase { - type: "list"; - element: CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType; - } - type CommandLineOption = CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType | TsConfigOnlyOption | CommandLineOptionOfListType; - const enum CharacterCodes { - nullCharacter = 0, - maxAsciiCharacter = 127, - lineFeed = 10, - carriageReturn = 13, - lineSeparator = 8232, - paragraphSeparator = 8233, - nextLine = 133, - space = 32, - nonBreakingSpace = 160, - enQuad = 8192, - emQuad = 8193, - enSpace = 8194, - emSpace = 8195, - threePerEmSpace = 8196, - fourPerEmSpace = 8197, - sixPerEmSpace = 8198, - figureSpace = 8199, - punctuationSpace = 8200, - thinSpace = 8201, - hairSpace = 8202, - zeroWidthSpace = 8203, - narrowNoBreakSpace = 8239, - ideographicSpace = 12288, - mathematicalSpace = 8287, - ogham = 5760, - _ = 95, - $ = 36, - _0 = 48, - _1 = 49, - _2 = 50, - _3 = 51, - _4 = 52, - _5 = 53, - _6 = 54, - _7 = 55, - _8 = 56, - _9 = 57, - a = 97, - b = 98, - c = 99, - d = 100, - e = 101, - f = 102, - g = 103, - h = 104, - i = 105, - j = 106, - k = 107, - l = 108, - m = 109, - n = 110, - o = 111, - p = 112, - q = 113, - r = 114, - s = 115, - t = 116, - u = 117, - v = 118, - w = 119, - x = 120, - y = 121, - z = 122, - A = 65, - B = 66, - C = 67, - D = 68, - E = 69, - F = 70, - G = 71, - H = 72, - I = 73, - J = 74, - K = 75, - L = 76, - M = 77, - N = 78, - O = 79, - P = 80, - Q = 81, - R = 82, - S = 83, - T = 84, - U = 85, - V = 86, - W = 87, - X = 88, - Y = 89, - Z = 90, - ampersand = 38, - asterisk = 42, - at = 64, - backslash = 92, - backtick = 96, - bar = 124, - caret = 94, - closeBrace = 125, - closeBracket = 93, - closeParen = 41, - colon = 58, - comma = 44, - dot = 46, - doubleQuote = 34, - equals = 61, - exclamation = 33, - greaterThan = 62, - hash = 35, - lessThan = 60, - minus = 45, - openBrace = 123, - openBracket = 91, - openParen = 40, - percent = 37, - plus = 43, - question = 63, - semicolon = 59, - singleQuote = 39, - slash = 47, - tilde = 126, - backspace = 8, - formFeed = 12, - byteOrderMark = 65279, - tab = 9, - verticalTab = 11, - } interface ModuleResolutionHost { fileExists(fileName: string): boolean; readFile(fileName: string): string; @@ -3375,7 +2084,6 @@ declare namespace ts { } interface ResolvedModuleWithFailedLookupLocations { resolvedModule: ResolvedModuleFull | undefined; - failedLookupLocations: string[]; } interface ResolvedTypeReferenceDirective { primary: boolean; @@ -3401,72 +2109,6 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; getEnvironmentVariable?(name: string): string; } - const enum TransformFlags { - None = 0, - TypeScript = 1, - ContainsTypeScript = 2, - ContainsJsx = 4, - ContainsESNext = 8, - ContainsES2017 = 16, - ContainsES2016 = 32, - ES2015 = 64, - ContainsES2015 = 128, - Generator = 256, - ContainsGenerator = 512, - DestructuringAssignment = 1024, - ContainsDestructuringAssignment = 2048, - ContainsDecorators = 4096, - ContainsPropertyInitializer = 8192, - ContainsLexicalThis = 16384, - ContainsCapturedLexicalThis = 32768, - ContainsLexicalThisInComputedPropertyName = 65536, - ContainsDefaultValueAssignments = 131072, - ContainsParameterPropertyAssignments = 262144, - ContainsSpread = 524288, - ContainsObjectSpread = 1048576, - ContainsRest = 524288, - ContainsObjectRest = 1048576, - ContainsComputedPropertyName = 2097152, - ContainsBlockScopedBinding = 4194304, - ContainsBindingPattern = 8388608, - ContainsYield = 16777216, - ContainsHoistedDeclarationOrCompletion = 33554432, - HasComputedFlags = 536870912, - AssertTypeScript = 3, - AssertJsx = 4, - AssertESNext = 8, - AssertES2017 = 16, - AssertES2016 = 32, - AssertES2015 = 192, - AssertGenerator = 768, - AssertDestructuringAssignment = 3072, - NodeExcludes = 536872257, - ArrowFunctionExcludes = 601249089, - FunctionExcludes = 601281857, - ConstructorExcludes = 601015617, - MethodOrAccessorExcludes = 601015617, - ClassExcludes = 539358529, - ModuleExcludes = 574674241, - TypeExcludes = -3, - ObjectLiteralExcludes = 540087617, - ArrayLiteralOrCallOrNewExcludes = 537396545, - VariableDeclarationListExcludes = 546309441, - ParameterExcludes = 536872257, - CatchClauseExcludes = 537920833, - BindingPatternExcludes = 537396545, - TypeScriptClassSyntaxMask = 274432, - ES2015FunctionSyntaxMask = 163840, - } - interface EmitNode { - annotatedNodes?: Node[]; - flags?: EmitFlags; - commentRange?: TextRange; - sourceMapRange?: TextRange; - tokenSourceMapRanges?: Map; - constantValue?: number; - externalHelpersModuleName?: Identifier; - helpers?: EmitHelper[]; - } const enum EmitFlags { SingleLine = 1, AdviseOnEmitNode = 2, @@ -3500,58 +2142,27 @@ declare namespace ts { readonly text: string; readonly priority?: number; } - const enum ExternalEmitHelpers { - Extends = 1, - Assign = 2, - Rest = 4, - Decorate = 8, - Metadata = 16, - Param = 32, - Awaiter = 64, - Generator = 128, - FirstEmitHelper = 1, - LastEmitHelper = 128, - } - const enum EmitContext { + const enum EmitHint { SourceFile = 0, Expression = 1, IdentifierName = 2, Unspecified = 3, } - interface EmitHost extends ScriptReferenceHost { - getSourceFiles(): SourceFile[]; - isSourceFileFromExternalLibrary(file: SourceFile): boolean; - getCommonSourceDirectory(): string; - getCanonicalFileName(fileName: string): string; - getNewLine(): string; - isEmitBlocked(emitFileName: string): boolean; - writeFile: WriteFileCallback; + interface Printer { + printNode(hint: EmitHint, node: Node, sourceFile: SourceFile): string; + printFile(sourceFile: SourceFile): string; + printBundle(bundle: Bundle): string; } - interface TransformationContext { - getCompilerOptions(): CompilerOptions; - getEmitResolver(): EmitResolver; - getEmitHost(): EmitHost; - startLexicalEnvironment(): void; - suspendLexicalEnvironment(): void; - resumeLexicalEnvironment(): void; - endLexicalEnvironment(): Statement[]; - hoistFunctionDeclaration(node: FunctionDeclaration): void; - hoistVariableDeclaration(node: Identifier): void; - requestEmitHelper(helper: EmitHelper): void; - readEmitHelpers(): EmitHelper[] | undefined; - enableSubstitution(kind: SyntaxKind): void; - isSubstitutionEnabled(node: Node): boolean; - onSubstituteNode?: (emitContext: EmitContext, node: Node) => Node; - enableEmitNotification(kind: SyntaxKind): void; - isEmitNotificationEnabled(node: Node): boolean; - onEmitNode?: (emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) => void; + interface PrintHandlers { + hasGlobalName?(name: string): boolean; + onEmitNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + onSubstituteNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; } - interface TransformationResult { - transformed: SourceFile[]; - emitNodeWithSubstitution(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; - emitNodeWithNotification(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; + interface PrinterOptions { + target?: ScriptTarget; + removeComments?: boolean; + newLine?: NewLineKind; } - type Transformer = (context: TransformationContext) => (node: SourceFile) => SourceFile; interface TextSpan { start: number; length: number; @@ -3560,235 +2171,15 @@ declare namespace ts { span: TextSpan; newLength: number; } - interface DiagnosticCollection { - add(diagnostic: Diagnostic): void; - getGlobalDiagnostics(): Diagnostic[]; - getDiagnostics(fileName?: string): Diagnostic[]; - getModificationCount(): number; - reattachFileDiagnostics(newFile: SourceFile): void; - } interface SyntaxList extends Node { _children: Node[]; } } declare namespace ts { - const timestamp: () => number; -} -declare namespace ts.performance { - function mark(markName: string): void; - function measure(measureName: string, startMarkName?: string, endMarkName?: string): void; - function getCount(markName: string): number; - function getDuration(measureName: string): number; - function forEachMeasure(cb: (measureName: string, duration: number) => void): void; - function enable(): void; - function disable(): void; -} -declare namespace ts { - const version = "2.2.0"; -} -declare namespace ts { - const enum Ternary { - False = 0, - Maybe = 1, - True = -1, - } - const collator: { - compare(a: string, b: string): number; - }; - function createMap(template?: MapLike): Map; - function createFileMap(keyMapper?: (key: string) => string): FileMap; - function toPath(fileName: string, basePath: string, getCanonicalFileName: (path: string) => string): Path; - const enum Comparison { - LessThan = -1, - EqualTo = 0, - GreaterThan = 1, - } - function forEach(array: T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined; - function zipWith(arrayA: T[], arrayB: U[], callback: (a: T, b: U, index: number) => void): void; - function every(array: T[], callback: (element: T, index: number) => boolean): boolean; - function find(array: T[], predicate: (element: T, index: number) => boolean): T | undefined; - function findMap(array: T[], callback: (element: T, index: number) => U | undefined): U; - function contains(array: T[], value: T): boolean; - function indexOf(array: T[], value: T): number; - function indexOfAnyCharCode(text: string, charCodes: number[], start?: number): number; - function countWhere(array: T[], predicate: (x: T, i: number) => boolean): number; - function filter(array: T[], f: (x: T) => x is U): U[]; - function filter(array: T[], f: (x: T) => boolean): T[]; - function removeWhere(array: T[], f: (x: T) => boolean): boolean; - function filterMutate(array: T[], f: (x: T) => boolean): void; - function map(array: T[], f: (x: T, i: number) => U): U[]; - function sameMap(array: T[], f: (x: T, i: number) => T): T[]; - function flatten(array: (T | T[])[]): T[]; - function flatMap(array: T[], mapfn: (x: T, i: number) => U | U[]): U[]; - function span(array: T[], f: (x: T, i: number) => boolean): [T[], T[]]; - function spanMap(array: T[], keyfn: (x: T, i: number) => K, mapfn: (chunk: T[], key: K, start: number, end: number) => U): U[]; - function mapObject(object: MapLike, f: (key: string, x: T) => [string, U]): MapLike; - function some(array: T[], predicate?: (value: T) => boolean): boolean; - function concatenate(array1: T[], array2: T[]): T[]; - function deduplicate(array: T[], areEqual?: (a: T, b: T) => boolean): T[]; - function arrayIsEqualTo(array1: ReadonlyArray, array2: ReadonlyArray, equaler?: (a: T, b: T) => boolean): boolean; - function changesAffectModuleResolution(oldOptions: CompilerOptions, newOptions: CompilerOptions): boolean; - function compact(array: T[]): T[]; - function relativeComplement(arrayA: T[] | undefined, arrayB: T[] | undefined, comparer?: (x: T, y: T) => Comparison, offsetA?: number, offsetB?: number): T[] | undefined; - function sum(array: any[], prop: string): number; - function append(to: T[] | undefined, value: T | undefined): T[] | undefined; - function addRange(to: T[] | undefined, from: T[] | undefined): T[] | undefined; - function stableSort(array: T[], comparer?: (x: T, y: T) => Comparison): T[]; - function rangeEquals(array1: T[], array2: T[], pos: number, end: number): boolean; - function firstOrUndefined(array: T[]): T; - function lastOrUndefined(array: T[]): T; - function singleOrUndefined(array: T[]): T; - function singleOrMany(array: T[]): T | T[]; - function replaceElement(array: T[], index: number, value: T): T[]; - function binarySearch(array: T[], value: T, comparer?: (v1: T, v2: T) => number, offset?: number): number; - function reduceLeft(array: T[], f: (memo: U, value: T, i: number) => U, initial: U, start?: number, count?: number): U; - function reduceLeft(array: T[], f: (memo: T, value: T, i: number) => T): T; - function reduceRight(array: T[], f: (memo: U, value: T, i: number) => U, initial: U, start?: number, count?: number): U; - function reduceRight(array: T[], f: (memo: T, value: T, i: number) => T): T; - function hasProperty(map: MapLike, key: string): boolean; - function getProperty(map: MapLike, key: string): T | undefined; - function getOwnKeys(map: MapLike): string[]; - function forEachProperty(map: Map, callback: (value: T, key: string) => U): U; - function someProperties(map: Map, predicate?: (value: T, key: string) => boolean): boolean; - function copyProperties(source: Map, target: MapLike): void; - function appendProperty(map: Map, key: string | number, value: T): Map; - function assign, T2, T3>(t: T1, arg1: T2, arg2: T3): T1 & T2 & T3; - function assign, T2>(t: T1, arg1: T2): T1 & T2; - function assign>(t: T1, ...args: any[]): any; - function reduceProperties(map: Map, callback: (aggregate: U, value: T, key: string) => U, initial: U): U; - function equalOwnProperties(left: MapLike, right: MapLike, equalityComparer?: (left: T, right: T) => boolean): boolean; - function arrayToMap(array: T[], makeKey: (value: T) => string): Map; - function arrayToMap(array: T[], makeKey: (value: T) => string, makeValue: (value: T) => U): Map; - function isEmpty(map: Map): boolean; - function cloneMap(map: Map): Map; - function clone(object: T): T; - function extend(first: T1, second: T2): T1 & T2; - function multiMapAdd(map: Map, key: string | number, value: V): V[]; - function multiMapRemove(map: Map, key: string, value: V): void; - function isArray(value: any): value is any[]; - function noop(): void; - function notImplemented(): never; - function memoize(callback: () => T): () => T; - function chain(...args: ((t: T) => (u: U) => U)[]): (t: T) => (u: U) => U; - function compose(...args: ((t: T) => T)[]): (t: T) => T; - let localizedDiagnosticMessages: Map; - function getLocaleSpecificMessage(message: DiagnosticMessage): string; - function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic; - function formatMessage(_dummy: any, message: DiagnosticMessage): string; - function createCompilerDiagnostic(message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic; - function createCompilerDiagnosticFromMessageChain(chain: DiagnosticMessageChain): Diagnostic; - function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain; - function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain; - function compareValues(a: T, b: T): Comparison; - function compareStrings(a: string, b: string, ignoreCase?: boolean): Comparison; - function compareStringsCaseInsensitive(a: string, b: string): Comparison; - function compareDiagnostics(d1: Diagnostic, d2: Diagnostic): Comparison; - function sortAndDeduplicateDiagnostics(diagnostics: Diagnostic[]): Diagnostic[]; - function deduplicateSortedDiagnostics(diagnostics: Diagnostic[]): Diagnostic[]; - function normalizeSlashes(path: string): string; - function getRootLength(path: string): number; - const directorySeparator = "/"; - function normalizePath(path: string): string; - function pathEndsWithDirectorySeparator(path: string): boolean; - function getDirectoryPath(path: Path): Path; - function getDirectoryPath(path: string): string; - function isUrl(path: string): boolean; - function isExternalModuleNameRelative(moduleName: string): boolean; - function getEmitScriptTarget(compilerOptions: CompilerOptions): ScriptTarget; - function getEmitModuleKind(compilerOptions: CompilerOptions): ModuleKind; - function getEmitModuleResolutionKind(compilerOptions: CompilerOptions): ModuleResolutionKind; - function hasZeroOrOneAsteriskCharacter(str: string): boolean; - function isRootedDiskPath(path: string): boolean; - function convertToRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string; - function getNormalizedPathComponents(path: string, currentDirectory: string): string[]; - function getNormalizedAbsolutePath(fileName: string, currentDirectory: string): string; - function getNormalizedPathFromPathComponents(pathComponents: string[]): string; - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean): string; - function getBaseFileName(path: string): string; - function combinePaths(path1: string, path2: string): string; - function removeTrailingDirectorySeparator(path: string): string; - function ensureTrailingDirectorySeparator(path: string): string; - function comparePaths(a: string, b: string, currentDirectory: string, ignoreCase?: boolean): Comparison; - function containsPath(parent: string, child: string, currentDirectory: string, ignoreCase?: boolean): boolean; - function startsWith(str: string, prefix: string): boolean; - function endsWith(str: string, suffix: string): boolean; - function hasExtension(fileName: string): boolean; - function fileExtensionIs(path: string, extension: string): boolean; - function fileExtensionIsAny(path: string, extensions: string[]): boolean; - function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude"): string; - function isImplicitGlob(lastPathComponent: string): boolean; - interface FileSystemEntries { - files: string[]; - directories: string[]; - } - interface FileMatcherPatterns { - includeFilePattern: string; - includeDirectoryPattern: string; - excludePattern: string; - basePaths: string[]; - } - function getFileMatcherPatterns(path: string, excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns; - function matchFiles(path: string, extensions: string[], excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string, getFileSystemEntries: (path: string) => FileSystemEntries): string[]; - function ensureScriptKind(fileName: string, scriptKind?: ScriptKind): ScriptKind; - function getScriptKindFromFileName(fileName: string): ScriptKind; - const supportedTypeScriptExtensions: string[]; - const supportedTypescriptExtensionsForExtractExtension: string[]; - const supportedJavascriptExtensions: string[]; - function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: FileExtensionInfo[]): string[]; - function hasJavaScriptFileExtension(fileName: string): boolean; - function hasTypeScriptFileExtension(fileName: string): boolean; - function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: FileExtensionInfo[]): boolean; - const enum ExtensionPriority { - TypeScriptFiles = 0, - DeclarationAndJavaScriptFiles = 2, - Limit = 5, - Highest = 0, - Lowest = 2, - } - function getExtensionPriority(path: string, supportedExtensions: string[]): ExtensionPriority; - function adjustExtensionPriority(extensionPriority: ExtensionPriority): ExtensionPriority; - function getNextLowestExtensionPriority(extensionPriority: ExtensionPriority): ExtensionPriority; - function removeFileExtension(path: string): string; - function tryRemoveExtension(path: string, extension: string): string | undefined; - function removeExtension(path: string, extension: string): string; - function changeExtension(path: T, newExtension: string): T; - interface ObjectAllocator { - getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node; - getTokenConstructor(): new (kind: TKind, pos?: number, end?: number) => Token; - getIdentifierConstructor(): new (kind: SyntaxKind.Identifier, pos?: number, end?: number) => Identifier; - getSourceFileConstructor(): new (kind: SyntaxKind.SourceFile, pos?: number, end?: number) => SourceFile; - getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol; - getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type; - getSignatureConstructor(): new (checker: TypeChecker) => Signature; - } - let objectAllocator: ObjectAllocator; - const enum AssertionLevel { - None = 0, - Normal = 1, - Aggressive = 2, - VeryAggressive = 3, - } - namespace Debug { - let currentAssertionLevel: AssertionLevel; - function shouldAssert(level: AssertionLevel): boolean; - function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void; - function fail(message?: string): void; - } - function orderedRemoveItem(array: T[], item: T): boolean; - function orderedRemoveItemAt(array: T[], index: number): void; - function unorderedRemoveItemAt(array: T[], index: number): void; - function unorderedRemoveItem(array: T[], item: T): void; - function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): (fileName: string) => string; - function matchPatternOrExact(patternStrings: string[], candidate: string): string | Pattern | undefined; - function patternText({prefix, suffix}: Pattern): string; - function matchedText(pattern: Pattern, candidate: string): string; - function findBestPatternMatch(values: T[], getPattern: (value: T) => Pattern, candidate: string): T | undefined; - function tryParsePattern(pattern: string): Pattern | undefined; - function positionIsSynthesized(pos: number): boolean; - function extensionIsTypeScript(ext: Extension): boolean; - function extensionFromPath(path: string): Extension; - function tryGetExtensionFromPath(path: string): Extension | undefined; + const version = "2.3.0"; } +declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; +declare function clearTimeout(handle: any): void; declare namespace ts { type FileWatcherCallback = (fileName: string, removed?: boolean) => void; type DirectoryWatcherCallback = (fileName: string) => void; @@ -3820,8 +2211,6 @@ declare namespace ts { getMemoryUsage?(): number; exit(exitCode?: number): void; realpath?(path: string): string; - getEnvironmentVariable(name: string): string; - tryEnableSourceMapsForHost?(): void; setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; clearTimeout?(timeoutId: any): void; } @@ -3834,4863 +2223,10 @@ declare namespace ts { } let sys: System; } -declare namespace ts { - const Diagnostics: { - Unterminated_string_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Identifier_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_file_cannot_have_a_reference_to_itself: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Trailing_comma_not_allowed: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Asterisk_Slash_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unexpected_token: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_parameter_must_be_last_in_a_parameter_list: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_cannot_have_question_mark_and_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_required_parameter_cannot_follow_an_optional_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_cannot_have_a_rest_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_cannot_have_an_accessibility_modifier: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_cannot_have_a_question_mark: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_must_have_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_must_have_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_type_must_be_string_or_number: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Accessibility_modifier_already_seen: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_must_precede_1_modifier: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_already_seen: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_class_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_must_be_followed_by_an_argument_list_or_member_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_ambient_modules_can_use_quoted_names: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Statements_are_not_allowed_in_ambient_contexts: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializers_are_not_allowed_in_ambient_contexts: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_be_used_in_an_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_be_used_with_a_class_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_be_used_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_data_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_module_or_namespace_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_0_modifier_cannot_be_used_with_an_interface_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_parameter_cannot_be_optional: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_parameter_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_must_have_exactly_one_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_cannot_have_an_optional_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_parameter_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_cannot_have_rest_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_get_accessor_cannot_have_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_async_function_or_method_must_have_a_valid_awaitable_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Operand_for_await_does_not_have_a_valid_callable_then_member: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_member_must_have_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_assignment_cannot_be_used_in_a_namespace: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_type_member: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_an_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_0_modifier_cannot_be_used_with_an_import_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_reference_directive_syntax: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_accessor_cannot_be_declared_in_an_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_constructor_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameters_cannot_appear_on_a_constructor_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_annotation_cannot_appear_on_a_constructor_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_accessor_cannot_have_type_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_cannot_have_a_return_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_must_have_exactly_one_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_argument_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_use_of_0_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - with_statements_are_not_allowed_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - delete_cannot_be_called_on_an_identifier_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Jump_target_cannot_cross_function_boundary: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_return_statement_can_only_be_used_within_a_function_body: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_label_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_assignment_cannot_have_modifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Octal_literals_are_not_allowed_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_tuple_type_element_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_declaration_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Digit_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Hexadecimal_digit_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unexpected_end_of_text: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_character: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Declaration_or_statement_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Statement_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - case_or_default_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_or_signature_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_member_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_declaration_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Argument_expression_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_assignment_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_or_comma_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_declaration_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_declaration_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_argument_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - String_literal_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Line_break_not_permitted_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - or_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Declaration_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_declarations_in_a_namespace_cannot_reference_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_name_0_differs_from_already_included_file_name_1_only_in_casing: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_declarations_must_be_initialized: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_declarations_can_only_be_declared_inside_a_block: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - let_declarations_can_only_be_declared_inside_a_block: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unterminated_template_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unterminated_regular_expression_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_object_member_cannot_be_declared_optional: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_yield_expression_is_only_allowed_in_a_generator_body: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Computed_property_names_are_not_allowed_in_enums: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_comma_expression_is_not_allowed_in_a_computed_property_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - extends_clause_already_seen: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - extends_clause_must_precede_implements_clause: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Classes_can_only_extend_a_single_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - implements_clause_already_seen: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Interface_declaration_cannot_have_implements_clause: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Binary_digit_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Octal_digit_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unexpected_token_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_destructuring_pattern_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Array_element_destructuring_pattern_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_destructuring_declaration_must_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_implementation_cannot_be_declared_in_ambient_contexts: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Modifiers_cannot_appear_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Merge_conflict_marker_encountered: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_element_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_parameter_property_may_not_be_declared_using_a_binding_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_import_declaration_cannot_have_modifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_has_no_default_export: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_declaration_cannot_have_modifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Export_declarations_are_not_permitted_in_a_namespace: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Catch_clause_variable_cannot_have_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Catch_clause_variable_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unterminated_Unicode_escape_sequence: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Line_terminator_not_permitted_before_arrow: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Decorators_are_not_valid_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_declaration_without_the_default_modifier_must_have_a_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Identifier_expected_0_is_a_reserved_word_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Export_assignment_is_not_supported_when_module_flag_is_system: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generators_are_not_allowed_in_an_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_overload_signature_cannot_be_declared_as_a_generator: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_tag_already_specified: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Signature_0_must_have_a_type_predicate: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_parameter_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_predicate_0_is_not_assignable_to_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_is_not_in_the_same_position_as_parameter_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_predicate_cannot_reference_a_rest_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_assignment_can_only_be_used_in_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_import_declaration_can_only_be_used_in_a_namespace_or_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_declaration_can_only_be_used_in_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_be_used_with_1_modifier: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Abstract_methods_can_only_appear_within_an_abstract_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_interface_property_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_literal_property_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_member_cannot_have_the_0_keyword: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_decorator_can_only_decorate_a_method_implementation_not_an_overload: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - with_statements_are_not_allowed_in_an_async_function_block: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - await_expression_is_only_allowed_within_an_async_function: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_body_of_an_if_statement_cannot_be_the_empty_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_module_exports_may_only_appear_in_module_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_module_exports_may_only_appear_in_declaration_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_module_exports_may_only_appear_at_top_level: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_parameter_property_cannot_be_declared_using_a_rest_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_abstract_accessor_cannot_have_an_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Static_members_cannot_reference_class_type_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Circular_definition_of_import_alias_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_has_no_exported_member_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_is_not_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_module_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_recursively_references_itself_as_a_base_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_may_only_extend_another_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_interface_may_only_extend_a_class_or_another_interface: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_has_a_circular_constraint: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generic_type_0_requires_1_type_argument_s: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_generic: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_type_0_must_be_a_class_or_interface_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_type_0_must_have_1_type_parameter_s: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_global_type_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Named_property_0_of_types_1_and_2_are_not_identical: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Interface_0_cannot_simultaneously_extend_types_1_and_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Excessive_stack_depth_comparing_types_0_and_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_assignable_to_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_redeclare_exported_variable_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_missing_in_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_private_in_type_1_but_not_in_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Types_of_property_0_are_incompatible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_optional_in_type_1_but_required_in_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Types_of_parameters_0_and_1_are_incompatible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Index_signature_is_missing_in_type_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Index_signatures_are_incompatible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_a_module_or_namespace_body: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_current_location: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_constructor_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_a_static_property_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_can_only_be_referenced_in_a_derived_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_cannot_be_referenced_in_constructor_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_does_not_exist_on_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_private_and_only_accessible_within_class_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_does_not_satisfy_the_constraint_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Supplied_parameters_do_not_match_any_signature_of_call_target: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Untyped_function_calls_may_not_accept_type_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_a_void_function_can_be_called_with_the_new_keyword: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_cannot_be_converted_to_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Operator_0_cannot_be_applied_to_types_1_and_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_parameter_property_is_only_allowed_in_a_constructor_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_parameter_must_be_of_an_array_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_cannot_be_referenced_in_its_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_string_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_number_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Constructors_for_derived_classes_must_contain_a_super_call: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_get_accessor_must_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Getter_and_setter_accessors_do_not_agree_in_visibility: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - get_and_set_accessor_must_have_the_same_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_signature_with_an_implementation_cannot_use_a_string_literal_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_exported_or_non_exported: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_ambient_or_non_ambient: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_public_private_or_protected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_optional_or_required: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_overload_must_be_static: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_overload_must_not_be_static: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_implementation_name_must_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Constructor_implementation_is_missing: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_implementation_is_missing_or_not_immediately_following_the_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Multiple_constructor_implementations_are_not_allowed: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_function_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signature_is_not_compatible_with_function_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Declaration_name_conflicts_with_built_in_global_identifier_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Setters_cannot_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_incorrectly_extends_base_class_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_static_side_0_incorrectly_extends_base_class_static_side_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_incorrectly_implements_interface_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_may_only_implement_another_class_or_interface: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Interface_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - All_declarations_of_0_must_have_identical_type_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Interface_0_incorrectly_extends_interface_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Ambient_module_declaration_cannot_specify_relative_module_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_declaration_conflicts_with_local_declaration_of_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Types_have_separate_declarations_of_a_private_property_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_protected_in_type_1_but_public_in_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Block_scoped_variable_0_used_before_its_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_redeclare_block_scoped_variable_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_enum_member_cannot_have_a_numeric_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_0_is_used_before_being_assigned: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_alias_0_circularly_references_itself: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_alias_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_AMD_module_cannot_have_multiple_name_assignments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_has_no_property_1_and_no_string_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_has_no_property_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_an_array_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_element_must_be_last_in_a_destructuring_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_a_computed_property_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_cannot_be_referenced_in_a_computed_property_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_global_value_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_0_operator_cannot_be_applied_to_type_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_declarations_must_all_be_const_or_non_const: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - In_const_enum_declarations_member_initializer_must_be_constant_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_const_enum_member_can_only_be_accessed_using_a_string_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_does_not_exist_on_const_enum_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Export_declaration_conflicts_with_exported_declaration_of_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_iterator_must_have_a_next_method: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_redeclare_identifier_0_in_catch_clause: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_an_array_type_or_a_string_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_element_cannot_contain_a_binding_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_namespace_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_generator_cannot_have_a_void_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_a_constructor_function_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - No_base_constructor_has_the_specified_number_of_type_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Base_constructor_return_type_0_is_not_a_class_or_interface_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Base_constructors_must_all_have_the_same_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_create_an_instance_of_the_abstract_class_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_abstract_or_non_abstract: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Classes_containing_abstract_methods_must_be_marked_abstract: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - All_declarations_of_an_abstract_method_must_be_consecutive: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - yield_expressions_cannot_be_used_in_a_parameter_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - await_expressions_cannot_be_used_in_a_parameter_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_module_cannot_have_multiple_default_exports: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_incompatible_with_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_is_possibly_null: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_is_possibly_undefined: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_is_possibly_null_or_undefined: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_function_returning_never_cannot_have_a_reachable_end_point: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_type_0_has_members_with_initializers_that_are_not_literals: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_cannot_be_used_to_index_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_has_no_matching_index_signature_for_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_cannot_be_used_as_an_index_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_assign_to_0_because_it_is_not_a_variable: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Index_signature_in_type_0_only_permits_reading: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_attributes_type_0_may_not_be_a_union_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_in_type_1_is_not_assignable_to_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_global_type_JSX_0_may_not_have_more_than_one_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_emit_namespaced_JSX_elements_in_React: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_expressions_must_have_one_parent_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_provides_no_match_for_the_signature_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_name_0_Did_you_mean_the_static_member_1_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_name_0_Did_you_mean_the_instance_member_this_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_module_name_in_augmentation_module_0_cannot_be_found: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exports_and_export_assignments_are_not_permitted_in_module_augmentations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_assign_a_0_constructor_type_to_a_1_constructor_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_extend_a_class_0_Class_constructor_is_marked_as_private: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Accessors_must_both_be_abstract_or_non_abstract: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_comparable_to_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_this_parameter_must_be_the_first_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_constructor_cannot_have_a_this_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - get_and_set_accessor_must_have_the_same_this_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_this_types_of_each_signature_are_incompatible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - All_declarations_of_0_must_have_identical_modifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_type_definition_file_for_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_extend_an_interface_0_Did_you_mean_implements: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_must_be_declared_after_its_base_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Namespace_0_has_no_exported_member_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Left_side_of_comma_operator_is_unused_and_has_no_side_effects: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Spread_types_may_only_be_created_from_object_types: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Rest_types_may_only_be_created_from_object_types: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_declaration_0_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_variable_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_property_0_of_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_exported_function_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_exported_function_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_type_alias_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Default_export_of_the_module_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_current_host_does_not_support_the_0_option: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_the_common_subdirectory_path_for_the_input_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_read_file_0_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unsupported_file_encoding: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Failed_to_parse_file_0_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unknown_compiler_option_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Compiler_option_0_requires_a_value_of_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Could_not_write_file_0_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_cannot_be_specified_without_specifying_option_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_cannot_be_specified_with_option_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_tsconfig_json_file_is_already_defined_at_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_write_file_0_because_it_would_overwrite_input_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_specified_path_does_not_exist_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_paths_cannot_be_used_without_specifying_baseUrl_option: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Pattern_0_can_have_at_most_one_Asterisk_character: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Substitutions_for_pattern_0_should_be_an_array: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Substitutions_for_pattern_0_shouldn_t_be_an_empty_array: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Concatenate_and_emit_output_to_single_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generates_corresponding_d_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Watch_input_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Redirect_output_structure_to_the_directory: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_erase_const_enum_declarations_in_generated_code: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_outputs_if_any_errors_were_reported: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_comments_to_output: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_outputs: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Skip_type_checking_of_declaration_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Print_this_message: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Print_the_compiler_s_version: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Compile_the_project_in_the_given_directory: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Syntax_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - options: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Examples_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Options_Colon: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Version_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Insert_command_line_options_and_files_from_a_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_change_detected_Starting_incremental_compilation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - KIND: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - FILE: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - VERSION: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - LOCATION: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - DIRECTORY: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - STRATEGY: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Compilation_complete_Watching_for_file_changes: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generates_corresponding_map_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Compiler_option_0_expects_an_argument: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unterminated_quoted_string_in_response_file_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Argument_for_0_option_must_be_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unsupported_locale_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_open_file_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Corrupted_locale_file_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_not_found: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - NEWLINE: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_can_only_be_specified_in_tsconfig_json_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enables_experimental_support_for_ES7_decorators: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enables_experimental_support_for_emitting_type_metadata_for_decorators: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enables_experimental_support_for_ES7_async_functions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Successfully_created_a_tsconfig_json_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Suppress_excess_property_checks_for_object_literals: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Stylize_errors_and_messages_using_color_and_context_experimental: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_report_errors_on_unused_labels: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Report_error_when_not_all_code_paths_in_function_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Report_errors_for_fallthrough_cases_in_switch_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_report_errors_on_unreachable_code: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Disallow_inconsistently_cased_references_to_the_same_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_library_files_to_be_included_in_the_compilation_Colon: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_JSX_code_generation_Colon_preserve_or_react: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_amd_and_system_modules_are_supported_alongside_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Base_directory_to_resolve_non_absolute_module_names: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enable_tracing_of_the_name_resolution_process: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_module_0_from_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Explicitly_specified_module_resolution_kind_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_resolution_kind_is_not_specified_using_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_name_0_was_successfully_resolved_to_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_name_0_was_not_resolved: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_name_0_matched_pattern_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Trying_substitution_0_candidate_module_location_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_module_name_0_relative_to_base_url_1_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Loading_module_as_file_Slash_folder_candidate_module_location_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_does_not_exist: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_exist_use_it_as_a_name_resolution_result: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Loading_module_0_from_node_modules_folder: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Found_package_json_at_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - package_json_does_not_have_a_types_or_main_field: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - package_json_has_0_field_1_that_references_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Allow_javascript_files_to_be_compiled: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_should_have_array_of_strings_as_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Checking_if_0_is_the_longest_matching_prefix_for_1_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expected_type_of_0_field_in_package_json_to_be_string_got_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Longest_matching_prefix_for_0_is_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Loading_0_from_the_root_dir_1_candidate_location_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Trying_other_entries_in_rootDirs: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_resolution_using_rootDirs_has_failed: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_use_strict_directives_in_module_output: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enable_strict_null_checks: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unknown_option_excludes_Did_you_mean_exclude: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Raise_error_on_this_expressions_with_an_implied_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_type_reference_directive_0_containing_file_1_root_directory_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_using_primary_search_paths: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_from_node_modules_folder: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_reference_directive_0_was_not_resolved: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_with_primary_search_path_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Root_directory_cannot_be_determined_skipping_primary_search_paths: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_declaration_files_to_be_included_in_compilation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Looking_up_in_node_modules_folder_initial_location_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_config_file_0_found_doesn_t_contain_any_source_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_real_path_for_0_result_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_name_0_has_a_1_extension_stripping_it: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_declared_but_never_used: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Report_errors_on_unused_locals: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Report_errors_on_unused_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - No_types_specified_in_package_json_so_returning_main_value_of_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_declared_but_never_used: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_emit_helpers_from_tslib: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_was_resolved_to_1_but_jsx_is_not_set: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_was_resolved_to_1_but_allowJs_is_not_set: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Member_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_literal_s_property_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Rest_parameter_0_implicitly_has_an_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unreachable_code_detected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unused_label: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Fallthrough_case_in_switch: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Not_all_code_paths_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Binding_element_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - You_cannot_rename_this_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - import_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - export_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - type_parameter_declarations_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - implements_clauses_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - interface_declarations_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - module_declarations_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - type_aliases_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - types_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - type_arguments_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - parameter_modifiers_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - enum_declarations_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - type_assertion_expressions_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - class_expressions_are_not_currently_supported: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Language_service_is_disabled: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_attributes_must_only_be_assigned_a_non_empty_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expected_corresponding_JSX_closing_tag_for_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_attribute_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_0_has_no_corresponding_closing_tag: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unknown_type_acquisition_option_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Circularity_detected_while_resolving_configuration_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_files_list_in_config_file_0_is_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Add_missing_super_call: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Make_super_call_the_first_statement_in_the_constructor: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Change_extends_to_implements: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Remove_unused_identifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Implement_interface_on_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Implement_interface_on_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Implement_inherited_abstract_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_0_from_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Change_0_to_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Add_0_to_existing_import_declaration_from_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - }; -} declare namespace ts { interface ErrorCallback { (message: DiagnosticMessage, length: number): void; } - function tokenIsIdentifierOrKeyword(token: SyntaxKind): boolean; interface Scanner { getStartPos(): number; getToken(): SyntaxKind; @@ -8722,50 +2258,25 @@ declare namespace ts { scanRange(start: number, length: number, callback: () => T): T; tryScan(callback: () => T): T; } - function isUnicodeIdentifierStart(code: number, languageVersion: ScriptTarget): boolean; function tokenToString(t: SyntaxKind): string; - function stringToToken(s: string): SyntaxKind; - function computeLineStarts(text: string): number[]; function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number; - function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number; - function getLineStarts(sourceFile: SourceFile): number[]; - function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): { - line: number; - character: number; - }; function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; function isWhiteSpace(ch: number): boolean; function isWhiteSpaceSingleLine(ch: number): boolean; function isLineBreak(ch: number): boolean; - function isOctalDigit(ch: number): boolean; function couldStartTrivia(text: string, pos: number): boolean; - function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean, stopAtComments?: boolean): number; function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; - function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; - function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined; + function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined; function getShebang(text: string): string; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; - function isIdentifierText(name: string, languageVersion: ScriptTarget): boolean; function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; } declare namespace ts { - const compileOnSaveCommandLineOption: CommandLineOption; - const optionDeclarations: CommandLineOption[]; - let typeAcquisitionDeclarations: CommandLineOption[]; - interface OptionNameMap { - optionNameMap: Map; - shortOptionNames: Map; - } - const defaultInitCompilerOptions: CompilerOptions; - function convertEnableAutoDiscoveryToEnable(typeAcquisition: TypeAcquisition): TypeAcquisition; - function getOptionNameMap(): OptionNameMap; - function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic; - function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]): string | number; - function parseListTypeOption(opt: CommandLineOptionOfListType, value: string, errors: Diagnostic[]): (string | number)[] | undefined; function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine; function readConfigFile(fileName: string, readFile: (path: string) => string): { config?: any; @@ -8775,10 +2286,7 @@ declare namespace ts { config?: any; error?: Diagnostic; }; - function generateTSConfig(options: CompilerOptions, fileNames: string[]): { - compilerOptions: Map; - }; - function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: FileExtensionInfo[]): ParsedCommandLine; + function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: JsFileExtensionInfo[]): ParsedCommandLine; function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; @@ -8789,114 +2297,10 @@ declare namespace ts { errors: Diagnostic[]; }; } -declare namespace ts.JsTyping { - interface TypingResolutionHost { - directoryExists: (path: string) => boolean; - fileExists: (fileName: string) => boolean; - readFile: (path: string, encoding?: string) => string; - readDirectory: (rootDir: string, extensions: string[], excludes: string[], includes: string[], depth?: number) => string[]; - } - const nodeCoreModuleList: ReadonlyArray; - function discoverTypings(host: TypingResolutionHost, fileNames: string[], projectRootPath: Path, safeListPath: Path, packageNameToTypingLocation: Map, typeAcquisition: TypeAcquisition, unresolvedImports: ReadonlyArray): { - cachedTypingPaths: string[]; - newTypingNames: string[]; - filesToWatch: string[]; - }; -} -declare namespace ts.server { - const ActionSet: ActionSet; - const ActionInvalidate: ActionInvalidate; - const EventBeginInstallTypes: EventBeginInstallTypes; - const EventEndInstallTypes: EventEndInstallTypes; - namespace Arguments { - const GlobalCacheLocation = "--globalTypingsCacheLocation"; - const LogFile = "--logFile"; - const EnableTelemetry = "--enableTelemetry"; - } - function hasArgument(argumentName: string): boolean; - function findArgument(argumentName: string): string; -} -declare namespace ts.server { - enum LogLevel { - terse = 0, - normal = 1, - requestTime = 2, - verbose = 3, - } - const emptyArray: ReadonlyArray; - interface Logger { - close(): void; - hasLevel(level: LogLevel): boolean; - loggingEnabled(): boolean; - perftrc(s: string): void; - info(s: string): void; - startGroup(): void; - endGroup(): void; - msg(s: string, type?: Msg.Types): void; - getLogFileName(): string; - } - namespace Msg { - type Err = "Err"; - const Err: Err; - type Info = "Info"; - const Info: Info; - type Perf = "Perf"; - const Perf: Perf; - type Types = Err | Info | Perf; - } - function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, cachePath?: string): DiscoverTypings; - namespace Errors { - function ThrowNoProject(): never; - function ThrowProjectLanguageServiceDisabled(): never; - function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never; - } - function getDefaultFormatCodeSettings(host: ServerHost): FormatCodeSettings; - function mergeMaps(target: MapLike, source: MapLike): void; - function removeItemFromSet(items: T[], itemToRemove: T): void; - type NormalizedPath = string & { - __normalizedPathTag: any; - }; - function toNormalizedPath(fileName: string): NormalizedPath; - function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path; - function asNormalizedPath(fileName: string): NormalizedPath; - interface NormalizedPathMap { - get(path: NormalizedPath): T; - set(path: NormalizedPath, value: T): void; - contains(path: NormalizedPath): boolean; - remove(path: NormalizedPath): void; - } - function createNormalizedPathMap(): NormalizedPathMap; - interface ProjectOptions { - configHasFilesProperty?: boolean; - files?: string[]; - wildcardDirectories?: Map; - compilerOptions?: CompilerOptions; - typeAcquisition?: TypeAcquisition; - compileOnSave?: boolean; - } - function isInferredProjectName(name: string): boolean; - function makeInferredProjectName(counter: number): string; - function toSortedReadonlyArray(arr: string[]): SortedReadonlyArray; - class ThrottledOperations { - private readonly host; - private pendingTimeouts; - constructor(host: ServerHost); - schedule(operationId: string, delay: number, cb: () => void): void; - private static run(self, operationId, cb); - } - class GcTimer { - private readonly host; - private readonly delay; - private readonly logger; - private timerId; - constructor(host: ServerHost, delay: number, logger: Logger); - scheduleCollect(): void; - private static run(self); - } -} declare namespace ts { - function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void; - function isTraceEnabled(compilerOptions: CompilerOptions, host: ModuleResolutionHost): boolean; + interface Push { + push(value: T): void; + } function moduleHasNonRelativeName(moduleName: string): boolean; function getEffectiveTypeRoots(options: CompilerOptions, host: { directoryExists?: (directoryName: string) => boolean; @@ -8904,392 +2308,20 @@ declare namespace ts { }): string[] | undefined; function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function directoryProbablyExists(directoryName: string, host: { - directoryExists?: (directoryName: string) => boolean; - }): boolean; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function loadModuleFromGlobalCache(moduleName: string, projectName: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, globalCache: string): ResolvedModuleWithFailedLookupLocations; -} -declare namespace ts { - const externalHelpersModuleNameText = "tslib"; - interface ReferencePathMatchResult { - fileReference?: FileReference; - diagnosticMessage?: DiagnosticMessage; - isNoDefaultLib?: boolean; - isTypeReferenceDirective?: boolean; + interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { + getOrCreateCacheForDirectory(directoryName: string): Map; } - function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration; - interface StringSymbolWriter extends SymbolWriter { - string(): string; + interface NonRelativeModuleNameResolutionCache { + getOrCreateCacheForModuleName(nonRelativeModuleName: string): PerModuleNameCache; } - function getSingleLineStringWriter(): StringSymbolWriter; - function releaseStringWriter(writer: StringSymbolWriter): void; - function getFullWidth(node: Node): number; - function hasResolvedModule(sourceFile: SourceFile, moduleNameText: string): boolean; - function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModuleFull; - function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModuleFull): void; - function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeReferenceDirectiveName: string, resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective): void; - function moduleResolutionIsEqualTo(oldResolution: ResolvedModuleFull, newResolution: ResolvedModuleFull): boolean; - function typeDirectiveIsEqualTo(oldResolution: ResolvedTypeReferenceDirective, newResolution: ResolvedTypeReferenceDirective): boolean; - function hasChangesInResolutions(names: string[], newResolutions: T[], oldResolutions: Map, comparer: (oldResolution: T, newResolution: T) => boolean): boolean; - function containsParseError(node: Node): boolean; - function getSourceFileOfNode(node: Node): SourceFile; - function isStatementWithLocals(node: Node): boolean; - function getStartPositionOfLine(line: number, sourceFile: SourceFile): number; - function nodePosToString(node: Node): string; - function getStartPosOfNode(node: Node): number; - function isDefined(value: any): boolean; - function getEndLinePosition(line: number, sourceFile: SourceFile): number; - function nodeIsMissing(node: Node): boolean; - function nodeIsPresent(node: Node): boolean; - function getTokenPosOfNode(node: Node, sourceFile?: SourceFile, includeJsDoc?: boolean): number; - function isJSDocNode(node: Node): boolean; - function isJSDocTag(node: Node): boolean; - function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFile): number; - function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node, includeTrivia?: boolean): string; - function getTextOfNodeFromSourceText(sourceText: string, node: Node): string; - function getTextOfNode(node: Node, includeTrivia?: boolean): string; - function getLiteralText(node: LiteralLikeNode, sourceFile: SourceFile, languageVersion: ScriptTarget): string; - function isBinaryOrOctalIntegerLiteral(node: LiteralLikeNode, text: string): boolean; - function escapeIdentifier(identifier: string): string; - function unescapeIdentifier(identifier: string): string; - function makeIdentifierFromModuleName(moduleName: string): string; - function isBlockOrCatchScoped(declaration: Declaration): boolean; - function isCatchClauseVariableDeclarationOrBindingElement(declaration: Declaration): boolean; - function isAmbientModule(node: Node): boolean; - function isShorthandAmbientModuleSymbol(moduleSymbol: Symbol): boolean; - function isBlockScopedContainerTopLevel(node: Node): boolean; - function isGlobalScopeAugmentation(module: ModuleDeclaration): boolean; - function isExternalModuleAugmentation(node: Node): boolean; - function isEffectiveExternalModule(node: SourceFile, compilerOptions: CompilerOptions): boolean; - function isBlockScope(node: Node, parentNode: Node): boolean; - function getEnclosingBlockScopeContainer(node: Node): Node; - function declarationNameToString(name: DeclarationName): string; - function getTextOfPropertyName(name: PropertyName): string; - function entityNameToString(name: EntityNameOrEntityNameExpression): string; - function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): Diagnostic; - function createDiagnosticForNodeInSourceFile(sourceFile: SourceFile, node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): Diagnostic; - function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain): Diagnostic; - function getSpanOfTokenAtPosition(sourceFile: SourceFile, pos: number): TextSpan; - function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan; - function isExternalOrCommonJsModule(file: SourceFile): boolean; - function isDeclarationFile(file: SourceFile): boolean; - function isConstEnumDeclaration(node: Node): boolean; - function isConst(node: Node): boolean; - function isLet(node: Node): boolean; - function isSuperCall(n: Node): n is SuperCall; - function isPrologueDirective(node: Node): node is PrologueDirective; - function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile): CommentRange[]; - function getLeadingCommentRangesOfNodeFromText(node: Node, text: string): CommentRange[]; - function getJSDocCommentRanges(node: Node, text: string): CommentRange[]; - let fullTripleSlashReferencePathRegEx: RegExp; - let fullTripleSlashReferenceTypeReferenceDirectiveRegEx: RegExp; - let fullTripleSlashAMDReferencePathRegEx: RegExp; - function isPartOfTypeNode(node: Node): boolean; - function forEachReturnStatement(body: Block, visitor: (stmt: ReturnStatement) => T): T; - function forEachYieldExpression(body: Block, visitor: (expr: YieldExpression) => void): void; - function getRestParameterElementType(node: TypeNode): TypeNode; - function isVariableLike(node: Node): node is VariableLikeDeclaration; - function isAccessor(node: Node): node is AccessorDeclaration; - function isClassLike(node: Node): node is ClassLikeDeclaration; - function isFunctionLike(node: Node): node is FunctionLikeDeclaration; - function isFunctionLikeKind(kind: SyntaxKind): boolean; - function introducesArgumentsExoticObject(node: Node): boolean; - function isIterationStatement(node: Node, lookInLabeledStatements: boolean): node is IterationStatement; - function isFunctionBlock(node: Node): boolean; - function isObjectLiteralMethod(node: Node): node is MethodDeclaration; - function isObjectLiteralOrClassExpressionMethod(node: Node): node is MethodDeclaration; - function isIdentifierTypePredicate(predicate: TypePredicate): predicate is IdentifierTypePredicate; - function isThisTypePredicate(predicate: TypePredicate): predicate is ThisTypePredicate; - function getContainingFunction(node: Node): FunctionLikeDeclaration; - function getContainingClass(node: Node): ClassLikeDeclaration; - function getThisContainer(node: Node, includeArrowFunctions: boolean): Node; - function getSuperContainer(node: Node, stopOnFunctions: boolean): Node; - function getImmediatelyInvokedFunctionExpression(func: Node): CallExpression; - function isSuperProperty(node: Node): node is SuperProperty; - function getEntityNameFromTypeNode(node: TypeNode): EntityNameOrEntityNameExpression; - function isCallLikeExpression(node: Node): node is CallLikeExpression; - function getInvokedExpression(node: CallLikeExpression): Expression; - function nodeCanBeDecorated(node: Node): boolean; - function nodeIsDecorated(node: Node): boolean; - function nodeOrChildIsDecorated(node: Node): boolean; - function childIsDecorated(node: Node): boolean; - function isJSXTagName(node: Node): boolean; - function isPartOfExpression(node: Node): boolean; - function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean; - function isExternalModuleImportEqualsDeclaration(node: Node): boolean; - function getExternalModuleImportEqualsDeclarationExpression(node: Node): Expression; - function isInternalModuleImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration; - function isSourceFileJavaScript(file: SourceFile): boolean; - function isInJavaScriptFile(node: Node): boolean; - function isRequireCall(expression: Node, checkArgumentIsStringLiteral: boolean): expression is CallExpression; - function isSingleOrDoubleQuote(charCode: number): boolean; - function isDeclarationOfFunctionExpression(s: Symbol): boolean; - function getSpecialPropertyAssignmentKind(expression: Node): SpecialPropertyAssignmentKind; - function getExternalModuleName(node: Node): Expression; - function getNamespaceDeclarationNode(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): ImportEqualsDeclaration | NamespaceImport; - function isDefaultImport(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): boolean; - function hasQuestionToken(node: Node): boolean; - function isJSDocConstructSignature(node: Node): boolean; - function getCommentsFromJSDoc(node: Node): string[]; - function getJSDocParameterTags(param: Node): JSDocParameterTag[]; - function getJSDocType(node: Node): JSDocType; - function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag; - function getJSDocReturnTag(node: Node): JSDocReturnTag; - function getJSDocTemplateTag(node: Node): JSDocTemplateTag; - function hasRestParameter(s: SignatureDeclaration): boolean; - function hasDeclaredRestParameter(s: SignatureDeclaration): boolean; - function isRestParameter(node: ParameterDeclaration): boolean; - function isDeclaredRestParam(node: ParameterDeclaration): boolean; - const enum AssignmentKind { - None = 0, - Definite = 1, - Compound = 2, + interface PerModuleNameCache { + get(directory: string): ResolvedModuleWithFailedLookupLocations; + set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; } - function getAssignmentTargetKind(node: Node): AssignmentKind; - function isAssignmentTarget(node: Node): boolean; - function isNodeDescendantOf(node: Node, ancestor: Node): boolean; - function isInAmbientContext(node: Node): boolean; - function isDeclarationName(name: Node): boolean; - function isLiteralComputedPropertyDeclarationName(node: Node): boolean; - function isIdentifierName(node: Identifier): boolean; - function isAliasSymbolDeclaration(node: Node): boolean; - function exportAssignmentIsAlias(node: ExportAssignment): boolean; - function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration | InterfaceDeclaration): ExpressionWithTypeArguments; - function getClassImplementsHeritageClauseElements(node: ClassLikeDeclaration): NodeArray; - function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray; - function getHeritageClause(clauses: NodeArray, kind: SyntaxKind): HeritageClause; - function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile, reference: FileReference): SourceFile; - function getAncestor(node: Node, kind: SyntaxKind): Node; - function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult; - function isKeyword(token: SyntaxKind): boolean; - function isTrivia(token: SyntaxKind): boolean; - function isAsyncFunctionLike(node: Node): boolean; - function isStringOrNumericLiteral(node: Node): node is StringLiteral | NumericLiteral; - function hasDynamicName(declaration: Declaration): boolean; - function isDynamicName(name: DeclarationName): boolean; - function isWellKnownSymbolSyntactically(node: Expression): boolean; - function getPropertyNameForPropertyNameNode(name: DeclarationName | ParameterDeclaration): string; - function getPropertyNameForKnownSymbolName(symbolName: string): string; - function isESSymbolIdentifier(node: Node): boolean; - function isPushOrUnshiftIdentifier(node: Identifier): boolean; - function isModifierKind(token: SyntaxKind): boolean; - function isParameterDeclaration(node: VariableLikeDeclaration): boolean; - function getRootDeclaration(node: Node): Node; - function nodeStartsNewLexicalEnvironment(node: Node): boolean; - function nodeIsSynthesized(node: TextRange): boolean; - function getOriginalNode(node: Node): Node; - function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; - function isParseTreeNode(node: Node): boolean; - function getParseTreeNode(node: Node): Node; - function getParseTreeNode(node: Node, nodeTest?: (node: Node) => node is T): T; - function getOriginalSourceFiles(sourceFiles: SourceFile[]): SourceFile[]; - function getOriginalNodeId(node: Node): number; - const enum Associativity { - Left = 0, - Right = 1, - } - function getExpressionAssociativity(expression: Expression): Associativity; - function getOperatorAssociativity(kind: SyntaxKind, operator: SyntaxKind, hasArguments?: boolean): Associativity; - function getExpressionPrecedence(expression: Expression): 0 | 1 | -1 | 2 | 4 | 3 | 16 | 10 | 5 | 6 | 11 | 8 | 19 | 18 | 17 | 15 | 14 | 13 | 12 | 9 | 7; - function getOperator(expression: Expression): SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.NumericLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.Identifier | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.LetKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.StaticKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AbstractKeyword | SyntaxKind.AsKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.GetKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.NumberKeyword | SyntaxKind.SetKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.TypeKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.FromKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.OfKeyword | SyntaxKind.QualifiedName | SyntaxKind.ComputedPropertyName | SyntaxKind.TypeParameter | SyntaxKind.Parameter | SyntaxKind.Decorator | SyntaxKind.PropertySignature | SyntaxKind.PropertyDeclaration | SyntaxKind.MethodSignature | SyntaxKind.MethodDeclaration | SyntaxKind.Constructor | SyntaxKind.GetAccessor | SyntaxKind.SetAccessor | SyntaxKind.CallSignature | SyntaxKind.ConstructSignature | SyntaxKind.IndexSignature | SyntaxKind.TypePredicate | SyntaxKind.TypeReference | SyntaxKind.FunctionType | SyntaxKind.ConstructorType | SyntaxKind.TypeQuery | SyntaxKind.TypeLiteral | SyntaxKind.ArrayType | SyntaxKind.TupleType | SyntaxKind.UnionType | SyntaxKind.IntersectionType | SyntaxKind.ParenthesizedType | SyntaxKind.ThisType | SyntaxKind.TypeOperator | SyntaxKind.IndexedAccessType | SyntaxKind.MappedType | SyntaxKind.LiteralType | SyntaxKind.ObjectBindingPattern | SyntaxKind.ArrayBindingPattern | SyntaxKind.BindingElement | SyntaxKind.ArrayLiteralExpression | SyntaxKind.ObjectLiteralExpression | SyntaxKind.PropertyAccessExpression | SyntaxKind.ElementAccessExpression | SyntaxKind.CallExpression | SyntaxKind.NewExpression | SyntaxKind.TaggedTemplateExpression | SyntaxKind.TypeAssertionExpression | SyntaxKind.ParenthesizedExpression | SyntaxKind.FunctionExpression | SyntaxKind.ArrowFunction | SyntaxKind.DeleteExpression | SyntaxKind.TypeOfExpression | SyntaxKind.VoidExpression | SyntaxKind.AwaitExpression | SyntaxKind.ConditionalExpression | SyntaxKind.TemplateExpression | SyntaxKind.YieldExpression | SyntaxKind.SpreadElement | SyntaxKind.ClassExpression | SyntaxKind.OmittedExpression | SyntaxKind.ExpressionWithTypeArguments | SyntaxKind.AsExpression | SyntaxKind.NonNullExpression | SyntaxKind.TemplateSpan | SyntaxKind.SemicolonClassElement | SyntaxKind.Block | SyntaxKind.VariableStatement | SyntaxKind.EmptyStatement | SyntaxKind.ExpressionStatement | SyntaxKind.IfStatement | SyntaxKind.DoStatement | SyntaxKind.WhileStatement | SyntaxKind.ForStatement | SyntaxKind.ForInStatement | SyntaxKind.ForOfStatement | SyntaxKind.ContinueStatement | SyntaxKind.BreakStatement | SyntaxKind.ReturnStatement | SyntaxKind.WithStatement | SyntaxKind.SwitchStatement | SyntaxKind.LabeledStatement | SyntaxKind.ThrowStatement | SyntaxKind.TryStatement | SyntaxKind.DebuggerStatement | SyntaxKind.VariableDeclaration | SyntaxKind.VariableDeclarationList | SyntaxKind.FunctionDeclaration | SyntaxKind.ClassDeclaration | SyntaxKind.InterfaceDeclaration | SyntaxKind.TypeAliasDeclaration | SyntaxKind.EnumDeclaration | SyntaxKind.ModuleDeclaration | SyntaxKind.ModuleBlock | SyntaxKind.CaseBlock | SyntaxKind.NamespaceExportDeclaration | SyntaxKind.ImportEqualsDeclaration | SyntaxKind.ImportDeclaration | SyntaxKind.ImportClause | SyntaxKind.NamespaceImport | SyntaxKind.NamedImports | SyntaxKind.ImportSpecifier | SyntaxKind.ExportAssignment | SyntaxKind.ExportDeclaration | SyntaxKind.NamedExports | SyntaxKind.ExportSpecifier | SyntaxKind.MissingDeclaration | SyntaxKind.ExternalModuleReference | SyntaxKind.JsxElement | SyntaxKind.JsxSelfClosingElement | SyntaxKind.JsxOpeningElement | SyntaxKind.JsxClosingElement | SyntaxKind.JsxAttribute | SyntaxKind.JsxSpreadAttribute | SyntaxKind.JsxExpression | SyntaxKind.CaseClause | SyntaxKind.DefaultClause | SyntaxKind.HeritageClause | SyntaxKind.CatchClause | SyntaxKind.PropertyAssignment | SyntaxKind.ShorthandPropertyAssignment | SyntaxKind.SpreadAssignment | SyntaxKind.EnumMember | SyntaxKind.SourceFile | SyntaxKind.JSDocTypeExpression | SyntaxKind.JSDocAllType | SyntaxKind.JSDocUnknownType | SyntaxKind.JSDocArrayType | SyntaxKind.JSDocUnionType | SyntaxKind.JSDocTupleType | SyntaxKind.JSDocNullableType | SyntaxKind.JSDocNonNullableType | SyntaxKind.JSDocRecordType | SyntaxKind.JSDocRecordMember | SyntaxKind.JSDocTypeReference | SyntaxKind.JSDocOptionalType | SyntaxKind.JSDocFunctionType | SyntaxKind.JSDocVariadicType | SyntaxKind.JSDocConstructorType | SyntaxKind.JSDocThisType | SyntaxKind.JSDocComment | SyntaxKind.JSDocTag | SyntaxKind.JSDocAugmentsTag | SyntaxKind.JSDocParameterTag | SyntaxKind.JSDocReturnTag | SyntaxKind.JSDocTypeTag | SyntaxKind.JSDocTemplateTag | SyntaxKind.JSDocTypedefTag | SyntaxKind.JSDocPropertyTag | SyntaxKind.JSDocTypeLiteral | SyntaxKind.JSDocLiteralType | SyntaxKind.JSDocNullKeyword | SyntaxKind.JSDocUndefinedKeyword | SyntaxKind.JSDocNeverKeyword | SyntaxKind.SyntaxList | SyntaxKind.NotEmittedStatement | SyntaxKind.PartiallyEmittedExpression | SyntaxKind.MergeDeclarationMarker | SyntaxKind.EndOfDeclarationMarker | SyntaxKind.RawExpression | SyntaxKind.Count; - function getOperatorPrecedence(nodeKind: SyntaxKind, operatorKind: SyntaxKind, hasArguments?: boolean): 0 | 1 | -1 | 2 | 4 | 3 | 16 | 10 | 5 | 6 | 11 | 8 | 19 | 18 | 17 | 15 | 14 | 13 | 12 | 9 | 7; - function createDiagnosticCollection(): DiagnosticCollection; - function escapeString(s: string): string; - function isIntrinsicJsxName(name: string): boolean; - function escapeNonAsciiCharacters(s: string): string; - interface EmitTextWriter { - write(s: string): void; - writeTextOfNode(text: string, node: Node): void; - writeLine(): void; - increaseIndent(): void; - decreaseIndent(): void; - getText(): string; - rawWrite(s: string): void; - writeLiteral(s: string): void; - getTextPos(): number; - getLine(): number; - getColumn(): number; - getIndent(): number; - isAtStartOfLine(): boolean; - reset(): void; - } - function getIndentString(level: number): string; - function getIndentSize(): number; - function createTextWriter(newLine: String): EmitTextWriter; - function getResolvedExternalModuleName(host: EmitHost, file: SourceFile): string; - function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): string; - function getExternalModuleNameFromPath(host: EmitHost, fileName: string): string; - function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string): string; - function getDeclarationEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost): string; - interface EmitFileNames { - jsFilePath: string; - sourceMapFilePath: string; - declarationFilePath: string; - } - function getSourceFilesToEmit(host: EmitHost, targetSourceFile?: SourceFile): SourceFile[]; - function filterSourceFilesInDirectory(sourceFiles: SourceFile[], isSourceFileFromExternalLibrary: (file: SourceFile) => boolean): SourceFile[]; - function forEachTransformedEmitFile(host: EmitHost, sourceFiles: SourceFile[], action: (jsFilePath: string, sourceMapFilePath: string, declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) => void, emitOnlyDtsFiles?: boolean): void; - function forEachExpectedEmitFile(host: EmitHost, action: (emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean, emitOnlyDtsFiles: boolean) => void, targetSourceFile?: SourceFile, emitOnlyDtsFiles?: boolean): void; - function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string): string; - function writeFile(host: EmitHost, diagnostics: DiagnosticCollection, fileName: string, data: string, writeByteOrderMark: boolean, sourceFiles?: SourceFile[]): void; - function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number): number; - function getLineOfLocalPositionFromLineMap(lineMap: number[], pos: number): number; - function getFirstConstructorWithBody(node: ClassLikeDeclaration): ConstructorDeclaration; - function getSetAccessorTypeAnnotationNode(accessor: SetAccessorDeclaration): TypeNode; - function getThisParameter(signature: SignatureDeclaration): ParameterDeclaration | undefined; - function parameterIsThisKeyword(parameter: ParameterDeclaration): boolean; - function isThisIdentifier(node: Node | undefined): boolean; - function identifierIsThisKeyword(id: Identifier): boolean; - interface AllAccessorDeclarations { - firstAccessor: AccessorDeclaration; - secondAccessor: AccessorDeclaration; - getAccessor: AccessorDeclaration; - setAccessor: AccessorDeclaration; - } - function getAllAccessorDeclarations(declarations: NodeArray, accessor: AccessorDeclaration): AllAccessorDeclarations; - function emitNewLineBeforeLeadingComments(lineMap: number[], writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]): void; - function emitNewLineBeforeLeadingCommentsOfPosition(lineMap: number[], writer: EmitTextWriter, pos: number, leadingComments: CommentRange[]): void; - function emitNewLineBeforeLeadingCommentOfPosition(lineMap: number[], writer: EmitTextWriter, pos: number, commentPos: number): void; - function emitComments(text: string, lineMap: number[], writer: EmitTextWriter, comments: CommentRange[], leadingSeparator: boolean, trailingSeparator: boolean, newLine: string, writeComment: (text: string, lineMap: number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) => void): void; - function emitDetachedComments(text: string, lineMap: number[], writer: EmitTextWriter, writeComment: (text: string, lineMap: number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) => void, node: TextRange, newLine: string, removeComments: boolean): { - nodePos: number; - detachedCommentEndPos: number; - }; - function writeCommentRange(text: string, lineMap: number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string): void; - function hasModifiers(node: Node): boolean; - function hasModifier(node: Node, flags: ModifierFlags): boolean; - function getModifierFlags(node: Node): ModifierFlags; - function modifierToFlag(token: SyntaxKind): ModifierFlags; - function isLogicalOperator(token: SyntaxKind): boolean; - function isAssignmentOperator(token: SyntaxKind): boolean; - function tryGetClassExtendingExpressionWithTypeArguments(node: Node): ClassLikeDeclaration | undefined; - function isAssignmentExpression(node: Node, excludeCompoundAssignment: true): node is AssignmentExpression; - function isAssignmentExpression(node: Node, excludeCompoundAssignment?: false): node is AssignmentExpression; - function isDestructuringAssignment(node: Node): node is DestructuringAssignment; - function isSupportedExpressionWithTypeArguments(node: ExpressionWithTypeArguments): boolean; - function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean; - function isEntityNameExpression(node: Expression): node is EntityNameExpression; - function isRightSideOfQualifiedNameOrPropertyAccess(node: Node): boolean; - function isEmptyObjectLiteralOrArrayLiteral(expression: Node): boolean; - function getLocalSymbolForExportDefault(symbol: Symbol): Symbol; - function tryExtractTypeScriptExtension(fileName: string): string | undefined; - function convertToBase64(input: string): string; - function getNewLineCharacter(options: CompilerOptions): string; - function isSimpleExpression(node: Expression): boolean; - function formatSyntaxKind(kind: SyntaxKind): string; - function movePos(pos: number, value: number): number; - function createRange(pos: number, end: number): TextRange; - function moveRangeEnd(range: TextRange, end: number): TextRange; - function moveRangePos(range: TextRange, pos: number): TextRange; - function moveRangePastDecorators(node: Node): TextRange; - function moveRangePastModifiers(node: Node): TextRange; - function isCollapsedRange(range: TextRange): boolean; - function collapseRangeToStart(range: TextRange): TextRange; - function collapseRangeToEnd(range: TextRange): TextRange; - function createTokenRange(pos: number, token: SyntaxKind): TextRange; - function rangeIsOnSingleLine(range: TextRange, sourceFile: SourceFile): boolean; - function rangeStartPositionsAreOnSameLine(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; - function rangeEndPositionsAreOnSameLine(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; - function rangeStartIsOnSameLineAsRangeEnd(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; - function rangeEndIsOnSameLineAsRangeStart(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; - function positionsAreOnSameLine(pos1: number, pos2: number, sourceFile: SourceFile): boolean; - function getStartPositionOfRange(range: TextRange, sourceFile: SourceFile): number; - function isDeclarationNameOfEnumOrNamespace(node: Identifier): boolean; - function getInitializedVariables(node: VariableDeclarationList): VariableDeclaration[]; - function isMergedWithClass(node: Node): boolean; - function isFirstDeclarationOfKind(node: Node, kind: SyntaxKind): boolean; - function isNodeArray(array: T[]): array is NodeArray; - function isNoSubstitutionTemplateLiteral(node: Node): node is LiteralExpression; - function isLiteralKind(kind: SyntaxKind): boolean; - function isTextualLiteralKind(kind: SyntaxKind): boolean; - function isLiteralExpression(node: Node): node is LiteralExpression; - function isTemplateLiteralKind(kind: SyntaxKind): boolean; - function isTemplateHead(node: Node): node is TemplateHead; - function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail; - function isIdentifier(node: Node): node is Identifier; - function isGeneratedIdentifier(node: Node): node is GeneratedIdentifier; - function isModifier(node: Node): node is Modifier; - function isQualifiedName(node: Node): node is QualifiedName; - function isComputedPropertyName(node: Node): node is ComputedPropertyName; - function isEntityName(node: Node): node is EntityName; - function isPropertyName(node: Node): node is PropertyName; - function isModuleName(node: Node): node is ModuleName; - function isBindingName(node: Node): node is BindingName; - function isTypeParameter(node: Node): node is TypeParameterDeclaration; - function isParameter(node: Node): node is ParameterDeclaration; - function isDecorator(node: Node): node is Decorator; - function isMethodDeclaration(node: Node): node is MethodDeclaration; - function isClassElement(node: Node): node is ClassElement; - function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike; - function isTypeNode(node: Node): node is TypeNode; - function isArrayBindingPattern(node: Node): node is ArrayBindingPattern; - function isObjectBindingPattern(node: Node): node is ObjectBindingPattern; - function isBindingPattern(node: Node): node is BindingPattern; - function isAssignmentPattern(node: Node): node is AssignmentPattern; - function isBindingElement(node: Node): node is BindingElement; - function isArrayBindingElement(node: Node): node is ArrayBindingElement; - function isDeclarationBindingElement(bindingElement: BindingOrAssignmentElement): bindingElement is VariableDeclaration | ParameterDeclaration | BindingElement; - function isBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is BindingOrAssignmentPattern; - function isObjectBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is ObjectBindingOrAssignmentPattern; - function isArrayBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is ArrayBindingOrAssignmentPattern; - function isArrayLiteralExpression(node: Node): node is ArrayLiteralExpression; - function isObjectLiteralExpression(node: Node): node is ObjectLiteralExpression; - function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression; - function isElementAccessExpression(node: Node): node is ElementAccessExpression; - function isBinaryExpression(node: Node): node is BinaryExpression; - function isConditionalExpression(node: Node): node is ConditionalExpression; - function isCallExpression(node: Node): node is CallExpression; - function isTemplateLiteral(node: Node): node is TemplateLiteral; - function isSpreadExpression(node: Node): node is SpreadElement; - function isExpressionWithTypeArguments(node: Node): node is ExpressionWithTypeArguments; - function isLeftHandSideExpression(node: Node): node is LeftHandSideExpression; - function isUnaryExpression(node: Node): node is UnaryExpression; - function isExpression(node: Node): node is Expression; - function isAssertionExpression(node: Node): node is AssertionExpression; - function isPartiallyEmittedExpression(node: Node): node is PartiallyEmittedExpression; - function isNotEmittedStatement(node: Node): node is NotEmittedStatement; - function isNotEmittedOrPartiallyEmittedNode(node: Node): node is NotEmittedStatement | PartiallyEmittedExpression; - function isOmittedExpression(node: Node): node is OmittedExpression; - function isTemplateSpan(node: Node): node is TemplateSpan; - function isBlock(node: Node): node is Block; - function isConciseBody(node: Node): node is ConciseBody; - function isFunctionBody(node: Node): node is FunctionBody; - function isForInitializer(node: Node): node is ForInitializer; - function isVariableDeclaration(node: Node): node is VariableDeclaration; - function isVariableDeclarationList(node: Node): node is VariableDeclarationList; - function isCaseBlock(node: Node): node is CaseBlock; - function isModuleBody(node: Node): node is ModuleBody; - function isImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration; - function isImportClause(node: Node): node is ImportClause; - function isNamedImportBindings(node: Node): node is NamedImportBindings; - function isImportSpecifier(node: Node): node is ImportSpecifier; - function isNamedExports(node: Node): node is NamedExports; - function isExportSpecifier(node: Node): node is ExportSpecifier; - function isModuleOrEnumDeclaration(node: Node): node is ModuleDeclaration | EnumDeclaration; - function isDeclaration(node: Node): node is Declaration; - function isDeclarationStatement(node: Node): node is DeclarationStatement; - function isStatementButNotDeclaration(node: Node): node is Statement; - function isStatement(node: Node): node is Statement; - function isModuleReference(node: Node): node is ModuleReference; - function isJsxOpeningElement(node: Node): node is JsxOpeningElement; - function isJsxClosingElement(node: Node): node is JsxClosingElement; - function isJsxTagNameExpression(node: Node): node is JsxTagNameExpression; - function isJsxChild(node: Node): node is JsxChild; - function isJsxAttributeLike(node: Node): node is JsxAttributeLike; - function isJsxSpreadAttribute(node: Node): node is JsxSpreadAttribute; - function isJsxAttribute(node: Node): node is JsxAttribute; - function isStringLiteralOrJsxExpression(node: Node): node is StringLiteral | JsxExpression; - function isCaseOrDefaultClause(node: Node): node is CaseOrDefaultClause; - function isHeritageClause(node: Node): node is HeritageClause; - function isCatchClause(node: Node): node is CatchClause; - function isPropertyAssignment(node: Node): node is PropertyAssignment; - function isShorthandPropertyAssignment(node: Node): node is ShorthandPropertyAssignment; - function isEnumMember(node: Node): node is EnumMember; - function isSourceFile(node: Node): node is SourceFile; - function isWatchSet(options: CompilerOptions): boolean; + function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): ModuleResolutionCache; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -9321,271 +2353,242 @@ declare namespace ts { fileExists(fileName: string): boolean; readFile(fileName: string): string; }, errors?: Diagnostic[]): void; + function getOriginalNode(node: Node): Node; + function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; + function isParseTreeNode(node: Node): boolean; + function getParseTreeNode(node: Node): Node; + function getParseTreeNode(node: Node, nodeTest?: (node: Node) => node is T): T; + function unescapeIdentifier(identifier: string): string; } declare namespace ts { - function updateNode(updated: T, original: T): T; - function createNodeArray(elements?: T[], location?: TextRange, hasTrailingComma?: boolean): NodeArray; - function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node; - function createSynthesizedNodeArray(elements?: T[]): NodeArray; - function getSynthesizedClone(node: T): T; - function getMutableClone(node: T): T; - function createLiteral(textSource: StringLiteral | NumericLiteral | Identifier, location?: TextRange): StringLiteral; - function createLiteral(value: string, location?: TextRange): StringLiteral; - function createLiteral(value: number, location?: TextRange): NumericLiteral; - function createLiteral(value: boolean, location?: TextRange): BooleanLiteral; - function createLiteral(value: string | number | boolean, location?: TextRange): PrimaryExpression; - function createIdentifier(text: string, location?: TextRange): Identifier; - function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, location?: TextRange): Identifier; - function createLoopVariable(location?: TextRange): Identifier; - function createUniqueName(text: string, location?: TextRange): Identifier; - function getGeneratedNameForNode(node: Node, location?: TextRange): Identifier; + function createNodeArray(elements?: T[], hasTrailingComma?: boolean): NodeArray; + function createLiteral(value: string): StringLiteral; + function createLiteral(value: number): NumericLiteral; + function createLiteral(value: boolean): BooleanLiteral; + function createLiteral(sourceNode: StringLiteral | NumericLiteral | Identifier): StringLiteral; + function createLiteral(value: string | number | boolean): PrimaryExpression; + function createNumericLiteral(value: string): NumericLiteral; + function createIdentifier(text: string): Identifier; + function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier; + function createLoopVariable(): Identifier; + function createUniqueName(text: string): Identifier; + function getGeneratedNameForNode(node: Node): Identifier; function createToken(token: TKind): Token; function createSuper(): PrimaryExpression; - function createThis(location?: TextRange): PrimaryExpression; + function createThis(): PrimaryExpression; function createNull(): PrimaryExpression; - function createComputedPropertyName(expression: Expression, location?: TextRange): ComputedPropertyName; + function createTrue(): BooleanLiteral; + function createFalse(): BooleanLiteral; + function createQualifiedName(left: EntityName, right: string | Identifier): QualifiedName; + function updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName; + function createComputedPropertyName(expression: Expression): ComputedPropertyName; function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; - function createParameter(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression, location?: TextRange, flags?: NodeFlags): ParameterDeclaration; + function createParameter(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; function updateParameter(node: ParameterDeclaration, decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: BindingName, type: TypeNode, initializer: Expression): ParameterDeclaration; - function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: QuestionToken, type: TypeNode, initializer: Expression, location?: TextRange): PropertyDeclaration; + function createDecorator(expression: Expression): Decorator; + function updateDecorator(node: Decorator, expression: Expression): Decorator; + function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: QuestionToken, type: TypeNode, initializer: Expression): PropertyDeclaration; function updateProperty(node: PropertyDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, type: TypeNode, initializer: Expression): PropertyDeclaration; - function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): MethodDeclaration; + function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; function updateMethod(node: MethodDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; - function createConstructor(decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block, location?: TextRange, flags?: NodeFlags): ConstructorDeclaration; + function createConstructor(decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; - function createGetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): GetAccessorDeclaration; + function createGetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; - function createSetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], body: Block, location?: TextRange, flags?: NodeFlags): SetAccessorDeclaration; + function createSetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; - function createObjectBindingPattern(elements: BindingElement[], location?: TextRange): ObjectBindingPattern; + function createObjectBindingPattern(elements: BindingElement[]): ObjectBindingPattern; function updateObjectBindingPattern(node: ObjectBindingPattern, elements: BindingElement[]): ObjectBindingPattern; - function createArrayBindingPattern(elements: ArrayBindingElement[], location?: TextRange): ArrayBindingPattern; + function createArrayBindingPattern(elements: ArrayBindingElement[]): ArrayBindingPattern; function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ArrayBindingElement[]): ArrayBindingPattern; - function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: DotDotDotToken, name: string | BindingName, initializer?: Expression, location?: TextRange): BindingElement; + function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: DotDotDotToken, name: string | BindingName, initializer?: Expression): BindingElement; function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken, propertyName: PropertyName, name: BindingName, initializer: Expression): BindingElement; - function createArrayLiteral(elements?: Expression[], location?: TextRange, multiLine?: boolean): ArrayLiteralExpression; + function createArrayLiteral(elements?: Expression[], multiLine?: boolean): ArrayLiteralExpression; function updateArrayLiteral(node: ArrayLiteralExpression, elements: Expression[]): ArrayLiteralExpression; - function createObjectLiteral(properties?: ObjectLiteralElementLike[], location?: TextRange, multiLine?: boolean): ObjectLiteralExpression; + function createObjectLiteral(properties?: ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; function updateObjectLiteral(node: ObjectLiteralExpression, properties: ObjectLiteralElementLike[]): ObjectLiteralExpression; - function createPropertyAccess(expression: Expression, name: string | Identifier, location?: TextRange, flags?: NodeFlags): PropertyAccessExpression; + function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression; function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; - function createElementAccess(expression: Expression, index: number | Expression, location?: TextRange): ElementAccessExpression; + function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[], location?: TextRange, flags?: NodeFlags): CallExpression; + function createCall(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; - function createNew(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[], location?: TextRange, flags?: NodeFlags): NewExpression; + function createNew(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; - function createTaggedTemplate(tag: Expression, template: TemplateLiteral, location?: TextRange): TaggedTemplateExpression; + function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function createParen(expression: Expression, location?: TextRange): ParenthesizedExpression; + function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; + function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; + function createParen(expression: Expression): ParenthesizedExpression; function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): FunctionExpression; + function createFunctionExpression(modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; - function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody, location?: TextRange, flags?: NodeFlags): ArrowFunction; + function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody): ArrowFunction; function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: ConciseBody): ArrowFunction; - function createDelete(expression: Expression, location?: TextRange): DeleteExpression; - function updateDelete(node: DeleteExpression, expression: Expression): Expression; - function createTypeOf(expression: Expression, location?: TextRange): TypeOfExpression; - function updateTypeOf(node: TypeOfExpression, expression: Expression): Expression; - function createVoid(expression: Expression, location?: TextRange): VoidExpression; + function createDelete(expression: Expression): DeleteExpression; + function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; + function createTypeOf(expression: Expression): TypeOfExpression; + function updateTypeOf(node: TypeOfExpression, expression: Expression): TypeOfExpression; + function createVoid(expression: Expression): VoidExpression; function updateVoid(node: VoidExpression, expression: Expression): VoidExpression; - function createAwait(expression: Expression, location?: TextRange): AwaitExpression; + function createAwait(expression: Expression): AwaitExpression; function updateAwait(node: AwaitExpression, expression: Expression): AwaitExpression; - function createPrefix(operator: PrefixUnaryOperator, operand: Expression, location?: TextRange): PrefixUnaryExpression; + function createPrefix(operator: PrefixUnaryOperator, operand: Expression): PrefixUnaryExpression; function updatePrefix(node: PrefixUnaryExpression, operand: Expression): PrefixUnaryExpression; - function createPostfix(operand: Expression, operator: PostfixUnaryOperator, location?: TextRange): PostfixUnaryExpression; + function createPostfix(operand: Expression, operator: PostfixUnaryOperator): PostfixUnaryExpression; function updatePostfix(node: PostfixUnaryExpression, operand: Expression): PostfixUnaryExpression; - function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression, location?: TextRange): BinaryExpression; + function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression): BinaryExpression; function updateBinary(node: BinaryExpression, left: Expression, right: Expression): BinaryExpression; - function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression, location?: TextRange): ConditionalExpression; - function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression, location?: TextRange): ConditionalExpression; + function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; - function createTemplateExpression(head: TemplateHead, templateSpans: TemplateSpan[], location?: TextRange): TemplateExpression; + function createTemplateExpression(head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; - function createYield(asteriskToken: AsteriskToken, expression: Expression, location?: TextRange): YieldExpression; + function createYield(expression?: Expression): YieldExpression; + function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression; function updateYield(node: YieldExpression, expression: Expression): YieldExpression; - function createSpread(expression: Expression, location?: TextRange): SpreadElement; + function createSpread(expression: Expression): SpreadElement; function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; - function createClassExpression(modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[], location?: TextRange): ClassExpression; + function createClassExpression(modifiers: Modifier[], name: string | Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; function updateClassExpression(node: ClassExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; - function createOmittedExpression(location?: TextRange): OmittedExpression; - function createExpressionWithTypeArguments(typeArguments: TypeNode[], expression: Expression, location?: TextRange): ExpressionWithTypeArguments; + function createOmittedExpression(): OmittedExpression; + function createExpressionWithTypeArguments(typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; - function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail, location?: TextRange): TemplateSpan; + function createAsExpression(expression: Expression, type: TypeNode): AsExpression; + function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; + function createNonNullExpression(expression: Expression): NonNullExpression; + function updateNonNullExpression(node: NonNullExpression, expression: Expression): NonNullExpression; + function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; - function createBlock(statements: Statement[], location?: TextRange, multiLine?: boolean, flags?: NodeFlags): Block; + function createBlock(statements: Statement[], multiLine?: boolean): Block; function updateBlock(node: Block, statements: Statement[]): Block; - function createVariableStatement(modifiers: Modifier[], declarationList: VariableDeclarationList | VariableDeclaration[], location?: TextRange, flags?: NodeFlags): VariableStatement; + function createVariableStatement(modifiers: Modifier[], declarationList: VariableDeclarationList | VariableDeclaration[]): VariableStatement; function updateVariableStatement(node: VariableStatement, modifiers: Modifier[], declarationList: VariableDeclarationList): VariableStatement; - function createVariableDeclarationList(declarations: VariableDeclaration[], location?: TextRange, flags?: NodeFlags): VariableDeclarationList; + function createVariableDeclarationList(declarations: VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList; - function createVariableDeclaration(name: string | BindingPattern | Identifier, type?: TypeNode, initializer?: Expression, location?: TextRange, flags?: NodeFlags): VariableDeclaration; + function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode, initializer: Expression): VariableDeclaration; - function createEmptyStatement(location: TextRange): EmptyStatement; - function createStatement(expression: Expression, location?: TextRange, flags?: NodeFlags): ExpressionStatement; + function createEmptyStatement(): EmptyStatement; + function createStatement(expression: Expression): ExpressionStatement; function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; - function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement, location?: TextRange): IfStatement; + function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement; function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement): IfStatement; - function createDo(statement: Statement, expression: Expression, location?: TextRange): DoStatement; + function createDo(statement: Statement, expression: Expression): DoStatement; function updateDo(node: DoStatement, statement: Statement, expression: Expression): DoStatement; - function createWhile(expression: Expression, statement: Statement, location?: TextRange): WhileStatement; + function createWhile(expression: Expression, statement: Statement): WhileStatement; function updateWhile(node: WhileStatement, expression: Expression, statement: Statement): WhileStatement; - function createFor(initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement, location?: TextRange): ForStatement; + function createFor(initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; function updateFor(node: ForStatement, initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; - function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement, location?: TextRange): ForInStatement; + function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; function updateForIn(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; - function createForOf(initializer: ForInitializer, expression: Expression, statement: Statement, location?: TextRange): ForOfStatement; + function createForOf(initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; function updateForOf(node: ForOfStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; - function createContinue(label?: Identifier, location?: TextRange): ContinueStatement; + function createContinue(label?: string | Identifier): ContinueStatement; function updateContinue(node: ContinueStatement, label: Identifier): ContinueStatement; - function createBreak(label?: Identifier, location?: TextRange): BreakStatement; + function createBreak(label?: string | Identifier): BreakStatement; function updateBreak(node: BreakStatement, label: Identifier): BreakStatement; - function createReturn(expression?: Expression, location?: TextRange): ReturnStatement; + function createReturn(expression?: Expression): ReturnStatement; function updateReturn(node: ReturnStatement, expression: Expression): ReturnStatement; - function createWith(expression: Expression, statement: Statement, location?: TextRange): WithStatement; + function createWith(expression: Expression, statement: Statement): WithStatement; function updateWith(node: WithStatement, expression: Expression, statement: Statement): WithStatement; - function createSwitch(expression: Expression, caseBlock: CaseBlock, location?: TextRange): SwitchStatement; + function createSwitch(expression: Expression, caseBlock: CaseBlock): SwitchStatement; function updateSwitch(node: SwitchStatement, expression: Expression, caseBlock: CaseBlock): SwitchStatement; - function createLabel(label: string | Identifier, statement: Statement, location?: TextRange): LabeledStatement; + function createLabel(label: string | Identifier, statement: Statement): LabeledStatement; function updateLabel(node: LabeledStatement, label: Identifier, statement: Statement): LabeledStatement; - function createThrow(expression: Expression, location?: TextRange): ThrowStatement; + function createThrow(expression: Expression): ThrowStatement; function updateThrow(node: ThrowStatement, expression: Expression): ThrowStatement; - function createTry(tryBlock: Block, catchClause: CatchClause, finallyBlock: Block, location?: TextRange): TryStatement; + function createTry(tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; - function createCaseBlock(clauses: CaseOrDefaultClause[], location?: TextRange): CaseBlock; - function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]): CaseBlock; - function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): FunctionDeclaration; + function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; - function createClassDeclaration(decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[], location?: TextRange): ClassDeclaration; + function createClassDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; - function createImportDeclaration(decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier?: Expression, location?: TextRange): ImportDeclaration; + function createEnumDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, members: EnumMember[]): EnumDeclaration; + function updateEnumDeclaration(node: EnumDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, members: EnumMember[]): EnumDeclaration; + function createModuleDeclaration(decorators: Decorator[], modifiers: Modifier[], name: ModuleName, body: ModuleBody, flags?: NodeFlags): ModuleDeclaration; + function updateModuleDeclaration(node: ModuleDeclaration, decorators: Decorator[], modifiers: Modifier[], name: ModuleName, body: ModuleBody): ModuleDeclaration; + function createModuleBlock(statements: Statement[]): ModuleBlock; + function updateModuleBlock(node: ModuleBlock, statements: Statement[]): ModuleBlock; + function createCaseBlock(clauses: CaseOrDefaultClause[]): CaseBlock; + function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]): CaseBlock; + function createImportEqualsDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function createImportDeclaration(decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier?: Expression): ImportDeclaration; function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier: Expression): ImportDeclaration; - function createImportClause(name: Identifier, namedBindings: NamedImportBindings, location?: TextRange): ImportClause; + function createImportClause(name: Identifier, namedBindings: NamedImportBindings): ImportClause; function updateImportClause(node: ImportClause, name: Identifier, namedBindings: NamedImportBindings): ImportClause; - function createNamespaceImport(name: Identifier, location?: TextRange): NamespaceImport; + function createNamespaceImport(name: Identifier): NamespaceImport; function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; - function createNamedImports(elements: ImportSpecifier[], location?: TextRange): NamedImports; + function createNamedImports(elements: ImportSpecifier[]): NamedImports; function updateNamedImports(node: NamedImports, elements: ImportSpecifier[]): NamedImports; - function createImportSpecifier(propertyName: Identifier, name: Identifier, location?: TextRange): ImportSpecifier; + function createImportSpecifier(propertyName: Identifier, name: Identifier): ImportSpecifier; function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: Decorator[], modifiers: Modifier[], isExportEquals: boolean, expression: Expression, location?: TextRange): ExportAssignment; + function createExportAssignment(decorators: Decorator[], modifiers: Modifier[], isExportEquals: boolean, expression: Expression): ExportAssignment; function updateExportAssignment(node: ExportAssignment, decorators: Decorator[], modifiers: Modifier[], expression: Expression): ExportAssignment; - function createExportDeclaration(decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier?: Expression, location?: TextRange): ExportDeclaration; + function createExportDeclaration(decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier?: Expression): ExportDeclaration; function updateExportDeclaration(node: ExportDeclaration, decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier: Expression): ExportDeclaration; - function createNamedExports(elements: ExportSpecifier[], location?: TextRange): NamedExports; + function createNamedExports(elements: ExportSpecifier[]): NamedExports; function updateNamedExports(node: NamedExports, elements: ExportSpecifier[]): NamedExports; - function createExportSpecifier(name: string | Identifier, propertyName?: string | Identifier, location?: TextRange): ExportSpecifier; + function createExportSpecifier(name: string | Identifier, propertyName?: string | Identifier): ExportSpecifier; function updateExportSpecifier(node: ExportSpecifier, name: Identifier, propertyName: Identifier): ExportSpecifier; - function createJsxElement(openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement, location?: TextRange): JsxElement; + function createExternalModuleReference(expression: Expression): ExternalModuleReference; + function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; + function createJsxElement(openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; - function createJsxSelfClosingElement(tagName: JsxTagNameExpression, attributes: JsxAttributeLike[], location?: TextRange): JsxSelfClosingElement; - function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, attributes: JsxAttributeLike[]): JsxSelfClosingElement; - function createJsxOpeningElement(tagName: JsxTagNameExpression, attributes: JsxAttributeLike[], location?: TextRange): JsxOpeningElement; - function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, attributes: JsxAttributeLike[]): JsxOpeningElement; - function createJsxClosingElement(tagName: JsxTagNameExpression, location?: TextRange): JsxClosingElement; + function createJsxSelfClosingElement(tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxSelfClosingElement; + function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxSelfClosingElement; + function createJsxOpeningElement(tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxOpeningElement; + function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxOpeningElement; + function createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement; function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; - function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression, location?: TextRange): JsxAttribute; + function createJsxAttributes(properties: JsxAttributeLike[]): JsxAttributes; + function updateJsxAttributes(jsxAttributes: JsxAttributes, properties: JsxAttributeLike[]): JsxAttributes; + function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; - function createJsxSpreadAttribute(expression: Expression, location?: TextRange): JsxSpreadAttribute; + function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; - function createJsxExpression(expression: Expression, location?: TextRange): JsxExpression; + function createJsxExpression(expression: Expression, dotDotDotToken: DotDotDotToken): JsxExpression; function updateJsxExpression(node: JsxExpression, expression: Expression): JsxExpression; - function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[], location?: TextRange): HeritageClause; + function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[]): HeritageClause; function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause; - function createCaseClause(expression: Expression, statements: Statement[], location?: TextRange): CaseClause; + function createCaseClause(expression: Expression, statements: Statement[]): CaseClause; function updateCaseClause(node: CaseClause, expression: Expression, statements: Statement[]): CaseClause; - function createDefaultClause(statements: Statement[], location?: TextRange): DefaultClause; + function createDefaultClause(statements: Statement[]): DefaultClause; function updateDefaultClause(node: DefaultClause, statements: Statement[]): DefaultClause; - function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block, location?: TextRange): CatchClause; + function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block): CatchClause; function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause; - function createPropertyAssignment(name: string | PropertyName, initializer: Expression, location?: TextRange): PropertyAssignment; + function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment; - function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer: Expression, location?: TextRange): ShorthandPropertyAssignment; - function createSpreadAssignment(expression: Expression, location?: TextRange): SpreadAssignment; + function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; + function createSpreadAssignment(expression: Expression): SpreadAssignment; function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; + function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; + function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; function updateSourceFileNode(node: SourceFile, statements: Statement[]): SourceFile; + function getMutableClone(node: T): T; function createNotEmittedStatement(original: Node): NotEmittedStatement; - function createEndOfDeclarationMarker(original: Node): EndOfDeclarationMarker; - function createMergeDeclarationMarker(original: Node): MergeDeclarationMarker; - function createPartiallyEmittedExpression(expression: Expression, original?: Node, location?: TextRange): PartiallyEmittedExpression; + function createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression; function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; - function createRawExpression(text: string): RawExpression; + function createBundle(sourceFiles: SourceFile[]): Bundle; + function updateBundle(node: Bundle, sourceFiles: SourceFile[]): Bundle; function createComma(left: Expression, right: Expression): Expression; - function createLessThan(left: Expression, right: Expression, location?: TextRange): Expression; - function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression, location?: TextRange): DestructuringAssignment; - function createAssignment(left: Expression, right: Expression, location?: TextRange): BinaryExpression; + function createLessThan(left: Expression, right: Expression): Expression; + function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; + function createAssignment(left: Expression, right: Expression): BinaryExpression; function createStrictEquality(left: Expression, right: Expression): BinaryExpression; function createStrictInequality(left: Expression, right: Expression): BinaryExpression; function createAdd(left: Expression, right: Expression): BinaryExpression; function createSubtract(left: Expression, right: Expression): BinaryExpression; - function createPostfixIncrement(operand: Expression, location?: TextRange): PostfixUnaryExpression; + function createPostfixIncrement(operand: Expression): PostfixUnaryExpression; function createLogicalAnd(left: Expression, right: Expression): BinaryExpression; function createLogicalOr(left: Expression, right: Expression): BinaryExpression; function createLogicalNot(operand: Expression): PrefixUnaryExpression; function createVoidZero(): VoidExpression; - type TypeOfTag = "undefined" | "number" | "boolean" | "string" | "symbol" | "object" | "function"; - function createTypeCheck(value: Expression, tag: TypeOfTag): BinaryExpression; - function createMemberAccessForPropertyName(target: Expression, memberName: PropertyName, location?: TextRange): MemberExpression; - function createFunctionCall(func: Expression, thisArg: Expression, argumentsList: Expression[], location?: TextRange): CallExpression; - function createFunctionApply(func: Expression, thisArg: Expression, argumentsExpression: Expression, location?: TextRange): CallExpression; - function createArraySlice(array: Expression, start?: number | Expression): CallExpression; - function createArrayConcat(array: Expression, values: Expression[]): CallExpression; - function createMathPow(left: Expression, right: Expression, location?: TextRange): CallExpression; - function createExpressionForJsxElement(jsxFactoryEntity: EntityName, reactNamespace: string, tagName: Expression, props: Expression, children: Expression[], parentElement: JsxOpeningLikeElement, location: TextRange): LeftHandSideExpression; function createExportDefault(expression: Expression): ExportAssignment; function createExternalModuleExport(exportName: Identifier): ExportDeclaration; - function createLetStatement(name: Identifier, initializer: Expression, location?: TextRange): VariableStatement; - function createLetDeclarationList(declarations: VariableDeclaration[], location?: TextRange): VariableDeclarationList; - function createConstDeclarationList(declarations: VariableDeclaration[], location?: TextRange): VariableDeclarationList; - function getHelperName(name: string): Identifier; - interface CallBinding { - target: LeftHandSideExpression; - thisArg: Expression; - } - function createCallBinding(expression: Expression, recordTempVariable: (temp: Identifier) => void, languageVersion?: ScriptTarget, cacheIdentifiers?: boolean): CallBinding; - function inlineExpressions(expressions: Expression[]): Expression; - function createExpressionFromEntityName(node: EntityName | Expression): Expression; - function createExpressionForPropertyName(memberName: PropertyName): Expression; - function createExpressionForObjectLiteralElementLike(node: ObjectLiteralExpression, property: ObjectLiteralElementLike, receiver: Expression): Expression; - function getLocalName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; - function isLocalName(node: Identifier): boolean; - function getExportName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; - function isExportName(node: Identifier): boolean; - function getDeclarationName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; - function getExternalModuleOrNamespaceExportName(ns: Identifier | undefined, node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier | PropertyAccessExpression; - function getNamespaceMemberName(ns: Identifier, name: Identifier, allowComments?: boolean, allowSourceMaps?: boolean): PropertyAccessExpression; - function convertToFunctionBody(node: ConciseBody, multiLine?: boolean): Block; - function addPrologueDirectives(target: Statement[], source: Statement[], ensureUseStrict?: boolean, visitor?: (node: Node) => VisitResult): number; - function startsWithUseStrict(statements: Statement[]): boolean; - function ensureUseStrict(statements: NodeArray): NodeArray; - function parenthesizeBinaryOperand(binaryOperator: SyntaxKind, operand: Expression, isLeftSideOfBinary: boolean, leftOperand?: Expression): Expression; - function parenthesizeForConditionalHead(condition: Expression): Expression; - function parenthesizeForNew(expression: Expression): LeftHandSideExpression; - function parenthesizeForAccess(expression: Expression): LeftHandSideExpression; - function parenthesizePostfixOperand(operand: Expression): LeftHandSideExpression; - function parenthesizePrefixOperand(operand: Expression): UnaryExpression; - function parenthesizeExpressionForList(expression: Expression): Expression; - function parenthesizeExpressionForExpressionStatement(expression: Expression): Expression; - function parenthesizeConciseBody(body: ConciseBody): ConciseBody; - const enum OuterExpressionKinds { - Parentheses = 1, - Assertions = 2, - PartiallyEmittedExpressions = 4, - All = 7, - } - function skipOuterExpressions(node: Expression, kinds?: OuterExpressionKinds): Expression; - function skipOuterExpressions(node: Node, kinds?: OuterExpressionKinds): Node; - function skipParentheses(node: Expression): Expression; - function skipParentheses(node: Node): Node; - function skipAssertions(node: Expression): Expression; - function skipAssertions(node: Node): Node; - function skipPartiallyEmittedExpressions(node: Expression): Expression; - function skipPartiallyEmittedExpressions(node: Node): Node; - function startOnNewLine(node: T): T; - function setOriginalNode(node: T, original: Node): T; function disposeEmitNodes(sourceFile: SourceFile): void; - function getOrCreateEmitNode(node: Node): EmitNode; + function setTextRange(range: T, location: TextRange | undefined): T; function getEmitFlags(node: Node): EmitFlags; function setEmitFlags(node: T, emitFlags: EmitFlags): T; function getSourceMapRange(node: Node): TextRange; @@ -9596,42 +2599,12 @@ declare namespace ts { function setCommentRange(node: T, range: TextRange): T; function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number): PropertyAccessExpression | ElementAccessExpression; - function getExternalHelpersModuleName(node: SourceFile): Identifier; - function getOrCreateExternalHelpersModuleNameIfNeeded(node: SourceFile, compilerOptions: CompilerOptions): Identifier; function addEmitHelper(node: T, helper: EmitHelper): T; function addEmitHelpers(node: T, helpers: EmitHelper[] | undefined): T; function removeEmitHelper(node: Node, helper: EmitHelper): boolean; function getEmitHelpers(node: Node): EmitHelper[] | undefined; function moveEmitHelpers(source: Node, target: Node, predicate: (helper: EmitHelper) => boolean): void; - function compareEmitHelpers(x: EmitHelper, y: EmitHelper): Comparison; - function setTextRange(node: T, location: TextRange): T; - function setNodeFlags(node: T, flags: NodeFlags): T; - function setMultiLine(node: T, multiLine: boolean): T; - function setHasTrailingComma(nodes: NodeArray, hasTrailingComma: boolean): NodeArray; - function getLocalNameForExternalImport(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration, sourceFile: SourceFile): Identifier; - function getExternalModuleNameLiteral(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration, sourceFile: SourceFile, host: EmitHost, resolver: EmitResolver, compilerOptions: CompilerOptions): StringLiteral; - function tryGetModuleNameFromFile(file: SourceFile, host: EmitHost, options: CompilerOptions): StringLiteral; - function getInitializerOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): Expression | undefined; - function getTargetOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): BindingOrAssignmentElementTarget; - function getRestIndicatorOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): BindingOrAssignmentElementRestIndicator; - function getPropertyNameOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): PropertyName; - function getElementsOfBindingOrAssignmentPattern(name: BindingOrAssignmentPattern): BindingOrAssignmentElement[]; - function convertToArrayAssignmentElement(element: BindingOrAssignmentElement): Expression; - function convertToObjectAssignmentElement(element: BindingOrAssignmentElement): ObjectLiteralElementLike; - function convertToAssignmentPattern(node: BindingOrAssignmentPattern): AssignmentPattern; - function convertToObjectAssignmentPattern(node: ObjectBindingOrAssignmentPattern): ObjectLiteralExpression; - function convertToArrayAssignmentPattern(node: ArrayBindingOrAssignmentPattern): ArrayLiteralExpression; - function convertToAssignmentElementTarget(node: BindingOrAssignmentElementTarget): Expression; - interface ExternalModuleInfo { - externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]; - externalHelpersImportDeclaration: ImportDeclaration | undefined; - exportSpecifiers: Map; - exportedBindings: Map; - exportedNames: Identifier[]; - exportEquals: ExportAssignment | undefined; - hasExportStarsToExportValues: boolean; - } - function collectExternalModuleInfo(sourceFile: SourceFile, resolver: EmitResolver, compilerOptions: CompilerOptions): ExternalModuleInfo; + function setOriginalNode(node: T, original: Node): T; } declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; @@ -9640,140 +2613,13 @@ declare namespace ts { function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName; function isExternalModule(file: SourceFile): boolean; function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; - function parseIsolatedJSDocComment(content: string, start?: number, length?: number): { - jsDoc: JSDoc; - diagnostics: Diagnostic[]; - }; - function parseJSDocTypeExpressionForTests(content: string, start?: number, length?: number): { - jsDocTypeExpression: JSDocTypeExpression; - diagnostics: Diagnostic[]; - }; } declare namespace ts { - const enum ModuleInstanceState { - NonInstantiated = 0, - Instantiated = 1, - ConstEnumOnly = 2, - } - function getModuleInstanceState(node: Node): ModuleInstanceState; - function bindSourceFile(file: SourceFile, options: CompilerOptions): void; - function computeTransformFlagsForNode(node: Node, subtreeFlags: TransformFlags): TransformFlags; - function getTransformFlagsSubtreeExclusions(kind: SyntaxKind): TransformFlags; -} -declare namespace ts { - function getNodeId(node: Node): number; - function getSymbolId(symbol: Symbol): number; - function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker; -} -declare namespace ts { - type VisitResult = T | T[]; - function reduceEachChild(node: Node, initial: T, cbNode: (memo: T, node: Node) => T, cbNodeArray?: (memo: T, nodes: Node[]) => T): T; - function visitNode(node: T, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, optional?: boolean, lift?: (node: NodeArray) => T): T; - function visitNode(node: T, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, optional: boolean, lift: (node: NodeArray) => T, parenthesize: (node: Node, parentNode: Node) => Node, parentNode: Node): T; - function visitNodes(nodes: NodeArray, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, start?: number, count?: number): NodeArray; - function visitNodes(nodes: NodeArray, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, start: number, count: number, parenthesize: (node: Node, parentNode: Node) => Node, parentNode: Node): NodeArray; - function visitLexicalEnvironment(statements: NodeArray, visitor: (node: Node) => VisitResult, context: TransformationContext, start?: number, ensureUseStrict?: boolean): NodeArray; - function visitParameterList(nodes: NodeArray, visitor: (node: Node) => VisitResult, context: TransformationContext): NodeArray; - function visitFunctionBody(node: FunctionBody, visitor: (node: Node) => VisitResult, context: TransformationContext): FunctionBody; - function visitFunctionBody(node: ConciseBody, visitor: (node: Node) => VisitResult, context: TransformationContext): ConciseBody; - function visitEachChild(node: T, visitor: (node: Node) => VisitResult, context: TransformationContext): T; - function mergeLexicalEnvironment(statements: NodeArray, declarations: Statement[]): NodeArray; - function mergeLexicalEnvironment(statements: Statement[], declarations: Statement[]): Statement[]; - function mergeFunctionBodyLexicalEnvironment(body: FunctionBody, declarations: Statement[]): FunctionBody; - function mergeFunctionBodyLexicalEnvironment(body: ConciseBody, declarations: Statement[]): ConciseBody; - function liftToBlock(nodes: Node[]): Statement; - function aggregateTransformFlags(node: T): T; - namespace Debug { - const failNotOptional: typeof noop; - const failBadSyntaxKind: (node: Node, message?: string) => void; - const assertEachNode: (nodes: Node[], test: (node: Node) => boolean, message?: string) => void; - const assertNode: (node: Node, test: (node: Node) => boolean, message?: string) => void; - const assertOptionalNode: (node: Node, test: (node: Node) => boolean, message?: string) => void; - const assertOptionalToken: (node: Node, kind: SyntaxKind, message?: string) => void; - const assertMissingNode: (node: Node, message?: string) => void; - } -} -declare namespace ts { - const enum FlattenLevel { - All = 0, - ObjectRest = 1, - } - function flattenDestructuringAssignment(node: VariableDeclaration | DestructuringAssignment, visitor: ((node: Node) => VisitResult) | undefined, context: TransformationContext, level: FlattenLevel, needsValue?: boolean, createAssignmentCallback?: (name: Identifier, value: Expression, location?: TextRange) => Expression): Expression; - function flattenDestructuringBinding(node: VariableDeclaration | ParameterDeclaration, visitor: (node: Node) => VisitResult, context: TransformationContext, level: FlattenLevel, rval?: Expression, hoistTempVariables?: boolean, skipInitializer?: boolean): VariableDeclaration[]; -} -declare namespace ts { - function transformTypeScript(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformESNext(context: TransformationContext): (node: SourceFile) => SourceFile; - function createAssignHelper(context: TransformationContext, attributesSegments: Expression[]): CallExpression; -} -declare namespace ts { - function transformJsx(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES2017(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES2016(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES2015(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformGenerators(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES5(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformModule(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformSystemModule(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES2015Module(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function getTransformers(compilerOptions: CompilerOptions): Transformer[]; - function transformFiles(resolver: EmitResolver, host: EmitHost, sourceFiles: SourceFile[], transformers: Transformer[]): TransformationResult; -} -declare namespace ts { - function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[]; - function writeDeclarationFile(declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean, host: EmitHost, resolver: EmitResolver, emitterDiagnostics: DiagnosticCollection, emitOnlyDtsFiles: boolean): boolean; -} -declare namespace ts { - interface SourceMapWriter { - initialize(filePath: string, sourceMapFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean): void; - reset(): void; - setSourceFile(sourceFile: SourceFile): void; - emitPos(pos: number): void; - emitNodeWithSourceMap(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; - emitTokenWithSourceMap(node: Node, token: SyntaxKind, tokenStartPos: number, emitCallback: (token: SyntaxKind, tokenStartPos: number) => number): number; - getText(): string; - getSourceMappingURL(): string; - getSourceMapData(): SourceMapData; - } - function createSourceMapWriter(host: EmitHost, writer: EmitTextWriter): SourceMapWriter; -} -declare namespace ts { - interface CommentWriter { - reset(): void; - setSourceFile(sourceFile: SourceFile): void; - emitNodeWithComments(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; - emitBodyWithDetachedComments(node: Node, detachedRange: TextRange, emitCallback: (node: Node) => void): void; - emitTrailingCommentsOfPosition(pos: number): void; - } - function createCommentWriter(host: EmitHost, writer: EmitTextWriter, sourceMap: SourceMapWriter): CommentWriter; -} -declare namespace ts { - function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile, emitOnlyDtsFiles?: boolean): EmitResult; + function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } declare namespace ts { function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; function resolveTripleslashReference(moduleName: string, containingFile: string): string; - function computeCommonSourceDirectoryOfFilenames(fileNames: string[], currentDirectory: string, getCanonicalFileName: (fileName: string) => string): string; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; interface FormatDiagnosticsHost { @@ -9784,7 +2630,6 @@ declare namespace ts { function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; - function getResolutionDiagnostic(options: CompilerOptions, {extension}: ResolvedModuleFull): DiagnosticMessage | undefined; } declare namespace ts { interface Node { @@ -9819,7 +2664,7 @@ declare namespace ts { getConstructSignatures(): Signature[]; getStringIndexType(): Type; getNumberIndexType(): Type; - getBaseTypes(): ObjectType[]; + getBaseTypes(): BaseType[]; getNonNullableType(): Type; } interface Signature { @@ -9830,10 +2675,6 @@ declare namespace ts { getDocumentationComment(): SymbolDisplayPart[]; } interface SourceFile { - version: string; - scriptSnapshot: IScriptSnapshot; - nameTable: Map; - getNamedDeclarations(): Map; getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; getLineStarts(): number[]; @@ -9924,8 +2765,6 @@ declare namespace ts { getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; getProgram(): Program; - getNonBoundSourceFile(fileName: string): SourceFile; - getSourceFile(fileName: string): SourceFile; dispose(): void; } interface Classifications { @@ -10043,6 +2882,7 @@ declare namespace ts { InsertSpaceAfterCommaDelimiter: boolean; InsertSpaceAfterSemicolonInForStatements: boolean; InsertSpaceBeforeAndAfterBinaryOperators: boolean; + InsertSpaceAfterConstructor?: boolean; InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; @@ -10051,6 +2891,7 @@ declare namespace ts { InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; InsertSpaceAfterTypeAssertion?: boolean; + InsertSpaceBeforeFunctionParenthesis?: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; } @@ -10058,6 +2899,7 @@ declare namespace ts { insertSpaceAfterCommaDelimiter?: boolean; insertSpaceAfterSemicolonInForStatements?: boolean; insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterConstructor?: boolean; insertSpaceAfterKeywordsInControlFlowStatements?: boolean; insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; @@ -10066,6 +2908,7 @@ declare namespace ts { insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; insertSpaceAfterTypeAssertion?: boolean; + insertSpaceBeforeFunctionParenthesis?: boolean; placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; } @@ -10254,6 +3097,7 @@ declare namespace ts { const letElement = "let"; const directory = "directory"; const externalModuleName = "external module name"; + const jsxAttribute = "JSX attribute"; } namespace ScriptElementKindModifier { const none = ""; @@ -10317,123 +3161,8 @@ declare namespace ts { jsxAttributeStringLiteralValue = 24, } } -declare namespace ts { - const scanner: Scanner; - const emptyArray: any[]; - const enum SemanticMeaning { - None = 0, - Value = 1, - Type = 2, - Namespace = 4, - All = 7, - } - function getMeaningFromDeclaration(node: Node): SemanticMeaning; - function getMeaningFromLocation(node: Node): SemanticMeaning; - function isCallExpressionTarget(node: Node): boolean; - function isNewExpressionTarget(node: Node): boolean; - function climbPastPropertyAccess(node: Node): Node; - function getTargetLabel(referenceNode: Node, labelName: string): Identifier; - function isJumpStatementTarget(node: Node): boolean; - function isLabelName(node: Node): boolean; - function isRightSideOfQualifiedName(node: Node): boolean; - function isRightSideOfPropertyAccess(node: Node): boolean; - function isNameOfModuleDeclaration(node: Node): boolean; - function isNameOfFunctionDeclaration(node: Node): boolean; - function isLiteralNameOfPropertyDeclarationOrIndexAccess(node: Node): boolean; - function isExpressionOfExternalModuleImportEqualsDeclaration(node: Node): boolean; - function isInsideComment(sourceFile: SourceFile, token: Node, position: number): boolean; - function getContainerNode(node: Node): Declaration; - function getNodeKind(node: Node): string; - function getStringLiteralTypeForNode(node: StringLiteral | LiteralTypeNode, typeChecker: TypeChecker): LiteralType; - function isThis(node: Node): boolean; - interface ListItemInfo { - listItemIndex: number; - list: Node; - } - function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number; - function rangeContainsRange(r1: TextRange, r2: TextRange): boolean; - function startEndContainsRange(start: number, end: number, range: TextRange): boolean; - function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean; - function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean; - function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean; - function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean; - function isCompletedNode(n: Node, sourceFile: SourceFile): boolean; - function findListItemInfo(node: Node): ListItemInfo; - function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean; - function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node; - function findContainingList(node: Node): Node; - function getTouchingWord(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; - function getTouchingPropertyName(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; - function getTouchingToken(sourceFile: SourceFile, position: number, includeItemAtEndPosition?: (n: Node) => boolean, includeJsDocComment?: boolean): Node; - function getTokenAtPosition(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; - function findTokenOnLeftOfPosition(file: SourceFile, position: number): Node; - function findNextToken(previousToken: Node, parent: Node): Node; - function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node): Node; - function isInString(sourceFile: SourceFile, position: number): boolean; - function isInComment(sourceFile: SourceFile, position: number): boolean; - function isInsideJsxElementOrAttribute(sourceFile: SourceFile, position: number): boolean; - function isInTemplateString(sourceFile: SourceFile, position: number): boolean; - function isInCommentHelper(sourceFile: SourceFile, position: number, predicate?: (c: CommentRange) => boolean): boolean; - function hasDocComment(sourceFile: SourceFile, position: number): boolean; - function getJsDocTagAtPosition(sourceFile: SourceFile, position: number): JSDocTag; - function getNodeModifiers(node: Node): string; - function getTypeArgumentOrTypeParameterList(node: Node): NodeArray; - function isToken(n: Node): boolean; - function isWord(kind: SyntaxKind): boolean; - function isComment(kind: SyntaxKind): boolean; - function isStringOrRegularExpressionOrTemplateLiteral(kind: SyntaxKind): boolean; - function isPunctuation(kind: SyntaxKind): boolean; - function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean; - function isAccessibilityModifier(kind: SyntaxKind): boolean; - function compareDataObjects(dst: any, src: any): boolean; - function isArrayLiteralOrObjectLiteralDestructuringPattern(node: Node): boolean; - function hasTrailingDirectorySeparator(path: string): boolean; - function isInReferenceComment(sourceFile: SourceFile, position: number): boolean; - function isInNonReferenceComment(sourceFile: SourceFile, position: number): boolean; -} -declare namespace ts { - function isFirstDeclarationOfSymbolParameter(symbol: Symbol): boolean; - function symbolPart(text: string, symbol: Symbol): SymbolDisplayPart; - function displayPart(text: string, kind: SymbolDisplayPartKind): SymbolDisplayPart; - function spacePart(): SymbolDisplayPart; - function keywordPart(kind: SyntaxKind): SymbolDisplayPart; - function punctuationPart(kind: SyntaxKind): SymbolDisplayPart; - function operatorPart(kind: SyntaxKind): SymbolDisplayPart; - function textOrKeywordPart(text: string): SymbolDisplayPart; - function textPart(text: string): SymbolDisplayPart; - function getNewLineOrDefaultFromHost(host: LanguageServiceHost | LanguageServiceShimHost): string; - function lineBreakPart(): SymbolDisplayPart; - function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[]; - function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; - function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): SymbolDisplayPart[]; - function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; - function getDeclaredName(typeChecker: TypeChecker, symbol: Symbol, location: Node): string; - function isImportOrExportSpecifierName(location: Node): boolean; - function stripQuotes(name: string): string; - function scriptKindIs(fileName: string, host: LanguageServiceHost, ...scriptKinds: ScriptKind[]): boolean; - function getScriptKind(fileName: string, host?: LanguageServiceHost): ScriptKind; - function sanitizeConfigFile(configFileName: string, content: string): { - configJsonObject: any; - diagnostics: Diagnostic[]; - }; -} -declare namespace ts.BreakpointResolver { - function spanInSourceFileAtLocation(sourceFile: SourceFile, position: number): TextSpan; -} declare namespace ts { function createClassifier(): Classifier; - function getSemanticClassifications(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, classifiableNames: Map, span: TextSpan): ClassifiedSpan[]; - function getEncodedSemanticClassifications(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, classifiableNames: Map, span: TextSpan): Classifications; - function getSyntacticClassifications(cancellationToken: CancellationToken, sourceFile: SourceFile, span: TextSpan): ClassifiedSpan[]; - function getEncodedSyntacticClassifications(cancellationToken: CancellationToken, sourceFile: SourceFile, span: TextSpan): Classifications; -} -declare namespace ts.Completions { - function getCompletionsAtPosition(host: LanguageServiceHost, typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number): CompletionInfo; - function getCompletionEntryDetails(typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number, entryName: string): CompletionEntryDetails; - function getCompletionEntrySymbol(typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number, entryName: string): Symbol; -} -declare namespace ts.DocumentHighlights { - function getDocumentHighlights(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, position: number, sourceFilesToSearch: SourceFile[]): DocumentHighlights[]; } declare namespace ts { interface DocumentRegistry { @@ -10451,88 +3180,9 @@ declare namespace ts { }; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry; } -declare namespace ts.FindAllReferences { - function findReferencedSymbols(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, findInStrings: boolean, findInComments: boolean): ReferencedSymbol[]; - function getReferencedSymbolsForNode(typeChecker: TypeChecker, cancellationToken: CancellationToken, node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean, implementations: boolean): ReferencedSymbol[]; - function convertReferences(referenceSymbols: ReferencedSymbol[]): ReferenceEntry[]; - function getReferenceEntriesForShorthandPropertyAssignment(node: Node, typeChecker: TypeChecker, result: ReferenceEntry[]): void; - function getReferenceEntryFromNode(node: Node): ReferenceEntry; -} -declare namespace ts.GoToDefinition { - function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number): DefinitionInfo[]; - function getTypeDefinitionAtPosition(typeChecker: TypeChecker, sourceFile: SourceFile, position: number): DefinitionInfo[]; -} -declare namespace ts.GoToImplementation { - function getImplementationAtPosition(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], node: Node): ImplementationLocation[]; -} -declare namespace ts.JsDoc { - function getJsDocCommentsFromDeclarations(declarations: Declaration[]): SymbolDisplayPart[]; - function getAllJsDocCompletionEntries(): CompletionEntry[]; - function getDocCommentTemplateAtPosition(newLine: string, sourceFile: SourceFile, position: number): TextInsertion; -} -declare namespace ts.NavigateTo { - function getNavigateToItems(sourceFiles: SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number, excludeDtsFiles: boolean): NavigateToItem[]; -} -declare namespace ts.NavigationBar { - function getNavigationBarItems(sourceFile: SourceFile): NavigationBarItem[]; - function getNavigationTree(sourceFile: SourceFile): NavigationTree; -} -declare namespace ts.OutliningElementsCollector { - function collectElements(sourceFile: SourceFile): OutliningSpan[]; -} -declare namespace ts { - enum PatternMatchKind { - exact = 0, - prefix = 1, - substring = 2, - camelCase = 3, - } - interface PatternMatch { - kind: PatternMatchKind; - camelCaseWeight?: number; - isCaseSensitive: boolean; - punctuationStripped: boolean; - } - interface PatternMatcher { - getMatchesForLastSegmentOfPattern(candidate: string): PatternMatch[]; - getMatches(candidateContainers: string[], candidate: string): PatternMatch[]; - patternContainsDots: boolean; - } - function createPatternMatcher(pattern: string): PatternMatcher; - function breakIntoCharacterSpans(identifier: string): TextSpan[]; - function breakIntoWordSpans(identifier: string): TextSpan[]; -} declare namespace ts { function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo; } -declare namespace ts.Rename { - function getRenameInfo(typeChecker: TypeChecker, defaultLibFileName: string, getCanonicalFileName: (fileName: string) => string, sourceFile: SourceFile, position: number): RenameInfo; -} -declare namespace ts.SignatureHelp { - const enum ArgumentListKind { - TypeArguments = 0, - CallArguments = 1, - TaggedTemplateArguments = 2, - } - interface ArgumentListInfo { - kind: ArgumentListKind; - invocation: CallLikeExpression; - argumentsSpan: TextSpan; - argumentIndex?: number; - argumentCount: number; - } - function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, cancellationToken: CancellationToken): SignatureHelpItems; - function getContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile): ArgumentListInfo; -} -declare namespace ts.SymbolDisplay { - function getSymbolKind(typeChecker: TypeChecker, symbol: Symbol, location: Node): string; - function getSymbolModifiers(symbol: Symbol): string; - function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker: TypeChecker, symbol: Symbol, sourceFile: SourceFile, enclosingDeclaration: Node, location: Node, semanticMeaning?: SemanticMeaning): { - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - symbolKind: string; - }; -} declare namespace ts { interface TranspileOptions { compilerOptions?: CompilerOptions; @@ -10549,444 +3199,11 @@ declare namespace ts { function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; } -declare namespace ts.formatting { - interface FormattingScanner { - advance(): void; - isOnToken(): boolean; - readTokenInfo(n: Node): TokenInfo; - getCurrentLeadingTrivia(): TextRangeWithKind[]; - lastTrailingTriviaWasNewLine(): boolean; - skipToEndOf(node: Node): void; - close(): void; - } - function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner; -} -declare namespace ts.formatting { - class FormattingContext { - sourceFile: SourceFile; - formattingRequestKind: FormattingRequestKind; - currentTokenSpan: TextRangeWithKind; - nextTokenSpan: TextRangeWithKind; - contextNode: Node; - currentTokenParent: Node; - nextTokenParent: Node; - private contextNodeAllOnSameLine; - private nextNodeAllOnSameLine; - private tokensAreOnSameLine; - private contextNodeBlockIsOnOneLine; - private nextNodeBlockIsOnOneLine; - constructor(sourceFile: SourceFile, formattingRequestKind: FormattingRequestKind); - updateContext(currentRange: TextRangeWithKind, currentTokenParent: Node, nextRange: TextRangeWithKind, nextTokenParent: Node, commonParent: Node): void; - ContextNodeAllOnSameLine(): boolean; - NextNodeAllOnSameLine(): boolean; - TokensAreOnSameLine(): boolean; - ContextNodeBlockIsOnOneLine(): boolean; - NextNodeBlockIsOnOneLine(): boolean; - private NodeIsOnOneLine(node); - private BlockIsOnOneLine(node); - } -} -declare namespace ts.formatting { - const enum FormattingRequestKind { - FormatDocument = 0, - FormatSelection = 1, - FormatOnEnter = 2, - FormatOnSemicolon = 3, - FormatOnClosingCurlyBrace = 4, - } -} -declare namespace ts.formatting { - class Rule { - Descriptor: RuleDescriptor; - Operation: RuleOperation; - Flag: RuleFlags; - constructor(Descriptor: RuleDescriptor, Operation: RuleOperation, Flag?: RuleFlags); - toString(): string; - } -} -declare namespace ts.formatting { - const enum RuleAction { - Ignore = 1, - Space = 2, - NewLine = 4, - Delete = 8, - } -} -declare namespace ts.formatting { - class RuleDescriptor { - LeftTokenRange: Shared.TokenRange; - RightTokenRange: Shared.TokenRange; - constructor(LeftTokenRange: Shared.TokenRange, RightTokenRange: Shared.TokenRange); - toString(): string; - static create1(left: SyntaxKind, right: SyntaxKind): RuleDescriptor; - static create2(left: Shared.TokenRange, right: SyntaxKind): RuleDescriptor; - static create3(left: SyntaxKind, right: Shared.TokenRange): RuleDescriptor; - static create4(left: Shared.TokenRange, right: Shared.TokenRange): RuleDescriptor; - } -} -declare namespace ts.formatting { - const enum RuleFlags { - None = 0, - CanDeleteNewLines = 1, - } -} -declare namespace ts.formatting { - class RuleOperation { - Context: RuleOperationContext; - Action: RuleAction; - constructor(Context: RuleOperationContext, Action: RuleAction); - toString(): string; - static create1(action: RuleAction): RuleOperation; - static create2(context: RuleOperationContext, action: RuleAction): RuleOperation; - } -} -declare namespace ts.formatting { - class RuleOperationContext { - private customContextChecks; - constructor(...funcs: { - (context: FormattingContext): boolean; - }[]); - static Any: RuleOperationContext; - IsAny(): boolean; - InContext(context: FormattingContext): boolean; - } -} -declare namespace ts.formatting { - class Rules { - getRuleName(rule: Rule): string; - [name: string]: any; - IgnoreBeforeComment: Rule; - IgnoreAfterLineComment: Rule; - NoSpaceBeforeSemicolon: Rule; - NoSpaceBeforeColon: Rule; - NoSpaceBeforeQuestionMark: Rule; - SpaceAfterColon: Rule; - SpaceAfterQuestionMarkInConditionalOperator: Rule; - NoSpaceAfterQuestionMark: Rule; - SpaceAfterSemicolon: Rule; - SpaceAfterCloseBrace: Rule; - SpaceBetweenCloseBraceAndElse: Rule; - SpaceBetweenCloseBraceAndWhile: Rule; - NoSpaceAfterCloseBrace: Rule; - NoSpaceBeforeDot: Rule; - NoSpaceAfterDot: Rule; - NoSpaceBeforeOpenBracket: Rule; - NoSpaceAfterCloseBracket: Rule; - SpaceAfterOpenBrace: Rule; - SpaceBeforeCloseBrace: Rule; - NoSpaceAfterOpenBrace: Rule; - NoSpaceBeforeCloseBrace: Rule; - NoSpaceBetweenEmptyBraceBrackets: Rule; - NewLineAfterOpenBraceInBlockContext: Rule; - NewLineBeforeCloseBraceInBlockContext: Rule; - NoSpaceAfterUnaryPrefixOperator: Rule; - NoSpaceAfterUnaryPreincrementOperator: Rule; - NoSpaceAfterUnaryPredecrementOperator: Rule; - NoSpaceBeforeUnaryPostincrementOperator: Rule; - NoSpaceBeforeUnaryPostdecrementOperator: Rule; - SpaceAfterPostincrementWhenFollowedByAdd: Rule; - SpaceAfterAddWhenFollowedByUnaryPlus: Rule; - SpaceAfterAddWhenFollowedByPreincrement: Rule; - SpaceAfterPostdecrementWhenFollowedBySubtract: Rule; - SpaceAfterSubtractWhenFollowedByUnaryMinus: Rule; - SpaceAfterSubtractWhenFollowedByPredecrement: Rule; - NoSpaceBeforeComma: Rule; - SpaceAfterCertainKeywords: Rule; - SpaceAfterLetConstInVariableDeclaration: Rule; - NoSpaceBeforeOpenParenInFuncCall: Rule; - SpaceAfterFunctionInFuncDecl: Rule; - NoSpaceBeforeOpenParenInFuncDecl: Rule; - SpaceAfterVoidOperator: Rule; - NoSpaceBetweenReturnAndSemicolon: Rule; - SpaceBetweenStatements: Rule; - SpaceAfterTryFinally: Rule; - SpaceAfterGetSetInMember: Rule; - SpaceBeforeBinaryKeywordOperator: Rule; - SpaceAfterBinaryKeywordOperator: Rule; - NoSpaceAfterConstructor: Rule; - NoSpaceAfterModuleImport: Rule; - SpaceAfterCertainTypeScriptKeywords: Rule; - SpaceBeforeCertainTypeScriptKeywords: Rule; - SpaceAfterModuleName: Rule; - SpaceBeforeArrow: Rule; - SpaceAfterArrow: Rule; - NoSpaceAfterEllipsis: Rule; - NoSpaceAfterOptionalParameters: Rule; - NoSpaceBeforeOpenAngularBracket: Rule; - NoSpaceBetweenCloseParenAndAngularBracket: Rule; - NoSpaceAfterOpenAngularBracket: Rule; - NoSpaceBeforeCloseAngularBracket: Rule; - NoSpaceAfterCloseAngularBracket: Rule; - NoSpaceBetweenEmptyInterfaceBraceBrackets: Rule; - HighPriorityCommonRules: Rule[]; - LowPriorityCommonRules: Rule[]; - SpaceAfterComma: Rule; - NoSpaceAfterComma: Rule; - SpaceBeforeBinaryOperator: Rule; - SpaceAfterBinaryOperator: Rule; - NoSpaceBeforeBinaryOperator: Rule; - NoSpaceAfterBinaryOperator: Rule; - SpaceAfterKeywordInControl: Rule; - NoSpaceAfterKeywordInControl: Rule; - FunctionOpenBraceLeftTokenRange: Shared.TokenRange; - SpaceBeforeOpenBraceInFunction: Rule; - NewLineBeforeOpenBraceInFunction: Rule; - TypeScriptOpenBraceLeftTokenRange: Shared.TokenRange; - SpaceBeforeOpenBraceInTypeScriptDeclWithBlock: Rule; - NewLineBeforeOpenBraceInTypeScriptDeclWithBlock: Rule; - ControlOpenBraceLeftTokenRange: Shared.TokenRange; - SpaceBeforeOpenBraceInControl: Rule; - NewLineBeforeOpenBraceInControl: Rule; - SpaceAfterSemicolonInFor: Rule; - NoSpaceAfterSemicolonInFor: Rule; - SpaceAfterOpenParen: Rule; - SpaceBeforeCloseParen: Rule; - NoSpaceBetweenParens: Rule; - NoSpaceAfterOpenParen: Rule; - NoSpaceBeforeCloseParen: Rule; - SpaceAfterOpenBracket: Rule; - SpaceBeforeCloseBracket: Rule; - NoSpaceBetweenBrackets: Rule; - NoSpaceAfterOpenBracket: Rule; - NoSpaceBeforeCloseBracket: Rule; - SpaceAfterAnonymousFunctionKeyword: Rule; - NoSpaceAfterAnonymousFunctionKeyword: Rule; - SpaceBeforeAt: Rule; - NoSpaceAfterAt: Rule; - SpaceAfterDecorator: Rule; - NoSpaceBetweenFunctionKeywordAndStar: Rule; - SpaceAfterStarInGeneratorDeclaration: Rule; - NoSpaceBetweenYieldKeywordAndStar: Rule; - SpaceBetweenYieldOrYieldStarAndOperand: Rule; - SpaceBetweenAsyncAndOpenParen: Rule; - SpaceBetweenAsyncAndFunctionKeyword: Rule; - NoSpaceBetweenTagAndTemplateString: Rule; - NoSpaceAfterTemplateHeadAndMiddle: Rule; - SpaceAfterTemplateHeadAndMiddle: Rule; - NoSpaceBeforeTemplateMiddleAndTail: Rule; - SpaceBeforeTemplateMiddleAndTail: Rule; - NoSpaceAfterOpenBraceInJsxExpression: Rule; - SpaceAfterOpenBraceInJsxExpression: Rule; - NoSpaceBeforeCloseBraceInJsxExpression: Rule; - SpaceBeforeCloseBraceInJsxExpression: Rule; - SpaceBeforeJsxAttribute: Rule; - SpaceBeforeSlashInJsxOpeningElement: Rule; - NoSpaceBeforeGreaterThanTokenInJsxOpeningElement: Rule; - NoSpaceBeforeEqualInJsxAttribute: Rule; - NoSpaceAfterEqualInJsxAttribute: Rule; - NoSpaceAfterTypeAssertion: Rule; - SpaceAfterTypeAssertion: Rule; - constructor(); - static IsForContext(context: FormattingContext): boolean; - static IsNotForContext(context: FormattingContext): boolean; - static IsBinaryOpContext(context: FormattingContext): boolean; - static IsNotBinaryOpContext(context: FormattingContext): boolean; - static IsConditionalOperatorContext(context: FormattingContext): boolean; - static IsSameLineTokenOrBeforeMultilineBlockContext(context: FormattingContext): boolean; - static IsBeforeMultilineBlockContext(context: FormattingContext): boolean; - static IsMultilineBlockContext(context: FormattingContext): boolean; - static IsSingleLineBlockContext(context: FormattingContext): boolean; - static IsBlockContext(context: FormattingContext): boolean; - static IsBeforeBlockContext(context: FormattingContext): boolean; - static NodeIsBlockContext(node: Node): boolean; - static IsFunctionDeclContext(context: FormattingContext): boolean; - static IsFunctionDeclarationOrFunctionExpressionContext(context: FormattingContext): boolean; - static IsTypeScriptDeclWithBlockContext(context: FormattingContext): boolean; - static NodeIsTypeScriptDeclWithBlockContext(node: Node): boolean; - static IsAfterCodeBlockContext(context: FormattingContext): boolean; - static IsControlDeclContext(context: FormattingContext): boolean; - static IsObjectContext(context: FormattingContext): boolean; - static IsFunctionCallContext(context: FormattingContext): boolean; - static IsNewContext(context: FormattingContext): boolean; - static IsFunctionCallOrNewContext(context: FormattingContext): boolean; - static IsPreviousTokenNotComma(context: FormattingContext): boolean; - static IsNextTokenNotCloseBracket(context: FormattingContext): boolean; - static IsArrowFunctionContext(context: FormattingContext): boolean; - static IsNonJsxSameLineTokenContext(context: FormattingContext): boolean; - static IsNonJsxElementContext(context: FormattingContext): boolean; - static IsJsxExpressionContext(context: FormattingContext): boolean; - static IsNextTokenParentJsxAttribute(context: FormattingContext): boolean; - static IsJsxAttributeContext(context: FormattingContext): boolean; - static IsJsxSelfClosingElementContext(context: FormattingContext): boolean; - static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean; - static IsEndOfDecoratorContextOnSameLine(context: FormattingContext): boolean; - static NodeIsInDecoratorContext(node: Node): boolean; - static IsStartOfVariableDeclarationList(context: FormattingContext): boolean; - static IsNotFormatOnEnter(context: FormattingContext): boolean; - static IsModuleDeclContext(context: FormattingContext): boolean; - static IsObjectTypeContext(context: FormattingContext): boolean; - static IsTypeArgumentOrParameterOrAssertion(token: TextRangeWithKind, parent: Node): boolean; - static IsTypeArgumentOrParameterOrAssertionContext(context: FormattingContext): boolean; - static IsTypeAssertionContext(context: FormattingContext): boolean; - static IsVoidOpContext(context: FormattingContext): boolean; - static IsYieldOrYieldStarWithOperand(context: FormattingContext): boolean; - } -} -declare namespace ts.formatting { - class RulesMap { - map: RulesBucket[]; - mapRowLength: number; - constructor(); - static create(rules: Rule[]): RulesMap; - Initialize(rules: Rule[]): RulesBucket[]; - FillRules(rules: Rule[], rulesBucketConstructionStateList: RulesBucketConstructionState[]): void; - private GetRuleBucketIndex(row, column); - private FillRule(rule, rulesBucketConstructionStateList); - GetRule(context: FormattingContext): Rule; - } - enum RulesPosition { - IgnoreRulesSpecific = 0, - IgnoreRulesAny, - ContextRulesSpecific, - ContextRulesAny, - NoContextRulesSpecific, - NoContextRulesAny, - } - class RulesBucketConstructionState { - private rulesInsertionIndexBitmap; - constructor(); - GetInsertionIndex(maskPosition: RulesPosition): number; - IncreaseInsertionIndex(maskPosition: RulesPosition): void; - } - class RulesBucket { - private rules; - constructor(); - Rules(): Rule[]; - AddRule(rule: Rule, specificTokens: boolean, constructionState: RulesBucketConstructionState[], rulesBucketIndex: number): void; - } -} -declare namespace ts.formatting { - namespace Shared { - interface ITokenAccess { - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - } - class TokenRangeAccess implements ITokenAccess { - private tokens; - constructor(from: SyntaxKind, to: SyntaxKind, except: SyntaxKind[]); - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - } - class TokenValuesAccess implements ITokenAccess { - private tokens; - constructor(tks: SyntaxKind[]); - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - } - class TokenSingleValueAccess implements ITokenAccess { - token: SyntaxKind; - constructor(token: SyntaxKind); - GetTokens(): SyntaxKind[]; - Contains(tokenValue: SyntaxKind): boolean; - } - class TokenAllAccess implements ITokenAccess { - GetTokens(): SyntaxKind[]; - Contains(): boolean; - toString(): string; - } - class TokenRange { - tokenAccess: ITokenAccess; - constructor(tokenAccess: ITokenAccess); - static FromToken(token: SyntaxKind): TokenRange; - static FromTokens(tokens: SyntaxKind[]): TokenRange; - static FromRange(f: SyntaxKind, to: SyntaxKind, except?: SyntaxKind[]): TokenRange; - static AllTokens(): TokenRange; - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - toString(): string; - static Any: TokenRange; - static AnyIncludingMultilineComments: TokenRange; - static Keywords: TokenRange; - static BinaryOperators: TokenRange; - static BinaryKeywordOperators: TokenRange; - static UnaryPrefixOperators: TokenRange; - static UnaryPrefixExpressions: TokenRange; - static UnaryPreincrementExpressions: TokenRange; - static UnaryPostincrementExpressions: TokenRange; - static UnaryPredecrementExpressions: TokenRange; - static UnaryPostdecrementExpressions: TokenRange; - static Comments: TokenRange; - static TypeNames: TokenRange; - } - } -} -declare namespace ts.formatting { - class RulesProvider { - private globalRules; - private options; - private activeRules; - private rulesMap; - constructor(); - getRuleName(rule: Rule): string; - getRuleByName(name: string): Rule; - getRulesMap(): RulesMap; - ensureUpToDate(options: ts.FormatCodeSettings): void; - private createActiveRules(options); - } -} -declare namespace ts.formatting { - interface TextRangeWithKind extends TextRange { - kind: SyntaxKind; - } - interface TokenInfo { - leadingTrivia: TextRangeWithKind[]; - token: TextRangeWithKind; - trailingTrivia: TextRangeWithKind[]; - } - function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function formatOnSemicolon(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function formatOnClosingCurly(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function formatDocument(sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function formatSelection(start: number, end: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function getIndentationString(indentation: number, options: EditorSettings): string; -} -declare namespace ts.formatting { - namespace SmartIndenter { - function getIndentation(position: number, sourceFile: SourceFile, options: EditorSettings): number; - function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: EditorSettings): number; - function getBaseIndentation(options: EditorSettings): number; - function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean; - function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorSettings): { - column: number; - character: number; - }; - function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorSettings): number; - function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind, indentByDefault: boolean): boolean; - function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind): boolean; - } -} -declare namespace ts { - interface CodeFix { - errorCodes: number[]; - getCodeActions(context: CodeFixContext): CodeAction[] | undefined; - } - interface CodeFixContext { - errorCode: number; - sourceFile: SourceFile; - span: TextSpan; - program: Program; - newLineCharacter: string; - host: LanguageServiceHost; - cancellationToken: CancellationToken; - } - namespace codefix { - function registerCodeFix(action: CodeFix): void; - function getSupportedErrorCodes(): string[]; - function getFixes(context: CodeFixContext): CodeAction[]; - } -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} declare namespace ts { const servicesVersion = "0.5"; interface DisplayPartsSymbolWriter extends SymbolWriter { displayParts(): SymbolDisplayPart[]; } - function toEditorSettings(options: FormatCodeOptions | FormatCodeSettings): FormatCodeSettings; function toEditorSettings(options: EditorOptions | EditorSettings): EditorSettings; function displayPartsToString(displayParts: SymbolDisplayPart[]): string; function getDefaultCompilerOptions(): CompilerOptions; @@ -10995,423 +3212,992 @@ declare namespace ts { let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; - function getNameTable(sourceFile: SourceFile): Map; function getDefaultLibFilePath(options: CompilerOptions): string; } declare namespace ts.server { - class TextStorage { - private readonly host; - private readonly fileName; - private svc; - private svcVersion; - private text; - private lineMap; - private textVersion; - constructor(host: ServerHost, fileName: NormalizedPath); - getVersion(): string; - hasScriptVersionCache(): boolean; - useScriptVersionCache(newText?: string): void; - useText(newText?: string): void; - edit(start: number, end: number, newText: string): void; - reload(text: string): void; - reloadFromFile(tempFileName?: string): void; - getSnapshot(): IScriptSnapshot; - getLineInfo(line: number): ILineInfo; - lineToTextSpan(line: number): TextSpan; - lineOffsetToPosition(line: number, offset: number): number; - positionToLineOffset(position: number): ILineInfo; - private getFileText(tempFileName?); - private ensureNoScriptVersionCache(); - private switchToScriptVersionCache(newText?); - private getOrLoadText(); - private getLineMap(); - private setText(newText); + interface CompressedData { + length: number; + compressionKind: string; + data: any; } - class ScriptInfo { - private readonly host; - readonly fileName: NormalizedPath; - readonly scriptKind: ScriptKind; - hasMixedContent: boolean; - readonly containingProjects: Project[]; - private formatCodeSettings; - readonly path: Path; - private fileWatcher; - private textStorage; - private isOpen; - constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent?: boolean); - isScriptOpen(): boolean; - open(newText: string): void; + type RequireResult = { + module: {}; + error: undefined; + } | { + module: undefined; + error: {}; + }; + interface ServerHost extends System { + setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; + clearTimeout(timeoutId: any): void; + setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; + clearImmediate(timeoutId: any): void; + gc?(): void; + trace?(s: string): void; + require?(initialPath: string, moduleName: string): RequireResult; + } + interface SortedReadonlyArray extends ReadonlyArray { + " __sortedReadonlyArrayBrand": any; + } + interface TypingInstallerRequest { + readonly projectName: string; + readonly kind: "discover" | "closeProject"; + } + interface DiscoverTypings extends TypingInstallerRequest { + readonly fileNames: string[]; + readonly projectRootPath: ts.Path; + readonly compilerOptions: ts.CompilerOptions; + readonly typeAcquisition: ts.TypeAcquisition; + readonly unresolvedImports: SortedReadonlyArray; + readonly cachePath?: string; + readonly kind: "discover"; + } + interface CloseProject extends TypingInstallerRequest { + readonly kind: "closeProject"; + } + type ActionSet = "action::set"; + type ActionInvalidate = "action::invalidate"; + type EventBeginInstallTypes = "event::beginInstallTypes"; + type EventEndInstallTypes = "event::endInstallTypes"; + interface TypingInstallerResponse { + readonly kind: ActionSet | ActionInvalidate | EventBeginInstallTypes | EventEndInstallTypes; + } + interface ProjectResponse extends TypingInstallerResponse { + readonly projectName: string; + } + interface SetTypings extends ProjectResponse { + readonly typeAcquisition: ts.TypeAcquisition; + readonly compilerOptions: ts.CompilerOptions; + readonly typings: string[]; + readonly unresolvedImports: SortedReadonlyArray; + readonly kind: ActionSet; + } + interface InvalidateCachedTypings extends ProjectResponse { + readonly kind: ActionInvalidate; + } + interface InstallTypes extends ProjectResponse { + readonly kind: EventBeginInstallTypes | EventEndInstallTypes; + readonly eventId: number; + readonly typingsInstallerVersion: string; + readonly packagesToInstall: ReadonlyArray; + } + interface BeginInstallTypes extends InstallTypes { + readonly kind: EventBeginInstallTypes; + } + interface EndInstallTypes extends InstallTypes { + readonly kind: EventEndInstallTypes; + readonly installSuccess: boolean; + } +} +declare namespace ts.server { + const ActionSet: ActionSet; + const ActionInvalidate: ActionInvalidate; + const EventBeginInstallTypes: EventBeginInstallTypes; + const EventEndInstallTypes: EventEndInstallTypes; + namespace Arguments { + const GlobalCacheLocation = "--globalTypingsCacheLocation"; + const LogFile = "--logFile"; + const EnableTelemetry = "--enableTelemetry"; + } + function hasArgument(argumentName: string): boolean; + function findArgument(argumentName: string): string; +} +declare namespace ts.server { + enum LogLevel { + terse = 0, + normal = 1, + requestTime = 2, + verbose = 3, + } + const emptyArray: ReadonlyArray; + interface Logger { close(): void; - getSnapshot(): IScriptSnapshot; - getFormatCodeSettings(): FormatCodeSettings; - attachToProject(project: Project): boolean; - isAttached(project: Project): boolean; - detachFromProject(project: Project): void; - detachAllProjects(): void; - getDefaultProject(): Project; - registerFileUpdate(): void; - setFormatOptions(formatSettings: FormatCodeSettings): void; - setWatcher(watcher: FileWatcher): void; - stopWatcher(): void; - getLatestVersion(): string; - reload(script: string): void; - saveTo(fileName: string): void; - reloadFromFile(tempFileName?: NormalizedPath): void; - getLineInfo(line: number): ILineInfo; - editContent(start: number, end: number, newText: string): void; - markContainingProjectsAsDirty(): void; - lineToTextSpan(line: number): TextSpan; - lineOffsetToPosition(line: number, offset: number): number; - positionToLineOffset(position: number): ILineInfo; + hasLevel(level: LogLevel): boolean; + loggingEnabled(): boolean; + perftrc(s: string): void; + info(s: string): void; + startGroup(): void; + endGroup(): void; + msg(s: string, type?: Msg.Types): void; + getLogFileName(): string; } -} -declare namespace ts.server { - class LSHost implements ts.LanguageServiceHost, ModuleResolutionHost { + namespace Msg { + type Err = "Err"; + const Err: Err; + type Info = "Info"; + const Info: Info; + type Perf = "Perf"; + const Perf: Perf; + type Types = Err | Info | Perf; + } + function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, cachePath?: string): DiscoverTypings; + namespace Errors { + function ThrowNoProject(): never; + function ThrowProjectLanguageServiceDisabled(): never; + function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never; + } + function getDefaultFormatCodeSettings(host: ServerHost): FormatCodeSettings; + function mergeMapLikes(target: MapLike, source: MapLike): void; + function removeItemFromSet(items: T[], itemToRemove: T): void; + type NormalizedPath = string & { + __normalizedPathTag: any; + }; + function toNormalizedPath(fileName: string): NormalizedPath; + function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path; + function asNormalizedPath(fileName: string): NormalizedPath; + interface NormalizedPathMap { + get(path: NormalizedPath): T; + set(path: NormalizedPath, value: T): void; + contains(path: NormalizedPath): boolean; + remove(path: NormalizedPath): void; + } + function createNormalizedPathMap(): NormalizedPathMap; + interface ProjectOptions { + configHasFilesProperty?: boolean; + files?: string[]; + wildcardDirectories?: Map; + compilerOptions?: CompilerOptions; + typeAcquisition?: TypeAcquisition; + compileOnSave?: boolean; + } + function isInferredProjectName(name: string): boolean; + function makeInferredProjectName(counter: number): string; + function toSortedReadonlyArray(arr: string[]): SortedReadonlyArray; + class ThrottledOperations { private readonly host; - private readonly project; - private readonly cancellationToken; - private compilationSettings; - private readonly resolvedModuleNames; - private readonly resolvedTypeReferenceDirectives; - private readonly getCanonicalFileName; - private filesWithChangedSetOfUnresolvedImports; - private readonly resolveModuleName; - readonly trace: (s: string) => void; - readonly realpath?: (path: string) => string; - constructor(host: ServerHost, project: Project, cancellationToken: HostCancellationToken); - startRecordingFilesWithChangedResolutions(): void; - finishRecordingFilesWithChangedResolutions(): Path[]; - private resolveNamesWithLocalCache(names, containingFile, cache, loader, getResult, getResultFileName, logChanges); - getProjectVersion(): string; - getCompilationSettings(): CompilerOptions; - useCaseSensitiveFileNames(): boolean; - getCancellationToken(): HostCancellationToken; - resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; - resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModuleFull[]; - getDefaultLibFileName(): string; - getScriptSnapshot(filename: string): ts.IScriptSnapshot; - getScriptFileNames(): string[]; - getTypeRootsVersion(): number; - getScriptKind(fileName: string): ScriptKind; - getScriptVersion(filename: string): string; - getCurrentDirectory(): string; - resolvePath(path: string): string; - fileExists(path: string): boolean; - readFile(fileName: string): string; - directoryExists(path: string): boolean; - readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; - getDirectories(path: string): string[]; - notifyFileRemoved(info: ScriptInfo): void; - setCompilationSettings(opt: ts.CompilerOptions): void; + private pendingTimeouts; + constructor(host: ServerHost); + schedule(operationId: string, delay: number, cb: () => void): void; + private static run(self, operationId, cb); + } + class GcTimer { + private readonly host; + private readonly delay; + private readonly logger; + private timerId; + constructor(host: ServerHost, delay: number, logger: Logger); + scheduleCollect(): void; + private static run(self); } } -declare namespace ts.server { - interface ITypingsInstaller { - enqueueInstallTypingsRequest(p: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray): void; - attach(projectService: ProjectService): void; - onProjectClosed(p: Project): void; - readonly globalTypingsCacheLocation: string; +declare namespace ts.server.protocol { + namespace CommandTypes { + type Brace = "brace"; + type BraceCompletion = "braceCompletion"; + type Change = "change"; + type Close = "close"; + type Completions = "completions"; + type CompletionDetails = "completionEntryDetails"; + type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + type CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + type Configure = "configure"; + type Definition = "definition"; + type Implementation = "implementation"; + type Exit = "exit"; + type Format = "format"; + type Formatonkey = "formatonkey"; + type Geterr = "geterr"; + type GeterrForProject = "geterrForProject"; + type SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + type NavBar = "navbar"; + type Navto = "navto"; + type NavTree = "navtree"; + type NavTreeFull = "navtree-full"; + type Occurrences = "occurrences"; + type DocumentHighlights = "documentHighlights"; + type Open = "open"; + type Quickinfo = "quickinfo"; + type References = "references"; + type Reload = "reload"; + type Rename = "rename"; + type Saveto = "saveto"; + type SignatureHelp = "signatureHelp"; + type TypeDefinition = "typeDefinition"; + type ProjectInfo = "projectInfo"; + type ReloadProjects = "reloadProjects"; + type Unknown = "unknown"; + type OpenExternalProject = "openExternalProject"; + type OpenExternalProjects = "openExternalProjects"; + type CloseExternalProject = "closeExternalProject"; + type TodoComments = "todoComments"; + type Indentation = "indentation"; + type DocCommentTemplate = "docCommentTemplate"; + type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + type GetCodeFixes = "getCodeFixes"; + type GetSupportedCodeFixes = "getSupportedCodeFixes"; } - const nullTypingsInstaller: ITypingsInstaller; - class TypingsCache { - private readonly installer; - private readonly perProjectCache; - constructor(installer: ITypingsInstaller); - getTypingsForProject(project: Project, unresolvedImports: SortedReadonlyArray, forceRefresh: boolean): SortedReadonlyArray; - updateTypingsForProject(projectName: string, compilerOptions: CompilerOptions, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, newTypings: string[]): void; - deleteTypingsForProject(projectName: string): void; - onProjectClosed(project: Project): void; + interface Message { + seq: number; + type: "request" | "response" | "event"; } -} -declare namespace ts.server { - function shouldEmitFile(scriptInfo: ScriptInfo): boolean; - class BuilderFileInfo { - readonly scriptInfo: ScriptInfo; - readonly project: Project; - private lastCheckedShapeSignature; - constructor(scriptInfo: ScriptInfo, project: Project); - isExternalModuleOrHasOnlyAmbientExternalModules(): boolean; - private containsOnlyAmbientModules(sourceFile); - private computeHash(text); - private getSourceFile(); - updateShapeSignature(): boolean; + interface Request extends Message { + command: string; + arguments?: any; } - interface Builder { - readonly project: Project; - getFilesAffectedBy(scriptInfo: ScriptInfo): string[]; - onProjectUpdateGraph(): void; - emitFile(scriptInfo: ScriptInfo, writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => void): boolean; - clear(): void; + interface ReloadProjectsRequest extends Message { + command: CommandTypes.ReloadProjects; } - function createBuilder(project: Project): Builder; -} -declare namespace ts.server { - enum ProjectKind { - Inferred = 0, - Configured = 1, - External = 2, + interface Event extends Message { + event: string; + body?: any; } - function allRootFilesAreJsOrDts(project: Project): boolean; - function allFilesAreJsOrDts(project: Project): boolean; - interface ProjectFilesWithTSDiagnostics extends protocol.ProjectFiles { - projectErrors: Diagnostic[]; + interface Response extends Message { + request_seq: number; + success: boolean; + command: string; + message?: string; + body?: any; } - class UnresolvedImportsMap { - readonly perFileMap: FileMap>; - private version; - clear(): void; - getVersion(): number; - remove(path: Path): void; - get(path: Path): ReadonlyArray; - set(path: Path, value: ReadonlyArray): void; + interface FileRequestArgs { + file: string; + projectFileName?: string; } - abstract class Project { - private readonly projectName; - readonly projectKind: ProjectKind; - readonly projectService: ProjectService; - private documentRegistry; - private compilerOptions; - compileOnSaveEnabled: boolean; - private rootFiles; - private rootFilesMap; - private lsHost; - private program; - private cachedUnresolvedImportsPerFile; - private lastCachedUnresolvedImportsList; - private readonly languageService; + interface DocCommentTemplateRequest extends FileLocationRequest { + command: CommandTypes.DocCommentTemplate; + } + interface DocCommandTemplateResponse extends Response { + body?: TextInsertion; + } + interface TodoCommentRequest extends FileRequest { + command: CommandTypes.TodoComments; + arguments: TodoCommentRequestArgs; + } + interface TodoCommentRequestArgs extends FileRequestArgs { + descriptors: TodoCommentDescriptor[]; + } + interface TodoCommentsResponse extends Response { + body?: TodoComment[]; + } + interface IndentationRequest extends FileLocationRequest { + command: CommandTypes.Indentation; + arguments: IndentationRequestArgs; + } + interface IndentationResponse extends Response { + body?: IndentationResult; + } + interface IndentationResult { + position: number; + indentation: number; + } + interface IndentationRequestArgs extends FileLocationRequestArgs { + options?: EditorSettings; + } + interface ProjectInfoRequestArgs extends FileRequestArgs { + needFileNameList: boolean; + } + interface ProjectInfoRequest extends Request { + command: CommandTypes.ProjectInfo; + arguments: ProjectInfoRequestArgs; + } + interface CompilerOptionsDiagnosticsRequest extends Request { + arguments: CompilerOptionsDiagnosticsRequestArgs; + } + interface CompilerOptionsDiagnosticsRequestArgs { + projectFileName: string; + } + interface ProjectInfo { + configFileName: string; + fileNames?: string[]; + languageServiceDisabled?: boolean; + } + interface DiagnosticWithLinePosition { + message: string; + start: number; + length: number; + startLocation: Location; + endLocation: Location; + category: string; + code: number; + } + interface ProjectInfoResponse extends Response { + body?: ProjectInfo; + } + interface FileRequest extends Request { + arguments: FileRequestArgs; + } + interface FileLocationRequestArgs extends FileRequestArgs { + line: number; + offset: number; + } + interface CodeFixRequest extends Request { + command: CommandTypes.GetCodeFixes; + arguments: CodeFixRequestArgs; + } + interface CodeFixRequestArgs extends FileRequestArgs { + startLine: number; + startOffset: number; + endLine: number; + endOffset: number; + errorCodes?: number[]; + } + interface GetCodeFixesResponse extends Response { + body?: CodeAction[]; + } + interface FileLocationRequest extends FileRequest { + arguments: FileLocationRequestArgs; + } + interface GetSupportedCodeFixesRequest extends Request { + command: CommandTypes.GetSupportedCodeFixes; + } + interface GetSupportedCodeFixesResponse extends Response { + body?: string[]; + } + interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { + start: number; + length: number; + } + interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { + filesToSearch: string[]; + } + interface DefinitionRequest extends FileLocationRequest { + command: CommandTypes.Definition; + } + interface TypeDefinitionRequest extends FileLocationRequest { + command: CommandTypes.TypeDefinition; + } + interface ImplementationRequest extends FileLocationRequest { + command: CommandTypes.Implementation; + } + interface Location { + line: number; + offset: number; + } + interface TextSpan { + start: Location; + end: Location; + } + interface FileSpan extends TextSpan { + file: string; + } + interface DefinitionResponse extends Response { + body?: FileSpan[]; + } + interface TypeDefinitionResponse extends Response { + body?: FileSpan[]; + } + interface ImplementationResponse extends Response { + body?: FileSpan[]; + } + interface BraceCompletionRequest extends FileLocationRequest { + command: CommandTypes.BraceCompletion; + arguments: BraceCompletionRequestArgs; + } + interface BraceCompletionRequestArgs extends FileLocationRequestArgs { + openingBrace: string; + } + interface OccurrencesRequest extends FileLocationRequest { + command: CommandTypes.Occurrences; + } + interface OccurrencesResponseItem extends FileSpan { + isWriteAccess: boolean; + } + interface OccurrencesResponse extends Response { + body?: OccurrencesResponseItem[]; + } + interface DocumentHighlightsRequest extends FileLocationRequest { + command: CommandTypes.DocumentHighlights; + arguments: DocumentHighlightsRequestArgs; + } + interface HighlightSpan extends TextSpan { + kind: string; + } + interface DocumentHighlightsItem { + file: string; + highlightSpans: HighlightSpan[]; + } + interface DocumentHighlightsResponse extends Response { + body?: DocumentHighlightsItem[]; + } + interface ReferencesRequest extends FileLocationRequest { + command: CommandTypes.References; + } + interface ReferencesResponseItem extends FileSpan { + lineText: string; + isWriteAccess: boolean; + isDefinition: boolean; + } + interface ReferencesResponseBody { + refs: ReferencesResponseItem[]; + symbolName: string; + symbolStartOffset: number; + symbolDisplayString: string; + } + interface ReferencesResponse extends Response { + body?: ReferencesResponseBody; + } + interface RenameRequestArgs extends FileLocationRequestArgs { + findInComments?: boolean; + findInStrings?: boolean; + } + interface RenameRequest extends FileLocationRequest { + command: CommandTypes.Rename; + arguments: RenameRequestArgs; + } + interface RenameInfo { + canRename: boolean; + localizedErrorMessage?: string; + displayName: string; + fullDisplayName: string; + kind: string; + kindModifiers: string; + } + interface SpanGroup { + file: string; + locs: TextSpan[]; + } + interface RenameResponseBody { + info: RenameInfo; + locs: SpanGroup[]; + } + interface RenameResponse extends Response { + body?: RenameResponseBody; + } + interface ExternalFile { + fileName: string; + scriptKind?: ScriptKindName | ts.ScriptKind; + hasMixedContent?: boolean; + content?: string; + } + interface ExternalProject { + projectFileName: string; + rootFiles: ExternalFile[]; + options: ExternalProjectCompilerOptions; + typingOptions?: TypeAcquisition; + typeAcquisition?: TypeAcquisition; + } + interface CompileOnSaveMixin { + compileOnSave?: boolean; + } + type ExternalProjectCompilerOptions = CompilerOptions & CompileOnSaveMixin; + interface ProjectChanges { + added: string[]; + removed: string[]; + updated: string[]; + } + interface ConfigureRequestArguments { + hostInfo?: string; + file?: string; + formatOptions?: FormatCodeSettings; + extraFileExtensions?: JsFileExtensionInfo[]; + } + interface ConfigureRequest extends Request { + command: CommandTypes.Configure; + arguments: ConfigureRequestArguments; + } + interface ConfigureResponse extends Response { + } + interface OpenRequestArgs extends FileRequestArgs { + fileContent?: string; + scriptKindName?: ScriptKindName; + } + type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; + interface OpenRequest extends Request { + command: CommandTypes.Open; + arguments: OpenRequestArgs; + } + interface OpenExternalProjectRequest extends Request { + command: CommandTypes.OpenExternalProject; + arguments: OpenExternalProjectArgs; + } + type OpenExternalProjectArgs = ExternalProject; + interface OpenExternalProjectsRequest extends Request { + command: CommandTypes.OpenExternalProjects; + arguments: OpenExternalProjectsArgs; + } + interface OpenExternalProjectsArgs { + projects: ExternalProject[]; + } + interface OpenExternalProjectResponse extends Response { + } + interface OpenExternalProjectsResponse extends Response { + } + interface CloseExternalProjectRequest extends Request { + command: CommandTypes.CloseExternalProject; + arguments: CloseExternalProjectRequestArgs; + } + interface CloseExternalProjectRequestArgs { + projectFileName: string; + } + interface CloseExternalProjectResponse extends Response { + } + interface SetCompilerOptionsForInferredProjectsRequest extends Request { + command: CommandTypes.CompilerOptionsForInferredProjects; + arguments: SetCompilerOptionsForInferredProjectsArgs; + } + interface SetCompilerOptionsForInferredProjectsArgs { + options: ExternalProjectCompilerOptions; + } + interface SetCompilerOptionsForInferredProjectsResponse extends Response { + } + interface ExitRequest extends Request { + command: CommandTypes.Exit; + } + interface CloseRequest extends FileRequest { + command: CommandTypes.Close; + } + interface CompileOnSaveAffectedFileListRequest extends FileRequest { + command: CommandTypes.CompileOnSaveAffectedFileList; + } + interface CompileOnSaveAffectedFileListSingleProject { + projectFileName: string; + fileNames: string[]; + projectUsesOutFile: boolean; + } + interface CompileOnSaveAffectedFileListResponse extends Response { + body: CompileOnSaveAffectedFileListSingleProject[]; + } + interface CompileOnSaveEmitFileRequest extends FileRequest { + command: CommandTypes.CompileOnSaveEmitFile; + arguments: CompileOnSaveEmitFileRequestArgs; + } + interface CompileOnSaveEmitFileRequestArgs extends FileRequestArgs { + forced?: boolean; + } + interface QuickInfoRequest extends FileLocationRequest { + command: CommandTypes.Quickinfo; + } + interface QuickInfoResponseBody { + kind: string; + kindModifiers: string; + start: Location; + end: Location; + displayString: string; + documentation: string; + } + interface QuickInfoResponse extends Response { + body?: QuickInfoResponseBody; + } + interface FormatRequestArgs extends FileLocationRequestArgs { + endLine: number; + endOffset: number; + options?: FormatCodeSettings; + } + interface FormatRequest extends FileLocationRequest { + command: CommandTypes.Format; + arguments: FormatRequestArgs; + } + interface CodeEdit { + start: Location; + end: Location; + newText: string; + } + interface FileCodeEdits { + fileName: string; + textChanges: CodeEdit[]; + } + interface CodeFixResponse extends Response { + body?: CodeAction[]; + } + interface CodeAction { + description: string; + changes: FileCodeEdits[]; + } + interface FormatResponse extends Response { + body?: CodeEdit[]; + } + interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { + key: string; + options?: FormatCodeSettings; + } + interface FormatOnKeyRequest extends FileLocationRequest { + command: CommandTypes.Formatonkey; + arguments: FormatOnKeyRequestArgs; + } + interface CompletionsRequestArgs extends FileLocationRequestArgs { + prefix?: string; + } + interface CompletionsRequest extends FileLocationRequest { + command: CommandTypes.Completions; + arguments: CompletionsRequestArgs; + } + interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { + entryNames: string[]; + } + interface CompletionDetailsRequest extends FileLocationRequest { + command: CommandTypes.CompletionDetails; + arguments: CompletionDetailsRequestArgs; + } + interface SymbolDisplayPart { + text: string; + kind: string; + } + interface CompletionEntry { + name: string; + kind: string; + kindModifiers: string; + sortText: string; + replacementSpan?: TextSpan; + } + interface CompletionEntryDetails { + name: string; + kind: string; + kindModifiers: string; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + } + interface CompletionsResponse extends Response { + body?: CompletionEntry[]; + } + interface CompletionDetailsResponse extends Response { + body?: CompletionEntryDetails[]; + } + interface SignatureHelpParameter { + name: string; + documentation: SymbolDisplayPart[]; + displayParts: SymbolDisplayPart[]; + isOptional: boolean; + } + interface SignatureHelpItem { + isVariadic: boolean; + prefixDisplayParts: SymbolDisplayPart[]; + suffixDisplayParts: SymbolDisplayPart[]; + separatorDisplayParts: SymbolDisplayPart[]; + parameters: SignatureHelpParameter[]; + documentation: SymbolDisplayPart[]; + } + interface SignatureHelpItems { + items: SignatureHelpItem[]; + applicableSpan: TextSpan; + selectedItemIndex: number; + argumentIndex: number; + argumentCount: number; + } + interface SignatureHelpRequestArgs extends FileLocationRequestArgs { + } + interface SignatureHelpRequest extends FileLocationRequest { + command: CommandTypes.SignatureHelp; + arguments: SignatureHelpRequestArgs; + } + interface SignatureHelpResponse extends Response { + body?: SignatureHelpItems; + } + interface SemanticDiagnosticsSyncRequest extends FileRequest { + command: CommandTypes.SemanticDiagnosticsSync; + arguments: SemanticDiagnosticsSyncRequestArgs; + } + interface SemanticDiagnosticsSyncRequestArgs extends FileRequestArgs { + includeLinePosition?: boolean; + } + interface SemanticDiagnosticsSyncResponse extends Response { + body?: Diagnostic[] | DiagnosticWithLinePosition[]; + } + interface SyntacticDiagnosticsSyncRequest extends FileRequest { + command: CommandTypes.SyntacticDiagnosticsSync; + arguments: SyntacticDiagnosticsSyncRequestArgs; + } + interface SyntacticDiagnosticsSyncRequestArgs extends FileRequestArgs { + includeLinePosition?: boolean; + } + interface SyntacticDiagnosticsSyncResponse extends Response { + body?: Diagnostic[] | DiagnosticWithLinePosition[]; + } + interface GeterrForProjectRequestArgs { + file: string; + delay: number; + } + interface GeterrForProjectRequest extends Request { + command: CommandTypes.GeterrForProject; + arguments: GeterrForProjectRequestArgs; + } + interface GeterrRequestArgs { + files: string[]; + delay: number; + } + interface GeterrRequest extends Request { + command: CommandTypes.Geterr; + arguments: GeterrRequestArgs; + } + type RequestCompletedEventName = "requestCompleted"; + interface RequestCompletedEvent extends Event { + event: RequestCompletedEventName; + body: RequestCompletedEventBody; + } + interface RequestCompletedEventBody { + request_seq: number; + } + interface Diagnostic { + start: Location; + end: Location; + text: string; + code?: number; + } + interface DiagnosticEventBody { + file: string; + diagnostics: Diagnostic[]; + } + interface DiagnosticEvent extends Event { + body?: DiagnosticEventBody; + } + interface ConfigFileDiagnosticEventBody { + triggerFile: string; + configFile: string; + diagnostics: Diagnostic[]; + } + interface ConfigFileDiagnosticEvent extends Event { + body?: ConfigFileDiagnosticEventBody; + event: "configFileDiag"; + } + type ProjectLanguageServiceStateEventName = "projectLanguageServiceState"; + interface ProjectLanguageServiceStateEvent extends Event { + event: ProjectLanguageServiceStateEventName; + body?: ProjectLanguageServiceStateEventBody; + } + interface ProjectLanguageServiceStateEventBody { + projectName: string; languageServiceEnabled: boolean; - builder: Builder; - private updatedFileNames; - private lastReportedFileNames; - private lastReportedVersion; - private projectStructureVersion; - private projectStateVersion; - private typingFiles; - protected projectErrors: Diagnostic[]; - typesVersion: number; - isNonTsProject(): boolean; - isJsOnlyProject(): boolean; - getCachedUnresolvedImportsPerFile_TestOnly(): UnresolvedImportsMap; - constructor(projectName: string, projectKind: ProjectKind, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, languageServiceEnabled: boolean, compilerOptions: CompilerOptions, compileOnSaveEnabled: boolean); - private setInternalCompilerOptionsForEmittingJsFiles(); - getProjectErrors(): Diagnostic[]; - getLanguageService(ensureSynchronized?: boolean): LanguageService; - getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[]; - getProjectVersion(): string; - enableLanguageService(): void; - disableLanguageService(): void; - getProjectName(): string; - abstract getProjectRootPath(): string | undefined; - abstract getTypeAcquisition(): TypeAcquisition; - getSourceFile(path: Path): SourceFile; - updateTypes(): void; - close(): void; - getCompilerOptions(): CompilerOptions; - hasRoots(): boolean; - getRootFiles(): NormalizedPath[]; - getRootFilesLSHost(): string[]; - getRootScriptInfos(): ScriptInfo[]; - getScriptInfos(): ScriptInfo[]; - getFileEmitOutput(info: ScriptInfo, emitOnlyDtsFiles: boolean): EmitOutput; - getFileNames(excludeFilesFromExternalLibraries?: boolean): NormalizedPath[]; - getAllEmittableFiles(): string[]; - containsScriptInfo(info: ScriptInfo): boolean; - containsFile(filename: NormalizedPath, requireOpen?: boolean): boolean; - isRoot(info: ScriptInfo): boolean; - addRoot(info: ScriptInfo): void; - removeFile(info: ScriptInfo, detachFromProject?: boolean): void; - registerFileUpdate(fileName: string): void; - markAsDirty(): void; - private extractUnresolvedImportsFromSourceFile(file, result); - updateGraph(): boolean; - private setTypings(typings); - private updateGraphWorker(); - getScriptInfoLSHost(fileName: string): ScriptInfo; - getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo; - getScriptInfo(uncheckedFileName: string): ScriptInfo; - filesToString(): string; - setCompilerOptions(compilerOptions: CompilerOptions): void; - reloadScript(filename: NormalizedPath, tempFileName?: NormalizedPath): boolean; - getChangesSinceVersion(lastKnownVersion?: number): ProjectFilesWithTSDiagnostics; - getReferencedFiles(path: Path): Path[]; - private removeRootFileIfNecessary(info); } - class InferredProject extends Project { - private static newName; - directoriesWatchedForTsconfig: string[]; - constructor(projectService: ProjectService, documentRegistry: ts.DocumentRegistry, compilerOptions: CompilerOptions); - getProjectRootPath(): string; - close(): void; - getTypeAcquisition(): TypeAcquisition; + interface ReloadRequestArgs extends FileRequestArgs { + tmpfile: string; } - class ConfiguredProject extends Project { - private wildcardDirectories; - compileOnSaveEnabled: boolean; - private typeAcquisition; - private projectFileWatcher; - private directoryWatcher; - private directoriesWatchedForWildcards; - private typeRootsWatchers; - readonly canonicalConfigFilePath: NormalizedPath; - openRefCount: number; - constructor(configFileName: NormalizedPath, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, compilerOptions: CompilerOptions, wildcardDirectories: Map, languageServiceEnabled: boolean, compileOnSaveEnabled: boolean); - getConfigFilePath(): string; - getProjectRootPath(): string; - setProjectErrors(projectErrors: Diagnostic[]): void; - setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; - getTypeAcquisition(): TypeAcquisition; - watchConfigFile(callback: (project: ConfiguredProject) => void): void; - watchTypeRoots(callback: (project: ConfiguredProject, path: string) => void): void; - watchConfigDirectory(callback: (project: ConfiguredProject, path: string) => void): void; - watchWildcards(callback: (project: ConfiguredProject, path: string) => void): void; - stopWatchingDirectory(): void; - close(): void; - addOpenRef(): void; - deleteOpenRef(): number; - getEffectiveTypeRoots(): string[]; + interface ReloadRequest extends FileRequest { + command: CommandTypes.Reload; + arguments: ReloadRequestArgs; } - class ExternalProject extends Project { - compileOnSaveEnabled: boolean; - private readonly projectFilePath; - private typeAcquisition; - constructor(externalProjectName: string, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, compilerOptions: CompilerOptions, languageServiceEnabled: boolean, compileOnSaveEnabled: boolean, projectFilePath?: string); - getProjectRootPath(): string; - getTypeAcquisition(): TypeAcquisition; - setProjectErrors(projectErrors: Diagnostic[]): void; - setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; + interface ReloadResponse extends Response { } + interface SavetoRequestArgs extends FileRequestArgs { + tmpfile: string; + } + interface SavetoRequest extends FileRequest { + command: CommandTypes.Saveto; + arguments: SavetoRequestArgs; + } + interface NavtoRequestArgs extends FileRequestArgs { + searchValue: string; + maxResultCount?: number; + currentFileOnly?: boolean; + projectFileName?: string; + } + interface NavtoRequest extends FileRequest { + command: CommandTypes.Navto; + arguments: NavtoRequestArgs; + } + interface NavtoItem { + name: string; + kind: string; + matchKind?: string; + isCaseSensitive?: boolean; + kindModifiers?: string; + file: string; + start: Location; + end: Location; + containerName?: string; + containerKind?: string; + } + interface NavtoResponse extends Response { + body?: NavtoItem[]; + } + interface ChangeRequestArgs extends FormatRequestArgs { + insertString?: string; + } + interface ChangeRequest extends FileLocationRequest { + command: CommandTypes.Change; + arguments: ChangeRequestArgs; + } + interface BraceResponse extends Response { + body?: TextSpan[]; + } + interface BraceRequest extends FileLocationRequest { + command: CommandTypes.Brace; + } + interface NavBarRequest extends FileRequest { + command: CommandTypes.NavBar; + } + interface NavTreeRequest extends FileRequest { + command: CommandTypes.NavTree; + } + interface NavigationBarItem { + text: string; + kind: string; + kindModifiers?: string; + spans: TextSpan[]; + childItems?: NavigationBarItem[]; + indent: number; + } + interface NavigationTree { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems?: NavigationTree[]; + } + type TelemetryEventName = "telemetry"; + interface TelemetryEvent extends Event { + event: TelemetryEventName; + body: TelemetryEventBody; + } + interface TelemetryEventBody { + telemetryEventName: string; + payload: any; + } + type TypingsInstalledTelemetryEventName = "typingsInstalled"; + interface TypingsInstalledTelemetryEventBody extends TelemetryEventBody { + telemetryEventName: TypingsInstalledTelemetryEventName; + payload: TypingsInstalledTelemetryEventPayload; + } + interface TypingsInstalledTelemetryEventPayload { + installedPackages: string; + installSuccess: boolean; + typingsInstallerVersion: string; + } + type BeginInstallTypesEventName = "beginInstallTypes"; + type EndInstallTypesEventName = "endInstallTypes"; + interface BeginInstallTypesEvent extends Event { + event: BeginInstallTypesEventName; + body: BeginInstallTypesEventBody; + } + interface EndInstallTypesEvent extends Event { + event: EndInstallTypesEventName; + body: EndInstallTypesEventBody; + } + interface InstallTypesEventBody { + eventId: number; + packages: ReadonlyArray; + } + interface BeginInstallTypesEventBody extends InstallTypesEventBody { + } + interface EndInstallTypesEventBody extends InstallTypesEventBody { + success: boolean; + } + interface NavBarResponse extends Response { + body?: NavigationBarItem[]; + } + interface NavTreeResponse extends Response { + body?: NavigationTree; + } + namespace IndentStyle { + type None = "None"; + type Block = "Block"; + type Smart = "Smart"; + } + type IndentStyle = IndentStyle.None | IndentStyle.Block | IndentStyle.Smart; + interface EditorSettings { + baseIndentSize?: number; + indentSize?: number; + tabSize?: number; + newLineCharacter?: string; + convertTabsToSpaces?: boolean; + indentStyle?: IndentStyle | ts.IndentStyle; + } + interface FormatCodeSettings extends EditorSettings { + insertSpaceAfterCommaDelimiter?: boolean; + insertSpaceAfterSemicolonInForStatements?: boolean; + insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterConstructor?: boolean; + insertSpaceAfterKeywordsInControlFlowStatements?: boolean; + insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + insertSpaceBeforeFunctionParenthesis?: boolean; + placeOpenBraceOnNewLineForFunctions?: boolean; + placeOpenBraceOnNewLineForControlBlocks?: boolean; + } + interface CompilerOptions { + allowJs?: boolean; + allowSyntheticDefaultImports?: boolean; + allowUnreachableCode?: boolean; + allowUnusedLabels?: boolean; + baseUrl?: string; + charset?: string; + declaration?: boolean; + declarationDir?: string; + disableSizeLimit?: boolean; + emitBOM?: boolean; + emitDecoratorMetadata?: boolean; + experimentalDecorators?: boolean; + forceConsistentCasingInFileNames?: boolean; + inlineSourceMap?: boolean; + inlineSources?: boolean; + isolatedModules?: boolean; + jsx?: JsxEmit | ts.JsxEmit; + lib?: string[]; + locale?: string; + mapRoot?: string; + maxNodeModuleJsDepth?: number; + module?: ModuleKind | ts.ModuleKind; + moduleResolution?: ModuleResolutionKind | ts.ModuleResolutionKind; + newLine?: NewLineKind | ts.NewLineKind; + noEmit?: boolean; + noEmitHelpers?: boolean; + noEmitOnError?: boolean; + noErrorTruncation?: boolean; + noFallthroughCasesInSwitch?: boolean; + noImplicitAny?: boolean; + noImplicitReturns?: boolean; + noImplicitThis?: boolean; + noUnusedLocals?: boolean; + noUnusedParameters?: boolean; + noImplicitUseStrict?: boolean; + noLib?: boolean; + noResolve?: boolean; + out?: string; + outDir?: string; + outFile?: string; + paths?: MapLike; + plugins?: PluginImport[]; + preserveConstEnums?: boolean; + project?: string; + reactNamespace?: string; + removeComments?: boolean; + rootDir?: string; + rootDirs?: string[]; + skipLibCheck?: boolean; + skipDefaultLibCheck?: boolean; + sourceMap?: boolean; + sourceRoot?: string; + strictNullChecks?: boolean; + suppressExcessPropertyErrors?: boolean; + suppressImplicitAnyIndexErrors?: boolean; + target?: ScriptTarget | ts.ScriptTarget; + traceResolution?: boolean; + types?: string[]; + typeRoots?: string[]; + [option: string]: CompilerOptionsValue | undefined; + } + namespace JsxEmit { + type None = "None"; + type Preserve = "Preserve"; + type ReactNative = "ReactNative"; + type React = "React"; + } + type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React | JsxEmit.ReactNative; + namespace ModuleKind { + type None = "None"; + type CommonJS = "CommonJS"; + type AMD = "AMD"; + type UMD = "UMD"; + type System = "System"; + type ES6 = "ES6"; + type ES2015 = "ES2015"; + } + type ModuleKind = ModuleKind.None | ModuleKind.CommonJS | ModuleKind.AMD | ModuleKind.UMD | ModuleKind.System | ModuleKind.ES6 | ModuleKind.ES2015; + namespace ModuleResolutionKind { + type Classic = "Classic"; + type Node = "Node"; + } + type ModuleResolutionKind = ModuleResolutionKind.Classic | ModuleResolutionKind.Node; + namespace NewLineKind { + type Crlf = "Crlf"; + type Lf = "Lf"; + } + type NewLineKind = NewLineKind.Crlf | NewLineKind.Lf; + namespace ScriptTarget { + type ES3 = "ES3"; + type ES5 = "ES5"; + type ES6 = "ES6"; + type ES2015 = "ES2015"; + } + type ScriptTarget = ScriptTarget.ES3 | ScriptTarget.ES5 | ScriptTarget.ES6 | ScriptTarget.ES2015; } declare namespace ts.server { - const maxProgramSizeForNonTsFiles: number; - const ContextEvent = "context"; - const ConfigFileDiagEvent = "configFileDiag"; - const ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; - interface ContextEvent { - eventName: typeof ContextEvent; - data: { - project: Project; - fileName: NormalizedPath; - }; + interface ServerCancellationToken extends HostCancellationToken { + setRequest(requestId: number): void; + resetRequest(requestId: number): void; } - interface ConfigFileDiagEvent { - eventName: typeof ConfigFileDiagEvent; - data: { - triggerFile: string; - configFileName: string; - diagnostics: Diagnostic[]; - }; - } - interface ProjectLanguageServiceStateEvent { - eventName: typeof ProjectLanguageServiceStateEvent; - data: { - project: Project; - languageServiceEnabled: boolean; - }; - } - type ProjectServiceEvent = ContextEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent; - interface ProjectServiceEventHandler { - (event: ProjectServiceEvent): void; - } - function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings; - function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin; - function tryConvertScriptKindName(scriptKindName: protocol.ScriptKindName | ScriptKind): ScriptKind; - function convertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind; - function combineProjectOutput(projects: Project[], action: (project: Project) => T[], comparer?: (a: T, b: T) => number, areEqual?: (a: T, b: T) => boolean): T[]; - interface HostConfiguration { - formatCodeOptions: FormatCodeSettings; - hostInfo: string; - extraFileExtensions?: FileExtensionInfo[]; - } - interface OpenConfiguredProjectResult { - configFileName?: NormalizedPath; - configFileErrors?: Diagnostic[]; - } - class ProjectService { - readonly host: ServerHost; - readonly logger: Logger; - readonly cancellationToken: HostCancellationToken; - readonly useSingleInferredProject: boolean; - readonly typingsInstaller: ITypingsInstaller; - private readonly eventHandler; - readonly typingsCache: TypingsCache; - private readonly documentRegistry; - private readonly filenameToScriptInfo; - private readonly externalProjectToConfiguredProjectMap; - readonly externalProjects: ExternalProject[]; - readonly inferredProjects: InferredProject[]; - readonly configuredProjects: ConfiguredProject[]; - readonly openFiles: ScriptInfo[]; - private compilerOptionsForInferredProjects; - private compileOnSaveForInferredProjects; - private readonly directoryWatchers; - private readonly throttledOperations; - private readonly hostConfiguration; - private changedFiles; - readonly toCanonicalFileName: (f: string) => string; - lastDeletedFile: ScriptInfo; - constructor(host: ServerHost, logger: Logger, cancellationToken: HostCancellationToken, useSingleInferredProject: boolean, typingsInstaller?: ITypingsInstaller, eventHandler?: ProjectServiceEventHandler); - getChangedFiles_TestOnly(): ScriptInfo[]; - ensureInferredProjectsUpToDate_TestOnly(): void; - getCompilerOptionsForInferredProjects(): CompilerOptions; - onUpdateLanguageServiceStateForProject(project: Project, languageServiceEnabled: boolean): void; - updateTypingsForProject(response: SetTypings | InvalidateCachedTypings): void; - setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions): void; - stopWatchingDirectory(directory: string): void; - findProject(projectName: string): Project; - getDefaultProjectForFile(fileName: NormalizedPath, refreshInferredProjects: boolean): Project; - private ensureInferredProjectsUpToDate(); - private findContainingExternalProject(fileName); - getFormatCodeOptions(file?: NormalizedPath): FormatCodeSettings; - private updateProjectGraphs(projects); - private onSourceFileChanged(fileName); - private handleDeletedFile(info); - private onTypeRootFileChanged(project, fileName); - private onSourceFileInDirectoryChangedForConfiguredProject(project, fileName); - private handleChangeInSourceFileForConfiguredProject(project, triggerFile); - private onConfigChangedForConfiguredProject(project); - private onConfigFileAddedForInferredProject(fileName); - private getCanonicalFileName(fileName); - private removeProject(project); - private assignScriptInfoToInferredProjectIfNecessary(info, addToListOfOpenFiles); - private closeOpenFile(info); - private openOrUpdateConfiguredProjectForFile(fileName); - private findConfigFile(searchPath); - private printProjects(); - private findConfiguredProjectByProjectName(configFileName); - private findExternalProjectByProjectName(projectFileName); - private convertConfigFileContentToProjectOptions(configFilename); - private exceededTotalSizeLimitForNonTsFiles(options, fileNames, propertyReader); - private createAndAddExternalProject(projectFileName, files, options, typeAcquisition); - private reportConfigFileDiagnostics(configFileName, diagnostics, triggerFile); - private createAndAddConfiguredProject(configFileName, projectOptions, configFileErrors, clientFileName?); - private watchConfigDirectoryForProject(project, options); - private addFilesToProjectAndUpdateGraph(project, files, propertyReader, clientFileName, typeAcquisition, configFileErrors); - private openConfigFile(configFileName, clientFileName?); - private updateNonInferredProject(project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave, configFileErrors); - private updateConfiguredProject(project); - createInferredProjectWithRootFileIfNecessary(root: ScriptInfo): InferredProject; - getOrCreateScriptInfo(uncheckedFileName: string, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind): ScriptInfo; - getScriptInfo(uncheckedFileName: string): ScriptInfo; - getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): ScriptInfo; - getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo; - getScriptInfoForPath(fileName: Path): ScriptInfo; - setHostConfiguration(args: protocol.ConfigureRequestArguments): void; - closeLog(): void; - reloadProjects(): void; - refreshInferredProjects(): void; - openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind): OpenConfiguredProjectResult; - openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): OpenConfiguredProjectResult; - closeClientFile(uncheckedFileName: string): void; - private collectChanges(lastKnownProjectVersions, currentProjects, result); - synchronizeProjectList(knownProjects: protocol.ProjectVersionInfo[]): ProjectFilesWithTSDiagnostics[]; - applyChangesInOpenFiles(openFiles: protocol.ExternalFile[], changedFiles: protocol.ChangedOpenFile[], closedFiles: string[]): void; - private closeConfiguredProject(configFile); - closeExternalProject(uncheckedFileName: string, suppressRefresh?: boolean): void; - openExternalProjects(projects: protocol.ExternalProject[]): void; - openExternalProject(proj: protocol.ExternalProject, suppressRefreshOfInferredProjects?: boolean): void; - } -} -declare namespace ts.server { + const nullCancellationToken: ServerCancellationToken; interface PendingErrorCheck { fileName: NormalizedPath; project: Project; @@ -11421,51 +4207,36 @@ declare namespace ts.server { } namespace CommandNames { const Brace: protocol.CommandTypes.Brace; - const BraceFull: protocol.CommandTypes.BraceFull; const BraceCompletion: protocol.CommandTypes.BraceCompletion; const Change: protocol.CommandTypes.Change; const Close: protocol.CommandTypes.Close; const Completions: protocol.CommandTypes.Completions; - const CompletionsFull: protocol.CommandTypes.CompletionsFull; const CompletionDetails: protocol.CommandTypes.CompletionDetails; const CompileOnSaveAffectedFileList: protocol.CommandTypes.CompileOnSaveAffectedFileList; const CompileOnSaveEmitFile: protocol.CommandTypes.CompileOnSaveEmitFile; const Configure: protocol.CommandTypes.Configure; const Definition: protocol.CommandTypes.Definition; - const DefinitionFull: protocol.CommandTypes.DefinitionFull; const Exit: protocol.CommandTypes.Exit; const Format: protocol.CommandTypes.Format; const Formatonkey: protocol.CommandTypes.Formatonkey; - const FormatFull: protocol.CommandTypes.FormatFull; - const FormatonkeyFull: protocol.CommandTypes.FormatonkeyFull; - const FormatRangeFull: protocol.CommandTypes.FormatRangeFull; const Geterr: protocol.CommandTypes.Geterr; const GeterrForProject: protocol.CommandTypes.GeterrForProject; const Implementation: protocol.CommandTypes.Implementation; - const ImplementationFull: protocol.CommandTypes.ImplementationFull; const SemanticDiagnosticsSync: protocol.CommandTypes.SemanticDiagnosticsSync; const SyntacticDiagnosticsSync: protocol.CommandTypes.SyntacticDiagnosticsSync; const NavBar: protocol.CommandTypes.NavBar; - const NavBarFull: protocol.CommandTypes.NavBarFull; const NavTree: protocol.CommandTypes.NavTree; const NavTreeFull: protocol.CommandTypes.NavTreeFull; const Navto: protocol.CommandTypes.Navto; - const NavtoFull: protocol.CommandTypes.NavtoFull; const Occurrences: protocol.CommandTypes.Occurrences; const DocumentHighlights: protocol.CommandTypes.DocumentHighlights; - const DocumentHighlightsFull: protocol.CommandTypes.DocumentHighlightsFull; const Open: protocol.CommandTypes.Open; const Quickinfo: protocol.CommandTypes.Quickinfo; - const QuickinfoFull: protocol.CommandTypes.QuickinfoFull; const References: protocol.CommandTypes.References; - const ReferencesFull: protocol.CommandTypes.ReferencesFull; const Reload: protocol.CommandTypes.Reload; const Rename: protocol.CommandTypes.Rename; - const RenameInfoFull: protocol.CommandTypes.RenameInfoFull; - const RenameLocationsFull: protocol.CommandTypes.RenameLocationsFull; const Saveto: protocol.CommandTypes.Saveto; const SignatureHelp: protocol.CommandTypes.SignatureHelp; - const SignatureHelpFull: protocol.CommandTypes.SignatureHelpFull; const TypeDefinition: protocol.CommandTypes.TypeDefinition; const ProjectInfo: protocol.CommandTypes.ProjectInfo; const ReloadProjects: protocol.CommandTypes.ReloadProjects; @@ -11473,25 +4244,17 @@ declare namespace ts.server { const OpenExternalProject: protocol.CommandTypes.OpenExternalProject; const OpenExternalProjects: protocol.CommandTypes.OpenExternalProjects; const CloseExternalProject: protocol.CommandTypes.CloseExternalProject; - const SynchronizeProjectList: protocol.CommandTypes.SynchronizeProjectList; - const ApplyChangedToOpenFiles: protocol.CommandTypes.ApplyChangedToOpenFiles; - const EncodedSemanticClassificationsFull: protocol.CommandTypes.EncodedSemanticClassificationsFull; - const Cleanup: protocol.CommandTypes.Cleanup; - const OutliningSpans: protocol.CommandTypes.OutliningSpans; const TodoComments: protocol.CommandTypes.TodoComments; const Indentation: protocol.CommandTypes.Indentation; const DocCommentTemplate: protocol.CommandTypes.DocCommentTemplate; - const CompilerOptionsDiagnosticsFull: protocol.CommandTypes.CompilerOptionsDiagnosticsFull; - const NameOrDottedNameSpan: protocol.CommandTypes.NameOrDottedNameSpan; - const BreakpointStatement: protocol.CommandTypes.BreakpointStatement; const CompilerOptionsForInferredProjects: protocol.CommandTypes.CompilerOptionsForInferredProjects; const GetCodeFixes: protocol.CommandTypes.GetCodeFixes; - const GetCodeFixesFull: protocol.CommandTypes.GetCodeFixesFull; const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes; } function formatMessage(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string; class Session implements EventSender { private host; + private readonly cancellationToken; protected readonly typingsInstaller: ITypingsInstaller; private byteLength; private hrtime; @@ -11499,11 +4262,12 @@ declare namespace ts.server { protected readonly canUseEvents: boolean; private readonly gcTimer; protected projectService: ProjectService; - private errorTimer; - private immediateId; private changeSeq; + private currentRequestId; + private errorCheck; private eventHander; - constructor(host: ServerHost, cancellationToken: HostCancellationToken, useSingleInferredProject: boolean, typingsInstaller: ITypingsInstaller, byteLength: (buf: string, encoding?: string) => number, hrtime: (start?: number[]) => number[], logger: Logger, canUseEvents: boolean, eventHandler?: ProjectServiceEventHandler); + constructor(host: ServerHost, cancellationToken: ServerCancellationToken, useSingleInferredProject: boolean, typingsInstaller: ITypingsInstaller, byteLength: (buf: string, encoding?: string) => number, hrtime: (start?: number[]) => number[], logger: Logger, canUseEvents: boolean, eventHandler?: ProjectServiceEventHandler); + private sendRequestCompletedEvent(requestId); private defaultEventHandler(event); logError(err: Error, cmd: string): void; send(msg: protocol.Message): void; @@ -11513,7 +4277,7 @@ declare namespace ts.server { private semanticCheck(file, project); private syntacticCheck(file, project); private updateProjectStructure(seq, matchSeq, ms?); - private updateErrorCheck(checkList, seq, matchSeq, ms?, followMs?, requireOpen?); + private updateErrorCheck(next, checkList, seq, matchSeq, ms?, followMs?, requireOpen?); private cleanProjects(caption, projects); private cleanup(); private getEncodedSemanticClassifications(args); @@ -11558,7 +4322,7 @@ declare namespace ts.server { private getCompileOnSaveAffectedFileList(args); private emitFile(args); private getSignatureHelpItems(args, simplifiedResult); - private getDiagnostics(delay, fileNames); + private getDiagnostics(next, delay, fileNames); private change(args); private reload(args, reqSeq); private saveToTmp(fileName, tempFileName); @@ -11574,7 +4338,7 @@ declare namespace ts.server { private mapCodeAction(codeAction, scriptInfo); private convertTextChangeToCodeEdit(change, scriptInfo); private getBraceMatching(args, simplifiedResult); - getDiagnosticsForProject(delay: number, fileName: string): void; + private getDiagnosticsForProject(next, delay, fileName); getCanonicalFileName(fileName: string): string; exit(): void; private notRequired(); @@ -11584,6 +4348,9 @@ declare namespace ts.server { response?: any; responseRequired: boolean; }): void; + private setCurrentRequest(requestId); + private resetCurrentRequest(requestId); + executeWithRequestId(requestId: number, f: () => T): T; executeCommand(request: protocol.Request): { response?: any; responseRequired?: boolean; @@ -11716,178 +4483,414 @@ declare namespace ts.server { lineCount(): number; } } -declare let debugObjectHost: any; -declare namespace ts { - interface ScriptSnapshotShim { - getText(start: number, end: number): string; - getLength(): number; - getChangeRange(oldSnapshot: ScriptSnapshotShim): string; - dispose?(): void; - } - interface Logger { - log(s: string): void; - trace(s: string): void; - error(s: string): void; - } - interface LanguageServiceShimHost extends Logger { - getCompilationSettings(): string; - getScriptFileNames(): string; - getScriptKind?(fileName: string): ScriptKind; - getScriptVersion(fileName: string): string; - getScriptSnapshot(fileName: string): ScriptSnapshotShim; - getLocalizedDiagnosticMessages(): string; - getCancellationToken(): HostCancellationToken; - getCurrentDirectory(): string; - getDirectories(path: string): string; - getDefaultLibFileName(options: string): string; - getNewLine?(): string; - getProjectVersion?(): string; - useCaseSensitiveFileNames?(): boolean; - getTypeRootsVersion?(): number; - readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; - readFile(path: string, encoding?: string): string; - fileExists(path: string): boolean; - getModuleResolutionsForFile?(fileName: string): string; - getTypeReferenceDirectiveResolutionsForFile?(fileName: string): string; - directoryExists(directoryName: string): boolean; - } - interface CoreServicesShimHost extends Logger { - directoryExists(directoryName: string): boolean; - fileExists(fileName: string): boolean; - getCurrentDirectory(): string; - getDirectories(path: string): string; - readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; - readFile(fileName: string): string; - realpath?(path: string): string; - trace(s: string): void; - useCaseSensitiveFileNames?(): boolean; - } - interface IFileReference { - path: string; - position: number; - length: number; - } - interface ShimFactory { - registerShim(shim: Shim): void; - unregisterShim(shim: Shim): void; - } - interface Shim { - dispose(_dummy: any): void; - } - interface LanguageServiceShim extends Shim { - languageService: LanguageService; - dispose(_dummy: any): void; - refresh(throwOnError: boolean): void; - cleanupSemanticCache(): void; - getSyntacticDiagnostics(fileName: string): string; - getSemanticDiagnostics(fileName: string): string; - getCompilerOptionsDiagnostics(): string; - getSyntacticClassifications(fileName: string, start: number, length: number): string; - getSemanticClassifications(fileName: string, start: number, length: number): string; - getEncodedSyntacticClassifications(fileName: string, start: number, length: number): string; - getEncodedSemanticClassifications(fileName: string, start: number, length: number): string; - getCompletionsAtPosition(fileName: string, position: number): string; - getCompletionEntryDetails(fileName: string, position: number, entryName: string): string; - getQuickInfoAtPosition(fileName: string, position: number): string; - getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): string; - getBreakpointStatementAtPosition(fileName: string, position: number): string; - getSignatureHelpItems(fileName: string, position: number): string; - getRenameInfo(fileName: string, position: number): string; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): string; - getDefinitionAtPosition(fileName: string, position: number): string; - getTypeDefinitionAtPosition(fileName: string, position: number): string; - getImplementationAtPosition(fileName: string, position: number): string; - getReferencesAtPosition(fileName: string, position: number): string; - findReferences(fileName: string, position: number): string; - getOccurrencesAtPosition(fileName: string, position: number): string; - getDocumentHighlights(fileName: string, position: number, filesToSearch: string): string; - getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string): string; - getNavigationBarItems(fileName: string): string; - getNavigationTree(fileName: string): string; - getOutliningSpans(fileName: string): string; - getTodoComments(fileName: string, todoCommentDescriptors: string): string; - getBraceMatchingAtPosition(fileName: string, position: number): string; - getIndentationAtPosition(fileName: string, position: number, options: string): string; - getFormattingEditsForRange(fileName: string, start: number, end: number, options: string): string; - getFormattingEditsForDocument(fileName: string, options: string): string; - getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: string): string; - getDocCommentTemplateAtPosition(fileName: string, position: number): string; - isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string; - getEmitOutput(fileName: string): string; - getEmitOutputObject(fileName: string): EmitOutput; - } - interface ClassifierShim extends Shim { - getEncodedLexicalClassifications(text: string, lexState: EndOfLineState, syntacticClassifierAbsent?: boolean): string; - getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent?: boolean): string; - } - interface CoreServicesShim extends Shim { - getAutomaticTypeDirectiveNames(compilerOptionsJson: string): string; - getPreProcessedFileInfo(fileName: string, sourceText: IScriptSnapshot): string; - getTSConfigFileInfo(fileName: string, sourceText: IScriptSnapshot): string; - getDefaultCompilationSettings(): string; - discoverTypings(discoverTypingsJson: string): string; - } - class LanguageServiceShimHostAdapter implements LanguageServiceHost { - private shimHost; - private files; - private loggingEnabled; - private tracingEnabled; - resolveModuleNames: (moduleName: string[], containingFile: string) => ResolvedModuleFull[]; - resolveTypeReferenceDirectives: (typeDirectiveNames: string[], containingFile: string) => ResolvedTypeReferenceDirective[]; - directoryExists: (directoryName: string) => boolean; - constructor(shimHost: LanguageServiceShimHost); - log(s: string): void; - trace(s: string): void; - error(s: string): void; - getProjectVersion(): string; - getTypeRootsVersion(): number; - useCaseSensitiveFileNames(): boolean; - getCompilationSettings(): CompilerOptions; - getScriptFileNames(): string[]; - getScriptSnapshot(fileName: string): IScriptSnapshot; - getScriptKind(fileName: string): ScriptKind; - getScriptVersion(fileName: string): string; - getLocalizedDiagnosticMessages(): any; - getCancellationToken(): HostCancellationToken; - getCurrentDirectory(): string; - getDirectories(path: string): string[]; - getDefaultLibFileName(options: CompilerOptions): string; - readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[], depth?: number): string[]; - readFile(path: string, encoding?: string): string; - fileExists(path: string): boolean; - } - class CoreServicesShimHostAdapter implements ParseConfigHost, ModuleResolutionHost { - private shimHost; - directoryExists: (directoryName: string) => boolean; - realpath: (path: string) => string; - useCaseSensitiveFileNames: boolean; - constructor(shimHost: CoreServicesShimHost); - readDirectory(rootDir: string, extensions: string[], exclude: string[], include: string[], depth?: number): string[]; - fileExists(fileName: string): boolean; - readFile(fileName: string): string; - private readDirectoryFallback(rootDir, extension, exclude); - getDirectories(path: string): string[]; - } - function realizeDiagnostics(diagnostics: Diagnostic[], newLine: string): { - message: string; - start: number; - length: number; - category: string; - code: number; - }[]; - class TypeScriptServicesFactory implements ShimFactory { - private _shims; - private documentRegistry; - getServicesVersion(): string; - createLanguageServiceShim(host: LanguageServiceShimHost): LanguageServiceShim; - createClassifierShim(logger: Logger): ClassifierShim; - createCoreServicesShim(host: CoreServicesShimHost): CoreServicesShim; +declare namespace ts.server { + class ScriptInfo { + private readonly host; + readonly fileName: NormalizedPath; + readonly scriptKind: ScriptKind; + hasMixedContent: boolean; + readonly containingProjects: Project[]; + private formatCodeSettings; + readonly path: Path; + private fileWatcher; + private textStorage; + private isOpen; + constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent?: boolean); + isScriptOpen(): boolean; + open(newText: string): void; close(): void; - registerShim(shim: Shim): void; - unregisterShim(shim: Shim): void; + getSnapshot(): IScriptSnapshot; + getFormatCodeSettings(): FormatCodeSettings; + attachToProject(project: Project): boolean; + isAttached(project: Project): boolean; + detachFromProject(project: Project): void; + detachAllProjects(): void; + getDefaultProject(): Project; + registerFileUpdate(): void; + setFormatOptions(formatSettings: FormatCodeSettings): void; + setWatcher(watcher: FileWatcher): void; + stopWatcher(): void; + getLatestVersion(): string; + reload(script: string): void; + saveTo(fileName: string): void; + reloadFromFile(tempFileName?: NormalizedPath): void; + getLineInfo(line: number): ILineInfo; + editContent(start: number, end: number, newText: string): void; + markContainingProjectsAsDirty(): void; + lineToTextSpan(line: number): TextSpan; + lineOffsetToPosition(line: number, offset: number): number; + positionToLineOffset(position: number): ILineInfo; + isJavaScript(): boolean; } } -declare namespace TypeScript.Services { - const TypeScriptServicesFactory: typeof ts.TypeScriptServicesFactory; +declare namespace ts.server { + class LSHost implements ts.LanguageServiceHost, ModuleResolutionHost { + private readonly host; + private readonly project; + private readonly cancellationToken; + private compilationSettings; + private readonly resolvedModuleNames; + private readonly resolvedTypeReferenceDirectives; + private readonly getCanonicalFileName; + private filesWithChangedSetOfUnresolvedImports; + private readonly resolveModuleName; + readonly trace: (s: string) => void; + readonly realpath?: (path: string) => string; + constructor(host: ServerHost, project: Project, cancellationToken: HostCancellationToken); + startRecordingFilesWithChangedResolutions(): void; + finishRecordingFilesWithChangedResolutions(): Path[]; + private resolveNamesWithLocalCache(names, containingFile, cache, loader, getResult, getResultFileName, logChanges); + getNewLine(): string; + getProjectVersion(): string; + getCompilationSettings(): CompilerOptions; + useCaseSensitiveFileNames(): boolean; + getCancellationToken(): HostCancellationToken; + resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModuleFull[]; + getDefaultLibFileName(): string; + getScriptSnapshot(filename: string): ts.IScriptSnapshot; + getScriptFileNames(): string[]; + getTypeRootsVersion(): number; + getScriptKind(fileName: string): ScriptKind; + getScriptVersion(filename: string): string; + getCurrentDirectory(): string; + resolvePath(path: string): string; + fileExists(path: string): boolean; + readFile(fileName: string): string; + directoryExists(path: string): boolean; + readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; + getDirectories(path: string): string[]; + notifyFileRemoved(info: ScriptInfo): void; + setCompilationSettings(opt: ts.CompilerOptions): void; + } } -declare const toolsVersion = "2.2"; +declare namespace ts.server { + interface ITypingsInstaller { + enqueueInstallTypingsRequest(p: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray): void; + attach(projectService: ProjectService): void; + onProjectClosed(p: Project): void; + readonly globalTypingsCacheLocation: string; + } + const nullTypingsInstaller: ITypingsInstaller; + class TypingsCache { + private readonly installer; + private readonly perProjectCache; + constructor(installer: ITypingsInstaller); + getTypingsForProject(project: Project, unresolvedImports: SortedReadonlyArray, forceRefresh: boolean): SortedReadonlyArray; + updateTypingsForProject(projectName: string, compilerOptions: CompilerOptions, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, newTypings: string[]): void; + deleteTypingsForProject(projectName: string): void; + onProjectClosed(project: Project): void; + } +} +declare namespace ts.server { + function shouldEmitFile(scriptInfo: ScriptInfo): boolean; + class BuilderFileInfo { + readonly scriptInfo: ScriptInfo; + readonly project: Project; + private lastCheckedShapeSignature; + constructor(scriptInfo: ScriptInfo, project: Project); + isExternalModuleOrHasOnlyAmbientExternalModules(): boolean; + private containsOnlyAmbientModules(sourceFile); + private computeHash(text); + private getSourceFile(); + updateShapeSignature(): boolean; + } + interface Builder { + readonly project: Project; + getFilesAffectedBy(scriptInfo: ScriptInfo): string[]; + onProjectUpdateGraph(): void; + emitFile(scriptInfo: ScriptInfo, writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => void): boolean; + clear(): void; + } + function createBuilder(project: Project): Builder; +} +declare namespace ts.server { + enum ProjectKind { + Inferred = 0, + Configured = 1, + External = 2, + } + function allRootFilesAreJsOrDts(project: Project): boolean; + function allFilesAreJsOrDts(project: Project): boolean; + class UnresolvedImportsMap { + readonly perFileMap: FileMap>; + private version; + clear(): void; + getVersion(): number; + remove(path: Path): void; + get(path: Path): ReadonlyArray; + set(path: Path, value: ReadonlyArray): void; + } + interface PluginCreateInfo { + project: Project; + languageService: LanguageService; + languageServiceHost: LanguageServiceHost; + serverHost: ServerHost; + config: any; + } + interface PluginModule { + create(createInfo: PluginCreateInfo): LanguageService; + getExternalFiles?(proj: Project): string[]; + } + interface PluginModuleFactory { + (mod: { + typescript: typeof ts; + }): PluginModule; + } + abstract class Project { + private readonly projectName; + readonly projectKind: ProjectKind; + readonly projectService: ProjectService; + private documentRegistry; + private compilerOptions; + compileOnSaveEnabled: boolean; + private rootFiles; + private rootFilesMap; + private program; + private cachedUnresolvedImportsPerFile; + private lastCachedUnresolvedImportsList; + protected languageService: LanguageService; + languageServiceEnabled: boolean; + protected readonly lsHost: LSHost; + builder: Builder; + private updatedFileNames; + private lastReportedFileNames; + private lastReportedVersion; + private projectStructureVersion; + private projectStateVersion; + private typingFiles; + protected projectErrors: Diagnostic[]; + typesVersion: number; + isNonTsProject(): boolean; + isJsOnlyProject(): boolean; + getCachedUnresolvedImportsPerFile_TestOnly(): UnresolvedImportsMap; + static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void): {}; + constructor(projectName: string, projectKind: ProjectKind, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, languageServiceEnabled: boolean, compilerOptions: CompilerOptions, compileOnSaveEnabled: boolean); + private setInternalCompilerOptionsForEmittingJsFiles(); + getProjectErrors(): Diagnostic[]; + getLanguageService(ensureSynchronized?: boolean): LanguageService; + getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[]; + getProjectVersion(): string; + enableLanguageService(): void; + disableLanguageService(): void; + getProjectName(): string; + abstract getProjectRootPath(): string | undefined; + abstract getTypeAcquisition(): TypeAcquisition; + getExternalFiles(): string[]; + getSourceFile(path: Path): SourceFile; + updateTypes(): void; + close(): void; + getCompilerOptions(): CompilerOptions; + hasRoots(): boolean; + getRootFiles(): NormalizedPath[]; + getRootFilesLSHost(): string[]; + getRootScriptInfos(): ScriptInfo[]; + getScriptInfos(): ScriptInfo[]; + getFileEmitOutput(info: ScriptInfo, emitOnlyDtsFiles: boolean): EmitOutput; + getFileNames(excludeFilesFromExternalLibraries?: boolean): NormalizedPath[]; + getAllEmittableFiles(): string[]; + containsScriptInfo(info: ScriptInfo): boolean; + containsFile(filename: NormalizedPath, requireOpen?: boolean): boolean; + isRoot(info: ScriptInfo): boolean; + addRoot(info: ScriptInfo): void; + removeFile(info: ScriptInfo, detachFromProject?: boolean): void; + registerFileUpdate(fileName: string): void; + markAsDirty(): void; + private extractUnresolvedImportsFromSourceFile(file, result); + updateGraph(): boolean; + private setTypings(typings); + private updateGraphWorker(); + getScriptInfoLSHost(fileName: string): ScriptInfo; + getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo; + getScriptInfo(uncheckedFileName: string): ScriptInfo; + filesToString(): string; + setCompilerOptions(compilerOptions: CompilerOptions): void; + reloadScript(filename: NormalizedPath, tempFileName?: NormalizedPath): boolean; + getReferencedFiles(path: Path): Path[]; + protected removeRoot(info: ScriptInfo): void; + } + class InferredProject extends Project { + private static newName; + private _isJsInferredProject; + toggleJsInferredProject(isJsInferredProject: boolean): void; + setCompilerOptions(options?: CompilerOptions): void; + directoriesWatchedForTsconfig: string[]; + constructor(projectService: ProjectService, documentRegistry: ts.DocumentRegistry, compilerOptions: CompilerOptions); + addRoot(info: ScriptInfo): void; + removeRoot(info: ScriptInfo): void; + getProjectRootPath(): string; + close(): void; + getTypeAcquisition(): TypeAcquisition; + } + class ConfiguredProject extends Project { + private configFileName; + private wildcardDirectories; + compileOnSaveEnabled: boolean; + private typeAcquisition; + private projectFileWatcher; + private directoryWatcher; + private directoriesWatchedForWildcards; + private typeRootsWatchers; + readonly canonicalConfigFilePath: NormalizedPath; + private plugins; + openRefCount: number; + constructor(configFileName: NormalizedPath, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, compilerOptions: CompilerOptions, wildcardDirectories: Map, languageServiceEnabled: boolean, compileOnSaveEnabled: boolean); + getConfigFilePath(): string; + enablePlugins(): void; + private enableProxy(pluginModuleFactory, configEntry); + getProjectRootPath(): string; + setProjectErrors(projectErrors: Diagnostic[]): void; + setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; + getTypeAcquisition(): TypeAcquisition; + getExternalFiles(): string[]; + watchConfigFile(callback: (project: ConfiguredProject) => void): void; + watchTypeRoots(callback: (project: ConfiguredProject, path: string) => void): void; + watchConfigDirectory(callback: (project: ConfiguredProject, path: string) => void): void; + watchWildcards(callback: (project: ConfiguredProject, path: string) => void): void; + stopWatchingDirectory(): void; + close(): void; + addOpenRef(): void; + deleteOpenRef(): number; + getEffectiveTypeRoots(): string[]; + } + class ExternalProject extends Project { + compileOnSaveEnabled: boolean; + private readonly projectFilePath; + private typeAcquisition; + constructor(externalProjectName: string, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, compilerOptions: CompilerOptions, languageServiceEnabled: boolean, compileOnSaveEnabled: boolean, projectFilePath?: string); + getProjectRootPath(): string; + getTypeAcquisition(): TypeAcquisition; + setProjectErrors(projectErrors: Diagnostic[]): void; + setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; + } +} +declare namespace ts.server { + const maxProgramSizeForNonTsFiles: number; + const ContextEvent = "context"; + const ConfigFileDiagEvent = "configFileDiag"; + const ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; + interface ContextEvent { + eventName: typeof ContextEvent; + data: { + project: Project; + fileName: NormalizedPath; + }; + } + interface ConfigFileDiagEvent { + eventName: typeof ConfigFileDiagEvent; + data: { + triggerFile: string; + configFileName: string; + diagnostics: Diagnostic[]; + }; + } + interface ProjectLanguageServiceStateEvent { + eventName: typeof ProjectLanguageServiceStateEvent; + data: { + project: Project; + languageServiceEnabled: boolean; + }; + } + type ProjectServiceEvent = ContextEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent; + interface ProjectServiceEventHandler { + (event: ProjectServiceEvent): void; + } + function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings; + function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin; + function tryConvertScriptKindName(scriptKindName: protocol.ScriptKindName | ScriptKind): ScriptKind; + function convertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind.Unknown | ScriptKind.JS | ScriptKind.JSX | ScriptKind.TS | ScriptKind.TSX; + function combineProjectOutput(projects: Project[], action: (project: Project) => T[], comparer?: (a: T, b: T) => number, areEqual?: (a: T, b: T) => boolean): T[]; + interface HostConfiguration { + formatCodeOptions: FormatCodeSettings; + hostInfo: string; + extraFileExtensions?: JsFileExtensionInfo[]; + } + interface OpenConfiguredProjectResult { + configFileName?: NormalizedPath; + configFileErrors?: Diagnostic[]; + } + class ProjectService { + readonly host: ServerHost; + readonly logger: Logger; + readonly cancellationToken: HostCancellationToken; + readonly useSingleInferredProject: boolean; + readonly typingsInstaller: ITypingsInstaller; + private readonly eventHandler; + readonly typingsCache: TypingsCache; + private readonly documentRegistry; + private readonly filenameToScriptInfo; + private readonly externalProjectToConfiguredProjectMap; + readonly externalProjects: ExternalProject[]; + readonly inferredProjects: InferredProject[]; + readonly configuredProjects: ConfiguredProject[]; + readonly openFiles: ScriptInfo[]; + private compilerOptionsForInferredProjects; + private compileOnSaveForInferredProjects; + private readonly directoryWatchers; + private readonly throttledOperations; + private readonly hostConfiguration; + private changedFiles; + readonly toCanonicalFileName: (f: string) => string; + lastDeletedFile: ScriptInfo; + constructor(host: ServerHost, logger: Logger, cancellationToken: HostCancellationToken, useSingleInferredProject: boolean, typingsInstaller?: ITypingsInstaller, eventHandler?: ProjectServiceEventHandler); + ensureInferredProjectsUpToDate_TestOnly(): void; + getCompilerOptionsForInferredProjects(): CompilerOptions; + onUpdateLanguageServiceStateForProject(project: Project, languageServiceEnabled: boolean): void; + updateTypingsForProject(response: SetTypings | InvalidateCachedTypings): void; + setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions): void; + stopWatchingDirectory(directory: string): void; + findProject(projectName: string): Project; + getDefaultProjectForFile(fileName: NormalizedPath, refreshInferredProjects: boolean): Project; + private ensureInferredProjectsUpToDate(); + private findContainingExternalProject(fileName); + getFormatCodeOptions(file?: NormalizedPath): FormatCodeSettings; + private updateProjectGraphs(projects); + private onSourceFileChanged(fileName); + private handleDeletedFile(info); + private onTypeRootFileChanged(project, fileName); + private onSourceFileInDirectoryChangedForConfiguredProject(project, fileName); + private handleChangeInSourceFileForConfiguredProject(project, triggerFile); + private onConfigChangedForConfiguredProject(project); + private onConfigFileAddedForInferredProject(fileName); + private getCanonicalFileName(fileName); + private removeProject(project); + private assignScriptInfoToInferredProjectIfNecessary(info, addToListOfOpenFiles); + private closeOpenFile(info); + private openOrUpdateConfiguredProjectForFile(fileName); + private findConfigFile(searchPath); + private printProjects(); + private findConfiguredProjectByProjectName(configFileName); + private findExternalProjectByProjectName(projectFileName); + private convertConfigFileContentToProjectOptions(configFilename); + private exceededTotalSizeLimitForNonTsFiles(options, fileNames, propertyReader); + private createAndAddExternalProject(projectFileName, files, options, typeAcquisition); + private reportConfigFileDiagnostics(configFileName, diagnostics, triggerFile); + private createAndAddConfiguredProject(configFileName, projectOptions, configFileErrors, clientFileName?); + private watchConfigDirectoryForProject(project, options); + private addFilesToProjectAndUpdateGraph(project, files, propertyReader, clientFileName, typeAcquisition, configFileErrors); + private openConfigFile(configFileName, clientFileName?); + private updateNonInferredProject(project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave, configFileErrors); + private updateConfiguredProject(project); + createInferredProjectWithRootFileIfNecessary(root: ScriptInfo): InferredProject; + getOrCreateScriptInfo(uncheckedFileName: string, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind): ScriptInfo; + getScriptInfo(uncheckedFileName: string): ScriptInfo; + getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): ScriptInfo; + getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo; + getScriptInfoForPath(fileName: Path): ScriptInfo; + setHostConfiguration(args: protocol.ConfigureRequestArguments): void; + closeLog(): void; + reloadProjects(): void; + refreshInferredProjects(): void; + openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind): OpenConfiguredProjectResult; + openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): OpenConfiguredProjectResult; + closeClientFile(uncheckedFileName: string): void; + private collectChanges(lastKnownProjectVersions, currentProjects, result); + private closeConfiguredProject(configFile); + closeExternalProject(uncheckedFileName: string, suppressRefresh?: boolean): void; + openExternalProjects(projects: protocol.ExternalProject[]): void; + openExternalProject(proj: protocol.ExternalProject, suppressRefreshOfInferredProjects?: boolean): void; + } +} + +export = ts; +export as namespace ts; \ No newline at end of file diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 842c5458a89..38fcfa5c6b5 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -13,13 +13,440 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ts; (function (ts) { + var SyntaxKind; + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 126] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 127] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 128] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 129] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 130] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 131] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 132] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 133] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 134] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 135] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 136] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 137] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 138] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 139] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 140] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 141] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 142] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 143] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 144] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 145] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 146] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 147] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 148] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 149] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 150] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 151] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 152] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 153] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 154] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 155] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 156] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypePredicate"] = 157] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 158] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 159] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 160] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 161] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 162] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 163] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 164] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 165] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 166] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 167] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 168] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 169] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 170] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 171] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 172] = "LiteralType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 173] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 174] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 175] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 176] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 177] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 178] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 179] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 180] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 181] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 182] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 183] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 184] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 185] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 186] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 187] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 188] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 189] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 190] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 191] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 192] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 193] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 194] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 195] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 196] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 197] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 198] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 199] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 200] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 201] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 202] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 203] = "MetaProperty"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 204] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 205] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["Block"] = 206] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 207] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 208] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 209] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 210] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 211] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 212] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 213] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 214] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 215] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 216] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 217] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 218] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 219] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 220] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 221] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 222] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 223] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 224] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 225] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 226] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 227] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 228] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 229] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 230] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 231] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 232] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 233] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 234] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 235] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 236] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 237] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 238] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 239] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 240] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 241] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 242] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 243] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 244] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 245] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 246] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 247] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["JsxElement"] = 248] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 249] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 250] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 251] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 252] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 253] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 254] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 255] = "JsxExpression"; + SyntaxKind[SyntaxKind["CaseClause"] = 256] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 257] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 258] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 259] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 260] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 261] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 262] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 263] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 264] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 265] = "Bundle"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 266] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 267] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 268] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 269] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 270] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 271] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 272] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 273] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 274] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 275] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 276] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 277] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 278] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 279] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 280] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 281] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 282] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 283] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 284] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 285] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 286] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 287] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 288] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 289] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 290] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 291] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 292] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 293] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 294] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 295] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["SyntaxList"] = 296] = "SyntaxList"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 297] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 298] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 299] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 300] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["Count"] = 301] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 141] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 157] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 172] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = 141] = "LastToken"; + SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 142] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 266] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 295] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 282] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 295] = "LastJSDocTagNode"; + })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); + var NodeFlags; + (function (NodeFlags) { + NodeFlags[NodeFlags["None"] = 0] = "None"; + NodeFlags[NodeFlags["Let"] = 1] = "Let"; + NodeFlags[NodeFlags["Const"] = 2] = "Const"; + NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; + NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; + NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 96256] = "ContextFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags"; + })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); + var ModifierFlags; + (function (ModifierFlags) { + ModifierFlags[ModifierFlags["None"] = 0] = "None"; + ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; + ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; + ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; + ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; + ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; + ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; + ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; + ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; + ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; + ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; + ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; + ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + ModifierFlags[ModifierFlags["ExportDefault"] = 513] = "ExportDefault"; + })(ModifierFlags = ts.ModifierFlags || (ts.ModifierFlags = {})); + var JsxFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(JsxFlags = ts.JsxFlags || (ts.JsxFlags = {})); + var RelationComparisonResult; + (function (RelationComparisonResult) { + RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; + RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; + RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); + var GeneratedIdentifierKind; + (function (GeneratedIdentifierKind) { + GeneratedIdentifierKind[GeneratedIdentifierKind["None"] = 0] = "None"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Auto"] = 1] = "Auto"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Loop"] = 2] = "Loop"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; + })(GeneratedIdentifierKind = ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + var FlowFlags; + (function (FlowFlags) { + FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; + FlowFlags[FlowFlags["Start"] = 2] = "Start"; + FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; + FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; + FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; + FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; + FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; + FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; + FlowFlags[FlowFlags["Label"] = 12] = "Label"; + FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; + })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); var OperationCanceledException = (function () { function OperationCanceledException() { } @@ -32,6 +459,45 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + var TypeFormatFlags; + (function (TypeFormatFlags) { + TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; + TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; + TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 2] = "UseTypeOfFunction"; + TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 4] = "NoTruncation"; + TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 8] = "WriteArrowStyleSignature"; + TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 16] = "WriteOwnNameForAnyLike"; + TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; + TypeFormatFlags[TypeFormatFlags["InElementType"] = 64] = "InElementType"; + TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; + TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; + TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; + TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; + TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 2048] = "SuppressAnyReturnType"; + TypeFormatFlags[TypeFormatFlags["AddUndefined"] = 4096] = "AddUndefined"; + })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var SymbolFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; + })(SymbolFormatFlags = ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolAccessibility; + (function (SymbolAccessibility) { + SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; + SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; + SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; + })(SymbolAccessibility = ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); + var SyntheticSymbolKind; + (function (SyntheticSymbolKind) { + SyntheticSymbolKind[SyntheticSymbolKind["UnionOrIntersection"] = 0] = "UnionOrIntersection"; + SyntheticSymbolKind[SyntheticSymbolKind["Spread"] = 1] = "Spread"; + })(SyntheticSymbolKind = ts.SyntheticSymbolKind || (ts.SyntheticSymbolKind = {})); + var TypePredicateKind; + (function (TypePredicateKind) { + TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; + TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; @@ -46,6 +512,189 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 9] = "TypeWithCallSignature"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); + var SymbolFlags; + (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["Prototype"] = 16777216] = "Prototype"; + SymbolFlags[SymbolFlags["ExportStar"] = 33554432] = "ExportStar"; + SymbolFlags[SymbolFlags["Optional"] = 67108864] = "Optional"; + SymbolFlags[SymbolFlags["Transient"] = 134217728] = "Transient"; + SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; + SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; + SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 793064] = "Type"; + SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; + SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; + SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792968] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; + SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530920] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793064] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["AliasExcludes"] = 8388608] = "AliasExcludes"; + SymbolFlags[SymbolFlags["ModuleMember"] = 8914931] = "ModuleMember"; + SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; + SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; + SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; + SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; + SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; + SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; + })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); + var CheckFlags; + (function (CheckFlags) { + CheckFlags[CheckFlags["Instantiated"] = 1] = "Instantiated"; + CheckFlags[CheckFlags["SyntheticProperty"] = 2] = "SyntheticProperty"; + CheckFlags[CheckFlags["Readonly"] = 4] = "Readonly"; + CheckFlags[CheckFlags["Partial"] = 8] = "Partial"; + CheckFlags[CheckFlags["HasNonUniformType"] = 16] = "HasNonUniformType"; + CheckFlags[CheckFlags["ContainsPublic"] = 32] = "ContainsPublic"; + CheckFlags[CheckFlags["ContainsProtected"] = 64] = "ContainsProtected"; + CheckFlags[CheckFlags["ContainsPrivate"] = 128] = "ContainsPrivate"; + CheckFlags[CheckFlags["ContainsStatic"] = 256] = "ContainsStatic"; + })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); + var NodeCheckFlags; + (function (NodeCheckFlags) { + NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; + NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["CaptureNewTarget"] = 8] = "CaptureNewTarget"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; + NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; + NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; + NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; + NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; + NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; + })(NodeCheckFlags = ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); + var TypeFlags; + (function (TypeFlags) { + TypeFlags[TypeFlags["Any"] = 1] = "Any"; + TypeFlags[TypeFlags["String"] = 2] = "String"; + TypeFlags[TypeFlags["Number"] = 4] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; + TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; + TypeFlags[TypeFlags["Void"] = 1024] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 2048] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 4096] = "Null"; + TypeFlags[TypeFlags["Never"] = 8192] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; + TypeFlags[TypeFlags["Object"] = 32768] = "Object"; + TypeFlags[TypeFlags["Union"] = 65536] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 131072] = "Intersection"; + TypeFlags[TypeFlags["Index"] = 262144] = "Index"; + TypeFlags[TypeFlags["IndexedAccess"] = 524288] = "IndexedAccess"; + TypeFlags[TypeFlags["FreshLiteral"] = 1048576] = "FreshLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 2097152] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; + TypeFlags[TypeFlags["JsxAttributes"] = 33554432] = "JsxAttributes"; + TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; + TypeFlags[TypeFlags["Intrinsic"] = 16793231] = "Intrinsic"; + TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 262178] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 340] = "NumberLike"; + TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 196608] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 229376] = "StructuredType"; + TypeFlags[TypeFlags["StructuredOrTypeVariable"] = 1032192] = "StructuredOrTypeVariable"; + TypeFlags[TypeFlags["TypeVariable"] = 540672] = "TypeVariable"; + TypeFlags[TypeFlags["Narrowable"] = 17810431] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 16810497] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; + TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "PropagatingFlags"; + })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); + var ObjectFlags; + (function (ObjectFlags) { + ObjectFlags[ObjectFlags["Class"] = 1] = "Class"; + ObjectFlags[ObjectFlags["Interface"] = 2] = "Interface"; + ObjectFlags[ObjectFlags["Reference"] = 4] = "Reference"; + ObjectFlags[ObjectFlags["Tuple"] = 8] = "Tuple"; + ObjectFlags[ObjectFlags["Anonymous"] = 16] = "Anonymous"; + ObjectFlags[ObjectFlags["Mapped"] = 32] = "Mapped"; + ObjectFlags[ObjectFlags["Instantiated"] = 64] = "Instantiated"; + ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; + ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; + ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; + ObjectFlags[ObjectFlags["NonPrimitive"] = 1024] = "NonPrimitive"; + ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; + })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); + var SignatureKind; + (function (SignatureKind) { + SignatureKind[SignatureKind["Call"] = 0] = "Call"; + SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; + })(SignatureKind = ts.SignatureKind || (ts.SignatureKind = {})); + var IndexKind; + (function (IndexKind) { + IndexKind[IndexKind["String"] = 0] = "String"; + IndexKind[IndexKind["Number"] = 1] = "Number"; + })(IndexKind = ts.IndexKind || (ts.IndexKind = {})); + var SpecialPropertyAssignmentKind; + (function (SpecialPropertyAssignmentKind) { + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; + })(SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); var DiagnosticCategory; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; @@ -66,6 +715,179 @@ var ts; ModuleKind[ModuleKind["System"] = 4] = "System"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); + var JsxEmit; + (function (JsxEmit) { + JsxEmit[JsxEmit["None"] = 0] = "None"; + JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; + JsxEmit[JsxEmit["React"] = 2] = "React"; + JsxEmit[JsxEmit["ReactNative"] = 3] = "ReactNative"; + })(JsxEmit = ts.JsxEmit || (ts.JsxEmit = {})); + var NewLineKind; + (function (NewLineKind) { + NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; + NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; + })(NewLineKind = ts.NewLineKind || (ts.NewLineKind = {})); + var ScriptKind; + (function (ScriptKind) { + ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; + ScriptKind[ScriptKind["JS"] = 1] = "JS"; + ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; + ScriptKind[ScriptKind["TS"] = 3] = "TS"; + ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + ScriptKind[ScriptKind["External"] = 5] = "External"; + })(ScriptKind = ts.ScriptKind || (ts.ScriptKind = {})); + var ScriptTarget; + (function (ScriptTarget) { + ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; + ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; + ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; + ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; + ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; + ScriptTarget[ScriptTarget["ESNext"] = 5] = "ESNext"; + ScriptTarget[ScriptTarget["Latest"] = 5] = "Latest"; + })(ScriptTarget = ts.ScriptTarget || (ts.ScriptTarget = {})); + var LanguageVariant; + (function (LanguageVariant) { + LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; + LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; + })(LanguageVariant = ts.LanguageVariant || (ts.LanguageVariant = {})); + var DiagnosticStyle; + (function (DiagnosticStyle) { + DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; + DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; + })(DiagnosticStyle = ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var WatchDirectoryFlags; + (function (WatchDirectoryFlags) { + WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; + WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; + })(WatchDirectoryFlags = ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); + var CharacterCodes; + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; + CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; + CharacterCodes[CharacterCodes["space"] = 32] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; + CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; + CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; + CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; + CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; + CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; + CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; + CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["j"] = 106] = "j"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["B"] = 66] = "B"; + CharacterCodes[CharacterCodes["C"] = 67] = "C"; + CharacterCodes[CharacterCodes["D"] = 68] = "D"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["G"] = 71] = "G"; + CharacterCodes[CharacterCodes["H"] = 72] = "H"; + CharacterCodes[CharacterCodes["I"] = 73] = "I"; + CharacterCodes[CharacterCodes["J"] = 74] = "J"; + CharacterCodes[CharacterCodes["K"] = 75] = "K"; + CharacterCodes[CharacterCodes["L"] = 76] = "L"; + CharacterCodes[CharacterCodes["M"] = 77] = "M"; + CharacterCodes[CharacterCodes["N"] = 78] = "N"; + CharacterCodes[CharacterCodes["O"] = 79] = "O"; + CharacterCodes[CharacterCodes["P"] = 80] = "P"; + CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; + CharacterCodes[CharacterCodes["R"] = 82] = "R"; + CharacterCodes[CharacterCodes["S"] = 83] = "S"; + CharacterCodes[CharacterCodes["T"] = 84] = "T"; + CharacterCodes[CharacterCodes["U"] = 85] = "U"; + CharacterCodes[CharacterCodes["V"] = 86] = "V"; + CharacterCodes[CharacterCodes["W"] = 87] = "W"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(CharacterCodes = ts.CharacterCodes || (ts.CharacterCodes = {})); var Extension; (function (Extension) { Extension[Extension["Ts"] = 0] = "Ts"; @@ -75,6 +897,111 @@ var ts; Extension[Extension["Jsx"] = 4] = "Jsx"; Extension[Extension["LastTypeScriptExtension"] = 2] = "LastTypeScriptExtension"; })(Extension = ts.Extension || (ts.Extension = {})); + var TransformFlags; + (function (TransformFlags) { + TransformFlags[TransformFlags["None"] = 0] = "None"; + TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript"; + TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; + TransformFlags[TransformFlags["ContainsJsx"] = 4] = "ContainsJsx"; + TransformFlags[TransformFlags["ContainsESNext"] = 8] = "ContainsESNext"; + TransformFlags[TransformFlags["ContainsES2017"] = 16] = "ContainsES2017"; + TransformFlags[TransformFlags["ContainsES2016"] = 32] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 64] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 128] = "ContainsES2015"; + TransformFlags[TransformFlags["Generator"] = 256] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 512] = "ContainsGenerator"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; + TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 2048] = "ContainsDestructuringAssignment"; + TransformFlags[TransformFlags["ContainsDecorators"] = 4096] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 8192] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 16384] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 32768] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 65536] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 131072] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 262144] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpread"] = 524288] = "ContainsSpread"; + TransformFlags[TransformFlags["ContainsObjectSpread"] = 1048576] = "ContainsObjectSpread"; + TransformFlags[TransformFlags["ContainsRest"] = 524288] = "ContainsRest"; + TransformFlags[TransformFlags["ContainsObjectRest"] = 1048576] = "ContainsObjectRest"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; + TransformFlags[TransformFlags["AssertJsx"] = 4] = "AssertJsx"; + TransformFlags[TransformFlags["AssertESNext"] = 8] = "AssertESNext"; + TransformFlags[TransformFlags["AssertES2017"] = 16] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 32] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 192] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 768] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 3072] = "AssertDestructuringAssignment"; + TransformFlags[TransformFlags["NodeExcludes"] = 536872257] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 601249089] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 601281857] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 601015617] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 601015617] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 539358529] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 574674241] = "ModuleExcludes"; + TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 540087617] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537396545] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 546309441] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 536872257] = "ParameterExcludes"; + TransformFlags[TransformFlags["CatchClauseExcludes"] = 537920833] = "CatchClauseExcludes"; + TransformFlags[TransformFlags["BindingPatternExcludes"] = 537396545] = "BindingPatternExcludes"; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 274432] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 163840] = "ES2015FunctionSyntaxMask"; + })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); + var EmitFlags; + (function (EmitFlags) { + EmitFlags[EmitFlags["SingleLine"] = 1] = "SingleLine"; + EmitFlags[EmitFlags["AdviseOnEmitNode"] = 2] = "AdviseOnEmitNode"; + EmitFlags[EmitFlags["NoSubstitution"] = 4] = "NoSubstitution"; + EmitFlags[EmitFlags["CapturesThis"] = 8] = "CapturesThis"; + EmitFlags[EmitFlags["NoLeadingSourceMap"] = 16] = "NoLeadingSourceMap"; + EmitFlags[EmitFlags["NoTrailingSourceMap"] = 32] = "NoTrailingSourceMap"; + EmitFlags[EmitFlags["NoSourceMap"] = 48] = "NoSourceMap"; + EmitFlags[EmitFlags["NoNestedSourceMaps"] = 64] = "NoNestedSourceMaps"; + EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 128] = "NoTokenLeadingSourceMaps"; + EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 256] = "NoTokenTrailingSourceMaps"; + EmitFlags[EmitFlags["NoTokenSourceMaps"] = 384] = "NoTokenSourceMaps"; + EmitFlags[EmitFlags["NoLeadingComments"] = 512] = "NoLeadingComments"; + EmitFlags[EmitFlags["NoTrailingComments"] = 1024] = "NoTrailingComments"; + EmitFlags[EmitFlags["NoComments"] = 1536] = "NoComments"; + EmitFlags[EmitFlags["NoNestedComments"] = 2048] = "NoNestedComments"; + EmitFlags[EmitFlags["HelperName"] = 4096] = "HelperName"; + EmitFlags[EmitFlags["ExportName"] = 8192] = "ExportName"; + EmitFlags[EmitFlags["LocalName"] = 16384] = "LocalName"; + EmitFlags[EmitFlags["Indented"] = 32768] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 65536] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 131072] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 262144] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 524288] = "CustomPrologue"; + EmitFlags[EmitFlags["NoHoisting"] = 1048576] = "NoHoisting"; + EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 2097152] = "HasEndOfDeclarationMarker"; + })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); + var ExternalEmitHelpers; + (function (ExternalEmitHelpers) { + ExternalEmitHelpers[ExternalEmitHelpers["Extends"] = 1] = "Extends"; + ExternalEmitHelpers[ExternalEmitHelpers["Assign"] = 2] = "Assign"; + ExternalEmitHelpers[ExternalEmitHelpers["Rest"] = 4] = "Rest"; + ExternalEmitHelpers[ExternalEmitHelpers["Decorate"] = 8] = "Decorate"; + ExternalEmitHelpers[ExternalEmitHelpers["Metadata"] = 16] = "Metadata"; + ExternalEmitHelpers[ExternalEmitHelpers["Param"] = 32] = "Param"; + ExternalEmitHelpers[ExternalEmitHelpers["Awaiter"] = 64] = "Awaiter"; + ExternalEmitHelpers[ExternalEmitHelpers["Generator"] = 128] = "Generator"; + ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper"; + ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 128] = "LastEmitHelper"; + })(ExternalEmitHelpers = ts.ExternalEmitHelpers || (ts.ExternalEmitHelpers = {})); + var EmitHint; + (function (EmitHint) { + EmitHint[EmitHint["SourceFile"] = 0] = "SourceFile"; + EmitHint[EmitHint["Expression"] = 1] = "Expression"; + EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; + EmitHint[EmitHint["Unspecified"] = 3] = "Unspecified"; + })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -93,32 +1020,32 @@ var ts; var measures; function mark(markName) { if (enabled) { - marks[markName] = ts.timestamp(); - counts[markName] = (counts[markName] || 0) + 1; + marks.set(markName, ts.timestamp()); + counts.set(markName, (counts.get(markName) || 0) + 1); profilerEvent(markName); } } performance.mark = mark; function measure(measureName, startMarkName, endMarkName) { if (enabled) { - var end = endMarkName && marks[endMarkName] || ts.timestamp(); - var start = startMarkName && marks[startMarkName] || profilerStart; - measures[measureName] = (measures[measureName] || 0) + (end - start); + var end = endMarkName && marks.get(endMarkName) || ts.timestamp(); + var start = startMarkName && marks.get(startMarkName) || profilerStart; + measures.set(measureName, (measures.get(measureName) || 0) + (end - start)); } } performance.measure = measure; function getCount(markName) { - return counts && counts[markName] || 0; + return counts && counts.get(markName) || 0; } performance.getCount = getCount; function getDuration(measureName) { - return measures && measures[measureName] || 0; + return measures && measures.get(measureName) || 0; } performance.getDuration = getDuration; function forEachMeasure(cb) { - for (var key in measures) { - cb(key, measures[key]); - } + measures.forEach(function (measure, key) { + cb(key, measure); + }); } performance.forEachMeasure = forEachMeasure; function enable() { @@ -137,22 +1064,102 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.2.0"; + ts.version = "2.3.0"; })(ts || (ts = {})); (function (ts) { - var createObject = Object.create; - ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - function createMap(template) { - var map = createObject(null); + var Ternary; + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(Ternary = ts.Ternary || (ts.Ternary = {})); + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(undefined, { usage: "sort", sensitivity: "accent" }) : undefined; + ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + function createDictionaryObject() { + var map = Object.create(null); map["__"] = undefined; delete map["__"]; + return map; + } + function createMap() { + return new MapCtr(); + } + ts.createMap = createMap; + function createMapFromTemplate(template) { + var map = new MapCtr(); for (var key in template) if (hasOwnProperty.call(template, key)) { - map[key] = template[key]; + map.set(key, template[key]); } return map; } - ts.createMap = createMap; + ts.createMapFromTemplate = createMapFromTemplate; + var MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); + function shimMap() { + var MapIterator = (function () { + function MapIterator(data, selector) { + this.index = 0; + this.data = data; + this.selector = selector; + this.keys = Object.keys(data); + } + MapIterator.prototype.next = function () { + var index = this.index; + if (index < this.keys.length) { + this.index++; + return { value: this.selector(this.data, this.keys[index]), done: false }; + } + return { value: undefined, done: true }; + }; + return MapIterator; + }()); + return (function () { + function class_1() { + this.data = createDictionaryObject(); + this.size = 0; + } + class_1.prototype.get = function (key) { + return this.data[key]; + }; + class_1.prototype.set = function (key, value) { + if (!this.has(key)) { + this.size++; + } + this.data[key] = value; + return this; + }; + class_1.prototype.has = function (key) { + return key in this.data; + }; + class_1.prototype.delete = function (key) { + if (this.has(key)) { + this.size--; + delete this.data[key]; + return true; + } + return false; + }; + class_1.prototype.clear = function () { + this.data = createDictionaryObject(); + this.size = 0; + }; + class_1.prototype.keys = function () { + return new MapIterator(this.data, function (_data, key) { return key; }); + }; + class_1.prototype.values = function () { + return new MapIterator(this.data, function (data, key) { return data[key]; }); + }; + class_1.prototype.entries = function () { + return new MapIterator(this.data, function (data, key) { return [key, data[key]]; }); + }; + class_1.prototype.forEach = function (action) { + for (var key in this.data) { + action(this.data[key], key); + } + }; + return class_1; + }()); + } function createFileMap(keyMapper) { var files = createMap(); return { @@ -165,32 +1172,27 @@ var ts; clear: clear, }; function forEachValueInMap(f) { - for (var key in files) { - f(key, files[key]); - } + files.forEach(function (file, key) { + f(key, file); + }); } function getKeys() { - var keys = []; - for (var key in files) { - keys.push(key); - } - return keys; + return arrayFrom(files.keys()); } function get(path) { - return files[toKey(path)]; + return files.get(toKey(path)); } function set(path, value) { - files[toKey(path)] = value; + files.set(toKey(path), value); } function contains(path) { - return toKey(path) in files; + return files.has(toKey(path)); } function remove(path) { - var key = toKey(path); - delete files[key]; + files.delete(toKey(path)); } function clear() { - files = createMap(); + files.clear(); } function toKey(path) { return keyMapper ? keyMapper(path) : path; @@ -204,9 +1206,19 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + var Comparison; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(Comparison = ts.Comparison || (ts.Comparison = {})); + function length(array) { + return array ? array.length : 0; + } + ts.length = length; function forEach(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -225,7 +1237,7 @@ var ts; ts.zipWith = zipWith; function every(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -235,7 +1247,7 @@ var ts; } ts.every = every; function find(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -244,8 +1256,17 @@ var ts; return undefined; } ts.find = find; + function findIndex(array, predicate) { + for (var i = 0; i < array.length; i++) { + if (predicate(array[i], i)) { + return i; + } + } + return -1; + } + ts.findIndex = findIndex; function findMap(array, callback) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -268,7 +1289,7 @@ var ts; ts.contains = contains; function indexOf(array, value) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -278,7 +1299,7 @@ var ts; } ts.indexOf = indexOf; function indexOfAnyCharCode(text, charCodes, start) { - for (var i = start || 0, len = text.length; i < len; i++) { + for (var i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -465,21 +1486,18 @@ var ts; return result; } ts.spanMap = spanMap; - function mapObject(object, f) { - var result; - if (object) { - result = {}; - for (var _i = 0, _a = getOwnKeys(object); _i < _a.length; _i++) { - var v = _a[_i]; - var _b = f(v, object[v]) || [undefined, undefined], key = _b[0], value = _b[1]; - if (key !== undefined) { - result[key] = value; - } - } + function mapEntries(map, f) { + if (!map) { + return undefined; } + var result = createMap(); + map.forEach(function (value, key) { + var _a = f(key, value), newKey = _a[0], newValue = _a[1]; + result.set(newKey, newValue); + }); return result; } - ts.mapObject = mapObject; + ts.mapEntries = mapEntries; function some(array, predicate) { if (array) { if (predicate) { @@ -763,38 +1781,55 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; - function forEachProperty(map, callback) { - var result; - for (var key in map) { - if (result = callback(map[key], key)) - break; + function arrayFrom(iterator) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(value); } return result; + var _b; } - ts.forEachProperty = forEachProperty; - function someProperties(map, predicate) { - for (var key in map) { - if (!predicate || predicate(map[key], key)) - return true; + ts.arrayFrom = arrayFrom; + function convertToArray(iterator, f) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(f(value)); } - return false; + return result; + var _b; } - ts.someProperties = someProperties; - function copyProperties(source, target) { - for (var key in source) { - target[key] = source[key]; + ts.convertToArray = convertToArray; + function forEachEntry(map, callback) { + var iterator = map.entries(); + for (var _a = iterator.next(), pair = _a.value, done = _a.done; !done; _b = iterator.next(), pair = _b.value, done = _b.done, _b) { + var key = pair[0], value = pair[1]; + var result = callback(value, key); + if (result) { + return result; + } } + return undefined; + var _b; } - ts.copyProperties = copyProperties; - function appendProperty(map, key, value) { - if (key === undefined || value === undefined) - return map; - if (map === undefined) - map = createMap(); - map[key] = value; - return map; + ts.forEachEntry = forEachEntry; + function forEachKey(map, callback) { + var iterator = map.keys(); + for (var _a = iterator.next(), key = _a.value, done = _a.done; !done; _b = iterator.next(), key = _b.value, done = _b.done, _b) { + var result = callback(key); + if (result) { + return result; + } + } + return undefined; + var _b; } - ts.appendProperty = appendProperty; + ts.forEachKey = forEachKey; + function copyEntries(source, target) { + source.forEach(function (value, key) { + target.set(key, value); + }); + } + ts.copyEntries = copyEntries; function assign(t) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -810,14 +1845,6 @@ var ts; return t; } ts.assign = assign; - function reduceProperties(map, callback, initial) { - var result = initial; - for (var key in map) { - result = callback(result, map[key], String(key)); - } - return result; - } - ts.reduceProperties = reduceProperties; function equalOwnProperties(left, right, equalityComparer) { if (left === right) return true; @@ -842,23 +1869,14 @@ var ts; var result = createMap(); for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { var value = array_8[_i]; - result[makeKey(value)] = makeValue ? makeValue(value) : value; + result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; } ts.arrayToMap = arrayToMap; - function isEmpty(map) { - for (var id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - ts.isEmpty = isEmpty; function cloneMap(map) { var clone = createMap(); - copyProperties(map, clone); + copyEntries(map, clone); return clone; } ts.cloneMap = cloneMap; @@ -885,27 +1903,32 @@ var ts; return result; } ts.extend = extend; - function multiMapAdd(map, key, value) { - var values = map[key]; + function createMultiMap() { + var map = createMap(); + map.add = multiMapAdd; + map.remove = multiMapRemove; + return map; + } + ts.createMultiMap = createMultiMap; + function multiMapAdd(key, value) { + var values = this.get(key); if (values) { values.push(value); - return values; } else { - return map[key] = [value]; + this.set(key, values = [value]); } + return values; } - ts.multiMapAdd = multiMapAdd; - function multiMapRemove(map, key, value) { - var values = map[key]; + function multiMapRemove(key, value) { + var values = this.get(key); if (values) { unorderedRemoveItem(values, value); if (!values.length) { - delete map[key]; + this.delete(key); } } } - ts.multiMapRemove = multiMapRemove; function isArray(value) { return Array.isArray ? Array.isArray(value) : value instanceof Array; } @@ -981,6 +2004,7 @@ var ts; baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } + ts.formatStringFromArgs = formatStringFromArgs; ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; @@ -1082,8 +2106,10 @@ var ts; if (b === undefined) return 1; if (ignoreCase) { - if (ts.collator && String.prototype.localeCompare) { - var result = a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); + if (ts.collator) { + var result = ts.localeCompareIsCorrect ? + ts.collator.compare(a, b) : + a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 : result > 0 ? 1 : 0; } a = a.toUpperCase(); @@ -1465,36 +2491,26 @@ var ts; var singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; var singleAsteriskRegexFragmentOther = "[^/]*"; function getRegularExpressionForWildcard(specs, basePath, usage) { + var patterns = getRegularExpressionsForWildcards(specs, basePath, usage); + if (!patterns || !patterns.length) { + return undefined; + } + var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var terminator = usage === "exclude" ? "($|/)" : "$"; + return "^(" + pattern + ")" + terminator; + } + ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; + function getRegularExpressionsForWildcards(specs, basePath, usage) { if (specs === undefined || specs.length === 0) { return undefined; } var replaceWildcardCharacter = usage === "files" ? replaceWildCardCharacterFiles : replaceWildCardCharacterOther; var singleAsteriskRegexFragment = usage === "files" ? singleAsteriskRegexFragmentFiles : singleAsteriskRegexFragmentOther; var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; - var pattern = ""; - var hasWrittenSubpattern = false; - for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { - var spec = specs_1[_i]; - if (!spec) { - continue; - } - var subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); - if (subPattern === undefined) { - continue; - } - if (hasWrittenSubpattern) { - pattern += "|"; - } - pattern += "(" + subPattern + ")"; - hasWrittenSubpattern = true; - } - if (!pattern) { - return undefined; - } - var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return flatMap(specs, function (spec) { + return spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + }); } - ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function isImplicitGlob(lastPathComponent) { return !/[.*?]/.test(lastPathComponent); } @@ -1564,6 +2580,7 @@ var ts; currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); return { + includeFilePatterns: map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -1576,34 +2593,48 @@ var ts; currentDirectory = normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; - var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); + var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return new RegExp(pattern, regexFlag); }); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); var excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); - var result = []; + var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]]; + var comparer = useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive; for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; visitDirectory(basePath, combinePaths(currentDirectory, basePath)); } - return result; + return flatten(results); function visitDirectory(path, absolutePath) { var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; + files = files.slice().sort(comparer); + directories = directories.slice().sort(comparer); + var _loop_1 = function (current) { + var name = combinePaths(path, current); + var absoluteName = combinePaths(absolutePath, current); + if (extensions && !fileExtensionIsAny(name, extensions)) + return "continue"; + if (excludeRegex && excludeRegex.test(absoluteName)) + return "continue"; + if (!includeFileRegexes) { + results[0].push(name); + } + else { + var includeIndex = findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); }); + if (includeIndex !== -1) { + results[includeIndex].push(name); + } + } + }; for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var current = files_1[_i]; - var name_1 = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); - if ((!extensions || fileExtensionIsAny(name_1, extensions)) && - (!includeFileRegex || includeFileRegex.test(absoluteName)) && - (!excludeRegex || !excludeRegex.test(absoluteName))) { - result.push(name_1); - } + _loop_1(current); } for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var current = directories_1[_b]; - var name_2 = combinePaths(path, current); + var name = combinePaths(path, current); var absoluteName = combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { - visitDirectory(name_2, absoluteName); + visitDirectory(name, absoluteName); } } } @@ -1619,14 +2650,14 @@ var ts; includeBasePaths.push(getIncludeBasePath(absolute)); } includeBasePaths.sort(useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); - var _loop_1 = function (includeBasePath) { + var _loop_2 = function (includeBasePath) { if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { basePaths.push(includeBasePath); } }; for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) { var includeBasePath = includeBasePaths_1[_a]; - _loop_1(includeBasePath); + _loop_2(includeBasePath); } } return basePaths; @@ -1666,13 +2697,13 @@ var ts; var allSupportedExtensions = ts.supportedTypeScriptExtensions.concat(ts.supportedJavascriptExtensions); function getSupportedExtensions(options, extraFileExtensions) { var needAllExtensions = options && options.allowJs; - if (!extraFileExtensions || extraFileExtensions.length === 0) { + if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } - var extensions = (needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions).slice(0); + var extensions = allSupportedExtensions.slice(0); for (var _i = 0, extraFileExtensions_1 = extraFileExtensions; _i < extraFileExtensions_1.length; _i++) { var extInfo = extraFileExtensions_1[_i]; - if (needAllExtensions || extInfo.scriptKind === 3) { + if (extensions.indexOf(extInfo.extension) === -1) { extensions.push(extInfo.extension); } } @@ -1700,33 +2731,40 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + var ExtensionPriority; + (function (ExtensionPriority) { + ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; + ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; + ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; + ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; + })(ExtensionPriority = ts.ExtensionPriority || (ts.ExtensionPriority = {})); function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { - return adjustExtensionPriority(i); + return adjustExtensionPriority(i, supportedExtensions); } } return 0; } ts.getExtensionPriority = getExtensionPriority; - function adjustExtensionPriority(extensionPriority) { + function adjustExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2) { return 0; } - else if (extensionPriority < 5) { + else if (extensionPriority < supportedExtensions.length) { return 2; } else { - return 5; + return supportedExtensions.length; } } ts.adjustExtensionPriority = adjustExtensionPriority; - function getNextLowestExtensionPriority(extensionPriority) { + function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2) { return 2; } else { - return 5; + return supportedExtensions.length; } } ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority; @@ -1784,6 +2822,13 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; + var AssertionLevel; + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(AssertionLevel = ts.AssertionLevel || (ts.AssertionLevel = {})); var Debug; (function (Debug) { Debug.currentAssertionLevel = 0; @@ -2073,32 +3118,32 @@ var ts; var useNonPollingWatchers = process.env["TSC_NONPOLLING_WATCHER"]; function createWatchedFileSet() { var dirWatchers = ts.createMap(); - var fileWatcherCallbacks = ts.createMap(); + var fileWatcherCallbacks = ts.createMultiMap(); return { addFile: addFile, removeFile: removeFile }; function reduceDirWatcherRefCountForFile(fileName) { var dirName = ts.getDirectoryPath(fileName); - var watcher = dirWatchers[dirName]; + var watcher = dirWatchers.get(dirName); if (watcher) { watcher.referenceCount -= 1; if (watcher.referenceCount <= 0) { watcher.close(); - delete dirWatchers[dirName]; + dirWatchers.delete(dirName); } } } function addDirWatcher(dirPath) { - var watcher = dirWatchers[dirPath]; + var watcher = dirWatchers.get(dirPath); if (watcher) { watcher.referenceCount += 1; return; } watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); watcher.referenceCount = 1; - dirWatchers[dirPath] = watcher; + dirWatchers.set(dirPath, watcher); return; } function addFileWatcherCallback(filePath, callback) { - ts.multiMapAdd(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.add(filePath, callback); } function addFile(fileName, callback) { addFileWatcherCallback(fileName, callback); @@ -2110,16 +3155,19 @@ var ts; reduceDirWatcherRefCountForFile(watchedFile.fileName); } function removeFileWatcherCallback(filePath, callback) { - ts.multiMapRemove(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.remove(filePath, callback); } function fileEventHandler(eventName, relativeFileName, baseDirPath) { var fileName = typeof relativeFileName !== "string" ? undefined : ts.getNormalizedAbsolutePath(relativeFileName, baseDirPath); - if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks[fileName]) { - for (var _i = 0, _a = fileWatcherCallbacks[fileName]; _i < _a.length; _i++) { - var fileCallback = _a[_i]; - fileCallback(fileName); + if ((eventName === "change" || eventName === "rename")) { + var callbacks = fileWatcherCallbacks.get(fileName); + if (callbacks) { + for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) { + var fileCallback = callbacks_1[_i]; + fileCallback(fileName); + } } } } @@ -2184,10 +3232,10 @@ var ts; if (entry === "." || entry === "..") { continue; } - var name_3 = ts.combinePaths(path, entry); + var name = ts.combinePaths(path, entry); var stat = void 0; try { - stat = _fs.statSync(name_3); + stat = _fs.statSync(name); } catch (e) { continue; @@ -2208,6 +3256,11 @@ var ts; function readDirectory(path, extensions, excludes, includes) { return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), getAccessibleFileSystemEntries); } + var FileSystemEntryKind; + (function (FileSystemEntryKind) { + FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; + FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; + })(FileSystemEntryKind || (FileSystemEntryKind = {})); function fileSystemEntryExists(path, entryKind) { try { var stat = _fs.statSync(path); @@ -2261,7 +3314,7 @@ var ts; }, watchDirectory: function (directoryName, callback, recursive) { var options; - if (!directoryExists(directoryName)) { + if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { return noOpFileWatcher; } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { @@ -2276,6 +3329,9 @@ var ts; } ; }); + function isUNCPath(s) { + return s.length > 2 && s.charCodeAt(0) === 47 && s.charCodeAt(1) === 47; + } }, resolvePath: function (path) { return _path.resolve(path); @@ -2475,7 +3531,7 @@ var ts; _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, 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." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." }, 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." }, @@ -2586,6 +3642,7 @@ var ts; 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." }, + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", message: "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules." }, 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_Set_the_experimentalDecorators_option_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_Set_t_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", message: "Generators are only available when targeting ECMAScript 2015 or higher." }, @@ -2632,6 +3689,7 @@ var ts; Global_module_exports_may_only_appear_at_top_level: { code: 1316, category: ts.DiagnosticCategory.Error, key: "Global_module_exports_may_only_appear_at_top_level_1316", message: "Global module exports may only appear at top level." }, A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, 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." }, @@ -2861,6 +3919,10 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, + A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: { code: 2545, category: ts.DiagnosticCategory.Error, key: "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", message: "A mixin class must have a constructor with a single rest parameter of type 'any[]'." }, + Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: { code: 2546, category: ts.DiagnosticCategory.Error, key: "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", message: "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union 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." }, @@ -2870,6 +3932,8 @@ var ts; 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" }, + JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, + Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: { code: 2649, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", message: "Cannot augment module '{0}' with value exports because it resolves to a non-module entity." }, 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." }, @@ -2918,9 +3982,15 @@ var ts; The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { code: 2696, category: ts.DiagnosticCategory.Error, key: "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", message: "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?" }, An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, + Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: { code: 2699, category: ts.DiagnosticCategory.Error, key: "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", message: "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'." }, Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, + An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: { code: 2705, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", message: "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option." }, + Required_type_parameters_may_not_follow_optional_type_parameters: { code: 2706, category: ts.DiagnosticCategory.Error, key: "Required_type_parameters_may_not_follow_optional_type_parameters_2706", message: "Required type parameters may not follow optional type parameters." }, + Generic_type_0_requires_between_1_and_2_type_arguments: { code: 2707, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_between_1_and_2_type_arguments_2707", message: "Generic type '{0}' requires between {1} and {2} type arguments." }, 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}'." }, @@ -2931,8 +4001,8 @@ var ts; 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}'." }, + 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}'." }, @@ -2995,6 +4065,7 @@ var ts; Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { code: 4090, category: ts.DiagnosticCategory.Message, key: "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", message: "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", message: "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4092, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", message: "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'." }, + extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced: { code: 4093, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced_4093", message: "'extends' clause of exported class '{0}' refers to a type whose name cannot be referenced." }, 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." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, @@ -3040,7 +4111,7 @@ var ts; 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." }, + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'" }, 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" }, @@ -3055,6 +4126,7 @@ var ts; LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION_6037", message: "LOCATION" }, DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY_6038", message: "DIRECTORY" }, STRATEGY: { code: 6039, category: ts.DiagnosticCategory.Message, key: "STRATEGY_6039", message: "STRATEGY" }, + FILE_OR_DIRECTORY: { code: 6040, category: ts.DiagnosticCategory.Message, key: "FILE_OR_DIRECTORY_6040", message: "FILE OR 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." }, @@ -3088,7 +4160,8 @@ var ts; 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_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, - 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'" }, + Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'" }, + File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, @@ -3102,12 +4175,12 @@ var ts; Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, - Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", message: "Loading module as file / folder, candidate module location '{0}', target file type '{1}'." }, File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, - Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, - package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, + package_json_does_not_have_a_0_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_0_field_6100", message: "'package.json' does not have a '{0}' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, @@ -3144,7 +4217,6 @@ var ts; Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, - No_types_specified_in_package_json_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json', so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, @@ -3154,6 +4226,8 @@ var ts; Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, + Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, + Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, 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." }, @@ -3195,7 +4269,7 @@ var ts; 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." }, 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." }, - 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." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: { 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' clause." }, 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." }, Language_service_is_disabled: { code: 9004, category: ts.DiagnosticCategory.Error, key: "Language_service_is_disabled_9004", message: "Language service is disabled." }, 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'." }, @@ -3210,22 +4284,26 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, - Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, - Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, - Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, + Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: {0}" }, + Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, + Add_this_to_unresolved_variable: { code: 90008, category: ts.DiagnosticCategory.Message, key: "Add_this_to_unresolved_variable_90008", message: "Add 'this.' to unresolved variable." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, }; })(ts || (ts = {})); var ts; @@ -3234,7 +4312,7 @@ var ts; return token >= 70; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = ts.createMap({ + var textToToken = ts.createMapFromTemplate({ "abstract": 116, "any": 118, "as": 117, @@ -3258,7 +4336,7 @@ var ts; "false": 85, "finally": 86, "for": 87, - "from": 138, + "from": 139, "function": 88, "get": 124, "if": 89, @@ -3276,27 +4354,28 @@ var ts; "new": 93, "null": 94, "number": 132, + "object": 133, "package": 110, "private": 111, "protected": 112, "public": 113, "readonly": 130, "require": 131, - "global": 139, + "global": 140, "return": 95, - "set": 133, + "set": 134, "static": 114, - "string": 134, + "string": 135, "super": 96, "switch": 97, - "symbol": 135, + "symbol": 136, "this": 98, "throw": 99, "true": 100, "try": 101, - "type": 136, + "type": 137, "typeof": 102, - "undefined": 137, + "undefined": 138, "var": 103, "void": 104, "while": 105, @@ -3304,7 +4383,7 @@ var ts; "yield": 115, "async": 119, "await": 120, - "of": 140, + "of": 141, "{": 16, "}": 17, "(": 18, @@ -3399,9 +4478,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var name_4 in source) { - result[source[name_4]] = name_4; - } + source.forEach(function (value, name) { + result[value] = name; + }); return result; } var tokenStrings = makeReverseMap(textToToken); @@ -3410,7 +4489,7 @@ var ts; } ts.tokenToString = tokenToString; function stringToToken(s) { - return textToToken[s]; + return textToToken.get(s); } ts.stringToToken = stringToToken; function computeLineStarts(text) { @@ -3470,7 +4549,6 @@ var ts; return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - var hasOwnProperty = Object.prototype.hasOwnProperty; function isWhiteSpace(ch) { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } @@ -3606,7 +4684,7 @@ var ts; 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++) { + for (var i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -3792,7 +4870,7 @@ var ts; if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { return false; } - for (var i = 1, n = name.length; i < n; i++) { + for (var i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -4129,8 +5207,11 @@ var ts; 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]; + if (ch >= 97 && ch <= 122) { + token = textToToken.get(tokenValue); + if (token !== undefined) { + return token; + } } } return token = 70; @@ -4840,12 +5921,13 @@ var ts; }, { name: "jsx", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "preserve": 1, + "react-native": 3, "react": 2 }), paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, }, { name: "reactNamespace", @@ -4875,7 +5957,7 @@ var ts; { name: "module", shortName: "m", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "none": ts.ModuleKind.None, "commonjs": ts.ModuleKind.CommonJS, "amd": ts.ModuleKind.AMD, @@ -4889,7 +5971,7 @@ var ts; }, { name: "newLine", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "crlf": 0, "lf": 1 }), @@ -4986,8 +6068,8 @@ var ts; shortName: "p", type: "string", isFilePath: true, - description: ts.Diagnostics.Compile_the_project_in_the_given_directory, - paramType: ts.Diagnostics.DIRECTORY + description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY }, { name: "removeComments", @@ -5037,7 +6119,7 @@ var ts; { name: "target", shortName: "t", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "es3": 0, "es5": 1, "es6": 2, @@ -5074,7 +6156,7 @@ var ts; }, { name: "moduleResolution", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "node": ts.ModuleResolutionKind.NodeJs, "classic": ts.ModuleResolutionKind.Classic, }), @@ -5179,7 +6261,7 @@ var ts; type: "list", element: { name: "lib", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "es5": "lib.es5.d.ts", "es6": "lib.es2015.d.ts", "es2015": "lib.es2015.d.ts", @@ -5225,6 +6307,15 @@ var ts; name: "alwaysStrict", type: "boolean", description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + }, + { + name: "plugins", + type: "list", + isTSConfigOnly: true, + element: { + name: "plugin", + type: "object" + } } ]; ts.typeAcquisitionDeclarations = [ @@ -5279,9 +6370,9 @@ var ts; var optionNameMap = ts.createMap(); var shortOptionNames = ts.createMap(); ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; + optionNameMap.set(option.name.toLowerCase(), option); if (option.shortName) { - shortOptionNames[option.shortName] = option.name; + shortOptionNames.set(option.shortName, option.name); } }); optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; @@ -5289,7 +6380,7 @@ var ts; } ts.getOptionNameMap = getOptionNameMap; function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; @@ -5338,11 +6429,12 @@ var ts; } else if (s.charCodeAt(0) === 45) { s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); - if (s in shortOptionNames) { - s = shortOptionNames[s]; + var short = shortOptionNames.get(s); + if (short !== undefined) { + s = short; } - if (s in optionNameMap) { - var opt = optionNameMap[s]; + var opt = optionNameMap.get(s); + if (opt) { if (opt.isTSConfigOnly) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); } @@ -5468,19 +6560,18 @@ var ts; } } function getNameOfCompilerOptionValue(value, customTypeMap) { - for (var key in customTypeMap) { - if (customTypeMap[key] === value) { + return ts.forEachEntry(customTypeMap, function (mapValue, key) { + if (mapValue === value) { return key; } - } - return undefined; + }); } function serializeCompilerOptions(options) { - var result = ts.createMap(); + var result = {}; var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_5 in options) { - if (ts.hasProperty(options, name_5)) { - switch (name_5) { + for (var name in options) { + if (ts.hasProperty(options, name)) { + switch (name) { case "init": case "watch": case "version": @@ -5488,12 +6579,12 @@ var ts; case "project": break; default: - var value = options[name_5]; - var optionDefinition = optionsNameMap[name_5.toLowerCase()]; + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { - result[name_5] = value; + result[name] = value; } else { if (optionDefinition.type === "list") { @@ -5502,10 +6593,10 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_5] = convertedValue; + result[name] = convertedValue; } else { - result[name_5] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -5539,6 +6630,7 @@ var ts; if (resolutionStack === void 0) { resolutionStack = []; } if (extraFileExtensions === void 0) { extraFileExtensions = []; } var errors = []; + basePath = ts.normalizeSlashes(basePath); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -5711,8 +6803,8 @@ var ts; } var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); for (var id in jsonOptions) { - if (id in optionNameMap) { - var opt = optionNameMap[id]; + var opt = optionNameMap.get(id); + if (opt) { defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); } else { @@ -5746,8 +6838,9 @@ var ts; } function convertJsonOptionOfCustomType(opt, value, errors) { var key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; + var val = opt.type.get(key); + if (val !== undefined) { + return val; } else { errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); @@ -5781,7 +6874,7 @@ var ts; for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { var fileName = fileNames_1[_i]; var file = ts.combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; + literalFileMap.set(keyMapper(file), file); } } if (include && include.length > 0) { @@ -5792,14 +6885,13 @@ var ts; } removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); var key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; + if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) { + wildcardFileMap.set(key, file); } } } - var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); - var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); + var literalFiles = ts.arrayFrom(literalFileMap.values()); + var wildcardFiles = ts.arrayFrom(wildcardFileMap.values()); return { fileNames: literalFiles.concat(wildcardFiles), wildcardDirectories: wildcardDirectories @@ -5807,8 +6899,8 @@ var ts; } function validateSpecs(specs, errors, allowTrailingRecursion) { var validSpecs = []; - for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { - var spec = specs_2[_i]; + for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { + var spec = specs_1[_i]; if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); } @@ -5827,7 +6919,7 @@ var ts; function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - var wildcardDirectories = ts.createMap(); + var wildcardDirectories = {}; if (include !== undefined) { var recursiveKeys = []; for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { @@ -5848,14 +6940,16 @@ var ts; } } } - for (var key in wildcardDirectories) { - for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { - var recursiveKey = recursiveKeys_1[_a]; - if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; + for (var key in wildcardDirectories) + if (ts.hasProperty(wildcardDirectories, key)) { + for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { + var recursiveKey = recursiveKeys_1[_a]; + if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; + } } } - } + ; } return wildcardDirectories; } @@ -5874,11 +6968,11 @@ var ts; } function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); + var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions); for (var i = 0; i < adjustedExtensionPriority; i++) { var higherPriorityExtension = extensions[i]; var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { return true; } } @@ -5886,17 +6980,13 @@ var ts; } function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); + var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions); for (var i = nextExtensionPriority; i < extensions.length; i++) { var lowerPriorityExtension = extensions[i]; var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; + wildcardFiles.delete(lowerPriorityPath); } } - function addFileToOutput(output, file) { - output.push(file); - return output; - } function caseSensitiveKeyMapper(key) { return key; } @@ -5905,385 +6995,6 @@ var ts; } })(ts || (ts = {})); var ts; -(function (ts) { - var JsTyping; - (function (JsTyping) { - ; - ; - var safeList; - var EmptySafeList = ts.createMap(); - JsTyping.nodeCoreModuleList = [ - "buffer", "querystring", "events", "http", "cluster", - "zlib", "os", "https", "punycode", "repl", "readline", - "vm", "child_process", "url", "dns", "net", - "dgram", "fs", "path", "string_decoder", "tls", - "crypto", "stream", "util", "assert", "tty", "domain", - "constants", "process", "v8", "timers", "console" - ]; - var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typeAcquisition, unresolvedImports) { - var inferredTypings = ts.createMap(); - if (!typeAcquisition || !typeAcquisition.enable) { - return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; - } - fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { - var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); - return kind === 1 || kind === 2; - }); - if (!safeList) { - var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); - safeList = result.config ? ts.createMap(result.config) : EmptySafeList; - } - var filesToWatch = []; - var searchDirs = []; - var exclude = []; - mergeTypings(typeAcquisition.include); - exclude = typeAcquisition.exclude || []; - var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); - if (projectRootPath) { - possibleSearchDirs.push(projectRootPath); - } - searchDirs = ts.deduplicate(possibleSearchDirs); - for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { - var searchDir = searchDirs_1[_i]; - var packageJsonPath = ts.combinePaths(searchDir, "package.json"); - getTypingNamesFromJson(packageJsonPath, filesToWatch); - var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); - getTypingNamesFromJson(bowerJsonPath, filesToWatch); - var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); - getTypingNamesFromNodeModuleFolder(nodeModulesPath); - } - getTypingNamesFromSourceFileNames(fileNames); - if (unresolvedImports) { - for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { - var moduleId = unresolvedImports_1[_a]; - var typingName = moduleId in nodeCoreModules ? "node" : moduleId; - if (!(typingName in inferredTypings)) { - inferredTypings[typingName] = undefined; - } - } - } - for (var name_6 in packageNameToTypingLocation) { - if (name_6 in inferredTypings && !inferredTypings[name_6]) { - inferredTypings[name_6] = packageNameToTypingLocation[name_6]; - } - } - for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { - var excludeTypingName = exclude_1[_b]; - delete inferredTypings[excludeTypingName]; - } - var newTypingNames = []; - var cachedTypingPaths = []; - for (var typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); - } - else { - newTypingNames.push(typing); - } - } - return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; - function mergeTypings(typingNames) { - if (!typingNames) { - return; - } - for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { - var typing = typingNames_1[_i]; - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; - } - } - } - function getTypingNamesFromJson(jsonPath, filesToWatch) { - if (host.fileExists(jsonPath)) { - filesToWatch.push(jsonPath); - } - var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); - if (result.config) { - var jsonConfig = result.config; - if (jsonConfig.dependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); - } - if (jsonConfig.devDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); - } - if (jsonConfig.optionalDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); - } - if (jsonConfig.peerDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); - } - } - } - function getTypingNamesFromSourceFileNames(fileNames) { - var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); - var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); - var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); - if (safeList !== EmptySafeList) { - mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); - } - var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); - if (hasJsxFile) { - mergeTypings(["react"]); - } - } - function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { - if (!host.directoryExists(nodeModulesPath)) { - return; - } - var typingNames = []; - var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); - for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { - var fileName = fileNames_2[_i]; - var normalizedFileName = ts.normalizePath(fileName); - if (ts.getBaseFileName(normalizedFileName) !== "package.json") { - continue; - } - var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); - if (!result.config) { - continue; - } - var packageJson = result.config; - if (packageJson._requiredBy && - ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { - continue; - } - if (!packageJson.name) { - continue; - } - if (packageJson.typings) { - var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; - } - else { - typingNames.push(packageJson.name); - } - } - mergeTypings(typingNames); - } - } - JsTyping.discoverTypings = discoverTypings; - })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - server.ActionSet = "action::set"; - server.ActionInvalidate = "action::invalidate"; - server.EventBeginInstallTypes = "event::beginInstallTypes"; - server.EventEndInstallTypes = "event::endInstallTypes"; - var Arguments; - (function (Arguments) { - Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation"; - Arguments.LogFile = "--logFile"; - Arguments.EnableTelemetry = "--enableTelemetry"; - })(Arguments = server.Arguments || (server.Arguments = {})); - function hasArgument(argumentName) { - return ts.sys.args.indexOf(argumentName) >= 0; - } - server.hasArgument = hasArgument; - function findArgument(argumentName) { - var index = ts.sys.args.indexOf(argumentName); - return index >= 0 && index < ts.sys.args.length - 1 - ? ts.sys.args[index + 1] - : undefined; - } - server.findArgument = findArgument; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - var LogLevel; - (function (LogLevel) { - LogLevel[LogLevel["terse"] = 0] = "terse"; - LogLevel[LogLevel["normal"] = 1] = "normal"; - LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; - LogLevel[LogLevel["verbose"] = 3] = "verbose"; - })(LogLevel = server.LogLevel || (server.LogLevel = {})); - server.emptyArray = []; - var Msg; - (function (Msg) { - Msg.Err = "Err"; - Msg.Info = "Info"; - Msg.Perf = "Perf"; - })(Msg = server.Msg || (server.Msg = {})); - function getProjectRootPath(project) { - switch (project.projectKind) { - case server.ProjectKind.Configured: - return ts.getDirectoryPath(project.getProjectName()); - case server.ProjectKind.Inferred: - return ""; - case server.ProjectKind.External: - var projectName = ts.normalizeSlashes(project.getProjectName()); - return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; - } - } - function createInstallTypingsRequest(project, typeAcquisition, unresolvedImports, cachePath) { - return { - projectName: project.getProjectName(), - fileNames: project.getFileNames(true), - compilerOptions: project.getCompilerOptions(), - typeAcquisition: typeAcquisition, - unresolvedImports: unresolvedImports, - projectRootPath: getProjectRootPath(project), - cachePath: cachePath, - kind: "discover" - }; - } - server.createInstallTypingsRequest = createInstallTypingsRequest; - var Errors; - (function (Errors) { - function ThrowNoProject() { - throw new Error("No Project."); - } - Errors.ThrowNoProject = ThrowNoProject; - function ThrowProjectLanguageServiceDisabled() { - throw new Error("The project's language service is disabled."); - } - Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; - function ThrowProjectDoesNotContainDocument(fileName, project) { - throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); - } - Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; - })(Errors = server.Errors || (server.Errors = {})); - function getDefaultFormatCodeSettings(host) { - return { - indentSize: 4, - tabSize: 4, - newLineCharacter: host.newLine || "\n", - convertTabsToSpaces: true, - indentStyle: ts.IndentStyle.Smart, - insertSpaceAfterCommaDelimiter: true, - insertSpaceAfterSemicolonInForStatements: true, - insertSpaceBeforeAndAfterBinaryOperators: true, - insertSpaceAfterKeywordsInControlFlowStatements: true, - insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, - placeOpenBraceOnNewLineForFunctions: false, - placeOpenBraceOnNewLineForControlBlocks: false, - }; - } - server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; - function mergeMaps(target, source) { - for (var key in source) { - if (ts.hasProperty(source, key)) { - target[key] = source[key]; - } - } - } - server.mergeMaps = mergeMaps; - function removeItemFromSet(items, itemToRemove) { - if (items.length === 0) { - return; - } - var index = items.indexOf(itemToRemove); - if (index < 0) { - return; - } - if (index === items.length - 1) { - items.pop(); - } - else { - items[index] = items.pop(); - } - } - server.removeItemFromSet = removeItemFromSet; - function toNormalizedPath(fileName) { - return ts.normalizePath(fileName); - } - server.toNormalizedPath = toNormalizedPath; - function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { - var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); - return getCanonicalFileName(f); - } - server.normalizedPathToPath = normalizedPathToPath; - function asNormalizedPath(fileName) { - return fileName; - } - server.asNormalizedPath = asNormalizedPath; - function createNormalizedPathMap() { - var map = Object.create(null); - return { - get: function (path) { - return map[path]; - }, - set: function (path, value) { - map[path] = value; - }, - contains: function (path) { - return ts.hasProperty(map, path); - }, - remove: function (path) { - delete map[path]; - } - }; - } - server.createNormalizedPathMap = createNormalizedPathMap; - function isInferredProjectName(name) { - return /dev\/null\/inferredProject\d+\*/.test(name); - } - server.isInferredProjectName = isInferredProjectName; - function makeInferredProjectName(counter) { - return "/dev/null/inferredProject" + counter + "*"; - } - server.makeInferredProjectName = makeInferredProjectName; - function toSortedReadonlyArray(arr) { - arr.sort(); - return arr; - } - server.toSortedReadonlyArray = toSortedReadonlyArray; - var ThrottledOperations = (function () { - function ThrottledOperations(host) { - this.host = host; - this.pendingTimeouts = ts.createMap(); - } - ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { - if (ts.hasProperty(this.pendingTimeouts, operationId)) { - this.host.clearTimeout(this.pendingTimeouts[operationId]); - } - this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); - }; - ThrottledOperations.run = function (self, operationId, cb) { - delete self.pendingTimeouts[operationId]; - cb(); - }; - return ThrottledOperations; - }()); - server.ThrottledOperations = ThrottledOperations; - var GcTimer = (function () { - function GcTimer(host, delay, logger) { - this.host = host; - this.delay = delay; - this.logger = logger; - } - GcTimer.prototype.scheduleCollect = function () { - if (!this.host.gc || this.timerId != undefined) { - return; - } - this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); - }; - GcTimer.run = function (self) { - self.timerId = undefined; - var log = self.logger.hasLevel(LogLevel.requestTime); - var before = log && self.host.getMemoryUsage(); - self.host.gc(); - if (log) { - var after = self.host.getMemoryUsage(); - self.logger.perftrc("GC::before " + before + ", after " + after); - } - }; - return GcTimer; - }()); - server.GcTimer = GcTimer; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; (function (ts) { function trace(host) { host.trace(ts.formatMessage.apply(undefined, arguments)); @@ -6293,6 +7004,12 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; + var Extensions; + (function (Extensions) { + Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; + Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; + Extensions[Extensions["DtsOnly"] = 2] = "DtsOnly"; + })(Extensions || (Extensions = {})); function resolvedTypeScriptOnly(resolved) { if (!resolved) { return undefined; @@ -6300,9 +7017,6 @@ var ts; ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); return resolved.path; } - function resolvedFromAnyFile(path) { - return { path: path, extension: ts.extensionFromPath(path) }; - } function resolvedModuleFromResolved(_a, isExternalLibraryImport) { var path = _a.path, extension = _a.extension; return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; @@ -6314,37 +7028,28 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { + function tryReadPackageJsonFields(readTypes, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); - switch (extensions) { - case 2: - case 0: - return tryReadFromField("typings") || tryReadFromField("types"); - case 1: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; - } + return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); - } - return typesFilePath; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } + if (!ts.hasProperty(jsonContent, fieldName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName); } + return; } + var fileName = jsonContent[fieldName]; + if (typeof fileName !== "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof fileName); + } + return; + } + var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path); + } + return path; } } function readJson(path, host) { @@ -6382,6 +7087,7 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } + return undefined; }); return typeRoots; } @@ -6436,7 +7142,11 @@ var ts; return ts.forEach(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); }); } else { @@ -6452,7 +7162,8 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -6493,31 +7204,116 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); + if (!perModuleNameCache) { + perModuleNameCache = createPerModuleNameCache(); + moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent = ts.getDirectoryPath(current); + if (parent === current || directoryPathMap.contains(parent)) { + break; + } + directoryPathMap.set(parent, result); + current = parent; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache.get(moduleName); + if (result) { if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache.set(moduleName, result); + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; } if (traceEnabled) { if (result.resolvedModule) { @@ -6642,37 +7438,43 @@ var ts; return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, false); + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, jsOnly) { + if (jsOnly === void 0) { jsOnly = false; } var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(0) || tryResolve(1); - if (result) { - var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + var result = jsOnly ? tryResolve(Extensions.JavaScript) : (tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript)); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { - var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); + var loader = function (extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, true); }; + var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); if (resolved) { - return { resolved: resolved, isExternalLibraryImport: false }; + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); - return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); - return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state, true); + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } - ts.nodeModuleNameResolver = nodeModuleNameResolver; + ts.nodeModuleNameResolverWorker = nodeModuleNameResolverWorker; function realpath(path, host, traceEnabled) { if (!host.realpath) { return path; @@ -6683,12 +7485,35 @@ var ts; } return real; } - function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } - var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson); } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); @@ -6716,11 +7541,11 @@ var ts; } } switch (extensions) { - case 2: + case Extensions.DtsOnly: return tryExtension(".d.ts", ts.Extension.Dts); - case 0: + case Extensions.TypeScript: return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case 1: + case Extensions.JavaScript: return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } function tryExtension(ext, extension) { @@ -6729,113 +7554,168 @@ var ts; } } function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); - } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); - } - failedLookupLocations.push(fileName); - return undefined; - } - } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromFile) { - return resolvedFromAnyFile(fromFile); - } - var x = tryAddingExtensions(typesFile, 0, failedLookupLocations, onlyRecordFailures_1, state); - if (x) { - return x; + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); } + return fileName; } else { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); } } } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + failedLookupLocations.push(fileName); + return undefined; + } + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { + if (considerPackageJson === void 0) { considerPackageJson = true; } + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (considerPackageJson) { + var packageJsonPath = pathToPackageJson(candidate); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + var fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; + } + } + else { + if (directoryExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + } + failedLookupLocations.push(packageJsonPath); } - failedLookupLocations.push(packageJsonPath); } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + if (!file) { + return undefined; + } + var onlyRecordFailures = !directoryProbablyExists(ts.getDirectoryPath(file), state.host); + var fromFile = tryFile(file, failedLookupLocations, onlyRecordFailures, state); + if (fromFile) { + var resolved = fromFile && resolvedIfExtensionMatches(extensions, fromFile); + if (resolved) { + return resolved; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile); + } + } + var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; + return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, false); + } + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false, cache); } function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(2, moduleName, directory, failedLookupLocations, state, true); + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, true, undefined); } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); } }); } function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { if (typesOnly === void 0) { typesOnly = false; } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); if (packageResult) { return packageResult; } - if (extensions !== 1) { - return loadModuleFromNodeModulesFolder(2, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(0) || tryResolve(1); - return createResolvedModuleWithFailedLookupLocations(resolved, false, failedLookupLocations); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); if (resolvedUsingSettings) { - return resolvedUsingSettings; + return { value: resolvedUsingSettings }; } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); }); if (resolved_3) { return resolved_3; } - if (extensions === 0) { + if (extensions === Extensions.TypeScript) { return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state)); } } } @@ -6847,10 +7727,13 @@ var ts; } var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(2, moduleName, globalCache, failedLookupLocations, state); + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } function forEachAncestorDirectory(directory, callback) { while (true) { var result = callback(directory); @@ -6881,6 +7764,19 @@ var ts; return undefined; } ts.getDeclarationOfKind = getDeclarationOfKind; + function findDeclaration(symbol, predicate) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; + if (predicate(declaration)) { + return declaration; + } + } + } + return undefined; + } + ts.findDeclaration = findDeclaration; var stringWriters = []; function getSingleLineStringWriter() { if (stringWriters.length === 0) { @@ -6901,7 +7797,8 @@ var ts; decreaseIndent: ts.noop, clear: function () { return str_1 = ""; }, trackSymbol: ts.noop, - reportInaccessibleThisError: ts.noop + reportInaccessibleThisError: ts.noop, + reportIllegalExtends: ts.noop }; } return stringWriters.pop(); @@ -6917,25 +7814,25 @@ var ts; } ts.getFullWidth = getFullWidth; function hasResolvedModule(sourceFile, moduleNameText) { - return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); + return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText)); } ts.hasResolvedModule = hasResolvedModule; function getResolvedModule(sourceFile, moduleNameText) { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules.get(moduleNameText) : undefined; } ts.getResolvedModule = getResolvedModule; function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { if (!sourceFile.resolvedModules) { sourceFile.resolvedModules = ts.createMap(); } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; + sourceFile.resolvedModules.set(moduleNameText, resolvedModule); } ts.setResolvedModule = setResolvedModule; function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { if (!sourceFile.resolvedTypeReferenceDirectiveNames) { sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); } - sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; + sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective); } ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; function moduleResolutionIsEqualTo(oldResolution, newResolution) { @@ -6954,7 +7851,7 @@ var ts; } for (var i = 0; i < names.length; i++) { var newResolution = newResolutions[i]; - var oldResolution = oldResolutions && oldResolutions[names[i]]; + var oldResolution = oldResolutions && oldResolutions.get(names[i]); var changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) : newResolution; @@ -6981,7 +7878,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 261) { + while (node && node.kind !== 264) { node = node.parent; } return node; @@ -6989,11 +7886,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 204: - case 232: - case 211: - case 212: + case 206: + case 234: case 213: + case 214: + case 215: return true; } return false; @@ -7058,18 +7955,18 @@ var ts; if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 292 && node._children.length > 0) { + if (node.kind === 296 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 262 && node.kind <= 288; + return node.kind >= 266 && node.kind <= 295; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 278 && node.kind <= 291; + return node.kind >= 282 && node.kind <= 295; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -7129,18 +8026,47 @@ var ts; } ts.getLiteralText = getLiteralText; function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 && text.length > 1) { + return node.kind === 8 + && (getNumericLiteralFlags(text, 6) & 6) !== 0; + } + ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + var NumericLiteralFlags; + (function (NumericLiteralFlags) { + NumericLiteralFlags[NumericLiteralFlags["None"] = 0] = "None"; + NumericLiteralFlags[NumericLiteralFlags["Hexadecimal"] = 1] = "Hexadecimal"; + NumericLiteralFlags[NumericLiteralFlags["Binary"] = 2] = "Binary"; + NumericLiteralFlags[NumericLiteralFlags["Octal"] = 4] = "Octal"; + NumericLiteralFlags[NumericLiteralFlags["Scientific"] = 8] = "Scientific"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctal"] = 6] = "BinaryOrOctal"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctalOrHexadecimal"] = 7] = "BinaryOrOctalOrHexadecimal"; + NumericLiteralFlags[NumericLiteralFlags["All"] = 15] = "All"; + })(NumericLiteralFlags = ts.NumericLiteralFlags || (ts.NumericLiteralFlags = {})); + function getNumericLiteralFlags(text, hint) { + if (text.length > 1) { switch (text.charCodeAt(1)) { case 98: case 66: + return 2; case 111: case 79: - return true; + return 4; + case 120: + case 88: + return 1; + } + if (hint & 8) { + for (var i = text.length - 1; i >= 0; i--) { + switch (text.charCodeAt(i)) { + case 101: + case 69: + return 8; + } + } } } - return false; + return 0; } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + ts.getNumericLiteralFlags = getNumericLiteralFlags; function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; } @@ -7148,10 +8074,6 @@ var ts; 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, "_"); } @@ -7163,11 +8085,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 223 && node.parent.kind === 256; + return node.kind === 225 && node.parent.kind === 259; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 230 && + return node && node.kind === 232 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -7176,11 +8098,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node.kind === 230 && (!node.body); + return node && node.kind === 232 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 261 || - node.kind === 230 || + return node.kind === 264 || + node.kind === 232 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -7193,9 +8115,9 @@ var ts; return false; } switch (node.parent.kind) { - case 261: + case 264: return ts.isExternalModule(node.parent); - case 231: + case 233: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -7207,22 +8129,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 261: + case 264: + case 234: + case 259: case 232: - case 256: - case 230: - case 211: - case 212: case 213: - case 150: - case 149: + case 214: + case 215: case 151: + case 150: case 152: - case 225: - case 184: + case 153: + case 227: case 185: + case 186: return true; - case 204: + case 206: return parentNode && !isFunctionLike(parentNode); } return false; @@ -7249,7 +8171,7 @@ var ts; case 9: case 8: return name.text; - case 142: + case 143: if (isStringOrNumericLiteral(name.expression)) { return name.expression.text; } @@ -7260,10 +8182,10 @@ var ts; function entityNameToString(name) { switch (name.kind) { case 70: - return getFullWidth(name) === 0 ? unescapeIdentifier(name.text) : getTextOfNode(name); - case 141: + return getFullWidth(name) === 0 ? ts.unescapeIdentifier(name.text) : getTextOfNode(name); + case 142: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 177: + case 178: return entityNameToString(name.expression) + "." + entityNameToString(name.name); } } @@ -7300,7 +8222,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 204) { + if (node.body && node.body.kind === 206) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -7312,29 +8234,29 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 261: + case 264: 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 223: - case 174: - case 226: - case 197: - case 227: - case 230: - case 229: - case 260: case 225: - case 184: - case 149: - case 151: - case 152: + case 175: case 228: + case 198: + case 229: + case 232: + case 231: + case 263: + case 227: + case 185: + case 150: + case 152: + case 153: + case 230: errorNode = node.name; break; - case 185: + case 186: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -7355,7 +8277,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 229 && isConst(node); + return node.kind === 231 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -7368,11 +8290,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 179 && n.expression.kind === 96; + return n.kind === 180 && n.expression.kind === 96; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 207 + return node.kind === 209 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; @@ -7385,10 +8307,10 @@ var ts; } ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 144 || - node.kind === 143 || - node.kind === 184 || - node.kind === 185) ? + var commentRanges = (node.kind === 145 || + node.kind === 144 || + node.kind === 185 || + node.kind === 186) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, function (comment) { @@ -7402,96 +8324,110 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (156 <= node.kind && node.kind <= 171) { + if (157 <= node.kind && node.kind <= 172) { return true; } switch (node.kind) { case 118: case 132: - case 134: - case 121: case 135: - case 137: + case 121: + case 136: + case 138: case 129: return true; case 104: - return node.parent.kind !== 188; - case 199: + return node.parent.kind !== 189; + case 200: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 70: - if (node.parent.kind === 141 && node.parent.right === node) { + if (node.parent.kind === 142 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 177 && node.parent.name === node) { + else if (node.parent.kind === 178 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 70 || node.kind === 141 || node.kind === 177, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 141: - case 177: + ts.Debug.assert(node.kind === 70 || node.kind === 142 || node.kind === 178, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 142: + case 178: case 98: - var parent_1 = node.parent; - if (parent_1.kind === 160) { + var parent = node.parent; + if (parent.kind === 161) { return false; } - if (156 <= parent_1.kind && parent_1.kind <= 171) { + if (157 <= parent.kind && parent.kind <= 172) { return true; } - switch (parent_1.kind) { - case 199: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 143: - return node === parent_1.constraint; - case 147: - case 146: + switch (parent.kind) { + case 200: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 144: - case 223: - return node === parent_1.type; + return node === parent.constraint; + case 148: + case 147: + case 145: case 225: - case 184: + return node === parent.type; + case 227: case 185: + case 186: + case 151: case 150: case 149: - case 148: - case 151: case 152: - return node === parent_1.type; case 153: + return node === parent.type; case 154: case 155: - return node === parent_1.type; - case 182: - return node === parent_1.type; - case 179: + case 156: + return node === parent.type; + case 183: + return node === parent.type; case 180: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 181: + return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; + case 182: return false; } } return false; } ts.isPartOfTypeNode = isPartOfTypeNode; + function isChildOfNodeWithKind(node, kind) { + while (node) { + if (node.kind === kind) { + return true; + } + node = node.parent; + } + return false; + } + ts.isChildOfNodeWithKind = isChildOfNodeWithKind; + function isPrefixUnaryExpression(node) { + return node.kind === 191; + } + ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 216: + case 218: return visitor(node); - case 232: - case 204: - case 208: - case 209: + case 234: + case 206: case 210: case 211: case 212: case 213: - case 217: - case 218: - case 253: - case 254: + case 214: + case 215: case 219: - case 221: + case 220: case 256: + case 257: + case 221: + case 223: + case 259: return ts.forEachChild(node, traverse); } } @@ -7501,24 +8437,24 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 195: + case 196: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } + case 231: case 229: - case 227: + case 232: case 230: case 228: - case 226: - case 197: + case 198: return; default: if (isFunctionLike(node)) { - var name_7 = node.name; - if (name_7 && name_7.kind === 142) { - traverse(name_7.expression); + var name = node.name; + if (name && name.kind === 143) { + traverse(name.expression); return; } } @@ -7530,10 +8466,10 @@ var ts; } ts.forEachYieldExpression = forEachYieldExpression; function getRestParameterElementType(node) { - if (node && node.kind === 162) { + if (node && node.kind === 163) { return node.elementType; } - else if (node && node.kind === 157) { + else if (node && node.kind === 158) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -7544,14 +8480,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 174: + case 175: + case 263: + case 145: case 260: - case 144: - case 257: + case 148: case 147: - case 146: - case 258: - case 223: + case 261: + case 225: return true; } } @@ -7559,11 +8495,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 151 || node.kind === 152); + return node && (node.kind === 152 || node.kind === 153); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 226 || node.kind === 197); + return node && (node.kind === 228 || node.kind === 198); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7572,19 +8508,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 150: - case 184: - case 225: - case 185: - case 149: - case 148: case 151: + case 185: + case 227: + case 186: + case 150: + case 149: case 152: case 153: case 154: case 155: - case 158: + case 156: case 159: + case 160: return true; } return false; @@ -7592,13 +8528,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 225: - case 184: + case 153: + case 227: + case 185: return true; } return false; @@ -7606,30 +8542,42 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { + case 213: + case 214: + case 215: case 211: case 212: - case 213: - case 209: - case 210: return true; - case 219: + case 221: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; + function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + while (true) { + if (beforeUnwrapLabelCallback) { + beforeUnwrapLabelCallback(node); + } + if (node.statement.kind !== 221) { + return node.statement; + } + node = node.statement; + } + } + ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; function isFunctionBlock(node) { - return node && node.kind === 204 && isFunctionLike(node.parent); + return node && node.kind === 206 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 149 && node.parent.kind === 176; + return node && node.kind === 150 && node.parent.kind === 177; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 149 && - (node.parent.kind === 176 || - node.parent.kind === 197); + return node.kind === 150 && + (node.parent.kind === 177 || + node.parent.kind === 198); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -7665,44 +8613,57 @@ var ts; return undefined; } switch (node.kind) { - case 142: + case 143: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 145: - if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { + case 146: + if (node.parent.kind === 145 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 185: + case 186: if (!includeArrowFunctions) { continue; } - case 225: - case 184: - case 230: - case 147: - case 146: - case 149: + case 227: + case 185: + case 232: case 148: + case 147: case 150: + case 149: case 151: case 152: case 153: case 154: case 155: - case 229: - case 261: + case 156: + case 231: + case 264: return node; } } } ts.getThisContainer = getThisContainer; + function getNewTargetContainer(node) { + var container = getThisContainer(node, false); + if (container) { + switch (container.kind) { + case 151: + case 227: + case 185: + return container; + } + } + return undefined; + } + ts.getNewTargetContainer = getNewTargetContainer; function getSuperContainer(node, stopOnFunctions) { while (true) { node = node.parent; @@ -7710,25 +8671,25 @@ var ts; return node; } switch (node.kind) { - case 142: + case 143: node = node.parent; break; - case 225: - case 184: + case 227: case 185: + case 186: if (!stopOnFunctions) { continue; } - case 147: - case 146: - case 149: case 148: + case 147: case 150: + case 149: case 151: case 152: + case 153: return node; - case 145: - if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { + case 146: + if (node.parent.kind === 145 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { @@ -7740,36 +8701,36 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 184 || func.kind === 185) { + if (func.kind === 185 || func.kind === 186) { var prev = func; - var parent_2 = func.parent; - while (parent_2.kind === 183) { - prev = parent_2; - parent_2 = parent_2.parent; + var parent = func.parent; + while (parent.kind === 184) { + prev = parent; + parent = parent.parent; } - if (parent_2.kind === 179 && parent_2.expression === prev) { - return parent_2; + if (parent.kind === 180 && parent.expression === prev) { + return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 177 || kind === 178) + return (kind === 178 || kind === 179) && node.expression.kind === 96; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 157: - case 272: + case 158: + case 276: return node.typeName; - case 199: + case 200: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 70: - case 141: + case 142: return node; } return undefined; @@ -7777,10 +8738,12 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 179: + case 250: + case 249: case 180: case 181: - case 145: + case 182: + case 146: return true; default: return false; @@ -7788,29 +8751,32 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 181) { + if (node.kind === 182) { return node.tag; } + else if (isJsxOpeningLikeElement(node)) { + return node.tagName; + } return node.expression; } ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 226: + case 228: return true; - case 147: - return node.parent.kind === 226; - case 151: + case 148: + return node.parent.kind === 228; case 152: - case 149: + case 153: + case 150: return node.body !== undefined - && node.parent.kind === 226; - case 144: + && node.parent.kind === 228; + case 145: return node.parent.body !== undefined - && (node.parent.kind === 150 - || node.parent.kind === 149 - || node.parent.kind === 152) - && node.parent.parent.kind === 226; + && (node.parent.kind === 151 + || node.parent.kind === 150 + || node.parent.kind === 153) + && node.parent.parent.kind === 228; } return false; } @@ -7826,19 +8792,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 226: + case 228: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 149: - case 152: + case 150: + case 153: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 248 || - parent.kind === 247 || - parent.kind === 249) { + if (parent.kind === 250 || + parent.kind === 249 || + parent.kind === 251) { return parent.tagName === node; } return false; @@ -7852,95 +8818,96 @@ var ts; case 100: case 85: case 11: - case 175: case 176: case 177: case 178: case 179: case 180: case 181: - case 200: case 182: case 201: case 183: + case 202: case 184: - case 197: case 185: - case 188: + case 198: case 186: + case 189: case 187: - case 190: + case 188: case 191: case 192: case 193: - case 196: case 194: - case 12: - case 198: - case 246: - case 247: + case 197: case 195: - case 189: + case 12: + case 199: + case 248: + case 249: + case 196: + case 190: + case 203: return true; - case 141: - while (node.parent.kind === 141) { + case 142: + while (node.parent.kind === 142) { node = node.parent; } - return node.parent.kind === 160 || isJSXTagName(node); + return node.parent.kind === 161 || isJSXTagName(node); case 70: - if (node.parent.kind === 160 || isJSXTagName(node)) { + if (node.parent.kind === 161 || isJSXTagName(node)) { return true; } case 8: case 9: case 98: - var parent_3 = node.parent; - switch (parent_3.kind) { - case 223: - case 144: + var parent = node.parent; + switch (parent.kind) { + case 225: + case 145: + case 148: case 147: - case 146: + case 263: case 260: - case 257: - case 174: - return parent_3.initializer === node; - case 207: - case 208: + case 175: + return parent.initializer === node; case 209: case 210: - case 216: - case 217: - case 218: - case 253: - case 220: - case 218: - return parent_3.expression === node; case 211: - var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 224) || + case 212: + case 218: + case 219: + case 220: + case 256: + case 222: + case 220: + return parent.expression === node; + case 213: + var forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== 226) || forStatement.condition === node || forStatement.incrementor === node; - case 212: - case 213: - var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224) || + case 214: + case 215: + var forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 226) || forInStatement.expression === node; - case 182: - case 200: - return node === parent_3.expression; - case 202: - return node === parent_3.expression; - case 142: - return node === parent_3.expression; - case 145: - case 252: - case 251: - case 259: + case 183: + case 201: + return node === parent.expression; + case 204: + return node === parent.expression; + case 143: + return node === parent.expression; + case 146: + case 255: + case 254: + case 262: return true; - case 199: - return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); + case 200: + return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: - if (isPartOfExpression(parent_3)) { + if (isPartOfExpression(parent)) { return true; } } @@ -7955,7 +8922,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 && node.moduleReference.kind === 245; + return node.kind === 236 && node.moduleReference.kind === 247; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7964,7 +8931,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 && node.moduleReference.kind !== 245; + return node.kind === 236 && node.moduleReference.kind !== 247; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7976,7 +8943,7 @@ var ts; } ts.isInJavaScriptFile = isInJavaScriptFile; function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 179 && + var isRequire = expression.kind === 180 && expression.expression.kind === 70 && expression.expression.text === "require" && expression.arguments.length === 1; @@ -7988,9 +8955,9 @@ var ts; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 223) { + if (s.valueDeclaration && s.valueDeclaration.kind === 225) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 184; + return declaration.initializer && declaration.initializer.kind === 185; } return false; } @@ -7999,11 +8966,11 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0; } - if (expression.kind !== 192) { + if (expression.kind !== 193) { return 0; } var expr = expression; - if (expr.operatorToken.kind !== 57 || expr.left.kind !== 177) { + if (expr.operatorToken.kind !== 57 || expr.left.kind !== 178) { return 0; } var lhs = expr.left; @@ -8019,7 +8986,7 @@ var ts; else if (lhs.expression.kind === 98) { return 4; } - else if (lhs.expression.kind === 177) { + else if (lhs.expression.kind === 178) { var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 70) { var innerPropertyAccessIdentifier = innerPropertyAccess.expression; @@ -8035,35 +9002,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 235) { + if (node.kind === 237) { return node.moduleSpecifier; } - if (node.kind === 234) { + if (node.kind === 236) { var reference = node.moduleReference; - if (reference.kind === 245) { + if (reference.kind === 247) { return reference.expression; } } - if (node.kind === 241) { + if (node.kind === 243) { return node.moduleSpecifier; } - if (node.kind === 230 && node.name.kind === 9) { + if (node.kind === 232 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 234) { + if (node.kind === 236) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 239) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 235 + return node.kind === 237 && node.importClause && !!node.importClause.name; } @@ -8071,13 +9038,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 144: + case 145: + case 150: case 149: + case 261: + case 260: case 148: - case 258: - case 257: case 147: - case 146: return node.questionToken !== undefined; } } @@ -8085,22 +9052,27 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 274 && + return node.kind === 278 && node.parameters.length > 0 && - node.parameters[0].type.kind === 276; + node.parameters[0].type.kind === 280; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { return ts.map(getJSDocs(node), function (doc) { return doc.comment; }); } ts.getCommentsFromJSDoc = getCommentsFromJSDoc; + function hasJSDocParameterTags(node) { + var parameterTags = getJSDocTags(node, 285); + return parameterTags && parameterTags.length > 0; + } + ts.hasJSDocParameterTags = hasJSDocParameterTags; function getJSDocTags(node, kind) { var docs = getJSDocs(node); if (docs) { var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 281) { + if (doc.kind === 285) { if (doc.kind === kind) { result.push(doc); } @@ -8126,9 +9098,9 @@ var ts; var parent = node.parent; var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 205; + parent.parent.parent.kind === 207; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 205; + parent.parent.kind === 207; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -8136,19 +9108,19 @@ var ts; getJSDocsWorker(variableStatementNode); } var isSourceOfAssignmentExpressionStatement = parent && parent.parent && - parent.kind === 192 && + parent.kind === 193 && parent.operatorToken.kind === 57 && - parent.parent.kind === 207; + parent.parent.kind === 209; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 230 && - parent && parent.kind === 230; - var isPropertyAssignmentExpression = parent && parent.kind === 257; + var isModuleDeclaration = node.kind === 232 && + parent && parent.kind === 232; + var isPropertyAssignmentExpression = parent && parent.kind === 260; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } - if (node.kind === 144) { + if (node.kind === 145) { cache = ts.concatenate(cache, getJSDocParameterTags(node)); } if (isVariableLike(node) && node.initializer) { @@ -8162,17 +9134,17 @@ var ts; return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 281); + var tags = getJSDocTags(func, 285); if (!param.name) { var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 281; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 285; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70) { - var name_8 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 281 && tag.parameterName.text === name_8; }); + var name_1 = param.name.text; + return ts.filter(tags, function (tag) { return tag.kind === 285 && tag.parameterName.text === name_1; }); } else { return undefined; @@ -8180,8 +9152,8 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 283); - if (!tag && node.kind === 144) { + var tag = getFirstJSDocTag(node, 287); + if (!tag && node.kind === 145) { var paramTags = getJSDocParameterTags(node); if (paramTags) { tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); @@ -8191,15 +9163,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 280); + return getFirstJSDocTag(node, 284); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 282); + return getFirstJSDocTag(node, 286); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 284); + return getFirstJSDocTag(node, 288); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -8212,8 +9184,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536)) { - if (node.type && node.type.kind === 275 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275; })) { + if (node.type && node.type.kind === 279 || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 279; })) { return true; } } @@ -8224,32 +9196,43 @@ var ts; return node && node.dotDotDotToken !== undefined; } ts.isDeclaredRestParam = isDeclaredRestParam; + var AssignmentKind; + (function (AssignmentKind) { + AssignmentKind[AssignmentKind["None"] = 0] = "None"; + AssignmentKind[AssignmentKind["Definite"] = 1] = "Definite"; + AssignmentKind[AssignmentKind["Compound"] = 2] = "Compound"; + })(AssignmentKind = ts.AssignmentKind || (ts.AssignmentKind = {})); function getAssignmentTargetKind(node) { var parent = node.parent; while (true) { switch (parent.kind) { - case 192: + case 193: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 57 ? 1 : 2 : 0; - case 190: case 191: + case 192: var unaryOperator = parent.operator; return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; - case 212: - case 213: + case 214: + case 215: return parent.initializer === node ? 1 : 0; - case 183: - case 175: - case 196: + case 184: + case 176: + case 197: node = parent; break; - case 258: + case 261: if (parent.name !== node) { return 0; } - case 257: + node = parent.parent; + break; + case 260: + if (parent.name === node) { + return 0; + } node = parent.parent; break; default: @@ -8263,6 +9246,17 @@ var ts; return getAssignmentTargetKind(node) !== 0; } ts.isAssignmentTarget = isAssignmentTarget; + function isDeleteTarget(node) { + if (node.kind !== 178 && node.kind !== 179) { + return false; + } + node = node.parent; + while (node && node.kind === 184) { + node = node.parent; + } + return node && node.kind === 187; + } + ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { while (node) { if (node === ancestor) @@ -8274,7 +9268,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2) || (node.kind === 261 && node.isDeclarationFile)) { + if (hasModifier(node, 2) || (node.kind === 264 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -8287,7 +9281,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 239 || parent.kind === 243) { + if (parent.kind === 241 || parent.kind === 245) { if (parent.propertyName) { return true; } @@ -8300,48 +9294,48 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 142 && + node.parent.kind === 143 && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 147: - case 146: - case 149: case 148: - case 151: + case 147: + case 150: + case 149: case 152: + case 153: + case 263: case 260: - case 257: - case 177: + case 178: return parent.name === node; - case 141: + case 142: if (parent.right === node) { - while (parent.kind === 141) { + while (parent.kind === 142) { parent = parent.parent; } - return parent.kind === 160; + return parent.kind === 161; } return false; - case 174: - case 239: + case 175: + case 241: return parent.propertyName === node; - case 243: + case 245: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 234 || - node.kind === 233 || - node.kind === 236 && !!node.name || - node.kind === 237 || + return node.kind === 236 || + node.kind === 235 || + node.kind === 238 && !!node.name || node.kind === 239 || - node.kind === 243 || - node.kind === 240 && exportAssignmentIsAlias(node); + node.kind === 241 || + node.kind === 245 || + node.kind === 242 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8427,7 +9421,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 71 <= token && token <= 140; + return 71 <= token && token <= 141; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -8449,7 +9443,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 142 && + return name.kind === 143 && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -8459,10 +9453,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 144) { + if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 145) { return name.text; } - if (name.kind === 142) { + if (name.kind === 143) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -8507,11 +9501,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 144; + return root.kind === 145; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 174) { + while (node.kind === 175) { node = node.parent.parent; } return node; @@ -8519,15 +9513,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 150 - || kind === 184 - || kind === 225 + return kind === 151 || kind === 185 - || kind === 149 - || kind === 151 + || kind === 227 + || kind === 186 + || kind === 150 || kind === 152 - || kind === 230 - || kind === 261; + || kind === 153 + || kind === 232 + || kind === 264; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -8535,66 +9529,49 @@ var ts; || ts.positionIsSynthesized(node.end); } ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node, nodeTest) { - if (node) { - while (node.original !== undefined) { - node = node.original; - } + function getOriginalSourceFileOrBundle(sourceFileOrBundle) { + if (sourceFileOrBundle.kind === 265) { + return ts.updateBundle(sourceFileOrBundle, ts.sameMap(sourceFileOrBundle.sourceFiles, getOriginalSourceFile)); } - return !nodeTest || nodeTest(node) ? node : undefined; + return getOriginalSourceFile(sourceFileOrBundle); } - ts.getOriginalNode = getOriginalNode; - function isParseTreeNode(node) { - return (node.flags & 8) === 0; + ts.getOriginalSourceFileOrBundle = getOriginalSourceFileOrBundle; + function getOriginalSourceFile(sourceFile) { + return ts.getParseTreeNode(sourceFile, isSourceFile) || sourceFile; } - ts.isParseTreeNode = isParseTreeNode; - function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { - return node; - } - node = getOriginalNode(node); - if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { - return node; - } - return undefined; - } - ts.getParseTreeNode = getParseTreeNode; function getOriginalSourceFiles(sourceFiles) { - var originalSourceFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); - if (originalSourceFile) { - originalSourceFiles.push(originalSourceFile); - } - } - return originalSourceFiles; + return ts.sameMap(sourceFiles, getOriginalSourceFile); } ts.getOriginalSourceFiles = getOriginalSourceFiles; function getOriginalNodeId(node) { - node = getOriginalNode(node); + node = ts.getOriginalNode(node); return node ? ts.getNodeId(node) : 0; } ts.getOriginalNodeId = getOriginalNodeId; + var Associativity; + (function (Associativity) { + Associativity[Associativity["Left"] = 0] = "Left"; + Associativity[Associativity["Right"] = 1] = "Right"; + })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 180 && expression.arguments !== undefined; + var hasArguments = expression.kind === 181 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 180: + case 181: return hasArguments ? 0 : 1; - case 190: - case 187: + case 191: case 188: - case 186: case 189: - case 193: - case 195: + case 187: + case 190: + case 194: + case 196: return 1; - case 192: + case 193: switch (operator) { case 39: case 57: @@ -8618,15 +9595,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 180 && expression.arguments !== undefined; + var hasArguments = expression.kind === 181 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 192) { + if (expression.kind === 193) { return expression.operatorToken.kind; } - else if (expression.kind === 190 || expression.kind === 191) { + else if (expression.kind === 191 || expression.kind === 192) { return expression.operator; } else { @@ -8644,37 +9621,36 @@ var ts; case 85: case 8: case 9: - case 175: case 176: - case 184: + case 177: case 185: - case 197: - case 246: - case 247: + case 186: + case 198: + case 248: + case 249: case 11: case 12: - case 194: - case 183: - case 198: - case 297: + case 195: + case 184: + case 199: return 19; - case 181: - case 177: + case 182: case 178: - return 18; - case 180: - return hasArguments ? 18 : 17; case 179: + return 18; + case 181: + return hasArguments ? 18 : 17; + case 180: return 17; - case 191: - return 16; - case 190: - case 187: - case 188: - case 186: - case 189: - return 15; case 192: + return 16; + case 191: + case 188: + case 189: + case 187: + case 190: + return 15; + case 193: switch (operatorKind) { case 50: case 51: @@ -8732,11 +9708,11 @@ var ts; default: return -1; } - case 193: + case 194: return 4; - case 195: - return 2; case 196: + return 2; + case 197: return 1; default: return -1; @@ -8759,21 +9735,15 @@ var ts; 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; - } + ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); } function add(diagnostic) { var diagnostics; if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); if (!diagnostics) { diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; + fileDiagnostics.set(diagnostic.file.fileName, diagnostics); } } else { @@ -8790,16 +9760,16 @@ var ts; function getDiagnostics(fileName) { sortAndDeduplicate(); if (fileName) { - return fileDiagnostics[fileName] || []; + return fileDiagnostics.get(fileName) || []; } var allDiagnostics = []; function pushDiagnostic(d) { allDiagnostics.push(d); } ts.forEach(nonFileDiagnostics, pushDiagnostic); - for (var key in fileDiagnostics) { - ts.forEach(fileDiagnostics[key], pushDiagnostic); - } + fileDiagnostics.forEach(function (diagnostics) { + ts.forEach(diagnostics, pushDiagnostic); + }); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function sortAndDeduplicate() { @@ -8808,14 +9778,14 @@ var ts; } diagnosticsModified = false; nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (var key in fileDiagnostics) { - fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } + fileDiagnostics.forEach(function (diagnostics, key) { + fileDiagnostics.set(key, ts.sortAndDeduplicateDiagnostics(diagnostics)); + }); } } ts.createDiagnosticCollection = createDiagnosticCollection; var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = ts.createMap({ + var escapedCharsMap = ts.createMapFromTemplate({ "\0": "\\0", "\t": "\\t", "\v": "\\v", @@ -8830,13 +9800,12 @@ var ts; "\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)); - } + return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; + function getReplacement(c) { + return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } function isIntrinsicJsxName(name) { var ch = name.substr(0, 1); return ch.toLowerCase() === ch; @@ -8979,129 +9948,62 @@ var ts; ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); + var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); }; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); - var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = getAllEmittableSourceFiles(); - return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); + var moduleEmitEnabled_1 = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; + return ts.filter(host.getSourceFiles(), function (sourceFile) { + return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); + }); } else { - var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; - return filterSourceFilesInDirectory(sourceFiles, function (file) { return host.isSourceFileFromExternalLibrary(file); }); - } - function getAllEmittableSourceFiles() { - return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); + var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); }); } } ts.getSourceFilesToEmit = getSourceFilesToEmit; - function filterSourceFilesInDirectory(sourceFiles, isSourceFileFromExternalLibrary) { - return ts.filter(sourceFiles, function (file) { return shouldEmitInDirectory(file, isSourceFileFromExternalLibrary); }); + function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary) { + return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !isDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); } - ts.filterSourceFilesInDirectory = filterSourceFilesInDirectory; - function isNonDeclarationFile(sourceFile) { - return !isDeclarationFile(sourceFile); - } - function shouldEmitInDirectory(sourceFile, isSourceFileFromExternalLibrary) { - return isNonDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); - } - function isBundleEmitNonExternalModule(sourceFile) { - return isNonDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); - } - function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { + ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { - onBundledEmit(sourceFiles); - } - else { - for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { - var sourceFile = sourceFiles_2[_i]; - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } - } - } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); - } - function onBundledEmit(sourceFiles) { if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, true); + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, ts.createBundle(sourceFiles), emitOnlyDtsFiles); + } + } + else { + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, sourceFile, emitOnlyDtsFiles); } } } - ts.forEachTransformedEmitFile = forEachTransformedEmitFile; + ts.forEachEmittedFile = forEachEmittedFile; function getSourceMapFilePath(jsFilePath, options) { return options.sourceMap ? jsFilePath + ".map" : undefined; } - function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - onBundledEmit(host); - } - else { - var sourceFiles = targetSourceFile === undefined ? getSourceFilesToEmit(host) : [targetSourceFile]; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; - if (shouldEmitInDirectory(sourceFile, function (file) { return host.isSourceFileFromExternalLibrary(file); })) { - onSingleFileEmit(host, sourceFile); + function getOutputExtension(sourceFile, options) { + if (options.jsx === 1) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + return ".jsx"; } } - } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: declarationFilePath - }; - action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); - } - function onBundledEmit(host) { - var bundledSources = ts.filter(getSourceFilesToEmit(host), function (sourceFile) { return !isDeclarationFile(sourceFile) && - !host.isSourceFileFromExternalLibrary(sourceFile) && - (!ts.isExternalModule(sourceFile) || - !!ts.getEmitModuleKind(options)); }); - if (bundledSources.length) { - var jsFilePath = options.outFile || options.out; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined - }; - action(emitFileNames, bundledSources, true, emitOnlyDtsFiles); + else if (sourceFile.languageVariant === 1) { + return ".jsx"; } } + return ".js"; } - ts.forEachExpectedEmitFile = forEachExpectedEmitFile; function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); var commonSourceDirectory = host.getCommonSourceDirectory(); @@ -9126,7 +10028,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 150 && nodeIsPresent(member.body)) { + if (member.kind === 151 && nodeIsPresent(member.body)) { return member; } }); @@ -9167,10 +10069,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 151) { + if (accessor.kind === 152) { getAccessor = accessor; } - else if (accessor.kind === 152) { + else if (accessor.kind === 153) { setAccessor = accessor; } else { @@ -9179,7 +10081,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 151 || member.kind === 152) + if ((member.kind === 152 || member.kind === 153) && hasModifier(member, 32) === hasModifier(accessor, 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -9190,10 +10092,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 151 && !getAccessor) { + if (member.kind === 152 && !getAccessor) { getAccessor = member; } - if (member.kind === 152 && !setAccessor) { + if (member.kind === 153 && !setAccessor) { setAccessor = member; } } @@ -9411,7 +10313,7 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 199 && + if (node.kind === 200 && node.parent.token === 84 && isClassLike(node.parent.parent)) { return node.parent.parent; @@ -9429,8 +10331,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, true)) { var kind = node.left.kind; - return kind === 176 - || kind === 175; + return kind === 177 + || kind === 176; } return false; } @@ -9456,29 +10358,33 @@ var ts; ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { return node.kind === 70 || - node.kind === 177 && isEntityNameExpression(node.expression); + node.kind === 178 && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 141 && node.parent.right === node) || - (node.parent.kind === 177 && node.parent.name === node); + return (node.parent.kind === 142 && node.parent.right === node) || + (node.parent.kind === 178 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 176) { + if (kind === 177) { return expression.properties.length === 0; } - if (kind === 175) { + if (kind === 176) { return expression.elements.length === 0; } return false; } ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512) ? symbol.valueDeclaration.localSymbol : undefined; + return isExportDefaultSymbol(symbol) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function isExportDefaultSymbol(symbol) { + return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512); + } + ts.isExportDefaultSymbol = isExportDefaultSymbol; function tryExtractTypeScriptExtension(fileName) { return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); } @@ -9570,39 +10476,39 @@ var ts; || kind === 94) { return true; } - else if (kind === 177) { + else if (kind === 178) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 178) { + else if (kind === 179) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 190 - || kind === 191) { + else if (kind === 191 + || kind === 192) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 192) { + else if (kind === 193) { return node.operatorToken.kind !== 39 && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 193) { + else if (kind === 194) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 188 - || kind === 187 - || kind === 186) { + else if (kind === 189 + || kind === 188 + || kind === 187) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 175) { + else if (kind === 176) { return node.elements.length === 0; } - else if (kind === 176) { + else if (kind === 177) { return node.properties.length === 0; } - else if (kind === 179) { + else if (kind === 180) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9617,16 +10523,19 @@ var ts; } return false; } - var syntaxKindCache = ts.createMap(); + var syntaxKindCache = []; function formatSyntaxKind(kind) { var syntaxKindEnum = ts.SyntaxKind; if (syntaxKindEnum) { - if (syntaxKindCache[kind]) { - return syntaxKindCache[kind]; + var cached = syntaxKindCache[kind]; + if (cached !== undefined) { + return cached; } - for (var name_9 in syntaxKindEnum) { - if (syntaxKindEnum[name_9] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_9 + ")"; + for (var name in syntaxKindEnum) { + if (syntaxKindEnum[name] === kind) { + var result = kind + " (" + name + ")"; + syntaxKindCache[kind] = result; + return result; } } } @@ -9635,6 +10544,14 @@ var ts; } } ts.formatSyntaxKind = formatSyntaxKind; + function getRangePos(range) { + return range ? range.pos : -1; + } + ts.getRangePos = getRangePos; + function getRangeEnd(range) { + return range ? range.end : -1; + } + ts.getRangeEnd = getRangeEnd; function movePos(pos, value) { return ts.positionIsSynthesized(pos) ? -1 : pos + value; } @@ -9709,11 +10626,11 @@ var ts; } ts.getStartPositionOfRange = getStartPositionOfRange; function isDeclarationNameOfEnumOrNamespace(node) { - var parseNode = getParseTreeNode(node); + var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 229: - case 230: + case 231: + case 232: return parseNode === parseNode.parent.name; } } @@ -9731,7 +10648,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 && declaration !== node) { + if (declaration.kind === 228 && declaration !== node) { return true; } } @@ -9782,6 +10699,10 @@ var ts; return node.kind === 70; } ts.isIdentifier = isIdentifier; + function isVoidExpression(node) { + return node.kind === 189; + } + ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { return isIdentifier(node) && node.autoGenerateKind > 0; } @@ -9791,16 +10712,16 @@ var ts; } ts.isModifier = isModifier; function isQualifiedName(node) { - return node.kind === 141; + return node.kind === 142; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 142; + return node.kind === 143; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 141 + return kind === 142 || kind === 70; } ts.isEntityName = isEntityName; @@ -9809,7 +10730,7 @@ var ts; return kind === 70 || kind === 9 || kind === 8 - || kind === 142; + || kind === 143; } ts.isPropertyName = isPropertyName; function isModuleName(node) { @@ -9821,101 +10742,101 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 70 - || kind === 172 - || kind === 173; + || kind === 173 + || kind === 174; } ts.isBindingName = isBindingName; function isTypeParameter(node) { - return node.kind === 143; + return node.kind === 144; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 144; + return node.kind === 145; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 145; + return node.kind === 146; } ts.isDecorator = isDecorator; function isMethodDeclaration(node) { - return node.kind === 149; + return node.kind === 150; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 150 - || kind === 147 - || kind === 149 - || kind === 151 + return kind === 151 + || kind === 148 + || kind === 150 || kind === 152 - || kind === 155 - || kind === 203; + || kind === 153 + || kind === 156 + || kind === 205; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 257 - || kind === 258 - || kind === 259 - || kind === 149 - || kind === 151 + return kind === 260 + || kind === 261 + || kind === 262 + || kind === 150 || kind === 152 - || kind === 244; + || kind === 153 + || kind === 246; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 156 && kind <= 171) + return (kind >= 157 && kind <= 172) || kind === 118 || kind === 132 || kind === 121 - || kind === 134 || kind === 135 + || kind === 136 || kind === 104 || kind === 129 - || kind === 199; + || kind === 200; } function isTypeNode(node) { return isTypeNodeKind(node.kind); } ts.isTypeNode = isTypeNode; function isArrayBindingPattern(node) { - return node.kind === 173; + return node.kind === 174; } ts.isArrayBindingPattern = isArrayBindingPattern; function isObjectBindingPattern(node) { - return node.kind === 172; + return node.kind === 173; } ts.isObjectBindingPattern = isObjectBindingPattern; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 173 - || kind === 172; + return kind === 174 + || kind === 173; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 175 - || kind === 176; + return kind === 176 + || kind === 177; } ts.isAssignmentPattern = isAssignmentPattern; function isBindingElement(node) { - return node.kind === 174; + return node.kind === 175; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 174 - || kind === 198; + return kind === 175 + || kind === 199; } ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 223: - case 144: - case 174: + case 225: + case 145: + case 175: return true; } return false; @@ -9928,8 +10849,8 @@ var ts; ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 172: - case 176: + case 173: + case 177: return true; } return false; @@ -9937,94 +10858,94 @@ var ts; ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 173: - case 175: + case 174: + case 176: return true; } return false; } ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; function isArrayLiteralExpression(node) { - return node.kind === 175; + return node.kind === 176; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 176; + return node.kind === 177; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 177; + return node.kind === 178; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 178; + return node.kind === 179; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 192; + return node.kind === 193; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 193; + return node.kind === 194; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 179; + return node.kind === 180; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 194 + return kind === 195 || kind === 12; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadExpression(node) { - return node.kind === 196; + return node.kind === 197; } ts.isSpreadExpression = isSpreadExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 199; + return node.kind === 200; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 177 - || kind === 178 - || kind === 180 + return kind === 178 || kind === 179 - || kind === 246 - || kind === 247 || kind === 181 - || kind === 175 - || kind === 183 + || kind === 180 + || kind === 248 + || kind === 249 + || kind === 182 || kind === 176 - || kind === 197 || kind === 184 + || kind === 177 + || kind === 198 + || kind === 185 || kind === 70 || kind === 11 || kind === 8 || kind === 9 || kind === 12 - || kind === 194 + || kind === 195 || kind === 85 || kind === 94 || kind === 98 || kind === 100 || kind === 96 - || kind === 201 - || kind === 297; + || kind === 202 + || kind === 203; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 190 - || kind === 191 - || kind === 186 + return kind === 191 + || kind === 192 || kind === 187 || kind === 188 || kind === 189 - || kind === 182 + || kind === 190 + || kind === 183 || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -10032,14 +10953,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 193 - || kind === 195 - || kind === 185 - || kind === 192 + return kind === 194 || kind === 196 - || kind === 200 - || kind === 198 - || kind === 297 + || kind === 186 + || kind === 193 + || kind === 197 + || kind === 201 + || kind === 199 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -10048,16 +10968,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 182 - || kind === 200; + return kind === 183 + || kind === 201; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 294; + return node.kind === 298; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 293; + return node.kind === 297; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10066,15 +10986,15 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 198; + return node.kind === 199; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 202; + return node.kind === 204; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 204; + return node.kind === 206; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -10092,121 +11012,135 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 223; + return node.kind === 225; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 224; + return node.kind === 226; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 232; + return node.kind === 234; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 231 - || kind === 230; + return kind === 233 + || kind === 232 + || kind === 70; } ts.isModuleBody = isModuleBody; + function isNamespaceBody(node) { + var kind = node.kind; + return kind === 233 + || kind === 232; + } + ts.isNamespaceBody = isNamespaceBody; + function isJSDocNamespaceBody(node) { + var kind = node.kind; + return kind === 70 + || kind === 232; + } + ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isImportEqualsDeclaration(node) { - return node.kind === 234; + return node.kind === 236; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 236; + return node.kind === 238; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 238 - || kind === 237; + return kind === 240 + || kind === 239; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 239; + return node.kind === 241; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 242; + return node.kind === 244; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 243; + return node.kind === 245; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 230 || node.kind === 229; + return node.kind === 232 || node.kind === 231; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 185 - || kind === 174 - || kind === 226 - || kind === 197 - || kind === 150 - || kind === 229 - || kind === 260 - || kind === 243 - || kind === 225 - || kind === 184 - || kind === 151 - || kind === 236 - || kind === 234 - || kind === 239 - || kind === 227 - || kind === 149 - || kind === 148 - || kind === 230 - || kind === 233 - || kind === 237 - || kind === 144 - || kind === 257 - || kind === 147 - || kind === 146 - || kind === 152 - || kind === 258 + return kind === 186 + || kind === 175 || kind === 228 - || kind === 143 - || kind === 223 - || kind === 285; + || kind === 198 + || kind === 151 + || kind === 231 + || kind === 263 + || kind === 245 + || kind === 227 + || kind === 185 + || kind === 152 + || kind === 238 + || kind === 236 + || kind === 241 + || kind === 229 + || kind === 252 + || kind === 150 + || kind === 149 + || kind === 232 + || kind === 235 + || kind === 239 + || kind === 145 + || kind === 260 + || kind === 148 + || kind === 147 + || kind === 153 + || kind === 261 + || kind === 230 + || kind === 144 + || kind === 225 + || kind === 289; } function isDeclarationStatementKind(kind) { - return kind === 225 - || kind === 244 - || kind === 226 - || kind === 227 + return kind === 227 + || kind === 246 || kind === 228 || kind === 229 || kind === 230 - || kind === 235 - || kind === 234 - || kind === 241 - || kind === 240 - || kind === 233; + || kind === 231 + || kind === 232 + || kind === 237 + || kind === 236 + || kind === 243 + || kind === 242 + || kind === 235; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 215 - || kind === 214 - || kind === 222 - || kind === 209 - || kind === 207 - || kind === 206 - || kind === 212 - || kind === 213 - || kind === 211 - || kind === 208 - || kind === 219 + return kind === 217 || kind === 216 + || kind === 224 + || kind === 211 + || kind === 209 + || kind === 208 + || kind === 214 + || kind === 215 + || kind === 213 + || kind === 210 + || kind === 221 || kind === 218 || kind === 220 - || kind === 221 - || kind === 205 - || kind === 210 - || kind === 217 - || kind === 293 - || kind === 296 - || kind === 295; + || kind === 222 + || kind === 223 + || kind === 207 + || kind === 212 + || kind === 219 + || kind === 297 + || kind === 300 + || kind === 299; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10224,87 +11158,96 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 204; + || kind === 206; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 245 - || kind === 141 + return kind === 247 + || kind === 142 || kind === 70; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 248; + return node.kind === 250; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 249; + return node.kind === 251; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; return kind === 98 || kind === 70 - || kind === 177; + || kind === 178; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 246 - || kind === 252 - || kind === 247 + return kind === 248 + || kind === 255 + || kind === 249 || kind === 10; } ts.isJsxChild = isJsxChild; + function isJsxAttributes(node) { + var kind = node.kind; + return kind === 253; + } + ts.isJsxAttributes = isJsxAttributes; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 250 - || kind === 251; + return kind === 252 + || kind === 254; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 251; + return node.kind === 254; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 250; + return node.kind === 252; } ts.isJsxAttribute = isJsxAttribute; + function isJsxOpeningLikeElement(node) { + return node.kind === 250 || node.kind === 249; + } + ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 252; + || kind === 255; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 253 - || kind === 254; + return kind === 256 + || kind === 257; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 255; + return node.kind === 258; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 256; + return node.kind === 259; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 257; + return node.kind === 260; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 258; + return node.kind === 261; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isEnumMember(node) { - return node.kind === 260; + return node.kind === 263; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 261; + return node.kind === 264; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -10443,9 +11386,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 143) { + if (d && d.kind === 144) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 227) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 229) { return current; } } @@ -10453,11 +11396,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 150 && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92) && node.parent.kind === 151 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 174 || ts.isBindingPattern(node))) { + while (node && (node.kind === 175 || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10465,14 +11408,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 223) { + if (node.kind === 225) { node = node.parent; } - if (node && node.kind === 224) { + if (node && node.kind === 226) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 205) { + if (node && node.kind === 207) { flags |= ts.getModifierFlags(node); } return flags; @@ -10481,14 +11424,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 223) { + if (node.kind === 225) { node = node.parent; } - if (node && node.kind === 224) { + if (node && node.kind === 226) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 205) { + if (node && node.kind === 207) { flags |= node.flags; } return flags; @@ -10541,24 +11484,46 @@ var ts; } } ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage; + function getOriginalNode(node, nodeTest) { + if (node) { + while (node.original !== undefined) { + node = node.original; + } + } + return !nodeTest || nodeTest(node) ? node : undefined; + } + ts.getOriginalNode = getOriginalNode; + function isParseTreeNode(node) { + return (node.flags & 8) === 0; + } + ts.isParseTreeNode = isParseTreeNode; + function getParseTreeNode(node, nodeTest) { + if (isParseTreeNode(node)) { + return node; + } + node = getOriginalNode(node); + if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { + return node; + } + return undefined; + } + ts.getParseTreeNode = getParseTreeNode; + 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; })(ts || (ts = {})); var ts; (function (ts) { - var NodeConstructor; - var SourceFileConstructor; - function createNode(kind, location, flags) { - var ConstructorForKind = kind === 261 - ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) - : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); - var node = location - ? new ConstructorForKind(kind, location.pos, location.end) - : new ConstructorForKind(kind, -1, -1); - node.flags = flags | 8; + function createSynthesizedNode(kind) { + var node = ts.createNode(kind, -1, -1); + node.flags |= 8; return node; } function updateNode(updated, original) { if (updated !== original) { setOriginalNode(updated, original); + setTextRange(updated, original); if (original.startsOnNewLine) { updated.startsOnNewLine = true; } @@ -10567,7 +11532,7 @@ var ts; return updated; } ts.updateNode = updateNode; - function createNodeArray(elements, location, hasTrailingComma) { + function createNodeArray(elements, hasTrailingComma) { if (elements) { if (ts.isNodeArray(elements)) { return elements; @@ -10577,32 +11542,15 @@ var ts; elements = []; } var array = elements; - if (location) { - array.pos = location.pos; - array.end = location.end; - } - else { - array.pos = -1; - array.end = -1; - } - if (hasTrailingComma) { - array.hasTrailingComma = true; - } + array.pos = -1; + array.end = -1; + array.hasTrailingComma = hasTrailingComma; return array; } ts.createNodeArray = createNodeArray; - function createSynthesizedNode(kind, startsOnNewLine) { - var node = createNode(kind, undefined); - node.startsOnNewLine = startsOnNewLine; - return node; - } - ts.createSynthesizedNode = createSynthesizedNode; - function createSynthesizedNodeArray(elements) { - return createNodeArray(elements, undefined); - } - ts.createSynthesizedNodeArray = createSynthesizedNodeArray; function getSynthesizedClone(node) { - var clone = createNode(node.kind, undefined, node.flags); + var clone = createSynthesizedNode(node.kind); + clone.flags |= node.flags; setOriginalNode(clone, node); for (var key in node) { if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) { @@ -10613,50 +11561,47 @@ var ts; return clone; } ts.getSynthesizedClone = getSynthesizedClone; - function getMutableClone(node) { - var clone = getSynthesizedClone(node); - clone.pos = node.pos; - clone.end = node.end; - clone.parent = node.parent; - return clone; - } - ts.getMutableClone = getMutableClone; - function createLiteral(value, location) { + function createLiteral(value) { if (typeof value === "number") { - var node = createNode(8, location, undefined); - node.text = value.toString(); - return node; + return createNumericLiteral(value + ""); } - else if (typeof value === "boolean") { - return createNode(value ? 100 : 85, location, undefined); + if (typeof value === "boolean") { + return value ? createTrue() : createFalse(); } - else if (typeof value === "string") { - var node = createNode(9, location, undefined); - node.text = value; - return node; - } - else if (value) { - var node = createNode(9, location, undefined); - node.textSourceNode = value; - node.text = value.text; - return node; + if (typeof value === "string") { + return createStringLiteral(value); } + return createLiteralFromNode(value); } ts.createLiteral = createLiteral; - var nextAutoGenerateId = 0; - function createIdentifier(text, location) { - var node = createNode(70, location); + function createNumericLiteral(value) { + var node = createSynthesizedNode(8); + node.text = value; + return node; + } + ts.createNumericLiteral = createNumericLiteral; + function createStringLiteral(text) { + var node = createSynthesizedNode(9); + node.text = text; + return node; + } + function createLiteralFromNode(sourceNode) { + var node = createStringLiteral(sourceNode.text); + node.textSourceNode = sourceNode; + return node; + } + function createIdentifier(text) { + var node = createSynthesizedNode(70); node.text = ts.escapeIdentifier(text); - node.originalKeywordKind = ts.stringToToken(text); + node.originalKeywordKind = text ? ts.stringToToken(text) : 0; node.autoGenerateKind = 0; node.autoGenerateId = 0; return node; } ts.createIdentifier = createIdentifier; - function createTempVariable(recordTempVariable, location) { - var name = createNode(70, location); - name.text = ""; - name.originalKeywordKind = 0; + var nextAutoGenerateId = 0; + function createTempVariable(recordTempVariable) { + var name = createIdentifier(""); name.autoGenerateKind = 1; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; @@ -10666,93 +11611,121 @@ var ts; return name; } ts.createTempVariable = createTempVariable; - function createLoopVariable(location) { - var name = createNode(70, location); - name.text = ""; - name.originalKeywordKind = 0; + function createLoopVariable() { + var name = createIdentifier(""); name.autoGenerateKind = 2; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createLoopVariable = createLoopVariable; - function createUniqueName(text, location) { - var name = createNode(70, location); - name.text = text; - name.originalKeywordKind = 0; + function createUniqueName(text) { + var name = createIdentifier(text); name.autoGenerateKind = 3; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createUniqueName = createUniqueName; - function getGeneratedNameForNode(node, location) { - var name = createNode(70, location); - name.original = node; - name.text = ""; - name.originalKeywordKind = 0; + function getGeneratedNameForNode(node) { + var name = createIdentifier(""); name.autoGenerateKind = 4; name.autoGenerateId = nextAutoGenerateId; + name.original = node; nextAutoGenerateId++; return name; } ts.getGeneratedNameForNode = getGeneratedNameForNode; function createToken(token) { - return createNode(token); + return createSynthesizedNode(token); } ts.createToken = createToken; function createSuper() { - var node = createNode(96); - return node; + return createSynthesizedNode(96); } ts.createSuper = createSuper; - function createThis(location) { - var node = createNode(98, location); - return node; + function createThis() { + return createSynthesizedNode(98); } ts.createThis = createThis; function createNull() { - var node = createNode(94); - return node; + return createSynthesizedNode(94); } ts.createNull = createNull; - function createComputedPropertyName(expression, location) { - var node = createNode(142, location); + function createTrue() { + return createSynthesizedNode(100); + } + ts.createTrue = createTrue; + function createFalse() { + return createSynthesizedNode(85); + } + ts.createFalse = createFalse; + function createQualifiedName(left, right) { + var node = createSynthesizedNode(142); + node.left = left; + node.right = asName(right); + return node; + } + ts.createQualifiedName = createQualifiedName; + function updateQualifiedName(node, left, right) { + return node.left !== left + || node.right !== right + ? updateNode(createQualifiedName(left, right), node) + : node; + } + ts.updateQualifiedName = updateQualifiedName; + function createComputedPropertyName(expression) { + var node = createSynthesizedNode(143); node.expression = expression; return node; } ts.createComputedPropertyName = createComputedPropertyName; function updateComputedPropertyName(node, expression) { - if (node.expression !== expression) { - return updateNode(createComputedPropertyName(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createComputedPropertyName(expression), node) + : node; } ts.updateComputedPropertyName = updateComputedPropertyName; - function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(144, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { + var node = createSynthesizedNode(145); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.questionToken = questionToken; node.type = type; - node.initializer = initializer ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createParameter = createParameter; function updateParameter(node, decorators, modifiers, dotDotDotToken, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) + : node; } ts.updateParameter = updateParameter; - function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(147, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createDecorator(expression) { + var node = createSynthesizedNode(146); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createDecorator = createDecorator; + function updateDecorator(node, expression) { + return node.expression !== expression + ? updateNode(createDecorator(expression), node) + : node; + } + ts.updateDecorator = updateDecorator; + function createProperty(decorators, modifiers, name, questionToken, type, initializer) { + var node = createSynthesizedNode(148); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.questionToken = questionToken; node.type = type; node.initializer = initializer; @@ -10760,19 +11733,22 @@ var ts; } ts.createProperty = createProperty; function updateProperty(node, decorators, modifiers, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer), node) + : node; } ts.updateProperty = updateProperty; - function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(149, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(150); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -10780,16 +11756,21 @@ var ts; } ts.createMethod = createMethod; function updateMethod(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateMethod = updateMethod; - function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(150, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createConstructor(decorators, modifiers, parameters, body) { + var node = createSynthesizedNode(151); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = undefined; @@ -10798,17 +11779,19 @@ var ts; } ts.createConstructor = createConstructor; function updateConstructor(node, decorators, modifiers, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.parameters !== parameters || node.body !== body) { - return updateNode(createConstructor(decorators, modifiers, parameters, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.parameters !== parameters + || node.body !== body + ? updateNode(createConstructor(decorators, modifiers, parameters, body), node) + : node; } ts.updateConstructor = updateConstructor; - function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(151, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createGetAccessor(decorators, modifiers, name, parameters, type, body) { + var node = createSynthesizedNode(152); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = type; @@ -10817,17 +11800,21 @@ var ts; } ts.createGetAccessor = createGetAccessor; function updateGetAccessor(node, decorators, modifiers, name, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body), node) + : node; } ts.updateGetAccessor = updateGetAccessor; - function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(152, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createSetAccessor(decorators, modifiers, name, parameters, body) { + var node = createSynthesizedNode(153); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.body = body; @@ -10835,57 +11822,60 @@ var ts; } ts.createSetAccessor = createSetAccessor; function updateSetAccessor(node, decorators, modifiers, name, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.body !== body) { - return updateNode(createSetAccessor(decorators, modifiers, name, parameters, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.body !== body + ? updateNode(createSetAccessor(decorators, modifiers, name, parameters, body), node) + : node; } ts.updateSetAccessor = updateSetAccessor; - function createObjectBindingPattern(elements, location) { - var node = createNode(172, location); + function createObjectBindingPattern(elements) { + var node = createSynthesizedNode(173); node.elements = createNodeArray(elements); return node; } ts.createObjectBindingPattern = createObjectBindingPattern; function updateObjectBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createObjectBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createObjectBindingPattern(elements), node) + : node; } ts.updateObjectBindingPattern = updateObjectBindingPattern; - function createArrayBindingPattern(elements, location) { - var node = createNode(173, location); + function createArrayBindingPattern(elements) { + var node = createSynthesizedNode(174); node.elements = createNodeArray(elements); return node; } ts.createArrayBindingPattern = createArrayBindingPattern; function updateArrayBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayBindingPattern(elements), node) + : node; } ts.updateArrayBindingPattern = updateArrayBindingPattern; - function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(174, location); - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createBindingElement(propertyName, dotDotDotToken, name, initializer) { + var node = createSynthesizedNode(175); + node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.initializer = initializer; return node; } ts.createBindingElement = createBindingElement; function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) { - if (node.propertyName !== propertyName || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.initializer !== initializer) { - return updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer, node), node); - } - return node; + return node.propertyName !== propertyName + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.initializer !== initializer + ? updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer), node) + : node; } ts.updateBindingElement = updateBindingElement; - function createArrayLiteral(elements, location, multiLine) { - var node = createNode(175, location); - node.elements = parenthesizeListElements(createNodeArray(elements)); + function createArrayLiteral(elements, multiLine) { + var node = createSynthesizedNode(176); + node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; } @@ -10893,14 +11883,13 @@ var ts; } ts.createArrayLiteral = createArrayLiteral; function updateArrayLiteral(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayLiteral(elements, node, node.multiLine), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayLiteral(elements, node.multiLine), node) + : node; } ts.updateArrayLiteral = updateArrayLiteral; - function createObjectLiteral(properties, location, multiLine) { - var node = createNode(176, location); + function createObjectLiteral(properties, multiLine) { + var node = createSynthesizedNode(177); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -10909,108 +11898,118 @@ var ts; } ts.createObjectLiteral = createObjectLiteral; function updateObjectLiteral(node, properties) { - if (node.properties !== properties) { - return updateNode(createObjectLiteral(properties, node, node.multiLine), node); - } - return node; + return node.properties !== properties + ? updateNode(createObjectLiteral(properties, node.multiLine), node) + : node; } ts.updateObjectLiteral = updateObjectLiteral; - function createPropertyAccess(expression, name, location, flags) { - var node = createNode(177, location, flags); - node.expression = parenthesizeForAccess(expression); - (node.emitNode || (node.emitNode = {})).flags |= 65536; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAccess(expression, name) { + var node = createSynthesizedNode(178); + node.expression = ts.parenthesizeForAccess(expression); + node.name = asName(name); + setEmitFlags(node, 65536); return node; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { - if (node.expression !== expression || node.name !== name) { - var propertyAccess = createPropertyAccess(expression, name, node, node.flags); - (propertyAccess.emitNode || (propertyAccess.emitNode = {})).flags = getEmitFlags(node); - return updateNode(propertyAccess, node); - } - return node; + return node.expression !== expression + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccess(expression, name), getEmitFlags(node)), node) + : node; } ts.updatePropertyAccess = updatePropertyAccess; - function createElementAccess(expression, index, location) { - var node = createNode(178, location); - node.expression = parenthesizeForAccess(expression); - node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; + function createElementAccess(expression, index) { + var node = createSynthesizedNode(179); + node.expression = ts.parenthesizeForAccess(expression); + node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { - if (node.expression !== expression || node.argumentExpression !== argumentExpression) { - return updateNode(createElementAccess(expression, argumentExpression, node), node); - } - return node; + return node.expression !== expression + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccess(expression, argumentExpression), node) + : node; } ts.updateElementAccess = updateElementAccess; - function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(179, location, flags); - node.expression = parenthesizeForAccess(expression); - if (typeArguments) { - node.typeArguments = createNodeArray(typeArguments); - } - node.arguments = parenthesizeListElements(createNodeArray(argumentsArray)); + function createCall(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(180); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); return node; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { - if (expression !== node.expression || typeArguments !== node.typeArguments || argumentsArray !== node.arguments) { - return updateNode(createCall(expression, typeArguments, argumentsArray, node, node.flags), node); - } - return node; + return expression !== node.expression + || typeArguments !== node.typeArguments + || argumentsArray !== node.arguments + ? updateNode(createCall(expression, typeArguments, argumentsArray), node) + : node; } ts.updateCall = updateCall; - function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(180, location, flags); - node.expression = parenthesizeForNew(expression); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; + function createNew(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(181); + node.expression = ts.parenthesizeForNew(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; return node; } ts.createNew = createNew; function updateNew(node, expression, typeArguments, argumentsArray) { - if (node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray) { - return updateNode(createNew(expression, typeArguments, argumentsArray, node, node.flags), node); - } - return node; + return node.expression !== expression + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createNew(expression, typeArguments, argumentsArray), node) + : node; } ts.updateNew = updateNew; - function createTaggedTemplate(tag, template, location) { - var node = createNode(181, location); - node.tag = parenthesizeForAccess(tag); + function createTaggedTemplate(tag, template) { + var node = createSynthesizedNode(182); + node.tag = ts.parenthesizeForAccess(tag); node.template = template; return node; } ts.createTaggedTemplate = createTaggedTemplate; function updateTaggedTemplate(node, tag, template) { - if (node.tag !== tag || node.template !== template) { - return updateNode(createTaggedTemplate(tag, template, node), node); - } - return node; + return node.tag !== tag + || node.template !== template + ? updateNode(createTaggedTemplate(tag, template), node) + : node; } ts.updateTaggedTemplate = updateTaggedTemplate; - function createParen(expression, location) { - var node = createNode(183, location); + function createTypeAssertion(type, expression) { + var node = createSynthesizedNode(183); + node.type = type; + node.expression = ts.parenthesizePrefixOperand(expression); + return node; + } + ts.createTypeAssertion = createTypeAssertion; + function updateTypeAssertion(node, type, expression) { + return node.type !== type + || node.expression !== expression + ? updateNode(createTypeAssertion(type, expression), node) + : node; + } + ts.updateTypeAssertion = updateTypeAssertion; + function createParen(expression) { + var node = createSynthesizedNode(184); node.expression = expression; return node; } ts.createParen = createParen; function updateParen(node, expression) { - if (node.expression !== expression) { - return updateNode(createParen(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createParen(expression), node) + : node; } ts.updateParen = updateParen; - function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(184, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(185); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -11018,322 +12017,340 @@ var ts; } ts.createFunctionExpression = createFunctionExpression; function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); - } - return node; + return node.name !== name + || node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionExpression = updateFunctionExpression; - function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(185, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { + var node = createSynthesizedNode(186); + node.modifiers = asNodeArray(modifiers); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35); - node.body = parenthesizeConciseBody(body); + node.body = ts.parenthesizeConciseBody(body); return node; } ts.createArrowFunction = createArrowFunction; function updateArrowFunction(node, modifiers, typeParameters, parameters, type, body) { - if (node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body, node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body), node) + : node; } ts.updateArrowFunction = updateArrowFunction; - function createDelete(expression, location) { - var node = createNode(186, location); - node.expression = parenthesizePrefixOperand(expression); + function createDelete(expression) { + var node = createSynthesizedNode(187); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createDelete = createDelete; function updateDelete(node, expression) { - if (node.expression !== expression) { - return updateNode(createDelete(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createDelete(expression), node) + : node; } ts.updateDelete = updateDelete; - function createTypeOf(expression, location) { - var node = createNode(187, location); - node.expression = parenthesizePrefixOperand(expression); + function createTypeOf(expression) { + var node = createSynthesizedNode(188); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createTypeOf = createTypeOf; function updateTypeOf(node, expression) { - if (node.expression !== expression) { - return updateNode(createTypeOf(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createTypeOf(expression), node) + : node; } ts.updateTypeOf = updateTypeOf; - function createVoid(expression, location) { - var node = createNode(188, location); - node.expression = parenthesizePrefixOperand(expression); + function createVoid(expression) { + var node = createSynthesizedNode(189); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createVoid = createVoid; function updateVoid(node, expression) { - if (node.expression !== expression) { - return updateNode(createVoid(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createVoid(expression), node) + : node; } ts.updateVoid = updateVoid; - function createAwait(expression, location) { - var node = createNode(189, location); - node.expression = parenthesizePrefixOperand(expression); + function createAwait(expression) { + var node = createSynthesizedNode(190); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createAwait = createAwait; function updateAwait(node, expression) { - if (node.expression !== expression) { - return updateNode(createAwait(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createAwait(expression), node) + : node; } ts.updateAwait = updateAwait; - function createPrefix(operator, operand, location) { - var node = createNode(190, location); + function createPrefix(operator, operand) { + var node = createSynthesizedNode(191); node.operator = operator; - node.operand = parenthesizePrefixOperand(operand); + node.operand = ts.parenthesizePrefixOperand(operand); return node; } ts.createPrefix = createPrefix; function updatePrefix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPrefix(node.operator, operand, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPrefix(node.operator, operand), node) + : node; } ts.updatePrefix = updatePrefix; - function createPostfix(operand, operator, location) { - var node = createNode(191, location); - node.operand = parenthesizePostfixOperand(operand); + function createPostfix(operand, operator) { + var node = createSynthesizedNode(192); + node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; } ts.createPostfix = createPostfix; function updatePostfix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPostfix(operand, node.operator, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPostfix(operand, node.operator), node) + : node; } ts.updatePostfix = updatePostfix; - function createBinary(left, operator, right, location) { - var operatorToken = typeof operator === "number" ? createToken(operator) : operator; + function createBinary(left, operator, right) { + var node = createSynthesizedNode(193); + var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; - var node = createNode(192, location); - node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); + node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined); node.operatorToken = operatorToken; - node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); + node.right = ts.parenthesizeBinaryOperand(operatorKind, right, false, node.left); return node; } ts.createBinary = createBinary; function updateBinary(node, left, right) { - if (node.left !== left || node.right !== right) { - return updateNode(createBinary(left, node.operatorToken, right, node), node); - } - return node; + return node.left !== left + || node.right !== right + ? updateNode(createBinary(left, node.operatorToken, right), node) + : node; } ts.updateBinary = updateBinary; - function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonTokenOrLocation, whenFalse, location) { - var node = createNode(193, whenFalse ? location : colonTokenOrLocation); - node.condition = parenthesizeForConditionalHead(condition); - if (whenFalse) { - node.questionToken = questionTokenOrWhenTrue; - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - node.colonToken = colonTokenOrLocation; - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenFalse); - } - else { - node.questionToken = createToken(54); - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(questionTokenOrWhenTrue); - node.colonToken = createToken(55); - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - } + function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { + var node = createSynthesizedNode(194); + node.condition = ts.parenthesizeForConditionalHead(condition); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(54); + node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); + node.colonToken = whenFalse ? colonToken : createToken(55); + node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } ts.createConditional = createConditional; function updateConditional(node, condition, whenTrue, whenFalse) { - if (node.condition !== condition || node.whenTrue !== whenTrue || node.whenFalse !== whenFalse) { - return updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse, node), node); - } - return node; + return node.condition !== condition + || node.whenTrue !== whenTrue + || node.whenFalse !== whenFalse + ? updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse), node) + : node; } ts.updateConditional = updateConditional; - function createTemplateExpression(head, templateSpans, location) { - var node = createNode(194, location); + function createTemplateExpression(head, templateSpans) { + var node = createSynthesizedNode(195); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; } ts.createTemplateExpression = createTemplateExpression; function updateTemplateExpression(node, head, templateSpans) { - if (node.head !== head || node.templateSpans !== templateSpans) { - return updateNode(createTemplateExpression(head, templateSpans, node), node); - } - return node; + return node.head !== head + || node.templateSpans !== templateSpans + ? updateNode(createTemplateExpression(head, templateSpans), node) + : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createYield(asteriskToken, expression, location) { - var node = createNode(195, location); - node.asteriskToken = asteriskToken; - node.expression = expression; + function createYield(asteriskTokenOrExpression, expression) { + var node = createSynthesizedNode(196); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 38 ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 38 ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; function updateYield(node, expression) { - if (node.expression !== expression) { - return updateNode(createYield(node.asteriskToken, expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createYield(node.asteriskToken, expression), node) + : node; } ts.updateYield = updateYield; - function createSpread(expression, location) { - var node = createNode(196, location); - node.expression = parenthesizeExpressionForList(expression); + function createSpread(expression) { + var node = createSynthesizedNode(197); + node.expression = ts.parenthesizeExpressionForList(expression); return node; } ts.createSpread = createSpread; function updateSpread(node, expression) { - if (node.expression !== expression) { - return updateNode(createSpread(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createSpread(expression), node) + : node; } ts.updateSpread = updateSpread; - function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(197, location); + function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(198); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassExpression = createClassExpression; function updateClassExpression(node, modifiers, name, typeParameters, heritageClauses, members) { - if (node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassExpression = updateClassExpression; - function createOmittedExpression(location) { - var node = createNode(198, location); - return node; + function createOmittedExpression() { + return createSynthesizedNode(199); } ts.createOmittedExpression = createOmittedExpression; - function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(199, location); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.expression = parenthesizeForAccess(expression); + function createExpressionWithTypeArguments(typeArguments, expression) { + var node = createSynthesizedNode(200); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); return node; } ts.createExpressionWithTypeArguments = createExpressionWithTypeArguments; function updateExpressionWithTypeArguments(node, typeArguments, expression) { - if (node.typeArguments !== typeArguments || node.expression !== expression) { - return updateNode(createExpressionWithTypeArguments(typeArguments, expression, node), node); - } - return node; + return node.typeArguments !== typeArguments + || node.expression !== expression + ? updateNode(createExpressionWithTypeArguments(typeArguments, expression), node) + : node; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; - function createTemplateSpan(expression, literal, location) { - var node = createNode(202, location); + function createAsExpression(expression, type) { + var node = createSynthesizedNode(201); + node.expression = expression; + node.type = type; + return node; + } + ts.createAsExpression = createAsExpression; + function updateAsExpression(node, expression, type) { + return node.expression !== expression + || node.type !== type + ? updateNode(createAsExpression(expression, type), node) + : node; + } + ts.updateAsExpression = updateAsExpression; + function createNonNullExpression(expression) { + var node = createSynthesizedNode(202); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createNonNullExpression = createNonNullExpression; + function updateNonNullExpression(node, expression) { + return node.expression !== expression + ? updateNode(createNonNullExpression(expression), node) + : node; + } + ts.updateNonNullExpression = updateNonNullExpression; + function createTemplateSpan(expression, literal) { + var node = createSynthesizedNode(204); node.expression = expression; node.literal = literal; return node; } ts.createTemplateSpan = createTemplateSpan; function updateTemplateSpan(node, expression, literal) { - if (node.expression !== expression || node.literal !== literal) { - return updateNode(createTemplateSpan(expression, literal, node), node); - } - return node; + return node.expression !== expression + || node.literal !== literal + ? updateNode(createTemplateSpan(expression, literal), node) + : node; } ts.updateTemplateSpan = updateTemplateSpan; - function createBlock(statements, location, multiLine, flags) { - var block = createNode(204, location, flags); + function createBlock(statements, multiLine) { + var block = createSynthesizedNode(206); block.statements = createNodeArray(statements); - if (multiLine) { - block.multiLine = true; - } + if (multiLine) + block.multiLine = multiLine; return block; } ts.createBlock = createBlock; function updateBlock(node, statements) { - if (statements !== node.statements) { - return updateNode(createBlock(statements, node, node.multiLine, node.flags), node); - } - return node; + return statements !== node.statements + ? updateNode(createBlock(statements, node.multiLine), node) + : node; } ts.updateBlock = updateBlock; - function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(205, location, flags); + function createVariableStatement(modifiers, declarationList) { + var node = createSynthesizedNode(207); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; return node; } ts.createVariableStatement = createVariableStatement; function updateVariableStatement(node, modifiers, declarationList) { - if (node.modifiers !== modifiers || node.declarationList !== declarationList) { - return updateNode(createVariableStatement(modifiers, declarationList, node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.declarationList !== declarationList + ? updateNode(createVariableStatement(modifiers, declarationList), node) + : node; } ts.updateVariableStatement = updateVariableStatement; - function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(224, location, flags); + function createVariableDeclarationList(declarations, flags) { + var node = createSynthesizedNode(226); + node.flags |= flags; node.declarations = createNodeArray(declarations); return node; } ts.createVariableDeclarationList = createVariableDeclarationList; function updateVariableDeclarationList(node, declarations) { - if (node.declarations !== declarations) { - return updateNode(createVariableDeclarationList(declarations, node, node.flags), node); - } - return node; + return node.declarations !== declarations + ? updateNode(createVariableDeclarationList(declarations, node.flags), node) + : node; } ts.updateVariableDeclarationList = updateVariableDeclarationList; - function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(223, location, flags); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createVariableDeclaration(name, type, initializer) { + var node = createSynthesizedNode(225); + node.name = asName(name); node.type = type; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createVariableDeclaration = createVariableDeclaration; function updateVariableDeclaration(node, name, type, initializer) { - if (node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createVariableDeclaration(name, type, initializer, node, node.flags), node); - } - return node; + return node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createVariableDeclaration(name, type, initializer), node) + : node; } ts.updateVariableDeclaration = updateVariableDeclaration; - function createEmptyStatement(location) { - return createNode(206, location); + function createEmptyStatement() { + return createSynthesizedNode(208); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression, location, flags) { - var node = createNode(207, location, flags); - node.expression = parenthesizeExpressionForExpressionStatement(expression); + function createStatement(expression) { + var node = createSynthesizedNode(209); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } ts.createStatement = createStatement; function updateStatement(node, expression) { - if (node.expression !== expression) { - return updateNode(createStatement(expression, node, node.flags), node); - } - return node; + return node.expression !== expression + ? updateNode(createStatement(expression), node) + : node; } ts.updateStatement = updateStatement; - function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(208, location); + function createIf(expression, thenStatement, elseStatement) { + var node = createSynthesizedNode(210); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11341,42 +12358,43 @@ var ts; } ts.createIf = createIf; function updateIf(node, expression, thenStatement, elseStatement) { - if (node.expression !== expression || node.thenStatement !== thenStatement || node.elseStatement !== elseStatement) { - return updateNode(createIf(expression, thenStatement, elseStatement, node), node); - } - return node; + return node.expression !== expression + || node.thenStatement !== thenStatement + || node.elseStatement !== elseStatement + ? updateNode(createIf(expression, thenStatement, elseStatement), node) + : node; } ts.updateIf = updateIf; - function createDo(statement, expression, location) { - var node = createNode(209, location); + function createDo(statement, expression) { + var node = createSynthesizedNode(211); node.statement = statement; node.expression = expression; return node; } ts.createDo = createDo; function updateDo(node, statement, expression) { - if (node.statement !== statement || node.expression !== expression) { - return updateNode(createDo(statement, expression, node), node); - } - return node; + return node.statement !== statement + || node.expression !== expression + ? updateNode(createDo(statement, expression), node) + : node; } ts.updateDo = updateDo; - function createWhile(expression, statement, location) { - var node = createNode(210, location); + function createWhile(expression, statement) { + var node = createSynthesizedNode(212); node.expression = expression; node.statement = statement; return node; } ts.createWhile = createWhile; function updateWhile(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWhile(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWhile(expression, statement), node) + : node; } ts.updateWhile = updateWhile; - function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(211, location, undefined); + function createFor(initializer, condition, incrementor, statement) { + var node = createSynthesizedNode(213); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11385,14 +12403,16 @@ var ts; } ts.createFor = createFor; function updateFor(node, initializer, condition, incrementor, statement) { - if (node.initializer !== initializer || node.condition !== condition || node.incrementor !== incrementor || node.statement !== statement) { - return updateNode(createFor(initializer, condition, incrementor, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.condition !== condition + || node.incrementor !== incrementor + || node.statement !== statement + ? updateNode(createFor(initializer, condition, incrementor, statement), node) + : node; } ts.updateFor = updateFor; - function createForIn(initializer, expression, statement, location) { - var node = createNode(212, location); + function createForIn(initializer, expression, statement) { + var node = createSynthesizedNode(214); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11400,14 +12420,15 @@ var ts; } ts.createForIn = createForIn; function updateForIn(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForIn(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForIn(initializer, expression, statement), node) + : node; } ts.updateForIn = updateForIn; - function createForOf(initializer, expression, statement, location) { - var node = createNode(213, location); + function createForOf(initializer, expression, statement) { + var node = createSynthesizedNode(215); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11415,112 +12436,105 @@ var ts; } ts.createForOf = createForOf; function updateForOf(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForOf(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForOf(initializer, expression, statement), node) + : node; } ts.updateForOf = updateForOf; - function createContinue(label, location) { - var node = createNode(214, location); - if (label) { - node.label = label; - } + function createContinue(label) { + var node = createSynthesizedNode(216); + node.label = asName(label); return node; } ts.createContinue = createContinue; function updateContinue(node, label) { - if (node.label !== label) { - return updateNode(createContinue(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createContinue(label), node) + : node; } ts.updateContinue = updateContinue; - function createBreak(label, location) { - var node = createNode(215, location); - if (label) { - node.label = label; - } + function createBreak(label) { + var node = createSynthesizedNode(217); + node.label = asName(label); return node; } ts.createBreak = createBreak; function updateBreak(node, label) { - if (node.label !== label) { - return updateNode(createBreak(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createBreak(label), node) + : node; } ts.updateBreak = updateBreak; - function createReturn(expression, location) { - var node = createNode(216, location); + function createReturn(expression) { + var node = createSynthesizedNode(218); node.expression = expression; return node; } ts.createReturn = createReturn; function updateReturn(node, expression) { - if (node.expression !== expression) { - return updateNode(createReturn(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createReturn(expression), node) + : node; } ts.updateReturn = updateReturn; - function createWith(expression, statement, location) { - var node = createNode(217, location); + function createWith(expression, statement) { + var node = createSynthesizedNode(219); node.expression = expression; node.statement = statement; return node; } ts.createWith = createWith; function updateWith(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWith(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWith(expression, statement), node) + : node; } ts.updateWith = updateWith; - function createSwitch(expression, caseBlock, location) { - var node = createNode(218, location); - node.expression = parenthesizeExpressionForList(expression); + function createSwitch(expression, caseBlock) { + var node = createSynthesizedNode(220); + node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; } ts.createSwitch = createSwitch; function updateSwitch(node, expression, caseBlock) { - if (node.expression !== expression || node.caseBlock !== caseBlock) { - return updateNode(createSwitch(expression, caseBlock, node), node); - } - return node; + return node.expression !== expression + || node.caseBlock !== caseBlock + ? updateNode(createSwitch(expression, caseBlock), node) + : node; } ts.updateSwitch = updateSwitch; - function createLabel(label, statement, location) { - var node = createNode(219, location); - node.label = typeof label === "string" ? createIdentifier(label) : label; + function createLabel(label, statement) { + var node = createSynthesizedNode(221); + node.label = asName(label); node.statement = statement; return node; } ts.createLabel = createLabel; function updateLabel(node, label, statement) { - if (node.label !== label || node.statement !== statement) { - return updateNode(createLabel(label, statement, node), node); - } - return node; + return node.label !== label + || node.statement !== statement + ? updateNode(createLabel(label, statement), node) + : node; } ts.updateLabel = updateLabel; - function createThrow(expression, location) { - var node = createNode(220, location); + function createThrow(expression) { + var node = createSynthesizedNode(222); node.expression = expression; return node; } ts.createThrow = createThrow; function updateThrow(node, expression) { - if (node.expression !== expression) { - return updateNode(createThrow(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createThrow(expression), node) + : node; } ts.updateThrow = updateThrow; - function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(221, location); + function createTry(tryBlock, catchClause, finallyBlock) { + var node = createSynthesizedNode(223); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11528,32 +12542,20 @@ var ts; } ts.createTry = createTry; function updateTry(node, tryBlock, catchClause, finallyBlock) { - if (node.tryBlock !== tryBlock || node.catchClause !== catchClause || node.finallyBlock !== finallyBlock) { - return updateNode(createTry(tryBlock, catchClause, finallyBlock, node), node); - } - return node; + return node.tryBlock !== tryBlock + || node.catchClause !== catchClause + || node.finallyBlock !== finallyBlock + ? updateNode(createTry(tryBlock, catchClause, finallyBlock), node) + : node; } ts.updateTry = updateTry; - function createCaseBlock(clauses, location) { - var node = createNode(232, location); - node.clauses = createNodeArray(clauses); - return node; - } - ts.createCaseBlock = createCaseBlock; - function updateCaseBlock(node, clauses) { - if (node.clauses !== clauses) { - return updateNode(createCaseBlock(clauses, node), node); - } - return node; - } - ts.updateCaseBlock = updateCaseBlock; - function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(225, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(227); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -11561,161 +12563,261 @@ var ts; } ts.createFunctionDeclaration = createFunctionDeclaration; function updateFunctionDeclaration(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionDeclaration = updateFunctionDeclaration; - function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(226, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(228); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassDeclaration = createClassDeclaration; function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassDeclaration = updateClassDeclaration; - function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(235, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createEnumDeclaration(decorators, modifiers, name, members) { + var node = createSynthesizedNode(231); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.members = createNodeArray(members); + return node; + } + ts.createEnumDeclaration = createEnumDeclaration; + function updateEnumDeclaration(node, decorators, modifiers, name, members) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.members !== members + ? updateNode(createEnumDeclaration(decorators, modifiers, name, members), node) + : node; + } + ts.updateEnumDeclaration = updateEnumDeclaration; + function createModuleDeclaration(decorators, modifiers, name, body, flags) { + var node = createSynthesizedNode(232); + node.flags |= flags; + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = name; + node.body = body; + return node; + } + ts.createModuleDeclaration = createModuleDeclaration; + function updateModuleDeclaration(node, decorators, modifiers, name, body) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.body !== body + ? updateNode(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node) + : node; + } + ts.updateModuleDeclaration = updateModuleDeclaration; + function createModuleBlock(statements) { + var node = createSynthesizedNode(234); + node.statements = createNodeArray(statements); + return node; + } + ts.createModuleBlock = createModuleBlock; + function updateModuleBlock(node, statements) { + return node.statements !== statements + ? updateNode(createModuleBlock(statements), node) + : node; + } + ts.updateModuleBlock = updateModuleBlock; + function createCaseBlock(clauses) { + var node = createSynthesizedNode(234); + node.clauses = createNodeArray(clauses); + return node; + } + ts.createCaseBlock = createCaseBlock; + function updateCaseBlock(node, clauses) { + return node.clauses !== clauses + ? updateNode(createCaseBlock(clauses), node) + : node; + } + ts.updateCaseBlock = updateCaseBlock; + function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { + var node = createSynthesizedNode(236); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.moduleReference = moduleReference; + return node; + } + ts.createImportEqualsDeclaration = createImportEqualsDeclaration; + function updateImportEqualsDeclaration(node, decorators, modifiers, name, moduleReference) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.moduleReference !== moduleReference + ? updateNode(createImportEqualsDeclaration(decorators, modifiers, name, moduleReference), node) + : node; + } + ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; + function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { + var node = createSynthesizedNode(237); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createImportDeclaration = createImportDeclaration; function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node) + : node; } ts.updateImportDeclaration = updateImportDeclaration; - function createImportClause(name, namedBindings, location) { - var node = createNode(236, location); + function createImportClause(name, namedBindings) { + var node = createSynthesizedNode(238); node.name = name; node.namedBindings = namedBindings; return node; } ts.createImportClause = createImportClause; function updateImportClause(node, name, namedBindings) { - if (node.name !== name || node.namedBindings !== namedBindings) { - return updateNode(createImportClause(name, namedBindings, node), node); - } - return node; + return node.name !== name + || node.namedBindings !== namedBindings + ? updateNode(createImportClause(name, namedBindings), node) + : node; } ts.updateImportClause = updateImportClause; - function createNamespaceImport(name, location) { - var node = createNode(237, location); + function createNamespaceImport(name) { + var node = createSynthesizedNode(239); node.name = name; return node; } ts.createNamespaceImport = createNamespaceImport; function updateNamespaceImport(node, name) { - if (node.name !== name) { - return updateNode(createNamespaceImport(name, node), node); - } - return node; + return node.name !== name + ? updateNode(createNamespaceImport(name), node) + : node; } ts.updateNamespaceImport = updateNamespaceImport; - function createNamedImports(elements, location) { - var node = createNode(238, location); + function createNamedImports(elements) { + var node = createSynthesizedNode(240); node.elements = createNodeArray(elements); return node; } ts.createNamedImports = createNamedImports; function updateNamedImports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedImports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedImports(elements), node) + : node; } ts.updateNamedImports = updateNamedImports; - function createImportSpecifier(propertyName, name, location) { - var node = createNode(239, location); + function createImportSpecifier(propertyName, name) { + var node = createSynthesizedNode(241); node.propertyName = propertyName; node.name = name; return node; } ts.createImportSpecifier = createImportSpecifier; function updateImportSpecifier(node, propertyName, name) { - if (node.propertyName !== propertyName || node.name !== name) { - return updateNode(createImportSpecifier(propertyName, name, node), node); - } - return node; + return node.propertyName !== propertyName + || node.name !== name + ? updateNode(createImportSpecifier(propertyName, name), node) + : node; } ts.updateImportSpecifier = updateImportSpecifier; - function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(240, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportAssignment(decorators, modifiers, isExportEquals, expression) { + var node = createSynthesizedNode(242); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; node.expression = expression; return node; } ts.createExportAssignment = createExportAssignment; function updateExportAssignment(node, decorators, modifiers, expression) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.expression !== expression) { - return updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.expression !== expression + ? updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node) + : node; } ts.updateExportAssignment = updateExportAssignment; - function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(241, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { + var node = createSynthesizedNode(243); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createExportDeclaration = createExportDeclaration; function updateExportDeclaration(node, decorators, modifiers, exportClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.exportClause !== exportClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.exportClause !== exportClause + || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier), node) + : node; } ts.updateExportDeclaration = updateExportDeclaration; - function createNamedExports(elements, location) { - var node = createNode(242, location); + function createNamedExports(elements) { + var node = createSynthesizedNode(244); node.elements = createNodeArray(elements); return node; } ts.createNamedExports = createNamedExports; function updateNamedExports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedExports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedExports(elements), node) + : node; } ts.updateNamedExports = updateNamedExports; - function createExportSpecifier(name, propertyName, location) { - var node = createNode(243, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createExportSpecifier(name, propertyName) { + var node = createSynthesizedNode(245); + node.name = asName(name); + node.propertyName = asName(propertyName); return node; } ts.createExportSpecifier = createExportSpecifier; function updateExportSpecifier(node, name, propertyName) { - if (node.name !== name || node.propertyName !== propertyName) { - return updateNode(createExportSpecifier(name, propertyName, node), node); - } - return node; + return node.name !== name || node.propertyName !== propertyName + ? updateNode(createExportSpecifier(name, propertyName), node) + : node; } ts.updateExportSpecifier = updateExportSpecifier; - function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(246, location); + function createExternalModuleReference(expression) { + var node = createSynthesizedNode(247); + node.expression = expression; + return node; + } + ts.createExternalModuleReference = createExternalModuleReference; + function updateExternalModuleReference(node, expression) { + return node.expression !== expression + ? updateNode(createExternalModuleReference(expression), node) + : node; + } + ts.updateExternalModuleReference = updateExternalModuleReference; + function createJsxElement(openingElement, children, closingElement) { + var node = createSynthesizedNode(248); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11723,95 +12825,107 @@ var ts; } ts.createJsxElement = createJsxElement; function updateJsxElement(node, openingElement, children, closingElement) { - if (node.openingElement !== openingElement || node.children !== children || node.closingElement !== closingElement) { - return updateNode(createJsxElement(openingElement, children, closingElement, node), node); - } - return node; + return node.openingElement !== openingElement + || node.children !== children + || node.closingElement !== closingElement + ? updateNode(createJsxElement(openingElement, children, closingElement), node) + : node; } ts.updateJsxElement = updateJsxElement; - function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(247, location); + function createJsxSelfClosingElement(tagName, attributes) { + var node = createSynthesizedNode(249); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxSelfClosingElement = createJsxSelfClosingElement; function updateJsxSelfClosingElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxSelfClosingElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxSelfClosingElement(tagName, attributes), node) + : node; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; - function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(248, location); + function createJsxOpeningElement(tagName, attributes) { + var node = createSynthesizedNode(250); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxOpeningElement = createJsxOpeningElement; function updateJsxOpeningElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxOpeningElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxOpeningElement(tagName, attributes), node) + : node; } ts.updateJsxOpeningElement = updateJsxOpeningElement; - function createJsxClosingElement(tagName, location) { - var node = createNode(249, location); + function createJsxClosingElement(tagName) { + var node = createSynthesizedNode(251); node.tagName = tagName; return node; } ts.createJsxClosingElement = createJsxClosingElement; function updateJsxClosingElement(node, tagName) { - if (node.tagName !== tagName) { - return updateNode(createJsxClosingElement(tagName, node), node); - } - return node; + return node.tagName !== tagName + ? updateNode(createJsxClosingElement(tagName), node) + : node; } ts.updateJsxClosingElement = updateJsxClosingElement; - function createJsxAttribute(name, initializer, location) { - var node = createNode(250, location); + function createJsxAttributes(properties) { + var jsxAttributes = createSynthesizedNode(253); + jsxAttributes.properties = createNodeArray(properties); + return jsxAttributes; + } + ts.createJsxAttributes = createJsxAttributes; + function updateJsxAttributes(jsxAttributes, properties) { + if (jsxAttributes.properties !== properties) { + return updateNode(createJsxAttributes(properties), jsxAttributes); + } + return jsxAttributes; + } + ts.updateJsxAttributes = updateJsxAttributes; + function createJsxAttribute(name, initializer) { + var node = createSynthesizedNode(252); node.name = name; node.initializer = initializer; return node; } ts.createJsxAttribute = createJsxAttribute; function updateJsxAttribute(node, name, initializer) { - if (node.name !== name || node.initializer !== initializer) { - return updateNode(createJsxAttribute(name, initializer, node), node); - } - return node; + return node.name !== name + || node.initializer !== initializer + ? updateNode(createJsxAttribute(name, initializer), node) + : node; } ts.updateJsxAttribute = updateJsxAttribute; - function createJsxSpreadAttribute(expression, location) { - var node = createNode(251, location); + function createJsxSpreadAttribute(expression) { + var node = createSynthesizedNode(254); node.expression = expression; return node; } ts.createJsxSpreadAttribute = createJsxSpreadAttribute; function updateJsxSpreadAttribute(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxSpreadAttribute(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxSpreadAttribute(expression), node) + : node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, location) { - var node = createNode(252, location); + function createJsxExpression(expression, dotDotDotToken) { + var node = createSynthesizedNode(255); + node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxExpression(expression, node.dotDotDotToken), node) + : node; } ts.updateJsxExpression = updateJsxExpression; - function createHeritageClause(token, types, location) { - var node = createNode(255, location); + function createHeritageClause(token, types) { + var node = createSynthesizedNode(258); node.token = token; node.types = createNodeArray(types); return node; @@ -11819,40 +12933,40 @@ var ts; ts.createHeritageClause = createHeritageClause; function updateHeritageClause(node, types) { if (node.types !== types) { - return updateNode(createHeritageClause(node.token, types, node), node); + return updateNode(createHeritageClause(node.token, types), node); } return node; } ts.updateHeritageClause = updateHeritageClause; - function createCaseClause(expression, statements, location) { - var node = createNode(253, location); - node.expression = parenthesizeExpressionForList(expression); + function createCaseClause(expression, statements) { + var node = createSynthesizedNode(256); + node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; } ts.createCaseClause = createCaseClause; function updateCaseClause(node, expression, statements) { if (node.expression !== expression || node.statements !== statements) { - return updateNode(createCaseClause(expression, statements, node), node); + return updateNode(createCaseClause(expression, statements), node); } return node; } ts.updateCaseClause = updateCaseClause; - function createDefaultClause(statements, location) { - var node = createNode(254, location); + function createDefaultClause(statements) { + var node = createSynthesizedNode(257); node.statements = createNodeArray(statements); return node; } ts.createDefaultClause = createDefaultClause; function updateDefaultClause(node, statements) { if (node.statements !== statements) { - return updateNode(createDefaultClause(statements, node), node); + return updateNode(createDefaultClause(statements), node); } return node; } ts.updateDefaultClause = updateDefaultClause; - function createCatchClause(variableDeclaration, block, location) { - var node = createNode(256, location); + function createCatchClause(variableDeclaration, block) { + var node = createSynthesizedNode(259); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11860,56 +12974,71 @@ var ts; ts.createCatchClause = createCatchClause; function updateCatchClause(node, variableDeclaration, block) { if (node.variableDeclaration !== variableDeclaration || node.block !== block) { - return updateNode(createCatchClause(variableDeclaration, block, node), node); + return updateNode(createCatchClause(variableDeclaration, block), node); } return node; } ts.updateCatchClause = updateCatchClause; - function createPropertyAssignment(name, initializer, location) { - var node = createNode(257, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAssignment(name, initializer) { + var node = createSynthesizedNode(260); + node.name = asName(name); node.questionToken = undefined; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createPropertyAssignment = createPropertyAssignment; function updatePropertyAssignment(node, name, initializer) { if (node.name !== name || node.initializer !== initializer) { - return updateNode(createPropertyAssignment(name, initializer, node), node); + return updateNode(createPropertyAssignment(name, initializer), node); } return node; } ts.updatePropertyAssignment = updatePropertyAssignment; - function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(258, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; + function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { + var node = createSynthesizedNode(261); + node.name = asName(name); + node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; - function createSpreadAssignment(expression, location) { - var node = createNode(259, location); - node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; + function createSpreadAssignment(expression) { + var node = createSynthesizedNode(262); + node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; return node; } ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { - return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node); + return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node); } return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function updateSpreadAssignment(node, expression) { if (node.expression !== expression) { - return updateNode(createSpreadAssignment(expression, node), node); + return updateNode(createSpreadAssignment(expression), node); } return node; } ts.updateSpreadAssignment = updateSpreadAssignment; + function createEnumMember(name, initializer) { + var node = createSynthesizedNode(263); + node.name = asName(name); + node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); + return node; + } + ts.createEnumMember = createEnumMember; + function updateEnumMember(node, name, initializer) { + return node.name !== name + || node.initializer !== initializer + ? updateNode(createEnumMember(name, initializer), node) + : node; + } + ts.updateEnumMember = updateEnumMember; function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(261, node, node.flags); + var updated = createSynthesizedNode(264); + updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -11968,56 +13097,73 @@ var ts; return node; } ts.updateSourceFileNode = updateSourceFileNode; + function getMutableClone(node) { + var clone = getSynthesizedClone(node); + clone.pos = node.pos; + clone.end = node.end; + clone.parent = node.parent; + return clone; + } + ts.getMutableClone = getMutableClone; function createNotEmittedStatement(original) { - var node = createNode(293, original); + var node = createSynthesizedNode(297); node.original = original; + setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createNode(296); + var node = createSynthesizedNode(300); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createNode(295); + var node = createSynthesizedNode(299); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; - function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(294, location || original); + function createPartiallyEmittedExpression(expression, original) { + var node = createSynthesizedNode(298); node.expression = expression; node.original = original; + setTextRange(node, original); return node; } ts.createPartiallyEmittedExpression = createPartiallyEmittedExpression; function updatePartiallyEmittedExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createPartiallyEmittedExpression(expression, node.original, node), node); + return updateNode(createPartiallyEmittedExpression(expression, node.original), node); } return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; - function createRawExpression(text) { - var node = createNode(297); - node.text = text; + function createBundle(sourceFiles) { + var node = ts.createNode(265); + node.sourceFiles = sourceFiles; return node; } - ts.createRawExpression = createRawExpression; + ts.createBundle = createBundle; + function updateBundle(node, sourceFiles) { + if (node.sourceFiles !== sourceFiles) { + return createBundle(sourceFiles); + } + return node; + } + ts.updateBundle = updateBundle; function createComma(left, right) { return createBinary(left, 25, right); } ts.createComma = createComma; - function createLessThan(left, right, location) { - return createBinary(left, 26, right, location); + function createLessThan(left, right) { + return createBinary(left, 26, right); } ts.createLessThan = createLessThan; - function createAssignment(left, right, location) { - return createBinary(left, 57, right, location); + function createAssignment(left, right) { + return createBinary(left, 57, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { @@ -12036,8 +13182,8 @@ var ts; return createBinary(left, 37, right); } ts.createSubtract = createSubtract; - function createPostfixIncrement(operand, location) { - return createPostfix(operand, 42, location); + function createPostfixIncrement(operand) { + return createPostfix(operand, 42); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { @@ -12056,97 +13202,6 @@ var ts; return createVoid(createLiteral(0)); } ts.createVoidZero = createVoidZero; - function createTypeCheck(value, tag) { - return tag === "undefined" - ? createStrictEquality(value, createVoidZero()) - : createStrictEquality(createTypeOf(value), createLiteral(tag)); - } - ts.createTypeCheck = createTypeCheck; - function createMemberAccessForPropertyName(target, memberName, location) { - if (ts.isComputedPropertyName(memberName)) { - return createElementAccess(target, memberName.expression, location); - } - else { - var expression = ts.isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); - (expression.emitNode || (expression.emitNode = {})).flags |= 64; - return expression; - } - } - ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; - function createFunctionCall(func, thisArg, argumentsList, location) { - return createCall(createPropertyAccess(func, "call"), undefined, [ - thisArg - ].concat(argumentsList), location); - } - ts.createFunctionCall = createFunctionCall; - function createFunctionApply(func, thisArg, argumentsExpression, location) { - return createCall(createPropertyAccess(func, "apply"), undefined, [ - thisArg, - argumentsExpression - ], location); - } - ts.createFunctionApply = createFunctionApply; - function createArraySlice(array, start) { - var argumentsList = []; - if (start !== undefined) { - argumentsList.push(typeof start === "number" ? createLiteral(start) : start); - } - return createCall(createPropertyAccess(array, "slice"), undefined, argumentsList); - } - ts.createArraySlice = createArraySlice; - function createArrayConcat(array, values) { - return createCall(createPropertyAccess(array, "concat"), undefined, values); - } - ts.createArrayConcat = createArrayConcat; - function createMathPow(left, right, location) { - return createCall(createPropertyAccess(createIdentifier("Math"), "pow"), undefined, [left, right], location); - } - ts.createMathPow = createMathPow; - function createReactNamespace(reactNamespace, parent) { - var react = createIdentifier(reactNamespace || "React"); - react.flags &= ~8; - react.parent = ts.getParseTreeNode(parent); - return react; - } - function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { - if (ts.isQualifiedName(jsxFactory)) { - var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent); - var right = createSynthesizedNode(70); - right.text = jsxFactory.right.text; - return createPropertyAccess(left, right); - } - else { - return createReactNamespace(jsxFactory.text, parent); - } - } - function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { - return jsxFactoryEntity ? - createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : - createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); - } - function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { - var argumentsList = [tagName]; - if (props) { - argumentsList.push(props); - } - if (children && children.length > 0) { - if (!props) { - argumentsList.push(createNull()); - } - if (children.length > 1) { - for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { - var child = children_1[_i]; - child.startsOnNewLine = true; - argumentsList.push(child); - } - } - else { - argumentsList.push(children[0]); - } - } - return createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList, location); - } - ts.createExpressionForJsxElement = createExpressionForJsxElement; function createExportDefault(expression) { return createExportAssignment(undefined, undefined, false, expression); } @@ -12155,573 +13210,17 @@ var ts; return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(exportName)])); } ts.createExternalModuleExport = createExternalModuleExport; - function createLetStatement(name, initializer, location) { - return createVariableStatement(undefined, createLetDeclarationList([createVariableDeclaration(name, undefined, initializer)]), location); + function asName(name) { + return typeof name === "string" ? createIdentifier(name) : name; } - ts.createLetStatement = createLetStatement; - function createLetDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 1); + function asExpression(value) { + return typeof value === "string" || typeof value === "number" ? createLiteral(value) : value; } - ts.createLetDeclarationList = createLetDeclarationList; - function createConstDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 2); + function asNodeArray(array) { + return array ? createNodeArray(array) : undefined; } - ts.createConstDeclarationList = createConstDeclarationList; - function getHelperName(name) { - return setEmitFlags(createIdentifier(name), 4096 | 2); - } - ts.getHelperName = getHelperName; - function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { - var target = skipParentheses(node); - switch (target.kind) { - case 70: - return cacheIdentifiers; - case 98: - case 8: - case 9: - return false; - case 175: - var elements = target.elements; - if (elements.length === 0) { - return false; - } - return true; - case 176: - return target.properties.length > 0; - default: - return true; - } - } - function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { - var callee = skipOuterExpressions(expression, 7); - var thisArg; - var target; - if (ts.isSuperProperty(callee)) { - thisArg = createThis(); - target = callee; - } - else if (callee.kind === 96) { - thisArg = createThis(); - target = languageVersion < 2 ? createIdentifier("_super", callee) : callee; - } - else { - switch (callee.kind) { - case 177: { - if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { - thisArg = createTempVariable(recordTempVariable); - target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); - } - else { - thisArg = callee.expression; - target = callee; - } - break; - } - case 178: { - if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { - thisArg = createTempVariable(recordTempVariable); - target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); - } - else { - thisArg = callee.expression; - target = callee; - } - break; - } - default: { - thisArg = createVoidZero(); - target = parenthesizeForAccess(expression); - break; - } - } - } - return { target: target, thisArg: thisArg }; - } - ts.createCallBinding = createCallBinding; - function inlineExpressions(expressions) { - return ts.reduceLeft(expressions, createComma); - } - ts.inlineExpressions = inlineExpressions; - function createExpressionFromEntityName(node) { - if (ts.isQualifiedName(node)) { - var left = createExpressionFromEntityName(node.left); - var right = getMutableClone(node.right); - return createPropertyAccess(left, right, node); - } - else { - return getMutableClone(node); - } - } - ts.createExpressionFromEntityName = createExpressionFromEntityName; - function createExpressionForPropertyName(memberName) { - if (ts.isIdentifier(memberName)) { - return createLiteral(memberName, undefined); - } - else if (ts.isComputedPropertyName(memberName)) { - return getMutableClone(memberName.expression); - } - else { - return getMutableClone(memberName); - } - } - ts.createExpressionForPropertyName = createExpressionForPropertyName; - function createExpressionForObjectLiteralElementLike(node, property, receiver) { - switch (property.kind) { - case 151: - case 152: - return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 257: - return createExpressionForPropertyAssignment(property, receiver); - case 258: - return createExpressionForShorthandPropertyAssignment(property, receiver); - case 149: - return createExpressionForMethodDeclaration(property, receiver); - } - } - ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike; - function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { - var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; - if (property === firstAccessor) { - var properties_1 = []; - if (getAccessor) { - var getterFunction = createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body, getAccessor); - setOriginalNode(getterFunction, getAccessor); - var getter = createPropertyAssignment("get", getterFunction); - properties_1.push(getter); - } - if (setAccessor) { - var setterFunction = createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body, setAccessor); - setOriginalNode(setterFunction, setAccessor); - var setter = createPropertyAssignment("set", setterFunction); - properties_1.push(setter); - } - properties_1.push(createPropertyAssignment("enumerable", createLiteral(true))); - properties_1.push(createPropertyAssignment("configurable", createLiteral(true))); - var expression = createCall(createPropertyAccess(createIdentifier("Object"), "defineProperty"), undefined, [ - receiver, - createExpressionForPropertyName(property.name), - createObjectLiteral(properties_1, undefined, multiLine) - ], firstAccessor); - return ts.aggregateTransformFlags(expression); - } - return undefined; - } - function createExpressionForPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), property.initializer, property), property)); - } - function createExpressionForShorthandPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), getSynthesizedClone(property.name), property), property)); - } - function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); - } - function getLocalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384); - } - ts.getLocalName = getLocalName; - function isLocalName(node) { - return (getEmitFlags(node) & 16384) !== 0; - } - ts.isLocalName = isLocalName; - function getExportName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 8192); - } - ts.getExportName = getExportName; - function isExportName(node) { - return (getEmitFlags(node) & 8192) !== 0; - } - ts.isExportName = isExportName; - function getDeclarationName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps); - } - ts.getDeclarationName = getDeclarationName; - function getName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { - var name_10 = getMutableClone(node.name); - emitFlags |= getEmitFlags(node.name); - if (!allowSourceMaps) - emitFlags |= 48; - if (!allowComments) - emitFlags |= 1536; - if (emitFlags) - setEmitFlags(name_10, emitFlags); - return name_10; - } - return getGeneratedNameForNode(node); - } - function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && ts.hasModifier(node, 1)) { - return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); - } - return getExportName(node, allowComments, allowSourceMaps); - } - ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName; - function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { - var qualifiedName = createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : getSynthesizedClone(name), name); - var emitFlags; - if (!allowSourceMaps) - emitFlags |= 48; - if (!allowComments) - emitFlags |= 1536; - if (emitFlags) - setEmitFlags(qualifiedName, emitFlags); - return qualifiedName; - } - ts.getNamespaceMemberName = getNamespaceMemberName; - function convertToFunctionBody(node, multiLine) { - return ts.isBlock(node) ? node : createBlock([createReturn(node, node)], node, multiLine); - } - ts.convertToFunctionBody = convertToFunctionBody; - function isUseStrictPrologue(node) { - return node.expression.text === "use strict"; - } - function addPrologueDirectives(target, source, ensureUseStrict, visitor) { - ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); - var foundUseStrict = false; - var statementOffset = 0; - var numStatements = source.length; - while (statementOffset < numStatements) { - var statement = source[statementOffset]; - if (ts.isPrologueDirective(statement)) { - if (isUseStrictPrologue(statement)) { - foundUseStrict = true; - } - target.push(statement); - } - else { - break; - } - statementOffset++; - } - if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); - } - while (statementOffset < numStatements) { - var statement = source[statementOffset]; - if (getEmitFlags(statement) & 524288) { - target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); - } - else { - break; - } - statementOffset++; - } - return statementOffset; - } - ts.addPrologueDirectives = addPrologueDirectives; - function startsWithUseStrict(statements) { - var firstStatement = ts.firstOrUndefined(statements); - return firstStatement !== undefined - && ts.isPrologueDirective(firstStatement) - && isUseStrictPrologue(firstStatement); - } - ts.startsWithUseStrict = startsWithUseStrict; - function ensureUseStrict(statements) { - var foundUseStrict = false; - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; - if (ts.isPrologueDirective(statement)) { - if (isUseStrictPrologue(statement)) { - foundUseStrict = true; - break; - } - } - else { - break; - } - } - if (!foundUseStrict) { - return createNodeArray([ - startOnNewLine(createStatement(createLiteral("use strict"))) - ].concat(statements), statements); - } - return statements; - } - ts.ensureUseStrict = ensureUseStrict; - function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 183) { - return operand; - } - return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) - ? createParen(operand) - : operand; - } - ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; - function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(192, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(192, binaryOperator); - var emittedOperand = skipPartiallyEmittedExpressions(operand); - var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); - switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { - case -1: - if (!isLeftSideOfBinary - && binaryOperatorAssociativity === 1 - && operand.kind === 195) { - return false; - } - return true; - case 1: - return false; - case 0: - if (isLeftSideOfBinary) { - return binaryOperatorAssociativity === 1; - } - else { - if (ts.isBinaryExpression(emittedOperand) - && emittedOperand.operatorToken.kind === binaryOperator) { - if (operatorHasAssociativeProperty(binaryOperator)) { - return false; - } - if (binaryOperator === 36) { - var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; - if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { - return false; - } - } - } - var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); - return operandAssociativity === 0; - } - } - } - function operatorHasAssociativeProperty(binaryOperator) { - return binaryOperator === 38 - || binaryOperator === 48 - || binaryOperator === 47 - || binaryOperator === 49; - } - function getLiteralKindOfBinaryPlusOperand(node) { - node = skipPartiallyEmittedExpressions(node); - if (ts.isLiteralKind(node.kind)) { - return node.kind; - } - if (node.kind === 192 && node.operatorToken.kind === 36) { - if (node.cachedLiteralKind !== undefined) { - return node.cachedLiteralKind; - } - var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0; - node.cachedLiteralKind = literalKind; - return literalKind; - } - return 0; - } - function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(193, 54); - var emittedCondition = skipPartiallyEmittedExpressions(condition); - var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { - return createParen(condition); - } - return condition; - } - ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; - function parenthesizeSubexpressionOfConditionalExpression(e) { - return e.kind === 192 && e.operatorToken.kind === 25 - ? createParen(e) - : e; - } - function parenthesizeForNew(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - switch (emittedExpression.kind) { - case 179: - return createParen(expression); - case 180: - return emittedExpression.arguments - ? expression - : createParen(expression); - } - return parenthesizeForAccess(expression); - } - ts.parenthesizeForNew = parenthesizeForNew; - function parenthesizeForAccess(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 180 || emittedExpression.arguments) - && emittedExpression.kind !== 8) { - return expression; - } - return createParen(expression, expression); - } - ts.parenthesizeForAccess = parenthesizeForAccess; - function parenthesizePostfixOperand(operand) { - return ts.isLeftHandSideExpression(operand) - ? operand - : createParen(operand, operand); - } - ts.parenthesizePostfixOperand = parenthesizePostfixOperand; - function parenthesizePrefixOperand(operand) { - return ts.isUnaryExpression(operand) - ? operand - : createParen(operand, operand); - } - ts.parenthesizePrefixOperand = parenthesizePrefixOperand; - function parenthesizeListElements(elements) { - var result; - for (var i = 0; i < elements.length; i++) { - var element = parenthesizeExpressionForList(elements[i]); - if (result !== undefined || element !== elements[i]) { - if (result === undefined) { - result = elements.slice(0, i); - } - result.push(element); - } - } - if (result !== undefined) { - return createNodeArray(result, elements, elements.hasTrailingComma); - } - return elements; - } - function parenthesizeExpressionForList(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(192, 25); - return expressionPrecedence > commaPrecedence - ? expression - : createParen(expression, expression); - } - ts.parenthesizeExpressionForList = parenthesizeExpressionForList; - function parenthesizeExpressionForExpressionStatement(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - if (ts.isCallExpression(emittedExpression)) { - var callee = emittedExpression.expression; - var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 184 || kind === 185) { - var mutableCall = getMutableClone(emittedExpression); - mutableCall.expression = createParen(callee, callee); - return recreatePartiallyEmittedExpressions(expression, mutableCall); - } - } - else { - var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 176 || leftmostExpressionKind === 184) { - return createParen(expression, expression); - } - } - return expression; - } - ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; - function recreatePartiallyEmittedExpressions(originalOuterExpression, newInnerExpression) { - if (ts.isPartiallyEmittedExpression(originalOuterExpression)) { - var clone_1 = getMutableClone(originalOuterExpression); - clone_1.expression = recreatePartiallyEmittedExpressions(clone_1.expression, newInnerExpression); - return clone_1; - } - return newInnerExpression; - } - function getLeftmostExpression(node) { - while (true) { - switch (node.kind) { - case 191: - node = node.operand; - continue; - case 192: - node = node.left; - continue; - case 193: - node = node.condition; - continue; - case 179: - case 178: - case 177: - node = node.expression; - continue; - case 294: - node = node.expression; - continue; - } - return node; - } - } - function parenthesizeConciseBody(body) { - var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 176) { - return createParen(body, body); - } - return body; - } - ts.parenthesizeConciseBody = parenthesizeConciseBody; - function skipOuterExpressions(node, kinds) { - if (kinds === void 0) { kinds = 7; } - var previousNode; - do { - previousNode = node; - if (kinds & 1) { - node = skipParentheses(node); - } - if (kinds & 2) { - node = skipAssertions(node); - } - if (kinds & 4) { - node = skipPartiallyEmittedExpressions(node); - } - } while (previousNode !== node); - return node; - } - ts.skipOuterExpressions = skipOuterExpressions; - function skipParentheses(node) { - while (node.kind === 183) { - node = node.expression; - } - return node; - } - ts.skipParentheses = skipParentheses; - function skipAssertions(node) { - while (ts.isAssertionExpression(node)) { - node = node.expression; - } - return node; - } - ts.skipAssertions = skipAssertions; - function skipPartiallyEmittedExpressions(node) { - while (node.kind === 294) { - node = node.expression; - } - return node; - } - ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; - function startOnNewLine(node) { - node.startsOnNewLine = true; - return node; - } - ts.startOnNewLine = startOnNewLine; - function setOriginalNode(node, original) { - node.original = original; - if (original) { - var emitNode = original.emitNode; - if (emitNode) - node.emitNode = mergeEmitNode(emitNode, node.emitNode); - } - return node; - } - ts.setOriginalNode = setOriginalNode; - function mergeEmitNode(sourceEmitNode, destEmitNode) { - var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; - if (!destEmitNode) - destEmitNode = {}; - if (flags) - destEmitNode.flags = flags; - if (commentRange) - destEmitNode.commentRange = commentRange; - if (sourceMapRange) - destEmitNode.sourceMapRange = sourceMapRange; - if (tokenSourceMapRanges) - destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); - if (constantValue !== undefined) - destEmitNode.constantValue = constantValue; - if (helpers) - destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); - return destEmitNode; - } - function mergeTokenSourceMapRanges(sourceRanges, destRanges) { - if (!destRanges) - destRanges = ts.createMap(); - ts.copyProperties(sourceRanges, destRanges); - return destRanges; + function asToken(value) { + return typeof value === "number" ? createToken(value) : value; } function disposeEmitNodes(sourceFile) { sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); @@ -12738,7 +13237,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 261) { + if (node.kind === 264) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -12749,6 +13248,14 @@ var ts; return node.emitNode; } ts.getOrCreateEmitNode = getOrCreateEmitNode; + function setTextRange(range, location) { + if (location) { + range.pos = location.pos; + range.end = location.end; + } + return range; + } + ts.setTextRange = setTextRange; function getEmitFlags(node) { var emitNode = node.emitNode; return emitNode && emitNode.flags; @@ -12777,7 +13284,7 @@ var ts; ts.getTokenSourceMapRange = getTokenSourceMapRange; function setTokenSourceMapRange(node, token, range) { var emitNode = getOrCreateEmitNode(node); - var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = ts.createMap()); + var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = []); tokenSourceMapRanges[token] = range; return node; } @@ -12803,32 +13310,6 @@ var ts; return node; } ts.setConstantValue = setConstantValue; - function getExternalHelpersModuleName(node) { - var parseNode = ts.getOriginalNode(node, ts.isSourceFile); - var emitNode = parseNode && parseNode.emitNode; - return emitNode && emitNode.externalHelpersModuleName; - } - ts.getExternalHelpersModuleName = getExternalHelpersModuleName; - function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions) { - if (compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { - var externalHelpersModuleName = getExternalHelpersModuleName(node); - if (externalHelpersModuleName) { - return externalHelpersModuleName; - } - var helpers = getEmitHelpers(node); - if (helpers) { - for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { - var helper = helpers_1[_i]; - if (!helper.scoped) { - var parseNode = ts.getOriginalNode(node, ts.isSourceFile); - var emitNode = getOrCreateEmitNode(parseNode); - return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = createUniqueName(ts.externalHelpersModuleNameText)); - } - } - } - } - } - ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded; function addEmitHelper(node, helper) { var emitNode = getOrCreateEmitNode(node); emitNode.helpers = ts.append(emitNode.helpers, helper); @@ -12838,8 +13319,8 @@ var ts; function addEmitHelpers(node, helpers) { if (ts.some(helpers)) { var emitNode = getOrCreateEmitNode(node); - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; + for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { + var helper = helpers_1[_i]; if (!ts.contains(emitNode.helpers, helper)) { emitNode.helpers = ts.append(emitNode.helpers, helper); } @@ -12900,40 +13381,725 @@ var ts; return ts.compareValues(x.priority, y.priority); } ts.compareEmitHelpers = compareEmitHelpers; - function setTextRange(node, location) { - if (location) { - node.pos = location.pos; - node.end = location.end; + function setOriginalNode(node, original) { + node.original = original; + if (original) { + var emitNode = original.emitNode; + if (emitNode) + node.emitNode = mergeEmitNode(emitNode, node.emitNode); } return node; } - ts.setTextRange = setTextRange; - function setNodeFlags(node, flags) { - node.flags = flags; + ts.setOriginalNode = setOriginalNode; + function mergeEmitNode(sourceEmitNode, destEmitNode) { + var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; + if (!destEmitNode) + destEmitNode = {}; + if (flags) + destEmitNode.flags = flags; + if (commentRange) + destEmitNode.commentRange = commentRange; + if (sourceMapRange) + destEmitNode.sourceMapRange = sourceMapRange; + if (tokenSourceMapRanges) + destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); + if (constantValue !== undefined) + destEmitNode.constantValue = constantValue; + if (helpers) + destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); + return destEmitNode; + } + function mergeTokenSourceMapRanges(sourceRanges, destRanges) { + if (!destRanges) + destRanges = []; + for (var key in sourceRanges) { + destRanges[key] = sourceRanges[key]; + } + return destRanges; + } +})(ts || (ts = {})); +(function (ts) { + function createTypeCheck(value, tag) { + return tag === "undefined" + ? ts.createStrictEquality(value, ts.createVoidZero()) + : ts.createStrictEquality(ts.createTypeOf(value), ts.createLiteral(tag)); + } + ts.createTypeCheck = createTypeCheck; + function createMemberAccessForPropertyName(target, memberName, location) { + if (ts.isComputedPropertyName(memberName)) { + return ts.setTextRange(ts.createElementAccess(target, memberName.expression), location); + } + else { + var expression = ts.setTextRange(ts.isIdentifier(memberName) + ? ts.createPropertyAccess(target, memberName) + : ts.createElementAccess(target, memberName), memberName); + ts.getOrCreateEmitNode(expression).flags |= 64; + return expression; + } + } + ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; + function createFunctionCall(func, thisArg, argumentsList, location) { + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), undefined, [ + thisArg + ].concat(argumentsList)), location); + } + ts.createFunctionCall = createFunctionCall; + function createFunctionApply(func, thisArg, argumentsExpression, location) { + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "apply"), undefined, [ + thisArg, + argumentsExpression + ]), location); + } + ts.createFunctionApply = createFunctionApply; + function createArraySlice(array, start) { + var argumentsList = []; + if (start !== undefined) { + argumentsList.push(typeof start === "number" ? ts.createLiteral(start) : start); + } + return ts.createCall(ts.createPropertyAccess(array, "slice"), undefined, argumentsList); + } + ts.createArraySlice = createArraySlice; + function createArrayConcat(array, values) { + return ts.createCall(ts.createPropertyAccess(array, "concat"), undefined, values); + } + ts.createArrayConcat = createArrayConcat; + function createMathPow(left, right, location) { + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Math"), "pow"), undefined, [left, right]), location); + } + ts.createMathPow = createMathPow; + function createReactNamespace(reactNamespace, parent) { + var react = ts.createIdentifier(reactNamespace || "React"); + react.flags &= ~8; + react.parent = ts.getParseTreeNode(parent); + return react; + } + function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { + if (ts.isQualifiedName(jsxFactory)) { + var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent); + var right = ts.createIdentifier(jsxFactory.right.text); + right.text = jsxFactory.right.text; + return ts.createPropertyAccess(left, right); + } + else { + return createReactNamespace(jsxFactory.text, parent); + } + } + function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { + return jsxFactoryEntity ? + createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : + ts.createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); + } + function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { + var argumentsList = [tagName]; + if (props) { + argumentsList.push(props); + } + if (children && children.length > 0) { + if (!props) { + argumentsList.push(ts.createNull()); + } + if (children.length > 1) { + for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { + var child = children_1[_i]; + child.startsOnNewLine = true; + argumentsList.push(child); + } + } + else { + argumentsList.push(children[0]); + } + } + return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList), location); + } + ts.createExpressionForJsxElement = createExpressionForJsxElement; + function getHelperName(name) { + return ts.setEmitFlags(ts.createIdentifier(name), 4096 | 2); + } + ts.getHelperName = getHelperName; + function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { + if (!outermostLabeledStatement) { + return node; + } + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 221 + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + ts.restoreEnclosingLabel = restoreEnclosingLabel; + function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { + var target = skipParentheses(node); + switch (target.kind) { + case 70: + return cacheIdentifiers; + case 98: + case 8: + case 9: + return false; + case 176: + var elements = target.elements; + if (elements.length === 0) { + return false; + } + return true; + case 177: + return target.properties.length > 0; + default: + return true; + } + } + function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { + var callee = skipOuterExpressions(expression, 7); + var thisArg; + var target; + if (ts.isSuperProperty(callee)) { + thisArg = ts.createThis(); + target = callee; + } + else if (callee.kind === 96) { + thisArg = ts.createThis(); + target = languageVersion < 2 + ? ts.setTextRange(ts.createIdentifier("_super"), callee) + : callee; + } + else { + switch (callee.kind) { + case 178: { + if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); + ts.setTextRange(target, callee); + } + else { + thisArg = callee.expression; + target = callee; + } + break; + } + case 179: { + if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); + ts.setTextRange(target, callee); + } + else { + thisArg = callee.expression; + target = callee; + } + break; + } + default: { + thisArg = ts.createVoidZero(); + target = parenthesizeForAccess(expression); + break; + } + } + } + return { target: target, thisArg: thisArg }; + } + ts.createCallBinding = createCallBinding; + function inlineExpressions(expressions) { + return ts.reduceLeft(expressions, ts.createComma); + } + ts.inlineExpressions = inlineExpressions; + function createExpressionFromEntityName(node) { + if (ts.isQualifiedName(node)) { + var left = createExpressionFromEntityName(node.left); + var right = ts.getMutableClone(node.right); + return ts.setTextRange(ts.createPropertyAccess(left, right), node); + } + else { + return ts.getMutableClone(node); + } + } + ts.createExpressionFromEntityName = createExpressionFromEntityName; + function createExpressionForPropertyName(memberName) { + if (ts.isIdentifier(memberName)) { + return ts.createLiteral(memberName); + } + else if (ts.isComputedPropertyName(memberName)) { + return ts.getMutableClone(memberName.expression); + } + else { + return ts.getMutableClone(memberName); + } + } + ts.createExpressionForPropertyName = createExpressionForPropertyName; + function createExpressionForObjectLiteralElementLike(node, property, receiver) { + switch (property.kind) { + case 152: + case 153: + return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); + case 260: + return createExpressionForPropertyAssignment(property, receiver); + case 261: + return createExpressionForShorthandPropertyAssignment(property, receiver); + case 150: + return createExpressionForMethodDeclaration(property, receiver); + } + } + ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike; + function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { + var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + if (property === firstAccessor) { + var properties_1 = []; + if (getAccessor) { + var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body); + ts.setTextRange(getterFunction, getAccessor); + ts.setOriginalNode(getterFunction, getAccessor); + var getter = ts.createPropertyAssignment("get", getterFunction); + properties_1.push(getter); + } + if (setAccessor) { + var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body); + ts.setTextRange(setterFunction, setAccessor); + ts.setOriginalNode(setterFunction, setAccessor); + var setter = ts.createPropertyAssignment("set", setterFunction); + properties_1.push(setter); + } + properties_1.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_1.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + receiver, + createExpressionForPropertyName(property.name), + ts.createObjectLiteral(properties_1, multiLine) + ]), firstAccessor); + return ts.aggregateTransformFlags(expression); + } + return undefined; + } + function createExpressionForPropertyAssignment(property, receiver) { + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), property.initializer), property), property)); + } + function createExpressionForShorthandPropertyAssignment(property, receiver) { + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), ts.getSynthesizedClone(property.name)), property), property)); + } + function createExpressionForMethodDeclaration(method, receiver) { + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body), method), method)), method), method)); + } + function getLocalName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 16384); + } + ts.getLocalName = getLocalName; + function isLocalName(node) { + return (ts.getEmitFlags(node) & 16384) !== 0; + } + ts.isLocalName = isLocalName; + function getExportName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 8192); + } + ts.getExportName = getExportName; + function isExportName(node) { + return (ts.getEmitFlags(node) & 8192) !== 0; + } + ts.isExportName = isExportName; + function getDeclarationName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps); + } + ts.getDeclarationName = getDeclarationName; + function getName(node, allowComments, allowSourceMaps, emitFlags) { + if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { + var name = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); + if (!allowSourceMaps) + emitFlags |= 48; + if (!allowComments) + emitFlags |= 1536; + if (emitFlags) + ts.setEmitFlags(name, emitFlags); + return name; + } + return ts.getGeneratedNameForNode(node); + } + function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { + if (ns && ts.hasModifier(node, 1)) { + return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); + } + return getExportName(node, allowComments, allowSourceMaps); + } + ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName; + function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { + var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name)); + ts.setTextRange(qualifiedName, name); + var emitFlags; + if (!allowSourceMaps) + emitFlags |= 48; + if (!allowComments) + emitFlags |= 1536; + if (emitFlags) + ts.setEmitFlags(qualifiedName, emitFlags); + return qualifiedName; + } + ts.getNamespaceMemberName = getNamespaceMemberName; + function convertToFunctionBody(node, multiLine) { + return ts.isBlock(node) ? node : ts.setTextRange(ts.createBlock([ts.setTextRange(ts.createReturn(node), node)], multiLine), node); + } + ts.convertToFunctionBody = convertToFunctionBody; + function isUseStrictPrologue(node) { + return node.expression.text === "use strict"; + } + function addPrologueDirectives(target, source, ensureUseStrict, visitor) { + ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); + var foundUseStrict = false; + var statementOffset = 0; + var numStatements = source.length; + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + } + target.push(statement); + } + else { + break; + } + statementOffset++; + } + if (ensureUseStrict && !foundUseStrict) { + target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))); + } + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (ts.getEmitFlags(statement) & 524288) { + target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); + } + else { + break; + } + statementOffset++; + } + return statementOffset; + } + ts.addPrologueDirectives = addPrologueDirectives; + function startsWithUseStrict(statements) { + var firstStatement = ts.firstOrUndefined(statements); + return firstStatement !== undefined + && ts.isPrologueDirective(firstStatement) + && isUseStrictPrologue(firstStatement); + } + ts.startsWithUseStrict = startsWithUseStrict; + function ensureUseStrict(statements) { + var foundUseStrict = false; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + break; + } + } + else { + break; + } + } + if (!foundUseStrict) { + return ts.setTextRange(ts.createNodeArray([ + startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) + ].concat(statements)), statements); + } + return statements; + } + ts.ensureUseStrict = ensureUseStrict; + function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { + var skipped = skipPartiallyEmittedExpressions(operand); + if (skipped.kind === 184) { + return operand; + } + return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) + ? ts.createParen(operand) + : operand; + } + ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; + function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { + var binaryOperatorPrecedence = ts.getOperatorPrecedence(193, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(193, binaryOperator); + var emittedOperand = skipPartiallyEmittedExpressions(operand); + var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); + switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { + case -1: + if (!isLeftSideOfBinary + && binaryOperatorAssociativity === 1 + && operand.kind === 196) { + return false; + } + return true; + case 1: + return false; + case 0: + if (isLeftSideOfBinary) { + return binaryOperatorAssociativity === 1; + } + else { + if (ts.isBinaryExpression(emittedOperand) + && emittedOperand.operatorToken.kind === binaryOperator) { + if (operatorHasAssociativeProperty(binaryOperator)) { + return false; + } + if (binaryOperator === 36) { + var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; + if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { + return false; + } + } + } + var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); + return operandAssociativity === 0; + } + } + } + function operatorHasAssociativeProperty(binaryOperator) { + return binaryOperator === 38 + || binaryOperator === 48 + || binaryOperator === 47 + || binaryOperator === 49; + } + function getLiteralKindOfBinaryPlusOperand(node) { + node = skipPartiallyEmittedExpressions(node); + if (ts.isLiteralKind(node.kind)) { + return node.kind; + } + if (node.kind === 193 && node.operatorToken.kind === 36) { + if (node.cachedLiteralKind !== undefined) { + return node.cachedLiteralKind; + } + var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); + var literalKind = ts.isLiteralKind(leftKind) + && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) + ? leftKind + : 0; + node.cachedLiteralKind = literalKind; + return literalKind; + } + return 0; + } + function parenthesizeForConditionalHead(condition) { + var conditionalPrecedence = ts.getOperatorPrecedence(194, 54); + var emittedCondition = skipPartiallyEmittedExpressions(condition); + var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { + return ts.createParen(condition); + } + return condition; + } + ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; + function parenthesizeSubexpressionOfConditionalExpression(e) { + return e.kind === 193 && e.operatorToken.kind === 25 + ? ts.createParen(e) + : e; + } + ts.parenthesizeSubexpressionOfConditionalExpression = parenthesizeSubexpressionOfConditionalExpression; + function parenthesizeForNew(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + switch (emittedExpression.kind) { + case 180: + return ts.createParen(expression); + case 181: + return emittedExpression.arguments + ? expression + : ts.createParen(expression); + } + return parenthesizeForAccess(expression); + } + ts.parenthesizeForNew = parenthesizeForNew; + function parenthesizeForAccess(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + if (ts.isLeftHandSideExpression(emittedExpression) + && (emittedExpression.kind !== 181 || emittedExpression.arguments) + && emittedExpression.kind !== 8) { + return expression; + } + return ts.setTextRange(ts.createParen(expression), expression); + } + ts.parenthesizeForAccess = parenthesizeForAccess; + function parenthesizePostfixOperand(operand) { + return ts.isLeftHandSideExpression(operand) + ? operand + : ts.setTextRange(ts.createParen(operand), operand); + } + ts.parenthesizePostfixOperand = parenthesizePostfixOperand; + function parenthesizePrefixOperand(operand) { + return ts.isUnaryExpression(operand) + ? operand + : ts.setTextRange(ts.createParen(operand), operand); + } + ts.parenthesizePrefixOperand = parenthesizePrefixOperand; + function parenthesizeListElements(elements) { + var result; + for (var i = 0; i < elements.length; i++) { + var element = parenthesizeExpressionForList(elements[i]); + if (result !== undefined || element !== elements[i]) { + if (result === undefined) { + result = elements.slice(0, i); + } + result.push(element); + } + } + if (result !== undefined) { + return ts.setTextRange(ts.createNodeArray(result, elements.hasTrailingComma), elements); + } + return elements; + } + ts.parenthesizeListElements = parenthesizeListElements; + function parenthesizeExpressionForList(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); + var commaPrecedence = ts.getOperatorPrecedence(193, 25); + return expressionPrecedence > commaPrecedence + ? expression + : ts.setTextRange(ts.createParen(expression), expression); + } + ts.parenthesizeExpressionForList = parenthesizeExpressionForList; + function parenthesizeExpressionForExpressionStatement(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + if (ts.isCallExpression(emittedExpression)) { + var callee = emittedExpression.expression; + var kind = skipPartiallyEmittedExpressions(callee).kind; + if (kind === 185 || kind === 186) { + var mutableCall = ts.getMutableClone(emittedExpression); + mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); + return recreatePartiallyEmittedExpressions(expression, mutableCall); + } + } + else { + var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; + if (leftmostExpressionKind === 177 || leftmostExpressionKind === 185) { + return ts.setTextRange(ts.createParen(expression), expression); + } + } + return expression; + } + ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; + function recreatePartiallyEmittedExpressions(originalOuterExpression, newInnerExpression) { + if (ts.isPartiallyEmittedExpression(originalOuterExpression)) { + var clone_1 = ts.getMutableClone(originalOuterExpression); + clone_1.expression = recreatePartiallyEmittedExpressions(clone_1.expression, newInnerExpression); + return clone_1; + } + return newInnerExpression; + } + function getLeftmostExpression(node) { + while (true) { + switch (node.kind) { + case 192: + node = node.operand; + continue; + case 193: + node = node.left; + continue; + case 194: + node = node.condition; + continue; + case 180: + case 179: + case 178: + node = node.expression; + continue; + case 298: + node = node.expression; + continue; + } + return node; + } + } + function parenthesizeConciseBody(body) { + var emittedBody = skipPartiallyEmittedExpressions(body); + if (emittedBody.kind === 177) { + return ts.setTextRange(ts.createParen(body), body); + } + return body; + } + ts.parenthesizeConciseBody = parenthesizeConciseBody; + var OuterExpressionKinds; + (function (OuterExpressionKinds) { + OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; + OuterExpressionKinds[OuterExpressionKinds["Assertions"] = 2] = "Assertions"; + OuterExpressionKinds[OuterExpressionKinds["PartiallyEmittedExpressions"] = 4] = "PartiallyEmittedExpressions"; + OuterExpressionKinds[OuterExpressionKinds["All"] = 7] = "All"; + })(OuterExpressionKinds = ts.OuterExpressionKinds || (ts.OuterExpressionKinds = {})); + function skipOuterExpressions(node, kinds) { + if (kinds === void 0) { kinds = 7; } + var previousNode; + do { + previousNode = node; + if (kinds & 1) { + node = skipParentheses(node); + } + if (kinds & 2) { + node = skipAssertions(node); + } + if (kinds & 4) { + node = skipPartiallyEmittedExpressions(node); + } + } while (previousNode !== node); return node; } - ts.setNodeFlags = setNodeFlags; - function setMultiLine(node, multiLine) { - node.multiLine = multiLine; + ts.skipOuterExpressions = skipOuterExpressions; + function skipParentheses(node) { + while (node.kind === 184) { + node = node.expression; + } return node; } - ts.setMultiLine = setMultiLine; - function setHasTrailingComma(nodes, hasTrailingComma) { - nodes.hasTrailingComma = hasTrailingComma; - return nodes; + ts.skipParentheses = skipParentheses; + function skipAssertions(node) { + while (ts.isAssertionExpression(node)) { + node = node.expression; + } + return node; } - ts.setHasTrailingComma = setHasTrailingComma; + ts.skipAssertions = skipAssertions; + function skipPartiallyEmittedExpressions(node) { + while (node.kind === 298) { + node = node.expression; + } + return node; + } + ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; + function startOnNewLine(node) { + node.startsOnNewLine = true; + return node; + } + ts.startOnNewLine = startOnNewLine; + function getExternalHelpersModuleName(node) { + var parseNode = ts.getOriginalNode(node, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return emitNode && emitNode.externalHelpersModuleName; + } + ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions) { + if (compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { + var externalHelpersModuleName = getExternalHelpersModuleName(node); + if (externalHelpersModuleName) { + return externalHelpersModuleName; + } + var helpers = ts.getEmitHelpers(node); + if (helpers) { + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!helper.scoped) { + var parseNode = ts.getOriginalNode(node, ts.isSourceFile); + var emitNode = ts.getOrCreateEmitNode(parseNode); + return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = ts.createUniqueName(ts.externalHelpersModuleNameText)); + } + } + } + } + } + ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_11 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_11) ? name_11 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 235 && node.importClause) { - return getGeneratedNameForNode(node); + if (node.kind === 237 && node.importClause) { + return ts.getGeneratedNameForNode(node); } - if (node.kind === 241 && node.moduleSpecifier) { - return getGeneratedNameForNode(node); + if (node.kind === 243 && node.moduleSpecifier) { + return ts.getGeneratedNameForNode(node); } return undefined; } @@ -12943,26 +14109,24 @@ var ts; if (moduleName.kind === 9) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) - || getSynthesizedClone(moduleName); + || ts.getSynthesizedClone(moduleName); } return undefined; } ts.getExternalModuleNameLiteral = getExternalModuleNameLiteral; function tryRenameExternalModule(moduleName, sourceFile) { - if (sourceFile.renamedDependencies && ts.hasProperty(sourceFile.renamedDependencies, moduleName.text)) { - return createLiteral(sourceFile.renamedDependencies[moduleName.text]); - } - return undefined; + var rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text); + return rename && ts.createLiteral(rename); } function tryGetModuleNameFromFile(file, host, options) { if (!file) { return undefined; } if (file.moduleName) { - return createLiteral(file.moduleName); + return ts.createLiteral(file.moduleName); } if (!ts.isDeclarationFile(file) && (options.out || options.outFile)) { - return createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); + return ts.createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); } return undefined; } @@ -12996,11 +14160,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 257: + case 260: return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 258: + case 261: return bindingElement.name; - case 259: + case 262: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -13016,11 +14180,11 @@ var ts; ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 144: - case 174: + case 145: + case 175: return bindingElement.dotDotDotToken; - case 196: - case 259: + case 197: + case 262: return bindingElement; } return undefined; @@ -13028,7 +14192,7 @@ var ts; ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement; function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 174: + case 175: if (bindingElement.propertyName) { var propertyName = bindingElement.propertyName; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -13036,7 +14200,7 @@ var ts; : propertyName; } break; - case 257: + case 260: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -13044,7 +14208,7 @@ var ts; : propertyName; } break; - case 259: + case 262: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -13058,11 +14222,11 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 172: case 173: - case 175: - return name.elements; + case 174: case 176: + return name.elements; + case 177: return name.properties; } } @@ -13071,10 +14235,12 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpread(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpread(element.name), element), element); } var expression = convertToAssignmentElementTarget(element.name); - return element.initializer ? setOriginalNode(createAssignment(expression, element.initializer, element), element) : expression; + return element.initializer + ? ts.setOriginalNode(ts.setTextRange(ts.createAssignment(expression, element.initializer), element), element) + : expression; } ts.Debug.assertNode(element, ts.isExpression); return element; @@ -13084,14 +14250,14 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpreadAssignment(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpreadAssignment(element.name), element), element); } if (element.propertyName) { var expression = convertToAssignmentElementTarget(element.name); - return setOriginalNode(createPropertyAssignment(element.propertyName, element.initializer ? createAssignment(expression, element.initializer) : expression, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createPropertyAssignment(element.propertyName, element.initializer ? ts.createAssignment(expression, element.initializer) : expression), element), element); } ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createShorthandPropertyAssignment(element.name, element.initializer, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createShorthandPropertyAssignment(element.name, element.initializer), element), element); } ts.Debug.assertNode(element, ts.isObjectLiteralElementLike); return element; @@ -13099,18 +14265,18 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 173: - case 175: - return convertToArrayAssignmentPattern(node); - case 172: + case 174: case 176: + return convertToArrayAssignmentPattern(node); + case 173: + case 177: return convertToObjectAssignmentPattern(node); } } ts.convertToAssignmentPattern = convertToAssignmentPattern; function convertToObjectAssignmentPattern(node) { if (ts.isObjectBindingPattern(node)) { - return setOriginalNode(createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isObjectLiteralExpression); return node; @@ -13118,7 +14284,7 @@ var ts; ts.convertToObjectAssignmentPattern = convertToObjectAssignmentPattern; function convertToArrayAssignmentPattern(node) { if (ts.isArrayBindingPattern(node)) { - return setOriginalNode(createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isArrayLiteralExpression); return node; @@ -13134,30 +14300,30 @@ var ts; ts.convertToAssignmentElementTarget = convertToAssignmentElementTarget; function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) { var externalImports = []; - var exportSpecifiers = ts.createMap(); - var exportedBindings = ts.createMap(); + var exportSpecifiers = ts.createMultiMap(); + var exportedBindings = []; var uniqueExports = ts.createMap(); var exportedNames; var hasExportDefault = false; var exportEquals = undefined; var hasExportStarsToExportValues = false; var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions); - var externalHelpersImportDeclaration = externalHelpersModuleName && createImportDeclaration(undefined, undefined, createImportClause(undefined, createNamespaceImport(externalHelpersModuleName)), createLiteral(ts.externalHelpersModuleNameText)); + var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); if (externalHelpersImportDeclaration) { externalImports.push(externalHelpersImportDeclaration); } for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 235: + case 237: externalImports.push(node); break; - case 234: - if (node.moduleReference.kind === 245) { + case 236: + if (node.moduleReference.kind === 247) { externalImports.push(node); } break; - case 241: + case 243: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -13170,26 +14336,26 @@ var ts; else { for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - if (!uniqueExports[specifier.name.text]) { - var name_12 = specifier.propertyName || specifier.name; - ts.multiMapAdd(exportSpecifiers, name_12.text, specifier); - var decl = resolver.getReferencedImportDeclaration(name_12) - || resolver.getReferencedValueDeclaration(name_12); + if (!uniqueExports.get(specifier.name.text)) { + var name = specifier.propertyName || specifier.name; + exportSpecifiers.add(name.text, specifier); + var decl = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); if (decl) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); } - uniqueExports[specifier.name.text] = true; + uniqueExports.set(specifier.name.text, true); exportedNames = ts.append(exportedNames, specifier.name); } } } break; - case 240: + case 242: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 205: + case 207: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -13197,38 +14363,38 @@ var ts; } } break; - case 225: + case 227: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { - var name_13 = node.name; - if (!uniqueExports[name_13.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_13); - uniqueExports[name_13.text] = true; - exportedNames = ts.append(exportedNames, name_13); + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); } } } break; - case 226: + case 228: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { - var name_14 = node.name; - if (!uniqueExports[name_14.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_14); - uniqueExports[name_14.text] = true; - exportedNames = ts.append(exportedNames, name_14); + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); } } } @@ -13248,13 +14414,23 @@ var ts; } } else if (!ts.isGeneratedIdentifier(decl.name)) { - if (!uniqueExports[decl.name.text]) { - uniqueExports[decl.name.text] = true; + if (!uniqueExports.get(decl.name.text)) { + uniqueExports.set(decl.name.text, true); exportedNames = ts.append(exportedNames, decl.name); } } return exportedNames; } + function multiMapSparseArrayAdd(map, key, value) { + var values = map[key]; + if (values) { + values.push(value); + } + else { + map[key] = values = [value]; + } + return values; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -13263,13 +14439,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 261) { + if (kind === 264) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 141) { + else if (kind < 142) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -13305,28 +14481,29 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 141: + case 142: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 143: + case 144: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || + visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 258: + case 261: 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 259: + case 262: return visitNode(cbNode, node.expression); - case 144: + case 145: + case 148: case 147: - case 146: - case 257: - case 223: - case 174: + case 260: + case 225: + case 175: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -13335,24 +14512,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 158: case 159: - case 153: + case 160: case 154: case 155: + case 156: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 184: - case 225: + case 153: case 185: + case 227: + case 186: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -13363,320 +14540,325 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 157: + case 158: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 156: + case 157: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 160: - return visitNode(cbNode, node.exprName); case 161: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 162: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 163: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 164: + return visitNodes(cbNodes, node.elementTypes); case 165: - return visitNodes(cbNodes, node.types); case 166: - case 168: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); + case 167: case 169: + return visitNode(cbNode, node.type); + case 170: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 170: + case 171: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 171: - return visitNode(cbNode, node.literal); case 172: + return visitNode(cbNode, node.literal); case 173: - return visitNodes(cbNodes, node.elements); - case 175: + case 174: return visitNodes(cbNodes, node.elements); case 176: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 177: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.name); + return visitNodes(cbNodes, node.properties); case 178: return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); + visitNode(cbNode, node.name); case 179: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); case 180: + case 181: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 181: + case 182: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 182: + case 183: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 183: - return visitNode(cbNode, node.expression); - case 186: + case 184: return visitNode(cbNode, node.expression); case 187: return visitNode(cbNode, node.expression); case 188: return visitNode(cbNode, node.expression); - case 190: - return visitNode(cbNode, node.operand); - case 195: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 189: return visitNode(cbNode, node.expression); case 191: return visitNode(cbNode, node.operand); + case 196: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 190: + return visitNode(cbNode, node.expression); case 192: + return visitNode(cbNode, node.operand); + case 193: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 200: + case 201: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 201: + case 202: return visitNode(cbNode, node.expression); - case 193: + case 203: + return visitNode(cbNode, node.name); + case 194: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 196: + case 197: return visitNode(cbNode, node.expression); - case 204: - case 231: + case 206: + case 233: return visitNodes(cbNodes, node.statements); - case 261: + case 264: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 205: + case 207: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 224: + case 226: return visitNodes(cbNodes, node.declarations); - case 207: + case 209: return visitNode(cbNode, node.expression); - case 208: + case 210: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 209: + case 211: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 210: + case 212: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 211: + case 213: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 212: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 213: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 214: - case 215: - return visitNode(cbNode, node.label); - case 216: - return visitNode(cbNode, node.expression); - case 217: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 215: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 216: + case 217: + return visitNode(cbNode, node.label); case 218: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 232: - return visitNodes(cbNodes, node.clauses); - case 253: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 254: - return visitNodes(cbNodes, node.statements); + return visitNode(cbNode, node.expression); case 219: - return visitNode(cbNode, node.label) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 220: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 234: + return visitNodes(cbNodes, node.clauses); + case 256: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 257: + return visitNodes(cbNodes, node.statements); case 221: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 222: + return visitNode(cbNode, node.expression); + case 223: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 256: + case 259: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 145: + case 146: return visitNode(cbNode, node.expression); - case 226: - case 197: - 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 227: - 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 228: + case 198: 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 229: 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 260: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); case 230: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 231: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 263: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 232: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 234: + case 236: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 235: + case 237: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 236: + case 238: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 233: + case 235: return visitNode(cbNode, node.name); - case 237: + case 239: return visitNode(cbNode, node.name); - case 238: - case 242: + case 240: + case 244: return visitNodes(cbNodes, node.elements); - case 241: + case 243: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 239: - case 243: + case 241: + case 245: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 240: + case 242: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 194: + case 195: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 202: + case 204: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 142: + case 143: return visitNode(cbNode, node.expression); - case 255: + case 258: return visitNodes(cbNodes, node.types); - case 199: + case 200: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 245: + case 247: return visitNode(cbNode, node.expression); - case 244: - return visitNodes(cbNodes, node.decorators); case 246: + return visitNodes(cbNodes, node.decorators); + case 248: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 247: - case 248: - return visitNode(cbNode, node.tagName) || - visitNodes(cbNodes, node.attributes); + case 249: case 250: + return visitNode(cbNode, node.tagName) || + visitNode(cbNode, node.attributes); + case 253: + return visitNodes(cbNodes, node.properties); + case 252: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); + case 254: + return visitNode(cbNode, node.expression); + case 255: + return visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.expression); case 251: - return visitNode(cbNode, node.expression); - case 252: - return visitNode(cbNode, node.expression); - case 249: return visitNode(cbNode, node.tagName); - case 262: - return visitNode(cbNode, node.type); case 266: - return visitNodes(cbNodes, node.types); - case 267: - return visitNodes(cbNodes, node.types); - case 265: - return visitNode(cbNode, node.elementType); - case 269: - return visitNode(cbNode, node.type); - case 268: return visitNode(cbNode, node.type); case 270: - return visitNode(cbNode, node.literal); - case 272: - return visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeArguments); + return visitNodes(cbNodes, node.types); + case 271: + return visitNodes(cbNodes, node.types); + case 269: + return visitNode(cbNode, node.elementType); case 273: return visitNode(cbNode, node.type); + case 272: + return visitNode(cbNode, node.type); case 274: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 275: - return visitNode(cbNode, node.type); + return visitNode(cbNode, node.literal); case 276: - return visitNode(cbNode, node.type); + return visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeArguments); case 277: return visitNode(cbNode, node.type); - case 271: + case 278: + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 279: + return visitNode(cbNode, node.type); + case 280: + return visitNode(cbNode, node.type); + case 281: + return visitNode(cbNode, node.type); + case 275: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 278: + case 282: return visitNodes(cbNodes, node.tags); - case 281: + case 285: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 282: + case 286: return visitNode(cbNode, node.typeExpression); - case 283: - return visitNode(cbNode, node.typeExpression); - case 280: + case 287: return visitNode(cbNode, node.typeExpression); case 284: + return visitNode(cbNode, node.typeExpression); + case 288: return visitNodes(cbNodes, node.typeParameters); - case 285: + case 289: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 287: + case 291: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 286: + case 290: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 294: + case 298: return visitNode(cbNode, node.expression); - case 288: + case 292: return visitNode(cbNode, node.literal); } } @@ -13840,7 +15022,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(261, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(264, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -14067,7 +15249,7 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 141 ? new NodeConstructor(kind, pos, pos) : + return kind >= 142 ? new NodeConstructor(kind, pos, pos) : kind === 70 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } @@ -14104,7 +15286,11 @@ var ts; } function internIdentifier(text) { text = ts.escapeIdentifier(text); - return identifiers[text] || (identifiers[text] = text); + var identifier = identifiers.get(text); + if (identifier === undefined) { + identifiers.set(text, identifier = text); + } + return identifier; } function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; @@ -14149,7 +15335,7 @@ var ts; return token() === 9 || token() === 8 || ts.tokenIsIdentifierOrKeyword(token()); } function parseComputedPropertyName() { - var node = createNode(142); + var node = createNode(143); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); @@ -14454,14 +15640,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 150: - case 155: case 151: + case 156: case 152: - case 147: - case 203: + case 153: + case 148: + case 205: return true; - case 149: + case 150: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 70 && methodDeclaration.name.originalKeywordKind === 122; @@ -14473,8 +15659,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 253: - case 254: + case 256: + case 257: return true; } } @@ -14483,65 +15669,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 225: - case 205: - case 204: - case 208: + case 227: case 207: - case 220: - case 216: - case 218: - case 215: - case 214: - case 212: - case 213: - case 211: - case 210: - case 217: case 206: - case 221: - case 219: + case 210: case 209: case 222: - case 235: - case 234: - case 241: - case 240: - case 230: - case 226: - case 227: - case 229: + case 218: + case 220: + case 217: + case 216: + case 214: + case 215: + case 213: + case 212: + case 219: + case 208: + case 223: + case 221: + case 211: + case 224: + case 237: + case 236: + case 243: + case 242: + case 232: case 228: + case 229: + case 231: + case 230: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 260; + return node.kind === 263; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 154: - case 148: case 155: - case 146: - case 153: + case 149: + case 156: + case 147: + case 154: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 223) { + if (node.kind !== 225) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 144) { + if (node.kind !== 145) { return false; } var parameter = node; @@ -14637,7 +15823,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(22)) { - var node = createNode(141, entity.pos); + var node = createNode(142, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -14654,7 +15840,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(194); + var template = createNode(195); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -14666,7 +15852,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(202); + var span = createNode(204); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17) { @@ -14714,7 +15900,7 @@ var ts; } function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(157, typeName.pos); + var node = createNode(158, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token() === 26) { node.typeArguments = parseBracketedList(19, parseType, 26, 28); @@ -14723,24 +15909,24 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(156, lhs.pos); + var node = createNode(157, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(167); + var node = createNode(168); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(160); + var node = createNode(161); parseExpected(102); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(143); + var node = createNode(144); node.name = parseIdentifier(); if (parseOptional(84)) { if (isStartOfType() || !isStartOfExpression()) { @@ -14750,6 +15936,9 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } + if (parseOptional(57)) { + node.default = parseType(); + } return finishNode(node); } function parseTypeParameters() { @@ -14767,7 +15956,7 @@ var ts; return token() === 23 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 || token() === 98; } function parseParameter() { - var node = createNode(144); + var node = createNode(145); if (token() === 98) { node.name = createIdentifier(true, undefined); node.type = parseParameterType(); @@ -14827,7 +16016,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 154) { + if (kind === 155) { parseExpected(93); } fillSignature(55, false, false, false, node); @@ -14867,7 +16056,7 @@ var ts; return token() === 55 || token() === 25 || token() === 21; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(155, fullStart); + var node = createNode(156, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.parameters = parseBracketedList(16, parseParameter, 20, 21); @@ -14879,7 +16068,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(54); if (token() === 18 || token() === 26) { - var method = createNode(148, fullStart); + var method = createNode(149, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; @@ -14888,7 +16077,7 @@ var ts; return addJSDocComment(finishNode(method)); } else { - var property = createNode(146, fullStart); + var property = createNode(147, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; @@ -14928,10 +16117,10 @@ var ts; } function parseTypeMember() { if (token() === 18 || token() === 26) { - return parseSignatureMember(153); + return parseSignatureMember(154); } if (token() === 93 && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(154); + return parseSignatureMember(155); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -14945,7 +16134,7 @@ var ts; return token() === 18 || token() === 26; } function parseTypeLiteral() { - var node = createNode(161); + var node = createNode(162); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -14968,14 +16157,14 @@ var ts; return token() === 20 && nextTokenIsIdentifier() && nextToken() === 91; } function parseMappedTypeParameter() { - var node = createNode(143); + var node = createNode(144); node.name = parseIdentifier(); parseExpected(91); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(170); + var node = createNode(171); parseExpected(16); node.readonlyToken = parseOptionalToken(130); parseExpected(20); @@ -14988,12 +16177,12 @@ var ts; return finishNode(node); } function parseTupleType() { - var node = createNode(163); + var node = createNode(164); node.elementTypes = parseBracketedList(20, parseType, 20, 21); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(166); + var node = createNode(167); parseExpected(18); node.type = parseType(); parseExpected(19); @@ -15001,7 +16190,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 159) { + if (kind === 160) { parseExpected(93); } fillSignature(35, false, false, false, node); @@ -15012,7 +16201,7 @@ var ts; return token() === 22 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(171); + var node = createNode(172); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -15023,12 +16212,13 @@ var ts; function parseNonArrayType() { switch (token()) { case 118: - case 134: + case 135: case 132: case 121: - case 135: - case 137: + case 136: + case 138: case 129: + case 133: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: @@ -15065,12 +16255,12 @@ var ts; function isStartOfType() { switch (token()) { case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 136: case 104: - case 137: + case 138: case 94: case 98: case 102: @@ -15085,6 +16275,7 @@ var ts; case 8: case 100: case 85: + case 133: return true; case 37: return lookAhead(nextTokenIsNumericLiteral); @@ -15102,14 +16293,14 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(20)) { if (isStartOfType()) { - var node = createNode(169, type.pos); + var node = createNode(170, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(21); type = finishNode(node); } else { - var node = createNode(162, type.pos); + var node = createNode(163, type.pos); node.elementType = type; parseExpected(21); type = finishNode(node); @@ -15118,7 +16309,7 @@ var ts; return type; } function parseTypeOperator(operator) { - var node = createNode(168); + var node = createNode(169); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); @@ -15147,10 +16338,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(165, parseTypeOperatorOrHigher, 47); + return parseUnionOrIntersectionType(166, parseTypeOperatorOrHigher, 47); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(164, parseIntersectionTypeOrHigher, 48); + return parseUnionOrIntersectionType(165, parseIntersectionTypeOrHigher, 48); } function isStartOfFunctionType() { if (token() === 26) { @@ -15196,7 +16387,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(156, typePredicateVariable.pos); + var node = createNode(157, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -15217,10 +16408,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(158); + return parseFunctionOrConstructorType(159); } if (token() === 93) { - return parseFunctionOrConstructorType(159); + return parseFunctionOrConstructorType(160); } return parseUnionTypeOrHigher(); } @@ -15339,7 +16530,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(195); + var node = createNode(196); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 38 || isStartOfExpression())) { @@ -15355,13 +16546,13 @@ var ts; ts.Debug.assert(token() === 35, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(185, asyncModifier.pos); + node = createNode(186, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(185, identifier.pos); + node = createNode(186, identifier.pos); } - var parameter = createNode(144, identifier.pos); + var parameter = createNode(145, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); @@ -15495,7 +16686,7 @@ var ts; return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(185); + var node = createNode(186); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); fillSignature(55, false, isAsync, !allowAmbiguity, node); @@ -15527,7 +16718,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(193, leftOperand.pos); + var node = createNode(194, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -15540,7 +16731,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 || t === 140; + return t === 91 || t === 141; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -15618,43 +16809,43 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(192, left.pos); + var node = createNode(193, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(200, left.pos); + var node = createNode(201, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(190); + var node = createNode(191); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(186); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(187); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(188); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(189); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { if (token() === 120) { if (inAwaitContext()) { @@ -15665,7 +16856,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(189); + var node = createNode(190); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15681,7 +16872,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === 39) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 182) { + if (simpleUnaryExpression.kind === 183) { 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 { @@ -15734,7 +16925,7 @@ var ts; } function parseIncrementExpression() { if (token() === 42 || token() === 43) { - var node = createNode(190); + var node = createNode(191); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -15746,7 +16937,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 42 || token() === 43) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(191, expression.pos); + var node = createNode(192, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -15769,7 +16960,7 @@ var ts; if (token() === 18 || token() === 22 || token() === 20) { return expression; } - var node = createNode(177, expression.pos); + var node = createNode(178, expression.pos); node.expression = expression; parseExpectedToken(22, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -15791,8 +16982,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 248) { - var node = createNode(246, opening.pos); + if (opening.kind === 250) { + var node = createNode(248, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -15802,14 +16993,14 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 247); + ts.Debug.assert(opening.kind === 249); result = opening; } if (inExpressionContext && token() === 26) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(192, result.pos); + var badNode = createNode(193, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -15855,14 +17046,19 @@ var ts; parsingContext = saveParsingContext; return result; } + function parseJsxAttributes() { + var jsxAttributes = createNode(253); + jsxAttributes.properties = parseList(13, parseJsxAttribute); + return finishNode(jsxAttributes); + } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); parseExpected(26); var tagName = parseJsxElementName(); - var attributes = parseList(13, parseJsxAttribute); + var attributes = parseJsxAttributes(); var node; if (token() === 28) { - node = createNode(248, fullStart); + node = createNode(250, fullStart); scanJsxText(); } else { @@ -15874,7 +17070,7 @@ var ts; parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(247, fullStart); + node = createNode(249, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -15885,7 +17081,7 @@ var ts; var expression = token() === 98 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22)) { - var propertyAccess = createNode(177, expression.pos); + var propertyAccess = createNode(178, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -15893,9 +17089,10 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(252); + var node = createNode(255); parseExpected(16); if (token() !== 17) { + node.dotDotDotToken = parseOptionalToken(23); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { @@ -15912,7 +17109,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(250); + var node = createNode(252); node.name = parseIdentifierName(); if (token() === 57) { switch (scanJsxAttributeValue()) { @@ -15927,7 +17124,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(251); + var node = createNode(254); parseExpected(16); parseExpected(23); node.expression = parseExpression(); @@ -15935,7 +17132,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(249); + var node = createNode(251); parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -15948,7 +17145,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(182); + var node = createNode(183); parseExpected(26); node.type = parseType(); parseExpected(28); @@ -15959,7 +17156,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22); if (dotToken) { - var propertyAccess = createNode(177, expression.pos); + var propertyAccess = createNode(178, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -15967,13 +17164,13 @@ var ts; } if (token() === 50 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(201, expression.pos); + var nonNullExpression = createNode(202, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } if (!inDecoratorContext() && parseOptional(20)) { - var indexedAccess = createNode(178, expression.pos); + var indexedAccess = createNode(179, expression.pos); indexedAccess.expression = expression; if (token() !== 21) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -15987,7 +17184,7 @@ var ts; continue; } if (token() === 12 || token() === 13) { - var tagExpression = createNode(181, expression.pos); + var tagExpression = createNode(182, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 ? parseLiteralNode() @@ -16006,7 +17203,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(179, expression.pos); + var callExpr = createNode(180, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -16014,7 +17211,7 @@ var ts; continue; } else if (token() === 18) { - var callExpr = createNode(179, expression.pos); + var callExpr = createNode(180, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -16109,28 +17306,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(183); + var node = createNode(184); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); return finishNode(node); } function parseSpreadElement() { - var node = createNode(196); + var node = createNode(197); parseExpected(23); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 23 ? parseSpreadElement() : - token() === 25 ? createNode(198) : + token() === 25 ? createNode(199) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(175); + var node = createNode(176); parseExpected(20); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16141,18 +17338,18 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(124)) { - return parseAccessorDeclaration(151, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(133)) { return parseAccessorDeclaration(152, fullStart, decorators, modifiers); } + else if (parseContextualModifier(134)) { + return parseAccessorDeclaration(153, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23); if (dotDotDotToken) { - var spreadElement = createNode(259, fullStart); + var spreadElement = createNode(262, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -16171,7 +17368,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(258, fullStart); + var shorthandDeclaration = createNode(261, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57); @@ -16182,7 +17379,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(257, fullStart); + var propertyAssignment = createNode(260, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -16192,7 +17389,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(176); + var node = createNode(177); parseExpected(16); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16206,7 +17403,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(184); + var node = createNode(185); node.modifiers = parseModifiers(); parseExpected(88); node.asteriskToken = parseOptionalToken(38); @@ -16228,8 +17425,15 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(180); + var fullStart = scanner.getStartPos(); parseExpected(93); + if (parseOptional(22)) { + var node_1 = createNode(203, fullStart); + node_1.keywordToken = 93; + node_1.name = parseIdentifierName(); + return finishNode(node_1); + } + var node = createNode(181, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18) { @@ -16238,7 +17442,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(204); + var node = createNode(206); if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16269,12 +17473,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(206); + var node = createNode(208); parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(208); + var node = createNode(210); parseExpected(89); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16284,7 +17488,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(209); + var node = createNode(211); parseExpected(80); node.statement = parseStatement(); parseExpected(105); @@ -16295,7 +17499,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(210); + var node = createNode(212); parseExpected(105); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16318,21 +17522,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91)) { - var forInStatement = createNode(212, pos); + var forInStatement = createNode(214, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(140)) { - var forOfStatement = createNode(213, pos); + else if (parseOptional(141)) { + var forOfStatement = createNode(215, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(211, pos); + var forStatement = createNode(213, pos); forStatement.initializer = initializer; parseExpected(24); if (token() !== 24 && token() !== 19) { @@ -16350,7 +17554,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 215 ? 71 : 76); + parseExpected(kind === 217 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16358,7 +17562,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(216); + var node = createNode(218); parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -16367,7 +17571,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(217); + var node = createNode(219); parseExpected(106); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -16376,7 +17580,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(253); + var node = createNode(256); parseExpected(72); node.expression = allowInAnd(parseExpression); parseExpected(55); @@ -16384,7 +17588,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(254); + var node = createNode(257); parseExpected(78); parseExpected(55); node.statements = parseList(3, parseStatement); @@ -16394,12 +17598,12 @@ var ts; return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(218); + var node = createNode(220); parseExpected(97); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); - var caseBlock = createNode(232, scanner.getStartPos()); + var caseBlock = createNode(234, scanner.getStartPos()); parseExpected(16); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(17); @@ -16407,14 +17611,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(220); + var node = createNode(222); parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(221); + var node = createNode(223); parseExpected(101); node.tryBlock = parseBlock(false); node.catchClause = token() === 73 ? parseCatchClause() : undefined; @@ -16425,7 +17629,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(256); + var result = createNode(259); parseExpected(73); if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); @@ -16435,7 +17639,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(222); + var node = createNode(224); parseExpected(77); parseSemicolon(); return finishNode(node); @@ -16444,13 +17648,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 && parseOptional(55)) { - var labeledStatement = createNode(219, fullStart); + var labeledStatement = createNode(221, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(207, fullStart); + var expressionStatement = createNode(209, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -16479,7 +17683,7 @@ var ts; case 82: return true; case 108: - case 136: + case 137: return nextTokenIsIdentifierOnSameLine(); case 127: case 128: @@ -16496,7 +17700,7 @@ var ts; return false; } continue; - case 139: + case 140: nextToken(); return token() === 16 || token() === 70 || token() === 83; case 90: @@ -16556,8 +17760,8 @@ var ts; case 108: case 127: case 128: - case 136: - case 139: + case 137: + case 140: return true; case 113: case 111: @@ -16602,9 +17806,9 @@ var ts; case 87: return parseForOrForInOrForOfStatement(); case 76: - return parseBreakOrContinueStatement(214); + return parseBreakOrContinueStatement(216); case 71: - return parseBreakOrContinueStatement(215); + return parseBreakOrContinueStatement(217); case 95: return parseReturnStatement(); case 106: @@ -16623,7 +17827,7 @@ var ts; return parseDeclaration(); case 119: case 108: - case 136: + case 137: case 127: case 128: case 123: @@ -16637,7 +17841,7 @@ var ts; case 116: case 114: case 130: - case 139: + case 140: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -16660,11 +17864,11 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 108: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 136: + case 137: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 82: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 139: + case 140: case 127: case 128: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -16683,7 +17887,7 @@ var ts; } default: if (decorators || modifiers) { - var node = createMissingNode(244, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(246, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -16704,16 +17908,16 @@ var ts; } function parseArrayBindingElement() { if (token() === 25) { - return createNode(198); + return createNode(199); } - var node = createNode(174); + var node = createNode(175); node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(174); + var node = createNode(175); node.dotDotDotToken = parseOptionalToken(23); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -16729,14 +17933,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(172); + var node = createNode(173); parseExpected(16); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(17); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(173); + var node = createNode(174); parseExpected(20); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(21); @@ -16755,7 +17959,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(223); + var node = createNode(225); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -16764,7 +17968,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(224); + var node = createNode(226); switch (token()) { case 103: break; @@ -16778,7 +17982,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token() === 140 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 141 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -16793,7 +17997,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(205, fullStart); + var node = createNode(207, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -16801,7 +18005,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(227, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88); @@ -16814,7 +18018,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(150, pos); + var node = createNode(151, pos); node.decorators = decorators; node.modifiers = modifiers; parseExpected(122); @@ -16823,7 +18027,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(149, fullStart); + var method = createNode(150, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -16836,7 +18040,7 @@ var ts; return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(147, fullStart); + var property = createNode(148, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -16906,7 +18110,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 133 || idToken === 124) { + if (!ts.isKeyword(idToken) || idToken === 134 || idToken === 124) { return true; } switch (token()) { @@ -16929,7 +18133,7 @@ var ts; if (!parseOptional(56)) { break; } - var decorator = createNode(145, decoratorStart); + var decorator = createNode(146, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -16986,7 +18190,7 @@ var ts; } function parseClassElement() { if (token() === 24) { - var result = createNode(203); + var result = createNode(205); nextToken(); return finishNode(result); } @@ -17011,16 +18215,16 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_15 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_15, undefined); + var name = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 197); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 198); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 228); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -17055,7 +18259,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 || token() === 107) { - var node = createNode(255); + var node = createNode(258); node.token = token(); nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -17064,7 +18268,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(199); + var node = createNode(200); node.expression = parseLeftHandSideExpressionOrHigher(); if (token() === 26) { node.typeArguments = parseBracketedList(19, parseType, 26, 28); @@ -17078,7 +18282,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227, fullStart); + var node = createNode(229, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108); @@ -17089,10 +18293,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(136); + parseExpected(137); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57); @@ -17101,13 +18305,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(260, scanner.getStartPos()); + var node = createNode(263, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82); @@ -17122,7 +18326,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(231, scanner.getStartPos()); + var node = createNode(233, scanner.getStartPos()); if (parseExpected(16)) { node.statements = parseList(1, parseStatement); parseExpected(17); @@ -17133,7 +18337,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(230, fullStart); + var node = createNode(232, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; @@ -17145,10 +18349,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(232, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 139) { + if (token() === 140) { node.name = parseIdentifier(); node.flags |= 512; } @@ -17165,7 +18369,7 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 139) { + if (token() === 140) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } else if (parseOptional(128)) { @@ -17190,7 +18394,7 @@ var ts; return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(233, fullStart); + var exportDeclaration = createNode(235, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117); @@ -17205,8 +18409,8 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 && token() !== 138) { - var importEqualsDeclaration = createNode(234, fullStart); + if (token() !== 25 && token() !== 139) { + var importEqualsDeclaration = createNode(236, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -17216,27 +18420,27 @@ var ts; return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(235, fullStart); + var importDeclaration = createNode(237, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || token() === 38 || token() === 16) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(138); + parseExpected(139); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(236, fullStart); + var importClause = createNode(238, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(238); + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(240); } return finishNode(importClause); } @@ -17246,7 +18450,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(245); + var node = createNode(247); parseExpected(131); parseExpected(18); node.expression = parseModuleSpecifier(); @@ -17264,7 +18468,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(237); + var namespaceImport = createNode(239); parseExpected(38); parseExpected(117); namespaceImport.name = parseIdentifier(); @@ -17272,14 +18476,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 238 ? parseImportSpecifier : parseExportSpecifier, 16, 17); + node.elements = parseBracketedList(22, kind === 240 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(243); + return parseImportOrExportSpecifier(245); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(239); + return parseImportOrExportSpecifier(241); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17298,23 +18502,23 @@ var ts; else { node.name = identifierName; } - if (kind === 239 && checkIdentifierIsKeyword) { + if (kind === 241 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(241, fullStart); + var node = createNode(243, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38)) { - parseExpected(138); + parseExpected(139); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(242); - if (token() === 138 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(138); + node.exportClause = parseNamedImportsOrExports(244); + if (token() === 139 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(139); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -17322,7 +18526,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(240, fullStart); + var node = createNode(242, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57)) { @@ -17401,14 +18605,51 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 234 && node.moduleReference.kind === 245 - || node.kind === 235 - || node.kind === 240 - || node.kind === 241 + || node.kind === 236 && node.moduleReference.kind === 247 + || node.kind === 237 + || node.kind === 242 + || node.kind === 243 ? node : undefined; }); } + var ParsingContext; + (function (ParsingContext) { + ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; + ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; + ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; + ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; + ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; + ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; + ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; + ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; + ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; + ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; + ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; + ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; + ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; + ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes"; + ParsingContext[ParsingContext["JsxChildren"] = 14] = "JsxChildren"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 16] = "Parameters"; + ParsingContext[ParsingContext["RestProperties"] = 17] = "RestProperties"; + ParsingContext[ParsingContext["TypeParameters"] = 18] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 19] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 20] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 21] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 22] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["JSDocFunctionParameters"] = 23] = "JSDocFunctionParameters"; + ParsingContext[ParsingContext["JSDocTypeArguments"] = 24] = "JSDocTypeArguments"; + ParsingContext[ParsingContext["JSDocRecordMembers"] = 25] = "JSDocRecordMembers"; + ParsingContext[ParsingContext["JSDocTupleTypes"] = 26] = "JSDocTupleTypes"; + ParsingContext[ParsingContext["Count"] = 27] = "Count"; + })(ParsingContext || (ParsingContext = {})); + var Tristate; + (function (Tristate) { + Tristate[Tristate["False"] = 0] = "False"; + Tristate[Tristate["True"] = 1] = "True"; + Tristate[Tristate["Unknown"] = 2] = "Unknown"; + })(Tristate || (Tristate = {})); var JSDocParser; (function (JSDocParser) { function isJSDocType() { @@ -17440,7 +18681,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(262, scanner.getTokenPos()); + var result = createNode(266, scanner.getTokenPos()); parseExpected(16); result.type = parseJSDocTopLevelType(); parseExpected(17); @@ -17451,12 +18692,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48) { - var unionType = createNode(266, type.pos); + var unionType = createNode(270, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57) { - var optionalType = createNode(273, type.pos); + var optionalType = createNode(277, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -17467,20 +18708,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20) { - var arrayType = createNode(265, type.pos); + var arrayType = createNode(269, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21); type = finishNode(arrayType); } else if (token() === 54) { - var nullableType = createNode(268, type.pos); + var nullableType = createNode(272, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50) { - var nonNullableType = createNode(269, type.pos); + var nonNullableType = createNode(273, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -17514,14 +18755,15 @@ var ts; case 98: return parseJSDocThisType(); case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 136: case 104: case 94: - case 137: + case 138: case 129: + case 133: return parseTokenNode(); case 9: case 8: @@ -17532,27 +18774,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(277); + var result = createNode(281); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(276); + var result = createNode(280); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(275); + var result = createNode(279); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(274); + var result = createNode(278); nextToken(); parseExpected(18); result.parameters = parseDelimitedList(23, parseJSDocParameter); @@ -17565,7 +18807,7 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(144); + var parameter = createNode(145); parameter.type = parseJSDocType(); if (parseOptional(57)) { parameter.questionToken = createNode(57); @@ -17573,7 +18815,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(272); + var result = createNode(276); result.name = parseSimplePropertyName(); if (token() === 26) { result.typeArguments = parseTypeArguments(); @@ -17607,24 +18849,24 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(141, left.pos); + var result = createNode(142, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(270); + var result = createNode(274); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(269); + var result = createNode(273); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(267); + var result = createNode(271); nextToken(); result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); @@ -17638,7 +18880,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(266); + var result = createNode(270); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19); @@ -17654,12 +18896,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(263); + var result = createNode(267); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(288); + var result = createNode(292); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -17672,11 +18914,11 @@ var ts; token() === 28 || token() === 57 || token() === 48) { - var result = createNode(264, pos); + var result = createNode(268, pos); return finishNode(result); } else { - var result = createNode(268, pos); + var result = createNode(272, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -17704,6 +18946,12 @@ var ts; return comment; } JSDocParser.parseJSDocComment = parseJSDocComment; + var JSDocState; + (function (JSDocState) { + JSDocState[JSDocState["BeginningOfLine"] = 0] = "BeginningOfLine"; + JSDocState[JSDocState["SawAsterisk"] = 1] = "SawAsterisk"; + JSDocState[JSDocState["SavingComments"] = 2] = "SavingComments"; + })(JSDocState || (JSDocState = {})); function parseJSDocCommentWorker(start, length) { var content = sourceText; start = start || 0; @@ -17820,7 +19068,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(278, start); + var result = createNode(282, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -17930,7 +19178,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(279, atToken.pos); + var result = createNode(283, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -17985,7 +19233,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(281, atToken.pos); + var result = createNode(285, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -17996,20 +19244,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 282; })) { + if (ts.forEach(tags, function (t) { return t.kind === 286; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(282, atToken.pos); + var result = createNode(286, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283; })) { + if (ts.forEach(tags, function (t) { return t.kind === 287; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283, atToken.pos); + var result = createNode(287, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -18024,7 +19272,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(286, atToken.pos); + var result = createNode(290, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -18033,7 +19281,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(280, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -18042,25 +19290,28 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(285, atToken.pos); + var typedefTag = createNode(289, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); if (typedefTag.fullName) { var rightNode = typedefTag.fullName; - while (rightNode.kind !== 70) { + while (true) { + if (rightNode.kind === 70 || !rightNode.body) { + typedefTag.name = rightNode.kind === 70 ? rightNode : rightNode.name; + break; + } rightNode = rightNode.body; } - typedefTag.name = rightNode; } typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 272) { + if (typeExpression.type.kind === 276) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { - var name_16 = jsDocTypeReference.name; - if (name_16.text === "Object") { + var name = jsDocTypeReference.name; + if (name.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -18074,7 +19325,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(287, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(291, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -18115,7 +19366,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22)) { - var jsDocNamespaceNode = createNode(230, pos); + var jsDocNamespaceNode = createNode(232, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); @@ -18159,19 +19410,19 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284; })) { + if (ts.forEach(tags, function (t) { return t.kind === 288; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); while (true) { - var name_17 = parseJSDocIdentifierName(); + var name = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_17) { + if (!name) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(143, name_17.pos); - typeParameter.name = name_17; + var typeParameter = createNode(144, name.pos); + typeParameter.name = name; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25) { @@ -18182,7 +19433,7 @@ var ts; break; } } - var result = createNode(284, atToken.pos); + var result = createNode(288, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -18474,7 +19725,7 @@ var ts; } function visitArray(array) { if (position >= array.pos && position < array.end) { - for (var i = 0, n = array.length; i < n; i++) { + for (var i = 0; i < array.length; i++) { var child = array[i]; if (child) { if (child.pos === position) { @@ -18496,21 +19747,31 @@ var ts; } } } + var InvalidPosition; + (function (InvalidPosition) { + InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; + })(InvalidPosition || (InvalidPosition = {})); })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); var ts; (function (ts) { + var ModuleInstanceState; + (function (ModuleInstanceState) { + ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; + ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; + ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; + })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); function getModuleInstanceState(node) { - if (node.kind === 227 || node.kind === 228) { + if (node.kind === 229 || node.kind === 230) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 235 || node.kind === 234) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 237 || node.kind === 236) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 231) { + else if (node.kind === 233) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -18526,7 +19787,7 @@ var ts; }); return state_1; } - else if (node.kind === 230) { + else if (node.kind === 232) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -18538,6 +19799,18 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; + var ContainerFlags; + (function (ContainerFlags) { + ContainerFlags[ContainerFlags["None"] = 0] = "None"; + ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; + ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; + ContainerFlags[ContainerFlags["IsControlFlowContainer"] = 4] = "IsControlFlowContainer"; + ContainerFlags[ContainerFlags["IsFunctionLike"] = 8] = "IsFunctionLike"; + ContainerFlags[ContainerFlags["IsFunctionExpression"] = 16] = "IsFunctionExpression"; + ContainerFlags[ContainerFlags["HasLocals"] = 32] = "HasLocals"; + ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; + ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; + })(ContainerFlags || (ContainerFlags = {})); var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -18635,7 +19908,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 230)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 232)) { symbol.valueDeclaration = node; } } @@ -18645,7 +19918,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 142) { + if (node.name.kind === 143) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression)) { return nameExpression.text; @@ -18656,21 +19929,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 150: + case 151: return "__constructor"; - case 158: - case 153: - return "__call"; case 159: case 154: - return "__new"; + return "__call"; + case 160: case 155: + return "__new"; + case 156: return "__index"; - case 241: + case 243: return "__export"; - case 240: + case 242: return node.isExportEquals ? "export=" : "default"; - case 192: + case 193: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -18682,20 +19955,20 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 225: - case 226: + case 227: + case 228: return ts.hasModifier(node, 512) ? "default" : undefined; - case 274: + case 278: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 144: - ts.Debug.assert(node.parent.kind === 274); + case 145: + ts.Debug.assert(node.parent.kind === 278); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 285: + case 289: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 205) { + if (parentNode && parentNode.kind === 207) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -18718,13 +19991,16 @@ var ts; symbol = createSymbol(0, "__missing"); } else { - symbol = symbolTable[name] || (symbolTable[name] = createSymbol(0, name)); + symbol = symbolTable.get(name); + if (!symbol) { + symbolTable.set(name, symbol = createSymbol(0, name)); + } if (name && (includes & 788448)) { - classifiableNames[name] = name; + classifiableNames.set(name, name); } if (symbol.flags & excludes) { if (symbol.isReplaceableByMethod) { - symbol = symbolTable[name] = createSymbol(0, name); + symbolTable.set(name, symbol = createSymbol(0, name)); } else { if (node.name) { @@ -18739,7 +20015,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 240 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 242 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -18759,7 +20035,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 243 || (node.kind === 234 && hasExportModifier)) { + if (node.kind === 245 || (node.kind === 236 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -18767,7 +20043,7 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 285 && + var isJSDocTypedefInJSDocNamespace = node.kind === 289 && node.name && node.name.kind === 70 && node.name.isInJSDocNamespace; @@ -18828,7 +20104,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 261) { + if (node.kind === 264) { node.flags |= emitFlags; } if (isIIFE) { @@ -18904,64 +20180,64 @@ var ts; return; } switch (node.kind) { - case 210: + case 212: bindWhileStatement(node); break; - case 209: + case 211: bindDoStatement(node); break; - case 211: + case 213: bindForStatement(node); break; - case 212: - case 213: + case 214: + case 215: bindForInOrForOfStatement(node); break; - case 208: + case 210: bindIfStatement(node); break; - case 216: - case 220: + case 218: + case 222: bindReturnOrThrow(node); break; - case 215: - case 214: + case 217: + case 216: bindBreakOrContinueStatement(node); break; - case 221: + case 223: bindTryStatement(node); break; - case 218: + case 220: bindSwitchStatement(node); break; - case 232: + case 234: bindCaseBlock(node); break; - case 253: + case 256: bindCaseClause(node); break; - case 219: + case 221: bindLabeledStatement(node); break; - case 190: + case 191: bindPrefixUnaryExpressionFlow(node); break; - case 191: + case 192: bindPostfixUnaryExpressionFlow(node); break; - case 192: + case 193: bindBinaryExpressionFlow(node); break; - case 186: + case 187: bindDeleteExpressionFlow(node); break; - case 193: + case 194: bindConditionalExpressionFlow(node); break; - case 223: + case 225: bindVariableDeclarationFlow(node); break; - case 179: + case 180: bindCallExpressionFlow(node); break; default: @@ -18973,15 +20249,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 177: + case 178: return isNarrowableReference(expr); - case 179: + case 180: return hasNarrowableArgument(expr); - case 183: + case 184: return isNarrowingExpression(expr.expression); - case 192: + case 193: return isNarrowingBinaryExpression(expr); - case 190: + case 191: return expr.operator === 50 && isNarrowingExpression(expr.operand); } return false; @@ -18989,7 +20265,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 || expr.kind === 98 || - expr.kind === 177 && isNarrowableReference(expr.expression); + expr.kind === 178 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -19000,14 +20276,14 @@ var ts; } } } - if (expr.expression.kind === 177 && + if (expr.expression.kind === 178 && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 187 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; + return expr1.kind === 188 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -19028,9 +20304,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 183: + case 184: return isNarrowableOperand(expr.expression); - case 192: + case 193: switch (expr.operatorToken.kind) { case 57: return isNarrowableOperand(expr.left); @@ -19124,33 +20400,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 208: case 210: - case 209: - return parent.expression === node; + case 212: case 211: - case 193: + return parent.expression === node; + case 213: + case 194: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 183) { + if (node.kind === 184) { node = node.expression; } - else if (node.kind === 190 && node.operator === 50) { + else if (node.kind === 191 && node.operator === 50) { node = node.operand; } else { - return node.kind === 192 && (node.operatorToken.kind === 52 || + return node.kind === 193 && (node.operatorToken.kind === 52 || node.operatorToken.kind === 53); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 183 || - node.parent.kind === 190 && + while (node.parent.kind === 184 || + node.parent.kind === 191 && node.parent.operator === 50) { node = node.parent; } @@ -19192,7 +20468,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 219 + var enclosingLabeledStatement = node.parent.kind === 221 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -19227,7 +20503,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 224) { + if (node.initializer.kind !== 226) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -19249,7 +20525,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 216) { + if (node.kind === 218) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -19269,7 +20545,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 215 ? breakTarget : continueTarget; + var flowLabel = node.kind === 217 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -19302,7 +20578,8 @@ var ts; flowAfterCatch = currentFlow; } if (node.finallyBlock) { - addAntecedent(preFinallyLabel, preTryFlow); + var preFinallyFlow = { flags: 2048, antecedent: preTryFlow, lock: {} }; + addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); if (!(currentFlow.flags & 1)) { @@ -19312,6 +20589,11 @@ var ts; : unreachableFlow; } } + if (!(currentFlow.flags & 1)) { + var afterFinallyFlow = { flags: 4096, antecedent: currentFlow }; + preFinallyFlow.lock = afterFinallyFlow; + currentFlow = afterFinallyFlow; + } } else { currentFlow = finishFlowLabel(preFinallyLabel); @@ -19326,7 +20608,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 254; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 257; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -19391,13 +20673,13 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 209) { + if (!node.statement || node.statement.kind !== 211) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 192 && node.operatorToken.kind === 57) { + if (node.kind === 193 && node.operatorToken.kind === 57) { bindAssignmentTargetFlow(node.left); } else { @@ -19408,10 +20690,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 175) { + else if (node.kind === 176) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 196) { + if (e.kind === 197) { bindAssignmentTargetFlow(e.expression); } else { @@ -19419,16 +20701,16 @@ var ts; } } } - else if (node.kind === 176) { + else if (node.kind === 177) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 257) { + if (p.kind === 260) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 258) { + else if (p.kind === 261) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 259) { + else if (p.kind === 262) { bindAssignmentTargetFlow(p.expression); } } @@ -19484,7 +20766,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 57 && node.left.kind === 178) { + if (operator === 57 && node.left.kind === 179) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -19495,7 +20777,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 177) { + if (node.expression.kind === 178) { bindAssignmentTargetFlow(node.expression); } } @@ -19528,16 +20810,16 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 212 || node.parent.parent.kind === 213) { + if (node.initializer || node.parent.parent.kind === 214 || node.parent.parent.kind === 215) { bindInitializedVariableFlow(node); } } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 183) { + while (expr.kind === 184) { expr = expr.expression; } - if (expr.kind === 184 || expr.kind === 185) { + if (expr.kind === 185 || expr.kind === 186) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -19545,7 +20827,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 177) { + if (node.expression.kind === 178) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -19554,52 +20836,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 197: - case 226: - case 229: - case 176: - case 161: - case 287: - case 270: - return 1; - case 227: - return 1 | 64; - case 274: - case 230: + case 198: case 228: - case 170: + case 231: + case 177: + case 162: + case 291: + case 274: + case 253: + return 1; + case 229: + return 1 | 64; + case 278: + case 232: + case 230: + case 171: return 1 | 32; - case 261: + case 264: return 1 | 4 | 32; - case 149: + case 150: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 150: - case 225: - case 148: case 151: + case 227: + case 149: case 152: case 153: case 154: case 155: - case 158: + case 156: case 159: + case 160: return 1 | 4 | 32 | 8; - case 184: case 185: + case 186: return 1 | 4 | 32 | 8 | 16; - case 231: + case 233: return 4; - case 147: + case 148: return node.initializer ? 4 : 0; - case 256: - case 211: - case 212: + case 259: case 213: - case 232: + case 214: + case 215: + case 234: return 2; - case 204: + case 206: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -19615,37 +20898,38 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 230: + case 232: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 261: + case 264: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 197: - case 226: + case 198: + case 228: return declareClassMember(node, symbolFlags, symbolExcludes); - case 229: + case 231: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 161: - case 176: - case 227: - case 270: - case 287: + case 162: + case 177: + case 229: + case 274: + case 291: + case 253: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 158: case 159: - case 153: + case 160: case 154: case 155: - case 149: - case 148: + case 156: case 150: + case 149: case 151: case 152: - case 225: - case 184: + case 153: + case 227: case 185: - case 274: - case 228: - case 170: + case 186: + case 278: + case 230: + case 171: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -19660,11 +20944,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 261 ? node : node.body; - if (body && (body.kind === 261 || body.kind === 231)) { + var body = node.kind === 264 ? node : node.body; + if (body && (body.kind === 264 || body.kind === 233)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 241 || stat.kind === 240) { + if (stat.kind === 243 || stat.kind === 242) { return true; } } @@ -19686,7 +20970,7 @@ var ts; errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isExternalModuleAugmentation(node)) { - declareSymbolAndAddToSymbolTable(node, 1024, 0); + declareModuleSymbol(node); } else { var pattern = void 0; @@ -19706,12 +20990,8 @@ var ts; } } else { - var state = getModuleInstanceState(node); - if (state === 0) { - declareSymbolAndAddToSymbolTable(node, 1024, 0); - } - else { - declareSymbolAndAddToSymbolTable(node, 512, 106639); + var state = declareModuleSymbol(node); + if (state !== 0) { if (node.symbol.flags & (16 | 32 | 256)) { node.symbol.constEnumOnlyModule = false; } @@ -19727,29 +21007,40 @@ var ts; } } } + function declareModuleSymbol(node) { + var state = getModuleInstanceState(node); + var instantiated = state !== 0; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 : 1024, instantiated ? 106639 : 0); + return state; + } function bindFunctionOrConstructorType(node) { var symbol = createSymbol(131072, getDeclarationName(node)); addDeclarationToSymbol(symbol, node, 131072); var typeLiteralSymbol = createSymbol(2048, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, 2048); typeLiteralSymbol.members = ts.createMap(); - typeLiteralSymbol.members[symbol.name] = symbol; + typeLiteralSymbol.members.set(symbol.name, symbol); } function bindObjectLiteralExpression(node) { + var ElementKind; + (function (ElementKind) { + ElementKind[ElementKind["Property"] = 1] = "Property"; + ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; + })(ElementKind || (ElementKind = {})); if (inStrictMode) { var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 || prop.name.kind !== 70) { + if (prop.kind === 262 || prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 257 || prop.kind === 258 || prop.kind === 149 + var currentKind = prop.kind === 260 || prop.kind === 261 || prop.kind === 150 ? 1 : 2; - var existingKind = seen[identifier.text]; + var existingKind = seen.get(identifier.text); if (!existingKind) { - seen[identifier.text] = currentKind; + seen.set(identifier.text, currentKind); continue; } if (currentKind === 1 && existingKind === 1) { @@ -19760,16 +21051,22 @@ var ts; } return bindAnonymousDeclaration(node, 4096, "__object"); } + function bindJsxAttributes(node) { + return bindAnonymousDeclaration(node, 4096, "__jsxAttributes"); + } + function bindJsxAttribute(node, symbolFlags, symbolExcludes) { + return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); + } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 230: + case 232: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 261: + case 264: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -19859,8 +21156,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 261 && - blockScopeContainer.kind !== 230 && + if (blockScopeContainer.kind !== 264 && + blockScopeContainer.kind !== 232 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -19903,7 +21200,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 140) { + if (node.kind > 141) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -19943,23 +21240,23 @@ var ts; case 70: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 285) { + while (parentNode && parentNode.kind !== 289) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); break; } case 98: - if (currentFlow && (ts.isExpression(node) || parent.kind === 258)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 261)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 177: + case 178: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 192: + case 193: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -19982,48 +21279,48 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 256: + case 259: return checkStrictModeCatchClause(node); - case 186: + case 187: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 191: + case 192: return checkStrictModePostfixUnaryExpression(node); - case 190: + case 191: return checkStrictModePrefixUnaryExpression(node); - case 217: + case 219: return checkStrictModeWithStatement(node); - case 167: + case 168: seenThisKeyword = true; return; - case 156: + case 157: return checkTypePredicate(node); - case 143: - return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 144: + return declareSymbolAndAddToSymbolTable(node, 262144, 530920); + case 145: return bindParameter(node); - case 223: - case 174: + case 225: + case 175: return bindVariableDeclarationOrBindingElement(node); + case 148: case 147: - case 146: - case 271: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 286: + case 275: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 67108864 : 0), 0); + case 290: return bindJSDocProperty(node); - case 257: - case 258: - return bindPropertyOrMethodOrAccessor(node, 4, 0); case 260: + case 261: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 263: return bindPropertyOrMethodOrAccessor(node, 8, 900095); - case 259: - case 251: + case 262: + case 254: var root = container; var hasRest = false; while (root.parent) { - if (root.kind === 176 && - root.parent.kind === 192 && + if (root.kind === 177 && + root.parent.kind === 193 && root.parent.operatorToken.kind === 57 && root.parent.left === root) { hasRest = true; @@ -20032,78 +21329,82 @@ var ts; root = root.parent; } return; - case 153: case 154: case 155: + case 156: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 149: - case 148: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 225: - return bindFunctionDeclaration(node); case 150: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 149: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 67108864 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); + case 227: + return bindFunctionDeclaration(node); case 151: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 152: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 153: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 158: case 159: - case 274: + case 160: + case 278: return bindFunctionOrConstructorType(node); - case 161: - case 170: - case 287: - case 270: + case 162: + case 171: + case 291: + case 274: return bindAnonymousDeclaration(node, 2048, "__type"); - case 176: + case 177: return bindObjectLiteralExpression(node); - case 184: case 185: + case 186: return bindFunctionExpression(node); - case 179: + case 180: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 197: - case 226: + case 198: + case 228: inStrictMode = true; return bindClassLikeDeclaration(node); - case 227: + case 229: return bindBlockScopedDeclaration(node, 64, 792968); - case 285: + case 289: if (!node.fullName || node.fullName.kind === 70) { return bindBlockScopedDeclaration(node, 524288, 793064); } break; - case 228: - return bindBlockScopedDeclaration(node, 524288, 793064); - case 229: - return bindEnumDeclaration(node); case 230: + return bindBlockScopedDeclaration(node, 524288, 793064); + case 231: + return bindEnumDeclaration(node); + case 232: return bindModuleDeclaration(node); - case 234: - case 237: - case 239: - case 243: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 233: - return bindNamespaceExportDeclaration(node); + case 253: + return bindJsxAttributes(node); + case 252: + return bindJsxAttribute(node, 4, 0); case 236: - return bindImportClause(node); + case 239: case 241: + case 245: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 235: + return bindNamespaceExportDeclaration(node); + case 238: + return bindImportClause(node); + case 243: return bindExportDeclaration(node); - case 240: + case 242: return bindExportAssignment(node); - case 261: + case 264: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 204: + case 206: if (!ts.isFunctionLike(node.parent)) { return; } - case 231: + case 233: return updateStrictModeStatementList(node.statements); } } @@ -20112,7 +21413,7 @@ var ts; if (parameterName && parameterName.kind === 70) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 167) { + if (parameterName && parameterName.kind === 168) { seenThisKeyword = true; } bind(type); @@ -20131,7 +21432,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 240 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 242 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -20141,17 +21442,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 261) { + if (node.parent.kind !== 264) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_4 = node.parent; - if (!ts.isExternalModule(parent_4)) { + var parent_1 = node.parent; + if (!ts.isExternalModule(parent_1)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_4.isDeclarationFile) { + if (!parent_1.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -20161,10 +21462,10 @@ var ts; } function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { - bindAnonymousDeclaration(node, 1073741824, getDeclarationName(node)); + bindAnonymousDeclaration(node, 33554432, getDeclarationName(node)); } else if (!node.exportClause) { - declareSymbol(container.symbol.exports, container.symbol, node, 1073741824, 0); + declareSymbol(container.symbol.exports, container.symbol, node, 33554432, 0); } } function bindImportClause(node) { @@ -20190,11 +21491,11 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 225 || container.kind === 184) { + if (container.kind === 227 || container.kind === 185) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } - else if (container.kind === 150) { + else if (container.kind === 151) { var saveContainer = container; container = container.parent; var symbol = bindPropertyOrMethodOrAccessor(node, 4, 0); @@ -20211,7 +21512,7 @@ var ts; leftSideOfAssignment.parent = node; constructorFunction.parent = classPrototype; classPrototype.parent = leftSideOfAssignment; - var funcSymbol = container.locals[constructorFunction.text]; + var funcSymbol = container.locals.get(constructorFunction.text); if (!funcSymbol || !(funcSymbol.flags & 16 || ts.isDeclarationOfFunctionExpression(funcSymbol))) { return; } @@ -20226,25 +21527,26 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 226) { + if (node.kind === 228) { 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; + classifiableNames.set(node.name.text, node.name.text); } } var symbol = node.symbol; - var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); - if (symbol.exports[prototypeSymbol.name]) { + var prototypeSymbol = createSymbol(4 | 16777216, "prototype"); + var symbolExport = symbol.exports.get(prototypeSymbol.name); + if (symbolExport) { 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)); + file.bindDiagnostics.push(ts.createDiagnosticForNode(symbolExport.declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; + symbol.exports.set(prototypeSymbol.name, prototypeSymbol); prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { @@ -20280,7 +21582,7 @@ var ts; } if (ts.isParameterPropertyDeclaration(node)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 536870912 : 0), 0); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 67108864 : 0), 0); } } function bindFunctionDeclaration(node) { @@ -20336,15 +21638,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 206) || - node.kind === 226 || - (node.kind === 230 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 229 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 208) || + node.kind === 228 || + (node.kind === 232 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 231 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 205 || + (node.kind !== 207 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -20358,56 +21660,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 179: - return computeCallExpression(node, subtreeFlags); case 180: + return computeCallExpression(node, subtreeFlags); + case 181: return computeNewExpression(node, subtreeFlags); - case 230: + case 232: return computeModuleDeclaration(node, subtreeFlags); - case 183: - return computeParenthesizedExpression(node, subtreeFlags); - case 192: - return computeBinaryExpression(node, subtreeFlags); - case 207: - return computeExpressionStatement(node, subtreeFlags); - case 144: - return computeParameter(node, subtreeFlags); - case 185: - return computeArrowFunction(node, subtreeFlags); case 184: + return computeParenthesizedExpression(node, subtreeFlags); + case 193: + return computeBinaryExpression(node, subtreeFlags); + case 209: + return computeExpressionStatement(node, subtreeFlags); + case 145: + return computeParameter(node, subtreeFlags); + case 186: + return computeArrowFunction(node, subtreeFlags); + case 185: return computeFunctionExpression(node, subtreeFlags); - case 225: + case 227: return computeFunctionDeclaration(node, subtreeFlags); - case 223: + case 225: return computeVariableDeclaration(node, subtreeFlags); - case 224: - return computeVariableDeclarationList(node, subtreeFlags); - case 205: - return computeVariableStatement(node, subtreeFlags); - case 219: - return computeLabeledStatement(node, subtreeFlags); case 226: + return computeVariableDeclarationList(node, subtreeFlags); + case 207: + return computeVariableStatement(node, subtreeFlags); + case 221: + return computeLabeledStatement(node, subtreeFlags); + case 228: return computeClassDeclaration(node, subtreeFlags); - case 197: + case 198: return computeClassExpression(node, subtreeFlags); - case 255: + case 258: return computeHeritageClause(node, subtreeFlags); - case 256: + case 259: return computeCatchClause(node, subtreeFlags); - case 199: + case 200: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 150: - return computeConstructor(node, subtreeFlags); - case 147: - return computePropertyDeclaration(node, subtreeFlags); - case 149: - return computeMethod(node, subtreeFlags); case 151: + return computeConstructor(node, subtreeFlags); + case 148: + return computePropertyDeclaration(node, subtreeFlags); + case 150: + return computeMethod(node, subtreeFlags); case 152: + case 153: return computeAccessor(node, subtreeFlags); - case 234: + case 236: return computeImportEquals(node, subtreeFlags); - case 177: + case 178: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -20432,8 +21734,8 @@ var ts; switch (kind) { case 96: return true; - case 177: case 178: + case 179: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96; @@ -20455,10 +21757,10 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 && leftKind === 176) { + if (operatorTokenKind === 57 && leftKind === 177) { transformFlags |= 8 | 192 | 3072; } - else if (operatorTokenKind === 57 && leftKind === 175) { + else if (operatorTokenKind === 57 && leftKind === 176) { transformFlags |= 192 | 3072; } else if (operatorTokenKind === 39 @@ -20497,8 +21799,8 @@ var ts; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 200 - || expressionKind === 182) { + if (expressionKind === 201 + || expressionKind === 183) { transformFlags |= 3; } if (expressionTransformFlags & 1024) { @@ -20784,7 +22086,7 @@ var ts; var excludeFlags = 536872257; switch (kind) { case 119: - case 189: + case 190: transformFlags |= 16; break; case 113: @@ -20793,50 +22095,52 @@ var ts; case 116: case 123: case 75: - case 229: - case 260: - case 182: - case 200: + case 231: + case 263: + case 183: case 201: + case 202: case 130: transformFlags |= 3; break; - case 246: - case 247: case 248: - case 10: case 249: case 250: + case 10: case 251: case 252: + case 253: + case 254: + case 255: transformFlags |= 4; break; - case 213: + case 215: transformFlags |= 8; case 12: case 13: case 14: case 15: - case 194: - case 181: - case 258: + case 195: + case 182: + case 261: case 114: + case 203: transformFlags |= 192; break; - case 195: + case 196: transformFlags |= 192 | 16777216; break; case 118: case 132: case 129: - case 134: - case 121: + case 133: case 135: + case 121: + case 136: case 104: - case 143: - case 146: - case 148: - case 153: + case 144: + case 147: + case 149: case 154: case 155: case 156: @@ -20850,26 +22154,27 @@ var ts; case 164: case 165: case 166: - case 227: - case 228: case 167: + case 229: + case 230: case 168: case 169: case 170: case 171: + case 172: transformFlags = 3; excludeFlags = -3; break; - case 142: + case 143: transformFlags |= 2097152; if (subtreeFlags & 16384) { transformFlags |= 65536; } break; - case 196: + case 197: transformFlags |= 192 | 524288; break; - case 259: + case 262: transformFlags |= 8 | 1048576; break; case 96: @@ -20878,27 +22183,27 @@ var ts; case 98: transformFlags |= 16384; break; - case 172: + case 173: transformFlags |= 192 | 8388608; if (subtreeFlags & 524288) { transformFlags |= 8 | 1048576; } excludeFlags = 537396545; break; - case 173: + case 174: transformFlags |= 192 | 8388608; excludeFlags = 537396545; break; - case 174: + case 175: transformFlags |= 192; if (node.dotDotDotToken) { transformFlags |= 524288; } break; - case 145: + case 146: transformFlags |= 3 | 4096; break; - case 176: + case 177: excludeFlags = 540087617; if (subtreeFlags & 2097152) { transformFlags |= 192; @@ -20910,29 +22215,29 @@ var ts; transformFlags |= 8; } break; - case 175: - case 180: + case 176: + case 181: excludeFlags = 537396545; if (subtreeFlags & 524288) { transformFlags |= 192; } break; - case 209: - case 210: case 211: case 212: + case 213: + case 214: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 261: + case 264: if (subtreeFlags & 32768) { transformFlags |= 192; } break; + case 218: case 216: - case 214: - case 215: + case 217: transformFlags |= 33554432; break; } @@ -20940,56 +22245,57 @@ var ts; return transformFlags & ~excludeFlags; } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 156 && kind <= 171) { + if (kind >= 157 && kind <= 172) { return -3; } switch (kind) { - case 179: case 180: - case 175: + case 181: + case 176: return 537396545; - case 230: + case 232: return 574674241; - case 144: + case 145: return 536872257; - case 185: + case 186: return 601249089; - case 184: - case 225: + case 185: + case 227: return 601281857; - case 224: - return 546309441; case 226: - case 197: + return 546309441; + case 228: + case 198: return 539358529; - case 150: - return 601015617; - case 149: case 151: + return 601015617; + case 150: case 152: + case 153: return 601015617; case 118: case 132: case 129: - case 134: - case 121: case 135: + case 133: + case 121: + case 136: case 104: - case 143: - case 146: - case 148: - case 153: + case 144: + case 147: + case 149: case 154: case 155: - case 227: - case 228: + case 156: + case 229: + case 230: return -3; - case 176: + case 177: return 540087617; - case 256: + case 259: return 537920833; - case 172: case 173: + case 174: return 537396545; default: return 536872257; @@ -21038,9 +22344,9 @@ var ts; var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; var strictNullChecks = compilerOptions.strictNullChecks; var emitResolver = createResolver(); - var undefinedSymbol = createSymbol(4 | 67108864, "undefined"); + var undefinedSymbol = createSymbol(4, "undefined"); undefinedSymbol.declarations = []; - var argumentsSymbol = createSymbol(4 | 67108864, "arguments"); + var argumentsSymbol = createSymbol(4, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, @@ -21056,9 +22362,12 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, + getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, + getTypeFromTypeNode: getTypeFromTypeNode, + getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -21067,6 +22376,7 @@ var ts; getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, + signatureToString: signatureToString, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -21082,14 +22392,16 @@ var ts; getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, + getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getAmbientModules: getAmbientModules, - getJsxElementAttributesType: getJsxElementAttributesType, + getAllAttributesTypeFromJsxOpeningLikeElement: getAllAttributesTypeFromJsxOpeningLikeElement, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, isOptionalParameter: isOptionalParameter, tryGetMemberInModuleExports: tryGetMemberInModuleExports, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { return tryFindAmbientModule(moduleName, false); - } + }, + getApparentType: getApparentType }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -21098,8 +22410,8 @@ var ts; var numericLiteralTypes = ts.createMap(); var indexedAccessTypes = ts.createMap(); var evolvingArrayTypes = []; - var unknownSymbol = createSymbol(4 | 67108864, "unknown"); - var resolvingSymbol = createSymbol(67108864, "__resolving__"); + var unknownSymbol = createSymbol(4, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__"); var anyType = createIntrinsicType(1, "any"); var autoType = createIntrinsicType(1, "any"); var unknownType = createIntrinsicType(1, "unknown"); @@ -21116,8 +22428,9 @@ var ts; var voidType = createIntrinsicType(1024, "void"); var neverType = createIntrinsicType(8192, "never"); var silentNeverType = createIntrinsicType(8192, "never"); + var nonPrimitiveType = createIntrinsicType(16777216, "object"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var emptyTypeLiteralSymbol = createSymbol(2048 | 67108864, "__type"); + var emptyTypeLiteralSymbol = createSymbol(2048, "__type"); emptyTypeLiteralSymbol.members = ts.createMap(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -21125,6 +22438,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); anyFunctionType.flags |= 8388608; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); var resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false); @@ -21183,9 +22497,70 @@ var ts; var visitedFlowNodes = []; var visitedFlowTypes = []; var potentialThisCollisions = []; + var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - var typeofEQFacts = ts.createMap({ + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; + TypeFacts[TypeFacts["Discriminatable"] = 4194304] = "Discriminatable"; + TypeFacts[TypeFacts["All"] = 8388607] = "All"; + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; + TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; + TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; + TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 6166480] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 8378320] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 6164448] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 8376288] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; + })(TypeFacts || (TypeFacts = {})); + var typeofEQFacts = ts.createMapFromTemplate({ "string": 1, "number": 2, "boolean": 4, @@ -21194,7 +22569,7 @@ var ts; "object": 16, "function": 32 }); - var typeofNEFacts = ts.createMap({ + var typeofNEFacts = ts.createMapFromTemplate({ "string": 128, "number": 256, "boolean": 512, @@ -21203,13 +22578,14 @@ var ts; "object": 2048, "function": 4096 }); - var typeofTypesByName = ts.createMap({ + var typeofTypesByName = ts.createMapFromTemplate({ "string": stringType, "number": numberType, "boolean": booleanType, "symbol": esSymbolType, "undefined": undefinedType }); + var typeofType = createTypeofType(); var jsxElementType; var _jsxNamespace; var _jsxFactoryEntity; @@ -21229,8 +22605,15 @@ var ts; var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); var _displayBuilder; + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var builtinGlobals = ts.createMap(); - builtinGlobals[undefinedSymbol.name] = undefinedSymbol; + builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); initializeTypeChecker(); return checker; function getJsxNamespace() { @@ -21260,7 +22643,9 @@ var ts; } function createSymbol(flags, name) { symbolCount++; - return new Symbol(flags, name); + var symbol = (new Symbol(flags | 134217728, name)); + symbol.checkFlags = 0; + return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; @@ -21306,7 +22691,7 @@ var ts; mergedSymbols[source.mergeId] = target; } function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 33554432, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); result.declarations = symbol.declarations.slice(0); result.parent = symbol.parent; if (symbol.valueDeclaration) @@ -21328,7 +22713,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 230 && source.valueDeclaration.kind !== 230))) { + (target.valueDeclaration.kind === 232 && source.valueDeclaration.kind !== 232))) { target.valueDeclaration = source.valueDeclaration; } ts.addRange(target.declarations, source.declarations); @@ -21344,6 +22729,9 @@ var ts; } recordMergedSymbol(target, source); } + else if (target.flags & 1024) { + error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + } else { var message_2 = target.flags & 2 || source.flags & 2 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -21356,18 +22744,19 @@ var ts; } } function mergeSymbolTable(target, source) { - for (var id in source) { - var targetSymbol = target[id]; + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); if (!targetSymbol) { - target[id] = source[id]; + target.set(id, sourceSymbol); } else { - if (!(targetSymbol.flags & 33554432)) { - target[id] = targetSymbol = cloneSymbol(targetSymbol); + if (!(targetSymbol.flags & 134217728)) { + targetSymbol = cloneSymbol(targetSymbol); + target.set(id, targetSymbol); } - mergeSymbol(targetSymbol, source[id]); + mergeSymbol(targetSymbol, sourceSymbol); } - } + }); } function mergeModuleAugmentation(moduleName) { var moduleAugmentation = moduleName.parent; @@ -21388,7 +22777,7 @@ var ts; } mainModule = resolveExternalModuleSymbol(mainModule); if (mainModule.flags & 1920) { - mainModule = mainModule.flags & 33554432 ? mainModule : cloneSymbol(mainModule); + mainModule = mainModule.flags & 134217728 ? mainModule : cloneSymbol(mainModule); mergeSymbol(mainModule, moduleAugmentation.symbol); } else { @@ -21397,20 +22786,21 @@ var ts; } } function addToSymbolTable(target, source, message) { - for (var id in source) { - if (target[id]) { - ts.forEach(target[id].declarations, addDeclarationDiagnostic(id, message)); + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); + if (targetSymbol) { + ts.forEach(targetSymbol.declarations, addDeclarationDiagnostic(id, message)); } else { - target[id] = source[id]; + target.set(id, sourceSymbol); } - } + }); function addDeclarationDiagnostic(id, message) { return function (declaration) { return diagnostics.add(ts.createDiagnosticForNode(declaration, message, id)); }; } } function getSymbolLinks(symbol) { - if (symbol.flags & 67108864) + if (symbol.flags & 134217728) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = {}); @@ -21422,14 +22812,17 @@ var ts; function getObjectFlags(type) { return type.flags & 32768 ? type.objectFlags : 0; } + function getCheckFlags(symbol) { + return symbol.flags & 134217728 ? symbol.checkFlags : 0; + } function isGlobalSourceFile(node) { - return node.kind === 261 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 264 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { - var symbol = symbols[name]; + var symbol = symbols.get(name); if (symbol) { - ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } @@ -21460,39 +22853,50 @@ var ts; (!compilerOptions.outFile && !compilerOptions.out)) { return true; } - if (isUsedInFunctionOrNonStaticProperty(usage)) { + if (isUsedInFunctionOrInstanceProperty(usage)) { return true; } var sourceFiles = host.getSourceFiles(); return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 223 || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + if (declaration.kind === 175) { + var errorBindingElement = ts.getAncestor(usage, 175); + if (errorBindingElement) { + return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + declaration.pos < errorBindingElement.pos; + } + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 225), usage); + } + else if (declaration.kind === 225) { + return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); - return isUsedInFunctionOrNonStaticProperty(usage, container); + var isInstanceProperty = declaration.kind === 148 && !(ts.getModifierFlags(declaration) & 32); + return isUsedInFunctionOrInstanceProperty(usage, isInstanceProperty, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 205: - case 211: + case 207: case 213: + case 215: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 212: - case 213: + case 214: + case 215: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } } return false; } - function isUsedInFunctionOrNonStaticProperty(usage, container) { + function isUsedInFunctionOrInstanceProperty(usage, isDeclarationInstanceProperty, container) { var current = usage; while (current) { if (current === container) { @@ -21501,17 +22905,26 @@ var ts; if (ts.isFunctionLike(current)) { return true; } - var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 147 && + var initializerOfInstanceProperty = current.parent && + current.parent.kind === 148 && (ts.getModifierFlags(current.parent) & 32) === 0 && current.parent.initializer === current; - if (initializerOfNonStaticProperty) { - return true; + if (initializerOfInstanceProperty) { + return !isDeclarationInstanceProperty; } current = current.parent; } return false; } + function getAncestorBindingPattern(node) { + while (node) { + if (ts.isBindingPattern(node)) { + return node; + } + node = node.parent; + } + return undefined; + } } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { var result; @@ -21525,18 +22938,18 @@ var ts; if (result = getSymbol(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 793064 && lastLocation.kind !== 278) { + if (meaning & result.flags & 793064 && lastLocation.kind !== 282) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 144 || - lastLocation.kind === 143 + lastLocation.kind === 145 || + lastLocation.kind === 144 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 144 || + lastLocation.kind === 145 || (lastLocation === location.type && - result.valueDeclaration.kind === 144); + result.valueDeclaration.kind === 145); } } if (useResult) { @@ -21548,23 +22961,24 @@ var ts; } } switch (location.kind) { - case 261: + case 264: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 230: + case 232: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 261 || ts.isAmbientModule(location)) { - if (result = moduleExports["default"]) { + if (location.kind === 264 || ts.isAmbientModule(location)) { + if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; } result = undefined; } - if (moduleExports[name] && - moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 243)) { + var moduleExport = moduleExports.get(name); + if (moduleExport && + moduleExport.flags === 8388608 && + ts.getDeclarationOfKind(moduleExport, 245)) { break; } } @@ -21572,13 +22986,13 @@ var ts; break loop; } break; - case 229: + case 231: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 148: case 147: - case 146: if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -21588,17 +23002,21 @@ var ts; } } break; - case 226: - case 197: - case 227: + case 228: + case 198: + case 229: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { + if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { + result = undefined; + break; + } if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; } break loop; } - if (location.kind === 197 && meaning & 32) { + if (location.kind === 198 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -21606,28 +23024,28 @@ var ts; } } break; - case 142: + case 143: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 227) { + if (ts.isClassLike(grandparent) || grandparent.kind === 229) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 225: - case 185: + case 153: + case 227: + case 186: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 184: + case 185: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -21640,8 +23058,8 @@ var ts; } } break; - case 145: - if (location.parent && location.parent.kind === 144) { + case 146: + if (location.parent && location.parent.kind === 145) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -21684,13 +23102,22 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 233) { + if (decls && decls.length === 1 && decls[0].kind === 235) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } } return result; } + function isTypeParameterSymbolDeclaredInContainer(symbol, container) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.kind === 144 && decl.parent === container) { + return true; + } + } + return false; + } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { if ((errorLocation.kind === 70 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; @@ -21731,9 +23158,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70: - case 177: + case 178: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 199: + case 200: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -21764,7 +23191,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 223), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -21781,10 +23208,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 234) { + if (node.kind === 236) { return node; } - while (node && node.kind !== 235) { + while (node && node.kind !== 237) { node = node.parent; } return node; @@ -21794,7 +23221,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 245) { + if (node.moduleReference.kind === 247) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -21802,11 +23229,16 @@ var ts; function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { - var exportDefaultSymbol = ts.isShorthandAmbientModuleSymbol(moduleSymbol) ? - moduleSymbol : - moduleSymbol.exports["export="] ? - getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") : - resolveSymbol(moduleSymbol.exports["default"]); + var exportDefaultSymbol = void 0; + if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { + exportDefaultSymbol = moduleSymbol; + } + else { + var exportValue = moduleSymbol.exports.get("export="); + exportDefaultSymbol = exportValue + ? getPropertyOfType(getTypeOfSymbol(exportValue), "default") + : resolveSymbol(moduleSymbol.exports.get("default")); + } if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } @@ -21837,7 +23269,7 @@ var ts; } function getExportOfModule(symbol, name) { if (symbol.flags & 1536) { - var exportedSymbol = getExportsOfSymbol(symbol)[name]; + var exportedSymbol = getExportsOfSymbol(symbol).get(name); if (exportedSymbol) { return resolveSymbol(exportedSymbol); } @@ -21855,28 +23287,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_18 = specifier.propertyName || specifier.name; - if (name_18.text) { + var name = specifier.propertyName || specifier.name; + if (name.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_18.text); + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) { + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_18.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_18.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_18.text === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name.text); + if (!symbolFromModule && allowSyntheticDefaultImports && name.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_18, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_18)); + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name)); } return symbol; } @@ -21898,19 +23330,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 234: - return getTargetOfImportEqualsDeclaration(node); case 236: + return getTargetOfImportEqualsDeclaration(node); + case 238: return getTargetOfImportClause(node); - case 237: - return getTargetOfNamespaceImport(node); case 239: + return getTargetOfNamespaceImport(node); + case 241: return getTargetOfImportSpecifier(node); - case 243: + case 245: return getTargetOfExportSpecifier(node); - case 240: + case 242: return getTargetOfExportAssignment(node); - case 233: + case 235: return getTargetOfNamespaceExportDeclaration(node); } } @@ -21954,10 +23386,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 240) { + if (node.kind === 242) { checkExpressionCached(node.expression); } - else if (node.kind === 243) { + else if (node.kind === 245) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -21969,11 +23401,11 @@ var ts; if (entityName.kind === 70 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 70 || entityName.parent.kind === 141) { + if (entityName.kind === 70 || entityName.parent.kind === 142) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 234); + ts.Debug.assert(entityName.parent.kind === 236); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -21992,9 +23424,9 @@ var ts; return undefined; } } - else if (name.kind === 141 || name.kind === 177) { - var left = name.kind === 141 ? name.left : name.expression; - var right = name.kind === 141 ? name.right : name.name; + else if (name.kind === 142 || name.kind === 178) { + var left = name.kind === 142 ? name.left : name.expression; + var right = name.kind === 142 ? name.right : name.name; var namespace = resolveEntityName(left, 1920, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -22013,7 +23445,7 @@ var ts; else { ts.Debug.fail("Unknown entity name kind."); } - ts.Debug.assert((symbol.flags & 16777216) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); } function resolveExternalModuleName(location, moduleReferenceExpression) { @@ -22084,7 +23516,7 @@ var ts; return undefined; } function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports["export="])) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="))) || moduleSymbol; } function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { var symbol = resolveExternalModuleSymbol(moduleSymbol); @@ -22095,15 +23527,23 @@ var ts; return symbol; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["export="] !== undefined; + return moduleSymbol.exports.get("export=") !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); } + function getExportsAndPropertiesOfModule(moduleSymbol) { + var exports = getExportsOfModuleAsArray(moduleSymbol); + var exportEquals = resolveExternalModuleSymbol(moduleSymbol); + if (exportEquals !== moduleSymbol) { + ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + } + return exports; + } function tryGetMemberInModuleExports(memberName, moduleSymbol) { var symbolTable = getExportsOfModule(moduleSymbol); if (symbolTable) { - return symbolTable[memberName]; + return symbolTable.get(memberName); } } function getExportsOfSymbol(symbol) { @@ -22114,24 +23554,28 @@ var ts; return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol)); } function extendExportSymbols(target, source, lookupTable, exportNode) { - for (var id in source) { - if (id !== "default" && !target[id]) { - target[id] = source[id]; + source && source.forEach(function (sourceSymbol, id) { + if (id === "default") + return; + var targetSymbol = target.get(id); + if (!targetSymbol) { + target.set(id, sourceSymbol); if (lookupTable && exportNode) { - lookupTable[id] = { + lookupTable.set(id, { specifierText: ts.getTextOfNode(exportNode.moduleSpecifier) - }; + }); } } - else if (lookupTable && exportNode && id !== "default" && target[id] && resolveSymbol(target[id]) !== resolveSymbol(source[id])) { - if (!lookupTable[id].exportsWithDuplicate) { - lookupTable[id].exportsWithDuplicate = [exportNode]; + else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) { + var collisionTracker = lookupTable.get(id); + if (!collisionTracker.exportsWithDuplicate) { + collisionTracker.exportsWithDuplicate = [exportNode]; } else { - lookupTable[id].exportsWithDuplicate.push(exportNode); + collisionTracker.exportsWithDuplicate.push(exportNode); } } - } + }); } function getExportsForModule(moduleSymbol) { var visitedSymbols = []; @@ -22143,26 +23587,26 @@ var ts; } visitedSymbols.push(symbol); var symbols = ts.cloneMap(symbol.exports); - var exportStars = symbol.exports["__export"]; + var exportStars = symbol.exports.get("__export"); if (exportStars) { var nestedSymbols = ts.createMap(); - var lookupTable = ts.createMap(); + var lookupTable_1 = ts.createMap(); for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { var node = _a[_i]; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); var exportedSymbols = visit(resolvedModule); - extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable, node); + extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); } - for (var id in lookupTable) { - var exportsWithDuplicate = lookupTable[id].exportsWithDuplicate; - if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols[id]) { - continue; + lookupTable_1.forEach(function (_a, id) { + var exportsWithDuplicate = _a.exportsWithDuplicate; + if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) { + return; } - for (var _b = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _b < exportsWithDuplicate_1.length; _b++) { - var node = exportsWithDuplicate_1[_b]; - diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable[id].specifierText, id)); + for (var _i = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _i < exportsWithDuplicate_1.length; _i++) { + var node = exportsWithDuplicate_1[_i]; + diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable_1.get(id).specifierText, id)); } - } + }); extendExportSymbols(symbols, nestedSymbols); } return symbols; @@ -22184,22 +23628,13 @@ var ts; : 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; + return !!(symbol.flags & 107455 || symbol.flags & 8388608 && resolveAlias(symbol).flags & 107455); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 150 && ts.nodeIsPresent(member.body)) { + if (member.kind === 151 && ts.nodeIsPresent(member.body)) { return member; } } @@ -22227,6 +23662,9 @@ var ts; type.symbol = symbol; return type; } + function createTypeofType() { + return getUnionType(ts.convertToArray(typeofEQFacts.keys(), function (s) { return getLiteralTypeForText(32, s); })); + } function isReservedMemberName(name) { return name.charCodeAt(0) === 95 && name.charCodeAt(1) === 95 && @@ -22235,16 +23673,15 @@ var ts; } function getNamedMembers(members) { var result; - for (var id in members) { + members.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { if (!result) result = []; - var symbol = members[id]; if (symbolIsValue(symbol)) { result.push(symbol); } } - } + }); return result || emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -22263,19 +23700,19 @@ var ts; } 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)) { + for (var location = enclosingDeclaration; location; location = location.parent) { + if (location.locals && !isGlobalSourceFile(location)) { + if (result = callback(location.locals)) { return result; } } - switch (location_1.kind) { - case 261: - if (!ts.isExternalOrCommonJsModule(location_1)) { + switch (location.kind) { + case 264: + if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230: - if (result = callback(getSymbolOfNode(location_1).exports)) { + case 232: + if (result = callback(getSymbolOfNode(location).exports)) { return result; } break; @@ -22312,13 +23749,13 @@ var ts; } } function trySymbolTable(symbols) { - if (isAccessible(symbols[symbol.name])) { + if (isAccessible(symbols.get(symbol.name))) { return [symbol]; } - return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { + return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -22343,14 +23780,14 @@ var ts; function needsQualification(symbol, enclosingDeclaration, meaning) { var qualify = false; forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { - var symbolFromSymbolTable = symbolTable[symbol.name]; + var symbolFromSymbolTable = symbolTable.get(symbol.name); if (!symbolFromSymbolTable) { return false; } if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -22364,10 +23801,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 147: - case 149: - case 151: + case 148: + case 150: case 152: + case 153: continue; default: return false; @@ -22423,7 +23860,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 261 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 264 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -22457,11 +23894,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 160 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 161 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning = 107455 | 1048576; } - else if (entityName.kind === 141 || entityName.kind === 177 || - entityName.parent.kind === 234) { + else if (entityName.kind === 142 || entityName.kind === 178 || + entityName.parent.kind === 236) { meaning = 1920; } else { @@ -22553,10 +23990,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 166) { + while (node.kind === 167) { node = node.parent; } - if (node.kind === 228) { + if (node.kind === 230) { return getSymbolOfNode(node); } } @@ -22564,29 +24001,29 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 231 && + node.parent.kind === 233 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { return type.flags & 32 ? "\"" + ts.escapeString(type.text) + "\"" : type.text; } - 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 197: - return "(Anonymous class)"; - case 184: - case 185: - return "(Anonymous function)"; - } + 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 198: + return "(Anonymous class)"; + case 185: + case 186: + return "(Anonymous function)"; } - return symbol.name; } + return symbol.name; + } + function getSymbolDisplayBuilder() { function appendSymbolNameOnly(symbol, writer) { writer.writeSymbol(getNameOfSymbol(symbol), symbol); } @@ -22614,7 +24051,7 @@ var ts; function appendParentTypeArgumentsAndSymbolName(symbol) { if (parentSymbol) { if (flags & 1) { - if (symbol.flags & 16777216) { + if (getCheckFlags(symbol) & 1) { buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); } else { @@ -22633,9 +24070,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_5 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_5) { - walkSymbol(parent_5, getQualifiedLeftMeaning(meaning), false); + var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + walkSymbol(parent, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -22665,7 +24102,7 @@ var ts; return writeType(type, globalFlags); function writeType(type, flags) { var nextFlags = flags & ~512; - if (type.flags & 16015) { + if (type.flags & 16793231) { writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) ? "any" : type.intrinsicName); @@ -22690,7 +24127,7 @@ var ts; else if (!(flags & 512) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) { var typeArguments = type.aliasTypeArguments; - writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); + writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, ts.length(typeArguments), nextFlags); } else if (type.flags & 196608) { writeUnionOrIntersectionType(type, nextFlags); @@ -22768,12 +24205,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_6 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_6); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_6, typeArguments, start, i, flags); + writeSymbolTypeReference(parent, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -22799,7 +24236,8 @@ var ts; function writeAnonymousType(type, flags) { var symbol = type.symbol; if (symbol) { - if (symbol.flags & (32 | 384 | 512)) { + if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (384 | 512)) { writeTypeOfSymbol(type, flags); } else if (shouldWriteTypeOfFunctionSymbol()) { @@ -22832,7 +24270,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 261 || declaration.parent.kind === 231; + return declaration.parent.kind === 264 || declaration.parent.kind === 233; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -22845,32 +24283,13 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } - function writeIndexSignature(info, keyword) { - if (info) { - if (info.isReadonly) { - writeKeyword(writer, 130); - writeSpace(writer); - } - writePunctuation(writer, 20); - writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55); - writeSpace(writer); - writeKeyword(writer, keyword); - writePunctuation(writer, 21); - writePunctuation(writer, 55); - writeSpace(writer); - writeType(info.type, 0); - writePunctuation(writer, 24); - writer.writeLine(); - } - } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { writeKeyword(writer, 130); writeSpace(writer); } buildSymbolDisplay(prop, writer); - if (prop.flags & 536870912) { + if (prop.flags & 67108864) { writePunctuation(writer, 54); } } @@ -22946,8 +24365,8 @@ var ts; writePunctuation(writer, 24); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 134); - writeIndexSignature(resolved.numberIndexInfo, 132); + buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0, enclosingDeclaration, globalFlags, symbolStack); + buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, 1, enclosingDeclaration, globalFlags, symbolStack); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -23013,6 +24432,13 @@ var ts; writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } + var defaultType = getDefaultFromTypeParameter(tp); + if (defaultType) { + writeSpace(writer); + writePunctuation(writer, 57); + writeSpace(writer); + buildTypeDisplay(defaultType, writer, enclosingDeclaration, flags, symbolStack); + } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; @@ -23030,15 +24456,19 @@ var ts; } writePunctuation(writer, 55); writeSpace(writer); - buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); + var type = getTypeOfSymbol(p); + if (isRequiredInitializedParameter(parameterNode)) { + type = includeFalsyTypes(type, 2048); + } + buildTypeDisplay(type, writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 172) { + if (bindingPattern.kind === 173) { writePunctuation(writer, 16); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); writePunctuation(writer, 17); } - else if (bindingPattern.kind === 173) { + else if (bindingPattern.kind === 174) { writePunctuation(writer, 20); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -23052,7 +24482,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 174); + ts.Debug.assert(bindingElement.kind === 175); if (bindingElement.propertyName) { writer.writeProperty(ts.getTextOfNode(bindingElement.propertyName)); writePunctuation(writer, 55); @@ -23126,6 +24556,10 @@ var ts; buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + var returnType = getReturnTypeOfSignature(signature); + if (flags & 2048 && isTypeAny(returnType)) { + return; + } if (flags & 8) { writeSpace(writer); writePunctuation(writer, 35); @@ -23138,7 +24572,6 @@ var ts; buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); } else { - var returnType = getReturnTypeOfSignature(signature); buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } } @@ -23156,6 +24589,32 @@ var ts; buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } + function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 130); + writeSpace(writer); + } + writePunctuation(writer, 20); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 55); + writeSpace(writer); + switch (kind) { + case 1: + writeKeyword(writer, 132); + break; + case 0: + writeKeyword(writer, 135); + break; + } + writePunctuation(writer, 21); + writePunctuation(writer, 55); + writeSpace(writer); + buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); + writePunctuation(writer, 24); + writer.writeLine(); + } + } return _displayBuilder || (_displayBuilder = { buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, @@ -23166,6 +24625,7 @@ var ts; buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, + buildIndexSignatureDisplay: buildIndexSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay }); } @@ -23180,63 +24640,63 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 174: + case 175: return isDeclarationVisible(node.parent.parent); - case 223: + case 225: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 230: - case 226: - case 227: + case 232: case 228: - case 225: case 229: - case 234: + case 230: + case 227: + case 231: + case 236: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_7 = getDeclarationContainer(node); + var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 234 && parent_7.kind !== 261 && ts.isInAmbientContext(parent_7))) { - return isGlobalSourceFile(parent_7); + !(node.kind !== 236 && parent.kind !== 264 && ts.isInAmbientContext(parent))) { + return isGlobalSourceFile(parent); } - return isDeclarationVisible(parent_7); - case 147: - case 146: - case 151: - case 152: - case 149: + return isDeclarationVisible(parent); case 148: + case 147: + case 152: + case 153: + case 150: + case 149: if (ts.getModifierFlags(node) & (8 | 16)) { return false; } - case 150: - case 154: - case 153: + case 151: case 155: - case 144: - case 231: - case 158: + case 154: + case 156: + case 145: + case 233: case 159: - case 161: - case 157: + case 160: case 162: + case 158: case 163: case 164: case 165: case 166: + case 167: return isDeclarationVisible(node.parent); - case 236: - case 237: + case 238: case 239: + case 241: return false; - case 143: - case 261: - case 233: + case 144: + case 264: + case 235: return true; - case 240: + case 242: return false; default: return false; @@ -23245,10 +24705,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 240) { + if (node.parent && node.parent.kind === 242) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 243) { + else if (node.parent.kind === 245) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -23326,12 +24786,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 223: - case 224: + case 225: + case 226: + case 241: + case 240: case 239: case 238: - case 237: - case 236: node = node.parent; break; default: @@ -23350,15 +24810,12 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1) !== 0; } - function isTypeNever(type) { - return type && (type.flags & 8192) !== 0; - } function getTypeForBindingElementParent(node) { var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } function isComputedNonLiteralName(name) { - return name.kind === 142 && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 143 && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 6144); }); @@ -23371,17 +24828,16 @@ var ts; var members = ts.createMap(); var names = ts.createMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name_19 = properties_2[_i]; - names[ts.getTextOfPropertyName(name_19)] = true; + var name = properties_2[_i]; + names.set(ts.getTextOfPropertyName(name), true); } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - var inNamesToRemove = prop.name in names; + var inNamesToRemove = names.has(prop.name); var isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16); - var isMethod = prop.flags & 8192; var isSetOnlyAccessor = prop.flags & 65536 && !(prop.flags & 32768); - if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { - members[prop.name] = prop; + if (!inNamesToRemove && !isPrivate && !isClassMethod(prop) && !isSetOnlyAccessor) { + members.set(prop.name, prop); } } var stringIndexInfo = getIndexInfoOfType(source, 0); @@ -23401,7 +24857,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 172) { + if (pattern.kind === 173) { if (declaration.dotDotDotToken) { if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -23417,19 +24873,19 @@ var ts; type = getRestType(parentType, literalMembers, declaration.symbol); } else { - var name_20 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_20)) { + var name = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name)) { return anyType; } if (declaration.initializer) { getContextualType(declaration.initializer); } - var text = ts.getTextOfPropertyName(name_20); + var text = ts.getTextOfPropertyName(name); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_20)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); return unknownType; } } @@ -23462,7 +24918,7 @@ var ts; getUnionType([type, checkExpressionCached(declaration.initializer)], true) : type; } - function getTypeForVariableLikeDeclarationFromJSDocComment(declaration) { + function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); if (jsdocType) { return getTypeFromTypeNode(jsdocType); @@ -23475,33 +24931,42 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 175 && expr.elements.length === 0; + return expr.kind === 176 && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; } + function removeOptionalityFromAnnotation(annotatedType, declaration) { + var annotationIncludesUndefined = strictNullChecks && + declaration.kind === 145 && + declaration.initializer && + getFalsyFlags(annotatedType) & 2048 && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048); + return annotationIncludesUndefined ? getNonNullableType(annotatedType) : annotatedType; + } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { if (declaration.flags & 65536) { - var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); + var type = getTypeForDeclarationFromJSDocComment(declaration); if (type && type !== unknownType) { return type; } } - if (declaration.parent.parent.kind === 212) { + if (declaration.parent.parent.kind === 214) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 | 262144) ? indexType : stringType; } - if (declaration.parent.parent.kind === 213) { + if (declaration.parent.parent.kind === 215) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } if (declaration.type) { - return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); + var declaredType = removeOptionalityFromAnnotation(getTypeFromTypeNode(declaration.type), declaration); + return addOptionality(declaredType, declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536) && - declaration.kind === 223 && !ts.isBindingPattern(declaration.name) && + declaration.kind === 225 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -23510,10 +24975,10 @@ var ts; return autoArrayType; } } - if (declaration.kind === 144) { + if (declaration.kind === 145) { var func = declaration.parent; - if (func.kind === 152 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 151); + if (func.kind === 153 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 152); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -23539,7 +25004,10 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, declaration.questionToken && includeOptionality); } - if (declaration.kind === 258) { + if (ts.isJsxAttribute(declaration)) { + return trueType; + } + if (declaration.kind === 261) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -23547,6 +25015,21 @@ var ts; } return undefined; } + function getTypeForJSSpecialPropertyDeclaration(declaration) { + var expression = declaration.kind === 193 ? declaration : + declaration.kind === 178 ? ts.getAncestor(declaration, 193) : + undefined; + if (!expression) { + return unknownType; + } + if (expression.flags & 65536) { + var type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type && type !== unknownType) { + return getWidenedType(type); + } + } + return getWidenedLiteralType(checkExpressionCached(expression.right)); + } function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { return checkDeclarationInitializer(element); @@ -23574,11 +25057,11 @@ var ts; return; } var text = ts.getTextOfPropertyName(name); - var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); + var flags = 4 | (e.initializer ? 67108864 : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; - members[symbol.name] = symbol; + members.set(symbol.name, symbol); }); var result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); if (includePatternInType) { @@ -23604,7 +25087,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 172 + return pattern.kind === 173 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -23614,7 +25097,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 257) { + if (declaration.kind === 260) { return type; } return getWidenedType(type); @@ -23629,41 +25112,32 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 144 ? root.parent : root; + var memberDeclaration = root.kind === 145 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.flags & 134217728) { + if (symbol.flags & 16777216) { return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 240) { + if (declaration.kind === 242) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 && declaration.kind === 286 && declaration.typeExpression) { + if (declaration.flags & 65536 && declaration.kind === 290 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { return unknownType; } var type = void 0; - if (declaration.kind === 192 || - declaration.kind === 177 && declaration.parent.kind === 192) { - if (declaration.flags & 65536) { - var jsdocType = ts.getJSDocType(declaration.parent); - if (jsdocType) { - return links.type = getTypeFromTypeNode(jsdocType); - } - } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 192 ? - checkExpressionCached(decl.right) : - checkExpressionCached(decl.parent.right); }); - type = getUnionType(declaredTypes, true); + if (declaration.kind === 193 || + declaration.kind === 178 && declaration.parent.kind === 193) { + type = getWidenedType(getUnionType(ts.map(symbol.declarations, getTypeForJSSpecialPropertyDeclaration), true)); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -23677,7 +25151,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 151) { + if (accessor.kind === 152) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -23697,10 +25171,10 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 151); - var setter = ts.getDeclarationOfKind(symbol, 152); + var getter = ts.getDeclarationOfKind(symbol, 152); + var setter = ts.getDeclarationOfKind(symbol, 153); if (getter && getter.flags & 65536) { - var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); + var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; } @@ -23739,7 +25213,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 151); + var getter_1 = ts.getDeclarationOfKind(symbol, 152); 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)); } } @@ -23747,6 +25221,10 @@ var ts; } return links.type; } + function getBaseTypeVariableOfClass(symbol) { + var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); + return baseConstructorType.flags & 540672 ? baseConstructorType : undefined; + } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { @@ -23755,8 +25233,13 @@ var ts; } else { var type = createObjectType(16, symbol); - links.type = strictNullChecks && symbol.flags & 536870912 ? - includeFalsyTypes(type, 2048) : type; + if (symbol.flags & 32) { + var baseTypeVariable = getBaseTypeVariableOfClass(symbol); + links.type = baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; + } + else { + links.type = strictNullChecks && symbol.flags & 67108864 ? includeFalsyTypes(type, 2048) : type; + } } } return links.type; @@ -23803,7 +25286,7 @@ var ts; return anyType; } function getTypeOfSymbol(symbol) { - if (symbol.flags & 16777216) { + if (getCheckFlags(symbol) & 1) { return getTypeOfInstantiatedSymbol(symbol); } if (symbol.flags & (3 | 4)) { @@ -23829,13 +25312,18 @@ var ts; function hasBaseType(type, checkBase) { return check(type); function check(type) { - var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); + if (getObjectFlags(type) & (3 | 4)) { + var target = getTargetType(type); + return target === checkBase || ts.forEach(getBaseTypes(target), check); + } + else if (type.flags & 131072) { + return ts.forEach(type.types, check); + } } } function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { - var declaration = declarations_2[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -23852,9 +25340,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 226 || node.kind === 197 || - node.kind === 225 || node.kind === 184 || - node.kind === 149 || node.kind === 185) { + if (node.kind === 228 || node.kind === 198 || + node.kind === 227 || node.kind === 185 || + node.kind === 150 || node.kind === 186) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -23863,15 +25351,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 227); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 229); 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 === 227 || node.kind === 226 || - node.kind === 197 || node.kind === 228) { + if (node.kind === 229 || node.kind === 228 || + node.kind === 198 || node.kind === 230) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -23883,15 +25371,30 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } + function isMixinConstructorType(type) { + var signatures = getSignaturesOfType(type, 1); + if (signatures.length === 1) { + var s = signatures[0]; + return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + } + return false; + } function isConstructorType(type) { - return type.flags & 32768 && getSignaturesOfType(type, 1).length > 0; + if (isValidBaseType(type) && getSignaturesOfType(type, 1).length > 0) { + return true; + } + if (type.flags & 540672) { + var constraint = getBaseConstraintOfType(type); + return isValidBaseType(constraint) && isMixinConstructorType(constraint); + } + return false; } 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; }); + var typeArgCount = ts.length(typeArgumentNodes); + return ts.filter(getSignaturesOfType(type, 1), function (sig) { return typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); @@ -23911,7 +25414,7 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 32768) { + if (baseConstructorType.flags & (32768 | 131072)) { resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { @@ -23947,8 +25450,8 @@ var ts; } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - var baseConstructorType = getBaseConstructorTypeOfClass(type); - if (!(baseConstructorType.flags & 32768)) { + var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); + if (!(baseConstructorType.flags & (32768 | 131072))) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -23976,7 +25479,7 @@ var ts; if (baseType === unknownType) { return; } - if (!(getObjectFlags(getTargetType(baseType)) & 3)) { + if (!isValidBaseType(baseType)) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } @@ -24000,16 +25503,20 @@ var ts; } return true; } + function isValidBaseType(type) { + return type.flags & (32768 | 16777216) && !isGenericMappedType(type) || + type.flags & 131072 && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); + } 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 === 227 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 229 && 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 (getObjectFlags(getTargetType(baseType)) & 3) { + if (isValidBaseType(baseType)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; @@ -24033,7 +25540,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227) { + if (declaration.kind === 229) { if (declaration.flags & 64) { return false; } @@ -24066,7 +25573,7 @@ var ts; type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384); @@ -24083,7 +25590,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 285); + var declaration = ts.getDeclarationOfKind(symbol, 289); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -24094,7 +25601,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 228); + declaration = ts.getDeclarationOfKind(symbol, 230); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -24102,7 +25609,7 @@ var ts; if (typeParameters) { links.typeParameters = typeParameters; links.instantiations = ts.createMap(); - links.instantiations[getTypeListId(typeParameters)] = type; + links.instantiations.set(getTypeListId(typeParameters), type); } } else { @@ -24119,14 +25626,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 190 && expr.operator === 37 && + expr.kind === 191 && expr.operator === 37 && expr.operand.kind === 8 || - expr.kind === 70 && !!symbol.exports[expr.text]; + expr.kind === 70 && !!symbol.exports.get(expr.text); } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 231) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -24151,10 +25658,10 @@ var ts; enumType.symbol = symbol; if (enumHasLiteralMembers(symbol)) { var memberTypeList = []; - var memberTypes = ts.createMap(); + var memberTypes = []; for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 231) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -24171,7 +25678,7 @@ var ts; if (memberTypeList.length > 1) { enumType.flags |= 65536; enumType.types = memberTypeList; - unionTypes[getTypeListId(memberTypeList)] = enumType; + unionTypes.set(getTypeListId(memberTypeList), enumType); } } } @@ -24192,9 +25699,6 @@ var ts; if (!links.declaredType) { var type = createType(16384); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 143).constraint) { - type.constraint = noConstraintType; - } links.declaredType = type; } return links.declaredType; @@ -24207,7 +25711,6 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 16777216) === 0); if (symbol.flags & (32 | 64)) { return getDeclaredTypeOfClassOrInterface(symbol); } @@ -24242,19 +25745,20 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 136: + case 133: case 104: - case 137: + case 138: case 94: case 129: - case 171: + case 172: return true; - case 162: + case 163: return isIndependentType(node.elementType); - case 157: + case 158: return isIndependentTypeReference(node); } return false; @@ -24263,7 +25767,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 150 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 151 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -24279,12 +25783,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 147: - case 146: - return isIndependentVariableLikeDeclaration(declaration); - case 149: case 148: + case 147: + return isIndependentVariableLikeDeclaration(declaration); case 150: + case 149: + case 151: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -24295,7 +25799,7 @@ var ts; var result = ts.createMap(); for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { var symbol = symbols_1[_i]; - result[symbol.name] = symbol; + result.set(symbol.name, symbol); } return result; } @@ -24303,15 +25807,15 @@ var ts; var result = ts.createMap(); 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); + result.set(symbol.name, mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; } function addInheritedMembers(symbols, baseSymbols) { for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) { var s = baseSymbols_1[_i]; - if (!symbols[s.name]) { - symbols[s.name] = s; + if (!symbols.has(s.name)) { + symbols.set(s.name, s); } } } @@ -24319,8 +25823,8 @@ var ts; 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.declaredCallSignatures = getSignaturesOfSymbol(symbol.members.get("__call")); + type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members.get("__new")); type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0); type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1); } @@ -24328,7 +25832,14 @@ var ts; } function getTypeWithThisArgument(type, thisArgument) { if (getObjectFlags(type) & 4) { - return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + var target = type.target; + var typeArguments = type.typeArguments; + if (ts.length(target.typeParameters) === ts.length(typeArguments)) { + return createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); + } + } + else if (type.flags & 131072) { + return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument); })); } return type; } @@ -24364,7 +25875,7 @@ var ts; 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)); + addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0); @@ -24407,13 +25918,14 @@ var ts; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); - var typeArgCount = typeArguments ? typeArguments.length : 0; + var typeArgCount = ts.length(typeArguments); var result = []; for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { var baseSig = baseSignatures_1[_i]; - var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; - if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); + var typeParamCount = ts.length(baseSig.typeParameters); + if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) { + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -24467,7 +25979,7 @@ var ts; s = cloneSignature(signature); if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) { var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return getTypeOfSymbol(sig.thisParameter) || anyType; }), true); - s.thisParameter = createTransientSymbol(signature.thisParameter, thisType); + s.thisParameter = createSymbolWithType(signature.thisParameter, thisType); } s.resolvedReturnType = undefined; s.unionSignatures = unionSignatures; @@ -24509,17 +26021,44 @@ var ts; function unionSpreadIndexInfos(info1, info2) { return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly); } + function includeMixinType(type, types, index) { + var mixedTypes = []; + for (var i = 0; i < types.length; i++) { + if (i === index) { + mixedTypes.push(type); + } + else if (isMixinConstructorType(types[i])) { + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1)[0])); + } + } + return getIntersectionType(mixedTypes); + } function resolveIntersectionTypeMembers(type) { var callSignatures = emptyArray; var constructSignatures = emptyArray; - var stringIndexInfo = undefined; - var numberIndexInfo = undefined; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + var stringIndexInfo; + var numberIndexInfo; + var types = type.types; + var mixinCount = ts.countWhere(types, isMixinConstructorType); + var _loop_3 = function (i) { + var t = type.types[i]; + if (mixinCount === 0 || mixinCount === types.length && i === 0 || !isMixinConstructorType(t)) { + var signatures = getSignaturesOfType(t, 1); + if (signatures.length && mixinCount > 0) { + signatures = ts.map(signatures, function (s) { + var clone = cloneSignature(s); + clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, i); + return clone; + }); + } + constructSignatures = ts.concatenate(constructSignatures, signatures); + } callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1)); stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0)); numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1)); + }; + for (var i = 0; i < types.length; i++) { + _loop_3(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } @@ -24535,8 +26074,8 @@ var ts; } else if (symbol.flags & 2048) { var members = symbol.members; - var callSignatures = getSignaturesOfSymbol(members["__call"]); - var constructSignatures = getSignaturesOfSymbol(members["__new"]); + var callSignatures = getSignaturesOfSymbol(members.get("__call")); + var constructSignatures = getSignaturesOfSymbol(members.get("__new")); var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0); var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1); setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -24549,14 +26088,14 @@ var ts; } if (symbol.flags & 32) { var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); + constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 32768) { + if (baseConstructorType.flags & (32768 | 131072 | 540672)) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); + addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } } var numberIndexInfo = symbol.flags & 384 ? enumNumberIndexInfo : undefined; @@ -24576,8 +26115,11 @@ var ts; var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); var templateReadonly = !!type.declaration.readonlyToken; var templateOptional = !!type.declaration.questionToken; - if (type.declaration.typeParameter.constraint.kind === 168) { - forEachType(getLiteralTypeFromPropertyNames(modifiersType), addMemberForKeyType); + if (type.declaration.typeParameter.constraint.kind === 169) { + for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { + var propertySymbol = _a[_i]; + addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol); + } if (getIndexInfoOfType(modifiersType, 0)) { addMemberForKeyType(stringType); } @@ -24588,18 +26130,21 @@ var ts; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, undefined); - function addMemberForKeyType(t) { - var iterationMapper = createUnaryTypeMapper(typeParameter, t); + function addMemberForKeyType(t, propertySymbol) { + var iterationMapper = createTypeMapper([typeParameter], [t]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; var propType = instantiateType(templateType, templateMapper); if (t.flags & 32) { var propName = t.text; var modifiersProp = getPropertyOfType(modifiersType, propName); - var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 536870912); - var prop = createSymbol(4 | 67108864 | (isOptional ? 536870912 : 0), propName); + var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 67108864); + var prop = createSymbol(4 | (isOptional ? 67108864 : 0), propName); + prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 4 : 0; prop.type = propType; - prop.isReadonly = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp); - members[propName] = prop; + if (propertySymbol) { + prop.mappedTypeOrigin = propertySymbol; + } + members.set(propName, prop); } else if (t.flags & 2) { stringIndexInfo = createIndexInfo(propType, templateReadonly); @@ -24623,21 +26168,18 @@ var ts; function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { var constraintDeclaration = type.declaration.typeParameter.constraint; - if (constraintDeclaration.kind === 168) { + if (constraintDeclaration.kind === 169) { type.modifiersType = instantiateType(getTypeFromTypeNode(constraintDeclaration.type), type.mapper || identityMapper); } else { var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint.flags & 16384 ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint.flags & 262144 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 16384 ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 262144 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; } - function getErasedTemplateTypeFromMappedType(type) { - return instantiateType(getTemplateTypeFromMappedType(type), createUnaryTypeMapper(getTypeParameterFromMappedType(type), anyType)); - } function isGenericMappedType(type) { if (getObjectFlags(type) & 32) { var constraintType = getConstraintTypeFromMappedType(type); @@ -24679,35 +26221,33 @@ var ts; function getPropertyOfObjectType(type, name) { if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && 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]; - getUnionOrIntersectionProperty(type, prop.name); - } - if (type.flags & 65536) { - break; - } - } - var props = type.resolvedProperties; - if (props) { - var result = []; - for (var key in props) { - var prop = props[key]; - if (!(prop.flags & 268435456 && prop.isPartial)) { - result.push(prop); + if (!type.resolvedProperties) { + var members = ts.createMap(); + 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]; + if (!members.has(prop.name)) { + var combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.name); + if (combinedProp) { + members.set(prop.name, combinedProp); + } + } + } + if (type.flags & 65536) { + break; } } - return result; + type.resolvedProperties = getNamedMembers(members); } - return emptyArray; + return type.resolvedProperties; } function getPropertiesOfType(type) { type = getApparentType(type); @@ -24715,36 +26255,110 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } - function getApparentTypeOfTypeVariable(type) { - if (!type.resolvedApparentType) { - var constraintType = getConstraintOfTypeVariable(type); - while (constraintType && constraintType.flags & 16384) { - constraintType = getConstraintOfTypeVariable(constraintType); - } - type.resolvedApparentType = getTypeWithThisArgument(constraintType || emptyObjectType, type); + function getConstraintOfType(type) { + return type.flags & 16384 ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + } + function getConstraintOfTypeParameter(typeParameter) { + return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; + } + function getBaseConstraintOfType(type) { + var constraint = getResolvedBaseConstraint(type); + return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + } + function hasNonCircularBaseConstraint(type) { + return getResolvedBaseConstraint(type) !== circularConstraintType; + } + function getResolvedBaseConstraint(type) { + var typeStack; + var circular; + if (!type.resolvedBaseConstraint) { + typeStack = []; + var constraint = getBaseConstraint(type); + type.resolvedBaseConstraint = circular ? circularConstraintType : getTypeWithThisArgument(constraint || noConstraintType, type); } - return type.resolvedApparentType; + return type.resolvedBaseConstraint; + function getBaseConstraint(t) { + if (ts.contains(typeStack, t)) { + circular = true; + return undefined; + } + typeStack.push(t); + var result = computeBaseConstraint(t); + typeStack.pop(); + return result; + } + function computeBaseConstraint(t) { + if (t.flags & 16384) { + var constraint = getConstraintFromTypeParameter(t); + return t.isThisType ? constraint : + constraint ? getBaseConstraint(constraint) : undefined; + } + if (t.flags & 196608) { + var types = t.types; + var baseTypes = []; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var type_1 = types_2[_i]; + var baseType = getBaseConstraint(type_1); + if (baseType) { + baseTypes.push(baseType); + } + } + return t.flags & 65536 && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 131072 && baseTypes.length ? getIntersectionType(baseTypes) : + undefined; + } + if (t.flags & 262144) { + return stringType; + } + if (t.flags & 524288) { + var baseObjectType = getBaseConstraint(t.objectType); + var baseIndexType = getBaseConstraint(t.indexType); + var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; + return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + } + return t; + } + } + function getApparentTypeOfIntersectionType(type) { + return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type)); + } + function getDefaultFromTypeParameter(typeParameter) { + if (!typeParameter.default) { + if (typeParameter.target) { + var targetDefault = getDefaultFromTypeParameter(typeParameter.target); + typeParameter.default = targetDefault ? instantiateType(targetDefault, typeParameter.mapper) : noConstraintType; + } + else { + var defaultDeclaration = typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameter(decl) && decl.default; }); + typeParameter.default = defaultDeclaration ? getTypeFromTypeNode(defaultDeclaration) : noConstraintType; + } + } + return typeParameter.default === noConstraintType ? undefined : typeParameter.default; } function getApparentType(type) { - var t = type.flags & 540672 ? getApparentTypeOfTypeVariable(type) : type; - return t.flags & 262178 ? globalStringType : - t.flags & 340 ? globalNumberType : - t.flags & 136 ? globalBooleanType : - t.flags & 512 ? getGlobalESSymbolType() : - t; + var t = type.flags & 540672 ? getBaseConstraintOfType(type) || emptyObjectType : type; + return t.flags & 131072 ? getApparentTypeOfIntersectionType(t) : + t.flags & 262178 ? globalStringType : + t.flags & 340 ? globalNumberType : + t.flags & 136 ? globalBooleanType : + t.flags & 512 ? getGlobalESSymbolType() : + t.flags & 16777216 ? emptyObjectType : + t; } function createUnionOrIntersectionProperty(containingType, name) { - var types = containingType.types; var props; - var commonFlags = (containingType.flags & 131072) ? 536870912 : 0; - var isReadonly = false; - var isPartial = false; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var current = types_2[_i]; + var types = containingType.types; + var isUnion = containingType.flags & 65536; + var excludeModifiers = isUnion ? 24 : 0; + var commonFlags = isUnion ? 0 : 67108864; + var checkFlags = 2; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var current = types_3[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16))) { + var modifiers = prop ? getDeclarationModifierFlagsFromSymbol(prop) : 0; + if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; if (!props) { props = [prop]; @@ -24752,25 +26366,26 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } - if (isReadonlySymbol(prop)) { - isReadonly = true; - } + checkFlags |= (isReadonlySymbol(prop) ? 4 : 0) | + (!(modifiers & 24) ? 32 : 0) | + (modifiers & 16 ? 64 : 0) | + (modifiers & 8 ? 128 : 0) | + (modifiers & 32 ? 256 : 0); } - else if (containingType.flags & 65536) { - isPartial = true; + else if (isUnion) { + checkFlags |= 8; } } } if (!props) { return undefined; } - if (props.length === 1 && !isPartial) { + if (props.length === 1 && !(checkFlags & 8)) { return props[0]; } var propTypes = []; var declarations = []; var commonType = undefined; - var hasNonUniformType = false; for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { var prop = props_1[_a]; if (prop.declarations) { @@ -24781,39 +26396,37 @@ var ts; commonType = type; } else if (type !== commonType) { - hasNonUniformType = true; + checkFlags |= 16; } propTypes.push(type); } - var result = createSymbol(4 | 67108864 | 268435456 | commonFlags, name); + var result = createSymbol(4 | commonFlags, name); + result.checkFlags = checkFlags; result.containingType = containingType; - result.hasNonUniformType = hasNonUniformType; - result.isPartial = isPartial; result.declarations = declarations; - result.isReadonly = isReadonly; - result.type = containingType.flags & 65536 ? getUnionType(propTypes) : getIntersectionType(propTypes); + result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } function getUnionOrIntersectionProperty(type, name) { - var properties = type.resolvedProperties || (type.resolvedProperties = ts.createMap()); - var property = properties[name]; + var properties = type.propertyCache || (type.propertyCache = ts.createMap()); + var property = properties.get(name); if (!property) { property = createUnionOrIntersectionProperty(type, name); if (property) { - properties[name] = property; + properties.set(name, property); } } return property; } function getPropertyOfUnionOrIntersectionType(type, name) { var property = getUnionOrIntersectionProperty(type, name); - return property && !(property.flags & 268435456 && property.isPartial) ? property : undefined; + return property && !(getCheckFlags(property) & 8) ? property : undefined; } function getPropertyOfType(type, name) { type = getApparentType(type); if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } @@ -24892,16 +26505,16 @@ var ts; } function symbolsToArray(symbols) { var result = []; - for (var id in symbols) { + symbols.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { - result.push(symbols[id]); + result.push(symbol); } - } + }); return result; } function isJSDocOptionalParameter(node) { if (node.flags & 65536) { - if (node.type && node.type.kind === 273) { + if (node.type && node.type.kind === 277) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -24912,7 +26525,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 273; + return paramTag.typeExpression.type.kind === 277; } } } @@ -24936,6 +26549,12 @@ var ts; ts.Debug.assert(parameterIndex >= 0); return parameterIndex >= signature.minArgumentCount; } + var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); + if (iife) { + return !node.type && + !node.dotDotDotToken && + ts.indexOf(node.parent.parameters, node) >= iife.arguments.length; + } return false; } function createTypePredicateFromTypePredicateNode(node) { @@ -24955,16 +26574,49 @@ var ts; }; } } + function getMinTypeArgumentCount(typeParameters) { + var minTypeArgumentCount = 0; + if (typeParameters) { + for (var i = 0; i < typeParameters.length; i++) { + if (!getDefaultFromTypeParameter(typeParameters[i])) { + minTypeArgumentCount = i + 1; + } + } + } + return minTypeArgumentCount; + } + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount) { + var numTypeParameters = ts.length(typeParameters); + if (numTypeParameters) { + var numTypeArguments = ts.length(typeArguments); + if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) { + if (!typeArguments) { + typeArguments = []; + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + typeArguments[i] = emptyObjectType; + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + var mapper = createTypeMapper(typeParameters, typeArguments); + var defaultType = getDefaultFromTypeParameter(typeParameters[i]); + typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType; + } + } + } + return typeArguments; + } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; var hasLiteralTypes = false; - var minArgumentCount = -1; + var minArgumentCount = 0; var thisParameter = undefined; var hasThisParameter = void 0; + var iife = ts.getImmediatelyInvokedFunctionExpression(declaration); var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); - for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { + var isUntypedSignatureInJSFile = !iife && !isJSConstructSignature && ts.isInJavaScriptFile(declaration) && !ts.hasJSDocParameterTags(declaration); + for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) { @@ -24978,41 +26630,34 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 171) { + if (param.type && param.type.kind === 172) { hasLiteralTypes = true; } - if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { - if (minArgumentCount < 0) { - minArgumentCount = i - (hasThisParameter ? 1 : 0); - } - } - else { - minArgumentCount = -1; + var isOptionalParameter_1 = param.initializer || param.questionToken || param.dotDotDotToken || + iife && parameters.length > iife.arguments.length && !param.type || + isJSDocOptionalParameter(param) || + isUntypedSignatureInJSFile; + if (!isOptionalParameter_1) { + minArgumentCount = parameters.length; } } - if ((declaration.kind === 151 || declaration.kind === 152) && + if ((declaration.kind === 152 || declaration.kind === 153) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 151 ? 152 : 151; + var otherKind = declaration.kind === 152 ? 153 : 152; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); - } - if (isJSConstructSignature) { - minArgumentCount--; - } - var classType = declaration.kind === 150 ? + var classType = declaration.kind === 151 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 156 ? + var typePredicate = declaration.type && declaration.type.kind === 157 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -25035,8 +26680,8 @@ var ts; return type; } } - if (declaration.kind === 151 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 152); + if (declaration.kind === 152 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 153); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -25047,23 +26692,23 @@ var ts; if (!symbol) return emptyArray; var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { + for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 158: case 159: - case 225: - case 149: - case 148: + case 160: + case 227: case 150: - case 153: + case 149: + case 151: case 154: case 155: - case 151: + case 156: case 152: - case 184: + case 153: case 185: - case 274: + case 186: + case 278: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -25131,9 +26776,14 @@ var ts; return anyType; } function getSignatureInstantiation(signature, typeArguments) { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); - return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments)); + var instantiation = instantiations.get(id); + if (!instantiation) { + instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments)); + } + return instantiation; } function createSignatureInstantiation(signature, typeArguments) { return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); @@ -25148,7 +26798,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 150 || signature.declaration.kind === 154; + var isConstructor = signature.declaration.kind === 151 || signature.declaration.kind === 155; var type = createObjectType(16); type.members = emptySymbols; type.properties = emptyArray; @@ -25159,10 +26809,10 @@ var ts; return signature.isolatedSignatureType; } function getIndexSymbol(symbol) { - return symbol.members["__index"]; + return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 132 : 134; + var syntaxKind = kind === 1 ? 132 : 135; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -25189,21 +26839,9 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 143).constraint; + return ts.getDeclarationOfKind(type.symbol, 144).constraint; } - function hasConstraintReferenceTo(type, target) { - var checked; - while (type && type.flags & 16384 && !(type.isThisType) && !ts.contains(checked, type)) { - if (type === target) { - return true; - } - (checked || (checked = [])).push(type); - var constraintDeclaration = getConstraintDeclaration(type); - type = constraintDeclaration && getTypeFromTypeNode(constraintDeclaration); - } - return false; - } - function getConstraintOfTypeParameter(typeParameter) { + function getConstraintFromTypeParameter(typeParameter) { if (!typeParameter.constraint) { if (typeParameter.target) { var targetConstraint = getConstraintOfTypeParameter(typeParameter.target); @@ -25211,23 +26849,13 @@ var ts; } else { var constraintDeclaration = getConstraintDeclaration(typeParameter); - var constraint = getTypeFromTypeNode(constraintDeclaration); - if (hasConstraintReferenceTo(constraint, typeParameter)) { - error(constraintDeclaration, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); - constraint = unknownType; - } - typeParameter.constraint = constraint; + typeParameter.constraint = constraintDeclaration ? getTypeFromTypeNode(constraintDeclaration) : noConstraintType; } } return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } - function getConstraintOfTypeVariable(type) { - return type.flags & 16384 ? getConstraintOfTypeParameter(type) : - type.flags & 524288 ? type.constraint : - undefined; - } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 143).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 144).parent); } function getTypeListId(types) { var result = ""; @@ -25254,8 +26882,8 @@ var ts; } function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var type = types_3[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -25264,9 +26892,10 @@ var ts; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); - var type = target.instantiations[id]; + var type = target.instantiations.get(id); if (!type) { - type = target.instantiations[id] = createObjectType(4, target.symbol); + type = createObjectType(4, target.symbol); + target.instantiations.set(id, type); type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0; type.target = target; type.typeArguments = typeArguments; @@ -25282,17 +26911,22 @@ var ts; return type; } function getTypeReferenceArity(type) { - return type.target.typeParameters ? type.target.typeParameters.length : 0; + return ts.length(type.target.typeParameters); } function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(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); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, undefined, 1), minTypeArgumentCount, typeParameters.length); return unknownType; } - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount)); + return createTypeReference(type, typeArguments); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); @@ -25305,14 +26939,22 @@ var ts; var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + var instantiation = links.instantiations.get(id); + if (!instantiation) { + links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + } + return instantiation; } function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).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); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return unknownType; } var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); @@ -25333,11 +26975,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 157: + case 158: return node.typeName; - case 272: + case 276: return node.name; - case 199: + case 200: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -25361,7 +27003,7 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 272) { + if (symbol.flags & 107455 && node.kind === 276) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); @@ -25371,13 +27013,13 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 272) { + if (node.kind === 276) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { - var typeNameOrExpression = node.kind === 157 + var typeNameOrExpression = node.kind === 158 ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -25403,12 +27045,12 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var declaration = declarations_4[_i]; switch (declaration.kind) { - case 226: - case 227: + case 228: case 229: + case 231: return declaration; } } @@ -25421,7 +27063,7 @@ var ts; 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) { + if (ts.length(type.typeParameters) !== arity) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); return arity ? emptyGenericType : emptyObjectType; } @@ -25476,7 +27118,7 @@ var ts; for (var i = 0; i < arity; i++) { var typeParameter = createType(16384); typeParameters.push(typeParameter); - var property = createSymbol(4 | 67108864, "" + i); + var property = createSymbol(4, "" + i); property.type = typeParameter; properties.push(property); } @@ -25485,7 +27127,7 @@ var ts; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384); @@ -25567,14 +27209,14 @@ var ts; } } function addTypesToUnion(typeSet, types) { - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var t = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var t = types_6[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -25582,8 +27224,9 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; + if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } } @@ -25661,10 +27304,11 @@ var ts; return types[0]; } var id = getTypeListId(types); - var type = unionTypes[id]; + var type = unionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(types, 6144); - type = unionTypes[id] = createType(65536 | propagatedFlags); + type = createType(65536 | propagatedFlags); + unionTypes.set(id, type); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -25689,12 +27333,15 @@ var ts; if (type.flags & 65536 && typeSet.unionIndex === undefined) { typeSet.unionIndex = typeSet.length; } - typeSet.push(type); + if (!(type.flags & 32768 && type.objectFlags & 16 && + type.symbol && type.symbol.flags & (16 | 8192) && containsIdenticalType(typeSet, type))) { + typeSet.push(type); + } } } function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; addTypeToIntersection(typeSet, type); } } @@ -25716,10 +27363,11 @@ var ts; return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex, t)); }), false, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); - var type = intersectionTypes[id]; + var type = intersectionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, 6144); - type = intersectionTypes[id] = createType(131072 | propagatedFlags); + type = createType(131072 | propagatedFlags); + intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -25769,21 +27417,10 @@ var ts; var type = createType(524288); type.objectType = objectType; type.indexType = indexType; - if (type.objectType.flags & 229376) { - type.constraint = getIndexTypeOfType(type.objectType, 0); - } - else if (type.objectType.flags & 540672) { - var apparentType = getApparentTypeOfTypeVariable(type.objectType); - if (apparentType !== emptyObjectType) { - type.constraint = isTypeOfKind(type.indexType, 262178) ? - getIndexedAccessType(apparentType, type.indexType) : - getIndexTypeOfType(apparentType, 0); - } - } return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 178 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 ? accessNode : undefined; var propName = indexType.flags & (32 | 64 | 256) ? indexType.text : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? @@ -25812,7 +27449,7 @@ var ts; getIndexInfoOfType(objectType, 0) || undefined; if (indexInfo) { - if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); return unknownType; } @@ -25831,7 +27468,7 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 178 ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 179 ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (32 | 64)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); } @@ -25845,33 +27482,31 @@ var ts; return unknownType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 178 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 ? accessNode : undefined; if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); return unknownType; } - var mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); + var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } function getIndexedAccessType(objectType, indexType, accessNode) { if (maybeTypeOfKind(indexType, 540672 | 262144) || - maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 178) || + maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 179) || isGenericMappedType(objectType)) { if (objectType.flags & 1) { return objectType; } - if (accessNode) { - if (!isTypeAssignableTo(indexType, getIndexType(objectType))) { - error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); - return unknownType; - } - } if (isGenericMappedType(objectType)) { return getIndexedAccessForMappedType(objectType, indexType, accessNode); } var id = objectType.id + "," + indexType.id; - return indexedAccessTypes[id] || (indexedAccessTypes[id] = createIndexedAccessType(objectType, indexType)); + var type = indexedAccessTypes.get(id); + if (!type) { + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType)); + } + return type; } var apparentObjectType = getApparentType(objectType); if (indexType.flags & 65536 && !(indexType.flags & 8190)) { @@ -25911,7 +27546,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); - if (ts.isEmpty(node.symbol.members) && !aliasSymbol) { + if (node.symbol.members.size === 0 && !aliasSymbol) { links.resolvedType = emptyTypeLiteralType; } else { @@ -25924,13 +27559,13 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 228 ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 230 ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } - function getSpreadType(left, right, isFromObjectLiteral) { + function getSpreadType(left, right) { if (left.flags & 1 || right.flags & 1) { return anyType; } @@ -25943,10 +27578,13 @@ var ts; return left; } if (left.flags & 65536) { - return mapType(left, function (t) { return getSpreadType(t, right, isFromObjectLiteral); }); + return mapType(left, function (t) { return getSpreadType(t, right); }); } if (right.flags & 65536) { - return mapType(right, function (t) { return getSpreadType(left, t, isFromObjectLiteral); }); + return mapType(right, function (t) { return getSpreadType(left, t); }); + } + if (right.flags & 16777216) { + return emptyObjectType; } var members = ts.createMap(); var skippedPrivateMembers = ts.createMap(); @@ -25962,42 +27600,45 @@ var ts; } for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; - var isOwnProperty = !(rightProp.flags & 8192) || isFromObjectLiteral; var isSetterWithoutGetter = rightProp.flags & 65536 && !(rightProp.flags & 32768); if (getDeclarationModifierFlagsFromSymbol(rightProp) & (8 | 16)) { - skippedPrivateMembers[rightProp.name] = true; + skippedPrivateMembers.set(rightProp.name, true); } - else if (isOwnProperty && !isSetterWithoutGetter) { - members[rightProp.name] = rightProp; + else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { + members.set(rightProp.name, rightProp); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { var leftProp = _c[_b]; if (leftProp.flags & 65536 && !(leftProp.flags & 32768) - || leftProp.name in skippedPrivateMembers) { + || skippedPrivateMembers.has(leftProp.name) + || isClassMethod(leftProp)) { continue; } - if (leftProp.name in members) { - var rightProp = members[leftProp.name]; + if (members.has(leftProp.name)) { + var rightProp = members.get(leftProp.name); var rightType = getTypeOfSymbol(rightProp); - if (maybeTypeOfKind(rightType, 2048) || rightProp.flags & 536870912) { + if (maybeTypeOfKind(rightType, 2048) || rightProp.flags & 67108864) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 | 67108864 | (leftProp.flags & 536870912); + var flags = 4 | (leftProp.flags & 67108864); var result = createSymbol(flags, leftProp.name); + result.checkFlags = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp) ? 4 : 0; result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072)]); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; - result.isReadonly = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp); - members[leftProp.name] = result; + members.set(leftProp.name, result); } } else { - members[leftProp.name] = leftProp; + members.set(leftProp.name, leftProp); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } + function isClassMethod(prop) { + return prop.flags & 8192 && ts.find(prop.declarations, function (decl) { return ts.isClassLike(decl.parent); }); + } function createLiteralType(flags, text) { var type = createType(flags); type.text = text; @@ -26019,7 +27660,11 @@ var ts; } function getLiteralTypeForText(flags, text) { var map = flags & 32 ? stringLiteralTypes : numericLiteralTypes; - return map[text] || (map[text] = createLiteralType(flags, text)); + var type = map.get(text); + if (!type) { + map.set(text, type = createLiteralType(flags, text)); + } + return type; } function getTypeFromLiteralTypeNode(node) { var links = getNodeLinks(node); @@ -26047,9 +27692,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 227)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 229)) { if (!(ts.getModifierFlags(container) & 32) && - (container.kind !== 150 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 151 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -26066,85 +27711,87 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118: - case 263: - case 264: + case 267: + case 268: return anyType; - case 134: + case 135: return stringType; case 132: return numberType; case 121: return booleanType; - case 135: + case 136: return esSymbolType; case 104: return voidType; - case 137: + case 138: return undefinedType; case 94: return nullType; case 129: return neverType; - case 289: + case 133: + return nonPrimitiveType; + case 293: return nullType; - case 290: + case 294: return undefinedType; - case 291: + case 295: return neverType; - case 167: + case 168: case 98: return getTypeFromThisTypeNode(node); - case 171: + case 172: return getTypeFromLiteralTypeNode(node); - case 288: + case 292: return getTypeFromLiteralTypeNode(node.literal); - case 157: - case 272: - return getTypeFromTypeReference(node); - case 156: - return booleanType; - case 199: - return getTypeFromTypeReference(node); - case 160: - return getTypeFromTypeQueryNode(node); - case 162: - case 265: - return getTypeFromArrayTypeNode(node); - case 163: - return getTypeFromTupleTypeNode(node); - case 164: - case 266: - return getTypeFromUnionTypeNode(node); - case 165: - return getTypeFromIntersectionTypeNode(node); - case 166: - case 268: - case 269: - case 276: - case 277: - case 273: - return getTypeFromTypeNode(node.type); - case 270: - return getTypeFromTypeNode(node.literal); case 158: - case 159: + case 276: + return getTypeFromTypeReference(node); + case 157: + return booleanType; + case 200: + return getTypeFromTypeReference(node); case 161: - case 287: + return getTypeFromTypeQueryNode(node); + case 163: + case 269: + return getTypeFromArrayTypeNode(node); + case 164: + return getTypeFromTupleTypeNode(node); + case 165: + case 270: + return getTypeFromUnionTypeNode(node); + case 166: + return getTypeFromIntersectionTypeNode(node); + case 167: + case 272: + case 273: + case 280: + case 281: + case 277: + return getTypeFromTypeNode(node.type); case 274: + return getTypeFromTypeNode(node.literal); + case 159: + case 160: + case 162: + case 291: + case 278: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 168: - return getTypeFromTypeOperatorNode(node); case 169: - return getTypeFromIndexedAccessTypeNode(node); + return getTypeFromTypeOperatorNode(node); case 170: + return getTypeFromIndexedAccessTypeNode(node); + case 171: return getTypeFromMappedTypeNode(node); case 70: - case 141: + case 142: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 267: + case 271: return getTypeFromJSDocTupleType(node); - case 275: + case 279: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -26171,13 +27818,13 @@ var ts; var instantiations = mapper.instantiations || (mapper.instantiations = []); return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); } - function createUnaryTypeMapper(source, target) { + function makeUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } - function createBinaryTypeMapper(source1, target1, source2, target2) { + function makeBinaryTypeMapper(source1, target1, source2, target2) { return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; } - function createArrayTypeMapper(sources, targets) { + function makeArrayTypeMapper(sources, targets) { return function (t) { for (var i = 0; i < sources.length; i++) { if (t === sources[i]) { @@ -26188,16 +27835,20 @@ var ts; }; } function createTypeMapper(sources, targets) { - var count = sources.length; - var mapper = count == 1 ? createUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : - count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : - createArrayTypeMapper(sources, targets); + var mapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : + makeArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; return mapper; } function createTypeEraser(sources) { return createTypeMapper(sources, undefined); } + function createBackreferenceMapper(typeParameters, index) { + var mapper = function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; + mapper.mappedTypes = typeParameters; + return mapper; + } function getInferenceMapper(context) { if (!context.mapper) { var mapper = function (t) { @@ -26221,7 +27872,12 @@ var ts; } function combineTypeMappers(mapper1, mapper2) { var mapper = function (t) { return instantiateType(mapper1(t), mapper2); }; - mapper.mappedTypes = mapper1.mappedTypes; + mapper.mappedTypes = ts.concatenate(mapper1.mappedTypes, mapper2.mappedTypes); + return mapper; + } + function createReplacementMapper(source, target, baseMapper) { + var mapper = function (t) { return t === source ? target : baseMapper(t); }; + mapper.mappedTypes = baseMapper.mappedTypes; return mapper; } function cloneTypeParameter(typeParameter) { @@ -26266,12 +27922,13 @@ var ts; return result; } function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 16777216) { + if (getCheckFlags(symbol) & 1) { var links = getSymbolLinks(symbol); symbol = links.target; mapper = combineTypeMappers(links.mapper, mapper); } - var result = createSymbol(16777216 | 67108864 | symbol.flags, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); + result.checkFlags = 1; result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -26293,17 +27950,16 @@ var ts; var constraintType = getConstraintTypeFromMappedType(type); if (constraintType.flags & 262144) { var typeVariable_1 = constraintType.type; - var mappedTypeVariable = instantiateType(typeVariable_1, mapper); - if (typeVariable_1 !== mappedTypeVariable) { - return mapType(mappedTypeVariable, function (t) { - if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); - } - return t; - }); + if (typeVariable_1.flags & 16384) { + var mappedTypeVariable = instantiateType(typeVariable_1, mapper); + if (typeVariable_1 !== mappedTypeVariable) { + return mapType(mappedTypeVariable, function (t) { + if (isMappableType(t)) { + return instantiateMappedObjectType(type, createReplacementMapper(typeVariable_1, t, mapper)); + } + return t; + }); + } } } return instantiateMappedObjectType(type, mapper); @@ -26324,26 +27980,26 @@ var ts; return false; } var mappedTypes = mapper.mappedTypes; - var node = symbol.declarations[0].parent; + var node = symbol.declarations[0]; while (node) { switch (node.kind) { - case 158: case 159: - case 225: - case 149: - case 148: + case 160: + case 227: case 150: - case 153: + case 149: + case 151: case 154: case 155: - case 151: + case 156: case 152: - case 184: + case 153: case 185: - case 226: - case 197: - case 227: + case 186: case 228: + case 198: + case 229: + case 230: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -26353,15 +28009,29 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 227) { + if (ts.isClassLike(node) || node.kind === 229) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 230: - case 261: + case 171: + if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { + return true; + } + break; + case 278: + var func = node; + for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { + var p = _c[_b]; + if (ts.contains(mappedTypes, getTypeOfNode(p))) { + return true; + } + } + break; + case 232: + case 264: return false; } node = node.parent; @@ -26371,7 +28041,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 261 || parentKind === 231; + return parentKind === 264 || parentKind === 233; } return false; } @@ -26423,28 +28093,34 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 184: case 185: + case 186: return isContextSensitiveFunctionLikeDeclaration(node); - case 176: + case 177: return ts.forEach(node.properties, isContextSensitive); - case 175: + case 176: return ts.forEach(node.elements, isContextSensitive); - case 193: + case 194: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 192: + case 193: return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 257: + case 260: return isContextSensitive(node.initializer); + case 150: case 149: - case 148: return isContextSensitiveFunctionLikeDeclaration(node); - case 183: + case 184: return isContextSensitive(node.expression); + case 253: + return ts.forEach(node.properties, isContextSensitive); + case 252: + return node.initializer && isContextSensitive(node.initializer); + case 255: + return node.expression && isContextSensitive(node.expression); } return false; } @@ -26455,7 +28131,7 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !p.type; })) { return true; } - if (node.kind === 185) { + if (node.kind === 186) { return false; } var parameter = ts.firstOrUndefined(node.parameters); @@ -26473,9 +28149,12 @@ var ts; result.properties = resolved.properties; result.callSignatures = emptyArray; result.constructSignatures = emptyArray; - type = result; + return result; } } + else if (type.flags & 131072) { + return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); + } return type; } function isTypeIdenticalTo(source, target) { @@ -26494,7 +28173,7 @@ var ts; return isTypeRelatedTo(source, target, assignableRelation); } function isTypeInstanceOf(source, target) { - return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + return getTargetType(source) === getTargetType(target) || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); } function isTypeComparableTo(source, target) { return isTypeRelatedTo(source, target, comparableRelation); @@ -26642,13 +28321,15 @@ var ts; return true; } var id = source.id + "," + target.id; - if (enumRelation[id] !== undefined) { - return enumRelation[id]; + var relation = enumRelation.get(id); + if (relation !== undefined) { + return relation; } if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & 256) || !(target.symbol.flags & 256) || (source.flags & 65536) !== (target.flags & 65536)) { - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } var targetEnumType = getTypeOfSymbol(target.symbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(source.symbol)); _i < _a.length; _i++) { @@ -26659,11 +28340,13 @@ var ts; if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, property.name, typeToString(target, undefined, 128)); } - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } } } - return enumRelation[id] = true; + enumRelation.set(id, true); + return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { if (target.flags & 8192) @@ -26684,6 +28367,8 @@ var ts; return true; if (source.flags & 4096 && (!strictNullChecks || target.flags & 4096)) return true; + if (source.flags & 32768 && target.flags & 16777216) + return true; if (relation === assignableRelation || relation === comparableRelation) { if (source.flags & 1) return true; @@ -26715,12 +28400,12 @@ var ts; } if (source.flags & 32768 && target.flags & 32768) { var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { return related === 1; } } - if (source.flags & 507904 || target.flags & 507904) { + if (source.flags & 1032192 || target.flags & 1032192) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -26859,14 +28544,6 @@ var ts; } } } - else { - var constraint = getConstraintOfTypeParameter(target); - if (constraint && constraint.flags & 262144) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - return result; - } - } - } } else if (target.flags & 262144) { if (source.flags & 262144) { @@ -26874,12 +28551,10 @@ var ts; return result; } } - if (target.type.flags & 540672) { - var constraint = getConstraintOfTypeVariable(target.type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } + var constraint = getConstraintOfType(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; } } } @@ -26889,8 +28564,9 @@ var ts; return result; } } - if (target.constraint) { - if (result = isRelatedTo(source, target.constraint, reportErrors)) { + var constraint = getBaseConstraintOfType(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -26907,20 +28583,23 @@ var ts; } else { var constraint = getConstraintOfTypeParameter(source); - if (!constraint || constraint.flags & 1) { - constraint = emptyObjectType; - } - constraint = getTypeWithThisArgument(constraint, source); - var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; + if (constraint || !(target.flags & 16777216)) { + if (!constraint || constraint.flags & 1) { + constraint = emptyObjectType; + } + constraint = getTypeWithThisArgument(constraint, source); + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } } else if (source.flags & 524288) { - if (source.constraint) { - if (result = isRelatedTo(source.constraint, target, reportErrors)) { + var constraint = getBaseConstraintOfType(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -26972,42 +28651,55 @@ var ts; } return 0; } - function isKnownProperty(type, name) { + function isKnownProperty(type, name, isComparingJsxAttributes) { if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) || - resolved.stringIndexInfo || - (resolved.numberIndexInfo && isNumericLiteralName(name)) || - getPropertyOfType(type, name)) { + if ((relation === assignableRelation || relation === comparableRelation) && + (type === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(resolved)))) { + return true; + } + else if (resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name))) { + return true; + } + else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) { return true; } } else if (type.flags & 196608) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (isKnownProperty(t, name)) { + if (isKnownProperty(t, name, isComparingJsxAttributes)) { return true; } } } return false; } - function isEmptyObjectType(t) { + function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && t.constructSignatures.length === 0 && !t.stringIndexInfo && !t.numberIndexInfo; } + function isEmptyObjectType(type) { + return type.flags & 32768 && isEmptyResolvedType(resolveStructuredTypeMembers(type)); + } function hasExcessProperties(source, target, reportErrors) { if (maybeTypeOfKind(target, 32768) && !(getObjectFlags(target) & 512)) { + var isComparingJsxAttributes = !!(source.flags & 33554432); for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; - if (!isKnownProperty(target, prop.name)) { + if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) { if (reportErrors) { ts.Debug.assert(!!errorNode); - 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)); + if (ts.isJsxAttributes(errorNode)) { + reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); + } + else { + 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; } @@ -27033,20 +28725,42 @@ var ts; if (target.flags & 65536 && containsType(targetTypes, source)) { return -1; } - var len = targetTypes.length; - for (var i = 0; i < len; i++) { - var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); + for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { + var type = targetTypes_1[_i]; + var related = isRelatedTo(source, type, false); if (related) { return related; } } + if (reportErrors) { + var discriminantType = findMatchingDiscriminantType(source, target); + isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], true); + } return 0; } + function findMatchingDiscriminantType(source, target) { + var sourceProperties = getPropertiesOfObjectType(source); + if (sourceProperties) { + for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { + var sourceProperty = sourceProperties_1[_i]; + if (isDiscriminantProperty(target, sourceProperty.name)) { + var sourceType = getTypeOfSymbol(sourceProperty); + for (var _a = 0, _b = target.types; _a < _b.length; _a++) { + var type = _b[_a]; + var targetType = getTypeOfPropertyOfType(type, sourceProperty.name); + if (targetType && isRelatedTo(sourceType, targetType)) { + return type; + } + } + } + } + } + } function typeRelatedToEachType(source, target, reportErrors) { var result = -1; var targetTypes = target.types; - for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { - var targetType = targetTypes_1[_i]; + for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { + var targetType = targetTypes_2[_i]; var related = isRelatedTo(source, targetType, reportErrors); if (!related) { return 0; @@ -27104,10 +28818,10 @@ var ts; return 0; } var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2) { - relation[id] = 3; + relation.set(id, 3); } else { return related === 1 ? -1 : 0; @@ -27115,7 +28829,7 @@ var ts; } if (depth > 0) { for (var i = 0; i < depth; i++) { - if (maybeStack[i][id]) { + if (maybeStack[i].get(id)) { return 1; } } @@ -27133,7 +28847,7 @@ var ts; sourceStack[depth] = source; targetStack[depth] = target; maybeStack[depth] = ts.createMap(); - maybeStack[depth][id] = 1; + maybeStack[depth].set(id, 1); depth++; var saveExpandingFlags = expandingFlags; if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) @@ -27167,37 +28881,40 @@ var ts; if (result) { var maybeCache = maybeStack[depth]; var destinationCache = (result === -1 || depth === 0) ? relation : maybeStack[depth - 1]; - ts.copyProperties(maybeCache, destinationCache); + ts.copyEntries(maybeCache, destinationCache); } else { - relation[id] = reportErrors ? 3 : 2; + relation.set(id, reportErrors ? 3 : 2); } return result; } function mappedTypeRelatedTo(source, target, reportErrors) { if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { - var result_2; - if (relation === identityRelation) { - var readonlyMatches = !source.declaration.readonlyToken === !target.declaration.readonlyToken; - var optionalMatches = !source.declaration.questionToken === !target.declaration.questionToken; - if (readonlyMatches && optionalMatches) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getErasedTemplateTypeFromMappedType(source), getErasedTemplateTypeFromMappedType(target), reportErrors); - } - } - } - else { - if (relation === comparableRelation || !source.declaration.questionToken || target.declaration.questionToken) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors); - } + var sourceReadonly = !!source.declaration.readonlyToken; + var sourceOptional = !!source.declaration.questionToken; + var targetReadonly = !!target.declaration.readonlyToken; + var targetOptional = !!target.declaration.questionToken; + var modifiersRelated = relation === identityRelation ? + sourceReadonly === targetReadonly && sourceOptional === targetOptional : + relation === comparableRelation || !sourceOptional || targetOptional; + if (modifiersRelated) { + var result_2; + if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { + var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); + return result_2 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } + else if (target.declaration.questionToken && isEmptyObjectType(source)) { + return -1; + } } - else if (relation !== identityRelation && isEmptyObjectType(resolveStructuredTypeMembers(target))) { - return -1; + else if (relation !== identityRelation) { + var resolved = resolveStructuredTypeMembers(target); + if (isEmptyResolvedType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1) { + return -1; + } } return 0; } @@ -27213,17 +28930,23 @@ var ts; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { - if (!(targetProp.flags & 536870912) || requireOptionalProperties) { + if (!(targetProp.flags & 67108864) || requireOptionalProperties) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); } return 0; } } - else if (!(targetProp.flags & 134217728)) { + else if (!(targetProp.flags & 16777216)) { var sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 || targetPropFlags & 8) { + if (getCheckFlags(sourceProp) & 128) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); + } + return 0; + } if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { if (sourcePropFlags & 8 && targetPropFlags & 8) { @@ -27237,12 +28960,9 @@ var ts; } } else if (targetPropFlags & 16) { - var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(getParentOfSymbol(sourceProp)) : undefined; - var targetClass = getDeclaredTypeOfSymbol(getParentOfSymbol(targetProp)); - if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { + if (!isValidOverrideOf(sourceProp, targetProp)) { 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)); + reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } return 0; } @@ -27261,7 +28981,7 @@ var ts; return 0; } result &= related; - if (relation !== comparableRelation && sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { + if (relation !== comparableRelation && sourceProp.flags & 67108864 && !(targetProp.flags & 67108864)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -27282,8 +29002,8 @@ var ts; return 0; } var result = -1; - for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { - var sourceProp = sourceProperties_1[_i]; + for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) { + var sourceProp = sourceProperties_2[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return 0; @@ -27348,7 +29068,7 @@ var ts; return 0; } var result = -1; - for (var i = 0, len = sourceSignatures.length; i < len; i++) { + for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], false, false, false, isRelatedTo); if (!related) { return 0; @@ -27444,6 +29164,37 @@ var ts; return false; } } + function forEachProperty(prop, callback) { + if (getCheckFlags(prop) & 2) { + for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var p = getPropertyOfType(t, prop.name); + var result = p && forEachProperty(p, callback); + if (result) { + return result; + } + } + return undefined; + } + return callback(prop); + } + function getDeclaringClass(prop) { + return prop.parent && prop.parent.flags & 32 ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + } + function isPropertyInClassDerivedFrom(prop, baseClass) { + return forEachProperty(prop, function (sp) { + var sourceClass = getDeclaringClass(sp); + return sourceClass ? hasBaseType(sourceClass, baseClass) : false; + }); + } + function isValidOverrideOf(sourceProp, targetProp) { + return !forEachProperty(targetProp, function (tp) { return getDeclarationModifierFlagsFromSymbol(tp) & 16 ? + !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); + } + function isClassDerivedFromDeclaringClasses(checkClass, prop) { + return forEachProperty(prop, function (p) { return getDeclarationModifierFlagsFromSymbol(p) & 16 ? + !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; + } function isAbstractConstructorType(type) { if (getObjectFlags(type) & 16) { var symbol = type.symbol; @@ -27489,7 +29240,7 @@ var ts; } } else { - if ((sourceProp.flags & 536870912) !== (targetProp.flags & 536870912)) { + if ((sourceProp.flags & 67108864) !== (targetProp.flags & 67108864)) { return 0; } } @@ -27519,7 +29270,7 @@ var ts; if (!(isMatchingSignature(source, target, partialMatch))) { return 0; } - if ((source.typeParameters ? source.typeParameters.length : 0) !== (target.typeParameters ? target.typeParameters.length : 0)) { + if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { return 0; } source = getErasedSignature(source); @@ -27557,8 +29308,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var t = types_7[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -27566,8 +29317,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -27658,8 +29409,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getFalsyFlags(t); } return result; @@ -27688,7 +29439,7 @@ var ts; types.push(undefinedType); if (flags & 4096) types.push(nullType); - return getUnionType(types, true); + return getUnionType(types); } function removeDefinitelyFalsyTypes(type) { return getFalsyFlags(type) & 7392 ? @@ -27703,8 +29454,8 @@ var ts; getSignaturesOfType(type, 0).length === 0 && getSignaturesOfType(type, 1).length === 0; } - function createTransientSymbol(source, type) { - var symbol = createSymbol(source.flags | 67108864, source.name); + function createSymbolWithType(source, type) { + var symbol = createSymbol(source.flags, source.name); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -27720,7 +29471,7 @@ var ts; var property = _a[_i]; var original = getTypeOfSymbol(property); var updated = f(original); - members[property.name] = updated === original ? property : createTransientSymbol(property, updated); + members.set(property.name, updated === original ? property : createSymbolWithType(property, updated)); } ; return members; @@ -27806,25 +29557,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 148: case 147: - case 146: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 144: + case 145: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 174: + case 175: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 225: + case 227: + case 150: case 149: - case 148: - case 151: case 152: - case 184: + case 153: case 185: + case 186: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -27909,7 +29660,7 @@ var ts; var typeInferencesArray = [typeInferences]; var templateType = getTemplateTypeFromMappedType(target); var readonlyMask = target.declaration.readonlyToken ? false : true; - var optionalMask = target.declaration.questionToken ? 0 : 536870912; + var optionalMask = target.declaration.questionToken ? 0 : 67108864; var members = createSymbolTable(properties); for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var prop = properties_4[_i]; @@ -27917,11 +29668,11 @@ var ts; if (!inferredPropType) { return undefined; } - var inferredProp = createSymbol(4 | 67108864 | prop.flags & optionalMask, prop.name); + var inferredProp = createSymbol(4 | prop.flags & optionalMask, prop.name); + inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 4 : 0; inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; - inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop); - members[prop.name] = inferredProp; + members.set(prop.name, inferredProp); } if (indexInfo) { var inferredIndexType = inferTargetType(indexInfo.type); @@ -28031,8 +29782,8 @@ var ts; var targetTypes = target.types; var typeVariableCount = 0; var typeVariable = void 0; - for (var _d = 0, targetTypes_2 = targetTypes; _d < targetTypes_2.length; _d++) { - var t = targetTypes_2[_d]; + for (var _d = 0, targetTypes_3 = targetTypes; _d < targetTypes_3.length; _d++) { + var t = targetTypes_3[_d]; if (t.flags & 540672 && ts.contains(typeVariables, t)) { typeVariable = t; typeVariableCount++; @@ -28064,10 +29815,10 @@ var ts; return; } var key = source.id + "," + target.id; - if (visited[key]) { + if (visited.get(key)) { return; } - visited[key] = true; + visited.set(key, true); if (depth === 0) { sourceStack = []; targetStack = []; @@ -28159,8 +29910,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -28201,7 +29952,13 @@ var ts; inferenceSucceeded = !!unionOrSuperType; } else { - inferredType = emptyObjectType; + var defaultType = getDefaultFromTypeParameter(context.signature.typeParameters[index]); + if (defaultType) { + inferredType = instantiateType(defaultType, combineTypeMappers(createBackreferenceMapper(context.signature.typeParameters, index), getInferenceMapper(context))); + } + else { + inferredType = emptyObjectType; + } inferenceSucceeded = true; } context.inferredTypes[index] = inferredType; @@ -28236,10 +29993,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 160: + case 161: return true; case 70: - case 141: + case 142: node = node.parent; continue; default: @@ -28256,7 +30013,7 @@ var ts; if (node.kind === 98) { return "0"; } - if (node.kind === 177) { + if (node.kind === 178) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -28267,7 +30024,7 @@ var ts; case 70: case 98: return node; - case 177: + case 178: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -28276,19 +30033,19 @@ var ts; switch (source.kind) { case 70: return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 223 || target.kind === 174) && + (target.kind === 225 || target.kind === 175) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98: return target.kind === 98; - case 177: - return target.kind === 177 && + case 178: + return target.kind === 178 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 177) { + while (source.kind === 178) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -28297,7 +30054,7 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 177 && + return target.kind === 178 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -28305,7 +30062,7 @@ var ts; if (expr.kind === 70) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 177) { + if (expr.kind === 178) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -28314,9 +30071,9 @@ var ts; function isDiscriminantProperty(type, name) { if (type && type.flags & 65536) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && prop.flags & 268435456) { + if (prop && getCheckFlags(prop) & 2) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.hasNonUniformType && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.checkFlags & 16 && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -28335,7 +30092,7 @@ var ts; } } } - if (callExpression.expression.kind === 177 && + if (callExpression.expression.kind === 178 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -28374,8 +30131,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -28383,7 +30140,7 @@ var ts; function isFunctionObjectType(type) { var resolved = resolveStructuredTypeMembers(type); return !!(resolved.callSignatures.length || resolved.constructSignatures.length || - resolved.members["bind"] && isTypeSubtypeOf(type, globalFunctionType)); + resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type) { var flags = type.flags; @@ -28426,6 +30183,9 @@ var ts; if (flags & 512) { return strictNullChecks ? 1981320 : 4193160; } + if (flags & 16777216) { + return strictNullChecks ? 6166480 : 8378320; + } if (flags & 16384) { var constraint = getConstraintOfTypeParameter(type); return getTypeFacts(constraint || emptyObjectType); @@ -28461,10 +30221,16 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 || node.parent.kind === 257 ? + var isDestructuringDefaultAssignment = node.parent.kind === 176 && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 260 && isDestructuringAssignmentTarget(node.parent.parent); + return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } + function isDestructuringAssignmentTarget(parent) { + return parent.parent.kind === 193 && parent.parent.left === parent || + parent.parent.kind === 215 && parent.parent.initializer === parent; + } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); } @@ -28480,21 +30246,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 212: + case 214: return stringType; - case 213: + case 215: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 192: + case 193: return getAssignedTypeOfBinaryExpression(parent); - case 186: + case 187: return undefinedType; - case 175: + case 176: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 196: + case 197: return getAssignedTypeOfSpreadExpression(parent); - case 257: + case 260: return getAssignedTypeOfPropertyAssignment(parent); - case 258: + case 261: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -28502,7 +30268,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 172 ? + var type = pattern.kind === 173 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -28517,35 +30283,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 212) { + if (node.parent.parent.kind === 214) { return stringType; } - if (node.parent.parent.kind === 213) { + if (node.parent.parent.kind === 215) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 223 ? + return node.kind === 225 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 223 || node.kind === 174 ? + return node.kind === 225 || node.kind === 175 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 223 && node.initializer && + return node.kind === 225 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 174 && node.parent.kind === 192 && + node.kind !== 175 && node.parent.kind === 193 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 183: + case 184: return getReferenceCandidate(node.expression); - case 192: + case 193: switch (node.operatorToken.kind) { case 57: return getReferenceCandidate(node.left); @@ -28557,13 +30323,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 183 || - parent.kind === 192 && parent.operatorToken.kind === 57 && parent.left === node || - parent.kind === 192 && parent.operatorToken.kind === 25 && parent.right === node ? + return parent.kind === 184 || + parent.kind === 193 && parent.operatorToken.kind === 57 && parent.left === node || + parent.kind === 193 && parent.operatorToken.kind === 25 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 253) { + if (clause.kind === 256) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -28665,8 +30431,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; if (!(t.flags & 8192)) { if (!(getObjectFlags(t) & 256)) { return false; @@ -28684,11 +30450,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 177 && (parent.name.text === "length" || - parent.parent.kind === 179 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 178 && + var isLengthPushOrUnshift = parent.kind === 178 && (parent.name.text === "length" || + parent.parent.kind === 180 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 179 && parent.expression === root && - parent.parent.kind === 192 && + parent.parent.kind === 193 && parent.parent.operatorToken.kind === 57 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -28717,7 +30483,7 @@ var ts; } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 17810431)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -28727,7 +30493,7 @@ var ts; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; var resultType = getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 201 && getTypeWithFacts(resultType, 524288).flags & 8192) { + if (reference.parent.kind === 202 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } return resultType; @@ -28741,7 +30507,16 @@ var ts; } } var type = void 0; - if (flow.flags & 16) { + if (flow.flags & 4096) { + flow.locked = true; + type = getTypeAtFlowNode(flow.antecedent); + flow.locked = false; + } + else if (flow.flags & 2048) { + flow = flow.antecedent; + continue; + } + else if (flow.flags & 16) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; @@ -28772,7 +30547,7 @@ var ts; } else if (flow.flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 177) { + if (container && container !== flowContainer && reference.kind !== 178) { flow = container.flowNode; continue; } @@ -28815,7 +30590,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 179 ? + var expr = node.kind === 180 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -28823,7 +30598,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 179) { + if (node.kind === 180) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -28875,6 +30650,9 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; + if (antecedent.flags & 2048 && antecedent.lock.locked) { + continue; + } var flowType = getTypeAtFlowNode(antecedent); var type = getTypeFromFlowType(flowType); if (type === declaredType && declaredType === initialType) { @@ -28898,8 +30676,9 @@ var ts; if (!key) { key = getFlowCacheKey(reference); } - if (cache[key]) { - return cache[key]; + var cached = cache.get(key); + if (cached) { + return cached; } for (var i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { @@ -28921,8 +30700,9 @@ var ts; firstAntecedentType = flowType; } var type = getTypeFromFlowType(flowType); - if (cache[key]) { - return cache[key]; + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; } if (!ts.contains(antecedentTypes, type)) { antecedentTypes.push(type); @@ -28938,10 +30718,11 @@ var ts; if (isIncomplete(firstAntecedentType)) { return createFlowType(result, true); } - return cache[key] = result; + cache.set(key, result); + return result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 177 && + return expr.kind === 178 && declaredType.flags & 65536 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -28975,10 +30756,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 187 && right_1.kind === 9) { + if (left_1.kind === 188 && right_1.kind === 9) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 187 && left_1.kind === 9) { + if (right_1.kind === 188 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -29024,7 +30805,7 @@ var ts; assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); } - if (type.flags & 33281) { + if (type.flags & 16810497) { return type; } if (assumeTrue) { @@ -29049,14 +30830,14 @@ var ts; assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 65536)) { - var targetType = typeofTypesByName[literal.text]; + var targetType = typeofTypesByName.get(literal.text); if (targetType && isTypeSubtypeOf(targetType, type)) { return targetType; } } var facts = assumeTrue ? - typeofEQFacts[literal.text] || 64 : - typeofNEFacts[literal.text] || 8192; + typeofEQFacts.get(literal.text) || 64 : + typeofNEFacts.get(literal.text) || 8192; return getTypeWithFacts(type, facts); } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { @@ -29156,7 +30937,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 178 || invokedExpression.kind === 177) { + if (invokedExpression.kind === 179 || invokedExpression.kind === 178) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -29173,15 +30954,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 177: + case 178: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 179: + case 180: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 183: + case 184: return narrowType(type, expr.expression, assumeTrue); - case 192: + case 193: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 190: + case 191: if (expr.operator === 50) { return narrowType(type, expr.operand, !assumeTrue); } @@ -29208,9 +30989,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 231 || - node.kind === 261 || - node.kind === 147) { + node.kind === 233 || + node.kind === 264 || + node.kind === 148) { return node; } } @@ -29241,7 +31022,7 @@ var ts; if (node.kind === 70) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 144) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 145) { symbol.isAssigned = true; } } @@ -29261,7 +31042,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 185) { + if (container.kind === 186) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256)) { @@ -29279,7 +31060,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; - if (declaration_1.kind === 226 + if (declaration_1.kind === 228 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -29291,11 +31072,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 197) { + else if (declaration_1.kind === 198) { var container = ts.getThisContainer(node, false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 147 && ts.hasModifier(container, 32)) { + if (container.kind === 148 && ts.hasModifier(container, 32)) { getNodeLinks(declaration_1).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -29307,6 +31088,7 @@ var ts; } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkCollisionWithCapturedNewTargetVariable(node, node); checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; @@ -29324,17 +31106,17 @@ var ts; if (!(localOrExportSymbol.flags & 3) || assignmentKind === 1 || !declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 144; + var isParameter = ts.getRootDeclaration(declaration).kind === 145; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - while (flowContainer !== declarationContainer && (flowContainer.kind === 184 || - flowContainer.kind === 185 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 185 || + flowContainer.kind === 186 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0 || isInTypeQuery(node)) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); if (type === autoType || type === autoArrayType) { @@ -29365,7 +31147,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 256) { + symbol.valueDeclaration.parent.kind === 259) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -29383,8 +31165,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 211 && - ts.getAncestor(symbol.valueDeclaration, 224).parent === container && + if (container.kind === 213 && + ts.getAncestor(symbol.valueDeclaration, 226).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -29396,14 +31178,14 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 183) { + while (current.parent.kind === 184) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 190 || current.parent.kind === 191)) { + else if ((current.parent.kind === 191 || current.parent.kind === 192)) { var expr = current.parent; isAssigned = expr.operator === 42 || expr.operator === 43; } @@ -29422,7 +31204,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 147 || container.kind === 150) { + if (container.kind === 148 || container.kind === 151) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -29466,32 +31248,32 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 150) { + if (container.kind === 151) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } - if (container.kind === 185) { + if (container.kind === 186) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 230: + case 232: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 229: + case 231: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 150: + case 151: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 148: case 147: - case 146: if (ts.getModifierFlags(container) & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 142: + case 143: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -29500,7 +31282,7 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 184 && + if (container.kind === 185 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent @@ -29535,27 +31317,27 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 274) { + if (jsdocType && jsdocType.kind === 278) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 277) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 281) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 144) { + if (n.kind === 145) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 179 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 180 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 185) { + while (container && container.kind === 186) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -29564,16 +31346,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 142) { + while (current && current !== container && current.kind !== 143) { current = current.parent; } - if (current && current.kind === 142) { + if (current && current.kind === 143) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 176)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 177)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -29581,7 +31363,7 @@ var ts; } return unknownType; } - if (!isCallExpression && container.kind === 150) { + if (!isCallExpression && container.kind === 151) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if ((ts.getModifierFlags(container) & 32) || isCallExpression) { @@ -29591,7 +31373,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 149 && ts.getModifierFlags(container) & 256) { + if (container.kind === 150 && ts.getModifierFlags(container) & 256) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -29602,7 +31384,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 176) { + if (container.parent.kind === 177) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -29620,7 +31402,7 @@ var ts; } return unknownType; } - if (container.kind === 150 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 151 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -29632,24 +31414,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 150; + return container.kind === 151; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 176) { + if (ts.isClassLike(container.parent) || container.parent.kind === 177) { if (ts.getModifierFlags(container) & 32) { - return container.kind === 149 || - container.kind === 148 || - container.kind === 151 || - container.kind === 152; + return container.kind === 150 || + container.kind === 149 || + container.kind === 152 || + container.kind === 153; } else { - return container.kind === 149 || - container.kind === 148 || - container.kind === 151 || + return container.kind === 150 || + container.kind === 149 || container.kind === 152 || + container.kind === 153 || + container.kind === 148 || container.kind === 147 || - container.kind === 146 || - container.kind === 150; + container.kind === 151; } } } @@ -29657,7 +31439,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 185) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 186) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -29672,23 +31454,23 @@ var ts; var func = parameter.parent; if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { var iife = ts.getImmediatelyInvokedFunctionExpression(func); - if (iife) { + if (iife && iife.arguments) { var indexOfParameter = ts.indexOf(func.parameters, parameter); - if (iife.arguments && indexOfParameter < iife.arguments.length) { - if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return createArrayType(getUnionType(restTypes)); + if (parameter.dotDotDotToken) { + var restTypes = []; + for (var i = indexOfParameter; i < iife.arguments.length; i++) { + restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); } - var links = getNodeLinks(iife); - var cached = links.resolvedSignature; - links.resolvedSignature = anySignature; - var type = getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])); - links.resolvedSignature = cached; - return type; + return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; } + var links = getNodeLinks(iife); + var cached = links.resolvedSignature; + links.resolvedSignature = anySignature; + var type = indexOfParameter < iife.arguments.length ? + getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + parameter.initializer ? undefined : undefinedWideningType; + links.resolvedSignature = cached; + return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -29713,7 +31495,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 144) { + if (declaration.kind === 145) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -29724,11 +31506,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_21 = declaration.propertyName || declaration.name; + var name = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_21)) { - var text = ts.getTextOfPropertyName(name_21); + !ts.isBindingPattern(name)) { + var text = ts.getTextOfPropertyName(name); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -29765,7 +31547,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 144 && node.parent.initializer === node) { + if (node.parent.kind === 145 && node.parent.initializer === node) { return true; } node = node.parent; @@ -29774,8 +31556,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 150 || - functionDecl.kind === 151 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 152))) { + functionDecl.kind === 151 || + functionDecl.kind === 152 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 153))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -29794,7 +31576,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 181) { + if (template.parent.kind === 182) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -29831,8 +31613,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -29899,19 +31681,16 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxAttribute(attribute) { - var kind = attribute.kind; - var jsxElement = attribute.parent; - var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 250) { - if (!attrsType || isTypeAny(attrsType)) { + var attributesType = getContextualType(attribute.parent); + if (ts.isJsxAttribute(attribute)) { + if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfType(attrsType, attribute.name.text); + return getTypeOfPropertyOfType(attributesType, attribute.name.text); } - else if (attribute.kind === 251) { - return attrsType; + else { + return attributesType; } - ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); } function getApparentTypeOfContextualType(node) { var type = getContextualType(node); @@ -29926,42 +31705,45 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 223: - case 144: + case 225: + case 145: + case 148: case 147: - case 146: - case 174: - return getContextualTypeForInitializerExpression(node); - case 185: - case 216: - return getContextualTypeForReturnExpression(node); - case 195: - return getContextualTypeForYieldOperand(parent); - case 179: - case 180: - return getContextualTypeForArgument(parent, node); - case 182: - case 200: - return getTypeFromTypeNode(parent.type); - case 192: - return getContextualTypeForBinaryOperand(node); - case 257: - case 258: - return getContextualTypeForObjectLiteralElement(parent); case 175: - return getContextualTypeForElementExpression(node); - case 193: - return getContextualTypeForConditionalOperand(node); - case 202: - ts.Debug.assert(parent.parent.kind === 194); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 186: + case 218: + return getContextualTypeForReturnExpression(node); + case 196: + return getContextualTypeForYieldOperand(parent); + case 180: + case 181: + return getContextualTypeForArgument(parent, node); case 183: + case 201: + return getTypeFromTypeNode(parent.type); + case 193: + return getContextualTypeForBinaryOperand(node); + case 260: + case 261: + return getContextualTypeForObjectLiteralElement(parent); + case 176: + return getContextualTypeForElementExpression(node); + case 194: + return getContextualTypeForConditionalOperand(node); + case 204: + ts.Debug.assert(parent.parent.kind === 195); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 184: + return getContextualType(parent); + case 255: return getContextualType(parent); case 252: - return getContextualType(parent); - case 250: - case 251: + case 254: return getContextualTypeForJsxAttribute(parent); + case 250: + case 249: + return getAttributesTypeFromJsxOpeningLikeElement(parent); } return undefined; } @@ -29989,7 +31771,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 184 || node.kind === 185; + return node.kind === 185 || node.kind === 186; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -30002,7 +31784,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -30012,8 +31794,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -30043,8 +31825,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 174 && !!node.initializer) || - (node.kind === 192 && node.operatorToken.kind === 57); + return (node.kind === 175 && !!node.initializer) || + (node.kind === 193 && node.operatorToken.kind === 57); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -30053,7 +31835,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 196) { + if (inDestructuringPattern && e.kind === 197) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -30065,7 +31847,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 196; + hasSpreadElement = hasSpreadElement || e.kind === 197; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -30076,7 +31858,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 173 || pattern.kind === 175)) { + if (pattern && (pattern.kind === 174 || pattern.kind === 176)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -30084,7 +31866,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 198) { + if (patternElement.kind !== 199) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -30101,7 +31883,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 142 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 143 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 340); @@ -30147,7 +31929,7 @@ var ts; var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 172 || contextualType.pattern.kind === 176); + (contextualType.pattern.kind === 173 || contextualType.pattern.kind === 177); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -30156,27 +31938,27 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 257 || - memberDecl.kind === 258 || + if (memberDecl.kind === 260 || + memberDecl.kind === 261 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 257) { + if (memberDecl.kind === 260) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 149) { + else if (memberDecl.kind === 150) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 258); + ts.Debug.assert(memberDecl.kind === 261); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; - var prop = createSymbol(4 | 67108864 | member.flags, member.name); + var prop = createSymbol(4 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 257 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 258 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 260 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 261 && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 536870912; + prop.flags |= 67108864; } if (ts.hasDynamicName(memberDecl)) { patternWithComputedProperties = true; @@ -30185,7 +31967,7 @@ var ts; else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & 512)) { var impliedProp = getPropertyOfType(contextualType, member.name); if (impliedProp) { - prop.flags |= impliedProp.flags & 536870912; + prop.flags |= impliedProp.flags & 67108864; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -30200,12 +31982,12 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 259) { - if (languageVersion < 5) { + else if (memberDecl.kind === 262) { + if (languageVersion < 2) { checkExternalEmitHelpers(memberDecl, 2); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), true); + spread = getSpreadType(spread, createObjectLiteralType()); propertiesArray = []; propertiesTable = ts.createMap(); hasComputedStringProperty = false; @@ -30217,12 +31999,12 @@ var ts; error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } - spread = getSpreadType(spread, type, false); + spread = getSpreadType(spread, type); offset = i + 1; continue; } else { - ts.Debug.assert(memberDecl.kind === 151 || memberDecl.kind === 152); + ts.Debug.assert(memberDecl.kind === 152 || memberDecl.kind === 153); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -30234,25 +32016,25 @@ var ts; } } else { - propertiesTable[member.name] = member; + propertiesTable.set(member.name, member); } propertiesArray.push(member); } if (contextualTypeHasPattern) { for (var _i = 0, _a = getPropertiesOfType(contextualType); _i < _a.length; _i++) { var prop = _a[_i]; - if (!propertiesTable[prop.name]) { - if (!(prop.flags & 536870912)) { + if (!propertiesTable.get(prop.name)) { + if (!(prop.flags & 67108864)) { 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; + propertiesTable.set(prop.name, prop); propertiesArray.push(prop); } } } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), true); + spread = getSpreadType(spread, createObjectLiteralType()); } if (spread.flags & 32768) { spread.flags |= propagatedFlags; @@ -30281,7 +32063,7 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (1 | 4096 | 2048) || + return !!(type.flags & (1 | 4096 | 2048 | 16777216) || type.flags & 32768 && !isGenericMappedType(type) || type.flags & 196608 && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } @@ -30300,13 +32082,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 252: + case 255: checkJsxExpression(child); break; - case 246: + case 248: checkJsxElement(child); break; - case 247: + case 249: checkJsxSelfClosingElement(child); break; } @@ -30317,71 +32099,88 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 177 || tagName.kind === 98) { + if (tagName.kind === 178 || tagName.kind === 98) { 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 attributeType = getTypeOfPropertyOfType(elementAttributesType, ts.getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0); - if (attributeType) { - correspondingPropType = attributeType; + function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, contextualMapper) { + var attributes = openingLikeElement.attributes; + var attributesTable = ts.createMap(); + var spread = emptyObjectType; + var attributesArray = []; + for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { + var attributeDecl = _a[_i]; + var member = attributeDecl.symbol; + if (ts.isJsxAttribute(attributeDecl)) { + var exprType = attributeDecl.initializer ? + checkExpression(attributeDecl.initializer, contextualMapper) : + trueType; + var attributeSymbol = createSymbol(4 | 134217728 | member.flags, member.name); + attributeSymbol.declarations = member.declarations; + attributeSymbol.parent = member.parent; + if (member.valueDeclaration) { + attributeSymbol.valueDeclaration = member.valueDeclaration; } - else { - if (!correspondingPropType) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; - } + attributeSymbol.type = exprType; + attributeSymbol.target = member; + attributesTable.set(attributeSymbol.name, attributeSymbol); + attributesArray.push(attributeSymbol); + } + else { + ts.Debug.assert(attributeDecl.kind === 254); + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); } + var exprType = checkExpression(attributeDecl.expression); + if (!(exprType.flags & (32768 | 1))) { + error(attributeDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + return anyType; + } + if (isTypeAny(exprType)) { + return anyType; + } + spread = getSpreadType(spread, exprType); } } - var exprType; - if (node.initializer) { - exprType = checkExpression(node.initializer); + if (spread !== emptyObjectType) { + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); + } + attributesArray = getPropertiesOfType(spread); } - else { - exprType = booleanType; + attributesTable = ts.createMap(); + if (attributesArray) { + ts.forEach(attributesArray, function (attr) { + if (!filter || filter(attr)) { + attributesTable.set(attr.name, attr); + } + }); } - if (correspondingPropType) { - checkTypeAssignableTo(exprType, correspondingPropType, node); + return createJsxAttributesType(attributes.symbol, attributesTable); + function createJsxAttributesType(symbol, attributesTable) { + var result = createAnonymousType(symbol, attributesTable, emptyArray, emptyArray, undefined, undefined); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; + result.flags |= 33554432 | 4194304 | freshObjectLiteralFlag; + result.objectFlags |= 128; + return result; } - nameTable[node.name.text] = true; - return exprType; } - function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { - if (compilerOptions.jsx === 2) { - checkExternalEmitHelpers(node, 2); - } - var type = checkExpression(node.expression); - var props = getPropertiesOfType(type); - 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) { - 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 checkJsxAttributes(node, contextualMapper) { + return createJsxAttributesTypeFromAttributesProperty(node.parent, undefined, contextualMapper); } function getJsxType(name) { - if (jsxTypes[name] === undefined) { - return jsxTypes[name] = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType; + var jsxType = jsxTypes.get(name); + if (jsxType === undefined) { + jsxTypes.set(name, jsxType = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType); } - return jsxTypes[name]; + return jsxType; } function getIntrinsicTagSymbol(node) { var links = getNodeLinks(node); @@ -30446,23 +32245,84 @@ var ts; return undefined; } } - function getResolvedJsxType(node, elemType, elemClassType) { - if (!elemType) { - elemType = checkExpression(node.tagName); + function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + if (jsxElementType) { + var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, undefined); + if (callSignature !== unknownSignature) { + var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); + var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + paramType = intersectTypes(intrinsicAttributes, paramType); + } + return paramType; + } + } + } } - if (elemType.flags & 65536) { - var types = elemType.types; - return getUnionType(ts.map(types, function (type) { - return getResolvedJsxType(node, type, elemClassType); + return undefined; + } + function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + if (jsxElementType) { + var candidatesOutArray = []; + getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); + var result = void 0; + var allMatchingAttributesType = void 0; + for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { + var candidate = candidatesOutArray_1[_i]; + var callReturnType = getReturnTypeOfSignature(candidate); + var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + var shouldBeCandidate = true; + for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { + var attribute = _b[_a]; + if (ts.isJsxAttribute(attribute) && + isUnhyphenatedJsxName(attribute.name.text) && + !getPropertyOfType(paramType, attribute.name.text)) { + shouldBeCandidate = false; + break; + } + } + if (shouldBeCandidate) { + result = intersectTypes(result, paramType); + } + allMatchingAttributesType = intersectTypes(allMatchingAttributesType, paramType); + } + } + if (!result) { + result = allMatchingAttributesType; + } + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + result = intersectTypes(intrinsicAttributes, result); + } + return result; + } + } + return undefined; + } + function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { + if (!elementType) { + elementType = checkExpression(openingLikeElement.tagName); + } + if (elementType.flags & 65536) { + var types = elementType.types; + return getUnionType(types.map(function (type) { + return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); }), true); } - if (elemType.flags & 2) { + if (elementType.flags & 2) { return anyType; } - else if (elemType.flags & 32) { + else if (elementType.flags & 32) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); if (intrinsicElementsType !== unknownType) { - var stringLiteralTypeName = elemType.text; + var stringLiteralTypeName = elementType.text; var intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName); if (intrinsicProp) { return getTypeOfSymbol(intrinsicProp); @@ -30471,28 +32331,19 @@ var ts; if (indexSignatureType) { return indexSignatureType; } - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); + error(openingLikeElement, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); } return anyType; } - var elemInstanceType = getJsxElementInstanceType(node, elemType); - if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { - if (jsxElementType) { - var callSignatures = elemType && getSignaturesOfType(elemType, 0); - var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); - if (intrinsicAttributes !== unknownType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } - } + var elemInstanceType = getJsxElementInstanceType(openingLikeElement, elementType); + var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? + tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : + defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); + if (statelessAttributesType) { + return statelessAttributesType; } - if (elemClassType) { - checkTypeRelatedTo(elemInstanceType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + if (elementClassType) { + checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } if (isTypeAny(elemInstanceType)) { return elemInstanceType; @@ -30513,7 +32364,7 @@ var ts; return attributesType; } else if (attributesType.flags & 65536) { - error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); + error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); return anyType; } else { @@ -30538,30 +32389,49 @@ var ts; } } } - function getJsxElementAttributesType(node) { + function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) { + ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName)); var links = getNodeLinks(node); - if (!links.resolvedJsxType) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1) { - return links.resolvedJsxType = getTypeOfSymbol(symbol); - } - else if (links.jsxFlags & 2) { - return links.resolvedJsxType = getIndexInfoOfSymbol(symbol, 0).type; - } - else { - return links.resolvedJsxType = unknownType; - } + if (!links.resolvedJsxElementAttributesType) { + var symbol = getIntrinsicTagSymbol(node); + if (links.jsxFlags & 1) { + return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol); + } + else if (links.jsxFlags & 2) { + return links.resolvedJsxElementAttributesType = getIndexInfoOfSymbol(symbol, 0).type; } else { - var elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxType = getResolvedJsxType(node, undefined, elemClassType); + return links.resolvedJsxElementAttributesType = unknownType; } } - return links.resolvedJsxType; + return links.resolvedJsxElementAttributesType; + } + function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { + var links = getNodeLinks(node); + if (!links.resolvedJsxElementAttributesType) { + var elemClassType = getJsxGlobalElementClassType(); + return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); + } + return links.resolvedJsxElementAttributesType; + } + function getAllAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + return getCustomJsxElementAttributesType(node, true); + } + } + function getAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + return getCustomJsxElementAttributesType(node, false); + } } function getJsxAttributePropertySymbol(attrib) { - var attributesType = getJsxElementAttributesType(attrib.parent); + var attributesType = getAttributesTypeFromJsxOpeningLikeElement(attrib.parent.parent); var prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } @@ -30597,61 +32467,77 @@ var ts; markAliasSymbolAsReferenced(reactSym); } } - var targetAttributesType = getJsxElementAttributesType(node); - var nameTable = ts.createMap(); - var sawSpreadedAny = false; - for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 250) { - checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); - } - else { - ts.Debug.assert(node.attributes[i].kind === 251); - var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); - if (isTypeAny(spreadType)) { - sawSpreadedAny = true; - } - } + checkJsxAttributesAssignableToTagNameAttributes(node); + } + function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement) { + var targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? + getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : + getCustomJsxElementAttributesType(openingLikeElement, false); + var sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement, function (attribute) { + return isUnhyphenatedJsxName(attribute.name) || !!(getPropertyOfType(targetAttributesType, attribute.name)); + }); + if (targetAttributesType === emptyObjectType && (isTypeAny(sourceAttributesType) || sourceAttributesType.properties.length > 0)) { + error(openingLikeElement, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); } - if (targetAttributesType && !sawSpreadedAny) { - var targetProperties = getPropertiesOfType(targetAttributesType); - for (var i = 0; i < targetProperties.length; i++) { - if (!(targetProperties[i].flags & 536870912) && - !nameTable[targetProperties[i].name]) { - error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); - } - } + else { + checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.attributes.properties.length > 0 ? openingLikeElement.attributes : openingLikeElement); } } - function checkJsxExpression(node) { + function checkJsxExpression(node, contextualMapper) { if (node.expression) { - return checkExpression(node.expression); + var type = checkExpression(node.expression, contextualMapper); + if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { + error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); + } + return type; } else { return unknownType; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 147; + return s.valueDeclaration ? s.valueDeclaration.kind : 148; } function getDeclarationModifierFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 ? 4 | 32 : 0; + if (s.valueDeclaration) { + var flags = ts.getCombinedModifierFlags(s.valueDeclaration); + return s.parent && s.parent.flags & 32 ? flags : flags & ~28; + } + if (getCheckFlags(s) & 2) { + var checkFlags = s.checkFlags; + var accessModifier = checkFlags & 128 ? 8 : + checkFlags & 32 ? 4 : + 16; + var staticModifier = checkFlags & 256 ? 32 : 0; + return accessModifier | staticModifier; + } + if (s.flags & 16777216) { + return 4 | 32; + } + return 0; } function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; } - function checkClassPropertyAccess(node, left, type, prop) { + function checkPropertyAccessibility(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); - var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 || node.kind === 223 ? + var errorNode = node.kind === 178 || node.kind === 225 ? node.name : node.right; + if (getCheckFlags(prop) & 128) { + error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); + return false; + } if (left.kind === 96) { - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 149) { - error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - return false; + if (languageVersion < 2) { + var propKind = getDeclarationKindFromSymbol(prop); + if (propKind !== 150 && propKind !== 149) { + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } } if (flags & 128) { - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } } @@ -30661,7 +32547,7 @@ var ts; if (flags & 8) { var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } return true; @@ -30671,10 +32557,10 @@ var ts; } var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); - return hasBaseType(enclosingClass, declaringClass) ? enclosingClass : undefined; + return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; }); if (!enclosingClass) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); return false; } if (flags & 32) { @@ -30690,16 +32576,17 @@ var ts; return true; } function checkNonNullExpression(node) { - var type = checkExpression(node); - if (strictNullChecks) { - var kind = getFalsyFlags(type) & 6144; - if (kind) { - error(node, kind & 2048 ? kind & 4096 ? - ts.Diagnostics.Object_is_possibly_null_or_undefined : - ts.Diagnostics.Object_is_possibly_undefined : - ts.Diagnostics.Object_is_possibly_null); - } - return getNonNullableType(type); + return checkNonNullType(checkExpression(node), node); + } + function checkNonNullType(type, errorNode) { + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 6144; + if (kind) { + error(errorNode, kind & 2048 ? kind & 4096 ? + ts.Diagnostics.Object_is_possibly_null_or_undefined : + ts.Diagnostics.Object_is_possibly_undefined : + ts.Diagnostics.Object_is_possibly_null); + var t = getNonNullableType(type); + return t.flags & (6144 | 8192) ? unknownType : t; } return type; } @@ -30728,7 +32615,7 @@ var ts; noUnusedIdentifiers && (prop.flags & 106500) && prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8)) { - if (prop.flags & 16777216) { + if (getCheckFlags(prop) & 1) { getSymbolLinks(prop).target.isReferenced = true; } else { @@ -30736,6 +32623,15 @@ var ts; } } } + function isInPropertyInitializer(node) { + while (node) { + if (node.parent && node.parent.kind === 148 && node.parent.initializer === node) { + return true; + } + node = node.parent; + } + return false; + } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { var type = checkNonNullExpression(left); if (isTypeAny(type) || type === silentNeverType) { @@ -30747,16 +32643,23 @@ var ts; } var prop = getPropertyOfType(apparentType, right.text); if (!prop) { + var stringIndexType = getIndexTypeOfType(apparentType, 0); + if (stringIndexType) { + return stringIndexType; + } if (right.text && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, type.flags & 16384 && type.isThisType ? apparentType : type); } return unknownType; } + if (prop.valueDeclaration && + isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + } markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; - if (prop.parent && prop.parent.flags & 32) { - checkClassPropertyAccess(node, left, apparentType, prop); - } + checkPropertyAccessibility(node, left, apparentType, prop); var propType = getTypeOfSymbol(prop); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { @@ -30765,7 +32668,7 @@ var ts; return unknownType; } } - if (node.kind !== 177 || assignmentKind === 1 || + if (node.kind !== 178 || assignmentKind === 1 || !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 65536)) { return propType; @@ -30774,21 +32677,21 @@ var ts; return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 177 + var left = node.kind === 178 ? 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); + if (prop) { + return checkPropertyAccessibility(node, left, type, prop); } } return true; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 224) { + if (initializer.kind === 226) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -30810,7 +32713,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 212 && + if (node.kind === 214 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -30828,7 +32731,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 180 && node.parent.expression === node) { + if (node.parent.kind === 181 && 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); @@ -30848,7 +32751,7 @@ var ts; error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } - return getIndexedAccessType(objectType, indexType, node); + return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === unknownType) { @@ -30881,10 +32784,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 181) { + if (node.kind === 182) { checkExpression(node.template); } - else if (node.kind !== 145) { + else if (node.kind !== 146) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -30906,19 +32809,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_8 = signature.declaration && signature.declaration.parent; + var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_8 === lastParent) { + if (lastParent && parent === lastParent) { index++; } else { - lastParent = parent_8; + lastParent = parent; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_8; + lastParent = parent; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -30935,7 +32838,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 196) { + if (arg && arg.kind === 197) { return i; } } @@ -30948,11 +32851,14 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 181) { + if (ts.isJsxOpeningLikeElement(node)) { + return true; + } + if (node.kind === 182) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 194) { + if (tagExpression.template.kind === 195) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -30964,7 +32870,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 145) { + else if (node.kind === 146) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); @@ -30972,7 +32878,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 180); + ts.Debug.assert(callExpression.kind === 181); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -30980,8 +32886,10 @@ var ts; typeArguments = callExpression.typeArguments; spreadArgIndex = getSpreadArgumentIndex(args); } + var numTypeParameters = ts.length(signature.typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters); var hasRightNumberOfTypeArgs = !typeArguments || - (signature.typeParameters && typeArguments.length === signature.typeParameters.length); + (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters); if (!hasRightNumberOfTypeArgs) { return false; } @@ -31031,7 +32939,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 !== 198) { + if (arg === undefined || arg.kind !== 199) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -31056,7 +32964,7 @@ var ts; var typeParameters = signature.typeParameters; var typeArgumentsAreAssignable = true; var mapper; - for (var i = 0; i < typeParameters.length; i++) { + for (var i = 0; i < typeArgumentNodes.length; i++) { if (typeArgumentsAreAssignable) { var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { @@ -31076,9 +32984,29 @@ var ts; } return typeArgumentsAreAssignable; } + function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation) { + var callIsIncomplete = node.attributes.end === node.end; + if (callIsIncomplete) { + return true; + } + var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + var paramType = getTypeAtPosition(signature, 0); + var attributesType = checkExpressionWithContextualType(node.attributes, paramType, undefined); + var argProperties = getPropertiesOfType(attributesType); + for (var _i = 0, argProperties_1 = argProperties; _i < argProperties_1.length; _i++) { + var arg = argProperties_1[_i]; + if (!getPropertyOfType(paramType, arg.name) && isUnhyphenatedJsxName(arg.name)) { + return false; + } + } + return checkTypeRelatedTo(attributesType, paramType, relation, undefined, headMessage); + } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { + if (ts.isJsxOpeningLikeElement(node)) { + return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); + } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 180) { + if (thisType && thisType !== voidType && node.kind !== 181) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -31091,7 +33019,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 !== 198) { + if (arg === undefined || arg.kind !== 199) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -31106,51 +33034,54 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 179) { + if (node.kind === 180) { var callee = node.expression; - if (callee.kind === 177) { + if (callee.kind === 178) { return callee.expression; } - else if (callee.kind === 178) { + else if (callee.kind === 179) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 181) { + if (node.kind === 182) { var template = node.template; args = [undefined]; - if (template.kind === 194) { + if (template.kind === 195) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 145) { + else if (node.kind === 146) { return undefined; } + else if (ts.isJsxOpeningLikeElement(node)) { + args = node.attributes.properties.length > 0 ? [node.attributes] : emptyArray; + } else { args = node.arguments || emptyArray; } return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 145) { + if (node.kind === 146) { switch (node.parent.kind) { - case 226: - case 197: + case 228: + case 198: return 1; - case 147: + case 148: return 2; - case 149: - case 151: + case 150: case 152: + case 153: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 144: + case 145: return 3; } } @@ -31159,48 +33090,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 228) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 144) { + if (node.kind === 145) { node = node.parent; - if (node.kind === 150) { + if (node.kind === 151) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 147 || - node.kind === 149 || - node.kind === 151 || - node.kind === 152) { + if (node.kind === 148 || + node.kind === 150 || + node.kind === 152 || + node.kind === 153) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 228) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 144) { + if (node.kind === 145) { node = node.parent; - if (node.kind === 150) { + if (node.kind === 151) { return anyType; } } - if (node.kind === 147 || - node.kind === 149 || - node.kind === 151 || - node.kind === 152) { + if (node.kind === 148 || + node.kind === 150 || + node.kind === 152 || + node.kind === 153) { var element = node; switch (element.name.kind) { case 70: case 8: case 9: return getLiteralTypeForText(32, element.name.text); - case 142: + case 143: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512)) { return nameType; @@ -31217,20 +33148,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 226) { + if (node.kind === 228) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 144) { + if (node.kind === 145) { return numberType; } - if (node.kind === 147) { + if (node.kind === 148) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 149 || - node.kind === 151 || - node.kind === 152) { + if (node.kind === 150 || + node.kind === 152 || + node.kind === 153) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -31251,26 +33182,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex) { - if (node.kind === 145) { + if (node.kind === 146) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 181) { + else if (argIndex === 0 && node.kind === 182) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 145 || - (argIndex === 0 && node.kind === 181)) { + if (node.kind === 146 || + (argIndex === 0 && node.kind === 182)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 145) { + if (node.kind === 146) { return node.expression; } - else if (argIndex === 0 && node.kind === 181) { + else if (argIndex === 0 && node.kind === 182) { return node.template; } else { @@ -31278,10 +33209,11 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 181; - var isDecorator = node.kind === 145; + var isTaggedTemplate = node.kind === 182; + var isDecorator = node.kind === 146; + var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; - if (!isTaggedTemplate && !isDecorator) { + if (!isTaggedTemplate && !isDecorator && !isJsxOpeningOrSelfClosingElement) { typeArguments = node.typeArguments; if (node.expression.kind !== 96) { ts.forEach(typeArguments, checkSourceElement); @@ -31309,7 +33241,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 179 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 180 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -31323,6 +33255,9 @@ var ts; return result; } if (candidateForArgumentError) { + if (isJsxOpeningOrSelfClosingElement) { + return candidateForArgumentError; + } checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); } else if (candidateForTypeArgumentError) { @@ -31338,7 +33273,7 @@ var ts; if (headMessage) { diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); } - reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); + reportNoCommonSupertypeError(inferenceCandidates, node.tagName || node.expression || node.tag, diagnosticChainHead); } } else { @@ -31381,13 +33316,13 @@ var ts; if (candidate.typeParameters) { var typeArgumentTypes = void 0; if (typeArguments) { - typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNode); + typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); } else { inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); - typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; typeArgumentTypes = inferenceContext.inferredTypes; + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; } if (!typeArgumentsAreValid) { break; @@ -31578,16 +33513,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 226: - case 197: + case 228: + case 198: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 144: + case 145: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 147: + case 148: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 149: - case 151: + case 150: case 152: + case 153: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -31612,16 +33547,42 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray, headMessage); } + function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray) { + ts.Debug.assert(!(elementType.flags & 65536)); + var callSignature = resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray); + return callSignature; + } + function resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray) { + if (elementType.flags & 65536) { + var types = elementType.types; + var result = void 0; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; + result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); + } + return result; + } + var callSignatures = elementType && getSignaturesOfType(elementType, 0); + if (callSignatures && callSignatures.length > 0) { + var callSignature = void 0; + callSignature = resolveCall(openingLikeElement, callSignatures, candidatesOutArray); + return callSignature; + } + return undefined; + } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 179: - return resolveCallExpression(node, candidatesOutArray); case 180: - return resolveNewExpression(node, candidatesOutArray); + return resolveCallExpression(node, candidatesOutArray); case 181: + return resolveNewExpression(node, candidatesOutArray); + case 182: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 145: + case 146: return resolveDecorator(node, candidatesOutArray); + case 250: + case 249: + return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); } @@ -31652,12 +33613,12 @@ var ts; if (node.expression.kind === 96) { return voidType; } - if (node.kind === 180) { + if (node.kind === 181) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 150 && - declaration.kind !== 154 && - declaration.kind !== 159 && + declaration.kind !== 151 && + declaration.kind !== 155 && + declaration.kind !== 160 && !ts.isJSDocConstructSignature(declaration)) { var funcSymbol = node.expression.kind === 70 ? getResolvedSymbol(node.expression) : @@ -31688,9 +33649,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 225 + ? 227 : resolvedRequire.flags & 3 - ? 223 + ? 225 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -31716,6 +33677,23 @@ var ts; function checkNonNullAssertion(node) { return getNonNullableType(checkExpression(node.expression)); } + function checkMetaProperty(node) { + checkGrammarMetaProperty(node); + ts.Debug.assert(node.keywordToken === 93 && node.name.text === "target", "Unrecognized meta-property."); + var container = ts.getNewTargetContainer(node); + if (!container) { + error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); + return unknownType; + } + else if (container.kind === 151) { + var symbol = getSymbolOfNode(container.parent); + return getTypeOfSymbol(symbol); + } + else { + var symbol = getSymbolOfNode(container); + return getTypeOfSymbol(symbol); + } + } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks) { @@ -31745,7 +33723,7 @@ var ts; var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { if (!parameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + signature.thisParameter = createSymbolWithType(context.thisParameter, undefined); } assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } @@ -31783,8 +33761,8 @@ var ts; if (!links.type) { links.type = instantiateType(contextualType, mapper); if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 172 || - parameter.valueDeclaration.name.kind === 173)) { + (parameter.valueDeclaration.name.kind === 173 || + parameter.valueDeclaration.name.kind === 174)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -31814,6 +33792,9 @@ var ts; error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } + else if (!getGlobalPromiseConstructorSymbol()) { + error(func, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } return promiseType; } function getReturnTypeFromBody(func, contextualMapper) { @@ -31823,7 +33804,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 204) { + if (func.body.kind !== 206) { 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); @@ -31902,7 +33883,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 218 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 220 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -31931,7 +33912,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 184 || func.kind === 185)) { + func.kind === 185 || func.kind === 186)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -31948,7 +33929,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 204 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 206 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -31975,9 +33956,9 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 184) { + if (!hasGrammarError && node.kind === 185) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -32011,14 +33992,15 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 149) { + if (produceDiagnostics && node.kind !== 150) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -32028,7 +34010,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 204) { + if (node.body.kind === 206) { checkSourceElement(node.body); } else { @@ -32054,19 +34036,19 @@ var ts; return true; } function isReadonlySymbol(symbol) { - return symbol.isReadonly || - symbol.flags & 4 && (getDeclarationModifierFlagsFromSymbol(symbol) & 64) !== 0 || - symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 || + return !!(getCheckFlags(symbol) & 4 || + symbol.flags & 4 && getDeclarationModifierFlagsFromSymbol(symbol) & 64 || + symbol.flags & 3 && getDeclarationNodeFlagsFromSymbol(symbol) & 2 || symbol.flags & 98304 && !(symbol.flags & 65536) || - (symbol.flags & 8) !== 0; + symbol.flags & 8); } function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 177 || expr.kind === 178) && + (expr.kind === 178 || expr.kind === 179) && expr.expression.kind === 98) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 150)) + if (!(func && func.kind === 151)) return true; return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); } @@ -32075,13 +34057,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 177 || expr.kind === 178) { + if (expr.kind === 178 || expr.kind === 179) { var node = ts.skipParentheses(expr.expression); if (node.kind === 70) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 237; + return declaration && declaration.kind === 239; } } } @@ -32089,7 +34071,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage) { var node = ts.skipParentheses(expr); - if (node.kind !== 70 && node.kind !== 177 && node.kind !== 178) { + if (node.kind !== 70 && node.kind !== 178 && node.kind !== 179) { error(expr, invalidReferenceMessage); return false; } @@ -32097,11 +34079,21 @@ var ts; } function checkDeleteExpression(node) { checkExpression(node.expression); + var expr = ts.skipParentheses(node.expression); + if (expr.kind !== 178 && expr.kind !== 179) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); + return booleanType; + } + var links = getNodeLinks(expr); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol && isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } return booleanType; } function checkTypeOfExpression(node) { checkExpression(node.expression); - return stringType; + return typeofType; } function checkVoidExpression(node) { checkExpression(node.expression); @@ -32131,6 +34123,7 @@ var ts; case 36: case 37: case 51: + checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 512)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } @@ -32142,7 +34135,7 @@ var ts; booleanType; case 42: case 43: - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); } @@ -32155,7 +34148,7 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); } @@ -32167,8 +34160,8 @@ var ts; } if (type.flags & 196608) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -32182,8 +34175,8 @@ var ts; } if (type.flags & 65536) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var t = types_19[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -32192,8 +34185,8 @@ var ts; } if (type.flags & 131072) { var types = type.types; - for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { - var t = types_17[_a]; + for (var _a = 0, types_20 = types; _a < types_20.length; _a++) { + var t = types_20[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -32214,7 +34207,10 @@ var ts; if (isTypeOfKind(leftType, 8190)) { 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))) { + if (!(isTypeAny(rightType) || + getSignaturesOfType(rightType, 0).length || + getSignaturesOfType(rightType, 1).length || + 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; @@ -32223,6 +34219,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 340 | 512))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } @@ -32240,22 +34238,22 @@ var ts; return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 257 || property.kind === 258) { - var name_22 = property.name; - if (name_22.kind === 142) { - checkComputedPropertyName(name_22); + if (property.kind === 260 || property.kind === 261) { + var name = property.name; + if (name.kind === 143) { + checkComputedPropertyName(name); } - if (isComputedNonLiteralName(name_22)) { + if (isComputedNonLiteralName(name)) { return undefined; } - var text = ts.getTextOfPropertyName(name_22); + var text = ts.getTextOfPropertyName(name); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 258) { + if (property.kind === 261) { return checkDestructuringAssignment(property, type); } else { @@ -32263,10 +34261,10 @@ var ts; } } else { - error(name_22, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_22)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 259) { + else if (property.kind === 262) { if (languageVersion < 5) { checkExternalEmitHelpers(property, 4); } @@ -32294,8 +34292,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 198) { - if (element.kind !== 196) { + if (element.kind !== 199) { + if (element.kind !== 197) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -32321,7 +34319,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 192 && restExpression.operatorToken.kind === 57) { + if (restExpression.kind === 193 && restExpression.operatorToken.kind === 57) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -32334,7 +34332,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 258) { + if (exprOrAssignment.kind === 261) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -32348,21 +34346,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 192 && target.operatorToken.kind === 57) { + if (target.kind === 193 && target.operatorToken.kind === 57) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 176) { + if (target.kind === 177) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 175) { + if (target.kind === 176) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 259 ? + var error = target.parent.kind === 262 ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -32376,35 +34374,35 @@ var ts; case 70: case 9: case 11: - case 181: - case 194: + case 182: + case 195: case 12: case 8: case 100: case 85: case 94: - case 137: - case 184: - case 197: + case 138: case 185: - case 175: + case 198: + case 186: case 176: - case 187: - case 201: - case 247: - case 246: + case 177: + case 188: + case 202: + case 249: + case 248: return true; - case 193: + case 194: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 192: + case 193: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 190: case 191: + case 192: switch (node.operator) { case 50: case 36: @@ -32413,9 +34411,9 @@ var ts; return true; } return false; - case 188: - case 182: - case 200: + case 189: + case 183: + case 201: default: return false; } @@ -32435,7 +34433,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 57 && (left.kind === 176 || left.kind === 175)) { + if (operator === 57 && (left.kind === 177 || left.kind === 176)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -32466,12 +34464,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (leftType.flags & 6144) - leftType = rightType; - if (rightType.flags & 6144) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); var suggestedOperator = void 0; if ((leftType.flags & 136) && (rightType.flags & 136) && @@ -32491,12 +34485,10 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (leftType.flags & 6144) - leftType = rightType; - if (rightType.flags & 6144) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + if (!isTypeOfKind(leftType, 1 | 262178) && !isTypeOfKind(rightType, 1 | 262178)) { + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); + } var resultType = void 0; if (isTypeOfKind(leftType, 340) && isTypeOfKind(rightType, 340)) { resultType = numberType; @@ -32525,8 +34517,8 @@ var ts; case 29: case 30: if (checkForDisallowedESSymbolOperand(operator)) { - leftType = getBaseTypeOfLiteralType(leftType); - rightType = getBaseTypeOfLiteralType(rightType); + leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); + rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } @@ -32695,7 +34687,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 182 || node.kind === 200; + return node.kind === 183 || node.kind === 201; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -32706,11 +34698,11 @@ var ts; function isLiteralContextualType(contextualType) { if (contextualType) { if (contextualType.flags & 540672) { - var apparentType = getApparentTypeOfTypeVariable(contextualType); - if (apparentType.flags & (2 | 4 | 8 | 16)) { + var constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; + if (constraint.flags & (2 | 4 | 8 | 16)) { return true; } - contextualType = apparentType; + contextualType = constraint; } return maybeTypeOfKind(contextualType, (480 | 262144)); } @@ -32721,14 +34713,14 @@ var ts; return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -32750,7 +34742,7 @@ var ts; return type; } function getTypeOfExpression(node) { - if (node.kind === 179 && node.expression.kind !== 96) { + if (node.kind === 180 && node.expression.kind !== 96) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -32761,7 +34753,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 141) { + if (node.kind === 142) { type = checkQualifiedName(node); } else { @@ -32769,9 +34761,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 177 && node.parent.expression === node) || - (node.parent.kind === 178 && node.parent.expression === node) || - ((node.kind === 70 || node.kind === 141) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 178 && node.parent.expression === node) || + (node.parent.kind === 179 && node.parent.expression === node) || + ((node.kind === 70 || node.kind === 142) && 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); } @@ -32793,66 +34785,70 @@ var ts; case 100: case 85: return checkLiteralExpression(node); - case 194: + case 195: return checkTemplateExpression(node); case 12: return stringType; case 11: return globalRegExpType; - case 175: - return checkArrayLiteral(node, contextualMapper); case 176: - return checkObjectLiteral(node, contextualMapper); + return checkArrayLiteral(node, contextualMapper); case 177: - return checkPropertyAccessExpression(node); + return checkObjectLiteral(node, contextualMapper); case 178: - return checkIndexedAccess(node); + return checkPropertyAccessExpression(node); case 179: + return checkIndexedAccess(node); case 180: - return checkCallExpression(node); case 181: - return checkTaggedTemplateExpression(node); - case 183: - return checkExpression(node.expression, contextualMapper); - case 197: - return checkClassExpression(node); - case 184: - case 185: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 187: - return checkTypeOfExpression(node); + return checkCallExpression(node); case 182: - case 200: - return checkAssertion(node); - case 201: - return checkNonNullAssertion(node); - case 186: - return checkDeleteExpression(node); - case 188: - return checkVoidExpression(node); - case 189: - return checkAwaitExpression(node); - case 190: - return checkPrefixUnaryExpression(node); - case 191: - return checkPostfixUnaryExpression(node); - case 192: - return checkBinaryExpression(node, contextualMapper); - case 193: - return checkConditionalExpression(node, contextualMapper); - case 196: - return checkSpreadExpression(node, contextualMapper); + return checkTaggedTemplateExpression(node); + case 184: + return checkExpression(node.expression, contextualMapper); case 198: + return checkClassExpression(node); + case 185: + case 186: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 188: + return checkTypeOfExpression(node); + case 183: + case 201: + return checkAssertion(node); + case 202: + return checkNonNullAssertion(node); + case 203: + return checkMetaProperty(node); + case 187: + return checkDeleteExpression(node); + case 189: + return checkVoidExpression(node); + case 190: + return checkAwaitExpression(node); + case 191: + return checkPrefixUnaryExpression(node); + case 192: + return checkPostfixUnaryExpression(node); + case 193: + return checkBinaryExpression(node, contextualMapper); + case 194: + return checkConditionalExpression(node, contextualMapper); + case 197: + return checkSpreadExpression(node, contextualMapper); + case 199: return undefinedWideningType; - case 195: + case 196: return checkYieldExpression(node); - case 252: - return checkJsxExpression(node); - case 246: - return checkJsxElement(node); - case 247: - return checkJsxSelfClosingElement(node); + case 255: + return checkJsxExpression(node, contextualMapper); case 248: + return checkJsxElement(node); + case 249: + return checkJsxSelfClosingElement(node); + case 253: + return checkJsxAttributes(node, contextualMapper); + case 250: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -32862,7 +34858,16 @@ var ts; grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); } checkSourceElement(node.constraint); - getConstraintOfTypeParameter(getDeclaredTypeOfTypeParameter(getSymbolOfNode(node))); + checkSourceElement(node.default); + var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); + if (!hasNonCircularBaseConstraint(typeParameter)) { + error(node.constraint, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); + } + var constraintType = getConstraintOfTypeParameter(typeParameter); + var defaultType = getDefaultFromTypeParameter(typeParameter); + if (constraintType && defaultType) { + checkTypeAssignableTo(defaultType, getTypeWithThisArgument(constraintType, defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } @@ -32873,7 +34878,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92) { func = ts.getContainingFunction(node); - if (!(func.kind === 150 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 151 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -32884,7 +34889,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 150 || func.kind === 154 || func.kind === 159) { + if (func.kind === 151 || func.kind === 155 || func.kind === 160) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -32896,9 +34901,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 149 || - node.kind === 225 || - node.kind === 184; + return node.kind === 150 || + node.kind === 227 || + node.kind === 185; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -32939,9 +34944,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_23 = _a[_i].name; - if (ts.isBindingPattern(name_23) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_23, parameterName, typePredicate.parameterName)) { + var name = _a[_i].name; + if (ts.isBindingPattern(name) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -32954,16 +34959,16 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 186: + case 154: + case 227: case 185: - case 153: - case 225: - case 184: - case 158: + case 159: + case 150: case 149: - case 148: - var parent_9 = node.parent; - if (node === parent_9.type) { - return parent_9; + var parent = node.parent; + if (node === parent.type) { + return parent; } } } @@ -32973,27 +34978,27 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_24 = element.name; - if (name_24.kind === 70 && - name_24.text === predicateVariableName) { + var name = element.name; + if (name.kind === 70 && + name.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_24.kind === 173 || - name_24.kind === 172) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_24, predicateVariableNode, predicateVariableName)) { + else if (name.kind === 174 || + name.kind === 173) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } } } } function checkSignatureDeclaration(node) { - if (node.kind === 155) { + if (node.kind === 156) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 || node.kind === 225 || node.kind === 159 || - node.kind === 153 || node.kind === 150 || - node.kind === 154) { + else if (node.kind === 159 || node.kind === 227 || node.kind === 160 || + node.kind === 154 || node.kind === 151 || + node.kind === 155) { checkGrammarFunctionLikeDeclaration(node); } if (ts.isAsyncFunctionLike(node) && languageVersion < 4) { @@ -33011,10 +35016,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 154: + case 155: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 153: + case 154: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -33041,11 +35046,18 @@ var ts; } } function checkClassForDuplicateDeclarations(node) { + var Declaration; + (function (Declaration) { + Declaration[Declaration["Getter"] = 1] = "Getter"; + Declaration[Declaration["Setter"] = 2] = "Setter"; + Declaration[Declaration["Method"] = 4] = "Method"; + Declaration[Declaration["Property"] = 3] = "Property"; + })(Declaration || (Declaration = {})); var instanceNames = ts.createMap(); var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150) { + if (member.kind === 151) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -33054,36 +35066,65 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114; }); + var isStatic = ts.getModifierFlags(member) & 32; var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 151: + case 152: addName(names, member.name, memberName, 1); break; - case 152: + case 153: addName(names, member.name, memberName, 2); break; - case 147: + case 148: addName(names, member.name, memberName, 3); break; + case 150: + addName(names, member.name, memberName, 4); + break; } } } } function addName(names, location, name, meaning) { - var prev = names[name]; + var prev = names.get(name); if (prev) { - if (prev & meaning) { + if (prev & 4) { + if (meaning !== 4) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + } + else if (prev & meaning) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { - names[name] = prev | meaning; + names.set(name, prev | meaning); } } else { - names[name] = meaning; + names.set(name, meaning); + } + } + } + function checkClassForStaticPropertyNameConflicts(node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + var memberNameNode = member.name; + var isStatic = ts.getModifierFlags(member) & 32; + if (isStatic && memberNameNode) { + var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode); + switch (memberName) { + case "name": + case "length": + case "caller": + case "arguments": + case "prototype": + var message = ts.Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1; + var className = getNameOfSymbol(getSymbolOfNode(node)); + error(memberNameNode, message, memberName, className); + break; + } } } } @@ -33091,7 +35132,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 146) { + if (member.kind == 147) { var memberName = void 0; switch (member.name.kind) { case 9: @@ -33102,18 +35143,18 @@ var ts; default: continue; } - if (names[memberName]) { + if (names.get(memberName)) { error(member.symbol.valueDeclaration.name, ts.Diagnostics.Duplicate_identifier_0, memberName); error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName); } else { - names[memberName] = true; + names.set(memberName, true); } } } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 227) { + if (node.kind === 229) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -33128,7 +35169,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 134: + case 135: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -33195,12 +35236,12 @@ var ts; if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 && n.kind !== 225) { + else if (n.kind !== 185 && n.kind !== 227) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 147 && + return n.kind === 148 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -33220,7 +35261,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -33243,18 +35284,18 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 151) { + if (node.kind === 152) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 151 ? 152 : 151; + var otherKind = node.kind === 152 ? 153 : 152; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { @@ -33268,11 +35309,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 151) { + if (node.kind === 152) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 176) { + if (node.parent.kind !== 177) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -33295,6 +35336,7 @@ var ts; checkDecorators(node); } function checkTypeArgumentConstraints(typeParameters, typeArgumentNodes) { + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); var typeArguments; var mapper; var result = true; @@ -33302,7 +35344,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -33353,25 +35395,42 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessIndexType(type, accessNode) { + if (!(type.flags & 524288)) { + return type; + } + var objectType = type.objectType; + var indexType = type.indexType; + if (isTypeAssignableTo(indexType, getIndexType(objectType))) { + return type; + } + if (maybeTypeOfKind(objectType, 540672) && isTypeOfKind(indexType, 340)) { + var constraint = getBaseConstraintOfType(objectType); + if (constraint && getIndexInfoOfType(constraint, 1)) { + return type; + } + } + error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); + return type; + } function checkIndexedAccessType(node) { - getTypeFromIndexedAccessTypeNode(node); + checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node) { checkSourceElement(node.typeParameter); checkSourceElement(node.type); var type = getTypeFromMappedTypeNode(node); var constraintType = getConstraintTypeFromMappedType(type); - var keyType = constraintType.flags & 540672 ? getApparentTypeOfTypeVariable(constraintType) : constraintType; - checkTypeAssignableTo(keyType, stringType, node.typeParameter.constraint); + checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node) { return (ts.getModifierFlags(node) & 8) && ts.isInAmbientContext(node); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 227 && - n.parent.kind !== 226 && - n.parent.kind !== 197 && + if (n.parent.kind !== 229 && + n.parent.kind !== 228 && + n.parent.kind !== 198 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -33448,7 +35507,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 149 || node.kind === 148) && + var reportError = (node.kind === 150 || node.kind === 149) && (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); if (reportError) { var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -33477,15 +35536,15 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var current = declarations_4[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var current = declarations_5[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 227 || node.parent.kind === 161 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 229 || node.parent.kind === 162 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 225 || node.kind === 149 || node.kind === 148 || node.kind === 150) { + if (node.kind === 227 || node.kind === 150 || node.kind === 149 || node.kind === 151) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -33596,16 +35655,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 227: + case 229: return 2097152; - case 230: + case 232: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 226: - case 229: + case 228: + case 231: return 2097152 | 1048576; - case 234: + case 236: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -33617,7 +35676,8 @@ var ts; } function checkNonThenableType(type, location, message) { type = getWidenedType(type); - if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + var apparentType = getApparentType(type); + if ((apparentType.flags & (1 | 8192)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -33722,7 +35782,12 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455, true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; if (promiseConstructorType === unknownType) { - error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + if (promiseConstructorName.kind === 70 && promiseConstructorName.text === "Promise" && getTargetType(returnType) === tryGetGlobalPromiseType()) { + error(node.type, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } + else { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + } return unknownType; } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); @@ -33752,22 +35817,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 226: + case 228: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 144: + case 145: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 147: + case 148: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 149: - case 151: + case 150: case 152: + case 153: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -33801,13 +35866,13 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8); - if (node.kind === 144) { + if (node.kind === 145) { checkExternalEmitHelpers(firstDecorator, 32); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 226: + case 228: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -33816,19 +35881,19 @@ var ts; } } break; - case 149: - case 151: + case 150: case 152: + case 153: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markTypeNodeAsReferenced(node.type); break; - case 147: + case 148: markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); break; - case 144: + case 145: markTypeNodeAsReferenced(node.type); break; } @@ -33840,6 +35905,7 @@ var ts; checkFunctionOrMethodDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -33848,7 +35914,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 142) { + if (node.name && node.name.kind === 143) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -33890,43 +35956,43 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 261: - case 230: + case 264: + case 232: checkUnusedModuleMembers(node); break; - case 226: - case 197: + case 228: + case 198: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 227: + case 229: checkUnusedTypeParameters(node); break; - case 204: - case 232: - case 211: - case 212: + case 206: + case 234: case 213: + case 214: + case 215: checkUnusedLocalsAndParameters(node); break; - case 150: - case 184: - case 225: - case 185: - case 149: case 151: + case 185: + case 227: + case 186: + case 150: case 152: + case 153: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 148: - case 153: + case 149: case 154: case 155: - case 158: + case 156: case 159: + case 160: checkUnusedTypeParameters(node); break; } @@ -33935,11 +36001,10 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 227 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_2 = function (key) { - var local = node.locals[key]; + if (node.parent.kind !== 229 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + node.locals.forEach(function (local) { if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 145) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -33952,10 +36017,7 @@ var ts; ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d.name || d, local.name); }); } } - }; - for (var key in node.locals) { - _loop_2(key); - } + }); } } function isRemovedPropertyFromObjectSpread(node) { @@ -33968,9 +36030,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 223 && - (declaration.parent.parent.kind === 212 || - declaration.parent.parent.kind === 213)) { + if (declaration.kind === 225 && + (declaration.parent.parent.kind === 214 || + declaration.parent.parent.kind === 215)) { return; } } @@ -33989,12 +36051,12 @@ var ts; if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149 || member.kind === 147) { + if (member.kind === 150 || member.kind === 148) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 150) { + else if (member.kind === 151) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { @@ -34025,21 +36087,20 @@ var ts; } function checkUnusedModuleMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { - for (var key in node.locals) { - var local = node.locals[key]; + node.locals.forEach(function (local) { if (!local.isReferenced && !local.exportSymbol) { for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - error(declaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + errorUnusedLocal(declaration.name, local.name); } } } - } + }); } } function checkBlock(node) { - if (node.kind === 204) { + if (node.kind === 206) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -34061,19 +36122,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 147 || - node.kind === 146 || + if (node.kind === 148 || + node.kind === 147 || + node.kind === 150 || node.kind === 149 || - node.kind === 148 || - node.kind === 151 || - node.kind === 152) { + node.kind === 152 || + node.kind === 153) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 144 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 145 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -34083,6 +36144,11 @@ var ts; potentialThisCollisions.push(node); } } + function checkCollisionWithCapturedNewTargetVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_newTarget")) { + potentialNewTargetCollisions.push(node); + } + } function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; while (current) { @@ -34099,6 +36165,22 @@ var ts; current = current.parent; } } + function checkIfNewTargetIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 8) { + var isDeclaration_2 = node.kind !== 70; + if (isDeclaration_2) { + error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); + } + return; + } + current = current.parent; + } + } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; @@ -34108,8 +36190,8 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 70; - if (isDeclaration_2) { + var isDeclaration_3 = node.kind !== 70; + if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } else { @@ -34124,11 +36206,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 232 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 264 && 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)); } } @@ -34136,11 +36218,11 @@ var ts; if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 232 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 264 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -34148,7 +36230,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 223 && !node.initializer) { + if (node.kind === 225 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -34158,25 +36240,25 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 224); - var container = varDeclList.parent.kind === 205 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 226); + var container = varDeclList.parent.kind === 207 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 204 && ts.isFunctionLike(container.parent) || - container.kind === 231 || - container.kind === 230 || - container.kind === 261); + (container.kind === 206 && ts.isFunctionLike(container.parent) || + container.kind === 233 || + container.kind === 232 || + container.kind === 264); if (!namesShareScope) { - var name_25 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_25, name_25); + var name = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 144) { + if (ts.getRootDeclaration(node).kind !== 145) { return; } var func = ts.getContainingFunction(node); @@ -34185,7 +36267,7 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 177) { + if (n.kind === 178) { return visit(n.expression); } else if (n.kind === 70) { @@ -34199,7 +36281,8 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144) { + if (symbol.valueDeclaration.kind === 145 || + symbol.valueDeclaration.kind === 175) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -34208,7 +36291,7 @@ var ts; if (ts.isFunctionLike(current.parent)) { return; } - if (current.parent.kind === 147 && + if (current.parent.kind === 148 && !(ts.hasModifier(current.parent, 32)) && ts.isClassLike(current.parent.parent)) { return; @@ -34230,37 +36313,37 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 142) { + if (node.name.kind === 143) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 174) { - if (node.parent.kind === 172 && languageVersion < 5) { + if (node.kind === 175) { + if (node.parent.kind === 173 && languageVersion < 5 && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4); } - if (node.propertyName && node.propertyName.kind === 142) { + if (node.propertyName && node.propertyName.kind === 143) { checkComputedPropertyName(node.propertyName); } - var parent_10 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_10); - var name_26 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_26)); + var parent = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent); + var name = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); markPropertyAsReferenced(property); - if (parent_10.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_10, parent_10.initializer, parentType, property); + if (parent.initializer && property) { + checkPropertyAccessibility(parent, parent.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 144 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 145 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 212) { + if (node.initializer && node.parent.parent.kind !== 214) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -34269,7 +36352,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 212) { + if (node.initializer && node.parent.parent.kind !== 214) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -34287,20 +36370,21 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 147 && node.kind !== 146) { + if (node.kind !== 148 && node.kind !== 147) { checkExportsOnMergedDeclarations(node); - if (node.kind === 223 || node.kind === 174) { + if (node.kind === 225 || node.kind === 175) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 && right.kind === 223) || - (left.kind === 223 && right.kind === 144)) { + if ((left.kind === 145 && right.kind === 225) || + (left.kind === 225 && right.kind === 145)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -34327,7 +36411,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 176) { + if (node.modifiers && node.parent.kind === 177) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -34346,7 +36430,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 206) { + if (node.thenStatement.kind === 208) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -34363,12 +36447,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 224) { + if (node.initializer && node.initializer.kind === 226) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 224) { + if (node.initializer.kind === 226) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -34386,13 +36470,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 224) { + if (node.initializer.kind === 226) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 175 || varExpr.kind === 176) { + if (varExpr.kind === 176 || varExpr.kind === 177) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -34411,7 +36495,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 224) { + if (node.initializer.kind === 226) { 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); @@ -34421,7 +36505,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 175 || varExpr.kind === 176) { + if (varExpr.kind === 176 || varExpr.kind === 177) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -34597,7 +36681,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 151 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 152))); + return !!(node.kind === 152 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 153))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -34619,30 +36703,30 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 152) { + if (func.kind === 153) { if (node.expression) { - error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); + error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 150) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { - error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); + else if (func.kind === 151) { + if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node.expression || node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); if (promisedType) { - checkTypeAssignableTo(awaitedType, promisedType, node.expression || node); + checkTypeAssignableTo(awaitedType, promisedType, node); } } else { - checkTypeAssignableTo(exprType, returnType, node.expression || node); + checkTypeAssignableTo(exprType, returnType, node); } } } - else if (func.kind !== 150 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 151 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -34668,7 +36752,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 254 && !hasDuplicateDefaultClause) { + if (clause.kind === 257 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -34680,7 +36764,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 253) { + if (produceDiagnostics && clause.kind === 256) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); var caseIsLiteral = isLiteralType(caseType); @@ -34706,7 +36790,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 219 && current.label.text === node.label.text) { + if (current.kind === 221 && 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; @@ -34739,14 +36823,14 @@ var ts; grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { - var blockLocals = catchClause.block.locals; - if (blockLocals) { - for (var caughtName in catchClause.locals) { - var blockLocal = blockLocals[caughtName]; + var blockLocals_1 = catchClause.block.locals; + if (blockLocals_1) { + ts.forEachKey(catchClause.locals, function (caughtName) { + var blockLocal = blockLocals_1.get(caughtName); if (blockLocal && (blockLocal.flags & 2) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } - } + }); } } } @@ -34794,12 +36878,13 @@ var ts; if (!indexType) { return; } - if (indexKind === 1 && !isNumericName(prop.valueDeclaration.name)) { + var propDeclaration = prop.valueDeclaration; + if (indexKind === 1 && !(propDeclaration ? isNumericName(propDeclaration.name) : isNumericLiteralName(prop.name))) { return; } var errorNode; - if (prop.valueDeclaration.name.kind === 142 || prop.parent === containingType.symbol) { - errorNode = prop.valueDeclaration; + if (propDeclaration && (propDeclaration.name.kind === 143 || prop.parent === containingType.symbol)) { + errorNode = propDeclaration; } else if (indexDeclaration) { errorNode = indexDeclaration; @@ -34824,15 +36909,23 @@ var ts; case "string": case "symbol": case "void": + case "object": error(name, message, name.text); } } function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + var seenDefault = false; + for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { + if (node.default) { + seenDefault = true; + } + else if (seenDefault) { + error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters); + } 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)); @@ -34842,23 +36935,57 @@ var ts; } } } - function checkTypeParameterListsIdentical(node, symbol) { + function checkTypeParameterListsIdentical(symbol) { if (symbol.declarations.length === 1) { return; } - var firstDecl; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 226 || declaration.kind === 227) { - if (!firstDecl) { - firstDecl = declaration; - } - else if (!areTypeParametersIdentical(firstDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); + var links = getSymbolLinks(symbol); + if (!links.typeParametersChecked) { + links.typeParametersChecked = true; + var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); + if (declarations.length <= 1) { + return; + } + var type = getDeclaredTypeOfSymbol(symbol); + if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { + var name = symbolToString(symbol); + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; + error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } } } + function areTypeParametersIdentical(declarations, typeParameters) { + var maxTypeArgumentCount = ts.length(typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; + var numTypeParameters = ts.length(declaration.typeParameters); + if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { + return false; + } + for (var i = 0; i < numTypeParameters; i++) { + var source = declaration.typeParameters[i]; + var target = typeParameters[i]; + if (source.name.text !== target.symbol.name) { + return false; + } + var sourceConstraint = source.constraint && getTypeFromTypeNode(source.constraint); + var targetConstraint = getConstraintFromTypeParameter(target); + if ((sourceConstraint || targetConstraint) && + (!sourceConstraint || !targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint))) { + return false; + } + var sourceDefault = source.default && getTypeFromTypeNode(source.default); + var targetDefault = getDefaultFromTypeParameter(target); + if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) { + return false; + } + } + } + return true; + } function checkClassExpression(node) { checkClassLikeDeclaration(node); checkNodeDeferred(node); @@ -34882,6 +37009,7 @@ var ts; if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -34891,8 +37019,11 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); - checkTypeParameterListsIdentical(node, symbol); + checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); + if (!ts.isInAmbientContext(node)) { + checkClassForStaticPropertyNameConflicts(node); + } var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { if (languageVersion < 2 && !ts.isInAmbientContext(node)) { @@ -34901,7 +37032,8 @@ var ts; var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType_1 = baseTypes[0]; - var staticBaseType = getBaseConstructorTypeOfClass(type); + var baseConstructorType = getBaseConstructorTypeOfClass(type); + var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { @@ -34915,14 +37047,17 @@ var ts; } checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType_1, 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 (baseType_1.symbol.valueDeclaration && + if (baseConstructorType.flags & 540672 && !isMixinConstructorType(staticType)) { + error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); + } + if (baseType_1.symbol && baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 226) { + baseType_1.symbol.valueDeclaration.kind === 228) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 540672)) { var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType_1; })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); @@ -34942,8 +37077,7 @@ var ts; if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - var declaredType = getObjectFlags(t) & 4 ? t.target : t; - if (getObjectFlags(declaredType) & 3) { + if (isValidBaseType(t)) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { @@ -34971,17 +37105,22 @@ var ts; } } function getTargetSymbol(s) { - return s.flags & 16777216 ? getSymbolLinks(s).target : s; + return getCheckFlags(s) & 1 ? s.target : s; } function getClassLikeDeclarationOfSymbol(symbol) { return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); } + function getClassOrInterfaceDeclarationsOfSymbol(symbol) { + return ts.filter(symbol.declarations, function (d) { + return d.kind === 228 || d.kind === 229; + }); + } function checkKindsOfPropertyMemberOverrides(type, baseType) { - var baseProperties = getPropertiesOfObjectType(baseType); + var baseProperties = getPropertiesOfType(baseType); 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) { + if (base.flags & 16777216) { continue; } var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); @@ -34991,7 +37130,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { - if (derivedClassDecl.kind === 197) { + if (derivedClassDecl.kind === 198) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -35035,32 +37174,7 @@ var ts; } } function isAccessor(kind) { - return kind === 151 || kind === 152; - } - 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; + return kind === 152 || kind === 153; } function checkInheritedPropertiesAreIdentical(type, typeNode) { var baseTypes = getBaseTypes(type); @@ -35068,16 +37182,16 @@ var ts; return true; } var seen = ts.createMap(); - ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.name, { prop: p, containingType: type }); }); var ok = true; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; - var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); + var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { var prop = properties_7[_a]; - var existing = seen[prop.name]; + var existing = seen.get(prop.name); if (!existing) { - seen[prop.name] = { prop: prop, containingType: base }; + seen.set(prop.name, { prop: prop, containingType: base }); } else { var isInheritedProperty = existing.containingType !== type; @@ -35101,8 +37215,8 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 227); + checkTypeParameterListsIdentical(symbol); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 229); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -35198,7 +37312,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 190: + case 191: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -35209,7 +37323,7 @@ var ts; case 51: return ~value_1; } return undefined; - case 192: + case 193: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -35233,12 +37347,13 @@ var ts; } return undefined; case 8: + checkGrammarNumericLiteral(e); return +e.text; - case 183: + case 184: return evalConstant(e.expression); case 70: + case 179: case 178: - case 177: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -35249,7 +37364,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 178) { + if (e.kind === 179) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -35266,7 +37381,7 @@ var ts; if (current.kind === 70) { break; } - else if (current.kind === 177) { + else if (current.kind === 178) { current = current.expression; } else { @@ -35306,6 +37421,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); @@ -35326,7 +37442,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 229) { + if (declaration.kind !== 231) { return false; } var enumDeclaration = declaration; @@ -35347,10 +37463,10 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var declaration = declarations_5[_i]; - if ((declaration.kind === 226 || - (declaration.kind === 225 && ts.nodeIsPresent(declaration.body))) && + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 228 || + (declaration.kind === 227 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -35409,7 +37525,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, 226); + var mergedClass = ts.getDeclarationOfKind(symbol, 228); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -35417,7 +37533,7 @@ var ts; } if (isAmbientExternalModule) { if (ts.isExternalModuleAugmentation(node)) { - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 134217728); if (checkBody && node.body) { for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { var statement = _a[_i]; @@ -35452,42 +37568,42 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 205: + case 207: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 240: - case 241: + case 242: + case 243: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 234: - case 235: + case 236: + case 237: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 174: - case 223: - var name_27 = node.name; - if (ts.isBindingPattern(name_27)) { - for (var _b = 0, _c = name_27.elements; _b < _c.length; _b++) { + case 175: + case 225: + var name = node.name; + if (ts.isBindingPattern(name)) { + for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } - case 226: - case 229: - case 225: - case 227: - case 230: case 228: + case 231: + case 227: + case 229: + case 232: + case 230: if (isGlobalAugmentation) { return; } var symbol = getSymbolOfNode(node); if (symbol) { - var reportError = !(symbol.flags & 33554432); + var reportError = !(symbol.flags & 134217728); if (!reportError) { reportError = ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } @@ -35499,12 +37615,12 @@ var ts; switch (node.kind) { case 70: return node; - case 141: + case 142: do { node = node.left; } while (node.kind !== 70); return node; - case 177: + case 178: do { node = node.expression; } while (node.kind !== 70); @@ -35517,9 +37633,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 231 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 && !inAmbientExternalModule) { - error(moduleName, node.kind === 241 ? + var inAmbientExternalModule = node.parent.kind === 233 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 264 && !inAmbientExternalModule) { + error(moduleName, node.kind === 243 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -35540,7 +37656,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 243 ? + var message = node.kind === 245 ? 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)); @@ -35567,7 +37683,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237) { + if (importClause.namedBindings.kind === 239) { checkImportBinding(importClause.namedBindings); } else { @@ -35618,8 +37734,10 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 231 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 233 && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 233 && + !node.moduleSpecifier && ts.isInAmbientContext(node); + if (node.parent.kind !== 264 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -35632,7 +37750,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 261 || node.parent.kind === 231 || node.parent.kind === 230; + var isInAppropriateContext = node.parent.kind === 264 || node.parent.kind === 233 || node.parent.kind === 232; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -35655,9 +37773,14 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 261 ? node.parent : node.parent.parent; - if (container.kind === 230 && !ts.isAmbientModule(container)) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + var container = node.parent.kind === 264 ? node.parent : node.parent.parent; + if (container.kind === 232 && !ts.isAmbientModule(container)) { + if (node.isExportEquals) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + } + else { + error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); + } return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { @@ -35680,18 +37803,13 @@ var ts; } } function hasExportedMembers(moduleSymbol) { - for (var id in moduleSymbol.exports) { - if (id !== "export=") { - return true; - } - } - return false; + return ts.forEachEntry(moduleSymbol.exports, function (_, id) { return id !== "export="; }); } function checkExternalModuleExports(node) { var moduleSymbol = getSymbolOfNode(node); var links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - var exportEqualsSymbol = moduleSymbol.exports["export="]; + var exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; if (!isTopLevelInExternalModuleAugmentation(declaration)) { @@ -35699,31 +37817,31 @@ var ts; } } var exports_1 = getExportsOfModule(moduleSymbol); - for (var id in exports_1) { + exports_1 && exports_1.forEach(function (_a, id) { + var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { - continue; + return; } - var _a = exports_1[id], declarations = _a.declarations, flags = _a.flags; if (flags & (1920 | 64 | 384)) { - continue; + return; } var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); if (flags & 524288 && exportedDeclarationsCount <= 2) { - continue; + return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, id)); } } } - } + }); links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 225 && declaration.kind !== 149) || + return (declaration.kind !== 227 && declaration.kind !== 150) || !!declaration.body; } } @@ -35734,123 +37852,123 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 230: - case 226: + case 232: + case 228: + case 229: case 227: - case 225: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 143: - return checkTypeParameter(node); case 144: + return checkTypeParameter(node); + case 145: return checkParameter(node); + case 148: case 147: - case 146: return checkPropertyDeclaration(node); - case 158: case 159: - case 153: + case 160: case 154: - return checkSignatureDeclaration(node); case 155: return checkSignatureDeclaration(node); - case 149: - case 148: - return checkMethodDeclaration(node); - case 150: - return checkConstructorDeclaration(node); - case 151: - case 152: - return checkAccessorDeclaration(node); - case 157: - return checkTypeReferenceNode(node); case 156: + return checkSignatureDeclaration(node); + case 150: + case 149: + return checkMethodDeclaration(node); + case 151: + return checkConstructorDeclaration(node); + case 152: + case 153: + return checkAccessorDeclaration(node); + case 158: + return checkTypeReferenceNode(node); + case 157: return checkTypePredicate(node); - case 160: - return checkTypeQuery(node); case 161: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 162: - return checkArrayType(node); + return checkTypeLiteral(node); case 163: - return checkTupleType(node); + return checkArrayType(node); case 164: + return checkTupleType(node); case 165: - return checkUnionOrIntersectionType(node); case 166: - case 168: - return checkSourceElement(node.type); + return checkUnionOrIntersectionType(node); + case 167: case 169: - return checkIndexedAccessType(node); + return checkSourceElement(node.type); case 170: + return checkIndexedAccessType(node); + case 171: return checkMappedType(node); - case 225: - return checkFunctionDeclaration(node); - case 204: - case 231: - return checkBlock(node); - case 205: - return checkVariableStatement(node); - case 207: - return checkExpressionStatement(node); - case 208: - return checkIfStatement(node); - case 209: - return checkDoStatement(node); - case 210: - return checkWhileStatement(node); - case 211: - return checkForStatement(node); - case 212: - return checkForInStatement(node); - case 213: - return checkForOfStatement(node); - case 214: - case 215: - return checkBreakOrContinueStatement(node); - case 216: - return checkReturnStatement(node); - case 217: - return checkWithStatement(node); - case 218: - return checkSwitchStatement(node); - case 219: - return checkLabeledStatement(node); - case 220: - return checkThrowStatement(node); - case 221: - return checkTryStatement(node); - case 223: - return checkVariableDeclaration(node); - case 174: - return checkBindingElement(node); - case 226: - return checkClassDeclaration(node); case 227: - return checkInterfaceDeclaration(node); - case 228: - return checkTypeAliasDeclaration(node); - case 229: - return checkEnumDeclaration(node); - case 230: - return checkModuleDeclaration(node); - case 235: - return checkImportDeclaration(node); - case 234: - return checkImportEqualsDeclaration(node); - case 241: - return checkExportDeclaration(node); - case 240: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); case 206: - checkGrammarStatementInAmbientContext(node); - return; + case 233: + return checkBlock(node); + case 207: + return checkVariableStatement(node); + case 209: + return checkExpressionStatement(node); + case 210: + return checkIfStatement(node); + case 211: + return checkDoStatement(node); + case 212: + return checkWhileStatement(node); + case 213: + return checkForStatement(node); + case 214: + return checkForInStatement(node); + case 215: + return checkForOfStatement(node); + case 216: + case 217: + return checkBreakOrContinueStatement(node); + case 218: + return checkReturnStatement(node); + case 219: + return checkWithStatement(node); + case 220: + return checkSwitchStatement(node); + case 221: + return checkLabeledStatement(node); case 222: + return checkThrowStatement(node); + case 223: + return checkTryStatement(node); + case 225: + return checkVariableDeclaration(node); + case 175: + return checkBindingElement(node); + case 228: + return checkClassDeclaration(node); + case 229: + return checkInterfaceDeclaration(node); + case 230: + return checkTypeAliasDeclaration(node); + case 231: + return checkEnumDeclaration(node); + case 232: + return checkModuleDeclaration(node); + case 237: + return checkImportDeclaration(node); + case 236: + return checkImportEqualsDeclaration(node); + case 243: + return checkExportDeclaration(node); + case 242: + return checkExportAssignment(node); + case 208: checkGrammarStatementInAmbientContext(node); return; - case 244: + case 224: + checkGrammarStatementInAmbientContext(node); + return; + case 246: return checkMissingDeclaration(node); } } @@ -35863,17 +37981,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 184: case 185: + case 186: + case 150: case 149: - case 148: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 151: case 152: + case 153: checkAccessorDeferred(node); break; - case 197: + case 198: checkClassExpressionDeferred(node); break; } @@ -35893,6 +38011,7 @@ var ts; } checkGrammarSourceFile(node); potentialThisCollisions.length = 0; + potentialNewTargetCollisions.length = 0; deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; ts.forEach(node.statements, checkSourceElement); @@ -35912,6 +38031,10 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } + if (potentialNewTargetCollisions.length) { + ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); + potentialNewTargetCollisions.length = 0; + } links.flags |= 1; } } @@ -35956,7 +38079,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 217 && node.parent.statement === node) { + if (node.parent.kind === 219 && node.parent.statement === node) { return true; } node = node.parent; @@ -35978,28 +38101,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 261: + case 264: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230: + case 232: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 229: + case 231: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 197: + case 198: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 226: - case 227: + case 228: + case 229: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 184: + case 185: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -36017,17 +38140,16 @@ var ts; function copySymbol(symbol, meaning) { if (symbol.flags & meaning) { var id = symbol.name; - if (!symbols[id]) { - symbols[id] = symbol; + if (!symbols.has(id)) { + symbols.set(id, symbol); } } } function copySymbols(source, meaning) { if (meaning) { - for (var id in source) { - var symbol = source[id]; + source.forEach(function (symbol) { copySymbol(symbol, meaning); - } + }); } } } @@ -36038,27 +38160,27 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 143: - case 226: - case 227: + case 144: case 228: case 229: + case 230: + case 231: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 141) { + while (node.parent && node.parent.kind === 142) { node = node.parent; } - return node.parent && (node.parent.kind === 157 || node.parent.kind === 272); + return node.parent && (node.parent.kind === 158 || node.parent.kind === 276); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 177) { + while (node.parent && node.parent.kind === 178) { node = node.parent; } - return node.parent && node.parent.kind === 199; + return node.parent && node.parent.kind === 200; } function forEachEnclosingClass(node, callback) { var result; @@ -36075,13 +38197,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 141) { + while (nodeOnRightSide.parent.kind === 142) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 234) { + if (nodeOnRightSide.parent.kind === 236) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 240) { + if (nodeOnRightSide.parent.kind === 242) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -36093,7 +38215,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 177) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 178) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1: @@ -36105,11 +38227,11 @@ var ts; default: } } - if (entityName.parent.kind === 240 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 242 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } - if (entityName.kind !== 177 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 234); + if (entityName.kind !== 178 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 236); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -36118,7 +38240,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 199) { + if (entityName.parent.kind === 200) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -36140,14 +38262,14 @@ var ts; } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 177) { + else if (entityName.kind === 178) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 141) { + else if (entityName.kind === 142) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -36156,19 +38278,19 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 272) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 158 || entityName.parent.kind === 276) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 250) { + else if (entityName.parent.kind === 252) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 156) { + if (entityName.parent.kind === 157) { return resolveEntityName(entityName, 1); } return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 261) { + if (node.kind === 264) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -36184,8 +38306,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 174 && - node.parent.parent.kind === 172 && + else if (node.parent.kind === 175 && + node.parent.parent.kind === 173 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -36196,8 +38318,8 @@ var ts; } switch (node.kind) { case 70: - case 177: - case 141: + case 178: + case 142: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98: var container = ts.getThisContainer(node, false); @@ -36210,18 +38332,18 @@ var ts; case 96: var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 167: + case 168: return getTypeFromTypeNode(node).symbol; case 122: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 150) { + if (constructorDeclaration && constructorDeclaration.kind === 151) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 235 || node.parent.kind === 241) && + ((node.parent.kind === 237 || node.parent.kind === 243) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -36229,7 +38351,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 178 && node.parent.argumentExpression === node) { + if (node.parent.kind === 179 && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -36243,7 +38365,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 258) { + if (location && location.kind === 261) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -36293,20 +38415,20 @@ var ts; return unknownType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 176 || expr.kind === 175); - if (expr.parent.kind === 213) { + ts.Debug.assert(expr.kind === 177 || expr.kind === 176); + if (expr.parent.kind === 215) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 192) { + if (expr.parent.kind === 193) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 257) { + if (expr.parent.kind === 260) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 175); + ts.Debug.assert(expr.parent.kind === 176); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); @@ -36332,30 +38454,33 @@ var ts; var propsByName = createSymbolTable(getPropertiesOfType(type)); if (getSignaturesOfType(type, 0).length || getSignaturesOfType(type, 1).length) { ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { - if (!propsByName[p.name]) { - propsByName[p.name] = p; + if (!propsByName.has(p.name)) { + propsByName.set(p.name, p); } }); } return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (symbol.flags & 268435456) { + if (getCheckFlags(symbol) & 2) { var symbols_3 = []; - var name_28 = symbol.name; + var name_2 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_28); + var symbol = getPropertyOfType(t, name_2); if (symbol) { symbols_3.push(symbol); } }); return symbols_3; } - else if (symbol.flags & 67108864) { + else if (symbol.flags & 134217728) { if (symbol.leftSpread) { var links = symbol; return [links.leftSpread, links.rightSpread]; } + if (symbol.mappedTypeOrigin) { + return getRootSymbols(symbol.mappedTypeOrigin); + } var target = void 0; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -36371,7 +38496,8 @@ var ts; if (!ts.isGeneratedIdentifier(node)) { node = ts.getParseTreeNode(node, ts.isIdentifier); if (node) { - return getReferencedValueSymbol(node) === argumentsSymbol; + var isPropertyName_1 = node.parent.kind === 178 && node.parent.name === node; + return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } return false; @@ -36387,7 +38513,7 @@ var ts; if (symbolLinks.exportsSomeValue === undefined) { symbolLinks.exportsSomeValue = hasExportAssignment ? !!(moduleSymbol.flags & 107455) - : ts.forEachProperty(getExportsOfModule(moduleSymbol), isValue); + : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { @@ -36413,7 +38539,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 261) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 264) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -36451,7 +38577,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 204 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 206 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -36491,16 +38617,16 @@ var ts; return true; } switch (node.kind) { - case 234: case 236: - case 237: + case 238: case 239: - case 243: - return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); case 241: + case 245: + return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); + case 243: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 240: + case 242: return node.expression && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -36510,7 +38636,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 261 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 264 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -36552,6 +38678,12 @@ var ts; } return false; } + function isRequiredInitializedParameter(parameter) { + return strictNullChecks && + !isOptionalParameter(parameter) && + parameter.initializer && + !(ts.getModifierFlags(parameter) & 92); + } function getNodeCheckFlags(node) { node = ts.getParseTreeNode(node); return node ? getNodeLinks(node).flags : undefined; @@ -36561,7 +38693,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 260) { + if (node.kind === 263) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -36577,15 +38709,17 @@ var ts; } function getTypeReferenceSerializationKind(typeName, location) { var valueSymbol = resolveEntityName(typeName, 107455, true, false, location); - var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); - if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { - return ts.TypeReferenceSerializationKind.Promise; - } - var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; - if (constructorType && isConstructorType(constructorType)) { - return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; - } var typeSymbol = resolveEntityName(typeName, 793064, true, false, location); + if (valueSymbol && valueSymbol === typeSymbol) { + var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); + if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { + return ts.TypeReferenceSerializationKind.Promise; + } + var constructorType = getTypeOfSymbol(valueSymbol); + if (constructorType && isConstructorType(constructorType)) { + return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + } if (!typeSymbol) { return ts.TypeReferenceSerializationKind.ObjectType; } @@ -36629,6 +38763,9 @@ var ts; var type = symbol && !(symbol.flags & (2048 | 131072)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : unknownType; + if (flags & 4096) { + type = includeFalsyTypes(type, 2048); + } getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { @@ -36643,10 +38780,13 @@ var ts; var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(node)); resolveBaseTypesOfClass(classType); var baseType = classType.resolvedBaseTypes.length ? classType.resolvedBaseTypes[0] : unknownType; + if (!baseType.symbol) { + writer.reportIllegalExtends(); + } getSymbolDisplayBuilder().buildTypeDisplay(baseType, writer, enclosingDeclaration, flags); } function hasGlobalName(name) { - return !!globals[name]; + return globals.has(name); } function getReferencedValueSymbol(reference, startInDeclarationContainer) { var resolvedSymbol = getNodeLinks(reference).resolvedSymbol; @@ -36655,9 +38795,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_11 = reference.parent; - if (ts.isDeclaration(parent_11) && reference === parent_11.name) { - location = getDeclarationContainer(parent_11); + var parent = reference.parent; + if (ts.isDeclaration(parent) && reference === parent.name) { + location = getDeclarationContainer(parent); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -36690,14 +38830,13 @@ var ts; var fileToDirective; if (resolvedTypeReferenceDirectives) { fileToDirective = ts.createFileMap(); - for (var key in resolvedTypeReferenceDirectives) { - var resolvedDirective = resolvedTypeReferenceDirectives[key]; + resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) { if (!resolvedDirective) { - continue; + return; } var file = host.getSourceFile(resolvedDirective.resolvedFileName); fileToDirective.set(file.path, key); - } + }); } return { getReferencedExportContainer: getReferencedExportContainer, @@ -36711,6 +38850,7 @@ var ts; isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, + isRequiredInitializedParameter: isRequiredInitializedParameter, writeTypeOfDeclaration: writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, writeTypeOfExpression: writeTypeOfExpression, @@ -36735,7 +38875,7 @@ var ts; if (!fileToDirective) { return undefined; } - var meaning = (node.kind === 177) || (node.kind === 70 && isInTypeQuery(node)) + var meaning = (node.kind === 178) || (node.kind === 70 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -36770,15 +38910,15 @@ var ts; } var current = symbol; while (true) { - var parent_12 = getParentOfSymbol(current); - if (parent_12) { - current = parent_12; + var parent = getParentOfSymbol(current); + if (parent) { + current = parent; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 261 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 264 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -36797,7 +38937,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 261); + return ts.getDeclarationOfKind(moduleSymbol, 264); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -36818,11 +38958,11 @@ var ts; } if (file.symbol && file.symbol.globalExports) { var source = file.symbol.globalExports; - for (var id in source) { - if (!(id in globals)) { - globals[id] = source[id]; + source.forEach(function (sourceSymbol, id) { + if (!globals.has(id)) { + globals.set(id, sourceSymbol); } - } + }); } } if (augmentations) { @@ -36888,10 +39028,10 @@ var ts; var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1; helper <= 128; helper <<= 1) { if (uncheckedHelpers & helper) { - var name_29 = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_29), 107455); + var name = getHelperName(helper); + var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name), 107455); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_29); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); } } } @@ -36926,7 +39066,7 @@ var ts; return emptyObjectType; } function createThenableType() { - var thenPropertySymbol = createSymbol(67108864 | 4, "then"); + var thenPropertySymbol = createSymbol(4, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; var thenableType = createObjectType(16); thenableType.properties = [thenPropertySymbol]; @@ -36940,14 +39080,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 149 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 150 && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 151 || node.kind === 152) { + else if (node.kind === 152 || node.kind === 153) { 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); @@ -36965,16 +39105,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 130) { - if (node.kind === 146 || node.kind === 148) { + if (node.kind === 147 || node.kind === 149) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 155) { + if (node.kind === 156) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 75: - if (node.kind !== 229 && node.parent.kind === 226) { + if (node.kind !== 231 && node.parent.kind === 228) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; @@ -37000,7 +39140,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 231 || node.parent.kind === 261) { + else if (node.parent.kind === 233 || node.parent.kind === 264) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -37023,10 +39163,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 231 || node.parent.kind === 261) { + else if (node.parent.kind === 233 || node.parent.kind === 264) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -37039,7 +39179,7 @@ var ts; if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 147 && node.kind !== 146 && node.kind !== 155 && node.kind !== 144) { + else if (node.kind !== 148 && node.kind !== 147 && node.kind !== 156 && node.kind !== 145) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; @@ -37058,10 +39198,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 228) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; @@ -37073,13 +39213,13 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 226) { + else if (node.parent.kind === 228) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 231) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 233) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -37089,14 +39229,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 226) { - if (node.kind !== 149 && - node.kind !== 147 && - node.kind !== 151 && - node.kind !== 152) { + if (node.kind !== 228) { + if (node.kind !== 150 && + node.kind !== 148 && + node.kind !== 152 && + node.kind !== 153) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 226 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 228 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -37115,7 +39255,7 @@ var ts; 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 === 144) { + else if (node.kind === 145) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -37123,7 +39263,7 @@ var ts; break; } } - if (node.kind === 150) { + if (node.kind === 151) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -37138,13 +39278,13 @@ var ts; } return; } - else if ((node.kind === 235 || node.kind === 234) && flags & 2) { + else if ((node.kind === 237 || node.kind === 236) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 144 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 145 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 144 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 145 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -37160,37 +39300,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 151: case 152: - case 150: - case 147: - case 146: - case 149: + case 153: + case 151: case 148: - case 155: - case 230: - case 235: - case 234: - case 241: - case 240: - case 184: + case 147: + case 150: + case 149: + case 156: + case 232: + case 237: + case 236: + case 243: + case 242: case 185: - case 144: + case 186: + case 145: return false; default: - if (node.parent.kind === 231 || node.parent.kind === 261) { + if (node.parent.kind === 233 || node.parent.kind === 264) { return false; } switch (node.kind) { - case 225: - return nodeHasAnyModifiersExcept(node, 119); - case 226: - return nodeHasAnyModifiersExcept(node, 116); case 227: - case 205: + return nodeHasAnyModifiersExcept(node, 119); case 228: - return true; + return nodeHasAnyModifiersExcept(node, 116); case 229: + case 207: + case 230: + return true; + case 231: return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); @@ -37203,10 +39343,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 149: - case 225: - case 184: + case 150: + case 227: case 185: + case 186: if (!node.asteriskToken) { return false; } @@ -37268,7 +39408,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 185) { + if (node.kind === 186) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -37303,7 +39443,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 !== 134 && parameter.type.kind !== 132) { + if (parameter.type.kind !== 135 && parameter.type.kind !== 132) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -37330,7 +39470,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 198) { + if (arg.kind === 199) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -37400,19 +39540,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 142) { + if (node.kind !== 143) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 192 && computedPropertyName.expression.operatorToken.kind === 25) { + if (computedPropertyName.expression.kind === 193 && computedPropertyName.expression.operatorToken.kind === 25) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 225 || - node.kind === 184 || - node.kind === 149); + ts.Debug.assert(node.kind === 227 || + node.kind === 185 || + node.kind === 150); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -37437,87 +39577,87 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259) { + if (prop.kind === 262) { continue; } - var name_30 = prop.name; - if (name_30.kind === 142) { - checkGrammarComputedPropertyName(name_30); + var name = prop.name; + if (name.kind === 143) { + checkGrammarComputedPropertyName(name); } - if (prop.kind === 258 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 261 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 || prop.kind !== 149) { + if (mod.kind !== 119 || prop.kind !== 150) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; - if (prop.kind === 257 || prop.kind === 258) { + if (prop.kind === 260 || prop.kind === 261) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_30.kind === 8) { - checkGrammarNumericLiteral(name_30); + if (name.kind === 8) { + checkGrammarNumericLiteral(name); } currentKind = Property; } - else if (prop.kind === 149) { + else if (prop.kind === 150) { currentKind = Property; } - else if (prop.kind === 151) { + else if (prop.kind === 152) { currentKind = GetAccessor; } - else if (prop.kind === 152) { + else if (prop.kind === 153) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_30); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { continue; } - if (!seen[effectiveName]) { - seen[effectiveName] = currentKind; + var existingKind = seen.get(effectiveName); + if (!existingKind) { + seen.set(effectiveName, currentKind); } else { - var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_30, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_30)); + grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[effectiveName] = currentKind | existingKind; + seen.set(effectiveName, currentKind | existingKind); } else { - return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } } function checkGrammarJsxElement(node) { var seen = ts.createMap(); - for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { + for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 251) { + if (attr.kind === 254) { continue; } var jsxAttr = attr; - var name_31 = jsxAttr.name; - if (!seen[name_31.text]) { - seen[name_31.text] = true; + var name = jsxAttr.name; + if (!seen.get(name.text)) { + seen.set(name.text, true); } else { - return grammarErrorOnNode(name_31, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 252 && !initializer.expression) { + if (initializer && initializer.kind === 255 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -37526,7 +39666,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 224) { + if (forInOrOfStatement.initializer.kind === 226) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -37534,20 +39674,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 214 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 212 + var diagnostic = forInOrOfStatement.kind === 214 ? 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 === 212 + var diagnostic = forInOrOfStatement.kind === 214 ? 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); @@ -37574,11 +39714,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 151 ? + return grammarErrorOnNode(accessor.name, kind === 152 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 152) { + else if (kind === 153) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -37597,10 +39737,10 @@ var ts; } } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 151 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 152 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 151 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 152 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -37615,7 +39755,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 176) { + if (node.parent.kind === 177) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -37631,10 +39771,10 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 229) { 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 === 161) { + else if (node.parent.kind === 162) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -37645,9 +39785,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 219: + case 221: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 214 + var isMisplacedContinueLabel = node.kind === 216 && !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); @@ -37655,8 +39795,8 @@ var ts; return false; } break; - case 218: - if (node.kind === 215 && !node.label) { + case 220: + if (node.kind === 217 && !node.label) { return false; } break; @@ -37669,13 +39809,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 215 + var message = node.kind === 217 ? 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 === 215 + var message = node.kind === 217 ? 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); @@ -37687,7 +39827,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 173 || node.name.kind === 172) { + if (node.name.kind === 174 || node.name.kind === 173) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -37697,11 +39837,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 190 && expr.operator === 37 && + expr.kind === 191 && expr.operator === 37 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 212 && node.parent.parent.kind !== 213) { + if (node.parent.parent.kind !== 214 && node.parent.parent.kind !== 215) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -37728,9 +39868,29 @@ var ts; } } } + if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && + !ts.isInAmbientContext(node.parent.parent) && ts.hasModifier(node.parent.parent, 1)) { + checkESModuleMarker(node.name); + } var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } + function checkESModuleMarker(name) { + if (name.kind === 70) { + if (ts.unescapeIdentifier(name.text) === "__esModule") { + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); + } + } + else { + var elements = name.elements; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; + if (!ts.isOmittedExpression(element)) { + return checkESModuleMarker(element.name); + } + } + } + } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 70) { if (name.originalKeywordKind === 109) { @@ -37739,8 +39899,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { - var element = elements_2[_i]; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var element = elements_3[_i]; if (!ts.isOmittedExpression(element)) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -37758,15 +39918,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 208: - case 209: case 210: - case 217: case 211: case 212: - case 213: - return false; case 219: + case 213: + case 214: + case 215: + return false; + case 221: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -37781,6 +39941,13 @@ var ts; } } } + function checkGrammarMetaProperty(node) { + if (node.keywordToken === 93) { + if (node.name.text !== "target") { + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + } + } + } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -37821,7 +39988,7 @@ var ts; return true; } } - else if (node.parent.kind === 227) { + else if (node.parent.kind === 229) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -37829,7 +39996,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 161) { + else if (node.parent.kind === 162) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -37842,13 +40009,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 227 || - node.kind === 228 || + if (node.kind === 229 || + node.kind === 230 || + node.kind === 237 || + node.kind === 236 || + node.kind === 243 || + node.kind === 242 || node.kind === 235 || - node.kind === 234 || - node.kind === 241 || - node.kind === 240 || - node.kind === 233 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -37857,7 +40024,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 === 205) { + if (ts.isDeclaration(decl) || decl.kind === 207) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -37876,7 +40043,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 === 204 || node.parent.kind === 231 || node.parent.kind === 261) { + if (node.parent.kind === 206 || node.parent.kind === 233 || node.parent.kind === 264) { 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); @@ -37887,8 +40054,22 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.isOctalLiteral && languageVersion >= 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + if (node.isOctalLiteral) { + var diagnosticMessage = void 0; + if (languageVersion >= 1) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 172)) { + diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 263)) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; + } + if (diagnosticMessage) { + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37; + var literal = (withMinus ? "-" : "") + "0o" + node.text; + return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); + } } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -37901,11 +40082,11 @@ var ts; } function getAmbientModules() { var result = []; - for (var sym in globals) { + globals.forEach(function (global, sym) { if (ambientModuleSymbolRegex.test(sym)) { - result.push(globals[sym]); + result.push(global); } - } + }); return result; } } @@ -37913,55 +40094,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ; - var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[141] = [ - { name: "left", test: ts.isEntityName }, - { name: "right", test: ts.isIdentifier } - ], - _a[145] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[182] = [ - { name: "type", test: ts.isTypeNode }, - { name: "expression", test: ts.isUnaryExpression } - ], - _a[200] = [ - { name: "expression", test: ts.isExpression }, - { name: "type", test: ts.isTypeNode } - ], - _a[201] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[229] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "members", test: ts.isEnumMember } - ], - _a[230] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isModuleName }, - { name: "body", test: ts.isModuleBody } - ], - _a[231] = [ - { name: "statements", test: ts.isStatement } - ], - _a[234] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "moduleReference", test: ts.isModuleReference } - ], - _a[245] = [ - { name: "expression", test: ts.isExpression, optional: true } - ], - _a[260] = [ - { name: "name", test: ts.isPropertyName }, - { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } - ], - _a)); function reduceNode(node, f, initial) { return node ? f(initial, node) : initial; } @@ -37975,41 +40107,45 @@ var ts; var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; - if ((kind > 0 && kind <= 140)) { + if ((kind > 0 && kind <= 141)) { return initial; } - if ((kind >= 156 && kind <= 171)) { + if ((kind >= 157 && kind <= 172)) { return initial; } var result = initial; switch (node.kind) { - case 203: - case 206: - case 198: - case 222: - case 293: + case 205: + case 208: + case 199: + case 224: + case 297: break; case 142: - result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); break; - case 144: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); + case 143: + result = reduceNode(node.expression, cbNode, result); break; case 145: - result = reduceNode(node.expression, cbNode, result); - break; - case 147: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 149: + case 146: + result = reduceNode(node.expression, cbNode, result); + break; + case 148: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 150: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -38018,53 +40154,48 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 150: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); - break; case 151: - result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; case 152: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 153: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 172: case 173: + case 174: result = reduceNodes(node.elements, cbNodes, result); break; - case 174: + case 175: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 175: + case 176: result = reduceNodes(node.elements, cbNodes, result); break; - case 176: - result = reduceNodes(node.properties, cbNodes, result); - break; case 177: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.properties, cbNodes, result); break; case 178: result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.argumentExpression, cbNode, result); + result = reduceNode(node.name, cbNode, result); break; case 179: result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); + result = reduceNode(node.argumentExpression, cbNode, result); break; case 180: result = reduceNode(node.expression, cbNode, result); @@ -38072,10 +40203,19 @@ var ts; result = reduceNodes(node.arguments, cbNodes, result); break; case 181: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 182: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 184: + case 183: + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 185: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -38083,117 +40223,124 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 185: + case 186: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 183: - case 186: + case 184: case 187: case 188: case 189: - case 195: + case 190: case 196: - case 201: + case 197: + case 202: result = reduceNode(node.expression, cbNode, result); break; - case 190: case 191: + case 192: result = reduceNode(node.operand, cbNode, result); break; - case 192: + case 193: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 193: + case 194: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 194: + case 195: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 197: + case 198: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 199: + case 200: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; + case 201: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.type, cbNode, result); + break; case 202: + result = reduceNode(node.expression, cbNode, result); + break; + case 204: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 204: + case 206: result = reduceNodes(node.statements, cbNodes, result); break; - case 205: + case 207: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 207: + case 209: result = reduceNode(node.expression, cbNode, result); break; - case 208: + case 210: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 209: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 210: - case 217: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; case 211: + result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 212: + case 219: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 213: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 212: - case 213: + case 214: + case 215: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 216: - case 220: + case 218: + case 222: result = reduceNode(node.expression, cbNode, result); break; - case 218: + case 220: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 219: + case 221: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 221: + case 223: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 223: + case 225: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 224: + case 226: result = reduceNodes(node.declarations, cbNodes, result); break; - case 225: + case 227: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -38202,7 +40349,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 226: + case 228: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -38210,113 +40357,131 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; + case 231: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.members, cbNodes, result); + break; case 232: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 233: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 234: result = reduceNodes(node.clauses, cbNodes, result); break; - case 235: + case 236: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.moduleReference, cbNode, result); + break; + case 237: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 236: + case 238: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 237: - result = reduceNode(node.name, cbNode, result); - break; - case 238: - case 242: - result = reduceNodes(node.elements, cbNodes, result); - break; case 239: - case 243: - result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; case 240: + case 244: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 241: + case 245: + result = reduceNode(node.propertyName, cbNode, result); + result = reduceNode(node.name, cbNode, result); + break; + case 242: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 241: + case 243: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 246: + case 247: + result = reduceNode(node.expression, cbNode, result); + break; + case 248: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 247: - case 248: - result = reduceNode(node.tagName, cbNode, result); - result = reduceNodes(node.attributes, cbNodes, result); - break; case 249: + case 250: + result = reduceNode(node.tagName, cbNode, result); + result = reduceNode(node.attributes, cbNode, result); + break; + case 251: result = reduceNode(node.tagName, cbNode, result); break; - case 250: + case 253: + result = reduceNodes(node.properties, cbNodes, result); + break; + case 252: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 251: - result = reduceNode(node.expression, cbNode, result); - break; - case 252: - result = reduceNode(node.expression, cbNode, result); - break; - case 253: - result = reduceNode(node.expression, cbNode, result); case 254: - result = reduceNodes(node.statements, cbNodes, result); + result = reduceNode(node.expression, cbNode, result); break; case 255: - result = reduceNodes(node.types, cbNodes, result); + result = reduceNode(node.expression, cbNode, result); break; case 256: + result = reduceNode(node.expression, cbNode, result); + case 257: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 258: + result = reduceNodes(node.types, cbNodes, result); + break; + case 259: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 257: + case 260: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 258: + case 261: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 259: + case 262: result = reduceNode(node.expression, cbNode, result); break; - case 261: + case 263: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + case 264: result = reduceNodes(node.statements, cbNodes, result); break; - case 294: + case 298: result = reduceNode(node.expression, cbNode, result); break; default: - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_1 = edgeTraversalPath; _i < edgeTraversalPath_1.length; _i++) { - var edge = edgeTraversalPath_1[_i]; - var value = node[edge.name]; - if (value !== undefined) { - result = ts.isArray(value) - ? reduceNodes(value, cbNodes, result) - : cbNode(result, value); - } - } - } break; } return result; } ts.reduceEachChild = reduceEachChild; - function visitNode(node, visitor, test, optional, lift, parenthesize, parentNode) { + function visitNode(node, visitor, test, optional, lift) { if (node === undefined || visitor === undefined) { return node; } @@ -38338,15 +40503,12 @@ var ts; else { visitedNode = visited; } - if (parenthesize !== undefined) { - visitedNode = parenthesize(visitedNode, parentNode); - } Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); return visitedNode; } ts.visitNode = visitNode; - function visitNodes(nodes, visitor, test, start, count, parenthesize, parentNode) { + function visitNodes(nodes, visitor, test, start, count) { if (nodes === undefined) { return undefined; } @@ -38359,7 +40521,7 @@ var ts; count = length - start; } if (start > 0 || count < length) { - updated = ts.createNodeArray([], undefined, nodes.hasTrailingComma && start + count === length); + updated = ts.createNodeArray([], nodes.hasTrailingComma && start + count === length); } for (var i = 0; i < count; i++) { var node = nodes[i + start]; @@ -38367,27 +40529,22 @@ var ts; var visited = node !== undefined ? visitor(node) : undefined; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { - updated = ts.createNodeArray(nodes.slice(0, i), nodes, nodes.hasTrailingComma); + updated = ts.createNodeArray(nodes.slice(0, i), nodes.hasTrailingComma); + ts.setTextRange(updated, nodes); } if (visited) { if (ts.isArray(visited)) { for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) { var visitedNode = visited_1[_i]; - visitedNode = parenthesize - ? parenthesize(visitedNode, parentNode) - : visitedNode; Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); updated.push(visitedNode); } } else { - var visitedNode = parenthesize - ? parenthesize(visited, parentNode) - : visited; - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); - updated.push(visitedNode); + Debug.assertNode(visited, test); + aggregateTransformFlags(visited); + updated.push(visited); } } } @@ -38399,10 +40556,10 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); - return ts.createNodeArray(ts.concatenate(statements, declarations), statements); + return ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements); } ts.visitLexicalEnvironment = visitLexicalEnvironment; function visitParameterList(nodes, visitor, context) { @@ -38429,203 +40586,206 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 140)) { + if ((kind > 0 && kind <= 141)) { return node; } - if ((kind >= 156 && kind <= 171)) { + if ((kind >= 157 && kind <= 172)) { return node; } switch (node.kind) { - case 203: - case 206: - case 198: - case 222: + case 205: + case 208: + case 199: + case 224: return node; case 142: + return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); + case 143: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 144: + case 145: return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), node.dotDotDotToken, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 147: + case 146: + return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); + case 148: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 149: - return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 150: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); + return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 151: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); case 152: + return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + case 153: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); - case 172: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 173: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); + return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 174: - return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); + return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); case 175: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); + return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); case 176: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); + return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); case 177: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); case 178: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); case 179: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); case 180: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); case 181: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 182: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); case 183: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 184: - return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 185: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 186: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 187: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 188: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); case 189: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); case 190: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 191: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); case 193: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + case 191: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 192: + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); case 194: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); case 195: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); case 196: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); case 197: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 198: return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 199: + case 200: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 201: + return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); case 202: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 204: + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + case 206: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 205: - return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); case 207: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 208: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); + return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); case 209: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 210: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); case 211: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); case 212: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 213: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 214: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 215: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 216: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 217: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 218: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); case 219: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); case 220: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); case 221: - return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 222: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); case 223: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 224: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); case 225: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 226: + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + case 227: + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); + case 228: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); + case 231: + return ts.updateEnumDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNodes(node.members, visitor, ts.isEnumMember)); case 232: + return ts.updateModuleDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); + case 233: + return ts.updateModuleBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 234: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 235: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 236: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); + return ts.updateImportEqualsDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); case 237: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 238: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); case 239: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 240: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 241: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 242: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 243: + return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + case 244: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + case 245: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 246: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 247: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); case 248: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 249: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 250: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 251: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 252: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 253: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxAttributes(node, visitNodes(node.properties, visitor, ts.isJsxAttributeLike)); + case 249: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 250: + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 251: + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + case 252: + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 254: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 255: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 256: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); case 257: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); case 258: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); case 259: - return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + case 260: + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); case 261: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 262: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + case 263: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 264: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 294: + case 298: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: - var updated = void 0; - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_2 = edgeTraversalPath; _i < edgeTraversalPath_2.length; _i++) { - var edge = edgeTraversalPath_2[_i]; - var value = node[edge.name]; - if (value !== undefined) { - var visited = ts.isArray(value) - ? visitNodes(value, visitor, edge.test, 0, value.length, edge.parenthesize, node) - : visitNode(value, visitor, edge.test, edge.optional, edge.lift, edge.parenthesize, node); - if (updated !== undefined || visited !== value) { - if (updated === undefined) { - updated = ts.getMutableClone(node); - } - if (visited !== value) { - updated[edge.name] = visited; - } - } - } - } - } - return updated ? ts.updateNode(updated, node) : node; + return node; } } ts.visitEachChild = visitEachChild; @@ -38634,17 +40794,17 @@ var ts; return statements; } return ts.isNodeArray(statements) - ? ts.createNodeArray(ts.concatenate(statements, declarations), statements) + ? ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements) : ts.addRange(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; function mergeFunctionBodyLexicalEnvironment(body, declarations) { if (body && declarations !== undefined && declarations.length > 0) { if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.createNodeArray(ts.concatenate(body.statements, declarations), body.statements)); + return ts.updateBlock(body, ts.setTextRange(ts.createNodeArray(ts.concatenate(body.statements, declarations)), body.statements)); } else { - return ts.createBlock(ts.createNodeArray([ts.createReturn(body, body)].concat(declarations), body), body, true); + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray([ts.setTextRange(ts.createReturn(body), body)].concat(declarations)), body), true), body); } } return body; @@ -38689,7 +40849,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || ts.isTypeNode(node)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 200)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -38737,10 +40897,14 @@ var ts; } } })(Debug = ts.Debug || (ts.Debug = {})); - var _a; })(ts || (ts = {})); var ts; (function (ts) { + var FlattenLevel; + (function (FlattenLevel) { + FlattenLevel[FlattenLevel["All"] = 0] = "All"; + FlattenLevel[FlattenLevel["ObjectRest"] = 1] = "ObjectRest"; + })(FlattenLevel = ts.FlattenLevel || (ts.FlattenLevel = {})); function flattenDestructuringAssignment(node, visitor, context, level, needsValue, createAssignmentCallback) { var location = node; var value; @@ -38794,7 +40958,7 @@ var ts; ts.Debug.assertNode(target, createAssignmentCallback ? ts.isIdentifier : ts.isExpression); var expression = createAssignmentCallback ? createAssignmentCallback(target, value, location) - : ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value, location); + : ts.setTextRange(ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value), location); expression.original = original; emitExpression(expression); } @@ -38832,10 +40996,11 @@ var ts; } } for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) { - var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_32 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; - var variable = ts.createVariableDeclaration(name_32, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); + var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name = _a.name, value = _a.value, location = _a.location, original = _a.original; + var variable = ts.createVariableDeclaration(name, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value); variable.original = original; - if (ts.isIdentifier(name_32)) { + ts.setTextRange(variable, location); + if (ts.isIdentifier(name)) { ts.setEmitFlags(variable, 64); } ts.aggregateTransformFlags(variable); @@ -38981,8 +41146,8 @@ var ts; return ts.createElementAccess(value, argumentExpression); } else { - var name_33 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); - return ts.createPropertyAccess(value, name_33); + var name = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); + return ts.createPropertyAccess(value, name); } } function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) { @@ -38993,7 +41158,7 @@ var ts; var temp = ts.createTempVariable(undefined); if (flattenContext.hoistTempVariables) { flattenContext.context.hoistVariableDeclaration(temp); - flattenContext.emitExpression(ts.createAssignment(temp, value, location)); + flattenContext.emitExpression(ts.setTextRange(ts.createAssignment(temp, value), location)); } else { flattenContext.emitBindingOrAssignment(temp, value, location, undefined); @@ -39043,12 +41208,21 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), undefined, [value, ts.createArrayLiteral(propertyNames, location)]); + return ts.createCall(ts.getHelperName("__rest"), undefined, [ + value, + ts.setTextRange(ts.createArrayLiteral(propertyNames), location) + ]); } })(ts || (ts = {})); var ts; (function (ts) { var USE_NEW_TYPE_METADATA_FORMAT = false; + var TypeScriptSubstitutionFlags; + (function (TypeScriptSubstitutionFlags) { + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; + })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); function transformTypeScript(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -39059,8 +41233,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(177); context.enableSubstitution(178); + context.enableSubstitution(179); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -39093,15 +41267,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 261: - case 232: - case 231: - case 204: + case 264: + case 234: + case 233: + case 206: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 226: - case 225: + case 228: + case 227: if (ts.hasModifier(node, 2)) { break; } @@ -39126,13 +41300,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 235: + case 237: return visitImportDeclaration(node); - case 234: + case 236: return visitImportEqualsDeclaration(node); - case 240: + case 242: return visitExportAssignment(node); - case 241: + case 243: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -39142,11 +41316,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 241 || - node.kind === 235 || - node.kind === 236 || - (node.kind === 234 && - node.moduleReference.kind === 245)) { + if (node.kind === 243 || + node.kind === 237 || + node.kind === 238 || + (node.kind === 236 && + node.moduleReference.kind === 247)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -39162,15 +41336,15 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 150: - return undefined; - case 147: - case 155: case 151: + return undefined; + case 148: + case 156: case 152: - case 149: + case 153: + case 150: return visitorWorker(node); - case 203: + case 205: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -39201,23 +41375,22 @@ var ts; case 75: case 123: case 130: - case 162: case 163: - case 161: - case 156: - case 143: + case 164: + case 162: + case 157: + case 144: case 118: case 121: - case 134: + case 135: case 132: case 129: case 104: - case 135: - case 159: - case 158: + case 136: case 160: - case 157: - case 164: + case 159: + case 161: + case 158: case 165: case 166: case 167: @@ -39225,57 +41398,58 @@ var ts; case 169: case 170: case 171: - case 155: - case 145: - case 228: - case 147: - return undefined; - case 150: - return visitConstructor(node); - case 227: - return ts.createNotEmittedStatement(node); - case 226: - return visitClassDeclaration(node); - case 197: - return visitClassExpression(node); - case 255: - return visitHeritageClause(node); - case 199: - return visitExpressionWithTypeArguments(node); - case 149: - return visitMethodDeclaration(node); - case 151: - return visitGetAccessor(node); - case 152: - return visitSetAccessor(node); - case 225: - return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); - case 185: - return visitArrowFunction(node); - case 144: - return visitParameter(node); - case 183: - return visitParenthesizedExpression(node); - case 182: - case 200: - return visitAssertionExpression(node); - case 179: - return visitCallExpression(node); - case 180: - return visitNewExpression(node); - case 201: - return visitNonNullExpression(node); - case 229: - return visitEnumDeclaration(node); - case 205: - return visitVariableStatement(node); - case 223: - return visitVariableDeclaration(node); + case 172: + case 156: + case 146: case 230: + case 148: + return undefined; + case 151: + return visitConstructor(node); + case 229: + return ts.createNotEmittedStatement(node); + case 228: + return visitClassDeclaration(node); + case 198: + return visitClassExpression(node); + case 258: + return visitHeritageClause(node); + case 200: + return visitExpressionWithTypeArguments(node); + case 150: + return visitMethodDeclaration(node); + case 152: + return visitGetAccessor(node); + case 153: + return visitSetAccessor(node); + case 227: + return visitFunctionDeclaration(node); + case 185: + return visitFunctionExpression(node); + case 186: + return visitArrowFunction(node); + case 145: + return visitParameter(node); + case 184: + return visitParenthesizedExpression(node); + case 183: + case 201: + return visitAssertionExpression(node); + case 180: + return visitCallExpression(node); + case 181: + return visitNewExpression(node); + case 202: + return visitNonNullExpression(node); + case 231: + return visitEnumDeclaration(node); + case 207: + return visitVariableStatement(node); + case 225: + return visitVariableDeclaration(node); + case 232: return visitModuleDeclaration(node); - case 234: + case 236: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39335,11 +41509,12 @@ var ts; return ts.singleOrMany(statements); } function createClassDeclarationHeadWithoutDecorators(node, name, hasExtendsClause, hasStaticProperties) { - var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); + var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause)); var emitFlags = ts.getEmitFlags(node); if (hasStaticProperties) { emitFlags |= 32; } + ts.setTextRange(classDeclaration, node); ts.setOriginalNode(classDeclaration, node); ts.setEmitFlags(classDeclaration, emitFlags); return classDeclaration; @@ -39350,10 +41525,14 @@ var ts; var declName = ts.getLocalName(node, false, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, hasExtendsClause); - var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members, location); + var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); - var statement = ts.createLetStatement(declName, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression, location); + ts.setTextRange(classExpression, location); + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(declName, undefined, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression) + ], 1)); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, location); ts.setCommentRange(statement, node); return statement; } @@ -39361,7 +41540,9 @@ var ts; var staticProperties = getInitializedProperties(node, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84; })); - var classExpression = ts.setOriginalNode(ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members, node), node); + var classExpression = ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members); + ts.setOriginalNode(classExpression, node); + ts.setTextRange(classExpression, node); if (staticProperties.length > 0) { var expressions = []; var temp = ts.createTempVariable(hoistVariableDeclaration); @@ -39384,7 +41565,7 @@ var ts; members.push(constructor); } ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement)); - return ts.createNodeArray(members, node.members); + return ts.setTextRange(ts.createNodeArray(members), node.members); } function transformConstructor(node, hasExtendsClause) { var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); @@ -39395,7 +41576,7 @@ var ts; } var parameters = transformConstructorParameters(constructor); var body = transformConstructorBody(node, constructor, hasExtendsClause); - return ts.startOnNewLine(ts.setOriginalNode(ts.createConstructor(undefined, undefined, parameters, body, constructor || node), constructor)); + return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(ts.createConstructor(undefined, undefined, parameters, body), constructor || node), constructor)); } function transformConstructorParameters(constructor) { return ts.visitParameterList(constructor && constructor.parameters, visitor, context) @@ -39419,7 +41600,7 @@ var ts; ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } ts.addRange(statements, endLexicalEnvironment()); - return ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : undefined, true); + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined); } function addPrologueDirectivesAndInitialSuperCall(ctor, result) { if (ctor.body) { @@ -39429,7 +41610,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -39451,7 +41632,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 | 48); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536); - return ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), propertyName, node.name), localName), ts.moveRangePos(node, -1))); + return ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1))); } function getInitializedProperties(node, isStatic) { return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); @@ -39463,7 +41644,7 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 147 + return member.kind === 148 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } @@ -39536,12 +41717,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 151: case 152: + case 153: return getAllDecoratorsOfAccessors(node, member); - case 149: + case 150: return getAllDecoratorsOfMethod(member); - case 147: + case 148: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -39620,7 +41801,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 147 + ? member.kind === 148 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -39698,43 +41879,43 @@ var ts; (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeReturnTypeOfNode(node)))); } if (properties) { - decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, undefined, true))); + decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, true))); } } } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 149 - || kind === 151 + return kind === 150 || kind === 152 - || kind === 147; + || kind === 153 + || kind === 148; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 149; + return node.kind === 150; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 226: - case 197: + case 228: + case 198: return ts.getFirstConstructorWithBody(node) !== undefined; - case 149: - case 151: + case 150: case 152: + case 153: return true; } return false; } function serializeTypeOfNode(node) { switch (node.kind) { - case 147: - case 144: - case 151: - return serializeTypeNode(node.type); + case 148: + case 145: case 152: + return serializeTypeNode(node.type); + case 153: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 226: - case 197: - case 149: + case 228: + case 198: + case 150: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -39766,7 +41947,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 151) { + if (container && node.kind === 152) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -39789,21 +41970,24 @@ var ts; } switch (node.kind) { case 104: + case 138: + case 94: + case 129: return ts.createVoidZero(); - case 166: + case 167: return serializeTypeNode(node.type); - case 158: case 159: + case 160: return ts.createIdentifier("Function"); - case 162: case 163: + case 164: return ts.createIdentifier("Array"); - case 156: + case 157: case 121: return ts.createIdentifier("Boolean"); - case 134: + case 135: return ts.createIdentifier("String"); - case 171: + case 172: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); @@ -39819,44 +42003,22 @@ var ts; break; case 132: return ts.createIdentifier("Number"); - case 135: + case 136: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 157: + case 158: return serializeTypeReferenceNode(node); + case 166: case 165: - case 164: - { - var unionOrIntersection = node; - var serializedUnion = void 0; - for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - var serializedIndividual = serializeTypeNode(typeNode); - if (serializedIndividual.kind !== 70) { - serializedUnion = undefined; - break; - } - if (serializedIndividual.text === "Object") { - return serializedIndividual; - } - if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { - serializedUnion = undefined; - break; - } - serializedUnion = serializedIndividual; - } - if (serializedUnion) { - return serializedUnion; - } - } - case 160: - case 168: + return serializeUnionOrIntersectionType(node); + case 161: case 169: case 170: - case 161: + case 171: + case 162: case 118: - case 167: + case 168: break; default: ts.Debug.failBadSyntaxKind(node); @@ -39864,6 +42026,32 @@ var ts; } return ts.createIdentifier("Object"); } + function serializeUnionOrIntersectionType(node) { + var serializedUnion; + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + if (ts.isVoidExpression(serializedIndividual)) { + if (!serializedUnion) { + serializedUnion = serializedIndividual; + } + } + else if (ts.isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") { + return serializedIndividual; + } + else if (serializedUnion && !ts.isVoidExpression(serializedUnion)) { + if (!ts.isIdentifier(serializedUnion) || + !ts.isIdentifier(serializedIndividual) || + serializedUnion.text !== serializedIndividual.text) { + return ts.createIdentifier("Object"); + } + } + else { + serializedUnion = serializedIndividual; + } + } + return serializedUnion; + } function serializeTypeReferenceNode(node) { switch (resolver.getTypeReferenceSerializationKind(node.typeName, currentScope)) { case ts.TypeReferenceSerializationKind.Unknown: @@ -39898,15 +42086,15 @@ var ts; function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { case 70: - var name_34 = ts.getMutableClone(node); - name_34.flags &= ~8; - name_34.original = undefined; - name_34.parent = currentScope; + var name = ts.getMutableClone(node); + name.flags &= ~8; + name.original = undefined; + name.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_34), ts.createLiteral("undefined")), name_34); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } - return name_34; - case 141: + return name; + case 142: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -39950,7 +42138,7 @@ var ts; hoistVariableDeclaration(generatedName); expression = ts.createAssignment(generatedName, expression); } - return ts.setOriginalNode(ts.createComputedPropertyName(expression, name), name); + return ts.updateComputedPropertyName(name, expression); } else { return name; @@ -39959,13 +42147,12 @@ var ts; function visitHeritageClause(node) { if (node.token === 84) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(84, types, node); + return ts.setTextRange(ts.createHeritageClause(84, types), node); } return undefined; } function visitExpressionWithTypeArguments(node) { - var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); - return ts.createExpressionWithTypeArguments(undefined, expression, node); + return ts.updateExpressionWithTypeArguments(node, undefined, ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); } function shouldEmitFunctionLikeDeclaration(node) { return !ts.nodeIsMissing(node.body); @@ -40039,8 +42226,9 @@ var ts; if (ts.parameterIsThisKeyword(node)) { return undefined; } - var parameter = ts.createParameter(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), ts.moveRangePastModifiers(node)); + var parameter = ts.createParameter(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); ts.setOriginalNode(parameter, node); + ts.setTextRange(parameter, ts.moveRangePastModifiers(node)); ts.setCommentRange(parameter, node); ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); ts.setEmitFlags(parameter.name, 32); @@ -40052,7 +42240,7 @@ var ts; if (variables.length === 0) { return undefined; } - return ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); + return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -40064,7 +42252,7 @@ var ts; return ts.flattenDestructuringAssignment(node, visitor, context, 0, false, createNamespaceExportExpression); } else { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), node); + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node); } } function visitVariableDeclaration(node) { @@ -40118,8 +42306,9 @@ var ts; var localName = ts.getLocalName(node, false, true); moduleArg = ts.createAssignment(localName, moduleArg); } - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg]), node); + var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg])); ts.setOriginalNode(enumStatement, node); + ts.setTextRange(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); statements.push(ts.createEndOfDeclarationMarker(node)); @@ -40133,11 +42322,11 @@ var ts; ts.addRange(statements, ts.map(node.members, transformEnumMember)); ts.addRange(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceLocalName; - return ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); + return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true); } function transformEnumMember(member) { var name = getExpressionForPropertyName(member, false); - return ts.createStatement(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name, member), member); + return ts.setTextRange(ts.createStatement(ts.setTextRange(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name), member)), member); } function transformEnumMemberDeclarationValue(member) { var value = resolver.getConstantValue(member); @@ -40169,16 +42358,16 @@ var ts; if (!currentScopeFirstDeclarationsOfName) { currentScopeFirstDeclarationsOfName = ts.createMap(); } - if (!(name in currentScopeFirstDeclarationsOfName)) { - currentScopeFirstDeclarationsOfName[name] = node; + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_35 = node.symbol && node.symbol.name; - if (name_35) { - return currentScopeFirstDeclarationsOfName[name_35] === node; + var name = node.symbol && node.symbol.name; + if (name) { + return currentScopeFirstDeclarationsOfName.get(name) === node; } } return false; @@ -40190,7 +42379,7 @@ var ts; ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 229) { + if (node.kind === 231) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -40231,8 +42420,9 @@ var ts; var localName = ts.getLocalName(node, false, true); moduleArg = ts.createAssignment(localName, moduleArg); } - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); + var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg])); ts.setOriginalNode(moduleStatement, node); + ts.setTextRange(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); statements.push(ts.createEndOfDeclarationMarker(node)); @@ -40250,8 +42440,8 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 231) { - ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); + if (body.kind === 233) { + saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; } @@ -40272,14 +42462,15 @@ var ts; currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 231) { + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true); + ts.setTextRange(block, blockLocation); + if (body.kind !== 233) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 230) { + if (moduleDeclaration.body.kind === 232) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -40299,7 +42490,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 237) { + if (node.kind === 239) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -40351,9 +42542,9 @@ var ts; var moduleReference = ts.createExpressionFromEntityName(node.moduleReference); ts.setEmitFlags(moduleReference, 1536 | 2048); if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { - return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ + return ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.setOriginalNode(ts.createVariableDeclaration(node.name, undefined, moduleReference), node) - ]), node), node); + ])), node), node); } else { return ts.setOriginalNode(createNamespaceExport(node.name, moduleReference, node), node); @@ -40374,7 +42565,7 @@ var ts; && ts.hasModifier(node, 512); } function expressionToStatement(expression) { - return ts.createStatement(expression, undefined); + return ts.createStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), ts.getLocalName(node)); @@ -40384,10 +42575,10 @@ var ts; statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue), location); + return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue, location); + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); } function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) { return ts.getNamespaceMemberName(currentNamespaceContainerName, name, false, true); @@ -40403,7 +42594,7 @@ var ts; function getClassAliasIfNeeded(node) { if (resolver.getNodeCheckFlags(node) & 8388608) { enableSubstitutionForClassAliases(); - var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); + var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.unescapeIdentifier(node.name.text) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; hoistVariableDeclaration(classAlias); return classAlias; @@ -40427,24 +42618,24 @@ var ts; if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; context.enableSubstitution(70); - classAliases = ts.createMap(); + classAliases = []; } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(70); - context.enableSubstitution(258); - context.enableEmitNotification(230); + context.enableSubstitution(261); + context.enableEmitNotification(232); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 230; + return ts.getOriginalNode(node).kind === 232; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 229; + return ts.getOriginalNode(node).kind === 231; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2; @@ -40452,12 +42643,12 @@ var ts; if (enabledSubstitutions & 8 && isTransformedEnumDeclaration(node)) { applicableSubstitutions |= 8; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -40467,14 +42658,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_36 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_36); + var name = node.name; + var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_36, initializer, node); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); } - return ts.createPropertyAssignment(name_36, exportedName, node); + return ts.setTextRange(ts.createPropertyAssignment(name, exportedName), node); } } return node; @@ -40483,9 +42674,9 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 177: - return substitutePropertyAccessExpression(node); case 178: + return substitutePropertyAccessExpression(node); + case 179: return substituteElementAccessExpression(node); } return node; @@ -40515,11 +42706,11 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 261) { - var substitute = (applicableSubstitutions & 2 && container.kind === 230) || - (applicableSubstitutions & 8 && container.kind === 229); + if (container && container.kind !== 264) { + var substitute = (applicableSubstitutions & 2 && container.kind === 232) || + (applicableSubstitutions & 8 && container.kind === 231); if (substitute) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node); } } } @@ -40566,10 +42757,10 @@ var ts; }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(paramHelper); - return ts.createCall(ts.getHelperName("__param"), undefined, [ + return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), undefined, [ ts.createLiteral(parameterOffset), expression - ], location); + ]), location); } var metadataHelper = { name: "typescript:metadata", @@ -40593,7 +42784,7 @@ var ts; function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) { context.requestEmitHelper(decorateHelper); var argumentsArray = []; - argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, undefined, true)); + argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, true)); argumentsArray.push(target); if (memberName) { argumentsArray.push(memberName); @@ -40601,7 +42792,7 @@ var ts; argumentsArray.push(descriptor); } } - return ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray, location); + return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray), location); } })(ts || (ts = {})); var ts; @@ -40628,37 +42819,37 @@ var ts; return node; } switch (node.kind) { - case 176: + case 177: return visitObjectLiteralExpression(node); - case 192: + case 193: return visitBinaryExpression(node, noDestructuringValue); - case 223: - return visitVariableDeclaration(node); - case 213: - return visitForOfStatement(node); - case 211: - return visitForStatement(node); - case 188: - return visitVoidExpression(node); - case 150: - return visitConstructorDeclaration(node); - case 149: - return visitMethodDeclaration(node); - case 151: - return visitGetAccessorDeclaration(node); - case 152: - return visitSetAccessorDeclaration(node); case 225: + return visitVariableDeclaration(node); + case 215: + return visitForOfStatement(node); + case 213: + return visitForStatement(node); + case 189: + return visitVoidExpression(node); + case 151: + return visitConstructorDeclaration(node); + case 150: + return visitMethodDeclaration(node); + case 152: + return visitGetAccessorDeclaration(node); + case 153: + return visitSetAccessorDeclaration(node); + case 227: return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); case 185: + return visitFunctionExpression(node); + case 186: return visitArrowFunction(node); - case 144: + case 145: return visitParameter(node); - case 207: + case 209: return visitExpressionStatement(node); - case 183: + case 184: return visitParenthesizedExpression(node, noDestructuringValue); default: return ts.visitEachChild(node, visitor, context); @@ -40667,9 +42858,9 @@ var ts; function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; - for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { - var e = elements_3[_i]; - if (e.kind === 259) { + for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { + var e = elements_4[_i]; + if (e.kind === 262) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -40681,7 +42872,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 257) { + if (e.kind === 260) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -40698,7 +42889,7 @@ var ts; function visitObjectLiteralExpression(node) { if (node.transformFlags & 1048576) { var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 176) { + if (objects.length && objects[0].kind !== 177) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -40742,25 +42933,26 @@ var ts; var firstDeclaration = ts.firstOrUndefined(initializer.declarations); var declarations = ts.flattenDestructuringBinding(firstDeclaration, visitor, context, 1, temp, false, true); if (ts.some(declarations)) { - var statement = ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(initializer, declarations), initializer); + var statement = ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(initializer, declarations)); + ts.setTextRange(statement, initializer); leadingStatements = ts.append(leadingStatements, statement); } } else if (ts.isAssignmentPattern(initializer)) { temp = ts.createTempVariable(undefined); - var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.createAssignment(initializer, temp, node.initializer)), visitor, context, 1); - leadingStatements = ts.append(leadingStatements, ts.createStatement(expression, node.initializer)); + var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.setTextRange(ts.createAssignment(initializer, temp), node.initializer)), visitor, context, 1); + leadingStatements = ts.append(leadingStatements, ts.setTextRange(ts.createStatement(expression), node.initializer)); } } if (temp) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var statement = ts.visitNode(node.statement, visitor, ts.isStatement); var block = ts.isBlock(statement) - ? ts.updateBlock(statement, ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements), statement.statements)) - : ts.createBlock(ts.append(leadingStatements, statement), statement, true); - return ts.updateForOf(node, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, undefined, undefined, node.initializer) - ], node.initializer, 1), expression, block); + ? ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements)), statement.statements)) + : ts.setTextRange(ts.createBlock(ts.append(leadingStatements, statement), true), statement); + return ts.updateForOf(node, ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer) + ], 1), node.initializer), expression, block); } return ts.visitEachChild(node, visitor, context); } @@ -40810,7 +43002,7 @@ var ts; var trailingStatements = endLexicalEnvironment(); if (ts.some(leadingStatements) || ts.some(trailingStatements)) { var block = ts.convertToFunctionBody(body, true); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements)), block.statements)); } return body; } @@ -40823,6 +43015,9 @@ var ts; text: "\n var __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };" }; function createAssignHelper(context, attributesSegments) { + if (context.getCompilerOptions().target >= 2) { + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), undefined, attributesSegments); + } context.requestEmitHelper(assignHelper); return ts.createCall(ts.getHelperName("__assign"), undefined, attributesSegments); } @@ -40854,11 +43049,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 246: + case 248: return visitJsxElement(node, false); - case 247: + case 249: return visitJsxSelfClosingElement(node, false); - case 252: + case 255: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -40868,11 +43063,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 252: + case 255: return visitJsxExpression(node); - case 246: + case 248: return visitJsxElement(node, true); - case 247: + case 249: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -40888,7 +43083,7 @@ var ts; function visitJsxOpeningLikeElement(node, children, isChild, location) { var tagName = getTagName(node); var objectProperties; - var attrs = node.attributes; + var attrs = node.attributes.properties; if (attrs.length === 0) { objectProperties = ts.createNull(); } @@ -40920,13 +43115,16 @@ var ts; } function transformJsxAttributeInitializer(node) { if (node === undefined) { - return ts.createLiteral(true); + return ts.createTrue(); } else if (node.kind === 9) { var decoded = tryDecodeEntities(node.text); - return decoded ? ts.createLiteral(decoded, node) : node; + return decoded ? ts.setTextRange(ts.createLiteral(decoded), node) : node; } - else if (node.kind === 252) { + else if (node.kind === 255) { + if (node.expression === undefined) { + return ts.createTrue(); + } return visitJsxExpression(node); } else { @@ -40934,43 +43132,35 @@ var ts; } } function visitJsxText(node) { - var text = ts.getTextOfNode(node, true); - var parts; + var fixed = fixupWhitespaceAndDecodeEntities(ts.getTextOfNode(node, true)); + return fixed === undefined ? undefined : ts.createLiteral(fixed); + } + function fixupWhitespaceAndDecodeEntities(text) { + var acc; 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); - if (!parts) { - parts = []; - } - parts.push(ts.createLiteral(decodeEntities(part))); + if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) { + acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1)); } firstNonWhitespace = -1; } - else if (!ts.isWhiteSpace(c)) { + else if (!ts.isWhiteSpaceSingleLine(c)) { lastNonWhitespace = i; if (firstNonWhitespace === -1) { firstNonWhitespace = i; } } } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - if (!parts) { - parts = []; - } - parts.push(ts.createLiteral(decodeEntities(part))); - } - if (parts) { - return ts.reduceLeft(parts, aggregateJsxTextParts); - } - return undefined; + return firstNonWhitespace !== -1 + ? addLineOfJsxText(acc, text.substr(firstNonWhitespace)) + : acc; } - function aggregateJsxTextParts(left, right) { - return ts.createAdd(ts.createAdd(left, ts.createLiteral(" ")), right); + function addLineOfJsxText(acc, trimmedLine) { + var decoded = decodeEntities(trimmedLine); + return acc === undefined ? decoded : acc + " " + decoded; } function decodeEntities(text) { return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) { @@ -40981,7 +43171,7 @@ var ts; return String.fromCharCode(parseInt(hex, 16)); } else { - var ch = entities[word]; + var ch = entities.get(word); return ch ? String.fromCharCode(ch) : match; } }); @@ -40991,16 +43181,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 246) { + if (node.kind === 248) { return getTagName(node.openingElement); } else { - var name_37 = node.tagName; - if (ts.isIdentifier(name_37) && ts.isIntrinsicJsxName(name_37.text)) { - return ts.createLiteral(name_37.text); + var name = node.tagName; + if (ts.isIdentifier(name) && ts.isIntrinsicJsxName(name.text)) { + return ts.createLiteral(name.text); } else { - return ts.createExpressionFromEntityName(name_37); + return ts.createExpressionFromEntityName(name); } } } @@ -41018,7 +43208,7 @@ var ts; } } ts.transformJsx = transformJsx; - var entities = ts.createMap({ + var entities = ts.createMapFromTemplate({ "quot": 0x0022, "amp": 0x0026, "apos": 0x0027, @@ -41276,6 +43466,10 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); function transformES2017(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var resolver = context.getEmitResolver(); @@ -41306,22 +43500,22 @@ var ts; switch (node.kind) { case 119: return undefined; - case 189: + case 190: return visitAwaitExpression(node); - case 149: + case 150: return visitMethodDeclaration(node); - case 225: + case 227: return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); case 185: + return visitFunctionExpression(node); + case 186: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); } } function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); } function visitMethodDeclaration(node) { return ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) @@ -41351,14 +43545,15 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 185; + var isArrowFunction = node.kind === 186; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(statements, node.body, true); + var block = ts.createBlock(statements, true); + ts.setTextRange(block, node.body); if (languageVersion >= 2) { if (resolver.getNodeCheckFlags(node) & 4096) { enableSubstitutionForAsyncMethodsWithSuper(); @@ -41376,7 +43571,7 @@ var ts; var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(block.statements, declarations), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); } return expression; } @@ -41389,7 +43584,7 @@ var ts; startLexicalEnvironment(); var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); var declarations = endLexicalEnvironment(); - return ts.updateBlock(visited, ts.createNodeArray(ts.concatenate(visited.statements, declarations), visited.statements)); + return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); } } function getPromiseConstructor(type) { @@ -41406,23 +43601,23 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(179); - context.enableSubstitution(177); + context.enableSubstitution(180); context.enableSubstitution(178); - context.enableEmitNotification(226); - context.enableEmitNotification(149); - context.enableEmitNotification(151); - context.enableEmitNotification(152); + context.enableSubstitution(179); + context.enableEmitNotification(228); context.enableEmitNotification(150); + context.enableEmitNotification(152); + context.enableEmitNotification(153); + context.enableEmitNotification(151); } } function substituteExpression(node) { switch (node.kind) { - case 177: - return substitutePropertyAccessExpression(node); case 178: - return substituteElementAccessExpression(node); + return substitutePropertyAccessExpression(node); case 179: + return substituteElementAccessExpression(node); + case 180: if (enabledSubstitutions & 1) { return substituteCallExpression(node); } @@ -41465,36 +43660,36 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 226 - || kind === 150 - || kind === 149 + return kind === 228 || kind === 151 - || kind === 152; + || kind === 150 + || kind === 152 + || kind === 153; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { if (enabledSubstitutions & 1 && isSuperContainer(node)) { var savedCurrentSuperContainer = currentSuperContainer; currentSuperContainer = node; - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSuperContainer = savedCurrentSuperContainer; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } return node; } function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { if (flags & 4096) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value"), location); } else { - return ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression], location); + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), location); } } function getSuperContainerAsyncMethodFlags() { @@ -41547,7 +43742,7 @@ var ts; return node; } switch (node.kind) { - case 192: + case 193: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -41571,19 +43766,19 @@ var ts; if (ts.isElementAccessExpression(left)) { var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createElementAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), ts.createAssignment(argumentExpressionTemp, left.argumentExpression, left.argumentExpression), left); - value = ts.createElementAccess(expressionTemp, argumentExpressionTemp, left); + target = ts.setTextRange(ts.createElementAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), ts.setTextRange(ts.createAssignment(argumentExpressionTemp, left.argumentExpression), left.argumentExpression)), left); + value = ts.setTextRange(ts.createElementAccess(expressionTemp, argumentExpressionTemp), left); } else if (ts.isPropertyAccessExpression(left)) { var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createPropertyAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), left.name, left); - value = ts.createPropertyAccess(expressionTemp, left.name, left); + target = ts.setTextRange(ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), left.name), left); + value = ts.setTextRange(ts.createPropertyAccess(expressionTemp, left.name), left); } else { target = left; value = left; } - return ts.createAssignment(target, ts.createMathPow(value, right, node), node); + return ts.setTextRange(ts.createAssignment(target, ts.createMathPow(value, right, node)), node); } function visitExponentiationExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); @@ -41595,6 +43790,75 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var ES2015SubstitutionFlags; + (function (ES2015SubstitutionFlags) { + ES2015SubstitutionFlags[ES2015SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; + ES2015SubstitutionFlags[ES2015SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; + })(ES2015SubstitutionFlags || (ES2015SubstitutionFlags = {})); + var CopyDirection; + (function (CopyDirection) { + CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; + CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; + })(CopyDirection || (CopyDirection = {})); + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); + var SuperCaptureResult; + (function (SuperCaptureResult) { + SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; + SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; + SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; + })(SuperCaptureResult || (SuperCaptureResult = {})); + var HierarchyFacts; + (function (HierarchyFacts) { + HierarchyFacts[HierarchyFacts["None"] = 0] = "None"; + HierarchyFacts[HierarchyFacts["Function"] = 1] = "Function"; + HierarchyFacts[HierarchyFacts["ArrowFunction"] = 2] = "ArrowFunction"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBody"] = 4] = "AsyncFunctionBody"; + HierarchyFacts[HierarchyFacts["NonStaticClassElement"] = 8] = "NonStaticClassElement"; + HierarchyFacts[HierarchyFacts["CapturesThis"] = 16] = "CapturesThis"; + HierarchyFacts[HierarchyFacts["ExportedVariableStatement"] = 32] = "ExportedVariableStatement"; + HierarchyFacts[HierarchyFacts["TopLevel"] = 64] = "TopLevel"; + HierarchyFacts[HierarchyFacts["Block"] = 128] = "Block"; + HierarchyFacts[HierarchyFacts["IterationStatement"] = 256] = "IterationStatement"; + HierarchyFacts[HierarchyFacts["IterationStatementBlock"] = 512] = "IterationStatementBlock"; + HierarchyFacts[HierarchyFacts["ForStatement"] = 1024] = "ForStatement"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 2048] = "ForInOrForOfStatement"; + HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 4096] = "ConstructorWithCapturedSuper"; + HierarchyFacts[HierarchyFacts["ComputedPropertyName"] = 8192] = "ComputedPropertyName"; + HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 16383] = "AncestorFactsMask"; + HierarchyFacts[HierarchyFacts["BlockScopeIncludes"] = 0] = "BlockScopeIncludes"; + HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 4032] = "BlockScopeExcludes"; + HierarchyFacts[HierarchyFacts["SourceFileIncludes"] = 64] = "SourceFileIncludes"; + HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 3968] = "SourceFileExcludes"; + HierarchyFacts[HierarchyFacts["FunctionIncludes"] = 65] = "FunctionIncludes"; + HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 16286] = "FunctionExcludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyIncludes"] = 69] = "AsyncFunctionBodyIncludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 16278] = "AsyncFunctionBodyExcludes"; + HierarchyFacts[HierarchyFacts["ArrowFunctionIncludes"] = 66] = "ArrowFunctionIncludes"; + HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 16256] = "ArrowFunctionExcludes"; + HierarchyFacts[HierarchyFacts["ConstructorIncludes"] = 73] = "ConstructorIncludes"; + HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 16278] = "ConstructorExcludes"; + HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 256] = "DoOrWhileStatementIncludes"; + HierarchyFacts[HierarchyFacts["DoOrWhileStatementExcludes"] = 0] = "DoOrWhileStatementExcludes"; + HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 1280] = "ForStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 3008] = "ForStatementExcludes"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 2304] = "ForInOrForOfStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 1984] = "ForInOrForOfStatementExcludes"; + HierarchyFacts[HierarchyFacts["BlockIncludes"] = 128] = "BlockIncludes"; + HierarchyFacts[HierarchyFacts["BlockExcludes"] = 3904] = "BlockExcludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockIncludes"] = 512] = "IterationStatementBlockIncludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 4032] = "IterationStatementBlockExcludes"; + HierarchyFacts[HierarchyFacts["ComputedPropertyNameIncludes"] = 8192] = "ComputedPropertyNameIncludes"; + HierarchyFacts[HierarchyFacts["ComputedPropertyNameExcludes"] = 0] = "ComputedPropertyNameExcludes"; + HierarchyFacts[HierarchyFacts["NewTarget"] = 16384] = "NewTarget"; + HierarchyFacts[HierarchyFacts["NewTargetInComputedPropertyName"] = 32768] = "NewTargetInComputedPropertyName"; + HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -16384] = "SubtreeFactsMask"; + HierarchyFacts[HierarchyFacts["PropagateNewTargetMask"] = 49152] = "PropagateNewTargetMask"; + })(HierarchyFacts || (HierarchyFacts = {})); function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -41604,15 +43868,7 @@ var ts; context.onSubstituteNode = onSubstituteNode; var currentSourceFile; var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - var isInConstructorWithCapturedSuper; + var hierarchyFacts; var convertedLoopState; var enabledSubstitutions; return transformSourceFile; @@ -41622,247 +43878,202 @@ var ts; } currentSourceFile = node; currentText = node.text; - var visited = saveStateAndInvoke(node, visitSourceFile); + var visited = visitSourceFile(node); ts.addEmitHelpers(visited, context.readEmitHelpers()); currentSourceFile = undefined; currentText = undefined; + hierarchyFacts = 0; return visited; } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); + function enterSubtree(excludeFacts, includeFacts) { + var ancestorFacts = hierarchyFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383; + return ancestorFacts; } - function dispatcher(node) { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - function saveStateAndInvoke(node, f) { - var savedEnclosingFunction = enclosingFunction; - var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - var savedEnclosingVariableStatement = enclosingVariableStatement; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var savedConvertedLoopState = convertedLoopState; - var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - isInConstructorWithCapturedSuper = false; - convertedLoopState = undefined; - } - onBeforeVisitNode(node); - var visited = f(node); - isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 185) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 131072)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - switch (currentNode.kind) { - case 205: - enclosingVariableStatement = currentNode; - break; - case 224: - case 223: - case 174: - case 172: - case 173: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - function returnCapturedThis(node) { - return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 216 && !node.expression; + return hierarchyFacts & 4096 + && node.kind === 218 + && !node.expression; } - function shouldCheckNode(node) { - return (node.transformFlags & 64) !== 0 || - node.kind === 219 || - (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); + function shouldVisitNode(node) { + return (node.transformFlags & 128) !== 0 + || convertedLoopState !== undefined + || (hierarchyFacts & 4096 && ts.isStatement(node)) + || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } - function visitorWorker(node) { - if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { - return returnCapturedThis(node); - } - else if (shouldCheckNode(node)) { + function visitor(node) { + if (shouldVisitNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { - return ts.visitEachChild(node, visitor, context); - } else { return node; } } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); + function functionBodyVisitor(node) { + if (shouldVisitNode(node)) { + return visitBlock(node, true); } - else { - result = visitNodesInConvertedLoop(node); - } - return result; + return node; } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 216: - node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; - return visitReturnStatement(node); - case 205: - return visitVariableStatement(node); - case 218: - return visitSwitchStatement(node); - case 215: - case 214: - return visitBreakOrContinueStatement(node); - case 98: - return visitThisKeyword(node); - case 70: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); + function callExpressionVisitor(node) { + if (node.kind === 96) { + return visitSuperKeyword(true); } + return visitor(node); } function visitJavaScript(node) { switch (node.kind) { case 114: return undefined; - case 226: + case 228: return visitClassDeclaration(node); - case 197: + case 198: return visitClassExpression(node); - case 144: + case 145: return visitParameter(node); - case 225: + case 227: return visitFunctionDeclaration(node); - case 185: + case 186: return visitArrowFunction(node); - case 184: + case 185: return visitFunctionExpression(node); - case 223: + case 225: return visitVariableDeclaration(node); case 70: return visitIdentifier(node); - case 224: + case 226: return visitVariableDeclarationList(node); - case 219: + case 220: + return visitSwitchStatement(node); + case 234: + return visitCaseBlock(node); + case 206: + return visitBlock(node, false); + case 217: + case 216: + return visitBreakOrContinueStatement(node); + case 221: return visitLabeledStatement(node); - case 209: - return visitDoStatement(node); - case 210: - return visitWhileStatement(node); case 211: - return visitForStatement(node); case 212: - return visitForInStatement(node); + return visitDoOrWhileStatement(node, undefined); case 213: - return visitForOfStatement(node); - case 207: + return visitForStatement(node, undefined); + case 214: + return visitForInStatement(node, undefined); + case 215: + return visitForOfStatement(node, undefined); + case 209: return visitExpressionStatement(node); - case 176: + case 177: return visitObjectLiteralExpression(node); - case 256: + case 259: return visitCatchClause(node); - case 258: + case 261: return visitShorthandPropertyAssignment(node); - case 175: + case 143: + return visitComputedPropertyName(node); + case 176: return visitArrayLiteralExpression(node); - case 179: - return visitCallExpression(node); case 180: + return visitCallExpression(node); + case 181: return visitNewExpression(node); - case 183: + case 184: return visitParenthesizedExpression(node, true); - case 192: + case 193: return visitBinaryExpression(node, true); case 12: case 13: case 14: case 15: return visitTemplateLiteral(node); - case 181: + case 182: return visitTaggedTemplateExpression(node); - case 194: - return visitTemplateExpression(node); case 195: - return visitYieldExpression(node); + return visitTemplateExpression(node); case 196: + return visitYieldExpression(node); + case 197: return visitSpreadElement(node); case 96: - return visitSuperKeyword(); - case 195: - return ts.visitEachChild(node, visitor, context); - case 149: + return visitSuperKeyword(false); + case 98: + return visitThisKeyword(node); + case 203: + return visitMetaProperty(node); + case 150: return visitMethodDeclaration(node); - case 205: + case 152: + case 153: + return visitAccessorDeclaration(node); + case 207: return visitVariableStatement(node); + case 218: + return visitReturnStatement(node); default: - ts.Debug.failBadSyntaxKind(node); return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { + var ancestorFacts = enterSubtree(3968, 64); var statements = []; startLexicalEnvironment(); var statementOffset = ts.addPrologueDirectives(statements, node.statements, false, visitor); addCaptureThisForNodeIfNeeded(statements, node); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + exitSubtree(ancestorFacts, 0, 0); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } function visitSwitchStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps |= 2; - var result = ts.visitEachChild(node, visitor, context); - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; + if (convertedLoopState !== undefined) { + var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps |= 2; + var result = ts.visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + return ts.visitEachChild(node, visitor, context); + } + function visitCaseBlock(node) { + var ancestorFacts = enterSubtree(4032, 0); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0, 0); + return updated; + } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function visitReturnStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - convertedLoopState.nonLocalJumps |= 8; - return ts.createReturn(ts.createObjectLiteral([ - ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression - ? ts.visitNode(node.expression, visitor, ts.isExpression) - : ts.createVoidZero()) - ])); + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8; + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + node = returnCapturedThis(node); + } + return ts.createReturn(ts.createObjectLiteral([ + ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression + ? ts.visitNode(node.expression, visitor, ts.isExpression) + : ts.createVoidZero()) + ])); + } + else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 185) { - convertedLoopState.containsLexicalThis = true; - return node; + if (convertedLoopState) { + if (hierarchyFacts & 2) { + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + return node; } function visitIdentifier(node) { if (!convertedLoopState) { @@ -41871,20 +44082,20 @@ var ts; if (ts.isGeneratedIdentifier(node)) { return node; } - if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + if (node.text !== "arguments" || !resolver.isArgumentsLocalBinding(node)) { return node; } return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 215 ? 2 : 4; - var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + var jump = node.kind === 217 ? 2 : 4; + var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(node.label.text)) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 215) { + if (node.kind === 217) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -41894,7 +44105,7 @@ var ts; } } else { - if (node.kind === 215) { + if (node.kind === 217) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -41927,8 +44138,9 @@ var ts; var variable = ts.createVariableDeclaration(ts.getLocalName(node, true), undefined, transformClassLikeDeclarationToExpression(node)); ts.setOriginalNode(variable, node); var statements = []; - var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable]), node); + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable])); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, node); ts.startOnNewLine(statement); statements.push(statement); if (ts.hasModifier(node, 1)) { @@ -41983,23 +44195,29 @@ var ts; ts.setEmitFlags(statement, 1536 | 384); statements.push(statement); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true); ts.setEmitFlags(block, 1536); return block; } function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node)), extendsClauseElement)); + statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node))), extendsClauseElement)); } } function addConstructor(statements, node, extendsClauseElement) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16278, 73); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); + var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); + ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { ts.setEmitFlags(constructorFunction, 8); } statements.push(constructorFunction); + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; } function transformConstructorParameters(constructor, hasSynthesizedSuper) { return ts.visitParameterList(constructor && !hasSynthesizedSuper && constructor.parameters, visitor, context) @@ -42020,41 +44238,45 @@ var ts; addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94; + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); if (superCaptureStatus === 1 || superCaptureStatus === 2) { statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { - isInConstructorWithCapturedSuper = superCaptureStatus === 1; - return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); - }); - ts.addRange(statements, body); + if (superCaptureStatus === 1) { + hierarchyFacts |= 4096; + } + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset)); } - if (extendsClauseElement + if (isDerivedClass && superCaptureStatus !== 2 && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createIdentifier("_this"))); } ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); + if (constructor) { + prependCaptureNewTargetIfNeeded(statements, constructor, false); + } + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true); + ts.setTextRange(block, constructor ? constructor.body : node); if (!constructor) { ts.setEmitFlags(block, 1536); } return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 216) { + if (statement.kind === 218) { return true; } - else if (statement.kind === 208) { + else if (statement.kind === 210) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 204) { + else if (statement.kind === 206) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -42062,8 +44284,8 @@ var ts; } return false; } - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { - if (!hasExtendsClause) { + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, isDerivedClass, hasSynthesizedSuper, statementOffset) { + if (!isDerivedClass) { if (ctor) { addCaptureThisForNodeIfNeeded(statements, ctor); } @@ -42083,44 +44305,43 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 207 && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + if (firstStatement.kind === 209 && ts.isSuperCall(firstStatement.expression)) { + superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } if (superCallExpression && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 | 32768))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 192 - || superCallExpression.left.kind !== 179) { + if (superCallExpression.kind !== 193 + || superCallExpression.left.kind !== 180) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } ts.setCommentRange(returnStatement, ts.getCommentRange(ts.setEmitFlags(superCallExpression.left, 1536))); statements.push(returnStatement); return 2; } - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement); if (superCallExpression) { return 1; } return 0; } + function createActualThis() { + return ts.setEmitFlags(ts.createThis(), 4); + } function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 4); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); + return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createIdentifier("_super"), ts.createNull()), ts.createFunctionApply(ts.createIdentifier("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis()); } function visitParameter(node) { if (node.dotDotDotToken) { return undefined; } else if (ts.isBindingPattern(node.name)) { - return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined, node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined), node), node); } else if (node.initializer) { - return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined, node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined), node), node); } else { return node; @@ -42135,15 +44356,15 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_38 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_38)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_38, initializer); + if (ts.isBindingPattern(name)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_38, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer); } } } @@ -42158,10 +44379,11 @@ var ts; } function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer)), parameter)) - ], parameter), 1 | 32 | 384), undefined, parameter); + var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([ + ts.createStatement(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer))), parameter)) + ]), parameter), 1 | 32 | 384)); statement.startsOnNewLine = true; + ts.setTextRange(statement, parameter); ts.setEmitFlags(statement, 384 | 32 | 524288); statements.push(statement); } @@ -42178,22 +44400,22 @@ var ts; var expressionName = ts.getSynthesizedClone(parameter.name); var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) - ]), parameter), 524288)); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ])), parameter), 524288)); + var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) - ], parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), parameter), ts.createPostfixIncrement(temp, parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 + ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([ + ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp - : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), parameter)) + : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), parameter)) ])); ts.setEmitFlags(forStatement, 524288); ts.startOnNewLine(forStatement); statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 && node.kind !== 185) { + if (node.transformFlags & 32768 && node.kind !== 186) { captureThisForNode(statements, node, ts.createThis()); } } @@ -42201,29 +44423,62 @@ var ts; enableSubstitutionsForCapturedThis(); var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration("_this", undefined, initializer) - ]), originalStatement); + ])); ts.setEmitFlags(captureThisStatement, 1536 | 524288); + ts.setTextRange(captureThisStatement, originalStatement); ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } + function prependCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { + if (hierarchyFacts & 16384) { + var newTarget = void 0; + switch (node.kind) { + case 186: + return statements; + case 150: + case 152: + case 153: + newTarget = ts.createVoidZero(); + break; + case 151: + newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); + break; + case 227: + case 185: + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 92, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + var captureNewTargetStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_newTarget", undefined, newTarget) + ])); + if (copyOnWrite) { + return [captureNewTargetStatement].concat(statements); + } + statements.unshift(captureNewTargetStatement); + } + return statements; + } function addClassMembers(statements, node) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 203: + case 205: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 149: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + case 150: + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 151: case 152: + case 153: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 150: + case 151: break; default: ts.Debug.failBadSyntaxKind(node); @@ -42232,28 +44487,32 @@ var ts; } } function transformSemicolonClassElementToStatement(member) { - return ts.createEmptyStatement(member); + return ts.setTextRange(ts.createEmptyStatement(), member); } - function transformClassMethodDeclarationToStatement(receiver, member) { + function transformClassMethodDeclarationToStatement(receiver, member, container) { + var ancestorFacts = enterSubtree(0, 0); var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name); - var memberFunction = transformFunctionLikeToExpression(member, member, undefined); + var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container); ts.setEmitFlags(memberFunction, 1536); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), member); + var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); ts.setEmitFlags(statement, 48); + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return statement; } - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), ts.getSourceMapRange(accessors.firstAccessor)); + function transformAccessorsToStatement(receiver, accessors, container) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, false)); ts.setEmitFlags(statement, 1536); + ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + var ancestorFacts = enterSubtree(0, 0); var target = ts.getMutableClone(receiver); ts.setEmitFlags(target, 1536 | 32); ts.setSourceMapRange(target, firstAccessor.name); @@ -42262,7 +44521,7 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); + var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); ts.setEmitFlags(getterFunction, 512); var getter = ts.createPropertyAssignment("get", getterFunction); @@ -42270,51 +44529,86 @@ var ts; properties.push(getter); } if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); + var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); ts.setEmitFlags(setterFunction, 512); var setter = ts.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } - properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); + properties.push(ts.createPropertyAssignment("enumerable", ts.createTrue()), ts.createPropertyAssignment("configurable", ts.createTrue())); var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ target, propertyName, - ts.createObjectLiteral(properties, undefined, true) + ts.createObjectLiteral(properties, true) ]); if (startsOnNewLine) { call.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return call; } function visitArrowFunction(node) { if (node.transformFlags & 16384) { enableSubstitutionsForCapturedThis(); } - var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node), node); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16256, 66); + var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + ts.setTextRange(func, node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8); + exitSubtree(ancestorFacts, 0, 0); + convertedLoopState = savedConvertedLoopState; return func; } function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + var ancestorFacts = ts.getEmitFlags(node) & 131072 + ? enterSubtree(16278, 69) + : enterSubtree(16286, 65); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionExpression(node, undefined, name, undefined, parameters, undefined, body); } function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286, 65); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, undefined, parameters, undefined, body); } - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 185) { - enclosingNonArrowFunction = node; + function transformFunctionLikeToExpression(node, location, name, container) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32) + ? enterSubtree(16286, 65 | 8) + : enterSubtree(16286, 65); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (hierarchyFacts & 16384 && !name && (node.kind === 227 || node.kind === 185)) { + name = ts.getGeneratedNameForNode(node); } - var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body), location), node); } function transformFunctionBody(node) { var multiLine = false; @@ -42342,7 +44636,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 185); + ts.Debug.assert(node.kind === 186); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -42354,17 +44648,20 @@ var ts; } } var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, body); + var returnStatement = ts.createReturn(expression); + ts.setTextRange(returnStatement, body); ts.setEmitFlags(returnStatement, 384 | 32 | 1024); statements.push(returnStatement); closeBraceLocation = body; } var lexicalEnvironment = context.endLexicalEnvironment(); ts.addRange(statements, lexicalEnvironment); + prependCaptureNewTargetIfNeeded(statements, node, false); if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), multiLine); + ts.setTextRange(block, node.body); if (!multiLine && singleLine) { ts.setEmitFlags(block, 1); } @@ -42374,11 +44671,26 @@ var ts; ts.setOriginalNode(block, node.body); return block; } + function visitFunctionBodyDownLevel(node) { + var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); + return ts.updateBlock(updated, ts.setTextRange(ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, true)), updated.statements)); + } + function visitBlock(node, isFunctionBody) { + if (isFunctionBody) { + return ts.visitEachChild(node, visitor, context); + } + var ancestorFacts = hierarchyFacts & 256 + ? enterSubtree(4032, 512) + : enterSubtree(3904, 128); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0, 0); + return updated; + } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 183: + case 184: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 192: + case 193: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -42386,9 +44698,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (!needsDestructuringValue) { switch (node.expression.kind) { - case 183: + case 184: return ts.updateParen(node, visitParenthesizedExpression(node.expression, false)); - case 192: + case 193: return ts.updateParen(node, visitBinaryExpression(node.expression, false)); } } @@ -42398,9 +44710,12 @@ var ts; if (ts.isDestructuringAssignment(node)) { return ts.flattenDestructuringAssignment(node, visitor, context, 0, needsDestructuringValue); } + return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3) == 0) { + var ancestorFacts = enterSubtree(0, ts.hasModifier(node, 1) ? 32 : 0); + var updated; + if (convertedLoopState && (node.declarationList.flags & 3) === 0) { var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; @@ -42417,49 +44732,55 @@ var ts; } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); + updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); })), node); } else { - return undefined; + updated = undefined; } } - return ts.visitEachChild(node, visitor, context); + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0, 0); + return updated; } function visitVariableDeclarationList(node) { - if (node.flags & 3) { - enableSubstitutionsForBlockScopedBindings(); + if (node.transformFlags & 64) { + if (node.flags & 3) { + enableSubstitutionsForBlockScopedBindings(); + } + var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + var declarationList = ts.createVariableDeclarationList(declarations); + ts.setOriginalNode(declarationList, node); + ts.setTextRange(declarationList, node); + ts.setCommentRange(declarationList, node); + if (node.transformFlags & 8388608 + && (ts.isBindingPattern(node.declarations[0].name) + || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + var firstDeclaration = ts.firstOrUndefined(declarations); + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } + return declarationList; } - var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, node); - ts.setOriginalNode(declarationList, node); - ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { - var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - } - return declarationList; + return ts.visitEachChild(node, visitor, context); } function shouldEmitExplicitInitializerForLetDeclaration(node) { var flags = resolver.getNodeCheckFlags(node); var isCapturedInFunction = flags & 131072; var isDeclaredInLoop = flags & 262144; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + var emittedAsTopLevel = (hierarchyFacts & 64) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); + && (hierarchyFacts & 512) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 212 - && enclosingBlockScopeContainer.kind !== 213 + && (hierarchyFacts & 2048) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, false))); + && (hierarchyFacts & (1024 | 2048)) === 0)); return emitExplicitInitializer; } function visitVariableDeclarationInLetDeclarationList(node) { @@ -42475,54 +44796,57 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableDeclaration(node) { + var ancestorFacts = enterSubtree(32, 0); + var updated; if (ts.isBindingPattern(node.name)) { - var hoistTempVariables = enclosingVariableStatement - && ts.hasModifier(enclosingVariableStatement, 1); - return ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, hoistTempVariables); - } - return ts.visitEachChild(node, visitor, context); - } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; - } - var result; - if (ts.isIterationStatement(node.statement, false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, (ancestorFacts & 32) !== 0); } else { - result = ts.visitEachChild(node, visitor, context); + updated = ts.visitEachChild(node, visitor, context); } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + exitSubtree(ancestorFacts, 0, 0); + return updated; + } + function recordLabel(node) { + convertedLoopState.labels.set(node.label.text, node.label.text); + } + function resetLabel(node) { + convertedLoopState.labels.set(node.label.text, undefined); + } + function visitLabeledStatement(node) { + if (convertedLoopState && !convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); } - return result; + var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, false) && shouldConvertIterationStatementBody(statement) + ? visitIterationStatement(statement, node) + : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { + var ancestorFacts = enterSubtree(excludeFacts, includeFacts); + var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); + exitSubtree(ancestorFacts, 0, 0); + return updated; } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitDoOrWhileStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(0, 256, node, outermostLabeledStatement); } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(3008, 1280, node, outermostLabeledStatement); } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForInStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement); } - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function visitForOfStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement, convertForOfToFor); } - function convertForOfToFor(node, convertedLoopBodyStatements) { + function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var initializer = node.initializer; var statements = []; var counter = ts.createLoopVariable(); var rhsReference = expression.kind === 70 - ? ts.createUniqueName(expression.text) + ? ts.createUniqueName(ts.unescapeIdentifier(expression.text)) : ts.createTempVariable(undefined); var elementAccess = ts.createElementAccess(rhsReference, counter); if (ts.isVariableDeclarationList(initializer)) { @@ -42532,17 +44856,18 @@ var ts; var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, elementAccess); - var declarationList = ts.createVariableDeclarationList(declarations, initializer); + var declarationList = ts.createVariableDeclarationList(declarations); ts.setOriginalNode(declarationList, initializer); + ts.setTextRange(declarationList, initializer); var firstDeclaration = declarations[0]; var lastDeclaration = ts.lastOrUndefined(declarations); ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); statements.push(ts.createVariableStatement(undefined, declarationList)); } else { - statements.push(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.createVariableDeclarationList([ + statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, ts.createElementAccess(rhsReference, counter)) - ], ts.moveRangePos(initializer, -1)), initializer), ts.moveRangeEnd(initializer, -1))); + ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); } } else { @@ -42552,7 +44877,7 @@ var ts; } else { assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createStatement(assignment), ts.moveRangeEnd(initializer, -1))); } } var bodyLocation; @@ -42561,7 +44886,7 @@ var ts; ts.addRange(statements, convertedLoopBodyStatements); } else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + var statement = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -42572,38 +44897,62 @@ var ts; } } ts.setEmitFlags(expression, 48 | ts.getEmitFlags(expression)); - var body = ts.createBlock(ts.createNodeArray(statements, statementsLocation), bodyLocation); + var body = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation)); + ts.setTextRange(body, bodyLocation); ts.setEmitFlags(body, 48 | 384); - var forStatement = ts.createFor(ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0), ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) - ], node.expression), 1048576), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); + var forStatement = ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)), + ts.setTextRange(ts.createVariableDeclaration(rhsReference, undefined, expression), node.expression) + ]), node.expression), 1048576), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), body); ts.setEmitFlags(forStatement, 256); - return forStatement; + ts.setTextRange(forStatement, node); + return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); + } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 211: + case 212: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 213: + return visitForStatement(node, outermostLabeledStatement); + case 214: + return visitForInStatement(node, outermostLabeledStatement); + case 215: + return visitForOfStatement(node, outermostLabeledStatement); + } } function visitObjectLiteralExpression(node) { var properties = node.properties; var numProperties = properties.length; var numInitialProperties = numProperties; + var numInitialPropertiesWithoutYield = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 - || property.name.kind === 142) { + if ((property.transformFlags & 16777216 && hierarchyFacts & 4) + && i < numInitialPropertiesWithoutYield) { + numInitialPropertiesWithoutYield = i; + } + if (property.name.kind === 143) { numInitialProperties = i; break; } } - ts.Debug.assert(numInitialProperties !== numProperties); - var temp = ts.createTempVariable(hoistVariableDeclaration); - var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); - if (node.multiLine) { - assignment.startsOnNewLine = true; + if (numInitialProperties !== numProperties) { + if (numInitialPropertiesWithoutYield < numInitialProperties) { + numInitialProperties = numInitialPropertiesWithoutYield; + } + var temp = ts.createTempVariable(hoistVariableDeclaration); + var expressions = []; + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 32768)); + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + expressions.push(assignment); + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); + return ts.inlineExpressions(expressions); } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); + return ts.visitEachChild(node, visitor, context); } function shouldConvertIterationStatementBody(node) { return (resolver.getNodeCheckFlags(node) & 65536) !== 0; @@ -42627,14 +44976,16 @@ var ts; } } } - function convertIterationStatementBodyIfNecessary(node, convert) { + function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) { if (!shouldConvertIterationStatementBody(node)) { var saveAllowedNonLabeledJumps = void 0; if (convertedLoopState) { saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; convertedLoopState.allowedNonLabeledJumps = 2 | 4; } - var result = convert ? convert(node, undefined) : ts.visitEachChild(node, visitor, context); + var result = convert + ? convert(node, outermostLabeledStatement, undefined) + : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel); if (convertedLoopState) { convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } @@ -42643,11 +44994,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 211: - case 212: case 213: + case 214: + case 215: var initializer = node.initializer; - if (initializer && initializer.kind === 224) { + if (initializer && initializer.kind === 226) { loopInitializer = initializer; } break; @@ -42674,7 +45025,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -42684,13 +45035,15 @@ var ts; copyOutParameters(loopOutParameters, 1, statements_4); } ts.addRange(statements_4, lexicalEnvironment); - loopBody = ts.createBlock(statements_4, undefined, true); + loopBody = ts.createBlock(statements_4, true); } - if (!ts.isBlock(loopBody)) { - loopBody = ts.createBlock([loopBody], undefined, true); + if (ts.isBlock(loopBody)) { + loopBody.multiLine = true; } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 131072) !== 0 + else { + loopBody = ts.createBlock([loopBody], true); + } + var isAsyncBlockContainingAwait = hierarchyFacts & 4 && (node.statement.transformFlags & 16777216) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -42749,19 +45102,18 @@ var ts; var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); var loop; if (convert) { - loop = convert(node, convertedLoopBodyStatements); + loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); } else { - loop = ts.getMutableClone(node); - loop.statement = undefined; - loop = ts.visitEachChild(loop, visitor, context); - loop.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); + var clone_4 = ts.getMutableClone(node); + clone_4.statement = undefined; + clone_4 = ts.visitEachChild(clone_4, visitor, context); + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, true); + clone_4.transformFlags = 0; + ts.aggregateTransformFlags(clone_4); + loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } - statements.push(currentParent.kind === 219 - ? ts.createLabel(currentParent.label, loop) - : loop); + statements.push(loop); return statements; } function copyOutParameter(outParam, copyDirection) { @@ -42820,23 +45172,22 @@ var ts; if (!state.labeledNonLocalBreaks) { state.labeledNonLocalBreaks = ts.createMap(); } - state.labeledNonLocalBreaks[labelText] = labelMarker; + state.labeledNonLocalBreaks.set(labelText, labelMarker); } else { if (!state.labeledNonLocalContinues) { state.labeledNonLocalContinues = ts.createMap(); } - state.labeledNonLocalContinues[labelText] = labelMarker; + state.labeledNonLocalContinues.set(labelText, labelMarker); } } function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { if (!table) { return; } - for (var labelText in table) { - var labelMarker = table[labelText]; + table.forEach(function (labelMarker, labelText) { var statements = []; - if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { + if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) { var label = ts.createIdentifier(labelText); statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); } @@ -42845,7 +45196,7 @@ var ts; statements.push(ts.createReturn(loopResultName)); } caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); - } + }); } function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { var name = decl.name; @@ -42860,7 +45211,7 @@ var ts; else { loopParameters.push(ts.createParameter(undefined, undefined, undefined, name)); if (resolver.getNodeCheckFlags(decl) & 2097152) { - var outParamName = ts.createUniqueName("out_" + name.text); + var outParamName = ts.createUniqueName("out_" + ts.unescapeIdentifier(name.text)); loopOutParameters.push({ originalName: name, outParamName: outParamName }); } } @@ -42871,22 +45222,22 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 151: case 152: + case 153: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 257: + case 150: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); + break; + case 260: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 258: + case 261: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 149: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); - break; default: ts.Debug.failBadSyntaxKind(node); break; @@ -42894,34 +45245,49 @@ var ts; } } function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } return expression; } function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } return expression; } - function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined), method); + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { + var ancestorFacts = enterSubtree(0, 0); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container)); + ts.setTextRange(expression, method); if (startsOnNewLine) { expression.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 16384 : 0); return expression; } function visitCatchClause(node) { - ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); - var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); - var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); - var destructure = ts.createVariableStatement(undefined, list); - return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + var ancestorFacts = enterSubtree(4032, 0); + var updated; + if (ts.isBindingPattern(node.variableDeclaration.name)) { + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp); + ts.setTextRange(newVariableDeclaration, node.variableDeclaration); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); + var list = ts.createVariableDeclarationList(vars); + ts.setTextRange(list, node.variableDeclaration); + var destructure = ts.createVariableStatement(undefined, list); + updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0, 0); + return updated; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); @@ -42929,21 +45295,43 @@ var ts; } function visitMethodDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); + var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined); ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression)); - return ts.createPropertyAssignment(node.name, functionExpression, node); + return ts.setTextRange(ts.createPropertyAssignment(node.name, functionExpression), node); + } + function visitAccessorDeclaration(node) { + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286, 65); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152, 0); + convertedLoopState = savedConvertedLoopState; + return updated; } function visitShorthandPropertyAssignment(node) { - return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), node); + return ts.setTextRange(ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name)), node); + } + function visitComputedPropertyName(node) { + var ancestorFacts = enterSubtree(0, 8192); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152, hierarchyFacts & 49152 ? 32768 : 0); + return updated; } function visitYieldExpression(node) { return ts.visitEachChild(node, visitor, context); } function visitArrayLiteralExpression(node) { - return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + if (node.transformFlags & 64) { + return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + } + return ts.visitEachChild(node, visitor, context); } function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + if (node.transformFlags & 64) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + } + return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); } function visitImmediateSuperCallInBody(node) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, false); @@ -42955,25 +45343,27 @@ var ts; } var resultingCall; if (node.transformFlags & 524288) { - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } if (node.expression.kind === 96) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4); var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis + resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createIdentifier("_this"), initializer) : initializer; } - return resultingCall; + return ts.setOriginalNode(resultingCall, node); } function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 524288) !== 0); - var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + if (node.transformFlags & 524288) { + var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + } + return ts.visitEachChild(node, visitor, context); } function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { var numElements = elements.length; @@ -42982,7 +45372,7 @@ var ts; })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 175 + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 176 ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -42997,7 +45387,7 @@ var ts; return ts.map(chunk, visitExpressionOfSpread); } function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) { - return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, undefined, hasTrailingComma), visitor, ts.isExpression), undefined, multiLine); + return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -43006,7 +45396,7 @@ var ts; return ts.visitNode(node.expression, visitor, ts.isExpression); } function visitTemplateLiteral(node) { - return ts.createLiteral(node.text, node); + return ts.setTextRange(ts.createLiteral(node.text), node); } function visitTaggedTemplateExpression(node) { var tag = ts.visitNode(node.tag, visitor, ts.isExpression); @@ -43040,7 +45430,7 @@ var ts; var isLast = node.kind === 12 || node.kind === 15; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); - return ts.createLiteral(text, node); + return ts.setTextRange(ts.createLiteral(text), node); } function visitTemplateExpression(node) { var expressions = []; @@ -43048,7 +45438,8 @@ var ts; addTemplateSpans(expressions, node); var expression = ts.reduceLeft(expressions, ts.createAdd); if (ts.nodeIsSynthesized(expression)) { - ts.setTextRange(expression, node); + expression.pos = node.pos; + expression.end = node.end; } return expression; } @@ -43071,21 +45462,34 @@ var ts; } } } - function visitSuperKeyword() { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 179 + function visitSuperKeyword(isExpressionOfCall) { + return hierarchyFacts & 8 + && !isExpressionOfCall ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } - function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; - if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { - enclosingFunction = node; + function visitMetaProperty(node) { + if (node.keywordToken === 93 && node.name.text === "target") { + if (hierarchyFacts & 8192) { + hierarchyFacts |= 32768; + } + else { + hierarchyFacts |= 16384; + } + return ts.createIdentifier("_newTarget"); } - previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; + return node; + } + function onEmitNode(hint, node, emitCallback) { + if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { + var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8 + ? 65 | 16 + : 65); + previousOnEmitNode(hint, node, emitCallback); + exitSubtree(ancestorFacts, 0, 0); + return; + } + previousOnEmitNode(hint, node, emitCallback); } function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { @@ -43097,18 +45501,18 @@ var ts; if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; context.enableSubstitution(98); - context.enableEmitNotification(150); - context.enableEmitNotification(149); context.enableEmitNotification(151); + context.enableEmitNotification(150); context.enableEmitNotification(152); + context.enableEmitNotification(153); + context.enableEmitNotification(186); context.enableEmitNotification(185); - context.enableEmitNotification(184); - context.enableEmitNotification(225); + context.enableEmitNotification(227); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -43128,10 +45532,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 174: - case 226: - case 229: - case 223: + case 175: + case 228: + case 231: + case 225: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -43157,9 +45561,8 @@ var ts; } function substituteThisKeyword(node) { if (enabledSubstitutions & 1 - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 8) { - return ts.createIdentifier("_this", node); + && hierarchyFacts & 16) { + return ts.setTextRange(ts.createIdentifier("_this"), node); } return node; } @@ -43175,11 +45578,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 207) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 209) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 179) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 180) { return false; } var callTarget = statementExpression.expression; @@ -43187,7 +45590,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 196) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 197) { return false; } var expression = callArgument.expression; @@ -43206,18 +45609,65 @@ var ts; name: "typescript:extends", scoped: false, priority: 0, - text: "\n var __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 };" + text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; })(ts || (ts = {})); var ts; (function (ts) { - var instructionNames = ts.createMap((_a = {}, - _a[2] = "return", - _a[3] = "break", - _a[4] = "yield", - _a[5] = "yield*", - _a[7] = "endfinally", - _a)); + var OpCode; + (function (OpCode) { + OpCode[OpCode["Nop"] = 0] = "Nop"; + OpCode[OpCode["Statement"] = 1] = "Statement"; + OpCode[OpCode["Assign"] = 2] = "Assign"; + OpCode[OpCode["Break"] = 3] = "Break"; + OpCode[OpCode["BreakWhenTrue"] = 4] = "BreakWhenTrue"; + OpCode[OpCode["BreakWhenFalse"] = 5] = "BreakWhenFalse"; + OpCode[OpCode["Yield"] = 6] = "Yield"; + OpCode[OpCode["YieldStar"] = 7] = "YieldStar"; + OpCode[OpCode["Return"] = 8] = "Return"; + OpCode[OpCode["Throw"] = 9] = "Throw"; + OpCode[OpCode["Endfinally"] = 10] = "Endfinally"; + })(OpCode || (OpCode = {})); + var BlockAction; + (function (BlockAction) { + BlockAction[BlockAction["Open"] = 0] = "Open"; + BlockAction[BlockAction["Close"] = 1] = "Close"; + })(BlockAction || (BlockAction = {})); + var CodeBlockKind; + (function (CodeBlockKind) { + CodeBlockKind[CodeBlockKind["Exception"] = 0] = "Exception"; + CodeBlockKind[CodeBlockKind["With"] = 1] = "With"; + CodeBlockKind[CodeBlockKind["Switch"] = 2] = "Switch"; + CodeBlockKind[CodeBlockKind["Loop"] = 3] = "Loop"; + CodeBlockKind[CodeBlockKind["Labeled"] = 4] = "Labeled"; + })(CodeBlockKind || (CodeBlockKind = {})); + var ExceptionBlockState; + (function (ExceptionBlockState) { + ExceptionBlockState[ExceptionBlockState["Try"] = 0] = "Try"; + ExceptionBlockState[ExceptionBlockState["Catch"] = 1] = "Catch"; + ExceptionBlockState[ExceptionBlockState["Finally"] = 2] = "Finally"; + ExceptionBlockState[ExceptionBlockState["Done"] = 3] = "Done"; + })(ExceptionBlockState || (ExceptionBlockState = {})); + var Instruction; + (function (Instruction) { + Instruction[Instruction["Next"] = 0] = "Next"; + Instruction[Instruction["Throw"] = 1] = "Throw"; + Instruction[Instruction["Return"] = 2] = "Return"; + Instruction[Instruction["Break"] = 3] = "Break"; + Instruction[Instruction["Yield"] = 4] = "Yield"; + Instruction[Instruction["YieldStar"] = 5] = "YieldStar"; + Instruction[Instruction["Catch"] = 6] = "Catch"; + Instruction[Instruction["Endfinally"] = 7] = "Endfinally"; + })(Instruction || (Instruction = {})); + function getInstructionName(instruction) { + switch (instruction) { + case 2: return "return"; + case 3: return "break"; + case 4: return "yield"; + case 5: return "yield*"; + case 7: return "endfinally"; + } + } function transformGenerators(context) { var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); @@ -43283,13 +45733,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 209: + case 211: return visitDoStatement(node); - case 210: + case 212: return visitWhileStatement(node); - case 218: + case 220: return visitSwitchStatement(node); - case 219: + case 221: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -43297,24 +45747,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 225: + case 227: return visitFunctionDeclaration(node); - case 184: + case 185: return visitFunctionExpression(node); - case 151: case 152: + case 153: return visitAccessorDeclaration(node); - case 205: + case 207: return visitVariableStatement(node); - case 211: + case 213: return visitForStatement(node); - case 212: - return visitForInStatement(node); - case 215: - return visitBreakStatement(node); case 214: - return visitContinueStatement(node); + return visitForInStatement(node); + case 217: + return visitBreakStatement(node); case 216: + return visitContinueStatement(node); + case 218: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -43330,21 +45780,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 192: - return visitBinaryExpression(node); case 193: + return visitBinaryExpression(node); + case 194: return visitConditionalExpression(node); - case 195: + case 196: return visitYieldExpression(node); - case 175: - return visitArrayLiteralExpression(node); case 176: + return visitArrayLiteralExpression(node); + case 177: return visitObjectLiteralExpression(node); - case 178: - return visitElementAccessExpression(node); case 179: - return visitCallExpression(node); + return visitElementAccessExpression(node); case 180: + return visitCallExpression(node); + case 181: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -43352,9 +45802,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 225: + case 227: return visitFunctionDeclaration(node); - case 184: + case 185: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -43363,7 +45813,7 @@ var ts; } function visitFunctionDeclaration(node) { if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { - node = ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body), node), node); + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration(undefined, node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -43384,7 +45834,7 @@ var ts; } function visitFunctionExpression(node) { if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { - node = ts.setOriginalNode(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body), node), node); + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -43454,7 +45904,7 @@ var ts; operationArguments = savedOperationArguments; operationLocations = savedOperationLocations; state = savedState; - return ts.createBlock(statements, body, body.multiLine); + return ts.setTextRange(ts.createBlock(statements, body.multiLine), body); } function visitVariableStatement(node) { if (node.transformFlags & 16777216) { @@ -43511,10 +45961,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 177: + case 178: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 178: + case 179: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -43523,7 +45973,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 57, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.setTextRange(ts.createAssignment(target, ts.setTextRange(ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression)), node)), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -43539,10 +45989,10 @@ var ts; else if (node.operatorToken.kind === 25) { return visitCommaExpression(node); } - var clone_4 = ts.getMutableClone(node); - clone_4.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_4.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_4; + var clone_5 = ts.getMutableClone(node); + clone_5.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_5.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_5; } return ts.visitEachChild(node, visitor, context); } @@ -43604,7 +46054,7 @@ var ts; emitYield(expression, node); } markLabel(resumeLabel); - return createGeneratorResume(); + return createGeneratorResume(node); } function visitArrayLiteralExpression(node) { return visitElements(node.elements, undefined, undefined, node.multiLine); @@ -43622,13 +46072,13 @@ var ts; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, location, multiLine); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { emitAssignment(temp, hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, undefined, multiLine)); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); hasAssignedTemp = true; leadingElement = undefined; expressions = []; @@ -43642,7 +46092,7 @@ var ts; var multiLine = node.multiLine; var numInitialProperties = countInitialNodesWithoutYield(properties); var temp = declareLocal(); - emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, multiLine)); + emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), multiLine)); var expressions = ts.reduceLeft(properties, reduceProperty, [], numInitialProperties); expressions.push(multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); return ts.inlineExpressions(expressions); @@ -43664,10 +46114,10 @@ var ts; } function visitElementAccessExpression(node) { if (containsYield(node.argumentExpression)) { - var clone_5 = ts.getMutableClone(node); - clone_5.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_5.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_5; + var clone_6 = ts.getMutableClone(node); + clone_6.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_6.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -43681,7 +46131,7 @@ var ts; function visitNewExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, ts.createVoidZero())), undefined, [], node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, ts.createVoidZero())), undefined, []), node), node); } return ts.visitEachChild(node, visitor, context); } @@ -43710,35 +46160,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 204: + case 206: return transformAndEmitBlock(node); - case 207: - return transformAndEmitExpressionStatement(node); - case 208: - return transformAndEmitIfStatement(node); case 209: - return transformAndEmitDoStatement(node); + return transformAndEmitExpressionStatement(node); case 210: - return transformAndEmitWhileStatement(node); + return transformAndEmitIfStatement(node); case 211: - return transformAndEmitForStatement(node); + return transformAndEmitDoStatement(node); case 212: - return transformAndEmitForInStatement(node); + return transformAndEmitWhileStatement(node); + case 213: + return transformAndEmitForStatement(node); case 214: - return transformAndEmitContinueStatement(node); - case 215: - return transformAndEmitBreakStatement(node); + return transformAndEmitForInStatement(node); case 216: - return transformAndEmitReturnStatement(node); + return transformAndEmitContinueStatement(node); case 217: - return transformAndEmitWithStatement(node); + return transformAndEmitBreakStatement(node); case 218: - return transformAndEmitSwitchStatement(node); + return transformAndEmitReturnStatement(node); case 219: - return transformAndEmitLabeledStatement(node); + return transformAndEmitWithStatement(node); case 220: - return transformAndEmitThrowStatement(node); + return transformAndEmitSwitchStatement(node); case 221: + return transformAndEmitLabeledStatement(node); + case 222: + return transformAndEmitThrowStatement(node); + case 223: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -43758,7 +46208,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - hoistVariableDeclaration(variable.name); + var name = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name, variable.name); + hoistVariableDeclaration(name); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -43788,7 +46240,7 @@ var ts; if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) { var endLabel = defineLabel(); var elseLabel = node.elseStatement ? defineLabel() : undefined; - emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression)); + emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), node.expression); transformAndEmitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { emitBreak(endLabel); @@ -43867,7 +46319,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression), initializer)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -43877,7 +46329,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression), node.incrementor)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -44022,7 +46474,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 254 && defaultClauseIndex === -1) { + if (clause.kind === 257 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -44032,7 +46484,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 253) { + if (clause.kind === 256) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -44134,9 +46586,9 @@ var ts; } return -1; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { return substituteExpression(node); } return node; @@ -44148,17 +46600,17 @@ var ts; return node; } function substituteExpressionIdentifier(node) { - if (renamedCatchVariables && ts.hasProperty(renamedCatchVariables, node.text)) { + if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { var original = ts.getOriginalNode(node); if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_39 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_39) { - var clone_6 = ts.getMutableClone(name_39); - ts.setSourceMapRange(clone_6, node); - ts.setCommentRange(clone_6, node); - return clone_6; + var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; + if (name) { + var clone_7 = ts.getMutableClone(name); + ts.setSourceMapRange(clone_7, node); + ts.setCommentRange(clone_7, node); + return clone_7; } } } @@ -44263,10 +46715,10 @@ var ts; var name = declareLocal(text); if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); - renamedCatchVariableDeclarations = ts.createMap(); + renamedCatchVariableDeclarations = []; context.enableSubstitution(70); } - renamedCatchVariables[text] = true; + renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; var exception = peekBlock(); ts.Debug.assert(exception.state < 1); @@ -44467,23 +46919,23 @@ var ts; } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); - literal.trailingComment = instructionNames[instruction]; + literal.trailingComment = getInstructionName(instruction); return literal; } function createInlineBreak(label, location) { ts.Debug.assert(label > 0, "Invalid label: " + label); - return ts.createReturn(ts.createArrayLiteral([ + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), location); + ])), location); } function createInlineReturn(expression, location) { - return ts.createReturn(ts.createArrayLiteral(expression + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2), expression] - : [createInstruction(2)]), location); + : [createInstruction(2)])), location); } function createGeneratorResume(location) { - return ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, [], location); + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, []), location); } function emitNop() { emitWorker(0); @@ -44549,7 +47001,7 @@ var ts; currentExceptionBlock = undefined; withBlockStack = undefined; var buildResult = buildStatements(); - return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 262144)); + return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, buildResult.length > 0)), 262144)); } function buildStatements() { if (operations) { @@ -44758,51 +47210,51 @@ var ts; } } function writeAssign(left, right, operationLocation) { - writeStatement(ts.createStatement(ts.createAssignment(left, right), operationLocation)); + writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); } function writeThrow(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createThrow(expression, operationLocation)); + writeStatement(ts.setTextRange(ts.createThrow(expression), operationLocation)); } function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2), expression] - : [createInstruction(2)]), operationLocation)); + : [createInstruction(2)])), operationLocation), 384)); } function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation)); + ])), operationLocation), 384)); } function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation))); + ])), operationLocation), 384)), 1)); } function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3), createLabel(label) - ]), operationLocation))); + ])), operationLocation), 384)), 1)); } function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4), expression] - : [createInstruction(4)]), operationLocation)); + : [createInstruction(4)])), operationLocation), 384)); } function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(5), expression - ]), operationLocation)); + ])), operationLocation), 384)); } function writeEndfinally() { lastOperationWasAbrupt = true; @@ -44822,21 +47274,45 @@ var ts; priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; - var _a; })(ts || (ts = {})); var ts; (function (ts) { function transformES5(context) { + var compilerOptions = context.getCompilerOptions(); + var previousOnEmitNode; + var noSubstitution; + if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) { + previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.enableEmitNotification(250); + context.enableEmitNotification(251); + context.enableEmitNotification(249); + noSubstitution = []; + } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(177); - context.enableSubstitution(257); + context.enableSubstitution(178); + context.enableSubstitution(260); return transformSourceFile; function transformSourceFile(node) { return node; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); + function onEmitNode(hint, node, emitCallback) { + switch (node.kind) { + case 250: + case 251: + case 249: + var tagName = node.tagName; + noSubstitution[ts.getOriginalNodeId(tagName)] = true; + break; + } + previousOnEmitNode(hint, node, emitCallback); + } + function onSubstituteNode(hint, node) { + if (node.id && noSubstitution && noSubstitution[node.id]) { + return previousOnSubstituteNode(hint, node); + } + node = previousOnSubstituteNode(hint, node); if (ts.isPropertyAccessExpression(node)) { return substitutePropertyAccessExpression(node); } @@ -44848,7 +47324,7 @@ var ts; function substitutePropertyAccessExpression(node) { var literalName = trySubstituteReservedName(node.name); if (literalName) { - return ts.createElementAccess(node.expression, literalName, node); + return ts.setTextRange(ts.createElementAccess(node.expression, literalName), node); } return node; } @@ -44862,7 +47338,7 @@ var ts; function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); if (token >= 71 && token <= 106) { - return ts.createLiteral(name, name); + return ts.setTextRange(ts.createLiteral(name), name); } return undefined; } @@ -44872,12 +47348,13 @@ var ts; var ts; (function (ts) { function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); + function getTransformModuleDelegate(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.AMD: return transformAMDModule; + case ts.ModuleKind.UMD: return transformUMDModule; + default: return transformCommonJSModule; + } + } var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); @@ -44889,13 +47366,13 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(70); - context.enableSubstitution(192); - context.enableSubstitution(190); + context.enableSubstitution(193); context.enableSubstitution(191); - context.enableSubstitution(258); - context.enableEmitNotification(261); - var moduleInfoMap = ts.createMap(); - var deferredExports = ts.createMap(); + context.enableSubstitution(192); + context.enableSubstitution(261); + context.enableEmitNotification(264); + var moduleInfoMap = []; + var deferredExports = []; var currentSourceFile; var currentModuleInfo; var noSubstitution; @@ -44907,8 +47384,9 @@ var ts; return node; } currentSourceFile = node; - currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(node)] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); - var transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; + currentModuleInfo = ts.collectExternalModuleInfo(node, resolver, compilerOptions); + moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo; + var transformModule = getTransformModuleDelegate(moduleKind); var updated = transformModule(node); currentSourceFile = undefined; currentModuleInfo = undefined; @@ -44918,11 +47396,14 @@ var ts; startLexicalEnvironment(); var statements = []; var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, false); - var updated = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); if (currentModuleInfo.hasExportStarsToExportValues) { ts.addEmitHelper(updated, exportStarHelper); } @@ -44931,15 +47412,8 @@ var ts; function transformAMDModule(node) { var define = ts.createIdentifier("define"); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, true); - } - function transformUMDModule(node) { - var define = ts.createRawExpression(umdHelper); - return transformAsynchronousModule(node, define, undefined, false); - } - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - return ts.updateSourceFileNode(node, ts.createNodeArray([ + var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), @@ -44950,7 +47424,37 @@ var ts; ts.createParameter(undefined, undefined, undefined, "exports") ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) ]))) - ], node.statements)); + ]), node.statements)); + } + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.setTextRange(ts.createBlock([ + ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ + ts.createVariableStatement(undefined, [ + ts.createVariableDeclaration("v", undefined, ts.createCall(ts.createIdentifier("factory"), undefined, [ + ts.createIdentifier("require"), + ts.createIdentifier("exports") + ])) + ]), + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1) + ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), undefined, [ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createIdentifier("factory") + ])) + ]))) + ], true), undefined)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ + ts.createStatement(ts.createCall(umdHeader, undefined, [ + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter(undefined, undefined, undefined, "require"), + ts.createParameter(undefined, undefined, undefined, "exports") + ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ])) + ]), node.statements)); } function collectAsynchronousDependencies(node, includeNonAmdDependencies) { var aliasedModuleNames = []; @@ -44985,11 +47489,14 @@ var ts; startLexicalEnvironment(); var statements = []; var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, true); - var body = ts.createBlock(statements, undefined, true); + var body = ts.createBlock(statements, true); if (currentModuleInfo.hasExportStarsToExportValues) { ts.addEmitHelper(body, exportStarHelper); } @@ -44998,12 +47505,14 @@ var ts; function addExportEqualsIfNeeded(statements, emitAsReturn) { if (currentModuleInfo.exportEquals) { if (emitAsReturn) { - var statement = ts.createReturn(currentModuleInfo.exportEquals.expression, currentModuleInfo.exportEquals); + var statement = ts.createReturn(currentModuleInfo.exportEquals.expression); + ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 384 | 1536); statements.push(statement); } else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression), currentModuleInfo.exportEquals); + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression)); + ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 1536); statements.push(statement); } @@ -45011,23 +47520,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 235: + case 237: return visitImportDeclaration(node); - case 234: + case 236: return visitImportEqualsDeclaration(node); - case 241: + case 243: return visitExportDeclaration(node); - case 240: + case 242: return visitExportAssignment(node); - case 205: + case 207: return visitVariableStatement(node); - case 225: + case 227: return visitFunctionDeclaration(node); - case 226: + case 228: return visitClassDeclaration(node); - case 295: + case 299: return visitMergeDeclarationMarker(node); - case 296: + case 300: return visitEndOfDeclarationMarker(node); default: return node; @@ -45038,7 +47547,7 @@ var ts; var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (moduleKind !== ts.ModuleKind.AMD) { if (!node.importClause) { - return ts.createStatement(createRequireCall(node), node); + return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); } else { var variables = []; @@ -45051,13 +47560,13 @@ var ts; variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node))); } } - statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, undefined, languageVersion >= 2 ? 2 : 0), node)); + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, languageVersion >= 2 ? 2 : 0)), node)); } } else if (namespaceDeclaration && ts.isDefaultImport(node)) { statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node), node) - ], undefined, languageVersion >= 2 ? 2 : 0))); + ts.setTextRange(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node)), node) + ], languageVersion >= 2 ? 2 : 0))); } if (hasAssociatedEndOfDeclarationMarker(node)) { var id = ts.getOriginalNodeId(node); @@ -45081,17 +47590,17 @@ var ts; var statements; if (moduleKind !== ts.ModuleKind.AMD) { if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(node.name, createRequireCall(node)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(node.name, createRequireCall(node))), node)); } else { - statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node)) - ], undefined, languageVersion >= 2 ? 2 : 0), node)); + ], languageVersion >= 2 ? 2 : 0)), node)); } } else { if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); } } if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -45111,23 +47620,23 @@ var ts; if (node.exportClause) { var statements = []; if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(generatedName, undefined, createRequireCall(node)) - ]), node)); + ])), node)); } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue), specifier)); + statements.push(ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); } return ts.singleOrMany(statements); } else { - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ + return ts.setTextRange(ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName - ]), node); + ])), node); } } function visitExportAssignment(node) { @@ -45148,7 +47657,7 @@ var ts; function visitFunctionDeclaration(node) { var statements; if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, node.parameters, undefined, node.body, node), node)); + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, node.parameters, undefined, node.body), node), node)); } else { statements = ts.append(statements, node); @@ -45165,7 +47674,7 @@ var ts; function visitClassDeclaration(node) { var statements; if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, node.heritageClauses, node.members, node), node)); + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, node.heritageClauses, node.members), node), node)); } else { statements = ts.append(statements, node); @@ -45201,7 +47710,7 @@ var ts; statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); } if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); } } else { @@ -45221,11 +47730,11 @@ var ts; return ts.flattenDestructuringAssignment(node, undefined, context, 0, false, createExportExpression); } else { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name, node.name), node.initializer); + return ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name), node.name), node.initializer); } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -45257,10 +47766,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237: + case 239: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238: + case 240: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -45318,7 +47827,7 @@ var ts; } function appendExportsOfDeclaration(statements, decl) { var name = ts.getDeclarationName(decl); - var exportSpecifiers = currentModuleInfo.exportSpecifiers[name.text]; + var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { var exportSpecifier = exportSpecifiers_1[_i]; @@ -45328,28 +47837,28 @@ var ts; return statements; } function appendExportStatement(statements, exportName, expression, location, allowComments) { - if (exportName.text === "default") { - var sourceFile = ts.getOriginalNode(currentSourceFile, ts.isSourceFile); - if (sourceFile && !sourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 0) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); - } - else { - statements = ts.append(statements, ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); - } - } - } statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); return statements; } + function createUnderscoreUnderscoreESModule() { + var statement; + if (languageVersion === 0) { + statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true))); + } + else { + statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ])); + } + ts.setEmitFlags(statement, 524288); + return statement; + } function createExportStatement(name, value, location, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value), location); + var statement = ts.setTextRange(ts.createStatement(createExportExpression(name, value)), location); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536); @@ -45357,7 +47866,7 @@ var ts; return statement; } function createExportExpression(name, value, location) { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value, location); + return ts.setTextRange(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value), location); } function modifierVisitor(node) { switch (node.kind) { @@ -45367,26 +47876,26 @@ var ts; } return node; } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261) { + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; - noSubstitution = ts.createMap(); - previousOnEmitNode(emitContext, node, emitCallback); + noSubstitution = []; + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; currentModuleInfo = undefined; noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); if (node.id && noSubstitution[node.id]) { return node; } - if (emitContext === 1) { + if (hint === 1) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -45400,9 +47909,9 @@ var ts; if (exportedOrImportedName !== name) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, node); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); } - return ts.createPropertyAssignment(name, exportedOrImportedName, node); + return ts.setTextRange(ts.createPropertyAssignment(name, exportedOrImportedName), node); } return node; } @@ -45410,10 +47919,10 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 192: + case 193: return substituteBinaryExpression(node); + case 192: case 191: - case 190: return substituteUnaryExpression(node); } return node; @@ -45428,17 +47937,17 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 261) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); + if (exportContainer && exportContainer.kind === 264) { + return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_40 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_40), node); + var name = importDeclaration.propertyName || importDeclaration.name; + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name)), node); } } } @@ -45471,8 +47980,8 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 191 - ? ts.createBinary(node.operand, ts.createToken(node.operator === 42 ? 58 : 59), ts.createLiteral(1), node) + var expression = node.kind === 192 + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 42 ? 58 : 59), ts.createLiteral(1)), node) : node; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { var exportName = exportedNames_2[_i]; @@ -45494,7 +48003,6 @@ var ts; } } } - var _a; } ts.transformModule = transformModule; var exportStarHelper = { @@ -45502,7 +48010,6 @@ var ts; scoped: true, text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" }; - var umdHelper = "\n (function (dependencies, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(dependencies, factory);\n }\n })"; })(ts || (ts = {})); var ts; (function (ts) { @@ -45516,14 +48023,14 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(70); - context.enableSubstitution(192); - context.enableSubstitution(190); + context.enableSubstitution(193); context.enableSubstitution(191); - context.enableEmitNotification(261); - var moduleInfoMap = ts.createMap(); - var deferredExports = ts.createMap(); - var exportFunctionsMap = ts.createMap(); - var noSubstitutionMap = ts.createMap(); + context.enableSubstitution(192); + context.enableEmitNotification(264); + var moduleInfoMap = []; + var deferredExports = []; + var exportFunctionsMap = []; + var noSubstitutionMap = []; var currentSourceFile; var moduleInfo; var exportFunction; @@ -45542,7 +48049,8 @@ var ts; currentSourceFile = node; enclosingBlockScopedContainer = node; moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); - exportFunction = exportFunctionsMap[id] = ts.createUniqueName("exports"); + exportFunction = ts.createUniqueName("exports"); + exportFunctionsMap[id] = exportFunction; contextObject = ts.createUniqueName("context"); var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); @@ -45552,11 +48060,11 @@ var ts; ], undefined, moduleBodyBlock); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); - var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.createNodeArray([ + var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ], node.statements)), 1024); + ]), node.statements)), 1024); if (!(compilerOptions.outFile || compilerOptions.out)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -45579,12 +48087,12 @@ var ts; var externalImport = externalImports[i]; var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { - var groupIndex = groupIndices[text]; + var groupIndex = groupIndices.get(text); + if (groupIndex !== undefined) { dependencyGroups[groupIndex].externalImports.push(externalImport); } else { - groupIndices[text] = dependencyGroups.length; + groupIndices.set(text, dependencyGroups.length); dependencyGroups.push({ name: externalModuleName, externalImports: [externalImport] @@ -45605,21 +48113,23 @@ var ts; ts.addRange(statements, hoistedStatements); ts.addRange(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + var moduleObject = ts.createObjectLiteral([ ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) - ]), true))); - return ts.createBlock(statements, undefined, true); + ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, true))) + ]); + moduleObject.multiLine = true; + statements.push(ts.createReturn(moduleObject)); + return ts.createBlock(statements, true); } function addExportStarIfNeeded(statements) { if (!moduleInfo.hasExportStarsToExportValues) { return; } - if (!moduleInfo.exportedNames && ts.isEmpty(moduleInfo.exportSpecifiers)) { + if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) { var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 241 && externalImport.exportClause) { + if (externalImport.kind === 243 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -45637,12 +48147,12 @@ var ts; if (exportedLocalName.text === "default") { continue; } - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createTrue())); } } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 241) { + if (externalImport.kind !== 243) { continue; } var exportDecl = externalImport; @@ -45651,12 +48161,12 @@ var ts; } for (var _f = 0, _g = exportDecl.exportClause.elements; _f < _g.length; _f++) { var element = _g[_f]; - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createTrue())); } } var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, undefined, true)) + ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, true)) ]))); var exportStarFunction = createExportStarFunction(exportedNamesStorageRef); statements.push(exportStarFunction); @@ -45681,7 +48191,7 @@ var ts; ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1) ])), ts.createStatement(ts.createCall(exportFunction, undefined, [exports])) - ], undefined, true)); + ], true)); } function createSettersArray(exportStarFunction, dependencyGroups) { var setters = []; @@ -45694,15 +48204,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 235: + case 237: if (!entry.importClause) { break; } - case 234: + case 236: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 241: + case 243: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -45710,7 +48220,7 @@ var ts; var e = _d[_c]; properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); } - statements.push(ts.createStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, undefined, true)]))); + statements.push(ts.createStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, true)]))); } else { statements.push(ts.createStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); @@ -45718,19 +48228,19 @@ var ts; break; } } - setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, undefined, true))); + setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, true))); } - return ts.createArrayLiteral(setters, undefined, true); + return ts.createArrayLiteral(setters, true); } function sourceElementVisitor(node) { switch (node.kind) { - case 235: + case 237: return visitImportDeclaration(node); - case 234: + case 236: return visitImportEqualsDeclaration(node); - case 241: + case 243: return undefined; - case 240: + case 242: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -45797,7 +48307,7 @@ var ts; var statements; var name = ts.getLocalName(node); hoistVariableDeclaration(name); - statements = ts.append(statements, ts.createStatement(ts.createAssignment(name, ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement), node)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); @@ -45825,7 +48335,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { var id = ts.getOriginalNodeId(node); @@ -45851,7 +48361,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 1048576) === 0 - && (enclosingBlockScopedContainer.kind === 261 + && (enclosingBlockScopedContainer.kind === 264 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -45869,11 +48379,11 @@ var ts; function createVariableAssignment(name, value, location, isExportedDeclaration) { hoistVariableDeclaration(ts.getSynthesizedClone(name)); return isExportedDeclaration - ? createExportExpression(name, preventSubstitution(ts.createAssignment(name, value, location))) - : preventSubstitution(ts.createAssignment(name, value, location)); + ? createExportExpression(name, preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location))) + : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -45906,10 +48416,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237: + case 239: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238: + case 240: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -45979,7 +48489,7 @@ var ts; return statements; } var name = ts.getDeclarationName(decl); - var exportSpecifiers = moduleInfo.exportSpecifiers[name.text]; + var exportSpecifiers = moduleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { var exportSpecifier = exportSpecifiers_2[_i]; @@ -46008,43 +48518,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 205: + case 207: return visitVariableStatement(node); - case 225: + case 227: return visitFunctionDeclaration(node); - case 226: + case 228: return visitClassDeclaration(node); - case 211: - return visitForStatement(node); - case 212: - return visitForInStatement(node); case 213: + return visitForStatement(node); + case 214: + return visitForInStatement(node); + case 215: return visitForOfStatement(node); - case 209: + case 211: return visitDoStatement(node); - case 210: + case 212: return visitWhileStatement(node); - case 219: - return visitLabeledStatement(node); - case 217: - return visitWithStatement(node); - case 218: - return visitSwitchStatement(node); - case 232: - return visitCaseBlock(node); - case 253: - return visitCaseClause(node); - case 254: - return visitDefaultClause(node); case 221: - return visitTryStatement(node); + return visitLabeledStatement(node); + case 219: + return visitWithStatement(node); + case 220: + return visitSwitchStatement(node); + case 234: + return visitCaseBlock(node); case 256: + return visitCaseClause(node); + case 257: + return visitDefaultClause(node); + case 223: + return visitTryStatement(node); + case 259: return visitCatchClause(node); - case 204: + case 206: return visitBlock(node); - case 295: + case 299: return visitMergeDeclarationMarker(node); - case 296: + case 300: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -46135,7 +48645,7 @@ var ts; } function destructuringVisitor(node) { if (node.transformFlags & 1024 - && node.kind === 192) { + && node.kind === 193) { return visitDestructuringAssignment(node); } else if (node.transformFlags & 2048) { @@ -46172,7 +48682,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 261; + return container !== undefined && container.kind === 264; } else { return false; @@ -46186,8 +48696,8 @@ var ts; } return node; } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261) { + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -46196,22 +48706,22 @@ var ts; if (noSubstitution) { delete noSubstitutionMap[id]; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); if (isSubstitutionPrevented(node)) { return node; } - if (emitContext === 1) { + if (hint === 1) { return substituteExpression(node); } return node; @@ -46220,10 +48730,10 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 192: + case 193: return substituteBinaryExpression(node); - case 190: case 191: + case 192: return substituteUnaryExpression(node); } return node; @@ -46240,10 +48750,10 @@ var ts; var importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node); } else if (ts.isImportSpecifier(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name), node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name)), node); } } } @@ -46275,14 +48785,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 191 - ? ts.createPrefix(node.operator, node.operand, node) + var expression = node.kind === 192 + ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { var exportName = exportedNames_4[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 191) { + if (node.kind === 192) { expression = node.operator === 42 ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -46299,7 +48809,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 261) { + if (exportContainer && exportContainer.kind === 264) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -46309,7 +48819,7 @@ var ts; } function preventSubstitution(node) { if (noSubstitution === undefined) - noSubstitution = ts.createMap(); + noSubstitution = []; noSubstitution[ts.getNodeId(node)] = true; return node; } @@ -46327,7 +48837,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(261); + context.enableEmitNotification(264); context.enableSubstitution(70); var currentSourceFile; return transformSourceFile; @@ -46342,7 +48852,7 @@ var ts; var statementOffset = ts.addPrologueDirectives(statements, node.statements); ts.append(statements, ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } else { return ts.visitEachChild(node, visitor, context); @@ -46352,9 +48862,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 234: + case 236: return undefined; - case 240: + case 242: return visitExportAssignment(node); } return node; @@ -46362,19 +48872,19 @@ var ts; function visitExportAssignment(node) { return node.isExportEquals ? undefined : node; } - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { if (ts.isSourceFile(node)) { currentSourceFile = node; - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (ts.isIdentifier(node) && emitContext === 1) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (ts.isIdentifier(node) && hint === 1) { return substituteExpressionIdentifier(node); } return node; @@ -46393,14 +48903,21 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, - _a[ts.ModuleKind.System] = ts.transformSystemModule, - _a[ts.ModuleKind.AMD] = ts.transformModule, - _a[ts.ModuleKind.CommonJS] = ts.transformModule, - _a[ts.ModuleKind.UMD] = ts.transformModule, - _a[ts.ModuleKind.None] = ts.transformModule, - _a)); + function getModuleTransformer(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.ES2015: + return ts.transformES2015Module; + case ts.ModuleKind.System: + return ts.transformSystemModule; + default: + return ts.transformModule; + } + } + var SyntaxKindFeatureFlags; + (function (SyntaxKindFeatureFlags) { + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["EmitNotifications"] = 2] = "EmitNotifications"; + })(SyntaxKindFeatureFlags || (SyntaxKindFeatureFlags = {})); function getTransformers(compilerOptions) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -46423,7 +48940,7 @@ var ts; transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } - transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); + transformers.push(getModuleTransformer(moduleKind)); if (languageVersion < 1) { transformers.push(ts.transformES5); } @@ -46431,7 +48948,7 @@ var ts; } ts.getTransformers = getTransformers; function transformFiles(resolver, host, sourceFiles, transformers) { - var enabledSyntaxKindFeatures = new Array(298); + var enabledSyntaxKindFeatures = new Array(301); var lexicalEnvironmentDisabled = false; var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; @@ -46452,16 +48969,19 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, - onSubstituteNode: function (_emitContext, node) { return node; }, + onSubstituteNode: function (_, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, + onEmitNode: function (hint, node, callback) { return callback(hint, node); }, enableEmitNotification: enableEmitNotification, isEmitNotificationEnabled: isEmitNotificationEnabled }; + ts.performance.mark("beforeTransform"); var transformation = ts.chain.apply(void 0, transformers)(context); var transformed = ts.map(sourceFiles, transformSourceFile); lexicalEnvironmentDisabled = true; + ts.performance.mark("afterTransform"); + ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { transformed: transformed, emitNodeWithSubstitution: emitNodeWithSubstitution, @@ -46480,16 +49000,12 @@ var ts; return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0 && (ts.getEmitFlags(node) & 4) === 0; } - function emitNodeWithSubstitution(emitContext, node, emitCallback) { + function emitNodeWithSubstitution(hint, node, emitCallback) { if (node) { if (isSubstitutionEnabled(node)) { - var substitute = context.onSubstituteNode(emitContext, node); - if (substitute && substitute !== node) { - emitCallback(emitContext, substitute); - return; - } + node = context.onSubstituteNode(hint, node) || node; } - emitCallback(emitContext, node); + emitCallback(hint, node); } } function enableEmitNotification(kind) { @@ -46499,13 +49015,13 @@ var ts; return (enabledSyntaxKindFeatures[node.kind] & 2) !== 0 || (ts.getEmitFlags(node) & 2) !== 0; } - function emitNodeWithNotification(emitContext, node, emitCallback) { + function emitNodeWithNotification(hint, node, emitCallback) { if (node) { if (isEmitNotificationEnabled(node)) { - context.onEmitNode(emitContext, node, emitCallback); + context.onEmitNode(hint, node, emitCallback); } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } } @@ -46587,21 +49103,22 @@ var ts; } } ts.transformFiles = transformFiles; - var _a; })(ts || (ts = {})); var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, targetSourceFile) { var declarationDiagnostics = ts.createDiagnosticCollection(); - ts.forEachExpectedEmitFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); + ts.forEachEmittedFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined); - function getDeclarationDiagnosticsFromFile(_a, sources, isBundledEmit) { + function getDeclarationDiagnosticsFromFile(_a, sourceFileOrBundle) { var declarationFilePath = _a.declarationFilePath; - emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit, false); + emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sourceFileOrBundle, false); } } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles) { + function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles) { + var sourceFiles = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var isBundledEmit = sourceFileOrBundle.kind === 265; var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -46663,7 +49180,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 235); + ts.Debug.assert(aliasEmitInfo.node.kind === 237); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -46686,9 +49203,9 @@ var ts; } }); if (usedTypeDirectiveReferences) { - for (var directive in usedTypeDirectiveReferences) { + ts.forEachKey(usedTypeDirectiveReferences, function (directive) { referencesOutput += "/// " + newLine; - } + }); } return { reportedDeclarationError: reportedDeclarationError, @@ -46713,6 +49230,7 @@ var ts; var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; writer.reportInaccessibleThisError = reportInaccessibleThisError; + writer.reportIllegalExtends = reportIllegalExtends; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -46735,10 +49253,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 223) { + if (declaration.kind === 225) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 238 || declaration.kind === 239 || declaration.kind === 236) { + else if (declaration.kind === 240 || declaration.kind === 241 || declaration.kind === 238) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -46749,7 +49267,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 235) { + if (moduleElementEmitInfo.node.kind === 237) { moduleElementEmitInfo.isVisible = true; } else { @@ -46757,12 +49275,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 230) { + if (nodeToCheck.kind === 232) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 230) { + if (nodeToCheck.kind === 232) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -46781,8 +49299,8 @@ var ts; } for (var _i = 0, typeReferenceDirectives_1 = typeReferenceDirectives; _i < typeReferenceDirectives_1.length; _i++) { var directive = typeReferenceDirectives_1[_i]; - if (!(directive in usedTypeDirectiveReferences)) { - usedTypeDirectiveReferences[directive] = directive; + if (!usedTypeDirectiveReferences.has(directive)) { + usedTypeDirectiveReferences.set(directive, directive); } } } @@ -46809,6 +49327,12 @@ var ts; handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); } + function reportIllegalExtends() { + if (errorNameNode) { + reportedDeclarationError = true; + emitterDiagnostics.add(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced, ts.declarationNameToString(errorNameNode))); + } + } function reportInaccessibleThisError() { if (errorNameNode) { reportedDeclarationError = true; @@ -46818,12 +49342,16 @@ var ts; function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); - if (type) { + var shouldUseResolverType = declaration.kind === 145 && + resolver.isRequiredInitializedParameter(declaration); + if (type && !shouldUseResolverType) { emitType(type); } else { errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 | 1024, writer); + var format = 2 | 1024 | + (shouldUseResolverType ? 4096 : 0); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer); errorNameNode = undefined; } } @@ -46875,49 +49403,50 @@ var ts; function emitType(type) { switch (type.kind) { case 118: - case 134: + case 135: case 132: case 121: - case 135: + case 133: + case 136: case 104: - case 137: + case 138: case 94: case 129: - case 167: - case 171: - return writeTextOfNode(currentText, type); - case 199: - return emitExpressionWithTypeArguments(type); - case 157: - return emitTypeReference(type); - case 160: - return emitTypeQuery(type); - case 162: - return emitArrayType(type); - case 163: - return emitTupleType(type); - case 164: - return emitUnionType(type); - case 165: - return emitIntersectionType(type); - case 166: - return emitParenType(type); case 168: - return emitTypeOperator(type); - case 169: - return emitIndexedAccessType(type); - case 170: - return emitMappedType(type); + case 172: + return writeTextOfNode(currentText, type); + case 200: + return emitExpressionWithTypeArguments(type); case 158: - case 159: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 161: + return emitTypeQuery(type); + case 163: + return emitArrayType(type); + case 164: + return emitTupleType(type); + case 165: + return emitUnionType(type); + case 166: + return emitIntersectionType(type); + case 167: + return emitParenType(type); + case 169: + return emitTypeOperator(type); + case 170: + return emitIndexedAccessType(type); + case 171: + return emitMappedType(type); + case 159: + case 160: + return emitSignatureDeclarationWithJsDocComments(type); + case 162: return emitTypeLiteral(type); case 70: return emitEntityName(type); - case 141: + case 142: return emitEntityName(type); - case 156: + case 157: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -46925,22 +49454,22 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 141 ? entityName.left : entityName.expression; - var right = entityName.kind === 141 ? entityName.right : entityName.name; + var left = entityName.kind === 142 ? entityName.left : entityName.expression; + var right = entityName.kind === 142 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 234 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 236 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 177); + ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 178); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -47044,15 +49573,15 @@ var ts; } function getExportDefaultTempVariableName() { var baseName = "_default"; - if (!(baseName in currentIdentifiers)) { + if (!currentIdentifiers.has(baseName)) { return baseName; } var count = 0; while (true) { count++; - var name_41 = baseName + "_" + count; - if (!(name_41 in currentIdentifiers)) { - return name_41; + var name = baseName + "_" + count; + if (!currentIdentifiers.has(name)) { + return name; } } } @@ -47096,10 +49625,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 234 || - (node.parent.kind === 261 && isCurrentFileExternalModule)) { + else if (node.kind === 236 || + (node.parent.kind === 264 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 264) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -47108,7 +49637,7 @@ var ts; }); } else { - if (node.kind === 235) { + if (node.kind === 237) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -47126,30 +49655,30 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 225: - return writeFunctionDeclaration(node); - case 205: - return writeVariableStatement(node); case 227: - return writeInterfaceDeclaration(node); - case 226: - return writeClassDeclaration(node); - case 228: - return writeTypeAliasDeclaration(node); + return writeFunctionDeclaration(node); + case 207: + return writeVariableStatement(node); case 229: - return writeEnumDeclaration(node); + return writeInterfaceDeclaration(node); + case 228: + return writeClassDeclaration(node); case 230: + return writeTypeAliasDeclaration(node); + case 231: + return writeEnumDeclaration(node); + case 232: return writeModuleDeclaration(node); - case 234: + case 236: return writeImportEqualsDeclaration(node); - case 235: + case 237: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 261) { + if (node.parent.kind === 264) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -47157,7 +49686,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 227 && !noDeclare) { + else if (node.kind !== 229 && !noDeclare) { write("declare "); } } @@ -47207,7 +49736,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 237) { + if (namedBindings.kind === 239) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -47230,7 +49759,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 237) { + if (node.importClause.namedBindings.kind === 239) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -47247,13 +49776,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 230; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 232; var moduleSpecifier; - if (parent.kind === 234) { + if (parent.kind === 236) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 230) { + else if (parent.kind === 232) { moduleSpecifier = parent.name; } else { @@ -47321,7 +49850,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 231) { + while (node.body && node.body.kind !== 233) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -47391,7 +49920,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 149 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 150 && ts.hasModifier(node.parent, 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -47401,52 +49930,69 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 158 || - node.parent.kind === 159 || - (node.parent.parent && node.parent.parent.kind === 161)) { - ts.Debug.assert(node.parent.kind === 149 || - node.parent.kind === 148 || - node.parent.kind === 158 || + if (node.parent.kind === 159 || + node.parent.kind === 160 || + (node.parent.parent && node.parent.parent.kind === 162)) { + ts.Debug.assert(node.parent.kind === 150 || + node.parent.kind === 149 || node.parent.kind === 159 || - node.parent.kind === 153 || - node.parent.kind === 154); + node.parent.kind === 160 || + node.parent.kind === 154 || + node.parent.kind === 155); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } + if (node.default && !isPrivateMethodTypeParameter(node)) { + write(" = "); + if (node.parent.kind === 159 || + node.parent.kind === 160 || + (node.parent.parent && node.parent.parent.kind === 162)) { + ts.Debug.assert(node.parent.kind === 150 || + node.parent.kind === 149 || + node.parent.kind === 159 || + node.parent.kind === 160 || + node.parent.kind === 154 || + node.parent.kind === 155); + emitType(node.default); + } + else { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.default, getTypeParameterConstraintVisibilityError); + } + } function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 226: + case 228: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 227: + case 229: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 154: + case 155: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 153: + case 154: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 150: case 149: - case 148: if (ts.hasModifier(node.parent, 32)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 226) { + else if (node.parent.parent.kind === 228) { 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 225: + case 227: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 228: + case 230: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -47465,7 +50011,7 @@ var ts; write(">"); } } - function emitHeritageClause(typeReferences, isImplementsList) { + function emitHeritageClause(className, typeReferences, isImplementsList) { if (typeReferences) { write(isImplementsList ? " implements " : " extends "); emitCommaList(typeReferences, emitTypeOfTypeReference); @@ -47479,17 +50025,19 @@ var ts; } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; + errorNameNode = className; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 | 1024, writer); + errorNameNode = undefined; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 226) { + if (node.parent.parent.kind === 228) { 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; + 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; + diagnosticMessage = ts.Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; } return { diagnosticMessage: diagnosticMessage, @@ -47521,9 +50069,10 @@ var ts; emitTypeParameters(node.typeParameters); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); + node.name; + emitHeritageClause(node.name, [baseTypeNode], false); } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), true); + emitHeritageClause(node.name, ts.getClassImplementsHeritageClauseElements(node), true); write(" {"); writeLine(); increaseIndent(); @@ -47544,7 +50093,7 @@ var ts; emitTypeParameters(node.typeParameters); var interfaceExtendsTypes = ts.filter(ts.getInterfaceBaseTypeNodes(node), function (base) { return ts.isEntityNameExpression(base.expression); }); if (interfaceExtendsTypes && interfaceExtendsTypes.length) { - emitHeritageClause(interfaceExtendsTypes, false); + emitHeritageClause(node.name, interfaceExtendsTypes, false); } write(" {"); writeLine(); @@ -47566,17 +50115,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 223 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 225 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 147 || node.kind === 146 || - (node.kind === 144 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 148 || node.kind === 147 || + (node.kind === 145 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 147 || node.kind === 146) && node.parent.kind === 161) { + if ((node.kind === 148 || node.kind === 147) && node.parent.kind === 162) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -47589,14 +50138,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 223) { + if (node.kind === 225) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 147 || node.kind === 146) { + else if (node.kind === 148 || node.kind === 147) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -47604,7 +50153,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 === 226) { + else if (node.parent.kind === 228) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47630,7 +50179,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 198) { + if (element.kind !== 199) { elements.push(element); } } @@ -47696,7 +50245,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 151 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 152 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -47709,7 +50258,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 151 + return accessor.kind === 152 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -47718,7 +50267,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 152) { + if (accessorWithTypeAnnotation.kind === 153) { if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -47764,17 +50313,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 225) { + if (node.kind === 227) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 149 || node.kind === 150) { + else if (node.kind === 150 || node.kind === 151) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 225) { + if (node.kind === 227) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 150) { + else if (node.kind === 151) { write("constructor"); } else { @@ -47794,15 +50343,15 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 155) { + if (node.kind === 156) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { - if (node.kind === 154 || node.kind === 159) { + if (node.kind === 155 || node.kind === 160) { write("new "); } - else if (node.kind === 158) { + else if (node.kind === 159) { var currentOutput = writer.getText(); if (node.typeParameters && currentOutput.charAt(currentOutput.length - 1) === "<") { closeParenthesizedFunctionType = true; @@ -47813,20 +50362,20 @@ var ts; write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 155) { + if (node.kind === 156) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 158 || node.kind === 159; - if (isFunctionTypeOrConstructorType || node.parent.kind === 161) { + var isFunctionTypeOrConstructorType = node.kind === 159 || node.kind === 160; + if (isFunctionTypeOrConstructorType || node.parent.kind === 162) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 150 && !ts.hasModifier(node, 8)) { + else if (node.kind !== 151 && !ts.hasModifier(node, 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -47840,23 +50389,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 154: + case 155: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 153: + case 154: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 155: + case 156: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; + case 150: case 149: - case 148: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -47864,7 +50413,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 === 226) { + else if (node.parent.kind === 228) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -47877,7 +50426,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 225: + case 227: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -47909,9 +50458,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 158 || - node.parent.kind === 159 || - node.parent.parent.kind === 161) { + if (node.parent.kind === 159 || + node.parent.kind === 160 || + node.parent.parent.kind === 162) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8)) { @@ -47927,26 +50476,26 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 150: + case 151: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 154: + case 155: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 153: + case 154: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 155: + case 156: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; + case 150: case 149: - case 148: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -47954,7 +50503,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 === 226) { + else if (node.parent.parent.kind === 228) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47966,7 +50515,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 225: + case 227: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -47977,12 +50526,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 172) { + if (bindingPattern.kind === 173) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 173) { + else if (bindingPattern.kind === 174) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -47993,10 +50542,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 198) { + if (bindingElement.kind === 199) { write(" "); } - else if (bindingElement.kind === 174) { + else if (bindingElement.kind === 175) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -48018,39 +50567,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 225: - case 230: - case 234: case 227: - case 226: - case 228: + case 232: + case 236: case 229: + case 228: + case 230: + case 231: return emitModuleElement(node, isModuleElementVisible(node)); - case 205: + case 207: return emitModuleElement(node, isVariableStatementVisible(node)); - case 235: + case 237: return emitModuleElement(node, !node.importClause); - case 241: + case 243: return emitExportDeclaration(node); + case 151: case 150: case 149: - case 148: return writeFunctionDeclaration(node); - case 154: - case 153: case 155: + case 154: + case 156: return emitSignatureDeclarationWithJsDocComments(node); - case 151: case 152: + case 153: return emitAccessorDeclaration(node); + case 148: case 147: - case 146: return emitPropertyDeclaration(node); - case 260: + case 263: return emitEnumMemberDeclaration(node); - case 240: + case 242: return emitExportAssignment(node); - case 261: + case 264: return emitSourceFile(node); } } @@ -48061,14 +50610,15 @@ var ts; declFileName = referencedFile.fileName; } else { - ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); } if (declFileName) { declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(declarationFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, sourceFileOrBundle) { + var isBundledEmit = sourceFileOrBundle.kind === 265; if (isBundledEmit && !addBundledFileReference) { return; } @@ -48078,10 +50628,11 @@ var ts; } } } - function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { - var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles); + function writeDeclarationFile(declarationFilePath, sourceFileOrBundle, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { + var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { + var sourceFiles = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; var declarationOutput = emitDeclarationResult.referencesOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); ts.writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM, sourceFiles); @@ -48135,7 +50686,7 @@ var ts; getText: getText, getSourceMappingURL: getSourceMappingURL, }; - function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { + function initialize(filePath, sourceMapFilePath, sourceFileOrBundle) { if (disabled) { return; } @@ -48166,9 +50717,8 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (!isBundledEmit) { - ts.Debug.assert(sourceFiles.length === 1); - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFiles[0], host, sourceMapDir)); + if (sourceFileOrBundle.kind === 264) { + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); @@ -48259,28 +50809,28 @@ var ts; ts.performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); } } - function emitNodeWithSourceMap(emitContext, node, emitCallback) { + function emitNodeWithSourceMap(hint, node, emitCallback) { if (disabled) { - return emitCallback(emitContext, node); + return emitCallback(hint, node); } if (node) { var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 293 + if (node.kind !== 297 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); } if (emitFlags & 64) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } - if (node.kind !== 293 + if (node.kind !== 297 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -48381,11 +50931,10 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function createCommentWriter(host, writer, sourceMap) { - var compilerOptions = host.getCompilerOptions(); - var extendedDiagnostics = compilerOptions.extendedDiagnostics; - var newLine = host.getNewLine(); - var emitPos = sourceMap.emitPos; + function createCommentWriter(printerOptions, emitPos) { + var extendedDiagnostics = printerOptions.extendedDiagnostics; + var newLine = ts.getNewLineCharacter(printerOptions); + var writer; var containerPos = -1; var containerEnd = -1; var declarationListContainerEnd = -1; @@ -48394,17 +50943,19 @@ var ts; var currentLineMap; var detachedCommentsInfo; var hasWrittenComment = false; - var disabled = compilerOptions.removeComments; + var disabled = printerOptions.removeComments; return { reset: reset, + setWriter: setWriter, setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, + emitLeadingCommentsOfPosition: emitLeadingCommentsOfPosition, }; - function emitNodeWithComments(emitContext, node, emitCallback) { + function emitNodeWithComments(hint, node, emitCallback) { if (disabled) { - emitCallback(emitContext, node); + emitCallback(hint, node); return; } if (node) { @@ -48413,18 +50964,18 @@ var ts; if ((pos < 0 && end < 0) || (pos === end)) { if (emitFlags & 2048) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } else { if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 293; + var isEmittedNode = node.kind !== 297; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0; if (!skipLeadingComments) { @@ -48438,7 +50989,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 224) { + if (node.kind === 226) { declarationListContainerEnd = end; } } @@ -48447,11 +50998,11 @@ var ts; } if (emitFlags & 2048) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } if (extendedDiagnostics) { ts.performance.mark("beginEmitNodeWithComment"); @@ -48522,9 +51073,11 @@ var ts; ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); hasWrittenComment = true; } - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -48532,6 +51085,12 @@ var ts; writer.write(" "); } } + function emitLeadingCommentsOfPosition(pos) { + if (disabled || pos === -1) { + return; + } + emitLeadingComments(pos, true); + } function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } @@ -48539,9 +51098,11 @@ var ts; if (!writer.isAtStartOfLine()) { writer.write(" "); } - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -48559,9 +51120,11 @@ var ts; } } function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -48590,6 +51153,9 @@ var ts; currentLineMap = undefined; detachedCommentsInfo = undefined; } + function setWriter(output) { + writer = output; + } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; currentText = currentSourceFile.text; @@ -48621,9 +51187,11 @@ var ts; } } function writeComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); } function isTripleSlashComment(commentPos, commentEnd) { if (currentText.charCodeAt(commentPos + 1) === 47 && @@ -48641,44 +51209,39 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var id = function (s) { return s; }; - var nullTransformers = [function (_) { return id; }]; + var delimiters = createDelimiterMap(); + var brackets = createBracketsMap(); function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { - var delimiters = createDelimiterMap(); - var brackets = createBracketsMap(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = emitOnlyDtsFiles ? nullTransformers : ts.getTransformers(compilerOptions); + var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); - var write = writer.write, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var sourceMap = ts.createSourceMapWriter(host, writer); - var emitNodeWithSourceMap = sourceMap.emitNodeWithSourceMap, emitTokenWithSourceMap = sourceMap.emitTokenWithSourceMap; - var comments = ts.createCommentWriter(host, writer, sourceMap); - var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition; - var nodeIdToGeneratedName; - var autoGeneratedIdToGeneratedName; - var generatedNameSet; - var tempFlags; var currentSourceFile; - var currentText; - var currentFileIdentifiers; var bundledHelpers; var isOwnFileEmit; var emitSkipped = false; var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); - ts.performance.mark("beforeTransform"); - var _a = ts.transformFiles(resolver, host, sourceFiles, transformers), transformed = _a.transformed, emitNodeWithSubstitution = _a.emitNodeWithSubstitution, emitNodeWithNotification = _a.emitNodeWithNotification; - ts.performance.measure("transformTime", "beforeTransform"); + var transform = ts.transformFiles(resolver, host, sourceFiles, transformers); + var printer = createPrinter(compilerOptions, { + hasGlobalName: resolver.hasGlobalName, + onEmitNode: transform.emitNodeWithNotification, + onSubstituteNode: transform.emitNodeWithSubstitution, + onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, + onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, + onEmitSourceMapOfPosition: sourceMap.emitPos, + onEmitHelpers: emitHelpers, + onSetSourceFile: setSourceFile, + }); ts.performance.mark("beforePrint"); - ts.forEachTransformedEmitFile(host, transformed, emitFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, emitSourceFileOrBundle, transform.transformed, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); - for (var _b = 0, sourceFiles_4 = sourceFiles; _b < sourceFiles_4.length; _b++) { - var sourceFile = sourceFiles_4[_b]; + for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { + var sourceFile = sourceFiles_2[_a]; ts.disposeEmitNodes(sourceFile); } return { @@ -48687,17 +51250,18 @@ var ts; emittedFiles: emittedFilesList, sourceMaps: sourceMapDataList }; - function emitFile(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, isBundledEmit) { + function emitSourceFileOrBundle(_a, sourceFileOrBundle) { + var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath; if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { if (!emitOnlyDtsFiles) { - printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle); } } else { emitSkipped = true; } if (declarationFilePath) { - emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; + emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFileOrBundle(sourceFileOrBundle), host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; } if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { @@ -48711,24 +51275,24 @@ var ts; } } } - function printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit) { - sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); - nodeIdToGeneratedName = []; - autoGeneratedIdToGeneratedName = []; - generatedNameSet = ts.createMap(); - bundledHelpers = isBundledEmit ? ts.createMap() : undefined; - isOwnFileEmit = !isBundledEmit; - if (isBundledEmit && moduleKind) { - for (var _a = 0, sourceFiles_5 = sourceFiles; _a < sourceFiles_5.length; _a++) { - var sourceFile = sourceFiles_5[_a]; - emitHelpers(sourceFile, true); - } + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle) { + var bundle = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 264 ? sourceFileOrBundle : undefined; + var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; + sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFileOrBundle); + if (bundle) { + bundledHelpers = ts.createMap(); + isOwnFileEmit = false; + printer.writeBundle(bundle, writer); } - ts.forEach(sourceFiles, printSourceFile); - writeLine(); + else { + isOwnFileEmit = true; + printer.writeFile(sourceFile, writer); + } + writer.writeLine(); var sourceMappingURL = sourceMap.getSourceMappingURL(); if (sourceMappingURL) { - write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); + writer.write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); } if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) { ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), false, sourceFiles); @@ -48738,23 +51302,165 @@ var ts; } ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM, sourceFiles); sourceMap.reset(); - comments.reset(); writer.reset(); - tempFlags = 0; currentSourceFile = undefined; - currentText = undefined; + bundledHelpers = undefined; isOwnFileEmit = false; } - function printSourceFile(node) { + function setSourceFile(node) { currentSourceFile = node; - currentText = node.text; - currentFileIdentifiers = node.identifiers; sourceMap.setSourceFile(node); - comments.setSourceFile(node); - pipelineEmitWithNotification(0, node); } - function emit(node) { - pipelineEmitWithNotification(3, node); + function emitHelpers(node, writeLines) { + var helpersEmitted = false; + var bundle = node.kind === 265 ? node : undefined; + if (bundle && moduleKind === ts.ModuleKind.None) { + return; + } + var numNodes = bundle ? bundle.sourceFiles.length : 1; + for (var i = 0; i < numNodes; i++) { + var currentNode = bundle ? bundle.sourceFiles[i] : node; + var sourceFile = ts.isSourceFile(currentNode) ? currentNode : currentSourceFile; + var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldBundle = ts.isSourceFile(currentNode) && !isOwnFileEmit; + var helpers = ts.getEmitHelpers(currentNode); + if (helpers) { + for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { + var helper = _b[_a]; + if (!helper.scoped) { + if (shouldSkip) + continue; + if (shouldBundle) { + if (bundledHelpers.get(helper.name)) { + continue; + } + bundledHelpers.set(helper.name, true); + } + } + else if (bundle) { + continue; + } + writeLines(helper.text); + helpersEmitted = true; + } + } + } + return helpersEmitted; + } + } + ts.emitFiles = emitFiles; + function createPrinter(printerOptions, handlers) { + if (printerOptions === void 0) { printerOptions = {}; } + if (handlers === void 0) { handlers = {}; } + var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, onSubstituteNode = handlers.onSubstituteNode; + var newLine = ts.getNewLineCharacter(printerOptions); + var languageVersion = ts.getEmitScriptTarget(printerOptions); + var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); + var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; + var currentSourceFile; + var nodeIdToGeneratedName; + var autoGeneratedIdToGeneratedName; + var generatedNames; + var tempFlagsStack; + var tempFlags; + var writer; + var ownWriter; + reset(); + return { + printNode: printNode, + printFile: printFile, + printBundle: printBundle, + writeNode: writeNode, + writeFile: writeFile, + writeBundle: writeBundle + }; + function printNode(hint, node, sourceFile) { + switch (hint) { + case 0: + ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); + break; + case 2: + ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); + break; + case 1: + ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); + break; + } + switch (node.kind) { + case 264: return printFile(node); + case 265: return printBundle(node); + } + writeNode(hint, node, sourceFile, beginPrint()); + return endPrint(); + } + function printBundle(bundle) { + writeBundle(bundle, beginPrint()); + return endPrint(); + } + function printFile(sourceFile) { + writeFile(sourceFile, beginPrint()); + return endPrint(); + } + function writeNode(hint, node, sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(hint, node, sourceFile); + reset(); + writer = previousWriter; + } + function writeBundle(bundle, output) { + var previousWriter = writer; + setWriter(output); + emitHelpersIndirect(bundle); + for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + print(0, sourceFile, sourceFile); + } + reset(); + writer = previousWriter; + } + function writeFile(sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(0, sourceFile, sourceFile); + reset(); + writer = previousWriter; + } + function beginPrint() { + return ownWriter || (ownWriter = ts.createTextWriter(newLine)); + } + function endPrint() { + var text = ownWriter.getText(); + ownWriter.reset(); + return text; + } + function print(hint, node, sourceFile) { + setSourceFile(sourceFile); + pipelineEmitWithNotification(hint, node); + } + function setSourceFile(sourceFile) { + currentSourceFile = sourceFile; + comments.setSourceFile(sourceFile); + if (onSetSourceFile) { + onSetSourceFile(sourceFile); + } + } + function setWriter(output) { + writer = output; + comments.setWriter(output); + } + function reset() { + nodeIdToGeneratedName = []; + autoGeneratedIdToGeneratedName = []; + generatedNames = ts.createMap(); + tempFlagsStack = []; + tempFlags = 0; + comments.reset(); + setWriter(undefined); + } + function emit(node, hint) { + if (hint === void 0) { hint = 3; } + pipelineEmitWithNotification(hint, node); } function emitIdentifierName(node) { pipelineEmitWithNotification(2, node); @@ -48762,51 +51468,60 @@ var ts; function emitExpression(node) { pipelineEmitWithNotification(1, node); } - function pipelineEmitWithNotification(emitContext, node) { - emitNodeWithNotification(emitContext, node, pipelineEmitWithComments); + function pipelineEmitWithNotification(hint, node) { + if (onEmitNode) { + onEmitNode(hint, node, pipelineEmitWithComments); + } + else { + pipelineEmitWithComments(hint, node); + } } - function pipelineEmitWithComments(emitContext, node) { - if (emitContext === 0) { - pipelineEmitWithSourceMap(emitContext, node); + function pipelineEmitWithComments(hint, node) { + if (emitNodeWithComments && hint !== 0) { + emitNodeWithComments(hint, node, pipelineEmitWithSourceMap); + } + else { + pipelineEmitWithSourceMap(hint, node); + } + } + function pipelineEmitWithSourceMap(hint, node) { + if (onEmitSourceMapOfNode && hint !== 0 && hint !== 2) { + onEmitSourceMapOfNode(hint, node, pipelineEmitWithSubstitution); + } + else { + pipelineEmitWithSubstitution(hint, node); + } + } + function pipelineEmitWithSubstitution(hint, node) { + if (onSubstituteNode) { + onSubstituteNode(hint, node, pipelineEmitWithHint); + } + else { + pipelineEmitWithHint(hint, node); + } + } + function pipelineEmitWithHint(hint, node) { + switch (hint) { + case 0: return pipelineEmitSourceFile(node); + case 2: return pipelineEmitIdentifierName(node); + case 1: return pipelineEmitExpression(node); + case 3: return pipelineEmitUnspecified(node); + } + } + function pipelineEmitSourceFile(node) { + ts.Debug.assertNode(node, ts.isSourceFile); + emitSourceFile(node); + } + function pipelineEmitIdentifierName(node) { + ts.Debug.assertNode(node, ts.isIdentifier); + emitIdentifier(node); + } + function pipelineEmitUnspecified(node) { + var kind = node.kind; + if (ts.isKeyword(kind)) { + writeTokenText(kind); return; } - emitNodeWithComments(emitContext, node, pipelineEmitWithSourceMap); - } - function pipelineEmitWithSourceMap(emitContext, node) { - if (emitContext === 0 - || emitContext === 2) { - pipelineEmitWithSubstitution(emitContext, node); - return; - } - emitNodeWithSourceMap(emitContext, node, pipelineEmitWithSubstitution); - } - function pipelineEmitWithSubstitution(emitContext, node) { - emitNodeWithSubstitution(emitContext, node, pipelineEmitForContext); - } - function pipelineEmitForContext(emitContext, node) { - switch (emitContext) { - case 0: return pipelineEmitInSourceFileContext(node); - case 2: return pipelineEmitInIdentifierNameContext(node); - case 3: return pipelineEmitInUnspecifiedContext(node); - case 1: return pipelineEmitInExpressionContext(node); - } - } - function pipelineEmitInSourceFileContext(node) { - var kind = node.kind; - switch (kind) { - case 261: - return emitSourceFile(node); - } - } - function pipelineEmitInIdentifierNameContext(node) { - var kind = node.kind; - switch (kind) { - case 70: - return emitIdentifier(node); - } - } - function pipelineEmitInUnspecifiedContext(node) { - var kind = node.kind; switch (kind) { case 13: case 14: @@ -48814,229 +51529,197 @@ var ts; return emitLiteral(node); case 70: return emitIdentifier(node); - case 75: - case 78: - case 83: - case 104: - case 111: - case 112: - case 113: - case 114: - case 116: - case 117: - case 118: - case 119: - case 120: - case 121: - case 122: - case 123: - case 124: - case 125: - case 127: - case 128: - case 129: - case 130: - case 131: - case 132: - case 133: - case 134: - case 135: - case 136: - case 137: - case 138: - case 139: - case 140: - writeTokenText(kind); - return; - case 141: - return emitQualifiedName(node); case 142: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 143: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 144: - return emitParameter(node); + return emitTypeParameter(node); case 145: - return emitDecorator(node); + return emitParameter(node); case 146: - return emitPropertySignature(node); + return emitDecorator(node); case 147: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 148: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 149: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 150: - return emitConstructor(node); + return emitMethodDeclaration(node); case 151: + return emitConstructor(node); case 152: - return emitAccessorDeclaration(node); case 153: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 154: - return emitConstructSignature(node); + return emitCallSignature(node); case 155: - return emitIndexSignature(node); + return emitConstructSignature(node); case 156: - return emitTypePredicate(node); + return emitIndexSignature(node); case 157: - return emitTypeReference(node); + return emitTypePredicate(node); case 158: - return emitFunctionType(node); + return emitTypeReference(node); case 159: - return emitConstructorType(node); + return emitFunctionType(node); case 160: - return emitTypeQuery(node); + return emitConstructorType(node); case 161: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 162: - return emitArrayType(node); + return emitTypeLiteral(node); case 163: - return emitTupleType(node); + return emitArrayType(node); case 164: - return emitUnionType(node); + return emitTupleType(node); case 165: - return emitIntersectionType(node); + return emitUnionType(node); case 166: - return emitParenthesizedType(node); - case 199: - return emitExpressionWithTypeArguments(node); + return emitIntersectionType(node); case 167: - return emitThisType(); + return emitParenthesizedType(node); + case 200: + return emitExpressionWithTypeArguments(node); case 168: - return emitTypeOperator(node); + return emitThisType(); case 169: - return emitIndexedAccessType(node); + return emitTypeOperator(node); case 170: - return emitMappedType(node); + return emitIndexedAccessType(node); case 171: - return emitLiteralType(node); + return emitMappedType(node); case 172: - return emitObjectBindingPattern(node); + return emitLiteralType(node); case 173: - return emitArrayBindingPattern(node); + return emitObjectBindingPattern(node); case 174: + return emitArrayBindingPattern(node); + case 175: return emitBindingElement(node); - case 202: - return emitTemplateSpan(node); - case 203: - return emitSemicolonClassElement(); case 204: - return emitBlock(node); + return emitTemplateSpan(node); case 205: - return emitVariableStatement(node); + return emitSemicolonClassElement(); case 206: - return emitEmptyStatement(); + return emitBlock(node); case 207: - return emitExpressionStatement(node); + return emitVariableStatement(node); case 208: - return emitIfStatement(node); + return emitEmptyStatement(); case 209: - return emitDoStatement(node); + return emitExpressionStatement(node); case 210: - return emitWhileStatement(node); + return emitIfStatement(node); case 211: - return emitForStatement(node); + return emitDoStatement(node); case 212: - return emitForInStatement(node); + return emitWhileStatement(node); case 213: - return emitForOfStatement(node); + return emitForStatement(node); case 214: - return emitContinueStatement(node); + return emitForInStatement(node); case 215: - return emitBreakStatement(node); + return emitForOfStatement(node); case 216: - return emitReturnStatement(node); + return emitContinueStatement(node); case 217: - return emitWithStatement(node); + return emitBreakStatement(node); case 218: - return emitSwitchStatement(node); + return emitReturnStatement(node); case 219: - return emitLabeledStatement(node); + return emitWithStatement(node); case 220: - return emitThrowStatement(node); + return emitSwitchStatement(node); case 221: - return emitTryStatement(node); + return emitLabeledStatement(node); case 222: - return emitDebuggerStatement(node); + return emitThrowStatement(node); case 223: - return emitVariableDeclaration(node); + return emitTryStatement(node); case 224: - return emitVariableDeclarationList(node); + return emitDebuggerStatement(node); case 225: - return emitFunctionDeclaration(node); + return emitVariableDeclaration(node); case 226: - return emitClassDeclaration(node); + return emitVariableDeclarationList(node); case 227: - return emitInterfaceDeclaration(node); + return emitFunctionDeclaration(node); case 228: - return emitTypeAliasDeclaration(node); + return emitClassDeclaration(node); case 229: - return emitEnumDeclaration(node); + return emitInterfaceDeclaration(node); case 230: - return emitModuleDeclaration(node); + return emitTypeAliasDeclaration(node); case 231: - return emitModuleBlock(node); + return emitEnumDeclaration(node); case 232: - return emitCaseBlock(node); + return emitModuleDeclaration(node); + case 233: + return emitModuleBlock(node); case 234: - return emitImportEqualsDeclaration(node); - case 235: - return emitImportDeclaration(node); + return emitCaseBlock(node); case 236: - return emitImportClause(node); + return emitImportEqualsDeclaration(node); case 237: - return emitNamespaceImport(node); + return emitImportDeclaration(node); case 238: - return emitNamedImports(node); + return emitImportClause(node); case 239: - return emitImportSpecifier(node); + return emitNamespaceImport(node); case 240: - return emitExportAssignment(node); + return emitNamedImports(node); case 241: - return emitExportDeclaration(node); + return emitImportSpecifier(node); case 242: - return emitNamedExports(node); + return emitExportAssignment(node); case 243: - return emitExportSpecifier(node); + return emitExportDeclaration(node); case 244: - return; + return emitNamedExports(node); case 245: + return emitExportSpecifier(node); + case 246: + return; + case 247: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 248: - return emitJsxOpeningElement(node); - case 249: - return emitJsxClosingElement(node); case 250: - return emitJsxAttribute(node); + return emitJsxOpeningElement(node); case 251: - return emitJsxSpreadAttribute(node); + return emitJsxClosingElement(node); case 252: - return emitJsxExpression(node); + return emitJsxAttribute(node); case 253: - return emitCaseClause(node); + return emitJsxAttributes(node); case 254: - return emitDefaultClause(node); + return emitJsxSpreadAttribute(node); case 255: - return emitHeritageClause(node); + return emitJsxExpression(node); case 256: - return emitCatchClause(node); + return emitCaseClause(node); case 257: - return emitPropertyAssignment(node); + return emitDefaultClause(node); case 258: - return emitShorthandPropertyAssignment(node); + return emitHeritageClause(node); case 259: - return emitSpreadAssignment(node); + return emitCatchClause(node); case 260: + return emitPropertyAssignment(node); + case 261: + return emitShorthandPropertyAssignment(node); + case 262: + return emitSpreadAssignment(node); + case 263: return emitEnumMember(node); } if (ts.isExpression(node)) { return pipelineEmitWithSubstitution(1, node); } } - function pipelineEmitInExpressionContext(node) { + function pipelineEmitExpression(node) { var kind = node.kind; switch (kind) { case 8: @@ -49054,66 +51737,79 @@ var ts; case 98: writeTokenText(kind); return; - case 175: - return emitArrayLiteralExpression(node); case 176: - return emitObjectLiteralExpression(node); + return emitArrayLiteralExpression(node); case 177: - return emitPropertyAccessExpression(node); + return emitObjectLiteralExpression(node); case 178: - return emitElementAccessExpression(node); + return emitPropertyAccessExpression(node); case 179: - return emitCallExpression(node); + return emitElementAccessExpression(node); case 180: - return emitNewExpression(node); + return emitCallExpression(node); case 181: - return emitTaggedTemplateExpression(node); + return emitNewExpression(node); case 182: - return emitTypeAssertionExpression(node); + return emitTaggedTemplateExpression(node); case 183: - return emitParenthesizedExpression(node); + return emitTypeAssertionExpression(node); case 184: - return emitFunctionExpression(node); + return emitParenthesizedExpression(node); case 185: - return emitArrowFunction(node); + return emitFunctionExpression(node); case 186: - return emitDeleteExpression(node); + return emitArrowFunction(node); case 187: - return emitTypeOfExpression(node); + return emitDeleteExpression(node); case 188: - return emitVoidExpression(node); + return emitTypeOfExpression(node); case 189: - return emitAwaitExpression(node); + return emitVoidExpression(node); case 190: - return emitPrefixUnaryExpression(node); + return emitAwaitExpression(node); case 191: - return emitPostfixUnaryExpression(node); + return emitPrefixUnaryExpression(node); case 192: - return emitBinaryExpression(node); + return emitPostfixUnaryExpression(node); case 193: - return emitConditionalExpression(node); + return emitBinaryExpression(node); case 194: - return emitTemplateExpression(node); + return emitConditionalExpression(node); case 195: - return emitYieldExpression(node); + return emitTemplateExpression(node); case 196: - return emitSpreadExpression(node); + return emitYieldExpression(node); case 197: - return emitClassExpression(node); + return emitSpreadExpression(node); case 198: + return emitClassExpression(node); + case 199: return; - case 200: - return emitAsExpression(node); case 201: + return emitAsExpression(node); + case 202: return emitNonNullExpression(node); - case 246: + case 203: + return emitMetaProperty(node); + case 248: return emitJsxElement(node); - case 247: + case 249: return emitJsxSelfClosingElement(node); - case 294: + case 298: return emitPartiallyEmittedExpression(node); - case 297: - return writeLines(node.text); + } + } + function emitBodyIndirect(node, elements, emitCallback) { + if (emitBodyWithDetachedComments) { + emitBodyWithDetachedComments(node, elements, emitCallback); + } + else { + emitCallback(node); + } + } + function emitHelpersIndirect(node) { + if (onEmitHelpers) { + onEmitHelpers(node, writeLines); } } function emitNumericLiteral(node) { @@ -49124,7 +51820,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralTextOfNode(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) + if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } @@ -49211,7 +51907,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 151 ? "get " : "set "); + write(node.kind === 152 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -49311,17 +52007,13 @@ var ts; write("{"); writeLine(); increaseIndent(); - if (node.readonlyToken) { - write("readonly "); - } + writeIfPresent(node.readonlyToken, "readonly "); write("["); emit(node.typeParameter.name); write(" in "); emit(node.typeParameter.constraint); write("]"); - if (node.questionToken) { - write("?"); - } + writeIfPresent(node.questionToken, "?"); write(": "); emit(node.type); write(";"); @@ -49393,7 +52085,7 @@ var ts; var indentAfterDot = false; if (!(ts.getEmitFlags(node) & 65536)) { var dotRangeStart = node.expression.end; - var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; + var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; var dotToken = { kind: 22, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); @@ -49409,13 +52101,15 @@ var ts; function needsDotDotForPropertyAccess(expression) { if (expression.kind === 8) { var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(22)) < 0; + return ts.getNumericLiteralFlags(text, 15) === 0 + && !expression.isOctalLiteral + && text.indexOf(ts.tokenToString(22)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { var constantValue = ts.getConstantValue(expression); return isFinite(constantValue) && Math.floor(constantValue) === constantValue - && compilerOptions.removeComments; + && printerOptions.removeComments; } } function emitElementAccessExpression(node) { @@ -49441,11 +52135,9 @@ var ts; emitExpression(node.template); } function emitTypeAssertionExpression(node) { - if (node.type) { - write("<"); - emit(node.type); - write(">"); - } + write("<"); + emit(node.type); + write(">"); emitExpression(node.expression); } function emitParenthesizedExpression(node) { @@ -49492,7 +52184,7 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 190 + return operand.kind === 191 && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); } @@ -49558,6 +52250,11 @@ var ts; emitExpression(node.expression); write("!"); } + function emitMetaProperty(node) { + writeToken(node.keywordToken, node.pos); + write("."); + emit(node.name); + } function emitTemplateSpan(node) { emitExpression(node.expression); emit(node.literal); @@ -49571,6 +52268,9 @@ var ts; else { writeToken(16, node.pos, node); emitBlockStatements(node); + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); writeToken(17, node.statements.end, node); } } @@ -49600,27 +52300,27 @@ var ts; writeToken(18, openParenPos, node); emitExpression(node.expression); writeToken(19, node.expression.end, node); - emitEmbeddedStatement(node.thenStatement); + emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { - writeLine(); + writeLineOrSpace(node); writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 208) { + if (node.elseStatement.kind === 210) { write(" "); emit(node.elseStatement); } else { - emitEmbeddedStatement(node.elseStatement); + emitEmbeddedStatement(node, node.elseStatement); } } } function emitDoStatement(node) { write("do"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { write(" "); } else { - writeLine(); + writeLineOrSpace(node); } write("while ("); emitExpression(node.expression); @@ -49630,7 +52330,7 @@ var ts; write("while ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -49642,7 +52342,7 @@ var ts; write(";"); emitExpressionWithPrefix(" ", node.incrementor); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -49652,7 +52352,7 @@ var ts; write(" in "); emitExpression(node.expression); writeToken(19, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { var openParenPos = writeToken(87, node.pos); @@ -49662,11 +52362,11 @@ var ts; write(" of "); emitExpression(node.expression); writeToken(19, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 224) { + if (node.kind === 226) { emit(node); } else { @@ -49693,7 +52393,7 @@ var ts; write("with ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { var openParenPos = writeToken(97, node.pos); @@ -49717,9 +52417,12 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchClause); + if (node.catchClause) { + writeLineOrSpace(node); + emit(node.catchClause); + } if (node.finallyBlock) { - writeLine(); + writeLineOrSpace(node); write("finally "); emit(node.finallyBlock); } @@ -49760,11 +52463,10 @@ var ts; emitBlockFunctionBody(body); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); emitSignatureHead(node); emitBlockFunctionBody(body); - tempFlags = savedTempFlags; + popNameGenerationScope(); } if (indentedFlag) { decreaseIndent(); @@ -49813,9 +52515,10 @@ var ts; function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) + var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine - : emitBlockFunctionBodyWorker); + : emitBlockFunctionBodyWorker; + emitBodyIndirect(body, body.statements, emitBlockFunctionBody); decreaseIndent(); writeToken(17, body.statements.end, body); } @@ -49824,8 +52527,9 @@ var ts; } function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) { var statementOffset = emitPrologueDirectives(body.statements, true); - var helpersEmitted = emitHelpers(body); - if (statementOffset === 0 && !helpersEmitted && emitBlockFunctionBodyOnSingleLine) { + var pos = writer.getTextPos(); + emitHelpersIndirect(body); + if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); emitList(body, body.statements, 384); increaseIndent(); @@ -49848,15 +52552,14 @@ var ts; } emitTypeParameters(node, node.typeParameters); emitList(node, node.heritageClauses, 256); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 65); write("}"); + popNameGenerationScope(); if (indentedFlag) { decreaseIndent(); } - tempFlags = savedTempFlags; } function emitInterfaceDeclaration(node) { emitDecorators(node, node.decorators); @@ -49883,19 +52586,18 @@ var ts; emitModifiers(node, node.modifiers); write("enum "); emit(node.name); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 81); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 230) { + while (body.kind === 232) { write("."); emit(body.name); body = body.body; @@ -49908,13 +52610,12 @@ var ts; write("{ }"); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write("{"); increaseIndent(); emitBlockStatements(node); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } } function emitCaseBlock(node) { @@ -50016,14 +52717,18 @@ var ts; write("<"); emitJsxTagName(node.tagName); write(" "); - emitList(node, node.attributes, 131328); + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write("/>"); } function emitJsxOpeningElement(node) { write("<"); emitJsxTagName(node.tagName); - writeIfAny(node.attributes, " "); - emitList(node, node.attributes, 131328); + writeIfAny(node.attributes.properties, " "); + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write(">"); } function emitJsxText(node) { @@ -50034,6 +52739,9 @@ var ts; emitJsxTagName(node.tagName); write(">"); } + function emitJsxAttributes(node) { + emitList(node, node.properties, 131328); + } function emitJsxAttribute(node) { emit(node.name); emitWithPrefix("=", node.initializer); @@ -50046,6 +52754,9 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); + if (node.dotDotDotToken) { + write("..."); + } emitExpression(node.expression); write("}"); } @@ -50088,7 +52799,6 @@ var ts; emitList(node, node.types, 272); } function emitCatchClause(node) { - writeLine(); var openParenPos = writeToken(73, node.pos); write(" "); writeToken(18, openParenPos); @@ -50101,7 +52811,7 @@ var ts; emit(node.name); write(": "); var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512) === 0) { + if (emitTrailingCommentsOfPosition && (ts.getEmitFlags(initializer) & 512) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -50127,16 +52837,15 @@ var ts; function emitSourceFile(node) { writeLine(); emitShebang(); - emitBodyWithDetachedComments(node, node.statements, emitSourceFileWorker); + emitBodyIndirect(node, node.statements, emitSourceFileWorker); } function emitSourceFileWorker(node) { var statements = node.statements; var statementOffset = emitPrologueDirectives(statements); - var savedTempFlags = tempFlags; - tempFlags = 0; - emitHelpers(node); + pushNameGenerationScope(); + emitHelpersIndirect(node); emitList(node, statements, 1, statementOffset); - tempFlags = savedTempFlags; + popNameGenerationScope(); } function emitPartiallyEmittedExpression(node) { emitExpression(node.expression); @@ -50155,67 +52864,8 @@ var ts; } return statements.length; } - function emitHelpers(node, isBundle) { - var sourceFile = ts.isSourceFile(node) ? node : currentSourceFile; - var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); - var shouldBundle = ts.isSourceFile(node) && !isOwnFileEmit; - var helpersEmitted = false; - var helpers = ts.getEmitHelpers(node); - if (helpers) { - for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { - var helper = _b[_a]; - if (!helper.scoped) { - if (shouldSkip) - continue; - if (shouldBundle) { - if (bundledHelpers[helper.name]) { - continue; - } - bundledHelpers[helper.name] = true; - } - } - else if (isBundle) { - continue; - } - writeLines(helper.text); - helpersEmitted = true; - } - } - if (helpersEmitted) { - writeLine(); - } - return helpersEmitted; - } - function writeLines(text) { - var lines = text.split(/\r\n?|\n/g); - var indentation = guessIndentation(lines); - for (var i = 0; i < lines.length; i++) { - var line = indentation ? lines[i].slice(indentation) : lines[i]; - if (line.length) { - if (i > 0) { - writeLine(); - } - write(line); - } - } - } - function guessIndentation(lines) { - var indentation; - for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { - var line = lines_1[_a]; - for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { - if (!ts.isWhiteSpace(line.charCodeAt(i))) { - if (indentation === undefined || i < indentation) { - indentation = i; - break; - } - } - } - } - return indentation; - } function emitShebang() { - var shebang = ts.getShebang(currentText); + var shebang = ts.getShebang(currentSourceFile.text); if (shebang) { write(shebang); writeLine(); @@ -50245,8 +52895,8 @@ var ts; write(suffix); } } - function emitEmbeddedStatement(node) { - if (ts.isBlock(node)) { + function emitEmbeddedStatement(parent, node) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1) { write(" "); emit(node); } @@ -50330,6 +52980,9 @@ var ts; for (var i = 0; i < count; i++) { var child = children[start + i]; if (previousSibling) { + if (delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } write(delimiter); if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { if ((format & (3 | 64)) === 0) { @@ -50344,8 +52997,10 @@ var ts; } } if (shouldEmitInterveningComments) { - var commentRange = ts.getCommentRange(child); - emitTrailingCommentsOfPosition(commentRange.pos); + if (emitTrailingCommentsOfPosition) { + var commentRange = ts.getCommentRange(child); + emitTrailingCommentsOfPosition(commentRange.pos); + } } else { shouldEmitInterveningComments = mayEmitInterveningComments; @@ -50361,6 +53016,9 @@ var ts; if (format & 16 && hasTrailingComma) { write(","); } + if (previousSibling && delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } if (format & 64) { decreaseIndent(); } @@ -50375,24 +53033,73 @@ var ts; write(getClosingBracket(format)); } } + function write(s) { + writer.write(s); + } + function writeLine() { + writer.writeLine(); + } + function increaseIndent() { + writer.increaseIndent(); + } + function decreaseIndent() { + writer.decreaseIndent(); + } function writeIfAny(nodes, text) { - if (nodes && nodes.length > 0) { + if (ts.some(nodes)) { write(text); } } function writeIfPresent(node, text) { - if (node !== undefined) { + if (node) { write(text); } } function writeToken(token, pos, contextNode) { - return emitTokenWithSourceMap(contextNode, token, pos, writeTokenText); + return onEmitSourceMapOfToken + ? onEmitSourceMapOfToken(contextNode, token, pos, writeTokenText) + : writeTokenText(token, pos); } function writeTokenText(token, pos) { var tokenString = ts.tokenToString(token); write(tokenString); return pos < 0 ? pos : pos + tokenString.length; } + function writeLineOrSpace(node) { + if (ts.getEmitFlags(node) & 1) { + write(" "); + } + else { + writeLine(); + } + } + function writeLines(text) { + var lines = text.split(/\r\n?|\n/g); + var indentation = guessIndentation(lines); + for (var i = 0; i < lines.length; i++) { + var line = indentation ? lines[i].slice(indentation) : lines[i]; + if (line.length) { + writeLine(); + write(line); + writeLine(); + } + } + } + function guessIndentation(lines) { + var indentation; + for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { + var line = lines_1[_a]; + for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { + if (!ts.isWhiteSpace(line.charCodeAt(i))) { + if (indentation === undefined || i < indentation) { + indentation = i; + break; + } + } + } + } + return indentation; + } function increaseIndentIf(value, valueToWriteWhenNotIndenting) { if (value) { increaseIndent(); @@ -50497,15 +53204,23 @@ var ts; && !ts.nodeIsSynthesized(node2) && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } + function isSingleLineEmptyBlock(block) { + return !block.multiLine + && isEmptyBlock(block); + } + function isEmptyBlock(block) { + return block.statements.length === 0 + && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + } function skipSynthesizedParentheses(node) { - while (node.kind === 183 && ts.nodeIsSynthesized(node)) { + while (node.kind === 184 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; } function getTextOfNode(node, includeTrivia) { if (ts.isGeneratedIdentifier(node)) { - return getGeneratedIdentifier(node); + return generateName(node); } else if (ts.isIdentifier(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { return ts.unescapeIdentifier(node.text); @@ -50530,23 +53245,37 @@ var ts; } return ts.getLiteralText(node, currentSourceFile, languageVersion); } - function isSingleLineEmptyBlock(block) { - return !block.multiLine - && isEmptyBlock(block); + function pushNameGenerationScope() { + tempFlagsStack.push(tempFlags); + tempFlags = 0; } - function isEmptyBlock(block) { - return block.statements.length === 0 - && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + function popNameGenerationScope() { + tempFlags = tempFlagsStack.pop(); + } + function generateName(name) { + if (name.autoGenerateKind === 4) { + var node = getNodeForGeneratedName(name); + return generateNameCached(node); + } + else { + var autoGenerateId = name.autoGenerateId; + return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(makeName(name))); + } + } + function generateNameCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); } function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentFileIdentifiers, name) && - !ts.hasProperty(generatedNameSet, name); + return !(hasGlobalName && hasGlobalName(name)) + && !currentSourceFile.identifiers.has(name) + && !generatedNames.has(name); } function isUniqueLocalName(name, container) { for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { + if (node.locals) { + var local = node.locals.get(name); + if (local && local.flags & (107455 | 1048576 | 8388608)) { return false; } } @@ -50555,21 +53284,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_42 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_42)) { + var name = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name)) { tempFlags |= flags; - return name_42; + return name; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_43 = count < 26 + var name = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_43)) { - return name_43; + if (isUniqueName(name)) { + return name; } } } @@ -50582,7 +53311,8 @@ var ts; while (true) { var generatedName = baseName + i; if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; + generatedNames.set(generatedName, generatedName); + return generatedName; } i++; } @@ -50603,34 +53333,44 @@ var ts; function generateNameForClassExpression() { return makeUniqueName("class"); } + function generateNameForMethodOrAccessor(node) { + if (ts.isIdentifier(node.name)) { + return generateNameCached(node.name); + } + return makeTempVariableName(0); + } function generateNameForNode(node) { switch (node.kind) { case 70: return makeUniqueName(getTextOfNode(node)); - case 230: - case 229: + case 232: + case 231: return generateNameForModuleOrEnum(node); - case 235: - case 241: + case 237: + case 243: return generateNameForImportOrExportDeclaration(node); - case 225: - case 226: - case 240: + case 227: + case 228: + case 242: return generateNameForExportDefault(); - case 197: + case 198: return generateNameForClassExpression(); + case 150: + case 152: + case 153: + return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0); } } - function generateName(name) { + function makeName(name) { switch (name.autoGenerateKind) { case 1: return makeTempVariableName(0); case 2: return makeTempVariableName(268435456); case 3: - return makeUniqueName(name.text); + return makeUniqueName(ts.unescapeIdentifier(name.text)); } ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } @@ -50649,44 +53389,101 @@ var ts; } return node; } - function getGeneratedIdentifier(name) { - if (name.autoGenerateKind === 4) { - var node = getNodeForGeneratedName(name); - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); - } - else { - var autoGenerateId = name.autoGenerateId; - return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(generateName(name))); - } - } - function createDelimiterMap() { - var delimiters = []; - delimiters[0] = ""; - delimiters[16] = ","; - delimiters[4] = " |"; - delimiters[8] = " &"; - return delimiters; - } - function getDelimiter(format) { - return delimiters[format & 28]; - } - function createBracketsMap() { - var brackets = []; - brackets[512] = ["{", "}"]; - brackets[1024] = ["(", ")"]; - brackets[2048] = ["<", ">"]; - brackets[4096] = ["[", "]"]; - return brackets; - } - function getOpeningBracket(format) { - return brackets[format & 7680][0]; - } - function getClosingBracket(format) { - return brackets[format & 7680][1]; - } } - ts.emitFiles = emitFiles; + ts.createPrinter = createPrinter; + function createDelimiterMap() { + var delimiters = []; + delimiters[0] = ""; + delimiters[16] = ","; + delimiters[4] = " |"; + delimiters[8] = " &"; + return delimiters; + } + function getDelimiter(format) { + return delimiters[format & 28]; + } + function createBracketsMap() { + var brackets = []; + brackets[512] = ["{", "}"]; + brackets[1024] = ["(", ")"]; + brackets[2048] = ["<", ">"]; + brackets[4096] = ["[", "]"]; + return brackets; + } + function getOpeningBracket(format) { + return brackets[format & 7680][0]; + } + function getClosingBracket(format) { + return brackets[format & 7680][1]; + } + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + })(TempFlags || (TempFlags = {})); + var ListFormat; + (function (ListFormat) { + ListFormat[ListFormat["None"] = 0] = "None"; + ListFormat[ListFormat["SingleLine"] = 0] = "SingleLine"; + ListFormat[ListFormat["MultiLine"] = 1] = "MultiLine"; + ListFormat[ListFormat["PreserveLines"] = 2] = "PreserveLines"; + ListFormat[ListFormat["LinesMask"] = 3] = "LinesMask"; + ListFormat[ListFormat["NotDelimited"] = 0] = "NotDelimited"; + ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; + ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; + ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; + ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; + ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; + ListFormat[ListFormat["Indented"] = 64] = "Indented"; + ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; + ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; + ListFormat[ListFormat["Braces"] = 512] = "Braces"; + ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; + ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; + ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; + ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; + ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; + ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; + ListFormat[ListFormat["Optional"] = 24576] = "Optional"; + ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; + ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; + ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; + ListFormat[ListFormat["Modifiers"] = 256] = "Modifiers"; + ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; + ListFormat[ListFormat["TypeLiteralMembers"] = 65] = "TypeLiteralMembers"; + ListFormat[ListFormat["TupleTypeElements"] = 336] = "TupleTypeElements"; + ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; + ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; + ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; + ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; + ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; + ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; + ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; + ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; + ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; + ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; + ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; + ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; + ListFormat[ListFormat["ClassHeritageClauses"] = 256] = "ClassHeritageClauses"; + ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; + ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; + ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; + ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; + ListFormat[ListFormat["NamedImportsOrExportsElements"] = 432] = "NamedImportsOrExportsElements"; + ListFormat[ListFormat["JsxElementChildren"] = 131072] = "JsxElementChildren"; + ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; + ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; + ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; + ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; + ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; + ListFormat[ListFormat["TypeArguments"] = 26960] = "TypeArguments"; + ListFormat[ListFormat["TypeParameters"] = 26960] = "TypeParameters"; + ListFormat[ListFormat["Parameters"] = 1360] = "Parameters"; + ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; + })(ListFormat || (ListFormat = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -50722,7 +53519,8 @@ var ts; commonPathComponents = sourcePathComponents; return; } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + var n = Math.min(commonPathComponents.length, sourcePathComponents.length); + for (var i = 0; i < n; i++) { if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { if (i === 0) { return true; @@ -50769,11 +53567,11 @@ var ts; return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; } function directoryExists(directoryPath) { - if (directoryPath in existingDirectories) { + if (existingDirectories.has(directoryPath)) { return true; } if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; + existingDirectories.set(directoryPath, true); return true; } return false; @@ -50792,9 +53590,10 @@ var ts; } var hash = ts.sys.createHash(data); var mtimeBefore = ts.sys.getModifiedTime(fileName); - if (mtimeBefore && fileName in outputFingerprints) { - var fingerprint = outputFingerprints[fileName]; - if (fingerprint.byteOrderMark === writeByteOrderMark && + if (mtimeBefore) { + var fingerprint = outputFingerprints.get(fileName); + if (fingerprint && + fingerprint.byteOrderMark === writeByteOrderMark && fingerprint.hash === hash && fingerprint.mtime.getTime() === mtimeBefore.getTime()) { return; @@ -50802,11 +53601,11 @@ var ts; } ts.sys.writeFile(fileName, data, writeByteOrderMark); var mtimeAfter = ts.sys.getModifiedTime(fileName); - outputFingerprints[fileName] = { + outputFingerprints.set(fileName, { hash: hash, byteOrderMark: writeByteOrderMark, mtime: mtimeAfter - }; + }); } function writeFile(fileName, data, writeByteOrderMark, onError) { try { @@ -50905,10 +53704,14 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_44 = names_1[_i]; - var result = name_44 in cache - ? cache[name_44] - : cache[name_44] = loader(name_44, containingFile); + var name = names_1[_i]; + var result = void 0; + if (cache.has(name)) { + result = cache.get(name); + } + else { + cache.set(name, result = loader(name, containingFile)); + } resolutions.push(result); } return resolutions; @@ -50933,6 +53736,7 @@ var ts; var currentDirectory = host.getCurrentDirectory(); var supportedExtensions = ts.getSupportedExtensions(options); var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); + var moduleResolutionCache; var resolveModuleNamesWorker; if (host.resolveModuleNames) { resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { @@ -50945,7 +53749,8 @@ var ts; }); }; } else { - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -50981,6 +53786,7 @@ var ts; } } } + moduleResolutionCache = undefined; oldProgram = undefined; program = { getRootFileNames: function () { return rootNames; }, @@ -51014,7 +53820,7 @@ var ts; return program; function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filterSourceFilesInDirectory(files, isSourceFileFromExternalLibrary); + var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); } @@ -51033,7 +53839,7 @@ var ts; classifiableNames = ts.createMap(); for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { var sourceFile = files_2[_i]; - ts.copyProperties(sourceFile.classifiableNames, classifiableNames); + ts.copyEntries(sourceFile.classifiableNames, classifiableNames); } } return classifiableNames; @@ -51187,7 +53993,7 @@ var ts; newSourceFile.resolvedModules = oldSourceFile.resolvedModules; newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } - for (var i = 0, len = newSourceFiles.length; i < len; i++) { + for (var i = 0; i < newSourceFiles.length; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; @@ -51216,7 +54022,7 @@ var ts; }; } function isSourceFileFromExternalLibrary(file) { - return sourceFilesFoundSearchingNodeModules[file.path]; + return sourceFilesFoundSearchingNodeModules.get(file.path); } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); @@ -51333,57 +54139,57 @@ var ts; return diagnostics; function walk(node) { switch (parent.kind) { - case 144: - case 147: + case 145: + case 148: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } - case 149: - case 148: case 150: + case 149: case 151: case 152: - case 184: - case 225: + case 153: case 185: + case 227: + case 186: + case 227: case 225: - case 223: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 234: + case 236: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 240: + case 242: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 255: + case 258: var heritageClause = node; if (heritageClause.token === 107) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 227: + case 229: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 230: + case 232: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 228: + case 230: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 229: + case 231: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 182: + case 183: var typeAssertionExpression = node; diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; @@ -51398,26 +54204,26 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 226: - case 149: - case 148: + case 228: case 150: + case 149: case 151: case 152: - case 184: - case 225: + case 153: case 185: - case 225: + case 227: + case 186: + case 227: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 205: + case 207: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 205); + return checkModifiers(nodes, parent.kind === 207); } break; - case 147: + case 148: if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; @@ -51428,15 +54234,15 @@ var ts; return; } break; - case 144: + case 145: if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 179: case 180: - case 199: + case 181: + case 200: if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); return; @@ -51524,11 +54330,10 @@ var ts; if (options.importHelpers && (options.isolatedModules || isExternalModuleFile) && !file.isDeclarationFile) { - var externalHelpersModuleReference = ts.createSynthesizedNode(9); - externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(235); - importDecl.parent = file; + var externalHelpersModuleReference = ts.createLiteral(ts.externalHelpersModuleNameText); + var importDecl = ts.createImportDeclaration(undefined, undefined, undefined); externalHelpersModuleReference.parent = importDecl; + importDecl.parent = file; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -51544,9 +54349,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 235: - case 234: - case 241: + case 237: + case 236: + case 243: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -51558,7 +54363,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 230: + case 232: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -51642,18 +54447,18 @@ var ts; if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd); } - if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { - sourceFilesFoundSearchingNodeModules[file_1.path] = false; + if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth == 0) { + sourceFilesFoundSearchingNodeModules.set(file_1.path, false); if (!options.noResolve) { processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } - else if (file_1 && modulesWithElidedImports[file_1.path]) { + else if (file_1 && modulesWithElidedImports.get(file_1.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } } @@ -51669,7 +54474,7 @@ var ts; }); filesByName.set(path, file); if (file) { - sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0); + sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; if (host.useCaseSensitiveFileNames()) { var existingFile = filesByNameIgnoreCase.get(path); @@ -51713,7 +54518,7 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { - var previousResolution = resolvedTypeReferenceDirectives[typeReferenceDirective]; + var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { return; } @@ -51741,7 +54546,7 @@ var ts; fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { - resolvedTypeReferenceDirectives[typeReferenceDirective] = resolvedTypeReferenceDirective; + resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); } } function createDiagnostic(refFile, refPos, refEnd, message) { @@ -51782,7 +54587,7 @@ var ts; var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { - modulesWithElidedImports[file.path] = true; + modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = ts.toPath(resolvedFileName, currentDirectory, getCanonicalFileName); @@ -51800,8 +54605,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var file = sourceFiles_6[_i]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var file = sourceFiles_3[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -51812,8 +54617,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -51964,7 +54769,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { + ts.forEachEmittedFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -52087,6 +54892,22 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + var OutputFileType; + (function (OutputFileType) { + OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; + OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; + OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; + })(OutputFileType = ts.OutputFileType || (ts.OutputFileType = {})); + var EndOfLineState; + (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"; + })(EndOfLineState = ts.EndOfLineState || (ts.EndOfLineState = {})); var TokenClass; (function (TokenClass) { TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; @@ -52133,6 +54954,7 @@ var ts; ScriptElementKind.letElement = "let"; ScriptElementKind.directory = "directory"; ScriptElementKind.externalModuleName = "external module name"; + ScriptElementKind.jsxAttribute = "JSX attribute"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; (function (ScriptElementKindModifier) { @@ -52174,40 +54996,76 @@ var ts; ClassificationTypeNames.jsxText = "jsx text"; ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; ts.ClassificationTypeNames = ClassificationTypeNames; + var ClassificationType; + (function (ClassificationType) { + ClassificationType[ClassificationType["comment"] = 1] = "comment"; + ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; + ClassificationType[ClassificationType["keyword"] = 3] = "keyword"; + ClassificationType[ClassificationType["numericLiteral"] = 4] = "numericLiteral"; + ClassificationType[ClassificationType["operator"] = 5] = "operator"; + ClassificationType[ClassificationType["stringLiteral"] = 6] = "stringLiteral"; + ClassificationType[ClassificationType["regularExpressionLiteral"] = 7] = "regularExpressionLiteral"; + ClassificationType[ClassificationType["whiteSpace"] = 8] = "whiteSpace"; + ClassificationType[ClassificationType["text"] = 9] = "text"; + ClassificationType[ClassificationType["punctuation"] = 10] = "punctuation"; + ClassificationType[ClassificationType["className"] = 11] = "className"; + ClassificationType[ClassificationType["enumName"] = 12] = "enumName"; + ClassificationType[ClassificationType["interfaceName"] = 13] = "interfaceName"; + ClassificationType[ClassificationType["moduleName"] = 14] = "moduleName"; + ClassificationType[ClassificationType["typeParameterName"] = 15] = "typeParameterName"; + ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName"; + ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName"; + ClassificationType[ClassificationType["docCommentTagName"] = 18] = "docCommentTagName"; + ClassificationType[ClassificationType["jsxOpenTagName"] = 19] = "jsxOpenTagName"; + ClassificationType[ClassificationType["jsxCloseTagName"] = 20] = "jsxCloseTagName"; + ClassificationType[ClassificationType["jsxSelfClosingTagName"] = 21] = "jsxSelfClosingTagName"; + ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; + ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; + ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; + })(ClassificationType = ts.ClassificationType || (ts.ClassificationType = {})); })(ts || (ts = {})); var ts; (function (ts) { ts.scanner = ts.createScanner(5, true); ts.emptyArray = []; + 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 = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 144: - case 223: - case 174: - case 147: - case 146: - case 257: - case 258: - case 260: - case 149: + case 145: + case 225: + case 175: case 148: + case 147: + case 260: + case 261: + case 263: case 150: + case 149: case 151: case 152: - case 225: - case 184: - case 185: - case 256: - return 1; - case 143: + case 153: case 227: - case 228: - case 161: - return 2; - case 226: + case 185: + case 186: + case 259: + case 252: + return 1; + case 144: case 229: - return 1 | 2; case 230: + case 162: + return 2; + case 228: + case 231: + return 1 | 2; + case 232: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -52217,21 +55075,24 @@ var ts; else { return 4; } - case 238: - case 239: - case 234: - case 235: case 240: case 241: + case 236: + case 237: + case 242: + case 243: return 1 | 2 | 4; - case 261: + case 264: return 4 | 1; } return 1 | 2 | 4; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 240) { + if (node.kind === 264) { + return 1; + } + else if (node.parent.kind === 242) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -52253,15 +55114,15 @@ var ts; ts.getMeaningFromLocation = getMeaningFromLocation; function getMeaningFromRightHandSideOfImportEquals(node) { ts.Debug.assert(node.kind === 70); - if (node.parent.kind === 141 && + if (node.parent.kind === 142 && node.parent.right === node && - node.parent.parent.kind === 234) { + node.parent.parent.kind === 236) { return 1 | 2 | 4; } return 4; } function isInRightSideOfImport(node) { - while (node.parent.kind === 141) { + while (node.parent.kind === 142) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -52272,27 +55133,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 141) { - while (root.parent && root.parent.kind === 141) { + if (root.parent.kind === 142) { + while (root.parent && root.parent.kind === 142) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 157 && !isLastClause; + return root.parent.kind === 158 && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 177) { - while (root.parent && root.parent.kind === 177) { + if (root.parent.kind === 178) { + while (root.parent && root.parent.kind === 178) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 199 && root.parent.parent.kind === 255) { + if (!isLastClause && root.parent.kind === 200 && root.parent.parent.kind === 258) { var decl = root.parent.parent.parent; - return (decl.kind === 226 && root.parent.parent.token === 107) || - (decl.kind === 227 && root.parent.parent.token === 84); + return (decl.kind === 228 && root.parent.parent.token === 107) || + (decl.kind === 229 && root.parent.parent.token === 84); } return false; } @@ -52300,17 +55161,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 157 || - (node.parent.kind === 199 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + return node.parent.kind === 158 || + (node.parent.kind === 200 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || (node.kind === 98 && !ts.isPartOfExpression(node)) || - node.kind === 167; + node.kind === 168; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 179); + return isCallOrNewExpressionTarget(node, 180); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 180); + return isCallOrNewExpressionTarget(node, 181); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -52323,7 +55184,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 219 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 221 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -52333,13 +55194,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 && - (node.parent.kind === 215 || node.parent.kind === 214) && + (node.parent.kind === 217 || node.parent.kind === 216) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 && - node.parent.kind === 219 && + node.parent.kind === 221 && node.parent.label === node; } function isLabelName(node) { @@ -52347,15 +55208,15 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 141 && node.parent.right === node; + return node.parent.kind === 142 && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 177 && node.parent.name === node; + return node && node.parent && node.parent.kind === 178 && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 230 && node.parent.name === node; + return node.parent.kind === 232 && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -52366,19 +55227,19 @@ var ts; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { - case 147: - case 146: - case 257: - case 260: - case 149: case 148: - case 151: + case 147: + case 260: + case 263: + case 150: + case 149: case 152: - case 230: + case 153: + case 232: return node.parent.name === node; - case 178: + case 179: return node.parent.argumentExpression === node; - case 142: + case 143: return true; } } @@ -52422,17 +55283,17 @@ var ts; return undefined; } switch (node.kind) { - case 261: + case 264: + case 150: case 149: - case 148: - case 225: - case 184: - case 151: - case 152: - case 226: case 227: + case 185: + case 152: + case 153: + case 228: case 229: - case 230: + case 231: + case 232: return node; } } @@ -52440,46 +55301,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 261: + case 264: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 230: + case 232: return ts.ScriptElementKind.moduleElement; - case 226: - case 197: + case 228: + case 198: return ts.ScriptElementKind.classElement; - case 227: return ts.ScriptElementKind.interfaceElement; - case 228: return ts.ScriptElementKind.typeElement; - case 229: return ts.ScriptElementKind.enumElement; - case 223: - return getKindOfVariableDeclaration(node); - case 174: - return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 185: + case 229: return ts.ScriptElementKind.interfaceElement; + case 230: return ts.ScriptElementKind.typeElement; + case 231: return ts.ScriptElementKind.enumElement; case 225: - case 184: + return getKindOfVariableDeclaration(node); + case 175: + return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); + case 186: + case 227: + case 185: return ts.ScriptElementKind.functionElement; - case 151: return ts.ScriptElementKind.memberGetAccessorElement; - case 152: return ts.ScriptElementKind.memberSetAccessorElement; + case 152: return ts.ScriptElementKind.memberGetAccessorElement; + case 153: return ts.ScriptElementKind.memberSetAccessorElement; + case 150: case 149: - case 148: return ts.ScriptElementKind.memberFunctionElement; + case 148: case 147: - case 146: return ts.ScriptElementKind.memberVariableElement; - case 155: return ts.ScriptElementKind.indexSignatureElement; - case 154: return ts.ScriptElementKind.constructSignatureElement; - case 153: return ts.ScriptElementKind.callSignatureElement; - case 150: return ts.ScriptElementKind.constructorImplementationElement; - case 143: return ts.ScriptElementKind.typeParameterElement; - case 260: return ts.ScriptElementKind.enumMemberElement; - case 144: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 234: - case 239: + case 156: return ts.ScriptElementKind.indexSignatureElement; + case 155: return ts.ScriptElementKind.constructSignatureElement; + case 154: return ts.ScriptElementKind.callSignatureElement; + case 151: return ts.ScriptElementKind.constructorImplementationElement; + case 144: return ts.ScriptElementKind.typeParameterElement; + case 263: return ts.ScriptElementKind.enumMemberElement; + case 145: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; case 236: - case 243: - case 237: + case 241: + case 238: + case 245: + case 239: return ts.ScriptElementKind.alias; - case 285: + case 289: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -52494,7 +55355,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 171 ? node.parent : node; + var searchNode = node.parent.kind === 172 ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32) { return type; @@ -52507,7 +55368,7 @@ var ts; case 98: return true; case 70: - return ts.identifierIsThisKeyword(node) && node.parent.kind === 144; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 145; default: return false; } @@ -52551,41 +55412,41 @@ var ts; return false; } switch (n.kind) { - case 226: - case 227: + case 228: case 229: - case 176: - case 172: - case 161: - case 204: case 231: - case 232: - case 238: - case 242: + case 177: + case 173: + case 162: + case 206: + case 233: + case 234: + case 240: + case 244: return nodeEndsWith(n, 17, sourceFile); - case 256: + case 259: return isCompletedNode(n.block, sourceFile); - case 180: + case 181: if (!n.arguments) { return true; } - case 179: - case 183: - case 166: + case 180: + case 184: + case 167: return nodeEndsWith(n, 19, sourceFile); - case 158: case 159: + case 160: return isCompletedNode(n.type, sourceFile); - case 150: case 151: case 152: - case 225: - case 184: - case 149: - case 148: - case 154: case 153: + case 227: case 185: + case 150: + case 149: + case 155: + case 154: + case 186: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -52593,65 +55454,65 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19, sourceFile); - case 230: + case 232: return n.body && isCompletedNode(n.body, sourceFile); - case 208: + case 210: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 207: + case 209: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24); - case 175: - case 173: - case 178: - case 142: - case 163: + case 176: + case 174: + case 179: + case 143: + case 164: return nodeEndsWith(n, 21, sourceFile); - case 155: + case 156: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21, sourceFile); - case 253: - case 254: + case 256: + case 257: return false; - case 211: - case 212: case 213: - case 210: + case 214: + case 215: + case 212: return isCompletedNode(n.statement, sourceFile); - case 209: + case 211: var hasWhileKeyword = findChildOfKind(n, 105, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 19, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 160: + case 161: return isCompletedNode(n.exprName, sourceFile); - case 187: - case 186: case 188: - case 195: + case 187: + case 189: case 196: + case 197: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 181: + case 182: return isCompletedNode(n.template, sourceFile); - case 194: + case 195: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 202: + case 204: return ts.nodeIsPresent(n.literal); - case 241: - case 235: + case 243: + case 237: return ts.nodeIsPresent(n.moduleSpecifier); - case 190: + case 191: return isCompletedNode(n.operand, sourceFile); - case 192: - return isCompletedNode(n.right, sourceFile); case 193: + return isCompletedNode(n.right, sourceFile); + case 194: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -52694,7 +55555,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 292 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 296 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -52749,8 +55610,8 @@ var ts; } } } - for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { - var child = current.getChildAt(i); + for (var _a = 0, _b = current.getChildren(); _a < _b.length; _a++) { + var child = _b[_a]; if (ts.isJSDocNode(child)) { continue; } @@ -52814,7 +55675,7 @@ var ts; return n; } var children = n.getChildren(); - for (var i = 0, len = children.length; i < len; i++) { + for (var i = 0; i < children.length; i++) { var child = children[i]; if (position < child.end && (nodeHasTokens(child) || child.kind === 10)) { var start = child.getStart(sourceFile); @@ -52829,7 +55690,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 261); + ts.Debug.assert(startNode !== undefined || n.kind === 264); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -52874,13 +55735,13 @@ var ts; if (token.kind === 26 && token.parent.kind === 10) { return true; } - if (token.kind === 26 && token.parent.kind === 252) { + if (token.kind === 26 && token.parent.kind === 255) { return true; } - if (token && token.kind === 17 && token.parent.kind === 252) { + if (token && token.kind === 17 && token.parent.kind === 255) { return true; } - if (token.kind === 26 && token.parent.kind === 249) { + if (token.kind === 26 && token.parent.kind === 251) { return true; } return false; @@ -52971,17 +55832,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 157 || node.kind === 179) { + if (node.kind === 158 || node.kind === 180) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 226 || node.kind === 227) { + if (ts.isFunctionLike(node) || node.kind === 228 || node.kind === 229) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 140; + return n.kind >= 0 && n.kind <= 141; } ts.isToken = isToken; function isWord(kind) { @@ -53040,18 +55901,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 175 || - node.kind === 176) { - if (node.parent.kind === 192 && + if (node.kind === 176 || + node.kind === 177) { + if (node.parent.kind === 193 && node.parent.left === node && node.parent.operatorToken.kind === 57) { return true; } - if (node.parent.kind === 213 && + if (node.parent.kind === 215 && node.parent.initializer === node) { return true; } - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 257 ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 260 ? node.parent.parent : node.parent)) { return true; } } @@ -53079,10 +55940,30 @@ var ts; } } ts.isInNonReferenceComment = isInNonReferenceComment; + function createTextSpanFromNode(node, sourceFile) { + return ts.createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); + } + ts.createTextSpanFromNode = createTextSpanFromNode; + function isTypeKeyword(kind) { + switch (kind) { + case 118: + case 121: + case 129: + case 132: + case 133: + case 135: + case 136: + case 104: + return true; + default: + return false; + } + } + ts.isTypeKeyword = isTypeKeyword; })(ts || (ts = {})); (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 144; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 145; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -53106,7 +55987,8 @@ var ts; decreaseIndent: function () { indent--; }, clear: resetWriter, trackSymbol: ts.noop, - reportInaccessibleThisError: ts.noop + reportInaccessibleThisError: ts.noop, + reportIllegalExtends: ts.noop }; function writeIndent() { if (lineStart) { @@ -53258,7 +56140,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location) && - location.parent.kind === 142) { + location.parent.kind === 143) { return location.text; } var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); @@ -53268,7 +56150,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 239 || location.parent.kind === 243) && + (location.parent.kind === 241 || location.parent.kind === 245) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -53325,6 +56207,10 @@ var ts; }; } ts.sanitizeConfigFile = sanitizeConfigFile; + function getOpenBraceEnd(constructor, sourceFile) { + return constructor.body.getFirstToken(sourceFile).getEnd(); + } + ts.getOpenBraceEnd = getOpenBraceEnd; })(ts || (ts = {})); var ts; (function (ts) { @@ -53373,89 +56259,89 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 205: + case 207: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 223: - case 147: - case 146: - return spanInVariableDeclaration(node); - case 144: - return spanInParameterDeclaration(node); case 225: - case 149: case 148: - case 151: - case 152: + case 147: + return spanInVariableDeclaration(node); + case 145: + return spanInParameterDeclaration(node); + case 227: case 150: - case 184: + case 149: + case 152: + case 153: + case 151: case 185: + case 186: return spanInFunctionDeclaration(node); - case 204: + case 206: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 231: + case 233: return spanInBlock(node); - case 256: + case 259: return spanInBlock(node.block); - case 207: - return textSpan(node.expression); - case 216: - return textSpan(node.getChildAt(0), node.expression); - case 210: - return textSpanEndingAtNextToken(node, node.expression); case 209: - return spanInNode(node.statement); - case 222: - return textSpan(node.getChildAt(0)); - case 208: - return textSpanEndingAtNextToken(node, node.expression); - case 219: - return spanInNode(node.statement); - case 215: - case 214: - return textSpan(node.getChildAt(0), node.label); - case 211: - return spanInForStatement(node); + return textSpan(node.expression); + case 218: + return textSpan(node.getChildAt(0), node.expression); case 212: return textSpanEndingAtNextToken(node, node.expression); - case 213: - return spanInInitializerOfForLike(node); - case 218: + case 211: + return spanInNode(node.statement); + case 224: + return textSpan(node.getChildAt(0)); + case 210: return textSpanEndingAtNextToken(node, node.expression); - case 253: - case 254: - return spanInNode(node.statements[0]); case 221: - return spanInBlock(node.tryBlock); + return spanInNode(node.statement); + case 217: + case 216: + return textSpan(node.getChildAt(0), node.label); + case 213: + return spanInForStatement(node); + case 214: + return textSpanEndingAtNextToken(node, node.expression); + case 215: + return spanInInitializerOfForLike(node); case 220: + return textSpanEndingAtNextToken(node, node.expression); + case 256: + case 257: + return spanInNode(node.statements[0]); + case 223: + return spanInBlock(node.tryBlock); + case 222: return textSpan(node, node.expression); - case 240: + case 242: return textSpan(node, node.expression); - case 234: + case 236: return textSpan(node, node.moduleReference); - case 235: + case 237: return textSpan(node, node.moduleSpecifier); - case 241: + case 243: return textSpan(node, node.moduleSpecifier); - case 230: + case 232: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 226: - case 229: - case 260: - case 174: - return textSpan(node); - case 217: - return spanInNode(node.statement); - case 145: - return spanInNodeArray(node.parent.decorators); - case 172: - case 173: - return spanInBindingPattern(node); - case 227: case 228: + case 231: + case 263: + case 175: + return textSpan(node); + case 219: + return spanInNode(node.statement); + case 146: + return spanInNodeArray(node.parent.decorators); + case 173: + case 174: + return spanInBindingPattern(node); + case 229: + case 230: return undefined; case 24: case 1: @@ -53483,20 +56369,20 @@ var ts; case 73: case 86: return spanInNextNode(node); - case 140: + case 141: return spanInOfKeyword(node); default: if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node); } if ((node.kind === 70 || - node.kind == 196 || - node.kind === 257 || - node.kind === 258) && + node.kind == 197 || + node.kind === 260 || + node.kind === 261) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 192) { + if (node.kind === 193) { var binaryExpression = node; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); @@ -53511,38 +56397,38 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 209: - return spanInPreviousNode(node); - case 145: - return spanInNode(node.parent); case 211: + return spanInPreviousNode(node); + case 146: + return spanInNode(node.parent); case 213: + case 215: return textSpan(node); - case 192: + case 193: if (node.parent.operatorToken.kind === 25) { return textSpan(node); } break; - case 185: + case 186: if (node.parent.body === node) { return textSpan(node); } break; } } - if (node.parent.kind === 257 && + if (node.parent.kind === 260 && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 182 && node.parent.type === node) { + if (node.parent.kind === 183 && node.parent.type === node) { return spanInNextNode(node.parent.type); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { return spanInPreviousNode(node); } - if ((node.parent.kind === 223 || - node.parent.kind === 144)) { + if ((node.parent.kind === 225 || + node.parent.kind === 145)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -53550,7 +56436,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 192) { + if (node.parent.kind === 193) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -53571,7 +56457,7 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 212) { + if (variableDeclaration.parent.parent.kind === 214) { return spanInNode(variableDeclaration.parent.parent); } if (ts.isBindingPattern(variableDeclaration.name)) { @@ -53579,7 +56465,7 @@ var ts; } if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 213) { + variableDeclaration.parent.parent.kind === 215) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -53611,7 +56497,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 226 && functionDeclaration.kind !== 150); + (functionDeclaration.parent.kind === 228 && functionDeclaration.kind !== 151); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -53631,22 +56517,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 230: + case 232: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 210: - case 208: case 212: + case 210: + case 214: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 211: case 213: + case 215: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 224) { + if (forLikeStatement.initializer.kind === 226) { var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -53668,62 +56554,62 @@ var ts; } } function spanInBindingPattern(bindingPattern) { - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 198 ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 199 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - if (bindingPattern.parent.kind === 174) { + if (bindingPattern.parent.kind === 175) { return textSpan(bindingPattern.parent); } return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 173 && node.kind !== 172); - var elements = node.kind === 175 ? + ts.Debug.assert(node.kind !== 174 && node.kind !== 173); + var elements = node.kind === 176 ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 198 ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 199 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - return textSpan(node.parent.kind === 192 ? node.parent : node); + return textSpan(node.parent.kind === 193 ? node.parent : node); } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 229: + case 231: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 226: + case 228: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 232: + case 234: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 231: + case 233: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 229: - case 226: + case 231: + case 228: return textSpan(node); - case 204: + case 206: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 256: + case 259: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 232: + case 234: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 172: + case 173: var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -53736,7 +56622,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 173: + case 174: var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -53748,33 +56634,33 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 209 || - node.parent.kind === 179 || - node.parent.kind === 180) { + if (node.parent.kind === 211 || + node.parent.kind === 180 || + node.parent.kind === 181) { return spanInPreviousNode(node); } - if (node.parent.kind === 183) { + if (node.parent.kind === 184) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 184: - case 225: case 185: - case 149: - case 148: - case 151: - case 152: + case 227: + case 186: case 150: - case 210: - case 209: + case 149: + case 152: + case 153: + case 151: + case 212: case 211: case 213: - case 179: + case 215: case 180: - case 183: + case 181: + case 184: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -53782,26 +56668,26 @@ var ts; } function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || - node.parent.kind === 257 || - node.parent.kind === 144) { + node.parent.kind === 260 || + node.parent.kind === 145) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 182) { + if (node.parent.kind === 183) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 209) { + if (node.parent.kind === 211) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 213) { + if (node.parent.kind === 215) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -53832,7 +56718,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 124 || - keyword2 === 133 || + keyword2 === 134 || keyword2 === 122 || keyword2 === 114) { return true; @@ -53845,7 +56731,7 @@ var ts; var entries = []; var dense = classifications.spans; var lastEnd = 0; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; var length_4 = dense[i + 1]; var type = dense[i + 2]; @@ -53948,10 +56834,10 @@ var ts; angleBracketStack--; } else if (token === 118 || - token === 134 || + token === 135 || token === 132 || token === 121 || - token === 135) { + token === 136) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { token = 70; } @@ -54106,7 +56992,7 @@ var ts; } } function isKeyword(token) { - return token >= 71 && token <= 140; + return token >= 71 && token <= 141; } function classFromKind(token) { if (isKeyword(token)) { @@ -54152,10 +57038,10 @@ var ts; ts.getSemanticClassifications = getSemanticClassifications; function checkForClassificationCancellation(cancellationToken, kind) { switch (kind) { - case 230: - case 226: + case 232: + case 228: + case 229: case 227: - case 225: cancellationToken.throwIfCancellationRequested(); } } @@ -54199,7 +57085,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 230 && + return declaration.kind === 232 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -54210,7 +57096,7 @@ var ts; checkForClassificationCancellation(cancellationToken, kind); if (kind === 70 && !ts.nodeIsMissing(node)) { var identifier = node; - if (classifiableNames[identifier.text]) { + if (classifiableNames.get(identifier.text)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { var type = classifySymbol(symbol, ts.getMeaningFromLocation(node)); @@ -54256,7 +57142,7 @@ var ts; 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) { + for (var i = 0; i < dense.length; i += 3) { result.push({ textSpan: ts.createTextSpan(dense[i], dense[i + 1]), classificationType: getClassificationTypeName(dense[i + 2]) @@ -54340,16 +57226,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 281: + case 285: processJSDocParameterTag(tag); break; - case 284: + case 288: processJSDocTemplateTag(tag); break; - case 283: + case 287: processElement(tag.typeExpression); break; - case 282: + case 286: processElement(tag.typeExpression); break; } @@ -54430,22 +57316,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 248: + case 250: if (token.parent.tagName === token) { return 19; } break; - case 249: + case 251: if (token.parent.tagName === token) { return 20; } break; - case 247: + case 249: if (token.parent.tagName === token) { return 21; } break; - case 250: + case 252: if (token.parent.name === token) { return 22; } @@ -54465,17 +57351,17 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { if (tokenKind === 57) { - if (token.parent.kind === 223 || - token.parent.kind === 147 || - token.parent.kind === 144 || - token.parent.kind === 250) { + if (token.parent.kind === 225 || + token.parent.kind === 148 || + token.parent.kind === 145 || + token.parent.kind === 252) { return 5; } } - if (token.parent.kind === 192 || - token.parent.kind === 190 || + if (token.parent.kind === 193 || token.parent.kind === 191 || - token.parent.kind === 193) { + token.parent.kind === 192 || + token.parent.kind === 194) { return 5; } } @@ -54485,7 +57371,7 @@ var ts; return 4; } else if (tokenKind === 9) { - return token.parent.kind === 250 ? 24 : 6; + return token.parent.kind === 252 ? 24 : 6; } else if (tokenKind === 11) { return 6; @@ -54499,32 +57385,32 @@ var ts; else if (tokenKind === 70) { if (token) { switch (token.parent.kind) { - case 226: + case 228: if (token.parent.name === token) { return 11; } return; - case 143: + case 144: if (token.parent.name === token) { return 15; } return; - case 227: + case 229: if (token.parent.name === token) { return 13; } return; - case 229: + case 231: if (token.parent.name === token) { return 12; } return; - case 230: + case 232: if (token.parent.name === token) { return 14; } return; - case 144: + case 145: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 : 17; } @@ -54540,9 +57426,8 @@ var ts; } if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { checkForClassificationCancellation(cancellationToken, element.kind); - var children = element.getChildren(sourceFile); - for (var i = 0, n = children.length; i < n; i++) { - var child = children[i]; + for (var _i = 0, _a = element.getChildren(sourceFile); _i < _a.length; _i++) { + var child = _a[_i]; if (!tryClassifyNode(child)) { processElement(child); } @@ -54558,10 +57443,10 @@ var ts; (function (Completions) { function getCompletionsAtPosition(host, typeChecker, log, compilerOptions, sourceFile, position) { if (ts.isInReferenceComment(sourceFile, position)) { - return getTripleSlashReferenceCompletion(sourceFile, position); + return getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); } if (ts.isInString(sourceFile, position)) { - return getStringLiteralCompletionEntries(sourceFile, position); + return getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log); } var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (!completionData) { @@ -54573,13 +57458,13 @@ var ts; } var entries = []; if (ts.isSourceFileJavaScript(sourceFile)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, true); - ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, true, typeChecker, compilerOptions.target, log); + ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target)); } else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 && - location.parent && location.parent.kind === 249) { + location.parent && location.parent.kind === 251) { var tagName = location.parent.parent.openingElement.tagName; entries.push({ name: tagName.text, @@ -54592,528 +57477,535 @@ var ts; return undefined; } } - getCompletionEntriesFromSymbols(symbols, entries, location, true); + getCompletionEntriesFromSymbols(symbols, entries, location, true, typeChecker, compilerOptions.target, log); } if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { - var entries = []; - var nameTable = ts.getNameTable(sourceFile); - for (var name_45 in nameTable) { - if (nameTable[name_45] === position) { - continue; + } + Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames, target) { + var entries = []; + var nameTable = ts.getNameTable(sourceFile); + nameTable.forEach(function (pos, name) { + if (pos === position) { + return; + } + if (!uniqueNames.get(name)) { + uniqueNames.set(name, name); + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name), target, true); + if (displayName) { + var entry = { + name: displayName, + kind: ts.ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } - if (!uniqueNames[name_45]) { - uniqueNames[name_45] = name_45; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_45), compilerOptions.target, true); - if (displayName) { - var entry = { - name: displayName, - kind: ts.ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; + } + }); + return entries; + } + function createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target) { + var displayName = getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, target, performCharacterChecks, location); + if (!displayName) { + return undefined; + } + return { + name: displayName, + kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), + kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), + sortText: "0", + }; + } + function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks, typeChecker, target, log) { + var start = ts.timestamp(); + var uniqueNames = ts.createMap(); + if (symbols) { + for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { + var symbol = symbols_4[_i]; + var entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target); + if (entry) { + var id = ts.escapeIdentifier(entry.name); + if (!uniqueNames.get(id)) { entries.push(entry); + uniqueNames.set(id, id); } } } - return entries; } - function createCompletionEntry(symbol, location, performCharacterChecks) { - var displayName = getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, compilerOptions.target, performCharacterChecks, location); - if (!displayName) { - return undefined; + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); + return uniqueNames; + } + function getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log) { + var node = ts.findPrecedingToken(position, sourceFile); + if (!node || node.kind !== 9) { + return undefined; + } + if (node.parent.kind === 260 && + node.parent.parent.kind === 177 && + node.parent.name === node) { + return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent, typeChecker, compilerOptions.target, log); + } + else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { + return getStringLiteralCompletionEntriesFromElementAccess(node.parent, typeChecker, compilerOptions.target, log); + } + else if (node.parent.kind === 237 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + return getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker); + } + else if (isEqualityExpression(node.parent)) { + return getStringLiteralCompletionEntriesFromType(typeChecker.getTypeAtLocation(node.parent.left === node ? node.parent.right : node.parent.left), typeChecker); + } + else if (ts.isCaseOrDefaultClause(node.parent)) { + return getStringLiteralCompletionEntriesFromType(typeChecker.getTypeAtLocation(node.parent.parent.parent.expression), typeChecker); + } + else { + var argumentInfo = ts.SignatureHelp.getImmediatelyContainingArgumentInfo(node, position, sourceFile); + if (argumentInfo) { + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker); } - return { - name: displayName, - kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0", - }; + return getStringLiteralCompletionEntriesFromType(typeChecker.getContextualType(node), typeChecker); } - function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks) { - var start = ts.timestamp(); - var uniqueNames = ts.createMap(); - if (symbols) { - for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { - var symbol = symbols_4[_i]; - var entry = createCompletionEntry(symbol, location, performCharacterChecks); - if (entry) { - var id = ts.escapeIdentifier(entry.name); - if (!uniqueNames[id]) { - entries.push(entry); - uniqueNames[id] = id; + } + function getStringLiteralCompletionEntriesFromPropertyAssignment(element, typeChecker, target, log) { + var type = typeChecker.getContextualType(element.parent); + var entries = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + } + } + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker) { + var candidates = []; + var entries = []; + typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); + for (var _i = 0, candidates_3 = candidates; _i < candidates_3.length; _i++) { + var candidate = candidates_3[_i]; + addStringLiteralCompletionsFromType(typeChecker.getParameterType(candidate, argumentInfo.argumentIndex), entries, typeChecker); + } + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; + } + return undefined; + } + function getStringLiteralCompletionEntriesFromElementAccess(node, typeChecker, target, log) { + var type = typeChecker.getTypeAtLocation(node.expression); + var entries = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + } + return undefined; + } + function getStringLiteralCompletionEntriesFromType(type, typeChecker) { + if (type) { + var entries = []; + addStringLiteralCompletionsFromType(type, entries, typeChecker); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; + } + } + return undefined; + } + function addStringLiteralCompletionsFromType(type, result, typeChecker) { + if (type && type.flags & 16384) { + type = typeChecker.getApparentType(type); + } + if (!type) { + return; + } + if (type.flags & 65536) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + addStringLiteralCompletionsFromType(t, result, typeChecker); + } + } + else if (type.flags & 32) { + result.push({ + name: type.text, + kindModifiers: ts.ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.variableElement, + sortText: "0" + }); + } + } + function getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker) { + var literalValue = ts.normalizeSlashes(node.text); + var scriptPath = node.getSourceFile().path; + var scriptDirectory = ts.getDirectoryPath(scriptPath); + var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); + var entries; + if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { + var extensions = ts.getSupportedExtensions(compilerOptions); + if (compilerOptions.rootDirs) { + entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, false, span, compilerOptions, host, scriptPath); + } + else { + entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensions, false, span, host, scriptPath); + } + } + else { + entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span, compilerOptions, host, typeChecker); + } + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: entries + }; + } + function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { + rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); + var relativeDirectory; + for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { + var rootDirectory = rootDirs_1[_i]; + if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { + relativeDirectory = scriptPath.substr(rootDirectory.length); + break; + } + } + return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); + } + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, compilerOptions, host, exclude) { + var basePath = compilerOptions.project || host.getCurrentDirectory(); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); + var result = []; + for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { + var baseDirectory = baseDirectories_1[_i]; + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, host, exclude, result); + } + return result; + } + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, host, exclude, result) { + if (result === void 0) { result = []; } + if (fragment === undefined) { + fragment = ""; + } + fragment = ts.normalizeSlashes(fragment); + fragment = ts.getDirectoryPath(fragment); + if (fragment === "") { + fragment = "." + ts.directorySeparator; + } + fragment = ts.ensureTrailingDirectorySeparator(fragment); + var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); + var baseDirectory = ts.getDirectoryPath(absolutePath); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + if (tryDirectoryExists(host, baseDirectory)) { + var files = tryReadDirectory(host, baseDirectory, extensions, undefined, ["./*"]); + if (files) { + var foundFiles = ts.createMap(); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var filePath = files_3[_i]; + filePath = ts.normalizePath(filePath); + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0) { + continue; + } + var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); + if (!foundFiles.get(foundFileName)) { + foundFiles.set(foundFileName, true); + } + } + ts.forEachKey(foundFiles, function (foundFile) { + result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); + }); + } + var directories = tryGetDirectories(host, baseDirectory); + if (directories) { + for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { + var directory = directories_2[_a]; + var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); + result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); + } + } + } + return result; + } + function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span, compilerOptions, host, typeChecker) { + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; + var result; + if (baseUrl) { + var fileExtensions = ts.getSupportedExtensions(compilerOptions); + var projectDir = compilerOptions.project || host.getCurrentDirectory(); + var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); + result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, false, span, host); + if (paths) { + for (var path in paths) { + if (paths.hasOwnProperty(path)) { + if (path === "*") { + if (paths[path]) { + for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { + var pattern = _a[_i]; + for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host); _b < _c.length; _b++) { + var match = _c[_b]; + result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + else if (ts.startsWith(path, fragment)) { + var entry = paths[path] && paths[path].length === 1 && paths[path][0]; + if (entry) { + result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); + } } } } } - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); - return uniqueNames; } - function getStringLiteralCompletionEntries(sourceFile, position) { - var node = ts.findPrecedingToken(position, sourceFile); - if (!node || node.kind !== 9) { - return undefined; + else { + result = []; + } + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); + for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host); _d < _e.length; _d++) { + var moduleName = _e[_d]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + return result; + } + function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { + if (host.readDirectory) { + var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; + if (parsed) { + var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); + var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); + var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); + var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; + var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; + var normalizedSuffix = ts.normalizePath(parsed.suffix); + var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); + var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + var includeGlob = normalizedSuffix ? "**/*" : "./*"; + var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); + if (matches) { + var result = []; + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; + var normalizedMatch = ts.normalizePath(match); + if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { + continue; + } + var start = completePrefix.length; + var length_5 = normalizedMatch.length - start - normalizedSuffix.length; + result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); + } + return result; + } } - if (node.parent.kind === 257 && - node.parent.parent.kind === 176 && - node.parent.name === node) { - return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); + } + return undefined; + } + function enumeratePotentialNonRelativeModules(fragment, scriptPath, options, typeChecker, host) { + var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; + var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; + var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); + var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); + if (isNestedModule) { + var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); + nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { + if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { + return moduleName.substr(moduleNameWithSeperator_1.length); + } + return moduleName; + }); + } + if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { + for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { + var visibleModule = _a[_i]; + if (!isNestedModule) { + nonRelativeModules.push(visibleModule.moduleName); + } + else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { + var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, undefined, ["./*"]); + if (nestedFiles) { + for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { + var f = nestedFiles_1[_b]; + f = ts.normalizePath(f); + var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); + nonRelativeModules.push(nestedModule); + } + } + } } - else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { - return getStringLiteralCompletionEntriesFromElementAccess(node.parent); - } - else if (node.parent.kind === 235 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { - return getStringLiteralCompletionEntriesFromModuleNames(node); + } + return ts.deduplicate(nonRelativeModules); + } + function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { + var token = ts.getTokenAtPosition(sourceFile, position); + if (!token) { + return undefined; + } + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + if (!commentRanges || !commentRanges.length) { + return undefined; + } + var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); + if (!range) { + return undefined; + } + var completionInfo = { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: [] + }; + var text = sourceFile.text.substr(range.pos, position - range.pos); + var match = tripleSlashDirectiveFragmentRegex.exec(text); + if (match) { + var prefix = match[1]; + var kind = match[2]; + var toComplete = match[3]; + var scriptPath = ts.getDirectoryPath(sourceFile.path); + if (kind === "path") { + var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), true, span_10, host, sourceFile.path); } else { - var argumentInfo = ts.SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); - if (argumentInfo) { - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); - } - return getStringLiteralCompletionEntriesFromContextualType(node); + var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); } } - function getStringLiteralCompletionEntriesFromPropertyAssignment(element) { - var type = typeChecker.getContextualType(element.parent); - var entries = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + return completionInfo; + } + function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { + if (result === void 0) { result = []; } + if (options.types) { + for (var _i = 0, _a = options.types; _i < _a.length; _i++) { + var moduleName = _a[_i]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + } + else if (host.getDirectories) { + var typeRoots = void 0; + try { + typeRoots = ts.getEffectiveTypeRoots(options, host); + } + catch (e) { } + if (typeRoots) { + for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { + var root = typeRoots_2[_b]; + getCompletionEntriesFromDirectories(host, root, span, result); } } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo) { - var candidates = []; - var entries = []; - typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); - for (var _i = 0, candidates_3 = candidates; _i < candidates_3.length; _i++) { - var candidate = candidates_3[_i]; - if (candidate.parameters.length > argumentInfo.argumentIndex) { - var parameter = candidate.parameters[argumentInfo.argumentIndex]; - addStringLiteralCompletionsFromType(typeChecker.getTypeAtLocation(parameter.valueDeclaration), entries); + if (host.getDirectories) { + for (var _c = 0, _d = findPackageJsons(scriptPath, host); _c < _d.length; _c++) { + var packageJson = _d[_c]; + var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(host, typesDir, span, result); + } + } + return result; + } + function getCompletionEntriesFromDirectories(host, directory, span, result) { + if (host.getDirectories && tryDirectoryExists(host, directory)) { + var directories = tryGetDirectories(host, directory); + if (directories) { + for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { + var typeDirectory = directories_3[_i]; + typeDirectory = ts.normalizePath(typeDirectory); + result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); } } - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; - } - return undefined; } - function getStringLiteralCompletionEntriesFromElementAccess(node) { - var type = typeChecker.getTypeAtLocation(node.expression); - var entries = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + function findPackageJsons(currentDir, host) { + var paths = []; + var currentConfigPath; + while (true) { + currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + currentDir = ts.getDirectoryPath(currentConfigPath); + var parent = ts.getDirectoryPath(currentDir); + if (currentDir === parent) { + break; } - } - return undefined; - } - function getStringLiteralCompletionEntriesFromContextualType(node) { - var type = typeChecker.getContextualType(node); - if (type) { - var entries_2 = []; - addStringLiteralCompletionsFromType(type, entries_2); - if (entries_2.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries_2 }; - } - } - return undefined; - } - function addStringLiteralCompletionsFromType(type, result) { - if (!type) { - return; - } - if (type.flags & 65536) { - ts.forEach(type.types, function (t) { return addStringLiteralCompletionsFromType(t, result); }); + currentDir = parent; } else { - if (type.flags & 32) { + break; + } + } + return paths; + } + function enumerateNodeModulesVisibleToScript(host, scriptPath) { + var result = []; + if (host.readFile && host.fileExists) { + for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + var packageJson = _a[_i]; + var contents = tryReadingPackageJson(packageJson); + if (!contents) { + return; + } + var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); + var foundModuleNames = []; + for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { + var key = nodeModulesDependencyKeys_1[_b]; + addPotentialPackageNames(contents[key], foundModuleNames); + } + for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { + var moduleName = foundModuleNames_1[_c]; + var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); result.push({ - name: type.text, - kindModifiers: ts.ScriptElementKindModifier.none, - kind: ts.ScriptElementKind.variableElement, - sortText: "0" + moduleName: moduleName, + moduleDir: moduleDir }); } } } - function getStringLiteralCompletionEntriesFromModuleNames(node) { - var literalValue = ts.normalizeSlashes(node.text); - var scriptPath = node.getSourceFile().path; - var scriptDirectory = ts.getDirectoryPath(scriptPath); - var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); - var entries; - if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { - if (compilerOptions.rootDirs) { - entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), false, span, scriptPath); - } - else { - entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), false, span, scriptPath); - } + return result; + function tryReadingPackageJson(filePath) { + try { + var fileText = tryReadFile(host, filePath); + return fileText ? JSON.parse(fileText) : undefined; } - else { - entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); - } - return { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: entries - }; - } - function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { - rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); - var relativeDirectory; - for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { - var rootDirectory = rootDirs_1[_i]; - if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { - relativeDirectory = scriptPath.substr(rootDirectory.length); - break; - } - } - return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); - } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, exclude) { - var basePath = compilerOptions.project || host.getCurrentDirectory(); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); - var result = []; - for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { - var baseDirectory = baseDirectories_1[_i]; - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, exclude, result); - } - return result; - } - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, exclude, result) { - if (result === void 0) { result = []; } - if (fragment === undefined) { - fragment = ""; - } - fragment = ts.normalizeSlashes(fragment); - fragment = ts.getDirectoryPath(fragment); - if (fragment === "") { - fragment = "." + ts.directorySeparator; - } - fragment = ts.ensureTrailingDirectorySeparator(fragment); - var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); - var baseDirectory = ts.getDirectoryPath(absolutePath); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (tryDirectoryExists(host, baseDirectory)) { - var files = tryReadDirectory(host, baseDirectory, extensions, undefined, ["./*"]); - if (files) { - var foundFiles = ts.createMap(); - for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { - var filePath = files_3[_i]; - filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0) { - continue; - } - var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); - if (!foundFiles[foundFileName]) { - foundFiles[foundFileName] = true; - } - } - for (var foundFile in foundFiles) { - result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); - } - } - var directories = tryGetDirectories(host, baseDirectory); - if (directories) { - for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { - var directory = directories_2[_a]; - var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); - } - } - } - return result; - } - function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span) { - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var result; - if (baseUrl) { - var fileExtensions = ts.getSupportedExtensions(compilerOptions); - var projectDir = compilerOptions.project || host.getCurrentDirectory(); - var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); - result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, false, span); - if (paths) { - for (var path in paths) { - if (paths.hasOwnProperty(path)) { - if (path === "*") { - if (paths[path]) { - for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { - var pattern = _a[_i]; - for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions); _b < _c.length; _b++) { - var match = _c[_b]; - result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - else if (ts.startsWith(path, fragment)) { - var entry = paths[path] && paths[path].length === 1 && paths[path][0]; - if (entry) { - result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - } - } - else { - result = []; - } - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); - for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions); _d < _e.length; _d++) { - var moduleName = _e[_d]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - return result; - } - function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions) { - if (host.readDirectory) { - var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; - if (parsed) { - var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); - var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); - var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); - var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; - var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; - var normalizedSuffix = ts.normalizePath(parsed.suffix); - var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); - var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); - if (matches) { - var result = []; - for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { - var match = matches_1[_i]; - var normalizedMatch = ts.normalizePath(match); - if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { - continue; - } - var start = completePrefix.length; - var length_5 = normalizedMatch.length - start - normalizedSuffix.length; - result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); - } - return result; - } - } - } - return undefined; - } - function enumeratePotentialNonRelativeModules(fragment, scriptPath, options) { - var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; - var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; - var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); - var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); - if (isNestedModule) { - var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); - nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { - if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { - return moduleName.substr(moduleNameWithSeperator_1.length); - } - return moduleName; - }); - } - if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { - for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { - var visibleModule = _a[_i]; - if (!isNestedModule) { - nonRelativeModules.push(visibleModule.moduleName); - } - else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { - var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, undefined, ["./*"]); - if (nestedFiles) { - for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { - var f = nestedFiles_1[_b]; - f = ts.normalizePath(f); - var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); - nonRelativeModules.push(nestedModule); - } - } - } - } - } - return ts.deduplicate(nonRelativeModules); - } - function getTripleSlashReferenceCompletion(sourceFile, position) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (!token) { + catch (e) { return undefined; } - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - if (!commentRanges || !commentRanges.length) { - return undefined; - } - var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); - if (!range) { - return undefined; - } - var completionInfo = { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: [] - }; - var text = sourceFile.text.substr(range.pos, position - range.pos); - var match = tripleSlashDirectiveFragmentRegex.exec(text); - if (match) { - var prefix = match[1]; - var kind = match[2]; - var toComplete = match[3]; - var scriptPath = ts.getDirectoryPath(sourceFile.path); - if (kind === "path") { - var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), true, span_10, sourceFile.path); - } - else { - var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); - } - } - return completionInfo; } - function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { - if (result === void 0) { result = []; } - if (options.types) { - for (var _i = 0, _a = options.types; _i < _a.length; _i++) { - var moduleName = _a[_i]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - } - else if (host.getDirectories) { - var typeRoots = void 0; - try { - typeRoots = ts.getEffectiveTypeRoots(options, host); - } - catch (e) { } - if (typeRoots) { - for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { - var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, root, span, result); + function addPotentialPackageNames(dependencies, result) { + if (dependencies) { + for (var dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { + result.push(dep); } } } - if (host.getDirectories) { - for (var _c = 0, _d = findPackageJsons(scriptPath); _c < _d.length; _c++) { - var packageJson = _d[_c]; - var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, typesDir, span, result); - } - } - return result; - } - function getCompletionEntriesFromDirectories(host, directory, span, result) { - if (host.getDirectories && tryDirectoryExists(host, directory)) { - var directories = tryGetDirectories(host, directory); - if (directories) { - for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { - var typeDirectory = directories_3[_i]; - typeDirectory = ts.normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - function findPackageJsons(currentDir) { - var paths = []; - var currentConfigPath; - while (true) { - currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); - currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_13 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_13) { - break; - } - currentDir = parent_13; - } - else { - break; - } - } - return paths; - } - function enumerateNodeModulesVisibleToScript(host, scriptPath) { - var result = []; - if (host.readFile && host.fileExists) { - for (var _i = 0, _a = findPackageJsons(scriptPath); _i < _a.length; _i++) { - var packageJson = _a[_i]; - var contents = tryReadingPackageJson(packageJson); - if (!contents) { - return; - } - var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); - var foundModuleNames = []; - for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { - var key = nodeModulesDependencyKeys_1[_b]; - addPotentialPackageNames(contents[key], foundModuleNames); - } - for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { - var moduleName = foundModuleNames_1[_c]; - var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName: moduleName, - moduleDir: moduleDir - }); - } - } - } - return result; - function tryReadingPackageJson(filePath) { - try { - var fileText = tryReadFile(host, filePath); - return fileText ? JSON.parse(fileText) : undefined; - } - catch (e) { - return undefined; - } - } - function addPotentialPackageNames(dependencies, result) { - if (dependencies) { - for (var dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { - result.push(dep); - } - } - } - } - } - function createCompletionEntryForModule(name, kind, replacementSpan) { - return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; - } - function getDirectoryFragmentTextSpan(text, textStart) { - var index = text.lastIndexOf(ts.directorySeparator); - var offset = index !== -1 ? index + 1 : 0; - return { start: textStart + offset, length: text.length - offset }; - } - function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 ? 2 : 1; - var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 || slashCharCode === 92; - } - return false; - } - function normalizeAndPreserveTrailingSlash(path) { - return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); } } - Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function createCompletionEntryForModule(name, kind, replacementSpan) { + return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; + } + function getDirectoryFragmentTextSpan(text, textStart) { + var index = text.lastIndexOf(ts.directorySeparator); + var offset = index !== -1 ? index + 1 : 0; + return { start: textStart + offset, length: text.length - offset }; + } + function isPathRelativeToScript(path) { + if (path && path.length >= 2 && path.charCodeAt(0) === 46) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 ? 2 : 1; + var slashCharCode = path.charCodeAt(slashIndex); + return slashCharCode === 47 || slashCharCode === 92; + } + return false; + } + function normalizeAndPreserveTrailingSlash(path) { + return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); + } function getCompletionEntryDetails(typeChecker, log, compilerOptions, sourceFile, position, entryName) { var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_3 = completionData.location; - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_3) === entryName ? s : undefined; }); + var symbols = completionData.symbols, location_1 = completionData.location; + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_1) === entryName ? s : undefined; }); if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_3, location_3, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { name: entryName, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), @@ -55139,8 +58031,8 @@ var ts; function getCompletionEntrySymbol(typeChecker, log, compilerOptions, sourceFile, position, entryName) { var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_4 = completionData.location; - return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_4) === entryName ? s : undefined; }); + var symbols = completionData.symbols, location_2 = completionData.location; + return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_2) === entryName ? s : undefined; }); } return undefined; } @@ -55165,9 +58057,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 283: - case 281: - case 282: + case 287: + case 285: + case 286: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -55202,13 +58094,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_14 = contextToken.parent, kind = contextToken.kind; + var parent = contextToken.parent, kind = contextToken.kind; if (kind === 22) { - if (parent_14.kind === 177) { + if (parent.kind === 178) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_14.kind === 141) { + else if (parent.kind === 142) { node = contextToken.parent.left; isRightOfDot = true; } @@ -55217,13 +58109,25 @@ var ts; } } else if (sourceFile.languageVariant === 1) { - if (kind === 26) { - isRightOfOpenTag = true; - location = contextToken; - } - else if (kind === 40 && contextToken.parent.kind === 249) { - isStartingCloseTag = true; - location = contextToken; + switch (contextToken.parent.kind) { + case 251: + if (kind === 40) { + isStartingCloseTag = true; + location = contextToken; + } + break; + case 193: + if (!(contextToken.parent.left.flags & 32768)) { + break; + } + case 249: + case 248: + case 250: + if (kind === 26) { + isRightOfOpenTag = true; + location = contextToken; + } + break; } } } @@ -55266,7 +58170,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 70 || node.kind === 141 || node.kind === 177) { + if (node.kind === 70 || node.kind === 142 || node.kind === 178) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -55312,10 +58216,10 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 247) || (jsxContainer.kind === 248)) { - attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + if ((jsxContainer.kind === 249) || (jsxContainer.kind === 250)) { + attrsType = typeChecker.getAllAttributesTypeFromJsxOpeningLikeElement(jsxContainer); if (attrsType) { - symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); + symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes.properties); isMemberCompletion = true; isNewIdentifierLocation = false; return true; @@ -55333,9 +58237,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 261 || - scopeNode.kind === 194 || - scopeNode.kind === 252 || + scopeNode.kind === 264 || + scopeNode.kind === 195 || + scopeNode.kind === 255 || ts.isStatement(scopeNode); } var symbolMeanings = 793064 | 107455 | 1920 | 8388608; @@ -55363,11 +58267,11 @@ var ts; return true; } if (contextToken.kind === 28 && contextToken.parent) { - if (contextToken.parent.kind === 248) { + if (contextToken.parent.kind === 250) { return true; } - if (contextToken.parent.kind === 249 || contextToken.parent.kind === 247) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 246; + if (contextToken.parent.kind === 251 || contextToken.parent.kind === 249) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 248; } } return false; @@ -55377,40 +58281,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 25: - return containingNodeKind === 179 - || containingNodeKind === 150 - || containingNodeKind === 180 - || containingNodeKind === 175 - || containingNodeKind === 192 - || containingNodeKind === 158; + return containingNodeKind === 180 + || containingNodeKind === 151 + || containingNodeKind === 181 + || containingNodeKind === 176 + || containingNodeKind === 193 + || containingNodeKind === 159; case 18: - return containingNodeKind === 179 - || containingNodeKind === 150 - || containingNodeKind === 180 - || containingNodeKind === 183 - || containingNodeKind === 166; + return containingNodeKind === 180 + || containingNodeKind === 151 + || containingNodeKind === 181 + || containingNodeKind === 184 + || containingNodeKind === 167; case 20: - return containingNodeKind === 175 - || containingNodeKind === 155 - || containingNodeKind === 142; + return containingNodeKind === 176 + || containingNodeKind === 156 + || containingNodeKind === 143; case 127: case 128: return true; case 22: - return containingNodeKind === 230; + return containingNodeKind === 232; case 16: - return containingNodeKind === 226; + return containingNodeKind === 228; case 57: - return containingNodeKind === 223 - || containingNodeKind === 192; + return containingNodeKind === 225 + || containingNodeKind === 193; case 13: - return containingNodeKind === 194; + return containingNodeKind === 195; case 14: - return containingNodeKind === 202; + return containingNodeKind === 204; case 113: case 111: case 112: - return containingNodeKind === 147; + return containingNodeKind === 148; } switch (previousToken.getText()) { case "public": @@ -55441,22 +58345,22 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 176) { + if (objectLikeContainer.kind === 177) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 172) { + else if (objectLikeContainer.kind === 173) { isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); if (ts.isVariableLike(rootDeclaration)) { var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 144) { + if (!canGetType && rootDeclaration.kind === 145) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 149 || rootDeclaration.parent.kind === 152) { + else if (rootDeclaration.parent.kind === 150 || rootDeclaration.parent.kind === 153) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -55482,9 +58386,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 238 ? - 235 : - 241; + var declarationKind = namedImportsOrExports.kind === 240 ? + 237 : + 243; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -55492,12 +58396,13 @@ var ts; } isMemberCompletion = true; isNewIdentifierLocation = false; - var exports; - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); + if (!moduleSpecifierSymbol) { + symbols = ts.emptyArray; + return true; } - symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : ts.emptyArray; + var exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); + symbols = filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements); return true; } function tryGetObjectLikeCompletionContainer(contextToken) { @@ -55505,9 +58410,9 @@ var ts; switch (contextToken.kind) { case 16: case 25: - var parent_15 = contextToken.parent; - if (parent_15 && (parent_15.kind === 176 || parent_15.kind === 172)) { - return parent_15; + var parent = contextToken.parent; + if (parent && (parent.kind === 177 || parent.kind === 173)) { + return parent; } break; } @@ -55520,8 +58425,8 @@ var ts; case 16: case 25: switch (contextToken.parent.kind) { - case 238: - case 242: + case 240: + case 244: return contextToken.parent; } } @@ -55530,34 +58435,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_16 = contextToken.parent; + var parent = contextToken.parent; switch (contextToken.kind) { case 27: case 40: case 70: - case 250: - case 251: - if (parent_16 && (parent_16.kind === 247 || parent_16.kind === 248)) { - return parent_16; + case 253: + case 252: + case 254: + if (parent && (parent.kind === 249 || parent.kind === 250)) { + return parent; } - else if (parent_16.kind === 250) { - return parent_16.parent; + else if (parent.kind === 252) { + return parent.parent.parent; } break; case 9: - if (parent_16 && ((parent_16.kind === 250) || (parent_16.kind === 251))) { - return parent_16.parent; + if (parent && ((parent.kind === 252) || (parent.kind === 254))) { + return parent.parent.parent; } break; case 17: - if (parent_16 && - parent_16.kind === 252 && - parent_16.parent && - (parent_16.parent.kind === 250)) { - return parent_16.parent.parent; + if (parent && + parent.kind === 255 && + parent.parent && parent.parent.kind === 252) { + return parent.parent.parent.parent; } - if (parent_16 && parent_16.kind === 251) { - return parent_16.parent; + if (parent && parent.kind === 254) { + return parent.parent.parent; } break; } @@ -55566,16 +58471,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 184: case 185: - case 225: + case 186: + case 227: + case 150: case 149: - case 148: - case 151: case 152: case 153: case 154: case 155: + case 156: return true; } return false; @@ -55584,66 +58489,66 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25: - return containingNodeKind === 223 || - containingNodeKind === 224 || - containingNodeKind === 205 || - containingNodeKind === 229 || - isFunction(containingNodeKind) || + return containingNodeKind === 225 || containingNodeKind === 226 || - containingNodeKind === 197 || - containingNodeKind === 227 || - containingNodeKind === 173 || - containingNodeKind === 228; + containingNodeKind === 207 || + containingNodeKind === 231 || + isFunction(containingNodeKind) || + containingNodeKind === 228 || + containingNodeKind === 198 || + containingNodeKind === 229 || + containingNodeKind === 174 || + containingNodeKind === 230; case 22: - return containingNodeKind === 173; - case 55: return containingNodeKind === 174; + case 55: + return containingNodeKind === 175; case 20: - return containingNodeKind === 173; + return containingNodeKind === 174; case 18: - return containingNodeKind === 256 || + return containingNodeKind === 259 || isFunction(containingNodeKind); case 16: - return containingNodeKind === 229 || - containingNodeKind === 227 || - containingNodeKind === 161; + return containingNodeKind === 231 || + containingNodeKind === 229 || + containingNodeKind === 162; case 24: - return containingNodeKind === 146 && + return containingNodeKind === 147 && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 227 || - contextToken.parent.parent.kind === 161); + (contextToken.parent.parent.kind === 229 || + contextToken.parent.parent.kind === 162); case 26: - return containingNodeKind === 226 || - containingNodeKind === 197 || - containingNodeKind === 227 || - containingNodeKind === 228 || + return containingNodeKind === 228 || + containingNodeKind === 198 || + containingNodeKind === 229 || + containingNodeKind === 230 || isFunction(containingNodeKind); case 114: - return containingNodeKind === 147; + return containingNodeKind === 148; case 23: - return containingNodeKind === 144 || + return containingNodeKind === 145 || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 173); + contextToken.parent.parent.kind === 174); case 113: case 111: case 112: - return containingNodeKind === 144; + return containingNodeKind === 145; case 117: - return containingNodeKind === 239 || - containingNodeKind === 243 || - containingNodeKind === 237; + return containingNodeKind === 241 || + containingNodeKind === 245 || + containingNodeKind === 239; case 74: case 82: case 108: case 88: case 103: case 124: - case 133: + case 134: case 90: case 109: case 75: case 115: - case 136: + case 137: return true; } switch (contextToken.getText()) { @@ -55680,13 +58585,13 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_46 = element.propertyName || element.name; - existingImportsOrExports[name_46.text] = true; + var name = element.propertyName || element.name; + existingImportsOrExports.set(name.text, true); } - if (!ts.someProperties(existingImportsOrExports)) { + if (existingImportsOrExports.size === 0) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); } - return ts.filter(exportsOfModule, function (e) { return e.name !== "default" && !existingImportsOrExports[e.name]; }); + return ts.filter(exportsOfModule, function (e) { return e.name !== "default" && !existingImportsOrExports.get(e.name); }); } function filterObjectMembersList(contextualMemberSymbols, existingMembers) { if (!existingMembers || existingMembers.length === 0) { @@ -55695,19 +58600,19 @@ var ts; var existingMemberNames = ts.createMap(); for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; - if (m.kind !== 257 && - m.kind !== 258 && - m.kind !== 174 && - m.kind !== 149 && - m.kind !== 151 && - m.kind !== 152) { + if (m.kind !== 260 && + m.kind !== 261 && + m.kind !== 175 && + m.kind !== 150 && + m.kind !== 152 && + m.kind !== 153) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 174 && m.propertyName) { + if (m.kind === 175 && m.propertyName) { if (m.propertyName.kind === 70) { existingName = m.propertyName.text; } @@ -55715,9 +58620,9 @@ var ts; else { existingName = m.name.text; } - existingMemberNames[existingName] = true; + existingMemberNames.set(existingName, true); } - return ts.filter(contextualMemberSymbols, function (m) { return !existingMemberNames[m.name]; }); + return ts.filter(contextualMemberSymbols, function (m) { return !existingMemberNames.get(m.name); }); } function filterJsxAttributes(symbols, attributes) { var seenNames = ts.createMap(); @@ -55726,11 +58631,11 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 250) { - seenNames[attr.name.text] = true; + if (attr.kind === 252) { + seenNames.set(attr.name.text, true); } } - return ts.filter(symbols, function (a) { return !seenNames[a.name]; }); + return ts.filter(symbols, function (a) { return !seenNames.get(a.name); }); } } function getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, target, performCharacterChecks, location) { @@ -55759,7 +58664,7 @@ var ts; return name; } var keywordCompletions = []; - for (var i = 71; i <= 140; i++) { + for (var i = 71; i <= 141; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -55799,6 +58704,15 @@ var ts; catch (e) { } return undefined; } + function isEqualityExpression(node) { + return ts.isBinaryExpression(node) && isEqualityOperatorKind(node.operatorToken.kind); + } + function isEqualityOperatorKind(kind) { + return kind == 31 || + kind === 32 || + kind === 33 || + kind === 34; + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); var ts; @@ -55807,495 +58721,480 @@ var ts; (function (DocumentHighlights) { function getDocumentHighlights(typeChecker, cancellationToken, sourceFile, position, sourceFilesToSearch) { var node = ts.getTouchingWord(sourceFile, position); + return node && (getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) || getSyntacticDocumentHighlights(node, sourceFile)); + } + DocumentHighlights.getDocumentHighlights = getDocumentHighlights; + function getHighlightSpanForNode(node, sourceFile) { + var start = node.getStart(sourceFile); + var end = node.getEnd(); + return { + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(start, end), + kind: ts.HighlightSpanKind.none + }; + } + function getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) { + var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch); + return referencedSymbols && convertReferencedSymbols(referencedSymbols); + } + function convertReferencedSymbols(referencedSymbols) { + var fileNameToDocumentHighlights = ts.createMap(); + var result = []; + 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 = referenceEntry.fileName; + var documentHighlights = fileNameToDocumentHighlights.get(fileName); + if (!documentHighlights) { + documentHighlights = { fileName: fileName, highlightSpans: [] }; + fileNameToDocumentHighlights.set(fileName, documentHighlights); + result.push(documentHighlights); + } + documentHighlights.highlightSpans.push({ + textSpan: referenceEntry.textSpan, + kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference + }); + } + } + return result; + } + function getSyntacticDocumentHighlights(node, sourceFile) { + var highlightSpans = getHighlightSpans(node, sourceFile); + if (!highlightSpans || highlightSpans.length === 0) { + return undefined; + } + return [{ fileName: sourceFile.fileName, highlightSpans: highlightSpans }]; + } + function hasKind(node, kind) { + return node !== undefined && node.kind === kind; + } + function parent(node) { + return node && node.parent; + } + function getHighlightSpans(node, sourceFile) { 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: ts.HighlightSpanKind.none - }; + switch (node.kind) { + case 89: + case 81: + if (hasKind(node.parent, 210)) { + return getIfElseOccurrences(node.parent, sourceFile); + } + break; + case 95: + if (hasKind(node.parent, 218)) { + return highlightSpans(getReturnOccurrences(node.parent)); + } + break; + case 99: + if (hasKind(node.parent, 222)) { + return highlightSpans(getThrowOccurrences(node.parent)); + } + break; + case 101: + case 73: + case 86: + var tryStatement = node.kind === 73 ? parent(parent(node)) : parent(node); + if (hasKind(tryStatement, 223)) { + return highlightSpans(getTryCatchFinallyOccurrences(tryStatement, sourceFile)); + } + break; + case 97: + if (hasKind(node.parent, 220)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent)); + } + break; + case 72: + case 78: + if (hasKind(parent(parent(parent(node))), 220)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent.parent.parent)); + } + break; + case 71: + case 76: + if (hasKind(node.parent, 217) || hasKind(node.parent, 216)) { + return highlightSpans(getBreakOrContinueStatementOccurrences(node.parent)); + } + break; + case 87: + if (hasKind(node.parent, 213) || + hasKind(node.parent, 214) || + hasKind(node.parent, 215)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case 105: + case 80: + if (hasKind(node.parent, 212) || hasKind(node.parent, 211)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case 122: + if (hasKind(node.parent, 151)) { + return highlightSpans(getConstructorOccurrences(node.parent)); + } + break; + case 124: + case 134: + if (hasKind(node.parent, 152) || hasKind(node.parent, 153)) { + return highlightSpans(getGetAndSetOccurrences(node.parent)); + } + break; + default: + if (ts.isModifierKind(node.kind) && node.parent && + (ts.isDeclaration(node.parent) || node.parent.kind === 207)) { + return highlightSpans(getModifierOccurrences(node.kind, node.parent)); + } } - function getSemanticDocumentHighlights(node) { - if (node.kind === 70 || - node.kind === 98 || - node.kind === 167 || - node.kind === 96 || - node.kind === 9 || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, false, false, false); - return convertReferencedSymbols(referencedSymbols); - } - return undefined; - function convertReferencedSymbols(referencedSymbols) { - if (!referencedSymbols) { - return undefined; - } - var fileNameToDocumentHighlights = ts.createMap(); - var result = []; - 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 = referenceEntry.fileName; - var documentHighlights = fileNameToDocumentHighlights[fileName]; - if (!documentHighlights) { - documentHighlights = { fileName: fileName, highlightSpans: [] }; - fileNameToDocumentHighlights[fileName] = documentHighlights; - result.push(documentHighlights); - } - documentHighlights.highlightSpans.push({ - textSpan: referenceEntry.textSpan, - kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference - }); - } - } - return result; - } + function highlightSpans(nodes) { + return nodes && nodes.map(function (node) { return getHighlightSpanForNode(node, sourceFile); }); } - function getSyntacticDocumentHighlights(node) { - var fileName = sourceFile.fileName; - var highlightSpans = getHighlightSpans(node); - if (!highlightSpans || highlightSpans.length === 0) { - return undefined; + } + function aggregateOwnedThrowStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 222) { + statementAccumulator.push(node); } - 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 89: - case 81: - if (hasKind(node.parent, 208)) { - return getIfElseOccurrences(node.parent); - } - break; - case 95: - if (hasKind(node.parent, 216)) { - return getReturnOccurrences(node.parent); - } - break; - case 99: - if (hasKind(node.parent, 220)) { - return getThrowOccurrences(node.parent); - } - break; - case 73: - if (hasKind(parent(parent(node)), 221)) { - return getTryCatchFinallyOccurrences(node.parent.parent); - } - break; - case 101: - case 86: - if (hasKind(parent(node), 221)) { - return getTryCatchFinallyOccurrences(node.parent); - } - break; - case 97: - if (hasKind(node.parent, 218)) { - return getSwitchCaseDefaultOccurrences(node.parent); - } - break; - case 72: - case 78: - if (hasKind(parent(parent(parent(node))), 218)) { - return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); - } - break; - case 71: - case 76: - if (hasKind(node.parent, 215) || hasKind(node.parent, 214)) { - return getBreakOrContinueStatementOccurrences(node.parent); - } - break; - case 87: - if (hasKind(node.parent, 211) || - hasKind(node.parent, 212) || - hasKind(node.parent, 213)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 105: - case 80: - if (hasKind(node.parent, 210) || hasKind(node.parent, 209)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 122: - if (hasKind(node.parent, 150)) { - return getConstructorOccurrences(node.parent); - } - break; - case 124: - case 133: - if (hasKind(node.parent, 151) || hasKind(node.parent, 152)) { - return getGetAndSetOccurrences(node.parent); - } - break; - default: - if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 205)) { - return getModifierOccurrences(node.kind, node.parent); - } - } - } - return undefined; - } - function aggregateOwnedThrowStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 220) { - statementAccumulator.push(node); - } - else if (node.kind === 221) { - 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_17 = child.parent; - if (ts.isFunctionBlock(parent_17) || parent_17.kind === 261) { - return parent_17; - } - if (parent_17.kind === 221) { - var tryStatement = parent_17; - if (tryStatement.tryBlock === child && tryStatement.catchClause) { - return child; - } - } - child = parent_17; - } - return undefined; - } - function aggregateAllBreakAndContinueStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 215 || node.kind === 214) { - 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_1 = statement.parent; node_1; node_1 = node_1.parent) { - switch (node_1.kind) { - case 218: - if (statement.kind === 214) { - continue; - } - case 211: - case 212: - case 213: - case 210: - case 209: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; - } - break; - default: - if (ts.isFunctionLike(node_1)) { - return undefined; - } - break; - } - } - return undefined; - } - function getModifierOccurrences(modifier, declaration) { - var container = declaration.parent; - if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 226 || - container.kind === 197 || - (declaration.kind === 144 && hasKind(container, 150)))) { - return undefined; - } - } - else if (modifier === 114) { - if (!(container.kind === 226 || container.kind === 197)) { - return undefined; - } - } - else if (modifier === 83 || modifier === 123) { - if (!(container.kind === 231 || container.kind === 261)) { - return undefined; - } - } - else if (modifier === 116) { - if (!(container.kind === 226 || declaration.kind === 226)) { - return undefined; - } + else if (node.kind === 223) { + var tryStatement = node; + if (tryStatement.catchClause) { + aggregate(tryStatement.catchClause); } else { - return undefined; - } - var keywords = []; - var modifierFlag = getFlagFromModifier(modifier); - var nodes; - switch (container.kind) { - case 231: - case 261: - if (modifierFlag & 128) { - nodes = declaration.members.concat(declaration); - } - else { - nodes = container.statements; - } - break; - case 150: - nodes = container.parameters.concat(container.parent.members); - break; - case 226: - case 197: - nodes = container.members; - if (modifierFlag & 28) { - var constructor = ts.forEach(container.members, function (member) { - return member.kind === 150 && member; - }); - if (constructor) { - nodes = nodes.concat(constructor.parameters); - } - } - else if (modifierFlag & 128) { - nodes = nodes.concat(container); - } - break; - default: - ts.Debug.fail("Invalid container kind."); - } - ts.forEach(nodes, function (node) { - if (ts.getModifierFlags(node) & modifierFlag) { - ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - function getFlagFromModifier(modifier) { - switch (modifier) { - case 113: - return 4; - case 111: - return 8; - case 112: - return 16; - case 114: - return 32; - case 83: - return 1; - case 123: - return 2; - case 116: - return 128; - 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, 151); - tryPushAccessorKeyword(accessorDeclaration.symbol, 152); - 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, 124, 133); }); - } - } - } - 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, 122); - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getLoopBreakContinueOccurrences(loopNode) { - var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { - if (loopNode.kind === 209) { - var loopTokens = loopNode.getChildren(); - for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 105)) { - break; - } - } - } - } - var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71, 76); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { - var owner = getBreakOrContinueOwner(breakOrContinueStatement); - if (owner) { - switch (owner.kind) { - case 211: - case 212: - case 213: - case 209: - case 210: - return getLoopBreakContinueOccurrences(owner); - case 218: - return getSwitchCaseDefaultOccurrences(owner); - } - } - return undefined; - } - function getSwitchCaseDefaultOccurrences(switchStatement) { - var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 97); - ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 72, 78); - var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71); - } - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getTryCatchFinallyOccurrences(tryStatement) { - var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 101); - if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73); + aggregate(tryStatement.tryBlock); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 86); + aggregate(tryStatement.finallyBlock); } - 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(), 99); - }); - if (ts.isFunctionBlock(owner)) { - ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); - }); - } - return ts.map(keywords, getHighlightSpanForNode); - } - function getReturnOccurrences(returnStatement) { - var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 204))) { - return undefined; - } - var keywords = []; - ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); - }); - ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getIfElseOccurrences(ifStatement) { - var keywords = []; - while (hasKind(ifStatement.parent, 208) && ifStatement.parent.elseStatement === ifStatement) { - ifStatement = ifStatement.parent; - } - while (ifStatement) { - var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 89); - for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 81)) { - break; - } - } - if (!hasKind(ifStatement.elseStatement, 208)) { - break; - } - ifStatement = ifStatement.elseStatement; - } - var result = []; - for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 81 && 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.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { - shouldCombindElseAndIf = false; - break; - } - } - if (shouldCombindElseAndIf) { - result.push({ - fileName: fileName, - textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: ts.HighlightSpanKind.reference - }); - i++; - continue; - } - } - result.push(getHighlightSpanForNode(keywords[i])); - } - return result; + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); } } } - DocumentHighlights.getDocumentHighlights = getDocumentHighlights; + function getThrowStatementOwner(throwStatement) { + var child = throwStatement; + while (child.parent) { + var parent_2 = child.parent; + if (ts.isFunctionBlock(parent_2) || parent_2.kind === 264) { + return parent_2; + } + if (parent_2.kind === 223) { + var tryStatement = parent_2; + if (tryStatement.tryBlock === child && tryStatement.catchClause) { + return child; + } + } + child = parent_2; + } + return undefined; + } + function aggregateAllBreakAndContinueStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 217 || node.kind === 216) { + 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 = statement.parent; node; node = node.parent) { + switch (node.kind) { + case 220: + if (statement.kind === 216) { + continue; + } + case 213: + case 214: + case 215: + case 212: + case 211: + if (!statement.label || isLabeledBy(node, statement.label.text)) { + return node; + } + break; + default: + if (ts.isFunctionLike(node)) { + return undefined; + } + break; + } + } + return undefined; + } + function getModifierOccurrences(modifier, declaration) { + var container = declaration.parent; + if (ts.isAccessibilityModifier(modifier)) { + if (!(container.kind === 228 || + container.kind === 198 || + (declaration.kind === 145 && hasKind(container, 151)))) { + return undefined; + } + } + else if (modifier === 114) { + if (!(container.kind === 228 || container.kind === 198)) { + return undefined; + } + } + else if (modifier === 83 || modifier === 123) { + if (!(container.kind === 233 || container.kind === 264)) { + return undefined; + } + } + else if (modifier === 116) { + if (!(container.kind === 228 || declaration.kind === 228)) { + return undefined; + } + } + else { + return undefined; + } + var keywords = []; + var modifierFlag = getFlagFromModifier(modifier); + var nodes; + switch (container.kind) { + case 233: + case 264: + if (modifierFlag & 128) { + nodes = declaration.members.concat(declaration); + } + else { + nodes = container.statements; + } + break; + case 151: + nodes = container.parameters.concat(container.parent.members); + break; + case 228: + case 198: + nodes = container.members; + if (modifierFlag & 28) { + var constructor = ts.forEach(container.members, function (member) { + return member.kind === 151 && member; + }); + if (constructor) { + nodes = nodes.concat(constructor.parameters); + } + } + else if (modifierFlag & 128) { + nodes = nodes.concat(container); + } + break; + default: + ts.Debug.fail("Invalid container kind."); + } + ts.forEach(nodes, function (node) { + if (ts.getModifierFlags(node) & modifierFlag) { + ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); + } + }); + return keywords; + function getFlagFromModifier(modifier) { + switch (modifier) { + case 113: + return 4; + case 111: + return 8; + case 112: + return 16; + case 114: + return 32; + case 83: + return 1; + case 123: + return 2; + case 116: + return 128; + 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, 152); + tryPushAccessorKeyword(accessorDeclaration.symbol, 153); + return keywords; + function tryPushAccessorKeyword(accessorSymbol, accessorKind) { + var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); + if (accessor) { + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124, 134); }); + } + } + } + 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, 122); + }); + }); + return keywords; + } + function getLoopBreakContinueOccurrences(loopNode) { + var keywords = []; + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { + if (loopNode.kind === 211) { + var loopTokens = loopNode.getChildren(); + for (var i = loopTokens.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, loopTokens[i], 105)) { + break; + } + } + } + } + var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(loopNode, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 71, 76); + } + }); + return keywords; + } + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { + var owner = getBreakOrContinueOwner(breakOrContinueStatement); + if (owner) { + switch (owner.kind) { + case 213: + case 214: + case 215: + case 211: + case 212: + return getLoopBreakContinueOccurrences(owner); + case 220: + return getSwitchCaseDefaultOccurrences(owner); + } + } + return undefined; + } + function getSwitchCaseDefaultOccurrences(switchStatement) { + var keywords = []; + pushKeywordIf(keywords, switchStatement.getFirstToken(), 97); + ts.forEach(switchStatement.caseBlock.clauses, function (clause) { + pushKeywordIf(keywords, clause.getFirstToken(), 72, 78); + var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(switchStatement, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 71); + } + }); + }); + return keywords; + } + function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { + var keywords = []; + pushKeywordIf(keywords, tryStatement.getFirstToken(), 101); + if (tryStatement.catchClause) { + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73); + } + if (tryStatement.finallyBlock) { + var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 86); + } + return keywords; + } + function getThrowOccurrences(throwStatement) { + var owner = getThrowStatementOwner(throwStatement); + if (!owner) { + return undefined; + } + var keywords = []; + ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); + }); + if (ts.isFunctionBlock(owner)) { + ts.forEachReturnStatement(owner, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); + }); + } + return keywords; + } + function getReturnOccurrences(returnStatement) { + var func = ts.getContainingFunction(returnStatement); + if (!(func && hasKind(func.body, 206))) { + return undefined; + } + var keywords = []; + ts.forEachReturnStatement(func.body, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); + }); + ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); + }); + return keywords; + } + function getIfElseOccurrences(ifStatement, sourceFile) { + var keywords = []; + while (hasKind(ifStatement.parent, 210) && ifStatement.parent.elseStatement === ifStatement) { + ifStatement = ifStatement.parent; + } + while (ifStatement) { + var children = ifStatement.getChildren(); + pushKeywordIf(keywords, children[0], 89); + for (var i = children.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, children[i], 81)) { + break; + } + } + if (!hasKind(ifStatement.elseStatement, 210)) { + break; + } + ifStatement = ifStatement.elseStatement; + } + var result = []; + for (var i = 0; i < keywords.length; i++) { + if (keywords[i].kind === 81 && 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.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { + shouldCombindElseAndIf = false; + break; + } + } + if (shouldCombindElseAndIf) { + result.push({ + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), + kind: ts.HighlightSpanKind.reference + }); + i++; + continue; + } + } + result.push(getHighlightSpanForNode(keywords[i], sourceFile)); + } + return result; + } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 219; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 221; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -56314,15 +59213,15 @@ var ts; return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + "|" + settings.allowJs + "|" + settings.baseUrl + "|" + JSON.stringify(settings.typeRoots) + "|" + JSON.stringify(settings.rootDirs) + "|" + JSON.stringify(settings.paths); } function getBucketForCompilationSettings(key, createIfMissing) { - var bucket = buckets[key]; + var bucket = buckets.get(key); if (!bucket && createIfMissing) { - buckets[key] = bucket = ts.createFileMap(); + buckets.set(key, bucket = ts.createFileMap()); } return bucket; } function reportStats() { - var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { - var entries = buckets[name]; + var bucketInfoArray = ts.arrayFrom(buckets.keys()).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { + var entries = buckets.get(name); var sourceFiles = []; entries.forEachValue(function (key, entry) { sourceFiles.push({ @@ -56410,881 +59309,937 @@ var ts; (function (ts) { var FindAllReferences; (function (FindAllReferences) { - function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments) { + function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments, isForRename) { var node = ts.getTouchingPropertyName(sourceFile, position, true); - if (node === sourceFile) { - return undefined; - } - switch (node.kind) { - case 8: - if (!ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - break; - } - case 70: - case 98: - case 122: - case 9: - return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, false); - } - return undefined; + return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename); } FindAllReferences.findReferencedSymbols = findReferencedSymbols; - function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, implementations) { + function convertReferences(referenceSymbols) { + return referenceSymbols && ts.flatMap(referenceSymbols, function (r) { return r.references; }); + } + FindAllReferences.convertReferences = convertReferences; + function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename, implementations) { if (!implementations) { - if (ts.isLabelName(node)) { - if (ts.isJumpStatementTarget(node)) { - var labelDefinition = ts.getTargetLabel(node.parent, node.text); - return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; - } - else { - return getLabelReferencesInNode(node.parent, node); - } - } - if (ts.isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles); - } - if (node.kind === 96) { - return getReferencesForSuperKeyword(node); + var special = getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken); + if (special) { + return special; } } var symbol = typeChecker.getSymbolAtLocation(node); - if (!implementations && !symbol && node.kind === 9) { - return getReferencesForStringLiteral(node, sourceFiles); - } if (!symbol) { + if (!implementations && node.kind === 9) { + return getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken); + } return undefined; } var declarations = symbol.declarations; if (!declarations || !declarations.length) { return undefined; } - var result; + var _a = followAliases(symbol, node, typeChecker, isForRename), aliasedSymbol = _a.symbol, shorthandModuleSymbol = _a.shorthandModuleSymbol; + symbol = aliasedSymbol; + var searchSymbols = populateSearchSymbolSet(symbol, node, typeChecker, implementations); + if (shorthandModuleSymbol) { + searchSymbols.push(shorthandModuleSymbol); + } var searchMeaning = getIntersectingMeaningFromDeclarations(ts.getMeaningFromLocation(node), declarations); + var result = []; + var symbolToIndex = []; + var inheritsFromCache = ts.createMap(); 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); + getRefs(scope, declaredName); } else { - var internedName = getInternedName(symbol, node); - for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { - var sourceFile = sourceFiles_8[_i]; + var isDefault = ts.isExportDefaultSymbol(symbol); + var internedName = isDefault ? symbol.valueDeclaration.localSymbol.name : getInternedName(symbol, node); + for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { + var sourceFile = sourceFiles_5[_i]; cancellationToken.throwIfCancellationRequested(); - var nameTable = ts.getNameTable(sourceFile); - if (nameTable[internedName] !== undefined) { - result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + var searchName = (isDefault ? getDefaultImportName(symbol, sourceFile, typeChecker) : undefined) || + (sourceFileHasName(sourceFile, internedName) ? declaredName : undefined); + if (searchName !== undefined) { + getRefs(sourceFile, searchName); } } } return result; - function getDefinition(symbol) { - var info = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.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), - displayParts: info.displayParts - }; + function getRefs(scope, searchName) { + getReferencesInNode(scope, symbol, searchName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache); } - function getAliasSymbolForPropertyNameSymbol(symbol, location) { - if (symbol.flags & 8388608) { - var defaultImport = ts.getDeclarationOfKind(symbol, 236); - if (defaultImport) { - return typeChecker.getAliasedSymbol(symbol); - } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 239 || - declaration.kind === 243) ? declaration : undefined; }); - if (importOrExportSpecifier && - (!importOrExportSpecifier.propertyName || - importOrExportSpecifier.propertyName === location)) { - return importOrExportSpecifier.kind === 239 ? - typeChecker.getAliasedSymbol(symbol) : - typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); - } + } + FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; + function getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken) { + if (ts.isTypeKeyword(node.kind)) { + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + } + if (ts.isLabelName(node)) { + if (ts.isJumpStatementTarget(node)) { + var labelDefinition = ts.getTargetLabel(node.parent, node.text); + return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition, cancellationToken); } + else { + return getLabelReferencesInNode(node.parent, node, cancellationToken); + } + } + if (ts.isThis(node)) { + return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken); + } + if (node.kind === 96) { + return getReferencesForSuperKeyword(node, typeChecker, cancellationToken); + } + return undefined; + } + function followAliases(symbol, node, typeChecker, isForRename) { + while (true) { + if (isForRename && isImportDefaultSymbol(symbol)) { + return { symbol: symbol }; + } + var aliasedSymbol = getAliasSymbolForPropertyNameSymbol(symbol, node, typeChecker); + if (!aliasedSymbol || !aliasedSymbol.declarations) { + return { symbol: symbol }; + } + if (ts.isShorthandAmbientModuleSymbol(aliasedSymbol)) { + return { symbol: symbol, shorthandModuleSymbol: aliasedSymbol }; + } + symbol = aliasedSymbol; + } + } + function sourceFileHasName(sourceFile, name) { + return ts.getNameTable(sourceFile).get(name) !== undefined; + } + function getDefaultImportName(symbol, sourceFile, checker) { + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var importSpecifier = _a[_i]; + var importDecl = importSpecifier.parent; + ts.Debug.assert(importDecl.moduleSpecifier === importSpecifier); + var defaultName = importDecl.importClause.name; + var defaultReferencedSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName)); + if (symbol === defaultReferencedSymbol) { + return defaultName.text; + } + } + return undefined; + } + function getDefinition(symbol, node, typeChecker) { + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.getContainerNode(node), node), displayParts = _a.displayParts, symbolKind = _a.symbolKind; + var name = displayParts.map(function (p) { return p.text; }).join(""); + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { return undefined; } - function followAliasIfNecessary(symbol, location) { - return getAliasSymbolForPropertyNameSymbol(symbol, location) || symbol; - } - function getPropertySymbolOfDestructuringAssignment(location) { - return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - typeChecker.getPropertySymbolOfDestructuringAssignment(location); - } - function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 174); - return bindingElement && - bindingElement.parent.kind === 172 && - !bindingElement.propertyName; - } - function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 174); - var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); - return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); - } + return { + containerKind: "", + containerName: "", + name: name, + kind: symbolKind, + fileName: declarations[0].getSourceFile().fileName, + textSpan: ts.createTextSpan(declarations[0].getStart(), 0), + displayParts: displayParts + }; + } + function getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) { + if (!(symbol.flags & 8388608)) { return undefined; } - function getInternedName(symbol, location) { - if (ts.isImportOrExportSpecifierName(location)) { - return location.getText(); - } - var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); - symbol = localExportDefaultSymbol || symbol; - return ts.stripQuotes(symbol.name); + var defaultImport = ts.getDeclarationOfKind(symbol, 238); + if (defaultImport) { + return typeChecker.getAliasedSymbol(symbol); } - function getSymbolScope(symbol) { - var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 184 || valueDeclaration.kind === 197)) { - return valueDeclaration; - } - if (symbol.flags & (4 | 8192)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8) ? d : undefined; }); - if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 226); - } - } - if (symbol.flags & 8388608) { - return undefined; - } - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - return undefined; - } - if (symbol.parent || (symbol.flags & 268435456)) { - return undefined; - } - var scope; - var declarations = symbol.getDeclarations(); - if (declarations) { - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; - var container = ts.getContainerNode(declaration); - if (!container) { - return undefined; - } - if (scope && scope !== container) { - return undefined; - } - if (container.kind === 261 && !ts.isExternalModule(container)) { - return undefined; - } - scope = container; - } - } - return scope; + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 241 || + declaration.kind === 245) ? declaration : undefined; }); + if (importOrExportSpecifier && + (!importOrExportSpecifier.propertyName || + importOrExportSpecifier.propertyName === location)) { + return importOrExportSpecifier.kind === 241 ? + typeChecker.getAliasedSymbol(symbol) : + typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } - function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { - var positions = []; - if (!symbolName || !symbolName.length) { - return positions; + } + function followAliasIfNecessary(symbol, location, typeChecker) { + return getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) || symbol; + } + function getPropertySymbolOfDestructuringAssignment(location, typeChecker) { + return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && + typeChecker.getPropertySymbolOfDestructuringAssignment(location); + } + function isObjectBindingPatternElementWithoutPropertyName(symbol) { + var bindingElement = ts.getDeclarationOfKind(symbol, 175); + return bindingElement && + bindingElement.parent.kind === 173 && + !bindingElement.propertyName; + } + function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker) { + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + var bindingElement = ts.getDeclarationOfKind(symbol, 175); + var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); + return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + } + return undefined; + } + function getInternedName(symbol, location) { + if (ts.isImportOrExportSpecifierName(location)) { + return location.text; + } + return ts.stripQuotes(symbol.name); + } + function getSymbolScope(symbol) { + var valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && (valueDeclaration.kind === 185 || valueDeclaration.kind === 198)) { + return valueDeclaration; + } + if (symbol.flags & (4 | 8192)) { + var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8) ? d : undefined; }); + if (privateDeclaration) { + return ts.getAncestor(privateDeclaration, 228); } - 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), 5)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5))) { - positions.push(position); + } + if (symbol.flags & 8388608) { + return undefined; + } + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + return undefined; + } + if (symbol.parent || (symbol.flags & 134217728 && symbol.checkFlags & 2)) { + return undefined; + } + var scope; + var declarations = symbol.getDeclarations(); + if (declarations) { + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; + var container = ts.getContainerNode(declaration); + if (!container) { + return undefined; } - position = text.indexOf(symbolName, position + symbolNameLength + 1); + if (scope && scope !== container) { + return undefined; + } + if (container.kind === 264 && !ts.isExternalModule(container)) { + return undefined; + } + scope = container; } + } + return scope; + } + function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end, cancellationToken) { + var positions = []; + if (!symbolName || !symbolName.length) { 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 || - (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ts.ScriptElementKind.label, - name: labelName, - textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()), - displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] - }; - return [{ definition: definition, references: references }]; + 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), 5)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5))) { + positions.push(position); + } + position = text.indexOf(symbolName, position + symbolNameLength + 1); } - function isValidReferencePosition(node, searchSymbolName) { - if (node) { - switch (node.kind) { - case 70: - return node.getWidth() === searchSymbolName.length; - case 9: - if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isNameOfExternalModuleImportOrDeclaration(node)) { - return node.getWidth() === searchSymbolName.length + 2; + return positions; + } + function getLabelReferencesInNode(container, targetLabel, cancellationToken) { + var references = []; + var sourceFile = container.getSourceFile(); + var labelName = targetLabel.text; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd(), cancellationToken); + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { + return; + } + if (node === targetLabel || + (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { + references.push(getReferenceEntryFromNode(node)); + } + }); + var definition = { + containerKind: "", + containerName: "", + fileName: targetLabel.getSourceFile().fileName, + kind: ts.ScriptElementKind.label, + name: labelName, + textSpan: ts.createTextSpanFromNode(targetLabel, sourceFile), + displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] + }; + return [{ definition: definition, references: references }]; + } + function isValidReferencePosition(node, searchSymbolName) { + switch (node && node.kind) { + case 70: + return node.getWidth() === searchSymbolName.length; + case 9: + return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && + node.getWidth() === searchSymbolName.length + 2; + case 8: + return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; + default: + return false; + } + } + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + var name = ts.tokenToString(keywordKind); + var references = []; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var sourceFile = sourceFiles_6[_i]; + cancellationToken.throwIfCancellationRequested(); + addReferencesForKeywordInFile(sourceFile, keywordKind, name, cancellationToken, references); + } + if (!references.length) + return undefined; + var definition = { + containerKind: "", + containerName: "", + fileName: references[0].fileName, + kind: ts.ScriptElementKind.keyword, + name: name, + textSpan: references[0].textSpan, + displayParts: [{ text: name, kind: ts.ScriptElementKind.keyword }] + }; + return [{ definition: definition, references: references }]; + } + function addReferencesForKeywordInFile(sourceFile, kind, searchText, cancellationToken, references) { + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { + var position = possiblePositions_1[_i]; + cancellationToken.throwIfCancellationRequested(); + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (referenceLocation.kind === kind) { + references.push({ + textSpan: ts.createTextSpanFromNode(referenceLocation), + fileName: sourceFile.fileName, + isWriteAccess: false, + isDefinition: false, + }); + } + } + } + function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache) { + var sourceFile = container.getSourceFile(); + var start = findInComments ? container.getFullStart() : container.getStart(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd(), cancellationToken); + var parents = getParentSymbolsOfPropertyAccess(); + for (var _i = 0, possiblePositions_2 = possiblePositions; _i < possiblePositions_2.length; _i++) { + var position = possiblePositions_2[_i]; + cancellationToken.throwIfCancellationRequested(); + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (!isValidReferencePosition(referenceLocation, searchText)) { + if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || + (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { + result.push({ + definition: undefined, + references: [{ + fileName: sourceFile.fileName, + textSpan: ts.createTextSpan(position, searchText.length), + isWriteAccess: false, + isDefinition: false + }] + }); + } + continue; + } + if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { + continue; + } + var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); + if (referenceSymbol) { + var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); + var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocation.kind === 122, parents, inheritsFromCache, typeChecker); + if (relatedSymbol) { + addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); + } + else if (!(referenceSymbol.flags & 134217728) && ts.contains(searchSymbols, shorthandValueSymbol)) { + addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); + } + else if (searchLocation.kind === 122) { + findAdditionalConstructorReferences(referenceSymbol, referenceLocation); + } + } + } + return; + function getParentSymbolsOfPropertyAccess() { + if (implementations) { + var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); + if (propertyAccessExpression) { + var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); + if (localParentType) { + if (localParentType.symbol && localParentType.symbol.flags & (32 | 64) && localParentType.symbol !== searchSymbol.parent) { + return [localParentType.symbol]; } - break; - case 8: - if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - return node.getWidth() === searchSymbolName.length; + else if (localParentType.flags & 196608) { + return getSymbolsForClassAndInterfaceComponents(localParentType); } - break; + } + } + } + } + function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { + ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); + var referenceClass = referenceLocation.parent; + if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { + ts.Debug.assert(referenceClass.name === referenceLocation); + addReferences(findOwnConstructorCalls(searchSymbol, sourceFile)); + } + else { + var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); + if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation, typeChecker) === searchSymbol) { + addReferences(superConstructorAccesses(classExtending)); + } + } + } + function addReferences(references) { + if (references.length) { + var referencedSymbol = getReferencedSymbol(searchSymbol); + ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); + } + } + 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, searchLocation, typeChecker), + references: [] + }); + } + return result[index]; + } + function addReferenceToRelatedSymbol(node, relatedSymbol) { + var references = getReferencedSymbol(relatedSymbol).references; + if (implementations) { + getImplementationReferenceEntryForNode(node, references, typeChecker); + } + else { + references.push(getReferenceEntryFromNode(node)); + } + } + } + function getPropertyAccessExpressionFromRightHandSide(node) { + return ts.isRightSideOfPropertyAccess(node) && node.parent; + } + function findOwnConstructorCalls(classSymbol, sourceFile) { + var result = []; + for (var _i = 0, _a = classSymbol.members.get("__constructor").declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var ctrKeyword = ts.findChildOfKind(decl, 122, sourceFile); + ts.Debug.assert(decl.kind === 151 && !!ctrKeyword); + result.push(ctrKeyword); + } + classSymbol.exports.forEach(function (member) { + var decl = member.valueDeclaration; + if (decl && decl.kind === 150) { + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 98, function (thisKeyword) { + if (ts.isNewExpressionTarget(thisKeyword)) { + result.push(thisKeyword); + } + }); + } + } + }); + return result; + } + function superConstructorAccesses(cls) { + var symbol = cls.symbol; + var ctr = symbol.members.get("__constructor"); + if (!ctr) { + return []; + } + var result = []; + for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.Debug.assert(decl.kind === 151); + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 96, function (node) { + if (ts.isCallExpressionTarget(node)) { + result.push(node); + } + }); + } + } + ; + return result; + } + function getImplementationReferenceEntryForNode(refNode, result, typeChecker) { + if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { + result.push(getReferenceEntryFromNode(refNode.parent)); + } + else if (refNode.kind === 70) { + if (refNode.parent.kind === 261) { + getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); + } + var containingClass = getContainingClassIfInHeritageClause(refNode); + if (containingClass) { + result.push(getReferenceEntryFromNode(containingClass)); + return; + } + var containingTypeReference = getContainingTypeReference(refNode); + if (containingTypeReference) { + var parent = containingTypeReference.parent; + if (ts.isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent.initializer)); + } + else if (ts.isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { + if (parent.body.kind === 206) { + ts.forEachReturnStatement(parent.body, function (returnStatement) { + if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { + maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); + } + }); + } + else if (isImplementationExpression(parent.body)) { + maybeAdd(getReferenceEntryFromNode(parent.body)); + } + } + else if (ts.isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { + maybeAdd(getReferenceEntryFromNode(parent.expression)); + } + } + } + function maybeAdd(a) { + if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { + result.push(a); + } + } + } + function getSymbolsForClassAndInterfaceComponents(type, result) { + if (result === void 0) { result = []; } + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var componentType = _a[_i]; + if (componentType.symbol && componentType.symbol.getFlags() & (32 | 64)) { + result.push(componentType.symbol); + } + if (componentType.getFlags() & 196608) { + getSymbolsForClassAndInterfaceComponents(componentType, result); + } + } + return result; + } + function getContainingTypeReference(node) { + var topLevelTypeReference = undefined; + while (node) { + if (ts.isTypeNode(node)) { + topLevelTypeReference = node; + } + node = node.parent; + } + return topLevelTypeReference; + } + function getContainingClassIfInHeritageClause(node) { + if (node && node.parent) { + if (node.kind === 200 + && node.parent.kind === 258 + && ts.isClassLike(node.parent.parent)) { + return node.parent.parent; + } + else if (node.kind === 70 || node.kind === 178) { + return getContainingClassIfInHeritageClause(node.parent); + } + } + return undefined; + } + function isImplementationExpression(node) { + switch (node.kind) { + case 184: + return isImplementationExpression(node.expression); + case 186: + case 185: + case 177: + case 198: + case 176: + return true; + default: + return false; + } + } + function explicitlyInheritsFrom(child, parent, cachedResults, typeChecker) { + var parentIsInterface = parent.getFlags() & 64; + return searchHierarchy(child); + function searchHierarchy(symbol) { + if (symbol === parent) { + return true; + } + var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); + var cached = cachedResults.get(key); + if (cached !== undefined) { + return cached; + } + cachedResults.set(key, false); + var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + if (parentIsInterface) { + var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); + if (interfaceReferences) { + for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { + var typeReference = interfaceReferences_1[_i]; + if (searchTypeReference(typeReference)) { + return true; + } + } + } + } + return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + } + else if (declaration.kind === 229) { + if (parentIsInterface) { + return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); + } + } + return false; + }); + cachedResults.set(key, inherits); + return inherits; + } + function searchTypeReference(typeReference) { + if (typeReference) { + var type = typeChecker.getTypeAtLocation(typeReference); + if (type && type.symbol) { + return searchHierarchy(type.symbol); } } return false; } - function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex) { - var sourceFile = container.getSourceFile(); - var start = findInComments ? container.getFullStart() : container.getStart(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd()); - var parents = getParentSymbolsOfPropertyAccess(); - var inheritsFromCache = ts.createMap(); - if (possiblePositions.length) { - var searchSymbols_1 = populateSearchSymbolSet(searchSymbol, searchLocation); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); - if (!isValidReferencePosition(referenceLocation, searchText)) { - if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || - (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { - result.push({ - definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: ts.createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] - }); - } - return; - } - if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { - return; - } - var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); - if (referenceSymbol) { - var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, searchLocation.kind === 122, parents, inheritsFromCache); - if (relatedSymbol) { - addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); - } - else if (!(referenceSymbol.flags & 67108864) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { - addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); - } - else if (searchLocation.kind === 122) { - findAdditionalConstructorReferences(referenceSymbol, referenceLocation); - } - } - }); - } - return; - function getParentSymbolsOfPropertyAccess() { - if (implementations) { - var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); - if (propertyAccessExpression) { - var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); - if (localParentType) { - if (localParentType.symbol && localParentType.symbol.flags & (32 | 64) && localParentType.symbol !== searchSymbol.parent) { - return [localParentType.symbol]; - } - else if (localParentType.flags & 196608) { - return getSymbolsForClassAndInterfaceComponents(localParentType); - } - } - } - } - } - function getPropertyAccessExpressionFromRightHandSide(node) { - return ts.isRightSideOfPropertyAccess(node) && node.parent; - } - function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { - ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); - var referenceClass = referenceLocation.parent; - if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { - ts.Debug.assert(referenceClass.name === referenceLocation); - addReferences(findOwnConstructorCalls(searchSymbol)); - } - else { - var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); - if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation) === searchSymbol) { - addReferences(superConstructorAccesses(classExtending)); - } - } - } - function addReferences(references) { - if (references.length) { - var referencedSymbol = getReferencedSymbol(searchSymbol); - ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); - } - } - function findOwnConstructorCalls(classSymbol) { - var result = []; - for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 150); - var ctrKeyword = decl.getChildAt(0); - ts.Debug.assert(ctrKeyword.kind === 122); - result.push(ctrKeyword); - } - ts.forEachProperty(classSymbol.exports, function (member) { - var decl = member.valueDeclaration; - if (decl && decl.kind === 149) { - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 98, function (thisKeyword) { - if (ts.isNewExpressionTarget(thisKeyword)) { - result.push(thisKeyword); - } - }); - } - } - }); - return result; - } - function superConstructorAccesses(cls) { - var symbol = cls.symbol; - var ctr = symbol.members["__constructor"]; - if (!ctr) { - return []; - } - var result = []; - for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 150); - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 96, function (node) { - if (ts.isCallExpressionTarget(node)) { - result.push(node); - } - }); - } - } - ; - return result; - } - 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 addReferenceToRelatedSymbol(node, relatedSymbol) { - var references = getReferencedSymbol(relatedSymbol).references; - if (implementations) { - getImplementationReferenceEntryForNode(node, references); - } - else { - references.push(getReferenceEntryFromNode(node)); - } - } - } - function getImplementationReferenceEntryForNode(refNode, result) { - if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { - result.push(getReferenceEntryFromNode(refNode.parent)); - } - else if (refNode.kind === 70) { - if (refNode.parent.kind === 258) { - getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); - } - var containingClass = getContainingClassIfInHeritageClause(refNode); - if (containingClass) { - result.push(getReferenceEntryFromNode(containingClass)); - return; - } - var containingTypeReference = getContainingTypeReference(refNode); - if (containingTypeReference) { - var parent_18 = containingTypeReference.parent; - if (ts.isVariableLike(parent_18) && parent_18.type === containingTypeReference && parent_18.initializer && isImplementationExpression(parent_18.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_18.initializer)); - } - else if (ts.isFunctionLike(parent_18) && parent_18.type === containingTypeReference && parent_18.body) { - if (parent_18.body.kind === 204) { - ts.forEachReturnStatement(parent_18.body, function (returnStatement) { - if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { - maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); - } - }); - } - else if (isImplementationExpression(parent_18.body)) { - maybeAdd(getReferenceEntryFromNode(parent_18.body)); - } - } - else if (ts.isAssertionExpression(parent_18) && isImplementationExpression(parent_18.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_18.expression)); - } - } - } - function maybeAdd(a) { - if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { - result.push(a); - } - } - } - function getSymbolsForClassAndInterfaceComponents(type, result) { - if (result === void 0) { result = []; } - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var componentType = _a[_i]; - if (componentType.symbol && componentType.symbol.getFlags() & (32 | 64)) { - result.push(componentType.symbol); - } - if (componentType.getFlags() & 196608) { - getSymbolsForClassAndInterfaceComponents(componentType, result); - } - } - return result; - } - function getContainingTypeReference(node) { - var topLevelTypeReference = undefined; - while (node) { - if (ts.isTypeNode(node)) { - topLevelTypeReference = node; - } - node = node.parent; - } - return topLevelTypeReference; - } - function getContainingClassIfInHeritageClause(node) { - if (node && node.parent) { - if (node.kind === 199 - && node.parent.kind === 255 - && ts.isClassLike(node.parent.parent)) { - return node.parent.parent; - } - else if (node.kind === 70 || node.kind === 177) { - return getContainingClassIfInHeritageClause(node.parent); - } - } + } + function getReferencesForSuperKeyword(superKeyword, typeChecker, cancellationToken) { + var searchSpaceNode = ts.getSuperContainer(superKeyword, false); + if (!searchSpaceNode) { return undefined; } - function isImplementationExpression(node) { - if (node.kind === 183) { - return isImplementationExpression(node.expression); - } - return node.kind === 185 || - node.kind === 184 || - node.kind === 176 || - node.kind === 197 || - node.kind === 175; - } - function explicitlyInheritsFrom(child, parent, cachedResults) { - var parentIsInterface = parent.getFlags() & 64; - return searchHierarchy(child); - function searchHierarchy(symbol) { - if (symbol === parent) { - return true; - } - var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); - if (key in cachedResults) { - return cachedResults[key]; - } - cachedResults[key] = false; - var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - if (parentIsInterface) { - var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); - if (interfaceReferences) { - for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { - var typeReference = interfaceReferences_1[_i]; - if (searchTypeReference(typeReference)) { - return true; - } - } - } - } - return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - } - else if (declaration.kind === 227) { - if (parentIsInterface) { - return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); - } - } - return false; - }); - cachedResults[key] = inherits; - return inherits; - } - function searchTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type && type.symbol) { - return searchHierarchy(type.symbol); - } - } - return false; - } - } - function getReferencesForSuperKeyword(superKeyword) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, false); - if (!searchSpaceNode) { + var staticFlag = 32; + switch (searchSpaceNode.kind) { + case 148: + case 147: + case 150: + case 149: + case 151: + case 152: + case 153: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; + break; + default: return undefined; + } + var references = []; + var sourceFile = searchSpaceNode.getSourceFile(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + for (var _i = 0, possiblePositions_3 = possiblePositions; _i < possiblePositions_3.length; _i++) { + var position = possiblePositions_3[_i]; + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 96) { + continue; } - var staticFlag = 32; - switch (searchSpaceNode.kind) { - case 147: - case 146: - case 149: - case 148: - case 150: - case 151: - case 152: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; + var container = ts.getSuperContainer(node, false); + if (container && (32 & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + references.push(getReferenceEntryFromNode(node)); + } + } + var definition = getDefinition(searchSpaceNode.symbol, superKeyword, typeChecker); + return [{ definition: definition, references: references }]; + } + function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, typeChecker, cancellationToken) { + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); + var staticFlag = 32; + switch (searchSpaceNode.kind) { + case 150: + case 149: + if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; - default: + } + case 148: + case 147: + case 151: + case 152: + case 153: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; + break; + case 264: + if (ts.isExternalModule(searchSpaceNode)) { return undefined; - } - var references = []; + } + case 227: + case 185: + break; + default: + return undefined; + } + var references = []; + var possiblePositions; + if (searchSpaceNode.kind === 264) { + ts.forEach(sourceFiles, function (sourceFile) { + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); + } + else { var sourceFile = searchSpaceNode.getSourceFile(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); + } + var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); + var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: thisOrSuperKeyword.getSourceFile().fileName, + kind: ts.ScriptElementKind.variableElement, + name: "this", + textSpan: ts.createTextSpanFromNode(thisOrSuperKeyword), + displayParts: displayParts + }, + 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 !== 96) { + if (!node || !ts.isThis(node)) { return; } - var container = ts.getSuperContainer(node, false); - if (container && (32 & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); + var container = ts.getThisContainer(node, false); + switch (searchSpaceNode.kind) { + case 185: + case 227: + if (searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 150: + case 149: + if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 198: + case 228: + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 264: + if (container.kind === 264 && !ts.isExternalModule(container)) { + result.push(getReferenceEntryFromNode(node)); + } + break; } }); - var definition = getDefinition(searchSpaceNode.symbol); - return [{ definition: definition, references: references }]; } - function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); - var staticFlag = 32; - switch (searchSpaceNode.kind) { - case 149: - case 148: - if (ts.isObjectLiteralMethod(searchSpaceNode)) { - break; + } + function getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken) { + var type = ts.getStringLiteralTypeForNode(node, typeChecker); + if (!type) { + return undefined; + } + var references = []; + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); + } + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ts.ScriptElementKind.variableElement, + name: type.text, + textSpan: ts.createTextSpanFromNode(node), + displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] + }, + references: references + }]; + function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { + for (var _i = 0, possiblePositions_4 = possiblePositions; _i < possiblePositions_4.length; _i++) { + var position = possiblePositions_4[_i]; + cancellationToken.throwIfCancellationRequested(); + var node_2 = ts.getTouchingWord(sourceFile, position); + if (!node_2 || node_2.kind !== 9) { + return; + } + var type_2 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + if (type_2 === searchType) { + references.push(getReferenceEntryFromNode(node_2)); + } + } + } + } + function populateSearchSymbolSet(symbol, location, typeChecker, implementations) { + var result = [symbol]; + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(location); + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 261) { + var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, typeChecker); + if (propertySymbol) { + result.push(propertySymbol); + } + } + if (containingObjectLiteralElement) { + ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { + ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); + }); + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); + if (shorthandValueSymbol) { + result.push(shorthandValueSymbol); + } + } + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 145 && + ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + ts.addRange(result, typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); + } + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker); + if (bindingElementPropertySymbol) { + result.push(bindingElementPropertySymbol); + } + for (var _i = 0, _a = typeChecker.getRootSymbols(symbol); _i < _a.length; _i++) { + var rootSymbol = _a[_i]; + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap(), typeChecker); + } + } + return result; + } + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache, typeChecker) { + if (!symbol) { + return; + } + if (previousIterationSymbolsCache.has(symbol.name)) { + return; + } + if (symbol.flags & (32 | 64)) { + ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === 229) { + 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.apply(result, typeChecker.getRootSymbols(propertySymbol)); } - case 147: - case 146: - case 150: - case 151: - case 152: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; - break; - case 261: - if (ts.isExternalModule(searchSpaceNode)) { + previousIterationSymbolsCache.set(symbol.name, symbol); + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, typeChecker); + } + } + } + } + function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker) { + if (ts.contains(searchSymbols, referenceSymbol)) { + return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) ? referenceSymbol : undefined; + } + var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation, typeChecker); + if (aliasSymbol) { + return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker); + } + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(referenceLocation); + if (containingObjectLiteralElement) { + var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { + return ts.find(typeChecker.getRootSymbols(contextualSymbol), function (symbol) { return ts.contains(searchSymbols, symbol); }); + }); + if (contextualSymbol) { + return contextualSymbol; + } + var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, typeChecker); + if (propertySymbol && ts.contains(searchSymbols, propertySymbol)) { + return propertySymbol; + } + } + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, typeChecker); + if (bindingElementPropertySymbol && ts.contains(searchSymbols, bindingElementPropertySymbol)) { + return bindingElementPropertySymbol; + } + return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { + if (ts.contains(searchSymbols, rootSymbol)) { + return rootSymbol; + } + if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + if (parents) { + if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache, typeChecker); })) { return undefined; } - case 225: - case 184: - break; - default: - return undefined; - } - var references = []; - var possiblePositions; - if (searchSpaceNode.kind === 261) { - 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); - } - var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); - var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: "this", - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: displayParts - }, - references: references - }]; - function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || !ts.isThis(node)) { - return; - } - var container = ts.getThisContainer(node, false); - switch (searchSpaceNode.kind) { - case 184: - case 225: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 149: - case 148: - if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 197: - case 226: - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 261: - if (container.kind === 261 && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); - } - } - function getReferencesForStringLiteral(node, sourceFiles) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (!type) { - return undefined; - } - var references = []; - for (var _i = 0, sourceFiles_9 = sourceFiles; _i < sourceFiles_9.length; _i++) { - var sourceFile = sourceFiles_9[_i]; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd()); - getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); - } - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: type.text, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] - }, - references: references - }]; - function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { - for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { - var position = possiblePositions_1[_i]; - cancellationToken.throwIfCancellationRequested(); - var node_2 = ts.getTouchingWord(sourceFile, position); - if (!node_2 || node_2.kind !== 9) { - return; - } - var type_1 = ts.getStringLiteralTypeForNode(node_2, typeChecker); - if (type_1 === searchType) { - references.push(getReferenceEntryFromNode(node_2)); - } } + var result = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap(), typeChecker); + return ts.find(result, function (symbol) { return ts.contains(searchSymbols, symbol); }); } - } - function populateSearchSymbolSet(symbol, location) { - var result = [symbol]; - var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 258) { - var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); - if (propertySymbol) { - result.push(propertySymbol); - } - } - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(symbol, location); - if (aliasSymbol) { - result = result.concat(populateSearchSymbolSet(aliasSymbol, location)); - } - if (containingObjectLiteralElement) { - ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), function (contextualSymbol) { - ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); - }); - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); - if (shorthandValueSymbol) { - result.push(shorthandValueSymbol); - } - } - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 144 && - ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { - result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); - } - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol); - if (bindingElementPropertySymbol) { - result.push(bindingElementPropertySymbol); - } - ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap()); - } - }); - return result; - } - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache) { - if (!symbol) { - return; - } - if (symbol.name in previousIterationSymbolsCache) { - return; - } - if (symbol.flags & (32 | 64)) { - ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === 227) { - 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.apply(result, typeChecker.getRootSymbols(propertySymbol)); - } - previousIterationSymbolsCache[symbol.name] = symbol; - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache); - } - } - } - } - function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache) { - if (ts.contains(searchSymbols, referenceSymbol)) { - return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) && referenceSymbol; - } - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation); - if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache); - } - var containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation); - if (containingObjectLiteralElement) { - var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), function (contextualSymbol) { - return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - }); - if (contextualSymbol) { - return contextualSymbol; - } - var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation); - if (propertySymbol && searchSymbols.indexOf(propertySymbol) >= 0) { - return propertySymbol; - } - } - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol); - if (bindingElementPropertySymbol && searchSymbols.indexOf(bindingElementPropertySymbol) >= 0) { - return bindingElementPropertySymbol; - } - return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { - if (searchSymbols.indexOf(rootSymbol) >= 0) { - return rootSymbol; - } - if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - if (parents) { - if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache); })) { - return undefined; - } - } - var result_4 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_4, ts.createMap()); - return ts.forEach(result_4, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - } - return undefined; - }); - } - function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 142) { - var nameExpression = node.name.expression; - if (ts.isStringOrNumericLiteral(nameExpression)) { - return nameExpression.text; - } - return undefined; - } - return node.name.text; - } - function getPropertySymbolsFromContextualType(node) { - var objectLiteral = node.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - var name = getNameFromObjectLiteralElement(node); - if (name && contextualType) { - var result_5 = []; - var symbol_2 = contextualType.getProperty(name); - if (symbol_2) { - result_5.push(symbol_2); - } - if (contextualType.flags & 65536) { - ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name); - if (symbol) { - result_5.push(symbol); - } - }); - } - return result_5; + return undefined; + }); + } + function getNameFromObjectLiteralElement(node) { + if (node.name.kind === 143) { + var nameExpression = node.name.expression; + if (ts.isStringOrNumericLiteral(nameExpression)) { + return nameExpression.text; } return undefined; } - function getIntersectingMeaningFromDeclarations(meaning, declarations) { - if (declarations) { - var lastIterationMeaning = void 0; - do { - lastIterationMeaning = meaning; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; - var declarationMeaning = ts.getMeaningFromDeclaration(declaration); - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; - } - } - } while (meaning !== lastIterationMeaning); + return node.name.text; + } + function getPropertySymbolsFromContextualType(node, typeChecker) { + var objectLiteral = node.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name = getNameFromObjectLiteralElement(node); + if (name && contextualType) { + var result_4 = []; + var symbol = contextualType.getProperty(name); + if (symbol) { + result_4.push(symbol); } - return meaning; + if (contextualType.flags & 65536) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_4.push(symbol); + } + }); + } + return result_4; } + return undefined; } - FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; - function convertReferences(referenceSymbols) { - if (!referenceSymbols) { - return undefined; + function getIntersectingMeaningFromDeclarations(meaning, declarations) { + if (declarations) { + var lastIterationMeaning = void 0; + do { + lastIterationMeaning = meaning; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; + var declarationMeaning = ts.getMeaningFromDeclaration(declaration); + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; + } + } + } while (meaning !== lastIterationMeaning); } - var referenceEntries = []; - for (var _i = 0, referenceSymbols_1 = referenceSymbols; _i < referenceSymbols_1.length; _i++) { - var referenceSymbol = referenceSymbols_1[_i]; - ts.addRange(referenceEntries, referenceSymbol.references); - } - return referenceEntries; + return meaning; } - FindAllReferences.convertReferences = convertReferences; function isImplementation(node) { if (!node) { return false; @@ -57293,7 +60248,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 223) { + else if (node.kind === 225) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2); } @@ -57303,18 +60258,18 @@ var ts; } else { switch (node.kind) { - case 226: - case 197: - case 229: - case 230: + case 228: + case 198: + case 231: + case 232: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 205) { - ts.Debug.assert(node.parent.kind === 224); + if (node.parent && node.parent.parent && node.parent.parent.kind === 207) { + ts.Debug.assert(node.parent.kind === 226); return node.parent.parent; } } @@ -57352,10 +60307,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 191 || parent.kind === 190) { + if (parent.kind === 192 || parent.kind === 191) { return true; } - else if (parent.kind === 192 && parent.left === node) { + else if (parent.kind === 193 && parent.left === node) { var operator = parent.operatorToken.kind; return 57 <= operator && operator <= 69; } @@ -57370,29 +60325,6 @@ var ts; forEachDescendantOfKind(child, kind, action); }); } - function getContainingObjectLiteralElement(node) { - switch (node.kind) { - case 9: - case 8: - if (node.parent.kind === 142) { - return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; - } - case 70: - return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; - } - return undefined; - } - function isObjectLiteralPropertyDeclaration(node) { - switch (node.kind) { - case 257: - case 258: - case 149: - case 151: - case 152: - return true; - } - return false; - } function tryGetClassByExtendingIdentifier(node) { return ts.tryGetClassExtendingExpressionWithTypeArguments(ts.climbPastPropertyAccess(node).parent); } @@ -57402,6 +60334,9 @@ var ts; } return false; } + function isImportDefaultSymbol(symbol) { + return symbol.declarations[0].kind === 238; + } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); var ts; @@ -57419,11 +60354,9 @@ var ts; } var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { - var referenceFile = program.getResolvedTypeReferenceDirectives()[typeReferenceDirective.fileName]; - if (referenceFile && referenceFile.resolvedFileName) { - return [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; - } - return undefined; + var referenceFile = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); + return referenceFile && referenceFile.resolvedFileName && + [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; } var node = ts.getTouchingPropertyName(sourceFile, position); if (node === sourceFile) { @@ -57432,7 +60365,7 @@ var ts; if (ts.isJumpStatementTarget(node)) { var labelName = node.text; var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ts.ScriptElementKind.label, labelName, undefined)] : undefined; + return label ? [createDefinitionInfoFromName(label, ts.ScriptElementKind.label, labelName, undefined)] : undefined; } var typeChecker = program.getTypeChecker(); var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); @@ -57447,11 +60380,11 @@ var ts; var declaration = symbol.declarations[0]; if (node.kind === 70 && (node.parent === declaration || - (declaration.kind === 239 && declaration.parent && declaration.parent.kind === 238))) { + (declaration.kind === 241 && declaration.parent && declaration.parent.kind === 240))) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 258) { + if (node.parent.kind === 261) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -57462,6 +60395,22 @@ var ts; var shorthandContainerName_1 = typeChecker.symbolToString(symbol.parent, node); return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind_1, shorthandSymbolName_1, shorthandContainerName_1); }); } + if (ts.isJsxOpeningLikeElement(node.parent)) { + var _a = getSymbolInfo(typeChecker, symbol, node), symbolName = _a.symbolName, symbolKind = _a.symbolKind, containerName = _a.containerName; + return [createDefinitionInfo(symbol.valueDeclaration, symbolKind, symbolName, containerName)]; + } + var element = ts.getContainingObjectLiteralElement(node); + if (element) { + if (typeChecker.getContextualType(element.parent)) { + var result = []; + var propertySymbols = ts.getPropertySymbolsFromContextualType(typeChecker, element); + for (var _i = 0, propertySymbols_1 = propertySymbols; _i < propertySymbols_1.length; _i++) { + var propertySymbol = propertySymbols_1[_i]; + result.push.apply(result, getDefinitionFromSymbol(typeChecker, propertySymbol, node)); + } + return result; + } + } return getDefinitionFromSymbol(typeChecker, symbol, node); } GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; @@ -57479,13 +60428,13 @@ var ts; return undefined; } if (type.flags & 65536 && !(type.flags & 16)) { - var result_6 = []; + var result_5 = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(result_6, getDefinitionFromSymbol(typeChecker, t.symbol, node)); + ts.addRange(result_5, getDefinitionFromSymbol(typeChecker, t.symbol, node)); } }); - return result_6; + return result_5; } if (!type.symbol) { return undefined; @@ -57527,29 +60476,40 @@ var ts; function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { var declarations = []; var definition; - ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 150) || - (!selectConstructors && (d.kind === 225 || d.kind === 149 || d.kind === 148))) { + for (var _i = 0, signatureDeclarations_1 = signatureDeclarations; _i < signatureDeclarations_1.length; _i++) { + var d = signatureDeclarations_1[_i]; + if (selectConstructors ? d.kind === 151 : isSignatureDeclaration(d)) { 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)); + if (declarations.length) { + result.push(createDefinitionInfo(definition || ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); return true; } return false; } } + function isSignatureDeclaration(node) { + switch (node.kind) { + case 151: + case 227: + case 150: + case 149: + return true; + default: + return false; + } + } function createDefinitionInfo(node, symbolKind, symbolName, containerName) { + return createDefinitionInfoFromName(node.name || node, symbolKind, symbolName, containerName); + } + function createDefinitionInfoFromName(name, symbolKind, symbolName, containerName) { + var sourceFile = name.getSourceFile(); return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromNode(name, sourceFile), kind: symbolKind, name: symbolName, containerKind: undefined, @@ -57596,7 +60556,14 @@ var ts; } function tryGetSignatureDeclaration(typeChecker, node) { var callLike = getAncestorCallLikeExpression(node); - return callLike && typeChecker.getResolvedSignature(callLike).declaration; + var signature = callLike && typeChecker.getResolvedSignature(callLike); + if (signature) { + var decl = signature.declaration; + if (decl && isSignatureDeclaration(decl)) { + return decl; + } + } + return undefined; } })(GoToDefinition = ts.GoToDefinition || (ts.GoToDefinition = {})); })(ts || (ts = {})); @@ -57605,7 +60572,7 @@ var ts; var GoToImplementation; (function (GoToImplementation) { function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { - if (node.parent.kind === 258) { + if (node.parent.kind === 261) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -57615,7 +60582,7 @@ var ts; return symbol.valueDeclaration && [ts.FindAllReferences.getReferenceEntryFromNode(symbol.valueDeclaration)]; } else { - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, false, false, true); + var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, false, false, false, true); var result = ts.flatMap(referencedSymbols, function (symbol) { return ts.map(symbol.references, function (_a) { var textSpan = _a.textSpan, fileName = _a.fileName; @@ -57697,7 +60664,7 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function forEachUnique(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (ts.indexOf(array, array[i]) === i) { var result = callback(array[i], i); if (result) { @@ -57731,16 +60698,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 225: - case 149: + case 227: case 150: - case 226: - case 205: + case 151: + case 228: + case 207: break findOwner; - case 261: + case 264: return undefined; - case 230: - if (commentOwner.parent.kind === 230) { + case 232: + if (commentOwner.parent.kind === 232) { return undefined; } break findOwner; @@ -57755,7 +60722,7 @@ var ts; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; - for (var i = 0, numParams = parameters.length; i < numParams; i++) { + for (var i = 0; i < parameters.length; i++) { var currentName = parameters[i].name; var paramName = currentName.kind === 70 ? currentName.text : @@ -57780,7 +60747,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 205) { + if (commentOwner.kind === 207) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -57790,17 +60757,17 @@ var ts; return ts.emptyArray; } function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 183) { + while (rightHandSide.kind === 184) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 184: case 185: + case 186: return rightHandSide.parameters; - case 197: + case 198: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150) { + if (member.kind === 151) { return member.parameters; } } @@ -57811,47 +60778,210 @@ var ts; })(JsDoc = ts.JsDoc || (ts.JsDoc = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var JsTyping; + (function (JsTyping) { + ; + ; + var safeList; + var EmptySafeList = ts.createMap(); + JsTyping.nodeCoreModuleList = [ + "buffer", "querystring", "events", "http", "cluster", + "zlib", "os", "https", "punycode", "repl", "readline", + "vm", "child_process", "url", "dns", "net", + "dgram", "fs", "path", "string_decoder", "tls", + "crypto", "stream", "util", "assert", "tty", "domain", + "constants", "process", "v8", "timers", "console" + ]; + var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typeAcquisition, unresolvedImports) { + var inferredTypings = ts.createMap(); + if (!typeAcquisition || !typeAcquisition.enable) { + return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; + } + fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { + var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); + return kind === 1 || kind === 2; + }); + if (!safeList) { + var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); + safeList = result.config ? ts.createMapFromTemplate(result.config) : EmptySafeList; + } + var filesToWatch = []; + var searchDirs = []; + var exclude = []; + mergeTypings(typeAcquisition.include); + exclude = typeAcquisition.exclude || []; + var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); + if (projectRootPath) { + possibleSearchDirs.push(projectRootPath); + } + searchDirs = ts.deduplicate(possibleSearchDirs); + for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { + var searchDir = searchDirs_1[_i]; + var packageJsonPath = ts.combinePaths(searchDir, "package.json"); + getTypingNamesFromJson(packageJsonPath, filesToWatch); + var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); + getTypingNamesFromJson(bowerJsonPath, filesToWatch); + var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); + getTypingNamesFromNodeModuleFolder(nodeModulesPath); + } + getTypingNamesFromSourceFileNames(fileNames); + if (unresolvedImports) { + for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { + var moduleId = unresolvedImports_1[_a]; + var typingName = nodeCoreModules.has(moduleId) ? "node" : moduleId; + if (!inferredTypings.has(typingName)) { + inferredTypings.set(typingName, undefined); + } + } + } + packageNameToTypingLocation.forEach(function (typingLocation, name) { + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined) { + inferredTypings.set(name, typingLocation); + } + }); + for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { + var excludeTypingName = exclude_1[_b]; + inferredTypings.delete(excludeTypingName); + } + var newTypingNames = []; + var cachedTypingPaths = []; + inferredTypings.forEach(function (inferred, typing) { + if (inferred !== undefined) { + cachedTypingPaths.push(inferred); + } + else { + newTypingNames.push(typing); + } + }); + return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; + function mergeTypings(typingNames) { + if (!typingNames) { + return; + } + for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { + var typing = typingNames_1[_i]; + if (!inferredTypings.has(typing)) { + inferredTypings.set(typing, undefined); + } + } + } + function getTypingNamesFromJson(jsonPath, filesToWatch) { + if (host.fileExists(jsonPath)) { + filesToWatch.push(jsonPath); + } + var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); + if (result.config) { + var jsonConfig = result.config; + if (jsonConfig.dependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); + } + if (jsonConfig.devDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); + } + if (jsonConfig.optionalDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); + } + if (jsonConfig.peerDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); + } + } + } + function getTypingNamesFromSourceFileNames(fileNames) { + var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); + var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); + var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); + if (safeList !== EmptySafeList) { + mergeTypings(ts.filter(cleanedTypingNames, function (f) { return safeList.has(f); })); + } + var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); + if (hasJsxFile) { + mergeTypings(["react"]); + } + } + function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { + if (!host.directoryExists(nodeModulesPath)) { + return; + } + var typingNames = []; + var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); + for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { + var fileName = fileNames_2[_i]; + var normalizedFileName = ts.normalizePath(fileName); + if (ts.getBaseFileName(normalizedFileName) !== "package.json") { + continue; + } + var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); + if (!result.config) { + continue; + } + var packageJson = result.config; + if (packageJson._requiredBy && + ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { + continue; + } + if (!packageJson.name) { + continue; + } + if (packageJson.typings) { + var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); + inferredTypings.set(packageJson.name, absolutePath); + } + else { + typingNames.push(packageJson.name); + } + } + mergeTypings(typingNames); + } + } + JsTyping.discoverTypings = discoverTypings; + })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var NavigateTo; (function (NavigateTo) { function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; - ts.forEach(sourceFiles, function (sourceFile) { + var _loop_4 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) { - return; + return "continue"; } - var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_47 in nameToDeclarations) { - var declarations = nameToDeclarations[name_47]; + ts.forEachEntry(sourceFile.getNamedDeclarations(), function (declarations, name) { if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_47); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); if (!matches) { - continue; + return; } - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { + var declaration = declarations_12[_i]; if (patternMatcher.patternContainsDots) { var containers = getContainers(declaration); if (!containers) { - return undefined; + return true; } - matches = patternMatcher.getMatches(containers, name_47); + matches = patternMatcher.getMatches(containers, name); if (!matches) { - continue; + return; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_47, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } - } - }); + }); + }; + for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { + var sourceFile = sourceFiles_8[_i]; + _loop_4(sourceFile); + } rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 236 || decl.kind === 239 || decl.kind === 234) { + if (decl.kind === 238 || decl.kind === 241 || decl.kind === 236) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -57892,7 +61022,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 142) { + else if (declaration.name.kind === 143) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -57909,7 +61039,7 @@ var ts; } return true; } - if (expression.kind === 177) { + if (expression.kind === 178) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -57920,7 +61050,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 142) { + if (declaration.name.kind === 143) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -57961,7 +61091,7 @@ var ts; matchKind: ts.PatternMatchKind[rawItem.matchKind], isCaseSensitive: rawItem.isCaseSensitive, fileName: rawItem.fileName, - textSpan: ts.createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), + textSpan: ts.createTextSpanFromNode(declaration), containerName: container && container.name ? container.name.text : "", containerKind: container && container.name ? ts.getNodeKind(container) : "" }; @@ -58052,7 +61182,7 @@ var ts; return; } switch (node.kind) { - case 150: + case 151: var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { @@ -58062,28 +61192,28 @@ var ts; } } break; - case 149: - case 151: + case 150: case 152: - case 148: + case 153: + case 149: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; + case 148: case 147: - case 146: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 236: + case 238: var importClause = node; if (importClause.name) { addLeafNode(importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 237) { + if (namedBindings.kind === 239) { addLeafNode(namedBindings); } else { @@ -58094,12 +61224,12 @@ var ts; } } break; - case 174: - case 223: + case 175: + case 225: var decl = node; - var name_48 = decl.name; - if (ts.isBindingPattern(name_48)) { - addChildrenRecursively(name_48); + var name = decl.name; + if (ts.isBindingPattern(name)) { + addChildrenRecursively(name); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { addChildrenRecursively(decl.initializer); @@ -58108,12 +61238,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; + case 186: + case 227: case 185: - case 225: - case 184: addNodeWithRecursiveChild(node, node.body); break; - case 229: + case 231: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -58123,9 +61253,9 @@ var ts; } endNode(); break; - case 226: - case 197: - case 227: + case 228: + case 198: + case 229: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -58133,21 +61263,21 @@ var ts; } endNode(); break; - case 230: + case 232: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 243: - case 234: - case 155: - case 153: + case 245: + case 236: + case 156: case 154: - case 228: + case 155: + case 230: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 285) { + if (tag.kind === 289) { addLeafNode(tag); } }); @@ -58163,9 +61293,9 @@ var ts; if (!name) { return true; } - var itemsWithSameName = nameToItems[name]; + var itemsWithSameName = nameToItems.get(name); if (!itemsWithSameName) { - nameToItems[name] = child; + nameToItems.set(name, child); return true; } if (itemsWithSameName instanceof Array) { @@ -58183,7 +61313,7 @@ var ts; if (tryMerge(itemWithSameName, child)) { return false; } - nameToItems[name] = [itemWithSameName, child]; + nameToItems.set(name, [itemWithSameName, child]); return true; } function tryMerge(a, b) { @@ -58195,12 +61325,12 @@ var ts; } }); function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 230 || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 232 || areSameModule(a, b)); function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 230) { + if (a.body.kind !== 232) { return true; } return areSameModule(a.body, b.body); @@ -58226,32 +61356,15 @@ var ts; function compareChildren(child1, child2) { var name1 = tryGetName(child1.node), name2 = tryGetName(child2.node); if (name1 && name2) { - var cmp = localeCompareFix(name1, name2); + var cmp = ts.compareStringsCaseInsensitive(name1, name2); return cmp !== 0 ? cmp : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } else { return name1 ? 1 : name2 ? -1 : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } } - var localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; - var localeCompareFix = localeCompareIsCorrect ? ts.collator.compare : function (a, b) { - for (var i = 0; i < Math.min(a.length, b.length); i++) { - var chA = a.charAt(i), chB = b.charAt(i); - if (chA === "\"" && chB === "'") { - return 1; - } - if (chA === "'" && chB === "\"") { - return -1; - } - var cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); - if (cmp !== 0) { - return cmp; - } - } - return a.length - b.length; - }; function tryGetName(node) { - if (node.kind === 230) { + if (node.kind === 232) { return getModuleName(node); } var decl = node; @@ -58259,18 +61372,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 184: case 185: - case 197: + case 186: + case 198: return getFunctionOrClassName(node); - case 285: + case 289: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 230) { + if (node.kind === 232) { return getModuleName(node); } var name = node.name; @@ -58281,29 +61394,29 @@ var ts; } } switch (node.kind) { - case 261: + case 264: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; + case 186: + case 227: case 185: - case 225: - case 184: - case 226: - case 197: + case 228: + case 198: if (ts.getModifierFlags(node) & 512) { return "default"; } return getFunctionOrClassName(node); - case 150: + case 151: return "constructor"; - case 154: - return "new()"; - case 153: - return "()"; case 155: + return "new()"; + case 154: + return "()"; + case 156: return "[]"; - case 285: + case 289: return getJSDocTypedefTagName(node); default: return ""; @@ -58315,7 +61428,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 205) { + if (parentNode && parentNode.kind === 207) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -58343,24 +61456,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 226: - case 197: - case 229: - case 227: - case 230: - case 261: case 228: - case 285: + case 198: + case 231: + case 229: + case 232: + case 264: + case 230: + case 289: return true; - case 150: - case 149: case 151: + case 150: case 152: - case 223: - return hasSomeImportantChild(item); - case 185: + case 153: case 225: - case 184: + return hasSomeImportantChild(item); + case 186: + case 227: + case 185: return isTopLevelFunctionDeclaration(item); default: return false; @@ -58370,10 +61483,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 231: - case 261: - case 149: + case 233: + case 264: case 150: + case 151: return true; default: return hasSomeImportantChild(item); @@ -58382,7 +61495,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 223 && childKind !== 174; + return childKind !== 225 && childKind !== 175; }); } } @@ -58392,7 +61505,7 @@ var ts; return { text: getItemName(n.node), kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: ts.map(n.children, convertToTree) }; @@ -58401,7 +61514,7 @@ var ts; return { text: getItemName(n.node), kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, indent: n.indent, @@ -58437,35 +61550,41 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 230) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 232) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } return result.join("."); } function getInteriorModule(decl) { - return decl.body.kind === 230 ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 232 ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 142; + return !member.name || member.name.kind === 143; } function getNodeSpan(node) { - return node.kind === 261 + return node.kind === 264 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) - : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); + : ts.createTextSpanFromNode(node, curSourceFile); + } + function getModifiers(node) { + if (node.parent && node.parent.kind === 225) { + node = node.parent; + } + return ts.getNodeModifiers(node); } function getFunctionOrClassName(node) { if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 223) { + else if (node.parent.kind === 225) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 192 && + else if (node.parent.kind === 193 && node.parent.operatorToken.kind === 57) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 257 && node.parent.name) { + else if (node.parent.kind === 260 && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512) { @@ -58476,7 +61595,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 184 || node.kind === 185 || node.kind === 197; + return node.kind === 185 || node.kind === 186 || node.kind === 198; } var whiteSpaceRegex = /\s+/g; })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); @@ -58492,7 +61611,7 @@ var ts; if (hintSpanNode && startElement && endElement) { var span_12 = { textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), - hintSpan: ts.createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), + hintSpan: ts.createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse }; @@ -58549,7 +61668,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 185; + return ts.isFunctionBlock(node) && node.parent.kind !== 186; } var depth = 0; var maxDepth = 20; @@ -58561,26 +61680,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 204: + case 206: if (!ts.isFunctionBlock(n)) { - var parent_19 = n.parent; + var parent = n.parent; var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); - if (parent_19.kind === 209 || - parent_19.kind === 212 || - parent_19.kind === 213 || - parent_19.kind === 211 || - parent_19.kind === 208 || - parent_19.kind === 210 || - parent_19.kind === 217 || - parent_19.kind === 256) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + if (parent.kind === 211 || + parent.kind === 214 || + parent.kind === 215 || + parent.kind === 213 || + parent.kind === 210 || + parent.kind === 212 || + parent.kind === 219 || + parent.kind === 259) { + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_19.kind === 221) { - var tryStatement = parent_19; + if (parent.kind === 223) { + var tryStatement = parent; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -58591,7 +61710,7 @@ var ts; } } } - var span_14 = ts.createTextSpanFromBounds(n.getStart(), n.end); + var span_14 = ts.createTextSpanFromNode(n); elements.push({ textSpan: span_14, hintSpan: span_14, @@ -58600,23 +61719,23 @@ var ts; }); break; } - case 231: { + case 233: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 226: - case 227: + case 228: case 229: - case 176: - case 232: { + case 231: + case 177: + case 234: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 175: + case 176: var openBracket = ts.findChildOfKind(n, 20, sourceFile); var closeBracket = ts.findChildOfKind(n, 21, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -58693,10 +61812,11 @@ var ts; return totalMatch; } function getWordSpans(word) { - if (!(word in stringToWordSpans)) { - stringToWordSpans[word] = breakIntoWordSpans(word); + var spans = stringToWordSpans.get(word); + if (!spans) { + stringToWordSpans.set(word, spans = breakIntoWordSpans(word)); } - return stringToWordSpans[word]; + return spans; } function matchTextChunk(candidate, chunk, punctuationStripped) { var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); @@ -58878,7 +61998,8 @@ var ts; return str === str.toLowerCase(); } function indexOfIgnoringCase(string, value) { - for (var i = 0, n = string.length - value.length; i <= n; i++) { + var n = string.length - value.length; + for (var i = 0; i <= n; i++) { if (startsWithIgnoringCase(string, value, i)) { return i; } @@ -58886,7 +62007,7 @@ var ts; return -1; } function startsWithIgnoringCase(string, value, start) { - for (var i = 0, n = value.length; i < n; i++) { + for (var i = 0; i < value.length; i++) { var ch1 = toLowerCase(string.charCodeAt(i + start)); var ch2 = value.charCodeAt(i); if (ch1 !== ch2) { @@ -58954,7 +62075,7 @@ var ts; function breakIntoSpans(identifier, word) { var result = []; var wordStart = 0; - for (var i = 1, n = identifier.length; i < n; i++) { + for (var i = 1; i < identifier.length; i++) { var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); var currentIsDigit = isDigit(identifier.charCodeAt(i)); var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); @@ -59128,7 +62249,7 @@ var ts; else { if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59154,7 +62275,7 @@ var ts; } if (token === 17) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59168,7 +62289,7 @@ var ts; token = nextToken(); if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59194,7 +62315,7 @@ var ts; } if (token === 17) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59204,7 +62325,7 @@ var ts; } else if (token === 38) { token = nextToken(); - if (token === 138) { + if (token === 139) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -59331,90 +62452,82 @@ var ts; var Rename; (function (Rename) { function getRenameInfo(typeChecker, defaultLibFileName, getCanonicalFileName, sourceFile, position) { - var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); + var getCanonicalDefaultLibName = ts.memoize(function () { return getCanonicalFileName(ts.normalizePath(defaultLibFileName)); }); var node = ts.getTouchingWord(sourceFile, position, true); - if (node) { - if (node.kind === 70 || - node.kind === 9 || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - ts.isThis(node)) { - var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol) { - var declarations = symbol.getDeclarations(); - if (declarations && declarations.length > 0) { - if (ts.forEach(declarations, isDefinedInLibraryFile)) { - 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 = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - if (kind) { - return { - canRename: true, - kind: kind, - displayName: displayName, - localizedErrorMessage: undefined, - fullDisplayName: typeChecker.getFullyQualifiedName(symbol), - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - else if (node.kind === 9) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (type) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } - else { - var displayName = ts.stripQuotes(type.text); - return { - canRename: true, - kind: ts.ScriptElementKind.variableElement, - displayName: displayName, - localizedErrorMessage: undefined, - fullDisplayName: displayName, - kindModifiers: ts.ScriptElementKindModifier.none, - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - } - } - 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 - }; - } + var renameInfo = node && nodeIsEligibleForRename(node) + ? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) + : undefined; + return renameInfo || getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); function isDefinedInLibraryFile(declaration) { - if (defaultLibFileName) { - var sourceFile_1 = declaration.getSourceFile(); - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_1.fileName)); - if (canonicalName === canonicalDefaultLibName) { - return true; - } + if (!defaultLibFileName) { + return false; } - return false; - } - function createTriggerSpanForNode(node, sourceFile) { - var start = node.getStart(sourceFile); - var width = node.getWidth(sourceFile); - if (node.kind === 9) { - start += 1; - width -= 2; - } - return ts.createTextSpan(start, width); + var sourceFile = declaration.getSourceFile(); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); + return canonicalName === getCanonicalDefaultLibName(); } } Rename.getRenameInfo = getRenameInfo; + function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol) { + var declarations = symbol.getDeclarations(); + if (declarations && declarations.length > 0) { + if (ts.some(declarations, isDefinedInLibraryFile)) { + return getRenameInfoError(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 = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); + return kind ? getRenameInfoSuccess(displayName, typeChecker.getFullyQualifiedName(symbol), kind, ts.SymbolDisplay.getSymbolModifiers(symbol), node, sourceFile) : undefined; + } + } + else if (node.kind === 9) { + var type = ts.getStringLiteralTypeForNode(node, typeChecker); + if (type) { + if (isDefinedInLibraryFile(node)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); + } + var displayName = ts.stripQuotes(type.text); + return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); + } + } + } + function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { + return { + canRename: true, + kind: kind, + displayName: displayName, + localizedErrorMessage: undefined, + fullDisplayName: fullDisplayName, + kindModifiers: kindModifiers, + triggerSpan: createTriggerSpanForNode(node, sourceFile) + }; + } + function getRenameInfoError(diagnostic) { + return { + canRename: false, + localizedErrorMessage: ts.getLocaleSpecificMessage(diagnostic), + displayName: undefined, + fullDisplayName: undefined, + kind: undefined, + kindModifiers: undefined, + triggerSpan: undefined + }; + } + function createTriggerSpanForNode(node, sourceFile) { + var start = node.getStart(sourceFile); + var width = node.getWidth(sourceFile); + if (node.kind === 9) { + start += 1; + width -= 2; + } + return ts.createTextSpan(start, width); + } + function nodeIsEligibleForRename(node) { + return node.kind === 70 || node.kind === 9 || + ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + ts.isThis(node); + } })(Rename = ts.Rename || (ts.Rename = {})); })(ts || (ts = {})); var ts; @@ -59422,6 +62535,13 @@ var ts; var SignatureHelp; (function (SignatureHelp) { var emptyArray = []; + var ArgumentListKind; + (function (ArgumentListKind) { + ArgumentListKind[ArgumentListKind["TypeArguments"] = 0] = "TypeArguments"; + ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; + ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; + ArgumentListKind[ArgumentListKind["JSXAttributesArguments"] = 3] = "JSXAttributesArguments"; + })(ArgumentListKind = SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); @@ -59447,14 +62567,14 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 179) { + if (argumentInfo.invocation.kind !== 180) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; var name = expression.kind === 70 ? expression - : expression.kind === 177 + : expression.kind === 178 ? expression.name : undefined; if (!name || !name.text) { @@ -59464,10 +62584,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameToDeclarations = sourceFile.getNamedDeclarations(); - var declarations = nameToDeclarations[name.text]; + var declarations = nameToDeclarations.get(name.text); if (declarations) { - for (var _b = 0, declarations_10 = declarations; _b < declarations_10.length; _b++) { - var declaration = declarations_10[_b]; + for (var _b = 0, declarations_13 = declarations; _b < declarations_13.length; _b++) { + var declaration = declarations_13[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -59483,7 +62603,7 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 179 || node.parent.kind === 180) { + if (node.parent.kind === 180 || node.parent.kind === 181) { var callExpression = node.parent; if (node.kind === 26 || node.kind === 18) { @@ -59515,23 +62635,23 @@ var ts; } return undefined; } - else if (node.kind === 12 && node.parent.kind === 181) { + else if (node.kind === 12 && node.parent.kind === 182) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0, sourceFile); } } - else if (node.kind === 13 && node.parent.parent.kind === 181) { + else if (node.kind === 13 && node.parent.parent.kind === 182) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 194); + ts.Debug.assert(templateExpression.kind === 195); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 202 && node.parent.parent.parent.kind === 181) { + else if (node.parent.kind === 204 && node.parent.parent.parent.kind === 182) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 194); + ts.Debug.assert(templateExpression.kind === 195); if (node.kind === 15 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } @@ -59539,8 +62659,20 @@ var ts; var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position); return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } + else if (node.parent && ts.isJsxOpeningLikeElement(node.parent)) { + var attributeSpanStart = node.parent.attributes.getFullStart(); + var attributeSpanEnd = ts.skipTrivia(sourceFile.text, node.parent.attributes.getEnd(), false); + return { + kind: 3, + invocation: node.parent, + argumentsSpan: ts.createTextSpan(attributeSpanStart, attributeSpanEnd - attributeSpanStart), + argumentIndex: 0, + argumentCount: 1 + }; + } return undefined; } + SignatureHelp.getImmediatelyContainingArgumentInfo = getImmediatelyContainingArgumentInfo; function getArgumentIndex(argumentsList, node) { var argumentIndex = 0; var listChildren = argumentsList.getChildren(); @@ -59595,7 +62727,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 194) { + if (template.kind === 195) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -59604,7 +62736,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 261; n = n.parent) { + for (var n = node; n.kind !== 264; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -59736,7 +62868,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 197) ? + return ts.getDeclarationOfKind(symbol, 198) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384) return ts.ScriptElementKind.enumElement; @@ -59793,7 +62925,7 @@ var ts; if (flags & 16384) return ts.ScriptElementKind.constructorImplementationElement; if (flags & 4) { - if (flags & 268435456) { + if (flags & 134217728 && symbol.checkFlags & 2) { var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); if (rootSymbolFlags & (98308 | 3)) { @@ -59810,6 +62942,9 @@ var ts; } return unionPropertyKind; } + if (location.parent && ts.isJsxAttribute(location.parent)) { + return ts.ScriptElementKind.jsxAttribute; + } return ts.ScriptElementKind.memberVariableElement; } return ts.ScriptElementKind.unknown; @@ -59836,26 +62971,29 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 177) { + if (location.parent && location.parent.kind === 178) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } - var callExpression = void 0; - if (location.kind === 179 || location.kind === 180) { - callExpression = location; + var callExpressionLike = void 0; + if (location.kind === 180 || location.kind === 181) { + callExpressionLike = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { - callExpression = location.parent; + callExpressionLike = location.parent; } - if (callExpression) { + else if (location.parent && ts.isJsxOpeningLikeElement(location.parent) && ts.isFunctionLike(symbol.valueDeclaration)) { + callExpressionLike = location.parent; + } + if (callExpressionLike) { var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures); + signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 180 || callExpression.expression.kind === 96; + var useConstructSignatures = callExpressionLike.kind === 181 || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 96); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -59879,6 +63017,7 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { + case ts.ScriptElementKind.jsxAttribute: case ts.ScriptElementKind.memberVariableElement: case ts.ScriptElementKind.variableElement: case ts.ScriptElementKind.constElement: @@ -59903,21 +63042,21 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 122 && location.parent.kind === 150)) { + (location.kind === 122 && location.parent.kind === 151)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 150 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 151 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 150) { + if (functionDeclaration.kind === 151) { symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 153 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 154 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -59926,7 +63065,7 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 197)) { + if (ts.getDeclarationOfKind(symbol, 198)) { pushTypePart(ts.ScriptElementKind.localClassElement); } else { @@ -59945,7 +63084,7 @@ var ts; } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(136)); + displayParts.push(ts.keywordPart(137)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); @@ -59966,7 +63105,7 @@ var ts; } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 230); + var declaration = ts.getDeclarationOfKind(symbol, 232); var isNamespace = declaration && declaration.name && declaration.name.kind === 70; displayParts.push(ts.keywordPart(isNamespace ? 128 : 127)); displayParts.push(ts.spacePart()); @@ -59985,25 +63124,25 @@ var ts; writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var declaration = ts.getDeclarationOfKind(symbol, 143); + var declaration = ts.getDeclarationOfKind(symbol, 144); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 154) { + if (declaration.kind === 155) { displayParts.push(ts.keywordPart(93)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 153 && declaration.name) { + else if (declaration.kind !== 154 && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } - else if (declaration.kind === 228) { + else if (declaration.kind === 230) { addInPrefix(); - displayParts.push(ts.keywordPart(136)); + displayParts.push(ts.keywordPart(137)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -60014,7 +63153,7 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 260) { + if (declaration.kind === 263) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -60026,7 +63165,7 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 233) { + if (symbol.declarations[0].kind === 235) { displayParts.push(ts.keywordPart(83)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(128)); @@ -60037,7 +63176,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 234) { + if (declaration.kind === 236) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -60072,6 +63211,7 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } if (symbolKind === ts.ScriptElementKind.memberVariableElement || + symbolKind === ts.ScriptElementKind.jsxAttribute || symbolFlags & 3 || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { @@ -60105,10 +63245,10 @@ var ts; if (!documentation) { documentation = symbol.getDocumentationComment(); if (documentation.length === 0 && symbol.flags & 4) { - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 261; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 264; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 192) { + if (!declaration.parent || declaration.parent.kind !== 193) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -60188,14 +63328,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 184) { + if (declaration.kind === 185) { return true; } - if (declaration.kind !== 223 && declaration.kind !== 225) { + if (declaration.kind !== 225 && declaration.kind !== 227) { return false; } - for (var parent_20 = declaration.parent; !ts.isFunctionBlock(parent_20); parent_20 = parent_20.parent) { - if (parent_20.kind === 261 || parent_20.kind === 231) { + for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { + if (parent.kind === 264 || parent.kind === 233) { return false; } } @@ -60230,7 +63370,7 @@ var ts; sourceFile.moduleName = transpileOptions.moduleName; } if (transpileOptions.renamedDependencies) { - sourceFile.renamedDependencies = ts.createMap(transpileOptions.renamedDependencies); + sourceFile.renamedDependencies = ts.createMapFromTemplate(transpileOptions.renamedDependencies); } var newLine = ts.getNewLineCharacter(options); var outputText; @@ -60276,10 +63416,10 @@ var ts; var commandLineOptionsStringToEnum; function fixupCompilerOptions(options, diagnostics) { commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { - return typeof o.type === "object" && !ts.forEachProperty(o.type, function (v) { return typeof v !== "number"; }); + return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_3 = function (opt) { + var _loop_5 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -60288,14 +63428,14 @@ var ts; options[opt.name] = ts.parseCustomTypeOption(opt, value, diagnostics); } else { - if (!ts.forEachProperty(opt.type, function (v) { return v === value; })) { + if (!ts.forEachEntry(opt.type, function (v) { return v === value; })) { diagnostics.push(ts.createCompilerDiagnosticForInvalidCustomType(opt)); } } }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_3(opt); + _loop_5(opt); } return options; } @@ -60307,6 +63447,15 @@ var ts; var standardScanner = ts.createScanner(5, false, 0); var jsxScanner = ts.createScanner(5, false, 1); var scanner; + var ScanAction; + (function (ScanAction) { + ScanAction[ScanAction["Scan"] = 0] = "Scan"; + ScanAction[ScanAction["RescanGreaterThanToken"] = 1] = "RescanGreaterThanToken"; + ScanAction[ScanAction["RescanSlashToken"] = 2] = "RescanSlashToken"; + ScanAction[ScanAction["RescanTemplateToken"] = 3] = "RescanTemplateToken"; + ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; + ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; + })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); scanner = sourceFile.languageVariant === 1 ? jsxScanner : standardScanner; @@ -60386,10 +63535,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { + case 252: case 250: - case 248: + case 251: case 249: - case 247: return node.kind === 70; } } @@ -60600,6 +63749,20 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + var FormattingRequestKind; + (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"; + })(FormattingRequestKind = formatting.FormattingRequestKind || (formatting.FormattingRequestKind = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -60621,6 +63784,19 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleAction; + (function (RuleAction) { + RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; + RuleAction[RuleAction["Space"] = 2] = "Space"; + RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; + RuleAction[RuleAction["Delete"] = 8] = "Delete"; + })(RuleAction = formatting.RuleAction || (formatting.RuleAction = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -60651,6 +63827,17 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleFlags; + (function (RuleFlags) { + RuleFlags[RuleFlags["None"] = 0] = "None"; + RuleFlags[RuleFlags["CanDeleteNewLines"] = 1] = "CanDeleteNewLines"; + })(RuleFlags = formatting.RuleFlags || (formatting.RuleFlags = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -60722,10 +63909,10 @@ var ts; this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromRange(0, 141, [19])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17, 81), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17, 105), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromTokens([19, 21, 25, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromTokens([21, 25, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); @@ -60736,10 +63923,10 @@ var ts; this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19, 3, 80, 101, 86, 81]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8)); this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8)); this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); @@ -60759,18 +63946,20 @@ var ts; this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([109, 75]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2)); this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([19, 80, 81, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2)); this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101, 86]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 133]), 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 134]), 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([127, 131]), 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 133, 114, 136, 138]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84, 107, 138])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 130, 134, 114, 137, 139, 126]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84, 107, 139])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(35, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); @@ -60784,7 +63973,7 @@ var ts; this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116, 70, 83, 78, 74, 114, 113, 111, 112, 124, 133, 20, 38])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116, 70, 83, 78, 74, 114, 113, 111, 112, 124, 134, 20, 38])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38, formatting.Shared.TokenRange.FromTokens([70, 18])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); @@ -60797,6 +63986,7 @@ var ts; this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40, 28), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, @@ -60825,7 +64015,7 @@ var ts; this.NoSpaceBetweenTagAndTemplateString, this.SpaceBeforeJsxAttribute, this.SpaceBeforeSlashInJsxOpeningElement, this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement, this.NoSpaceBeforeEqualInJsxAttribute, this.NoSpaceAfterEqualInJsxAttribute, - this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, + this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, this.SpaceBeforeArrow, this.SpaceAfterArrow, @@ -60840,6 +64030,7 @@ var ts; this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, + this.NoSpaceBeforeNonNullAssertionOperator ]; this.LowPriorityCommonRules = [ this.NoSpaceBeforeSemicolon, @@ -60848,7 +64039,6 @@ var ts; this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, - this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2)); @@ -60889,43 +64079,44 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_49 in o) { - if (o[name_49] === rule) { - return name_49; + for (var name in o) { + if (o[name] === rule) { + return name; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 211; + return context.contextNode.kind === 213; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 192: case 193: - case 200: - case 243: - case 239: - case 156: - case 164: + case 194: + case 201: + case 245: + case 241: + case 157: case 165: + case 166: return true; - case 174: - case 228: - case 234: - case 223: - case 144: - case 260: + case 175: + case 230: + case 236: + case 225: + case 145: + case 263: + case 148: case 147: - case 146: return context.currentTokenSpan.kind === 57 || context.nextTokenSpan.kind === 57; - case 212: + case 214: + case 144: return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; - case 213: - return context.currentTokenSpan.kind === 140 || context.nextTokenSpan.kind === 140; + case 215: + return context.currentTokenSpan.kind === 141 || context.nextTokenSpan.kind === 141; } return false; }; @@ -60933,11 +64124,14 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 193; + return context.contextNode.kind === 194; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; + Rules.IsBraceWrappedContext = function (context) { + return context.contextNode.kind === 173 || Rules.IsSingleLineBlockContext(context); + }; Rules.IsBeforeMultilineBlockContext = function (context) { return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); }; @@ -60958,90 +64152,96 @@ var ts; return true; } switch (node.kind) { - case 204: - case 232: - case 176: - case 231: + case 206: + case 234: + case 177: + case 233: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 225: + case 227: + case 150: case 149: - case 148: - case 151: case 152: case 153: - case 184: - case 150: + case 154: case 185: - case 227: + case 151: + case 186: + case 229: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 225 || context.contextNode.kind === 184; + return context.contextNode.kind === 227 || context.contextNode.kind === 185; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 226: - case 197: - case 227: + case 228: + case 198: case 229: - case 161: - case 230: - case 241: - case 242: - case 235: - case 238: + case 231: + case 162: + case 232: + case 243: + case 244: + case 237: + case 240: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 226: - case 230: - case 229: - case 204: - case 256: + case 228: + case 232: case 231: - case 218: + case 259: + case 233: + case 220: return true; + case 206: { + var blockParent = context.currentTokenParent.parent; + if (blockParent.kind !== 186 && + blockParent.kind !== 185) { + return true; + } + } } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 208: - case 218: - case 211: - case 212: - case 213: case 210: - case 221: - case 209: - case 217: - case 256: + case 220: + case 213: + case 214: + case 215: + case 212: + case 223: + case 211: + case 219: + case 259: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 176; + return context.contextNode.kind === 177; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 179; + return context.contextNode.kind === 180; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 180; + return context.contextNode.kind === 181; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -61053,25 +64253,25 @@ var ts; return context.nextTokenSpan.kind !== 21; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 185; + return context.contextNode.kind === 186; }; Rules.IsNonJsxSameLineTokenContext = function (context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 246; + return context.contextNode.kind !== 248; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 252; + return context.contextNode.kind === 255; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 250; + return context.nextTokenParent.kind === 252; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 250; + return context.contextNode.kind === 252; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 247; + return context.contextNode.kind === 249; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -61086,41 +64286,42 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 145; + return node.kind === 146; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 224 && + return context.currentTokenParent.kind === 226 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 230; + return context.contextNode.kind === 232; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 161; + return context.contextNode.kind === 162; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 26 && token.kind !== 28) { return false; } switch (parent.kind) { - case 157: - case 182: - case 226: - case 197: + case 158: + case 183: + case 230: + case 228: + case 198: + case 229: case 227: - case 225: - case 184: case 185: + case 186: + case 150: case 149: - case 148: - case 153: case 154: - case 179: + case 155: case 180: - case 199: + case 181: + case 200: return true; default: return false; @@ -61131,13 +64332,16 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 182; + return context.contextNode.kind === 183; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 188; + return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 189; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 195 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 196 && context.contextNode.expression !== undefined; + }; + Rules.IsNonNullAssertionContext = function (context) { + return context.contextNode.kind === 202; }; return Rules; }()); @@ -61159,7 +64363,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 140 + 1; + this.mapRowLength = 141 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -61172,7 +64376,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - ts.Debug.assert(row <= 140 && column <= 140, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 141 && column <= 141, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -61336,7 +64540,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 140; token++) { + for (var token = 0; token <= 141; token++) { result.push(token); } return result; @@ -61380,9 +64584,9 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(71, 140); + TokenRange.Keywords = TokenRange.FromRange(71, 141); TokenRange.BinaryOperators = TokenRange.FromRange(26, 69); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91, 92, 140, 117, 125]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91, 92, 141, 117, 125]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42, 43, 51, 50]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 70, 18, 20, 16, 98, 93]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); @@ -61390,7 +64594,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70, 19, 21, 93]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([70, 132, 134, 121, 135, 104, 118]); + TokenRange.TypeNames = TokenRange.FromTokens([70, 132, 135, 121, 136, 104, 118]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -61423,6 +64627,12 @@ var ts; }; RulesProvider.prototype.createActiveRules = function (options) { var rules = this.globalRules.HighPriorityCommonRules.slice(0); + if (options.insertSpaceAfterConstructor) { + rules.push(this.globalRules.SpaceAfterConstructor); + } + else { + rules.push(this.globalRules.NoSpaceAfterConstructor); + } if (options.insertSpaceAfterCommaDelimiter) { rules.push(this.globalRules.SpaceAfterComma); } @@ -61501,6 +64711,12 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); rules.push(this.globalRules.NoSpaceAfterBinaryOperator); } + if (options.insertSpaceBeforeFunctionParenthesis) { + rules.push(this.globalRules.SpaceBeforeOpenParenInFuncDecl); + } + else { + rules.push(this.globalRules.NoSpaceBeforeOpenParenInFuncDecl); + } if (options.placeOpenBraceOnNewLineForControlBlocks) { rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); } @@ -61526,6 +64742,10 @@ var ts; (function (ts) { var formatting; (function (formatting) { + var Constants; + (function (Constants) { + Constants[Constants["Unknown"] = -1] = "Unknown"; + })(Constants || (Constants = {})); function formatOnEnter(position, sourceFile, rulesProvider, options) { var line = sourceFile.getLineAndCharacterOfPosition(position).line; if (line === 0) { @@ -61598,17 +64818,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 226: - case 227: + case 228: + case 229: return ts.rangeContainsRange(parent.members, node); - case 230: + case 232: var body = parent.body; - return body && body.kind === 231 && ts.rangeContainsRange(body.statements, node); - case 261: - case 204: - case 231: + return body && body.kind === 233 && ts.rangeContainsRange(body.statements, node); + case 264: + case 206: + case 233: return ts.rangeContainsRange(parent.statements, node); - case 256: + case 259: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -61764,18 +64984,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 226: return 74; - case 227: return 108; - case 225: return 88; - case 229: return 229; - case 151: return 124; - case 152: return 133; - case 149: + case 228: return 74; + case 229: return 108; + case 227: return 88; + case 231: return 231; + case 152: return 124; + case 153: return 134; + case 150: if (node.asteriskToken) { return 38; } - case 147: - case 144: + case 148: + case 145: return node.name.kind; } } @@ -61799,17 +65019,30 @@ var ts; switch (kind) { case 16: case 17: - case 20: - case 21: case 18: case 19: case 81: case 105: case 56: return indentation; - default: - return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; + case 40: + case 28: { + if (container.kind === 250 || + container.kind === 251 || + container.kind === 249) { + return indentation; + } + break; + } + case 20: + case 21: { + if (container.kind !== 171) { + return indentation; + } + break; + } } + return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; }, getIndentation: function () { return indentation; }, getDelta: function (child) { return getEffectiveDelta(delta, child); }, @@ -61850,7 +65083,7 @@ var ts; if (tokenInfo.token.end > node.end) { break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); @@ -61880,7 +65113,7 @@ var ts; if (tokenInfo.token.end > childStartPos) { break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, node); } if (!formattingScanner.isOnToken()) { return inheritedIndentation; @@ -61891,11 +65124,11 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 145 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 146 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 175 && inheritedIndentation === -1) { + if (isFirstListItem && parent.kind === 176 && inheritedIndentation === -1) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -61915,10 +65148,10 @@ var ts; 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); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } else { - consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); } } } @@ -61931,7 +65164,7 @@ var ts; if (formattingScanner.isOnToken()) { var tokenInfo = formattingScanner.readTokenInfo(parent); if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } } } @@ -62121,7 +65354,7 @@ var ts; startLine++; } var delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; i++, startLine++) { + for (var i = startIndex; i < parts.length; i++, startLine++) { var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart @@ -62211,12 +65444,12 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 150: - case 225: - case 184: - case 149: - case 148: + case 151: + case 227: case 185: + case 150: + case 149: + case 186: if (node.typeParameters === list) { return 26; } @@ -62224,8 +65457,8 @@ var ts; return 18; } break; - case 179: case 180: + case 181: if (node.typeArguments === list) { return 26; } @@ -62233,7 +65466,7 @@ var ts; return 18; } break; - case 157: + case 158: if (node.typeArguments === list) { return 26; } @@ -62306,6 +65539,10 @@ var ts; (function (formatting) { var SmartIndenter; (function (SmartIndenter) { + var Value; + (function (Value) { + Value[Value["Unknown"] = -1] = "Unknown"; + })(Value || (Value = {})); function getIndentation(position, sourceFile, options) { if (position > sourceFile.text.length) { return getBaseIndentation(options); @@ -62334,7 +65571,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 25 && precedingToken.parent.kind !== 192) { + if (precedingToken.kind === 25 && precedingToken.parent.kind !== 193) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -62436,7 +65673,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 261 || !parentAndChildShareLine); + (parent.kind === 264 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -62460,7 +65697,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 208 && parent.elseStatement === child) { + if (parent.kind === 210 && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -62472,23 +65709,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 157: + case 158: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 176: + case 177: return node.parent.properties; - case 175: + case 176: return node.parent.elements; - case 225: - case 184: + case 227: case 185: + case 186: + case 150: case 149: - case 148: - case 153: - case 154: { + case 154: + case 155: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -62499,8 +65736,8 @@ var ts; } break; } - case 180: - case 179: { + case 181: + case 180: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -62528,8 +65765,8 @@ var ts; if (node.kind === 19) { return -1; } - if (node.parent && (node.parent.kind === 179 || - node.parent.kind === 180) && + if (node.parent && (node.parent.kind === 180 || + node.parent.kind === 181) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -62547,10 +65784,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 179: case 180: - case 177: + case 181: case 178: + case 179: node = node.expression; break; default: @@ -62604,48 +65841,49 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 207: - case 226: - case 197: - case 227: - case 229: + case 209: case 228: - case 175: - case 204: + case 198: + case 229: case 231: + case 230: case 176: - case 161: - case 163: - case 232: - case 254: - case 253: - case 183: + case 206: + case 233: case 177: - case 179: + case 162: + case 171: + case 164: + case 234: + case 257: + case 256: + case 184: + case 178: case 180: - case 205: - case 223: - case 240: - case 216: - case 193: - case 173: - case 172: - case 248: - case 247: - case 252: - case 148: - case 153: - case 154: - case 144: - case 158: - case 159: - case 166: case 181: - case 189: + case 207: + case 225: case 242: - case 238: - case 243: - case 239: + case 218: + case 194: + case 174: + case 173: + case 250: + case 249: + case 255: + case 149: + case 154: + case 155: + case 145: + case 159: + case 160: + case 167: + case 182: + case 190: + case 244: + case 240: + case 245: + case 241: return true; } return false; @@ -62653,27 +65891,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0; switch (parent.kind) { - case 209: - case 210: - case 212: - case 213: case 211: - case 208: - case 225: - case 184: - case 149: + case 212: + case 214: + case 215: + case 213: + case 210: + case 227: case 185: case 150: + case 186: case 151: case 152: - return childKind !== 204; - case 241: - return childKind !== 242; - case 235: - return childKind !== 236 || - (child.namedBindings && child.namedBindings.kind !== 238); - case 246: - return childKind !== 249; + case 153: + return childKind !== 206; + case 243: + return childKind !== 244; + case 237: + return childKind !== 238 || + (child.namedBindings && child.namedBindings.kind !== 240); + case 248: + return childKind !== 251; } return indentByDefault; } @@ -62689,7 +65927,7 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var codeFixes = ts.createMap(); + var codeFixes = []; function registerCodeFix(action) { ts.forEach(action.errorCodes, function (error) { var fixes = codeFixes[error]; @@ -62723,24 +65961,120 @@ var ts; (function (ts) { var codefix; (function (codefix) { - function getOpenBraceEnd(constructor, sourceFile) { - return constructor.body.getFirstToken(sourceFile).getEnd(); - } codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 122) { - return undefined; - } - var newPosition = getOpenBraceEnd(token.parent, sourceFile); - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] - }]; - } + errorCodes: [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code], + getCodeActions: getActionForClassLikeIncorrectImplementsInterface }); + function getActionForClassLikeIncorrectImplementsInterface(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + var classDecl = ts.getContainingClass(token); + if (!classDecl) { + return undefined; + } + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDecl); + var hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, 1); + var hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, 0); + var result = []; + for (var _i = 0, implementedTypeNodes_2 = implementedTypeNodes; _i < implementedTypeNodes_2.length; _i++) { + var implementedTypeNode = implementedTypeNodes_2[_i]; + var implementedType = checker.getTypeFromTypeNode(implementedTypeNode); + var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); + var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8); }); + var insertion = getMissingIndexSignatureInsertion(implementedType, 1, classDecl, hasNumericIndexSignature); + insertion += getMissingIndexSignatureInsertion(implementedType, 0, classDecl, hasStringIndexSignature); + insertion += codefix.getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); + var message = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); + if (insertion) { + pushAction(result, insertion, message); + } + } + return result; + function getMissingIndexSignatureInsertion(type, kind, enclosingDeclaration, hasIndexSigOfKind) { + if (!hasIndexSigOfKind) { + var IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); + if (IndexInfoOfKind) { + var writer = ts.getSingleLineStringWriter(); + checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); + var result_6 = writer.string(); + ts.releaseStringWriter(writer); + return result_6; + } + } + return ""; + } + function pushAction(result, insertion, description) { + var newAction = { + description: description, + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }; + result.push(newAction); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + function getActionForClassLikeMissingAbstractMember(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + if (ts.isClassLike(token.parent)) { + var classDecl = token.parent; + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + var extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); + var abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); + var insertion = codefix.getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); + if (insertion.length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_inherited_abstract_class), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }]; + } + } + return undefined; + } + function symbolPointsToNonPrivateAndAbstractMember(symbol) { + var decls = symbol.getDeclarations(); + ts.Debug.assert(!!(decls && decls.length > 0)); + var flags = ts.getModifierFlags(decls[0]); + return !(flags & 8) && !!(flags & 128); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { codefix.registerCodeFix({ errorCodes: [ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], getCodeActions: function (context) { @@ -62754,7 +66088,7 @@ var ts; if (!superCall) { return undefined; } - if (superCall.expression && superCall.expression.kind == 179) { + if (superCall.expression && superCall.expression.kind == 180) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -62762,7 +66096,7 @@ var ts; } } } - var newPosition = getOpenBraceEnd(constructor, sourceFile); + var newPosition = ts.getOpenBraceEnd(constructor, sourceFile); var changes = [{ fileName: sourceFile.fileName, textChanges: [{ newText: superCall.getText(sourceFile), @@ -62778,7 +66112,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 207 && ts.isSuperCall(n.expression)) { + if (n.kind === 209 && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -62791,6 +66125,257 @@ var ts; })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 122) { + return undefined; + } + var newPosition = ts.getOpenBraceEnd(token.parent, sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var classDeclNode = ts.getContainingClass(token); + if (!(token.kind === 70 && ts.isClassLike(classDeclNode))) { + return undefined; + } + var heritageClauses = classDeclNode.heritageClauses; + if (!(heritageClauses && heritageClauses.length > 0)) { + return undefined; + } + var extendsToken = heritageClauses[0].getFirstToken(); + if (!(extendsToken && extendsToken.kind === 84)) { + return undefined; + } + var changeStart = extendsToken.getStart(sourceFile); + var changeEnd = extendsToken.getEnd(); + var textChanges = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + for (var i = 1; i < heritageClauses.length; i++) { + var keywordToken = heritageClauses[i].getFirstToken(); + if (keywordToken) { + changeStart = keywordToken.getStart(sourceFile); + changeEnd = keywordToken.getEnd(); + textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + } + } + var result = [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Change_extends_to_implements), + changes: [{ + fileName: sourceFile.fileName, + textChanges: textChanges + }] + }]; + return result; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + var start = token.getStart(sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_this_to_unresolved_variable), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "this.", span: { start: start, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ + ts.Diagnostics._0_is_declared_but_never_used.code, + ts.Diagnostics.Property_0_is_declared_but_never_used.code + ], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + if (token.kind === 20) { + token = ts.getTokenAtPosition(sourceFile, start + 1); + } + switch (token.kind) { + case 70: + switch (token.parent.kind) { + case 225: + switch (token.parent.parent.parent.kind) { + case 213: + var forStatement = token.parent.parent.parent; + var forInitializer = forStatement.initializer; + if (forInitializer.declarations.length === 1) { + return createCodeFixToRemoveNode(forInitializer); + } + else { + return removeSingleItem(forInitializer.declarations, token); + } + case 215: + var forOfStatement = token.parent.parent.parent; + if (forOfStatement.initializer.kind === 226) { + var forOfInitializer = forOfStatement.initializer; + return createCodeFix("{}", forOfInitializer.declarations[0].getStart(), forOfInitializer.declarations[0].getWidth()); + } + break; + case 214: + return undefined; + case 259: + var catchClause = token.parent.parent; + var parameter = catchClause.variableDeclaration.getChildren()[0]; + return createCodeFixToRemoveNode(parameter); + default: + var variableStatement = token.parent.parent.parent; + if (variableStatement.declarationList.declarations.length === 1) { + return createCodeFixToRemoveNode(variableStatement); + } + else { + var declarations = variableStatement.declarationList.declarations; + return removeSingleItem(declarations, token); + } + } + case 144: + var typeParameters = token.parent.parent.typeParameters; + if (typeParameters.length === 1) { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + } + else { + return removeSingleItem(typeParameters, token); + } + case 145: + var functionDeclaration = token.parent.parent; + if (functionDeclaration.parameters.length === 1) { + return createCodeFixToRemoveNode(token.parent); + } + else { + return removeSingleItem(functionDeclaration.parameters, token); + } + case 236: + var importEquals = findImportDeclaration(token); + return createCodeFixToRemoveNode(importEquals); + case 241: + var namedImports = token.parent.parent; + if (namedImports.elements.length === 1) { + var importSpec = findImportDeclaration(token); + return createCodeFixToRemoveNode(importSpec); + } + else { + return removeSingleItem(namedImports.elements, token); + } + case 238: + var importClause = token.parent; + if (!importClause.namedBindings) { + var importDecl = findImportDeclaration(importClause); + return createCodeFixToRemoveNode(importDecl); + } + else { + var start_4 = importClause.name.getStart(); + var end = findFirstNonSpaceCharPosStarting(importClause.name.end); + if (sourceFile.text.charCodeAt(end) === 44) { + end = findFirstNonSpaceCharPosStarting(end + 1); + } + return createCodeFix("", start_4, end - start_4); + } + case 239: + var namespaceImport = token.parent; + if (namespaceImport.name == token && !namespaceImport.parent.name) { + var importDecl = findImportDeclaration(namespaceImport); + return createCodeFixToRemoveNode(importDecl); + } + else { + var start_5 = namespaceImport.parent.name.end; + return createCodeFix("", start_5, namespaceImport.parent.namedBindings.end - start_5); + } + } + break; + case 148: + case 239: + return createCodeFixToRemoveNode(token.parent); + } + if (ts.isDeclarationName(token)) { + return createCodeFixToRemoveNode(token.parent); + } + else if (ts.isLiteralComputedPropertyDeclarationName(token)) { + return createCodeFixToRemoveNode(token.parent.parent); + } + else { + return undefined; + } + function findImportDeclaration(token) { + var importDecl = token; + while (importDecl.kind != 237 && importDecl.parent) { + importDecl = importDecl.parent; + } + return importDecl; + } + function createCodeFixToRemoveNode(node) { + var end = node.getEnd(); + var endCharCode = sourceFile.text.charCodeAt(end); + var afterEndCharCode = sourceFile.text.charCodeAt(end + 1); + if (ts.isLineBreak(endCharCode)) { + end += 1; + } + if (ts.isLineBreak(afterEndCharCode) && endCharCode !== afterEndCharCode) { + end += 1; + } + var start = node.getStart(); + return createCodeFix("", start, end - start); + } + function findFirstNonSpaceCharPosStarting(start) { + while (ts.isWhiteSpace(sourceFile.text.charCodeAt(start))) { + start += 1; + } + return start; + } + function createCodeFix(newText, start, length) { + return [{ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ newText: newText, span: { start: start, length: length } }] + }] + }]; + } + function removeSingleItem(elements, token) { + if (elements[0] === token.parent) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + } + else { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + } + } + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var codefix; (function (codefix) { @@ -62802,18 +66387,19 @@ var ts; })(ModuleSpecifierComparison || (ModuleSpecifierComparison = {})); var ImportCodeActionMap = (function () { function ImportCodeActionMap() { - this.symbolIdToActionMap = ts.createMap(); + this.symbolIdToActionMap = []; } ImportCodeActionMap.prototype.addAction = function (symbolId, newAction) { if (!newAction) { return; } - if (!this.symbolIdToActionMap[symbolId]) { + var actions = this.symbolIdToActionMap[symbolId]; + if (!actions) { this.symbolIdToActionMap[symbolId] = [newAction]; return; } if (newAction.kind === "CodeChange") { - this.symbolIdToActionMap[symbolId].push(newAction); + actions.push(newAction); return; } var updatedNewImports = []; @@ -62846,8 +66432,8 @@ var ts; }; ImportCodeActionMap.prototype.getAllActions = function () { var result = []; - for (var symbolId in this.symbolIdToActionMap) { - result = ts.concatenate(result, this.symbolIdToActionMap[symbolId]); + for (var key in this.symbolIdToActionMap) { + result = ts.concatenate(result, this.symbolIdToActionMap[key]); } return result; }; @@ -62876,7 +66462,11 @@ var ts; return ImportCodeActionMap; }()); codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Cannot_find_name_0.code], + errorCodes: [ + ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics.Cannot_find_namespace_0.code, + ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ], getCodeActions: function (context) { var sourceFile = context.sourceFile; var checker = context.program.getTypeChecker(); @@ -62885,8 +66475,13 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, context.span.start); var name = token.getText(); var symbolIdActionMap = new ImportCodeActionMap(); - var cachedImportDeclarations = ts.createMap(); + var cachedImportDeclarations = []; var cachedNewImportInsertPosition; + var currentTokenMeaning = ts.getMeaningFromLocation(token); + if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { + var symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); + return getCodeActionForImport(symbol, false, true); + } var allPotentialModules = checker.getAmbientModules(); for (var _i = 0, allSourceFiles_1 = allSourceFiles; _i < allSourceFiles_1.length; _i++) { var otherSourceFile = allSourceFiles_1[_i]; @@ -62894,7 +66489,6 @@ var ts; allPotentialModules.push(otherSourceFile.symbol); } } - var currentTokenMeaning = ts.getMeaningFromLocation(token); for (var _a = 0, allPotentialModules_1 = allPotentialModules; _a < allPotentialModules_1.length; _a++) { var moduleSymbol = allPotentialModules_1[_a]; context.cancellationToken.throwIfCancellationRequested(); @@ -62915,8 +66509,9 @@ var ts; return symbolIdActionMap.getAllActions(); function getImportDeclarations(moduleSymbol) { var moduleSymbolId = getUniqueSymbolId(moduleSymbol); - if (cachedImportDeclarations[moduleSymbolId]) { - return cachedImportDeclarations[moduleSymbolId]; + var cached = cachedImportDeclarations[moduleSymbolId]; + if (cached) { + return cached; } var existingDeclarations = []; for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { @@ -62931,10 +66526,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 235) { + if (node.kind === 237) { return node; } - if (node.kind === 234) { + if (node.kind === 236) { return node; } node = node.parent; @@ -62952,7 +66547,7 @@ var ts; var declarations = symbol.getDeclarations(); return declarations ? ts.some(symbol.declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }) : false; } - function getCodeActionForImport(moduleSymbol, isDefault) { + function getCodeActionForImport(moduleSymbol, isDefault, isNamespaceImport) { var existingDeclarations = getImportDeclarations(moduleSymbol); if (existingDeclarations.length > 0) { return getCodeActionsForExistingImport(existingDeclarations); @@ -62965,11 +66560,11 @@ var ts; var namespaceImportDeclaration; var namedImportDeclaration; var existingModuleSpecifier; - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; - if (declaration.kind === 235) { + for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { + var declaration = declarations_14[_i]; + if (declaration.kind === 237) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 237) { + if (namedBindings && namedBindings.kind === 239) { namespaceImportDeclaration = declaration; } else { @@ -62985,7 +66580,7 @@ var ts; if (namespaceImportDeclaration) { actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration)); } - if (namedImportDeclaration && namedImportDeclaration.importClause && + if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause && (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { var textChange = getTextChangeForImportClause(namedImportDeclaration.importClause); var moduleSpecifierWithoutQuotes = ts.stripQuotes(namedImportDeclaration.moduleSpecifier.getText()); @@ -62996,7 +66591,7 @@ var ts; } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 245) { + if (declaration.moduleReference && declaration.moduleReference.kind === 247) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); @@ -63029,7 +66624,7 @@ var ts; } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 235) { + if (declaration.kind === 237) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { @@ -63055,24 +66650,26 @@ var ts; var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); var importStatementText = isDefault ? "import " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" - : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; + : isNamespaceImport + ? "import * as " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" + : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; var newText = cachedNewImportInsertPosition === sourceFile.getStart() ? importStatementText + ";" + context.newLineCharacter + context.newLineCharacter : "" + context.newLineCharacter + importStatementText + ";"; return createCodeAction(ts.Diagnostics.Import_0_from_1, [name, "\"" + moduleSpecifierWithoutQuotes + "\""], newText, { start: cachedNewImportInsertPosition, length: 0 }, sourceFile.fileName, "NewImport", moduleSpecifierWithoutQuotes); function getModuleSpecifierForNewImport() { - var fileName = sourceFile.path; - var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().path; + var fileName = sourceFile.fileName; + var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; var sourceDirectory = ts.getDirectoryPath(fileName); var options = context.program.getCompilerOptions(); return tryGetModuleNameFromAmbientModule() || - tryGetModuleNameFromBaseUrl() || - tryGetModuleNameFromRootDirs() || tryGetModuleNameFromTypeRoots() || tryGetModuleNameAsNodeModule() || + tryGetModuleNameFromBaseUrl() || + tryGetModuleNameFromRootDirs() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 261) { + if (moduleSymbol.valueDeclaration.kind !== 264) { return moduleSymbol.name; } } @@ -63080,11 +66677,11 @@ var ts; if (!options.baseUrl) { return undefined; } - var normalizedBaseUrl = ts.toPath(options.baseUrl, ts.getDirectoryPath(options.baseUrl), getCanonicalFileName); - var relativeName = tryRemoveParentDirectoryName(moduleFileName, normalizedBaseUrl); + var relativeName = getRelativePathIfInDirectory(moduleFileName, options.baseUrl); if (!relativeName) { return undefined; } + var relativeNameWithIndex = ts.removeFileExtension(relativeName); relativeName = removeExtensionAndIndexPostFix(relativeName); if (options.paths) { for (var key in options.paths) { @@ -63104,7 +66701,7 @@ var ts; return key.replace("\*", matchedStar); } } - else if (pattern === relativeName) { + else if (pattern === relativeName || pattern === relativeNameWithIndex) { return key; } } @@ -63114,9 +66711,8 @@ var ts; } function tryGetModuleNameFromRootDirs() { if (options.rootDirs) { - var normalizedRootDirs = ts.map(options.rootDirs, function (rootDir) { return ts.toPath(rootDir, undefined, getCanonicalFileName); }); - var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, normalizedRootDirs); - var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, normalizedRootDirs); + var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, options.rootDirs); + var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, options.rootDirs); if (normalizedTargetPath !== undefined) { var relativePath = normalizedSourcePath !== undefined ? getRelativePath(normalizedTargetPath, normalizedSourcePath) : normalizedTargetPath; return ts.removeFileExtension(relativePath); @@ -63178,7 +66774,7 @@ var ts; function getPathRelativeToRootDirs(path, rootDirs) { for (var _i = 0, rootDirs_2 = rootDirs; _i < rootDirs_2.length; _i++) { var rootDir = rootDirs_2[_i]; - var relativeName = tryRemoveParentDirectoryName(path, rootDir); + var relativeName = getRelativePathIfInDirectory(path, rootDir); if (relativeName !== undefined) { return relativeName; } @@ -63192,19 +66788,14 @@ var ts; } return fileName; } + function getRelativePathIfInDirectory(path, directoryPath) { + var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); + return ts.isRootedDiskPath(relativePath) || ts.startsWith(relativePath, "..") ? undefined : relativePath; + } function getRelativePath(path, directoryPath) { var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); return ts.moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath; } - function tryRemoveParentDirectoryName(path, parentDirectory) { - var index = path.indexOf(parentDirectory); - if (index === 0) { - return ts.endsWith(parentDirectory, ts.directorySeparator) - ? path.substring(parentDirectory.length) - : path.substring(parentDirectory.length + 1); - } - return undefined; - } } } function createCodeAction(description, diagnosticArgs, newText, span, fileName, kind, moduleSpecifier) { @@ -63223,151 +66814,127 @@ var ts; (function (ts) { var codefix; (function (codefix) { - codefix.registerCodeFix({ - errorCodes: [ - ts.Diagnostics._0_is_declared_but_never_used.code, - ts.Diagnostics.Property_0_is_declared_but_never_used.code - ], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var start = context.span.start; - var token = ts.getTokenAtPosition(sourceFile, start); - if (token.kind === 20) { - token = ts.getTokenAtPosition(sourceFile, start + 1); - } - switch (token.kind) { - case 70: - switch (token.parent.kind) { - case 223: - switch (token.parent.parent.parent.kind) { - case 211: - var forStatement = token.parent.parent.parent; - var forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); - } - else { - return removeSingleItem(forInitializer.declarations, token); - } - case 213: - var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 224) { - var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); - } - break; - case 212: - return undefined; - case 256: - var catchClause = token.parent.parent; - var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFix("", parameter.pos, parameter.end - parameter.pos); - default: - var variableStatement = token.parent.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); - } - else { - var declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); - } - } - case 143: - var typeParameters = token.parent.parent.typeParameters; - if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); - } - else { - return removeSingleItem(typeParameters, token); - } - case 144: - var functionDeclaration = token.parent.parent; - if (functionDeclaration.parameters.length === 1) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else { - return removeSingleItem(functionDeclaration.parameters, token); - } - case 234: - var importEquals = findImportDeclaration(token); - return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); - case 239: - var namedImports = token.parent.parent; - if (namedImports.elements.length === 1) { - var importSpec = findImportDeclaration(token); - return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); - } - else { - return removeSingleItem(namedImports.elements, token); - } - case 236: - var importClause = token.parent; - if (!importClause.namedBindings) { - var importDecl = findImportDeclaration(importClause); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); - } - case 237: - var namespaceImport = token.parent; - if (namespaceImport.name == token && !namespaceImport.parent.name) { - var importDecl = findImportDeclaration(namespaceImport); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - var start_4 = namespaceImport.parent.name.end; - return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); - } - } - break; - case 147: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - case 237: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - if (ts.isDeclarationName(token)) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); - } - else { - return undefined; - } - function findImportDeclaration(token) { - var importDecl = token; - while (importDecl.kind != 235 && importDecl.parent) { - importDecl = importDecl.parent; + function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { + var classMembers = classDeclaration.symbol.members; + var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !classMembers.has(symbol.getName()); }); + var insertion = ""; + for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { + var symbol = missingMembers_1[_i]; + insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + } + return insertion; + } + codefix.getMissingMembersInsertion = getMissingMembersInsertion; + function getInsertionForMemberSymbol(symbol, enclosingDeclaration, checker, newlineChar) { + var type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + var declarations = symbol.getDeclarations(); + if (!(declarations && declarations.length)) { + return ""; + } + var declaration = declarations[0]; + var name = declaration.name ? declaration.name.getText() : undefined; + var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); + switch (declaration.kind) { + case 152: + case 153: + case 147: + case 148: + var typeString = checker.typeToString(type, enclosingDeclaration, 0); + return "" + visibility + name + ": " + typeString + ";" + newlineChar; + case 149: + case 150: + var signatures = checker.getSignaturesOfType(type, 0); + if (!(signatures && signatures.length > 0)) { + return ""; } - return importDecl; - } - function createCodeFix(newText, start, length) { - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText: newText, span: { start: start, length: length } }] - }] - }]; - } - function removeSingleItem(elements, token) { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + if (declarations.length === 1) { + ts.Debug.assert(signatures.length === 1); + var sigString_1 = checker.signatureToString(signatures[0], enclosingDeclaration, 2048, 0); + return "" + visibility + name + sigString_1 + getMethodBodyStub(newlineChar); + } + var result = ""; + for (var i = 0; i < signatures.length; i++) { + var sigString_2 = checker.signatureToString(signatures[i], enclosingDeclaration, 2048, 0); + result += "" + visibility + name + sigString_2 + ";" + newlineChar; + } + var bodySig = undefined; + if (declarations.length > signatures.length) { + bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); } else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + ts.Debug.assert(declarations.length === signatures.length); + bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); } + var sigString = checker.signatureToString(bodySig, enclosingDeclaration, 2048, 0); + result += "" + visibility + name + sigString + getMethodBodyStub(newlineChar); + return result; + default: + return ""; + } + } + function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { + var newSignatureDeclaration = ts.createNode(154); + newSignatureDeclaration.parent = enclosingDeclaration; + newSignatureDeclaration.name = signatures[0].getDeclaration().name; + var maxNonRestArgs = -1; + var maxArgsIndex = 0; + var minArgumentCount = signatures[0].minArgumentCount; + var hasRestParameter = false; + for (var i = 0; i < signatures.length; i++) { + var sig = signatures[i]; + minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); + hasRestParameter = hasRestParameter || sig.hasRestParameter; + var nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); + if (nonRestLength > maxNonRestArgs) { + maxNonRestArgs = nonRestLength; + maxArgsIndex = i; } } - }); + var maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(function (symbol) { return symbol.getName(); }); + var optionalToken = ts.createToken(54); + newSignatureDeclaration.parameters = ts.createNodeArray(); + for (var i = 0; i < maxNonRestArgs; i++) { + var newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); + newSignatureDeclaration.parameters.push(newParameter); + } + if (hasRestParameter) { + var restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); + restParameter.dotDotDotToken = ts.createToken(23); + newSignatureDeclaration.parameters.push(restParameter); + } + return checker.getSignatureFromDeclaration(newSignatureDeclaration); + function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { + var newParameter = ts.createNode(145); + newParameter.symbol = new SymbolConstructor(1, maxArgsParameterSymbolNames[index] || "rest"); + newParameter.symbol.valueDeclaration = newParameter; + newParameter.symbol.declarations = [newParameter]; + newParameter.parent = enclosingSignatureDeclaration; + if (index >= minArgCount) { + newParameter.questionToken = optionalToken; + } + return newParameter; + } + } + function getMethodBodyStub(newLineChar) { + return " {" + newLineChar + "throw new Error('Method not implemented.');" + newLineChar + "}" + newLineChar; + } + function getVisibilityPrefix(flags) { + if (flags & 4) { + return "public "; + } + else if (flags & 16) { + return "protected "; + } + return ""; + } + var SymbolConstructor = ts.objectAllocator.getSymbolConstructor(); })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; (function (ts) { ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 141 ? new NodeObject(kind, pos, end) : + var node = kind >= 142 ? new NodeObject(kind, pos, end) : kind === 70 ? new IdentifierObject(70, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; @@ -63425,7 +66992,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(292, nodes.pos, nodes.end, this); + var list = createNode(296, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -63444,11 +67011,11 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 141) { + if (this.kind >= 142) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 278 && this.kind <= 291; + var useJSDocScanner_1 = this.kind >= 282 && this.kind <= 295; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -63501,8 +67068,10 @@ var ts; if (!children.length) { return undefined; } - var child = children[0]; - return child.kind < 141 ? child : child.getFirstToken(sourceFile); + var child = ts.find(children, function (kid) { return kid.kind < 266 || kid.kind > 295; }); + return child.kind < 142 ? + child : + child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -63510,7 +67079,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 141 ? child : child.getLastToken(sourceFile); + return child.kind < 142 ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -63707,17 +67276,21 @@ var ts; return this.namedDeclarations; }; SourceFileObject.prototype.computeNamedDeclarations = function () { - var result = ts.createMap(); + var result = ts.createMultiMap(); ts.forEachChild(this, visit); return result; function addDeclaration(declaration) { var name = getDeclarationName(declaration); if (name) { - ts.multiMapAdd(result, name, declaration); + result.add(name, declaration); } } function getDeclarations(name) { - return result[name] || (result[name] = []); + var declarations = result.get(name); + if (!declarations) { + result.set(name, declarations = []); + } + return declarations; } function getDeclarationName(declaration) { if (declaration.name) { @@ -63725,9 +67298,9 @@ var ts; if (result_7 !== undefined) { return result_7; } - if (declaration.name.kind === 142) { + if (declaration.name.kind === 143) { var expr = declaration.name.expression; - if (expr.kind === 177) { + if (expr.kind === 178) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -63747,10 +67320,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 225: - case 184: + case 227: + case 185: + case 150: case 149: - case 148: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -63767,30 +67340,30 @@ var ts; } ts.forEachChild(node, visit); break; - case 226: - case 197: - case 227: case 228: + case 198: case 229: case 230: - case 234: - case 243: - case 239: - case 234: + case 231: + case 232: case 236: - case 237: - case 151: + case 245: + case 241: + case 236: + case 238: + case 239: case 152: - case 161: + case 153: + case 162: addDeclaration(node); ts.forEachChild(node, visit); break; - case 144: + case 145: if (!ts.hasModifier(node, 92)) { break; } - case 223: - case 174: { + case 225: + case 175: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -63799,24 +67372,24 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 260: + case 263: + case 148: case 147: - case 146: addDeclaration(node); break; - case 241: + case 243: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 235: + case 237: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237) { + if (importClause.namedBindings.kind === 239) { addDeclaration(importClause.namedBindings); } else { @@ -64259,10 +67832,10 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { switch (node.kind) { case 70: - case 177: - case 141: + case 178: + case 142: case 98: - case 167: + case 168: case 96: var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -64301,8 +67874,8 @@ var ts; function getOccurrencesAtPosition(fileName, position) { var results = getOccurrencesAtPositionCore(fileName, position); if (results) { - var sourceFile_2 = getCanonicalFileName(ts.normalizeSlashes(fileName)); - results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_2; }); + var sourceFile_1 = getCanonicalFileName(ts.normalizeSlashes(fileName)); + results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_1; }); } return results; } @@ -64336,20 +67909,20 @@ var ts; } } function findRenameLocations(fileName, position, findInStrings, findInComments) { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments, true); return ts.FindAllReferences.convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, false, false, false); return ts.FindAllReferences.convertReferences(referencedSymbols); } function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, false, false, false); return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); } - function findReferencedSymbols(fileName, position, findInStrings, findInComments) { + function findReferencedSymbols(fileName, position, findInStrings, findInComments, isForRename) { synchronizeHostData(); - return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments); + return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments, isForRename); } function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { synchronizeHostData(); @@ -64391,15 +67964,15 @@ var ts; return; } switch (node.kind) { - case 177: - case 141: + case 178: + case 142: case 9: case 85: case 100: case 94: case 96: case 98: - case 167: + case 168: case 70: break; default: @@ -64411,7 +67984,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 230 && + if (nodeForStartPos.parent.parent.kind === 232 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -64543,7 +68116,7 @@ var ts; var span = { start: start, length: end - start }; var newLineChar = ts.getNewLineOrDefaultFromHost(host); var allFixes = []; - ts.forEach(errorCodes, function (error) { + ts.forEach(ts.deduplicate(errorCodes), function (error) { cancellationToken.throwIfCancellationRequested(); var context = { errorCode: error, @@ -64600,7 +68173,7 @@ var ts; continue; } var descriptor = undefined; - for (var i = 0, n = descriptors.length; i < n; i++) { + for (var i = 0; i < descriptors.length; i++) { if (matchArray[i + firstDescriptorCaptureIndex]) { descriptor = descriptors[i]; } @@ -64704,15 +68277,15 @@ var ts; function walk(node) { switch (node.kind) { case 70: - nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; + setNameTable(node.text, node); break; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 245 || + node.parent.kind === 247 || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { - nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; + setNameTable(node.text, node); } break; default: @@ -64725,11 +68298,66 @@ var ts; } } } + function setNameTable(text, node) { + nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); + } } + function isObjectLiteralElement(node) { + switch (node.kind) { + case 252: + case 254: + case 260: + case 261: + case 150: + case 152: + case 153: + return true; + } + return false; + } + function getContainingObjectLiteralElement(node) { + switch (node.kind) { + case 9: + case 8: + if (node.parent.kind === 143) { + return isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; + } + case 70: + return isObjectLiteralElement(node.parent) && + (node.parent.parent.kind === 177 || node.parent.parent.kind === 253) && + node.parent.name === node ? node.parent : undefined; + } + return undefined; + } + ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; + function getPropertySymbolsFromContextualType(typeChecker, node) { + var objectLiteral = node.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name = ts.getTextOfPropertyName(node.name); + if (name && contextualType) { + var result_8 = []; + var symbol = contextualType.getProperty(name); + if (contextualType.flags & 65536) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_8.push(symbol); + } + }); + return result_8; + } + if (symbol) { + result_8.push(symbol); + return result_8; + } + } + return undefined; + } + ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 178 && + node.parent.kind === 179 && node.parent.argumentExpression === node; } function getDefaultLibFilePath(options) { @@ -64739,2744 +68367,239 @@ var ts; throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); } ts.getDefaultLibFilePath = getDefaultLibFilePath; - function initializeServices() { - ts.objectAllocator = getServicesObjectAllocator(); - } - initializeServices(); + ts.objectAllocator = getServicesObjectAllocator(); })(ts || (ts = {})); var ts; (function (ts) { var server; (function (server) { - var TextStorage = (function () { - function TextStorage(host, fileName) { - this.host = host; - this.fileName = fileName; - this.svcVersion = 0; - this.textVersion = 0; - } - TextStorage.prototype.getVersion = function () { - return this.svc - ? "SVC-" + this.svcVersion + "-" + this.svc.getSnapshot().version - : "Text-" + this.textVersion; - }; - TextStorage.prototype.hasScriptVersionCache = function () { - return this.svc !== undefined; - }; - TextStorage.prototype.useScriptVersionCache = function (newText) { - this.switchToScriptVersionCache(newText); - }; - TextStorage.prototype.useText = function (newText) { - this.svc = undefined; - this.setText(newText); - }; - TextStorage.prototype.edit = function (start, end, newText) { - this.switchToScriptVersionCache().edit(start, end - start, newText); - }; - TextStorage.prototype.reload = function (text) { - if (this.svc) { - this.svc.reload(text); - } - else { - this.setText(text); - } - }; - TextStorage.prototype.reloadFromFile = function (tempFileName) { - if (this.svc || (tempFileName !== this.fileName)) { - this.reload(this.getFileText(tempFileName)); - } - else { - this.setText(undefined); - } - }; - TextStorage.prototype.getSnapshot = function () { - return this.svc - ? this.svc.getSnapshot() - : ts.ScriptSnapshot.fromString(this.getOrLoadText()); - }; - TextStorage.prototype.getLineInfo = function (line) { - return this.switchToScriptVersionCache().getSnapshot().index.lineNumberToInfo(line); - }; - TextStorage.prototype.lineToTextSpan = function (line) { - if (!this.svc) { - var lineMap = this.getLineMap(); - var start = lineMap[line]; - var end = line + 1 < lineMap.length ? lineMap[line + 1] : this.text.length; - return ts.createTextSpanFromBounds(start, end); - } - var index = this.svc.getSnapshot().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); - }; - TextStorage.prototype.lineOffsetToPosition = function (line, offset) { - if (!this.svc) { - return ts.computePositionOfLineAndCharacter(this.getLineMap(), line - 1, offset - 1); - } - var index = this.svc.getSnapshot().index; - var lineInfo = index.lineNumberToInfo(line); - return (lineInfo.offset + offset - 1); - }; - TextStorage.prototype.positionToLineOffset = function (position) { - if (!this.svc) { - var _a = ts.computeLineAndCharacterOfPosition(this.getLineMap(), position), line = _a.line, character = _a.character; - return { line: line + 1, offset: character + 1 }; - } - var index = this.svc.getSnapshot().index; - var lineOffset = index.charOffsetToLineNumberAndPos(position); - return { line: lineOffset.line, offset: lineOffset.offset + 1 }; - }; - TextStorage.prototype.getFileText = function (tempFileName) { - return this.host.readFile(tempFileName || this.fileName) || ""; - }; - TextStorage.prototype.ensureNoScriptVersionCache = function () { - ts.Debug.assert(!this.svc, "ScriptVersionCache should not be set"); - }; - TextStorage.prototype.switchToScriptVersionCache = function (newText) { - if (!this.svc) { - this.svc = server.ScriptVersionCache.fromString(this.host, newText !== undefined ? newText : this.getOrLoadText()); - this.svcVersion++; - this.text = undefined; - } - return this.svc; - }; - TextStorage.prototype.getOrLoadText = function () { - this.ensureNoScriptVersionCache(); - if (this.text === undefined) { - this.setText(this.getFileText()); - } - return this.text; - }; - TextStorage.prototype.getLineMap = function () { - this.ensureNoScriptVersionCache(); - return this.lineMap || (this.lineMap = ts.computeLineStarts(this.getOrLoadText())); - }; - TextStorage.prototype.setText = function (newText) { - this.ensureNoScriptVersionCache(); - if (newText === undefined || this.text !== newText) { - this.text = newText; - this.lineMap = undefined; - this.textVersion++; - } - }; - return TextStorage; - }()); - server.TextStorage = TextStorage; - var ScriptInfo = (function () { - function ScriptInfo(host, fileName, scriptKind, hasMixedContent) { - if (hasMixedContent === void 0) { hasMixedContent = false; } - this.host = host; - this.fileName = fileName; - this.scriptKind = scriptKind; - this.hasMixedContent = hasMixedContent; - this.containingProjects = []; - this.path = ts.toPath(fileName, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); - this.textStorage = new TextStorage(host, fileName); - if (hasMixedContent) { - this.textStorage.reload(""); - } - this.scriptKind = scriptKind - ? scriptKind - : ts.getScriptKindFromFileName(fileName); - } - ScriptInfo.prototype.isScriptOpen = function () { - return this.isOpen; - }; - ScriptInfo.prototype.open = function (newText) { - this.isOpen = true; - this.textStorage.useScriptVersionCache(newText); - this.markContainingProjectsAsDirty(); - }; - ScriptInfo.prototype.close = function () { - this.isOpen = false; - this.textStorage.useText(this.hasMixedContent ? "" : undefined); - this.markContainingProjectsAsDirty(); - }; - ScriptInfo.prototype.getSnapshot = function () { - return this.textStorage.getSnapshot(); - }; - ScriptInfo.prototype.getFormatCodeSettings = function () { - return this.formatCodeSettings; - }; - ScriptInfo.prototype.attachToProject = function (project) { - var isNew = !this.isAttached(project); - if (isNew) { - this.containingProjects.push(project); - } - return isNew; - }; - ScriptInfo.prototype.isAttached = function (project) { - switch (this.containingProjects.length) { - case 0: return false; - case 1: return this.containingProjects[0] === project; - case 2: return this.containingProjects[0] === project || this.containingProjects[1] === project; - default: return ts.contains(this.containingProjects, project); - } - }; - ScriptInfo.prototype.detachFromProject = function (project) { - switch (this.containingProjects.length) { - case 0: - return; - case 1: - if (this.containingProjects[0] === project) { - this.containingProjects.pop(); - } - break; - case 2: - if (this.containingProjects[0] === project) { - this.containingProjects[0] = this.containingProjects.pop(); - } - else if (this.containingProjects[1] === project) { - this.containingProjects.pop(); - } - break; - default: - server.removeItemFromSet(this.containingProjects, project); - break; - } - }; - ScriptInfo.prototype.detachAllProjects = function () { - for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { - var p = _a[_i]; - p.removeFile(this, false); - } - this.containingProjects.length = 0; - }; - ScriptInfo.prototype.getDefaultProject = function () { - if (this.containingProjects.length === 0) { - return server.Errors.ThrowNoProject(); - } - return this.containingProjects[0]; - }; - ScriptInfo.prototype.registerFileUpdate = function () { - for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { - var p = _a[_i]; - p.registerFileUpdate(this.path); - } - }; - ScriptInfo.prototype.setFormatOptions = function (formatSettings) { - if (formatSettings) { - if (!this.formatCodeSettings) { - this.formatCodeSettings = server.getDefaultFormatCodeSettings(this.host); - } - server.mergeMaps(this.formatCodeSettings, formatSettings); - } - }; - ScriptInfo.prototype.setWatcher = function (watcher) { - this.stopWatcher(); - this.fileWatcher = watcher; - }; - ScriptInfo.prototype.stopWatcher = function () { - if (this.fileWatcher) { - this.fileWatcher.close(); - this.fileWatcher = undefined; - } - }; - ScriptInfo.prototype.getLatestVersion = function () { - return this.textStorage.getVersion(); - }; - ScriptInfo.prototype.reload = function (script) { - this.textStorage.reload(script); - this.markContainingProjectsAsDirty(); - }; - ScriptInfo.prototype.saveTo = function (fileName) { - var snap = this.textStorage.getSnapshot(); - this.host.writeFile(fileName, snap.getText(0, snap.getLength())); - }; - ScriptInfo.prototype.reloadFromFile = function (tempFileName) { - if (this.hasMixedContent) { - this.reload(""); - } - else { - this.textStorage.reloadFromFile(tempFileName); - this.markContainingProjectsAsDirty(); - } - }; - ScriptInfo.prototype.getLineInfo = function (line) { - return this.textStorage.getLineInfo(line); - }; - ScriptInfo.prototype.editContent = function (start, end, newText) { - this.textStorage.edit(start, end, newText); - this.markContainingProjectsAsDirty(); - }; - ScriptInfo.prototype.markContainingProjectsAsDirty = function () { - for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { - var p = _a[_i]; - p.markAsDirty(); - } - }; - ScriptInfo.prototype.lineToTextSpan = function (line) { - return this.textStorage.lineToTextSpan(line); - }; - ScriptInfo.prototype.lineOffsetToPosition = function (line, offset) { - return this.textStorage.lineOffsetToPosition(line, offset); - }; - ScriptInfo.prototype.positionToLineOffset = function (position) { - return this.textStorage.positionToLineOffset(position); - }; - return ScriptInfo; - }()); - server.ScriptInfo = ScriptInfo; + server.ActionSet = "action::set"; + server.ActionInvalidate = "action::invalidate"; + server.EventBeginInstallTypes = "event::beginInstallTypes"; + server.EventEndInstallTypes = "event::endInstallTypes"; + var Arguments; + (function (Arguments) { + Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation"; + Arguments.LogFile = "--logFile"; + Arguments.EnableTelemetry = "--enableTelemetry"; + })(Arguments = server.Arguments || (server.Arguments = {})); + function hasArgument(argumentName) { + return ts.sys.args.indexOf(argumentName) >= 0; + } + server.hasArgument = hasArgument; + function findArgument(argumentName) { + var index = ts.sys.args.indexOf(argumentName); + return index >= 0 && index < ts.sys.args.length - 1 + ? ts.sys.args[index + 1] + : undefined; + } + server.findArgument = findArgument; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; (function (ts) { var server; (function (server) { - var LSHost = (function () { - function LSHost(host, project, cancellationToken) { - var _this = this; - this.host = host; - this.project = project; - this.cancellationToken = cancellationToken; - this.resolvedModuleNames = ts.createFileMap(); - this.resolvedTypeReferenceDirectives = ts.createFileMap(); - this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); - if (host.trace) { - this.trace = function (s) { return host.trace(s); }; - } - this.resolveModuleName = function (moduleName, containingFile, compilerOptions, host) { - var globalCache = _this.project.getTypeAcquisition().enable - ? _this.project.projectService.typingsInstaller.globalTypingsCacheLocation - : undefined; - var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host); - if (!(primaryResult.resolvedModule && ts.extensionIsTypeScript(primaryResult.resolvedModule.extension)) && globalCache !== undefined) { - var _a = ts.loadModuleFromGlobalCache(moduleName, _this.project.getProjectName(), compilerOptions, host, globalCache), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; - if (resolvedModule) { - return { resolvedModule: resolvedModule, failedLookupLocations: primaryResult.failedLookupLocations.concat(failedLookupLocations) }; - } - } - return primaryResult; - }; - if (this.host.realpath) { - this.realpath = function (path) { return _this.host.realpath(path); }; - } - } - LSHost.prototype.startRecordingFilesWithChangedResolutions = function () { - this.filesWithChangedSetOfUnresolvedImports = []; - }; - LSHost.prototype.finishRecordingFilesWithChangedResolutions = function () { - var collected = this.filesWithChangedSetOfUnresolvedImports; - this.filesWithChangedSetOfUnresolvedImports = undefined; - return collected; - }; - LSHost.prototype.resolveNamesWithLocalCache = function (names, containingFile, cache, loader, getResult, getResultFileName, logChanges) { - var path = ts.toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); - var currentResolutionsInFile = cache.get(path); - var newResolutions = ts.createMap(); - var resolvedModules = []; - var compilerOptions = this.getCompilationSettings(); - var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; - for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_50 = names_2[_i]; - var resolution = newResolutions[name_50]; - if (!resolution) { - var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_50]; - if (moduleResolutionIsValid(existingResolution)) { - resolution = existingResolution; - } - else { - newResolutions[name_50] = resolution = loader(name_50, containingFile, compilerOptions, this); - } - if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { - this.filesWithChangedSetOfUnresolvedImports.push(path); - logChanges = false; - } - } - ts.Debug.assert(resolution !== undefined); - resolvedModules.push(getResult(resolution)); - } - cache.set(path, newResolutions); - return resolvedModules; - function resolutionIsEqualTo(oldResolution, newResolution) { - if (oldResolution === newResolution) { - return true; - } - if (!oldResolution || !newResolution) { - return false; - } - var oldResult = getResult(oldResolution); - var newResult = getResult(newResolution); - if (oldResult === newResult) { - return true; - } - if (!oldResult || !newResult) { - return false; - } - return getResultFileName(oldResult) === getResultFileName(newResult); - } - function moduleResolutionIsValid(resolution) { - if (!resolution) { - return false; - } - var result = getResult(resolution); - if (result) { - return getResultFileName(result) !== lastDeletedFileName; - } - return resolution.failedLookupLocations.length === 0; - } - }; - LSHost.prototype.getProjectVersion = function () { - return this.project.getProjectVersion(); - }; - LSHost.prototype.getCompilationSettings = function () { - return this.compilationSettings; - }; - LSHost.prototype.useCaseSensitiveFileNames = function () { - return this.host.useCaseSensitiveFileNames; - }; - LSHost.prototype.getCancellationToken = function () { - return this.cancellationToken; - }; - LSHost.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - return this.resolveNamesWithLocalCache(typeDirectiveNames, containingFile, this.resolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, function (m) { return m.resolvedTypeReferenceDirective; }, function (r) { return r.resolvedFileName; }, false); - }; - LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { - return this.resolveNamesWithLocalCache(moduleNames, containingFile, this.resolvedModuleNames, this.resolveModuleName, function (m) { return m.resolvedModule; }, function (r) { return r.resolvedFileName; }, true); - }; - LSHost.prototype.getDefaultLibFileName = function () { - var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); - return ts.combinePaths(nodeModuleBinDir, ts.getDefaultLibFileName(this.compilationSettings)); - }; - LSHost.prototype.getScriptSnapshot = function (filename) { - var scriptInfo = this.project.getScriptInfoLSHost(filename); - if (scriptInfo) { - return scriptInfo.getSnapshot(); - } - }; - LSHost.prototype.getScriptFileNames = function () { - return this.project.getRootFilesLSHost(); - }; - LSHost.prototype.getTypeRootsVersion = function () { - return this.project.typesVersion; - }; - LSHost.prototype.getScriptKind = function (fileName) { - var info = this.project.getScriptInfoLSHost(fileName); - return info && info.scriptKind; - }; - LSHost.prototype.getScriptVersion = function (filename) { - var info = this.project.getScriptInfoLSHost(filename); - return info && info.getLatestVersion(); - }; - LSHost.prototype.getCurrentDirectory = function () { - return this.host.getCurrentDirectory(); - }; - LSHost.prototype.resolvePath = function (path) { - return this.host.resolvePath(path); - }; - LSHost.prototype.fileExists = function (path) { - return this.host.fileExists(path); - }; - LSHost.prototype.readFile = function (fileName) { - return this.host.readFile(fileName); - }; - LSHost.prototype.directoryExists = function (path) { - return this.host.directoryExists(path); - }; - LSHost.prototype.readDirectory = function (path, extensions, exclude, include) { - return this.host.readDirectory(path, extensions, exclude, include); - }; - LSHost.prototype.getDirectories = function (path) { - return this.host.getDirectories(path); - }; - LSHost.prototype.notifyFileRemoved = function (info) { - this.resolvedModuleNames.remove(info.path); - this.resolvedTypeReferenceDirectives.remove(info.path); - }; - LSHost.prototype.setCompilationSettings = function (opt) { - if (ts.changesAffectModuleResolution(this.compilationSettings, opt)) { - this.resolvedModuleNames.clear(); - this.resolvedTypeReferenceDirectives.clear(); - } - this.compilationSettings = opt; - }; - return LSHost; - }()); - server.LSHost = LSHost; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - server.nullTypingsInstaller = { - enqueueInstallTypingsRequest: ts.noop, - attach: ts.noop, - onProjectClosed: ts.noop, - globalTypingsCacheLocation: undefined - }; - var TypingsCacheEntry = (function () { - function TypingsCacheEntry() { - } - return TypingsCacheEntry; - }()); - function setIsEqualTo(arr1, arr2) { - if (arr1 === arr2) { - return true; - } - if ((arr1 || server.emptyArray).length === 0 && (arr2 || server.emptyArray).length === 0) { - return true; - } - var set = ts.createMap(); - var unique = 0; - for (var _i = 0, arr1_1 = arr1; _i < arr1_1.length; _i++) { - var v = arr1_1[_i]; - if (set[v] !== true) { - set[v] = true; - unique++; - } - } - for (var _a = 0, arr2_1 = arr2; _a < arr2_1.length; _a++) { - var v = arr2_1[_a]; - if (!ts.hasProperty(set, v)) { - return false; - } - if (set[v] === true) { - set[v] = false; - unique--; - } - } - return unique === 0; - } - function typeAcquisitionChanged(opt1, opt2) { - return opt1.enable !== opt2.enable || - !setIsEqualTo(opt1.include, opt2.include) || - !setIsEqualTo(opt1.exclude, opt2.exclude); - } - function compilerOptionsChanged(opt1, opt2) { - return opt1.allowJs != opt2.allowJs; - } - function unresolvedImportsChanged(imports1, imports2) { - if (imports1 === imports2) { - return false; - } - return !ts.arrayIsEqualTo(imports1, imports2); - } - var TypingsCache = (function () { - function TypingsCache(installer) { - this.installer = installer; - this.perProjectCache = ts.createMap(); - } - TypingsCache.prototype.getTypingsForProject = function (project, unresolvedImports, forceRefresh) { - var typeAcquisition = project.getTypeAcquisition(); - if (!typeAcquisition || !typeAcquisition.enable) { - return server.emptyArray; - } - var entry = this.perProjectCache[project.getProjectName()]; - var result = entry ? entry.typings : server.emptyArray; - if (forceRefresh || - !entry || - typeAcquisitionChanged(typeAcquisition, entry.typeAcquisition) || - compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions) || - unresolvedImportsChanged(unresolvedImports, entry.unresolvedImports)) { - this.perProjectCache[project.getProjectName()] = { - compilerOptions: project.getCompilerOptions(), - typeAcquisition: typeAcquisition, - typings: result, - unresolvedImports: unresolvedImports, - poisoned: true - }; - this.installer.enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports); - } - return result; - }; - TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typeAcquisition, unresolvedImports, newTypings) { - this.perProjectCache[projectName] = { - compilerOptions: compilerOptions, - typeAcquisition: typeAcquisition, - typings: server.toSortedReadonlyArray(newTypings), - unresolvedImports: unresolvedImports, - poisoned: false - }; - }; - TypingsCache.prototype.deleteTypingsForProject = function (projectName) { - delete this.perProjectCache[projectName]; - }; - TypingsCache.prototype.onProjectClosed = function (project) { - delete this.perProjectCache[project.getProjectName()]; - this.installer.onProjectClosed(project); - }; - return TypingsCache; - }()); - server.TypingsCache = TypingsCache; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - function shouldEmitFile(scriptInfo) { - return !scriptInfo.hasMixedContent; - } - server.shouldEmitFile = shouldEmitFile; - var BuilderFileInfo = (function () { - function BuilderFileInfo(scriptInfo, project) { - this.scriptInfo = scriptInfo; - this.project = project; - } - BuilderFileInfo.prototype.isExternalModuleOrHasOnlyAmbientExternalModules = function () { - var sourceFile = this.getSourceFile(); - return ts.isExternalModule(sourceFile) || this.containsOnlyAmbientModules(sourceFile); - }; - BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { - for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (statement.kind !== 230 || statement.name.kind !== 9) { - return false; - } - } - return true; - }; - BuilderFileInfo.prototype.computeHash = function (text) { - return this.project.projectService.host.createHash(text); - }; - BuilderFileInfo.prototype.getSourceFile = function () { - return this.project.getSourceFile(this.scriptInfo.path); - }; - BuilderFileInfo.prototype.updateShapeSignature = function () { - var sourceFile = this.getSourceFile(); - if (!sourceFile) { - return true; - } - var lastSignature = this.lastCheckedShapeSignature; - if (sourceFile.isDeclarationFile) { - this.lastCheckedShapeSignature = this.computeHash(sourceFile.text); - } - else { - var emitOutput = this.project.getFileEmitOutput(this.scriptInfo, true); - if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { - this.lastCheckedShapeSignature = this.computeHash(emitOutput.outputFiles[0].text); - } - } - return !lastSignature || this.lastCheckedShapeSignature !== lastSignature; - }; - return BuilderFileInfo; - }()); - server.BuilderFileInfo = BuilderFileInfo; - var AbstractBuilder = (function () { - function AbstractBuilder(project, ctor) { - this.project = project; - this.ctor = ctor; - } - AbstractBuilder.prototype.getFileInfos = function () { - return this.fileInfos_doNotAccessDirectly || (this.fileInfos_doNotAccessDirectly = ts.createFileMap()); - }; - AbstractBuilder.prototype.clear = function () { - this.fileInfos_doNotAccessDirectly = undefined; - }; - AbstractBuilder.prototype.getFileInfo = function (path) { - return this.getFileInfos().get(path); - }; - AbstractBuilder.prototype.getOrCreateFileInfo = function (path) { - var fileInfo = this.getFileInfo(path); - if (!fileInfo) { - var scriptInfo = this.project.getScriptInfo(path); - fileInfo = new this.ctor(scriptInfo, this.project); - this.setFileInfo(path, fileInfo); - } - return fileInfo; - }; - AbstractBuilder.prototype.getFileInfoPaths = function () { - return this.getFileInfos().getKeys(); - }; - AbstractBuilder.prototype.setFileInfo = function (path, info) { - this.getFileInfos().set(path, info); - }; - AbstractBuilder.prototype.removeFileInfo = function (path) { - this.getFileInfos().remove(path); - }; - AbstractBuilder.prototype.forEachFileInfo = function (action) { - this.getFileInfos().forEachValue(function (_path, value) { return action(value); }); - }; - AbstractBuilder.prototype.emitFile = function (scriptInfo, writeFile) { - var fileInfo = this.getFileInfo(scriptInfo.path); - if (!fileInfo) { - return false; - } - var _a = this.project.getFileEmitOutput(fileInfo.scriptInfo, false), emitSkipped = _a.emitSkipped, outputFiles = _a.outputFiles; - if (!emitSkipped) { - var projectRootPath = this.project.getProjectRootPath(); - for (var _i = 0, outputFiles_1 = outputFiles; _i < outputFiles_1.length; _i++) { - var outputFile = outputFiles_1[_i]; - var outputFileAbsoluteFileName = ts.getNormalizedAbsolutePath(outputFile.name, projectRootPath ? projectRootPath : ts.getDirectoryPath(scriptInfo.fileName)); - writeFile(outputFileAbsoluteFileName, outputFile.text, outputFile.writeByteOrderMark); - } - } - return !emitSkipped; - }; - return AbstractBuilder; - }()); - var NonModuleBuilder = (function (_super) { - __extends(NonModuleBuilder, _super); - function NonModuleBuilder(project) { - var _this = _super.call(this, project, BuilderFileInfo) || this; - _this.project = project; - return _this; - } - NonModuleBuilder.prototype.onProjectUpdateGraph = function () { - }; - NonModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { - var info = this.getOrCreateFileInfo(scriptInfo.path); - var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; - if (info.updateShapeSignature()) { - var options = this.project.getCompilerOptions(); - if (options && (options.out || options.outFile)) { - return singleFileResult; - } - return this.project.getAllEmittableFiles(); - } - return singleFileResult; - }; - return NonModuleBuilder; - }(AbstractBuilder)); - var ModuleBuilderFileInfo = (function (_super) { - __extends(ModuleBuilderFileInfo, _super); - function ModuleBuilderFileInfo() { - var _this = _super.apply(this, arguments) || this; - _this.references = []; - _this.referencedBy = []; - return _this; - } - ModuleBuilderFileInfo.compareFileInfos = function (lf, rf) { - var l = lf.scriptInfo.fileName; - var r = rf.scriptInfo.fileName; - return (l < r ? -1 : (l > r ? 1 : 0)); - }; - ; - ModuleBuilderFileInfo.addToReferenceList = function (array, fileInfo) { - if (array.length === 0) { - array.push(fileInfo); - return; - } - var insertIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); - if (insertIndex < 0) { - array.splice(~insertIndex, 0, fileInfo); - } - }; - ModuleBuilderFileInfo.removeFromReferenceList = function (array, fileInfo) { - if (!array || array.length === 0) { - return; - } - if (array[0] === fileInfo) { - array.splice(0, 1); - return; - } - var removeIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); - if (removeIndex >= 0) { - array.splice(removeIndex, 1); - } - }; - ModuleBuilderFileInfo.prototype.addReferencedBy = function (fileInfo) { - ModuleBuilderFileInfo.addToReferenceList(this.referencedBy, fileInfo); - }; - ModuleBuilderFileInfo.prototype.removeReferencedBy = function (fileInfo) { - ModuleBuilderFileInfo.removeFromReferenceList(this.referencedBy, fileInfo); - }; - ModuleBuilderFileInfo.prototype.removeFileReferences = function () { - for (var _i = 0, _a = this.references; _i < _a.length; _i++) { - var reference = _a[_i]; - reference.removeReferencedBy(this); - } - this.references = []; - }; - return ModuleBuilderFileInfo; - }(BuilderFileInfo)); - var ModuleBuilder = (function (_super) { - __extends(ModuleBuilder, _super); - function ModuleBuilder(project) { - var _this = _super.call(this, project, ModuleBuilderFileInfo) || this; - _this.project = project; - return _this; - } - ModuleBuilder.prototype.clear = function () { - this.projectVersionForDependencyGraph = undefined; - _super.prototype.clear.call(this); - }; - ModuleBuilder.prototype.getReferencedFileInfos = function (fileInfo) { - var _this = this; - if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { - return []; - } - var referencedFilePaths = this.project.getReferencedFiles(fileInfo.scriptInfo.path); - if (referencedFilePaths.length > 0) { - return ts.map(referencedFilePaths, function (f) { return _this.getOrCreateFileInfo(f); }).sort(ModuleBuilderFileInfo.compareFileInfos); - } - return []; - }; - ModuleBuilder.prototype.onProjectUpdateGraph = function () { - this.ensureProjectDependencyGraphUpToDate(); - }; - ModuleBuilder.prototype.ensureProjectDependencyGraphUpToDate = function () { - var _this = this; - if (!this.projectVersionForDependencyGraph || this.project.getProjectVersion() !== this.projectVersionForDependencyGraph) { - var currentScriptInfos = this.project.getScriptInfos(); - for (var _i = 0, currentScriptInfos_1 = currentScriptInfos; _i < currentScriptInfos_1.length; _i++) { - var scriptInfo = currentScriptInfos_1[_i]; - var fileInfo = this.getOrCreateFileInfo(scriptInfo.path); - this.updateFileReferences(fileInfo); - } - this.forEachFileInfo(function (fileInfo) { - if (!_this.project.containsScriptInfo(fileInfo.scriptInfo)) { - fileInfo.removeFileReferences(); - _this.removeFileInfo(fileInfo.scriptInfo.path); - } - }); - this.projectVersionForDependencyGraph = this.project.getProjectVersion(); - } - }; - ModuleBuilder.prototype.updateFileReferences = function (fileInfo) { - if (fileInfo.scriptVersionForReferences === fileInfo.scriptInfo.getLatestVersion()) { - return; - } - var newReferences = this.getReferencedFileInfos(fileInfo); - var oldReferences = fileInfo.references; - var oldIndex = 0; - var newIndex = 0; - while (oldIndex < oldReferences.length && newIndex < newReferences.length) { - var oldReference = oldReferences[oldIndex]; - var newReference = newReferences[newIndex]; - var compare = ModuleBuilderFileInfo.compareFileInfos(oldReference, newReference); - if (compare < 0) { - oldReference.removeReferencedBy(fileInfo); - oldIndex++; - } - else if (compare > 0) { - newReference.addReferencedBy(fileInfo); - newIndex++; - } - else { - oldIndex++; - newIndex++; - } - } - for (var i = oldIndex; i < oldReferences.length; i++) { - oldReferences[i].removeReferencedBy(fileInfo); - } - for (var i = newIndex; i < newReferences.length; i++) { - newReferences[i].addReferencedBy(fileInfo); - } - fileInfo.references = newReferences; - fileInfo.scriptVersionForReferences = fileInfo.scriptInfo.getLatestVersion(); - }; - ModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { - this.ensureProjectDependencyGraphUpToDate(); - var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; - var fileInfo = this.getFileInfo(scriptInfo.path); - if (!fileInfo || !fileInfo.updateShapeSignature()) { - return singleFileResult; - } - if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { - return this.project.getAllEmittableFiles(); - } - var options = this.project.getCompilerOptions(); - if (options && (options.isolatedModules || options.out || options.outFile)) { - return singleFileResult; - } - var queue = fileInfo.referencedBy.slice(0); - var fileNameSet = ts.createMap(); - fileNameSet[scriptInfo.fileName] = scriptInfo; - while (queue.length > 0) { - var processingFileInfo = queue.pop(); - if (processingFileInfo.updateShapeSignature() && processingFileInfo.referencedBy.length > 0) { - for (var _i = 0, _a = processingFileInfo.referencedBy; _i < _a.length; _i++) { - var potentialFileInfo = _a[_i]; - if (!fileNameSet[potentialFileInfo.scriptInfo.fileName]) { - queue.push(potentialFileInfo); - } - } - } - fileNameSet[processingFileInfo.scriptInfo.fileName] = processingFileInfo.scriptInfo; - } - var result = []; - for (var fileName in fileNameSet) { - if (shouldEmitFile(fileNameSet[fileName])) { - result.push(fileName); - } - } - return result; - }; - return ModuleBuilder; - }(AbstractBuilder)); - function createBuilder(project) { - var moduleKind = project.getCompilerOptions().module; - switch (moduleKind) { - case ts.ModuleKind.None: - return new NonModuleBuilder(project); - default: - return new ModuleBuilder(project); - } - } - server.createBuilder = createBuilder; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - var ProjectKind; - (function (ProjectKind) { - ProjectKind[ProjectKind["Inferred"] = 0] = "Inferred"; - ProjectKind[ProjectKind["Configured"] = 1] = "Configured"; - ProjectKind[ProjectKind["External"] = 2] = "External"; - })(ProjectKind = server.ProjectKind || (server.ProjectKind = {})); - function remove(items, item) { - var index = items.indexOf(item); - if (index >= 0) { - items.splice(index, 1); - } - } - function countEachFileTypes(infos) { - var result = { js: 0, jsx: 0, ts: 0, tsx: 0, dts: 0 }; - for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { - var info = infos_1[_i]; - switch (info.scriptKind) { - case 1: - result.js += 1; - break; - case 2: - result.jsx += 1; - break; - case 3: - ts.fileExtensionIs(info.fileName, ".d.ts") - ? result.dts += 1 - : result.ts += 1; - break; - case 4: - result.tsx += 1; - break; - } - } - return result; - } - function hasOneOrMoreJsAndNoTsFiles(project) { - var counts = countEachFileTypes(project.getScriptInfos()); - return counts.js > 0 && counts.ts === 0 && counts.tsx === 0; - } - function allRootFilesAreJsOrDts(project) { - var counts = countEachFileTypes(project.getRootScriptInfos()); - return counts.ts === 0 && counts.tsx === 0; - } - server.allRootFilesAreJsOrDts = allRootFilesAreJsOrDts; - function allFilesAreJsOrDts(project) { - var counts = countEachFileTypes(project.getScriptInfos()); - return counts.ts === 0 && counts.tsx === 0; - } - server.allFilesAreJsOrDts = allFilesAreJsOrDts; - var UnresolvedImportsMap = (function () { - function UnresolvedImportsMap() { - this.perFileMap = ts.createFileMap(); - this.version = 0; - } - UnresolvedImportsMap.prototype.clear = function () { - this.perFileMap.clear(); - this.version = 0; - }; - UnresolvedImportsMap.prototype.getVersion = function () { - return this.version; - }; - UnresolvedImportsMap.prototype.remove = function (path) { - this.perFileMap.remove(path); - this.version++; - }; - UnresolvedImportsMap.prototype.get = function (path) { - return this.perFileMap.get(path); - }; - UnresolvedImportsMap.prototype.set = function (path, value) { - this.perFileMap.set(path, value); - this.version++; - }; - return UnresolvedImportsMap; - }()); - server.UnresolvedImportsMap = UnresolvedImportsMap; - var Project = (function () { - function Project(projectName, projectKind, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { - this.projectName = projectName; - this.projectKind = projectKind; - this.projectService = projectService; - this.documentRegistry = documentRegistry; - this.compilerOptions = compilerOptions; - this.compileOnSaveEnabled = compileOnSaveEnabled; - this.rootFiles = []; - this.rootFilesMap = ts.createFileMap(); - this.cachedUnresolvedImportsPerFile = new UnresolvedImportsMap(); - this.languageServiceEnabled = true; - this.lastReportedVersion = 0; - this.projectStructureVersion = 0; - this.projectStateVersion = 0; - this.typesVersion = 0; - if (!this.compilerOptions) { - this.compilerOptions = ts.getDefaultCompilerOptions(); - this.compilerOptions.allowNonTsExtensions = true; - this.compilerOptions.allowJs = true; - } - else if (hasExplicitListOfFiles) { - this.compilerOptions.allowNonTsExtensions = true; - } - this.setInternalCompilerOptionsForEmittingJsFiles(); - this.lsHost = new server.LSHost(this.projectService.host, this, this.projectService.cancellationToken); - this.lsHost.setCompilationSettings(this.compilerOptions); - this.languageService = ts.createLanguageService(this.lsHost, this.documentRegistry); - if (!languageServiceEnabled) { - this.disableLanguageService(); - } - this.builder = server.createBuilder(this); - this.markAsDirty(); - } - Project.prototype.isNonTsProject = function () { - this.updateGraph(); - return allFilesAreJsOrDts(this); - }; - Project.prototype.isJsOnlyProject = function () { - this.updateGraph(); - return hasOneOrMoreJsAndNoTsFiles(this); - }; - Project.prototype.getCachedUnresolvedImportsPerFile_TestOnly = function () { - return this.cachedUnresolvedImportsPerFile; - }; - Project.prototype.setInternalCompilerOptionsForEmittingJsFiles = function () { - if (this.projectKind === ProjectKind.Inferred || this.projectKind === ProjectKind.External) { - this.compilerOptions.noEmitForJsFiles = true; - } - }; - Project.prototype.getProjectErrors = function () { - return this.projectErrors; - }; - Project.prototype.getLanguageService = function (ensureSynchronized) { - if (ensureSynchronized === void 0) { ensureSynchronized = true; } - if (ensureSynchronized) { - this.updateGraph(); - } - return this.languageService; - }; - Project.prototype.getCompileOnSaveAffectedFileList = function (scriptInfo) { - if (!this.languageServiceEnabled) { - return []; - } - this.updateGraph(); - return this.builder.getFilesAffectedBy(scriptInfo); - }; - Project.prototype.getProjectVersion = function () { - return this.projectStateVersion.toString(); - }; - Project.prototype.enableLanguageService = function () { - if (this.languageServiceEnabled) { - return; - } - this.languageServiceEnabled = true; - this.projectService.onUpdateLanguageServiceStateForProject(this, true); - }; - Project.prototype.disableLanguageService = function () { - if (!this.languageServiceEnabled) { - return; - } - this.languageService.cleanupSemanticCache(); - this.languageServiceEnabled = false; - this.projectService.onUpdateLanguageServiceStateForProject(this, false); - }; - Project.prototype.getProjectName = function () { - return this.projectName; - }; - Project.prototype.getSourceFile = function (path) { - if (!this.program) { - return undefined; - } - return this.program.getSourceFileByPath(path); - }; - Project.prototype.updateTypes = function () { - this.typesVersion++; - this.markAsDirty(); - this.updateGraph(); - }; - Project.prototype.close = function () { - if (this.program) { - for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { - var f = _a[_i]; - var info = this.projectService.getScriptInfo(f.fileName); - info.detachFromProject(this); - } - } - else { - for (var _b = 0, _c = this.rootFiles; _b < _c.length; _b++) { - var root = _c[_b]; - root.detachFromProject(this); - } - } - this.rootFiles = undefined; - this.rootFilesMap = undefined; - this.program = undefined; - this.languageService.dispose(); - }; - Project.prototype.getCompilerOptions = function () { - return this.compilerOptions; - }; - Project.prototype.hasRoots = function () { - return this.rootFiles && this.rootFiles.length > 0; - }; - Project.prototype.getRootFiles = function () { - return this.rootFiles && this.rootFiles.map(function (info) { return info.fileName; }); - }; - Project.prototype.getRootFilesLSHost = function () { - var result = []; - if (this.rootFiles) { - for (var _i = 0, _a = this.rootFiles; _i < _a.length; _i++) { - var f = _a[_i]; - if (this.languageServiceEnabled || f.isScriptOpen()) { - result.push(f.fileName); - } - } - if (this.typingFiles) { - for (var _b = 0, _c = this.typingFiles; _b < _c.length; _b++) { - var f = _c[_b]; - result.push(f); - } - } - } - return result; - }; - Project.prototype.getRootScriptInfos = function () { - return this.rootFiles; - }; - Project.prototype.getScriptInfos = function () { - var _this = this; - if (!this.languageServiceEnabled) { - return this.rootFiles; - } - return ts.map(this.program.getSourceFiles(), function (sourceFile) { - var scriptInfo = _this.projectService.getScriptInfoForPath(sourceFile.path); - if (!scriptInfo) { - ts.Debug.assert(false, "scriptInfo for a file '" + sourceFile.fileName + "' is missing."); - } - return scriptInfo; - }); - }; - Project.prototype.getFileEmitOutput = function (info, emitOnlyDtsFiles) { - if (!this.languageServiceEnabled) { - return undefined; - } - return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles); - }; - Project.prototype.getFileNames = function (excludeFilesFromExternalLibraries) { - if (!this.program) { - return []; - } - if (!this.languageServiceEnabled) { - var rootFiles = this.getRootFiles(); - if (this.compilerOptions) { - var defaultLibrary = ts.getDefaultLibFilePath(this.compilerOptions); - if (defaultLibrary) { - (rootFiles || (rootFiles = [])).push(server.asNormalizedPath(defaultLibrary)); - } - } - return rootFiles; - } - var result = []; - for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { - var f = _a[_i]; - if (excludeFilesFromExternalLibraries && this.program.isSourceFileFromExternalLibrary(f)) { - continue; - } - result.push(server.asNormalizedPath(f.fileName)); - } - return result; - }; - Project.prototype.getAllEmittableFiles = function () { - if (!this.languageServiceEnabled) { - return []; - } - var defaultLibraryFileName = ts.getDefaultLibFileName(this.compilerOptions); - var infos = this.getScriptInfos(); - var result = []; - for (var _i = 0, infos_2 = infos; _i < infos_2.length; _i++) { - var info = infos_2[_i]; - if (ts.getBaseFileName(info.fileName) !== defaultLibraryFileName && server.shouldEmitFile(info)) { - result.push(info.fileName); - } - } - return result; - }; - Project.prototype.containsScriptInfo = function (info) { - return this.isRoot(info) || (this.program && this.program.getSourceFileByPath(info.path) !== undefined); - }; - Project.prototype.containsFile = function (filename, requireOpen) { - var info = this.projectService.getScriptInfoForNormalizedPath(filename); - if (info && (info.isScriptOpen() || !requireOpen)) { - return this.containsScriptInfo(info); - } - }; - Project.prototype.isRoot = function (info) { - return this.rootFilesMap && this.rootFilesMap.contains(info.path); - }; - Project.prototype.addRoot = function (info) { - if (!this.isRoot(info)) { - this.rootFiles.push(info); - this.rootFilesMap.set(info.path, info); - info.attachToProject(this); - this.markAsDirty(); - } - }; - Project.prototype.removeFile = function (info, detachFromProject) { - if (detachFromProject === void 0) { detachFromProject = true; } - this.removeRootFileIfNecessary(info); - this.lsHost.notifyFileRemoved(info); - this.cachedUnresolvedImportsPerFile.remove(info.path); - if (detachFromProject) { - info.detachFromProject(this); - } - this.markAsDirty(); - }; - Project.prototype.registerFileUpdate = function (fileName) { - (this.updatedFileNames || (this.updatedFileNames = ts.createMap()))[fileName] = fileName; - }; - Project.prototype.markAsDirty = function () { - this.projectStateVersion++; - }; - Project.prototype.extractUnresolvedImportsFromSourceFile = function (file, result) { - var cached = this.cachedUnresolvedImportsPerFile.get(file.path); - if (cached) { - for (var _i = 0, cached_1 = cached; _i < cached_1.length; _i++) { - var f = cached_1[_i]; - result.push(f); - } - return; - } - var unresolvedImports; - if (file.resolvedModules) { - for (var name_51 in file.resolvedModules) { - if (!file.resolvedModules[name_51] && !ts.isExternalModuleNameRelative(name_51)) { - var trimmed = name_51.trim(); - var i = trimmed.indexOf("/"); - if (i !== -1 && trimmed.charCodeAt(0) === 64) { - i = trimmed.indexOf("/", i + 1); - } - if (i !== -1) { - trimmed = trimmed.substr(0, i); - } - (unresolvedImports || (unresolvedImports = [])).push(trimmed); - result.push(trimmed); - } - } - } - this.cachedUnresolvedImportsPerFile.set(file.path, unresolvedImports || server.emptyArray); - }; - Project.prototype.updateGraph = function () { - this.lsHost.startRecordingFilesWithChangedResolutions(); - var hasChanges = this.updateGraphWorker(); - var changedFiles = this.lsHost.finishRecordingFilesWithChangedResolutions() || server.emptyArray; - for (var _i = 0, changedFiles_1 = changedFiles; _i < changedFiles_1.length; _i++) { - var file = changedFiles_1[_i]; - this.cachedUnresolvedImportsPerFile.remove(file); - } - var unresolvedImports; - if (hasChanges || changedFiles.length) { - var result = []; - for (var _a = 0, _b = this.program.getSourceFiles(); _a < _b.length; _a++) { - var sourceFile = _b[_a]; - this.extractUnresolvedImportsFromSourceFile(sourceFile, result); - } - this.lastCachedUnresolvedImportsList = server.toSortedReadonlyArray(result); - } - unresolvedImports = this.lastCachedUnresolvedImportsList; - var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, unresolvedImports, hasChanges); - if (this.setTypings(cachedTypings)) { - hasChanges = this.updateGraphWorker() || hasChanges; - } - if (this.languageServiceEnabled) { - this.builder.onProjectUpdateGraph(); - } - else { - this.builder.clear(); - } - if (hasChanges) { - this.projectStructureVersion++; - } - return !hasChanges; - }; - Project.prototype.setTypings = function (typings) { - if (ts.arrayIsEqualTo(this.typingFiles, typings)) { - return false; - } - this.typingFiles = typings; - this.markAsDirty(); - return true; - }; - Project.prototype.updateGraphWorker = function () { - var oldProgram = this.program; - this.program = this.languageService.getProgram(); - var hasChanges = false; - if (!oldProgram || (this.program !== oldProgram && !oldProgram.structureIsReused)) { - hasChanges = true; - if (oldProgram) { - for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { - var f = _a[_i]; - if (this.program.getSourceFileByPath(f.path)) { - continue; - } - var scriptInfoToDetach = this.projectService.getScriptInfo(f.fileName); - if (scriptInfoToDetach) { - scriptInfoToDetach.detachFromProject(this); - } - } - } - } - return hasChanges; - }; - Project.prototype.getScriptInfoLSHost = function (fileName) { - var scriptInfo = this.projectService.getOrCreateScriptInfo(fileName, false); - if (scriptInfo) { - scriptInfo.attachToProject(this); - } - return scriptInfo; - }; - Project.prototype.getScriptInfoForNormalizedPath = function (fileName) { - var scriptInfo = this.projectService.getOrCreateScriptInfoForNormalizedPath(fileName, false); - if (scriptInfo && !scriptInfo.isAttached(this)) { - return server.Errors.ThrowProjectDoesNotContainDocument(fileName, this); - } - return scriptInfo; - }; - Project.prototype.getScriptInfo = function (uncheckedFileName) { - return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); - }; - Project.prototype.filesToString = function () { - if (!this.program) { + var LogLevel; + (function (LogLevel) { + LogLevel[LogLevel["terse"] = 0] = "terse"; + LogLevel[LogLevel["normal"] = 1] = "normal"; + LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; + LogLevel[LogLevel["verbose"] = 3] = "verbose"; + })(LogLevel = server.LogLevel || (server.LogLevel = {})); + server.emptyArray = []; + var Msg; + (function (Msg) { + Msg.Err = "Err"; + Msg.Info = "Info"; + Msg.Perf = "Perf"; + })(Msg = server.Msg || (server.Msg = {})); + function getProjectRootPath(project) { + switch (project.projectKind) { + case server.ProjectKind.Configured: + return ts.getDirectoryPath(project.getProjectName()); + case server.ProjectKind.Inferred: return ""; - } - var strBuilder = ""; - for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { - var file = _a[_i]; - strBuilder += file.fileName + "\n"; - } - return strBuilder; - }; - Project.prototype.setCompilerOptions = function (compilerOptions) { - if (compilerOptions) { - if (this.projectKind === ProjectKind.Inferred) { - compilerOptions.allowJs = true; - } - compilerOptions.allowNonTsExtensions = true; - if (ts.changesAffectModuleResolution(this.compilerOptions, compilerOptions)) { - this.cachedUnresolvedImportsPerFile.clear(); - this.lastCachedUnresolvedImportsList = undefined; - } - this.compilerOptions = compilerOptions; - this.setInternalCompilerOptionsForEmittingJsFiles(); - this.lsHost.setCompilationSettings(compilerOptions); - this.markAsDirty(); - } - }; - Project.prototype.reloadScript = function (filename, tempFileName) { - var script = this.projectService.getScriptInfoForNormalizedPath(filename); - if (script) { - ts.Debug.assert(script.isAttached(this)); - script.reloadFromFile(tempFileName); - return true; - } - return false; - }; - Project.prototype.getChangesSinceVersion = function (lastKnownVersion) { - this.updateGraph(); - var info = { - projectName: this.getProjectName(), - version: this.projectStructureVersion, - isInferred: this.projectKind === ProjectKind.Inferred, - options: this.getCompilerOptions(), - languageServiceDisabled: !this.languageServiceEnabled - }; - var updatedFileNames = this.updatedFileNames; - this.updatedFileNames = undefined; - if (this.lastReportedFileNames && lastKnownVersion === this.lastReportedVersion) { - if (this.projectStructureVersion == this.lastReportedVersion && !updatedFileNames) { - return { info: info, projectErrors: this.projectErrors }; - } - var lastReportedFileNames = this.lastReportedFileNames; - var currentFiles = ts.arrayToMap(this.getFileNames(), function (x) { return x; }); - var added = []; - var removed = []; - var updated = ts.getOwnKeys(updatedFileNames); - for (var id in currentFiles) { - if (!ts.hasProperty(lastReportedFileNames, id)) { - added.push(id); - } - } - for (var id in lastReportedFileNames) { - if (!ts.hasProperty(currentFiles, id)) { - removed.push(id); - } - } - this.lastReportedFileNames = currentFiles; - this.lastReportedVersion = this.projectStructureVersion; - return { info: info, changes: { added: added, removed: removed, updated: updated }, projectErrors: this.projectErrors }; - } - else { - var projectFileNames = this.getFileNames(); - this.lastReportedFileNames = ts.arrayToMap(projectFileNames, function (x) { return x; }); - this.lastReportedVersion = this.projectStructureVersion; - return { info: info, files: projectFileNames, projectErrors: this.projectErrors }; - } - }; - Project.prototype.getReferencedFiles = function (path) { - var _this = this; - if (!this.languageServiceEnabled) { - return []; - } - var sourceFile = this.getSourceFile(path); - if (!sourceFile) { - return []; - } - var referencedFiles = ts.createMap(); - if (sourceFile.imports && sourceFile.imports.length > 0) { - var checker = this.program.getTypeChecker(); - for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { - var importName = _a[_i]; - var symbol = checker.getSymbolAtLocation(importName); - if (symbol && symbol.declarations && symbol.declarations[0]) { - var declarationSourceFile = symbol.declarations[0].getSourceFile(); - if (declarationSourceFile) { - referencedFiles[declarationSourceFile.path] = true; - } - } - } - } - var currentDirectory = ts.getDirectoryPath(path); - var getCanonicalFileName = ts.createGetCanonicalFileName(this.projectService.host.useCaseSensitiveFileNames); - if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) { - for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) { - var referencedFile = _c[_b]; - var referencedPath = ts.toPath(referencedFile.fileName, currentDirectory, getCanonicalFileName); - referencedFiles[referencedPath] = true; - } - } - if (sourceFile.resolvedTypeReferenceDirectiveNames) { - for (var typeName in sourceFile.resolvedTypeReferenceDirectiveNames) { - var resolvedTypeReferenceDirective = sourceFile.resolvedTypeReferenceDirectiveNames[typeName]; - if (!resolvedTypeReferenceDirective) { - continue; - } - var fileName = resolvedTypeReferenceDirective.resolvedFileName; - var typeFilePath = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - referencedFiles[typeFilePath] = true; - } - } - var allFileNames = ts.map(Object.keys(referencedFiles), function (key) { return key; }); - return ts.filter(allFileNames, function (file) { return _this.projectService.host.fileExists(file); }); - }; - Project.prototype.removeRootFileIfNecessary = function (info) { - if (this.isRoot(info)) { - remove(this.rootFiles, info); - this.rootFilesMap.remove(info.path); - } - }; - return Project; - }()); - server.Project = Project; - var InferredProject = (function (_super) { - __extends(InferredProject, _super); - function InferredProject(projectService, documentRegistry, compilerOptions) { - var _this = _super.call(this, InferredProject.newName(), ProjectKind.Inferred, projectService, documentRegistry, undefined, true, compilerOptions, false) || this; - _this.directoriesWatchedForTsconfig = []; - return _this; + case server.ProjectKind.External: + var projectName = ts.normalizeSlashes(project.getProjectName()); + return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; } - InferredProject.prototype.getProjectRootPath = function () { - if (this.projectService.useSingleInferredProject) { - return undefined; - } - var rootFiles = this.getRootFiles(); - return ts.getDirectoryPath(rootFiles[0]); + } + function createInstallTypingsRequest(project, typeAcquisition, unresolvedImports, cachePath) { + return { + projectName: project.getProjectName(), + fileNames: project.getFileNames(true), + compilerOptions: project.getCompilerOptions(), + typeAcquisition: typeAcquisition, + unresolvedImports: unresolvedImports, + projectRootPath: getProjectRootPath(project), + cachePath: cachePath, + kind: "discover" }; - InferredProject.prototype.close = function () { - _super.prototype.close.call(this); - for (var _i = 0, _a = this.directoriesWatchedForTsconfig; _i < _a.length; _i++) { - var directory = _a[_i]; - this.projectService.stopWatchingDirectory(directory); - } - }; - InferredProject.prototype.getTypeAcquisition = function () { - return { - enable: allRootFilesAreJsOrDts(this), - include: [], - exclude: [] - }; - }; - return InferredProject; - }(Project)); - InferredProject.newName = (function () { - var nextId = 1; - return function () { - var id = nextId; - nextId++; - return server.makeInferredProjectName(id); - }; - })(); - server.InferredProject = InferredProject; - var ConfiguredProject = (function (_super) { - __extends(ConfiguredProject, _super); - function ConfiguredProject(configFileName, projectService, documentRegistry, hasExplicitListOfFiles, compilerOptions, wildcardDirectories, languageServiceEnabled, compileOnSaveEnabled) { - var _this = _super.call(this, configFileName, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; - _this.wildcardDirectories = wildcardDirectories; - _this.compileOnSaveEnabled = compileOnSaveEnabled; - _this.openRefCount = 0; - _this.canonicalConfigFilePath = server.asNormalizedPath(projectService.toCanonicalFileName(configFileName)); - return _this; + } + server.createInstallTypingsRequest = createInstallTypingsRequest; + var Errors; + (function (Errors) { + function ThrowNoProject() { + throw new Error("No Project."); } - ConfiguredProject.prototype.getConfigFilePath = function () { - return this.getProjectName(); - }; - ConfiguredProject.prototype.getProjectRootPath = function () { - return ts.getDirectoryPath(this.getConfigFilePath()); - }; - ConfiguredProject.prototype.setProjectErrors = function (projectErrors) { - this.projectErrors = projectErrors; - }; - ConfiguredProject.prototype.setTypeAcquisition = function (newTypeAcquisition) { - this.typeAcquisition = newTypeAcquisition; - }; - ConfiguredProject.prototype.getTypeAcquisition = function () { - return this.typeAcquisition; - }; - ConfiguredProject.prototype.watchConfigFile = function (callback) { - var _this = this; - this.projectFileWatcher = this.projectService.host.watchFile(this.getConfigFilePath(), function (_) { return callback(_this); }); - }; - ConfiguredProject.prototype.watchTypeRoots = function (callback) { - var _this = this; - var roots = this.getEffectiveTypeRoots(); - var watchers = []; - for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { - var root = roots_1[_i]; - this.projectService.logger.info("Add type root watcher for: " + root); - watchers.push(this.projectService.host.watchDirectory(root, function (path) { return callback(_this, path); }, false)); - } - this.typeRootsWatchers = watchers; - }; - ConfiguredProject.prototype.watchConfigDirectory = function (callback) { - var _this = this; - if (this.directoryWatcher) { - return; - } - var directoryToWatch = ts.getDirectoryPath(this.getConfigFilePath()); - this.projectService.logger.info("Add recursive watcher for: " + directoryToWatch); - this.directoryWatcher = this.projectService.host.watchDirectory(directoryToWatch, function (path) { return callback(_this, path); }, true); - }; - ConfiguredProject.prototype.watchWildcards = function (callback) { - var _this = this; - if (!this.wildcardDirectories) { - return; - } - var configDirectoryPath = ts.getDirectoryPath(this.getConfigFilePath()); - this.directoriesWatchedForWildcards = ts.reduceProperties(this.wildcardDirectories, function (watchers, flag, directory) { - if (ts.comparePaths(configDirectoryPath, directory, ".", !_this.projectService.host.useCaseSensitiveFileNames) !== 0) { - var recursive = (flag & 1) !== 0; - _this.projectService.logger.info("Add " + (recursive ? "recursive " : "") + "watcher for: " + directory); - watchers[directory] = _this.projectService.host.watchDirectory(directory, function (path) { return callback(_this, path); }, recursive); - } - return watchers; - }, {}); - }; - ConfiguredProject.prototype.stopWatchingDirectory = function () { - if (this.directoryWatcher) { - this.directoryWatcher.close(); - this.directoryWatcher = undefined; - } - }; - ConfiguredProject.prototype.close = function () { - _super.prototype.close.call(this); - if (this.projectFileWatcher) { - this.projectFileWatcher.close(); - } - if (this.typeRootsWatchers) { - for (var _i = 0, _a = this.typeRootsWatchers; _i < _a.length; _i++) { - var watcher = _a[_i]; - watcher.close(); - } - this.typeRootsWatchers = undefined; - } - for (var id in this.directoriesWatchedForWildcards) { - this.directoriesWatchedForWildcards[id].close(); - } - this.directoriesWatchedForWildcards = undefined; - this.stopWatchingDirectory(); - }; - ConfiguredProject.prototype.addOpenRef = function () { - this.openRefCount++; - }; - ConfiguredProject.prototype.deleteOpenRef = function () { - this.openRefCount--; - return this.openRefCount; - }; - ConfiguredProject.prototype.getEffectiveTypeRoots = function () { - return ts.getEffectiveTypeRoots(this.getCompilerOptions(), this.projectService.host) || []; - }; - return ConfiguredProject; - }(Project)); - server.ConfiguredProject = ConfiguredProject; - var ExternalProject = (function (_super) { - __extends(ExternalProject, _super); - function ExternalProject(externalProjectName, projectService, documentRegistry, compilerOptions, languageServiceEnabled, compileOnSaveEnabled, projectFilePath) { - var _this = _super.call(this, externalProjectName, ProjectKind.External, projectService, documentRegistry, true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; - _this.compileOnSaveEnabled = compileOnSaveEnabled; - _this.projectFilePath = projectFilePath; - return _this; + Errors.ThrowNoProject = ThrowNoProject; + function ThrowProjectLanguageServiceDisabled() { + throw new Error("The project's language service is disabled."); } - ExternalProject.prototype.getProjectRootPath = function () { - if (this.projectFilePath) { - return ts.getDirectoryPath(this.projectFilePath); + Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; + function ThrowProjectDoesNotContainDocument(fileName, project) { + throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); + } + Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; + })(Errors = server.Errors || (server.Errors = {})); + function getDefaultFormatCodeSettings(host) { + return { + indentSize: 4, + tabSize: 4, + newLineCharacter: host.newLine || "\n", + convertTabsToSpaces: true, + indentStyle: ts.IndentStyle.Smart, + insertSpaceAfterConstructor: false, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + insertSpaceBeforeFunctionParenthesis: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false, + }; + } + server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; + function mergeMapLikes(target, source) { + for (var key in source) { + if (ts.hasProperty(source, key)) { + target[key] = source[key]; } - return ts.getDirectoryPath(ts.normalizeSlashes(this.getProjectName())); - }; - ExternalProject.prototype.getTypeAcquisition = function () { - return this.typeAcquisition; - }; - ExternalProject.prototype.setProjectErrors = function (projectErrors) { - this.projectErrors = projectErrors; - }; - ExternalProject.prototype.setTypeAcquisition = function (newTypeAcquisition) { - if (!newTypeAcquisition) { - newTypeAcquisition = { - enable: allRootFilesAreJsOrDts(this), - include: [], - exclude: [] - }; - } - else { - if (newTypeAcquisition.enable === undefined) { - newTypeAcquisition.enable = allRootFilesAreJsOrDts(this); - } - if (!newTypeAcquisition.include) { - newTypeAcquisition.include = []; - } - if (!newTypeAcquisition.exclude) { - newTypeAcquisition.exclude = []; - } - } - this.typeAcquisition = newTypeAcquisition; - }; - return ExternalProject; - }(Project)); - server.ExternalProject = ExternalProject; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; - server.ContextEvent = "context"; - server.ConfigFileDiagEvent = "configFileDiag"; - server.ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; - function prepareConvertersForEnumLikeCompilerOptions(commandLineOptions) { + } + } + server.mergeMapLikes = mergeMapLikes; + function removeItemFromSet(items, itemToRemove) { + if (items.length === 0) { + return; + } + var index = items.indexOf(itemToRemove); + if (index < 0) { + return; + } + if (index === items.length - 1) { + items.pop(); + } + else { + items[index] = items.pop(); + } + } + server.removeItemFromSet = removeItemFromSet; + function toNormalizedPath(fileName) { + return ts.normalizePath(fileName); + } + server.toNormalizedPath = toNormalizedPath; + function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { + var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); + return getCanonicalFileName(f); + } + server.normalizedPathToPath = normalizedPathToPath; + function asNormalizedPath(fileName) { + return fileName; + } + server.asNormalizedPath = asNormalizedPath; + function createNormalizedPathMap() { var map = ts.createMap(); - for (var _i = 0, commandLineOptions_1 = commandLineOptions; _i < commandLineOptions_1.length; _i++) { - var option = commandLineOptions_1[_i]; - if (typeof option.type === "object") { - var optionMap = option.type; - for (var id in optionMap) { - ts.Debug.assert(typeof optionMap[id] === "number"); - } - map[option.name] = optionMap; - } - } - return map; - } - var compilerOptionConverters = prepareConvertersForEnumLikeCompilerOptions(ts.optionDeclarations); - var indentStyle = ts.createMap({ - "none": ts.IndentStyle.None, - "block": ts.IndentStyle.Block, - "smart": ts.IndentStyle.Smart - }); - function convertFormatOptions(protocolOptions) { - if (typeof protocolOptions.indentStyle === "string") { - protocolOptions.indentStyle = indentStyle[protocolOptions.indentStyle.toLowerCase()]; - ts.Debug.assert(protocolOptions.indentStyle !== undefined); - } - return protocolOptions; - } - server.convertFormatOptions = convertFormatOptions; - function convertCompilerOptions(protocolOptions) { - for (var id in compilerOptionConverters) { - var propertyValue = protocolOptions[id]; - if (typeof propertyValue === "string") { - var mappedValues = compilerOptionConverters[id]; - protocolOptions[id] = mappedValues[propertyValue.toLowerCase()]; - } - } - return protocolOptions; - } - server.convertCompilerOptions = convertCompilerOptions; - function tryConvertScriptKindName(scriptKindName) { - return typeof scriptKindName === "string" - ? convertScriptKindName(scriptKindName) - : scriptKindName; - } - server.tryConvertScriptKindName = tryConvertScriptKindName; - function convertScriptKindName(scriptKindName) { - switch (scriptKindName) { - case "JS": - return 1; - case "JSX": - return 2; - case "TS": - return 3; - case "TSX": - return 4; - default: - return 0; - } - } - server.convertScriptKindName = convertScriptKindName; - function combineProjectOutput(projects, action, comparer, areEqual) { - var result = projects.reduce(function (previous, current) { return ts.concatenate(previous, action(current)); }, []).sort(comparer); - return projects.length > 1 ? ts.deduplicate(result, areEqual) : result; - } - server.combineProjectOutput = combineProjectOutput; - var fileNamePropertyReader = { - getFileName: function (x) { return x; }, - getScriptKind: function (_) { return undefined; }, - hasMixedContent: function (fileName, extraFileExtensions) { - var mixedContentExtensions = ts.map(ts.filter(extraFileExtensions, function (item) { return item.isMixedContent; }), function (item) { return item.extension; }); - return ts.forEach(mixedContentExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); }); - } - }; - var externalFilePropertyReader = { - getFileName: function (x) { return x.fileName; }, - getScriptKind: function (x) { return tryConvertScriptKindName(x.scriptKind); }, - hasMixedContent: function (x) { return x.hasMixedContent; } - }; - function findProjectByName(projectName, projects) { - for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) { - var proj = projects_1[_i]; - if (proj.getProjectName() === projectName) { - return proj; - } - } - } - function createFileNotFoundDiagnostic(fileName) { - return ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName); - } - function isRootFileInInferredProject(info) { - if (info.containingProjects.length === 0) { - return false; - } - return info.containingProjects[0].projectKind === server.ProjectKind.Inferred && info.containingProjects[0].isRoot(info); - } - var DirectoryWatchers = (function () { - function DirectoryWatchers(projectService) { - this.projectService = projectService; - this.directoryWatchersForTsconfig = ts.createMap(); - this.directoryWatchersRefCount = ts.createMap(); - } - DirectoryWatchers.prototype.stopWatchingDirectory = function (directory) { - this.directoryWatchersRefCount[directory]--; - if (this.directoryWatchersRefCount[directory] === 0) { - this.projectService.logger.info("Close directory watcher for: " + directory); - this.directoryWatchersForTsconfig[directory].close(); - delete this.directoryWatchersForTsconfig[directory]; + return { + get: function (path) { + return map.get(path); + }, + set: function (path, value) { + map.set(path, value); + }, + contains: function (path) { + return map.has(path); + }, + remove: function (path) { + map.delete(path); } }; - DirectoryWatchers.prototype.startWatchingContainingDirectoriesForFile = function (fileName, project, callback) { - var currentPath = ts.getDirectoryPath(fileName); - var parentPath = ts.getDirectoryPath(currentPath); - while (currentPath != parentPath) { - if (!this.directoryWatchersForTsconfig[currentPath]) { - this.projectService.logger.info("Add watcher for: " + currentPath); - this.directoryWatchersForTsconfig[currentPath] = this.projectService.host.watchDirectory(currentPath, callback); - this.directoryWatchersRefCount[currentPath] = 1; - } - else { - this.directoryWatchersRefCount[currentPath] += 1; - } - project.directoriesWatchedForTsconfig.push(currentPath); - currentPath = parentPath; - parentPath = ts.getDirectoryPath(parentPath); - } - }; - return DirectoryWatchers; - }()); - var ProjectService = (function () { - function ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, eventHandler) { - if (typingsInstaller === void 0) { typingsInstaller = server.nullTypingsInstaller; } + } + server.createNormalizedPathMap = createNormalizedPathMap; + function isInferredProjectName(name) { + return /dev\/null\/inferredProject\d+\*/.test(name); + } + server.isInferredProjectName = isInferredProjectName; + function makeInferredProjectName(counter) { + return "/dev/null/inferredProject" + counter + "*"; + } + server.makeInferredProjectName = makeInferredProjectName; + function toSortedReadonlyArray(arr) { + arr.sort(); + return arr; + } + server.toSortedReadonlyArray = toSortedReadonlyArray; + var ThrottledOperations = (function () { + function ThrottledOperations(host) { this.host = host; - this.logger = logger; - this.cancellationToken = cancellationToken; - this.useSingleInferredProject = useSingleInferredProject; - this.typingsInstaller = typingsInstaller; - this.eventHandler = eventHandler; - this.filenameToScriptInfo = ts.createFileMap(); - this.externalProjectToConfiguredProjectMap = ts.createMap(); - this.externalProjects = []; - this.inferredProjects = []; - this.configuredProjects = []; - this.openFiles = []; - ts.Debug.assert(!!host.createHash, "'ServerHost.createHash' is required for ProjectService"); - this.toCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - this.directoryWatchers = new DirectoryWatchers(this); - this.throttledOperations = new server.ThrottledOperations(host); - this.typingsInstaller.attach(this); - this.typingsCache = new server.TypingsCache(this.typingsInstaller); - this.hostConfiguration = { - formatCodeOptions: server.getDefaultFormatCodeSettings(this.host), - hostInfo: "Unknown host", - extraFileExtensions: [] - }; - this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory()); + this.pendingTimeouts = ts.createMap(); } - ProjectService.prototype.getChangedFiles_TestOnly = function () { - return this.changedFiles; + ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { + var pendingTimeout = this.pendingTimeouts.get(operationId); + if (pendingTimeout) { + this.host.clearTimeout(pendingTimeout); + } + this.pendingTimeouts.set(operationId, this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb)); }; - ProjectService.prototype.ensureInferredProjectsUpToDate_TestOnly = function () { - this.ensureInferredProjectsUpToDate(); + ThrottledOperations.run = function (self, operationId, cb) { + self.pendingTimeouts.delete(operationId); + cb(); }; - ProjectService.prototype.getCompilerOptionsForInferredProjects = function () { - return this.compilerOptionsForInferredProjects; - }; - ProjectService.prototype.onUpdateLanguageServiceStateForProject = function (project, languageServiceEnabled) { - if (!this.eventHandler) { - return; - } - this.eventHandler({ - eventName: server.ProjectLanguageServiceStateEvent, - data: { project: project, languageServiceEnabled: languageServiceEnabled } - }); - }; - ProjectService.prototype.updateTypingsForProject = function (response) { - var project = this.findProject(response.projectName); - if (!project) { - return; - } - switch (response.kind) { - case server.ActionSet: - this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typeAcquisition, response.unresolvedImports, response.typings); - break; - case server.ActionInvalidate: - this.typingsCache.deleteTypingsForProject(response.projectName); - break; - } - project.updateGraph(); - }; - ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions) { - this.compilerOptionsForInferredProjects = convertCompilerOptions(projectCompilerOptions); - this.compilerOptionsForInferredProjects.allowNonTsExtensions = true; - this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave; - for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { - var proj = _a[_i]; - proj.setCompilerOptions(this.compilerOptionsForInferredProjects); - proj.compileOnSaveEnabled = projectCompilerOptions.compileOnSave; - } - this.updateProjectGraphs(this.inferredProjects); - }; - ProjectService.prototype.stopWatchingDirectory = function (directory) { - this.directoryWatchers.stopWatchingDirectory(directory); - }; - ProjectService.prototype.findProject = function (projectName) { - if (projectName === undefined) { - return undefined; - } - if (server.isInferredProjectName(projectName)) { - this.ensureInferredProjectsUpToDate(); - return findProjectByName(projectName, this.inferredProjects); - } - return this.findExternalProjectByProjectName(projectName) || this.findConfiguredProjectByProjectName(server.toNormalizedPath(projectName)); - }; - ProjectService.prototype.getDefaultProjectForFile = function (fileName, refreshInferredProjects) { - if (refreshInferredProjects) { - this.ensureInferredProjectsUpToDate(); - } - var scriptInfo = this.getScriptInfoForNormalizedPath(fileName); - return scriptInfo && scriptInfo.getDefaultProject(); - }; - ProjectService.prototype.ensureInferredProjectsUpToDate = function () { - if (this.changedFiles) { - var projectsToUpdate = void 0; - if (this.changedFiles.length === 1) { - projectsToUpdate = this.changedFiles[0].containingProjects; - } - else { - projectsToUpdate = []; - for (var _i = 0, _a = this.changedFiles; _i < _a.length; _i++) { - var f = _a[_i]; - projectsToUpdate = projectsToUpdate.concat(f.containingProjects); - } - } - this.updateProjectGraphs(projectsToUpdate); - this.changedFiles = undefined; - } - }; - ProjectService.prototype.findContainingExternalProject = function (fileName) { - for (var _i = 0, _a = this.externalProjects; _i < _a.length; _i++) { - var proj = _a[_i]; - if (proj.containsFile(fileName)) { - return proj; - } - } - return undefined; - }; - ProjectService.prototype.getFormatCodeOptions = function (file) { - var formatCodeSettings; - if (file) { - var info = this.getScriptInfoForNormalizedPath(file); - if (info) { - formatCodeSettings = info.getFormatCodeSettings(); - } - } - return formatCodeSettings || this.hostConfiguration.formatCodeOptions; - }; - ProjectService.prototype.updateProjectGraphs = function (projects) { - var shouldRefreshInferredProjects = false; - for (var _i = 0, projects_2 = projects; _i < projects_2.length; _i++) { - var p = projects_2[_i]; - if (!p.updateGraph()) { - shouldRefreshInferredProjects = true; - } - } - if (shouldRefreshInferredProjects) { - this.refreshInferredProjects(); - } - }; - ProjectService.prototype.onSourceFileChanged = function (fileName) { - var info = this.getScriptInfoForNormalizedPath(fileName); - if (!info) { - this.logger.info("Error: got watch notification for unknown file: " + fileName); - return; - } - if (!this.host.fileExists(fileName)) { - this.handleDeletedFile(info); - } - else { - if (info && (!info.isScriptOpen())) { - info.reloadFromFile(); - this.updateProjectGraphs(info.containingProjects); - } - } - }; - ProjectService.prototype.handleDeletedFile = function (info) { - this.logger.info(info.fileName + " deleted"); - info.stopWatcher(); - if (!info.isScriptOpen()) { - this.filenameToScriptInfo.remove(info.path); - this.lastDeletedFile = info; - var containingProjects = info.containingProjects.slice(); - info.detachAllProjects(); - this.updateProjectGraphs(containingProjects); - this.lastDeletedFile = undefined; - if (!this.eventHandler) { - return; - } - for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { - var openFile = _a[_i]; - this.eventHandler({ - eventName: server.ContextEvent, - data: { project: openFile.getDefaultProject(), fileName: openFile.fileName } - }); - } - } - this.printProjects(); - }; - ProjectService.prototype.onTypeRootFileChanged = function (project, fileName) { - var _this = this; - this.logger.info("Type root file " + fileName + " changed"); - this.throttledOperations.schedule(project.getConfigFilePath() + " * type root", 250, function () { - project.updateTypes(); - _this.updateConfiguredProject(project); - _this.refreshInferredProjects(); - }); - }; - ProjectService.prototype.onSourceFileInDirectoryChangedForConfiguredProject = function (project, fileName) { - var _this = this; - if (fileName && !ts.isSupportedSourceFileName(fileName, project.getCompilerOptions(), this.hostConfiguration.extraFileExtensions)) { - return; - } - this.logger.info("Detected source file changes: " + fileName); - this.throttledOperations.schedule(project.getConfigFilePath(), 250, function () { return _this.handleChangeInSourceFileForConfiguredProject(project, fileName); }); - }; - ProjectService.prototype.handleChangeInSourceFileForConfiguredProject = function (project, triggerFile) { - var _this = this; - var _a = this.convertConfigFileContentToProjectOptions(project.getConfigFilePath()), projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; - this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors, triggerFile); - var newRootFiles = projectOptions.files.map((function (f) { return _this.getCanonicalFileName(f); })); - var currentRootFiles = project.getRootFiles().map((function (f) { return _this.getCanonicalFileName(f); })); - if (!ts.arrayIsEqualTo(currentRootFiles.sort(), newRootFiles.sort())) { - this.logger.info("Updating configured project"); - this.updateConfiguredProject(project); - this.refreshInferredProjects(); - } - }; - ProjectService.prototype.onConfigChangedForConfiguredProject = function (project) { - var configFileName = project.getConfigFilePath(); - this.logger.info("Config file changed: " + configFileName); - var configFileErrors = this.updateConfiguredProject(project); - this.reportConfigFileDiagnostics(configFileName, configFileErrors, configFileName); - this.refreshInferredProjects(); - }; - ProjectService.prototype.onConfigFileAddedForInferredProject = function (fileName) { - if (ts.getBaseFileName(fileName) != "tsconfig.json") { - this.logger.info(fileName + " is not tsconfig.json"); - return; - } - var configFileErrors = this.convertConfigFileContentToProjectOptions(fileName).configFileErrors; - this.reportConfigFileDiagnostics(fileName, configFileErrors, fileName); - this.logger.info("Detected newly added tsconfig file: " + fileName); - this.reloadProjects(); - }; - ProjectService.prototype.getCanonicalFileName = function (fileName) { - var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - return ts.normalizePath(name); - }; - ProjectService.prototype.removeProject = function (project) { - this.logger.info("remove project: " + project.getRootFiles().toString()); - project.close(); - switch (project.projectKind) { - case server.ProjectKind.External: - server.removeItemFromSet(this.externalProjects, project); - break; - case server.ProjectKind.Configured: - server.removeItemFromSet(this.configuredProjects, project); - break; - case server.ProjectKind.Inferred: - server.removeItemFromSet(this.inferredProjects, project); - break; - } - }; - ProjectService.prototype.assignScriptInfoToInferredProjectIfNecessary = function (info, addToListOfOpenFiles) { - var externalProject = this.findContainingExternalProject(info.fileName); - if (externalProject) { - if (addToListOfOpenFiles) { - this.openFiles.push(info); - } - return; - } - var foundConfiguredProject = false; - for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { - var p = _a[_i]; - if (p.projectKind === server.ProjectKind.Configured) { - foundConfiguredProject = true; - if (addToListOfOpenFiles) { - (p).addOpenRef(); - } - } - } - if (foundConfiguredProject) { - if (addToListOfOpenFiles) { - this.openFiles.push(info); - } - return; - } - if (info.containingProjects.length === 0) { - var inferredProject = this.createInferredProjectWithRootFileIfNecessary(info); - if (!this.useSingleInferredProject) { - for (var _b = 0, _c = this.openFiles; _b < _c.length; _b++) { - var f = _c[_b]; - if (f.containingProjects.length === 0) { - continue; - } - var defaultProject = f.getDefaultProject(); - if (isRootFileInInferredProject(info) && defaultProject !== inferredProject && inferredProject.containsScriptInfo(f)) { - this.removeProject(defaultProject); - f.attachToProject(inferredProject); - } - } - } - } - if (addToListOfOpenFiles) { - this.openFiles.push(info); - } - }; - ProjectService.prototype.closeOpenFile = function (info) { - info.close(); - server.removeItemFromSet(this.openFiles, info); - var projectsToRemove; - for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { - var p = _a[_i]; - if (p.projectKind === server.ProjectKind.Configured) { - if (info.hasMixedContent) { - info.registerFileUpdate(); - } - if (p.deleteOpenRef() === 0) { - (projectsToRemove || (projectsToRemove = [])).push(p); - } - } - else if (p.projectKind === server.ProjectKind.Inferred && p.isRoot(info)) { - (projectsToRemove || (projectsToRemove = [])).push(p); - } - if (!p.languageServiceEnabled) { - p.markAsDirty(); - } - } - if (projectsToRemove) { - for (var _b = 0, projectsToRemove_1 = projectsToRemove; _b < projectsToRemove_1.length; _b++) { - var project = projectsToRemove_1[_b]; - this.removeProject(project); - } - var orphanFiles = void 0; - for (var _c = 0, _d = this.openFiles; _c < _d.length; _c++) { - var f = _d[_c]; - if (f.containingProjects.length === 0) { - (orphanFiles || (orphanFiles = [])).push(f); - } - } - if (orphanFiles) { - for (var _e = 0, orphanFiles_1 = orphanFiles; _e < orphanFiles_1.length; _e++) { - var f = orphanFiles_1[_e]; - this.assignScriptInfoToInferredProjectIfNecessary(f, false); - } - } - } - if (info.containingProjects.length === 0) { - this.filenameToScriptInfo.remove(info.path); - } - }; - ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { - var searchPath = ts.getDirectoryPath(fileName); - this.logger.info("Search path: " + searchPath); - var configFileName = this.findConfigFile(server.asNormalizedPath(searchPath)); - if (!configFileName) { - this.logger.info("No config files found."); - return {}; - } - this.logger.info("Config file name: " + configFileName); - var project = this.findConfiguredProjectByProjectName(configFileName); - if (!project) { - var _a = this.openConfigFile(configFileName, fileName), success = _a.success, errors = _a.errors; - if (!success) { - return { configFileName: configFileName, configFileErrors: errors }; - } - this.logger.info("Opened configuration file " + configFileName); - if (errors && errors.length > 0) { - return { configFileName: configFileName, configFileErrors: errors }; - } - } - else { - this.updateConfiguredProject(project); - } - return { configFileName: configFileName }; - }; - ProjectService.prototype.findConfigFile = function (searchPath) { - while (true) { - var tsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "tsconfig.json")); - if (this.host.fileExists(tsconfigFileName)) { - return tsconfigFileName; - } - var jsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "jsconfig.json")); - if (this.host.fileExists(jsconfigFileName)) { - return jsconfigFileName; - } - var parentPath = server.asNormalizedPath(ts.getDirectoryPath(searchPath)); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - return undefined; - }; - ProjectService.prototype.printProjects = function () { - if (!this.logger.hasLevel(server.LogLevel.verbose)) { - return; - } - this.logger.startGroup(); - var counter = 0; - counter = printProjects(this.logger, this.externalProjects, counter); - counter = printProjects(this.logger, this.configuredProjects, counter); - counter = printProjects(this.logger, this.inferredProjects, counter); - this.logger.info("Open files: "); - for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { - var rootFile = _a[_i]; - this.logger.info(rootFile.fileName); - } - this.logger.endGroup(); - function printProjects(logger, projects, counter) { - for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { - var project = projects_3[_i]; - project.updateGraph(); - logger.info("Project '" + project.getProjectName() + "' (" + server.ProjectKind[project.projectKind] + ") " + counter); - logger.info(project.filesToString()); - logger.info("-----------------------------------------------"); - counter++; - } - return counter; - } - }; - ProjectService.prototype.findConfiguredProjectByProjectName = function (configFileName) { - configFileName = server.asNormalizedPath(this.toCanonicalFileName(configFileName)); - for (var _i = 0, _a = this.configuredProjects; _i < _a.length; _i++) { - var proj = _a[_i]; - if (proj.canonicalConfigFilePath === configFileName) { - return proj; - } - } - }; - ProjectService.prototype.findExternalProjectByProjectName = function (projectFileName) { - return findProjectByName(projectFileName, this.externalProjects); - }; - ProjectService.prototype.convertConfigFileContentToProjectOptions = function (configFilename) { - configFilename = ts.normalizePath(configFilename); - var configFileContent = this.host.readFile(configFilename); - var errors; - var result = ts.parseConfigFileTextToJson(configFilename, configFileContent); - var config = result.config; - if (result.error) { - var _a = ts.sanitizeConfigFile(configFilename, configFileContent), sanitizedConfig = _a.configJsonObject, diagnostics = _a.diagnostics; - config = sanitizedConfig; - errors = diagnostics.length ? diagnostics : [result.error]; - } - var parsedCommandLine = ts.parseJsonConfigFileContent(config, this.host, ts.getDirectoryPath(configFilename), {}, configFilename, [], this.hostConfiguration.extraFileExtensions); - if (parsedCommandLine.errors.length) { - errors = ts.concatenate(errors, parsedCommandLine.errors); - } - ts.Debug.assert(!!parsedCommandLine.fileNames); - if (parsedCommandLine.fileNames.length === 0) { - (errors || (errors = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename)); - return { success: false, configFileErrors: errors }; - } - var projectOptions = { - files: parsedCommandLine.fileNames, - compilerOptions: parsedCommandLine.options, - configHasFilesProperty: config["files"] !== undefined, - wildcardDirectories: ts.createMap(parsedCommandLine.wildcardDirectories), - typeAcquisition: parsedCommandLine.typeAcquisition, - compileOnSave: parsedCommandLine.compileOnSave - }; - return { success: true, projectOptions: projectOptions, configFileErrors: errors }; - }; - ProjectService.prototype.exceededTotalSizeLimitForNonTsFiles = function (options, fileNames, propertyReader) { - if (options && options.disableSizeLimit || !this.host.getFileSize) { - return false; - } - var totalNonTsFileSize = 0; - for (var _i = 0, fileNames_3 = fileNames; _i < fileNames_3.length; _i++) { - var f = fileNames_3[_i]; - var fileName = propertyReader.getFileName(f); - if (ts.hasTypeScriptFileExtension(fileName)) { - continue; - } - totalNonTsFileSize += this.host.getFileSize(fileName); - if (totalNonTsFileSize > server.maxProgramSizeForNonTsFiles) { - return true; - } - } - return false; - }; - ProjectService.prototype.createAndAddExternalProject = function (projectFileName, files, options, typeAcquisition) { - var compilerOptions = convertCompilerOptions(options); - var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, compilerOptions, !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); - this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, undefined, typeAcquisition, undefined); - this.externalProjects.push(project); - return project; - }; - ProjectService.prototype.reportConfigFileDiagnostics = function (configFileName, diagnostics, triggerFile) { - if (!this.eventHandler) { - return; - } - this.eventHandler({ - eventName: server.ConfigFileDiagEvent, - data: { configFileName: configFileName, diagnostics: diagnostics || [], triggerFile: triggerFile } - }); - }; - ProjectService.prototype.createAndAddConfiguredProject = function (configFileName, projectOptions, configFileErrors, clientFileName) { - var _this = this; - var sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); - var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, projectOptions.configHasFilesProperty, projectOptions.compilerOptions, projectOptions.wildcardDirectories, !sizeLimitExceeded, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); - this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); - project.watchConfigFile(function (project) { return _this.onConfigChangedForConfiguredProject(project); }); - if (!sizeLimitExceeded) { - this.watchConfigDirectoryForProject(project, projectOptions); - } - project.watchWildcards(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); - project.watchTypeRoots(function (project, path) { return _this.onTypeRootFileChanged(project, path); }); - this.configuredProjects.push(project); - return project; - }; - ProjectService.prototype.watchConfigDirectoryForProject = function (project, options) { - var _this = this; - if (!options.configHasFilesProperty) { - project.watchConfigDirectory(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); - } - }; - ProjectService.prototype.addFilesToProjectAndUpdateGraph = function (project, files, propertyReader, clientFileName, typeAcquisition, configFileErrors) { - var errors; - for (var _i = 0, files_4 = files; _i < files_4.length; _i++) { - var f = files_4[_i]; - var rootFilename = propertyReader.getFileName(f); - var scriptKind = propertyReader.getScriptKind(f); - var hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); - if (this.host.fileExists(rootFilename)) { - var info = this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(rootFilename), clientFileName == rootFilename, undefined, scriptKind, hasMixedContent); - project.addRoot(info); - } - else { - (errors || (errors = [])).push(createFileNotFoundDiagnostic(rootFilename)); - } - } - project.setProjectErrors(ts.concatenate(configFileErrors, errors)); - project.setTypeAcquisition(typeAcquisition); - project.updateGraph(); - }; - ProjectService.prototype.openConfigFile = function (configFileName, clientFileName) { - var conversionResult = this.convertConfigFileContentToProjectOptions(configFileName); - var projectOptions = conversionResult.success - ? conversionResult.projectOptions - : { files: [], compilerOptions: {} }; - var project = this.createAndAddConfiguredProject(configFileName, projectOptions, conversionResult.configFileErrors, clientFileName); - return { - success: conversionResult.success, - project: project, - errors: project.getProjectErrors() - }; - }; - ProjectService.prototype.updateNonInferredProject = function (project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave, configFileErrors) { - var oldRootScriptInfos = project.getRootScriptInfos(); - var newRootScriptInfos = []; - var newRootScriptInfoMap = server.createNormalizedPathMap(); - var projectErrors; - var rootFilesChanged = false; - for (var _i = 0, newUncheckedFiles_1 = newUncheckedFiles; _i < newUncheckedFiles_1.length; _i++) { - var f = newUncheckedFiles_1[_i]; - var newRootFile = propertyReader.getFileName(f); - if (!this.host.fileExists(newRootFile)) { - (projectErrors || (projectErrors = [])).push(createFileNotFoundDiagnostic(newRootFile)); - continue; - } - var normalizedPath = server.toNormalizedPath(newRootFile); - var scriptInfo = this.getScriptInfoForNormalizedPath(normalizedPath); - if (!scriptInfo || !project.isRoot(scriptInfo)) { - rootFilesChanged = true; - if (!scriptInfo) { - var scriptKind = propertyReader.getScriptKind(f); - var hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); - scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, false, undefined, scriptKind, hasMixedContent); - } - } - newRootScriptInfos.push(scriptInfo); - newRootScriptInfoMap.set(scriptInfo.fileName, scriptInfo); - } - if (rootFilesChanged || newRootScriptInfos.length !== oldRootScriptInfos.length) { - var toAdd = void 0; - var toRemove = void 0; - for (var _a = 0, oldRootScriptInfos_1 = oldRootScriptInfos; _a < oldRootScriptInfos_1.length; _a++) { - var oldFile = oldRootScriptInfos_1[_a]; - if (!newRootScriptInfoMap.contains(oldFile.fileName)) { - (toRemove || (toRemove = [])).push(oldFile); - } - } - for (var _b = 0, newRootScriptInfos_1 = newRootScriptInfos; _b < newRootScriptInfos_1.length; _b++) { - var newFile = newRootScriptInfos_1[_b]; - if (!project.isRoot(newFile)) { - (toAdd || (toAdd = [])).push(newFile); - } - } - if (toRemove) { - for (var _c = 0, toRemove_1 = toRemove; _c < toRemove_1.length; _c++) { - var f = toRemove_1[_c]; - project.removeFile(f); - } - } - if (toAdd) { - for (var _d = 0, toAdd_1 = toAdd; _d < toAdd_1.length; _d++) { - var f = toAdd_1[_d]; - if (f.isScriptOpen() && isRootFileInInferredProject(f)) { - var inferredProject = f.containingProjects[0]; - inferredProject.removeFile(f); - if (!inferredProject.hasRoots()) { - this.removeProject(inferredProject); - } - } - project.addRoot(f); - } - } - } - project.setCompilerOptions(newOptions); - project.setTypeAcquisition(newTypeAcquisition); - if (compileOnSave !== undefined) { - project.compileOnSaveEnabled = compileOnSave; - } - project.setProjectErrors(ts.concatenate(configFileErrors, projectErrors)); - project.updateGraph(); - }; - ProjectService.prototype.updateConfiguredProject = function (project) { - if (!this.host.fileExists(project.getConfigFilePath())) { - this.logger.info("Config file deleted"); - this.removeProject(project); - return; - } - var _a = this.convertConfigFileContentToProjectOptions(project.getConfigFilePath()), success = _a.success, projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; - if (!success) { - this.updateNonInferredProject(project, [], fileNamePropertyReader, {}, {}, false, configFileErrors); - return configFileErrors; - } - if (this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { - project.setCompilerOptions(projectOptions.compilerOptions); - if (!project.languageServiceEnabled) { - return configFileErrors; - } - project.disableLanguageService(); - project.stopWatchingDirectory(); - } - else { - project.enableLanguageService(); - this.watchConfigDirectoryForProject(project, projectOptions); - this.updateNonInferredProject(project, projectOptions.files, fileNamePropertyReader, projectOptions.compilerOptions, projectOptions.typeAcquisition, projectOptions.compileOnSave, configFileErrors); - } - return configFileErrors; - }; - ProjectService.prototype.createInferredProjectWithRootFileIfNecessary = function (root) { - var _this = this; - var useExistingProject = this.useSingleInferredProject && this.inferredProjects.length; - var project = useExistingProject - ? this.inferredProjects[0] - : new server.InferredProject(this, this.documentRegistry, this.compilerOptionsForInferredProjects); - project.addRoot(root); - this.directoryWatchers.startWatchingContainingDirectoriesForFile(root.fileName, project, function (fileName) { return _this.onConfigFileAddedForInferredProject(fileName); }); - project.updateGraph(); - if (!useExistingProject) { - this.inferredProjects.push(project); - } - return project; - }; - ProjectService.prototype.getOrCreateScriptInfo = function (uncheckedFileName, openedByClient, fileContent, scriptKind) { - return this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName), openedByClient, fileContent, scriptKind); - }; - ProjectService.prototype.getScriptInfo = function (uncheckedFileName) { - return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); - }; - ProjectService.prototype.getOrCreateScriptInfoForNormalizedPath = function (fileName, openedByClient, fileContent, scriptKind, hasMixedContent) { - var _this = this; - var info = this.getScriptInfoForNormalizedPath(fileName); - if (!info) { - if (openedByClient || this.host.fileExists(fileName)) { - info = new server.ScriptInfo(this.host, fileName, scriptKind, hasMixedContent); - this.filenameToScriptInfo.set(info.path, info); - if (openedByClient) { - if (fileContent === undefined) { - fileContent = this.host.readFile(fileName) || ""; - } - } - else { - if (!hasMixedContent) { - info.setWatcher(this.host.watchFile(fileName, function (_) { return _this.onSourceFileChanged(fileName); })); - } - } - } - } - if (info) { - if (openedByClient && !info.isScriptOpen()) { - info.open(fileContent); - if (hasMixedContent) { - info.registerFileUpdate(); - } - } - else if (fileContent !== undefined) { - info.reload(fileContent); - } - } - return info; - }; - ProjectService.prototype.getScriptInfoForNormalizedPath = function (fileName) { - return this.getScriptInfoForPath(server.normalizedPathToPath(fileName, this.host.getCurrentDirectory(), this.toCanonicalFileName)); - }; - ProjectService.prototype.getScriptInfoForPath = function (fileName) { - return this.filenameToScriptInfo.get(fileName); - }; - ProjectService.prototype.setHostConfiguration = function (args) { - if (args.file) { - var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file)); - if (info) { - info.setFormatOptions(convertFormatOptions(args.formatOptions)); - this.logger.info("Host configuration update for file " + args.file); - } - } - else { - if (args.hostInfo !== undefined) { - this.hostConfiguration.hostInfo = args.hostInfo; - this.logger.info("Host information " + args.hostInfo); - } - if (args.formatOptions) { - server.mergeMaps(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); - this.logger.info("Format host information updated"); - } - if (args.extraFileExtensions) { - this.hostConfiguration.extraFileExtensions = args.extraFileExtensions; - this.logger.info("Host file extension mappings updated"); - } - } - }; - ProjectService.prototype.closeLog = function () { - this.logger.close(); - }; - ProjectService.prototype.reloadProjects = function () { - this.logger.info("reload projects."); - for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { - var info = _a[_i]; - this.openOrUpdateConfiguredProjectForFile(info.fileName); - } - this.refreshInferredProjects(); - }; - ProjectService.prototype.refreshInferredProjects = function () { - this.logger.info("updating project structure from ..."); - this.printProjects(); - var orphantedFiles = []; - for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { - var info = _a[_i]; - if (info.containingProjects.length === 0) { - orphantedFiles.push(info); - } - else { - if (isRootFileInInferredProject(info) && info.containingProjects.length > 1) { - var inferredProject = info.containingProjects[0]; - ts.Debug.assert(inferredProject.projectKind === server.ProjectKind.Inferred); - inferredProject.removeFile(info); - if (!inferredProject.hasRoots()) { - this.removeProject(inferredProject); - } - } - } - } - for (var _b = 0, orphantedFiles_1 = orphantedFiles; _b < orphantedFiles_1.length; _b++) { - var f = orphantedFiles_1[_b]; - this.assignScriptInfoToInferredProjectIfNecessary(f, false); - } - for (var _c = 0, _d = this.inferredProjects; _c < _d.length; _c++) { - var p = _d[_c]; - p.updateGraph(); - } - this.printProjects(); - }; - ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind); - }; - ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent) { - var configFileName; - var configFileErrors; - var project = this.findContainingExternalProject(fileName); - if (!project) { - (_a = this.openOrUpdateConfiguredProjectForFile(fileName), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors); - if (configFileName) { - project = this.findConfiguredProjectByProjectName(configFileName); - } - } - if (project && !project.languageServiceEnabled) { - project.markAsDirty(); - } - var info = this.getOrCreateScriptInfoForNormalizedPath(fileName, true, fileContent, scriptKind, hasMixedContent); - this.assignScriptInfoToInferredProjectIfNecessary(info, true); - this.printProjects(); - return { configFileName: configFileName, configFileErrors: configFileErrors }; - var _a; - }; - ProjectService.prototype.closeClientFile = function (uncheckedFileName) { - var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); - if (info) { - this.closeOpenFile(info); - } - this.printProjects(); - }; - ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_4 = function (proj) { - var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); - result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); - }; - for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { - var proj = currentProjects_1[_i]; - _loop_4(proj); - } - }; - ProjectService.prototype.synchronizeProjectList = function (knownProjects) { - var files = []; - this.collectChanges(knownProjects, this.externalProjects, files); - this.collectChanges(knownProjects, this.configuredProjects, files); - this.collectChanges(knownProjects, this.inferredProjects, files); - return files; - }; - ProjectService.prototype.applyChangesInOpenFiles = function (openFiles, changedFiles, closedFiles) { - var recordChangedFiles = changedFiles && !openFiles && !closedFiles; - if (openFiles) { - for (var _i = 0, openFiles_1 = openFiles; _i < openFiles_1.length; _i++) { - var file = openFiles_1[_i]; - var scriptInfo = this.getScriptInfo(file.fileName); - ts.Debug.assert(!scriptInfo || !scriptInfo.isScriptOpen()); - var normalizedPath = scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file.fileName); - this.openClientFileWithNormalizedPath(normalizedPath, file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent); - } - } - if (changedFiles) { - for (var _a = 0, changedFiles_2 = changedFiles; _a < changedFiles_2.length; _a++) { - var file = changedFiles_2[_a]; - var scriptInfo = this.getScriptInfo(file.fileName); - ts.Debug.assert(!!scriptInfo); - for (var i = file.changes.length - 1; i >= 0; i--) { - var change = file.changes[i]; - scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText); - } - if (recordChangedFiles) { - if (!this.changedFiles) { - this.changedFiles = [scriptInfo]; - } - else if (this.changedFiles.indexOf(scriptInfo) < 0) { - this.changedFiles.push(scriptInfo); - } - } - } - } - if (closedFiles) { - for (var _b = 0, closedFiles_1 = closedFiles; _b < closedFiles_1.length; _b++) { - var file = closedFiles_1[_b]; - this.closeClientFile(file); - } - } - if (openFiles || closedFiles) { - this.refreshInferredProjects(); - } - }; - ProjectService.prototype.closeConfiguredProject = function (configFile) { - var configuredProject = this.findConfiguredProjectByProjectName(configFile); - if (configuredProject && configuredProject.deleteOpenRef() === 0) { - this.removeProject(configuredProject); - } - }; - ProjectService.prototype.closeExternalProject = function (uncheckedFileName, suppressRefresh) { - if (suppressRefresh === void 0) { suppressRefresh = false; } - var fileName = server.toNormalizedPath(uncheckedFileName); - var configFiles = this.externalProjectToConfiguredProjectMap[fileName]; - if (configFiles) { - var shouldRefreshInferredProjects = false; - for (var _i = 0, configFiles_1 = configFiles; _i < configFiles_1.length; _i++) { - var configFile = configFiles_1[_i]; - if (this.closeConfiguredProject(configFile)) { - shouldRefreshInferredProjects = true; - } - } - delete this.externalProjectToConfiguredProjectMap[fileName]; - if (shouldRefreshInferredProjects && !suppressRefresh) { - this.refreshInferredProjects(); - } - } - else { - var externalProject = this.findExternalProjectByProjectName(uncheckedFileName); - if (externalProject) { - this.removeProject(externalProject); - if (!suppressRefresh) { - this.refreshInferredProjects(); - } - } - } - }; - ProjectService.prototype.openExternalProjects = function (projects) { - var projectsToClose = ts.arrayToMap(this.externalProjects, function (p) { return p.getProjectName(); }, function (_) { return true; }); - for (var externalProjectName in this.externalProjectToConfiguredProjectMap) { - projectsToClose[externalProjectName] = true; - } - for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { - var externalProject = projects_4[_i]; - this.openExternalProject(externalProject, true); - delete projectsToClose[externalProject.projectFileName]; - } - for (var externalProjectName in projectsToClose) { - this.closeExternalProject(externalProjectName, true); - } - this.refreshInferredProjects(); - }; - ProjectService.prototype.openExternalProject = function (proj, suppressRefreshOfInferredProjects) { - if (suppressRefreshOfInferredProjects === void 0) { suppressRefreshOfInferredProjects = false; } - if (proj.typingOptions && !proj.typeAcquisition) { - var typeAcquisition = ts.convertEnableAutoDiscoveryToEnable(proj.typingOptions); - proj.typeAcquisition = typeAcquisition; - } - var tsConfigFiles; - var rootFiles = []; - for (var _i = 0, _a = proj.rootFiles; _i < _a.length; _i++) { - var file = _a[_i]; - var normalized = server.toNormalizedPath(file.fileName); - if (ts.getBaseFileName(normalized) === "tsconfig.json") { - if (this.host.fileExists(normalized)) { - (tsConfigFiles || (tsConfigFiles = [])).push(normalized); - } - } - else { - rootFiles.push(file); - } - } - if (tsConfigFiles) { - tsConfigFiles.sort(); - } - var externalProject = this.findExternalProjectByProjectName(proj.projectFileName); - var exisingConfigFiles; - if (externalProject) { - if (!tsConfigFiles) { - var compilerOptions = convertCompilerOptions(proj.options); - if (this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, proj.rootFiles, externalFilePropertyReader)) { - externalProject.disableLanguageService(); - } - else { - externalProject.enableLanguageService(); - } - this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, compilerOptions, proj.typeAcquisition, proj.options.compileOnSave, undefined); - return; - } - this.closeExternalProject(proj.projectFileName, true); - } - else if (this.externalProjectToConfiguredProjectMap[proj.projectFileName]) { - if (!tsConfigFiles) { - this.closeExternalProject(proj.projectFileName, true); - } - else { - var oldConfigFiles = this.externalProjectToConfiguredProjectMap[proj.projectFileName]; - var iNew = 0; - var iOld = 0; - while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) { - var newConfig = tsConfigFiles[iNew]; - var oldConfig = oldConfigFiles[iOld]; - if (oldConfig < newConfig) { - this.closeConfiguredProject(oldConfig); - iOld++; - } - else if (oldConfig > newConfig) { - iNew++; - } - else { - (exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig); - iOld++; - iNew++; - } - } - for (var i = iOld; i < oldConfigFiles.length; i++) { - this.closeConfiguredProject(oldConfigFiles[i]); - } - } - } - if (tsConfigFiles) { - this.externalProjectToConfiguredProjectMap[proj.projectFileName] = tsConfigFiles; - for (var _b = 0, tsConfigFiles_1 = tsConfigFiles; _b < tsConfigFiles_1.length; _b++) { - var tsconfigFile = tsConfigFiles_1[_b]; - var project = this.findConfiguredProjectByProjectName(tsconfigFile); - if (!project) { - var result = this.openConfigFile(tsconfigFile); - project = result.success && result.project; - } - if (project && !ts.contains(exisingConfigFiles, tsconfigFile)) { - project.addOpenRef(); - } - } - } - else { - delete this.externalProjectToConfiguredProjectMap[proj.projectFileName]; - this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition); - } - if (!suppressRefreshOfInferredProjects) { - this.refreshInferredProjects(); - } - }; - return ProjectService; + return ThrottledOperations; }()); - server.ProjectService = ProjectService; + server.ThrottledOperations = ThrottledOperations; + var GcTimer = (function () { + function GcTimer(host, delay, logger) { + this.host = host; + this.delay = delay; + this.logger = logger; + } + GcTimer.prototype.scheduleCollect = function () { + if (!this.host.gc || this.timerId != undefined) { + return; + } + this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); + }; + GcTimer.run = function (self) { + self.timerId = undefined; + var log = self.logger.hasLevel(LogLevel.requestTime); + var before = log && self.host.getMemoryUsage(); + self.host.gc(); + if (log) { + var after = self.host.getMemoryUsage(); + self.logger.perftrc("GC::before " + before + ", after " + after); + } + }; + return GcTimer; + }()); + server.GcTimer = GcTimer; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; (function (ts) { var server; (function (server) { + server.nullCancellationToken = { + isCancellationRequested: function () { return false; }, + setRequest: function () { return void 0; }, + resetRequest: function () { return void 0; } + }; function hrTimeToMilliseconds(time) { var seconds = time[0]; var nanoseconds = time[1]; @@ -67616,17 +68739,100 @@ var ts; return "Content-Length: " + (1 + len) + "\r\n\r\n" + json + newLine; } server.formatMessage = formatMessage; + var MultistepOperation = (function () { + function MultistepOperation(operationHost) { + var _this = this; + this.operationHost = operationHost; + this.completed = true; + this.next = { + immediate: function (action) { return _this.immediate(action); }, + delay: function (ms, action) { return _this.delay(ms, action); } + }; + } + MultistepOperation.prototype.startNew = function (action) { + this.complete(); + this.requestId = this.operationHost.getCurrentRequestId(); + this.completed = false; + this.executeAction(action); + }; + MultistepOperation.prototype.complete = function () { + if (!this.completed) { + if (this.requestId) { + this.operationHost.sendRequestCompletedEvent(this.requestId); + } + this.completed = true; + } + this.setTimerHandle(undefined); + this.setImmediateId(undefined); + }; + MultistepOperation.prototype.immediate = function (action) { + var _this = this; + var requestId = this.requestId; + ts.Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "immediate: incorrect request id"); + this.setImmediateId(this.operationHost.getServerHost().setImmediate(function () { + _this.immediateId = undefined; + _this.operationHost.executeWithRequestId(requestId, function () { return _this.executeAction(action); }); + })); + }; + MultistepOperation.prototype.delay = function (ms, action) { + var _this = this; + var requestId = this.requestId; + ts.Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "delay: incorrect request id"); + this.setTimerHandle(this.operationHost.getServerHost().setTimeout(function () { + _this.timerHandle = undefined; + _this.operationHost.executeWithRequestId(requestId, function () { return _this.executeAction(action); }); + }, ms)); + }; + MultistepOperation.prototype.executeAction = function (action) { + var stop = false; + try { + if (this.operationHost.isCancellationRequested()) { + stop = true; + } + else { + action(this.next); + } + } + catch (e) { + stop = true; + if (!(e instanceof ts.OperationCanceledException)) { + this.operationHost.logError(e, "delayed processing of request " + this.requestId); + } + } + if (stop || !this.hasPendingWork()) { + this.complete(); + } + }; + MultistepOperation.prototype.setTimerHandle = function (timerHandle) { + ; + if (this.timerHandle !== undefined) { + this.operationHost.getServerHost().clearTimeout(this.timerHandle); + } + this.timerHandle = timerHandle; + }; + MultistepOperation.prototype.setImmediateId = function (immediateId) { + if (this.immediateId !== undefined) { + this.operationHost.getServerHost().clearImmediate(this.immediateId); + } + this.immediateId = immediateId; + }; + MultistepOperation.prototype.hasPendingWork = function () { + return !!this.timerHandle || !!this.immediateId; + }; + return MultistepOperation; + }()); var Session = (function () { function Session(host, cancellationToken, useSingleInferredProject, typingsInstaller, byteLength, hrtime, logger, canUseEvents, eventHandler) { var _this = this; this.host = host; + this.cancellationToken = cancellationToken; this.typingsInstaller = typingsInstaller; this.byteLength = byteLength; this.hrtime = hrtime; this.logger = logger; this.canUseEvents = canUseEvents; this.changeSeq = 0; - this.handlers = ts.createMap((_a = {}, + this.handlers = ts.createMapFromTemplate((_a = {}, _a[CommandNames.OpenExternalProject] = function (request) { _this.projectService.openExternalProject(request.arguments, false); return _this.requiredResponse(true); @@ -67780,12 +68986,12 @@ var ts; return _this.requiredResponse(_this.getSyntacticDiagnosticsSync(request.arguments)); }, _a[CommandNames.Geterr] = function (request) { - var geterrArgs = request.arguments; - return { response: _this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false }; + _this.errorCheck.startNew(function (next) { return _this.getDiagnostics(next, request.arguments.delay, request.arguments.files); }); + return _this.notRequired(); }, _a[CommandNames.GeterrForProject] = function (request) { - var _a = request.arguments, file = _a.file, delay = _a.delay; - return { response: _this.getDiagnosticsForProject(delay, file), responseRequired: false }; + _this.errorCheck.startNew(function (next) { return _this.getDiagnosticsForProject(next, request.arguments.delay, request.arguments.file); }); + return _this.notRequired(); }, _a[CommandNames.Change] = function (request) { _this.change(request.arguments); @@ -67867,17 +69073,35 @@ var ts; this.eventHander = canUseEvents ? eventHandler || (function (event) { return _this.defaultEventHandler(event); }) : undefined; + var multistepOperationHost = { + executeWithRequestId: function (requestId, action) { return _this.executeWithRequestId(requestId, action); }, + getCurrentRequestId: function () { return _this.currentRequestId; }, + getServerHost: function () { return _this.host; }, + logError: function (err, cmd) { return _this.logError(err, cmd); }, + sendRequestCompletedEvent: function (requestId) { return _this.sendRequestCompletedEvent(requestId); }, + isCancellationRequested: function () { return cancellationToken.isCancellationRequested(); } + }; + this.errorCheck = new MultistepOperation(multistepOperationHost); this.projectService = new server.ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); this.gcTimer = new server.GcTimer(host, 7000, logger); var _a; } + Session.prototype.sendRequestCompletedEvent = function (requestId) { + var event = { + seq: 0, + type: "event", + event: "requestCompleted", + body: { request_seq: requestId } + }; + this.send(event); + }; Session.prototype.defaultEventHandler = function (event) { var _this = this; switch (event.eventName) { case server.ContextEvent: - var _a = event.data, project = _a.project, fileName = _a.fileName; - this.projectService.logger.info("got context event, updating diagnostics for " + fileName); - this.updateErrorCheck([{ fileName: fileName, project: project }], this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); + var _a = event.data, project_1 = _a.project, fileName_1 = _a.fileName; + this.projectService.logger.info("got context event, updating diagnostics for " + fileName_1); + this.errorCheck.startNew(function (next) { return _this.updateErrorCheck(next, [{ fileName: fileName_1, project: project_1 }], _this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); }); break; case server.ConfigFileDiagEvent: var _b = event.data, triggerFile = _b.triggerFile, configFileName = _b.configFileName, diagnostics = _b.diagnostics; @@ -67930,7 +69154,7 @@ var ts; seq: 0, type: "event", event: eventName, - body: info, + body: info }; this.send(ev); }; @@ -67985,7 +69209,7 @@ var ts; } }, ms); }; - Session.prototype.updateErrorCheck = function (checkList, seq, matchSeq, ms, followMs, requireOpen) { + Session.prototype.updateErrorCheck = function (next, checkList, seq, matchSeq, ms, followMs, requireOpen) { var _this = this; if (ms === void 0) { ms = 1500; } if (followMs === void 0) { followMs = 200; } @@ -67993,13 +69217,6 @@ var ts; if (followMs > ms) { followMs = ms; } - if (this.errorTimer) { - this.host.clearTimeout(this.errorTimer); - } - if (this.immediateId) { - this.host.clearImmediate(this.immediateId); - this.immediateId = undefined; - } var index = 0; var checkOne = function () { if (matchSeq(seq)) { @@ -68007,21 +69224,17 @@ var ts; index++; if (checkSpec_1.project.containsFile(checkSpec_1.fileName, requireOpen)) { _this.syntacticCheck(checkSpec_1.fileName, checkSpec_1.project); - _this.immediateId = _this.host.setImmediate(function () { + next.immediate(function () { _this.semanticCheck(checkSpec_1.fileName, checkSpec_1.project); - _this.immediateId = undefined; if (checkList.length > index) { - _this.errorTimer = _this.host.setTimeout(checkOne, followMs); - } - else { - _this.errorTimer = undefined; + next.delay(followMs, checkOne); } }); } } }; if ((checkList.length > index) && (matchSeq(seq))) { - this.errorTimer = this.host.setTimeout(checkOne, ms); + next.delay(ms, checkOne); } }; Session.prototype.cleanProjects = function (caption, projects) { @@ -68029,8 +69242,8 @@ var ts; return; } this.logger.info("cleaning " + caption); - for (var _i = 0, projects_5 = projects; _i < projects_5.length; _i++) { - var p = projects_5[_i]; + for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) { + var p = projects_1[_i]; p.getLanguageService(false).cleanupSemanticCache(); } }; @@ -68118,18 +69331,21 @@ var ts; }; Session.prototype.getImplementation = function (args, simplifiedResult) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); var implementations = project.getLanguageService().getImplementationAtPosition(file, position); if (!implementations) { return []; } if (simplifiedResult) { - return implementations.map(function (impl) { return ({ - file: impl.fileName, - start: scriptInfo.positionToLineOffset(impl.textSpan.start), - end: scriptInfo.positionToLineOffset(ts.textSpanEnd(impl.textSpan)) - }); }); + return implementations.map(function (_a) { + var fileName = _a.fileName, textSpan = _a.textSpan; + var scriptInfo = project.getScriptInfo(fileName); + return { + file: fileName, + start: scriptInfo.positionToLineOffset(textSpan.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)) + }; + }); } else { return implementations; @@ -68539,9 +69755,9 @@ var ts; if (simplifiedResult) { return completions.entries.reduce(function (result, entry) { if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - var name_52 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; + var name = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; var convertedSpan = replacementSpan ? _this.decorateSpan(replacementSpan, scriptInfo) : undefined; - result.push({ name: name_52, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); + result.push({ name: name, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); } return result; }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); @@ -68574,7 +69790,8 @@ var ts; if (project.compileOnSaveEnabled && project.languageServiceEnabled) { result.push({ projectFileName: project.getProjectName(), - fileNames: project.getCompileOnSaveAffectedFileList(info) + fileNames: project.getCompileOnSaveAffectedFileList(info), + projectUsesOutFile: !!project.getCompilerOptions().outFile || !!project.getCompilerOptions().out }); } } @@ -68617,7 +69834,7 @@ var ts; return helpItems; } }; - Session.prototype.getDiagnostics = function (delay, fileNames) { + Session.prototype.getDiagnostics = function (next, delay, fileNames) { var _this = this; var checkList = fileNames.reduce(function (accum, uncheckedFileName) { var fileName = server.toNormalizedPath(uncheckedFileName); @@ -68628,7 +69845,7 @@ var ts; return accum; }, []); if (checkList.length > 0) { - this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay); + this.updateErrorCheck(next, checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay); } }; Session.prototype.change = function (args) { @@ -68835,7 +70052,7 @@ var ts; ? spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }) : spans; }; - Session.prototype.getDiagnosticsForProject = function (delay, fileName) { + Session.prototype.getDiagnosticsForProject = function (next, delay, fileName) { var _this = this; var _a = this.getProjectInfoWorker(fileName, undefined, true), fileNames = _a.fileNames, languageServiceDisabled = _a.languageServiceDisabled; if (languageServiceDisabled) { @@ -68867,7 +70084,7 @@ var ts; fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); if (fileNamesInProject.length > 0) { var checkList = fileNamesInProject.map(function (fileName) { return ({ fileName: fileName, project: project }); }); - this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); + this.updateErrorCheck(next, checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); } }; Session.prototype.getCanonicalFileName = function (fileName) { @@ -68883,15 +70100,34 @@ var ts; return { response: response, responseRequired: true }; }; Session.prototype.addProtocolHandler = function (command, handler) { - if (command in this.handlers) { + if (this.handlers.has(command)) { throw new Error("Protocol handler already exists for command \"" + command + "\""); } - this.handlers[command] = handler; + this.handlers.set(command, handler); + }; + Session.prototype.setCurrentRequest = function (requestId) { + ts.Debug.assert(this.currentRequestId === undefined); + this.currentRequestId = requestId; + this.cancellationToken.setRequest(requestId); + }; + Session.prototype.resetCurrentRequest = function (requestId) { + ts.Debug.assert(this.currentRequestId === requestId); + this.currentRequestId = undefined; + this.cancellationToken.resetRequest(requestId); + }; + Session.prototype.executeWithRequestId = function (requestId, f) { + try { + this.setCurrentRequest(requestId); + return f(); + } + finally { + this.resetCurrentRequest(requestId); + } }; Session.prototype.executeCommand = function (request) { - var handler = this.handlers[request.command]; + var handler = this.handlers.get(request.command); if (handler) { - return handler(request); + return this.executeWithRequestId(request.seq, function () { return handler(request); }); } else { this.logger.msg("Unrecognized JSON command: " + JSON.stringify(request), server.Msg.Err); @@ -69022,7 +70258,7 @@ var ts; if (len > 1) { var insertedNodes = new Array(len - 1); var startNode = leafNode; - for (var i = 1, len_1 = lines.length; i < len_1; i++) { + for (var i = 1; i < lines.length; i++) { insertedNodes[i - 1] = new LineLeaf(lines[i]); } var pathIndex = this.startPath.length - 2; @@ -69219,8 +70455,8 @@ var ts; var snap = this.versions[this.currentVersionToIndex()]; if (this.changes.length > 0) { var snapIndex = snap.index; - for (var i = 0, len = this.changes.length; i < len; i++) { - var change = this.changes[i]; + for (var _i = 0, _a = this.changes; _i < _a.length; _i++) { + var change = _a[_i]; snapIndex = snapIndex.edit(change.pos, change.deleteLen, change.insertedText); } snap = new LineIndexSnapshot(this.currentVersion + 1, this); @@ -69241,8 +70477,8 @@ var ts; var textChangeRanges = []; for (var i = oldVersion + 1; i <= newVersion; i++) { var snap = this.versions[this.versionToIndex(i)]; - for (var j = 0, len = snap.changesSincePreviousVersion.length; j < len; j++) { - var textChange = snap.changesSincePreviousVersion[j]; + for (var _i = 0, _a = snap.changesSincePreviousVersion; _i < _a.length; _i++) { + var textChange = _a[_i]; textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); } } @@ -69342,7 +70578,7 @@ var ts; LineIndex.prototype.load = function (lines) { if (lines.length > 0) { var leaves = []; - for (var i = 0, len = lines.length; i < len; i++) { + for (var i = 0; i < lines.length; i++) { leaves[i] = new LineLeaf(lines[i]); } this.root = LineIndex.buildTreeFromBottom(leaves); @@ -69502,8 +70738,8 @@ var ts; 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]; + for (var _i = 0, _a = this.children; _i < _a.length; _i++) { + var child = _a[_i]; this.totalChars += child.charCount(); this.totalLines += child.lineCount(); } @@ -69789,6 +71025,2851 @@ var ts; server.LineLeaf = LineLeaf; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var TextStorage = (function () { + function TextStorage(host, fileName) { + this.host = host; + this.fileName = fileName; + this.svcVersion = 0; + this.textVersion = 0; + } + TextStorage.prototype.getVersion = function () { + return this.svc + ? "SVC-" + this.svcVersion + "-" + this.svc.getSnapshot().version + : "Text-" + this.textVersion; + }; + TextStorage.prototype.hasScriptVersionCache = function () { + return this.svc !== undefined; + }; + TextStorage.prototype.useScriptVersionCache = function (newText) { + this.switchToScriptVersionCache(newText); + }; + TextStorage.prototype.useText = function (newText) { + this.svc = undefined; + this.setText(newText); + }; + TextStorage.prototype.edit = function (start, end, newText) { + this.switchToScriptVersionCache().edit(start, end - start, newText); + }; + TextStorage.prototype.reload = function (text) { + if (this.svc) { + this.svc.reload(text); + } + else { + this.setText(text); + } + }; + TextStorage.prototype.reloadFromFile = function (tempFileName) { + if (this.svc || (tempFileName !== this.fileName)) { + this.reload(this.getFileText(tempFileName)); + } + else { + this.setText(undefined); + } + }; + TextStorage.prototype.getSnapshot = function () { + return this.svc + ? this.svc.getSnapshot() + : ts.ScriptSnapshot.fromString(this.getOrLoadText()); + }; + TextStorage.prototype.getLineInfo = function (line) { + return this.switchToScriptVersionCache().getSnapshot().index.lineNumberToInfo(line); + }; + TextStorage.prototype.lineToTextSpan = function (line) { + if (!this.svc) { + var lineMap = this.getLineMap(); + var start = lineMap[line]; + var end = line + 1 < lineMap.length ? lineMap[line + 1] : this.text.length; + return ts.createTextSpanFromBounds(start, end); + } + var index = this.svc.getSnapshot().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); + }; + TextStorage.prototype.lineOffsetToPosition = function (line, offset) { + if (!this.svc) { + return ts.computePositionOfLineAndCharacter(this.getLineMap(), line - 1, offset - 1); + } + var index = this.svc.getSnapshot().index; + var lineInfo = index.lineNumberToInfo(line); + return (lineInfo.offset + offset - 1); + }; + TextStorage.prototype.positionToLineOffset = function (position) { + if (!this.svc) { + var _a = ts.computeLineAndCharacterOfPosition(this.getLineMap(), position), line = _a.line, character = _a.character; + return { line: line + 1, offset: character + 1 }; + } + var index = this.svc.getSnapshot().index; + var lineOffset = index.charOffsetToLineNumberAndPos(position); + return { line: lineOffset.line, offset: lineOffset.offset + 1 }; + }; + TextStorage.prototype.getFileText = function (tempFileName) { + return this.host.readFile(tempFileName || this.fileName) || ""; + }; + TextStorage.prototype.ensureNoScriptVersionCache = function () { + ts.Debug.assert(!this.svc, "ScriptVersionCache should not be set"); + }; + TextStorage.prototype.switchToScriptVersionCache = function (newText) { + if (!this.svc) { + this.svc = server.ScriptVersionCache.fromString(this.host, newText !== undefined ? newText : this.getOrLoadText()); + this.svcVersion++; + this.text = undefined; + } + return this.svc; + }; + TextStorage.prototype.getOrLoadText = function () { + this.ensureNoScriptVersionCache(); + if (this.text === undefined) { + this.setText(this.getFileText()); + } + return this.text; + }; + TextStorage.prototype.getLineMap = function () { + this.ensureNoScriptVersionCache(); + return this.lineMap || (this.lineMap = ts.computeLineStarts(this.getOrLoadText())); + }; + TextStorage.prototype.setText = function (newText) { + this.ensureNoScriptVersionCache(); + if (newText === undefined || this.text !== newText) { + this.text = newText; + this.lineMap = undefined; + this.textVersion++; + } + }; + return TextStorage; + }()); + server.TextStorage = TextStorage; + var ScriptInfo = (function () { + function ScriptInfo(host, fileName, scriptKind, hasMixedContent) { + if (hasMixedContent === void 0) { hasMixedContent = false; } + this.host = host; + this.fileName = fileName; + this.scriptKind = scriptKind; + this.hasMixedContent = hasMixedContent; + this.containingProjects = []; + this.path = ts.toPath(fileName, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); + this.textStorage = new TextStorage(host, fileName); + if (hasMixedContent) { + this.textStorage.reload(""); + } + this.scriptKind = scriptKind + ? scriptKind + : ts.getScriptKindFromFileName(fileName); + } + ScriptInfo.prototype.isScriptOpen = function () { + return this.isOpen; + }; + ScriptInfo.prototype.open = function (newText) { + this.isOpen = true; + this.textStorage.useScriptVersionCache(newText); + this.markContainingProjectsAsDirty(); + }; + ScriptInfo.prototype.close = function () { + this.isOpen = false; + this.textStorage.useText(this.hasMixedContent ? "" : undefined); + this.markContainingProjectsAsDirty(); + }; + ScriptInfo.prototype.getSnapshot = function () { + return this.textStorage.getSnapshot(); + }; + ScriptInfo.prototype.getFormatCodeSettings = function () { + return this.formatCodeSettings; + }; + ScriptInfo.prototype.attachToProject = function (project) { + var isNew = !this.isAttached(project); + if (isNew) { + this.containingProjects.push(project); + } + return isNew; + }; + ScriptInfo.prototype.isAttached = function (project) { + switch (this.containingProjects.length) { + case 0: return false; + case 1: return this.containingProjects[0] === project; + case 2: return this.containingProjects[0] === project || this.containingProjects[1] === project; + default: return ts.contains(this.containingProjects, project); + } + }; + ScriptInfo.prototype.detachFromProject = function (project) { + switch (this.containingProjects.length) { + case 0: + return; + case 1: + if (this.containingProjects[0] === project) { + this.containingProjects.pop(); + } + break; + case 2: + if (this.containingProjects[0] === project) { + this.containingProjects[0] = this.containingProjects.pop(); + } + else if (this.containingProjects[1] === project) { + this.containingProjects.pop(); + } + break; + default: + server.removeItemFromSet(this.containingProjects, project); + break; + } + }; + ScriptInfo.prototype.detachAllProjects = function () { + for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + p.removeFile(this, false); + } + this.containingProjects.length = 0; + }; + ScriptInfo.prototype.getDefaultProject = function () { + if (this.containingProjects.length === 0) { + return server.Errors.ThrowNoProject(); + } + return this.containingProjects[0]; + }; + ScriptInfo.prototype.registerFileUpdate = function () { + for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + p.registerFileUpdate(this.path); + } + }; + ScriptInfo.prototype.setFormatOptions = function (formatSettings) { + if (formatSettings) { + if (!this.formatCodeSettings) { + this.formatCodeSettings = server.getDefaultFormatCodeSettings(this.host); + } + server.mergeMapLikes(this.formatCodeSettings, formatSettings); + } + }; + ScriptInfo.prototype.setWatcher = function (watcher) { + this.stopWatcher(); + this.fileWatcher = watcher; + }; + ScriptInfo.prototype.stopWatcher = function () { + if (this.fileWatcher) { + this.fileWatcher.close(); + this.fileWatcher = undefined; + } + }; + ScriptInfo.prototype.getLatestVersion = function () { + return this.textStorage.getVersion(); + }; + ScriptInfo.prototype.reload = function (script) { + this.textStorage.reload(script); + this.markContainingProjectsAsDirty(); + }; + ScriptInfo.prototype.saveTo = function (fileName) { + var snap = this.textStorage.getSnapshot(); + this.host.writeFile(fileName, snap.getText(0, snap.getLength())); + }; + ScriptInfo.prototype.reloadFromFile = function (tempFileName) { + if (this.hasMixedContent) { + this.reload(""); + } + else { + this.textStorage.reloadFromFile(tempFileName); + this.markContainingProjectsAsDirty(); + } + }; + ScriptInfo.prototype.getLineInfo = function (line) { + return this.textStorage.getLineInfo(line); + }; + ScriptInfo.prototype.editContent = function (start, end, newText) { + this.textStorage.edit(start, end, newText); + this.markContainingProjectsAsDirty(); + }; + ScriptInfo.prototype.markContainingProjectsAsDirty = function () { + for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + p.markAsDirty(); + } + }; + ScriptInfo.prototype.lineToTextSpan = function (line) { + return this.textStorage.lineToTextSpan(line); + }; + ScriptInfo.prototype.lineOffsetToPosition = function (line, offset) { + return this.textStorage.lineOffsetToPosition(line, offset); + }; + ScriptInfo.prototype.positionToLineOffset = function (position) { + return this.textStorage.positionToLineOffset(position); + }; + ScriptInfo.prototype.isJavaScript = function () { + return this.scriptKind === 1 || this.scriptKind === 2; + }; + return ScriptInfo; + }()); + server.ScriptInfo = ScriptInfo; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var LSHost = (function () { + function LSHost(host, project, cancellationToken) { + var _this = this; + this.host = host; + this.project = project; + this.cancellationToken = cancellationToken; + this.resolvedModuleNames = ts.createFileMap(); + this.resolvedTypeReferenceDirectives = ts.createFileMap(); + this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); + if (host.trace) { + this.trace = function (s) { return host.trace(s); }; + } + this.resolveModuleName = function (moduleName, containingFile, compilerOptions, host) { + var globalCache = _this.project.getTypeAcquisition().enable + ? _this.project.projectService.typingsInstaller.globalTypingsCacheLocation + : undefined; + var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host); + if (ts.moduleHasNonRelativeName(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTypeScript(primaryResult.resolvedModule.extension)) && globalCache !== undefined) { + var _a = ts.loadModuleFromGlobalCache(moduleName, _this.project.getProjectName(), compilerOptions, host, globalCache), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; + if (resolvedModule) { + return { resolvedModule: resolvedModule, failedLookupLocations: primaryResult.failedLookupLocations.concat(failedLookupLocations) }; + } + } + return primaryResult; + }; + if (this.host.realpath) { + this.realpath = function (path) { return _this.host.realpath(path); }; + } + } + LSHost.prototype.startRecordingFilesWithChangedResolutions = function () { + this.filesWithChangedSetOfUnresolvedImports = []; + }; + LSHost.prototype.finishRecordingFilesWithChangedResolutions = function () { + var collected = this.filesWithChangedSetOfUnresolvedImports; + this.filesWithChangedSetOfUnresolvedImports = undefined; + return collected; + }; + LSHost.prototype.resolveNamesWithLocalCache = function (names, containingFile, cache, loader, getResult, getResultFileName, logChanges) { + var path = ts.toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); + var currentResolutionsInFile = cache.get(path); + var newResolutions = ts.createMap(); + var resolvedModules = []; + var compilerOptions = this.getCompilationSettings(); + var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; + for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { + var name = names_2[_i]; + var resolution = newResolutions.get(name); + if (!resolution) { + var existingResolution = currentResolutionsInFile && currentResolutionsInFile.get(name); + if (moduleResolutionIsValid(existingResolution)) { + resolution = existingResolution; + } + else { + resolution = loader(name, containingFile, compilerOptions, this); + newResolutions.set(name, resolution); + } + if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { + this.filesWithChangedSetOfUnresolvedImports.push(path); + logChanges = false; + } + } + ts.Debug.assert(resolution !== undefined); + resolvedModules.push(getResult(resolution)); + } + cache.set(path, newResolutions); + return resolvedModules; + function resolutionIsEqualTo(oldResolution, newResolution) { + if (oldResolution === newResolution) { + return true; + } + if (!oldResolution || !newResolution) { + return false; + } + var oldResult = getResult(oldResolution); + var newResult = getResult(newResolution); + if (oldResult === newResult) { + return true; + } + if (!oldResult || !newResult) { + return false; + } + return getResultFileName(oldResult) === getResultFileName(newResult); + } + function moduleResolutionIsValid(resolution) { + if (!resolution) { + return false; + } + var result = getResult(resolution); + if (result) { + return getResultFileName(result) !== lastDeletedFileName; + } + return resolution.failedLookupLocations.length === 0; + } + }; + LSHost.prototype.getNewLine = function () { + return this.host.newLine; + }; + LSHost.prototype.getProjectVersion = function () { + return this.project.getProjectVersion(); + }; + LSHost.prototype.getCompilationSettings = function () { + return this.compilationSettings; + }; + LSHost.prototype.useCaseSensitiveFileNames = function () { + return this.host.useCaseSensitiveFileNames; + }; + LSHost.prototype.getCancellationToken = function () { + return this.cancellationToken; + }; + LSHost.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { + return this.resolveNamesWithLocalCache(typeDirectiveNames, containingFile, this.resolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, function (m) { return m.resolvedTypeReferenceDirective; }, function (r) { return r.resolvedFileName; }, false); + }; + LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { + return this.resolveNamesWithLocalCache(moduleNames, containingFile, this.resolvedModuleNames, this.resolveModuleName, function (m) { return m.resolvedModule; }, function (r) { return r.resolvedFileName; }, true); + }; + LSHost.prototype.getDefaultLibFileName = function () { + var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); + return ts.combinePaths(nodeModuleBinDir, ts.getDefaultLibFileName(this.compilationSettings)); + }; + LSHost.prototype.getScriptSnapshot = function (filename) { + var scriptInfo = this.project.getScriptInfoLSHost(filename); + if (scriptInfo) { + return scriptInfo.getSnapshot(); + } + }; + LSHost.prototype.getScriptFileNames = function () { + return this.project.getRootFilesLSHost(); + }; + LSHost.prototype.getTypeRootsVersion = function () { + return this.project.typesVersion; + }; + LSHost.prototype.getScriptKind = function (fileName) { + var info = this.project.getScriptInfoLSHost(fileName); + return info && info.scriptKind; + }; + LSHost.prototype.getScriptVersion = function (filename) { + var info = this.project.getScriptInfoLSHost(filename); + return info && info.getLatestVersion(); + }; + LSHost.prototype.getCurrentDirectory = function () { + return this.host.getCurrentDirectory(); + }; + LSHost.prototype.resolvePath = function (path) { + return this.host.resolvePath(path); + }; + LSHost.prototype.fileExists = function (path) { + return this.host.fileExists(path); + }; + LSHost.prototype.readFile = function (fileName) { + return this.host.readFile(fileName); + }; + LSHost.prototype.directoryExists = function (path) { + return this.host.directoryExists(path); + }; + LSHost.prototype.readDirectory = function (path, extensions, exclude, include) { + return this.host.readDirectory(path, extensions, exclude, include); + }; + LSHost.prototype.getDirectories = function (path) { + return this.host.getDirectories(path); + }; + LSHost.prototype.notifyFileRemoved = function (info) { + this.resolvedModuleNames.remove(info.path); + this.resolvedTypeReferenceDirectives.remove(info.path); + }; + LSHost.prototype.setCompilationSettings = function (opt) { + if (ts.changesAffectModuleResolution(this.compilationSettings, opt)) { + this.resolvedModuleNames.clear(); + this.resolvedTypeReferenceDirectives.clear(); + } + this.compilationSettings = opt; + }; + return LSHost; + }()); + server.LSHost = LSHost; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + server.nullTypingsInstaller = { + enqueueInstallTypingsRequest: ts.noop, + attach: ts.noop, + onProjectClosed: ts.noop, + globalTypingsCacheLocation: undefined + }; + var TypingsCacheEntry = (function () { + function TypingsCacheEntry() { + } + return TypingsCacheEntry; + }()); + function setIsEqualTo(arr1, arr2) { + if (arr1 === arr2) { + return true; + } + if ((arr1 || server.emptyArray).length === 0 && (arr2 || server.emptyArray).length === 0) { + return true; + } + var set = ts.createMap(); + var unique = 0; + for (var _i = 0, arr1_1 = arr1; _i < arr1_1.length; _i++) { + var v = arr1_1[_i]; + if (set.get(v) !== true) { + set.set(v, true); + unique++; + } + } + for (var _a = 0, arr2_1 = arr2; _a < arr2_1.length; _a++) { + var v = arr2_1[_a]; + var isSet = set.get(v); + if (isSet === undefined) { + return false; + } + if (isSet === true) { + set.set(v, false); + unique--; + } + } + return unique === 0; + } + function typeAcquisitionChanged(opt1, opt2) { + return opt1.enable !== opt2.enable || + !setIsEqualTo(opt1.include, opt2.include) || + !setIsEqualTo(opt1.exclude, opt2.exclude); + } + function compilerOptionsChanged(opt1, opt2) { + return opt1.allowJs != opt2.allowJs; + } + function unresolvedImportsChanged(imports1, imports2) { + if (imports1 === imports2) { + return false; + } + return !ts.arrayIsEqualTo(imports1, imports2); + } + var TypingsCache = (function () { + function TypingsCache(installer) { + this.installer = installer; + this.perProjectCache = ts.createMap(); + } + TypingsCache.prototype.getTypingsForProject = function (project, unresolvedImports, forceRefresh) { + var typeAcquisition = project.getTypeAcquisition(); + if (!typeAcquisition || !typeAcquisition.enable) { + return server.emptyArray; + } + var entry = this.perProjectCache.get(project.getProjectName()); + var result = entry ? entry.typings : server.emptyArray; + if (forceRefresh || + !entry || + typeAcquisitionChanged(typeAcquisition, entry.typeAcquisition) || + compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions) || + unresolvedImportsChanged(unresolvedImports, entry.unresolvedImports)) { + this.perProjectCache.set(project.getProjectName(), { + compilerOptions: project.getCompilerOptions(), + typeAcquisition: typeAcquisition, + typings: result, + unresolvedImports: unresolvedImports, + poisoned: true + }); + this.installer.enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports); + } + return result; + }; + TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typeAcquisition, unresolvedImports, newTypings) { + this.perProjectCache.set(projectName, { + compilerOptions: compilerOptions, + typeAcquisition: typeAcquisition, + typings: server.toSortedReadonlyArray(newTypings), + unresolvedImports: unresolvedImports, + poisoned: false + }); + }; + TypingsCache.prototype.deleteTypingsForProject = function (projectName) { + this.perProjectCache.delete(projectName); + }; + TypingsCache.prototype.onProjectClosed = function (project) { + this.perProjectCache.delete(project.getProjectName()); + this.installer.onProjectClosed(project); + }; + return TypingsCache; + }()); + server.TypingsCache = TypingsCache; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + function shouldEmitFile(scriptInfo) { + return !scriptInfo.hasMixedContent; + } + server.shouldEmitFile = shouldEmitFile; + var BuilderFileInfo = (function () { + function BuilderFileInfo(scriptInfo, project) { + this.scriptInfo = scriptInfo; + this.project = project; + } + BuilderFileInfo.prototype.isExternalModuleOrHasOnlyAmbientExternalModules = function () { + var sourceFile = this.getSourceFile(); + return ts.isExternalModule(sourceFile) || this.containsOnlyAmbientModules(sourceFile); + }; + BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { + for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (statement.kind !== 232 || statement.name.kind !== 9) { + return false; + } + } + return true; + }; + BuilderFileInfo.prototype.computeHash = function (text) { + return this.project.projectService.host.createHash(text); + }; + BuilderFileInfo.prototype.getSourceFile = function () { + return this.project.getSourceFile(this.scriptInfo.path); + }; + BuilderFileInfo.prototype.updateShapeSignature = function () { + var sourceFile = this.getSourceFile(); + if (!sourceFile) { + return true; + } + var lastSignature = this.lastCheckedShapeSignature; + if (sourceFile.isDeclarationFile) { + this.lastCheckedShapeSignature = this.computeHash(sourceFile.text); + } + else { + var emitOutput = this.project.getFileEmitOutput(this.scriptInfo, true); + if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { + this.lastCheckedShapeSignature = this.computeHash(emitOutput.outputFiles[0].text); + } + } + return !lastSignature || this.lastCheckedShapeSignature !== lastSignature; + }; + return BuilderFileInfo; + }()); + server.BuilderFileInfo = BuilderFileInfo; + var AbstractBuilder = (function () { + function AbstractBuilder(project, ctor) { + this.project = project; + this.ctor = ctor; + } + AbstractBuilder.prototype.getFileInfos = function () { + return this.fileInfos_doNotAccessDirectly || (this.fileInfos_doNotAccessDirectly = ts.createFileMap()); + }; + AbstractBuilder.prototype.clear = function () { + this.fileInfos_doNotAccessDirectly = undefined; + }; + AbstractBuilder.prototype.getFileInfo = function (path) { + return this.getFileInfos().get(path); + }; + AbstractBuilder.prototype.getOrCreateFileInfo = function (path) { + var fileInfo = this.getFileInfo(path); + if (!fileInfo) { + var scriptInfo = this.project.getScriptInfo(path); + fileInfo = new this.ctor(scriptInfo, this.project); + this.setFileInfo(path, fileInfo); + } + return fileInfo; + }; + AbstractBuilder.prototype.getFileInfoPaths = function () { + return this.getFileInfos().getKeys(); + }; + AbstractBuilder.prototype.setFileInfo = function (path, info) { + this.getFileInfos().set(path, info); + }; + AbstractBuilder.prototype.removeFileInfo = function (path) { + this.getFileInfos().remove(path); + }; + AbstractBuilder.prototype.forEachFileInfo = function (action) { + this.getFileInfos().forEachValue(function (_path, value) { return action(value); }); + }; + AbstractBuilder.prototype.emitFile = function (scriptInfo, writeFile) { + var fileInfo = this.getFileInfo(scriptInfo.path); + if (!fileInfo) { + return false; + } + var _a = this.project.getFileEmitOutput(fileInfo.scriptInfo, false), emitSkipped = _a.emitSkipped, outputFiles = _a.outputFiles; + if (!emitSkipped) { + var projectRootPath = this.project.getProjectRootPath(); + for (var _i = 0, outputFiles_1 = outputFiles; _i < outputFiles_1.length; _i++) { + var outputFile = outputFiles_1[_i]; + var outputFileAbsoluteFileName = ts.getNormalizedAbsolutePath(outputFile.name, projectRootPath ? projectRootPath : ts.getDirectoryPath(scriptInfo.fileName)); + writeFile(outputFileAbsoluteFileName, outputFile.text, outputFile.writeByteOrderMark); + } + } + return !emitSkipped; + }; + return AbstractBuilder; + }()); + var NonModuleBuilder = (function (_super) { + __extends(NonModuleBuilder, _super); + function NonModuleBuilder(project) { + var _this = _super.call(this, project, BuilderFileInfo) || this; + _this.project = project; + return _this; + } + NonModuleBuilder.prototype.onProjectUpdateGraph = function () { + }; + NonModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { + var info = this.getOrCreateFileInfo(scriptInfo.path); + var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + if (info.updateShapeSignature()) { + var options = this.project.getCompilerOptions(); + if (options && (options.out || options.outFile)) { + return singleFileResult; + } + return this.project.getAllEmittableFiles(); + } + return singleFileResult; + }; + return NonModuleBuilder; + }(AbstractBuilder)); + var ModuleBuilderFileInfo = (function (_super) { + __extends(ModuleBuilderFileInfo, _super); + function ModuleBuilderFileInfo() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.references = []; + _this.referencedBy = []; + return _this; + } + ModuleBuilderFileInfo.compareFileInfos = function (lf, rf) { + var l = lf.scriptInfo.fileName; + var r = rf.scriptInfo.fileName; + return (l < r ? -1 : (l > r ? 1 : 0)); + }; + ; + ModuleBuilderFileInfo.addToReferenceList = function (array, fileInfo) { + if (array.length === 0) { + array.push(fileInfo); + return; + } + var insertIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); + if (insertIndex < 0) { + array.splice(~insertIndex, 0, fileInfo); + } + }; + ModuleBuilderFileInfo.removeFromReferenceList = function (array, fileInfo) { + if (!array || array.length === 0) { + return; + } + if (array[0] === fileInfo) { + array.splice(0, 1); + return; + } + var removeIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); + if (removeIndex >= 0) { + array.splice(removeIndex, 1); + } + }; + ModuleBuilderFileInfo.prototype.addReferencedBy = function (fileInfo) { + ModuleBuilderFileInfo.addToReferenceList(this.referencedBy, fileInfo); + }; + ModuleBuilderFileInfo.prototype.removeReferencedBy = function (fileInfo) { + ModuleBuilderFileInfo.removeFromReferenceList(this.referencedBy, fileInfo); + }; + ModuleBuilderFileInfo.prototype.removeFileReferences = function () { + for (var _i = 0, _a = this.references; _i < _a.length; _i++) { + var reference = _a[_i]; + reference.removeReferencedBy(this); + } + this.references = []; + }; + return ModuleBuilderFileInfo; + }(BuilderFileInfo)); + var ModuleBuilder = (function (_super) { + __extends(ModuleBuilder, _super); + function ModuleBuilder(project) { + var _this = _super.call(this, project, ModuleBuilderFileInfo) || this; + _this.project = project; + return _this; + } + ModuleBuilder.prototype.clear = function () { + this.projectVersionForDependencyGraph = undefined; + _super.prototype.clear.call(this); + }; + ModuleBuilder.prototype.getReferencedFileInfos = function (fileInfo) { + var _this = this; + if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { + return []; + } + var referencedFilePaths = this.project.getReferencedFiles(fileInfo.scriptInfo.path); + if (referencedFilePaths.length > 0) { + return ts.map(referencedFilePaths, function (f) { return _this.getOrCreateFileInfo(f); }).sort(ModuleBuilderFileInfo.compareFileInfos); + } + return []; + }; + ModuleBuilder.prototype.onProjectUpdateGraph = function () { + this.ensureProjectDependencyGraphUpToDate(); + }; + ModuleBuilder.prototype.ensureProjectDependencyGraphUpToDate = function () { + var _this = this; + if (!this.projectVersionForDependencyGraph || this.project.getProjectVersion() !== this.projectVersionForDependencyGraph) { + var currentScriptInfos = this.project.getScriptInfos(); + for (var _i = 0, currentScriptInfos_1 = currentScriptInfos; _i < currentScriptInfos_1.length; _i++) { + var scriptInfo = currentScriptInfos_1[_i]; + var fileInfo = this.getOrCreateFileInfo(scriptInfo.path); + this.updateFileReferences(fileInfo); + } + this.forEachFileInfo(function (fileInfo) { + if (!_this.project.containsScriptInfo(fileInfo.scriptInfo)) { + fileInfo.removeFileReferences(); + _this.removeFileInfo(fileInfo.scriptInfo.path); + } + }); + this.projectVersionForDependencyGraph = this.project.getProjectVersion(); + } + }; + ModuleBuilder.prototype.updateFileReferences = function (fileInfo) { + if (fileInfo.scriptVersionForReferences === fileInfo.scriptInfo.getLatestVersion()) { + return; + } + var newReferences = this.getReferencedFileInfos(fileInfo); + var oldReferences = fileInfo.references; + var oldIndex = 0; + var newIndex = 0; + while (oldIndex < oldReferences.length && newIndex < newReferences.length) { + var oldReference = oldReferences[oldIndex]; + var newReference = newReferences[newIndex]; + var compare = ModuleBuilderFileInfo.compareFileInfos(oldReference, newReference); + if (compare < 0) { + oldReference.removeReferencedBy(fileInfo); + oldIndex++; + } + else if (compare > 0) { + newReference.addReferencedBy(fileInfo); + newIndex++; + } + else { + oldIndex++; + newIndex++; + } + } + for (var i = oldIndex; i < oldReferences.length; i++) { + oldReferences[i].removeReferencedBy(fileInfo); + } + for (var i = newIndex; i < newReferences.length; i++) { + newReferences[i].addReferencedBy(fileInfo); + } + fileInfo.references = newReferences; + fileInfo.scriptVersionForReferences = fileInfo.scriptInfo.getLatestVersion(); + }; + ModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { + this.ensureProjectDependencyGraphUpToDate(); + var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + var fileInfo = this.getFileInfo(scriptInfo.path); + if (!fileInfo || !fileInfo.updateShapeSignature()) { + return singleFileResult; + } + if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { + return this.project.getAllEmittableFiles(); + } + var options = this.project.getCompilerOptions(); + if (options && (options.isolatedModules || options.out || options.outFile)) { + return singleFileResult; + } + var queue = fileInfo.referencedBy.slice(0); + var fileNameSet = ts.createMap(); + fileNameSet.set(scriptInfo.fileName, scriptInfo); + while (queue.length > 0) { + var processingFileInfo = queue.pop(); + if (processingFileInfo.updateShapeSignature() && processingFileInfo.referencedBy.length > 0) { + for (var _i = 0, _a = processingFileInfo.referencedBy; _i < _a.length; _i++) { + var potentialFileInfo = _a[_i]; + if (!fileNameSet.has(potentialFileInfo.scriptInfo.fileName)) { + queue.push(potentialFileInfo); + } + } + } + fileNameSet.set(processingFileInfo.scriptInfo.fileName, processingFileInfo.scriptInfo); + } + var result = []; + fileNameSet.forEach(function (scriptInfo, fileName) { + if (shouldEmitFile(scriptInfo)) { + result.push(fileName); + } + }); + return result; + }; + return ModuleBuilder; + }(AbstractBuilder)); + function createBuilder(project) { + var moduleKind = project.getCompilerOptions().module; + switch (moduleKind) { + case ts.ModuleKind.None: + return new NonModuleBuilder(project); + default: + return new ModuleBuilder(project); + } + } + server.createBuilder = createBuilder; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var ProjectKind; + (function (ProjectKind) { + ProjectKind[ProjectKind["Inferred"] = 0] = "Inferred"; + ProjectKind[ProjectKind["Configured"] = 1] = "Configured"; + ProjectKind[ProjectKind["External"] = 2] = "External"; + })(ProjectKind = server.ProjectKind || (server.ProjectKind = {})); + function remove(items, item) { + var index = items.indexOf(item); + if (index >= 0) { + items.splice(index, 1); + } + } + function countEachFileTypes(infos) { + var result = { js: 0, jsx: 0, ts: 0, tsx: 0, dts: 0 }; + for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { + var info = infos_1[_i]; + switch (info.scriptKind) { + case 1: + result.js += 1; + break; + case 2: + result.jsx += 1; + break; + case 3: + ts.fileExtensionIs(info.fileName, ".d.ts") + ? result.dts += 1 + : result.ts += 1; + break; + case 4: + result.tsx += 1; + break; + } + } + return result; + } + function hasOneOrMoreJsAndNoTsFiles(project) { + var counts = countEachFileTypes(project.getScriptInfos()); + return counts.js > 0 && counts.ts === 0 && counts.tsx === 0; + } + function allRootFilesAreJsOrDts(project) { + var counts = countEachFileTypes(project.getRootScriptInfos()); + return counts.ts === 0 && counts.tsx === 0; + } + server.allRootFilesAreJsOrDts = allRootFilesAreJsOrDts; + function allFilesAreJsOrDts(project) { + var counts = countEachFileTypes(project.getScriptInfos()); + return counts.ts === 0 && counts.tsx === 0; + } + server.allFilesAreJsOrDts = allFilesAreJsOrDts; + var UnresolvedImportsMap = (function () { + function UnresolvedImportsMap() { + this.perFileMap = ts.createFileMap(); + this.version = 0; + } + UnresolvedImportsMap.prototype.clear = function () { + this.perFileMap.clear(); + this.version = 0; + }; + UnresolvedImportsMap.prototype.getVersion = function () { + return this.version; + }; + UnresolvedImportsMap.prototype.remove = function (path) { + this.perFileMap.remove(path); + this.version++; + }; + UnresolvedImportsMap.prototype.get = function (path) { + return this.perFileMap.get(path); + }; + UnresolvedImportsMap.prototype.set = function (path, value) { + this.perFileMap.set(path, value); + this.version++; + }; + return UnresolvedImportsMap; + }()); + server.UnresolvedImportsMap = UnresolvedImportsMap; + var Project = (function () { + function Project(projectName, projectKind, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { + this.projectName = projectName; + this.projectKind = projectKind; + this.projectService = projectService; + this.documentRegistry = documentRegistry; + this.compilerOptions = compilerOptions; + this.compileOnSaveEnabled = compileOnSaveEnabled; + this.rootFiles = []; + this.rootFilesMap = ts.createFileMap(); + this.cachedUnresolvedImportsPerFile = new UnresolvedImportsMap(); + this.languageServiceEnabled = true; + this.lastReportedVersion = 0; + this.projectStructureVersion = 0; + this.projectStateVersion = 0; + this.typesVersion = 0; + if (!this.compilerOptions) { + this.compilerOptions = ts.getDefaultCompilerOptions(); + this.compilerOptions.allowNonTsExtensions = true; + this.compilerOptions.allowJs = true; + } + else if (hasExplicitListOfFiles || this.compilerOptions.allowJs) { + this.compilerOptions.allowNonTsExtensions = true; + } + this.setInternalCompilerOptionsForEmittingJsFiles(); + this.lsHost = new server.LSHost(this.projectService.host, this, this.projectService.cancellationToken); + this.lsHost.setCompilationSettings(this.compilerOptions); + this.languageService = ts.createLanguageService(this.lsHost, this.documentRegistry); + if (!languageServiceEnabled) { + this.disableLanguageService(); + } + this.builder = server.createBuilder(this); + this.markAsDirty(); + } + Project.prototype.isNonTsProject = function () { + this.updateGraph(); + return allFilesAreJsOrDts(this); + }; + Project.prototype.isJsOnlyProject = function () { + this.updateGraph(); + return hasOneOrMoreJsAndNoTsFiles(this); + }; + Project.prototype.getCachedUnresolvedImportsPerFile_TestOnly = function () { + return this.cachedUnresolvedImportsPerFile; + }; + Project.resolveModule = function (moduleName, initialDir, host, log) { + var resolvedPath = ts.normalizeSlashes(host.resolvePath(ts.combinePaths(initialDir, "node_modules"))); + log("Loading " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")"); + var result = host.require(resolvedPath, moduleName); + if (result.error) { + log("Failed to load module: " + JSON.stringify(result.error)); + return undefined; + } + return result.module; + }; + Project.prototype.setInternalCompilerOptionsForEmittingJsFiles = function () { + if (this.projectKind === ProjectKind.Inferred || this.projectKind === ProjectKind.External) { + this.compilerOptions.noEmitForJsFiles = true; + } + }; + Project.prototype.getProjectErrors = function () { + return this.projectErrors; + }; + Project.prototype.getLanguageService = function (ensureSynchronized) { + if (ensureSynchronized === void 0) { ensureSynchronized = true; } + if (ensureSynchronized) { + this.updateGraph(); + } + return this.languageService; + }; + Project.prototype.getCompileOnSaveAffectedFileList = function (scriptInfo) { + if (!this.languageServiceEnabled) { + return []; + } + this.updateGraph(); + return this.builder.getFilesAffectedBy(scriptInfo); + }; + Project.prototype.getProjectVersion = function () { + return this.projectStateVersion.toString(); + }; + Project.prototype.enableLanguageService = function () { + if (this.languageServiceEnabled) { + return; + } + this.languageServiceEnabled = true; + this.projectService.onUpdateLanguageServiceStateForProject(this, true); + }; + Project.prototype.disableLanguageService = function () { + if (!this.languageServiceEnabled) { + return; + } + this.languageService.cleanupSemanticCache(); + this.languageServiceEnabled = false; + this.projectService.onUpdateLanguageServiceStateForProject(this, false); + }; + Project.prototype.getProjectName = function () { + return this.projectName; + }; + Project.prototype.getExternalFiles = function () { + return []; + }; + Project.prototype.getSourceFile = function (path) { + if (!this.program) { + return undefined; + } + return this.program.getSourceFileByPath(path); + }; + Project.prototype.updateTypes = function () { + this.typesVersion++; + this.markAsDirty(); + this.updateGraph(); + }; + Project.prototype.close = function () { + if (this.program) { + for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { + var f = _a[_i]; + var info = this.projectService.getScriptInfo(f.fileName); + info.detachFromProject(this); + } + } + if (!this.program || !this.languageServiceEnabled) { + for (var _b = 0, _c = this.rootFiles; _b < _c.length; _b++) { + var root = _c[_b]; + root.detachFromProject(this); + } + } + this.rootFiles = undefined; + this.rootFilesMap = undefined; + this.program = undefined; + this.languageService.dispose(); + }; + Project.prototype.getCompilerOptions = function () { + return this.compilerOptions; + }; + Project.prototype.hasRoots = function () { + return this.rootFiles && this.rootFiles.length > 0; + }; + Project.prototype.getRootFiles = function () { + return this.rootFiles && this.rootFiles.map(function (info) { return info.fileName; }); + }; + Project.prototype.getRootFilesLSHost = function () { + var result = []; + if (this.rootFiles) { + for (var _i = 0, _a = this.rootFiles; _i < _a.length; _i++) { + var f = _a[_i]; + if (this.languageServiceEnabled || f.isScriptOpen()) { + result.push(f.fileName); + } + } + if (this.typingFiles) { + for (var _b = 0, _c = this.typingFiles; _b < _c.length; _b++) { + var f = _c[_b]; + result.push(f); + } + } + } + return result; + }; + Project.prototype.getRootScriptInfos = function () { + return this.rootFiles; + }; + Project.prototype.getScriptInfos = function () { + var _this = this; + if (!this.languageServiceEnabled) { + return this.rootFiles; + } + return ts.map(this.program.getSourceFiles(), function (sourceFile) { + var scriptInfo = _this.projectService.getScriptInfoForPath(sourceFile.path); + if (!scriptInfo) { + ts.Debug.assert(false, "scriptInfo for a file '" + sourceFile.fileName + "' is missing."); + } + return scriptInfo; + }); + }; + Project.prototype.getFileEmitOutput = function (info, emitOnlyDtsFiles) { + if (!this.languageServiceEnabled) { + return undefined; + } + return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles); + }; + Project.prototype.getFileNames = function (excludeFilesFromExternalLibraries) { + if (!this.program) { + return []; + } + if (!this.languageServiceEnabled) { + var rootFiles = this.getRootFiles(); + if (this.compilerOptions) { + var defaultLibrary = ts.getDefaultLibFilePath(this.compilerOptions); + if (defaultLibrary) { + (rootFiles || (rootFiles = [])).push(server.asNormalizedPath(defaultLibrary)); + } + } + return rootFiles; + } + var result = []; + for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { + var f = _a[_i]; + if (excludeFilesFromExternalLibraries && this.program.isSourceFileFromExternalLibrary(f)) { + continue; + } + result.push(server.asNormalizedPath(f.fileName)); + } + return result; + }; + Project.prototype.getAllEmittableFiles = function () { + if (!this.languageServiceEnabled) { + return []; + } + var defaultLibraryFileName = ts.getDefaultLibFileName(this.compilerOptions); + var infos = this.getScriptInfos(); + var result = []; + for (var _i = 0, infos_2 = infos; _i < infos_2.length; _i++) { + var info = infos_2[_i]; + if (ts.getBaseFileName(info.fileName) !== defaultLibraryFileName && server.shouldEmitFile(info)) { + result.push(info.fileName); + } + } + return result; + }; + Project.prototype.containsScriptInfo = function (info) { + return this.isRoot(info) || (this.program && this.program.getSourceFileByPath(info.path) !== undefined); + }; + Project.prototype.containsFile = function (filename, requireOpen) { + var info = this.projectService.getScriptInfoForNormalizedPath(filename); + if (info && (info.isScriptOpen() || !requireOpen)) { + return this.containsScriptInfo(info); + } + }; + Project.prototype.isRoot = function (info) { + return this.rootFilesMap && this.rootFilesMap.contains(info.path); + }; + Project.prototype.addRoot = function (info) { + if (!this.isRoot(info)) { + this.rootFiles.push(info); + this.rootFilesMap.set(info.path, info); + info.attachToProject(this); + this.markAsDirty(); + } + }; + Project.prototype.removeFile = function (info, detachFromProject) { + if (detachFromProject === void 0) { detachFromProject = true; } + if (this.isRoot(info)) { + this.removeRoot(info); + } + this.lsHost.notifyFileRemoved(info); + this.cachedUnresolvedImportsPerFile.remove(info.path); + if (detachFromProject) { + info.detachFromProject(this); + } + this.markAsDirty(); + }; + Project.prototype.registerFileUpdate = function (fileName) { + (this.updatedFileNames || (this.updatedFileNames = ts.createMap())).set(fileName, fileName); + }; + Project.prototype.markAsDirty = function () { + this.projectStateVersion++; + }; + Project.prototype.extractUnresolvedImportsFromSourceFile = function (file, result) { + var cached = this.cachedUnresolvedImportsPerFile.get(file.path); + if (cached) { + for (var _i = 0, cached_2 = cached; _i < cached_2.length; _i++) { + var f = cached_2[_i]; + result.push(f); + } + return; + } + var unresolvedImports; + if (file.resolvedModules) { + file.resolvedModules.forEach(function (resolvedModule, name) { + if (!resolvedModule && !ts.isExternalModuleNameRelative(name)) { + var trimmed = name.trim(); + var i = trimmed.indexOf("/"); + if (i !== -1 && trimmed.charCodeAt(0) === 64) { + i = trimmed.indexOf("/", i + 1); + } + if (i !== -1) { + trimmed = trimmed.substr(0, i); + } + (unresolvedImports || (unresolvedImports = [])).push(trimmed); + result.push(trimmed); + } + }); + } + this.cachedUnresolvedImportsPerFile.set(file.path, unresolvedImports || server.emptyArray); + }; + Project.prototype.updateGraph = function () { + this.lsHost.startRecordingFilesWithChangedResolutions(); + var hasChanges = this.updateGraphWorker(); + var changedFiles = this.lsHost.finishRecordingFilesWithChangedResolutions() || server.emptyArray; + for (var _i = 0, changedFiles_1 = changedFiles; _i < changedFiles_1.length; _i++) { + var file = changedFiles_1[_i]; + this.cachedUnresolvedImportsPerFile.remove(file); + } + var unresolvedImports; + if (hasChanges || changedFiles.length) { + var result = []; + for (var _a = 0, _b = this.program.getSourceFiles(); _a < _b.length; _a++) { + var sourceFile = _b[_a]; + this.extractUnresolvedImportsFromSourceFile(sourceFile, result); + } + this.lastCachedUnresolvedImportsList = server.toSortedReadonlyArray(result); + } + unresolvedImports = this.lastCachedUnresolvedImportsList; + var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, unresolvedImports, hasChanges); + if (this.setTypings(cachedTypings)) { + hasChanges = this.updateGraphWorker() || hasChanges; + } + if (this.languageServiceEnabled) { + this.builder.onProjectUpdateGraph(); + } + else { + this.builder.clear(); + } + if (hasChanges) { + this.projectStructureVersion++; + } + return !hasChanges; + }; + Project.prototype.setTypings = function (typings) { + if (ts.arrayIsEqualTo(this.typingFiles, typings)) { + return false; + } + this.typingFiles = typings; + this.markAsDirty(); + return true; + }; + Project.prototype.updateGraphWorker = function () { + var oldProgram = this.program; + this.program = this.languageService.getProgram(); + var hasChanges = false; + if (!oldProgram || (this.program !== oldProgram && !oldProgram.structureIsReused)) { + hasChanges = true; + if (oldProgram) { + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var f = _a[_i]; + if (this.program.getSourceFileByPath(f.path)) { + continue; + } + var scriptInfoToDetach = this.projectService.getScriptInfo(f.fileName); + if (scriptInfoToDetach) { + scriptInfoToDetach.detachFromProject(this); + } + } + } + } + return hasChanges; + }; + Project.prototype.getScriptInfoLSHost = function (fileName) { + var scriptInfo = this.projectService.getOrCreateScriptInfo(fileName, false); + if (scriptInfo) { + scriptInfo.attachToProject(this); + } + return scriptInfo; + }; + Project.prototype.getScriptInfoForNormalizedPath = function (fileName) { + var scriptInfo = this.projectService.getOrCreateScriptInfoForNormalizedPath(fileName, false); + if (scriptInfo && !scriptInfo.isAttached(this)) { + return server.Errors.ThrowProjectDoesNotContainDocument(fileName, this); + } + return scriptInfo; + }; + Project.prototype.getScriptInfo = function (uncheckedFileName) { + return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); + }; + Project.prototype.filesToString = function () { + if (!this.program) { + return ""; + } + var strBuilder = ""; + for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { + var file = _a[_i]; + strBuilder += file.fileName + "\n"; + } + return strBuilder; + }; + Project.prototype.setCompilerOptions = function (compilerOptions) { + if (compilerOptions) { + compilerOptions.allowNonTsExtensions = true; + if (ts.changesAffectModuleResolution(this.compilerOptions, compilerOptions)) { + this.cachedUnresolvedImportsPerFile.clear(); + this.lastCachedUnresolvedImportsList = undefined; + } + this.compilerOptions = compilerOptions; + this.setInternalCompilerOptionsForEmittingJsFiles(); + this.lsHost.setCompilationSettings(compilerOptions); + this.markAsDirty(); + } + }; + Project.prototype.reloadScript = function (filename, tempFileName) { + var script = this.projectService.getScriptInfoForNormalizedPath(filename); + if (script) { + ts.Debug.assert(script.isAttached(this)); + script.reloadFromFile(tempFileName); + return true; + } + return false; + }; + Project.prototype.getChangesSinceVersion = function (lastKnownVersion) { + this.updateGraph(); + var info = { + projectName: this.getProjectName(), + version: this.projectStructureVersion, + isInferred: this.projectKind === ProjectKind.Inferred, + options: this.getCompilerOptions(), + languageServiceDisabled: !this.languageServiceEnabled + }; + var updatedFileNames = this.updatedFileNames; + this.updatedFileNames = undefined; + if (this.lastReportedFileNames && lastKnownVersion === this.lastReportedVersion) { + if (this.projectStructureVersion == this.lastReportedVersion && !updatedFileNames) { + return { info: info, projectErrors: this.projectErrors }; + } + var lastReportedFileNames_1 = this.lastReportedFileNames; + var currentFiles_1 = ts.arrayToMap(this.getFileNames(), function (x) { return x; }); + var added_1 = []; + var removed_1 = []; + var updated = ts.arrayFrom(updatedFileNames.keys()); + ts.forEachKey(currentFiles_1, function (id) { + if (!lastReportedFileNames_1.has(id)) { + added_1.push(id); + } + }); + ts.forEachKey(lastReportedFileNames_1, function (id) { + if (!currentFiles_1.has(id)) { + removed_1.push(id); + } + }); + this.lastReportedFileNames = currentFiles_1; + this.lastReportedVersion = this.projectStructureVersion; + return { info: info, changes: { added: added_1, removed: removed_1, updated: updated }, projectErrors: this.projectErrors }; + } + else { + var projectFileNames = this.getFileNames(); + this.lastReportedFileNames = ts.arrayToMap(projectFileNames, function (x) { return x; }); + this.lastReportedVersion = this.projectStructureVersion; + return { info: info, files: projectFileNames, projectErrors: this.projectErrors }; + } + }; + Project.prototype.getReferencedFiles = function (path) { + var _this = this; + if (!this.languageServiceEnabled) { + return []; + } + var sourceFile = this.getSourceFile(path); + if (!sourceFile) { + return []; + } + var referencedFiles = ts.createMap(); + if (sourceFile.imports && sourceFile.imports.length > 0) { + var checker = this.program.getTypeChecker(); + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var importName = _a[_i]; + var symbol = checker.getSymbolAtLocation(importName); + if (symbol && symbol.declarations && symbol.declarations[0]) { + var declarationSourceFile = symbol.declarations[0].getSourceFile(); + if (declarationSourceFile) { + referencedFiles.set(declarationSourceFile.path, true); + } + } + } + } + var currentDirectory = ts.getDirectoryPath(path); + var getCanonicalFileName = ts.createGetCanonicalFileName(this.projectService.host.useCaseSensitiveFileNames); + if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) { + for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) { + var referencedFile = _c[_b]; + var referencedPath = ts.toPath(referencedFile.fileName, currentDirectory, getCanonicalFileName); + referencedFiles.set(referencedPath, true); + } + } + if (sourceFile.resolvedTypeReferenceDirectiveNames) { + sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (resolvedTypeReferenceDirective) { + if (!resolvedTypeReferenceDirective) { + return; + } + var fileName = resolvedTypeReferenceDirective.resolvedFileName; + var typeFilePath = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + referencedFiles.set(typeFilePath, true); + }); + } + var allFileNames = ts.arrayFrom(referencedFiles.keys()); + return ts.filter(allFileNames, function (file) { return _this.projectService.host.fileExists(file); }); + }; + Project.prototype.removeRoot = function (info) { + remove(this.rootFiles, info); + this.rootFilesMap.remove(info.path); + }; + return Project; + }()); + server.Project = Project; + var InferredProject = (function (_super) { + __extends(InferredProject, _super); + function InferredProject(projectService, documentRegistry, compilerOptions) { + var _this = _super.call(this, InferredProject.newName(), ProjectKind.Inferred, projectService, documentRegistry, undefined, true, compilerOptions, false) || this; + _this._isJsInferredProject = false; + _this.directoriesWatchedForTsconfig = []; + return _this; + } + InferredProject.prototype.toggleJsInferredProject = function (isJsInferredProject) { + if (isJsInferredProject !== this._isJsInferredProject) { + this._isJsInferredProject = isJsInferredProject; + this.setCompilerOptions(); + } + }; + InferredProject.prototype.setCompilerOptions = function (options) { + var newOptions = options ? ts.clone(options) : this.getCompilerOptions(); + if (!newOptions) { + return; + } + if (this._isJsInferredProject && typeof newOptions.maxNodeModuleJsDepth !== "number") { + newOptions.maxNodeModuleJsDepth = 2; + } + else if (!this._isJsInferredProject) { + newOptions.maxNodeModuleJsDepth = undefined; + } + newOptions.allowJs = true; + _super.prototype.setCompilerOptions.call(this, newOptions); + }; + InferredProject.prototype.addRoot = function (info) { + if (!this._isJsInferredProject && info.isJavaScript()) { + this.toggleJsInferredProject(true); + } + _super.prototype.addRoot.call(this, info); + }; + InferredProject.prototype.removeRoot = function (info) { + if (this._isJsInferredProject && info.isJavaScript()) { + if (ts.filter(this.getRootScriptInfos(), function (info) { return info.isJavaScript(); }).length === 0) { + this.toggleJsInferredProject(false); + } + } + _super.prototype.removeRoot.call(this, info); + }; + InferredProject.prototype.getProjectRootPath = function () { + if (this.projectService.useSingleInferredProject) { + return undefined; + } + var rootFiles = this.getRootFiles(); + return ts.getDirectoryPath(rootFiles[0]); + }; + InferredProject.prototype.close = function () { + _super.prototype.close.call(this); + for (var _i = 0, _a = this.directoriesWatchedForTsconfig; _i < _a.length; _i++) { + var directory = _a[_i]; + this.projectService.stopWatchingDirectory(directory); + } + }; + InferredProject.prototype.getTypeAcquisition = function () { + return { + enable: allRootFilesAreJsOrDts(this), + include: [], + exclude: [] + }; + }; + return InferredProject; + }(Project)); + InferredProject.newName = (function () { + var nextId = 1; + return function () { + var id = nextId; + nextId++; + return server.makeInferredProjectName(id); + }; + })(); + server.InferredProject = InferredProject; + var ConfiguredProject = (function (_super) { + __extends(ConfiguredProject, _super); + function ConfiguredProject(configFileName, projectService, documentRegistry, hasExplicitListOfFiles, compilerOptions, wildcardDirectories, languageServiceEnabled, compileOnSaveEnabled) { + var _this = _super.call(this, configFileName, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.configFileName = configFileName; + _this.wildcardDirectories = wildcardDirectories; + _this.compileOnSaveEnabled = compileOnSaveEnabled; + _this.plugins = []; + _this.openRefCount = 0; + _this.canonicalConfigFilePath = server.asNormalizedPath(projectService.toCanonicalFileName(configFileName)); + _this.enablePlugins(); + return _this; + } + ConfiguredProject.prototype.getConfigFilePath = function () { + return this.getProjectName(); + }; + ConfiguredProject.prototype.enablePlugins = function () { + var _this = this; + var host = this.projectService.host; + var options = this.getCompilerOptions(); + var log = function (message) { + _this.projectService.logger.info(message); + }; + if (!(options.plugins && options.plugins.length)) { + this.projectService.logger.info("No plugins exist"); + return; + } + if (!host.require) { + this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); + return; + } + for (var _i = 0, _a = options.plugins; _i < _a.length; _i++) { + var pluginConfigEntry = _a[_i]; + var searchPath = ts.getDirectoryPath(this.configFileName); + var resolvedModule = Project.resolveModule(pluginConfigEntry.name, searchPath, host, log); + if (resolvedModule) { + this.enableProxy(resolvedModule, pluginConfigEntry); + } + } + }; + ConfiguredProject.prototype.enableProxy = function (pluginModuleFactory, configEntry) { + try { + if (typeof pluginModuleFactory !== "function") { + this.projectService.logger.info("Skipped loading plugin " + configEntry.name + " because it did expose a proper factory function"); + return; + } + var info = { + config: configEntry, + project: this, + languageService: this.languageService, + languageServiceHost: this.lsHost, + serverHost: this.projectService.host + }; + var pluginModule = pluginModuleFactory({ typescript: ts }); + this.languageService = pluginModule.create(info); + this.plugins.push(pluginModule); + } + catch (e) { + this.projectService.logger.info("Plugin activation failed: " + e); + } + }; + ConfiguredProject.prototype.getProjectRootPath = function () { + return ts.getDirectoryPath(this.getConfigFilePath()); + }; + ConfiguredProject.prototype.setProjectErrors = function (projectErrors) { + this.projectErrors = projectErrors; + }; + ConfiguredProject.prototype.setTypeAcquisition = function (newTypeAcquisition) { + this.typeAcquisition = newTypeAcquisition; + }; + ConfiguredProject.prototype.getTypeAcquisition = function () { + return this.typeAcquisition; + }; + ConfiguredProject.prototype.getExternalFiles = function () { + var items = []; + for (var _i = 0, _a = this.plugins; _i < _a.length; _i++) { + var plugin = _a[_i]; + if (typeof plugin.getExternalFiles === "function") { + try { + items.push.apply(items, plugin.getExternalFiles(this)); + } + catch (e) { + this.projectService.logger.info("A plugin threw an exception in getExternalFiles: " + e); + } + } + } + return items; + }; + ConfiguredProject.prototype.watchConfigFile = function (callback) { + var _this = this; + this.projectFileWatcher = this.projectService.host.watchFile(this.getConfigFilePath(), function (_) { return callback(_this); }); + }; + ConfiguredProject.prototype.watchTypeRoots = function (callback) { + var _this = this; + var roots = this.getEffectiveTypeRoots(); + var watchers = []; + for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { + var root = roots_1[_i]; + this.projectService.logger.info("Add type root watcher for: " + root); + watchers.push(this.projectService.host.watchDirectory(root, function (path) { return callback(_this, path); }, false)); + } + this.typeRootsWatchers = watchers; + }; + ConfiguredProject.prototype.watchConfigDirectory = function (callback) { + var _this = this; + if (this.directoryWatcher) { + return; + } + var directoryToWatch = ts.getDirectoryPath(this.getConfigFilePath()); + this.projectService.logger.info("Add recursive watcher for: " + directoryToWatch); + this.directoryWatcher = this.projectService.host.watchDirectory(directoryToWatch, function (path) { return callback(_this, path); }, true); + }; + ConfiguredProject.prototype.watchWildcards = function (callback) { + var _this = this; + if (!this.wildcardDirectories) { + return; + } + var configDirectoryPath = ts.getDirectoryPath(this.getConfigFilePath()); + this.directoriesWatchedForWildcards = ts.createMap(); + this.wildcardDirectories.forEach(function (flag, directory) { + if (ts.comparePaths(configDirectoryPath, directory, ".", !_this.projectService.host.useCaseSensitiveFileNames) !== 0) { + var recursive = (flag & 1) !== 0; + _this.projectService.logger.info("Add " + (recursive ? "recursive " : "") + "watcher for: " + directory); + _this.directoriesWatchedForWildcards.set(directory, _this.projectService.host.watchDirectory(directory, function (path) { return callback(_this, path); }, recursive)); + } + }); + }; + ConfiguredProject.prototype.stopWatchingDirectory = function () { + if (this.directoryWatcher) { + this.directoryWatcher.close(); + this.directoryWatcher = undefined; + } + }; + ConfiguredProject.prototype.close = function () { + _super.prototype.close.call(this); + if (this.projectFileWatcher) { + this.projectFileWatcher.close(); + } + if (this.typeRootsWatchers) { + for (var _i = 0, _a = this.typeRootsWatchers; _i < _a.length; _i++) { + var watcher = _a[_i]; + watcher.close(); + } + this.typeRootsWatchers = undefined; + } + this.directoriesWatchedForWildcards.forEach(function (watcher) { + watcher.close(); + }); + this.directoriesWatchedForWildcards = undefined; + this.stopWatchingDirectory(); + }; + ConfiguredProject.prototype.addOpenRef = function () { + this.openRefCount++; + }; + ConfiguredProject.prototype.deleteOpenRef = function () { + this.openRefCount--; + return this.openRefCount; + }; + ConfiguredProject.prototype.getEffectiveTypeRoots = function () { + return ts.getEffectiveTypeRoots(this.getCompilerOptions(), this.projectService.host) || []; + }; + return ConfiguredProject; + }(Project)); + server.ConfiguredProject = ConfiguredProject; + var ExternalProject = (function (_super) { + __extends(ExternalProject, _super); + function ExternalProject(externalProjectName, projectService, documentRegistry, compilerOptions, languageServiceEnabled, compileOnSaveEnabled, projectFilePath) { + var _this = _super.call(this, externalProjectName, ProjectKind.External, projectService, documentRegistry, true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.compileOnSaveEnabled = compileOnSaveEnabled; + _this.projectFilePath = projectFilePath; + return _this; + } + ExternalProject.prototype.getProjectRootPath = function () { + if (this.projectFilePath) { + return ts.getDirectoryPath(this.projectFilePath); + } + return ts.getDirectoryPath(ts.normalizeSlashes(this.getProjectName())); + }; + ExternalProject.prototype.getTypeAcquisition = function () { + return this.typeAcquisition; + }; + ExternalProject.prototype.setProjectErrors = function (projectErrors) { + this.projectErrors = projectErrors; + }; + ExternalProject.prototype.setTypeAcquisition = function (newTypeAcquisition) { + if (!newTypeAcquisition) { + newTypeAcquisition = { + enable: allRootFilesAreJsOrDts(this), + include: [], + exclude: [] + }; + } + else { + if (newTypeAcquisition.enable === undefined) { + newTypeAcquisition.enable = allRootFilesAreJsOrDts(this); + } + if (!newTypeAcquisition.include) { + newTypeAcquisition.include = []; + } + if (!newTypeAcquisition.exclude) { + newTypeAcquisition.exclude = []; + } + } + this.typeAcquisition = newTypeAcquisition; + }; + return ExternalProject; + }(Project)); + server.ExternalProject = ExternalProject; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; + server.ContextEvent = "context"; + server.ConfigFileDiagEvent = "configFileDiag"; + server.ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; + function prepareConvertersForEnumLikeCompilerOptions(commandLineOptions) { + var map = ts.createMap(); + for (var _i = 0, commandLineOptions_1 = commandLineOptions; _i < commandLineOptions_1.length; _i++) { + var option = commandLineOptions_1[_i]; + if (typeof option.type === "object") { + var optionMap = option.type; + optionMap.forEach(function (value) { + ts.Debug.assert(typeof value === "number"); + }); + map.set(option.name, optionMap); + } + } + return map; + } + var compilerOptionConverters = prepareConvertersForEnumLikeCompilerOptions(ts.optionDeclarations); + var indentStyle = ts.createMapFromTemplate({ + "none": ts.IndentStyle.None, + "block": ts.IndentStyle.Block, + "smart": ts.IndentStyle.Smart + }); + function convertFormatOptions(protocolOptions) { + if (typeof protocolOptions.indentStyle === "string") { + protocolOptions.indentStyle = indentStyle.get(protocolOptions.indentStyle.toLowerCase()); + ts.Debug.assert(protocolOptions.indentStyle !== undefined); + } + return protocolOptions; + } + server.convertFormatOptions = convertFormatOptions; + function convertCompilerOptions(protocolOptions) { + compilerOptionConverters.forEach(function (mappedValues, id) { + var propertyValue = protocolOptions[id]; + if (typeof propertyValue === "string") { + protocolOptions[id] = mappedValues.get(propertyValue.toLowerCase()); + } + }); + return protocolOptions; + } + server.convertCompilerOptions = convertCompilerOptions; + function tryConvertScriptKindName(scriptKindName) { + return typeof scriptKindName === "string" + ? convertScriptKindName(scriptKindName) + : scriptKindName; + } + server.tryConvertScriptKindName = tryConvertScriptKindName; + function convertScriptKindName(scriptKindName) { + switch (scriptKindName) { + case "JS": + return 1; + case "JSX": + return 2; + case "TS": + return 3; + case "TSX": + return 4; + default: + return 0; + } + } + server.convertScriptKindName = convertScriptKindName; + function combineProjectOutput(projects, action, comparer, areEqual) { + var result = projects.reduce(function (previous, current) { return ts.concatenate(previous, action(current)); }, []).sort(comparer); + return projects.length > 1 ? ts.deduplicate(result, areEqual) : result; + } + server.combineProjectOutput = combineProjectOutput; + var fileNamePropertyReader = { + getFileName: function (x) { return x; }, + getScriptKind: function (_) { return undefined; }, + hasMixedContent: function (fileName, extraFileExtensions) { + var mixedContentExtensions = ts.map(ts.filter(extraFileExtensions, function (item) { return item.isMixedContent; }), function (item) { return item.extension; }); + return ts.forEach(mixedContentExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); }); + } + }; + var externalFilePropertyReader = { + getFileName: function (x) { return x.fileName; }, + getScriptKind: function (x) { return tryConvertScriptKindName(x.scriptKind); }, + hasMixedContent: function (x) { return x.hasMixedContent; } + }; + function findProjectByName(projectName, projects) { + for (var _i = 0, projects_2 = projects; _i < projects_2.length; _i++) { + var proj = projects_2[_i]; + if (proj.getProjectName() === projectName) { + return proj; + } + } + } + function createFileNotFoundDiagnostic(fileName) { + return ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName); + } + function isRootFileInInferredProject(info) { + if (info.containingProjects.length === 0) { + return false; + } + return info.containingProjects[0].projectKind === server.ProjectKind.Inferred && info.containingProjects[0].isRoot(info); + } + var DirectoryWatchers = (function () { + function DirectoryWatchers(projectService) { + this.projectService = projectService; + this.directoryWatchersForTsconfig = ts.createMap(); + this.directoryWatchersRefCount = ts.createMap(); + } + DirectoryWatchers.prototype.stopWatchingDirectory = function (directory) { + var refCount = this.directoryWatchersRefCount.get(directory) - 1; + this.directoryWatchersRefCount.set(directory, refCount); + if (refCount === 0) { + this.projectService.logger.info("Close directory watcher for: " + directory); + this.directoryWatchersForTsconfig.get(directory).close(); + this.directoryWatchersForTsconfig.delete(directory); + } + }; + DirectoryWatchers.prototype.startWatchingContainingDirectoriesForFile = function (fileName, project, callback) { + var currentPath = ts.getDirectoryPath(fileName); + var parentPath = ts.getDirectoryPath(currentPath); + while (currentPath != parentPath) { + if (!this.directoryWatchersForTsconfig.has(currentPath)) { + this.projectService.logger.info("Add watcher for: " + currentPath); + this.directoryWatchersForTsconfig.set(currentPath, this.projectService.host.watchDirectory(currentPath, callback)); + this.directoryWatchersRefCount.set(currentPath, 1); + } + else { + this.directoryWatchersRefCount.set(currentPath, this.directoryWatchersRefCount.get(currentPath) + 1); + } + project.directoriesWatchedForTsconfig.push(currentPath); + currentPath = parentPath; + parentPath = ts.getDirectoryPath(parentPath); + } + }; + return DirectoryWatchers; + }()); + var ProjectService = (function () { + function ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, eventHandler) { + if (typingsInstaller === void 0) { typingsInstaller = server.nullTypingsInstaller; } + this.host = host; + this.logger = logger; + this.cancellationToken = cancellationToken; + this.useSingleInferredProject = useSingleInferredProject; + this.typingsInstaller = typingsInstaller; + this.eventHandler = eventHandler; + this.filenameToScriptInfo = ts.createFileMap(); + this.externalProjectToConfiguredProjectMap = ts.createMap(); + this.externalProjects = []; + this.inferredProjects = []; + this.configuredProjects = []; + this.openFiles = []; + ts.Debug.assert(!!host.createHash, "'ServerHost.createHash' is required for ProjectService"); + this.toCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + this.directoryWatchers = new DirectoryWatchers(this); + this.throttledOperations = new server.ThrottledOperations(host); + this.typingsInstaller.attach(this); + this.typingsCache = new server.TypingsCache(this.typingsInstaller); + this.hostConfiguration = { + formatCodeOptions: server.getDefaultFormatCodeSettings(this.host), + hostInfo: "Unknown host", + extraFileExtensions: [] + }; + this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory()); + } + ProjectService.prototype.getChangedFiles_TestOnly = function () { + return this.changedFiles; + }; + ProjectService.prototype.ensureInferredProjectsUpToDate_TestOnly = function () { + this.ensureInferredProjectsUpToDate(); + }; + ProjectService.prototype.getCompilerOptionsForInferredProjects = function () { + return this.compilerOptionsForInferredProjects; + }; + ProjectService.prototype.onUpdateLanguageServiceStateForProject = function (project, languageServiceEnabled) { + if (!this.eventHandler) { + return; + } + this.eventHandler({ + eventName: server.ProjectLanguageServiceStateEvent, + data: { project: project, languageServiceEnabled: languageServiceEnabled } + }); + }; + ProjectService.prototype.updateTypingsForProject = function (response) { + var project = this.findProject(response.projectName); + if (!project) { + return; + } + switch (response.kind) { + case server.ActionSet: + this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typeAcquisition, response.unresolvedImports, response.typings); + break; + case server.ActionInvalidate: + this.typingsCache.deleteTypingsForProject(response.projectName); + break; + } + project.updateGraph(); + }; + ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions) { + this.compilerOptionsForInferredProjects = convertCompilerOptions(projectCompilerOptions); + this.compilerOptionsForInferredProjects.allowNonTsExtensions = true; + this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave; + for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { + var proj = _a[_i]; + proj.setCompilerOptions(this.compilerOptionsForInferredProjects); + proj.compileOnSaveEnabled = projectCompilerOptions.compileOnSave; + } + this.updateProjectGraphs(this.inferredProjects); + }; + ProjectService.prototype.stopWatchingDirectory = function (directory) { + this.directoryWatchers.stopWatchingDirectory(directory); + }; + ProjectService.prototype.findProject = function (projectName) { + if (projectName === undefined) { + return undefined; + } + if (server.isInferredProjectName(projectName)) { + this.ensureInferredProjectsUpToDate(); + return findProjectByName(projectName, this.inferredProjects); + } + return this.findExternalProjectByProjectName(projectName) || this.findConfiguredProjectByProjectName(server.toNormalizedPath(projectName)); + }; + ProjectService.prototype.getDefaultProjectForFile = function (fileName, refreshInferredProjects) { + if (refreshInferredProjects) { + this.ensureInferredProjectsUpToDate(); + } + var scriptInfo = this.getScriptInfoForNormalizedPath(fileName); + return scriptInfo && scriptInfo.getDefaultProject(); + }; + ProjectService.prototype.ensureInferredProjectsUpToDate = function () { + if (this.changedFiles) { + var projectsToUpdate = void 0; + if (this.changedFiles.length === 1) { + projectsToUpdate = this.changedFiles[0].containingProjects; + } + else { + projectsToUpdate = []; + for (var _i = 0, _a = this.changedFiles; _i < _a.length; _i++) { + var f = _a[_i]; + projectsToUpdate = projectsToUpdate.concat(f.containingProjects); + } + } + this.updateProjectGraphs(projectsToUpdate); + this.changedFiles = undefined; + } + }; + ProjectService.prototype.findContainingExternalProject = function (fileName) { + for (var _i = 0, _a = this.externalProjects; _i < _a.length; _i++) { + var proj = _a[_i]; + if (proj.containsFile(fileName)) { + return proj; + } + } + return undefined; + }; + ProjectService.prototype.getFormatCodeOptions = function (file) { + var formatCodeSettings; + if (file) { + var info = this.getScriptInfoForNormalizedPath(file); + if (info) { + formatCodeSettings = info.getFormatCodeSettings(); + } + } + return formatCodeSettings || this.hostConfiguration.formatCodeOptions; + }; + ProjectService.prototype.updateProjectGraphs = function (projects) { + var shouldRefreshInferredProjects = false; + for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { + var p = projects_3[_i]; + if (!p.updateGraph()) { + shouldRefreshInferredProjects = true; + } + } + if (shouldRefreshInferredProjects) { + this.refreshInferredProjects(); + } + }; + ProjectService.prototype.onSourceFileChanged = function (fileName) { + var info = this.getScriptInfoForNormalizedPath(fileName); + if (!info) { + this.logger.info("Error: got watch notification for unknown file: " + fileName); + return; + } + if (!this.host.fileExists(fileName)) { + this.handleDeletedFile(info); + } + else { + if (info && (!info.isScriptOpen())) { + info.reloadFromFile(); + this.updateProjectGraphs(info.containingProjects); + } + } + }; + ProjectService.prototype.handleDeletedFile = function (info) { + this.logger.info(info.fileName + " deleted"); + info.stopWatcher(); + if (!info.isScriptOpen()) { + this.filenameToScriptInfo.remove(info.path); + this.lastDeletedFile = info; + var containingProjects = info.containingProjects.slice(); + info.detachAllProjects(); + this.updateProjectGraphs(containingProjects); + this.lastDeletedFile = undefined; + if (!this.eventHandler) { + return; + } + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var openFile = _a[_i]; + this.eventHandler({ + eventName: server.ContextEvent, + data: { project: openFile.getDefaultProject(), fileName: openFile.fileName } + }); + } + } + this.printProjects(); + }; + ProjectService.prototype.onTypeRootFileChanged = function (project, fileName) { + var _this = this; + this.logger.info("Type root file " + fileName + " changed"); + this.throttledOperations.schedule(project.getConfigFilePath() + " * type root", 250, function () { + project.updateTypes(); + _this.updateConfiguredProject(project); + _this.refreshInferredProjects(); + }); + }; + ProjectService.prototype.onSourceFileInDirectoryChangedForConfiguredProject = function (project, fileName) { + var _this = this; + if (fileName && !ts.isSupportedSourceFileName(fileName, project.getCompilerOptions(), this.hostConfiguration.extraFileExtensions)) { + return; + } + this.logger.info("Detected source file changes: " + fileName); + this.throttledOperations.schedule(project.getConfigFilePath(), 250, function () { return _this.handleChangeInSourceFileForConfiguredProject(project, fileName); }); + }; + ProjectService.prototype.handleChangeInSourceFileForConfiguredProject = function (project, triggerFile) { + var _this = this; + var _a = this.convertConfigFileContentToProjectOptions(project.getConfigFilePath()), projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; + this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors, triggerFile); + var newRootFiles = projectOptions.files.map((function (f) { return _this.getCanonicalFileName(f); })); + var currentRootFiles = project.getRootFiles().map((function (f) { return _this.getCanonicalFileName(f); })); + if (!ts.arrayIsEqualTo(currentRootFiles.sort(), newRootFiles.sort())) { + this.logger.info("Updating configured project"); + this.updateConfiguredProject(project); + this.refreshInferredProjects(); + } + }; + ProjectService.prototype.onConfigChangedForConfiguredProject = function (project) { + var configFileName = project.getConfigFilePath(); + this.logger.info("Config file changed: " + configFileName); + var configFileErrors = this.updateConfiguredProject(project); + this.reportConfigFileDiagnostics(configFileName, configFileErrors, configFileName); + this.refreshInferredProjects(); + }; + ProjectService.prototype.onConfigFileAddedForInferredProject = function (fileName) { + if (ts.getBaseFileName(fileName) != "tsconfig.json") { + this.logger.info(fileName + " is not tsconfig.json"); + return; + } + var configFileErrors = this.convertConfigFileContentToProjectOptions(fileName).configFileErrors; + this.reportConfigFileDiagnostics(fileName, configFileErrors, fileName); + this.logger.info("Detected newly added tsconfig file: " + fileName); + this.reloadProjects(); + }; + ProjectService.prototype.getCanonicalFileName = function (fileName) { + var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + return ts.normalizePath(name); + }; + ProjectService.prototype.removeProject = function (project) { + this.logger.info("remove project: " + project.getRootFiles().toString()); + project.close(); + switch (project.projectKind) { + case server.ProjectKind.External: + server.removeItemFromSet(this.externalProjects, project); + break; + case server.ProjectKind.Configured: + server.removeItemFromSet(this.configuredProjects, project); + break; + case server.ProjectKind.Inferred: + server.removeItemFromSet(this.inferredProjects, project); + break; + } + }; + ProjectService.prototype.assignScriptInfoToInferredProjectIfNecessary = function (info, addToListOfOpenFiles) { + var externalProject = this.findContainingExternalProject(info.fileName); + if (externalProject) { + if (addToListOfOpenFiles) { + this.openFiles.push(info); + } + return; + } + var foundConfiguredProject = false; + for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.projectKind === server.ProjectKind.Configured) { + foundConfiguredProject = true; + if (addToListOfOpenFiles) { + (p).addOpenRef(); + } + } + } + if (foundConfiguredProject) { + if (addToListOfOpenFiles) { + this.openFiles.push(info); + } + return; + } + if (info.containingProjects.length === 0) { + var inferredProject = this.createInferredProjectWithRootFileIfNecessary(info); + if (!this.useSingleInferredProject) { + for (var _b = 0, _c = this.openFiles; _b < _c.length; _b++) { + var f = _c[_b]; + if (f.containingProjects.length === 0) { + continue; + } + var defaultProject = f.getDefaultProject(); + if (isRootFileInInferredProject(info) && defaultProject !== inferredProject && inferredProject.containsScriptInfo(f)) { + this.removeProject(defaultProject); + f.attachToProject(inferredProject); + } + } + } + } + if (addToListOfOpenFiles) { + this.openFiles.push(info); + } + }; + ProjectService.prototype.closeOpenFile = function (info) { + info.close(); + server.removeItemFromSet(this.openFiles, info); + var projectsToRemove; + for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.projectKind === server.ProjectKind.Configured) { + if (info.hasMixedContent) { + info.registerFileUpdate(); + } + if (p.deleteOpenRef() === 0) { + (projectsToRemove || (projectsToRemove = [])).push(p); + } + } + else if (p.projectKind === server.ProjectKind.Inferred && p.isRoot(info)) { + (projectsToRemove || (projectsToRemove = [])).push(p); + } + if (!p.languageServiceEnabled) { + p.markAsDirty(); + } + } + if (projectsToRemove) { + for (var _b = 0, projectsToRemove_1 = projectsToRemove; _b < projectsToRemove_1.length; _b++) { + var project = projectsToRemove_1[_b]; + this.removeProject(project); + } + var orphanFiles = void 0; + for (var _c = 0, _d = this.openFiles; _c < _d.length; _c++) { + var f = _d[_c]; + if (f.containingProjects.length === 0) { + (orphanFiles || (orphanFiles = [])).push(f); + } + } + if (orphanFiles) { + for (var _e = 0, orphanFiles_1 = orphanFiles; _e < orphanFiles_1.length; _e++) { + var f = orphanFiles_1[_e]; + this.assignScriptInfoToInferredProjectIfNecessary(f, false); + } + } + } + if (info.containingProjects.length === 0) { + this.filenameToScriptInfo.remove(info.path); + } + }; + ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { + var searchPath = ts.getDirectoryPath(fileName); + this.logger.info("Search path: " + searchPath); + var configFileName = this.findConfigFile(server.asNormalizedPath(searchPath)); + if (!configFileName) { + this.logger.info("No config files found."); + return {}; + } + this.logger.info("Config file name: " + configFileName); + var project = this.findConfiguredProjectByProjectName(configFileName); + if (!project) { + var _a = this.openConfigFile(configFileName, fileName), success = _a.success, errors = _a.errors; + if (!success) { + return { configFileName: configFileName, configFileErrors: errors }; + } + this.logger.info("Opened configuration file " + configFileName); + if (errors && errors.length > 0) { + return { configFileName: configFileName, configFileErrors: errors }; + } + } + else { + this.updateConfiguredProject(project); + } + return { configFileName: configFileName }; + }; + ProjectService.prototype.findConfigFile = function (searchPath) { + while (true) { + var tsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "tsconfig.json")); + if (this.host.fileExists(tsconfigFileName)) { + return tsconfigFileName; + } + var jsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "jsconfig.json")); + if (this.host.fileExists(jsconfigFileName)) { + return jsconfigFileName; + } + var parentPath = server.asNormalizedPath(ts.getDirectoryPath(searchPath)); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return undefined; + }; + ProjectService.prototype.printProjects = function () { + if (!this.logger.hasLevel(server.LogLevel.verbose)) { + return; + } + this.logger.startGroup(); + var counter = 0; + counter = printProjects(this.logger, this.externalProjects, counter); + counter = printProjects(this.logger, this.configuredProjects, counter); + counter = printProjects(this.logger, this.inferredProjects, counter); + this.logger.info("Open files: "); + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var rootFile = _a[_i]; + this.logger.info(rootFile.fileName); + } + this.logger.endGroup(); + function printProjects(logger, projects, counter) { + for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { + var project = projects_4[_i]; + project.updateGraph(); + logger.info("Project '" + project.getProjectName() + "' (" + server.ProjectKind[project.projectKind] + ") " + counter); + logger.info(project.filesToString()); + logger.info("-----------------------------------------------"); + counter++; + } + return counter; + } + }; + ProjectService.prototype.findConfiguredProjectByProjectName = function (configFileName) { + configFileName = server.asNormalizedPath(this.toCanonicalFileName(configFileName)); + for (var _i = 0, _a = this.configuredProjects; _i < _a.length; _i++) { + var proj = _a[_i]; + if (proj.canonicalConfigFilePath === configFileName) { + return proj; + } + } + }; + ProjectService.prototype.findExternalProjectByProjectName = function (projectFileName) { + return findProjectByName(projectFileName, this.externalProjects); + }; + ProjectService.prototype.convertConfigFileContentToProjectOptions = function (configFilename) { + configFilename = ts.normalizePath(configFilename); + var configFileContent = this.host.readFile(configFilename); + var errors; + var result = ts.parseConfigFileTextToJson(configFilename, configFileContent); + var config = result.config; + if (result.error) { + var _a = ts.sanitizeConfigFile(configFilename, configFileContent), sanitizedConfig = _a.configJsonObject, diagnostics = _a.diagnostics; + config = sanitizedConfig; + errors = diagnostics.length ? diagnostics : [result.error]; + } + var parsedCommandLine = ts.parseJsonConfigFileContent(config, this.host, ts.getDirectoryPath(configFilename), {}, configFilename, [], this.hostConfiguration.extraFileExtensions); + if (parsedCommandLine.errors.length) { + errors = ts.concatenate(errors, parsedCommandLine.errors); + } + ts.Debug.assert(!!parsedCommandLine.fileNames); + if (parsedCommandLine.fileNames.length === 0) { + (errors || (errors = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename)); + return { success: false, configFileErrors: errors }; + } + var projectOptions = { + files: parsedCommandLine.fileNames, + compilerOptions: parsedCommandLine.options, + configHasFilesProperty: config["files"] !== undefined, + wildcardDirectories: ts.createMapFromTemplate(parsedCommandLine.wildcardDirectories), + typeAcquisition: parsedCommandLine.typeAcquisition, + compileOnSave: parsedCommandLine.compileOnSave + }; + return { success: true, projectOptions: projectOptions, configFileErrors: errors }; + }; + ProjectService.prototype.exceededTotalSizeLimitForNonTsFiles = function (options, fileNames, propertyReader) { + if (options && options.disableSizeLimit || !this.host.getFileSize) { + return false; + } + var totalNonTsFileSize = 0; + for (var _i = 0, fileNames_3 = fileNames; _i < fileNames_3.length; _i++) { + var f = fileNames_3[_i]; + var fileName = propertyReader.getFileName(f); + if (ts.hasTypeScriptFileExtension(fileName)) { + continue; + } + totalNonTsFileSize += this.host.getFileSize(fileName); + if (totalNonTsFileSize > server.maxProgramSizeForNonTsFiles) { + return true; + } + } + return false; + }; + ProjectService.prototype.createAndAddExternalProject = function (projectFileName, files, options, typeAcquisition) { + var compilerOptions = convertCompilerOptions(options); + var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, compilerOptions, !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); + this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, undefined, typeAcquisition, undefined); + this.externalProjects.push(project); + return project; + }; + ProjectService.prototype.reportConfigFileDiagnostics = function (configFileName, diagnostics, triggerFile) { + if (!this.eventHandler) { + return; + } + this.eventHandler({ + eventName: server.ConfigFileDiagEvent, + data: { configFileName: configFileName, diagnostics: diagnostics || [], triggerFile: triggerFile } + }); + }; + ProjectService.prototype.createAndAddConfiguredProject = function (configFileName, projectOptions, configFileErrors, clientFileName) { + var _this = this; + var sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); + var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, projectOptions.configHasFilesProperty, projectOptions.compilerOptions, projectOptions.wildcardDirectories, !sizeLimitExceeded, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); + this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); + project.watchConfigFile(function (project) { return _this.onConfigChangedForConfiguredProject(project); }); + if (!sizeLimitExceeded) { + this.watchConfigDirectoryForProject(project, projectOptions); + } + project.watchWildcards(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); + project.watchTypeRoots(function (project, path) { return _this.onTypeRootFileChanged(project, path); }); + this.configuredProjects.push(project); + return project; + }; + ProjectService.prototype.watchConfigDirectoryForProject = function (project, options) { + var _this = this; + if (!options.configHasFilesProperty) { + project.watchConfigDirectory(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); + } + }; + ProjectService.prototype.addFilesToProjectAndUpdateGraph = function (project, files, propertyReader, clientFileName, typeAcquisition, configFileErrors) { + var errors; + for (var _i = 0, files_4 = files; _i < files_4.length; _i++) { + var f = files_4[_i]; + var rootFilename = propertyReader.getFileName(f); + var scriptKind = propertyReader.getScriptKind(f); + var hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); + if (this.host.fileExists(rootFilename)) { + var info = this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(rootFilename), clientFileName == rootFilename, undefined, scriptKind, hasMixedContent); + project.addRoot(info); + } + else { + (errors || (errors = [])).push(createFileNotFoundDiagnostic(rootFilename)); + } + } + project.setProjectErrors(ts.concatenate(configFileErrors, errors)); + project.setTypeAcquisition(typeAcquisition); + project.updateGraph(); + }; + ProjectService.prototype.openConfigFile = function (configFileName, clientFileName) { + var conversionResult = this.convertConfigFileContentToProjectOptions(configFileName); + var projectOptions = conversionResult.success + ? conversionResult.projectOptions + : { files: [], compilerOptions: {} }; + var project = this.createAndAddConfiguredProject(configFileName, projectOptions, conversionResult.configFileErrors, clientFileName); + return { + success: conversionResult.success, + project: project, + errors: project.getProjectErrors() + }; + }; + ProjectService.prototype.updateNonInferredProject = function (project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave, configFileErrors) { + var oldRootScriptInfos = project.getRootScriptInfos(); + var newRootScriptInfos = []; + var newRootScriptInfoMap = server.createNormalizedPathMap(); + var projectErrors; + var rootFilesChanged = false; + for (var _i = 0, newUncheckedFiles_1 = newUncheckedFiles; _i < newUncheckedFiles_1.length; _i++) { + var f = newUncheckedFiles_1[_i]; + var newRootFile = propertyReader.getFileName(f); + if (!this.host.fileExists(newRootFile)) { + (projectErrors || (projectErrors = [])).push(createFileNotFoundDiagnostic(newRootFile)); + continue; + } + var normalizedPath = server.toNormalizedPath(newRootFile); + var scriptInfo = this.getScriptInfoForNormalizedPath(normalizedPath); + if (!scriptInfo || !project.isRoot(scriptInfo)) { + rootFilesChanged = true; + if (!scriptInfo) { + var scriptKind = propertyReader.getScriptKind(f); + var hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); + scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, false, undefined, scriptKind, hasMixedContent); + } + } + newRootScriptInfos.push(scriptInfo); + newRootScriptInfoMap.set(scriptInfo.fileName, scriptInfo); + } + if (rootFilesChanged || newRootScriptInfos.length !== oldRootScriptInfos.length) { + var toAdd = void 0; + var toRemove = void 0; + for (var _a = 0, oldRootScriptInfos_1 = oldRootScriptInfos; _a < oldRootScriptInfos_1.length; _a++) { + var oldFile = oldRootScriptInfos_1[_a]; + if (!newRootScriptInfoMap.contains(oldFile.fileName)) { + (toRemove || (toRemove = [])).push(oldFile); + } + } + for (var _b = 0, newRootScriptInfos_1 = newRootScriptInfos; _b < newRootScriptInfos_1.length; _b++) { + var newFile = newRootScriptInfos_1[_b]; + if (!project.isRoot(newFile)) { + (toAdd || (toAdd = [])).push(newFile); + } + } + if (toRemove) { + for (var _c = 0, toRemove_1 = toRemove; _c < toRemove_1.length; _c++) { + var f = toRemove_1[_c]; + project.removeFile(f); + } + } + if (toAdd) { + for (var _d = 0, toAdd_1 = toAdd; _d < toAdd_1.length; _d++) { + var f = toAdd_1[_d]; + if (f.isScriptOpen() && isRootFileInInferredProject(f)) { + var inferredProject = f.containingProjects[0]; + inferredProject.removeFile(f); + if (!inferredProject.hasRoots()) { + this.removeProject(inferredProject); + } + } + project.addRoot(f); + } + } + } + project.setCompilerOptions(newOptions); + project.setTypeAcquisition(newTypeAcquisition); + if (compileOnSave !== undefined) { + project.compileOnSaveEnabled = compileOnSave; + } + project.setProjectErrors(ts.concatenate(configFileErrors, projectErrors)); + project.updateGraph(); + }; + ProjectService.prototype.updateConfiguredProject = function (project) { + if (!this.host.fileExists(project.getConfigFilePath())) { + this.logger.info("Config file deleted"); + this.removeProject(project); + return; + } + var _a = this.convertConfigFileContentToProjectOptions(project.getConfigFilePath()), success = _a.success, projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; + if (!success) { + this.updateNonInferredProject(project, [], fileNamePropertyReader, {}, {}, false, configFileErrors); + return configFileErrors; + } + if (this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { + project.setCompilerOptions(projectOptions.compilerOptions); + if (!project.languageServiceEnabled) { + return configFileErrors; + } + project.disableLanguageService(); + project.stopWatchingDirectory(); + } + else { + project.enableLanguageService(); + this.watchConfigDirectoryForProject(project, projectOptions); + this.updateNonInferredProject(project, projectOptions.files, fileNamePropertyReader, projectOptions.compilerOptions, projectOptions.typeAcquisition, projectOptions.compileOnSave, configFileErrors); + } + return configFileErrors; + }; + ProjectService.prototype.createInferredProjectWithRootFileIfNecessary = function (root) { + var _this = this; + var useExistingProject = this.useSingleInferredProject && this.inferredProjects.length; + var project = useExistingProject + ? this.inferredProjects[0] + : new server.InferredProject(this, this.documentRegistry, this.compilerOptionsForInferredProjects); + project.addRoot(root); + this.directoryWatchers.startWatchingContainingDirectoriesForFile(root.fileName, project, function (fileName) { return _this.onConfigFileAddedForInferredProject(fileName); }); + project.updateGraph(); + if (!useExistingProject) { + this.inferredProjects.push(project); + } + return project; + }; + ProjectService.prototype.getOrCreateScriptInfo = function (uncheckedFileName, openedByClient, fileContent, scriptKind) { + return this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName), openedByClient, fileContent, scriptKind); + }; + ProjectService.prototype.getScriptInfo = function (uncheckedFileName) { + return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); + }; + ProjectService.prototype.getOrCreateScriptInfoForNormalizedPath = function (fileName, openedByClient, fileContent, scriptKind, hasMixedContent) { + var _this = this; + var info = this.getScriptInfoForNormalizedPath(fileName); + if (!info) { + if (openedByClient || this.host.fileExists(fileName)) { + info = new server.ScriptInfo(this.host, fileName, scriptKind, hasMixedContent); + this.filenameToScriptInfo.set(info.path, info); + if (openedByClient) { + if (fileContent === undefined) { + fileContent = this.host.readFile(fileName) || ""; + } + } + else { + if (!hasMixedContent) { + info.setWatcher(this.host.watchFile(fileName, function (_) { return _this.onSourceFileChanged(fileName); })); + } + } + } + } + if (info) { + if (openedByClient && !info.isScriptOpen()) { + info.open(fileContent); + if (hasMixedContent) { + info.registerFileUpdate(); + } + } + else if (fileContent !== undefined) { + info.reload(fileContent); + } + } + return info; + }; + ProjectService.prototype.getScriptInfoForNormalizedPath = function (fileName) { + return this.getScriptInfoForPath(server.normalizedPathToPath(fileName, this.host.getCurrentDirectory(), this.toCanonicalFileName)); + }; + ProjectService.prototype.getScriptInfoForPath = function (fileName) { + return this.filenameToScriptInfo.get(fileName); + }; + ProjectService.prototype.setHostConfiguration = function (args) { + if (args.file) { + var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file)); + if (info) { + info.setFormatOptions(convertFormatOptions(args.formatOptions)); + this.logger.info("Host configuration update for file " + args.file); + } + } + else { + if (args.hostInfo !== undefined) { + this.hostConfiguration.hostInfo = args.hostInfo; + this.logger.info("Host information " + args.hostInfo); + } + if (args.formatOptions) { + server.mergeMapLikes(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); + this.logger.info("Format host information updated"); + } + if (args.extraFileExtensions) { + this.hostConfiguration.extraFileExtensions = args.extraFileExtensions; + this.logger.info("Host file extension mappings updated"); + } + } + }; + ProjectService.prototype.closeLog = function () { + this.logger.close(); + }; + ProjectService.prototype.reloadProjects = function () { + this.logger.info("reload projects."); + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var info = _a[_i]; + this.openOrUpdateConfiguredProjectForFile(info.fileName); + } + this.refreshInferredProjects(); + }; + ProjectService.prototype.refreshInferredProjects = function () { + this.logger.info("updating project structure from ..."); + this.printProjects(); + var orphantedFiles = []; + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var info = _a[_i]; + if (info.containingProjects.length === 0) { + orphantedFiles.push(info); + } + else { + if (isRootFileInInferredProject(info) && info.containingProjects.length > 1) { + var inferredProject = info.containingProjects[0]; + ts.Debug.assert(inferredProject.projectKind === server.ProjectKind.Inferred); + inferredProject.removeFile(info); + if (!inferredProject.hasRoots()) { + this.removeProject(inferredProject); + } + } + } + } + for (var _b = 0, orphantedFiles_1 = orphantedFiles; _b < orphantedFiles_1.length; _b++) { + var f = orphantedFiles_1[_b]; + this.assignScriptInfoToInferredProjectIfNecessary(f, false); + } + for (var _c = 0, _d = this.inferredProjects; _c < _d.length; _c++) { + var p = _d[_c]; + p.updateGraph(); + } + this.printProjects(); + }; + ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind) { + return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind); + }; + ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent) { + var configFileName; + var configFileErrors; + var project = this.findContainingExternalProject(fileName); + if (!project) { + (_a = this.openOrUpdateConfiguredProjectForFile(fileName), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors); + if (configFileName) { + project = this.findConfiguredProjectByProjectName(configFileName); + } + } + if (project && !project.languageServiceEnabled) { + project.markAsDirty(); + } + var info = this.getOrCreateScriptInfoForNormalizedPath(fileName, true, fileContent, scriptKind, hasMixedContent); + this.assignScriptInfoToInferredProjectIfNecessary(info, true); + this.printProjects(); + return { configFileName: configFileName, configFileErrors: configFileErrors }; + var _a; + }; + ProjectService.prototype.closeClientFile = function (uncheckedFileName) { + var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); + if (info) { + this.closeOpenFile(info); + } + this.printProjects(); + }; + ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { + var _loop_6 = function (proj) { + var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); + result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); + }; + for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { + var proj = currentProjects_1[_i]; + _loop_6(proj); + } + }; + ProjectService.prototype.synchronizeProjectList = function (knownProjects) { + var files = []; + this.collectChanges(knownProjects, this.externalProjects, files); + this.collectChanges(knownProjects, this.configuredProjects, files); + this.collectChanges(knownProjects, this.inferredProjects, files); + return files; + }; + ProjectService.prototype.applyChangesInOpenFiles = function (openFiles, changedFiles, closedFiles) { + var recordChangedFiles = changedFiles && !openFiles && !closedFiles; + if (openFiles) { + for (var _i = 0, openFiles_1 = openFiles; _i < openFiles_1.length; _i++) { + var file = openFiles_1[_i]; + var scriptInfo = this.getScriptInfo(file.fileName); + ts.Debug.assert(!scriptInfo || !scriptInfo.isScriptOpen()); + var normalizedPath = scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file.fileName); + this.openClientFileWithNormalizedPath(normalizedPath, file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent); + } + } + if (changedFiles) { + for (var _a = 0, changedFiles_2 = changedFiles; _a < changedFiles_2.length; _a++) { + var file = changedFiles_2[_a]; + var scriptInfo = this.getScriptInfo(file.fileName); + ts.Debug.assert(!!scriptInfo); + for (var i = file.changes.length - 1; i >= 0; i--) { + var change = file.changes[i]; + scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText); + } + if (recordChangedFiles) { + if (!this.changedFiles) { + this.changedFiles = [scriptInfo]; + } + else if (this.changedFiles.indexOf(scriptInfo) < 0) { + this.changedFiles.push(scriptInfo); + } + } + } + } + if (closedFiles) { + for (var _b = 0, closedFiles_1 = closedFiles; _b < closedFiles_1.length; _b++) { + var file = closedFiles_1[_b]; + this.closeClientFile(file); + } + } + if (openFiles || closedFiles) { + this.refreshInferredProjects(); + } + }; + ProjectService.prototype.closeConfiguredProject = function (configFile) { + var configuredProject = this.findConfiguredProjectByProjectName(configFile); + if (configuredProject && configuredProject.deleteOpenRef() === 0) { + this.removeProject(configuredProject); + } + }; + ProjectService.prototype.closeExternalProject = function (uncheckedFileName, suppressRefresh) { + if (suppressRefresh === void 0) { suppressRefresh = false; } + var fileName = server.toNormalizedPath(uncheckedFileName); + var configFiles = this.externalProjectToConfiguredProjectMap.get(fileName); + if (configFiles) { + var shouldRefreshInferredProjects = false; + for (var _i = 0, configFiles_1 = configFiles; _i < configFiles_1.length; _i++) { + var configFile = configFiles_1[_i]; + if (this.closeConfiguredProject(configFile)) { + shouldRefreshInferredProjects = true; + } + } + this.externalProjectToConfiguredProjectMap.delete(fileName); + if (shouldRefreshInferredProjects && !suppressRefresh) { + this.refreshInferredProjects(); + } + } + else { + var externalProject = this.findExternalProjectByProjectName(uncheckedFileName); + if (externalProject) { + this.removeProject(externalProject); + if (!suppressRefresh) { + this.refreshInferredProjects(); + } + } + } + }; + ProjectService.prototype.openExternalProjects = function (projects) { + var _this = this; + var projectsToClose = ts.arrayToMap(this.externalProjects, function (p) { return p.getProjectName(); }, function (_) { return true; }); + ts.forEachKey(this.externalProjectToConfiguredProjectMap, function (externalProjectName) { + projectsToClose.set(externalProjectName, true); + }); + for (var _i = 0, projects_5 = projects; _i < projects_5.length; _i++) { + var externalProject = projects_5[_i]; + this.openExternalProject(externalProject, true); + projectsToClose.delete(externalProject.projectFileName); + } + ts.forEachKey(projectsToClose, function (externalProjectName) { + _this.closeExternalProject(externalProjectName, true); + }); + this.refreshInferredProjects(); + }; + ProjectService.prototype.openExternalProject = function (proj, suppressRefreshOfInferredProjects) { + if (suppressRefreshOfInferredProjects === void 0) { suppressRefreshOfInferredProjects = false; } + if (proj.typingOptions && !proj.typeAcquisition) { + var typeAcquisition = ts.convertEnableAutoDiscoveryToEnable(proj.typingOptions); + proj.typeAcquisition = typeAcquisition; + } + var tsConfigFiles; + var rootFiles = []; + for (var _i = 0, _a = proj.rootFiles; _i < _a.length; _i++) { + var file = _a[_i]; + var normalized = server.toNormalizedPath(file.fileName); + if (ts.getBaseFileName(normalized) === "tsconfig.json") { + if (this.host.fileExists(normalized)) { + (tsConfigFiles || (tsConfigFiles = [])).push(normalized); + } + } + else { + rootFiles.push(file); + } + } + if (tsConfigFiles) { + tsConfigFiles.sort(); + } + var externalProject = this.findExternalProjectByProjectName(proj.projectFileName); + var exisingConfigFiles; + if (externalProject) { + if (!tsConfigFiles) { + var compilerOptions = convertCompilerOptions(proj.options); + if (this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, proj.rootFiles, externalFilePropertyReader)) { + externalProject.disableLanguageService(); + } + else { + externalProject.enableLanguageService(); + } + this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, compilerOptions, proj.typeAcquisition, proj.options.compileOnSave, undefined); + return; + } + this.closeExternalProject(proj.projectFileName, true); + } + else if (this.externalProjectToConfiguredProjectMap.get(proj.projectFileName)) { + if (!tsConfigFiles) { + this.closeExternalProject(proj.projectFileName, true); + } + else { + var oldConfigFiles = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName); + var iNew = 0; + var iOld = 0; + while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) { + var newConfig = tsConfigFiles[iNew]; + var oldConfig = oldConfigFiles[iOld]; + if (oldConfig < newConfig) { + this.closeConfiguredProject(oldConfig); + iOld++; + } + else if (oldConfig > newConfig) { + iNew++; + } + else { + (exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig); + iOld++; + iNew++; + } + } + for (var i = iOld; i < oldConfigFiles.length; i++) { + this.closeConfiguredProject(oldConfigFiles[i]); + } + } + } + if (tsConfigFiles) { + this.externalProjectToConfiguredProjectMap.set(proj.projectFileName, tsConfigFiles); + for (var _b = 0, tsConfigFiles_1 = tsConfigFiles; _b < tsConfigFiles_1.length; _b++) { + var tsconfigFile = tsConfigFiles_1[_b]; + var project = this.findConfiguredProjectByProjectName(tsconfigFile); + if (!project) { + var result = this.openConfigFile(tsconfigFile); + project = result.success && result.project; + } + if (project && !ts.contains(exisingConfigFiles, tsconfigFile)) { + project.addOpenRef(); + } + } + } + else { + this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName); + this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition); + } + if (!suppressRefreshOfInferredProjects) { + this.refreshInferredProjects(); + } + }; + return ProjectService; + }()); + server.ProjectService = ProjectService; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); var debugObjectHost = (function () { return this; })(); var ts; (function (ts) { @@ -69881,7 +73962,9 @@ var ts; if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } - return JSON.parse(settingsJson); + var compilerOptions = JSON.parse(settingsJson); + compilerOptions.allowNonTsExtensions = true; + return compilerOptions; }; LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { var encoded = this.shimHost.getScriptFileNames(); @@ -70319,12 +74402,6 @@ var ts; var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (resolvedFileName && !compilerOptions.allowJs && ts.fileExtensionIs(resolvedFileName, ".js")) { - return { - resolvedFileName: undefined, - failedLookupLocations: [] - }; - } return { resolvedFileName: resolvedFileName, failedLookupLocations: result.failedLookupLocations @@ -70464,7 +74541,7 @@ var ts; this._shims.push(shim); }; TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0, n = this._shims.length; i < n; i++) { + for (var i = 0; i < this._shims.length; i++) { if (this._shims[i] === shim) { delete this._shims[i]; return; @@ -70486,4 +74563,4 @@ var TypeScript; Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); -var toolsVersion = "2.2"; +var toolsVersion = "2.3"; diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index c5cee20bdde..05f02b45233 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -14,11 +14,36 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { + /** + * Type of objects whose values are all of the same type. + * The `in` and `for-in` operators can *not* be safely used, + * since `Object.prototype` may be modified by outside code. + */ interface MapLike { [index: string]: T; } - interface Map extends MapLike { - __mapBrand: any; + /** ES6 Map interface. */ + interface Map { + get(key: string): T; + has(key: string): boolean; + set(key: string, value: T): this; + delete(key: string): boolean; + clear(): void; + forEach(action: (value: T, key: string) => void): void; + readonly size: number; + keys(): Iterator; + values(): Iterator; + entries(): Iterator<[string, T]>; + } + /** ES6 Iterator type. */ + interface Iterator { + next(): { + value: T; + done: false; + } | { + value: never; + done: true; + }; } type Path = string & { __pathBrand: any; @@ -170,172 +195,175 @@ declare namespace ts { ReadonlyKeyword = 130, RequireKeyword = 131, NumberKeyword = 132, - SetKeyword = 133, - StringKeyword = 134, - SymbolKeyword = 135, - TypeKeyword = 136, - UndefinedKeyword = 137, - FromKeyword = 138, - GlobalKeyword = 139, - OfKeyword = 140, - QualifiedName = 141, - ComputedPropertyName = 142, - TypeParameter = 143, - Parameter = 144, - Decorator = 145, - PropertySignature = 146, - PropertyDeclaration = 147, - MethodSignature = 148, - MethodDeclaration = 149, - Constructor = 150, - GetAccessor = 151, - SetAccessor = 152, - CallSignature = 153, - ConstructSignature = 154, - IndexSignature = 155, - TypePredicate = 156, - TypeReference = 157, - FunctionType = 158, - ConstructorType = 159, - TypeQuery = 160, - TypeLiteral = 161, - ArrayType = 162, - TupleType = 163, - UnionType = 164, - IntersectionType = 165, - ParenthesizedType = 166, - ThisType = 167, - TypeOperator = 168, - IndexedAccessType = 169, - MappedType = 170, - LiteralType = 171, - ObjectBindingPattern = 172, - ArrayBindingPattern = 173, - BindingElement = 174, - ArrayLiteralExpression = 175, - ObjectLiteralExpression = 176, - PropertyAccessExpression = 177, - ElementAccessExpression = 178, - CallExpression = 179, - NewExpression = 180, - TaggedTemplateExpression = 181, - TypeAssertionExpression = 182, - ParenthesizedExpression = 183, - FunctionExpression = 184, - ArrowFunction = 185, - DeleteExpression = 186, - TypeOfExpression = 187, - VoidExpression = 188, - AwaitExpression = 189, - PrefixUnaryExpression = 190, - PostfixUnaryExpression = 191, - BinaryExpression = 192, - ConditionalExpression = 193, - TemplateExpression = 194, - YieldExpression = 195, - SpreadElement = 196, - ClassExpression = 197, - OmittedExpression = 198, - ExpressionWithTypeArguments = 199, - AsExpression = 200, - NonNullExpression = 201, - TemplateSpan = 202, - SemicolonClassElement = 203, - Block = 204, - VariableStatement = 205, - EmptyStatement = 206, - ExpressionStatement = 207, - IfStatement = 208, - DoStatement = 209, - WhileStatement = 210, - ForStatement = 211, - ForInStatement = 212, - ForOfStatement = 213, - ContinueStatement = 214, - BreakStatement = 215, - ReturnStatement = 216, - WithStatement = 217, - SwitchStatement = 218, - LabeledStatement = 219, - ThrowStatement = 220, - TryStatement = 221, - DebuggerStatement = 222, - VariableDeclaration = 223, - VariableDeclarationList = 224, - FunctionDeclaration = 225, - ClassDeclaration = 226, - InterfaceDeclaration = 227, - TypeAliasDeclaration = 228, - EnumDeclaration = 229, - ModuleDeclaration = 230, - ModuleBlock = 231, - CaseBlock = 232, - NamespaceExportDeclaration = 233, - ImportEqualsDeclaration = 234, - ImportDeclaration = 235, - ImportClause = 236, - NamespaceImport = 237, - NamedImports = 238, - ImportSpecifier = 239, - ExportAssignment = 240, - ExportDeclaration = 241, - NamedExports = 242, - ExportSpecifier = 243, - MissingDeclaration = 244, - ExternalModuleReference = 245, - JsxElement = 246, - JsxSelfClosingElement = 247, - JsxOpeningElement = 248, - JsxClosingElement = 249, - JsxAttribute = 250, - JsxSpreadAttribute = 251, - JsxExpression = 252, - CaseClause = 253, - DefaultClause = 254, - HeritageClause = 255, - CatchClause = 256, - PropertyAssignment = 257, - ShorthandPropertyAssignment = 258, - SpreadAssignment = 259, - EnumMember = 260, - SourceFile = 261, - JSDocTypeExpression = 262, - JSDocAllType = 263, - JSDocUnknownType = 264, - JSDocArrayType = 265, - JSDocUnionType = 266, - JSDocTupleType = 267, - JSDocNullableType = 268, - JSDocNonNullableType = 269, - JSDocRecordType = 270, - JSDocRecordMember = 271, - JSDocTypeReference = 272, - JSDocOptionalType = 273, - JSDocFunctionType = 274, - JSDocVariadicType = 275, - JSDocConstructorType = 276, - JSDocThisType = 277, - JSDocComment = 278, - JSDocTag = 279, - JSDocAugmentsTag = 280, - JSDocParameterTag = 281, - JSDocReturnTag = 282, - JSDocTypeTag = 283, - JSDocTemplateTag = 284, - JSDocTypedefTag = 285, - JSDocPropertyTag = 286, - JSDocTypeLiteral = 287, - JSDocLiteralType = 288, - JSDocNullKeyword = 289, - JSDocUndefinedKeyword = 290, - JSDocNeverKeyword = 291, - SyntaxList = 292, - NotEmittedStatement = 293, - PartiallyEmittedExpression = 294, - MergeDeclarationMarker = 295, - EndOfDeclarationMarker = 296, - RawExpression = 297, - Count = 298, + ObjectKeyword = 133, + SetKeyword = 134, + StringKeyword = 135, + SymbolKeyword = 136, + TypeKeyword = 137, + UndefinedKeyword = 138, + FromKeyword = 139, + GlobalKeyword = 140, + OfKeyword = 141, + QualifiedName = 142, + ComputedPropertyName = 143, + TypeParameter = 144, + Parameter = 145, + Decorator = 146, + PropertySignature = 147, + PropertyDeclaration = 148, + MethodSignature = 149, + MethodDeclaration = 150, + Constructor = 151, + GetAccessor = 152, + SetAccessor = 153, + CallSignature = 154, + ConstructSignature = 155, + IndexSignature = 156, + TypePredicate = 157, + TypeReference = 158, + FunctionType = 159, + ConstructorType = 160, + TypeQuery = 161, + TypeLiteral = 162, + ArrayType = 163, + TupleType = 164, + UnionType = 165, + IntersectionType = 166, + ParenthesizedType = 167, + ThisType = 168, + TypeOperator = 169, + IndexedAccessType = 170, + MappedType = 171, + LiteralType = 172, + ObjectBindingPattern = 173, + ArrayBindingPattern = 174, + BindingElement = 175, + ArrayLiteralExpression = 176, + ObjectLiteralExpression = 177, + PropertyAccessExpression = 178, + ElementAccessExpression = 179, + CallExpression = 180, + NewExpression = 181, + TaggedTemplateExpression = 182, + TypeAssertionExpression = 183, + ParenthesizedExpression = 184, + FunctionExpression = 185, + ArrowFunction = 186, + DeleteExpression = 187, + TypeOfExpression = 188, + VoidExpression = 189, + AwaitExpression = 190, + PrefixUnaryExpression = 191, + PostfixUnaryExpression = 192, + BinaryExpression = 193, + ConditionalExpression = 194, + TemplateExpression = 195, + YieldExpression = 196, + SpreadElement = 197, + ClassExpression = 198, + OmittedExpression = 199, + ExpressionWithTypeArguments = 200, + AsExpression = 201, + NonNullExpression = 202, + MetaProperty = 203, + TemplateSpan = 204, + SemicolonClassElement = 205, + Block = 206, + VariableStatement = 207, + EmptyStatement = 208, + ExpressionStatement = 209, + IfStatement = 210, + DoStatement = 211, + WhileStatement = 212, + ForStatement = 213, + ForInStatement = 214, + ForOfStatement = 215, + ContinueStatement = 216, + BreakStatement = 217, + ReturnStatement = 218, + WithStatement = 219, + SwitchStatement = 220, + LabeledStatement = 221, + ThrowStatement = 222, + TryStatement = 223, + DebuggerStatement = 224, + VariableDeclaration = 225, + VariableDeclarationList = 226, + FunctionDeclaration = 227, + ClassDeclaration = 228, + InterfaceDeclaration = 229, + TypeAliasDeclaration = 230, + EnumDeclaration = 231, + ModuleDeclaration = 232, + ModuleBlock = 233, + CaseBlock = 234, + NamespaceExportDeclaration = 235, + ImportEqualsDeclaration = 236, + ImportDeclaration = 237, + ImportClause = 238, + NamespaceImport = 239, + NamedImports = 240, + ImportSpecifier = 241, + ExportAssignment = 242, + ExportDeclaration = 243, + NamedExports = 244, + ExportSpecifier = 245, + MissingDeclaration = 246, + ExternalModuleReference = 247, + JsxElement = 248, + JsxSelfClosingElement = 249, + JsxOpeningElement = 250, + JsxClosingElement = 251, + JsxAttribute = 252, + JsxAttributes = 253, + JsxSpreadAttribute = 254, + JsxExpression = 255, + CaseClause = 256, + DefaultClause = 257, + HeritageClause = 258, + CatchClause = 259, + PropertyAssignment = 260, + ShorthandPropertyAssignment = 261, + SpreadAssignment = 262, + EnumMember = 263, + SourceFile = 264, + Bundle = 265, + JSDocTypeExpression = 266, + JSDocAllType = 267, + JSDocUnknownType = 268, + JSDocArrayType = 269, + JSDocUnionType = 270, + JSDocTupleType = 271, + JSDocNullableType = 272, + JSDocNonNullableType = 273, + JSDocRecordType = 274, + JSDocRecordMember = 275, + JSDocTypeReference = 276, + JSDocOptionalType = 277, + JSDocFunctionType = 278, + JSDocVariadicType = 279, + JSDocConstructorType = 280, + JSDocThisType = 281, + JSDocComment = 282, + JSDocTag = 283, + JSDocAugmentsTag = 284, + JSDocParameterTag = 285, + JSDocReturnTag = 286, + JSDocTypeTag = 287, + JSDocTemplateTag = 288, + JSDocTypedefTag = 289, + JSDocPropertyTag = 290, + JSDocTypeLiteral = 291, + JSDocLiteralType = 292, + JSDocNullKeyword = 293, + JSDocUndefinedKeyword = 294, + JSDocNeverKeyword = 295, + SyntaxList = 296, + NotEmittedStatement = 297, + PartiallyEmittedExpression = 298, + MergeDeclarationMarker = 299, + EndOfDeclarationMarker = 300, + Count = 301, FirstAssignment = 57, LastAssignment = 69, FirstCompoundAssignment = 58, @@ -343,15 +371,15 @@ declare namespace ts { FirstReservedWord = 71, LastReservedWord = 106, FirstKeyword = 71, - LastKeyword = 140, + LastKeyword = 141, FirstFutureReservedWord = 107, LastFutureReservedWord = 115, - FirstTypeNode = 156, - LastTypeNode = 171, + FirstTypeNode = 157, + LastTypeNode = 172, FirstPunctuation = 16, LastPunctuation = 69, FirstToken = 0, - LastToken = 140, + LastToken = 141, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -360,11 +388,11 @@ declare namespace ts { LastTemplateToken = 15, FirstBinaryOperator = 26, LastBinaryOperator = 69, - FirstNode = 141, - FirstJSDocNode = 262, - LastJSDocNode = 288, - FirstJSDocTagNode = 278, - LastJSDocTagNode = 291, + FirstNode = 142, + FirstJSDocNode = 266, + LastJSDocNode = 295, + FirstJSDocTagNode = 282, + LastJSDocTagNode = 295, } enum NodeFlags { None = 0, @@ -481,6 +509,7 @@ declare namespace ts { kind: SyntaxKind.TypeParameter; name: Identifier; constraint?: TypeNode; + default?: TypeNode; expression?: Expression; } interface SignatureDeclaration extends Declaration { @@ -632,7 +661,7 @@ declare namespace ts { _typeNodeBrand: any; } interface KeywordTypeNode extends TypeNode { - kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; + kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; } interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; @@ -717,6 +746,10 @@ declare namespace ts { interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; } + interface PartiallyEmittedExpression extends LeftHandSideExpression { + kind: SyntaxKind.PartiallyEmittedExpression; + expression: Expression; + } interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } @@ -953,7 +986,7 @@ declare namespace ts { tag: LeftHandSideExpression; template: TemplateLiteral; } - type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; + type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; interface AsExpression extends Expression { kind: SyntaxKind.AsExpression; expression: Expression; @@ -969,31 +1002,38 @@ declare namespace ts { kind: SyntaxKind.NonNullExpression; expression: Expression; } + interface MetaProperty extends PrimaryExpression { + kind: SyntaxKind.MetaProperty; + keywordToken: SyntaxKind; + name: Identifier; + } interface JsxElement extends PrimaryExpression { kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; children: NodeArray; closingElement: JsxClosingElement; } + type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; + interface JsxAttributes extends ObjectLiteralExpressionBase { + } interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; tagName: JsxTagNameExpression; - attributes: NodeArray; + attributes: JsxAttributes; } interface JsxSelfClosingElement extends PrimaryExpression { kind: SyntaxKind.JsxSelfClosingElement; tagName: JsxTagNameExpression; - attributes: NodeArray; + attributes: JsxAttributes; } - type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; - type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - interface JsxAttribute extends Node { + interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; name: Identifier; initializer?: StringLiteral | JsxExpression; } - interface JsxSpreadAttribute extends Node { + interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; expression: Expression; } @@ -1003,6 +1043,7 @@ declare namespace ts { } interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; + dotDotDotToken?: Token; expression?: Expression; } interface JsxText extends Node { @@ -1012,6 +1053,9 @@ declare namespace ts { interface Statement extends Node { _statementBrand: any; } + interface NotEmittedStatement extends Statement { + kind: SyntaxKind.NotEmittedStatement; + } interface EmptyStatement extends Statement { kind: SyntaxKind.EmptyStatement; } @@ -1022,7 +1066,7 @@ declare namespace ts { kind: SyntaxKind.MissingDeclaration; name?: Identifier; } - type BlockLike = SourceFile | Block | ModuleBlock | CaseClause; + type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; @@ -1178,20 +1222,22 @@ declare namespace ts { name: Identifier; members: NodeArray; } - type ModuleBody = ModuleBlock | ModuleDeclaration; type ModuleName = Identifier | StringLiteral; + type ModuleBody = NamespaceBody | JSDocNamespaceBody; interface ModuleDeclaration extends DeclarationStatement { kind: SyntaxKind.ModuleDeclaration; name: Identifier | StringLiteral; - body?: ModuleBlock | NamespaceDeclaration | JSDocNamespaceDeclaration | Identifier; + body?: ModuleBody | JSDocNamespaceDeclaration | Identifier; } + type NamespaceBody = ModuleBlock | NamespaceDeclaration; interface NamespaceDeclaration extends ModuleDeclaration { name: Identifier; - body: ModuleBlock | NamespaceDeclaration; + body: NamespaceBody; } + type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; interface JSDocNamespaceDeclaration extends ModuleDeclaration { name: Identifier; - body: JSDocNamespaceDeclaration | Identifier; + body: JSDocNamespaceBody; } interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; @@ -1406,9 +1452,21 @@ declare namespace ts { ArrayMutation = 256, Referenced = 512, Shared = 1024, + PreFinally = 2048, + AfterFinally = 4096, Label = 12, Condition = 96, } + interface FlowLock { + locked?: boolean; + } + interface AfterFinallyFlow extends FlowNode, FlowLock { + antecedent: FlowNode; + } + interface PreFinallyFlow extends FlowNode { + antecedent: FlowNode; + lock: FlowLock; + } interface FlowNode { flags: FlowFlags; id?: number; @@ -1470,6 +1528,10 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; } + interface Bundle extends Node { + kind: SyntaxKind.Bundle; + sourceFiles: SourceFile[]; + } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; getSourceFile(fileName: string): SourceFile; @@ -1569,9 +1631,10 @@ declare namespace ts { getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol; + getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; - getBaseTypes(type: InterfaceType): ObjectType[]; + getBaseTypes(type: InterfaceType): BaseType[]; getReturnTypeOfSignature(signature: Signature): Type; getNonNullableType(type: Type): Type; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; @@ -1581,6 +1644,8 @@ declare namespace ts { getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol; getTypeAtLocation(node: Node): Type; + getTypeFromTypeNode(node: TypeNode): Type; + signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string; typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; getSymbolDisplayBuilder(): SymbolDisplayBuilder; @@ -1598,16 +1663,18 @@ declare namespace ts { isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; - getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; + getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; + getApparentType(type: Type): Type; } 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, kind?: SignatureKind): void; + buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1631,6 +1698,7 @@ declare namespace ts { clear(): void; trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; reportInaccessibleThisError(): void; + reportIllegalExtends(): void; } enum TypeFormatFlags { None = 0, @@ -1645,6 +1713,8 @@ declare namespace ts { InFirstTypeArgument = 256, InTypeAlias = 512, UseTypeAliasValue = 1024, + SuppressAnyReturnType = 2048, + AddUndefined = 4096, } enum SymbolFormatFlags { None = 0, @@ -1694,13 +1764,10 @@ declare namespace ts { ExportType = 2097152, ExportNamespace = 4194304, Alias = 8388608, - Instantiated = 16777216, - Merged = 33554432, - Transient = 67108864, - Prototype = 134217728, - SyntheticProperty = 268435456, - Optional = 536870912, - ExportStar = 1073741824, + Prototype = 16777216, + ExportStar = 33554432, + Optional = 67108864, + Transient = 134217728, Enum = 384, Variable = 3, Value = 107455, @@ -1766,6 +1833,7 @@ declare namespace ts { Intersection = 131072, Index = 262144, IndexedAccess = 524288, + NonPrimitive = 16777216, Literal = 480, StringOrNumberLiteral = 96, PossiblyFalsy = 7406, @@ -1775,10 +1843,10 @@ declare namespace ts { EnumLike = 272, UnionOrIntersection = 196608, StructuredType = 229376, - StructuredOrTypeParameter = 507904, + StructuredOrTypeVariable = 1032192, TypeVariable = 540672, - Narrowable = 1033215, - NotUnionOrUnit = 33281, + Narrowable = 17810431, + NotUnionOrUnit = 16810497, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { @@ -1794,7 +1862,7 @@ declare namespace ts { regularType?: LiteralType; } interface EnumType extends Type { - memberTypes: Map; + memberTypes: EnumLiteralType[]; } interface EnumLiteralType extends LiteralType { baseType: EnumType & UnionType; @@ -1810,17 +1878,20 @@ declare namespace ts { ObjectLiteral = 128, EvolvingArray = 256, ObjectLiteralPatternWithComputedProperties = 512, + NonPrimitive = 1024, ClassOrInterface = 3, } interface ObjectType extends Type { objectFlags: ObjectFlags; } + /** Class and interface types (TypeFlags.Class and TypeFlags.Interface). */ interface InterfaceType extends ObjectType { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; thisType: TypeParameter; } + type BaseType = ObjectType | IntersectionType; interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; @@ -1828,6 +1899,16 @@ declare namespace ts { declaredStringIndexInfo: IndexInfo; declaredNumberIndexInfo: IndexInfo; } + /** + * Type references (TypeFlags.Reference). When a class or interface has type parameters or + * a "this" type, references to the class or interface are made using type references. The + * typeArguments property specifies the types to substitute for the type parameters of the + * class or interface and optionally includes an extra element that specifies the type to + * substitute for "this" in the resulting instantiation. When no extra argument is present, + * the type reference itself is substituted for "this". The typeArguments property is undefined + * if the class or interface has no type parameters and the reference isn't specifying an + * explicit "this" argument. + */ interface TypeReference extends ObjectType { target: GenericType; typeArguments: Type[]; @@ -1850,6 +1931,7 @@ declare namespace ts { } interface TypeParameter extends TypeVariable { constraint: Type; + default?: Type; } interface IndexedAccessType extends TypeVariable { objectType: Type; @@ -1877,9 +1959,8 @@ declare namespace ts { isReadonly: boolean; declaration?: SignatureDeclaration; } - interface FileExtensionInfo { + interface JsFileExtensionInfo { extension: string; - scriptKind: ScriptKind; isMixedContent: boolean; } interface DiagnosticMessage { @@ -1917,7 +1998,10 @@ declare namespace ts { Classic = 1, NodeJs = 2, } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; + interface PluginImport { + name: string; + } + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[]; interface CompilerOptions { allowJs?: boolean; allowSyntheticDefaultImports?: boolean; @@ -2011,6 +2095,7 @@ declare namespace ts { None = 0, Preserve = 1, React = 2, + ReactNative = 3, } enum NewLineKind { CarriageReturnLineFeed = 0, @@ -2026,6 +2111,7 @@ declare namespace ts { JSX = 2, TS = 3, TSX = 4, + External = 5, } enum ScriptTarget { ES3 = 0, @@ -2106,7 +2192,6 @@ declare namespace ts { } interface ResolvedModuleWithFailedLookupLocations { resolvedModule: ResolvedModuleFull | undefined; - failedLookupLocations: string[]; } interface ResolvedTypeReferenceDirective { primary: boolean; @@ -2135,6 +2220,120 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; getEnvironmentVariable?(name: string): string; } + enum EmitFlags { + SingleLine = 1, + AdviseOnEmitNode = 2, + NoSubstitution = 4, + CapturesThis = 8, + NoLeadingSourceMap = 16, + NoTrailingSourceMap = 32, + NoSourceMap = 48, + NoNestedSourceMaps = 64, + NoTokenLeadingSourceMaps = 128, + NoTokenTrailingSourceMaps = 256, + NoTokenSourceMaps = 384, + NoLeadingComments = 512, + NoTrailingComments = 1024, + NoComments = 1536, + NoNestedComments = 2048, + HelperName = 4096, + ExportName = 8192, + LocalName = 16384, + Indented = 32768, + NoIndentation = 65536, + AsyncFunctionBody = 131072, + ReuseTempVariableScope = 262144, + CustomPrologue = 524288, + NoHoisting = 1048576, + HasEndOfDeclarationMarker = 2097152, + } + interface EmitHelper { + readonly name: string; + readonly scoped: boolean; + readonly text: string; + readonly priority?: number; + } + enum EmitHint { + SourceFile = 0, + Expression = 1, + IdentifierName = 2, + Unspecified = 3, + } + interface Printer { + /** + * Print a node and its subtree as-is, without any emit transformations. + * @param hint A value indicating the purpose of a node. This is primarily used to + * distinguish between an `Identifier` used in an expression position, versus an + * `Identifier` used as an `IdentifierName` as part of a declaration. For most nodes you + * should just pass `Unspecified`. + * @param node The node to print. The node and its subtree are printed as-is, without any + * emit transformations. + * @param sourceFile A source file that provides context for the node. The source text of + * the file is used to emit the original source content for literals and identifiers, while + * the identifiers of the source file are used when generating unique names to avoid + * collisions. + */ + printNode(hint: EmitHint, node: Node, sourceFile: SourceFile): string; + /** + * Prints a source file as-is, without any emit transformations. + */ + printFile(sourceFile: SourceFile): string; + /** + * Prints a bundle of source files as-is, without any emit transformations. + */ + printBundle(bundle: Bundle): string; + } + interface PrintHandlers { + /** + * A hook used by the Printer when generating unique names to avoid collisions with + * globally defined names that exist outside of the current source file. + */ + hasGlobalName?(name: string): boolean; + /** + * A hook used by the Printer to provide notifications prior to emitting a node. A + * compatible implementation **must** invoke `emitCallback` with the provided `hint` and + * `node` values. + * @param hint A hint indicating the intended purpose of the node. + * @param node The node to emit. + * @param emitCallback A callback that, when invoked, will emit the node. + * @example + * ```ts + * var printer = createPrinter(printerOptions, { + * onEmitNode(hint, node, emitCallback) { + * // set up or track state prior to emitting the node... + * emitCallback(hint, node); + * // restore state after emitting the node... + * } + * }); + * ``` + */ + onEmitNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + /** + * A hook used by the Printer to perform just-in-time substitution of a node. This is + * primarily used by node transformations that need to substitute one node for another, + * such as replacing `myExportedVar` with `exports.myExportedVar`. A compatible + * implementation **must** invoke `emitCallback` eith the provided `hint` and either + * the provided `node`, or its substitute. + * @param hint A hint indicating the intended purpose of the node. + * @param node The node to emit. + * @param emitCallback A callback that, when invoked, will emit the node. + * @example + * ```ts + * var printer = createPrinter(printerOptions, { + * onSubstituteNode(hint, node, emitCallback) { + * // perform substitution if necessary... + * emitCallback(hint, node); + * } + * }); + * ``` + */ + onSubstituteNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + } + interface PrinterOptions { + target?: ScriptTarget; + removeComments?: boolean; + newLine?: NewLineKind; + } interface TextSpan { start: number; length: number; @@ -2149,8 +2348,10 @@ declare namespace ts { } declare namespace ts { /** The version of the TypeScript compiler release */ - const version = "2.2.0"; + const version = "2.3.0"; } +declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; +declare function clearTimeout(handle: any): void; declare namespace ts { type FileWatcherCallback = (fileName: string, removed?: boolean) => void; type DirectoryWatcherCallback = (fileName: string) => void; @@ -2245,8 +2446,8 @@ declare namespace ts { function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; - function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; - function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined; + function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined; /** Optionally, get the shebang */ function getShebang(text: string): string; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; @@ -2295,6 +2496,356 @@ declare namespace ts { fileExists(fileName: string): boolean; readFile(fileName: string): string; }, errors?: Diagnostic[]): void; + function getOriginalNode(node: Node): Node; + function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; + /** + * Gets a value indicating whether a node originated in the parse tree. + * + * @param node The node to test. + */ + function isParseTreeNode(node: Node): boolean; + /** + * Gets the original parse tree node for a node. + * + * @param node The original node. + * @returns The original parse tree node if found; otherwise, undefined. + */ + function getParseTreeNode(node: Node): Node; + /** + * Gets the original parse tree node for a node. + * + * @param node The original node. + * @param nodeTest A callback used to ensure the correct type of parse tree node is returned. + * @returns The original parse tree node if found; otherwise, undefined. + */ + function getParseTreeNode(node: Node, nodeTest?: (node: Node) => node is T): T; + /** + * Remove extra underscore from escaped identifier text content. + * + * @param identifier The escaped identifier text. + * @returns The unescaped identifier text. + */ + function unescapeIdentifier(identifier: string): string; +} +declare namespace ts { + /** + * Make `elements` into a `NodeArray`. If `elements` is `undefined`, returns an empty `NodeArray`. + */ + function createNodeArray(elements?: T[], hasTrailingComma?: boolean): NodeArray; + function createLiteral(value: string): StringLiteral; + function createLiteral(value: number): NumericLiteral; + function createLiteral(value: boolean): BooleanLiteral; + /** Create a string literal whose source text is read from a source node during emit. */ + function createLiteral(sourceNode: StringLiteral | NumericLiteral | Identifier): StringLiteral; + function createLiteral(value: string | number | boolean): PrimaryExpression; + function createNumericLiteral(value: string): NumericLiteral; + function createIdentifier(text: string): Identifier; + /** Create a unique temporary variable. */ + function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier; + /** Create a unique temporary variable for use in a loop. */ + function createLoopVariable(): Identifier; + /** Create a unique name based on the supplied text. */ + function createUniqueName(text: string): Identifier; + /** Create a unique name generated for a node. */ + function getGeneratedNameForNode(node: Node): Identifier; + function createToken(token: TKind): Token; + function createSuper(): PrimaryExpression; + function createThis(): PrimaryExpression; + function createNull(): PrimaryExpression; + function createTrue(): BooleanLiteral; + function createFalse(): BooleanLiteral; + function createQualifiedName(left: EntityName, right: string | Identifier): QualifiedName; + function updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName; + function createComputedPropertyName(expression: Expression): ComputedPropertyName; + function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; + function createParameter(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + function updateParameter(node: ParameterDeclaration, decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: BindingName, type: TypeNode, initializer: Expression): ParameterDeclaration; + function createDecorator(expression: Expression): Decorator; + function updateDecorator(node: Decorator, expression: Expression): Decorator; + function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: QuestionToken, type: TypeNode, initializer: Expression): PropertyDeclaration; + function updateProperty(node: PropertyDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, type: TypeNode, initializer: Expression): PropertyDeclaration; + function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; + function updateMethod(node: MethodDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; + function createConstructor(decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; + function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; + function createGetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; + function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; + function createSetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; + function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; + function createObjectBindingPattern(elements: BindingElement[]): ObjectBindingPattern; + function updateObjectBindingPattern(node: ObjectBindingPattern, elements: BindingElement[]): ObjectBindingPattern; + function createArrayBindingPattern(elements: ArrayBindingElement[]): ArrayBindingPattern; + function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ArrayBindingElement[]): ArrayBindingPattern; + function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: DotDotDotToken, name: string | BindingName, initializer?: Expression): BindingElement; + function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken, propertyName: PropertyName, name: BindingName, initializer: Expression): BindingElement; + function createArrayLiteral(elements?: Expression[], multiLine?: boolean): ArrayLiteralExpression; + function updateArrayLiteral(node: ArrayLiteralExpression, elements: Expression[]): ArrayLiteralExpression; + function createObjectLiteral(properties?: ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; + function updateObjectLiteral(node: ObjectLiteralExpression, properties: ObjectLiteralElementLike[]): ObjectLiteralExpression; + function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression; + function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; + function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; + function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; + function createCall(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; + function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; + function createNew(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; + function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; + function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; + function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; + function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; + function createParen(expression: Expression): ParenthesizedExpression; + function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; + function createFunctionExpression(modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; + function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; + function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: ConciseBody): ArrowFunction; + function createDelete(expression: Expression): DeleteExpression; + function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; + function createTypeOf(expression: Expression): TypeOfExpression; + function updateTypeOf(node: TypeOfExpression, expression: Expression): TypeOfExpression; + function createVoid(expression: Expression): VoidExpression; + function updateVoid(node: VoidExpression, expression: Expression): VoidExpression; + function createAwait(expression: Expression): AwaitExpression; + function updateAwait(node: AwaitExpression, expression: Expression): AwaitExpression; + function createPrefix(operator: PrefixUnaryOperator, operand: Expression): PrefixUnaryExpression; + function updatePrefix(node: PrefixUnaryExpression, operand: Expression): PrefixUnaryExpression; + function createPostfix(operand: Expression, operator: PostfixUnaryOperator): PostfixUnaryExpression; + function updatePostfix(node: PostfixUnaryExpression, operand: Expression): PostfixUnaryExpression; + function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression): BinaryExpression; + function updateBinary(node: BinaryExpression, left: Expression, right: Expression): BinaryExpression; + function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; + function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + function createTemplateExpression(head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; + function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; + function createYield(expression?: Expression): YieldExpression; + function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression; + function updateYield(node: YieldExpression, expression: Expression): YieldExpression; + function createSpread(expression: Expression): SpreadElement; + function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; + function createClassExpression(modifiers: Modifier[], name: string | Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; + function createOmittedExpression(): OmittedExpression; + function createExpressionWithTypeArguments(typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; + function createAsExpression(expression: Expression, type: TypeNode): AsExpression; + function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; + function createNonNullExpression(expression: Expression): NonNullExpression; + function updateNonNullExpression(node: NonNullExpression, expression: Expression): NonNullExpression; + function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; + function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; + function createBlock(statements: Statement[], multiLine?: boolean): Block; + function updateBlock(node: Block, statements: Statement[]): Block; + function createVariableStatement(modifiers: Modifier[], declarationList: VariableDeclarationList | VariableDeclaration[]): VariableStatement; + function updateVariableStatement(node: VariableStatement, modifiers: Modifier[], declarationList: VariableDeclarationList): VariableStatement; + function createVariableDeclarationList(declarations: VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; + function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList; + function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; + function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode, initializer: Expression): VariableDeclaration; + function createEmptyStatement(): EmptyStatement; + function createStatement(expression: Expression): ExpressionStatement; + function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement; + function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement): IfStatement; + function createDo(statement: Statement, expression: Expression): DoStatement; + function updateDo(node: DoStatement, statement: Statement, expression: Expression): DoStatement; + function createWhile(expression: Expression, statement: Statement): WhileStatement; + function updateWhile(node: WhileStatement, expression: Expression, statement: Statement): WhileStatement; + function createFor(initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; + function updateFor(node: ForStatement, initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; + function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; + function updateForIn(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; + function createForOf(initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function updateForOf(node: ForOfStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function createContinue(label?: string | Identifier): ContinueStatement; + function updateContinue(node: ContinueStatement, label: Identifier): ContinueStatement; + function createBreak(label?: string | Identifier): BreakStatement; + function updateBreak(node: BreakStatement, label: Identifier): BreakStatement; + function createReturn(expression?: Expression): ReturnStatement; + function updateReturn(node: ReturnStatement, expression: Expression): ReturnStatement; + function createWith(expression: Expression, statement: Statement): WithStatement; + function updateWith(node: WithStatement, expression: Expression, statement: Statement): WithStatement; + function createSwitch(expression: Expression, caseBlock: CaseBlock): SwitchStatement; + function updateSwitch(node: SwitchStatement, expression: Expression, caseBlock: CaseBlock): SwitchStatement; + function createLabel(label: string | Identifier, statement: Statement): LabeledStatement; + function updateLabel(node: LabeledStatement, label: Identifier, statement: Statement): LabeledStatement; + function createThrow(expression: Expression): ThrowStatement; + function updateThrow(node: ThrowStatement, expression: Expression): ThrowStatement; + function createTry(tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; + function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; + function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; + function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; + function createClassDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; + function createEnumDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, members: EnumMember[]): EnumDeclaration; + function updateEnumDeclaration(node: EnumDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, members: EnumMember[]): EnumDeclaration; + function createModuleDeclaration(decorators: Decorator[], modifiers: Modifier[], name: ModuleName, body: ModuleBody, flags?: NodeFlags): ModuleDeclaration; + function updateModuleDeclaration(node: ModuleDeclaration, decorators: Decorator[], modifiers: Modifier[], name: ModuleName, body: ModuleBody): ModuleDeclaration; + function createModuleBlock(statements: Statement[]): ModuleBlock; + function updateModuleBlock(node: ModuleBlock, statements: Statement[]): ModuleBlock; + function createCaseBlock(clauses: CaseOrDefaultClause[]): CaseBlock; + function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]): CaseBlock; + function createImportEqualsDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function createImportDeclaration(decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier?: Expression): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier: Expression): ImportDeclaration; + function createImportClause(name: Identifier, namedBindings: NamedImportBindings): ImportClause; + function updateImportClause(node: ImportClause, name: Identifier, namedBindings: NamedImportBindings): ImportClause; + function createNamespaceImport(name: Identifier): NamespaceImport; + function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; + function createNamedImports(elements: ImportSpecifier[]): NamedImports; + function updateNamedImports(node: NamedImports, elements: ImportSpecifier[]): NamedImports; + function createImportSpecifier(propertyName: Identifier, name: Identifier): ImportSpecifier; + function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier, name: Identifier): ImportSpecifier; + function createExportAssignment(decorators: Decorator[], modifiers: Modifier[], isExportEquals: boolean, expression: Expression): ExportAssignment; + function updateExportAssignment(node: ExportAssignment, decorators: Decorator[], modifiers: Modifier[], expression: Expression): ExportAssignment; + function createExportDeclaration(decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier?: Expression): ExportDeclaration; + function updateExportDeclaration(node: ExportDeclaration, decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier: Expression): ExportDeclaration; + function createNamedExports(elements: ExportSpecifier[]): NamedExports; + function updateNamedExports(node: NamedExports, elements: ExportSpecifier[]): NamedExports; + function createExportSpecifier(name: string | Identifier, propertyName?: string | Identifier): ExportSpecifier; + function updateExportSpecifier(node: ExportSpecifier, name: Identifier, propertyName: Identifier): ExportSpecifier; + function createExternalModuleReference(expression: Expression): ExternalModuleReference; + function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; + function createJsxElement(openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; + function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; + function createJsxSelfClosingElement(tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxSelfClosingElement; + function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxSelfClosingElement; + function createJsxOpeningElement(tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxOpeningElement; + function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxOpeningElement; + function createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement; + function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; + function createJsxAttributes(properties: JsxAttributeLike[]): JsxAttributes; + function updateJsxAttributes(jsxAttributes: JsxAttributes, properties: JsxAttributeLike[]): JsxAttributes; + function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; + function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; + function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; + function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; + function createJsxExpression(expression: Expression, dotDotDotToken: DotDotDotToken): JsxExpression; + function updateJsxExpression(node: JsxExpression, expression: Expression): JsxExpression; + function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[]): HeritageClause; + function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause; + function createCaseClause(expression: Expression, statements: Statement[]): CaseClause; + function updateCaseClause(node: CaseClause, expression: Expression, statements: Statement[]): CaseClause; + function createDefaultClause(statements: Statement[]): DefaultClause; + function updateDefaultClause(node: DefaultClause, statements: Statement[]): DefaultClause; + function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block): CatchClause; + function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause; + function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; + function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment; + function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; + function createSpreadAssignment(expression: Expression): SpreadAssignment; + function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; + function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; + function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; + function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; + function updateSourceFileNode(node: SourceFile, statements: Statement[]): SourceFile; + /** + * Creates a shallow, memberwise clone of a node for mutation. + */ + function getMutableClone(node: T): T; + /** + * Creates a synthetic statement to act as a placeholder for a not-emitted statement in + * order to preserve comments. + * + * @param original The original statement. + */ + function createNotEmittedStatement(original: Node): NotEmittedStatement; + /** + * Creates a synthetic expression to act as a placeholder for a not-emitted expression in + * order to preserve comments or sourcemap positions. + * + * @param expression The inner expression to emit. + * @param original The original outer expression. + * @param location The location for the expression. Defaults to the positions from "original" if provided. + */ + function createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression; + function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; + function createBundle(sourceFiles: SourceFile[]): Bundle; + function updateBundle(node: Bundle, sourceFiles: SourceFile[]): Bundle; + function createComma(left: Expression, right: Expression): Expression; + function createLessThan(left: Expression, right: Expression): Expression; + function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; + function createAssignment(left: Expression, right: Expression): BinaryExpression; + function createStrictEquality(left: Expression, right: Expression): BinaryExpression; + function createStrictInequality(left: Expression, right: Expression): BinaryExpression; + function createAdd(left: Expression, right: Expression): BinaryExpression; + function createSubtract(left: Expression, right: Expression): BinaryExpression; + function createPostfixIncrement(operand: Expression): PostfixUnaryExpression; + function createLogicalAnd(left: Expression, right: Expression): BinaryExpression; + function createLogicalOr(left: Expression, right: Expression): BinaryExpression; + function createLogicalNot(operand: Expression): PrefixUnaryExpression; + function createVoidZero(): VoidExpression; + function createExportDefault(expression: Expression): ExportAssignment; + function createExternalModuleExport(exportName: Identifier): ExportDeclaration; + /** + * Clears any EmitNode entries from parse-tree nodes. + * @param sourceFile A source file. + */ + function disposeEmitNodes(sourceFile: SourceFile): void; + function setTextRange(range: T, location: TextRange | undefined): T; + /** + * Gets flags that control emit behavior of a node. + */ + function getEmitFlags(node: Node): EmitFlags; + /** + * Sets flags that control emit behavior of a node. + */ + function setEmitFlags(node: T, emitFlags: EmitFlags): T; + /** + * Gets a custom text range to use when emitting source maps. + */ + function getSourceMapRange(node: Node): TextRange; + /** + * Sets a custom text range to use when emitting source maps. + */ + function setSourceMapRange(node: T, range: TextRange): T; + /** + * Gets the TextRange to use for source maps for a token of a node. + */ + function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange; + /** + * Sets the TextRange to use for source maps for a token of a node. + */ + function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange): T; + /** + * Gets a custom text range to use when emitting comments. + */ + function getCommentRange(node: Node): TextRange; + /** + * Sets a custom text range to use when emitting comments. + */ + function setCommentRange(node: T, range: TextRange): T; + /** + * Gets the constant value to emit for an expression. + */ + function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; + /** + * Sets the constant value to emit for an expression. + */ + function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number): PropertyAccessExpression | ElementAccessExpression; + /** + * Adds an EmitHelper to a node. + */ + function addEmitHelper(node: T, helper: EmitHelper): T; + /** + * Add EmitHelpers to a node. + */ + function addEmitHelpers(node: T, helpers: EmitHelper[] | undefined): T; + /** + * Removes an EmitHelper from a node. + */ + function removeEmitHelper(node: Node, helper: EmitHelper): boolean; + /** + * Gets the EmitHelpers of a node. + */ + function getEmitHelpers(node: Node): EmitHelper[] | undefined; + /** + * Moves matching emit helpers from a source node to a target node. + */ + function moveEmitHelpers(source: Node, target: Node, predicate: (helper: EmitHelper) => boolean): void; + function setOriginalNode(node: T, original: Node): T; } declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; @@ -2305,6 +2856,10 @@ declare namespace ts { function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } declare namespace ts { + /** Array that is only intended to be pushed to, never read. */ + interface Push { + push(value: T): void; + } function moduleHasNonRelativeName(moduleName: string): boolean; function getEffectiveTypeRoots(options: CompilerOptions, host: { directoryExists?: (directoryName: string) => boolean; @@ -2325,9 +2880,31 @@ declare namespace ts { * this list is only the set of defaults that are implicitly included. */ function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + /** + * Cached module resolutions per containing directory. + * This assumes that any module id will have the same resolution for sibling files located in the same folder. + */ + interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { + getOrCreateCacheForDirectory(directoryName: string): Map; + } + /** + * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory + * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. + */ + interface NonRelativeModuleNameResolutionCache { + getOrCreateCacheForModuleName(nonRelativeModuleName: string): PerModuleNameCache; + } + interface PerModuleNameCache { + get(directory: string): ResolvedModuleWithFailedLookupLocations; + set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; + } + function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): ModuleResolutionCache; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache): ResolvedModuleWithFailedLookupLocations; +} +declare namespace ts { + function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } declare namespace ts { function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; @@ -2369,7 +2946,7 @@ declare namespace ts { * @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, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: FileExtensionInfo[]): ParsedCommandLine; + function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: JsFileExtensionInfo[]): ParsedCommandLine; function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; @@ -2413,7 +2990,7 @@ declare namespace ts { getConstructSignatures(): Signature[]; getStringIndexType(): Type; getNumberIndexType(): Type; - getBaseTypes(): ObjectType[]; + getBaseTypes(): BaseType[]; getNonNullableType(): Type; } interface Signature { @@ -2674,6 +3251,7 @@ declare namespace ts { InsertSpaceAfterCommaDelimiter: boolean; InsertSpaceAfterSemicolonInForStatements: boolean; InsertSpaceBeforeAndAfterBinaryOperators: boolean; + InsertSpaceAfterConstructor?: boolean; InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; @@ -2682,6 +3260,7 @@ declare namespace ts { InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; InsertSpaceAfterTypeAssertion?: boolean; + InsertSpaceBeforeFunctionParenthesis?: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; } @@ -2689,6 +3268,7 @@ declare namespace ts { insertSpaceAfterCommaDelimiter?: boolean; insertSpaceAfterSemicolonInForStatements?: boolean; insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterConstructor?: boolean; insertSpaceAfterKeywordsInControlFlowStatements?: boolean; insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; @@ -2697,6 +3277,7 @@ declare namespace ts { insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; insertSpaceAfterTypeAssertion?: boolean; + insertSpaceBeforeFunctionParenthesis?: boolean; placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; } @@ -2959,6 +3540,10 @@ declare namespace ts { const letElement = "let"; const directory = "directory"; const externalModuleName = "external module name"; + /** + * + **/ + const jsxAttribute = "JSX attribute"; } namespace ScriptElementKindModifier { const none = ""; diff --git a/lib/typescript.js b/lib/typescript.js index 7f41e5d07f5..a8db5a7997f 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -13,11 +13,16 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ts; (function (ts) { // token > SyntaxKind.Identifer => token is a keyword @@ -168,193 +173,196 @@ var ts; SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 130] = "ReadonlyKeyword"; SyntaxKind[SyntaxKind["RequireKeyword"] = 131] = "RequireKeyword"; SyntaxKind[SyntaxKind["NumberKeyword"] = 132] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 133] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 134] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 135] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 136] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 137] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 138] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 139] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 140] = "OfKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 133] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 134] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 135] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 136] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 137] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 138] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 139] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 140] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 141] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 141] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 142] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 142] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 143] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 143] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 144] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 145] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 144] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 145] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 146] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 146] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 147] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 148] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 149] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 150] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 151] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 152] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 153] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 154] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 155] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 147] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 148] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 149] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 150] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 151] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 152] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 153] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 154] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 155] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 156] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 156] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 157] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 158] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 159] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 160] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 161] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 162] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 163] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 164] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 165] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 166] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 167] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 168] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 169] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 170] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 171] = "LiteralType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 157] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 158] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 159] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 160] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 161] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 162] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 163] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 164] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 165] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 166] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 167] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 168] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 169] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 170] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 171] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 172] = "LiteralType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 172] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 173] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 174] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 173] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 174] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 175] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 175] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 176] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 177] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 178] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 179] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 180] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 181] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 182] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 183] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 184] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 185] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 186] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 187] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 188] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 189] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 190] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 191] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 192] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 193] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 194] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 195] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 196] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 197] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 198] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 199] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 200] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 201] = "NonNullExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 176] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 177] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 178] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 179] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 180] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 181] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 182] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 183] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 184] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 185] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 186] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 187] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 188] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 189] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 190] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 191] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 192] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 193] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 194] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 195] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 196] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 197] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 198] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 199] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 200] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 201] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 202] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 203] = "MetaProperty"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 202] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 203] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 204] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 205] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 204] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 205] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 206] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 207] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 208] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 209] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 210] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 211] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 212] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 213] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 214] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 215] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 216] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 217] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 218] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 219] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 220] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 221] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 222] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 223] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 224] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 225] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 226] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 227] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 228] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 229] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 230] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 231] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 232] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 233] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 234] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 235] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 236] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 237] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 238] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 239] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 240] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 241] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 242] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 243] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 244] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 206] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 207] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 208] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 209] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 210] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 211] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 212] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 213] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 214] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 215] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 216] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 217] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 218] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 219] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 220] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 221] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 222] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 223] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 224] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 225] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 226] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 227] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 228] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 229] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 230] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 231] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 232] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 233] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 234] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 235] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 236] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 237] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 238] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 239] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 240] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 241] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 242] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 243] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 244] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 245] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 246] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 247] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 246] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 247] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 248] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 249] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 250] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 251] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 252] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 248] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 249] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 250] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 251] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 252] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 253] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 254] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 255] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 253] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 254] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 255] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 256] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 256] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 257] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 258] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 259] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 257] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 258] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 259] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 260] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 261] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 262] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 260] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 263] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 261] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 264] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 265] = "Bundle"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 262] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 266] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 263] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 267] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 264] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 265] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 266] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 267] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 268] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 269] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 270] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 271] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 272] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 273] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 274] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 275] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 276] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 277] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 278] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 279] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 280] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 281] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 282] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 283] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 284] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 285] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 286] = "JSDocPropertyTag"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 287] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocLiteralType"] = 288] = "JSDocLiteralType"; - SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 289] = "JSDocNullKeyword"; - SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 290] = "JSDocUndefinedKeyword"; - SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 291] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 268] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 269] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 270] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 271] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 272] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 273] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 274] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 275] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 276] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 277] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 278] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 279] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 280] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 281] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 282] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 283] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 284] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 285] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 286] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 287] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 288] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 289] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 290] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 291] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 292] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 293] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 294] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 295] = "JSDocNeverKeyword"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 292] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 296] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 293] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 294] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 295] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 296] = "EndOfDeclarationMarker"; - SyntaxKind[SyntaxKind["RawExpression"] = 297] = "RawExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 297] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 298] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 299] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 300] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 298] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 301] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; @@ -363,15 +371,15 @@ var ts; SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 140] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 141] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 156] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 171] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 157] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 172] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 140] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 141] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -380,11 +388,11 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 141] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 262] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 288] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 278] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 291] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 142] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 266] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 295] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 282] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 295] = "LastJSDocTagNode"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -476,6 +484,8 @@ var ts; FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); @@ -511,6 +521,8 @@ var ts; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; + TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 2048] = "SuppressAnyReturnType"; + TypeFormatFlags[TypeFormatFlags["AddUndefined"] = 4096] = "AddUndefined"; })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var SymbolFormatFlags; (function (SymbolFormatFlags) { @@ -592,13 +604,10 @@ var ts; 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["Prototype"] = 16777216] = "Prototype"; + SymbolFlags[SymbolFlags["ExportStar"] = 33554432] = "ExportStar"; + SymbolFlags[SymbolFlags["Optional"] = 67108864] = "Optional"; + SymbolFlags[SymbolFlags["Transient"] = 134217728] = "Transient"; SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; @@ -642,11 +651,25 @@ var ts; SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); /* @internal */ + var CheckFlags; + (function (CheckFlags) { + CheckFlags[CheckFlags["Instantiated"] = 1] = "Instantiated"; + CheckFlags[CheckFlags["SyntheticProperty"] = 2] = "SyntheticProperty"; + CheckFlags[CheckFlags["Readonly"] = 4] = "Readonly"; + CheckFlags[CheckFlags["Partial"] = 8] = "Partial"; + CheckFlags[CheckFlags["HasNonUniformType"] = 16] = "HasNonUniformType"; + CheckFlags[CheckFlags["ContainsPublic"] = 32] = "ContainsPublic"; + CheckFlags[CheckFlags["ContainsProtected"] = 64] = "ContainsProtected"; + CheckFlags[CheckFlags["ContainsPrivate"] = 128] = "ContainsPrivate"; + CheckFlags[CheckFlags["ContainsStatic"] = 256] = "ContainsStatic"; + })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); + /* @internal */ var NodeCheckFlags; (function (NodeCheckFlags) { NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["CaptureNewTarget"] = 8] = "CaptureNewTarget"; NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; @@ -695,6 +718,9 @@ var ts; TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; /* @internal */ TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; + /* @internal */ + TypeFlags[TypeFlags["JsxAttributes"] = 33554432] = "JsxAttributes"; /* @internal */ TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; @@ -703,7 +729,7 @@ var ts; TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 16015] = "Intrinsic"; + TypeFlags[TypeFlags["Intrinsic"] = 16793231] = "Intrinsic"; /* @internal */ TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; TypeFlags[TypeFlags["StringLike"] = 262178] = "StringLike"; @@ -712,12 +738,12 @@ var ts; TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; TypeFlags[TypeFlags["UnionOrIntersection"] = 196608] = "UnionOrIntersection"; TypeFlags[TypeFlags["StructuredType"] = 229376] = "StructuredType"; - TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 507904] = "StructuredOrTypeParameter"; + TypeFlags[TypeFlags["StructuredOrTypeVariable"] = 1032192] = "StructuredOrTypeVariable"; TypeFlags[TypeFlags["TypeVariable"] = 540672] = "TypeVariable"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 1033215] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 33281] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["Narrowable"] = 17810431] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 16810497] = "NotUnionOrUnit"; /* @internal */ TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; /* @internal */ @@ -735,6 +761,7 @@ var ts; ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; + ObjectFlags[ObjectFlags["NonPrimitive"] = 1024] = "NonPrimitive"; ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); var SignatureKind; @@ -785,6 +812,7 @@ var ts; JsxEmit[JsxEmit["None"] = 0] = "None"; JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; JsxEmit[JsxEmit["React"] = 2] = "React"; + JsxEmit[JsxEmit["ReactNative"] = 3] = "ReactNative"; })(JsxEmit = ts.JsxEmit || (ts.JsxEmit = {})); var NewLineKind; (function (NewLineKind) { @@ -798,6 +826,7 @@ var ts; ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; ScriptKind[ScriptKind["TS"] = 3] = "TS"; ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + ScriptKind[ScriptKind["External"] = 5] = "External"; })(ScriptKind = ts.ScriptKind || (ts.ScriptKind = {})); var ScriptTarget; (function (ScriptTarget) { @@ -1032,7 +1061,6 @@ var ts; TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 274432] = "TypeScriptClassSyntaxMask"; TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 163840] = "ES2015FunctionSyntaxMask"; })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); - /* @internal */ var EmitFlags; (function (EmitFlags) { EmitFlags[EmitFlags["SingleLine"] = 1] = "SingleLine"; @@ -1079,14 +1107,13 @@ var ts; ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper"; ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 128] = "LastEmitHelper"; })(ExternalEmitHelpers = ts.ExternalEmitHelpers || (ts.ExternalEmitHelpers = {})); - /* @internal */ - var EmitContext; - (function (EmitContext) { - EmitContext[EmitContext["SourceFile"] = 0] = "SourceFile"; - EmitContext[EmitContext["Expression"] = 1] = "Expression"; - EmitContext[EmitContext["IdentifierName"] = 2] = "IdentifierName"; - EmitContext[EmitContext["Unspecified"] = 3] = "Unspecified"; - })(EmitContext = ts.EmitContext || (ts.EmitContext = {})); + var EmitHint; + (function (EmitHint) { + EmitHint[EmitHint["SourceFile"] = 0] = "SourceFile"; + EmitHint[EmitHint["Expression"] = 1] = "Expression"; + EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; + EmitHint[EmitHint["Unspecified"] = 3] = "Unspecified"; + })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); })(ts || (ts = {})); /*@internal*/ var ts; @@ -1114,8 +1141,8 @@ var ts; */ function mark(markName) { if (enabled) { - marks[markName] = ts.timestamp(); - counts[markName] = (counts[markName] || 0) + 1; + marks.set(markName, ts.timestamp()); + counts.set(markName, (counts.get(markName) || 0) + 1); profilerEvent(markName); } } @@ -1131,9 +1158,9 @@ var ts; */ function measure(measureName, startMarkName, endMarkName) { if (enabled) { - var end = endMarkName && marks[endMarkName] || ts.timestamp(); - var start = startMarkName && marks[startMarkName] || profilerStart; - measures[measureName] = (measures[measureName] || 0) + (end - start); + var end = endMarkName && marks.get(endMarkName) || ts.timestamp(); + var start = startMarkName && marks.get(startMarkName) || profilerStart; + measures.set(measureName, (measures.get(measureName) || 0) + (end - start)); } } performance.measure = measure; @@ -1143,7 +1170,7 @@ var ts; * @param markName The name of the mark. */ function getCount(markName) { - return counts && counts[markName] || 0; + return counts && counts.get(markName) || 0; } performance.getCount = getCount; /** @@ -1152,7 +1179,7 @@ var ts; * @param measureName The name of the measure whose durations should be accumulated. */ function getDuration(measureName) { - return measures && measures[measureName] || 0; + return measures && measures.get(measureName) || 0; } performance.getDuration = getDuration; /** @@ -1161,9 +1188,9 @@ var ts; * @param cb The action to perform for each measure */ function forEachMeasure(cb) { - for (var key in measures) { - cb(key, measures[key]); - } + measures.forEach(function (measure, key) { + cb(key, measure); + }); } performance.forEachMeasure = forEachMeasure; /** Enables (and resets) performance measurements for the compiler. */ @@ -1187,7 +1214,7 @@ var ts; var ts; (function (ts) { /** The version of the TypeScript compiler release */ - ts.version = "2.2.0"; + ts.version = "2.3.0"; })(ts || (ts = {})); /* @internal */ (function (ts) { @@ -1206,25 +1233,106 @@ var ts; Ternary[Ternary["Maybe"] = 1] = "Maybe"; Ternary[Ternary["True"] = -1] = "True"; })(Ternary = ts.Ternary || (ts.Ternary = {})); - var createObject = Object.create; // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. - ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - function createMap(template) { - var map = createObject(null); // tslint:disable-line:no-null-keyword + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(/*locales*/ undefined, { usage: "sort", sensitivity: "accent" }) : undefined; + // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". + ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + /** Create a MapLike with good performance. */ + function createDictionaryObject() { + var map = Object.create(null); // tslint:disable-line:no-null-keyword // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is // constantly changing shape. map["__"] = undefined; delete map["__"]; + return map; + } + /** Create a new map. If a template object is provided, the map will copy entries from it. */ + function createMap() { + return new MapCtr(); + } + ts.createMap = createMap; + function createMapFromTemplate(template) { + var map = new MapCtr(); // Copies keys/values from template. Note that for..in will not throw if // template is undefined, and instead will just exit the loop. for (var key in template) if (hasOwnProperty.call(template, key)) { - map[key] = template[key]; + map.set(key, template[key]); } return map; } - ts.createMap = createMap; + ts.createMapFromTemplate = createMapFromTemplate; + // Internet Explorer's Map doesn't support iteration, so don't use it. + // tslint:disable-next-line:no-in-operator + var MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); + // Keep the class inside a function so it doesn't get compiled if it's not used. + function shimMap() { + var MapIterator = (function () { + function MapIterator(data, selector) { + this.index = 0; + this.data = data; + this.selector = selector; + this.keys = Object.keys(data); + } + MapIterator.prototype.next = function () { + var index = this.index; + if (index < this.keys.length) { + this.index++; + return { value: this.selector(this.data, this.keys[index]), done: false }; + } + return { value: undefined, done: true }; + }; + return MapIterator; + }()); + return (function () { + function class_1() { + this.data = createDictionaryObject(); + this.size = 0; + } + class_1.prototype.get = function (key) { + return this.data[key]; + }; + class_1.prototype.set = function (key, value) { + if (!this.has(key)) { + this.size++; + } + this.data[key] = value; + return this; + }; + class_1.prototype.has = function (key) { + // tslint:disable-next-line:no-in-operator + return key in this.data; + }; + class_1.prototype.delete = function (key) { + if (this.has(key)) { + this.size--; + delete this.data[key]; + return true; + } + return false; + }; + class_1.prototype.clear = function () { + this.data = createDictionaryObject(); + this.size = 0; + }; + class_1.prototype.keys = function () { + return new MapIterator(this.data, function (_data, key) { return key; }); + }; + class_1.prototype.values = function () { + return new MapIterator(this.data, function (data, key) { return data[key]; }); + }; + class_1.prototype.entries = function () { + return new MapIterator(this.data, function (data, key) { return [key, data[key]]; }); + }; + class_1.prototype.forEach = function (action) { + for (var key in this.data) { + action(this.data[key], key); + } + }; + return class_1; + }()); + } function createFileMap(keyMapper) { var files = createMap(); return { @@ -1237,33 +1345,28 @@ var ts; clear: clear, }; function forEachValueInMap(f) { - for (var key in files) { - f(key, files[key]); - } + files.forEach(function (file, key) { + f(key, file); + }); } function getKeys() { - var keys = []; - for (var key in files) { - keys.push(key); - } - return keys; + return arrayFrom(files.keys()); } // path should already be well-formed so it does not need to be normalized function get(path) { - return files[toKey(path)]; + return files.get(toKey(path)); } function set(path, value) { - files[toKey(path)] = value; + files.set(toKey(path), value); } function contains(path) { - return toKey(path) in files; + return files.has(toKey(path)); } function remove(path) { - var key = toKey(path); - delete files[key]; + files.delete(toKey(path)); } function clear() { - files = createMap(); + files.clear(); } function toKey(path) { return keyMapper ? keyMapper(path) : path; @@ -1283,6 +1386,10 @@ var ts; Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; })(Comparison = ts.Comparison || (ts.Comparison = {})); + function length(array) { + return array ? array.length : 0; + } + ts.length = length; /** * 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. @@ -1290,7 +1397,7 @@ var ts; */ function forEach(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -1314,7 +1421,7 @@ var ts; */ function every(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -1325,7 +1432,7 @@ var ts; ts.every = every; /** Works like Array.prototype.find, returning `undefined` if no element satisfying the predicate is found. */ function find(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -1334,12 +1441,22 @@ var ts; return undefined; } ts.find = find; + /** Works like Array.prototype.findIndex, returning `-1` if no element satisfying the predicate is found. */ + function findIndex(array, predicate) { + for (var i = 0; i < array.length; i++) { + if (predicate(array[i], i)) { + return i; + } + } + return -1; + } + ts.findIndex = findIndex; /** * Returns the first truthy result of `callback`, or else fails. * This is like `forEach`, but never returns undefined. */ function findMap(array, callback) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -1362,7 +1479,7 @@ var ts; ts.contains = contains; function indexOf(array, value) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -1372,7 +1489,7 @@ var ts; } ts.indexOf = indexOf; function indexOfAnyCharCode(text, charCodes, start) { - for (var i = start || 0, len = text.length; i < len; i++) { + for (var i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -1582,21 +1699,18 @@ var ts; return result; } ts.spanMap = spanMap; - function mapObject(object, f) { - var result; - if (object) { - result = {}; - for (var _i = 0, _a = getOwnKeys(object); _i < _a.length; _i++) { - var v = _a[_i]; - var _b = f(v, object[v]) || [undefined, undefined], key = _b[0], value = _b[1]; - if (key !== undefined) { - result[key] = value; - } - } + function mapEntries(map, f) { + if (!map) { + return undefined; } + var result = createMap(); + map.forEach(function (value, key) { + var _a = f(key, value), newKey = _a[0], newValue = _a[1]; + result.set(newKey, newValue); + }); return result; } - ts.mapObject = mapObject; + ts.mapEntries = mapEntries; function some(array, predicate) { if (array) { if (predicate) { @@ -1914,9 +2028,6 @@ var ts; /** * Indicates whether a map-like contains an own property with the specified key. * - * NOTE: This is intended for use only with MapLike objects. For Map objects, use - * the 'in' operator. - * * @param map A map-like. * @param key A property key. */ @@ -1927,9 +2038,6 @@ var ts; /** * Gets the value of an owned property in a map-like. * - * NOTE: This is intended for use only with MapLike objects. For Map objects, use - * an indexer. - * * @param map A map-like. * @param key A property key. */ @@ -1954,56 +2062,62 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; - /** - * Enumerates the properties of a Map, invoking a callback and returning the first truthy result. - * - * @param map A map for which properties should be enumerated. - * @param callback A callback to invoke for each property. - */ - function forEachProperty(map, callback) { - var result; - for (var key in map) { - if (result = callback(map[key], key)) - break; + /** Shims `Array.from`. */ + function arrayFrom(iterator) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(value); } return result; + var _b; } - ts.forEachProperty = forEachProperty; - /** - * Returns true if a Map has some matching property. - * - * @param map A map whose properties should be tested. - * @param predicate An optional callback used to test each property. - */ - function someProperties(map, predicate) { - for (var key in map) { - if (!predicate || predicate(map[key], key)) - return true; + ts.arrayFrom = arrayFrom; + function convertToArray(iterator, f) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(f(value)); } - return false; + return result; + var _b; } - ts.someProperties = someProperties; + ts.convertToArray = convertToArray; /** - * Performs a shallow copy of the properties from a source Map to a target MapLike - * - * @param source A map from which properties should be copied. - * @param target A map to which properties should be copied. + * Calls `callback` for each entry in the map, returning the first truthy result. + * Use `map.forEach` instead for normal iteration. */ - function copyProperties(source, target) { - for (var key in source) { - target[key] = source[key]; + function forEachEntry(map, callback) { + var iterator = map.entries(); + for (var _a = iterator.next(), pair = _a.value, done = _a.done; !done; _b = iterator.next(), pair = _b.value, done = _b.done, _b) { + var key = pair[0], value = pair[1]; + var result = callback(value, key); + if (result) { + return result; + } } + return undefined; + var _b; } - ts.copyProperties = copyProperties; - function appendProperty(map, key, value) { - if (key === undefined || value === undefined) - return map; - if (map === undefined) - map = createMap(); - map[key] = value; - return map; + ts.forEachEntry = forEachEntry; + /** `forEachEntry` for just keys. */ + function forEachKey(map, callback) { + var iterator = map.keys(); + for (var _a = iterator.next(), key = _a.value, done = _a.done; !done; _b = iterator.next(), key = _b.value, done = _b.done, _b) { + var result = callback(key); + if (result) { + return result; + } + } + return undefined; + var _b; } - ts.appendProperty = appendProperty; + ts.forEachKey = forEachKey; + /** Copy entries from `source` to `target`. */ + function copyEntries(source, target) { + source.forEach(function (value, key) { + target.set(key, value); + }); + } + ts.copyEntries = copyEntries; function assign(t) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -2019,24 +2133,6 @@ var ts; return t; } ts.assign = assign; - /** - * Reduce the properties of a map. - * - * NOTE: This is intended for use with Map objects. For MapLike objects, use - * reduceOwnProperties instead as it offers better runtime safety. - * - * @param map The map to reduce - * @param callback An aggregation function that is called for each entry in the map - * @param initial The initial value for the reduction. - */ - function reduceProperties(map, callback, initial) { - var result = initial; - for (var key in map) { - result = callback(result, map[key], String(key)); - } - return result; - } - ts.reduceProperties = reduceProperties; /** * Performs a shallow equality comparison of the contents of two map-likes. * @@ -2067,23 +2163,14 @@ var ts; var result = createMap(); for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { var value = array_8[_i]; - result[makeKey(value)] = makeValue ? makeValue(value) : value; + result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; } ts.arrayToMap = arrayToMap; - function isEmpty(map) { - for (var id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - ts.isEmpty = isEmpty; function cloneMap(map) { var clone = createMap(); - copyProperties(map, clone); + copyEntries(map, clone); return clone; } ts.cloneMap = cloneMap; @@ -2110,36 +2197,32 @@ var ts; return result; } ts.extend = extend; - /** - * Adds the value to an array of values associated with the key, and returns the array. - * Creates the array if it does not already exist. - */ - function multiMapAdd(map, key, value) { - var values = map[key]; + function createMultiMap() { + var map = createMap(); + map.add = multiMapAdd; + map.remove = multiMapRemove; + return map; + } + ts.createMultiMap = createMultiMap; + function multiMapAdd(key, value) { + var values = this.get(key); if (values) { values.push(value); - return values; } else { - return map[key] = [value]; + this.set(key, values = [value]); } + return values; } - ts.multiMapAdd = multiMapAdd; - /** - * Removes a value from an array of values associated with the key. - * Does not preserve the order of those values. - * Does nothing if `key` is not in `map`, or `value` is not in `map[key]`. - */ - function multiMapRemove(map, key, value) { - var values = map[key]; + function multiMapRemove(key, value) { + var values = this.get(key); if (values) { unorderedRemoveItem(values, value); if (!values.length) { - delete map[key]; + this.delete(key); } } } - ts.multiMapRemove = multiMapRemove; /** * Tests whether a value is an array. */ @@ -2220,6 +2303,7 @@ var ts; baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } + ts.formatStringFromArgs = formatStringFromArgs; ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; @@ -2322,9 +2406,12 @@ var ts; if (b === undefined) return 1 /* GreaterThan */; if (ignoreCase) { - if (ts.collator && String.prototype.localeCompare) { - // accent means a ≠ b, a ≠ á, a = A - var result = a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); + // Checking if "collator exists indicates that Intl is available. + // We still have to check if "collator.compare" is correct. If it is not, use "String.localeComapre" + if (ts.collator) { + var result = ts.localeCompareIsCorrect ? + ts.collator.compare(a, b) : + a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); // accent means a ≠ b, a ≠ á, a = A return result < 0 ? -1 /* LessThan */ : result > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; } a = a.toUpperCase(); @@ -2769,6 +2856,17 @@ var ts; var singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; var singleAsteriskRegexFragmentOther = "[^/]*"; function getRegularExpressionForWildcard(specs, basePath, usage) { + var patterns = getRegularExpressionsForWildcards(specs, basePath, usage); + if (!patterns || !patterns.length) { + return undefined; + } + var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + // If excluding, match "foo/bar/baz...", but if including, only allow "foo". + var terminator = usage === "exclude" ? "($|/)" : "$"; + return "^(" + pattern + ")" + terminator; + } + ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; + function getRegularExpressionsForWildcards(specs, basePath, usage) { if (specs === undefined || specs.length === 0) { return undefined; } @@ -2779,31 +2877,10 @@ var ts; * files or directories, does not match subdirectories that start with a . character */ var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; - var pattern = ""; - var hasWrittenSubpattern = false; - for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { - var spec = specs_1[_i]; - if (!spec) { - continue; - } - var subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); - if (subPattern === undefined) { - continue; - } - if (hasWrittenSubpattern) { - pattern += "|"; - } - pattern += "(" + subPattern + ")"; - hasWrittenSubpattern = true; - } - if (!pattern) { - return undefined; - } - // If excluding, match "foo/bar/baz...", but if including, only allow "foo". - var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return flatMap(specs, function (spec) { + return spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + }); } - ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; /** * An "includes" path "foo" is implicitly a glob "foo/** /*" (without the space) if its last component has no extension, * and does not contain any glob characters itself. @@ -2882,6 +2959,7 @@ var ts; currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); return { + includeFilePatterns: map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -2894,34 +2972,50 @@ var ts; currentDirectory = normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; - var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); + var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return new RegExp(pattern, regexFlag); }); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); var excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); - var result = []; + // Associate an array of results with each include regex. This keeps results in order of the "include" order. + // If there are no "includes", then just put everything in results[0]. + var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]]; + var comparer = useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive; for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; visitDirectory(basePath, combinePaths(currentDirectory, basePath)); } - return result; + return flatten(results); function visitDirectory(path, absolutePath) { var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; + files = files.slice().sort(comparer); + directories = directories.slice().sort(comparer); + var _loop_1 = function (current) { + var name = combinePaths(path, current); + var absoluteName = combinePaths(absolutePath, current); + if (extensions && !fileExtensionIsAny(name, extensions)) + return "continue"; + if (excludeRegex && excludeRegex.test(absoluteName)) + return "continue"; + if (!includeFileRegexes) { + results[0].push(name); + } + else { + var includeIndex = findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); }); + if (includeIndex !== -1) { + results[includeIndex].push(name); + } + } + }; for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var current = files_1[_i]; - var name_1 = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); - if ((!extensions || fileExtensionIsAny(name_1, extensions)) && - (!includeFileRegex || includeFileRegex.test(absoluteName)) && - (!excludeRegex || !excludeRegex.test(absoluteName))) { - result.push(name_1); - } + _loop_1(current); } for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var current = directories_1[_b]; - var name_2 = combinePaths(path, current); + var name = combinePaths(path, current); var absoluteName = combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { - visitDirectory(name_2, absoluteName); + visitDirectory(name, absoluteName); } } } @@ -2946,7 +3040,7 @@ var ts; } // Sort the offsets array using either the literal or canonical path representations. includeBasePaths.sort(useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); - var _loop_1 = function (includeBasePath) { + var _loop_2 = function (includeBasePath) { if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { basePaths.push(includeBasePath); } @@ -2955,7 +3049,7 @@ var ts; // subpath of an existing base path for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) { var includeBasePath = includeBasePaths_1[_a]; - _loop_1(includeBasePath); + _loop_2(includeBasePath); } } return basePaths; @@ -3006,13 +3100,13 @@ var ts; var allSupportedExtensions = ts.supportedTypeScriptExtensions.concat(ts.supportedJavascriptExtensions); function getSupportedExtensions(options, extraFileExtensions) { var needAllExtensions = options && options.allowJs; - if (!extraFileExtensions || extraFileExtensions.length === 0) { + if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } - var extensions = (needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions).slice(0); + var extensions = allSupportedExtensions.slice(0); for (var _i = 0, extraFileExtensions_1 = extraFileExtensions; _i < extraFileExtensions_1.length; _i++) { var extInfo = extraFileExtensions_1[_i]; - if (needAllExtensions || extInfo.scriptKind === 3 /* TS */) { + if (extensions.indexOf(extInfo.extension) === -1) { extensions.push(extInfo.extension); } } @@ -3049,14 +3143,13 @@ var ts; (function (ExtensionPriority) { ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; - ExtensionPriority[ExtensionPriority["Limit"] = 5] = "Limit"; ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; })(ExtensionPriority = ts.ExtensionPriority || (ts.ExtensionPriority = {})); function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { - return adjustExtensionPriority(i); + return adjustExtensionPriority(i, supportedExtensions); } } // If its not in the list of supported extensions, this is likely a @@ -3067,27 +3160,27 @@ var ts; /** * Adjusts an extension priority to be the highest priority within the same range. */ - function adjustExtensionPriority(extensionPriority) { + function adjustExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) { return 0 /* TypeScriptFiles */; } - else if (extensionPriority < 5 /* Limit */) { + else if (extensionPriority < supportedExtensions.length) { return 2 /* DeclarationAndJavaScriptFiles */; } else { - return 5 /* Limit */; + return supportedExtensions.length; } } ts.adjustExtensionPriority = adjustExtensionPriority; /** * Gets the next lowest extension priority for a given priority. */ - function getNextLowestExtensionPriority(extensionPriority) { + function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) { return 2 /* DeclarationAndJavaScriptFiles */; } else { - return 5 /* Limit */; + return supportedExtensions.length; } } ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority; @@ -3481,32 +3574,32 @@ var ts; function createWatchedFileSet() { var dirWatchers = ts.createMap(); // One file can have multiple watchers - var fileWatcherCallbacks = ts.createMap(); + var fileWatcherCallbacks = ts.createMultiMap(); return { addFile: addFile, removeFile: removeFile }; function reduceDirWatcherRefCountForFile(fileName) { var dirName = ts.getDirectoryPath(fileName); - var watcher = dirWatchers[dirName]; + var watcher = dirWatchers.get(dirName); if (watcher) { watcher.referenceCount -= 1; if (watcher.referenceCount <= 0) { watcher.close(); - delete dirWatchers[dirName]; + dirWatchers.delete(dirName); } } } function addDirWatcher(dirPath) { - var watcher = dirWatchers[dirPath]; + var watcher = dirWatchers.get(dirPath); if (watcher) { watcher.referenceCount += 1; return; } watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); watcher.referenceCount = 1; - dirWatchers[dirPath] = watcher; + dirWatchers.set(dirPath, watcher); return; } function addFileWatcherCallback(filePath, callback) { - ts.multiMapAdd(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.add(filePath, callback); } function addFile(fileName, callback) { addFileWatcherCallback(fileName, callback); @@ -3518,7 +3611,7 @@ var ts; reduceDirWatcherRefCountForFile(watchedFile.fileName); } function removeFileWatcherCallback(filePath, callback) { - ts.multiMapRemove(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.remove(filePath, callback); } function fileEventHandler(eventName, relativeFileName, baseDirPath) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" @@ -3526,10 +3619,13 @@ var ts; ? undefined : ts.getNormalizedAbsolutePath(relativeFileName, baseDirPath); // Some applications save a working file via rename operations - if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks[fileName]) { - for (var _i = 0, _a = fileWatcherCallbacks[fileName]; _i < _a.length; _i++) { - var fileCallback = _a[_i]; - fileCallback(fileName); + if ((eventName === "change" || eventName === "rename")) { + var callbacks = fileWatcherCallbacks.get(fileName); + if (callbacks) { + for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) { + var fileCallback = callbacks_1[_i]; + fileCallback(fileName); + } } } } @@ -3605,10 +3701,10 @@ var ts; if (entry === "." || entry === "..") { continue; } - var name_3 = ts.combinePaths(path, entry); + var name = ts.combinePaths(path, entry); var stat = void 0; try { - stat = _fs.statSync(name_3); + stat = _fs.statSync(name); } catch (e) { continue; @@ -3689,7 +3785,10 @@ var ts; // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643) var options; - if (!directoryExists(directoryName)) { + if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { + // do nothing if either + // - target folder does not exist + // - this is UNC path on Windows (https://github.com/Microsoft/TypeScript/issues/13874) return noOpFileWatcher; } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { @@ -3708,6 +3807,9 @@ var ts; } ; }); + function isUNCPath(s) { + return s.length > 2 && s.charCodeAt(0) === 47 /* slash */ && s.charCodeAt(1) === 47 /* slash */; + } }, resolvePath: function (path) { return _path.resolve(path); @@ -3770,6 +3872,7 @@ var ts; require("source-map-support").install(); } catch (e) { + // Could not enable source maps. } }, setTimeout: setTimeout, @@ -3915,7 +4018,7 @@ var ts; _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, 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." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." }, 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." }, @@ -4026,6 +4129,7 @@ var ts; 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." }, + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", message: "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules." }, 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_Set_the_experimentalDecorators_option_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_Set_t_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", message: "Generators are only available when targeting ECMAScript 2015 or higher." }, @@ -4072,6 +4176,7 @@ var ts; Global_module_exports_may_only_appear_at_top_level: { code: 1316, category: ts.DiagnosticCategory.Error, key: "Global_module_exports_may_only_appear_at_top_level_1316", message: "Global module exports may only appear at top level." }, A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, 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." }, @@ -4301,6 +4406,10 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, + A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: { code: 2545, category: ts.DiagnosticCategory.Error, key: "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", message: "A mixin class must have a constructor with a single rest parameter of type 'any[]'." }, + Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: { code: 2546, category: ts.DiagnosticCategory.Error, key: "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", message: "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union 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." }, @@ -4310,6 +4419,8 @@ var ts; 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" }, + JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, + Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: { code: 2649, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", message: "Cannot augment module '{0}' with value exports because it resolves to a non-module entity." }, 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." }, @@ -4358,9 +4469,15 @@ var ts; The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { code: 2696, category: ts.DiagnosticCategory.Error, key: "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", message: "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?" }, An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, + Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: { code: 2699, category: ts.DiagnosticCategory.Error, key: "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", message: "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'." }, Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, + An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: { code: 2705, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", message: "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option." }, + Required_type_parameters_may_not_follow_optional_type_parameters: { code: 2706, category: ts.DiagnosticCategory.Error, key: "Required_type_parameters_may_not_follow_optional_type_parameters_2706", message: "Required type parameters may not follow optional type parameters." }, + Generic_type_0_requires_between_1_and_2_type_arguments: { code: 2707, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_between_1_and_2_type_arguments_2707", message: "Generic type '{0}' requires between {1} and {2} type arguments." }, 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}'." }, @@ -4371,8 +4488,8 @@ var ts; 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}'." }, + 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}'." }, @@ -4435,6 +4552,7 @@ var ts; Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { code: 4090, category: ts.DiagnosticCategory.Message, key: "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", message: "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", message: "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4092, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", message: "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'." }, + extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced: { code: 4093, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced_4093", message: "'extends' clause of exported class '{0}' refers to a type whose name cannot be referenced." }, 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." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, @@ -4480,7 +4598,7 @@ var ts; 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." }, + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'" }, 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" }, @@ -4495,6 +4613,7 @@ var ts; LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION_6037", message: "LOCATION" }, DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY_6038", message: "DIRECTORY" }, STRATEGY: { code: 6039, category: ts.DiagnosticCategory.Message, key: "STRATEGY_6039", message: "STRATEGY" }, + FILE_OR_DIRECTORY: { code: 6040, category: ts.DiagnosticCategory.Message, key: "FILE_OR_DIRECTORY_6040", message: "FILE OR 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." }, @@ -4528,7 +4647,8 @@ var ts; 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_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, - 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'" }, + Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'" }, + File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, @@ -4542,12 +4662,12 @@ var ts; Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, - Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", message: "Loading module as file / folder, candidate module location '{0}', target file type '{1}'." }, File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, - Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, - package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, + package_json_does_not_have_a_0_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_0_field_6100", message: "'package.json' does not have a '{0}' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, @@ -4584,7 +4704,6 @@ var ts; Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, - No_types_specified_in_package_json_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json', so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, @@ -4594,6 +4713,8 @@ var ts; Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, + Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, + Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, 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." }, @@ -4635,7 +4756,7 @@ var ts; 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." }, 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." }, - 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." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: { 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' clause." }, 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." }, Language_service_is_disabled: { code: 9004, category: ts.DiagnosticCategory.Error, key: "Language_service_is_disabled_9004", message: "Language service is disabled." }, 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'." }, @@ -4650,22 +4771,26 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, - Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, - Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, - Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, + Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: {0}" }, + Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, + Add_this_to_unresolved_variable: { code: 90008, category: ts.DiagnosticCategory.Message, key: "Add_this_to_unresolved_variable_90008", message: "Add 'this.' to unresolved variable." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, }; })(ts || (ts = {})); /// @@ -4677,7 +4802,7 @@ var ts; return token >= 70 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = ts.createMap({ + var textToToken = ts.createMapFromTemplate({ "abstract": 116 /* AbstractKeyword */, "any": 118 /* AnyKeyword */, "as": 117 /* AsKeyword */, @@ -4701,7 +4826,7 @@ var ts; "false": 85 /* FalseKeyword */, "finally": 86 /* FinallyKeyword */, "for": 87 /* ForKeyword */, - "from": 138 /* FromKeyword */, + "from": 139 /* FromKeyword */, "function": 88 /* FunctionKeyword */, "get": 124 /* GetKeyword */, "if": 89 /* IfKeyword */, @@ -4719,27 +4844,28 @@ var ts; "new": 93 /* NewKeyword */, "null": 94 /* NullKeyword */, "number": 132 /* NumberKeyword */, + "object": 133 /* ObjectKeyword */, "package": 110 /* PackageKeyword */, "private": 111 /* PrivateKeyword */, "protected": 112 /* ProtectedKeyword */, "public": 113 /* PublicKeyword */, "readonly": 130 /* ReadonlyKeyword */, "require": 131 /* RequireKeyword */, - "global": 139 /* GlobalKeyword */, + "global": 140 /* GlobalKeyword */, "return": 95 /* ReturnKeyword */, - "set": 133 /* SetKeyword */, + "set": 134 /* SetKeyword */, "static": 114 /* StaticKeyword */, - "string": 134 /* StringKeyword */, + "string": 135 /* StringKeyword */, "super": 96 /* SuperKeyword */, "switch": 97 /* SwitchKeyword */, - "symbol": 135 /* SymbolKeyword */, + "symbol": 136 /* SymbolKeyword */, "this": 98 /* ThisKeyword */, "throw": 99 /* ThrowKeyword */, "true": 100 /* TrueKeyword */, "try": 101 /* TryKeyword */, - "type": 136 /* TypeKeyword */, + "type": 137 /* TypeKeyword */, "typeof": 102 /* TypeOfKeyword */, - "undefined": 137 /* UndefinedKeyword */, + "undefined": 138 /* UndefinedKeyword */, "var": 103 /* VarKeyword */, "void": 104 /* VoidKeyword */, "while": 105 /* WhileKeyword */, @@ -4747,7 +4873,7 @@ var ts; "yield": 115 /* YieldKeyword */, "async": 119 /* AsyncKeyword */, "await": 120 /* AwaitKeyword */, - "of": 140 /* OfKeyword */, + "of": 141 /* OfKeyword */, "{": 16 /* OpenBraceToken */, "}": 17 /* CloseBraceToken */, "(": 18 /* OpenParenToken */, @@ -4887,9 +5013,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var name_4 in source) { - result[source[name_4]] = name_4; - } + source.forEach(function (value, name) { + result[value] = name; + }); return result; } var tokenStrings = makeReverseMap(textToToken); @@ -4899,7 +5025,7 @@ var ts; ts.tokenToString = tokenToString; /* @internal */ function stringToToken(s) { - return textToToken[s]; + return textToToken.get(s); } ts.stringToToken = stringToToken; /* @internal */ @@ -4973,7 +5099,6 @@ var ts; return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - var hasOwnProperty = Object.prototype.hasOwnProperty; function isWhiteSpace(ch) { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } @@ -5132,7 +5257,7 @@ var ts; 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++) { + for (var i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -5344,7 +5469,7 @@ var ts; if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { return false; } - for (var i = 1, n = name.length; i < n; i++) { + for (var i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -5716,8 +5841,11 @@ var ts; 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]; + if (ch >= 97 /* a */ && ch <= 122 /* z */) { + token = textToToken.get(tokenValue); + if (token !== undefined) { + return token; + } } } return token = 70 /* Identifier */; @@ -6410,6 +6538,19 @@ var ts; return undefined; } ts.getDeclarationOfKind = getDeclarationOfKind; + function findDeclaration(symbol, predicate) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; + if (predicate(declaration)) { + return declaration; + } + } + } + return undefined; + } + ts.findDeclaration = findDeclaration; // Pool writers to avoid needing to allocate them for every symbol we write. var stringWriters = []; function getSingleLineStringWriter() { @@ -6433,7 +6574,8 @@ var ts; decreaseIndent: ts.noop, clear: function () { return str_1 = ""; }, trackSymbol: ts.noop, - reportInaccessibleThisError: ts.noop + reportInaccessibleThisError: ts.noop, + reportIllegalExtends: ts.noop }; } return stringWriters.pop(); @@ -6449,25 +6591,25 @@ var ts; } ts.getFullWidth = getFullWidth; function hasResolvedModule(sourceFile, moduleNameText) { - return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); + return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText)); } ts.hasResolvedModule = hasResolvedModule; function getResolvedModule(sourceFile, moduleNameText) { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules.get(moduleNameText) : undefined; } ts.getResolvedModule = getResolvedModule; function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { if (!sourceFile.resolvedModules) { sourceFile.resolvedModules = ts.createMap(); } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; + sourceFile.resolvedModules.set(moduleNameText, resolvedModule); } ts.setResolvedModule = setResolvedModule; function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { if (!sourceFile.resolvedTypeReferenceDirectiveNames) { sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); } - sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; + sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective); } ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; /* @internal */ @@ -6489,7 +6631,7 @@ var ts; } for (var i = 0; i < names.length; i++) { var newResolution = newResolutions[i]; - var oldResolution = oldResolutions && oldResolutions[names[i]]; + var oldResolution = oldResolutions && oldResolutions.get(names[i]); var changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) : newResolution; @@ -6524,7 +6666,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 261 /* SourceFile */) { + while (node && node.kind !== 264 /* SourceFile */) { node = node.parent; } return node; @@ -6532,11 +6674,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 204 /* Block */: - case 232 /* CaseBlock */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 206 /* Block */: + case 234 /* CaseBlock */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: return true; } return false; @@ -6627,18 +6769,18 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 292 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 296 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 262 /* FirstJSDocNode */ && node.kind <= 288 /* LastJSDocNode */; + return node.kind >= 266 /* FirstJSDocNode */ && node.kind <= 295 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 278 /* FirstJSDocTagNode */ && node.kind <= 291 /* LastJSDocTagNode */; + return node.kind >= 282 /* FirstJSDocTagNode */ && node.kind <= 295 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -6704,18 +6846,52 @@ var ts; } ts.getLiteralText = getLiteralText; function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 /* NumericLiteral */ && text.length > 1) { + return node.kind === 8 /* NumericLiteral */ + && (getNumericLiteralFlags(text, /*hint*/ 6 /* BinaryOrOctal */) & 6 /* BinaryOrOctal */) !== 0; + } + ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + var NumericLiteralFlags; + (function (NumericLiteralFlags) { + NumericLiteralFlags[NumericLiteralFlags["None"] = 0] = "None"; + NumericLiteralFlags[NumericLiteralFlags["Hexadecimal"] = 1] = "Hexadecimal"; + NumericLiteralFlags[NumericLiteralFlags["Binary"] = 2] = "Binary"; + NumericLiteralFlags[NumericLiteralFlags["Octal"] = 4] = "Octal"; + NumericLiteralFlags[NumericLiteralFlags["Scientific"] = 8] = "Scientific"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctal"] = 6] = "BinaryOrOctal"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctalOrHexadecimal"] = 7] = "BinaryOrOctalOrHexadecimal"; + NumericLiteralFlags[NumericLiteralFlags["All"] = 15] = "All"; + })(NumericLiteralFlags = ts.NumericLiteralFlags || (ts.NumericLiteralFlags = {})); + /** + * Scans a numeric literal string to determine the form of the number. + * @param text Numeric literal text + * @param hint If `Scientific` or `All` is specified, performs a more expensive check to scan for scientific notation. + */ + function getNumericLiteralFlags(text, hint) { + if (text.length > 1) { switch (text.charCodeAt(1)) { case 98 /* b */: case 66 /* B */: + return 2 /* Binary */; case 111 /* o */: case 79 /* O */: - return true; + return 4 /* Octal */; + case 120 /* x */: + case 88 /* X */: + return 1 /* Hexadecimal */; + } + if (hint & 8 /* Scientific */) { + for (var i = text.length - 1; i >= 0; i--) { + switch (text.charCodeAt(i)) { + case 101 /* e */: + case 69 /* E */: + return 8 /* Scientific */; + } + } } } - return false; + return 0 /* None */; } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + ts.getNumericLiteralFlags = getNumericLiteralFlags; function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; } @@ -6724,11 +6900,6 @@ var ts; 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) { @@ -6742,11 +6913,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 223 /* VariableDeclaration */ && node.parent.kind === 256 /* CatchClause */; + return node.kind === 225 /* VariableDeclaration */ && node.parent.kind === 259 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 230 /* ModuleDeclaration */ && + return node && node.kind === 232 /* ModuleDeclaration */ && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -6757,11 +6928,11 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node.kind === 230 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 232 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 261 /* SourceFile */ || - node.kind === 230 /* ModuleDeclaration */ || + return node.kind === 264 /* SourceFile */ || + node.kind === 232 /* ModuleDeclaration */ || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6777,9 +6948,9 @@ var ts; return false; } switch (node.parent.kind) { - case 261 /* SourceFile */: + case 264 /* SourceFile */: return ts.isExternalModule(node.parent); - case 231 /* ModuleBlock */: + case 233 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6791,22 +6962,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 261 /* SourceFile */: - case 232 /* CaseBlock */: - case 256 /* CatchClause */: - case 230 /* ModuleDeclaration */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 150 /* Constructor */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 264 /* SourceFile */: + case 234 /* CaseBlock */: + case 259 /* CatchClause */: + case 232 /* ModuleDeclaration */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 151 /* Constructor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return true; - case 204 /* Block */: + case 206 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return parentNode && !isFunctionLike(parentNode); @@ -6840,7 +7011,7 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: if (isStringOrNumericLiteral(name.expression)) { return name.expression.text; } @@ -6851,10 +7022,10 @@ var ts; function entityNameToString(name) { switch (name.kind) { case 70 /* Identifier */: - return getFullWidth(name) === 0 ? unescapeIdentifier(name.text) : getTextOfNode(name); - case 141 /* QualifiedName */: + return getFullWidth(name) === 0 ? ts.unescapeIdentifier(name.text) : getTextOfNode(name); + case 142 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); } } @@ -6891,7 +7062,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 204 /* Block */) { + if (node.body && node.body.kind === 206 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6905,7 +7076,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 261 /* SourceFile */: + case 264 /* 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 @@ -6914,23 +7085,23 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 223 /* VariableDeclaration */: - case 174 /* BindingElement */: - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 229 /* EnumDeclaration */: - case 260 /* EnumMember */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 228 /* TypeAliasDeclaration */: + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 232 /* ModuleDeclaration */: + case 231 /* EnumDeclaration */: + case 263 /* EnumMember */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 230 /* TypeAliasDeclaration */: errorNode = node.name; break; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -6953,7 +7124,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 229 /* EnumDeclaration */ && isConst(node); + return node.kind === 231 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -6966,11 +7137,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 179 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; + return n.kind === 180 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 207 /* ExpressionStatement */ + return node.kind === 209 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -6983,10 +7154,10 @@ var ts; } ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 144 /* Parameter */ || - node.kind === 143 /* TypeParameter */ || - node.kind === 184 /* FunctionExpression */ || - node.kind === 185 /* ArrowFunction */) ? + var commentRanges = (node.kind === 145 /* Parameter */ || + node.kind === 144 /* TypeParameter */ || + node.kind === 185 /* FunctionExpression */ || + node.kind === 186 /* ArrowFunction */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); // True if the comment starts with '/**' but not if it is '/**/' @@ -7001,39 +7172,39 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (156 /* FirstTypeNode */ <= node.kind && node.kind <= 171 /* LastTypeNode */) { + if (157 /* FirstTypeNode */ <= node.kind && node.kind <= 172 /* LastTypeNode */) { return true; } switch (node.kind) { case 118 /* AnyKeyword */: case 132 /* NumberKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: - case 137 /* UndefinedKeyword */: + case 136 /* SymbolKeyword */: + case 138 /* UndefinedKeyword */: case 129 /* NeverKeyword */: return true; case 104 /* VoidKeyword */: - return node.parent.kind !== 188 /* VoidExpression */; - case 199 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 189 /* VoidExpression */; + case 200 /* 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 70 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 177 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 178 /* 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 === 70 /* Identifier */ || node.kind === 141 /* QualifiedName */ || node.kind === 177 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 141 /* QualifiedName */: - case 177 /* PropertyAccessExpression */: + ts.Debug.assert(node.kind === 70 /* Identifier */ || node.kind === 142 /* QualifiedName */ || node.kind === 178 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 142 /* QualifiedName */: + case 178 /* PropertyAccessExpression */: case 98 /* ThisKeyword */: - var parent_1 = node.parent; - if (parent_1.kind === 160 /* TypeQuery */) { + var parent = node.parent; + if (parent.kind === 161 /* TypeQuery */) { return false; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -7042,38 +7213,38 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (156 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 171 /* LastTypeNode */) { + if (157 /* FirstTypeNode */ <= parent.kind && parent.kind <= 172 /* LastTypeNode */) { return true; } - switch (parent_1.kind) { - case 199 /* ExpressionWithTypeArguments */: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 143 /* TypeParameter */: - return node === parent_1.constraint; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 144 /* Parameter */: - case 223 /* VariableDeclaration */: - return node === parent_1.type; - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 150 /* Constructor */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - return node === parent_1.type; - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - return node === parent_1.type; - case 182 /* TypeAssertionExpression */: - return node === parent_1.type; - case 179 /* CallExpression */: - case 180 /* NewExpression */: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 181 /* TaggedTemplateExpression */: + switch (parent.kind) { + case 200 /* ExpressionWithTypeArguments */: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); + case 144 /* TypeParameter */: + return node === parent.constraint; + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 145 /* Parameter */: + case 225 /* VariableDeclaration */: + return node === parent.type; + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 151 /* Constructor */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + return node === parent.type; + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + return node === parent.type; + case 183 /* TypeAssertionExpression */: + return node === parent.type; + case 180 /* CallExpression */: + case 181 /* NewExpression */: + return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; + case 182 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -7081,29 +7252,43 @@ var ts; return false; } ts.isPartOfTypeNode = isPartOfTypeNode; + function isChildOfNodeWithKind(node, kind) { + while (node) { + if (node.kind === kind) { + return true; + } + node = node.parent; + } + return false; + } + ts.isChildOfNodeWithKind = isChildOfNodeWithKind; + function isPrefixUnaryExpression(node) { + return node.kind === 191 /* PrefixUnaryExpression */; + } + ts.isPrefixUnaryExpression = isPrefixUnaryExpression; // 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 216 /* ReturnStatement */: + case 218 /* ReturnStatement */: return visitor(node); - case 232 /* CaseBlock */: - case 204 /* Block */: - case 208 /* IfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 217 /* WithStatement */: - case 218 /* SwitchStatement */: - case 253 /* CaseClause */: - case 254 /* DefaultClause */: - case 219 /* LabeledStatement */: - case 221 /* TryStatement */: - case 256 /* CatchClause */: + case 234 /* CaseBlock */: + case 206 /* Block */: + case 210 /* IfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 219 /* WithStatement */: + case 220 /* SwitchStatement */: + case 256 /* CaseClause */: + case 257 /* DefaultClause */: + case 221 /* LabeledStatement */: + case 223 /* TryStatement */: + case 259 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -7113,29 +7298,29 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 229 /* EnumDeclaration */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 231 /* EnumDeclaration */: + case 229 /* InterfaceDeclaration */: + case 232 /* ModuleDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* 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 === 142 /* ComputedPropertyName */) { + var name = node.name; + if (name && name.kind === 143 /* 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); + traverse(name.expression); return; } } @@ -7155,10 +7340,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 162 /* ArrayType */) { + if (node && node.kind === 163 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 157 /* TypeReference */) { + else if (node && node.kind === 158 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -7169,14 +7354,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 174 /* BindingElement */: - case 260 /* EnumMember */: - case 144 /* Parameter */: - case 257 /* PropertyAssignment */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 258 /* ShorthandPropertyAssignment */: - case 223 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 263 /* EnumMember */: + case 145 /* Parameter */: + case 260 /* PropertyAssignment */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 261 /* ShorthandPropertyAssignment */: + case 225 /* VariableDeclaration */: return true; } } @@ -7184,11 +7369,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 151 /* GetAccessor */ || node.kind === 152 /* SetAccessor */); + return node && (node.kind === 152 /* GetAccessor */ || node.kind === 153 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 226 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */); + return node && (node.kind === 228 /* ClassDeclaration */ || node.kind === 198 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7197,19 +7382,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 150 /* Constructor */: - case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 151 /* Constructor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return true; } return false; @@ -7217,13 +7402,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: return true; } return false; @@ -7231,30 +7416,42 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: return true; - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; + function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + while (true) { + if (beforeUnwrapLabelCallback) { + beforeUnwrapLabelCallback(node); + } + if (node.statement.kind !== 221 /* LabeledStatement */) { + return node.statement; + } + node = node.statement; + } + } + ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; function isFunctionBlock(node) { - return node && node.kind === 204 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 206 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 149 /* MethodDeclaration */ && node.parent.kind === 176 /* ObjectLiteralExpression */; + return node && node.kind === 150 /* MethodDeclaration */ && node.parent.kind === 177 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 149 /* MethodDeclaration */ && - (node.parent.kind === 176 /* ObjectLiteralExpression */ || - node.parent.kind === 197 /* ClassExpression */); + return node.kind === 150 /* MethodDeclaration */ && + (node.parent.kind === 177 /* ObjectLiteralExpression */ || + node.parent.kind === 198 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -7290,7 +7487,7 @@ var ts; return undefined; } switch (node.kind) { - case 142 /* ComputedPropertyName */: + case 143 /* 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 @@ -7305,9 +7502,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 145 /* Decorator */: + case 146 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 144 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 145 /* 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; @@ -7318,31 +7515,44 @@ var ts; node = node.parent; } break; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 230 /* ModuleDeclaration */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 229 /* EnumDeclaration */: - case 261 /* SourceFile */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 232 /* ModuleDeclaration */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 231 /* EnumDeclaration */: + case 264 /* SourceFile */: return node; } } } ts.getThisContainer = getThisContainer; + function getNewTargetContainer(node) { + var container = getThisContainer(node, /*includeArrowFunctions*/ false); + if (container) { + switch (container.kind) { + case 151 /* Constructor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + return container; + } + } + return undefined; + } + ts.getNewTargetContainer = getNewTargetContainer; /** * Given an super call/property node, returns the closest node where * - a super call/property access is legal in the node and not legal in the parent node the node. @@ -7358,26 +7568,26 @@ var ts; return node; } switch (node.kind) { - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: node = node.parent; break; - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: if (!stopOnFunctions) { continue; } - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return node; - case 145 /* Decorator */: + case 146 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 144 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 145 /* 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; @@ -7393,15 +7603,15 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 184 /* FunctionExpression */ || func.kind === 185 /* ArrowFunction */) { + if (func.kind === 185 /* FunctionExpression */ || func.kind === 186 /* ArrowFunction */) { var prev = func; - var parent_2 = func.parent; - while (parent_2.kind === 183 /* ParenthesizedExpression */) { - prev = parent_2; - parent_2 = parent_2.parent; + var parent = func.parent; + while (parent.kind === 184 /* ParenthesizedExpression */) { + prev = parent; + parent = parent.parent; } - if (parent_2.kind === 179 /* CallExpression */ && parent_2.expression === prev) { - return parent_2; + if (parent.kind === 180 /* CallExpression */ && parent.expression === prev) { + return parent; } } } @@ -7411,21 +7621,21 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 177 /* PropertyAccessExpression */ || kind === 178 /* ElementAccessExpression */) + return (kind === 178 /* PropertyAccessExpression */ || kind === 179 /* ElementAccessExpression */) && node.expression.kind === 96 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 157 /* TypeReference */: - case 272 /* JSDocTypeReference */: + case 158 /* TypeReference */: + case 276 /* JSDocTypeReference */: return node.typeName; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 70 /* Identifier */: - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: return node; } return undefined; @@ -7433,10 +7643,12 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 181 /* TaggedTemplateExpression */: - case 145 /* Decorator */: + case 250 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 182 /* TaggedTemplateExpression */: + case 146 /* Decorator */: return true; default: return false; @@ -7444,34 +7656,37 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 181 /* TaggedTemplateExpression */) { + if (node.kind === 182 /* TaggedTemplateExpression */) { return node.tag; } + else if (isJsxOpeningLikeElement(node)) { + return node.tagName; + } // Will either be a CallExpression, NewExpression, or Decorator. return node.expression; } ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: // classes are valid targets return true; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 226 /* ClassDeclaration */; - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 149 /* MethodDeclaration */: + return node.parent.kind === 228 /* ClassDeclaration */; + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 150 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && node.parent.kind === 226 /* ClassDeclaration */; - case 144 /* Parameter */: + && node.parent.kind === 228 /* ClassDeclaration */; + case 145 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return node.parent.body !== undefined - && (node.parent.kind === 150 /* Constructor */ - || node.parent.kind === 149 /* MethodDeclaration */ - || node.parent.kind === 152 /* SetAccessor */) - && node.parent.parent.kind === 226 /* ClassDeclaration */; + && (node.parent.kind === 151 /* Constructor */ + || node.parent.kind === 150 /* MethodDeclaration */ + || node.parent.kind === 153 /* SetAccessor */) + && node.parent.parent.kind === 228 /* ClassDeclaration */; } return false; } @@ -7487,19 +7702,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 149 /* MethodDeclaration */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 153 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 248 /* JsxOpeningElement */ || - parent.kind === 247 /* JsxSelfClosingElement */ || - parent.kind === 249 /* JsxClosingElement */) { + if (parent.kind === 250 /* JsxOpeningElement */ || + parent.kind === 249 /* JsxSelfClosingElement */ || + parent.kind === 251 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -7513,96 +7728,97 @@ var ts; case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: case 11 /* RegularExpressionLiteral */: - case 175 /* ArrayLiteralExpression */: - case 176 /* ObjectLiteralExpression */: - case 177 /* PropertyAccessExpression */: - case 178 /* ElementAccessExpression */: - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 181 /* TaggedTemplateExpression */: - case 200 /* AsExpression */: - case 182 /* TypeAssertionExpression */: - case 201 /* NonNullExpression */: - case 183 /* ParenthesizedExpression */: - case 184 /* FunctionExpression */: - case 197 /* ClassExpression */: - case 185 /* ArrowFunction */: - case 188 /* VoidExpression */: - case 186 /* DeleteExpression */: - case 187 /* TypeOfExpression */: - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: - case 192 /* BinaryExpression */: - case 193 /* ConditionalExpression */: - case 196 /* SpreadElement */: - case 194 /* TemplateExpression */: + case 176 /* ArrayLiteralExpression */: + case 177 /* ObjectLiteralExpression */: + case 178 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 182 /* TaggedTemplateExpression */: + case 201 /* AsExpression */: + case 183 /* TypeAssertionExpression */: + case 202 /* NonNullExpression */: + case 184 /* ParenthesizedExpression */: + case 185 /* FunctionExpression */: + case 198 /* ClassExpression */: + case 186 /* ArrowFunction */: + case 189 /* VoidExpression */: + case 187 /* DeleteExpression */: + case 188 /* TypeOfExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: + case 193 /* BinaryExpression */: + case 194 /* ConditionalExpression */: + case 197 /* SpreadElement */: + case 195 /* TemplateExpression */: case 12 /* NoSubstitutionTemplateLiteral */: - case 198 /* OmittedExpression */: - case 246 /* JsxElement */: - case 247 /* JsxSelfClosingElement */: - case 195 /* YieldExpression */: - case 189 /* AwaitExpression */: + case 199 /* OmittedExpression */: + case 248 /* JsxElement */: + case 249 /* JsxSelfClosingElement */: + case 196 /* YieldExpression */: + case 190 /* AwaitExpression */: + case 203 /* MetaProperty */: return true; - case 141 /* QualifiedName */: - while (node.parent.kind === 141 /* QualifiedName */) { + case 142 /* QualifiedName */: + while (node.parent.kind === 142 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 160 /* TypeQuery */ || isJSXTagName(node); + return node.parent.kind === 161 /* TypeQuery */ || isJSXTagName(node); case 70 /* Identifier */: - if (node.parent.kind === 160 /* TypeQuery */ || isJSXTagName(node)) { + if (node.parent.kind === 161 /* TypeQuery */ || isJSXTagName(node)) { return true; } // fall through case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 98 /* ThisKeyword */: - var parent_3 = node.parent; - switch (parent_3.kind) { - case 223 /* VariableDeclaration */: - case 144 /* Parameter */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 260 /* EnumMember */: - case 257 /* PropertyAssignment */: - case 174 /* BindingElement */: - return parent_3.initializer === node; - case 207 /* ExpressionStatement */: - case 208 /* IfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 216 /* ReturnStatement */: - case 217 /* WithStatement */: - case 218 /* SwitchStatement */: - case 253 /* CaseClause */: - case 220 /* ThrowStatement */: - case 218 /* SwitchStatement */: - return parent_3.expression === node; - case 211 /* ForStatement */: - var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 224 /* VariableDeclarationList */) || + var parent = node.parent; + switch (parent.kind) { + case 225 /* VariableDeclaration */: + case 145 /* Parameter */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 263 /* EnumMember */: + case 260 /* PropertyAssignment */: + case 175 /* BindingElement */: + return parent.initializer === node; + case 209 /* ExpressionStatement */: + case 210 /* IfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 218 /* ReturnStatement */: + case 219 /* WithStatement */: + case 220 /* SwitchStatement */: + case 256 /* CaseClause */: + case 222 /* ThrowStatement */: + case 220 /* SwitchStatement */: + return parent.expression === node; + case 213 /* ForStatement */: + var forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== 226 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224 /* VariableDeclarationList */) || + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + var forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 226 /* VariableDeclarationList */) || forInStatement.expression === node; - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: - return node === parent_3.expression; - case 202 /* TemplateSpan */: - return node === parent_3.expression; - case 142 /* ComputedPropertyName */: - return node === parent_3.expression; - case 145 /* Decorator */: - case 252 /* JsxExpression */: - case 251 /* JsxSpreadAttribute */: - case 259 /* SpreadAssignment */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: + return node === parent.expression; + case 204 /* TemplateSpan */: + return node === parent.expression; + case 143 /* ComputedPropertyName */: + return node === parent.expression; + case 146 /* Decorator */: + case 255 /* JsxExpression */: + case 254 /* JsxSpreadAttribute */: + case 262 /* SpreadAssignment */: return true; - case 199 /* ExpressionWithTypeArguments */: - return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); + case 200 /* ExpressionWithTypeArguments */: + return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: - if (isPartOfExpression(parent_3)) { + if (isPartOfExpression(parent)) { return true; } } @@ -7617,7 +7833,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 245 /* ExternalModuleReference */; + return node.kind === 236 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 247 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7626,7 +7842,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 245 /* ExternalModuleReference */; + return node.kind === 236 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 247 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7644,7 +7860,7 @@ var ts; */ function isRequireCall(expression, checkArgumentIsStringLiteral) { // of the form 'require("name")' - var isRequire = expression.kind === 179 /* CallExpression */ && + var isRequire = expression.kind === 180 /* CallExpression */ && expression.expression.kind === 70 /* Identifier */ && expression.expression.text === "require" && expression.arguments.length === 1; @@ -7660,9 +7876,9 @@ var ts; * This function does not test if the node is in a JavaScript file or not. */ function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 223 /* VariableDeclaration */) { + if (s.valueDeclaration && s.valueDeclaration.kind === 225 /* VariableDeclaration */) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 184 /* FunctionExpression */; + return declaration.initializer && declaration.initializer.kind === 185 /* FunctionExpression */; } return false; } @@ -7673,11 +7889,11 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0 /* None */; } - if (expression.kind !== 192 /* BinaryExpression */) { + if (expression.kind !== 193 /* BinaryExpression */) { return 0 /* None */; } var expr = expression; - if (expr.operatorToken.kind !== 57 /* EqualsToken */ || expr.left.kind !== 177 /* PropertyAccessExpression */) { + if (expr.operatorToken.kind !== 57 /* EqualsToken */ || expr.left.kind !== 178 /* PropertyAccessExpression */) { return 0 /* None */; } var lhs = expr.left; @@ -7695,7 +7911,7 @@ var ts; else if (lhs.expression.kind === 98 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (lhs.expression.kind === 177 /* PropertyAccessExpression */) { + else if (lhs.expression.kind === 178 /* PropertyAccessExpression */) { // chained dot, e.g. x.y.z = expr; this var is the 'x.y' part var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 70 /* Identifier */) { @@ -7713,35 +7929,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 235 /* ImportDeclaration */) { + if (node.kind === 237 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 236 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 245 /* ExternalModuleReference */) { + if (reference.kind === 247 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 241 /* ExportDeclaration */) { + if (node.kind === 243 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 230 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 232 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 236 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 239 /* NamespaceImport */) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 235 /* ImportDeclaration */ + return node.kind === 237 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } @@ -7749,13 +7965,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 144 /* Parameter */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 258 /* ShorthandPropertyAssignment */: - case 257 /* PropertyAssignment */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 145 /* Parameter */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 261 /* ShorthandPropertyAssignment */: + case 260 /* PropertyAssignment */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -7763,22 +7979,27 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 274 /* JSDocFunctionType */ && + return node.kind === 278 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 276 /* JSDocConstructorType */; + node.parameters[0].type.kind === 280 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { return ts.map(getJSDocs(node), function (doc) { return doc.comment; }); } ts.getCommentsFromJSDoc = getCommentsFromJSDoc; + function hasJSDocParameterTags(node) { + var parameterTags = getJSDocTags(node, 285 /* JSDocParameterTag */); + return parameterTags && parameterTags.length > 0; + } + ts.hasJSDocParameterTags = hasJSDocParameterTags; function getJSDocTags(node, kind) { var docs = getJSDocs(node); if (docs) { var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 281 /* JSDocParameterTag */) { + if (doc.kind === 285 /* JSDocParameterTag */) { if (doc.kind === kind) { result.push(doc); } @@ -7810,9 +8031,9 @@ var ts; // var x = function(name) { return name.length; } var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 205 /* VariableStatement */; + parent.parent.parent.kind === 207 /* VariableStatement */; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 205 /* VariableStatement */; + parent.parent.kind === 207 /* VariableStatement */; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -7821,20 +8042,20 @@ var ts; } // Also recognize when the node is the RHS of an assignment expression var isSourceOfAssignmentExpressionStatement = parent && parent.parent && - parent.kind === 192 /* BinaryExpression */ && + parent.kind === 193 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && - parent.parent.kind === 207 /* ExpressionStatement */; + parent.parent.kind === 209 /* ExpressionStatement */; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 230 /* ModuleDeclaration */ && - parent && parent.kind === 230 /* ModuleDeclaration */; - var isPropertyAssignmentExpression = parent && parent.kind === 257 /* PropertyAssignment */; + var isModuleDeclaration = node.kind === 232 /* ModuleDeclaration */ && + parent && parent.kind === 232 /* ModuleDeclaration */; + var isPropertyAssignmentExpression = parent && parent.kind === 260 /* PropertyAssignment */; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } // Pull parameter comments from declaring function as well - if (node.kind === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { cache = ts.concatenate(cache, getJSDocParameterTags(node)); } if (isVariableLike(node) && node.initializer) { @@ -7848,18 +8069,18 @@ var ts; return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 281 /* JSDocParameterTag */); + var tags = getJSDocTags(func, 285 /* JSDocParameterTag */); if (!param.name) { // this is an anonymous jsdoc param from a `function(type1, type2): type3` specification var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 281 /* JSDocParameterTag */; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 285 /* JSDocParameterTag */; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70 /* Identifier */) { - var name_6 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 281 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); + var name_1 = param.name.text; + return ts.filter(tags, function (tag) { return tag.kind === 285 /* JSDocParameterTag */ && tag.parameterName.text === name_1; }); } else { // TODO: it's a destructured parameter, so it should look up an "object type" series of multiple lines @@ -7869,8 +8090,8 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 283 /* JSDocTypeTag */); - if (!tag && node.kind === 144 /* Parameter */) { + var tag = getFirstJSDocTag(node, 287 /* JSDocTypeTag */); + if (!tag && node.kind === 145 /* Parameter */) { var paramTags = getJSDocParameterTags(node); if (paramTags) { tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); @@ -7880,15 +8101,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 280 /* JSDocAugmentsTag */); + return getFirstJSDocTag(node, 284 /* JSDocAugmentsTag */); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 282 /* JSDocReturnTag */); + return getFirstJSDocTag(node, 286 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 284 /* JSDocTemplateTag */); + return getFirstJSDocTag(node, 288 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -7901,8 +8122,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536 /* JavaScriptFile */)) { - if (node.type && node.type.kind === 275 /* JSDocVariadicType */ || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275 /* JSDocVariadicType */; })) { + if (node.type && node.type.kind === 279 /* JSDocVariadicType */ || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 279 /* JSDocVariadicType */; })) { return true; } } @@ -7923,29 +8144,33 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 57 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 42 /* PlusPlusToken */ || unaryOperator === 43 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 183 /* ParenthesizedExpression */: - case 175 /* ArrayLiteralExpression */: - case 196 /* SpreadElement */: + case 184 /* ParenthesizedExpression */: + case 176 /* ArrayLiteralExpression */: + case 197 /* SpreadElement */: node = parent; break; - case 258 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } - // Fall through - case 257 /* PropertyAssignment */: + node = parent.parent; + break; + case 260 /* PropertyAssignment */: + if (parent.name === node) { + return 0 /* None */; + } node = parent.parent; break; default: @@ -7957,11 +8182,24 @@ var ts; ts.getAssignmentTargetKind = getAssignmentTargetKind; // 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'. + // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ a }] = xxx'. + // (Note that `p` is not a target in the above examples, only `a`.) function isAssignmentTarget(node) { return getAssignmentTargetKind(node) !== 0 /* None */; } ts.isAssignmentTarget = isAssignmentTarget; + // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped + function isDeleteTarget(node) { + if (node.kind !== 178 /* PropertyAccessExpression */ && node.kind !== 179 /* ElementAccessExpression */) { + return false; + } + node = node.parent; + while (node && node.kind === 184 /* ParenthesizedExpression */) { + node = node.parent; + } + return node && node.kind === 187 /* DeleteExpression */; + } + ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { while (node) { if (node === ancestor) @@ -7973,7 +8211,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2 /* Ambient */) || (node.kind === 261 /* SourceFile */ && node.isDeclarationFile)) { + if (hasModifier(node, 2 /* Ambient */) || (node.kind === 264 /* SourceFile */ && node.isDeclarationFile)) { return true; } node = node.parent; @@ -7987,7 +8225,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 239 /* ImportSpecifier */ || parent.kind === 243 /* ExportSpecifier */) { + if (parent.kind === 241 /* ImportSpecifier */ || parent.kind === 245 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -8000,7 +8238,7 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 142 /* ComputedPropertyName */ && + node.parent.kind === 143 /* ComputedPropertyName */ && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -8008,31 +8246,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 260 /* EnumMember */: - case 257 /* PropertyAssignment */: - case 177 /* PropertyAccessExpression */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 263 /* EnumMember */: + case 260 /* PropertyAssignment */: + case 178 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 141 /* QualifiedName */) { + while (parent.kind === 142 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 160 /* TypeQuery */; + return parent.kind === 161 /* TypeQuery */; } return false; - case 174 /* BindingElement */: - case 239 /* ImportSpecifier */: + case 175 /* BindingElement */: + case 241 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 243 /* ExportSpecifier */: + case 245 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -8048,13 +8286,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */ || - node.kind === 233 /* NamespaceExportDeclaration */ || - node.kind === 236 /* ImportClause */ && !!node.name || - node.kind === 237 /* NamespaceImport */ || - node.kind === 239 /* ImportSpecifier */ || - node.kind === 243 /* ExportSpecifier */ || - node.kind === 240 /* ExportAssignment */ && exportAssignmentIsAlias(node); + return node.kind === 236 /* ImportEqualsDeclaration */ || + node.kind === 235 /* NamespaceExportDeclaration */ || + node.kind === 238 /* ImportClause */ && !!node.name || + node.kind === 239 /* NamespaceImport */ || + node.kind === 241 /* ImportSpecifier */ || + node.kind === 245 /* ExportSpecifier */ || + node.kind === 242 /* ExportAssignment */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8140,7 +8378,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 71 /* FirstKeyword */ <= token && token <= 140 /* LastKeyword */; + return 71 /* FirstKeyword */ <= token && token <= 141 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -8169,7 +8407,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 142 /* ComputedPropertyName */ && + return name.kind === 143 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -8184,10 +8422,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 144 /* Parameter */) { + if (name.kind === 70 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 145 /* Parameter */) { return name.text; } - if (name.kind === 142 /* ComputedPropertyName */) { + if (name.kind === 143 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -8235,11 +8473,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 144 /* Parameter */; + return root.kind === 145 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 174 /* BindingElement */) { + while (node.kind === 175 /* BindingElement */) { node = node.parent.parent; } return node; @@ -8247,15 +8485,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 150 /* Constructor */ - || kind === 184 /* FunctionExpression */ - || kind === 225 /* FunctionDeclaration */ - || kind === 185 /* ArrowFunction */ - || kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */ - || kind === 230 /* ModuleDeclaration */ - || kind === 261 /* SourceFile */; + return kind === 151 /* Constructor */ + || kind === 185 /* FunctionExpression */ + || kind === 227 /* FunctionDeclaration */ + || kind === 186 /* ArrowFunction */ + || kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */ + || kind === 232 /* ModuleDeclaration */ + || kind === 264 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -8263,49 +8501,22 @@ var ts; || ts.positionIsSynthesized(node.end); } ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node, nodeTest) { - if (node) { - while (node.original !== undefined) { - node = node.original; - } + function getOriginalSourceFileOrBundle(sourceFileOrBundle) { + if (sourceFileOrBundle.kind === 265 /* Bundle */) { + return ts.updateBundle(sourceFileOrBundle, ts.sameMap(sourceFileOrBundle.sourceFiles, getOriginalSourceFile)); } - return !nodeTest || nodeTest(node) ? node : undefined; + return getOriginalSourceFile(sourceFileOrBundle); } - ts.getOriginalNode = getOriginalNode; - /** - * Gets a value indicating whether a node originated in the parse tree. - * - * @param node The node to test. - */ - function isParseTreeNode(node) { - return (node.flags & 8 /* Synthesized */) === 0; + ts.getOriginalSourceFileOrBundle = getOriginalSourceFileOrBundle; + function getOriginalSourceFile(sourceFile) { + return ts.getParseTreeNode(sourceFile, isSourceFile) || sourceFile; } - ts.isParseTreeNode = isParseTreeNode; - function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { - return node; - } - node = getOriginalNode(node); - if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { - return node; - } - return undefined; - } - ts.getParseTreeNode = getParseTreeNode; function getOriginalSourceFiles(sourceFiles) { - var originalSourceFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); - if (originalSourceFile) { - originalSourceFiles.push(originalSourceFile); - } - } - return originalSourceFiles; + return ts.sameMap(sourceFiles, getOriginalSourceFile); } ts.getOriginalSourceFiles = getOriginalSourceFiles; function getOriginalNodeId(node) { - node = getOriginalNode(node); + node = ts.getOriginalNode(node); return node ? ts.getNodeId(node) : 0; } ts.getOriginalNodeId = getOriginalNodeId; @@ -8316,23 +8527,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 180 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 181 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 180 /* NewExpression */: + case 181 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 190 /* PrefixUnaryExpression */: - case 187 /* TypeOfExpression */: - case 188 /* VoidExpression */: - case 186 /* DeleteExpression */: - case 189 /* AwaitExpression */: - case 193 /* ConditionalExpression */: - case 195 /* YieldExpression */: + case 191 /* PrefixUnaryExpression */: + case 188 /* TypeOfExpression */: + case 189 /* VoidExpression */: + case 187 /* DeleteExpression */: + case 190 /* AwaitExpression */: + case 194 /* ConditionalExpression */: + case 196 /* YieldExpression */: return 1 /* Right */; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (operator) { case 39 /* AsteriskAsteriskToken */: case 57 /* EqualsToken */: @@ -8356,15 +8567,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 180 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 181 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 192 /* BinaryExpression */) { + if (expression.kind === 193 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 190 /* PrefixUnaryExpression */ || expression.kind === 191 /* PostfixUnaryExpression */) { + else if (expression.kind === 191 /* PrefixUnaryExpression */ || expression.kind === 192 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -8382,37 +8593,36 @@ var ts; case 85 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 175 /* ArrayLiteralExpression */: - case 176 /* ObjectLiteralExpression */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 197 /* ClassExpression */: - case 246 /* JsxElement */: - case 247 /* JsxSelfClosingElement */: + case 176 /* ArrayLiteralExpression */: + case 177 /* ObjectLiteralExpression */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 198 /* ClassExpression */: + case 248 /* JsxElement */: + case 249 /* JsxSelfClosingElement */: case 11 /* RegularExpressionLiteral */: case 12 /* NoSubstitutionTemplateLiteral */: - case 194 /* TemplateExpression */: - case 183 /* ParenthesizedExpression */: - case 198 /* OmittedExpression */: - case 297 /* RawExpression */: + case 195 /* TemplateExpression */: + case 184 /* ParenthesizedExpression */: + case 199 /* OmittedExpression */: return 19; - case 181 /* TaggedTemplateExpression */: - case 177 /* PropertyAccessExpression */: - case 178 /* ElementAccessExpression */: + case 182 /* TaggedTemplateExpression */: + case 178 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: return 18; - case 180 /* NewExpression */: + case 181 /* NewExpression */: return hasArguments ? 18 : 17; - case 179 /* CallExpression */: + case 180 /* CallExpression */: return 17; - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return 16; - case 190 /* PrefixUnaryExpression */: - case 187 /* TypeOfExpression */: - case 188 /* VoidExpression */: - case 186 /* DeleteExpression */: - case 189 /* AwaitExpression */: + case 191 /* PrefixUnaryExpression */: + case 188 /* TypeOfExpression */: + case 189 /* VoidExpression */: + case 187 /* DeleteExpression */: + case 190 /* AwaitExpression */: return 15; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (operatorKind) { case 50 /* ExclamationToken */: case 51 /* TildeToken */: @@ -8470,11 +8680,11 @@ var ts; default: return -1; } - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return 4; - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return 2; - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return 1; default: return -1; @@ -8497,21 +8707,15 @@ var ts; 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; - } + ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); } function add(diagnostic) { var diagnostics; if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); if (!diagnostics) { diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; + fileDiagnostics.set(diagnostic.file.fileName, diagnostics); } } else { @@ -8528,16 +8732,16 @@ var ts; function getDiagnostics(fileName) { sortAndDeduplicate(); if (fileName) { - return fileDiagnostics[fileName] || []; + return fileDiagnostics.get(fileName) || []; } var allDiagnostics = []; function pushDiagnostic(d) { allDiagnostics.push(d); } ts.forEach(nonFileDiagnostics, pushDiagnostic); - for (var key in fileDiagnostics) { - ts.forEach(fileDiagnostics[key], pushDiagnostic); - } + fileDiagnostics.forEach(function (diagnostics) { + ts.forEach(diagnostics, pushDiagnostic); + }); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function sortAndDeduplicate() { @@ -8546,9 +8750,9 @@ var ts; } diagnosticsModified = false; nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (var key in fileDiagnostics) { - fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } + fileDiagnostics.forEach(function (diagnostics, key) { + fileDiagnostics.set(key, ts.sortAndDeduplicateDiagnostics(diagnostics)); + }); } } ts.createDiagnosticCollection = createDiagnosticCollection; @@ -8558,7 +8762,7 @@ var ts; // 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 = ts.createMap({ + var escapedCharsMap = ts.createMapFromTemplate({ "\0": "\\0", "\t": "\\t", "\v": "\\v", @@ -8578,13 +8782,12 @@ var ts; * 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)); - } + return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; + function getReplacement(c) { + return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } function isIntrinsicJsxName(name) { var ch = name.substr(0, 1); return ch.toLowerCase() === ch; @@ -8741,168 +8944,77 @@ var ts; */ function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); + var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); }; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); - var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = getAllEmittableSourceFiles(); + var moduleEmitEnabled_1 = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified - return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); + return ts.filter(host.getSourceFiles(), function (sourceFile) { + return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); + }); } else { - var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; - return filterSourceFilesInDirectory(sourceFiles, function (file) { return host.isSourceFileFromExternalLibrary(file); }); - } - function getAllEmittableSourceFiles() { - return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); + var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); }); } } ts.getSourceFilesToEmit = getSourceFilesToEmit; - /** Don't call this for `--outFile`, just for `--outDir` or plain emit. */ - function filterSourceFilesInDirectory(sourceFiles, isSourceFileFromExternalLibrary) { - return ts.filter(sourceFiles, function (file) { return shouldEmitInDirectory(file, isSourceFileFromExternalLibrary); }); - } - ts.filterSourceFilesInDirectory = filterSourceFilesInDirectory; - function isNonDeclarationFile(sourceFile) { - return !isDeclarationFile(sourceFile); + /** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */ + function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary) { + return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !isDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); } + ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; /** - * Whether a file should be emitted in a non-`--outFile` case. - * Don't emit if source file is a declaration file, or was located under node_modules - */ - function shouldEmitInDirectory(sourceFile, isSourceFileFromExternalLibrary) { - return isNonDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); - } - function isBundleEmitNonExternalModule(sourceFile) { - return isNonDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); - } - /** - * Iterates over each source file to emit. The source files are expected to have been - * transformed for use by the pretty printer. - * - * Originally part of `forEachExpectedEmitFile`, this functionality was extracted to support - * transformations. + * Iterates over the source files that are expected to have an emit output. * * @param host An EmitHost. - * @param sourceFiles The transformed source files to emit. * @param action The action to execute. + * @param sourceFilesOrTargetSourceFile + * If an array, the full list of source files to emit. + * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); - // Emit on each source file if (options.outFile || options.out) { - onBundledEmit(sourceFiles); - } - else { - for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { - var sourceFile = sourceFiles_2[_i]; - // Don't emit if source file is a declaration file, or was located under node_modules - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } - } - } - function onSingleFileEmit(host, sourceFile) { - // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. - // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. - // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve - var extension = ".js"; - if (options.jsx === 1 /* Preserve */) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1 /* JSX */) { - // TypeScript source file preserving JSX syntax - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], /*isBundledEmit*/ false); - } - function onBundledEmit(sourceFiles) { if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, /*isBundledEmit*/ true); + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, ts.createBundle(sourceFiles), emitOnlyDtsFiles); + } + } + else { + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, sourceFile, emitOnlyDtsFiles); } } } - ts.forEachTransformedEmitFile = forEachTransformedEmitFile; + ts.forEachEmittedFile = forEachEmittedFile; function getSourceMapFilePath(jsFilePath, options) { return options.sourceMap ? jsFilePath + ".map" : undefined; } - /** - * Iterates over the source files that are expected to have an emit output. This function - * is used by the legacy emitter and the declaration emitter and should not be used by - * the tree transforming emitter. - * - * @param host An EmitHost. - * @param action The action to execute. - * @param targetSourceFile An optional target source file to emit. - */ - function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - // Emit on each source file - if (options.outFile || options.out) { - onBundledEmit(host); - } - else { - var sourceFiles = targetSourceFile === undefined ? getSourceFilesToEmit(host) : [targetSourceFile]; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; - if (shouldEmitInDirectory(sourceFile, function (file) { return host.isSourceFileFromExternalLibrary(file); })) { - onSingleFileEmit(host, sourceFile); + // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. + // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. + // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve + function getOutputExtension(sourceFile, options) { + if (options.jsx === 1 /* Preserve */) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + return ".jsx"; } } - } - function onSingleFileEmit(host, sourceFile) { - // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. - // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. - // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve - var extension = ".js"; - if (options.jsx === 1 /* Preserve */) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1 /* JSX */) { - // TypeScript source file preserving JSX syntax - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: declarationFilePath - }; - action(emitFileNames, [sourceFile], /*isBundledEmit*/ false, emitOnlyDtsFiles); - } - function onBundledEmit(host) { - // Can emit only sources that are not declaration file and are either non module code or module with - // --module or --target es6 specified. Files included by searching under node_modules are also not emitted. - var bundledSources = ts.filter(getSourceFilesToEmit(host), function (sourceFile) { return !isDeclarationFile(sourceFile) && - !host.isSourceFileFromExternalLibrary(sourceFile) && - (!ts.isExternalModule(sourceFile) || - !!ts.getEmitModuleKind(options)); }); - if (bundledSources.length) { - var jsFilePath = options.outFile || options.out; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined - }; - action(emitFileNames, bundledSources, /*isBundledEmit*/ true, emitOnlyDtsFiles); + else if (sourceFile.languageVariant === 1 /* JSX */) { + // TypeScript source file preserving JSX syntax + return ".jsx"; } } + return ".js"; } - ts.forEachExpectedEmitFile = forEachExpectedEmitFile; function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); var commonSourceDirectory = host.getCommonSourceDirectory(); @@ -8927,7 +9039,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 150 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 151 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -8969,10 +9081,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 151 /* GetAccessor */) { + if (accessor.kind === 152 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 152 /* SetAccessor */) { + else if (accessor.kind === 153 /* SetAccessor */) { setAccessor = accessor; } else { @@ -8981,7 +9093,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 151 /* GetAccessor */ || member.kind === 152 /* SetAccessor */) + if ((member.kind === 152 /* GetAccessor */ || member.kind === 153 /* SetAccessor */) && hasModifier(member, 32 /* Static */) === hasModifier(accessor, 32 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -8992,10 +9104,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 151 /* GetAccessor */ && !getAccessor) { + if (member.kind === 152 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 152 /* SetAccessor */ && !setAccessor) { + if (member.kind === 153 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -9258,7 +9370,7 @@ var ts; ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 199 /* ExpressionWithTypeArguments */ && + if (node.kind === 200 /* ExpressionWithTypeArguments */ && node.parent.token === 84 /* ExtendsKeyword */ && isClassLike(node.parent.parent)) { return node.parent.parent; @@ -9276,8 +9388,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 176 /* ObjectLiteralExpression */ - || kind === 175 /* ArrayLiteralExpression */; + return kind === 177 /* ObjectLiteralExpression */ + || kind === 176 /* ArrayLiteralExpression */; } return false; } @@ -9305,29 +9417,33 @@ var ts; ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { return node.kind === 70 /* Identifier */ || - node.kind === 177 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); + node.kind === 178 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 177 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 176 /* ObjectLiteralExpression */) { + if (kind === 177 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 175 /* ArrayLiteralExpression */) { + if (kind === 176 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; } ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; + return isExportDefaultSymbol(symbol) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function isExportDefaultSymbol(symbol) { + return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512 /* Default */); + } + ts.isExportDefaultSymbol = isExportDefaultSymbol; /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTypeScriptExtension(fileName) { return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); @@ -9439,39 +9555,39 @@ var ts; || kind === 94 /* NullKeyword */) { return true; } - else if (kind === 177 /* PropertyAccessExpression */) { + else if (kind === 178 /* PropertyAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 178 /* ElementAccessExpression */) { + else if (kind === 179 /* ElementAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 190 /* PrefixUnaryExpression */ - || kind === 191 /* PostfixUnaryExpression */) { + else if (kind === 191 /* PrefixUnaryExpression */ + || kind === 192 /* PostfixUnaryExpression */) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 192 /* BinaryExpression */) { + else if (kind === 193 /* BinaryExpression */) { return node.operatorToken.kind !== 39 /* AsteriskAsteriskToken */ && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 193 /* ConditionalExpression */) { + else if (kind === 194 /* ConditionalExpression */) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 188 /* VoidExpression */ - || kind === 187 /* TypeOfExpression */ - || kind === 186 /* DeleteExpression */) { + else if (kind === 189 /* VoidExpression */ + || kind === 188 /* TypeOfExpression */ + || kind === 187 /* DeleteExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 175 /* ArrayLiteralExpression */) { + else if (kind === 176 /* ArrayLiteralExpression */) { return node.elements.length === 0; } - else if (kind === 176 /* ObjectLiteralExpression */) { + else if (kind === 177 /* ObjectLiteralExpression */) { return node.properties.length === 0; } - else if (kind === 179 /* CallExpression */) { + else if (kind === 180 /* CallExpression */) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9486,16 +9602,19 @@ var ts; } return false; } - var syntaxKindCache = ts.createMap(); + var syntaxKindCache = []; function formatSyntaxKind(kind) { var syntaxKindEnum = ts.SyntaxKind; if (syntaxKindEnum) { - if (syntaxKindCache[kind]) { - return syntaxKindCache[kind]; + var cached = syntaxKindCache[kind]; + if (cached !== undefined) { + return cached; } - for (var name_7 in syntaxKindEnum) { - if (syntaxKindEnum[name_7] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_7 + ")"; + for (var name in syntaxKindEnum) { + if (syntaxKindEnum[name] === kind) { + var result = kind + " (" + name + ")"; + syntaxKindCache[kind] = result; + return result; } } } @@ -9504,6 +9623,14 @@ var ts; } } ts.formatSyntaxKind = formatSyntaxKind; + function getRangePos(range) { + return range ? range.pos : -1; + } + ts.getRangePos = getRangePos; + function getRangeEnd(range) { + return range ? range.end : -1; + } + ts.getRangeEnd = getRangeEnd; /** * Increases (or decreases) a position by the provided amount. * @@ -9635,11 +9762,11 @@ var ts; * declaration. */ function isDeclarationNameOfEnumOrNamespace(node) { - var parseNode = getParseTreeNode(node); + var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: + case 231 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -9660,7 +9787,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 /* ClassDeclaration */ && declaration !== node) { + if (declaration.kind === 228 /* ClassDeclaration */ && declaration !== node) { return true; } } @@ -9725,6 +9852,10 @@ var ts; return node.kind === 70 /* Identifier */; } ts.isIdentifier = isIdentifier; + function isVoidExpression(node) { + return node.kind === 189 /* VoidExpression */; + } + ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { // Using `>` here catches both `GeneratedIdentifierKind.None` and `undefined`. return isIdentifier(node) && node.autoGenerateKind > 0 /* None */; @@ -9737,16 +9868,16 @@ var ts; ts.isModifier = isModifier; // Names function isQualifiedName(node) { - return node.kind === 141 /* QualifiedName */; + return node.kind === 142 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 142 /* ComputedPropertyName */; + return node.kind === 143 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 141 /* QualifiedName */ + return kind === 142 /* QualifiedName */ || kind === 70 /* Identifier */; } ts.isEntityName = isEntityName; @@ -9755,7 +9886,7 @@ var ts; return kind === 70 /* Identifier */ || kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 142 /* ComputedPropertyName */; + || kind === 143 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isModuleName(node) { @@ -9767,61 +9898,61 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 70 /* Identifier */ - || kind === 172 /* ObjectBindingPattern */ - || kind === 173 /* ArrayBindingPattern */; + || kind === 173 /* ObjectBindingPattern */ + || kind === 174 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Signature elements function isTypeParameter(node) { - return node.kind === 143 /* TypeParameter */; + return node.kind === 144 /* TypeParameter */; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 144 /* Parameter */; + return node.kind === 145 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 145 /* Decorator */; + return node.kind === 146 /* Decorator */; } ts.isDecorator = isDecorator; // Type members function isMethodDeclaration(node) { - return node.kind === 149 /* MethodDeclaration */; + return node.kind === 150 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 150 /* Constructor */ - || kind === 147 /* PropertyDeclaration */ - || kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */ - || kind === 155 /* IndexSignature */ - || kind === 203 /* SemicolonClassElement */; + return kind === 151 /* Constructor */ + || kind === 148 /* PropertyDeclaration */ + || kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */ + || kind === 156 /* IndexSignature */ + || kind === 205 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 257 /* PropertyAssignment */ - || kind === 258 /* ShorthandPropertyAssignment */ - || kind === 259 /* SpreadAssignment */ - || kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */ - || kind === 244 /* MissingDeclaration */; + return kind === 260 /* PropertyAssignment */ + || kind === 261 /* ShorthandPropertyAssignment */ + || kind === 262 /* SpreadAssignment */ + || kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */ + || kind === 246 /* MissingDeclaration */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 156 /* FirstTypeNode */ && kind <= 171 /* LastTypeNode */) + return (kind >= 157 /* FirstTypeNode */ && kind <= 172 /* LastTypeNode */) || kind === 118 /* AnyKeyword */ || kind === 132 /* NumberKeyword */ || kind === 121 /* BooleanKeyword */ - || kind === 134 /* StringKeyword */ - || kind === 135 /* SymbolKeyword */ + || kind === 135 /* StringKeyword */ + || kind === 136 /* SymbolKeyword */ || kind === 104 /* VoidKeyword */ || kind === 129 /* NeverKeyword */ - || kind === 199 /* ExpressionWithTypeArguments */; + || kind === 200 /* ExpressionWithTypeArguments */; } /** * Node test that determines whether a node is a valid type node. @@ -9834,36 +9965,36 @@ var ts; ts.isTypeNode = isTypeNode; // Binding patterns function isArrayBindingPattern(node) { - return node.kind === 173 /* ArrayBindingPattern */; + return node.kind === 174 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isObjectBindingPattern(node) { - return node.kind === 172 /* ObjectBindingPattern */; + return node.kind === 173 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 173 /* ArrayBindingPattern */ - || kind === 172 /* ObjectBindingPattern */; + return kind === 174 /* ArrayBindingPattern */ + || kind === 173 /* ObjectBindingPattern */; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 175 /* ArrayLiteralExpression */ - || kind === 176 /* ObjectLiteralExpression */; + return kind === 176 /* ArrayLiteralExpression */ + || kind === 177 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; function isBindingElement(node) { - return node.kind === 174 /* BindingElement */; + return node.kind === 175 /* BindingElement */; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 174 /* BindingElement */ - || kind === 198 /* OmittedExpression */; + return kind === 175 /* BindingElement */ + || kind === 199 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -9871,9 +10002,9 @@ var ts; */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 223 /* VariableDeclaration */: - case 144 /* Parameter */: - case 174 /* BindingElement */: + case 225 /* VariableDeclaration */: + case 145 /* Parameter */: + case 175 /* BindingElement */: return true; } return false; @@ -9892,8 +10023,8 @@ var ts; */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 172 /* ObjectBindingPattern */: - case 176 /* ObjectLiteralExpression */: + case 173 /* ObjectBindingPattern */: + case 177 /* ObjectLiteralExpression */: return true; } return false; @@ -9904,8 +10035,8 @@ var ts; */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 173 /* ArrayBindingPattern */: - case 175 /* ArrayLiteralExpression */: + case 174 /* ArrayBindingPattern */: + case 176 /* ArrayLiteralExpression */: return true; } return false; @@ -9913,86 +10044,86 @@ var ts; ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; // Expression function isArrayLiteralExpression(node) { - return node.kind === 175 /* ArrayLiteralExpression */; + return node.kind === 176 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 176 /* ObjectLiteralExpression */; + return node.kind === 177 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 177 /* PropertyAccessExpression */; + return node.kind === 178 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 178 /* ElementAccessExpression */; + return node.kind === 179 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 192 /* BinaryExpression */; + return node.kind === 193 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 193 /* ConditionalExpression */; + return node.kind === 194 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 179 /* CallExpression */; + return node.kind === 180 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 194 /* TemplateExpression */ + return kind === 195 /* TemplateExpression */ || kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadExpression(node) { - return node.kind === 196 /* SpreadElement */; + return node.kind === 197 /* SpreadElement */; } ts.isSpreadExpression = isSpreadExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 199 /* ExpressionWithTypeArguments */; + return node.kind === 200 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 177 /* PropertyAccessExpression */ - || kind === 178 /* ElementAccessExpression */ - || kind === 180 /* NewExpression */ - || kind === 179 /* CallExpression */ - || kind === 246 /* JsxElement */ - || kind === 247 /* JsxSelfClosingElement */ - || kind === 181 /* TaggedTemplateExpression */ - || kind === 175 /* ArrayLiteralExpression */ - || kind === 183 /* ParenthesizedExpression */ - || kind === 176 /* ObjectLiteralExpression */ - || kind === 197 /* ClassExpression */ - || kind === 184 /* FunctionExpression */ + return kind === 178 /* PropertyAccessExpression */ + || kind === 179 /* ElementAccessExpression */ + || kind === 181 /* NewExpression */ + || kind === 180 /* CallExpression */ + || kind === 248 /* JsxElement */ + || kind === 249 /* JsxSelfClosingElement */ + || kind === 182 /* TaggedTemplateExpression */ + || kind === 176 /* ArrayLiteralExpression */ + || kind === 184 /* ParenthesizedExpression */ + || kind === 177 /* ObjectLiteralExpression */ + || kind === 198 /* ClassExpression */ + || kind === 185 /* FunctionExpression */ || kind === 70 /* Identifier */ || kind === 11 /* RegularExpressionLiteral */ || kind === 8 /* NumericLiteral */ || kind === 9 /* StringLiteral */ || kind === 12 /* NoSubstitutionTemplateLiteral */ - || kind === 194 /* TemplateExpression */ + || kind === 195 /* TemplateExpression */ || kind === 85 /* FalseKeyword */ || kind === 94 /* NullKeyword */ || kind === 98 /* ThisKeyword */ || kind === 100 /* TrueKeyword */ || kind === 96 /* SuperKeyword */ - || kind === 201 /* NonNullExpression */ - || kind === 297 /* RawExpression */; + || kind === 202 /* NonNullExpression */ + || kind === 203 /* MetaProperty */; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 190 /* PrefixUnaryExpression */ - || kind === 191 /* PostfixUnaryExpression */ - || kind === 186 /* DeleteExpression */ - || kind === 187 /* TypeOfExpression */ - || kind === 188 /* VoidExpression */ - || kind === 189 /* AwaitExpression */ - || kind === 182 /* TypeAssertionExpression */ + return kind === 191 /* PrefixUnaryExpression */ + || kind === 192 /* PostfixUnaryExpression */ + || kind === 187 /* DeleteExpression */ + || kind === 188 /* TypeOfExpression */ + || kind === 189 /* VoidExpression */ + || kind === 190 /* AwaitExpression */ + || kind === 183 /* TypeAssertionExpression */ || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -10000,14 +10131,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 193 /* ConditionalExpression */ - || kind === 195 /* YieldExpression */ - || kind === 185 /* ArrowFunction */ - || kind === 192 /* BinaryExpression */ - || kind === 196 /* SpreadElement */ - || kind === 200 /* AsExpression */ - || kind === 198 /* OmittedExpression */ - || kind === 297 /* RawExpression */ + return kind === 194 /* ConditionalExpression */ + || kind === 196 /* YieldExpression */ + || kind === 186 /* ArrowFunction */ + || kind === 193 /* BinaryExpression */ + || kind === 197 /* SpreadElement */ + || kind === 201 /* AsExpression */ + || kind === 199 /* OmittedExpression */ || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -10016,16 +10146,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 182 /* TypeAssertionExpression */ - || kind === 200 /* AsExpression */; + return kind === 183 /* TypeAssertionExpression */ + || kind === 201 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 294 /* PartiallyEmittedExpression */; + return node.kind === 298 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 293 /* NotEmittedStatement */; + return node.kind === 297 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10034,17 +10164,17 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 198 /* OmittedExpression */; + return node.kind === 199 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; // Misc function isTemplateSpan(node) { - return node.kind === 202 /* TemplateSpan */; + return node.kind === 204 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; // Element function isBlock(node) { - return node.kind === 204 /* Block */; + return node.kind === 206 /* Block */; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -10062,121 +10192,135 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 223 /* VariableDeclaration */; + return node.kind === 225 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 224 /* VariableDeclarationList */; + return node.kind === 226 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 232 /* CaseBlock */; + return node.kind === 234 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 231 /* ModuleBlock */ - || kind === 230 /* ModuleDeclaration */; + return kind === 233 /* ModuleBlock */ + || kind === 232 /* ModuleDeclaration */ + || kind === 70 /* Identifier */; } ts.isModuleBody = isModuleBody; + function isNamespaceBody(node) { + var kind = node.kind; + return kind === 233 /* ModuleBlock */ + || kind === 232 /* ModuleDeclaration */; + } + ts.isNamespaceBody = isNamespaceBody; + function isJSDocNamespaceBody(node) { + var kind = node.kind; + return kind === 70 /* Identifier */ + || kind === 232 /* ModuleDeclaration */; + } + ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isImportEqualsDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */; + return node.kind === 236 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 236 /* ImportClause */; + return node.kind === 238 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 238 /* NamedImports */ - || kind === 237 /* NamespaceImport */; + return kind === 240 /* NamedImports */ + || kind === 239 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 239 /* ImportSpecifier */; + return node.kind === 241 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 242 /* NamedExports */; + return node.kind === 244 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 243 /* ExportSpecifier */; + return node.kind === 245 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 230 /* ModuleDeclaration */ || node.kind === 229 /* EnumDeclaration */; + return node.kind === 232 /* ModuleDeclaration */ || node.kind === 231 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 185 /* ArrowFunction */ - || kind === 174 /* BindingElement */ - || kind === 226 /* ClassDeclaration */ - || kind === 197 /* ClassExpression */ - || kind === 150 /* Constructor */ - || kind === 229 /* EnumDeclaration */ - || kind === 260 /* EnumMember */ - || kind === 243 /* ExportSpecifier */ - || kind === 225 /* FunctionDeclaration */ - || kind === 184 /* FunctionExpression */ - || kind === 151 /* GetAccessor */ - || kind === 236 /* ImportClause */ - || kind === 234 /* ImportEqualsDeclaration */ - || kind === 239 /* ImportSpecifier */ - || kind === 227 /* InterfaceDeclaration */ - || kind === 149 /* MethodDeclaration */ - || kind === 148 /* MethodSignature */ - || kind === 230 /* ModuleDeclaration */ - || kind === 233 /* NamespaceExportDeclaration */ - || kind === 237 /* NamespaceImport */ - || kind === 144 /* Parameter */ - || kind === 257 /* PropertyAssignment */ - || kind === 147 /* PropertyDeclaration */ - || kind === 146 /* PropertySignature */ - || kind === 152 /* SetAccessor */ - || kind === 258 /* ShorthandPropertyAssignment */ - || kind === 228 /* TypeAliasDeclaration */ - || kind === 143 /* TypeParameter */ - || kind === 223 /* VariableDeclaration */ - || kind === 285 /* JSDocTypedefTag */; + return kind === 186 /* ArrowFunction */ + || kind === 175 /* BindingElement */ + || kind === 228 /* ClassDeclaration */ + || kind === 198 /* ClassExpression */ + || kind === 151 /* Constructor */ + || kind === 231 /* EnumDeclaration */ + || kind === 263 /* EnumMember */ + || kind === 245 /* ExportSpecifier */ + || kind === 227 /* FunctionDeclaration */ + || kind === 185 /* FunctionExpression */ + || kind === 152 /* GetAccessor */ + || kind === 238 /* ImportClause */ + || kind === 236 /* ImportEqualsDeclaration */ + || kind === 241 /* ImportSpecifier */ + || kind === 229 /* InterfaceDeclaration */ + || kind === 252 /* JsxAttribute */ + || kind === 150 /* MethodDeclaration */ + || kind === 149 /* MethodSignature */ + || kind === 232 /* ModuleDeclaration */ + || kind === 235 /* NamespaceExportDeclaration */ + || kind === 239 /* NamespaceImport */ + || kind === 145 /* Parameter */ + || kind === 260 /* PropertyAssignment */ + || kind === 148 /* PropertyDeclaration */ + || kind === 147 /* PropertySignature */ + || kind === 153 /* SetAccessor */ + || kind === 261 /* ShorthandPropertyAssignment */ + || kind === 230 /* TypeAliasDeclaration */ + || kind === 144 /* TypeParameter */ + || kind === 225 /* VariableDeclaration */ + || kind === 289 /* JSDocTypedefTag */; } function isDeclarationStatementKind(kind) { - return kind === 225 /* FunctionDeclaration */ - || kind === 244 /* MissingDeclaration */ - || kind === 226 /* ClassDeclaration */ - || kind === 227 /* InterfaceDeclaration */ - || kind === 228 /* TypeAliasDeclaration */ - || kind === 229 /* EnumDeclaration */ - || kind === 230 /* ModuleDeclaration */ - || kind === 235 /* ImportDeclaration */ - || kind === 234 /* ImportEqualsDeclaration */ - || kind === 241 /* ExportDeclaration */ - || kind === 240 /* ExportAssignment */ - || kind === 233 /* NamespaceExportDeclaration */; + return kind === 227 /* FunctionDeclaration */ + || kind === 246 /* MissingDeclaration */ + || kind === 228 /* ClassDeclaration */ + || kind === 229 /* InterfaceDeclaration */ + || kind === 230 /* TypeAliasDeclaration */ + || kind === 231 /* EnumDeclaration */ + || kind === 232 /* ModuleDeclaration */ + || kind === 237 /* ImportDeclaration */ + || kind === 236 /* ImportEqualsDeclaration */ + || kind === 243 /* ExportDeclaration */ + || kind === 242 /* ExportAssignment */ + || kind === 235 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 215 /* BreakStatement */ - || kind === 214 /* ContinueStatement */ - || kind === 222 /* DebuggerStatement */ - || kind === 209 /* DoStatement */ - || kind === 207 /* ExpressionStatement */ - || kind === 206 /* EmptyStatement */ - || kind === 212 /* ForInStatement */ - || kind === 213 /* ForOfStatement */ - || kind === 211 /* ForStatement */ - || kind === 208 /* IfStatement */ - || kind === 219 /* LabeledStatement */ - || kind === 216 /* ReturnStatement */ - || kind === 218 /* SwitchStatement */ - || kind === 220 /* ThrowStatement */ - || kind === 221 /* TryStatement */ - || kind === 205 /* VariableStatement */ - || kind === 210 /* WhileStatement */ - || kind === 217 /* WithStatement */ - || kind === 293 /* NotEmittedStatement */ - || kind === 296 /* EndOfDeclarationMarker */ - || kind === 295 /* MergeDeclarationMarker */; + return kind === 217 /* BreakStatement */ + || kind === 216 /* ContinueStatement */ + || kind === 224 /* DebuggerStatement */ + || kind === 211 /* DoStatement */ + || kind === 209 /* ExpressionStatement */ + || kind === 208 /* EmptyStatement */ + || kind === 214 /* ForInStatement */ + || kind === 215 /* ForOfStatement */ + || kind === 213 /* ForStatement */ + || kind === 210 /* IfStatement */ + || kind === 221 /* LabeledStatement */ + || kind === 218 /* ReturnStatement */ + || kind === 220 /* SwitchStatement */ + || kind === 222 /* ThrowStatement */ + || kind === 223 /* TryStatement */ + || kind === 207 /* VariableStatement */ + || kind === 212 /* WhileStatement */ + || kind === 219 /* WithStatement */ + || kind === 297 /* NotEmittedStatement */ + || kind === 300 /* EndOfDeclarationMarker */ + || kind === 299 /* MergeDeclarationMarker */; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10197,93 +10341,102 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 204 /* Block */; + || kind === 206 /* Block */; } ts.isStatement = isStatement; // Module references function isModuleReference(node) { var kind = node.kind; - return kind === 245 /* ExternalModuleReference */ - || kind === 141 /* QualifiedName */ + return kind === 247 /* ExternalModuleReference */ + || kind === 142 /* QualifiedName */ || kind === 70 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX function isJsxOpeningElement(node) { - return node.kind === 248 /* JsxOpeningElement */; + return node.kind === 250 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 249 /* JsxClosingElement */; + return node.kind === 251 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; return kind === 98 /* ThisKeyword */ || kind === 70 /* Identifier */ - || kind === 177 /* PropertyAccessExpression */; + || kind === 178 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 246 /* JsxElement */ - || kind === 252 /* JsxExpression */ - || kind === 247 /* JsxSelfClosingElement */ + return kind === 248 /* JsxElement */ + || kind === 255 /* JsxExpression */ + || kind === 249 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */; } ts.isJsxChild = isJsxChild; + function isJsxAttributes(node) { + var kind = node.kind; + return kind === 253 /* JsxAttributes */; + } + ts.isJsxAttributes = isJsxAttributes; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 250 /* JsxAttribute */ - || kind === 251 /* JsxSpreadAttribute */; + return kind === 252 /* JsxAttribute */ + || kind === 254 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 251 /* JsxSpreadAttribute */; + return node.kind === 254 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 250 /* JsxAttribute */; + return node.kind === 252 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; + function isJsxOpeningLikeElement(node) { + return node.kind === 250 /* JsxOpeningElement */ || node.kind === 249 /* JsxSelfClosingElement */; + } + ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 252 /* JsxExpression */; + || kind === 255 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 253 /* CaseClause */ - || kind === 254 /* DefaultClause */; + return kind === 256 /* CaseClause */ + || kind === 257 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 255 /* HeritageClause */; + return node.kind === 258 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 256 /* CatchClause */; + return node.kind === 259 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 257 /* PropertyAssignment */; + return node.kind === 260 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 258 /* ShorthandPropertyAssignment */; + return node.kind === 261 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; // Enum function isEnumMember(node) { - return node.kind === 260 /* EnumMember */; + return node.kind === 263 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 261 /* SourceFile */; + return node.kind === 264 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -10513,9 +10666,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 143 /* TypeParameter */) { + if (d && d.kind === 144 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 227 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 229 /* InterfaceDeclaration */) { return current; } } @@ -10523,11 +10676,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 150 /* Constructor */ && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 151 /* Constructor */ && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 174 /* BindingElement */ || ts.isBindingPattern(node))) { + while (node && (node.kind === 175 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10535,14 +10688,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 223 /* VariableDeclaration */) { + if (node.kind === 225 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 224 /* VariableDeclarationList */) { + if (node && node.kind === 226 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 205 /* VariableStatement */) { + if (node && node.kind === 207 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -10558,14 +10711,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 223 /* VariableDeclaration */) { + if (node.kind === 225 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 224 /* VariableDeclarationList */) { + if (node && node.kind === 226 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 205 /* VariableStatement */) { + if (node && node.kind === 207 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -10625,27 +10778,60 @@ var ts; } } ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage; + function getOriginalNode(node, nodeTest) { + if (node) { + while (node.original !== undefined) { + node = node.original; + } + } + return !nodeTest || nodeTest(node) ? node : undefined; + } + ts.getOriginalNode = getOriginalNode; + /** + * Gets a value indicating whether a node originated in the parse tree. + * + * @param node The node to test. + */ + function isParseTreeNode(node) { + return (node.flags & 8 /* Synthesized */) === 0; + } + ts.isParseTreeNode = isParseTreeNode; + function getParseTreeNode(node, nodeTest) { + if (isParseTreeNode(node)) { + return node; + } + node = getOriginalNode(node); + if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { + return node; + } + return undefined; + } + ts.getParseTreeNode = getParseTreeNode; + /** + * Remove extra underscore from escaped identifier text content. + * + * @param identifier The escaped identifier text. + * @returns The unescaped identifier text. + */ + 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; })(ts || (ts = {})); /// /// -/* @internal */ var ts; (function (ts) { - var NodeConstructor; - var SourceFileConstructor; - function createNode(kind, location, flags) { - var ConstructorForKind = kind === 261 /* SourceFile */ - ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) - : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); - var node = location - ? new ConstructorForKind(kind, location.pos, location.end) - : new ConstructorForKind(kind, /*pos*/ -1, /*end*/ -1); - node.flags = flags | 8 /* Synthesized */; + function createSynthesizedNode(kind) { + var node = ts.createNode(kind, -1, -1); + node.flags |= 8 /* Synthesized */; return node; } + /* @internal */ function updateNode(updated, original) { if (updated !== original) { setOriginalNode(updated, original); + setTextRange(updated, original); if (original.startsOnNewLine) { updated.startsOnNewLine = true; } @@ -10654,7 +10840,10 @@ var ts; return updated; } ts.updateNode = updateNode; - function createNodeArray(elements, location, hasTrailingComma) { + /** + * Make `elements` into a `NodeArray`. If `elements` is `undefined`, returns an empty `NodeArray`. + */ + function createNodeArray(elements, hasTrailingComma) { if (elements) { if (ts.isNodeArray(elements)) { return elements; @@ -10664,38 +10853,22 @@ var ts; elements = []; } var array = elements; - if (location) { - array.pos = location.pos; - array.end = location.end; - } - else { - array.pos = -1; - array.end = -1; - } - if (hasTrailingComma) { - array.hasTrailingComma = true; - } + array.pos = -1; + array.end = -1; + array.hasTrailingComma = hasTrailingComma; return array; } ts.createNodeArray = createNodeArray; - function createSynthesizedNode(kind, startsOnNewLine) { - var node = createNode(kind, /*location*/ undefined); - node.startsOnNewLine = startsOnNewLine; - return node; - } - ts.createSynthesizedNode = createSynthesizedNode; - function createSynthesizedNodeArray(elements) { - return createNodeArray(elements, /*location*/ undefined); - } - ts.createSynthesizedNodeArray = createSynthesizedNodeArray; /** * Creates a shallow, memberwise clone of a node with no source map location. */ + /* @internal */ function getSynthesizedClone(node) { // We don't use "clone" from core.ts here, as we need to preserve the prototype chain of // the original node. We also need to exclude specific properties and only include own- // properties (to skip members already defined on the shared prototype). - var clone = createNode(node.kind, /*location*/ undefined, node.flags); + var clone = createSynthesizedNode(node.kind); + clone.flags |= node.flags; setOriginalNode(clone, node); for (var key in node) { if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) { @@ -10706,54 +10879,49 @@ var ts; return clone; } ts.getSynthesizedClone = getSynthesizedClone; - /** - * Creates a shallow, memberwise clone of a node for mutation. - */ - function getMutableClone(node) { - var clone = getSynthesizedClone(node); - clone.pos = node.pos; - clone.end = node.end; - clone.parent = node.parent; - return clone; - } - ts.getMutableClone = getMutableClone; - function createLiteral(value, location) { + function createLiteral(value) { if (typeof value === "number") { - var node = createNode(8 /* NumericLiteral */, location, /*flags*/ undefined); - node.text = value.toString(); - return node; + return createNumericLiteral(value + ""); } - else if (typeof value === "boolean") { - return createNode(value ? 100 /* TrueKeyword */ : 85 /* FalseKeyword */, location, /*flags*/ undefined); + if (typeof value === "boolean") { + return value ? createTrue() : createFalse(); } - else if (typeof value === "string") { - var node = createNode(9 /* StringLiteral */, location, /*flags*/ undefined); - node.text = value; - return node; - } - else if (value) { - var node = createNode(9 /* StringLiteral */, location, /*flags*/ undefined); - node.textSourceNode = value; - node.text = value.text; - return node; + if (typeof value === "string") { + return createStringLiteral(value); } + return createLiteralFromNode(value); } ts.createLiteral = createLiteral; + function createNumericLiteral(value) { + var node = createSynthesizedNode(8 /* NumericLiteral */); + node.text = value; + return node; + } + ts.createNumericLiteral = createNumericLiteral; + function createStringLiteral(text) { + var node = createSynthesizedNode(9 /* StringLiteral */); + node.text = text; + return node; + } + function createLiteralFromNode(sourceNode) { + var node = createStringLiteral(sourceNode.text); + node.textSourceNode = sourceNode; + return node; + } // Identifiers - var nextAutoGenerateId = 0; - function createIdentifier(text, location) { - var node = createNode(70 /* Identifier */, location); + function createIdentifier(text) { + var node = createSynthesizedNode(70 /* Identifier */); node.text = ts.escapeIdentifier(text); - node.originalKeywordKind = ts.stringToToken(text); + node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateKind = 0 /* None */; node.autoGenerateId = 0; return node; } ts.createIdentifier = createIdentifier; - function createTempVariable(recordTempVariable, location) { - var name = createNode(70 /* Identifier */, location); - name.text = ""; - name.originalKeywordKind = 0 /* Unknown */; + var nextAutoGenerateId = 0; + /** Create a unique temporary variable. */ + function createTempVariable(recordTempVariable) { + var name = createIdentifier(""); name.autoGenerateKind = 1 /* Auto */; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; @@ -10763,98 +10931,129 @@ var ts; return name; } ts.createTempVariable = createTempVariable; - function createLoopVariable(location) { - var name = createNode(70 /* Identifier */, location); - name.text = ""; - name.originalKeywordKind = 0 /* Unknown */; + /** Create a unique temporary variable for use in a loop. */ + function createLoopVariable() { + var name = createIdentifier(""); name.autoGenerateKind = 2 /* Loop */; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createLoopVariable = createLoopVariable; - function createUniqueName(text, location) { - var name = createNode(70 /* Identifier */, location); - name.text = text; - name.originalKeywordKind = 0 /* Unknown */; + /** Create a unique name based on the supplied text. */ + function createUniqueName(text) { + var name = createIdentifier(text); name.autoGenerateKind = 3 /* Unique */; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createUniqueName = createUniqueName; - function getGeneratedNameForNode(node, location) { - var name = createNode(70 /* Identifier */, location); - name.original = node; - name.text = ""; - name.originalKeywordKind = 0 /* Unknown */; + /** Create a unique name generated for a node. */ + function getGeneratedNameForNode(node) { + var name = createIdentifier(""); name.autoGenerateKind = 4 /* Node */; name.autoGenerateId = nextAutoGenerateId; + name.original = node; nextAutoGenerateId++; return name; } ts.getGeneratedNameForNode = getGeneratedNameForNode; // Punctuation function createToken(token) { - return createNode(token); + return createSynthesizedNode(token); } ts.createToken = createToken; // Reserved words function createSuper() { - var node = createNode(96 /* SuperKeyword */); - return node; + return createSynthesizedNode(96 /* SuperKeyword */); } ts.createSuper = createSuper; - function createThis(location) { - var node = createNode(98 /* ThisKeyword */, location); - return node; + function createThis() { + return createSynthesizedNode(98 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - var node = createNode(94 /* NullKeyword */); - return node; + return createSynthesizedNode(94 /* NullKeyword */); } ts.createNull = createNull; + function createTrue() { + return createSynthesizedNode(100 /* TrueKeyword */); + } + ts.createTrue = createTrue; + function createFalse() { + return createSynthesizedNode(85 /* FalseKeyword */); + } + ts.createFalse = createFalse; // Names - function createComputedPropertyName(expression, location) { - var node = createNode(142 /* ComputedPropertyName */, location); + function createQualifiedName(left, right) { + var node = createSynthesizedNode(142 /* QualifiedName */); + node.left = left; + node.right = asName(right); + return node; + } + ts.createQualifiedName = createQualifiedName; + function updateQualifiedName(node, left, right) { + return node.left !== left + || node.right !== right + ? updateNode(createQualifiedName(left, right), node) + : node; + } + ts.updateQualifiedName = updateQualifiedName; + function createComputedPropertyName(expression) { + var node = createSynthesizedNode(143 /* ComputedPropertyName */); node.expression = expression; return node; } ts.createComputedPropertyName = createComputedPropertyName; function updateComputedPropertyName(node, expression) { - if (node.expression !== expression) { - return updateNode(createComputedPropertyName(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createComputedPropertyName(expression), node) + : node; } ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements - function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(144 /* Parameter */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { + var node = createSynthesizedNode(145 /* Parameter */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.questionToken = questionToken; node.type = type; - node.initializer = initializer ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createParameter = createParameter; function updateParameter(node, decorators, modifiers, dotDotDotToken, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer, /*location*/ node, /*flags*/ node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) + : node; } ts.updateParameter = updateParameter; + function createDecorator(expression) { + var node = createSynthesizedNode(146 /* Decorator */); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createDecorator = createDecorator; + function updateDecorator(node, expression) { + return node.expression !== expression + ? updateNode(createDecorator(expression), node) + : node; + } + ts.updateDecorator = updateDecorator; // Type members - function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(147 /* PropertyDeclaration */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createProperty(decorators, modifiers, name, questionToken, type, initializer) { + var node = createSynthesizedNode(148 /* PropertyDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.questionToken = questionToken; node.type = type; node.initializer = initializer; @@ -10862,19 +11061,22 @@ var ts; } ts.createProperty = createProperty; function updateProperty(node, decorators, modifiers, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer), node) + : node; } ts.updateProperty = updateProperty; - function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(149 /* MethodDeclaration */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(150 /* MethodDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -10882,16 +11084,21 @@ var ts; } ts.createMethod = createMethod; function updateMethod(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateMethod = updateMethod; - function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(150 /* Constructor */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createConstructor(decorators, modifiers, parameters, body) { + var node = createSynthesizedNode(151 /* Constructor */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = undefined; @@ -10900,17 +11107,19 @@ var ts; } ts.createConstructor = createConstructor; function updateConstructor(node, decorators, modifiers, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.parameters !== parameters || node.body !== body) { - return updateNode(createConstructor(decorators, modifiers, parameters, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.parameters !== parameters + || node.body !== body + ? updateNode(createConstructor(decorators, modifiers, parameters, body), node) + : node; } ts.updateConstructor = updateConstructor; - function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(151 /* GetAccessor */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createGetAccessor(decorators, modifiers, name, parameters, type, body) { + var node = createSynthesizedNode(152 /* GetAccessor */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = type; @@ -10919,17 +11128,21 @@ var ts; } ts.createGetAccessor = createGetAccessor; function updateGetAccessor(node, decorators, modifiers, name, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body), node) + : node; } ts.updateGetAccessor = updateGetAccessor; - function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(152 /* SetAccessor */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createSetAccessor(decorators, modifiers, name, parameters, body) { + var node = createSynthesizedNode(153 /* SetAccessor */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.body = body; @@ -10937,59 +11150,62 @@ var ts; } ts.createSetAccessor = createSetAccessor; function updateSetAccessor(node, decorators, modifiers, name, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.body !== body) { - return updateNode(createSetAccessor(decorators, modifiers, name, parameters, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.body !== body + ? updateNode(createSetAccessor(decorators, modifiers, name, parameters, body), node) + : node; } ts.updateSetAccessor = updateSetAccessor; // Binding Patterns - function createObjectBindingPattern(elements, location) { - var node = createNode(172 /* ObjectBindingPattern */, location); + function createObjectBindingPattern(elements) { + var node = createSynthesizedNode(173 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } ts.createObjectBindingPattern = createObjectBindingPattern; function updateObjectBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createObjectBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createObjectBindingPattern(elements), node) + : node; } ts.updateObjectBindingPattern = updateObjectBindingPattern; - function createArrayBindingPattern(elements, location) { - var node = createNode(173 /* ArrayBindingPattern */, location); + function createArrayBindingPattern(elements) { + var node = createSynthesizedNode(174 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } ts.createArrayBindingPattern = createArrayBindingPattern; function updateArrayBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayBindingPattern(elements), node) + : node; } ts.updateArrayBindingPattern = updateArrayBindingPattern; - function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(174 /* BindingElement */, location); - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createBindingElement(propertyName, dotDotDotToken, name, initializer) { + var node = createSynthesizedNode(175 /* BindingElement */); + node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.initializer = initializer; return node; } ts.createBindingElement = createBindingElement; function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) { - if (node.propertyName !== propertyName || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.initializer !== initializer) { - return updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer, node), node); - } - return node; + return node.propertyName !== propertyName + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.initializer !== initializer + ? updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer), node) + : node; } ts.updateBindingElement = updateBindingElement; // Expression - function createArrayLiteral(elements, location, multiLine) { - var node = createNode(175 /* ArrayLiteralExpression */, location); - node.elements = parenthesizeListElements(createNodeArray(elements)); + function createArrayLiteral(elements, multiLine) { + var node = createSynthesizedNode(176 /* ArrayLiteralExpression */); + node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; } @@ -10997,14 +11213,13 @@ var ts; } ts.createArrayLiteral = createArrayLiteral; function updateArrayLiteral(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayLiteral(elements, node, node.multiLine), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayLiteral(elements, node.multiLine), node) + : node; } ts.updateArrayLiteral = updateArrayLiteral; - function createObjectLiteral(properties, location, multiLine) { - var node = createNode(176 /* ObjectLiteralExpression */, location); + function createObjectLiteral(properties, multiLine) { + var node = createSynthesizedNode(177 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -11013,109 +11228,120 @@ var ts; } ts.createObjectLiteral = createObjectLiteral; function updateObjectLiteral(node, properties) { - if (node.properties !== properties) { - return updateNode(createObjectLiteral(properties, node, node.multiLine), node); - } - return node; + return node.properties !== properties + ? updateNode(createObjectLiteral(properties, node.multiLine), node) + : node; } ts.updateObjectLiteral = updateObjectLiteral; - function createPropertyAccess(expression, name, location, flags) { - var node = createNode(177 /* PropertyAccessExpression */, location, flags); - node.expression = parenthesizeForAccess(expression); - (node.emitNode || (node.emitNode = {})).flags |= 65536 /* NoIndentation */; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAccess(expression, name) { + var node = createSynthesizedNode(178 /* PropertyAccessExpression */); + node.expression = ts.parenthesizeForAccess(expression); + node.name = asName(name); + setEmitFlags(node, 65536 /* NoIndentation */); return node; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { - if (node.expression !== expression || node.name !== name) { - var propertyAccess = createPropertyAccess(expression, name, /*location*/ node, node.flags); - // Because we are updating existed propertyAccess we want to inherit its emitFlags instead of using default from createPropertyAccess - (propertyAccess.emitNode || (propertyAccess.emitNode = {})).flags = getEmitFlags(node); - return updateNode(propertyAccess, node); - } - return node; + // Because we are updating existed propertyAccess we want to inherit its emitFlags + // instead of using the default from createPropertyAccess + return node.expression !== expression + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccess(expression, name), getEmitFlags(node)), node) + : node; } ts.updatePropertyAccess = updatePropertyAccess; - function createElementAccess(expression, index, location) { - var node = createNode(178 /* ElementAccessExpression */, location); - node.expression = parenthesizeForAccess(expression); - node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; + function createElementAccess(expression, index) { + var node = createSynthesizedNode(179 /* ElementAccessExpression */); + node.expression = ts.parenthesizeForAccess(expression); + node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { - if (node.expression !== expression || node.argumentExpression !== argumentExpression) { - return updateNode(createElementAccess(expression, argumentExpression, node), node); - } - return node; + return node.expression !== expression + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccess(expression, argumentExpression), node) + : node; } ts.updateElementAccess = updateElementAccess; - function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(179 /* CallExpression */, location, flags); - node.expression = parenthesizeForAccess(expression); - if (typeArguments) { - node.typeArguments = createNodeArray(typeArguments); - } - node.arguments = parenthesizeListElements(createNodeArray(argumentsArray)); + function createCall(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(180 /* CallExpression */); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); return node; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { - if (expression !== node.expression || typeArguments !== node.typeArguments || argumentsArray !== node.arguments) { - return updateNode(createCall(expression, typeArguments, argumentsArray, /*location*/ node, node.flags), node); - } - return node; + return expression !== node.expression + || typeArguments !== node.typeArguments + || argumentsArray !== node.arguments + ? updateNode(createCall(expression, typeArguments, argumentsArray), node) + : node; } ts.updateCall = updateCall; - function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(180 /* NewExpression */, location, flags); - node.expression = parenthesizeForNew(expression); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; + function createNew(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(181 /* NewExpression */); + node.expression = ts.parenthesizeForNew(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; return node; } ts.createNew = createNew; function updateNew(node, expression, typeArguments, argumentsArray) { - if (node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray) { - return updateNode(createNew(expression, typeArguments, argumentsArray, /*location*/ node, node.flags), node); - } - return node; + return node.expression !== expression + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createNew(expression, typeArguments, argumentsArray), node) + : node; } ts.updateNew = updateNew; - function createTaggedTemplate(tag, template, location) { - var node = createNode(181 /* TaggedTemplateExpression */, location); - node.tag = parenthesizeForAccess(tag); + function createTaggedTemplate(tag, template) { + var node = createSynthesizedNode(182 /* TaggedTemplateExpression */); + node.tag = ts.parenthesizeForAccess(tag); node.template = template; return node; } ts.createTaggedTemplate = createTaggedTemplate; function updateTaggedTemplate(node, tag, template) { - if (node.tag !== tag || node.template !== template) { - return updateNode(createTaggedTemplate(tag, template, node), node); - } - return node; + return node.tag !== tag + || node.template !== template + ? updateNode(createTaggedTemplate(tag, template), node) + : node; } ts.updateTaggedTemplate = updateTaggedTemplate; - function createParen(expression, location) { - var node = createNode(183 /* ParenthesizedExpression */, location); + function createTypeAssertion(type, expression) { + var node = createSynthesizedNode(183 /* TypeAssertionExpression */); + node.type = type; + node.expression = ts.parenthesizePrefixOperand(expression); + return node; + } + ts.createTypeAssertion = createTypeAssertion; + function updateTypeAssertion(node, type, expression) { + return node.type !== type + || node.expression !== expression + ? updateNode(createTypeAssertion(type, expression), node) + : node; + } + ts.updateTypeAssertion = updateTypeAssertion; + function createParen(expression) { + var node = createSynthesizedNode(184 /* ParenthesizedExpression */); node.expression = expression; return node; } ts.createParen = createParen; function updateParen(node, expression) { - if (node.expression !== expression) { - return updateNode(createParen(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createParen(expression), node) + : node; } ts.updateParen = updateParen; - function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(184 /* FunctionExpression */, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(185 /* FunctionExpression */); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -11123,326 +11349,342 @@ var ts; } ts.createFunctionExpression = createFunctionExpression; function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + return node.name !== name + || node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionExpression = updateFunctionExpression; - function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(185 /* ArrowFunction */, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { + var node = createSynthesizedNode(186 /* ArrowFunction */); + node.modifiers = asNodeArray(modifiers); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35 /* EqualsGreaterThanToken */); - node.body = parenthesizeConciseBody(body); + node.body = ts.parenthesizeConciseBody(body); return node; } ts.createArrowFunction = createArrowFunction; function updateArrowFunction(node, modifiers, typeParameters, parameters, type, body) { - if (node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body, /*location*/ node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body), node) + : node; } ts.updateArrowFunction = updateArrowFunction; - function createDelete(expression, location) { - var node = createNode(186 /* DeleteExpression */, location); - node.expression = parenthesizePrefixOperand(expression); + function createDelete(expression) { + var node = createSynthesizedNode(187 /* DeleteExpression */); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createDelete = createDelete; function updateDelete(node, expression) { - if (node.expression !== expression) { - return updateNode(createDelete(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createDelete(expression), node) + : node; } ts.updateDelete = updateDelete; - function createTypeOf(expression, location) { - var node = createNode(187 /* TypeOfExpression */, location); - node.expression = parenthesizePrefixOperand(expression); + function createTypeOf(expression) { + var node = createSynthesizedNode(188 /* TypeOfExpression */); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createTypeOf = createTypeOf; function updateTypeOf(node, expression) { - if (node.expression !== expression) { - return updateNode(createTypeOf(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createTypeOf(expression), node) + : node; } ts.updateTypeOf = updateTypeOf; - function createVoid(expression, location) { - var node = createNode(188 /* VoidExpression */, location); - node.expression = parenthesizePrefixOperand(expression); + function createVoid(expression) { + var node = createSynthesizedNode(189 /* VoidExpression */); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createVoid = createVoid; function updateVoid(node, expression) { - if (node.expression !== expression) { - return updateNode(createVoid(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createVoid(expression), node) + : node; } ts.updateVoid = updateVoid; - function createAwait(expression, location) { - var node = createNode(189 /* AwaitExpression */, location); - node.expression = parenthesizePrefixOperand(expression); + function createAwait(expression) { + var node = createSynthesizedNode(190 /* AwaitExpression */); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createAwait = createAwait; function updateAwait(node, expression) { - if (node.expression !== expression) { - return updateNode(createAwait(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createAwait(expression), node) + : node; } ts.updateAwait = updateAwait; - function createPrefix(operator, operand, location) { - var node = createNode(190 /* PrefixUnaryExpression */, location); + function createPrefix(operator, operand) { + var node = createSynthesizedNode(191 /* PrefixUnaryExpression */); node.operator = operator; - node.operand = parenthesizePrefixOperand(operand); + node.operand = ts.parenthesizePrefixOperand(operand); return node; } ts.createPrefix = createPrefix; function updatePrefix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPrefix(node.operator, operand, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPrefix(node.operator, operand), node) + : node; } ts.updatePrefix = updatePrefix; - function createPostfix(operand, operator, location) { - var node = createNode(191 /* PostfixUnaryExpression */, location); - node.operand = parenthesizePostfixOperand(operand); + function createPostfix(operand, operator) { + var node = createSynthesizedNode(192 /* PostfixUnaryExpression */); + node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; } ts.createPostfix = createPostfix; function updatePostfix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPostfix(operand, node.operator, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPostfix(operand, node.operator), node) + : node; } ts.updatePostfix = updatePostfix; - function createBinary(left, operator, right, location) { - var operatorToken = typeof operator === "number" ? createToken(operator) : operator; + function createBinary(left, operator, right) { + var node = createSynthesizedNode(193 /* BinaryExpression */); + var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; - var node = createNode(192 /* BinaryExpression */, location); - node.left = parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); + node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); node.operatorToken = operatorToken; - node.right = parenthesizeBinaryOperand(operatorKind, right, /*isLeftSideOfBinary*/ false, node.left); + node.right = ts.parenthesizeBinaryOperand(operatorKind, right, /*isLeftSideOfBinary*/ false, node.left); return node; } ts.createBinary = createBinary; function updateBinary(node, left, right) { - if (node.left !== left || node.right !== right) { - return updateNode(createBinary(left, node.operatorToken, right, /*location*/ node), node); - } - return node; + return node.left !== left + || node.right !== right + ? updateNode(createBinary(left, node.operatorToken, right), node) + : node; } ts.updateBinary = updateBinary; - function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonTokenOrLocation, whenFalse, location) { - var node = createNode(193 /* ConditionalExpression */, whenFalse ? location : colonTokenOrLocation); - node.condition = parenthesizeForConditionalHead(condition); - if (whenFalse) { - // second overload - node.questionToken = questionTokenOrWhenTrue; - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - node.colonToken = colonTokenOrLocation; - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenFalse); - } - else { - // first overload - node.questionToken = createToken(54 /* QuestionToken */); - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(questionTokenOrWhenTrue); - node.colonToken = createToken(55 /* ColonToken */); - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - } + function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { + var node = createSynthesizedNode(194 /* ConditionalExpression */); + node.condition = ts.parenthesizeForConditionalHead(condition); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(54 /* QuestionToken */); + node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); + node.colonToken = whenFalse ? colonToken : createToken(55 /* ColonToken */); + node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } ts.createConditional = createConditional; function updateConditional(node, condition, whenTrue, whenFalse) { - if (node.condition !== condition || node.whenTrue !== whenTrue || node.whenFalse !== whenFalse) { - return updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse, node), node); - } - return node; + return node.condition !== condition + || node.whenTrue !== whenTrue + || node.whenFalse !== whenFalse + ? updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse), node) + : node; } ts.updateConditional = updateConditional; - function createTemplateExpression(head, templateSpans, location) { - var node = createNode(194 /* TemplateExpression */, location); + function createTemplateExpression(head, templateSpans) { + var node = createSynthesizedNode(195 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; } ts.createTemplateExpression = createTemplateExpression; function updateTemplateExpression(node, head, templateSpans) { - if (node.head !== head || node.templateSpans !== templateSpans) { - return updateNode(createTemplateExpression(head, templateSpans, node), node); - } - return node; + return node.head !== head + || node.templateSpans !== templateSpans + ? updateNode(createTemplateExpression(head, templateSpans), node) + : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createYield(asteriskToken, expression, location) { - var node = createNode(195 /* YieldExpression */, location); - node.asteriskToken = asteriskToken; - node.expression = expression; + function createYield(asteriskTokenOrExpression, expression) { + var node = createSynthesizedNode(196 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 38 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 38 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; function updateYield(node, expression) { - if (node.expression !== expression) { - return updateNode(createYield(node.asteriskToken, expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createYield(node.asteriskToken, expression), node) + : node; } ts.updateYield = updateYield; - function createSpread(expression, location) { - var node = createNode(196 /* SpreadElement */, location); - node.expression = parenthesizeExpressionForList(expression); + function createSpread(expression) { + var node = createSynthesizedNode(197 /* SpreadElement */); + node.expression = ts.parenthesizeExpressionForList(expression); return node; } ts.createSpread = createSpread; function updateSpread(node, expression) { - if (node.expression !== expression) { - return updateNode(createSpread(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createSpread(expression), node) + : node; } ts.updateSpread = updateSpread; - function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(197 /* ClassExpression */, location); + function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(198 /* ClassExpression */); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassExpression = createClassExpression; function updateClassExpression(node, modifiers, name, typeParameters, heritageClauses, members) { - if (node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassExpression = updateClassExpression; - function createOmittedExpression(location) { - var node = createNode(198 /* OmittedExpression */, location); - return node; + function createOmittedExpression() { + return createSynthesizedNode(199 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; - function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(199 /* ExpressionWithTypeArguments */, location); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.expression = parenthesizeForAccess(expression); + function createExpressionWithTypeArguments(typeArguments, expression) { + var node = createSynthesizedNode(200 /* ExpressionWithTypeArguments */); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); return node; } ts.createExpressionWithTypeArguments = createExpressionWithTypeArguments; function updateExpressionWithTypeArguments(node, typeArguments, expression) { - if (node.typeArguments !== typeArguments || node.expression !== expression) { - return updateNode(createExpressionWithTypeArguments(typeArguments, expression, node), node); - } - return node; + return node.typeArguments !== typeArguments + || node.expression !== expression + ? updateNode(createExpressionWithTypeArguments(typeArguments, expression), node) + : node; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; + function createAsExpression(expression, type) { + var node = createSynthesizedNode(201 /* AsExpression */); + node.expression = expression; + node.type = type; + return node; + } + ts.createAsExpression = createAsExpression; + function updateAsExpression(node, expression, type) { + return node.expression !== expression + || node.type !== type + ? updateNode(createAsExpression(expression, type), node) + : node; + } + ts.updateAsExpression = updateAsExpression; + function createNonNullExpression(expression) { + var node = createSynthesizedNode(202 /* NonNullExpression */); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createNonNullExpression = createNonNullExpression; + function updateNonNullExpression(node, expression) { + return node.expression !== expression + ? updateNode(createNonNullExpression(expression), node) + : node; + } + ts.updateNonNullExpression = updateNonNullExpression; // Misc - function createTemplateSpan(expression, literal, location) { - var node = createNode(202 /* TemplateSpan */, location); + function createTemplateSpan(expression, literal) { + var node = createSynthesizedNode(204 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; } ts.createTemplateSpan = createTemplateSpan; function updateTemplateSpan(node, expression, literal) { - if (node.expression !== expression || node.literal !== literal) { - return updateNode(createTemplateSpan(expression, literal, node), node); - } - return node; + return node.expression !== expression + || node.literal !== literal + ? updateNode(createTemplateSpan(expression, literal), node) + : node; } ts.updateTemplateSpan = updateTemplateSpan; // Element - function createBlock(statements, location, multiLine, flags) { - var block = createNode(204 /* Block */, location, flags); + function createBlock(statements, multiLine) { + var block = createSynthesizedNode(206 /* Block */); block.statements = createNodeArray(statements); - if (multiLine) { - block.multiLine = true; - } + if (multiLine) + block.multiLine = multiLine; return block; } ts.createBlock = createBlock; function updateBlock(node, statements) { - if (statements !== node.statements) { - return updateNode(createBlock(statements, /*location*/ node, node.multiLine, node.flags), node); - } - return node; + return statements !== node.statements + ? updateNode(createBlock(statements, node.multiLine), node) + : node; } ts.updateBlock = updateBlock; - function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(205 /* VariableStatement */, location, flags); + function createVariableStatement(modifiers, declarationList) { + var node = createSynthesizedNode(207 /* VariableStatement */); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; return node; } ts.createVariableStatement = createVariableStatement; function updateVariableStatement(node, modifiers, declarationList) { - if (node.modifiers !== modifiers || node.declarationList !== declarationList) { - return updateNode(createVariableStatement(modifiers, declarationList, /*location*/ node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.declarationList !== declarationList + ? updateNode(createVariableStatement(modifiers, declarationList), node) + : node; } ts.updateVariableStatement = updateVariableStatement; - function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(224 /* VariableDeclarationList */, location, flags); + function createVariableDeclarationList(declarations, flags) { + var node = createSynthesizedNode(226 /* VariableDeclarationList */); + node.flags |= flags; node.declarations = createNodeArray(declarations); return node; } ts.createVariableDeclarationList = createVariableDeclarationList; function updateVariableDeclarationList(node, declarations) { - if (node.declarations !== declarations) { - return updateNode(createVariableDeclarationList(declarations, /*location*/ node, node.flags), node); - } - return node; + return node.declarations !== declarations + ? updateNode(createVariableDeclarationList(declarations, node.flags), node) + : node; } ts.updateVariableDeclarationList = updateVariableDeclarationList; - function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(223 /* VariableDeclaration */, location, flags); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createVariableDeclaration(name, type, initializer) { + var node = createSynthesizedNode(225 /* VariableDeclaration */); + node.name = asName(name); node.type = type; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createVariableDeclaration = createVariableDeclaration; function updateVariableDeclaration(node, name, type, initializer) { - if (node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createVariableDeclaration(name, type, initializer, /*location*/ node, node.flags), node); - } - return node; + return node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createVariableDeclaration(name, type, initializer), node) + : node; } ts.updateVariableDeclaration = updateVariableDeclaration; - function createEmptyStatement(location) { - return createNode(206 /* EmptyStatement */, location); + function createEmptyStatement() { + return createSynthesizedNode(208 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression, location, flags) { - var node = createNode(207 /* ExpressionStatement */, location, flags); - node.expression = parenthesizeExpressionForExpressionStatement(expression); + function createStatement(expression) { + var node = createSynthesizedNode(209 /* ExpressionStatement */); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } ts.createStatement = createStatement; function updateStatement(node, expression) { - if (node.expression !== expression) { - return updateNode(createStatement(expression, /*location*/ node, node.flags), node); - } - return node; + return node.expression !== expression + ? updateNode(createStatement(expression), node) + : node; } ts.updateStatement = updateStatement; - function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(208 /* IfStatement */, location); + function createIf(expression, thenStatement, elseStatement) { + var node = createSynthesizedNode(210 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11450,42 +11692,43 @@ var ts; } ts.createIf = createIf; function updateIf(node, expression, thenStatement, elseStatement) { - if (node.expression !== expression || node.thenStatement !== thenStatement || node.elseStatement !== elseStatement) { - return updateNode(createIf(expression, thenStatement, elseStatement, /*location*/ node), node); - } - return node; + return node.expression !== expression + || node.thenStatement !== thenStatement + || node.elseStatement !== elseStatement + ? updateNode(createIf(expression, thenStatement, elseStatement), node) + : node; } ts.updateIf = updateIf; - function createDo(statement, expression, location) { - var node = createNode(209 /* DoStatement */, location); + function createDo(statement, expression) { + var node = createSynthesizedNode(211 /* DoStatement */); node.statement = statement; node.expression = expression; return node; } ts.createDo = createDo; function updateDo(node, statement, expression) { - if (node.statement !== statement || node.expression !== expression) { - return updateNode(createDo(statement, expression, node), node); - } - return node; + return node.statement !== statement + || node.expression !== expression + ? updateNode(createDo(statement, expression), node) + : node; } ts.updateDo = updateDo; - function createWhile(expression, statement, location) { - var node = createNode(210 /* WhileStatement */, location); + function createWhile(expression, statement) { + var node = createSynthesizedNode(212 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; } ts.createWhile = createWhile; function updateWhile(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWhile(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWhile(expression, statement), node) + : node; } ts.updateWhile = updateWhile; - function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(211 /* ForStatement */, location, /*flags*/ undefined); + function createFor(initializer, condition, incrementor, statement) { + var node = createSynthesizedNode(213 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11494,14 +11737,16 @@ var ts; } ts.createFor = createFor; function updateFor(node, initializer, condition, incrementor, statement) { - if (node.initializer !== initializer || node.condition !== condition || node.incrementor !== incrementor || node.statement !== statement) { - return updateNode(createFor(initializer, condition, incrementor, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.condition !== condition + || node.incrementor !== incrementor + || node.statement !== statement + ? updateNode(createFor(initializer, condition, incrementor, statement), node) + : node; } ts.updateFor = updateFor; - function createForIn(initializer, expression, statement, location) { - var node = createNode(212 /* ForInStatement */, location); + function createForIn(initializer, expression, statement) { + var node = createSynthesizedNode(214 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11509,14 +11754,15 @@ var ts; } ts.createForIn = createForIn; function updateForIn(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForIn(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForIn(initializer, expression, statement), node) + : node; } ts.updateForIn = updateForIn; - function createForOf(initializer, expression, statement, location) { - var node = createNode(213 /* ForOfStatement */, location); + function createForOf(initializer, expression, statement) { + var node = createSynthesizedNode(215 /* ForOfStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11524,112 +11770,105 @@ var ts; } ts.createForOf = createForOf; function updateForOf(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForOf(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForOf(initializer, expression, statement), node) + : node; } ts.updateForOf = updateForOf; - function createContinue(label, location) { - var node = createNode(214 /* ContinueStatement */, location); - if (label) { - node.label = label; - } + function createContinue(label) { + var node = createSynthesizedNode(216 /* ContinueStatement */); + node.label = asName(label); return node; } ts.createContinue = createContinue; function updateContinue(node, label) { - if (node.label !== label) { - return updateNode(createContinue(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createContinue(label), node) + : node; } ts.updateContinue = updateContinue; - function createBreak(label, location) { - var node = createNode(215 /* BreakStatement */, location); - if (label) { - node.label = label; - } + function createBreak(label) { + var node = createSynthesizedNode(217 /* BreakStatement */); + node.label = asName(label); return node; } ts.createBreak = createBreak; function updateBreak(node, label) { - if (node.label !== label) { - return updateNode(createBreak(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createBreak(label), node) + : node; } ts.updateBreak = updateBreak; - function createReturn(expression, location) { - var node = createNode(216 /* ReturnStatement */, location); + function createReturn(expression) { + var node = createSynthesizedNode(218 /* ReturnStatement */); node.expression = expression; return node; } ts.createReturn = createReturn; function updateReturn(node, expression) { - if (node.expression !== expression) { - return updateNode(createReturn(expression, /*location*/ node), node); - } - return node; + return node.expression !== expression + ? updateNode(createReturn(expression), node) + : node; } ts.updateReturn = updateReturn; - function createWith(expression, statement, location) { - var node = createNode(217 /* WithStatement */, location); + function createWith(expression, statement) { + var node = createSynthesizedNode(219 /* WithStatement */); node.expression = expression; node.statement = statement; return node; } ts.createWith = createWith; function updateWith(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWith(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWith(expression, statement), node) + : node; } ts.updateWith = updateWith; - function createSwitch(expression, caseBlock, location) { - var node = createNode(218 /* SwitchStatement */, location); - node.expression = parenthesizeExpressionForList(expression); + function createSwitch(expression, caseBlock) { + var node = createSynthesizedNode(220 /* SwitchStatement */); + node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; } ts.createSwitch = createSwitch; function updateSwitch(node, expression, caseBlock) { - if (node.expression !== expression || node.caseBlock !== caseBlock) { - return updateNode(createSwitch(expression, caseBlock, node), node); - } - return node; + return node.expression !== expression + || node.caseBlock !== caseBlock + ? updateNode(createSwitch(expression, caseBlock), node) + : node; } ts.updateSwitch = updateSwitch; - function createLabel(label, statement, location) { - var node = createNode(219 /* LabeledStatement */, location); - node.label = typeof label === "string" ? createIdentifier(label) : label; + function createLabel(label, statement) { + var node = createSynthesizedNode(221 /* LabeledStatement */); + node.label = asName(label); node.statement = statement; return node; } ts.createLabel = createLabel; function updateLabel(node, label, statement) { - if (node.label !== label || node.statement !== statement) { - return updateNode(createLabel(label, statement, node), node); - } - return node; + return node.label !== label + || node.statement !== statement + ? updateNode(createLabel(label, statement), node) + : node; } ts.updateLabel = updateLabel; - function createThrow(expression, location) { - var node = createNode(220 /* ThrowStatement */, location); + function createThrow(expression) { + var node = createSynthesizedNode(222 /* ThrowStatement */); node.expression = expression; return node; } ts.createThrow = createThrow; function updateThrow(node, expression) { - if (node.expression !== expression) { - return updateNode(createThrow(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createThrow(expression), node) + : node; } ts.updateThrow = updateThrow; - function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(221 /* TryStatement */, location); + function createTry(tryBlock, catchClause, finallyBlock) { + var node = createSynthesizedNode(223 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11637,32 +11876,20 @@ var ts; } ts.createTry = createTry; function updateTry(node, tryBlock, catchClause, finallyBlock) { - if (node.tryBlock !== tryBlock || node.catchClause !== catchClause || node.finallyBlock !== finallyBlock) { - return updateNode(createTry(tryBlock, catchClause, finallyBlock, node), node); - } - return node; + return node.tryBlock !== tryBlock + || node.catchClause !== catchClause + || node.finallyBlock !== finallyBlock + ? updateNode(createTry(tryBlock, catchClause, finallyBlock), node) + : node; } ts.updateTry = updateTry; - function createCaseBlock(clauses, location) { - var node = createNode(232 /* CaseBlock */, location); - node.clauses = createNodeArray(clauses); - return node; - } - ts.createCaseBlock = createCaseBlock; - function updateCaseBlock(node, clauses) { - if (node.clauses !== clauses) { - return updateNode(createCaseBlock(clauses, node), node); - } - return node; - } - ts.updateCaseBlock = updateCaseBlock; - function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(225 /* FunctionDeclaration */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(227 /* FunctionDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -11670,162 +11897,263 @@ var ts; } ts.createFunctionDeclaration = createFunctionDeclaration; function updateFunctionDeclaration(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionDeclaration = updateFunctionDeclaration; - function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(226 /* ClassDeclaration */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(228 /* ClassDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassDeclaration = createClassDeclaration; function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassDeclaration = updateClassDeclaration; - function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(235 /* ImportDeclaration */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createEnumDeclaration(decorators, modifiers, name, members) { + var node = createSynthesizedNode(231 /* EnumDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.members = createNodeArray(members); + return node; + } + ts.createEnumDeclaration = createEnumDeclaration; + function updateEnumDeclaration(node, decorators, modifiers, name, members) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.members !== members + ? updateNode(createEnumDeclaration(decorators, modifiers, name, members), node) + : node; + } + ts.updateEnumDeclaration = updateEnumDeclaration; + function createModuleDeclaration(decorators, modifiers, name, body, flags) { + var node = createSynthesizedNode(232 /* ModuleDeclaration */); + node.flags |= flags; + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = name; + node.body = body; + return node; + } + ts.createModuleDeclaration = createModuleDeclaration; + function updateModuleDeclaration(node, decorators, modifiers, name, body) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.body !== body + ? updateNode(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node) + : node; + } + ts.updateModuleDeclaration = updateModuleDeclaration; + function createModuleBlock(statements) { + var node = createSynthesizedNode(234 /* CaseBlock */); + node.statements = createNodeArray(statements); + return node; + } + ts.createModuleBlock = createModuleBlock; + function updateModuleBlock(node, statements) { + return node.statements !== statements + ? updateNode(createModuleBlock(statements), node) + : node; + } + ts.updateModuleBlock = updateModuleBlock; + function createCaseBlock(clauses) { + var node = createSynthesizedNode(234 /* CaseBlock */); + node.clauses = createNodeArray(clauses); + return node; + } + ts.createCaseBlock = createCaseBlock; + function updateCaseBlock(node, clauses) { + return node.clauses !== clauses + ? updateNode(createCaseBlock(clauses), node) + : node; + } + ts.updateCaseBlock = updateCaseBlock; + function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { + var node = createSynthesizedNode(236 /* ImportEqualsDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.moduleReference = moduleReference; + return node; + } + ts.createImportEqualsDeclaration = createImportEqualsDeclaration; + function updateImportEqualsDeclaration(node, decorators, modifiers, name, moduleReference) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.moduleReference !== moduleReference + ? updateNode(createImportEqualsDeclaration(decorators, modifiers, name, moduleReference), node) + : node; + } + ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; + function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { + var node = createSynthesizedNode(237 /* ImportDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createImportDeclaration = createImportDeclaration; function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node) + : node; } ts.updateImportDeclaration = updateImportDeclaration; - function createImportClause(name, namedBindings, location) { - var node = createNode(236 /* ImportClause */, location); + function createImportClause(name, namedBindings) { + var node = createSynthesizedNode(238 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; } ts.createImportClause = createImportClause; function updateImportClause(node, name, namedBindings) { - if (node.name !== name || node.namedBindings !== namedBindings) { - return updateNode(createImportClause(name, namedBindings, node), node); - } - return node; + return node.name !== name + || node.namedBindings !== namedBindings + ? updateNode(createImportClause(name, namedBindings), node) + : node; } ts.updateImportClause = updateImportClause; - function createNamespaceImport(name, location) { - var node = createNode(237 /* NamespaceImport */, location); + function createNamespaceImport(name) { + var node = createSynthesizedNode(239 /* NamespaceImport */); node.name = name; return node; } ts.createNamespaceImport = createNamespaceImport; function updateNamespaceImport(node, name) { - if (node.name !== name) { - return updateNode(createNamespaceImport(name, node), node); - } - return node; + return node.name !== name + ? updateNode(createNamespaceImport(name), node) + : node; } ts.updateNamespaceImport = updateNamespaceImport; - function createNamedImports(elements, location) { - var node = createNode(238 /* NamedImports */, location); + function createNamedImports(elements) { + var node = createSynthesizedNode(240 /* NamedImports */); node.elements = createNodeArray(elements); return node; } ts.createNamedImports = createNamedImports; function updateNamedImports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedImports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedImports(elements), node) + : node; } ts.updateNamedImports = updateNamedImports; - function createImportSpecifier(propertyName, name, location) { - var node = createNode(239 /* ImportSpecifier */, location); + function createImportSpecifier(propertyName, name) { + var node = createSynthesizedNode(241 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; } ts.createImportSpecifier = createImportSpecifier; function updateImportSpecifier(node, propertyName, name) { - if (node.propertyName !== propertyName || node.name !== name) { - return updateNode(createImportSpecifier(propertyName, name, node), node); - } - return node; + return node.propertyName !== propertyName + || node.name !== name + ? updateNode(createImportSpecifier(propertyName, name), node) + : node; } ts.updateImportSpecifier = updateImportSpecifier; - function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(240 /* ExportAssignment */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportAssignment(decorators, modifiers, isExportEquals, expression) { + var node = createSynthesizedNode(242 /* ExportAssignment */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; node.expression = expression; return node; } ts.createExportAssignment = createExportAssignment; function updateExportAssignment(node, decorators, modifiers, expression) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.expression !== expression) { - return updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.expression !== expression + ? updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node) + : node; } ts.updateExportAssignment = updateExportAssignment; - function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(241 /* ExportDeclaration */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { + var node = createSynthesizedNode(243 /* ExportDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createExportDeclaration = createExportDeclaration; function updateExportDeclaration(node, decorators, modifiers, exportClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.exportClause !== exportClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.exportClause !== exportClause + || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier), node) + : node; } ts.updateExportDeclaration = updateExportDeclaration; - function createNamedExports(elements, location) { - var node = createNode(242 /* NamedExports */, location); + function createNamedExports(elements) { + var node = createSynthesizedNode(244 /* NamedExports */); node.elements = createNodeArray(elements); return node; } ts.createNamedExports = createNamedExports; function updateNamedExports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedExports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedExports(elements), node) + : node; } ts.updateNamedExports = updateNamedExports; - function createExportSpecifier(name, propertyName, location) { - var node = createNode(243 /* ExportSpecifier */, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createExportSpecifier(name, propertyName) { + var node = createSynthesizedNode(245 /* ExportSpecifier */); + node.name = asName(name); + node.propertyName = asName(propertyName); return node; } ts.createExportSpecifier = createExportSpecifier; function updateExportSpecifier(node, name, propertyName) { - if (node.name !== name || node.propertyName !== propertyName) { - return updateNode(createExportSpecifier(name, propertyName, node), node); - } - return node; + return node.name !== name || node.propertyName !== propertyName + ? updateNode(createExportSpecifier(name, propertyName), node) + : node; } ts.updateExportSpecifier = updateExportSpecifier; + // Module references + function createExternalModuleReference(expression) { + var node = createSynthesizedNode(247 /* ExternalModuleReference */); + node.expression = expression; + return node; + } + ts.createExternalModuleReference = createExternalModuleReference; + function updateExternalModuleReference(node, expression) { + return node.expression !== expression + ? updateNode(createExternalModuleReference(expression), node) + : node; + } + ts.updateExternalModuleReference = updateExternalModuleReference; // JSX - function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(246 /* JsxElement */, location); + function createJsxElement(openingElement, children, closingElement) { + var node = createSynthesizedNode(248 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11833,96 +12161,108 @@ var ts; } ts.createJsxElement = createJsxElement; function updateJsxElement(node, openingElement, children, closingElement) { - if (node.openingElement !== openingElement || node.children !== children || node.closingElement !== closingElement) { - return updateNode(createJsxElement(openingElement, children, closingElement, node), node); - } - return node; + return node.openingElement !== openingElement + || node.children !== children + || node.closingElement !== closingElement + ? updateNode(createJsxElement(openingElement, children, closingElement), node) + : node; } ts.updateJsxElement = updateJsxElement; - function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(247 /* JsxSelfClosingElement */, location); + function createJsxSelfClosingElement(tagName, attributes) { + var node = createSynthesizedNode(249 /* JsxSelfClosingElement */); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxSelfClosingElement = createJsxSelfClosingElement; function updateJsxSelfClosingElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxSelfClosingElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxSelfClosingElement(tagName, attributes), node) + : node; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; - function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(248 /* JsxOpeningElement */, location); + function createJsxOpeningElement(tagName, attributes) { + var node = createSynthesizedNode(250 /* JsxOpeningElement */); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxOpeningElement = createJsxOpeningElement; function updateJsxOpeningElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxOpeningElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxOpeningElement(tagName, attributes), node) + : node; } ts.updateJsxOpeningElement = updateJsxOpeningElement; - function createJsxClosingElement(tagName, location) { - var node = createNode(249 /* JsxClosingElement */, location); + function createJsxClosingElement(tagName) { + var node = createSynthesizedNode(251 /* JsxClosingElement */); node.tagName = tagName; return node; } ts.createJsxClosingElement = createJsxClosingElement; function updateJsxClosingElement(node, tagName) { - if (node.tagName !== tagName) { - return updateNode(createJsxClosingElement(tagName, node), node); - } - return node; + return node.tagName !== tagName + ? updateNode(createJsxClosingElement(tagName), node) + : node; } ts.updateJsxClosingElement = updateJsxClosingElement; - function createJsxAttribute(name, initializer, location) { - var node = createNode(250 /* JsxAttribute */, location); + function createJsxAttributes(properties) { + var jsxAttributes = createSynthesizedNode(253 /* JsxAttributes */); + jsxAttributes.properties = createNodeArray(properties); + return jsxAttributes; + } + ts.createJsxAttributes = createJsxAttributes; + function updateJsxAttributes(jsxAttributes, properties) { + if (jsxAttributes.properties !== properties) { + return updateNode(createJsxAttributes(properties), jsxAttributes); + } + return jsxAttributes; + } + ts.updateJsxAttributes = updateJsxAttributes; + function createJsxAttribute(name, initializer) { + var node = createSynthesizedNode(252 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; } ts.createJsxAttribute = createJsxAttribute; function updateJsxAttribute(node, name, initializer) { - if (node.name !== name || node.initializer !== initializer) { - return updateNode(createJsxAttribute(name, initializer, node), node); - } - return node; + return node.name !== name + || node.initializer !== initializer + ? updateNode(createJsxAttribute(name, initializer), node) + : node; } ts.updateJsxAttribute = updateJsxAttribute; - function createJsxSpreadAttribute(expression, location) { - var node = createNode(251 /* JsxSpreadAttribute */, location); + function createJsxSpreadAttribute(expression) { + var node = createSynthesizedNode(254 /* JsxSpreadAttribute */); node.expression = expression; return node; } ts.createJsxSpreadAttribute = createJsxSpreadAttribute; function updateJsxSpreadAttribute(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxSpreadAttribute(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxSpreadAttribute(expression), node) + : node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, location) { - var node = createNode(252 /* JsxExpression */, location); + function createJsxExpression(expression, dotDotDotToken) { + var node = createSynthesizedNode(255 /* JsxExpression */); + node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxExpression(expression, node.dotDotDotToken), node) + : node; } ts.updateJsxExpression = updateJsxExpression; // Clauses - function createHeritageClause(token, types, location) { - var node = createNode(255 /* HeritageClause */, location); + function createHeritageClause(token, types) { + var node = createSynthesizedNode(258 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -11930,40 +12270,40 @@ var ts; ts.createHeritageClause = createHeritageClause; function updateHeritageClause(node, types) { if (node.types !== types) { - return updateNode(createHeritageClause(node.token, types, node), node); + return updateNode(createHeritageClause(node.token, types), node); } return node; } ts.updateHeritageClause = updateHeritageClause; - function createCaseClause(expression, statements, location) { - var node = createNode(253 /* CaseClause */, location); - node.expression = parenthesizeExpressionForList(expression); + function createCaseClause(expression, statements) { + var node = createSynthesizedNode(256 /* CaseClause */); + node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; } ts.createCaseClause = createCaseClause; function updateCaseClause(node, expression, statements) { if (node.expression !== expression || node.statements !== statements) { - return updateNode(createCaseClause(expression, statements, node), node); + return updateNode(createCaseClause(expression, statements), node); } return node; } ts.updateCaseClause = updateCaseClause; - function createDefaultClause(statements, location) { - var node = createNode(254 /* DefaultClause */, location); + function createDefaultClause(statements) { + var node = createSynthesizedNode(257 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } ts.createDefaultClause = createDefaultClause; function updateDefaultClause(node, statements) { if (node.statements !== statements) { - return updateNode(createDefaultClause(statements, node), node); + return updateNode(createDefaultClause(statements), node); } return node; } ts.updateDefaultClause = updateDefaultClause; - function createCatchClause(variableDeclaration, block, location) { - var node = createNode(256 /* CatchClause */, location); + function createCatchClause(variableDeclaration, block) { + var node = createSynthesizedNode(259 /* CatchClause */); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11971,58 +12311,74 @@ var ts; ts.createCatchClause = createCatchClause; function updateCatchClause(node, variableDeclaration, block) { if (node.variableDeclaration !== variableDeclaration || node.block !== block) { - return updateNode(createCatchClause(variableDeclaration, block, node), node); + return updateNode(createCatchClause(variableDeclaration, block), node); } return node; } ts.updateCatchClause = updateCatchClause; // Property assignments - function createPropertyAssignment(name, initializer, location) { - var node = createNode(257 /* PropertyAssignment */, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAssignment(name, initializer) { + var node = createSynthesizedNode(260 /* PropertyAssignment */); + node.name = asName(name); node.questionToken = undefined; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createPropertyAssignment = createPropertyAssignment; function updatePropertyAssignment(node, name, initializer) { if (node.name !== name || node.initializer !== initializer) { - return updateNode(createPropertyAssignment(name, initializer, node), node); + return updateNode(createPropertyAssignment(name, initializer), node); } return node; } ts.updatePropertyAssignment = updatePropertyAssignment; - function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(258 /* ShorthandPropertyAssignment */, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; + function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { + var node = createSynthesizedNode(261 /* ShorthandPropertyAssignment */); + node.name = asName(name); + node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; - function createSpreadAssignment(expression, location) { - var node = createNode(259 /* SpreadAssignment */, location); - node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; + function createSpreadAssignment(expression) { + var node = createSynthesizedNode(262 /* SpreadAssignment */); + node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; return node; } ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { - return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node); + return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node); } return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function updateSpreadAssignment(node, expression) { if (node.expression !== expression) { - return updateNode(createSpreadAssignment(expression, node), node); + return updateNode(createSpreadAssignment(expression), node); } return node; } ts.updateSpreadAssignment = updateSpreadAssignment; + // Enum + function createEnumMember(name, initializer) { + var node = createSynthesizedNode(263 /* EnumMember */); + node.name = asName(name); + node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); + return node; + } + ts.createEnumMember = createEnumMember; + function updateEnumMember(node, name, initializer) { + return node.name !== name + || node.initializer !== initializer + ? updateNode(createEnumMember(name, initializer), node) + : node; + } + ts.updateEnumMember = updateEnumMember; // Top-level nodes function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(261 /* SourceFile */, /*location*/ node, node.flags); + var updated = createSynthesizedNode(264 /* SourceFile */); + updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -12081,6 +12437,17 @@ var ts; return node; } ts.updateSourceFileNode = updateSourceFileNode; + /** + * Creates a shallow, memberwise clone of a node for mutation. + */ + function getMutableClone(node) { + var clone = getSynthesizedClone(node); + clone.pos = node.pos; + clone.end = node.end; + clone.parent = node.parent; + return clone; + } + ts.getMutableClone = getMutableClone; // Transformation nodes /** * Creates a synthetic statement to act as a placeholder for a not-emitted statement in @@ -12089,8 +12456,9 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createNode(293 /* NotEmittedStatement */, /*location*/ original); + var node = createSynthesizedNode(297 /* NotEmittedStatement */); node.original = original; + setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; @@ -12098,8 +12466,9 @@ var ts; * Creates a synthetic element to act as a placeholder for the end of an emitted declaration in * order to properly emit exports. */ + /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createNode(296 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(300 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12109,8 +12478,9 @@ var ts; * Creates a synthetic element to act as a placeholder for the beginning of a merged declaration in * order to properly emit exports. */ + /* @internal */ function createMergeDeclarationMarker(original) { - var node = createNode(295 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(299 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12124,44 +12494,45 @@ var ts; * @param original The original outer expression. * @param location The location for the expression. Defaults to the positions from "original" if provided. */ - function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(294 /* PartiallyEmittedExpression */, /*location*/ location || original); + function createPartiallyEmittedExpression(expression, original) { + var node = createSynthesizedNode(298 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; + setTextRange(node, original); return node; } ts.createPartiallyEmittedExpression = createPartiallyEmittedExpression; function updatePartiallyEmittedExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createPartiallyEmittedExpression(expression, node.original, node), node); + return updateNode(createPartiallyEmittedExpression(expression, node.original), node); } return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; - /** - * Creates a node that emits a string of raw text in an expression position. Raw text is never - * transformed, should be ES3 compliant, and should have the same precedence as - * PrimaryExpression. - * - * @param text The raw text of the node. - */ - function createRawExpression(text) { - var node = createNode(297 /* RawExpression */); - node.text = text; + function createBundle(sourceFiles) { + var node = ts.createNode(265 /* Bundle */); + node.sourceFiles = sourceFiles; return node; } - ts.createRawExpression = createRawExpression; + ts.createBundle = createBundle; + function updateBundle(node, sourceFiles) { + if (node.sourceFiles !== sourceFiles) { + return createBundle(sourceFiles); + } + return node; + } + ts.updateBundle = updateBundle; // Compound nodes function createComma(left, right) { return createBinary(left, 25 /* CommaToken */, right); } ts.createComma = createComma; - function createLessThan(left, right, location) { - return createBinary(left, 26 /* LessThanToken */, right, location); + function createLessThan(left, right) { + return createBinary(left, 26 /* LessThanToken */, right); } ts.createLessThan = createLessThan; - function createAssignment(left, right, location) { - return createBinary(left, 57 /* EqualsToken */, right, location); + function createAssignment(left, right) { + return createBinary(left, 57 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { @@ -12180,8 +12551,8 @@ var ts; return createBinary(left, 37 /* MinusToken */, right); } ts.createSubtract = createSubtract; - function createPostfixIncrement(operand, location) { - return createPostfix(operand, 42 /* PlusPlusToken */, location); + function createPostfixIncrement(operand) { + return createPostfix(operand, 42 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { @@ -12200,61 +12571,346 @@ var ts; return createVoid(createLiteral(0)); } ts.createVoidZero = createVoidZero; + function createExportDefault(expression) { + return createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportEquals*/ false, expression); + } + ts.createExportDefault = createExportDefault; + function createExternalModuleExport(exportName) { + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(exportName)])); + } + ts.createExternalModuleExport = createExternalModuleExport; + function asName(name) { + return typeof name === "string" ? createIdentifier(name) : name; + } + function asExpression(value) { + return typeof value === "string" || typeof value === "number" ? createLiteral(value) : value; + } + function asNodeArray(array) { + return array ? createNodeArray(array) : undefined; + } + function asToken(value) { + return typeof value === "number" ? createToken(value) : value; + } + /** + * Clears any EmitNode entries from parse-tree nodes. + * @param sourceFile A source file. + */ + function disposeEmitNodes(sourceFile) { + // During transformation we may need to annotate a parse tree node with transient + // transformation properties. As parse tree nodes live longer than transformation + // nodes, we need to make sure we reclaim any memory allocated for custom ranges + // from these nodes to ensure we do not hold onto entire subtrees just for position + // information. We also need to reset these nodes to a pre-transformation state + // for incremental parsing scenarios so that we do not impact later emit. + sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); + var emitNode = sourceFile && sourceFile.emitNode; + var annotatedNodes = emitNode && emitNode.annotatedNodes; + if (annotatedNodes) { + for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) { + var node = annotatedNodes_1[_i]; + node.emitNode = undefined; + } + } + } + ts.disposeEmitNodes = disposeEmitNodes; + /** + * Associates a node with the current transformation, initializing + * various transient transformation properties. + */ + /* @internal */ + function getOrCreateEmitNode(node) { + if (!node.emitNode) { + if (ts.isParseTreeNode(node)) { + // To avoid holding onto transformation artifacts, we keep track of any + // parse tree node we are annotating. This allows us to clean them up after + // all transformations have completed. + if (node.kind === 264 /* SourceFile */) { + return node.emitNode = { annotatedNodes: [node] }; + } + var sourceFile = ts.getSourceFileOfNode(node); + getOrCreateEmitNode(sourceFile).annotatedNodes.push(node); + } + node.emitNode = {}; + } + return node.emitNode; + } + ts.getOrCreateEmitNode = getOrCreateEmitNode; + function setTextRange(range, location) { + if (location) { + range.pos = location.pos; + range.end = location.end; + } + return range; + } + ts.setTextRange = setTextRange; + /** + * Gets flags that control emit behavior of a node. + */ + function getEmitFlags(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.flags; + } + ts.getEmitFlags = getEmitFlags; + /** + * Sets flags that control emit behavior of a node. + */ + function setEmitFlags(node, emitFlags) { + getOrCreateEmitNode(node).flags = emitFlags; + return node; + } + ts.setEmitFlags = setEmitFlags; + /** + * Gets a custom text range to use when emitting source maps. + */ + function getSourceMapRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.sourceMapRange) || node; + } + ts.getSourceMapRange = getSourceMapRange; + /** + * Sets a custom text range to use when emitting source maps. + */ + function setSourceMapRange(node, range) { + getOrCreateEmitNode(node).sourceMapRange = range; + return node; + } + ts.setSourceMapRange = setSourceMapRange; + /** + * Gets the TextRange to use for source maps for a token of a node. + */ + function getTokenSourceMapRange(node, token) { + var emitNode = node.emitNode; + var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; + return tokenSourceMapRanges && tokenSourceMapRanges[token]; + } + ts.getTokenSourceMapRange = getTokenSourceMapRange; + /** + * Sets the TextRange to use for source maps for a token of a node. + */ + function setTokenSourceMapRange(node, token, range) { + var emitNode = getOrCreateEmitNode(node); + var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = []); + tokenSourceMapRanges[token] = range; + return node; + } + ts.setTokenSourceMapRange = setTokenSourceMapRange; + /** + * Gets a custom text range to use when emitting comments. + */ + function getCommentRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.commentRange) || node; + } + ts.getCommentRange = getCommentRange; + /** + * Sets a custom text range to use when emitting comments. + */ + function setCommentRange(node, range) { + getOrCreateEmitNode(node).commentRange = range; + return node; + } + ts.setCommentRange = setCommentRange; + /** + * Gets the constant value to emit for an expression. + */ + function getConstantValue(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.constantValue; + } + ts.getConstantValue = getConstantValue; + /** + * Sets the constant value to emit for an expression. + */ + function setConstantValue(node, value) { + var emitNode = getOrCreateEmitNode(node); + emitNode.constantValue = value; + return node; + } + ts.setConstantValue = setConstantValue; + /** + * Adds an EmitHelper to a node. + */ + function addEmitHelper(node, helper) { + var emitNode = getOrCreateEmitNode(node); + emitNode.helpers = ts.append(emitNode.helpers, helper); + return node; + } + ts.addEmitHelper = addEmitHelper; + /** + * Add EmitHelpers to a node. + */ + function addEmitHelpers(node, helpers) { + if (ts.some(helpers)) { + var emitNode = getOrCreateEmitNode(node); + for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { + var helper = helpers_1[_i]; + if (!ts.contains(emitNode.helpers, helper)) { + emitNode.helpers = ts.append(emitNode.helpers, helper); + } + } + } + return node; + } + ts.addEmitHelpers = addEmitHelpers; + /** + * Removes an EmitHelper from a node. + */ + function removeEmitHelper(node, helper) { + var emitNode = node.emitNode; + if (emitNode) { + var helpers = emitNode.helpers; + if (helpers) { + return ts.orderedRemoveItem(helpers, helper); + } + } + return false; + } + ts.removeEmitHelper = removeEmitHelper; + /** + * Gets the EmitHelpers of a node. + */ + function getEmitHelpers(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.helpers; + } + ts.getEmitHelpers = getEmitHelpers; + /** + * Moves matching emit helpers from a source node to a target node. + */ + function moveEmitHelpers(source, target, predicate) { + var sourceEmitNode = source.emitNode; + var sourceEmitHelpers = sourceEmitNode && sourceEmitNode.helpers; + if (!ts.some(sourceEmitHelpers)) + return; + var targetEmitNode = getOrCreateEmitNode(target); + var helpersRemoved = 0; + for (var i = 0; i < sourceEmitHelpers.length; i++) { + var helper = sourceEmitHelpers[i]; + if (predicate(helper)) { + helpersRemoved++; + if (!ts.contains(targetEmitNode.helpers, helper)) { + targetEmitNode.helpers = ts.append(targetEmitNode.helpers, helper); + } + } + else if (helpersRemoved > 0) { + sourceEmitHelpers[i - helpersRemoved] = helper; + } + } + if (helpersRemoved > 0) { + sourceEmitHelpers.length -= helpersRemoved; + } + } + ts.moveEmitHelpers = moveEmitHelpers; + /* @internal */ + function compareEmitHelpers(x, y) { + if (x === y) + return 0 /* EqualTo */; + if (x.priority === y.priority) + return 0 /* EqualTo */; + if (x.priority === undefined) + return 1 /* GreaterThan */; + if (y.priority === undefined) + return -1 /* LessThan */; + return ts.compareValues(x.priority, y.priority); + } + ts.compareEmitHelpers = compareEmitHelpers; + function setOriginalNode(node, original) { + node.original = original; + if (original) { + var emitNode = original.emitNode; + if (emitNode) + node.emitNode = mergeEmitNode(emitNode, node.emitNode); + } + return node; + } + ts.setOriginalNode = setOriginalNode; + function mergeEmitNode(sourceEmitNode, destEmitNode) { + var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; + if (!destEmitNode) + destEmitNode = {}; + if (flags) + destEmitNode.flags = flags; + if (commentRange) + destEmitNode.commentRange = commentRange; + if (sourceMapRange) + destEmitNode.sourceMapRange = sourceMapRange; + if (tokenSourceMapRanges) + destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); + if (constantValue !== undefined) + destEmitNode.constantValue = constantValue; + if (helpers) + destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); + return destEmitNode; + } + function mergeTokenSourceMapRanges(sourceRanges, destRanges) { + if (!destRanges) + destRanges = []; + for (var key in sourceRanges) { + destRanges[key] = sourceRanges[key]; + } + return destRanges; + } +})(ts || (ts = {})); +/* @internal */ +(function (ts) { + // Compound nodes function createTypeCheck(value, tag) { return tag === "undefined" - ? createStrictEquality(value, createVoidZero()) - : createStrictEquality(createTypeOf(value), createLiteral(tag)); + ? ts.createStrictEquality(value, ts.createVoidZero()) + : ts.createStrictEquality(ts.createTypeOf(value), ts.createLiteral(tag)); } ts.createTypeCheck = createTypeCheck; function createMemberAccessForPropertyName(target, memberName, location) { if (ts.isComputedPropertyName(memberName)) { - return createElementAccess(target, memberName.expression, location); + return ts.setTextRange(ts.createElementAccess(target, memberName.expression), location); } else { - var expression = ts.isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); - (expression.emitNode || (expression.emitNode = {})).flags |= 64 /* NoNestedSourceMaps */; + var expression = ts.setTextRange(ts.isIdentifier(memberName) + ? ts.createPropertyAccess(target, memberName) + : ts.createElementAccess(target, memberName), memberName); + ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; return expression; } } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createFunctionCall(func, thisArg, argumentsList, location) { - return createCall(createPropertyAccess(func, "call"), + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), /*typeArguments*/ undefined, [ thisArg - ].concat(argumentsList), location); + ].concat(argumentsList)), location); } ts.createFunctionCall = createFunctionCall; function createFunctionApply(func, thisArg, argumentsExpression, location) { - return createCall(createPropertyAccess(func, "apply"), + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "apply"), /*typeArguments*/ undefined, [ thisArg, argumentsExpression - ], location); + ]), location); } ts.createFunctionApply = createFunctionApply; function createArraySlice(array, start) { var argumentsList = []; if (start !== undefined) { - argumentsList.push(typeof start === "number" ? createLiteral(start) : start); + argumentsList.push(typeof start === "number" ? ts.createLiteral(start) : start); } - return createCall(createPropertyAccess(array, "slice"), /*typeArguments*/ undefined, argumentsList); + return ts.createCall(ts.createPropertyAccess(array, "slice"), /*typeArguments*/ undefined, argumentsList); } ts.createArraySlice = createArraySlice; function createArrayConcat(array, values) { - return createCall(createPropertyAccess(array, "concat"), + return ts.createCall(ts.createPropertyAccess(array, "concat"), /*typeArguments*/ undefined, values); } ts.createArrayConcat = createArrayConcat; function createMathPow(left, right, location) { - return createCall(createPropertyAccess(createIdentifier("Math"), "pow"), - /*typeArguments*/ undefined, [left, right], location); + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Math"), "pow"), + /*typeArguments*/ undefined, [left, right]), location); } ts.createMathPow = createMathPow; function createReactNamespace(reactNamespace, parent) { // To ensure the emit resolver can properly resolve the namespace, we need to // treat this identifier as if it were a source tree node by clearing the `Synthesized` // flag and setting a parent node. - var react = createIdentifier(reactNamespace || "React"); + var react = ts.createIdentifier(reactNamespace || "React"); react.flags &= ~8 /* Synthesized */; // Set the parent that is in parse tree // this makes sure that parent chain is intact for checker to traverse complete scope tree @@ -12264,9 +12920,9 @@ var ts; function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { if (ts.isQualifiedName(jsxFactory)) { var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent); - var right = createSynthesizedNode(70 /* Identifier */); + var right = ts.createIdentifier(jsxFactory.right.text); right.text = jsxFactory.right.text; - return createPropertyAccess(left, right); + return ts.createPropertyAccess(left, right); } else { return createReactNamespace(jsxFactory.text, parent); @@ -12275,7 +12931,7 @@ var ts; function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { return jsxFactoryEntity ? createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : - createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); + ts.createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); } function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { var argumentsList = [tagName]; @@ -12284,7 +12940,7 @@ var ts; } if (children && children.length > 0) { if (!props) { - argumentsList.push(createNull()); + argumentsList.push(ts.createNull()); } if (children.length > 1) { for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { @@ -12297,35 +12953,29 @@ var ts; argumentsList.push(children[0]); } } - return createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), - /*typeArguments*/ undefined, argumentsList, location); + return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), + /*typeArguments*/ undefined, argumentsList), location); } ts.createExpressionForJsxElement = createExpressionForJsxElement; - function createExportDefault(expression) { - return createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportEquals*/ false, expression); - } - ts.createExportDefault = createExportDefault; - function createExternalModuleExport(exportName) { - return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(exportName)])); - } - ts.createExternalModuleExport = createExternalModuleExport; - function createLetStatement(name, initializer, location) { - return createVariableStatement(/*modifiers*/ undefined, createLetDeclarationList([createVariableDeclaration(name, /*type*/ undefined, initializer)]), location); - } - ts.createLetStatement = createLetStatement; - function createLetDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 1 /* Let */); - } - ts.createLetDeclarationList = createLetDeclarationList; - function createConstDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 2 /* Const */); - } - ts.createConstDeclarationList = createConstDeclarationList; // Helpers function getHelperName(name) { - return setEmitFlags(createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); + return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } ts.getHelperName = getHelperName; + // Utilities + function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { + if (!outermostLabeledStatement) { + return node; + } + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 221 /* LabeledStatement */ + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + ts.restoreEnclosingLabel = restoreEnclosingLabel; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { @@ -12335,13 +12985,13 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -12352,22 +13002,23 @@ var ts; var thisArg; var target; if (ts.isSuperProperty(callee)) { - thisArg = createThis(); + thisArg = ts.createThis(); target = callee; } else if (callee.kind === 96 /* SuperKeyword */) { - thisArg = createThis(); - target = languageVersion < 2 /* ES2015 */ ? createIdentifier("_super", /*location*/ callee) : callee; + thisArg = ts.createThis(); + target = languageVersion < 2 /* ES2015 */ + ? ts.setTextRange(ts.createIdentifier("_super"), callee) + : callee; } else { switch (callee.kind) { - case 177 /* PropertyAccessExpression */: { + case 178 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` - thisArg = createTempVariable(recordTempVariable); - target = createPropertyAccess(createAssignment(thisArg, callee.expression, - /*location*/ callee.expression), callee.name, - /*location*/ callee); + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); + ts.setTextRange(target, callee); } else { thisArg = callee.expression; @@ -12375,13 +13026,12 @@ var ts; } break; } - case 178 /* ElementAccessExpression */: { + case 179 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` - thisArg = createTempVariable(recordTempVariable); - target = createElementAccess(createAssignment(thisArg, callee.expression, - /*location*/ callee.expression), callee.argumentExpression, - /*location*/ callee); + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); + ts.setTextRange(target, callee); } else { thisArg = callee.expression; @@ -12391,7 +13041,7 @@ var ts; } default: { // for `a()` target is `a` and thisArg is `void 0` - thisArg = createVoidZero(); + thisArg = ts.createVoidZero(); target = parenthesizeForAccess(expression); break; } @@ -12401,42 +13051,42 @@ var ts; } ts.createCallBinding = createCallBinding; function inlineExpressions(expressions) { - return ts.reduceLeft(expressions, createComma); + return ts.reduceLeft(expressions, ts.createComma); } ts.inlineExpressions = inlineExpressions; function createExpressionFromEntityName(node) { if (ts.isQualifiedName(node)) { var left = createExpressionFromEntityName(node.left); - var right = getMutableClone(node.right); - return createPropertyAccess(left, right, /*location*/ node); + var right = ts.getMutableClone(node.right); + return ts.setTextRange(ts.createPropertyAccess(left, right), node); } else { - return getMutableClone(node); + return ts.getMutableClone(node); } } ts.createExpressionFromEntityName = createExpressionFromEntityName; function createExpressionForPropertyName(memberName) { if (ts.isIdentifier(memberName)) { - return createLiteral(memberName, /*location*/ undefined); + return ts.createLiteral(memberName); } else if (ts.isComputedPropertyName(memberName)) { - return getMutableClone(memberName.expression); + return ts.getMutableClone(memberName.expression); } else { - return getMutableClone(memberName); + return ts.getMutableClone(memberName); } } ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 257 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 258 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -12446,57 +13096,55 @@ var ts; if (property === firstAccessor) { var properties_1 = []; if (getAccessor) { - var getterFunction = createFunctionExpression(getAccessor.modifiers, + var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, getAccessor.parameters, - /*type*/ undefined, getAccessor.body, - /*location*/ getAccessor); - setOriginalNode(getterFunction, getAccessor); - var getter = createPropertyAssignment("get", getterFunction); + /*type*/ undefined, getAccessor.body); + ts.setTextRange(getterFunction, getAccessor); + ts.setOriginalNode(getterFunction, getAccessor); + var getter = ts.createPropertyAssignment("get", getterFunction); properties_1.push(getter); } if (setAccessor) { - var setterFunction = createFunctionExpression(setAccessor.modifiers, + var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, setAccessor.parameters, - /*type*/ undefined, setAccessor.body, - /*location*/ setAccessor); - setOriginalNode(setterFunction, setAccessor); - var setter = createPropertyAssignment("set", setterFunction); + /*type*/ undefined, setAccessor.body); + ts.setTextRange(setterFunction, setAccessor); + ts.setOriginalNode(setterFunction, setAccessor); + var setter = ts.createPropertyAssignment("set", setterFunction); properties_1.push(setter); } - properties_1.push(createPropertyAssignment("enumerable", createLiteral(true))); - properties_1.push(createPropertyAssignment("configurable", createLiteral(true))); - var expression = createCall(createPropertyAccess(createIdentifier("Object"), "defineProperty"), + properties_1.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_1.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ receiver, createExpressionForPropertyName(property.name), - createObjectLiteral(properties_1, /*location*/ undefined, multiLine) - ], + ts.createObjectLiteral(properties_1, multiLine) + ]), /*location*/ firstAccessor); return ts.aggregateTransformFlags(expression); } return undefined; } function createExpressionForPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), property.initializer, - /*location*/ property), - /*original*/ property)); + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), property.initializer), property), property)); } function createExpressionForShorthandPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), getSynthesizedClone(property.name), + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), ts.getSynthesizedClone(property.name)), /*location*/ property), /*original*/ property)); } function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(method.modifiers, method.asteriskToken, /*name*/ undefined, /*typeParameters*/ undefined, method.parameters, - /*type*/ undefined, method.body, + /*type*/ undefined, method.body), /*location*/ method), - /*original*/ method), + /*original*/ method)), /*location*/ method), /*original*/ method)); } @@ -12518,7 +13166,7 @@ var ts; * Gets whether an identifier should only be referred to by its local name. */ function isLocalName(node) { - return (getEmitFlags(node) & 16384 /* LocalName */) !== 0; + return (ts.getEmitFlags(node) & 16384 /* LocalName */) !== 0; } ts.isLocalName = isLocalName; /** @@ -12540,7 +13188,7 @@ var ts; * name points to an exported symbol. */ function isExportName(node) { - return (getEmitFlags(node) & 8192 /* ExportName */) !== 0; + return (ts.getEmitFlags(node) & 8192 /* ExportName */) !== 0; } ts.isExportName = isExportName; /** @@ -12556,17 +13204,17 @@ var ts; ts.getDeclarationName = getDeclarationName; function getName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { - var name_8 = getMutableClone(node.name); - emitFlags |= getEmitFlags(node.name); + var name = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) emitFlags |= 48 /* NoSourceMap */; if (!allowComments) emitFlags |= 1536 /* NoComments */; if (emitFlags) - setEmitFlags(name_8, emitFlags); - return name_8; + ts.setEmitFlags(name, emitFlags); + return name; } - return getGeneratedNameForNode(node); + return ts.getGeneratedNameForNode(node); } /** * Gets the exported name of a declaration for use in expressions. @@ -12595,19 +13243,20 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { - var qualifiedName = createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : getSynthesizedClone(name), /*location*/ name); + var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name)); + ts.setTextRange(qualifiedName, name); var emitFlags; if (!allowSourceMaps) emitFlags |= 48 /* NoSourceMap */; if (!allowComments) emitFlags |= 1536 /* NoComments */; if (emitFlags) - setEmitFlags(qualifiedName, emitFlags); + ts.setEmitFlags(qualifiedName, emitFlags); return qualifiedName; } ts.getNamespaceMemberName = getNamespaceMemberName; function convertToFunctionBody(node, multiLine) { - return ts.isBlock(node) ? node : createBlock([createReturn(node, /*location*/ node)], /*location*/ node, multiLine); + return ts.isBlock(node) ? node : ts.setTextRange(ts.createBlock([ts.setTextRange(ts.createReturn(node), node)], multiLine), node); } ts.convertToFunctionBody = convertToFunctionBody; function isUseStrictPrologue(node) { @@ -12643,11 +13292,11 @@ var ts; statementOffset++; } if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); + target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))); } while (statementOffset < numStatements) { var statement = source[statementOffset]; - if (getEmitFlags(statement) & 524288 /* CustomPrologue */) { + if (ts.getEmitFlags(statement) & 524288 /* CustomPrologue */) { target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -12685,9 +13334,9 @@ var ts; } } if (!foundUseStrict) { - return createNodeArray([ - startOnNewLine(createStatement(createLiteral("use strict"))) - ].concat(statements), statements); + return ts.setTextRange(ts.createNodeArray([ + startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) + ].concat(statements)), statements); } return statements; } @@ -12704,11 +13353,11 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 183 /* ParenthesizedExpression */) { + if (skipped.kind === 184 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) - ? createParen(operand) + ? ts.createParen(operand) : operand; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; @@ -12738,8 +13387,8 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(192 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(192 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(193 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(193 /* BinaryExpression */, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -12748,7 +13397,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 195 /* YieldExpression */) { + && operand.kind === 196 /* YieldExpression */) { return false; } return true; @@ -12836,7 +13485,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 192 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { + if (node.kind === 193 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -12851,11 +13500,11 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(193 /* ConditionalExpression */, 54 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(194 /* ConditionalExpression */, 54 /* QuestionToken */); var emittedCondition = skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { - return createParen(condition); + return ts.createParen(condition); } return condition; } @@ -12864,10 +13513,11 @@ var ts; // per ES grammar both 'whenTrue' and 'whenFalse' parts of conditional expression are assignment expressions // so in case when comma expression is introduced as a part of previous transformations // if should be wrapped in parens since comma operator has the lowest precedence - return e.kind === 192 /* BinaryExpression */ && e.operatorToken.kind === 25 /* CommaToken */ - ? createParen(e) + return e.kind === 193 /* BinaryExpression */ && e.operatorToken.kind === 25 /* CommaToken */ + ? ts.createParen(e) : e; } + ts.parenthesizeSubexpressionOfConditionalExpression = parenthesizeSubexpressionOfConditionalExpression; /** * Wraps an expression in parentheses if it is needed in order to use the expression * as the expression of a NewExpression node. @@ -12877,12 +13527,12 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 179 /* CallExpression */: - return createParen(expression); - case 180 /* NewExpression */: + case 180 /* CallExpression */: + return ts.createParen(expression); + case 181 /* NewExpression */: return emittedExpression.arguments ? expression - : createParen(expression); + : ts.createParen(expression); } return parenthesizeForAccess(expression); } @@ -12904,23 +13554,23 @@ var ts; // var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 180 /* NewExpression */ || emittedExpression.arguments) + && (emittedExpression.kind !== 181 /* NewExpression */ || emittedExpression.arguments) && emittedExpression.kind !== 8 /* NumericLiteral */) { return expression; } - return createParen(expression, /*location*/ expression); + return ts.setTextRange(ts.createParen(expression), expression); } ts.parenthesizeForAccess = parenthesizeForAccess; function parenthesizePostfixOperand(operand) { return ts.isLeftHandSideExpression(operand) ? operand - : createParen(operand, /*location*/ operand); + : ts.setTextRange(ts.createParen(operand), operand); } ts.parenthesizePostfixOperand = parenthesizePostfixOperand; function parenthesizePrefixOperand(operand) { return ts.isUnaryExpression(operand) ? operand - : createParen(operand, /*location*/ operand); + : ts.setTextRange(ts.createParen(operand), operand); } ts.parenthesizePrefixOperand = parenthesizePrefixOperand; function parenthesizeListElements(elements) { @@ -12935,17 +13585,18 @@ var ts; } } if (result !== undefined) { - return createNodeArray(result, elements, elements.hasTrailingComma); + return ts.setTextRange(ts.createNodeArray(result, elements.hasTrailingComma), elements); } return elements; } + ts.parenthesizeListElements = parenthesizeListElements; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(192 /* BinaryExpression */, 25 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(193 /* BinaryExpression */, 25 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression - : createParen(expression, /*location*/ expression); + : ts.setTextRange(ts.createParen(expression), expression); } ts.parenthesizeExpressionForList = parenthesizeExpressionForList; function parenthesizeExpressionForExpressionStatement(expression) { @@ -12953,16 +13604,16 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 184 /* FunctionExpression */ || kind === 185 /* ArrowFunction */) { - var mutableCall = getMutableClone(emittedExpression); - mutableCall.expression = createParen(callee, /*location*/ callee); + if (kind === 185 /* FunctionExpression */ || kind === 186 /* ArrowFunction */) { + var mutableCall = ts.getMutableClone(emittedExpression); + mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); } } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 176 /* ObjectLiteralExpression */ || leftmostExpressionKind === 184 /* FunctionExpression */) { - return createParen(expression, /*location*/ expression); + if (leftmostExpressionKind === 177 /* ObjectLiteralExpression */ || leftmostExpressionKind === 185 /* FunctionExpression */) { + return ts.setTextRange(ts.createParen(expression), expression); } } return expression; @@ -12976,7 +13627,7 @@ var ts; */ function recreatePartiallyEmittedExpressions(originalOuterExpression, newInnerExpression) { if (ts.isPartiallyEmittedExpression(originalOuterExpression)) { - var clone_1 = getMutableClone(originalOuterExpression); + var clone_1 = ts.getMutableClone(originalOuterExpression); clone_1.expression = recreatePartiallyEmittedExpressions(clone_1.expression, newInnerExpression); return clone_1; } @@ -12985,21 +13636,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: node = node.operand; continue; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: node = node.left; continue; - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: node = node.condition; continue; - case 179 /* CallExpression */: - case 178 /* ElementAccessExpression */: - case 177 /* PropertyAccessExpression */: + case 180 /* CallExpression */: + case 179 /* ElementAccessExpression */: + case 178 /* PropertyAccessExpression */: node = node.expression; continue; - case 294 /* PartiallyEmittedExpression */: + case 298 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -13008,8 +13659,8 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 176 /* ObjectLiteralExpression */) { - return createParen(body, /*location*/ body); + if (emittedBody.kind === 177 /* ObjectLiteralExpression */) { + return ts.setTextRange(ts.createParen(body), body); } return body; } @@ -13040,7 +13691,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 183 /* ParenthesizedExpression */) { + while (node.kind === 184 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -13054,7 +13705,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 294 /* PartiallyEmittedExpression */) { + while (node.kind === 298 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -13065,188 +13716,6 @@ var ts; return node; } ts.startOnNewLine = startOnNewLine; - function setOriginalNode(node, original) { - node.original = original; - if (original) { - var emitNode = original.emitNode; - if (emitNode) - node.emitNode = mergeEmitNode(emitNode, node.emitNode); - } - return node; - } - ts.setOriginalNode = setOriginalNode; - function mergeEmitNode(sourceEmitNode, destEmitNode) { - var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; - if (!destEmitNode) - destEmitNode = {}; - if (flags) - destEmitNode.flags = flags; - if (commentRange) - destEmitNode.commentRange = commentRange; - if (sourceMapRange) - destEmitNode.sourceMapRange = sourceMapRange; - if (tokenSourceMapRanges) - destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); - if (constantValue !== undefined) - destEmitNode.constantValue = constantValue; - if (helpers) - destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); - return destEmitNode; - } - function mergeTokenSourceMapRanges(sourceRanges, destRanges) { - if (!destRanges) - destRanges = ts.createMap(); - ts.copyProperties(sourceRanges, destRanges); - return destRanges; - } - /** - * Clears any EmitNode entries from parse-tree nodes. - * @param sourceFile A source file. - */ - function disposeEmitNodes(sourceFile) { - // During transformation we may need to annotate a parse tree node with transient - // transformation properties. As parse tree nodes live longer than transformation - // nodes, we need to make sure we reclaim any memory allocated for custom ranges - // from these nodes to ensure we do not hold onto entire subtrees just for position - // information. We also need to reset these nodes to a pre-transformation state - // for incremental parsing scenarios so that we do not impact later emit. - sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); - var emitNode = sourceFile && sourceFile.emitNode; - var annotatedNodes = emitNode && emitNode.annotatedNodes; - if (annotatedNodes) { - for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) { - var node = annotatedNodes_1[_i]; - node.emitNode = undefined; - } - } - } - ts.disposeEmitNodes = disposeEmitNodes; - /** - * Associates a node with the current transformation, initializing - * various transient transformation properties. - * - * @param node The node. - */ - function getOrCreateEmitNode(node) { - if (!node.emitNode) { - if (ts.isParseTreeNode(node)) { - // To avoid holding onto transformation artifacts, we keep track of any - // parse tree node we are annotating. This allows us to clean them up after - // all transformations have completed. - if (node.kind === 261 /* SourceFile */) { - return node.emitNode = { annotatedNodes: [node] }; - } - var sourceFile = ts.getSourceFileOfNode(node); - getOrCreateEmitNode(sourceFile).annotatedNodes.push(node); - } - node.emitNode = {}; - } - return node.emitNode; - } - ts.getOrCreateEmitNode = getOrCreateEmitNode; - /** - * Gets flags that control emit behavior of a node. - * - * @param node The node. - */ - function getEmitFlags(node) { - var emitNode = node.emitNode; - return emitNode && emitNode.flags; - } - ts.getEmitFlags = getEmitFlags; - /** - * Sets flags that control emit behavior of a node. - * - * @param node The node. - * @param emitFlags The NodeEmitFlags for the node. - */ - function setEmitFlags(node, emitFlags) { - getOrCreateEmitNode(node).flags = emitFlags; - return node; - } - ts.setEmitFlags = setEmitFlags; - /** - * Gets a custom text range to use when emitting source maps. - * - * @param node The node. - */ - function getSourceMapRange(node) { - var emitNode = node.emitNode; - return (emitNode && emitNode.sourceMapRange) || node; - } - ts.getSourceMapRange = getSourceMapRange; - /** - * Sets a custom text range to use when emitting source maps. - * - * @param node The node. - * @param range The text range. - */ - function setSourceMapRange(node, range) { - getOrCreateEmitNode(node).sourceMapRange = range; - return node; - } - ts.setSourceMapRange = setSourceMapRange; - /** - * Gets the TextRange to use for source maps for a token of a node. - * - * @param node The node. - * @param token The token. - */ - function getTokenSourceMapRange(node, token) { - var emitNode = node.emitNode; - var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; - return tokenSourceMapRanges && tokenSourceMapRanges[token]; - } - ts.getTokenSourceMapRange = getTokenSourceMapRange; - /** - * Sets the TextRange to use for source maps for a token of a node. - * - * @param node The node. - * @param token The token. - * @param range The text range. - */ - function setTokenSourceMapRange(node, token, range) { - var emitNode = getOrCreateEmitNode(node); - var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = ts.createMap()); - tokenSourceMapRanges[token] = range; - return node; - } - ts.setTokenSourceMapRange = setTokenSourceMapRange; - /** - * Gets a custom text range to use when emitting comments. - * - * @param node The node. - */ - function getCommentRange(node) { - var emitNode = node.emitNode; - return (emitNode && emitNode.commentRange) || node; - } - ts.getCommentRange = getCommentRange; - /** - * Sets a custom text range to use when emitting comments. - */ - function setCommentRange(node, range) { - getOrCreateEmitNode(node).commentRange = range; - return node; - } - ts.setCommentRange = setCommentRange; - /** - * Gets the constant value to emit for an expression. - */ - function getConstantValue(node) { - var emitNode = node.emitNode; - return emitNode && emitNode.constantValue; - } - ts.getConstantValue = getConstantValue; - /** - * Sets the constant value to emit for an expression. - */ - function setConstantValue(node, value) { - var emitNode = getOrCreateEmitNode(node); - emitNode.constantValue = value; - return node; - } - ts.setConstantValue = setConstantValue; function getExternalHelpersModuleName(node) { var parseNode = ts.getOriginalNode(node, ts.isSourceFile); var emitNode = parseNode && parseNode.emitNode; @@ -13259,143 +13728,34 @@ var ts; if (externalHelpersModuleName) { return externalHelpersModuleName; } - var helpers = getEmitHelpers(node); + var helpers = ts.getEmitHelpers(node); if (helpers) { - for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { - var helper = helpers_1[_i]; + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; if (!helper.scoped) { var parseNode = ts.getOriginalNode(node, ts.isSourceFile); - var emitNode = getOrCreateEmitNode(parseNode); - return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = createUniqueName(ts.externalHelpersModuleNameText)); + var emitNode = ts.getOrCreateEmitNode(parseNode); + return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = ts.createUniqueName(ts.externalHelpersModuleNameText)); } } } } } ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded; - /** - * Adds an EmitHelper to a node. - */ - function addEmitHelper(node, helper) { - var emitNode = getOrCreateEmitNode(node); - emitNode.helpers = ts.append(emitNode.helpers, helper); - return node; - } - ts.addEmitHelper = addEmitHelper; - /** - * Adds an EmitHelper to a node. - */ - function addEmitHelpers(node, helpers) { - if (ts.some(helpers)) { - var emitNode = getOrCreateEmitNode(node); - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; - if (!ts.contains(emitNode.helpers, helper)) { - emitNode.helpers = ts.append(emitNode.helpers, helper); - } - } - } - return node; - } - ts.addEmitHelpers = addEmitHelpers; - /** - * Removes an EmitHelper from a node. - */ - function removeEmitHelper(node, helper) { - var emitNode = node.emitNode; - if (emitNode) { - var helpers = emitNode.helpers; - if (helpers) { - return ts.orderedRemoveItem(helpers, helper); - } - } - return false; - } - ts.removeEmitHelper = removeEmitHelper; - /** - * Gets the EmitHelpers of a node. - */ - function getEmitHelpers(node) { - var emitNode = node.emitNode; - return emitNode && emitNode.helpers; - } - ts.getEmitHelpers = getEmitHelpers; - /** - * Moves matching emit helpers from a source node to a target node. - */ - function moveEmitHelpers(source, target, predicate) { - var sourceEmitNode = source.emitNode; - var sourceEmitHelpers = sourceEmitNode && sourceEmitNode.helpers; - if (!ts.some(sourceEmitHelpers)) - return; - var targetEmitNode = getOrCreateEmitNode(target); - var helpersRemoved = 0; - for (var i = 0; i < sourceEmitHelpers.length; i++) { - var helper = sourceEmitHelpers[i]; - if (predicate(helper)) { - helpersRemoved++; - if (!ts.contains(targetEmitNode.helpers, helper)) { - targetEmitNode.helpers = ts.append(targetEmitNode.helpers, helper); - } - } - else if (helpersRemoved > 0) { - sourceEmitHelpers[i - helpersRemoved] = helper; - } - } - if (helpersRemoved > 0) { - sourceEmitHelpers.length -= helpersRemoved; - } - } - ts.moveEmitHelpers = moveEmitHelpers; - function compareEmitHelpers(x, y) { - if (x === y) - return 0 /* EqualTo */; - if (x.priority === y.priority) - return 0 /* EqualTo */; - if (x.priority === undefined) - return 1 /* GreaterThan */; - if (y.priority === undefined) - return -1 /* LessThan */; - return ts.compareValues(x.priority, y.priority); - } - ts.compareEmitHelpers = compareEmitHelpers; - function setTextRange(node, location) { - if (location) { - node.pos = location.pos; - node.end = location.end; - } - return node; - } - ts.setTextRange = setTextRange; - function setNodeFlags(node, flags) { - node.flags = flags; - return node; - } - ts.setNodeFlags = setNodeFlags; - function setMultiLine(node, multiLine) { - node.multiLine = multiLine; - return node; - } - ts.setMultiLine = setMultiLine; - function setHasTrailingComma(nodes, hasTrailingComma) { - nodes.hasTrailingComma = hasTrailingComma; - return nodes; - } - ts.setHasTrailingComma = setHasTrailingComma; /** * Get the name of that target module from an import or export declaration */ function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_9 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 235 /* ImportDeclaration */ && node.importClause) { - return getGeneratedNameForNode(node); + if (node.kind === 237 /* ImportDeclaration */ && node.importClause) { + return ts.getGeneratedNameForNode(node); } - if (node.kind === 241 /* ExportDeclaration */ && node.moduleSpecifier) { - return getGeneratedNameForNode(node); + if (node.kind === 243 /* ExportDeclaration */ && node.moduleSpecifier) { + return ts.getGeneratedNameForNode(node); } return undefined; } @@ -13413,7 +13773,7 @@ var ts; if (moduleName.kind === 9 /* StringLiteral */) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) - || getSynthesizedClone(moduleName); + || ts.getSynthesizedClone(moduleName); } return undefined; } @@ -13423,10 +13783,8 @@ var ts; * Here we check if alternative name was provided for a given moduleName and return it if possible. */ function tryRenameExternalModule(moduleName, sourceFile) { - if (sourceFile.renamedDependencies && ts.hasProperty(sourceFile.renamedDependencies, moduleName.text)) { - return createLiteral(sourceFile.renamedDependencies[moduleName.text]); - } - return undefined; + var rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text); + return rename && ts.createLiteral(rename); } /** * Get the name of a module as should be written in the emitted output. @@ -13440,10 +13798,10 @@ var ts; return undefined; } if (file.moduleName) { - return createLiteral(file.moduleName); + return ts.createLiteral(file.moduleName); } if (!ts.isDeclarationFile(file) && (options.out || options.outFile)) { - return createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); + return ts.createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); } return undefined; } @@ -13514,7 +13872,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 257 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -13526,11 +13884,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 258 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 259 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -13562,12 +13920,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 144 /* Parameter */: - case 174 /* BindingElement */: + case 145 /* Parameter */: + case 175 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 196 /* SpreadElement */: - case 259 /* SpreadAssignment */: + case 197 /* SpreadElement */: + case 262 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -13579,7 +13937,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 174 /* BindingElement */: + case 175 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -13591,7 +13949,7 @@ var ts; : propertyName; } break; - case 257 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -13603,7 +13961,7 @@ var ts; : propertyName; } break; - case 259 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -13621,13 +13979,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: - case 175 /* ArrayLiteralExpression */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: + case 176 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -13637,10 +13995,12 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpread(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpread(element.name), element), element); } var expression = convertToAssignmentElementTarget(element.name); - return element.initializer ? setOriginalNode(createAssignment(expression, element.initializer, element), element) : expression; + return element.initializer + ? ts.setOriginalNode(ts.setTextRange(ts.createAssignment(expression, element.initializer), element), element) + : expression; } ts.Debug.assertNode(element, ts.isExpression); return element; @@ -13650,14 +14010,14 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpreadAssignment(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpreadAssignment(element.name), element), element); } if (element.propertyName) { var expression = convertToAssignmentElementTarget(element.name); - return setOriginalNode(createPropertyAssignment(element.propertyName, element.initializer ? createAssignment(expression, element.initializer) : expression, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createPropertyAssignment(element.propertyName, element.initializer ? ts.createAssignment(expression, element.initializer) : expression), element), element); } ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createShorthandPropertyAssignment(element.name, element.initializer, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createShorthandPropertyAssignment(element.name, element.initializer), element), element); } ts.Debug.assertNode(element, ts.isObjectLiteralElementLike); return element; @@ -13665,18 +14025,18 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 173 /* ArrayBindingPattern */: - case 175 /* ArrayLiteralExpression */: + case 174 /* ArrayBindingPattern */: + case 176 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 172 /* ObjectBindingPattern */: - case 176 /* ObjectLiteralExpression */: + case 173 /* ObjectBindingPattern */: + case 177 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } ts.convertToAssignmentPattern = convertToAssignmentPattern; function convertToObjectAssignmentPattern(node) { if (ts.isObjectBindingPattern(node)) { - return setOriginalNode(createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isObjectLiteralExpression); return node; @@ -13684,7 +14044,7 @@ var ts; ts.convertToObjectAssignmentPattern = convertToObjectAssignmentPattern; function convertToArrayAssignmentPattern(node) { if (ts.isArrayBindingPattern(node)) { - return setOriginalNode(createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isArrayLiteralExpression); return node; @@ -13700,37 +14060,37 @@ var ts; ts.convertToAssignmentElementTarget = convertToAssignmentElementTarget; function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) { var externalImports = []; - var exportSpecifiers = ts.createMap(); - var exportedBindings = ts.createMap(); + var exportSpecifiers = ts.createMultiMap(); + var exportedBindings = []; var uniqueExports = ts.createMap(); var exportedNames; var hasExportDefault = false; var exportEquals = undefined; var hasExportStarsToExportValues = false; var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions); - var externalHelpersImportDeclaration = externalHelpersModuleName && createImportDeclaration( + var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, createImportClause(/*name*/ undefined, createNamespaceImport(externalHelpersModuleName)), createLiteral(ts.externalHelpersModuleNameText)); + /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); if (externalHelpersImportDeclaration) { externalImports.push(externalHelpersImportDeclaration); } for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); break; - case 234 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 245 /* ExternalModuleReference */) { + case 236 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 247 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -13746,27 +14106,27 @@ var ts; // export { x, y } for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - if (!uniqueExports[specifier.name.text]) { - var name_10 = specifier.propertyName || specifier.name; - ts.multiMapAdd(exportSpecifiers, name_10.text, specifier); - var decl = resolver.getReferencedImportDeclaration(name_10) - || resolver.getReferencedValueDeclaration(name_10); + if (!uniqueExports.get(specifier.name.text)) { + var name = specifier.propertyName || specifier.name; + exportSpecifiers.add(name.text, specifier); + var decl = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); if (decl) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); } - uniqueExports[specifier.name.text] = true; + uniqueExports.set(specifier.name.text, true); exportedNames = ts.append(exportedNames, specifier.name); } } } break; - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -13774,42 +14134,42 @@ var ts; } } break; - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { // export function x() { } - var name_11 = node.name; - if (!uniqueExports[name_11.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_11); - uniqueExports[name_11.text] = true; - exportedNames = ts.append(exportedNames, name_11); + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); } } } break; - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { // export class x { } - var name_12 = node.name; - if (!uniqueExports[name_12.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_12); - uniqueExports[name_12.text] = true; - exportedNames = ts.append(exportedNames, name_12); + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); } } } @@ -13829,13 +14189,24 @@ var ts; } } else if (!ts.isGeneratedIdentifier(decl.name)) { - if (!uniqueExports[decl.name.text]) { - uniqueExports[decl.name.text] = true; + if (!uniqueExports.get(decl.name.text)) { + uniqueExports.set(decl.name.text, true); exportedNames = ts.append(exportedNames, decl.name); } } return exportedNames; } + /** Use a sparse array as a multi-map. */ + function multiMapSparseArrayAdd(map, key, value) { + var values = map[key]; + if (values) { + values.push(value); + } + else { + map[key] = values = [value]; + } + return values; + } })(ts || (ts = {})); /// /// @@ -13847,13 +14218,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 261 /* SourceFile */) { + if (kind === 264 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 141 /* FirstNode */) { + else if (kind < 142 /* FirstNode */) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -13896,28 +14267,29 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || + visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 258 /* ShorthandPropertyAssignment */: + case 261 /* 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 259 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 144 /* Parameter */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 257 /* PropertyAssignment */: - case 223 /* VariableDeclaration */: - case 174 /* BindingElement */: + case 145 /* Parameter */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 260 /* PropertyAssignment */: + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -13926,24 +14298,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -13954,320 +14326,325 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 161 /* TypeLiteral */: + case 162 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 162 /* ArrayType */: + case 163 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 163 /* TupleType */: + case 164 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 164 /* UnionType */: - case 165 /* IntersectionType */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 166 /* ParenthesizedType */: - case 168 /* TypeOperator */: + case 167 /* ParenthesizedType */: + case 169 /* TypeOperator */: return visitNode(cbNode, node.type); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 170 /* MappedType */: + case 171 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 171 /* LiteralType */: + case 172 /* LiteralType */: return visitNode(cbNode, node.literal); - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 179 /* CallExpression */: - case 180 /* NewExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 182 /* TypeAssertionExpression */: + case 183 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 187 /* TypeOfExpression */: + case 188 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 200 /* AsExpression */: + case 201 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 201 /* NonNullExpression */: + case 202 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 193 /* ConditionalExpression */: + case 203 /* MetaProperty */: + return visitNode(cbNode, node.name); + case 194 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 204 /* Block */: - case 231 /* ModuleBlock */: + case 206 /* Block */: + case 233 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 261 /* SourceFile */: + case 264 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 224 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 208 /* IfStatement */: + case 210 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 209 /* DoStatement */: + case 211 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 210 /* WhileStatement */: + case 212 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 211 /* ForStatement */: + case 213 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 213 /* ForOfStatement */: + case 215 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 214 /* ContinueStatement */: - case 215 /* BreakStatement */: + case 216 /* ContinueStatement */: + case 217 /* BreakStatement */: return visitNode(cbNode, node.label); - case 216 /* ReturnStatement */: + case 218 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 217 /* WithStatement */: + case 219 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 232 /* CaseBlock */: + case 234 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 253 /* CaseClause */: + case 256 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 254 /* DefaultClause */: + case 257 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 220 /* ThrowStatement */: + case 222 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 221 /* TryStatement */: + case 223 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 145 /* Decorator */: + case 146 /* Decorator */: return visitNode(cbNode, node.expression); - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* 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 227 /* InterfaceDeclaration */: + case 229 /* 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 228 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 260 /* EnumMember */: + case 263 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 236 /* ImportClause */: + case 238 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 233 /* NamespaceExportDeclaration */: + case 235 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 237 /* NamespaceImport */: + case 239 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 240 /* NamedImports */: + case 244 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: + case 245 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 202 /* TemplateSpan */: + case 204 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 255 /* HeritageClause */: + case 258 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 245 /* ExternalModuleReference */: + case 247 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 244 /* MissingDeclaration */: + case 246 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 246 /* JsxElement */: + case 248 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 247 /* JsxSelfClosingElement */: - case 248 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + case 250 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || - visitNodes(cbNodes, node.attributes); - case 250 /* JsxAttribute */: + visitNode(cbNode, node.attributes); + case 253 /* JsxAttributes */: + return visitNodes(cbNodes, node.properties); + case 252 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 251 /* JsxSpreadAttribute */: + case 254 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 252 /* JsxExpression */: - return visitNode(cbNode, node.expression); - case 249 /* JsxClosingElement */: + case 255 /* JsxExpression */: + return visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.expression); + case 251 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 262 /* JSDocTypeExpression */: + case 266 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 266 /* JSDocUnionType */: + case 270 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 267 /* JSDocTupleType */: + case 271 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 265 /* JSDocArrayType */: + case 269 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 269 /* JSDocNonNullableType */: + case 273 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 268 /* JSDocNullableType */: + case 272 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 270 /* JSDocRecordType */: + case 274 /* JSDocRecordType */: return visitNode(cbNode, node.literal); - case 272 /* JSDocTypeReference */: + case 276 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 273 /* JSDocOptionalType */: + case 277 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 274 /* JSDocFunctionType */: + case 278 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 275 /* JSDocVariadicType */: + case 279 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 276 /* JSDocConstructorType */: + case 280 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 277 /* JSDocThisType */: + case 281 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 271 /* JSDocRecordMember */: + case 275 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 278 /* JSDocComment */: + case 282 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 281 /* JSDocParameterTag */: + case 285 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 282 /* JSDocReturnTag */: + case 286 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 283 /* JSDocTypeTag */: + case 287 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 280 /* JSDocAugmentsTag */: + case 284 /* JSDocAugmentsTag */: return visitNode(cbNode, node.typeExpression); - case 284 /* JSDocTemplateTag */: + case 288 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); - case 285 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 287 /* JSDocTypeLiteral */: + case 291 /* JSDocTypeLiteral */: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 286 /* JSDocPropertyTag */: + case 290 /* JSDocPropertyTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 294 /* PartiallyEmittedExpression */: + case 298 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); - case 288 /* JSDocLiteralType */: + case 292 /* JSDocLiteralType */: return visitNode(cbNode, node.literal); } } @@ -14539,7 +14916,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(261 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(264 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -14823,7 +15200,7 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 141 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : + return kind >= 142 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : kind === 70 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } @@ -14863,7 +15240,11 @@ var ts; } function internIdentifier(text) { text = ts.escapeIdentifier(text); - return identifiers[text] || (identifiers[text] = text); + var identifier = identifiers.get(text); + if (identifier === undefined) { + identifiers.set(text, identifier = text); + } + return identifier; } // 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 @@ -14915,7 +15296,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(142 /* ComputedPropertyName */); + var node = createNode(143 /* ComputedPropertyName */); parseExpected(20 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -15322,14 +15703,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 150 /* Constructor */: - case 155 /* IndexSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 147 /* PropertyDeclaration */: - case 203 /* SemicolonClassElement */: + case 151 /* Constructor */: + case 156 /* IndexSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 148 /* PropertyDeclaration */: + case 205 /* SemicolonClassElement */: return true; - case 149 /* MethodDeclaration */: + case 150 /* 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. @@ -15344,8 +15725,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 253 /* CaseClause */: - case 254 /* DefaultClause */: + case 256 /* CaseClause */: + case 257 /* DefaultClause */: return true; } } @@ -15354,58 +15735,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: - case 205 /* VariableStatement */: - case 204 /* Block */: - case 208 /* IfStatement */: - case 207 /* ExpressionStatement */: - case 220 /* ThrowStatement */: - case 216 /* ReturnStatement */: - case 218 /* SwitchStatement */: - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 211 /* ForStatement */: - case 210 /* WhileStatement */: - case 217 /* WithStatement */: - case 206 /* EmptyStatement */: - case 221 /* TryStatement */: - case 219 /* LabeledStatement */: - case 209 /* DoStatement */: - case 222 /* DebuggerStatement */: - case 235 /* ImportDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 241 /* ExportDeclaration */: - case 240 /* ExportAssignment */: - case 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 227 /* FunctionDeclaration */: + case 207 /* VariableStatement */: + case 206 /* Block */: + case 210 /* IfStatement */: + case 209 /* ExpressionStatement */: + case 222 /* ThrowStatement */: + case 218 /* ReturnStatement */: + case 220 /* SwitchStatement */: + case 217 /* BreakStatement */: + case 216 /* ContinueStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 213 /* ForStatement */: + case 212 /* WhileStatement */: + case 219 /* WithStatement */: + case 208 /* EmptyStatement */: + case 223 /* TryStatement */: + case 221 /* LabeledStatement */: + case 211 /* DoStatement */: + case 224 /* DebuggerStatement */: + case 237 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 243 /* ExportDeclaration */: + case 242 /* ExportAssignment */: + case 232 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 230 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 260 /* EnumMember */; + return node.kind === 263 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 154 /* ConstructSignature */: - case 148 /* MethodSignature */: - case 155 /* IndexSignature */: - case 146 /* PropertySignature */: - case 153 /* CallSignature */: + case 155 /* ConstructSignature */: + case 149 /* MethodSignature */: + case 156 /* IndexSignature */: + case 147 /* PropertySignature */: + case 154 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 223 /* VariableDeclaration */) { + if (node.kind !== 225 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -15426,7 +15807,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 144 /* Parameter */) { + if (node.kind !== 145 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -15539,7 +15920,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(22 /* DotToken */)) { - var node = createNode(141 /* QualifiedName */, entity.pos); // !!! + var node = createNode(142 /* QualifiedName */, entity.pos); // !!! node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -15578,7 +15959,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(194 /* TemplateExpression */); + var template = createNode(195 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -15590,7 +15971,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(202 /* TemplateSpan */); + var span = createNode(204 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17 /* CloseBraceToken */) { @@ -15645,7 +16026,7 @@ var ts; // TYPES function parseTypeReference() { var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - var node = createNode(157 /* TypeReference */, typeName.pos); + var node = createNode(158 /* TypeReference */, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token() === 26 /* LessThanToken */) { node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); @@ -15654,24 +16035,24 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(156 /* TypePredicate */, lhs.pos); + var node = createNode(157 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(167 /* ThisType */); + var node = createNode(168 /* ThisType */); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(160 /* TypeQuery */); + var node = createNode(161 /* TypeQuery */); parseExpected(102 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(143 /* TypeParameter */); + var node = createNode(144 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(84 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -15692,6 +16073,9 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } + if (parseOptional(57 /* EqualsToken */)) { + node.default = parseType(); + } return finishNode(node); } function parseTypeParameters() { @@ -15709,7 +16093,7 @@ var ts; return token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 /* AtToken */ || token() === 98 /* ThisKeyword */; } function parseParameter() { - var node = createNode(144 /* Parameter */); + var node = createNode(145 /* Parameter */); if (token() === 98 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true, undefined); node.type = parseParameterType(); @@ -15808,7 +16192,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 154 /* ConstructSignature */) { + if (kind === 155 /* ConstructSignature */) { parseExpected(93 /* NewKeyword */); } fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -15872,7 +16256,7 @@ var ts; return token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */ || token() === 21 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(155 /* IndexSignature */, fullStart); + var node = createNode(156 /* IndexSignature */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); @@ -15884,7 +16268,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(54 /* QuestionToken */); if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { - var method = createNode(148 /* MethodSignature */, fullStart); + var method = createNode(149 /* MethodSignature */, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; @@ -15895,7 +16279,7 @@ var ts; return addJSDocComment(finishNode(method)); } else { - var property = createNode(146 /* PropertySignature */, fullStart); + var property = createNode(147 /* PropertySignature */, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; @@ -15944,10 +16328,10 @@ var ts; } function parseTypeMember() { if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { - return parseSignatureMember(153 /* CallSignature */); + return parseSignatureMember(154 /* CallSignature */); } if (token() === 93 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(154 /* ConstructSignature */); + return parseSignatureMember(155 /* ConstructSignature */); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -15961,7 +16345,7 @@ var ts; return token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(161 /* TypeLiteral */); + var node = createNode(162 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -15984,14 +16368,14 @@ var ts; return token() === 20 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 91 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(143 /* TypeParameter */); + var node = createNode(144 /* TypeParameter */); node.name = parseIdentifier(); parseExpected(91 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(170 /* MappedType */); + var node = createNode(171 /* MappedType */); parseExpected(16 /* OpenBraceToken */); node.readonlyToken = parseOptionalToken(130 /* ReadonlyKeyword */); parseExpected(20 /* OpenBracketToken */); @@ -16004,12 +16388,12 @@ var ts; return finishNode(node); } function parseTupleType() { - var node = createNode(163 /* TupleType */); + var node = createNode(164 /* TupleType */); node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(166 /* ParenthesizedType */); + var node = createNode(167 /* ParenthesizedType */); parseExpected(18 /* OpenParenToken */); node.type = parseType(); parseExpected(19 /* CloseParenToken */); @@ -16017,7 +16401,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 159 /* ConstructorType */) { + if (kind === 160 /* ConstructorType */) { parseExpected(93 /* NewKeyword */); } fillSignature(35 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -16028,7 +16412,7 @@ var ts; return token() === 22 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(171 /* LiteralType */); + var node = createNode(172 /* LiteralType */); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -16039,12 +16423,13 @@ var ts; function parseNonArrayType() { switch (token()) { case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: - case 137 /* UndefinedKeyword */: + case 136 /* SymbolKeyword */: + case 138 /* UndefinedKeyword */: case 129 /* NeverKeyword */: + case 133 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); @@ -16082,12 +16467,12 @@ var ts; function isStartOfType() { switch (token()) { case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: case 94 /* NullKeyword */: case 98 /* ThisKeyword */: case 102 /* TypeOfKeyword */: @@ -16102,6 +16487,7 @@ var ts; case 8 /* NumericLiteral */: case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: + case 133 /* ObjectKeyword */: return true; case 37 /* MinusToken */: return lookAhead(nextTokenIsNumericLiteral); @@ -16121,14 +16507,14 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(20 /* OpenBracketToken */)) { if (isStartOfType()) { - var node = createNode(169 /* IndexedAccessType */, type.pos); + var node = createNode(170 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(21 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(162 /* ArrayType */, type.pos); + var node = createNode(163 /* ArrayType */, type.pos); node.elementType = type; parseExpected(21 /* CloseBracketToken */); type = finishNode(node); @@ -16137,7 +16523,7 @@ var ts; return type; } function parseTypeOperator(operator) { - var node = createNode(168 /* TypeOperator */); + var node = createNode(169 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); @@ -16166,10 +16552,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(165 /* IntersectionType */, parseTypeOperatorOrHigher, 47 /* AmpersandToken */); + return parseUnionOrIntersectionType(166 /* IntersectionType */, parseTypeOperatorOrHigher, 47 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(164 /* UnionType */, parseIntersectionTypeOrHigher, 48 /* BarToken */); + return parseUnionOrIntersectionType(165 /* UnionType */, parseIntersectionTypeOrHigher, 48 /* BarToken */); } function isStartOfFunctionType() { if (token() === 26 /* LessThanToken */) { @@ -16226,7 +16612,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(156 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(157 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -16249,10 +16635,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(158 /* FunctionType */); + return parseFunctionOrConstructorType(159 /* FunctionType */); } if (token() === 93 /* NewKeyword */) { - return parseFunctionOrConstructorType(159 /* ConstructorType */); + return parseFunctionOrConstructorType(160 /* ConstructorType */); } return parseUnionTypeOrHigher(); } @@ -16453,7 +16839,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(195 /* YieldExpression */); + var node = createNode(196 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -16475,13 +16861,13 @@ var ts; ts.Debug.assert(token() === 35 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(185 /* ArrowFunction */, asyncModifier.pos); + node = createNode(186 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(185 /* ArrowFunction */, identifier.pos); + node = createNode(186 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(144 /* Parameter */, identifier.pos); + var parameter = createNode(145 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); @@ -16663,7 +17049,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(185 /* ArrowFunction */); + var node = createNode(186 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); // Arrow functions are never generators. @@ -16729,7 +17115,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(193 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(194 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -16742,7 +17128,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 /* InKeyword */ || t === 140 /* OfKeyword */; + return t === 91 /* InKeyword */ || t === 141 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -16850,39 +17236,39 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(192 /* BinaryExpression */, left.pos); + var node = createNode(193 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(200 /* AsExpression */, left.pos); + var node = createNode(201 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(190 /* PrefixUnaryExpression */); + var node = createNode(191 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(186 /* DeleteExpression */); + var node = createNode(187 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(187 /* TypeOfExpression */); + var node = createNode(188 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(188 /* VoidExpression */); + var node = createNode(189 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -16898,7 +17284,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(189 /* AwaitExpression */); + var node = createNode(190 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -16941,7 +17327,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === 39 /* AsteriskAsteriskToken */) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 182 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 183 /* 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 { @@ -17037,7 +17423,7 @@ var ts; */ function parseIncrementExpression() { if (token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) { - var node = createNode(190 /* PrefixUnaryExpression */); + var node = createNode(191 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -17050,7 +17436,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(191 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(192 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -17154,7 +17540,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(177 /* PropertyAccessExpression */, expression.pos); + var node = createNode(178 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(22 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -17179,8 +17565,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 248 /* JsxOpeningElement */) { - var node = createNode(246 /* JsxElement */, opening.pos); + if (opening.kind === 250 /* JsxOpeningElement */) { + var node = createNode(248 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -17190,7 +17576,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 247 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 249 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -17205,7 +17591,7 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(192 /* BinaryExpression */, result.pos); + var badNode = createNode(193 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -17254,17 +17640,22 @@ var ts; parsingContext = saveParsingContext; return result; } + function parseJsxAttributes() { + var jsxAttributes = createNode(253 /* JsxAttributes */); + jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); + return finishNode(jsxAttributes); + } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); parseExpected(26 /* LessThanToken */); var tagName = parseJsxElementName(); - var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); + var attributes = parseJsxAttributes(); var node; if (token() === 28 /* GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(248 /* JsxOpeningElement */, fullStart); + node = createNode(250 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -17276,7 +17667,7 @@ var ts; parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(247 /* JsxSelfClosingElement */, fullStart); + node = createNode(249 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -17292,7 +17683,7 @@ var ts; var expression = token() === 98 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22 /* DotToken */)) { - var propertyAccess = createNode(177 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(178 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -17300,9 +17691,10 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(252 /* JsxExpression */); + var node = createNode(255 /* JsxExpression */); parseExpected(16 /* OpenBraceToken */); if (token() !== 17 /* CloseBraceToken */) { + node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { @@ -17319,7 +17711,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(250 /* JsxAttribute */); + var node = createNode(252 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 57 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -17334,7 +17726,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(251 /* JsxSpreadAttribute */); + var node = createNode(254 /* JsxSpreadAttribute */); parseExpected(16 /* OpenBraceToken */); parseExpected(23 /* DotDotDotToken */); node.expression = parseExpression(); @@ -17342,7 +17734,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(249 /* JsxClosingElement */); + var node = createNode(251 /* JsxClosingElement */); parseExpected(27 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -17355,7 +17747,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(182 /* TypeAssertionExpression */); + var node = createNode(183 /* TypeAssertionExpression */); parseExpected(26 /* LessThanToken */); node.type = parseType(); parseExpected(28 /* GreaterThanToken */); @@ -17366,7 +17758,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(177 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(178 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -17374,14 +17766,14 @@ var ts; } if (token() === 50 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(201 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(202 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(20 /* OpenBracketToken */)) { - var indexedAccess = createNode(178 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(179 /* 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. @@ -17397,7 +17789,7 @@ var ts; continue; } if (token() === 12 /* NoSubstitutionTemplateLiteral */ || token() === 13 /* TemplateHead */) { - var tagExpression = createNode(181 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(182 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -17420,7 +17812,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(179 /* CallExpression */, expression.pos); + var callExpr = createNode(180 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -17428,7 +17820,7 @@ var ts; continue; } else if (token() === 18 /* OpenParenToken */) { - var callExpr = createNode(179 /* CallExpression */, expression.pos); + var callExpr = createNode(180 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -17538,28 +17930,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(183 /* ParenthesizedExpression */); + var node = createNode(184 /* ParenthesizedExpression */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(196 /* SpreadElement */); + var node = createNode(197 /* SpreadElement */); parseExpected(23 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 23 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 25 /* CommaToken */ ? createNode(198 /* OmittedExpression */) : + token() === 25 /* CommaToken */ ? createNode(199 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(175 /* ArrayLiteralExpression */); + var node = createNode(176 /* ArrayLiteralExpression */); parseExpected(20 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17570,10 +17962,10 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(124 /* GetKeyword */)) { - return parseAccessorDeclaration(151 /* GetAccessor */, fullStart, decorators, modifiers); + return parseAccessorDeclaration(152 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(133 /* SetKeyword */)) { - return parseAccessorDeclaration(152 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(134 /* SetKeyword */)) { + return parseAccessorDeclaration(153 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -17581,7 +17973,7 @@ var ts; var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); if (dotDotDotToken) { - var spreadElement = createNode(259 /* SpreadAssignment */, fullStart); + var spreadElement = createNode(262 /* SpreadAssignment */, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -17606,7 +17998,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 /* CommaToken */ || token() === 17 /* CloseBraceToken */ || token() === 57 /* EqualsToken */); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(258 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(261 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57 /* EqualsToken */); @@ -17617,7 +18009,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(257 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(260 /* PropertyAssignment */, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -17627,7 +18019,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(176 /* ObjectLiteralExpression */); + var node = createNode(177 /* ObjectLiteralExpression */); parseExpected(16 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17646,7 +18038,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNode(184 /* FunctionExpression */); + var node = createNode(185 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(88 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); @@ -17668,8 +18060,15 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(180 /* NewExpression */); + var fullStart = scanner.getStartPos(); parseExpected(93 /* NewKeyword */); + if (parseOptional(22 /* DotToken */)) { + var node_1 = createNode(203 /* MetaProperty */, fullStart); + node_1.keywordToken = 93 /* NewKeyword */; + node_1.name = parseIdentifierName(); + return finishNode(node_1); + } + var node = createNode(181 /* NewExpression */, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18 /* OpenParenToken */) { @@ -17679,7 +18078,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(204 /* Block */); + var node = createNode(206 /* Block */); if (parseExpected(16 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17712,12 +18111,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(206 /* EmptyStatement */); + var node = createNode(208 /* EmptyStatement */); parseExpected(24 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(208 /* IfStatement */); + var node = createNode(210 /* IfStatement */); parseExpected(89 /* IfKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17727,7 +18126,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(209 /* DoStatement */); + var node = createNode(211 /* DoStatement */); parseExpected(80 /* DoKeyword */); node.statement = parseStatement(); parseExpected(105 /* WhileKeyword */); @@ -17742,7 +18141,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(210 /* WhileStatement */); + var node = createNode(212 /* WhileStatement */); parseExpected(105 /* WhileKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17765,21 +18164,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91 /* InKeyword */)) { - var forInStatement = createNode(212 /* ForInStatement */, pos); + var forInStatement = createNode(214 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(140 /* OfKeyword */)) { - var forOfStatement = createNode(213 /* ForOfStatement */, pos); + else if (parseOptional(141 /* OfKeyword */)) { + var forOfStatement = createNode(215 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(211 /* ForStatement */, pos); + var forStatement = createNode(213 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(24 /* SemicolonToken */); if (token() !== 24 /* SemicolonToken */ && token() !== 19 /* CloseParenToken */) { @@ -17797,7 +18196,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 215 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); + parseExpected(kind === 217 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -17805,7 +18204,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(216 /* ReturnStatement */); + var node = createNode(218 /* ReturnStatement */); parseExpected(95 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -17814,7 +18213,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(217 /* WithStatement */); + var node = createNode(219 /* WithStatement */); parseExpected(106 /* WithKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17823,7 +18222,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(253 /* CaseClause */); + var node = createNode(256 /* CaseClause */); parseExpected(72 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(55 /* ColonToken */); @@ -17831,7 +18230,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(254 /* DefaultClause */); + var node = createNode(257 /* DefaultClause */); parseExpected(78 /* DefaultKeyword */); parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -17841,12 +18240,12 @@ var ts; return token() === 72 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(218 /* SwitchStatement */); + var node = createNode(220 /* SwitchStatement */); parseExpected(97 /* SwitchKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); - var caseBlock = createNode(232 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(234 /* CaseBlock */, scanner.getStartPos()); parseExpected(16 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(17 /* CloseBraceToken */); @@ -17861,7 +18260,7 @@ 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(220 /* ThrowStatement */); + var node = createNode(222 /* ThrowStatement */); parseExpected(99 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -17869,7 +18268,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(221 /* TryStatement */); + var node = createNode(223 /* TryStatement */); parseExpected(101 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 73 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -17882,7 +18281,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(256 /* CatchClause */); + var result = createNode(259 /* CatchClause */); parseExpected(73 /* CatchKeyword */); if (parseExpected(18 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -17892,7 +18291,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(222 /* DebuggerStatement */); + var node = createNode(224 /* DebuggerStatement */); parseExpected(77 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -17904,13 +18303,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 /* Identifier */ && parseOptional(55 /* ColonToken */)) { - var labeledStatement = createNode(219 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(221 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(207 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(209 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -17960,7 +18359,7 @@ var ts; // // could be legal, it would add complexity for very little gain. case 108 /* InterfaceKeyword */: - case 136 /* TypeKeyword */: + case 137 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); case 127 /* ModuleKeyword */: case 128 /* NamespaceKeyword */: @@ -17978,7 +18377,7 @@ var ts; return false; } continue; - case 139 /* GlobalKeyword */: + case 140 /* GlobalKeyword */: nextToken(); return token() === 16 /* OpenBraceToken */ || token() === 70 /* Identifier */ || token() === 83 /* ExportKeyword */; case 90 /* ImportKeyword */: @@ -18040,8 +18439,8 @@ var ts; case 108 /* InterfaceKeyword */: case 127 /* ModuleKeyword */: case 128 /* NamespaceKeyword */: - case 136 /* TypeKeyword */: - case 139 /* GlobalKeyword */: + case 137 /* TypeKeyword */: + case 140 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; case 113 /* PublicKeyword */: @@ -18091,9 +18490,9 @@ var ts; case 87 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 76 /* ContinueKeyword */: - return parseBreakOrContinueStatement(214 /* ContinueStatement */); + return parseBreakOrContinueStatement(216 /* ContinueStatement */); case 71 /* BreakKeyword */: - return parseBreakOrContinueStatement(215 /* BreakStatement */); + return parseBreakOrContinueStatement(217 /* BreakStatement */); case 95 /* ReturnKeyword */: return parseReturnStatement(); case 106 /* WithKeyword */: @@ -18113,7 +18512,7 @@ var ts; return parseDeclaration(); case 119 /* AsyncKeyword */: case 108 /* InterfaceKeyword */: - case 136 /* TypeKeyword */: + case 137 /* TypeKeyword */: case 127 /* ModuleKeyword */: case 128 /* NamespaceKeyword */: case 123 /* DeclareKeyword */: @@ -18127,7 +18526,7 @@ var ts; case 116 /* AbstractKeyword */: case 114 /* StaticKeyword */: case 130 /* ReadonlyKeyword */: - case 139 /* GlobalKeyword */: + case 140 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -18150,11 +18549,11 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 108 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 136 /* TypeKeyword */: + case 137 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 82 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 139 /* GlobalKeyword */: + case 140 /* GlobalKeyword */: case 127 /* ModuleKeyword */: case 128 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -18175,7 +18574,7 @@ var ts; if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(244 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(246 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -18197,16 +18596,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 25 /* CommaToken */) { - return createNode(198 /* OmittedExpression */); + return createNode(199 /* OmittedExpression */); } - var node = createNode(174 /* BindingElement */); + var node = createNode(175 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(174 /* BindingElement */); + var node = createNode(175 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -18222,14 +18621,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(172 /* ObjectBindingPattern */); + var node = createNode(173 /* ObjectBindingPattern */); parseExpected(16 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(17 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(173 /* ArrayBindingPattern */); + var node = createNode(174 /* ArrayBindingPattern */); parseExpected(20 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(21 /* CloseBracketToken */); @@ -18248,7 +18647,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(223 /* VariableDeclaration */); + var node = createNode(225 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -18257,7 +18656,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(224 /* VariableDeclarationList */); + var node = createNode(226 /* VariableDeclarationList */); switch (token()) { case 103 /* VarKeyword */: break; @@ -18280,7 +18679,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() === 140 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 141 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -18295,7 +18694,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(205 /* VariableStatement */, fullStart); + var node = createNode(207 /* VariableStatement */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -18303,7 +18702,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225 /* FunctionDeclaration */, fullStart); + var node = createNode(227 /* FunctionDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88 /* FunctionKeyword */); @@ -18316,7 +18715,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(150 /* Constructor */, pos); + var node = createNode(151 /* Constructor */, pos); node.decorators = decorators; node.modifiers = modifiers; parseExpected(122 /* ConstructorKeyword */); @@ -18325,7 +18724,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(149 /* MethodDeclaration */, fullStart); + var method = createNode(150 /* MethodDeclaration */, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -18338,7 +18737,7 @@ var ts; return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(147 /* PropertyDeclaration */, fullStart); + var property = createNode(148 /* PropertyDeclaration */, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -18431,7 +18830,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 === 133 /* SetKeyword */ || idToken === 124 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 134 /* SetKeyword */ || idToken === 124 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -18461,7 +18860,7 @@ var ts; if (!parseOptional(56 /* AtToken */)) { break; } - var decorator = createNode(145 /* Decorator */, decoratorStart); + var decorator = createNode(146 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -18527,7 +18926,7 @@ var ts; } function parseClassElement() { if (token() === 24 /* SemicolonToken */) { - var result = createNode(203 /* SemicolonClassElement */); + var result = createNode(205 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -18555,8 +18954,8 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_13 = createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_13, /*questionToken*/ undefined); + var name = createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. ts.Debug.fail("Should not have attempted to parse class member declaration."); @@ -18565,10 +18964,10 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 197 /* ClassExpression */); + /*modifiers*/ undefined, 198 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 228 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -18612,7 +19011,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */) { - var node = createNode(255 /* HeritageClause */); + var node = createNode(258 /* HeritageClause */); node.token = token(); nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -18621,7 +19020,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(199 /* ExpressionWithTypeArguments */); + var node = createNode(200 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token() === 26 /* LessThanToken */) { node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); @@ -18635,7 +19034,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227 /* InterfaceDeclaration */, fullStart); + var node = createNode(229 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108 /* InterfaceKeyword */); @@ -18646,10 +19045,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228 /* TypeAliasDeclaration */, fullStart); + var node = createNode(230 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(136 /* TypeKeyword */); + parseExpected(137 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57 /* EqualsToken */); @@ -18662,13 +19061,13 @@ 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(260 /* EnumMember */, scanner.getStartPos()); + var node = createNode(263 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229 /* EnumDeclaration */, fullStart); + var node = createNode(231 /* EnumDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82 /* EnumKeyword */); @@ -18683,7 +19082,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(231 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(233 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(16 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(17 /* CloseBraceToken */); @@ -18694,7 +19093,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(230 /* ModuleDeclaration */, fullStart); + var node = createNode(232 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -18708,10 +19107,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230 /* ModuleDeclaration */, fullStart); + var node = createNode(232 /* ModuleDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 139 /* GlobalKeyword */) { + if (token() === 140 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -18729,7 +19128,7 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 139 /* GlobalKeyword */) { + if (token() === 140 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -18755,7 +19154,7 @@ var ts; return nextToken() === 40 /* SlashToken */; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(233 /* NamespaceExportDeclaration */, fullStart); + var exportDeclaration = createNode(235 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117 /* AsKeyword */); @@ -18770,11 +19169,11 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 /* CommaToken */ && token() !== 138 /* FromKeyword */) { + if (token() !== 25 /* CommaToken */ && token() !== 139 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(234 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(236 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -18785,7 +19184,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(235 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(237 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; // ImportDeclaration: @@ -18795,7 +19194,7 @@ var ts; token() === 38 /* AsteriskToken */ || token() === 16 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(138 /* FromKeyword */); + parseExpected(139 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -18808,7 +19207,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(236 /* ImportClause */, fullStart); + var importClause = createNode(238 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -18818,7 +19217,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(25 /* CommaToken */)) { - importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(238 /* NamedImports */); + importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(240 /* NamedImports */); } return finishNode(importClause); } @@ -18828,7 +19227,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(245 /* ExternalModuleReference */); + var node = createNode(247 /* ExternalModuleReference */); parseExpected(131 /* RequireKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -18851,7 +19250,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(237 /* NamespaceImport */); + var namespaceImport = createNode(239 /* NamespaceImport */); parseExpected(38 /* AsteriskToken */); parseExpected(117 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -18866,14 +19265,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 238 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 240 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(243 /* ExportSpecifier */); + return parseImportOrExportSpecifier(245 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(239 /* ImportSpecifier */); + return parseImportOrExportSpecifier(241 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -18898,27 +19297,27 @@ var ts; else { node.name = identifierName; } - if (kind === 239 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 241 /* 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(241 /* ExportDeclaration */, fullStart); + var node = createNode(243 /* ExportDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38 /* AsteriskToken */)) { - parseExpected(138 /* FromKeyword */); + parseExpected(139 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(242 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(244 /* 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() === 138 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(138 /* FromKeyword */); + if (token() === 139 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(139 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -18926,7 +19325,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(240 /* ExportAssignment */, fullStart); + var node = createNode(242 /* ExportAssignment */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57 /* EqualsToken */)) { @@ -19008,10 +19407,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 245 /* ExternalModuleReference */ - || node.kind === 235 /* ImportDeclaration */ - || node.kind === 240 /* ExportAssignment */ - || node.kind === 241 /* ExportDeclaration */ + || node.kind === 236 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 247 /* ExternalModuleReference */ + || node.kind === 237 /* ImportDeclaration */ + || node.kind === 242 /* ExportAssignment */ + || node.kind === 243 /* ExportDeclaration */ ? node : undefined; }); @@ -19086,7 +19485,7 @@ var ts; // Parses out a JSDoc type expression. /* @internal */ function parseJSDocTypeExpression() { - var result = createNode(262 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(266 /* JSDocTypeExpression */, scanner.getTokenPos()); parseExpected(16 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(17 /* CloseBraceToken */); @@ -19097,12 +19496,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48 /* BarToken */) { - var unionType = createNode(266 /* JSDocUnionType */, type.pos); + var unionType = createNode(270 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57 /* EqualsToken */) { - var optionalType = createNode(273 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(277 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -19113,20 +19512,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20 /* OpenBracketToken */) { - var arrayType = createNode(265 /* JSDocArrayType */, type.pos); + var arrayType = createNode(269 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21 /* CloseBracketToken */); type = finishNode(arrayType); } else if (token() === 54 /* QuestionToken */) { - var nullableType = createNode(268 /* JSDocNullableType */, type.pos); + var nullableType = createNode(272 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50 /* ExclamationToken */) { - var nonNullableType = createNode(269 /* JSDocNonNullableType */, type.pos); + var nonNullableType = createNode(273 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -19160,14 +19559,15 @@ var ts; case 98 /* ThisKeyword */: return parseJSDocThisType(); case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: case 94 /* NullKeyword */: - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: case 129 /* NeverKeyword */: + case 133 /* ObjectKeyword */: return parseTokenNode(); case 9 /* StringLiteral */: case 8 /* NumericLiteral */: @@ -19178,27 +19578,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(277 /* JSDocThisType */); + var result = createNode(281 /* JSDocThisType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(276 /* JSDocConstructorType */); + var result = createNode(280 /* JSDocConstructorType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(275 /* JSDocVariadicType */); + var result = createNode(279 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(274 /* JSDocFunctionType */); + var result = createNode(278 /* JSDocFunctionType */); nextToken(); parseExpected(18 /* OpenParenToken */); result.parameters = parseDelimitedList(23 /* JSDocFunctionParameters */, parseJSDocParameter); @@ -19211,7 +19611,7 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(144 /* Parameter */); + var parameter = createNode(145 /* Parameter */); parameter.type = parseJSDocType(); if (parseOptional(57 /* EqualsToken */)) { // TODO(rbuckton): Can this be changed to SyntaxKind.QuestionToken? @@ -19220,7 +19620,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(272 /* JSDocTypeReference */); + var result = createNode(276 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); @@ -19255,24 +19655,24 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(141 /* QualifiedName */, left.pos); + var result = createNode(142 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(270 /* JSDocRecordType */); + var result = createNode(274 /* JSDocRecordType */); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(269 /* JSDocNonNullableType */); + var result = createNode(273 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(267 /* JSDocTupleType */); + var result = createNode(271 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(26 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); @@ -19286,7 +19686,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(266 /* JSDocUnionType */); + var result = createNode(270 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19 /* CloseParenToken */); @@ -19302,12 +19702,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(263 /* JSDocAllType */); + var result = createNode(267 /* JSDocAllType */); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(288 /* JSDocLiteralType */); + var result = createNode(292 /* JSDocLiteralType */); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -19330,11 +19730,11 @@ var ts; token() === 28 /* GreaterThanToken */ || token() === 57 /* EqualsToken */ || token() === 48 /* BarToken */) { - var result = createNode(264 /* JSDocUnknownType */, pos); + var result = createNode(268 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(268 /* JSDocNullableType */, pos); + var result = createNode(272 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -19499,7 +19899,7 @@ var ts; content.charCodeAt(start + 3) !== 42 /* asterisk */; } function createJSDocComment() { - var result = createNode(278 /* JSDocComment */, start); + var result = createNode(282 /* JSDocComment */, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -19615,7 +20015,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(279 /* JSDocTag */, atToken.pos); + var result = createNode(283 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -19672,7 +20072,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(281 /* JSDocParameterTag */, atToken.pos); + var result = createNode(285 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -19683,20 +20083,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 282 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 286 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(282 /* JSDocReturnTag */, atToken.pos); + var result = createNode(286 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 287 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283 /* JSDocTypeTag */, atToken.pos); + var result = createNode(287 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -19711,7 +20111,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), /*length*/ 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(286 /* JSDocPropertyTag */, atToken.pos); + var result = createNode(290 /* JSDocPropertyTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -19720,7 +20120,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(280 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(284 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -19729,25 +20129,30 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(285 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(289 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0); if (typedefTag.fullName) { var rightNode = typedefTag.fullName; - while (rightNode.kind !== 70 /* Identifier */) { + while (true) { + if (rightNode.kind === 70 /* Identifier */ || !rightNode.body) { + // if node is identifier - use it as name + // otherwise use name of the rightmost part that we were able to parse + typedefTag.name = rightNode.kind === 70 /* Identifier */ ? rightNode : rightNode.name; + break; + } rightNode = rightNode.body; } - typedefTag.name = rightNode; } typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 272 /* JSDocTypeReference */) { + if (typeExpression.type.kind === 276 /* JSDocTypeReference */) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70 /* Identifier */) { - var name_14 = jsDocTypeReference.name; - if (name_14.text === "Object") { + var name = jsDocTypeReference.name; + if (name.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -19761,7 +20166,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(291 /* JSDocTypeLiteral */, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -19802,7 +20207,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22 /* DotToken */)) { - var jsDocNamespaceNode = createNode(230 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(232 /* ModuleDeclaration */, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4 /* NestedNamespace */); @@ -19848,20 +20253,20 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 288 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } // Type parameter list looks like '@template T,U,V' var typeParameters = createNodeArray(); while (true) { - var name_15 = parseJSDocIdentifierName(); + var name = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_15) { + if (!name) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(143 /* TypeParameter */, name_15.pos); - typeParameter.name = name_15; + var typeParameter = createNode(144 /* TypeParameter */, name.pos); + typeParameter.name = name; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25 /* CommaToken */) { @@ -19872,7 +20277,7 @@ var ts; break; } } - var result = createNode(284 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(288 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -20346,7 +20751,7 @@ var ts; 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++) { + for (var i = 0; i < array.length; i++) { var child = array[i]; if (child) { if (child.pos === position) { @@ -20392,16 +20797,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 227 /* InterfaceDeclaration */ || node.kind === 228 /* TypeAliasDeclaration */) { + if (node.kind === 229 /* InterfaceDeclaration */ || node.kind === 230 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 235 /* ImportDeclaration */ || node.kind === 234 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { + else if ((node.kind === 237 /* ImportDeclaration */ || node.kind === 236 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } - else if (node.kind === 231 /* ModuleBlock */) { + else if (node.kind === 233 /* ModuleBlock */) { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -20420,7 +20825,7 @@ var ts; }); return state_1; } - else if (node.kind === 230 /* ModuleDeclaration */) { + else if (node.kind === 232 /* ModuleDeclaration */) { var body = node.body; return body ? getModuleInstanceState(body) : 1 /* Instantiated */; } @@ -20561,7 +20966,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 230 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 232 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -20574,7 +20979,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { var nameExpression = node.name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression)) { @@ -20586,21 +20991,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 150 /* Constructor */: + case 151 /* Constructor */: return "__constructor"; - case 158 /* FunctionType */: - case 153 /* CallSignature */: + case 159 /* FunctionType */: + case 154 /* CallSignature */: return "__call"; - case 159 /* ConstructorType */: - case 154 /* ConstructSignature */: + case 160 /* ConstructorType */: + case 155 /* ConstructSignature */: return "__new"; - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: return "__index"; - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return "__export"; - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2 /* ModuleExports */: // module.exports = ... @@ -20615,22 +21020,22 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 225 /* FunctionDeclaration */: - case 226 /* ClassDeclaration */: + case 227 /* FunctionDeclaration */: + case 228 /* ClassDeclaration */: return ts.hasModifier(node, 512 /* Default */) ? "default" : undefined; - case 274 /* JSDocFunctionType */: + case 278 /* JSDocFunctionType */: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 144 /* Parameter */: + case 145 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 274 /* JSDocFunctionType */); + ts.Debug.assert(node.parent.kind === 278 /* JSDocFunctionType */); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 285 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 205 /* VariableStatement */) { + if (parentNode && parentNode.kind === 207 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -20685,15 +21090,18 @@ var ts; // Otherwise, we'll be merging into a compatible existing symbol (for example when // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. - symbol = symbolTable[name] || (symbolTable[name] = createSymbol(0 /* None */, name)); + symbol = symbolTable.get(name); + if (!symbol) { + symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + } if (name && (includes & 788448 /* Classifiable */)) { - classifiableNames[name] = name; + classifiableNames.set(name, name); } if (symbol.flags & excludes) { if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. - symbol = symbolTable[name] = createSymbol(0 /* None */, name); + symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); } else { if (node.name) { @@ -20717,7 +21125,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 240 /* ExportAssignment */ && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 242 /* ExportAssignment */ && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -20737,7 +21145,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 243 /* ExportSpecifier */ || (node.kind === 234 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 245 /* ExportSpecifier */ || (node.kind === 236 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -20760,7 +21168,7 @@ var ts; // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation // and this case is specially handled. Module augmentations should only be merged with original module definition // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. - var isJSDocTypedefInJSDocNamespace = node.kind === 285 /* JSDocTypedefTag */ && + var isJSDocTypedefInJSDocNamespace = node.kind === 289 /* JSDocTypedefTag */ && node.name && node.name.kind === 70 /* Identifier */ && node.name.isInJSDocNamespace; @@ -20847,7 +21255,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 264 /* SourceFile */) { node.flags |= emitFlags; } if (isIIFE) { @@ -20926,64 +21334,64 @@ var ts; return; } switch (node.kind) { - case 210 /* WhileStatement */: + case 212 /* WhileStatement */: bindWhileStatement(node); break; - case 209 /* DoStatement */: + case 211 /* DoStatement */: bindDoStatement(node); break; - case 211 /* ForStatement */: + case 213 /* ForStatement */: bindForStatement(node); break; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 208 /* IfStatement */: + case 210 /* IfStatement */: bindIfStatement(node); break; - case 216 /* ReturnStatement */: - case 220 /* ThrowStatement */: + case 218 /* ReturnStatement */: + case 222 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: + case 217 /* BreakStatement */: + case 216 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 221 /* TryStatement */: + case 223 /* TryStatement */: bindTryStatement(node); break; - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: bindSwitchStatement(node); break; - case 232 /* CaseBlock */: + case 234 /* CaseBlock */: bindCaseBlock(node); break; - case 253 /* CaseClause */: + case 256 /* CaseClause */: bindCaseClause(node); break; - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: bindLabeledStatement(node); break; - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 179 /* CallExpression */: + case 180 /* CallExpression */: bindCallExpressionFlow(node); break; default: @@ -20995,15 +21403,15 @@ var ts; switch (expr.kind) { case 70 /* Identifier */: case 98 /* ThisKeyword */: - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return hasNarrowableArgument(expr); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return expr.operator === 50 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -21011,7 +21419,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 /* Identifier */ || expr.kind === 98 /* ThisKeyword */ || - expr.kind === 177 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 178 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -21022,14 +21430,14 @@ var ts; } } } - if (expr.expression.kind === 177 /* PropertyAccessExpression */ && + if (expr.expression.kind === 178 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 187 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; + return expr1.kind === 188 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -21050,9 +21458,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 57 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -21147,33 +21555,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 208 /* IfStatement */: - case 210 /* WhileStatement */: - case 209 /* DoStatement */: + case 210 /* IfStatement */: + case 212 /* WhileStatement */: + case 211 /* DoStatement */: return parent.expression === node; - case 211 /* ForStatement */: - case 193 /* ConditionalExpression */: + case 213 /* ForStatement */: + case 194 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 183 /* ParenthesizedExpression */) { + if (node.kind === 184 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 190 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { + else if (node.kind === 191 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 192 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || + return node.kind === 193 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 53 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 183 /* ParenthesizedExpression */ || - node.parent.kind === 190 /* PrefixUnaryExpression */ && + while (node.parent.kind === 184 /* ParenthesizedExpression */ || + node.parent.kind === 191 /* PrefixUnaryExpression */ && node.parent.operator === 50 /* ExclamationToken */) { node = node.parent; } @@ -21215,7 +21623,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 219 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 221 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -21252,7 +21660,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 224 /* VariableDeclarationList */) { + if (node.initializer.kind !== 226 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -21274,7 +21682,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 216 /* ReturnStatement */) { + if (node.kind === 218 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -21294,7 +21702,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 215 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 217 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -21330,7 +21738,32 @@ var ts; if (node.finallyBlock) { // in finally flow is combined from pre-try/flow from try/flow from catch // pre-flow is necessary to make sure that finally is reachable even if finally flows in both try and finally blocks are unreachable - addAntecedent(preFinallyLabel, preTryFlow); + // also for finally blocks we inject two extra edges into the flow graph. + // first -> edge that connects pre-try flow with the label at the beginning of the finally block, it has lock associated with it + // second -> edge that represents post-finally flow. + // these edges are used in following scenario: + // let a; (1) + // try { a = someOperation(); (2)} + // finally { (3) console.log(a) } (4) + // (5) a + // flow graph for this case looks roughly like this (arrows show ): + // (1-pre-try-flow) <--.. <-- (2-post-try-flow) + // ^ ^ + // |*****(3-pre-finally-label) -----| + // ^ + // |-- ... <-- (4-post-finally-label) <--- (5) + // In case when we walk the flow starting from inside the finally block we want to take edge '*****' into account + // since it ensures that finally is always reachable. However when we start outside the finally block and go through label (5) + // then edge '*****' should be discarded because label 4 is only reachable if post-finally label-4 is reachable + // Simply speaking code inside finally block is treated as reachable as pre-try-flow + // since we conservatively assume that any line in try block can throw or return in which case we'll enter finally. + // However code after finally is reachable only if control flow was not abrupted in try/catch or finally blocks - it should be composed from + // final flows of these blocks without taking pre-try flow into account. + // + // extra edges that we inject allows to control this behavior + // if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped. + var preFinallyFlow = { flags: 2048 /* PreFinally */, antecedent: preTryFlow, lock: {} }; + addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); // if flow after finally is unreachable - keep it @@ -21346,6 +21779,11 @@ var ts; : unreachableFlow; } } + if (!(currentFlow.flags & 1 /* Unreachable */)) { + var afterFinallyFlow = { flags: 4096 /* AfterFinally */, antecedent: currentFlow }; + preFinallyFlow.lock = afterFinallyFlow; + currentFlow = afterFinallyFlow; + } } else { currentFlow = finishFlowLabel(preFinallyLabel); @@ -21360,7 +21798,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 254 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 257 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -21427,14 +21865,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 209 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 211 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 192 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { + if (node.kind === 193 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -21445,10 +21883,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 175 /* ArrayLiteralExpression */) { + else if (node.kind === 176 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 196 /* SpreadElement */) { + if (e.kind === 197 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -21456,16 +21894,16 @@ var ts; } } } - else if (node.kind === 176 /* ObjectLiteralExpression */) { + else if (node.kind === 177 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 257 /* PropertyAssignment */) { + if (p.kind === 260 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 258 /* ShorthandPropertyAssignment */) { + else if (p.kind === 261 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 259 /* SpreadAssignment */) { + else if (p.kind === 262 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -21521,7 +21959,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 57 /* EqualsToken */ && node.left.kind === 178 /* ElementAccessExpression */) { + if (operator === 57 /* EqualsToken */ && node.left.kind === 179 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -21532,7 +21970,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 177 /* PropertyAccessExpression */) { + if (node.expression.kind === 178 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -21565,7 +22003,7 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 212 /* ForInStatement */ || node.parent.parent.kind === 213 /* ForOfStatement */) { + if (node.initializer || node.parent.parent.kind === 214 /* ForInStatement */ || node.parent.parent.kind === 215 /* ForOfStatement */) { bindInitializedVariableFlow(node); } } @@ -21574,10 +22012,10 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 183 /* ParenthesizedExpression */) { + while (expr.kind === 184 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 184 /* FunctionExpression */ || expr.kind === 185 /* ArrowFunction */) { + if (expr.kind === 185 /* FunctionExpression */ || expr.kind === 186 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -21585,7 +22023,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 177 /* PropertyAccessExpression */) { + if (node.expression.kind === 178 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -21594,52 +22032,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 176 /* ObjectLiteralExpression */: - case 161 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 270 /* JSDocRecordType */: + case 198 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 177 /* ObjectLiteralExpression */: + case 162 /* TypeLiteral */: + case 291 /* JSDocTypeLiteral */: + case 274 /* JSDocRecordType */: + case 253 /* JsxAttributes */: return 1 /* IsContainer */; - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 274 /* JSDocFunctionType */: - case 230 /* ModuleDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 170 /* MappedType */: + case 278 /* JSDocFunctionType */: + case 232 /* ModuleDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 171 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 261 /* SourceFile */: + case 264 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } - case 150 /* Constructor */: - case 225 /* FunctionDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 151 /* Constructor */: + case 227 /* FunctionDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 231 /* ModuleBlock */: + case 233 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 256 /* CatchClause */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 232 /* CaseBlock */: + case 259 /* CatchClause */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 234 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 204 /* Block */: + case 206 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -21676,42 +22115,43 @@ 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 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 261 /* SourceFile */: + case 264 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 228 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 161 /* TypeLiteral */: - case 176 /* ObjectLiteralExpression */: - case 227 /* InterfaceDeclaration */: - case 270 /* JSDocRecordType */: - case 287 /* JSDocTypeLiteral */: + case 162 /* TypeLiteral */: + case 177 /* ObjectLiteralExpression */: + case 229 /* InterfaceDeclaration */: + case 274 /* JSDocRecordType */: + case 291 /* JSDocTypeLiteral */: + case 253 /* JsxAttributes */: // 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 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 274 /* JSDocFunctionType */: - case 228 /* TypeAliasDeclaration */: - case 170 /* MappedType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 278 /* JSDocFunctionType */: + case 230 /* TypeAliasDeclaration */: + case 171 /* MappedType */: // 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 @@ -21732,11 +22172,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 261 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 261 /* SourceFile */ || body.kind === 231 /* ModuleBlock */)) { + var body = node.kind === 264 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 264 /* SourceFile */ || body.kind === 233 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 241 /* ExportDeclaration */ || stat.kind === 240 /* ExportAssignment */) { + if (stat.kind === 243 /* ExportDeclaration */ || stat.kind === 242 /* ExportAssignment */) { return true; } } @@ -21760,7 +22200,7 @@ var ts; errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isExternalModuleAugmentation(node)) { - declareSymbolAndAddToSymbolTable(node, 1024 /* NamespaceModule */, 0 /* NamespaceModuleExcludes */); + declareModuleSymbol(node); } else { var pattern = void 0; @@ -21780,12 +22220,8 @@ var ts; } } else { - var state = getModuleInstanceState(node); - if (state === 0 /* NonInstantiated */) { - declareSymbolAndAddToSymbolTable(node, 1024 /* NamespaceModule */, 0 /* NamespaceModuleExcludes */); - } - else { - declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); + var state = declareModuleSymbol(node); + if (state !== 0 /* NonInstantiated */) { 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 @@ -21805,6 +22241,12 @@ var ts; } } } + function declareModuleSymbol(node) { + var state = getModuleInstanceState(node); + var instantiated = state !== 0 /* NonInstantiated */; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* ValueModule */ : 1024 /* NamespaceModule */, instantiated ? 106639 /* ValueModuleExcludes */ : 0 /* NamespaceModuleExcludes */); + return state; + } function bindFunctionOrConstructorType(node) { // For a given function symbol "<...>(...) => T" we want to generate a symbol identical // to the one we would get for: { <...>(...): T } @@ -21817,7 +22259,7 @@ var ts; var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); typeLiteralSymbol.members = ts.createMap(); - typeLiteralSymbol.members[symbol.name] = symbol; + typeLiteralSymbol.members.set(symbol.name, symbol); } function bindObjectLiteralExpression(node) { var ElementKind; @@ -21829,7 +22271,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { + if (prop.kind === 262 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { continue; } var identifier = prop.name; @@ -21841,12 +22283,12 @@ 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 === 257 /* PropertyAssignment */ || prop.kind === 258 /* ShorthandPropertyAssignment */ || prop.kind === 149 /* MethodDeclaration */ + var currentKind = prop.kind === 260 /* PropertyAssignment */ || prop.kind === 261 /* ShorthandPropertyAssignment */ || prop.kind === 150 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; - var existingKind = seen[identifier.text]; + var existingKind = seen.get(identifier.text); if (!existingKind) { - seen[identifier.text] = currentKind; + seen.set(identifier.text, currentKind); continue; } if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { @@ -21857,16 +22299,22 @@ var ts; } return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object"); } + function bindJsxAttributes(node) { + return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__jsxAttributes"); + } + function bindJsxAttribute(node, symbolFlags, symbolExcludes) { + return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); + } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 261 /* SourceFile */: + case 264 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -21977,8 +22425,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 261 /* SourceFile */ && - blockScopeContainer.kind !== 230 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 264 /* SourceFile */ && + blockScopeContainer.kind !== 232 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -22044,7 +22492,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 140 /* LastToken */) { + if (node.kind > 141 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -22091,23 +22539,23 @@ var ts; // current "blockScopeContainer" needs to be set to its immediate namespace parent. if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 285 /* JSDocTypedefTag */) { + while (parentNode && parentNode.kind !== 289 /* JSDocTypedefTag */) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); break; } case 98 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 258 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 261 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -22131,48 +22579,48 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return checkStrictModeCatchClause(node); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 217 /* WithStatement */: + case 219 /* WithStatement */: return checkStrictModeWithStatement(node); - case 167 /* ThisType */: + case 168 /* ThisType */: seenThisKeyword = true; return; - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return checkTypePredicate(node); - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530920 /* TypeParameterExcludes */); - case 144 /* Parameter */: + case 145 /* Parameter */: return bindParameter(node); - case 223 /* VariableDeclaration */: - case 174 /* BindingElement */: + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 271 /* JSDocRecordMember */: - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); - case 286 /* JSDocPropertyTag */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 275 /* JSDocRecordMember */: + return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 67108864 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + case 290 /* JSDocPropertyTag */: return bindJSDocProperty(node); - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: + case 260 /* PropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 260 /* EnumMember */: + case 263 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 259 /* SpreadAssignment */: - case 251 /* JsxSpreadAttribute */: + case 262 /* SpreadAssignment */: + case 254 /* JsxSpreadAttribute */: var root = container; var hasRest = false; while (root.parent) { - if (root.kind === 176 /* ObjectLiteralExpression */ && - root.parent.kind === 192 /* BinaryExpression */ && + if (root.kind === 177 /* ObjectLiteralExpression */ && + root.parent.kind === 193 /* BinaryExpression */ && root.parent.operatorToken.kind === 57 /* EqualsToken */ && root.parent.left === root) { hasRest = true; @@ -22181,86 +22629,91 @@ var ts; root = root.parent; } return; - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. - return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 225 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 67108864 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 99263 /* MethodExcludes */); + case 227 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 274 /* JSDocFunctionType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 278 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); - case 161 /* TypeLiteral */: - case 170 /* MappedType */: - case 287 /* JSDocTypeLiteral */: - case 270 /* JSDocRecordType */: + case 162 /* TypeLiteral */: + case 171 /* MappedType */: + case 291 /* JSDocTypeLiteral */: + case 274 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return bindFunctionExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 228 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792968 /* InterfaceExcludes */); - case 285 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: if (!node.fullName || node.fullName.kind === 70 /* Identifier */) { return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); } break; - case 228 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return bindModuleDeclaration(node); + // Jsx-attributes + case 253 /* JsxAttributes */: + return bindJsxAttributes(node); + case 252 /* JsxAttribute */: + return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 234 /* ImportEqualsDeclaration */: - case 237 /* NamespaceImport */: - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 239 /* NamespaceImport */: + case 241 /* ImportSpecifier */: + case 245 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 233 /* NamespaceExportDeclaration */: + case 235 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 236 /* ImportClause */: + case 238 /* ImportClause */: return bindImportClause(node); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return bindExportDeclaration(node); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return bindExportAssignment(node); - case 261 /* SourceFile */: + case 264 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 204 /* Block */: + case 206 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // Fall through - case 231 /* ModuleBlock */: + case 233 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); } } @@ -22269,7 +22722,7 @@ var ts; if (parameterName && parameterName.kind === 70 /* Identifier */) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 167 /* ThisType */) { + if (parameterName && parameterName.kind === 168 /* ThisType */) { seenThisKeyword = true; } bind(type); @@ -22292,7 +22745,7 @@ var ts; // An export default clause with an expression exports a value // We want to exclude both class and function here, this is necessary to issue an error when there are both // default export-assignment and default export function and class declaration. - var flags = node.kind === 240 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 242 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); @@ -22302,17 +22755,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 261 /* SourceFile */) { + if (node.parent.kind !== 264 /* SourceFile */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_4 = node.parent; - if (!ts.isExternalModule(parent_4)) { + var parent_1 = node.parent; + if (!ts.isExternalModule(parent_1)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_4.isDeclarationFile) { + if (!parent_1.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -22323,11 +22776,11 @@ var ts; function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { // Export * in some sort of block construct - bindAnonymousDeclaration(node, 1073741824 /* ExportStar */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 33554432 /* 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 */); + declareSymbol(container.symbol.exports, container.symbol, node, 33554432 /* ExportStar */, 0 /* None */); } } function bindImportClause(node) { @@ -22357,12 +22810,12 @@ var ts; function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); // Declare a 'member' if the container is an ES5 class or ES6 constructor - if (container.kind === 225 /* FunctionDeclaration */ || container.kind === 184 /* FunctionExpression */) { + if (container.kind === 227 /* FunctionDeclaration */ || container.kind === 185 /* FunctionExpression */) { container.symbol.members = container.symbol.members || ts.createMap(); // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); } - else if (container.kind === 150 /* Constructor */) { + else if (container.kind === 151 /* Constructor */) { // this.foo assignment in a JavaScript class // Bind this property to the containing class var saveContainer = container; @@ -22386,7 +22839,7 @@ var ts; leftSideOfAssignment.parent = node; constructorFunction.parent = classPrototype; classPrototype.parent = leftSideOfAssignment; - var funcSymbol = container.locals[constructorFunction.text]; + var funcSymbol = container.locals.get(constructorFunction.text); if (!funcSymbol || !(funcSymbol.flags & 16 /* Function */ || ts.isDeclarationOfFunctionExpression(funcSymbol))) { return; } @@ -22405,7 +22858,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 228 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -22413,7 +22866,7 @@ var ts; 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; + classifiableNames.set(node.name.text, node.name.text); } } var symbol = node.symbol; @@ -22426,14 +22879,15 @@ var 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. - var prototypeSymbol = createSymbol(4 /* Property */ | 134217728 /* Prototype */, "prototype"); - if (symbol.exports[prototypeSymbol.name]) { + var prototypeSymbol = createSymbol(4 /* Property */ | 16777216 /* Prototype */, "prototype"); + var symbolExport = symbol.exports.get(prototypeSymbol.name); + if (symbolExport) { 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)); + file.bindDiagnostics.push(ts.createDiagnosticForNode(symbolExport.declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; + symbol.exports.set(prototypeSymbol.name, prototypeSymbol); prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { @@ -22482,7 +22936,7 @@ var ts; // containing class. if (ts.isParameterPropertyDeclaration(node)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 67108864 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } } function bindFunctionDeclaration(node) { @@ -22541,13 +22995,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 206 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 208 /* EmptyStatement */) || // report error on class declarations - node.kind === 226 /* ClassDeclaration */ || + node.kind === 228 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 230 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 232 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 229 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 231 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; // unreachable code is reported if @@ -22561,7 +23015,7 @@ var ts; // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 205 /* VariableStatement */ || + (node.kind !== 207 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -22581,56 +23035,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 179 /* CallExpression */: + case 180 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 144 /* Parameter */: + case 145 /* Parameter */: return computeParameter(node, subtreeFlags); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 224 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 255 /* HeritageClause */: + case 258 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 150 /* Constructor */: + case 151 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -22657,8 +23111,8 @@ var ts; switch (kind) { case 96 /* SuperKeyword */: return true; - case 177 /* PropertyAccessExpression */: - case 178 /* ElementAccessExpression */: + case 178 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96 /* SuperKeyword */; @@ -22682,12 +23136,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 176 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 177 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ESNext if they contain rest transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 175 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 176 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } @@ -22737,8 +23191,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 200 /* AsExpression */ - || expressionKind === 182 /* TypeAssertionExpression */) { + if (expressionKind === 201 /* AsExpression */ + || expressionKind === 183 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -23103,7 +23557,7 @@ var ts; var excludeFlags = 536872257 /* NodeExcludes */; switch (kind) { case 119 /* AsyncKeyword */: - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: // async/await is ES2017 syntax transformFlags |= 16 /* AssertES2017 */; break; @@ -23113,27 +23567,28 @@ var ts; case 116 /* AbstractKeyword */: case 123 /* DeclareKeyword */: case 75 /* ConstKeyword */: - case 229 /* EnumDeclaration */: - case 260 /* EnumMember */: - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: - case 201 /* NonNullExpression */: + case 231 /* EnumDeclaration */: + case 263 /* EnumMember */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: + case 202 /* NonNullExpression */: case 130 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 246 /* JsxElement */: - case 247 /* JsxSelfClosingElement */: - case 248 /* JsxOpeningElement */: + case 248 /* JsxElement */: + case 249 /* JsxSelfClosingElement */: + case 250 /* JsxOpeningElement */: case 10 /* JsxText */: - case 249 /* JsxClosingElement */: - case 250 /* JsxAttribute */: - case 251 /* JsxSpreadAttribute */: - case 252 /* JsxExpression */: + case 251 /* JsxClosingElement */: + case 252 /* JsxAttribute */: + case 253 /* JsxAttributes */: + case 254 /* JsxSpreadAttribute */: + case 255 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; - case 213 /* ForOfStatement */: + case 215 /* ForOfStatement */: // for-of might be ESNext if it has a rest destructuring transformFlags |= 8 /* AssertESNext */; // FALLTHROUGH @@ -23141,53 +23596,55 @@ var ts; case 13 /* TemplateHead */: case 14 /* TemplateMiddle */: case 15 /* TemplateTail */: - case 194 /* TemplateExpression */: - case 181 /* TaggedTemplateExpression */: - case 258 /* ShorthandPropertyAssignment */: + case 195 /* TemplateExpression */: + case 182 /* TaggedTemplateExpression */: + case 261 /* ShorthandPropertyAssignment */: case 114 /* StaticKeyword */: + case 203 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: // This node is ES6 syntax. transformFlags |= 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; break; case 118 /* AnyKeyword */: case 132 /* NumberKeyword */: case 129 /* NeverKeyword */: - case 134 /* StringKeyword */: + case 133 /* ObjectKeyword */: + case 135 /* StringKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 143 /* TypeParameter */: - case 146 /* PropertySignature */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 156 /* TypePredicate */: - case 157 /* TypeReference */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 160 /* TypeQuery */: - case 161 /* TypeLiteral */: - case 162 /* ArrayType */: - case 163 /* TupleType */: - case 164 /* UnionType */: - case 165 /* IntersectionType */: - case 166 /* ParenthesizedType */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 167 /* ThisType */: - case 168 /* TypeOperator */: - case 169 /* IndexedAccessType */: - case 170 /* MappedType */: - case 171 /* LiteralType */: + case 144 /* TypeParameter */: + case 147 /* PropertySignature */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 157 /* TypePredicate */: + case 158 /* TypeReference */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 161 /* TypeQuery */: + case 162 /* TypeLiteral */: + case 163 /* ArrayType */: + case 164 /* TupleType */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: + case 167 /* ParenthesizedType */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 168 /* ThisType */: + case 169 /* TypeOperator */: + case 170 /* IndexedAccessType */: + case 171 /* MappedType */: + case 172 /* LiteralType */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. @@ -23204,10 +23661,10 @@ var ts; transformFlags |= 65536 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 259 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 96 /* SuperKeyword */: @@ -23218,28 +23675,28 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 16384 /* ContainsLexicalThis */; break; - case 172 /* ObjectBindingPattern */: + case 173 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; if (subtreeFlags & 524288 /* ContainsRest */) { transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectRest */; } excludeFlags = 537396545 /* BindingPatternExcludes */; break; - case 173 /* ArrayBindingPattern */: + case 174 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; excludeFlags = 537396545 /* BindingPatternExcludes */; break; - case 174 /* BindingElement */: + case 175 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 524288 /* ContainsRest */; } break; - case 145 /* Decorator */: + case 146 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsDecorators */; break; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: excludeFlags = 540087617 /* ObjectLiteralExcludes */; if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -23257,8 +23714,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 175 /* ArrayLiteralExpression */: - case 180 /* NewExpression */: + case 176 /* ArrayLiteralExpression */: + case 181 /* NewExpression */: excludeFlags = 537396545 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 524288 /* ContainsSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -23266,23 +23723,23 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 261 /* SourceFile */: + case 264 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 216 /* ReturnStatement */: - case 214 /* ContinueStatement */: - case 215 /* BreakStatement */: + case 218 /* ReturnStatement */: + case 216 /* ContinueStatement */: + case 217 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -23298,56 +23755,57 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 156 /* FirstTypeNode */ && kind <= 171 /* LastTypeNode */) { + if (kind >= 157 /* FirstTypeNode */ && kind <= 172 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 175 /* ArrayLiteralExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 176 /* ArrayLiteralExpression */: return 537396545 /* ArrayLiteralOrCallOrNewExcludes */; - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return 574674241 /* ModuleExcludes */; - case 144 /* Parameter */: + case 145 /* Parameter */: return 536872257 /* ParameterExcludes */; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return 601249089 /* ArrowFunctionExcludes */; - case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: return 601281857 /* FunctionExcludes */; - case 224 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return 546309441 /* VariableDeclarationListExcludes */; - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: return 539358529 /* ClassExcludes */; - case 150 /* Constructor */: + case 151 /* Constructor */: return 601015617 /* ConstructorExcludes */; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return 601015617 /* MethodOrAccessorExcludes */; case 118 /* AnyKeyword */: case 132 /* NumberKeyword */: case 129 /* NeverKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: + case 133 /* ObjectKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 143 /* TypeParameter */: - case 146 /* PropertySignature */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 144 /* TypeParameter */: + case 147 /* PropertySignature */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return 540087617 /* ObjectLiteralExcludes */; - case 256 /* CatchClause */: + case 259 /* CatchClause */: return 537920833 /* CatchClauseExcludes */; - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: return 537396545 /* BindingPatternExcludes */; default: return 536872257 /* NodeExcludes */; @@ -23386,10 +23844,6 @@ var ts; ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); return resolved.path; } - /** Create Resolved from a file with unknown extension. */ - function resolvedFromAnyFile(path) { - return { path: path, extension: ts.extensionFromPath(path) }; - } /** Adds `isExernalLibraryImport` to a Resolved to get a ResolvedModule. */ function resolvedModuleFromResolved(_a, isExternalLibraryImport) { var path = _a.path, extension = _a.extension; @@ -23402,37 +23856,29 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { + /** Reads from "main" or "types"/"typings" depending on `extensions`. */ + function tryReadPackageJsonFields(readTypes, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); - switch (extensions) { - case 2 /* DtsOnly */: - case 0 /* TypeScript */: - return tryReadFromField("typings") || tryReadFromField("types"); - case 1 /* JavaScript */: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; - } + return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); - } - return typesFilePath; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } + if (!ts.hasProperty(jsonContent, fieldName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName); } + return; } + var fileName = jsonContent[fieldName]; + if (typeof fileName !== "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof fileName); + } + return; + } + var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path); + } + return path; } } function readJson(path, host) { @@ -23468,6 +23914,7 @@ var ts; function getDefaultTypeRoots(currentDirectory, host) { if (!host.directoryExists) { return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; + // And if it doesn't exist, tough. } var typeRoots; forEachAncestorDirectory(currentDirectory, function (directory) { @@ -23475,6 +23922,7 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } + return undefined; }); return typeRoots; } @@ -23535,7 +23983,11 @@ var ts; return ts.forEach(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2 /* DtsOnly */, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); }); } else { @@ -23552,7 +24004,8 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2 /* DtsOnly */, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, /*cache*/ undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -23605,31 +24058,135 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); + if (!perModuleNameCache) { + perModuleNameCache = createPerModuleNameCache(); + moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + /** + * At first this function add entry directory -> module resolution result to the table. + * Then it computes the set of parent folders for 'directory' that should have the same module resolution result + * and for every parent folder in set it adds entry: parent -> module resolution. . + * Lets say we first directory name: /a/b/c/d/e and resolution result is: /a/b/bar.ts. + * Set of parent folders that should have the same result will be: + * [ + * /a/b/c/d, /a/b/c, /a/b + * ] + * this means that request for module resolution from file in any of these folder will be immediately found in cache. + */ + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + // if entry is already in cache do nothing + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + // find common prefix between directory and resolved file name + // this common prefix should be the shorted path that has the same resolution + // directory: /a/b/c/d/e + // resolvedFileName: /a/b/foo.d.ts + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent = ts.getDirectoryPath(current); + if (parent === current || directoryPathMap.contains(parent)) { + break; + } + directoryPathMap.set(parent, result); + current = parent; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + // find first position where directory and resolution differs + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + // find last directory separator before position i + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache.get(moduleName); + if (result) { if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache.set(moduleName, result); + // put result in per-module name cache + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; } if (traceEnabled) { if (result.resolvedModule) { @@ -23822,38 +24379,45 @@ var ts; return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /* jsOnly*/ false); + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + /* @internal */ + function nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, jsOnly) { + if (jsOnly === void 0) { jsOnly = false; } var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(0 /* TypeScript */) || tryResolve(1 /* JavaScript */); - if (result) { - var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + var result = jsOnly ? tryResolve(Extensions.JavaScript) : (tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript)); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { - var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); + var loader = function (extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, /*considerPackageJson*/ true); }; + var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); if (resolved) { - return { resolved: resolved, isExternalLibraryImport: false }; + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. - return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); - return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/ true); + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } - ts.nodeModuleNameResolver = nodeModuleNameResolver; + ts.nodeModuleNameResolverWorker = nodeModuleNameResolverWorker; function realpath(path, host, traceEnabled) { if (!host.realpath) { return path; @@ -23864,12 +24428,35 @@ var ts; } return real; } - function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } - var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson); } /* @internal */ function directoryProbablyExists(directoryName, host) { @@ -23908,11 +24495,11 @@ var ts; } } switch (extensions) { - case 2 /* DtsOnly */: + case Extensions.DtsOnly: return tryExtension(".d.ts", ts.Extension.Dts); - case 0 /* TypeScript */: + case Extensions.TypeScript: return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case 1 /* JavaScript */: + case Extensions.JavaScript: return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } function tryExtension(ext, extension) { @@ -23922,120 +24509,177 @@ var ts; } /** Return the file if it exists. */ function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); - } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); - } - failedLookupLocations.push(fileName); - return undefined; - } - } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - // A package.json "typings" may specify an exact filename, or may choose to omit an extension. - var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromFile) { - // Note: this would allow a package.json to specify a ".js" file as typings. Maybe that should be forbidden. - return resolvedFromAnyFile(fromFile); - } - var x = tryAddingExtensions(typesFile, 0 /* TypeScript */, failedLookupLocations, onlyRecordFailures_1, state); - if (x) { - return x; + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); } + return fileName; } else { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); } } } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + failedLookupLocations.push(fileName); + return undefined; + } + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { + if (considerPackageJson === void 0) { considerPackageJson = true; } + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (considerPackageJson) { + var packageJsonPath = pathToPackageJson(candidate); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + var fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; + } + } + else { + if (directoryExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + } + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocations.push(packageJsonPath); } - // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results - failedLookupLocations.push(packageJsonPath); } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + if (!file) { + return undefined; + } + var onlyRecordFailures = !directoryProbablyExists(ts.getDirectoryPath(file), state.host); + var fromFile = tryFile(file, failedLookupLocations, onlyRecordFailures, state); + if (fromFile) { + var resolved = fromFile && resolvedIfExtensionMatches(extensions, fromFile); + if (resolved) { + return resolved; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile); + } + } + // Even if extensions is DtsOnly, we can still look up a .ts file as a result of package.json "types" + var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; + // Don't do package.json lookup recursively, because Node.js' package lookup doesn't. + return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, /*considerPackageJson*/ false); + } + /** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */ + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + /** True if `extension` is one of the supported `extensions`. */ + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ false, cache); } function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { // Extensions parameter here doesn't actually matter, because typesOnly ensures we're just doing @types lookup, which is always DtsOnly. - return loadModuleFromNodeModulesWorker(2 /* DtsOnly */, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ true); + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ true, /*cache*/ undefined); } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); } }); } /** Load a module from a single node_modules directory, but not from any ancestors' node_modules directories. */ function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { if (typesOnly === void 0) { typesOnly = false; } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); if (packageResult) { return packageResult; } - if (extensions !== 1 /* JavaScript */) { - return loadModuleFromNodeModulesFolder(2 /* DtsOnly */, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(0 /* TypeScript */) || tryResolve(1 /* JavaScript */); - return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ false, failedLookupLocations); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); if (resolvedUsingSettings) { - return resolvedUsingSettings; + return { value: resolvedUsingSettings }; } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { // Climb up parent directories looking for a module. var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state)); }); if (resolved_3) { return resolved_3; } - if (extensions === 0 /* TypeScript */) { + if (extensions === Extensions.TypeScript) { // If we didn't find the file normally, look it up in @types. return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state)); } } } @@ -24052,10 +24696,17 @@ var ts; } var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(2 /* DtsOnly */, moduleName, globalCache, failedLookupLocations, state); + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + /** + * Wraps value to SearchResult. + * @returns undefined if value is undefined or { value } otherwise + */ + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ function forEachAncestorDirectory(directory, callback) { while (true) { @@ -24124,9 +24775,9 @@ var ts; var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; var strictNullChecks = compilerOptions.strictNullChecks; var emitResolver = createResolver(); - var undefinedSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "undefined"); + var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); undefinedSymbol.declarations = []; - var argumentsSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "arguments"); + var argumentsSymbol = createSymbol(4 /* Property */, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, @@ -24142,9 +24793,12 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, + getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, + getTypeFromTypeNode: getTypeFromTypeNode, + getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -24153,6 +24807,7 @@ var ts; getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, + signatureToString: signatureToString, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -24168,8 +24823,9 @@ var ts; getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, + getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getAmbientModules: getAmbientModules, - getJsxElementAttributesType: getJsxElementAttributesType, + getAllAttributesTypeFromJsxOpeningLikeElement: getAllAttributesTypeFromJsxOpeningLikeElement, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, isOptionalParameter: isOptionalParameter, tryGetMemberInModuleExports: tryGetMemberInModuleExports, @@ -24177,7 +24833,8 @@ var ts; // we deliberately exclude augmentations // since we are only interested in declarations of the module itself return tryFindAmbientModule(moduleName, /*withAugmentations*/ false); - } + }, + getApparentType: getApparentType }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -24186,8 +24843,8 @@ var ts; var numericLiteralTypes = ts.createMap(); var indexedAccessTypes = ts.createMap(); var evolvingArrayTypes = []; - var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); - var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); + var unknownSymbol = createSymbol(4 /* Property */, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__"); var anyType = createIntrinsicType(1 /* Any */, "any"); var autoType = createIntrinsicType(1 /* Any */, "any"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); @@ -24204,8 +24861,9 @@ var ts; var voidType = createIntrinsicType(1024 /* Void */, "void"); var neverType = createIntrinsicType(8192 /* Never */, "never"); var silentNeverType = createIntrinsicType(8192 /* Never */, "never"); + var nonPrimitiveType = createIntrinsicType(16777216 /* NonPrimitive */, "object"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */ | 67108864 /* Transient */, "__type"); + var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type"); emptyTypeLiteralSymbol.members = ts.createMap(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -24215,6 +24873,7 @@ var ts; // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. anyFunctionType.flags |= 8388608 /* ContainsAnyFunctionType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); @@ -24281,6 +24940,7 @@ var ts; var visitedFlowNodes = []; var visitedFlowTypes = []; var potentialThisCollisions = []; + var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var TypeFacts; @@ -24346,7 +25006,7 @@ var ts; TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; })(TypeFacts || (TypeFacts = {})); - var typeofEQFacts = ts.createMap({ + var typeofEQFacts = ts.createMapFromTemplate({ "string": 1 /* TypeofEQString */, "number": 2 /* TypeofEQNumber */, "boolean": 4 /* TypeofEQBoolean */, @@ -24355,7 +25015,7 @@ var ts; "object": 16 /* TypeofEQObject */, "function": 32 /* TypeofEQFunction */ }); - var typeofNEFacts = ts.createMap({ + var typeofNEFacts = ts.createMapFromTemplate({ "string": 128 /* TypeofNEString */, "number": 256 /* TypeofNENumber */, "boolean": 512 /* TypeofNEBoolean */, @@ -24364,13 +25024,14 @@ var ts; "object": 2048 /* TypeofNEObject */, "function": 4096 /* TypeofNEFunction */ }); - var typeofTypesByName = ts.createMap({ + var typeofTypesByName = ts.createMapFromTemplate({ "string": stringType, "number": numberType, "boolean": booleanType, "symbol": esSymbolType, "undefined": undefinedType }); + var typeofType = createTypeofType(); var jsxElementType; var _jsxNamespace; var _jsxFactoryEntity; @@ -24400,7 +25061,7 @@ var ts; TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var builtinGlobals = ts.createMap(); - builtinGlobals[undefinedSymbol.name] = undefinedSymbol; + builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); initializeTypeChecker(); return checker; function getJsxNamespace() { @@ -24432,7 +25093,9 @@ var ts; } function createSymbol(flags, name) { symbolCount++; - return new Symbol(flags, name); + var symbol = (new Symbol(flags | 134217728 /* Transient */, name)); + symbol.checkFlags = 0; + return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; @@ -24478,7 +25141,7 @@ var ts; mergedSymbols[source.mergeId] = target; } function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 33554432 /* Merged */, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); result.declarations = symbol.declarations.slice(0); result.parent = symbol.parent; if (symbol.valueDeclaration) @@ -24501,7 +25164,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 230 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 230 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 232 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 232 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -24518,6 +25181,9 @@ var ts; } recordMergedSymbol(target, source); } + else if (target.flags & 1024 /* NamespaceModule */) { + error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + } else { var message_2 = target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -24530,18 +25196,19 @@ var ts; } } function mergeSymbolTable(target, source) { - for (var id in source) { - var targetSymbol = target[id]; + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); if (!targetSymbol) { - target[id] = source[id]; + target.set(id, sourceSymbol); } else { - if (!(targetSymbol.flags & 33554432 /* Merged */)) { - target[id] = targetSymbol = cloneSymbol(targetSymbol); + if (!(targetSymbol.flags & 134217728 /* Transient */)) { + targetSymbol = cloneSymbol(targetSymbol); + target.set(id, targetSymbol); } - mergeSymbol(targetSymbol, source[id]); + mergeSymbol(targetSymbol, sourceSymbol); } - } + }); } function mergeModuleAugmentation(moduleName) { var moduleAugmentation = moduleName.parent; @@ -24570,7 +25237,7 @@ var ts; if (mainModule.flags & 1920 /* Namespace */) { // if module symbol has already been merged - it is safe to use it. // otherwise clone it - mainModule = mainModule.flags & 33554432 /* Merged */ ? mainModule : cloneSymbol(mainModule); + mainModule = mainModule.flags & 134217728 /* Transient */ ? mainModule : cloneSymbol(mainModule); mergeSymbol(mainModule, moduleAugmentation.symbol); } else { @@ -24579,21 +25246,22 @@ var ts; } } function addToSymbolTable(target, source, message) { - for (var id in source) { - if (target[id]) { + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); + if (targetSymbol) { // Error on redeclarations - ts.forEach(target[id].declarations, addDeclarationDiagnostic(id, message)); + ts.forEach(targetSymbol.declarations, addDeclarationDiagnostic(id, message)); } else { - target[id] = source[id]; + target.set(id, sourceSymbol); } - } + }); function addDeclarationDiagnostic(id, message) { return function (declaration) { return diagnostics.add(ts.createDiagnosticForNode(declaration, message, id)); }; } } function getSymbolLinks(symbol) { - if (symbol.flags & 67108864 /* Transient */) + if (symbol.flags & 134217728 /* Transient */) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = {}); @@ -24605,14 +25273,17 @@ var ts; function getObjectFlags(type) { return type.flags & 32768 /* Object */ ? type.objectFlags : 0; } + function getCheckFlags(symbol) { + return symbol.flags & 134217728 /* Transient */ ? symbol.checkFlags : 0; + } function isGlobalSourceFile(node) { - return node.kind === 261 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 264 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { - var symbol = symbols[name]; + var symbol = symbols.get(name); if (symbol) { - ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } @@ -24654,7 +25325,7 @@ var ts; } // declaration is after usage // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) - if (isUsedInFunctionOrNonStaticProperty(usage)) { + if (isUsedInFunctionOrInstanceProperty(usage)) { return true; } var sourceFiles = host.getSourceFiles(); @@ -24662,20 +25333,34 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - // still might be illegal if usage is in the initializer of the variable declaration - return declaration.kind !== 223 /* VariableDeclaration */ || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + if (declaration.kind === 175 /* BindingElement */) { + // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) + var errorBindingElement = ts.getAncestor(usage, 175 /* BindingElement */); + if (errorBindingElement) { + return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + declaration.pos < errorBindingElement.pos; + } + // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 225 /* VariableDeclaration */), usage); + } + else if (declaration.kind === 225 /* VariableDeclaration */) { + // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) + return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return true; } - // declaration is after usage - // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) + // declaration is after usage, but it can still be legal if usage is deferred: + // 1. inside a function + // 2. inside an instance property initializer, a reference to a non-instance property var container = ts.getEnclosingBlockScopeContainer(declaration); - return isUsedInFunctionOrNonStaticProperty(usage, container); + var isInstanceProperty = declaration.kind === 148 /* PropertyDeclaration */ && !(ts.getModifierFlags(declaration) & 32 /* Static */); + return isUsedInFunctionOrInstanceProperty(usage, isInstanceProperty, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 205 /* VariableStatement */: - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 207 /* VariableStatement */: + case 213 /* ForStatement */: + case 215 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -24684,8 +25369,8 @@ var ts; break; } switch (declaration.parent.parent.kind) { - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: // ForIn/ForOf case - use site should not be used in expression part if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; @@ -24693,7 +25378,7 @@ var ts; } return false; } - function isUsedInFunctionOrNonStaticProperty(usage, container) { + function isUsedInFunctionOrInstanceProperty(usage, isDeclarationInstanceProperty, container) { var current = usage; while (current) { if (current === container) { @@ -24702,17 +25387,26 @@ var ts; if (ts.isFunctionLike(current)) { return true; } - var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 147 /* PropertyDeclaration */ && + var initializerOfInstanceProperty = current.parent && + current.parent.kind === 148 /* PropertyDeclaration */ && (ts.getModifierFlags(current.parent) & 32 /* Static */) === 0 && current.parent.initializer === current; - if (initializerOfNonStaticProperty) { - return true; + if (initializerOfInstanceProperty) { + return !isDeclarationInstanceProperty; } current = current.parent; } return false; } + function getAncestorBindingPattern(node) { + while (node) { + if (ts.isBindingPattern(node)) { + return node; + } + node = node.parent; + } + return undefined; + } } // 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 @@ -24736,11 +25430,11 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 278 /* JSDocComment */) { + if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 282 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || - lastLocation.kind === 144 /* Parameter */ || - lastLocation.kind === 143 /* TypeParameter */ + lastLocation.kind === 145 /* Parameter */ || + lastLocation.kind === 144 /* TypeParameter */ : false; } if (meaning & 107455 /* Value */ && result.flags & 1 /* FunctionScopedVariable */) { @@ -24749,9 +25443,9 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 144 /* Parameter */ || + lastLocation.kind === 145 /* Parameter */ || (lastLocation === location.type && - result.valueDeclaration.kind === 144 /* Parameter */); + result.valueDeclaration.kind === 145 /* Parameter */); } } if (useResult) { @@ -24763,16 +25457,16 @@ var ts; } } switch (location.kind) { - case 261 /* SourceFile */: + case 264 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 261 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 264 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. - if (result = moduleExports["default"]) { + if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; @@ -24790,9 +25484,10 @@ var ts; // 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 (moduleExports[name] && - moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 243 /* ExportSpecifier */)) { + var moduleExport = moduleExports.get(name); + if (moduleExport && + moduleExport.flags === 8388608 /* Alias */ && + ts.getDeclarationOfKind(moduleExport, 245 /* ExportSpecifier */)) { break; } } @@ -24800,13 +25495,13 @@ var ts; break loop; } break; - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* 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 @@ -24823,10 +25518,15 @@ var ts; } } break; - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064 /* Type */)) { + if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { + // ignore type parameters not declared in this container + result = undefined; + break; + } if (lastLocation && ts.getModifierFlags(lastLocation) & 32 /* 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 @@ -24836,7 +25536,7 @@ var ts; } break loop; } - if (location.kind === 197 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 198 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -24852,9 +25552,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 227 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 229 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -24862,19 +25562,19 @@ var ts; } } break; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -24887,7 +25587,7 @@ var ts; } } break; - case 145 /* Decorator */: + case 146 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -24896,7 +25596,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 === 144 /* Parameter */) { + if (location.parent && location.parent.kind === 145 /* Parameter */) { location = location.parent; } // @@ -24947,10 +25647,10 @@ var ts; // interface 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 + // The foo at /*1*/ and /*2*/ will share same symbol with two meanings: + // block-scoped 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 + // we want to check for block-scoped if (meaning & 2 /* BlockScopedVariable */) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */) { @@ -24960,18 +25660,27 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 107455 /* Value */) === 107455 /* Value */) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 233 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 235 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } } return result; } + function isTypeParameterSymbolDeclaredInContainer(symbol, container) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.kind === 144 /* TypeParameter */ && decl.parent === container) { + return true; + } + } + return false; + } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { if ((errorLocation.kind === 70 /* Identifier */ && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } - var container = ts.getThisContainer(errorLocation, /* includeArrowFunctions */ true); + var container = ts.getThisContainer(errorLocation, /*includeArrowFunctions*/ true); var location = container; while (location) { if (ts.isClassLike(location.parent)) { @@ -25014,9 +25723,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70 /* Identifier */: - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -25048,7 +25757,7 @@ var ts; // Block-scoped variables cannot be used before their definition var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 223 /* VariableDeclaration */), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -25069,10 +25778,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 236 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 235 /* ImportDeclaration */) { + while (node && node.kind !== 237 /* ImportDeclaration */) { node = node.parent; } return node; @@ -25082,7 +25791,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 245 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 247 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -25090,11 +25799,16 @@ var ts; function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { - var exportDefaultSymbol = ts.isShorthandAmbientModuleSymbol(moduleSymbol) ? - moduleSymbol : - moduleSymbol.exports["export="] ? - getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") : - resolveSymbol(moduleSymbol.exports["default"]); + var exportDefaultSymbol = void 0; + if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { + exportDefaultSymbol = moduleSymbol; + } + else { + var exportValue = moduleSymbol.exports.get("export="); + exportDefaultSymbol = exportValue + ? getPropertyOfType(getTypeOfSymbol(exportValue), "default") + : resolveSymbol(moduleSymbol.exports.get("default")); + } if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } @@ -25143,7 +25857,7 @@ var ts; } function getExportOfModule(symbol, name) { if (symbol.flags & 1536 /* Module */) { - var exportedSymbol = getExportsOfSymbol(symbol)[name]; + var exportedSymbol = getExportsOfSymbol(symbol).get(name); if (exportedSymbol) { return resolveSymbol(exportedSymbol); } @@ -25161,31 +25875,31 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_16 = specifier.propertyName || specifier.name; - if (name_16.text) { + var name = specifier.propertyName || specifier.name; + if (name.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; // First check if module was specified with "export=". If so, get the member from the resolved type - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_16.text); + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) { + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_16.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_16.text); + var symbolFromModule = getExportOfModule(targetSymbol, name.text); // If the export member we're looking for is default, and there is no real default but allowSyntheticDefaultImports is on, return the entire module as the default - if (!symbolFromModule && allowSyntheticDefaultImports && name_16.text === "default") { + if (!symbolFromModule && allowSyntheticDefaultImports && name.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_16, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_16)); + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name)); } return symbol; } @@ -25207,19 +25921,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 236 /* ImportClause */: + case 238 /* ImportClause */: return getTargetOfImportClause(node); - case 237 /* NamespaceImport */: + case 239 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 239 /* ImportSpecifier */: + case 241 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 243 /* ExportSpecifier */: + case 245 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return getTargetOfExportAssignment(node); - case 233 /* NamespaceExportDeclaration */: + case 235 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node); } } @@ -25266,11 +25980,11 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 240 /* ExportAssignment */) { + if (node.kind === 242 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 243 /* ExportSpecifier */) { + else if (node.kind === 245 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -25292,20 +26006,22 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 70 /* Identifier */ || entityName.parent.kind === 141 /* QualifiedName */) { + if (entityName.kind === 70 /* Identifier */ || entityName.parent.kind === 142 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 234 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 236 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol) { return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); } - // Resolves a qualified name and any involved aliases + /** + * Resolves a qualified name and any involved aliases. + */ function resolveEntityName(name, meaning, ignoreErrors, dontResolveAlias, location) { if (ts.nodeIsMissing(name)) { return undefined; @@ -25318,9 +26034,9 @@ var ts; return undefined; } } - else if (name.kind === 141 /* QualifiedName */ || name.kind === 177 /* PropertyAccessExpression */) { - var left = name.kind === 141 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 141 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 142 /* QualifiedName */ || name.kind === 178 /* PropertyAccessExpression */) { + var left = name.kind === 142 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 142 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1920 /* Namespace */, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -25339,7 +26055,7 @@ var ts; else { ts.Debug.fail("Unknown entity name kind."); } - ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); } function resolveExternalModuleName(location, moduleReferenceExpression) { @@ -25419,7 +26135,7 @@ var ts; // 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 && getMergedSymbol(resolveSymbol(moduleSymbol.exports["export="])) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("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 @@ -25433,15 +26149,23 @@ var ts; return symbol; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["export="] !== undefined; + return moduleSymbol.exports.get("export=") !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); } + function getExportsAndPropertiesOfModule(moduleSymbol) { + var exports = getExportsOfModuleAsArray(moduleSymbol); + var exportEquals = resolveExternalModuleSymbol(moduleSymbol); + if (exportEquals !== moduleSymbol) { + ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + } + return exports; + } function tryGetMemberInModuleExports(memberName, moduleSymbol) { var symbolTable = getExportsOfModule(moduleSymbol); if (symbolTable) { - return symbolTable[memberName]; + return symbolTable.get(memberName); } } function getExportsOfSymbol(symbol) { @@ -25456,24 +26180,28 @@ var ts; * Not passing `lookupTable` and `exportNode` disables this collection, and just extends the tables */ function extendExportSymbols(target, source, lookupTable, exportNode) { - for (var id in source) { - if (id !== "default" && !target[id]) { - target[id] = source[id]; + source && source.forEach(function (sourceSymbol, id) { + if (id === "default") + return; + var targetSymbol = target.get(id); + if (!targetSymbol) { + target.set(id, sourceSymbol); if (lookupTable && exportNode) { - lookupTable[id] = { + lookupTable.set(id, { specifierText: ts.getTextOfNode(exportNode.moduleSpecifier) - }; + }); } } - else if (lookupTable && exportNode && id !== "default" && target[id] && resolveSymbol(target[id]) !== resolveSymbol(source[id])) { - if (!lookupTable[id].exportsWithDuplicate) { - lookupTable[id].exportsWithDuplicate = [exportNode]; + else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) { + var collisionTracker = lookupTable.get(id); + if (!collisionTracker.exportsWithDuplicate) { + collisionTracker.exportsWithDuplicate = [exportNode]; } else { - lookupTable[id].exportsWithDuplicate.push(exportNode); + collisionTracker.exportsWithDuplicate.push(exportNode); } } - } + }); } function getExportsForModule(moduleSymbol) { var visitedSymbols = []; @@ -25489,27 +26217,27 @@ var ts; visitedSymbols.push(symbol); var symbols = ts.cloneMap(symbol.exports); // All export * declarations are collected in an __export symbol by the binder - var exportStars = symbol.exports["__export"]; + var exportStars = symbol.exports.get("__export"); if (exportStars) { var nestedSymbols = ts.createMap(); - var lookupTable = ts.createMap(); + var lookupTable_1 = ts.createMap(); for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { var node = _a[_i]; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); var exportedSymbols = visit(resolvedModule); - extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable, node); + extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); } - for (var id in lookupTable) { - var exportsWithDuplicate = lookupTable[id].exportsWithDuplicate; + lookupTable_1.forEach(function (_a, id) { + var exportsWithDuplicate = _a.exportsWithDuplicate; // It's not an error if the file with multiple `export *`s with duplicate names exports a member with that name itself - if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols[id]) { - continue; + if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) { + return; } - for (var _b = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _b < exportsWithDuplicate_1.length; _b++) { - var node = exportsWithDuplicate_1[_b]; - diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable[id].specifierText, id)); + for (var _i = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _i < exportsWithDuplicate_1.length; _i++) { + var node = exportsWithDuplicate_1[_i]; + diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable_1.get(id).specifierText, id)); } - } + }); extendExportSymbols(symbols, nestedSymbols); } return symbols; @@ -25531,26 +26259,13 @@ var ts; : 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; + return !!(symbol.flags & 107455 /* Value */ || symbol.flags & 8388608 /* Alias */ && resolveAlias(symbol).flags & 107455 /* Value */); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 150 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 151 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -25578,6 +26293,9 @@ var ts; type.symbol = symbol; return type; } + function createTypeofType() { + return getUnionType(ts.convertToArray(typeofEQFacts.keys(), function (s) { return getLiteralTypeForText(32 /* StringLiteral */, s); })); + } // 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 @@ -25590,16 +26308,15 @@ var ts; } function getNamedMembers(members) { var result; - for (var id in members) { + members.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { if (!result) result = []; - var symbol = members[id]; if (symbolIsValue(symbol)) { result.push(symbol); } } - } + }); return result || emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -25618,20 +26335,20 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { + for (var location = enclosingDeclaration; location; location = location.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)) { + if (location.locals && !isGlobalSourceFile(location)) { + if (result = callback(location.locals)) { return result; } } - switch (location_1.kind) { - case 261 /* SourceFile */: - if (!ts.isExternalOrCommonJsModule(location_1)) { + switch (location.kind) { + case 264 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230 /* ModuleDeclaration */: - if (result = callback(getSymbolOfNode(location_1).exports)) { + case 232 /* ModuleDeclaration */: + if (result = callback(getSymbolOfNode(location).exports)) { return result; } break; @@ -25675,14 +26392,14 @@ var ts; } function trySymbolTable(symbols) { // If symbol is directly available by its name in the symbol table - if (isAccessible(symbols[symbol.name])) { + if (isAccessible(symbols.get(symbol.name))) { return [symbol]; } // Check if symbol is any of the alias - return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { + return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -25711,7 +26428,7 @@ var ts; var qualify = false; forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { // If symbol of this name is not available in the symbol table we are ok - var symbolFromSymbolTable = symbolTable[symbol.name]; + var symbolFromSymbolTable = symbolTable.get(symbol.name); if (!symbolFromSymbolTable) { // Continue to the next symbol table return false; @@ -25722,7 +26439,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, 243 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -25737,10 +26454,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 147 /* PropertyDeclaration */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 148 /* PropertyDeclaration */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: continue; default: return false; @@ -25821,7 +26538,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 264 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -25862,12 +26579,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 160 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 161 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 141 /* QualifiedName */ || entityName.kind === 177 /* PropertyAccessExpression */ || - entityName.parent.kind === 234 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 142 /* QualifiedName */ || entityName.kind === 178 /* PropertyAccessExpression */ || + entityName.parent.kind === 236 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -25963,10 +26680,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 166 /* ParenthesizedType */) { + while (node.kind === 167 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 228 /* TypeAliasDeclaration */) { + if (node.kind === 230 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -25974,29 +26691,29 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 231 /* ModuleBlock */ && + node.parent.kind === 233 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { return type.flags & 32 /* StringLiteral */ ? "\"" + ts.escapeString(type.text) + "\"" : type.text; } - 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 197 /* ClassExpression */: - return "(Anonymous class)"; - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - return "(Anonymous function)"; - } + 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 198 /* ClassExpression */: + return "(Anonymous class)"; + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + return "(Anonymous function)"; } - return symbol.name; } + return symbol.name; + } + function getSymbolDisplayBuilder() { /** * 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 wrote the name. @@ -26038,7 +26755,7 @@ var ts; if (parentSymbol) { // Write type arguments of instantiated class/interface here if (flags & 1 /* WriteTypeParametersOrArguments */) { - if (symbol.flags & 16777216 /* Instantiated */) { + if (getCheckFlags(symbol) & 1 /* Instantiated */) { buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); } else { @@ -26066,9 +26783,9 @@ var ts; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. - var parent_5 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_5) { - walkSymbol(parent_5, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + walkSymbol(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); } } if (accessibleSymbolChain) { @@ -26106,7 +26823,7 @@ var ts; function writeType(type, flags) { var nextFlags = flags & ~512 /* InTypeAlias */; // Write undefined/null type as any - if (type.flags & 16015 /* Intrinsic */) { + if (type.flags & 16793231 /* 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" @@ -26133,7 +26850,7 @@ var ts; else if (!(flags & 512 /* InTypeAlias */) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === 0 /* Accessible */) { var typeArguments = type.aliasTypeArguments; - writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); + writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, ts.length(typeArguments), nextFlags); } else if (type.flags & 196608 /* UnionOrIntersection */) { writeUnionOrIntersectionType(type, nextFlags); @@ -26218,14 +26935,14 @@ var ts; while (i < length_1) { // Find group of type arguments for type parameters with the same declaring container. var start = i; - var parent_6 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_6); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); // 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_6, typeArguments, start, i, flags); + writeSymbolTypeReference(parent, typeArguments, start, i, flags); writePunctuation(writer, 22 /* DotToken */); } } @@ -26252,7 +26969,8 @@ var ts; 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 */)) { + if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (384 /* Enum */ | 512 /* ValueModule */)) { writeTypeOfSymbol(type, flags); } else if (shouldWriteTypeOfFunctionSymbol()) { @@ -26291,7 +27009,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 261 /* SourceFile */ || declaration.parent.kind === 231 /* ModuleBlock */; + return declaration.parent.kind === 264 /* SourceFile */ || declaration.parent.kind === 233 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -26305,32 +27023,13 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } - function writeIndexSignature(info, keyword) { - if (info) { - if (info.isReadonly) { - writeKeyword(writer, 130 /* ReadonlyKeyword */); - writeSpace(writer); - } - writePunctuation(writer, 20 /* OpenBracketToken */); - writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55 /* ColonToken */); - writeSpace(writer); - writeKeyword(writer, keyword); - writePunctuation(writer, 21 /* CloseBracketToken */); - writePunctuation(writer, 55 /* ColonToken */); - writeSpace(writer); - writeType(info.type, 0 /* None */); - writePunctuation(writer, 24 /* SemicolonToken */); - writer.writeLine(); - } - } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { writeKeyword(writer, 130 /* ReadonlyKeyword */); writeSpace(writer); } buildSymbolDisplay(prop, writer); - if (prop.flags & 536870912 /* Optional */) { + if (prop.flags & 67108864 /* Optional */) { writePunctuation(writer, 54 /* QuestionToken */); } } @@ -26407,8 +27106,8 @@ var ts; writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 134 /* StringKeyword */); - writeIndexSignature(resolved.numberIndexInfo, 132 /* NumberKeyword */); + buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0 /* String */, enclosingDeclaration, globalFlags, symbolStack); + buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, 1 /* Number */, enclosingDeclaration, globalFlags, symbolStack); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -26474,6 +27173,13 @@ var ts; writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } + var defaultType = getDefaultFromTypeParameter(tp); + if (defaultType) { + writeSpace(writer); + writePunctuation(writer, 57 /* EqualsToken */); + writeSpace(writer); + buildTypeDisplay(defaultType, writer, enclosingDeclaration, flags, symbolStack); + } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; @@ -26491,16 +27197,20 @@ var ts; } writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); - buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); + var type = getTypeOfSymbol(p); + if (isRequiredInitializedParameter(parameterNode)) { + type = includeFalsyTypes(type, 2048 /* Undefined */); + } + buildTypeDisplay(type, writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { // We have to explicitly emit square bracket and bracket because these tokens are not stored inside the node. - if (bindingPattern.kind === 172 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 173 /* ObjectBindingPattern */) { writePunctuation(writer, 16 /* OpenBraceToken */); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); writePunctuation(writer, 17 /* CloseBraceToken */); } - else if (bindingPattern.kind === 173 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 174 /* ArrayBindingPattern */) { writePunctuation(writer, 20 /* OpenBracketToken */); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -26514,7 +27224,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 174 /* BindingElement */); + ts.Debug.assert(bindingElement.kind === 175 /* BindingElement */); if (bindingElement.propertyName) { writer.writeProperty(ts.getTextOfNode(bindingElement.propertyName)); writePunctuation(writer, 55 /* ColonToken */); @@ -26588,6 +27298,10 @@ var ts; buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + var returnType = getReturnTypeOfSignature(signature); + if (flags & 2048 /* SuppressAnyReturnType */ && isTypeAny(returnType)) { + return; + } if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); writePunctuation(writer, 35 /* EqualsGreaterThanToken */); @@ -26600,7 +27314,6 @@ var ts; buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); } else { - var returnType = getReturnTypeOfSignature(signature); buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } } @@ -26620,6 +27333,32 @@ var ts; buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } + function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 130 /* ReadonlyKeyword */); + writeSpace(writer); + } + writePunctuation(writer, 20 /* OpenBracketToken */); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 55 /* ColonToken */); + writeSpace(writer); + switch (kind) { + case 1 /* Number */: + writeKeyword(writer, 132 /* NumberKeyword */); + break; + case 0 /* String */: + writeKeyword(writer, 135 /* StringKeyword */); + break; + } + writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 55 /* ColonToken */); + writeSpace(writer); + buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); + writePunctuation(writer, 24 /* SemicolonToken */); + writer.writeLine(); + } + } return _displayBuilder || (_displayBuilder = { buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, @@ -26630,6 +27369,7 @@ var ts; buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, + buildIndexSignatureDisplay: buildIndexSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay }); } @@ -26644,75 +27384,75 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 174 /* BindingElement */: + case 175 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 223 /* VariableDeclaration */: + case 225 /* 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 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 225 /* FunctionDeclaration */: - case 229 /* EnumDeclaration */: - case 234 /* ImportEqualsDeclaration */: + case 232 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 227 /* FunctionDeclaration */: + case 231 /* EnumDeclaration */: + case 236 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_7 = getDeclarationContainer(node); + var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 234 /* ImportEqualsDeclaration */ && parent_7.kind !== 261 /* SourceFile */ && ts.isInAmbientContext(parent_7))) { - return isGlobalSourceFile(parent_7); + !(node.kind !== 236 /* ImportEqualsDeclaration */ && parent.kind !== 264 /* SourceFile */ && ts.isInAmbientContext(parent))) { + return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible - return isDeclarationVisible(parent_7); - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + return isDeclarationVisible(parent); + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: if (ts.getModifierFlags(node) & (8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so const it fall into next case statement - case 150 /* Constructor */: - case 154 /* ConstructSignature */: - case 153 /* CallSignature */: - case 155 /* IndexSignature */: - case 144 /* Parameter */: - case 231 /* ModuleBlock */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 161 /* TypeLiteral */: - case 157 /* TypeReference */: - case 162 /* ArrayType */: - case 163 /* TupleType */: - case 164 /* UnionType */: - case 165 /* IntersectionType */: - case 166 /* ParenthesizedType */: + case 151 /* Constructor */: + case 155 /* ConstructSignature */: + case 154 /* CallSignature */: + case 156 /* IndexSignature */: + case 145 /* Parameter */: + case 233 /* ModuleBlock */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 162 /* TypeLiteral */: + case 158 /* TypeReference */: + case 163 /* ArrayType */: + case 164 /* TupleType */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: + case 167 /* 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 236 /* ImportClause */: - case 237 /* NamespaceImport */: - case 239 /* ImportSpecifier */: + case 238 /* ImportClause */: + case 239 /* NamespaceImport */: + case 241 /* ImportSpecifier */: return false; // Type parameters are always visible - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: // Source file and namespace export are always visible - case 261 /* SourceFile */: - case 233 /* NamespaceExportDeclaration */: + case 264 /* SourceFile */: + case 235 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return false; default: return false; @@ -26721,10 +27461,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 240 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 242 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 243 /* ExportSpecifier */) { + else if (node.parent.kind === 245 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -26817,12 +27557,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 223 /* VariableDeclaration */: - case 224 /* VariableDeclarationList */: - case 239 /* ImportSpecifier */: - case 238 /* NamedImports */: - case 237 /* NamespaceImport */: - case 236 /* ImportClause */: + case 225 /* VariableDeclaration */: + case 226 /* VariableDeclarationList */: + case 241 /* ImportSpecifier */: + case 240 /* NamedImports */: + case 239 /* NamespaceImport */: + case 238 /* ImportClause */: node = node.parent; break; default: @@ -26846,9 +27586,6 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1 /* Any */) !== 0; } - function isTypeNever(type) { - return type && (type.flags & 8192 /* Never */) !== 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) { @@ -26856,7 +27593,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 142 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 143 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 6144 /* Nullable */); }); @@ -26869,17 +27606,16 @@ var ts; var members = ts.createMap(); var names = ts.createMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name_17 = properties_2[_i]; - names[ts.getTextOfPropertyName(name_17)] = true; + var name = properties_2[_i]; + names.set(ts.getTextOfPropertyName(name), true); } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - var inNamesToRemove = prop.name in names; + var inNamesToRemove = names.has(prop.name); var isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */); - var isMethod = prop.flags & 8192 /* Method */; var isSetOnlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { - members[prop.name] = prop; + if (!inNamesToRemove && !isPrivate && !isClassMethod(prop) && !isSetOnlyAccessor) { + members.set(prop.name, prop); } } var stringIndexInfo = getIndexInfoOfType(source, 0 /* String */); @@ -26904,7 +27640,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 172 /* ObjectBindingPattern */) { + if (pattern.kind === 173 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -26921,8 +27657,8 @@ var ts; } else { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) - var name_18 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_18)) { + var name = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name)) { // computed properties with non-literal names are treated as 'any' return anyType; } @@ -26931,12 +27667,12 @@ var ts; } // 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. - var text = ts.getTextOfPropertyName(name_18); + var text = ts.getTextOfPropertyName(name); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); if (!type) { - error(name_18, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_18)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); return unknownType; } } @@ -26976,7 +27712,7 @@ var ts; getUnionType([type, checkExpressionCached(declaration.initializer)], /*subtypeReduction*/ true) : type; } - function getTypeForVariableLikeDeclarationFromJSDocComment(declaration) { + function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); if (jsdocType) { return getTypeFromTypeNode(jsdocType); @@ -26989,29 +27725,38 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 175 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 176 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048 /* Undefined */) : type; } + /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ + function removeOptionalityFromAnnotation(annotatedType, declaration) { + var annotationIncludesUndefined = strictNullChecks && + declaration.kind === 145 /* Parameter */ && + declaration.initializer && + getFalsyFlags(annotatedType) & 2048 /* Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048 /* Undefined */); + return annotationIncludesUndefined ? getNonNullableType(annotatedType) : annotatedType; + } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { if (declaration.flags & 65536 /* JavaScriptFile */) { // If this is a variable in a JavaScript file, then use the JSDoc type (if it has // one as its type), otherwise fallback to the below standard TS codepaths to // try to figure it out. - var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); + var type = getTypeForDeclarationFromJSDocComment(declaration); if (type && type !== unknownType) { return type; } } // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (declaration.parent.parent.kind === 212 /* ForInStatement */) { + if (declaration.parent.parent.kind === 214 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 /* TypeParameter */ | 262144 /* Index */) ? indexType : stringType; } - if (declaration.parent.parent.kind === 213 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 215 /* 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, @@ -27023,10 +27768,11 @@ var ts; } // Use type from type annotation if one is present if (declaration.type) { - return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); + var declaredType = removeOptionalityFromAnnotation(getTypeFromTypeNode(declaration.type), declaration); + return addOptionality(declaredType, /*optional*/ declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536 /* JavaScriptFile */) && - declaration.kind === 223 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 225 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !ts.isInAmbientContext(declaration)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no @@ -27040,11 +27786,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 144 /* Parameter */) { + if (declaration.kind === 145 /* 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 === 152 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 151 /* GetAccessor */); + if (func.kind === 153 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 152 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -27073,8 +27819,13 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality); } + if (ts.isJsxAttribute(declaration)) { + // if JSX attribute doesn't have initializer, by default the attribute will have boolean value of true. + // I.e is sugar for + return trueType; + } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 258 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 261 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -27084,6 +27835,23 @@ var ts; // No type specified and nothing can be inferred return undefined; } + // Return the inferred type for a variable, parameter, or property declaration + function getTypeForJSSpecialPropertyDeclaration(declaration) { + var expression = declaration.kind === 193 /* BinaryExpression */ ? declaration : + declaration.kind === 178 /* PropertyAccessExpression */ ? ts.getAncestor(declaration, 193 /* BinaryExpression */) : + undefined; + if (!expression) { + return unknownType; + } + if (expression.flags & 65536 /* JavaScriptFile */) { + // If there is a JSDoc type, use it + var type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type && type !== unknownType) { + return getWidenedType(type); + } + } + return getWidenedLiteralType(checkExpressionCached(expression.right)); + } // 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. @@ -27116,11 +27884,11 @@ var ts; return; } var text = ts.getTextOfPropertyName(name); - var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0); + var flags = 4 /* Property */ | (e.initializer ? 67108864 /* Optional */ : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; - members[symbol.name] = symbol; + members.set(symbol.name, symbol); }); var result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); if (includePatternInType) { @@ -27155,7 +27923,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 172 /* ObjectBindingPattern */ + return pattern.kind === 173 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -27177,7 +27945,7 @@ 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. - if (declaration.kind === 257 /* PropertyAssignment */) { + if (declaration.kind === 260 /* PropertyAssignment */) { return type; } return getWidenedType(type); @@ -27194,14 +27962,14 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 144 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 145 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { // Handle prototype property - if (symbol.flags & 134217728 /* Prototype */) { + if (symbol.flags & 16777216 /* Prototype */) { return links.type = getTypeOfPrototypeProperty(symbol); } // Handle catch clause variables @@ -27210,10 +27978,10 @@ var ts; return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 240 /* ExportAssignment */) { + if (declaration.kind === 242 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 286 /* JSDocPropertyTag */ && declaration.typeExpression) { + if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 290 /* JSDocPropertyTag */ && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } // Handle variable, parameter or property @@ -27226,19 +27994,9 @@ var ts; // * exports.p = expr // * this.p = expr // * className.prototype.method = expr - if (declaration.kind === 192 /* BinaryExpression */ || - declaration.kind === 177 /* PropertyAccessExpression */ && declaration.parent.kind === 192 /* BinaryExpression */) { - // Use JS Doc type if present on parent expression statement - if (declaration.flags & 65536 /* JavaScriptFile */) { - var jsdocType = ts.getJSDocType(declaration.parent); - if (jsdocType) { - return links.type = getTypeFromTypeNode(jsdocType); - } - } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 192 /* BinaryExpression */ ? - checkExpressionCached(decl.right) : - checkExpressionCached(decl.parent.right); }); - type = getUnionType(declaredTypes, /*subtypeReduction*/ true); + if (declaration.kind === 193 /* BinaryExpression */ || + declaration.kind === 178 /* PropertyAccessExpression */ && declaration.parent.kind === 193 /* BinaryExpression */) { + type = getWidenedType(getUnionType(ts.map(symbol.declarations, getTypeForJSSpecialPropertyDeclaration), /*subtypeReduction*/ true)); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); @@ -27252,7 +28010,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 151 /* GetAccessor */) { + if (accessor.kind === 152 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -27272,10 +28030,10 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 151 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 152 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 152 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 153 /* SetAccessor */); if (getter && getter.flags & 65536 /* JavaScriptFile */) { - var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); + var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; } @@ -27317,7 +28075,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 151 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 152 /* 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)); } } @@ -27325,6 +28083,10 @@ var ts; } return links.type; } + function getBaseTypeVariableOfClass(symbol) { + var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); + return baseConstructorType.flags & 540672 /* TypeVariable */ ? baseConstructorType : undefined; + } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { @@ -27333,8 +28095,13 @@ var ts; } else { var type = createObjectType(16 /* Anonymous */, symbol); - links.type = strictNullChecks && symbol.flags & 536870912 /* Optional */ ? - includeFalsyTypes(type, 2048 /* Undefined */) : type; + if (symbol.flags & 32 /* Class */) { + var baseTypeVariable = getBaseTypeVariableOfClass(symbol); + links.type = baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; + } + else { + links.type = strictNullChecks && symbol.flags & 67108864 /* Optional */ ? includeFalsyTypes(type, 2048 /* Undefined */) : type; + } } } return links.type; @@ -27388,7 +28155,7 @@ var ts; return anyType; } function getTypeOfSymbol(symbol) { - if (symbol.flags & 16777216 /* Instantiated */) { + if (getCheckFlags(symbol) & 1 /* Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { @@ -27414,16 +28181,21 @@ var ts; function hasBaseType(type, checkBase) { return check(type); function check(type) { - var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); + if (getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + var target = getTargetType(type); + return target === checkBase || ts.forEach(getBaseTypes(target), check); + } + else if (type.flags & 131072 /* Intersection */) { + return ts.forEach(type.types, 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, declarations_2 = declarations; _i < declarations_2.length; _i++) { - var declaration = declarations_2[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -27443,9 +28215,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 226 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */ || - node.kind === 225 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */ || - node.kind === 149 /* MethodDeclaration */ || node.kind === 185 /* ArrowFunction */) { + if (node.kind === 228 /* ClassDeclaration */ || node.kind === 198 /* ClassExpression */ || + node.kind === 227 /* FunctionDeclaration */ || node.kind === 185 /* FunctionExpression */ || + node.kind === 150 /* MethodDeclaration */ || node.kind === 186 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -27455,7 +28227,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, 227 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 229 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -27464,8 +28236,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 227 /* InterfaceDeclaration */ || node.kind === 226 /* ClassDeclaration */ || - node.kind === 197 /* ClassExpression */ || node.kind === 228 /* TypeAliasDeclaration */) { + if (node.kind === 229 /* InterfaceDeclaration */ || node.kind === 228 /* ClassDeclaration */ || + node.kind === 198 /* ClassExpression */ || node.kind === 230 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -27479,15 +28251,32 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } + // A type is a mixin constructor if it has a single construct signature taking no type parameters and a single + // rest parameter of type any[]. + function isMixinConstructorType(type) { + var signatures = getSignaturesOfType(type, 1 /* Construct */); + if (signatures.length === 1) { + var s = signatures[0]; + return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + } + return false; + } function isConstructorType(type) { - return type.flags & 32768 /* Object */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; + if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { + return true; + } + if (type.flags & 540672 /* TypeVariable */) { + var constraint = getBaseConstraintOfType(type); + return isValidBaseType(constraint) && isMixinConstructorType(constraint); + } + return false; } 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; }); + var typeArgCount = ts.length(typeArgumentNodes); + return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); @@ -27497,11 +28286,13 @@ var ts; } 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. + /** + * 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); @@ -27512,7 +28303,7 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 32768 /* Object */) { + if (baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */)) { // 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); @@ -27550,8 +28341,8 @@ var ts; } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - var baseConstructorType = getBaseConstructorTypeOfClass(type); - if (!(baseConstructorType.flags & 32768 /* Object */)) { + var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); + if (!(baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */))) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -27586,7 +28377,7 @@ var ts; if (baseType === unknownType) { return; } - if (!(getObjectFlags(getTargetType(baseType)) & 3 /* ClassOrInterface */)) { + if (!isValidBaseType(baseType)) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } @@ -27612,16 +28403,22 @@ var ts; } return true; } + // A valid base type is any non-generic object type or intersection of non-generic + // object types. + function isValidBaseType(type) { + return type.flags & (32768 /* Object */ | 16777216 /* NonPrimitive */) && !isGenericMappedType(type) || + type.flags & 131072 /* Intersection */ && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); + } 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 === 227 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 229 /* 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 (getObjectFlags(getTargetType(baseType)) & 3 /* ClassOrInterface */) { + if (isValidBaseType(baseType)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; @@ -27648,7 +28445,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 /* InterfaceDeclaration */) { + if (declaration.kind === 229 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -27686,7 +28483,7 @@ var ts; type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384 /* TypeParameter */); @@ -27705,7 +28502,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 285 /* JSDocTypedefTag */); + var declaration = ts.getDeclarationOfKind(symbol, 289 /* JSDocTypedefTag */); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -27716,7 +28513,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 228 /* TypeAliasDeclaration */); + declaration = ts.getDeclarationOfKind(symbol, 230 /* TypeAliasDeclaration */); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -27726,7 +28523,7 @@ var ts; // an instantiation of the type alias with the type parameters supplied as type arguments. links.typeParameters = typeParameters; links.instantiations = ts.createMap(); - links.instantiations[getTypeListId(typeParameters)] = type; + links.instantiations.set(getTypeListId(typeParameters), type); } } else { @@ -27743,14 +28540,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 /* NumericLiteral */ || - expr.kind === 190 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && + expr.kind === 191 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */ || - expr.kind === 70 /* Identifier */ && !!symbol.exports[expr.text]; + expr.kind === 70 /* Identifier */ && !!symbol.exports.get(expr.text); } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 /* EnumDeclaration */) { + if (declaration.kind === 231 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -27775,10 +28572,10 @@ var ts; enumType.symbol = symbol; if (enumHasLiteralMembers(symbol)) { var memberTypeList = []; - var memberTypes = ts.createMap(); + var memberTypes = []; for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 /* EnumDeclaration */) { + if (declaration.kind === 231 /* EnumDeclaration */) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -27795,7 +28592,7 @@ var ts; if (memberTypeList.length > 1) { enumType.flags |= 65536 /* Union */; enumType.types = memberTypeList; - unionTypes[getTypeListId(memberTypeList)] = enumType; + unionTypes.set(getTypeListId(memberTypeList), enumType); } } } @@ -27816,9 +28613,6 @@ var ts; if (!links.declaredType) { var type = createType(16384 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 143 /* TypeParameter */).constraint) { - type.constraint = noConstraintType; - } links.declaredType = type; } return links.declaredType; @@ -27831,7 +28625,6 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0); if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { return getDeclaredTypeOfClassOrInterface(symbol); } @@ -27870,19 +28663,20 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: + case 133 /* ObjectKeyword */: case 104 /* VoidKeyword */: - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: case 94 /* NullKeyword */: case 129 /* NeverKeyword */: - case 171 /* LiteralType */: + case 172 /* LiteralType */: return true; - case 162 /* ArrayType */: + case 163 /* ArrayType */: return isIndependentType(node.elementType); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return isIndependentTypeReference(node); } return false; @@ -27895,7 +28689,7 @@ var ts; // A function-like declaration is considered independent (free of this references) if it has a return type // annotation that is considered independent and if each parameter is considered independent. function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 150 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 151 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -27916,12 +28710,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return isIndependentVariableLikeDeclaration(declaration); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -27932,7 +28726,7 @@ var ts; var result = ts.createMap(); for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { var symbol = symbols_1[_i]; - result[symbol.name] = symbol; + result.set(symbol.name, symbol); } return result; } @@ -27942,15 +28736,15 @@ var ts; var result = ts.createMap(); 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); + result.set(symbol.name, mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; } function addInheritedMembers(symbols, baseSymbols) { for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) { var s = baseSymbols_1[_i]; - if (!symbols[s.name]) { - symbols[s.name] = s; + if (!symbols.has(s.name)) { + symbols.set(s.name, s); } } } @@ -27958,8 +28752,8 @@ var ts; 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.declaredCallSignatures = getSignaturesOfSymbol(symbol.members.get("__call")); + type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members.get("__new")); type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0 /* String */); type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1 /* Number */); } @@ -27967,7 +28761,14 @@ var ts; } function getTypeWithThisArgument(type, thisArgument) { if (getObjectFlags(type) & 4 /* Reference */) { - return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + var target = type.target; + var typeArguments = type.typeArguments; + if (ts.length(target.typeParameters) === ts.length(typeArguments)) { + return createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); + } + } + else if (type.flags & 131072 /* Intersection */) { + return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument); })); } return type; } @@ -28003,7 +28804,7 @@ var ts; 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)); + addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0 /* String */); @@ -28046,13 +28847,14 @@ var ts; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); - var typeArgCount = typeArguments ? typeArguments.length : 0; + var typeArgCount = ts.length(typeArguments); var result = []; for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { var baseSig = baseSignatures_1[_i]; - var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; - if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); + var typeParamCount = ts.length(baseSig.typeParameters); + if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) { + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -28115,7 +28917,7 @@ var ts; s = cloneSignature(signature); if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) { var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return getTypeOfSymbol(sig.thisParameter) || anyType; }), /*subtypeReduction*/ true); - s.thisParameter = createTransientSymbol(signature.thisParameter, thisType); + s.thisParameter = createSymbolWithType(signature.thisParameter, thisType); } // Clear resolved return type we possibly got from cloneSignature s.resolvedReturnType = undefined; @@ -28160,22 +28962,57 @@ var ts; function unionSpreadIndexInfos(info1, info2) { return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly); } + function includeMixinType(type, types, index) { + var mixedTypes = []; + for (var i = 0; i < types.length; i++) { + if (i === index) { + mixedTypes.push(type); + } + else if (isMixinConstructorType(types[i])) { + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* Construct */)[0])); + } + } + return getIntersectionType(mixedTypes); + } 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 stringIndexInfo = undefined; - var numberIndexInfo = undefined; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + var stringIndexInfo; + var numberIndexInfo; + var types = type.types; + var mixinCount = ts.countWhere(types, isMixinConstructorType); + var _loop_3 = function (i) { + var t = type.types[i]; + // When an intersection type contains mixin constructor types, the construct signatures from + // those types are discarded and their return types are mixed into the return types of all + // other construct signatures in the intersection type. For example, the intersection type + // '{ new(...args: any[]) => A } & { new(s: string) => B }' has a single construct signature + // 'new(s: string) => A & B'. + if (mixinCount === 0 || mixinCount === types.length && i === 0 || !isMixinConstructorType(t)) { + var signatures = getSignaturesOfType(t, 1 /* Construct */); + if (signatures.length && mixinCount > 0) { + signatures = ts.map(signatures, function (s) { + var clone = cloneSignature(s); + clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, i); + return clone; + }); + } + constructSignatures = ts.concatenate(constructSignatures, signatures); + } callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1 /* Construct */)); stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0 /* String */)); numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); + }; + for (var i = 0; i < types.length; i++) { + _loop_3(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } + /** + * Converts an AnonymousType to a ResolvedType. + */ function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; if (type.target) { @@ -28188,8 +29025,8 @@ var ts; } else if (symbol.flags & 2048 /* TypeLiteral */) { var members = symbol.members; - var callSignatures = getSignaturesOfSymbol(members["__call"]); - var constructSignatures = getSignaturesOfSymbol(members["__new"]); + var callSignatures = getSignaturesOfSymbol(members.get("__call")); + var constructSignatures = getSignaturesOfSymbol(members.get("__new")); var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0 /* String */); var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1 /* Number */); setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -28203,14 +29040,14 @@ var ts; } if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); + constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 32768 /* Object */) { + if (baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */ | 540672 /* TypeVariable */)) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); + addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } } var numberIndexInfo = symbol.flags & 384 /* Enum */ ? enumNumberIndexInfo : undefined; @@ -28235,12 +29072,15 @@ var ts; var typeParameter = getTypeParameterFromMappedType(type); var constraintType = getConstraintTypeFromMappedType(type); var templateType = getTemplateTypeFromMappedType(type); - var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); + var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateReadonly = !!type.declaration.readonlyToken; var templateOptional = !!type.declaration.questionToken; - if (type.declaration.typeParameter.constraint.kind === 168 /* TypeOperator */) { + if (type.declaration.typeParameter.constraint.kind === 169 /* TypeOperator */) { // We have a { [P in keyof T]: X } - forEachType(getLiteralTypeFromPropertyNames(modifiersType), addMemberForKeyType); + for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { + var propertySymbol = _a[_i]; + addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol); + } if (getIndexInfoOfType(modifiersType, 0 /* String */)) { addMemberForKeyType(stringType); } @@ -28254,11 +29094,11 @@ var ts; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, undefined); - function addMemberForKeyType(t) { + function addMemberForKeyType(t, propertySymbol) { // Create a mapper from T to the current iteration type constituent. Then, if the // mapped type is itself an instantiated type, combine the iteration mapper with the // instantiation mapper. - var iterationMapper = createUnaryTypeMapper(typeParameter, t); + var iterationMapper = createTypeMapper([typeParameter], [t]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; var propType = instantiateType(templateType, templateMapper); // If the current iteration type constituent is a string literal type, create a property. @@ -28266,11 +29106,14 @@ var ts; if (t.flags & 32 /* StringLiteral */) { var propName = t.text; var modifiersProp = getPropertyOfType(modifiersType, propName); - var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 536870912 /* Optional */); - var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | (isOptional ? 536870912 /* Optional */ : 0), propName); + var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 67108864 /* Optional */); + var prop = createSymbol(4 /* Property */ | (isOptional ? 67108864 /* Optional */ : 0), propName); + prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 4 /* Readonly */ : 0; prop.type = propType; - prop.isReadonly = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp); - members[propName] = prop; + if (propertySymbol) { + prop.mappedTypeOrigin = propertySymbol; + } + members.set(propName, prop); } else if (t.flags & 2 /* String */) { stringIndexInfo = createIndexInfo(propType, templateReadonly); @@ -28294,7 +29137,7 @@ var ts; function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { var constraintDeclaration = type.declaration.typeParameter.constraint; - if (constraintDeclaration.kind === 168 /* TypeOperator */) { + if (constraintDeclaration.kind === 169 /* TypeOperator */) { // If the constraint declaration is a 'keyof T' node, the modifiers type is T. We check // AST nodes here because, when T is a non-generic type, the logic below eagerly resolves // 'keyof T' to a literal union type and we can't recover T from that type. @@ -28306,15 +29149,12 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is {}. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint.flags & 262144 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 262144 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; } - function getErasedTemplateTypeFromMappedType(type) { - return instantiateType(getTemplateTypeFromMappedType(type), createUnaryTypeMapper(getTypeParameterFromMappedType(type), anyType)); - } function isGenericMappedType(type) { if (getObjectFlags(type) & 32 /* Mapped */) { var constraintType = getConstraintTypeFromMappedType(type); @@ -28359,38 +29199,35 @@ var ts; function getPropertyOfObjectType(type, name) { if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && 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]; - getUnionOrIntersectionProperty(type, prop.name); - } - // The properties of a union type are those that are present in all constituent types, so - // we only need to check the properties of the first type - if (type.flags & 65536 /* Union */) { - break; - } - } - var props = type.resolvedProperties; - if (props) { - var result = []; - for (var key in props) { - var prop = props[key]; - // We need to filter out partial properties in union types - if (!(prop.flags & 268435456 /* SyntheticProperty */ && prop.isPartial)) { - result.push(prop); + if (!type.resolvedProperties) { + var members = ts.createMap(); + 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]; + if (!members.has(prop.name)) { + var combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.name); + if (combinedProp) { + members.set(prop.name, combinedProp); + } + } + } + // 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 & 65536 /* Union */) { + break; } } - return result; + type.resolvedProperties = getNamedMembers(members); } - return emptyArray; + return type.resolvedProperties; } function getPropertiesOfType(type) { type = getApparentType(type); @@ -28398,19 +29235,99 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } + function getConstraintOfType(type) { + return type.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + } + function getConstraintOfTypeParameter(typeParameter) { + return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; + } + function getBaseConstraintOfType(type) { + var constraint = getResolvedBaseConstraint(type); + return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + } + function hasNonCircularBaseConstraint(type) { + return getResolvedBaseConstraint(type) !== circularConstraintType; + } /** - * The apparent type of a type parameter is the base constraint instantiated with the type parameter - * as the type argument for the 'this' type. + * Return the resolved base constraint of a type variable. The noConstraintType singleton is returned if the + * type variable has no constraint, and the circularConstraintType singleton is returned if the constraint + * circularly references the type variable. */ - function getApparentTypeOfTypeVariable(type) { - if (!type.resolvedApparentType) { - var constraintType = getConstraintOfTypeVariable(type); - while (constraintType && constraintType.flags & 16384 /* TypeParameter */) { - constraintType = getConstraintOfTypeVariable(constraintType); - } - type.resolvedApparentType = getTypeWithThisArgument(constraintType || emptyObjectType, type); + function getResolvedBaseConstraint(type) { + var typeStack; + var circular; + if (!type.resolvedBaseConstraint) { + typeStack = []; + var constraint = getBaseConstraint(type); + type.resolvedBaseConstraint = circular ? circularConstraintType : getTypeWithThisArgument(constraint || noConstraintType, type); } - return type.resolvedApparentType; + return type.resolvedBaseConstraint; + function getBaseConstraint(t) { + if (ts.contains(typeStack, t)) { + circular = true; + return undefined; + } + typeStack.push(t); + var result = computeBaseConstraint(t); + typeStack.pop(); + return result; + } + function computeBaseConstraint(t) { + if (t.flags & 16384 /* TypeParameter */) { + var constraint = getConstraintFromTypeParameter(t); + return t.isThisType ? constraint : + constraint ? getBaseConstraint(constraint) : undefined; + } + if (t.flags & 196608 /* UnionOrIntersection */) { + var types = t.types; + var baseTypes = []; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var type_1 = types_2[_i]; + var baseType = getBaseConstraint(type_1); + if (baseType) { + baseTypes.push(baseType); + } + } + return t.flags & 65536 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 131072 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + undefined; + } + if (t.flags & 262144 /* Index */) { + return stringType; + } + if (t.flags & 524288 /* IndexedAccess */) { + var baseObjectType = getBaseConstraint(t.objectType); + var baseIndexType = getBaseConstraint(t.indexType); + var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; + return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + } + return t; + } + } + function getApparentTypeOfIntersectionType(type) { + return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type)); + } + /** + * Gets the default type for a type parameter. + * + * If the type parameter is the result of an instantiation, this gets the instantiated + * default type of its target. If the type parameter has no default type, `undefined` + * is returned. + * + * This function *does not* perform a circularity check. + */ + function getDefaultFromTypeParameter(typeParameter) { + if (!typeParameter.default) { + if (typeParameter.target) { + var targetDefault = getDefaultFromTypeParameter(typeParameter.target); + typeParameter.default = targetDefault ? instantiateType(targetDefault, typeParameter.mapper) : noConstraintType; + } + else { + var defaultDeclaration = typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameter(decl) && decl.default; }); + typeParameter.default = defaultDeclaration ? getTypeFromTypeNode(defaultDeclaration) : noConstraintType; + } + } + return typeParameter.default === noConstraintType ? undefined : typeParameter.default; } /** * For a type parameter, return the base constraint of the type parameter. For the string, number, @@ -28418,26 +29335,30 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - var t = type.flags & 540672 /* TypeVariable */ ? getApparentTypeOfTypeVariable(type) : type; - return t.flags & 262178 /* StringLike */ ? globalStringType : - t.flags & 340 /* NumberLike */ ? globalNumberType : - t.flags & 136 /* BooleanLike */ ? globalBooleanType : - t.flags & 512 /* ESSymbol */ ? getGlobalESSymbolType() : - t; + var t = type.flags & 540672 /* TypeVariable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; + return t.flags & 131072 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 262178 /* StringLike */ ? globalStringType : + t.flags & 340 /* NumberLike */ ? globalNumberType : + t.flags & 136 /* BooleanLike */ ? globalBooleanType : + t.flags & 512 /* ESSymbol */ ? getGlobalESSymbolType() : + t.flags & 16777216 /* NonPrimitive */ ? emptyObjectType : + t; } function createUnionOrIntersectionProperty(containingType, name) { - var types = containingType.types; var props; + var types = containingType.types; + var isUnion = containingType.flags & 65536 /* Union */; + var excludeModifiers = isUnion ? 24 /* NonPublicAccessibilityModifier */ : 0; // Flags we want to propagate to the result if they exist in all source symbols - var commonFlags = (containingType.flags & 131072 /* Intersection */) ? 536870912 /* Optional */ : 0 /* None */; - var isReadonly = false; - var isPartial = false; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var current = types_2[_i]; + var commonFlags = isUnion ? 0 /* None */ : 67108864 /* Optional */; + var checkFlags = 2 /* SyntheticProperty */; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var current = types_3[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */))) { + var modifiers = prop ? getDeclarationModifierFlagsFromSymbol(prop) : 0; + if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; if (!props) { props = [prop]; @@ -28445,25 +29366,26 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } - if (isReadonlySymbol(prop)) { - isReadonly = true; - } + checkFlags |= (isReadonlySymbol(prop) ? 4 /* Readonly */ : 0) | + (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 32 /* ContainsPublic */ : 0) | + (modifiers & 16 /* Protected */ ? 64 /* ContainsProtected */ : 0) | + (modifiers & 8 /* Private */ ? 128 /* ContainsPrivate */ : 0) | + (modifiers & 32 /* Static */ ? 256 /* ContainsStatic */ : 0); } - else if (containingType.flags & 65536 /* Union */) { - isPartial = true; + else if (isUnion) { + checkFlags |= 8 /* Partial */; } } } if (!props) { return undefined; } - if (props.length === 1 && !isPartial) { + if (props.length === 1 && !(checkFlags & 8 /* Partial */)) { return props[0]; } var propTypes = []; var declarations = []; var commonType = undefined; - var hasNonUniformType = false; for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { var prop = props_1[_a]; if (prop.declarations) { @@ -28474,17 +29396,15 @@ var ts; commonType = type; } else if (type !== commonType) { - hasNonUniformType = true; + checkFlags |= 16 /* HasNonUniformType */; } propTypes.push(type); } - var result = createSymbol(4 /* Property */ | 67108864 /* Transient */ | 268435456 /* SyntheticProperty */ | commonFlags, name); + var result = createSymbol(4 /* Property */ | commonFlags, name); + result.checkFlags = checkFlags; result.containingType = containingType; - result.hasNonUniformType = hasNonUniformType; - result.isPartial = isPartial; result.declarations = declarations; - result.isReadonly = isReadonly; - result.type = containingType.flags & 65536 /* Union */ ? getUnionType(propTypes) : getIntersectionType(propTypes); + result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } // Return the symbol for a given property in a union or intersection type, or undefined if the property @@ -28493,12 +29413,12 @@ var ts; // these partial properties when identifying discriminant properties, but otherwise they are filtered out // and do not appear to be present in the union type. function getUnionOrIntersectionProperty(type, name) { - var properties = type.resolvedProperties || (type.resolvedProperties = ts.createMap()); - var property = properties[name]; + var properties = type.propertyCache || (type.propertyCache = ts.createMap()); + var property = properties.get(name); if (!property) { property = createUnionOrIntersectionProperty(type, name); if (property) { - properties[name] = property; + properties.set(name, property); } } return property; @@ -28506,7 +29426,7 @@ var ts; function getPropertyOfUnionOrIntersectionType(type, name) { var property = getUnionOrIntersectionProperty(type, name); // We need to filter out partial properties in union types - return property && !(property.flags & 268435456 /* SyntheticProperty */ && property.isPartial) ? property : undefined; + return property && !(getCheckFlags(property) & 8 /* Partial */) ? property : undefined; } /** * Return the symbol for the property with the given name in the given type. Creates synthetic union properties when @@ -28520,7 +29440,7 @@ var ts; type = getApparentType(type); if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } @@ -28609,16 +29529,16 @@ var ts; } function symbolsToArray(symbols) { var result = []; - for (var id in symbols) { + symbols.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { - result.push(symbols[id]); + result.push(symbol); } - } + }); return result; } function isJSDocOptionalParameter(node) { if (node.flags & 65536 /* JavaScriptFile */) { - if (node.type && node.type.kind === 273 /* JSDocOptionalType */) { + if (node.type && node.type.kind === 277 /* JSDocOptionalType */) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -28629,7 +29549,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 273 /* JSDocOptionalType */; + return paramTag.typeExpression.type.kind === 277 /* JSDocOptionalType */; } } } @@ -28654,6 +29574,12 @@ var ts; ts.Debug.assert(parameterIndex >= 0); return parameterIndex >= signature.minArgumentCount; } + var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); + if (iife) { + return !node.type && + !node.dotDotDotToken && + ts.indexOf(node.parent.parameters, node) >= iife.arguments.length; + } return false; } function createTypePredicateFromTypePredicateNode(node) { @@ -28673,19 +29599,67 @@ var ts; }; } } + /** + * Gets the minimum number of type arguments needed to satisfy all non-optional type + * parameters. + */ + function getMinTypeArgumentCount(typeParameters) { + var minTypeArgumentCount = 0; + if (typeParameters) { + for (var i = 0; i < typeParameters.length; i++) { + if (!getDefaultFromTypeParameter(typeParameters[i])) { + minTypeArgumentCount = i + 1; + } + } + } + return minTypeArgumentCount; + } + /** + * Fill in default types for unsupplied type arguments. If `typeArguments` is undefined + * when a default type is supplied, a new array will be created and returned. + * + * @param typeArguments The supplied type arguments. + * @param typeParameters The requested type parameters. + * @param minTypeArgumentCount The minimum number of required type arguments. + */ + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount) { + var numTypeParameters = ts.length(typeParameters); + if (numTypeParameters) { + var numTypeArguments = ts.length(typeArguments); + if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) { + if (!typeArguments) { + typeArguments = []; + } + // Map an unsatisfied type parameter with a default type. + // If a type parameter does not have a default type, or if the default type + // is a forward reference, the empty object type is used. + for (var i = numTypeArguments; i < numTypeParameters; i++) { + typeArguments[i] = emptyObjectType; + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + var mapper = createTypeMapper(typeParameters, typeArguments); + var defaultType = getDefaultFromTypeParameter(typeParameters[i]); + typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType; + } + } + } + return typeArguments; + } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; var hasLiteralTypes = false; - var minArgumentCount = -1; + var minArgumentCount = 0; var thisParameter = undefined; var hasThisParameter = void 0; + var iife = ts.getImmediatelyInvokedFunctionExpression(declaration); var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); + var isUntypedSignatureInJSFile = !iife && !isJSConstructSignature && ts.isInJavaScriptFile(declaration) && !ts.hasJSDocParameterTags(declaration); // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct // signature. - for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { + for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; // Include parameter symbol instead of property symbol in the signature @@ -28700,43 +29674,36 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 171 /* LiteralType */) { + if (param.type && param.type.kind === 172 /* LiteralType */) { hasLiteralTypes = true; } - if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { - if (minArgumentCount < 0) { - minArgumentCount = i - (hasThisParameter ? 1 : 0); - } - } - else { - // If we see any required parameters, it means the prior ones were not in fact optional. - minArgumentCount = -1; + // Record a new minimum argument count if this is not an optional parameter + var isOptionalParameter_1 = param.initializer || param.questionToken || param.dotDotDotToken || + iife && parameters.length > iife.arguments.length && !param.type || + isJSDocOptionalParameter(param) || + isUntypedSignatureInJSFile; + if (!isOptionalParameter_1) { + minArgumentCount = parameters.length; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 151 /* GetAccessor */ || declaration.kind === 152 /* SetAccessor */) && + if ((declaration.kind === 152 /* GetAccessor */ || declaration.kind === 153 /* SetAccessor */) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 151 /* GetAccessor */ ? 152 /* SetAccessor */ : 151 /* GetAccessor */; + var otherKind = declaration.kind === 152 /* GetAccessor */ ? 153 /* SetAccessor */ : 152 /* GetAccessor */; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); - } - if (isJSConstructSignature) { - minArgumentCount--; - } - var classType = declaration.kind === 150 /* Constructor */ ? + var classType = declaration.kind === 151 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 156 /* TypePredicate */ ? + var typePredicate = declaration.type && declaration.type.kind === 157 /* TypePredicate */ ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -28761,8 +29728,8 @@ var ts; } // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 151 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 152 /* SetAccessor */); + if (declaration.kind === 152 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 153 /* SetAccessor */); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -28773,23 +29740,23 @@ var ts; if (!symbol) return emptyArray; var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { + for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 225 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 274 /* JSDocFunctionType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 278 /* JSDocFunctionType */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -28860,9 +29827,14 @@ var ts; return anyType; } function getSignatureInstantiation(signature, typeArguments) { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); - return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments)); + var instantiation = instantiations.get(id); + if (!instantiation) { + instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments)); + } + return instantiation; } function createSignatureInstantiation(signature, typeArguments) { return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), /*eraseTypeParameters*/ true); @@ -28881,7 +29853,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 === 150 /* Constructor */ || signature.declaration.kind === 154 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 151 /* Constructor */ || signature.declaration.kind === 155 /* ConstructSignature */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = emptyArray; @@ -28892,10 +29864,10 @@ var ts; return signature.isolatedSignatureType; } function getIndexSymbol(symbol) { - return symbol.members["__index"]; + return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 132 /* NumberKeyword */ : 134 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 132 /* NumberKeyword */ : 135 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -28922,21 +29894,9 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 143 /* TypeParameter */).constraint; + return ts.getDeclarationOfKind(type.symbol, 144 /* TypeParameter */).constraint; } - function hasConstraintReferenceTo(type, target) { - var checked; - while (type && type.flags & 16384 /* TypeParameter */ && !(type.isThisType) && !ts.contains(checked, type)) { - if (type === target) { - return true; - } - (checked || (checked = [])).push(type); - var constraintDeclaration = getConstraintDeclaration(type); - type = constraintDeclaration && getTypeFromTypeNode(constraintDeclaration); - } - return false; - } - function getConstraintOfTypeParameter(typeParameter) { + function getConstraintFromTypeParameter(typeParameter) { if (!typeParameter.constraint) { if (typeParameter.target) { var targetConstraint = getConstraintOfTypeParameter(typeParameter.target); @@ -28944,23 +29904,13 @@ var ts; } else { var constraintDeclaration = getConstraintDeclaration(typeParameter); - var constraint = getTypeFromTypeNode(constraintDeclaration); - if (hasConstraintReferenceTo(constraint, typeParameter)) { - error(constraintDeclaration, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); - constraint = unknownType; - } - typeParameter.constraint = constraint; + typeParameter.constraint = constraintDeclaration ? getTypeFromTypeNode(constraintDeclaration) : noConstraintType; } } return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } - function getConstraintOfTypeVariable(type) { - return type.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 524288 /* IndexedAccess */ ? type.constraint : - undefined; - } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 143 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 144 /* TypeParameter */).parent); } function getTypeListId(types) { var result = ""; @@ -28991,8 +29941,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var type = types_3[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -29001,9 +29951,10 @@ var ts; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); - var type = target.instantiations[id]; + var type = target.instantiations.get(id); if (!type) { - type = target.instantiations[id] = createObjectType(4 /* Reference */, target.symbol); + type = createObjectType(4 /* Reference */, target.symbol); + target.instantiations.set(id, type); type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; type.typeArguments = typeArguments; @@ -29019,21 +29970,26 @@ var ts; return type; } function getTypeReferenceArity(type) { - return type.target.typeParameters ? type.target.typeParameters.length : 0; + return ts.length(type.target.typeParameters); } // Get type from reference to class or interface function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(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); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), minTypeArgumentCount, 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))); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount)); + return createTypeReference(type, typeArguments); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); @@ -29046,7 +30002,11 @@ var ts; var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + var instantiation = links.instantiations.get(id); + if (!instantiation) { + links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + } + return instantiation; } // 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 @@ -29055,8 +30015,12 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).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); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return unknownType; } var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); @@ -29078,11 +30042,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 157 /* TypeReference */: + case 158 /* TypeReference */: return node.typeName; - case 272 /* JSDocTypeReference */: + case 276 /* JSDocTypeReference */: return node.name; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -29108,7 +30072,7 @@ var ts; if (symbol.flags & 524288 /* TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 /* Value */ && node.kind === 272 /* JSDocTypeReference */) { + if (symbol.flags & 107455 /* Value */ && node.kind === 276 /* JSDocTypeReference */) { // A JSDocTypeReference may have resolved to a value (as opposed to a type). In // that case, the type of this reference is just the type of the value we resolved // to. @@ -29121,14 +30085,14 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 272 /* JSDocTypeReference */) { + if (node.kind === 276 /* JSDocTypeReference */) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 157 /* TypeReference */ + var typeNameOrExpression = node.kind === 158 /* TypeReference */ ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -29160,12 +30124,12 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var declaration = declarations_4[_i]; switch (declaration.kind) { - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: return declaration; } } @@ -29178,7 +30142,7 @@ var ts; 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) { + if (ts.length(type.typeParameters) !== arity) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); return arity ? emptyGenericType : emptyObjectType; } @@ -29250,7 +30214,7 @@ var ts; for (var i = 0; i < arity; i++) { var typeParameter = createType(16384 /* TypeParameter */); typeParameters.push(typeParameter); - var property = createSymbol(4 /* Property */ | 67108864 /* Transient */, "" + i); + var property = createSymbol(4 /* Property */, "" + i); property.type = typeParameter; properties.push(property); } @@ -29259,7 +30223,7 @@ var ts; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384 /* TypeParameter */); @@ -29343,14 +30307,14 @@ 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 addTypesToUnion(typeSet, types) { - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var t = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var t = types_6[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -29358,8 +30322,9 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; + if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } } @@ -29445,10 +30410,11 @@ var ts; return types[0]; } var id = getTypeListId(types); - var type = unionTypes[id]; + var type = unionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 6144 /* Nullable */); - type = unionTypes[id] = createType(65536 /* Union */ | propagatedFlags); + type = createType(65536 /* Union */ | propagatedFlags); + unionTypes.set(id, type); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -29473,14 +30439,17 @@ var ts; if (type.flags & 65536 /* Union */ && typeSet.unionIndex === undefined) { typeSet.unionIndex = typeSet.length; } - typeSet.push(type); + if (!(type.flags & 32768 /* Object */ && type.objectFlags & 16 /* Anonymous */ && + type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */) && containsIdenticalType(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 addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; addTypeToIntersection(typeSet, type); } } @@ -29515,10 +30484,11 @@ var ts; /*subtypeReduction*/ false, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); - var type = intersectionTypes[id]; + var type = intersectionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 6144 /* Nullable */); - type = intersectionTypes[id] = createType(131072 /* Intersection */ | propagatedFlags); + type = createType(131072 /* Intersection */ | propagatedFlags); + intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -29568,28 +30538,10 @@ var ts; var type = createType(524288 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; - // We eagerly compute the constraint of the indexed access type such that circularity - // errors are immediately caught and reported. For example, class C { x: this["x"] } - // becomes an error only when the constraint is eagerly computed. - if (type.objectType.flags & 229376 /* StructuredType */) { - // The constraint of T[K], where T is an object, union, or intersection type, - // is the type of the string index signature of T, if any. - type.constraint = getIndexTypeOfType(type.objectType, 0 /* String */); - } - else if (type.objectType.flags & 540672 /* TypeVariable */) { - // The constraint of T[K], where T is a type variable, is A[K], where A is the - // apparent type of T. - var apparentType = getApparentTypeOfTypeVariable(type.objectType); - if (apparentType !== emptyObjectType) { - type.constraint = isTypeOfKind(type.indexType, 262178 /* StringLike */) ? - getIndexedAccessType(apparentType, type.indexType) : - getIndexTypeOfType(apparentType, 0 /* String */); - } - } return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 178 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 /* ElementAccessExpression */ ? accessNode : undefined; var propName = indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */ | 256 /* EnumLiteral */) ? indexType.text : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -29618,7 +30570,7 @@ var ts; getIndexInfoOfType(objectType, 0 /* String */) || undefined; if (indexInfo) { - if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); return unknownType; } @@ -29637,7 +30589,7 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 178 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 179 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); } @@ -29651,12 +30603,12 @@ var ts; return unknownType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 178 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 /* ElementAccessExpression */ ? accessNode : undefined; if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); return unknownType; } - var mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); + var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } @@ -29668,18 +30620,11 @@ var ts; // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved // eagerly using the constraint type of 'this' at the given location. if (maybeTypeOfKind(indexType, 540672 /* TypeVariable */ | 262144 /* Index */) || - maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && !(accessNode && accessNode.kind === 178 /* ElementAccessExpression */) || + maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && !(accessNode && accessNode.kind === 179 /* ElementAccessExpression */) || isGenericMappedType(objectType)) { if (objectType.flags & 1 /* Any */) { return objectType; } - // We first check that the index type is assignable to 'keyof T' for the object type. - if (accessNode) { - if (!isTypeAssignableTo(indexType, getIndexType(objectType))) { - error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); - return unknownType; - } - } // If the object type is a mapped type { [P in K]: E }, we instantiate E using a mapper that substitutes // the index type for P. For example, for an index access { [P in K]: Box }[X], we construct the // type Box. @@ -29688,7 +30633,11 @@ var ts; } // Otherwise we defer the operation by creating an indexed access type. var id = objectType.id + "," + indexType.id; - return indexedAccessTypes[id] || (indexedAccessTypes[id] = createIndexedAccessType(objectType, indexType)); + var type = indexedAccessTypes.get(id); + if (!type) { + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType)); + } + return type; } // In the following we resolve T[K] to the type of the property in T selected by K. var apparentObjectType = getApparentType(objectType); @@ -29732,7 +30681,7 @@ var ts; if (!links.resolvedType) { // Deferred resolution of members is handled by resolveObjectTypeMembers var aliasSymbol = getAliasSymbolForTypeNode(node); - if (ts.isEmpty(node.symbol.members) && !aliasSymbol) { + if (node.symbol.members.size === 0 && !aliasSymbol) { links.resolvedType = emptyTypeLiteralType; } else { @@ -29745,7 +30694,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 228 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 230 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -29756,7 +30705,7 @@ var ts; * this function should be called in a left folding style, with left = previous result of getSpreadType * and right = the new element to be spread. */ - function getSpreadType(left, right, isFromObjectLiteral) { + function getSpreadType(left, right) { if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { return anyType; } @@ -29769,10 +30718,13 @@ var ts; return left; } if (left.flags & 65536 /* Union */) { - return mapType(left, function (t) { return getSpreadType(t, right, isFromObjectLiteral); }); + return mapType(left, function (t) { return getSpreadType(t, right); }); } if (right.flags & 65536 /* Union */) { - return mapType(right, function (t) { return getSpreadType(left, t, isFromObjectLiteral); }); + return mapType(right, function (t) { return getSpreadType(left, t); }); + } + if (right.flags & 16777216 /* NonPrimitive */) { + return emptyObjectType; } var members = ts.createMap(); var skippedPrivateMembers = ts.createMap(); @@ -29790,42 +30742,45 @@ var ts; for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; // we approximate own properties as non-methods plus methods that are inside the object literal - var isOwnProperty = !(rightProp.flags & 8192 /* Method */) || isFromObjectLiteral; var isSetterWithoutGetter = rightProp.flags & 65536 /* SetAccessor */ && !(rightProp.flags & 32768 /* GetAccessor */); if (getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { - skippedPrivateMembers[rightProp.name] = true; + skippedPrivateMembers.set(rightProp.name, true); } - else if (isOwnProperty && !isSetterWithoutGetter) { - members[rightProp.name] = rightProp; + else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { + members.set(rightProp.name, rightProp); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { var leftProp = _c[_b]; if (leftProp.flags & 65536 /* SetAccessor */ && !(leftProp.flags & 32768 /* GetAccessor */) - || leftProp.name in skippedPrivateMembers) { + || skippedPrivateMembers.has(leftProp.name) + || isClassMethod(leftProp)) { continue; } - if (leftProp.name in members) { - var rightProp = members[leftProp.name]; + if (members.has(leftProp.name)) { + var rightProp = members.get(leftProp.name); var rightType = getTypeOfSymbol(rightProp); - if (maybeTypeOfKind(rightType, 2048 /* Undefined */) || rightProp.flags & 536870912 /* Optional */) { + if (maybeTypeOfKind(rightType, 2048 /* Undefined */) || rightProp.flags & 67108864 /* Optional */) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 /* Property */ | 67108864 /* Transient */ | (leftProp.flags & 536870912 /* Optional */); + var flags = 4 /* Property */ | (leftProp.flags & 67108864 /* Optional */); var result = createSymbol(flags, leftProp.name); + result.checkFlags = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp) ? 4 /* Readonly */ : 0; result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072 /* NEUndefined */)]); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; - result.isReadonly = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp); - members[leftProp.name] = result; + members.set(leftProp.name, result); } } else { - members[leftProp.name] = leftProp; + members.set(leftProp.name, leftProp); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } + function isClassMethod(prop) { + return prop.flags & 8192 /* Method */ && ts.find(prop.declarations, function (decl) { return ts.isClassLike(decl.parent); }); + } function createLiteralType(flags, text) { var type = createType(flags); type.text = text; @@ -29847,7 +30802,11 @@ var ts; } function getLiteralTypeForText(flags, text) { var map = flags & 32 /* StringLiteral */ ? stringLiteralTypes : numericLiteralTypes; - return map[text] || (map[text] = createLiteralType(flags, text)); + var type = map.get(text); + if (!type) { + map.set(text, type = createLiteralType(flags, text)); + } + return type; } function getTypeFromLiteralTypeNode(node) { var links = getNodeLinks(node); @@ -29875,9 +30834,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 227 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 229 /* InterfaceDeclaration */)) { if (!(ts.getModifierFlags(container) & 32 /* Static */) && - (container.kind !== 150 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 151 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -29894,87 +30853,89 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118 /* AnyKeyword */: - case 263 /* JSDocAllType */: - case 264 /* JSDocUnknownType */: + case 267 /* JSDocAllType */: + case 268 /* JSDocUnknownType */: return anyType; - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: return stringType; case 132 /* NumberKeyword */: return numberType; case 121 /* BooleanKeyword */: return booleanType; - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: return esSymbolType; case 104 /* VoidKeyword */: return voidType; - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: return undefinedType; case 94 /* NullKeyword */: return nullType; case 129 /* NeverKeyword */: return neverType; - case 289 /* JSDocNullKeyword */: + case 133 /* ObjectKeyword */: + return nonPrimitiveType; + case 293 /* JSDocNullKeyword */: return nullType; - case 290 /* JSDocUndefinedKeyword */: + case 294 /* JSDocUndefinedKeyword */: return undefinedType; - case 291 /* JSDocNeverKeyword */: + case 295 /* JSDocNeverKeyword */: return neverType; - case 167 /* ThisType */: + case 168 /* ThisType */: case 98 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 171 /* LiteralType */: + case 172 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 288 /* JSDocLiteralType */: + case 292 /* JSDocLiteralType */: return getTypeFromLiteralTypeNode(node.literal); - case 157 /* TypeReference */: - case 272 /* JSDocTypeReference */: + case 158 /* TypeReference */: + case 276 /* JSDocTypeReference */: return getTypeFromTypeReference(node); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return booleanType; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 162 /* ArrayType */: - case 265 /* JSDocArrayType */: + case 163 /* ArrayType */: + case 269 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); - case 163 /* TupleType */: + case 164 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 164 /* UnionType */: - case 266 /* JSDocUnionType */: + case 165 /* UnionType */: + case 270 /* JSDocUnionType */: return getTypeFromUnionTypeNode(node); - case 165 /* IntersectionType */: + case 166 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 166 /* ParenthesizedType */: - case 268 /* JSDocNullableType */: - case 269 /* JSDocNonNullableType */: - case 276 /* JSDocConstructorType */: - case 277 /* JSDocThisType */: - case 273 /* JSDocOptionalType */: + case 167 /* ParenthesizedType */: + case 272 /* JSDocNullableType */: + case 273 /* JSDocNonNullableType */: + case 280 /* JSDocConstructorType */: + case 281 /* JSDocThisType */: + case 277 /* JSDocOptionalType */: return getTypeFromTypeNode(node.type); - case 270 /* JSDocRecordType */: + case 274 /* JSDocRecordType */: return getTypeFromTypeNode(node.literal); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 161 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 274 /* JSDocFunctionType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 162 /* TypeLiteral */: + case 291 /* JSDocTypeLiteral */: + case 278 /* JSDocFunctionType */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 168 /* TypeOperator */: + case 169 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 170 /* MappedType */: + case 171 /* MappedType */: return getTypeFromMappedTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 70 /* Identifier */: - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 267 /* JSDocTupleType */: + case 271 /* JSDocTupleType */: return getTypeFromJSDocTupleType(node); - case 275 /* JSDocVariadicType */: + case 279 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -30001,13 +30962,13 @@ var ts; var instantiations = mapper.instantiations || (mapper.instantiations = []); return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); } - function createUnaryTypeMapper(source, target) { + function makeUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } - function createBinaryTypeMapper(source1, target1, source2, target2) { + function makeBinaryTypeMapper(source1, target1, source2, target2) { return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; } - function createArrayTypeMapper(sources, targets) { + function makeArrayTypeMapper(sources, targets) { return function (t) { for (var i = 0; i < sources.length; i++) { if (t === sources[i]) { @@ -30018,16 +30979,24 @@ var ts; }; } function createTypeMapper(sources, targets) { - var count = sources.length; - var mapper = count == 1 ? createUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : - count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : - createArrayTypeMapper(sources, targets); + var mapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : + makeArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; return mapper; } function createTypeEraser(sources) { return createTypeMapper(sources, undefined); } + /** + * Maps forward-references to later types parameters to the empty object type. + * This is used during inference when instantiating type parameter defaults. + */ + function createBackreferenceMapper(typeParameters, index) { + var mapper = function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; + mapper.mappedTypes = typeParameters; + return mapper; + } function getInferenceMapper(context) { if (!context.mapper) { var mapper = function (t) { @@ -30051,7 +31020,12 @@ var ts; } function combineTypeMappers(mapper1, mapper2) { var mapper = function (t) { return instantiateType(mapper1(t), mapper2); }; - mapper.mappedTypes = mapper1.mappedTypes; + mapper.mappedTypes = ts.concatenate(mapper1.mappedTypes, mapper2.mappedTypes); + return mapper; + } + function createReplacementMapper(source, target, baseMapper) { + var mapper = function (t) { return t === source ? target : baseMapper(t); }; + mapper.mappedTypes = baseMapper.mappedTypes; return mapper; } function cloneTypeParameter(typeParameter) { @@ -30099,7 +31073,7 @@ var ts; return result; } function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 16777216 /* Instantiated */) { + if (getCheckFlags(symbol) & 1 /* 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 @@ -30109,7 +31083,8 @@ var 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. - var result = createSymbol(16777216 /* Instantiated */ | 67108864 /* Transient */ | symbol.flags, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); + result.checkFlags = 1 /* Instantiated */; result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -30136,17 +31111,16 @@ var ts; var constraintType = getConstraintTypeFromMappedType(type); if (constraintType.flags & 262144 /* Index */) { var typeVariable_1 = constraintType.type; - var mappedTypeVariable = instantiateType(typeVariable_1, mapper); - if (typeVariable_1 !== mappedTypeVariable) { - return mapType(mappedTypeVariable, function (t) { - if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); - } - return t; - }); + if (typeVariable_1.flags & 16384 /* TypeParameter */) { + var mappedTypeVariable = instantiateType(typeVariable_1, mapper); + if (typeVariable_1 !== mappedTypeVariable) { + return mapType(mappedTypeVariable, function (t) { + if (isMappableType(t)) { + return instantiateMappedObjectType(type, createReplacementMapper(typeVariable_1, t, mapper)); + } + return t; + }); + } } } return instantiateMappedObjectType(type, mapper); @@ -30170,26 +31144,26 @@ var ts; // Starting with the parent of the symbol's declaration, check if the mapper maps any of // the type parameters introduced by enclosing declarations. We just pick the first // declaration since multiple declarations will all have the same parent anyway. - var node = symbol.declarations[0].parent; + var node = symbol.declarations[0]; while (node) { switch (node.kind) { - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 225 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -30199,15 +31173,29 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 227 /* InterfaceDeclaration */) { + if (ts.isClassLike(node) || node.kind === 229 /* InterfaceDeclaration */) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 230 /* ModuleDeclaration */: - case 261 /* SourceFile */: + case 171 /* MappedType */: + if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { + return true; + } + break; + case 278 /* JSDocFunctionType */: + var func = node; + for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { + var p = _c[_b]; + if (ts.contains(mappedTypes, getTypeOfNode(p))) { + return true; + } + } + break; + case 232 /* ModuleDeclaration */: + case 264 /* SourceFile */: return false; } node = node.parent; @@ -30217,7 +31205,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 261 /* SourceFile */ || parentKind === 231 /* ModuleBlock */; + return parentKind === 264 /* SourceFile */ || parentKind === 233 /* ModuleBlock */; } return false; } @@ -30294,28 +31282,36 @@ 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 !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return node.operatorToken.kind === 53 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 257 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return isContextSensitive(node.expression); + case 253 /* JsxAttributes */: + return ts.forEach(node.properties, isContextSensitive); + case 252 /* JsxAttribute */: + // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. + return node.initializer && isContextSensitive(node.initializer); + case 255 /* JsxExpression */: + // It is possible to that node.expression is undefined (e.g
) + return node.expression && isContextSensitive(node.expression); } return false; } @@ -30329,7 +31325,7 @@ var ts; return true; } // For arrow functions we now know we're not context sensitive. - if (node.kind === 185 /* ArrowFunction */) { + if (node.kind === 186 /* ArrowFunction */) { return false; } // If the first parameter is not an explicit 'this' parameter, then the function has @@ -30351,9 +31347,12 @@ var ts; result.properties = resolved.properties; result.callSignatures = emptyArray; result.constructSignatures = emptyArray; - type = result; + return result; } } + else if (type.flags & 131072 /* Intersection */) { + return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); + } return type; } // TYPE CHECKING @@ -30376,7 +31375,7 @@ var ts; // subtype of T but not structurally identical to T. This specifically means that two distinct but // structurally identical types (such as two classes) are not considered instances of each other. function isTypeInstanceOf(source, target) { - return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + return getTargetType(source) === getTargetType(target) || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); } /** * This is *not* a bi-directional relationship. @@ -30544,13 +31543,15 @@ var ts; return true; } var id = source.id + "," + target.id; - if (enumRelation[id] !== undefined) { - return enumRelation[id]; + var relation = enumRelation.get(id); + if (relation !== undefined) { + return relation; } if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & 256 /* RegularEnum */) || !(target.symbol.flags & 256 /* RegularEnum */) || (source.flags & 65536 /* Union */) !== (target.flags & 65536 /* Union */)) { - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } var targetEnumType = getTypeOfSymbol(target.symbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(source.symbol)); _i < _a.length; _i++) { @@ -30561,11 +31562,13 @@ var ts; if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, property.name, typeToString(target, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */)); } - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } } } - return enumRelation[id] = true; + enumRelation.set(id, true); + return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { if (target.flags & 8192 /* Never */) @@ -30586,6 +31589,8 @@ var ts; return true; if (source.flags & 4096 /* Null */ && (!strictNullChecks || target.flags & 4096 /* Null */)) return true; + if (source.flags & 32768 /* Object */ && target.flags & 16777216 /* NonPrimitive */) + return true; if (relation === assignableRelation || relation === comparableRelation) { if (source.flags & 1 /* Any */) return true; @@ -30617,12 +31622,12 @@ var ts; } if (source.flags & 32768 /* Object */ && target.flags & 32768 /* Object */) { var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { return related === 1 /* Succeeded */; } } - if (source.flags & 507904 /* StructuredOrTypeParameter */ || target.flags & 507904 /* StructuredOrTypeParameter */) { + if (source.flags & 1032192 /* StructuredOrTypeVariable */ || target.flags & 1032192 /* StructuredOrTypeVariable */) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -30710,10 +31715,12 @@ var ts; } return false; } - // 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. + /** + * 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; if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 1048576 /* FreshLiteral */) { @@ -30799,16 +31806,6 @@ var ts; } } } - else { - // Given a type parameter K with a constraint keyof T, a type S is - // assignable to K if S is assignable to keyof T. - var constraint = getConstraintOfTypeParameter(target); - if (constraint && constraint.flags & 262144 /* Index */) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - return result; - } - } - } } else if (target.flags & 262144 /* Index */) { // A keyof S is related to a keyof T if T is related to S. @@ -30817,14 +31814,12 @@ var ts; return result; } } - // Given a type variable T with a constraint C, a type S is assignable to - // keyof T if S is assignable to keyof C. - if (target.type.flags & 540672 /* TypeVariable */) { - var constraint = getConstraintOfTypeVariable(target.type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } + // A type S is assignable to keyof T if S is assignable to keyof C, where C is the + // constraint of T. + var constraint = getConstraintOfType(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; } } } @@ -30838,8 +31833,9 @@ var ts; } // A type S is related to a type T[K] if S is related to A[K], where K is string-like and // A is the apparent type of S. - if (target.constraint) { - if (result = isRelatedTo(source, target.constraint, reportErrors)) { + var constraint = getBaseConstraintOfType(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -30857,24 +31853,28 @@ var ts; } else { var constraint = getConstraintOfTypeParameter(source); - if (!constraint || constraint.flags & 1 /* Any */) { - constraint = emptyObjectType; - } - // The constraint may need to be further instantiated with its 'this' type. - constraint = getTypeWithThisArgument(constraint, source); - // 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; + // A type parameter with no constraint is not related to the non-primitive object type. + if (constraint || !(target.flags & 16777216 /* NonPrimitive */)) { + if (!constraint || constraint.flags & 1 /* Any */) { + constraint = emptyObjectType; + } + // The constraint may need to be further instantiated with its 'this' type. + constraint = getTypeWithThisArgument(constraint, source); + // 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 & 524288 /* IndexedAccess */) { // A type S[K] is related to a type T if A[K] is related to T, where K is string-like and // A is the apparent type of S. - if (source.constraint) { - if (result = isRelatedTo(source.constraint, target, reportErrors)) { + var constraint = getBaseConstraintOfType(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -30938,45 +31938,61 @@ var ts; // 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) { + function isKnownProperty(type, name, isComparingJsxAttributes) { if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); - if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) || - resolved.stringIndexInfo || - (resolved.numberIndexInfo && isNumericLiteralName(name)) || - getPropertyOfType(type, name)) { + if ((relation === assignableRelation || relation === comparableRelation) && + (type === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(resolved)))) { + return true; + } + else if (resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name))) { + return true; + } + else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) { + // For JSXAttributes, if the attribute has a hyphenated name, consider that the attribute to be known. return true; } } else if (type.flags & 196608 /* UnionOrIntersection */) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (isKnownProperty(t, name)) { + if (isKnownProperty(t, name, isComparingJsxAttributes)) { return true; } } } return false; } - function isEmptyObjectType(t) { + function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && t.constructSignatures.length === 0 && !t.stringIndexInfo && !t.numberIndexInfo; } + function isEmptyObjectType(type) { + return type.flags & 32768 /* Object */ && isEmptyResolvedType(resolveStructuredTypeMembers(type)); + } function hasExcessProperties(source, target, reportErrors) { if (maybeTypeOfKind(target, 32768 /* Object */) && !(getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + var isComparingJsxAttributes = !!(source.flags & 33554432 /* JsxAttributes */); for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; - if (!isKnownProperty(target, prop.name)) { + if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) { 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. ts.Debug.assert(!!errorNode); - 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)); + if (ts.isJsxAttributes(errorNode)) { + // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. + // However, using an object-literal error message will be very confusing to the users so we give different a message. + reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); + } + else { + 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; } @@ -31002,20 +32018,42 @@ var ts; if (target.flags & 65536 /* Union */ && containsType(targetTypes, source)) { return -1 /* True */; } - var len = targetTypes.length; - for (var i = 0; i < len; i++) { - var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); + for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { + var type = targetTypes_1[_i]; + var related = isRelatedTo(source, type, /*reportErrors*/ false); if (related) { return related; } } + if (reportErrors) { + var discriminantType = findMatchingDiscriminantType(source, target); + isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); + } return 0 /* False */; } + function findMatchingDiscriminantType(source, target) { + var sourceProperties = getPropertiesOfObjectType(source); + if (sourceProperties) { + for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { + var sourceProperty = sourceProperties_1[_i]; + if (isDiscriminantProperty(target, sourceProperty.name)) { + var sourceType = getTypeOfSymbol(sourceProperty); + for (var _a = 0, _b = target.types; _a < _b.length; _a++) { + var type = _b[_a]; + var targetType = getTypeOfPropertyOfType(type, sourceProperty.name); + if (targetType && isRelatedTo(sourceType, targetType)) { + return type; + } + } + } + } + } + } function typeRelatedToEachType(source, target, reportErrors) { var result = -1 /* True */; var targetTypes = target.types; - for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { - var targetType = targetTypes_1[_i]; + for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { + var targetType = targetTypes_2[_i]; var related = isRelatedTo(source, targetType, reportErrors); if (!related) { return 0 /* False */; @@ -31078,12 +32116,12 @@ var ts; return 0 /* False */; } var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2 /* Failed */) { // We are elaborating errors and the cached result is an unreported failure. Record the result as a reported // failure and continue computing the relation such that errors get reported. - relation[id] = 3 /* FailedAndReported */; + relation.set(id, 3 /* FailedAndReported */); } else { return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; @@ -31092,7 +32130,7 @@ var ts; 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]) { + if (maybeStack[i].get(id)) { return 1 /* Maybe */; } } @@ -31110,7 +32148,7 @@ var ts; sourceStack[depth] = source; targetStack[depth] = target; maybeStack[depth] = ts.createMap(); - maybeStack[depth][id] = 1 /* Succeeded */; + maybeStack[depth].set(id, 1 /* Succeeded */); depth++; var saveExpandingFlags = expandingFlags; if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) @@ -31145,40 +32183,45 @@ var ts; 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.copyProperties(maybeCache, destinationCache); + ts.copyEntries(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 */; + relation.set(id, reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */); } return result; } - // A type [P in S]: X is related to a type [P in T]: Y if T is related to S and X is related to Y. + // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is + // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice + // that S and T are contra-variant whereas X and Y are co-variant. function mappedTypeRelatedTo(source, target, reportErrors) { if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { - var result_2; - if (relation === identityRelation) { - var readonlyMatches = !source.declaration.readonlyToken === !target.declaration.readonlyToken; - var optionalMatches = !source.declaration.questionToken === !target.declaration.questionToken; - if (readonlyMatches && optionalMatches) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getErasedTemplateTypeFromMappedType(source), getErasedTemplateTypeFromMappedType(target), reportErrors); - } - } - } - else { - if (relation === comparableRelation || !source.declaration.questionToken || target.declaration.questionToken) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors); - } + var sourceReadonly = !!source.declaration.readonlyToken; + var sourceOptional = !!source.declaration.questionToken; + var targetReadonly = !!target.declaration.readonlyToken; + var targetOptional = !!target.declaration.questionToken; + var modifiersRelated = relation === identityRelation ? + sourceReadonly === targetReadonly && sourceOptional === targetOptional : + relation === comparableRelation || !sourceOptional || targetOptional; + if (modifiersRelated) { + var result_2; + if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { + var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); + return result_2 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } + else if (target.declaration.questionToken && isEmptyObjectType(source)) { + return -1 /* True */; + } } - else if (relation !== identityRelation && isEmptyObjectType(resolveStructuredTypeMembers(target))) { - return -1 /* True */; + else if (relation !== identityRelation) { + var resolved = resolveStructuredTypeMembers(target); + if (isEmptyResolvedType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1 /* Any */) { + return -1 /* True */; + } } return 0 /* False */; } @@ -31194,17 +32237,23 @@ var ts; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { - if (!(targetProp.flags & 536870912 /* Optional */) || requireOptionalProperties) { + if (!(targetProp.flags & 67108864 /* 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 */)) { + else if (!(targetProp.flags & 16777216 /* Prototype */)) { var sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { + if (getCheckFlags(sourceProp) & 128 /* ContainsPrivate */) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); + } + return 0 /* False */; + } if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { @@ -31218,12 +32267,9 @@ var ts; } } else if (targetPropFlags & 16 /* Protected */) { - var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32 /* Class */; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(getParentOfSymbol(sourceProp)) : undefined; - var targetClass = getDeclaredTypeOfSymbol(getParentOfSymbol(targetProp)); - if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { + if (!isValidOverrideOf(sourceProp, targetProp)) { 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)); + reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } return 0 /* False */; } @@ -31243,7 +32289,7 @@ var ts; } result &= related; // When checking for comparability, be more lenient with optional properties. - if (relation !== comparableRelation && sourceProp.flags & 536870912 /* Optional */ && !(targetProp.flags & 536870912 /* Optional */)) { + if (relation !== comparableRelation && sourceProp.flags & 67108864 /* Optional */ && !(targetProp.flags & 67108864 /* 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.. @@ -31271,8 +32317,8 @@ var ts; return 0 /* False */; } var result = -1 /* True */; - for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { - var sourceProp = sourceProperties_1[_i]; + for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) { + var sourceProp = sourceProperties_2[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return 0 /* False */; @@ -31345,7 +32391,7 @@ var ts; return 0 /* False */; } var result = -1 /* True */; - for (var i = 0, len = sourceSignatures.length; i < len; i++) { + for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { return 0 /* False */; @@ -31445,6 +32491,45 @@ var ts; return false; } } + // Invoke the callback for each underlying property symbol of the given symbol and return the first + // value that isn't undefined. + function forEachProperty(prop, callback) { + if (getCheckFlags(prop) & 2 /* SyntheticProperty */) { + for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var p = getPropertyOfType(t, prop.name); + var result = p && forEachProperty(p, callback); + if (result) { + return result; + } + } + return undefined; + } + return callback(prop); + } + // Return the declaring class type of a property or undefined if property not declared in class + function getDeclaringClass(prop) { + return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + } + // Return true if some underlying source property is declared in a class that derives + // from the given base class. + function isPropertyInClassDerivedFrom(prop, baseClass) { + return forEachProperty(prop, function (sp) { + var sourceClass = getDeclaringClass(sp); + return sourceClass ? hasBaseType(sourceClass, baseClass) : false; + }); + } + // Return true if source property is a valid override of protected parts of target property. + function isValidOverrideOf(sourceProp, targetProp) { + return !forEachProperty(targetProp, function (tp) { return getDeclarationModifierFlagsFromSymbol(tp) & 16 /* Protected */ ? + !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); + } + // Return true if the given class derives from each of the declaring classes of the protected + // constituents of the given property. + function isClassDerivedFromDeclaringClasses(checkClass, prop) { + return forEachProperty(prop, function (p) { return getDeclarationModifierFlagsFromSymbol(p) & 16 /* Protected */ ? + !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; + } // Return true if the given type is the constructor type for an abstract class function isAbstractConstructorType(type) { if (getObjectFlags(type) & 16 /* Anonymous */) { @@ -31500,7 +32585,7 @@ var ts; } } else { - if ((sourceProp.flags & 536870912 /* Optional */) !== (targetProp.flags & 536870912 /* Optional */)) { + if ((sourceProp.flags & 67108864 /* Optional */) !== (targetProp.flags & 67108864 /* Optional */)) { return 0 /* False */; } } @@ -31544,7 +32629,7 @@ var ts; // the constraints with a common set of type arguments to get relatable entities in places where // type parameters occur in the constraints. The complexity of doing that doesn't seem worthwhile, // particularly as we're comparing erased versions of the signatures below. - if ((source.typeParameters ? source.typeParameters.length : 0) !== (target.typeParameters ? target.typeParameters.length : 0)) { + if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { return 0 /* False */; } // Spec 1.0 Section 3.8.3 & 3.8.4: @@ -31584,8 +32669,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var t = types_7[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -31593,8 +32678,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -31700,8 +32785,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getFalsyFlags(t); } return result; @@ -31733,7 +32818,7 @@ var ts; types.push(undefinedType); if (flags & 4096 /* Null */) types.push(nullType); - return getUnionType(types, /*subtypeReduction*/ true); + return getUnionType(types); } function removeDefinitelyFalsyTypes(type) { return getFalsyFlags(type) & 7392 /* DefinitelyFalsy */ ? @@ -31752,8 +32837,8 @@ var ts; getSignaturesOfType(type, 0 /* Call */).length === 0 && getSignaturesOfType(type, 1 /* Construct */).length === 0; } - function createTransientSymbol(source, type) { - var symbol = createSymbol(source.flags | 67108864 /* Transient */, source.name); + function createSymbolWithType(source, type) { + var symbol = createSymbol(source.flags, source.name); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -31769,7 +32854,7 @@ var ts; var property = _a[_i]; var original = getTypeOfSymbol(property); var updated = f(original); - members[property.name] = updated === original ? property : createTransientSymbol(property, updated); + members.set(property.name, updated === original ? property : createSymbolWithType(property, updated)); } ; return members; @@ -31871,25 +32956,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 144 /* Parameter */: + case 145 /* 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 174 /* BindingElement */: + case 175 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 225 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -31982,7 +33067,7 @@ var ts; var typeInferencesArray = [typeInferences]; var templateType = getTemplateTypeFromMappedType(target); var readonlyMask = target.declaration.readonlyToken ? false : true; - var optionalMask = target.declaration.questionToken ? 0 : 536870912 /* Optional */; + var optionalMask = target.declaration.questionToken ? 0 : 67108864 /* Optional */; var members = createSymbolTable(properties); for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var prop = properties_4[_i]; @@ -31990,11 +33075,11 @@ var ts; if (!inferredPropType) { return undefined; } - var inferredProp = createSymbol(4 /* Property */ | 67108864 /* Transient */ | prop.flags & optionalMask, prop.name); + var inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.name); + inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 4 /* Readonly */ : 0; inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; - inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop); - members[prop.name] = inferredProp; + members.set(prop.name, inferredProp); } if (indexInfo) { var inferredIndexType = inferTargetType(indexInfo.type); @@ -32131,8 +33216,8 @@ var ts; var typeVariableCount = 0; var typeVariable = void 0; // First infer to each type in union or intersection that isn't a type variable - for (var _d = 0, targetTypes_2 = targetTypes; _d < targetTypes_2.length; _d++) { - var t = targetTypes_2[_d]; + for (var _d = 0, targetTypes_3 = targetTypes; _d < targetTypes_3.length; _d++) { + var t = targetTypes_3[_d]; if (t.flags & 540672 /* TypeVariable */ && ts.contains(typeVariables, t)) { typeVariable = t; typeVariableCount++; @@ -32168,10 +33253,10 @@ var ts; return; } var key = source.id + "," + target.id; - if (visited[key]) { + if (visited.get(key)) { return; } - visited[key] = true; + visited.set(key, true); if (depth === 0) { sourceStack = []; targetStack = []; @@ -32269,8 +33354,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -32320,11 +33405,20 @@ var ts; 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. + // Infer either the default or 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; + var defaultType = getDefaultFromTypeParameter(context.signature.typeParameters[index]); + if (defaultType) { + // Instantiate the default type. Any forward reference to a type + // parameter should be instantiated to the empty object type. + inferredType = instantiateType(defaultType, combineTypeMappers(createBackreferenceMapper(context.signature.typeParameters, index), getInferenceMapper(context))); + } + else { + inferredType = emptyObjectType; + } inferenceSucceeded = true; } context.inferredTypes[index] = inferredType; @@ -32367,10 +33461,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 160 /* TypeQuery */: + case 161 /* TypeQuery */: return true; case 70 /* Identifier */: - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: node = node.parent; continue; default: @@ -32391,7 +33485,7 @@ var ts; if (node.kind === 98 /* ThisKeyword */) { return "0"; } - if (node.kind === 177 /* PropertyAccessExpression */) { + if (node.kind === 178 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -32402,7 +33496,7 @@ var ts; case 70 /* Identifier */: case 98 /* ThisKeyword */: return node; - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -32411,19 +33505,19 @@ var ts; switch (source.kind) { case 70 /* Identifier */: return target.kind === 70 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 223 /* VariableDeclaration */ || target.kind === 174 /* BindingElement */) && + (target.kind === 225 /* VariableDeclaration */ || target.kind === 175 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98 /* ThisKeyword */: return target.kind === 98 /* ThisKeyword */; - case 177 /* PropertyAccessExpression */: - return target.kind === 177 /* PropertyAccessExpression */ && + case 178 /* PropertyAccessExpression */: + return target.kind === 178 /* PropertyAccessExpression */ && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 177 /* PropertyAccessExpression */) { + while (source.kind === 178 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -32436,7 +33530,7 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 177 /* PropertyAccessExpression */ && + return target.kind === 178 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -32444,7 +33538,7 @@ var ts; if (expr.kind === 70 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 177 /* PropertyAccessExpression */) { + if (expr.kind === 178 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -32453,9 +33547,9 @@ var ts; function isDiscriminantProperty(type, name) { if (type && type.flags & 65536 /* Union */) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && prop.flags & 268435456 /* SyntheticProperty */) { + if (prop && getCheckFlags(prop) & 2 /* SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.hasNonUniformType && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.checkFlags & 16 /* HasNonUniformType */ && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -32474,7 +33568,7 @@ var ts; } } } - if (callExpression.expression.kind === 177 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 178 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -32516,8 +33610,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -32527,7 +33621,7 @@ var ts; // check. This gives us a quicker out in the common case where an object type is not a function. var resolved = resolveStructuredTypeMembers(type); return !!(resolved.callSignatures.length || resolved.constructSignatures.length || - resolved.members["bind"] && isTypeSubtypeOf(type, globalFunctionType)); + resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type) { var flags = type.flags; @@ -32570,6 +33664,9 @@ var ts; if (flags & 512 /* ESSymbol */) { return strictNullChecks ? 1981320 /* SymbolStrictFacts */ : 4193160 /* SymbolFacts */; } + if (flags & 16777216 /* NonPrimitive */) { + return strictNullChecks ? 6166480 /* ObjectStrictFacts */ : 8378320 /* ObjectFacts */; + } if (flags & 16384 /* TypeParameter */) { var constraint = getConstraintOfTypeParameter(type); return getTypeFacts(constraint || emptyObjectType); @@ -32605,10 +33702,16 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 /* ArrayLiteralExpression */ || node.parent.kind === 257 /* PropertyAssignment */ ? + var isDestructuringDefaultAssignment = node.parent.kind === 176 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 260 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } + function isDestructuringAssignmentTarget(parent) { + return parent.parent.kind === 193 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 215 /* ForOfStatement */ && parent.parent.initializer === parent; + } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); } @@ -32624,21 +33727,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: return stringType; - case 213 /* ForOfStatement */: + case 215 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return undefinedType; - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 257 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 258 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -32646,7 +33749,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 172 /* ObjectBindingPattern */ ? + var type = pattern.kind === 173 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -32664,35 +33767,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 212 /* ForInStatement */) { + if (node.parent.parent.kind === 214 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 213 /* ForOfStatement */) { + if (node.parent.parent.kind === 215 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 223 /* VariableDeclaration */ ? + return node.kind === 225 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 223 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */ ? + return node.kind === 225 /* VariableDeclaration */ || node.kind === 175 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 223 /* VariableDeclaration */ && node.initializer && + return node.kind === 225 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 174 /* BindingElement */ && node.parent.kind === 192 /* BinaryExpression */ && + node.kind !== 175 /* BindingElement */ && node.parent.kind === 193 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (node.operatorToken.kind) { case 57 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -32704,13 +33807,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 183 /* ParenthesizedExpression */ || - parent.kind === 192 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || - parent.kind === 192 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? + return parent.kind === 184 /* ParenthesizedExpression */ || + parent.kind === 193 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || + parent.kind === 193 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 253 /* CaseClause */) { + if (clause.kind === 256 /* CaseClause */) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -32825,8 +33928,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; if (!(t.flags & 8192 /* Never */)) { if (!(getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -32849,11 +33952,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 177 /* PropertyAccessExpression */ && (parent.name.text === "length" || - parent.parent.kind === 179 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 178 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 178 /* PropertyAccessExpression */ && (parent.name.text === "length" || + parent.parent.kind === 180 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 179 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 192 /* BinaryExpression */ && + parent.parent.kind === 193 /* BinaryExpression */ && parent.parent.operatorToken.kind === 57 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -32882,7 +33985,7 @@ var ts; } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215 /* Narrowable */)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 17810431 /* Narrowable */)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -32896,7 +33999,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 201 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { + if (reference.parent.kind === 202 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { return declaredType; } return resultType; @@ -32913,7 +34016,19 @@ var ts; } } var type = void 0; - if (flow.flags & 16 /* Assignment */) { + if (flow.flags & 4096 /* AfterFinally */) { + // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement + flow.locked = true; + type = getTypeAtFlowNode(flow.antecedent); + flow.locked = false; + } + else if (flow.flags & 2048 /* PreFinally */) { + // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel + // so here just redirect to antecedent + flow = flow.antecedent; + continue; + } + else if (flow.flags & 16 /* Assignment */) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; @@ -32945,7 +34060,7 @@ var ts; else if (flow.flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 177 /* PropertyAccessExpression */) { + if (container && container !== flowContainer && reference.kind !== 178 /* PropertyAccessExpression */) { flow = container.flowNode; continue; } @@ -32999,7 +34114,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 179 /* CallExpression */ ? + var expr = node.kind === 180 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -33007,7 +34122,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 179 /* CallExpression */) { + if (node.kind === 180 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -33066,6 +34181,12 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; + if (antecedent.flags & 2048 /* PreFinally */ && antecedent.lock.locked) { + // if flow correspond to branch from pre-try to finally and this branch is locked - this means that + // we initially have started following the flow outside the finally block. + // in this case we should ignore this branch. + continue; + } var flowType = getTypeAtFlowNode(antecedent); var type = getTypeFromFlowType(flowType); // If the type at a particular antecedent path is the declared type and the @@ -33098,8 +34219,9 @@ var ts; if (!key) { key = getFlowCacheKey(reference); } - if (cache[key]) { - return cache[key]; + var cached = cache.get(key); + if (cached) { + return cached; } // If this flow loop junction and reference are already being processed, return // the union of the types computed for each branch so far, marked as incomplete. @@ -33134,8 +34256,9 @@ var ts; // If we see a value appear in the cache it is a sign that control flow analysis // was restarted and completed by checkExpressionCached. We can simply pick up // the resulting type and bail out. - if (cache[key]) { - return cache[key]; + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; } if (!ts.contains(antecedentTypes, type)) { antecedentTypes.push(type); @@ -33159,10 +34282,11 @@ var ts; if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } - return cache[key] = result; + cache.set(key, result); + return result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 177 /* PropertyAccessExpression */ && + return expr.kind === 178 /* PropertyAccessExpression */ && declaredType.flags & 65536 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -33196,10 +34320,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 187 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { + if (left_1.kind === 188 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 187 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { + if (right_1.kind === 188 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -33245,7 +34369,7 @@ var ts; assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; return getTypeWithFacts(type, facts); } - if (type.flags & 33281 /* NotUnionOrUnit */) { + if (type.flags & 16810497 /* NotUnionOrUnit */) { return type; } if (assumeTrue) { @@ -33276,14 +34400,14 @@ var ts; // We narrow a non-union type to an exact primitive type if the non-union type // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. - var targetType = typeofTypesByName[literal.text]; + var targetType = typeofTypesByName.get(literal.text); if (targetType && isTypeSubtypeOf(targetType, type)) { return targetType; } } var facts = assumeTrue ? - typeofEQFacts[literal.text] || 64 /* TypeofEQHostObject */ : - typeofNEFacts[literal.text] || 8192 /* TypeofNEHostObject */; + typeofEQFacts.get(literal.text) || 64 /* TypeofEQHostObject */ : + typeofNEFacts.get(literal.text) || 8192 /* TypeofNEHostObject */; return getTypeWithFacts(type, facts); } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { @@ -33398,7 +34522,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 178 /* ElementAccessExpression */ || invokedExpression.kind === 177 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 179 /* ElementAccessExpression */ || invokedExpression.kind === 178 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -33417,15 +34541,15 @@ var ts; switch (expr.kind) { case 70 /* Identifier */: case 98 /* ThisKeyword */: - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: if (expr.operator === 50 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -33461,9 +34585,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 231 /* ModuleBlock */ || - node.kind === 261 /* SourceFile */ || - node.kind === 147 /* PropertyDeclaration */) { + node.kind === 233 /* ModuleBlock */ || + node.kind === 264 /* SourceFile */ || + node.kind === 148 /* PropertyDeclaration */) { return node; } } @@ -33495,7 +34619,7 @@ var ts; if (node.kind === 70 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 144 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 145 /* Parameter */) { symbol.isAssigned = true; } } @@ -33521,7 +34645,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 185 /* ArrowFunction */) { + if (container.kind === 186 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { @@ -33542,7 +34666,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration_1.kind === 226 /* ClassDeclaration */ + if (declaration_1.kind === 228 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -33554,14 +34678,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 197 /* ClassExpression */) { + else if (declaration_1.kind === 198 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 147 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 148 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration_1).flags |= 8388608 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 16777216 /* ConstructorReferenceInClass */; } @@ -33573,6 +34697,7 @@ var ts; } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkCollisionWithCapturedNewTargetVariable(node, node); checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; @@ -33595,15 +34720,15 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 144 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 145 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 184 /* FunctionExpression */ || - flowContainer.kind === 185 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 185 /* FunctionExpression */ || + flowContainer.kind === 186 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -33611,7 +34736,7 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0 || isInTypeQuery(node)) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph @@ -33646,7 +34771,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 256 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 259 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -33671,8 +34796,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 211 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 224 /* VariableDeclarationList */).parent === container && + if (container.kind === 213 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 226 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -33686,7 +34811,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { var current = node; // skip parenthesized nodes - while (current.parent.kind === 183 /* ParenthesizedExpression */) { + while (current.parent.kind === 184 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -33694,7 +34819,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 190 /* PrefixUnaryExpression */ || current.parent.kind === 191 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 191 /* PrefixUnaryExpression */ || current.parent.kind === 192 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 42 /* PlusPlusToken */ || expr.operator === 43 /* MinusMinusToken */; } @@ -33715,7 +34840,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 147 /* PropertyDeclaration */ || container.kind === 150 /* Constructor */) { + if (container.kind === 148 /* PropertyDeclaration */ || container.kind === 151 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -33783,36 +34908,38 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; - if (container.kind === 150 /* Constructor */) { + if (container.kind === 151 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 185 /* ArrowFunction */) { + if (container.kind === 186 /* 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 /* ES2015 */); } switch (container.kind) { - case 230 /* ModuleDeclaration */: + case 232 /* 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 229 /* EnumDeclaration */: + case 231 /* 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 150 /* Constructor */: + case 151 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); + // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: if (ts.getModifierFlags(container) & 32 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); + // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -33824,7 +34951,7 @@ var ts; // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated. // If this is a function in a JS file, it might be a class method. Check if it's the RHS // of a x.prototype.y = function [name]() { .... } - if (container.kind === 184 /* FunctionExpression */ && + if (container.kind === 185 /* FunctionExpression */ && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') @@ -33861,28 +34988,28 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 274 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 278 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 277 /* JSDocThisType */) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 281 /* JSDocThisType */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 144 /* Parameter */) { + if (n.kind === 145 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 179 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 180 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 185 /* ArrowFunction */) { + while (container && container.kind === 186 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -33896,16 +35023,16 @@ var ts; // [super.foo()]() {} // } var current = node; - while (current && current !== container && current.kind !== 142 /* ComputedPropertyName */) { + while (current && current !== container && current.kind !== 143 /* ComputedPropertyName */) { current = current.parent; } - if (current && current.kind === 142 /* ComputedPropertyName */) { + if (current && current.kind === 143 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 176 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 177 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -33913,7 +35040,7 @@ var ts; } return unknownType; } - if (!isCallExpression && container.kind === 150 /* Constructor */) { + if (!isCallExpression && container.kind === 151 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if ((ts.getModifierFlags(container) & 32 /* Static */) || isCallExpression) { @@ -33979,7 +35106,7 @@ var ts; // This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set. // This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment // while a property access can. - if (container.kind === 149 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { + if (container.kind === 150 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -33993,7 +35120,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 176 /* ObjectLiteralExpression */) { + if (container.parent.kind === 177 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -34013,7 +35140,7 @@ var ts; } return unknownType; } - if (container.kind === 150 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 151 /* 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; @@ -34028,7 +35155,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 === 150 /* Constructor */; + return container.kind === 151 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -34036,21 +35163,21 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 176 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 177 /* ObjectLiteralExpression */) { if (ts.getModifierFlags(container) & 32 /* Static */) { - return container.kind === 149 /* MethodDeclaration */ || - container.kind === 148 /* MethodSignature */ || - container.kind === 151 /* GetAccessor */ || - container.kind === 152 /* SetAccessor */; + return container.kind === 150 /* MethodDeclaration */ || + container.kind === 149 /* MethodSignature */ || + container.kind === 152 /* GetAccessor */ || + container.kind === 153 /* SetAccessor */; } else { - return container.kind === 149 /* MethodDeclaration */ || - container.kind === 148 /* MethodSignature */ || - container.kind === 151 /* GetAccessor */ || - container.kind === 152 /* SetAccessor */ || - container.kind === 147 /* PropertyDeclaration */ || - container.kind === 146 /* PropertySignature */ || - container.kind === 150 /* Constructor */; + return container.kind === 150 /* MethodDeclaration */ || + container.kind === 149 /* MethodSignature */ || + container.kind === 152 /* GetAccessor */ || + container.kind === 153 /* SetAccessor */ || + container.kind === 148 /* PropertyDeclaration */ || + container.kind === 147 /* PropertySignature */ || + container.kind === 151 /* Constructor */; } } } @@ -34058,7 +35185,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 185 /* ArrowFunction */) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 186 /* ArrowFunction */) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -34074,23 +35201,23 @@ var ts; var func = parameter.parent; if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { var iife = ts.getImmediatelyInvokedFunctionExpression(func); - if (iife) { + if (iife && iife.arguments) { var indexOfParameter = ts.indexOf(func.parameters, parameter); - if (iife.arguments && indexOfParameter < iife.arguments.length) { - if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return createArrayType(getUnionType(restTypes)); + if (parameter.dotDotDotToken) { + var restTypes = []; + for (var i = indexOfParameter; i < iife.arguments.length; i++) { + restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); } - var links = getNodeLinks(iife); - var cached = links.resolvedSignature; - links.resolvedSignature = anySignature; - var type = getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])); - links.resolvedSignature = cached; - return type; + return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; } + var links = getNodeLinks(iife); + var cached = links.resolvedSignature; + links.resolvedSignature = anySignature; + var type = indexOfParameter < iife.arguments.length ? + getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + parameter.initializer ? undefined : undefinedWideningType; + links.resolvedSignature = cached; + return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -34124,7 +35251,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 144 /* Parameter */) { + if (declaration.kind === 145 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -34135,11 +35262,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_19 = declaration.propertyName || declaration.name; + var name = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_19)) { - var text = ts.getTextOfPropertyName(name_19); + !ts.isBindingPattern(name)) { + var text = ts.getTextOfPropertyName(name); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -34176,7 +35303,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 144 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 145 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -34187,8 +35314,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 === 150 /* Constructor */ || - functionDecl.kind === 151 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 152 /* SetAccessor */))) { + functionDecl.kind === 151 /* Constructor */ || + functionDecl.kind === 152 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 153 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -34210,7 +35337,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 181 /* TaggedTemplateExpression */) { + if (template.parent.kind === 182 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -34254,8 +35381,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -34335,19 +35462,19 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxAttribute(attribute) { - var kind = attribute.kind; - var jsxElement = attribute.parent; - var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 250 /* JsxAttribute */) { - if (!attrsType || isTypeAny(attrsType)) { + // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type + // which is a type of the parameter of the signature we are trying out. + // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName + var attributesType = getContextualType(attribute.parent); + if (ts.isJsxAttribute(attribute)) { + if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfType(attrsType, attribute.name.text); + return getTypeOfPropertyOfType(attributesType, attribute.name.text); } - else if (attribute.kind === 251 /* JsxSpreadAttribute */) { - return attrsType; + else { + return attributesType; } - ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); } // 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. @@ -34382,42 +35509,45 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 223 /* VariableDeclaration */: - case 144 /* Parameter */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 174 /* BindingElement */: + case 225 /* VariableDeclaration */: + case 145 /* Parameter */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 175 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 185 /* ArrowFunction */: - case 216 /* ReturnStatement */: + case 186 /* ArrowFunction */: + case 218 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 179 /* CallExpression */: - case 180 /* NewExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: + case 260 /* PropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 202 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 194 /* TemplateExpression */); + case 204 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 195 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return getContextualType(parent); - case 252 /* JsxExpression */: + case 255 /* JsxExpression */: return getContextualType(parent); - case 250 /* JsxAttribute */: - case 251 /* JsxSpreadAttribute */: + case 252 /* JsxAttribute */: + case 254 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); + case 250 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + return getAttributesTypeFromJsxOpeningLikeElement(parent); } return undefined; } @@ -34448,7 +35578,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 184 /* FunctionExpression */ || node.kind === 185 /* ArrowFunction */; + return node.kind === 185 /* FunctionExpression */ || node.kind === 186 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -34467,7 +35597,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 !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -34477,8 +35607,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -34528,8 +35658,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function hasDefaultValue(node) { - return (node.kind === 174 /* BindingElement */ && !!node.initializer) || - (node.kind === 192 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); + return (node.kind === 175 /* BindingElement */ && !!node.initializer) || + (node.kind === 193 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -34538,7 +35668,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 196 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 197 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -34562,7 +35692,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 196 /* SpreadElement */; + hasSpreadElement = hasSpreadElement || e.kind === 197 /* SpreadElement */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -34577,7 +35707,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 === 173 /* ArrayBindingPattern */ || pattern.kind === 175 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 174 /* ArrayBindingPattern */ || pattern.kind === 176 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -34585,7 +35715,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 198 /* OmittedExpression */) { + if (patternElement.kind !== 199 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -34602,7 +35732,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 142 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 143 /* 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, @@ -34674,7 +35804,7 @@ var ts; var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 172 /* ObjectBindingPattern */ || contextualType.pattern.kind === 176 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 173 /* ObjectBindingPattern */ || contextualType.pattern.kind === 177 /* ObjectLiteralExpression */); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -34683,29 +35813,29 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 257 /* PropertyAssignment */ || - memberDecl.kind === 258 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 260 /* PropertyAssignment */ || + memberDecl.kind === 261 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 257 /* PropertyAssignment */) { + if (memberDecl.kind === 260 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 149 /* MethodDeclaration */) { + else if (memberDecl.kind === 150 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 258 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 261 /* ShorthandPropertyAssignment */); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; - var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | member.flags, member.name); + var prop = createSymbol(4 /* Property */ | 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 === 257 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 258 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 260 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 261 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 536870912 /* Optional */; + prop.flags |= 67108864 /* Optional */; } if (ts.hasDynamicName(memberDecl)) { patternWithComputedProperties = true; @@ -34716,7 +35846,7 @@ var ts; // 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 */; + prop.flags |= impliedProp.flags & 67108864 /* Optional */; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0 /* String */)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -34731,12 +35861,12 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 259 /* SpreadAssignment */) { - if (languageVersion < 5 /* ESNext */) { + else if (memberDecl.kind === 262 /* SpreadAssignment */) { + if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); + spread = getSpreadType(spread, createObjectLiteralType()); propertiesArray = []; propertiesTable = ts.createMap(); hasComputedStringProperty = false; @@ -34748,7 +35878,7 @@ var ts; error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } - spread = getSpreadType(spread, type, /*isFromObjectLiteral*/ false); + spread = getSpreadType(spread, type); offset = i + 1; continue; } @@ -34758,7 +35888,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 === 151 /* GetAccessor */ || memberDecl.kind === 152 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 152 /* GetAccessor */ || memberDecl.kind === 153 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -34770,7 +35900,7 @@ var ts; } } else { - propertiesTable[member.name] = member; + propertiesTable.set(member.name, member); } propertiesArray.push(member); } @@ -34779,18 +35909,18 @@ var ts; if (contextualTypeHasPattern) { for (var _i = 0, _a = getPropertiesOfType(contextualType); _i < _a.length; _i++) { var prop = _a[_i]; - if (!propertiesTable[prop.name]) { - if (!(prop.flags & 536870912 /* Optional */)) { + if (!propertiesTable.get(prop.name)) { + if (!(prop.flags & 67108864 /* 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; + propertiesTable.set(prop.name, prop); propertiesArray.push(prop); } } } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); + spread = getSpreadType(spread, createObjectLiteralType()); } if (spread.flags & 32768 /* Object */) { // only set the symbol and flags if this is a (fresh) object type @@ -34820,7 +35950,7 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (1 /* Any */ | 4096 /* Null */ | 2048 /* Undefined */) || + return !!(type.flags & (1 /* Any */ | 4096 /* Null */ | 2048 /* Undefined */ | 16777216 /* NonPrimitive */) || type.flags & 32768 /* Object */ && !isGenericMappedType(type) || type.flags & 196608 /* UnionOrIntersection */ && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } @@ -34842,13 +35972,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 252 /* JsxExpression */: + case 255 /* JsxExpression */: checkJsxExpression(child); break; - case 246 /* JsxElement */: + case 248 /* JsxElement */: checkJsxElement(child); break; - case 247 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -34867,77 +35997,105 @@ var ts; */ function isJsxIntrinsicIdentifier(tagName) { // TODO (yuisu): comment - if (tagName.kind === 177 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { + if (tagName.kind === 178 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { 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)) { - var attributeType = getTypeOfPropertyOfType(elementAttributesType, ts.getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0 /* String */); - if (attributeType) { - correspondingPropType = attributeType; + /** + * Get attributes type of the JSX opening-like element. The result is from resolving "attributes" property of the opening-like element. + * + * @param openingLikeElement a JSX opening-like element + * @param filter a function to remove attributes that will not participate in checking whether attributes are assignable + * @return an anonymous type (similar to the one returned by checkObjectLiteral) in which its properties are attributes property. + */ + function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, contextualMapper) { + var attributes = openingLikeElement.attributes; + var attributesTable = ts.createMap(); + var spread = emptyObjectType; + var attributesArray = []; + for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { + var attributeDecl = _a[_i]; + var member = attributeDecl.symbol; + if (ts.isJsxAttribute(attributeDecl)) { + var exprType = attributeDecl.initializer ? + checkExpression(attributeDecl.initializer, contextualMapper) : + trueType; // is sugar for + var attributeSymbol = createSymbol(4 /* Property */ | 134217728 /* Transient */ | member.flags, member.name); + attributeSymbol.declarations = member.declarations; + attributeSymbol.parent = member.parent; + if (member.valueDeclaration) { + attributeSymbol.valueDeclaration = member.valueDeclaration; } - 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; - } + attributeSymbol.type = exprType; + attributeSymbol.target = member; + attributesTable.set(attributeSymbol.name, attributeSymbol); + attributesArray.push(attributeSymbol); + } + else { + ts.Debug.assert(attributeDecl.kind === 254 /* JsxSpreadAttribute */); + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); } + var exprType = checkExpression(attributeDecl.expression); + if (!(exprType.flags & (32768 /* Object */ | 1 /* Any */))) { + error(attributeDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + return anyType; + } + if (isTypeAny(exprType)) { + return anyType; + } + spread = getSpreadType(spread, exprType); } } - var exprType; - if (node.initializer) { - exprType = checkExpression(node.initializer); + if (spread !== emptyObjectType) { + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); + } + attributesArray = getPropertiesOfType(spread); } - else { - // is sugar for - exprType = booleanType; + attributesTable = ts.createMap(); + if (attributesArray) { + ts.forEach(attributesArray, function (attr) { + if (!filter || filter(attr)) { + attributesTable.set(attr.name, attr); + } + }); } - if (correspondingPropType) { - checkTypeAssignableTo(exprType, correspondingPropType, node); + return createJsxAttributesType(attributes.symbol, attributesTable); + /** + * Create anonymous type from given attributes symbol table. + * @param symbol a symbol of JsxAttributes containing attributes corresponding to attributesTable + * @param attributesTable a symbol table of attributes property + */ + function createJsxAttributesType(symbol, attributesTable) { + var result = createAnonymousType(symbol, attributesTable, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshLiteral */; + result.flags |= 33554432 /* JsxAttributes */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag; + result.objectFlags |= 128 /* ObjectLiteral */; + return result; } - nameTable[node.name.text] = true; - return exprType; } - function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { - if (compilerOptions.jsx === 2 /* React */) { - checkExternalEmitHelpers(node, 2 /* Assign */); - } - var type = checkExpression(node.expression); - var props = getPropertiesOfType(type); - 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]) { - 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; + /** + * Check attributes property of opening-like element. This function is called during chooseOverload to get call signature of a JSX opening-like element. + * (See "checkApplicableSignatureForJsxOpeningLikeElement" for how the function is used) + * @param node a JSXAttributes to be resolved of its type + */ + function checkJsxAttributes(node, contextualMapper) { + return createJsxAttributesTypeFromAttributesProperty(node.parent, /*filter*/ undefined, contextualMapper); } function getJsxType(name) { - if (jsxTypes[name] === undefined) { - return jsxTypes[name] = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType; + var jsxType = jsxTypes.get(name); + if (jsxType === undefined) { + jsxTypes.set(name, jsxType = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType); } - return jsxTypes[name]; + return jsxType; } /** * Looks up an intrinsic tag name and returns a symbol that either points to an intrinsic @@ -35032,28 +36190,131 @@ var ts; } } /** - * Given React element instance type and the class type, resolve the Jsx type - * Pass elemType to handle individual type in the union typed element type. + * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. + * Return only attributes type of successfully resolved call signature. + * This function assumes that the caller handled other possible element type of the JSX element (e.g. stateful component) + * Unlike tryGetAllJsxStatelessFunctionAttributesType, this function is a default behavior of type-checkers. + * @param openingLikeElement a JSX opening-like element to find attributes type + * @param elementType a type of the opening-like element. This elementType can't be an union type + * @param elemInstanceType an element instance type (the result of newing or invoking this tag) + * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global */ - function getResolvedJsxType(node, elemType, elemClassType) { - if (!elemType) { - elemType = checkExpression(node.tagName); + function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536 /* Union */)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + if (jsxElementType) { + // We don't call getResolvedSignature here because we have already resolve the type of JSX Element. + var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, /*candidatesOutArray*/ undefined); + if (callSignature !== unknownSignature) { + var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); + var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + // Intersect in JSX.IntrinsicAttributes if it exists + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + paramType = intersectTypes(intrinsicAttributes, paramType); + } + return paramType; + } + } + } } - if (elemType.flags & 65536 /* Union */) { - var types = elemType.types; - return getUnionType(ts.map(types, function (type) { - return getResolvedJsxType(node, type, elemClassType); + return undefined; + } + /** + * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. + * Return all attributes type of resolved call signature including candidate signatures. + * This function assumes that the caller handled other possible element type of the JSX element. + * This function is a behavior used by language service when looking up completion in JSX element. + * @param openingLikeElement a JSX opening-like element to find attributes type + * @param elementType a type of the opening-like element. This elementType can't be an union type + * @param elemInstanceType an element instance type (the result of newing or invoking this tag) + * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global + */ + function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536 /* Union */)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + // Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type + if (jsxElementType) { + // We don't call getResolvedSignature because here we have already resolve the type of JSX Element. + var candidatesOutArray = []; + getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); + var result = void 0; + var allMatchingAttributesType = void 0; + for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { + var candidate = candidatesOutArray_1[_i]; + var callReturnType = getReturnTypeOfSignature(candidate); + var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + var shouldBeCandidate = true; + for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { + var attribute = _b[_a]; + if (ts.isJsxAttribute(attribute) && + isUnhyphenatedJsxName(attribute.name.text) && + !getPropertyOfType(paramType, attribute.name.text)) { + shouldBeCandidate = false; + break; + } + } + if (shouldBeCandidate) { + result = intersectTypes(result, paramType); + } + allMatchingAttributesType = intersectTypes(allMatchingAttributesType, paramType); + } + } + // If we can't find any matching, just return everything. + if (!result) { + result = allMatchingAttributesType; + } + // Intersect in JSX.IntrinsicAttributes if it exists + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + result = intersectTypes(intrinsicAttributes, result); + } + return result; + } + } + return undefined; + } + /** + * Resolve attributes type of the given opening-like element. The attributes type is a type of attributes associated with the given elementType. + * For instance: + * declare function Foo(attr: { p1: string}): JSX.Element; + * ; // This function will try resolve "Foo" and return an attributes type of "Foo" which is "{ p1: string }" + * + * The function is intended to initially be called from getAttributesTypeFromJsxOpeningLikeElement which already handle JSX-intrinsic-element.. + * This function will try to resolve custom JSX attributes type in following order: string literal, stateless function, and stateful component + * + * @param openingLikeElement a non-intrinsic JSXOPeningLikeElement + * @param shouldIncludeAllStatelessAttributesType a boolean indicating whether to include all attributes types from all stateless function signature + * @param elementType an instance type of the given opening-like element. If undefined, the function will check type openinglikeElement's tagname. + * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global (imported from react.d.ts) + * @return attributes type if able to resolve the type of node + * anyType if there is no type ElementAttributesProperty or there is an error + * emptyObjectType if there is no "prop" in the element instance type + **/ + function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { + if (!elementType) { + elementType = checkExpression(openingLikeElement.tagName); + } + if (elementType.flags & 65536 /* Union */) { + var types = elementType.types; + return getUnionType(types.map(function (type) { + return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); }), /*subtypeReduction*/ true); } // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - if (elemType.flags & 2 /* String */) { + if (elementType.flags & 2 /* String */) { return anyType; } - else if (elemType.flags & 32 /* StringLiteral */) { + else if (elementType.flags & 32 /* StringLiteral */) { // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type + // For example: + // var CustomTag: "h1" = "h1"; + // Hello World var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); if (intrinsicElementsType !== unknownType) { - var stringLiteralTypeName = elemType.text; + var stringLiteralTypeName = elementType.text; var intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName); if (intrinsicProp) { return getTypeOfSymbol(intrinsicProp); @@ -35062,34 +36323,24 @@ var ts; if (indexSignatureType) { return indexSignatureType; } - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); + error(openingLikeElement, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); } // If we need to report an error, we already done so here. So just return any to prevent any more error downstream return anyType; } // Get the element instance type (the result of newing or invoking this tag) - var elemInstanceType = getJsxElementInstanceType(node, elemType); - if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { - // Is this is a stateless function component? See if its single signature's return type is - // assignable to the JSX Element Type - if (jsxElementType) { - var callSignatures = elemType && getSignaturesOfType(elemType, 0 /* Call */); - var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { - // Intersect in JSX.IntrinsicAttributes if it exists - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); - if (intrinsicAttributes !== unknownType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } - } + var elemInstanceType = getJsxElementInstanceType(openingLikeElement, elementType); + // If we should include all stateless attributes type, then get all attributes type from all stateless function signature. + // Otherwise get only attributes type from the signature picked by choose-overload logic. + var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? + tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : + defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); + if (statelessAttributesType) { + return statelessAttributesType; } // Issue an error if this return type isn't assignable to JSX.ElementClass - if (elemClassType) { - checkTypeRelatedTo(elemInstanceType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + if (elementClassType) { + checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } if (isTypeAny(elemInstanceType)) { return elemInstanceType; @@ -35115,7 +36366,7 @@ var ts; } else if (attributesType.flags & 65536 /* Union */) { // Props cannot be a union type - error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); + error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); return anyType; } else { @@ -35142,30 +36393,68 @@ var ts; } } /** - * 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. + * Get attributes type of the given intrinsic opening-like Jsx element by resolving the tag name. + * The function is intended to be called from a function which has checked that the opening element is an intrinsic element. + * @param node an intrinsic JSX opening-like element */ - function getJsxElementAttributesType(node) { + function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) { + ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName)); var links = getNodeLinks(node); - if (!links.resolvedJsxType) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { - return links.resolvedJsxType = getTypeOfSymbol(symbol); - } - else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { - return links.resolvedJsxType = getIndexInfoOfSymbol(symbol, 0 /* String */).type; - } - else { - return links.resolvedJsxType = unknownType; - } + if (!links.resolvedJsxElementAttributesType) { + var symbol = getIntrinsicTagSymbol(node); + if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol); + } + else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + return links.resolvedJsxElementAttributesType = getIndexInfoOfSymbol(symbol, 0 /* String */).type; } else { - var elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxType = getResolvedJsxType(node, undefined, elemClassType); + return links.resolvedJsxElementAttributesType = unknownType; } } - return links.resolvedJsxType; + return links.resolvedJsxElementAttributesType; + } + /** + * Get attributes type of the given custom opening-like JSX element. + * This function is intended to be called from a caller that handles intrinsic JSX element already. + * @param node a custom JSX opening-like element + * @param shouldIncludeAllStatelessAttributesType a boolean value used by language service to get all possible attributes type from an overload stateless function component + */ + function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { + var links = getNodeLinks(node); + if (!links.resolvedJsxElementAttributesType) { + var elemClassType = getJsxGlobalElementClassType(); + return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); + } + return links.resolvedJsxElementAttributesType; + } + /** + * Get all possible attributes type, especially from an overload stateless function component, of the given JSX opening-like element. + * This function is called by language service (see: completions-tryGetGlobalSymbols). + * @param node a JSX opening-like element to get attributes type for + */ + function getAllAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + // Because in language service, the given JSX opening-like element may be incomplete and therefore, + // we can't resolve to exact signature if the element is a stateless function component so the best thing to do is return all attributes type from all overloads. + return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ true); + } + } + /** + * Get the attributes type, which indicates the attributes that are valid on the given JSXOpeningLikeElement. + * @param node a JSXOpeningLikeElement node + * @return an attributes type of the given node + */ + function getAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ false); + } } /** * Given a JSX attribute, returns the symbol for the corresponds property @@ -35173,7 +36462,7 @@ var ts; * that have no matching element attributes type property. */ function getJsxAttributePropertySymbol(attrib) { - var attributesType = getJsxElementAttributesType(attrib.parent); + var attributesType = getAttributesTypeFromJsxOpeningLikeElement(attrib.parent.parent); var prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } @@ -35183,7 +36472,9 @@ var ts; } return jsxElementClassType; } - /// Returns all the properties of the Jsx.IntrinsicElements interface + /** + * Returns all the properties of the Jsx.IntrinsicElements interface + */ function getJsxIntrinsicTagNames() { var intrinsics = getJsxType(JsxNames.IntrinsicElements); return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; @@ -35216,39 +36507,46 @@ var ts; markAliasSymbolAsReferenced(reactSym); } } - var targetAttributesType = getJsxElementAttributesType(node); - var nameTable = ts.createMap(); - // 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 === 250 /* JsxAttribute */) { - checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); - } - else { - ts.Debug.assert(node.attributes[i].kind === 251 /* JsxSpreadAttribute */); - var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); - if (isTypeAny(spreadType)) { - sawSpreadedAny = true; - } - } + checkJsxAttributesAssignableToTagNameAttributes(node); + } + /** + * Check whether the given attributes of JSX opening-like element is assignable to the tagName attributes. + * Get the attributes type of the opening-like element through resolving the tagName, "target attributes" + * Check assignablity between given attributes property, "source attributes", and the "target attributes" + * @param openingLikeElement an opening-like JSX element to check its JSXAttributes + */ + function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement) { + // The function involves following steps: + // 1. Figure out expected attributes type by resolving tagName of the JSX opening-like element, targetAttributesType. + // During these steps, we will try to resolve the tagName as intrinsic name, stateless function, stateful component (in the order) + // 2. Solved JSX attributes type given by users, sourceAttributesType, which is by resolving "attributes" property of the JSX opening-like element. + // 3. Check if the two are assignable to each other + // targetAttributesType is a type of an attributes from resolving tagName of an opening-like JSX element. + var targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? + getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : + getCustomJsxElementAttributesType(openingLikeElement, /*shouldIncludeAllStatelessAttributesType*/ false); + // sourceAttributesType is a type of an attributes properties. + // i.e
+ // attr1 and attr2 are treated as JSXAttributes attached in the JsxOpeningLikeElement as "attributes". + var sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement, function (attribute) { + return isUnhyphenatedJsxName(attribute.name) || !!(getPropertyOfType(targetAttributesType, attribute.name)); + }); + // If the targetAttributesType is an emptyObjectType, indicating that there is no property named 'props' on this instance type. + // but there exists a sourceAttributesType, we need to explicitly give an error as normal assignability check allow excess properties and will pass. + if (targetAttributesType === emptyObjectType && (isTypeAny(sourceAttributesType) || sourceAttributesType.properties.length > 0)) { + error(openingLikeElement, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); } - // 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]) { - error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); - } - } + else { + checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.attributes.properties.length > 0 ? openingLikeElement.attributes : openingLikeElement); } } - function checkJsxExpression(node) { + function checkJsxExpression(node, contextualMapper) { if (node.expression) { - return checkExpression(node.expression); + var type = checkExpression(node.expression, contextualMapper); + if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { + error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); + } + return type; } else { return unknownType; @@ -35257,10 +36555,25 @@ 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 : 147 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 148 /* PropertyDeclaration */; } function getDeclarationModifierFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 4 /* Public */ | 32 /* Static */ : 0; + if (s.valueDeclaration) { + var flags = ts.getCombinedModifierFlags(s.valueDeclaration); + return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; + } + if (getCheckFlags(s) & 2 /* SyntheticProperty */) { + var checkFlags = s.checkFlags; + var accessModifier = checkFlags & 128 /* ContainsPrivate */ ? 8 /* Private */ : + checkFlags & 32 /* ContainsPublic */ ? 4 /* Public */ : + 16 /* Protected */; + var staticModifier = checkFlags & 256 /* ContainsStatic */ ? 32 /* Static */ : 0; + return accessModifier | staticModifier; + } + if (s.flags & 16777216 /* Prototype */) { + return 4 /* Public */ | 32 /* Static */; + } + return 0; } function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; @@ -35273,12 +36586,16 @@ var ts; * @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) { + function checkPropertyAccessibility(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); - var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 /* PropertyAccessExpression */ || node.kind === 223 /* VariableDeclaration */ ? + var errorNode = node.kind === 178 /* PropertyAccessExpression */ || node.kind === 225 /* VariableDeclaration */ ? node.name : node.right; + if (getCheckFlags(prop) & 128 /* ContainsPrivate */) { + // Synthetic property with private constituent property + error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); + return false; + } if (left.kind === 96 /* SuperKeyword */) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or @@ -35287,18 +36604,21 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES2015 */ && getDeclarationKindFromSymbol(prop) !== 149 /* 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 (languageVersion < 2 /* ES2015 */) { + var propKind = getDeclarationKindFromSymbol(prop); + if (propKind !== 150 /* MethodDeclaration */ && propKind !== 149 /* MethodSignature */) { + // `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 & 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 // additional error elsewhere. - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } } @@ -35311,7 +36631,7 @@ var ts; if (flags & 8 /* Private */) { var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } return true; @@ -35321,14 +36641,15 @@ var ts; if (left.kind === 96 /* SuperKeyword */) { return true; } - // Get the enclosing class that has the declaring class as its base type + // Find the first enclosing class that has the declaring classes of the protected constituents + // of the property as base classes var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); - return hasBaseType(enclosingClass, declaringClass) ? enclosingClass : undefined; + return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; }); // A protected property is accessible if the property is within the declaring class or classes derived from it if (!enclosingClass) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); return false; } // No further restrictions for static properties @@ -35340,7 +36661,6 @@ var ts; // 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 (!(getObjectFlags(getTargetType(type)) & 3 /* ClassOrInterface */ && hasBaseType(type, enclosingClass))) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; @@ -35348,16 +36668,17 @@ var ts; return true; } function checkNonNullExpression(node) { - var type = checkExpression(node); - if (strictNullChecks) { - var kind = getFalsyFlags(type) & 6144 /* Nullable */; - if (kind) { - error(node, kind & 2048 /* Undefined */ ? kind & 4096 /* Null */ ? - ts.Diagnostics.Object_is_possibly_null_or_undefined : - ts.Diagnostics.Object_is_possibly_undefined : - ts.Diagnostics.Object_is_possibly_null); - } - return getNonNullableType(type); + return checkNonNullType(checkExpression(node), node); + } + function checkNonNullType(type, errorNode) { + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 6144 /* Nullable */; + if (kind) { + error(errorNode, kind & 2048 /* Undefined */ ? kind & 4096 /* Null */ ? + ts.Diagnostics.Object_is_possibly_null_or_undefined : + ts.Diagnostics.Object_is_possibly_undefined : + ts.Diagnostics.Object_is_possibly_null); + var t = getNonNullableType(type); + return t.flags & (6144 /* Nullable */ | 8192 /* Never */) ? unknownType : t; } return type; } @@ -35386,7 +36707,7 @@ var ts; noUnusedIdentifiers && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8 /* Private */)) { - if (prop.flags & 16777216 /* Instantiated */) { + if (getCheckFlags(prop) & 1 /* Instantiated */) { getSymbolLinks(prop).target.isReferenced = true; } else { @@ -35394,6 +36715,15 @@ var ts; } } } + function isInPropertyInitializer(node) { + while (node) { + if (node.parent && node.parent.kind === 148 /* PropertyDeclaration */ && node.parent.initializer === node) { + return true; + } + node = node.parent; + } + return false; + } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { var type = checkNonNullExpression(left); if (isTypeAny(type) || type === silentNeverType) { @@ -35406,16 +36736,23 @@ var ts; } var prop = getPropertyOfType(apparentType, right.text); if (!prop) { + var stringIndexType = getIndexTypeOfType(apparentType, 0 /* String */); + if (stringIndexType) { + return stringIndexType; + } if (right.text && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, type.flags & 16384 /* TypeParameter */ && type.isThisType ? apparentType : type); } return unknownType; } + if (prop.valueDeclaration && + isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + } markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; - if (prop.parent && prop.parent.flags & 32 /* Class */) { - checkClassPropertyAccess(node, left, apparentType, prop); - } + checkPropertyAccessibility(node, left, apparentType, prop); var propType = getTypeOfSymbol(prop); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { @@ -35427,7 +36764,7 @@ var ts; // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. - if (node.kind !== 177 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || + if (node.kind !== 178 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 65536 /* Union */)) { return propType; @@ -35436,14 +36773,14 @@ var ts; return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 177 /* PropertyAccessExpression */ + var left = node.kind === 178 /* 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); + if (prop) { + return checkPropertyAccessibility(node, left, type, prop); } } return true; @@ -35453,7 +36790,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 224 /* VariableDeclarationList */) { + if (initializer.kind === 226 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -35482,7 +36819,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 212 /* ForInStatement */ && + if (node.kind === 214 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -35500,7 +36837,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 180 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 181 /* 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); @@ -35520,7 +36857,7 @@ var ts; error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } - return getIndexedAccessType(objectType, indexType, node); + return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === unknownType) { @@ -35558,10 +36895,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 181 /* TaggedTemplateExpression */) { + if (node.kind === 182 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 145 /* Decorator */) { + else if (node.kind !== 146 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -35591,13 +36928,13 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_8 = signature.declaration && signature.declaration.parent; + var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_8 === lastParent) { + if (lastParent && parent === lastParent) { index++; } else { - lastParent = parent_8; + lastParent = parent; index = cutoffIndex; } } @@ -35605,7 +36942,7 @@ var ts; // current declaration belongs to a different symbol // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex index = cutoffIndex = result.length; - lastParent = parent_8; + lastParent = parent; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -35627,7 +36964,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 196 /* SpreadElement */) { + if (arg && arg.kind === 197 /* SpreadElement */) { return i; } } @@ -35640,13 +36977,17 @@ 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 === 181 /* TaggedTemplateExpression */) { + if (ts.isJsxOpeningLikeElement(node)) { + // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". + return true; + } + if (node.kind === 182 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 194 /* TemplateExpression */) { + if (tagExpression.template.kind === 195 /* 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; @@ -35663,7 +37004,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 145 /* Decorator */) { + else if (node.kind === 146 /* Decorator */) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -35672,19 +37013,21 @@ 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 === 180 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 181 /* NewExpression */); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; - // If we are missing the close paren, the call is incomplete. + // If we are missing the close parenthesis, 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 numTypeParameters = ts.length(signature.typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters); var hasRightNumberOfTypeArgs = !typeArguments || - (signature.typeParameters && typeArguments.length === signature.typeParameters.length); + (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters); if (!hasRightNumberOfTypeArgs) { return false; } @@ -35756,7 +37099,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 !== 198 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 199 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -35791,7 +37134,7 @@ var ts; var typeParameters = signature.typeParameters; var typeArgumentsAreAssignable = true; var mapper; - for (var i = 0; i < typeParameters.length; i++) { + for (var i = 0; i < typeArgumentNodes.length; i++) { if (typeArgumentsAreAssignable /* so far */) { var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { @@ -35811,9 +37154,44 @@ var ts; } return typeArgumentsAreAssignable; } + /** + * Check if the given signature can possibly be a signature called by the JSX opening-like element. + * @param node a JSX opening-like element we are trying to figure its call signature + * @param signature a candidate signature we are trying whether it is a call signature + * @param relation a relationship to check parameter and argument type + * @param excludeArgument + */ + function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation) { + // JSX opening-like element has correct arity for stateless-function component if the one of the following condition is true: + // 1. callIsIncomplete + // 2. attributes property has same number of properties as the parameter object type. + // We can figure that out by resolving attributes property and check number of properties in the resolved type + // If the call has correct arity, we will then check if the argument type and parameter type is assignable + var callIsIncomplete = node.attributes.end === node.end; // If we are missing the close "/>", the call is incomplete + if (callIsIncomplete) { + return true; + } + var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + // Stateless function components can have maximum of three arguments: "props", "context", and "updater". + // However "context" and "updater" are implicit and can't be specify by users. Only the first parameter, props, + // can be specified by users through attributes property. + var paramType = getTypeAtPosition(signature, 0); + var attributesType = checkExpressionWithContextualType(node.attributes, paramType, /*contextualMapper*/ undefined); + var argProperties = getPropertiesOfType(attributesType); + for (var _i = 0, argProperties_1 = argProperties; _i < argProperties_1.length; _i++) { + var arg = argProperties_1[_i]; + if (!getPropertyOfType(paramType, arg.name) && isUnhyphenatedJsxName(arg.name)) { + return false; + } + } + return checkTypeRelatedTo(attributesType, paramType, relation, /*errorNode*/ undefined, headMessage); + } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { + if (ts.isJsxOpeningLikeElement(node)) { + return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); + } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 180 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 181 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -35830,7 +37208,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 !== 198 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 199 /* 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); @@ -35852,12 +37230,12 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 179 /* CallExpression */) { + if (node.kind === 180 /* CallExpression */) { var callee = node.expression; - if (callee.kind === 177 /* PropertyAccessExpression */) { + if (callee.kind === 178 /* PropertyAccessExpression */) { return callee.expression; } - else if (callee.kind === 178 /* ElementAccessExpression */) { + else if (callee.kind === 179 /* ElementAccessExpression */) { return callee.expression; } } @@ -35873,21 +37251,24 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 181 /* TaggedTemplateExpression */) { + if (node.kind === 182 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 194 /* TemplateExpression */) { + if (template.kind === 195 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 145 /* Decorator */) { + else if (node.kind === 146 /* 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 if (ts.isJsxOpeningLikeElement(node)) { + args = node.attributes.properties.length > 0 ? [node.attributes] : emptyArray; + } else { args = node.arguments || emptyArray; } @@ -35907,19 +37288,19 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 145 /* Decorator */) { + if (node.kind === 146 /* Decorator */) { switch (node.parent.kind) { - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* 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. @@ -35929,7 +37310,7 @@ var ts; // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 144 /* Parameter */: + case 145 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -35953,25 +37334,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 228 /* 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 === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 150 /* Constructor */) { + if (node.kind === 151 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 147 /* PropertyDeclaration */ || - node.kind === 149 /* MethodDeclaration */ || - node.kind === 151 /* GetAccessor */ || - node.kind === 152 /* SetAccessor */) { + if (node.kind === 148 /* PropertyDeclaration */ || + node.kind === 150 /* MethodDeclaration */ || + node.kind === 152 /* GetAccessor */ || + node.kind === 153 /* 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 @@ -35998,21 +37379,23 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 228 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { node = node.parent; - if (node.kind === 150 /* Constructor */) { + if (node.kind === 151 /* 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. } - if (node.kind === 147 /* PropertyDeclaration */ || - node.kind === 149 /* MethodDeclaration */ || - node.kind === 151 /* GetAccessor */ || - node.kind === 152 /* SetAccessor */) { + if (node.kind === 148 /* PropertyDeclaration */ || + node.kind === 150 /* MethodDeclaration */ || + node.kind === 152 /* GetAccessor */ || + node.kind === 153 /* 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 @@ -36023,7 +37406,7 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getLiteralTypeForText(32 /* StringLiteral */, element.name.text); - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512 /* ESSymbol */)) { return nameType; @@ -36049,21 +37432,21 @@ var ts; function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a parameter decorator - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 228 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 147 /* PropertyDeclaration */) { + if (node.kind === 148 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 149 /* MethodDeclaration */ || - node.kind === 151 /* GetAccessor */ || - node.kind === 152 /* SetAccessor */) { + if (node.kind === 150 /* MethodDeclaration */ || + node.kind === 152 /* GetAccessor */ || + node.kind === 153 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -36095,10 +37478,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 === 145 /* Decorator */) { + if (node.kind === 146 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 181 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 182 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -36110,8 +37493,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 === 145 /* Decorator */ || - (argIndex === 0 && node.kind === 181 /* TaggedTemplateExpression */)) { + if (node.kind === 146 /* Decorator */ || + (argIndex === 0 && node.kind === 182 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -36120,11 +37503,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 145 /* Decorator */) { + if (node.kind === 146 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 181 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 182 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -36133,10 +37516,11 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 181 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 145 /* Decorator */; + var isTaggedTemplate = node.kind === 182 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 146 /* Decorator */; + var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; - if (!isTaggedTemplate && !isDecorator) { + if (!isTaggedTemplate && !isDecorator && !isJsxOpeningOrSelfClosingElement) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. if (node.expression.kind !== 96 /* SuperKeyword */) { @@ -36205,7 +37589,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 179 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 180 /* CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -36234,6 +37618,10 @@ var ts; // If candidate is undefined, it means that no candidates had a suitable arity. In that case, // skip the checkApplicableSignature check. if (candidateForArgumentError) { + if (isJsxOpeningOrSelfClosingElement) { + // We do not report any error here because any error will be handled in "resolveCustomJsxElementAttributesType". + return 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 @@ -36255,7 +37643,7 @@ var ts; if (headMessage) { diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); } - reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); + reportNoCommonSupertypeError(inferenceCandidates, node.tagName || node.expression || node.tag, diagnosticChainHead); } } else { @@ -36303,13 +37691,13 @@ var ts; if (candidate.typeParameters) { var typeArgumentTypes = void 0; if (typeArguments) { - typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNode); + typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); } else { inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); - typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; typeArgumentTypes = inferenceContext.inferredTypes; + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; } if (!typeArgumentsAreValid) { break; @@ -36554,16 +37942,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 144 /* Parameter */: + case 145 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -36591,21 +37979,73 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray, headMessage); } + /** + * This function is similar to getResolvedSignature but is exclusively for trying to resolve JSX stateless-function component. + * The main reason we have to use this function instead of getResolvedSignature because, the caller of this function will already check the type of openingLikeElement's tagName + * and pass the type as elementType. The elementType can not be a union (as such case should be handled by the caller of this function) + * Note: at this point, we are still not sure whether the opening-like element is a stateless function component or not. + * @param openingLikeElement an opening-like JSX element to try to resolve as JSX stateless function + * @param elementType an element type of the opneing-like element by checking opening-like element's tagname. + * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; + * the function will fill it up with appropriate candidate signatures + */ + function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray) { + ts.Debug.assert(!(elementType.flags & 65536 /* Union */)); + var callSignature = resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray); + return callSignature; + } + /** + * Try treating a given opening-like element as stateless function component and resolve a tagName to a function signature. + * @param openingLikeElement an JSX opening-like element we want to try resolve its stateless function if possible + * @param elementType a type of the opening-like JSX element, a result of resolving tagName in opening-like element. + * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; + * the function will fill it up with appropriate candidate signatures + * @return a resolved signature if we can find function matching function signature through resolve call or a first signature in the list of functions. + * otherwise return undefined if tag-name of the opening-like element doesn't have call signatures + */ + function resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray) { + // If this function is called from language service, elementType can be a union type. This is not possible if the function is called from compiler (see: resolveCustomJsxElementAttributesType) + if (elementType.flags & 65536 /* Union */) { + var types = elementType.types; + var result = void 0; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; + result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); + } + return result; + } + var callSignatures = elementType && getSignaturesOfType(elementType, 0 /* Call */); + if (callSignatures && callSignatures.length > 0) { + var callSignature = void 0; + callSignature = resolveCall(openingLikeElement, callSignatures, candidatesOutArray); + return callSignature; + } + return undefined; + } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 179 /* CallExpression */: + case 180 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 145 /* Decorator */: + case 146 /* Decorator */: return resolveDecorator(node, candidatesOutArray); + case 250 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + // This code-path is called by language service + return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); } - // candidatesOutArray is passed by signature help in the language service, and collectCandidates - // must fill it up with the appropriate candidate signatures + /** + * Resolve a signature of a given call-like expression. + * @param node a call-like expression to try resolve a signature for + * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; + * the function will fill it up with appropriate candidate signatures + * @return a signature of the call-like expression or undefined if one can't be found + */ function getResolvedSignature(node, candidatesOutArray) { var links = getNodeLinks(node); // If getResolvedSignature has already been called, we will have cached the resolvedSignature. @@ -36648,12 +38088,12 @@ var ts; if (node.expression.kind === 96 /* SuperKeyword */) { return voidType; } - if (node.kind === 180 /* NewExpression */) { + if (node.kind === 181 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 150 /* Constructor */ && - declaration.kind !== 154 /* ConstructSignature */ && - declaration.kind !== 159 /* ConstructorType */ && + declaration.kind !== 151 /* Constructor */ && + declaration.kind !== 155 /* ConstructSignature */ && + declaration.kind !== 160 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations @@ -36693,9 +38133,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 225 /* FunctionDeclaration */ + ? 227 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 223 /* VariableDeclaration */ + ? 225 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -36722,6 +38162,23 @@ var ts; function checkNonNullAssertion(node) { return getNonNullableType(checkExpression(node.expression)); } + function checkMetaProperty(node) { + checkGrammarMetaProperty(node); + ts.Debug.assert(node.keywordToken === 93 /* NewKeyword */ && node.name.text === "target", "Unrecognized meta-property."); + var container = ts.getNewTargetContainer(node); + if (!container) { + error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); + return unknownType; + } + else if (container.kind === 151 /* Constructor */) { + var symbol = getSymbolOfNode(container.parent); + return getTypeOfSymbol(symbol); + } + else { + var symbol = getSymbolOfNode(container); + return getTypeOfSymbol(symbol); + } + } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks) { @@ -36751,7 +38208,7 @@ var ts; var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { if (!parameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + signature.thisParameter = createSymbolWithType(context.thisParameter, undefined); } assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } @@ -36792,8 +38249,8 @@ var ts; links.type = instantiateType(contextualType, mapper); // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 172 /* ObjectBindingPattern */ || - parameter.valueDeclaration.name.kind === 173 /* ArrayBindingPattern */)) { + (parameter.valueDeclaration.name.kind === 173 /* ObjectBindingPattern */ || + parameter.valueDeclaration.name.kind === 174 /* ArrayBindingPattern */)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -36854,6 +38311,9 @@ var ts; error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } + else if (!getGlobalPromiseConstructorSymbol()) { + error(func, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } return promiseType; } function getReturnTypeFromBody(func, contextualMapper) { @@ -36863,7 +38323,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 204 /* Block */) { + if (func.body.kind !== 206 /* 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 @@ -36953,7 +38413,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 218 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 220 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -36986,7 +38446,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 184 /* FunctionExpression */ || func.kind === 185 /* ArrowFunction */)) { + func.kind === 185 /* FunctionExpression */ || func.kind === 186 /* ArrowFunction */)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -37015,7 +38475,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (ts.nodeIsMissing(func.body) || func.body.kind !== 204 /* Block */ || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 206 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -37048,10 +38508,10 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 184 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 185 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -37092,14 +38552,15 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 149 /* MethodDeclaration */) { + if (produceDiagnostics && node.kind !== 150 /* MethodDeclaration */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -37115,7 +38576,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 204 /* Block */) { + if (node.body.kind === 206 /* Block */) { checkSourceElement(node.body); } else { @@ -37152,21 +38613,21 @@ var ts; // Get accessors without matching set accessors // Enum members // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) - return symbol.isReadonly || - symbol.flags & 4 /* Property */ && (getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */) !== 0 || - symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0 || + return !!(getCheckFlags(symbol) & 4 /* Readonly */ || + symbol.flags & 4 /* Property */ && getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || + symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */ || symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || - (symbol.flags & 8 /* EnumMember */) !== 0; + symbol.flags & 8 /* EnumMember */); } function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 177 /* PropertyAccessExpression */ || expr.kind === 178 /* ElementAccessExpression */) && + (expr.kind === 178 /* PropertyAccessExpression */ || expr.kind === 179 /* ElementAccessExpression */) && expr.expression.kind === 98 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 150 /* Constructor */)) + if (!(func && func.kind === 151 /* Constructor */)) return true; // If func.parent is a class and symbol is a (readonly) property of that class, or // if func is a constructor and symbol is a (readonly) parameter property declared in it, @@ -37178,13 +38639,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 177 /* PropertyAccessExpression */ || expr.kind === 178 /* ElementAccessExpression */) { + if (expr.kind === 178 /* PropertyAccessExpression */ || expr.kind === 179 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); if (node.kind === 70 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 237 /* NamespaceImport */; + return declaration && declaration.kind === 239 /* NamespaceImport */; } } } @@ -37193,7 +38654,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipParentheses(expr); - if (node.kind !== 70 /* Identifier */ && node.kind !== 177 /* PropertyAccessExpression */ && node.kind !== 178 /* ElementAccessExpression */) { + if (node.kind !== 70 /* Identifier */ && node.kind !== 178 /* PropertyAccessExpression */ && node.kind !== 179 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -37201,11 +38662,21 @@ var ts; } function checkDeleteExpression(node) { checkExpression(node.expression); + var expr = ts.skipParentheses(node.expression); + if (expr.kind !== 178 /* PropertyAccessExpression */ && expr.kind !== 179 /* ElementAccessExpression */) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); + return booleanType; + } + var links = getNodeLinks(expr); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol && isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } return booleanType; } function checkTypeOfExpression(node) { checkExpression(node.expression); - return stringType; + return typeofType; } function checkVoidExpression(node) { checkExpression(node.expression); @@ -37236,6 +38707,7 @@ var ts; case 36 /* PlusToken */: case 37 /* MinusToken */: case 51 /* TildeToken */: + checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 512 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } @@ -37247,7 +38719,7 @@ var ts; booleanType; case 42 /* PlusPlusToken */: case 43 /* MinusMinusToken */: - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); @@ -37261,7 +38733,7 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); @@ -37276,8 +38748,8 @@ var ts; } if (type.flags & 196608 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -37294,8 +38766,8 @@ var ts; } if (type.flags & 65536 /* Union */) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var t = types_19[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -37304,8 +38776,8 @@ var ts; } if (type.flags & 131072 /* Intersection */) { var types = type.types; - for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { - var t = types_17[_a]; + for (var _a = 0, types_20 = types; _a < types_20.length; _a++) { + var t = types_20[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -37325,14 +38797,17 @@ var ts; } // 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. + // and the right operand to be of type Any, a subtype of the 'Function' interface type, or have a call or construct signature. // 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 (isTypeOfKind(leftType, 8190 /* 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))) { + if (!(isTypeAny(rightType) || + getSignaturesOfType(rightType, 0 /* Call */).length || + getSignaturesOfType(rightType, 1 /* Construct */).length || + 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; @@ -37341,6 +38816,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); // 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. @@ -37363,22 +38840,22 @@ var ts; } /** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 257 /* PropertyAssignment */ || property.kind === 258 /* ShorthandPropertyAssignment */) { - var name_20 = property.name; - if (name_20.kind === 142 /* ComputedPropertyName */) { - checkComputedPropertyName(name_20); + if (property.kind === 260 /* PropertyAssignment */ || property.kind === 261 /* ShorthandPropertyAssignment */) { + var name = property.name; + if (name.kind === 143 /* ComputedPropertyName */) { + checkComputedPropertyName(name); } - if (isComputedNonLiteralName(name_20)) { + if (isComputedNonLiteralName(name)) { return undefined; } - var text = ts.getTextOfPropertyName(name_20); + var text = ts.getTextOfPropertyName(name); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 258 /* ShorthandPropertyAssignment */) { + if (property.kind === 261 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -37387,10 +38864,10 @@ var ts; } } else { - error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 259 /* SpreadAssignment */) { + else if (property.kind === 262 /* SpreadAssignment */) { if (languageVersion < 5 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -37421,8 +38898,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 198 /* OmittedExpression */) { - if (element.kind !== 196 /* SpreadElement */) { + if (element.kind !== 199 /* OmittedExpression */) { + if (element.kind !== 197 /* SpreadElement */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -37450,7 +38927,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 192 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { + if (restExpression.kind === 193 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -37463,7 +38940,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 258 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 261 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -37479,21 +38956,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 192 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { + if (target.kind === 193 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 176 /* ObjectLiteralExpression */) { + if (target.kind === 177 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 175 /* ArrayLiteralExpression */) { + if (target.kind === 176 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 259 /* SpreadAssignment */ ? + var error = target.parent.kind === 262 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -37515,35 +38992,35 @@ var ts; case 70 /* Identifier */: case 9 /* StringLiteral */: case 11 /* RegularExpressionLiteral */: - case 181 /* TaggedTemplateExpression */: - case 194 /* TemplateExpression */: + case 182 /* TaggedTemplateExpression */: + case 195 /* TemplateExpression */: case 12 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: case 94 /* NullKeyword */: - case 137 /* UndefinedKeyword */: - case 184 /* FunctionExpression */: - case 197 /* ClassExpression */: - case 185 /* ArrowFunction */: - case 175 /* ArrayLiteralExpression */: - case 176 /* ObjectLiteralExpression */: - case 187 /* TypeOfExpression */: - case 201 /* NonNullExpression */: - case 247 /* JsxSelfClosingElement */: - case 246 /* JsxElement */: + case 138 /* UndefinedKeyword */: + case 185 /* FunctionExpression */: + case 198 /* ClassExpression */: + case 186 /* ArrowFunction */: + case 176 /* ArrayLiteralExpression */: + case 177 /* ObjectLiteralExpression */: + case 188 /* TypeOfExpression */: + case 202 /* NonNullExpression */: + case 249 /* JsxSelfClosingElement */: + case 248 /* JsxElement */: return true; - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -37555,9 +39032,9 @@ var ts; } return false; // Some forms listed here for clarity - case 188 /* VoidExpression */: // Explicit opt-out - case 182 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 200 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 189 /* VoidExpression */: // Explicit opt-out + case 183 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 201 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -37577,7 +39054,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 57 /* EqualsToken */ && (left.kind === 176 /* ObjectLiteralExpression */ || left.kind === 175 /* ArrayLiteralExpression */)) { + if (operator === 57 /* EqualsToken */ && (left.kind === 177 /* ObjectLiteralExpression */ || left.kind === 176 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -37608,18 +39085,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - // 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 & 6144 /* Nullable */) - leftType = rightType; - if (rightType.flags & 6144 /* Nullable */) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion @@ -37642,16 +39109,10 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - // 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 & 6144 /* Nullable */) - leftType = rightType; - if (rightType.flags & 6144 /* Nullable */) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + if (!isTypeOfKind(leftType, 1 /* Any */ | 262178 /* StringLike */) && !isTypeOfKind(rightType, 1 /* Any */ | 262178 /* StringLike */)) { + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); + } var resultType = void 0; if (isTypeOfKind(leftType, 340 /* NumberLike */) && isTypeOfKind(rightType, 340 /* NumberLike */)) { // Operands of an enum type are treated as having the primitive type Number. @@ -37686,8 +39147,8 @@ var ts; case 29 /* LessThanEqualsToken */: case 30 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { - leftType = getBaseTypeOfLiteralType(leftType); - rightType = getBaseTypeOfLiteralType(rightType); + leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); + rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } @@ -37879,7 +39340,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 182 /* TypeAssertionExpression */ || node.kind === 200 /* AsExpression */; + return node.kind === 183 /* TypeAssertionExpression */ || node.kind === 201 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -37890,14 +39351,14 @@ var ts; function isLiteralContextualType(contextualType) { if (contextualType) { if (contextualType.flags & 540672 /* TypeVariable */) { - var apparentType = getApparentTypeOfTypeVariable(contextualType); + var constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; // If the type parameter is constrained to the base primitive type we're checking for, // consider this a literal context. For example, given a type parameter 'T extends string', // this causes us to infer string literal types for T. - if (apparentType.flags & (2 /* String */ | 4 /* Number */ | 8 /* Boolean */ | 16 /* Enum */)) { + if (constraint.flags & (2 /* String */ | 4 /* Number */ | 8 /* Boolean */ | 16 /* Enum */)) { return true; } - contextualType = apparentType; + contextualType = constraint; } return maybeTypeOfKind(contextualType, (480 /* Literal */ | 262144 /* Index */)); } @@ -37911,7 +39372,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 === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); @@ -37922,7 +39383,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 === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -37948,7 +39409,7 @@ var ts; function getTypeOfExpression(node) { // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (node.kind === 179 /* CallExpression */ && node.expression.kind !== 96 /* SuperKeyword */) { + if (node.kind === 180 /* CallExpression */ && node.expression.kind !== 96 /* SuperKeyword */) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -37969,7 +39430,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 141 /* QualifiedName */) { + if (node.kind === 142 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -37981,9 +39442,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 177 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 178 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 70 /* Identifier */ || node.kind === 141 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 179 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 70 /* Identifier */ || node.kind === 142 /* 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); } @@ -38005,66 +39466,70 @@ var ts; case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: return checkLiteralExpression(node); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* NoSubstitutionTemplateLiteral */: return stringType; case 11 /* RegularExpressionLiteral */: return globalRegExpType; - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 179 /* CallExpression */: - case 180 /* NewExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: return checkCallExpression(node); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return checkClassExpression(node); - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 187 /* TypeOfExpression */: + case 188 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: return checkAssertion(node); - case 201 /* NonNullExpression */: + case 202 /* NonNullExpression */: return checkNonNullAssertion(node); - case 186 /* DeleteExpression */: + case 203 /* MetaProperty */: + return checkMetaProperty(node); + case 187 /* DeleteExpression */: return checkDeleteExpression(node); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return checkVoidExpression(node); - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: return checkAwaitExpression(node); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return checkSpreadExpression(node, contextualMapper); - case 198 /* OmittedExpression */: + case 199 /* OmittedExpression */: return undefinedWideningType; - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return checkYieldExpression(node); - case 252 /* JsxExpression */: - return checkJsxExpression(node); - case 246 /* JsxElement */: + case 255 /* JsxExpression */: + return checkJsxExpression(node, contextualMapper); + case 248 /* JsxElement */: return checkJsxElement(node); - case 247 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 248 /* JsxOpeningElement */: + case 253 /* JsxAttributes */: + return checkJsxAttributes(node, contextualMapper); + case 250 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -38076,7 +39541,16 @@ var ts; grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); } checkSourceElement(node.constraint); - getConstraintOfTypeParameter(getDeclaredTypeOfTypeParameter(getSymbolOfNode(node))); + checkSourceElement(node.default); + var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); + if (!hasNonCircularBaseConstraint(typeParameter)) { + error(node.constraint, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); + } + var constraintType = getConstraintOfTypeParameter(typeParameter); + var defaultType = getDefaultFromTypeParameter(typeParameter); + if (constraintType && defaultType) { + checkTypeAssignableTo(defaultType, getTypeWithThisArgument(constraintType, defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } @@ -38092,7 +39566,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92 /* ParameterPropertyModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 150 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 151 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -38103,7 +39577,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 150 /* Constructor */ || func.kind === 154 /* ConstructSignature */ || func.kind === 159 /* ConstructorType */) { + if (func.kind === 151 /* Constructor */ || func.kind === 155 /* ConstructSignature */ || func.kind === 160 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -38117,9 +39591,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 149 /* MethodDeclaration */ || - node.kind === 225 /* FunctionDeclaration */ || - node.kind === 184 /* FunctionExpression */; + return node.kind === 150 /* MethodDeclaration */ || + node.kind === 227 /* FunctionDeclaration */ || + node.kind === 185 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -38162,9 +39636,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_21 = _a[_i].name; - if (ts.isBindingPattern(name_21) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_21, parameterName, typePredicate.parameterName)) { + var name = _a[_i].name; + if (ts.isBindingPattern(name) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -38177,16 +39651,16 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 185 /* ArrowFunction */: - case 153 /* CallSignature */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 158 /* FunctionType */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - var parent_9 = node.parent; - if (node === parent_9.type) { - return parent_9; + case 186 /* ArrowFunction */: + case 154 /* CallSignature */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 159 /* FunctionType */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + var parent = node.parent; + if (node === parent.type) { + return parent; } } } @@ -38196,15 +39670,15 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_22 = element.name; - if (name_22.kind === 70 /* Identifier */ && - name_22.text === predicateVariableName) { + var name = element.name; + if (name.kind === 70 /* Identifier */ && + name.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_22.kind === 173 /* ArrayBindingPattern */ || - name_22.kind === 172 /* ObjectBindingPattern */) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, predicateVariableNode, predicateVariableName)) { + else if (name.kind === 174 /* ArrayBindingPattern */ || + name.kind === 173 /* ObjectBindingPattern */) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } } @@ -38212,12 +39686,12 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 155 /* IndexSignature */) { + if (node.kind === 156 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 /* FunctionType */ || node.kind === 225 /* FunctionDeclaration */ || node.kind === 159 /* ConstructorType */ || - node.kind === 153 /* CallSignature */ || node.kind === 150 /* Constructor */ || - node.kind === 154 /* ConstructSignature */) { + else if (node.kind === 159 /* FunctionType */ || node.kind === 227 /* FunctionDeclaration */ || node.kind === 160 /* ConstructorType */ || + node.kind === 154 /* CallSignature */ || node.kind === 151 /* Constructor */ || + node.kind === 155 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } if (ts.isAsyncFunctionLike(node) && languageVersion < 4 /* ES2017 */) { @@ -38235,10 +39709,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 153 /* CallSignature */: + case 154 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -38271,17 +39745,18 @@ var ts; } } function checkClassForDuplicateDeclarations(node) { - var Accessor; - (function (Accessor) { - Accessor[Accessor["Getter"] = 1] = "Getter"; - Accessor[Accessor["Setter"] = 2] = "Setter"; - Accessor[Accessor["Property"] = 3] = "Property"; - })(Accessor || (Accessor = {})); + var Declaration; + (function (Declaration) { + Declaration[Declaration["Getter"] = 1] = "Getter"; + Declaration[Declaration["Setter"] = 2] = "Setter"; + Declaration[Declaration["Method"] = 4] = "Method"; + Declaration[Declaration["Property"] = 3] = "Property"; + })(Declaration || (Declaration = {})); var instanceNames = ts.createMap(); var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150 /* Constructor */) { + if (member.kind === 151 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -38290,36 +39765,76 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114 /* StaticKeyword */; }); + var isStatic = ts.getModifierFlags(member) & 32 /* Static */; var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: addName(names, member.name, memberName, 1 /* Getter */); break; - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: addName(names, member.name, memberName, 2 /* Setter */); break; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: addName(names, member.name, memberName, 3 /* Property */); break; + case 150 /* MethodDeclaration */: + addName(names, member.name, memberName, 4 /* Method */); + break; } } } } function addName(names, location, name, meaning) { - var prev = names[name]; + var prev = names.get(name); if (prev) { - if (prev & meaning) { + if (prev & 4 /* Method */) { + if (meaning !== 4 /* Method */) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + } + else if (prev & meaning) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { - names[name] = prev | meaning; + names.set(name, prev | meaning); } } else { - names[name] = meaning; + names.set(name, meaning); + } + } + } + /** + * Static members being set on a constructor function may conflict with built-in properties + * of Function. Esp. in ECMAScript 5 there are non-configurable and non-writable + * built-in properties. This check issues a transpile error when a class has a static + * member with the same name as a non-writable built-in property. + * + * @see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.3 + * @see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.5 + * @see http://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-the-function-constructor + * @see http://www.ecma-international.org/ecma-262/6.0/#sec-function-instances + */ + function checkClassForStaticPropertyNameConflicts(node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + var memberNameNode = member.name; + var isStatic = ts.getModifierFlags(member) & 32 /* Static */; + if (isStatic && memberNameNode) { + var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode); + switch (memberName) { + case "name": + case "length": + case "caller": + case "arguments": + case "prototype": + var message = ts.Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1; + var className = getNameOfSymbol(getSymbolOfNode(node)); + error(memberNameNode, message, memberName, className); + break; + } } } } @@ -38327,7 +39842,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 146 /* PropertySignature */) { + if (member.kind == 147 /* PropertySignature */) { var memberName = void 0; switch (member.name.kind) { case 9 /* StringLiteral */: @@ -38338,18 +39853,18 @@ var ts; default: continue; } - if (names[memberName]) { + if (names.get(memberName)) { error(member.symbol.valueDeclaration.name, ts.Diagnostics.Duplicate_identifier_0, memberName); error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName); } else { - names[memberName] = true; + names.set(memberName, true); } } } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 227 /* InterfaceDeclaration */) { + if (node.kind === 229 /* 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 @@ -38369,7 +39884,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -38445,12 +39960,12 @@ var ts; if (n.kind === 98 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 /* FunctionExpression */ && n.kind !== 225 /* FunctionDeclaration */) { + else if (n.kind !== 185 /* FunctionExpression */ && n.kind !== 227 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 147 /* PropertyDeclaration */ && + return n.kind === 148 /* PropertyDeclaration */ && !(ts.getModifierFlags(n) & 32 /* Static */) && !!n.initializer; } @@ -38480,7 +39995,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -38504,7 +40019,7 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 151 /* GetAccessor */) { + if (node.kind === 152 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -38514,13 +40029,13 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 151 /* GetAccessor */ ? 152 /* SetAccessor */ : 151 /* GetAccessor */; + var otherKind = node.kind === 152 /* GetAccessor */ ? 153 /* SetAccessor */ : 152 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28 /* AccessibilityModifier */) !== (ts.getModifierFlags(otherAccessor) & 28 /* AccessibilityModifier */)) { @@ -38536,11 +40051,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 151 /* GetAccessor */) { + if (node.kind === 152 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 176 /* ObjectLiteralExpression */) { + if (node.parent.kind !== 177 /* ObjectLiteralExpression */) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -38563,6 +40078,7 @@ var ts; checkDecorators(node); } function checkTypeArgumentConstraints(typeParameters, typeArgumentNodes) { + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); var typeArguments; var mapper; var result = true; @@ -38570,7 +40086,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -38623,16 +40139,36 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessIndexType(type, accessNode) { + if (!(type.flags & 524288 /* IndexedAccess */)) { + return type; + } + // Check if the index type is assignable to 'keyof T' for the object type. + var objectType = type.objectType; + var indexType = type.indexType; + if (isTypeAssignableTo(indexType, getIndexType(objectType))) { + return type; + } + // Check if we're indexing with a numeric type and the object type is a generic + // type with a constraint that has a numeric index signature. + if (maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && isTypeOfKind(indexType, 340 /* NumberLike */)) { + var constraint = getBaseConstraintOfType(objectType); + if (constraint && getIndexInfoOfType(constraint, 1 /* Number */)) { + return type; + } + } + error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); + return type; + } function checkIndexedAccessType(node) { - getTypeFromIndexedAccessTypeNode(node); + checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node) { checkSourceElement(node.typeParameter); checkSourceElement(node.type); var type = getTypeFromMappedTypeNode(node); var constraintType = getConstraintTypeFromMappedType(type); - var keyType = constraintType.flags & 540672 /* TypeVariable */ ? getApparentTypeOfTypeVariable(constraintType) : constraintType; - checkTypeAssignableTo(keyType, stringType, node.typeParameter.constraint); + checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node) { return (ts.getModifierFlags(node) & 8 /* Private */) && ts.isInAmbientContext(node); @@ -38641,9 +40177,9 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 227 /* InterfaceDeclaration */ && - n.parent.kind !== 226 /* ClassDeclaration */ && - n.parent.kind !== 197 /* ClassExpression */ && + if (n.parent.kind !== 229 /* InterfaceDeclaration */ && + n.parent.kind !== 228 /* ClassDeclaration */ && + n.parent.kind !== 198 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported @@ -38731,7 +40267,7 @@ var ts; var errorNode_1 = subsequentNode.name || subsequentNode; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */) && + var reportError = (node.kind === 150 /* MethodDeclaration */ || node.kind === 149 /* MethodSignature */) && (ts.getModifierFlags(node) & 32 /* Static */) !== (ts.getModifierFlags(subsequentNode) & 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -38766,11 +40302,11 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var current = declarations_4[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var current = declarations_5[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 227 /* InterfaceDeclaration */ || node.parent.kind === 161 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 229 /* InterfaceDeclaration */ || node.parent.kind === 162 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -38781,7 +40317,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 === 225 /* FunctionDeclaration */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */ || node.kind === 150 /* Constructor */) { + if (node.kind === 227 /* FunctionDeclaration */ || node.kind === 150 /* MethodDeclaration */ || node.kind === 149 /* MethodSignature */ || node.kind === 151 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -38903,16 +40439,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -38924,7 +40460,8 @@ var ts; } function checkNonThenableType(type, location, message) { type = getWidenedType(type); - if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + var apparentType = getApparentType(type); + if ((apparentType.flags & (1 /* Any */ | 8192 /* Never */)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -39140,7 +40677,12 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; if (promiseConstructorType === unknownType) { - error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + if (promiseConstructorName.kind === 70 /* Identifier */ && promiseConstructorName.text === "Promise" && getTargetType(returnType) === tryGetGlobalPromiseType()) { + error(node.type, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } + else { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + } return unknownType; } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); @@ -39175,22 +40717,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 144 /* Parameter */: + case 145 /* 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 147 /* PropertyDeclaration */: + case 148 /* 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 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -39231,14 +40773,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -39247,19 +40789,19 @@ var ts; } } break; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markTypeNodeAsReferenced(node.type); break; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); break; - case 144 /* Parameter */: + case 145 /* Parameter */: markTypeNodeAsReferenced(node.type); break; } @@ -39271,6 +40813,7 @@ var ts; checkFunctionOrMethodDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -39282,7 +40825,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 142 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 143 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -39342,43 +40885,43 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 261 /* SourceFile */: - case 230 /* ModuleDeclaration */: + case 264 /* SourceFile */: + case 232 /* ModuleDeclaration */: checkUnusedModuleMembers(node); break; - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: checkUnusedTypeParameters(node); break; - case 204 /* Block */: - case 232 /* CaseBlock */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 206 /* Block */: + case 234 /* CaseBlock */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: checkUnusedLocalsAndParameters(node); break; - case 150 /* Constructor */: - case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 151 /* Constructor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: checkUnusedTypeParameters(node); break; } @@ -39387,11 +40930,10 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 227 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_2 = function (key) { - var local = node.locals[key]; + if (node.parent.kind !== 229 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + node.locals.forEach(function (local) { if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144 /* Parameter */) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 145 /* Parameter */) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -39404,10 +40946,7 @@ var ts; ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d.name || d, local.name); }); } } - }; - for (var key in node.locals) { - _loop_2(key); - } + }); } } function isRemovedPropertyFromObjectSpread(node) { @@ -39420,9 +40959,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 223 /* VariableDeclaration */ && - (declaration.parent.parent.kind === 212 /* ForInStatement */ || - declaration.parent.parent.kind === 213 /* ForOfStatement */)) { + if (declaration.kind === 225 /* VariableDeclaration */ && + (declaration.parent.parent.kind === 214 /* ForInStatement */ || + declaration.parent.parent.kind === 215 /* ForOfStatement */)) { return; } } @@ -39441,12 +40980,12 @@ var ts; if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149 /* MethodDeclaration */ || member.kind === 147 /* PropertyDeclaration */) { + if (member.kind === 150 /* MethodDeclaration */ || member.kind === 148 /* PropertyDeclaration */) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8 /* Private */) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 150 /* Constructor */) { + else if (member.kind === 151 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8 /* Private */) { @@ -39479,22 +41018,21 @@ var ts; } function checkUnusedModuleMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { - for (var key in node.locals) { - var local = node.locals[key]; + node.locals.forEach(function (local) { if (!local.isReferenced && !local.exportSymbol) { for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - error(declaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + errorUnusedLocal(declaration.name, local.name); } } } - } + }); } } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 204 /* Block */) { + if (node.kind === 206 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -39517,12 +41055,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 147 /* PropertyDeclaration */ || - node.kind === 146 /* PropertySignature */ || - node.kind === 149 /* MethodDeclaration */ || - node.kind === 148 /* MethodSignature */ || - node.kind === 151 /* GetAccessor */ || - node.kind === 152 /* SetAccessor */) { + if (node.kind === 148 /* PropertyDeclaration */ || + node.kind === 147 /* PropertySignature */ || + node.kind === 150 /* MethodDeclaration */ || + node.kind === 149 /* MethodSignature */ || + node.kind === 152 /* GetAccessor */ || + node.kind === 153 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -39531,7 +41069,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 144 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 145 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -39542,6 +41080,11 @@ var ts; potentialThisCollisions.push(node); } } + function checkCollisionWithCapturedNewTargetVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_newTarget")) { + potentialNewTargetCollisions.push(node); + } + } // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; @@ -39559,6 +41102,22 @@ var ts; current = current.parent; } } + function checkIfNewTargetIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { + var isDeclaration_2 = node.kind !== 70 /* Identifier */; + if (isDeclaration_2) { + error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); + } + return; + } + current = current.parent; + } + } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; @@ -39570,8 +41129,8 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 70 /* Identifier */; - if (isDeclaration_2) { + var isDeclaration_3 = node.kind !== 70 /* Identifier */; + if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } else { @@ -39588,12 +41147,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 230 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 232 /* 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 === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 264 /* 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)); } @@ -39603,12 +41162,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 230 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 232 /* 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 === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 264 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -39643,7 +41202,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 === 223 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 225 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -39653,24 +41212,24 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 224 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 205 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 226 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 207 /* 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 === 204 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 231 /* ModuleBlock */ || - container.kind === 230 /* ModuleDeclaration */ || - container.kind === 261 /* SourceFile */); + (container.kind === 206 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 233 /* ModuleBlock */ || + container.kind === 232 /* ModuleDeclaration */ || + container.kind === 264 /* 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_23 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_23, name_23); + var name = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); } } } @@ -39678,7 +41237,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 144 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 145 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -39689,7 +41248,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 177 /* PropertyAccessExpression */) { + if (n.kind === 178 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -39708,7 +41267,8 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144 /* Parameter */) { + if (symbol.valueDeclaration.kind === 145 /* Parameter */ || + symbol.valueDeclaration.kind === 175 /* BindingElement */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -39722,13 +41282,14 @@ var ts; } // computed property names/initializers in instance property declaration of class like entities // are executed in constructor and thus deferred - if (current.parent.kind === 147 /* PropertyDeclaration */ && + if (current.parent.kind === 148 /* PropertyDeclaration */ && !(ts.hasModifier(current.parent, 32 /* Static */)) && ts.isClassLike(current.parent.parent)) { return; } current = current.parent; } + // fall through to report error } error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(node.name), ts.declarationNameToString(n)); } @@ -39749,28 +41310,28 @@ 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 === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 174 /* BindingElement */) { - if (node.parent.kind === 172 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */) { + if (node.kind === 175 /* BindingElement */) { + if (node.parent.kind === 173 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */ && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 142 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access - var parent_10 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_10); - var name_24 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_24)); + var parent = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent); + var name = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); markPropertyAsReferenced(property); - if (parent_10.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_10, parent_10.initializer, parentType, property); + if (parent.initializer && property) { + checkPropertyAccessibility(parent, parent.initializer, parentType, property); } } // For a binding pattern, check contained binding elements @@ -39778,14 +41339,14 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 144 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 145 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 212 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 214 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -39796,7 +41357,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 212 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 214 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -39816,21 +41377,22 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 146 /* PropertySignature */) { + if (node.kind !== 148 /* PropertyDeclaration */ && node.kind !== 147 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 223 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */) { + if (node.kind === 225 /* VariableDeclaration */ || node.kind === 175 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 /* Parameter */ && right.kind === 223 /* VariableDeclaration */) || - (left.kind === 223 /* VariableDeclaration */ && right.kind === 144 /* Parameter */)) { + if ((left.kind === 145 /* Parameter */ && right.kind === 225 /* VariableDeclaration */) || + (left.kind === 225 /* VariableDeclaration */ && right.kind === 145 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -39860,7 +41422,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 === 176 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 177 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -39881,7 +41443,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 206 /* EmptyStatement */) { + if (node.thenStatement.kind === 208 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -39901,12 +41463,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 224 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 226 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 224 /* VariableDeclarationList */) { + if (node.initializer.kind === 226 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -39929,14 +41491,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 === 224 /* VariableDeclarationList */) { + if (node.initializer.kind === 226 /* 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 === 175 /* ArrayLiteralExpression */ || varExpr.kind === 176 /* ObjectLiteralExpression */) { + if (varExpr.kind === 176 /* ArrayLiteralExpression */ || varExpr.kind === 177 /* 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. @@ -39968,7 +41530,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 === 224 /* VariableDeclarationList */) { + if (node.initializer.kind === 226 /* 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); @@ -39982,7 +41544,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 === 175 /* ArrayLiteralExpression */ || varExpr.kind === 176 /* ObjectLiteralExpression */) { + if (varExpr.kind === 176 /* ArrayLiteralExpression */ || varExpr.kind === 177 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -40235,7 +41797,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 151 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 152 /* SetAccessor */))); + return !!(node.kind === 152 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 153 /* SetAccessor */))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -40262,33 +41824,33 @@ var ts; // for generators. return; } - if (func.kind === 152 /* SetAccessor */) { + if (func.kind === 153 /* SetAccessor */) { if (node.expression) { - error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); + error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 150 /* Constructor */) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { - error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); + else if (func.kind === 151 /* Constructor */) { + if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node.expression || node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + var awaitedType = checkAwaitedType(exprType, node, 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 || node); + checkTypeAssignableTo(awaitedType, promisedType, node); } } else { - checkTypeAssignableTo(exprType, returnType, node.expression || node); + checkTypeAssignableTo(exprType, returnType, node); } } } - else if (func.kind !== 150 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 151 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -40318,7 +41880,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 254 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 257 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -40330,7 +41892,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 253 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 256 /* 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 comparable @@ -40361,7 +41923,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 219 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 221 /* 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; @@ -40398,14 +41960,14 @@ var ts; grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { - var blockLocals = catchClause.block.locals; - if (blockLocals) { - for (var caughtName in catchClause.locals) { - var blockLocal = blockLocals[caughtName]; + var blockLocals_1 = catchClause.block.locals; + if (blockLocals_1) { + ts.forEachKey(catchClause.locals, function (caughtName) { + var blockLocal = blockLocals_1.get(caughtName); if (blockLocal && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } - } + }); } } } @@ -40457,15 +42019,16 @@ var ts; if (!indexType) { return; } + var propDeclaration = prop.valueDeclaration; // index is numeric and property name is not valid numeric literal - if (indexKind === 1 /* Number */ && !isNumericName(prop.valueDeclaration.name)) { + if (indexKind === 1 /* Number */ && !(propDeclaration ? isNumericName(propDeclaration.name) : isNumericLiteralName(prop.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 === 142 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { - errorNode = prop.valueDeclaration; + if (propDeclaration && (propDeclaration.name.kind === 143 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { + errorNode = propDeclaration; } else if (indexDeclaration) { errorNode = indexDeclaration; @@ -40495,16 +42058,26 @@ var ts; case "string": case "symbol": case "void": + case "object": error(name, message, name.text); } } - /** Check each type parameter and check that type parameters have no duplicate type parameter declarations */ + /** + * Check each type parameter and check that type parameters have no duplicate type parameter declarations + */ function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + var seenDefault = false; + for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { + if (node.default) { + seenDefault = true; + } + else if (seenDefault) { + error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters); + } 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)); @@ -40515,23 +42088,65 @@ var ts; } } /** Check that type parameter lists are identical across multiple declarations */ - function checkTypeParameterListsIdentical(node, symbol) { + function checkTypeParameterListsIdentical(symbol) { if (symbol.declarations.length === 1) { return; } - var firstDecl; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 226 /* ClassDeclaration */ || declaration.kind === 227 /* InterfaceDeclaration */) { - if (!firstDecl) { - firstDecl = declaration; - } - else if (!areTypeParametersIdentical(firstDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); + var links = getSymbolLinks(symbol); + if (!links.typeParametersChecked) { + links.typeParametersChecked = true; + var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); + if (declarations.length <= 1) { + return; + } + var type = getDeclaredTypeOfSymbol(symbol); + if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { + // Report an error on every conflicting declaration. + var name = symbolToString(symbol); + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; + error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } } } + function areTypeParametersIdentical(declarations, typeParameters) { + var maxTypeArgumentCount = ts.length(typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; + // If this declaration has too few or too many type parameters, we report an error + var numTypeParameters = ts.length(declaration.typeParameters); + if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { + return false; + } + for (var i = 0; i < numTypeParameters; i++) { + var source = declaration.typeParameters[i]; + var target = typeParameters[i]; + // If the type parameter node does not have the same as the resolved type + // parameter at this position, we report an error. + if (source.name.text !== target.symbol.name) { + return false; + } + // If the type parameter node does not have an identical constraint as the resolved + // type parameter at this position, we report an error. + var sourceConstraint = source.constraint && getTypeFromTypeNode(source.constraint); + var targetConstraint = getConstraintFromTypeParameter(target); + if ((sourceConstraint || targetConstraint) && + (!sourceConstraint || !targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint))) { + return false; + } + // If the type parameter node has a default and it is not identical to the default + // for the type parameter at this position, we report an error. + var sourceDefault = source.default && getTypeFromTypeNode(source.default); + var targetDefault = getDefaultFromTypeParameter(target); + if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) { + return false; + } + } + } + return true; + } function checkClassExpression(node) { checkClassLikeDeclaration(node); checkNodeDeferred(node); @@ -40555,6 +42170,7 @@ var ts; if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -40564,8 +42180,12 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); - checkTypeParameterListsIdentical(node, symbol); + checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); + // Only check for reserved static identifiers on non-ambient context. + if (!ts.isInAmbientContext(node)) { + checkClassForStaticPropertyNameConflicts(node); + } var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { if (languageVersion < 2 /* ES2015 */ && !ts.isInAmbientContext(node)) { @@ -40574,7 +42194,8 @@ var ts; var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType_1 = baseTypes[0]; - var staticBaseType = getBaseConstructorTypeOfClass(type); + var baseConstructorType = getBaseConstructorTypeOfClass(type); + var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { @@ -40588,14 +42209,17 @@ var ts; } checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType_1, 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 (baseType_1.symbol.valueDeclaration && + if (baseConstructorType.flags & 540672 /* TypeVariable */ && !isMixinConstructorType(staticType)) { + error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); + } + if (baseType_1.symbol && baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 226 /* ClassDeclaration */) { + baseType_1.symbol.valueDeclaration.kind === 228 /* ClassDeclaration */) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 540672 /* TypeVariable */)) { // 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 @@ -40619,8 +42243,7 @@ var ts; if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - var declaredType = getObjectFlags(t) & 4 /* Reference */ ? t.target : t; - if (getObjectFlags(declaredType) & 3 /* ClassOrInterface */) { + if (isValidBaseType(t)) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { @@ -40650,11 +42273,16 @@ var ts; 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; + return getCheckFlags(s) & 1 /* Instantiated */ ? s.target : s; } function getClassLikeDeclarationOfSymbol(symbol) { return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); } + function getClassOrInterfaceDeclarationsOfSymbol(symbol) { + return ts.filter(symbol.declarations, function (d) { + return d.kind === 228 /* ClassDeclaration */ || d.kind === 229 /* InterfaceDeclaration */; + }); + } 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. @@ -40670,11 +42298,11 @@ var ts; // 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); + var baseProperties = getPropertiesOfType(baseType); 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 */) { + if (base.flags & 16777216 /* Prototype */) { continue; } var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); @@ -40691,7 +42319,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128 /* Abstract */))) { - if (derivedClassDecl.kind === 197 /* ClassExpression */) { + if (derivedClassDecl.kind === 198 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -40739,35 +42367,7 @@ var ts; } } function isAccessor(kind) { - return kind === 151 /* GetAccessor */ || kind === 152 /* 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; + return kind === 152 /* GetAccessor */ || kind === 153 /* SetAccessor */; } function checkInheritedPropertiesAreIdentical(type, typeNode) { var baseTypes = getBaseTypes(type); @@ -40775,16 +42375,16 @@ var ts; return true; } var seen = ts.createMap(); - ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.name, { prop: p, containingType: type }); }); var ok = true; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; - var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); + var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { var prop = properties_7[_a]; - var existing = seen[prop.name]; + var existing = seen.get(prop.name); if (!existing) { - seen[prop.name] = { prop: prop, containingType: base }; + seen.set(prop.name, { prop: prop, containingType: base }); } else { var isInheritedProperty = existing.containingType !== type; @@ -40809,9 +42409,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - checkTypeParameterListsIdentical(node, symbol); + checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 227 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 229 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -40918,7 +42518,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -40929,7 +42529,7 @@ var ts; case 51 /* TildeToken */: return ~value_1; } return undefined; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -40953,12 +42553,13 @@ var ts; } return undefined; case 8 /* NumericLiteral */: + checkGrammarNumericLiteral(e); return +e.text; - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return evalConstant(e.expression); case 70 /* Identifier */: - case 178 /* ElementAccessExpression */: - case 177 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: + case 178 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -40971,7 +42572,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 178 /* ElementAccessExpression */) { + if (e.kind === 179 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -40989,7 +42590,7 @@ var ts; if (current.kind === 70 /* Identifier */) { break; } - else if (current.kind === 177 /* PropertyAccessExpression */) { + else if (current.kind === 178 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -41033,6 +42634,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); @@ -41061,7 +42663,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 229 /* EnumDeclaration */) { + if (declaration.kind !== 231 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -41082,10 +42684,10 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var declaration = declarations_5[_i]; - if ((declaration.kind === 226 /* ClassDeclaration */ || - (declaration.kind === 225 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 228 /* ClassDeclaration */ || + (declaration.kind === 227 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -41149,7 +42751,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, 226 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 228 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -41162,7 +42764,7 @@ var ts; // We can detect if augmentation was applied using following rules: // - augmentation for a global scope is always applied // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Merged */); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 134217728 /* Transient */); if (checkBody && node.body) { // body of ambient external module is always a module block for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { @@ -41200,26 +42802,26 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 240 /* ExportAssignment */: - case 241 /* ExportDeclaration */: + case 242 /* ExportAssignment */: + case 243 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 234 /* ImportEqualsDeclaration */: - case 235 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 174 /* BindingElement */: - case 223 /* VariableDeclaration */: - var name_25 = node.name; - if (ts.isBindingPattern(name_25)) { - for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { + case 175 /* BindingElement */: + case 225 /* VariableDeclaration */: + var name = node.name; + if (ts.isBindingPattern(name)) { + for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { var el = _c[_b]; // mark individual names in binding pattern checkModuleAugmentationElement(el, isGlobalAugmentation); @@ -41227,12 +42829,12 @@ var ts; break; } // fallthrough - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 225 /* FunctionDeclaration */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 227 /* FunctionDeclaration */: + case 229 /* InterfaceDeclaration */: + case 232 /* ModuleDeclaration */: + case 230 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -41242,7 +42844,7 @@ var ts; // this is done it two steps // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error // 2. main check - report error if value declaration of the parent symbol is module augmentation) - var reportError = !(symbol.flags & 33554432 /* Merged */); + var reportError = !(symbol.flags & 134217728 /* Transient */); if (!reportError) { // symbol should not originate in augmentation reportError = ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); @@ -41255,12 +42857,12 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return node; - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: do { node = node.left; } while (node.kind !== 70 /* Identifier */); return node; - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 70 /* Identifier */); @@ -41273,9 +42875,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 231 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 241 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 233 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 264 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 243 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -41308,7 +42910,7 @@ var ts; (symbol.flags & 793064 /* Type */ ? 793064 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 243 /* ExportSpecifier */ ? + var message = node.kind === 245 /* 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)); @@ -41336,7 +42938,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 239 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -41393,8 +42995,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 231 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 233 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 233 /* ModuleBlock */ && + !node.moduleSpecifier && ts.isInAmbientContext(node); + if (node.parent.kind !== 264 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -41408,7 +43012,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 261 /* SourceFile */ || node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 230 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 264 /* SourceFile */ || node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 232 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -41434,9 +43038,14 @@ 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 === 261 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 230 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + var container = node.parent.kind === 264 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 232 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + if (node.isExportEquals) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + } + else { + error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); + } return; } // Grammar checking @@ -41462,18 +43071,13 @@ var ts; } } function hasExportedMembers(moduleSymbol) { - for (var id in moduleSymbol.exports) { - if (id !== "export=") { - return true; - } - } - return false; + return ts.forEachEntry(moduleSymbol.exports, function (_, id) { return id !== "export="; }); } function checkExternalModuleExports(node) { var moduleSymbol = getSymbolOfNode(node); var links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - var exportEqualsSymbol = moduleSymbol.exports["export="]; + var exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; if (!isTopLevelInExternalModuleAugmentation(declaration)) { @@ -41482,35 +43086,35 @@ var ts; } // Checks for export * conflicts var exports = getExportsOfModule(moduleSymbol); - for (var id in exports) { + exports && exports.forEach(function (_a, id) { + var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { - continue; + return; } - var _a = exports[id], declarations = _a.declarations, flags = _a.flags; // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. // (TS Exceptions: namespaces, function overloads, enums, and interfaces) if (flags & (1920 /* Namespace */ | 64 /* Interface */ | 384 /* Enum */)) { - continue; + return; } var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) - continue; + return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, id)); } } } - } + }); links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 225 /* FunctionDeclaration */ && declaration.kind !== 149 /* MethodDeclaration */) || + return (declaration.kind !== 227 /* FunctionDeclaration */ && declaration.kind !== 150 /* MethodDeclaration */) || !!declaration.body; } } @@ -41523,123 +43127,123 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 225 /* FunctionDeclaration */: + case 232 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 227 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: return checkTypeParameter(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return checkParameter(node); - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return checkPropertyDeclaration(node); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: return checkSignatureDeclaration(node); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: return checkMethodDeclaration(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return checkConstructorDeclaration(node); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return checkAccessorDeclaration(node); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return checkTypeReferenceNode(node); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return checkTypePredicate(node); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return checkTypeQuery(node); - case 161 /* TypeLiteral */: + case 162 /* TypeLiteral */: return checkTypeLiteral(node); - case 162 /* ArrayType */: + case 163 /* ArrayType */: return checkArrayType(node); - case 163 /* TupleType */: + case 164 /* TupleType */: return checkTupleType(node); - case 164 /* UnionType */: - case 165 /* IntersectionType */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 166 /* ParenthesizedType */: - case 168 /* TypeOperator */: + case 167 /* ParenthesizedType */: + case 169 /* TypeOperator */: return checkSourceElement(node.type); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 170 /* MappedType */: + case 171 /* MappedType */: return checkMappedType(node); - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 204 /* Block */: - case 231 /* ModuleBlock */: + case 206 /* Block */: + case 233 /* ModuleBlock */: return checkBlock(node); - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: return checkVariableStatement(node); - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return checkExpressionStatement(node); - case 208 /* IfStatement */: + case 210 /* IfStatement */: return checkIfStatement(node); - case 209 /* DoStatement */: + case 211 /* DoStatement */: return checkDoStatement(node); - case 210 /* WhileStatement */: + case 212 /* WhileStatement */: return checkWhileStatement(node); - case 211 /* ForStatement */: + case 213 /* ForStatement */: return checkForStatement(node); - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: return checkForInStatement(node); - case 213 /* ForOfStatement */: + case 215 /* ForOfStatement */: return checkForOfStatement(node); - case 214 /* ContinueStatement */: - case 215 /* BreakStatement */: + case 216 /* ContinueStatement */: + case 217 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 216 /* ReturnStatement */: + case 218 /* ReturnStatement */: return checkReturnStatement(node); - case 217 /* WithStatement */: + case 219 /* WithStatement */: return checkWithStatement(node); - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: return checkSwitchStatement(node); - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return checkLabeledStatement(node); - case 220 /* ThrowStatement */: + case 222 /* ThrowStatement */: return checkThrowStatement(node); - case 221 /* TryStatement */: + case 223 /* TryStatement */: return checkTryStatement(node); - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 174 /* BindingElement */: + case 175 /* BindingElement */: return checkBindingElement(node); - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return checkClassDeclaration(node); - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 228 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return checkImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return checkExportDeclaration(node); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return checkExportAssignment(node); - case 206 /* EmptyStatement */: + case 208 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 222 /* DebuggerStatement */: + case 224 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 244 /* MissingDeclaration */: + case 246 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -41661,17 +43265,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: checkAccessorDeferred(node); break; - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -41696,6 +43300,7 @@ var ts; // Grammar checking checkGrammarSourceFile(node); potentialThisCollisions.length = 0; + potentialNewTargetCollisions.length = 0; deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; ts.forEach(node.statements, checkSourceElement); @@ -41715,6 +43320,10 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } + if (potentialNewTargetCollisions.length) { + ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); + potentialNewTargetCollisions.length = 0; + } links.flags |= 1 /* TypeChecked */; } } @@ -41772,7 +43381,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 217 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 219 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -41795,25 +43404,25 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 261 /* SourceFile */: + case 264 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 197 /* ClassExpression */: + case 198 /* 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 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* 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. @@ -41822,7 +43431,7 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793064 /* Type */); } break; - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -41850,17 +43459,16 @@ var ts; // 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 (!symbols[id]) { - symbols[id] = symbol; + if (!symbols.has(id)) { + symbols.set(id, symbol); } } } function copySymbols(source, meaning) { if (meaning) { - for (var id in source) { - var symbol = source[id]; + source.forEach(function (symbol) { copySymbol(symbol, meaning); - } + }); } } } @@ -41871,28 +43479,28 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 143 /* TypeParameter */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 229 /* EnumDeclaration */: + case 144 /* TypeParameter */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 231 /* 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 === 141 /* QualifiedName */) { + while (node.parent && node.parent.kind === 142 /* QualifiedName */) { node = node.parent; } - return node.parent && (node.parent.kind === 157 /* TypeReference */ || node.parent.kind === 272 /* JSDocTypeReference */); + return node.parent && (node.parent.kind === 158 /* TypeReference */ || node.parent.kind === 276 /* JSDocTypeReference */); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 177 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 178 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 199 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 200 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -41909,13 +43517,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 141 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 142 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 234 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 236 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 240 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 242 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -41927,7 +43535,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 177 /* PropertyAccessExpression */) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 178 /* PropertyAccessExpression */) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1 /* ExportsProperty */: @@ -41939,13 +43547,13 @@ var ts; default: } } - if (entityName.parent.kind === 240 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 242 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 177 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { + if (entityName.kind !== 178 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 234 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 236 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -41955,7 +43563,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 199 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 200 /* ExpressionWithTypeArguments */) { meaning = 793064 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -41979,14 +43587,14 @@ var ts; } return resolveEntityName(entityName, 107455 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 177 /* PropertyAccessExpression */) { + else if (entityName.kind === 178 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 141 /* QualifiedName */) { + else if (entityName.kind === 142 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -41995,20 +43603,20 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 /* TypeReference */ || entityName.parent.kind === 272 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = (entityName.parent.kind === 158 /* TypeReference */ || entityName.parent.kind === 276 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 250 /* JsxAttribute */) { + else if (entityName.parent.kind === 252 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 156 /* TypePredicate */) { + if (entityName.parent.kind === 157 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 264 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -42026,8 +43634,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 174 /* BindingElement */ && - node.parent.parent.kind === 172 /* ObjectBindingPattern */ && + else if (node.parent.kind === 175 /* BindingElement */ && + node.parent.parent.kind === 173 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -42038,8 +43646,8 @@ var ts; } switch (node.kind) { case 70 /* Identifier */: - case 177 /* PropertyAccessExpression */: - case 141 /* QualifiedName */: + case 178 /* PropertyAccessExpression */: + case 142 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -42053,12 +43661,12 @@ var ts; case 96 /* SuperKeyword */: var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 167 /* ThisType */: + case 168 /* ThisType */: return getTypeFromTypeNode(node).symbol; case 122 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 150 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 151 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -42066,7 +43674,7 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 235 /* ImportDeclaration */ || node.parent.kind === 241 /* ExportDeclaration */) && + ((node.parent.kind === 237 /* ImportDeclaration */ || node.parent.kind === 243 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -42076,7 +43684,7 @@ var ts; // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 178 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 179 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -42093,7 +43701,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 === 258 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 261 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */ | 8388608 /* Alias */); } return undefined; @@ -42155,28 +43763,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 176 /* ObjectLiteralExpression */ || expr.kind === 175 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 177 /* ObjectLiteralExpression */ || expr.kind === 176 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 213 /* ForOfStatement */) { + if (expr.parent.kind === 215 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 192 /* BinaryExpression */) { + if (expr.parent.kind === 193 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 257 /* PropertyAssignment */) { + if (expr.parent.kind === 260 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 175 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 176 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false) || unknownType; @@ -42216,30 +43824,33 @@ var ts; var propsByName = createSymbolTable(getPropertiesOfType(type)); if (getSignaturesOfType(type, 0 /* Call */).length || getSignaturesOfType(type, 1 /* Construct */).length) { ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { - if (!propsByName[p.name]) { - propsByName[p.name] = p; + if (!propsByName.has(p.name)) { + propsByName.set(p.name, p); } }); } return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (symbol.flags & 268435456 /* SyntheticProperty */) { + if (getCheckFlags(symbol) & 2 /* SyntheticProperty */) { var symbols_3 = []; - var name_26 = symbol.name; + var name_2 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_26); + var symbol = getPropertyOfType(t, name_2); if (symbol) { symbols_3.push(symbol); } }); return symbols_3; } - else if (symbol.flags & 67108864 /* Transient */) { + else if (symbol.flags & 134217728 /* Transient */) { if (symbol.leftSpread) { var links = symbol; return [links.leftSpread, links.rightSpread]; } + if (symbol.mappedTypeOrigin) { + return getRootSymbols(symbol.mappedTypeOrigin); + } var target = void 0; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -42256,7 +43867,8 @@ var ts; if (!ts.isGeneratedIdentifier(node)) { node = ts.getParseTreeNode(node, ts.isIdentifier); if (node) { - return getReferencedValueSymbol(node) === argumentsSymbol; + var isPropertyName_1 = node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node; + return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } return false; @@ -42277,7 +43889,7 @@ var ts; // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment ? !!(moduleSymbol.flags & 107455 /* Value */) - : ts.forEachProperty(getExportsOfModule(moduleSymbol), isValue); + : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { @@ -42312,7 +43924,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 261 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 264 /* SourceFile */) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -42369,7 +43981,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 204 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 206 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -42415,16 +44027,16 @@ var ts; return true; } switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: - case 236 /* ImportClause */: - case 237 /* NamespaceImport */: - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 238 /* ImportClause */: + case 239 /* NamespaceImport */: + case 241 /* ImportSpecifier */: + case 245 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return node.expression && node.expression.kind === 70 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -42434,7 +44046,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 261 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 264 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -42491,6 +44103,12 @@ var ts; } return false; } + function isRequiredInitializedParameter(parameter) { + return strictNullChecks && + !isOptionalParameter(parameter) && + parameter.initializer && + !(ts.getModifierFlags(parameter) & 92 /* ParameterPropertyModifier */); + } function getNodeCheckFlags(node) { node = ts.getParseTreeNode(node); return node ? getNodeLinks(node).flags : undefined; @@ -42500,7 +44118,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 260 /* EnumMember */) { + if (node.kind === 263 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -42518,16 +44136,18 @@ var ts; function getTypeReferenceSerializationKind(typeName, location) { // 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, /*dontResolveAlias*/ false, location); - var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); - if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { - return ts.TypeReferenceSerializationKind.Promise; - } - 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, 793064 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + if (valueSymbol && valueSymbol === typeSymbol) { + var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); + if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { + return ts.TypeReferenceSerializationKind.Promise; + } + var constructorType = getTypeOfSymbol(valueSymbol); + if (constructorType && isConstructorType(constructorType)) { + return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + } // 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; @@ -42573,6 +44193,9 @@ var ts; var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : unknownType; + if (flags & 4096 /* AddUndefined */) { + type = includeFalsyTypes(type, 2048 /* Undefined */); + } getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { @@ -42587,10 +44210,13 @@ var ts; var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(node)); resolveBaseTypesOfClass(classType); var baseType = classType.resolvedBaseTypes.length ? classType.resolvedBaseTypes[0] : unknownType; + if (!baseType.symbol) { + writer.reportIllegalExtends(); + } getSymbolDisplayBuilder().buildTypeDisplay(baseType, writer, enclosingDeclaration, flags); } function hasGlobalName(name) { - return !!globals[name]; + return globals.has(name); } function getReferencedValueSymbol(reference, startInDeclarationContainer) { var resolvedSymbol = getNodeLinks(reference).resolvedSymbol; @@ -42601,9 +44227,9 @@ var ts; if (startInDeclarationContainer) { // When resolving the name of a declaration as a value, we need to start resolution // at a point outside of the declaration. - var parent_11 = reference.parent; - if (ts.isDeclaration(parent_11) && reference === parent_11.name) { - location = getDeclarationContainer(parent_11); + var parent = reference.parent; + if (ts.isDeclaration(parent) && reference === parent.name) { + location = getDeclarationContainer(parent); } } return resolveName(location, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -42639,14 +44265,13 @@ var ts; if (resolvedTypeReferenceDirectives) { // populate reverse mapping: file path -> type reference directive that was resolved to this file fileToDirective = ts.createFileMap(); - for (var key in resolvedTypeReferenceDirectives) { - var resolvedDirective = resolvedTypeReferenceDirectives[key]; + resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) { if (!resolvedDirective) { - continue; + return; } var file = host.getSourceFile(resolvedDirective.resolvedFileName); fileToDirective.set(file.path, key); - } + }); } return { getReferencedExportContainer: getReferencedExportContainer, @@ -42660,6 +44285,7 @@ var ts; isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, + isRequiredInitializedParameter: isRequiredInitializedParameter, writeTypeOfDeclaration: writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, writeTypeOfExpression: writeTypeOfExpression, @@ -42689,7 +44315,7 @@ var ts; // property access can only be used as values // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = (node.kind === 177 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) + var meaning = (node.kind === 178 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) ? 107455 /* Value */ | 1048576 /* ExportValue */ : 793064 /* Type */ | 1920 /* Namespace */; var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -42732,15 +44358,15 @@ var ts; // external modules cannot define or contribute to type declaration files var current = symbol; while (true) { - var parent_12 = getParentOfSymbol(current); - if (parent_12) { - current = parent_12; + var parent = getParentOfSymbol(current); + if (parent) { + current = parent; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 261 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 264 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -42760,7 +44386,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 261 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 264 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -42784,11 +44410,11 @@ var ts; if (file.symbol && file.symbol.globalExports) { // Merge in UMD exports with first-in-wins semantics (see #9771) var source = file.symbol.globalExports; - for (var id in source) { - if (!(id in globals)) { - globals[id] = source[id]; + source.forEach(function (sourceSymbol, id) { + if (!globals.has(id)) { + globals.set(id, sourceSymbol); } - } + }); } } if (augmentations) { @@ -42858,10 +44484,10 @@ var ts; var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1 /* FirstEmitHelper */; helper <= 128 /* LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { - var name_27 = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_27), 107455 /* Value */); + var name = getHelperName(helper); + var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name), 107455 /* Value */); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_27); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); } } } @@ -42897,7 +44523,7 @@ var ts; } 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"); + var thenPropertySymbol = createSymbol(4 /* Property */, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; var thenableType = createObjectType(16 /* Anonymous */); thenableType.properties = [thenPropertySymbol]; @@ -42912,14 +44538,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 149 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 150 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 151 /* GetAccessor */ || node.kind === 152 /* SetAccessor */) { + else if (node.kind === 152 /* GetAccessor */ || node.kind === 153 /* 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); @@ -42937,16 +44563,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 130 /* ReadonlyKeyword */) { - if (node.kind === 146 /* PropertySignature */ || node.kind === 148 /* MethodSignature */) { + if (node.kind === 147 /* PropertySignature */ || node.kind === 149 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 155 /* IndexSignature */) { + if (node.kind === 156 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 75 /* ConstKeyword */: - if (node.kind !== 229 /* EnumDeclaration */ && node.parent.kind === 226 /* ClassDeclaration */) { + if (node.kind !== 231 /* EnumDeclaration */ && node.parent.kind === 228 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75 /* ConstKeyword */)); } break; @@ -42972,7 +44598,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + else if (node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -42995,10 +44621,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + else if (node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 144 /* Parameter */) { + else if (node.kind === 145 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -43011,7 +44637,7 @@ var ts; if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 146 /* PropertySignature */ && node.kind !== 155 /* IndexSignature */ && node.kind !== 144 /* Parameter */) { + else if (node.kind !== 148 /* PropertyDeclaration */ && node.kind !== 147 /* PropertySignature */ && node.kind !== 156 /* IndexSignature */ && node.kind !== 145 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } @@ -43031,10 +44657,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 228 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 144 /* Parameter */) { + else if (node.kind === 145 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; @@ -43046,13 +44672,13 @@ var ts; 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 === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 228 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 144 /* Parameter */) { + else if (node.kind === 145 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 231 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 233 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -43062,14 +44688,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 226 /* ClassDeclaration */) { - if (node.kind !== 149 /* MethodDeclaration */ && - node.kind !== 147 /* PropertyDeclaration */ && - node.kind !== 151 /* GetAccessor */ && - node.kind !== 152 /* SetAccessor */) { + if (node.kind !== 228 /* ClassDeclaration */) { + if (node.kind !== 150 /* MethodDeclaration */ && + node.kind !== 148 /* PropertyDeclaration */ && + node.kind !== 152 /* GetAccessor */ && + node.kind !== 153 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 226 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { + if (!(node.parent.kind === 228 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -43088,7 +44714,7 @@ var ts; 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 === 144 /* Parameter */) { + else if (node.kind === 145 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -43096,7 +44722,7 @@ var ts; break; } } - if (node.kind === 150 /* Constructor */) { + if (node.kind === 151 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -43111,13 +44737,13 @@ var ts; } return; } - else if ((node.kind === 235 /* ImportDeclaration */ || node.kind === 234 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 237 /* ImportDeclaration */ || node.kind === 236 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 144 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 145 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 144 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 145 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -43137,37 +44763,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 150 /* Constructor */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 155 /* IndexSignature */: - case 230 /* ModuleDeclaration */: - case 235 /* ImportDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 241 /* ExportDeclaration */: - case 240 /* ExportAssignment */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 144 /* Parameter */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 151 /* Constructor */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 156 /* IndexSignature */: + case 232 /* ModuleDeclaration */: + case 237 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 243 /* ExportDeclaration */: + case 242 /* ExportAssignment */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 145 /* Parameter */: return false; default: - if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + if (node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { return false; } switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 119 /* AsyncKeyword */); - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 116 /* AbstractKeyword */); - case 227 /* InterfaceDeclaration */: - case 205 /* VariableStatement */: - case 228 /* TypeAliasDeclaration */: + case 229 /* InterfaceDeclaration */: + case 207 /* VariableStatement */: + case 230 /* TypeAliasDeclaration */: return true; - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 75 /* ConstKeyword */); default: ts.Debug.fail(); @@ -43180,10 +44806,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 149 /* MethodDeclaration */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -43246,7 +44872,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 185 /* ArrowFunction */) { + if (node.kind === 186 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -43281,7 +44907,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 !== 134 /* StringKeyword */ && parameter.type.kind !== 132 /* NumberKeyword */) { + if (parameter.type.kind !== 135 /* StringKeyword */ && parameter.type.kind !== 132 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -43309,7 +44935,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 198 /* OmittedExpression */) { + if (arg.kind === 199 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -43382,19 +45008,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 142 /* ComputedPropertyName */) { + if (node.kind !== 143 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 192 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 25 /* CommaToken */) { + if (computedPropertyName.expression.kind === 193 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 25 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 225 /* FunctionDeclaration */ || - node.kind === 184 /* FunctionExpression */ || - node.kind === 149 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 227 /* FunctionDeclaration */ || + node.kind === 185 /* FunctionExpression */ || + node.kind === 150 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -43419,15 +45045,15 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 /* SpreadAssignment */) { + if (prop.kind === 262 /* SpreadAssignment */) { continue; } - var name_28 = prop.name; - if (name_28.kind === 142 /* ComputedPropertyName */) { + var name = prop.name; + if (name.kind === 143 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_28); + checkGrammarComputedPropertyName(name); } - if (prop.kind === 258 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 261 /* 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); @@ -43436,7 +45062,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 /* AsyncKeyword */ || prop.kind !== 149 /* MethodDeclaration */) { + if (mod.kind !== 119 /* AsyncKeyword */ || prop.kind !== 150 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -43450,69 +45076,69 @@ 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 === 257 /* PropertyAssignment */ || prop.kind === 258 /* ShorthandPropertyAssignment */) { + if (prop.kind === 260 /* PropertyAssignment */ || prop.kind === 261 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_28.kind === 8 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_28); + if (name.kind === 8 /* NumericLiteral */) { + checkGrammarNumericLiteral(name); } currentKind = Property; } - else if (prop.kind === 149 /* MethodDeclaration */) { + else if (prop.kind === 150 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 151 /* GetAccessor */) { + else if (prop.kind === 152 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 152 /* SetAccessor */) { + else if (prop.kind === 153 /* SetAccessor */) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_28); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { continue; } - if (!seen[effectiveName]) { - seen[effectiveName] = currentKind; + var existingKind = seen.get(effectiveName); + if (!existingKind) { + seen.set(effectiveName, currentKind); } else { - var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_28, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_28)); + grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[effectiveName] = currentKind | existingKind; + seen.set(effectiveName, currentKind | existingKind); } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } } function checkGrammarJsxElement(node) { var seen = ts.createMap(); - for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { + for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 251 /* JsxSpreadAttribute */) { + if (attr.kind === 254 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; - var name_29 = jsxAttr.name; - if (!seen[name_29.text]) { - seen[name_29.text] = true; + var name = jsxAttr.name; + if (!seen.get(name.text)) { + seen.set(name.text, true); } else { - return grammarErrorOnNode(name_29, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 252 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 255 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -43521,7 +45147,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 224 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 226 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -43536,20 +45162,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 212 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 214 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 212 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 214 /* 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 === 212 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 214 /* 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); @@ -43576,11 +45202,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 151 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 152 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 152 /* SetAccessor */) { + else if (kind === 153 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -43603,10 +45229,10 @@ var ts; A get accessor has no parameters or a single `this` parameter. A set accessor has one parameter or a `this` parameter and one more parameter */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 151 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 152 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 151 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 152 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -43621,7 +45247,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 176 /* ObjectLiteralExpression */) { + if (node.parent.kind === 177 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -43642,10 +45268,10 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 227 /* InterfaceDeclaration */) { + else if (node.parent.kind === 229 /* 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 === 161 /* TypeLiteral */) { + else if (node.parent.kind === 162 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -43656,11 +45282,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 219 /* LabeledStatement */: + case 221 /* 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 === 214 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 216 /* 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); @@ -43668,8 +45294,8 @@ var ts; return false; } break; - case 218 /* SwitchStatement */: - if (node.kind === 215 /* BreakStatement */ && !node.label) { + case 220 /* SwitchStatement */: + if (node.kind === 217 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -43684,13 +45310,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 215 /* BreakStatement */ + var message = node.kind === 217 /* 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 === 215 /* BreakStatement */ + var message = node.kind === 217 /* 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); @@ -43702,7 +45328,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 173 /* ArrayBindingPattern */ || node.name.kind === 172 /* ObjectBindingPattern */) { + if (node.name.kind === 174 /* ArrayBindingPattern */ || node.name.kind === 173 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -43713,11 +45339,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 190 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && + expr.kind === 191 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 212 /* ForInStatement */ && node.parent.parent.kind !== 213 /* ForOfStatement */) { + if (node.parent.parent.kind !== 214 /* ForInStatement */ && node.parent.parent.kind !== 215 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -43746,6 +45372,10 @@ var ts; } } } + if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && + !ts.isInAmbientContext(node.parent.parent) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { + checkESModuleMarker(node.name); + } var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". @@ -43755,6 +45385,22 @@ var ts; // and its Identifier is eval or arguments return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } + function checkESModuleMarker(name) { + if (name.kind === 70 /* Identifier */) { + if (ts.unescapeIdentifier(name.text) === "__esModule") { + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); + } + } + else { + var elements = name.elements; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; + if (!ts.isOmittedExpression(element)) { + return checkESModuleMarker(element.name); + } + } + } + } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 70 /* Identifier */) { if (name.originalKeywordKind === 109 /* LetKeyword */) { @@ -43763,8 +45409,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { - var element = elements_2[_i]; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var element = elements_3[_i]; if (!ts.isOmittedExpression(element)) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -43782,15 +45428,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 208 /* IfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 217 /* WithStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 210 /* IfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 219 /* WithStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: return false; - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -43805,6 +45451,13 @@ var ts; } } } + function checkGrammarMetaProperty(node) { + if (node.keywordToken === 93 /* NewKeyword */) { + if (node.name.text !== "target") { + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + } + } + } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -43845,7 +45498,7 @@ var ts; return true; } } - else if (node.parent.kind === 227 /* InterfaceDeclaration */) { + else if (node.parent.kind === 229 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -43853,7 +45506,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 161 /* TypeLiteral */) { + else if (node.parent.kind === 162 /* 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; } @@ -43878,13 +45531,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 227 /* InterfaceDeclaration */ || - node.kind === 228 /* TypeAliasDeclaration */ || - node.kind === 235 /* ImportDeclaration */ || - node.kind === 234 /* ImportEqualsDeclaration */ || - node.kind === 241 /* ExportDeclaration */ || - node.kind === 240 /* ExportAssignment */ || - node.kind === 233 /* NamespaceExportDeclaration */ || + if (node.kind === 229 /* InterfaceDeclaration */ || + node.kind === 230 /* TypeAliasDeclaration */ || + node.kind === 237 /* ImportDeclaration */ || + node.kind === 236 /* ImportEqualsDeclaration */ || + node.kind === 243 /* ExportDeclaration */ || + node.kind === 242 /* ExportAssignment */ || + node.kind === 235 /* NamespaceExportDeclaration */ || ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -43893,7 +45546,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 === 205 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 207 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -43919,7 +45572,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 204 /* Block */ || node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + if (node.parent.kind === 206 /* Block */ || node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -43927,13 +45580,30 @@ var ts; } } else { + // We must be parented by a statement. If so, there's no need + // to report the error as our parent will have already done it. + // Debug.assert(isStatement(node.parent)); } } } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.isOctalLiteral && languageVersion >= 1 /* ES5 */) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + if (node.isOctalLiteral) { + var diagnosticMessage = void 0; + if (languageVersion >= 1 /* ES5 */) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 172 /* LiteralType */)) { + diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 263 /* EnumMember */)) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; + } + if (diagnosticMessage) { + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37 /* MinusToken */; + var literal = (withMinus ? "-" : "") + "0o" + node.text; + return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); + } } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -43946,11 +45616,11 @@ var ts; } function getAmbientModules() { var result = []; - for (var sym in globals) { + globals.forEach(function (global, sym) { if (ambientModuleSymbolRegex.test(sym)) { - result.push(globals[sym]); + result.push(global); } - } + }); return result; } } @@ -43962,70 +45632,6 @@ var ts; /* @internal */ var ts; (function (ts) { - ; - /** - * This map contains information about the shape of each Node in "types.ts" pertaining to how - * each node should be traversed during a transformation. - * - * Each edge corresponds to a property in a Node subtype that should be traversed when visiting - * each child. The properties are assigned in the order in which traversal should occur. - * - * We only add entries for nodes that do not have a create/update pair defined in factory.ts - * - * NOTE: This needs to be kept up to date with changes to nodes in "types.ts". Currently, this - * map is not comprehensive. Only node edges relevant to tree transformation are - * currently defined. We may extend this to be more comprehensive, and eventually - * supplant the existing `forEachChild` implementation if performance is not - * significantly impacted. - */ - var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[141 /* QualifiedName */] = [ - { name: "left", test: ts.isEntityName }, - { name: "right", test: ts.isIdentifier } - ], - _a[145 /* Decorator */] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[182 /* TypeAssertionExpression */] = [ - { name: "type", test: ts.isTypeNode }, - { name: "expression", test: ts.isUnaryExpression } - ], - _a[200 /* AsExpression */] = [ - { name: "expression", test: ts.isExpression }, - { name: "type", test: ts.isTypeNode } - ], - _a[201 /* NonNullExpression */] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[229 /* EnumDeclaration */] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "members", test: ts.isEnumMember } - ], - _a[230 /* ModuleDeclaration */] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isModuleName }, - { name: "body", test: ts.isModuleBody } - ], - _a[231 /* ModuleBlock */] = [ - { name: "statements", test: ts.isStatement } - ], - _a[234 /* ImportEqualsDeclaration */] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "moduleReference", test: ts.isModuleReference } - ], - _a[245 /* ExternalModuleReference */] = [ - { name: "expression", test: ts.isExpression, optional: true } - ], - _a[260 /* EnumMember */] = [ - { name: "name", test: ts.isPropertyName }, - { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } - ], - _a)); function reduceNode(node, f, initial) { return node ? f(initial, node) : initial; } @@ -44034,8 +45640,7 @@ var ts; } /** * Similar to `reduceLeft`, performs a reduction against each child of a node. - * NOTE: Unlike `forEachChild`, this does *not* visit every node. Only nodes added to the - * `nodeEdgeTraversalMap` above will be visited. + * NOTE: Unlike `forEachChild`, this does *not* visit every node. * * @param node The node containing the children to reduce. * @param initial The initial value to supply to the reduction. @@ -44049,47 +45654,51 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 140 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 141 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 156 /* TypePredicate */ && kind <= 171 /* LiteralType */)) { + if ((kind >= 157 /* TypePredicate */ && kind <= 172 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 203 /* SemicolonClassElement */: - case 206 /* EmptyStatement */: - case 198 /* OmittedExpression */: - case 222 /* DebuggerStatement */: - case 293 /* NotEmittedStatement */: + case 205 /* SemicolonClassElement */: + case 208 /* EmptyStatement */: + case 199 /* OmittedExpression */: + case 224 /* DebuggerStatement */: + case 297 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 142 /* ComputedPropertyName */: + case 142 /* QualifiedName */: + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); + break; + case 143 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 144 /* Parameter */: + case 145 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 145 /* Decorator */: + case 146 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44098,12 +45707,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 150 /* Constructor */: + case 151 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44111,7 +45720,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44119,45 +45728,49 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 174 /* BindingElement */: + case 175 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 179 /* CallExpression */: + case 180 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 180 /* NewExpression */: + case 181 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 184 /* FunctionExpression */: + case 183 /* TypeAssertionExpression */: + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 185 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -44165,119 +45778,126 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 183 /* ParenthesizedExpression */: - case 186 /* DeleteExpression */: - case 187 /* TypeOfExpression */: - case 188 /* VoidExpression */: - case 189 /* AwaitExpression */: - case 195 /* YieldExpression */: - case 196 /* SpreadElement */: - case 201 /* NonNullExpression */: + case 184 /* ParenthesizedExpression */: + case 187 /* DeleteExpression */: + case 188 /* TypeOfExpression */: + case 189 /* VoidExpression */: + case 190 /* AwaitExpression */: + case 196 /* YieldExpression */: + case 197 /* SpreadElement */: + case 202 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; + case 201 /* AsExpression */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.type, cbNode, result); + break; + case 202 /* NonNullExpression */: + result = reduceNode(node.expression, cbNode, result); + break; // Misc - case 202 /* TemplateSpan */: + case 204 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 204 /* Block */: + case 206 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 208 /* IfStatement */: + case 210 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 209 /* DoStatement */: + case 211 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 210 /* WhileStatement */: - case 217 /* WithStatement */: + case 212 /* WhileStatement */: + case 219 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 211 /* ForStatement */: + case 213 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 216 /* ReturnStatement */: - case 220 /* ThrowStatement */: + case 218 /* ReturnStatement */: + case 222 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 221 /* TryStatement */: + case 223 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 224 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44286,7 +45906,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44294,118 +45914,148 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 232 /* CaseBlock */: + case 231 /* EnumDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 232 /* ModuleDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 233 /* ModuleBlock */: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 234 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 235 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.moduleReference, cbNode, result); + break; + case 237 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 236 /* ImportClause */: + case 238 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 237 /* NamespaceImport */: + case 239 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 240 /* NamedImports */: + case 244 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: + case 245 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; + // Module references + case 247 /* ExternalModuleReference */: + result = reduceNode(node.expression, cbNode, result); + break; // JSX - case 246 /* JsxElement */: + case 248 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 247 /* JsxSelfClosingElement */: - case 248 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + case 250 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); - result = reduceNodes(node.attributes, cbNodes, result); + result = reduceNode(node.attributes, cbNode, result); break; - case 249 /* JsxClosingElement */: + case 251 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 250 /* JsxAttribute */: + case 253 /* JsxAttributes */: + result = reduceNodes(node.properties, cbNodes, result); + break; + case 252 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 251 /* JsxSpreadAttribute */: + case 254 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 252 /* JsxExpression */: + case 255 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 253 /* CaseClause */: + case 256 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // fall-through - case 254 /* DefaultClause */: + case 257 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 255 /* HeritageClause */: + case 258 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 256 /* CatchClause */: + case 259 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 257 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 258 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 259 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; + // Enum + case 263 /* EnumMember */: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); // Top-level nodes - case 261 /* SourceFile */: + case 264 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; - case 294 /* PartiallyEmittedExpression */: + // Transformation nodes + case 298 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; default: - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_1 = edgeTraversalPath; _i < edgeTraversalPath_1.length; _i++) { - var edge = edgeTraversalPath_1[_i]; - var value = node[edge.name]; - if (value !== undefined) { - result = ts.isArray(value) - ? reduceNodes(value, cbNodes, result) - : cbNode(result, value); - } - } - } break; } return result; } ts.reduceEachChild = reduceEachChild; - function visitNode(node, visitor, test, optional, lift, parenthesize, parentNode) { + /** + * Visits a Node using the supplied visitor, possibly returning a new Node in its place. + * + * @param node The Node to visit. + * @param visitor The callback used to visit the Node. + * @param test A callback to execute to verify the Node is valid. + * @param optional An optional value indicating whether the Node is itself optional. + * @param lift An optional callback to execute to lift a NodeArray into a valid Node. + */ + function visitNode(node, visitor, test, optional, lift) { if (node === undefined || visitor === undefined) { return node; } @@ -44427,15 +46077,21 @@ var ts; else { visitedNode = visited; } - if (parenthesize !== undefined) { - visitedNode = parenthesize(visitedNode, parentNode); - } Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); return visitedNode; } ts.visitNode = visitNode; - function visitNodes(nodes, visitor, test, start, count, parenthesize, parentNode) { + /** + * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. + * + * @param nodes The NodeArray to visit. + * @param visitor The callback used to visit a Node. + * @param test A node test to execute for each node. + * @param start An optional value indicating the starting offset at which to start visiting. + * @param count An optional value indicating the maximum number of nodes to visit. + */ + function visitNodes(nodes, visitor, test, start, count) { if (nodes === undefined) { return undefined; } @@ -44452,8 +46108,7 @@ var ts; // If we are not visiting all of the original nodes, we must always create a new array. // Since this is a fragment of a node array, we do not copy over the previous location // and will only copy over `hasTrailingComma` if we are including the last element. - updated = ts.createNodeArray([], /*location*/ undefined, - /*hasTrailingComma*/ nodes.hasTrailingComma && start + count === length); + updated = ts.createNodeArray([], /*hasTrailingComma*/ nodes.hasTrailingComma && start + count === length); } // Visit each original node. for (var i = 0; i < count; i++) { @@ -44463,27 +46118,22 @@ var ts; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { // Ensure we have a copy of `nodes`, up to the current index. - updated = ts.createNodeArray(nodes.slice(0, i), /*location*/ nodes, nodes.hasTrailingComma); + updated = ts.createNodeArray(nodes.slice(0, i), nodes.hasTrailingComma); + ts.setTextRange(updated, nodes); } if (visited) { if (ts.isArray(visited)) { for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) { var visitedNode = visited_1[_i]; - visitedNode = parenthesize - ? parenthesize(visitedNode, parentNode) - : visitedNode; Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); updated.push(visitedNode); } } else { - var visitedNode = parenthesize - ? parenthesize(visited, parentNode) - : visited; - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); - updated.push(visitedNode); + Debug.assertNode(visited, test); + aggregateTransformFlags(visited); + updated.push(visited); } } } @@ -44499,10 +46149,10 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); - return ts.createNodeArray(ts.concatenate(statements, declarations), statements); + return ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements); } ts.visitLexicalEnvironment = visitLexicalEnvironment; /** @@ -44534,219 +46184,223 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 140 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 141 /* LastToken */)) { return node; } // We do not yet support types. - if ((kind >= 156 /* TypePredicate */ && kind <= 171 /* LiteralType */)) { + if ((kind >= 157 /* TypePredicate */ && kind <= 172 /* LiteralType */)) { return node; } switch (node.kind) { - case 203 /* SemicolonClassElement */: - case 206 /* EmptyStatement */: - case 198 /* OmittedExpression */: - case 222 /* DebuggerStatement */: + case 205 /* SemicolonClassElement */: + case 208 /* EmptyStatement */: + case 199 /* OmittedExpression */: + case 224 /* DebuggerStatement */: // No need to visit nodes with no children. return node; // Names - case 142 /* ComputedPropertyName */: + case 142 /* QualifiedName */: + return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); + case 143 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 144 /* Parameter */: + case 145 /* Parameter */: return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), node.dotDotDotToken, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); + case 146 /* Decorator */: + return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type member - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 150 /* Constructor */: + case 151 /* Constructor */: return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); // Binding patterns - case 172 /* ObjectBindingPattern */: + case 173 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 173 /* ArrayBindingPattern */: + case 174 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 174 /* BindingElement */: + case 175 /* BindingElement */: return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, /*optional*/ true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Expression - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 183 /* ParenthesizedExpression */: + case 183 /* TypeAssertionExpression */: + return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 184 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 187 /* TypeOfExpression */: + case 188 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 201 /* AsExpression */: + return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); + case 202 /* NonNullExpression */: + return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Misc - case 202 /* TemplateSpan */: + case 204 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 204 /* Block */: + case 206 /* Block */: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 208 /* IfStatement */: + case 210 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, /*optional*/ true, liftToBlock)); - case 209 /* DoStatement */: + case 211 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* WhileStatement */: + case 212 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 211 /* ForStatement */: + case 213 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 213 /* ForOfStatement */: + case 215 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 214 /* ContinueStatement */: + case 216 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 215 /* BreakStatement */: + case 217 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 216 /* ReturnStatement */: + case 218 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true)); - case 217 /* WithStatement */: + case 219 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 220 /* ThrowStatement */: + case 222 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 221 /* TryStatement */: + case 223 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, /*optional*/ true), visitNode(node.finallyBlock, visitor, ts.isBlock, /*optional*/ true)); - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 224 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 232 /* CaseBlock */: + case 231 /* EnumDeclaration */: + return ts.updateEnumDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNodes(node.members, visitor, ts.isEnumMember)); + case 232 /* ModuleDeclaration */: + return ts.updateModuleDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); + case 233 /* ModuleBlock */: + return ts.updateModuleBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 234 /* CaseBlock */: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 235 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + return ts.updateImportEqualsDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); + case 237 /* ImportDeclaration */: return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 236 /* ImportClause */: + case 238 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true)); - case 237 /* NamespaceImport */: + case 239 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 238 /* NamedImports */: + case 240 /* NamedImports */: return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 239 /* ImportSpecifier */: + case 241 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, /*optional*/ true)); - case 242 /* NamedExports */: + case 244 /* NamedExports */: return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 243 /* ExportSpecifier */: + case 245 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); + // Module references + case 247 /* ExternalModuleReference */: + return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 246 /* JsxElement */: + case 248 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 247 /* JsxSelfClosingElement */: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 248 /* JsxOpeningElement */: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 249 /* JsxClosingElement */: + case 253 /* JsxAttributes */: + return ts.updateJsxAttributes(node, visitNodes(node.properties, visitor, ts.isJsxAttributeLike)); + case 249 /* JsxSelfClosingElement */: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 250 /* JsxOpeningElement */: + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 251 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 250 /* JsxAttribute */: + case 252 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 251 /* JsxSpreadAttribute */: + case 254 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 252 /* JsxExpression */: + case 255 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 253 /* CaseClause */: + case 256 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); - case 254 /* DefaultClause */: + case 257 /* DefaultClause */: return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 255 /* HeritageClause */: + case 258 /* HeritageClause */: return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 257 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 258 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 259 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + // Enum + case 263 /* EnumMember */: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Top-level nodes - case 261 /* SourceFile */: + case 264 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 294 /* PartiallyEmittedExpression */: + case 298 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: - var updated = void 0; - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_2 = edgeTraversalPath; _i < edgeTraversalPath_2.length; _i++) { - var edge = edgeTraversalPath_2[_i]; - var value = node[edge.name]; - if (value !== undefined) { - var visited = ts.isArray(value) - ? visitNodes(value, visitor, edge.test, 0, value.length, edge.parenthesize, node) - : visitNode(value, visitor, edge.test, edge.optional, edge.lift, edge.parenthesize, node); - if (updated !== undefined || visited !== value) { - if (updated === undefined) { - updated = ts.getMutableClone(node); - } - if (visited !== value) { - updated[edge.name] = visited; - } - } - } - } - } - return updated ? ts.updateNode(updated, node) : node; + return node; } - // return node; } ts.visitEachChild = visitEachChild; function mergeLexicalEnvironment(statements, declarations) { @@ -44754,19 +46408,19 @@ var ts; return statements; } return ts.isNodeArray(statements) - ? ts.createNodeArray(ts.concatenate(statements, declarations), statements) + ? ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements) : ts.addRange(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; function mergeFunctionBodyLexicalEnvironment(body, declarations) { if (body && declarations !== undefined && declarations.length > 0) { if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.createNodeArray(ts.concatenate(body.statements, declarations), body.statements)); + return ts.updateBlock(body, ts.setTextRange(ts.createNodeArray(ts.concatenate(body.statements, declarations)), body.statements)); } else { - return ts.createBlock(ts.createNodeArray([ts.createReturn(body, /*location*/ body)].concat(declarations), body), - /*location*/ body, - /*multiLine*/ true); + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray([ts.setTextRange(ts.createReturn(body), body)].concat(declarations)), body), + /*multiLine*/ true), + /*location*/ body); } } return body; @@ -44836,7 +46490,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || ts.isTypeNode(node)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 200 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -44889,7 +46543,6 @@ var ts; } } })(Debug = ts.Debug || (ts.Debug = {})); - var _a; })(ts || (ts = {})); /// /// @@ -44979,7 +46632,7 @@ var ts; ts.Debug.assertNode(target, createAssignmentCallback ? ts.isIdentifier : ts.isExpression); var expression = createAssignmentCallback ? createAssignmentCallback(target, value, location) - : ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value, location); + : ts.setTextRange(ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value), location); expression.original = original; emitExpression(expression); } @@ -45028,11 +46681,12 @@ var ts; } } for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) { - var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_30 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; - var variable = ts.createVariableDeclaration(name_30, - /*type*/ undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); + var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name = _a.name, value = _a.value, location = _a.location, original = _a.original; + var variable = ts.createVariableDeclaration(name, + /*type*/ undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value); variable.original = original; - if (ts.isIdentifier(name_30)) { + ts.setTextRange(variable, location); + if (ts.isIdentifier(name)) { ts.setEmitFlags(variable, 64 /* NoNestedSourceMaps */); } ts.aggregateTransformFlags(variable); @@ -45236,8 +46890,8 @@ var ts; return ts.createElementAccess(value, argumentExpression); } else { - var name_31 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); - return ts.createPropertyAccess(value, name_31); + var name = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); + return ts.createPropertyAccess(value, name); } } /** @@ -45259,7 +46913,7 @@ var ts; var temp = ts.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { flattenContext.context.hoistVariableDeclaration(temp); - flattenContext.emitExpression(ts.createAssignment(temp, value, location)); + flattenContext.emitExpression(ts.setTextRange(ts.createAssignment(temp, value), location)); } else { flattenContext.emitBindingOrAssignment(temp, value, location, /*original*/ undefined); @@ -45312,7 +46966,10 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), undefined, [value, ts.createArrayLiteral(propertyNames, location)]); + return ts.createCall(ts.getHelperName("__rest"), undefined, [ + value, + ts.setTextRange(ts.createArrayLiteral(propertyNames), location) + ]); } })(ts || (ts = {})); /// @@ -45347,8 +47004,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(177 /* PropertyAccessExpression */); - context.enableSubstitution(178 /* ElementAccessExpression */); + context.enableSubstitution(178 /* PropertyAccessExpression */); + context.enableSubstitution(179 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -45412,15 +47069,15 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 261 /* SourceFile */: - case 232 /* CaseBlock */: - case 231 /* ModuleBlock */: - case 204 /* Block */: + case 264 /* SourceFile */: + case 234 /* CaseBlock */: + case 233 /* ModuleBlock */: + case 206 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 226 /* ClassDeclaration */: - case 225 /* FunctionDeclaration */: + case 228 /* ClassDeclaration */: + case 227 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -45467,13 +47124,13 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return visitImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return visitExportAssignment(node); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -45493,11 +47150,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 241 /* ExportDeclaration */ || - node.kind === 235 /* ImportDeclaration */ || - node.kind === 236 /* ImportClause */ || - (node.kind === 234 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 245 /* ExternalModuleReference */)) { + if (node.kind === 243 /* ExportDeclaration */ || + node.kind === 237 /* ImportDeclaration */ || + node.kind === 238 /* ImportClause */ || + (node.kind === 236 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 247 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -45527,19 +47184,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 150 /* Constructor */: + case 151 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 147 /* PropertyDeclaration */: - case 155 /* IndexSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 149 /* MethodDeclaration */: + case 148 /* PropertyDeclaration */: + case 156 /* IndexSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 150 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 203 /* SemicolonClassElement */: + case 205 /* SemicolonClassElement */: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -45579,47 +47236,47 @@ var ts; case 123 /* DeclareKeyword */: case 130 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 162 /* ArrayType */: - case 163 /* TupleType */: - case 161 /* TypeLiteral */: - case 156 /* TypePredicate */: - case 143 /* TypeParameter */: + case 163 /* ArrayType */: + case 164 /* TupleType */: + case 162 /* TypeLiteral */: + case 157 /* TypePredicate */: + case 144 /* TypeParameter */: case 118 /* AnyKeyword */: case 121 /* BooleanKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 129 /* NeverKeyword */: case 104 /* VoidKeyword */: - case 135 /* SymbolKeyword */: - case 159 /* ConstructorType */: - case 158 /* FunctionType */: - case 160 /* TypeQuery */: - case 157 /* TypeReference */: - case 164 /* UnionType */: - case 165 /* IntersectionType */: - case 166 /* ParenthesizedType */: - case 167 /* ThisType */: - case 168 /* TypeOperator */: - case 169 /* IndexedAccessType */: - case 170 /* MappedType */: - case 171 /* LiteralType */: + case 136 /* SymbolKeyword */: + case 160 /* ConstructorType */: + case 159 /* FunctionType */: + case 161 /* TypeQuery */: + case 158 /* TypeReference */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: + case 167 /* ParenthesizedType */: + case 168 /* ThisType */: + case 169 /* TypeOperator */: + case 170 /* IndexedAccessType */: + case 171 /* MappedType */: + case 172 /* LiteralType */: // TypeScript type nodes are elided. - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: // TypeScript index signatures are elided. - case 145 /* Decorator */: + case 146 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 228 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: // TypeScript property declarations are elided. return undefined; - case 150 /* Constructor */: + case 151 /* Constructor */: return visitConstructor(node); - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -45630,7 +47287,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -45641,35 +47298,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 255 /* HeritageClause */: + case 258 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 144 /* Parameter */: + case 145 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -45679,33 +47336,33 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return visitCallExpression(node); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return visitNewExpression(node); - case 201 /* NonNullExpression */: + case 202 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -45810,13 +47467,14 @@ var ts; // } var classDeclaration = ts.createClassDeclaration( /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); - var emitFlags = ts.getEmitFlags(node); + /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause)); // To better align with the old emitter, we should not emit a trailing source map // entry if the class has static properties. + var emitFlags = ts.getEmitFlags(node); if (hasStaticProperties) { emitFlags |= 32 /* NoTrailingSourceMap */; } + ts.setTextRange(classDeclaration, node); ts.setOriginalNode(classDeclaration, node); ts.setEmitFlags(classDeclaration, emitFlags); return classDeclaration; @@ -45924,12 +47582,18 @@ var ts; // } var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, hasExtendsClause); - var classExpression = ts.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members, location); + var classExpression = ts.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); + ts.setTextRange(classExpression, location); // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference // or decoratedClassAlias if the class contain self-reference. - var statement = ts.createLetStatement(declName, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression, location); + var statement = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(declName, + /*type*/ undefined, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression) + ], 1 /* Let */)); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, location); ts.setCommentRange(statement, node); return statement; } @@ -45946,10 +47610,11 @@ var ts; var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84 /* ExtendsKeyword */; })); - var classExpression = ts.setOriginalNode(ts.createClassExpression( + var classExpression = ts.createClassExpression( /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, heritageClauses, members, - /*location*/ node), node); + /*typeParameters*/ undefined, heritageClauses, members); + ts.setOriginalNode(classExpression, node); + ts.setTextRange(classExpression, node); if (staticProperties.length > 0) { var expressions = []; var temp = ts.createTempVariable(hoistVariableDeclaration); @@ -45981,7 +47646,7 @@ var ts; members.push(constructor); } ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement)); - return ts.createNodeArray(members, /*location*/ node.members); + return ts.setTextRange(ts.createNodeArray(members), /*location*/ node.members); } /** * Transforms (or creates) a constructor for a class. @@ -46006,10 +47671,9 @@ var ts; // constructor(${parameters}) { // ${body} // } - return ts.startOnNewLine(ts.setOriginalNode(ts.createConstructor( + return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(ts.createConstructor( /*decorators*/ undefined, - /*modifiers*/ undefined, parameters, body, - /*location*/ constructor || node), constructor)); + /*modifiers*/ undefined, parameters, body), constructor || node), constructor)); } /** * Transforms (or creates) the parameters for the constructor of a class with @@ -46092,10 +47756,10 @@ var ts; } // End the lexical environment. ts.addRange(statements, endLexicalEnvironment()); - return ts.createBlock(ts.createNodeArray(statements, + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ constructor ? constructor.body.statements : node.members), - /*location*/ constructor ? constructor.body : undefined, - /*multiLine*/ true); + /*multiLine*/ true), + /*location*/ constructor ? constructor.body : undefined); } /** * Adds super call and preceding prologue directives into the list of statements. @@ -46113,7 +47777,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -46150,9 +47814,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536 /* NoComments */); - return ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), propertyName, - /*location*/ node.name), localName), - /*location*/ ts.moveRangePos(node, -1))); + return ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1))); } /** * Gets all property declarations with initializers on either the static or instance side of a class. @@ -46186,7 +47848,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 147 /* PropertyDeclaration */ + return member.kind === 148 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } @@ -46321,12 +47983,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -46479,7 +48141,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 147 /* PropertyDeclaration */ + ? member.kind === 148 /* PropertyDeclaration */ ? ts.createVoidZero() : ts.createNull() : undefined; @@ -46585,7 +48247,7 @@ var ts; (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(35 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { - decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true))); + decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); } } } @@ -46598,10 +48260,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */ - || kind === 147 /* PropertyDeclaration */; + return kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */ + || kind === 148 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -46611,7 +48273,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 149 /* MethodDeclaration */; + return node.kind === 150 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -46622,12 +48284,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return true; } return false; @@ -46639,15 +48301,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 147 /* PropertyDeclaration */: - case 144 /* Parameter */: - case 151 /* GetAccessor */: + case 148 /* PropertyDeclaration */: + case 145 /* Parameter */: + case 152 /* GetAccessor */: return serializeTypeNode(node.type); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 149 /* MethodDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 150 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -46684,7 +48346,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 151 /* GetAccessor */) { + if (container && node.kind === 152 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -46730,21 +48392,24 @@ var ts; } switch (node.kind) { case 104 /* VoidKeyword */: + case 138 /* UndefinedKeyword */: + case 94 /* NullKeyword */: + case 129 /* NeverKeyword */: return ts.createVoidZero(); - case 166 /* ParenthesizedType */: + case 167 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return ts.createIdentifier("Function"); - case 162 /* ArrayType */: - case 163 /* TupleType */: + case 163 /* ArrayType */: + case 164 /* TupleType */: return ts.createIdentifier("Array"); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: case 121 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: return ts.createIdentifier("String"); - case 171 /* LiteralType */: + case 172 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -46760,49 +48425,22 @@ var ts; break; case 132 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return serializeTypeReferenceNode(node); - case 165 /* IntersectionType */: - case 164 /* UnionType */: - { - var unionOrIntersection = node; - var serializedUnion = void 0; - for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - var serializedIndividual = serializeTypeNode(typeNode); - // Non identifier - if (serializedIndividual.kind !== 70 /* Identifier */) { - serializedUnion = undefined; - break; - } - // One of the individual is global object, return immediately - if (serializedIndividual.text === "Object") { - return serializedIndividual; - } - // Different types - if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { - serializedUnion = undefined; - break; - } - serializedUnion = serializedIndividual; - } - // If we were able to find common type - if (serializedUnion) { - return serializedUnion; - } - } - // Fallthrough - case 160 /* TypeQuery */: - case 168 /* TypeOperator */: - case 169 /* IndexedAccessType */: - case 170 /* MappedType */: - case 161 /* TypeLiteral */: + case 166 /* IntersectionType */: + case 165 /* UnionType */: + return serializeUnionOrIntersectionType(node); + case 161 /* TypeQuery */: + case 169 /* TypeOperator */: + case 170 /* IndexedAccessType */: + case 171 /* MappedType */: + case 162 /* TypeLiteral */: case 118 /* AnyKeyword */: - case 167 /* ThisType */: + case 168 /* ThisType */: break; default: ts.Debug.failBadSyntaxKind(node); @@ -46810,6 +48448,37 @@ var ts; } return ts.createIdentifier("Object"); } + function serializeUnionOrIntersectionType(node) { + var serializedUnion; + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + if (ts.isVoidExpression(serializedIndividual)) { + // If we dont have any other type already set, set the initial type + if (!serializedUnion) { + serializedUnion = serializedIndividual; + } + } + else if (ts.isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") { + // One of the individual is global object, return immediately + return serializedIndividual; + } + else if (serializedUnion && !ts.isVoidExpression(serializedUnion)) { + // Different types + if (!ts.isIdentifier(serializedUnion) || + !ts.isIdentifier(serializedIndividual) || + serializedUnion.text !== serializedIndividual.text) { + return ts.createIdentifier("Object"); + } + } + else { + // Initialize the union type + serializedUnion = serializedIndividual; + } + } + // If we were able to find common type, use it + return serializedUnion; + } /** * Serializes a TypeReferenceNode to an appropriate JS constructor value for use with * decorator type metadata. @@ -46859,15 +48528,15 @@ var ts; case 70 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. - var name_32 = ts.getMutableClone(node); - name_32.flags &= ~8 /* Synthesized */; - name_32.original = undefined; - name_32.parent = currentScope; + var name = ts.getMutableClone(node); + name.flags &= ~8 /* Synthesized */; + name.original = undefined; + name.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_32), ts.createLiteral("undefined")), name_32); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } - return name_32; - case 141 /* QualifiedName */: + return name; + case 142 /* QualifiedName */: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -46935,7 +48604,7 @@ var ts; hoistVariableDeclaration(generatedName); expression = ts.createAssignment(generatedName, expression); } - return ts.setOriginalNode(ts.createComputedPropertyName(expression, /*location*/ name), name); + return ts.updateComputedPropertyName(name, expression); } else { return name; @@ -46953,7 +48622,7 @@ var ts; function visitHeritageClause(node) { if (node.token === 84 /* ExtendsKeyword */) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(84 /* ExtendsKeyword */, types, node); + return ts.setTextRange(ts.createHeritageClause(84 /* ExtendsKeyword */, types), node); } return undefined; } @@ -46966,9 +48635,8 @@ var ts; * @param node The ExpressionWithTypeArguments to transform. */ function visitExpressionWithTypeArguments(node) { - var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); - return ts.createExpressionWithTypeArguments( - /*typeArguments*/ undefined, expression, node); + return ts.updateExpressionWithTypeArguments(node, + /*typeArguments*/ undefined, ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); } /** * Determines whether to emit a function-like declaration. We should not emit the @@ -47138,11 +48806,11 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), /*questionToken*/ undefined, - /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), - /*location*/ ts.moveRangePastModifiers(node)); + /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); // While we emit the source map for the node after skipping decorators and modifiers, // we need to emit the comments for the original range. ts.setOriginalNode(parameter, node); + ts.setTextRange(parameter, ts.moveRangePastModifiers(node)); ts.setCommentRange(parameter, node); ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); ts.setEmitFlags(parameter.name, 32 /* NoTrailingSourceMap */); @@ -47161,8 +48829,7 @@ var ts; // elide statement if there are no initialized variables. return undefined; } - return ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), - /*location*/ node); + return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -47175,7 +48842,7 @@ var ts; /*needsValue*/ false, createNamespaceExportExpression); } else { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression)), /*location*/ node); } } @@ -47289,9 +48956,9 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], /*type*/ undefined, transformEnumBody(node, containerName)), - /*typeArguments*/ undefined, [moduleArg]), - /*location*/ node); + /*typeArguments*/ undefined, [moduleArg])); ts.setOriginalNode(enumStatement, node); + ts.setTextRange(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); // Add a DeclarationMarker for the enum to preserve trailing comments and mark @@ -47312,8 +48979,7 @@ var ts; ts.addRange(statements, ts.map(node.members, transformEnumMember)); ts.addRange(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceLocalName; - return ts.createBlock(ts.createNodeArray(statements, /*location*/ node.members), - /*location*/ undefined, + return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); } /** @@ -47326,9 +48992,7 @@ var ts; // we pass false as 'generateNameForComputedPropertyName' for a backward compatibility purposes // old emitter always generate 'expression' part of the name as-is. var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); - return ts.createStatement(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name, - /*location*/ member), - /*location*/ member); + return ts.setTextRange(ts.createStatement(ts.setTextRange(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name), member)), member); } /** * Transforms the value of an enum member. @@ -47381,8 +49045,8 @@ var ts; if (!currentScopeFirstDeclarationsOfName) { currentScopeFirstDeclarationsOfName = ts.createMap(); } - if (!(name in currentScopeFirstDeclarationsOfName)) { - currentScopeFirstDeclarationsOfName[name] = node; + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } } @@ -47392,9 +49056,9 @@ var ts; */ function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_33 = node.symbol && node.symbol.name; - if (name_33) { - return currentScopeFirstDeclarationsOfName[name_33] === node; + var name = node.symbol && node.symbol.name; + if (name) { + return currentScopeFirstDeclarationsOfName.get(name) === node; } } return false; @@ -47411,7 +49075,7 @@ var ts; recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 229 /* EnumDeclaration */) { + if (node.kind === 231 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -47503,9 +49167,9 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], /*type*/ undefined, transformModuleBody(node, containerName)), - /*typeArguments*/ undefined, [moduleArg]), - /*location*/ node); + /*typeArguments*/ undefined, [moduleArg])); ts.setOriginalNode(moduleStatement, node); + ts.setTextRange(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); // Add a DeclarationMarker for the namespace to preserve trailing comments and mark @@ -47530,8 +49194,8 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 231 /* ModuleBlock */) { - ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); + if (body.kind === 233 /* ModuleBlock */) { + saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; } @@ -47552,10 +49216,10 @@ var ts; currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; - var block = ts.createBlock(ts.createNodeArray(statements, + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ statementsLocation), - /*location*/ blockLocation, /*multiLine*/ true); + ts.setTextRange(block, blockLocation); // namespace hello.hi.world { // function foo() {} // @@ -47576,13 +49240,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 231 /* ModuleBlock */) { + if (body.kind !== 233 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 230 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 232 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -47623,7 +49287,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 237 /* NamespaceImport */) { + if (node.kind === 239 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -47730,10 +49394,10 @@ var ts; if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; - return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ + return ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.setOriginalNode(ts.createVariableDeclaration(node.name, /*type*/ undefined, moduleReference), node) - ]), node), node); + ])), node), node); } else { // exports.${name} = ${moduleReference}; @@ -47778,7 +49442,7 @@ var ts; * Creates a statement for the provided expression. This is used in calls to `map`. */ function expressionToStatement(expression) { - return ts.createStatement(expression, /*location*/ undefined); + return ts.createStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), ts.getLocalName(node)); @@ -47788,10 +49452,10 @@ var ts; statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue), location); + return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue, location); + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); } function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) { return ts.getNamespaceMemberName(currentNamespaceContainerName, name, /*allowComments*/ false, /*allowSourceMaps*/ true); @@ -47819,7 +49483,7 @@ var ts; function getClassAliasIfNeeded(node) { if (resolver.getNodeCheckFlags(node) & 8388608 /* ClassWithConstructorReference */) { enableSubstitutionForClassAliases(); - var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); + var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.unescapeIdentifier(node.name.text) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; hoistVariableDeclaration(classAlias); return classAlias; @@ -47846,7 +49510,7 @@ var ts; // substitute class names inside of a class declaration. context.enableSubstitution(70 /* Identifier */); // Keep track of class aliases. - classAliases = ts.createMap(); + classAliases = []; } } function enableSubstitutionForNamespaceExports() { @@ -47855,25 +49519,25 @@ var ts; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. context.enableSubstitution(70 /* Identifier */); - context.enableSubstitution(258 /* ShorthandPropertyAssignment */); + context.enableSubstitution(261 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(230 /* ModuleDeclaration */); + context.enableEmitNotification(232 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 230 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 232 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 229 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 231 /* EnumDeclaration */; } /** * Hook for node emit. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2 /* NamespaceExports */; @@ -47881,18 +49545,18 @@ var ts; if (enabledSubstitutions & 8 /* NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { applicableSubstitutions |= 8 /* NonQualifiedEnumMembers */; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; } /** * Hooks node substitutions. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -47902,16 +49566,16 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2 /* NamespaceExports */) { - var name_34 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_34); + var name = node.name; + var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { // A shorthand property with an assignment initializer is probably part of a // destructuring assignment if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_34, initializer, /*location*/ node); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); } - return ts.createPropertyAssignment(name_34, exportedName, /*location*/ node); + return ts.setTextRange(ts.createPropertyAssignment(name, exportedName), node); } } return node; @@ -47920,9 +49584,9 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return substituteExpressionIdentifier(node); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -47960,11 +49624,12 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 261 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 230 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 229 /* EnumDeclaration */); + if (container && container.kind !== 264 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 232 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 231 /* EnumDeclaration */); if (substitute) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, /*location*/ node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), + /*location*/ node); } } } @@ -48011,11 +49676,11 @@ var ts; }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(paramHelper); - return ts.createCall(ts.getHelperName("__param"), + return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression - ], location); + ]), location); } var metadataHelper = { name: "typescript:metadata", @@ -48040,7 +49705,7 @@ var ts; function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) { context.requestEmitHelper(decorateHelper); var argumentsArray = []; - argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, /*location*/ undefined, /*multiLine*/ true)); + argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, /*multiLine*/ true)); argumentsArray.push(target); if (memberName) { argumentsArray.push(memberName); @@ -48048,7 +49713,8 @@ var ts; argumentsArray.push(descriptor); } } - return ts.createCall(ts.getHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray, location); + return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), + /*typeArguments*/ undefined, argumentsArray), location); } })(ts || (ts = {})); /// @@ -48078,37 +49744,37 @@ var ts; return node; } switch (node.kind) { - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 213 /* ForOfStatement */: + case 215 /* ForOfStatement */: return visitForOfStatement(node); - case 211 /* ForStatement */: + case 213 /* ForStatement */: return visitForStatement(node); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return visitVoidExpression(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return visitConstructorDeclaration(node); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: return visitGetAccessorDeclaration(node); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return visitFunctionExpression(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return visitArrowFunction(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return visitParameter(node); - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return visitExpressionStatement(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); default: return ts.visitEachChild(node, visitor, context); @@ -48117,9 +49783,9 @@ var ts; function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; - for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { - var e = elements_3[_i]; - if (e.kind === 259 /* SpreadAssignment */) { + for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { + var e = elements_4[_i]; + if (e.kind === 262 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -48131,7 +49797,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 257 /* PropertyAssignment */) { + if (e.kind === 260 /* PropertyAssignment */) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -48153,7 +49819,7 @@ var ts; // If the first element is a spread element, then the first argument to __assign is {}: // { ...o, a, b, ...o2 } => __assign({}, o, {a, b}, o2) var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 176 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 177 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -48216,26 +49882,26 @@ var ts; /*skipInitializer*/ true); if (ts.some(declarations)) { var statement = ts.createVariableStatement( - /*modifiers*/ undefined, ts.updateVariableDeclarationList(initializer, declarations), - /*location*/ initializer); + /*modifiers*/ undefined, ts.updateVariableDeclarationList(initializer, declarations)); + ts.setTextRange(statement, initializer); leadingStatements = ts.append(leadingStatements, statement); } } else if (ts.isAssignmentPattern(initializer)) { temp = ts.createTempVariable(/*recordTempVariable*/ undefined); - var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.createAssignment(initializer, temp, /*location*/ node.initializer)), visitor, context, 1 /* ObjectRest */); - leadingStatements = ts.append(leadingStatements, ts.createStatement(expression, /*location*/ node.initializer)); + var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.setTextRange(ts.createAssignment(initializer, temp), node.initializer)), visitor, context, 1 /* ObjectRest */); + leadingStatements = ts.append(leadingStatements, ts.setTextRange(ts.createStatement(expression), node.initializer)); } } if (temp) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var statement = ts.visitNode(node.statement, visitor, ts.isStatement); var block = ts.isBlock(statement) - ? ts.updateBlock(statement, ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements), statement.statements)) - : ts.createBlock(ts.append(leadingStatements, statement), statement, /*multiLine*/ true); - return ts.updateForOf(node, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, /*type*/ undefined, /*initializer*/ undefined, node.initializer) - ], node.initializer, 1 /* Let */), expression, block); + ? ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements)), statement.statements)) + : ts.setTextRange(ts.createBlock(ts.append(leadingStatements, statement), /*multiLine*/ true), statement); + return ts.updateForOf(node, ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer) + ], 1 /* Let */), node.initializer), expression, block); } return ts.visitEachChild(node, visitor, context); } @@ -48307,7 +49973,7 @@ var ts; var trailingStatements = endLexicalEnvironment(); if (ts.some(leadingStatements) || ts.some(trailingStatements)) { var block = ts.convertToFunctionBody(body, /*multiLine*/ true); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements)), block.statements)); } return body; } @@ -48320,6 +49986,10 @@ var ts; text: "\n var __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };" }; function createAssignHelper(context, attributesSegments) { + if (context.getCompilerOptions().target >= 2 /* ES2015 */) { + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), + /*typeArguments*/ undefined, attributesSegments); + } context.requestEmitHelper(assignHelper); return ts.createCall(ts.getHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); @@ -48361,11 +50031,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 246 /* JsxElement */: + case 248 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 247 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 252 /* JsxExpression */: + case 255 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -48375,11 +50045,11 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 252 /* JsxExpression */: + case 255 /* JsxExpression */: return visitJsxExpression(node); - case 246 /* JsxElement */: + case 248 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 247 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); default: ts.Debug.failBadSyntaxKind(node); @@ -48395,7 +50065,7 @@ var ts; function visitJsxOpeningLikeElement(node, children, isChild, location) { var tagName = getTagName(node); var objectProperties; - var attrs = node.attributes; + var attrs = node.attributes.properties; if (attrs.length === 0) { // When there are no attributes, React wants "null" objectProperties = ts.createNull(); @@ -48434,13 +50104,16 @@ var ts; } function transformJsxAttributeInitializer(node) { if (node === undefined) { - return ts.createLiteral(true); + return ts.createTrue(); } else if (node.kind === 9 /* StringLiteral */) { var decoded = tryDecodeEntities(node.text); - return decoded ? ts.createLiteral(decoded, /*location*/ node) : node; + return decoded ? ts.setTextRange(ts.createLiteral(decoded), node) : node; } - else if (node.kind === 252 /* JsxExpression */) { + else if (node.kind === 255 /* JsxExpression */) { + if (node.expression === undefined) { + return ts.createTrue(); + } return visitJsxExpression(node); } else { @@ -48448,54 +50121,61 @@ var ts; } } function visitJsxText(node) { - var text = ts.getTextOfNode(node, /*includeTrivia*/ true); - var parts; + var fixed = fixupWhitespaceAndDecodeEntities(ts.getTextOfNode(node, /*includeTrivia*/ true)); + return fixed === undefined ? undefined : ts.createLiteral(fixed); + } + /** + * 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 + * See also https://www.w3.org/TR/html4/struct/text.html#h-9.1 and https://www.w3.org/TR/CSS2/text.html#white-space-model + * + * An equivalent algorithm would be: + * - If there is only one line, return it. + * - If there is only whitespace (but multiple lines), return `undefined`. + * - Split the text into lines. + * - 'trimRight' the first line, 'trimLeft' the last line, 'trim' middle lines. + * - Decode entities on each line (individually). + * - Remove empty lines and join the rest with " ". + */ + function fixupWhitespaceAndDecodeEntities(text) { + var acc; + // First non-whitespace character on this line. var firstNonWhitespace = 0; + // Last non-whitespace character on this line. 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 + // These initial values are special because the first line is: + // firstNonWhitespace = 0 to indicate that we want leading whitsepace, + // but lastNonWhitespace = -1 as a special flag to indicate that we *don't* include the line if it's all whitespace. 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); - if (!parts) { - parts = []; - } - // We do not escape the string here as that is handled by the printer - // when it emits the literal. We do, however, need to decode JSX entities. - parts.push(ts.createLiteral(decodeEntities(part))); + // If we've seen any non-whitespace characters on this line, add the 'trim' of the line. + // (lastNonWhitespace === -1 is a special flag to detect whether the first line is all whitespace.) + if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) { + acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1)); } + // Reset firstNonWhitespace for the next line. + // Don't bother to reset lastNonWhitespace because we ignore it if firstNonWhitespace = -1. firstNonWhitespace = -1; } - else if (!ts.isWhiteSpace(c)) { + else if (!ts.isWhiteSpaceSingleLine(c)) { lastNonWhitespace = i; if (firstNonWhitespace === -1) { firstNonWhitespace = i; } } } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - if (!parts) { - parts = []; - } - // We do not escape the string here as that is handled by the printer - // when it emits the literal. We do, however, need to decode JSX entities. - parts.push(ts.createLiteral(decodeEntities(part))); - } - if (parts) { - return ts.reduceLeft(parts, aggregateJsxTextParts); - } - return undefined; + return firstNonWhitespace !== -1 + ? addLineOfJsxText(acc, text.substr(firstNonWhitespace)) + : acc; } - /** - * Aggregates two expressions by interpolating them with a whitespace literal. - */ - function aggregateJsxTextParts(left, right) { - return ts.createAdd(ts.createAdd(left, ts.createLiteral(" ")), right); + function addLineOfJsxText(acc, trimmedLine) { + // We do not escape the string here as that is handled by the printer + // when it emits the literal. We do, however, need to decode JSX entities. + var decoded = decodeEntities(trimmedLine); + return acc === undefined ? decoded : acc + " " + decoded; } /** * Replace entities like " ", "{", and "�" with the characters they encode. @@ -48510,7 +50190,7 @@ var ts; return String.fromCharCode(parseInt(hex, 16)); } else { - var ch = entities[word]; + var ch = entities.get(word); // If this is not a valid entity, then just use `match` (replace it with itself, i.e. don't replace) return ch ? String.fromCharCode(ch) : match; } @@ -48522,16 +50202,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 246 /* JsxElement */) { + if (node.kind === 248 /* JsxElement */) { return getTagName(node.openingElement); } else { - var name_35 = node.tagName; - if (ts.isIdentifier(name_35) && ts.isIntrinsicJsxName(name_35.text)) { - return ts.createLiteral(name_35.text); + var name = node.tagName; + if (ts.isIdentifier(name) && ts.isIntrinsicJsxName(name.text)) { + return ts.createLiteral(name.text); } else { - return ts.createExpressionFromEntityName(name_35); + return ts.createExpressionFromEntityName(name); } } } @@ -48554,7 +50234,7 @@ var ts; } } ts.transformJsx = transformJsx; - var entities = ts.createMap({ + var entities = ts.createMapFromTemplate({ "quot": 0x0022, "amp": 0x0026, "apos": 0x0027, @@ -48862,19 +50542,19 @@ var ts; case 119 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: // ES2017 'await' expressions must be transformed for targets < ES2017. return visitAwaitExpression(node); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: // ES2017 method declarations may be 'async' return visitMethodDeclaration(node); - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: // ES2017 function declarations may be 'async' return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: // ES2017 function expressions may be 'async' return visitFunctionExpression(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: // ES2017 arrow functions may be 'async' return visitArrowFunction(node); default: @@ -48889,9 +50569,8 @@ var ts; * @param node The node to visit. */ function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield( - /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression), - /*location*/ node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createYield( + /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); } /** * Visits a MethodDeclaration node. @@ -48964,7 +50643,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 185 /* ArrowFunction */; + var isArrowFunction = node.kind === 186 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current @@ -48976,7 +50655,8 @@ var ts; var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(statements, /*location*/ node.body, /*multiLine*/ true); + var block = ts.createBlock(statements, /*multiLine*/ true); + ts.setTextRange(block, node.body); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. if (languageVersion >= 2 /* ES2015 */) { @@ -48996,7 +50676,7 @@ var ts; var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(block.statements, declarations), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); } return expression; } @@ -49009,7 +50689,7 @@ var ts; startLexicalEnvironment(); var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); var declarations = endLexicalEnvironment(); - return ts.updateBlock(visited, ts.createNodeArray(ts.concatenate(visited.statements, declarations), visited.statements)); + return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); } } function getPromiseConstructor(type) { @@ -49028,24 +50708,24 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(179 /* CallExpression */); - context.enableSubstitution(177 /* PropertyAccessExpression */); - context.enableSubstitution(178 /* ElementAccessExpression */); + context.enableSubstitution(180 /* CallExpression */); + context.enableSubstitution(178 /* PropertyAccessExpression */); + context.enableSubstitution(179 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(226 /* ClassDeclaration */); - context.enableEmitNotification(149 /* MethodDeclaration */); - context.enableEmitNotification(151 /* GetAccessor */); - context.enableEmitNotification(152 /* SetAccessor */); - context.enableEmitNotification(150 /* Constructor */); + context.enableEmitNotification(228 /* ClassDeclaration */); + context.enableEmitNotification(150 /* MethodDeclaration */); + context.enableEmitNotification(152 /* GetAccessor */); + context.enableEmitNotification(153 /* SetAccessor */); + context.enableEmitNotification(151 /* Constructor */); } } function substituteExpression(node) { switch (node.kind) { - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) { return substituteCallExpression(node); } @@ -49089,53 +50769,53 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 226 /* ClassDeclaration */ - || kind === 150 /* Constructor */ - || kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */; + return kind === 228 /* ClassDeclaration */ + || kind === 151 /* Constructor */ + || kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */; } /** * Hook for node emit. * + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { var savedCurrentSuperContainer = currentSuperContainer; currentSuperContainer = node; - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSuperContainer = savedCurrentSuperContainer; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } /** * Hooks node substitutions. * + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */) { return substituteExpression(node); } return node; } function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { if (flags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression]), "value", location); + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } else { - return ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression], location); + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), location); } } function getSuperContainerAsyncMethodFlags() { @@ -49198,7 +50878,7 @@ var ts; return node; } switch (node.kind) { - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -49223,25 +50903,21 @@ var ts; // Transforms `a[x] **= b` into `(_a = a)[_x = x] = Math.pow(_a[_x], b)` var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createElementAccess(ts.createAssignment(expressionTemp, left.expression, /*location*/ left.expression), ts.createAssignment(argumentExpressionTemp, left.argumentExpression, /*location*/ left.argumentExpression), - /*location*/ left); - value = ts.createElementAccess(expressionTemp, argumentExpressionTemp, - /*location*/ left); + target = ts.setTextRange(ts.createElementAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), ts.setTextRange(ts.createAssignment(argumentExpressionTemp, left.argumentExpression), left.argumentExpression)), left); + value = ts.setTextRange(ts.createElementAccess(expressionTemp, argumentExpressionTemp), left); } else if (ts.isPropertyAccessExpression(left)) { // Transforms `a.x **= b` into `(_a = a).x = Math.pow(_a.x, b)` var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createPropertyAccess(ts.createAssignment(expressionTemp, left.expression, /*location*/ left.expression), left.name, - /*location*/ left); - value = ts.createPropertyAccess(expressionTemp, left.name, - /*location*/ left); + target = ts.setTextRange(ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), left.name), left); + value = ts.setTextRange(ts.createPropertyAccess(expressionTemp, left.name), left); } else { // Transforms `a **= b` into `a = Math.pow(a, b)` target = left; value = left; } - return ts.createAssignment(target, ts.createMathPow(value, right, /*location*/ node), /*location*/ node); + return ts.setTextRange(ts.createAssignment(target, ts.createMathPow(value, right, /*location*/ node)), node); } function visitExponentiationExpression(node) { // Transforms `a ** b` into `Math.pow(a, b)` @@ -49299,6 +50975,82 @@ var ts; */ SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; })(SuperCaptureResult || (SuperCaptureResult = {})); + // Facts we track as we traverse the tree + var HierarchyFacts; + (function (HierarchyFacts) { + HierarchyFacts[HierarchyFacts["None"] = 0] = "None"; + // + // Ancestor facts + // + HierarchyFacts[HierarchyFacts["Function"] = 1] = "Function"; + HierarchyFacts[HierarchyFacts["ArrowFunction"] = 2] = "ArrowFunction"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBody"] = 4] = "AsyncFunctionBody"; + HierarchyFacts[HierarchyFacts["NonStaticClassElement"] = 8] = "NonStaticClassElement"; + HierarchyFacts[HierarchyFacts["CapturesThis"] = 16] = "CapturesThis"; + HierarchyFacts[HierarchyFacts["ExportedVariableStatement"] = 32] = "ExportedVariableStatement"; + HierarchyFacts[HierarchyFacts["TopLevel"] = 64] = "TopLevel"; + HierarchyFacts[HierarchyFacts["Block"] = 128] = "Block"; + HierarchyFacts[HierarchyFacts["IterationStatement"] = 256] = "IterationStatement"; + HierarchyFacts[HierarchyFacts["IterationStatementBlock"] = 512] = "IterationStatementBlock"; + HierarchyFacts[HierarchyFacts["ForStatement"] = 1024] = "ForStatement"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 2048] = "ForInOrForOfStatement"; + HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 4096] = "ConstructorWithCapturedSuper"; + HierarchyFacts[HierarchyFacts["ComputedPropertyName"] = 8192] = "ComputedPropertyName"; + // NOTE: do not add more ancestor flags without also updating AncestorFactsMask below. + // + // Ancestor masks + // + HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 16383] = "AncestorFactsMask"; + // We are always in *some* kind of block scope, but only specific block-scope containers are + // top-level or Blocks. + HierarchyFacts[HierarchyFacts["BlockScopeIncludes"] = 0] = "BlockScopeIncludes"; + HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 4032] = "BlockScopeExcludes"; + // A source file is a top-level block scope. + HierarchyFacts[HierarchyFacts["SourceFileIncludes"] = 64] = "SourceFileIncludes"; + HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 3968] = "SourceFileExcludes"; + // Functions, methods, and accessors are both new lexical scopes and new block scopes. + HierarchyFacts[HierarchyFacts["FunctionIncludes"] = 65] = "FunctionIncludes"; + HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 16286] = "FunctionExcludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyIncludes"] = 69] = "AsyncFunctionBodyIncludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 16278] = "AsyncFunctionBodyExcludes"; + // Arrow functions are lexically scoped to their container, but are new block scopes. + HierarchyFacts[HierarchyFacts["ArrowFunctionIncludes"] = 66] = "ArrowFunctionIncludes"; + HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 16256] = "ArrowFunctionExcludes"; + // Constructors are both new lexical scopes and new block scopes. Constructors are also + // always considered non-static members of a class. + HierarchyFacts[HierarchyFacts["ConstructorIncludes"] = 73] = "ConstructorIncludes"; + HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 16278] = "ConstructorExcludes"; + // 'do' and 'while' statements are not block scopes. We track that the subtree is contained + // within an IterationStatement to indicate whether the embedded statement is an + // IterationStatementBlock. + HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 256] = "DoOrWhileStatementIncludes"; + HierarchyFacts[HierarchyFacts["DoOrWhileStatementExcludes"] = 0] = "DoOrWhileStatementExcludes"; + // 'for' statements are new block scopes and have special handling for 'let' declarations. + HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 1280] = "ForStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 3008] = "ForStatementExcludes"; + // 'for-in' and 'for-of' statements are new block scopes and have special handling for + // 'let' declarations. + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 2304] = "ForInOrForOfStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 1984] = "ForInOrForOfStatementExcludes"; + // Blocks (other than function bodies) are new block scopes. + HierarchyFacts[HierarchyFacts["BlockIncludes"] = 128] = "BlockIncludes"; + HierarchyFacts[HierarchyFacts["BlockExcludes"] = 3904] = "BlockExcludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockIncludes"] = 512] = "IterationStatementBlockIncludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 4032] = "IterationStatementBlockExcludes"; + // Computed property names track subtree flags differently than their containing members. + HierarchyFacts[HierarchyFacts["ComputedPropertyNameIncludes"] = 8192] = "ComputedPropertyNameIncludes"; + HierarchyFacts[HierarchyFacts["ComputedPropertyNameExcludes"] = 0] = "ComputedPropertyNameExcludes"; + // + // Subtree facts + // + HierarchyFacts[HierarchyFacts["NewTarget"] = 16384] = "NewTarget"; + HierarchyFacts[HierarchyFacts["NewTargetInComputedPropertyName"] = 32768] = "NewTargetInComputedPropertyName"; + // + // Subtree masks + // + HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -16384] = "SubtreeFactsMask"; + HierarchyFacts[HierarchyFacts["PropagateNewTargetMask"] = 49152] = "PropagateNewTargetMask"; + })(HierarchyFacts || (HierarchyFacts = {})); function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -49308,15 +51060,7 @@ var ts; context.onSubstituteNode = onSubstituteNode; var currentSourceFile; var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - var isInConstructorWithCapturedSuper; + var hierarchyFacts; /** * Used to track if we are emitting body of the converted loop */ @@ -49334,257 +51078,216 @@ var ts; } currentSourceFile = node; currentText = node.text; - var visited = saveStateAndInvoke(node, visitSourceFile); + var visited = visitSourceFile(node); ts.addEmitHelpers(visited, context.readEmitHelpers()); currentSourceFile = undefined; currentText = undefined; + hierarchyFacts = 0 /* None */; return visited; } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); + /** + * Sets the `HierarchyFacts` for this node prior to visiting this node's subtree, returning the facts set prior to modification. + * @param excludeFacts The existing `HierarchyFacts` to reset before visiting the subtree. + * @param includeFacts The new `HierarchyFacts` to set before visiting the subtree. + **/ + function enterSubtree(excludeFacts, includeFacts) { + var ancestorFacts = hierarchyFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383 /* AncestorFactsMask */; + return ancestorFacts; } - function dispatcher(node) { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - function saveStateAndInvoke(node, f) { - var savedEnclosingFunction = enclosingFunction; - var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - var savedEnclosingVariableStatement = enclosingVariableStatement; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var savedConvertedLoopState = convertedLoopState; - var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - // don't treat content of nodes that start new lexical environment as part of converted loop copy or constructor body - isInConstructorWithCapturedSuper = false; - convertedLoopState = undefined; - } - onBeforeVisitNode(node); - var visited = f(node); - isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 185 /* ArrowFunction */) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 131072 /* AsyncFunctionBody */)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - // keep track of the enclosing variable statement when in the context of - // variable statements, variable declarations, binding elements, and binding - // patterns. - switch (currentNode.kind) { - case 205 /* VariableStatement */: - enclosingVariableStatement = currentNode; - break; - case 224 /* VariableDeclarationList */: - case 223 /* VariableDeclaration */: - case 174 /* BindingElement */: - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - function returnCapturedThis(node) { - return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + /** + * Restores the `HierarchyFacts` for this node's ancestor after visiting this node's + * subtree, propagating specific facts from the subtree. + * @param ancestorFacts The `HierarchyFacts` of the ancestor to restore after visiting the subtree. + * @param excludeFacts The existing `HierarchyFacts` of the subtree that should not be propagated. + * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. + **/ + function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 /* SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 216 /* ReturnStatement */ && !node.expression; + return hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ + && node.kind === 218 /* ReturnStatement */ + && !node.expression; } - function shouldCheckNode(node) { - return (node.transformFlags & 64 /* ES2015 */) !== 0 || - node.kind === 219 /* LabeledStatement */ || - (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); + function shouldVisitNode(node) { + return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 + || convertedLoopState !== undefined + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && ts.isStatement(node)) + || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); } - function visitorWorker(node) { - if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { - return returnCapturedThis(node); - } - else if (shouldCheckNode(node)) { + function visitor(node) { + if (shouldVisitNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128 /* ContainsES2015 */ || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { - // we want to dive in this branch either if node has children with ES2015 specific syntax - // or we are inside constructor that captures result of the super call so all returns without expression should be - // rewritten. Note: we skip expressions since returns should never appear there - return ts.visitEachChild(node, visitor, context); - } else { return node; } } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); + function functionBodyVisitor(node) { + if (shouldVisitNode(node)) { + return visitBlock(node, /*isFunctionBody*/ true); } - else { - result = visitNodesInConvertedLoop(node); - } - return result; + return node; } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 216 /* ReturnStatement */: - node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; - return visitReturnStatement(node); - case 205 /* VariableStatement */: - return visitVariableStatement(node); - case 218 /* SwitchStatement */: - return visitSwitchStatement(node); - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: - return visitBreakOrContinueStatement(node); - case 98 /* ThisKeyword */: - return visitThisKeyword(node); - case 70 /* Identifier */: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); + function callExpressionVisitor(node) { + if (node.kind === 96 /* SuperKeyword */) { + return visitSuperKeyword(/*isExpressionOfCall*/ true); } + return visitor(node); } function visitJavaScript(node) { switch (node.kind) { case 114 /* StaticKeyword */: return undefined; // elide static keyword - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return visitClassDeclaration(node); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return visitClassExpression(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return visitParameter(node); - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return visitArrowFunction(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return visitFunctionExpression(node); - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return visitVariableDeclaration(node); case 70 /* Identifier */: return visitIdentifier(node); - case 224 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 219 /* LabeledStatement */: + case 220 /* SwitchStatement */: + return visitSwitchStatement(node); + case 234 /* CaseBlock */: + return visitCaseBlock(node); + case 206 /* Block */: + return visitBlock(node, /*isFunctionBody*/ false); + case 217 /* BreakStatement */: + case 216 /* ContinueStatement */: + return visitBreakOrContinueStatement(node); + case 221 /* LabeledStatement */: return visitLabeledStatement(node); - case 209 /* DoStatement */: - return visitDoStatement(node); - case 210 /* WhileStatement */: - return visitWhileStatement(node); - case 211 /* ForStatement */: - return visitForStatement(node); - case 212 /* ForInStatement */: - return visitForInStatement(node); - case 213 /* ForOfStatement */: - return visitForOfStatement(node); - case 207 /* ExpressionStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); + case 213 /* ForStatement */: + return visitForStatement(node, /*outermostLabeledStatement*/ undefined); + case 214 /* ForInStatement */: + return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); + case 215 /* ForOfStatement */: + return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); + case 209 /* ExpressionStatement */: return visitExpressionStatement(node); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return visitCatchClause(node); - case 258 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 175 /* ArrayLiteralExpression */: + case 143 /* ComputedPropertyName */: + return visitComputedPropertyName(node); + case 176 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return visitCallExpression(node); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return visitNewExpression(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 12 /* NoSubstitutionTemplateLiteral */: case 13 /* TemplateHead */: case 14 /* TemplateMiddle */: case 15 /* TemplateTail */: return visitTemplateLiteral(node); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return visitTemplateExpression(node); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return visitYieldExpression(node); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return visitSpreadElement(node); case 96 /* SuperKeyword */: - return visitSuperKeyword(); - case 195 /* YieldExpression */: - // `yield` will be handled by a generators transform. - return ts.visitEachChild(node, visitor, context); - case 149 /* MethodDeclaration */: + return visitSuperKeyword(/*isExpressionOfCall*/ false); + case 98 /* ThisKeyword */: + return visitThisKeyword(node); + case 203 /* MetaProperty */: + return visitMetaProperty(node); + case 150 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 205 /* VariableStatement */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + return visitAccessorDeclaration(node); + case 207 /* VariableStatement */: return visitVariableStatement(node); + case 218 /* ReturnStatement */: + return visitReturnStatement(node); default: - ts.Debug.failBadSyntaxKind(node); return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { + var ancestorFacts = enterSubtree(3968 /* SourceFileExcludes */, 64 /* SourceFileIncludes */); var statements = []; startLexicalEnvironment(); var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ false, visitor); addCaptureThisForNodeIfNeeded(statements, node); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } function visitSwitchStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; - var result = ts.visitEachChild(node, visitor, context); - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; + if (convertedLoopState !== undefined) { + var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + // for switch statement allow only non-labeled break + convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + var result = ts.visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + return ts.visitEachChild(node, visitor, context); + } + function visitCaseBlock(node) { + var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; + } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function visitReturnStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - convertedLoopState.nonLocalJumps |= 8 /* Return */; - return ts.createReturn(ts.createObjectLiteral([ - ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression - ? ts.visitNode(node.expression, visitor, ts.isExpression) - : ts.createVoidZero()) - ])); + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8 /* Return */; + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + node = returnCapturedThis(node); + } + return ts.createReturn(ts.createObjectLiteral([ + ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression + ? ts.visitNode(node.expression, visitor, ts.isExpression) + : ts.createVoidZero()) + ])); + } + else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 185 /* ArrowFunction */) { - // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. - convertedLoopState.containsLexicalThis = true; - return node; + if (convertedLoopState) { + if (hierarchyFacts & 2 /* ArrowFunction */) { + // if the enclosing function is an ArrowFunction then we use the captured 'this' keyword. + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + return node; } function visitIdentifier(node) { if (!convertedLoopState) { @@ -49593,7 +51296,7 @@ var ts; if (ts.isGeneratedIdentifier(node)) { return node; } - if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + if (node.text !== "arguments" || !resolver.isArgumentsLocalBinding(node)) { return node; } return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); @@ -49604,13 +51307,13 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 215 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; - var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + var jump = node.kind === 217 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(node.label.text)) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 215 /* BreakStatement */) { + if (node.kind === 217 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -49621,7 +51324,7 @@ var ts; } } else { - if (node.kind === 215 /* BreakStatement */) { + if (node.kind === 217 /* BreakStatement */) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); } @@ -49669,8 +51372,9 @@ var ts; /*type*/ undefined, transformClassLikeDeclarationToExpression(node)); ts.setOriginalNode(variable, node); var statements = []; - var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([variable]), /*location*/ node); + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([variable])); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, node); ts.startOnNewLine(statement); statements.push(statement); // Add an `export default` statement for default exports (for `--target es5 --module es6`) @@ -49788,7 +51492,7 @@ var ts; ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); statements.push(statement); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ node.members), /*location*/ undefined, /*multiLine*/ true); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); ts.setEmitFlags(block, 1536 /* NoComments */); return block; } @@ -49801,7 +51505,7 @@ var ts; */ function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node)), + statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node))), /*location*/ extendsClauseElement)); } } @@ -49813,6 +51517,9 @@ var ts; * @param extendsClauseElement The expression for the class `extends` clause. */ function addConstructor(statements, node, extendsClauseElement) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16278 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = ts.createFunctionDeclaration( @@ -49820,12 +51527,14 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, ts.getDeclarationName(node), /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), - /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), - /*location*/ constructor || node); + /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); + ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); } statements.push(constructorFunction); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; } /** * Transforms the parameters of the constructor declaration of a class. @@ -49871,30 +51580,35 @@ var ts; addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + // determine whether the class is known syntactically to be a derived class (e.g. a + // class that extends a value that is not syntactically known to be `null`). + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94 /* NullKeyword */; + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); // The last statement expression was replaced. Skip it. if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { - isInConstructorWithCapturedSuper = superCaptureStatus === 1 /* ReplaceSuperCapture */; - return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); - }); - ts.addRange(statements, body); + if (superCaptureStatus === 1 /* ReplaceSuperCapture */) { + hierarchyFacts |= 4096 /* ConstructorWithCapturedSuper */; + } + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset)); } // Return `_this` unless we're sure enough that it would be pointless to add a return statement. // If there's a constructor that we can tell returns in enough places, then we *do not* want to add a return. - if (extendsClauseElement + if (isDerivedClass && superCaptureStatus !== 2 /* ReplaceWithReturn */ && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createIdentifier("_this"))); } ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, + if (constructor) { + prependCaptureNewTargetIfNeeded(statements, constructor, /*copyOnWrite*/ false); + } + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ constructor ? constructor.body.statements : node.members), - /*location*/ constructor ? constructor.body : node, /*multiLine*/ true); + ts.setTextRange(block, constructor ? constructor.body : node); if (!constructor) { ts.setEmitFlags(block, 1536 /* NoComments */); } @@ -49907,17 +51621,17 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 216 /* ReturnStatement */) { + if (statement.kind === 218 /* ReturnStatement */) { return true; } - else if (statement.kind === 208 /* IfStatement */) { + else if (statement.kind === 210 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 204 /* Block */) { + else if (statement.kind === 206 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -49930,9 +51644,9 @@ var ts; * * @returns The new statement offset into the `statements` array. */ - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, isDerivedClass, hasSynthesizedSuper, statementOffset) { // If this isn't a derived class, just capture 'this' for arrow functions if necessary. - if (!hasExtendsClause) { + if (!isDerivedClass) { if (ctor) { addCaptureThisForNodeIfNeeded(statements, ctor); } @@ -49975,9 +51689,8 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + if (firstStatement.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } // Return the result if we have an immediate super() call on the last statement, @@ -49986,8 +51699,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 /* ContainsLexicalThis */ | 32768 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 192 /* BinaryExpression */ - || superCallExpression.left.kind !== 179 /* CallExpression */) { + if (superCallExpression.kind !== 193 /* BinaryExpression */ + || superCallExpression.left.kind !== 180 /* CallExpression */) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } // Shift comments from the original super call to the return statement. @@ -49996,18 +51709,18 @@ var ts; return 2 /* ReplaceWithReturn */; } // Perform the capture. - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement); // If we're actually replacing the original statement, we need to signal this to the caller. if (superCallExpression) { return 1 /* ReplaceSuperCapture */; } return 0 /* NoReplacement */; } + function createActualThis() { + return ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */); + } function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); + return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createIdentifier("_super"), ts.createNull()), ts.createFunctionApply(ts.createIdentifier("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis()); } /** * Visits a parameter declaration. @@ -50022,25 +51735,25 @@ var ts; else if (ts.isBindingPattern(node.name)) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. - return ts.setOriginalNode(ts.createParameter( + return ts.setOriginalNode(ts.setTextRange(ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, ts.getGeneratedNameForNode(node), /*questionToken*/ undefined, /*type*/ undefined, - /*initializer*/ undefined, + /*initializer*/ undefined), /*location*/ node), /*original*/ node); } else if (node.initializer) { // Initializers are elided - return ts.setOriginalNode(ts.createParameter( + return ts.setOriginalNode(ts.setTextRange(ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, node.name, /*questionToken*/ undefined, /*type*/ undefined, - /*initializer*/ undefined, + /*initializer*/ undefined), /*location*/ node), /*original*/ node); } @@ -50070,17 +51783,17 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_36 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; // A rest parameter cannot have a binding pattern or an initializer, // so let's just ignore it. if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_36)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_36, initializer); + if (ts.isBindingPattern(name)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_36, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer); } } } @@ -50115,13 +51828,11 @@ var ts; */ function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer)), - /*location*/ parameter)) - ], /*location*/ parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */), - /*elseStatement*/ undefined, - /*location*/ parameter); + var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([ + ts.createStatement(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer))), parameter)) + ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */)); statement.startsOnNewLine = true; + ts.setTextRange(statement, parameter); ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 524288 /* CustomPrologue */); statements.push(statement); } @@ -50158,22 +51869,21 @@ var ts; var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); // var param = []; - statements.push(ts.setEmitFlags(ts.createVariableStatement( + statements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(declarationName, /*type*/ undefined, ts.createArrayLiteral([])) - ]), + ])), /*location*/ parameter), 524288 /* CustomPrologue */)); // for (var _i = restIndex; _i < arguments.length; _i++) { // param[_i - restIndex] = arguments[_i]; // } - var forStatement = ts.createFor(ts.createVariableDeclarationList([ + var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) - ], /*location*/ parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), - /*location*/ parameter), ts.createPostfixIncrement(temp, /*location*/ parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 + ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([ + ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp - : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), + : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), /*location*/ parameter)) ])); ts.setEmitFlags(forStatement, 524288 /* CustomPrologue */); @@ -50187,7 +51897,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 185 /* ArrowFunction */) { + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 186 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -50197,11 +51907,52 @@ var ts; /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration("_this", /*type*/ undefined, initializer) - ]), originalStatement); + ])); ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 524288 /* CustomPrologue */); + ts.setTextRange(captureThisStatement, originalStatement); ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } + function prependCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { + if (hierarchyFacts & 16384 /* NewTarget */) { + var newTarget = void 0; + switch (node.kind) { + case 186 /* ArrowFunction */: + return statements; + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + // Methods and accessors cannot be constructors, so 'new.target' will + // always return 'undefined'. + newTarget = ts.createVoidZero(); + break; + case 151 /* Constructor */: + // Class constructors can only be called with `new`, so `this.constructor` + // should be relatively safe to use. + newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); + break; + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + // Functions can be called or constructed, and may have a `this` due to + // being a member or when calling an imported function via `other_1.f()`. + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 92 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + var captureNewTargetStatement = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_newTarget", + /*type*/ undefined, newTarget) + ])); + if (copyOnWrite) { + return [captureNewTargetStatement].concat(statements); + } + statements.unshift(captureNewTargetStatement); + } + return statements; + } /** * Adds statements to the class body function for a class to define the members of the * class. @@ -50213,20 +51964,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 203 /* SemicolonClassElement */: + case 205 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 149 /* MethodDeclaration */: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + case 150 /* MethodDeclaration */: + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 150 /* Constructor */: + case 151 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -50241,7 +51992,7 @@ var ts; * @param member The SemicolonClassElement node. */ function transformSemicolonClassElementToStatement(member) { - return ts.createEmptyStatement(/*location*/ member); + return ts.setTextRange(ts.createEmptyStatement(), member); } /** * Transforms a MethodDeclaration into a statement for a class body function. @@ -50249,14 +52000,15 @@ var ts; * @param receiver The receiver for the member. * @param member The MethodDeclaration node. */ - function transformClassMethodDeclarationToStatement(receiver, member) { + function transformClassMethodDeclarationToStatement(receiver, member, container) { + var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); - var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined); + var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), + var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); @@ -50264,6 +52016,7 @@ var ts; // No source map should be emitted for this statement to align with the // old emitter. ts.setEmitFlags(statement, 48 /* NoSourceMap */); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 16384 /* NewTarget */ : 0 /* None */); return statement; } /** @@ -50272,13 +52025,13 @@ var ts; * @param receiver The receiver for the member. * @param accessors The set of related get/set accessors. */ - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, /*startsOnNewLine*/ false), - /*location*/ ts.getSourceMapRange(accessors.firstAccessor)); + function transformAccessorsToStatement(receiver, accessors, container) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false)); // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } /** @@ -50287,8 +52040,9 @@ var ts; * * @param receiver The receiver for the member. */ - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); // To align with source maps in the old emitter, the receiver and property name // arguments are both mapped contiguously to the accessor name. var target = ts.getMutableClone(receiver); @@ -50299,7 +52053,7 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined); + var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); var getter = ts.createPropertyAssignment("get", getterFunction); @@ -50307,23 +52061,24 @@ var ts; properties.push(getter); } if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined); + var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); var setter = ts.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } - properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); + properties.push(ts.createPropertyAssignment("enumerable", ts.createTrue()), ts.createPropertyAssignment("configurable", ts.createTrue())); var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ target, propertyName, - ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true) + ts.createObjectLiteral(properties, /*multiLine*/ true) ]); if (startsOnNewLine) { call.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 16384 /* NewTarget */ : 0 /* None */); return call; } /** @@ -50335,14 +52090,20 @@ var ts; if (node.transformFlags & 16384 /* ContainsLexicalThis */) { enableSubstitutionsForCapturedThis(); } + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16256 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */); var func = ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformFunctionBody(node), node); + /*type*/ undefined, transformFunctionBody(node)); + ts.setTextRange(func, node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8 /* CapturesThis */); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; return func; } /** @@ -50351,12 +52112,24 @@ var ts; * @param node a FunctionExpression node. */ function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, - /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.transformFlags & 64 /* ES2015 */ + var ancestorFacts = ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */ + ? enterSubtree(16278 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) + : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 /* ES2015 */ ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 /* NewTarget */ + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionExpression(node, + /*modifiers*/ undefined, name, + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body); } /** * Visits a FunctionDeclaration node. @@ -50364,12 +52137,22 @@ var ts; * @param node a FunctionDeclaration node. */ function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, - /*decorators*/ undefined, node.modifiers, node.name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.transformFlags & 64 /* ES2015 */ + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 /* ES2015 */ ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 /* NewTarget */ + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionDeclaration(node, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body); } /** * Transforms a function-like node into a FunctionExpression. @@ -50378,18 +52161,24 @@ var ts; * @param location The source-map location for the new FunctionExpression. * @param name The name of the new FunctionExpression. */ - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 185 /* ArrowFunction */) { - enclosingNonArrowFunction = node; + function transformFunctionLikeToExpression(node, location, name, container) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32 /* Static */) + ? enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */) + : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 227 /* FunctionDeclaration */ || node.kind === 185 /* FunctionExpression */)) { + name = ts.getGeneratedNameForNode(node); } - var expression = ts.setOriginalNode(ts.createFunctionExpression( + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, saveStateAndInvoke(node, transformFunctionBody), location), + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body), location), /*original*/ node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; } /** * Transforms the body of a function-like node. @@ -50426,7 +52215,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 185 /* ArrowFunction */); + ts.Debug.assert(node.kind === 186 /* ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -50442,7 +52231,8 @@ var ts; } } var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, /*location*/ body); + var returnStatement = ts.createReturn(expression); + ts.setTextRange(returnStatement, body); ts.setEmitFlags(returnStatement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1024 /* NoTrailingComments */); statements.push(returnStatement); // To align with the source map emit for the old emitter, we set a custom @@ -50451,11 +52241,13 @@ var ts; } var lexicalEnvironment = context.endLexicalEnvironment(); ts.addRange(statements, lexicalEnvironment); + prependCaptureNewTargetIfNeeded(statements, node, /*copyOnWrite*/ false); // If we added any final generated statements, this must be a multi-line block if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), multiLine); + ts.setTextRange(block, node.body); if (!multiLine && singleLine) { ts.setEmitFlags(block, 1 /* SingleLine */); } @@ -50465,6 +52257,23 @@ var ts; ts.setOriginalNode(block, node.body); return block; } + function visitFunctionBodyDownLevel(node) { + var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); + return ts.updateBlock(updated, ts.setTextRange(ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, /*copyOnWrite*/ true)), + /*location*/ updated.statements)); + } + function visitBlock(node, isFunctionBody) { + if (isFunctionBody) { + // A function body is not a block scope. + return ts.visitEachChild(node, visitor, context); + } + var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */ + ? enterSubtree(4032 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */) + : enterSubtree(3904 /* BlockExcludes */, 128 /* BlockIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; + } /** * Visits an ExpressionStatement that contains a destructuring assignment. * @@ -50473,9 +52282,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -50491,9 +52300,9 @@ var ts; // If we are here it is most likely because our expression is a destructuring assignment. if (!needsDestructuringValue) { switch (node.expression.kind) { - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -50511,9 +52320,12 @@ var ts; if (ts.isDestructuringAssignment(node)) { return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, needsDestructuringValue); } + return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) == 0) { + var ancestorFacts = enterSubtree(0 /* None */, ts.hasModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + var updated; + if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0) { // we are inside a converted loop - hoist variable declarations var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -50531,14 +52343,18 @@ var ts; } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); }), node); + updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); })), node); } else { // none of declarations has initializer - the entire variable statement can be deleted - return undefined; + updated = undefined; } } - return ts.visitEachChild(node, visitor, context); + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; } /** * Visits a VariableDeclarationList that is block scoped (e.g. `let` or `const`). @@ -50546,25 +52362,29 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */) { - enableSubstitutionsForBlockScopedBindings(); + if (node.transformFlags & 64 /* ES2015 */) { + if (node.flags & 3 /* BlockScoped */) { + enableSubstitutionsForBlockScopedBindings(); + } + var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 /* Let */ + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + var declarationList = ts.createVariableDeclarationList(declarations); + ts.setOriginalNode(declarationList, node); + ts.setTextRange(declarationList, node); + ts.setCommentRange(declarationList, node); + if (node.transformFlags & 8388608 /* ContainsBindingPattern */ + && (ts.isBindingPattern(node.declarations[0].name) + || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + // If the first or last declaration is a binding pattern, we need to modify + // the source map range for the declaration list. + var firstDeclaration = ts.firstOrUndefined(declarations); + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } + return declarationList; } - var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 /* Let */ - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); - ts.setOriginalNode(declarationList, node); - ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 /* ContainsBindingPattern */ - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { - // If the first or last declaration is a binding pattern, we need to modify - // the source map range for the declaration list. - var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - } - return declarationList; + return ts.visitEachChild(node, visitor, context); } /** * Gets a value indicating whether we should emit an explicit initializer for a variable @@ -50615,18 +52435,16 @@ var ts; var flags = resolver.getNodeCheckFlags(node); var isCapturedInFunction = flags & 131072 /* CapturedBlockScopedBinding */; var isDeclaredInLoop = flags & 262144 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + var emittedAsTopLevel = (hierarchyFacts & 64 /* TopLevel */) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); + && (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 212 /* ForInStatement */ - && enclosingBlockScopeContainer.kind !== 213 /* ForOfStatement */ + && (hierarchyFacts & 2048 /* ForInOrForOfStatement */) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, /*lookInLabeledStatements*/ false))); + && (hierarchyFacts & (1024 /* ForStatement */ | 2048 /* ForInOrForOfStatement */)) === 0)); return emitExplicitInitializer; } /** @@ -50655,55 +52473,52 @@ var ts; * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { - // If we are here it is because the name contains a binding pattern. + var ancestorFacts = enterSubtree(32 /* ExportedVariableStatement */, 0 /* None */); + var updated; if (ts.isBindingPattern(node.name)) { - var hoistTempVariables = enclosingVariableStatement - && ts.hasModifier(enclosingVariableStatement, 1 /* Export */); - return ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, - /*value*/ undefined, hoistTempVariables); - } - return ts.visitEachChild(node, visitor, context); - } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; - } - var result; - if (ts.isIterationStatement(node.statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, + /*value*/ undefined, (ancestorFacts & 32 /* ExportedVariableStatement */) !== 0); } else { - result = ts.visitEachChild(node, visitor, context); + updated = ts.visitEachChild(node, visitor, context); } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; + } + function recordLabel(node) { + convertedLoopState.labels.set(node.label.text, node.label.text); + } + function resetLabel(node) { + convertedLoopState.labels.set(node.label.text, undefined); + } + function visitLabeledStatement(node) { + if (convertedLoopState && !convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); } - return result; + var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(statement) + ? visitIterationStatement(statement, /*outermostLabeledStatement*/ node) + : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { + var ancestorFacts = enterSubtree(excludeFacts, includeFacts); + var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitDoOrWhileStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 256 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement); } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(3008 /* ForStatementExcludes */, 1280 /* ForStatementIncludes */, node, outermostLabeledStatement); } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForInStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } - /** - * Visits a ForOfStatement and converts it into a compatible ForStatement. - * - * @param node A ForOfStatement. - */ - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function visitForOfStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, convertForOfToFor); } - function convertForOfToFor(node, convertedLoopBodyStatements) { + function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { // The following ES6 code: // // for (let v of expr) { } @@ -50734,7 +52549,7 @@ var ts; // we don't want to emit a temporary variable for the RHS, just use it directly. var counter = ts.createLoopVariable(); var rhsReference = expression.kind === 70 /* Identifier */ - ? ts.createUniqueName(expression.text) + ? ts.createUniqueName(ts.unescapeIdentifier(expression.text)) : ts.createTempVariable(/*recordTempVariable*/ undefined); var elementAccess = ts.createElementAccess(rhsReference, counter); // Initialize LHS @@ -50748,8 +52563,9 @@ var ts; // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, elementAccess); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ initializer); + var declarationList = ts.createVariableDeclarationList(declarations); ts.setOriginalNode(declarationList, initializer); + ts.setTextRange(declarationList, initializer); // Adjust the source map range for the first declaration to align with the old // emitter. var firstDeclaration = declarations[0]; @@ -50761,12 +52577,11 @@ var ts; else { // The following call does not include the initializer, so we have // to emit it separately. - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.setOriginalNode(ts.createVariableDeclarationList([ + statements.push(ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), /*type*/ undefined, ts.createElementAccess(rhsReference, counter)) - ], /*location*/ ts.moveRangePos(initializer, -1)), initializer), - /*location*/ ts.moveRangeEnd(initializer, -1))); + ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); } } else { @@ -50781,7 +52596,7 @@ var ts; // Currently there is not way to check that assignment is binary expression of destructing assignment // so we have to cast never type to binaryExpression assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, /*location*/ ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createStatement(assignment), ts.moveRangeEnd(initializer, -1))); } } var bodyLocation; @@ -50790,7 +52605,7 @@ var ts; ts.addRange(statements, convertedLoopBodyStatements); } else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + var statement = ts.visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, ts.liftToBlock); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -50804,18 +52619,30 @@ var ts; ts.setEmitFlags(expression, 48 /* NoSourceMap */ | ts.getEmitFlags(expression)); // The old emitter does not emit source maps for the block. // We add the location to preserve comments. - var body = ts.createBlock(ts.createNodeArray(statements, /*location*/ statementsLocation), - /*location*/ bodyLocation); + var body = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ statementsLocation)); + ts.setTextRange(body, bodyLocation); ts.setEmitFlags(body, 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); - var forStatement = ts.createFor(ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0), /*location*/ ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) - ], /*location*/ node.expression), 1048576 /* NoHoisting */), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), - /*location*/ node.expression), ts.createPostfixIncrement(counter, /*location*/ node.expression), body, - /*location*/ node); + var forStatement = ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)), + ts.setTextRange(ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression), node.expression) + ]), node.expression), 1048576 /* NoHoisting */), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), body); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); - return forStatement; + ts.setTextRange(forStatement, node); + return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); + } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 213 /* ForStatement */: + return visitForStatement(node, outermostLabeledStatement); + case 214 /* ForInStatement */: + return visitForInStatement(node, outermostLabeledStatement); + case 215 /* ForOfStatement */: + return visitForOfStatement(node, outermostLabeledStatement); + } } /** * Visits an ObjectLiteralExpression with computed propety names. @@ -50829,31 +52656,39 @@ var ts; // Find the first computed property. // Everything until that point can be emitted as part of the initial object literal. var numInitialProperties = numProperties; + var numInitialPropertiesWithoutYield = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 /* ContainsYield */ - || property.name.kind === 142 /* ComputedPropertyName */) { + if ((property.transformFlags & 16777216 /* ContainsYield */ && hierarchyFacts & 4 /* AsyncFunctionBody */) + && i < numInitialPropertiesWithoutYield) { + numInitialPropertiesWithoutYield = i; + } + if (property.name.kind === 143 /* ComputedPropertyName */) { numInitialProperties = i; break; } } - ts.Debug.assert(numInitialProperties !== numProperties); - // For computed properties, we need to create a unique handle to the object - // literal so we can modify it without risking internal assignments tainting the object. - var temp = ts.createTempVariable(hoistVariableDeclaration); - // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. - var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), - /*location*/ undefined, node.multiLine), 32768 /* Indented */)); - if (node.multiLine) { - assignment.startsOnNewLine = true; + if (numInitialProperties !== numProperties) { + if (numInitialPropertiesWithoutYield < numInitialProperties) { + numInitialProperties = numInitialPropertiesWithoutYield; + } + // For computed properties, we need to create a unique handle to the object + // literal so we can modify it without risking internal assignments tainting the object. + var temp = ts.createTempVariable(hoistVariableDeclaration); + // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. + var expressions = []; + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 32768 /* Indented */)); + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + expressions.push(assignment); + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + // We need to clone the temporary identifier so that we can write it on a + // new line + expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); + return ts.inlineExpressions(expressions); } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - // We need to clone the temporary identifier so that we can write it on a - // new line - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); + return ts.visitEachChild(node, visitor, context); } function shouldConvertIterationStatementBody(node) { return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; @@ -50880,7 +52715,7 @@ var ts; } } } - function convertIterationStatementBodyIfNecessary(node, convert) { + function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) { if (!shouldConvertIterationStatementBody(node)) { var saveAllowedNonLabeledJumps = void 0; if (convertedLoopState) { @@ -50889,7 +52724,9 @@ var ts; saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; } - var result = convert ? convert(node, /*convertedLoopBodyStatements*/ undefined) : ts.visitEachChild(node, visitor, context); + var result = convert + ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined) + : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel); if (convertedLoopState) { convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } @@ -50898,11 +52735,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 224 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 226 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -50939,7 +52776,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -50949,13 +52786,15 @@ var ts; copyOutParameters(loopOutParameters, 1 /* ToOutParameter */, statements_4); } ts.addRange(statements_4, lexicalEnvironment); - loopBody = ts.createBlock(statements_4, /*location*/ undefined, /*multiline*/ true); + loopBody = ts.createBlock(statements_4, /*multiline*/ true); } - if (!ts.isBlock(loopBody)) { - loopBody = ts.createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); + if (ts.isBlock(loopBody)) { + loopBody.multiLine = true; } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 131072 /* AsyncFunctionBody */) !== 0 + else { + loopBody = ts.createBlock([loopBody], /*multiline*/ true); + } + var isAsyncBlockContainingAwait = hierarchyFacts & 4 /* AsyncFunctionBody */ && (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -51038,25 +52877,22 @@ var ts; var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); var loop; if (convert) { - loop = convert(node, convertedLoopBodyStatements); + loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); } else { - loop = ts.getMutableClone(node); + var clone_4 = ts.getMutableClone(node); // clean statement part - loop.statement = undefined; + clone_4.statement = undefined; // visit childnodes to transform initializer/condition/incrementor parts - loop = ts.visitEachChild(loop, visitor, context); + clone_4 = ts.visitEachChild(clone_4, visitor, context); // set loop statement - loop.statement = ts.createBlock(convertedLoopBodyStatements, - /*location*/ undefined, - /*multiline*/ true); + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, /*multiline*/ true); // reset and re-aggregate the transform flags - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); + clone_4.transformFlags = 0; + ts.aggregateTransformFlags(clone_4); + loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } - statements.push(currentParent.kind === 219 /* LabeledStatement */ - ? ts.createLabel(currentParent.label, loop) - : loop); + statements.push(loop); return statements; } function copyOutParameter(outParam, copyDirection) { @@ -51119,26 +52955,25 @@ var ts; if (!state.labeledNonLocalBreaks) { state.labeledNonLocalBreaks = ts.createMap(); } - state.labeledNonLocalBreaks[labelText] = labelMarker; + state.labeledNonLocalBreaks.set(labelText, labelMarker); } else { if (!state.labeledNonLocalContinues) { state.labeledNonLocalContinues = ts.createMap(); } - state.labeledNonLocalContinues[labelText] = labelMarker; + state.labeledNonLocalContinues.set(labelText, labelMarker); } } function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { if (!table) { return; } - for (var labelText in table) { - var labelMarker = table[labelText]; + table.forEach(function (labelMarker, labelText) { var statements = []; // if there are no outer converted loop or outer label in question is located inside outer converted loop // then emit labeled break\continue // otherwise propagate pair 'label -> marker' to outer converted loop and emit 'return labelMarker' so outer loop can later decide what to do - if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { + if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) { var label = ts.createIdentifier(labelText); statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); } @@ -51147,7 +52982,7 @@ var ts; statements.push(ts.createReturn(loopResultName)); } caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); - } + }); } function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { var name = decl.name; @@ -51162,7 +52997,7 @@ var ts; else { loopParameters.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); if (resolver.getNodeCheckFlags(decl) & 2097152 /* NeedsLoopOutParameter */) { - var outParamName = ts.createUniqueName("out_" + name.text); + var outParamName = ts.createUniqueName("out_" + ts.unescapeIdentifier(name.text)); loopOutParameters.push({ originalName: name, outParamName: outParamName }); } } @@ -51182,22 +53017,22 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 257 /* PropertyAssignment */: + case 150 /* MethodDeclaration */: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); + break; + case 260 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 258 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 149 /* MethodDeclaration */: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); - break; default: ts.Debug.failBadSyntaxKind(node); break; @@ -51212,8 +53047,8 @@ var ts; * @param receiver The receiver for the assignment. */ function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), - /*location*/ property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -51227,8 +53062,8 @@ var ts; * @param receiver The receiver for the assignment. */ function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), - /*location*/ property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -51241,22 +53076,34 @@ var ts; * @param method The MethodDeclaration node. * @param receiver The receiver for the assignment. */ - function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined), - /*location*/ method); + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { + var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined, container)); + ts.setTextRange(expression, method); if (startsOnNewLine) { expression.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 16384 /* NewTarget */ : 0 /* None */); return expression; } function visitCatchClause(node) { - ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); - var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); - var list = ts.createVariableDeclarationList(vars, /*location*/ node.variableDeclaration, /*flags*/ node.variableDeclaration.flags); - var destructure = ts.createVariableStatement(undefined, list); - return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var updated; + if (ts.isBindingPattern(node.variableDeclaration.name)) { + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp); + ts.setTextRange(newVariableDeclaration, node.variableDeclaration); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); + var list = ts.createVariableDeclarationList(vars); + ts.setTextRange(list, node.variableDeclaration); + var destructure = ts.createVariableStatement(/*modifiers*/ undefined, list); + updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); @@ -51273,20 +53120,41 @@ var ts; // Methods on classes are handled in visitClassDeclaration/visitClassExpression. // Methods with computed property names are handled in visitObjectLiteralExpression. ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined); + var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); - return ts.createPropertyAssignment(node.name, functionExpression, + return ts.setTextRange(ts.createPropertyAssignment(node.name, functionExpression), /*location*/ node); } + /** + * Visits an AccessorDeclaration of an ObjectLiteralExpression. + * + * @param node An AccessorDeclaration node. + */ + function visitAccessorDeclaration(node) { + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return updated; + } /** * Visits a ShorthandPropertyAssignment and transforms it into a PropertyAssignment. * * @param node A ShorthandPropertyAssignment node. */ function visitShorthandPropertyAssignment(node) { - return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), + return ts.setTextRange(ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name)), /*location*/ node); } + function visitComputedPropertyName(node) { + var ancestorFacts = enterSubtree(0 /* ComputedPropertyNameExcludes */, 8192 /* ComputedPropertyNameIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 32768 /* NewTargetInComputedPropertyName */ : 0 /* None */); + return updated; + } /** * Visits a YieldExpression node. * @@ -51302,8 +53170,11 @@ var ts; * @param node An ArrayLiteralExpression node. */ function visitArrayLiteralExpression(node) { - // We are here because we contain a SpreadElementExpression. - return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + if (node.transformFlags & 64 /* ES2015 */) { + // We are here because we contain a SpreadElementExpression. + return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + } + return ts.visitEachChild(node, visitor, context); } /** * Visits a CallExpression that contains either a spread element or `super`. @@ -51311,7 +53182,11 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + if (node.transformFlags & 64 /* ES2015 */) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + } + return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), + /*typeArguments*/ undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); } function visitImmediateSuperCallInBody(node) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false); @@ -51338,7 +53213,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -51350,18 +53225,18 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } if (node.expression.kind === 96 /* SuperKeyword */) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis + resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createIdentifier("_this"), initializer) : initializer; } - return resultingCall; + return ts.setOriginalNode(resultingCall, node); } /** * Visits a NewExpression that contains a spread element. @@ -51369,16 +53244,18 @@ var ts; * @param node A NewExpression node. */ function visitNewExpression(node) { - // We are here because we contain a SpreadElementExpression. - ts.Debug.assert((node.transformFlags & 524288 /* ContainsSpread */) !== 0); - // [source] - // new C(...a) - // - // [output] - // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() - var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), - /*typeArguments*/ undefined, []); + if (node.transformFlags & 524288 /* ContainsSpread */) { + // We are here because we contain a SpreadElementExpression. + // [source] + // new C(...a) + // + // [output] + // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() + var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + /*typeArguments*/ undefined, []); + } + return ts.visitEachChild(node, visitor, context); } /** * Transforms an array of Expression nodes that contains a SpreadExpression. @@ -51401,7 +53278,7 @@ var ts; })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 175 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 176 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -51417,8 +53294,7 @@ var ts; return ts.map(chunk, visitExpressionOfSpread); } function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) { - return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, /*location*/ undefined, hasTrailingComma), visitor, ts.isExpression), - /*location*/ undefined, multiLine); + return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -51437,7 +53313,7 @@ var ts; * @param node A template literal. */ function visitTemplateLiteral(node) { - return ts.createLiteral(node.text, /*location*/ node); + return ts.setTextRange(ts.createLiteral(node.text), node); } /** * Visits a TaggedTemplateExpression node. @@ -51497,7 +53373,7 @@ var ts; // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's // and LineTerminatorSequences are normalized to for both TV and TRV. text = text.replace(/\r\n?/g, "\n"); - return ts.createLiteral(text, /*location*/ node); + return ts.setTextRange(ts.createLiteral(text), node); } /** * Visits a TemplateExpression node. @@ -51519,7 +53395,8 @@ var ts; // "abc" + (1 << 2) + "" var expression = ts.reduceLeft(expressions, ts.createAdd); if (ts.nodeIsSynthesized(expression)) { - ts.setTextRange(expression, node); + expression.pos = node.pos; + expression.end = node.end; } return expression; } @@ -51581,27 +53458,42 @@ var ts; /** * Visits the `super` keyword */ - function visitSuperKeyword() { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32 /* Static */) - && currentParent.kind !== 179 /* CallExpression */ + function visitSuperKeyword(isExpressionOfCall) { + return hierarchyFacts & 8 /* NonStaticClassElement */ + && !isExpressionOfCall ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } + function visitMetaProperty(node) { + if (node.keywordToken === 93 /* NewKeyword */ && node.name.text === "target") { + if (hierarchyFacts & 8192 /* ComputedPropertyName */) { + hierarchyFacts |= 32768 /* NewTargetInComputedPropertyName */; + } + else { + hierarchyFacts |= 16384 /* NewTarget */; + } + return ts.createIdentifier("_newTarget"); + } + return node; + } /** * Called by the printer just before a node is printed. * + * @param hint A hint as to the intended usage of the node. * @param node The node to be printed. + * @param emitCallback The callback used to emit the node. */ - function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; + function onEmitNode(hint, node, emitCallback) { if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. - enclosingFunction = node; + var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ + ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ + : 65 /* FunctionIncludes */); + previousOnEmitNode(hint, node, emitCallback); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return; } - previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; + previousOnEmitNode(hint, node, emitCallback); } /** * Enables a more costly code path for substitutions when we determine a source file @@ -51621,24 +53513,24 @@ var ts; if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; context.enableSubstitution(98 /* ThisKeyword */); - context.enableEmitNotification(150 /* Constructor */); - context.enableEmitNotification(149 /* MethodDeclaration */); - context.enableEmitNotification(151 /* GetAccessor */); - context.enableEmitNotification(152 /* SetAccessor */); - context.enableEmitNotification(185 /* ArrowFunction */); - context.enableEmitNotification(184 /* FunctionExpression */); - context.enableEmitNotification(225 /* FunctionDeclaration */); + context.enableEmitNotification(151 /* Constructor */); + context.enableEmitNotification(150 /* MethodDeclaration */); + context.enableEmitNotification(152 /* GetAccessor */); + context.enableEmitNotification(153 /* SetAccessor */); + context.enableEmitNotification(186 /* ArrowFunction */); + context.enableEmitNotification(185 /* FunctionExpression */); + context.enableEmitNotification(227 /* FunctionDeclaration */); } } /** * Hooks node substitutions. * - * @param emitContext The context for the emitter. + * @param hint The context for the emitter. * @param node The node to substitute. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -51669,10 +53561,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 174 /* BindingElement */: - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 223 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 225 /* VariableDeclaration */: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -51713,9 +53605,8 @@ var ts; */ function substituteThisKeyword(node) { if (enabledSubstitutions & 1 /* CapturedThis */ - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 8 /* CapturesThis */) { - return ts.createIdentifier("_this", /*location*/ node); + && hierarchyFacts & 16 /* CapturesThis */) { + return ts.setTextRange(ts.createIdentifier("_this"), node); } return node; } @@ -51731,11 +53622,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 207 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 209 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 179 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 180 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -51743,7 +53634,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 196 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 197 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -51763,11 +53654,123 @@ var ts; name: "typescript:extends", scoped: false, priority: 0, - text: "\n var __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 };" + text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; })(ts || (ts = {})); /// /// +/*@internal*/ +var ts; +(function (ts) { + /** + * Transforms ES5 syntax into ES3 syntax. + * + * @param context Context and state information for the transformation. + */ + function transformES5(context) { + var compilerOptions = context.getCompilerOptions(); + // enable emit notification only if using --jsx preserve or react-native + var previousOnEmitNode; + var noSubstitution; + if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { + previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.enableEmitNotification(250 /* JsxOpeningElement */); + context.enableEmitNotification(251 /* JsxClosingElement */); + context.enableEmitNotification(249 /* JsxSelfClosingElement */); + noSubstitution = []; + } + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(178 /* PropertyAccessExpression */); + context.enableSubstitution(260 /* PropertyAssignment */); + return transformSourceFile; + /** + * Transforms an ES5 source file to ES3. + * + * @param node A SourceFile + */ + function transformSourceFile(node) { + return node; + } + /** + * Called by the printer just before a node is printed. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to emit. + * @param emitCallback A callback used to emit the node. + */ + function onEmitNode(hint, node, emitCallback) { + switch (node.kind) { + case 250 /* JsxOpeningElement */: + case 251 /* JsxClosingElement */: + case 249 /* JsxSelfClosingElement */: + var tagName = node.tagName; + noSubstitution[ts.getOriginalNodeId(tagName)] = true; + break; + } + previousOnEmitNode(hint, node, emitCallback); + } + /** + * Hooks node substitutions. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to substitute. + */ + function onSubstituteNode(hint, node) { + if (node.id && noSubstitution && noSubstitution[node.id]) { + return previousOnSubstituteNode(hint, node); + } + node = previousOnSubstituteNode(hint, node); + if (ts.isPropertyAccessExpression(node)) { + return substitutePropertyAccessExpression(node); + } + else if (ts.isPropertyAssignment(node)) { + return substitutePropertyAssignment(node); + } + return node; + } + /** + * Substitutes a PropertyAccessExpression whose name is a reserved word. + * + * @param node A PropertyAccessExpression + */ + function substitutePropertyAccessExpression(node) { + var literalName = trySubstituteReservedName(node.name); + if (literalName) { + return ts.setTextRange(ts.createElementAccess(node.expression, literalName), node); + } + return node; + } + /** + * Substitutes a PropertyAssignment whose name is a reserved word. + * + * @param node A PropertyAssignment + */ + function substitutePropertyAssignment(node) { + var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); + if (literalName) { + return ts.updatePropertyAssignment(node, literalName, node.initializer); + } + return node; + } + /** + * If an identifier name is a reserved word, returns a string literal for the name. + * + * @param name An Identifier + */ + function trySubstituteReservedName(name) { + var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); + if (token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */) { + return ts.setTextRange(ts.createLiteral(name), name); + } + return undefined; + } + } + ts.transformES5 = transformES5; +})(ts || (ts = {})); +/// +/// // Transforms generator functions into a compatible ES5 representation with similar runtime // semantics. This is accomplished by first transforming the body of each generator // function into an intermediate representation that is the compiled into a JavaScript @@ -51938,13 +53941,15 @@ var ts; Instruction[Instruction["Catch"] = 6] = "Catch"; Instruction[Instruction["Endfinally"] = 7] = "Endfinally"; })(Instruction || (Instruction = {})); - var instructionNames = ts.createMap((_a = {}, - _a[2 /* Return */] = "return", - _a[3 /* Break */] = "break", - _a[4 /* Yield */] = "yield", - _a[5 /* YieldStar */] = "yield*", - _a[7 /* Endfinally */] = "endfinally", - _a)); + function getInstructionName(instruction) { + switch (instruction) { + case 2 /* Return */: return "return"; + case 3 /* Break */: return "break"; + case 4 /* Yield */: return "yield"; + case 5 /* YieldStar */: return "yield*"; + case 7 /* Endfinally */: return "endfinally"; + } + } function transformGenerators(context) { var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); @@ -52036,13 +54041,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 209 /* DoStatement */: + case 211 /* DoStatement */: return visitDoStatement(node); - case 210 /* WhileStatement */: + case 212 /* WhileStatement */: return visitWhileStatement(node); - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: return visitSwitchStatement(node); - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -52055,24 +54060,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return visitFunctionExpression(node); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return visitAccessorDeclaration(node); - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: return visitVariableStatement(node); - case 211 /* ForStatement */: + case 213 /* ForStatement */: return visitForStatement(node); - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: return visitForInStatement(node); - case 215 /* BreakStatement */: + case 217 /* BreakStatement */: return visitBreakStatement(node); - case 214 /* ContinueStatement */: + case 216 /* ContinueStatement */: return visitContinueStatement(node); - case 216 /* ReturnStatement */: + case 218 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -52093,21 +54098,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitBinaryExpression(node); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return visitConditionalExpression(node); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return visitYieldExpression(node); - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return visitCallExpression(node); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -52120,9 +54125,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -52141,11 +54146,11 @@ var ts; function visitFunctionDeclaration(node) { // Currently, we only support generators that were originally async functions. if (node.asteriskToken && ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */) { - node = ts.setOriginalNode(ts.createFunctionDeclaration( + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration( /*decorators*/ undefined, node.modifiers, /*asteriskToken*/ undefined, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformGeneratorFunctionBody(node.body), + /*type*/ undefined, transformGeneratorFunctionBody(node.body)), /*location*/ node), node); } else { @@ -52179,11 +54184,11 @@ var ts; function visitFunctionExpression(node) { // Currently, we only support generators that were originally async functions. if (node.asteriskToken && ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */) { - node = ts.setOriginalNode(ts.createFunctionExpression( + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformGeneratorFunctionBody(node.body), + /*type*/ undefined, transformGeneratorFunctionBody(node.body)), /*location*/ node), node); } else { @@ -52271,7 +54276,7 @@ var ts; operationArguments = savedOperationArguments; operationLocations = savedOperationLocations; state = savedState; - return ts.createBlock(statements, /*location*/ body, body.multiLine); + return ts.setTextRange(ts.createBlock(statements, body.multiLine), body); } /** * Visits a variable statement. @@ -52350,7 +54355,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -52362,7 +54367,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -52381,7 +54386,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 57 /* EqualsToken */, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.setTextRange(ts.createAssignment(target, ts.setTextRange(ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression)), node)), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -52405,10 +54410,10 @@ var ts; // _a = a(); // .yield resumeLabel // _a + %sent% + c() - var clone_4 = ts.getMutableClone(node); - clone_4.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_4.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_4; + var clone_5 = ts.getMutableClone(node); + clone_5.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_5.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_5; } return ts.visitEachChild(node, visitor, context); } @@ -52553,7 +54558,7 @@ var ts; emitYield(expression, /*location*/ node); } markLabel(resumeLabel); - return createGeneratorResume(); + return createGeneratorResume(/*location*/ node); } /** * Visits an ArrayLiteralExpression that contains a YieldExpression. @@ -52592,14 +54597,13 @@ var ts; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, /*location*/ undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, location, multiLine); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { emitAssignment(temp, hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, /*location*/ undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, - /*location*/ undefined, multiLine)); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); hasAssignedTemp = true; leadingElement = undefined; expressions = []; @@ -52630,8 +54634,7 @@ var ts; var multiLine = node.multiLine; var numInitialProperties = countInitialNodesWithoutYield(properties); var temp = declareLocal(); - emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), - /*location*/ undefined, multiLine)); + emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), multiLine)); var expressions = ts.reduceLeft(properties, reduceProperty, [], numInitialProperties); expressions.push(multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); return ts.inlineExpressions(expressions); @@ -52667,10 +54670,10 @@ var ts; // .yield resumeLabel // .mark resumeLabel // a = _a[%sent%] - var clone_5 = ts.getMutableClone(node); - clone_5.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_5.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_5; + var clone_6 = ts.getMutableClone(node); + clone_6.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_6.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -52705,10 +54708,9 @@ var ts; // .mark resumeLabel // new (_b.apply(_a, _c.concat([%sent%, 2]))); var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, + return ts.setOriginalNode(ts.setTextRange(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, /*leadingElement*/ ts.createVoidZero())), - /*typeArguments*/ undefined, [], - /*location*/ node), node); + /*typeArguments*/ undefined, []), node), node); } return ts.visitEachChild(node, visitor, context); } @@ -52737,35 +54739,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 204 /* Block */: + case 206 /* Block */: return transformAndEmitBlock(node); - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 208 /* IfStatement */: + case 210 /* IfStatement */: return transformAndEmitIfStatement(node); - case 209 /* DoStatement */: + case 211 /* DoStatement */: return transformAndEmitDoStatement(node); - case 210 /* WhileStatement */: + case 212 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 211 /* ForStatement */: + case 213 /* ForStatement */: return transformAndEmitForStatement(node); - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 214 /* ContinueStatement */: + case 216 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 215 /* BreakStatement */: + case 217 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 216 /* ReturnStatement */: + case 218 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 217 /* WithStatement */: + case 219 /* WithStatement */: return transformAndEmitWithStatement(node); - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 220 /* ThrowStatement */: + case 222 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 221 /* TryStatement */: + case 223 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, /*optional*/ true)); @@ -52785,7 +54787,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - hoistVariableDeclaration(variable.name); + var name = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name, variable.name); + hoistVariableDeclaration(name); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -52828,7 +54832,7 @@ var ts; if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) { var endLabel = defineLabel(); var elseLabel = node.elseStatement ? defineLabel() : undefined; - emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression)); + emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), /*location*/ node.expression); transformAndEmitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { emitBreak(endLabel); @@ -52951,8 +54955,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression), - /*location*/ initializer)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -52962,8 +54965,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression), - /*location*/ node.incrementor)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -53185,7 +55187,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 254 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 257 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -53198,7 +55200,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 253 /* CaseClause */) { + if (clause.kind === 256 /* CaseClause */) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -53340,9 +55342,9 @@ var ts; } return -1; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */) { return substituteExpression(node); } return node; @@ -53354,17 +55356,17 @@ var ts; return node; } function substituteExpressionIdentifier(node) { - if (renamedCatchVariables && ts.hasProperty(renamedCatchVariables, node.text)) { + if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { var original = ts.getOriginalNode(node); if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_37) { - var clone_6 = ts.getMutableClone(name_37); - ts.setSourceMapRange(clone_6, node); - ts.setCommentRange(clone_6, node); - return clone_6; + var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; + if (name) { + var clone_7 = ts.getMutableClone(name); + ts.setSourceMapRange(clone_7, node); + ts.setCommentRange(clone_7, node); + return clone_7; } } } @@ -53505,10 +55507,10 @@ var ts; var name = declareLocal(text); if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); - renamedCatchVariableDeclarations = ts.createMap(); + renamedCatchVariableDeclarations = []; context.enableSubstitution(70 /* Identifier */); } - renamedCatchVariables[text] = true; + renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; var exception = peekBlock(); ts.Debug.assert(exception.state < 1 /* Catch */); @@ -53779,7 +55781,7 @@ var ts; */ function createInstruction(instruction) { var literal = ts.createLiteral(instruction); - literal.trailingComment = instructionNames[instruction]; + literal.trailingComment = getInstructionName(instruction); return literal; } /** @@ -53790,10 +55792,10 @@ var ts; */ function createInlineBreak(label, location) { ts.Debug.assert(label > 0, "Invalid label: " + label); - return ts.createReturn(ts.createArrayLiteral([ + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), location); + ])), location); } /** * Creates a statement that can be used indicate a Return operation. @@ -53802,15 +55804,16 @@ var ts; * @param location An optional source map location for the statement. */ function createInlineReturn(expression, location) { - return ts.createReturn(ts.createArrayLiteral(expression + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)]), location); + : [createInstruction(2 /* Return */)])), location); } /** * Creates an expression that can be used to resume from a Yield operation. */ function createGeneratorResume(location) { - return ts.createCall(ts.createPropertyAccess(state, "sent"), /*typeArguments*/ undefined, [], location); + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(state, "sent"), + /*typeArguments*/ undefined, []), location); } /** * Emits an empty instruction. @@ -53956,7 +55959,6 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, ts.createBlock(buildResult, - /*location*/ undefined, /*multiLine*/ buildResult.length > 0)), 262144 /* ReuseTempVariableScope */)); } /** @@ -54227,7 +56229,7 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeAssign(left, right, operationLocation) { - writeStatement(ts.createStatement(ts.createAssignment(left, right), operationLocation)); + writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); } /** * Writes a Throw operation to the current label's statement list. @@ -54238,7 +56240,7 @@ var ts; function writeThrow(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createThrow(expression, operationLocation)); + writeStatement(ts.setTextRange(ts.createThrow(expression), operationLocation)); } /** * Writes a Return operation to the current label's statement list. @@ -54249,9 +56251,9 @@ var ts; function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)]), operationLocation)); + : [createInstruction(2 /* Return */)])), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a Break operation to the current label's statement list. @@ -54261,10 +56263,10 @@ var ts; */ function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation)); + ])), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a BreakWhenTrue operation to the current label's statement list. @@ -54274,10 +56276,10 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation))); + ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); } /** * Writes a BreakWhenFalse operation to the current label's statement list. @@ -54287,10 +56289,10 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation))); + ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); } /** * Writes a Yield operation to the current label's statement list. @@ -54300,9 +56302,9 @@ var ts; */ function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)]), operationLocation)); + : [createInstruction(4 /* Yield */)])), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a YieldStar instruction to the current label's statement list. @@ -54312,10 +56314,10 @@ var ts; */ function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(5 /* YieldStar */), expression - ]), operationLocation)); + ])), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes an Endfinally instruction to the current label's statement list. @@ -54398,155 +56400,903 @@ var ts; priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; - var _a; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - /** - * Transforms ES5 syntax into ES3 syntax. - * - * @param context Context and state information for the transformation. - */ - function transformES5(context) { - var previousOnSubstituteNode = context.onSubstituteNode; - context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(177 /* PropertyAccessExpression */); - context.enableSubstitution(257 /* PropertyAssignment */); - return transformSourceFile; - /** - * Transforms an ES5 source file to ES3. - * - * @param node A SourceFile - */ - function transformSourceFile(node) { - return node; - } - /** - * Hooks node substitutions. - * - * @param emitContext The context for the emitter. - * @param node The node to substitute. - */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (ts.isPropertyAccessExpression(node)) { - return substitutePropertyAccessExpression(node); - } - else if (ts.isPropertyAssignment(node)) { - return substitutePropertyAssignment(node); - } - return node; - } - /** - * Substitutes a PropertyAccessExpression whose name is a reserved word. - * - * @param node A PropertyAccessExpression - */ - function substitutePropertyAccessExpression(node) { - var literalName = trySubstituteReservedName(node.name); - if (literalName) { - return ts.createElementAccess(node.expression, literalName, /*location*/ node); - } - return node; - } - /** - * Substitutes a PropertyAssignment whose name is a reserved word. - * - * @param node A PropertyAssignment - */ - function substitutePropertyAssignment(node) { - var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); - if (literalName) { - return ts.updatePropertyAssignment(node, literalName, node.initializer); - } - return node; - } - /** - * If an identifier name is a reserved word, returns a string literal for the name. - * - * @param name An Identifier - */ - function trySubstituteReservedName(name) { - var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); - if (token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */) { - return ts.createLiteral(name, /*location*/ name); - } - return undefined; - } - } - ts.transformES5 = transformES5; })(ts || (ts = {})); /// /// /*@internal*/ var ts; (function (ts) { - function transformES2015Module(context) { + function transformModule(context) { + function getTransformModuleDelegate(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.AMD: return transformAMDModule; + case ts.ModuleKind.UMD: return transformUMDModule; + default: return transformCommonJSModule; + } + } + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var compilerOptions = context.getCompilerOptions(); - var previousOnEmitNode = context.onEmitNode; + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var moduleKind = ts.getEmitModuleKind(compilerOptions); var previousOnSubstituteNode = context.onSubstituteNode; - context.onEmitNode = onEmitNode; + var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(261 /* SourceFile */); - context.enableSubstitution(70 /* Identifier */); - var currentSourceFile; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(193 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(191 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(192 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(261 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(264 /* SourceFile */); // Restore state when substituting nodes in a file. + var moduleInfoMap = []; // The ExternalModuleInfo for each file. + var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. + var currentSourceFile; // The current file. + var currentModuleInfo; // The ExternalModuleInfo for the current file. + var noSubstitution; // Set of nodes for which substitution rules should be ignored. return transformSourceFile; + /** + * Transforms the module aspects of a SourceFile. + * + * @param node The SourceFile node. + */ function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { + if (ts.isDeclarationFile(node) + || !(ts.isExternalModule(node) + || compilerOptions.isolatedModules)) { return node; } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); - if (externalHelpersModuleName) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements); - ts.append(statements, ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + currentSourceFile = node; + currentModuleInfo = ts.collectExternalModuleInfo(node, resolver, compilerOptions); + moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo; + // Perform the transformation. + var transformModule = getTransformModuleDelegate(moduleKind); + var updated = transformModule(node); + currentSourceFile = undefined; + currentModuleInfo = undefined; + return ts.aggregateTransformFlags(updated); + } + /** + * Transforms a SourceFile into a CommonJS module. + * + * @param node The SourceFile node. + */ + function transformCommonJSModule(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + ts.addRange(statements, endLexicalEnvironment()); + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); + var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); + if (currentModuleInfo.hasExportStarsToExportValues) { + ts.addEmitHelper(updated, exportStarHelper); + } + return updated; + } + /** + * Transforms a SourceFile into an AMD module. + * + * @param node The SourceFile node. + */ + function transformAMDModule(node) { + var define = ts.createIdentifier("define"); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + // An AMD define function has the following shape: + // + // define(id?, dependencies?, factory); + // + // This has the shape of the following: + // + // define(name, ["module1", "module2"], function (module1Alias) { ... } + // + // The location of the alias in the parameter list in the factory function needs to + // match the position of the module name in the dependency list. + // + // To ensure this is true in cases of modules with no aliases, e.g.: + // + // import "module" + // + // or + // + // /// + // + // we need to add modules without alias names to the end of the dependencies list + var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + // Create an updated SourceFile: + // + // define(moduleName?, ["module1", "module2"], function ... + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ + ts.createStatement(ts.createCall(define, + /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + // Add the dependency array argument: + // + // ["require", "exports", module1", "module2", ...] + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + // Add the module body function argument: + // + // function (require, exports, module1, module2) ... + ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") + ].concat(importAliasNames), + /*type*/ undefined, transformAsynchronousModuleBody(node)) + ]))) + ]), + /*location*/ node.statements)); + } + /** + * Transforms a SourceFile into a UMD module. + * + * @param node The SourceFile node. + */ + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var umdHeader = ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "factory")], + /*type*/ undefined, ts.setTextRange(ts.createBlock([ + ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ + ts.createVariableStatement( + /*modifiers*/ undefined, [ + ts.createVariableDeclaration("v", + /*type*/ undefined, ts.createCall(ts.createIdentifier("factory"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("require"), + ts.createIdentifier("exports") + ])) + ]), + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) + ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), + /*typeArguments*/ undefined, [ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createIdentifier("factory") + ])) + ]))) + ], + /*multiLine*/ true), + /*location*/ undefined)); + // Create an updated SourceFile: + // + // (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 ...) + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ + ts.createStatement(ts.createCall(umdHeader, + /*typeArguments*/ undefined, [ + // Add the module body function argument: + // + // function (require, exports) ... + ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") + ].concat(importAliasNames), + /*type*/ undefined, transformAsynchronousModuleBody(node)) + ])) + ]), + /*location*/ node.statements)); + } + /** + * Collect the additional asynchronous dependencies for the module. + * + * @param node The source file. + * @param includeNonAmdDependencies A value indicating whether to include non-AMD dependencies. + */ + function collectAsynchronousDependencies(node, includeNonAmdDependencies) { + // names of modules with corresponding parameter in the factory function + var aliasedModuleNames = []; + // names of modules with no corresponding parameters in factory function + var unaliasedModuleNames = []; + // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding + // module names in aliasedModuleNames. + var importAliasNames = []; + // Fill in amd-dependency tags + for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { + var amdDependency = _a[_i]; + if (amdDependency.name) { + aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, amdDependency.name)); } else { - return ts.visitEachChild(node, visitor, context); + unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); } } - return node; + for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) { + var importNode = _c[_b]; + // Find the name of the external module + var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + // Find the name of the module alias, if there is one + var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); + if (includeNonAmdDependencies && importAliasName) { + // Set emitFlags on the name of the classDeclaration + // This is so that when printer will not substitute the identifier + ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; } - function visitor(node) { + /** + * Transforms a SourceFile into an AMD or UMD module body. + * + * @param node The SourceFile node. + */ + function transformAsynchronousModuleBody(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } + // Visit each statement of the module body. + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + // End the lexical environment for the module body + // and merge any new lexical declarations. + ts.addRange(statements, endLexicalEnvironment()); + // Append the 'export =' statement if provided. + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); + var body = ts.createBlock(statements, /*multiLine*/ true); + if (currentModuleInfo.hasExportStarsToExportValues) { + // If we have any `export * from ...` declarations + // we need to inform the emitter to add the __export helper. + ts.addEmitHelper(body, exportStarHelper); + } + return body; + } + /** + * Adds the down-level representation of `export=` to the statement list if one exists + * in the source file. + * + * @param statements The Statement list to modify. + * @param emitAsReturn A value indicating whether to emit the `export=` statement as a + * return statement. + */ + function addExportEqualsIfNeeded(statements, emitAsReturn) { + if (currentModuleInfo.exportEquals) { + if (emitAsReturn) { + var statement = ts.createReturn(currentModuleInfo.exportEquals.expression); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + statements.push(statement); + } + else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression)); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 1536 /* NoComments */); + statements.push(statement); + } + } + } + // + // Top-Level Source Element Visitors + // + /** + * Visits a node at the top level of the source file. + * + * @param node The node to visit. + */ + function sourceElementVisitor(node) { switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: - // Elide `import=` as it is not legal with --module ES6 - return undefined; - case 240 /* ExportAssignment */: + case 237 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 236 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 243 /* ExportDeclaration */: + return visitExportDeclaration(node); + case 242 /* ExportAssignment */: return visitExportAssignment(node); + case 207 /* VariableStatement */: + return visitVariableStatement(node); + case 227 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 228 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 299 /* MergeDeclarationMarker */: + return visitMergeDeclarationMarker(node); + case 300 /* EndOfDeclarationMarker */: + return visitEndOfDeclarationMarker(node); + default: + // This visitor does not descend into the tree, as export/import statements + // are only transformed at the top level of a file. + return node; + } + } + /** + * Visits an ImportDeclaration node. + * + * @param node The node to visit. + */ + function visitImportDeclaration(node) { + var statements; + var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); + if (moduleKind !== ts.ModuleKind.AMD) { + if (!node.importClause) { + // import "mod"; + return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); + } + else { + var variables = []; + if (namespaceDeclaration && !ts.isDefaultImport(node)) { + // import * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, createRequireCall(node))); + } + else { + // import d from "mod"; + // import { x, y } from "mod"; + // import d, { x, y } from "mod"; + // import d, * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), + /*type*/ undefined, createRequireCall(node))); + if (namespaceDeclaration && ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node))); + } + } + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList(variables, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), + /*location*/ node)); + } + } + else if (namespaceDeclaration && ts.isDefaultImport(node)) { + // import d, * as n from "mod"; + statements = ts.append(statements, ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node)), + /*location*/ node) + ], languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Creates a `require()` call to import an external module. + * + * @param importNode The declararation to import. + */ + function createRequireCall(importNode) { + var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var args = []; + if (moduleName) { + args.push(moduleName); + } + return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); + } + /** + * Visits an ImportEqualsDeclaration node. + * + * @param node The node to visit. + */ + function visitImportEqualsDeclaration(node) { + ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); + var statements; + if (moduleKind !== ts.ModuleKind.AMD) { + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(node.name, createRequireCall(node))), node)); + } + else { + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), + /*type*/ undefined, createRequireCall(node)) + ], + /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node)); + } + } + else { + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); + } + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportEqualsDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits an ExportDeclaration node. + * + * @param The node to visit. + */ + function visitExportDeclaration(node) { + if (!node.moduleSpecifier) { + // Elide export declarations with no module specifier as they are handled + // elsewhere. + return undefined; + } + var generatedName = ts.getGeneratedNameForNode(node); + if (node.exportClause) { + var statements = []; + // export { x, y } from "mod"; + if (moduleKind !== ts.ModuleKind.AMD) { + statements.push(ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(generatedName, + /*type*/ undefined, createRequireCall(node)) + ])), + /*location*/ node)); + } + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); + } + return ts.singleOrMany(statements); + } + else { + // export * from "mod"; + return ts.setTextRange(ts.createStatement(ts.createCall(ts.createIdentifier("__export"), + /*typeArguments*/ undefined, [ + moduleKind !== ts.ModuleKind.AMD + ? createRequireCall(node) + : generatedName + ])), node); + } + } + /** + * Visits an ExportAssignment node. + * + * @param node The node to visit. + */ + function visitExportAssignment(node) { + if (node.isExportEquals) { + return undefined; + } + var statements; + var original = node.original; + if (original && hasAssociatedEndOfDeclarationMarker(original)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); + } + else { + statements = appendExportStatement(statements, ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); + } + return ts.singleOrMany(statements); + } + /** + * Visits a FunctionDeclaration node. + * + * @param node The node to visit. + */ + function visitFunctionDeclaration(node) { + var statements; + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), + /*typeParameters*/ undefined, node.parameters, + /*type*/ undefined, node.body), + /*location*/ node), + /*original*/ node)); + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits a ClassDeclaration node. + * + * @param node The node to visit. + */ + function visitClassDeclaration(node) { + var statements; + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createClassDeclaration( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), + /*typeParameters*/ undefined, node.heritageClauses, node.members), node), node)); + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits a VariableStatement node. + * + * @param node The node to visit. + */ + function visitVariableStatement(node) { + var statements; + var variables; + var expressions; + if (ts.hasModifier(node, 1 /* Export */)) { + var modifiers = void 0; + // If we're exporting these variables, then these just become assignments to 'exports.x'. + // We only want to emit assignments for variables with initializers. + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { + if (!modifiers) { + modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); + } + variables = ts.append(variables, variable); + } + else if (variable.initializer) { + expressions = ts.append(expressions, transformInitializedVariable(variable)); + } + } + if (variables) { + statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); + } + if (expressions) { + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + } + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); + } + else { + statements = appendExportsOfVariableStatement(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Transforms an exported variable with an initializer into an expression. + * + * @param node The node to transform. + */ + function transformInitializedVariable(node) { + if (ts.isBindingPattern(node.name)) { + return ts.flattenDestructuringAssignment(node, + /*visitor*/ undefined, context, 0 /* All */, + /*needsValue*/ false, createExportExpression); + } + else { + return ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name), + /*location*/ node.name), node.initializer); + } + } + /** + * Visits a MergeDeclarationMarker used as a placeholder for the beginning of a merged + * and transformed declaration. + * + * @param node The node to visit. + */ + function visitMergeDeclarationMarker(node) { + // For an EnumDeclaration or ModuleDeclaration that merges with a preceeding + // declaration we do not emit a leading variable declaration. To preserve the + // begin/end semantics of the declararation and to properly handle exports + // we wrapped the leading variable declaration in a `MergeDeclarationMarker`. + // + // To balance the declaration, add the exports of the elided variable + // statement. + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207 /* VariableStatement */) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } return node; } - function visitExportAssignment(node) { - // Elide `export=` as it is not legal with --module ES6 - return node.isExportEquals ? undefined : node; + /** + * Determines whether a node has an associated EndOfDeclarationMarker. + * + * @param node The node to test. + */ + function hasAssociatedEndOfDeclarationMarker(node) { + return (ts.getEmitFlags(node) & 2097152 /* HasEndOfDeclarationMarker */) !== 0; + } + /** + * Visits a DeclarationMarker used as a placeholder for the end of a transformed + * declaration. + * + * @param node The node to visit. + */ + function visitEndOfDeclarationMarker(node) { + // For some transformations we emit an `EndOfDeclarationMarker` to mark the actual + // end of the transformed declaration. We use this marker to emit any deferred exports + // of the declaration. + var id = ts.getOriginalNodeId(node); + var statements = deferredExports[id]; + if (statements) { + delete deferredExports[id]; + return ts.append(statements, node); + } + return node; + } + /** + * Appends the exports of an ImportDeclaration to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfImportDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + var importClause = decl.importClause; + if (!importClause) { + return statements; + } + if (importClause.name) { + statements = appendExportsOfDeclaration(statements, importClause); + } + var namedBindings = importClause.namedBindings; + if (namedBindings) { + switch (namedBindings.kind) { + case 239 /* NamespaceImport */: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 240 /* NamedImports */: + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var importBinding = _a[_i]; + statements = appendExportsOfDeclaration(statements, importBinding); + } + break; + } + } + return statements; + } + /** + * Appends the exports of an ImportEqualsDeclaration to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfImportEqualsDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + return appendExportsOfDeclaration(statements, decl); + } + /** + * Appends the exports of a VariableStatement to a statement list, returning the statement + * list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param node The VariableStatement whose exports are to be recorded. + */ + function appendExportsOfVariableStatement(statements, node) { + if (currentModuleInfo.exportEquals) { + return statements; + } + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + statements = appendExportsOfBindingElement(statements, decl); + } + return statements; + } + /** + * Appends the exports of a VariableDeclaration or BindingElement to a statement list, + * returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfBindingElement(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + statements = appendExportsOfBindingElement(statements, element); + } + } + } + else if (!ts.isGeneratedIdentifier(decl.name)) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + /** + * Appends the exports of a ClassDeclaration or FunctionDeclaration to a statement list, + * returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfHoistedDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.hasModifier(decl, 1 /* Export */)) { + var exportName = ts.hasModifier(decl, 512 /* Default */) ? ts.createIdentifier("default") : decl.name; + statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), /*location*/ decl); + } + if (decl.name) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + /** + * Appends the exports of a declaration to a statement list, returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration to export. + */ + function appendExportsOfDeclaration(statements, decl) { + var name = ts.getDeclarationName(decl); + var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(name.text); + if (exportSpecifiers) { + for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { + var exportSpecifier = exportSpecifiers_1[_i]; + statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name); + } + } + return statements; + } + /** + * Appends the down-level representation of an export to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param exportName The name of the export. + * @param expression The expression to export. + * @param location The location to use for source maps and comments for the export. + * @param allowComments Whether to allow comments on the export. + */ + function appendExportStatement(statements, exportName, expression, location, allowComments) { + statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); + return statements; + } + function createUnderscoreUnderscoreESModule() { + var statement; + if (languageVersion === 0 /* ES3 */) { + statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true))); + } + else { + statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ])); + } + ts.setEmitFlags(statement, 524288 /* CustomPrologue */); + return statement; + } + /** + * Creates a call to the current file's export function to export a value. + * + * @param name The bound name of the export. + * @param value The exported value. + * @param location The location to use for source maps and comments for the export. + * @param allowComments An optional value indicating whether to emit comments for the statement. + */ + function createExportStatement(name, value, location, allowComments) { + var statement = ts.setTextRange(ts.createStatement(createExportExpression(name, value)), location); + ts.startOnNewLine(statement); + if (!allowComments) { + ts.setEmitFlags(statement, 1536 /* NoComments */); + } + return statement; + } + /** + * Creates a call to the current file's export function to export a value. + * + * @param name The bound name of the export. + * @param value The exported value. + * @param location The location to use for source maps and comments for the export. + */ + function createExportExpression(name, value, location) { + return ts.setTextRange(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value), location); + } + // + // Modifier Visitors + // + /** + * Visit nodes to elide module-specific modifiers. + * + * @param node The node to visit. + */ + function modifierVisitor(node) { + // Elide module-specific modifiers. + switch (node.kind) { + case 83 /* ExportKeyword */: + case 78 /* DefaultKeyword */: + return undefined; + } + return node; } // // Emit Notification // /** - * Hook for node emit. + * Hook for node emit notifications. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ - function onEmitNode(emitContext, node, emitCallback) { - if (ts.isSourceFile(node)) { + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264 /* SourceFile */) { currentSourceFile = node; - previousOnEmitNode(emitContext, node, emitCallback); + currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; + noSubstitution = []; + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; + currentModuleInfo = undefined; + noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } // @@ -54555,27 +57305,188 @@ var ts; /** * Hooks node substitutions. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (ts.isIdentifier(node) && emitContext === 1 /* Expression */) { - return substituteExpressionIdentifier(node); + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (node.id && noSubstitution[node.id]) { + return node; + } + if (hint === 1 /* Expression */) { + return substituteExpression(node); + } + else if (ts.isShorthandPropertyAssignment(node)) { + return substituteShorthandPropertyAssignment(node); } return node; } + /** + * Substitution for a ShorthandPropertyAssignment whose declaration name is an imported + * or exported symbol. + * + * @param node The node to substitute. + */ + function substituteShorthandPropertyAssignment(node) { + var name = node.name; + var exportedOrImportedName = substituteExpressionIdentifier(name); + if (exportedOrImportedName !== name) { + // A shorthand property with an assignment initializer is probably part of a + // destructuring assignment + if (node.objectAssignmentInitializer) { + var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); + } + return ts.setTextRange(ts.createPropertyAssignment(name, exportedOrImportedName), node); + } + return node; + } + /** + * Substitution for an Expression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteExpression(node) { + switch (node.kind) { + case 70 /* Identifier */: + return substituteExpressionIdentifier(node); + case 193 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 192 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + return substituteUnaryExpression(node); + } + return node; + } + /** + * Substitution for an Identifier expression that may contain an imported or exported + * symbol. + * + * @param node The node to substitute. + */ function substituteExpressionIdentifier(node) { if (ts.getEmitFlags(node) & 4096 /* HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return ts.createPropertyAccess(externalHelpersModuleName, node); } + return node; + } + if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { + var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); + if (exportContainer && exportContainer.kind === 264 /* SourceFile */) { + return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), + /*location*/ node); + } + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + if (ts.isImportClause(importDeclaration)) { + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), + /*location*/ node); + } + else if (ts.isImportSpecifier(importDeclaration)) { + var name = importDeclaration.propertyName || importDeclaration.name; + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name)), + /*location*/ node); + } + } } return node; } + /** + * Substitution for a BinaryExpression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteBinaryExpression(node) { + // When we see an assignment expression whose left-hand side is an exported symbol, + // we should ensure all exports of that symbol are updated with the correct value. + // + // - We do not substitute generated identifiers for any reason. + // - We do not substitute identifiers tagged with the LocalName flag. + // - We do not substitute identifiers that were originally the name of an enum or + // namespace due to how they are transformed in TypeScript. + // - We only substitute identifiers that are exported at the top level. + if (ts.isAssignmentOperator(node.operatorToken.kind) + && ts.isIdentifier(node.left) + && !ts.isGeneratedIdentifier(node.left) + && !ts.isLocalName(node.left) + && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { + var exportedNames = getExports(node.left); + if (exportedNames) { + // For each additional export of the declaration, apply an export assignment. + var expression = node; + for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { + var exportName = exportedNames_1[_i]; + // Mark the node to prevent triggering this rule again. + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression, /*location*/ node); + } + return expression; + } + } + return node; + } + /** + * Substitution for a UnaryExpression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteUnaryExpression(node) { + // When we see a prefix or postfix increment expression whose operand is an exported + // symbol, we should ensure all exports of that symbol are updated with the correct + // value. + // + // - We do not substitute generated identifiers for any reason. + // - We do not substitute identifiers tagged with the LocalName flag. + // - We do not substitute identifiers that were originally the name of an enum or + // namespace due to how they are transformed in TypeScript. + // - We only substitute identifiers that are exported at the top level. + if ((node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) + && ts.isIdentifier(node.operand) + && !ts.isGeneratedIdentifier(node.operand) + && !ts.isLocalName(node.operand) + && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var expression = node.kind === 192 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 42 /* PlusPlusToken */ ? 58 /* PlusEqualsToken */ : 59 /* MinusEqualsToken */), ts.createLiteral(1)), + /*location*/ node) + : node; + for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { + var exportName = exportedNames_2[_i]; + // Mark the node to prevent triggering this rule again. + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression); + } + return expression; + } + } + return node; + } + /** + * Gets the additional exports of a name. + * + * @param name The name. + */ + function getExports(name) { + if (!ts.isGeneratedIdentifier(name)) { + var valueDeclaration = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); + if (valueDeclaration) { + return currentModuleInfo + && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; + } + } + } } - ts.transformES2015Module = transformES2015Module; + ts.transformModule = transformModule; + // emit output for the __export helper function + var exportStarHelper = { + name: "typescript:export-star", + scoped: true, + text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" + }; })(ts || (ts = {})); /// /// @@ -54592,14 +57503,14 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(261 /* SourceFile */); // Restore state when substituting nodes in a file. - var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. - var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. - var exportFunctionsMap = ts.createMap(); // The export function associated with a source file. - var noSubstitutionMap = ts.createMap(); // Set of nodes for which substitution rules should be ignored for each file. + context.enableSubstitution(193 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(191 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(192 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(264 /* SourceFile */); // Restore state when substituting nodes in a file. + var moduleInfoMap = []; // The ExternalModuleInfo for each file. + var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. + var exportFunctionsMap = []; // The export function associated with a source file. + var noSubstitutionMap = []; // Set of nodes for which substitution rules should be ignored for each file. var currentSourceFile; // The current file. var moduleInfo; // ExternalModuleInfo for the current file. var exportFunction; // The export function for the current file. @@ -54638,7 +57549,8 @@ var ts; moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); // Make sure that the name of the 'exports' function does not conflict with // existing identifiers. - exportFunction = exportFunctionsMap[id] = ts.createUniqueName("exports"); + exportFunction = ts.createUniqueName("exports"); + exportFunctionsMap[id] = exportFunction; contextObject = ts.createUniqueName("context"); // Add the body of the module. var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); @@ -54657,12 +57569,12 @@ var ts; // So the helper will be emit at the correct position instead of at the top of the source-file var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); - var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.createNodeArray([ + var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ], node.statements)), 1024 /* NoTrailingComments */); + ]), node.statements)), 1024 /* NoTrailingComments */); if (!(compilerOptions.outFile || compilerOptions.out)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -54690,13 +57602,13 @@ var ts; var externalImport = externalImports[i]; var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices.get(text); + if (groupIndex !== undefined) { // deduplicate/group entries in dependency list by the dependency name - var groupIndex = groupIndices[text]; dependencyGroups[groupIndex].externalImports.push(externalImport); } else { - groupIndices[text] = dependencyGroups.length; + groupIndices.set(text, dependencyGroups.length); dependencyGroups.push({ name: externalModuleName, externalImports: [externalImport] @@ -54780,7 +57692,7 @@ var ts; // - Temporary variables will appear at the top rather than at the bottom of the file ts.addRange(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + var moduleObject = ts.createObjectLiteral([ ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), ts.createPropertyAssignment("execute", ts.createFunctionExpression( /*modifiers*/ undefined, @@ -54788,12 +57700,11 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, ts.createBlock(executeStatements, - /*location*/ undefined, - /*multiLine*/ true))) - ]), - /*multiLine*/ true))); - return ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); + /*type*/ undefined, ts.createBlock(executeStatements, /*multiLine*/ true))) + ]); + moduleObject.multiLine = true; + statements.push(ts.createReturn(moduleObject)); + return ts.createBlock(statements, /*multiLine*/ true); } /** * Adds an exportStar function to a statement list if it is needed for the file. @@ -54809,13 +57720,13 @@ var ts; // to support this we store names of local/indirect exported entries in a set. // this set is used to filter names brought by star expors. // local names set should only be added if we have anything exported - if (!moduleInfo.exportedNames && ts.isEmpty(moduleInfo.exportSpecifiers)) { + if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) { // no exported declarations (export var ...) or export specifiers (export {x}) // check if we have any non star export declarations. var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 241 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 243 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -54835,12 +57746,12 @@ var ts; continue; } // write name of exported declaration, i.e 'export var x...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createTrue())); } } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 241 /* ExportDeclaration */) { + if (externalImport.kind !== 243 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -54851,14 +57762,14 @@ var ts; for (var _f = 0, _g = exportDecl.exportClause.elements; _f < _g.length; _f++) { var element = _g[_f]; // write name of indirectly exported entry, i.e. 'export {x} from ...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createTrue())); } } var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); statements.push(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(exportedNamesStorageRef, - /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*location*/ undefined, /*multiline*/ true)) + /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*multiline*/ true)) ]))); var exportStarFunction = createExportStarFunction(exportedNamesStorageRef); statements.push(exportStarFunction); @@ -54899,9 +57810,7 @@ var ts; ])), ts.createStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [exports])) - ], - /*location*/ undefined, - /*multiline*/ true)); + ], /*multiline*/ true)); } /** * Creates an array setter callbacks for each dependency group. @@ -54921,19 +57830,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // fall-through - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -54950,7 +57859,7 @@ var ts; properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); } statements.push(ts.createStatement(ts.createCall(exportFunction, - /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*location*/ undefined, /*multiline*/ true)]))); + /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*multiline*/ true)]))); } else { // export * from 'foo' @@ -54969,9 +57878,9 @@ var ts; /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], - /*type*/ undefined, ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true))); + /*type*/ undefined, ts.createBlock(statements, /*multiLine*/ true))); } - return ts.createArrayLiteral(setters, /*location*/ undefined, /*multiLine*/ true); + return ts.createArrayLiteral(setters, /*multiLine*/ true); } // // Top-level Source Element Visitors @@ -54983,15 +57892,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return visitImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -55092,11 +58001,9 @@ var ts; var name = ts.getLocalName(node); hoistVariableDeclaration(name); // Rewrite the class declaration into an assignment of a class expression. - statements = ts.append(statements, ts.createStatement(ts.createAssignment(name, ts.createClassExpression( + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement), - /*location*/ node)), - /*location*/ node)); + /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts.getOriginalNodeId(node); @@ -55131,7 +58038,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), /*location*/ node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -55169,7 +58076,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 1048576 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 261 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 264 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -55216,8 +58123,8 @@ var ts; function createVariableAssignment(name, value, location, isExportedDeclaration) { hoistVariableDeclaration(ts.getSynthesizedClone(name)); return isExportedDeclaration - ? createExportExpression(name, preventSubstitution(ts.createAssignment(name, value, location))) - : preventSubstitution(ts.createAssignment(name, value, location)); + ? createExportExpression(name, preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location))) + : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } /** * Visits a MergeDeclarationMarker used as a placeholder for the beginning of a merged @@ -55233,7 +58140,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -55289,10 +58196,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237 /* NamespaceImport */: + case 239 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238 /* NamedImports */: + case 240 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -55410,10 +58317,10 @@ var ts; return statements; } var name = ts.getDeclarationName(decl); - var exportSpecifiers = moduleInfo.exportSpecifiers[name.text]; + var exportSpecifiers = moduleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { - for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { - var exportSpecifier = exportSpecifiers_1[_i]; + for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { + var exportSpecifier = exportSpecifiers_2[_i]; if (exportSpecifier.name.text !== excludeName) { statements = appendExportStatement(statements, exportSpecifier.name, name); } @@ -55471,43 +58378,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: return visitVariableStatement(node); - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return visitClassDeclaration(node); - case 211 /* ForStatement */: + case 213 /* ForStatement */: return visitForStatement(node); - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: return visitForInStatement(node); - case 213 /* ForOfStatement */: + case 215 /* ForOfStatement */: return visitForOfStatement(node); - case 209 /* DoStatement */: + case 211 /* DoStatement */: return visitDoStatement(node); - case 210 /* WhileStatement */: + case 212 /* WhileStatement */: return visitWhileStatement(node); - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return visitLabeledStatement(node); - case 217 /* WithStatement */: + case 219 /* WithStatement */: return visitWithStatement(node); - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: return visitSwitchStatement(node); - case 232 /* CaseBlock */: + case 234 /* CaseBlock */: return visitCaseBlock(node); - case 253 /* CaseClause */: + case 256 /* CaseClause */: return visitCaseClause(node); - case 254 /* DefaultClause */: + case 257 /* DefaultClause */: return visitDefaultClause(node); - case 221 /* TryStatement */: + case 223 /* TryStatement */: return visitTryStatement(node); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return visitCatchClause(node); - case 204 /* Block */: + case 206 /* Block */: return visitBlock(node); - case 295 /* MergeDeclarationMarker */: + case 299 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 296 /* EndOfDeclarationMarker */: + case 300 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -55687,7 +58594,7 @@ var ts; */ function destructuringVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 192 /* BinaryExpression */) { + && node.kind === 193 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (node.transformFlags & 2048 /* ContainsDestructuringAssignment */) { @@ -55735,7 +58642,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 261 /* SourceFile */; + return container !== undefined && container.kind === 264 /* SourceFile */; } else { return false; @@ -55763,12 +58670,12 @@ var ts; /** * Hook for node emit notifications. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. - * @param emit A callback used to emit the node in the printer. + * @param emitCallback A callback used to emit the node in the printer. */ - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261 /* SourceFile */) { + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -55777,14 +58684,14 @@ var ts; if (noSubstitution) { delete noSubstitutionMap[id]; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } // @@ -55793,15 +58700,15 @@ var ts; /** * Hooks node substitutions. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); if (isSubstitutionPrevented(node)) { return node; } - if (emitContext === 1 /* Expression */) { + if (hint === 1 /* Expression */) { return substituteExpression(node); } return node; @@ -55815,10 +58722,10 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return substituteExpressionIdentifier(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return substituteBinaryExpression(node); - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -55846,1072 +58753,11 @@ var ts; var importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), /*location*/ node); } else if (ts.isImportSpecifier(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name), - /*location*/ node); - } - } - } - return node; - } - /** - * Substitution for a BinaryExpression that may contain an imported or exported symbol. - * - * @param node The node to substitute. - */ - function substituteBinaryExpression(node) { - // When we see an assignment expression whose left-hand side is an exported symbol, - // we should ensure all exports of that symbol are updated with the correct value. - // - // - We do not substitute generated identifiers for any reason. - // - We do not substitute identifiers tagged with the LocalName flag. - // - We do not substitute identifiers that were originally the name of an enum or - // namespace due to how they are transformed in TypeScript. - // - We only substitute identifiers that are exported at the top level. - if (ts.isAssignmentOperator(node.operatorToken.kind) - && ts.isIdentifier(node.left) - && !ts.isGeneratedIdentifier(node.left) - && !ts.isLocalName(node.left) - && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { - var exportedNames = getExports(node.left); - if (exportedNames) { - // For each additional export of the declaration, apply an export assignment. - var expression = node; - for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { - var exportName = exportedNames_1[_i]; - expression = createExportExpression(exportName, preventSubstitution(expression)); - } - return expression; - } - } - return node; - } - /** - * Substitution for a UnaryExpression that may contain an imported or exported symbol. - * - * @param node The node to substitute. - */ - function substituteUnaryExpression(node) { - // When we see a prefix or postfix increment expression whose operand is an exported - // symbol, we should ensure all exports of that symbol are updated with the correct - // value. - // - // - We do not substitute generated identifiers for any reason. - // - We do not substitute identifiers tagged with the LocalName flag. - // - We do not substitute identifiers that were originally the name of an enum or - // namespace due to how they are transformed in TypeScript. - // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) - && ts.isIdentifier(node.operand) - && !ts.isGeneratedIdentifier(node.operand) - && !ts.isLocalName(node.operand) - && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { - var exportedNames = getExports(node.operand); - if (exportedNames) { - var expression = node.kind === 191 /* PostfixUnaryExpression */ - ? ts.createPrefix(node.operator, node.operand, - /*location*/ node) - : node; - for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { - var exportName = exportedNames_2[_i]; - expression = createExportExpression(exportName, preventSubstitution(expression)); - } - if (node.kind === 191 /* PostfixUnaryExpression */) { - expression = node.operator === 42 /* PlusPlusToken */ - ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) - : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); - } - return expression; - } - } - return node; - } - /** - * Gets the exports of a name. - * - * @param name The name. - */ - function getExports(name) { - var exportedNames; - if (!ts.isGeneratedIdentifier(name)) { - var valueDeclaration = resolver.getReferencedImportDeclaration(name) - || resolver.getReferencedValueDeclaration(name); - if (valueDeclaration) { - var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 261 /* SourceFile */) { - exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); - } - exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); - } - } - return exportedNames; - } - /** - * Prevent substitution of a node for this transformer. - * - * @param node The node which should not be substituted. - */ - function preventSubstitution(node) { - if (noSubstitution === undefined) - noSubstitution = ts.createMap(); - noSubstitution[ts.getNodeId(node)] = true; - return node; - } - /** - * Determines whether a node should not be substituted. - * - * @param node The node to test. - */ - function isSubstitutionPrevented(node) { - return noSubstitution && node.id && noSubstitution[node.id]; - } - } - ts.transformSystemModule = transformSystemModule; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var moduleKind = ts.getEmitModuleKind(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(258 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(261 /* SourceFile */); // Restore state when substituting nodes in a file. - var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. - var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. - var currentSourceFile; // The current file. - var currentModuleInfo; // The ExternalModuleInfo for the current file. - var noSubstitution; // Set of nodes for which substitution rules should be ignored. - return transformSourceFile; - /** - * Transforms the module aspects of a SourceFile. - * - * @param node The SourceFile node. - */ - function transformSourceFile(node) { - if (ts.isDeclarationFile(node) - || !(ts.isExternalModule(node) - || compilerOptions.isolatedModules)) { - return node; - } - currentSourceFile = node; - currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(node)] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); - // Perform the transformation. - var transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; - var updated = transformModule(node); - currentSourceFile = undefined; - currentModuleInfo = undefined; - return ts.aggregateTransformFlags(updated); - } - /** - * Transforms a SourceFile into a CommonJS module. - * - * @param node The SourceFile node. - */ - function transformCommonJSModule(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); - ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); - var updated = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); - if (currentModuleInfo.hasExportStarsToExportValues) { - ts.addEmitHelper(updated, exportStarHelper); - } - return updated; - } - /** - * Transforms a SourceFile into an AMD module. - * - * @param node The SourceFile node. - */ - function transformAMDModule(node) { - var define = ts.createIdentifier("define"); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); - } - /** - * Transforms a SourceFile into a UMD module. - * - * @param node The SourceFile node. - */ - function transformUMDModule(node) { - var define = ts.createRawExpression(umdHelper); - return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); - } - /** - * Transforms a SourceFile into an AMD or UMD module. - * - * @param node The SourceFile node. - * @param define The expression used to define the module. - * @param moduleName An expression for the module name, if available. - * @param includeNonAmdDependencies A value indicating whether to incldue any non-AMD dependencies. - */ - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - // An AMD define function has the following shape: - // - // define(id?, dependencies?, factory); - // - // This has the shape of the following: - // - // define(name, ["module1", "module2"], function (module1Alias) { ... } - // - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. - // - // To ensure this is true in cases of modules with no aliases, e.g.: - // - // import "module" - // - // or - // - // /// - // - // we need to add modules without alias names to the end of the dependencies list - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - // Create an updated SourceFile: - // - // define(moduleName?, ["module1", "module2"], function ... - return ts.updateSourceFileNode(node, ts.createNodeArray([ - ts.createStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - // Add the dependency array argument: - // - // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral([ - ts.createLiteral("require"), - ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), - // Add the module body function argument: - // - // function (require, exports, module1, module2) ... - ts.createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ - ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), - ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), - /*type*/ undefined, transformAsynchronousModuleBody(node)) - ]))) - ], - /*location*/ node.statements)); - } - /** - * Collect the additional asynchronous dependencies for the module. - * - * @param node The source file. - * @param includeNonAmdDependencies A value indicating whether to include non-AMD dependencies. - */ - function collectAsynchronousDependencies(node, includeNonAmdDependencies) { - // names of modules with corresponding parameter in the factory function - var aliasedModuleNames = []; - // names of modules with no corresponding parameters in factory function - var unaliasedModuleNames = []; - // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding - // module names in aliasedModuleNames. - var importAliasNames = []; - // Fill in amd-dependency tags - for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { - var amdDependency = _a[_i]; - if (amdDependency.name) { - aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, amdDependency.name)); - } - else { - unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - } - } - for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) { - var importNode = _c[_b]; - // Find the name of the external module - var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - // Find the name of the module alias, if there is one - var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - // Set emitFlags on the name of the classDeclaration - // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; - } - /** - * Transforms a SourceFile into an AMD or UMD module body. - * - * @param node The SourceFile node. - */ - function transformAsynchronousModuleBody(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - // Visit each statement of the module body. - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); - ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - // End the lexical environment for the module body - // and merge any new lexical declarations. - ts.addRange(statements, endLexicalEnvironment()); - // Append the 'export =' statement if provided. - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); - var body = ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); - if (currentModuleInfo.hasExportStarsToExportValues) { - // If we have any `export * from ...` declarations - // we need to inform the emitter to add the __export helper. - ts.addEmitHelper(body, exportStarHelper); - } - return body; - } - /** - * Adds the down-level representation of `export=` to the statement list if one exists - * in the source file. - * - * @param statements The Statement list to modify. - * @param emitAsReturn A value indicating whether to emit the `export=` statement as a - * return statement. - */ - function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (currentModuleInfo.exportEquals) { - if (emitAsReturn) { - var statement = ts.createReturn(currentModuleInfo.exportEquals.expression, - /*location*/ currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression), - /*location*/ currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536 /* NoComments */); - statements.push(statement); - } - } - } - // - // Top-Level Source Element Visitors - // - /** - * Visits a node at the top level of the source file. - * - * @param node The node to visit. - */ - function sourceElementVisitor(node) { - switch (node.kind) { - case 235 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 241 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 240 /* ExportAssignment */: - return visitExportAssignment(node); - case 205 /* VariableStatement */: - return visitVariableStatement(node); - case 225 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 226 /* ClassDeclaration */: - return visitClassDeclaration(node); - case 295 /* MergeDeclarationMarker */: - return visitMergeDeclarationMarker(node); - case 296 /* EndOfDeclarationMarker */: - return visitEndOfDeclarationMarker(node); - default: - // This visitor does not descend into the tree, as export/import statements - // are only transformed at the top level of a file. - return node; - } - } - /** - * Visits an ImportDeclaration node. - * - * @param node The node to visit. - */ - function visitImportDeclaration(node) { - var statements; - var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); - if (moduleKind !== ts.ModuleKind.AMD) { - if (!node.importClause) { - // import "mod"; - return ts.createStatement(createRequireCall(node), /*location*/ node); - } - else { - var variables = []; - if (namespaceDeclaration && !ts.isDefaultImport(node)) { - // import * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, createRequireCall(node))); - } - else { - // import d from "mod"; - // import { x, y } from "mod"; - // import d, { x, y } from "mod"; - // import d, * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), - /*type*/ undefined, createRequireCall(node))); - if (namespaceDeclaration && ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node))); - } - } - statements = ts.append(statements, ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList(variables, - /*location*/ undefined, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */), - /*location*/ node)); - } - } - else if (namespaceDeclaration && ts.isDefaultImport(node)) { - // import d, * as n from "mod"; - statements = ts.append(statements, ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node), - /*location*/ node) - ], - /*location*/ undefined, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfImportDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Creates a `require()` call to import an external module. - * - * @param importNode The declararation to import. - */ - function createRequireCall(importNode) { - var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var args = []; - if (moduleName) { - args.push(moduleName); - } - return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); - } - /** - * Visits an ImportEqualsDeclaration node. - * - * @param node The node to visit. - */ - function visitImportEqualsDeclaration(node) { - ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); - var statements; - if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(node.name, createRequireCall(node)), - /*location*/ node)); - } - else { - statements = ts.append(statements, ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), - /*type*/ undefined, createRequireCall(node)) - ], - /*location*/ undefined, - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */), - /*location*/ node)); - } - } - else { - if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node)), - /*location*/ node)); - } - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfImportEqualsDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Visits an ExportDeclaration node. - * - * @param The node to visit. - */ - function visitExportDeclaration(node) { - if (!node.moduleSpecifier) { - // Elide export declarations with no module specifier as they are handled - // elsewhere. - return undefined; - } - var generatedName = ts.getGeneratedNameForNode(node); - if (node.exportClause) { - var statements = []; - // export { x, y } from "mod"; - if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(generatedName, - /*type*/ undefined, createRequireCall(node)) - ]), - /*location*/ node)); - } - for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { - var specifier = _a[_i]; - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue), - /*location*/ specifier)); - } - return ts.singleOrMany(statements); - } - else { - // export * from "mod"; - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), - /*typeArguments*/ undefined, [ - moduleKind !== ts.ModuleKind.AMD - ? createRequireCall(node) - : generatedName - ]), - /*location*/ node); - } - } - /** - * Visits an ExportAssignment node. - * - * @param node The node to visit. - */ - function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; - } - var statements; - var original = node.original; - if (original && hasAssociatedEndOfDeclarationMarker(original)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); - } - else { - statements = appendExportStatement(statements, ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); - } - return ts.singleOrMany(statements); - } - /** - * Visits a FunctionDeclaration node. - * - * @param node The node to visit. - */ - function visitFunctionDeclaration(node) { - var statements; - if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createFunctionDeclaration( - /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), - /*typeParameters*/ undefined, node.parameters, - /*type*/ undefined, node.body, - /*location*/ node), - /*original*/ node)); - } - else { - statements = ts.append(statements, node); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfHoistedDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Visits a ClassDeclaration node. - * - * @param node The node to visit. - */ - function visitClassDeclaration(node) { - var statements; - if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createClassDeclaration( - /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), - /*typeParameters*/ undefined, node.heritageClauses, node.members, - /*location*/ node), - /*original*/ node)); - } - else { - statements = ts.append(statements, node); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfHoistedDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Visits a VariableStatement node. - * - * @param node The node to visit. - */ - function visitVariableStatement(node) { - var statements; - var variables; - var expressions; - if (ts.hasModifier(node, 1 /* Export */)) { - var modifiers = void 0; - // If we're exporting these variables, then these just become assignments to 'exports.x'. - // We only want to emit assignments for variables with initializers. - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { - if (!modifiers) { - modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); - } - variables = ts.append(variables, variable); - } - else if (variable.initializer) { - expressions = ts.append(expressions, transformInitializedVariable(variable)); - } - } - if (variables) { - statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); - } - if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), /*location*/ node)); - } - } - else { - statements = ts.append(statements, node); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); - } - else { - statements = appendExportsOfVariableStatement(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Transforms an exported variable with an initializer into an expression. - * - * @param node The node to transform. - */ - function transformInitializedVariable(node) { - if (ts.isBindingPattern(node.name)) { - return ts.flattenDestructuringAssignment(node, - /*visitor*/ undefined, context, 0 /* All */, - /*needsValue*/ false, createExportExpression); - } - else { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name, - /*location*/ node.name), node.initializer); - } - } - /** - * Visits a MergeDeclarationMarker used as a placeholder for the beginning of a merged - * and transformed declaration. - * - * @param node The node to visit. - */ - function visitMergeDeclarationMarker(node) { - // For an EnumDeclaration or ModuleDeclaration that merges with a preceeding - // declaration we do not emit a leading variable declaration. To preserve the - // begin/end semantics of the declararation and to properly handle exports - // we wrapped the leading variable declaration in a `MergeDeclarationMarker`. - // - // To balance the declaration, add the exports of the elided variable - // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205 /* VariableStatement */) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); - } - return node; - } - /** - * Determines whether a node has an associated EndOfDeclarationMarker. - * - * @param node The node to test. - */ - function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 2097152 /* HasEndOfDeclarationMarker */) !== 0; - } - /** - * Visits a DeclarationMarker used as a placeholder for the end of a transformed - * declaration. - * - * @param node The node to visit. - */ - function visitEndOfDeclarationMarker(node) { - // For some transformations we emit an `EndOfDeclarationMarker` to mark the actual - // end of the transformed declaration. We use this marker to emit any deferred exports - // of the declaration. - var id = ts.getOriginalNodeId(node); - var statements = deferredExports[id]; - if (statements) { - delete deferredExports[id]; - return ts.append(statements, node); - } - return node; - } - /** - * Appends the exports of an ImportDeclaration to a statement list, returning the - * statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration whose exports are to be recorded. - */ - function appendExportsOfImportDeclaration(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - var importClause = decl.importClause; - if (!importClause) { - return statements; - } - if (importClause.name) { - statements = appendExportsOfDeclaration(statements, importClause); - } - var namedBindings = importClause.namedBindings; - if (namedBindings) { - switch (namedBindings.kind) { - case 237 /* NamespaceImport */: - statements = appendExportsOfDeclaration(statements, namedBindings); - break; - case 238 /* NamedImports */: - for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { - var importBinding = _a[_i]; - statements = appendExportsOfDeclaration(statements, importBinding); - } - break; - } - } - return statements; - } - /** - * Appends the exports of an ImportEqualsDeclaration to a statement list, returning the - * statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration whose exports are to be recorded. - */ - function appendExportsOfImportEqualsDeclaration(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - return appendExportsOfDeclaration(statements, decl); - } - /** - * Appends the exports of a VariableStatement to a statement list, returning the statement - * list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param node The VariableStatement whose exports are to be recorded. - */ - function appendExportsOfVariableStatement(statements, node) { - if (currentModuleInfo.exportEquals) { - return statements; - } - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - statements = appendExportsOfBindingElement(statements, decl); - } - return statements; - } - /** - * Appends the exports of a VariableDeclaration or BindingElement to a statement list, - * returning the statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration whose exports are to be recorded. - */ - function appendExportsOfBindingElement(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - if (ts.isBindingPattern(decl.name)) { - for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - statements = appendExportsOfBindingElement(statements, element); - } - } - } - else if (!ts.isGeneratedIdentifier(decl.name)) { - statements = appendExportsOfDeclaration(statements, decl); - } - return statements; - } - /** - * Appends the exports of a ClassDeclaration or FunctionDeclaration to a statement list, - * returning the statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration whose exports are to be recorded. - */ - function appendExportsOfHoistedDeclaration(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - if (ts.hasModifier(decl, 1 /* Export */)) { - var exportName = ts.hasModifier(decl, 512 /* Default */) ? ts.createIdentifier("default") : decl.name; - statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), /*location*/ decl); - } - if (decl.name) { - statements = appendExportsOfDeclaration(statements, decl); - } - return statements; - } - /** - * Appends the exports of a declaration to a statement list, returning the statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration to export. - */ - function appendExportsOfDeclaration(statements, decl) { - var name = ts.getDeclarationName(decl); - var exportSpecifiers = currentModuleInfo.exportSpecifiers[name.text]; - if (exportSpecifiers) { - for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { - var exportSpecifier = exportSpecifiers_2[_i]; - statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name); - } - } - return statements; - } - /** - * Appends the down-level representation of an export to a statement list, returning the - * statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param exportName The name of the export. - * @param expression The expression to export. - * @param location The location to use for source maps and comments for the export. - * @param allowComments Whether to allow comments on the export. - */ - function appendExportStatement(statements, exportName, expression, location, allowComments) { - if (exportName.text === "default") { - var sourceFile = ts.getOriginalNode(currentSourceFile, ts.isSourceFile); - if (sourceFile && !sourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 0 /* ES3 */) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); - } - else { - statements = ts.append(statements, ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), - /*typeArguments*/ undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); - } - } - } - statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); - return statements; - } - /** - * Creates a call to the current file's export function to export a value. - * - * @param name The bound name of the export. - * @param value The exported value. - * @param location The location to use for source maps and comments for the export. - * @param allowComments An optional value indicating whether to emit comments for the statement. - */ - function createExportStatement(name, value, location, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value), location); - ts.startOnNewLine(statement); - if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); - } - return statement; - } - /** - * Creates a call to the current file's export function to export a value. - * - * @param name The bound name of the export. - * @param value The exported value. - * @param location The location to use for source maps and comments for the export. - */ - function createExportExpression(name, value, location) { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value, location); - } - // - // Modifier Visitors - // - /** - * Visit nodes to elide module-specific modifiers. - * - * @param node The node to visit. - */ - function modifierVisitor(node) { - // Elide module-specific modifiers. - switch (node.kind) { - case 83 /* ExportKeyword */: - case 78 /* DefaultKeyword */: - return undefined; - } - return node; - } - // - // Emit Notification - // - /** - * Hook for node emit notifications. - * - * @param emitContext A context hint for the emitter. - * @param node The node to emit. - * @param emit A callback used to emit the node in the printer. - */ - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261 /* SourceFile */) { - currentSourceFile = node; - currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; - noSubstitution = ts.createMap(); - previousOnEmitNode(emitContext, node, emitCallback); - currentSourceFile = undefined; - currentModuleInfo = undefined; - noSubstitution = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - // - // Substitutions - // - /** - * Hooks node substitutions. - * - * @param emitContext A context hint for the emitter. - * @param node The node to substitute. - */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (node.id && noSubstitution[node.id]) { - return node; - } - if (emitContext === 1 /* Expression */) { - return substituteExpression(node); - } - else if (ts.isShorthandPropertyAssignment(node)) { - return substituteShorthandPropertyAssignment(node); - } - return node; - } - /** - * Substitution for a ShorthandPropertyAssignment whose declaration name is an imported - * or exported symbol. - * - * @param node The node to substitute. - */ - function substituteShorthandPropertyAssignment(node) { - var name = node.name; - var exportedOrImportedName = substituteExpressionIdentifier(name); - if (exportedOrImportedName !== name) { - // A shorthand property with an assignment initializer is probably part of a - // destructuring assignment - if (node.objectAssignmentInitializer) { - var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, /*location*/ node); - } - return ts.createPropertyAssignment(name, exportedOrImportedName, /*location*/ node); - } - return node; - } - /** - * Substitution for an Expression that may contain an imported or exported symbol. - * - * @param node The node to substitute. - */ - function substituteExpression(node) { - switch (node.kind) { - case 70 /* Identifier */: - return substituteExpressionIdentifier(node); - case 192 /* BinaryExpression */: - return substituteBinaryExpression(node); - case 191 /* PostfixUnaryExpression */: - case 190 /* PrefixUnaryExpression */: - return substituteUnaryExpression(node); - } - return node; - } - /** - * Substitution for an Identifier expression that may contain an imported or exported - * symbol. - * - * @param node The node to substitute. - */ - function substituteExpressionIdentifier(node) { - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) { - return ts.createPropertyAccess(externalHelpersModuleName, node); - } - return node; - } - if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { - var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 261 /* SourceFile */) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), - /*location*/ node); - } - var importDeclaration = resolver.getReferencedImportDeclaration(node); - if (importDeclaration) { - if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), - /*location*/ node); - } - else if (ts.isImportSpecifier(importDeclaration)) { - var name_38 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_38), + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name)), /*location*/ node); } } @@ -56943,9 +58789,7 @@ var ts; var expression = node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { var exportName = exportedNames_3[_i]; - // Mark the node to prevent triggering this rule again. - noSubstitution[ts.getNodeId(expression)] = true; - expression = createExportExpression(exportName, expression, /*location*/ node); + expression = createExportExpression(exportName, preventSubstitution(expression)); } return expression; } @@ -56974,15 +58818,17 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 191 /* PostfixUnaryExpression */ - ? ts.createBinary(node.operand, ts.createToken(node.operator === 42 /* PlusPlusToken */ ? 58 /* PlusEqualsToken */ : 59 /* MinusEqualsToken */), ts.createLiteral(1), - /*location*/ node) + var expression = node.kind === 192 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { var exportName = exportedNames_4[_i]; - // Mark the node to prevent triggering this rule again. - noSubstitution[ts.getNodeId(expression)] = true; - expression = createExportExpression(exportName, expression); + expression = createExportExpression(exportName, preventSubstitution(expression)); + } + if (node.kind === 192 /* PostfixUnaryExpression */) { + expression = node.operator === 42 /* PlusPlusToken */ + ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) + : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } return expression; } @@ -56990,31 +58836,144 @@ var ts; return node; } /** - * Gets the additional exports of a name. + * Gets the exports of a name. * * @param name The name. */ function getExports(name) { + var exportedNames; if (!ts.isGeneratedIdentifier(name)) { var valueDeclaration = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { - return currentModuleInfo - && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; + var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); + if (exportContainer && exportContainer.kind === 264 /* SourceFile */) { + exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); + } + exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); } } + return exportedNames; + } + /** + * Prevent substitution of a node for this transformer. + * + * @param node The node which should not be substituted. + */ + function preventSubstitution(node) { + if (noSubstitution === undefined) + noSubstitution = []; + noSubstitution[ts.getNodeId(node)] = true; + return node; + } + /** + * Determines whether a node should not be substituted. + * + * @param node The node to test. + */ + function isSubstitutionPrevented(node) { + return noSubstitution && node.id && noSubstitution[node.id]; } - var _a; } - ts.transformModule = transformModule; - // emit output for the __export helper function - var exportStarHelper = { - name: "typescript:export-star", - scoped: true, - text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" - }; - // emit output for the UMD helper function. - var umdHelper = "\n (function (dependencies, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(dependencies, factory);\n }\n })"; + ts.transformSystemModule = transformSystemModule; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformES2015Module(context) { + var compilerOptions = context.getCompilerOptions(); + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.enableEmitNotification(264 /* SourceFile */); + context.enableSubstitution(70 /* Identifier */); + var currentSourceFile; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); + if (externalHelpersModuleName) { + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements); + ts.append(statements, ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); + } + else { + return ts.visitEachChild(node, visitor, context); + } + } + return node; + } + function visitor(node) { + switch (node.kind) { + case 236 /* ImportEqualsDeclaration */: + // Elide `import=` as it is not legal with --module ES6 + return undefined; + case 242 /* ExportAssignment */: + return visitExportAssignment(node); + } + return node; + } + function visitExportAssignment(node) { + // Elide `export=` as it is not legal with --module ES6 + return node.isExportEquals ? undefined : node; + } + // + // Emit Notification + // + /** + * Hook for node emit. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to emit. + * @param emit A callback used to emit the node in the printer. + */ + function onEmitNode(hint, node, emitCallback) { + if (ts.isSourceFile(node)) { + currentSourceFile = node; + previousOnEmitNode(hint, node, emitCallback); + currentSourceFile = undefined; + } + else { + previousOnEmitNode(hint, node, emitCallback); + } + } + // + // Substitutions + // + /** + * Hooks node substitutions. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to substitute. + */ + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (ts.isIdentifier(node) && hint === 1 /* Expression */) { + return substituteExpressionIdentifier(node); + } + return node; + } + function substituteExpressionIdentifier(node) { + if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); + if (externalHelpersModuleName) { + return ts.createPropertyAccess(externalHelpersModuleName, node); + } + } + return node; + } + } + ts.transformES2015Module = transformES2015Module; })(ts || (ts = {})); /// /// @@ -57031,14 +58990,16 @@ var ts; /* @internal */ var ts; (function (ts) { - var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, - _a[ts.ModuleKind.System] = ts.transformSystemModule, - _a[ts.ModuleKind.AMD] = ts.transformModule, - _a[ts.ModuleKind.CommonJS] = ts.transformModule, - _a[ts.ModuleKind.UMD] = ts.transformModule, - _a[ts.ModuleKind.None] = ts.transformModule, - _a)); + function getModuleTransformer(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.ES2015: + return ts.transformES2015Module; + case ts.ModuleKind.System: + return ts.transformSystemModule; + default: + return ts.transformModule; + } + } var SyntaxKindFeatureFlags; (function (SyntaxKindFeatureFlags) { SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; @@ -57066,7 +59027,7 @@ var ts; transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } - transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); + transformers.push(getModuleTransformer(moduleKind)); // The ES5 transformer is last so that it can substitute expressions like `exports.default` // for ES3. if (languageVersion < 1 /* ES5 */) { @@ -57084,7 +59045,7 @@ var ts; * @param transforms An array of Transformers. */ function transformFiles(resolver, host, sourceFiles, transformers) { - var enabledSyntaxKindFeatures = new Array(298 /* Count */); + var enabledSyntaxKindFeatures = new Array(301 /* Count */); var lexicalEnvironmentDisabled = false; var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; @@ -57107,19 +59068,22 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, - onSubstituteNode: function (_emitContext, node) { return node; }, + onSubstituteNode: function (_, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, + onEmitNode: function (hint, node, callback) { return callback(hint, node); }, enableEmitNotification: enableEmitNotification, isEmitNotificationEnabled: isEmitNotificationEnabled }; + ts.performance.mark("beforeTransform"); // Chain together and initialize each transformer. var transformation = ts.chain.apply(void 0, transformers)(context); // Transform each source file. var transformed = ts.map(sourceFiles, transformSourceFile); // Disable modification of the lexical environment. lexicalEnvironmentDisabled = true; + ts.performance.mark("afterTransform"); + ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { transformed: transformed, emitNodeWithSubstitution: emitNodeWithSubstitution, @@ -57152,20 +59116,16 @@ var ts; /** * Emits a node with possible substitution. * - * @param emitContext The current emit context. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emitCallback The callback used to emit the node or its substitute. */ - function emitNodeWithSubstitution(emitContext, node, emitCallback) { + function emitNodeWithSubstitution(hint, node, emitCallback) { if (node) { if (isSubstitutionEnabled(node)) { - var substitute = context.onSubstituteNode(emitContext, node); - if (substitute && substitute !== node) { - emitCallback(emitContext, substitute); - return; - } + node = context.onSubstituteNode(hint, node) || node; } - emitCallback(emitContext, node); + emitCallback(hint, node); } } /** @@ -57185,17 +59145,17 @@ var ts; /** * Emits a node with possible emit notification. * - * @param emitContext The current emit context. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emitCallback The callback used to emit the node. */ - function emitNodeWithNotification(emitContext, node, emitCallback) { + function emitNodeWithNotification(hint, node, emitCallback) { if (node) { if (isEmitNotificationEnabled(node)) { - context.onEmitNode(emitContext, node, emitCallback); + context.onEmitNode(hint, node, emitCallback); } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } } @@ -57299,7 +59259,6 @@ var ts; } } ts.transformFiles = transformFiles; - var _a; })(ts || (ts = {})); /// /* @internal */ @@ -57344,10 +59303,9 @@ var ts; * * @param filePath The path to the generated output file. * @param sourceMapFilePath The path to the output source map file. - * @param sourceFiles The input source files for the program. - * @param isBundledEmit A value indicating whether the generated output file is a bundle. + * @param sourceFileOrBundle The input source file or bundle for the program. */ - function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { + function initialize(filePath, sourceMapFilePath, sourceFileOrBundle) { if (disabled) { return; } @@ -57383,11 +59341,10 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (!isBundledEmit) { - ts.Debug.assert(sourceFiles.length === 1); + if (sourceFileOrBundle.kind === 264 /* SourceFile */) { // 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(sourceFiles[0], host, sourceMapDir)); + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { // The relative paths are relative to the common directory @@ -57510,31 +59467,32 @@ var ts; /** * Emits a node with possible leading and trailing source maps. * + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emitCallback The callback used to emit the node. */ - function emitNodeWithSourceMap(emitContext, node, emitCallback) { + function emitNodeWithSourceMap(hint, node, emitCallback) { if (disabled) { - return emitCallback(emitContext, node); + return emitCallback(hint, node); } if (node) { var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 293 /* NotEmittedStatement */ + if (node.kind !== 297 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); } if (emitFlags & 64 /* NoNestedSourceMaps */) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } - if (node.kind !== 293 /* NotEmittedStatement */ + if (node.kind !== 297 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -57669,11 +59627,10 @@ var ts; /* @internal */ var ts; (function (ts) { - function createCommentWriter(host, writer, sourceMap) { - var compilerOptions = host.getCompilerOptions(); - var extendedDiagnostics = compilerOptions.extendedDiagnostics; - var newLine = host.getNewLine(); - var emitPos = sourceMap.emitPos; + function createCommentWriter(printerOptions, emitPos) { + var extendedDiagnostics = printerOptions.extendedDiagnostics; + var newLine = ts.getNewLineCharacter(printerOptions); + var writer; var containerPos = -1; var containerEnd = -1; var declarationListContainerEnd = -1; @@ -57682,17 +59639,19 @@ var ts; var currentLineMap; var detachedCommentsInfo; var hasWrittenComment = false; - var disabled = compilerOptions.removeComments; + var disabled = printerOptions.removeComments; return { reset: reset, + setWriter: setWriter, setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, + emitLeadingCommentsOfPosition: emitLeadingCommentsOfPosition, }; - function emitNodeWithComments(emitContext, node, emitCallback) { + function emitNodeWithComments(hint, node, emitCallback) { if (disabled) { - emitCallback(emitContext, node); + emitCallback(hint, node); return; } if (node) { @@ -57702,18 +59661,18 @@ var ts; // Both pos and end are synthesized, so just emit the node without comments. if (emitFlags & 2048 /* NoNestedComments */) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } else { if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 293 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 297 /* NotEmittedStatement */; var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; // Emit leading comments if the position is not synthesized and the node @@ -57732,7 +59691,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 224 /* VariableDeclarationList */) { + if (node.kind === 226 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -57741,11 +59700,11 @@ var ts; } if (emitFlags & 2048 /* NoNestedComments */) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } if (extendedDiagnostics) { ts.performance.mark("beginEmitNodeWithComment"); @@ -57828,9 +59787,11 @@ var ts; hasWrittenComment = true; } // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -57838,6 +59799,12 @@ var ts; writer.write(" "); } } + function emitLeadingCommentsOfPosition(pos) { + if (disabled || pos === -1) { + return; + } + emitLeadingComments(pos, /*isEmittedNode*/ true); + } function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } @@ -57846,9 +59813,11 @@ var ts; if (!writer.isAtStartOfLine()) { writer.write(" "); } - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -57867,9 +59836,11 @@ var ts; } function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -57900,6 +59871,9 @@ var ts; currentLineMap = undefined; detachedCommentsInfo = undefined; } + function setWriter(output) { + writer = output; + } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; currentText = currentSourceFile.text; @@ -57932,9 +59906,11 @@ var ts; } } function writeComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); } /** * Determine if the given comment is a triple-slash @@ -57963,15 +59939,17 @@ var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, targetSourceFile) { var declarationDiagnostics = ts.createDiagnosticCollection(); - ts.forEachExpectedEmitFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); + ts.forEachEmittedFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined); - function getDeclarationDiagnosticsFromFile(_a, sources, isBundledEmit) { + function getDeclarationDiagnosticsFromFile(_a, sourceFileOrBundle) { var declarationFilePath = _a.declarationFilePath; - emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit, /*emitOnlyDtsFiles*/ false); + emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sourceFileOrBundle, /*emitOnlyDtsFiles*/ false); } } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles) { + function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles) { + var sourceFiles = sourceFileOrBundle.kind === 265 /* Bundle */ ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var isBundledEmit = sourceFileOrBundle.kind === 265 /* Bundle */; var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -58045,7 +60023,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 235 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 237 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -58071,9 +60049,9 @@ var ts; } }); if (usedTypeDirectiveReferences) { - for (var directive in usedTypeDirectiveReferences) { + ts.forEachKey(usedTypeDirectiveReferences, function (directive) { referencesOutput += "/// " + newLine; - } + }); } return { reportedDeclarationError: reportedDeclarationError, @@ -58098,6 +60076,7 @@ var ts; var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; writer.reportInaccessibleThisError = reportInaccessibleThisError; + writer.reportIllegalExtends = reportIllegalExtends; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -58120,10 +60099,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 223 /* VariableDeclaration */) { + if (declaration.kind === 225 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 238 /* NamedImports */ || declaration.kind === 239 /* ImportSpecifier */ || declaration.kind === 236 /* ImportClause */) { + else if (declaration.kind === 240 /* NamedImports */ || declaration.kind === 241 /* ImportSpecifier */ || declaration.kind === 238 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -58141,7 +60120,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 === 235 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 237 /* 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; @@ -58151,12 +60130,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 230 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 232 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 230 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 232 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -58175,8 +60154,8 @@ var ts; } for (var _i = 0, typeReferenceDirectives_1 = typeReferenceDirectives; _i < typeReferenceDirectives_1.length; _i++) { var directive = typeReferenceDirectives_1[_i]; - if (!(directive in usedTypeDirectiveReferences)) { - usedTypeDirectiveReferences[directive] = directive; + if (!usedTypeDirectiveReferences.has(directive)) { + usedTypeDirectiveReferences.set(directive, directive); } } } @@ -58205,6 +60184,12 @@ var ts; handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); } + function reportIllegalExtends() { + if (errorNameNode) { + reportedDeclarationError = true; + emitterDiagnostics.add(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced, ts.declarationNameToString(errorNameNode))); + } + } function reportInaccessibleThisError() { if (errorNameNode) { reportedDeclarationError = true; @@ -58214,13 +60199,19 @@ var ts; function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); - if (type) { + // use the checker's type, not the declared type, + // for non-optional initialized parameters that aren't a parameter property + var shouldUseResolverType = declaration.kind === 145 /* Parameter */ && + resolver.isRequiredInitializedParameter(declaration); + if (type && !shouldUseResolverType) { // Write the type emitType(type); } else { errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); + var format = 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */ | + (shouldUseResolverType ? 4096 /* AddUndefined */ : 0); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer); errorNameNode = undefined; } } @@ -58274,49 +60265,50 @@ var ts; function emitType(type) { switch (type.kind) { case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 133 /* ObjectKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: case 94 /* NullKeyword */: case 129 /* NeverKeyword */: - case 167 /* ThisType */: - case 171 /* LiteralType */: + case 168 /* ThisType */: + case 172 /* LiteralType */: return writeTextOfNode(currentText, type); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return emitTypeReference(type); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return emitTypeQuery(type); - case 162 /* ArrayType */: + case 163 /* ArrayType */: return emitArrayType(type); - case 163 /* TupleType */: + case 164 /* TupleType */: return emitTupleType(type); - case 164 /* UnionType */: + case 165 /* UnionType */: return emitUnionType(type); - case 165 /* IntersectionType */: + case 166 /* IntersectionType */: return emitIntersectionType(type); - case 166 /* ParenthesizedType */: + case 167 /* ParenthesizedType */: return emitParenType(type); - case 168 /* TypeOperator */: + case 169 /* TypeOperator */: return emitTypeOperator(type); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return emitIndexedAccessType(type); - case 170 /* MappedType */: + case 171 /* MappedType */: return emitMappedType(type); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 161 /* TypeLiteral */: + case 162 /* TypeLiteral */: return emitTypeLiteral(type); case 70 /* Identifier */: return emitEntityName(type); - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: return emitEntityName(type); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -58324,8 +60316,8 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 141 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 141 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 142 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 142 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); @@ -58334,14 +60326,14 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 234 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 236 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 /* Identifier */ || node.expression.kind === 177 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 70 /* Identifier */ || node.expression.kind === 178 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -58450,15 +60442,15 @@ var ts; // do not need to keep track of created temp names. function getExportDefaultTempVariableName() { var baseName = "_default"; - if (!(baseName in currentIdentifiers)) { + if (!currentIdentifiers.has(baseName)) { return baseName; } var count = 0; while (true) { count++; - var name_39 = baseName + "_" + count; - if (!(name_39 in currentIdentifiers)) { - return name_39; + var name = baseName + "_" + count; + if (!currentIdentifiers.has(name)) { + return name; } } } @@ -58505,10 +60497,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 234 /* ImportEqualsDeclaration */ || - (node.parent.kind === 261 /* SourceFile */ && isCurrentFileExternalModule)) { + else if (node.kind === 236 /* ImportEqualsDeclaration */ || + (node.parent.kind === 264 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 264 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -58518,7 +60510,7 @@ var ts; }); } else { - if (node.kind === 235 /* ImportDeclaration */) { + if (node.kind === 237 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -58536,23 +60528,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: return writeVariableStatement(node); - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return writeClassDeclaration(node); - case 228 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -58560,7 +60552,7 @@ var ts; } 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.kind === 261 /* SourceFile */) { + if (node.parent.kind === 264 /* SourceFile */) { var modifiers = ts.getModifierFlags(node); // If the node is exported if (modifiers & 1 /* Export */) { @@ -58569,7 +60561,7 @@ var ts; if (modifiers & 512 /* Default */) { write("default "); } - else if (node.kind !== 227 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 229 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -58621,7 +60613,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 237 /* NamespaceImport */) { + if (namedBindings.kind === 239 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -58645,7 +60637,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 239 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -58666,13 +60658,13 @@ var ts; // the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered // external modules since they are indistinguishable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' // so compiler will treat them as external modules. - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 230 /* ModuleDeclaration */; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 232 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 234 /* ImportEqualsDeclaration */) { + if (parent.kind === 236 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 230 /* ModuleDeclaration */) { + else if (parent.kind === 232 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -58742,7 +60734,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 231 /* ModuleBlock */) { + while (node.body && node.body.kind !== 233 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -58812,7 +60804,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 149 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 150 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -58823,53 +60815,70 @@ 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 === 158 /* FunctionType */ || - node.parent.kind === 159 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 161 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 149 /* MethodDeclaration */ || - node.parent.kind === 148 /* MethodSignature */ || - node.parent.kind === 158 /* FunctionType */ || - node.parent.kind === 159 /* ConstructorType */ || - node.parent.kind === 153 /* CallSignature */ || - node.parent.kind === 154 /* ConstructSignature */); + if (node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 162 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 150 /* MethodDeclaration */ || + node.parent.kind === 149 /* MethodSignature */ || + node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + node.parent.kind === 154 /* CallSignature */ || + node.parent.kind === 155 /* ConstructSignature */); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } + if (node.default && !isPrivateMethodTypeParameter(node)) { + write(" = "); + if (node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 162 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 150 /* MethodDeclaration */ || + node.parent.kind === 149 /* MethodSignature */ || + node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + node.parent.kind === 154 /* CallSignature */ || + node.parent.kind === 155 /* ConstructSignature */); + emitType(node.default); + } + else { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.default, getTypeParameterConstraintVisibilityError); + } + } function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 153 /* CallSignature */: + case 154 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 228 /* 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 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 228 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -58888,7 +60897,7 @@ var ts; write(">"); } } - function emitHeritageClause(typeReferences, isImplementsList) { + function emitHeritageClause(className, typeReferences, isImplementsList) { if (typeReferences) { write(isImplementsList ? " implements " : " extends "); emitCommaList(typeReferences, emitTypeOfTypeReference); @@ -58902,20 +60911,22 @@ var ts; } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; + errorNameNode = className; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); + errorNameNode = undefined; } function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 226 /* ClassDeclaration */) { + if (node.parent.parent.kind === 228 /* 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; + 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; + diagnosticMessage = ts.Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; } return { diagnosticMessage: diagnosticMessage, @@ -58947,9 +60958,10 @@ var ts; emitTypeParameters(node.typeParameters); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); + node.name; + emitHeritageClause(node.name, [baseTypeNode], /*isImplementsList*/ false); } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); + emitHeritageClause(node.name, ts.getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); write(" {"); writeLine(); increaseIndent(); @@ -58970,7 +60982,7 @@ var ts; emitTypeParameters(node.typeParameters); var interfaceExtendsTypes = ts.filter(ts.getInterfaceBaseTypeNodes(node), function (base) { return ts.isEntityNameExpression(base.expression); }); if (interfaceExtendsTypes && interfaceExtendsTypes.length) { - emitHeritageClause(interfaceExtendsTypes, /*isImplementsList*/ false); + emitHeritageClause(node.name, interfaceExtendsTypes, /*isImplementsList*/ false); } write(" {"); writeLine(); @@ -58994,7 +61006,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 !== 223 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 225 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -59005,11 +61017,11 @@ var ts; writeTextOfNode(currentText, node.name); // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor // we don't want to emit property declaration with "?" - if ((node.kind === 147 /* PropertyDeclaration */ || node.kind === 146 /* PropertySignature */ || - (node.kind === 144 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 148 /* PropertyDeclaration */ || node.kind === 147 /* PropertySignature */ || + (node.kind === 145 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 147 /* PropertyDeclaration */ || node.kind === 146 /* PropertySignature */) && node.parent.kind === 161 /* TypeLiteral */) { + if ((node.kind === 148 /* PropertyDeclaration */ || node.kind === 147 /* PropertySignature */) && node.parent.kind === 162 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -59022,14 +61034,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 223 /* VariableDeclaration */) { + if (node.kind === 225 /* VariableDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 147 /* PropertyDeclaration */ || node.kind === 146 /* PropertySignature */) { + else if (node.kind === 148 /* PropertyDeclaration */ || node.kind === 147 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -59038,7 +61050,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 === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 228 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -59070,7 +61082,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 198 /* OmittedExpression */) { + if (element.kind !== 199 /* OmittedExpression */) { elements.push(element); } } @@ -59140,7 +61152,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 === 151 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 152 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -59153,7 +61165,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 151 /* GetAccessor */ + return accessor.kind === 152 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -59162,7 +61174,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 152 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 153 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? @@ -59212,17 +61224,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 225 /* FunctionDeclaration */) { + if (node.kind === 227 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 149 /* MethodDeclaration */ || node.kind === 150 /* Constructor */) { + else if (node.kind === 150 /* MethodDeclaration */ || node.kind === 151 /* Constructor */) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 225 /* FunctionDeclaration */) { + if (node.kind === 227 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 150 /* Constructor */) { + else if (node.kind === 151 /* Constructor */) { write("constructor"); } else { @@ -59242,17 +61254,17 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 155 /* IndexSignature */) { + if (node.kind === 156 /* IndexSignature */) { // Index signature can have readonly modifier emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { // Construct signature or constructor type write new Signature - if (node.kind === 154 /* ConstructSignature */ || node.kind === 159 /* ConstructorType */) { + if (node.kind === 155 /* ConstructSignature */ || node.kind === 160 /* ConstructorType */) { write("new "); } - else if (node.kind === 158 /* FunctionType */) { + else if (node.kind === 159 /* FunctionType */) { var currentOutput = writer.getText(); // Do not generate incorrect type when function type with type parameters is type argument // This could happen if user used space between two '<' making it error free @@ -59267,22 +61279,22 @@ var ts; } // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 155 /* IndexSignature */) { + if (node.kind === 156 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 158 /* FunctionType */ || node.kind === 159 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 161 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 159 /* FunctionType */ || node.kind === 160 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 162 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 150 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { + else if (node.kind !== 151 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -59296,26 +61308,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 153 /* CallSignature */: + case 154 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -59323,7 +61335,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 === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 228 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -59337,7 +61349,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -59372,9 +61384,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 158 /* FunctionType */ || - node.parent.kind === 159 /* ConstructorType */ || - node.parent.parent.kind === 161 /* TypeLiteral */) { + if (node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + node.parent.parent.kind === 162 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8 /* Private */)) { @@ -59390,29 +61402,29 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 150 /* Constructor */: + case 151 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 153 /* CallSignature */: + case 154 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -59420,7 +61432,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 === 226 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 228 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -59433,7 +61445,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 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -59445,12 +61457,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 === 172 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 173 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 173 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 174 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -59461,7 +61473,7 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 198 /* OmittedExpression */) { + if (bindingElement.kind === 199 /* 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) @@ -59470,7 +61482,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 174 /* BindingElement */) { + else if (bindingElement.kind === 175 /* 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" @@ -59509,40 +61521,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: - case 230 /* ModuleDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 227 /* InterfaceDeclaration */: - case 226 /* ClassDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* FunctionDeclaration */: + case 232 /* ModuleDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 229 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 231 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return emitExportDeclaration(node); - case 150 /* Constructor */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 151 /* Constructor */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: return writeFunctionDeclaration(node); - case 154 /* ConstructSignature */: - case 153 /* CallSignature */: - case 155 /* IndexSignature */: + case 155 /* ConstructSignature */: + case 154 /* CallSignature */: + case 156 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return emitAccessorDeclaration(node); - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return emitPropertyDeclaration(node); - case 260 /* EnumMember */: + case 263 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return emitExportAssignment(node); - case 261 /* SourceFile */: + case 264 /* SourceFile */: return emitSourceFile(node); } } @@ -59560,7 +61572,7 @@ var ts; } else { // Get the declaration file path - ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); } if (declFileName) { declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(declarationFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, @@ -59568,8 +61580,9 @@ var ts; referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, sourceFileOrBundle) { // Dont add reference path to this file if it is a bundled emit and caller asked not emit bundled file path + var isBundledEmit = sourceFileOrBundle.kind === 265 /* Bundle */; if (isBundledEmit && !addBundledFileReference) { return; } @@ -59580,10 +61593,11 @@ var ts; } } /* @internal */ - function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { - var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles); + function writeDeclarationFile(declarationFilePath, sourceFileOrBundle, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { + var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { + var sourceFiles = sourceFileOrBundle.kind === 265 /* Bundle */ ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; var declarationOutput = emitDeclarationResult.referencesOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); ts.writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM, sourceFiles); @@ -59606,63 +61620,56 @@ var ts; } ts.writeDeclarationFile = writeDeclarationFile; })(ts || (ts = {})); -/// +/// /// -/// -/// +/// +/// /// -/* @internal */ var ts; (function (ts) { - // 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 = {})); - var id = function (s) { return s; }; - var nullTransformers = [function (_) { return id; }]; + var delimiters = createDelimiterMap(); + var brackets = createBracketsMap(); + /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { - var delimiters = createDelimiterMap(); - var brackets = createBracketsMap(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = emitOnlyDtsFiles ? nullTransformers : ts.getTransformers(compilerOptions); + var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); - var write = writer.write, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var sourceMap = ts.createSourceMapWriter(host, writer); - var emitNodeWithSourceMap = sourceMap.emitNodeWithSourceMap, emitTokenWithSourceMap = sourceMap.emitTokenWithSourceMap; - var comments = ts.createCommentWriter(host, writer, sourceMap); - var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition; - var nodeIdToGeneratedName; - var autoGeneratedIdToGeneratedName; - var generatedNameSet; - var tempFlags; var currentSourceFile; - var currentText; - var currentFileIdentifiers; var bundledHelpers; var isOwnFileEmit; var emitSkipped = false; var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); // Transform the source files - ts.performance.mark("beforeTransform"); - var _a = ts.transformFiles(resolver, host, sourceFiles, transformers), transformed = _a.transformed, emitNodeWithSubstitution = _a.emitNodeWithSubstitution, emitNodeWithNotification = _a.emitNodeWithNotification; - ts.performance.measure("transformTime", "beforeTransform"); + var transform = ts.transformFiles(resolver, host, sourceFiles, transformers); + // Create a printer to print the nodes + var printer = createPrinter(compilerOptions, { + // resolver hooks + hasGlobalName: resolver.hasGlobalName, + // transform hooks + onEmitNode: transform.emitNodeWithNotification, + onSubstituteNode: transform.emitNodeWithSubstitution, + // sourcemap hooks + onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, + onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, + onEmitSourceMapOfPosition: sourceMap.emitPos, + // emitter hooks + onEmitHelpers: emitHelpers, + onSetSourceFile: setSourceFile, + }); // Emit each output file ts.performance.mark("beforePrint"); - ts.forEachTransformedEmitFile(host, transformed, emitFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, emitSourceFileOrBundle, transform.transformed, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); // Clean up emit nodes on parse tree - for (var _b = 0, sourceFiles_4 = sourceFiles; _b < sourceFiles_4.length; _b++) { - var sourceFile = sourceFiles_4[_b]; + for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { + var sourceFile = sourceFiles_2[_a]; ts.disposeEmitNodes(sourceFile); } return { @@ -59671,18 +61678,19 @@ var ts; emittedFiles: emittedFilesList, sourceMaps: sourceMapDataList }; - function emitFile(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, isBundledEmit) { + function emitSourceFileOrBundle(_a, sourceFileOrBundle) { + var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath; // Make sure not to write js file and source map file if any of them cannot be written if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { if (!emitOnlyDtsFiles) { - printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle); } } else { emitSkipped = true; } if (declarationFilePath) { - emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; + emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFileOrBundle(sourceFileOrBundle), host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; } if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { @@ -59696,26 +61704,24 @@ var ts; } } } - function printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit) { - sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); - nodeIdToGeneratedName = []; - autoGeneratedIdToGeneratedName = []; - generatedNameSet = ts.createMap(); - bundledHelpers = isBundledEmit ? ts.createMap() : undefined; - isOwnFileEmit = !isBundledEmit; - // Emit helpers from all the files - if (isBundledEmit && moduleKind) { - for (var _a = 0, sourceFiles_5 = sourceFiles; _a < sourceFiles_5.length; _a++) { - var sourceFile = sourceFiles_5[_a]; - emitHelpers(sourceFile, /*isBundle*/ true); - } + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle) { + var bundle = sourceFileOrBundle.kind === 265 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 264 /* SourceFile */ ? sourceFileOrBundle : undefined; + var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; + sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFileOrBundle); + if (bundle) { + bundledHelpers = ts.createMap(); + isOwnFileEmit = false; + printer.writeBundle(bundle, writer); } - // Print each transformed source file. - ts.forEach(sourceFiles, printSourceFile); - writeLine(); + else { + isOwnFileEmit = true; + printer.writeFile(sourceFile, writer); + } + writer.writeLine(); var sourceMappingURL = sourceMap.getSourceMappingURL(); if (sourceMappingURL) { - write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Sometimes tools can sometimes see this line as a source mapping url comment + writer.write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Sometimes tools can sometimes see this line as a source mapping url comment } // Write the source map if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) { @@ -59729,138 +61735,237 @@ var ts; ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM, sourceFiles); // Reset state sourceMap.reset(); - comments.reset(); writer.reset(); - tempFlags = 0 /* Auto */; currentSourceFile = undefined; - currentText = undefined; + bundledHelpers = undefined; isOwnFileEmit = false; } - function printSourceFile(node) { + function setSourceFile(node) { currentSourceFile = node; - currentText = node.text; - currentFileIdentifiers = node.identifiers; sourceMap.setSourceFile(node); - comments.setSourceFile(node); - pipelineEmitWithNotification(0 /* SourceFile */, node); } - /** - * Emits a node. - */ - function emit(node) { - pipelineEmitWithNotification(3 /* Unspecified */, node); + function emitHelpers(node, writeLines) { + var helpersEmitted = false; + var bundle = node.kind === 265 /* Bundle */ ? node : undefined; + if (bundle && moduleKind === ts.ModuleKind.None) { + return; + } + var numNodes = bundle ? bundle.sourceFiles.length : 1; + for (var i = 0; i < numNodes; i++) { + var currentNode = bundle ? bundle.sourceFiles[i] : node; + var sourceFile = ts.isSourceFile(currentNode) ? currentNode : currentSourceFile; + var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldBundle = ts.isSourceFile(currentNode) && !isOwnFileEmit; + var helpers = ts.getEmitHelpers(currentNode); + if (helpers) { + for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { + var helper = _b[_a]; + if (!helper.scoped) { + // Skip the helper if it can be skipped and the noEmitHelpers compiler + // option is set, or if it can be imported and the importHelpers compiler + // option is set. + if (shouldSkip) + continue; + // Skip the helper if it can be bundled but hasn't already been emitted and we + // are emitting a bundled module. + if (shouldBundle) { + if (bundledHelpers.get(helper.name)) { + continue; + } + bundledHelpers.set(helper.name, true); + } + } + else if (bundle) { + // Skip the helper if it is scoped and we are emitting bundled helpers + continue; + } + writeLines(helper.text); + helpersEmitted = true; + } + } + } + return helpersEmitted; + } + } + ts.emitFiles = emitFiles; + function createPrinter(printerOptions, handlers) { + if (printerOptions === void 0) { printerOptions = {}; } + if (handlers === void 0) { handlers = {}; } + var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, onSubstituteNode = handlers.onSubstituteNode; + var newLine = ts.getNewLineCharacter(printerOptions); + var languageVersion = ts.getEmitScriptTarget(printerOptions); + var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); + var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; + var currentSourceFile; + var nodeIdToGeneratedName; // Map of generated names for specific nodes. + var autoGeneratedIdToGeneratedName; // Map of generated names for temp and loop variables. + var generatedNames; // Set of names generated by the NameGenerator. + var tempFlagsStack; // Stack of enclosing name generation scopes. + var tempFlags; // TempFlags for the current name generation scope. + var writer; + var ownWriter; + reset(); + return { + // public API + printNode: printNode, + printFile: printFile, + printBundle: printBundle, + // internal API + writeNode: writeNode, + writeFile: writeFile, + writeBundle: writeBundle + }; + function printNode(hint, node, sourceFile) { + switch (hint) { + case 0 /* SourceFile */: + ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); + break; + case 2 /* IdentifierName */: + ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); + break; + case 1 /* Expression */: + ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); + break; + } + switch (node.kind) { + case 264 /* SourceFile */: return printFile(node); + case 265 /* Bundle */: return printBundle(node); + } + writeNode(hint, node, sourceFile, beginPrint()); + return endPrint(); + } + function printBundle(bundle) { + writeBundle(bundle, beginPrint()); + return endPrint(); + } + function printFile(sourceFile) { + writeFile(sourceFile, beginPrint()); + return endPrint(); + } + function writeNode(hint, node, sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(hint, node, sourceFile); + reset(); + writer = previousWriter; + } + function writeBundle(bundle, output) { + var previousWriter = writer; + setWriter(output); + emitHelpersIndirect(bundle); + for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + print(0 /* SourceFile */, sourceFile, sourceFile); + } + reset(); + writer = previousWriter; + } + function writeFile(sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(0 /* SourceFile */, sourceFile, sourceFile); + reset(); + writer = previousWriter; + } + function beginPrint() { + return ownWriter || (ownWriter = ts.createTextWriter(newLine)); + } + function endPrint() { + var text = ownWriter.getText(); + ownWriter.reset(); + return text; + } + function print(hint, node, sourceFile) { + setSourceFile(sourceFile); + pipelineEmitWithNotification(hint, node); + } + function setSourceFile(sourceFile) { + currentSourceFile = sourceFile; + comments.setSourceFile(sourceFile); + if (onSetSourceFile) { + onSetSourceFile(sourceFile); + } + } + function setWriter(output) { + writer = output; + comments.setWriter(output); + } + function reset() { + nodeIdToGeneratedName = []; + autoGeneratedIdToGeneratedName = []; + generatedNames = ts.createMap(); + tempFlagsStack = []; + tempFlags = 0 /* Auto */; + comments.reset(); + setWriter(/*output*/ undefined); + } + function emit(node, hint) { + if (hint === void 0) { hint = 3 /* Unspecified */; } + pipelineEmitWithNotification(hint, node); } - /** - * Emits an IdentifierName. - */ function emitIdentifierName(node) { pipelineEmitWithNotification(2 /* IdentifierName */, node); } - /** - * Emits an expression node. - */ function emitExpression(node) { pipelineEmitWithNotification(1 /* Expression */, node); } - /** - * Emits a node with possible notification. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called from printSourceFile, emit, emitExpression, or - * emitIdentifierName. - */ - function pipelineEmitWithNotification(emitContext, node) { - emitNodeWithNotification(emitContext, node, pipelineEmitWithComments); + function pipelineEmitWithNotification(hint, node) { + if (onEmitNode) { + onEmitNode(hint, node, pipelineEmitWithComments); + } + else { + pipelineEmitWithComments(hint, node); + } } - /** - * Emits a node with comments. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithNotification. - */ - function pipelineEmitWithComments(emitContext, node) { - // Do not emit comments for SourceFile - if (emitContext === 0 /* SourceFile */) { - pipelineEmitWithSourceMap(emitContext, node); + function pipelineEmitWithComments(hint, node) { + if (emitNodeWithComments && hint !== 0 /* SourceFile */) { + emitNodeWithComments(hint, node, pipelineEmitWithSourceMap); + } + else { + pipelineEmitWithSourceMap(hint, node); + } + } + function pipelineEmitWithSourceMap(hint, node) { + if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */) { + onEmitSourceMapOfNode(hint, node, pipelineEmitWithSubstitution); + } + else { + pipelineEmitWithSubstitution(hint, node); + } + } + function pipelineEmitWithSubstitution(hint, node) { + if (onSubstituteNode) { + onSubstituteNode(hint, node, pipelineEmitWithHint); + } + else { + pipelineEmitWithHint(hint, node); + } + } + function pipelineEmitWithHint(hint, node) { + switch (hint) { + case 0 /* SourceFile */: return pipelineEmitSourceFile(node); + case 2 /* IdentifierName */: return pipelineEmitIdentifierName(node); + case 1 /* Expression */: return pipelineEmitExpression(node); + case 3 /* Unspecified */: return pipelineEmitUnspecified(node); + } + } + function pipelineEmitSourceFile(node) { + ts.Debug.assertNode(node, ts.isSourceFile); + emitSourceFile(node); + } + function pipelineEmitIdentifierName(node) { + ts.Debug.assertNode(node, ts.isIdentifier); + emitIdentifier(node); + } + function pipelineEmitUnspecified(node) { + var kind = node.kind; + // Reserved words + // Strict mode reserved words + // Contextual keywords + if (ts.isKeyword(kind)) { + writeTokenText(kind); return; } - emitNodeWithComments(emitContext, node, pipelineEmitWithSourceMap); - } - /** - * Emits a node with source maps. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithComments. - */ - function pipelineEmitWithSourceMap(emitContext, node) { - // Do not emit source mappings for SourceFile or IdentifierName - if (emitContext === 0 /* SourceFile */ - || emitContext === 2 /* IdentifierName */) { - pipelineEmitWithSubstitution(emitContext, node); - return; - } - emitNodeWithSourceMap(emitContext, node, pipelineEmitWithSubstitution); - } - /** - * Emits a node with possible substitution. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithSourceMap or - * pipelineEmitInUnspecifiedContext (when picking a more specific context). - */ - function pipelineEmitWithSubstitution(emitContext, node) { - emitNodeWithSubstitution(emitContext, node, pipelineEmitForContext); - } - /** - * Emits a node. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithSubstitution. - */ - function pipelineEmitForContext(emitContext, node) { - switch (emitContext) { - case 0 /* SourceFile */: return pipelineEmitInSourceFileContext(node); - case 2 /* IdentifierName */: return pipelineEmitInIdentifierNameContext(node); - case 3 /* Unspecified */: return pipelineEmitInUnspecifiedContext(node); - case 1 /* Expression */: return pipelineEmitInExpressionContext(node); - } - } - /** - * Emits a node in the SourceFile EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInSourceFileContext(node) { - var kind = node.kind; - switch (kind) { - // Top-level nodes - case 261 /* SourceFile */: - return emitSourceFile(node); - } - } - /** - * Emits a node in the IdentifierName EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInIdentifierNameContext(node) { - var kind = node.kind; - switch (kind) { - // Identifiers - case 70 /* Identifier */: - return emitIdentifier(node); - } - } - /** - * Emits a node in the Unspecified EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInUnspecifiedContext(node) { - var kind = node.kind; switch (kind) { // Pseudo-literals case 13 /* TemplateHead */: @@ -59870,239 +61975,204 @@ var ts; // Identifiers case 70 /* Identifier */: return emitIdentifier(node); - // Reserved words - case 75 /* ConstKeyword */: - case 78 /* DefaultKeyword */: - case 83 /* ExportKeyword */: - case 104 /* VoidKeyword */: - // Strict mode reserved words - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 113 /* PublicKeyword */: - case 114 /* StaticKeyword */: - // Contextual keywords - case 116 /* AbstractKeyword */: - case 117 /* AsKeyword */: - case 118 /* AnyKeyword */: - case 119 /* AsyncKeyword */: - case 120 /* AwaitKeyword */: - case 121 /* BooleanKeyword */: - case 122 /* ConstructorKeyword */: - case 123 /* DeclareKeyword */: - case 124 /* GetKeyword */: - case 125 /* IsKeyword */: - case 127 /* ModuleKeyword */: - case 128 /* NamespaceKeyword */: - case 129 /* NeverKeyword */: - case 130 /* ReadonlyKeyword */: - case 131 /* RequireKeyword */: - case 132 /* NumberKeyword */: - case 133 /* SetKeyword */: - case 134 /* StringKeyword */: - case 135 /* SymbolKeyword */: - case 136 /* TypeKeyword */: - case 137 /* UndefinedKeyword */: - case 138 /* FromKeyword */: - case 139 /* GlobalKeyword */: - case 140 /* OfKeyword */: - writeTokenText(kind); - return; // Parse tree nodes // Names - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: return emitQualifiedName(node); - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: return emitTypeParameter(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return emitParameter(node); - case 145 /* Decorator */: + case 146 /* Decorator */: return emitDecorator(node); // Type members - case 146 /* PropertySignature */: + case 147 /* PropertySignature */: return emitPropertySignature(node); - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 148 /* MethodSignature */: + case 149 /* MethodSignature */: return emitMethodSignature(node); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return emitConstructor(node); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return emitAccessorDeclaration(node); - case 153 /* CallSignature */: + case 154 /* CallSignature */: return emitCallSignature(node); - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: return emitConstructSignature(node); - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: return emitIndexSignature(node); // Types - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return emitTypePredicate(node); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return emitTypeReference(node); - case 158 /* FunctionType */: + case 159 /* FunctionType */: return emitFunctionType(node); - case 159 /* ConstructorType */: + case 160 /* ConstructorType */: return emitConstructorType(node); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return emitTypeQuery(node); - case 161 /* TypeLiteral */: + case 162 /* TypeLiteral */: return emitTypeLiteral(node); - case 162 /* ArrayType */: + case 163 /* ArrayType */: return emitArrayType(node); - case 163 /* TupleType */: + case 164 /* TupleType */: return emitTupleType(node); - case 164 /* UnionType */: + case 165 /* UnionType */: return emitUnionType(node); - case 165 /* IntersectionType */: + case 166 /* IntersectionType */: return emitIntersectionType(node); - case 166 /* ParenthesizedType */: + case 167 /* ParenthesizedType */: return emitParenthesizedType(node); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 167 /* ThisType */: + case 168 /* ThisType */: return emitThisType(); - case 168 /* TypeOperator */: + case 169 /* TypeOperator */: return emitTypeOperator(node); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 170 /* MappedType */: + case 171 /* MappedType */: return emitMappedType(node); - case 171 /* LiteralType */: + case 172 /* LiteralType */: return emitLiteralType(node); // Binding patterns - case 172 /* ObjectBindingPattern */: + case 173 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 173 /* ArrayBindingPattern */: + case 174 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 174 /* BindingElement */: + case 175 /* BindingElement */: return emitBindingElement(node); // Misc - case 202 /* TemplateSpan */: + case 204 /* TemplateSpan */: return emitTemplateSpan(node); - case 203 /* SemicolonClassElement */: + case 205 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 204 /* Block */: + case 206 /* Block */: return emitBlock(node); - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: return emitVariableStatement(node); - case 206 /* EmptyStatement */: + case 208 /* EmptyStatement */: return emitEmptyStatement(); - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return emitExpressionStatement(node); - case 208 /* IfStatement */: + case 210 /* IfStatement */: return emitIfStatement(node); - case 209 /* DoStatement */: + case 211 /* DoStatement */: return emitDoStatement(node); - case 210 /* WhileStatement */: + case 212 /* WhileStatement */: return emitWhileStatement(node); - case 211 /* ForStatement */: + case 213 /* ForStatement */: return emitForStatement(node); - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: return emitForInStatement(node); - case 213 /* ForOfStatement */: + case 215 /* ForOfStatement */: return emitForOfStatement(node); - case 214 /* ContinueStatement */: + case 216 /* ContinueStatement */: return emitContinueStatement(node); - case 215 /* BreakStatement */: + case 217 /* BreakStatement */: return emitBreakStatement(node); - case 216 /* ReturnStatement */: + case 218 /* ReturnStatement */: return emitReturnStatement(node); - case 217 /* WithStatement */: + case 219 /* WithStatement */: return emitWithStatement(node); - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: return emitSwitchStatement(node); - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return emitLabeledStatement(node); - case 220 /* ThrowStatement */: + case 222 /* ThrowStatement */: return emitThrowStatement(node); - case 221 /* TryStatement */: + case 223 /* TryStatement */: return emitTryStatement(node); - case 222 /* DebuggerStatement */: + case 224 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 224 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return emitClassDeclaration(node); - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 228 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 231 /* ModuleBlock */: + case 233 /* ModuleBlock */: return emitModuleBlock(node); - case 232 /* CaseBlock */: + case 234 /* CaseBlock */: return emitCaseBlock(node); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return emitImportDeclaration(node); - case 236 /* ImportClause */: + case 238 /* ImportClause */: return emitImportClause(node); - case 237 /* NamespaceImport */: + case 239 /* NamespaceImport */: return emitNamespaceImport(node); - case 238 /* NamedImports */: + case 240 /* NamedImports */: return emitNamedImports(node); - case 239 /* ImportSpecifier */: + case 241 /* ImportSpecifier */: return emitImportSpecifier(node); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return emitExportAssignment(node); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return emitExportDeclaration(node); - case 242 /* NamedExports */: + case 244 /* NamedExports */: return emitNamedExports(node); - case 243 /* ExportSpecifier */: + case 245 /* ExportSpecifier */: return emitExportSpecifier(node); - case 244 /* MissingDeclaration */: + case 246 /* MissingDeclaration */: return; // Module references - case 245 /* ExternalModuleReference */: + case 247 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 248 /* JsxOpeningElement */: + case 250 /* JsxOpeningElement */: return emitJsxOpeningElement(node); - case 249 /* JsxClosingElement */: + case 251 /* JsxClosingElement */: return emitJsxClosingElement(node); - case 250 /* JsxAttribute */: + case 252 /* JsxAttribute */: return emitJsxAttribute(node); - case 251 /* JsxSpreadAttribute */: + case 253 /* JsxAttributes */: + return emitJsxAttributes(node); + case 254 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 252 /* JsxExpression */: + case 255 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 253 /* CaseClause */: + case 256 /* CaseClause */: return emitCaseClause(node); - case 254 /* DefaultClause */: + case 257 /* DefaultClause */: return emitDefaultClause(node); - case 255 /* HeritageClause */: + case 258 /* HeritageClause */: return emitHeritageClause(node); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 257 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 258 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 259 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 260 /* EnumMember */: + case 263 /* EnumMember */: return emitEnumMember(node); } // If the node is an expression, try to emit it as an expression with @@ -60111,13 +62181,7 @@ var ts; return pipelineEmitWithSubstitution(1 /* Expression */, node); } } - /** - * Emits a node in the Expression EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInExpressionContext(node) { + function pipelineEmitExpression(node) { var kind = node.kind; switch (kind) { // Literals @@ -60139,68 +62203,81 @@ var ts; writeTokenText(kind); return; // Expressions - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return emitCallExpression(node); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return emitNewExpression(node); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 182 /* TypeAssertionExpression */: + case 183 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return emitFunctionExpression(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return emitArrowFunction(node); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return emitDeleteExpression(node); - case 187 /* TypeOfExpression */: + case 188 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return emitVoidExpression(node); - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: return emitAwaitExpression(node); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return emitBinaryExpression(node); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return emitConditionalExpression(node); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return emitTemplateExpression(node); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return emitYieldExpression(node); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return emitSpreadExpression(node); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return emitClassExpression(node); - case 198 /* OmittedExpression */: + case 199 /* OmittedExpression */: return; - case 200 /* AsExpression */: + case 201 /* AsExpression */: return emitAsExpression(node); - case 201 /* NonNullExpression */: + case 202 /* NonNullExpression */: return emitNonNullExpression(node); + case 203 /* MetaProperty */: + return emitMetaProperty(node); // JSX - case 246 /* JsxElement */: + case 248 /* JsxElement */: return emitJsxElement(node); - case 247 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); // Transformation nodes - case 294 /* PartiallyEmittedExpression */: + case 298 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 297 /* RawExpression */: - return writeLines(node.text); + } + } + function emitBodyIndirect(node, elements, emitCallback) { + if (emitBodyWithDetachedComments) { + emitBodyWithDetachedComments(node, elements, emitCallback); + } + else { + emitCallback(node); + } + } + function emitHelpersIndirect(node) { + if (onEmitHelpers) { + onEmitHelpers(node, writeLines); } } // @@ -60221,7 +62298,7 @@ var ts; // SyntaxKind.TemplateTail function emitLiteral(node) { var text = getLiteralTextOfNode(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) + if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } @@ -60320,7 +62397,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 151 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 152 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -60423,17 +62500,13 @@ var ts; write("{"); writeLine(); increaseIndent(); - if (node.readonlyToken) { - write("readonly "); - } + writeIfPresent(node.readonlyToken, "readonly "); write("["); emit(node.typeParameter.name); write(" in "); emit(node.typeParameter.constraint); write("]"); - if (node.questionToken) { - write("?"); - } + writeIfPresent(node.questionToken, "?"); write(": "); emit(node.type); write(";"); @@ -60511,7 +62584,7 @@ var ts; var indentAfterDot = false; if (!(ts.getEmitFlags(node) & 65536 /* NoIndentation */)) { var dotRangeStart = node.expression.end; - var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; + var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; var dotToken = { kind: 22 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); @@ -60528,9 +62601,11 @@ var ts; // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal function needsDotDotForPropertyAccess(expression) { if (expression.kind === 8 /* NumericLiteral */) { - // check if numeric literal was originally written with a dot + // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(22 /* DotToken */)) < 0; + return ts.getNumericLiteralFlags(text, /*hint*/ 15 /* All */) === 0 /* None */ + && !expression.isOctalLiteral + && text.indexOf(ts.tokenToString(22 /* DotToken */)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { // check if constant enum value is integer @@ -60538,7 +62613,7 @@ var ts; // isFinite handles cases when constantValue is undefined return isFinite(constantValue) && Math.floor(constantValue) === constantValue - && compilerOptions.removeComments; + && printerOptions.removeComments; } } function emitElementAccessExpression(node) { @@ -60564,11 +62639,9 @@ var ts; emitExpression(node.template); } function emitTypeAssertionExpression(node) { - if (node.type) { - write("<"); - emit(node.type); - write(">"); - } + write("<"); + emit(node.type); + write(">"); emitExpression(node.expression); } function emitParenthesizedExpression(node) { @@ -60627,7 +62700,7 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 190 /* PrefixUnaryExpression */ + return operand.kind === 191 /* PrefixUnaryExpression */ && ((node.operator === 36 /* PlusToken */ && (operand.operator === 36 /* PlusToken */ || operand.operator === 42 /* PlusPlusToken */)) || (node.operator === 37 /* MinusToken */ && (operand.operator === 37 /* MinusToken */ || operand.operator === 43 /* MinusMinusToken */))); } @@ -60693,6 +62766,11 @@ var ts; emitExpression(node.expression); write("!"); } + function emitMetaProperty(node) { + writeToken(node.keywordToken, node.pos); + write("."); + emit(node.name); + } // // Misc // @@ -60712,6 +62790,10 @@ var ts; else { writeToken(16 /* OpenBraceToken */, node.pos, /*contextNode*/ node); emitBlockStatements(node); + // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); writeToken(17 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); } } @@ -60741,27 +62823,27 @@ var ts; writeToken(18 /* OpenParenToken */, openParenPos, node); emitExpression(node.expression); writeToken(19 /* CloseParenToken */, node.expression.end, node); - emitEmbeddedStatement(node.thenStatement); + emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { - writeLine(); + writeLineOrSpace(node); writeToken(81 /* ElseKeyword */, node.thenStatement.end, node); - if (node.elseStatement.kind === 208 /* IfStatement */) { + if (node.elseStatement.kind === 210 /* IfStatement */) { write(" "); emit(node.elseStatement); } else { - emitEmbeddedStatement(node.elseStatement); + emitEmbeddedStatement(node, node.elseStatement); } } } function emitDoStatement(node) { write("do"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { write(" "); } else { - writeLine(); + writeLineOrSpace(node); } write("while ("); emitExpression(node.expression); @@ -60771,7 +62853,7 @@ var ts; write("while ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { var openParenPos = writeToken(87 /* ForKeyword */, node.pos); @@ -60783,7 +62865,7 @@ var ts; write(";"); emitExpressionWithPrefix(" ", node.incrementor); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { var openParenPos = writeToken(87 /* ForKeyword */, node.pos); @@ -60793,7 +62875,7 @@ var ts; write(" in "); emitExpression(node.expression); writeToken(19 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { var openParenPos = writeToken(87 /* ForKeyword */, node.pos); @@ -60803,11 +62885,11 @@ var ts; write(" of "); emitExpression(node.expression); writeToken(19 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 224 /* VariableDeclarationList */) { + if (node.kind === 226 /* VariableDeclarationList */) { emit(node); } else { @@ -60834,7 +62916,7 @@ var ts; write("with ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { var openParenPos = writeToken(97 /* SwitchKeyword */, node.pos); @@ -60858,9 +62940,12 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchClause); + if (node.catchClause) { + writeLineOrSpace(node); + emit(node.catchClause); + } if (node.finallyBlock) { - writeLine(); + writeLineOrSpace(node); write("finally "); emit(node.finallyBlock); } @@ -60904,11 +62989,10 @@ var ts; emitBlockFunctionBody(body); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); emitSignatureHead(node); emitBlockFunctionBody(body); - tempFlags = savedTempFlags; + popNameGenerationScope(); } if (indentedFlag) { decreaseIndent(); @@ -60963,9 +63047,10 @@ var ts; function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) + var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine - : emitBlockFunctionBodyWorker); + : emitBlockFunctionBodyWorker; + emitBodyIndirect(body, body.statements, emitBlockFunctionBody); decreaseIndent(); writeToken(17 /* CloseBraceToken */, body.statements.end, body); } @@ -60975,8 +63060,9 @@ var ts; function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) { // Emit all the prologue directives (like "use strict"). var statementOffset = emitPrologueDirectives(body.statements, /*startWithNewLine*/ true); - var helpersEmitted = emitHelpers(body); - if (statementOffset === 0 && !helpersEmitted && emitBlockFunctionBodyOnSingleLine) { + var pos = writer.getTextPos(); + emitHelpersIndirect(body); + if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); emitList(body, body.statements, 384 /* SingleLineFunctionBodyStatements */); increaseIndent(); @@ -60999,15 +63085,14 @@ var ts; } emitTypeParameters(node, node.typeParameters); emitList(node, node.heritageClauses, 256 /* ClassHeritageClauses */); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 65 /* ClassMembers */); write("}"); + popNameGenerationScope(); if (indentedFlag) { decreaseIndent(); } - tempFlags = savedTempFlags; } function emitInterfaceDeclaration(node) { emitDecorators(node, node.decorators); @@ -61034,19 +63119,18 @@ var ts; emitModifiers(node, node.modifiers); write("enum "); emit(node.name); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 81 /* EnumMembers */); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 230 /* ModuleDeclaration */) { + while (body.kind === 232 /* ModuleDeclaration */) { write("."); emit(body.name); body = body.body; @@ -61059,13 +63143,12 @@ var ts; write("{ }"); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write("{"); increaseIndent(); emitBlockStatements(node); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } } function emitCaseBlock(node) { @@ -61173,14 +63256,20 @@ var ts; write("<"); emitJsxTagName(node.tagName); write(" "); - emitList(node, node.attributes, 131328 /* JsxElementAttributes */); + // We are checking here so we won't re-enter the emiting pipeline and emit extra sourcemap + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write("/>"); } function emitJsxOpeningElement(node) { write("<"); emitJsxTagName(node.tagName); - writeIfAny(node.attributes, " "); - emitList(node, node.attributes, 131328 /* JsxElementAttributes */); + writeIfAny(node.attributes.properties, " "); + // We are checking here so we won't re-enter the emitting pipeline and emit extra sourcemap + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write(">"); } function emitJsxText(node) { @@ -61191,6 +63280,9 @@ var ts; emitJsxTagName(node.tagName); write(">"); } + function emitJsxAttributes(node) { + emitList(node, node.properties, 131328 /* JsxElementAttributes */); + } function emitJsxAttribute(node) { emit(node.name); emitWithPrefix("=", node.initializer); @@ -61203,6 +63295,9 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); + if (node.dotDotDotToken) { + write("..."); + } emitExpression(node.expression); write("}"); } @@ -61250,7 +63345,6 @@ var ts; emitList(node, node.types, 272 /* HeritageClauseTypes */); } function emitCatchClause(node) { - writeLine(); var openParenPos = writeToken(73 /* CatchKeyword */, node.pos); write(" "); writeToken(18 /* OpenParenToken */, openParenPos); @@ -61273,7 +63367,7 @@ var ts; // "comment1" is not considered to be leading comment for node.initializer // but rather a trailing comment on the previous node. var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) { + if (emitTrailingCommentsOfPosition && (ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -61305,16 +63399,15 @@ var ts; function emitSourceFile(node) { writeLine(); emitShebang(); - emitBodyWithDetachedComments(node, node.statements, emitSourceFileWorker); + emitBodyIndirect(node, node.statements, emitSourceFileWorker); } function emitSourceFileWorker(node) { var statements = node.statements; var statementOffset = emitPrologueDirectives(statements); - var savedTempFlags = tempFlags; - tempFlags = 0; - emitHelpers(node); + pushNameGenerationScope(); + emitHelpersIndirect(node); emitList(node, statements, 1 /* MultiLine */, statementOffset); - tempFlags = savedTempFlags; + popNameGenerationScope(); } // Transformation nodes function emitPartiallyEmittedExpression(node) { @@ -61339,76 +63432,11 @@ var ts; } return statements.length; } - function emitHelpers(node, isBundle) { - var sourceFile = ts.isSourceFile(node) ? node : currentSourceFile; - var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); - var shouldBundle = ts.isSourceFile(node) && !isOwnFileEmit; - var helpersEmitted = false; - var helpers = ts.getEmitHelpers(node); - if (helpers) { - for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { - var helper = _b[_a]; - if (!helper.scoped) { - // Skip the helper if it can be skipped and the noEmitHelpers compiler - // option is set, or if it can be imported and the importHelpers compiler - // option is set. - if (shouldSkip) - continue; - // Skip the helper if it can be bundled but hasn't already been emitted and we - // are emitting a bundled module. - if (shouldBundle) { - if (bundledHelpers[helper.name]) { - continue; - } - bundledHelpers[helper.name] = true; - } - } - else if (isBundle) { - // Skip the helper if it is scoped and we are emitting bundled helpers - continue; - } - writeLines(helper.text); - helpersEmitted = true; - } - } - if (helpersEmitted) { - writeLine(); - } - return helpersEmitted; - } - function writeLines(text) { - var lines = text.split(/\r\n?|\n/g); - var indentation = guessIndentation(lines); - for (var i = 0; i < lines.length; i++) { - var line = indentation ? lines[i].slice(indentation) : lines[i]; - if (line.length) { - if (i > 0) { - writeLine(); - } - write(line); - } - } - } - function guessIndentation(lines) { - var indentation; - for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { - var line = lines_1[_a]; - for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { - if (!ts.isWhiteSpace(line.charCodeAt(i))) { - if (indentation === undefined || i < indentation) { - indentation = i; - break; - } - } - } - } - return indentation; - } // // Helpers // function emitShebang() { - var shebang = ts.getShebang(currentText); + var shebang = ts.getShebang(currentSourceFile.text); if (shebang) { write(shebang); writeLine(); @@ -61438,8 +63466,8 @@ var ts; write(suffix); } } - function emitEmbeddedStatement(node) { - if (ts.isBlock(node)) { + function emitEmbeddedStatement(parent, node) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* SingleLine */) { write(" "); emit(node); } @@ -61528,6 +63556,15 @@ var ts; var child = children[start + i]; // Write the delimiter if this is not the first node. if (previousSibling) { + // i.e + // function commentedParameters( + // /* Parameter a */ + // a + // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline + // , + if (delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } write(delimiter); // Write either a line terminator or whitespace to separate the elements. if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { @@ -61544,14 +63581,16 @@ var ts; write(" "); } } + // Emit this child. if (shouldEmitInterveningComments) { - var commentRange = ts.getCommentRange(child); - emitTrailingCommentsOfPosition(commentRange.pos); + if (emitTrailingCommentsOfPosition) { + var commentRange = ts.getCommentRange(child); + emitTrailingCommentsOfPosition(commentRange.pos); + } } else { shouldEmitInterveningComments = mayEmitInterveningComments; } - // Emit this child. emit(child); if (shouldDecreaseIndentAfterEmit) { decreaseIndent(); @@ -61564,6 +63603,15 @@ var ts; if (format & 16 /* CommaDelimited */ && hasTrailingComma) { write(","); } + // Emit any trailing comment of the last element in the list + // i.e + // var array = [... + // 2 + // /* end of element 2 */ + // ]; + if (previousSibling && delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } // Decrease the indent, if requested. if (format & 64 /* Indented */) { decreaseIndent(); @@ -61580,24 +63628,73 @@ var ts; write(getClosingBracket(format)); } } + function write(s) { + writer.write(s); + } + function writeLine() { + writer.writeLine(); + } + function increaseIndent() { + writer.increaseIndent(); + } + function decreaseIndent() { + writer.decreaseIndent(); + } function writeIfAny(nodes, text) { - if (nodes && nodes.length > 0) { + if (ts.some(nodes)) { write(text); } } function writeIfPresent(node, text) { - if (node !== undefined) { + if (node) { write(text); } } function writeToken(token, pos, contextNode) { - return emitTokenWithSourceMap(contextNode, token, pos, writeTokenText); + return onEmitSourceMapOfToken + ? onEmitSourceMapOfToken(contextNode, token, pos, writeTokenText) + : writeTokenText(token, pos); } function writeTokenText(token, pos) { var tokenString = ts.tokenToString(token); write(tokenString); return pos < 0 ? pos : pos + tokenString.length; } + function writeLineOrSpace(node) { + if (ts.getEmitFlags(node) & 1 /* SingleLine */) { + write(" "); + } + else { + writeLine(); + } + } + function writeLines(text) { + var lines = text.split(/\r\n?|\n/g); + var indentation = guessIndentation(lines); + for (var i = 0; i < lines.length; i++) { + var line = indentation ? lines[i].slice(indentation) : lines[i]; + if (line.length) { + writeLine(); + write(line); + writeLine(); + } + } + } + function guessIndentation(lines) { + var indentation; + for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { + var line = lines_1[_a]; + for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { + if (!ts.isWhiteSpace(line.charCodeAt(i))) { + if (indentation === undefined || i < indentation) { + indentation = i; + break; + } + } + } + } + return indentation; + } function increaseIndentIf(value, valueToWriteWhenNotIndenting) { if (value) { increaseIndent(); @@ -61707,15 +63804,23 @@ var ts; && !ts.nodeIsSynthesized(node2) && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } + function isSingleLineEmptyBlock(block) { + return !block.multiLine + && isEmptyBlock(block); + } + function isEmptyBlock(block) { + return block.statements.length === 0 + && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + } function skipSynthesizedParentheses(node) { - while (node.kind === 183 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 184 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; } function getTextOfNode(node, includeTrivia) { if (ts.isGeneratedIdentifier(node)) { - return getGeneratedIdentifier(node); + return generateName(node); } else if (ts.isIdentifier(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { return ts.unescapeIdentifier(node.text); @@ -61740,24 +63845,58 @@ var ts; } return ts.getLiteralText(node, currentSourceFile, languageVersion); } - function isSingleLineEmptyBlock(block) { - return !block.multiLine - && isEmptyBlock(block); + /** + * Push a new name generation scope. + */ + function pushNameGenerationScope() { + tempFlagsStack.push(tempFlags); + tempFlags = 0; } - function isEmptyBlock(block) { - return block.statements.length === 0 - && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + /** + * Pop the current name generation scope. + */ + function popNameGenerationScope() { + tempFlags = tempFlagsStack.pop(); } + /** + * Generate the text for a generated identifier. + */ + function generateName(name) { + if (name.autoGenerateKind === 4 /* Node */) { + // Node names generate unique names based on their original node + // and are cached based on that node's id. + var node = getNodeForGeneratedName(name); + return generateNameCached(node); + } + else { + // Auto, Loop, and Unique names are cached based on their unique + // autoGenerateId. + var autoGenerateId = name.autoGenerateId; + return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(makeName(name))); + } + } + function generateNameCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + } + /** + * Returns a value indicating whether a name is unique globally, within the current file, + * or within the NameGenerator. + */ function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentFileIdentifiers, name) && - !ts.hasProperty(generatedNameSet, name); + return !(hasGlobalName && hasGlobalName(name)) + && !currentSourceFile.identifiers.has(name) + && !generatedNames.has(name); } + /** + * Returns a value indicating whether a name is unique within a container. + */ function isUniqueLocalName(name, container) { for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { + if (node.locals) { + var local = node.locals.get(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 */)) { + if (local && local.flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { return false; } } @@ -61765,16 +63904,16 @@ var ts; return true; } /** - * 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. - */ + * 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_40 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_40)) { + var name = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name)) { tempFlags |= flags; - return name_40; + return name; } } while (true) { @@ -61782,19 +63921,21 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_41 = count < 26 + var name = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_41)) { - return name_41; + if (isUniqueName(name)) { + return name; } } } } - // Generate a name that is unique within the current file and doesn't conflict with any names - // in global scope. The name is formed by adding an '_n' suffix to the specified base name, - // where n is a positive integer. Note that names generated by makeTempVariableName and - // makeUniqueName are guaranteed to never conflict. + /** + * 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 /* _ */) { @@ -61804,73 +63945,90 @@ var ts; while (true) { var generatedName = baseName + i; if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; + generatedNames.set(generatedName, generatedName); + return generatedName; } i++; } } + /** + * Generates a unique name for a ModuleDeclaration or EnumDeclaration. + */ function generateNameForModuleOrEnum(node) { var name = getTextOfNode(node.name); // Use module/enum name itself if it is unique, otherwise make a unique variation return isUniqueLocalName(name, node) ? name : makeUniqueName(name); } + /** + * Generates a unique name for an ImportDeclaration or ExportDeclaration. + */ function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); var baseName = expr.kind === 9 /* StringLiteral */ ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; return makeUniqueName(baseName); } + /** + * Generates a unique name for a default export. + */ function generateNameForExportDefault() { return makeUniqueName("default"); } + /** + * Generates a unique name for a class expression. + */ function generateNameForClassExpression() { return makeUniqueName("class"); } + function generateNameForMethodOrAccessor(node) { + if (ts.isIdentifier(node.name)) { + return generateNameCached(node.name); + } + return makeTempVariableName(0 /* Auto */); + } /** * Generates a unique name from a node. - * - * @param node A node. */ function generateNameForNode(node) { switch (node.kind) { case 70 /* Identifier */: return makeUniqueName(getTextOfNode(node)); - case 230 /* ModuleDeclaration */: - case 229 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: + case 231 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 235 /* ImportDeclaration */: - case 241 /* ExportDeclaration */: + case 237 /* ImportDeclaration */: + case 243 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 225 /* FunctionDeclaration */: - case 226 /* ClassDeclaration */: - case 240 /* ExportAssignment */: + case 227 /* FunctionDeclaration */: + case 228 /* ClassDeclaration */: + case 242 /* ExportAssignment */: return generateNameForExportDefault(); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return generateNameForClassExpression(); + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0 /* Auto */); } } /** * Generates a unique identifier for a node. - * - * @param name A generated name. */ - function generateName(name) { + function makeName(name) { switch (name.autoGenerateKind) { case 1 /* Auto */: return makeTempVariableName(0 /* Auto */); case 2 /* Loop */: return makeTempVariableName(268435456 /* _i */); case 3 /* Unique */: - return makeUniqueName(name.text); + return makeUniqueName(ts.unescapeIdentifier(name.text)); } ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } /** * Gets the node from which a name should be generated. - * - * @param name A generated name wrapper. */ function getNodeForGeneratedName(name) { var autoGenerateId = name.autoGenerateId; @@ -61890,53 +64048,40 @@ var ts; // otherwise, return the original node for the source; return node; } - /** - * Gets the generated identifier text from a generated identifier. - * - * @param name The generated identifier. - */ - function getGeneratedIdentifier(name) { - if (name.autoGenerateKind === 4 /* Node */) { - // Generated names generate unique names based on their original node - // and are cached based on that node's id - var node = getNodeForGeneratedName(name); - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); - } - else { - // Auto, Loop, and Unique names are cached based on their unique - // autoGenerateId. - var autoGenerateId = name.autoGenerateId; - return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(generateName(name))); - } - } - function createDelimiterMap() { - var delimiters = []; - delimiters[0 /* None */] = ""; - delimiters[16 /* CommaDelimited */] = ","; - delimiters[4 /* BarDelimited */] = " |"; - delimiters[8 /* AmpersandDelimited */] = " &"; - return delimiters; - } - function getDelimiter(format) { - return delimiters[format & 28 /* DelimitersMask */]; - } - function createBracketsMap() { - var brackets = []; - brackets[512 /* Braces */] = ["{", "}"]; - brackets[1024 /* Parenthesis */] = ["(", ")"]; - brackets[2048 /* AngleBrackets */] = ["<", ">"]; - brackets[4096 /* SquareBrackets */] = ["[", "]"]; - return brackets; - } - function getOpeningBracket(format) { - return brackets[format & 7680 /* BracketsMask */][0]; - } - function getClosingBracket(format) { - return brackets[format & 7680 /* BracketsMask */][1]; - } } - ts.emitFiles = emitFiles; + ts.createPrinter = createPrinter; + function createDelimiterMap() { + var delimiters = []; + delimiters[0 /* None */] = ""; + delimiters[16 /* CommaDelimited */] = ","; + delimiters[4 /* BarDelimited */] = " |"; + delimiters[8 /* AmpersandDelimited */] = " &"; + return delimiters; + } + function getDelimiter(format) { + return delimiters[format & 28 /* DelimitersMask */]; + } + function createBracketsMap() { + var brackets = []; + brackets[512 /* Braces */] = ["{", "}"]; + brackets[1024 /* Parenthesis */] = ["(", ")"]; + brackets[2048 /* AngleBrackets */] = ["<", ">"]; + brackets[4096 /* SquareBrackets */] = ["[", "]"]; + return brackets; + } + function getOpeningBracket(format) { + return brackets[format & 7680 /* BracketsMask */][0]; + } + function getClosingBracket(format) { + return brackets[format & 7680 /* BracketsMask */][1]; + } + // 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 = {})); var ListFormat; (function (ListFormat) { ListFormat[ListFormat["None"] = 0] = "None"; @@ -62046,7 +64191,8 @@ var ts; commonPathComponents = sourcePathComponents; return; } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + var n = Math.min(commonPathComponents.length, sourcePathComponents.length); + for (var i = 0; i < n; i++) { if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { if (i === 0) { // Failed to find any common path component @@ -62100,11 +64246,11 @@ var ts; return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; } function directoryExists(directoryPath) { - if (directoryPath in existingDirectories) { + if (existingDirectories.has(directoryPath)) { return true; } if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; + existingDirectories.set(directoryPath, true); return true; } return false; @@ -62123,10 +64269,11 @@ var ts; } var hash = ts.sys.createHash(data); var mtimeBefore = ts.sys.getModifiedTime(fileName); - if (mtimeBefore && fileName in outputFingerprints) { - var fingerprint = outputFingerprints[fileName]; + if (mtimeBefore) { + var fingerprint = outputFingerprints.get(fileName); // If output has not been changed, and the file has no external modification - if (fingerprint.byteOrderMark === writeByteOrderMark && + if (fingerprint && + fingerprint.byteOrderMark === writeByteOrderMark && fingerprint.hash === hash && fingerprint.mtime.getTime() === mtimeBefore.getTime()) { return; @@ -62134,11 +64281,11 @@ var ts; } ts.sys.writeFile(fileName, data, writeByteOrderMark); var mtimeAfter = ts.sys.getModifiedTime(fileName); - outputFingerprints[fileName] = { + outputFingerprints.set(fileName, { hash: hash, byteOrderMark: writeByteOrderMark, mtime: mtimeAfter - }; + }); } function writeFile(fileName, data, writeByteOrderMark, onError) { try { @@ -62237,10 +64384,14 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_42 = names_1[_i]; - var result = name_42 in cache - ? cache[name_42] - : cache[name_42] = loader(name_42, containingFile); + var name = names_1[_i]; + var result = void 0; + if (cache.has(name)) { + result = cache.get(name); + } + else { + cache.set(name, result = loader(name, containingFile)); + } resolutions.push(result); } return resolutions; @@ -62276,6 +64427,7 @@ var ts; var supportedExtensions = ts.getSupportedExtensions(options); // Map storing if there is emit blocking diagnostics for given input var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); + var moduleResolutionCache; var resolveModuleNamesWorker; if (host.resolveModuleNames) { resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { @@ -62289,7 +64441,8 @@ var ts; }); }; } else { - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -62335,6 +64488,8 @@ var ts; } } } + // unconditionally set moduleResolutionCache to undefined to avoid unnecessary leaks + moduleResolutionCache = undefined; // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; program = { @@ -62369,7 +64524,7 @@ var ts; return program; function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filterSourceFilesInDirectory(files, isSourceFileFromExternalLibrary); + var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified and is valid use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -62393,7 +64548,7 @@ var ts; classifiableNames = ts.createMap(); for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { var sourceFile = files_2[_i]; - ts.copyProperties(sourceFile.classifiableNames, classifiableNames); + ts.copyEntries(sourceFile.classifiableNames, classifiableNames); } } return classifiableNames; @@ -62600,7 +64755,7 @@ var ts; newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } // update fileName -> file mapping - for (var i = 0, len = newSourceFiles.length; i < len; i++) { + for (var i = 0; i < newSourceFiles.length; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; @@ -62629,7 +64784,7 @@ var ts; }; } function isSourceFileFromExternalLibrary(file) { - return sourceFilesFoundSearchingNodeModules[file.path]; + return sourceFilesFoundSearchingNodeModules.get(file.path); } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); @@ -62774,23 +64929,23 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 144 /* Parameter */: - case 147 /* PropertyDeclaration */: + case 145 /* Parameter */: + case 148 /* PropertyDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // Pass through - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: - case 223 /* VariableDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 225 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -62798,35 +64953,35 @@ var ts; } } switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 255 /* HeritageClause */: + case 258 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 107 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 228 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 182 /* TypeAssertionExpression */: + case 183 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; @@ -62841,29 +64996,29 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 226 /* ClassDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 228 /* ClassDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // pass through - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 205 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 207 /* VariableStatement */); } break; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { @@ -62875,16 +65030,16 @@ var ts; return; } break; - case 144 /* Parameter */: + case 145 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 199 /* ExpressionWithTypeArguments */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 200 /* ExpressionWithTypeArguments */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -62981,11 +65136,10 @@ var ts; && (options.isolatedModules || isExternalModuleFile) && !file.isDeclarationFile) { // synthesize 'import "tslib"' declaration - var externalHelpersModuleReference = ts.createSynthesizedNode(9 /* StringLiteral */); - externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(235 /* ImportDeclaration */); - importDecl.parent = file; + var externalHelpersModuleReference = ts.createLiteral(ts.externalHelpersModuleNameText); + var importDecl = ts.createImportDeclaration(undefined, undefined, undefined); externalHelpersModuleReference.parent = importDecl; + importDecl.parent = file; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -63001,9 +65155,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 235 /* ImportDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 241 /* ExportDeclaration */: + case 237 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 243 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -63018,7 +65172,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2 /* Ambient */) || ts.isDeclarationFile(file))) { var moduleName = node.name; // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -63118,18 +65272,18 @@ var ts; } // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { - sourceFilesFoundSearchingNodeModules[file_1.path] = false; + if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth == 0) { + sourceFilesFoundSearchingNodeModules.set(file_1.path, false); if (!options.noResolve) { processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } - else if (file_1 && modulesWithElidedImports[file_1.path]) { + else if (file_1 && modulesWithElidedImports.get(file_1.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } } @@ -63146,7 +65300,7 @@ var ts; }); filesByName.set(path, file); if (file) { - sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0); + sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; if (host.useCaseSensitiveFileNames()) { // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case @@ -63195,7 +65349,7 @@ var ts; } function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { // If we already found this library as a primary reference - nothing to do - var previousResolution = resolvedTypeReferenceDirectives[typeReferenceDirective]; + var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { return; } @@ -63229,7 +65383,7 @@ var ts; fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { - resolvedTypeReferenceDirectives[typeReferenceDirective] = resolvedTypeReferenceDirective; + resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); } } function createDiagnostic(refFile, refPos, refEnd, message) { @@ -63278,7 +65432,7 @@ var ts; // This may still end up being an untyped module -- the file won't be included but imports will be allowed. var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { - modulesWithElidedImports[file.path] = true; + modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = ts.toPath(resolvedFileName, currentDirectory, getCanonicalFileName); @@ -63297,8 +65451,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var file = sourceFiles_6[_i]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var file = sourceFiles_3[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -63309,8 +65463,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -63469,7 +65623,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { + ts.forEachEmittedFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -63601,12 +65755,13 @@ var ts; }, { name: "jsx", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "preserve": 1 /* Preserve */, + "react-native": 3 /* ReactNative */, "react": 2 /* React */ }), paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, }, { name: "reactNamespace", @@ -63636,7 +65791,7 @@ var ts; { name: "module", shortName: "m", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "none": ts.ModuleKind.None, "commonjs": ts.ModuleKind.CommonJS, "amd": ts.ModuleKind.AMD, @@ -63650,7 +65805,7 @@ var ts; }, { name: "newLine", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "crlf": 0 /* CarriageReturnLineFeed */, "lf": 1 /* LineFeed */ }), @@ -63748,8 +65903,8 @@ var ts; shortName: "p", type: "string", isFilePath: true, - description: ts.Diagnostics.Compile_the_project_in_the_given_directory, - paramType: ts.Diagnostics.DIRECTORY + description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY }, { name: "removeComments", @@ -63799,7 +65954,7 @@ var ts; { name: "target", shortName: "t", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "es3": 0 /* ES3 */, "es5": 1 /* ES5 */, "es6": 2 /* ES2015 */, @@ -63836,7 +65991,7 @@ var ts; }, { name: "moduleResolution", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "node": ts.ModuleResolutionKind.NodeJs, "classic": ts.ModuleResolutionKind.Classic, }), @@ -63945,7 +66100,7 @@ var ts; type: "list", element: { name: "lib", - type: ts.createMap({ + type: ts.createMapFromTemplate({ // JavaScript only "es5": "lib.es5.d.ts", "es6": "lib.es2015.d.ts", @@ -63994,6 +66149,16 @@ var ts; name: "alwaysStrict", type: "boolean", description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + }, + { + // A list of plugins to load in the language service + name: "plugins", + type: "list", + isTSConfigOnly: true, + element: { + name: "plugin", + type: "object" + } } ]; /* @internal */ @@ -64056,9 +66221,9 @@ var ts; var optionNameMap = ts.createMap(); var shortOptionNames = ts.createMap(); ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; + optionNameMap.set(option.name.toLowerCase(), option); if (option.shortName) { - shortOptionNames[option.shortName] = option.name; + shortOptionNames.set(option.shortName, option.name); } }); optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; @@ -64067,7 +66232,7 @@ var ts; ts.getOptionNameMap = getOptionNameMap; /* @internal */ function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; @@ -64119,11 +66284,12 @@ var ts; 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 (s in shortOptionNames) { - s = shortOptionNames[s]; + var short = shortOptionNames.get(s); + if (short !== undefined) { + s = short; } - if (s in optionNameMap) { - var opt = optionNameMap[s]; + var opt = optionNameMap.get(s); + if (opt) { if (opt.isTSConfigOnly) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); } @@ -64271,21 +66437,20 @@ var ts; } function getNameOfCompilerOptionValue(value, customTypeMap) { // There is a typeMap associated with this command-line option so use it to map value back to its name - for (var key in customTypeMap) { - if (customTypeMap[key] === value) { + return ts.forEachEntry(customTypeMap, function (mapValue, key) { + if (mapValue === value) { return key; } - } - return undefined; + }); } function serializeCompilerOptions(options) { - var result = ts.createMap(); + var result = {}; var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_43 in options) { - if (ts.hasProperty(options, name_43)) { + for (var name in options) { + if (ts.hasProperty(options, name)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - switch (name_43) { + switch (name) { case "init": case "watch": case "version": @@ -64293,14 +66458,14 @@ var ts; case "project": break; default: - var value = options[name_43]; - var optionDefinition = optionsNameMap[name_43.toLowerCase()]; + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { // There is no map associated with this compiler option then use the value as-is // This is the case if the value is expect to be string, number, boolean or list of string - result[name_43] = value; + result[name] = value; } else { if (optionDefinition.type === "list") { @@ -64309,11 +66474,11 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_43] = convertedValue; + result[name] = convertedValue; } else { // There is a typeMap associated with this command-line option so use it to map value back to its name - result[name_43] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -64361,6 +66526,7 @@ var ts; if (resolutionStack === void 0) { resolutionStack = []; } if (extraFileExtensions === void 0) { extraFileExtensions = []; } var errors = []; + basePath = ts.normalizeSlashes(basePath); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -64538,8 +66704,8 @@ var ts; } var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); for (var id in jsonOptions) { - if (id in optionNameMap) { - var opt = optionNameMap[id]; + var opt = optionNameMap.get(id); + if (opt) { defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); } else { @@ -64573,8 +66739,9 @@ var ts; } function convertJsonOptionOfCustomType(opt, value, errors) { var key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; + var val = opt.type.get(key); + if (val !== undefined) { + return val; } else { errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); @@ -64698,7 +66865,7 @@ var ts; for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { var fileName = fileNames_1[_i]; var file = ts.combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; + literalFileMap.set(keyMapper(file), file); } } if (include && include.length > 0) { @@ -64719,14 +66886,13 @@ var ts; // same directory, we should remove it. removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); var key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; + if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) { + wildcardFileMap.set(key, file); } } } - var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); - var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); + var literalFiles = ts.arrayFrom(literalFileMap.values()); + var wildcardFiles = ts.arrayFrom(wildcardFileMap.values()); return { fileNames: literalFiles.concat(wildcardFiles), wildcardDirectories: wildcardDirectories @@ -64734,8 +66900,8 @@ var ts; } function validateSpecs(specs, errors, allowTrailingRecursion) { var validSpecs = []; - for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { - var spec = specs_2[_i]; + for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { + var spec = specs_1[_i]; if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); } @@ -64769,7 +66935,7 @@ var ts; // /a/b/a?z - Watch /a/b directly to catch any new file matching a?z var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - var wildcardDirectories = ts.createMap(); + var wildcardDirectories = {}; if (include !== undefined) { var recursiveKeys = []; for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { @@ -64791,14 +66957,16 @@ var ts; } } // Remove any subpaths under an existing recursively watched directory. - for (var key in wildcardDirectories) { - for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { - var recursiveKey = recursiveKeys_1[_a]; - if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; + for (var key in wildcardDirectories) + if (ts.hasProperty(wildcardDirectories, key)) { + for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { + var recursiveKey = recursiveKeys_1[_a]; + if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; + } } } - } + ; } return wildcardDirectories; } @@ -64825,11 +66993,11 @@ var ts; */ function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); + var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions); for (var i = 0 /* Highest */; i < adjustedExtensionPriority; i++) { var higherPriorityExtension = extensions[i]; var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { return true; } } @@ -64845,23 +67013,13 @@ var ts; */ function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); + var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions); for (var i = nextExtensionPriority; i < extensions.length; i++) { var lowerPriorityExtension = extensions[i]; var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; + wildcardFiles.delete(lowerPriorityPath); } } - /** - * Adds a file to an array of files. - * - * @param output The output array. - * @param file The file path. - */ - function addFileToOutput(output, file) { - output.push(file); - return output; - } /** * Gets a case sensitive key. * @@ -65044,6 +67202,10 @@ var ts; ScriptElementKind.letElement = "let"; ScriptElementKind.directory = "directory"; ScriptElementKind.externalModuleName = "external module name"; + /** + * + **/ + ScriptElementKind.jsxAttribute = "JSX attribute"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; (function (ScriptElementKindModifier) { @@ -65129,33 +67291,34 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 144 /* Parameter */: - case 223 /* VariableDeclaration */: - case 174 /* BindingElement */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: - case 260 /* EnumMember */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 256 /* CatchClause */: + case 145 /* Parameter */: + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 260 /* PropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: + case 263 /* EnumMember */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 259 /* CatchClause */: + case 252 /* JsxAttribute */: return 1 /* Value */; - case 143 /* TypeParameter */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 161 /* TypeLiteral */: + case 144 /* TypeParameter */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 162 /* TypeLiteral */: return 2 /* Type */; - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -65165,22 +67328,25 @@ var ts; else { return 4 /* Namespace */; } - case 238 /* NamedImports */: - case 239 /* ImportSpecifier */: - case 234 /* ImportEqualsDeclaration */: - case 235 /* ImportDeclaration */: - case 240 /* ExportAssignment */: - case 241 /* ExportDeclaration */: + case 240 /* NamedImports */: + case 241 /* ImportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportDeclaration */: + case 242 /* ExportAssignment */: + case 243 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 261 /* SourceFile */: + case 264 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 240 /* ExportAssignment */) { + if (node.kind === 264 /* SourceFile */) { + return 1 /* Value */; + } + else if (node.parent.kind === 242 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -65205,15 +67371,15 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 141 /* QualifiedName */ && + if (node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 234 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 236 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function isInRightSideOfImport(node) { - while (node.parent.kind === 141 /* QualifiedName */) { + while (node.parent.kind === 142 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -65224,27 +67390,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 141 /* QualifiedName */) { - while (root.parent && root.parent.kind === 141 /* QualifiedName */) { + if (root.parent.kind === 142 /* QualifiedName */) { + while (root.parent && root.parent.kind === 142 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 157 /* TypeReference */ && !isLastClause; + return root.parent.kind === 158 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 177 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 177 /* PropertyAccessExpression */) { + if (root.parent.kind === 178 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 178 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 199 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 255 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 200 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 258 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 226 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || - (decl.kind === 227 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); + return (decl.kind === 228 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || + (decl.kind === 229 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); } return false; } @@ -65252,17 +67418,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 157 /* TypeReference */ || - (node.parent.kind === 199 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + return node.parent.kind === 158 /* TypeReference */ || + (node.parent.kind === 200 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || (node.kind === 98 /* ThisKeyword */ && !ts.isPartOfExpression(node)) || - node.kind === 167 /* ThisType */; + node.kind === 168 /* ThisType */; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 179 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 180 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 180 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 181 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -65275,7 +67441,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 219 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 221 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -65285,13 +67451,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 /* Identifier */ && - (node.parent.kind === 215 /* BreakStatement */ || node.parent.kind === 214 /* ContinueStatement */) && + (node.parent.kind === 217 /* BreakStatement */ || node.parent.kind === 216 /* ContinueStatement */) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 /* Identifier */ && - node.parent.kind === 219 /* LabeledStatement */ && + node.parent.kind === 221 /* LabeledStatement */ && node.parent.label === node; } function isLabelName(node) { @@ -65299,15 +67465,15 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 177 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 230 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 232 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -65318,19 +67484,19 @@ var ts; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 257 /* PropertyAssignment */: - case 260 /* EnumMember */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 230 /* ModuleDeclaration */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 260 /* PropertyAssignment */: + case 263 /* EnumMember */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 232 /* ModuleDeclaration */: return node.parent.name === node; - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: return true; } } @@ -65379,17 +67545,17 @@ var ts; return undefined; } switch (node.kind) { - case 261 /* SourceFile */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: + case 264 /* SourceFile */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: return node; } } @@ -65397,46 +67563,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 261 /* SourceFile */: + case 264 /* SourceFile */: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return ts.ScriptElementKind.moduleElement; - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: return ts.ScriptElementKind.classElement; - case 227 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; - case 228 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; - case 229 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; - case 223 /* VariableDeclaration */: + case 229 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 230 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 231 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; + case 225 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 174 /* BindingElement */: + case 175 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: return ts.ScriptElementKind.functionElement; - case 151 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; - case 152 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 152 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; + case 153 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: return ts.ScriptElementKind.memberFunctionElement; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return ts.ScriptElementKind.memberVariableElement; - case 155 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; - case 154 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; - case 153 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; - case 150 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; - case 143 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; - case 260 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; - case 144 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 234 /* ImportEqualsDeclaration */: - case 239 /* ImportSpecifier */: - case 236 /* ImportClause */: - case 243 /* ExportSpecifier */: - case 237 /* NamespaceImport */: + case 156 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; + case 155 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; + case 154 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; + case 151 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; + case 144 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; + case 263 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; + case 145 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 236 /* ImportEqualsDeclaration */: + case 241 /* ImportSpecifier */: + case 238 /* ImportClause */: + case 245 /* ExportSpecifier */: + case 239 /* NamespaceImport */: return ts.ScriptElementKind.alias; - case 285 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -65451,7 +67617,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 171 /* LiteralType */ ? node.parent : node; + var searchNode = node.parent.kind === 172 /* LiteralType */ ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32 /* StringLiteral */) { return type; @@ -65466,7 +67632,7 @@ var ts; return true; case 70 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 144 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 145 /* Parameter */; default: return false; } @@ -65511,42 +67677,42 @@ var ts; return false; } switch (n.kind) { - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 176 /* ObjectLiteralExpression */: - case 172 /* ObjectBindingPattern */: - case 161 /* TypeLiteral */: - case 204 /* Block */: - case 231 /* ModuleBlock */: - case 232 /* CaseBlock */: - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 177 /* ObjectLiteralExpression */: + case 173 /* ObjectBindingPattern */: + case 162 /* TypeLiteral */: + case 206 /* Block */: + case 233 /* ModuleBlock */: + case 234 /* CaseBlock */: + case 240 /* NamedImports */: + case 244 /* NamedExports */: return nodeEndsWith(n, 17 /* CloseBraceToken */, sourceFile); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 180 /* NewExpression */: + case 181 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 179 /* CallExpression */: - case 183 /* ParenthesizedExpression */: - case 166 /* ParenthesizedType */: + case 180 /* CallExpression */: + case 184 /* ParenthesizedExpression */: + case 167 /* ParenthesizedType */: return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 154 /* ConstructSignature */: - case 153 /* CallSignature */: - case 185 /* ArrowFunction */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 155 /* ConstructSignature */: + case 154 /* CallSignature */: + case 186 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -65556,67 +67722,67 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 19 /* CloseParenToken */, sourceFile); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 208 /* IfStatement */: + case 210 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24 /* SemicolonToken */); - case 175 /* ArrayLiteralExpression */: - case 173 /* ArrayBindingPattern */: - case 178 /* ElementAccessExpression */: - case 142 /* ComputedPropertyName */: - case 163 /* TupleType */: + case 176 /* ArrayLiteralExpression */: + case 174 /* ArrayBindingPattern */: + case 179 /* ElementAccessExpression */: + case 143 /* ComputedPropertyName */: + case 164 /* TupleType */: return nodeEndsWith(n, 21 /* CloseBracketToken */, sourceFile); - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); - case 253 /* CaseClause */: - case 254 /* DefaultClause */: + case 256 /* CaseClause */: + case 257 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 210 /* WhileStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 212 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 209 /* DoStatement */: + case 211 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 105 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 187 /* TypeOfExpression */: - case 186 /* DeleteExpression */: - case 188 /* VoidExpression */: - case 195 /* YieldExpression */: - case 196 /* SpreadElement */: + case 188 /* TypeOfExpression */: + case 187 /* DeleteExpression */: + case 189 /* VoidExpression */: + case 196 /* YieldExpression */: + case 197 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 202 /* TemplateSpan */: + case 204 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 241 /* ExportDeclaration */: - case 235 /* ImportDeclaration */: + case 243 /* ExportDeclaration */: + case 237 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -65672,7 +67838,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 === 292 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 296 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -65739,8 +67905,8 @@ var ts; } } // find the child that contains 'position' - for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { - var child = current.getChildAt(i); + for (var _a = 0, _b = current.getChildren(); _a < _b.length; _a++) { + var child = _b[_a]; // all jsDocComment nodes were already visited if (ts.isJSDocNode(child)) { continue; @@ -65819,7 +67985,7 @@ var ts; return n; } var children = n.getChildren(); - for (var i = 0, len = children.length; i < len; i++) { + for (var i = 0; i < children.length; 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' @@ -65844,7 +68010,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 261 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 264 /* 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. @@ -65903,17 +68069,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 252 /* JsxExpression */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 255 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 252 /* JsxExpression */) { + if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 255 /* JsxExpression */) { return true; } //
|
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 249 /* JsxClosingElement */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 251 /* JsxClosingElement */) { return true; } return false; @@ -66025,17 +68191,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 157 /* TypeReference */ || node.kind === 179 /* CallExpression */) { + if (node.kind === 158 /* TypeReference */ || node.kind === 180 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 226 /* ClassDeclaration */ || node.kind === 227 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 228 /* ClassDeclaration */ || node.kind === 229 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 140 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 141 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { @@ -66094,18 +68260,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 175 /* ArrayLiteralExpression */ || - node.kind === 176 /* ObjectLiteralExpression */) { + if (node.kind === 176 /* ArrayLiteralExpression */ || + node.kind === 177 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 192 /* BinaryExpression */ && + if (node.parent.kind === 193 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 57 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 213 /* ForOfStatement */ && + if (node.parent.kind === 215 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -66113,7 +68279,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 257 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 260 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -66141,12 +68307,32 @@ var ts; } } ts.isInNonReferenceComment = isInNonReferenceComment; + function createTextSpanFromNode(node, sourceFile) { + return ts.createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); + } + ts.createTextSpanFromNode = createTextSpanFromNode; + function isTypeKeyword(kind) { + switch (kind) { + case 118 /* AnyKeyword */: + case 121 /* BooleanKeyword */: + case 129 /* NeverKeyword */: + case 132 /* NumberKeyword */: + case 133 /* ObjectKeyword */: + case 135 /* StringKeyword */: + case 136 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + return true; + default: + return false; + } + } + ts.isTypeKeyword = isTypeKeyword; })(ts || (ts = {})); // Display-part writer helpers /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 144 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 145 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -66170,7 +68356,8 @@ var ts; decreaseIndent: function () { indent--; }, clear: resetWriter, trackSymbol: ts.noop, - reportInaccessibleThisError: ts.noop + reportInaccessibleThisError: ts.noop, + reportIllegalExtends: ts.noop }; function writeIndent() { if (lineStart) { @@ -66327,7 +68514,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location) && - location.parent.kind === 142 /* ComputedPropertyName */) { + location.parent.kind === 143 /* ComputedPropertyName */) { return location.text; } // Try to get the local symbol if we're dealing with an 'export default' @@ -66339,7 +68526,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 239 /* ImportSpecifier */ || location.parent.kind === 243 /* ExportSpecifier */) && + (location.parent.kind === 241 /* ImportSpecifier */ || location.parent.kind === 245 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -66406,6 +68593,11 @@ var ts; }; } ts.sanitizeConfigFile = sanitizeConfigFile; + function getOpenBraceEnd(constructor, sourceFile) { + // First token is the open curly, this is where we want to put the 'super' call. + return constructor.body.getFirstToken(sourceFile).getEnd(); + } + ts.getOpenBraceEnd = getOpenBraceEnd; })(ts || (ts = {})); var ts; (function (ts) { @@ -66454,7 +68646,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 124 /* GetKeyword */ || - keyword2 === 133 /* SetKeyword */ || + keyword2 === 134 /* SetKeyword */ || keyword2 === 122 /* ConstructorKeyword */ || keyword2 === 114 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". @@ -66473,7 +68665,7 @@ var ts; var entries = []; var dense = classifications.spans; var lastEnd = 0; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; var length_4 = dense[i + 1]; var type = dense[i + 2]; @@ -66613,10 +68805,10 @@ var ts; angleBracketStack--; } else if (token === 118 /* AnyKeyword */ || - token === 134 /* StringKeyword */ || + token === 135 /* StringKeyword */ || token === 132 /* NumberKeyword */ || token === 121 /* BooleanKeyword */ || - token === 135 /* SymbolKeyword */) { + token === 136 /* 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, @@ -66788,7 +68980,7 @@ var ts; } } function isKeyword(token) { - return token >= 71 /* FirstKeyword */ && token <= 140 /* LastKeyword */; + return token >= 71 /* FirstKeyword */ && token <= 141 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -66845,10 +69037,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 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 225 /* FunctionDeclaration */: + case 232 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 227 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -66899,7 +69091,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 230 /* ModuleDeclaration */ && + return declaration.kind === 232 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -66914,7 +69106,7 @@ var ts; // 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]) { + if (classifiableNames.get(identifier.text)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { var type = classifySymbol(symbol, ts.getMeaningFromLocation(node)); @@ -66960,7 +69152,7 @@ var ts; 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) { + for (var i = 0; i < dense.length; i += 3) { result.push({ textSpan: ts.createTextSpan(dense[i], dense[i + 1]), classificationType: getClassificationTypeName(dense[i + 2]) @@ -67063,16 +69255,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 281 /* JSDocParameterTag */: + case 285 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 284 /* JSDocTemplateTag */: + case 288 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 283 /* JSDocTypeTag */: + case 287 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 282 /* JSDocReturnTag */: + case 286 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -67159,22 +69351,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 248 /* JsxOpeningElement */: + case 250 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 249 /* JsxClosingElement */: + case 251 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 247 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 250 /* JsxAttribute */: + case 252 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -67202,17 +69394,17 @@ var ts; if (token) { if (tokenKind === 57 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 223 /* VariableDeclaration */ || - token.parent.kind === 147 /* PropertyDeclaration */ || - token.parent.kind === 144 /* Parameter */ || - token.parent.kind === 250 /* JsxAttribute */) { + if (token.parent.kind === 225 /* VariableDeclaration */ || + token.parent.kind === 148 /* PropertyDeclaration */ || + token.parent.kind === 145 /* Parameter */ || + token.parent.kind === 252 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 192 /* BinaryExpression */ || - token.parent.kind === 190 /* PrefixUnaryExpression */ || - token.parent.kind === 191 /* PostfixUnaryExpression */ || - token.parent.kind === 193 /* ConditionalExpression */) { + if (token.parent.kind === 193 /* BinaryExpression */ || + token.parent.kind === 191 /* PrefixUnaryExpression */ || + token.parent.kind === 192 /* PostfixUnaryExpression */ || + token.parent.kind === 194 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -67222,7 +69414,7 @@ var ts; return 4 /* numericLiteral */; } else if (tokenKind === 9 /* StringLiteral */) { - return token.parent.kind === 250 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 252 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 11 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -67238,32 +69430,32 @@ var ts; else if (tokenKind === 70 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 144 /* Parameter */: + case 145 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -67280,9 +69472,8 @@ var ts; // Ignore nodes that don't intersect the original span to classify. if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { checkForClassificationCancellation(cancellationToken, element.kind); - var children = element.getChildren(sourceFile); - for (var i = 0, n = children.length; i < n; i++) { - var child = children[i]; + for (var _i = 0, _a = element.getChildren(sourceFile); _i < _a.length; _i++) { + var child = _a[_i]; if (!tryClassifyNode(child)) { // Recurse into our child nodes. processElement(child); @@ -67293,7 +69484,6 @@ var ts; } ts.getEncodedSyntacticClassifications = getEncodedSyntacticClassifications; })(ts || (ts = {})); -/// /* @internal */ var ts; (function (ts) { @@ -67301,10 +69491,10 @@ var ts; (function (Completions) { function getCompletionsAtPosition(host, typeChecker, log, compilerOptions, sourceFile, position) { if (ts.isInReferenceComment(sourceFile, position)) { - return getTripleSlashReferenceCompletion(sourceFile, position); + return getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); } if (ts.isInString(sourceFile, position)) { - return getStringLiteralCompletionEntries(sourceFile, position); + return getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log); } var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (!completionData) { @@ -67317,13 +69507,13 @@ var ts; } var entries = []; if (ts.isSourceFileJavaScript(sourceFile)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true); - ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); + ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target)); } else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 /* JSX */ && - location.parent && location.parent.kind === 249 /* JsxClosingElement */) { + location.parent && location.parent.kind === 251 /* JsxClosingElement */) { // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. // For example: @@ -67340,629 +69530,642 @@ var ts; return undefined; } } - getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true); + getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); } // Add keywords if this is not a member completion list if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { - var entries = []; - var nameTable = ts.getNameTable(sourceFile); - for (var name_44 in nameTable) { - // Skip identifiers produced only from the current location - if (nameTable[name_44] === position) { - continue; + } + Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames, target) { + var entries = []; + var nameTable = ts.getNameTable(sourceFile); + nameTable.forEach(function (pos, name) { + // Skip identifiers produced only from the current location + if (pos === position) { + return; + } + if (!uniqueNames.get(name)) { + uniqueNames.set(name, name); + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name), target, /*performCharacterChecks*/ true); + if (displayName) { + var entry = { + name: displayName, + kind: ts.ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } - if (!uniqueNames[name_44]) { - uniqueNames[name_44] = name_44; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_44), compilerOptions.target, /*performCharacterChecks*/ true); - if (displayName) { - var entry = { - name: displayName, - kind: ts.ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; + } + }); + return entries; + } + function createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target) { + // 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(typeChecker, symbol, target, performCharacterChecks, 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: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), + kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), + sortText: "0", + }; + } + function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks, typeChecker, target, log) { + var start = ts.timestamp(); + var uniqueNames = ts.createMap(); + if (symbols) { + for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { + var symbol = symbols_4[_i]; + var entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target); + if (entry) { + var id = ts.escapeIdentifier(entry.name); + if (!uniqueNames.get(id)) { entries.push(entry); + uniqueNames.set(id, id); } } } - return entries; } - function createCompletionEntry(symbol, location, performCharacterChecks) { - // 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(typeChecker, symbol, compilerOptions.target, performCharacterChecks, location); - if (!displayName) { - return undefined; + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); + return uniqueNames; + } + function getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log) { + var node = ts.findPrecedingToken(position, sourceFile); + if (!node || node.kind !== 9 /* StringLiteral */) { + return undefined; + } + if (node.parent.kind === 260 /* PropertyAssignment */ && + node.parent.parent.kind === 177 /* ObjectLiteralExpression */ && + node.parent.name === node) { + // Get quoted name of properties of the object literal expression + // i.e. interface ConfigFiles { + // 'jspm:dev': string + // } + // let files: ConfigFiles = { + // '/*completion position*/' + // } + // + // function foo(c: ConfigFiles) {} + // foo({ + // '/*completion position*/' + // }); + return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent, typeChecker, compilerOptions.target, log); + } + else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { + // Get all names of properties on the expression + // i.e. interface A { + // 'prop1': string + // } + // let a: A; + // a['/*completion position*/'] + return getStringLiteralCompletionEntriesFromElementAccess(node.parent, typeChecker, compilerOptions.target, log); + } + else if (node.parent.kind === 237 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + // Get all known external module names or complete a path to a module + // i.e. import * as ns from "/*completion position*/"; + // import x = require("/*completion position*/"); + // var y = require("/*completion position*/"); + return getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker); + } + else if (isEqualityExpression(node.parent)) { + // Get completions from the type of the other operand + // i.e. switch (a) { + // case '/*completion position*/' + // } + return getStringLiteralCompletionEntriesFromType(typeChecker.getTypeAtLocation(node.parent.left === node ? node.parent.right : node.parent.left), typeChecker); + } + else if (ts.isCaseOrDefaultClause(node.parent)) { + // Get completions from the type of the switch expression + // i.e. x === '/*completion position' + return getStringLiteralCompletionEntriesFromType(typeChecker.getTypeAtLocation(node.parent.parent.parent.expression), typeChecker); + } + else { + var argumentInfo = ts.SignatureHelp.getImmediatelyContainingArgumentInfo(node, position, sourceFile); + if (argumentInfo) { + // Get string literal completions from specialized signatures of the target + // i.e. declare function f(a: 'A'); + // f("/*completion position*/") + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker); } - // 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: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0", - }; + // Get completion for string literal from string literal type + // i.e. var x: "hi" | "hello" = "/*completion position*/" + return getStringLiteralCompletionEntriesFromType(typeChecker.getContextualType(node), typeChecker); } - function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks) { - var start = ts.timestamp(); - var uniqueNames = ts.createMap(); - if (symbols) { - for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { - var symbol = symbols_4[_i]; - var entry = createCompletionEntry(symbol, location, performCharacterChecks); - if (entry) { - var id = ts.escapeIdentifier(entry.name); - if (!uniqueNames[id]) { - entries.push(entry); - uniqueNames[id] = id; + } + function getStringLiteralCompletionEntriesFromPropertyAssignment(element, typeChecker, target, log) { + var type = typeChecker.getContextualType(element.parent); + var entries = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/ false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + } + } + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker) { + var candidates = []; + var entries = []; + typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); + for (var _i = 0, candidates_3 = candidates; _i < candidates_3.length; _i++) { + var candidate = candidates_3[_i]; + addStringLiteralCompletionsFromType(typeChecker.getParameterType(candidate, argumentInfo.argumentIndex), entries, typeChecker); + } + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; + } + return undefined; + } + function getStringLiteralCompletionEntriesFromElementAccess(node, typeChecker, target, log) { + var type = typeChecker.getTypeAtLocation(node.expression); + var entries = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/ false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + } + return undefined; + } + function getStringLiteralCompletionEntriesFromType(type, typeChecker) { + if (type) { + var entries = []; + addStringLiteralCompletionsFromType(type, entries, typeChecker); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; + } + } + return undefined; + } + function addStringLiteralCompletionsFromType(type, result, typeChecker) { + if (type && type.flags & 16384 /* TypeParameter */) { + type = typeChecker.getApparentType(type); + } + if (!type) { + return; + } + if (type.flags & 65536 /* Union */) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + addStringLiteralCompletionsFromType(t, result, typeChecker); + } + } + else if (type.flags & 32 /* StringLiteral */) { + result.push({ + name: type.text, + kindModifiers: ts.ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.variableElement, + sortText: "0" + }); + } + } + function getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker) { + var literalValue = ts.normalizeSlashes(node.text); + var scriptPath = node.getSourceFile().path; + var scriptDirectory = ts.getDirectoryPath(scriptPath); + var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); + var entries; + if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { + var extensions = ts.getSupportedExtensions(compilerOptions); + if (compilerOptions.rootDirs) { + entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, span, compilerOptions, host, scriptPath); + } + else { + entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, span, host, scriptPath); + } + } + else { + // Check for node modules + entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span, compilerOptions, host, typeChecker); + } + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: entries + }; + } + /** + * Takes a script path and returns paths for all potential folders that could be merged with its + * containing folder via the "rootDirs" compiler option + */ + function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { + // Make all paths absolute/normalized if they are not already + rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); + // Determine the path to the directory containing the script relative to the root directory it is contained within + var relativeDirectory; + for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { + var rootDirectory = rootDirs_1[_i]; + if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { + relativeDirectory = scriptPath.substr(rootDirectory.length); + break; + } + } + // Now find a path for each potential directory that is to be merged with the one containing the script + return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); + } + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, compilerOptions, host, exclude) { + var basePath = compilerOptions.project || host.getCurrentDirectory(); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); + var result = []; + for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { + var baseDirectory = baseDirectories_1[_i]; + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, host, exclude, result); + } + return result; + } + /** + * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. + */ + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, host, exclude, result) { + if (result === void 0) { result = []; } + if (fragment === undefined) { + fragment = ""; + } + fragment = ts.normalizeSlashes(fragment); + /** + * Remove the basename from the path. Note that we don't use the basename to filter completions; + * the client is responsible for refining completions. + */ + fragment = ts.getDirectoryPath(fragment); + if (fragment === "") { + fragment = "." + ts.directorySeparator; + } + fragment = ts.ensureTrailingDirectorySeparator(fragment); + var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); + var baseDirectory = ts.getDirectoryPath(absolutePath); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + if (tryDirectoryExists(host, baseDirectory)) { + // Enumerate the available files if possible + var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + if (files) { + /** + * Multiple file entries might map to the same truncated name once we remove extensions + * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: + * + * both foo.ts and foo.tsx become foo + */ + var foundFiles = ts.createMap(); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var filePath = files_3[_i]; + filePath = ts.normalizePath(filePath); + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { + continue; + } + var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); + if (!foundFiles.get(foundFileName)) { + foundFiles.set(foundFileName, true); + } + } + ts.forEachKey(foundFiles, function (foundFile) { + result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); + }); + } + // If possible, get folder completion as well + var directories = tryGetDirectories(host, baseDirectory); + if (directories) { + for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { + var directory = directories_2[_a]; + var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); + result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); + } + } + } + return result; + } + /** + * Check all of the declared modules and those in node modules. Possible sources of modules: + * Modules that are found by the type checker + * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) + * Modules from node_modules (i.e. those listed in package.json) + * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions + */ + function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span, compilerOptions, host, typeChecker) { + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; + var result; + if (baseUrl) { + var fileExtensions = ts.getSupportedExtensions(compilerOptions); + var projectDir = compilerOptions.project || host.getCurrentDirectory(); + var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); + result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, /*includeExtensions*/ false, span, host); + if (paths) { + for (var path in paths) { + if (paths.hasOwnProperty(path)) { + if (path === "*") { + if (paths[path]) { + for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { + var pattern = _a[_i]; + for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host); _b < _c.length; _b++) { + var match = _c[_b]; + result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + else if (ts.startsWith(path, fragment)) { + var entry = paths[path] && paths[path].length === 1 && paths[path][0]; + if (entry) { + result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); + } } } } } - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); - return uniqueNames; } - function getStringLiteralCompletionEntries(sourceFile, position) { - var node = ts.findPrecedingToken(position, sourceFile); - if (!node || node.kind !== 9 /* StringLiteral */) { - return undefined; + else { + result = []; + } + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); + for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host); _d < _e.length; _d++) { + var moduleName = _e[_d]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + return result; + } + function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { + if (host.readDirectory) { + var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; + if (parsed) { + // The prefix has two effective parts: the directory path and the base component after the filepath that is not a + // full directory component. For example: directory/path/of/prefix/base* + var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); + var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); + var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); + var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; + // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call + var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; + var normalizedSuffix = ts.normalizePath(parsed.suffix); + var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); + var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + // If we have a suffix, then we need to read the directory all the way down. We could create a glob + // that encodes the suffix, but we would have to escape the character "?" which readDirectory + // doesn't support. For now, this is safer but slower + var includeGlob = normalizedSuffix ? "**/*" : "./*"; + var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); + if (matches) { + var result = []; + // Trim away prefix and suffix + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; + var normalizedMatch = ts.normalizePath(match); + if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { + continue; + } + var start = completePrefix.length; + var length_5 = normalizedMatch.length - start - normalizedSuffix.length; + result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); + } + return result; + } } - if (node.parent.kind === 257 /* PropertyAssignment */ && - node.parent.parent.kind === 176 /* ObjectLiteralExpression */ && - node.parent.name === node) { - // Get quoted name of properties of the object literal expression - // i.e. interface ConfigFiles { - // 'jspm:dev': string - // } - // let files: ConfigFiles = { - // '/*completion position*/' - // } - // - // function foo(c: ConfigFiles) {} - // foo({ - // '/*completion position*/' - // }); - return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); + } + return undefined; + } + function enumeratePotentialNonRelativeModules(fragment, scriptPath, options, typeChecker, host) { + // Check If this is a nested module + var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; + var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; + // Get modules that the type checker picked up + var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); + var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); + // Nested modules of the form "module-name/sub" need to be adjusted to only return the string + // after the last '/' that appears in the fragment because that's where the replacement span + // starts + if (isNestedModule) { + var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); + nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { + if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { + return moduleName.substr(moduleNameWithSeperator_1.length); + } + return moduleName; + }); + } + if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { + for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { + var visibleModule = _a[_i]; + if (!isNestedModule) { + nonRelativeModules.push(visibleModule.moduleName); + } + else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { + var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, /*exclude*/ undefined, /*include*/ ["./*"]); + if (nestedFiles) { + for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { + var f = nestedFiles_1[_b]; + f = ts.normalizePath(f); + var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); + nonRelativeModules.push(nestedModule); + } + } + } } - else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { - // Get all names of properties on the expression - // i.e. interface A { - // 'prop1': string - // } - // let a: A; - // a['/*completion position*/'] - return getStringLiteralCompletionEntriesFromElementAccess(node.parent); - } - else if (node.parent.kind === 235 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { - // Get all known external module names or complete a path to a module - // i.e. import * as ns from "/*completion position*/"; - // import x = require("/*completion position*/"); - // var y = require("/*completion position*/"); - return getStringLiteralCompletionEntriesFromModuleNames(node); + } + return ts.deduplicate(nonRelativeModules); + } + function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { + var token = ts.getTokenAtPosition(sourceFile, position); + if (!token) { + return undefined; + } + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + if (!commentRanges || !commentRanges.length) { + return undefined; + } + var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); + if (!range) { + return undefined; + } + var completionInfo = { + /** + * We don't want the editor to offer any other completions, such as snippets, inside a comment. + */ + isGlobalCompletion: false, + isMemberCompletion: false, + /** + * The user may type in a path that doesn't yet exist, creating a "new identifier" + * with respect to the collection of identifiers the server is aware of. + */ + isNewIdentifierLocation: true, + entries: [] + }; + var text = sourceFile.text.substr(range.pos, position - range.pos); + var match = tripleSlashDirectiveFragmentRegex.exec(text); + if (match) { + var prefix = match[1]; + var kind = match[2]; + var toComplete = match[3]; + var scriptPath = ts.getDirectoryPath(sourceFile.path); + if (kind === "path") { + // Give completions for a relative path + var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, span_10, host, sourceFile.path); } else { - var argumentInfo = ts.SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); - if (argumentInfo) { - // Get string literal completions from specialized signatures of the target - // i.e. declare function f(a: 'A'); - // f("/*completion position*/") - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); - } - // Get completion for string literal from string literal type - // i.e. var x: "hi" | "hello" = "/*completion position*/" - return getStringLiteralCompletionEntriesFromContextualType(node); + // Give completions based on the typings available + var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); } } - function getStringLiteralCompletionEntriesFromPropertyAssignment(element) { - var type = typeChecker.getContextualType(element.parent); - var entries = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/ false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + return completionInfo; + } + function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { + if (result === void 0) { result = []; } + // Check for typings specified in compiler options + if (options.types) { + for (var _i = 0, _a = options.types; _i < _a.length; _i++) { + var moduleName = _a[_i]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + } + else if (host.getDirectories) { + var typeRoots = void 0; + try { + // Wrap in try catch because getEffectiveTypeRoots touches the filesystem + typeRoots = ts.getEffectiveTypeRoots(options, host); + } + catch (e) { } + if (typeRoots) { + for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { + var root = typeRoots_2[_b]; + getCompletionEntriesFromDirectories(host, root, span, result); } } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo) { - var candidates = []; - var entries = []; - typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); - for (var _i = 0, candidates_3 = candidates; _i < candidates_3.length; _i++) { - var candidate = candidates_3[_i]; - if (candidate.parameters.length > argumentInfo.argumentIndex) { - var parameter = candidate.parameters[argumentInfo.argumentIndex]; - addStringLiteralCompletionsFromType(typeChecker.getTypeAtLocation(parameter.valueDeclaration), entries); + if (host.getDirectories) { + // Also get all @types typings installed in visible node_modules directories + for (var _c = 0, _d = findPackageJsons(scriptPath, host); _c < _d.length; _c++) { + var packageJson = _d[_c]; + var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(host, typesDir, span, result); + } + } + return result; + } + function getCompletionEntriesFromDirectories(host, directory, span, result) { + if (host.getDirectories && tryDirectoryExists(host, directory)) { + var directories = tryGetDirectories(host, directory); + if (directories) { + for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { + var typeDirectory = directories_3[_i]; + typeDirectory = ts.normalizePath(typeDirectory); + result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); } } - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; - } - return undefined; } - function getStringLiteralCompletionEntriesFromElementAccess(node) { - var type = typeChecker.getTypeAtLocation(node.expression); - var entries = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/ false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + function findPackageJsons(currentDir, host) { + var paths = []; + var currentConfigPath; + while (true) { + currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + currentDir = ts.getDirectoryPath(currentConfigPath); + var parent = ts.getDirectoryPath(currentDir); + if (currentDir === parent) { + break; } - } - return undefined; - } - function getStringLiteralCompletionEntriesFromContextualType(node) { - var type = typeChecker.getContextualType(node); - if (type) { - var entries_2 = []; - addStringLiteralCompletionsFromType(type, entries_2); - if (entries_2.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries_2 }; - } - } - return undefined; - } - function addStringLiteralCompletionsFromType(type, result) { - if (!type) { - return; - } - if (type.flags & 65536 /* Union */) { - ts.forEach(type.types, function (t) { return addStringLiteralCompletionsFromType(t, result); }); + currentDir = parent; } else { - if (type.flags & 32 /* StringLiteral */) { + break; + } + } + return paths; + } + function enumerateNodeModulesVisibleToScript(host, scriptPath) { + var result = []; + if (host.readFile && host.fileExists) { + for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + var packageJson = _a[_i]; + var contents = tryReadingPackageJson(packageJson); + if (!contents) { + return; + } + var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); + var foundModuleNames = []; + // Provide completions for all non @types dependencies + for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { + var key = nodeModulesDependencyKeys_1[_b]; + addPotentialPackageNames(contents[key], foundModuleNames); + } + for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { + var moduleName = foundModuleNames_1[_c]; + var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); result.push({ - name: type.text, - kindModifiers: ts.ScriptElementKindModifier.none, - kind: ts.ScriptElementKind.variableElement, - sortText: "0" + moduleName: moduleName, + moduleDir: moduleDir }); } } } - function getStringLiteralCompletionEntriesFromModuleNames(node) { - var literalValue = ts.normalizeSlashes(node.text); - var scriptPath = node.getSourceFile().path; - var scriptDirectory = ts.getDirectoryPath(scriptPath); - var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); - var entries; - if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { - if (compilerOptions.rootDirs) { - entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ false, span, scriptPath); - } - else { - entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ false, span, scriptPath); - } + return result; + function tryReadingPackageJson(filePath) { + try { + var fileText = tryReadFile(host, filePath); + return fileText ? JSON.parse(fileText) : undefined; } - else { - // Check for node modules - entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); - } - return { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: entries - }; - } - /** - * Takes a script path and returns paths for all potential folders that could be merged with its - * containing folder via the "rootDirs" compiler option - */ - function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { - // Make all paths absolute/normalized if they are not already - rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); - // Determine the path to the directory containing the script relative to the root directory it is contained within - var relativeDirectory; - for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { - var rootDirectory = rootDirs_1[_i]; - if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { - relativeDirectory = scriptPath.substr(rootDirectory.length); - break; - } - } - // Now find a path for each potential directory that is to be merged with the one containing the script - return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); - } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, exclude) { - var basePath = compilerOptions.project || host.getCurrentDirectory(); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); - var result = []; - for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { - var baseDirectory = baseDirectories_1[_i]; - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, exclude, result); - } - return result; - } - /** - * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. - */ - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, exclude, result) { - if (result === void 0) { result = []; } - if (fragment === undefined) { - fragment = ""; - } - fragment = ts.normalizeSlashes(fragment); - /** - * Remove the basename from the path. Note that we don't use the basename to filter completions; - * the client is responsible for refining completions. - */ - fragment = ts.getDirectoryPath(fragment); - if (fragment === "") { - fragment = "." + ts.directorySeparator; - } - fragment = ts.ensureTrailingDirectorySeparator(fragment); - var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); - var baseDirectory = ts.getDirectoryPath(absolutePath); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (tryDirectoryExists(host, baseDirectory)) { - // Enumerate the available files if possible - var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); - if (files) { - /** - * Multiple file entries might map to the same truncated name once we remove extensions - * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: - * - * both foo.ts and foo.tsx become foo - */ - var foundFiles = ts.createMap(); - for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { - var filePath = files_3[_i]; - filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { - continue; - } - var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); - if (!foundFiles[foundFileName]) { - foundFiles[foundFileName] = true; - } - } - for (var foundFile in foundFiles) { - result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); - } - } - // If possible, get folder completion as well - var directories = tryGetDirectories(host, baseDirectory); - if (directories) { - for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { - var directory = directories_2[_a]; - var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); - } - } - } - return result; - } - /** - * Check all of the declared modules and those in node modules. Possible sources of modules: - * Modules that are found by the type checker - * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) - * Modules from node_modules (i.e. those listed in package.json) - * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions - */ - function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span) { - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var result; - if (baseUrl) { - var fileExtensions = ts.getSupportedExtensions(compilerOptions); - var projectDir = compilerOptions.project || host.getCurrentDirectory(); - var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); - result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, /*includeExtensions*/ false, span); - if (paths) { - for (var path in paths) { - if (paths.hasOwnProperty(path)) { - if (path === "*") { - if (paths[path]) { - for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { - var pattern = _a[_i]; - for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions); _b < _c.length; _b++) { - var match = _c[_b]; - result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - else if (ts.startsWith(path, fragment)) { - var entry = paths[path] && paths[path].length === 1 && paths[path][0]; - if (entry) { - result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - } - } - else { - result = []; - } - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); - for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions); _d < _e.length; _d++) { - var moduleName = _e[_d]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - return result; - } - function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions) { - if (host.readDirectory) { - var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; - if (parsed) { - // The prefix has two effective parts: the directory path and the base component after the filepath that is not a - // full directory component. For example: directory/path/of/prefix/base* - var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); - var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); - var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); - var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; - // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call - var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; - var normalizedSuffix = ts.normalizePath(parsed.suffix); - var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); - var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - // If we have a suffix, then we need to read the directory all the way down. We could create a glob - // that encodes the suffix, but we would have to escape the character "?" which readDirectory - // doesn't support. For now, this is safer but slower - var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); - if (matches) { - var result = []; - // Trim away prefix and suffix - for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { - var match = matches_1[_i]; - var normalizedMatch = ts.normalizePath(match); - if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { - continue; - } - var start = completePrefix.length; - var length_5 = normalizedMatch.length - start - normalizedSuffix.length; - result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); - } - return result; - } - } - } - return undefined; - } - function enumeratePotentialNonRelativeModules(fragment, scriptPath, options) { - // Check If this is a nested module - var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; - var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; - // Get modules that the type checker picked up - var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); - var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); - // Nested modules of the form "module-name/sub" need to be adjusted to only return the string - // after the last '/' that appears in the fragment because that's where the replacement span - // starts - if (isNestedModule) { - var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); - nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { - if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { - return moduleName.substr(moduleNameWithSeperator_1.length); - } - return moduleName; - }); - } - if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { - for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { - var visibleModule = _a[_i]; - if (!isNestedModule) { - nonRelativeModules.push(visibleModule.moduleName); - } - else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { - var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, /*exclude*/ undefined, /*include*/ ["./*"]); - if (nestedFiles) { - for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { - var f = nestedFiles_1[_b]; - f = ts.normalizePath(f); - var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); - nonRelativeModules.push(nestedModule); - } - } - } - } - } - return ts.deduplicate(nonRelativeModules); - } - function getTripleSlashReferenceCompletion(sourceFile, position) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (!token) { + catch (e) { return undefined; } - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - if (!commentRanges || !commentRanges.length) { - return undefined; - } - var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); - if (!range) { - return undefined; - } - var completionInfo = { - /** - * We don't want the editor to offer any other completions, such as snippets, inside a comment. - */ - isGlobalCompletion: false, - isMemberCompletion: false, - /** - * The user may type in a path that doesn't yet exist, creating a "new identifier" - * with respect to the collection of identifiers the server is aware of. - */ - isNewIdentifierLocation: true, - entries: [] - }; - var text = sourceFile.text.substr(range.pos, position - range.pos); - var match = tripleSlashDirectiveFragmentRegex.exec(text); - if (match) { - var prefix = match[1]; - var kind = match[2]; - var toComplete = match[3]; - var scriptPath = ts.getDirectoryPath(sourceFile.path); - if (kind === "path") { - // Give completions for a relative path - var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, span_10, sourceFile.path); - } - else { - // Give completions based on the typings available - var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); - } - } - return completionInfo; } - function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { - if (result === void 0) { result = []; } - // Check for typings specified in compiler options - if (options.types) { - for (var _i = 0, _a = options.types; _i < _a.length; _i++) { - var moduleName = _a[_i]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - } - else if (host.getDirectories) { - var typeRoots = void 0; - try { - // Wrap in try catch because getEffectiveTypeRoots touches the filesystem - typeRoots = ts.getEffectiveTypeRoots(options, host); - } - catch (e) { } - if (typeRoots) { - for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { - var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, root, span, result); + function addPotentialPackageNames(dependencies, result) { + if (dependencies) { + for (var dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { + result.push(dep); } } } - if (host.getDirectories) { - // Also get all @types typings installed in visible node_modules directories - for (var _c = 0, _d = findPackageJsons(scriptPath); _c < _d.length; _c++) { - var packageJson = _d[_c]; - var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, typesDir, span, result); - } - } - return result; - } - function getCompletionEntriesFromDirectories(host, directory, span, result) { - if (host.getDirectories && tryDirectoryExists(host, directory)) { - var directories = tryGetDirectories(host, directory); - if (directories) { - for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { - var typeDirectory = directories_3[_i]; - typeDirectory = ts.normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - function findPackageJsons(currentDir) { - var paths = []; - var currentConfigPath; - while (true) { - currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); - currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_13 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_13) { - break; - } - currentDir = parent_13; - } - else { - break; - } - } - return paths; - } - function enumerateNodeModulesVisibleToScript(host, scriptPath) { - var result = []; - if (host.readFile && host.fileExists) { - for (var _i = 0, _a = findPackageJsons(scriptPath); _i < _a.length; _i++) { - var packageJson = _a[_i]; - var contents = tryReadingPackageJson(packageJson); - if (!contents) { - return; - } - var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); - var foundModuleNames = []; - // Provide completions for all non @types dependencies - for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { - var key = nodeModulesDependencyKeys_1[_b]; - addPotentialPackageNames(contents[key], foundModuleNames); - } - for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { - var moduleName = foundModuleNames_1[_c]; - var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName: moduleName, - moduleDir: moduleDir - }); - } - } - } - return result; - function tryReadingPackageJson(filePath) { - try { - var fileText = tryReadFile(host, filePath); - return fileText ? JSON.parse(fileText) : undefined; - } - catch (e) { - return undefined; - } - } - function addPotentialPackageNames(dependencies, result) { - if (dependencies) { - for (var dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { - result.push(dep); - } - } - } - } - } - function createCompletionEntryForModule(name, kind, replacementSpan) { - return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; - } - // Replace everything after the last directory seperator that appears - function getDirectoryFragmentTextSpan(text, textStart) { - var index = text.lastIndexOf(ts.directorySeparator); - var offset = index !== -1 ? index + 1 : 0; - return { start: textStart + offset, length: text.length - offset }; - } - // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) - function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; - var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; - } - return false; - } - function normalizeAndPreserveTrailingSlash(path) { - return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); } } - Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function createCompletionEntryForModule(name, kind, replacementSpan) { + return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; + } + // Replace everything after the last directory seperator that appears + function getDirectoryFragmentTextSpan(text, textStart) { + var index = text.lastIndexOf(ts.directorySeparator); + var offset = index !== -1 ? index + 1 : 0; + return { start: textStart + offset, length: text.length - offset }; + } + // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) + function isPathRelativeToScript(path) { + if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; + var slashCharCode = path.charCodeAt(slashIndex); + return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; + } + return false; + } + function normalizeAndPreserveTrailingSlash(path) { + return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); + } function getCompletionEntryDetails(typeChecker, log, compilerOptions, sourceFile, position, entryName) { // Compute all the completion symbols again. var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_3 = completionData.location; + var symbols = completionData.symbols, location_1 = completionData.location; // Find the symbol with the matching entry name. // 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(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_3) === entryName ? s : undefined; }); + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_1) === entryName ? s : undefined; }); if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_3, location_3, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { name: entryName, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), @@ -67990,12 +70193,12 @@ var ts; // Compute all the completion symbols again. var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_4 = completionData.location; + var symbols = completionData.symbols, location_2 = completionData.location; // Find the symbol with the matching entry name. // 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. - return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_4) === entryName ? s : undefined; }); + return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_2) === entryName ? s : undefined; }); } return undefined; } @@ -68026,9 +70229,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 283 /* JSDocTypeTag */: - case 281 /* JSDocParameterTag */: - case 282 /* JSDocReturnTag */: + case 287 /* JSDocTypeTag */: + case 285 /* JSDocParameterTag */: + case 286 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -68073,13 +70276,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_14 = contextToken.parent, kind = contextToken.kind; + var parent = contextToken.parent, kind = contextToken.kind; if (kind === 22 /* DotToken */) { - if (parent_14.kind === 177 /* PropertyAccessExpression */) { + if (parent.kind === 178 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_14.kind === 141 /* QualifiedName */) { + else if (parent.kind === 142 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -68090,13 +70293,27 @@ var ts; } } else if (sourceFile.languageVariant === 1 /* JSX */) { - if (kind === 26 /* LessThanToken */) { - isRightOfOpenTag = true; - location = contextToken; - } - else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 249 /* JsxClosingElement */) { - isStartingCloseTag = true; - location = contextToken; + switch (contextToken.parent.kind) { + case 251 /* JsxClosingElement */: + if (kind === 40 /* SlashToken */) { + isStartingCloseTag = true; + location = contextToken; + } + break; + case 193 /* BinaryExpression */: + if (!(contextToken.parent.left.flags & 32768 /* ThisNodeHasError */)) { + // It has a left-hand side, so we're not in an opening JSX tag. + break; + } + // fall through + case 249 /* JsxSelfClosingElement */: + case 248 /* JsxElement */: + case 250 /* JsxOpeningElement */: + if (kind === 26 /* LessThanToken */) { + isRightOfOpenTag = true; + location = contextToken; + } + break; } } } @@ -68143,7 +70360,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 70 /* Identifier */ || node.kind === 141 /* QualifiedName */ || node.kind === 177 /* PropertyAccessExpression */) { + if (node.kind === 70 /* Identifier */ || node.kind === 142 /* QualifiedName */ || node.kind === 178 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -68199,11 +70416,11 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 247 /* JsxSelfClosingElement */) || (jsxContainer.kind === 248 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 249 /* JsxSelfClosingElement */) || (jsxContainer.kind === 250 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element - attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + attrsType = typeChecker.getAllAttributesTypeFromJsxOpeningLikeElement(jsxContainer); if (attrsType) { - symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); + symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes.properties); isMemberCompletion = true; isNewIdentifierLocation = false; return true; @@ -68247,9 +70464,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 261 /* SourceFile */ || - scopeNode.kind === 194 /* TemplateExpression */ || - scopeNode.kind === 252 /* JsxExpression */ || + scopeNode.kind === 264 /* SourceFile */ || + scopeNode.kind === 195 /* TemplateExpression */ || + scopeNode.kind === 255 /* JsxExpression */ || ts.isStatement(scopeNode); } /// TODO filter meaning based on the current context @@ -68282,11 +70499,11 @@ var ts; return true; } if (contextToken.kind === 28 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 248 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 250 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 249 /* JsxClosingElement */ || contextToken.parent.kind === 247 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 246 /* JsxElement */; + if (contextToken.parent.kind === 251 /* JsxClosingElement */ || contextToken.parent.kind === 249 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 248 /* JsxElement */; } } return false; @@ -68296,40 +70513,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 25 /* CommaToken */: - return containingNodeKind === 179 /* CallExpression */ // func( a, | - || containingNodeKind === 150 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 180 /* NewExpression */ // new C(a, | - || containingNodeKind === 175 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 192 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 158 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 180 /* CallExpression */ // func( a, | + || containingNodeKind === 151 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 181 /* NewExpression */ // new C(a, | + || containingNodeKind === 176 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 193 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 159 /* FunctionType */; // var x: (s: string, list| case 18 /* OpenParenToken */: - return containingNodeKind === 179 /* CallExpression */ // func( | - || containingNodeKind === 150 /* Constructor */ // constructor( | - || containingNodeKind === 180 /* NewExpression */ // new C(a| - || containingNodeKind === 183 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 166 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 180 /* CallExpression */ // func( | + || containingNodeKind === 151 /* Constructor */ // constructor( | + || containingNodeKind === 181 /* NewExpression */ // new C(a| + || containingNodeKind === 184 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 167 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 20 /* OpenBracketToken */: - return containingNodeKind === 175 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 155 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 142 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + return containingNodeKind === 176 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 156 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 143 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 127 /* ModuleKeyword */: // module | case 128 /* NamespaceKeyword */: return true; case 22 /* DotToken */: - return containingNodeKind === 230 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 232 /* ModuleDeclaration */; // module A.| case 16 /* OpenBraceToken */: - return containingNodeKind === 226 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 228 /* ClassDeclaration */; // class A{ | case 57 /* EqualsToken */: - return containingNodeKind === 223 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 192 /* BinaryExpression */; // x = a| + return containingNodeKind === 225 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 193 /* BinaryExpression */; // x = a| case 13 /* TemplateHead */: - return containingNodeKind === 194 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 195 /* TemplateExpression */; // `aa ${| case 14 /* TemplateMiddle */: - return containingNodeKind === 202 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 204 /* TemplateSpan */; // `aa ${10} dd ${| case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: - return containingNodeKind === 147 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 148 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -68372,7 +70589,7 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 176 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 177 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; @@ -68382,7 +70599,7 @@ var ts; typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 172 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 173 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -68393,11 +70610,11 @@ var ts; // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 144 /* Parameter */) { + if (!canGetType && rootDeclaration.kind === 145 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 149 /* MethodDeclaration */ || rootDeclaration.parent.kind === 152 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 150 /* MethodDeclaration */ || rootDeclaration.parent.kind === 153 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -68439,9 +70656,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 238 /* NamedImports */ ? - 235 /* ImportDeclaration */ : - 241 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 240 /* NamedImports */ ? + 237 /* ImportDeclaration */ : + 243 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -68449,12 +70666,13 @@ var ts; } isMemberCompletion = true; isNewIdentifierLocation = false; - var exports; - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); + if (!moduleSpecifierSymbol) { + symbols = ts.emptyArray; + return true; } - symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : ts.emptyArray; + var exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); + symbols = filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements); return true; } /** @@ -68466,9 +70684,9 @@ var ts; switch (contextToken.kind) { case 16 /* OpenBraceToken */: // const x = { | case 25 /* CommaToken */: - var parent_15 = contextToken.parent; - if (parent_15 && (parent_15.kind === 176 /* ObjectLiteralExpression */ || parent_15.kind === 172 /* ObjectBindingPattern */)) { - return parent_15; + var parent = contextToken.parent; + if (parent && (parent.kind === 177 /* ObjectLiteralExpression */ || parent.kind === 173 /* ObjectBindingPattern */)) { + return parent; } break; } @@ -68485,8 +70703,8 @@ var ts; case 16 /* OpenBraceToken */: // import { | case 25 /* CommaToken */: switch (contextToken.parent.kind) { - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 240 /* NamedImports */: + case 244 /* NamedExports */: return contextToken.parent; } } @@ -68495,37 +70713,54 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_16 = contextToken.parent; + var parent = contextToken.parent; switch (contextToken.kind) { case 27 /* LessThanSlashToken */: case 40 /* SlashToken */: case 70 /* Identifier */: - case 250 /* JsxAttribute */: - case 251 /* JsxSpreadAttribute */: - if (parent_16 && (parent_16.kind === 247 /* JsxSelfClosingElement */ || parent_16.kind === 248 /* JsxOpeningElement */)) { - return parent_16; + case 253 /* JsxAttributes */: + case 252 /* JsxAttribute */: + case 254 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 249 /* JsxSelfClosingElement */ || parent.kind === 250 /* JsxOpeningElement */)) { + return parent; } - else if (parent_16.kind === 250 /* JsxAttribute */) { - return parent_16.parent; + else if (parent.kind === 252 /* JsxAttribute */) { + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + return parent.parent.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_16 && ((parent_16.kind === 250 /* JsxAttribute */) || (parent_16.kind === 251 /* JsxSpreadAttribute */))) { - return parent_16.parent; + if (parent && ((parent.kind === 252 /* JsxAttribute */) || (parent.kind === 254 /* JsxSpreadAttribute */))) { + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + return parent.parent.parent; } break; case 17 /* CloseBraceToken */: - if (parent_16 && - parent_16.kind === 252 /* JsxExpression */ && - parent_16.parent && - (parent_16.parent.kind === 250 /* JsxAttribute */)) { - return parent_16.parent.parent; + if (parent && + parent.kind === 255 /* JsxExpression */ && + parent.parent && parent.parent.kind === 252 /* JsxAttribute */) { + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + // each JsxAttribute can have initializer as JsxExpression + return parent.parent.parent.parent; } - if (parent_16 && parent_16.kind === 251 /* JsxSpreadAttribute */) { - return parent_16.parent; + if (parent && parent.kind === 254 /* JsxSpreadAttribute */) { + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + return parent.parent.parent; } break; } @@ -68534,16 +70769,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: return true; } return false; @@ -68555,66 +70790,66 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25 /* CommaToken */: - return containingNodeKind === 223 /* VariableDeclaration */ || - containingNodeKind === 224 /* VariableDeclarationList */ || - containingNodeKind === 205 /* VariableStatement */ || - containingNodeKind === 229 /* EnumDeclaration */ || + return containingNodeKind === 225 /* VariableDeclaration */ || + containingNodeKind === 226 /* VariableDeclarationList */ || + containingNodeKind === 207 /* VariableStatement */ || + containingNodeKind === 231 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 226 /* ClassDeclaration */ || - containingNodeKind === 197 /* ClassExpression */ || - containingNodeKind === 227 /* InterfaceDeclaration */ || - containingNodeKind === 173 /* ArrayBindingPattern */ || - containingNodeKind === 228 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 228 /* ClassDeclaration */ || + containingNodeKind === 198 /* ClassExpression */ || + containingNodeKind === 229 /* InterfaceDeclaration */ || + containingNodeKind === 174 /* ArrayBindingPattern */ || + containingNodeKind === 230 /* TypeAliasDeclaration */; // type Map, K, | case 22 /* DotToken */: - return containingNodeKind === 173 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 174 /* ArrayBindingPattern */; // var [.| case 55 /* ColonToken */: - return containingNodeKind === 174 /* BindingElement */; // var {x :html| + return containingNodeKind === 175 /* BindingElement */; // var {x :html| case 20 /* OpenBracketToken */: - return containingNodeKind === 173 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 174 /* ArrayBindingPattern */; // var [x| case 18 /* OpenParenToken */: - return containingNodeKind === 256 /* CatchClause */ || + return containingNodeKind === 259 /* CatchClause */ || isFunction(containingNodeKind); case 16 /* OpenBraceToken */: - return containingNodeKind === 229 /* EnumDeclaration */ || - containingNodeKind === 227 /* InterfaceDeclaration */ || - containingNodeKind === 161 /* TypeLiteral */; // const x : { | + return containingNodeKind === 231 /* EnumDeclaration */ || + containingNodeKind === 229 /* InterfaceDeclaration */ || + containingNodeKind === 162 /* TypeLiteral */; // const x : { | case 24 /* SemicolonToken */: - return containingNodeKind === 146 /* PropertySignature */ && + return containingNodeKind === 147 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 227 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 161 /* TypeLiteral */); // const x : { a; | + (contextToken.parent.parent.kind === 229 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 162 /* TypeLiteral */); // const x : { a; | case 26 /* LessThanToken */: - return containingNodeKind === 226 /* ClassDeclaration */ || - containingNodeKind === 197 /* ClassExpression */ || - containingNodeKind === 227 /* InterfaceDeclaration */ || - containingNodeKind === 228 /* TypeAliasDeclaration */ || + return containingNodeKind === 228 /* ClassDeclaration */ || + containingNodeKind === 198 /* ClassExpression */ || + containingNodeKind === 229 /* InterfaceDeclaration */ || + containingNodeKind === 230 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); case 114 /* StaticKeyword */: - return containingNodeKind === 147 /* PropertyDeclaration */; + return containingNodeKind === 148 /* PropertyDeclaration */; case 23 /* DotDotDotToken */: - return containingNodeKind === 144 /* Parameter */ || + return containingNodeKind === 145 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 173 /* ArrayBindingPattern */); // var [...z| + contextToken.parent.parent.kind === 174 /* ArrayBindingPattern */); // var [...z| case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: - return containingNodeKind === 144 /* Parameter */; + return containingNodeKind === 145 /* Parameter */; case 117 /* AsKeyword */: - return containingNodeKind === 239 /* ImportSpecifier */ || - containingNodeKind === 243 /* ExportSpecifier */ || - containingNodeKind === 237 /* NamespaceImport */; + return containingNodeKind === 241 /* ImportSpecifier */ || + containingNodeKind === 245 /* ExportSpecifier */ || + containingNodeKind === 239 /* NamespaceImport */; case 74 /* ClassKeyword */: case 82 /* EnumKeyword */: case 108 /* InterfaceKeyword */: case 88 /* FunctionKeyword */: case 103 /* VarKeyword */: case 124 /* GetKeyword */: - case 133 /* SetKeyword */: + case 134 /* SetKeyword */: case 90 /* ImportKeyword */: case 109 /* LetKeyword */: case 75 /* ConstKeyword */: case 115 /* YieldKeyword */: - case 136 /* TypeKeyword */: + case 137 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -68662,13 +70897,13 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_45 = element.propertyName || element.name; - existingImportsOrExports[name_45.text] = true; + var name = element.propertyName || element.name; + existingImportsOrExports.set(name.text, true); } - if (!ts.someProperties(existingImportsOrExports)) { + if (existingImportsOrExports.size === 0) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); } - return ts.filter(exportsOfModule, function (e) { return e.name !== "default" && !existingImportsOrExports[e.name]; }); + return ts.filter(exportsOfModule, function (e) { return e.name !== "default" && !existingImportsOrExports.get(e.name); }); } /** * Filters out completion suggestions for named imports or exports. @@ -68684,12 +70919,12 @@ var ts; 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 !== 257 /* PropertyAssignment */ && - m.kind !== 258 /* ShorthandPropertyAssignment */ && - m.kind !== 174 /* BindingElement */ && - m.kind !== 149 /* MethodDeclaration */ && - m.kind !== 151 /* GetAccessor */ && - m.kind !== 152 /* SetAccessor */) { + if (m.kind !== 260 /* PropertyAssignment */ && + m.kind !== 261 /* ShorthandPropertyAssignment */ && + m.kind !== 175 /* BindingElement */ && + m.kind !== 150 /* MethodDeclaration */ && + m.kind !== 152 /* GetAccessor */ && + m.kind !== 153 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -68697,7 +70932,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 174 /* BindingElement */ && m.propertyName) { + if (m.kind === 175 /* BindingElement */ && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 70 /* Identifier */) { existingName = m.propertyName.text; @@ -68709,9 +70944,9 @@ var ts; // things like '__proto__' are not filtered out. existingName = m.name.text; } - existingMemberNames[existingName] = true; + existingMemberNames.set(existingName, true); } - return ts.filter(contextualMemberSymbols, function (m) { return !existingMemberNames[m.name]; }); + return ts.filter(contextualMemberSymbols, function (m) { return !existingMemberNames.get(m.name); }); } /** * Filters out completion suggestions from 'symbols' according to existing JSX attributes. @@ -68727,11 +70962,11 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 250 /* JsxAttribute */) { - seenNames[attr.name.text] = true; + if (attr.kind === 252 /* JsxAttribute */) { + seenNames.set(attr.name.text, true); } } - return ts.filter(symbols, function (a) { return !seenNames[a.name]; }); + return ts.filter(symbols, function (a) { return !seenNames.get(a.name); }); } } /** @@ -68777,7 +71012,7 @@ var ts; } // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 71 /* FirstKeyword */; i <= 140 /* LastKeyword */; i++) { + for (var i = 71 /* FirstKeyword */; i <= 141 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -68829,6 +71064,15 @@ var ts; catch (e) { } return undefined; } + function isEqualityExpression(node) { + return ts.isBinaryExpression(node) && isEqualityOperatorKind(node.operatorToken.kind); + } + function isEqualityOperatorKind(kind) { + return kind == 31 /* EqualsEqualsToken */ || + kind === 32 /* ExclamationEqualsToken */ || + kind === 33 /* EqualsEqualsEqualsToken */ || + kind === 34 /* ExclamationEqualsEqualsToken */; + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -68838,534 +71082,519 @@ var ts; (function (DocumentHighlights) { function getDocumentHighlights(typeChecker, cancellationToken, sourceFile, position, sourceFilesToSearch) { var node = ts.getTouchingWord(sourceFile, position); + return node && (getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) || getSyntacticDocumentHighlights(node, sourceFile)); + } + DocumentHighlights.getDocumentHighlights = getDocumentHighlights; + function getHighlightSpanForNode(node, sourceFile) { + var start = node.getStart(sourceFile); + var end = node.getEnd(); + return { + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(start, end), + kind: ts.HighlightSpanKind.none + }; + } + function getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) { + var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch); + return referencedSymbols && convertReferencedSymbols(referencedSymbols); + } + function convertReferencedSymbols(referencedSymbols) { + var fileNameToDocumentHighlights = ts.createMap(); + var result = []; + 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 = referenceEntry.fileName; + var documentHighlights = fileNameToDocumentHighlights.get(fileName); + if (!documentHighlights) { + documentHighlights = { fileName: fileName, highlightSpans: [] }; + fileNameToDocumentHighlights.set(fileName, documentHighlights); + result.push(documentHighlights); + } + documentHighlights.highlightSpans.push({ + textSpan: referenceEntry.textSpan, + kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference + }); + } + } + return result; + } + function getSyntacticDocumentHighlights(node, sourceFile) { + var highlightSpans = getHighlightSpans(node, sourceFile); + if (!highlightSpans || highlightSpans.length === 0) { + return undefined; + } + return [{ fileName: sourceFile.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, sourceFile) { 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: ts.HighlightSpanKind.none - }; + switch (node.kind) { + case 89 /* IfKeyword */: + case 81 /* ElseKeyword */: + if (hasKind(node.parent, 210 /* IfStatement */)) { + return getIfElseOccurrences(node.parent, sourceFile); + } + break; + case 95 /* ReturnKeyword */: + if (hasKind(node.parent, 218 /* ReturnStatement */)) { + return highlightSpans(getReturnOccurrences(node.parent)); + } + break; + case 99 /* ThrowKeyword */: + if (hasKind(node.parent, 222 /* ThrowStatement */)) { + return highlightSpans(getThrowOccurrences(node.parent)); + } + break; + case 101 /* TryKeyword */: + case 73 /* CatchKeyword */: + case 86 /* FinallyKeyword */: + var tryStatement = node.kind === 73 /* CatchKeyword */ ? parent(parent(node)) : parent(node); + if (hasKind(tryStatement, 223 /* TryStatement */)) { + return highlightSpans(getTryCatchFinallyOccurrences(tryStatement, sourceFile)); + } + break; + case 97 /* SwitchKeyword */: + if (hasKind(node.parent, 220 /* SwitchStatement */)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent)); + } + break; + case 72 /* CaseKeyword */: + case 78 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 220 /* SwitchStatement */)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent.parent.parent)); + } + break; + case 71 /* BreakKeyword */: + case 76 /* ContinueKeyword */: + if (hasKind(node.parent, 217 /* BreakStatement */) || hasKind(node.parent, 216 /* ContinueStatement */)) { + return highlightSpans(getBreakOrContinueStatementOccurrences(node.parent)); + } + break; + case 87 /* ForKeyword */: + if (hasKind(node.parent, 213 /* ForStatement */) || + hasKind(node.parent, 214 /* ForInStatement */) || + hasKind(node.parent, 215 /* ForOfStatement */)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case 105 /* WhileKeyword */: + case 80 /* DoKeyword */: + if (hasKind(node.parent, 212 /* WhileStatement */) || hasKind(node.parent, 211 /* DoStatement */)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case 122 /* ConstructorKeyword */: + if (hasKind(node.parent, 151 /* Constructor */)) { + return highlightSpans(getConstructorOccurrences(node.parent)); + } + break; + case 124 /* GetKeyword */: + case 134 /* SetKeyword */: + if (hasKind(node.parent, 152 /* GetAccessor */) || hasKind(node.parent, 153 /* SetAccessor */)) { + return highlightSpans(getGetAndSetOccurrences(node.parent)); + } + break; + default: + if (ts.isModifierKind(node.kind) && node.parent && + (ts.isDeclaration(node.parent) || node.parent.kind === 207 /* VariableStatement */)) { + return highlightSpans(getModifierOccurrences(node.kind, node.parent)); + } } - function getSemanticDocumentHighlights(node) { - if (node.kind === 70 /* Identifier */ || - node.kind === 98 /* ThisKeyword */ || - node.kind === 167 /* ThisType */ || - node.kind === 96 /* SuperKeyword */ || - node.kind === 9 /* StringLiteral */ || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, /*findInStrings*/ false, /*findInComments*/ false, /*implementations*/ false); - return convertReferencedSymbols(referencedSymbols); - } - return undefined; - function convertReferencedSymbols(referencedSymbols) { - if (!referencedSymbols) { - return undefined; - } - var fileNameToDocumentHighlights = ts.createMap(); - var result = []; - 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 = referenceEntry.fileName; - var documentHighlights = fileNameToDocumentHighlights[fileName]; - if (!documentHighlights) { - documentHighlights = { fileName: fileName, highlightSpans: [] }; - fileNameToDocumentHighlights[fileName] = documentHighlights; - result.push(documentHighlights); - } - documentHighlights.highlightSpans.push({ - textSpan: referenceEntry.textSpan, - kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference - }); - } - } - return result; - } + function highlightSpans(nodes) { + return nodes && nodes.map(function (node) { return getHighlightSpanForNode(node, sourceFile); }); } - function getSyntacticDocumentHighlights(node) { - var fileName = sourceFile.fileName; - var highlightSpans = getHighlightSpans(node); - if (!highlightSpans || highlightSpans.length === 0) { - 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 === 222 /* ThrowStatement */) { + statementAccumulator.push(node); } - 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 89 /* IfKeyword */: - case 81 /* ElseKeyword */: - if (hasKind(node.parent, 208 /* IfStatement */)) { - return getIfElseOccurrences(node.parent); - } - break; - case 95 /* ReturnKeyword */: - if (hasKind(node.parent, 216 /* ReturnStatement */)) { - return getReturnOccurrences(node.parent); - } - break; - case 99 /* ThrowKeyword */: - if (hasKind(node.parent, 220 /* ThrowStatement */)) { - return getThrowOccurrences(node.parent); - } - break; - case 73 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 221 /* TryStatement */)) { - return getTryCatchFinallyOccurrences(node.parent.parent); - } - break; - case 101 /* TryKeyword */: - case 86 /* FinallyKeyword */: - if (hasKind(parent(node), 221 /* TryStatement */)) { - return getTryCatchFinallyOccurrences(node.parent); - } - break; - case 97 /* SwitchKeyword */: - if (hasKind(node.parent, 218 /* SwitchStatement */)) { - return getSwitchCaseDefaultOccurrences(node.parent); - } - break; - case 72 /* CaseKeyword */: - case 78 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 218 /* SwitchStatement */)) { - return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); - } - break; - case 71 /* BreakKeyword */: - case 76 /* ContinueKeyword */: - if (hasKind(node.parent, 215 /* BreakStatement */) || hasKind(node.parent, 214 /* ContinueStatement */)) { - return getBreakOrContinueStatementOccurrences(node.parent); - } - break; - case 87 /* ForKeyword */: - if (hasKind(node.parent, 211 /* ForStatement */) || - hasKind(node.parent, 212 /* ForInStatement */) || - hasKind(node.parent, 213 /* ForOfStatement */)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 105 /* WhileKeyword */: - case 80 /* DoKeyword */: - if (hasKind(node.parent, 210 /* WhileStatement */) || hasKind(node.parent, 209 /* DoStatement */)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 122 /* ConstructorKeyword */: - if (hasKind(node.parent, 150 /* Constructor */)) { - return getConstructorOccurrences(node.parent); - } - break; - case 124 /* GetKeyword */: - case 133 /* SetKeyword */: - if (hasKind(node.parent, 151 /* GetAccessor */) || hasKind(node.parent, 152 /* SetAccessor */)) { - return getGetAndSetOccurrences(node.parent); - } - break; - default: - if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 205 /* 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 === 220 /* ThrowStatement */) { - statementAccumulator.push(node); - } - else if (node.kind === 221 /* 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_17 = child.parent; - if (ts.isFunctionBlock(parent_17) || parent_17.kind === 261 /* SourceFile */) { - return parent_17; - } - // 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_17.kind === 221 /* TryStatement */) { - var tryStatement = parent_17; - if (tryStatement.tryBlock === child && tryStatement.catchClause) { - return child; - } - } - child = parent_17; - } - return undefined; - } - function aggregateAllBreakAndContinueStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 215 /* BreakStatement */ || node.kind === 214 /* 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_1 = statement.parent; node_1; node_1 = node_1.parent) { - switch (node_1.kind) { - case 218 /* SwitchStatement */: - if (statement.kind === 214 /* ContinueStatement */) { - continue; - } - // Fall through. - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 210 /* WhileStatement */: - case 209 /* DoStatement */: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; - } - break; - default: - // Don't cross function boundaries. - if (ts.isFunctionLike(node_1)) { - 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 === 226 /* ClassDeclaration */ || - container.kind === 197 /* ClassExpression */ || - (declaration.kind === 144 /* Parameter */ && hasKind(container, 150 /* Constructor */)))) { - return undefined; - } - } - else if (modifier === 114 /* StaticKeyword */) { - if (!(container.kind === 226 /* ClassDeclaration */ || container.kind === 197 /* ClassExpression */)) { - return undefined; - } - } - else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { - if (!(container.kind === 231 /* ModuleBlock */ || container.kind === 261 /* SourceFile */)) { - return undefined; - } - } - else if (modifier === 116 /* AbstractKeyword */) { - if (!(container.kind === 226 /* ClassDeclaration */ || declaration.kind === 226 /* ClassDeclaration */)) { - return undefined; - } + else if (node.kind === 223 /* TryStatement */) { + var tryStatement = node; + if (tryStatement.catchClause) { + aggregate(tryStatement.catchClause); } else { - // unsupported modifier - return undefined; - } - var keywords = []; - var modifierFlag = getFlagFromModifier(modifier); - var nodes; - switch (container.kind) { - case 231 /* ModuleBlock */: - case 261 /* SourceFile */: - // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & 128 /* Abstract */) { - nodes = declaration.members.concat(declaration); - } - else { - nodes = container.statements; - } - break; - case 150 /* Constructor */: - nodes = container.parameters.concat(container.parent.members); - break; - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - nodes = container.members; - // If we're an accessibility modifier, we're in an instance member and should search - // the constructor's parameter list for instance members as well. - if (modifierFlag & 28 /* AccessibilityModifier */) { - var constructor = ts.forEach(container.members, function (member) { - return member.kind === 150 /* Constructor */ && member; - }); - if (constructor) { - nodes = nodes.concat(constructor.parameters); - } - } - else if (modifierFlag & 128 /* Abstract */) { - nodes = nodes.concat(container); - } - break; - default: - ts.Debug.fail("Invalid container kind."); - } - ts.forEach(nodes, function (node) { - if (ts.getModifierFlags(node) & modifierFlag) { - ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - function getFlagFromModifier(modifier) { - switch (modifier) { - case 113 /* PublicKeyword */: - return 4 /* Public */; - case 111 /* PrivateKeyword */: - return 8 /* Private */; - case 112 /* ProtectedKeyword */: - return 16 /* Protected */; - case 114 /* StaticKeyword */: - return 32 /* Static */; - case 83 /* ExportKeyword */: - return 1 /* Export */; - case 123 /* DeclareKeyword */: - return 2 /* Ambient */; - case 116 /* AbstractKeyword */: - return 128 /* 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, 151 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 152 /* 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, 124 /* GetKeyword */, 133 /* 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, 122 /* ConstructorKeyword */); - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getLoopBreakContinueOccurrences(loopNode) { - var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87 /* ForKeyword */, 105 /* WhileKeyword */, 80 /* DoKeyword */)) { - // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 209 /* DoStatement */) { - var loopTokens = loopNode.getChildren(); - for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { - break; - } - } - } - } - var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */, 76 /* ContinueKeyword */); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { - var owner = getBreakOrContinueOwner(breakOrContinueStatement); - if (owner) { - switch (owner.kind) { - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - return getLoopBreakContinueOccurrences(owner); - case 218 /* SwitchStatement */: - return getSwitchCaseDefaultOccurrences(owner); - } - } - return undefined; - } - function getSwitchCaseDefaultOccurrences(switchStatement) { - var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 97 /* SwitchKeyword */); - // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. - ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 72 /* CaseKeyword */, 78 /* DefaultKeyword */); - var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */); - } - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getTryCatchFinallyOccurrences(tryStatement) { - var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 101 /* TryKeyword */); - if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73 /* CatchKeyword */); + // Exceptions thrown within a try block lacking a catch clause + // are "owned" in the current context. + aggregate(tryStatement.tryBlock); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 86 /* FinallyKeyword */); + aggregate(tryStatement.finallyBlock); } - 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(), 99 /* ThrowKeyword */); - }); - // If the "owner" is a function, then we equate 'return' and 'throw' statements in their - // ability to "jump out" of the function, and include occurrences for both. - if (ts.isFunctionBlock(owner)) { - ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* 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, 204 /* Block */))) { - return undefined; - } - var keywords = []; - ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); - }); - // Include 'throw' statements that do not occur within a try block. - ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* ThrowKeyword */); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getIfElseOccurrences(ifStatement) { - var keywords = []; - // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 208 /* 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], 89 /* IfKeyword */); - // Generally the 'else' keyword is second-to-last, so we traverse backwards. - for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 81 /* ElseKeyword */)) { - break; - } - } - if (!hasKind(ifStatement.elseStatement, 208 /* 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 === 81 /* ElseKeyword */ && i < keywords.length - 1) { - var elseKeyword = keywords[i]; - var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. - var shouldCombindElseAndIf = true; - // Avoid recalculating getStart() by iterating backwards. - for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { - if (!ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { - shouldCombindElseAndIf = false; - break; - } - } - if (shouldCombindElseAndIf) { - result.push({ - fileName: fileName, - textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: ts.HighlightSpanKind.reference - }); - i++; // skip the next keyword - continue; - } - } - // Ordinary case: just highlight the keyword. - result.push(getHighlightSpanForNode(keywords[i])); - } - return result; + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); } } } - DocumentHighlights.getDocumentHighlights = getDocumentHighlights; + /** + * 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_2 = child.parent; + if (ts.isFunctionBlock(parent_2) || parent_2.kind === 264 /* SourceFile */) { + return parent_2; + } + // 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_2.kind === 223 /* TryStatement */) { + var tryStatement = parent_2; + if (tryStatement.tryBlock === child && tryStatement.catchClause) { + return child; + } + } + child = parent_2; + } + return undefined; + } + function aggregateAllBreakAndContinueStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 217 /* BreakStatement */ || node.kind === 216 /* 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 = statement.parent; node; node = node.parent) { + switch (node.kind) { + case 220 /* SwitchStatement */: + if (statement.kind === 216 /* ContinueStatement */) { + continue; + } + // Fall through. + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 212 /* WhileStatement */: + case 211 /* DoStatement */: + if (!statement.label || isLabeledBy(node, statement.label.text)) { + return node; + } + break; + default: + // Don't cross function boundaries. + if (ts.isFunctionLike(node)) { + 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 === 228 /* ClassDeclaration */ || + container.kind === 198 /* ClassExpression */ || + (declaration.kind === 145 /* Parameter */ && hasKind(container, 151 /* Constructor */)))) { + return undefined; + } + } + else if (modifier === 114 /* StaticKeyword */) { + if (!(container.kind === 228 /* ClassDeclaration */ || container.kind === 198 /* ClassExpression */)) { + return undefined; + } + } + else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { + if (!(container.kind === 233 /* ModuleBlock */ || container.kind === 264 /* SourceFile */)) { + return undefined; + } + } + else if (modifier === 116 /* AbstractKeyword */) { + if (!(container.kind === 228 /* ClassDeclaration */ || declaration.kind === 228 /* ClassDeclaration */)) { + return undefined; + } + } + else { + // unsupported modifier + return undefined; + } + var keywords = []; + var modifierFlag = getFlagFromModifier(modifier); + var nodes; + switch (container.kind) { + case 233 /* ModuleBlock */: + case 264 /* SourceFile */: + // Container is either a class declaration or the declaration is a classDeclaration + if (modifierFlag & 128 /* Abstract */) { + nodes = declaration.members.concat(declaration); + } + else { + nodes = container.statements; + } + break; + case 151 /* Constructor */: + nodes = container.parameters.concat(container.parent.members); + break; + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + nodes = container.members; + // If we're an accessibility modifier, we're in an instance member and should search + // the constructor's parameter list for instance members as well. + if (modifierFlag & 28 /* AccessibilityModifier */) { + var constructor = ts.forEach(container.members, function (member) { + return member.kind === 151 /* Constructor */ && member; + }); + if (constructor) { + nodes = nodes.concat(constructor.parameters); + } + } + else if (modifierFlag & 128 /* Abstract */) { + nodes = nodes.concat(container); + } + break; + default: + ts.Debug.fail("Invalid container kind."); + } + ts.forEach(nodes, function (node) { + if (ts.getModifierFlags(node) & modifierFlag) { + ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); + } + }); + return keywords; + function getFlagFromModifier(modifier) { + switch (modifier) { + case 113 /* PublicKeyword */: + return 4 /* Public */; + case 111 /* PrivateKeyword */: + return 8 /* Private */; + case 112 /* ProtectedKeyword */: + return 16 /* Protected */; + case 114 /* StaticKeyword */: + return 32 /* Static */; + case 83 /* ExportKeyword */: + return 1 /* Export */; + case 123 /* DeclareKeyword */: + return 2 /* Ambient */; + case 116 /* AbstractKeyword */: + return 128 /* 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, 152 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 153 /* SetAccessor */); + return keywords; + function tryPushAccessorKeyword(accessorSymbol, accessorKind) { + var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); + if (accessor) { + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124 /* GetKeyword */, 134 /* 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, 122 /* ConstructorKeyword */); + }); + }); + return keywords; + } + function getLoopBreakContinueOccurrences(loopNode) { + var keywords = []; + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87 /* ForKeyword */, 105 /* WhileKeyword */, 80 /* DoKeyword */)) { + // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. + if (loopNode.kind === 211 /* DoStatement */) { + var loopTokens = loopNode.getChildren(); + for (var i = loopTokens.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { + break; + } + } + } + } + var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(loopNode, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */, 76 /* ContinueKeyword */); + } + }); + return keywords; + } + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { + var owner = getBreakOrContinueOwner(breakOrContinueStatement); + if (owner) { + switch (owner.kind) { + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + return getLoopBreakContinueOccurrences(owner); + case 220 /* SwitchStatement */: + return getSwitchCaseDefaultOccurrences(owner); + } + } + return undefined; + } + function getSwitchCaseDefaultOccurrences(switchStatement) { + var keywords = []; + pushKeywordIf(keywords, switchStatement.getFirstToken(), 97 /* SwitchKeyword */); + // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. + ts.forEach(switchStatement.caseBlock.clauses, function (clause) { + pushKeywordIf(keywords, clause.getFirstToken(), 72 /* CaseKeyword */, 78 /* DefaultKeyword */); + var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(switchStatement, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */); + } + }); + }); + return keywords; + } + function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { + var keywords = []; + pushKeywordIf(keywords, tryStatement.getFirstToken(), 101 /* TryKeyword */); + if (tryStatement.catchClause) { + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73 /* CatchKeyword */); + } + if (tryStatement.finallyBlock) { + var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 86 /* FinallyKeyword */); + } + return keywords; + } + function getThrowOccurrences(throwStatement) { + var owner = getThrowStatementOwner(throwStatement); + if (!owner) { + return undefined; + } + var keywords = []; + ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* ThrowKeyword */); + }); + // If the "owner" is a function, then we equate 'return' and 'throw' statements in their + // ability to "jump out" of the function, and include occurrences for both. + if (ts.isFunctionBlock(owner)) { + ts.forEachReturnStatement(owner, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); + }); + } + return keywords; + } + 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, 206 /* Block */))) { + return undefined; + } + var keywords = []; + ts.forEachReturnStatement(func.body, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); + }); + // Include 'throw' statements that do not occur within a try block. + ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* ThrowKeyword */); + }); + return keywords; + } + function getIfElseOccurrences(ifStatement, sourceFile) { + var keywords = []; + // Traverse upwards through all parent if-statements linked by their else-branches. + while (hasKind(ifStatement.parent, 210 /* 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], 89 /* IfKeyword */); + // Generally the 'else' keyword is second-to-last, so we traverse backwards. + for (var i = children.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, children[i], 81 /* ElseKeyword */)) { + break; + } + } + if (!hasKind(ifStatement.elseStatement, 210 /* 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 === 81 /* ElseKeyword */ && i < keywords.length - 1) { + var elseKeyword = keywords[i]; + var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. + var shouldCombindElseAndIf = true; + // Avoid recalculating getStart() by iterating backwards. + for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { + if (!ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { + shouldCombindElseAndIf = false; + break; + } + } + if (shouldCombindElseAndIf) { + result.push({ + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), + kind: ts.HighlightSpanKind.reference + }); + i++; // skip the next keyword + continue; + } + } + // Ordinary case: just highlight the keyword. + result.push(getHighlightSpanForNode(keywords[i], sourceFile)); + } + return result; + } /** * 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 === 219 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 221 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -69386,15 +71615,15 @@ var ts; return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + "|" + settings.allowJs + "|" + settings.baseUrl + "|" + JSON.stringify(settings.typeRoots) + "|" + JSON.stringify(settings.rootDirs) + "|" + JSON.stringify(settings.paths); } function getBucketForCompilationSettings(key, createIfMissing) { - var bucket = buckets[key]; + var bucket = buckets.get(key); if (!bucket && createIfMissing) { - buckets[key] = bucket = ts.createFileMap(); + buckets.set(key, bucket = ts.createFileMap()); } return bucket; } function reportStats() { - var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { - var entries = buckets[name]; + var bucketInfoArray = ts.arrayFrom(buckets.keys()).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { + var entries = buckets.get(name); var sourceFiles = []; entries.forEachValue(function (key, entry) { sourceFiles.push({ @@ -69492,57 +71721,30 @@ var ts; (function (ts) { var FindAllReferences; (function (FindAllReferences) { - function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments) { + function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments, isForRename) { var node = ts.getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); - if (node === sourceFile) { - return undefined; - } - switch (node.kind) { - case 8 /* NumericLiteral */: - if (!ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - break; - } - // Fallthrough - case 70 /* Identifier */: - case 98 /* ThisKeyword */: - // case SyntaxKind.SuperKeyword: TODO:GH#9268 - case 122 /* ConstructorKeyword */: - case 9 /* StringLiteral */: - return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, /*implementations*/ false); - } - return undefined; + return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename); } FindAllReferences.findReferencedSymbols = findReferencedSymbols; - function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, implementations) { + function convertReferences(referenceSymbols) { + return referenceSymbols && ts.flatMap(referenceSymbols, function (r) { return r.references; }); + } + FindAllReferences.convertReferences = convertReferences; + function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename, implementations) { if (!implementations) { - // Labels - if (ts.isLabelName(node)) { - if (ts.isJumpStatementTarget(node)) { - var labelDefinition = ts.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 (ts.isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles); - } - if (node.kind === 96 /* SuperKeyword */) { - return getReferencesForSuperKeyword(node); + var special = getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken); + if (special) { + return special; } } // `getSymbolAtLocation` normally returns the symbol of the class when given the constructor keyword, // so we have to specify that we want the constructor symbol. var symbol = typeChecker.getSymbolAtLocation(node); - if (!implementations && !symbol && node.kind === 9 /* StringLiteral */) { - return getReferencesForStringLiteral(node, sourceFiles); - } // Could not find a symbol e.g. unknown identifier if (!symbol) { + if (!implementations && node.kind === 9 /* StringLiteral */) { + return getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken); + } // Can't have references to something that we have no symbol for. return undefined; } @@ -69551,1040 +71753,1120 @@ var ts; if (!declarations || !declarations.length) { return undefined; } - var result; + var _a = followAliases(symbol, node, typeChecker, isForRename), aliasedSymbol = _a.symbol, shorthandModuleSymbol = _a.shorthandModuleSymbol; + symbol = aliasedSymbol; + // Build the set of symbols to search for, initially it has only the current symbol + var searchSymbols = populateSearchSymbolSet(symbol, node, typeChecker, implementations); + if (shorthandModuleSymbol) { + searchSymbols.push(shorthandModuleSymbol); + } // Compute the meaning from the location and the symbol it references var searchMeaning = getIntersectingMeaningFromDeclarations(ts.getMeaningFromLocation(node), declarations); + var result = []; + // Maps from a symbol ID to the ReferencedSymbol entry in 'result'. + var symbolToIndex = []; + var inheritsFromCache = ts.createMap(); // 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); + getRefs(scope, declaredName); } else { - var internedName = getInternedName(symbol, node); - for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { - var sourceFile = sourceFiles_8[_i]; + var isDefault = ts.isExportDefaultSymbol(symbol); + var internedName = isDefault ? symbol.valueDeclaration.localSymbol.name : getInternedName(symbol, node); + for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { + var sourceFile = sourceFiles_5[_i]; cancellationToken.throwIfCancellationRequested(); - var nameTable = ts.getNameTable(sourceFile); - if (nameTable[internedName] !== undefined) { - result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + var searchName = (isDefault ? getDefaultImportName(symbol, sourceFile, typeChecker) : undefined) || + (sourceFileHasName(sourceFile, internedName) ? declaredName : undefined); + if (searchName !== undefined) { + getRefs(sourceFile, searchName); } } } return result; - function getDefinition(symbol) { - var info = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.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), - displayParts: info.displayParts - }; + function getRefs(scope, searchName) { + getReferencesInNode(scope, symbol, searchName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache); } - function getAliasSymbolForPropertyNameSymbol(symbol, location) { - if (symbol.flags & 8388608 /* Alias */) { - // Default import get alias - var defaultImport = ts.getDeclarationOfKind(symbol, 236 /* ImportClause */); - if (defaultImport) { - return typeChecker.getAliasedSymbol(symbol); - } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 239 /* ImportSpecifier */ || - declaration.kind === 243 /* ExportSpecifier */) ? declaration : undefined; }); - if (importOrExportSpecifier && - // export { a } - (!importOrExportSpecifier.propertyName || - // export {a as class } where a is location - importOrExportSpecifier.propertyName === location)) { - // If Import specifier -> get alias - // else Export specifier -> get local target - return importOrExportSpecifier.kind === 239 /* ImportSpecifier */ ? - typeChecker.getAliasedSymbol(symbol) : - typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); - } + } + FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; + /** getReferencedSymbols for special node kinds. */ + function getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken) { + if (ts.isTypeKeyword(node.kind)) { + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + } + // Labels + if (ts.isLabelName(node)) { + if (ts.isJumpStatementTarget(node)) { + var labelDefinition = ts.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, cancellationToken); } + else { + // it is a label definition and not a target, search within the parent labeledStatement + return getLabelReferencesInNode(node.parent, node, cancellationToken); + } + } + if (ts.isThis(node)) { + return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken); + } + if (node.kind === 96 /* SuperKeyword */) { + return getReferencesForSuperKeyword(node, typeChecker, cancellationToken); + } + return undefined; + } + /** + * Follows aliases to get to the original declaration of a symbol. + * For a shorthand ambient module, we don't follow the alias to it, but we will need to add it to the set of search symbols. + */ + function followAliases(symbol, node, typeChecker, isForRename) { + while (true) { + // When renaming a default import, only rename in the current file + if (isForRename && isImportDefaultSymbol(symbol)) { + return { symbol: symbol }; + } + var aliasedSymbol = getAliasSymbolForPropertyNameSymbol(symbol, node, typeChecker); + // Don't follow alias if it goes to unknown symbol. This can happen if it points to an untyped module. + if (!aliasedSymbol || !aliasedSymbol.declarations) { + return { symbol: symbol }; + } + if (ts.isShorthandAmbientModuleSymbol(aliasedSymbol)) { + return { symbol: symbol, shorthandModuleSymbol: aliasedSymbol }; + } + symbol = aliasedSymbol; + } + } + function sourceFileHasName(sourceFile, name) { + return ts.getNameTable(sourceFile).get(name) !== undefined; + } + /** + * Given a symbol, see if any of the imports in a source file reference it. + * Only call this if `symbol` is a default export. + */ + function getDefaultImportName(symbol, sourceFile, checker) { + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var importSpecifier = _a[_i]; + var importDecl = importSpecifier.parent; + ts.Debug.assert(importDecl.moduleSpecifier === importSpecifier); + var defaultName = importDecl.importClause.name; + var defaultReferencedSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName)); + if (symbol === defaultReferencedSymbol) { + return defaultName.text; + } + } + return undefined; + } + function getDefinition(symbol, node, typeChecker) { + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.getContainerNode(node), node), displayParts = _a.displayParts, symbolKind = _a.symbolKind; + var name = displayParts.map(function (p) { return p.text; }).join(""); + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { return undefined; } - function followAliasIfNecessary(symbol, location) { - return getAliasSymbolForPropertyNameSymbol(symbol, location) || symbol; - } - function getPropertySymbolOfDestructuringAssignment(location) { - return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - typeChecker.getPropertySymbolOfDestructuringAssignment(location); - } - function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 174 /* BindingElement */); - return bindingElement && - bindingElement.parent.kind === 172 /* ObjectBindingPattern */ && - !bindingElement.propertyName; - } - function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 174 /* BindingElement */); - var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); - return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); - } + return { + containerKind: "", + containerName: "", + name: name, + kind: symbolKind, + fileName: declarations[0].getSourceFile().fileName, + textSpan: ts.createTextSpan(declarations[0].getStart(), 0), + displayParts: displayParts + }; + } + function getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) { + if (!(symbol.flags & 8388608 /* Alias */)) { return undefined; } - function getInternedName(symbol, location) { - // If this is an export or import specifier it could have been renamed using the 'as' syntax. - // If so we want to search for whatever under the cursor. - if (ts.isImportOrExportSpecifierName(location)) { - 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); + // Default import get alias + var defaultImport = ts.getDeclarationOfKind(symbol, 238 /* ImportClause */); + if (defaultImport) { + return typeChecker.getAliasedSymbol(symbol); } - /** - * 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 === 184 /* FunctionExpression */ || valueDeclaration.kind === 197 /* ClassExpression */)) { - return valueDeclaration; - } - // If this is private property or method, the scope is the containing class - if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8 /* Private */) ? d : undefined; }); - if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 226 /* ClassDeclaration */); - } - } - // If the symbol is an import we would like to find it if we are looking for what it imports. - // So consider it visible outside its declaration scope. - if (symbol.flags & 8388608 /* Alias */) { - return undefined; - } - // If symbol is of object binding pattern element without property name we would want to - // look for property too and that could be anywhere - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - 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; - var declarations = symbol.getDeclarations(); - if (declarations) { - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; - var container = ts.getContainerNode(declaration); - if (!container) { - return undefined; - } - if (scope && scope !== container) { - // Different declarations have different containers, bail out - return undefined; - } - if (container.kind === 261 /* 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; + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 241 /* ImportSpecifier */ || + declaration.kind === 245 /* ExportSpecifier */) ? declaration : undefined; }); + if (importOrExportSpecifier && + // export { a } + (!importOrExportSpecifier.propertyName || + // export {a as class } where a is location + importOrExportSpecifier.propertyName === location)) { + // If Import specifier -> get alias + // else Export specifier -> get local target + return importOrExportSpecifier.kind === 241 /* ImportSpecifier */ ? + typeChecker.getAliasedSymbol(symbol) : + typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } - 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; + } + function followAliasIfNecessary(symbol, location, typeChecker) { + return getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) || symbol; + } + function getPropertySymbolOfDestructuringAssignment(location, typeChecker) { + return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && + typeChecker.getPropertySymbolOfDestructuringAssignment(location); + } + function isObjectBindingPatternElementWithoutPropertyName(symbol) { + var bindingElement = ts.getDeclarationOfKind(symbol, 175 /* BindingElement */); + return bindingElement && + bindingElement.parent.kind === 173 /* ObjectBindingPattern */ && + !bindingElement.propertyName; + } + function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker) { + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + var bindingElement = ts.getDeclarationOfKind(symbol, 175 /* BindingElement */); + var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); + return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + } + return undefined; + } + function getInternedName(symbol, location) { + // If this is an export or import specifier it could have been renamed using the 'as' syntax. + // If so we want to search for whatever under the cursor. + if (ts.isImportOrExportSpecifierName(location)) { + return location.text; + } + 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 === 185 /* FunctionExpression */ || valueDeclaration.kind === 198 /* ClassExpression */)) { + return valueDeclaration; + } + // If this is private property or method, the scope is the containing class + if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { + var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8 /* Private */) ? d : undefined; }); + if (privateDeclaration) { + return ts.getAncestor(privateDeclaration, 228 /* ClassDeclaration */); } - 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), 5 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5 /* Latest */))) { - // Found a real match. Keep searching. - positions.push(position); + } + // If the symbol is an import we would like to find it if we are looking for what it imports. + // So consider it visible outside its declaration scope. + if (symbol.flags & 8388608 /* Alias */) { + return undefined; + } + // If symbol is of object binding pattern element without property name we would want to + // look for property too and that could be anywhere + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + 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 & 134217728 /* Transient */ && symbol.checkFlags & 2 /* SyntheticProperty */)) { + return undefined; + } + var scope; + var declarations = symbol.getDeclarations(); + if (declarations) { + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; + var container = ts.getContainerNode(declaration); + if (!container) { + return undefined; } - position = text.indexOf(symbolName, position + symbolNameLength + 1); + if (scope && scope !== container) { + // Different declarations have different containers, bail out + return undefined; + } + if (container.kind === 264 /* 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, cancellationToken) { + 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; } - 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 || - (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ts.ScriptElementKind.label, - name: labelName, - textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()), - displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] - }; - return [{ definition: definition, references: references }]; + 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), 5 /* Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5 /* Latest */))) { + // Found a real match. Keep searching. + positions.push(position); + } + position = text.indexOf(symbolName, position + symbolNameLength + 1); } - 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 70 /* Identifier */: - return node.getWidth() === searchSymbolName.length; - case 9 /* StringLiteral */: - if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isNameOfExternalModuleImportOrDeclaration(node)) { - // For string literals we have two additional chars for the quotes - return node.getWidth() === searchSymbolName.length + 2; + return positions; + } + function getLabelReferencesInNode(container, targetLabel, cancellationToken) { + var references = []; + var sourceFile = container.getSourceFile(); + var labelName = targetLabel.text; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd(), cancellationToken); + 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 || + (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { + references.push(getReferenceEntryFromNode(node)); + } + }); + var definition = { + containerKind: "", + containerName: "", + fileName: targetLabel.getSourceFile().fileName, + kind: ts.ScriptElementKind.label, + name: labelName, + textSpan: ts.createTextSpanFromNode(targetLabel, sourceFile), + displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] + }; + return [{ definition: definition, references: references }]; + } + function isValidReferencePosition(node, searchSymbolName) { + // Compare the length so we filter out strict superstrings of the symbol we are looking for + switch (node && node.kind) { + case 70 /* Identifier */: + return node.getWidth() === searchSymbolName.length; + case 9 /* StringLiteral */: + return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && + // For string literals we have two additional chars for the quotes + node.getWidth() === searchSymbolName.length + 2; + case 8 /* NumericLiteral */: + return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; + default: + return false; + } + } + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + var name = ts.tokenToString(keywordKind); + var references = []; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var sourceFile = sourceFiles_6[_i]; + cancellationToken.throwIfCancellationRequested(); + addReferencesForKeywordInFile(sourceFile, keywordKind, name, cancellationToken, references); + } + if (!references.length) + return undefined; + var definition = { + containerKind: "", + containerName: "", + fileName: references[0].fileName, + kind: ts.ScriptElementKind.keyword, + name: name, + textSpan: references[0].textSpan, + displayParts: [{ text: name, kind: ts.ScriptElementKind.keyword }] + }; + return [{ definition: definition, references: references }]; + } + function addReferencesForKeywordInFile(sourceFile, kind, searchText, cancellationToken, references) { + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { + var position = possiblePositions_1[_i]; + cancellationToken.throwIfCancellationRequested(); + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (referenceLocation.kind === kind) { + references.push({ + textSpan: ts.createTextSpanFromNode(referenceLocation), + fileName: sourceFile.fileName, + isWriteAccess: false, + isDefinition: 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, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache) { + var sourceFile = container.getSourceFile(); + var start = findInComments ? container.getFullStart() : container.getStart(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd(), cancellationToken); + var parents = getParentSymbolsOfPropertyAccess(); + for (var _i = 0, possiblePositions_2 = possiblePositions; _i < possiblePositions_2.length; _i++) { + var position = possiblePositions_2[_i]; + cancellationToken.throwIfCancellationRequested(); + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (!isValidReferencePosition(referenceLocation, searchText)) { + // This wasn't the start of a token. Check to see if it might be a + // match in a comment or string if that's what the caller is asking + // for. + if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || + (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { + // In the case where we're looking inside comments/strings, we don't have + // an actual definition. So just use 'undefined' here. Features like + // 'Rename' won't care (as they ignore the definitions), and features like + // 'FindReferences' will just filter out these results. + result.push({ + definition: undefined, + references: [{ + fileName: sourceFile.fileName, + textSpan: ts.createTextSpan(position, searchText.length), + isWriteAccess: false, + isDefinition: false + }] + }); + } + continue; + } + if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { + continue; + } + var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); + if (referenceSymbol) { + var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); + var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, + /*searchLocationIsConstructor*/ searchLocation.kind === 122 /* ConstructorKeyword */, parents, inheritsFromCache, typeChecker); + if (relatedSymbol) { + addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); + } + else if (!(referenceSymbol.flags & 134217728 /* Transient */) && ts.contains(searchSymbols, shorthandValueSymbol)) { + addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); + } + else if (searchLocation.kind === 122 /* ConstructorKeyword */) { + findAdditionalConstructorReferences(referenceSymbol, referenceLocation); + } + } + } + return; + /* If we are just looking for implementations and this is a property access expression, we need to get the + * symbol of the local type of the symbol the property is being accessed on. This is because our search + * symbol may have a different parent symbol if the local type's symbol does not declare the property + * being accessed (i.e. it is declared in some parent class or interface) + */ + function getParentSymbolsOfPropertyAccess() { + if (implementations) { + var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); + if (propertyAccessExpression) { + var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); + if (localParentType) { + if (localParentType.symbol && localParentType.symbol.flags & (32 /* Class */ | 64 /* Interface */) && localParentType.symbol !== searchSymbol.parent) { + return [localParentType.symbol]; } - break; - case 8 /* NumericLiteral */: - if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - return node.getWidth() === searchSymbolName.length; + else if (localParentType.flags & 196608 /* UnionOrIntersection */) { + return getSymbolsForClassAndInterfaceComponents(localParentType); } - break; + } + } + } + } + /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ + function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { + ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); + var referenceClass = referenceLocation.parent; + if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { + ts.Debug.assert(referenceClass.name === referenceLocation); + // This is the class declaration containing the constructor. + addReferences(findOwnConstructorCalls(searchSymbol, sourceFile)); + } + else { + // If this class appears in `extends C`, then the extending class' "super" calls are references. + var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); + if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation, typeChecker) === searchSymbol) { + addReferences(superConstructorAccesses(classExtending)); + } + } + } + function addReferences(references) { + if (references.length) { + var referencedSymbol = getReferencedSymbol(searchSymbol); + ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); + } + } + 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, searchLocation, typeChecker), + references: [] + }); + } + return result[index]; + } + function addReferenceToRelatedSymbol(node, relatedSymbol) { + var references = getReferencedSymbol(relatedSymbol).references; + if (implementations) { + getImplementationReferenceEntryForNode(node, references, typeChecker); + } + else { + references.push(getReferenceEntryFromNode(node)); + } + } + } + function getPropertyAccessExpressionFromRightHandSide(node) { + return ts.isRightSideOfPropertyAccess(node) && node.parent; + } + /** `classSymbol` is the class where the constructor was defined. + * Reference the constructor and all calls to `new this()`. + */ + function findOwnConstructorCalls(classSymbol, sourceFile) { + var result = []; + for (var _i = 0, _a = classSymbol.members.get("__constructor").declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var ctrKeyword = ts.findChildOfKind(decl, 122 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 151 /* Constructor */ && !!ctrKeyword); + result.push(ctrKeyword); + } + classSymbol.exports.forEach(function (member) { + var decl = member.valueDeclaration; + if (decl && decl.kind === 150 /* MethodDeclaration */) { + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 98 /* ThisKeyword */, function (thisKeyword) { + if (ts.isNewExpressionTarget(thisKeyword)) { + result.push(thisKeyword); + } + }); + } + } + }); + return result; + } + /** Find references to `super` in the constructor of an extending class. */ + function superConstructorAccesses(cls) { + var symbol = cls.symbol; + var ctr = symbol.members.get("__constructor"); + if (!ctr) { + return []; + } + var result = []; + for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.Debug.assert(decl.kind === 151 /* Constructor */); + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 96 /* SuperKeyword */, function (node) { + if (ts.isCallExpressionTarget(node)) { + result.push(node); + } + }); + } + } + ; + return result; + } + function getImplementationReferenceEntryForNode(refNode, result, typeChecker) { + // Check if we found a function/propertyAssignment/method with an implementation or initializer + if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { + result.push(getReferenceEntryFromNode(refNode.parent)); + } + else if (refNode.kind === 70 /* Identifier */) { + if (refNode.parent.kind === 261 /* ShorthandPropertyAssignment */) { + // Go ahead and dereference the shorthand assignment by going to its definition + getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); + } + // Check if the node is within an extends or implements clause + var containingClass = getContainingClassIfInHeritageClause(refNode); + if (containingClass) { + result.push(getReferenceEntryFromNode(containingClass)); + return; + } + // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface + var containingTypeReference = getContainingTypeReference(refNode); + if (containingTypeReference) { + var parent = containingTypeReference.parent; + if (ts.isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent.initializer)); + } + else if (ts.isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { + if (parent.body.kind === 206 /* Block */) { + ts.forEachReturnStatement(parent.body, function (returnStatement) { + if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { + maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); + } + }); + } + else if (isImplementationExpression(parent.body)) { + maybeAdd(getReferenceEntryFromNode(parent.body)); + } + } + else if (ts.isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { + maybeAdd(getReferenceEntryFromNode(parent.expression)); + } + } + } + // Type nodes can contain multiple references to the same type. For example: + // let x: Foo & (Foo & Bar) = ... + // Because we are returning the implementation locations and not the identifier locations, + // duplicate entries would be returned here as each of the type references is part of + // the same implementation. For that reason, check before we add a new entry + function maybeAdd(a) { + if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { + result.push(a); + } + } + } + function getSymbolsForClassAndInterfaceComponents(type, result) { + if (result === void 0) { result = []; } + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var componentType = _a[_i]; + if (componentType.symbol && componentType.symbol.getFlags() & (32 /* Class */ | 64 /* Interface */)) { + result.push(componentType.symbol); + } + if (componentType.getFlags() & 196608 /* UnionOrIntersection */) { + getSymbolsForClassAndInterfaceComponents(componentType, result); + } + } + return result; + } + function getContainingTypeReference(node) { + var topLevelTypeReference = undefined; + while (node) { + if (ts.isTypeNode(node)) { + topLevelTypeReference = node; + } + node = node.parent; + } + return topLevelTypeReference; + } + function getContainingClassIfInHeritageClause(node) { + if (node && node.parent) { + if (node.kind === 200 /* ExpressionWithTypeArguments */ + && node.parent.kind === 258 /* HeritageClause */ + && ts.isClassLike(node.parent.parent)) { + return node.parent.parent; + } + else if (node.kind === 70 /* Identifier */ || node.kind === 178 /* PropertyAccessExpression */) { + return getContainingClassIfInHeritageClause(node.parent); + } + } + return undefined; + } + /** + * Returns true if this is an expression that can be considered an implementation + */ + function isImplementationExpression(node) { + switch (node.kind) { + case 184 /* ParenthesizedExpression */: + return isImplementationExpression(node.expression); + case 186 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 177 /* ObjectLiteralExpression */: + case 198 /* ClassExpression */: + case 176 /* ArrayLiteralExpression */: + return true; + default: + return false; + } + } + /** + * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol + * is an interface, determines if some ancestor of the child symbol extends or inherits from it. + * Also takes in a cache of previous results which makes this slightly more efficient and is + * necessary to avoid potential loops like so: + * class A extends B { } + * class B extends A { } + * + * We traverse the AST rather than using the type checker because users are typically only interested + * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling + * implementations of types that share a common ancestor with the type whose implementation we are + * searching for need to be filtered out of the results. The type checker doesn't let us make the + * distinction between structurally compatible implementations and explicit implementations, so we + * must use the AST. + * + * @param child A class or interface Symbol + * @param parent Another class or interface Symbol + * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results + */ + function explicitlyInheritsFrom(child, parent, cachedResults, typeChecker) { + var parentIsInterface = parent.getFlags() & 64 /* Interface */; + return searchHierarchy(child); + function searchHierarchy(symbol) { + if (symbol === parent) { + return true; + } + var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); + var cached = cachedResults.get(key); + if (cached !== undefined) { + return cached; + } + // Set the key so that we don't infinitely recurse + cachedResults.set(key, false); + var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + if (parentIsInterface) { + var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); + if (interfaceReferences) { + for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { + var typeReference = interfaceReferences_1[_i]; + if (searchTypeReference(typeReference)) { + return true; + } + } + } + } + return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + } + else if (declaration.kind === 229 /* InterfaceDeclaration */) { + if (parentIsInterface) { + return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); + } + } + return false; + }); + cachedResults.set(key, inherits); + return inherits; + } + function searchTypeReference(typeReference) { + if (typeReference) { + var type = typeChecker.getTypeAtLocation(typeReference); + if (type && type.symbol) { + return searchHierarchy(type.symbol); } } 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 start = findInComments ? container.getFullStart() : container.getStart(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd()); - var parents = getParentSymbolsOfPropertyAccess(); - var inheritsFromCache = ts.createMap(); - if (possiblePositions.length) { - // Build the set of symbols to search for, initially it has only the current symbol - var searchSymbols_1 = populateSearchSymbolSet(searchSymbol, searchLocation); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); - if (!isValidReferencePosition(referenceLocation, searchText)) { - // This wasn't the start of a token. Check to see if it might be a - // match in a comment or string if that's what the caller is asking - // for. - if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || - (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { - // In the case where we're looking inside comments/strings, we don't have - // an actual definition. So just use 'undefined' here. Features like - // 'Rename' won't care (as they ignore the definitions), and features like - // 'FindReferences' will just filter out these results. - result.push({ - definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: ts.createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] - }); - } - return; - } - if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { - return; - } - var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); - if (referenceSymbol) { - var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, - /*searchLocationIsConstructor*/ searchLocation.kind === 122 /* ConstructorKeyword */, parents, inheritsFromCache); - if (relatedSymbol) { - addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); - } - else if (!(referenceSymbol.flags & 67108864 /* Transient */) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { - addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); - } - else if (searchLocation.kind === 122 /* ConstructorKeyword */) { - findAdditionalConstructorReferences(referenceSymbol, referenceLocation); - } - } - }); - } - return; - /* If we are just looking for implementations and this is a property access expression, we need to get the - * symbol of the local type of the symbol the property is being accessed on. This is because our search - * symbol may have a different parent symbol if the local type's symbol does not declare the property - * being accessed (i.e. it is declared in some parent class or interface) - */ - function getParentSymbolsOfPropertyAccess() { - if (implementations) { - var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); - if (propertyAccessExpression) { - var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); - if (localParentType) { - if (localParentType.symbol && localParentType.symbol.flags & (32 /* Class */ | 64 /* Interface */) && localParentType.symbol !== searchSymbol.parent) { - return [localParentType.symbol]; - } - else if (localParentType.flags & 196608 /* UnionOrIntersection */) { - return getSymbolsForClassAndInterfaceComponents(localParentType); - } - } - } - } - } - function getPropertyAccessExpressionFromRightHandSide(node) { - return ts.isRightSideOfPropertyAccess(node) && node.parent; - } - /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ - function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { - ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); - var referenceClass = referenceLocation.parent; - if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { - ts.Debug.assert(referenceClass.name === referenceLocation); - // This is the class declaration containing the constructor. - addReferences(findOwnConstructorCalls(searchSymbol)); - } - else { - // If this class appears in `extends C`, then the extending class' "super" calls are references. - var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); - if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation) === searchSymbol) { - addReferences(superConstructorAccesses(classExtending)); - } - } - } - function addReferences(references) { - if (references.length) { - var referencedSymbol = getReferencedSymbol(searchSymbol); - ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); - } - } - /** `classSymbol` is the class where the constructor was defined. - * Reference the constructor and all calls to `new this()`. - */ - function findOwnConstructorCalls(classSymbol) { - var result = []; - for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 150 /* Constructor */); - var ctrKeyword = decl.getChildAt(0); - ts.Debug.assert(ctrKeyword.kind === 122 /* ConstructorKeyword */); - result.push(ctrKeyword); - } - ts.forEachProperty(classSymbol.exports, function (member) { - var decl = member.valueDeclaration; - if (decl && decl.kind === 149 /* MethodDeclaration */) { - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 98 /* ThisKeyword */, function (thisKeyword) { - if (ts.isNewExpressionTarget(thisKeyword)) { - result.push(thisKeyword); - } - }); - } - } - }); - return result; - } - /** Find references to `super` in the constructor of an extending class. */ - function superConstructorAccesses(cls) { - var symbol = cls.symbol; - var ctr = symbol.members["__constructor"]; - if (!ctr) { - return []; - } - var result = []; - for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 150 /* Constructor */); - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 96 /* SuperKeyword */, function (node) { - if (ts.isCallExpressionTarget(node)) { - result.push(node); - } - }); - } - } - ; - return result; - } - 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 addReferenceToRelatedSymbol(node, relatedSymbol) { - var references = getReferencedSymbol(relatedSymbol).references; - if (implementations) { - getImplementationReferenceEntryForNode(node, references); - } - else { - references.push(getReferenceEntryFromNode(node)); - } - } - } - function getImplementationReferenceEntryForNode(refNode, result) { - // Check if we found a function/propertyAssignment/method with an implementation or initializer - if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { - result.push(getReferenceEntryFromNode(refNode.parent)); - } - else if (refNode.kind === 70 /* Identifier */) { - if (refNode.parent.kind === 258 /* ShorthandPropertyAssignment */) { - // Go ahead and dereference the shorthand assignment by going to its definition - getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); - } - // Check if the node is within an extends or implements clause - var containingClass = getContainingClassIfInHeritageClause(refNode); - if (containingClass) { - result.push(getReferenceEntryFromNode(containingClass)); - return; - } - // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface - var containingTypeReference = getContainingTypeReference(refNode); - if (containingTypeReference) { - var parent_18 = containingTypeReference.parent; - if (ts.isVariableLike(parent_18) && parent_18.type === containingTypeReference && parent_18.initializer && isImplementationExpression(parent_18.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_18.initializer)); - } - else if (ts.isFunctionLike(parent_18) && parent_18.type === containingTypeReference && parent_18.body) { - if (parent_18.body.kind === 204 /* Block */) { - ts.forEachReturnStatement(parent_18.body, function (returnStatement) { - if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { - maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); - } - }); - } - else if (isImplementationExpression(parent_18.body)) { - maybeAdd(getReferenceEntryFromNode(parent_18.body)); - } - } - else if (ts.isAssertionExpression(parent_18) && isImplementationExpression(parent_18.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_18.expression)); - } - } - } - // Type nodes can contain multiple references to the same type. For example: - // let x: Foo & (Foo & Bar) = ... - // Because we are returning the implementation locations and not the identifier locations, - // duplicate entries would be returned here as each of the type references is part of - // the same implementation. For that reason, check before we add a new entry - function maybeAdd(a) { - if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { - result.push(a); - } - } - } - function getSymbolsForClassAndInterfaceComponents(type, result) { - if (result === void 0) { result = []; } - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var componentType = _a[_i]; - if (componentType.symbol && componentType.symbol.getFlags() & (32 /* Class */ | 64 /* Interface */)) { - result.push(componentType.symbol); - } - if (componentType.getFlags() & 196608 /* UnionOrIntersection */) { - getSymbolsForClassAndInterfaceComponents(componentType, result); - } - } - return result; - } - function getContainingTypeReference(node) { - var topLevelTypeReference = undefined; - while (node) { - if (ts.isTypeNode(node)) { - topLevelTypeReference = node; - } - node = node.parent; - } - return topLevelTypeReference; - } - function getContainingClassIfInHeritageClause(node) { - if (node && node.parent) { - if (node.kind === 199 /* ExpressionWithTypeArguments */ - && node.parent.kind === 255 /* HeritageClause */ - && ts.isClassLike(node.parent.parent)) { - return node.parent.parent; - } - else if (node.kind === 70 /* Identifier */ || node.kind === 177 /* PropertyAccessExpression */) { - return getContainingClassIfInHeritageClause(node.parent); - } - } + } + function getReferencesForSuperKeyword(superKeyword, typeChecker, cancellationToken) { + var searchSpaceNode = ts.getSuperContainer(superKeyword, /*stopOnFunctions*/ false); + if (!searchSpaceNode) { return undefined; } - /** - * Returns true if this is an expression that can be considered an implementation - */ - function isImplementationExpression(node) { - // Unwrap parentheses - if (node.kind === 183 /* ParenthesizedExpression */) { - return isImplementationExpression(node.expression); - } - return node.kind === 185 /* ArrowFunction */ || - node.kind === 184 /* FunctionExpression */ || - node.kind === 176 /* ObjectLiteralExpression */ || - node.kind === 197 /* ClassExpression */ || - node.kind === 175 /* ArrayLiteralExpression */; - } - /** - * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol - * is an interface, determines if some ancestor of the child symbol extends or inherits from it. - * Also takes in a cache of previous results which makes this slightly more efficient and is - * necessary to avoid potential loops like so: - * class A extends B { } - * class B extends A { } - * - * We traverse the AST rather than using the type checker because users are typically only interested - * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling - * implementations of types that share a common ancestor with the type whose implementation we are - * searching for need to be filtered out of the results. The type checker doesn't let us make the - * distinction between structurally compatible implementations and explicit implementations, so we - * must use the AST. - * - * @param child A class or interface Symbol - * @param parent Another class or interface Symbol - * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results - */ - function explicitlyInheritsFrom(child, parent, cachedResults) { - var parentIsInterface = parent.getFlags() & 64 /* Interface */; - return searchHierarchy(child); - function searchHierarchy(symbol) { - if (symbol === parent) { - return true; - } - var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); - if (key in cachedResults) { - return cachedResults[key]; - } - // Set the key so that we don't infinitely recurse - cachedResults[key] = false; - var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - if (parentIsInterface) { - var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); - if (interfaceReferences) { - for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { - var typeReference = interfaceReferences_1[_i]; - if (searchTypeReference(typeReference)) { - return true; - } - } - } - } - return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - } - else if (declaration.kind === 227 /* InterfaceDeclaration */) { - if (parentIsInterface) { - return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); - } - } - return false; - }); - cachedResults[key] = inherits; - return inherits; - } - function searchTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type && type.symbol) { - return searchHierarchy(type.symbol); - } - } - return false; - } - } - function getReferencesForSuperKeyword(superKeyword) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, /*stopOnFunctions*/ false); - if (!searchSpaceNode) { + // Whether 'super' occurs in a static context within a class. + var staticFlag = 32 /* Static */; + switch (searchSpaceNode.kind) { + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + 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(), cancellationToken); + for (var _i = 0, possiblePositions_3 = possiblePositions; _i < possiblePositions_3.length; _i++) { + var position = possiblePositions_3[_i]; + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 96 /* SuperKeyword */) { + continue; } - // Whether 'super' occurs in a static context within a class. - var staticFlag = 32 /* Static */; - switch (searchSpaceNode.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + var container = ts.getSuperContainer(node, /*stopOnFunctions*/ 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 && (32 /* Static */ & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + references.push(getReferenceEntryFromNode(node)); + } + } + var definition = getDefinition(searchSpaceNode.symbol, superKeyword, typeChecker); + return [{ definition: definition, references: references }]; + } + function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, typeChecker, cancellationToken) { + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); + // Whether 'this' occurs in a static context within a class. + var staticFlag = 32 /* Static */; + switch (searchSpaceNode.kind) { + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; - default: + } + // fall through + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + break; + case 264 /* SourceFile */: + if (ts.isExternalModule(searchSpaceNode)) { return undefined; - } - var references = []; + } + // Fall through + case 227 /* FunctionDeclaration */: + case 185 /* 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 === 264 /* SourceFile */) { + ts.forEach(sourceFiles, function (sourceFile) { + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); + } + else { var sourceFile = searchSpaceNode.getSourceFile(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); + } + var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); + var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: thisOrSuperKeyword.getSourceFile().fileName, + kind: ts.ScriptElementKind.variableElement, + name: "this", + textSpan: ts.createTextSpanFromNode(thisOrSuperKeyword), + displayParts: displayParts + }, + 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 !== 96 /* SuperKeyword */) { + if (!node || !ts.isThis(node)) { return; } - var container = ts.getSuperContainer(node, /*stopOnFunctions*/ 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 && (32 /* Static */ & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); + var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); + switch (searchSpaceNode.kind) { + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + if (searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 198 /* ClassExpression */: + case 228 /* ClassDeclaration */: + // Make sure the container belongs to the same class + // and has the appropriate static modifier from the original container. + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 264 /* SourceFile */: + if (container.kind === 264 /* SourceFile */ && !ts.isExternalModule(container)) { + result.push(getReferenceEntryFromNode(node)); + } + break; } }); - 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 = 32 /* Static */; - switch (searchSpaceNode.kind) { - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - if (ts.isObjectLiteralMethod(searchSpaceNode)) { - break; + } + function getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken) { + var type = ts.getStringLiteralTypeForNode(node, typeChecker); + if (!type) { + // nothing to do here. moving on + return undefined; + } + var references = []; + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); + } + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ts.ScriptElementKind.variableElement, + name: type.text, + textSpan: ts.createTextSpanFromNode(node), + displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] + }, + references: references + }]; + function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { + for (var _i = 0, possiblePositions_4 = possiblePositions; _i < possiblePositions_4.length; _i++) { + var position = possiblePositions_4[_i]; + cancellationToken.throwIfCancellationRequested(); + var node_2 = ts.getTouchingWord(sourceFile, position); + if (!node_2 || node_2.kind !== 9 /* StringLiteral */) { + return; + } + var type_2 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + if (type_2 === searchType) { + references.push(getReferenceEntryFromNode(node_2)); + } + } + } + } + function populateSearchSymbolSet(symbol, location, typeChecker, implementations) { + // The search set contains at least the current symbol + var result = [symbol]; + // If the location is name of property symbol from object literal destructuring pattern + // Search the property symbol + // for ( { property: p2 } of elems) { } + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(location); + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 261 /* ShorthandPropertyAssignment */) { + var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, typeChecker); + if (propertySymbol) { + result.push(propertySymbol); + } + } + // 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 (containingObjectLiteralElement) { + ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), 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 + * const name = "Foo"; + * const 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 the symbol.valueDeclaration is a property parameter declaration, + // we should include both parameter declaration symbol and property declaration symbol + // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. + // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 145 /* Parameter */ && + ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + ts.addRange(result, typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); + } + // If this is symbol of binding element without propertyName declaration in Object binding pattern + // Include the property in the search + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker); + if (bindingElementPropertySymbol) { + result.push(bindingElementPropertySymbol); + } + // 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 + for (var _i = 0, _a = typeChecker.getRootSymbols(symbol); _i < _a.length; _i++) { + var rootSymbol = _a[_i]; + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap(), typeChecker); + } + } + return result; + } + /** + * Find symbol of the given property-name and add the symbol to the given result array + * @param symbol a symbol to start searching for the given propertyName + * @param propertyName a name of property to search for + * @param result an array of symbol of found property symbols + * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. + * The value of previousIterationSymbol is undefined when the function is first called. + */ + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache, typeChecker) { + if (!symbol) { + return; + } + // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited + // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. + // For example: + // interface C extends C { + // /*findRef*/propName: string; + // } + // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, + // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, + // the function will add any found symbol of the property-name, then its sub-routine will call + // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already + // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. + if (previousIterationSymbolsCache.has(symbol.name)) { + return; + } + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === 229 /* 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.apply(result, typeChecker.getRootSymbols(propertySymbol)); } - // fall through - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class - break; - case 261 /* SourceFile */: - if (ts.isExternalModule(searchSpaceNode)) { + // Visit the typeReference as well to see if it directly or indirectly use that property + previousIterationSymbolsCache.set(symbol.name, symbol); + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, typeChecker); + } + } + } + } + function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker) { + if (ts.contains(searchSymbols, referenceSymbol)) { + // If we are searching for constructor uses, they must be 'new' expressions. + return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) ? referenceSymbol : undefined; + } + // If the reference symbol is an alias, check if what it is aliasing is one of the search + // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. + var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation, typeChecker); + if (aliasSymbol) { + return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker); + } + // 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 + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(referenceLocation); + if (containingObjectLiteralElement) { + var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { + return ts.find(typeChecker.getRootSymbols(contextualSymbol), function (symbol) { return ts.contains(searchSymbols, symbol); }); + }); + if (contextualSymbol) { + return contextualSymbol; + } + // If the reference location is the name of property from object literal destructuring pattern + // Get the property symbol from the object literal's type and look if thats the search symbol + // In below eg. get 'property' from type of elems iterating type + // for ( { property: p2 } of elems) { } + var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, typeChecker); + if (propertySymbol && ts.contains(searchSymbols, propertySymbol)) { + return propertySymbol; + } + } + // If the reference location is the binding element and doesn't have property name + // then include the binding element in the related symbols + // let { a } : { a }; + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, typeChecker); + if (bindingElementPropertySymbol && ts.contains(searchSymbols, bindingElementPropertySymbol)) { + return bindingElementPropertySymbol; + } + // 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 (ts.contains(searchSymbols, rootSymbol)) { + 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 we were passed a parent symbol, only include types that are subtypes of the + // parent symbol + if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + // Parents will only be defined if implementations is true + if (parents) { + if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache, typeChecker); })) { return undefined; } - // Fall through - case 225 /* FunctionDeclaration */: - case 184 /* 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 === 261 /* 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); - } - var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); - var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: "this", - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: displayParts - }, - references: references - }]; - function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || !ts.isThis(node)) { - return; - } - var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); - switch (searchSpaceNode.kind) { - case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: - // Make sure the container belongs to the same class - // and has the appropriate static modifier from the original container. - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 261 /* SourceFile */: - if (container.kind === 261 /* SourceFile */ && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); - } - } - function getReferencesForStringLiteral(node, sourceFiles) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (!type) { - // nothing to do here. moving on - return undefined; - } - var references = []; - for (var _i = 0, sourceFiles_9 = sourceFiles; _i < sourceFiles_9.length; _i++) { - var sourceFile = sourceFiles_9[_i]; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd()); - getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); - } - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: type.text, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] - }, - references: references - }]; - function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { - for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { - var position = possiblePositions_1[_i]; - cancellationToken.throwIfCancellationRequested(); - var node_2 = ts.getTouchingWord(sourceFile, position); - if (!node_2 || node_2.kind !== 9 /* StringLiteral */) { - return; - } - var type_1 = ts.getStringLiteralTypeForNode(node_2, typeChecker); - if (type_1 === searchType) { - references.push(getReferenceEntryFromNode(node_2)); - } } + var result = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap(), typeChecker); + return ts.find(result, function (symbol) { return ts.contains(searchSymbols, symbol); }); } - } - function populateSearchSymbolSet(symbol, location) { - // The search set contains at least the current symbol - var result = [symbol]; - // If the location is name of property symbol from object literal destructuring pattern - // Search the property symbol - // for ( { property: p2 } of elems) { } - var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 258 /* ShorthandPropertyAssignment */) { - var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); - if (propertySymbol) { - result.push(propertySymbol); - } - } - // If the symbol is an alias, add what it aliases to the list - // import {a} from "mod"; - // export {a} - // If the symbol is an alias to default declaration, add what it aliases to the list - // declare "mod" { export default class B { } } - // import B from "mod"; - //// For export specifiers, the exported name can be referring to a local symbol, e.g.: - //// import {a} from "mod"; - //// export {a as somethingElse} - //// We want the *local* declaration of 'a' as declared in the import, - //// *not* as declared within "mod" (or farther) - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(symbol, location); - if (aliasSymbol) { - result = result.concat(populateSearchSymbolSet(aliasSymbol, location)); - } - // 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 (containingObjectLiteralElement) { - ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), 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 - * const name = "Foo"; - * const 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 the symbol.valueDeclaration is a property parameter declaration, - // we should include both parameter declaration symbol and property declaration symbol - // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. - // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 144 /* Parameter */ && - ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { - result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); - } - // If this is symbol of binding element without propertyName declaration in Object binding pattern - // Include the property in the search - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol); - if (bindingElementPropertySymbol) { - result.push(bindingElementPropertySymbol); - } - // 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 (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap()); - } - }); - return result; - } - /** - * Find symbol of the given property-name and add the symbol to the given result array - * @param symbol a symbol to start searching for the given propertyName - * @param propertyName a name of property to search for - * @param result an array of symbol of found property symbols - * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. - * The value of previousIterationSymbol is undefined when the function is first called. - */ - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache) { - if (!symbol) { - return; - } - // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited - // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. - // For example: - // interface C extends C { - // /*findRef*/propName: string; - // } - // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, - // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, - // the function will add any found symbol of the property-name, then its sub-routine will call - // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already - // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. - if (symbol.name in previousIterationSymbolsCache) { - return; - } - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === 227 /* 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.apply(result, typeChecker.getRootSymbols(propertySymbol)); - } - // Visit the typeReference as well to see if it directly or indirectly use that property - previousIterationSymbolsCache[symbol.name] = symbol; - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache); - } - } - } - } - function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache) { - if (ts.contains(searchSymbols, referenceSymbol)) { - // If we are searching for constructor uses, they must be 'new' expressions. - return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) && referenceSymbol; - } - // If the reference symbol is an alias, check if what it is aliasing is one of the search - // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation); - if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache); - } - // 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 - var containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation); - if (containingObjectLiteralElement) { - var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), function (contextualSymbol) { - return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - }); - if (contextualSymbol) { - return contextualSymbol; - } - // If the reference location is the name of property from object literal destructuring pattern - // Get the property symbol from the object literal's type and look if thats the search symbol - // In below eg. get 'property' from type of elems iterating type - // for ( { property: p2 } of elems) { } - var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation); - if (propertySymbol && searchSymbols.indexOf(propertySymbol) >= 0) { - return propertySymbol; - } - } - // If the reference location is the binding element and doesn't have property name - // then include the binding element in the related symbols - // let { a } : { a }; - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol); - if (bindingElementPropertySymbol && searchSymbols.indexOf(bindingElementPropertySymbol) >= 0) { - return bindingElementPropertySymbol; - } - // 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 we were passed a parent symbol, only include types that are subtypes of the - // parent symbol - if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - // Parents will only be defined if implementations is true - if (parents) { - if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache); })) { - return undefined; - } - } - var result_4 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_4, /*previousIterationSymbolsCache*/ ts.createMap()); - return ts.forEach(result_4, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - } - return undefined; - }); - } - function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 142 /* ComputedPropertyName */) { - var nameExpression = node.name.expression; - // treat computed property names where expression is string/numeric literal as just string/numeric literal - if (ts.isStringOrNumericLiteral(nameExpression)) { - return nameExpression.text; - } - return undefined; - } - return node.name.text; - } - function getPropertySymbolsFromContextualType(node) { - var objectLiteral = node.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - var name = getNameFromObjectLiteralElement(node); - if (name && contextualType) { - var result_5 = []; - var symbol_2 = contextualType.getProperty(name); - if (symbol_2) { - result_5.push(symbol_2); - } - if (contextualType.flags & 65536 /* Union */) { - ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name); - if (symbol) { - result_5.push(symbol); - } - }); - } - return result_5; + return undefined; + }); + } + function getNameFromObjectLiteralElement(node) { + if (node.name.kind === 143 /* ComputedPropertyName */) { + var nameExpression = node.name.expression; + // treat computed property names where expression is string/numeric literal as just string/numeric literal + if (ts.isStringOrNumericLiteral(nameExpression)) { + return nameExpression.text; } 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 = void 0; - 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, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; - var declarationMeaning = ts.getMeaningFromDeclaration(declaration); - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; - } - } - } while (meaning !== lastIterationMeaning); + return node.name.text; + } + /** Gets all symbols for one property. Does not get symbols for every property. */ + function getPropertySymbolsFromContextualType(node, typeChecker) { + var objectLiteral = node.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name = getNameFromObjectLiteralElement(node); + if (name && contextualType) { + var result_4 = []; + var symbol = contextualType.getProperty(name); + if (symbol) { + result_4.push(symbol); } - return meaning; + if (contextualType.flags & 65536 /* Union */) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_4.push(symbol); + } + }); + } + return result_4; } + return undefined; } - FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; - function convertReferences(referenceSymbols) { - if (!referenceSymbols) { - 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 = void 0; + 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, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; + var declarationMeaning = ts.getMeaningFromDeclaration(declaration); + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; + } + } + } while (meaning !== lastIterationMeaning); } - var referenceEntries = []; - for (var _i = 0, referenceSymbols_1 = referenceSymbols; _i < referenceSymbols_1.length; _i++) { - var referenceSymbol = referenceSymbols_1[_i]; - ts.addRange(referenceEntries, referenceSymbol.references); - } - return referenceEntries; + return meaning; } - FindAllReferences.convertReferences = convertReferences; function isImplementation(node) { if (!node) { return false; @@ -70593,7 +72875,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 223 /* VariableDeclaration */) { + else if (node.kind === 225 /* VariableDeclaration */) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); } @@ -70603,18 +72885,18 @@ var ts; } else { switch (node.kind) { - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 231 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 205 /* VariableStatement */) { - ts.Debug.assert(node.parent.kind === 224 /* VariableDeclarationList */); + if (node.parent && node.parent.parent && node.parent.parent.kind === 207 /* VariableStatement */) { + ts.Debug.assert(node.parent.kind === 226 /* VariableDeclarationList */); return node.parent.parent; } } @@ -70653,10 +72935,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 191 /* PostfixUnaryExpression */ || parent.kind === 190 /* PrefixUnaryExpression */) { + if (parent.kind === 192 /* PostfixUnaryExpression */ || parent.kind === 191 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 192 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 193 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; return 57 /* FirstAssignment */ <= operator && operator <= 69 /* LastAssignment */; } @@ -70671,33 +72953,6 @@ var ts; forEachDescendantOfKind(child, kind, action); }); } - /** - * Returns the containing object literal property declaration given a possible name node, e.g. "a" in x = { "a": 1 } - */ - function getContainingObjectLiteralElement(node) { - switch (node.kind) { - case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - if (node.parent.kind === 142 /* ComputedPropertyName */) { - return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; - } - // intential fall through - case 70 /* Identifier */: - return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; - } - return undefined; - } - function isObjectLiteralPropertyDeclaration(node) { - switch (node.kind) { - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - return true; - } - return false; - } /** Get `C` given `N` if `N` is in the position `class C extends N` or `class C extends foo.N` where `N` is an identifier. */ function tryGetClassByExtendingIdentifier(node) { return ts.tryGetClassExtendingExpressionWithTypeArguments(ts.climbPastPropertyAccess(node).parent); @@ -70708,6 +72963,9 @@ var ts; } return false; } + function isImportDefaultSymbol(symbol) { + return symbol.declarations[0].kind === 238 /* ImportClause */; + } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); /* @internal */ @@ -70728,11 +72986,9 @@ var ts; // Type reference directives var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { - var referenceFile = program.getResolvedTypeReferenceDirectives()[typeReferenceDirective.fileName]; - if (referenceFile && referenceFile.resolvedFileName) { - return [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; - } - return undefined; + var referenceFile = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); + return referenceFile && referenceFile.resolvedFileName && + [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; } var node = ts.getTouchingPropertyName(sourceFile, position); if (node === sourceFile) { @@ -70742,7 +72998,7 @@ var ts; if (ts.isJumpStatementTarget(node)) { var labelName = node.text; var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ts.ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; + return label ? [createDefinitionInfoFromName(label, ts.ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; } var typeChecker = program.getTypeChecker(); var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); @@ -70768,7 +73024,7 @@ var ts; // if (node.kind === 70 /* Identifier */ && (node.parent === declaration || - (declaration.kind === 239 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 238 /* NamedImports */))) { + (declaration.kind === 241 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 240 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -70777,7 +73033,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 === 258 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 261 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -70788,6 +73044,37 @@ var ts; var shorthandContainerName_1 = typeChecker.symbolToString(symbol.parent, node); return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind_1, shorthandSymbolName_1, shorthandContainerName_1); }); } + if (ts.isJsxOpeningLikeElement(node.parent)) { + // If there are errors when trying to figure out stateless component function, just return the first declaration + // For example: + // declare function /*firstSource*/MainButton(buttonProps: ButtonProps): JSX.Element; + // declare function /*secondSource*/MainButton(linkProps: LinkProps): JSX.Element; + // declare function /*thirdSource*/MainButton(props: ButtonProps | LinkProps): JSX.Element; + // let opt =
; // Error - We get undefined for resolved signature indicating an error, then just return the first declaration + var _a = getSymbolInfo(typeChecker, symbol, node), symbolName = _a.symbolName, symbolKind = _a.symbolKind, containerName = _a.containerName; + return [createDefinitionInfo(symbol.valueDeclaration, symbolKind, symbolName, containerName)]; + } + // If the current location we want to find its definition 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 for goto-definition. + // For example + // interface Props{ + // /*first*/prop1: number + // prop2: boolean + // } + // function Foo(arg: Props) {} + // Foo( { pr/*1*/op1: 10, prop2: true }) + var element = ts.getContainingObjectLiteralElement(node); + if (element) { + if (typeChecker.getContextualType(element.parent)) { + var result = []; + var propertySymbols = ts.getPropertySymbolsFromContextualType(typeChecker, element); + for (var _i = 0, propertySymbols_1 = propertySymbols; _i < propertySymbols_1.length; _i++) { + var propertySymbol = propertySymbols_1[_i]; + result.push.apply(result, getDefinitionFromSymbol(typeChecker, propertySymbol, node)); + } + return result; + } + } return getDefinitionFromSymbol(typeChecker, symbol, node); } GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; @@ -70806,13 +73093,13 @@ var ts; return undefined; } if (type.flags & 65536 /* Union */ && !(type.flags & 16 /* Enum */)) { - var result_6 = []; + var result_5 = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(/*to*/ result_6, /*from*/ getDefinitionFromSymbol(typeChecker, t.symbol, node)); + ts.addRange(/*to*/ result_5, /*from*/ getDefinitionFromSymbol(typeChecker, t.symbol, node)); } }); - return result_6; + return result_5; } if (!type.symbol) { return undefined; @@ -70859,29 +73146,42 @@ var ts; function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { var declarations = []; var definition; - ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 150 /* Constructor */) || - (!selectConstructors && (d.kind === 225 /* FunctionDeclaration */ || d.kind === 149 /* MethodDeclaration */ || d.kind === 148 /* MethodSignature */))) { + for (var _i = 0, signatureDeclarations_1 = signatureDeclarations; _i < signatureDeclarations_1.length; _i++) { + var d = signatureDeclarations_1[_i]; + if (selectConstructors ? d.kind === 151 /* Constructor */ : isSignatureDeclaration(d)) { 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)); + if (declarations.length) { + result.push(createDefinitionInfo(definition || ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); return true; } return false; } } + function isSignatureDeclaration(node) { + switch (node.kind) { + case 151 /* Constructor */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + return true; + default: + return false; + } + } + /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */ function createDefinitionInfo(node, symbolKind, symbolName, containerName) { + return createDefinitionInfoFromName(node.name || node, symbolKind, symbolName, containerName); + } + /** Creates a DefinitionInfo directly from the name of a declaration. */ + function createDefinitionInfoFromName(name, symbolKind, symbolName, containerName) { + var sourceFile = name.getSourceFile(); return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromNode(name, sourceFile), kind: symbolKind, name: symbolName, containerKind: undefined, @@ -70929,7 +73229,15 @@ var ts; } function tryGetSignatureDeclaration(typeChecker, node) { var callLike = getAncestorCallLikeExpression(node); - return callLike && typeChecker.getResolvedSignature(callLike).declaration; + var signature = callLike && typeChecker.getResolvedSignature(callLike); + if (signature) { + var decl = signature.declaration; + if (decl && isSignatureDeclaration(decl)) { + return decl; + } + } + // Don't go to a function type, go to the value having that type. + return undefined; } })(GoToDefinition = ts.GoToDefinition || (ts.GoToDefinition = {})); })(ts || (ts = {})); @@ -70941,7 +73249,7 @@ var ts; function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 258 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 261 /* ShorthandPropertyAssignment */) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -70954,7 +73262,7 @@ var ts; } else { // Perform "Find all References" and retrieve only those that are implementations - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, /*findInStrings*/ false, /*findInComments*/ false, /*implementations*/ true); + var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/ false, /*implementations*/ true); var result = ts.flatMap(referencedSymbols, function (symbol) { return ts.map(symbol.references, function (_a) { var textSpan = _a.textSpan, fileName = _a.fileName; @@ -71048,7 +73356,7 @@ var ts; */ function forEachUnique(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (ts.indexOf(array, array[i]) === i) { var result = callback(array[i], i); if (result) { @@ -71108,19 +73416,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 225 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 150 /* Constructor */: - case 226 /* ClassDeclaration */: - case 205 /* VariableStatement */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 151 /* Constructor */: + case 228 /* ClassDeclaration */: + case 207 /* VariableStatement */: break findOwner; - case 261 /* SourceFile */: + case 264 /* SourceFile */: return undefined; - case 230 /* ModuleDeclaration */: + case 232 /* 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 === 230 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 232 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -71135,7 +73443,7 @@ var ts; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; - for (var i = 0, numParams = parameters.length; i < numParams; i++) { + for (var i = 0; i < parameters.length; i++) { var currentName = parameters[i].name; var paramName = currentName.kind === 70 /* Identifier */ ? currentName.text : @@ -71167,7 +73475,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 205 /* VariableStatement */) { + if (commentOwner.kind === 207 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -71185,17 +73493,17 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 183 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 184 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return rightHandSide.parameters; - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150 /* Constructor */) { + if (member.kind === 151 /* Constructor */) { return member.parameters; } } @@ -71253,7 +73561,7 @@ var ts; }); if (!safeList) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); - safeList = result.config ? ts.createMap(result.config) : EmptySafeList; + safeList = result.config ? ts.createMapFromTemplate(result.config) : EmptySafeList; } var filesToWatch = []; // Directories to search for package.json, bower.json and other typing information @@ -71280,33 +73588,33 @@ var ts; if (unresolvedImports) { for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { var moduleId = unresolvedImports_1[_a]; - var typingName = moduleId in nodeCoreModules ? "node" : moduleId; - if (!(typingName in inferredTypings)) { - inferredTypings[typingName] = undefined; + var typingName = nodeCoreModules.has(moduleId) ? "node" : moduleId; + if (!inferredTypings.has(typingName)) { + inferredTypings.set(typingName, undefined); } } } // Add the cached typing locations for inferred typings that are already installed - for (var name_46 in packageNameToTypingLocation) { - if (name_46 in inferredTypings && !inferredTypings[name_46]) { - inferredTypings[name_46] = packageNameToTypingLocation[name_46]; + packageNameToTypingLocation.forEach(function (typingLocation, name) { + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined) { + inferredTypings.set(name, typingLocation); } - } + }); // Remove typings that the user has added to the exclude list for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { var excludeTypingName = exclude_1[_b]; - delete inferredTypings[excludeTypingName]; + inferredTypings.delete(excludeTypingName); } var newTypingNames = []; var cachedTypingPaths = []; - for (var typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); + inferredTypings.forEach(function (inferred, typing) { + if (inferred !== undefined) { + cachedTypingPaths.push(inferred); } else { newTypingNames.push(typing); } - } + }); return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; /** * Merge a given list of typingNames to the inferredTypings map @@ -71317,8 +73625,8 @@ var ts; } for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { var typing = typingNames_1[_i]; - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; + if (!inferredTypings.has(typing)) { + inferredTypings.set(typing, undefined); } } } @@ -71357,7 +73665,7 @@ var ts; var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); if (safeList !== EmptySafeList) { - mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); + mergeTypings(ts.filter(cleanedTypingNames, function (f) { return safeList.has(f); })); } var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2 /* JSX */; }); if (hasJsxFile) { @@ -71400,7 +73708,7 @@ var ts; } if (packageJson.typings) { var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; + inferredTypings.set(packageJson.name, absolutePath); } else { typingNames.push(packageJson.name); @@ -71420,47 +73728,49 @@ var ts; function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; - // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] - ts.forEach(sourceFiles, function (sourceFile) { + var _loop_4 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) { - return; + return "continue"; } - var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_47 in nameToDeclarations) { - var declarations = nameToDeclarations[name_47]; + ts.forEachEntry(sourceFile.getNamedDeclarations(), function (declarations, name) { 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_47); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); if (!matches) { - continue; + return; // continue to next named declarations } - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { + var declaration = declarations_12[_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; + return true; // Break out of named declarations and go to the next source file. } - matches = patternMatcher.getMatches(containers, name_47); + matches = patternMatcher.getMatches(containers, name); if (!matches) { - continue; + return; // continue to next named declarations } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_47, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } - } - }); + }); + }; + // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] + for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { + var sourceFile = sourceFiles_8[_i]; + _loop_4(sourceFile); + } // Remove imports when the imported declaration is already in the list and has the same name. rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 236 /* ImportClause */ || decl.kind === 239 /* ImportSpecifier */ || decl.kind === 234 /* ImportEqualsDeclaration */) { + if (decl.kind === 238 /* ImportClause */ || decl.kind === 241 /* ImportSpecifier */ || decl.kind === 236 /* ImportEqualsDeclaration */) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -71502,7 +73812,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 142 /* ComputedPropertyName */) { + else if (declaration.name.kind === 143 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ true); } else { @@ -71523,7 +73833,7 @@ var ts; } return true; } - if (expression.kind === 177 /* PropertyAccessExpression */) { + if (expression.kind === 178 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -71536,7 +73846,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 === 142 /* ComputedPropertyName */) { + if (declaration.name.kind === 143 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } @@ -71582,7 +73892,7 @@ var ts; matchKind: ts.PatternMatchKind[rawItem.matchKind], isCaseSensitive: rawItem.isCaseSensitive, fileName: rawItem.fileName, - textSpan: ts.createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), + textSpan: ts.createTextSpanFromNode(declaration), // 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) : "" @@ -71689,7 +73999,7 @@ var ts; return; } switch (node.kind) { - case 150 /* Constructor */: + case 151 /* Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -71701,21 +74011,21 @@ var ts; } } break; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 149 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 236 /* ImportClause */: + case 238 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -71727,7 +74037,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 237 /* NamespaceImport */) { + if (namedBindings.kind === 239 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -71738,12 +74048,12 @@ var ts; } } break; - case 174 /* BindingElement */: - case 223 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 225 /* VariableDeclaration */: var decl = node; - var name_48 = decl.name; - if (ts.isBindingPattern(name_48)) { - addChildrenRecursively(name_48); + var name = decl.name; + if (ts.isBindingPattern(name)) { + addChildrenRecursively(name); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { // For `const x = function() {}`, just use the function node, not the const. @@ -71753,12 +74063,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; - case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -71768,9 +74078,9 @@ var ts; } endNode(); break; - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -71778,21 +74088,21 @@ var ts; } endNode(); break; - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 243 /* ExportSpecifier */: - case 234 /* ImportEqualsDeclaration */: - case 155 /* IndexSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 228 /* TypeAliasDeclaration */: + case 245 /* ExportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 156 /* IndexSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 230 /* TypeAliasDeclaration */: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 285 /* JSDocTypedefTag */) { + if (tag.kind === 289 /* JSDocTypedefTag */) { addLeafNode(tag); } }); @@ -71810,9 +74120,9 @@ var ts; // Anonymous items are never merged. return true; } - var itemsWithSameName = nameToItems[name]; + var itemsWithSameName = nameToItems.get(name); if (!itemsWithSameName) { - nameToItems[name] = child; + nameToItems.set(name, child); return true; } if (itemsWithSameName instanceof Array) { @@ -71830,7 +74140,7 @@ var ts; if (tryMerge(itemWithSameName, child)) { return false; } - nameToItems[name] = [itemWithSameName, child]; + nameToItems.set(name, [itemWithSameName, child]); return true; } function tryMerge(a, b) { @@ -71843,14 +74153,14 @@ var ts; }); /** a and b have the same name, but they may not be mergeable. */ function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 230 /* ModuleDeclaration */ || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 232 /* ModuleDeclaration */ || areSameModule(a, b)); // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 230 /* ModuleDeclaration */) { + if (a.body.kind !== 232 /* ModuleDeclaration */) { return true; } return areSameModule(a.body, b.body); @@ -71878,39 +74188,20 @@ var ts; function compareChildren(child1, child2) { var name1 = tryGetName(child1.node), name2 = tryGetName(child2.node); if (name1 && name2) { - var cmp = localeCompareFix(name1, name2); + var cmp = ts.compareStringsCaseInsensitive(name1, name2); return cmp !== 0 ? cmp : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } else { return name1 ? 1 : name2 ? -1 : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } } - // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". - var localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; - var localeCompareFix = localeCompareIsCorrect ? ts.collator.compare : function (a, b) { - // This isn't perfect, but it passes all of our tests. - for (var i = 0; i < Math.min(a.length, b.length); i++) { - var chA = a.charAt(i), chB = b.charAt(i); - if (chA === "\"" && chB === "'") { - return 1; - } - if (chA === "'" && chB === "\"") { - return -1; - } - var cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); - if (cmp !== 0) { - return cmp; - } - } - return a.length - b.length; - }; /** * This differs from getItemName because this is just used for sorting. * We only sort nodes by name that have a more-or-less "direct" name, as opposed to `new()` and the like. * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 230 /* ModuleDeclaration */) { + if (node.kind === 232 /* ModuleDeclaration */) { return getModuleName(node); } var decl = node; @@ -71918,18 +74209,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 197 /* ClassExpression */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 198 /* ClassExpression */: return getFunctionOrClassName(node); - case 285 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 230 /* ModuleDeclaration */) { + if (node.kind === 232 /* ModuleDeclaration */) { return getModuleName(node); } var name = node.name; @@ -71940,16 +74231,16 @@ var ts; } } switch (node.kind) { - case 261 /* SourceFile */: + case 264 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -71957,15 +74248,15 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return "constructor"; - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: return "new()"; - case 153 /* CallSignature */: + case 154 /* CallSignature */: return "()"; - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: return "[]"; - case 285 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return ""; @@ -71977,7 +74268,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 205 /* VariableStatement */) { + if (parentNode && parentNode.kind === 207 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -72006,24 +74297,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 229 /* EnumDeclaration */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 261 /* SourceFile */: - case 228 /* TypeAliasDeclaration */: - case 285 /* JSDocTypedefTag */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 231 /* EnumDeclaration */: + case 229 /* InterfaceDeclaration */: + case 232 /* ModuleDeclaration */: + case 264 /* SourceFile */: + case 230 /* TypeAliasDeclaration */: + case 289 /* JSDocTypedefTag */: return true; - case 150 /* Constructor */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 223 /* VariableDeclaration */: + case 151 /* Constructor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 225 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -72033,10 +74324,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 231 /* ModuleBlock */: - case 261 /* SourceFile */: - case 149 /* MethodDeclaration */: - case 150 /* Constructor */: + case 233 /* ModuleBlock */: + case 264 /* SourceFile */: + case 150 /* MethodDeclaration */: + case 151 /* Constructor */: return true; default: return hasSomeImportantChild(item); @@ -72045,7 +74336,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 223 /* VariableDeclaration */ && childKind !== 174 /* BindingElement */; + return childKind !== 225 /* VariableDeclaration */ && childKind !== 175 /* BindingElement */; }); } } @@ -72056,7 +74347,7 @@ var ts; return { text: getItemName(n.node), kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: ts.map(n.children, convertToTree) }; @@ -72065,7 +74356,7 @@ var ts; return { text: getItemName(n.node), kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, indent: n.indent, @@ -72103,7 +74394,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 === 230 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 232 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -72114,28 +74405,34 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 230 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 232 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 142 /* ComputedPropertyName */; + return !member.name || member.name.kind === 143 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 261 /* SourceFile */ + return node.kind === 264 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) - : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); + : ts.createTextSpanFromNode(node, curSourceFile); + } + function getModifiers(node) { + if (node.parent && node.parent.kind === 225 /* VariableDeclaration */) { + node = node.parent; + } + return ts.getNodeModifiers(node); } function getFunctionOrClassName(node) { if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 223 /* VariableDeclaration */) { + else if (node.parent.kind === 225 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 192 /* BinaryExpression */ && + else if (node.parent.kind === 193 /* BinaryExpression */ && node.parent.operatorToken.kind === 57 /* EqualsToken */) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 257 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 260 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512 /* Default */) { @@ -72146,7 +74443,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 184 /* FunctionExpression */ || node.kind === 185 /* ArrowFunction */ || node.kind === 197 /* ClassExpression */; + return node.kind === 185 /* FunctionExpression */ || node.kind === 186 /* ArrowFunction */ || node.kind === 198 /* ClassExpression */; } /** * Matches all whitespace characters in a string. Eg: @@ -72176,7 +74473,7 @@ var ts; if (hintSpanNode && startElement && endElement) { var span_12 = { textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), - hintSpan: ts.createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), + hintSpan: ts.createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse }; @@ -72236,7 +74533,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 185 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 186 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -72248,30 +74545,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 204 /* Block */: + case 206 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_19 = n.parent; + var parent = n.parent; var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. - if (parent_19.kind === 209 /* DoStatement */ || - parent_19.kind === 212 /* ForInStatement */ || - parent_19.kind === 213 /* ForOfStatement */ || - parent_19.kind === 211 /* ForStatement */ || - parent_19.kind === 208 /* IfStatement */ || - parent_19.kind === 210 /* WhileStatement */ || - parent_19.kind === 217 /* WithStatement */ || - parent_19.kind === 256 /* CatchClause */) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + if (parent.kind === 211 /* DoStatement */ || + parent.kind === 214 /* ForInStatement */ || + parent.kind === 215 /* ForOfStatement */ || + parent.kind === 213 /* ForStatement */ || + parent.kind === 210 /* IfStatement */ || + parent.kind === 212 /* WhileStatement */ || + parent.kind === 219 /* WithStatement */ || + parent.kind === 259 /* CatchClause */) { + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_19.kind === 221 /* TryStatement */) { + if (parent.kind === 223 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_19; + var tryStatement = parent; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -72281,10 +74578,11 @@ var ts; break; } } + // fall through. } // 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_14 = ts.createTextSpanFromBounds(n.getStart(), n.end); + var span_14 = ts.createTextSpanFromNode(n); elements.push({ textSpan: span_14, hintSpan: span_14, @@ -72294,23 +74592,23 @@ var ts; break; } // Fallthrough. - case 231 /* ModuleBlock */: { + case 233 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 176 /* ObjectLiteralExpression */: - case 232 /* CaseBlock */: { + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 177 /* ObjectLiteralExpression */: + case 234 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 20 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -72406,10 +74704,11 @@ var ts; return totalMatch; } function getWordSpans(word) { - if (!(word in stringToWordSpans)) { - stringToWordSpans[word] = breakIntoWordSpans(word); + var spans = stringToWordSpans.get(word); + if (!spans) { + stringToWordSpans.set(word, spans = breakIntoWordSpans(word)); } - return stringToWordSpans[word]; + return spans; } function matchTextChunk(candidate, chunk, punctuationStripped) { var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); @@ -72690,7 +74989,8 @@ var ts; } // Assumes 'value' is already lowercase. function indexOfIgnoringCase(string, value) { - for (var i = 0, n = string.length - value.length; i <= n; i++) { + var n = string.length - value.length; + for (var i = 0; i <= n; i++) { if (startsWithIgnoringCase(string, value, i)) { return i; } @@ -72699,7 +74999,7 @@ var ts; } // Assumes 'value' is already lowercase. function startsWithIgnoringCase(string, value, start) { - for (var i = 0, n = value.length; i < n; i++) { + for (var i = 0; i < value.length; i++) { var ch1 = toLowerCase(string.charCodeAt(i + start)); var ch2 = value.charCodeAt(i); if (ch1 !== ch2) { @@ -72771,7 +75071,7 @@ var ts; function breakIntoSpans(identifier, word) { var result = []; var wordStart = 0; - for (var i = 1, n = identifier.length; i < n; i++) { + for (var i = 1; i < identifier.length; i++) { var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); var currentIsDigit = isDigit(identifier.charCodeAt(i)); var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); @@ -72983,7 +75283,7 @@ var ts; else { if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import d from "mod"; @@ -73014,7 +75314,7 @@ var ts; } if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; @@ -73030,7 +75330,7 @@ var ts; token = nextToken(); if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import * as NS from "mod" @@ -73060,7 +75360,7 @@ var ts; } if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; @@ -73072,7 +75372,7 @@ var ts; } else if (token === 38 /* AsteriskToken */) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export * from "mod" @@ -73224,93 +75524,85 @@ var ts; var Rename; (function (Rename) { function getRenameInfo(typeChecker, defaultLibFileName, getCanonicalFileName, sourceFile, position) { - var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); + var getCanonicalDefaultLibName = ts.memoize(function () { return getCanonicalFileName(ts.normalizePath(defaultLibFileName)); }); var node = ts.getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true); - if (node) { - if (node.kind === 70 /* Identifier */ || - node.kind === 9 /* StringLiteral */ || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - ts.isThis(node)) { - 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. - if (ts.forEach(declarations, isDefinedInLibraryFile)) { - 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 = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - if (kind) { - return { - canRename: true, - kind: kind, - displayName: displayName, - localizedErrorMessage: undefined, - fullDisplayName: typeChecker.getFullyQualifiedName(symbol), - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - else if (node.kind === 9 /* StringLiteral */) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (type) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } - else { - var displayName = ts.stripQuotes(type.text); - return { - canRename: true, - kind: ts.ScriptElementKind.variableElement, - displayName: displayName, - localizedErrorMessage: undefined, - fullDisplayName: displayName, - kindModifiers: ts.ScriptElementKindModifier.none, - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - } - } - 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 - }; - } + var renameInfo = node && nodeIsEligibleForRename(node) + ? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) + : undefined; + return renameInfo || getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); function isDefinedInLibraryFile(declaration) { - if (defaultLibFileName) { - var sourceFile_1 = declaration.getSourceFile(); - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_1.fileName)); - if (canonicalName === canonicalDefaultLibName) { - return true; - } + if (!defaultLibFileName) { + return false; } - return false; - } - function createTriggerSpanForNode(node, sourceFile) { - var start = node.getStart(sourceFile); - var width = node.getWidth(sourceFile); - if (node.kind === 9 /* StringLiteral */) { - // Exclude the quotes - start += 1; - width -= 2; - } - return ts.createTextSpan(start, width); + var sourceFile = declaration.getSourceFile(); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); + return canonicalName === getCanonicalDefaultLibName(); } } Rename.getRenameInfo = getRenameInfo; + function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) { + 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. + if (ts.some(declarations, isDefinedInLibraryFile)) { + return getRenameInfoError(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 = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); + return kind ? getRenameInfoSuccess(displayName, typeChecker.getFullyQualifiedName(symbol), kind, ts.SymbolDisplay.getSymbolModifiers(symbol), node, sourceFile) : undefined; + } + } + else if (node.kind === 9 /* StringLiteral */) { + var type = ts.getStringLiteralTypeForNode(node, typeChecker); + if (type) { + if (isDefinedInLibraryFile(node)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); + } + var displayName = ts.stripQuotes(type.text); + return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); + } + } + } + function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { + return { + canRename: true, + kind: kind, + displayName: displayName, + localizedErrorMessage: undefined, + fullDisplayName: fullDisplayName, + kindModifiers: kindModifiers, + triggerSpan: createTriggerSpanForNode(node, sourceFile) + }; + } + function getRenameInfoError(diagnostic) { + return { + canRename: false, + localizedErrorMessage: ts.getLocaleSpecificMessage(diagnostic), + displayName: undefined, + fullDisplayName: undefined, + kind: undefined, + kindModifiers: undefined, + triggerSpan: undefined + }; + } + function createTriggerSpanForNode(node, sourceFile) { + var start = node.getStart(sourceFile); + var width = node.getWidth(sourceFile); + if (node.kind === 9 /* StringLiteral */) { + // Exclude the quotes + start += 1; + width -= 2; + } + return ts.createTextSpan(start, width); + } + function nodeIsEligibleForRename(node) { + return node.kind === 70 /* Identifier */ || node.kind === 9 /* StringLiteral */ || + ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + ts.isThis(node); + } })(Rename = ts.Rename || (ts.Rename = {})); })(ts || (ts = {})); /// @@ -73457,6 +75749,7 @@ var ts; ArgumentListKind[ArgumentListKind["TypeArguments"] = 0] = "TypeArguments"; ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; + ArgumentListKind[ArgumentListKind["JSXAttributesArguments"] = 3] = "JSXAttributesArguments"; })(ArgumentListKind = SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); @@ -73488,7 +75781,7 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 179 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 180 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. @@ -73496,7 +75789,7 @@ var ts; var expression = callExpression.expression; var name = expression.kind === 70 /* Identifier */ ? expression - : expression.kind === 177 /* PropertyAccessExpression */ + : expression.kind === 178 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -73506,10 +75799,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameToDeclarations = sourceFile.getNamedDeclarations(); - var declarations = nameToDeclarations[name.text]; + var declarations = nameToDeclarations.get(name.text); if (declarations) { - for (var _b = 0, declarations_10 = declarations; _b < declarations_10.length; _b++) { - var declaration = declarations_10[_b]; + for (var _b = 0, declarations_13 = declarations; _b < declarations_13.length; _b++) { + var declaration = declarations_13[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -73529,21 +75822,21 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 179 /* CallExpression */ || node.parent.kind === 180 /* NewExpression */) { + if (node.parent.kind === 180 /* CallExpression */ || node.parent.kind === 181 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: - // 1. The token introduces a list, and should begin a sig help session + // 1. The token introduces a list, and should begin a signature help session // 2. The token is either not associated with a list, or ends a list, so the session should end - // 3. The token is buried inside a list, and should give sig help + // 3. The token is buried inside a list, and should give signature help // // The following are examples of each: // // Case 1: - // foo<#T, U>(#a, b) -> The token introduces a list, and should begin a sig help session + // foo<#T, U>(#a, b) -> The token introduces a list, and should begin a signature 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 + // foo(a#, #b#) -> The token is buried inside a list, and should give signature help // Find out if 'node' is an argument, a type argument, or neither if (node.kind === 26 /* LessThanToken */ || node.kind === 18 /* OpenParenToken */) { @@ -73562,7 +75855,7 @@ var ts; } // 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. + // - To the right of the closing parenthesis, 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 @@ -73583,25 +75876,25 @@ var ts; } return undefined; } - else if (node.kind === 12 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 181 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 182 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0, sourceFile); } } - else if (node.kind === 13 /* TemplateHead */ && node.parent.parent.kind === 181 /* TaggedTemplateExpression */) { + else if (node.kind === 13 /* TemplateHead */ && node.parent.parent.kind === 182 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 194 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 195 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 202 /* TemplateSpan */ && node.parent.parent.parent.kind === 181 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 204 /* TemplateSpan */ && node.parent.parent.parent.kind === 182 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 194 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 195 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 15 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -73610,8 +75903,25 @@ var ts; var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position); return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } + else if (node.parent && ts.isJsxOpeningLikeElement(node.parent)) { + // Provide a signature help for JSX opening element or JSX self-closing element. + // This is not guarantee that JSX tag-name is resolved into stateless function component. (that is done in "getSignatureHelpItems") + // i.e + // export function MainButton(props: ButtonProps, context: any): JSX.Element { ... } + // ' '' - // That will give us 2 non-commas. We then add one for the last comma, givin us an + // That will give us 2 non-commas. We then add one for the last comma, giving us an // arg count of 3. var listChildren = argumentsList.getChildren(); var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 25 /* CommaToken */; }); @@ -73719,7 +76029,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 === 194 /* TemplateExpression */) { + if (template.kind === 195 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -73728,7 +76038,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 261 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 264 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -73741,6 +76051,7 @@ var ts; if (argumentInfo) { return argumentInfo; } + // TODO: Handle generic call with incomplete syntax } return undefined; } @@ -73873,7 +76184,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 197 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 198 /* ClassExpression */) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ts.ScriptElementKind.enumElement; @@ -73930,7 +76241,7 @@ var ts; if (flags & 16384 /* Constructor */) return ts.ScriptElementKind.constructorImplementationElement; if (flags & 4 /* Property */) { - if (flags & 268435456 /* SyntheticProperty */) { + if (flags & 134217728 /* Transient */ && symbol.checkFlags & 2 /* 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(); @@ -73950,6 +76261,9 @@ var ts; } return unionPropertyKind; } + if (location.parent && ts.isJsxAttribute(location.parent)) { + return ts.ScriptElementKind.jsxAttribute; + } return ts.ScriptElementKind.memberVariableElement; } return ts.ScriptElementKind.unknown; @@ -73979,7 +76293,7 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 177 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 178 /* 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)) { @@ -73987,21 +76301,24 @@ var ts; } } // try get the call/construct signature from the type if it matches - var callExpression = void 0; - if (location.kind === 179 /* CallExpression */ || location.kind === 180 /* NewExpression */) { - callExpression = location; + var callExpressionLike = void 0; + if (location.kind === 180 /* CallExpression */ || location.kind === 181 /* NewExpression */) { + callExpressionLike = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { - callExpression = location.parent; + callExpressionLike = location.parent; } - if (callExpression) { + else if (location.parent && ts.isJsxOpeningLikeElement(location.parent) && ts.isFunctionLike(symbol.valueDeclaration)) { + callExpressionLike = location.parent; + } + if (callExpressionLike) { var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures); + signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); if (!signature && candidateSignatures.length) { // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 180 /* NewExpression */ || callExpression.expression.kind === 96 /* SuperKeyword */; + var useConstructSignatures = callExpressionLike.kind === 181 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 96 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -74028,6 +76345,7 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { + case ts.ScriptElementKind.jsxAttribute: case ts.ScriptElementKind.memberVariableElement: case ts.ScriptElementKind.variableElement: case ts.ScriptElementKind.constElement: @@ -74054,24 +76372,24 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 122 /* ConstructorKeyword */ && location.parent.kind === 150 /* Constructor */)) { + (location.kind === 122 /* ConstructorKeyword */ && location.parent.kind === 151 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 150 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 151 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 150 /* Constructor */) { + if (functionDeclaration.kind === 151 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 153 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 154 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -74080,7 +76398,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 197 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 198 /* 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 @@ -74103,7 +76421,7 @@ var ts; } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(136 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(137 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); @@ -74124,7 +76442,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 230 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 232 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 70 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 128 /* NamespaceKeyword */ : 127 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -74145,28 +76463,28 @@ var ts; } else { // Method/function type parameter - var declaration = ts.getDeclarationOfKind(symbol, 143 /* TypeParameter */); + var declaration = ts.getDeclarationOfKind(symbol, 144 /* TypeParameter */); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 154 /* ConstructSignature */) { + if (declaration.kind === 155 /* ConstructSignature */) { displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 153 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 154 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 228 /* TypeAliasDeclaration */) { + else if (declaration.kind === 230 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(136 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(137 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -74177,7 +76495,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 260 /* EnumMember */) { + if (declaration.kind === 263 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -74189,7 +76507,7 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 233 /* NamespaceExportDeclaration */) { + if (symbol.declarations[0].kind === 235 /* NamespaceExportDeclaration */) { displayParts.push(ts.keywordPart(83 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(128 /* NamespaceKeyword */)); @@ -74200,7 +76518,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 234 /* ImportEqualsDeclaration */) { + if (declaration.kind === 236 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -74236,6 +76554,7 @@ var ts; } // For properties, variables and local vars: show the type if (symbolKind === ts.ScriptElementKind.memberVariableElement || + symbolKind === ts.ScriptElementKind.jsxAttribute || symbolFlags & 3 /* Variable */ || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { @@ -74273,10 +76592,10 @@ var ts; // For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 261 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 264 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 192 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 193 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -74357,16 +76676,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 184 /* FunctionExpression */) { + if (declaration.kind === 185 /* FunctionExpression */) { return true; } - if (declaration.kind !== 223 /* VariableDeclaration */ && declaration.kind !== 225 /* FunctionDeclaration */) { + if (declaration.kind !== 225 /* VariableDeclaration */ && declaration.kind !== 227 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_20 = declaration.parent; !ts.isFunctionBlock(parent_20); parent_20 = parent_20.parent) { + for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent_20.kind === 261 /* SourceFile */ || parent_20.kind === 231 /* ModuleBlock */) { + if (parent.kind === 264 /* SourceFile */ || parent.kind === 233 /* ModuleBlock */) { return false; } } @@ -74419,7 +76738,7 @@ var ts; sourceFile.moduleName = transpileOptions.moduleName; } if (transpileOptions.renamedDependencies) { - sourceFile.renamedDependencies = ts.createMap(transpileOptions.renamedDependencies); + sourceFile.renamedDependencies = ts.createMapFromTemplate(transpileOptions.renamedDependencies); } var newLine = ts.getNewLineCharacter(options); // Output @@ -74474,10 +76793,10 @@ var ts; function fixupCompilerOptions(options, diagnostics) { // Lazily create this value to fix module loading errors. commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { - return typeof o.type === "object" && !ts.forEachProperty(o.type, function (v) { return typeof v !== "number"; }); + return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_3 = function (opt) { + var _loop_5 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -74488,7 +76807,7 @@ var ts; options[opt.name] = ts.parseCustomTypeOption(opt, value, diagnostics); } else { - if (!ts.forEachProperty(opt.type, function (v) { return v === value; })) { + if (!ts.forEachEntry(opt.type, function (v) { return v === value; })) { // Supplied value isn't a valid enum value. diagnostics.push(ts.createCompilerDiagnosticForInvalidCustomType(opt)); } @@ -74496,7 +76815,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_3(opt); + _loop_5(opt); } return options; } @@ -74604,10 +76923,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 250 /* JsxAttribute */: - case 248 /* JsxOpeningElement */: - case 249 /* JsxClosingElement */: - case 247 /* JsxSelfClosingElement */: + case 252 /* JsxAttribute */: + case 250 /* JsxOpeningElement */: + case 251 /* JsxClosingElement */: + case 249 /* JsxSelfClosingElement */: return node.kind === 70 /* Identifier */; } } @@ -75019,11 +77338,11 @@ var ts; this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Space after }. - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromRange(0 /* FirstToken */, 141 /* LastToken */, [19 /* CloseParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 81 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 105 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 21 /* CloseBracketToken */, 25 /* CommaToken */, 24 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([21 /* CloseBracketToken */, 25 /* CommaToken */, 24 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // No space for dot this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); @@ -75040,10 +77359,10 @@ var ts; this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 80 /* DoKeyword */, 101 /* TryKeyword */, 86 /* FinallyKeyword */, 81 /* ElseKeyword */]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8 /* Delete */)); this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenBraceToken */, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); // Insert new line after { and before } in multi-line contexts. this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); @@ -75073,6 +77392,7 @@ var ts; this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([109 /* LetKeyword */, 75 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95 /* ReturnKeyword */, 24 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); @@ -75083,18 +77403,19 @@ var ts; this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101 /* TryKeyword */, 86 /* FinallyKeyword */]), 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124 /* GetKeyword */, 133 /* SetKeyword */]), 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124 /* GetKeyword */, 134 /* SetKeyword */]), 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); // TypeScript-specific higher priority rules // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses + this.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([127 /* ModuleKeyword */, 131 /* RequireKeyword */]), 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 133 /* SetKeyword */, 114 /* StaticKeyword */, 136 /* TypeKeyword */, 138 /* FromKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 138 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 130 /* ReadonlyKeyword */, 134 /* SetKeyword */, 114 /* StaticKeyword */, 137 /* TypeKeyword */, 139 /* FromKeyword */, 126 /* KeyOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 139 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions @@ -75114,7 +77435,7 @@ var ts; // decorators this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 70 /* Identifier */, 83 /* ExportKeyword */, 78 /* DefaultKeyword */, 74 /* ClassKeyword */, 114 /* StaticKeyword */, 113 /* PublicKeyword */, 111 /* PrivateKeyword */, 112 /* ProtectedKeyword */, 124 /* GetKeyword */, 133 /* SetKeyword */, 20 /* OpenBracketToken */, 38 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 70 /* Identifier */, 83 /* ExportKeyword */, 78 /* DefaultKeyword */, 74 /* ClassKeyword */, 114 /* StaticKeyword */, 113 /* PublicKeyword */, 111 /* PrivateKeyword */, 112 /* ProtectedKeyword */, 124 /* GetKeyword */, 134 /* SetKeyword */, 20 /* OpenBracketToken */, 38 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115 /* YieldKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); @@ -75130,6 +77451,8 @@ var ts; this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* SlashToken */, 28 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57 /* EqualsToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57 /* EqualsToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + // No space before non-null assertion operator + this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50 /* ExclamationToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -75160,7 +77483,7 @@ var ts; this.SpaceBeforeJsxAttribute, this.SpaceBeforeSlashInJsxOpeningElement, this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement, this.NoSpaceBeforeEqualInJsxAttribute, this.NoSpaceAfterEqualInJsxAttribute, // TypeScript-specific rules - this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, + this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, this.SpaceBeforeArrow, this.SpaceAfterArrow, @@ -75175,6 +77498,7 @@ var ts; this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, + this.NoSpaceBeforeNonNullAssertionOperator ]; // These rules are lower in priority than user-configurable rules. this.LowPriorityCommonRules = [ @@ -75184,7 +77508,6 @@ var ts; this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, - this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; /// @@ -75242,9 +77565,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_49 in o) { - if (o[name_49] === rule) { - return name_49; + for (var name in o) { + if (o[name] === rule) { + return name; } } throw new Error("Unknown rule"); @@ -75253,42 +77576,44 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 211 /* ForStatement */; + return context.contextNode.kind === 213 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 192 /* BinaryExpression */: - case 193 /* ConditionalExpression */: - case 200 /* AsExpression */: - case 243 /* ExportSpecifier */: - case 239 /* ImportSpecifier */: - case 156 /* TypePredicate */: - case 164 /* UnionType */: - case 165 /* IntersectionType */: + case 193 /* BinaryExpression */: + case 194 /* ConditionalExpression */: + case 201 /* AsExpression */: + case 245 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: + case 157 /* TypePredicate */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 174 /* BindingElement */: + case 175 /* BindingElement */: // equals in type X = ... - case 228 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: // equal in p = 0; - case 144 /* Parameter */: - case 260 /* EnumMember */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 145 /* Parameter */: + case 263 /* EnumMember */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return context.currentTokenSpan.kind === 57 /* EqualsToken */ || context.nextTokenSpan.kind === 57 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: + // "in" keyword in [P in keyof T]: T[P] + case 144 /* TypeParameter */: return context.currentTokenSpan.kind === 91 /* InKeyword */ || context.nextTokenSpan.kind === 91 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 213 /* ForOfStatement */: - return context.currentTokenSpan.kind === 140 /* OfKeyword */ || context.nextTokenSpan.kind === 140 /* OfKeyword */; + case 215 /* ForOfStatement */: + return context.currentTokenSpan.kind === 141 /* OfKeyword */ || context.nextTokenSpan.kind === 141 /* OfKeyword */; } return false; }; @@ -75296,7 +77621,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 193 /* ConditionalExpression */; + return context.contextNode.kind === 194 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -75317,6 +77642,9 @@ var ts; //// * ) and { are on different lines. We only need to format if the block is multiline context. So in this case we format. return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; + Rules.IsBraceWrappedContext = function (context) { + return context.contextNode.kind === 173 /* ObjectBindingPattern */ || Rules.IsSingleLineBlockContext(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()); @@ -75340,97 +77668,103 @@ var ts; return true; } switch (node.kind) { - case 204 /* Block */: - case 232 /* CaseBlock */: - case 176 /* ObjectLiteralExpression */: - case 231 /* ModuleBlock */: + case 206 /* Block */: + case 234 /* CaseBlock */: + case 177 /* ObjectLiteralExpression */: + case 233 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 225 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 153 /* CallSignature */: - case 184 /* FunctionExpression */: - case 150 /* Constructor */: - case 185 /* ArrowFunction */: + case 154 /* CallSignature */: + case 185 /* FunctionExpression */: + case 151 /* Constructor */: + case 186 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 225 /* FunctionDeclaration */ || context.contextNode.kind === 184 /* FunctionExpression */; + return context.contextNode.kind === 227 /* FunctionDeclaration */ || context.contextNode.kind === 185 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 161 /* TypeLiteral */: - case 230 /* ModuleDeclaration */: - case 241 /* ExportDeclaration */: - case 242 /* NamedExports */: - case 235 /* ImportDeclaration */: - case 238 /* NamedImports */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 162 /* TypeLiteral */: + case 232 /* ModuleDeclaration */: + case 243 /* ExportDeclaration */: + case 244 /* NamedExports */: + case 237 /* ImportDeclaration */: + case 240 /* NamedImports */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 226 /* ClassDeclaration */: - case 230 /* ModuleDeclaration */: - case 229 /* EnumDeclaration */: - case 204 /* Block */: - case 256 /* CatchClause */: - case 231 /* ModuleBlock */: - case 218 /* SwitchStatement */: + case 228 /* ClassDeclaration */: + case 232 /* ModuleDeclaration */: + case 231 /* EnumDeclaration */: + case 259 /* CatchClause */: + case 233 /* ModuleBlock */: + case 220 /* SwitchStatement */: return true; + case 206 /* Block */: { + var blockParent = context.currentTokenParent.parent; + if (blockParent.kind !== 186 /* ArrowFunction */ && + blockParent.kind !== 185 /* FunctionExpression */) { + return true; + } + } } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 208 /* IfStatement */: - case 218 /* SwitchStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 210 /* WhileStatement */: - case 221 /* TryStatement */: - case 209 /* DoStatement */: - case 217 /* WithStatement */: + case 210 /* IfStatement */: + case 220 /* SwitchStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 212 /* WhileStatement */: + case 223 /* TryStatement */: + case 211 /* DoStatement */: + case 219 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 256 /* CatchClause */: + case 259 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 176 /* ObjectLiteralExpression */; + return context.contextNode.kind === 177 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 179 /* CallExpression */; + return context.contextNode.kind === 180 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 180 /* NewExpression */; + return context.contextNode.kind === 181 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -75442,25 +77776,25 @@ var ts; return context.nextTokenSpan.kind !== 21 /* CloseBracketToken */; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 185 /* ArrowFunction */; + return context.contextNode.kind === 186 /* ArrowFunction */; }; Rules.IsNonJsxSameLineTokenContext = function (context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 246 /* JsxElement */; + return context.contextNode.kind !== 248 /* JsxElement */; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 252 /* JsxExpression */; + return context.contextNode.kind === 255 /* JsxExpression */; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 250 /* JsxAttribute */; + return context.nextTokenParent.kind === 252 /* JsxAttribute */; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 250 /* JsxAttribute */; + return context.contextNode.kind === 252 /* JsxAttribute */; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 247 /* JsxSelfClosingElement */; + return context.contextNode.kind === 249 /* JsxSelfClosingElement */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -75475,41 +77809,42 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 145 /* Decorator */; + return node.kind === 146 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 224 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 226 /* 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 === 230 /* ModuleDeclaration */; + return context.contextNode.kind === 232 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 161 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 162 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 26 /* LessThanToken */ && token.kind !== 28 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 157 /* TypeReference */: - case 182 /* TypeAssertionExpression */: - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 199 /* ExpressionWithTypeArguments */: + case 158 /* TypeReference */: + case 183 /* TypeAssertionExpression */: + case 230 /* TypeAliasDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 200 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -75520,13 +77855,16 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 182 /* TypeAssertionExpression */; + return context.contextNode.kind === 183 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 104 /* VoidKeyword */ && context.currentTokenParent.kind === 188 /* VoidExpression */; + return context.currentTokenSpan.kind === 104 /* VoidKeyword */ && context.currentTokenParent.kind === 189 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 195 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 196 /* YieldExpression */ && context.contextNode.expression !== undefined; + }; + Rules.IsNonNullAssertionContext = function (context) { + return context.contextNode.kind === 202 /* NonNullExpression */; }; return Rules; }()); @@ -75550,7 +77888,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 140 /* LastToken */ + 1; + this.mapRowLength = 141 /* 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); @@ -75564,7 +77902,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - ts.Debug.assert(row <= 140 /* LastKeyword */ && column <= 140 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 141 /* LastKeyword */ && column <= 141 /* LastKeyword */, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -75745,7 +78083,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 140 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 141 /* LastToken */; token++) { result.push(token); } return result; @@ -75789,9 +78127,9 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(71 /* FirstKeyword */, 140 /* LastKeyword */); + TokenRange.Keywords = TokenRange.FromRange(71 /* FirstKeyword */, 141 /* LastKeyword */); TokenRange.BinaryOperators = TokenRange.FromRange(26 /* FirstBinaryOperator */, 69 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91 /* InKeyword */, 92 /* InstanceOfKeyword */, 140 /* OfKeyword */, 117 /* AsKeyword */, 125 /* IsKeyword */]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91 /* InKeyword */, 92 /* InstanceOfKeyword */, 141 /* OfKeyword */, 117 /* AsKeyword */, 125 /* IsKeyword */]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42 /* PlusPlusToken */, 43 /* MinusMinusToken */, 51 /* TildeToken */, 50 /* ExclamationToken */]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 70 /* Identifier */, 18 /* OpenParenToken */, 20 /* OpenBracketToken */, 16 /* OpenBraceToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); @@ -75799,7 +78137,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 19 /* CloseParenToken */, 21 /* CloseBracketToken */, 93 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([70 /* Identifier */, 132 /* NumberKeyword */, 134 /* StringKeyword */, 121 /* BooleanKeyword */, 135 /* SymbolKeyword */, 104 /* VoidKeyword */, 118 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([70 /* Identifier */, 132 /* NumberKeyword */, 135 /* StringKeyword */, 121 /* BooleanKeyword */, 136 /* SymbolKeyword */, 104 /* VoidKeyword */, 118 /* AnyKeyword */]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -75846,6 +78184,12 @@ var ts; }; RulesProvider.prototype.createActiveRules = function (options) { var rules = this.globalRules.HighPriorityCommonRules.slice(0); + if (options.insertSpaceAfterConstructor) { + rules.push(this.globalRules.SpaceAfterConstructor); + } + else { + rules.push(this.globalRules.NoSpaceAfterConstructor); + } if (options.insertSpaceAfterCommaDelimiter) { rules.push(this.globalRules.SpaceAfterComma); } @@ -75926,6 +78270,12 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); rules.push(this.globalRules.NoSpaceAfterBinaryOperator); } + if (options.insertSpaceBeforeFunctionParenthesis) { + rules.push(this.globalRules.SpaceBeforeOpenParenInFuncDecl); + } + else { + rules.push(this.globalRules.NoSpaceBeforeOpenParenInFuncDecl); + } if (options.placeOpenBraceOnNewLineForControlBlocks) { rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); } @@ -76058,17 +78408,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 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 231 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 261 /* SourceFile */: - case 204 /* Block */: - case 231 /* ModuleBlock */: + return body && body.kind === 233 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 264 /* SourceFile */: + case 206 /* Block */: + case 233 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -76273,20 +78623,20 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 226 /* ClassDeclaration */: return 74 /* ClassKeyword */; - case 227 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; - case 225 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; - case 229 /* EnumDeclaration */: return 229 /* EnumDeclaration */; - case 151 /* GetAccessor */: return 124 /* GetKeyword */; - case 152 /* SetAccessor */: return 133 /* SetKeyword */; - case 149 /* MethodDeclaration */: + case 228 /* ClassDeclaration */: return 74 /* ClassKeyword */; + case 229 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; + case 227 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; + case 231 /* EnumDeclaration */: return 231 /* EnumDeclaration */; + case 152 /* GetAccessor */: return 124 /* GetKeyword */; + case 153 /* SetAccessor */: return 134 /* SetKeyword */; + case 150 /* MethodDeclaration */: if (node.asteriskToken) { return 38 /* AsteriskToken */; } /* fall-through */ - case 147 /* PropertyDeclaration */: - case 144 /* Parameter */: + case 148 /* PropertyDeclaration */: + case 145 /* Parameter */: return node.name.kind; } } @@ -76316,18 +78666,31 @@ var ts; // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent case 16 /* OpenBraceToken */: case 17 /* CloseBraceToken */: - case 20 /* OpenBracketToken */: - case 21 /* CloseBracketToken */: case 18 /* OpenParenToken */: case 19 /* CloseParenToken */: case 81 /* ElseKeyword */: case 105 /* WhileKeyword */: case 56 /* AtToken */: return indentation; - default: - // if token line equals to the line of containing node (this is a first token in the node) - use node indentation - return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; + case 40 /* SlashToken */: + case 28 /* GreaterThanToken */: { + if (container.kind === 250 /* JsxOpeningElement */ || + container.kind === 251 /* JsxClosingElement */ || + container.kind === 249 /* JsxSelfClosingElement */) { + return indentation; + } + break; + } + case 20 /* OpenBracketToken */: + case 21 /* CloseBracketToken */: { + if (container.kind !== 171 /* MappedType */) { + return indentation; + } + break; + } } + // 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 + getEffectiveDelta(delta, container) : indentation; }, getIndentation: function () { return indentation; }, getDelta: function (child) { return getEffectiveDelta(delta, child); }, @@ -76383,7 +78746,7 @@ var ts; if (tokenInfo.token.end > node.end) { break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); @@ -76417,7 +78780,7 @@ var ts; // stop when formatting scanner advances past the beginning of the child break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, node); } if (!formattingScanner.isOnToken()) { return inheritedIndentation; @@ -76430,11 +78793,11 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 145 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 146 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 175 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 176 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -76457,11 +78820,11 @@ var ts; 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); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } else { // consume any tokens that precede the list as child elements of 'node' using its indentation scope - consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); } } } @@ -76479,7 +78842,7 @@ var ts; // 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); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } } } @@ -76686,7 +79049,7 @@ var ts; } // shift all parts on the delta size var delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; i++, startLine++) { + for (var i = startIndex; i < parts.length; i++, startLine++) { var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart @@ -76791,12 +79154,12 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 150 /* Constructor */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 185 /* ArrowFunction */: + case 151 /* Constructor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 186 /* ArrowFunction */: if (node.typeParameters === list) { return 26 /* LessThanToken */; } @@ -76804,8 +79167,8 @@ var ts; return 18 /* OpenParenToken */; } break; - case 179 /* CallExpression */: - case 180 /* NewExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: if (node.typeArguments === list) { return 26 /* LessThanToken */; } @@ -76813,7 +79176,7 @@ var ts; return 18 /* OpenParenToken */; } break; - case 157 /* TypeReference */: + case 158 /* TypeReference */: if (node.typeArguments === list) { return 26 /* LessThanToken */; } @@ -76929,7 +79292,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 25 /* CommaToken */ && precedingToken.parent.kind !== 192 /* BinaryExpression */) { + if (precedingToken.kind === 25 /* CommaToken */ && precedingToken.parent.kind !== 193 /* 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 */) { @@ -77052,7 +79415,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.isStatementButNotDeclaration(current)) && - (parent.kind === 261 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 264 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -77085,7 +79448,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 208 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 210 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -77097,23 +79460,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 157 /* TypeReference */: + case 158 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return node.parent.properties; - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return node.parent.elements; - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: { + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -77124,8 +79487,8 @@ var ts; } break; } - case 180 /* NewExpression */: - case 179 /* CallExpression */: { + case 181 /* NewExpression */: + case 180 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -77155,8 +79518,8 @@ var ts; if (node.kind === 19 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 179 /* CallExpression */ || - node.parent.kind === 180 /* NewExpression */) && + if (node.parent && (node.parent.kind === 180 /* CallExpression */ || + node.parent.kind === 181 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -77174,10 +79537,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 177 /* PropertyAccessExpression */: - case 178 /* ElementAccessExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 178 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: node = node.expression; break; default: @@ -77241,48 +79604,49 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 207 /* ExpressionStatement */: - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 175 /* ArrayLiteralExpression */: - case 204 /* Block */: - case 231 /* ModuleBlock */: - case 176 /* ObjectLiteralExpression */: - case 161 /* TypeLiteral */: - case 163 /* TupleType */: - case 232 /* CaseBlock */: - case 254 /* DefaultClause */: - case 253 /* CaseClause */: - case 183 /* ParenthesizedExpression */: - case 177 /* PropertyAccessExpression */: - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 205 /* VariableStatement */: - case 223 /* VariableDeclaration */: - case 240 /* ExportAssignment */: - case 216 /* ReturnStatement */: - case 193 /* ConditionalExpression */: - case 173 /* ArrayBindingPattern */: - case 172 /* ObjectBindingPattern */: - case 248 /* JsxOpeningElement */: - case 247 /* JsxSelfClosingElement */: - case 252 /* JsxExpression */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 144 /* Parameter */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 166 /* ParenthesizedType */: - case 181 /* TaggedTemplateExpression */: - case 189 /* AwaitExpression */: - case 242 /* NamedExports */: - case 238 /* NamedImports */: - case 243 /* ExportSpecifier */: - case 239 /* ImportSpecifier */: + case 209 /* ExpressionStatement */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 176 /* ArrayLiteralExpression */: + case 206 /* Block */: + case 233 /* ModuleBlock */: + case 177 /* ObjectLiteralExpression */: + case 162 /* TypeLiteral */: + case 171 /* MappedType */: + case 164 /* TupleType */: + case 234 /* CaseBlock */: + case 257 /* DefaultClause */: + case 256 /* CaseClause */: + case 184 /* ParenthesizedExpression */: + case 178 /* PropertyAccessExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 207 /* VariableStatement */: + case 225 /* VariableDeclaration */: + case 242 /* ExportAssignment */: + case 218 /* ReturnStatement */: + case 194 /* ConditionalExpression */: + case 174 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 250 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + case 255 /* JsxExpression */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 145 /* Parameter */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 167 /* ParenthesizedType */: + case 182 /* TaggedTemplateExpression */: + case 190 /* AwaitExpression */: + case 244 /* NamedExports */: + case 240 /* NamedImports */: + case 245 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: return true; } return false; @@ -77291,27 +79655,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 211 /* ForStatement */: - case 208 /* IfStatement */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 185 /* ArrowFunction */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - return childKind !== 204 /* Block */; - case 241 /* ExportDeclaration */: - return childKind !== 242 /* NamedExports */; - case 235 /* ImportDeclaration */: - return childKind !== 236 /* ImportClause */ || - (child.namedBindings && child.namedBindings.kind !== 238 /* NamedImports */); - case 246 /* JsxElement */: - return childKind !== 249 /* JsxClosingElement */; + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 213 /* ForStatement */: + case 210 /* IfStatement */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 186 /* ArrowFunction */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + return childKind !== 206 /* Block */; + case 243 /* ExportDeclaration */: + return childKind !== 244 /* NamedExports */; + case 237 /* ImportDeclaration */: + return childKind !== 238 /* ImportClause */ || + (child.namedBindings && child.namedBindings.kind !== 240 /* NamedImports */); + case 248 /* JsxElement */: + return childKind !== 251 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -77332,7 +79696,7 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var codeFixes = ts.createMap(); + var codeFixes = []; function registerCodeFix(action) { ts.forEach(action.errorCodes, function (error) { var fixes = codeFixes[error]; @@ -77367,25 +79731,128 @@ var ts; (function (ts) { var codefix; (function (codefix) { - function getOpenBraceEnd(constructor, sourceFile) { - // First token is the open curly, this is where we want to put the 'super' call. - return constructor.body.getFirstToken(sourceFile).getEnd(); - } codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 122 /* ConstructorKeyword */) { - return undefined; - } - var newPosition = getOpenBraceEnd(token.parent, sourceFile); - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] - }]; - } + errorCodes: [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code], + getCodeActions: getActionForClassLikeIncorrectImplementsInterface }); + function getActionForClassLikeIncorrectImplementsInterface(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + var classDecl = ts.getContainingClass(token); + if (!classDecl) { + return undefined; + } + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDecl); + var hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, 1 /* Number */); + var hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, 0 /* String */); + var result = []; + for (var _i = 0, implementedTypeNodes_2 = implementedTypeNodes; _i < implementedTypeNodes_2.length; _i++) { + var implementedTypeNode = implementedTypeNodes_2[_i]; + var implementedType = checker.getTypeFromTypeNode(implementedTypeNode); + // Note that this is ultimately derived from a map indexed by symbol names, + // so duplicates cannot occur. + var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); + var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); }); + var insertion = getMissingIndexSignatureInsertion(implementedType, 1 /* Number */, classDecl, hasNumericIndexSignature); + insertion += getMissingIndexSignatureInsertion(implementedType, 0 /* String */, classDecl, hasStringIndexSignature); + insertion += codefix.getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); + var message = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); + if (insertion) { + pushAction(result, insertion, message); + } + } + return result; + function getMissingIndexSignatureInsertion(type, kind, enclosingDeclaration, hasIndexSigOfKind) { + if (!hasIndexSigOfKind) { + var IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); + if (IndexInfoOfKind) { + var writer = ts.getSingleLineStringWriter(); + checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); + var result_6 = writer.string(); + ts.releaseStringWriter(writer); + return result_6; + } + } + return ""; + } + function pushAction(result, insertion, description) { + var newAction = { + description: description, + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }; + result.push(newAction); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + function getActionForClassLikeMissingAbstractMember(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + // This is the identifier in the case of a class declaration + // or the class keyword token in the case of a class expression. + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + if (ts.isClassLike(token.parent)) { + var classDecl = token.parent; + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + // Note that this is ultimately derived from a map indexed by symbol names, + // so duplicates cannot occur. + var extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); + var abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); + var insertion = codefix.getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); + if (insertion.length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_inherited_abstract_class), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }]; + } + } + return undefined; + } + function symbolPointsToNonPrivateAndAbstractMember(symbol) { + var decls = symbol.getDeclarations(); + ts.Debug.assert(!!(decls && decls.length > 0)); + var flags = ts.getModifierFlags(decls[0]); + return !(flags & 8 /* Private */) && !!(flags & 128 /* Abstract */); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { codefix.registerCodeFix({ errorCodes: [ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], getCodeActions: function (context) { @@ -77401,7 +79868,7 @@ var ts; } // figure out if the this access is actuall inside the supercall // i.e. super(this.a), since in that case we won't suggest a fix - if (superCall.expression && superCall.expression.kind == 179 /* CallExpression */) { + if (superCall.expression && superCall.expression.kind == 180 /* CallExpression */) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -77409,7 +79876,7 @@ var ts; } } } - var newPosition = getOpenBraceEnd(constructor, sourceFile); + var newPosition = ts.getOpenBraceEnd(constructor, sourceFile); var changes = [{ fileName: sourceFile.fileName, textChanges: [{ newText: superCall.getText(sourceFile), @@ -77425,7 +79892,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + if (n.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -77439,6 +79906,272 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 122 /* ConstructorKeyword */) { + return undefined; + } + var newPosition = ts.getOpenBraceEnd(token.parent, sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var classDeclNode = ts.getContainingClass(token); + if (!(token.kind === 70 /* Identifier */ && ts.isClassLike(classDeclNode))) { + return undefined; + } + var heritageClauses = classDeclNode.heritageClauses; + if (!(heritageClauses && heritageClauses.length > 0)) { + return undefined; + } + var extendsToken = heritageClauses[0].getFirstToken(); + if (!(extendsToken && extendsToken.kind === 84 /* ExtendsKeyword */)) { + return undefined; + } + var changeStart = extendsToken.getStart(sourceFile); + var changeEnd = extendsToken.getEnd(); + var textChanges = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + // We replace existing keywords with commas. + for (var i = 1; i < heritageClauses.length; i++) { + var keywordToken = heritageClauses[i].getFirstToken(); + if (keywordToken) { + changeStart = keywordToken.getStart(sourceFile); + changeEnd = keywordToken.getEnd(); + textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + } + } + var result = [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Change_extends_to_implements), + changes: [{ + fileName: sourceFile.fileName, + textChanges: textChanges + }] + }]; + return result; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + var start = token.getStart(sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_this_to_unresolved_variable), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "this.", span: { start: start, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ + ts.Diagnostics._0_is_declared_but_never_used.code, + ts.Diagnostics.Property_0_is_declared_but_never_used.code + ], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + // this handles var ["computed"] = 12; + if (token.kind === 20 /* OpenBracketToken */) { + token = ts.getTokenAtPosition(sourceFile, start + 1); + } + switch (token.kind) { + case 70 /* Identifier */: + switch (token.parent.kind) { + case 225 /* VariableDeclaration */: + switch (token.parent.parent.parent.kind) { + case 213 /* ForStatement */: + var forStatement = token.parent.parent.parent; + var forInitializer = forStatement.initializer; + if (forInitializer.declarations.length === 1) { + return createCodeFixToRemoveNode(forInitializer); + } + else { + return removeSingleItem(forInitializer.declarations, token); + } + case 215 /* ForOfStatement */: + var forOfStatement = token.parent.parent.parent; + if (forOfStatement.initializer.kind === 226 /* VariableDeclarationList */) { + var forOfInitializer = forOfStatement.initializer; + return createCodeFix("{}", forOfInitializer.declarations[0].getStart(), forOfInitializer.declarations[0].getWidth()); + } + break; + case 214 /* ForInStatement */: + // There is no valid fix in the case of: + // for .. in + return undefined; + case 259 /* CatchClause */: + var catchClause = token.parent.parent; + var parameter = catchClause.variableDeclaration.getChildren()[0]; + return createCodeFixToRemoveNode(parameter); + default: + var variableStatement = token.parent.parent.parent; + if (variableStatement.declarationList.declarations.length === 1) { + return createCodeFixToRemoveNode(variableStatement); + } + else { + var declarations = variableStatement.declarationList.declarations; + return removeSingleItem(declarations, token); + } + } + case 144 /* TypeParameter */: + var typeParameters = token.parent.parent.typeParameters; + if (typeParameters.length === 1) { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + } + else { + return removeSingleItem(typeParameters, token); + } + case 145 /* Parameter */: + var functionDeclaration = token.parent.parent; + if (functionDeclaration.parameters.length === 1) { + return createCodeFixToRemoveNode(token.parent); + } + else { + return removeSingleItem(functionDeclaration.parameters, token); + } + // handle case where 'import a = A;' + case 236 /* ImportEqualsDeclaration */: + var importEquals = findImportDeclaration(token); + return createCodeFixToRemoveNode(importEquals); + case 241 /* ImportSpecifier */: + var namedImports = token.parent.parent; + if (namedImports.elements.length === 1) { + // Only 1 import and it is unused. So the entire declaration should be removed. + var importSpec = findImportDeclaration(token); + return createCodeFixToRemoveNode(importSpec); + } + else { + return removeSingleItem(namedImports.elements, token); + } + // handle case where "import d, * as ns from './file'" + // or "'import {a, b as ns} from './file'" + case 238 /* ImportClause */: + var importClause = token.parent; + if (!importClause.namedBindings) { + var importDecl = findImportDeclaration(importClause); + return createCodeFixToRemoveNode(importDecl); + } + else { + // import |d,| * as ns from './file' + var start_4 = importClause.name.getStart(); + var end = findFirstNonSpaceCharPosStarting(importClause.name.end); + if (sourceFile.text.charCodeAt(end) === 44 /* comma */) { + end = findFirstNonSpaceCharPosStarting(end + 1); + } + return createCodeFix("", start_4, end - start_4); + } + case 239 /* NamespaceImport */: + var namespaceImport = token.parent; + if (namespaceImport.name == token && !namespaceImport.parent.name) { + var importDecl = findImportDeclaration(namespaceImport); + return createCodeFixToRemoveNode(importDecl); + } + else { + var start_5 = namespaceImport.parent.name.end; + return createCodeFix("", start_5, namespaceImport.parent.namedBindings.end - start_5); + } + } + break; + case 148 /* PropertyDeclaration */: + case 239 /* NamespaceImport */: + return createCodeFixToRemoveNode(token.parent); + } + if (ts.isDeclarationName(token)) { + return createCodeFixToRemoveNode(token.parent); + } + else if (ts.isLiteralComputedPropertyDeclarationName(token)) { + return createCodeFixToRemoveNode(token.parent.parent); + } + else { + return undefined; + } + function findImportDeclaration(token) { + var importDecl = token; + while (importDecl.kind != 237 /* ImportDeclaration */ && importDecl.parent) { + importDecl = importDecl.parent; + } + return importDecl; + } + function createCodeFixToRemoveNode(node) { + var end = node.getEnd(); + var endCharCode = sourceFile.text.charCodeAt(end); + var afterEndCharCode = sourceFile.text.charCodeAt(end + 1); + if (ts.isLineBreak(endCharCode)) { + end += 1; + } + // in the case of CR LF, you could have two consecutive new line characters for one new line. + // this needs to be differenciated from two LF LF chars that actually mean two new lines. + if (ts.isLineBreak(afterEndCharCode) && endCharCode !== afterEndCharCode) { + end += 1; + } + var start = node.getStart(); + return createCodeFix("", start, end - start); + } + function findFirstNonSpaceCharPosStarting(start) { + while (ts.isWhiteSpace(sourceFile.text.charCodeAt(start))) { + start += 1; + } + return start; + } + function createCodeFix(newText, start, length) { + return [{ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ newText: newText, span: { start: start, length: length } }] + }] + }]; + } + function removeSingleItem(elements, token) { + if (elements[0] === token.parent) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + } + else { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + } + } + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -77450,18 +80183,19 @@ var ts; })(ModuleSpecifierComparison || (ModuleSpecifierComparison = {})); var ImportCodeActionMap = (function () { function ImportCodeActionMap() { - this.symbolIdToActionMap = ts.createMap(); + this.symbolIdToActionMap = []; } ImportCodeActionMap.prototype.addAction = function (symbolId, newAction) { if (!newAction) { return; } - if (!this.symbolIdToActionMap[symbolId]) { + var actions = this.symbolIdToActionMap[symbolId]; + if (!actions) { this.symbolIdToActionMap[symbolId] = [newAction]; return; } if (newAction.kind === "CodeChange") { - this.symbolIdToActionMap[symbolId].push(newAction); + actions.push(newAction); return; } var updatedNewImports = []; @@ -77505,8 +80239,8 @@ var ts; }; ImportCodeActionMap.prototype.getAllActions = function () { var result = []; - for (var symbolId in this.symbolIdToActionMap) { - result = ts.concatenate(result, this.symbolIdToActionMap[symbolId]); + for (var key in this.symbolIdToActionMap) { + result = ts.concatenate(result, this.symbolIdToActionMap[key]); } return result; }; @@ -77538,7 +80272,11 @@ var ts; return ImportCodeActionMap; }()); codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Cannot_find_name_0.code], + errorCodes: [ + ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics.Cannot_find_namespace_0.code, + ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ], getCodeActions: function (context) { var sourceFile = context.sourceFile; var checker = context.program.getTypeChecker(); @@ -77548,8 +80286,13 @@ var ts; var name = token.getText(); var symbolIdActionMap = new ImportCodeActionMap(); // this is a module id -> module import declaration map - var cachedImportDeclarations = ts.createMap(); + var cachedImportDeclarations = []; var cachedNewImportInsertPosition; + var currentTokenMeaning = ts.getMeaningFromLocation(token); + if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { + var symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); + return getCodeActionForImport(symbol, /*isDefault*/ false, /*isNamespaceImport*/ true); + } var allPotentialModules = checker.getAmbientModules(); for (var _i = 0, allSourceFiles_1 = allSourceFiles; _i < allSourceFiles_1.length; _i++) { var otherSourceFile = allSourceFiles_1[_i]; @@ -77557,7 +80300,6 @@ var ts; allPotentialModules.push(otherSourceFile.symbol); } } - var currentTokenMeaning = ts.getMeaningFromLocation(token); for (var _a = 0, allPotentialModules_1 = allPotentialModules; _a < allPotentialModules_1.length; _a++) { var moduleSymbol = allPotentialModules_1[_a]; context.cancellationToken.throwIfCancellationRequested(); @@ -77581,8 +80323,9 @@ var ts; return symbolIdActionMap.getAllActions(); function getImportDeclarations(moduleSymbol) { var moduleSymbolId = getUniqueSymbolId(moduleSymbol); - if (cachedImportDeclarations[moduleSymbolId]) { - return cachedImportDeclarations[moduleSymbolId]; + var cached = cachedImportDeclarations[moduleSymbolId]; + if (cached) { + return cached; } var existingDeclarations = []; for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { @@ -77597,10 +80340,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 235 /* ImportDeclaration */) { + if (node.kind === 237 /* ImportDeclaration */) { return node; } - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 236 /* ImportEqualsDeclaration */) { return node; } node = node.parent; @@ -77618,7 +80361,7 @@ var ts; var declarations = symbol.getDeclarations(); return declarations ? ts.some(symbol.declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }) : false; } - function getCodeActionForImport(moduleSymbol, isDefault) { + function getCodeActionForImport(moduleSymbol, isDefault, isNamespaceImport) { var existingDeclarations = getImportDeclarations(moduleSymbol); if (existingDeclarations.length > 0) { // With an existing import statement, there are more than one actions the user can do. @@ -77644,11 +80387,11 @@ var ts; var namespaceImportDeclaration; var namedImportDeclaration; var existingModuleSpecifier; - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; - if (declaration.kind === 235 /* ImportDeclaration */) { + for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { + var declaration = declarations_14[_i]; + if (declaration.kind === 237 /* ImportDeclaration */) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 237 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 239 /* NamespaceImport */) { // case: // import * as ns from "foo" namespaceImportDeclaration = declaration; @@ -77672,7 +80415,7 @@ var ts; if (namespaceImportDeclaration) { actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration)); } - if (namedImportDeclaration && namedImportDeclaration.importClause && + if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause && (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { /** * If the existing import declaration already has a named import list, just @@ -77688,7 +80431,7 @@ var ts; } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 245 /* ExternalModuleReference */) { + if (declaration.moduleReference && declaration.moduleReference.kind === 247 /* ExternalModuleReference */) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); @@ -77736,7 +80479,7 @@ var ts; } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 235 /* ImportDeclaration */) { + if (declaration.kind === 237 /* ImportDeclaration */) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { @@ -77773,7 +80516,9 @@ var ts; var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); var importStatementText = isDefault ? "import " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" - : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; + : isNamespaceImport + ? "import * as " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" + : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; // if this file doesn't have any import statements, insert an import statement and then insert a new line // between the only import statement and user code. Otherwise just insert the statement because chances // are there are already a new line seperating code and import statements. @@ -77782,18 +80527,18 @@ var ts; : "" + context.newLineCharacter + importStatementText + ";"; return createCodeAction(ts.Diagnostics.Import_0_from_1, [name, "\"" + moduleSpecifierWithoutQuotes + "\""], newText, { start: cachedNewImportInsertPosition, length: 0 }, sourceFile.fileName, "NewImport", moduleSpecifierWithoutQuotes); function getModuleSpecifierForNewImport() { - var fileName = sourceFile.path; - var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().path; + var fileName = sourceFile.fileName; + var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; var sourceDirectory = ts.getDirectoryPath(fileName); var options = context.program.getCompilerOptions(); return tryGetModuleNameFromAmbientModule() || - tryGetModuleNameFromBaseUrl() || - tryGetModuleNameFromRootDirs() || tryGetModuleNameFromTypeRoots() || tryGetModuleNameAsNodeModule() || + tryGetModuleNameFromBaseUrl() || + tryGetModuleNameFromRootDirs() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 261 /* SourceFile */) { + if (moduleSymbol.valueDeclaration.kind !== 264 /* SourceFile */) { return moduleSymbol.name; } } @@ -77801,11 +80546,11 @@ var ts; if (!options.baseUrl) { return undefined; } - var normalizedBaseUrl = ts.toPath(options.baseUrl, ts.getDirectoryPath(options.baseUrl), getCanonicalFileName); - var relativeName = tryRemoveParentDirectoryName(moduleFileName, normalizedBaseUrl); + var relativeName = getRelativePathIfInDirectory(moduleFileName, options.baseUrl); if (!relativeName) { return undefined; } + var relativeNameWithIndex = ts.removeFileExtension(relativeName); relativeName = removeExtensionAndIndexPostFix(relativeName); if (options.paths) { for (var key in options.paths) { @@ -77825,7 +80570,7 @@ var ts; return key.replace("\*", matchedStar); } } - else if (pattern === relativeName) { + else if (pattern === relativeName || pattern === relativeNameWithIndex) { return key; } } @@ -77835,9 +80580,8 @@ var ts; } function tryGetModuleNameFromRootDirs() { if (options.rootDirs) { - var normalizedRootDirs = ts.map(options.rootDirs, function (rootDir) { return ts.toPath(rootDir, /*basePath*/ undefined, getCanonicalFileName); }); - var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, normalizedRootDirs); - var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, normalizedRootDirs); + var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, options.rootDirs); + var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, options.rootDirs); if (normalizedTargetPath !== undefined) { var relativePath = normalizedSourcePath !== undefined ? getRelativePath(normalizedTargetPath, normalizedSourcePath) : normalizedTargetPath; return ts.removeFileExtension(relativePath); @@ -77901,7 +80645,7 @@ var ts; function getPathRelativeToRootDirs(path, rootDirs) { for (var _i = 0, rootDirs_2 = rootDirs; _i < rootDirs_2.length; _i++) { var rootDir = rootDirs_2[_i]; - var relativeName = tryRemoveParentDirectoryName(path, rootDir); + var relativeName = getRelativePathIfInDirectory(path, rootDir); if (relativeName !== undefined) { return relativeName; } @@ -77915,19 +80659,14 @@ var ts; } return fileName; } + function getRelativePathIfInDirectory(path, directoryPath) { + var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); + return ts.isRootedDiskPath(relativePath) || ts.startsWith(relativePath, "..") ? undefined : relativePath; + } function getRelativePath(path, directoryPath) { var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); return ts.moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath; } - function tryRemoveParentDirectoryName(path, parentDirectory) { - var index = path.indexOf(parentDirectory); - if (index === 0) { - return ts.endsWith(parentDirectory, ts.directorySeparator) - ? path.substring(parentDirectory.length) - : path.substring(parentDirectory.length + 1); - } - return undefined; - } } } function createCodeAction(description, diagnosticArgs, newText, span, fileName, kind, moduleSpecifier) { @@ -77947,156 +80686,150 @@ var ts; (function (ts) { var codefix; (function (codefix) { - codefix.registerCodeFix({ - errorCodes: [ - ts.Diagnostics._0_is_declared_but_never_used.code, - ts.Diagnostics.Property_0_is_declared_but_never_used.code - ], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var start = context.span.start; - var token = ts.getTokenAtPosition(sourceFile, start); - // this handles var ["computed"] = 12; - if (token.kind === 20 /* OpenBracketToken */) { - token = ts.getTokenAtPosition(sourceFile, start + 1); - } - switch (token.kind) { - case 70 /* Identifier */: - switch (token.parent.kind) { - case 223 /* VariableDeclaration */: - switch (token.parent.parent.parent.kind) { - case 211 /* ForStatement */: - var forStatement = token.parent.parent.parent; - var forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); - } - else { - return removeSingleItem(forInitializer.declarations, token); - } - case 213 /* ForOfStatement */: - var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 224 /* VariableDeclarationList */) { - var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); - } - break; - case 212 /* ForInStatement */: - // There is no valid fix in the case of: - // for .. in - return undefined; - case 256 /* CatchClause */: - var catchClause = token.parent.parent; - var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFix("", parameter.pos, parameter.end - parameter.pos); - default: - var variableStatement = token.parent.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); - } - else { - var declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); - } - } - case 143 /* TypeParameter */: - var typeParameters = token.parent.parent.typeParameters; - if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); - } - else { - return removeSingleItem(typeParameters, token); - } - case 144 /* Parameter */: - var functionDeclaration = token.parent.parent; - if (functionDeclaration.parameters.length === 1) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else { - return removeSingleItem(functionDeclaration.parameters, token); - } - // handle case where 'import a = A;' - case 234 /* ImportEqualsDeclaration */: - var importEquals = findImportDeclaration(token); - return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); - case 239 /* ImportSpecifier */: - var namedImports = token.parent.parent; - if (namedImports.elements.length === 1) { - // Only 1 import and it is unused. So the entire declaration should be removed. - var importSpec = findImportDeclaration(token); - return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); - } - else { - return removeSingleItem(namedImports.elements, token); - } - // handle case where "import d, * as ns from './file'" - // or "'import {a, b as ns} from './file'" - case 236 /* ImportClause */: - var importClause = token.parent; - if (!importClause.namedBindings) { - var importDecl = findImportDeclaration(importClause); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); - } - case 237 /* NamespaceImport */: - var namespaceImport = token.parent; - if (namespaceImport.name == token && !namespaceImport.parent.name) { - var importDecl = findImportDeclaration(namespaceImport); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - var start_4 = namespaceImport.parent.name.end; - return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); - } - } - break; - case 147 /* PropertyDeclaration */: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - case 237 /* NamespaceImport */: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - if (ts.isDeclarationName(token)) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); - } - else { - return undefined; - } - function findImportDeclaration(token) { - var importDecl = token; - while (importDecl.kind != 235 /* ImportDeclaration */ && importDecl.parent) { - importDecl = importDecl.parent; + /** + * Finds members of the resolved type that are missing in the class pointed to by class decl + * and generates source code for the missing members. + * @param possiblyMissingSymbols The collection of symbols to filter and then get insertions for. + * @returns Empty string iff there are no member insertions. + */ + function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { + var classMembers = classDeclaration.symbol.members; + var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !classMembers.has(symbol.getName()); }); + var insertion = ""; + for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { + var symbol = missingMembers_1[_i]; + insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + } + return insertion; + } + codefix.getMissingMembersInsertion = getMissingMembersInsertion; + /** + * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`. + */ + function getInsertionForMemberSymbol(symbol, enclosingDeclaration, checker, newlineChar) { + // const name = symbol.getName(); + var type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + var declarations = symbol.getDeclarations(); + if (!(declarations && declarations.length)) { + return ""; + } + var declaration = declarations[0]; + var name = declaration.name ? declaration.name.getText() : undefined; + var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); + switch (declaration.kind) { + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 147 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + var typeString = checker.typeToString(type, enclosingDeclaration, 0 /* None */); + return "" + visibility + name + ": " + typeString + ";" + newlineChar; + case 149 /* MethodSignature */: + case 150 /* MethodDeclaration */: + // The signature for the implementation appears as an entry in `signatures` iff + // there is only one signature. + // If there are overloads and an implementation signature, it appears as an + // extra declaration that isn't a signature for `type`. + // If there is more than one overload but no implementation signature + // (eg: an abstract method or interface declaration), there is a 1-1 + // correspondence of declarations and signatures. + var signatures = checker.getSignaturesOfType(type, 0 /* Call */); + if (!(signatures && signatures.length > 0)) { + return ""; } - return importDecl; - } - function createCodeFix(newText, start, length) { - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText: newText, span: { start: start, length: length } }] - }] - }]; - } - function removeSingleItem(elements, token) { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + if (declarations.length === 1) { + ts.Debug.assert(signatures.length === 1); + var sigString_1 = checker.signatureToString(signatures[0], enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); + return "" + visibility + name + sigString_1 + getMethodBodyStub(newlineChar); + } + var result = ""; + for (var i = 0; i < signatures.length; i++) { + var sigString_2 = checker.signatureToString(signatures[i], enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); + result += "" + visibility + name + sigString_2 + ";" + newlineChar; + } + // If there is a declaration with a body, it is the last declaration, + // and it isn't caught by `getSignaturesOfType`. + var bodySig = undefined; + if (declarations.length > signatures.length) { + bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); } else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + ts.Debug.assert(declarations.length === signatures.length); + bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); } + var sigString = checker.signatureToString(bodySig, enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); + result += "" + visibility + name + sigString + getMethodBodyStub(newlineChar); + return result; + default: + return ""; + } + } + function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { + var newSignatureDeclaration = ts.createNode(154 /* CallSignature */); + newSignatureDeclaration.parent = enclosingDeclaration; + newSignatureDeclaration.name = signatures[0].getDeclaration().name; + var maxNonRestArgs = -1; + var maxArgsIndex = 0; + var minArgumentCount = signatures[0].minArgumentCount; + var hasRestParameter = false; + for (var i = 0; i < signatures.length; i++) { + var sig = signatures[i]; + minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); + hasRestParameter = hasRestParameter || sig.hasRestParameter; + var nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); + if (nonRestLength > maxNonRestArgs) { + maxNonRestArgs = nonRestLength; + maxArgsIndex = i; } } - }); + var maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(function (symbol) { return symbol.getName(); }); + var optionalToken = ts.createToken(54 /* QuestionToken */); + newSignatureDeclaration.parameters = ts.createNodeArray(); + for (var i = 0; i < maxNonRestArgs; i++) { + var newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); + newSignatureDeclaration.parameters.push(newParameter); + } + if (hasRestParameter) { + var restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); + restParameter.dotDotDotToken = ts.createToken(23 /* DotDotDotToken */); + newSignatureDeclaration.parameters.push(restParameter); + } + return checker.getSignatureFromDeclaration(newSignatureDeclaration); + function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { + var newParameter = ts.createNode(145 /* Parameter */); + newParameter.symbol = new SymbolConstructor(1 /* FunctionScopedVariable */, maxArgsParameterSymbolNames[index] || "rest"); + newParameter.symbol.valueDeclaration = newParameter; + newParameter.symbol.declarations = [newParameter]; + newParameter.parent = enclosingSignatureDeclaration; + if (index >= minArgCount) { + newParameter.questionToken = optionalToken; + } + return newParameter; + } + } + function getMethodBodyStub(newLineChar) { + return " {" + newLineChar + "throw new Error('Method not implemented.');" + newLineChar + "}" + newLineChar; + } + function getVisibilityPrefix(flags) { + if (flags & 4 /* Public */) { + return "public "; + } + else if (flags & 16 /* Protected */) { + return "protected "; + } + return ""; + } + var SymbolConstructor = ts.objectAllocator.getSymbolConstructor(); })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); -/// -/// -/// +/// +/// +/// +/// +/// +/// +/// +/// +/// /// /// /// @@ -78122,14 +80855,14 @@ var ts; /// /// /// -/// +/// /// var ts; (function (ts) { /** The version of the language service API */ ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 141 /* FirstNode */ ? new NodeObject(kind, pos, end) : + var node = kind >= 142 /* FirstNode */ ? new NodeObject(kind, pos, end) : kind === 70 /* Identifier */ ? new IdentifierObject(70 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; @@ -78187,7 +80920,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(292 /* SyntaxList */, nodes.pos, nodes.end, this); + var list = createNode(296 /* SyntaxList */, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -78206,11 +80939,11 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 141 /* FirstNode */) { + if (this.kind >= 142 /* FirstNode */) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 278 /* FirstJSDocTagNode */ && this.kind <= 291 /* LastJSDocTagNode */; + var useJSDocScanner_1 = this.kind >= 282 /* FirstJSDocTagNode */ && this.kind <= 295 /* LastJSDocTagNode */; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -78267,8 +81000,10 @@ var ts; if (!children.length) { return undefined; } - var child = children[0]; - return child.kind < 141 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + var child = ts.find(children, function (kid) { return kid.kind < 266 /* FirstJSDocNode */ || kid.kind > 295 /* LastJSDocNode */; }); + return child.kind < 142 /* FirstNode */ ? + child : + child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -78276,7 +81011,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 141 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 142 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -78475,17 +81210,21 @@ var ts; return this.namedDeclarations; }; SourceFileObject.prototype.computeNamedDeclarations = function () { - var result = ts.createMap(); + var result = ts.createMultiMap(); ts.forEachChild(this, visit); return result; function addDeclaration(declaration) { var name = getDeclarationName(declaration); if (name) { - ts.multiMapAdd(result, name, declaration); + result.add(name, declaration); } } function getDeclarations(name) { - return result[name] || (result[name] = []); + var declarations = result.get(name); + if (!declarations) { + result.set(name, declarations = []); + } + return declarations; } function getDeclarationName(declaration) { if (declaration.name) { @@ -78493,9 +81232,9 @@ var ts; if (result_7 !== undefined) { return result_7; } - if (declaration.name.kind === 142 /* ComputedPropertyName */) { + if (declaration.name.kind === 143 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 177 /* PropertyAccessExpression */) { + if (expr.kind === 178 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -78515,10 +81254,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -78538,32 +81277,32 @@ var ts; } ts.forEachChild(node, visit); break; - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 243 /* ExportSpecifier */: - case 239 /* ImportSpecifier */: - case 234 /* ImportEqualsDeclaration */: - case 236 /* ImportClause */: - case 237 /* NamespaceImport */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 161 /* TypeLiteral */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 231 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 245 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 238 /* ImportClause */: + case 239 /* NamespaceImport */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 162 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 144 /* Parameter */: + case 145 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // fall through - case 223 /* VariableDeclaration */: - case 174 /* BindingElement */: { + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -78572,19 +81311,19 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 260 /* EnumMember */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 263 /* EnumMember */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: addDeclaration(node); break; - case 241 /* ExportDeclaration */: + case 243 /* 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 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -78596,7 +81335,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 239 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -79026,6 +81765,7 @@ var ts; ts.Debug.assert(hostFileInformation.scriptKind === oldSourceFile.scriptKind, "Registered script kind (" + oldSourceFile.scriptKind + ") should match new script kind (" + hostFileInformation.scriptKind + ") for file: " + path); return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } + // We didn't already have the file. Fall through and acquire it from the registry. } // Could not find this file in the old program, create a new SourceFile for it. return documentRegistry.acquireDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); @@ -79126,10 +81866,10 @@ var ts; // Try getting just type at this position and show switch (node.kind) { case 70 /* Identifier */: - case 177 /* PropertyAccessExpression */: - case 141 /* QualifiedName */: + case 178 /* PropertyAccessExpression */: + case 142 /* QualifiedName */: case 98 /* ThisKeyword */: - case 167 /* ThisType */: + case 168 /* ThisType */: case 96 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); @@ -79171,10 +81911,10 @@ var ts; function getOccurrencesAtPosition(fileName, position) { var results = getOccurrencesAtPositionCore(fileName, position); if (results) { - var sourceFile_2 = getCanonicalFileName(ts.normalizeSlashes(fileName)); + var sourceFile_1 = 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_2; }); + results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_1; }); } return results; } @@ -79209,21 +81949,21 @@ var ts; } } function findRenameLocations(fileName, position, findInStrings, findInComments) { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments, /*isForRename*/ true); return ts.FindAllReferences.convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/ false); return ts.FindAllReferences.convertReferences(referencedSymbols); } function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/ 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) { + function findReferencedSymbols(fileName, position, findInStrings, findInComments, isForRename) { synchronizeHostData(); - return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments); + return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments, isForRename); } /// NavigateTo function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { @@ -79272,15 +82012,15 @@ var ts; return; } switch (node.kind) { - case 177 /* PropertyAccessExpression */: - case 141 /* QualifiedName */: + case 178 /* PropertyAccessExpression */: + case 142 /* QualifiedName */: case 9 /* StringLiteral */: case 85 /* FalseKeyword */: case 100 /* TrueKeyword */: case 94 /* NullKeyword */: case 96 /* SuperKeyword */: case 98 /* ThisKeyword */: - case 167 /* ThisType */: + case 168 /* ThisType */: case 70 /* Identifier */: break; // Cant create the text span @@ -79297,7 +82037,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 === 230 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 232 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -79440,7 +82180,7 @@ var ts; var span = { start: start, length: end - start }; var newLineChar = ts.getNewLineOrDefaultFromHost(host); var allFixes = []; - ts.forEach(errorCodes, function (error) { + ts.forEach(ts.deduplicate(errorCodes), function (error) { cancellationToken.throwIfCancellationRequested(); var context = { errorCode: error, @@ -79529,7 +82269,7 @@ var ts; continue; } var descriptor = undefined; - for (var i = 0, n = descriptors.length; i < n; i++) { + for (var i = 0; i < descriptors.length; i++) { if (matchArray[i + firstDescriptorCaptureIndex]) { descriptor = descriptors[i]; } @@ -79674,7 +82414,7 @@ var ts; function walk(node) { switch (node.kind) { case 70 /* Identifier */: - nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; + setNameTable(node.text, node); break; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: @@ -79683,10 +82423,10 @@ 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 === 245 /* ExternalModuleReference */ || + node.parent.kind === 247 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { - nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; + setNameTable(node.text, node); } break; default: @@ -79699,11 +82439,72 @@ var ts; } } } + function setNameTable(text, node) { + nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); + } } + function isObjectLiteralElement(node) { + switch (node.kind) { + case 252 /* JsxAttribute */: + case 254 /* JsxSpreadAttribute */: + case 260 /* PropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + return true; + } + return false; + } + /** + * Returns the containing object literal property declaration given a possible name node, e.g. "a" in x = { "a": 1 } + */ + /* @internal */ + function getContainingObjectLiteralElement(node) { + switch (node.kind) { + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + if (node.parent.kind === 143 /* ComputedPropertyName */) { + return isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; + } + // intentionally fall through + case 70 /* Identifier */: + return isObjectLiteralElement(node.parent) && + (node.parent.parent.kind === 177 /* ObjectLiteralExpression */ || node.parent.parent.kind === 253 /* JsxAttributes */) && + node.parent.name === node ? node.parent : undefined; + } + return undefined; + } + ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; + /* @internal */ + function getPropertySymbolsFromContextualType(typeChecker, node) { + var objectLiteral = node.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name = ts.getTextOfPropertyName(node.name); + if (name && contextualType) { + var result_8 = []; + var symbol = contextualType.getProperty(name); + if (contextualType.flags & 65536 /* Union */) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_8.push(symbol); + } + }); + return result_8; + } + if (symbol) { + result_8.push(symbol); + return result_8; + } + } + return undefined; + } + ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 178 /* ElementAccessExpression */ && + node.parent.kind === 179 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -79719,10 +82520,7 @@ var ts; throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); } ts.getDefaultLibFilePath = getDefaultLibFilePath; - function initializeServices() { - ts.objectAllocator = getServicesObjectAllocator(); - } - initializeServices(); + ts.objectAllocator = getServicesObjectAllocator(); })(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. @@ -79787,113 +82585,113 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 223 /* VariableDeclaration */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 225 /* VariableDeclaration */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return spanInVariableDeclaration(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return spanInParameterDeclaration(node); - case 225 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 150 /* Constructor */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 151 /* Constructor */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 204 /* Block */: + case 206 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 231 /* ModuleBlock */: + case 233 /* ModuleBlock */: return spanInBlock(node); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return spanInBlock(node.block); - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 216 /* ReturnStatement */: + case 218 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 210 /* WhileStatement */: + case 212 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 209 /* DoStatement */: + case 211 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 222 /* DebuggerStatement */: + case 224 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 208 /* IfStatement */: + case 210 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: + case 217 /* BreakStatement */: + case 216 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 211 /* ForStatement */: + case 213 /* ForStatement */: return spanInForStatement(node); - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 213 /* ForOfStatement */: + case 215 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 253 /* CaseClause */: - case 254 /* DefaultClause */: + case 256 /* CaseClause */: + case 257 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 221 /* TryStatement */: + case 223 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 220 /* ThrowStatement */: + case 222 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 260 /* EnumMember */: - case 174 /* BindingElement */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 263 /* EnumMember */: + case 175 /* BindingElement */: // span on complete node return textSpan(node); - case 217 /* WithStatement */: + case 219 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 145 /* Decorator */: + case 146 /* Decorator */: return spanInNodeArray(node.parent.decorators); - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: return undefined; // Tokens: case 24 /* SemicolonToken */: @@ -79923,7 +82721,7 @@ var ts; case 73 /* CatchKeyword */: case 86 /* FinallyKeyword */: return spanInNextNode(node); - case 140 /* OfKeyword */: + case 141 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -79936,13 +82734,13 @@ var ts; // a or ...c or d: x from // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern if ((node.kind === 70 /* Identifier */ || - node.kind == 196 /* SpreadElement */ || - node.kind === 257 /* PropertyAssignment */ || - node.kind === 258 /* ShorthandPropertyAssignment */) && + node.kind == 197 /* SpreadElement */ || + node.kind === 260 /* PropertyAssignment */ || + node.kind === 261 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 192 /* BinaryExpression */) { + if (node.kind === 193 /* BinaryExpression */) { var binaryExpression = node; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -79965,22 +82763,22 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 209 /* DoStatement */: + case 211 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 145 /* Decorator */: + case 146 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForStatement */: + case 215 /* ForOfStatement */: return textSpan(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: if (node.parent.operatorToken.kind === 25 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -79989,13 +82787,13 @@ var ts; } } // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 257 /* PropertyAssignment */ && + if (node.parent.kind === 260 /* PropertyAssignment */ && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 182 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 183 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNextNode(node.parent.type); } // return type of function go to previous token @@ -80003,8 +82801,8 @@ var ts; return spanInPreviousNode(node); } // initializer of variable/parameter declaration go to previous node - if ((node.parent.kind === 223 /* VariableDeclaration */ || - node.parent.kind === 144 /* Parameter */)) { + if ((node.parent.kind === 225 /* VariableDeclaration */ || + node.parent.kind === 145 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -80012,7 +82810,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 192 /* BinaryExpression */) { + if (node.parent.kind === 193 /* BinaryExpression */) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -80038,7 +82836,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 212 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 214 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern, set breakpoint in binding pattern @@ -80049,7 +82847,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 213 /* ForOfStatement */) { + variableDeclaration.parent.parent.kind === 215 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -80089,7 +82887,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 226 /* ClassDeclaration */ && functionDeclaration.kind !== 150 /* Constructor */); + (functionDeclaration.parent.kind === 228 /* ClassDeclaration */ && functionDeclaration.kind !== 151 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -80112,25 +82910,25 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 210 /* WhileStatement */: - case 208 /* IfStatement */: - case 212 /* ForInStatement */: + case 212 /* WhileStatement */: + case 210 /* IfStatement */: + case 214 /* ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForStatement */: + case 215 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 224 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 226 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -80155,23 +82953,23 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 198 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 199 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 174 /* BindingElement */) { + if (bindingPattern.parent.kind === 175 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 173 /* ArrayBindingPattern */ && node.kind !== 172 /* ObjectBindingPattern */); - var elements = node.kind === 175 /* ArrayLiteralExpression */ ? + ts.Debug.assert(node.kind !== 174 /* ArrayBindingPattern */ && node.kind !== 173 /* ObjectBindingPattern */); + var elements = node.kind === 176 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 198 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 199 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -80179,18 +82977,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 192 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 193 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 232 /* CaseBlock */: + case 234 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -80198,24 +82996,24 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 231 /* ModuleBlock */: + case 233 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 229 /* EnumDeclaration */: - case 226 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 228 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 204 /* Block */: + case 206 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through - case 256 /* CatchClause */: + case 259 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 232 /* CaseBlock */: + case 234 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -80223,7 +83021,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 172 /* ObjectBindingPattern */: + case 173 /* ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -80239,7 +83037,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 173 /* ArrayBindingPattern */: + case 174 /* ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -80254,12 +83052,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 209 /* DoStatement */ || - node.parent.kind === 179 /* CallExpression */ || - node.parent.kind === 180 /* NewExpression */) { + if (node.parent.kind === 211 /* DoStatement */ || + node.parent.kind === 180 /* CallExpression */ || + node.parent.kind === 181 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 183 /* ParenthesizedExpression */) { + if (node.parent.kind === 184 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -80268,21 +83066,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 150 /* Constructor */: - case 210 /* WhileStatement */: - case 209 /* DoStatement */: - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 183 /* ParenthesizedExpression */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 151 /* Constructor */: + case 212 /* WhileStatement */: + case 211 /* DoStatement */: + case 213 /* ForStatement */: + case 215 /* ForOfStatement */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 184 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -80292,20 +83090,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 257 /* PropertyAssignment */ || - node.parent.kind === 144 /* Parameter */) { + node.parent.kind === 260 /* PropertyAssignment */ || + node.parent.kind === 145 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 182 /* TypeAssertionExpression */) { + if (node.parent.kind === 183 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 209 /* DoStatement */) { + if (node.parent.kind === 211 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -80313,7 +83111,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 213 /* ForOfStatement */) { + if (node.parent.kind === 215 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -80444,7 +83242,10 @@ var ts; if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } - return JSON.parse(settingsJson); + var compilerOptions = JSON.parse(settingsJson); + // permit language service to handle all files (filtering should be performed on the host side) + compilerOptions.allowNonTsExtensions = true; + return compilerOptions; }; LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { var encoded = this.shimHost.getScriptFileNames(); @@ -80952,12 +83753,6 @@ var ts; var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (resolvedFileName && !compilerOptions.allowJs && ts.fileExtensionIs(resolvedFileName, ".js")) { - return { - resolvedFileName: undefined, - failedLookupLocations: [] - }; - } return { resolvedFileName: resolvedFileName, failedLookupLocations: result.failedLookupLocations @@ -81102,7 +83897,7 @@ var ts; this._shims.push(shim); }; TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0, n = this._shims.length; i < n; i++) { + for (var i = 0; i < this._shims.length; i++) { if (this._shims[i] === shim) { delete this._shims[i]; return; @@ -81131,4 +83926,4 @@ var TypeScript; // 'toolsVersion' gets consumed by the managed side, so it's not unused. // TODO: it should be moved into a namespace though. /* @internal */ -var toolsVersion = "2.2"; +var toolsVersion = "2.3"; diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index e11c200ef44..1be69fb2455 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -14,11 +14,36 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { + /** + * Type of objects whose values are all of the same type. + * The `in` and `for-in` operators can *not* be safely used, + * since `Object.prototype` may be modified by outside code. + */ interface MapLike { [index: string]: T; } - interface Map extends MapLike { - __mapBrand: any; + /** ES6 Map interface. */ + interface Map { + get(key: string): T; + has(key: string): boolean; + set(key: string, value: T): this; + delete(key: string): boolean; + clear(): void; + forEach(action: (value: T, key: string) => void): void; + readonly size: number; + keys(): Iterator; + values(): Iterator; + entries(): Iterator<[string, T]>; + } + /** ES6 Iterator type. */ + interface Iterator { + next(): { + value: T; + done: false; + } | { + value: never; + done: true; + }; } type Path = string & { __pathBrand: any; @@ -170,172 +195,175 @@ declare namespace ts { ReadonlyKeyword = 130, RequireKeyword = 131, NumberKeyword = 132, - SetKeyword = 133, - StringKeyword = 134, - SymbolKeyword = 135, - TypeKeyword = 136, - UndefinedKeyword = 137, - FromKeyword = 138, - GlobalKeyword = 139, - OfKeyword = 140, - QualifiedName = 141, - ComputedPropertyName = 142, - TypeParameter = 143, - Parameter = 144, - Decorator = 145, - PropertySignature = 146, - PropertyDeclaration = 147, - MethodSignature = 148, - MethodDeclaration = 149, - Constructor = 150, - GetAccessor = 151, - SetAccessor = 152, - CallSignature = 153, - ConstructSignature = 154, - IndexSignature = 155, - TypePredicate = 156, - TypeReference = 157, - FunctionType = 158, - ConstructorType = 159, - TypeQuery = 160, - TypeLiteral = 161, - ArrayType = 162, - TupleType = 163, - UnionType = 164, - IntersectionType = 165, - ParenthesizedType = 166, - ThisType = 167, - TypeOperator = 168, - IndexedAccessType = 169, - MappedType = 170, - LiteralType = 171, - ObjectBindingPattern = 172, - ArrayBindingPattern = 173, - BindingElement = 174, - ArrayLiteralExpression = 175, - ObjectLiteralExpression = 176, - PropertyAccessExpression = 177, - ElementAccessExpression = 178, - CallExpression = 179, - NewExpression = 180, - TaggedTemplateExpression = 181, - TypeAssertionExpression = 182, - ParenthesizedExpression = 183, - FunctionExpression = 184, - ArrowFunction = 185, - DeleteExpression = 186, - TypeOfExpression = 187, - VoidExpression = 188, - AwaitExpression = 189, - PrefixUnaryExpression = 190, - PostfixUnaryExpression = 191, - BinaryExpression = 192, - ConditionalExpression = 193, - TemplateExpression = 194, - YieldExpression = 195, - SpreadElement = 196, - ClassExpression = 197, - OmittedExpression = 198, - ExpressionWithTypeArguments = 199, - AsExpression = 200, - NonNullExpression = 201, - TemplateSpan = 202, - SemicolonClassElement = 203, - Block = 204, - VariableStatement = 205, - EmptyStatement = 206, - ExpressionStatement = 207, - IfStatement = 208, - DoStatement = 209, - WhileStatement = 210, - ForStatement = 211, - ForInStatement = 212, - ForOfStatement = 213, - ContinueStatement = 214, - BreakStatement = 215, - ReturnStatement = 216, - WithStatement = 217, - SwitchStatement = 218, - LabeledStatement = 219, - ThrowStatement = 220, - TryStatement = 221, - DebuggerStatement = 222, - VariableDeclaration = 223, - VariableDeclarationList = 224, - FunctionDeclaration = 225, - ClassDeclaration = 226, - InterfaceDeclaration = 227, - TypeAliasDeclaration = 228, - EnumDeclaration = 229, - ModuleDeclaration = 230, - ModuleBlock = 231, - CaseBlock = 232, - NamespaceExportDeclaration = 233, - ImportEqualsDeclaration = 234, - ImportDeclaration = 235, - ImportClause = 236, - NamespaceImport = 237, - NamedImports = 238, - ImportSpecifier = 239, - ExportAssignment = 240, - ExportDeclaration = 241, - NamedExports = 242, - ExportSpecifier = 243, - MissingDeclaration = 244, - ExternalModuleReference = 245, - JsxElement = 246, - JsxSelfClosingElement = 247, - JsxOpeningElement = 248, - JsxClosingElement = 249, - JsxAttribute = 250, - JsxSpreadAttribute = 251, - JsxExpression = 252, - CaseClause = 253, - DefaultClause = 254, - HeritageClause = 255, - CatchClause = 256, - PropertyAssignment = 257, - ShorthandPropertyAssignment = 258, - SpreadAssignment = 259, - EnumMember = 260, - SourceFile = 261, - JSDocTypeExpression = 262, - JSDocAllType = 263, - JSDocUnknownType = 264, - JSDocArrayType = 265, - JSDocUnionType = 266, - JSDocTupleType = 267, - JSDocNullableType = 268, - JSDocNonNullableType = 269, - JSDocRecordType = 270, - JSDocRecordMember = 271, - JSDocTypeReference = 272, - JSDocOptionalType = 273, - JSDocFunctionType = 274, - JSDocVariadicType = 275, - JSDocConstructorType = 276, - JSDocThisType = 277, - JSDocComment = 278, - JSDocTag = 279, - JSDocAugmentsTag = 280, - JSDocParameterTag = 281, - JSDocReturnTag = 282, - JSDocTypeTag = 283, - JSDocTemplateTag = 284, - JSDocTypedefTag = 285, - JSDocPropertyTag = 286, - JSDocTypeLiteral = 287, - JSDocLiteralType = 288, - JSDocNullKeyword = 289, - JSDocUndefinedKeyword = 290, - JSDocNeverKeyword = 291, - SyntaxList = 292, - NotEmittedStatement = 293, - PartiallyEmittedExpression = 294, - MergeDeclarationMarker = 295, - EndOfDeclarationMarker = 296, - RawExpression = 297, - Count = 298, + ObjectKeyword = 133, + SetKeyword = 134, + StringKeyword = 135, + SymbolKeyword = 136, + TypeKeyword = 137, + UndefinedKeyword = 138, + FromKeyword = 139, + GlobalKeyword = 140, + OfKeyword = 141, + QualifiedName = 142, + ComputedPropertyName = 143, + TypeParameter = 144, + Parameter = 145, + Decorator = 146, + PropertySignature = 147, + PropertyDeclaration = 148, + MethodSignature = 149, + MethodDeclaration = 150, + Constructor = 151, + GetAccessor = 152, + SetAccessor = 153, + CallSignature = 154, + ConstructSignature = 155, + IndexSignature = 156, + TypePredicate = 157, + TypeReference = 158, + FunctionType = 159, + ConstructorType = 160, + TypeQuery = 161, + TypeLiteral = 162, + ArrayType = 163, + TupleType = 164, + UnionType = 165, + IntersectionType = 166, + ParenthesizedType = 167, + ThisType = 168, + TypeOperator = 169, + IndexedAccessType = 170, + MappedType = 171, + LiteralType = 172, + ObjectBindingPattern = 173, + ArrayBindingPattern = 174, + BindingElement = 175, + ArrayLiteralExpression = 176, + ObjectLiteralExpression = 177, + PropertyAccessExpression = 178, + ElementAccessExpression = 179, + CallExpression = 180, + NewExpression = 181, + TaggedTemplateExpression = 182, + TypeAssertionExpression = 183, + ParenthesizedExpression = 184, + FunctionExpression = 185, + ArrowFunction = 186, + DeleteExpression = 187, + TypeOfExpression = 188, + VoidExpression = 189, + AwaitExpression = 190, + PrefixUnaryExpression = 191, + PostfixUnaryExpression = 192, + BinaryExpression = 193, + ConditionalExpression = 194, + TemplateExpression = 195, + YieldExpression = 196, + SpreadElement = 197, + ClassExpression = 198, + OmittedExpression = 199, + ExpressionWithTypeArguments = 200, + AsExpression = 201, + NonNullExpression = 202, + MetaProperty = 203, + TemplateSpan = 204, + SemicolonClassElement = 205, + Block = 206, + VariableStatement = 207, + EmptyStatement = 208, + ExpressionStatement = 209, + IfStatement = 210, + DoStatement = 211, + WhileStatement = 212, + ForStatement = 213, + ForInStatement = 214, + ForOfStatement = 215, + ContinueStatement = 216, + BreakStatement = 217, + ReturnStatement = 218, + WithStatement = 219, + SwitchStatement = 220, + LabeledStatement = 221, + ThrowStatement = 222, + TryStatement = 223, + DebuggerStatement = 224, + VariableDeclaration = 225, + VariableDeclarationList = 226, + FunctionDeclaration = 227, + ClassDeclaration = 228, + InterfaceDeclaration = 229, + TypeAliasDeclaration = 230, + EnumDeclaration = 231, + ModuleDeclaration = 232, + ModuleBlock = 233, + CaseBlock = 234, + NamespaceExportDeclaration = 235, + ImportEqualsDeclaration = 236, + ImportDeclaration = 237, + ImportClause = 238, + NamespaceImport = 239, + NamedImports = 240, + ImportSpecifier = 241, + ExportAssignment = 242, + ExportDeclaration = 243, + NamedExports = 244, + ExportSpecifier = 245, + MissingDeclaration = 246, + ExternalModuleReference = 247, + JsxElement = 248, + JsxSelfClosingElement = 249, + JsxOpeningElement = 250, + JsxClosingElement = 251, + JsxAttribute = 252, + JsxAttributes = 253, + JsxSpreadAttribute = 254, + JsxExpression = 255, + CaseClause = 256, + DefaultClause = 257, + HeritageClause = 258, + CatchClause = 259, + PropertyAssignment = 260, + ShorthandPropertyAssignment = 261, + SpreadAssignment = 262, + EnumMember = 263, + SourceFile = 264, + Bundle = 265, + JSDocTypeExpression = 266, + JSDocAllType = 267, + JSDocUnknownType = 268, + JSDocArrayType = 269, + JSDocUnionType = 270, + JSDocTupleType = 271, + JSDocNullableType = 272, + JSDocNonNullableType = 273, + JSDocRecordType = 274, + JSDocRecordMember = 275, + JSDocTypeReference = 276, + JSDocOptionalType = 277, + JSDocFunctionType = 278, + JSDocVariadicType = 279, + JSDocConstructorType = 280, + JSDocThisType = 281, + JSDocComment = 282, + JSDocTag = 283, + JSDocAugmentsTag = 284, + JSDocParameterTag = 285, + JSDocReturnTag = 286, + JSDocTypeTag = 287, + JSDocTemplateTag = 288, + JSDocTypedefTag = 289, + JSDocPropertyTag = 290, + JSDocTypeLiteral = 291, + JSDocLiteralType = 292, + JSDocNullKeyword = 293, + JSDocUndefinedKeyword = 294, + JSDocNeverKeyword = 295, + SyntaxList = 296, + NotEmittedStatement = 297, + PartiallyEmittedExpression = 298, + MergeDeclarationMarker = 299, + EndOfDeclarationMarker = 300, + Count = 301, FirstAssignment = 57, LastAssignment = 69, FirstCompoundAssignment = 58, @@ -343,15 +371,15 @@ declare namespace ts { FirstReservedWord = 71, LastReservedWord = 106, FirstKeyword = 71, - LastKeyword = 140, + LastKeyword = 141, FirstFutureReservedWord = 107, LastFutureReservedWord = 115, - FirstTypeNode = 156, - LastTypeNode = 171, + FirstTypeNode = 157, + LastTypeNode = 172, FirstPunctuation = 16, LastPunctuation = 69, FirstToken = 0, - LastToken = 140, + LastToken = 141, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -360,11 +388,11 @@ declare namespace ts { LastTemplateToken = 15, FirstBinaryOperator = 26, LastBinaryOperator = 69, - FirstNode = 141, - FirstJSDocNode = 262, - LastJSDocNode = 288, - FirstJSDocTagNode = 278, - LastJSDocTagNode = 291, + FirstNode = 142, + FirstJSDocNode = 266, + LastJSDocNode = 295, + FirstJSDocTagNode = 282, + LastJSDocTagNode = 295, } enum NodeFlags { None = 0, @@ -481,6 +509,7 @@ declare namespace ts { kind: SyntaxKind.TypeParameter; name: Identifier; constraint?: TypeNode; + default?: TypeNode; expression?: Expression; } interface SignatureDeclaration extends Declaration { @@ -632,7 +661,7 @@ declare namespace ts { _typeNodeBrand: any; } interface KeywordTypeNode extends TypeNode { - kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; + kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; } interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; @@ -717,6 +746,10 @@ declare namespace ts { interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; } + interface PartiallyEmittedExpression extends LeftHandSideExpression { + kind: SyntaxKind.PartiallyEmittedExpression; + expression: Expression; + } interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } @@ -953,7 +986,7 @@ declare namespace ts { tag: LeftHandSideExpression; template: TemplateLiteral; } - type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; + type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; interface AsExpression extends Expression { kind: SyntaxKind.AsExpression; expression: Expression; @@ -969,31 +1002,38 @@ declare namespace ts { kind: SyntaxKind.NonNullExpression; expression: Expression; } + interface MetaProperty extends PrimaryExpression { + kind: SyntaxKind.MetaProperty; + keywordToken: SyntaxKind; + name: Identifier; + } interface JsxElement extends PrimaryExpression { kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; children: NodeArray; closingElement: JsxClosingElement; } + type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; + interface JsxAttributes extends ObjectLiteralExpressionBase { + } interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; tagName: JsxTagNameExpression; - attributes: NodeArray; + attributes: JsxAttributes; } interface JsxSelfClosingElement extends PrimaryExpression { kind: SyntaxKind.JsxSelfClosingElement; tagName: JsxTagNameExpression; - attributes: NodeArray; + attributes: JsxAttributes; } - type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; - type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - interface JsxAttribute extends Node { + interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; name: Identifier; initializer?: StringLiteral | JsxExpression; } - interface JsxSpreadAttribute extends Node { + interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; expression: Expression; } @@ -1003,6 +1043,7 @@ declare namespace ts { } interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; + dotDotDotToken?: Token; expression?: Expression; } interface JsxText extends Node { @@ -1012,6 +1053,9 @@ declare namespace ts { interface Statement extends Node { _statementBrand: any; } + interface NotEmittedStatement extends Statement { + kind: SyntaxKind.NotEmittedStatement; + } interface EmptyStatement extends Statement { kind: SyntaxKind.EmptyStatement; } @@ -1022,7 +1066,7 @@ declare namespace ts { kind: SyntaxKind.MissingDeclaration; name?: Identifier; } - type BlockLike = SourceFile | Block | ModuleBlock | CaseClause; + type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; @@ -1178,20 +1222,22 @@ declare namespace ts { name: Identifier; members: NodeArray; } - type ModuleBody = ModuleBlock | ModuleDeclaration; type ModuleName = Identifier | StringLiteral; + type ModuleBody = NamespaceBody | JSDocNamespaceBody; interface ModuleDeclaration extends DeclarationStatement { kind: SyntaxKind.ModuleDeclaration; name: Identifier | StringLiteral; - body?: ModuleBlock | NamespaceDeclaration | JSDocNamespaceDeclaration | Identifier; + body?: ModuleBody | JSDocNamespaceDeclaration | Identifier; } + type NamespaceBody = ModuleBlock | NamespaceDeclaration; interface NamespaceDeclaration extends ModuleDeclaration { name: Identifier; - body: ModuleBlock | NamespaceDeclaration; + body: NamespaceBody; } + type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; interface JSDocNamespaceDeclaration extends ModuleDeclaration { name: Identifier; - body: JSDocNamespaceDeclaration | Identifier; + body: JSDocNamespaceBody; } interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; @@ -1406,9 +1452,21 @@ declare namespace ts { ArrayMutation = 256, Referenced = 512, Shared = 1024, + PreFinally = 2048, + AfterFinally = 4096, Label = 12, Condition = 96, } + interface FlowLock { + locked?: boolean; + } + interface AfterFinallyFlow extends FlowNode, FlowLock { + antecedent: FlowNode; + } + interface PreFinallyFlow extends FlowNode { + antecedent: FlowNode; + lock: FlowLock; + } interface FlowNode { flags: FlowFlags; id?: number; @@ -1470,6 +1528,10 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; } + interface Bundle extends Node { + kind: SyntaxKind.Bundle; + sourceFiles: SourceFile[]; + } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; getSourceFile(fileName: string): SourceFile; @@ -1569,9 +1631,10 @@ declare namespace ts { getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol; + getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; - getBaseTypes(type: InterfaceType): ObjectType[]; + getBaseTypes(type: InterfaceType): BaseType[]; getReturnTypeOfSignature(signature: Signature): Type; getNonNullableType(type: Type): Type; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; @@ -1581,6 +1644,8 @@ declare namespace ts { getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol; getTypeAtLocation(node: Node): Type; + getTypeFromTypeNode(node: TypeNode): Type; + signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string; typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; getSymbolDisplayBuilder(): SymbolDisplayBuilder; @@ -1598,16 +1663,18 @@ declare namespace ts { isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; - getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; + getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; + getApparentType(type: Type): Type; } 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, kind?: SignatureKind): void; + buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1631,6 +1698,7 @@ declare namespace ts { clear(): void; trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; reportInaccessibleThisError(): void; + reportIllegalExtends(): void; } enum TypeFormatFlags { None = 0, @@ -1645,6 +1713,8 @@ declare namespace ts { InFirstTypeArgument = 256, InTypeAlias = 512, UseTypeAliasValue = 1024, + SuppressAnyReturnType = 2048, + AddUndefined = 4096, } enum SymbolFormatFlags { None = 0, @@ -1694,13 +1764,10 @@ declare namespace ts { ExportType = 2097152, ExportNamespace = 4194304, Alias = 8388608, - Instantiated = 16777216, - Merged = 33554432, - Transient = 67108864, - Prototype = 134217728, - SyntheticProperty = 268435456, - Optional = 536870912, - ExportStar = 1073741824, + Prototype = 16777216, + ExportStar = 33554432, + Optional = 67108864, + Transient = 134217728, Enum = 384, Variable = 3, Value = 107455, @@ -1766,6 +1833,7 @@ declare namespace ts { Intersection = 131072, Index = 262144, IndexedAccess = 524288, + NonPrimitive = 16777216, Literal = 480, StringOrNumberLiteral = 96, PossiblyFalsy = 7406, @@ -1775,10 +1843,10 @@ declare namespace ts { EnumLike = 272, UnionOrIntersection = 196608, StructuredType = 229376, - StructuredOrTypeParameter = 507904, + StructuredOrTypeVariable = 1032192, TypeVariable = 540672, - Narrowable = 1033215, - NotUnionOrUnit = 33281, + Narrowable = 17810431, + NotUnionOrUnit = 16810497, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { @@ -1794,7 +1862,7 @@ declare namespace ts { regularType?: LiteralType; } interface EnumType extends Type { - memberTypes: Map; + memberTypes: EnumLiteralType[]; } interface EnumLiteralType extends LiteralType { baseType: EnumType & UnionType; @@ -1810,17 +1878,20 @@ declare namespace ts { ObjectLiteral = 128, EvolvingArray = 256, ObjectLiteralPatternWithComputedProperties = 512, + NonPrimitive = 1024, ClassOrInterface = 3, } interface ObjectType extends Type { objectFlags: ObjectFlags; } + /** Class and interface types (TypeFlags.Class and TypeFlags.Interface). */ interface InterfaceType extends ObjectType { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; thisType: TypeParameter; } + type BaseType = ObjectType | IntersectionType; interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; @@ -1828,6 +1899,16 @@ declare namespace ts { declaredStringIndexInfo: IndexInfo; declaredNumberIndexInfo: IndexInfo; } + /** + * Type references (TypeFlags.Reference). When a class or interface has type parameters or + * a "this" type, references to the class or interface are made using type references. The + * typeArguments property specifies the types to substitute for the type parameters of the + * class or interface and optionally includes an extra element that specifies the type to + * substitute for "this" in the resulting instantiation. When no extra argument is present, + * the type reference itself is substituted for "this". The typeArguments property is undefined + * if the class or interface has no type parameters and the reference isn't specifying an + * explicit "this" argument. + */ interface TypeReference extends ObjectType { target: GenericType; typeArguments: Type[]; @@ -1850,6 +1931,7 @@ declare namespace ts { } interface TypeParameter extends TypeVariable { constraint: Type; + default?: Type; } interface IndexedAccessType extends TypeVariable { objectType: Type; @@ -1877,9 +1959,8 @@ declare namespace ts { isReadonly: boolean; declaration?: SignatureDeclaration; } - interface FileExtensionInfo { + interface JsFileExtensionInfo { extension: string; - scriptKind: ScriptKind; isMixedContent: boolean; } interface DiagnosticMessage { @@ -1917,7 +1998,10 @@ declare namespace ts { Classic = 1, NodeJs = 2, } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; + interface PluginImport { + name: string; + } + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[]; interface CompilerOptions { allowJs?: boolean; allowSyntheticDefaultImports?: boolean; @@ -2011,6 +2095,7 @@ declare namespace ts { None = 0, Preserve = 1, React = 2, + ReactNative = 3, } enum NewLineKind { CarriageReturnLineFeed = 0, @@ -2026,6 +2111,7 @@ declare namespace ts { JSX = 2, TS = 3, TSX = 4, + External = 5, } enum ScriptTarget { ES3 = 0, @@ -2106,7 +2192,6 @@ declare namespace ts { } interface ResolvedModuleWithFailedLookupLocations { resolvedModule: ResolvedModuleFull | undefined; - failedLookupLocations: string[]; } interface ResolvedTypeReferenceDirective { primary: boolean; @@ -2135,6 +2220,120 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; getEnvironmentVariable?(name: string): string; } + enum EmitFlags { + SingleLine = 1, + AdviseOnEmitNode = 2, + NoSubstitution = 4, + CapturesThis = 8, + NoLeadingSourceMap = 16, + NoTrailingSourceMap = 32, + NoSourceMap = 48, + NoNestedSourceMaps = 64, + NoTokenLeadingSourceMaps = 128, + NoTokenTrailingSourceMaps = 256, + NoTokenSourceMaps = 384, + NoLeadingComments = 512, + NoTrailingComments = 1024, + NoComments = 1536, + NoNestedComments = 2048, + HelperName = 4096, + ExportName = 8192, + LocalName = 16384, + Indented = 32768, + NoIndentation = 65536, + AsyncFunctionBody = 131072, + ReuseTempVariableScope = 262144, + CustomPrologue = 524288, + NoHoisting = 1048576, + HasEndOfDeclarationMarker = 2097152, + } + interface EmitHelper { + readonly name: string; + readonly scoped: boolean; + readonly text: string; + readonly priority?: number; + } + enum EmitHint { + SourceFile = 0, + Expression = 1, + IdentifierName = 2, + Unspecified = 3, + } + interface Printer { + /** + * Print a node and its subtree as-is, without any emit transformations. + * @param hint A value indicating the purpose of a node. This is primarily used to + * distinguish between an `Identifier` used in an expression position, versus an + * `Identifier` used as an `IdentifierName` as part of a declaration. For most nodes you + * should just pass `Unspecified`. + * @param node The node to print. The node and its subtree are printed as-is, without any + * emit transformations. + * @param sourceFile A source file that provides context for the node. The source text of + * the file is used to emit the original source content for literals and identifiers, while + * the identifiers of the source file are used when generating unique names to avoid + * collisions. + */ + printNode(hint: EmitHint, node: Node, sourceFile: SourceFile): string; + /** + * Prints a source file as-is, without any emit transformations. + */ + printFile(sourceFile: SourceFile): string; + /** + * Prints a bundle of source files as-is, without any emit transformations. + */ + printBundle(bundle: Bundle): string; + } + interface PrintHandlers { + /** + * A hook used by the Printer when generating unique names to avoid collisions with + * globally defined names that exist outside of the current source file. + */ + hasGlobalName?(name: string): boolean; + /** + * A hook used by the Printer to provide notifications prior to emitting a node. A + * compatible implementation **must** invoke `emitCallback` with the provided `hint` and + * `node` values. + * @param hint A hint indicating the intended purpose of the node. + * @param node The node to emit. + * @param emitCallback A callback that, when invoked, will emit the node. + * @example + * ```ts + * var printer = createPrinter(printerOptions, { + * onEmitNode(hint, node, emitCallback) { + * // set up or track state prior to emitting the node... + * emitCallback(hint, node); + * // restore state after emitting the node... + * } + * }); + * ``` + */ + onEmitNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + /** + * A hook used by the Printer to perform just-in-time substitution of a node. This is + * primarily used by node transformations that need to substitute one node for another, + * such as replacing `myExportedVar` with `exports.myExportedVar`. A compatible + * implementation **must** invoke `emitCallback` eith the provided `hint` and either + * the provided `node`, or its substitute. + * @param hint A hint indicating the intended purpose of the node. + * @param node The node to emit. + * @param emitCallback A callback that, when invoked, will emit the node. + * @example + * ```ts + * var printer = createPrinter(printerOptions, { + * onSubstituteNode(hint, node, emitCallback) { + * // perform substitution if necessary... + * emitCallback(hint, node); + * } + * }); + * ``` + */ + onSubstituteNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + } + interface PrinterOptions { + target?: ScriptTarget; + removeComments?: boolean; + newLine?: NewLineKind; + } interface TextSpan { start: number; length: number; @@ -2149,8 +2348,10 @@ declare namespace ts { } declare namespace ts { /** The version of the TypeScript compiler release */ - const version = "2.2.0"; + const version = "2.3.0"; } +declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; +declare function clearTimeout(handle: any): void; declare namespace ts { type FileWatcherCallback = (fileName: string, removed?: boolean) => void; type DirectoryWatcherCallback = (fileName: string) => void; @@ -2245,8 +2446,8 @@ declare namespace ts { function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; - function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; - function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined; + function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined; /** Optionally, get the shebang */ function getShebang(text: string): string; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; @@ -2295,6 +2496,356 @@ declare namespace ts { fileExists(fileName: string): boolean; readFile(fileName: string): string; }, errors?: Diagnostic[]): void; + function getOriginalNode(node: Node): Node; + function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; + /** + * Gets a value indicating whether a node originated in the parse tree. + * + * @param node The node to test. + */ + function isParseTreeNode(node: Node): boolean; + /** + * Gets the original parse tree node for a node. + * + * @param node The original node. + * @returns The original parse tree node if found; otherwise, undefined. + */ + function getParseTreeNode(node: Node): Node; + /** + * Gets the original parse tree node for a node. + * + * @param node The original node. + * @param nodeTest A callback used to ensure the correct type of parse tree node is returned. + * @returns The original parse tree node if found; otherwise, undefined. + */ + function getParseTreeNode(node: Node, nodeTest?: (node: Node) => node is T): T; + /** + * Remove extra underscore from escaped identifier text content. + * + * @param identifier The escaped identifier text. + * @returns The unescaped identifier text. + */ + function unescapeIdentifier(identifier: string): string; +} +declare namespace ts { + /** + * Make `elements` into a `NodeArray`. If `elements` is `undefined`, returns an empty `NodeArray`. + */ + function createNodeArray(elements?: T[], hasTrailingComma?: boolean): NodeArray; + function createLiteral(value: string): StringLiteral; + function createLiteral(value: number): NumericLiteral; + function createLiteral(value: boolean): BooleanLiteral; + /** Create a string literal whose source text is read from a source node during emit. */ + function createLiteral(sourceNode: StringLiteral | NumericLiteral | Identifier): StringLiteral; + function createLiteral(value: string | number | boolean): PrimaryExpression; + function createNumericLiteral(value: string): NumericLiteral; + function createIdentifier(text: string): Identifier; + /** Create a unique temporary variable. */ + function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier; + /** Create a unique temporary variable for use in a loop. */ + function createLoopVariable(): Identifier; + /** Create a unique name based on the supplied text. */ + function createUniqueName(text: string): Identifier; + /** Create a unique name generated for a node. */ + function getGeneratedNameForNode(node: Node): Identifier; + function createToken(token: TKind): Token; + function createSuper(): PrimaryExpression; + function createThis(): PrimaryExpression; + function createNull(): PrimaryExpression; + function createTrue(): BooleanLiteral; + function createFalse(): BooleanLiteral; + function createQualifiedName(left: EntityName, right: string | Identifier): QualifiedName; + function updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName; + function createComputedPropertyName(expression: Expression): ComputedPropertyName; + function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; + function createParameter(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + function updateParameter(node: ParameterDeclaration, decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: BindingName, type: TypeNode, initializer: Expression): ParameterDeclaration; + function createDecorator(expression: Expression): Decorator; + function updateDecorator(node: Decorator, expression: Expression): Decorator; + function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: QuestionToken, type: TypeNode, initializer: Expression): PropertyDeclaration; + function updateProperty(node: PropertyDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, type: TypeNode, initializer: Expression): PropertyDeclaration; + function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; + function updateMethod(node: MethodDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; + function createConstructor(decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; + function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; + function createGetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; + function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; + function createSetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; + function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; + function createObjectBindingPattern(elements: BindingElement[]): ObjectBindingPattern; + function updateObjectBindingPattern(node: ObjectBindingPattern, elements: BindingElement[]): ObjectBindingPattern; + function createArrayBindingPattern(elements: ArrayBindingElement[]): ArrayBindingPattern; + function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ArrayBindingElement[]): ArrayBindingPattern; + function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: DotDotDotToken, name: string | BindingName, initializer?: Expression): BindingElement; + function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken, propertyName: PropertyName, name: BindingName, initializer: Expression): BindingElement; + function createArrayLiteral(elements?: Expression[], multiLine?: boolean): ArrayLiteralExpression; + function updateArrayLiteral(node: ArrayLiteralExpression, elements: Expression[]): ArrayLiteralExpression; + function createObjectLiteral(properties?: ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; + function updateObjectLiteral(node: ObjectLiteralExpression, properties: ObjectLiteralElementLike[]): ObjectLiteralExpression; + function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression; + function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; + function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; + function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; + function createCall(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; + function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; + function createNew(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; + function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; + function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; + function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; + function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; + function createParen(expression: Expression): ParenthesizedExpression; + function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; + function createFunctionExpression(modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; + function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; + function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: ConciseBody): ArrowFunction; + function createDelete(expression: Expression): DeleteExpression; + function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; + function createTypeOf(expression: Expression): TypeOfExpression; + function updateTypeOf(node: TypeOfExpression, expression: Expression): TypeOfExpression; + function createVoid(expression: Expression): VoidExpression; + function updateVoid(node: VoidExpression, expression: Expression): VoidExpression; + function createAwait(expression: Expression): AwaitExpression; + function updateAwait(node: AwaitExpression, expression: Expression): AwaitExpression; + function createPrefix(operator: PrefixUnaryOperator, operand: Expression): PrefixUnaryExpression; + function updatePrefix(node: PrefixUnaryExpression, operand: Expression): PrefixUnaryExpression; + function createPostfix(operand: Expression, operator: PostfixUnaryOperator): PostfixUnaryExpression; + function updatePostfix(node: PostfixUnaryExpression, operand: Expression): PostfixUnaryExpression; + function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression): BinaryExpression; + function updateBinary(node: BinaryExpression, left: Expression, right: Expression): BinaryExpression; + function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; + function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + function createTemplateExpression(head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; + function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; + function createYield(expression?: Expression): YieldExpression; + function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression; + function updateYield(node: YieldExpression, expression: Expression): YieldExpression; + function createSpread(expression: Expression): SpreadElement; + function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; + function createClassExpression(modifiers: Modifier[], name: string | Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; + function createOmittedExpression(): OmittedExpression; + function createExpressionWithTypeArguments(typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; + function createAsExpression(expression: Expression, type: TypeNode): AsExpression; + function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; + function createNonNullExpression(expression: Expression): NonNullExpression; + function updateNonNullExpression(node: NonNullExpression, expression: Expression): NonNullExpression; + function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; + function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; + function createBlock(statements: Statement[], multiLine?: boolean): Block; + function updateBlock(node: Block, statements: Statement[]): Block; + function createVariableStatement(modifiers: Modifier[], declarationList: VariableDeclarationList | VariableDeclaration[]): VariableStatement; + function updateVariableStatement(node: VariableStatement, modifiers: Modifier[], declarationList: VariableDeclarationList): VariableStatement; + function createVariableDeclarationList(declarations: VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; + function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList; + function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; + function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode, initializer: Expression): VariableDeclaration; + function createEmptyStatement(): EmptyStatement; + function createStatement(expression: Expression): ExpressionStatement; + function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement; + function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement): IfStatement; + function createDo(statement: Statement, expression: Expression): DoStatement; + function updateDo(node: DoStatement, statement: Statement, expression: Expression): DoStatement; + function createWhile(expression: Expression, statement: Statement): WhileStatement; + function updateWhile(node: WhileStatement, expression: Expression, statement: Statement): WhileStatement; + function createFor(initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; + function updateFor(node: ForStatement, initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; + function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; + function updateForIn(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; + function createForOf(initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function updateForOf(node: ForOfStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function createContinue(label?: string | Identifier): ContinueStatement; + function updateContinue(node: ContinueStatement, label: Identifier): ContinueStatement; + function createBreak(label?: string | Identifier): BreakStatement; + function updateBreak(node: BreakStatement, label: Identifier): BreakStatement; + function createReturn(expression?: Expression): ReturnStatement; + function updateReturn(node: ReturnStatement, expression: Expression): ReturnStatement; + function createWith(expression: Expression, statement: Statement): WithStatement; + function updateWith(node: WithStatement, expression: Expression, statement: Statement): WithStatement; + function createSwitch(expression: Expression, caseBlock: CaseBlock): SwitchStatement; + function updateSwitch(node: SwitchStatement, expression: Expression, caseBlock: CaseBlock): SwitchStatement; + function createLabel(label: string | Identifier, statement: Statement): LabeledStatement; + function updateLabel(node: LabeledStatement, label: Identifier, statement: Statement): LabeledStatement; + function createThrow(expression: Expression): ThrowStatement; + function updateThrow(node: ThrowStatement, expression: Expression): ThrowStatement; + function createTry(tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; + function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; + function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; + function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; + function createClassDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; + function createEnumDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, members: EnumMember[]): EnumDeclaration; + function updateEnumDeclaration(node: EnumDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, members: EnumMember[]): EnumDeclaration; + function createModuleDeclaration(decorators: Decorator[], modifiers: Modifier[], name: ModuleName, body: ModuleBody, flags?: NodeFlags): ModuleDeclaration; + function updateModuleDeclaration(node: ModuleDeclaration, decorators: Decorator[], modifiers: Modifier[], name: ModuleName, body: ModuleBody): ModuleDeclaration; + function createModuleBlock(statements: Statement[]): ModuleBlock; + function updateModuleBlock(node: ModuleBlock, statements: Statement[]): ModuleBlock; + function createCaseBlock(clauses: CaseOrDefaultClause[]): CaseBlock; + function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]): CaseBlock; + function createImportEqualsDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function createImportDeclaration(decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier?: Expression): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier: Expression): ImportDeclaration; + function createImportClause(name: Identifier, namedBindings: NamedImportBindings): ImportClause; + function updateImportClause(node: ImportClause, name: Identifier, namedBindings: NamedImportBindings): ImportClause; + function createNamespaceImport(name: Identifier): NamespaceImport; + function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; + function createNamedImports(elements: ImportSpecifier[]): NamedImports; + function updateNamedImports(node: NamedImports, elements: ImportSpecifier[]): NamedImports; + function createImportSpecifier(propertyName: Identifier, name: Identifier): ImportSpecifier; + function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier, name: Identifier): ImportSpecifier; + function createExportAssignment(decorators: Decorator[], modifiers: Modifier[], isExportEquals: boolean, expression: Expression): ExportAssignment; + function updateExportAssignment(node: ExportAssignment, decorators: Decorator[], modifiers: Modifier[], expression: Expression): ExportAssignment; + function createExportDeclaration(decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier?: Expression): ExportDeclaration; + function updateExportDeclaration(node: ExportDeclaration, decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier: Expression): ExportDeclaration; + function createNamedExports(elements: ExportSpecifier[]): NamedExports; + function updateNamedExports(node: NamedExports, elements: ExportSpecifier[]): NamedExports; + function createExportSpecifier(name: string | Identifier, propertyName?: string | Identifier): ExportSpecifier; + function updateExportSpecifier(node: ExportSpecifier, name: Identifier, propertyName: Identifier): ExportSpecifier; + function createExternalModuleReference(expression: Expression): ExternalModuleReference; + function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; + function createJsxElement(openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; + function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; + function createJsxSelfClosingElement(tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxSelfClosingElement; + function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxSelfClosingElement; + function createJsxOpeningElement(tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxOpeningElement; + function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, attributes: JsxAttributes): JsxOpeningElement; + function createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement; + function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; + function createJsxAttributes(properties: JsxAttributeLike[]): JsxAttributes; + function updateJsxAttributes(jsxAttributes: JsxAttributes, properties: JsxAttributeLike[]): JsxAttributes; + function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; + function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; + function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; + function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; + function createJsxExpression(expression: Expression, dotDotDotToken: DotDotDotToken): JsxExpression; + function updateJsxExpression(node: JsxExpression, expression: Expression): JsxExpression; + function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[]): HeritageClause; + function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause; + function createCaseClause(expression: Expression, statements: Statement[]): CaseClause; + function updateCaseClause(node: CaseClause, expression: Expression, statements: Statement[]): CaseClause; + function createDefaultClause(statements: Statement[]): DefaultClause; + function updateDefaultClause(node: DefaultClause, statements: Statement[]): DefaultClause; + function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block): CatchClause; + function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause; + function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; + function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment; + function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; + function createSpreadAssignment(expression: Expression): SpreadAssignment; + function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; + function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; + function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; + function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; + function updateSourceFileNode(node: SourceFile, statements: Statement[]): SourceFile; + /** + * Creates a shallow, memberwise clone of a node for mutation. + */ + function getMutableClone(node: T): T; + /** + * Creates a synthetic statement to act as a placeholder for a not-emitted statement in + * order to preserve comments. + * + * @param original The original statement. + */ + function createNotEmittedStatement(original: Node): NotEmittedStatement; + /** + * Creates a synthetic expression to act as a placeholder for a not-emitted expression in + * order to preserve comments or sourcemap positions. + * + * @param expression The inner expression to emit. + * @param original The original outer expression. + * @param location The location for the expression. Defaults to the positions from "original" if provided. + */ + function createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression; + function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; + function createBundle(sourceFiles: SourceFile[]): Bundle; + function updateBundle(node: Bundle, sourceFiles: SourceFile[]): Bundle; + function createComma(left: Expression, right: Expression): Expression; + function createLessThan(left: Expression, right: Expression): Expression; + function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; + function createAssignment(left: Expression, right: Expression): BinaryExpression; + function createStrictEquality(left: Expression, right: Expression): BinaryExpression; + function createStrictInequality(left: Expression, right: Expression): BinaryExpression; + function createAdd(left: Expression, right: Expression): BinaryExpression; + function createSubtract(left: Expression, right: Expression): BinaryExpression; + function createPostfixIncrement(operand: Expression): PostfixUnaryExpression; + function createLogicalAnd(left: Expression, right: Expression): BinaryExpression; + function createLogicalOr(left: Expression, right: Expression): BinaryExpression; + function createLogicalNot(operand: Expression): PrefixUnaryExpression; + function createVoidZero(): VoidExpression; + function createExportDefault(expression: Expression): ExportAssignment; + function createExternalModuleExport(exportName: Identifier): ExportDeclaration; + /** + * Clears any EmitNode entries from parse-tree nodes. + * @param sourceFile A source file. + */ + function disposeEmitNodes(sourceFile: SourceFile): void; + function setTextRange(range: T, location: TextRange | undefined): T; + /** + * Gets flags that control emit behavior of a node. + */ + function getEmitFlags(node: Node): EmitFlags; + /** + * Sets flags that control emit behavior of a node. + */ + function setEmitFlags(node: T, emitFlags: EmitFlags): T; + /** + * Gets a custom text range to use when emitting source maps. + */ + function getSourceMapRange(node: Node): TextRange; + /** + * Sets a custom text range to use when emitting source maps. + */ + function setSourceMapRange(node: T, range: TextRange): T; + /** + * Gets the TextRange to use for source maps for a token of a node. + */ + function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange; + /** + * Sets the TextRange to use for source maps for a token of a node. + */ + function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange): T; + /** + * Gets a custom text range to use when emitting comments. + */ + function getCommentRange(node: Node): TextRange; + /** + * Sets a custom text range to use when emitting comments. + */ + function setCommentRange(node: T, range: TextRange): T; + /** + * Gets the constant value to emit for an expression. + */ + function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; + /** + * Sets the constant value to emit for an expression. + */ + function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number): PropertyAccessExpression | ElementAccessExpression; + /** + * Adds an EmitHelper to a node. + */ + function addEmitHelper(node: T, helper: EmitHelper): T; + /** + * Add EmitHelpers to a node. + */ + function addEmitHelpers(node: T, helpers: EmitHelper[] | undefined): T; + /** + * Removes an EmitHelper from a node. + */ + function removeEmitHelper(node: Node, helper: EmitHelper): boolean; + /** + * Gets the EmitHelpers of a node. + */ + function getEmitHelpers(node: Node): EmitHelper[] | undefined; + /** + * Moves matching emit helpers from a source node to a target node. + */ + function moveEmitHelpers(source: Node, target: Node, predicate: (helper: EmitHelper) => boolean): void; + function setOriginalNode(node: T, original: Node): T; } declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; @@ -2305,6 +2856,10 @@ declare namespace ts { function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } declare namespace ts { + /** Array that is only intended to be pushed to, never read. */ + interface Push { + push(value: T): void; + } function moduleHasNonRelativeName(moduleName: string): boolean; function getEffectiveTypeRoots(options: CompilerOptions, host: { directoryExists?: (directoryName: string) => boolean; @@ -2325,9 +2880,31 @@ declare namespace ts { * this list is only the set of defaults that are implicitly included. */ function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + /** + * Cached module resolutions per containing directory. + * This assumes that any module id will have the same resolution for sibling files located in the same folder. + */ + interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { + getOrCreateCacheForDirectory(directoryName: string): Map; + } + /** + * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory + * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. + */ + interface NonRelativeModuleNameResolutionCache { + getOrCreateCacheForModuleName(nonRelativeModuleName: string): PerModuleNameCache; + } + interface PerModuleNameCache { + get(directory: string): ResolvedModuleWithFailedLookupLocations; + set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; + } + function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): ModuleResolutionCache; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache): ResolvedModuleWithFailedLookupLocations; +} +declare namespace ts { + function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } declare namespace ts { function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; @@ -2369,7 +2946,7 @@ declare namespace ts { * @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, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: FileExtensionInfo[]): ParsedCommandLine; + function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: JsFileExtensionInfo[]): ParsedCommandLine; function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; @@ -2413,7 +2990,7 @@ declare namespace ts { getConstructSignatures(): Signature[]; getStringIndexType(): Type; getNumberIndexType(): Type; - getBaseTypes(): ObjectType[]; + getBaseTypes(): BaseType[]; getNonNullableType(): Type; } interface Signature { @@ -2674,6 +3251,7 @@ declare namespace ts { InsertSpaceAfterCommaDelimiter: boolean; InsertSpaceAfterSemicolonInForStatements: boolean; InsertSpaceBeforeAndAfterBinaryOperators: boolean; + InsertSpaceAfterConstructor?: boolean; InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; @@ -2682,6 +3260,7 @@ declare namespace ts { InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; InsertSpaceAfterTypeAssertion?: boolean; + InsertSpaceBeforeFunctionParenthesis?: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; } @@ -2689,6 +3268,7 @@ declare namespace ts { insertSpaceAfterCommaDelimiter?: boolean; insertSpaceAfterSemicolonInForStatements?: boolean; insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterConstructor?: boolean; insertSpaceAfterKeywordsInControlFlowStatements?: boolean; insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; @@ -2697,6 +3277,7 @@ declare namespace ts { insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; insertSpaceAfterTypeAssertion?: boolean; + insertSpaceBeforeFunctionParenthesis?: boolean; placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; } @@ -2959,6 +3540,10 @@ declare namespace ts { const letElement = "let"; const directory = "directory"; const externalModuleName = "external module name"; + /** + * + **/ + const jsxAttribute = "JSX attribute"; } namespace ScriptElementKindModifier { const none = ""; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 7f41e5d07f5..a8db5a7997f 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -13,11 +13,16 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ts; (function (ts) { // token > SyntaxKind.Identifer => token is a keyword @@ -168,193 +173,196 @@ var ts; SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 130] = "ReadonlyKeyword"; SyntaxKind[SyntaxKind["RequireKeyword"] = 131] = "RequireKeyword"; SyntaxKind[SyntaxKind["NumberKeyword"] = 132] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 133] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 134] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 135] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 136] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 137] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 138] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 139] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 140] = "OfKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 133] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 134] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 135] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 136] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 137] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 138] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 139] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 140] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 141] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 141] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 142] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 142] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 143] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 143] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 144] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 145] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 144] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 145] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 146] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 146] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 147] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 148] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 149] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 150] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 151] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 152] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 153] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 154] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 155] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 147] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 148] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 149] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 150] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 151] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 152] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 153] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 154] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 155] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 156] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 156] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 157] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 158] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 159] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 160] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 161] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 162] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 163] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 164] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 165] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 166] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 167] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 168] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 169] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 170] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 171] = "LiteralType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 157] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 158] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 159] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 160] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 161] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 162] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 163] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 164] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 165] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 166] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 167] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 168] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 169] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 170] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 171] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 172] = "LiteralType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 172] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 173] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 174] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 173] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 174] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 175] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 175] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 176] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 177] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 178] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 179] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 180] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 181] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 182] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 183] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 184] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 185] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 186] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 187] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 188] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 189] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 190] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 191] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 192] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 193] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 194] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 195] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 196] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 197] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 198] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 199] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 200] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 201] = "NonNullExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 176] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 177] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 178] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 179] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 180] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 181] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 182] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 183] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 184] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 185] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 186] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 187] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 188] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 189] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 190] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 191] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 192] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 193] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 194] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 195] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 196] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 197] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 198] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 199] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 200] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 201] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 202] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 203] = "MetaProperty"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 202] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 203] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 204] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 205] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 204] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 205] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 206] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 207] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 208] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 209] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 210] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 211] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 212] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 213] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 214] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 215] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 216] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 217] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 218] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 219] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 220] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 221] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 222] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 223] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 224] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 225] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 226] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 227] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 228] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 229] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 230] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 231] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 232] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 233] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 234] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 235] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 236] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 237] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 238] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 239] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 240] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 241] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 242] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 243] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 244] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 206] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 207] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 208] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 209] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 210] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 211] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 212] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 213] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 214] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 215] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 216] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 217] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 218] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 219] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 220] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 221] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 222] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 223] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 224] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 225] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 226] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 227] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 228] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 229] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 230] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 231] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 232] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 233] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 234] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 235] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 236] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 237] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 238] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 239] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 240] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 241] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 242] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 243] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 244] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 245] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 246] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 247] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 246] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 247] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 248] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 249] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 250] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 251] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 252] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 248] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 249] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 250] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 251] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 252] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 253] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 254] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 255] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 253] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 254] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 255] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 256] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 256] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 257] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 258] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 259] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 257] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 258] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 259] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 260] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 261] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 262] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 260] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 263] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 261] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 264] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 265] = "Bundle"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 262] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 266] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 263] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 267] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 264] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 265] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 266] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 267] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 268] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 269] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 270] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 271] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 272] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 273] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 274] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 275] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 276] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 277] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 278] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 279] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 280] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 281] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 282] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 283] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 284] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 285] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 286] = "JSDocPropertyTag"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 287] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocLiteralType"] = 288] = "JSDocLiteralType"; - SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 289] = "JSDocNullKeyword"; - SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 290] = "JSDocUndefinedKeyword"; - SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 291] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 268] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 269] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 270] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 271] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 272] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 273] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 274] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 275] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 276] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 277] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 278] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 279] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 280] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 281] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 282] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 283] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 284] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 285] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 286] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 287] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 288] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 289] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 290] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 291] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 292] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 293] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 294] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 295] = "JSDocNeverKeyword"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 292] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 296] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 293] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 294] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 295] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 296] = "EndOfDeclarationMarker"; - SyntaxKind[SyntaxKind["RawExpression"] = 297] = "RawExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 297] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 298] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 299] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 300] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 298] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 301] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; @@ -363,15 +371,15 @@ var ts; SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 140] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 141] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 156] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 171] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 157] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 172] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 140] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 141] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -380,11 +388,11 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 141] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 262] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 288] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 278] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 291] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 142] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 266] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 295] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 282] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 295] = "LastJSDocTagNode"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -476,6 +484,8 @@ var ts; FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); @@ -511,6 +521,8 @@ var ts; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; + TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 2048] = "SuppressAnyReturnType"; + TypeFormatFlags[TypeFormatFlags["AddUndefined"] = 4096] = "AddUndefined"; })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var SymbolFormatFlags; (function (SymbolFormatFlags) { @@ -592,13 +604,10 @@ var ts; 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["Prototype"] = 16777216] = "Prototype"; + SymbolFlags[SymbolFlags["ExportStar"] = 33554432] = "ExportStar"; + SymbolFlags[SymbolFlags["Optional"] = 67108864] = "Optional"; + SymbolFlags[SymbolFlags["Transient"] = 134217728] = "Transient"; SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; @@ -642,11 +651,25 @@ var ts; SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); /* @internal */ + var CheckFlags; + (function (CheckFlags) { + CheckFlags[CheckFlags["Instantiated"] = 1] = "Instantiated"; + CheckFlags[CheckFlags["SyntheticProperty"] = 2] = "SyntheticProperty"; + CheckFlags[CheckFlags["Readonly"] = 4] = "Readonly"; + CheckFlags[CheckFlags["Partial"] = 8] = "Partial"; + CheckFlags[CheckFlags["HasNonUniformType"] = 16] = "HasNonUniformType"; + CheckFlags[CheckFlags["ContainsPublic"] = 32] = "ContainsPublic"; + CheckFlags[CheckFlags["ContainsProtected"] = 64] = "ContainsProtected"; + CheckFlags[CheckFlags["ContainsPrivate"] = 128] = "ContainsPrivate"; + CheckFlags[CheckFlags["ContainsStatic"] = 256] = "ContainsStatic"; + })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); + /* @internal */ var NodeCheckFlags; (function (NodeCheckFlags) { NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["CaptureNewTarget"] = 8] = "CaptureNewTarget"; NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; @@ -695,6 +718,9 @@ var ts; TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; /* @internal */ TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; + /* @internal */ + TypeFlags[TypeFlags["JsxAttributes"] = 33554432] = "JsxAttributes"; /* @internal */ TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; @@ -703,7 +729,7 @@ var ts; TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 16015] = "Intrinsic"; + TypeFlags[TypeFlags["Intrinsic"] = 16793231] = "Intrinsic"; /* @internal */ TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; TypeFlags[TypeFlags["StringLike"] = 262178] = "StringLike"; @@ -712,12 +738,12 @@ var ts; TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; TypeFlags[TypeFlags["UnionOrIntersection"] = 196608] = "UnionOrIntersection"; TypeFlags[TypeFlags["StructuredType"] = 229376] = "StructuredType"; - TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 507904] = "StructuredOrTypeParameter"; + TypeFlags[TypeFlags["StructuredOrTypeVariable"] = 1032192] = "StructuredOrTypeVariable"; TypeFlags[TypeFlags["TypeVariable"] = 540672] = "TypeVariable"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 1033215] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 33281] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["Narrowable"] = 17810431] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 16810497] = "NotUnionOrUnit"; /* @internal */ TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; /* @internal */ @@ -735,6 +761,7 @@ var ts; ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; + ObjectFlags[ObjectFlags["NonPrimitive"] = 1024] = "NonPrimitive"; ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); var SignatureKind; @@ -785,6 +812,7 @@ var ts; JsxEmit[JsxEmit["None"] = 0] = "None"; JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; JsxEmit[JsxEmit["React"] = 2] = "React"; + JsxEmit[JsxEmit["ReactNative"] = 3] = "ReactNative"; })(JsxEmit = ts.JsxEmit || (ts.JsxEmit = {})); var NewLineKind; (function (NewLineKind) { @@ -798,6 +826,7 @@ var ts; ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; ScriptKind[ScriptKind["TS"] = 3] = "TS"; ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + ScriptKind[ScriptKind["External"] = 5] = "External"; })(ScriptKind = ts.ScriptKind || (ts.ScriptKind = {})); var ScriptTarget; (function (ScriptTarget) { @@ -1032,7 +1061,6 @@ var ts; TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 274432] = "TypeScriptClassSyntaxMask"; TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 163840] = "ES2015FunctionSyntaxMask"; })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); - /* @internal */ var EmitFlags; (function (EmitFlags) { EmitFlags[EmitFlags["SingleLine"] = 1] = "SingleLine"; @@ -1079,14 +1107,13 @@ var ts; ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper"; ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 128] = "LastEmitHelper"; })(ExternalEmitHelpers = ts.ExternalEmitHelpers || (ts.ExternalEmitHelpers = {})); - /* @internal */ - var EmitContext; - (function (EmitContext) { - EmitContext[EmitContext["SourceFile"] = 0] = "SourceFile"; - EmitContext[EmitContext["Expression"] = 1] = "Expression"; - EmitContext[EmitContext["IdentifierName"] = 2] = "IdentifierName"; - EmitContext[EmitContext["Unspecified"] = 3] = "Unspecified"; - })(EmitContext = ts.EmitContext || (ts.EmitContext = {})); + var EmitHint; + (function (EmitHint) { + EmitHint[EmitHint["SourceFile"] = 0] = "SourceFile"; + EmitHint[EmitHint["Expression"] = 1] = "Expression"; + EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; + EmitHint[EmitHint["Unspecified"] = 3] = "Unspecified"; + })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); })(ts || (ts = {})); /*@internal*/ var ts; @@ -1114,8 +1141,8 @@ var ts; */ function mark(markName) { if (enabled) { - marks[markName] = ts.timestamp(); - counts[markName] = (counts[markName] || 0) + 1; + marks.set(markName, ts.timestamp()); + counts.set(markName, (counts.get(markName) || 0) + 1); profilerEvent(markName); } } @@ -1131,9 +1158,9 @@ var ts; */ function measure(measureName, startMarkName, endMarkName) { if (enabled) { - var end = endMarkName && marks[endMarkName] || ts.timestamp(); - var start = startMarkName && marks[startMarkName] || profilerStart; - measures[measureName] = (measures[measureName] || 0) + (end - start); + var end = endMarkName && marks.get(endMarkName) || ts.timestamp(); + var start = startMarkName && marks.get(startMarkName) || profilerStart; + measures.set(measureName, (measures.get(measureName) || 0) + (end - start)); } } performance.measure = measure; @@ -1143,7 +1170,7 @@ var ts; * @param markName The name of the mark. */ function getCount(markName) { - return counts && counts[markName] || 0; + return counts && counts.get(markName) || 0; } performance.getCount = getCount; /** @@ -1152,7 +1179,7 @@ var ts; * @param measureName The name of the measure whose durations should be accumulated. */ function getDuration(measureName) { - return measures && measures[measureName] || 0; + return measures && measures.get(measureName) || 0; } performance.getDuration = getDuration; /** @@ -1161,9 +1188,9 @@ var ts; * @param cb The action to perform for each measure */ function forEachMeasure(cb) { - for (var key in measures) { - cb(key, measures[key]); - } + measures.forEach(function (measure, key) { + cb(key, measure); + }); } performance.forEachMeasure = forEachMeasure; /** Enables (and resets) performance measurements for the compiler. */ @@ -1187,7 +1214,7 @@ var ts; var ts; (function (ts) { /** The version of the TypeScript compiler release */ - ts.version = "2.2.0"; + ts.version = "2.3.0"; })(ts || (ts = {})); /* @internal */ (function (ts) { @@ -1206,25 +1233,106 @@ var ts; Ternary[Ternary["Maybe"] = 1] = "Maybe"; Ternary[Ternary["True"] = -1] = "True"; })(Ternary = ts.Ternary || (ts.Ternary = {})); - var createObject = Object.create; // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. - ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - function createMap(template) { - var map = createObject(null); // tslint:disable-line:no-null-keyword + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(/*locales*/ undefined, { usage: "sort", sensitivity: "accent" }) : undefined; + // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". + ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + /** Create a MapLike with good performance. */ + function createDictionaryObject() { + var map = Object.create(null); // tslint:disable-line:no-null-keyword // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is // constantly changing shape. map["__"] = undefined; delete map["__"]; + return map; + } + /** Create a new map. If a template object is provided, the map will copy entries from it. */ + function createMap() { + return new MapCtr(); + } + ts.createMap = createMap; + function createMapFromTemplate(template) { + var map = new MapCtr(); // Copies keys/values from template. Note that for..in will not throw if // template is undefined, and instead will just exit the loop. for (var key in template) if (hasOwnProperty.call(template, key)) { - map[key] = template[key]; + map.set(key, template[key]); } return map; } - ts.createMap = createMap; + ts.createMapFromTemplate = createMapFromTemplate; + // Internet Explorer's Map doesn't support iteration, so don't use it. + // tslint:disable-next-line:no-in-operator + var MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); + // Keep the class inside a function so it doesn't get compiled if it's not used. + function shimMap() { + var MapIterator = (function () { + function MapIterator(data, selector) { + this.index = 0; + this.data = data; + this.selector = selector; + this.keys = Object.keys(data); + } + MapIterator.prototype.next = function () { + var index = this.index; + if (index < this.keys.length) { + this.index++; + return { value: this.selector(this.data, this.keys[index]), done: false }; + } + return { value: undefined, done: true }; + }; + return MapIterator; + }()); + return (function () { + function class_1() { + this.data = createDictionaryObject(); + this.size = 0; + } + class_1.prototype.get = function (key) { + return this.data[key]; + }; + class_1.prototype.set = function (key, value) { + if (!this.has(key)) { + this.size++; + } + this.data[key] = value; + return this; + }; + class_1.prototype.has = function (key) { + // tslint:disable-next-line:no-in-operator + return key in this.data; + }; + class_1.prototype.delete = function (key) { + if (this.has(key)) { + this.size--; + delete this.data[key]; + return true; + } + return false; + }; + class_1.prototype.clear = function () { + this.data = createDictionaryObject(); + this.size = 0; + }; + class_1.prototype.keys = function () { + return new MapIterator(this.data, function (_data, key) { return key; }); + }; + class_1.prototype.values = function () { + return new MapIterator(this.data, function (data, key) { return data[key]; }); + }; + class_1.prototype.entries = function () { + return new MapIterator(this.data, function (data, key) { return [key, data[key]]; }); + }; + class_1.prototype.forEach = function (action) { + for (var key in this.data) { + action(this.data[key], key); + } + }; + return class_1; + }()); + } function createFileMap(keyMapper) { var files = createMap(); return { @@ -1237,33 +1345,28 @@ var ts; clear: clear, }; function forEachValueInMap(f) { - for (var key in files) { - f(key, files[key]); - } + files.forEach(function (file, key) { + f(key, file); + }); } function getKeys() { - var keys = []; - for (var key in files) { - keys.push(key); - } - return keys; + return arrayFrom(files.keys()); } // path should already be well-formed so it does not need to be normalized function get(path) { - return files[toKey(path)]; + return files.get(toKey(path)); } function set(path, value) { - files[toKey(path)] = value; + files.set(toKey(path), value); } function contains(path) { - return toKey(path) in files; + return files.has(toKey(path)); } function remove(path) { - var key = toKey(path); - delete files[key]; + files.delete(toKey(path)); } function clear() { - files = createMap(); + files.clear(); } function toKey(path) { return keyMapper ? keyMapper(path) : path; @@ -1283,6 +1386,10 @@ var ts; Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; })(Comparison = ts.Comparison || (ts.Comparison = {})); + function length(array) { + return array ? array.length : 0; + } + ts.length = length; /** * 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. @@ -1290,7 +1397,7 @@ var ts; */ function forEach(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -1314,7 +1421,7 @@ var ts; */ function every(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -1325,7 +1432,7 @@ var ts; ts.every = every; /** Works like Array.prototype.find, returning `undefined` if no element satisfying the predicate is found. */ function find(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -1334,12 +1441,22 @@ var ts; return undefined; } ts.find = find; + /** Works like Array.prototype.findIndex, returning `-1` if no element satisfying the predicate is found. */ + function findIndex(array, predicate) { + for (var i = 0; i < array.length; i++) { + if (predicate(array[i], i)) { + return i; + } + } + return -1; + } + ts.findIndex = findIndex; /** * Returns the first truthy result of `callback`, or else fails. * This is like `forEach`, but never returns undefined. */ function findMap(array, callback) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -1362,7 +1479,7 @@ var ts; ts.contains = contains; function indexOf(array, value) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -1372,7 +1489,7 @@ var ts; } ts.indexOf = indexOf; function indexOfAnyCharCode(text, charCodes, start) { - for (var i = start || 0, len = text.length; i < len; i++) { + for (var i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -1582,21 +1699,18 @@ var ts; return result; } ts.spanMap = spanMap; - function mapObject(object, f) { - var result; - if (object) { - result = {}; - for (var _i = 0, _a = getOwnKeys(object); _i < _a.length; _i++) { - var v = _a[_i]; - var _b = f(v, object[v]) || [undefined, undefined], key = _b[0], value = _b[1]; - if (key !== undefined) { - result[key] = value; - } - } + function mapEntries(map, f) { + if (!map) { + return undefined; } + var result = createMap(); + map.forEach(function (value, key) { + var _a = f(key, value), newKey = _a[0], newValue = _a[1]; + result.set(newKey, newValue); + }); return result; } - ts.mapObject = mapObject; + ts.mapEntries = mapEntries; function some(array, predicate) { if (array) { if (predicate) { @@ -1914,9 +2028,6 @@ var ts; /** * Indicates whether a map-like contains an own property with the specified key. * - * NOTE: This is intended for use only with MapLike objects. For Map objects, use - * the 'in' operator. - * * @param map A map-like. * @param key A property key. */ @@ -1927,9 +2038,6 @@ var ts; /** * Gets the value of an owned property in a map-like. * - * NOTE: This is intended for use only with MapLike objects. For Map objects, use - * an indexer. - * * @param map A map-like. * @param key A property key. */ @@ -1954,56 +2062,62 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; - /** - * Enumerates the properties of a Map, invoking a callback and returning the first truthy result. - * - * @param map A map for which properties should be enumerated. - * @param callback A callback to invoke for each property. - */ - function forEachProperty(map, callback) { - var result; - for (var key in map) { - if (result = callback(map[key], key)) - break; + /** Shims `Array.from`. */ + function arrayFrom(iterator) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(value); } return result; + var _b; } - ts.forEachProperty = forEachProperty; - /** - * Returns true if a Map has some matching property. - * - * @param map A map whose properties should be tested. - * @param predicate An optional callback used to test each property. - */ - function someProperties(map, predicate) { - for (var key in map) { - if (!predicate || predicate(map[key], key)) - return true; + ts.arrayFrom = arrayFrom; + function convertToArray(iterator, f) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(f(value)); } - return false; + return result; + var _b; } - ts.someProperties = someProperties; + ts.convertToArray = convertToArray; /** - * Performs a shallow copy of the properties from a source Map to a target MapLike - * - * @param source A map from which properties should be copied. - * @param target A map to which properties should be copied. + * Calls `callback` for each entry in the map, returning the first truthy result. + * Use `map.forEach` instead for normal iteration. */ - function copyProperties(source, target) { - for (var key in source) { - target[key] = source[key]; + function forEachEntry(map, callback) { + var iterator = map.entries(); + for (var _a = iterator.next(), pair = _a.value, done = _a.done; !done; _b = iterator.next(), pair = _b.value, done = _b.done, _b) { + var key = pair[0], value = pair[1]; + var result = callback(value, key); + if (result) { + return result; + } } + return undefined; + var _b; } - ts.copyProperties = copyProperties; - function appendProperty(map, key, value) { - if (key === undefined || value === undefined) - return map; - if (map === undefined) - map = createMap(); - map[key] = value; - return map; + ts.forEachEntry = forEachEntry; + /** `forEachEntry` for just keys. */ + function forEachKey(map, callback) { + var iterator = map.keys(); + for (var _a = iterator.next(), key = _a.value, done = _a.done; !done; _b = iterator.next(), key = _b.value, done = _b.done, _b) { + var result = callback(key); + if (result) { + return result; + } + } + return undefined; + var _b; } - ts.appendProperty = appendProperty; + ts.forEachKey = forEachKey; + /** Copy entries from `source` to `target`. */ + function copyEntries(source, target) { + source.forEach(function (value, key) { + target.set(key, value); + }); + } + ts.copyEntries = copyEntries; function assign(t) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -2019,24 +2133,6 @@ var ts; return t; } ts.assign = assign; - /** - * Reduce the properties of a map. - * - * NOTE: This is intended for use with Map objects. For MapLike objects, use - * reduceOwnProperties instead as it offers better runtime safety. - * - * @param map The map to reduce - * @param callback An aggregation function that is called for each entry in the map - * @param initial The initial value for the reduction. - */ - function reduceProperties(map, callback, initial) { - var result = initial; - for (var key in map) { - result = callback(result, map[key], String(key)); - } - return result; - } - ts.reduceProperties = reduceProperties; /** * Performs a shallow equality comparison of the contents of two map-likes. * @@ -2067,23 +2163,14 @@ var ts; var result = createMap(); for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { var value = array_8[_i]; - result[makeKey(value)] = makeValue ? makeValue(value) : value; + result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; } ts.arrayToMap = arrayToMap; - function isEmpty(map) { - for (var id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - ts.isEmpty = isEmpty; function cloneMap(map) { var clone = createMap(); - copyProperties(map, clone); + copyEntries(map, clone); return clone; } ts.cloneMap = cloneMap; @@ -2110,36 +2197,32 @@ var ts; return result; } ts.extend = extend; - /** - * Adds the value to an array of values associated with the key, and returns the array. - * Creates the array if it does not already exist. - */ - function multiMapAdd(map, key, value) { - var values = map[key]; + function createMultiMap() { + var map = createMap(); + map.add = multiMapAdd; + map.remove = multiMapRemove; + return map; + } + ts.createMultiMap = createMultiMap; + function multiMapAdd(key, value) { + var values = this.get(key); if (values) { values.push(value); - return values; } else { - return map[key] = [value]; + this.set(key, values = [value]); } + return values; } - ts.multiMapAdd = multiMapAdd; - /** - * Removes a value from an array of values associated with the key. - * Does not preserve the order of those values. - * Does nothing if `key` is not in `map`, or `value` is not in `map[key]`. - */ - function multiMapRemove(map, key, value) { - var values = map[key]; + function multiMapRemove(key, value) { + var values = this.get(key); if (values) { unorderedRemoveItem(values, value); if (!values.length) { - delete map[key]; + this.delete(key); } } } - ts.multiMapRemove = multiMapRemove; /** * Tests whether a value is an array. */ @@ -2220,6 +2303,7 @@ var ts; baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } + ts.formatStringFromArgs = formatStringFromArgs; ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; @@ -2322,9 +2406,12 @@ var ts; if (b === undefined) return 1 /* GreaterThan */; if (ignoreCase) { - if (ts.collator && String.prototype.localeCompare) { - // accent means a ≠ b, a ≠ á, a = A - var result = a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); + // Checking if "collator exists indicates that Intl is available. + // We still have to check if "collator.compare" is correct. If it is not, use "String.localeComapre" + if (ts.collator) { + var result = ts.localeCompareIsCorrect ? + ts.collator.compare(a, b) : + a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); // accent means a ≠ b, a ≠ á, a = A return result < 0 ? -1 /* LessThan */ : result > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; } a = a.toUpperCase(); @@ -2769,6 +2856,17 @@ var ts; var singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; var singleAsteriskRegexFragmentOther = "[^/]*"; function getRegularExpressionForWildcard(specs, basePath, usage) { + var patterns = getRegularExpressionsForWildcards(specs, basePath, usage); + if (!patterns || !patterns.length) { + return undefined; + } + var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + // If excluding, match "foo/bar/baz...", but if including, only allow "foo". + var terminator = usage === "exclude" ? "($|/)" : "$"; + return "^(" + pattern + ")" + terminator; + } + ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; + function getRegularExpressionsForWildcards(specs, basePath, usage) { if (specs === undefined || specs.length === 0) { return undefined; } @@ -2779,31 +2877,10 @@ var ts; * files or directories, does not match subdirectories that start with a . character */ var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; - var pattern = ""; - var hasWrittenSubpattern = false; - for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { - var spec = specs_1[_i]; - if (!spec) { - continue; - } - var subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); - if (subPattern === undefined) { - continue; - } - if (hasWrittenSubpattern) { - pattern += "|"; - } - pattern += "(" + subPattern + ")"; - hasWrittenSubpattern = true; - } - if (!pattern) { - return undefined; - } - // If excluding, match "foo/bar/baz...", but if including, only allow "foo". - var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return flatMap(specs, function (spec) { + return spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + }); } - ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; /** * An "includes" path "foo" is implicitly a glob "foo/** /*" (without the space) if its last component has no extension, * and does not contain any glob characters itself. @@ -2882,6 +2959,7 @@ var ts; currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); return { + includeFilePatterns: map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -2894,34 +2972,50 @@ var ts; currentDirectory = normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; - var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); + var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return new RegExp(pattern, regexFlag); }); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); var excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); - var result = []; + // Associate an array of results with each include regex. This keeps results in order of the "include" order. + // If there are no "includes", then just put everything in results[0]. + var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]]; + var comparer = useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive; for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; visitDirectory(basePath, combinePaths(currentDirectory, basePath)); } - return result; + return flatten(results); function visitDirectory(path, absolutePath) { var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; + files = files.slice().sort(comparer); + directories = directories.slice().sort(comparer); + var _loop_1 = function (current) { + var name = combinePaths(path, current); + var absoluteName = combinePaths(absolutePath, current); + if (extensions && !fileExtensionIsAny(name, extensions)) + return "continue"; + if (excludeRegex && excludeRegex.test(absoluteName)) + return "continue"; + if (!includeFileRegexes) { + results[0].push(name); + } + else { + var includeIndex = findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); }); + if (includeIndex !== -1) { + results[includeIndex].push(name); + } + } + }; for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var current = files_1[_i]; - var name_1 = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); - if ((!extensions || fileExtensionIsAny(name_1, extensions)) && - (!includeFileRegex || includeFileRegex.test(absoluteName)) && - (!excludeRegex || !excludeRegex.test(absoluteName))) { - result.push(name_1); - } + _loop_1(current); } for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var current = directories_1[_b]; - var name_2 = combinePaths(path, current); + var name = combinePaths(path, current); var absoluteName = combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { - visitDirectory(name_2, absoluteName); + visitDirectory(name, absoluteName); } } } @@ -2946,7 +3040,7 @@ var ts; } // Sort the offsets array using either the literal or canonical path representations. includeBasePaths.sort(useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); - var _loop_1 = function (includeBasePath) { + var _loop_2 = function (includeBasePath) { if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { basePaths.push(includeBasePath); } @@ -2955,7 +3049,7 @@ var ts; // subpath of an existing base path for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) { var includeBasePath = includeBasePaths_1[_a]; - _loop_1(includeBasePath); + _loop_2(includeBasePath); } } return basePaths; @@ -3006,13 +3100,13 @@ var ts; var allSupportedExtensions = ts.supportedTypeScriptExtensions.concat(ts.supportedJavascriptExtensions); function getSupportedExtensions(options, extraFileExtensions) { var needAllExtensions = options && options.allowJs; - if (!extraFileExtensions || extraFileExtensions.length === 0) { + if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } - var extensions = (needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions).slice(0); + var extensions = allSupportedExtensions.slice(0); for (var _i = 0, extraFileExtensions_1 = extraFileExtensions; _i < extraFileExtensions_1.length; _i++) { var extInfo = extraFileExtensions_1[_i]; - if (needAllExtensions || extInfo.scriptKind === 3 /* TS */) { + if (extensions.indexOf(extInfo.extension) === -1) { extensions.push(extInfo.extension); } } @@ -3049,14 +3143,13 @@ var ts; (function (ExtensionPriority) { ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; - ExtensionPriority[ExtensionPriority["Limit"] = 5] = "Limit"; ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; })(ExtensionPriority = ts.ExtensionPriority || (ts.ExtensionPriority = {})); function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { - return adjustExtensionPriority(i); + return adjustExtensionPriority(i, supportedExtensions); } } // If its not in the list of supported extensions, this is likely a @@ -3067,27 +3160,27 @@ var ts; /** * Adjusts an extension priority to be the highest priority within the same range. */ - function adjustExtensionPriority(extensionPriority) { + function adjustExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) { return 0 /* TypeScriptFiles */; } - else if (extensionPriority < 5 /* Limit */) { + else if (extensionPriority < supportedExtensions.length) { return 2 /* DeclarationAndJavaScriptFiles */; } else { - return 5 /* Limit */; + return supportedExtensions.length; } } ts.adjustExtensionPriority = adjustExtensionPriority; /** * Gets the next lowest extension priority for a given priority. */ - function getNextLowestExtensionPriority(extensionPriority) { + function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) { return 2 /* DeclarationAndJavaScriptFiles */; } else { - return 5 /* Limit */; + return supportedExtensions.length; } } ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority; @@ -3481,32 +3574,32 @@ var ts; function createWatchedFileSet() { var dirWatchers = ts.createMap(); // One file can have multiple watchers - var fileWatcherCallbacks = ts.createMap(); + var fileWatcherCallbacks = ts.createMultiMap(); return { addFile: addFile, removeFile: removeFile }; function reduceDirWatcherRefCountForFile(fileName) { var dirName = ts.getDirectoryPath(fileName); - var watcher = dirWatchers[dirName]; + var watcher = dirWatchers.get(dirName); if (watcher) { watcher.referenceCount -= 1; if (watcher.referenceCount <= 0) { watcher.close(); - delete dirWatchers[dirName]; + dirWatchers.delete(dirName); } } } function addDirWatcher(dirPath) { - var watcher = dirWatchers[dirPath]; + var watcher = dirWatchers.get(dirPath); if (watcher) { watcher.referenceCount += 1; return; } watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); watcher.referenceCount = 1; - dirWatchers[dirPath] = watcher; + dirWatchers.set(dirPath, watcher); return; } function addFileWatcherCallback(filePath, callback) { - ts.multiMapAdd(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.add(filePath, callback); } function addFile(fileName, callback) { addFileWatcherCallback(fileName, callback); @@ -3518,7 +3611,7 @@ var ts; reduceDirWatcherRefCountForFile(watchedFile.fileName); } function removeFileWatcherCallback(filePath, callback) { - ts.multiMapRemove(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.remove(filePath, callback); } function fileEventHandler(eventName, relativeFileName, baseDirPath) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" @@ -3526,10 +3619,13 @@ var ts; ? undefined : ts.getNormalizedAbsolutePath(relativeFileName, baseDirPath); // Some applications save a working file via rename operations - if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks[fileName]) { - for (var _i = 0, _a = fileWatcherCallbacks[fileName]; _i < _a.length; _i++) { - var fileCallback = _a[_i]; - fileCallback(fileName); + if ((eventName === "change" || eventName === "rename")) { + var callbacks = fileWatcherCallbacks.get(fileName); + if (callbacks) { + for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) { + var fileCallback = callbacks_1[_i]; + fileCallback(fileName); + } } } } @@ -3605,10 +3701,10 @@ var ts; if (entry === "." || entry === "..") { continue; } - var name_3 = ts.combinePaths(path, entry); + var name = ts.combinePaths(path, entry); var stat = void 0; try { - stat = _fs.statSync(name_3); + stat = _fs.statSync(name); } catch (e) { continue; @@ -3689,7 +3785,10 @@ var ts; // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643) var options; - if (!directoryExists(directoryName)) { + if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { + // do nothing if either + // - target folder does not exist + // - this is UNC path on Windows (https://github.com/Microsoft/TypeScript/issues/13874) return noOpFileWatcher; } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { @@ -3708,6 +3807,9 @@ var ts; } ; }); + function isUNCPath(s) { + return s.length > 2 && s.charCodeAt(0) === 47 /* slash */ && s.charCodeAt(1) === 47 /* slash */; + } }, resolvePath: function (path) { return _path.resolve(path); @@ -3770,6 +3872,7 @@ var ts; require("source-map-support").install(); } catch (e) { + // Could not enable source maps. } }, setTimeout: setTimeout, @@ -3915,7 +4018,7 @@ var ts; _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, 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." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." }, 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." }, @@ -4026,6 +4129,7 @@ var ts; 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." }, + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", message: "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules." }, 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_Set_the_experimentalDecorators_option_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_Set_t_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", message: "Generators are only available when targeting ECMAScript 2015 or higher." }, @@ -4072,6 +4176,7 @@ var ts; Global_module_exports_may_only_appear_at_top_level: { code: 1316, category: ts.DiagnosticCategory.Error, key: "Global_module_exports_may_only_appear_at_top_level_1316", message: "Global module exports may only appear at top level." }, A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, 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." }, @@ -4301,6 +4406,10 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, + A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: { code: 2545, category: ts.DiagnosticCategory.Error, key: "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", message: "A mixin class must have a constructor with a single rest parameter of type 'any[]'." }, + Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: { code: 2546, category: ts.DiagnosticCategory.Error, key: "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", message: "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union 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." }, @@ -4310,6 +4419,8 @@ var ts; 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" }, + JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, + Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: { code: 2649, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", message: "Cannot augment module '{0}' with value exports because it resolves to a non-module entity." }, 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." }, @@ -4358,9 +4469,15 @@ var ts; The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { code: 2696, category: ts.DiagnosticCategory.Error, key: "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", message: "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?" }, An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, + Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: { code: 2699, category: ts.DiagnosticCategory.Error, key: "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", message: "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'." }, Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, + An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: { code: 2705, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", message: "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option." }, + Required_type_parameters_may_not_follow_optional_type_parameters: { code: 2706, category: ts.DiagnosticCategory.Error, key: "Required_type_parameters_may_not_follow_optional_type_parameters_2706", message: "Required type parameters may not follow optional type parameters." }, + Generic_type_0_requires_between_1_and_2_type_arguments: { code: 2707, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_between_1_and_2_type_arguments_2707", message: "Generic type '{0}' requires between {1} and {2} type arguments." }, 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}'." }, @@ -4371,8 +4488,8 @@ var ts; 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}'." }, + 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}'." }, @@ -4435,6 +4552,7 @@ var ts; Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { code: 4090, category: ts.DiagnosticCategory.Message, key: "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", message: "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", message: "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4092, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", message: "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'." }, + extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced: { code: 4093, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced_4093", message: "'extends' clause of exported class '{0}' refers to a type whose name cannot be referenced." }, 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." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, @@ -4480,7 +4598,7 @@ var ts; 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." }, + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'" }, 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" }, @@ -4495,6 +4613,7 @@ var ts; LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION_6037", message: "LOCATION" }, DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY_6038", message: "DIRECTORY" }, STRATEGY: { code: 6039, category: ts.DiagnosticCategory.Message, key: "STRATEGY_6039", message: "STRATEGY" }, + FILE_OR_DIRECTORY: { code: 6040, category: ts.DiagnosticCategory.Message, key: "FILE_OR_DIRECTORY_6040", message: "FILE OR 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." }, @@ -4528,7 +4647,8 @@ var ts; 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_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, - 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'" }, + Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'" }, + File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, @@ -4542,12 +4662,12 @@ var ts; Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, - Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", message: "Loading module as file / folder, candidate module location '{0}', target file type '{1}'." }, File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, - Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, - package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, + package_json_does_not_have_a_0_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_0_field_6100", message: "'package.json' does not have a '{0}' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, @@ -4584,7 +4704,6 @@ var ts; Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, - No_types_specified_in_package_json_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json', so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, @@ -4594,6 +4713,8 @@ var ts; Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, + Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, + Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, 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." }, @@ -4635,7 +4756,7 @@ var ts; 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." }, 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." }, - 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." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: { 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' clause." }, 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." }, Language_service_is_disabled: { code: 9004, category: ts.DiagnosticCategory.Error, key: "Language_service_is_disabled_9004", message: "Language service is disabled." }, 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'." }, @@ -4650,22 +4771,26 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, - Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, - Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, - Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, + Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: {0}" }, + Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, + Add_this_to_unresolved_variable: { code: 90008, category: ts.DiagnosticCategory.Message, key: "Add_this_to_unresolved_variable_90008", message: "Add 'this.' to unresolved variable." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, }; })(ts || (ts = {})); /// @@ -4677,7 +4802,7 @@ var ts; return token >= 70 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = ts.createMap({ + var textToToken = ts.createMapFromTemplate({ "abstract": 116 /* AbstractKeyword */, "any": 118 /* AnyKeyword */, "as": 117 /* AsKeyword */, @@ -4701,7 +4826,7 @@ var ts; "false": 85 /* FalseKeyword */, "finally": 86 /* FinallyKeyword */, "for": 87 /* ForKeyword */, - "from": 138 /* FromKeyword */, + "from": 139 /* FromKeyword */, "function": 88 /* FunctionKeyword */, "get": 124 /* GetKeyword */, "if": 89 /* IfKeyword */, @@ -4719,27 +4844,28 @@ var ts; "new": 93 /* NewKeyword */, "null": 94 /* NullKeyword */, "number": 132 /* NumberKeyword */, + "object": 133 /* ObjectKeyword */, "package": 110 /* PackageKeyword */, "private": 111 /* PrivateKeyword */, "protected": 112 /* ProtectedKeyword */, "public": 113 /* PublicKeyword */, "readonly": 130 /* ReadonlyKeyword */, "require": 131 /* RequireKeyword */, - "global": 139 /* GlobalKeyword */, + "global": 140 /* GlobalKeyword */, "return": 95 /* ReturnKeyword */, - "set": 133 /* SetKeyword */, + "set": 134 /* SetKeyword */, "static": 114 /* StaticKeyword */, - "string": 134 /* StringKeyword */, + "string": 135 /* StringKeyword */, "super": 96 /* SuperKeyword */, "switch": 97 /* SwitchKeyword */, - "symbol": 135 /* SymbolKeyword */, + "symbol": 136 /* SymbolKeyword */, "this": 98 /* ThisKeyword */, "throw": 99 /* ThrowKeyword */, "true": 100 /* TrueKeyword */, "try": 101 /* TryKeyword */, - "type": 136 /* TypeKeyword */, + "type": 137 /* TypeKeyword */, "typeof": 102 /* TypeOfKeyword */, - "undefined": 137 /* UndefinedKeyword */, + "undefined": 138 /* UndefinedKeyword */, "var": 103 /* VarKeyword */, "void": 104 /* VoidKeyword */, "while": 105 /* WhileKeyword */, @@ -4747,7 +4873,7 @@ var ts; "yield": 115 /* YieldKeyword */, "async": 119 /* AsyncKeyword */, "await": 120 /* AwaitKeyword */, - "of": 140 /* OfKeyword */, + "of": 141 /* OfKeyword */, "{": 16 /* OpenBraceToken */, "}": 17 /* CloseBraceToken */, "(": 18 /* OpenParenToken */, @@ -4887,9 +5013,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var name_4 in source) { - result[source[name_4]] = name_4; - } + source.forEach(function (value, name) { + result[value] = name; + }); return result; } var tokenStrings = makeReverseMap(textToToken); @@ -4899,7 +5025,7 @@ var ts; ts.tokenToString = tokenToString; /* @internal */ function stringToToken(s) { - return textToToken[s]; + return textToToken.get(s); } ts.stringToToken = stringToToken; /* @internal */ @@ -4973,7 +5099,6 @@ var ts; return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - var hasOwnProperty = Object.prototype.hasOwnProperty; function isWhiteSpace(ch) { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } @@ -5132,7 +5257,7 @@ var ts; 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++) { + for (var i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -5344,7 +5469,7 @@ var ts; if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { return false; } - for (var i = 1, n = name.length; i < n; i++) { + for (var i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -5716,8 +5841,11 @@ var ts; 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]; + if (ch >= 97 /* a */ && ch <= 122 /* z */) { + token = textToToken.get(tokenValue); + if (token !== undefined) { + return token; + } } } return token = 70 /* Identifier */; @@ -6410,6 +6538,19 @@ var ts; return undefined; } ts.getDeclarationOfKind = getDeclarationOfKind; + function findDeclaration(symbol, predicate) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; + if (predicate(declaration)) { + return declaration; + } + } + } + return undefined; + } + ts.findDeclaration = findDeclaration; // Pool writers to avoid needing to allocate them for every symbol we write. var stringWriters = []; function getSingleLineStringWriter() { @@ -6433,7 +6574,8 @@ var ts; decreaseIndent: ts.noop, clear: function () { return str_1 = ""; }, trackSymbol: ts.noop, - reportInaccessibleThisError: ts.noop + reportInaccessibleThisError: ts.noop, + reportIllegalExtends: ts.noop }; } return stringWriters.pop(); @@ -6449,25 +6591,25 @@ var ts; } ts.getFullWidth = getFullWidth; function hasResolvedModule(sourceFile, moduleNameText) { - return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); + return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText)); } ts.hasResolvedModule = hasResolvedModule; function getResolvedModule(sourceFile, moduleNameText) { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules.get(moduleNameText) : undefined; } ts.getResolvedModule = getResolvedModule; function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { if (!sourceFile.resolvedModules) { sourceFile.resolvedModules = ts.createMap(); } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; + sourceFile.resolvedModules.set(moduleNameText, resolvedModule); } ts.setResolvedModule = setResolvedModule; function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { if (!sourceFile.resolvedTypeReferenceDirectiveNames) { sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); } - sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; + sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective); } ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; /* @internal */ @@ -6489,7 +6631,7 @@ var ts; } for (var i = 0; i < names.length; i++) { var newResolution = newResolutions[i]; - var oldResolution = oldResolutions && oldResolutions[names[i]]; + var oldResolution = oldResolutions && oldResolutions.get(names[i]); var changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) : newResolution; @@ -6524,7 +6666,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 261 /* SourceFile */) { + while (node && node.kind !== 264 /* SourceFile */) { node = node.parent; } return node; @@ -6532,11 +6674,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 204 /* Block */: - case 232 /* CaseBlock */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 206 /* Block */: + case 234 /* CaseBlock */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: return true; } return false; @@ -6627,18 +6769,18 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 292 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 296 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 262 /* FirstJSDocNode */ && node.kind <= 288 /* LastJSDocNode */; + return node.kind >= 266 /* FirstJSDocNode */ && node.kind <= 295 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 278 /* FirstJSDocTagNode */ && node.kind <= 291 /* LastJSDocTagNode */; + return node.kind >= 282 /* FirstJSDocTagNode */ && node.kind <= 295 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -6704,18 +6846,52 @@ var ts; } ts.getLiteralText = getLiteralText; function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 /* NumericLiteral */ && text.length > 1) { + return node.kind === 8 /* NumericLiteral */ + && (getNumericLiteralFlags(text, /*hint*/ 6 /* BinaryOrOctal */) & 6 /* BinaryOrOctal */) !== 0; + } + ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + var NumericLiteralFlags; + (function (NumericLiteralFlags) { + NumericLiteralFlags[NumericLiteralFlags["None"] = 0] = "None"; + NumericLiteralFlags[NumericLiteralFlags["Hexadecimal"] = 1] = "Hexadecimal"; + NumericLiteralFlags[NumericLiteralFlags["Binary"] = 2] = "Binary"; + NumericLiteralFlags[NumericLiteralFlags["Octal"] = 4] = "Octal"; + NumericLiteralFlags[NumericLiteralFlags["Scientific"] = 8] = "Scientific"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctal"] = 6] = "BinaryOrOctal"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctalOrHexadecimal"] = 7] = "BinaryOrOctalOrHexadecimal"; + NumericLiteralFlags[NumericLiteralFlags["All"] = 15] = "All"; + })(NumericLiteralFlags = ts.NumericLiteralFlags || (ts.NumericLiteralFlags = {})); + /** + * Scans a numeric literal string to determine the form of the number. + * @param text Numeric literal text + * @param hint If `Scientific` or `All` is specified, performs a more expensive check to scan for scientific notation. + */ + function getNumericLiteralFlags(text, hint) { + if (text.length > 1) { switch (text.charCodeAt(1)) { case 98 /* b */: case 66 /* B */: + return 2 /* Binary */; case 111 /* o */: case 79 /* O */: - return true; + return 4 /* Octal */; + case 120 /* x */: + case 88 /* X */: + return 1 /* Hexadecimal */; + } + if (hint & 8 /* Scientific */) { + for (var i = text.length - 1; i >= 0; i--) { + switch (text.charCodeAt(i)) { + case 101 /* e */: + case 69 /* E */: + return 8 /* Scientific */; + } + } } } - return false; + return 0 /* None */; } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + ts.getNumericLiteralFlags = getNumericLiteralFlags; function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; } @@ -6724,11 +6900,6 @@ var ts; 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) { @@ -6742,11 +6913,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 223 /* VariableDeclaration */ && node.parent.kind === 256 /* CatchClause */; + return node.kind === 225 /* VariableDeclaration */ && node.parent.kind === 259 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 230 /* ModuleDeclaration */ && + return node && node.kind === 232 /* ModuleDeclaration */ && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -6757,11 +6928,11 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node.kind === 230 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 232 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 261 /* SourceFile */ || - node.kind === 230 /* ModuleDeclaration */ || + return node.kind === 264 /* SourceFile */ || + node.kind === 232 /* ModuleDeclaration */ || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6777,9 +6948,9 @@ var ts; return false; } switch (node.parent.kind) { - case 261 /* SourceFile */: + case 264 /* SourceFile */: return ts.isExternalModule(node.parent); - case 231 /* ModuleBlock */: + case 233 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6791,22 +6962,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 261 /* SourceFile */: - case 232 /* CaseBlock */: - case 256 /* CatchClause */: - case 230 /* ModuleDeclaration */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 150 /* Constructor */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 264 /* SourceFile */: + case 234 /* CaseBlock */: + case 259 /* CatchClause */: + case 232 /* ModuleDeclaration */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 151 /* Constructor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return true; - case 204 /* Block */: + case 206 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return parentNode && !isFunctionLike(parentNode); @@ -6840,7 +7011,7 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: if (isStringOrNumericLiteral(name.expression)) { return name.expression.text; } @@ -6851,10 +7022,10 @@ var ts; function entityNameToString(name) { switch (name.kind) { case 70 /* Identifier */: - return getFullWidth(name) === 0 ? unescapeIdentifier(name.text) : getTextOfNode(name); - case 141 /* QualifiedName */: + return getFullWidth(name) === 0 ? ts.unescapeIdentifier(name.text) : getTextOfNode(name); + case 142 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); } } @@ -6891,7 +7062,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 204 /* Block */) { + if (node.body && node.body.kind === 206 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6905,7 +7076,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 261 /* SourceFile */: + case 264 /* 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 @@ -6914,23 +7085,23 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 223 /* VariableDeclaration */: - case 174 /* BindingElement */: - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 229 /* EnumDeclaration */: - case 260 /* EnumMember */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 228 /* TypeAliasDeclaration */: + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 232 /* ModuleDeclaration */: + case 231 /* EnumDeclaration */: + case 263 /* EnumMember */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 230 /* TypeAliasDeclaration */: errorNode = node.name; break; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -6953,7 +7124,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 229 /* EnumDeclaration */ && isConst(node); + return node.kind === 231 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -6966,11 +7137,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 179 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; + return n.kind === 180 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 207 /* ExpressionStatement */ + return node.kind === 209 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -6983,10 +7154,10 @@ var ts; } ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 144 /* Parameter */ || - node.kind === 143 /* TypeParameter */ || - node.kind === 184 /* FunctionExpression */ || - node.kind === 185 /* ArrowFunction */) ? + var commentRanges = (node.kind === 145 /* Parameter */ || + node.kind === 144 /* TypeParameter */ || + node.kind === 185 /* FunctionExpression */ || + node.kind === 186 /* ArrowFunction */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); // True if the comment starts with '/**' but not if it is '/**/' @@ -7001,39 +7172,39 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (156 /* FirstTypeNode */ <= node.kind && node.kind <= 171 /* LastTypeNode */) { + if (157 /* FirstTypeNode */ <= node.kind && node.kind <= 172 /* LastTypeNode */) { return true; } switch (node.kind) { case 118 /* AnyKeyword */: case 132 /* NumberKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: - case 137 /* UndefinedKeyword */: + case 136 /* SymbolKeyword */: + case 138 /* UndefinedKeyword */: case 129 /* NeverKeyword */: return true; case 104 /* VoidKeyword */: - return node.parent.kind !== 188 /* VoidExpression */; - case 199 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 189 /* VoidExpression */; + case 200 /* 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 70 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 177 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 178 /* 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 === 70 /* Identifier */ || node.kind === 141 /* QualifiedName */ || node.kind === 177 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 141 /* QualifiedName */: - case 177 /* PropertyAccessExpression */: + ts.Debug.assert(node.kind === 70 /* Identifier */ || node.kind === 142 /* QualifiedName */ || node.kind === 178 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 142 /* QualifiedName */: + case 178 /* PropertyAccessExpression */: case 98 /* ThisKeyword */: - var parent_1 = node.parent; - if (parent_1.kind === 160 /* TypeQuery */) { + var parent = node.parent; + if (parent.kind === 161 /* TypeQuery */) { return false; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -7042,38 +7213,38 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (156 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 171 /* LastTypeNode */) { + if (157 /* FirstTypeNode */ <= parent.kind && parent.kind <= 172 /* LastTypeNode */) { return true; } - switch (parent_1.kind) { - case 199 /* ExpressionWithTypeArguments */: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 143 /* TypeParameter */: - return node === parent_1.constraint; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 144 /* Parameter */: - case 223 /* VariableDeclaration */: - return node === parent_1.type; - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 150 /* Constructor */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - return node === parent_1.type; - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - return node === parent_1.type; - case 182 /* TypeAssertionExpression */: - return node === parent_1.type; - case 179 /* CallExpression */: - case 180 /* NewExpression */: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 181 /* TaggedTemplateExpression */: + switch (parent.kind) { + case 200 /* ExpressionWithTypeArguments */: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); + case 144 /* TypeParameter */: + return node === parent.constraint; + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 145 /* Parameter */: + case 225 /* VariableDeclaration */: + return node === parent.type; + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 151 /* Constructor */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + return node === parent.type; + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + return node === parent.type; + case 183 /* TypeAssertionExpression */: + return node === parent.type; + case 180 /* CallExpression */: + case 181 /* NewExpression */: + return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; + case 182 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -7081,29 +7252,43 @@ var ts; return false; } ts.isPartOfTypeNode = isPartOfTypeNode; + function isChildOfNodeWithKind(node, kind) { + while (node) { + if (node.kind === kind) { + return true; + } + node = node.parent; + } + return false; + } + ts.isChildOfNodeWithKind = isChildOfNodeWithKind; + function isPrefixUnaryExpression(node) { + return node.kind === 191 /* PrefixUnaryExpression */; + } + ts.isPrefixUnaryExpression = isPrefixUnaryExpression; // 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 216 /* ReturnStatement */: + case 218 /* ReturnStatement */: return visitor(node); - case 232 /* CaseBlock */: - case 204 /* Block */: - case 208 /* IfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 217 /* WithStatement */: - case 218 /* SwitchStatement */: - case 253 /* CaseClause */: - case 254 /* DefaultClause */: - case 219 /* LabeledStatement */: - case 221 /* TryStatement */: - case 256 /* CatchClause */: + case 234 /* CaseBlock */: + case 206 /* Block */: + case 210 /* IfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 219 /* WithStatement */: + case 220 /* SwitchStatement */: + case 256 /* CaseClause */: + case 257 /* DefaultClause */: + case 221 /* LabeledStatement */: + case 223 /* TryStatement */: + case 259 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -7113,29 +7298,29 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 229 /* EnumDeclaration */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 231 /* EnumDeclaration */: + case 229 /* InterfaceDeclaration */: + case 232 /* ModuleDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* 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 === 142 /* ComputedPropertyName */) { + var name = node.name; + if (name && name.kind === 143 /* 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); + traverse(name.expression); return; } } @@ -7155,10 +7340,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 162 /* ArrayType */) { + if (node && node.kind === 163 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 157 /* TypeReference */) { + else if (node && node.kind === 158 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -7169,14 +7354,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 174 /* BindingElement */: - case 260 /* EnumMember */: - case 144 /* Parameter */: - case 257 /* PropertyAssignment */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 258 /* ShorthandPropertyAssignment */: - case 223 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 263 /* EnumMember */: + case 145 /* Parameter */: + case 260 /* PropertyAssignment */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 261 /* ShorthandPropertyAssignment */: + case 225 /* VariableDeclaration */: return true; } } @@ -7184,11 +7369,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 151 /* GetAccessor */ || node.kind === 152 /* SetAccessor */); + return node && (node.kind === 152 /* GetAccessor */ || node.kind === 153 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 226 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */); + return node && (node.kind === 228 /* ClassDeclaration */ || node.kind === 198 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7197,19 +7382,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 150 /* Constructor */: - case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 151 /* Constructor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return true; } return false; @@ -7217,13 +7402,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: return true; } return false; @@ -7231,30 +7416,42 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: return true; - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; + function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + while (true) { + if (beforeUnwrapLabelCallback) { + beforeUnwrapLabelCallback(node); + } + if (node.statement.kind !== 221 /* LabeledStatement */) { + return node.statement; + } + node = node.statement; + } + } + ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; function isFunctionBlock(node) { - return node && node.kind === 204 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 206 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 149 /* MethodDeclaration */ && node.parent.kind === 176 /* ObjectLiteralExpression */; + return node && node.kind === 150 /* MethodDeclaration */ && node.parent.kind === 177 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 149 /* MethodDeclaration */ && - (node.parent.kind === 176 /* ObjectLiteralExpression */ || - node.parent.kind === 197 /* ClassExpression */); + return node.kind === 150 /* MethodDeclaration */ && + (node.parent.kind === 177 /* ObjectLiteralExpression */ || + node.parent.kind === 198 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -7290,7 +7487,7 @@ var ts; return undefined; } switch (node.kind) { - case 142 /* ComputedPropertyName */: + case 143 /* 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 @@ -7305,9 +7502,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 145 /* Decorator */: + case 146 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 144 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 145 /* 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; @@ -7318,31 +7515,44 @@ var ts; node = node.parent; } break; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 230 /* ModuleDeclaration */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 229 /* EnumDeclaration */: - case 261 /* SourceFile */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 232 /* ModuleDeclaration */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 231 /* EnumDeclaration */: + case 264 /* SourceFile */: return node; } } } ts.getThisContainer = getThisContainer; + function getNewTargetContainer(node) { + var container = getThisContainer(node, /*includeArrowFunctions*/ false); + if (container) { + switch (container.kind) { + case 151 /* Constructor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + return container; + } + } + return undefined; + } + ts.getNewTargetContainer = getNewTargetContainer; /** * Given an super call/property node, returns the closest node where * - a super call/property access is legal in the node and not legal in the parent node the node. @@ -7358,26 +7568,26 @@ var ts; return node; } switch (node.kind) { - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: node = node.parent; break; - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: if (!stopOnFunctions) { continue; } - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return node; - case 145 /* Decorator */: + case 146 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 144 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 145 /* 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; @@ -7393,15 +7603,15 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 184 /* FunctionExpression */ || func.kind === 185 /* ArrowFunction */) { + if (func.kind === 185 /* FunctionExpression */ || func.kind === 186 /* ArrowFunction */) { var prev = func; - var parent_2 = func.parent; - while (parent_2.kind === 183 /* ParenthesizedExpression */) { - prev = parent_2; - parent_2 = parent_2.parent; + var parent = func.parent; + while (parent.kind === 184 /* ParenthesizedExpression */) { + prev = parent; + parent = parent.parent; } - if (parent_2.kind === 179 /* CallExpression */ && parent_2.expression === prev) { - return parent_2; + if (parent.kind === 180 /* CallExpression */ && parent.expression === prev) { + return parent; } } } @@ -7411,21 +7621,21 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 177 /* PropertyAccessExpression */ || kind === 178 /* ElementAccessExpression */) + return (kind === 178 /* PropertyAccessExpression */ || kind === 179 /* ElementAccessExpression */) && node.expression.kind === 96 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 157 /* TypeReference */: - case 272 /* JSDocTypeReference */: + case 158 /* TypeReference */: + case 276 /* JSDocTypeReference */: return node.typeName; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 70 /* Identifier */: - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: return node; } return undefined; @@ -7433,10 +7643,12 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 181 /* TaggedTemplateExpression */: - case 145 /* Decorator */: + case 250 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 182 /* TaggedTemplateExpression */: + case 146 /* Decorator */: return true; default: return false; @@ -7444,34 +7656,37 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 181 /* TaggedTemplateExpression */) { + if (node.kind === 182 /* TaggedTemplateExpression */) { return node.tag; } + else if (isJsxOpeningLikeElement(node)) { + return node.tagName; + } // Will either be a CallExpression, NewExpression, or Decorator. return node.expression; } ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: // classes are valid targets return true; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 226 /* ClassDeclaration */; - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 149 /* MethodDeclaration */: + return node.parent.kind === 228 /* ClassDeclaration */; + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 150 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && node.parent.kind === 226 /* ClassDeclaration */; - case 144 /* Parameter */: + && node.parent.kind === 228 /* ClassDeclaration */; + case 145 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return node.parent.body !== undefined - && (node.parent.kind === 150 /* Constructor */ - || node.parent.kind === 149 /* MethodDeclaration */ - || node.parent.kind === 152 /* SetAccessor */) - && node.parent.parent.kind === 226 /* ClassDeclaration */; + && (node.parent.kind === 151 /* Constructor */ + || node.parent.kind === 150 /* MethodDeclaration */ + || node.parent.kind === 153 /* SetAccessor */) + && node.parent.parent.kind === 228 /* ClassDeclaration */; } return false; } @@ -7487,19 +7702,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 149 /* MethodDeclaration */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 153 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 248 /* JsxOpeningElement */ || - parent.kind === 247 /* JsxSelfClosingElement */ || - parent.kind === 249 /* JsxClosingElement */) { + if (parent.kind === 250 /* JsxOpeningElement */ || + parent.kind === 249 /* JsxSelfClosingElement */ || + parent.kind === 251 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -7513,96 +7728,97 @@ var ts; case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: case 11 /* RegularExpressionLiteral */: - case 175 /* ArrayLiteralExpression */: - case 176 /* ObjectLiteralExpression */: - case 177 /* PropertyAccessExpression */: - case 178 /* ElementAccessExpression */: - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 181 /* TaggedTemplateExpression */: - case 200 /* AsExpression */: - case 182 /* TypeAssertionExpression */: - case 201 /* NonNullExpression */: - case 183 /* ParenthesizedExpression */: - case 184 /* FunctionExpression */: - case 197 /* ClassExpression */: - case 185 /* ArrowFunction */: - case 188 /* VoidExpression */: - case 186 /* DeleteExpression */: - case 187 /* TypeOfExpression */: - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: - case 192 /* BinaryExpression */: - case 193 /* ConditionalExpression */: - case 196 /* SpreadElement */: - case 194 /* TemplateExpression */: + case 176 /* ArrayLiteralExpression */: + case 177 /* ObjectLiteralExpression */: + case 178 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 182 /* TaggedTemplateExpression */: + case 201 /* AsExpression */: + case 183 /* TypeAssertionExpression */: + case 202 /* NonNullExpression */: + case 184 /* ParenthesizedExpression */: + case 185 /* FunctionExpression */: + case 198 /* ClassExpression */: + case 186 /* ArrowFunction */: + case 189 /* VoidExpression */: + case 187 /* DeleteExpression */: + case 188 /* TypeOfExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: + case 193 /* BinaryExpression */: + case 194 /* ConditionalExpression */: + case 197 /* SpreadElement */: + case 195 /* TemplateExpression */: case 12 /* NoSubstitutionTemplateLiteral */: - case 198 /* OmittedExpression */: - case 246 /* JsxElement */: - case 247 /* JsxSelfClosingElement */: - case 195 /* YieldExpression */: - case 189 /* AwaitExpression */: + case 199 /* OmittedExpression */: + case 248 /* JsxElement */: + case 249 /* JsxSelfClosingElement */: + case 196 /* YieldExpression */: + case 190 /* AwaitExpression */: + case 203 /* MetaProperty */: return true; - case 141 /* QualifiedName */: - while (node.parent.kind === 141 /* QualifiedName */) { + case 142 /* QualifiedName */: + while (node.parent.kind === 142 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 160 /* TypeQuery */ || isJSXTagName(node); + return node.parent.kind === 161 /* TypeQuery */ || isJSXTagName(node); case 70 /* Identifier */: - if (node.parent.kind === 160 /* TypeQuery */ || isJSXTagName(node)) { + if (node.parent.kind === 161 /* TypeQuery */ || isJSXTagName(node)) { return true; } // fall through case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 98 /* ThisKeyword */: - var parent_3 = node.parent; - switch (parent_3.kind) { - case 223 /* VariableDeclaration */: - case 144 /* Parameter */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 260 /* EnumMember */: - case 257 /* PropertyAssignment */: - case 174 /* BindingElement */: - return parent_3.initializer === node; - case 207 /* ExpressionStatement */: - case 208 /* IfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 216 /* ReturnStatement */: - case 217 /* WithStatement */: - case 218 /* SwitchStatement */: - case 253 /* CaseClause */: - case 220 /* ThrowStatement */: - case 218 /* SwitchStatement */: - return parent_3.expression === node; - case 211 /* ForStatement */: - var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 224 /* VariableDeclarationList */) || + var parent = node.parent; + switch (parent.kind) { + case 225 /* VariableDeclaration */: + case 145 /* Parameter */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 263 /* EnumMember */: + case 260 /* PropertyAssignment */: + case 175 /* BindingElement */: + return parent.initializer === node; + case 209 /* ExpressionStatement */: + case 210 /* IfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 218 /* ReturnStatement */: + case 219 /* WithStatement */: + case 220 /* SwitchStatement */: + case 256 /* CaseClause */: + case 222 /* ThrowStatement */: + case 220 /* SwitchStatement */: + return parent.expression === node; + case 213 /* ForStatement */: + var forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== 226 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224 /* VariableDeclarationList */) || + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + var forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 226 /* VariableDeclarationList */) || forInStatement.expression === node; - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: - return node === parent_3.expression; - case 202 /* TemplateSpan */: - return node === parent_3.expression; - case 142 /* ComputedPropertyName */: - return node === parent_3.expression; - case 145 /* Decorator */: - case 252 /* JsxExpression */: - case 251 /* JsxSpreadAttribute */: - case 259 /* SpreadAssignment */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: + return node === parent.expression; + case 204 /* TemplateSpan */: + return node === parent.expression; + case 143 /* ComputedPropertyName */: + return node === parent.expression; + case 146 /* Decorator */: + case 255 /* JsxExpression */: + case 254 /* JsxSpreadAttribute */: + case 262 /* SpreadAssignment */: return true; - case 199 /* ExpressionWithTypeArguments */: - return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); + case 200 /* ExpressionWithTypeArguments */: + return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: - if (isPartOfExpression(parent_3)) { + if (isPartOfExpression(parent)) { return true; } } @@ -7617,7 +7833,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 245 /* ExternalModuleReference */; + return node.kind === 236 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 247 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7626,7 +7842,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 245 /* ExternalModuleReference */; + return node.kind === 236 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 247 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7644,7 +7860,7 @@ var ts; */ function isRequireCall(expression, checkArgumentIsStringLiteral) { // of the form 'require("name")' - var isRequire = expression.kind === 179 /* CallExpression */ && + var isRequire = expression.kind === 180 /* CallExpression */ && expression.expression.kind === 70 /* Identifier */ && expression.expression.text === "require" && expression.arguments.length === 1; @@ -7660,9 +7876,9 @@ var ts; * This function does not test if the node is in a JavaScript file or not. */ function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 223 /* VariableDeclaration */) { + if (s.valueDeclaration && s.valueDeclaration.kind === 225 /* VariableDeclaration */) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 184 /* FunctionExpression */; + return declaration.initializer && declaration.initializer.kind === 185 /* FunctionExpression */; } return false; } @@ -7673,11 +7889,11 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0 /* None */; } - if (expression.kind !== 192 /* BinaryExpression */) { + if (expression.kind !== 193 /* BinaryExpression */) { return 0 /* None */; } var expr = expression; - if (expr.operatorToken.kind !== 57 /* EqualsToken */ || expr.left.kind !== 177 /* PropertyAccessExpression */) { + if (expr.operatorToken.kind !== 57 /* EqualsToken */ || expr.left.kind !== 178 /* PropertyAccessExpression */) { return 0 /* None */; } var lhs = expr.left; @@ -7695,7 +7911,7 @@ var ts; else if (lhs.expression.kind === 98 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (lhs.expression.kind === 177 /* PropertyAccessExpression */) { + else if (lhs.expression.kind === 178 /* PropertyAccessExpression */) { // chained dot, e.g. x.y.z = expr; this var is the 'x.y' part var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 70 /* Identifier */) { @@ -7713,35 +7929,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 235 /* ImportDeclaration */) { + if (node.kind === 237 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 236 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 245 /* ExternalModuleReference */) { + if (reference.kind === 247 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 241 /* ExportDeclaration */) { + if (node.kind === 243 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 230 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 232 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 236 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 239 /* NamespaceImport */) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 235 /* ImportDeclaration */ + return node.kind === 237 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } @@ -7749,13 +7965,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 144 /* Parameter */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 258 /* ShorthandPropertyAssignment */: - case 257 /* PropertyAssignment */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 145 /* Parameter */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 261 /* ShorthandPropertyAssignment */: + case 260 /* PropertyAssignment */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -7763,22 +7979,27 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 274 /* JSDocFunctionType */ && + return node.kind === 278 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 276 /* JSDocConstructorType */; + node.parameters[0].type.kind === 280 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { return ts.map(getJSDocs(node), function (doc) { return doc.comment; }); } ts.getCommentsFromJSDoc = getCommentsFromJSDoc; + function hasJSDocParameterTags(node) { + var parameterTags = getJSDocTags(node, 285 /* JSDocParameterTag */); + return parameterTags && parameterTags.length > 0; + } + ts.hasJSDocParameterTags = hasJSDocParameterTags; function getJSDocTags(node, kind) { var docs = getJSDocs(node); if (docs) { var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 281 /* JSDocParameterTag */) { + if (doc.kind === 285 /* JSDocParameterTag */) { if (doc.kind === kind) { result.push(doc); } @@ -7810,9 +8031,9 @@ var ts; // var x = function(name) { return name.length; } var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 205 /* VariableStatement */; + parent.parent.parent.kind === 207 /* VariableStatement */; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 205 /* VariableStatement */; + parent.parent.kind === 207 /* VariableStatement */; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -7821,20 +8042,20 @@ var ts; } // Also recognize when the node is the RHS of an assignment expression var isSourceOfAssignmentExpressionStatement = parent && parent.parent && - parent.kind === 192 /* BinaryExpression */ && + parent.kind === 193 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && - parent.parent.kind === 207 /* ExpressionStatement */; + parent.parent.kind === 209 /* ExpressionStatement */; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 230 /* ModuleDeclaration */ && - parent && parent.kind === 230 /* ModuleDeclaration */; - var isPropertyAssignmentExpression = parent && parent.kind === 257 /* PropertyAssignment */; + var isModuleDeclaration = node.kind === 232 /* ModuleDeclaration */ && + parent && parent.kind === 232 /* ModuleDeclaration */; + var isPropertyAssignmentExpression = parent && parent.kind === 260 /* PropertyAssignment */; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } // Pull parameter comments from declaring function as well - if (node.kind === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { cache = ts.concatenate(cache, getJSDocParameterTags(node)); } if (isVariableLike(node) && node.initializer) { @@ -7848,18 +8069,18 @@ var ts; return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 281 /* JSDocParameterTag */); + var tags = getJSDocTags(func, 285 /* JSDocParameterTag */); if (!param.name) { // this is an anonymous jsdoc param from a `function(type1, type2): type3` specification var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 281 /* JSDocParameterTag */; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 285 /* JSDocParameterTag */; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70 /* Identifier */) { - var name_6 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 281 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); + var name_1 = param.name.text; + return ts.filter(tags, function (tag) { return tag.kind === 285 /* JSDocParameterTag */ && tag.parameterName.text === name_1; }); } else { // TODO: it's a destructured parameter, so it should look up an "object type" series of multiple lines @@ -7869,8 +8090,8 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 283 /* JSDocTypeTag */); - if (!tag && node.kind === 144 /* Parameter */) { + var tag = getFirstJSDocTag(node, 287 /* JSDocTypeTag */); + if (!tag && node.kind === 145 /* Parameter */) { var paramTags = getJSDocParameterTags(node); if (paramTags) { tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); @@ -7880,15 +8101,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 280 /* JSDocAugmentsTag */); + return getFirstJSDocTag(node, 284 /* JSDocAugmentsTag */); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 282 /* JSDocReturnTag */); + return getFirstJSDocTag(node, 286 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 284 /* JSDocTemplateTag */); + return getFirstJSDocTag(node, 288 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -7901,8 +8122,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536 /* JavaScriptFile */)) { - if (node.type && node.type.kind === 275 /* JSDocVariadicType */ || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275 /* JSDocVariadicType */; })) { + if (node.type && node.type.kind === 279 /* JSDocVariadicType */ || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 279 /* JSDocVariadicType */; })) { return true; } } @@ -7923,29 +8144,33 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 57 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 42 /* PlusPlusToken */ || unaryOperator === 43 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 183 /* ParenthesizedExpression */: - case 175 /* ArrayLiteralExpression */: - case 196 /* SpreadElement */: + case 184 /* ParenthesizedExpression */: + case 176 /* ArrayLiteralExpression */: + case 197 /* SpreadElement */: node = parent; break; - case 258 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } - // Fall through - case 257 /* PropertyAssignment */: + node = parent.parent; + break; + case 260 /* PropertyAssignment */: + if (parent.name === node) { + return 0 /* None */; + } node = parent.parent; break; default: @@ -7957,11 +8182,24 @@ var ts; ts.getAssignmentTargetKind = getAssignmentTargetKind; // 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'. + // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ a }] = xxx'. + // (Note that `p` is not a target in the above examples, only `a`.) function isAssignmentTarget(node) { return getAssignmentTargetKind(node) !== 0 /* None */; } ts.isAssignmentTarget = isAssignmentTarget; + // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped + function isDeleteTarget(node) { + if (node.kind !== 178 /* PropertyAccessExpression */ && node.kind !== 179 /* ElementAccessExpression */) { + return false; + } + node = node.parent; + while (node && node.kind === 184 /* ParenthesizedExpression */) { + node = node.parent; + } + return node && node.kind === 187 /* DeleteExpression */; + } + ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { while (node) { if (node === ancestor) @@ -7973,7 +8211,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2 /* Ambient */) || (node.kind === 261 /* SourceFile */ && node.isDeclarationFile)) { + if (hasModifier(node, 2 /* Ambient */) || (node.kind === 264 /* SourceFile */ && node.isDeclarationFile)) { return true; } node = node.parent; @@ -7987,7 +8225,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 239 /* ImportSpecifier */ || parent.kind === 243 /* ExportSpecifier */) { + if (parent.kind === 241 /* ImportSpecifier */ || parent.kind === 245 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -8000,7 +8238,7 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 142 /* ComputedPropertyName */ && + node.parent.kind === 143 /* ComputedPropertyName */ && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -8008,31 +8246,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 260 /* EnumMember */: - case 257 /* PropertyAssignment */: - case 177 /* PropertyAccessExpression */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 263 /* EnumMember */: + case 260 /* PropertyAssignment */: + case 178 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 141 /* QualifiedName */) { + while (parent.kind === 142 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 160 /* TypeQuery */; + return parent.kind === 161 /* TypeQuery */; } return false; - case 174 /* BindingElement */: - case 239 /* ImportSpecifier */: + case 175 /* BindingElement */: + case 241 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 243 /* ExportSpecifier */: + case 245 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -8048,13 +8286,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */ || - node.kind === 233 /* NamespaceExportDeclaration */ || - node.kind === 236 /* ImportClause */ && !!node.name || - node.kind === 237 /* NamespaceImport */ || - node.kind === 239 /* ImportSpecifier */ || - node.kind === 243 /* ExportSpecifier */ || - node.kind === 240 /* ExportAssignment */ && exportAssignmentIsAlias(node); + return node.kind === 236 /* ImportEqualsDeclaration */ || + node.kind === 235 /* NamespaceExportDeclaration */ || + node.kind === 238 /* ImportClause */ && !!node.name || + node.kind === 239 /* NamespaceImport */ || + node.kind === 241 /* ImportSpecifier */ || + node.kind === 245 /* ExportSpecifier */ || + node.kind === 242 /* ExportAssignment */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8140,7 +8378,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 71 /* FirstKeyword */ <= token && token <= 140 /* LastKeyword */; + return 71 /* FirstKeyword */ <= token && token <= 141 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -8169,7 +8407,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 142 /* ComputedPropertyName */ && + return name.kind === 143 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -8184,10 +8422,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 144 /* Parameter */) { + if (name.kind === 70 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 145 /* Parameter */) { return name.text; } - if (name.kind === 142 /* ComputedPropertyName */) { + if (name.kind === 143 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -8235,11 +8473,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 144 /* Parameter */; + return root.kind === 145 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 174 /* BindingElement */) { + while (node.kind === 175 /* BindingElement */) { node = node.parent.parent; } return node; @@ -8247,15 +8485,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 150 /* Constructor */ - || kind === 184 /* FunctionExpression */ - || kind === 225 /* FunctionDeclaration */ - || kind === 185 /* ArrowFunction */ - || kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */ - || kind === 230 /* ModuleDeclaration */ - || kind === 261 /* SourceFile */; + return kind === 151 /* Constructor */ + || kind === 185 /* FunctionExpression */ + || kind === 227 /* FunctionDeclaration */ + || kind === 186 /* ArrowFunction */ + || kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */ + || kind === 232 /* ModuleDeclaration */ + || kind === 264 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -8263,49 +8501,22 @@ var ts; || ts.positionIsSynthesized(node.end); } ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node, nodeTest) { - if (node) { - while (node.original !== undefined) { - node = node.original; - } + function getOriginalSourceFileOrBundle(sourceFileOrBundle) { + if (sourceFileOrBundle.kind === 265 /* Bundle */) { + return ts.updateBundle(sourceFileOrBundle, ts.sameMap(sourceFileOrBundle.sourceFiles, getOriginalSourceFile)); } - return !nodeTest || nodeTest(node) ? node : undefined; + return getOriginalSourceFile(sourceFileOrBundle); } - ts.getOriginalNode = getOriginalNode; - /** - * Gets a value indicating whether a node originated in the parse tree. - * - * @param node The node to test. - */ - function isParseTreeNode(node) { - return (node.flags & 8 /* Synthesized */) === 0; + ts.getOriginalSourceFileOrBundle = getOriginalSourceFileOrBundle; + function getOriginalSourceFile(sourceFile) { + return ts.getParseTreeNode(sourceFile, isSourceFile) || sourceFile; } - ts.isParseTreeNode = isParseTreeNode; - function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { - return node; - } - node = getOriginalNode(node); - if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { - return node; - } - return undefined; - } - ts.getParseTreeNode = getParseTreeNode; function getOriginalSourceFiles(sourceFiles) { - var originalSourceFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); - if (originalSourceFile) { - originalSourceFiles.push(originalSourceFile); - } - } - return originalSourceFiles; + return ts.sameMap(sourceFiles, getOriginalSourceFile); } ts.getOriginalSourceFiles = getOriginalSourceFiles; function getOriginalNodeId(node) { - node = getOriginalNode(node); + node = ts.getOriginalNode(node); return node ? ts.getNodeId(node) : 0; } ts.getOriginalNodeId = getOriginalNodeId; @@ -8316,23 +8527,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 180 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 181 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 180 /* NewExpression */: + case 181 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 190 /* PrefixUnaryExpression */: - case 187 /* TypeOfExpression */: - case 188 /* VoidExpression */: - case 186 /* DeleteExpression */: - case 189 /* AwaitExpression */: - case 193 /* ConditionalExpression */: - case 195 /* YieldExpression */: + case 191 /* PrefixUnaryExpression */: + case 188 /* TypeOfExpression */: + case 189 /* VoidExpression */: + case 187 /* DeleteExpression */: + case 190 /* AwaitExpression */: + case 194 /* ConditionalExpression */: + case 196 /* YieldExpression */: return 1 /* Right */; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (operator) { case 39 /* AsteriskAsteriskToken */: case 57 /* EqualsToken */: @@ -8356,15 +8567,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 180 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 181 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 192 /* BinaryExpression */) { + if (expression.kind === 193 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 190 /* PrefixUnaryExpression */ || expression.kind === 191 /* PostfixUnaryExpression */) { + else if (expression.kind === 191 /* PrefixUnaryExpression */ || expression.kind === 192 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -8382,37 +8593,36 @@ var ts; case 85 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 175 /* ArrayLiteralExpression */: - case 176 /* ObjectLiteralExpression */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 197 /* ClassExpression */: - case 246 /* JsxElement */: - case 247 /* JsxSelfClosingElement */: + case 176 /* ArrayLiteralExpression */: + case 177 /* ObjectLiteralExpression */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 198 /* ClassExpression */: + case 248 /* JsxElement */: + case 249 /* JsxSelfClosingElement */: case 11 /* RegularExpressionLiteral */: case 12 /* NoSubstitutionTemplateLiteral */: - case 194 /* TemplateExpression */: - case 183 /* ParenthesizedExpression */: - case 198 /* OmittedExpression */: - case 297 /* RawExpression */: + case 195 /* TemplateExpression */: + case 184 /* ParenthesizedExpression */: + case 199 /* OmittedExpression */: return 19; - case 181 /* TaggedTemplateExpression */: - case 177 /* PropertyAccessExpression */: - case 178 /* ElementAccessExpression */: + case 182 /* TaggedTemplateExpression */: + case 178 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: return 18; - case 180 /* NewExpression */: + case 181 /* NewExpression */: return hasArguments ? 18 : 17; - case 179 /* CallExpression */: + case 180 /* CallExpression */: return 17; - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return 16; - case 190 /* PrefixUnaryExpression */: - case 187 /* TypeOfExpression */: - case 188 /* VoidExpression */: - case 186 /* DeleteExpression */: - case 189 /* AwaitExpression */: + case 191 /* PrefixUnaryExpression */: + case 188 /* TypeOfExpression */: + case 189 /* VoidExpression */: + case 187 /* DeleteExpression */: + case 190 /* AwaitExpression */: return 15; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (operatorKind) { case 50 /* ExclamationToken */: case 51 /* TildeToken */: @@ -8470,11 +8680,11 @@ var ts; default: return -1; } - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return 4; - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return 2; - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return 1; default: return -1; @@ -8497,21 +8707,15 @@ var ts; 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; - } + ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); } function add(diagnostic) { var diagnostics; if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); if (!diagnostics) { diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; + fileDiagnostics.set(diagnostic.file.fileName, diagnostics); } } else { @@ -8528,16 +8732,16 @@ var ts; function getDiagnostics(fileName) { sortAndDeduplicate(); if (fileName) { - return fileDiagnostics[fileName] || []; + return fileDiagnostics.get(fileName) || []; } var allDiagnostics = []; function pushDiagnostic(d) { allDiagnostics.push(d); } ts.forEach(nonFileDiagnostics, pushDiagnostic); - for (var key in fileDiagnostics) { - ts.forEach(fileDiagnostics[key], pushDiagnostic); - } + fileDiagnostics.forEach(function (diagnostics) { + ts.forEach(diagnostics, pushDiagnostic); + }); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function sortAndDeduplicate() { @@ -8546,9 +8750,9 @@ var ts; } diagnosticsModified = false; nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (var key in fileDiagnostics) { - fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } + fileDiagnostics.forEach(function (diagnostics, key) { + fileDiagnostics.set(key, ts.sortAndDeduplicateDiagnostics(diagnostics)); + }); } } ts.createDiagnosticCollection = createDiagnosticCollection; @@ -8558,7 +8762,7 @@ var ts; // 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 = ts.createMap({ + var escapedCharsMap = ts.createMapFromTemplate({ "\0": "\\0", "\t": "\\t", "\v": "\\v", @@ -8578,13 +8782,12 @@ var ts; * 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)); - } + return s.replace(escapedCharsRegExp, getReplacement); } ts.escapeString = escapeString; + function getReplacement(c) { + return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } function isIntrinsicJsxName(name) { var ch = name.substr(0, 1); return ch.toLowerCase() === ch; @@ -8741,168 +8944,77 @@ var ts; */ function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); + var isSourceFileFromExternalLibrary = function (file) { return host.isSourceFileFromExternalLibrary(file); }; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); - var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = getAllEmittableSourceFiles(); + var moduleEmitEnabled_1 = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified - return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); + return ts.filter(host.getSourceFiles(), function (sourceFile) { + return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); + }); } else { - var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; - return filterSourceFilesInDirectory(sourceFiles, function (file) { return host.isSourceFileFromExternalLibrary(file); }); - } - function getAllEmittableSourceFiles() { - return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); + var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary); }); } } ts.getSourceFilesToEmit = getSourceFilesToEmit; - /** Don't call this for `--outFile`, just for `--outDir` or plain emit. */ - function filterSourceFilesInDirectory(sourceFiles, isSourceFileFromExternalLibrary) { - return ts.filter(sourceFiles, function (file) { return shouldEmitInDirectory(file, isSourceFileFromExternalLibrary); }); - } - ts.filterSourceFilesInDirectory = filterSourceFilesInDirectory; - function isNonDeclarationFile(sourceFile) { - return !isDeclarationFile(sourceFile); + /** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */ + function sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary) { + return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !isDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); } + ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; /** - * Whether a file should be emitted in a non-`--outFile` case. - * Don't emit if source file is a declaration file, or was located under node_modules - */ - function shouldEmitInDirectory(sourceFile, isSourceFileFromExternalLibrary) { - return isNonDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); - } - function isBundleEmitNonExternalModule(sourceFile) { - return isNonDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); - } - /** - * Iterates over each source file to emit. The source files are expected to have been - * transformed for use by the pretty printer. - * - * Originally part of `forEachExpectedEmitFile`, this functionality was extracted to support - * transformations. + * Iterates over the source files that are expected to have an emit output. * * @param host An EmitHost. - * @param sourceFiles The transformed source files to emit. * @param action The action to execute. + * @param sourceFilesOrTargetSourceFile + * If an array, the full list of source files to emit. + * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); - // Emit on each source file if (options.outFile || options.out) { - onBundledEmit(sourceFiles); - } - else { - for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { - var sourceFile = sourceFiles_2[_i]; - // Don't emit if source file is a declaration file, or was located under node_modules - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } - } - } - function onSingleFileEmit(host, sourceFile) { - // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. - // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. - // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve - var extension = ".js"; - if (options.jsx === 1 /* Preserve */) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1 /* JSX */) { - // TypeScript source file preserving JSX syntax - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], /*isBundledEmit*/ false); - } - function onBundledEmit(sourceFiles) { if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, /*isBundledEmit*/ true); + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, ts.createBundle(sourceFiles), emitOnlyDtsFiles); + } + } + else { + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, sourceFile, emitOnlyDtsFiles); } } } - ts.forEachTransformedEmitFile = forEachTransformedEmitFile; + ts.forEachEmittedFile = forEachEmittedFile; function getSourceMapFilePath(jsFilePath, options) { return options.sourceMap ? jsFilePath + ".map" : undefined; } - /** - * Iterates over the source files that are expected to have an emit output. This function - * is used by the legacy emitter and the declaration emitter and should not be used by - * the tree transforming emitter. - * - * @param host An EmitHost. - * @param action The action to execute. - * @param targetSourceFile An optional target source file to emit. - */ - function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - // Emit on each source file - if (options.outFile || options.out) { - onBundledEmit(host); - } - else { - var sourceFiles = targetSourceFile === undefined ? getSourceFilesToEmit(host) : [targetSourceFile]; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; - if (shouldEmitInDirectory(sourceFile, function (file) { return host.isSourceFileFromExternalLibrary(file); })) { - onSingleFileEmit(host, sourceFile); + // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. + // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. + // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve + function getOutputExtension(sourceFile, options) { + if (options.jsx === 1 /* Preserve */) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + return ".jsx"; } } - } - function onSingleFileEmit(host, sourceFile) { - // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. - // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. - // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve - var extension = ".js"; - if (options.jsx === 1 /* Preserve */) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1 /* JSX */) { - // TypeScript source file preserving JSX syntax - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: declarationFilePath - }; - action(emitFileNames, [sourceFile], /*isBundledEmit*/ false, emitOnlyDtsFiles); - } - function onBundledEmit(host) { - // Can emit only sources that are not declaration file and are either non module code or module with - // --module or --target es6 specified. Files included by searching under node_modules are also not emitted. - var bundledSources = ts.filter(getSourceFilesToEmit(host), function (sourceFile) { return !isDeclarationFile(sourceFile) && - !host.isSourceFileFromExternalLibrary(sourceFile) && - (!ts.isExternalModule(sourceFile) || - !!ts.getEmitModuleKind(options)); }); - if (bundledSources.length) { - var jsFilePath = options.outFile || options.out; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined - }; - action(emitFileNames, bundledSources, /*isBundledEmit*/ true, emitOnlyDtsFiles); + else if (sourceFile.languageVariant === 1 /* JSX */) { + // TypeScript source file preserving JSX syntax + return ".jsx"; } } + return ".js"; } - ts.forEachExpectedEmitFile = forEachExpectedEmitFile; function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); var commonSourceDirectory = host.getCommonSourceDirectory(); @@ -8927,7 +9039,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 150 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 151 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -8969,10 +9081,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 151 /* GetAccessor */) { + if (accessor.kind === 152 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 152 /* SetAccessor */) { + else if (accessor.kind === 153 /* SetAccessor */) { setAccessor = accessor; } else { @@ -8981,7 +9093,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 151 /* GetAccessor */ || member.kind === 152 /* SetAccessor */) + if ((member.kind === 152 /* GetAccessor */ || member.kind === 153 /* SetAccessor */) && hasModifier(member, 32 /* Static */) === hasModifier(accessor, 32 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -8992,10 +9104,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 151 /* GetAccessor */ && !getAccessor) { + if (member.kind === 152 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 152 /* SetAccessor */ && !setAccessor) { + if (member.kind === 153 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -9258,7 +9370,7 @@ var ts; ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 199 /* ExpressionWithTypeArguments */ && + if (node.kind === 200 /* ExpressionWithTypeArguments */ && node.parent.token === 84 /* ExtendsKeyword */ && isClassLike(node.parent.parent)) { return node.parent.parent; @@ -9276,8 +9388,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 176 /* ObjectLiteralExpression */ - || kind === 175 /* ArrayLiteralExpression */; + return kind === 177 /* ObjectLiteralExpression */ + || kind === 176 /* ArrayLiteralExpression */; } return false; } @@ -9305,29 +9417,33 @@ var ts; ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { return node.kind === 70 /* Identifier */ || - node.kind === 177 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); + node.kind === 178 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 177 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 176 /* ObjectLiteralExpression */) { + if (kind === 177 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 175 /* ArrayLiteralExpression */) { + if (kind === 176 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; } ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; + return isExportDefaultSymbol(symbol) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function isExportDefaultSymbol(symbol) { + return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512 /* Default */); + } + ts.isExportDefaultSymbol = isExportDefaultSymbol; /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTypeScriptExtension(fileName) { return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); @@ -9439,39 +9555,39 @@ var ts; || kind === 94 /* NullKeyword */) { return true; } - else if (kind === 177 /* PropertyAccessExpression */) { + else if (kind === 178 /* PropertyAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 178 /* ElementAccessExpression */) { + else if (kind === 179 /* ElementAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 190 /* PrefixUnaryExpression */ - || kind === 191 /* PostfixUnaryExpression */) { + else if (kind === 191 /* PrefixUnaryExpression */ + || kind === 192 /* PostfixUnaryExpression */) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 192 /* BinaryExpression */) { + else if (kind === 193 /* BinaryExpression */) { return node.operatorToken.kind !== 39 /* AsteriskAsteriskToken */ && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 193 /* ConditionalExpression */) { + else if (kind === 194 /* ConditionalExpression */) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 188 /* VoidExpression */ - || kind === 187 /* TypeOfExpression */ - || kind === 186 /* DeleteExpression */) { + else if (kind === 189 /* VoidExpression */ + || kind === 188 /* TypeOfExpression */ + || kind === 187 /* DeleteExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 175 /* ArrayLiteralExpression */) { + else if (kind === 176 /* ArrayLiteralExpression */) { return node.elements.length === 0; } - else if (kind === 176 /* ObjectLiteralExpression */) { + else if (kind === 177 /* ObjectLiteralExpression */) { return node.properties.length === 0; } - else if (kind === 179 /* CallExpression */) { + else if (kind === 180 /* CallExpression */) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9486,16 +9602,19 @@ var ts; } return false; } - var syntaxKindCache = ts.createMap(); + var syntaxKindCache = []; function formatSyntaxKind(kind) { var syntaxKindEnum = ts.SyntaxKind; if (syntaxKindEnum) { - if (syntaxKindCache[kind]) { - return syntaxKindCache[kind]; + var cached = syntaxKindCache[kind]; + if (cached !== undefined) { + return cached; } - for (var name_7 in syntaxKindEnum) { - if (syntaxKindEnum[name_7] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_7 + ")"; + for (var name in syntaxKindEnum) { + if (syntaxKindEnum[name] === kind) { + var result = kind + " (" + name + ")"; + syntaxKindCache[kind] = result; + return result; } } } @@ -9504,6 +9623,14 @@ var ts; } } ts.formatSyntaxKind = formatSyntaxKind; + function getRangePos(range) { + return range ? range.pos : -1; + } + ts.getRangePos = getRangePos; + function getRangeEnd(range) { + return range ? range.end : -1; + } + ts.getRangeEnd = getRangeEnd; /** * Increases (or decreases) a position by the provided amount. * @@ -9635,11 +9762,11 @@ var ts; * declaration. */ function isDeclarationNameOfEnumOrNamespace(node) { - var parseNode = getParseTreeNode(node); + var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: + case 231 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -9660,7 +9787,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 226 /* ClassDeclaration */ && declaration !== node) { + if (declaration.kind === 228 /* ClassDeclaration */ && declaration !== node) { return true; } } @@ -9725,6 +9852,10 @@ var ts; return node.kind === 70 /* Identifier */; } ts.isIdentifier = isIdentifier; + function isVoidExpression(node) { + return node.kind === 189 /* VoidExpression */; + } + ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { // Using `>` here catches both `GeneratedIdentifierKind.None` and `undefined`. return isIdentifier(node) && node.autoGenerateKind > 0 /* None */; @@ -9737,16 +9868,16 @@ var ts; ts.isModifier = isModifier; // Names function isQualifiedName(node) { - return node.kind === 141 /* QualifiedName */; + return node.kind === 142 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 142 /* ComputedPropertyName */; + return node.kind === 143 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 141 /* QualifiedName */ + return kind === 142 /* QualifiedName */ || kind === 70 /* Identifier */; } ts.isEntityName = isEntityName; @@ -9755,7 +9886,7 @@ var ts; return kind === 70 /* Identifier */ || kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 142 /* ComputedPropertyName */; + || kind === 143 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isModuleName(node) { @@ -9767,61 +9898,61 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 70 /* Identifier */ - || kind === 172 /* ObjectBindingPattern */ - || kind === 173 /* ArrayBindingPattern */; + || kind === 173 /* ObjectBindingPattern */ + || kind === 174 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Signature elements function isTypeParameter(node) { - return node.kind === 143 /* TypeParameter */; + return node.kind === 144 /* TypeParameter */; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 144 /* Parameter */; + return node.kind === 145 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 145 /* Decorator */; + return node.kind === 146 /* Decorator */; } ts.isDecorator = isDecorator; // Type members function isMethodDeclaration(node) { - return node.kind === 149 /* MethodDeclaration */; + return node.kind === 150 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 150 /* Constructor */ - || kind === 147 /* PropertyDeclaration */ - || kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */ - || kind === 155 /* IndexSignature */ - || kind === 203 /* SemicolonClassElement */; + return kind === 151 /* Constructor */ + || kind === 148 /* PropertyDeclaration */ + || kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */ + || kind === 156 /* IndexSignature */ + || kind === 205 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 257 /* PropertyAssignment */ - || kind === 258 /* ShorthandPropertyAssignment */ - || kind === 259 /* SpreadAssignment */ - || kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */ - || kind === 244 /* MissingDeclaration */; + return kind === 260 /* PropertyAssignment */ + || kind === 261 /* ShorthandPropertyAssignment */ + || kind === 262 /* SpreadAssignment */ + || kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */ + || kind === 246 /* MissingDeclaration */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 156 /* FirstTypeNode */ && kind <= 171 /* LastTypeNode */) + return (kind >= 157 /* FirstTypeNode */ && kind <= 172 /* LastTypeNode */) || kind === 118 /* AnyKeyword */ || kind === 132 /* NumberKeyword */ || kind === 121 /* BooleanKeyword */ - || kind === 134 /* StringKeyword */ - || kind === 135 /* SymbolKeyword */ + || kind === 135 /* StringKeyword */ + || kind === 136 /* SymbolKeyword */ || kind === 104 /* VoidKeyword */ || kind === 129 /* NeverKeyword */ - || kind === 199 /* ExpressionWithTypeArguments */; + || kind === 200 /* ExpressionWithTypeArguments */; } /** * Node test that determines whether a node is a valid type node. @@ -9834,36 +9965,36 @@ var ts; ts.isTypeNode = isTypeNode; // Binding patterns function isArrayBindingPattern(node) { - return node.kind === 173 /* ArrayBindingPattern */; + return node.kind === 174 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isObjectBindingPattern(node) { - return node.kind === 172 /* ObjectBindingPattern */; + return node.kind === 173 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 173 /* ArrayBindingPattern */ - || kind === 172 /* ObjectBindingPattern */; + return kind === 174 /* ArrayBindingPattern */ + || kind === 173 /* ObjectBindingPattern */; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 175 /* ArrayLiteralExpression */ - || kind === 176 /* ObjectLiteralExpression */; + return kind === 176 /* ArrayLiteralExpression */ + || kind === 177 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; function isBindingElement(node) { - return node.kind === 174 /* BindingElement */; + return node.kind === 175 /* BindingElement */; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 174 /* BindingElement */ - || kind === 198 /* OmittedExpression */; + return kind === 175 /* BindingElement */ + || kind === 199 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -9871,9 +10002,9 @@ var ts; */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 223 /* VariableDeclaration */: - case 144 /* Parameter */: - case 174 /* BindingElement */: + case 225 /* VariableDeclaration */: + case 145 /* Parameter */: + case 175 /* BindingElement */: return true; } return false; @@ -9892,8 +10023,8 @@ var ts; */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 172 /* ObjectBindingPattern */: - case 176 /* ObjectLiteralExpression */: + case 173 /* ObjectBindingPattern */: + case 177 /* ObjectLiteralExpression */: return true; } return false; @@ -9904,8 +10035,8 @@ var ts; */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 173 /* ArrayBindingPattern */: - case 175 /* ArrayLiteralExpression */: + case 174 /* ArrayBindingPattern */: + case 176 /* ArrayLiteralExpression */: return true; } return false; @@ -9913,86 +10044,86 @@ var ts; ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; // Expression function isArrayLiteralExpression(node) { - return node.kind === 175 /* ArrayLiteralExpression */; + return node.kind === 176 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 176 /* ObjectLiteralExpression */; + return node.kind === 177 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 177 /* PropertyAccessExpression */; + return node.kind === 178 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 178 /* ElementAccessExpression */; + return node.kind === 179 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 192 /* BinaryExpression */; + return node.kind === 193 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 193 /* ConditionalExpression */; + return node.kind === 194 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 179 /* CallExpression */; + return node.kind === 180 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 194 /* TemplateExpression */ + return kind === 195 /* TemplateExpression */ || kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadExpression(node) { - return node.kind === 196 /* SpreadElement */; + return node.kind === 197 /* SpreadElement */; } ts.isSpreadExpression = isSpreadExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 199 /* ExpressionWithTypeArguments */; + return node.kind === 200 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 177 /* PropertyAccessExpression */ - || kind === 178 /* ElementAccessExpression */ - || kind === 180 /* NewExpression */ - || kind === 179 /* CallExpression */ - || kind === 246 /* JsxElement */ - || kind === 247 /* JsxSelfClosingElement */ - || kind === 181 /* TaggedTemplateExpression */ - || kind === 175 /* ArrayLiteralExpression */ - || kind === 183 /* ParenthesizedExpression */ - || kind === 176 /* ObjectLiteralExpression */ - || kind === 197 /* ClassExpression */ - || kind === 184 /* FunctionExpression */ + return kind === 178 /* PropertyAccessExpression */ + || kind === 179 /* ElementAccessExpression */ + || kind === 181 /* NewExpression */ + || kind === 180 /* CallExpression */ + || kind === 248 /* JsxElement */ + || kind === 249 /* JsxSelfClosingElement */ + || kind === 182 /* TaggedTemplateExpression */ + || kind === 176 /* ArrayLiteralExpression */ + || kind === 184 /* ParenthesizedExpression */ + || kind === 177 /* ObjectLiteralExpression */ + || kind === 198 /* ClassExpression */ + || kind === 185 /* FunctionExpression */ || kind === 70 /* Identifier */ || kind === 11 /* RegularExpressionLiteral */ || kind === 8 /* NumericLiteral */ || kind === 9 /* StringLiteral */ || kind === 12 /* NoSubstitutionTemplateLiteral */ - || kind === 194 /* TemplateExpression */ + || kind === 195 /* TemplateExpression */ || kind === 85 /* FalseKeyword */ || kind === 94 /* NullKeyword */ || kind === 98 /* ThisKeyword */ || kind === 100 /* TrueKeyword */ || kind === 96 /* SuperKeyword */ - || kind === 201 /* NonNullExpression */ - || kind === 297 /* RawExpression */; + || kind === 202 /* NonNullExpression */ + || kind === 203 /* MetaProperty */; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 190 /* PrefixUnaryExpression */ - || kind === 191 /* PostfixUnaryExpression */ - || kind === 186 /* DeleteExpression */ - || kind === 187 /* TypeOfExpression */ - || kind === 188 /* VoidExpression */ - || kind === 189 /* AwaitExpression */ - || kind === 182 /* TypeAssertionExpression */ + return kind === 191 /* PrefixUnaryExpression */ + || kind === 192 /* PostfixUnaryExpression */ + || kind === 187 /* DeleteExpression */ + || kind === 188 /* TypeOfExpression */ + || kind === 189 /* VoidExpression */ + || kind === 190 /* AwaitExpression */ + || kind === 183 /* TypeAssertionExpression */ || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -10000,14 +10131,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 193 /* ConditionalExpression */ - || kind === 195 /* YieldExpression */ - || kind === 185 /* ArrowFunction */ - || kind === 192 /* BinaryExpression */ - || kind === 196 /* SpreadElement */ - || kind === 200 /* AsExpression */ - || kind === 198 /* OmittedExpression */ - || kind === 297 /* RawExpression */ + return kind === 194 /* ConditionalExpression */ + || kind === 196 /* YieldExpression */ + || kind === 186 /* ArrowFunction */ + || kind === 193 /* BinaryExpression */ + || kind === 197 /* SpreadElement */ + || kind === 201 /* AsExpression */ + || kind === 199 /* OmittedExpression */ || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -10016,16 +10146,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 182 /* TypeAssertionExpression */ - || kind === 200 /* AsExpression */; + return kind === 183 /* TypeAssertionExpression */ + || kind === 201 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 294 /* PartiallyEmittedExpression */; + return node.kind === 298 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 293 /* NotEmittedStatement */; + return node.kind === 297 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10034,17 +10164,17 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 198 /* OmittedExpression */; + return node.kind === 199 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; // Misc function isTemplateSpan(node) { - return node.kind === 202 /* TemplateSpan */; + return node.kind === 204 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; // Element function isBlock(node) { - return node.kind === 204 /* Block */; + return node.kind === 206 /* Block */; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -10062,121 +10192,135 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 223 /* VariableDeclaration */; + return node.kind === 225 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 224 /* VariableDeclarationList */; + return node.kind === 226 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 232 /* CaseBlock */; + return node.kind === 234 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 231 /* ModuleBlock */ - || kind === 230 /* ModuleDeclaration */; + return kind === 233 /* ModuleBlock */ + || kind === 232 /* ModuleDeclaration */ + || kind === 70 /* Identifier */; } ts.isModuleBody = isModuleBody; + function isNamespaceBody(node) { + var kind = node.kind; + return kind === 233 /* ModuleBlock */ + || kind === 232 /* ModuleDeclaration */; + } + ts.isNamespaceBody = isNamespaceBody; + function isJSDocNamespaceBody(node) { + var kind = node.kind; + return kind === 70 /* Identifier */ + || kind === 232 /* ModuleDeclaration */; + } + ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isImportEqualsDeclaration(node) { - return node.kind === 234 /* ImportEqualsDeclaration */; + return node.kind === 236 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 236 /* ImportClause */; + return node.kind === 238 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 238 /* NamedImports */ - || kind === 237 /* NamespaceImport */; + return kind === 240 /* NamedImports */ + || kind === 239 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 239 /* ImportSpecifier */; + return node.kind === 241 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 242 /* NamedExports */; + return node.kind === 244 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 243 /* ExportSpecifier */; + return node.kind === 245 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 230 /* ModuleDeclaration */ || node.kind === 229 /* EnumDeclaration */; + return node.kind === 232 /* ModuleDeclaration */ || node.kind === 231 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 185 /* ArrowFunction */ - || kind === 174 /* BindingElement */ - || kind === 226 /* ClassDeclaration */ - || kind === 197 /* ClassExpression */ - || kind === 150 /* Constructor */ - || kind === 229 /* EnumDeclaration */ - || kind === 260 /* EnumMember */ - || kind === 243 /* ExportSpecifier */ - || kind === 225 /* FunctionDeclaration */ - || kind === 184 /* FunctionExpression */ - || kind === 151 /* GetAccessor */ - || kind === 236 /* ImportClause */ - || kind === 234 /* ImportEqualsDeclaration */ - || kind === 239 /* ImportSpecifier */ - || kind === 227 /* InterfaceDeclaration */ - || kind === 149 /* MethodDeclaration */ - || kind === 148 /* MethodSignature */ - || kind === 230 /* ModuleDeclaration */ - || kind === 233 /* NamespaceExportDeclaration */ - || kind === 237 /* NamespaceImport */ - || kind === 144 /* Parameter */ - || kind === 257 /* PropertyAssignment */ - || kind === 147 /* PropertyDeclaration */ - || kind === 146 /* PropertySignature */ - || kind === 152 /* SetAccessor */ - || kind === 258 /* ShorthandPropertyAssignment */ - || kind === 228 /* TypeAliasDeclaration */ - || kind === 143 /* TypeParameter */ - || kind === 223 /* VariableDeclaration */ - || kind === 285 /* JSDocTypedefTag */; + return kind === 186 /* ArrowFunction */ + || kind === 175 /* BindingElement */ + || kind === 228 /* ClassDeclaration */ + || kind === 198 /* ClassExpression */ + || kind === 151 /* Constructor */ + || kind === 231 /* EnumDeclaration */ + || kind === 263 /* EnumMember */ + || kind === 245 /* ExportSpecifier */ + || kind === 227 /* FunctionDeclaration */ + || kind === 185 /* FunctionExpression */ + || kind === 152 /* GetAccessor */ + || kind === 238 /* ImportClause */ + || kind === 236 /* ImportEqualsDeclaration */ + || kind === 241 /* ImportSpecifier */ + || kind === 229 /* InterfaceDeclaration */ + || kind === 252 /* JsxAttribute */ + || kind === 150 /* MethodDeclaration */ + || kind === 149 /* MethodSignature */ + || kind === 232 /* ModuleDeclaration */ + || kind === 235 /* NamespaceExportDeclaration */ + || kind === 239 /* NamespaceImport */ + || kind === 145 /* Parameter */ + || kind === 260 /* PropertyAssignment */ + || kind === 148 /* PropertyDeclaration */ + || kind === 147 /* PropertySignature */ + || kind === 153 /* SetAccessor */ + || kind === 261 /* ShorthandPropertyAssignment */ + || kind === 230 /* TypeAliasDeclaration */ + || kind === 144 /* TypeParameter */ + || kind === 225 /* VariableDeclaration */ + || kind === 289 /* JSDocTypedefTag */; } function isDeclarationStatementKind(kind) { - return kind === 225 /* FunctionDeclaration */ - || kind === 244 /* MissingDeclaration */ - || kind === 226 /* ClassDeclaration */ - || kind === 227 /* InterfaceDeclaration */ - || kind === 228 /* TypeAliasDeclaration */ - || kind === 229 /* EnumDeclaration */ - || kind === 230 /* ModuleDeclaration */ - || kind === 235 /* ImportDeclaration */ - || kind === 234 /* ImportEqualsDeclaration */ - || kind === 241 /* ExportDeclaration */ - || kind === 240 /* ExportAssignment */ - || kind === 233 /* NamespaceExportDeclaration */; + return kind === 227 /* FunctionDeclaration */ + || kind === 246 /* MissingDeclaration */ + || kind === 228 /* ClassDeclaration */ + || kind === 229 /* InterfaceDeclaration */ + || kind === 230 /* TypeAliasDeclaration */ + || kind === 231 /* EnumDeclaration */ + || kind === 232 /* ModuleDeclaration */ + || kind === 237 /* ImportDeclaration */ + || kind === 236 /* ImportEqualsDeclaration */ + || kind === 243 /* ExportDeclaration */ + || kind === 242 /* ExportAssignment */ + || kind === 235 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 215 /* BreakStatement */ - || kind === 214 /* ContinueStatement */ - || kind === 222 /* DebuggerStatement */ - || kind === 209 /* DoStatement */ - || kind === 207 /* ExpressionStatement */ - || kind === 206 /* EmptyStatement */ - || kind === 212 /* ForInStatement */ - || kind === 213 /* ForOfStatement */ - || kind === 211 /* ForStatement */ - || kind === 208 /* IfStatement */ - || kind === 219 /* LabeledStatement */ - || kind === 216 /* ReturnStatement */ - || kind === 218 /* SwitchStatement */ - || kind === 220 /* ThrowStatement */ - || kind === 221 /* TryStatement */ - || kind === 205 /* VariableStatement */ - || kind === 210 /* WhileStatement */ - || kind === 217 /* WithStatement */ - || kind === 293 /* NotEmittedStatement */ - || kind === 296 /* EndOfDeclarationMarker */ - || kind === 295 /* MergeDeclarationMarker */; + return kind === 217 /* BreakStatement */ + || kind === 216 /* ContinueStatement */ + || kind === 224 /* DebuggerStatement */ + || kind === 211 /* DoStatement */ + || kind === 209 /* ExpressionStatement */ + || kind === 208 /* EmptyStatement */ + || kind === 214 /* ForInStatement */ + || kind === 215 /* ForOfStatement */ + || kind === 213 /* ForStatement */ + || kind === 210 /* IfStatement */ + || kind === 221 /* LabeledStatement */ + || kind === 218 /* ReturnStatement */ + || kind === 220 /* SwitchStatement */ + || kind === 222 /* ThrowStatement */ + || kind === 223 /* TryStatement */ + || kind === 207 /* VariableStatement */ + || kind === 212 /* WhileStatement */ + || kind === 219 /* WithStatement */ + || kind === 297 /* NotEmittedStatement */ + || kind === 300 /* EndOfDeclarationMarker */ + || kind === 299 /* MergeDeclarationMarker */; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10197,93 +10341,102 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 204 /* Block */; + || kind === 206 /* Block */; } ts.isStatement = isStatement; // Module references function isModuleReference(node) { var kind = node.kind; - return kind === 245 /* ExternalModuleReference */ - || kind === 141 /* QualifiedName */ + return kind === 247 /* ExternalModuleReference */ + || kind === 142 /* QualifiedName */ || kind === 70 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX function isJsxOpeningElement(node) { - return node.kind === 248 /* JsxOpeningElement */; + return node.kind === 250 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 249 /* JsxClosingElement */; + return node.kind === 251 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; return kind === 98 /* ThisKeyword */ || kind === 70 /* Identifier */ - || kind === 177 /* PropertyAccessExpression */; + || kind === 178 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 246 /* JsxElement */ - || kind === 252 /* JsxExpression */ - || kind === 247 /* JsxSelfClosingElement */ + return kind === 248 /* JsxElement */ + || kind === 255 /* JsxExpression */ + || kind === 249 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */; } ts.isJsxChild = isJsxChild; + function isJsxAttributes(node) { + var kind = node.kind; + return kind === 253 /* JsxAttributes */; + } + ts.isJsxAttributes = isJsxAttributes; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 250 /* JsxAttribute */ - || kind === 251 /* JsxSpreadAttribute */; + return kind === 252 /* JsxAttribute */ + || kind === 254 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 251 /* JsxSpreadAttribute */; + return node.kind === 254 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 250 /* JsxAttribute */; + return node.kind === 252 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; + function isJsxOpeningLikeElement(node) { + return node.kind === 250 /* JsxOpeningElement */ || node.kind === 249 /* JsxSelfClosingElement */; + } + ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 252 /* JsxExpression */; + || kind === 255 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 253 /* CaseClause */ - || kind === 254 /* DefaultClause */; + return kind === 256 /* CaseClause */ + || kind === 257 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 255 /* HeritageClause */; + return node.kind === 258 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 256 /* CatchClause */; + return node.kind === 259 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 257 /* PropertyAssignment */; + return node.kind === 260 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 258 /* ShorthandPropertyAssignment */; + return node.kind === 261 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; // Enum function isEnumMember(node) { - return node.kind === 260 /* EnumMember */; + return node.kind === 263 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 261 /* SourceFile */; + return node.kind === 264 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -10513,9 +10666,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 143 /* TypeParameter */) { + if (d && d.kind === 144 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 227 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 229 /* InterfaceDeclaration */) { return current; } } @@ -10523,11 +10676,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 150 /* Constructor */ && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 151 /* Constructor */ && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 174 /* BindingElement */ || ts.isBindingPattern(node))) { + while (node && (node.kind === 175 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10535,14 +10688,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 223 /* VariableDeclaration */) { + if (node.kind === 225 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 224 /* VariableDeclarationList */) { + if (node && node.kind === 226 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 205 /* VariableStatement */) { + if (node && node.kind === 207 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -10558,14 +10711,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 223 /* VariableDeclaration */) { + if (node.kind === 225 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 224 /* VariableDeclarationList */) { + if (node && node.kind === 226 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 205 /* VariableStatement */) { + if (node && node.kind === 207 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -10625,27 +10778,60 @@ var ts; } } ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage; + function getOriginalNode(node, nodeTest) { + if (node) { + while (node.original !== undefined) { + node = node.original; + } + } + return !nodeTest || nodeTest(node) ? node : undefined; + } + ts.getOriginalNode = getOriginalNode; + /** + * Gets a value indicating whether a node originated in the parse tree. + * + * @param node The node to test. + */ + function isParseTreeNode(node) { + return (node.flags & 8 /* Synthesized */) === 0; + } + ts.isParseTreeNode = isParseTreeNode; + function getParseTreeNode(node, nodeTest) { + if (isParseTreeNode(node)) { + return node; + } + node = getOriginalNode(node); + if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { + return node; + } + return undefined; + } + ts.getParseTreeNode = getParseTreeNode; + /** + * Remove extra underscore from escaped identifier text content. + * + * @param identifier The escaped identifier text. + * @returns The unescaped identifier text. + */ + 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; })(ts || (ts = {})); /// /// -/* @internal */ var ts; (function (ts) { - var NodeConstructor; - var SourceFileConstructor; - function createNode(kind, location, flags) { - var ConstructorForKind = kind === 261 /* SourceFile */ - ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) - : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); - var node = location - ? new ConstructorForKind(kind, location.pos, location.end) - : new ConstructorForKind(kind, /*pos*/ -1, /*end*/ -1); - node.flags = flags | 8 /* Synthesized */; + function createSynthesizedNode(kind) { + var node = ts.createNode(kind, -1, -1); + node.flags |= 8 /* Synthesized */; return node; } + /* @internal */ function updateNode(updated, original) { if (updated !== original) { setOriginalNode(updated, original); + setTextRange(updated, original); if (original.startsOnNewLine) { updated.startsOnNewLine = true; } @@ -10654,7 +10840,10 @@ var ts; return updated; } ts.updateNode = updateNode; - function createNodeArray(elements, location, hasTrailingComma) { + /** + * Make `elements` into a `NodeArray`. If `elements` is `undefined`, returns an empty `NodeArray`. + */ + function createNodeArray(elements, hasTrailingComma) { if (elements) { if (ts.isNodeArray(elements)) { return elements; @@ -10664,38 +10853,22 @@ var ts; elements = []; } var array = elements; - if (location) { - array.pos = location.pos; - array.end = location.end; - } - else { - array.pos = -1; - array.end = -1; - } - if (hasTrailingComma) { - array.hasTrailingComma = true; - } + array.pos = -1; + array.end = -1; + array.hasTrailingComma = hasTrailingComma; return array; } ts.createNodeArray = createNodeArray; - function createSynthesizedNode(kind, startsOnNewLine) { - var node = createNode(kind, /*location*/ undefined); - node.startsOnNewLine = startsOnNewLine; - return node; - } - ts.createSynthesizedNode = createSynthesizedNode; - function createSynthesizedNodeArray(elements) { - return createNodeArray(elements, /*location*/ undefined); - } - ts.createSynthesizedNodeArray = createSynthesizedNodeArray; /** * Creates a shallow, memberwise clone of a node with no source map location. */ + /* @internal */ function getSynthesizedClone(node) { // We don't use "clone" from core.ts here, as we need to preserve the prototype chain of // the original node. We also need to exclude specific properties and only include own- // properties (to skip members already defined on the shared prototype). - var clone = createNode(node.kind, /*location*/ undefined, node.flags); + var clone = createSynthesizedNode(node.kind); + clone.flags |= node.flags; setOriginalNode(clone, node); for (var key in node) { if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) { @@ -10706,54 +10879,49 @@ var ts; return clone; } ts.getSynthesizedClone = getSynthesizedClone; - /** - * Creates a shallow, memberwise clone of a node for mutation. - */ - function getMutableClone(node) { - var clone = getSynthesizedClone(node); - clone.pos = node.pos; - clone.end = node.end; - clone.parent = node.parent; - return clone; - } - ts.getMutableClone = getMutableClone; - function createLiteral(value, location) { + function createLiteral(value) { if (typeof value === "number") { - var node = createNode(8 /* NumericLiteral */, location, /*flags*/ undefined); - node.text = value.toString(); - return node; + return createNumericLiteral(value + ""); } - else if (typeof value === "boolean") { - return createNode(value ? 100 /* TrueKeyword */ : 85 /* FalseKeyword */, location, /*flags*/ undefined); + if (typeof value === "boolean") { + return value ? createTrue() : createFalse(); } - else if (typeof value === "string") { - var node = createNode(9 /* StringLiteral */, location, /*flags*/ undefined); - node.text = value; - return node; - } - else if (value) { - var node = createNode(9 /* StringLiteral */, location, /*flags*/ undefined); - node.textSourceNode = value; - node.text = value.text; - return node; + if (typeof value === "string") { + return createStringLiteral(value); } + return createLiteralFromNode(value); } ts.createLiteral = createLiteral; + function createNumericLiteral(value) { + var node = createSynthesizedNode(8 /* NumericLiteral */); + node.text = value; + return node; + } + ts.createNumericLiteral = createNumericLiteral; + function createStringLiteral(text) { + var node = createSynthesizedNode(9 /* StringLiteral */); + node.text = text; + return node; + } + function createLiteralFromNode(sourceNode) { + var node = createStringLiteral(sourceNode.text); + node.textSourceNode = sourceNode; + return node; + } // Identifiers - var nextAutoGenerateId = 0; - function createIdentifier(text, location) { - var node = createNode(70 /* Identifier */, location); + function createIdentifier(text) { + var node = createSynthesizedNode(70 /* Identifier */); node.text = ts.escapeIdentifier(text); - node.originalKeywordKind = ts.stringToToken(text); + node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateKind = 0 /* None */; node.autoGenerateId = 0; return node; } ts.createIdentifier = createIdentifier; - function createTempVariable(recordTempVariable, location) { - var name = createNode(70 /* Identifier */, location); - name.text = ""; - name.originalKeywordKind = 0 /* Unknown */; + var nextAutoGenerateId = 0; + /** Create a unique temporary variable. */ + function createTempVariable(recordTempVariable) { + var name = createIdentifier(""); name.autoGenerateKind = 1 /* Auto */; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; @@ -10763,98 +10931,129 @@ var ts; return name; } ts.createTempVariable = createTempVariable; - function createLoopVariable(location) { - var name = createNode(70 /* Identifier */, location); - name.text = ""; - name.originalKeywordKind = 0 /* Unknown */; + /** Create a unique temporary variable for use in a loop. */ + function createLoopVariable() { + var name = createIdentifier(""); name.autoGenerateKind = 2 /* Loop */; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createLoopVariable = createLoopVariable; - function createUniqueName(text, location) { - var name = createNode(70 /* Identifier */, location); - name.text = text; - name.originalKeywordKind = 0 /* Unknown */; + /** Create a unique name based on the supplied text. */ + function createUniqueName(text) { + var name = createIdentifier(text); name.autoGenerateKind = 3 /* Unique */; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } ts.createUniqueName = createUniqueName; - function getGeneratedNameForNode(node, location) { - var name = createNode(70 /* Identifier */, location); - name.original = node; - name.text = ""; - name.originalKeywordKind = 0 /* Unknown */; + /** Create a unique name generated for a node. */ + function getGeneratedNameForNode(node) { + var name = createIdentifier(""); name.autoGenerateKind = 4 /* Node */; name.autoGenerateId = nextAutoGenerateId; + name.original = node; nextAutoGenerateId++; return name; } ts.getGeneratedNameForNode = getGeneratedNameForNode; // Punctuation function createToken(token) { - return createNode(token); + return createSynthesizedNode(token); } ts.createToken = createToken; // Reserved words function createSuper() { - var node = createNode(96 /* SuperKeyword */); - return node; + return createSynthesizedNode(96 /* SuperKeyword */); } ts.createSuper = createSuper; - function createThis(location) { - var node = createNode(98 /* ThisKeyword */, location); - return node; + function createThis() { + return createSynthesizedNode(98 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - var node = createNode(94 /* NullKeyword */); - return node; + return createSynthesizedNode(94 /* NullKeyword */); } ts.createNull = createNull; + function createTrue() { + return createSynthesizedNode(100 /* TrueKeyword */); + } + ts.createTrue = createTrue; + function createFalse() { + return createSynthesizedNode(85 /* FalseKeyword */); + } + ts.createFalse = createFalse; // Names - function createComputedPropertyName(expression, location) { - var node = createNode(142 /* ComputedPropertyName */, location); + function createQualifiedName(left, right) { + var node = createSynthesizedNode(142 /* QualifiedName */); + node.left = left; + node.right = asName(right); + return node; + } + ts.createQualifiedName = createQualifiedName; + function updateQualifiedName(node, left, right) { + return node.left !== left + || node.right !== right + ? updateNode(createQualifiedName(left, right), node) + : node; + } + ts.updateQualifiedName = updateQualifiedName; + function createComputedPropertyName(expression) { + var node = createSynthesizedNode(143 /* ComputedPropertyName */); node.expression = expression; return node; } ts.createComputedPropertyName = createComputedPropertyName; function updateComputedPropertyName(node, expression) { - if (node.expression !== expression) { - return updateNode(createComputedPropertyName(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createComputedPropertyName(expression), node) + : node; } ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements - function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(144 /* Parameter */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { + var node = createSynthesizedNode(145 /* Parameter */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.questionToken = questionToken; node.type = type; - node.initializer = initializer ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createParameter = createParameter; function updateParameter(node, decorators, modifiers, dotDotDotToken, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer, /*location*/ node, /*flags*/ node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) + : node; } ts.updateParameter = updateParameter; + function createDecorator(expression) { + var node = createSynthesizedNode(146 /* Decorator */); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createDecorator = createDecorator; + function updateDecorator(node, expression) { + return node.expression !== expression + ? updateNode(createDecorator(expression), node) + : node; + } + ts.updateDecorator = updateDecorator; // Type members - function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(147 /* PropertyDeclaration */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createProperty(decorators, modifiers, name, questionToken, type, initializer) { + var node = createSynthesizedNode(148 /* PropertyDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.questionToken = questionToken; node.type = type; node.initializer = initializer; @@ -10862,19 +11061,22 @@ var ts; } ts.createProperty = createProperty; function updateProperty(node, decorators, modifiers, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer), node) + : node; } ts.updateProperty = updateProperty; - function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(149 /* MethodDeclaration */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(150 /* MethodDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -10882,16 +11084,21 @@ var ts; } ts.createMethod = createMethod; function updateMethod(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateMethod = updateMethod; - function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(150 /* Constructor */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createConstructor(decorators, modifiers, parameters, body) { + var node = createSynthesizedNode(151 /* Constructor */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = undefined; @@ -10900,17 +11107,19 @@ var ts; } ts.createConstructor = createConstructor; function updateConstructor(node, decorators, modifiers, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.parameters !== parameters || node.body !== body) { - return updateNode(createConstructor(decorators, modifiers, parameters, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.parameters !== parameters + || node.body !== body + ? updateNode(createConstructor(decorators, modifiers, parameters, body), node) + : node; } ts.updateConstructor = updateConstructor; - function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(151 /* GetAccessor */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createGetAccessor(decorators, modifiers, name, parameters, type, body) { + var node = createSynthesizedNode(152 /* GetAccessor */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = type; @@ -10919,17 +11128,21 @@ var ts; } ts.createGetAccessor = createGetAccessor; function updateGetAccessor(node, decorators, modifiers, name, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body), node) + : node; } ts.updateGetAccessor = updateGetAccessor; - function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(152 /* SetAccessor */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createSetAccessor(decorators, modifiers, name, parameters, body) { + var node = createSynthesizedNode(153 /* SetAccessor */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.body = body; @@ -10937,59 +11150,62 @@ var ts; } ts.createSetAccessor = createSetAccessor; function updateSetAccessor(node, decorators, modifiers, name, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.body !== body) { - return updateNode(createSetAccessor(decorators, modifiers, name, parameters, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.body !== body + ? updateNode(createSetAccessor(decorators, modifiers, name, parameters, body), node) + : node; } ts.updateSetAccessor = updateSetAccessor; // Binding Patterns - function createObjectBindingPattern(elements, location) { - var node = createNode(172 /* ObjectBindingPattern */, location); + function createObjectBindingPattern(elements) { + var node = createSynthesizedNode(173 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } ts.createObjectBindingPattern = createObjectBindingPattern; function updateObjectBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createObjectBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createObjectBindingPattern(elements), node) + : node; } ts.updateObjectBindingPattern = updateObjectBindingPattern; - function createArrayBindingPattern(elements, location) { - var node = createNode(173 /* ArrayBindingPattern */, location); + function createArrayBindingPattern(elements) { + var node = createSynthesizedNode(174 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } ts.createArrayBindingPattern = createArrayBindingPattern; function updateArrayBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayBindingPattern(elements), node) + : node; } ts.updateArrayBindingPattern = updateArrayBindingPattern; - function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(174 /* BindingElement */, location); - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createBindingElement(propertyName, dotDotDotToken, name, initializer) { + var node = createSynthesizedNode(175 /* BindingElement */); + node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.initializer = initializer; return node; } ts.createBindingElement = createBindingElement; function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) { - if (node.propertyName !== propertyName || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.initializer !== initializer) { - return updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer, node), node); - } - return node; + return node.propertyName !== propertyName + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.initializer !== initializer + ? updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer), node) + : node; } ts.updateBindingElement = updateBindingElement; // Expression - function createArrayLiteral(elements, location, multiLine) { - var node = createNode(175 /* ArrayLiteralExpression */, location); - node.elements = parenthesizeListElements(createNodeArray(elements)); + function createArrayLiteral(elements, multiLine) { + var node = createSynthesizedNode(176 /* ArrayLiteralExpression */); + node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; } @@ -10997,14 +11213,13 @@ var ts; } ts.createArrayLiteral = createArrayLiteral; function updateArrayLiteral(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayLiteral(elements, node, node.multiLine), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayLiteral(elements, node.multiLine), node) + : node; } ts.updateArrayLiteral = updateArrayLiteral; - function createObjectLiteral(properties, location, multiLine) { - var node = createNode(176 /* ObjectLiteralExpression */, location); + function createObjectLiteral(properties, multiLine) { + var node = createSynthesizedNode(177 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -11013,109 +11228,120 @@ var ts; } ts.createObjectLiteral = createObjectLiteral; function updateObjectLiteral(node, properties) { - if (node.properties !== properties) { - return updateNode(createObjectLiteral(properties, node, node.multiLine), node); - } - return node; + return node.properties !== properties + ? updateNode(createObjectLiteral(properties, node.multiLine), node) + : node; } ts.updateObjectLiteral = updateObjectLiteral; - function createPropertyAccess(expression, name, location, flags) { - var node = createNode(177 /* PropertyAccessExpression */, location, flags); - node.expression = parenthesizeForAccess(expression); - (node.emitNode || (node.emitNode = {})).flags |= 65536 /* NoIndentation */; - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAccess(expression, name) { + var node = createSynthesizedNode(178 /* PropertyAccessExpression */); + node.expression = ts.parenthesizeForAccess(expression); + node.name = asName(name); + setEmitFlags(node, 65536 /* NoIndentation */); return node; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { - if (node.expression !== expression || node.name !== name) { - var propertyAccess = createPropertyAccess(expression, name, /*location*/ node, node.flags); - // Because we are updating existed propertyAccess we want to inherit its emitFlags instead of using default from createPropertyAccess - (propertyAccess.emitNode || (propertyAccess.emitNode = {})).flags = getEmitFlags(node); - return updateNode(propertyAccess, node); - } - return node; + // Because we are updating existed propertyAccess we want to inherit its emitFlags + // instead of using the default from createPropertyAccess + return node.expression !== expression + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccess(expression, name), getEmitFlags(node)), node) + : node; } ts.updatePropertyAccess = updatePropertyAccess; - function createElementAccess(expression, index, location) { - var node = createNode(178 /* ElementAccessExpression */, location); - node.expression = parenthesizeForAccess(expression); - node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; + function createElementAccess(expression, index) { + var node = createSynthesizedNode(179 /* ElementAccessExpression */); + node.expression = ts.parenthesizeForAccess(expression); + node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { - if (node.expression !== expression || node.argumentExpression !== argumentExpression) { - return updateNode(createElementAccess(expression, argumentExpression, node), node); - } - return node; + return node.expression !== expression + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccess(expression, argumentExpression), node) + : node; } ts.updateElementAccess = updateElementAccess; - function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(179 /* CallExpression */, location, flags); - node.expression = parenthesizeForAccess(expression); - if (typeArguments) { - node.typeArguments = createNodeArray(typeArguments); - } - node.arguments = parenthesizeListElements(createNodeArray(argumentsArray)); + function createCall(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(180 /* CallExpression */); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); return node; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { - if (expression !== node.expression || typeArguments !== node.typeArguments || argumentsArray !== node.arguments) { - return updateNode(createCall(expression, typeArguments, argumentsArray, /*location*/ node, node.flags), node); - } - return node; + return expression !== node.expression + || typeArguments !== node.typeArguments + || argumentsArray !== node.arguments + ? updateNode(createCall(expression, typeArguments, argumentsArray), node) + : node; } ts.updateCall = updateCall; - function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(180 /* NewExpression */, location, flags); - node.expression = parenthesizeForNew(expression); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; + function createNew(expression, typeArguments, argumentsArray) { + var node = createSynthesizedNode(181 /* NewExpression */); + node.expression = ts.parenthesizeForNew(expression); + node.typeArguments = asNodeArray(typeArguments); + node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; return node; } ts.createNew = createNew; function updateNew(node, expression, typeArguments, argumentsArray) { - if (node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray) { - return updateNode(createNew(expression, typeArguments, argumentsArray, /*location*/ node, node.flags), node); - } - return node; + return node.expression !== expression + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createNew(expression, typeArguments, argumentsArray), node) + : node; } ts.updateNew = updateNew; - function createTaggedTemplate(tag, template, location) { - var node = createNode(181 /* TaggedTemplateExpression */, location); - node.tag = parenthesizeForAccess(tag); + function createTaggedTemplate(tag, template) { + var node = createSynthesizedNode(182 /* TaggedTemplateExpression */); + node.tag = ts.parenthesizeForAccess(tag); node.template = template; return node; } ts.createTaggedTemplate = createTaggedTemplate; function updateTaggedTemplate(node, tag, template) { - if (node.tag !== tag || node.template !== template) { - return updateNode(createTaggedTemplate(tag, template, node), node); - } - return node; + return node.tag !== tag + || node.template !== template + ? updateNode(createTaggedTemplate(tag, template), node) + : node; } ts.updateTaggedTemplate = updateTaggedTemplate; - function createParen(expression, location) { - var node = createNode(183 /* ParenthesizedExpression */, location); + function createTypeAssertion(type, expression) { + var node = createSynthesizedNode(183 /* TypeAssertionExpression */); + node.type = type; + node.expression = ts.parenthesizePrefixOperand(expression); + return node; + } + ts.createTypeAssertion = createTypeAssertion; + function updateTypeAssertion(node, type, expression) { + return node.type !== type + || node.expression !== expression + ? updateNode(createTypeAssertion(type, expression), node) + : node; + } + ts.updateTypeAssertion = updateTypeAssertion; + function createParen(expression) { + var node = createSynthesizedNode(184 /* ParenthesizedExpression */); node.expression = expression; return node; } ts.createParen = createParen; function updateParen(node, expression) { - if (node.expression !== expression) { - return updateNode(createParen(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createParen(expression), node) + : node; } ts.updateParen = updateParen; - function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(184 /* FunctionExpression */, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(185 /* FunctionExpression */); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -11123,326 +11349,342 @@ var ts; } ts.createFunctionExpression = createFunctionExpression; function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + return node.name !== name + || node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionExpression = updateFunctionExpression; - function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(185 /* ArrowFunction */, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { + var node = createSynthesizedNode(186 /* ArrowFunction */); + node.modifiers = asNodeArray(modifiers); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35 /* EqualsGreaterThanToken */); - node.body = parenthesizeConciseBody(body); + node.body = ts.parenthesizeConciseBody(body); return node; } ts.createArrowFunction = createArrowFunction; function updateArrowFunction(node, modifiers, typeParameters, parameters, type, body) { - if (node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body, /*location*/ node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body), node) + : node; } ts.updateArrowFunction = updateArrowFunction; - function createDelete(expression, location) { - var node = createNode(186 /* DeleteExpression */, location); - node.expression = parenthesizePrefixOperand(expression); + function createDelete(expression) { + var node = createSynthesizedNode(187 /* DeleteExpression */); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createDelete = createDelete; function updateDelete(node, expression) { - if (node.expression !== expression) { - return updateNode(createDelete(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createDelete(expression), node) + : node; } ts.updateDelete = updateDelete; - function createTypeOf(expression, location) { - var node = createNode(187 /* TypeOfExpression */, location); - node.expression = parenthesizePrefixOperand(expression); + function createTypeOf(expression) { + var node = createSynthesizedNode(188 /* TypeOfExpression */); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createTypeOf = createTypeOf; function updateTypeOf(node, expression) { - if (node.expression !== expression) { - return updateNode(createTypeOf(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createTypeOf(expression), node) + : node; } ts.updateTypeOf = updateTypeOf; - function createVoid(expression, location) { - var node = createNode(188 /* VoidExpression */, location); - node.expression = parenthesizePrefixOperand(expression); + function createVoid(expression) { + var node = createSynthesizedNode(189 /* VoidExpression */); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createVoid = createVoid; function updateVoid(node, expression) { - if (node.expression !== expression) { - return updateNode(createVoid(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createVoid(expression), node) + : node; } ts.updateVoid = updateVoid; - function createAwait(expression, location) { - var node = createNode(189 /* AwaitExpression */, location); - node.expression = parenthesizePrefixOperand(expression); + function createAwait(expression) { + var node = createSynthesizedNode(190 /* AwaitExpression */); + node.expression = ts.parenthesizePrefixOperand(expression); return node; } ts.createAwait = createAwait; function updateAwait(node, expression) { - if (node.expression !== expression) { - return updateNode(createAwait(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createAwait(expression), node) + : node; } ts.updateAwait = updateAwait; - function createPrefix(operator, operand, location) { - var node = createNode(190 /* PrefixUnaryExpression */, location); + function createPrefix(operator, operand) { + var node = createSynthesizedNode(191 /* PrefixUnaryExpression */); node.operator = operator; - node.operand = parenthesizePrefixOperand(operand); + node.operand = ts.parenthesizePrefixOperand(operand); return node; } ts.createPrefix = createPrefix; function updatePrefix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPrefix(node.operator, operand, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPrefix(node.operator, operand), node) + : node; } ts.updatePrefix = updatePrefix; - function createPostfix(operand, operator, location) { - var node = createNode(191 /* PostfixUnaryExpression */, location); - node.operand = parenthesizePostfixOperand(operand); + function createPostfix(operand, operator) { + var node = createSynthesizedNode(192 /* PostfixUnaryExpression */); + node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; } ts.createPostfix = createPostfix; function updatePostfix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPostfix(operand, node.operator, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPostfix(operand, node.operator), node) + : node; } ts.updatePostfix = updatePostfix; - function createBinary(left, operator, right, location) { - var operatorToken = typeof operator === "number" ? createToken(operator) : operator; + function createBinary(left, operator, right) { + var node = createSynthesizedNode(193 /* BinaryExpression */); + var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; - var node = createNode(192 /* BinaryExpression */, location); - node.left = parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); + node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); node.operatorToken = operatorToken; - node.right = parenthesizeBinaryOperand(operatorKind, right, /*isLeftSideOfBinary*/ false, node.left); + node.right = ts.parenthesizeBinaryOperand(operatorKind, right, /*isLeftSideOfBinary*/ false, node.left); return node; } ts.createBinary = createBinary; function updateBinary(node, left, right) { - if (node.left !== left || node.right !== right) { - return updateNode(createBinary(left, node.operatorToken, right, /*location*/ node), node); - } - return node; + return node.left !== left + || node.right !== right + ? updateNode(createBinary(left, node.operatorToken, right), node) + : node; } ts.updateBinary = updateBinary; - function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonTokenOrLocation, whenFalse, location) { - var node = createNode(193 /* ConditionalExpression */, whenFalse ? location : colonTokenOrLocation); - node.condition = parenthesizeForConditionalHead(condition); - if (whenFalse) { - // second overload - node.questionToken = questionTokenOrWhenTrue; - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - node.colonToken = colonTokenOrLocation; - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenFalse); - } - else { - // first overload - node.questionToken = createToken(54 /* QuestionToken */); - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(questionTokenOrWhenTrue); - node.colonToken = createToken(55 /* ColonToken */); - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - } + function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { + var node = createSynthesizedNode(194 /* ConditionalExpression */); + node.condition = ts.parenthesizeForConditionalHead(condition); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(54 /* QuestionToken */); + node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); + node.colonToken = whenFalse ? colonToken : createToken(55 /* ColonToken */); + node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } ts.createConditional = createConditional; function updateConditional(node, condition, whenTrue, whenFalse) { - if (node.condition !== condition || node.whenTrue !== whenTrue || node.whenFalse !== whenFalse) { - return updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse, node), node); - } - return node; + return node.condition !== condition + || node.whenTrue !== whenTrue + || node.whenFalse !== whenFalse + ? updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse), node) + : node; } ts.updateConditional = updateConditional; - function createTemplateExpression(head, templateSpans, location) { - var node = createNode(194 /* TemplateExpression */, location); + function createTemplateExpression(head, templateSpans) { + var node = createSynthesizedNode(195 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; } ts.createTemplateExpression = createTemplateExpression; function updateTemplateExpression(node, head, templateSpans) { - if (node.head !== head || node.templateSpans !== templateSpans) { - return updateNode(createTemplateExpression(head, templateSpans, node), node); - } - return node; + return node.head !== head + || node.templateSpans !== templateSpans + ? updateNode(createTemplateExpression(head, templateSpans), node) + : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createYield(asteriskToken, expression, location) { - var node = createNode(195 /* YieldExpression */, location); - node.asteriskToken = asteriskToken; - node.expression = expression; + function createYield(asteriskTokenOrExpression, expression) { + var node = createSynthesizedNode(196 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 38 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 38 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; function updateYield(node, expression) { - if (node.expression !== expression) { - return updateNode(createYield(node.asteriskToken, expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createYield(node.asteriskToken, expression), node) + : node; } ts.updateYield = updateYield; - function createSpread(expression, location) { - var node = createNode(196 /* SpreadElement */, location); - node.expression = parenthesizeExpressionForList(expression); + function createSpread(expression) { + var node = createSynthesizedNode(197 /* SpreadElement */); + node.expression = ts.parenthesizeExpressionForList(expression); return node; } ts.createSpread = createSpread; function updateSpread(node, expression) { - if (node.expression !== expression) { - return updateNode(createSpread(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createSpread(expression), node) + : node; } ts.updateSpread = updateSpread; - function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(197 /* ClassExpression */, location); + function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(198 /* ClassExpression */); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassExpression = createClassExpression; function updateClassExpression(node, modifiers, name, typeParameters, heritageClauses, members) { - if (node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassExpression = updateClassExpression; - function createOmittedExpression(location) { - var node = createNode(198 /* OmittedExpression */, location); - return node; + function createOmittedExpression() { + return createSynthesizedNode(199 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; - function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(199 /* ExpressionWithTypeArguments */, location); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.expression = parenthesizeForAccess(expression); + function createExpressionWithTypeArguments(typeArguments, expression) { + var node = createSynthesizedNode(200 /* ExpressionWithTypeArguments */); + node.expression = ts.parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); return node; } ts.createExpressionWithTypeArguments = createExpressionWithTypeArguments; function updateExpressionWithTypeArguments(node, typeArguments, expression) { - if (node.typeArguments !== typeArguments || node.expression !== expression) { - return updateNode(createExpressionWithTypeArguments(typeArguments, expression, node), node); - } - return node; + return node.typeArguments !== typeArguments + || node.expression !== expression + ? updateNode(createExpressionWithTypeArguments(typeArguments, expression), node) + : node; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; + function createAsExpression(expression, type) { + var node = createSynthesizedNode(201 /* AsExpression */); + node.expression = expression; + node.type = type; + return node; + } + ts.createAsExpression = createAsExpression; + function updateAsExpression(node, expression, type) { + return node.expression !== expression + || node.type !== type + ? updateNode(createAsExpression(expression, type), node) + : node; + } + ts.updateAsExpression = updateAsExpression; + function createNonNullExpression(expression) { + var node = createSynthesizedNode(202 /* NonNullExpression */); + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createNonNullExpression = createNonNullExpression; + function updateNonNullExpression(node, expression) { + return node.expression !== expression + ? updateNode(createNonNullExpression(expression), node) + : node; + } + ts.updateNonNullExpression = updateNonNullExpression; // Misc - function createTemplateSpan(expression, literal, location) { - var node = createNode(202 /* TemplateSpan */, location); + function createTemplateSpan(expression, literal) { + var node = createSynthesizedNode(204 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; } ts.createTemplateSpan = createTemplateSpan; function updateTemplateSpan(node, expression, literal) { - if (node.expression !== expression || node.literal !== literal) { - return updateNode(createTemplateSpan(expression, literal, node), node); - } - return node; + return node.expression !== expression + || node.literal !== literal + ? updateNode(createTemplateSpan(expression, literal), node) + : node; } ts.updateTemplateSpan = updateTemplateSpan; // Element - function createBlock(statements, location, multiLine, flags) { - var block = createNode(204 /* Block */, location, flags); + function createBlock(statements, multiLine) { + var block = createSynthesizedNode(206 /* Block */); block.statements = createNodeArray(statements); - if (multiLine) { - block.multiLine = true; - } + if (multiLine) + block.multiLine = multiLine; return block; } ts.createBlock = createBlock; function updateBlock(node, statements) { - if (statements !== node.statements) { - return updateNode(createBlock(statements, /*location*/ node, node.multiLine, node.flags), node); - } - return node; + return statements !== node.statements + ? updateNode(createBlock(statements, node.multiLine), node) + : node; } ts.updateBlock = updateBlock; - function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(205 /* VariableStatement */, location, flags); + function createVariableStatement(modifiers, declarationList) { + var node = createSynthesizedNode(207 /* VariableStatement */); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; return node; } ts.createVariableStatement = createVariableStatement; function updateVariableStatement(node, modifiers, declarationList) { - if (node.modifiers !== modifiers || node.declarationList !== declarationList) { - return updateNode(createVariableStatement(modifiers, declarationList, /*location*/ node, node.flags), node); - } - return node; + return node.modifiers !== modifiers + || node.declarationList !== declarationList + ? updateNode(createVariableStatement(modifiers, declarationList), node) + : node; } ts.updateVariableStatement = updateVariableStatement; - function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(224 /* VariableDeclarationList */, location, flags); + function createVariableDeclarationList(declarations, flags) { + var node = createSynthesizedNode(226 /* VariableDeclarationList */); + node.flags |= flags; node.declarations = createNodeArray(declarations); return node; } ts.createVariableDeclarationList = createVariableDeclarationList; function updateVariableDeclarationList(node, declarations) { - if (node.declarations !== declarations) { - return updateNode(createVariableDeclarationList(declarations, /*location*/ node, node.flags), node); - } - return node; + return node.declarations !== declarations + ? updateNode(createVariableDeclarationList(declarations, node.flags), node) + : node; } ts.updateVariableDeclarationList = updateVariableDeclarationList; - function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(223 /* VariableDeclaration */, location, flags); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createVariableDeclaration(name, type, initializer) { + var node = createSynthesizedNode(225 /* VariableDeclaration */); + node.name = asName(name); node.type = type; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createVariableDeclaration = createVariableDeclaration; function updateVariableDeclaration(node, name, type, initializer) { - if (node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createVariableDeclaration(name, type, initializer, /*location*/ node, node.flags), node); - } - return node; + return node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createVariableDeclaration(name, type, initializer), node) + : node; } ts.updateVariableDeclaration = updateVariableDeclaration; - function createEmptyStatement(location) { - return createNode(206 /* EmptyStatement */, location); + function createEmptyStatement() { + return createSynthesizedNode(208 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression, location, flags) { - var node = createNode(207 /* ExpressionStatement */, location, flags); - node.expression = parenthesizeExpressionForExpressionStatement(expression); + function createStatement(expression) { + var node = createSynthesizedNode(209 /* ExpressionStatement */); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } ts.createStatement = createStatement; function updateStatement(node, expression) { - if (node.expression !== expression) { - return updateNode(createStatement(expression, /*location*/ node, node.flags), node); - } - return node; + return node.expression !== expression + ? updateNode(createStatement(expression), node) + : node; } ts.updateStatement = updateStatement; - function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(208 /* IfStatement */, location); + function createIf(expression, thenStatement, elseStatement) { + var node = createSynthesizedNode(210 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11450,42 +11692,43 @@ var ts; } ts.createIf = createIf; function updateIf(node, expression, thenStatement, elseStatement) { - if (node.expression !== expression || node.thenStatement !== thenStatement || node.elseStatement !== elseStatement) { - return updateNode(createIf(expression, thenStatement, elseStatement, /*location*/ node), node); - } - return node; + return node.expression !== expression + || node.thenStatement !== thenStatement + || node.elseStatement !== elseStatement + ? updateNode(createIf(expression, thenStatement, elseStatement), node) + : node; } ts.updateIf = updateIf; - function createDo(statement, expression, location) { - var node = createNode(209 /* DoStatement */, location); + function createDo(statement, expression) { + var node = createSynthesizedNode(211 /* DoStatement */); node.statement = statement; node.expression = expression; return node; } ts.createDo = createDo; function updateDo(node, statement, expression) { - if (node.statement !== statement || node.expression !== expression) { - return updateNode(createDo(statement, expression, node), node); - } - return node; + return node.statement !== statement + || node.expression !== expression + ? updateNode(createDo(statement, expression), node) + : node; } ts.updateDo = updateDo; - function createWhile(expression, statement, location) { - var node = createNode(210 /* WhileStatement */, location); + function createWhile(expression, statement) { + var node = createSynthesizedNode(212 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; } ts.createWhile = createWhile; function updateWhile(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWhile(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWhile(expression, statement), node) + : node; } ts.updateWhile = updateWhile; - function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(211 /* ForStatement */, location, /*flags*/ undefined); + function createFor(initializer, condition, incrementor, statement) { + var node = createSynthesizedNode(213 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11494,14 +11737,16 @@ var ts; } ts.createFor = createFor; function updateFor(node, initializer, condition, incrementor, statement) { - if (node.initializer !== initializer || node.condition !== condition || node.incrementor !== incrementor || node.statement !== statement) { - return updateNode(createFor(initializer, condition, incrementor, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.condition !== condition + || node.incrementor !== incrementor + || node.statement !== statement + ? updateNode(createFor(initializer, condition, incrementor, statement), node) + : node; } ts.updateFor = updateFor; - function createForIn(initializer, expression, statement, location) { - var node = createNode(212 /* ForInStatement */, location); + function createForIn(initializer, expression, statement) { + var node = createSynthesizedNode(214 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11509,14 +11754,15 @@ var ts; } ts.createForIn = createForIn; function updateForIn(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForIn(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForIn(initializer, expression, statement), node) + : node; } ts.updateForIn = updateForIn; - function createForOf(initializer, expression, statement, location) { - var node = createNode(213 /* ForOfStatement */, location); + function createForOf(initializer, expression, statement) { + var node = createSynthesizedNode(215 /* ForOfStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11524,112 +11770,105 @@ var ts; } ts.createForOf = createForOf; function updateForOf(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForOf(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForOf(initializer, expression, statement), node) + : node; } ts.updateForOf = updateForOf; - function createContinue(label, location) { - var node = createNode(214 /* ContinueStatement */, location); - if (label) { - node.label = label; - } + function createContinue(label) { + var node = createSynthesizedNode(216 /* ContinueStatement */); + node.label = asName(label); return node; } ts.createContinue = createContinue; function updateContinue(node, label) { - if (node.label !== label) { - return updateNode(createContinue(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createContinue(label), node) + : node; } ts.updateContinue = updateContinue; - function createBreak(label, location) { - var node = createNode(215 /* BreakStatement */, location); - if (label) { - node.label = label; - } + function createBreak(label) { + var node = createSynthesizedNode(217 /* BreakStatement */); + node.label = asName(label); return node; } ts.createBreak = createBreak; function updateBreak(node, label) { - if (node.label !== label) { - return updateNode(createBreak(label, node), node); - } - return node; + return node.label !== label + ? updateNode(createBreak(label), node) + : node; } ts.updateBreak = updateBreak; - function createReturn(expression, location) { - var node = createNode(216 /* ReturnStatement */, location); + function createReturn(expression) { + var node = createSynthesizedNode(218 /* ReturnStatement */); node.expression = expression; return node; } ts.createReturn = createReturn; function updateReturn(node, expression) { - if (node.expression !== expression) { - return updateNode(createReturn(expression, /*location*/ node), node); - } - return node; + return node.expression !== expression + ? updateNode(createReturn(expression), node) + : node; } ts.updateReturn = updateReturn; - function createWith(expression, statement, location) { - var node = createNode(217 /* WithStatement */, location); + function createWith(expression, statement) { + var node = createSynthesizedNode(219 /* WithStatement */); node.expression = expression; node.statement = statement; return node; } ts.createWith = createWith; function updateWith(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWith(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWith(expression, statement), node) + : node; } ts.updateWith = updateWith; - function createSwitch(expression, caseBlock, location) { - var node = createNode(218 /* SwitchStatement */, location); - node.expression = parenthesizeExpressionForList(expression); + function createSwitch(expression, caseBlock) { + var node = createSynthesizedNode(220 /* SwitchStatement */); + node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; } ts.createSwitch = createSwitch; function updateSwitch(node, expression, caseBlock) { - if (node.expression !== expression || node.caseBlock !== caseBlock) { - return updateNode(createSwitch(expression, caseBlock, node), node); - } - return node; + return node.expression !== expression + || node.caseBlock !== caseBlock + ? updateNode(createSwitch(expression, caseBlock), node) + : node; } ts.updateSwitch = updateSwitch; - function createLabel(label, statement, location) { - var node = createNode(219 /* LabeledStatement */, location); - node.label = typeof label === "string" ? createIdentifier(label) : label; + function createLabel(label, statement) { + var node = createSynthesizedNode(221 /* LabeledStatement */); + node.label = asName(label); node.statement = statement; return node; } ts.createLabel = createLabel; function updateLabel(node, label, statement) { - if (node.label !== label || node.statement !== statement) { - return updateNode(createLabel(label, statement, node), node); - } - return node; + return node.label !== label + || node.statement !== statement + ? updateNode(createLabel(label, statement), node) + : node; } ts.updateLabel = updateLabel; - function createThrow(expression, location) { - var node = createNode(220 /* ThrowStatement */, location); + function createThrow(expression) { + var node = createSynthesizedNode(222 /* ThrowStatement */); node.expression = expression; return node; } ts.createThrow = createThrow; function updateThrow(node, expression) { - if (node.expression !== expression) { - return updateNode(createThrow(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createThrow(expression), node) + : node; } ts.updateThrow = updateThrow; - function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(221 /* TryStatement */, location); + function createTry(tryBlock, catchClause, finallyBlock) { + var node = createSynthesizedNode(223 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11637,32 +11876,20 @@ var ts; } ts.createTry = createTry; function updateTry(node, tryBlock, catchClause, finallyBlock) { - if (node.tryBlock !== tryBlock || node.catchClause !== catchClause || node.finallyBlock !== finallyBlock) { - return updateNode(createTry(tryBlock, catchClause, finallyBlock, node), node); - } - return node; + return node.tryBlock !== tryBlock + || node.catchClause !== catchClause + || node.finallyBlock !== finallyBlock + ? updateNode(createTry(tryBlock, catchClause, finallyBlock), node) + : node; } ts.updateTry = updateTry; - function createCaseBlock(clauses, location) { - var node = createNode(232 /* CaseBlock */, location); - node.clauses = createNodeArray(clauses); - return node; - } - ts.createCaseBlock = createCaseBlock; - function updateCaseBlock(node, clauses) { - if (node.clauses !== clauses) { - return updateNode(createCaseBlock(clauses, node), node); - } - return node; - } - ts.updateCaseBlock = updateCaseBlock; - function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(225 /* FunctionDeclaration */, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(227 /* FunctionDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; @@ -11670,162 +11897,263 @@ var ts; } ts.createFunctionDeclaration = createFunctionDeclaration; function updateFunctionDeclaration(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } ts.updateFunctionDeclaration = updateFunctionDeclaration; - function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(226 /* ClassDeclaration */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { + var node = createSynthesizedNode(228 /* ClassDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } ts.createClassDeclaration = createClassDeclaration; function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node) + : node; } ts.updateClassDeclaration = updateClassDeclaration; - function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(235 /* ImportDeclaration */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createEnumDeclaration(decorators, modifiers, name, members) { + var node = createSynthesizedNode(231 /* EnumDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.members = createNodeArray(members); + return node; + } + ts.createEnumDeclaration = createEnumDeclaration; + function updateEnumDeclaration(node, decorators, modifiers, name, members) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.members !== members + ? updateNode(createEnumDeclaration(decorators, modifiers, name, members), node) + : node; + } + ts.updateEnumDeclaration = updateEnumDeclaration; + function createModuleDeclaration(decorators, modifiers, name, body, flags) { + var node = createSynthesizedNode(232 /* ModuleDeclaration */); + node.flags |= flags; + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = name; + node.body = body; + return node; + } + ts.createModuleDeclaration = createModuleDeclaration; + function updateModuleDeclaration(node, decorators, modifiers, name, body) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.body !== body + ? updateNode(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node) + : node; + } + ts.updateModuleDeclaration = updateModuleDeclaration; + function createModuleBlock(statements) { + var node = createSynthesizedNode(234 /* CaseBlock */); + node.statements = createNodeArray(statements); + return node; + } + ts.createModuleBlock = createModuleBlock; + function updateModuleBlock(node, statements) { + return node.statements !== statements + ? updateNode(createModuleBlock(statements), node) + : node; + } + ts.updateModuleBlock = updateModuleBlock; + function createCaseBlock(clauses) { + var node = createSynthesizedNode(234 /* CaseBlock */); + node.clauses = createNodeArray(clauses); + return node; + } + ts.createCaseBlock = createCaseBlock; + function updateCaseBlock(node, clauses) { + return node.clauses !== clauses + ? updateNode(createCaseBlock(clauses), node) + : node; + } + ts.updateCaseBlock = updateCaseBlock; + function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { + var node = createSynthesizedNode(236 /* ImportEqualsDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.moduleReference = moduleReference; + return node; + } + ts.createImportEqualsDeclaration = createImportEqualsDeclaration; + function updateImportEqualsDeclaration(node, decorators, modifiers, name, moduleReference) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.moduleReference !== moduleReference + ? updateNode(createImportEqualsDeclaration(decorators, modifiers, name, moduleReference), node) + : node; + } + ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; + function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { + var node = createSynthesizedNode(237 /* ImportDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createImportDeclaration = createImportDeclaration; function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node) + : node; } ts.updateImportDeclaration = updateImportDeclaration; - function createImportClause(name, namedBindings, location) { - var node = createNode(236 /* ImportClause */, location); + function createImportClause(name, namedBindings) { + var node = createSynthesizedNode(238 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; } ts.createImportClause = createImportClause; function updateImportClause(node, name, namedBindings) { - if (node.name !== name || node.namedBindings !== namedBindings) { - return updateNode(createImportClause(name, namedBindings, node), node); - } - return node; + return node.name !== name + || node.namedBindings !== namedBindings + ? updateNode(createImportClause(name, namedBindings), node) + : node; } ts.updateImportClause = updateImportClause; - function createNamespaceImport(name, location) { - var node = createNode(237 /* NamespaceImport */, location); + function createNamespaceImport(name) { + var node = createSynthesizedNode(239 /* NamespaceImport */); node.name = name; return node; } ts.createNamespaceImport = createNamespaceImport; function updateNamespaceImport(node, name) { - if (node.name !== name) { - return updateNode(createNamespaceImport(name, node), node); - } - return node; + return node.name !== name + ? updateNode(createNamespaceImport(name), node) + : node; } ts.updateNamespaceImport = updateNamespaceImport; - function createNamedImports(elements, location) { - var node = createNode(238 /* NamedImports */, location); + function createNamedImports(elements) { + var node = createSynthesizedNode(240 /* NamedImports */); node.elements = createNodeArray(elements); return node; } ts.createNamedImports = createNamedImports; function updateNamedImports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedImports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedImports(elements), node) + : node; } ts.updateNamedImports = updateNamedImports; - function createImportSpecifier(propertyName, name, location) { - var node = createNode(239 /* ImportSpecifier */, location); + function createImportSpecifier(propertyName, name) { + var node = createSynthesizedNode(241 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; } ts.createImportSpecifier = createImportSpecifier; function updateImportSpecifier(node, propertyName, name) { - if (node.propertyName !== propertyName || node.name !== name) { - return updateNode(createImportSpecifier(propertyName, name, node), node); - } - return node; + return node.propertyName !== propertyName + || node.name !== name + ? updateNode(createImportSpecifier(propertyName, name), node) + : node; } ts.updateImportSpecifier = updateImportSpecifier; - function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(240 /* ExportAssignment */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportAssignment(decorators, modifiers, isExportEquals, expression) { + var node = createSynthesizedNode(242 /* ExportAssignment */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; node.expression = expression; return node; } ts.createExportAssignment = createExportAssignment; function updateExportAssignment(node, decorators, modifiers, expression) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.expression !== expression) { - return updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.expression !== expression + ? updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node) + : node; } ts.updateExportAssignment = updateExportAssignment; - function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(241 /* ExportDeclaration */, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { + var node = createSynthesizedNode(243 /* ExportDeclaration */); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; return node; } ts.createExportDeclaration = createExportDeclaration; function updateExportDeclaration(node, decorators, modifiers, exportClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.exportClause !== exportClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, node), node); - } - return node; + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.exportClause !== exportClause + || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier), node) + : node; } ts.updateExportDeclaration = updateExportDeclaration; - function createNamedExports(elements, location) { - var node = createNode(242 /* NamedExports */, location); + function createNamedExports(elements) { + var node = createSynthesizedNode(244 /* NamedExports */); node.elements = createNodeArray(elements); return node; } ts.createNamedExports = createNamedExports; function updateNamedExports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedExports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedExports(elements), node) + : node; } ts.updateNamedExports = updateNamedExports; - function createExportSpecifier(name, propertyName, location) { - var node = createNode(243 /* ExportSpecifier */, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + function createExportSpecifier(name, propertyName) { + var node = createSynthesizedNode(245 /* ExportSpecifier */); + node.name = asName(name); + node.propertyName = asName(propertyName); return node; } ts.createExportSpecifier = createExportSpecifier; function updateExportSpecifier(node, name, propertyName) { - if (node.name !== name || node.propertyName !== propertyName) { - return updateNode(createExportSpecifier(name, propertyName, node), node); - } - return node; + return node.name !== name || node.propertyName !== propertyName + ? updateNode(createExportSpecifier(name, propertyName), node) + : node; } ts.updateExportSpecifier = updateExportSpecifier; + // Module references + function createExternalModuleReference(expression) { + var node = createSynthesizedNode(247 /* ExternalModuleReference */); + node.expression = expression; + return node; + } + ts.createExternalModuleReference = createExternalModuleReference; + function updateExternalModuleReference(node, expression) { + return node.expression !== expression + ? updateNode(createExternalModuleReference(expression), node) + : node; + } + ts.updateExternalModuleReference = updateExternalModuleReference; // JSX - function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(246 /* JsxElement */, location); + function createJsxElement(openingElement, children, closingElement) { + var node = createSynthesizedNode(248 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11833,96 +12161,108 @@ var ts; } ts.createJsxElement = createJsxElement; function updateJsxElement(node, openingElement, children, closingElement) { - if (node.openingElement !== openingElement || node.children !== children || node.closingElement !== closingElement) { - return updateNode(createJsxElement(openingElement, children, closingElement, node), node); - } - return node; + return node.openingElement !== openingElement + || node.children !== children + || node.closingElement !== closingElement + ? updateNode(createJsxElement(openingElement, children, closingElement), node) + : node; } ts.updateJsxElement = updateJsxElement; - function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(247 /* JsxSelfClosingElement */, location); + function createJsxSelfClosingElement(tagName, attributes) { + var node = createSynthesizedNode(249 /* JsxSelfClosingElement */); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxSelfClosingElement = createJsxSelfClosingElement; function updateJsxSelfClosingElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxSelfClosingElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxSelfClosingElement(tagName, attributes), node) + : node; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; - function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(248 /* JsxOpeningElement */, location); + function createJsxOpeningElement(tagName, attributes) { + var node = createSynthesizedNode(250 /* JsxOpeningElement */); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } ts.createJsxOpeningElement = createJsxOpeningElement; function updateJsxOpeningElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxOpeningElement(tagName, attributes, node), node); - } - return node; + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxOpeningElement(tagName, attributes), node) + : node; } ts.updateJsxOpeningElement = updateJsxOpeningElement; - function createJsxClosingElement(tagName, location) { - var node = createNode(249 /* JsxClosingElement */, location); + function createJsxClosingElement(tagName) { + var node = createSynthesizedNode(251 /* JsxClosingElement */); node.tagName = tagName; return node; } ts.createJsxClosingElement = createJsxClosingElement; function updateJsxClosingElement(node, tagName) { - if (node.tagName !== tagName) { - return updateNode(createJsxClosingElement(tagName, node), node); - } - return node; + return node.tagName !== tagName + ? updateNode(createJsxClosingElement(tagName), node) + : node; } ts.updateJsxClosingElement = updateJsxClosingElement; - function createJsxAttribute(name, initializer, location) { - var node = createNode(250 /* JsxAttribute */, location); + function createJsxAttributes(properties) { + var jsxAttributes = createSynthesizedNode(253 /* JsxAttributes */); + jsxAttributes.properties = createNodeArray(properties); + return jsxAttributes; + } + ts.createJsxAttributes = createJsxAttributes; + function updateJsxAttributes(jsxAttributes, properties) { + if (jsxAttributes.properties !== properties) { + return updateNode(createJsxAttributes(properties), jsxAttributes); + } + return jsxAttributes; + } + ts.updateJsxAttributes = updateJsxAttributes; + function createJsxAttribute(name, initializer) { + var node = createSynthesizedNode(252 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; } ts.createJsxAttribute = createJsxAttribute; function updateJsxAttribute(node, name, initializer) { - if (node.name !== name || node.initializer !== initializer) { - return updateNode(createJsxAttribute(name, initializer, node), node); - } - return node; + return node.name !== name + || node.initializer !== initializer + ? updateNode(createJsxAttribute(name, initializer), node) + : node; } ts.updateJsxAttribute = updateJsxAttribute; - function createJsxSpreadAttribute(expression, location) { - var node = createNode(251 /* JsxSpreadAttribute */, location); + function createJsxSpreadAttribute(expression) { + var node = createSynthesizedNode(254 /* JsxSpreadAttribute */); node.expression = expression; return node; } ts.createJsxSpreadAttribute = createJsxSpreadAttribute; function updateJsxSpreadAttribute(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxSpreadAttribute(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxSpreadAttribute(expression), node) + : node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, location) { - var node = createNode(252 /* JsxExpression */, location); + function createJsxExpression(expression, dotDotDotToken) { + var node = createSynthesizedNode(255 /* JsxExpression */); + node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxExpression(expression, node.dotDotDotToken), node) + : node; } ts.updateJsxExpression = updateJsxExpression; // Clauses - function createHeritageClause(token, types, location) { - var node = createNode(255 /* HeritageClause */, location); + function createHeritageClause(token, types) { + var node = createSynthesizedNode(258 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -11930,40 +12270,40 @@ var ts; ts.createHeritageClause = createHeritageClause; function updateHeritageClause(node, types) { if (node.types !== types) { - return updateNode(createHeritageClause(node.token, types, node), node); + return updateNode(createHeritageClause(node.token, types), node); } return node; } ts.updateHeritageClause = updateHeritageClause; - function createCaseClause(expression, statements, location) { - var node = createNode(253 /* CaseClause */, location); - node.expression = parenthesizeExpressionForList(expression); + function createCaseClause(expression, statements) { + var node = createSynthesizedNode(256 /* CaseClause */); + node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; } ts.createCaseClause = createCaseClause; function updateCaseClause(node, expression, statements) { if (node.expression !== expression || node.statements !== statements) { - return updateNode(createCaseClause(expression, statements, node), node); + return updateNode(createCaseClause(expression, statements), node); } return node; } ts.updateCaseClause = updateCaseClause; - function createDefaultClause(statements, location) { - var node = createNode(254 /* DefaultClause */, location); + function createDefaultClause(statements) { + var node = createSynthesizedNode(257 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } ts.createDefaultClause = createDefaultClause; function updateDefaultClause(node, statements) { if (node.statements !== statements) { - return updateNode(createDefaultClause(statements, node), node); + return updateNode(createDefaultClause(statements), node); } return node; } ts.updateDefaultClause = updateDefaultClause; - function createCatchClause(variableDeclaration, block, location) { - var node = createNode(256 /* CatchClause */, location); + function createCatchClause(variableDeclaration, block) { + var node = createSynthesizedNode(259 /* CatchClause */); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11971,58 +12311,74 @@ var ts; ts.createCatchClause = createCatchClause; function updateCatchClause(node, variableDeclaration, block) { if (node.variableDeclaration !== variableDeclaration || node.block !== block) { - return updateNode(createCatchClause(variableDeclaration, block, node), node); + return updateNode(createCatchClause(variableDeclaration, block), node); } return node; } ts.updateCatchClause = updateCatchClause; // Property assignments - function createPropertyAssignment(name, initializer, location) { - var node = createNode(257 /* PropertyAssignment */, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; + function createPropertyAssignment(name, initializer) { + var node = createSynthesizedNode(260 /* PropertyAssignment */); + node.name = asName(name); node.questionToken = undefined; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; return node; } ts.createPropertyAssignment = createPropertyAssignment; function updatePropertyAssignment(node, name, initializer) { if (node.name !== name || node.initializer !== initializer) { - return updateNode(createPropertyAssignment(name, initializer, node), node); + return updateNode(createPropertyAssignment(name, initializer), node); } return node; } ts.updatePropertyAssignment = updatePropertyAssignment; - function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(258 /* ShorthandPropertyAssignment */, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; + function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { + var node = createSynthesizedNode(261 /* ShorthandPropertyAssignment */); + node.name = asName(name); + node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; - function createSpreadAssignment(expression, location) { - var node = createNode(259 /* SpreadAssignment */, location); - node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; + function createSpreadAssignment(expression) { + var node = createSynthesizedNode(262 /* SpreadAssignment */); + node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; return node; } ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { - return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node); + return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node); } return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function updateSpreadAssignment(node, expression) { if (node.expression !== expression) { - return updateNode(createSpreadAssignment(expression, node), node); + return updateNode(createSpreadAssignment(expression), node); } return node; } ts.updateSpreadAssignment = updateSpreadAssignment; + // Enum + function createEnumMember(name, initializer) { + var node = createSynthesizedNode(263 /* EnumMember */); + node.name = asName(name); + node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); + return node; + } + ts.createEnumMember = createEnumMember; + function updateEnumMember(node, name, initializer) { + return node.name !== name + || node.initializer !== initializer + ? updateNode(createEnumMember(name, initializer), node) + : node; + } + ts.updateEnumMember = updateEnumMember; // Top-level nodes function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(261 /* SourceFile */, /*location*/ node, node.flags); + var updated = createSynthesizedNode(264 /* SourceFile */); + updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -12081,6 +12437,17 @@ var ts; return node; } ts.updateSourceFileNode = updateSourceFileNode; + /** + * Creates a shallow, memberwise clone of a node for mutation. + */ + function getMutableClone(node) { + var clone = getSynthesizedClone(node); + clone.pos = node.pos; + clone.end = node.end; + clone.parent = node.parent; + return clone; + } + ts.getMutableClone = getMutableClone; // Transformation nodes /** * Creates a synthetic statement to act as a placeholder for a not-emitted statement in @@ -12089,8 +12456,9 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createNode(293 /* NotEmittedStatement */, /*location*/ original); + var node = createSynthesizedNode(297 /* NotEmittedStatement */); node.original = original; + setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; @@ -12098,8 +12466,9 @@ var ts; * Creates a synthetic element to act as a placeholder for the end of an emitted declaration in * order to properly emit exports. */ + /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createNode(296 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(300 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12109,8 +12478,9 @@ var ts; * Creates a synthetic element to act as a placeholder for the beginning of a merged declaration in * order to properly emit exports. */ + /* @internal */ function createMergeDeclarationMarker(original) { - var node = createNode(295 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(299 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12124,44 +12494,45 @@ var ts; * @param original The original outer expression. * @param location The location for the expression. Defaults to the positions from "original" if provided. */ - function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(294 /* PartiallyEmittedExpression */, /*location*/ location || original); + function createPartiallyEmittedExpression(expression, original) { + var node = createSynthesizedNode(298 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; + setTextRange(node, original); return node; } ts.createPartiallyEmittedExpression = createPartiallyEmittedExpression; function updatePartiallyEmittedExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createPartiallyEmittedExpression(expression, node.original, node), node); + return updateNode(createPartiallyEmittedExpression(expression, node.original), node); } return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; - /** - * Creates a node that emits a string of raw text in an expression position. Raw text is never - * transformed, should be ES3 compliant, and should have the same precedence as - * PrimaryExpression. - * - * @param text The raw text of the node. - */ - function createRawExpression(text) { - var node = createNode(297 /* RawExpression */); - node.text = text; + function createBundle(sourceFiles) { + var node = ts.createNode(265 /* Bundle */); + node.sourceFiles = sourceFiles; return node; } - ts.createRawExpression = createRawExpression; + ts.createBundle = createBundle; + function updateBundle(node, sourceFiles) { + if (node.sourceFiles !== sourceFiles) { + return createBundle(sourceFiles); + } + return node; + } + ts.updateBundle = updateBundle; // Compound nodes function createComma(left, right) { return createBinary(left, 25 /* CommaToken */, right); } ts.createComma = createComma; - function createLessThan(left, right, location) { - return createBinary(left, 26 /* LessThanToken */, right, location); + function createLessThan(left, right) { + return createBinary(left, 26 /* LessThanToken */, right); } ts.createLessThan = createLessThan; - function createAssignment(left, right, location) { - return createBinary(left, 57 /* EqualsToken */, right, location); + function createAssignment(left, right) { + return createBinary(left, 57 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { @@ -12180,8 +12551,8 @@ var ts; return createBinary(left, 37 /* MinusToken */, right); } ts.createSubtract = createSubtract; - function createPostfixIncrement(operand, location) { - return createPostfix(operand, 42 /* PlusPlusToken */, location); + function createPostfixIncrement(operand) { + return createPostfix(operand, 42 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { @@ -12200,61 +12571,346 @@ var ts; return createVoid(createLiteral(0)); } ts.createVoidZero = createVoidZero; + function createExportDefault(expression) { + return createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportEquals*/ false, expression); + } + ts.createExportDefault = createExportDefault; + function createExternalModuleExport(exportName) { + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(exportName)])); + } + ts.createExternalModuleExport = createExternalModuleExport; + function asName(name) { + return typeof name === "string" ? createIdentifier(name) : name; + } + function asExpression(value) { + return typeof value === "string" || typeof value === "number" ? createLiteral(value) : value; + } + function asNodeArray(array) { + return array ? createNodeArray(array) : undefined; + } + function asToken(value) { + return typeof value === "number" ? createToken(value) : value; + } + /** + * Clears any EmitNode entries from parse-tree nodes. + * @param sourceFile A source file. + */ + function disposeEmitNodes(sourceFile) { + // During transformation we may need to annotate a parse tree node with transient + // transformation properties. As parse tree nodes live longer than transformation + // nodes, we need to make sure we reclaim any memory allocated for custom ranges + // from these nodes to ensure we do not hold onto entire subtrees just for position + // information. We also need to reset these nodes to a pre-transformation state + // for incremental parsing scenarios so that we do not impact later emit. + sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); + var emitNode = sourceFile && sourceFile.emitNode; + var annotatedNodes = emitNode && emitNode.annotatedNodes; + if (annotatedNodes) { + for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) { + var node = annotatedNodes_1[_i]; + node.emitNode = undefined; + } + } + } + ts.disposeEmitNodes = disposeEmitNodes; + /** + * Associates a node with the current transformation, initializing + * various transient transformation properties. + */ + /* @internal */ + function getOrCreateEmitNode(node) { + if (!node.emitNode) { + if (ts.isParseTreeNode(node)) { + // To avoid holding onto transformation artifacts, we keep track of any + // parse tree node we are annotating. This allows us to clean them up after + // all transformations have completed. + if (node.kind === 264 /* SourceFile */) { + return node.emitNode = { annotatedNodes: [node] }; + } + var sourceFile = ts.getSourceFileOfNode(node); + getOrCreateEmitNode(sourceFile).annotatedNodes.push(node); + } + node.emitNode = {}; + } + return node.emitNode; + } + ts.getOrCreateEmitNode = getOrCreateEmitNode; + function setTextRange(range, location) { + if (location) { + range.pos = location.pos; + range.end = location.end; + } + return range; + } + ts.setTextRange = setTextRange; + /** + * Gets flags that control emit behavior of a node. + */ + function getEmitFlags(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.flags; + } + ts.getEmitFlags = getEmitFlags; + /** + * Sets flags that control emit behavior of a node. + */ + function setEmitFlags(node, emitFlags) { + getOrCreateEmitNode(node).flags = emitFlags; + return node; + } + ts.setEmitFlags = setEmitFlags; + /** + * Gets a custom text range to use when emitting source maps. + */ + function getSourceMapRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.sourceMapRange) || node; + } + ts.getSourceMapRange = getSourceMapRange; + /** + * Sets a custom text range to use when emitting source maps. + */ + function setSourceMapRange(node, range) { + getOrCreateEmitNode(node).sourceMapRange = range; + return node; + } + ts.setSourceMapRange = setSourceMapRange; + /** + * Gets the TextRange to use for source maps for a token of a node. + */ + function getTokenSourceMapRange(node, token) { + var emitNode = node.emitNode; + var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; + return tokenSourceMapRanges && tokenSourceMapRanges[token]; + } + ts.getTokenSourceMapRange = getTokenSourceMapRange; + /** + * Sets the TextRange to use for source maps for a token of a node. + */ + function setTokenSourceMapRange(node, token, range) { + var emitNode = getOrCreateEmitNode(node); + var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = []); + tokenSourceMapRanges[token] = range; + return node; + } + ts.setTokenSourceMapRange = setTokenSourceMapRange; + /** + * Gets a custom text range to use when emitting comments. + */ + function getCommentRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.commentRange) || node; + } + ts.getCommentRange = getCommentRange; + /** + * Sets a custom text range to use when emitting comments. + */ + function setCommentRange(node, range) { + getOrCreateEmitNode(node).commentRange = range; + return node; + } + ts.setCommentRange = setCommentRange; + /** + * Gets the constant value to emit for an expression. + */ + function getConstantValue(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.constantValue; + } + ts.getConstantValue = getConstantValue; + /** + * Sets the constant value to emit for an expression. + */ + function setConstantValue(node, value) { + var emitNode = getOrCreateEmitNode(node); + emitNode.constantValue = value; + return node; + } + ts.setConstantValue = setConstantValue; + /** + * Adds an EmitHelper to a node. + */ + function addEmitHelper(node, helper) { + var emitNode = getOrCreateEmitNode(node); + emitNode.helpers = ts.append(emitNode.helpers, helper); + return node; + } + ts.addEmitHelper = addEmitHelper; + /** + * Add EmitHelpers to a node. + */ + function addEmitHelpers(node, helpers) { + if (ts.some(helpers)) { + var emitNode = getOrCreateEmitNode(node); + for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { + var helper = helpers_1[_i]; + if (!ts.contains(emitNode.helpers, helper)) { + emitNode.helpers = ts.append(emitNode.helpers, helper); + } + } + } + return node; + } + ts.addEmitHelpers = addEmitHelpers; + /** + * Removes an EmitHelper from a node. + */ + function removeEmitHelper(node, helper) { + var emitNode = node.emitNode; + if (emitNode) { + var helpers = emitNode.helpers; + if (helpers) { + return ts.orderedRemoveItem(helpers, helper); + } + } + return false; + } + ts.removeEmitHelper = removeEmitHelper; + /** + * Gets the EmitHelpers of a node. + */ + function getEmitHelpers(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.helpers; + } + ts.getEmitHelpers = getEmitHelpers; + /** + * Moves matching emit helpers from a source node to a target node. + */ + function moveEmitHelpers(source, target, predicate) { + var sourceEmitNode = source.emitNode; + var sourceEmitHelpers = sourceEmitNode && sourceEmitNode.helpers; + if (!ts.some(sourceEmitHelpers)) + return; + var targetEmitNode = getOrCreateEmitNode(target); + var helpersRemoved = 0; + for (var i = 0; i < sourceEmitHelpers.length; i++) { + var helper = sourceEmitHelpers[i]; + if (predicate(helper)) { + helpersRemoved++; + if (!ts.contains(targetEmitNode.helpers, helper)) { + targetEmitNode.helpers = ts.append(targetEmitNode.helpers, helper); + } + } + else if (helpersRemoved > 0) { + sourceEmitHelpers[i - helpersRemoved] = helper; + } + } + if (helpersRemoved > 0) { + sourceEmitHelpers.length -= helpersRemoved; + } + } + ts.moveEmitHelpers = moveEmitHelpers; + /* @internal */ + function compareEmitHelpers(x, y) { + if (x === y) + return 0 /* EqualTo */; + if (x.priority === y.priority) + return 0 /* EqualTo */; + if (x.priority === undefined) + return 1 /* GreaterThan */; + if (y.priority === undefined) + return -1 /* LessThan */; + return ts.compareValues(x.priority, y.priority); + } + ts.compareEmitHelpers = compareEmitHelpers; + function setOriginalNode(node, original) { + node.original = original; + if (original) { + var emitNode = original.emitNode; + if (emitNode) + node.emitNode = mergeEmitNode(emitNode, node.emitNode); + } + return node; + } + ts.setOriginalNode = setOriginalNode; + function mergeEmitNode(sourceEmitNode, destEmitNode) { + var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; + if (!destEmitNode) + destEmitNode = {}; + if (flags) + destEmitNode.flags = flags; + if (commentRange) + destEmitNode.commentRange = commentRange; + if (sourceMapRange) + destEmitNode.sourceMapRange = sourceMapRange; + if (tokenSourceMapRanges) + destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); + if (constantValue !== undefined) + destEmitNode.constantValue = constantValue; + if (helpers) + destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); + return destEmitNode; + } + function mergeTokenSourceMapRanges(sourceRanges, destRanges) { + if (!destRanges) + destRanges = []; + for (var key in sourceRanges) { + destRanges[key] = sourceRanges[key]; + } + return destRanges; + } +})(ts || (ts = {})); +/* @internal */ +(function (ts) { + // Compound nodes function createTypeCheck(value, tag) { return tag === "undefined" - ? createStrictEquality(value, createVoidZero()) - : createStrictEquality(createTypeOf(value), createLiteral(tag)); + ? ts.createStrictEquality(value, ts.createVoidZero()) + : ts.createStrictEquality(ts.createTypeOf(value), ts.createLiteral(tag)); } ts.createTypeCheck = createTypeCheck; function createMemberAccessForPropertyName(target, memberName, location) { if (ts.isComputedPropertyName(memberName)) { - return createElementAccess(target, memberName.expression, location); + return ts.setTextRange(ts.createElementAccess(target, memberName.expression), location); } else { - var expression = ts.isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); - (expression.emitNode || (expression.emitNode = {})).flags |= 64 /* NoNestedSourceMaps */; + var expression = ts.setTextRange(ts.isIdentifier(memberName) + ? ts.createPropertyAccess(target, memberName) + : ts.createElementAccess(target, memberName), memberName); + ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; return expression; } } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createFunctionCall(func, thisArg, argumentsList, location) { - return createCall(createPropertyAccess(func, "call"), + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), /*typeArguments*/ undefined, [ thisArg - ].concat(argumentsList), location); + ].concat(argumentsList)), location); } ts.createFunctionCall = createFunctionCall; function createFunctionApply(func, thisArg, argumentsExpression, location) { - return createCall(createPropertyAccess(func, "apply"), + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "apply"), /*typeArguments*/ undefined, [ thisArg, argumentsExpression - ], location); + ]), location); } ts.createFunctionApply = createFunctionApply; function createArraySlice(array, start) { var argumentsList = []; if (start !== undefined) { - argumentsList.push(typeof start === "number" ? createLiteral(start) : start); + argumentsList.push(typeof start === "number" ? ts.createLiteral(start) : start); } - return createCall(createPropertyAccess(array, "slice"), /*typeArguments*/ undefined, argumentsList); + return ts.createCall(ts.createPropertyAccess(array, "slice"), /*typeArguments*/ undefined, argumentsList); } ts.createArraySlice = createArraySlice; function createArrayConcat(array, values) { - return createCall(createPropertyAccess(array, "concat"), + return ts.createCall(ts.createPropertyAccess(array, "concat"), /*typeArguments*/ undefined, values); } ts.createArrayConcat = createArrayConcat; function createMathPow(left, right, location) { - return createCall(createPropertyAccess(createIdentifier("Math"), "pow"), - /*typeArguments*/ undefined, [left, right], location); + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Math"), "pow"), + /*typeArguments*/ undefined, [left, right]), location); } ts.createMathPow = createMathPow; function createReactNamespace(reactNamespace, parent) { // To ensure the emit resolver can properly resolve the namespace, we need to // treat this identifier as if it were a source tree node by clearing the `Synthesized` // flag and setting a parent node. - var react = createIdentifier(reactNamespace || "React"); + var react = ts.createIdentifier(reactNamespace || "React"); react.flags &= ~8 /* Synthesized */; // Set the parent that is in parse tree // this makes sure that parent chain is intact for checker to traverse complete scope tree @@ -12264,9 +12920,9 @@ var ts; function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { if (ts.isQualifiedName(jsxFactory)) { var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent); - var right = createSynthesizedNode(70 /* Identifier */); + var right = ts.createIdentifier(jsxFactory.right.text); right.text = jsxFactory.right.text; - return createPropertyAccess(left, right); + return ts.createPropertyAccess(left, right); } else { return createReactNamespace(jsxFactory.text, parent); @@ -12275,7 +12931,7 @@ var ts; function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { return jsxFactoryEntity ? createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : - createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); + ts.createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); } function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { var argumentsList = [tagName]; @@ -12284,7 +12940,7 @@ var ts; } if (children && children.length > 0) { if (!props) { - argumentsList.push(createNull()); + argumentsList.push(ts.createNull()); } if (children.length > 1) { for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { @@ -12297,35 +12953,29 @@ var ts; argumentsList.push(children[0]); } } - return createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), - /*typeArguments*/ undefined, argumentsList, location); + return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), + /*typeArguments*/ undefined, argumentsList), location); } ts.createExpressionForJsxElement = createExpressionForJsxElement; - function createExportDefault(expression) { - return createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportEquals*/ false, expression); - } - ts.createExportDefault = createExportDefault; - function createExternalModuleExport(exportName) { - return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(exportName)])); - } - ts.createExternalModuleExport = createExternalModuleExport; - function createLetStatement(name, initializer, location) { - return createVariableStatement(/*modifiers*/ undefined, createLetDeclarationList([createVariableDeclaration(name, /*type*/ undefined, initializer)]), location); - } - ts.createLetStatement = createLetStatement; - function createLetDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 1 /* Let */); - } - ts.createLetDeclarationList = createLetDeclarationList; - function createConstDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 2 /* Const */); - } - ts.createConstDeclarationList = createConstDeclarationList; // Helpers function getHelperName(name) { - return setEmitFlags(createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); + return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } ts.getHelperName = getHelperName; + // Utilities + function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { + if (!outermostLabeledStatement) { + return node; + } + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 221 /* LabeledStatement */ + ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) + : node); + if (afterRestoreLabelCallback) { + afterRestoreLabelCallback(outermostLabeledStatement); + } + return updated; + } + ts.restoreEnclosingLabel = restoreEnclosingLabel; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { @@ -12335,13 +12985,13 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -12352,22 +13002,23 @@ var ts; var thisArg; var target; if (ts.isSuperProperty(callee)) { - thisArg = createThis(); + thisArg = ts.createThis(); target = callee; } else if (callee.kind === 96 /* SuperKeyword */) { - thisArg = createThis(); - target = languageVersion < 2 /* ES2015 */ ? createIdentifier("_super", /*location*/ callee) : callee; + thisArg = ts.createThis(); + target = languageVersion < 2 /* ES2015 */ + ? ts.setTextRange(ts.createIdentifier("_super"), callee) + : callee; } else { switch (callee.kind) { - case 177 /* PropertyAccessExpression */: { + case 178 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` - thisArg = createTempVariable(recordTempVariable); - target = createPropertyAccess(createAssignment(thisArg, callee.expression, - /*location*/ callee.expression), callee.name, - /*location*/ callee); + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); + ts.setTextRange(target, callee); } else { thisArg = callee.expression; @@ -12375,13 +13026,12 @@ var ts; } break; } - case 178 /* ElementAccessExpression */: { + case 179 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` - thisArg = createTempVariable(recordTempVariable); - target = createElementAccess(createAssignment(thisArg, callee.expression, - /*location*/ callee.expression), callee.argumentExpression, - /*location*/ callee); + thisArg = ts.createTempVariable(recordTempVariable); + target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); + ts.setTextRange(target, callee); } else { thisArg = callee.expression; @@ -12391,7 +13041,7 @@ var ts; } default: { // for `a()` target is `a` and thisArg is `void 0` - thisArg = createVoidZero(); + thisArg = ts.createVoidZero(); target = parenthesizeForAccess(expression); break; } @@ -12401,42 +13051,42 @@ var ts; } ts.createCallBinding = createCallBinding; function inlineExpressions(expressions) { - return ts.reduceLeft(expressions, createComma); + return ts.reduceLeft(expressions, ts.createComma); } ts.inlineExpressions = inlineExpressions; function createExpressionFromEntityName(node) { if (ts.isQualifiedName(node)) { var left = createExpressionFromEntityName(node.left); - var right = getMutableClone(node.right); - return createPropertyAccess(left, right, /*location*/ node); + var right = ts.getMutableClone(node.right); + return ts.setTextRange(ts.createPropertyAccess(left, right), node); } else { - return getMutableClone(node); + return ts.getMutableClone(node); } } ts.createExpressionFromEntityName = createExpressionFromEntityName; function createExpressionForPropertyName(memberName) { if (ts.isIdentifier(memberName)) { - return createLiteral(memberName, /*location*/ undefined); + return ts.createLiteral(memberName); } else if (ts.isComputedPropertyName(memberName)) { - return getMutableClone(memberName.expression); + return ts.getMutableClone(memberName.expression); } else { - return getMutableClone(memberName); + return ts.getMutableClone(memberName); } } ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 257 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 258 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -12446,57 +13096,55 @@ var ts; if (property === firstAccessor) { var properties_1 = []; if (getAccessor) { - var getterFunction = createFunctionExpression(getAccessor.modifiers, + var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, getAccessor.parameters, - /*type*/ undefined, getAccessor.body, - /*location*/ getAccessor); - setOriginalNode(getterFunction, getAccessor); - var getter = createPropertyAssignment("get", getterFunction); + /*type*/ undefined, getAccessor.body); + ts.setTextRange(getterFunction, getAccessor); + ts.setOriginalNode(getterFunction, getAccessor); + var getter = ts.createPropertyAssignment("get", getterFunction); properties_1.push(getter); } if (setAccessor) { - var setterFunction = createFunctionExpression(setAccessor.modifiers, + var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, setAccessor.parameters, - /*type*/ undefined, setAccessor.body, - /*location*/ setAccessor); - setOriginalNode(setterFunction, setAccessor); - var setter = createPropertyAssignment("set", setterFunction); + /*type*/ undefined, setAccessor.body); + ts.setTextRange(setterFunction, setAccessor); + ts.setOriginalNode(setterFunction, setAccessor); + var setter = ts.createPropertyAssignment("set", setterFunction); properties_1.push(setter); } - properties_1.push(createPropertyAssignment("enumerable", createLiteral(true))); - properties_1.push(createPropertyAssignment("configurable", createLiteral(true))); - var expression = createCall(createPropertyAccess(createIdentifier("Object"), "defineProperty"), + properties_1.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_1.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ receiver, createExpressionForPropertyName(property.name), - createObjectLiteral(properties_1, /*location*/ undefined, multiLine) - ], + ts.createObjectLiteral(properties_1, multiLine) + ]), /*location*/ firstAccessor); return ts.aggregateTransformFlags(expression); } return undefined; } function createExpressionForPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), property.initializer, - /*location*/ property), - /*original*/ property)); + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), property.initializer), property), property)); } function createExpressionForShorthandPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), getSynthesizedClone(property.name), + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), ts.getSynthesizedClone(property.name)), /*location*/ property), /*original*/ property)); } function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, + return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(method.modifiers, method.asteriskToken, /*name*/ undefined, /*typeParameters*/ undefined, method.parameters, - /*type*/ undefined, method.body, + /*type*/ undefined, method.body), /*location*/ method), - /*original*/ method), + /*original*/ method)), /*location*/ method), /*original*/ method)); } @@ -12518,7 +13166,7 @@ var ts; * Gets whether an identifier should only be referred to by its local name. */ function isLocalName(node) { - return (getEmitFlags(node) & 16384 /* LocalName */) !== 0; + return (ts.getEmitFlags(node) & 16384 /* LocalName */) !== 0; } ts.isLocalName = isLocalName; /** @@ -12540,7 +13188,7 @@ var ts; * name points to an exported symbol. */ function isExportName(node) { - return (getEmitFlags(node) & 8192 /* ExportName */) !== 0; + return (ts.getEmitFlags(node) & 8192 /* ExportName */) !== 0; } ts.isExportName = isExportName; /** @@ -12556,17 +13204,17 @@ var ts; ts.getDeclarationName = getDeclarationName; function getName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { - var name_8 = getMutableClone(node.name); - emitFlags |= getEmitFlags(node.name); + var name = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) emitFlags |= 48 /* NoSourceMap */; if (!allowComments) emitFlags |= 1536 /* NoComments */; if (emitFlags) - setEmitFlags(name_8, emitFlags); - return name_8; + ts.setEmitFlags(name, emitFlags); + return name; } - return getGeneratedNameForNode(node); + return ts.getGeneratedNameForNode(node); } /** * Gets the exported name of a declaration for use in expressions. @@ -12595,19 +13243,20 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { - var qualifiedName = createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : getSynthesizedClone(name), /*location*/ name); + var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name)); + ts.setTextRange(qualifiedName, name); var emitFlags; if (!allowSourceMaps) emitFlags |= 48 /* NoSourceMap */; if (!allowComments) emitFlags |= 1536 /* NoComments */; if (emitFlags) - setEmitFlags(qualifiedName, emitFlags); + ts.setEmitFlags(qualifiedName, emitFlags); return qualifiedName; } ts.getNamespaceMemberName = getNamespaceMemberName; function convertToFunctionBody(node, multiLine) { - return ts.isBlock(node) ? node : createBlock([createReturn(node, /*location*/ node)], /*location*/ node, multiLine); + return ts.isBlock(node) ? node : ts.setTextRange(ts.createBlock([ts.setTextRange(ts.createReturn(node), node)], multiLine), node); } ts.convertToFunctionBody = convertToFunctionBody; function isUseStrictPrologue(node) { @@ -12643,11 +13292,11 @@ var ts; statementOffset++; } if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); + target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))); } while (statementOffset < numStatements) { var statement = source[statementOffset]; - if (getEmitFlags(statement) & 524288 /* CustomPrologue */) { + if (ts.getEmitFlags(statement) & 524288 /* CustomPrologue */) { target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -12685,9 +13334,9 @@ var ts; } } if (!foundUseStrict) { - return createNodeArray([ - startOnNewLine(createStatement(createLiteral("use strict"))) - ].concat(statements), statements); + return ts.setTextRange(ts.createNodeArray([ + startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) + ].concat(statements)), statements); } return statements; } @@ -12704,11 +13353,11 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 183 /* ParenthesizedExpression */) { + if (skipped.kind === 184 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) - ? createParen(operand) + ? ts.createParen(operand) : operand; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; @@ -12738,8 +13387,8 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(192 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(192 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(193 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(193 /* BinaryExpression */, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -12748,7 +13397,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 195 /* YieldExpression */) { + && operand.kind === 196 /* YieldExpression */) { return false; } return true; @@ -12836,7 +13485,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 192 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { + if (node.kind === 193 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -12851,11 +13500,11 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(193 /* ConditionalExpression */, 54 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(194 /* ConditionalExpression */, 54 /* QuestionToken */); var emittedCondition = skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { - return createParen(condition); + return ts.createParen(condition); } return condition; } @@ -12864,10 +13513,11 @@ var ts; // per ES grammar both 'whenTrue' and 'whenFalse' parts of conditional expression are assignment expressions // so in case when comma expression is introduced as a part of previous transformations // if should be wrapped in parens since comma operator has the lowest precedence - return e.kind === 192 /* BinaryExpression */ && e.operatorToken.kind === 25 /* CommaToken */ - ? createParen(e) + return e.kind === 193 /* BinaryExpression */ && e.operatorToken.kind === 25 /* CommaToken */ + ? ts.createParen(e) : e; } + ts.parenthesizeSubexpressionOfConditionalExpression = parenthesizeSubexpressionOfConditionalExpression; /** * Wraps an expression in parentheses if it is needed in order to use the expression * as the expression of a NewExpression node. @@ -12877,12 +13527,12 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 179 /* CallExpression */: - return createParen(expression); - case 180 /* NewExpression */: + case 180 /* CallExpression */: + return ts.createParen(expression); + case 181 /* NewExpression */: return emittedExpression.arguments ? expression - : createParen(expression); + : ts.createParen(expression); } return parenthesizeForAccess(expression); } @@ -12904,23 +13554,23 @@ var ts; // var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 180 /* NewExpression */ || emittedExpression.arguments) + && (emittedExpression.kind !== 181 /* NewExpression */ || emittedExpression.arguments) && emittedExpression.kind !== 8 /* NumericLiteral */) { return expression; } - return createParen(expression, /*location*/ expression); + return ts.setTextRange(ts.createParen(expression), expression); } ts.parenthesizeForAccess = parenthesizeForAccess; function parenthesizePostfixOperand(operand) { return ts.isLeftHandSideExpression(operand) ? operand - : createParen(operand, /*location*/ operand); + : ts.setTextRange(ts.createParen(operand), operand); } ts.parenthesizePostfixOperand = parenthesizePostfixOperand; function parenthesizePrefixOperand(operand) { return ts.isUnaryExpression(operand) ? operand - : createParen(operand, /*location*/ operand); + : ts.setTextRange(ts.createParen(operand), operand); } ts.parenthesizePrefixOperand = parenthesizePrefixOperand; function parenthesizeListElements(elements) { @@ -12935,17 +13585,18 @@ var ts; } } if (result !== undefined) { - return createNodeArray(result, elements, elements.hasTrailingComma); + return ts.setTextRange(ts.createNodeArray(result, elements.hasTrailingComma), elements); } return elements; } + ts.parenthesizeListElements = parenthesizeListElements; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(192 /* BinaryExpression */, 25 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(193 /* BinaryExpression */, 25 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression - : createParen(expression, /*location*/ expression); + : ts.setTextRange(ts.createParen(expression), expression); } ts.parenthesizeExpressionForList = parenthesizeExpressionForList; function parenthesizeExpressionForExpressionStatement(expression) { @@ -12953,16 +13604,16 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 184 /* FunctionExpression */ || kind === 185 /* ArrowFunction */) { - var mutableCall = getMutableClone(emittedExpression); - mutableCall.expression = createParen(callee, /*location*/ callee); + if (kind === 185 /* FunctionExpression */ || kind === 186 /* ArrowFunction */) { + var mutableCall = ts.getMutableClone(emittedExpression); + mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); } } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 176 /* ObjectLiteralExpression */ || leftmostExpressionKind === 184 /* FunctionExpression */) { - return createParen(expression, /*location*/ expression); + if (leftmostExpressionKind === 177 /* ObjectLiteralExpression */ || leftmostExpressionKind === 185 /* FunctionExpression */) { + return ts.setTextRange(ts.createParen(expression), expression); } } return expression; @@ -12976,7 +13627,7 @@ var ts; */ function recreatePartiallyEmittedExpressions(originalOuterExpression, newInnerExpression) { if (ts.isPartiallyEmittedExpression(originalOuterExpression)) { - var clone_1 = getMutableClone(originalOuterExpression); + var clone_1 = ts.getMutableClone(originalOuterExpression); clone_1.expression = recreatePartiallyEmittedExpressions(clone_1.expression, newInnerExpression); return clone_1; } @@ -12985,21 +13636,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: node = node.operand; continue; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: node = node.left; continue; - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: node = node.condition; continue; - case 179 /* CallExpression */: - case 178 /* ElementAccessExpression */: - case 177 /* PropertyAccessExpression */: + case 180 /* CallExpression */: + case 179 /* ElementAccessExpression */: + case 178 /* PropertyAccessExpression */: node = node.expression; continue; - case 294 /* PartiallyEmittedExpression */: + case 298 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -13008,8 +13659,8 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 176 /* ObjectLiteralExpression */) { - return createParen(body, /*location*/ body); + if (emittedBody.kind === 177 /* ObjectLiteralExpression */) { + return ts.setTextRange(ts.createParen(body), body); } return body; } @@ -13040,7 +13691,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 183 /* ParenthesizedExpression */) { + while (node.kind === 184 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -13054,7 +13705,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 294 /* PartiallyEmittedExpression */) { + while (node.kind === 298 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -13065,188 +13716,6 @@ var ts; return node; } ts.startOnNewLine = startOnNewLine; - function setOriginalNode(node, original) { - node.original = original; - if (original) { - var emitNode = original.emitNode; - if (emitNode) - node.emitNode = mergeEmitNode(emitNode, node.emitNode); - } - return node; - } - ts.setOriginalNode = setOriginalNode; - function mergeEmitNode(sourceEmitNode, destEmitNode) { - var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; - if (!destEmitNode) - destEmitNode = {}; - if (flags) - destEmitNode.flags = flags; - if (commentRange) - destEmitNode.commentRange = commentRange; - if (sourceMapRange) - destEmitNode.sourceMapRange = sourceMapRange; - if (tokenSourceMapRanges) - destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); - if (constantValue !== undefined) - destEmitNode.constantValue = constantValue; - if (helpers) - destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); - return destEmitNode; - } - function mergeTokenSourceMapRanges(sourceRanges, destRanges) { - if (!destRanges) - destRanges = ts.createMap(); - ts.copyProperties(sourceRanges, destRanges); - return destRanges; - } - /** - * Clears any EmitNode entries from parse-tree nodes. - * @param sourceFile A source file. - */ - function disposeEmitNodes(sourceFile) { - // During transformation we may need to annotate a parse tree node with transient - // transformation properties. As parse tree nodes live longer than transformation - // nodes, we need to make sure we reclaim any memory allocated for custom ranges - // from these nodes to ensure we do not hold onto entire subtrees just for position - // information. We also need to reset these nodes to a pre-transformation state - // for incremental parsing scenarios so that we do not impact later emit. - sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); - var emitNode = sourceFile && sourceFile.emitNode; - var annotatedNodes = emitNode && emitNode.annotatedNodes; - if (annotatedNodes) { - for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) { - var node = annotatedNodes_1[_i]; - node.emitNode = undefined; - } - } - } - ts.disposeEmitNodes = disposeEmitNodes; - /** - * Associates a node with the current transformation, initializing - * various transient transformation properties. - * - * @param node The node. - */ - function getOrCreateEmitNode(node) { - if (!node.emitNode) { - if (ts.isParseTreeNode(node)) { - // To avoid holding onto transformation artifacts, we keep track of any - // parse tree node we are annotating. This allows us to clean them up after - // all transformations have completed. - if (node.kind === 261 /* SourceFile */) { - return node.emitNode = { annotatedNodes: [node] }; - } - var sourceFile = ts.getSourceFileOfNode(node); - getOrCreateEmitNode(sourceFile).annotatedNodes.push(node); - } - node.emitNode = {}; - } - return node.emitNode; - } - ts.getOrCreateEmitNode = getOrCreateEmitNode; - /** - * Gets flags that control emit behavior of a node. - * - * @param node The node. - */ - function getEmitFlags(node) { - var emitNode = node.emitNode; - return emitNode && emitNode.flags; - } - ts.getEmitFlags = getEmitFlags; - /** - * Sets flags that control emit behavior of a node. - * - * @param node The node. - * @param emitFlags The NodeEmitFlags for the node. - */ - function setEmitFlags(node, emitFlags) { - getOrCreateEmitNode(node).flags = emitFlags; - return node; - } - ts.setEmitFlags = setEmitFlags; - /** - * Gets a custom text range to use when emitting source maps. - * - * @param node The node. - */ - function getSourceMapRange(node) { - var emitNode = node.emitNode; - return (emitNode && emitNode.sourceMapRange) || node; - } - ts.getSourceMapRange = getSourceMapRange; - /** - * Sets a custom text range to use when emitting source maps. - * - * @param node The node. - * @param range The text range. - */ - function setSourceMapRange(node, range) { - getOrCreateEmitNode(node).sourceMapRange = range; - return node; - } - ts.setSourceMapRange = setSourceMapRange; - /** - * Gets the TextRange to use for source maps for a token of a node. - * - * @param node The node. - * @param token The token. - */ - function getTokenSourceMapRange(node, token) { - var emitNode = node.emitNode; - var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; - return tokenSourceMapRanges && tokenSourceMapRanges[token]; - } - ts.getTokenSourceMapRange = getTokenSourceMapRange; - /** - * Sets the TextRange to use for source maps for a token of a node. - * - * @param node The node. - * @param token The token. - * @param range The text range. - */ - function setTokenSourceMapRange(node, token, range) { - var emitNode = getOrCreateEmitNode(node); - var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = ts.createMap()); - tokenSourceMapRanges[token] = range; - return node; - } - ts.setTokenSourceMapRange = setTokenSourceMapRange; - /** - * Gets a custom text range to use when emitting comments. - * - * @param node The node. - */ - function getCommentRange(node) { - var emitNode = node.emitNode; - return (emitNode && emitNode.commentRange) || node; - } - ts.getCommentRange = getCommentRange; - /** - * Sets a custom text range to use when emitting comments. - */ - function setCommentRange(node, range) { - getOrCreateEmitNode(node).commentRange = range; - return node; - } - ts.setCommentRange = setCommentRange; - /** - * Gets the constant value to emit for an expression. - */ - function getConstantValue(node) { - var emitNode = node.emitNode; - return emitNode && emitNode.constantValue; - } - ts.getConstantValue = getConstantValue; - /** - * Sets the constant value to emit for an expression. - */ - function setConstantValue(node, value) { - var emitNode = getOrCreateEmitNode(node); - emitNode.constantValue = value; - return node; - } - ts.setConstantValue = setConstantValue; function getExternalHelpersModuleName(node) { var parseNode = ts.getOriginalNode(node, ts.isSourceFile); var emitNode = parseNode && parseNode.emitNode; @@ -13259,143 +13728,34 @@ var ts; if (externalHelpersModuleName) { return externalHelpersModuleName; } - var helpers = getEmitHelpers(node); + var helpers = ts.getEmitHelpers(node); if (helpers) { - for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { - var helper = helpers_1[_i]; + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; if (!helper.scoped) { var parseNode = ts.getOriginalNode(node, ts.isSourceFile); - var emitNode = getOrCreateEmitNode(parseNode); - return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = createUniqueName(ts.externalHelpersModuleNameText)); + var emitNode = ts.getOrCreateEmitNode(parseNode); + return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = ts.createUniqueName(ts.externalHelpersModuleNameText)); } } } } } ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded; - /** - * Adds an EmitHelper to a node. - */ - function addEmitHelper(node, helper) { - var emitNode = getOrCreateEmitNode(node); - emitNode.helpers = ts.append(emitNode.helpers, helper); - return node; - } - ts.addEmitHelper = addEmitHelper; - /** - * Adds an EmitHelper to a node. - */ - function addEmitHelpers(node, helpers) { - if (ts.some(helpers)) { - var emitNode = getOrCreateEmitNode(node); - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; - if (!ts.contains(emitNode.helpers, helper)) { - emitNode.helpers = ts.append(emitNode.helpers, helper); - } - } - } - return node; - } - ts.addEmitHelpers = addEmitHelpers; - /** - * Removes an EmitHelper from a node. - */ - function removeEmitHelper(node, helper) { - var emitNode = node.emitNode; - if (emitNode) { - var helpers = emitNode.helpers; - if (helpers) { - return ts.orderedRemoveItem(helpers, helper); - } - } - return false; - } - ts.removeEmitHelper = removeEmitHelper; - /** - * Gets the EmitHelpers of a node. - */ - function getEmitHelpers(node) { - var emitNode = node.emitNode; - return emitNode && emitNode.helpers; - } - ts.getEmitHelpers = getEmitHelpers; - /** - * Moves matching emit helpers from a source node to a target node. - */ - function moveEmitHelpers(source, target, predicate) { - var sourceEmitNode = source.emitNode; - var sourceEmitHelpers = sourceEmitNode && sourceEmitNode.helpers; - if (!ts.some(sourceEmitHelpers)) - return; - var targetEmitNode = getOrCreateEmitNode(target); - var helpersRemoved = 0; - for (var i = 0; i < sourceEmitHelpers.length; i++) { - var helper = sourceEmitHelpers[i]; - if (predicate(helper)) { - helpersRemoved++; - if (!ts.contains(targetEmitNode.helpers, helper)) { - targetEmitNode.helpers = ts.append(targetEmitNode.helpers, helper); - } - } - else if (helpersRemoved > 0) { - sourceEmitHelpers[i - helpersRemoved] = helper; - } - } - if (helpersRemoved > 0) { - sourceEmitHelpers.length -= helpersRemoved; - } - } - ts.moveEmitHelpers = moveEmitHelpers; - function compareEmitHelpers(x, y) { - if (x === y) - return 0 /* EqualTo */; - if (x.priority === y.priority) - return 0 /* EqualTo */; - if (x.priority === undefined) - return 1 /* GreaterThan */; - if (y.priority === undefined) - return -1 /* LessThan */; - return ts.compareValues(x.priority, y.priority); - } - ts.compareEmitHelpers = compareEmitHelpers; - function setTextRange(node, location) { - if (location) { - node.pos = location.pos; - node.end = location.end; - } - return node; - } - ts.setTextRange = setTextRange; - function setNodeFlags(node, flags) { - node.flags = flags; - return node; - } - ts.setNodeFlags = setNodeFlags; - function setMultiLine(node, multiLine) { - node.multiLine = multiLine; - return node; - } - ts.setMultiLine = setMultiLine; - function setHasTrailingComma(nodes, hasTrailingComma) { - nodes.hasTrailingComma = hasTrailingComma; - return nodes; - } - ts.setHasTrailingComma = setHasTrailingComma; /** * Get the name of that target module from an import or export declaration */ function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_9 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 235 /* ImportDeclaration */ && node.importClause) { - return getGeneratedNameForNode(node); + if (node.kind === 237 /* ImportDeclaration */ && node.importClause) { + return ts.getGeneratedNameForNode(node); } - if (node.kind === 241 /* ExportDeclaration */ && node.moduleSpecifier) { - return getGeneratedNameForNode(node); + if (node.kind === 243 /* ExportDeclaration */ && node.moduleSpecifier) { + return ts.getGeneratedNameForNode(node); } return undefined; } @@ -13413,7 +13773,7 @@ var ts; if (moduleName.kind === 9 /* StringLiteral */) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) - || getSynthesizedClone(moduleName); + || ts.getSynthesizedClone(moduleName); } return undefined; } @@ -13423,10 +13783,8 @@ var ts; * Here we check if alternative name was provided for a given moduleName and return it if possible. */ function tryRenameExternalModule(moduleName, sourceFile) { - if (sourceFile.renamedDependencies && ts.hasProperty(sourceFile.renamedDependencies, moduleName.text)) { - return createLiteral(sourceFile.renamedDependencies[moduleName.text]); - } - return undefined; + var rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text); + return rename && ts.createLiteral(rename); } /** * Get the name of a module as should be written in the emitted output. @@ -13440,10 +13798,10 @@ var ts; return undefined; } if (file.moduleName) { - return createLiteral(file.moduleName); + return ts.createLiteral(file.moduleName); } if (!ts.isDeclarationFile(file) && (options.out || options.outFile)) { - return createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); + return ts.createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); } return undefined; } @@ -13514,7 +13872,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 257 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -13526,11 +13884,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 258 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 259 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -13562,12 +13920,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 144 /* Parameter */: - case 174 /* BindingElement */: + case 145 /* Parameter */: + case 175 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 196 /* SpreadElement */: - case 259 /* SpreadAssignment */: + case 197 /* SpreadElement */: + case 262 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -13579,7 +13937,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 174 /* BindingElement */: + case 175 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -13591,7 +13949,7 @@ var ts; : propertyName; } break; - case 257 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -13603,7 +13961,7 @@ var ts; : propertyName; } break; - case 259 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -13621,13 +13979,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: - case 175 /* ArrayLiteralExpression */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: + case 176 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -13637,10 +13995,12 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpread(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpread(element.name), element), element); } var expression = convertToAssignmentElementTarget(element.name); - return element.initializer ? setOriginalNode(createAssignment(expression, element.initializer, element), element) : expression; + return element.initializer + ? ts.setOriginalNode(ts.setTextRange(ts.createAssignment(expression, element.initializer), element), element) + : expression; } ts.Debug.assertNode(element, ts.isExpression); return element; @@ -13650,14 +14010,14 @@ var ts; if (ts.isBindingElement(element)) { if (element.dotDotDotToken) { ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createSpreadAssignment(element.name, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createSpreadAssignment(element.name), element), element); } if (element.propertyName) { var expression = convertToAssignmentElementTarget(element.name); - return setOriginalNode(createPropertyAssignment(element.propertyName, element.initializer ? createAssignment(expression, element.initializer) : expression, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createPropertyAssignment(element.propertyName, element.initializer ? ts.createAssignment(expression, element.initializer) : expression), element), element); } ts.Debug.assertNode(element.name, ts.isIdentifier); - return setOriginalNode(createShorthandPropertyAssignment(element.name, element.initializer, element), element); + return ts.setOriginalNode(ts.setTextRange(ts.createShorthandPropertyAssignment(element.name, element.initializer), element), element); } ts.Debug.assertNode(element, ts.isObjectLiteralElementLike); return element; @@ -13665,18 +14025,18 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 173 /* ArrayBindingPattern */: - case 175 /* ArrayLiteralExpression */: + case 174 /* ArrayBindingPattern */: + case 176 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 172 /* ObjectBindingPattern */: - case 176 /* ObjectLiteralExpression */: + case 173 /* ObjectBindingPattern */: + case 177 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } ts.convertToAssignmentPattern = convertToAssignmentPattern; function convertToObjectAssignmentPattern(node) { if (ts.isObjectBindingPattern(node)) { - return setOriginalNode(createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isObjectLiteralExpression); return node; @@ -13684,7 +14044,7 @@ var ts; ts.convertToObjectAssignmentPattern = convertToObjectAssignmentPattern; function convertToArrayAssignmentPattern(node) { if (ts.isArrayBindingPattern(node)) { - return setOriginalNode(createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement), node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement)), node), node); } ts.Debug.assertNode(node, ts.isArrayLiteralExpression); return node; @@ -13700,37 +14060,37 @@ var ts; ts.convertToAssignmentElementTarget = convertToAssignmentElementTarget; function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) { var externalImports = []; - var exportSpecifiers = ts.createMap(); - var exportedBindings = ts.createMap(); + var exportSpecifiers = ts.createMultiMap(); + var exportedBindings = []; var uniqueExports = ts.createMap(); var exportedNames; var hasExportDefault = false; var exportEquals = undefined; var hasExportStarsToExportValues = false; var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions); - var externalHelpersImportDeclaration = externalHelpersModuleName && createImportDeclaration( + var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, createImportClause(/*name*/ undefined, createNamespaceImport(externalHelpersModuleName)), createLiteral(ts.externalHelpersModuleNameText)); + /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); if (externalHelpersImportDeclaration) { externalImports.push(externalHelpersImportDeclaration); } for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); break; - case 234 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 245 /* ExternalModuleReference */) { + case 236 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 247 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -13746,27 +14106,27 @@ var ts; // export { x, y } for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - if (!uniqueExports[specifier.name.text]) { - var name_10 = specifier.propertyName || specifier.name; - ts.multiMapAdd(exportSpecifiers, name_10.text, specifier); - var decl = resolver.getReferencedImportDeclaration(name_10) - || resolver.getReferencedValueDeclaration(name_10); + if (!uniqueExports.get(specifier.name.text)) { + var name = specifier.propertyName || specifier.name; + exportSpecifiers.add(name.text, specifier); + var decl = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); if (decl) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); } - uniqueExports[specifier.name.text] = true; + uniqueExports.set(specifier.name.text, true); exportedNames = ts.append(exportedNames, specifier.name); } } } break; - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -13774,42 +14134,42 @@ var ts; } } break; - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { // export function x() { } - var name_11 = node.name; - if (!uniqueExports[name_11.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_11); - uniqueExports[name_11.text] = true; - exportedNames = ts.append(exportedNames, name_11); + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); } } } break; - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { // export class x { } - var name_12 = node.name; - if (!uniqueExports[name_12.text]) { - ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_12); - uniqueExports[name_12.text] = true; - exportedNames = ts.append(exportedNames, name_12); + var name = node.name; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, ts.getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); + exportedNames = ts.append(exportedNames, name); } } } @@ -13829,13 +14189,24 @@ var ts; } } else if (!ts.isGeneratedIdentifier(decl.name)) { - if (!uniqueExports[decl.name.text]) { - uniqueExports[decl.name.text] = true; + if (!uniqueExports.get(decl.name.text)) { + uniqueExports.set(decl.name.text, true); exportedNames = ts.append(exportedNames, decl.name); } } return exportedNames; } + /** Use a sparse array as a multi-map. */ + function multiMapSparseArrayAdd(map, key, value) { + var values = map[key]; + if (values) { + values.push(value); + } + else { + map[key] = values = [value]; + } + return values; + } })(ts || (ts = {})); /// /// @@ -13847,13 +14218,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 261 /* SourceFile */) { + if (kind === 264 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 141 /* FirstNode */) { + else if (kind < 142 /* FirstNode */) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -13896,28 +14267,29 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || + visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 258 /* ShorthandPropertyAssignment */: + case 261 /* 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 259 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 144 /* Parameter */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 257 /* PropertyAssignment */: - case 223 /* VariableDeclaration */: - case 174 /* BindingElement */: + case 145 /* Parameter */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 260 /* PropertyAssignment */: + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -13926,24 +14298,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -13954,320 +14326,325 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 161 /* TypeLiteral */: + case 162 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 162 /* ArrayType */: + case 163 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 163 /* TupleType */: + case 164 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 164 /* UnionType */: - case 165 /* IntersectionType */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 166 /* ParenthesizedType */: - case 168 /* TypeOperator */: + case 167 /* ParenthesizedType */: + case 169 /* TypeOperator */: return visitNode(cbNode, node.type); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 170 /* MappedType */: + case 171 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 171 /* LiteralType */: + case 172 /* LiteralType */: return visitNode(cbNode, node.literal); - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 179 /* CallExpression */: - case 180 /* NewExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 182 /* TypeAssertionExpression */: + case 183 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 187 /* TypeOfExpression */: + case 188 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 200 /* AsExpression */: + case 201 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 201 /* NonNullExpression */: + case 202 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 193 /* ConditionalExpression */: + case 203 /* MetaProperty */: + return visitNode(cbNode, node.name); + case 194 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 204 /* Block */: - case 231 /* ModuleBlock */: + case 206 /* Block */: + case 233 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 261 /* SourceFile */: + case 264 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 224 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 208 /* IfStatement */: + case 210 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 209 /* DoStatement */: + case 211 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 210 /* WhileStatement */: + case 212 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 211 /* ForStatement */: + case 213 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 213 /* ForOfStatement */: + case 215 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 214 /* ContinueStatement */: - case 215 /* BreakStatement */: + case 216 /* ContinueStatement */: + case 217 /* BreakStatement */: return visitNode(cbNode, node.label); - case 216 /* ReturnStatement */: + case 218 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 217 /* WithStatement */: + case 219 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 232 /* CaseBlock */: + case 234 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 253 /* CaseClause */: + case 256 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 254 /* DefaultClause */: + case 257 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 220 /* ThrowStatement */: + case 222 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 221 /* TryStatement */: + case 223 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 145 /* Decorator */: + case 146 /* Decorator */: return visitNode(cbNode, node.expression); - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* 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 227 /* InterfaceDeclaration */: + case 229 /* 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 228 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 260 /* EnumMember */: + case 263 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 236 /* ImportClause */: + case 238 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 233 /* NamespaceExportDeclaration */: + case 235 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 237 /* NamespaceImport */: + case 239 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 240 /* NamedImports */: + case 244 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: + case 245 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 202 /* TemplateSpan */: + case 204 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 255 /* HeritageClause */: + case 258 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 245 /* ExternalModuleReference */: + case 247 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 244 /* MissingDeclaration */: + case 246 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 246 /* JsxElement */: + case 248 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 247 /* JsxSelfClosingElement */: - case 248 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + case 250 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || - visitNodes(cbNodes, node.attributes); - case 250 /* JsxAttribute */: + visitNode(cbNode, node.attributes); + case 253 /* JsxAttributes */: + return visitNodes(cbNodes, node.properties); + case 252 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 251 /* JsxSpreadAttribute */: + case 254 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 252 /* JsxExpression */: - return visitNode(cbNode, node.expression); - case 249 /* JsxClosingElement */: + case 255 /* JsxExpression */: + return visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.expression); + case 251 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 262 /* JSDocTypeExpression */: + case 266 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 266 /* JSDocUnionType */: + case 270 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 267 /* JSDocTupleType */: + case 271 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 265 /* JSDocArrayType */: + case 269 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 269 /* JSDocNonNullableType */: + case 273 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 268 /* JSDocNullableType */: + case 272 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 270 /* JSDocRecordType */: + case 274 /* JSDocRecordType */: return visitNode(cbNode, node.literal); - case 272 /* JSDocTypeReference */: + case 276 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 273 /* JSDocOptionalType */: + case 277 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 274 /* JSDocFunctionType */: + case 278 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 275 /* JSDocVariadicType */: + case 279 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 276 /* JSDocConstructorType */: + case 280 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 277 /* JSDocThisType */: + case 281 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 271 /* JSDocRecordMember */: + case 275 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 278 /* JSDocComment */: + case 282 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 281 /* JSDocParameterTag */: + case 285 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 282 /* JSDocReturnTag */: + case 286 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 283 /* JSDocTypeTag */: + case 287 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 280 /* JSDocAugmentsTag */: + case 284 /* JSDocAugmentsTag */: return visitNode(cbNode, node.typeExpression); - case 284 /* JSDocTemplateTag */: + case 288 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); - case 285 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 287 /* JSDocTypeLiteral */: + case 291 /* JSDocTypeLiteral */: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 286 /* JSDocPropertyTag */: + case 290 /* JSDocPropertyTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 294 /* PartiallyEmittedExpression */: + case 298 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); - case 288 /* JSDocLiteralType */: + case 292 /* JSDocLiteralType */: return visitNode(cbNode, node.literal); } } @@ -14539,7 +14916,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(261 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(264 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -14823,7 +15200,7 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 141 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : + return kind >= 142 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : kind === 70 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } @@ -14863,7 +15240,11 @@ var ts; } function internIdentifier(text) { text = ts.escapeIdentifier(text); - return identifiers[text] || (identifiers[text] = text); + var identifier = identifiers.get(text); + if (identifier === undefined) { + identifiers.set(text, identifier = text); + } + return identifier; } // 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 @@ -14915,7 +15296,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(142 /* ComputedPropertyName */); + var node = createNode(143 /* ComputedPropertyName */); parseExpected(20 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -15322,14 +15703,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 150 /* Constructor */: - case 155 /* IndexSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 147 /* PropertyDeclaration */: - case 203 /* SemicolonClassElement */: + case 151 /* Constructor */: + case 156 /* IndexSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 148 /* PropertyDeclaration */: + case 205 /* SemicolonClassElement */: return true; - case 149 /* MethodDeclaration */: + case 150 /* 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. @@ -15344,8 +15725,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 253 /* CaseClause */: - case 254 /* DefaultClause */: + case 256 /* CaseClause */: + case 257 /* DefaultClause */: return true; } } @@ -15354,58 +15735,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: - case 205 /* VariableStatement */: - case 204 /* Block */: - case 208 /* IfStatement */: - case 207 /* ExpressionStatement */: - case 220 /* ThrowStatement */: - case 216 /* ReturnStatement */: - case 218 /* SwitchStatement */: - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 211 /* ForStatement */: - case 210 /* WhileStatement */: - case 217 /* WithStatement */: - case 206 /* EmptyStatement */: - case 221 /* TryStatement */: - case 219 /* LabeledStatement */: - case 209 /* DoStatement */: - case 222 /* DebuggerStatement */: - case 235 /* ImportDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 241 /* ExportDeclaration */: - case 240 /* ExportAssignment */: - case 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 227 /* FunctionDeclaration */: + case 207 /* VariableStatement */: + case 206 /* Block */: + case 210 /* IfStatement */: + case 209 /* ExpressionStatement */: + case 222 /* ThrowStatement */: + case 218 /* ReturnStatement */: + case 220 /* SwitchStatement */: + case 217 /* BreakStatement */: + case 216 /* ContinueStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 213 /* ForStatement */: + case 212 /* WhileStatement */: + case 219 /* WithStatement */: + case 208 /* EmptyStatement */: + case 223 /* TryStatement */: + case 221 /* LabeledStatement */: + case 211 /* DoStatement */: + case 224 /* DebuggerStatement */: + case 237 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 243 /* ExportDeclaration */: + case 242 /* ExportAssignment */: + case 232 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 230 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 260 /* EnumMember */; + return node.kind === 263 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 154 /* ConstructSignature */: - case 148 /* MethodSignature */: - case 155 /* IndexSignature */: - case 146 /* PropertySignature */: - case 153 /* CallSignature */: + case 155 /* ConstructSignature */: + case 149 /* MethodSignature */: + case 156 /* IndexSignature */: + case 147 /* PropertySignature */: + case 154 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 223 /* VariableDeclaration */) { + if (node.kind !== 225 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -15426,7 +15807,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 144 /* Parameter */) { + if (node.kind !== 145 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -15539,7 +15920,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(22 /* DotToken */)) { - var node = createNode(141 /* QualifiedName */, entity.pos); // !!! + var node = createNode(142 /* QualifiedName */, entity.pos); // !!! node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -15578,7 +15959,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(194 /* TemplateExpression */); + var template = createNode(195 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -15590,7 +15971,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(202 /* TemplateSpan */); + var span = createNode(204 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17 /* CloseBraceToken */) { @@ -15645,7 +16026,7 @@ var ts; // TYPES function parseTypeReference() { var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - var node = createNode(157 /* TypeReference */, typeName.pos); + var node = createNode(158 /* TypeReference */, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token() === 26 /* LessThanToken */) { node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); @@ -15654,24 +16035,24 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(156 /* TypePredicate */, lhs.pos); + var node = createNode(157 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(167 /* ThisType */); + var node = createNode(168 /* ThisType */); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(160 /* TypeQuery */); + var node = createNode(161 /* TypeQuery */); parseExpected(102 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(143 /* TypeParameter */); + var node = createNode(144 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(84 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -15692,6 +16073,9 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } + if (parseOptional(57 /* EqualsToken */)) { + node.default = parseType(); + } return finishNode(node); } function parseTypeParameters() { @@ -15709,7 +16093,7 @@ var ts; return token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 /* AtToken */ || token() === 98 /* ThisKeyword */; } function parseParameter() { - var node = createNode(144 /* Parameter */); + var node = createNode(145 /* Parameter */); if (token() === 98 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true, undefined); node.type = parseParameterType(); @@ -15808,7 +16192,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 154 /* ConstructSignature */) { + if (kind === 155 /* ConstructSignature */) { parseExpected(93 /* NewKeyword */); } fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -15872,7 +16256,7 @@ var ts; return token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */ || token() === 21 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(155 /* IndexSignature */, fullStart); + var node = createNode(156 /* IndexSignature */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); @@ -15884,7 +16268,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(54 /* QuestionToken */); if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { - var method = createNode(148 /* MethodSignature */, fullStart); + var method = createNode(149 /* MethodSignature */, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; @@ -15895,7 +16279,7 @@ var ts; return addJSDocComment(finishNode(method)); } else { - var property = createNode(146 /* PropertySignature */, fullStart); + var property = createNode(147 /* PropertySignature */, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; @@ -15944,10 +16328,10 @@ var ts; } function parseTypeMember() { if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { - return parseSignatureMember(153 /* CallSignature */); + return parseSignatureMember(154 /* CallSignature */); } if (token() === 93 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(154 /* ConstructSignature */); + return parseSignatureMember(155 /* ConstructSignature */); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -15961,7 +16345,7 @@ var ts; return token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(161 /* TypeLiteral */); + var node = createNode(162 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -15984,14 +16368,14 @@ var ts; return token() === 20 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 91 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(143 /* TypeParameter */); + var node = createNode(144 /* TypeParameter */); node.name = parseIdentifier(); parseExpected(91 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(170 /* MappedType */); + var node = createNode(171 /* MappedType */); parseExpected(16 /* OpenBraceToken */); node.readonlyToken = parseOptionalToken(130 /* ReadonlyKeyword */); parseExpected(20 /* OpenBracketToken */); @@ -16004,12 +16388,12 @@ var ts; return finishNode(node); } function parseTupleType() { - var node = createNode(163 /* TupleType */); + var node = createNode(164 /* TupleType */); node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(166 /* ParenthesizedType */); + var node = createNode(167 /* ParenthesizedType */); parseExpected(18 /* OpenParenToken */); node.type = parseType(); parseExpected(19 /* CloseParenToken */); @@ -16017,7 +16401,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 159 /* ConstructorType */) { + if (kind === 160 /* ConstructorType */) { parseExpected(93 /* NewKeyword */); } fillSignature(35 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -16028,7 +16412,7 @@ var ts; return token() === 22 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(171 /* LiteralType */); + var node = createNode(172 /* LiteralType */); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -16039,12 +16423,13 @@ var ts; function parseNonArrayType() { switch (token()) { case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: - case 137 /* UndefinedKeyword */: + case 136 /* SymbolKeyword */: + case 138 /* UndefinedKeyword */: case 129 /* NeverKeyword */: + case 133 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); @@ -16082,12 +16467,12 @@ var ts; function isStartOfType() { switch (token()) { case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: case 94 /* NullKeyword */: case 98 /* ThisKeyword */: case 102 /* TypeOfKeyword */: @@ -16102,6 +16487,7 @@ var ts; case 8 /* NumericLiteral */: case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: + case 133 /* ObjectKeyword */: return true; case 37 /* MinusToken */: return lookAhead(nextTokenIsNumericLiteral); @@ -16121,14 +16507,14 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(20 /* OpenBracketToken */)) { if (isStartOfType()) { - var node = createNode(169 /* IndexedAccessType */, type.pos); + var node = createNode(170 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(21 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(162 /* ArrayType */, type.pos); + var node = createNode(163 /* ArrayType */, type.pos); node.elementType = type; parseExpected(21 /* CloseBracketToken */); type = finishNode(node); @@ -16137,7 +16523,7 @@ var ts; return type; } function parseTypeOperator(operator) { - var node = createNode(168 /* TypeOperator */); + var node = createNode(169 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); @@ -16166,10 +16552,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(165 /* IntersectionType */, parseTypeOperatorOrHigher, 47 /* AmpersandToken */); + return parseUnionOrIntersectionType(166 /* IntersectionType */, parseTypeOperatorOrHigher, 47 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(164 /* UnionType */, parseIntersectionTypeOrHigher, 48 /* BarToken */); + return parseUnionOrIntersectionType(165 /* UnionType */, parseIntersectionTypeOrHigher, 48 /* BarToken */); } function isStartOfFunctionType() { if (token() === 26 /* LessThanToken */) { @@ -16226,7 +16612,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(156 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(157 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -16249,10 +16635,10 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(158 /* FunctionType */); + return parseFunctionOrConstructorType(159 /* FunctionType */); } if (token() === 93 /* NewKeyword */) { - return parseFunctionOrConstructorType(159 /* ConstructorType */); + return parseFunctionOrConstructorType(160 /* ConstructorType */); } return parseUnionTypeOrHigher(); } @@ -16453,7 +16839,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(195 /* YieldExpression */); + var node = createNode(196 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -16475,13 +16861,13 @@ var ts; ts.Debug.assert(token() === 35 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(185 /* ArrowFunction */, asyncModifier.pos); + node = createNode(186 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(185 /* ArrowFunction */, identifier.pos); + node = createNode(186 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(144 /* Parameter */, identifier.pos); + var parameter = createNode(145 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); @@ -16663,7 +17049,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(185 /* ArrowFunction */); + var node = createNode(186 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); // Arrow functions are never generators. @@ -16729,7 +17115,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(193 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(194 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -16742,7 +17128,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 /* InKeyword */ || t === 140 /* OfKeyword */; + return t === 91 /* InKeyword */ || t === 141 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -16850,39 +17236,39 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(192 /* BinaryExpression */, left.pos); + var node = createNode(193 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(200 /* AsExpression */, left.pos); + var node = createNode(201 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(190 /* PrefixUnaryExpression */); + var node = createNode(191 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(186 /* DeleteExpression */); + var node = createNode(187 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(187 /* TypeOfExpression */); + var node = createNode(188 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(188 /* VoidExpression */); + var node = createNode(189 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -16898,7 +17284,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(189 /* AwaitExpression */); + var node = createNode(190 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -16941,7 +17327,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === 39 /* AsteriskAsteriskToken */) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 182 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 183 /* 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 { @@ -17037,7 +17423,7 @@ var ts; */ function parseIncrementExpression() { if (token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) { - var node = createNode(190 /* PrefixUnaryExpression */); + var node = createNode(191 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -17050,7 +17436,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(191 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(192 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -17154,7 +17540,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(177 /* PropertyAccessExpression */, expression.pos); + var node = createNode(178 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(22 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -17179,8 +17565,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 248 /* JsxOpeningElement */) { - var node = createNode(246 /* JsxElement */, opening.pos); + if (opening.kind === 250 /* JsxOpeningElement */) { + var node = createNode(248 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -17190,7 +17576,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 247 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 249 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -17205,7 +17591,7 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(192 /* BinaryExpression */, result.pos); + var badNode = createNode(193 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -17254,17 +17640,22 @@ var ts; parsingContext = saveParsingContext; return result; } + function parseJsxAttributes() { + var jsxAttributes = createNode(253 /* JsxAttributes */); + jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); + return finishNode(jsxAttributes); + } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); parseExpected(26 /* LessThanToken */); var tagName = parseJsxElementName(); - var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); + var attributes = parseJsxAttributes(); var node; if (token() === 28 /* GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(248 /* JsxOpeningElement */, fullStart); + node = createNode(250 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -17276,7 +17667,7 @@ var ts; parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(247 /* JsxSelfClosingElement */, fullStart); + node = createNode(249 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -17292,7 +17683,7 @@ var ts; var expression = token() === 98 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22 /* DotToken */)) { - var propertyAccess = createNode(177 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(178 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -17300,9 +17691,10 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(252 /* JsxExpression */); + var node = createNode(255 /* JsxExpression */); parseExpected(16 /* OpenBraceToken */); if (token() !== 17 /* CloseBraceToken */) { + node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { @@ -17319,7 +17711,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(250 /* JsxAttribute */); + var node = createNode(252 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 57 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -17334,7 +17726,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(251 /* JsxSpreadAttribute */); + var node = createNode(254 /* JsxSpreadAttribute */); parseExpected(16 /* OpenBraceToken */); parseExpected(23 /* DotDotDotToken */); node.expression = parseExpression(); @@ -17342,7 +17734,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(249 /* JsxClosingElement */); + var node = createNode(251 /* JsxClosingElement */); parseExpected(27 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -17355,7 +17747,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(182 /* TypeAssertionExpression */); + var node = createNode(183 /* TypeAssertionExpression */); parseExpected(26 /* LessThanToken */); node.type = parseType(); parseExpected(28 /* GreaterThanToken */); @@ -17366,7 +17758,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(177 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(178 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -17374,14 +17766,14 @@ var ts; } if (token() === 50 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(201 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(202 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(20 /* OpenBracketToken */)) { - var indexedAccess = createNode(178 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(179 /* 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. @@ -17397,7 +17789,7 @@ var ts; continue; } if (token() === 12 /* NoSubstitutionTemplateLiteral */ || token() === 13 /* TemplateHead */) { - var tagExpression = createNode(181 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(182 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -17420,7 +17812,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(179 /* CallExpression */, expression.pos); + var callExpr = createNode(180 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -17428,7 +17820,7 @@ var ts; continue; } else if (token() === 18 /* OpenParenToken */) { - var callExpr = createNode(179 /* CallExpression */, expression.pos); + var callExpr = createNode(180 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -17538,28 +17930,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(183 /* ParenthesizedExpression */); + var node = createNode(184 /* ParenthesizedExpression */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(196 /* SpreadElement */); + var node = createNode(197 /* SpreadElement */); parseExpected(23 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 23 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 25 /* CommaToken */ ? createNode(198 /* OmittedExpression */) : + token() === 25 /* CommaToken */ ? createNode(199 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(175 /* ArrayLiteralExpression */); + var node = createNode(176 /* ArrayLiteralExpression */); parseExpected(20 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17570,10 +17962,10 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(124 /* GetKeyword */)) { - return parseAccessorDeclaration(151 /* GetAccessor */, fullStart, decorators, modifiers); + return parseAccessorDeclaration(152 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(133 /* SetKeyword */)) { - return parseAccessorDeclaration(152 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(134 /* SetKeyword */)) { + return parseAccessorDeclaration(153 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -17581,7 +17973,7 @@ var ts; var fullStart = scanner.getStartPos(); var dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); if (dotDotDotToken) { - var spreadElement = createNode(259 /* SpreadAssignment */, fullStart); + var spreadElement = createNode(262 /* SpreadAssignment */, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -17606,7 +17998,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 /* CommaToken */ || token() === 17 /* CloseBraceToken */ || token() === 57 /* EqualsToken */); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(258 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(261 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57 /* EqualsToken */); @@ -17617,7 +18009,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(257 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(260 /* PropertyAssignment */, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -17627,7 +18019,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(176 /* ObjectLiteralExpression */); + var node = createNode(177 /* ObjectLiteralExpression */); parseExpected(16 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17646,7 +18038,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNode(184 /* FunctionExpression */); + var node = createNode(185 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(88 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); @@ -17668,8 +18060,15 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(180 /* NewExpression */); + var fullStart = scanner.getStartPos(); parseExpected(93 /* NewKeyword */); + if (parseOptional(22 /* DotToken */)) { + var node_1 = createNode(203 /* MetaProperty */, fullStart); + node_1.keywordToken = 93 /* NewKeyword */; + node_1.name = parseIdentifierName(); + return finishNode(node_1); + } + var node = createNode(181 /* NewExpression */, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token() === 18 /* OpenParenToken */) { @@ -17679,7 +18078,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(204 /* Block */); + var node = createNode(206 /* Block */); if (parseExpected(16 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17712,12 +18111,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(206 /* EmptyStatement */); + var node = createNode(208 /* EmptyStatement */); parseExpected(24 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(208 /* IfStatement */); + var node = createNode(210 /* IfStatement */); parseExpected(89 /* IfKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17727,7 +18126,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(209 /* DoStatement */); + var node = createNode(211 /* DoStatement */); parseExpected(80 /* DoKeyword */); node.statement = parseStatement(); parseExpected(105 /* WhileKeyword */); @@ -17742,7 +18141,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(210 /* WhileStatement */); + var node = createNode(212 /* WhileStatement */); parseExpected(105 /* WhileKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17765,21 +18164,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91 /* InKeyword */)) { - var forInStatement = createNode(212 /* ForInStatement */, pos); + var forInStatement = createNode(214 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(140 /* OfKeyword */)) { - var forOfStatement = createNode(213 /* ForOfStatement */, pos); + else if (parseOptional(141 /* OfKeyword */)) { + var forOfStatement = createNode(215 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(211 /* ForStatement */, pos); + var forStatement = createNode(213 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(24 /* SemicolonToken */); if (token() !== 24 /* SemicolonToken */ && token() !== 19 /* CloseParenToken */) { @@ -17797,7 +18196,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 215 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); + parseExpected(kind === 217 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -17805,7 +18204,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(216 /* ReturnStatement */); + var node = createNode(218 /* ReturnStatement */); parseExpected(95 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -17814,7 +18213,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(217 /* WithStatement */); + var node = createNode(219 /* WithStatement */); parseExpected(106 /* WithKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -17823,7 +18222,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(253 /* CaseClause */); + var node = createNode(256 /* CaseClause */); parseExpected(72 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(55 /* ColonToken */); @@ -17831,7 +18230,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(254 /* DefaultClause */); + var node = createNode(257 /* DefaultClause */); parseExpected(78 /* DefaultKeyword */); parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -17841,12 +18240,12 @@ var ts; return token() === 72 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(218 /* SwitchStatement */); + var node = createNode(220 /* SwitchStatement */); parseExpected(97 /* SwitchKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); - var caseBlock = createNode(232 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(234 /* CaseBlock */, scanner.getStartPos()); parseExpected(16 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(17 /* CloseBraceToken */); @@ -17861,7 +18260,7 @@ 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(220 /* ThrowStatement */); + var node = createNode(222 /* ThrowStatement */); parseExpected(99 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -17869,7 +18268,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(221 /* TryStatement */); + var node = createNode(223 /* TryStatement */); parseExpected(101 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 73 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -17882,7 +18281,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(256 /* CatchClause */); + var result = createNode(259 /* CatchClause */); parseExpected(73 /* CatchKeyword */); if (parseExpected(18 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -17892,7 +18291,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(222 /* DebuggerStatement */); + var node = createNode(224 /* DebuggerStatement */); parseExpected(77 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -17904,13 +18303,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 /* Identifier */ && parseOptional(55 /* ColonToken */)) { - var labeledStatement = createNode(219 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(221 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(207 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(209 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -17960,7 +18359,7 @@ var ts; // // could be legal, it would add complexity for very little gain. case 108 /* InterfaceKeyword */: - case 136 /* TypeKeyword */: + case 137 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); case 127 /* ModuleKeyword */: case 128 /* NamespaceKeyword */: @@ -17978,7 +18377,7 @@ var ts; return false; } continue; - case 139 /* GlobalKeyword */: + case 140 /* GlobalKeyword */: nextToken(); return token() === 16 /* OpenBraceToken */ || token() === 70 /* Identifier */ || token() === 83 /* ExportKeyword */; case 90 /* ImportKeyword */: @@ -18040,8 +18439,8 @@ var ts; case 108 /* InterfaceKeyword */: case 127 /* ModuleKeyword */: case 128 /* NamespaceKeyword */: - case 136 /* TypeKeyword */: - case 139 /* GlobalKeyword */: + case 137 /* TypeKeyword */: + case 140 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; case 113 /* PublicKeyword */: @@ -18091,9 +18490,9 @@ var ts; case 87 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 76 /* ContinueKeyword */: - return parseBreakOrContinueStatement(214 /* ContinueStatement */); + return parseBreakOrContinueStatement(216 /* ContinueStatement */); case 71 /* BreakKeyword */: - return parseBreakOrContinueStatement(215 /* BreakStatement */); + return parseBreakOrContinueStatement(217 /* BreakStatement */); case 95 /* ReturnKeyword */: return parseReturnStatement(); case 106 /* WithKeyword */: @@ -18113,7 +18512,7 @@ var ts; return parseDeclaration(); case 119 /* AsyncKeyword */: case 108 /* InterfaceKeyword */: - case 136 /* TypeKeyword */: + case 137 /* TypeKeyword */: case 127 /* ModuleKeyword */: case 128 /* NamespaceKeyword */: case 123 /* DeclareKeyword */: @@ -18127,7 +18526,7 @@ var ts; case 116 /* AbstractKeyword */: case 114 /* StaticKeyword */: case 130 /* ReadonlyKeyword */: - case 139 /* GlobalKeyword */: + case 140 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -18150,11 +18549,11 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 108 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 136 /* TypeKeyword */: + case 137 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 82 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 139 /* GlobalKeyword */: + case 140 /* GlobalKeyword */: case 127 /* ModuleKeyword */: case 128 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -18175,7 +18574,7 @@ var ts; if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(244 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(246 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -18197,16 +18596,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 25 /* CommaToken */) { - return createNode(198 /* OmittedExpression */); + return createNode(199 /* OmittedExpression */); } - var node = createNode(174 /* BindingElement */); + var node = createNode(175 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(174 /* BindingElement */); + var node = createNode(175 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -18222,14 +18621,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(172 /* ObjectBindingPattern */); + var node = createNode(173 /* ObjectBindingPattern */); parseExpected(16 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(17 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(173 /* ArrayBindingPattern */); + var node = createNode(174 /* ArrayBindingPattern */); parseExpected(20 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(21 /* CloseBracketToken */); @@ -18248,7 +18647,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(223 /* VariableDeclaration */); + var node = createNode(225 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -18257,7 +18656,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(224 /* VariableDeclarationList */); + var node = createNode(226 /* VariableDeclarationList */); switch (token()) { case 103 /* VarKeyword */: break; @@ -18280,7 +18679,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() === 140 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 141 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -18295,7 +18694,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(205 /* VariableStatement */, fullStart); + var node = createNode(207 /* VariableStatement */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -18303,7 +18702,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225 /* FunctionDeclaration */, fullStart); + var node = createNode(227 /* FunctionDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88 /* FunctionKeyword */); @@ -18316,7 +18715,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(150 /* Constructor */, pos); + var node = createNode(151 /* Constructor */, pos); node.decorators = decorators; node.modifiers = modifiers; parseExpected(122 /* ConstructorKeyword */); @@ -18325,7 +18724,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(149 /* MethodDeclaration */, fullStart); + var method = createNode(150 /* MethodDeclaration */, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -18338,7 +18737,7 @@ var ts; return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(147 /* PropertyDeclaration */, fullStart); + var property = createNode(148 /* PropertyDeclaration */, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -18431,7 +18830,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 === 133 /* SetKeyword */ || idToken === 124 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 134 /* SetKeyword */ || idToken === 124 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -18461,7 +18860,7 @@ var ts; if (!parseOptional(56 /* AtToken */)) { break; } - var decorator = createNode(145 /* Decorator */, decoratorStart); + var decorator = createNode(146 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -18527,7 +18926,7 @@ var ts; } function parseClassElement() { if (token() === 24 /* SemicolonToken */) { - var result = createNode(203 /* SemicolonClassElement */); + var result = createNode(205 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -18555,8 +18954,8 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_13 = createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_13, /*questionToken*/ undefined); + var name = createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. ts.Debug.fail("Should not have attempted to parse class member declaration."); @@ -18565,10 +18964,10 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 197 /* ClassExpression */); + /*modifiers*/ undefined, 198 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 228 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -18612,7 +19011,7 @@ var ts; } function parseHeritageClause() { if (token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */) { - var node = createNode(255 /* HeritageClause */); + var node = createNode(258 /* HeritageClause */); node.token = token(); nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -18621,7 +19020,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(199 /* ExpressionWithTypeArguments */); + var node = createNode(200 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token() === 26 /* LessThanToken */) { node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); @@ -18635,7 +19034,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227 /* InterfaceDeclaration */, fullStart); + var node = createNode(229 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108 /* InterfaceKeyword */); @@ -18646,10 +19045,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(228 /* TypeAliasDeclaration */, fullStart); + var node = createNode(230 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(136 /* TypeKeyword */); + parseExpected(137 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57 /* EqualsToken */); @@ -18662,13 +19061,13 @@ 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(260 /* EnumMember */, scanner.getStartPos()); + var node = createNode(263 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229 /* EnumDeclaration */, fullStart); + var node = createNode(231 /* EnumDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82 /* EnumKeyword */); @@ -18683,7 +19082,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(231 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(233 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(16 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(17 /* CloseBraceToken */); @@ -18694,7 +19093,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(230 /* ModuleDeclaration */, fullStart); + var node = createNode(232 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -18708,10 +19107,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230 /* ModuleDeclaration */, fullStart); + var node = createNode(232 /* ModuleDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 139 /* GlobalKeyword */) { + if (token() === 140 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -18729,7 +19128,7 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 139 /* GlobalKeyword */) { + if (token() === 140 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -18755,7 +19154,7 @@ var ts; return nextToken() === 40 /* SlashToken */; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(233 /* NamespaceExportDeclaration */, fullStart); + var exportDeclaration = createNode(235 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117 /* AsKeyword */); @@ -18770,11 +19169,11 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 /* CommaToken */ && token() !== 138 /* FromKeyword */) { + if (token() !== 25 /* CommaToken */ && token() !== 139 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(234 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(236 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -18785,7 +19184,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(235 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(237 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; // ImportDeclaration: @@ -18795,7 +19194,7 @@ var ts; token() === 38 /* AsteriskToken */ || token() === 16 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(138 /* FromKeyword */); + parseExpected(139 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -18808,7 +19207,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(236 /* ImportClause */, fullStart); + var importClause = createNode(238 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -18818,7 +19217,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(25 /* CommaToken */)) { - importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(238 /* NamedImports */); + importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(240 /* NamedImports */); } return finishNode(importClause); } @@ -18828,7 +19227,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(245 /* ExternalModuleReference */); + var node = createNode(247 /* ExternalModuleReference */); parseExpected(131 /* RequireKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -18851,7 +19250,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(237 /* NamespaceImport */); + var namespaceImport = createNode(239 /* NamespaceImport */); parseExpected(38 /* AsteriskToken */); parseExpected(117 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -18866,14 +19265,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 238 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 240 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(243 /* ExportSpecifier */); + return parseImportOrExportSpecifier(245 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(239 /* ImportSpecifier */); + return parseImportOrExportSpecifier(241 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -18898,27 +19297,27 @@ var ts; else { node.name = identifierName; } - if (kind === 239 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 241 /* 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(241 /* ExportDeclaration */, fullStart); + var node = createNode(243 /* ExportDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38 /* AsteriskToken */)) { - parseExpected(138 /* FromKeyword */); + parseExpected(139 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(242 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(244 /* 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() === 138 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(138 /* FromKeyword */); + if (token() === 139 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(139 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -18926,7 +19325,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(240 /* ExportAssignment */, fullStart); + var node = createNode(242 /* ExportAssignment */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57 /* EqualsToken */)) { @@ -19008,10 +19407,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 245 /* ExternalModuleReference */ - || node.kind === 235 /* ImportDeclaration */ - || node.kind === 240 /* ExportAssignment */ - || node.kind === 241 /* ExportDeclaration */ + || node.kind === 236 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 247 /* ExternalModuleReference */ + || node.kind === 237 /* ImportDeclaration */ + || node.kind === 242 /* ExportAssignment */ + || node.kind === 243 /* ExportDeclaration */ ? node : undefined; }); @@ -19086,7 +19485,7 @@ var ts; // Parses out a JSDoc type expression. /* @internal */ function parseJSDocTypeExpression() { - var result = createNode(262 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(266 /* JSDocTypeExpression */, scanner.getTokenPos()); parseExpected(16 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(17 /* CloseBraceToken */); @@ -19097,12 +19496,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48 /* BarToken */) { - var unionType = createNode(266 /* JSDocUnionType */, type.pos); + var unionType = createNode(270 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57 /* EqualsToken */) { - var optionalType = createNode(273 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(277 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -19113,20 +19512,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20 /* OpenBracketToken */) { - var arrayType = createNode(265 /* JSDocArrayType */, type.pos); + var arrayType = createNode(269 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21 /* CloseBracketToken */); type = finishNode(arrayType); } else if (token() === 54 /* QuestionToken */) { - var nullableType = createNode(268 /* JSDocNullableType */, type.pos); + var nullableType = createNode(272 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50 /* ExclamationToken */) { - var nonNullableType = createNode(269 /* JSDocNonNullableType */, type.pos); + var nonNullableType = createNode(273 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -19160,14 +19559,15 @@ var ts; case 98 /* ThisKeyword */: return parseJSDocThisType(); case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: case 94 /* NullKeyword */: - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: case 129 /* NeverKeyword */: + case 133 /* ObjectKeyword */: return parseTokenNode(); case 9 /* StringLiteral */: case 8 /* NumericLiteral */: @@ -19178,27 +19578,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(277 /* JSDocThisType */); + var result = createNode(281 /* JSDocThisType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(276 /* JSDocConstructorType */); + var result = createNode(280 /* JSDocConstructorType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(275 /* JSDocVariadicType */); + var result = createNode(279 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(274 /* JSDocFunctionType */); + var result = createNode(278 /* JSDocFunctionType */); nextToken(); parseExpected(18 /* OpenParenToken */); result.parameters = parseDelimitedList(23 /* JSDocFunctionParameters */, parseJSDocParameter); @@ -19211,7 +19611,7 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(144 /* Parameter */); + var parameter = createNode(145 /* Parameter */); parameter.type = parseJSDocType(); if (parseOptional(57 /* EqualsToken */)) { // TODO(rbuckton): Can this be changed to SyntaxKind.QuestionToken? @@ -19220,7 +19620,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(272 /* JSDocTypeReference */); + var result = createNode(276 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); @@ -19255,24 +19655,24 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(141 /* QualifiedName */, left.pos); + var result = createNode(142 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(270 /* JSDocRecordType */); + var result = createNode(274 /* JSDocRecordType */); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(269 /* JSDocNonNullableType */); + var result = createNode(273 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(267 /* JSDocTupleType */); + var result = createNode(271 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(26 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); @@ -19286,7 +19686,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(266 /* JSDocUnionType */); + var result = createNode(270 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19 /* CloseParenToken */); @@ -19302,12 +19702,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(263 /* JSDocAllType */); + var result = createNode(267 /* JSDocAllType */); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(288 /* JSDocLiteralType */); + var result = createNode(292 /* JSDocLiteralType */); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -19330,11 +19730,11 @@ var ts; token() === 28 /* GreaterThanToken */ || token() === 57 /* EqualsToken */ || token() === 48 /* BarToken */) { - var result = createNode(264 /* JSDocUnknownType */, pos); + var result = createNode(268 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(268 /* JSDocNullableType */, pos); + var result = createNode(272 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -19499,7 +19899,7 @@ var ts; content.charCodeAt(start + 3) !== 42 /* asterisk */; } function createJSDocComment() { - var result = createNode(278 /* JSDocComment */, start); + var result = createNode(282 /* JSDocComment */, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -19615,7 +20015,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(279 /* JSDocTag */, atToken.pos); + var result = createNode(283 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -19672,7 +20072,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(281 /* JSDocParameterTag */, atToken.pos); + var result = createNode(285 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -19683,20 +20083,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 282 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 286 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(282 /* JSDocReturnTag */, atToken.pos); + var result = createNode(286 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 287 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(283 /* JSDocTypeTag */, atToken.pos); + var result = createNode(287 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -19711,7 +20111,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), /*length*/ 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(286 /* JSDocPropertyTag */, atToken.pos); + var result = createNode(290 /* JSDocPropertyTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -19720,7 +20120,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(280 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(284 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -19729,25 +20129,30 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(285 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(289 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0); if (typedefTag.fullName) { var rightNode = typedefTag.fullName; - while (rightNode.kind !== 70 /* Identifier */) { + while (true) { + if (rightNode.kind === 70 /* Identifier */ || !rightNode.body) { + // if node is identifier - use it as name + // otherwise use name of the rightmost part that we were able to parse + typedefTag.name = rightNode.kind === 70 /* Identifier */ ? rightNode : rightNode.name; + break; + } rightNode = rightNode.body; } - typedefTag.name = rightNode; } typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 272 /* JSDocTypeReference */) { + if (typeExpression.type.kind === 276 /* JSDocTypeReference */) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70 /* Identifier */) { - var name_14 = jsDocTypeReference.name; - if (name_14.text === "Object") { + var name = jsDocTypeReference.name; + if (name.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -19761,7 +20166,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(291 /* JSDocTypeLiteral */, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -19802,7 +20207,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22 /* DotToken */)) { - var jsDocNamespaceNode = createNode(230 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(232 /* ModuleDeclaration */, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4 /* NestedNamespace */); @@ -19848,20 +20253,20 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 284 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 288 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } // Type parameter list looks like '@template T,U,V' var typeParameters = createNodeArray(); while (true) { - var name_15 = parseJSDocIdentifierName(); + var name = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_15) { + if (!name) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(143 /* TypeParameter */, name_15.pos); - typeParameter.name = name_15; + var typeParameter = createNode(144 /* TypeParameter */, name.pos); + typeParameter.name = name; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25 /* CommaToken */) { @@ -19872,7 +20277,7 @@ var ts; break; } } - var result = createNode(284 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(288 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -20346,7 +20751,7 @@ var ts; 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++) { + for (var i = 0; i < array.length; i++) { var child = array[i]; if (child) { if (child.pos === position) { @@ -20392,16 +20797,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 227 /* InterfaceDeclaration */ || node.kind === 228 /* TypeAliasDeclaration */) { + if (node.kind === 229 /* InterfaceDeclaration */ || node.kind === 230 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 235 /* ImportDeclaration */ || node.kind === 234 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { + else if ((node.kind === 237 /* ImportDeclaration */ || node.kind === 236 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } - else if (node.kind === 231 /* ModuleBlock */) { + else if (node.kind === 233 /* ModuleBlock */) { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -20420,7 +20825,7 @@ var ts; }); return state_1; } - else if (node.kind === 230 /* ModuleDeclaration */) { + else if (node.kind === 232 /* ModuleDeclaration */) { var body = node.body; return body ? getModuleInstanceState(body) : 1 /* Instantiated */; } @@ -20561,7 +20966,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 230 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 232 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -20574,7 +20979,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { var nameExpression = node.name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression)) { @@ -20586,21 +20991,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 150 /* Constructor */: + case 151 /* Constructor */: return "__constructor"; - case 158 /* FunctionType */: - case 153 /* CallSignature */: + case 159 /* FunctionType */: + case 154 /* CallSignature */: return "__call"; - case 159 /* ConstructorType */: - case 154 /* ConstructSignature */: + case 160 /* ConstructorType */: + case 155 /* ConstructSignature */: return "__new"; - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: return "__index"; - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return "__export"; - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2 /* ModuleExports */: // module.exports = ... @@ -20615,22 +21020,22 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 225 /* FunctionDeclaration */: - case 226 /* ClassDeclaration */: + case 227 /* FunctionDeclaration */: + case 228 /* ClassDeclaration */: return ts.hasModifier(node, 512 /* Default */) ? "default" : undefined; - case 274 /* JSDocFunctionType */: + case 278 /* JSDocFunctionType */: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 144 /* Parameter */: + case 145 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 274 /* JSDocFunctionType */); + ts.Debug.assert(node.parent.kind === 278 /* JSDocFunctionType */); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 285 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 205 /* VariableStatement */) { + if (parentNode && parentNode.kind === 207 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -20685,15 +21090,18 @@ var ts; // Otherwise, we'll be merging into a compatible existing symbol (for example when // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. - symbol = symbolTable[name] || (symbolTable[name] = createSymbol(0 /* None */, name)); + symbol = symbolTable.get(name); + if (!symbol) { + symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + } if (name && (includes & 788448 /* Classifiable */)) { - classifiableNames[name] = name; + classifiableNames.set(name, name); } if (symbol.flags & excludes) { if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. - symbol = symbolTable[name] = createSymbol(0 /* None */, name); + symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); } else { if (node.name) { @@ -20717,7 +21125,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 240 /* ExportAssignment */ && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 242 /* ExportAssignment */ && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -20737,7 +21145,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 243 /* ExportSpecifier */ || (node.kind === 234 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 245 /* ExportSpecifier */ || (node.kind === 236 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -20760,7 +21168,7 @@ var ts; // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation // and this case is specially handled. Module augmentations should only be merged with original module definition // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. - var isJSDocTypedefInJSDocNamespace = node.kind === 285 /* JSDocTypedefTag */ && + var isJSDocTypedefInJSDocNamespace = node.kind === 289 /* JSDocTypedefTag */ && node.name && node.name.kind === 70 /* Identifier */ && node.name.isInJSDocNamespace; @@ -20847,7 +21255,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 264 /* SourceFile */) { node.flags |= emitFlags; } if (isIIFE) { @@ -20926,64 +21334,64 @@ var ts; return; } switch (node.kind) { - case 210 /* WhileStatement */: + case 212 /* WhileStatement */: bindWhileStatement(node); break; - case 209 /* DoStatement */: + case 211 /* DoStatement */: bindDoStatement(node); break; - case 211 /* ForStatement */: + case 213 /* ForStatement */: bindForStatement(node); break; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 208 /* IfStatement */: + case 210 /* IfStatement */: bindIfStatement(node); break; - case 216 /* ReturnStatement */: - case 220 /* ThrowStatement */: + case 218 /* ReturnStatement */: + case 222 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: + case 217 /* BreakStatement */: + case 216 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 221 /* TryStatement */: + case 223 /* TryStatement */: bindTryStatement(node); break; - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: bindSwitchStatement(node); break; - case 232 /* CaseBlock */: + case 234 /* CaseBlock */: bindCaseBlock(node); break; - case 253 /* CaseClause */: + case 256 /* CaseClause */: bindCaseClause(node); break; - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: bindLabeledStatement(node); break; - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 179 /* CallExpression */: + case 180 /* CallExpression */: bindCallExpressionFlow(node); break; default: @@ -20995,15 +21403,15 @@ var ts; switch (expr.kind) { case 70 /* Identifier */: case 98 /* ThisKeyword */: - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return hasNarrowableArgument(expr); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return expr.operator === 50 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -21011,7 +21419,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 /* Identifier */ || expr.kind === 98 /* ThisKeyword */ || - expr.kind === 177 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 178 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -21022,14 +21430,14 @@ var ts; } } } - if (expr.expression.kind === 177 /* PropertyAccessExpression */ && + if (expr.expression.kind === 178 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 187 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; + return expr1.kind === 188 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -21050,9 +21458,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 57 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -21147,33 +21555,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 208 /* IfStatement */: - case 210 /* WhileStatement */: - case 209 /* DoStatement */: + case 210 /* IfStatement */: + case 212 /* WhileStatement */: + case 211 /* DoStatement */: return parent.expression === node; - case 211 /* ForStatement */: - case 193 /* ConditionalExpression */: + case 213 /* ForStatement */: + case 194 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 183 /* ParenthesizedExpression */) { + if (node.kind === 184 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 190 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { + else if (node.kind === 191 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 192 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || + return node.kind === 193 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 53 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 183 /* ParenthesizedExpression */ || - node.parent.kind === 190 /* PrefixUnaryExpression */ && + while (node.parent.kind === 184 /* ParenthesizedExpression */ || + node.parent.kind === 191 /* PrefixUnaryExpression */ && node.parent.operator === 50 /* ExclamationToken */) { node = node.parent; } @@ -21215,7 +21623,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 219 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 221 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -21252,7 +21660,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 224 /* VariableDeclarationList */) { + if (node.initializer.kind !== 226 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -21274,7 +21682,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 216 /* ReturnStatement */) { + if (node.kind === 218 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -21294,7 +21702,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 215 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 217 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -21330,7 +21738,32 @@ var ts; if (node.finallyBlock) { // in finally flow is combined from pre-try/flow from try/flow from catch // pre-flow is necessary to make sure that finally is reachable even if finally flows in both try and finally blocks are unreachable - addAntecedent(preFinallyLabel, preTryFlow); + // also for finally blocks we inject two extra edges into the flow graph. + // first -> edge that connects pre-try flow with the label at the beginning of the finally block, it has lock associated with it + // second -> edge that represents post-finally flow. + // these edges are used in following scenario: + // let a; (1) + // try { a = someOperation(); (2)} + // finally { (3) console.log(a) } (4) + // (5) a + // flow graph for this case looks roughly like this (arrows show ): + // (1-pre-try-flow) <--.. <-- (2-post-try-flow) + // ^ ^ + // |*****(3-pre-finally-label) -----| + // ^ + // |-- ... <-- (4-post-finally-label) <--- (5) + // In case when we walk the flow starting from inside the finally block we want to take edge '*****' into account + // since it ensures that finally is always reachable. However when we start outside the finally block and go through label (5) + // then edge '*****' should be discarded because label 4 is only reachable if post-finally label-4 is reachable + // Simply speaking code inside finally block is treated as reachable as pre-try-flow + // since we conservatively assume that any line in try block can throw or return in which case we'll enter finally. + // However code after finally is reachable only if control flow was not abrupted in try/catch or finally blocks - it should be composed from + // final flows of these blocks without taking pre-try flow into account. + // + // extra edges that we inject allows to control this behavior + // if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped. + var preFinallyFlow = { flags: 2048 /* PreFinally */, antecedent: preTryFlow, lock: {} }; + addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); // if flow after finally is unreachable - keep it @@ -21346,6 +21779,11 @@ var ts; : unreachableFlow; } } + if (!(currentFlow.flags & 1 /* Unreachable */)) { + var afterFinallyFlow = { flags: 4096 /* AfterFinally */, antecedent: currentFlow }; + preFinallyFlow.lock = afterFinallyFlow; + currentFlow = afterFinallyFlow; + } } else { currentFlow = finishFlowLabel(preFinallyLabel); @@ -21360,7 +21798,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 254 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 257 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -21427,14 +21865,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 209 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 211 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 192 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { + if (node.kind === 193 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -21445,10 +21883,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 175 /* ArrayLiteralExpression */) { + else if (node.kind === 176 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 196 /* SpreadElement */) { + if (e.kind === 197 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -21456,16 +21894,16 @@ var ts; } } } - else if (node.kind === 176 /* ObjectLiteralExpression */) { + else if (node.kind === 177 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 257 /* PropertyAssignment */) { + if (p.kind === 260 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 258 /* ShorthandPropertyAssignment */) { + else if (p.kind === 261 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 259 /* SpreadAssignment */) { + else if (p.kind === 262 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -21521,7 +21959,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 57 /* EqualsToken */ && node.left.kind === 178 /* ElementAccessExpression */) { + if (operator === 57 /* EqualsToken */ && node.left.kind === 179 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -21532,7 +21970,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 177 /* PropertyAccessExpression */) { + if (node.expression.kind === 178 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -21565,7 +22003,7 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 212 /* ForInStatement */ || node.parent.parent.kind === 213 /* ForOfStatement */) { + if (node.initializer || node.parent.parent.kind === 214 /* ForInStatement */ || node.parent.parent.kind === 215 /* ForOfStatement */) { bindInitializedVariableFlow(node); } } @@ -21574,10 +22012,10 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 183 /* ParenthesizedExpression */) { + while (expr.kind === 184 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 184 /* FunctionExpression */ || expr.kind === 185 /* ArrowFunction */) { + if (expr.kind === 185 /* FunctionExpression */ || expr.kind === 186 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -21585,7 +22023,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 177 /* PropertyAccessExpression */) { + if (node.expression.kind === 178 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -21594,52 +22032,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 176 /* ObjectLiteralExpression */: - case 161 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 270 /* JSDocRecordType */: + case 198 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 177 /* ObjectLiteralExpression */: + case 162 /* TypeLiteral */: + case 291 /* JSDocTypeLiteral */: + case 274 /* JSDocRecordType */: + case 253 /* JsxAttributes */: return 1 /* IsContainer */; - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 274 /* JSDocFunctionType */: - case 230 /* ModuleDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 170 /* MappedType */: + case 278 /* JSDocFunctionType */: + case 232 /* ModuleDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 171 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 261 /* SourceFile */: + case 264 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } - case 150 /* Constructor */: - case 225 /* FunctionDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 151 /* Constructor */: + case 227 /* FunctionDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 231 /* ModuleBlock */: + case 233 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 256 /* CatchClause */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 232 /* CaseBlock */: + case 259 /* CatchClause */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 234 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 204 /* Block */: + case 206 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -21676,42 +22115,43 @@ 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 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 261 /* SourceFile */: + case 264 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 228 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 161 /* TypeLiteral */: - case 176 /* ObjectLiteralExpression */: - case 227 /* InterfaceDeclaration */: - case 270 /* JSDocRecordType */: - case 287 /* JSDocTypeLiteral */: + case 162 /* TypeLiteral */: + case 177 /* ObjectLiteralExpression */: + case 229 /* InterfaceDeclaration */: + case 274 /* JSDocRecordType */: + case 291 /* JSDocTypeLiteral */: + case 253 /* JsxAttributes */: // 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 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 274 /* JSDocFunctionType */: - case 228 /* TypeAliasDeclaration */: - case 170 /* MappedType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 278 /* JSDocFunctionType */: + case 230 /* TypeAliasDeclaration */: + case 171 /* MappedType */: // 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 @@ -21732,11 +22172,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 261 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 261 /* SourceFile */ || body.kind === 231 /* ModuleBlock */)) { + var body = node.kind === 264 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 264 /* SourceFile */ || body.kind === 233 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 241 /* ExportDeclaration */ || stat.kind === 240 /* ExportAssignment */) { + if (stat.kind === 243 /* ExportDeclaration */ || stat.kind === 242 /* ExportAssignment */) { return true; } } @@ -21760,7 +22200,7 @@ var ts; errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isExternalModuleAugmentation(node)) { - declareSymbolAndAddToSymbolTable(node, 1024 /* NamespaceModule */, 0 /* NamespaceModuleExcludes */); + declareModuleSymbol(node); } else { var pattern = void 0; @@ -21780,12 +22220,8 @@ var ts; } } else { - var state = getModuleInstanceState(node); - if (state === 0 /* NonInstantiated */) { - declareSymbolAndAddToSymbolTable(node, 1024 /* NamespaceModule */, 0 /* NamespaceModuleExcludes */); - } - else { - declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); + var state = declareModuleSymbol(node); + if (state !== 0 /* NonInstantiated */) { 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 @@ -21805,6 +22241,12 @@ var ts; } } } + function declareModuleSymbol(node) { + var state = getModuleInstanceState(node); + var instantiated = state !== 0 /* NonInstantiated */; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* ValueModule */ : 1024 /* NamespaceModule */, instantiated ? 106639 /* ValueModuleExcludes */ : 0 /* NamespaceModuleExcludes */); + return state; + } function bindFunctionOrConstructorType(node) { // For a given function symbol "<...>(...) => T" we want to generate a symbol identical // to the one we would get for: { <...>(...): T } @@ -21817,7 +22259,7 @@ var ts; var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); typeLiteralSymbol.members = ts.createMap(); - typeLiteralSymbol.members[symbol.name] = symbol; + typeLiteralSymbol.members.set(symbol.name, symbol); } function bindObjectLiteralExpression(node) { var ElementKind; @@ -21829,7 +22271,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { + if (prop.kind === 262 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { continue; } var identifier = prop.name; @@ -21841,12 +22283,12 @@ 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 === 257 /* PropertyAssignment */ || prop.kind === 258 /* ShorthandPropertyAssignment */ || prop.kind === 149 /* MethodDeclaration */ + var currentKind = prop.kind === 260 /* PropertyAssignment */ || prop.kind === 261 /* ShorthandPropertyAssignment */ || prop.kind === 150 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; - var existingKind = seen[identifier.text]; + var existingKind = seen.get(identifier.text); if (!existingKind) { - seen[identifier.text] = currentKind; + seen.set(identifier.text, currentKind); continue; } if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { @@ -21857,16 +22299,22 @@ var ts; } return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object"); } + function bindJsxAttributes(node) { + return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__jsxAttributes"); + } + function bindJsxAttribute(node, symbolFlags, symbolExcludes) { + return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); + } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 261 /* SourceFile */: + case 264 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -21977,8 +22425,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 261 /* SourceFile */ && - blockScopeContainer.kind !== 230 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 264 /* SourceFile */ && + blockScopeContainer.kind !== 232 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -22044,7 +22492,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 140 /* LastToken */) { + if (node.kind > 141 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -22091,23 +22539,23 @@ var ts; // current "blockScopeContainer" needs to be set to its immediate namespace parent. if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 285 /* JSDocTypedefTag */) { + while (parentNode && parentNode.kind !== 289 /* JSDocTypedefTag */) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); break; } case 98 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 258 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 261 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -22131,48 +22579,48 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return checkStrictModeCatchClause(node); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 217 /* WithStatement */: + case 219 /* WithStatement */: return checkStrictModeWithStatement(node); - case 167 /* ThisType */: + case 168 /* ThisType */: seenThisKeyword = true; return; - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return checkTypePredicate(node); - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530920 /* TypeParameterExcludes */); - case 144 /* Parameter */: + case 145 /* Parameter */: return bindParameter(node); - case 223 /* VariableDeclaration */: - case 174 /* BindingElement */: + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 271 /* JSDocRecordMember */: - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); - case 286 /* JSDocPropertyTag */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 275 /* JSDocRecordMember */: + return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 67108864 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + case 290 /* JSDocPropertyTag */: return bindJSDocProperty(node); - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: + case 260 /* PropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 260 /* EnumMember */: + case 263 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 259 /* SpreadAssignment */: - case 251 /* JsxSpreadAttribute */: + case 262 /* SpreadAssignment */: + case 254 /* JsxSpreadAttribute */: var root = container; var hasRest = false; while (root.parent) { - if (root.kind === 176 /* ObjectLiteralExpression */ && - root.parent.kind === 192 /* BinaryExpression */ && + if (root.kind === 177 /* ObjectLiteralExpression */ && + root.parent.kind === 193 /* BinaryExpression */ && root.parent.operatorToken.kind === 57 /* EqualsToken */ && root.parent.left === root) { hasRest = true; @@ -22181,86 +22629,91 @@ var ts; root = root.parent; } return; - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. - return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 225 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 67108864 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 99263 /* MethodExcludes */); + case 227 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 274 /* JSDocFunctionType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 278 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); - case 161 /* TypeLiteral */: - case 170 /* MappedType */: - case 287 /* JSDocTypeLiteral */: - case 270 /* JSDocRecordType */: + case 162 /* TypeLiteral */: + case 171 /* MappedType */: + case 291 /* JSDocTypeLiteral */: + case 274 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return bindFunctionExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 228 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792968 /* InterfaceExcludes */); - case 285 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: if (!node.fullName || node.fullName.kind === 70 /* Identifier */) { return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); } break; - case 228 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return bindModuleDeclaration(node); + // Jsx-attributes + case 253 /* JsxAttributes */: + return bindJsxAttributes(node); + case 252 /* JsxAttribute */: + return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 234 /* ImportEqualsDeclaration */: - case 237 /* NamespaceImport */: - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 239 /* NamespaceImport */: + case 241 /* ImportSpecifier */: + case 245 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 233 /* NamespaceExportDeclaration */: + case 235 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 236 /* ImportClause */: + case 238 /* ImportClause */: return bindImportClause(node); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return bindExportDeclaration(node); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return bindExportAssignment(node); - case 261 /* SourceFile */: + case 264 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 204 /* Block */: + case 206 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // Fall through - case 231 /* ModuleBlock */: + case 233 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); } } @@ -22269,7 +22722,7 @@ var ts; if (parameterName && parameterName.kind === 70 /* Identifier */) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 167 /* ThisType */) { + if (parameterName && parameterName.kind === 168 /* ThisType */) { seenThisKeyword = true; } bind(type); @@ -22292,7 +22745,7 @@ var ts; // An export default clause with an expression exports a value // We want to exclude both class and function here, this is necessary to issue an error when there are both // default export-assignment and default export function and class declaration. - var flags = node.kind === 240 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 242 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); @@ -22302,17 +22755,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 261 /* SourceFile */) { + if (node.parent.kind !== 264 /* SourceFile */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_4 = node.parent; - if (!ts.isExternalModule(parent_4)) { + var parent_1 = node.parent; + if (!ts.isExternalModule(parent_1)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_4.isDeclarationFile) { + if (!parent_1.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -22323,11 +22776,11 @@ var ts; function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { // Export * in some sort of block construct - bindAnonymousDeclaration(node, 1073741824 /* ExportStar */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 33554432 /* 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 */); + declareSymbol(container.symbol.exports, container.symbol, node, 33554432 /* ExportStar */, 0 /* None */); } } function bindImportClause(node) { @@ -22357,12 +22810,12 @@ var ts; function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); // Declare a 'member' if the container is an ES5 class or ES6 constructor - if (container.kind === 225 /* FunctionDeclaration */ || container.kind === 184 /* FunctionExpression */) { + if (container.kind === 227 /* FunctionDeclaration */ || container.kind === 185 /* FunctionExpression */) { container.symbol.members = container.symbol.members || ts.createMap(); // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); } - else if (container.kind === 150 /* Constructor */) { + else if (container.kind === 151 /* Constructor */) { // this.foo assignment in a JavaScript class // Bind this property to the containing class var saveContainer = container; @@ -22386,7 +22839,7 @@ var ts; leftSideOfAssignment.parent = node; constructorFunction.parent = classPrototype; classPrototype.parent = leftSideOfAssignment; - var funcSymbol = container.locals[constructorFunction.text]; + var funcSymbol = container.locals.get(constructorFunction.text); if (!funcSymbol || !(funcSymbol.flags & 16 /* Function */ || ts.isDeclarationOfFunctionExpression(funcSymbol))) { return; } @@ -22405,7 +22858,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 228 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -22413,7 +22866,7 @@ var ts; 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; + classifiableNames.set(node.name.text, node.name.text); } } var symbol = node.symbol; @@ -22426,14 +22879,15 @@ var 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. - var prototypeSymbol = createSymbol(4 /* Property */ | 134217728 /* Prototype */, "prototype"); - if (symbol.exports[prototypeSymbol.name]) { + var prototypeSymbol = createSymbol(4 /* Property */ | 16777216 /* Prototype */, "prototype"); + var symbolExport = symbol.exports.get(prototypeSymbol.name); + if (symbolExport) { 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)); + file.bindDiagnostics.push(ts.createDiagnosticForNode(symbolExport.declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; + symbol.exports.set(prototypeSymbol.name, prototypeSymbol); prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { @@ -22482,7 +22936,7 @@ var ts; // containing class. if (ts.isParameterPropertyDeclaration(node)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 67108864 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } } function bindFunctionDeclaration(node) { @@ -22541,13 +22995,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 206 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 208 /* EmptyStatement */) || // report error on class declarations - node.kind === 226 /* ClassDeclaration */ || + node.kind === 228 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 230 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 232 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 229 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 231 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; // unreachable code is reported if @@ -22561,7 +23015,7 @@ var ts; // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 205 /* VariableStatement */ || + (node.kind !== 207 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -22581,56 +23035,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 179 /* CallExpression */: + case 180 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 144 /* Parameter */: + case 145 /* Parameter */: return computeParameter(node, subtreeFlags); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 224 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 255 /* HeritageClause */: + case 258 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 150 /* Constructor */: + case 151 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -22657,8 +23111,8 @@ var ts; switch (kind) { case 96 /* SuperKeyword */: return true; - case 177 /* PropertyAccessExpression */: - case 178 /* ElementAccessExpression */: + case 178 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96 /* SuperKeyword */; @@ -22682,12 +23136,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 176 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 177 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ESNext if they contain rest transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 175 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 176 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } @@ -22737,8 +23191,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 200 /* AsExpression */ - || expressionKind === 182 /* TypeAssertionExpression */) { + if (expressionKind === 201 /* AsExpression */ + || expressionKind === 183 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -23103,7 +23557,7 @@ var ts; var excludeFlags = 536872257 /* NodeExcludes */; switch (kind) { case 119 /* AsyncKeyword */: - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: // async/await is ES2017 syntax transformFlags |= 16 /* AssertES2017 */; break; @@ -23113,27 +23567,28 @@ var ts; case 116 /* AbstractKeyword */: case 123 /* DeclareKeyword */: case 75 /* ConstKeyword */: - case 229 /* EnumDeclaration */: - case 260 /* EnumMember */: - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: - case 201 /* NonNullExpression */: + case 231 /* EnumDeclaration */: + case 263 /* EnumMember */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: + case 202 /* NonNullExpression */: case 130 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 246 /* JsxElement */: - case 247 /* JsxSelfClosingElement */: - case 248 /* JsxOpeningElement */: + case 248 /* JsxElement */: + case 249 /* JsxSelfClosingElement */: + case 250 /* JsxOpeningElement */: case 10 /* JsxText */: - case 249 /* JsxClosingElement */: - case 250 /* JsxAttribute */: - case 251 /* JsxSpreadAttribute */: - case 252 /* JsxExpression */: + case 251 /* JsxClosingElement */: + case 252 /* JsxAttribute */: + case 253 /* JsxAttributes */: + case 254 /* JsxSpreadAttribute */: + case 255 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; - case 213 /* ForOfStatement */: + case 215 /* ForOfStatement */: // for-of might be ESNext if it has a rest destructuring transformFlags |= 8 /* AssertESNext */; // FALLTHROUGH @@ -23141,53 +23596,55 @@ var ts; case 13 /* TemplateHead */: case 14 /* TemplateMiddle */: case 15 /* TemplateTail */: - case 194 /* TemplateExpression */: - case 181 /* TaggedTemplateExpression */: - case 258 /* ShorthandPropertyAssignment */: + case 195 /* TemplateExpression */: + case 182 /* TaggedTemplateExpression */: + case 261 /* ShorthandPropertyAssignment */: case 114 /* StaticKeyword */: + case 203 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: // This node is ES6 syntax. transformFlags |= 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; break; case 118 /* AnyKeyword */: case 132 /* NumberKeyword */: case 129 /* NeverKeyword */: - case 134 /* StringKeyword */: + case 133 /* ObjectKeyword */: + case 135 /* StringKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 143 /* TypeParameter */: - case 146 /* PropertySignature */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 156 /* TypePredicate */: - case 157 /* TypeReference */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 160 /* TypeQuery */: - case 161 /* TypeLiteral */: - case 162 /* ArrayType */: - case 163 /* TupleType */: - case 164 /* UnionType */: - case 165 /* IntersectionType */: - case 166 /* ParenthesizedType */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 167 /* ThisType */: - case 168 /* TypeOperator */: - case 169 /* IndexedAccessType */: - case 170 /* MappedType */: - case 171 /* LiteralType */: + case 144 /* TypeParameter */: + case 147 /* PropertySignature */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 157 /* TypePredicate */: + case 158 /* TypeReference */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 161 /* TypeQuery */: + case 162 /* TypeLiteral */: + case 163 /* ArrayType */: + case 164 /* TupleType */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: + case 167 /* ParenthesizedType */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 168 /* ThisType */: + case 169 /* TypeOperator */: + case 170 /* IndexedAccessType */: + case 171 /* MappedType */: + case 172 /* LiteralType */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. @@ -23204,10 +23661,10 @@ var ts; transformFlags |= 65536 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 259 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 96 /* SuperKeyword */: @@ -23218,28 +23675,28 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 16384 /* ContainsLexicalThis */; break; - case 172 /* ObjectBindingPattern */: + case 173 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; if (subtreeFlags & 524288 /* ContainsRest */) { transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectRest */; } excludeFlags = 537396545 /* BindingPatternExcludes */; break; - case 173 /* ArrayBindingPattern */: + case 174 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; excludeFlags = 537396545 /* BindingPatternExcludes */; break; - case 174 /* BindingElement */: + case 175 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 524288 /* ContainsRest */; } break; - case 145 /* Decorator */: + case 146 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsDecorators */; break; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: excludeFlags = 540087617 /* ObjectLiteralExcludes */; if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -23257,8 +23714,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 175 /* ArrayLiteralExpression */: - case 180 /* NewExpression */: + case 176 /* ArrayLiteralExpression */: + case 181 /* NewExpression */: excludeFlags = 537396545 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 524288 /* ContainsSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -23266,23 +23723,23 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 261 /* SourceFile */: + case 264 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 216 /* ReturnStatement */: - case 214 /* ContinueStatement */: - case 215 /* BreakStatement */: + case 218 /* ReturnStatement */: + case 216 /* ContinueStatement */: + case 217 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -23298,56 +23755,57 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 156 /* FirstTypeNode */ && kind <= 171 /* LastTypeNode */) { + if (kind >= 157 /* FirstTypeNode */ && kind <= 172 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 175 /* ArrayLiteralExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 176 /* ArrayLiteralExpression */: return 537396545 /* ArrayLiteralOrCallOrNewExcludes */; - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return 574674241 /* ModuleExcludes */; - case 144 /* Parameter */: + case 145 /* Parameter */: return 536872257 /* ParameterExcludes */; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return 601249089 /* ArrowFunctionExcludes */; - case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: return 601281857 /* FunctionExcludes */; - case 224 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return 546309441 /* VariableDeclarationListExcludes */; - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: return 539358529 /* ClassExcludes */; - case 150 /* Constructor */: + case 151 /* Constructor */: return 601015617 /* ConstructorExcludes */; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return 601015617 /* MethodOrAccessorExcludes */; case 118 /* AnyKeyword */: case 132 /* NumberKeyword */: case 129 /* NeverKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: + case 133 /* ObjectKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 143 /* TypeParameter */: - case 146 /* PropertySignature */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 144 /* TypeParameter */: + case 147 /* PropertySignature */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return 540087617 /* ObjectLiteralExcludes */; - case 256 /* CatchClause */: + case 259 /* CatchClause */: return 537920833 /* CatchClauseExcludes */; - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: return 537396545 /* BindingPatternExcludes */; default: return 536872257 /* NodeExcludes */; @@ -23386,10 +23844,6 @@ var ts; ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); return resolved.path; } - /** Create Resolved from a file with unknown extension. */ - function resolvedFromAnyFile(path) { - return { path: path, extension: ts.extensionFromPath(path) }; - } /** Adds `isExernalLibraryImport` to a Resolved to get a ResolvedModule. */ function resolvedModuleFromResolved(_a, isExternalLibraryImport) { var path = _a.path, extension = _a.extension; @@ -23402,37 +23856,29 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { + /** Reads from "main" or "types"/"typings" depending on `extensions`. */ + function tryReadPackageJsonFields(readTypes, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); - switch (extensions) { - case 2 /* DtsOnly */: - case 0 /* TypeScript */: - return tryReadFromField("typings") || tryReadFromField("types"); - case 1 /* JavaScript */: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; - } + return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); - } - return typesFilePath; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } + if (!ts.hasProperty(jsonContent, fieldName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName); } + return; } + var fileName = jsonContent[fieldName]; + if (typeof fileName !== "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof fileName); + } + return; + } + var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path); + } + return path; } } function readJson(path, host) { @@ -23468,6 +23914,7 @@ var ts; function getDefaultTypeRoots(currentDirectory, host) { if (!host.directoryExists) { return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; + // And if it doesn't exist, tough. } var typeRoots; forEachAncestorDirectory(currentDirectory, function (directory) { @@ -23475,6 +23922,7 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } + return undefined; }); return typeRoots; } @@ -23535,7 +23983,11 @@ var ts; return ts.forEach(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2 /* DtsOnly */, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); }); } else { @@ -23552,7 +24004,8 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2 /* DtsOnly */, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, /*cache*/ undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -23605,31 +24058,135 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); + if (!perModuleNameCache) { + perModuleNameCache = createPerModuleNameCache(); + moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + /** + * At first this function add entry directory -> module resolution result to the table. + * Then it computes the set of parent folders for 'directory' that should have the same module resolution result + * and for every parent folder in set it adds entry: parent -> module resolution. . + * Lets say we first directory name: /a/b/c/d/e and resolution result is: /a/b/bar.ts. + * Set of parent folders that should have the same result will be: + * [ + * /a/b/c/d, /a/b/c, /a/b + * ] + * this means that request for module resolution from file in any of these folder will be immediately found in cache. + */ + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + // if entry is already in cache do nothing + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + // find common prefix between directory and resolved file name + // this common prefix should be the shorted path that has the same resolution + // directory: /a/b/c/d/e + // resolvedFileName: /a/b/foo.d.ts + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent = ts.getDirectoryPath(current); + if (parent === current || directoryPathMap.contains(parent)) { + break; + } + directoryPathMap.set(parent, result); + current = parent; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + // find first position where directory and resolution differs + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + // find last directory separator before position i + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache.get(moduleName); + if (result) { if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache.set(moduleName, result); + // put result in per-module name cache + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; } if (traceEnabled) { if (result.resolvedModule) { @@ -23822,38 +24379,45 @@ var ts; return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /* jsOnly*/ false); + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + /* @internal */ + function nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, jsOnly) { + if (jsOnly === void 0) { jsOnly = false; } var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(0 /* TypeScript */) || tryResolve(1 /* JavaScript */); - if (result) { - var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + var result = jsOnly ? tryResolve(Extensions.JavaScript) : (tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript)); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { - var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); + var loader = function (extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, /*considerPackageJson*/ true); }; + var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); if (resolved) { - return { resolved: resolved, isExternalLibraryImport: false }; + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. - return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); - return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/ true); + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } - ts.nodeModuleNameResolver = nodeModuleNameResolver; + ts.nodeModuleNameResolverWorker = nodeModuleNameResolverWorker; function realpath(path, host, traceEnabled) { if (!host.realpath) { return path; @@ -23864,12 +24428,35 @@ var ts; } return real; } - function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } - var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson); } /* @internal */ function directoryProbablyExists(directoryName, host) { @@ -23908,11 +24495,11 @@ var ts; } } switch (extensions) { - case 2 /* DtsOnly */: + case Extensions.DtsOnly: return tryExtension(".d.ts", ts.Extension.Dts); - case 0 /* TypeScript */: + case Extensions.TypeScript: return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case 1 /* JavaScript */: + case Extensions.JavaScript: return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } function tryExtension(ext, extension) { @@ -23922,120 +24509,177 @@ var ts; } /** Return the file if it exists. */ function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); - } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); - } - failedLookupLocations.push(fileName); - return undefined; - } - } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - // A package.json "typings" may specify an exact filename, or may choose to omit an extension. - var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromFile) { - // Note: this would allow a package.json to specify a ".js" file as typings. Maybe that should be forbidden. - return resolvedFromAnyFile(fromFile); - } - var x = tryAddingExtensions(typesFile, 0 /* TypeScript */, failedLookupLocations, onlyRecordFailures_1, state); - if (x) { - return x; + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); } + return fileName; } else { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); } } } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + failedLookupLocations.push(fileName); + return undefined; + } + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { + if (considerPackageJson === void 0) { considerPackageJson = true; } + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (considerPackageJson) { + var packageJsonPath = pathToPackageJson(candidate); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + var fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; + } + } + else { + if (directoryExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + } + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocations.push(packageJsonPath); } - // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results - failedLookupLocations.push(packageJsonPath); } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + if (!file) { + return undefined; + } + var onlyRecordFailures = !directoryProbablyExists(ts.getDirectoryPath(file), state.host); + var fromFile = tryFile(file, failedLookupLocations, onlyRecordFailures, state); + if (fromFile) { + var resolved = fromFile && resolvedIfExtensionMatches(extensions, fromFile); + if (resolved) { + return resolved; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile); + } + } + // Even if extensions is DtsOnly, we can still look up a .ts file as a result of package.json "types" + var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; + // Don't do package.json lookup recursively, because Node.js' package lookup doesn't. + return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, /*considerPackageJson*/ false); + } + /** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */ + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + /** True if `extension` is one of the supported `extensions`. */ + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ false, cache); } function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { // Extensions parameter here doesn't actually matter, because typesOnly ensures we're just doing @types lookup, which is always DtsOnly. - return loadModuleFromNodeModulesWorker(2 /* DtsOnly */, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ true); + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ true, /*cache*/ undefined); } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); } }); } /** Load a module from a single node_modules directory, but not from any ancestors' node_modules directories. */ function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { if (typesOnly === void 0) { typesOnly = false; } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); if (packageResult) { return packageResult; } - if (extensions !== 1 /* JavaScript */) { - return loadModuleFromNodeModulesFolder(2 /* DtsOnly */, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(0 /* TypeScript */) || tryResolve(1 /* JavaScript */); - return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ false, failedLookupLocations); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); if (resolvedUsingSettings) { - return resolvedUsingSettings; + return { value: resolvedUsingSettings }; } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { // Climb up parent directories looking for a module. var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state)); }); if (resolved_3) { return resolved_3; } - if (extensions === 0 /* TypeScript */) { + if (extensions === Extensions.TypeScript) { // If we didn't find the file normally, look it up in @types. return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state)); } } } @@ -24052,10 +24696,17 @@ var ts; } var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(2 /* DtsOnly */, moduleName, globalCache, failedLookupLocations, state); + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + /** + * Wraps value to SearchResult. + * @returns undefined if value is undefined or { value } otherwise + */ + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ function forEachAncestorDirectory(directory, callback) { while (true) { @@ -24124,9 +24775,9 @@ var ts; var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; var strictNullChecks = compilerOptions.strictNullChecks; var emitResolver = createResolver(); - var undefinedSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "undefined"); + var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); undefinedSymbol.declarations = []; - var argumentsSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "arguments"); + var argumentsSymbol = createSymbol(4 /* Property */, "arguments"); var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, @@ -24142,9 +24793,12 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, + getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, + getTypeFromTypeNode: getTypeFromTypeNode, + getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, getSymbolsInScope: getSymbolsInScope, @@ -24153,6 +24807,7 @@ var ts; getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, getTypeAtLocation: getTypeOfNode, getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, + signatureToString: signatureToString, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -24168,8 +24823,9 @@ var ts; getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, + getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getAmbientModules: getAmbientModules, - getJsxElementAttributesType: getJsxElementAttributesType, + getAllAttributesTypeFromJsxOpeningLikeElement: getAllAttributesTypeFromJsxOpeningLikeElement, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, isOptionalParameter: isOptionalParameter, tryGetMemberInModuleExports: tryGetMemberInModuleExports, @@ -24177,7 +24833,8 @@ var ts; // we deliberately exclude augmentations // since we are only interested in declarations of the module itself return tryFindAmbientModule(moduleName, /*withAugmentations*/ false); - } + }, + getApparentType: getApparentType }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -24186,8 +24843,8 @@ var ts; var numericLiteralTypes = ts.createMap(); var indexedAccessTypes = ts.createMap(); var evolvingArrayTypes = []; - var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); - var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); + var unknownSymbol = createSymbol(4 /* Property */, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__"); var anyType = createIntrinsicType(1 /* Any */, "any"); var autoType = createIntrinsicType(1 /* Any */, "any"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); @@ -24204,8 +24861,9 @@ var ts; var voidType = createIntrinsicType(1024 /* Void */, "void"); var neverType = createIntrinsicType(8192 /* Never */, "never"); var silentNeverType = createIntrinsicType(8192 /* Never */, "never"); + var nonPrimitiveType = createIntrinsicType(16777216 /* NonPrimitive */, "object"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */ | 67108864 /* Transient */, "__type"); + var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type"); emptyTypeLiteralSymbol.members = ts.createMap(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -24215,6 +24873,7 @@ var ts; // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. anyFunctionType.flags |= 8388608 /* ContainsAnyFunctionType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); @@ -24281,6 +24940,7 @@ var ts; var visitedFlowNodes = []; var visitedFlowTypes = []; var potentialThisCollisions = []; + var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var TypeFacts; @@ -24346,7 +25006,7 @@ var ts; TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; })(TypeFacts || (TypeFacts = {})); - var typeofEQFacts = ts.createMap({ + var typeofEQFacts = ts.createMapFromTemplate({ "string": 1 /* TypeofEQString */, "number": 2 /* TypeofEQNumber */, "boolean": 4 /* TypeofEQBoolean */, @@ -24355,7 +25015,7 @@ var ts; "object": 16 /* TypeofEQObject */, "function": 32 /* TypeofEQFunction */ }); - var typeofNEFacts = ts.createMap({ + var typeofNEFacts = ts.createMapFromTemplate({ "string": 128 /* TypeofNEString */, "number": 256 /* TypeofNENumber */, "boolean": 512 /* TypeofNEBoolean */, @@ -24364,13 +25024,14 @@ var ts; "object": 2048 /* TypeofNEObject */, "function": 4096 /* TypeofNEFunction */ }); - var typeofTypesByName = ts.createMap({ + var typeofTypesByName = ts.createMapFromTemplate({ "string": stringType, "number": numberType, "boolean": booleanType, "symbol": esSymbolType, "undefined": undefinedType }); + var typeofType = createTypeofType(); var jsxElementType; var _jsxNamespace; var _jsxFactoryEntity; @@ -24400,7 +25061,7 @@ var ts; TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var builtinGlobals = ts.createMap(); - builtinGlobals[undefinedSymbol.name] = undefinedSymbol; + builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); initializeTypeChecker(); return checker; function getJsxNamespace() { @@ -24432,7 +25093,9 @@ var ts; } function createSymbol(flags, name) { symbolCount++; - return new Symbol(flags, name); + var symbol = (new Symbol(flags | 134217728 /* Transient */, name)); + symbol.checkFlags = 0; + return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; @@ -24478,7 +25141,7 @@ var ts; mergedSymbols[source.mergeId] = target; } function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 33554432 /* Merged */, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); result.declarations = symbol.declarations.slice(0); result.parent = symbol.parent; if (symbol.valueDeclaration) @@ -24501,7 +25164,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 230 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 230 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 232 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 232 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -24518,6 +25181,9 @@ var ts; } recordMergedSymbol(target, source); } + else if (target.flags & 1024 /* NamespaceModule */) { + error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + } else { var message_2 = target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -24530,18 +25196,19 @@ var ts; } } function mergeSymbolTable(target, source) { - for (var id in source) { - var targetSymbol = target[id]; + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); if (!targetSymbol) { - target[id] = source[id]; + target.set(id, sourceSymbol); } else { - if (!(targetSymbol.flags & 33554432 /* Merged */)) { - target[id] = targetSymbol = cloneSymbol(targetSymbol); + if (!(targetSymbol.flags & 134217728 /* Transient */)) { + targetSymbol = cloneSymbol(targetSymbol); + target.set(id, targetSymbol); } - mergeSymbol(targetSymbol, source[id]); + mergeSymbol(targetSymbol, sourceSymbol); } - } + }); } function mergeModuleAugmentation(moduleName) { var moduleAugmentation = moduleName.parent; @@ -24570,7 +25237,7 @@ var ts; if (mainModule.flags & 1920 /* Namespace */) { // if module symbol has already been merged - it is safe to use it. // otherwise clone it - mainModule = mainModule.flags & 33554432 /* Merged */ ? mainModule : cloneSymbol(mainModule); + mainModule = mainModule.flags & 134217728 /* Transient */ ? mainModule : cloneSymbol(mainModule); mergeSymbol(mainModule, moduleAugmentation.symbol); } else { @@ -24579,21 +25246,22 @@ var ts; } } function addToSymbolTable(target, source, message) { - for (var id in source) { - if (target[id]) { + source.forEach(function (sourceSymbol, id) { + var targetSymbol = target.get(id); + if (targetSymbol) { // Error on redeclarations - ts.forEach(target[id].declarations, addDeclarationDiagnostic(id, message)); + ts.forEach(targetSymbol.declarations, addDeclarationDiagnostic(id, message)); } else { - target[id] = source[id]; + target.set(id, sourceSymbol); } - } + }); function addDeclarationDiagnostic(id, message) { return function (declaration) { return diagnostics.add(ts.createDiagnosticForNode(declaration, message, id)); }; } } function getSymbolLinks(symbol) { - if (symbol.flags & 67108864 /* Transient */) + if (symbol.flags & 134217728 /* Transient */) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = {}); @@ -24605,14 +25273,17 @@ var ts; function getObjectFlags(type) { return type.flags & 32768 /* Object */ ? type.objectFlags : 0; } + function getCheckFlags(symbol) { + return symbol.flags & 134217728 /* Transient */ ? symbol.checkFlags : 0; + } function isGlobalSourceFile(node) { - return node.kind === 261 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 264 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { - var symbol = symbols[name]; + var symbol = symbols.get(name); if (symbol) { - ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } @@ -24654,7 +25325,7 @@ var ts; } // declaration is after usage // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) - if (isUsedInFunctionOrNonStaticProperty(usage)) { + if (isUsedInFunctionOrInstanceProperty(usage)) { return true; } var sourceFiles = host.getSourceFiles(); @@ -24662,20 +25333,34 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - // still might be illegal if usage is in the initializer of the variable declaration - return declaration.kind !== 223 /* VariableDeclaration */ || - !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + if (declaration.kind === 175 /* BindingElement */) { + // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) + var errorBindingElement = ts.getAncestor(usage, 175 /* BindingElement */); + if (errorBindingElement) { + return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + declaration.pos < errorBindingElement.pos; + } + // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 225 /* VariableDeclaration */), usage); + } + else if (declaration.kind === 225 /* VariableDeclaration */) { + // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) + return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); + } + return true; } - // declaration is after usage - // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) + // declaration is after usage, but it can still be legal if usage is deferred: + // 1. inside a function + // 2. inside an instance property initializer, a reference to a non-instance property var container = ts.getEnclosingBlockScopeContainer(declaration); - return isUsedInFunctionOrNonStaticProperty(usage, container); + var isInstanceProperty = declaration.kind === 148 /* PropertyDeclaration */ && !(ts.getModifierFlags(declaration) & 32 /* Static */); + return isUsedInFunctionOrInstanceProperty(usage, isInstanceProperty, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 205 /* VariableStatement */: - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 207 /* VariableStatement */: + case 213 /* ForStatement */: + case 215 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -24684,8 +25369,8 @@ var ts; break; } switch (declaration.parent.parent.kind) { - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: // ForIn/ForOf case - use site should not be used in expression part if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; @@ -24693,7 +25378,7 @@ var ts; } return false; } - function isUsedInFunctionOrNonStaticProperty(usage, container) { + function isUsedInFunctionOrInstanceProperty(usage, isDeclarationInstanceProperty, container) { var current = usage; while (current) { if (current === container) { @@ -24702,17 +25387,26 @@ var ts; if (ts.isFunctionLike(current)) { return true; } - var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 147 /* PropertyDeclaration */ && + var initializerOfInstanceProperty = current.parent && + current.parent.kind === 148 /* PropertyDeclaration */ && (ts.getModifierFlags(current.parent) & 32 /* Static */) === 0 && current.parent.initializer === current; - if (initializerOfNonStaticProperty) { - return true; + if (initializerOfInstanceProperty) { + return !isDeclarationInstanceProperty; } current = current.parent; } return false; } + function getAncestorBindingPattern(node) { + while (node) { + if (ts.isBindingPattern(node)) { + return node; + } + node = node.parent; + } + return undefined; + } } // 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 @@ -24736,11 +25430,11 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 278 /* JSDocComment */) { + if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 282 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || - lastLocation.kind === 144 /* Parameter */ || - lastLocation.kind === 143 /* TypeParameter */ + lastLocation.kind === 145 /* Parameter */ || + lastLocation.kind === 144 /* TypeParameter */ : false; } if (meaning & 107455 /* Value */ && result.flags & 1 /* FunctionScopedVariable */) { @@ -24749,9 +25443,9 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 144 /* Parameter */ || + lastLocation.kind === 145 /* Parameter */ || (lastLocation === location.type && - result.valueDeclaration.kind === 144 /* Parameter */); + result.valueDeclaration.kind === 145 /* Parameter */); } } if (useResult) { @@ -24763,16 +25457,16 @@ var ts; } } switch (location.kind) { - case 261 /* SourceFile */: + case 264 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 261 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 264 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. - if (result = moduleExports["default"]) { + if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; @@ -24790,9 +25484,10 @@ var ts; // 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 (moduleExports[name] && - moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 243 /* ExportSpecifier */)) { + var moduleExport = moduleExports.get(name); + if (moduleExport && + moduleExport.flags === 8388608 /* Alias */ && + ts.getDeclarationOfKind(moduleExport, 245 /* ExportSpecifier */)) { break; } } @@ -24800,13 +25495,13 @@ var ts; break loop; } break; - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* 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 @@ -24823,10 +25518,15 @@ var ts; } } break; - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064 /* Type */)) { + if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { + // ignore type parameters not declared in this container + result = undefined; + break; + } if (lastLocation && ts.getModifierFlags(lastLocation) & 32 /* 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 @@ -24836,7 +25536,7 @@ var ts; } break loop; } - if (location.kind === 197 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 198 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -24852,9 +25552,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 227 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 229 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -24862,19 +25562,19 @@ var ts; } } break; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -24887,7 +25587,7 @@ var ts; } } break; - case 145 /* Decorator */: + case 146 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -24896,7 +25596,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 === 144 /* Parameter */) { + if (location.parent && location.parent.kind === 145 /* Parameter */) { location = location.parent; } // @@ -24947,10 +25647,10 @@ var ts; // interface 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 + // The foo at /*1*/ and /*2*/ will share same symbol with two meanings: + // block-scoped 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 + // we want to check for block-scoped if (meaning & 2 /* BlockScopedVariable */) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */) { @@ -24960,18 +25660,27 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 107455 /* Value */) === 107455 /* Value */) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 233 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 235 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } } return result; } + function isTypeParameterSymbolDeclaredInContainer(symbol, container) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.kind === 144 /* TypeParameter */ && decl.parent === container) { + return true; + } + } + return false; + } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { if ((errorLocation.kind === 70 /* Identifier */ && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } - var container = ts.getThisContainer(errorLocation, /* includeArrowFunctions */ true); + var container = ts.getThisContainer(errorLocation, /*includeArrowFunctions*/ true); var location = container; while (location) { if (ts.isClassLike(location.parent)) { @@ -25014,9 +25723,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70 /* Identifier */: - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -25048,7 +25757,7 @@ var ts; // Block-scoped variables cannot be used before their definition var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 223 /* VariableDeclaration */), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -25069,10 +25778,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 236 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 235 /* ImportDeclaration */) { + while (node && node.kind !== 237 /* ImportDeclaration */) { node = node.parent; } return node; @@ -25082,7 +25791,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 245 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 247 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -25090,11 +25799,16 @@ var ts; function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { - var exportDefaultSymbol = ts.isShorthandAmbientModuleSymbol(moduleSymbol) ? - moduleSymbol : - moduleSymbol.exports["export="] ? - getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") : - resolveSymbol(moduleSymbol.exports["default"]); + var exportDefaultSymbol = void 0; + if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { + exportDefaultSymbol = moduleSymbol; + } + else { + var exportValue = moduleSymbol.exports.get("export="); + exportDefaultSymbol = exportValue + ? getPropertyOfType(getTypeOfSymbol(exportValue), "default") + : resolveSymbol(moduleSymbol.exports.get("default")); + } if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } @@ -25143,7 +25857,7 @@ var ts; } function getExportOfModule(symbol, name) { if (symbol.flags & 1536 /* Module */) { - var exportedSymbol = getExportsOfSymbol(symbol)[name]; + var exportedSymbol = getExportsOfSymbol(symbol).get(name); if (exportedSymbol) { return resolveSymbol(exportedSymbol); } @@ -25161,31 +25875,31 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_16 = specifier.propertyName || specifier.name; - if (name_16.text) { + var name = specifier.propertyName || specifier.name; + if (name.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; // First check if module was specified with "export=". If so, get the member from the resolved type - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_16.text); + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) { + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_16.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_16.text); + var symbolFromModule = getExportOfModule(targetSymbol, name.text); // If the export member we're looking for is default, and there is no real default but allowSyntheticDefaultImports is on, return the entire module as the default - if (!symbolFromModule && allowSyntheticDefaultImports && name_16.text === "default") { + if (!symbolFromModule && allowSyntheticDefaultImports && name.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_16, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_16)); + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name)); } return symbol; } @@ -25207,19 +25921,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 236 /* ImportClause */: + case 238 /* ImportClause */: return getTargetOfImportClause(node); - case 237 /* NamespaceImport */: + case 239 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 239 /* ImportSpecifier */: + case 241 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 243 /* ExportSpecifier */: + case 245 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return getTargetOfExportAssignment(node); - case 233 /* NamespaceExportDeclaration */: + case 235 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node); } } @@ -25266,11 +25980,11 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 240 /* ExportAssignment */) { + if (node.kind === 242 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 243 /* ExportSpecifier */) { + else if (node.kind === 245 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -25292,20 +26006,22 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 70 /* Identifier */ || entityName.parent.kind === 141 /* QualifiedName */) { + if (entityName.kind === 70 /* Identifier */ || entityName.parent.kind === 142 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 234 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 236 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol) { return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); } - // Resolves a qualified name and any involved aliases + /** + * Resolves a qualified name and any involved aliases. + */ function resolveEntityName(name, meaning, ignoreErrors, dontResolveAlias, location) { if (ts.nodeIsMissing(name)) { return undefined; @@ -25318,9 +26034,9 @@ var ts; return undefined; } } - else if (name.kind === 141 /* QualifiedName */ || name.kind === 177 /* PropertyAccessExpression */) { - var left = name.kind === 141 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 141 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 142 /* QualifiedName */ || name.kind === 178 /* PropertyAccessExpression */) { + var left = name.kind === 142 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 142 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1920 /* Namespace */, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -25339,7 +26055,7 @@ var ts; else { ts.Debug.fail("Unknown entity name kind."); } - ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); } function resolveExternalModuleName(location, moduleReferenceExpression) { @@ -25419,7 +26135,7 @@ var ts; // 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 && getMergedSymbol(resolveSymbol(moduleSymbol.exports["export="])) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("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 @@ -25433,15 +26149,23 @@ var ts; return symbol; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["export="] !== undefined; + return moduleSymbol.exports.get("export=") !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); } + function getExportsAndPropertiesOfModule(moduleSymbol) { + var exports = getExportsOfModuleAsArray(moduleSymbol); + var exportEquals = resolveExternalModuleSymbol(moduleSymbol); + if (exportEquals !== moduleSymbol) { + ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + } + return exports; + } function tryGetMemberInModuleExports(memberName, moduleSymbol) { var symbolTable = getExportsOfModule(moduleSymbol); if (symbolTable) { - return symbolTable[memberName]; + return symbolTable.get(memberName); } } function getExportsOfSymbol(symbol) { @@ -25456,24 +26180,28 @@ var ts; * Not passing `lookupTable` and `exportNode` disables this collection, and just extends the tables */ function extendExportSymbols(target, source, lookupTable, exportNode) { - for (var id in source) { - if (id !== "default" && !target[id]) { - target[id] = source[id]; + source && source.forEach(function (sourceSymbol, id) { + if (id === "default") + return; + var targetSymbol = target.get(id); + if (!targetSymbol) { + target.set(id, sourceSymbol); if (lookupTable && exportNode) { - lookupTable[id] = { + lookupTable.set(id, { specifierText: ts.getTextOfNode(exportNode.moduleSpecifier) - }; + }); } } - else if (lookupTable && exportNode && id !== "default" && target[id] && resolveSymbol(target[id]) !== resolveSymbol(source[id])) { - if (!lookupTable[id].exportsWithDuplicate) { - lookupTable[id].exportsWithDuplicate = [exportNode]; + else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) { + var collisionTracker = lookupTable.get(id); + if (!collisionTracker.exportsWithDuplicate) { + collisionTracker.exportsWithDuplicate = [exportNode]; } else { - lookupTable[id].exportsWithDuplicate.push(exportNode); + collisionTracker.exportsWithDuplicate.push(exportNode); } } - } + }); } function getExportsForModule(moduleSymbol) { var visitedSymbols = []; @@ -25489,27 +26217,27 @@ var ts; visitedSymbols.push(symbol); var symbols = ts.cloneMap(symbol.exports); // All export * declarations are collected in an __export symbol by the binder - var exportStars = symbol.exports["__export"]; + var exportStars = symbol.exports.get("__export"); if (exportStars) { var nestedSymbols = ts.createMap(); - var lookupTable = ts.createMap(); + var lookupTable_1 = ts.createMap(); for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { var node = _a[_i]; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); var exportedSymbols = visit(resolvedModule); - extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable, node); + extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); } - for (var id in lookupTable) { - var exportsWithDuplicate = lookupTable[id].exportsWithDuplicate; + lookupTable_1.forEach(function (_a, id) { + var exportsWithDuplicate = _a.exportsWithDuplicate; // It's not an error if the file with multiple `export *`s with duplicate names exports a member with that name itself - if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols[id]) { - continue; + if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) { + return; } - for (var _b = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _b < exportsWithDuplicate_1.length; _b++) { - var node = exportsWithDuplicate_1[_b]; - diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable[id].specifierText, id)); + for (var _i = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _i < exportsWithDuplicate_1.length; _i++) { + var node = exportsWithDuplicate_1[_i]; + diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable_1.get(id).specifierText, id)); } - } + }); extendExportSymbols(symbols, nestedSymbols); } return symbols; @@ -25531,26 +26259,13 @@ var ts; : 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; + return !!(symbol.flags & 107455 /* Value */ || symbol.flags & 8388608 /* Alias */ && resolveAlias(symbol).flags & 107455 /* Value */); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 150 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 151 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -25578,6 +26293,9 @@ var ts; type.symbol = symbol; return type; } + function createTypeofType() { + return getUnionType(ts.convertToArray(typeofEQFacts.keys(), function (s) { return getLiteralTypeForText(32 /* StringLiteral */, s); })); + } // 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 @@ -25590,16 +26308,15 @@ var ts; } function getNamedMembers(members) { var result; - for (var id in members) { + members.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { if (!result) result = []; - var symbol = members[id]; if (symbolIsValue(symbol)) { result.push(symbol); } } - } + }); return result || emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -25618,20 +26335,20 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location_1 = enclosingDeclaration; location_1; location_1 = location_1.parent) { + for (var location = enclosingDeclaration; location; location = location.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)) { + if (location.locals && !isGlobalSourceFile(location)) { + if (result = callback(location.locals)) { return result; } } - switch (location_1.kind) { - case 261 /* SourceFile */: - if (!ts.isExternalOrCommonJsModule(location_1)) { + switch (location.kind) { + case 264 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230 /* ModuleDeclaration */: - if (result = callback(getSymbolOfNode(location_1).exports)) { + case 232 /* ModuleDeclaration */: + if (result = callback(getSymbolOfNode(location).exports)) { return result; } break; @@ -25675,14 +26392,14 @@ var ts; } function trySymbolTable(symbols) { // If symbol is directly available by its name in the symbol table - if (isAccessible(symbols[symbol.name])) { + if (isAccessible(symbols.get(symbol.name))) { return [symbol]; } // Check if symbol is any of the alias - return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { + return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -25711,7 +26428,7 @@ var ts; var qualify = false; forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { // If symbol of this name is not available in the symbol table we are ok - var symbolFromSymbolTable = symbolTable[symbol.name]; + var symbolFromSymbolTable = symbolTable.get(symbol.name); if (!symbolFromSymbolTable) { // Continue to the next symbol table return false; @@ -25722,7 +26439,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, 243 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -25737,10 +26454,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 147 /* PropertyDeclaration */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 148 /* PropertyDeclaration */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: continue; default: return false; @@ -25821,7 +26538,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 264 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -25862,12 +26579,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 160 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 161 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 141 /* QualifiedName */ || entityName.kind === 177 /* PropertyAccessExpression */ || - entityName.parent.kind === 234 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 142 /* QualifiedName */ || entityName.kind === 178 /* PropertyAccessExpression */ || + entityName.parent.kind === 236 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -25963,10 +26680,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 166 /* ParenthesizedType */) { + while (node.kind === 167 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 228 /* TypeAliasDeclaration */) { + if (node.kind === 230 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -25974,29 +26691,29 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 231 /* ModuleBlock */ && + node.parent.kind === 233 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { return type.flags & 32 /* StringLiteral */ ? "\"" + ts.escapeString(type.text) + "\"" : type.text; } - 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 197 /* ClassExpression */: - return "(Anonymous class)"; - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - return "(Anonymous function)"; - } + 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 198 /* ClassExpression */: + return "(Anonymous class)"; + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + return "(Anonymous function)"; } - return symbol.name; } + return symbol.name; + } + function getSymbolDisplayBuilder() { /** * 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 wrote the name. @@ -26038,7 +26755,7 @@ var ts; if (parentSymbol) { // Write type arguments of instantiated class/interface here if (flags & 1 /* WriteTypeParametersOrArguments */) { - if (symbol.flags & 16777216 /* Instantiated */) { + if (getCheckFlags(symbol) & 1 /* Instantiated */) { buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); } else { @@ -26066,9 +26783,9 @@ var ts; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. - var parent_5 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_5) { - walkSymbol(parent_5, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + walkSymbol(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); } } if (accessibleSymbolChain) { @@ -26106,7 +26823,7 @@ var ts; function writeType(type, flags) { var nextFlags = flags & ~512 /* InTypeAlias */; // Write undefined/null type as any - if (type.flags & 16015 /* Intrinsic */) { + if (type.flags & 16793231 /* 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" @@ -26133,7 +26850,7 @@ var ts; else if (!(flags & 512 /* InTypeAlias */) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === 0 /* Accessible */) { var typeArguments = type.aliasTypeArguments; - writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); + writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, ts.length(typeArguments), nextFlags); } else if (type.flags & 196608 /* UnionOrIntersection */) { writeUnionOrIntersectionType(type, nextFlags); @@ -26218,14 +26935,14 @@ var ts; while (i < length_1) { // Find group of type arguments for type parameters with the same declaring container. var start = i; - var parent_6 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_6); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); // 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_6, typeArguments, start, i, flags); + writeSymbolTypeReference(parent, typeArguments, start, i, flags); writePunctuation(writer, 22 /* DotToken */); } } @@ -26252,7 +26969,8 @@ var ts; 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 */)) { + if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (384 /* Enum */ | 512 /* ValueModule */)) { writeTypeOfSymbol(type, flags); } else if (shouldWriteTypeOfFunctionSymbol()) { @@ -26291,7 +27009,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 261 /* SourceFile */ || declaration.parent.kind === 231 /* ModuleBlock */; + return declaration.parent.kind === 264 /* SourceFile */ || declaration.parent.kind === 233 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -26305,32 +27023,13 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } - function writeIndexSignature(info, keyword) { - if (info) { - if (info.isReadonly) { - writeKeyword(writer, 130 /* ReadonlyKeyword */); - writeSpace(writer); - } - writePunctuation(writer, 20 /* OpenBracketToken */); - writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55 /* ColonToken */); - writeSpace(writer); - writeKeyword(writer, keyword); - writePunctuation(writer, 21 /* CloseBracketToken */); - writePunctuation(writer, 55 /* ColonToken */); - writeSpace(writer); - writeType(info.type, 0 /* None */); - writePunctuation(writer, 24 /* SemicolonToken */); - writer.writeLine(); - } - } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { writeKeyword(writer, 130 /* ReadonlyKeyword */); writeSpace(writer); } buildSymbolDisplay(prop, writer); - if (prop.flags & 536870912 /* Optional */) { + if (prop.flags & 67108864 /* Optional */) { writePunctuation(writer, 54 /* QuestionToken */); } } @@ -26407,8 +27106,8 @@ var ts; writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 134 /* StringKeyword */); - writeIndexSignature(resolved.numberIndexInfo, 132 /* NumberKeyword */); + buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0 /* String */, enclosingDeclaration, globalFlags, symbolStack); + buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, 1 /* Number */, enclosingDeclaration, globalFlags, symbolStack); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -26474,6 +27173,13 @@ var ts; writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } + var defaultType = getDefaultFromTypeParameter(tp); + if (defaultType) { + writeSpace(writer); + writePunctuation(writer, 57 /* EqualsToken */); + writeSpace(writer); + buildTypeDisplay(defaultType, writer, enclosingDeclaration, flags, symbolStack); + } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; @@ -26491,16 +27197,20 @@ var ts; } writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); - buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); + var type = getTypeOfSymbol(p); + if (isRequiredInitializedParameter(parameterNode)) { + type = includeFalsyTypes(type, 2048 /* Undefined */); + } + buildTypeDisplay(type, writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { // We have to explicitly emit square bracket and bracket because these tokens are not stored inside the node. - if (bindingPattern.kind === 172 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 173 /* ObjectBindingPattern */) { writePunctuation(writer, 16 /* OpenBraceToken */); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); writePunctuation(writer, 17 /* CloseBraceToken */); } - else if (bindingPattern.kind === 173 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 174 /* ArrayBindingPattern */) { writePunctuation(writer, 20 /* OpenBracketToken */); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -26514,7 +27224,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 174 /* BindingElement */); + ts.Debug.assert(bindingElement.kind === 175 /* BindingElement */); if (bindingElement.propertyName) { writer.writeProperty(ts.getTextOfNode(bindingElement.propertyName)); writePunctuation(writer, 55 /* ColonToken */); @@ -26588,6 +27298,10 @@ var ts; buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { + var returnType = getReturnTypeOfSignature(signature); + if (flags & 2048 /* SuppressAnyReturnType */ && isTypeAny(returnType)) { + return; + } if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); writePunctuation(writer, 35 /* EqualsGreaterThanToken */); @@ -26600,7 +27314,6 @@ var ts; buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); } else { - var returnType = getReturnTypeOfSignature(signature); buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } } @@ -26620,6 +27333,32 @@ var ts; buildDisplayForParametersAndDelimiters(signature.thisParameter, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } + function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 130 /* ReadonlyKeyword */); + writeSpace(writer); + } + writePunctuation(writer, 20 /* OpenBracketToken */); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 55 /* ColonToken */); + writeSpace(writer); + switch (kind) { + case 1 /* Number */: + writeKeyword(writer, 132 /* NumberKeyword */); + break; + case 0 /* String */: + writeKeyword(writer, 135 /* StringKeyword */); + break; + } + writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 55 /* ColonToken */); + writeSpace(writer); + buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); + writePunctuation(writer, 24 /* SemicolonToken */); + writer.writeLine(); + } + } return _displayBuilder || (_displayBuilder = { buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, @@ -26630,6 +27369,7 @@ var ts; buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, + buildIndexSignatureDisplay: buildIndexSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay }); } @@ -26644,75 +27384,75 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 174 /* BindingElement */: + case 175 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 223 /* VariableDeclaration */: + case 225 /* 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 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 225 /* FunctionDeclaration */: - case 229 /* EnumDeclaration */: - case 234 /* ImportEqualsDeclaration */: + case 232 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 227 /* FunctionDeclaration */: + case 231 /* EnumDeclaration */: + case 236 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_7 = getDeclarationContainer(node); + var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 234 /* ImportEqualsDeclaration */ && parent_7.kind !== 261 /* SourceFile */ && ts.isInAmbientContext(parent_7))) { - return isGlobalSourceFile(parent_7); + !(node.kind !== 236 /* ImportEqualsDeclaration */ && parent.kind !== 264 /* SourceFile */ && ts.isInAmbientContext(parent))) { + return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible - return isDeclarationVisible(parent_7); - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + return isDeclarationVisible(parent); + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: if (ts.getModifierFlags(node) & (8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so const it fall into next case statement - case 150 /* Constructor */: - case 154 /* ConstructSignature */: - case 153 /* CallSignature */: - case 155 /* IndexSignature */: - case 144 /* Parameter */: - case 231 /* ModuleBlock */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 161 /* TypeLiteral */: - case 157 /* TypeReference */: - case 162 /* ArrayType */: - case 163 /* TupleType */: - case 164 /* UnionType */: - case 165 /* IntersectionType */: - case 166 /* ParenthesizedType */: + case 151 /* Constructor */: + case 155 /* ConstructSignature */: + case 154 /* CallSignature */: + case 156 /* IndexSignature */: + case 145 /* Parameter */: + case 233 /* ModuleBlock */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 162 /* TypeLiteral */: + case 158 /* TypeReference */: + case 163 /* ArrayType */: + case 164 /* TupleType */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: + case 167 /* 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 236 /* ImportClause */: - case 237 /* NamespaceImport */: - case 239 /* ImportSpecifier */: + case 238 /* ImportClause */: + case 239 /* NamespaceImport */: + case 241 /* ImportSpecifier */: return false; // Type parameters are always visible - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: // Source file and namespace export are always visible - case 261 /* SourceFile */: - case 233 /* NamespaceExportDeclaration */: + case 264 /* SourceFile */: + case 235 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return false; default: return false; @@ -26721,10 +27461,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 240 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 242 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 243 /* ExportSpecifier */) { + else if (node.parent.kind === 245 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -26817,12 +27557,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 223 /* VariableDeclaration */: - case 224 /* VariableDeclarationList */: - case 239 /* ImportSpecifier */: - case 238 /* NamedImports */: - case 237 /* NamespaceImport */: - case 236 /* ImportClause */: + case 225 /* VariableDeclaration */: + case 226 /* VariableDeclarationList */: + case 241 /* ImportSpecifier */: + case 240 /* NamedImports */: + case 239 /* NamespaceImport */: + case 238 /* ImportClause */: node = node.parent; break; default: @@ -26846,9 +27586,6 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1 /* Any */) !== 0; } - function isTypeNever(type) { - return type && (type.flags & 8192 /* Never */) !== 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) { @@ -26856,7 +27593,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 142 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 143 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 6144 /* Nullable */); }); @@ -26869,17 +27606,16 @@ var ts; var members = ts.createMap(); var names = ts.createMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name_17 = properties_2[_i]; - names[ts.getTextOfPropertyName(name_17)] = true; + var name = properties_2[_i]; + names.set(ts.getTextOfPropertyName(name), true); } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - var inNamesToRemove = prop.name in names; + var inNamesToRemove = names.has(prop.name); var isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */); - var isMethod = prop.flags & 8192 /* Method */; var isSetOnlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { - members[prop.name] = prop; + if (!inNamesToRemove && !isPrivate && !isClassMethod(prop) && !isSetOnlyAccessor) { + members.set(prop.name, prop); } } var stringIndexInfo = getIndexInfoOfType(source, 0 /* String */); @@ -26904,7 +27640,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 172 /* ObjectBindingPattern */) { + if (pattern.kind === 173 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -26921,8 +27657,8 @@ var ts; } else { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) - var name_18 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_18)) { + var name = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name)) { // computed properties with non-literal names are treated as 'any' return anyType; } @@ -26931,12 +27667,12 @@ var ts; } // 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. - var text = ts.getTextOfPropertyName(name_18); + var text = ts.getTextOfPropertyName(name); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); if (!type) { - error(name_18, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_18)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); return unknownType; } } @@ -26976,7 +27712,7 @@ var ts; getUnionType([type, checkExpressionCached(declaration.initializer)], /*subtypeReduction*/ true) : type; } - function getTypeForVariableLikeDeclarationFromJSDocComment(declaration) { + function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); if (jsdocType) { return getTypeFromTypeNode(jsdocType); @@ -26989,29 +27725,38 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 175 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 176 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048 /* Undefined */) : type; } + /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ + function removeOptionalityFromAnnotation(annotatedType, declaration) { + var annotationIncludesUndefined = strictNullChecks && + declaration.kind === 145 /* Parameter */ && + declaration.initializer && + getFalsyFlags(annotatedType) & 2048 /* Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048 /* Undefined */); + return annotationIncludesUndefined ? getNonNullableType(annotatedType) : annotatedType; + } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { if (declaration.flags & 65536 /* JavaScriptFile */) { // If this is a variable in a JavaScript file, then use the JSDoc type (if it has // one as its type), otherwise fallback to the below standard TS codepaths to // try to figure it out. - var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); + var type = getTypeForDeclarationFromJSDocComment(declaration); if (type && type !== unknownType) { return type; } } // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (declaration.parent.parent.kind === 212 /* ForInStatement */) { + if (declaration.parent.parent.kind === 214 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 /* TypeParameter */ | 262144 /* Index */) ? indexType : stringType; } - if (declaration.parent.parent.kind === 213 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 215 /* 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, @@ -27023,10 +27768,11 @@ var ts; } // Use type from type annotation if one is present if (declaration.type) { - return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); + var declaredType = removeOptionalityFromAnnotation(getTypeFromTypeNode(declaration.type), declaration); + return addOptionality(declaredType, /*optional*/ declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & 65536 /* JavaScriptFile */) && - declaration.kind === 223 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 225 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !ts.isInAmbientContext(declaration)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no @@ -27040,11 +27786,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 144 /* Parameter */) { + if (declaration.kind === 145 /* 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 === 152 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 151 /* GetAccessor */); + if (func.kind === 153 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 152 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -27073,8 +27819,13 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality); } + if (ts.isJsxAttribute(declaration)) { + // if JSX attribute doesn't have initializer, by default the attribute will have boolean value of true. + // I.e is sugar for + return trueType; + } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 258 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 261 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -27084,6 +27835,23 @@ var ts; // No type specified and nothing can be inferred return undefined; } + // Return the inferred type for a variable, parameter, or property declaration + function getTypeForJSSpecialPropertyDeclaration(declaration) { + var expression = declaration.kind === 193 /* BinaryExpression */ ? declaration : + declaration.kind === 178 /* PropertyAccessExpression */ ? ts.getAncestor(declaration, 193 /* BinaryExpression */) : + undefined; + if (!expression) { + return unknownType; + } + if (expression.flags & 65536 /* JavaScriptFile */) { + // If there is a JSDoc type, use it + var type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type && type !== unknownType) { + return getWidenedType(type); + } + } + return getWidenedLiteralType(checkExpressionCached(expression.right)); + } // 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. @@ -27116,11 +27884,11 @@ var ts; return; } var text = ts.getTextOfPropertyName(name); - var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0); + var flags = 4 /* Property */ | (e.initializer ? 67108864 /* Optional */ : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; - members[symbol.name] = symbol; + members.set(symbol.name, symbol); }); var result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); if (includePatternInType) { @@ -27155,7 +27923,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 172 /* ObjectBindingPattern */ + return pattern.kind === 173 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -27177,7 +27945,7 @@ 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. - if (declaration.kind === 257 /* PropertyAssignment */) { + if (declaration.kind === 260 /* PropertyAssignment */) { return type; } return getWidenedType(type); @@ -27194,14 +27962,14 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 144 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 145 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { // Handle prototype property - if (symbol.flags & 134217728 /* Prototype */) { + if (symbol.flags & 16777216 /* Prototype */) { return links.type = getTypeOfPrototypeProperty(symbol); } // Handle catch clause variables @@ -27210,10 +27978,10 @@ var ts; return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 240 /* ExportAssignment */) { + if (declaration.kind === 242 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 286 /* JSDocPropertyTag */ && declaration.typeExpression) { + if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 290 /* JSDocPropertyTag */ && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } // Handle variable, parameter or property @@ -27226,19 +27994,9 @@ var ts; // * exports.p = expr // * this.p = expr // * className.prototype.method = expr - if (declaration.kind === 192 /* BinaryExpression */ || - declaration.kind === 177 /* PropertyAccessExpression */ && declaration.parent.kind === 192 /* BinaryExpression */) { - // Use JS Doc type if present on parent expression statement - if (declaration.flags & 65536 /* JavaScriptFile */) { - var jsdocType = ts.getJSDocType(declaration.parent); - if (jsdocType) { - return links.type = getTypeFromTypeNode(jsdocType); - } - } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 192 /* BinaryExpression */ ? - checkExpressionCached(decl.right) : - checkExpressionCached(decl.parent.right); }); - type = getUnionType(declaredTypes, /*subtypeReduction*/ true); + if (declaration.kind === 193 /* BinaryExpression */ || + declaration.kind === 178 /* PropertyAccessExpression */ && declaration.parent.kind === 193 /* BinaryExpression */) { + type = getWidenedType(getUnionType(ts.map(symbol.declarations, getTypeForJSSpecialPropertyDeclaration), /*subtypeReduction*/ true)); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); @@ -27252,7 +28010,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 151 /* GetAccessor */) { + if (accessor.kind === 152 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -27272,10 +28030,10 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 151 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 152 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 152 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 153 /* SetAccessor */); if (getter && getter.flags & 65536 /* JavaScriptFile */) { - var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); + var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; } @@ -27317,7 +28075,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 151 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 152 /* 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)); } } @@ -27325,6 +28083,10 @@ var ts; } return links.type; } + function getBaseTypeVariableOfClass(symbol) { + var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); + return baseConstructorType.flags & 540672 /* TypeVariable */ ? baseConstructorType : undefined; + } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { @@ -27333,8 +28095,13 @@ var ts; } else { var type = createObjectType(16 /* Anonymous */, symbol); - links.type = strictNullChecks && symbol.flags & 536870912 /* Optional */ ? - includeFalsyTypes(type, 2048 /* Undefined */) : type; + if (symbol.flags & 32 /* Class */) { + var baseTypeVariable = getBaseTypeVariableOfClass(symbol); + links.type = baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; + } + else { + links.type = strictNullChecks && symbol.flags & 67108864 /* Optional */ ? includeFalsyTypes(type, 2048 /* Undefined */) : type; + } } } return links.type; @@ -27388,7 +28155,7 @@ var ts; return anyType; } function getTypeOfSymbol(symbol) { - if (symbol.flags & 16777216 /* Instantiated */) { + if (getCheckFlags(symbol) & 1 /* Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { @@ -27414,16 +28181,21 @@ var ts; function hasBaseType(type, checkBase) { return check(type); function check(type) { - var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); + if (getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + var target = getTargetType(type); + return target === checkBase || ts.forEach(getBaseTypes(target), check); + } + else if (type.flags & 131072 /* Intersection */) { + return ts.forEach(type.types, 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, declarations_2 = declarations; _i < declarations_2.length; _i++) { - var declaration = declarations_2[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -27443,9 +28215,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 226 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */ || - node.kind === 225 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */ || - node.kind === 149 /* MethodDeclaration */ || node.kind === 185 /* ArrowFunction */) { + if (node.kind === 228 /* ClassDeclaration */ || node.kind === 198 /* ClassExpression */ || + node.kind === 227 /* FunctionDeclaration */ || node.kind === 185 /* FunctionExpression */ || + node.kind === 150 /* MethodDeclaration */ || node.kind === 186 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -27455,7 +28227,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, 227 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 229 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -27464,8 +28236,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 227 /* InterfaceDeclaration */ || node.kind === 226 /* ClassDeclaration */ || - node.kind === 197 /* ClassExpression */ || node.kind === 228 /* TypeAliasDeclaration */) { + if (node.kind === 229 /* InterfaceDeclaration */ || node.kind === 228 /* ClassDeclaration */ || + node.kind === 198 /* ClassExpression */ || node.kind === 230 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -27479,15 +28251,32 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } + // A type is a mixin constructor if it has a single construct signature taking no type parameters and a single + // rest parameter of type any[]. + function isMixinConstructorType(type) { + var signatures = getSignaturesOfType(type, 1 /* Construct */); + if (signatures.length === 1) { + var s = signatures[0]; + return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + } + return false; + } function isConstructorType(type) { - return type.flags & 32768 /* Object */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; + if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { + return true; + } + if (type.flags & 540672 /* TypeVariable */) { + var constraint = getBaseConstraintOfType(type); + return isValidBaseType(constraint) && isMixinConstructorType(constraint); + } + return false; } 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; }); + var typeArgCount = ts.length(typeArgumentNodes); + return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); @@ -27497,11 +28286,13 @@ var ts; } 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. + /** + * 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); @@ -27512,7 +28303,7 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 32768 /* Object */) { + if (baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */)) { // 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); @@ -27550,8 +28341,8 @@ var ts; } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - var baseConstructorType = getBaseConstructorTypeOfClass(type); - if (!(baseConstructorType.flags & 32768 /* Object */)) { + var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); + if (!(baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */))) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -27586,7 +28377,7 @@ var ts; if (baseType === unknownType) { return; } - if (!(getObjectFlags(getTargetType(baseType)) & 3 /* ClassOrInterface */)) { + if (!isValidBaseType(baseType)) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } @@ -27612,16 +28403,22 @@ var ts; } return true; } + // A valid base type is any non-generic object type or intersection of non-generic + // object types. + function isValidBaseType(type) { + return type.flags & (32768 /* Object */ | 16777216 /* NonPrimitive */) && !isGenericMappedType(type) || + type.flags & 131072 /* Intersection */ && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); + } 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 === 227 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 229 /* 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 (getObjectFlags(getTargetType(baseType)) & 3 /* ClassOrInterface */) { + if (isValidBaseType(baseType)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; @@ -27648,7 +28445,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 227 /* InterfaceDeclaration */) { + if (declaration.kind === 229 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -27686,7 +28483,7 @@ var ts; type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384 /* TypeParameter */); @@ -27705,7 +28502,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 285 /* JSDocTypedefTag */); + var declaration = ts.getDeclarationOfKind(symbol, 289 /* JSDocTypedefTag */); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -27716,7 +28513,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 228 /* TypeAliasDeclaration */); + declaration = ts.getDeclarationOfKind(symbol, 230 /* TypeAliasDeclaration */); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -27726,7 +28523,7 @@ var ts; // an instantiation of the type alias with the type parameters supplied as type arguments. links.typeParameters = typeParameters; links.instantiations = ts.createMap(); - links.instantiations[getTypeListId(typeParameters)] = type; + links.instantiations.set(getTypeListId(typeParameters), type); } } else { @@ -27743,14 +28540,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 /* NumericLiteral */ || - expr.kind === 190 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && + expr.kind === 191 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */ || - expr.kind === 70 /* Identifier */ && !!symbol.exports[expr.text]; + expr.kind === 70 /* Identifier */ && !!symbol.exports.get(expr.text); } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 /* EnumDeclaration */) { + if (declaration.kind === 231 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -27775,10 +28572,10 @@ var ts; enumType.symbol = symbol; if (enumHasLiteralMembers(symbol)) { var memberTypeList = []; - var memberTypes = ts.createMap(); + var memberTypes = []; for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 /* EnumDeclaration */) { + if (declaration.kind === 231 /* EnumDeclaration */) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -27795,7 +28592,7 @@ var ts; if (memberTypeList.length > 1) { enumType.flags |= 65536 /* Union */; enumType.types = memberTypeList; - unionTypes[getTypeListId(memberTypeList)] = enumType; + unionTypes.set(getTypeListId(memberTypeList), enumType); } } } @@ -27816,9 +28613,6 @@ var ts; if (!links.declaredType) { var type = createType(16384 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 143 /* TypeParameter */).constraint) { - type.constraint = noConstraintType; - } links.declaredType = type; } return links.declaredType; @@ -27831,7 +28625,6 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0); if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { return getDeclaredTypeOfClassOrInterface(symbol); } @@ -27870,19 +28663,20 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: + case 133 /* ObjectKeyword */: case 104 /* VoidKeyword */: - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: case 94 /* NullKeyword */: case 129 /* NeverKeyword */: - case 171 /* LiteralType */: + case 172 /* LiteralType */: return true; - case 162 /* ArrayType */: + case 163 /* ArrayType */: return isIndependentType(node.elementType); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return isIndependentTypeReference(node); } return false; @@ -27895,7 +28689,7 @@ var ts; // A function-like declaration is considered independent (free of this references) if it has a return type // annotation that is considered independent and if each parameter is considered independent. function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 150 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 151 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -27916,12 +28710,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return isIndependentVariableLikeDeclaration(declaration); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -27932,7 +28726,7 @@ var ts; var result = ts.createMap(); for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { var symbol = symbols_1[_i]; - result[symbol.name] = symbol; + result.set(symbol.name, symbol); } return result; } @@ -27942,15 +28736,15 @@ var ts; var result = ts.createMap(); 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); + result.set(symbol.name, mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; } function addInheritedMembers(symbols, baseSymbols) { for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) { var s = baseSymbols_1[_i]; - if (!symbols[s.name]) { - symbols[s.name] = s; + if (!symbols.has(s.name)) { + symbols.set(s.name, s); } } } @@ -27958,8 +28752,8 @@ var ts; 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.declaredCallSignatures = getSignaturesOfSymbol(symbol.members.get("__call")); + type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members.get("__new")); type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0 /* String */); type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1 /* Number */); } @@ -27967,7 +28761,14 @@ var ts; } function getTypeWithThisArgument(type, thisArgument) { if (getObjectFlags(type) & 4 /* Reference */) { - return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); + var target = type.target; + var typeArguments = type.typeArguments; + if (ts.length(target.typeParameters) === ts.length(typeArguments)) { + return createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); + } + } + else if (type.flags & 131072 /* Intersection */) { + return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument); })); } return type; } @@ -28003,7 +28804,7 @@ var ts; 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)); + addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0 /* String */); @@ -28046,13 +28847,14 @@ var ts; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); - var typeArgCount = typeArguments ? typeArguments.length : 0; + var typeArgCount = ts.length(typeArguments); var result = []; for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { var baseSig = baseSignatures_1[_i]; - var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; - if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); + var typeParamCount = ts.length(baseSig.typeParameters); + if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) { + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -28115,7 +28917,7 @@ var ts; s = cloneSignature(signature); if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) { var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return getTypeOfSymbol(sig.thisParameter) || anyType; }), /*subtypeReduction*/ true); - s.thisParameter = createTransientSymbol(signature.thisParameter, thisType); + s.thisParameter = createSymbolWithType(signature.thisParameter, thisType); } // Clear resolved return type we possibly got from cloneSignature s.resolvedReturnType = undefined; @@ -28160,22 +28962,57 @@ var ts; function unionSpreadIndexInfos(info1, info2) { return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly); } + function includeMixinType(type, types, index) { + var mixedTypes = []; + for (var i = 0; i < types.length; i++) { + if (i === index) { + mixedTypes.push(type); + } + else if (isMixinConstructorType(types[i])) { + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* Construct */)[0])); + } + } + return getIntersectionType(mixedTypes); + } 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 stringIndexInfo = undefined; - var numberIndexInfo = undefined; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + var stringIndexInfo; + var numberIndexInfo; + var types = type.types; + var mixinCount = ts.countWhere(types, isMixinConstructorType); + var _loop_3 = function (i) { + var t = type.types[i]; + // When an intersection type contains mixin constructor types, the construct signatures from + // those types are discarded and their return types are mixed into the return types of all + // other construct signatures in the intersection type. For example, the intersection type + // '{ new(...args: any[]) => A } & { new(s: string) => B }' has a single construct signature + // 'new(s: string) => A & B'. + if (mixinCount === 0 || mixinCount === types.length && i === 0 || !isMixinConstructorType(t)) { + var signatures = getSignaturesOfType(t, 1 /* Construct */); + if (signatures.length && mixinCount > 0) { + signatures = ts.map(signatures, function (s) { + var clone = cloneSignature(s); + clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, i); + return clone; + }); + } + constructSignatures = ts.concatenate(constructSignatures, signatures); + } callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1 /* Construct */)); stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0 /* String */)); numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); + }; + for (var i = 0; i < types.length; i++) { + _loop_3(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } + /** + * Converts an AnonymousType to a ResolvedType. + */ function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; if (type.target) { @@ -28188,8 +29025,8 @@ var ts; } else if (symbol.flags & 2048 /* TypeLiteral */) { var members = symbol.members; - var callSignatures = getSignaturesOfSymbol(members["__call"]); - var constructSignatures = getSignaturesOfSymbol(members["__new"]); + var callSignatures = getSignaturesOfSymbol(members.get("__call")); + var constructSignatures = getSignaturesOfSymbol(members.get("__new")); var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0 /* String */); var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1 /* Number */); setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -28203,14 +29040,14 @@ var ts; } if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); + constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 32768 /* Object */) { + if (baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */ | 540672 /* TypeVariable */)) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); + addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } } var numberIndexInfo = symbol.flags & 384 /* Enum */ ? enumNumberIndexInfo : undefined; @@ -28235,12 +29072,15 @@ var ts; var typeParameter = getTypeParameterFromMappedType(type); var constraintType = getConstraintTypeFromMappedType(type); var templateType = getTemplateTypeFromMappedType(type); - var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); + var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateReadonly = !!type.declaration.readonlyToken; var templateOptional = !!type.declaration.questionToken; - if (type.declaration.typeParameter.constraint.kind === 168 /* TypeOperator */) { + if (type.declaration.typeParameter.constraint.kind === 169 /* TypeOperator */) { // We have a { [P in keyof T]: X } - forEachType(getLiteralTypeFromPropertyNames(modifiersType), addMemberForKeyType); + for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { + var propertySymbol = _a[_i]; + addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol); + } if (getIndexInfoOfType(modifiersType, 0 /* String */)) { addMemberForKeyType(stringType); } @@ -28254,11 +29094,11 @@ var ts; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, undefined); - function addMemberForKeyType(t) { + function addMemberForKeyType(t, propertySymbol) { // Create a mapper from T to the current iteration type constituent. Then, if the // mapped type is itself an instantiated type, combine the iteration mapper with the // instantiation mapper. - var iterationMapper = createUnaryTypeMapper(typeParameter, t); + var iterationMapper = createTypeMapper([typeParameter], [t]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; var propType = instantiateType(templateType, templateMapper); // If the current iteration type constituent is a string literal type, create a property. @@ -28266,11 +29106,14 @@ var ts; if (t.flags & 32 /* StringLiteral */) { var propName = t.text; var modifiersProp = getPropertyOfType(modifiersType, propName); - var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 536870912 /* Optional */); - var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | (isOptional ? 536870912 /* Optional */ : 0), propName); + var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 67108864 /* Optional */); + var prop = createSymbol(4 /* Property */ | (isOptional ? 67108864 /* Optional */ : 0), propName); + prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 4 /* Readonly */ : 0; prop.type = propType; - prop.isReadonly = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp); - members[propName] = prop; + if (propertySymbol) { + prop.mappedTypeOrigin = propertySymbol; + } + members.set(propName, prop); } else if (t.flags & 2 /* String */) { stringIndexInfo = createIndexInfo(propType, templateReadonly); @@ -28294,7 +29137,7 @@ var ts; function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { var constraintDeclaration = type.declaration.typeParameter.constraint; - if (constraintDeclaration.kind === 168 /* TypeOperator */) { + if (constraintDeclaration.kind === 169 /* TypeOperator */) { // If the constraint declaration is a 'keyof T' node, the modifiers type is T. We check // AST nodes here because, when T is a non-generic type, the logic below eagerly resolves // 'keyof T' to a literal union type and we can't recover T from that type. @@ -28306,15 +29149,12 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is {}. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint.flags & 262144 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 262144 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; } - function getErasedTemplateTypeFromMappedType(type) { - return instantiateType(getTemplateTypeFromMappedType(type), createUnaryTypeMapper(getTypeParameterFromMappedType(type), anyType)); - } function isGenericMappedType(type) { if (getObjectFlags(type) & 32 /* Mapped */) { var constraintType = getConstraintTypeFromMappedType(type); @@ -28359,38 +29199,35 @@ var ts; function getPropertyOfObjectType(type, name) { if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && 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]; - getUnionOrIntersectionProperty(type, prop.name); - } - // The properties of a union type are those that are present in all constituent types, so - // we only need to check the properties of the first type - if (type.flags & 65536 /* Union */) { - break; - } - } - var props = type.resolvedProperties; - if (props) { - var result = []; - for (var key in props) { - var prop = props[key]; - // We need to filter out partial properties in union types - if (!(prop.flags & 268435456 /* SyntheticProperty */ && prop.isPartial)) { - result.push(prop); + if (!type.resolvedProperties) { + var members = ts.createMap(); + 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]; + if (!members.has(prop.name)) { + var combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.name); + if (combinedProp) { + members.set(prop.name, combinedProp); + } + } + } + // 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 & 65536 /* Union */) { + break; } } - return result; + type.resolvedProperties = getNamedMembers(members); } - return emptyArray; + return type.resolvedProperties; } function getPropertiesOfType(type) { type = getApparentType(type); @@ -28398,19 +29235,99 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } + function getConstraintOfType(type) { + return type.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + } + function getConstraintOfTypeParameter(typeParameter) { + return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; + } + function getBaseConstraintOfType(type) { + var constraint = getResolvedBaseConstraint(type); + return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + } + function hasNonCircularBaseConstraint(type) { + return getResolvedBaseConstraint(type) !== circularConstraintType; + } /** - * The apparent type of a type parameter is the base constraint instantiated with the type parameter - * as the type argument for the 'this' type. + * Return the resolved base constraint of a type variable. The noConstraintType singleton is returned if the + * type variable has no constraint, and the circularConstraintType singleton is returned if the constraint + * circularly references the type variable. */ - function getApparentTypeOfTypeVariable(type) { - if (!type.resolvedApparentType) { - var constraintType = getConstraintOfTypeVariable(type); - while (constraintType && constraintType.flags & 16384 /* TypeParameter */) { - constraintType = getConstraintOfTypeVariable(constraintType); - } - type.resolvedApparentType = getTypeWithThisArgument(constraintType || emptyObjectType, type); + function getResolvedBaseConstraint(type) { + var typeStack; + var circular; + if (!type.resolvedBaseConstraint) { + typeStack = []; + var constraint = getBaseConstraint(type); + type.resolvedBaseConstraint = circular ? circularConstraintType : getTypeWithThisArgument(constraint || noConstraintType, type); } - return type.resolvedApparentType; + return type.resolvedBaseConstraint; + function getBaseConstraint(t) { + if (ts.contains(typeStack, t)) { + circular = true; + return undefined; + } + typeStack.push(t); + var result = computeBaseConstraint(t); + typeStack.pop(); + return result; + } + function computeBaseConstraint(t) { + if (t.flags & 16384 /* TypeParameter */) { + var constraint = getConstraintFromTypeParameter(t); + return t.isThisType ? constraint : + constraint ? getBaseConstraint(constraint) : undefined; + } + if (t.flags & 196608 /* UnionOrIntersection */) { + var types = t.types; + var baseTypes = []; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var type_1 = types_2[_i]; + var baseType = getBaseConstraint(type_1); + if (baseType) { + baseTypes.push(baseType); + } + } + return t.flags & 65536 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 131072 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + undefined; + } + if (t.flags & 262144 /* Index */) { + return stringType; + } + if (t.flags & 524288 /* IndexedAccess */) { + var baseObjectType = getBaseConstraint(t.objectType); + var baseIndexType = getBaseConstraint(t.indexType); + var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; + return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + } + return t; + } + } + function getApparentTypeOfIntersectionType(type) { + return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type)); + } + /** + * Gets the default type for a type parameter. + * + * If the type parameter is the result of an instantiation, this gets the instantiated + * default type of its target. If the type parameter has no default type, `undefined` + * is returned. + * + * This function *does not* perform a circularity check. + */ + function getDefaultFromTypeParameter(typeParameter) { + if (!typeParameter.default) { + if (typeParameter.target) { + var targetDefault = getDefaultFromTypeParameter(typeParameter.target); + typeParameter.default = targetDefault ? instantiateType(targetDefault, typeParameter.mapper) : noConstraintType; + } + else { + var defaultDeclaration = typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameter(decl) && decl.default; }); + typeParameter.default = defaultDeclaration ? getTypeFromTypeNode(defaultDeclaration) : noConstraintType; + } + } + return typeParameter.default === noConstraintType ? undefined : typeParameter.default; } /** * For a type parameter, return the base constraint of the type parameter. For the string, number, @@ -28418,26 +29335,30 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - var t = type.flags & 540672 /* TypeVariable */ ? getApparentTypeOfTypeVariable(type) : type; - return t.flags & 262178 /* StringLike */ ? globalStringType : - t.flags & 340 /* NumberLike */ ? globalNumberType : - t.flags & 136 /* BooleanLike */ ? globalBooleanType : - t.flags & 512 /* ESSymbol */ ? getGlobalESSymbolType() : - t; + var t = type.flags & 540672 /* TypeVariable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; + return t.flags & 131072 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 262178 /* StringLike */ ? globalStringType : + t.flags & 340 /* NumberLike */ ? globalNumberType : + t.flags & 136 /* BooleanLike */ ? globalBooleanType : + t.flags & 512 /* ESSymbol */ ? getGlobalESSymbolType() : + t.flags & 16777216 /* NonPrimitive */ ? emptyObjectType : + t; } function createUnionOrIntersectionProperty(containingType, name) { - var types = containingType.types; var props; + var types = containingType.types; + var isUnion = containingType.flags & 65536 /* Union */; + var excludeModifiers = isUnion ? 24 /* NonPublicAccessibilityModifier */ : 0; // Flags we want to propagate to the result if they exist in all source symbols - var commonFlags = (containingType.flags & 131072 /* Intersection */) ? 536870912 /* Optional */ : 0 /* None */; - var isReadonly = false; - var isPartial = false; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var current = types_2[_i]; + var commonFlags = isUnion ? 0 /* None */ : 67108864 /* Optional */; + var checkFlags = 2 /* SyntheticProperty */; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var current = types_3[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */))) { + var modifiers = prop ? getDeclarationModifierFlagsFromSymbol(prop) : 0; + if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; if (!props) { props = [prop]; @@ -28445,25 +29366,26 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } - if (isReadonlySymbol(prop)) { - isReadonly = true; - } + checkFlags |= (isReadonlySymbol(prop) ? 4 /* Readonly */ : 0) | + (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 32 /* ContainsPublic */ : 0) | + (modifiers & 16 /* Protected */ ? 64 /* ContainsProtected */ : 0) | + (modifiers & 8 /* Private */ ? 128 /* ContainsPrivate */ : 0) | + (modifiers & 32 /* Static */ ? 256 /* ContainsStatic */ : 0); } - else if (containingType.flags & 65536 /* Union */) { - isPartial = true; + else if (isUnion) { + checkFlags |= 8 /* Partial */; } } } if (!props) { return undefined; } - if (props.length === 1 && !isPartial) { + if (props.length === 1 && !(checkFlags & 8 /* Partial */)) { return props[0]; } var propTypes = []; var declarations = []; var commonType = undefined; - var hasNonUniformType = false; for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { var prop = props_1[_a]; if (prop.declarations) { @@ -28474,17 +29396,15 @@ var ts; commonType = type; } else if (type !== commonType) { - hasNonUniformType = true; + checkFlags |= 16 /* HasNonUniformType */; } propTypes.push(type); } - var result = createSymbol(4 /* Property */ | 67108864 /* Transient */ | 268435456 /* SyntheticProperty */ | commonFlags, name); + var result = createSymbol(4 /* Property */ | commonFlags, name); + result.checkFlags = checkFlags; result.containingType = containingType; - result.hasNonUniformType = hasNonUniformType; - result.isPartial = isPartial; result.declarations = declarations; - result.isReadonly = isReadonly; - result.type = containingType.flags & 65536 /* Union */ ? getUnionType(propTypes) : getIntersectionType(propTypes); + result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } // Return the symbol for a given property in a union or intersection type, or undefined if the property @@ -28493,12 +29413,12 @@ var ts; // these partial properties when identifying discriminant properties, but otherwise they are filtered out // and do not appear to be present in the union type. function getUnionOrIntersectionProperty(type, name) { - var properties = type.resolvedProperties || (type.resolvedProperties = ts.createMap()); - var property = properties[name]; + var properties = type.propertyCache || (type.propertyCache = ts.createMap()); + var property = properties.get(name); if (!property) { property = createUnionOrIntersectionProperty(type, name); if (property) { - properties[name] = property; + properties.set(name, property); } } return property; @@ -28506,7 +29426,7 @@ var ts; function getPropertyOfUnionOrIntersectionType(type, name) { var property = getUnionOrIntersectionProperty(type, name); // We need to filter out partial properties in union types - return property && !(property.flags & 268435456 /* SyntheticProperty */ && property.isPartial) ? property : undefined; + return property && !(getCheckFlags(property) & 8 /* Partial */) ? property : undefined; } /** * Return the symbol for the property with the given name in the given type. Creates synthetic union properties when @@ -28520,7 +29440,7 @@ var ts; type = getApparentType(type); if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); - var symbol = resolved.members[name]; + var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } @@ -28609,16 +29529,16 @@ var ts; } function symbolsToArray(symbols) { var result = []; - for (var id in symbols) { + symbols.forEach(function (symbol, id) { if (!isReservedMemberName(id)) { - result.push(symbols[id]); + result.push(symbol); } - } + }); return result; } function isJSDocOptionalParameter(node) { if (node.flags & 65536 /* JavaScriptFile */) { - if (node.type && node.type.kind === 273 /* JSDocOptionalType */) { + if (node.type && node.type.kind === 277 /* JSDocOptionalType */) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -28629,7 +29549,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 273 /* JSDocOptionalType */; + return paramTag.typeExpression.type.kind === 277 /* JSDocOptionalType */; } } } @@ -28654,6 +29574,12 @@ var ts; ts.Debug.assert(parameterIndex >= 0); return parameterIndex >= signature.minArgumentCount; } + var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); + if (iife) { + return !node.type && + !node.dotDotDotToken && + ts.indexOf(node.parent.parameters, node) >= iife.arguments.length; + } return false; } function createTypePredicateFromTypePredicateNode(node) { @@ -28673,19 +29599,67 @@ var ts; }; } } + /** + * Gets the minimum number of type arguments needed to satisfy all non-optional type + * parameters. + */ + function getMinTypeArgumentCount(typeParameters) { + var minTypeArgumentCount = 0; + if (typeParameters) { + for (var i = 0; i < typeParameters.length; i++) { + if (!getDefaultFromTypeParameter(typeParameters[i])) { + minTypeArgumentCount = i + 1; + } + } + } + return minTypeArgumentCount; + } + /** + * Fill in default types for unsupplied type arguments. If `typeArguments` is undefined + * when a default type is supplied, a new array will be created and returned. + * + * @param typeArguments The supplied type arguments. + * @param typeParameters The requested type parameters. + * @param minTypeArgumentCount The minimum number of required type arguments. + */ + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount) { + var numTypeParameters = ts.length(typeParameters); + if (numTypeParameters) { + var numTypeArguments = ts.length(typeArguments); + if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) { + if (!typeArguments) { + typeArguments = []; + } + // Map an unsatisfied type parameter with a default type. + // If a type parameter does not have a default type, or if the default type + // is a forward reference, the empty object type is used. + for (var i = numTypeArguments; i < numTypeParameters; i++) { + typeArguments[i] = emptyObjectType; + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + var mapper = createTypeMapper(typeParameters, typeArguments); + var defaultType = getDefaultFromTypeParameter(typeParameters[i]); + typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType; + } + } + } + return typeArguments; + } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; var hasLiteralTypes = false; - var minArgumentCount = -1; + var minArgumentCount = 0; var thisParameter = undefined; var hasThisParameter = void 0; + var iife = ts.getImmediatelyInvokedFunctionExpression(declaration); var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); + var isUntypedSignatureInJSFile = !iife && !isJSConstructSignature && ts.isInJavaScriptFile(declaration) && !ts.hasJSDocParameterTags(declaration); // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct // signature. - for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { + for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; // Include parameter symbol instead of property symbol in the signature @@ -28700,43 +29674,36 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 171 /* LiteralType */) { + if (param.type && param.type.kind === 172 /* LiteralType */) { hasLiteralTypes = true; } - if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { - if (minArgumentCount < 0) { - minArgumentCount = i - (hasThisParameter ? 1 : 0); - } - } - else { - // If we see any required parameters, it means the prior ones were not in fact optional. - minArgumentCount = -1; + // Record a new minimum argument count if this is not an optional parameter + var isOptionalParameter_1 = param.initializer || param.questionToken || param.dotDotDotToken || + iife && parameters.length > iife.arguments.length && !param.type || + isJSDocOptionalParameter(param) || + isUntypedSignatureInJSFile; + if (!isOptionalParameter_1) { + minArgumentCount = parameters.length; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 151 /* GetAccessor */ || declaration.kind === 152 /* SetAccessor */) && + if ((declaration.kind === 152 /* GetAccessor */ || declaration.kind === 153 /* SetAccessor */) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 151 /* GetAccessor */ ? 152 /* SetAccessor */ : 151 /* GetAccessor */; + var otherKind = declaration.kind === 152 /* GetAccessor */ ? 153 /* SetAccessor */ : 152 /* GetAccessor */; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); - } - if (isJSConstructSignature) { - minArgumentCount--; - } - var classType = declaration.kind === 150 /* Constructor */ ? + var classType = declaration.kind === 151 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 156 /* TypePredicate */ ? + var typePredicate = declaration.type && declaration.type.kind === 157 /* TypePredicate */ ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -28761,8 +29728,8 @@ var ts; } // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 151 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 152 /* SetAccessor */); + if (declaration.kind === 152 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 153 /* SetAccessor */); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -28773,23 +29740,23 @@ var ts; if (!symbol) return emptyArray; var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { + for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 225 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 274 /* JSDocFunctionType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 278 /* JSDocFunctionType */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -28860,9 +29827,14 @@ var ts; return anyType; } function getSignatureInstantiation(signature, typeArguments) { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); - return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments)); + var instantiation = instantiations.get(id); + if (!instantiation) { + instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments)); + } + return instantiation; } function createSignatureInstantiation(signature, typeArguments) { return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), /*eraseTypeParameters*/ true); @@ -28881,7 +29853,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 === 150 /* Constructor */ || signature.declaration.kind === 154 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 151 /* Constructor */ || signature.declaration.kind === 155 /* ConstructSignature */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = emptyArray; @@ -28892,10 +29864,10 @@ var ts; return signature.isolatedSignatureType; } function getIndexSymbol(symbol) { - return symbol.members["__index"]; + return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 132 /* NumberKeyword */ : 134 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 132 /* NumberKeyword */ : 135 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -28922,21 +29894,9 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 143 /* TypeParameter */).constraint; + return ts.getDeclarationOfKind(type.symbol, 144 /* TypeParameter */).constraint; } - function hasConstraintReferenceTo(type, target) { - var checked; - while (type && type.flags & 16384 /* TypeParameter */ && !(type.isThisType) && !ts.contains(checked, type)) { - if (type === target) { - return true; - } - (checked || (checked = [])).push(type); - var constraintDeclaration = getConstraintDeclaration(type); - type = constraintDeclaration && getTypeFromTypeNode(constraintDeclaration); - } - return false; - } - function getConstraintOfTypeParameter(typeParameter) { + function getConstraintFromTypeParameter(typeParameter) { if (!typeParameter.constraint) { if (typeParameter.target) { var targetConstraint = getConstraintOfTypeParameter(typeParameter.target); @@ -28944,23 +29904,13 @@ var ts; } else { var constraintDeclaration = getConstraintDeclaration(typeParameter); - var constraint = getTypeFromTypeNode(constraintDeclaration); - if (hasConstraintReferenceTo(constraint, typeParameter)) { - error(constraintDeclaration, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); - constraint = unknownType; - } - typeParameter.constraint = constraint; + typeParameter.constraint = constraintDeclaration ? getTypeFromTypeNode(constraintDeclaration) : noConstraintType; } } return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } - function getConstraintOfTypeVariable(type) { - return type.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 524288 /* IndexedAccess */ ? type.constraint : - undefined; - } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 143 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 144 /* TypeParameter */).parent); } function getTypeListId(types) { var result = ""; @@ -28991,8 +29941,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var type = types_3[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -29001,9 +29951,10 @@ var ts; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); - var type = target.instantiations[id]; + var type = target.instantiations.get(id); if (!type) { - type = target.instantiations[id] = createObjectType(4 /* Reference */, target.symbol); + type = createObjectType(4 /* Reference */, target.symbol); + target.instantiations.set(id, type); type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; type.typeArguments = typeArguments; @@ -29019,21 +29970,26 @@ var ts; return type; } function getTypeReferenceArity(type) { - return type.target.typeParameters ? type.target.typeParameters.length : 0; + return ts.length(type.target.typeParameters); } // Get type from reference to class or interface function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(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); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), minTypeArgumentCount, 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))); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount)); + return createTypeReference(type, typeArguments); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); @@ -29046,7 +30002,11 @@ var ts; var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + var instantiation = links.instantiations.get(id); + if (!instantiation) { + links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + } + return instantiation; } // 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 @@ -29055,8 +30015,12 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).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); + var numTypeArguments = ts.length(node.typeArguments); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, minTypeArgumentCount === typeParameters.length + ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s + : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return unknownType; } var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); @@ -29078,11 +30042,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 157 /* TypeReference */: + case 158 /* TypeReference */: return node.typeName; - case 272 /* JSDocTypeReference */: + case 276 /* JSDocTypeReference */: return node.name; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -29108,7 +30072,7 @@ var ts; if (symbol.flags & 524288 /* TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 /* Value */ && node.kind === 272 /* JSDocTypeReference */) { + if (symbol.flags & 107455 /* Value */ && node.kind === 276 /* JSDocTypeReference */) { // A JSDocTypeReference may have resolved to a value (as opposed to a type). In // that case, the type of this reference is just the type of the value we resolved // to. @@ -29121,14 +30085,14 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 272 /* JSDocTypeReference */) { + if (node.kind === 276 /* JSDocTypeReference */) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 157 /* TypeReference */ + var typeNameOrExpression = node.kind === 158 /* TypeReference */ ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -29160,12 +30124,12 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var declaration = declarations_4[_i]; switch (declaration.kind) { - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: return declaration; } } @@ -29178,7 +30142,7 @@ var ts; 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) { + if (ts.length(type.typeParameters) !== arity) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); return arity ? emptyGenericType : emptyObjectType; } @@ -29250,7 +30214,7 @@ var ts; for (var i = 0; i < arity; i++) { var typeParameter = createType(16384 /* TypeParameter */); typeParameters.push(typeParameter); - var property = createSymbol(4 /* Property */ | 67108864 /* Transient */, "" + i); + var property = createSymbol(4 /* Property */, "" + i); property.type = typeParameter; properties.push(property); } @@ -29259,7 +30223,7 @@ var ts; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; type.instantiations = ts.createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(16384 /* TypeParameter */); @@ -29343,14 +30307,14 @@ 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 addTypesToUnion(typeSet, types) { - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var t = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var t = types_6[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -29358,8 +30322,9 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; + if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } } @@ -29445,10 +30410,11 @@ var ts; return types[0]; } var id = getTypeListId(types); - var type = unionTypes[id]; + var type = unionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 6144 /* Nullable */); - type = unionTypes[id] = createType(65536 /* Union */ | propagatedFlags); + type = createType(65536 /* Union */ | propagatedFlags); + unionTypes.set(id, type); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -29473,14 +30439,17 @@ var ts; if (type.flags & 65536 /* Union */ && typeSet.unionIndex === undefined) { typeSet.unionIndex = typeSet.length; } - typeSet.push(type); + if (!(type.flags & 32768 /* Object */ && type.objectFlags & 16 /* Anonymous */ && + type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */) && containsIdenticalType(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 addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; addTypeToIntersection(typeSet, type); } } @@ -29515,10 +30484,11 @@ var ts; /*subtypeReduction*/ false, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); - var type = intersectionTypes[id]; + var type = intersectionTypes.get(id); if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 6144 /* Nullable */); - type = intersectionTypes[id] = createType(131072 /* Intersection */ | propagatedFlags); + type = createType(131072 /* Intersection */ | propagatedFlags); + intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -29568,28 +30538,10 @@ var ts; var type = createType(524288 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; - // We eagerly compute the constraint of the indexed access type such that circularity - // errors are immediately caught and reported. For example, class C { x: this["x"] } - // becomes an error only when the constraint is eagerly computed. - if (type.objectType.flags & 229376 /* StructuredType */) { - // The constraint of T[K], where T is an object, union, or intersection type, - // is the type of the string index signature of T, if any. - type.constraint = getIndexTypeOfType(type.objectType, 0 /* String */); - } - else if (type.objectType.flags & 540672 /* TypeVariable */) { - // The constraint of T[K], where T is a type variable, is A[K], where A is the - // apparent type of T. - var apparentType = getApparentTypeOfTypeVariable(type.objectType); - if (apparentType !== emptyObjectType) { - type.constraint = isTypeOfKind(type.indexType, 262178 /* StringLike */) ? - getIndexedAccessType(apparentType, type.indexType) : - getIndexTypeOfType(apparentType, 0 /* String */); - } - } return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 178 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 /* ElementAccessExpression */ ? accessNode : undefined; var propName = indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */ | 256 /* EnumLiteral */) ? indexType.text : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -29618,7 +30570,7 @@ var ts; getIndexInfoOfType(objectType, 0 /* String */) || undefined; if (indexInfo) { - if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); return unknownType; } @@ -29637,7 +30589,7 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 178 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 179 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); } @@ -29651,12 +30603,12 @@ var ts; return unknownType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 178 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 179 /* ElementAccessExpression */ ? accessNode : undefined; if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); return unknownType; } - var mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); + var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } @@ -29668,18 +30620,11 @@ var ts; // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved // eagerly using the constraint type of 'this' at the given location. if (maybeTypeOfKind(indexType, 540672 /* TypeVariable */ | 262144 /* Index */) || - maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && !(accessNode && accessNode.kind === 178 /* ElementAccessExpression */) || + maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && !(accessNode && accessNode.kind === 179 /* ElementAccessExpression */) || isGenericMappedType(objectType)) { if (objectType.flags & 1 /* Any */) { return objectType; } - // We first check that the index type is assignable to 'keyof T' for the object type. - if (accessNode) { - if (!isTypeAssignableTo(indexType, getIndexType(objectType))) { - error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); - return unknownType; - } - } // If the object type is a mapped type { [P in K]: E }, we instantiate E using a mapper that substitutes // the index type for P. For example, for an index access { [P in K]: Box }[X], we construct the // type Box. @@ -29688,7 +30633,11 @@ var ts; } // Otherwise we defer the operation by creating an indexed access type. var id = objectType.id + "," + indexType.id; - return indexedAccessTypes[id] || (indexedAccessTypes[id] = createIndexedAccessType(objectType, indexType)); + var type = indexedAccessTypes.get(id); + if (!type) { + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType)); + } + return type; } // In the following we resolve T[K] to the type of the property in T selected by K. var apparentObjectType = getApparentType(objectType); @@ -29732,7 +30681,7 @@ var ts; if (!links.resolvedType) { // Deferred resolution of members is handled by resolveObjectTypeMembers var aliasSymbol = getAliasSymbolForTypeNode(node); - if (ts.isEmpty(node.symbol.members) && !aliasSymbol) { + if (node.symbol.members.size === 0 && !aliasSymbol) { links.resolvedType = emptyTypeLiteralType; } else { @@ -29745,7 +30694,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 228 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 230 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -29756,7 +30705,7 @@ var ts; * this function should be called in a left folding style, with left = previous result of getSpreadType * and right = the new element to be spread. */ - function getSpreadType(left, right, isFromObjectLiteral) { + function getSpreadType(left, right) { if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { return anyType; } @@ -29769,10 +30718,13 @@ var ts; return left; } if (left.flags & 65536 /* Union */) { - return mapType(left, function (t) { return getSpreadType(t, right, isFromObjectLiteral); }); + return mapType(left, function (t) { return getSpreadType(t, right); }); } if (right.flags & 65536 /* Union */) { - return mapType(right, function (t) { return getSpreadType(left, t, isFromObjectLiteral); }); + return mapType(right, function (t) { return getSpreadType(left, t); }); + } + if (right.flags & 16777216 /* NonPrimitive */) { + return emptyObjectType; } var members = ts.createMap(); var skippedPrivateMembers = ts.createMap(); @@ -29790,42 +30742,45 @@ var ts; for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; // we approximate own properties as non-methods plus methods that are inside the object literal - var isOwnProperty = !(rightProp.flags & 8192 /* Method */) || isFromObjectLiteral; var isSetterWithoutGetter = rightProp.flags & 65536 /* SetAccessor */ && !(rightProp.flags & 32768 /* GetAccessor */); if (getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { - skippedPrivateMembers[rightProp.name] = true; + skippedPrivateMembers.set(rightProp.name, true); } - else if (isOwnProperty && !isSetterWithoutGetter) { - members[rightProp.name] = rightProp; + else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { + members.set(rightProp.name, rightProp); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { var leftProp = _c[_b]; if (leftProp.flags & 65536 /* SetAccessor */ && !(leftProp.flags & 32768 /* GetAccessor */) - || leftProp.name in skippedPrivateMembers) { + || skippedPrivateMembers.has(leftProp.name) + || isClassMethod(leftProp)) { continue; } - if (leftProp.name in members) { - var rightProp = members[leftProp.name]; + if (members.has(leftProp.name)) { + var rightProp = members.get(leftProp.name); var rightType = getTypeOfSymbol(rightProp); - if (maybeTypeOfKind(rightType, 2048 /* Undefined */) || rightProp.flags & 536870912 /* Optional */) { + if (maybeTypeOfKind(rightType, 2048 /* Undefined */) || rightProp.flags & 67108864 /* Optional */) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 /* Property */ | 67108864 /* Transient */ | (leftProp.flags & 536870912 /* Optional */); + var flags = 4 /* Property */ | (leftProp.flags & 67108864 /* Optional */); var result = createSymbol(flags, leftProp.name); + result.checkFlags = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp) ? 4 /* Readonly */ : 0; result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072 /* NEUndefined */)]); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; - result.isReadonly = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp); - members[leftProp.name] = result; + members.set(leftProp.name, result); } } else { - members[leftProp.name] = leftProp; + members.set(leftProp.name, leftProp); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } + function isClassMethod(prop) { + return prop.flags & 8192 /* Method */ && ts.find(prop.declarations, function (decl) { return ts.isClassLike(decl.parent); }); + } function createLiteralType(flags, text) { var type = createType(flags); type.text = text; @@ -29847,7 +30802,11 @@ var ts; } function getLiteralTypeForText(flags, text) { var map = flags & 32 /* StringLiteral */ ? stringLiteralTypes : numericLiteralTypes; - return map[text] || (map[text] = createLiteralType(flags, text)); + var type = map.get(text); + if (!type) { + map.set(text, type = createLiteralType(flags, text)); + } + return type; } function getTypeFromLiteralTypeNode(node) { var links = getNodeLinks(node); @@ -29875,9 +30834,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 227 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 229 /* InterfaceDeclaration */)) { if (!(ts.getModifierFlags(container) & 32 /* Static */) && - (container.kind !== 150 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 151 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -29894,87 +30853,89 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 118 /* AnyKeyword */: - case 263 /* JSDocAllType */: - case 264 /* JSDocUnknownType */: + case 267 /* JSDocAllType */: + case 268 /* JSDocUnknownType */: return anyType; - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: return stringType; case 132 /* NumberKeyword */: return numberType; case 121 /* BooleanKeyword */: return booleanType; - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: return esSymbolType; case 104 /* VoidKeyword */: return voidType; - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: return undefinedType; case 94 /* NullKeyword */: return nullType; case 129 /* NeverKeyword */: return neverType; - case 289 /* JSDocNullKeyword */: + case 133 /* ObjectKeyword */: + return nonPrimitiveType; + case 293 /* JSDocNullKeyword */: return nullType; - case 290 /* JSDocUndefinedKeyword */: + case 294 /* JSDocUndefinedKeyword */: return undefinedType; - case 291 /* JSDocNeverKeyword */: + case 295 /* JSDocNeverKeyword */: return neverType; - case 167 /* ThisType */: + case 168 /* ThisType */: case 98 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 171 /* LiteralType */: + case 172 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 288 /* JSDocLiteralType */: + case 292 /* JSDocLiteralType */: return getTypeFromLiteralTypeNode(node.literal); - case 157 /* TypeReference */: - case 272 /* JSDocTypeReference */: + case 158 /* TypeReference */: + case 276 /* JSDocTypeReference */: return getTypeFromTypeReference(node); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return booleanType; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 162 /* ArrayType */: - case 265 /* JSDocArrayType */: + case 163 /* ArrayType */: + case 269 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); - case 163 /* TupleType */: + case 164 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 164 /* UnionType */: - case 266 /* JSDocUnionType */: + case 165 /* UnionType */: + case 270 /* JSDocUnionType */: return getTypeFromUnionTypeNode(node); - case 165 /* IntersectionType */: + case 166 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 166 /* ParenthesizedType */: - case 268 /* JSDocNullableType */: - case 269 /* JSDocNonNullableType */: - case 276 /* JSDocConstructorType */: - case 277 /* JSDocThisType */: - case 273 /* JSDocOptionalType */: + case 167 /* ParenthesizedType */: + case 272 /* JSDocNullableType */: + case 273 /* JSDocNonNullableType */: + case 280 /* JSDocConstructorType */: + case 281 /* JSDocThisType */: + case 277 /* JSDocOptionalType */: return getTypeFromTypeNode(node.type); - case 270 /* JSDocRecordType */: + case 274 /* JSDocRecordType */: return getTypeFromTypeNode(node.literal); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 161 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 274 /* JSDocFunctionType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 162 /* TypeLiteral */: + case 291 /* JSDocTypeLiteral */: + case 278 /* JSDocFunctionType */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 168 /* TypeOperator */: + case 169 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 170 /* MappedType */: + case 171 /* MappedType */: return getTypeFromMappedTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 70 /* Identifier */: - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 267 /* JSDocTupleType */: + case 271 /* JSDocTupleType */: return getTypeFromJSDocTupleType(node); - case 275 /* JSDocVariadicType */: + case 279 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -30001,13 +30962,13 @@ var ts; var instantiations = mapper.instantiations || (mapper.instantiations = []); return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); } - function createUnaryTypeMapper(source, target) { + function makeUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } - function createBinaryTypeMapper(source1, target1, source2, target2) { + function makeBinaryTypeMapper(source1, target1, source2, target2) { return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; } - function createArrayTypeMapper(sources, targets) { + function makeArrayTypeMapper(sources, targets) { return function (t) { for (var i = 0; i < sources.length; i++) { if (t === sources[i]) { @@ -30018,16 +30979,24 @@ var ts; }; } function createTypeMapper(sources, targets) { - var count = sources.length; - var mapper = count == 1 ? createUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : - count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : - createArrayTypeMapper(sources, targets); + var mapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : + makeArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; return mapper; } function createTypeEraser(sources) { return createTypeMapper(sources, undefined); } + /** + * Maps forward-references to later types parameters to the empty object type. + * This is used during inference when instantiating type parameter defaults. + */ + function createBackreferenceMapper(typeParameters, index) { + var mapper = function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; + mapper.mappedTypes = typeParameters; + return mapper; + } function getInferenceMapper(context) { if (!context.mapper) { var mapper = function (t) { @@ -30051,7 +31020,12 @@ var ts; } function combineTypeMappers(mapper1, mapper2) { var mapper = function (t) { return instantiateType(mapper1(t), mapper2); }; - mapper.mappedTypes = mapper1.mappedTypes; + mapper.mappedTypes = ts.concatenate(mapper1.mappedTypes, mapper2.mappedTypes); + return mapper; + } + function createReplacementMapper(source, target, baseMapper) { + var mapper = function (t) { return t === source ? target : baseMapper(t); }; + mapper.mappedTypes = baseMapper.mappedTypes; return mapper; } function cloneTypeParameter(typeParameter) { @@ -30099,7 +31073,7 @@ var ts; return result; } function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 16777216 /* Instantiated */) { + if (getCheckFlags(symbol) & 1 /* 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 @@ -30109,7 +31083,8 @@ var 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. - var result = createSymbol(16777216 /* Instantiated */ | 67108864 /* Transient */ | symbol.flags, symbol.name); + var result = createSymbol(symbol.flags, symbol.name); + result.checkFlags = 1 /* Instantiated */; result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -30136,17 +31111,16 @@ var ts; var constraintType = getConstraintTypeFromMappedType(type); if (constraintType.flags & 262144 /* Index */) { var typeVariable_1 = constraintType.type; - var mappedTypeVariable = instantiateType(typeVariable_1, mapper); - if (typeVariable_1 !== mappedTypeVariable) { - return mapType(mappedTypeVariable, function (t) { - if (isMappableType(t)) { - var replacementMapper = createUnaryTypeMapper(typeVariable_1, t); - var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); - } - return t; - }); + if (typeVariable_1.flags & 16384 /* TypeParameter */) { + var mappedTypeVariable = instantiateType(typeVariable_1, mapper); + if (typeVariable_1 !== mappedTypeVariable) { + return mapType(mappedTypeVariable, function (t) { + if (isMappableType(t)) { + return instantiateMappedObjectType(type, createReplacementMapper(typeVariable_1, t, mapper)); + } + return t; + }); + } } } return instantiateMappedObjectType(type, mapper); @@ -30170,26 +31144,26 @@ var ts; // Starting with the parent of the symbol's declaration, check if the mapper maps any of // the type parameters introduced by enclosing declarations. We just pick the first // declaration since multiple declarations will all have the same parent anyway. - var node = symbol.declarations[0].parent; + var node = symbol.declarations[0]; while (node) { switch (node.kind) { - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 225 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -30199,15 +31173,29 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 227 /* InterfaceDeclaration */) { + if (ts.isClassLike(node) || node.kind === 229 /* InterfaceDeclaration */) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 230 /* ModuleDeclaration */: - case 261 /* SourceFile */: + case 171 /* MappedType */: + if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { + return true; + } + break; + case 278 /* JSDocFunctionType */: + var func = node; + for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { + var p = _c[_b]; + if (ts.contains(mappedTypes, getTypeOfNode(p))) { + return true; + } + } + break; + case 232 /* ModuleDeclaration */: + case 264 /* SourceFile */: return false; } node = node.parent; @@ -30217,7 +31205,7 @@ var ts; function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 261 /* SourceFile */ || parentKind === 231 /* ModuleBlock */; + return parentKind === 264 /* SourceFile */ || parentKind === 233 /* ModuleBlock */; } return false; } @@ -30294,28 +31282,36 @@ 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 !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return node.operatorToken.kind === 53 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 257 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return isContextSensitive(node.expression); + case 253 /* JsxAttributes */: + return ts.forEach(node.properties, isContextSensitive); + case 252 /* JsxAttribute */: + // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. + return node.initializer && isContextSensitive(node.initializer); + case 255 /* JsxExpression */: + // It is possible to that node.expression is undefined (e.g
) + return node.expression && isContextSensitive(node.expression); } return false; } @@ -30329,7 +31325,7 @@ var ts; return true; } // For arrow functions we now know we're not context sensitive. - if (node.kind === 185 /* ArrowFunction */) { + if (node.kind === 186 /* ArrowFunction */) { return false; } // If the first parameter is not an explicit 'this' parameter, then the function has @@ -30351,9 +31347,12 @@ var ts; result.properties = resolved.properties; result.callSignatures = emptyArray; result.constructSignatures = emptyArray; - type = result; + return result; } } + else if (type.flags & 131072 /* Intersection */) { + return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); + } return type; } // TYPE CHECKING @@ -30376,7 +31375,7 @@ var ts; // subtype of T but not structurally identical to T. This specifically means that two distinct but // structurally identical types (such as two classes) are not considered instances of each other. function isTypeInstanceOf(source, target) { - return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + return getTargetType(source) === getTargetType(target) || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); } /** * This is *not* a bi-directional relationship. @@ -30544,13 +31543,15 @@ var ts; return true; } var id = source.id + "," + target.id; - if (enumRelation[id] !== undefined) { - return enumRelation[id]; + var relation = enumRelation.get(id); + if (relation !== undefined) { + return relation; } if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & 256 /* RegularEnum */) || !(target.symbol.flags & 256 /* RegularEnum */) || (source.flags & 65536 /* Union */) !== (target.flags & 65536 /* Union */)) { - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } var targetEnumType = getTypeOfSymbol(target.symbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(source.symbol)); _i < _a.length; _i++) { @@ -30561,11 +31562,13 @@ var ts; if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, property.name, typeToString(target, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */)); } - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } } } - return enumRelation[id] = true; + enumRelation.set(id, true); + return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { if (target.flags & 8192 /* Never */) @@ -30586,6 +31589,8 @@ var ts; return true; if (source.flags & 4096 /* Null */ && (!strictNullChecks || target.flags & 4096 /* Null */)) return true; + if (source.flags & 32768 /* Object */ && target.flags & 16777216 /* NonPrimitive */) + return true; if (relation === assignableRelation || relation === comparableRelation) { if (source.flags & 1 /* Any */) return true; @@ -30617,12 +31622,12 @@ var ts; } if (source.flags & 32768 /* Object */ && target.flags & 32768 /* Object */) { var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { return related === 1 /* Succeeded */; } } - if (source.flags & 507904 /* StructuredOrTypeParameter */ || target.flags & 507904 /* StructuredOrTypeParameter */) { + if (source.flags & 1032192 /* StructuredOrTypeVariable */ || target.flags & 1032192 /* StructuredOrTypeVariable */) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -30710,10 +31715,12 @@ var ts; } return false; } - // 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. + /** + * 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; if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 1048576 /* FreshLiteral */) { @@ -30799,16 +31806,6 @@ var ts; } } } - else { - // Given a type parameter K with a constraint keyof T, a type S is - // assignable to K if S is assignable to keyof T. - var constraint = getConstraintOfTypeParameter(target); - if (constraint && constraint.flags & 262144 /* Index */) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - return result; - } - } - } } else if (target.flags & 262144 /* Index */) { // A keyof S is related to a keyof T if T is related to S. @@ -30817,14 +31814,12 @@ var ts; return result; } } - // Given a type variable T with a constraint C, a type S is assignable to - // keyof T if S is assignable to keyof C. - if (target.type.flags & 540672 /* TypeVariable */) { - var constraint = getConstraintOfTypeVariable(target.type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } + // A type S is assignable to keyof T if S is assignable to keyof C, where C is the + // constraint of T. + var constraint = getConstraintOfType(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; } } } @@ -30838,8 +31833,9 @@ var ts; } // A type S is related to a type T[K] if S is related to A[K], where K is string-like and // A is the apparent type of S. - if (target.constraint) { - if (result = isRelatedTo(source, target.constraint, reportErrors)) { + var constraint = getBaseConstraintOfType(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -30857,24 +31853,28 @@ var ts; } else { var constraint = getConstraintOfTypeParameter(source); - if (!constraint || constraint.flags & 1 /* Any */) { - constraint = emptyObjectType; - } - // The constraint may need to be further instantiated with its 'this' type. - constraint = getTypeWithThisArgument(constraint, source); - // 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; + // A type parameter with no constraint is not related to the non-primitive object type. + if (constraint || !(target.flags & 16777216 /* NonPrimitive */)) { + if (!constraint || constraint.flags & 1 /* Any */) { + constraint = emptyObjectType; + } + // The constraint may need to be further instantiated with its 'this' type. + constraint = getTypeWithThisArgument(constraint, source); + // 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 & 524288 /* IndexedAccess */) { // A type S[K] is related to a type T if A[K] is related to T, where K is string-like and // A is the apparent type of S. - if (source.constraint) { - if (result = isRelatedTo(source.constraint, target, reportErrors)) { + var constraint = getBaseConstraintOfType(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -30938,45 +31938,61 @@ var ts; // 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) { + function isKnownProperty(type, name, isComparingJsxAttributes) { if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); - if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) || - resolved.stringIndexInfo || - (resolved.numberIndexInfo && isNumericLiteralName(name)) || - getPropertyOfType(type, name)) { + if ((relation === assignableRelation || relation === comparableRelation) && + (type === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(resolved)))) { + return true; + } + else if (resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name))) { + return true; + } + else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) { + // For JSXAttributes, if the attribute has a hyphenated name, consider that the attribute to be known. return true; } } else if (type.flags & 196608 /* UnionOrIntersection */) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (isKnownProperty(t, name)) { + if (isKnownProperty(t, name, isComparingJsxAttributes)) { return true; } } } return false; } - function isEmptyObjectType(t) { + function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && t.constructSignatures.length === 0 && !t.stringIndexInfo && !t.numberIndexInfo; } + function isEmptyObjectType(type) { + return type.flags & 32768 /* Object */ && isEmptyResolvedType(resolveStructuredTypeMembers(type)); + } function hasExcessProperties(source, target, reportErrors) { if (maybeTypeOfKind(target, 32768 /* Object */) && !(getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + var isComparingJsxAttributes = !!(source.flags & 33554432 /* JsxAttributes */); for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; - if (!isKnownProperty(target, prop.name)) { + if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) { 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. ts.Debug.assert(!!errorNode); - 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)); + if (ts.isJsxAttributes(errorNode)) { + // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. + // However, using an object-literal error message will be very confusing to the users so we give different a message. + reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); + } + else { + 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; } @@ -31002,20 +32018,42 @@ var ts; if (target.flags & 65536 /* Union */ && containsType(targetTypes, source)) { return -1 /* True */; } - var len = targetTypes.length; - for (var i = 0; i < len; i++) { - var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); + for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { + var type = targetTypes_1[_i]; + var related = isRelatedTo(source, type, /*reportErrors*/ false); if (related) { return related; } } + if (reportErrors) { + var discriminantType = findMatchingDiscriminantType(source, target); + isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); + } return 0 /* False */; } + function findMatchingDiscriminantType(source, target) { + var sourceProperties = getPropertiesOfObjectType(source); + if (sourceProperties) { + for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { + var sourceProperty = sourceProperties_1[_i]; + if (isDiscriminantProperty(target, sourceProperty.name)) { + var sourceType = getTypeOfSymbol(sourceProperty); + for (var _a = 0, _b = target.types; _a < _b.length; _a++) { + var type = _b[_a]; + var targetType = getTypeOfPropertyOfType(type, sourceProperty.name); + if (targetType && isRelatedTo(sourceType, targetType)) { + return type; + } + } + } + } + } + } function typeRelatedToEachType(source, target, reportErrors) { var result = -1 /* True */; var targetTypes = target.types; - for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { - var targetType = targetTypes_1[_i]; + for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { + var targetType = targetTypes_2[_i]; var related = isRelatedTo(source, targetType, reportErrors); if (!related) { return 0 /* False */; @@ -31078,12 +32116,12 @@ var ts; return 0 /* False */; } var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - var related = relation[id]; + var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2 /* Failed */) { // We are elaborating errors and the cached result is an unreported failure. Record the result as a reported // failure and continue computing the relation such that errors get reported. - relation[id] = 3 /* FailedAndReported */; + relation.set(id, 3 /* FailedAndReported */); } else { return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; @@ -31092,7 +32130,7 @@ var ts; 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]) { + if (maybeStack[i].get(id)) { return 1 /* Maybe */; } } @@ -31110,7 +32148,7 @@ var ts; sourceStack[depth] = source; targetStack[depth] = target; maybeStack[depth] = ts.createMap(); - maybeStack[depth][id] = 1 /* Succeeded */; + maybeStack[depth].set(id, 1 /* Succeeded */); depth++; var saveExpandingFlags = expandingFlags; if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) @@ -31145,40 +32183,45 @@ var ts; 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.copyProperties(maybeCache, destinationCache); + ts.copyEntries(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 */; + relation.set(id, reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */); } return result; } - // A type [P in S]: X is related to a type [P in T]: Y if T is related to S and X is related to Y. + // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is + // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice + // that S and T are contra-variant whereas X and Y are co-variant. function mappedTypeRelatedTo(source, target, reportErrors) { if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { - var result_2; - if (relation === identityRelation) { - var readonlyMatches = !source.declaration.readonlyToken === !target.declaration.readonlyToken; - var optionalMatches = !source.declaration.questionToken === !target.declaration.questionToken; - if (readonlyMatches && optionalMatches) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getErasedTemplateTypeFromMappedType(source), getErasedTemplateTypeFromMappedType(target), reportErrors); - } - } - } - else { - if (relation === comparableRelation || !source.declaration.questionToken || target.declaration.questionToken) { - if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result_2 & isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors); - } + var sourceReadonly = !!source.declaration.readonlyToken; + var sourceOptional = !!source.declaration.questionToken; + var targetReadonly = !!target.declaration.readonlyToken; + var targetOptional = !!target.declaration.questionToken; + var modifiersRelated = relation === identityRelation ? + sourceReadonly === targetReadonly && sourceOptional === targetOptional : + relation === comparableRelation || !sourceOptional || targetOptional; + if (modifiersRelated) { + var result_2; + if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { + var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); + return result_2 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } + else if (target.declaration.questionToken && isEmptyObjectType(source)) { + return -1 /* True */; + } } - else if (relation !== identityRelation && isEmptyObjectType(resolveStructuredTypeMembers(target))) { - return -1 /* True */; + else if (relation !== identityRelation) { + var resolved = resolveStructuredTypeMembers(target); + if (isEmptyResolvedType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & 1 /* Any */) { + return -1 /* True */; + } } return 0 /* False */; } @@ -31194,17 +32237,23 @@ var ts; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { - if (!(targetProp.flags & 536870912 /* Optional */) || requireOptionalProperties) { + if (!(targetProp.flags & 67108864 /* 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 */)) { + else if (!(targetProp.flags & 16777216 /* Prototype */)) { var sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { + if (getCheckFlags(sourceProp) & 128 /* ContainsPrivate */) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); + } + return 0 /* False */; + } if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { @@ -31218,12 +32267,9 @@ var ts; } } else if (targetPropFlags & 16 /* Protected */) { - var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32 /* Class */; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(getParentOfSymbol(sourceProp)) : undefined; - var targetClass = getDeclaredTypeOfSymbol(getParentOfSymbol(targetProp)); - if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { + if (!isValidOverrideOf(sourceProp, targetProp)) { 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)); + reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } return 0 /* False */; } @@ -31243,7 +32289,7 @@ var ts; } result &= related; // When checking for comparability, be more lenient with optional properties. - if (relation !== comparableRelation && sourceProp.flags & 536870912 /* Optional */ && !(targetProp.flags & 536870912 /* Optional */)) { + if (relation !== comparableRelation && sourceProp.flags & 67108864 /* Optional */ && !(targetProp.flags & 67108864 /* 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.. @@ -31271,8 +32317,8 @@ var ts; return 0 /* False */; } var result = -1 /* True */; - for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { - var sourceProp = sourceProperties_1[_i]; + for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) { + var sourceProp = sourceProperties_2[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return 0 /* False */; @@ -31345,7 +32391,7 @@ var ts; return 0 /* False */; } var result = -1 /* True */; - for (var i = 0, len = sourceSignatures.length; i < len; i++) { + for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { return 0 /* False */; @@ -31445,6 +32491,45 @@ var ts; return false; } } + // Invoke the callback for each underlying property symbol of the given symbol and return the first + // value that isn't undefined. + function forEachProperty(prop, callback) { + if (getCheckFlags(prop) & 2 /* SyntheticProperty */) { + for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var p = getPropertyOfType(t, prop.name); + var result = p && forEachProperty(p, callback); + if (result) { + return result; + } + } + return undefined; + } + return callback(prop); + } + // Return the declaring class type of a property or undefined if property not declared in class + function getDeclaringClass(prop) { + return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + } + // Return true if some underlying source property is declared in a class that derives + // from the given base class. + function isPropertyInClassDerivedFrom(prop, baseClass) { + return forEachProperty(prop, function (sp) { + var sourceClass = getDeclaringClass(sp); + return sourceClass ? hasBaseType(sourceClass, baseClass) : false; + }); + } + // Return true if source property is a valid override of protected parts of target property. + function isValidOverrideOf(sourceProp, targetProp) { + return !forEachProperty(targetProp, function (tp) { return getDeclarationModifierFlagsFromSymbol(tp) & 16 /* Protected */ ? + !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); + } + // Return true if the given class derives from each of the declaring classes of the protected + // constituents of the given property. + function isClassDerivedFromDeclaringClasses(checkClass, prop) { + return forEachProperty(prop, function (p) { return getDeclarationModifierFlagsFromSymbol(p) & 16 /* Protected */ ? + !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; + } // Return true if the given type is the constructor type for an abstract class function isAbstractConstructorType(type) { if (getObjectFlags(type) & 16 /* Anonymous */) { @@ -31500,7 +32585,7 @@ var ts; } } else { - if ((sourceProp.flags & 536870912 /* Optional */) !== (targetProp.flags & 536870912 /* Optional */)) { + if ((sourceProp.flags & 67108864 /* Optional */) !== (targetProp.flags & 67108864 /* Optional */)) { return 0 /* False */; } } @@ -31544,7 +32629,7 @@ var ts; // the constraints with a common set of type arguments to get relatable entities in places where // type parameters occur in the constraints. The complexity of doing that doesn't seem worthwhile, // particularly as we're comparing erased versions of the signatures below. - if ((source.typeParameters ? source.typeParameters.length : 0) !== (target.typeParameters ? target.typeParameters.length : 0)) { + if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { return 0 /* False */; } // Spec 1.0 Section 3.8.3 & 3.8.4: @@ -31584,8 +32669,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var t = types_7[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var t = types_9[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -31593,8 +32678,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var t = types_8[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -31700,8 +32785,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getFalsyFlags(t); } return result; @@ -31733,7 +32818,7 @@ var ts; types.push(undefinedType); if (flags & 4096 /* Null */) types.push(nullType); - return getUnionType(types, /*subtypeReduction*/ true); + return getUnionType(types); } function removeDefinitelyFalsyTypes(type) { return getFalsyFlags(type) & 7392 /* DefinitelyFalsy */ ? @@ -31752,8 +32837,8 @@ var ts; getSignaturesOfType(type, 0 /* Call */).length === 0 && getSignaturesOfType(type, 1 /* Construct */).length === 0; } - function createTransientSymbol(source, type) { - var symbol = createSymbol(source.flags | 67108864 /* Transient */, source.name); + function createSymbolWithType(source, type) { + var symbol = createSymbol(source.flags, source.name); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -31769,7 +32854,7 @@ var ts; var property = _a[_i]; var original = getTypeOfSymbol(property); var updated = f(original); - members[property.name] = updated === original ? property : createTransientSymbol(property, updated); + members.set(property.name, updated === original ? property : createSymbolWithType(property, updated)); } ; return members; @@ -31871,25 +32956,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 144 /* Parameter */: + case 145 /* 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 174 /* BindingElement */: + case 175 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 225 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -31982,7 +33067,7 @@ var ts; var typeInferencesArray = [typeInferences]; var templateType = getTemplateTypeFromMappedType(target); var readonlyMask = target.declaration.readonlyToken ? false : true; - var optionalMask = target.declaration.questionToken ? 0 : 536870912 /* Optional */; + var optionalMask = target.declaration.questionToken ? 0 : 67108864 /* Optional */; var members = createSymbolTable(properties); for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var prop = properties_4[_i]; @@ -31990,11 +33075,11 @@ var ts; if (!inferredPropType) { return undefined; } - var inferredProp = createSymbol(4 /* Property */ | 67108864 /* Transient */ | prop.flags & optionalMask, prop.name); + var inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.name); + inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 4 /* Readonly */ : 0; inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; - inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop); - members[prop.name] = inferredProp; + members.set(prop.name, inferredProp); } if (indexInfo) { var inferredIndexType = inferTargetType(indexInfo.type); @@ -32131,8 +33216,8 @@ var ts; var typeVariableCount = 0; var typeVariable = void 0; // First infer to each type in union or intersection that isn't a type variable - for (var _d = 0, targetTypes_2 = targetTypes; _d < targetTypes_2.length; _d++) { - var t = targetTypes_2[_d]; + for (var _d = 0, targetTypes_3 = targetTypes; _d < targetTypes_3.length; _d++) { + var t = targetTypes_3[_d]; if (t.flags & 540672 /* TypeVariable */ && ts.contains(typeVariables, t)) { typeVariable = t; typeVariableCount++; @@ -32168,10 +33253,10 @@ var ts; return; } var key = source.id + "," + target.id; - if (visited[key]) { + if (visited.get(key)) { return; } - visited[key] = true; + visited.set(key, true); if (depth === 0) { sourceStack = []; targetStack = []; @@ -32269,8 +33354,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -32320,11 +33405,20 @@ var ts; 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. + // Infer either the default or 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; + var defaultType = getDefaultFromTypeParameter(context.signature.typeParameters[index]); + if (defaultType) { + // Instantiate the default type. Any forward reference to a type + // parameter should be instantiated to the empty object type. + inferredType = instantiateType(defaultType, combineTypeMappers(createBackreferenceMapper(context.signature.typeParameters, index), getInferenceMapper(context))); + } + else { + inferredType = emptyObjectType; + } inferenceSucceeded = true; } context.inferredTypes[index] = inferredType; @@ -32367,10 +33461,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 160 /* TypeQuery */: + case 161 /* TypeQuery */: return true; case 70 /* Identifier */: - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: node = node.parent; continue; default: @@ -32391,7 +33485,7 @@ var ts; if (node.kind === 98 /* ThisKeyword */) { return "0"; } - if (node.kind === 177 /* PropertyAccessExpression */) { + if (node.kind === 178 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -32402,7 +33496,7 @@ var ts; case 70 /* Identifier */: case 98 /* ThisKeyword */: return node; - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -32411,19 +33505,19 @@ var ts; switch (source.kind) { case 70 /* Identifier */: return target.kind === 70 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 223 /* VariableDeclaration */ || target.kind === 174 /* BindingElement */) && + (target.kind === 225 /* VariableDeclaration */ || target.kind === 175 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98 /* ThisKeyword */: return target.kind === 98 /* ThisKeyword */; - case 177 /* PropertyAccessExpression */: - return target.kind === 177 /* PropertyAccessExpression */ && + case 178 /* PropertyAccessExpression */: + return target.kind === 178 /* PropertyAccessExpression */ && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 177 /* PropertyAccessExpression */) { + while (source.kind === 178 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -32436,7 +33530,7 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 177 /* PropertyAccessExpression */ && + return target.kind === 178 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -32444,7 +33538,7 @@ var ts; if (expr.kind === 70 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 177 /* PropertyAccessExpression */) { + if (expr.kind === 178 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -32453,9 +33547,9 @@ var ts; function isDiscriminantProperty(type, name) { if (type && type.flags & 65536 /* Union */) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && prop.flags & 268435456 /* SyntheticProperty */) { + if (prop && getCheckFlags(prop) & 2 /* SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.hasNonUniformType && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.checkFlags & 16 /* HasNonUniformType */ && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -32474,7 +33568,7 @@ var ts; } } } - if (callExpression.expression.kind === 177 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 178 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -32516,8 +33610,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -32527,7 +33621,7 @@ var ts; // check. This gives us a quicker out in the common case where an object type is not a function. var resolved = resolveStructuredTypeMembers(type); return !!(resolved.callSignatures.length || resolved.constructSignatures.length || - resolved.members["bind"] && isTypeSubtypeOf(type, globalFunctionType)); + resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type) { var flags = type.flags; @@ -32570,6 +33664,9 @@ var ts; if (flags & 512 /* ESSymbol */) { return strictNullChecks ? 1981320 /* SymbolStrictFacts */ : 4193160 /* SymbolFacts */; } + if (flags & 16777216 /* NonPrimitive */) { + return strictNullChecks ? 6166480 /* ObjectStrictFacts */ : 8378320 /* ObjectFacts */; + } if (flags & 16384 /* TypeParameter */) { var constraint = getConstraintOfTypeParameter(type); return getTypeFacts(constraint || emptyObjectType); @@ -32605,10 +33702,16 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 175 /* ArrayLiteralExpression */ || node.parent.kind === 257 /* PropertyAssignment */ ? + var isDestructuringDefaultAssignment = node.parent.kind === 176 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 260 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } + function isDestructuringAssignmentTarget(parent) { + return parent.parent.kind === 193 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 215 /* ForOfStatement */ && parent.parent.initializer === parent; + } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); } @@ -32624,21 +33727,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: return stringType; - case 213 /* ForOfStatement */: + case 215 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return undefinedType; - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 257 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 258 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -32646,7 +33749,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 172 /* ObjectBindingPattern */ ? + var type = pattern.kind === 173 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -32664,35 +33767,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 212 /* ForInStatement */) { + if (node.parent.parent.kind === 214 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 213 /* ForOfStatement */) { + if (node.parent.parent.kind === 215 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 223 /* VariableDeclaration */ ? + return node.kind === 225 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 223 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */ ? + return node.kind === 225 /* VariableDeclaration */ || node.kind === 175 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 223 /* VariableDeclaration */ && node.initializer && + return node.kind === 225 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 174 /* BindingElement */ && node.parent.kind === 192 /* BinaryExpression */ && + node.kind !== 175 /* BindingElement */ && node.parent.kind === 193 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: switch (node.operatorToken.kind) { case 57 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -32704,13 +33807,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 183 /* ParenthesizedExpression */ || - parent.kind === 192 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || - parent.kind === 192 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? + return parent.kind === 184 /* ParenthesizedExpression */ || + parent.kind === 193 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || + parent.kind === 193 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 253 /* CaseClause */) { + if (clause.kind === 256 /* CaseClause */) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -32825,8 +33928,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; if (!(t.flags & 8192 /* Never */)) { if (!(getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -32849,11 +33952,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 177 /* PropertyAccessExpression */ && (parent.name.text === "length" || - parent.parent.kind === 179 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 178 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 178 /* PropertyAccessExpression */ && (parent.name.text === "length" || + parent.parent.kind === 180 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 179 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 192 /* BinaryExpression */ && + parent.parent.kind === 193 /* BinaryExpression */ && parent.parent.operatorToken.kind === 57 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -32882,7 +33985,7 @@ var ts; } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215 /* Narrowable */)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 17810431 /* Narrowable */)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -32896,7 +33999,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 201 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { + if (reference.parent.kind === 202 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { return declaredType; } return resultType; @@ -32913,7 +34016,19 @@ var ts; } } var type = void 0; - if (flow.flags & 16 /* Assignment */) { + if (flow.flags & 4096 /* AfterFinally */) { + // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement + flow.locked = true; + type = getTypeAtFlowNode(flow.antecedent); + flow.locked = false; + } + else if (flow.flags & 2048 /* PreFinally */) { + // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel + // so here just redirect to antecedent + flow = flow.antecedent; + continue; + } + else if (flow.flags & 16 /* Assignment */) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; @@ -32945,7 +34060,7 @@ var ts; else if (flow.flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 177 /* PropertyAccessExpression */) { + if (container && container !== flowContainer && reference.kind !== 178 /* PropertyAccessExpression */) { flow = container.flowNode; continue; } @@ -32999,7 +34114,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 179 /* CallExpression */ ? + var expr = node.kind === 180 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -33007,7 +34122,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 179 /* CallExpression */) { + if (node.kind === 180 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -33066,6 +34181,12 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; + if (antecedent.flags & 2048 /* PreFinally */ && antecedent.lock.locked) { + // if flow correspond to branch from pre-try to finally and this branch is locked - this means that + // we initially have started following the flow outside the finally block. + // in this case we should ignore this branch. + continue; + } var flowType = getTypeAtFlowNode(antecedent); var type = getTypeFromFlowType(flowType); // If the type at a particular antecedent path is the declared type and the @@ -33098,8 +34219,9 @@ var ts; if (!key) { key = getFlowCacheKey(reference); } - if (cache[key]) { - return cache[key]; + var cached = cache.get(key); + if (cached) { + return cached; } // If this flow loop junction and reference are already being processed, return // the union of the types computed for each branch so far, marked as incomplete. @@ -33134,8 +34256,9 @@ var ts; // If we see a value appear in the cache it is a sign that control flow analysis // was restarted and completed by checkExpressionCached. We can simply pick up // the resulting type and bail out. - if (cache[key]) { - return cache[key]; + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; } if (!ts.contains(antecedentTypes, type)) { antecedentTypes.push(type); @@ -33159,10 +34282,11 @@ var ts; if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } - return cache[key] = result; + cache.set(key, result); + return result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 177 /* PropertyAccessExpression */ && + return expr.kind === 178 /* PropertyAccessExpression */ && declaredType.flags & 65536 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -33196,10 +34320,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 187 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { + if (left_1.kind === 188 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 187 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { + if (right_1.kind === 188 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -33245,7 +34369,7 @@ var ts; assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; return getTypeWithFacts(type, facts); } - if (type.flags & 33281 /* NotUnionOrUnit */) { + if (type.flags & 16810497 /* NotUnionOrUnit */) { return type; } if (assumeTrue) { @@ -33276,14 +34400,14 @@ var ts; // We narrow a non-union type to an exact primitive type if the non-union type // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. - var targetType = typeofTypesByName[literal.text]; + var targetType = typeofTypesByName.get(literal.text); if (targetType && isTypeSubtypeOf(targetType, type)) { return targetType; } } var facts = assumeTrue ? - typeofEQFacts[literal.text] || 64 /* TypeofEQHostObject */ : - typeofNEFacts[literal.text] || 8192 /* TypeofNEHostObject */; + typeofEQFacts.get(literal.text) || 64 /* TypeofEQHostObject */ : + typeofNEFacts.get(literal.text) || 8192 /* TypeofNEHostObject */; return getTypeWithFacts(type, facts); } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { @@ -33398,7 +34522,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 178 /* ElementAccessExpression */ || invokedExpression.kind === 177 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 179 /* ElementAccessExpression */ || invokedExpression.kind === 178 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -33417,15 +34541,15 @@ var ts; switch (expr.kind) { case 70 /* Identifier */: case 98 /* ThisKeyword */: - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: if (expr.operator === 50 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -33461,9 +34585,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 231 /* ModuleBlock */ || - node.kind === 261 /* SourceFile */ || - node.kind === 147 /* PropertyDeclaration */) { + node.kind === 233 /* ModuleBlock */ || + node.kind === 264 /* SourceFile */ || + node.kind === 148 /* PropertyDeclaration */) { return node; } } @@ -33495,7 +34619,7 @@ var ts; if (node.kind === 70 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 144 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 145 /* Parameter */) { symbol.isAssigned = true; } } @@ -33521,7 +34645,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 185 /* ArrowFunction */) { + if (container.kind === 186 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { @@ -33542,7 +34666,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration_1.kind === 226 /* ClassDeclaration */ + if (declaration_1.kind === 228 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -33554,14 +34678,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 197 /* ClassExpression */) { + else if (declaration_1.kind === 198 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 147 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 148 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration_1).flags |= 8388608 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 16777216 /* ConstructorReferenceInClass */; } @@ -33573,6 +34697,7 @@ var ts; } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); + checkCollisionWithCapturedNewTargetVariable(node, node); checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; @@ -33595,15 +34720,15 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 144 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 145 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 184 /* FunctionExpression */ || - flowContainer.kind === 185 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 185 /* FunctionExpression */ || + flowContainer.kind === 186 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -33611,7 +34736,7 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0 || isInTypeQuery(node)) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph @@ -33646,7 +34771,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 256 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 259 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -33671,8 +34796,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 211 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 224 /* VariableDeclarationList */).parent === container && + if (container.kind === 213 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 226 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -33686,7 +34811,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { var current = node; // skip parenthesized nodes - while (current.parent.kind === 183 /* ParenthesizedExpression */) { + while (current.parent.kind === 184 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -33694,7 +34819,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 190 /* PrefixUnaryExpression */ || current.parent.kind === 191 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 191 /* PrefixUnaryExpression */ || current.parent.kind === 192 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 42 /* PlusPlusToken */ || expr.operator === 43 /* MinusMinusToken */; } @@ -33715,7 +34840,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 147 /* PropertyDeclaration */ || container.kind === 150 /* Constructor */) { + if (container.kind === 148 /* PropertyDeclaration */ || container.kind === 151 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -33783,36 +34908,38 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; - if (container.kind === 150 /* Constructor */) { + if (container.kind === 151 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 185 /* ArrowFunction */) { + if (container.kind === 186 /* 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 /* ES2015 */); } switch (container.kind) { - case 230 /* ModuleDeclaration */: + case 232 /* 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 229 /* EnumDeclaration */: + case 231 /* 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 150 /* Constructor */: + case 151 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); + // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: if (ts.getModifierFlags(container) & 32 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); + // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -33824,7 +34951,7 @@ var ts; // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated. // If this is a function in a JS file, it might be a class method. Check if it's the RHS // of a x.prototype.y = function [name]() { .... } - if (container.kind === 184 /* FunctionExpression */ && + if (container.kind === 185 /* FunctionExpression */ && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') @@ -33861,28 +34988,28 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 274 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 278 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 277 /* JSDocThisType */) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 281 /* JSDocThisType */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 144 /* Parameter */) { + if (n.kind === 145 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 179 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 180 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 185 /* ArrowFunction */) { + while (container && container.kind === 186 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -33896,16 +35023,16 @@ var ts; // [super.foo()]() {} // } var current = node; - while (current && current !== container && current.kind !== 142 /* ComputedPropertyName */) { + while (current && current !== container && current.kind !== 143 /* ComputedPropertyName */) { current = current.parent; } - if (current && current.kind === 142 /* ComputedPropertyName */) { + if (current && current.kind === 143 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 176 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 177 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -33913,7 +35040,7 @@ var ts; } return unknownType; } - if (!isCallExpression && container.kind === 150 /* Constructor */) { + if (!isCallExpression && container.kind === 151 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if ((ts.getModifierFlags(container) & 32 /* Static */) || isCallExpression) { @@ -33979,7 +35106,7 @@ var ts; // This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set. // This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment // while a property access can. - if (container.kind === 149 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { + if (container.kind === 150 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -33993,7 +35120,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 176 /* ObjectLiteralExpression */) { + if (container.parent.kind === 177 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -34013,7 +35140,7 @@ var ts; } return unknownType; } - if (container.kind === 150 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 151 /* 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; @@ -34028,7 +35155,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 === 150 /* Constructor */; + return container.kind === 151 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -34036,21 +35163,21 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 176 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 177 /* ObjectLiteralExpression */) { if (ts.getModifierFlags(container) & 32 /* Static */) { - return container.kind === 149 /* MethodDeclaration */ || - container.kind === 148 /* MethodSignature */ || - container.kind === 151 /* GetAccessor */ || - container.kind === 152 /* SetAccessor */; + return container.kind === 150 /* MethodDeclaration */ || + container.kind === 149 /* MethodSignature */ || + container.kind === 152 /* GetAccessor */ || + container.kind === 153 /* SetAccessor */; } else { - return container.kind === 149 /* MethodDeclaration */ || - container.kind === 148 /* MethodSignature */ || - container.kind === 151 /* GetAccessor */ || - container.kind === 152 /* SetAccessor */ || - container.kind === 147 /* PropertyDeclaration */ || - container.kind === 146 /* PropertySignature */ || - container.kind === 150 /* Constructor */; + return container.kind === 150 /* MethodDeclaration */ || + container.kind === 149 /* MethodSignature */ || + container.kind === 152 /* GetAccessor */ || + container.kind === 153 /* SetAccessor */ || + container.kind === 148 /* PropertyDeclaration */ || + container.kind === 147 /* PropertySignature */ || + container.kind === 151 /* Constructor */; } } } @@ -34058,7 +35185,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 185 /* ArrowFunction */) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 186 /* ArrowFunction */) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -34074,23 +35201,23 @@ var ts; var func = parameter.parent; if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { var iife = ts.getImmediatelyInvokedFunctionExpression(func); - if (iife) { + if (iife && iife.arguments) { var indexOfParameter = ts.indexOf(func.parameters, parameter); - if (iife.arguments && indexOfParameter < iife.arguments.length) { - if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return createArrayType(getUnionType(restTypes)); + if (parameter.dotDotDotToken) { + var restTypes = []; + for (var i = indexOfParameter; i < iife.arguments.length; i++) { + restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); } - var links = getNodeLinks(iife); - var cached = links.resolvedSignature; - links.resolvedSignature = anySignature; - var type = getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])); - links.resolvedSignature = cached; - return type; + return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; } + var links = getNodeLinks(iife); + var cached = links.resolvedSignature; + links.resolvedSignature = anySignature; + var type = indexOfParameter < iife.arguments.length ? + getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + parameter.initializer ? undefined : undefinedWideningType; + links.resolvedSignature = cached; + return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -34124,7 +35251,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 144 /* Parameter */) { + if (declaration.kind === 145 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -34135,11 +35262,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_19 = declaration.propertyName || declaration.name; + var name = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_19)) { - var text = ts.getTextOfPropertyName(name_19); + !ts.isBindingPattern(name)) { + var text = ts.getTextOfPropertyName(name); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -34176,7 +35303,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 144 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 145 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -34187,8 +35314,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 === 150 /* Constructor */ || - functionDecl.kind === 151 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 152 /* SetAccessor */))) { + functionDecl.kind === 151 /* Constructor */ || + functionDecl.kind === 152 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 153 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -34210,7 +35337,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 181 /* TaggedTemplateExpression */) { + if (template.parent.kind === 182 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -34254,8 +35381,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -34335,19 +35462,19 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxAttribute(attribute) { - var kind = attribute.kind; - var jsxElement = attribute.parent; - var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 250 /* JsxAttribute */) { - if (!attrsType || isTypeAny(attrsType)) { + // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type + // which is a type of the parameter of the signature we are trying out. + // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName + var attributesType = getContextualType(attribute.parent); + if (ts.isJsxAttribute(attribute)) { + if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfType(attrsType, attribute.name.text); + return getTypeOfPropertyOfType(attributesType, attribute.name.text); } - else if (attribute.kind === 251 /* JsxSpreadAttribute */) { - return attrsType; + else { + return attributesType; } - ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); } // 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. @@ -34382,42 +35509,45 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 223 /* VariableDeclaration */: - case 144 /* Parameter */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 174 /* BindingElement */: + case 225 /* VariableDeclaration */: + case 145 /* Parameter */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 175 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 185 /* ArrowFunction */: - case 216 /* ReturnStatement */: + case 186 /* ArrowFunction */: + case 218 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 179 /* CallExpression */: - case 180 /* NewExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: + case 260 /* PropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 202 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 194 /* TemplateExpression */); + case 204 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 195 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return getContextualType(parent); - case 252 /* JsxExpression */: + case 255 /* JsxExpression */: return getContextualType(parent); - case 250 /* JsxAttribute */: - case 251 /* JsxSpreadAttribute */: + case 252 /* JsxAttribute */: + case 254 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); + case 250 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + return getAttributesTypeFromJsxOpeningLikeElement(parent); } return undefined; } @@ -34448,7 +35578,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 184 /* FunctionExpression */ || node.kind === 185 /* ArrowFunction */; + return node.kind === 185 /* FunctionExpression */ || node.kind === 186 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -34467,7 +35597,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 !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -34477,8 +35607,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -34528,8 +35658,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function hasDefaultValue(node) { - return (node.kind === 174 /* BindingElement */ && !!node.initializer) || - (node.kind === 192 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); + return (node.kind === 175 /* BindingElement */ && !!node.initializer) || + (node.kind === 193 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -34538,7 +35668,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 196 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 197 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -34562,7 +35692,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 196 /* SpreadElement */; + hasSpreadElement = hasSpreadElement || e.kind === 197 /* SpreadElement */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -34577,7 +35707,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 === 173 /* ArrayBindingPattern */ || pattern.kind === 175 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 174 /* ArrayBindingPattern */ || pattern.kind === 176 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -34585,7 +35715,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 198 /* OmittedExpression */) { + if (patternElement.kind !== 199 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -34602,7 +35732,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 142 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 143 /* 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, @@ -34674,7 +35804,7 @@ var ts; var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 172 /* ObjectBindingPattern */ || contextualType.pattern.kind === 176 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 173 /* ObjectBindingPattern */ || contextualType.pattern.kind === 177 /* ObjectLiteralExpression */); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -34683,29 +35813,29 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 257 /* PropertyAssignment */ || - memberDecl.kind === 258 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 260 /* PropertyAssignment */ || + memberDecl.kind === 261 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 257 /* PropertyAssignment */) { + if (memberDecl.kind === 260 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 149 /* MethodDeclaration */) { + else if (memberDecl.kind === 150 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 258 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 261 /* ShorthandPropertyAssignment */); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; - var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | member.flags, member.name); + var prop = createSymbol(4 /* Property */ | 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 === 257 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 258 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 260 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 261 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 536870912 /* Optional */; + prop.flags |= 67108864 /* Optional */; } if (ts.hasDynamicName(memberDecl)) { patternWithComputedProperties = true; @@ -34716,7 +35846,7 @@ var ts; // 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 */; + prop.flags |= impliedProp.flags & 67108864 /* Optional */; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0 /* String */)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -34731,12 +35861,12 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 259 /* SpreadAssignment */) { - if (languageVersion < 5 /* ESNext */) { + else if (memberDecl.kind === 262 /* SpreadAssignment */) { + if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); + spread = getSpreadType(spread, createObjectLiteralType()); propertiesArray = []; propertiesTable = ts.createMap(); hasComputedStringProperty = false; @@ -34748,7 +35878,7 @@ var ts; error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } - spread = getSpreadType(spread, type, /*isFromObjectLiteral*/ false); + spread = getSpreadType(spread, type); offset = i + 1; continue; } @@ -34758,7 +35888,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 === 151 /* GetAccessor */ || memberDecl.kind === 152 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 152 /* GetAccessor */ || memberDecl.kind === 153 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -34770,7 +35900,7 @@ var ts; } } else { - propertiesTable[member.name] = member; + propertiesTable.set(member.name, member); } propertiesArray.push(member); } @@ -34779,18 +35909,18 @@ var ts; if (contextualTypeHasPattern) { for (var _i = 0, _a = getPropertiesOfType(contextualType); _i < _a.length; _i++) { var prop = _a[_i]; - if (!propertiesTable[prop.name]) { - if (!(prop.flags & 536870912 /* Optional */)) { + if (!propertiesTable.get(prop.name)) { + if (!(prop.flags & 67108864 /* 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; + propertiesTable.set(prop.name, prop); propertiesArray.push(prop); } } } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); + spread = getSpreadType(spread, createObjectLiteralType()); } if (spread.flags & 32768 /* Object */) { // only set the symbol and flags if this is a (fresh) object type @@ -34820,7 +35950,7 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (1 /* Any */ | 4096 /* Null */ | 2048 /* Undefined */) || + return !!(type.flags & (1 /* Any */ | 4096 /* Null */ | 2048 /* Undefined */ | 16777216 /* NonPrimitive */) || type.flags & 32768 /* Object */ && !isGenericMappedType(type) || type.flags & 196608 /* UnionOrIntersection */ && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } @@ -34842,13 +35972,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 252 /* JsxExpression */: + case 255 /* JsxExpression */: checkJsxExpression(child); break; - case 246 /* JsxElement */: + case 248 /* JsxElement */: checkJsxElement(child); break; - case 247 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -34867,77 +35997,105 @@ var ts; */ function isJsxIntrinsicIdentifier(tagName) { // TODO (yuisu): comment - if (tagName.kind === 177 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { + if (tagName.kind === 178 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { 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)) { - var attributeType = getTypeOfPropertyOfType(elementAttributesType, ts.getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0 /* String */); - if (attributeType) { - correspondingPropType = attributeType; + /** + * Get attributes type of the JSX opening-like element. The result is from resolving "attributes" property of the opening-like element. + * + * @param openingLikeElement a JSX opening-like element + * @param filter a function to remove attributes that will not participate in checking whether attributes are assignable + * @return an anonymous type (similar to the one returned by checkObjectLiteral) in which its properties are attributes property. + */ + function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, contextualMapper) { + var attributes = openingLikeElement.attributes; + var attributesTable = ts.createMap(); + var spread = emptyObjectType; + var attributesArray = []; + for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { + var attributeDecl = _a[_i]; + var member = attributeDecl.symbol; + if (ts.isJsxAttribute(attributeDecl)) { + var exprType = attributeDecl.initializer ? + checkExpression(attributeDecl.initializer, contextualMapper) : + trueType; // is sugar for + var attributeSymbol = createSymbol(4 /* Property */ | 134217728 /* Transient */ | member.flags, member.name); + attributeSymbol.declarations = member.declarations; + attributeSymbol.parent = member.parent; + if (member.valueDeclaration) { + attributeSymbol.valueDeclaration = member.valueDeclaration; } - 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; - } + attributeSymbol.type = exprType; + attributeSymbol.target = member; + attributesTable.set(attributeSymbol.name, attributeSymbol); + attributesArray.push(attributeSymbol); + } + else { + ts.Debug.assert(attributeDecl.kind === 254 /* JsxSpreadAttribute */); + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); } + var exprType = checkExpression(attributeDecl.expression); + if (!(exprType.flags & (32768 /* Object */ | 1 /* Any */))) { + error(attributeDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + return anyType; + } + if (isTypeAny(exprType)) { + return anyType; + } + spread = getSpreadType(spread, exprType); } } - var exprType; - if (node.initializer) { - exprType = checkExpression(node.initializer); + if (spread !== emptyObjectType) { + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = ts.createMap(); + } + attributesArray = getPropertiesOfType(spread); } - else { - // is sugar for - exprType = booleanType; + attributesTable = ts.createMap(); + if (attributesArray) { + ts.forEach(attributesArray, function (attr) { + if (!filter || filter(attr)) { + attributesTable.set(attr.name, attr); + } + }); } - if (correspondingPropType) { - checkTypeAssignableTo(exprType, correspondingPropType, node); + return createJsxAttributesType(attributes.symbol, attributesTable); + /** + * Create anonymous type from given attributes symbol table. + * @param symbol a symbol of JsxAttributes containing attributes corresponding to attributesTable + * @param attributesTable a symbol table of attributes property + */ + function createJsxAttributesType(symbol, attributesTable) { + var result = createAnonymousType(symbol, attributesTable, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshLiteral */; + result.flags |= 33554432 /* JsxAttributes */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag; + result.objectFlags |= 128 /* ObjectLiteral */; + return result; } - nameTable[node.name.text] = true; - return exprType; } - function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { - if (compilerOptions.jsx === 2 /* React */) { - checkExternalEmitHelpers(node, 2 /* Assign */); - } - var type = checkExpression(node.expression); - var props = getPropertiesOfType(type); - 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]) { - 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; + /** + * Check attributes property of opening-like element. This function is called during chooseOverload to get call signature of a JSX opening-like element. + * (See "checkApplicableSignatureForJsxOpeningLikeElement" for how the function is used) + * @param node a JSXAttributes to be resolved of its type + */ + function checkJsxAttributes(node, contextualMapper) { + return createJsxAttributesTypeFromAttributesProperty(node.parent, /*filter*/ undefined, contextualMapper); } function getJsxType(name) { - if (jsxTypes[name] === undefined) { - return jsxTypes[name] = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType; + var jsxType = jsxTypes.get(name); + if (jsxType === undefined) { + jsxTypes.set(name, jsxType = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType); } - return jsxTypes[name]; + return jsxType; } /** * Looks up an intrinsic tag name and returns a symbol that either points to an intrinsic @@ -35032,28 +36190,131 @@ var ts; } } /** - * Given React element instance type and the class type, resolve the Jsx type - * Pass elemType to handle individual type in the union typed element type. + * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. + * Return only attributes type of successfully resolved call signature. + * This function assumes that the caller handled other possible element type of the JSX element (e.g. stateful component) + * Unlike tryGetAllJsxStatelessFunctionAttributesType, this function is a default behavior of type-checkers. + * @param openingLikeElement a JSX opening-like element to find attributes type + * @param elementType a type of the opening-like element. This elementType can't be an union type + * @param elemInstanceType an element instance type (the result of newing or invoking this tag) + * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global */ - function getResolvedJsxType(node, elemType, elemClassType) { - if (!elemType) { - elemType = checkExpression(node.tagName); + function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536 /* Union */)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + if (jsxElementType) { + // We don't call getResolvedSignature here because we have already resolve the type of JSX Element. + var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, /*candidatesOutArray*/ undefined); + if (callSignature !== unknownSignature) { + var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); + var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + // Intersect in JSX.IntrinsicAttributes if it exists + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + paramType = intersectTypes(intrinsicAttributes, paramType); + } + return paramType; + } + } + } } - if (elemType.flags & 65536 /* Union */) { - var types = elemType.types; - return getUnionType(ts.map(types, function (type) { - return getResolvedJsxType(node, type, elemClassType); + return undefined; + } + /** + * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. + * Return all attributes type of resolved call signature including candidate signatures. + * This function assumes that the caller handled other possible element type of the JSX element. + * This function is a behavior used by language service when looking up completion in JSX element. + * @param openingLikeElement a JSX opening-like element to find attributes type + * @param elementType a type of the opening-like element. This elementType can't be an union type + * @param elemInstanceType an element instance type (the result of newing or invoking this tag) + * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global + */ + function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { + ts.Debug.assert(!(elementType.flags & 65536 /* Union */)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + // Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type + if (jsxElementType) { + // We don't call getResolvedSignature because here we have already resolve the type of JSX Element. + var candidatesOutArray = []; + getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); + var result = void 0; + var allMatchingAttributesType = void 0; + for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { + var candidate = candidatesOutArray_1[_i]; + var callReturnType = getReturnTypeOfSignature(candidate); + var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + var shouldBeCandidate = true; + for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { + var attribute = _b[_a]; + if (ts.isJsxAttribute(attribute) && + isUnhyphenatedJsxName(attribute.name.text) && + !getPropertyOfType(paramType, attribute.name.text)) { + shouldBeCandidate = false; + break; + } + } + if (shouldBeCandidate) { + result = intersectTypes(result, paramType); + } + allMatchingAttributesType = intersectTypes(allMatchingAttributesType, paramType); + } + } + // If we can't find any matching, just return everything. + if (!result) { + result = allMatchingAttributesType; + } + // Intersect in JSX.IntrinsicAttributes if it exists + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + result = intersectTypes(intrinsicAttributes, result); + } + return result; + } + } + return undefined; + } + /** + * Resolve attributes type of the given opening-like element. The attributes type is a type of attributes associated with the given elementType. + * For instance: + * declare function Foo(attr: { p1: string}): JSX.Element; + * ; // This function will try resolve "Foo" and return an attributes type of "Foo" which is "{ p1: string }" + * + * The function is intended to initially be called from getAttributesTypeFromJsxOpeningLikeElement which already handle JSX-intrinsic-element.. + * This function will try to resolve custom JSX attributes type in following order: string literal, stateless function, and stateful component + * + * @param openingLikeElement a non-intrinsic JSXOPeningLikeElement + * @param shouldIncludeAllStatelessAttributesType a boolean indicating whether to include all attributes types from all stateless function signature + * @param elementType an instance type of the given opening-like element. If undefined, the function will check type openinglikeElement's tagname. + * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global (imported from react.d.ts) + * @return attributes type if able to resolve the type of node + * anyType if there is no type ElementAttributesProperty or there is an error + * emptyObjectType if there is no "prop" in the element instance type + **/ + function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { + if (!elementType) { + elementType = checkExpression(openingLikeElement.tagName); + } + if (elementType.flags & 65536 /* Union */) { + var types = elementType.types; + return getUnionType(types.map(function (type) { + return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); }), /*subtypeReduction*/ true); } // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - if (elemType.flags & 2 /* String */) { + if (elementType.flags & 2 /* String */) { return anyType; } - else if (elemType.flags & 32 /* StringLiteral */) { + else if (elementType.flags & 32 /* StringLiteral */) { // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type + // For example: + // var CustomTag: "h1" = "h1"; + // Hello World var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); if (intrinsicElementsType !== unknownType) { - var stringLiteralTypeName = elemType.text; + var stringLiteralTypeName = elementType.text; var intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName); if (intrinsicProp) { return getTypeOfSymbol(intrinsicProp); @@ -35062,34 +36323,24 @@ var ts; if (indexSignatureType) { return indexSignatureType; } - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); + error(openingLikeElement, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); } // If we need to report an error, we already done so here. So just return any to prevent any more error downstream return anyType; } // Get the element instance type (the result of newing or invoking this tag) - var elemInstanceType = getJsxElementInstanceType(node, elemType); - if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { - // Is this is a stateless function component? See if its single signature's return type is - // assignable to the JSX Element Type - if (jsxElementType) { - var callSignatures = elemType && getSignaturesOfType(elemType, 0 /* Call */); - var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { - // Intersect in JSX.IntrinsicAttributes if it exists - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); - if (intrinsicAttributes !== unknownType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } - } + var elemInstanceType = getJsxElementInstanceType(openingLikeElement, elementType); + // If we should include all stateless attributes type, then get all attributes type from all stateless function signature. + // Otherwise get only attributes type from the signature picked by choose-overload logic. + var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? + tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : + defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); + if (statelessAttributesType) { + return statelessAttributesType; } // Issue an error if this return type isn't assignable to JSX.ElementClass - if (elemClassType) { - checkTypeRelatedTo(elemInstanceType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + if (elementClassType) { + checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } if (isTypeAny(elemInstanceType)) { return elemInstanceType; @@ -35115,7 +36366,7 @@ var ts; } else if (attributesType.flags & 65536 /* Union */) { // Props cannot be a union type - error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); + error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); return anyType; } else { @@ -35142,30 +36393,68 @@ var ts; } } /** - * 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. + * Get attributes type of the given intrinsic opening-like Jsx element by resolving the tag name. + * The function is intended to be called from a function which has checked that the opening element is an intrinsic element. + * @param node an intrinsic JSX opening-like element */ - function getJsxElementAttributesType(node) { + function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) { + ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName)); var links = getNodeLinks(node); - if (!links.resolvedJsxType) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { - return links.resolvedJsxType = getTypeOfSymbol(symbol); - } - else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { - return links.resolvedJsxType = getIndexInfoOfSymbol(symbol, 0 /* String */).type; - } - else { - return links.resolvedJsxType = unknownType; - } + if (!links.resolvedJsxElementAttributesType) { + var symbol = getIntrinsicTagSymbol(node); + if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol); + } + else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + return links.resolvedJsxElementAttributesType = getIndexInfoOfSymbol(symbol, 0 /* String */).type; } else { - var elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxType = getResolvedJsxType(node, undefined, elemClassType); + return links.resolvedJsxElementAttributesType = unknownType; } } - return links.resolvedJsxType; + return links.resolvedJsxElementAttributesType; + } + /** + * Get attributes type of the given custom opening-like JSX element. + * This function is intended to be called from a caller that handles intrinsic JSX element already. + * @param node a custom JSX opening-like element + * @param shouldIncludeAllStatelessAttributesType a boolean value used by language service to get all possible attributes type from an overload stateless function component + */ + function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { + var links = getNodeLinks(node); + if (!links.resolvedJsxElementAttributesType) { + var elemClassType = getJsxGlobalElementClassType(); + return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); + } + return links.resolvedJsxElementAttributesType; + } + /** + * Get all possible attributes type, especially from an overload stateless function component, of the given JSX opening-like element. + * This function is called by language service (see: completions-tryGetGlobalSymbols). + * @param node a JSX opening-like element to get attributes type for + */ + function getAllAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + // Because in language service, the given JSX opening-like element may be incomplete and therefore, + // we can't resolve to exact signature if the element is a stateless function component so the best thing to do is return all attributes type from all overloads. + return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ true); + } + } + /** + * Get the attributes type, which indicates the attributes that are valid on the given JSXOpeningLikeElement. + * @param node a JSXOpeningLikeElement node + * @return an attributes type of the given node + */ + function getAttributesTypeFromJsxOpeningLikeElement(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ false); + } } /** * Given a JSX attribute, returns the symbol for the corresponds property @@ -35173,7 +36462,7 @@ var ts; * that have no matching element attributes type property. */ function getJsxAttributePropertySymbol(attrib) { - var attributesType = getJsxElementAttributesType(attrib.parent); + var attributesType = getAttributesTypeFromJsxOpeningLikeElement(attrib.parent.parent); var prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } @@ -35183,7 +36472,9 @@ var ts; } return jsxElementClassType; } - /// Returns all the properties of the Jsx.IntrinsicElements interface + /** + * Returns all the properties of the Jsx.IntrinsicElements interface + */ function getJsxIntrinsicTagNames() { var intrinsics = getJsxType(JsxNames.IntrinsicElements); return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; @@ -35216,39 +36507,46 @@ var ts; markAliasSymbolAsReferenced(reactSym); } } - var targetAttributesType = getJsxElementAttributesType(node); - var nameTable = ts.createMap(); - // 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 === 250 /* JsxAttribute */) { - checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); - } - else { - ts.Debug.assert(node.attributes[i].kind === 251 /* JsxSpreadAttribute */); - var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); - if (isTypeAny(spreadType)) { - sawSpreadedAny = true; - } - } + checkJsxAttributesAssignableToTagNameAttributes(node); + } + /** + * Check whether the given attributes of JSX opening-like element is assignable to the tagName attributes. + * Get the attributes type of the opening-like element through resolving the tagName, "target attributes" + * Check assignablity between given attributes property, "source attributes", and the "target attributes" + * @param openingLikeElement an opening-like JSX element to check its JSXAttributes + */ + function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement) { + // The function involves following steps: + // 1. Figure out expected attributes type by resolving tagName of the JSX opening-like element, targetAttributesType. + // During these steps, we will try to resolve the tagName as intrinsic name, stateless function, stateful component (in the order) + // 2. Solved JSX attributes type given by users, sourceAttributesType, which is by resolving "attributes" property of the JSX opening-like element. + // 3. Check if the two are assignable to each other + // targetAttributesType is a type of an attributes from resolving tagName of an opening-like JSX element. + var targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? + getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : + getCustomJsxElementAttributesType(openingLikeElement, /*shouldIncludeAllStatelessAttributesType*/ false); + // sourceAttributesType is a type of an attributes properties. + // i.e
+ // attr1 and attr2 are treated as JSXAttributes attached in the JsxOpeningLikeElement as "attributes". + var sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement, function (attribute) { + return isUnhyphenatedJsxName(attribute.name) || !!(getPropertyOfType(targetAttributesType, attribute.name)); + }); + // If the targetAttributesType is an emptyObjectType, indicating that there is no property named 'props' on this instance type. + // but there exists a sourceAttributesType, we need to explicitly give an error as normal assignability check allow excess properties and will pass. + if (targetAttributesType === emptyObjectType && (isTypeAny(sourceAttributesType) || sourceAttributesType.properties.length > 0)) { + error(openingLikeElement, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); } - // 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]) { - error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); - } - } + else { + checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.attributes.properties.length > 0 ? openingLikeElement.attributes : openingLikeElement); } } - function checkJsxExpression(node) { + function checkJsxExpression(node, contextualMapper) { if (node.expression) { - return checkExpression(node.expression); + var type = checkExpression(node.expression, contextualMapper); + if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { + error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); + } + return type; } else { return unknownType; @@ -35257,10 +36555,25 @@ 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 : 147 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 148 /* PropertyDeclaration */; } function getDeclarationModifierFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 4 /* Public */ | 32 /* Static */ : 0; + if (s.valueDeclaration) { + var flags = ts.getCombinedModifierFlags(s.valueDeclaration); + return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; + } + if (getCheckFlags(s) & 2 /* SyntheticProperty */) { + var checkFlags = s.checkFlags; + var accessModifier = checkFlags & 128 /* ContainsPrivate */ ? 8 /* Private */ : + checkFlags & 32 /* ContainsPublic */ ? 4 /* Public */ : + 16 /* Protected */; + var staticModifier = checkFlags & 256 /* ContainsStatic */ ? 32 /* Static */ : 0; + return accessModifier | staticModifier; + } + if (s.flags & 16777216 /* Prototype */) { + return 4 /* Public */ | 32 /* Static */; + } + return 0; } function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; @@ -35273,12 +36586,16 @@ var ts; * @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) { + function checkPropertyAccessibility(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); - var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 177 /* PropertyAccessExpression */ || node.kind === 223 /* VariableDeclaration */ ? + var errorNode = node.kind === 178 /* PropertyAccessExpression */ || node.kind === 225 /* VariableDeclaration */ ? node.name : node.right; + if (getCheckFlags(prop) & 128 /* ContainsPrivate */) { + // Synthetic property with private constituent property + error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); + return false; + } if (left.kind === 96 /* SuperKeyword */) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or @@ -35287,18 +36604,21 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES2015 */ && getDeclarationKindFromSymbol(prop) !== 149 /* 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 (languageVersion < 2 /* ES2015 */) { + var propKind = getDeclarationKindFromSymbol(prop); + if (propKind !== 150 /* MethodDeclaration */ && propKind !== 149 /* MethodSignature */) { + // `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 & 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 // additional error elsewhere. - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } } @@ -35311,7 +36631,7 @@ var ts; if (flags & 8 /* Private */) { var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } return true; @@ -35321,14 +36641,15 @@ var ts; if (left.kind === 96 /* SuperKeyword */) { return true; } - // Get the enclosing class that has the declaring class as its base type + // Find the first enclosing class that has the declaring classes of the protected constituents + // of the property as base classes var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); - return hasBaseType(enclosingClass, declaringClass) ? enclosingClass : undefined; + return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; }); // A protected property is accessible if the property is within the declaring class or classes derived from it if (!enclosingClass) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); return false; } // No further restrictions for static properties @@ -35340,7 +36661,6 @@ var ts; // 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 (!(getObjectFlags(getTargetType(type)) & 3 /* ClassOrInterface */ && hasBaseType(type, enclosingClass))) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; @@ -35348,16 +36668,17 @@ var ts; return true; } function checkNonNullExpression(node) { - var type = checkExpression(node); - if (strictNullChecks) { - var kind = getFalsyFlags(type) & 6144 /* Nullable */; - if (kind) { - error(node, kind & 2048 /* Undefined */ ? kind & 4096 /* Null */ ? - ts.Diagnostics.Object_is_possibly_null_or_undefined : - ts.Diagnostics.Object_is_possibly_undefined : - ts.Diagnostics.Object_is_possibly_null); - } - return getNonNullableType(type); + return checkNonNullType(checkExpression(node), node); + } + function checkNonNullType(type, errorNode) { + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 6144 /* Nullable */; + if (kind) { + error(errorNode, kind & 2048 /* Undefined */ ? kind & 4096 /* Null */ ? + ts.Diagnostics.Object_is_possibly_null_or_undefined : + ts.Diagnostics.Object_is_possibly_undefined : + ts.Diagnostics.Object_is_possibly_null); + var t = getNonNullableType(type); + return t.flags & (6144 /* Nullable */ | 8192 /* Never */) ? unknownType : t; } return type; } @@ -35386,7 +36707,7 @@ var ts; noUnusedIdentifiers && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8 /* Private */)) { - if (prop.flags & 16777216 /* Instantiated */) { + if (getCheckFlags(prop) & 1 /* Instantiated */) { getSymbolLinks(prop).target.isReferenced = true; } else { @@ -35394,6 +36715,15 @@ var ts; } } } + function isInPropertyInitializer(node) { + while (node) { + if (node.parent && node.parent.kind === 148 /* PropertyDeclaration */ && node.parent.initializer === node) { + return true; + } + node = node.parent; + } + return false; + } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { var type = checkNonNullExpression(left); if (isTypeAny(type) || type === silentNeverType) { @@ -35406,16 +36736,23 @@ var ts; } var prop = getPropertyOfType(apparentType, right.text); if (!prop) { + var stringIndexType = getIndexTypeOfType(apparentType, 0 /* String */); + if (stringIndexType) { + return stringIndexType; + } if (right.text && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, type.flags & 16384 /* TypeParameter */ && type.isThisType ? apparentType : type); } return unknownType; } + if (prop.valueDeclaration && + isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + } markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; - if (prop.parent && prop.parent.flags & 32 /* Class */) { - checkClassPropertyAccess(node, left, apparentType, prop); - } + checkPropertyAccessibility(node, left, apparentType, prop); var propType = getTypeOfSymbol(prop); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { @@ -35427,7 +36764,7 @@ var ts; // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. - if (node.kind !== 177 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || + if (node.kind !== 178 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 65536 /* Union */)) { return propType; @@ -35436,14 +36773,14 @@ var ts; return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 177 /* PropertyAccessExpression */ + var left = node.kind === 178 /* 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); + if (prop) { + return checkPropertyAccessibility(node, left, type, prop); } } return true; @@ -35453,7 +36790,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 224 /* VariableDeclarationList */) { + if (initializer.kind === 226 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -35482,7 +36819,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 212 /* ForInStatement */ && + if (node.kind === 214 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -35500,7 +36837,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 180 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 181 /* 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); @@ -35520,7 +36857,7 @@ var ts; error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } - return getIndexedAccessType(objectType, indexType, node); + return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === unknownType) { @@ -35558,10 +36895,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 181 /* TaggedTemplateExpression */) { + if (node.kind === 182 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 145 /* Decorator */) { + else if (node.kind !== 146 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -35591,13 +36928,13 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_8 = signature.declaration && signature.declaration.parent; + var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_8 === lastParent) { + if (lastParent && parent === lastParent) { index++; } else { - lastParent = parent_8; + lastParent = parent; index = cutoffIndex; } } @@ -35605,7 +36942,7 @@ var ts; // current declaration belongs to a different symbol // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex index = cutoffIndex = result.length; - lastParent = parent_8; + lastParent = parent; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -35627,7 +36964,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 196 /* SpreadElement */) { + if (arg && arg.kind === 197 /* SpreadElement */) { return i; } } @@ -35640,13 +36977,17 @@ 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 === 181 /* TaggedTemplateExpression */) { + if (ts.isJsxOpeningLikeElement(node)) { + // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". + return true; + } + if (node.kind === 182 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 194 /* TemplateExpression */) { + if (tagExpression.template.kind === 195 /* 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; @@ -35663,7 +37004,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 145 /* Decorator */) { + else if (node.kind === 146 /* Decorator */) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -35672,19 +37013,21 @@ 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 === 180 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 181 /* NewExpression */); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; - // If we are missing the close paren, the call is incomplete. + // If we are missing the close parenthesis, 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 numTypeParameters = ts.length(signature.typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters); var hasRightNumberOfTypeArgs = !typeArguments || - (signature.typeParameters && typeArguments.length === signature.typeParameters.length); + (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters); if (!hasRightNumberOfTypeArgs) { return false; } @@ -35756,7 +37099,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 !== 198 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 199 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -35791,7 +37134,7 @@ var ts; var typeParameters = signature.typeParameters; var typeArgumentsAreAssignable = true; var mapper; - for (var i = 0; i < typeParameters.length; i++) { + for (var i = 0; i < typeArgumentNodes.length; i++) { if (typeArgumentsAreAssignable /* so far */) { var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { @@ -35811,9 +37154,44 @@ var ts; } return typeArgumentsAreAssignable; } + /** + * Check if the given signature can possibly be a signature called by the JSX opening-like element. + * @param node a JSX opening-like element we are trying to figure its call signature + * @param signature a candidate signature we are trying whether it is a call signature + * @param relation a relationship to check parameter and argument type + * @param excludeArgument + */ + function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation) { + // JSX opening-like element has correct arity for stateless-function component if the one of the following condition is true: + // 1. callIsIncomplete + // 2. attributes property has same number of properties as the parameter object type. + // We can figure that out by resolving attributes property and check number of properties in the resolved type + // If the call has correct arity, we will then check if the argument type and parameter type is assignable + var callIsIncomplete = node.attributes.end === node.end; // If we are missing the close "/>", the call is incomplete + if (callIsIncomplete) { + return true; + } + var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + // Stateless function components can have maximum of three arguments: "props", "context", and "updater". + // However "context" and "updater" are implicit and can't be specify by users. Only the first parameter, props, + // can be specified by users through attributes property. + var paramType = getTypeAtPosition(signature, 0); + var attributesType = checkExpressionWithContextualType(node.attributes, paramType, /*contextualMapper*/ undefined); + var argProperties = getPropertiesOfType(attributesType); + for (var _i = 0, argProperties_1 = argProperties; _i < argProperties_1.length; _i++) { + var arg = argProperties_1[_i]; + if (!getPropertyOfType(paramType, arg.name) && isUnhyphenatedJsxName(arg.name)) { + return false; + } + } + return checkTypeRelatedTo(attributesType, paramType, relation, /*errorNode*/ undefined, headMessage); + } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { + if (ts.isJsxOpeningLikeElement(node)) { + return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); + } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 180 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 181 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -35830,7 +37208,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 !== 198 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 199 /* 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); @@ -35852,12 +37230,12 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 179 /* CallExpression */) { + if (node.kind === 180 /* CallExpression */) { var callee = node.expression; - if (callee.kind === 177 /* PropertyAccessExpression */) { + if (callee.kind === 178 /* PropertyAccessExpression */) { return callee.expression; } - else if (callee.kind === 178 /* ElementAccessExpression */) { + else if (callee.kind === 179 /* ElementAccessExpression */) { return callee.expression; } } @@ -35873,21 +37251,24 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 181 /* TaggedTemplateExpression */) { + if (node.kind === 182 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 194 /* TemplateExpression */) { + if (template.kind === 195 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 145 /* Decorator */) { + else if (node.kind === 146 /* 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 if (ts.isJsxOpeningLikeElement(node)) { + args = node.attributes.properties.length > 0 ? [node.attributes] : emptyArray; + } else { args = node.arguments || emptyArray; } @@ -35907,19 +37288,19 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 145 /* Decorator */) { + if (node.kind === 146 /* Decorator */) { switch (node.parent.kind) { - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* 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. @@ -35929,7 +37310,7 @@ var ts; // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 144 /* Parameter */: + case 145 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -35953,25 +37334,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 228 /* 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 === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 150 /* Constructor */) { + if (node.kind === 151 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 147 /* PropertyDeclaration */ || - node.kind === 149 /* MethodDeclaration */ || - node.kind === 151 /* GetAccessor */ || - node.kind === 152 /* SetAccessor */) { + if (node.kind === 148 /* PropertyDeclaration */ || + node.kind === 150 /* MethodDeclaration */ || + node.kind === 152 /* GetAccessor */ || + node.kind === 153 /* 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 @@ -35998,21 +37379,23 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 228 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { node = node.parent; - if (node.kind === 150 /* Constructor */) { + if (node.kind === 151 /* 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. } - if (node.kind === 147 /* PropertyDeclaration */ || - node.kind === 149 /* MethodDeclaration */ || - node.kind === 151 /* GetAccessor */ || - node.kind === 152 /* SetAccessor */) { + if (node.kind === 148 /* PropertyDeclaration */ || + node.kind === 150 /* MethodDeclaration */ || + node.kind === 152 /* GetAccessor */ || + node.kind === 153 /* 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 @@ -36023,7 +37406,7 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getLiteralTypeForText(32 /* StringLiteral */, element.name.text); - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512 /* ESSymbol */)) { return nameType; @@ -36049,21 +37432,21 @@ var ts; function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a parameter decorator - if (node.kind === 226 /* ClassDeclaration */) { + if (node.kind === 228 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 147 /* PropertyDeclaration */) { + if (node.kind === 148 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 149 /* MethodDeclaration */ || - node.kind === 151 /* GetAccessor */ || - node.kind === 152 /* SetAccessor */) { + if (node.kind === 150 /* MethodDeclaration */ || + node.kind === 152 /* GetAccessor */ || + node.kind === 153 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -36095,10 +37478,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 === 145 /* Decorator */) { + if (node.kind === 146 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 181 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 182 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -36110,8 +37493,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 === 145 /* Decorator */ || - (argIndex === 0 && node.kind === 181 /* TaggedTemplateExpression */)) { + if (node.kind === 146 /* Decorator */ || + (argIndex === 0 && node.kind === 182 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -36120,11 +37503,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 145 /* Decorator */) { + if (node.kind === 146 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 181 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 182 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -36133,10 +37516,11 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 181 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 145 /* Decorator */; + var isTaggedTemplate = node.kind === 182 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 146 /* Decorator */; + var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; - if (!isTaggedTemplate && !isDecorator) { + if (!isTaggedTemplate && !isDecorator && !isJsxOpeningOrSelfClosingElement) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. if (node.expression.kind !== 96 /* SuperKeyword */) { @@ -36205,7 +37589,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 179 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 180 /* CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -36234,6 +37618,10 @@ var ts; // If candidate is undefined, it means that no candidates had a suitable arity. In that case, // skip the checkApplicableSignature check. if (candidateForArgumentError) { + if (isJsxOpeningOrSelfClosingElement) { + // We do not report any error here because any error will be handled in "resolveCustomJsxElementAttributesType". + return 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 @@ -36255,7 +37643,7 @@ var ts; if (headMessage) { diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); } - reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); + reportNoCommonSupertypeError(inferenceCandidates, node.tagName || node.expression || node.tag, diagnosticChainHead); } } else { @@ -36303,13 +37691,13 @@ var ts; if (candidate.typeParameters) { var typeArgumentTypes = void 0; if (typeArguments) { - typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNode); + typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); } else { inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); - typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; typeArgumentTypes = inferenceContext.inferredTypes; + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; } if (!typeArgumentsAreValid) { break; @@ -36554,16 +37942,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 144 /* Parameter */: + case 145 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -36591,21 +37979,73 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray, headMessage); } + /** + * This function is similar to getResolvedSignature but is exclusively for trying to resolve JSX stateless-function component. + * The main reason we have to use this function instead of getResolvedSignature because, the caller of this function will already check the type of openingLikeElement's tagName + * and pass the type as elementType. The elementType can not be a union (as such case should be handled by the caller of this function) + * Note: at this point, we are still not sure whether the opening-like element is a stateless function component or not. + * @param openingLikeElement an opening-like JSX element to try to resolve as JSX stateless function + * @param elementType an element type of the opneing-like element by checking opening-like element's tagname. + * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; + * the function will fill it up with appropriate candidate signatures + */ + function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray) { + ts.Debug.assert(!(elementType.flags & 65536 /* Union */)); + var callSignature = resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray); + return callSignature; + } + /** + * Try treating a given opening-like element as stateless function component and resolve a tagName to a function signature. + * @param openingLikeElement an JSX opening-like element we want to try resolve its stateless function if possible + * @param elementType a type of the opening-like JSX element, a result of resolving tagName in opening-like element. + * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; + * the function will fill it up with appropriate candidate signatures + * @return a resolved signature if we can find function matching function signature through resolve call or a first signature in the list of functions. + * otherwise return undefined if tag-name of the opening-like element doesn't have call signatures + */ + function resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray) { + // If this function is called from language service, elementType can be a union type. This is not possible if the function is called from compiler (see: resolveCustomJsxElementAttributesType) + if (elementType.flags & 65536 /* Union */) { + var types = elementType.types; + var result = void 0; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; + result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); + } + return result; + } + var callSignatures = elementType && getSignaturesOfType(elementType, 0 /* Call */); + if (callSignatures && callSignatures.length > 0) { + var callSignature = void 0; + callSignature = resolveCall(openingLikeElement, callSignatures, candidatesOutArray); + return callSignature; + } + return undefined; + } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 179 /* CallExpression */: + case 180 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 145 /* Decorator */: + case 146 /* Decorator */: return resolveDecorator(node, candidatesOutArray); + case 250 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + // This code-path is called by language service + return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); } - // candidatesOutArray is passed by signature help in the language service, and collectCandidates - // must fill it up with the appropriate candidate signatures + /** + * Resolve a signature of a given call-like expression. + * @param node a call-like expression to try resolve a signature for + * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; + * the function will fill it up with appropriate candidate signatures + * @return a signature of the call-like expression or undefined if one can't be found + */ function getResolvedSignature(node, candidatesOutArray) { var links = getNodeLinks(node); // If getResolvedSignature has already been called, we will have cached the resolvedSignature. @@ -36648,12 +38088,12 @@ var ts; if (node.expression.kind === 96 /* SuperKeyword */) { return voidType; } - if (node.kind === 180 /* NewExpression */) { + if (node.kind === 181 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 150 /* Constructor */ && - declaration.kind !== 154 /* ConstructSignature */ && - declaration.kind !== 159 /* ConstructorType */ && + declaration.kind !== 151 /* Constructor */ && + declaration.kind !== 155 /* ConstructSignature */ && + declaration.kind !== 160 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations @@ -36693,9 +38133,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 225 /* FunctionDeclaration */ + ? 227 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 223 /* VariableDeclaration */ + ? 225 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -36722,6 +38162,23 @@ var ts; function checkNonNullAssertion(node) { return getNonNullableType(checkExpression(node.expression)); } + function checkMetaProperty(node) { + checkGrammarMetaProperty(node); + ts.Debug.assert(node.keywordToken === 93 /* NewKeyword */ && node.name.text === "target", "Unrecognized meta-property."); + var container = ts.getNewTargetContainer(node); + if (!container) { + error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); + return unknownType; + } + else if (container.kind === 151 /* Constructor */) { + var symbol = getSymbolOfNode(container.parent); + return getTypeOfSymbol(symbol); + } + else { + var symbol = getSymbolOfNode(container); + return getTypeOfSymbol(symbol); + } + } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks) { @@ -36751,7 +38208,7 @@ var ts; var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { if (!parameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + signature.thisParameter = createSymbolWithType(context.thisParameter, undefined); } assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } @@ -36792,8 +38249,8 @@ var ts; links.type = instantiateType(contextualType, mapper); // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 172 /* ObjectBindingPattern */ || - parameter.valueDeclaration.name.kind === 173 /* ArrayBindingPattern */)) { + (parameter.valueDeclaration.name.kind === 173 /* ObjectBindingPattern */ || + parameter.valueDeclaration.name.kind === 174 /* ArrayBindingPattern */)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -36854,6 +38311,9 @@ var ts; error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } + else if (!getGlobalPromiseConstructorSymbol()) { + error(func, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } return promiseType; } function getReturnTypeFromBody(func, contextualMapper) { @@ -36863,7 +38323,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 204 /* Block */) { + if (func.body.kind !== 206 /* 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 @@ -36953,7 +38413,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 218 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 220 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -36986,7 +38446,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 184 /* FunctionExpression */ || func.kind === 185 /* ArrowFunction */)) { + func.kind === 185 /* FunctionExpression */ || func.kind === 186 /* ArrowFunction */)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -37015,7 +38475,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (ts.nodeIsMissing(func.body) || func.body.kind !== 204 /* Block */ || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 206 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -37048,10 +38508,10 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 184 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 185 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -37092,14 +38552,15 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 149 /* MethodDeclaration */) { + if (produceDiagnostics && node.kind !== 150 /* MethodDeclaration */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -37115,7 +38576,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 204 /* Block */) { + if (node.body.kind === 206 /* Block */) { checkSourceElement(node.body); } else { @@ -37152,21 +38613,21 @@ var ts; // Get accessors without matching set accessors // Enum members // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) - return symbol.isReadonly || - symbol.flags & 4 /* Property */ && (getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */) !== 0 || - symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0 || + return !!(getCheckFlags(symbol) & 4 /* Readonly */ || + symbol.flags & 4 /* Property */ && getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || + symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */ || symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || - (symbol.flags & 8 /* EnumMember */) !== 0; + symbol.flags & 8 /* EnumMember */); } function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 177 /* PropertyAccessExpression */ || expr.kind === 178 /* ElementAccessExpression */) && + (expr.kind === 178 /* PropertyAccessExpression */ || expr.kind === 179 /* ElementAccessExpression */) && expr.expression.kind === 98 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 150 /* Constructor */)) + if (!(func && func.kind === 151 /* Constructor */)) return true; // If func.parent is a class and symbol is a (readonly) property of that class, or // if func is a constructor and symbol is a (readonly) parameter property declared in it, @@ -37178,13 +38639,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 177 /* PropertyAccessExpression */ || expr.kind === 178 /* ElementAccessExpression */) { + if (expr.kind === 178 /* PropertyAccessExpression */ || expr.kind === 179 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); if (node.kind === 70 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 237 /* NamespaceImport */; + return declaration && declaration.kind === 239 /* NamespaceImport */; } } } @@ -37193,7 +38654,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipParentheses(expr); - if (node.kind !== 70 /* Identifier */ && node.kind !== 177 /* PropertyAccessExpression */ && node.kind !== 178 /* ElementAccessExpression */) { + if (node.kind !== 70 /* Identifier */ && node.kind !== 178 /* PropertyAccessExpression */ && node.kind !== 179 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -37201,11 +38662,21 @@ var ts; } function checkDeleteExpression(node) { checkExpression(node.expression); + var expr = ts.skipParentheses(node.expression); + if (expr.kind !== 178 /* PropertyAccessExpression */ && expr.kind !== 179 /* ElementAccessExpression */) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); + return booleanType; + } + var links = getNodeLinks(expr); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol && isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } return booleanType; } function checkTypeOfExpression(node) { checkExpression(node.expression); - return stringType; + return typeofType; } function checkVoidExpression(node) { checkExpression(node.expression); @@ -37236,6 +38707,7 @@ var ts; case 36 /* PlusToken */: case 37 /* MinusToken */: case 51 /* TildeToken */: + checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 512 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } @@ -37247,7 +38719,7 @@ var ts; booleanType; case 42 /* PlusPlusToken */: case 43 /* MinusMinusToken */: - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); @@ -37261,7 +38733,7 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); @@ -37276,8 +38748,8 @@ var ts; } if (type.flags & 196608 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -37294,8 +38766,8 @@ var ts; } if (type.flags & 65536 /* Union */) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var t = types_19[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -37304,8 +38776,8 @@ var ts; } if (type.flags & 131072 /* Intersection */) { var types = type.types; - for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { - var t = types_17[_a]; + for (var _a = 0, types_20 = types; _a < types_20.length; _a++) { + var t = types_20[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -37325,14 +38797,17 @@ var ts; } // 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. + // and the right operand to be of type Any, a subtype of the 'Function' interface type, or have a call or construct signature. // 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 (isTypeOfKind(leftType, 8190 /* 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))) { + if (!(isTypeAny(rightType) || + getSignaturesOfType(rightType, 0 /* Call */).length || + getSignaturesOfType(rightType, 1 /* Construct */).length || + 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; @@ -37341,6 +38816,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); // 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. @@ -37363,22 +38840,22 @@ var ts; } /** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 257 /* PropertyAssignment */ || property.kind === 258 /* ShorthandPropertyAssignment */) { - var name_20 = property.name; - if (name_20.kind === 142 /* ComputedPropertyName */) { - checkComputedPropertyName(name_20); + if (property.kind === 260 /* PropertyAssignment */ || property.kind === 261 /* ShorthandPropertyAssignment */) { + var name = property.name; + if (name.kind === 143 /* ComputedPropertyName */) { + checkComputedPropertyName(name); } - if (isComputedNonLiteralName(name_20)) { + if (isComputedNonLiteralName(name)) { return undefined; } - var text = ts.getTextOfPropertyName(name_20); + var text = ts.getTextOfPropertyName(name); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 258 /* ShorthandPropertyAssignment */) { + if (property.kind === 261 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -37387,10 +38864,10 @@ var ts; } } else { - error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); + error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 259 /* SpreadAssignment */) { + else if (property.kind === 262 /* SpreadAssignment */) { if (languageVersion < 5 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -37421,8 +38898,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 198 /* OmittedExpression */) { - if (element.kind !== 196 /* SpreadElement */) { + if (element.kind !== 199 /* OmittedExpression */) { + if (element.kind !== 197 /* SpreadElement */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -37450,7 +38927,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 192 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { + if (restExpression.kind === 193 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -37463,7 +38940,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 258 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 261 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -37479,21 +38956,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 192 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { + if (target.kind === 193 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 176 /* ObjectLiteralExpression */) { + if (target.kind === 177 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 175 /* ArrayLiteralExpression */) { + if (target.kind === 176 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 259 /* SpreadAssignment */ ? + var error = target.parent.kind === 262 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -37515,35 +38992,35 @@ var ts; case 70 /* Identifier */: case 9 /* StringLiteral */: case 11 /* RegularExpressionLiteral */: - case 181 /* TaggedTemplateExpression */: - case 194 /* TemplateExpression */: + case 182 /* TaggedTemplateExpression */: + case 195 /* TemplateExpression */: case 12 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: case 94 /* NullKeyword */: - case 137 /* UndefinedKeyword */: - case 184 /* FunctionExpression */: - case 197 /* ClassExpression */: - case 185 /* ArrowFunction */: - case 175 /* ArrayLiteralExpression */: - case 176 /* ObjectLiteralExpression */: - case 187 /* TypeOfExpression */: - case 201 /* NonNullExpression */: - case 247 /* JsxSelfClosingElement */: - case 246 /* JsxElement */: + case 138 /* UndefinedKeyword */: + case 185 /* FunctionExpression */: + case 198 /* ClassExpression */: + case 186 /* ArrowFunction */: + case 176 /* ArrayLiteralExpression */: + case 177 /* ObjectLiteralExpression */: + case 188 /* TypeOfExpression */: + case 202 /* NonNullExpression */: + case 249 /* JsxSelfClosingElement */: + case 248 /* JsxElement */: return true; - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -37555,9 +39032,9 @@ var ts; } return false; // Some forms listed here for clarity - case 188 /* VoidExpression */: // Explicit opt-out - case 182 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 200 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 189 /* VoidExpression */: // Explicit opt-out + case 183 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 201 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -37577,7 +39054,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 57 /* EqualsToken */ && (left.kind === 176 /* ObjectLiteralExpression */ || left.kind === 175 /* ArrayLiteralExpression */)) { + if (operator === 57 /* EqualsToken */ && (left.kind === 177 /* ObjectLiteralExpression */ || left.kind === 176 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -37608,18 +39085,8 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - // 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 & 6144 /* Nullable */) - leftType = rightType; - if (rightType.flags & 6144 /* Nullable */) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion @@ -37642,16 +39109,10 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - // 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 & 6144 /* Nullable */) - leftType = rightType; - if (rightType.flags & 6144 /* Nullable */) - rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + if (!isTypeOfKind(leftType, 1 /* Any */ | 262178 /* StringLike */) && !isTypeOfKind(rightType, 1 /* Any */ | 262178 /* StringLike */)) { + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); + } var resultType = void 0; if (isTypeOfKind(leftType, 340 /* NumberLike */) && isTypeOfKind(rightType, 340 /* NumberLike */)) { // Operands of an enum type are treated as having the primitive type Number. @@ -37686,8 +39147,8 @@ var ts; case 29 /* LessThanEqualsToken */: case 30 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { - leftType = getBaseTypeOfLiteralType(leftType); - rightType = getBaseTypeOfLiteralType(rightType); + leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); + rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } @@ -37879,7 +39340,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 182 /* TypeAssertionExpression */ || node.kind === 200 /* AsExpression */; + return node.kind === 183 /* TypeAssertionExpression */ || node.kind === 201 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -37890,14 +39351,14 @@ var ts; function isLiteralContextualType(contextualType) { if (contextualType) { if (contextualType.flags & 540672 /* TypeVariable */) { - var apparentType = getApparentTypeOfTypeVariable(contextualType); + var constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; // If the type parameter is constrained to the base primitive type we're checking for, // consider this a literal context. For example, given a type parameter 'T extends string', // this causes us to infer string literal types for T. - if (apparentType.flags & (2 /* String */ | 4 /* Number */ | 8 /* Boolean */ | 16 /* Enum */)) { + if (constraint.flags & (2 /* String */ | 4 /* Number */ | 8 /* Boolean */ | 16 /* Enum */)) { return true; } - contextualType = apparentType; + contextualType = constraint; } return maybeTypeOfKind(contextualType, (480 /* Literal */ | 262144 /* Index */)); } @@ -37911,7 +39372,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 === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); @@ -37922,7 +39383,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 === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -37948,7 +39409,7 @@ var ts; function getTypeOfExpression(node) { // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (node.kind === 179 /* CallExpression */ && node.expression.kind !== 96 /* SuperKeyword */) { + if (node.kind === 180 /* CallExpression */ && node.expression.kind !== 96 /* SuperKeyword */) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -37969,7 +39430,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 141 /* QualifiedName */) { + if (node.kind === 142 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -37981,9 +39442,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 177 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 178 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 70 /* Identifier */ || node.kind === 141 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 179 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 70 /* Identifier */ || node.kind === 142 /* 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); } @@ -38005,66 +39466,70 @@ var ts; case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: return checkLiteralExpression(node); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* NoSubstitutionTemplateLiteral */: return stringType; case 11 /* RegularExpressionLiteral */: return globalRegExpType; - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 179 /* CallExpression */: - case 180 /* NewExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: return checkCallExpression(node); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return checkClassExpression(node); - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 187 /* TypeOfExpression */: + case 188 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: return checkAssertion(node); - case 201 /* NonNullExpression */: + case 202 /* NonNullExpression */: return checkNonNullAssertion(node); - case 186 /* DeleteExpression */: + case 203 /* MetaProperty */: + return checkMetaProperty(node); + case 187 /* DeleteExpression */: return checkDeleteExpression(node); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return checkVoidExpression(node); - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: return checkAwaitExpression(node); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return checkSpreadExpression(node, contextualMapper); - case 198 /* OmittedExpression */: + case 199 /* OmittedExpression */: return undefinedWideningType; - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return checkYieldExpression(node); - case 252 /* JsxExpression */: - return checkJsxExpression(node); - case 246 /* JsxElement */: + case 255 /* JsxExpression */: + return checkJsxExpression(node, contextualMapper); + case 248 /* JsxElement */: return checkJsxElement(node); - case 247 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 248 /* JsxOpeningElement */: + case 253 /* JsxAttributes */: + return checkJsxAttributes(node, contextualMapper); + case 250 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -38076,7 +39541,16 @@ var ts; grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); } checkSourceElement(node.constraint); - getConstraintOfTypeParameter(getDeclaredTypeOfTypeParameter(getSymbolOfNode(node))); + checkSourceElement(node.default); + var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); + if (!hasNonCircularBaseConstraint(typeParameter)) { + error(node.constraint, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); + } + var constraintType = getConstraintOfTypeParameter(typeParameter); + var defaultType = getDefaultFromTypeParameter(typeParameter); + if (constraintType && defaultType) { + checkTypeAssignableTo(defaultType, getTypeWithThisArgument(constraintType, defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } if (produceDiagnostics) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } @@ -38092,7 +39566,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92 /* ParameterPropertyModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 150 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 151 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -38103,7 +39577,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 150 /* Constructor */ || func.kind === 154 /* ConstructSignature */ || func.kind === 159 /* ConstructorType */) { + if (func.kind === 151 /* Constructor */ || func.kind === 155 /* ConstructSignature */ || func.kind === 160 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -38117,9 +39591,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 149 /* MethodDeclaration */ || - node.kind === 225 /* FunctionDeclaration */ || - node.kind === 184 /* FunctionExpression */; + return node.kind === 150 /* MethodDeclaration */ || + node.kind === 227 /* FunctionDeclaration */ || + node.kind === 185 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -38162,9 +39636,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_21 = _a[_i].name; - if (ts.isBindingPattern(name_21) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_21, parameterName, typePredicate.parameterName)) { + var name = _a[_i].name; + if (ts.isBindingPattern(name) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -38177,16 +39651,16 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 185 /* ArrowFunction */: - case 153 /* CallSignature */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 158 /* FunctionType */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - var parent_9 = node.parent; - if (node === parent_9.type) { - return parent_9; + case 186 /* ArrowFunction */: + case 154 /* CallSignature */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 159 /* FunctionType */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + var parent = node.parent; + if (node === parent.type) { + return parent; } } } @@ -38196,15 +39670,15 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_22 = element.name; - if (name_22.kind === 70 /* Identifier */ && - name_22.text === predicateVariableName) { + var name = element.name; + if (name.kind === 70 /* Identifier */ && + name.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_22.kind === 173 /* ArrayBindingPattern */ || - name_22.kind === 172 /* ObjectBindingPattern */) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, predicateVariableNode, predicateVariableName)) { + else if (name.kind === 174 /* ArrayBindingPattern */ || + name.kind === 173 /* ObjectBindingPattern */) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } } @@ -38212,12 +39686,12 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 155 /* IndexSignature */) { + if (node.kind === 156 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 158 /* FunctionType */ || node.kind === 225 /* FunctionDeclaration */ || node.kind === 159 /* ConstructorType */ || - node.kind === 153 /* CallSignature */ || node.kind === 150 /* Constructor */ || - node.kind === 154 /* ConstructSignature */) { + else if (node.kind === 159 /* FunctionType */ || node.kind === 227 /* FunctionDeclaration */ || node.kind === 160 /* ConstructorType */ || + node.kind === 154 /* CallSignature */ || node.kind === 151 /* Constructor */ || + node.kind === 155 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } if (ts.isAsyncFunctionLike(node) && languageVersion < 4 /* ES2017 */) { @@ -38235,10 +39709,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 153 /* CallSignature */: + case 154 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -38271,17 +39745,18 @@ var ts; } } function checkClassForDuplicateDeclarations(node) { - var Accessor; - (function (Accessor) { - Accessor[Accessor["Getter"] = 1] = "Getter"; - Accessor[Accessor["Setter"] = 2] = "Setter"; - Accessor[Accessor["Property"] = 3] = "Property"; - })(Accessor || (Accessor = {})); + var Declaration; + (function (Declaration) { + Declaration[Declaration["Getter"] = 1] = "Getter"; + Declaration[Declaration["Setter"] = 2] = "Setter"; + Declaration[Declaration["Method"] = 4] = "Method"; + Declaration[Declaration["Property"] = 3] = "Property"; + })(Declaration || (Declaration = {})); var instanceNames = ts.createMap(); var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150 /* Constructor */) { + if (member.kind === 151 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -38290,36 +39765,76 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114 /* StaticKeyword */; }); + var isStatic = ts.getModifierFlags(member) & 32 /* Static */; var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: addName(names, member.name, memberName, 1 /* Getter */); break; - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: addName(names, member.name, memberName, 2 /* Setter */); break; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: addName(names, member.name, memberName, 3 /* Property */); break; + case 150 /* MethodDeclaration */: + addName(names, member.name, memberName, 4 /* Method */); + break; } } } } function addName(names, location, name, meaning) { - var prev = names[name]; + var prev = names.get(name); if (prev) { - if (prev & meaning) { + if (prev & 4 /* Method */) { + if (meaning !== 4 /* Method */) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + } + else if (prev & meaning) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { - names[name] = prev | meaning; + names.set(name, prev | meaning); } } else { - names[name] = meaning; + names.set(name, meaning); + } + } + } + /** + * Static members being set on a constructor function may conflict with built-in properties + * of Function. Esp. in ECMAScript 5 there are non-configurable and non-writable + * built-in properties. This check issues a transpile error when a class has a static + * member with the same name as a non-writable built-in property. + * + * @see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.3 + * @see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.5 + * @see http://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-the-function-constructor + * @see http://www.ecma-international.org/ecma-262/6.0/#sec-function-instances + */ + function checkClassForStaticPropertyNameConflicts(node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + var memberNameNode = member.name; + var isStatic = ts.getModifierFlags(member) & 32 /* Static */; + if (isStatic && memberNameNode) { + var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode); + switch (memberName) { + case "name": + case "length": + case "caller": + case "arguments": + case "prototype": + var message = ts.Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1; + var className = getNameOfSymbol(getSymbolOfNode(node)); + error(memberNameNode, message, memberName, className); + break; + } } } } @@ -38327,7 +39842,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 146 /* PropertySignature */) { + if (member.kind == 147 /* PropertySignature */) { var memberName = void 0; switch (member.name.kind) { case 9 /* StringLiteral */: @@ -38338,18 +39853,18 @@ var ts; default: continue; } - if (names[memberName]) { + if (names.get(memberName)) { error(member.symbol.valueDeclaration.name, ts.Diagnostics.Duplicate_identifier_0, memberName); error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName); } else { - names[memberName] = true; + names.set(memberName, true); } } } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 227 /* InterfaceDeclaration */) { + if (node.kind === 229 /* 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 @@ -38369,7 +39884,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -38445,12 +39960,12 @@ var ts; if (n.kind === 98 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 184 /* FunctionExpression */ && n.kind !== 225 /* FunctionDeclaration */) { + else if (n.kind !== 185 /* FunctionExpression */ && n.kind !== 227 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 147 /* PropertyDeclaration */ && + return n.kind === 148 /* PropertyDeclaration */ && !(ts.getModifierFlags(n) & 32 /* Static */) && !!n.initializer; } @@ -38480,7 +39995,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -38504,7 +40019,7 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 151 /* GetAccessor */) { + if (node.kind === 152 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -38514,13 +40029,13 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 151 /* GetAccessor */ ? 152 /* SetAccessor */ : 151 /* GetAccessor */; + var otherKind = node.kind === 152 /* GetAccessor */ ? 153 /* SetAccessor */ : 152 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28 /* AccessibilityModifier */) !== (ts.getModifierFlags(otherAccessor) & 28 /* AccessibilityModifier */)) { @@ -38536,11 +40051,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 151 /* GetAccessor */) { + if (node.kind === 152 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 176 /* ObjectLiteralExpression */) { + if (node.parent.kind !== 177 /* ObjectLiteralExpression */) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -38563,6 +40078,7 @@ var ts; checkDecorators(node); } function checkTypeArgumentConstraints(typeParameters, typeArgumentNodes) { + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); var typeArguments; var mapper; var result = true; @@ -38570,7 +40086,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); + typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -38623,16 +40139,36 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessIndexType(type, accessNode) { + if (!(type.flags & 524288 /* IndexedAccess */)) { + return type; + } + // Check if the index type is assignable to 'keyof T' for the object type. + var objectType = type.objectType; + var indexType = type.indexType; + if (isTypeAssignableTo(indexType, getIndexType(objectType))) { + return type; + } + // Check if we're indexing with a numeric type and the object type is a generic + // type with a constraint that has a numeric index signature. + if (maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && isTypeOfKind(indexType, 340 /* NumberLike */)) { + var constraint = getBaseConstraintOfType(objectType); + if (constraint && getIndexInfoOfType(constraint, 1 /* Number */)) { + return type; + } + } + error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); + return type; + } function checkIndexedAccessType(node) { - getTypeFromIndexedAccessTypeNode(node); + checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node) { checkSourceElement(node.typeParameter); checkSourceElement(node.type); var type = getTypeFromMappedTypeNode(node); var constraintType = getConstraintTypeFromMappedType(type); - var keyType = constraintType.flags & 540672 /* TypeVariable */ ? getApparentTypeOfTypeVariable(constraintType) : constraintType; - checkTypeAssignableTo(keyType, stringType, node.typeParameter.constraint); + checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node) { return (ts.getModifierFlags(node) & 8 /* Private */) && ts.isInAmbientContext(node); @@ -38641,9 +40177,9 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 227 /* InterfaceDeclaration */ && - n.parent.kind !== 226 /* ClassDeclaration */ && - n.parent.kind !== 197 /* ClassExpression */ && + if (n.parent.kind !== 229 /* InterfaceDeclaration */ && + n.parent.kind !== 228 /* ClassDeclaration */ && + n.parent.kind !== 198 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported @@ -38731,7 +40267,7 @@ var ts; var errorNode_1 = subsequentNode.name || subsequentNode; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */) && + var reportError = (node.kind === 150 /* MethodDeclaration */ || node.kind === 149 /* MethodSignature */) && (ts.getModifierFlags(node) & 32 /* Static */) !== (ts.getModifierFlags(subsequentNode) & 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -38766,11 +40302,11 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var current = declarations_4[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var current = declarations_5[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 227 /* InterfaceDeclaration */ || node.parent.kind === 161 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 229 /* InterfaceDeclaration */ || node.parent.kind === 162 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -38781,7 +40317,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 === 225 /* FunctionDeclaration */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */ || node.kind === 150 /* Constructor */) { + if (node.kind === 227 /* FunctionDeclaration */ || node.kind === 150 /* MethodDeclaration */ || node.kind === 149 /* MethodSignature */ || node.kind === 151 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -38903,16 +40439,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -38924,7 +40460,8 @@ var ts; } function checkNonThenableType(type, location, message) { type = getWidenedType(type); - if (!isTypeAny(type) && !isTypeNever(type) && isTypeAssignableTo(type, getGlobalThenableType())) { + var apparentType = getApparentType(type); + if ((apparentType.flags & (1 /* Any */ | 8192 /* Never */)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { if (location) { if (!message) { message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; @@ -39140,7 +40677,12 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; if (promiseConstructorType === unknownType) { - error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + if (promiseConstructorName.kind === 70 /* Identifier */ && promiseConstructorName.text === "Promise" && getTargetType(returnType) === tryGetGlobalPromiseType()) { + error(node.type, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } + else { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + } return unknownType; } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); @@ -39175,22 +40717,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 144 /* Parameter */: + case 145 /* 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 147 /* PropertyDeclaration */: + case 148 /* 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 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -39231,14 +40773,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 144 /* Parameter */) { + if (node.kind === 145 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -39247,19 +40789,19 @@ var ts; } } break; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markTypeNodeAsReferenced(node.type); break; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); break; - case 144 /* Parameter */: + case 145 /* Parameter */: markTypeNodeAsReferenced(node.type); break; } @@ -39271,6 +40813,7 @@ var ts; checkFunctionOrMethodDeclaration(node) || checkGrammarForGenerator(node); checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -39282,7 +40825,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 142 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 143 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -39342,43 +40885,43 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 261 /* SourceFile */: - case 230 /* ModuleDeclaration */: + case 264 /* SourceFile */: + case 232 /* ModuleDeclaration */: checkUnusedModuleMembers(node); break; - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: checkUnusedTypeParameters(node); break; - case 204 /* Block */: - case 232 /* CaseBlock */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 206 /* Block */: + case 234 /* CaseBlock */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: checkUnusedLocalsAndParameters(node); break; - case 150 /* Constructor */: - case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 151 /* Constructor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: checkUnusedTypeParameters(node); break; } @@ -39387,11 +40930,10 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 227 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_2 = function (key) { - var local = node.locals[key]; + if (node.parent.kind !== 229 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + node.locals.forEach(function (local) { if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144 /* Parameter */) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 145 /* Parameter */) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -39404,10 +40946,7 @@ var ts; ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d.name || d, local.name); }); } } - }; - for (var key in node.locals) { - _loop_2(key); - } + }); } } function isRemovedPropertyFromObjectSpread(node) { @@ -39420,9 +40959,9 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 223 /* VariableDeclaration */ && - (declaration.parent.parent.kind === 212 /* ForInStatement */ || - declaration.parent.parent.kind === 213 /* ForOfStatement */)) { + if (declaration.kind === 225 /* VariableDeclaration */ && + (declaration.parent.parent.kind === 214 /* ForInStatement */ || + declaration.parent.parent.kind === 215 /* ForOfStatement */)) { return; } } @@ -39441,12 +40980,12 @@ var ts; if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149 /* MethodDeclaration */ || member.kind === 147 /* PropertyDeclaration */) { + if (member.kind === 150 /* MethodDeclaration */ || member.kind === 148 /* PropertyDeclaration */) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8 /* Private */) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 150 /* Constructor */) { + else if (member.kind === 151 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8 /* Private */) { @@ -39479,22 +41018,21 @@ var ts; } function checkUnusedModuleMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { - for (var key in node.locals) { - var local = node.locals[key]; + node.locals.forEach(function (local) { if (!local.isReferenced && !local.exportSymbol) { for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - error(declaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); + errorUnusedLocal(declaration.name, local.name); } } } - } + }); } } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 204 /* Block */) { + if (node.kind === 206 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -39517,12 +41055,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 147 /* PropertyDeclaration */ || - node.kind === 146 /* PropertySignature */ || - node.kind === 149 /* MethodDeclaration */ || - node.kind === 148 /* MethodSignature */ || - node.kind === 151 /* GetAccessor */ || - node.kind === 152 /* SetAccessor */) { + if (node.kind === 148 /* PropertyDeclaration */ || + node.kind === 147 /* PropertySignature */ || + node.kind === 150 /* MethodDeclaration */ || + node.kind === 149 /* MethodSignature */ || + node.kind === 152 /* GetAccessor */ || + node.kind === 153 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -39531,7 +41069,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 144 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 145 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -39542,6 +41080,11 @@ var ts; potentialThisCollisions.push(node); } } + function checkCollisionWithCapturedNewTargetVariable(node, name) { + if (needCollisionCheckForIdentifier(node, name, "_newTarget")) { + potentialNewTargetCollisions.push(node); + } + } // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node) { var current = node; @@ -39559,6 +41102,22 @@ var ts; current = current.parent; } } + function checkIfNewTargetIsCapturedInEnclosingScope(node) { + var current = node; + while (current) { + if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { + var isDeclaration_2 = node.kind !== 70 /* Identifier */; + if (isDeclaration_2) { + error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); + } + else { + error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); + } + return; + } + current = current.parent; + } + } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; @@ -39570,8 +41129,8 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 70 /* Identifier */; - if (isDeclaration_2) { + var isDeclaration_3 = node.kind !== 70 /* Identifier */; + if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } else { @@ -39588,12 +41147,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 230 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 232 /* 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 === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 264 /* 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)); } @@ -39603,12 +41162,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 230 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 232 /* 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 === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 264 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -39643,7 +41202,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 === 223 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 225 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -39653,24 +41212,24 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 224 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 205 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 226 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 207 /* 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 === 204 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 231 /* ModuleBlock */ || - container.kind === 230 /* ModuleDeclaration */ || - container.kind === 261 /* SourceFile */); + (container.kind === 206 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 233 /* ModuleBlock */ || + container.kind === 232 /* ModuleDeclaration */ || + container.kind === 264 /* 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_23 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_23, name_23); + var name = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); } } } @@ -39678,7 +41237,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 144 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 145 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -39689,7 +41248,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 177 /* PropertyAccessExpression */) { + if (n.kind === 178 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -39708,7 +41267,8 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 144 /* Parameter */) { + if (symbol.valueDeclaration.kind === 145 /* Parameter */ || + symbol.valueDeclaration.kind === 175 /* BindingElement */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -39722,13 +41282,14 @@ var ts; } // computed property names/initializers in instance property declaration of class like entities // are executed in constructor and thus deferred - if (current.parent.kind === 147 /* PropertyDeclaration */ && + if (current.parent.kind === 148 /* PropertyDeclaration */ && !(ts.hasModifier(current.parent, 32 /* Static */)) && ts.isClassLike(current.parent.parent)) { return; } current = current.parent; } + // fall through to report error } error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(node.name), ts.declarationNameToString(n)); } @@ -39749,28 +41310,28 @@ 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 === 142 /* ComputedPropertyName */) { + if (node.name.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 174 /* BindingElement */) { - if (node.parent.kind === 172 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */) { + if (node.kind === 175 /* BindingElement */) { + if (node.parent.kind === 173 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */ && !ts.isInAmbientContext(node)) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 142 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 143 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access - var parent_10 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_10); - var name_24 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_24)); + var parent = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent); + var name = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); markPropertyAsReferenced(property); - if (parent_10.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_10, parent_10.initializer, parentType, property); + if (parent.initializer && property) { + checkPropertyAccessibility(parent, parent.initializer, parentType, property); } } // For a binding pattern, check contained binding elements @@ -39778,14 +41339,14 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 144 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 145 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 212 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 214 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -39796,7 +41357,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 212 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 214 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -39816,21 +41377,22 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 146 /* PropertySignature */) { + if (node.kind !== 148 /* PropertyDeclaration */ && node.kind !== 147 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 223 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */) { + if (node.kind === 225 /* VariableDeclaration */ || node.kind === 175 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 144 /* Parameter */ && right.kind === 223 /* VariableDeclaration */) || - (left.kind === 223 /* VariableDeclaration */ && right.kind === 144 /* Parameter */)) { + if ((left.kind === 145 /* Parameter */ && right.kind === 225 /* VariableDeclaration */) || + (left.kind === 225 /* VariableDeclaration */ && right.kind === 145 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -39860,7 +41422,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 === 176 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 177 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -39881,7 +41443,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 206 /* EmptyStatement */) { + if (node.thenStatement.kind === 208 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -39901,12 +41463,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 224 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 226 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 224 /* VariableDeclarationList */) { + if (node.initializer.kind === 226 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -39929,14 +41491,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 === 224 /* VariableDeclarationList */) { + if (node.initializer.kind === 226 /* 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 === 175 /* ArrayLiteralExpression */ || varExpr.kind === 176 /* ObjectLiteralExpression */) { + if (varExpr.kind === 176 /* ArrayLiteralExpression */ || varExpr.kind === 177 /* 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. @@ -39968,7 +41530,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 === 224 /* VariableDeclarationList */) { + if (node.initializer.kind === 226 /* 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); @@ -39982,7 +41544,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 === 175 /* ArrayLiteralExpression */ || varExpr.kind === 176 /* ObjectLiteralExpression */) { + if (varExpr.kind === 176 /* ArrayLiteralExpression */ || varExpr.kind === 177 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -40235,7 +41797,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 151 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 152 /* SetAccessor */))); + return !!(node.kind === 152 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 153 /* SetAccessor */))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -40262,33 +41824,33 @@ var ts; // for generators. return; } - if (func.kind === 152 /* SetAccessor */) { + if (func.kind === 153 /* SetAccessor */) { if (node.expression) { - error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); + error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 150 /* Constructor */) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { - error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); + else if (func.kind === 151 /* Constructor */) { + if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node.expression || node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + var awaitedType = checkAwaitedType(exprType, node, 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 || node); + checkTypeAssignableTo(awaitedType, promisedType, node); } } else { - checkTypeAssignableTo(exprType, returnType, node.expression || node); + checkTypeAssignableTo(exprType, returnType, node); } } } - else if (func.kind !== 150 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 151 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -40318,7 +41880,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 254 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 257 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -40330,7 +41892,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 253 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 256 /* 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 comparable @@ -40361,7 +41923,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 219 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 221 /* 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; @@ -40398,14 +41960,14 @@ var ts; grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { - var blockLocals = catchClause.block.locals; - if (blockLocals) { - for (var caughtName in catchClause.locals) { - var blockLocal = blockLocals[caughtName]; + var blockLocals_1 = catchClause.block.locals; + if (blockLocals_1) { + ts.forEachKey(catchClause.locals, function (caughtName) { + var blockLocal = blockLocals_1.get(caughtName); if (blockLocal && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } - } + }); } } } @@ -40457,15 +42019,16 @@ var ts; if (!indexType) { return; } + var propDeclaration = prop.valueDeclaration; // index is numeric and property name is not valid numeric literal - if (indexKind === 1 /* Number */ && !isNumericName(prop.valueDeclaration.name)) { + if (indexKind === 1 /* Number */ && !(propDeclaration ? isNumericName(propDeclaration.name) : isNumericLiteralName(prop.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 === 142 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { - errorNode = prop.valueDeclaration; + if (propDeclaration && (propDeclaration.name.kind === 143 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { + errorNode = propDeclaration; } else if (indexDeclaration) { errorNode = indexDeclaration; @@ -40495,16 +42058,26 @@ var ts; case "string": case "symbol": case "void": + case "object": error(name, message, name.text); } } - /** Check each type parameter and check that type parameters have no duplicate type parameter declarations */ + /** + * Check each type parameter and check that type parameters have no duplicate type parameter declarations + */ function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { - for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { + var seenDefault = false; + for (var i = 0; i < typeParameterDeclarations.length; i++) { var node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { + if (node.default) { + seenDefault = true; + } + else if (seenDefault) { + error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters); + } 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)); @@ -40515,23 +42088,65 @@ var ts; } } /** Check that type parameter lists are identical across multiple declarations */ - function checkTypeParameterListsIdentical(node, symbol) { + function checkTypeParameterListsIdentical(symbol) { if (symbol.declarations.length === 1) { return; } - var firstDecl; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 226 /* ClassDeclaration */ || declaration.kind === 227 /* InterfaceDeclaration */) { - if (!firstDecl) { - firstDecl = declaration; - } - else if (!areTypeParametersIdentical(firstDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); + var links = getSymbolLinks(symbol); + if (!links.typeParametersChecked) { + links.typeParametersChecked = true; + var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); + if (declarations.length <= 1) { + return; + } + var type = getDeclaredTypeOfSymbol(symbol); + if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { + // Report an error on every conflicting declaration. + var name = symbolToString(symbol); + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; + error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } } } + function areTypeParametersIdentical(declarations, typeParameters) { + var maxTypeArgumentCount = ts.length(typeParameters); + var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; + // If this declaration has too few or too many type parameters, we report an error + var numTypeParameters = ts.length(declaration.typeParameters); + if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { + return false; + } + for (var i = 0; i < numTypeParameters; i++) { + var source = declaration.typeParameters[i]; + var target = typeParameters[i]; + // If the type parameter node does not have the same as the resolved type + // parameter at this position, we report an error. + if (source.name.text !== target.symbol.name) { + return false; + } + // If the type parameter node does not have an identical constraint as the resolved + // type parameter at this position, we report an error. + var sourceConstraint = source.constraint && getTypeFromTypeNode(source.constraint); + var targetConstraint = getConstraintFromTypeParameter(target); + if ((sourceConstraint || targetConstraint) && + (!sourceConstraint || !targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint))) { + return false; + } + // If the type parameter node has a default and it is not identical to the default + // for the type parameter at this position, we report an error. + var sourceDefault = source.default && getTypeFromTypeNode(source.default); + var targetDefault = getDefaultFromTypeParameter(target); + if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) { + return false; + } + } + } + return true; + } function checkClassExpression(node) { checkClassLikeDeclaration(node); checkNodeDeferred(node); @@ -40555,6 +42170,7 @@ var ts; if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } @@ -40564,8 +42180,12 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); - checkTypeParameterListsIdentical(node, symbol); + checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); + // Only check for reserved static identifiers on non-ambient context. + if (!ts.isInAmbientContext(node)) { + checkClassForStaticPropertyNameConflicts(node); + } var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { if (languageVersion < 2 /* ES2015 */ && !ts.isInAmbientContext(node)) { @@ -40574,7 +42194,8 @@ var ts; var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType_1 = baseTypes[0]; - var staticBaseType = getBaseConstructorTypeOfClass(type); + var baseConstructorType = getBaseConstructorTypeOfClass(type); + var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { @@ -40588,14 +42209,17 @@ var ts; } checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType_1, 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 (baseType_1.symbol.valueDeclaration && + if (baseConstructorType.flags & 540672 /* TypeVariable */ && !isMixinConstructorType(staticType)) { + error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); + } + if (baseType_1.symbol && baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 226 /* ClassDeclaration */) { + baseType_1.symbol.valueDeclaration.kind === 228 /* ClassDeclaration */) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 540672 /* TypeVariable */)) { // 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 @@ -40619,8 +42243,7 @@ var ts; if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - var declaredType = getObjectFlags(t) & 4 /* Reference */ ? t.target : t; - if (getObjectFlags(declaredType) & 3 /* ClassOrInterface */) { + if (isValidBaseType(t)) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { @@ -40650,11 +42273,16 @@ var ts; 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; + return getCheckFlags(s) & 1 /* Instantiated */ ? s.target : s; } function getClassLikeDeclarationOfSymbol(symbol) { return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); } + function getClassOrInterfaceDeclarationsOfSymbol(symbol) { + return ts.filter(symbol.declarations, function (d) { + return d.kind === 228 /* ClassDeclaration */ || d.kind === 229 /* InterfaceDeclaration */; + }); + } 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. @@ -40670,11 +42298,11 @@ var ts; // 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); + var baseProperties = getPropertiesOfType(baseType); 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 */) { + if (base.flags & 16777216 /* Prototype */) { continue; } var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); @@ -40691,7 +42319,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128 /* Abstract */))) { - if (derivedClassDecl.kind === 197 /* ClassExpression */) { + if (derivedClassDecl.kind === 198 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -40739,35 +42367,7 @@ var ts; } } function isAccessor(kind) { - return kind === 151 /* GetAccessor */ || kind === 152 /* 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; + return kind === 152 /* GetAccessor */ || kind === 153 /* SetAccessor */; } function checkInheritedPropertiesAreIdentical(type, typeNode) { var baseTypes = getBaseTypes(type); @@ -40775,16 +42375,16 @@ var ts; return true; } var seen = ts.createMap(); - ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.name, { prop: p, containingType: type }); }); var ok = true; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; - var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); + var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { var prop = properties_7[_a]; - var existing = seen[prop.name]; + var existing = seen.get(prop.name); if (!existing) { - seen[prop.name] = { prop: prop, containingType: base }; + seen.set(prop.name, { prop: prop, containingType: base }); } else { var isInheritedProperty = existing.containingType !== type; @@ -40809,9 +42409,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - checkTypeParameterListsIdentical(node, symbol); + checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 227 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 229 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -40918,7 +42518,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -40929,7 +42529,7 @@ var ts; case 51 /* TildeToken */: return ~value_1; } return undefined; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -40953,12 +42553,13 @@ var ts; } return undefined; case 8 /* NumericLiteral */: + checkGrammarNumericLiteral(e); return +e.text; - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return evalConstant(e.expression); case 70 /* Identifier */: - case 178 /* ElementAccessExpression */: - case 177 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: + case 178 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -40971,7 +42572,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 178 /* ElementAccessExpression */) { + if (e.kind === 179 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -40989,7 +42590,7 @@ var ts; if (current.kind === 70 /* Identifier */) { break; } - else if (current.kind === 177 /* PropertyAccessExpression */) { + else if (current.kind === 178 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -41033,6 +42634,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithCapturedNewTargetVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); @@ -41061,7 +42663,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 229 /* EnumDeclaration */) { + if (declaration.kind !== 231 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -41082,10 +42684,10 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var declaration = declarations_5[_i]; - if ((declaration.kind === 226 /* ClassDeclaration */ || - (declaration.kind === 225 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 228 /* ClassDeclaration */ || + (declaration.kind === 227 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -41149,7 +42751,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, 226 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 228 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -41162,7 +42764,7 @@ var ts; // We can detect if augmentation was applied using following rules: // - augmentation for a global scope is always applied // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Merged */); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 134217728 /* Transient */); if (checkBody && node.body) { // body of ambient external module is always a module block for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { @@ -41200,26 +42802,26 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 240 /* ExportAssignment */: - case 241 /* ExportDeclaration */: + case 242 /* ExportAssignment */: + case 243 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 234 /* ImportEqualsDeclaration */: - case 235 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 174 /* BindingElement */: - case 223 /* VariableDeclaration */: - var name_25 = node.name; - if (ts.isBindingPattern(name_25)) { - for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { + case 175 /* BindingElement */: + case 225 /* VariableDeclaration */: + var name = node.name; + if (ts.isBindingPattern(name)) { + for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { var el = _c[_b]; // mark individual names in binding pattern checkModuleAugmentationElement(el, isGlobalAugmentation); @@ -41227,12 +42829,12 @@ var ts; break; } // fallthrough - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 225 /* FunctionDeclaration */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 227 /* FunctionDeclaration */: + case 229 /* InterfaceDeclaration */: + case 232 /* ModuleDeclaration */: + case 230 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -41242,7 +42844,7 @@ var ts; // this is done it two steps // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error // 2. main check - report error if value declaration of the parent symbol is module augmentation) - var reportError = !(symbol.flags & 33554432 /* Merged */); + var reportError = !(symbol.flags & 134217728 /* Transient */); if (!reportError) { // symbol should not originate in augmentation reportError = ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); @@ -41255,12 +42857,12 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return node; - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: do { node = node.left; } while (node.kind !== 70 /* Identifier */); return node; - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 70 /* Identifier */); @@ -41273,9 +42875,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 231 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 241 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 233 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 264 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 243 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -41308,7 +42910,7 @@ var ts; (symbol.flags & 793064 /* Type */ ? 793064 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 243 /* ExportSpecifier */ ? + var message = node.kind === 245 /* 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)); @@ -41336,7 +42938,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 239 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -41393,8 +42995,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 231 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 261 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 233 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 233 /* ModuleBlock */ && + !node.moduleSpecifier && ts.isInAmbientContext(node); + if (node.parent.kind !== 264 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -41408,7 +43012,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 261 /* SourceFile */ || node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 230 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 264 /* SourceFile */ || node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 232 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -41434,9 +43038,14 @@ 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 === 261 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 230 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + var container = node.parent.kind === 264 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 232 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + if (node.isExportEquals) { + error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); + } + else { + error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); + } return; } // Grammar checking @@ -41462,18 +43071,13 @@ var ts; } } function hasExportedMembers(moduleSymbol) { - for (var id in moduleSymbol.exports) { - if (id !== "export=") { - return true; - } - } - return false; + return ts.forEachEntry(moduleSymbol.exports, function (_, id) { return id !== "export="; }); } function checkExternalModuleExports(node) { var moduleSymbol = getSymbolOfNode(node); var links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - var exportEqualsSymbol = moduleSymbol.exports["export="]; + var exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; if (!isTopLevelInExternalModuleAugmentation(declaration)) { @@ -41482,35 +43086,35 @@ var ts; } // Checks for export * conflicts var exports = getExportsOfModule(moduleSymbol); - for (var id in exports) { + exports && exports.forEach(function (_a, id) { + var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { - continue; + return; } - var _a = exports[id], declarations = _a.declarations, flags = _a.flags; // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. // (TS Exceptions: namespaces, function overloads, enums, and interfaces) if (flags & (1920 /* Namespace */ | 64 /* Interface */ | 384 /* Enum */)) { - continue; + return; } var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) - continue; + return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, id)); } } } - } + }); links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 225 /* FunctionDeclaration */ && declaration.kind !== 149 /* MethodDeclaration */) || + return (declaration.kind !== 227 /* FunctionDeclaration */ && declaration.kind !== 150 /* MethodDeclaration */) || !!declaration.body; } } @@ -41523,123 +43127,123 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 225 /* FunctionDeclaration */: + case 232 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 227 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: return checkTypeParameter(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return checkParameter(node); - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return checkPropertyDeclaration(node); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: return checkSignatureDeclaration(node); - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: return checkMethodDeclaration(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return checkConstructorDeclaration(node); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return checkAccessorDeclaration(node); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return checkTypeReferenceNode(node); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return checkTypePredicate(node); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return checkTypeQuery(node); - case 161 /* TypeLiteral */: + case 162 /* TypeLiteral */: return checkTypeLiteral(node); - case 162 /* ArrayType */: + case 163 /* ArrayType */: return checkArrayType(node); - case 163 /* TupleType */: + case 164 /* TupleType */: return checkTupleType(node); - case 164 /* UnionType */: - case 165 /* IntersectionType */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 166 /* ParenthesizedType */: - case 168 /* TypeOperator */: + case 167 /* ParenthesizedType */: + case 169 /* TypeOperator */: return checkSourceElement(node.type); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 170 /* MappedType */: + case 171 /* MappedType */: return checkMappedType(node); - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 204 /* Block */: - case 231 /* ModuleBlock */: + case 206 /* Block */: + case 233 /* ModuleBlock */: return checkBlock(node); - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: return checkVariableStatement(node); - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return checkExpressionStatement(node); - case 208 /* IfStatement */: + case 210 /* IfStatement */: return checkIfStatement(node); - case 209 /* DoStatement */: + case 211 /* DoStatement */: return checkDoStatement(node); - case 210 /* WhileStatement */: + case 212 /* WhileStatement */: return checkWhileStatement(node); - case 211 /* ForStatement */: + case 213 /* ForStatement */: return checkForStatement(node); - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: return checkForInStatement(node); - case 213 /* ForOfStatement */: + case 215 /* ForOfStatement */: return checkForOfStatement(node); - case 214 /* ContinueStatement */: - case 215 /* BreakStatement */: + case 216 /* ContinueStatement */: + case 217 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 216 /* ReturnStatement */: + case 218 /* ReturnStatement */: return checkReturnStatement(node); - case 217 /* WithStatement */: + case 219 /* WithStatement */: return checkWithStatement(node); - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: return checkSwitchStatement(node); - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return checkLabeledStatement(node); - case 220 /* ThrowStatement */: + case 222 /* ThrowStatement */: return checkThrowStatement(node); - case 221 /* TryStatement */: + case 223 /* TryStatement */: return checkTryStatement(node); - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 174 /* BindingElement */: + case 175 /* BindingElement */: return checkBindingElement(node); - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return checkClassDeclaration(node); - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 228 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return checkImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return checkExportDeclaration(node); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return checkExportAssignment(node); - case 206 /* EmptyStatement */: + case 208 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 222 /* DebuggerStatement */: + case 224 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 244 /* MissingDeclaration */: + case 246 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -41661,17 +43265,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: checkAccessorDeferred(node); break; - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -41696,6 +43300,7 @@ var ts; // Grammar checking checkGrammarSourceFile(node); potentialThisCollisions.length = 0; + potentialNewTargetCollisions.length = 0; deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; ts.forEach(node.statements, checkSourceElement); @@ -41715,6 +43320,10 @@ var ts; ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); potentialThisCollisions.length = 0; } + if (potentialNewTargetCollisions.length) { + ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); + potentialNewTargetCollisions.length = 0; + } links.flags |= 1 /* TypeChecked */; } } @@ -41772,7 +43381,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 217 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 219 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -41795,25 +43404,25 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 261 /* SourceFile */: + case 264 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 197 /* ClassExpression */: + case 198 /* 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 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* 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. @@ -41822,7 +43431,7 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793064 /* Type */); } break; - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -41850,17 +43459,16 @@ var ts; // 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 (!symbols[id]) { - symbols[id] = symbol; + if (!symbols.has(id)) { + symbols.set(id, symbol); } } } function copySymbols(source, meaning) { if (meaning) { - for (var id in source) { - var symbol = source[id]; + source.forEach(function (symbol) { copySymbol(symbol, meaning); - } + }); } } } @@ -41871,28 +43479,28 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 143 /* TypeParameter */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 229 /* EnumDeclaration */: + case 144 /* TypeParameter */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 231 /* 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 === 141 /* QualifiedName */) { + while (node.parent && node.parent.kind === 142 /* QualifiedName */) { node = node.parent; } - return node.parent && (node.parent.kind === 157 /* TypeReference */ || node.parent.kind === 272 /* JSDocTypeReference */); + return node.parent && (node.parent.kind === 158 /* TypeReference */ || node.parent.kind === 276 /* JSDocTypeReference */); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 177 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 178 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 199 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 200 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -41909,13 +43517,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 141 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 142 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 234 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 236 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 240 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 242 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -41927,7 +43535,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 177 /* PropertyAccessExpression */) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 178 /* PropertyAccessExpression */) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1 /* ExportsProperty */: @@ -41939,13 +43547,13 @@ var ts; default: } } - if (entityName.parent.kind === 240 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 242 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 177 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { + if (entityName.kind !== 178 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 234 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 236 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -41955,7 +43563,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 199 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 200 /* ExpressionWithTypeArguments */) { meaning = 793064 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -41979,14 +43587,14 @@ var ts; } return resolveEntityName(entityName, 107455 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 177 /* PropertyAccessExpression */) { + else if (entityName.kind === 178 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 141 /* QualifiedName */) { + else if (entityName.kind === 142 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -41995,20 +43603,20 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 157 /* TypeReference */ || entityName.parent.kind === 272 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = (entityName.parent.kind === 158 /* TypeReference */ || entityName.parent.kind === 276 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 250 /* JsxAttribute */) { + else if (entityName.parent.kind === 252 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 156 /* TypePredicate */) { + if (entityName.parent.kind === 157 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 261 /* SourceFile */) { + if (node.kind === 264 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -42026,8 +43634,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 174 /* BindingElement */ && - node.parent.parent.kind === 172 /* ObjectBindingPattern */ && + else if (node.parent.kind === 175 /* BindingElement */ && + node.parent.parent.kind === 173 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -42038,8 +43646,8 @@ var ts; } switch (node.kind) { case 70 /* Identifier */: - case 177 /* PropertyAccessExpression */: - case 141 /* QualifiedName */: + case 178 /* PropertyAccessExpression */: + case 142 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -42053,12 +43661,12 @@ var ts; case 96 /* SuperKeyword */: var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 167 /* ThisType */: + case 168 /* ThisType */: return getTypeFromTypeNode(node).symbol; case 122 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 150 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 151 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -42066,7 +43674,7 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 235 /* ImportDeclaration */ || node.parent.kind === 241 /* ExportDeclaration */) && + ((node.parent.kind === 237 /* ImportDeclaration */ || node.parent.kind === 243 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -42076,7 +43684,7 @@ var ts; // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 178 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 179 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -42093,7 +43701,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 === 258 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 261 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */ | 8388608 /* Alias */); } return undefined; @@ -42155,28 +43763,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 176 /* ObjectLiteralExpression */ || expr.kind === 175 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 177 /* ObjectLiteralExpression */ || expr.kind === 176 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 213 /* ForOfStatement */) { + if (expr.parent.kind === 215 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 192 /* BinaryExpression */) { + if (expr.parent.kind === 193 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 257 /* PropertyAssignment */) { + if (expr.parent.kind === 260 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 175 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 176 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false) || unknownType; @@ -42216,30 +43824,33 @@ var ts; var propsByName = createSymbolTable(getPropertiesOfType(type)); if (getSignaturesOfType(type, 0 /* Call */).length || getSignaturesOfType(type, 1 /* Construct */).length) { ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { - if (!propsByName[p.name]) { - propsByName[p.name] = p; + if (!propsByName.has(p.name)) { + propsByName.set(p.name, p); } }); } return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (symbol.flags & 268435456 /* SyntheticProperty */) { + if (getCheckFlags(symbol) & 2 /* SyntheticProperty */) { var symbols_3 = []; - var name_26 = symbol.name; + var name_2 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_26); + var symbol = getPropertyOfType(t, name_2); if (symbol) { symbols_3.push(symbol); } }); return symbols_3; } - else if (symbol.flags & 67108864 /* Transient */) { + else if (symbol.flags & 134217728 /* Transient */) { if (symbol.leftSpread) { var links = symbol; return [links.leftSpread, links.rightSpread]; } + if (symbol.mappedTypeOrigin) { + return getRootSymbols(symbol.mappedTypeOrigin); + } var target = void 0; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -42256,7 +43867,8 @@ var ts; if (!ts.isGeneratedIdentifier(node)) { node = ts.getParseTreeNode(node, ts.isIdentifier); if (node) { - return getReferencedValueSymbol(node) === argumentsSymbol; + var isPropertyName_1 = node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node; + return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } return false; @@ -42277,7 +43889,7 @@ var ts; // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment ? !!(moduleSymbol.flags & 107455 /* Value */) - : ts.forEachProperty(getExportsOfModule(moduleSymbol), isValue); + : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { @@ -42312,7 +43924,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 261 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 264 /* SourceFile */) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -42369,7 +43981,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 204 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 206 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -42415,16 +44027,16 @@ var ts; return true; } switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: - case 236 /* ImportClause */: - case 237 /* NamespaceImport */: - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 238 /* ImportClause */: + case 239 /* NamespaceImport */: + case 241 /* ImportSpecifier */: + case 245 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return node.expression && node.expression.kind === 70 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -42434,7 +44046,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 261 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 264 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -42491,6 +44103,12 @@ var ts; } return false; } + function isRequiredInitializedParameter(parameter) { + return strictNullChecks && + !isOptionalParameter(parameter) && + parameter.initializer && + !(ts.getModifierFlags(parameter) & 92 /* ParameterPropertyModifier */); + } function getNodeCheckFlags(node) { node = ts.getParseTreeNode(node); return node ? getNodeLinks(node).flags : undefined; @@ -42500,7 +44118,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 260 /* EnumMember */) { + if (node.kind === 263 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -42518,16 +44136,18 @@ var ts; function getTypeReferenceSerializationKind(typeName, location) { // 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, /*dontResolveAlias*/ false, location); - var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); - if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { - return ts.TypeReferenceSerializationKind.Promise; - } - 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, 793064 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + if (valueSymbol && valueSymbol === typeSymbol) { + var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); + if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { + return ts.TypeReferenceSerializationKind.Promise; + } + var constructorType = getTypeOfSymbol(valueSymbol); + if (constructorType && isConstructorType(constructorType)) { + return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + } // 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; @@ -42573,6 +44193,9 @@ var ts; var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : unknownType; + if (flags & 4096 /* AddUndefined */) { + type = includeFalsyTypes(type, 2048 /* Undefined */); + } getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { @@ -42587,10 +44210,13 @@ var ts; var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(node)); resolveBaseTypesOfClass(classType); var baseType = classType.resolvedBaseTypes.length ? classType.resolvedBaseTypes[0] : unknownType; + if (!baseType.symbol) { + writer.reportIllegalExtends(); + } getSymbolDisplayBuilder().buildTypeDisplay(baseType, writer, enclosingDeclaration, flags); } function hasGlobalName(name) { - return !!globals[name]; + return globals.has(name); } function getReferencedValueSymbol(reference, startInDeclarationContainer) { var resolvedSymbol = getNodeLinks(reference).resolvedSymbol; @@ -42601,9 +44227,9 @@ var ts; if (startInDeclarationContainer) { // When resolving the name of a declaration as a value, we need to start resolution // at a point outside of the declaration. - var parent_11 = reference.parent; - if (ts.isDeclaration(parent_11) && reference === parent_11.name) { - location = getDeclarationContainer(parent_11); + var parent = reference.parent; + if (ts.isDeclaration(parent) && reference === parent.name) { + location = getDeclarationContainer(parent); } } return resolveName(location, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -42639,14 +44265,13 @@ var ts; if (resolvedTypeReferenceDirectives) { // populate reverse mapping: file path -> type reference directive that was resolved to this file fileToDirective = ts.createFileMap(); - for (var key in resolvedTypeReferenceDirectives) { - var resolvedDirective = resolvedTypeReferenceDirectives[key]; + resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) { if (!resolvedDirective) { - continue; + return; } var file = host.getSourceFile(resolvedDirective.resolvedFileName); fileToDirective.set(file.path, key); - } + }); } return { getReferencedExportContainer: getReferencedExportContainer, @@ -42660,6 +44285,7 @@ var ts; isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, + isRequiredInitializedParameter: isRequiredInitializedParameter, writeTypeOfDeclaration: writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, writeTypeOfExpression: writeTypeOfExpression, @@ -42689,7 +44315,7 @@ var ts; // property access can only be used as values // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = (node.kind === 177 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) + var meaning = (node.kind === 178 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) ? 107455 /* Value */ | 1048576 /* ExportValue */ : 793064 /* Type */ | 1920 /* Namespace */; var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -42732,15 +44358,15 @@ var ts; // external modules cannot define or contribute to type declaration files var current = symbol; while (true) { - var parent_12 = getParentOfSymbol(current); - if (parent_12) { - current = parent_12; + var parent = getParentOfSymbol(current); + if (parent) { + current = parent; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 261 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 264 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -42760,7 +44386,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 261 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 264 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -42784,11 +44410,11 @@ var ts; if (file.symbol && file.symbol.globalExports) { // Merge in UMD exports with first-in-wins semantics (see #9771) var source = file.symbol.globalExports; - for (var id in source) { - if (!(id in globals)) { - globals[id] = source[id]; + source.forEach(function (sourceSymbol, id) { + if (!globals.has(id)) { + globals.set(id, sourceSymbol); } - } + }); } } if (augmentations) { @@ -42858,10 +44484,10 @@ var ts; var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1 /* FirstEmitHelper */; helper <= 128 /* LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { - var name_27 = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_27), 107455 /* Value */); + var name = getHelperName(helper); + var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name), 107455 /* Value */); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_27); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); } } } @@ -42897,7 +44523,7 @@ var ts; } 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"); + var thenPropertySymbol = createSymbol(4 /* Property */, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; var thenableType = createObjectType(16 /* Anonymous */); thenableType.properties = [thenPropertySymbol]; @@ -42912,14 +44538,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 149 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 150 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 151 /* GetAccessor */ || node.kind === 152 /* SetAccessor */) { + else if (node.kind === 152 /* GetAccessor */ || node.kind === 153 /* 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); @@ -42937,16 +44563,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 130 /* ReadonlyKeyword */) { - if (node.kind === 146 /* PropertySignature */ || node.kind === 148 /* MethodSignature */) { + if (node.kind === 147 /* PropertySignature */ || node.kind === 149 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 155 /* IndexSignature */) { + if (node.kind === 156 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 75 /* ConstKeyword */: - if (node.kind !== 229 /* EnumDeclaration */ && node.parent.kind === 226 /* ClassDeclaration */) { + if (node.kind !== 231 /* EnumDeclaration */ && node.parent.kind === 228 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75 /* ConstKeyword */)); } break; @@ -42972,7 +44598,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + else if (node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -42995,10 +44621,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + else if (node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 144 /* Parameter */) { + else if (node.kind === 145 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -43011,7 +44637,7 @@ var ts; if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 146 /* PropertySignature */ && node.kind !== 155 /* IndexSignature */ && node.kind !== 144 /* Parameter */) { + else if (node.kind !== 148 /* PropertyDeclaration */ && node.kind !== 147 /* PropertySignature */ && node.kind !== 156 /* IndexSignature */ && node.kind !== 145 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } @@ -43031,10 +44657,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 228 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 144 /* Parameter */) { + else if (node.kind === 145 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; @@ -43046,13 +44672,13 @@ var ts; 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 === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 228 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 144 /* Parameter */) { + else if (node.kind === 145 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 231 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 233 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -43062,14 +44688,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 226 /* ClassDeclaration */) { - if (node.kind !== 149 /* MethodDeclaration */ && - node.kind !== 147 /* PropertyDeclaration */ && - node.kind !== 151 /* GetAccessor */ && - node.kind !== 152 /* SetAccessor */) { + if (node.kind !== 228 /* ClassDeclaration */) { + if (node.kind !== 150 /* MethodDeclaration */ && + node.kind !== 148 /* PropertyDeclaration */ && + node.kind !== 152 /* GetAccessor */ && + node.kind !== 153 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 226 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { + if (!(node.parent.kind === 228 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -43088,7 +44714,7 @@ var ts; 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 === 144 /* Parameter */) { + else if (node.kind === 145 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -43096,7 +44722,7 @@ var ts; break; } } - if (node.kind === 150 /* Constructor */) { + if (node.kind === 151 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -43111,13 +44737,13 @@ var ts; } return; } - else if ((node.kind === 235 /* ImportDeclaration */ || node.kind === 234 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 237 /* ImportDeclaration */ || node.kind === 236 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 144 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 145 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 144 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 145 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -43137,37 +44763,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 150 /* Constructor */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 155 /* IndexSignature */: - case 230 /* ModuleDeclaration */: - case 235 /* ImportDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 241 /* ExportDeclaration */: - case 240 /* ExportAssignment */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 144 /* Parameter */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 151 /* Constructor */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 156 /* IndexSignature */: + case 232 /* ModuleDeclaration */: + case 237 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 243 /* ExportDeclaration */: + case 242 /* ExportAssignment */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 145 /* Parameter */: return false; default: - if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + if (node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { return false; } switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 119 /* AsyncKeyword */); - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 116 /* AbstractKeyword */); - case 227 /* InterfaceDeclaration */: - case 205 /* VariableStatement */: - case 228 /* TypeAliasDeclaration */: + case 229 /* InterfaceDeclaration */: + case 207 /* VariableStatement */: + case 230 /* TypeAliasDeclaration */: return true; - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 75 /* ConstKeyword */); default: ts.Debug.fail(); @@ -43180,10 +44806,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 149 /* MethodDeclaration */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -43246,7 +44872,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 185 /* ArrowFunction */) { + if (node.kind === 186 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -43281,7 +44907,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 !== 134 /* StringKeyword */ && parameter.type.kind !== 132 /* NumberKeyword */) { + if (parameter.type.kind !== 135 /* StringKeyword */ && parameter.type.kind !== 132 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -43309,7 +44935,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 198 /* OmittedExpression */) { + if (arg.kind === 199 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -43382,19 +45008,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 142 /* ComputedPropertyName */) { + if (node.kind !== 143 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 192 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 25 /* CommaToken */) { + if (computedPropertyName.expression.kind === 193 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 25 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 225 /* FunctionDeclaration */ || - node.kind === 184 /* FunctionExpression */ || - node.kind === 149 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 227 /* FunctionDeclaration */ || + node.kind === 185 /* FunctionExpression */ || + node.kind === 150 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -43419,15 +45045,15 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 259 /* SpreadAssignment */) { + if (prop.kind === 262 /* SpreadAssignment */) { continue; } - var name_28 = prop.name; - if (name_28.kind === 142 /* ComputedPropertyName */) { + var name = prop.name; + if (name.kind === 143 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_28); + checkGrammarComputedPropertyName(name); } - if (prop.kind === 258 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 261 /* 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); @@ -43436,7 +45062,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 /* AsyncKeyword */ || prop.kind !== 149 /* MethodDeclaration */) { + if (mod.kind !== 119 /* AsyncKeyword */ || prop.kind !== 150 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -43450,69 +45076,69 @@ 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 === 257 /* PropertyAssignment */ || prop.kind === 258 /* ShorthandPropertyAssignment */) { + if (prop.kind === 260 /* PropertyAssignment */ || prop.kind === 261 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_28.kind === 8 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_28); + if (name.kind === 8 /* NumericLiteral */) { + checkGrammarNumericLiteral(name); } currentKind = Property; } - else if (prop.kind === 149 /* MethodDeclaration */) { + else if (prop.kind === 150 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 151 /* GetAccessor */) { + else if (prop.kind === 152 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 152 /* SetAccessor */) { + else if (prop.kind === 153 /* SetAccessor */) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_28); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { continue; } - if (!seen[effectiveName]) { - seen[effectiveName] = currentKind; + var existingKind = seen.get(effectiveName); + if (!existingKind) { + seen.set(effectiveName, currentKind); } else { - var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_28, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_28)); + grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[effectiveName] = currentKind | existingKind; + seen.set(effectiveName, currentKind | existingKind); } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } } function checkGrammarJsxElement(node) { var seen = ts.createMap(); - for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { + for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 251 /* JsxSpreadAttribute */) { + if (attr.kind === 254 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; - var name_29 = jsxAttr.name; - if (!seen[name_29.text]) { - seen[name_29.text] = true; + var name = jsxAttr.name; + if (!seen.get(name.text)) { + seen.set(name.text, true); } else { - return grammarErrorOnNode(name_29, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 252 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 255 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -43521,7 +45147,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 224 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 226 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -43536,20 +45162,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 212 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 214 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 212 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 214 /* 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 === 212 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 214 /* 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); @@ -43576,11 +45202,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 151 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 152 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 152 /* SetAccessor */) { + else if (kind === 153 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -43603,10 +45229,10 @@ var ts; A get accessor has no parameters or a single `this` parameter. A set accessor has one parameter or a `this` parameter and one more parameter */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 151 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 152 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 151 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 152 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -43621,7 +45247,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 176 /* ObjectLiteralExpression */) { + if (node.parent.kind === 177 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -43642,10 +45268,10 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 227 /* InterfaceDeclaration */) { + else if (node.parent.kind === 229 /* 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 === 161 /* TypeLiteral */) { + else if (node.parent.kind === 162 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -43656,11 +45282,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 219 /* LabeledStatement */: + case 221 /* 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 === 214 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 216 /* 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); @@ -43668,8 +45294,8 @@ var ts; return false; } break; - case 218 /* SwitchStatement */: - if (node.kind === 215 /* BreakStatement */ && !node.label) { + case 220 /* SwitchStatement */: + if (node.kind === 217 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -43684,13 +45310,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 215 /* BreakStatement */ + var message = node.kind === 217 /* 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 === 215 /* BreakStatement */ + var message = node.kind === 217 /* 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); @@ -43702,7 +45328,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 173 /* ArrayBindingPattern */ || node.name.kind === 172 /* ObjectBindingPattern */) { + if (node.name.kind === 174 /* ArrayBindingPattern */ || node.name.kind === 173 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -43713,11 +45339,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 190 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && + expr.kind === 191 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 212 /* ForInStatement */ && node.parent.parent.kind !== 213 /* ForOfStatement */) { + if (node.parent.parent.kind !== 214 /* ForInStatement */ && node.parent.parent.kind !== 215 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -43746,6 +45372,10 @@ var ts; } } } + if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && + !ts.isInAmbientContext(node.parent.parent) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { + checkESModuleMarker(node.name); + } var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". @@ -43755,6 +45385,22 @@ var ts; // and its Identifier is eval or arguments return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } + function checkESModuleMarker(name) { + if (name.kind === 70 /* Identifier */) { + if (ts.unescapeIdentifier(name.text) === "__esModule") { + return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); + } + } + else { + var elements = name.elements; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; + if (!ts.isOmittedExpression(element)) { + return checkESModuleMarker(element.name); + } + } + } + } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 70 /* Identifier */) { if (name.originalKeywordKind === 109 /* LetKeyword */) { @@ -43763,8 +45409,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { - var element = elements_2[_i]; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var element = elements_3[_i]; if (!ts.isOmittedExpression(element)) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -43782,15 +45428,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 208 /* IfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 217 /* WithStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 210 /* IfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 219 /* WithStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: return false; - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -43805,6 +45451,13 @@ var ts; } } } + function checkGrammarMetaProperty(node) { + if (node.keywordToken === 93 /* NewKeyword */) { + if (node.name.text !== "target") { + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + } + } + } function hasParseDiagnostics(sourceFile) { return sourceFile.parseDiagnostics.length > 0; } @@ -43845,7 +45498,7 @@ var ts; return true; } } - else if (node.parent.kind === 227 /* InterfaceDeclaration */) { + else if (node.parent.kind === 229 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -43853,7 +45506,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 161 /* TypeLiteral */) { + else if (node.parent.kind === 162 /* 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; } @@ -43878,13 +45531,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 227 /* InterfaceDeclaration */ || - node.kind === 228 /* TypeAliasDeclaration */ || - node.kind === 235 /* ImportDeclaration */ || - node.kind === 234 /* ImportEqualsDeclaration */ || - node.kind === 241 /* ExportDeclaration */ || - node.kind === 240 /* ExportAssignment */ || - node.kind === 233 /* NamespaceExportDeclaration */ || + if (node.kind === 229 /* InterfaceDeclaration */ || + node.kind === 230 /* TypeAliasDeclaration */ || + node.kind === 237 /* ImportDeclaration */ || + node.kind === 236 /* ImportEqualsDeclaration */ || + node.kind === 243 /* ExportDeclaration */ || + node.kind === 242 /* ExportAssignment */ || + node.kind === 235 /* NamespaceExportDeclaration */ || ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -43893,7 +45546,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 === 205 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 207 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -43919,7 +45572,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 204 /* Block */ || node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { + if (node.parent.kind === 206 /* Block */ || node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -43927,13 +45580,30 @@ var ts; } } else { + // We must be parented by a statement. If so, there's no need + // to report the error as our parent will have already done it. + // Debug.assert(isStatement(node.parent)); } } } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.isOctalLiteral && languageVersion >= 1 /* ES5 */) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + if (node.isOctalLiteral) { + var diagnosticMessage = void 0; + if (languageVersion >= 1 /* ES5 */) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 172 /* LiteralType */)) { + diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; + } + else if (ts.isChildOfNodeWithKind(node, 263 /* EnumMember */)) { + diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; + } + if (diagnosticMessage) { + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37 /* MinusToken */; + var literal = (withMinus ? "-" : "") + "0o" + node.text; + return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); + } } } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { @@ -43946,11 +45616,11 @@ var ts; } function getAmbientModules() { var result = []; - for (var sym in globals) { + globals.forEach(function (global, sym) { if (ambientModuleSymbolRegex.test(sym)) { - result.push(globals[sym]); + result.push(global); } - } + }); return result; } } @@ -43962,70 +45632,6 @@ var ts; /* @internal */ var ts; (function (ts) { - ; - /** - * This map contains information about the shape of each Node in "types.ts" pertaining to how - * each node should be traversed during a transformation. - * - * Each edge corresponds to a property in a Node subtype that should be traversed when visiting - * each child. The properties are assigned in the order in which traversal should occur. - * - * We only add entries for nodes that do not have a create/update pair defined in factory.ts - * - * NOTE: This needs to be kept up to date with changes to nodes in "types.ts". Currently, this - * map is not comprehensive. Only node edges relevant to tree transformation are - * currently defined. We may extend this to be more comprehensive, and eventually - * supplant the existing `forEachChild` implementation if performance is not - * significantly impacted. - */ - var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[141 /* QualifiedName */] = [ - { name: "left", test: ts.isEntityName }, - { name: "right", test: ts.isIdentifier } - ], - _a[145 /* Decorator */] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[182 /* TypeAssertionExpression */] = [ - { name: "type", test: ts.isTypeNode }, - { name: "expression", test: ts.isUnaryExpression } - ], - _a[200 /* AsExpression */] = [ - { name: "expression", test: ts.isExpression }, - { name: "type", test: ts.isTypeNode } - ], - _a[201 /* NonNullExpression */] = [ - { name: "expression", test: ts.isLeftHandSideExpression } - ], - _a[229 /* EnumDeclaration */] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "members", test: ts.isEnumMember } - ], - _a[230 /* ModuleDeclaration */] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isModuleName }, - { name: "body", test: ts.isModuleBody } - ], - _a[231 /* ModuleBlock */] = [ - { name: "statements", test: ts.isStatement } - ], - _a[234 /* ImportEqualsDeclaration */] = [ - { name: "decorators", test: ts.isDecorator }, - { name: "modifiers", test: ts.isModifier }, - { name: "name", test: ts.isIdentifier }, - { name: "moduleReference", test: ts.isModuleReference } - ], - _a[245 /* ExternalModuleReference */] = [ - { name: "expression", test: ts.isExpression, optional: true } - ], - _a[260 /* EnumMember */] = [ - { name: "name", test: ts.isPropertyName }, - { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } - ], - _a)); function reduceNode(node, f, initial) { return node ? f(initial, node) : initial; } @@ -44034,8 +45640,7 @@ var ts; } /** * Similar to `reduceLeft`, performs a reduction against each child of a node. - * NOTE: Unlike `forEachChild`, this does *not* visit every node. Only nodes added to the - * `nodeEdgeTraversalMap` above will be visited. + * NOTE: Unlike `forEachChild`, this does *not* visit every node. * * @param node The node containing the children to reduce. * @param initial The initial value to supply to the reduction. @@ -44049,47 +45654,51 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 140 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 141 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 156 /* TypePredicate */ && kind <= 171 /* LiteralType */)) { + if ((kind >= 157 /* TypePredicate */ && kind <= 172 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 203 /* SemicolonClassElement */: - case 206 /* EmptyStatement */: - case 198 /* OmittedExpression */: - case 222 /* DebuggerStatement */: - case 293 /* NotEmittedStatement */: + case 205 /* SemicolonClassElement */: + case 208 /* EmptyStatement */: + case 199 /* OmittedExpression */: + case 224 /* DebuggerStatement */: + case 297 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 142 /* ComputedPropertyName */: + case 142 /* QualifiedName */: + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); + break; + case 143 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 144 /* Parameter */: + case 145 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 145 /* Decorator */: + case 146 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44098,12 +45707,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 150 /* Constructor */: + case 151 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44111,7 +45720,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44119,45 +45728,49 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 174 /* BindingElement */: + case 175 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 179 /* CallExpression */: + case 180 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 180 /* NewExpression */: + case 181 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 184 /* FunctionExpression */: + case 183 /* TypeAssertionExpression */: + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 185 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -44165,119 +45778,126 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 183 /* ParenthesizedExpression */: - case 186 /* DeleteExpression */: - case 187 /* TypeOfExpression */: - case 188 /* VoidExpression */: - case 189 /* AwaitExpression */: - case 195 /* YieldExpression */: - case 196 /* SpreadElement */: - case 201 /* NonNullExpression */: + case 184 /* ParenthesizedExpression */: + case 187 /* DeleteExpression */: + case 188 /* TypeOfExpression */: + case 189 /* VoidExpression */: + case 190 /* AwaitExpression */: + case 196 /* YieldExpression */: + case 197 /* SpreadElement */: + case 202 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; + case 201 /* AsExpression */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.type, cbNode, result); + break; + case 202 /* NonNullExpression */: + result = reduceNode(node.expression, cbNode, result); + break; // Misc - case 202 /* TemplateSpan */: + case 204 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 204 /* Block */: + case 206 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 208 /* IfStatement */: + case 210 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 209 /* DoStatement */: + case 211 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 210 /* WhileStatement */: - case 217 /* WithStatement */: + case 212 /* WhileStatement */: + case 219 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 211 /* ForStatement */: + case 213 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 216 /* ReturnStatement */: - case 220 /* ThrowStatement */: + case 218 /* ReturnStatement */: + case 222 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 221 /* TryStatement */: + case 223 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 224 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44286,7 +45906,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -44294,118 +45914,148 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 232 /* CaseBlock */: + case 231 /* EnumDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 232 /* ModuleDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 233 /* ModuleBlock */: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 234 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 235 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.moduleReference, cbNode, result); + break; + case 237 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 236 /* ImportClause */: + case 238 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 237 /* NamespaceImport */: + case 239 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 240 /* NamedImports */: + case 244 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 239 /* ImportSpecifier */: - case 243 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: + case 245 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; + // Module references + case 247 /* ExternalModuleReference */: + result = reduceNode(node.expression, cbNode, result); + break; // JSX - case 246 /* JsxElement */: + case 248 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 247 /* JsxSelfClosingElement */: - case 248 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + case 250 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); - result = reduceNodes(node.attributes, cbNodes, result); + result = reduceNode(node.attributes, cbNode, result); break; - case 249 /* JsxClosingElement */: + case 251 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 250 /* JsxAttribute */: + case 253 /* JsxAttributes */: + result = reduceNodes(node.properties, cbNodes, result); + break; + case 252 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 251 /* JsxSpreadAttribute */: + case 254 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 252 /* JsxExpression */: + case 255 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 253 /* CaseClause */: + case 256 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // fall-through - case 254 /* DefaultClause */: + case 257 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 255 /* HeritageClause */: + case 258 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 256 /* CatchClause */: + case 259 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 257 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 258 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 259 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; + // Enum + case 263 /* EnumMember */: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); // Top-level nodes - case 261 /* SourceFile */: + case 264 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; - case 294 /* PartiallyEmittedExpression */: + // Transformation nodes + case 298 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; default: - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_1 = edgeTraversalPath; _i < edgeTraversalPath_1.length; _i++) { - var edge = edgeTraversalPath_1[_i]; - var value = node[edge.name]; - if (value !== undefined) { - result = ts.isArray(value) - ? reduceNodes(value, cbNodes, result) - : cbNode(result, value); - } - } - } break; } return result; } ts.reduceEachChild = reduceEachChild; - function visitNode(node, visitor, test, optional, lift, parenthesize, parentNode) { + /** + * Visits a Node using the supplied visitor, possibly returning a new Node in its place. + * + * @param node The Node to visit. + * @param visitor The callback used to visit the Node. + * @param test A callback to execute to verify the Node is valid. + * @param optional An optional value indicating whether the Node is itself optional. + * @param lift An optional callback to execute to lift a NodeArray into a valid Node. + */ + function visitNode(node, visitor, test, optional, lift) { if (node === undefined || visitor === undefined) { return node; } @@ -44427,15 +46077,21 @@ var ts; else { visitedNode = visited; } - if (parenthesize !== undefined) { - visitedNode = parenthesize(visitedNode, parentNode); - } Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); return visitedNode; } ts.visitNode = visitNode; - function visitNodes(nodes, visitor, test, start, count, parenthesize, parentNode) { + /** + * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. + * + * @param nodes The NodeArray to visit. + * @param visitor The callback used to visit a Node. + * @param test A node test to execute for each node. + * @param start An optional value indicating the starting offset at which to start visiting. + * @param count An optional value indicating the maximum number of nodes to visit. + */ + function visitNodes(nodes, visitor, test, start, count) { if (nodes === undefined) { return undefined; } @@ -44452,8 +46108,7 @@ var ts; // If we are not visiting all of the original nodes, we must always create a new array. // Since this is a fragment of a node array, we do not copy over the previous location // and will only copy over `hasTrailingComma` if we are including the last element. - updated = ts.createNodeArray([], /*location*/ undefined, - /*hasTrailingComma*/ nodes.hasTrailingComma && start + count === length); + updated = ts.createNodeArray([], /*hasTrailingComma*/ nodes.hasTrailingComma && start + count === length); } // Visit each original node. for (var i = 0; i < count; i++) { @@ -44463,27 +46118,22 @@ var ts; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { // Ensure we have a copy of `nodes`, up to the current index. - updated = ts.createNodeArray(nodes.slice(0, i), /*location*/ nodes, nodes.hasTrailingComma); + updated = ts.createNodeArray(nodes.slice(0, i), nodes.hasTrailingComma); + ts.setTextRange(updated, nodes); } if (visited) { if (ts.isArray(visited)) { for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) { var visitedNode = visited_1[_i]; - visitedNode = parenthesize - ? parenthesize(visitedNode, parentNode) - : visitedNode; Debug.assertNode(visitedNode, test); aggregateTransformFlags(visitedNode); updated.push(visitedNode); } } else { - var visitedNode = parenthesize - ? parenthesize(visited, parentNode) - : visited; - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); - updated.push(visitedNode); + Debug.assertNode(visited, test); + aggregateTransformFlags(visited); + updated.push(visited); } } } @@ -44499,10 +46149,10 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); - return ts.createNodeArray(ts.concatenate(statements, declarations), statements); + return ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements); } ts.visitLexicalEnvironment = visitLexicalEnvironment; /** @@ -44534,219 +46184,223 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 140 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 141 /* LastToken */)) { return node; } // We do not yet support types. - if ((kind >= 156 /* TypePredicate */ && kind <= 171 /* LiteralType */)) { + if ((kind >= 157 /* TypePredicate */ && kind <= 172 /* LiteralType */)) { return node; } switch (node.kind) { - case 203 /* SemicolonClassElement */: - case 206 /* EmptyStatement */: - case 198 /* OmittedExpression */: - case 222 /* DebuggerStatement */: + case 205 /* SemicolonClassElement */: + case 208 /* EmptyStatement */: + case 199 /* OmittedExpression */: + case 224 /* DebuggerStatement */: // No need to visit nodes with no children. return node; // Names - case 142 /* ComputedPropertyName */: + case 142 /* QualifiedName */: + return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); + case 143 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 144 /* Parameter */: + case 145 /* Parameter */: return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), node.dotDotDotToken, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); + case 146 /* Decorator */: + return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type member - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 150 /* Constructor */: + case 151 /* Constructor */: return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); // Binding patterns - case 172 /* ObjectBindingPattern */: + case 173 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 173 /* ArrayBindingPattern */: + case 174 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 174 /* BindingElement */: + case 175 /* BindingElement */: return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, /*optional*/ true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Expression - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 183 /* ParenthesizedExpression */: + case 183 /* TypeAssertionExpression */: + return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 184 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 187 /* TypeOfExpression */: + case 188 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 201 /* AsExpression */: + return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); + case 202 /* NonNullExpression */: + return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Misc - case 202 /* TemplateSpan */: + case 204 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 204 /* Block */: + case 206 /* Block */: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 208 /* IfStatement */: + case 210 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, /*optional*/ true, liftToBlock)); - case 209 /* DoStatement */: + case 211 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* WhileStatement */: + case 212 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 211 /* ForStatement */: + case 213 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 213 /* ForOfStatement */: + case 215 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 214 /* ContinueStatement */: + case 216 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 215 /* BreakStatement */: + case 217 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 216 /* ReturnStatement */: + case 218 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true)); - case 217 /* WithStatement */: + case 219 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 220 /* ThrowStatement */: + case 222 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 221 /* TryStatement */: + case 223 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, /*optional*/ true), visitNode(node.finallyBlock, visitor, ts.isBlock, /*optional*/ true)); - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 224 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 232 /* CaseBlock */: + case 231 /* EnumDeclaration */: + return ts.updateEnumDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNodes(node.members, visitor, ts.isEnumMember)); + case 232 /* ModuleDeclaration */: + return ts.updateModuleDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); + case 233 /* ModuleBlock */: + return ts.updateModuleBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 234 /* CaseBlock */: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 235 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + return ts.updateImportEqualsDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); + case 237 /* ImportDeclaration */: return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 236 /* ImportClause */: + case 238 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true)); - case 237 /* NamespaceImport */: + case 239 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 238 /* NamedImports */: + case 240 /* NamedImports */: return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 239 /* ImportSpecifier */: + case 241 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, /*optional*/ true)); - case 242 /* NamedExports */: + case 244 /* NamedExports */: return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 243 /* ExportSpecifier */: + case 245 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); + // Module references + case 247 /* ExternalModuleReference */: + return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 246 /* JsxElement */: + case 248 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 247 /* JsxSelfClosingElement */: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 248 /* JsxOpeningElement */: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 249 /* JsxClosingElement */: + case 253 /* JsxAttributes */: + return ts.updateJsxAttributes(node, visitNodes(node.properties, visitor, ts.isJsxAttributeLike)); + case 249 /* JsxSelfClosingElement */: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 250 /* JsxOpeningElement */: + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 251 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 250 /* JsxAttribute */: + case 252 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 251 /* JsxSpreadAttribute */: + case 254 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 252 /* JsxExpression */: + case 255 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 253 /* CaseClause */: + case 256 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); - case 254 /* DefaultClause */: + case 257 /* DefaultClause */: return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 255 /* HeritageClause */: + case 258 /* HeritageClause */: return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 257 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 258 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 259 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + // Enum + case 263 /* EnumMember */: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Top-level nodes - case 261 /* SourceFile */: + case 264 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 294 /* PartiallyEmittedExpression */: + case 298 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: - var updated = void 0; - var edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (var _i = 0, edgeTraversalPath_2 = edgeTraversalPath; _i < edgeTraversalPath_2.length; _i++) { - var edge = edgeTraversalPath_2[_i]; - var value = node[edge.name]; - if (value !== undefined) { - var visited = ts.isArray(value) - ? visitNodes(value, visitor, edge.test, 0, value.length, edge.parenthesize, node) - : visitNode(value, visitor, edge.test, edge.optional, edge.lift, edge.parenthesize, node); - if (updated !== undefined || visited !== value) { - if (updated === undefined) { - updated = ts.getMutableClone(node); - } - if (visited !== value) { - updated[edge.name] = visited; - } - } - } - } - } - return updated ? ts.updateNode(updated, node) : node; + return node; } - // return node; } ts.visitEachChild = visitEachChild; function mergeLexicalEnvironment(statements, declarations) { @@ -44754,19 +46408,19 @@ var ts; return statements; } return ts.isNodeArray(statements) - ? ts.createNodeArray(ts.concatenate(statements, declarations), statements) + ? ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements) : ts.addRange(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; function mergeFunctionBodyLexicalEnvironment(body, declarations) { if (body && declarations !== undefined && declarations.length > 0) { if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.createNodeArray(ts.concatenate(body.statements, declarations), body.statements)); + return ts.updateBlock(body, ts.setTextRange(ts.createNodeArray(ts.concatenate(body.statements, declarations)), body.statements)); } else { - return ts.createBlock(ts.createNodeArray([ts.createReturn(body, /*location*/ body)].concat(declarations), body), - /*location*/ body, - /*multiLine*/ true); + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray([ts.setTextRange(ts.createReturn(body), body)].concat(declarations)), body), + /*multiLine*/ true), + /*location*/ body); } } return body; @@ -44836,7 +46490,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || ts.isTypeNode(node)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 200 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -44889,7 +46543,6 @@ var ts; } } })(Debug = ts.Debug || (ts.Debug = {})); - var _a; })(ts || (ts = {})); /// /// @@ -44979,7 +46632,7 @@ var ts; ts.Debug.assertNode(target, createAssignmentCallback ? ts.isIdentifier : ts.isExpression); var expression = createAssignmentCallback ? createAssignmentCallback(target, value, location) - : ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value, location); + : ts.setTextRange(ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value), location); expression.original = original; emitExpression(expression); } @@ -45028,11 +46681,12 @@ var ts; } } for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) { - var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_30 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; - var variable = ts.createVariableDeclaration(name_30, - /*type*/ undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); + var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name = _a.name, value = _a.value, location = _a.location, original = _a.original; + var variable = ts.createVariableDeclaration(name, + /*type*/ undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value); variable.original = original; - if (ts.isIdentifier(name_30)) { + ts.setTextRange(variable, location); + if (ts.isIdentifier(name)) { ts.setEmitFlags(variable, 64 /* NoNestedSourceMaps */); } ts.aggregateTransformFlags(variable); @@ -45236,8 +46890,8 @@ var ts; return ts.createElementAccess(value, argumentExpression); } else { - var name_31 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); - return ts.createPropertyAccess(value, name_31); + var name = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); + return ts.createPropertyAccess(value, name); } } /** @@ -45259,7 +46913,7 @@ var ts; var temp = ts.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { flattenContext.context.hoistVariableDeclaration(temp); - flattenContext.emitExpression(ts.createAssignment(temp, value, location)); + flattenContext.emitExpression(ts.setTextRange(ts.createAssignment(temp, value), location)); } else { flattenContext.emitBindingOrAssignment(temp, value, location, /*original*/ undefined); @@ -45312,7 +46966,10 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), undefined, [value, ts.createArrayLiteral(propertyNames, location)]); + return ts.createCall(ts.getHelperName("__rest"), undefined, [ + value, + ts.setTextRange(ts.createArrayLiteral(propertyNames), location) + ]); } })(ts || (ts = {})); /// @@ -45347,8 +47004,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(177 /* PropertyAccessExpression */); - context.enableSubstitution(178 /* ElementAccessExpression */); + context.enableSubstitution(178 /* PropertyAccessExpression */); + context.enableSubstitution(179 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -45412,15 +47069,15 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 261 /* SourceFile */: - case 232 /* CaseBlock */: - case 231 /* ModuleBlock */: - case 204 /* Block */: + case 264 /* SourceFile */: + case 234 /* CaseBlock */: + case 233 /* ModuleBlock */: + case 206 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 226 /* ClassDeclaration */: - case 225 /* FunctionDeclaration */: + case 228 /* ClassDeclaration */: + case 227 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -45467,13 +47124,13 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return visitImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return visitExportAssignment(node); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -45493,11 +47150,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 241 /* ExportDeclaration */ || - node.kind === 235 /* ImportDeclaration */ || - node.kind === 236 /* ImportClause */ || - (node.kind === 234 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 245 /* ExternalModuleReference */)) { + if (node.kind === 243 /* ExportDeclaration */ || + node.kind === 237 /* ImportDeclaration */ || + node.kind === 238 /* ImportClause */ || + (node.kind === 236 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 247 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -45527,19 +47184,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 150 /* Constructor */: + case 151 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 147 /* PropertyDeclaration */: - case 155 /* IndexSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 149 /* MethodDeclaration */: + case 148 /* PropertyDeclaration */: + case 156 /* IndexSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 150 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 203 /* SemicolonClassElement */: + case 205 /* SemicolonClassElement */: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -45579,47 +47236,47 @@ var ts; case 123 /* DeclareKeyword */: case 130 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 162 /* ArrayType */: - case 163 /* TupleType */: - case 161 /* TypeLiteral */: - case 156 /* TypePredicate */: - case 143 /* TypeParameter */: + case 163 /* ArrayType */: + case 164 /* TupleType */: + case 162 /* TypeLiteral */: + case 157 /* TypePredicate */: + case 144 /* TypeParameter */: case 118 /* AnyKeyword */: case 121 /* BooleanKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 129 /* NeverKeyword */: case 104 /* VoidKeyword */: - case 135 /* SymbolKeyword */: - case 159 /* ConstructorType */: - case 158 /* FunctionType */: - case 160 /* TypeQuery */: - case 157 /* TypeReference */: - case 164 /* UnionType */: - case 165 /* IntersectionType */: - case 166 /* ParenthesizedType */: - case 167 /* ThisType */: - case 168 /* TypeOperator */: - case 169 /* IndexedAccessType */: - case 170 /* MappedType */: - case 171 /* LiteralType */: + case 136 /* SymbolKeyword */: + case 160 /* ConstructorType */: + case 159 /* FunctionType */: + case 161 /* TypeQuery */: + case 158 /* TypeReference */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: + case 167 /* ParenthesizedType */: + case 168 /* ThisType */: + case 169 /* TypeOperator */: + case 170 /* IndexedAccessType */: + case 171 /* MappedType */: + case 172 /* LiteralType */: // TypeScript type nodes are elided. - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: // TypeScript index signatures are elided. - case 145 /* Decorator */: + case 146 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 228 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: // TypeScript property declarations are elided. return undefined; - case 150 /* Constructor */: + case 151 /* Constructor */: return visitConstructor(node); - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -45630,7 +47287,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -45641,35 +47298,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 255 /* HeritageClause */: + case 258 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 144 /* Parameter */: + case 145 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -45679,33 +47336,33 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 182 /* TypeAssertionExpression */: - case 200 /* AsExpression */: + case 183 /* TypeAssertionExpression */: + case 201 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return visitCallExpression(node); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return visitNewExpression(node); - case 201 /* NonNullExpression */: + case 202 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -45810,13 +47467,14 @@ var ts; // } var classDeclaration = ts.createClassDeclaration( /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); - var emitFlags = ts.getEmitFlags(node); + /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause)); // To better align with the old emitter, we should not emit a trailing source map // entry if the class has static properties. + var emitFlags = ts.getEmitFlags(node); if (hasStaticProperties) { emitFlags |= 32 /* NoTrailingSourceMap */; } + ts.setTextRange(classDeclaration, node); ts.setOriginalNode(classDeclaration, node); ts.setEmitFlags(classDeclaration, emitFlags); return classDeclaration; @@ -45924,12 +47582,18 @@ var ts; // } var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, hasExtendsClause); - var classExpression = ts.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members, location); + var classExpression = ts.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); + ts.setTextRange(classExpression, location); // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference // or decoratedClassAlias if the class contain self-reference. - var statement = ts.createLetStatement(declName, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression, location); + var statement = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(declName, + /*type*/ undefined, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression) + ], 1 /* Let */)); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, location); ts.setCommentRange(statement, node); return statement; } @@ -45946,10 +47610,11 @@ var ts; var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84 /* ExtendsKeyword */; })); - var classExpression = ts.setOriginalNode(ts.createClassExpression( + var classExpression = ts.createClassExpression( /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, heritageClauses, members, - /*location*/ node), node); + /*typeParameters*/ undefined, heritageClauses, members); + ts.setOriginalNode(classExpression, node); + ts.setTextRange(classExpression, node); if (staticProperties.length > 0) { var expressions = []; var temp = ts.createTempVariable(hoistVariableDeclaration); @@ -45981,7 +47646,7 @@ var ts; members.push(constructor); } ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement)); - return ts.createNodeArray(members, /*location*/ node.members); + return ts.setTextRange(ts.createNodeArray(members), /*location*/ node.members); } /** * Transforms (or creates) a constructor for a class. @@ -46006,10 +47671,9 @@ var ts; // constructor(${parameters}) { // ${body} // } - return ts.startOnNewLine(ts.setOriginalNode(ts.createConstructor( + return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(ts.createConstructor( /*decorators*/ undefined, - /*modifiers*/ undefined, parameters, body, - /*location*/ constructor || node), constructor)); + /*modifiers*/ undefined, parameters, body), constructor || node), constructor)); } /** * Transforms (or creates) the parameters for the constructor of a class with @@ -46092,10 +47756,10 @@ var ts; } // End the lexical environment. ts.addRange(statements, endLexicalEnvironment()); - return ts.createBlock(ts.createNodeArray(statements, + return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ constructor ? constructor.body.statements : node.members), - /*location*/ constructor ? constructor.body : undefined, - /*multiLine*/ true); + /*multiLine*/ true), + /*location*/ constructor ? constructor.body : undefined); } /** * Adds super call and preceding prologue directives into the list of statements. @@ -46113,7 +47777,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -46150,9 +47814,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536 /* NoComments */); - return ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), propertyName, - /*location*/ node.name), localName), - /*location*/ ts.moveRangePos(node, -1))); + return ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1))); } /** * Gets all property declarations with initializers on either the static or instance side of a class. @@ -46186,7 +47848,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 147 /* PropertyDeclaration */ + return member.kind === 148 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } @@ -46321,12 +47983,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -46479,7 +48141,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 147 /* PropertyDeclaration */ + ? member.kind === 148 /* PropertyDeclaration */ ? ts.createVoidZero() : ts.createNull() : undefined; @@ -46585,7 +48247,7 @@ var ts; (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(35 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { - decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true))); + decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); } } } @@ -46598,10 +48260,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */ - || kind === 147 /* PropertyDeclaration */; + return kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */ + || kind === 148 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -46611,7 +48273,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 149 /* MethodDeclaration */; + return node.kind === 150 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -46622,12 +48284,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return true; } return false; @@ -46639,15 +48301,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 147 /* PropertyDeclaration */: - case 144 /* Parameter */: - case 151 /* GetAccessor */: + case 148 /* PropertyDeclaration */: + case 145 /* Parameter */: + case 152 /* GetAccessor */: return serializeTypeNode(node.type); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 149 /* MethodDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 150 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -46684,7 +48346,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 151 /* GetAccessor */) { + if (container && node.kind === 152 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -46730,21 +48392,24 @@ var ts; } switch (node.kind) { case 104 /* VoidKeyword */: + case 138 /* UndefinedKeyword */: + case 94 /* NullKeyword */: + case 129 /* NeverKeyword */: return ts.createVoidZero(); - case 166 /* ParenthesizedType */: + case 167 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return ts.createIdentifier("Function"); - case 162 /* ArrayType */: - case 163 /* TupleType */: + case 163 /* ArrayType */: + case 164 /* TupleType */: return ts.createIdentifier("Array"); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: case 121 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: return ts.createIdentifier("String"); - case 171 /* LiteralType */: + case 172 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -46760,49 +48425,22 @@ var ts; break; case 132 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 135 /* SymbolKeyword */: + case 136 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return serializeTypeReferenceNode(node); - case 165 /* IntersectionType */: - case 164 /* UnionType */: - { - var unionOrIntersection = node; - var serializedUnion = void 0; - for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - var serializedIndividual = serializeTypeNode(typeNode); - // Non identifier - if (serializedIndividual.kind !== 70 /* Identifier */) { - serializedUnion = undefined; - break; - } - // One of the individual is global object, return immediately - if (serializedIndividual.text === "Object") { - return serializedIndividual; - } - // Different types - if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { - serializedUnion = undefined; - break; - } - serializedUnion = serializedIndividual; - } - // If we were able to find common type - if (serializedUnion) { - return serializedUnion; - } - } - // Fallthrough - case 160 /* TypeQuery */: - case 168 /* TypeOperator */: - case 169 /* IndexedAccessType */: - case 170 /* MappedType */: - case 161 /* TypeLiteral */: + case 166 /* IntersectionType */: + case 165 /* UnionType */: + return serializeUnionOrIntersectionType(node); + case 161 /* TypeQuery */: + case 169 /* TypeOperator */: + case 170 /* IndexedAccessType */: + case 171 /* MappedType */: + case 162 /* TypeLiteral */: case 118 /* AnyKeyword */: - case 167 /* ThisType */: + case 168 /* ThisType */: break; default: ts.Debug.failBadSyntaxKind(node); @@ -46810,6 +48448,37 @@ var ts; } return ts.createIdentifier("Object"); } + function serializeUnionOrIntersectionType(node) { + var serializedUnion; + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + if (ts.isVoidExpression(serializedIndividual)) { + // If we dont have any other type already set, set the initial type + if (!serializedUnion) { + serializedUnion = serializedIndividual; + } + } + else if (ts.isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") { + // One of the individual is global object, return immediately + return serializedIndividual; + } + else if (serializedUnion && !ts.isVoidExpression(serializedUnion)) { + // Different types + if (!ts.isIdentifier(serializedUnion) || + !ts.isIdentifier(serializedIndividual) || + serializedUnion.text !== serializedIndividual.text) { + return ts.createIdentifier("Object"); + } + } + else { + // Initialize the union type + serializedUnion = serializedIndividual; + } + } + // If we were able to find common type, use it + return serializedUnion; + } /** * Serializes a TypeReferenceNode to an appropriate JS constructor value for use with * decorator type metadata. @@ -46859,15 +48528,15 @@ var ts; case 70 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. - var name_32 = ts.getMutableClone(node); - name_32.flags &= ~8 /* Synthesized */; - name_32.original = undefined; - name_32.parent = currentScope; + var name = ts.getMutableClone(node); + name.flags &= ~8 /* Synthesized */; + name.original = undefined; + name.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_32), ts.createLiteral("undefined")), name_32); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } - return name_32; - case 141 /* QualifiedName */: + return name; + case 142 /* QualifiedName */: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -46935,7 +48604,7 @@ var ts; hoistVariableDeclaration(generatedName); expression = ts.createAssignment(generatedName, expression); } - return ts.setOriginalNode(ts.createComputedPropertyName(expression, /*location*/ name), name); + return ts.updateComputedPropertyName(name, expression); } else { return name; @@ -46953,7 +48622,7 @@ var ts; function visitHeritageClause(node) { if (node.token === 84 /* ExtendsKeyword */) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(84 /* ExtendsKeyword */, types, node); + return ts.setTextRange(ts.createHeritageClause(84 /* ExtendsKeyword */, types), node); } return undefined; } @@ -46966,9 +48635,8 @@ var ts; * @param node The ExpressionWithTypeArguments to transform. */ function visitExpressionWithTypeArguments(node) { - var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); - return ts.createExpressionWithTypeArguments( - /*typeArguments*/ undefined, expression, node); + return ts.updateExpressionWithTypeArguments(node, + /*typeArguments*/ undefined, ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); } /** * Determines whether to emit a function-like declaration. We should not emit the @@ -47138,11 +48806,11 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), /*questionToken*/ undefined, - /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), - /*location*/ ts.moveRangePastModifiers(node)); + /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); // While we emit the source map for the node after skipping decorators and modifiers, // we need to emit the comments for the original range. ts.setOriginalNode(parameter, node); + ts.setTextRange(parameter, ts.moveRangePastModifiers(node)); ts.setCommentRange(parameter, node); ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); ts.setEmitFlags(parameter.name, 32 /* NoTrailingSourceMap */); @@ -47161,8 +48829,7 @@ var ts; // elide statement if there are no initialized variables. return undefined; } - return ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), - /*location*/ node); + return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -47175,7 +48842,7 @@ var ts; /*needsValue*/ false, createNamespaceExportExpression); } else { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression)), /*location*/ node); } } @@ -47289,9 +48956,9 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], /*type*/ undefined, transformEnumBody(node, containerName)), - /*typeArguments*/ undefined, [moduleArg]), - /*location*/ node); + /*typeArguments*/ undefined, [moduleArg])); ts.setOriginalNode(enumStatement, node); + ts.setTextRange(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); // Add a DeclarationMarker for the enum to preserve trailing comments and mark @@ -47312,8 +48979,7 @@ var ts; ts.addRange(statements, ts.map(node.members, transformEnumMember)); ts.addRange(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceLocalName; - return ts.createBlock(ts.createNodeArray(statements, /*location*/ node.members), - /*location*/ undefined, + return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); } /** @@ -47326,9 +48992,7 @@ var ts; // we pass false as 'generateNameForComputedPropertyName' for a backward compatibility purposes // old emitter always generate 'expression' part of the name as-is. var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); - return ts.createStatement(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name, - /*location*/ member), - /*location*/ member); + return ts.setTextRange(ts.createStatement(ts.setTextRange(ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), transformEnumMemberDeclarationValue(member))), name), member)), member); } /** * Transforms the value of an enum member. @@ -47381,8 +49045,8 @@ var ts; if (!currentScopeFirstDeclarationsOfName) { currentScopeFirstDeclarationsOfName = ts.createMap(); } - if (!(name in currentScopeFirstDeclarationsOfName)) { - currentScopeFirstDeclarationsOfName[name] = node; + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } } @@ -47392,9 +49056,9 @@ var ts; */ function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_33 = node.symbol && node.symbol.name; - if (name_33) { - return currentScopeFirstDeclarationsOfName[name_33] === node; + var name = node.symbol && node.symbol.name; + if (name) { + return currentScopeFirstDeclarationsOfName.get(name) === node; } } return false; @@ -47411,7 +49075,7 @@ var ts; recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 229 /* EnumDeclaration */) { + if (node.kind === 231 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -47503,9 +49167,9 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], /*type*/ undefined, transformModuleBody(node, containerName)), - /*typeArguments*/ undefined, [moduleArg]), - /*location*/ node); + /*typeArguments*/ undefined, [moduleArg])); ts.setOriginalNode(moduleStatement, node); + ts.setTextRange(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); // Add a DeclarationMarker for the namespace to preserve trailing comments and mark @@ -47530,8 +49194,8 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 231 /* ModuleBlock */) { - ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); + if (body.kind === 233 /* ModuleBlock */) { + saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; } @@ -47552,10 +49216,10 @@ var ts; currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; - var block = ts.createBlock(ts.createNodeArray(statements, + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ statementsLocation), - /*location*/ blockLocation, /*multiLine*/ true); + ts.setTextRange(block, blockLocation); // namespace hello.hi.world { // function foo() {} // @@ -47576,13 +49240,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 231 /* ModuleBlock */) { + if (body.kind !== 233 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 230 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 232 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -47623,7 +49287,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 237 /* NamespaceImport */) { + if (node.kind === 239 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -47730,10 +49394,10 @@ var ts; if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; - return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ + return ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.setOriginalNode(ts.createVariableDeclaration(node.name, /*type*/ undefined, moduleReference), node) - ]), node), node); + ])), node), node); } else { // exports.${name} = ${moduleReference}; @@ -47778,7 +49442,7 @@ var ts; * Creates a statement for the provided expression. This is used in calls to `map`. */ function expressionToStatement(expression) { - return ts.createStatement(expression, /*location*/ undefined); + return ts.createStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), ts.getLocalName(node)); @@ -47788,10 +49452,10 @@ var ts; statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue), location); + return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { - return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue, location); + return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); } function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) { return ts.getNamespaceMemberName(currentNamespaceContainerName, name, /*allowComments*/ false, /*allowSourceMaps*/ true); @@ -47819,7 +49483,7 @@ var ts; function getClassAliasIfNeeded(node) { if (resolver.getNodeCheckFlags(node) & 8388608 /* ClassWithConstructorReference */) { enableSubstitutionForClassAliases(); - var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); + var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.unescapeIdentifier(node.name.text) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; hoistVariableDeclaration(classAlias); return classAlias; @@ -47846,7 +49510,7 @@ var ts; // substitute class names inside of a class declaration. context.enableSubstitution(70 /* Identifier */); // Keep track of class aliases. - classAliases = ts.createMap(); + classAliases = []; } } function enableSubstitutionForNamespaceExports() { @@ -47855,25 +49519,25 @@ var ts; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. context.enableSubstitution(70 /* Identifier */); - context.enableSubstitution(258 /* ShorthandPropertyAssignment */); + context.enableSubstitution(261 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(230 /* ModuleDeclaration */); + context.enableEmitNotification(232 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 230 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 232 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 229 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 231 /* EnumDeclaration */; } /** * Hook for node emit. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2 /* NamespaceExports */; @@ -47881,18 +49545,18 @@ var ts; if (enabledSubstitutions & 8 /* NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { applicableSubstitutions |= 8 /* NonQualifiedEnumMembers */; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; } /** * Hooks node substitutions. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -47902,16 +49566,16 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2 /* NamespaceExports */) { - var name_34 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_34); + var name = node.name; + var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { // A shorthand property with an assignment initializer is probably part of a // destructuring assignment if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_34, initializer, /*location*/ node); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); } - return ts.createPropertyAssignment(name_34, exportedName, /*location*/ node); + return ts.setTextRange(ts.createPropertyAssignment(name, exportedName), node); } } return node; @@ -47920,9 +49584,9 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return substituteExpressionIdentifier(node); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -47960,11 +49624,12 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 261 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 230 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 229 /* EnumDeclaration */); + if (container && container.kind !== 264 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 232 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 231 /* EnumDeclaration */); if (substitute) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, /*location*/ node); + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), + /*location*/ node); } } } @@ -48011,11 +49676,11 @@ var ts; }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(paramHelper); - return ts.createCall(ts.getHelperName("__param"), + return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression - ], location); + ]), location); } var metadataHelper = { name: "typescript:metadata", @@ -48040,7 +49705,7 @@ var ts; function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) { context.requestEmitHelper(decorateHelper); var argumentsArray = []; - argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, /*location*/ undefined, /*multiLine*/ true)); + argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, /*multiLine*/ true)); argumentsArray.push(target); if (memberName) { argumentsArray.push(memberName); @@ -48048,7 +49713,8 @@ var ts; argumentsArray.push(descriptor); } } - return ts.createCall(ts.getHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray, location); + return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), + /*typeArguments*/ undefined, argumentsArray), location); } })(ts || (ts = {})); /// @@ -48078,37 +49744,37 @@ var ts; return node; } switch (node.kind) { - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 213 /* ForOfStatement */: + case 215 /* ForOfStatement */: return visitForOfStatement(node); - case 211 /* ForStatement */: + case 213 /* ForStatement */: return visitForStatement(node); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return visitVoidExpression(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return visitConstructorDeclaration(node); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 151 /* GetAccessor */: + case 152 /* GetAccessor */: return visitGetAccessorDeclaration(node); - case 152 /* SetAccessor */: + case 153 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return visitFunctionExpression(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return visitArrowFunction(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return visitParameter(node); - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return visitExpressionStatement(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); default: return ts.visitEachChild(node, visitor, context); @@ -48117,9 +49783,9 @@ var ts; function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; - for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { - var e = elements_3[_i]; - if (e.kind === 259 /* SpreadAssignment */) { + for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { + var e = elements_4[_i]; + if (e.kind === 262 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -48131,7 +49797,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 257 /* PropertyAssignment */) { + if (e.kind === 260 /* PropertyAssignment */) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -48153,7 +49819,7 @@ var ts; // If the first element is a spread element, then the first argument to __assign is {}: // { ...o, a, b, ...o2 } => __assign({}, o, {a, b}, o2) var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 176 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 177 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -48216,26 +49882,26 @@ var ts; /*skipInitializer*/ true); if (ts.some(declarations)) { var statement = ts.createVariableStatement( - /*modifiers*/ undefined, ts.updateVariableDeclarationList(initializer, declarations), - /*location*/ initializer); + /*modifiers*/ undefined, ts.updateVariableDeclarationList(initializer, declarations)); + ts.setTextRange(statement, initializer); leadingStatements = ts.append(leadingStatements, statement); } } else if (ts.isAssignmentPattern(initializer)) { temp = ts.createTempVariable(/*recordTempVariable*/ undefined); - var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.createAssignment(initializer, temp, /*location*/ node.initializer)), visitor, context, 1 /* ObjectRest */); - leadingStatements = ts.append(leadingStatements, ts.createStatement(expression, /*location*/ node.initializer)); + var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.setTextRange(ts.createAssignment(initializer, temp), node.initializer)), visitor, context, 1 /* ObjectRest */); + leadingStatements = ts.append(leadingStatements, ts.setTextRange(ts.createStatement(expression), node.initializer)); } } if (temp) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var statement = ts.visitNode(node.statement, visitor, ts.isStatement); var block = ts.isBlock(statement) - ? ts.updateBlock(statement, ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements), statement.statements)) - : ts.createBlock(ts.append(leadingStatements, statement), statement, /*multiLine*/ true); - return ts.updateForOf(node, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, /*type*/ undefined, /*initializer*/ undefined, node.initializer) - ], node.initializer, 1 /* Let */), expression, block); + ? ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements)), statement.statements)) + : ts.setTextRange(ts.createBlock(ts.append(leadingStatements, statement), /*multiLine*/ true), statement); + return ts.updateForOf(node, ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer) + ], 1 /* Let */), node.initializer), expression, block); } return ts.visitEachChild(node, visitor, context); } @@ -48307,7 +49973,7 @@ var ts; var trailingStatements = endLexicalEnvironment(); if (ts.some(leadingStatements) || ts.some(trailingStatements)) { var block = ts.convertToFunctionBody(body, /*multiLine*/ true); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements)), block.statements)); } return body; } @@ -48320,6 +49986,10 @@ var ts; text: "\n var __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };" }; function createAssignHelper(context, attributesSegments) { + if (context.getCompilerOptions().target >= 2 /* ES2015 */) { + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), + /*typeArguments*/ undefined, attributesSegments); + } context.requestEmitHelper(assignHelper); return ts.createCall(ts.getHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); @@ -48361,11 +50031,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 246 /* JsxElement */: + case 248 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 247 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 252 /* JsxExpression */: + case 255 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -48375,11 +50045,11 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 252 /* JsxExpression */: + case 255 /* JsxExpression */: return visitJsxExpression(node); - case 246 /* JsxElement */: + case 248 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 247 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); default: ts.Debug.failBadSyntaxKind(node); @@ -48395,7 +50065,7 @@ var ts; function visitJsxOpeningLikeElement(node, children, isChild, location) { var tagName = getTagName(node); var objectProperties; - var attrs = node.attributes; + var attrs = node.attributes.properties; if (attrs.length === 0) { // When there are no attributes, React wants "null" objectProperties = ts.createNull(); @@ -48434,13 +50104,16 @@ var ts; } function transformJsxAttributeInitializer(node) { if (node === undefined) { - return ts.createLiteral(true); + return ts.createTrue(); } else if (node.kind === 9 /* StringLiteral */) { var decoded = tryDecodeEntities(node.text); - return decoded ? ts.createLiteral(decoded, /*location*/ node) : node; + return decoded ? ts.setTextRange(ts.createLiteral(decoded), node) : node; } - else if (node.kind === 252 /* JsxExpression */) { + else if (node.kind === 255 /* JsxExpression */) { + if (node.expression === undefined) { + return ts.createTrue(); + } return visitJsxExpression(node); } else { @@ -48448,54 +50121,61 @@ var ts; } } function visitJsxText(node) { - var text = ts.getTextOfNode(node, /*includeTrivia*/ true); - var parts; + var fixed = fixupWhitespaceAndDecodeEntities(ts.getTextOfNode(node, /*includeTrivia*/ true)); + return fixed === undefined ? undefined : ts.createLiteral(fixed); + } + /** + * 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 + * See also https://www.w3.org/TR/html4/struct/text.html#h-9.1 and https://www.w3.org/TR/CSS2/text.html#white-space-model + * + * An equivalent algorithm would be: + * - If there is only one line, return it. + * - If there is only whitespace (but multiple lines), return `undefined`. + * - Split the text into lines. + * - 'trimRight' the first line, 'trimLeft' the last line, 'trim' middle lines. + * - Decode entities on each line (individually). + * - Remove empty lines and join the rest with " ". + */ + function fixupWhitespaceAndDecodeEntities(text) { + var acc; + // First non-whitespace character on this line. var firstNonWhitespace = 0; + // Last non-whitespace character on this line. 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 + // These initial values are special because the first line is: + // firstNonWhitespace = 0 to indicate that we want leading whitsepace, + // but lastNonWhitespace = -1 as a special flag to indicate that we *don't* include the line if it's all whitespace. 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); - if (!parts) { - parts = []; - } - // We do not escape the string here as that is handled by the printer - // when it emits the literal. We do, however, need to decode JSX entities. - parts.push(ts.createLiteral(decodeEntities(part))); + // If we've seen any non-whitespace characters on this line, add the 'trim' of the line. + // (lastNonWhitespace === -1 is a special flag to detect whether the first line is all whitespace.) + if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) { + acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1)); } + // Reset firstNonWhitespace for the next line. + // Don't bother to reset lastNonWhitespace because we ignore it if firstNonWhitespace = -1. firstNonWhitespace = -1; } - else if (!ts.isWhiteSpace(c)) { + else if (!ts.isWhiteSpaceSingleLine(c)) { lastNonWhitespace = i; if (firstNonWhitespace === -1) { firstNonWhitespace = i; } } } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - if (!parts) { - parts = []; - } - // We do not escape the string here as that is handled by the printer - // when it emits the literal. We do, however, need to decode JSX entities. - parts.push(ts.createLiteral(decodeEntities(part))); - } - if (parts) { - return ts.reduceLeft(parts, aggregateJsxTextParts); - } - return undefined; + return firstNonWhitespace !== -1 + ? addLineOfJsxText(acc, text.substr(firstNonWhitespace)) + : acc; } - /** - * Aggregates two expressions by interpolating them with a whitespace literal. - */ - function aggregateJsxTextParts(left, right) { - return ts.createAdd(ts.createAdd(left, ts.createLiteral(" ")), right); + function addLineOfJsxText(acc, trimmedLine) { + // We do not escape the string here as that is handled by the printer + // when it emits the literal. We do, however, need to decode JSX entities. + var decoded = decodeEntities(trimmedLine); + return acc === undefined ? decoded : acc + " " + decoded; } /** * Replace entities like " ", "{", and "�" with the characters they encode. @@ -48510,7 +50190,7 @@ var ts; return String.fromCharCode(parseInt(hex, 16)); } else { - var ch = entities[word]; + var ch = entities.get(word); // If this is not a valid entity, then just use `match` (replace it with itself, i.e. don't replace) return ch ? String.fromCharCode(ch) : match; } @@ -48522,16 +50202,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 246 /* JsxElement */) { + if (node.kind === 248 /* JsxElement */) { return getTagName(node.openingElement); } else { - var name_35 = node.tagName; - if (ts.isIdentifier(name_35) && ts.isIntrinsicJsxName(name_35.text)) { - return ts.createLiteral(name_35.text); + var name = node.tagName; + if (ts.isIdentifier(name) && ts.isIntrinsicJsxName(name.text)) { + return ts.createLiteral(name.text); } else { - return ts.createExpressionFromEntityName(name_35); + return ts.createExpressionFromEntityName(name); } } } @@ -48554,7 +50234,7 @@ var ts; } } ts.transformJsx = transformJsx; - var entities = ts.createMap({ + var entities = ts.createMapFromTemplate({ "quot": 0x0022, "amp": 0x0026, "apos": 0x0027, @@ -48862,19 +50542,19 @@ var ts; case 119 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: // ES2017 'await' expressions must be transformed for targets < ES2017. return visitAwaitExpression(node); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: // ES2017 method declarations may be 'async' return visitMethodDeclaration(node); - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: // ES2017 function declarations may be 'async' return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: // ES2017 function expressions may be 'async' return visitFunctionExpression(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: // ES2017 arrow functions may be 'async' return visitArrowFunction(node); default: @@ -48889,9 +50569,8 @@ var ts; * @param node The node to visit. */ function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield( - /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression), - /*location*/ node), node); + return ts.setOriginalNode(ts.setTextRange(ts.createYield( + /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); } /** * Visits a MethodDeclaration node. @@ -48964,7 +50643,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 185 /* ArrowFunction */; + var isArrowFunction = node.kind === 186 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current @@ -48976,7 +50655,8 @@ var ts; var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(statements, /*location*/ node.body, /*multiLine*/ true); + var block = ts.createBlock(statements, /*multiLine*/ true); + ts.setTextRange(block, node.body); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. if (languageVersion >= 2 /* ES2015 */) { @@ -48996,7 +50676,7 @@ var ts; var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); - return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(block.statements, declarations), block.statements)); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); } return expression; } @@ -49009,7 +50689,7 @@ var ts; startLexicalEnvironment(); var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); var declarations = endLexicalEnvironment(); - return ts.updateBlock(visited, ts.createNodeArray(ts.concatenate(visited.statements, declarations), visited.statements)); + return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); } } function getPromiseConstructor(type) { @@ -49028,24 +50708,24 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(179 /* CallExpression */); - context.enableSubstitution(177 /* PropertyAccessExpression */); - context.enableSubstitution(178 /* ElementAccessExpression */); + context.enableSubstitution(180 /* CallExpression */); + context.enableSubstitution(178 /* PropertyAccessExpression */); + context.enableSubstitution(179 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(226 /* ClassDeclaration */); - context.enableEmitNotification(149 /* MethodDeclaration */); - context.enableEmitNotification(151 /* GetAccessor */); - context.enableEmitNotification(152 /* SetAccessor */); - context.enableEmitNotification(150 /* Constructor */); + context.enableEmitNotification(228 /* ClassDeclaration */); + context.enableEmitNotification(150 /* MethodDeclaration */); + context.enableEmitNotification(152 /* GetAccessor */); + context.enableEmitNotification(153 /* SetAccessor */); + context.enableEmitNotification(151 /* Constructor */); } } function substituteExpression(node) { switch (node.kind) { - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) { return substituteCallExpression(node); } @@ -49089,53 +50769,53 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 226 /* ClassDeclaration */ - || kind === 150 /* Constructor */ - || kind === 149 /* MethodDeclaration */ - || kind === 151 /* GetAccessor */ - || kind === 152 /* SetAccessor */; + return kind === 228 /* ClassDeclaration */ + || kind === 151 /* Constructor */ + || kind === 150 /* MethodDeclaration */ + || kind === 152 /* GetAccessor */ + || kind === 153 /* SetAccessor */; } /** * Hook for node emit. * + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ - function onEmitNode(emitContext, node, emitCallback) { + function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { var savedCurrentSuperContainer = currentSuperContainer; currentSuperContainer = node; - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSuperContainer = savedCurrentSuperContainer; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } /** * Hooks node substitutions. * + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */) { return substituteExpression(node); } return node; } function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { if (flags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression]), "value", location); + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } else { - return ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression], location); + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), location); } } function getSuperContainerAsyncMethodFlags() { @@ -49198,7 +50878,7 @@ var ts; return node; } switch (node.kind) { - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -49223,25 +50903,21 @@ var ts; // Transforms `a[x] **= b` into `(_a = a)[_x = x] = Math.pow(_a[_x], b)` var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createElementAccess(ts.createAssignment(expressionTemp, left.expression, /*location*/ left.expression), ts.createAssignment(argumentExpressionTemp, left.argumentExpression, /*location*/ left.argumentExpression), - /*location*/ left); - value = ts.createElementAccess(expressionTemp, argumentExpressionTemp, - /*location*/ left); + target = ts.setTextRange(ts.createElementAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), ts.setTextRange(ts.createAssignment(argumentExpressionTemp, left.argumentExpression), left.argumentExpression)), left); + value = ts.setTextRange(ts.createElementAccess(expressionTemp, argumentExpressionTemp), left); } else if (ts.isPropertyAccessExpression(left)) { // Transforms `a.x **= b` into `(_a = a).x = Math.pow(_a.x, b)` var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createPropertyAccess(ts.createAssignment(expressionTemp, left.expression, /*location*/ left.expression), left.name, - /*location*/ left); - value = ts.createPropertyAccess(expressionTemp, left.name, - /*location*/ left); + target = ts.setTextRange(ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), left.name), left); + value = ts.setTextRange(ts.createPropertyAccess(expressionTemp, left.name), left); } else { // Transforms `a **= b` into `a = Math.pow(a, b)` target = left; value = left; } - return ts.createAssignment(target, ts.createMathPow(value, right, /*location*/ node), /*location*/ node); + return ts.setTextRange(ts.createAssignment(target, ts.createMathPow(value, right, /*location*/ node)), node); } function visitExponentiationExpression(node) { // Transforms `a ** b` into `Math.pow(a, b)` @@ -49299,6 +50975,82 @@ var ts; */ SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; })(SuperCaptureResult || (SuperCaptureResult = {})); + // Facts we track as we traverse the tree + var HierarchyFacts; + (function (HierarchyFacts) { + HierarchyFacts[HierarchyFacts["None"] = 0] = "None"; + // + // Ancestor facts + // + HierarchyFacts[HierarchyFacts["Function"] = 1] = "Function"; + HierarchyFacts[HierarchyFacts["ArrowFunction"] = 2] = "ArrowFunction"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBody"] = 4] = "AsyncFunctionBody"; + HierarchyFacts[HierarchyFacts["NonStaticClassElement"] = 8] = "NonStaticClassElement"; + HierarchyFacts[HierarchyFacts["CapturesThis"] = 16] = "CapturesThis"; + HierarchyFacts[HierarchyFacts["ExportedVariableStatement"] = 32] = "ExportedVariableStatement"; + HierarchyFacts[HierarchyFacts["TopLevel"] = 64] = "TopLevel"; + HierarchyFacts[HierarchyFacts["Block"] = 128] = "Block"; + HierarchyFacts[HierarchyFacts["IterationStatement"] = 256] = "IterationStatement"; + HierarchyFacts[HierarchyFacts["IterationStatementBlock"] = 512] = "IterationStatementBlock"; + HierarchyFacts[HierarchyFacts["ForStatement"] = 1024] = "ForStatement"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 2048] = "ForInOrForOfStatement"; + HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 4096] = "ConstructorWithCapturedSuper"; + HierarchyFacts[HierarchyFacts["ComputedPropertyName"] = 8192] = "ComputedPropertyName"; + // NOTE: do not add more ancestor flags without also updating AncestorFactsMask below. + // + // Ancestor masks + // + HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 16383] = "AncestorFactsMask"; + // We are always in *some* kind of block scope, but only specific block-scope containers are + // top-level or Blocks. + HierarchyFacts[HierarchyFacts["BlockScopeIncludes"] = 0] = "BlockScopeIncludes"; + HierarchyFacts[HierarchyFacts["BlockScopeExcludes"] = 4032] = "BlockScopeExcludes"; + // A source file is a top-level block scope. + HierarchyFacts[HierarchyFacts["SourceFileIncludes"] = 64] = "SourceFileIncludes"; + HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 3968] = "SourceFileExcludes"; + // Functions, methods, and accessors are both new lexical scopes and new block scopes. + HierarchyFacts[HierarchyFacts["FunctionIncludes"] = 65] = "FunctionIncludes"; + HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 16286] = "FunctionExcludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyIncludes"] = 69] = "AsyncFunctionBodyIncludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 16278] = "AsyncFunctionBodyExcludes"; + // Arrow functions are lexically scoped to their container, but are new block scopes. + HierarchyFacts[HierarchyFacts["ArrowFunctionIncludes"] = 66] = "ArrowFunctionIncludes"; + HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 16256] = "ArrowFunctionExcludes"; + // Constructors are both new lexical scopes and new block scopes. Constructors are also + // always considered non-static members of a class. + HierarchyFacts[HierarchyFacts["ConstructorIncludes"] = 73] = "ConstructorIncludes"; + HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 16278] = "ConstructorExcludes"; + // 'do' and 'while' statements are not block scopes. We track that the subtree is contained + // within an IterationStatement to indicate whether the embedded statement is an + // IterationStatementBlock. + HierarchyFacts[HierarchyFacts["DoOrWhileStatementIncludes"] = 256] = "DoOrWhileStatementIncludes"; + HierarchyFacts[HierarchyFacts["DoOrWhileStatementExcludes"] = 0] = "DoOrWhileStatementExcludes"; + // 'for' statements are new block scopes and have special handling for 'let' declarations. + HierarchyFacts[HierarchyFacts["ForStatementIncludes"] = 1280] = "ForStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForStatementExcludes"] = 3008] = "ForStatementExcludes"; + // 'for-in' and 'for-of' statements are new block scopes and have special handling for + // 'let' declarations. + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementIncludes"] = 2304] = "ForInOrForOfStatementIncludes"; + HierarchyFacts[HierarchyFacts["ForInOrForOfStatementExcludes"] = 1984] = "ForInOrForOfStatementExcludes"; + // Blocks (other than function bodies) are new block scopes. + HierarchyFacts[HierarchyFacts["BlockIncludes"] = 128] = "BlockIncludes"; + HierarchyFacts[HierarchyFacts["BlockExcludes"] = 3904] = "BlockExcludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockIncludes"] = 512] = "IterationStatementBlockIncludes"; + HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 4032] = "IterationStatementBlockExcludes"; + // Computed property names track subtree flags differently than their containing members. + HierarchyFacts[HierarchyFacts["ComputedPropertyNameIncludes"] = 8192] = "ComputedPropertyNameIncludes"; + HierarchyFacts[HierarchyFacts["ComputedPropertyNameExcludes"] = 0] = "ComputedPropertyNameExcludes"; + // + // Subtree facts + // + HierarchyFacts[HierarchyFacts["NewTarget"] = 16384] = "NewTarget"; + HierarchyFacts[HierarchyFacts["NewTargetInComputedPropertyName"] = 32768] = "NewTargetInComputedPropertyName"; + // + // Subtree masks + // + HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -16384] = "SubtreeFactsMask"; + HierarchyFacts[HierarchyFacts["PropagateNewTargetMask"] = 49152] = "PropagateNewTargetMask"; + })(HierarchyFacts || (HierarchyFacts = {})); function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -49308,15 +51060,7 @@ var ts; context.onSubstituteNode = onSubstituteNode; var currentSourceFile; var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - var isInConstructorWithCapturedSuper; + var hierarchyFacts; /** * Used to track if we are emitting body of the converted loop */ @@ -49334,257 +51078,216 @@ var ts; } currentSourceFile = node; currentText = node.text; - var visited = saveStateAndInvoke(node, visitSourceFile); + var visited = visitSourceFile(node); ts.addEmitHelpers(visited, context.readEmitHelpers()); currentSourceFile = undefined; currentText = undefined; + hierarchyFacts = 0 /* None */; return visited; } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); + /** + * Sets the `HierarchyFacts` for this node prior to visiting this node's subtree, returning the facts set prior to modification. + * @param excludeFacts The existing `HierarchyFacts` to reset before visiting the subtree. + * @param includeFacts The new `HierarchyFacts` to set before visiting the subtree. + **/ + function enterSubtree(excludeFacts, includeFacts) { + var ancestorFacts = hierarchyFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383 /* AncestorFactsMask */; + return ancestorFacts; } - function dispatcher(node) { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - function saveStateAndInvoke(node, f) { - var savedEnclosingFunction = enclosingFunction; - var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - var savedEnclosingVariableStatement = enclosingVariableStatement; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var savedConvertedLoopState = convertedLoopState; - var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - // don't treat content of nodes that start new lexical environment as part of converted loop copy or constructor body - isInConstructorWithCapturedSuper = false; - convertedLoopState = undefined; - } - onBeforeVisitNode(node); - var visited = f(node); - isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 185 /* ArrowFunction */) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 131072 /* AsyncFunctionBody */)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - // keep track of the enclosing variable statement when in the context of - // variable statements, variable declarations, binding elements, and binding - // patterns. - switch (currentNode.kind) { - case 205 /* VariableStatement */: - enclosingVariableStatement = currentNode; - break; - case 224 /* VariableDeclarationList */: - case 223 /* VariableDeclaration */: - case 174 /* BindingElement */: - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - function returnCapturedThis(node) { - return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + /** + * Restores the `HierarchyFacts` for this node's ancestor after visiting this node's + * subtree, propagating specific facts from the subtree. + * @param ancestorFacts The `HierarchyFacts` of the ancestor to restore after visiting the subtree. + * @param excludeFacts The existing `HierarchyFacts` of the subtree that should not be propagated. + * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. + **/ + function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 /* SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 216 /* ReturnStatement */ && !node.expression; + return hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ + && node.kind === 218 /* ReturnStatement */ + && !node.expression; } - function shouldCheckNode(node) { - return (node.transformFlags & 64 /* ES2015 */) !== 0 || - node.kind === 219 /* LabeledStatement */ || - (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); + function shouldVisitNode(node) { + return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 + || convertedLoopState !== undefined + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && ts.isStatement(node)) + || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); } - function visitorWorker(node) { - if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { - return returnCapturedThis(node); - } - else if (shouldCheckNode(node)) { + function visitor(node) { + if (shouldVisitNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128 /* ContainsES2015 */ || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { - // we want to dive in this branch either if node has children with ES2015 specific syntax - // or we are inside constructor that captures result of the super call so all returns without expression should be - // rewritten. Note: we skip expressions since returns should never appear there - return ts.visitEachChild(node, visitor, context); - } else { return node; } } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); + function functionBodyVisitor(node) { + if (shouldVisitNode(node)) { + return visitBlock(node, /*isFunctionBody*/ true); } - else { - result = visitNodesInConvertedLoop(node); - } - return result; + return node; } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 216 /* ReturnStatement */: - node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; - return visitReturnStatement(node); - case 205 /* VariableStatement */: - return visitVariableStatement(node); - case 218 /* SwitchStatement */: - return visitSwitchStatement(node); - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: - return visitBreakOrContinueStatement(node); - case 98 /* ThisKeyword */: - return visitThisKeyword(node); - case 70 /* Identifier */: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); + function callExpressionVisitor(node) { + if (node.kind === 96 /* SuperKeyword */) { + return visitSuperKeyword(/*isExpressionOfCall*/ true); } + return visitor(node); } function visitJavaScript(node) { switch (node.kind) { case 114 /* StaticKeyword */: return undefined; // elide static keyword - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return visitClassDeclaration(node); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return visitClassExpression(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return visitParameter(node); - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return visitArrowFunction(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return visitFunctionExpression(node); - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return visitVariableDeclaration(node); case 70 /* Identifier */: return visitIdentifier(node); - case 224 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 219 /* LabeledStatement */: + case 220 /* SwitchStatement */: + return visitSwitchStatement(node); + case 234 /* CaseBlock */: + return visitCaseBlock(node); + case 206 /* Block */: + return visitBlock(node, /*isFunctionBody*/ false); + case 217 /* BreakStatement */: + case 216 /* ContinueStatement */: + return visitBreakOrContinueStatement(node); + case 221 /* LabeledStatement */: return visitLabeledStatement(node); - case 209 /* DoStatement */: - return visitDoStatement(node); - case 210 /* WhileStatement */: - return visitWhileStatement(node); - case 211 /* ForStatement */: - return visitForStatement(node); - case 212 /* ForInStatement */: - return visitForInStatement(node); - case 213 /* ForOfStatement */: - return visitForOfStatement(node); - case 207 /* ExpressionStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); + case 213 /* ForStatement */: + return visitForStatement(node, /*outermostLabeledStatement*/ undefined); + case 214 /* ForInStatement */: + return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); + case 215 /* ForOfStatement */: + return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); + case 209 /* ExpressionStatement */: return visitExpressionStatement(node); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return visitCatchClause(node); - case 258 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 175 /* ArrayLiteralExpression */: + case 143 /* ComputedPropertyName */: + return visitComputedPropertyName(node); + case 176 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return visitCallExpression(node); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return visitNewExpression(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 12 /* NoSubstitutionTemplateLiteral */: case 13 /* TemplateHead */: case 14 /* TemplateMiddle */: case 15 /* TemplateTail */: return visitTemplateLiteral(node); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return visitTemplateExpression(node); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return visitYieldExpression(node); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return visitSpreadElement(node); case 96 /* SuperKeyword */: - return visitSuperKeyword(); - case 195 /* YieldExpression */: - // `yield` will be handled by a generators transform. - return ts.visitEachChild(node, visitor, context); - case 149 /* MethodDeclaration */: + return visitSuperKeyword(/*isExpressionOfCall*/ false); + case 98 /* ThisKeyword */: + return visitThisKeyword(node); + case 203 /* MetaProperty */: + return visitMetaProperty(node); + case 150 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 205 /* VariableStatement */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + return visitAccessorDeclaration(node); + case 207 /* VariableStatement */: return visitVariableStatement(node); + case 218 /* ReturnStatement */: + return visitReturnStatement(node); default: - ts.Debug.failBadSyntaxKind(node); return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { + var ancestorFacts = enterSubtree(3968 /* SourceFileExcludes */, 64 /* SourceFileIncludes */); var statements = []; startLexicalEnvironment(); var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ false, visitor); addCaptureThisForNodeIfNeeded(statements, node); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } function visitSwitchStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; - var result = ts.visitEachChild(node, visitor, context); - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; + if (convertedLoopState !== undefined) { + var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + // for switch statement allow only non-labeled break + convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + var result = ts.visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + return ts.visitEachChild(node, visitor, context); + } + function visitCaseBlock(node) { + var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; + } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function visitReturnStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - convertedLoopState.nonLocalJumps |= 8 /* Return */; - return ts.createReturn(ts.createObjectLiteral([ - ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression - ? ts.visitNode(node.expression, visitor, ts.isExpression) - : ts.createVoidZero()) - ])); + if (convertedLoopState) { + convertedLoopState.nonLocalJumps |= 8 /* Return */; + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + node = returnCapturedThis(node); + } + return ts.createReturn(ts.createObjectLiteral([ + ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression + ? ts.visitNode(node.expression, visitor, ts.isExpression) + : ts.createVoidZero()) + ])); + } + else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 185 /* ArrowFunction */) { - // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. - convertedLoopState.containsLexicalThis = true; - return node; + if (convertedLoopState) { + if (hierarchyFacts & 2 /* ArrowFunction */) { + // if the enclosing function is an ArrowFunction then we use the captured 'this' keyword. + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + return node; } function visitIdentifier(node) { if (!convertedLoopState) { @@ -49593,7 +51296,7 @@ var ts; if (ts.isGeneratedIdentifier(node)) { return node; } - if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + if (node.text !== "arguments" || !resolver.isArgumentsLocalBinding(node)) { return node; } return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); @@ -49604,13 +51307,13 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 215 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; - var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + var jump = node.kind === 217 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(node.label.text)) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 215 /* BreakStatement */) { + if (node.kind === 217 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -49621,7 +51324,7 @@ var ts; } } else { - if (node.kind === 215 /* BreakStatement */) { + if (node.kind === 217 /* BreakStatement */) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); } @@ -49669,8 +51372,9 @@ var ts; /*type*/ undefined, transformClassLikeDeclarationToExpression(node)); ts.setOriginalNode(variable, node); var statements = []; - var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([variable]), /*location*/ node); + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([variable])); ts.setOriginalNode(statement, node); + ts.setTextRange(statement, node); ts.startOnNewLine(statement); statements.push(statement); // Add an `export default` statement for default exports (for `--target es5 --module es6`) @@ -49788,7 +51492,7 @@ var ts; ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); statements.push(statement); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ node.members), /*location*/ undefined, /*multiLine*/ true); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); ts.setEmitFlags(block, 1536 /* NoComments */); return block; } @@ -49801,7 +51505,7 @@ var ts; */ function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node)), + statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node))), /*location*/ extendsClauseElement)); } } @@ -49813,6 +51517,9 @@ var ts; * @param extendsClauseElement The expression for the class `extends` clause. */ function addConstructor(statements, node, extendsClauseElement) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16278 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = ts.createFunctionDeclaration( @@ -49820,12 +51527,14 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, ts.getDeclarationName(node), /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), - /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), - /*location*/ constructor || node); + /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); + ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); } statements.push(constructorFunction); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; } /** * Transforms the parameters of the constructor declaration of a class. @@ -49871,30 +51580,35 @@ var ts; addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + // determine whether the class is known syntactically to be a derived class (e.g. a + // class that extends a value that is not syntactically known to be `null`). + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94 /* NullKeyword */; + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); // The last statement expression was replaced. Skip it. if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { - isInConstructorWithCapturedSuper = superCaptureStatus === 1 /* ReplaceSuperCapture */; - return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); - }); - ts.addRange(statements, body); + if (superCaptureStatus === 1 /* ReplaceSuperCapture */) { + hierarchyFacts |= 4096 /* ConstructorWithCapturedSuper */; + } + ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset)); } // Return `_this` unless we're sure enough that it would be pointless to add a return statement. // If there's a constructor that we can tell returns in enough places, then we *do not* want to add a return. - if (extendsClauseElement + if (isDerivedClass && superCaptureStatus !== 2 /* ReplaceWithReturn */ && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createIdentifier("_this"))); } ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, + if (constructor) { + prependCaptureNewTargetIfNeeded(statements, constructor, /*copyOnWrite*/ false); + } + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ constructor ? constructor.body.statements : node.members), - /*location*/ constructor ? constructor.body : node, /*multiLine*/ true); + ts.setTextRange(block, constructor ? constructor.body : node); if (!constructor) { ts.setEmitFlags(block, 1536 /* NoComments */); } @@ -49907,17 +51621,17 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 216 /* ReturnStatement */) { + if (statement.kind === 218 /* ReturnStatement */) { return true; } - else if (statement.kind === 208 /* IfStatement */) { + else if (statement.kind === 210 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 204 /* Block */) { + else if (statement.kind === 206 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -49930,9 +51644,9 @@ var ts; * * @returns The new statement offset into the `statements` array. */ - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, isDerivedClass, hasSynthesizedSuper, statementOffset) { // If this isn't a derived class, just capture 'this' for arrow functions if necessary. - if (!hasExtendsClause) { + if (!isDerivedClass) { if (ctor) { addCaptureThisForNodeIfNeeded(statements, ctor); } @@ -49975,9 +51689,8 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + if (firstStatement.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } // Return the result if we have an immediate super() call on the last statement, @@ -49986,8 +51699,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 /* ContainsLexicalThis */ | 32768 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 192 /* BinaryExpression */ - || superCallExpression.left.kind !== 179 /* CallExpression */) { + if (superCallExpression.kind !== 193 /* BinaryExpression */ + || superCallExpression.left.kind !== 180 /* CallExpression */) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } // Shift comments from the original super call to the return statement. @@ -49996,18 +51709,18 @@ var ts; return 2 /* ReplaceWithReturn */; } // Perform the capture. - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement); // If we're actually replacing the original statement, we need to signal this to the caller. if (superCallExpression) { return 1 /* ReplaceSuperCapture */; } return 0 /* NoReplacement */; } + function createActualThis() { + return ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */); + } function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); + return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createIdentifier("_super"), ts.createNull()), ts.createFunctionApply(ts.createIdentifier("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis()); } /** * Visits a parameter declaration. @@ -50022,25 +51735,25 @@ var ts; else if (ts.isBindingPattern(node.name)) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. - return ts.setOriginalNode(ts.createParameter( + return ts.setOriginalNode(ts.setTextRange(ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, ts.getGeneratedNameForNode(node), /*questionToken*/ undefined, /*type*/ undefined, - /*initializer*/ undefined, + /*initializer*/ undefined), /*location*/ node), /*original*/ node); } else if (node.initializer) { // Initializers are elided - return ts.setOriginalNode(ts.createParameter( + return ts.setOriginalNode(ts.setTextRange(ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, node.name, /*questionToken*/ undefined, /*type*/ undefined, - /*initializer*/ undefined, + /*initializer*/ undefined), /*location*/ node), /*original*/ node); } @@ -50070,17 +51783,17 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_36 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; // A rest parameter cannot have a binding pattern or an initializer, // so let's just ignore it. if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_36)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_36, initializer); + if (ts.isBindingPattern(name)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_36, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer); } } } @@ -50115,13 +51828,11 @@ var ts; */ function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer)), - /*location*/ parameter)) - ], /*location*/ parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */), - /*elseStatement*/ undefined, - /*location*/ parameter); + var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([ + ts.createStatement(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer))), parameter)) + ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */)); statement.startsOnNewLine = true; + ts.setTextRange(statement, parameter); ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 524288 /* CustomPrologue */); statements.push(statement); } @@ -50158,22 +51869,21 @@ var ts; var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); // var param = []; - statements.push(ts.setEmitFlags(ts.createVariableStatement( + statements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(declarationName, /*type*/ undefined, ts.createArrayLiteral([])) - ]), + ])), /*location*/ parameter), 524288 /* CustomPrologue */)); // for (var _i = restIndex; _i < arguments.length; _i++) { // param[_i - restIndex] = arguments[_i]; // } - var forStatement = ts.createFor(ts.createVariableDeclarationList([ + var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) - ], /*location*/ parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), - /*location*/ parameter), ts.createPostfixIncrement(temp, /*location*/ parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 + ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([ + ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp - : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), + : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), /*location*/ parameter)) ])); ts.setEmitFlags(forStatement, 524288 /* CustomPrologue */); @@ -50187,7 +51897,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 185 /* ArrowFunction */) { + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 186 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -50197,11 +51907,52 @@ var ts; /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration("_this", /*type*/ undefined, initializer) - ]), originalStatement); + ])); ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 524288 /* CustomPrologue */); + ts.setTextRange(captureThisStatement, originalStatement); ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } + function prependCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { + if (hierarchyFacts & 16384 /* NewTarget */) { + var newTarget = void 0; + switch (node.kind) { + case 186 /* ArrowFunction */: + return statements; + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + // Methods and accessors cannot be constructors, so 'new.target' will + // always return 'undefined'. + newTarget = ts.createVoidZero(); + break; + case 151 /* Constructor */: + // Class constructors can only be called with `new`, so `this.constructor` + // should be relatively safe to use. + newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); + break; + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + // Functions can be called or constructed, and may have a `this` due to + // being a member or when calling an imported function via `other_1.f()`. + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 92 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + var captureNewTargetStatement = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_newTarget", + /*type*/ undefined, newTarget) + ])); + if (copyOnWrite) { + return [captureNewTargetStatement].concat(statements); + } + statements.unshift(captureNewTargetStatement); + } + return statements; + } /** * Adds statements to the class body function for a class to define the members of the * class. @@ -50213,20 +51964,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 203 /* SemicolonClassElement */: + case 205 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 149 /* MethodDeclaration */: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + case 150 /* MethodDeclaration */: + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 150 /* Constructor */: + case 151 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -50241,7 +51992,7 @@ var ts; * @param member The SemicolonClassElement node. */ function transformSemicolonClassElementToStatement(member) { - return ts.createEmptyStatement(/*location*/ member); + return ts.setTextRange(ts.createEmptyStatement(), member); } /** * Transforms a MethodDeclaration into a statement for a class body function. @@ -50249,14 +52000,15 @@ var ts; * @param receiver The receiver for the member. * @param member The MethodDeclaration node. */ - function transformClassMethodDeclarationToStatement(receiver, member) { + function transformClassMethodDeclarationToStatement(receiver, member, container) { + var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); - var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined); + var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), + var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); @@ -50264,6 +52016,7 @@ var ts; // No source map should be emitted for this statement to align with the // old emitter. ts.setEmitFlags(statement, 48 /* NoSourceMap */); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 16384 /* NewTarget */ : 0 /* None */); return statement; } /** @@ -50272,13 +52025,13 @@ var ts; * @param receiver The receiver for the member. * @param accessors The set of related get/set accessors. */ - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, /*startsOnNewLine*/ false), - /*location*/ ts.getSourceMapRange(accessors.firstAccessor)); + function transformAccessorsToStatement(receiver, accessors, container) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false)); // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } /** @@ -50287,8 +52040,9 @@ var ts; * * @param receiver The receiver for the member. */ - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); // To align with source maps in the old emitter, the receiver and property name // arguments are both mapped contiguously to the accessor name. var target = ts.getMutableClone(receiver); @@ -50299,7 +52053,7 @@ var ts; ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined); + var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); var getter = ts.createPropertyAssignment("get", getterFunction); @@ -50307,23 +52061,24 @@ var ts; properties.push(getter); } if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined); + var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); var setter = ts.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } - properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); + properties.push(ts.createPropertyAssignment("enumerable", ts.createTrue()), ts.createPropertyAssignment("configurable", ts.createTrue())); var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ target, propertyName, - ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true) + ts.createObjectLiteral(properties, /*multiLine*/ true) ]); if (startsOnNewLine) { call.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 16384 /* NewTarget */ : 0 /* None */); return call; } /** @@ -50335,14 +52090,20 @@ var ts; if (node.transformFlags & 16384 /* ContainsLexicalThis */) { enableSubstitutionsForCapturedThis(); } + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16256 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */); var func = ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformFunctionBody(node), node); + /*type*/ undefined, transformFunctionBody(node)); + ts.setTextRange(func, node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8 /* CapturesThis */); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; return func; } /** @@ -50351,12 +52112,24 @@ var ts; * @param node a FunctionExpression node. */ function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, - /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.transformFlags & 64 /* ES2015 */ + var ancestorFacts = ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */ + ? enterSubtree(16278 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) + : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 /* ES2015 */ ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 /* NewTarget */ + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionExpression(node, + /*modifiers*/ undefined, name, + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body); } /** * Visits a FunctionDeclaration node. @@ -50364,12 +52137,22 @@ var ts; * @param node a FunctionDeclaration node. */ function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, - /*decorators*/ undefined, node.modifiers, node.name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.transformFlags & 64 /* ES2015 */ + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = node.transformFlags & 64 /* ES2015 */ ? transformFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); + : visitFunctionBodyDownLevel(node); + var name = hierarchyFacts & 16384 /* NewTarget */ + ? ts.getLocalName(node) + : node.name; + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return ts.updateFunctionDeclaration(node, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body); } /** * Transforms a function-like node into a FunctionExpression. @@ -50378,18 +52161,24 @@ var ts; * @param location The source-map location for the new FunctionExpression. * @param name The name of the new FunctionExpression. */ - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 185 /* ArrowFunction */) { - enclosingNonArrowFunction = node; + function transformFunctionLikeToExpression(node, location, name, container) { + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32 /* Static */) + ? enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */) + : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 227 /* FunctionDeclaration */ || node.kind === 185 /* FunctionExpression */)) { + name = ts.getGeneratedNameForNode(node); } - var expression = ts.setOriginalNode(ts.createFunctionExpression( + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, saveStateAndInvoke(node, transformFunctionBody), location), + /*typeParameters*/ undefined, parameters, + /*type*/ undefined, body), location), /*original*/ node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; } /** * Transforms the body of a function-like node. @@ -50426,7 +52215,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 185 /* ArrowFunction */); + ts.Debug.assert(node.kind === 186 /* ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -50442,7 +52231,8 @@ var ts; } } var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, /*location*/ body); + var returnStatement = ts.createReturn(expression); + ts.setTextRange(returnStatement, body); ts.setEmitFlags(returnStatement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1024 /* NoTrailingComments */); statements.push(returnStatement); // To align with the source map emit for the old emitter, we set a custom @@ -50451,11 +52241,13 @@ var ts; } var lexicalEnvironment = context.endLexicalEnvironment(); ts.addRange(statements, lexicalEnvironment); + prependCaptureNewTargetIfNeeded(statements, node, /*copyOnWrite*/ false); // If we added any final generated statements, this must be a multi-line block if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); + var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), multiLine); + ts.setTextRange(block, node.body); if (!multiLine && singleLine) { ts.setEmitFlags(block, 1 /* SingleLine */); } @@ -50465,6 +52257,23 @@ var ts; ts.setOriginalNode(block, node.body); return block; } + function visitFunctionBodyDownLevel(node) { + var updated = ts.visitFunctionBody(node.body, functionBodyVisitor, context); + return ts.updateBlock(updated, ts.setTextRange(ts.createNodeArray(prependCaptureNewTargetIfNeeded(updated.statements, node, /*copyOnWrite*/ true)), + /*location*/ updated.statements)); + } + function visitBlock(node, isFunctionBody) { + if (isFunctionBody) { + // A function body is not a block scope. + return ts.visitEachChild(node, visitor, context); + } + var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */ + ? enterSubtree(4032 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */) + : enterSubtree(3904 /* BlockExcludes */, 128 /* BlockIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; + } /** * Visits an ExpressionStatement that contains a destructuring assignment. * @@ -50473,9 +52282,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -50491,9 +52300,9 @@ var ts; // If we are here it is most likely because our expression is a destructuring assignment. if (!needsDestructuringValue) { switch (node.expression.kind) { - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -50511,9 +52320,12 @@ var ts; if (ts.isDestructuringAssignment(node)) { return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, needsDestructuringValue); } + return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) == 0) { + var ancestorFacts = enterSubtree(0 /* None */, ts.hasModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + var updated; + if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0) { // we are inside a converted loop - hoist variable declarations var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -50531,14 +52343,18 @@ var ts; } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); }), node); + updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); })), node); } else { // none of declarations has initializer - the entire variable statement can be deleted - return undefined; + updated = undefined; } } - return ts.visitEachChild(node, visitor, context); + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; } /** * Visits a VariableDeclarationList that is block scoped (e.g. `let` or `const`). @@ -50546,25 +52362,29 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */) { - enableSubstitutionsForBlockScopedBindings(); + if (node.transformFlags & 64 /* ES2015 */) { + if (node.flags & 3 /* BlockScoped */) { + enableSubstitutionsForBlockScopedBindings(); + } + var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 /* Let */ + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + var declarationList = ts.createVariableDeclarationList(declarations); + ts.setOriginalNode(declarationList, node); + ts.setTextRange(declarationList, node); + ts.setCommentRange(declarationList, node); + if (node.transformFlags & 8388608 /* ContainsBindingPattern */ + && (ts.isBindingPattern(node.declarations[0].name) + || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + // If the first or last declaration is a binding pattern, we need to modify + // the source map range for the declaration list. + var firstDeclaration = ts.firstOrUndefined(declarations); + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } + return declarationList; } - var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 /* Let */ - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); - ts.setOriginalNode(declarationList, node); - ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 /* ContainsBindingPattern */ - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { - // If the first or last declaration is a binding pattern, we need to modify - // the source map range for the declaration list. - var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - } - return declarationList; + return ts.visitEachChild(node, visitor, context); } /** * Gets a value indicating whether we should emit an explicit initializer for a variable @@ -50615,18 +52435,16 @@ var ts; var flags = resolver.getNodeCheckFlags(node); var isCapturedInFunction = flags & 131072 /* CapturedBlockScopedBinding */; var isDeclaredInLoop = flags & 262144 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + var emittedAsTopLevel = (hierarchyFacts & 64 /* TopLevel */) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); + && (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 212 /* ForInStatement */ - && enclosingBlockScopeContainer.kind !== 213 /* ForOfStatement */ + && (hierarchyFacts & 2048 /* ForInOrForOfStatement */) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, /*lookInLabeledStatements*/ false))); + && (hierarchyFacts & (1024 /* ForStatement */ | 2048 /* ForInOrForOfStatement */)) === 0)); return emitExplicitInitializer; } /** @@ -50655,55 +52473,52 @@ var ts; * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { - // If we are here it is because the name contains a binding pattern. + var ancestorFacts = enterSubtree(32 /* ExportedVariableStatement */, 0 /* None */); + var updated; if (ts.isBindingPattern(node.name)) { - var hoistTempVariables = enclosingVariableStatement - && ts.hasModifier(enclosingVariableStatement, 1 /* Export */); - return ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, - /*value*/ undefined, hoistTempVariables); - } - return ts.visitEachChild(node, visitor, context); - } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; - } - var result; - if (ts.isIterationStatement(node.statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, + /*value*/ undefined, (ancestorFacts & 32 /* ExportedVariableStatement */) !== 0); } else { - result = ts.visitEachChild(node, visitor, context); + updated = ts.visitEachChild(node, visitor, context); } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; + } + function recordLabel(node) { + convertedLoopState.labels.set(node.label.text, node.label.text); + } + function resetLabel(node) { + convertedLoopState.labels.set(node.label.text, undefined); + } + function visitLabeledStatement(node) { + if (convertedLoopState && !convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); } - return result; + var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(statement) + ? visitIterationStatement(statement, /*outermostLabeledStatement*/ node) + : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { + var ancestorFacts = enterSubtree(excludeFacts, includeFacts); + var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitDoOrWhileStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 256 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement); } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(3008 /* ForStatementExcludes */, 1280 /* ForStatementIncludes */, node, outermostLabeledStatement); } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitForInStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } - /** - * Visits a ForOfStatement and converts it into a compatible ForStatement. - * - * @param node A ForOfStatement. - */ - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function visitForOfStatement(node, outermostLabeledStatement) { + return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, convertForOfToFor); } - function convertForOfToFor(node, convertedLoopBodyStatements) { + function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { // The following ES6 code: // // for (let v of expr) { } @@ -50734,7 +52549,7 @@ var ts; // we don't want to emit a temporary variable for the RHS, just use it directly. var counter = ts.createLoopVariable(); var rhsReference = expression.kind === 70 /* Identifier */ - ? ts.createUniqueName(expression.text) + ? ts.createUniqueName(ts.unescapeIdentifier(expression.text)) : ts.createTempVariable(/*recordTempVariable*/ undefined); var elementAccess = ts.createElementAccess(rhsReference, counter); // Initialize LHS @@ -50748,8 +52563,9 @@ var ts; // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, elementAccess); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ initializer); + var declarationList = ts.createVariableDeclarationList(declarations); ts.setOriginalNode(declarationList, initializer); + ts.setTextRange(declarationList, initializer); // Adjust the source map range for the first declaration to align with the old // emitter. var firstDeclaration = declarations[0]; @@ -50761,12 +52577,11 @@ var ts; else { // The following call does not include the initializer, so we have // to emit it separately. - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.setOriginalNode(ts.createVariableDeclarationList([ + statements.push(ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), /*type*/ undefined, ts.createElementAccess(rhsReference, counter)) - ], /*location*/ ts.moveRangePos(initializer, -1)), initializer), - /*location*/ ts.moveRangeEnd(initializer, -1))); + ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); } } else { @@ -50781,7 +52596,7 @@ var ts; // Currently there is not way to check that assignment is binary expression of destructing assignment // so we have to cast never type to binaryExpression assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, /*location*/ ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createStatement(assignment), ts.moveRangeEnd(initializer, -1))); } } var bodyLocation; @@ -50790,7 +52605,7 @@ var ts; ts.addRange(statements, convertedLoopBodyStatements); } else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + var statement = ts.visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, ts.liftToBlock); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -50804,18 +52619,30 @@ var ts; ts.setEmitFlags(expression, 48 /* NoSourceMap */ | ts.getEmitFlags(expression)); // The old emitter does not emit source maps for the block. // We add the location to preserve comments. - var body = ts.createBlock(ts.createNodeArray(statements, /*location*/ statementsLocation), - /*location*/ bodyLocation); + var body = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ statementsLocation)); + ts.setTextRange(body, bodyLocation); ts.setEmitFlags(body, 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); - var forStatement = ts.createFor(ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0), /*location*/ ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) - ], /*location*/ node.expression), 1048576 /* NoHoisting */), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), - /*location*/ node.expression), ts.createPostfixIncrement(counter, /*location*/ node.expression), body, - /*location*/ node); + var forStatement = ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)), + ts.setTextRange(ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression), node.expression) + ]), node.expression), 1048576 /* NoHoisting */), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), body); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); - return forStatement; + ts.setTextRange(forStatement, node); + return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); + } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 213 /* ForStatement */: + return visitForStatement(node, outermostLabeledStatement); + case 214 /* ForInStatement */: + return visitForInStatement(node, outermostLabeledStatement); + case 215 /* ForOfStatement */: + return visitForOfStatement(node, outermostLabeledStatement); + } } /** * Visits an ObjectLiteralExpression with computed propety names. @@ -50829,31 +52656,39 @@ var ts; // Find the first computed property. // Everything until that point can be emitted as part of the initial object literal. var numInitialProperties = numProperties; + var numInitialPropertiesWithoutYield = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 /* ContainsYield */ - || property.name.kind === 142 /* ComputedPropertyName */) { + if ((property.transformFlags & 16777216 /* ContainsYield */ && hierarchyFacts & 4 /* AsyncFunctionBody */) + && i < numInitialPropertiesWithoutYield) { + numInitialPropertiesWithoutYield = i; + } + if (property.name.kind === 143 /* ComputedPropertyName */) { numInitialProperties = i; break; } } - ts.Debug.assert(numInitialProperties !== numProperties); - // For computed properties, we need to create a unique handle to the object - // literal so we can modify it without risking internal assignments tainting the object. - var temp = ts.createTempVariable(hoistVariableDeclaration); - // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. - var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), - /*location*/ undefined, node.multiLine), 32768 /* Indented */)); - if (node.multiLine) { - assignment.startsOnNewLine = true; + if (numInitialProperties !== numProperties) { + if (numInitialPropertiesWithoutYield < numInitialProperties) { + numInitialProperties = numInitialPropertiesWithoutYield; + } + // For computed properties, we need to create a unique handle to the object + // literal so we can modify it without risking internal assignments tainting the object. + var temp = ts.createTempVariable(hoistVariableDeclaration); + // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. + var expressions = []; + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 32768 /* Indented */)); + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + expressions.push(assignment); + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + // We need to clone the temporary identifier so that we can write it on a + // new line + expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); + return ts.inlineExpressions(expressions); } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - // We need to clone the temporary identifier so that we can write it on a - // new line - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); + return ts.visitEachChild(node, visitor, context); } function shouldConvertIterationStatementBody(node) { return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; @@ -50880,7 +52715,7 @@ var ts; } } } - function convertIterationStatementBodyIfNecessary(node, convert) { + function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert) { if (!shouldConvertIterationStatementBody(node)) { var saveAllowedNonLabeledJumps = void 0; if (convertedLoopState) { @@ -50889,7 +52724,9 @@ var ts; saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; } - var result = convert ? convert(node, /*convertedLoopBodyStatements*/ undefined) : ts.visitEachChild(node, visitor, context); + var result = convert + ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined) + : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel); if (convertedLoopState) { convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } @@ -50898,11 +52735,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 224 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 226 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -50939,7 +52776,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -50949,13 +52786,15 @@ var ts; copyOutParameters(loopOutParameters, 1 /* ToOutParameter */, statements_4); } ts.addRange(statements_4, lexicalEnvironment); - loopBody = ts.createBlock(statements_4, /*location*/ undefined, /*multiline*/ true); + loopBody = ts.createBlock(statements_4, /*multiline*/ true); } - if (!ts.isBlock(loopBody)) { - loopBody = ts.createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); + if (ts.isBlock(loopBody)) { + loopBody.multiLine = true; } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 131072 /* AsyncFunctionBody */) !== 0 + else { + loopBody = ts.createBlock([loopBody], /*multiline*/ true); + } + var isAsyncBlockContainingAwait = hierarchyFacts & 4 /* AsyncFunctionBody */ && (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -51038,25 +52877,22 @@ var ts; var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); var loop; if (convert) { - loop = convert(node, convertedLoopBodyStatements); + loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); } else { - loop = ts.getMutableClone(node); + var clone_4 = ts.getMutableClone(node); // clean statement part - loop.statement = undefined; + clone_4.statement = undefined; // visit childnodes to transform initializer/condition/incrementor parts - loop = ts.visitEachChild(loop, visitor, context); + clone_4 = ts.visitEachChild(clone_4, visitor, context); // set loop statement - loop.statement = ts.createBlock(convertedLoopBodyStatements, - /*location*/ undefined, - /*multiline*/ true); + clone_4.statement = ts.createBlock(convertedLoopBodyStatements, /*multiline*/ true); // reset and re-aggregate the transform flags - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); + clone_4.transformFlags = 0; + ts.aggregateTransformFlags(clone_4); + loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } - statements.push(currentParent.kind === 219 /* LabeledStatement */ - ? ts.createLabel(currentParent.label, loop) - : loop); + statements.push(loop); return statements; } function copyOutParameter(outParam, copyDirection) { @@ -51119,26 +52955,25 @@ var ts; if (!state.labeledNonLocalBreaks) { state.labeledNonLocalBreaks = ts.createMap(); } - state.labeledNonLocalBreaks[labelText] = labelMarker; + state.labeledNonLocalBreaks.set(labelText, labelMarker); } else { if (!state.labeledNonLocalContinues) { state.labeledNonLocalContinues = ts.createMap(); } - state.labeledNonLocalContinues[labelText] = labelMarker; + state.labeledNonLocalContinues.set(labelText, labelMarker); } } function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { if (!table) { return; } - for (var labelText in table) { - var labelMarker = table[labelText]; + table.forEach(function (labelMarker, labelText) { var statements = []; // if there are no outer converted loop or outer label in question is located inside outer converted loop // then emit labeled break\continue // otherwise propagate pair 'label -> marker' to outer converted loop and emit 'return labelMarker' so outer loop can later decide what to do - if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { + if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) { var label = ts.createIdentifier(labelText); statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); } @@ -51147,7 +52982,7 @@ var ts; statements.push(ts.createReturn(loopResultName)); } caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); - } + }); } function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { var name = decl.name; @@ -51162,7 +52997,7 @@ var ts; else { loopParameters.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); if (resolver.getNodeCheckFlags(decl) & 2097152 /* NeedsLoopOutParameter */) { - var outParamName = ts.createUniqueName("out_" + name.text); + var outParamName = ts.createUniqueName("out_" + ts.unescapeIdentifier(name.text)); loopOutParameters.push({ originalName: name, outParamName: outParamName }); } } @@ -51182,22 +53017,22 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 257 /* PropertyAssignment */: + case 150 /* MethodDeclaration */: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); + break; + case 260 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 258 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 149 /* MethodDeclaration */: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); - break; default: ts.Debug.failBadSyntaxKind(node); break; @@ -51212,8 +53047,8 @@ var ts; * @param receiver The receiver for the assignment. */ function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), - /*location*/ property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -51227,8 +53062,8 @@ var ts; * @param receiver The receiver for the assignment. */ function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), - /*location*/ property); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name)); + ts.setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -51241,22 +53076,34 @@ var ts; * @param method The MethodDeclaration node. * @param receiver The receiver for the assignment. */ - function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined), - /*location*/ method); + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) { + var ancestorFacts = enterSubtree(0 /* None */, 0 /* None */); + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined, container)); + ts.setTextRange(expression, method); if (startsOnNewLine) { expression.startsOnNewLine = true; } + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 16384 /* NewTarget */ : 0 /* None */); return expression; } function visitCatchClause(node) { - ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); - var temp = ts.createTempVariable(undefined); - var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); - var list = ts.createVariableDeclarationList(vars, /*location*/ node.variableDeclaration, /*flags*/ node.variableDeclaration.flags); - var destructure = ts.createVariableStatement(undefined, list); - return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var updated; + if (ts.isBindingPattern(node.variableDeclaration.name)) { + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp); + ts.setTextRange(newVariableDeclaration, node.variableDeclaration); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); + var list = ts.createVariableDeclarationList(vars); + ts.setTextRange(list, node.variableDeclaration); + var destructure = ts.createVariableStatement(/*modifiers*/ undefined, list); + updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + else { + updated = ts.visitEachChild(node, visitor, context); + } + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return updated; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); @@ -51273,20 +53120,41 @@ var ts; // Methods on classes are handled in visitClassDeclaration/visitClassExpression. // Methods with computed property names are handled in visitObjectLiteralExpression. ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined); + var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); - return ts.createPropertyAssignment(node.name, functionExpression, + return ts.setTextRange(ts.createPropertyAssignment(node.name, functionExpression), /*location*/ node); } + /** + * Visits an AccessorDeclaration of an ObjectLiteralExpression. + * + * @param node An AccessorDeclaration node. + */ + function visitAccessorDeclaration(node) { + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; + var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); + convertedLoopState = savedConvertedLoopState; + return updated; + } /** * Visits a ShorthandPropertyAssignment and transforms it into a PropertyAssignment. * * @param node A ShorthandPropertyAssignment node. */ function visitShorthandPropertyAssignment(node) { - return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), + return ts.setTextRange(ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name)), /*location*/ node); } + function visitComputedPropertyName(node) { + var ancestorFacts = enterSubtree(0 /* ComputedPropertyNameExcludes */, 8192 /* ComputedPropertyNameIncludes */); + var updated = ts.visitEachChild(node, visitor, context); + exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, hierarchyFacts & 49152 /* PropagateNewTargetMask */ ? 32768 /* NewTargetInComputedPropertyName */ : 0 /* None */); + return updated; + } /** * Visits a YieldExpression node. * @@ -51302,8 +53170,11 @@ var ts; * @param node An ArrayLiteralExpression node. */ function visitArrayLiteralExpression(node) { - // We are here because we contain a SpreadElementExpression. - return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + if (node.transformFlags & 64 /* ES2015 */) { + // We are here because we contain a SpreadElementExpression. + return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + } + return ts.visitEachChild(node, visitor, context); } /** * Visits a CallExpression that contains either a spread element or `super`. @@ -51311,7 +53182,11 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + if (node.transformFlags & 64 /* ES2015 */) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + } + return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), + /*typeArguments*/ undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); } function visitImmediateSuperCallInBody(node) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false); @@ -51338,7 +53213,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -51350,18 +53225,18 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } if (node.expression.kind === 96 /* SuperKeyword */) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis + resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createIdentifier("_this"), initializer) : initializer; } - return resultingCall; + return ts.setOriginalNode(resultingCall, node); } /** * Visits a NewExpression that contains a spread element. @@ -51369,16 +53244,18 @@ var ts; * @param node A NewExpression node. */ function visitNewExpression(node) { - // We are here because we contain a SpreadElementExpression. - ts.Debug.assert((node.transformFlags & 524288 /* ContainsSpread */) !== 0); - // [source] - // new C(...a) - // - // [output] - // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() - var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), - /*typeArguments*/ undefined, []); + if (node.transformFlags & 524288 /* ContainsSpread */) { + // We are here because we contain a SpreadElementExpression. + // [source] + // new C(...a) + // + // [output] + // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() + var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + /*typeArguments*/ undefined, []); + } + return ts.visitEachChild(node, visitor, context); } /** * Transforms an array of Expression nodes that contains a SpreadExpression. @@ -51401,7 +53278,7 @@ var ts; })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 175 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 176 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -51417,8 +53294,7 @@ var ts; return ts.map(chunk, visitExpressionOfSpread); } function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) { - return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, /*location*/ undefined, hasTrailingComma), visitor, ts.isExpression), - /*location*/ undefined, multiLine); + return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -51437,7 +53313,7 @@ var ts; * @param node A template literal. */ function visitTemplateLiteral(node) { - return ts.createLiteral(node.text, /*location*/ node); + return ts.setTextRange(ts.createLiteral(node.text), node); } /** * Visits a TaggedTemplateExpression node. @@ -51497,7 +53373,7 @@ var ts; // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's // and LineTerminatorSequences are normalized to for both TV and TRV. text = text.replace(/\r\n?/g, "\n"); - return ts.createLiteral(text, /*location*/ node); + return ts.setTextRange(ts.createLiteral(text), node); } /** * Visits a TemplateExpression node. @@ -51519,7 +53395,8 @@ var ts; // "abc" + (1 << 2) + "" var expression = ts.reduceLeft(expressions, ts.createAdd); if (ts.nodeIsSynthesized(expression)) { - ts.setTextRange(expression, node); + expression.pos = node.pos; + expression.end = node.end; } return expression; } @@ -51581,27 +53458,42 @@ var ts; /** * Visits the `super` keyword */ - function visitSuperKeyword() { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32 /* Static */) - && currentParent.kind !== 179 /* CallExpression */ + function visitSuperKeyword(isExpressionOfCall) { + return hierarchyFacts & 8 /* NonStaticClassElement */ + && !isExpressionOfCall ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } + function visitMetaProperty(node) { + if (node.keywordToken === 93 /* NewKeyword */ && node.name.text === "target") { + if (hierarchyFacts & 8192 /* ComputedPropertyName */) { + hierarchyFacts |= 32768 /* NewTargetInComputedPropertyName */; + } + else { + hierarchyFacts |= 16384 /* NewTarget */; + } + return ts.createIdentifier("_newTarget"); + } + return node; + } /** * Called by the printer just before a node is printed. * + * @param hint A hint as to the intended usage of the node. * @param node The node to be printed. + * @param emitCallback The callback used to emit the node. */ - function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; + function onEmitNode(hint, node, emitCallback) { if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. - enclosingFunction = node; + var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ + ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ + : 65 /* FunctionIncludes */); + previousOnEmitNode(hint, node, emitCallback); + exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + return; } - previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; + previousOnEmitNode(hint, node, emitCallback); } /** * Enables a more costly code path for substitutions when we determine a source file @@ -51621,24 +53513,24 @@ var ts; if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; context.enableSubstitution(98 /* ThisKeyword */); - context.enableEmitNotification(150 /* Constructor */); - context.enableEmitNotification(149 /* MethodDeclaration */); - context.enableEmitNotification(151 /* GetAccessor */); - context.enableEmitNotification(152 /* SetAccessor */); - context.enableEmitNotification(185 /* ArrowFunction */); - context.enableEmitNotification(184 /* FunctionExpression */); - context.enableEmitNotification(225 /* FunctionDeclaration */); + context.enableEmitNotification(151 /* Constructor */); + context.enableEmitNotification(150 /* MethodDeclaration */); + context.enableEmitNotification(152 /* GetAccessor */); + context.enableEmitNotification(153 /* SetAccessor */); + context.enableEmitNotification(186 /* ArrowFunction */); + context.enableEmitNotification(185 /* FunctionExpression */); + context.enableEmitNotification(227 /* FunctionDeclaration */); } } /** * Hooks node substitutions. * - * @param emitContext The context for the emitter. + * @param hint The context for the emitter. * @param node The node to substitute. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -51669,10 +53561,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 174 /* BindingElement */: - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 223 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 225 /* VariableDeclaration */: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -51713,9 +53605,8 @@ var ts; */ function substituteThisKeyword(node) { if (enabledSubstitutions & 1 /* CapturedThis */ - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 8 /* CapturesThis */) { - return ts.createIdentifier("_this", /*location*/ node); + && hierarchyFacts & 16 /* CapturesThis */) { + return ts.setTextRange(ts.createIdentifier("_this"), node); } return node; } @@ -51731,11 +53622,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 207 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 209 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 179 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 180 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -51743,7 +53634,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 196 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 197 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -51763,11 +53654,123 @@ var ts; name: "typescript:extends", scoped: false, priority: 0, - text: "\n var __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 };" + text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; })(ts || (ts = {})); /// /// +/*@internal*/ +var ts; +(function (ts) { + /** + * Transforms ES5 syntax into ES3 syntax. + * + * @param context Context and state information for the transformation. + */ + function transformES5(context) { + var compilerOptions = context.getCompilerOptions(); + // enable emit notification only if using --jsx preserve or react-native + var previousOnEmitNode; + var noSubstitution; + if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { + previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.enableEmitNotification(250 /* JsxOpeningElement */); + context.enableEmitNotification(251 /* JsxClosingElement */); + context.enableEmitNotification(249 /* JsxSelfClosingElement */); + noSubstitution = []; + } + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(178 /* PropertyAccessExpression */); + context.enableSubstitution(260 /* PropertyAssignment */); + return transformSourceFile; + /** + * Transforms an ES5 source file to ES3. + * + * @param node A SourceFile + */ + function transformSourceFile(node) { + return node; + } + /** + * Called by the printer just before a node is printed. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to emit. + * @param emitCallback A callback used to emit the node. + */ + function onEmitNode(hint, node, emitCallback) { + switch (node.kind) { + case 250 /* JsxOpeningElement */: + case 251 /* JsxClosingElement */: + case 249 /* JsxSelfClosingElement */: + var tagName = node.tagName; + noSubstitution[ts.getOriginalNodeId(tagName)] = true; + break; + } + previousOnEmitNode(hint, node, emitCallback); + } + /** + * Hooks node substitutions. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to substitute. + */ + function onSubstituteNode(hint, node) { + if (node.id && noSubstitution && noSubstitution[node.id]) { + return previousOnSubstituteNode(hint, node); + } + node = previousOnSubstituteNode(hint, node); + if (ts.isPropertyAccessExpression(node)) { + return substitutePropertyAccessExpression(node); + } + else if (ts.isPropertyAssignment(node)) { + return substitutePropertyAssignment(node); + } + return node; + } + /** + * Substitutes a PropertyAccessExpression whose name is a reserved word. + * + * @param node A PropertyAccessExpression + */ + function substitutePropertyAccessExpression(node) { + var literalName = trySubstituteReservedName(node.name); + if (literalName) { + return ts.setTextRange(ts.createElementAccess(node.expression, literalName), node); + } + return node; + } + /** + * Substitutes a PropertyAssignment whose name is a reserved word. + * + * @param node A PropertyAssignment + */ + function substitutePropertyAssignment(node) { + var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); + if (literalName) { + return ts.updatePropertyAssignment(node, literalName, node.initializer); + } + return node; + } + /** + * If an identifier name is a reserved word, returns a string literal for the name. + * + * @param name An Identifier + */ + function trySubstituteReservedName(name) { + var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); + if (token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */) { + return ts.setTextRange(ts.createLiteral(name), name); + } + return undefined; + } + } + ts.transformES5 = transformES5; +})(ts || (ts = {})); +/// +/// // Transforms generator functions into a compatible ES5 representation with similar runtime // semantics. This is accomplished by first transforming the body of each generator // function into an intermediate representation that is the compiled into a JavaScript @@ -51938,13 +53941,15 @@ var ts; Instruction[Instruction["Catch"] = 6] = "Catch"; Instruction[Instruction["Endfinally"] = 7] = "Endfinally"; })(Instruction || (Instruction = {})); - var instructionNames = ts.createMap((_a = {}, - _a[2 /* Return */] = "return", - _a[3 /* Break */] = "break", - _a[4 /* Yield */] = "yield", - _a[5 /* YieldStar */] = "yield*", - _a[7 /* Endfinally */] = "endfinally", - _a)); + function getInstructionName(instruction) { + switch (instruction) { + case 2 /* Return */: return "return"; + case 3 /* Break */: return "break"; + case 4 /* Yield */: return "yield"; + case 5 /* YieldStar */: return "yield*"; + case 7 /* Endfinally */: return "endfinally"; + } + } function transformGenerators(context) { var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); @@ -52036,13 +54041,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 209 /* DoStatement */: + case 211 /* DoStatement */: return visitDoStatement(node); - case 210 /* WhileStatement */: + case 212 /* WhileStatement */: return visitWhileStatement(node); - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: return visitSwitchStatement(node); - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -52055,24 +54060,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return visitFunctionExpression(node); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return visitAccessorDeclaration(node); - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: return visitVariableStatement(node); - case 211 /* ForStatement */: + case 213 /* ForStatement */: return visitForStatement(node); - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: return visitForInStatement(node); - case 215 /* BreakStatement */: + case 217 /* BreakStatement */: return visitBreakStatement(node); - case 214 /* ContinueStatement */: + case 216 /* ContinueStatement */: return visitContinueStatement(node); - case 216 /* ReturnStatement */: + case 218 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -52093,21 +54098,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return visitBinaryExpression(node); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return visitConditionalExpression(node); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return visitYieldExpression(node); - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return visitCallExpression(node); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -52120,9 +54125,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -52141,11 +54146,11 @@ var ts; function visitFunctionDeclaration(node) { // Currently, we only support generators that were originally async functions. if (node.asteriskToken && ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */) { - node = ts.setOriginalNode(ts.createFunctionDeclaration( + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration( /*decorators*/ undefined, node.modifiers, /*asteriskToken*/ undefined, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformGeneratorFunctionBody(node.body), + /*type*/ undefined, transformGeneratorFunctionBody(node.body)), /*location*/ node), node); } else { @@ -52179,11 +54184,11 @@ var ts; function visitFunctionExpression(node) { // Currently, we only support generators that were originally async functions. if (node.asteriskToken && ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */) { - node = ts.setOriginalNode(ts.createFunctionExpression( + node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformGeneratorFunctionBody(node.body), + /*type*/ undefined, transformGeneratorFunctionBody(node.body)), /*location*/ node), node); } else { @@ -52271,7 +54276,7 @@ var ts; operationArguments = savedOperationArguments; operationLocations = savedOperationLocations; state = savedState; - return ts.createBlock(statements, /*location*/ body, body.multiLine); + return ts.setTextRange(ts.createBlock(statements, body.multiLine), body); } /** * Visits a variable statement. @@ -52350,7 +54355,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -52362,7 +54367,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -52381,7 +54386,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 57 /* EqualsToken */, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.setTextRange(ts.createAssignment(target, ts.setTextRange(ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression)), node)), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -52405,10 +54410,10 @@ var ts; // _a = a(); // .yield resumeLabel // _a + %sent% + c() - var clone_4 = ts.getMutableClone(node); - clone_4.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_4.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_4; + var clone_5 = ts.getMutableClone(node); + clone_5.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_5.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_5; } return ts.visitEachChild(node, visitor, context); } @@ -52553,7 +54558,7 @@ var ts; emitYield(expression, /*location*/ node); } markLabel(resumeLabel); - return createGeneratorResume(); + return createGeneratorResume(/*location*/ node); } /** * Visits an ArrayLiteralExpression that contains a YieldExpression. @@ -52592,14 +54597,13 @@ var ts; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, /*location*/ undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, location, multiLine); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { emitAssignment(temp, hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, /*location*/ undefined, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, - /*location*/ undefined, multiLine)); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) + : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); hasAssignedTemp = true; leadingElement = undefined; expressions = []; @@ -52630,8 +54634,7 @@ var ts; var multiLine = node.multiLine; var numInitialProperties = countInitialNodesWithoutYield(properties); var temp = declareLocal(); - emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), - /*location*/ undefined, multiLine)); + emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), multiLine)); var expressions = ts.reduceLeft(properties, reduceProperty, [], numInitialProperties); expressions.push(multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); return ts.inlineExpressions(expressions); @@ -52667,10 +54670,10 @@ var ts; // .yield resumeLabel // .mark resumeLabel // a = _a[%sent%] - var clone_5 = ts.getMutableClone(node); - clone_5.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_5.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_5; + var clone_6 = ts.getMutableClone(node); + clone_6.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_6.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -52705,10 +54708,9 @@ var ts; // .mark resumeLabel // new (_b.apply(_a, _c.concat([%sent%, 2]))); var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, + return ts.setOriginalNode(ts.setTextRange(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, /*leadingElement*/ ts.createVoidZero())), - /*typeArguments*/ undefined, [], - /*location*/ node), node); + /*typeArguments*/ undefined, []), node), node); } return ts.visitEachChild(node, visitor, context); } @@ -52737,35 +54739,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 204 /* Block */: + case 206 /* Block */: return transformAndEmitBlock(node); - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 208 /* IfStatement */: + case 210 /* IfStatement */: return transformAndEmitIfStatement(node); - case 209 /* DoStatement */: + case 211 /* DoStatement */: return transformAndEmitDoStatement(node); - case 210 /* WhileStatement */: + case 212 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 211 /* ForStatement */: + case 213 /* ForStatement */: return transformAndEmitForStatement(node); - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 214 /* ContinueStatement */: + case 216 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 215 /* BreakStatement */: + case 217 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 216 /* ReturnStatement */: + case 218 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 217 /* WithStatement */: + case 219 /* WithStatement */: return transformAndEmitWithStatement(node); - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 220 /* ThrowStatement */: + case 222 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 221 /* TryStatement */: + case 223 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, /*optional*/ true)); @@ -52785,7 +54787,9 @@ var ts; function transformAndEmitVariableDeclarationList(node) { for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { var variable = _a[_i]; - hoistVariableDeclaration(variable.name); + var name = ts.getSynthesizedClone(variable.name); + ts.setCommentRange(name, variable.name); + hoistVariableDeclaration(name); } var variables = ts.getInitializedVariables(node); var numVariables = variables.length; @@ -52828,7 +54832,7 @@ var ts; if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) { var endLabel = defineLabel(); var elseLabel = node.elseStatement ? defineLabel() : undefined; - emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression)); + emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), /*location*/ node.expression); transformAndEmitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { emitBreak(endLabel); @@ -52951,8 +54955,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression), - /*location*/ initializer)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -52962,8 +54965,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression), - /*location*/ node.incrementor)); + emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -53185,7 +55187,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 254 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 257 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -53198,7 +55200,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 253 /* CaseClause */) { + if (clause.kind === 256 /* CaseClause */) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -53340,9 +55342,9 @@ var ts; } return -1; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */) { return substituteExpression(node); } return node; @@ -53354,17 +55356,17 @@ var ts; return node; } function substituteExpressionIdentifier(node) { - if (renamedCatchVariables && ts.hasProperty(renamedCatchVariables, node.text)) { + if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { var original = ts.getOriginalNode(node); if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_37) { - var clone_6 = ts.getMutableClone(name_37); - ts.setSourceMapRange(clone_6, node); - ts.setCommentRange(clone_6, node); - return clone_6; + var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; + if (name) { + var clone_7 = ts.getMutableClone(name); + ts.setSourceMapRange(clone_7, node); + ts.setCommentRange(clone_7, node); + return clone_7; } } } @@ -53505,10 +55507,10 @@ var ts; var name = declareLocal(text); if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); - renamedCatchVariableDeclarations = ts.createMap(); + renamedCatchVariableDeclarations = []; context.enableSubstitution(70 /* Identifier */); } - renamedCatchVariables[text] = true; + renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; var exception = peekBlock(); ts.Debug.assert(exception.state < 1 /* Catch */); @@ -53779,7 +55781,7 @@ var ts; */ function createInstruction(instruction) { var literal = ts.createLiteral(instruction); - literal.trailingComment = instructionNames[instruction]; + literal.trailingComment = getInstructionName(instruction); return literal; } /** @@ -53790,10 +55792,10 @@ var ts; */ function createInlineBreak(label, location) { ts.Debug.assert(label > 0, "Invalid label: " + label); - return ts.createReturn(ts.createArrayLiteral([ + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), location); + ])), location); } /** * Creates a statement that can be used indicate a Return operation. @@ -53802,15 +55804,16 @@ var ts; * @param location An optional source map location for the statement. */ function createInlineReturn(expression, location) { - return ts.createReturn(ts.createArrayLiteral(expression + return ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)]), location); + : [createInstruction(2 /* Return */)])), location); } /** * Creates an expression that can be used to resume from a Yield operation. */ function createGeneratorResume(location) { - return ts.createCall(ts.createPropertyAccess(state, "sent"), /*typeArguments*/ undefined, [], location); + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(state, "sent"), + /*typeArguments*/ undefined, []), location); } /** * Emits an empty instruction. @@ -53956,7 +55959,6 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, ts.createBlock(buildResult, - /*location*/ undefined, /*multiLine*/ buildResult.length > 0)), 262144 /* ReuseTempVariableScope */)); } /** @@ -54227,7 +56229,7 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeAssign(left, right, operationLocation) { - writeStatement(ts.createStatement(ts.createAssignment(left, right), operationLocation)); + writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); } /** * Writes a Throw operation to the current label's statement list. @@ -54238,7 +56240,7 @@ var ts; function writeThrow(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createThrow(expression, operationLocation)); + writeStatement(ts.setTextRange(ts.createThrow(expression), operationLocation)); } /** * Writes a Return operation to the current label's statement list. @@ -54249,9 +56251,9 @@ var ts; function writeReturn(expression, operationLocation) { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)]), operationLocation)); + : [createInstruction(2 /* Return */)])), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a Break operation to the current label's statement list. @@ -54261,10 +56263,10 @@ var ts; */ function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation)); + ])), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a BreakWhenTrue operation to the current label's statement list. @@ -54274,10 +56276,10 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation))); + ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); } /** * Writes a BreakWhenFalse operation to the current label's statement list. @@ -54287,10 +56289,10 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation))); + ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); } /** * Writes a Yield operation to the current label's statement list. @@ -54300,9 +56302,9 @@ var ts; */ function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)]), operationLocation)); + : [createInstruction(4 /* Yield */)])), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes a YieldStar instruction to the current label's statement list. @@ -54312,10 +56314,10 @@ var ts; */ function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ + writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([ createInstruction(5 /* YieldStar */), expression - ]), operationLocation)); + ])), operationLocation), 384 /* NoTokenSourceMaps */)); } /** * Writes an Endfinally instruction to the current label's statement list. @@ -54398,155 +56400,903 @@ var ts; priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; - var _a; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - /** - * Transforms ES5 syntax into ES3 syntax. - * - * @param context Context and state information for the transformation. - */ - function transformES5(context) { - var previousOnSubstituteNode = context.onSubstituteNode; - context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(177 /* PropertyAccessExpression */); - context.enableSubstitution(257 /* PropertyAssignment */); - return transformSourceFile; - /** - * Transforms an ES5 source file to ES3. - * - * @param node A SourceFile - */ - function transformSourceFile(node) { - return node; - } - /** - * Hooks node substitutions. - * - * @param emitContext The context for the emitter. - * @param node The node to substitute. - */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (ts.isPropertyAccessExpression(node)) { - return substitutePropertyAccessExpression(node); - } - else if (ts.isPropertyAssignment(node)) { - return substitutePropertyAssignment(node); - } - return node; - } - /** - * Substitutes a PropertyAccessExpression whose name is a reserved word. - * - * @param node A PropertyAccessExpression - */ - function substitutePropertyAccessExpression(node) { - var literalName = trySubstituteReservedName(node.name); - if (literalName) { - return ts.createElementAccess(node.expression, literalName, /*location*/ node); - } - return node; - } - /** - * Substitutes a PropertyAssignment whose name is a reserved word. - * - * @param node A PropertyAssignment - */ - function substitutePropertyAssignment(node) { - var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); - if (literalName) { - return ts.updatePropertyAssignment(node, literalName, node.initializer); - } - return node; - } - /** - * If an identifier name is a reserved word, returns a string literal for the name. - * - * @param name An Identifier - */ - function trySubstituteReservedName(name) { - var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); - if (token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */) { - return ts.createLiteral(name, /*location*/ name); - } - return undefined; - } - } - ts.transformES5 = transformES5; })(ts || (ts = {})); /// /// /*@internal*/ var ts; (function (ts) { - function transformES2015Module(context) { + function transformModule(context) { + function getTransformModuleDelegate(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.AMD: return transformAMDModule; + case ts.ModuleKind.UMD: return transformUMDModule; + default: return transformCommonJSModule; + } + } + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var compilerOptions = context.getCompilerOptions(); - var previousOnEmitNode = context.onEmitNode; + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var moduleKind = ts.getEmitModuleKind(compilerOptions); var previousOnSubstituteNode = context.onSubstituteNode; - context.onEmitNode = onEmitNode; + var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(261 /* SourceFile */); - context.enableSubstitution(70 /* Identifier */); - var currentSourceFile; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(193 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(191 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(192 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(261 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(264 /* SourceFile */); // Restore state when substituting nodes in a file. + var moduleInfoMap = []; // The ExternalModuleInfo for each file. + var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. + var currentSourceFile; // The current file. + var currentModuleInfo; // The ExternalModuleInfo for the current file. + var noSubstitution; // Set of nodes for which substitution rules should be ignored. return transformSourceFile; + /** + * Transforms the module aspects of a SourceFile. + * + * @param node The SourceFile node. + */ function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { + if (ts.isDeclarationFile(node) + || !(ts.isExternalModule(node) + || compilerOptions.isolatedModules)) { return node; } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); - if (externalHelpersModuleName) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements); - ts.append(statements, ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + currentSourceFile = node; + currentModuleInfo = ts.collectExternalModuleInfo(node, resolver, compilerOptions); + moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo; + // Perform the transformation. + var transformModule = getTransformModuleDelegate(moduleKind); + var updated = transformModule(node); + currentSourceFile = undefined; + currentModuleInfo = undefined; + return ts.aggregateTransformFlags(updated); + } + /** + * Transforms a SourceFile into a CommonJS module. + * + * @param node The SourceFile node. + */ + function transformCommonJSModule(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + ts.addRange(statements, endLexicalEnvironment()); + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); + var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); + if (currentModuleInfo.hasExportStarsToExportValues) { + ts.addEmitHelper(updated, exportStarHelper); + } + return updated; + } + /** + * Transforms a SourceFile into an AMD module. + * + * @param node The SourceFile node. + */ + function transformAMDModule(node) { + var define = ts.createIdentifier("define"); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + // An AMD define function has the following shape: + // + // define(id?, dependencies?, factory); + // + // This has the shape of the following: + // + // define(name, ["module1", "module2"], function (module1Alias) { ... } + // + // The location of the alias in the parameter list in the factory function needs to + // match the position of the module name in the dependency list. + // + // To ensure this is true in cases of modules with no aliases, e.g.: + // + // import "module" + // + // or + // + // /// + // + // we need to add modules without alias names to the end of the dependencies list + var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + // Create an updated SourceFile: + // + // define(moduleName?, ["module1", "module2"], function ... + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ + ts.createStatement(ts.createCall(define, + /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + // Add the dependency array argument: + // + // ["require", "exports", module1", "module2", ...] + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + // Add the module body function argument: + // + // function (require, exports, module1, module2) ... + ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") + ].concat(importAliasNames), + /*type*/ undefined, transformAsynchronousModuleBody(node)) + ]))) + ]), + /*location*/ node.statements)); + } + /** + * Transforms a SourceFile into a UMD module. + * + * @param node The SourceFile node. + */ + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var umdHeader = ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "factory")], + /*type*/ undefined, ts.setTextRange(ts.createBlock([ + ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ + ts.createVariableStatement( + /*modifiers*/ undefined, [ + ts.createVariableDeclaration("v", + /*type*/ undefined, ts.createCall(ts.createIdentifier("factory"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("require"), + ts.createIdentifier("exports") + ])) + ]), + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) + ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), + /*typeArguments*/ undefined, [ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createIdentifier("factory") + ])) + ]))) + ], + /*multiLine*/ true), + /*location*/ undefined)); + // Create an updated SourceFile: + // + // (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 ...) + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ + ts.createStatement(ts.createCall(umdHeader, + /*typeArguments*/ undefined, [ + // Add the module body function argument: + // + // function (require, exports) ... + ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") + ].concat(importAliasNames), + /*type*/ undefined, transformAsynchronousModuleBody(node)) + ])) + ]), + /*location*/ node.statements)); + } + /** + * Collect the additional asynchronous dependencies for the module. + * + * @param node The source file. + * @param includeNonAmdDependencies A value indicating whether to include non-AMD dependencies. + */ + function collectAsynchronousDependencies(node, includeNonAmdDependencies) { + // names of modules with corresponding parameter in the factory function + var aliasedModuleNames = []; + // names of modules with no corresponding parameters in factory function + var unaliasedModuleNames = []; + // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding + // module names in aliasedModuleNames. + var importAliasNames = []; + // Fill in amd-dependency tags + for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { + var amdDependency = _a[_i]; + if (amdDependency.name) { + aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, amdDependency.name)); } else { - return ts.visitEachChild(node, visitor, context); + unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); } } - return node; + for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) { + var importNode = _c[_b]; + // Find the name of the external module + var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + // Find the name of the module alias, if there is one + var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); + if (includeNonAmdDependencies && importAliasName) { + // Set emitFlags on the name of the classDeclaration + // This is so that when printer will not substitute the identifier + ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; } - function visitor(node) { + /** + * Transforms a SourceFile into an AMD or UMD module body. + * + * @param node The SourceFile node. + */ + function transformAsynchronousModuleBody(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + ts.append(statements, createUnderscoreUnderscoreESModule()); + } + // Visit each statement of the module body. + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + // End the lexical environment for the module body + // and merge any new lexical declarations. + ts.addRange(statements, endLexicalEnvironment()); + // Append the 'export =' statement if provided. + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); + var body = ts.createBlock(statements, /*multiLine*/ true); + if (currentModuleInfo.hasExportStarsToExportValues) { + // If we have any `export * from ...` declarations + // we need to inform the emitter to add the __export helper. + ts.addEmitHelper(body, exportStarHelper); + } + return body; + } + /** + * Adds the down-level representation of `export=` to the statement list if one exists + * in the source file. + * + * @param statements The Statement list to modify. + * @param emitAsReturn A value indicating whether to emit the `export=` statement as a + * return statement. + */ + function addExportEqualsIfNeeded(statements, emitAsReturn) { + if (currentModuleInfo.exportEquals) { + if (emitAsReturn) { + var statement = ts.createReturn(currentModuleInfo.exportEquals.expression); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + statements.push(statement); + } + else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression)); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 1536 /* NoComments */); + statements.push(statement); + } + } + } + // + // Top-Level Source Element Visitors + // + /** + * Visits a node at the top level of the source file. + * + * @param node The node to visit. + */ + function sourceElementVisitor(node) { switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: - // Elide `import=` as it is not legal with --module ES6 - return undefined; - case 240 /* ExportAssignment */: + case 237 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 236 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 243 /* ExportDeclaration */: + return visitExportDeclaration(node); + case 242 /* ExportAssignment */: return visitExportAssignment(node); + case 207 /* VariableStatement */: + return visitVariableStatement(node); + case 227 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 228 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 299 /* MergeDeclarationMarker */: + return visitMergeDeclarationMarker(node); + case 300 /* EndOfDeclarationMarker */: + return visitEndOfDeclarationMarker(node); + default: + // This visitor does not descend into the tree, as export/import statements + // are only transformed at the top level of a file. + return node; + } + } + /** + * Visits an ImportDeclaration node. + * + * @param node The node to visit. + */ + function visitImportDeclaration(node) { + var statements; + var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); + if (moduleKind !== ts.ModuleKind.AMD) { + if (!node.importClause) { + // import "mod"; + return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); + } + else { + var variables = []; + if (namespaceDeclaration && !ts.isDefaultImport(node)) { + // import * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, createRequireCall(node))); + } + else { + // import d from "mod"; + // import { x, y } from "mod"; + // import d, { x, y } from "mod"; + // import d, * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), + /*type*/ undefined, createRequireCall(node))); + if (namespaceDeclaration && ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node))); + } + } + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList(variables, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), + /*location*/ node)); + } + } + else if (namespaceDeclaration && ts.isDefaultImport(node)) { + // import d, * as n from "mod"; + statements = ts.append(statements, ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node)), + /*location*/ node) + ], languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Creates a `require()` call to import an external module. + * + * @param importNode The declararation to import. + */ + function createRequireCall(importNode) { + var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var args = []; + if (moduleName) { + args.push(moduleName); + } + return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); + } + /** + * Visits an ImportEqualsDeclaration node. + * + * @param node The node to visit. + */ + function visitImportEqualsDeclaration(node) { + ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); + var statements; + if (moduleKind !== ts.ModuleKind.AMD) { + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(node.name, createRequireCall(node))), node)); + } + else { + statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), + /*type*/ undefined, createRequireCall(node)) + ], + /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node)); + } + } + else { + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); + } + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportEqualsDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits an ExportDeclaration node. + * + * @param The node to visit. + */ + function visitExportDeclaration(node) { + if (!node.moduleSpecifier) { + // Elide export declarations with no module specifier as they are handled + // elsewhere. + return undefined; + } + var generatedName = ts.getGeneratedNameForNode(node); + if (node.exportClause) { + var statements = []; + // export { x, y } from "mod"; + if (moduleKind !== ts.ModuleKind.AMD) { + statements.push(ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(generatedName, + /*type*/ undefined, createRequireCall(node)) + ])), + /*location*/ node)); + } + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); + } + return ts.singleOrMany(statements); + } + else { + // export * from "mod"; + return ts.setTextRange(ts.createStatement(ts.createCall(ts.createIdentifier("__export"), + /*typeArguments*/ undefined, [ + moduleKind !== ts.ModuleKind.AMD + ? createRequireCall(node) + : generatedName + ])), node); + } + } + /** + * Visits an ExportAssignment node. + * + * @param node The node to visit. + */ + function visitExportAssignment(node) { + if (node.isExportEquals) { + return undefined; + } + var statements; + var original = node.original; + if (original && hasAssociatedEndOfDeclarationMarker(original)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); + } + else { + statements = appendExportStatement(statements, ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); + } + return ts.singleOrMany(statements); + } + /** + * Visits a FunctionDeclaration node. + * + * @param node The node to visit. + */ + function visitFunctionDeclaration(node) { + var statements; + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), + /*typeParameters*/ undefined, node.parameters, + /*type*/ undefined, node.body), + /*location*/ node), + /*original*/ node)); + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits a ClassDeclaration node. + * + * @param node The node to visit. + */ + function visitClassDeclaration(node) { + var statements; + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createClassDeclaration( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), + /*typeParameters*/ undefined, node.heritageClauses, node.members), node), node)); + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits a VariableStatement node. + * + * @param node The node to visit. + */ + function visitVariableStatement(node) { + var statements; + var variables; + var expressions; + if (ts.hasModifier(node, 1 /* Export */)) { + var modifiers = void 0; + // If we're exporting these variables, then these just become assignments to 'exports.x'. + // We only want to emit assignments for variables with initializers. + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { + if (!modifiers) { + modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); + } + variables = ts.append(variables, variable); + } + else if (variable.initializer) { + expressions = ts.append(expressions, transformInitializedVariable(variable)); + } + } + if (variables) { + statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); + } + if (expressions) { + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + } + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); + } + else { + statements = appendExportsOfVariableStatement(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Transforms an exported variable with an initializer into an expression. + * + * @param node The node to transform. + */ + function transformInitializedVariable(node) { + if (ts.isBindingPattern(node.name)) { + return ts.flattenDestructuringAssignment(node, + /*visitor*/ undefined, context, 0 /* All */, + /*needsValue*/ false, createExportExpression); + } + else { + return ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name), + /*location*/ node.name), node.initializer); + } + } + /** + * Visits a MergeDeclarationMarker used as a placeholder for the beginning of a merged + * and transformed declaration. + * + * @param node The node to visit. + */ + function visitMergeDeclarationMarker(node) { + // For an EnumDeclaration or ModuleDeclaration that merges with a preceeding + // declaration we do not emit a leading variable declaration. To preserve the + // begin/end semantics of the declararation and to properly handle exports + // we wrapped the leading variable declaration in a `MergeDeclarationMarker`. + // + // To balance the declaration, add the exports of the elided variable + // statement. + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207 /* VariableStatement */) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } return node; } - function visitExportAssignment(node) { - // Elide `export=` as it is not legal with --module ES6 - return node.isExportEquals ? undefined : node; + /** + * Determines whether a node has an associated EndOfDeclarationMarker. + * + * @param node The node to test. + */ + function hasAssociatedEndOfDeclarationMarker(node) { + return (ts.getEmitFlags(node) & 2097152 /* HasEndOfDeclarationMarker */) !== 0; + } + /** + * Visits a DeclarationMarker used as a placeholder for the end of a transformed + * declaration. + * + * @param node The node to visit. + */ + function visitEndOfDeclarationMarker(node) { + // For some transformations we emit an `EndOfDeclarationMarker` to mark the actual + // end of the transformed declaration. We use this marker to emit any deferred exports + // of the declaration. + var id = ts.getOriginalNodeId(node); + var statements = deferredExports[id]; + if (statements) { + delete deferredExports[id]; + return ts.append(statements, node); + } + return node; + } + /** + * Appends the exports of an ImportDeclaration to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfImportDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + var importClause = decl.importClause; + if (!importClause) { + return statements; + } + if (importClause.name) { + statements = appendExportsOfDeclaration(statements, importClause); + } + var namedBindings = importClause.namedBindings; + if (namedBindings) { + switch (namedBindings.kind) { + case 239 /* NamespaceImport */: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 240 /* NamedImports */: + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var importBinding = _a[_i]; + statements = appendExportsOfDeclaration(statements, importBinding); + } + break; + } + } + return statements; + } + /** + * Appends the exports of an ImportEqualsDeclaration to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfImportEqualsDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + return appendExportsOfDeclaration(statements, decl); + } + /** + * Appends the exports of a VariableStatement to a statement list, returning the statement + * list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param node The VariableStatement whose exports are to be recorded. + */ + function appendExportsOfVariableStatement(statements, node) { + if (currentModuleInfo.exportEquals) { + return statements; + } + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + statements = appendExportsOfBindingElement(statements, decl); + } + return statements; + } + /** + * Appends the exports of a VariableDeclaration or BindingElement to a statement list, + * returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfBindingElement(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + statements = appendExportsOfBindingElement(statements, element); + } + } + } + else if (!ts.isGeneratedIdentifier(decl.name)) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + /** + * Appends the exports of a ClassDeclaration or FunctionDeclaration to a statement list, + * returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfHoistedDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.hasModifier(decl, 1 /* Export */)) { + var exportName = ts.hasModifier(decl, 512 /* Default */) ? ts.createIdentifier("default") : decl.name; + statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), /*location*/ decl); + } + if (decl.name) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + /** + * Appends the exports of a declaration to a statement list, returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration to export. + */ + function appendExportsOfDeclaration(statements, decl) { + var name = ts.getDeclarationName(decl); + var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(name.text); + if (exportSpecifiers) { + for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { + var exportSpecifier = exportSpecifiers_1[_i]; + statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name); + } + } + return statements; + } + /** + * Appends the down-level representation of an export to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param exportName The name of the export. + * @param expression The expression to export. + * @param location The location to use for source maps and comments for the export. + * @param allowComments Whether to allow comments on the export. + */ + function appendExportStatement(statements, exportName, expression, location, allowComments) { + statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); + return statements; + } + function createUnderscoreUnderscoreESModule() { + var statement; + if (languageVersion === 0 /* ES3 */) { + statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true))); + } + else { + statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ])); + } + ts.setEmitFlags(statement, 524288 /* CustomPrologue */); + return statement; + } + /** + * Creates a call to the current file's export function to export a value. + * + * @param name The bound name of the export. + * @param value The exported value. + * @param location The location to use for source maps and comments for the export. + * @param allowComments An optional value indicating whether to emit comments for the statement. + */ + function createExportStatement(name, value, location, allowComments) { + var statement = ts.setTextRange(ts.createStatement(createExportExpression(name, value)), location); + ts.startOnNewLine(statement); + if (!allowComments) { + ts.setEmitFlags(statement, 1536 /* NoComments */); + } + return statement; + } + /** + * Creates a call to the current file's export function to export a value. + * + * @param name The bound name of the export. + * @param value The exported value. + * @param location The location to use for source maps and comments for the export. + */ + function createExportExpression(name, value, location) { + return ts.setTextRange(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value), location); + } + // + // Modifier Visitors + // + /** + * Visit nodes to elide module-specific modifiers. + * + * @param node The node to visit. + */ + function modifierVisitor(node) { + // Elide module-specific modifiers. + switch (node.kind) { + case 83 /* ExportKeyword */: + case 78 /* DefaultKeyword */: + return undefined; + } + return node; } // // Emit Notification // /** - * Hook for node emit. + * Hook for node emit notifications. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ - function onEmitNode(emitContext, node, emitCallback) { - if (ts.isSourceFile(node)) { + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264 /* SourceFile */) { currentSourceFile = node; - previousOnEmitNode(emitContext, node, emitCallback); + currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; + noSubstitution = []; + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; + currentModuleInfo = undefined; + noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } // @@ -54555,27 +57305,188 @@ var ts; /** * Hooks node substitutions. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (ts.isIdentifier(node) && emitContext === 1 /* Expression */) { - return substituteExpressionIdentifier(node); + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (node.id && noSubstitution[node.id]) { + return node; + } + if (hint === 1 /* Expression */) { + return substituteExpression(node); + } + else if (ts.isShorthandPropertyAssignment(node)) { + return substituteShorthandPropertyAssignment(node); } return node; } + /** + * Substitution for a ShorthandPropertyAssignment whose declaration name is an imported + * or exported symbol. + * + * @param node The node to substitute. + */ + function substituteShorthandPropertyAssignment(node) { + var name = node.name; + var exportedOrImportedName = substituteExpressionIdentifier(name); + if (exportedOrImportedName !== name) { + // A shorthand property with an assignment initializer is probably part of a + // destructuring assignment + if (node.objectAssignmentInitializer) { + var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); + return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node); + } + return ts.setTextRange(ts.createPropertyAssignment(name, exportedOrImportedName), node); + } + return node; + } + /** + * Substitution for an Expression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteExpression(node) { + switch (node.kind) { + case 70 /* Identifier */: + return substituteExpressionIdentifier(node); + case 193 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 192 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + return substituteUnaryExpression(node); + } + return node; + } + /** + * Substitution for an Identifier expression that may contain an imported or exported + * symbol. + * + * @param node The node to substitute. + */ function substituteExpressionIdentifier(node) { if (ts.getEmitFlags(node) & 4096 /* HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return ts.createPropertyAccess(externalHelpersModuleName, node); } + return node; + } + if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { + var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); + if (exportContainer && exportContainer.kind === 264 /* SourceFile */) { + return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), + /*location*/ node); + } + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + if (ts.isImportClause(importDeclaration)) { + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), + /*location*/ node); + } + else if (ts.isImportSpecifier(importDeclaration)) { + var name = importDeclaration.propertyName || importDeclaration.name; + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name)), + /*location*/ node); + } + } } return node; } + /** + * Substitution for a BinaryExpression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteBinaryExpression(node) { + // When we see an assignment expression whose left-hand side is an exported symbol, + // we should ensure all exports of that symbol are updated with the correct value. + // + // - We do not substitute generated identifiers for any reason. + // - We do not substitute identifiers tagged with the LocalName flag. + // - We do not substitute identifiers that were originally the name of an enum or + // namespace due to how they are transformed in TypeScript. + // - We only substitute identifiers that are exported at the top level. + if (ts.isAssignmentOperator(node.operatorToken.kind) + && ts.isIdentifier(node.left) + && !ts.isGeneratedIdentifier(node.left) + && !ts.isLocalName(node.left) + && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { + var exportedNames = getExports(node.left); + if (exportedNames) { + // For each additional export of the declaration, apply an export assignment. + var expression = node; + for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { + var exportName = exportedNames_1[_i]; + // Mark the node to prevent triggering this rule again. + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression, /*location*/ node); + } + return expression; + } + } + return node; + } + /** + * Substitution for a UnaryExpression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteUnaryExpression(node) { + // When we see a prefix or postfix increment expression whose operand is an exported + // symbol, we should ensure all exports of that symbol are updated with the correct + // value. + // + // - We do not substitute generated identifiers for any reason. + // - We do not substitute identifiers tagged with the LocalName flag. + // - We do not substitute identifiers that were originally the name of an enum or + // namespace due to how they are transformed in TypeScript. + // - We only substitute identifiers that are exported at the top level. + if ((node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) + && ts.isIdentifier(node.operand) + && !ts.isGeneratedIdentifier(node.operand) + && !ts.isLocalName(node.operand) + && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var expression = node.kind === 192 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 42 /* PlusPlusToken */ ? 58 /* PlusEqualsToken */ : 59 /* MinusEqualsToken */), ts.createLiteral(1)), + /*location*/ node) + : node; + for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { + var exportName = exportedNames_2[_i]; + // Mark the node to prevent triggering this rule again. + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression); + } + return expression; + } + } + return node; + } + /** + * Gets the additional exports of a name. + * + * @param name The name. + */ + function getExports(name) { + if (!ts.isGeneratedIdentifier(name)) { + var valueDeclaration = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); + if (valueDeclaration) { + return currentModuleInfo + && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; + } + } + } } - ts.transformES2015Module = transformES2015Module; + ts.transformModule = transformModule; + // emit output for the __export helper function + var exportStarHelper = { + name: "typescript:export-star", + scoped: true, + text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" + }; })(ts || (ts = {})); /// /// @@ -54592,14 +57503,14 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(261 /* SourceFile */); // Restore state when substituting nodes in a file. - var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. - var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. - var exportFunctionsMap = ts.createMap(); // The export function associated with a source file. - var noSubstitutionMap = ts.createMap(); // Set of nodes for which substitution rules should be ignored for each file. + context.enableSubstitution(193 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(191 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(192 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(264 /* SourceFile */); // Restore state when substituting nodes in a file. + var moduleInfoMap = []; // The ExternalModuleInfo for each file. + var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. + var exportFunctionsMap = []; // The export function associated with a source file. + var noSubstitutionMap = []; // Set of nodes for which substitution rules should be ignored for each file. var currentSourceFile; // The current file. var moduleInfo; // ExternalModuleInfo for the current file. var exportFunction; // The export function for the current file. @@ -54638,7 +57549,8 @@ var ts; moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); // Make sure that the name of the 'exports' function does not conflict with // existing identifiers. - exportFunction = exportFunctionsMap[id] = ts.createUniqueName("exports"); + exportFunction = ts.createUniqueName("exports"); + exportFunctionsMap[id] = exportFunction; contextObject = ts.createUniqueName("context"); // Add the body of the module. var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); @@ -54657,12 +57569,12 @@ var ts; // So the helper will be emit at the correct position instead of at the top of the source-file var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); - var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.createNodeArray([ + var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ], node.statements)), 1024 /* NoTrailingComments */); + ]), node.statements)), 1024 /* NoTrailingComments */); if (!(compilerOptions.outFile || compilerOptions.out)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -54690,13 +57602,13 @@ var ts; var externalImport = externalImports[i]; var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices.get(text); + if (groupIndex !== undefined) { // deduplicate/group entries in dependency list by the dependency name - var groupIndex = groupIndices[text]; dependencyGroups[groupIndex].externalImports.push(externalImport); } else { - groupIndices[text] = dependencyGroups.length; + groupIndices.set(text, dependencyGroups.length); dependencyGroups.push({ name: externalModuleName, externalImports: [externalImport] @@ -54780,7 +57692,7 @@ var ts; // - Temporary variables will appear at the top rather than at the bottom of the file ts.addRange(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + var moduleObject = ts.createObjectLiteral([ ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), ts.createPropertyAssignment("execute", ts.createFunctionExpression( /*modifiers*/ undefined, @@ -54788,12 +57700,11 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, ts.createBlock(executeStatements, - /*location*/ undefined, - /*multiLine*/ true))) - ]), - /*multiLine*/ true))); - return ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); + /*type*/ undefined, ts.createBlock(executeStatements, /*multiLine*/ true))) + ]); + moduleObject.multiLine = true; + statements.push(ts.createReturn(moduleObject)); + return ts.createBlock(statements, /*multiLine*/ true); } /** * Adds an exportStar function to a statement list if it is needed for the file. @@ -54809,13 +57720,13 @@ var ts; // to support this we store names of local/indirect exported entries in a set. // this set is used to filter names brought by star expors. // local names set should only be added if we have anything exported - if (!moduleInfo.exportedNames && ts.isEmpty(moduleInfo.exportSpecifiers)) { + if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) { // no exported declarations (export var ...) or export specifiers (export {x}) // check if we have any non star export declarations. var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 241 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 243 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -54835,12 +57746,12 @@ var ts; continue; } // write name of exported declaration, i.e 'export var x...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createTrue())); } } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 241 /* ExportDeclaration */) { + if (externalImport.kind !== 243 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -54851,14 +57762,14 @@ var ts; for (var _f = 0, _g = exportDecl.exportClause.elements; _f < _g.length; _f++) { var element = _g[_f]; // write name of indirectly exported entry, i.e. 'export {x} from ...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createTrue())); } } var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); statements.push(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(exportedNamesStorageRef, - /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*location*/ undefined, /*multiline*/ true)) + /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*multiline*/ true)) ]))); var exportStarFunction = createExportStarFunction(exportedNamesStorageRef); statements.push(exportStarFunction); @@ -54899,9 +57810,7 @@ var ts; ])), ts.createStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [exports])) - ], - /*location*/ undefined, - /*multiline*/ true)); + ], /*multiline*/ true)); } /** * Creates an array setter callbacks for each dependency group. @@ -54921,19 +57830,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // fall-through - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -54950,7 +57859,7 @@ var ts; properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); } statements.push(ts.createStatement(ts.createCall(exportFunction, - /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*location*/ undefined, /*multiline*/ true)]))); + /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*multiline*/ true)]))); } else { // export * from 'foo' @@ -54969,9 +57878,9 @@ var ts; /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], - /*type*/ undefined, ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true))); + /*type*/ undefined, ts.createBlock(statements, /*multiLine*/ true))); } - return ts.createArrayLiteral(setters, /*location*/ undefined, /*multiLine*/ true); + return ts.createArrayLiteral(setters, /*multiLine*/ true); } // // Top-level Source Element Visitors @@ -54983,15 +57892,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return visitImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -55092,11 +58001,9 @@ var ts; var name = ts.getLocalName(node); hoistVariableDeclaration(name); // Rewrite the class declaration into an assignment of a class expression. - statements = ts.append(statements, ts.createStatement(ts.createAssignment(name, ts.createClassExpression( + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement), - /*location*/ node)), - /*location*/ node)); + /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts.getOriginalNodeId(node); @@ -55131,7 +58038,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), /*location*/ node)); + statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -55169,7 +58076,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 1048576 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 261 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 264 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -55216,8 +58123,8 @@ var ts; function createVariableAssignment(name, value, location, isExportedDeclaration) { hoistVariableDeclaration(ts.getSynthesizedClone(name)); return isExportedDeclaration - ? createExportExpression(name, preventSubstitution(ts.createAssignment(name, value, location))) - : preventSubstitution(ts.createAssignment(name, value, location)); + ? createExportExpression(name, preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location))) + : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } /** * Visits a MergeDeclarationMarker used as a placeholder for the beginning of a merged @@ -55233,7 +58140,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -55289,10 +58196,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 237 /* NamespaceImport */: + case 239 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 238 /* NamedImports */: + case 240 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -55410,10 +58317,10 @@ var ts; return statements; } var name = ts.getDeclarationName(decl); - var exportSpecifiers = moduleInfo.exportSpecifiers[name.text]; + var exportSpecifiers = moduleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { - for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { - var exportSpecifier = exportSpecifiers_1[_i]; + for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { + var exportSpecifier = exportSpecifiers_2[_i]; if (exportSpecifier.name.text !== excludeName) { statements = appendExportStatement(statements, exportSpecifier.name, name); } @@ -55471,43 +58378,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: return visitVariableStatement(node); - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return visitClassDeclaration(node); - case 211 /* ForStatement */: + case 213 /* ForStatement */: return visitForStatement(node); - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: return visitForInStatement(node); - case 213 /* ForOfStatement */: + case 215 /* ForOfStatement */: return visitForOfStatement(node); - case 209 /* DoStatement */: + case 211 /* DoStatement */: return visitDoStatement(node); - case 210 /* WhileStatement */: + case 212 /* WhileStatement */: return visitWhileStatement(node); - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return visitLabeledStatement(node); - case 217 /* WithStatement */: + case 219 /* WithStatement */: return visitWithStatement(node); - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: return visitSwitchStatement(node); - case 232 /* CaseBlock */: + case 234 /* CaseBlock */: return visitCaseBlock(node); - case 253 /* CaseClause */: + case 256 /* CaseClause */: return visitCaseClause(node); - case 254 /* DefaultClause */: + case 257 /* DefaultClause */: return visitDefaultClause(node); - case 221 /* TryStatement */: + case 223 /* TryStatement */: return visitTryStatement(node); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return visitCatchClause(node); - case 204 /* Block */: + case 206 /* Block */: return visitBlock(node); - case 295 /* MergeDeclarationMarker */: + case 299 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 296 /* EndOfDeclarationMarker */: + case 300 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -55687,7 +58594,7 @@ var ts; */ function destructuringVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 192 /* BinaryExpression */) { + && node.kind === 193 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (node.transformFlags & 2048 /* ContainsDestructuringAssignment */) { @@ -55735,7 +58642,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 261 /* SourceFile */; + return container !== undefined && container.kind === 264 /* SourceFile */; } else { return false; @@ -55763,12 +58670,12 @@ var ts; /** * Hook for node emit notifications. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. - * @param emit A callback used to emit the node in the printer. + * @param emitCallback A callback used to emit the node in the printer. */ - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261 /* SourceFile */) { + function onEmitNode(hint, node, emitCallback) { + if (node.kind === 264 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -55777,14 +58684,14 @@ var ts; if (noSubstitution) { delete noSubstitutionMap[id]; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } // @@ -55793,15 +58700,15 @@ var ts; /** * Hooks node substitutions. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); if (isSubstitutionPrevented(node)) { return node; } - if (emitContext === 1 /* Expression */) { + if (hint === 1 /* Expression */) { return substituteExpression(node); } return node; @@ -55815,10 +58722,10 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return substituteExpressionIdentifier(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return substituteBinaryExpression(node); - case 190 /* PrefixUnaryExpression */: - case 191 /* PostfixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -55846,1072 +58753,11 @@ var ts; var importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), /*location*/ node); } else if (ts.isImportSpecifier(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name), - /*location*/ node); - } - } - } - return node; - } - /** - * Substitution for a BinaryExpression that may contain an imported or exported symbol. - * - * @param node The node to substitute. - */ - function substituteBinaryExpression(node) { - // When we see an assignment expression whose left-hand side is an exported symbol, - // we should ensure all exports of that symbol are updated with the correct value. - // - // - We do not substitute generated identifiers for any reason. - // - We do not substitute identifiers tagged with the LocalName flag. - // - We do not substitute identifiers that were originally the name of an enum or - // namespace due to how they are transformed in TypeScript. - // - We only substitute identifiers that are exported at the top level. - if (ts.isAssignmentOperator(node.operatorToken.kind) - && ts.isIdentifier(node.left) - && !ts.isGeneratedIdentifier(node.left) - && !ts.isLocalName(node.left) - && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { - var exportedNames = getExports(node.left); - if (exportedNames) { - // For each additional export of the declaration, apply an export assignment. - var expression = node; - for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { - var exportName = exportedNames_1[_i]; - expression = createExportExpression(exportName, preventSubstitution(expression)); - } - return expression; - } - } - return node; - } - /** - * Substitution for a UnaryExpression that may contain an imported or exported symbol. - * - * @param node The node to substitute. - */ - function substituteUnaryExpression(node) { - // When we see a prefix or postfix increment expression whose operand is an exported - // symbol, we should ensure all exports of that symbol are updated with the correct - // value. - // - // - We do not substitute generated identifiers for any reason. - // - We do not substitute identifiers tagged with the LocalName flag. - // - We do not substitute identifiers that were originally the name of an enum or - // namespace due to how they are transformed in TypeScript. - // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) - && ts.isIdentifier(node.operand) - && !ts.isGeneratedIdentifier(node.operand) - && !ts.isLocalName(node.operand) - && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { - var exportedNames = getExports(node.operand); - if (exportedNames) { - var expression = node.kind === 191 /* PostfixUnaryExpression */ - ? ts.createPrefix(node.operator, node.operand, - /*location*/ node) - : node; - for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { - var exportName = exportedNames_2[_i]; - expression = createExportExpression(exportName, preventSubstitution(expression)); - } - if (node.kind === 191 /* PostfixUnaryExpression */) { - expression = node.operator === 42 /* PlusPlusToken */ - ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) - : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); - } - return expression; - } - } - return node; - } - /** - * Gets the exports of a name. - * - * @param name The name. - */ - function getExports(name) { - var exportedNames; - if (!ts.isGeneratedIdentifier(name)) { - var valueDeclaration = resolver.getReferencedImportDeclaration(name) - || resolver.getReferencedValueDeclaration(name); - if (valueDeclaration) { - var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 261 /* SourceFile */) { - exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); - } - exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); - } - } - return exportedNames; - } - /** - * Prevent substitution of a node for this transformer. - * - * @param node The node which should not be substituted. - */ - function preventSubstitution(node) { - if (noSubstitution === undefined) - noSubstitution = ts.createMap(); - noSubstitution[ts.getNodeId(node)] = true; - return node; - } - /** - * Determines whether a node should not be substituted. - * - * @param node The node to test. - */ - function isSubstitutionPrevented(node) { - return noSubstitution && node.id && noSubstitution[node.id]; - } - } - ts.transformSystemModule = transformSystemModule; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var moduleKind = ts.getEmitModuleKind(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(258 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(261 /* SourceFile */); // Restore state when substituting nodes in a file. - var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. - var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. - var currentSourceFile; // The current file. - var currentModuleInfo; // The ExternalModuleInfo for the current file. - var noSubstitution; // Set of nodes for which substitution rules should be ignored. - return transformSourceFile; - /** - * Transforms the module aspects of a SourceFile. - * - * @param node The SourceFile node. - */ - function transformSourceFile(node) { - if (ts.isDeclarationFile(node) - || !(ts.isExternalModule(node) - || compilerOptions.isolatedModules)) { - return node; - } - currentSourceFile = node; - currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(node)] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); - // Perform the transformation. - var transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; - var updated = transformModule(node); - currentSourceFile = undefined; - currentModuleInfo = undefined; - return ts.aggregateTransformFlags(updated); - } - /** - * Transforms a SourceFile into a CommonJS module. - * - * @param node The SourceFile node. - */ - function transformCommonJSModule(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); - ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); - var updated = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); - if (currentModuleInfo.hasExportStarsToExportValues) { - ts.addEmitHelper(updated, exportStarHelper); - } - return updated; - } - /** - * Transforms a SourceFile into an AMD module. - * - * @param node The SourceFile node. - */ - function transformAMDModule(node) { - var define = ts.createIdentifier("define"); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); - } - /** - * Transforms a SourceFile into a UMD module. - * - * @param node The SourceFile node. - */ - function transformUMDModule(node) { - var define = ts.createRawExpression(umdHelper); - return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); - } - /** - * Transforms a SourceFile into an AMD or UMD module. - * - * @param node The SourceFile node. - * @param define The expression used to define the module. - * @param moduleName An expression for the module name, if available. - * @param includeNonAmdDependencies A value indicating whether to incldue any non-AMD dependencies. - */ - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - // An AMD define function has the following shape: - // - // define(id?, dependencies?, factory); - // - // This has the shape of the following: - // - // define(name, ["module1", "module2"], function (module1Alias) { ... } - // - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. - // - // To ensure this is true in cases of modules with no aliases, e.g.: - // - // import "module" - // - // or - // - // /// - // - // we need to add modules without alias names to the end of the dependencies list - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - // Create an updated SourceFile: - // - // define(moduleName?, ["module1", "module2"], function ... - return ts.updateSourceFileNode(node, ts.createNodeArray([ - ts.createStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - // Add the dependency array argument: - // - // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral([ - ts.createLiteral("require"), - ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), - // Add the module body function argument: - // - // function (require, exports, module1, module2) ... - ts.createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ - ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), - ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), - /*type*/ undefined, transformAsynchronousModuleBody(node)) - ]))) - ], - /*location*/ node.statements)); - } - /** - * Collect the additional asynchronous dependencies for the module. - * - * @param node The source file. - * @param includeNonAmdDependencies A value indicating whether to include non-AMD dependencies. - */ - function collectAsynchronousDependencies(node, includeNonAmdDependencies) { - // names of modules with corresponding parameter in the factory function - var aliasedModuleNames = []; - // names of modules with no corresponding parameters in factory function - var unaliasedModuleNames = []; - // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding - // module names in aliasedModuleNames. - var importAliasNames = []; - // Fill in amd-dependency tags - for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { - var amdDependency = _a[_i]; - if (amdDependency.name) { - aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, amdDependency.name)); - } - else { - unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - } - } - for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) { - var importNode = _c[_b]; - // Find the name of the external module - var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - // Find the name of the module alias, if there is one - var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - // Set emitFlags on the name of the classDeclaration - // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; - } - /** - * Transforms a SourceFile into an AMD or UMD module body. - * - * @param node The SourceFile node. - */ - function transformAsynchronousModuleBody(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - // Visit each statement of the module body. - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); - ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - // End the lexical environment for the module body - // and merge any new lexical declarations. - ts.addRange(statements, endLexicalEnvironment()); - // Append the 'export =' statement if provided. - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); - var body = ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); - if (currentModuleInfo.hasExportStarsToExportValues) { - // If we have any `export * from ...` declarations - // we need to inform the emitter to add the __export helper. - ts.addEmitHelper(body, exportStarHelper); - } - return body; - } - /** - * Adds the down-level representation of `export=` to the statement list if one exists - * in the source file. - * - * @param statements The Statement list to modify. - * @param emitAsReturn A value indicating whether to emit the `export=` statement as a - * return statement. - */ - function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (currentModuleInfo.exportEquals) { - if (emitAsReturn) { - var statement = ts.createReturn(currentModuleInfo.exportEquals.expression, - /*location*/ currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression), - /*location*/ currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536 /* NoComments */); - statements.push(statement); - } - } - } - // - // Top-Level Source Element Visitors - // - /** - * Visits a node at the top level of the source file. - * - * @param node The node to visit. - */ - function sourceElementVisitor(node) { - switch (node.kind) { - case 235 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 234 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 241 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 240 /* ExportAssignment */: - return visitExportAssignment(node); - case 205 /* VariableStatement */: - return visitVariableStatement(node); - case 225 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 226 /* ClassDeclaration */: - return visitClassDeclaration(node); - case 295 /* MergeDeclarationMarker */: - return visitMergeDeclarationMarker(node); - case 296 /* EndOfDeclarationMarker */: - return visitEndOfDeclarationMarker(node); - default: - // This visitor does not descend into the tree, as export/import statements - // are only transformed at the top level of a file. - return node; - } - } - /** - * Visits an ImportDeclaration node. - * - * @param node The node to visit. - */ - function visitImportDeclaration(node) { - var statements; - var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); - if (moduleKind !== ts.ModuleKind.AMD) { - if (!node.importClause) { - // import "mod"; - return ts.createStatement(createRequireCall(node), /*location*/ node); - } - else { - var variables = []; - if (namespaceDeclaration && !ts.isDefaultImport(node)) { - // import * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, createRequireCall(node))); - } - else { - // import d from "mod"; - // import { x, y } from "mod"; - // import d, { x, y } from "mod"; - // import d, * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), - /*type*/ undefined, createRequireCall(node))); - if (namespaceDeclaration && ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node))); - } - } - statements = ts.append(statements, ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList(variables, - /*location*/ undefined, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */), - /*location*/ node)); - } - } - else if (namespaceDeclaration && ts.isDefaultImport(node)) { - // import d, * as n from "mod"; - statements = ts.append(statements, ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node), - /*location*/ node) - ], - /*location*/ undefined, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfImportDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Creates a `require()` call to import an external module. - * - * @param importNode The declararation to import. - */ - function createRequireCall(importNode) { - var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var args = []; - if (moduleName) { - args.push(moduleName); - } - return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); - } - /** - * Visits an ImportEqualsDeclaration node. - * - * @param node The node to visit. - */ - function visitImportEqualsDeclaration(node) { - ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); - var statements; - if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(node.name, createRequireCall(node)), - /*location*/ node)); - } - else { - statements = ts.append(statements, ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), - /*type*/ undefined, createRequireCall(node)) - ], - /*location*/ undefined, - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */), - /*location*/ node)); - } - } - else { - if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node)), - /*location*/ node)); - } - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfImportEqualsDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Visits an ExportDeclaration node. - * - * @param The node to visit. - */ - function visitExportDeclaration(node) { - if (!node.moduleSpecifier) { - // Elide export declarations with no module specifier as they are handled - // elsewhere. - return undefined; - } - var generatedName = ts.getGeneratedNameForNode(node); - if (node.exportClause) { - var statements = []; - // export { x, y } from "mod"; - if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(generatedName, - /*type*/ undefined, createRequireCall(node)) - ]), - /*location*/ node)); - } - for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { - var specifier = _a[_i]; - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue), - /*location*/ specifier)); - } - return ts.singleOrMany(statements); - } - else { - // export * from "mod"; - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), - /*typeArguments*/ undefined, [ - moduleKind !== ts.ModuleKind.AMD - ? createRequireCall(node) - : generatedName - ]), - /*location*/ node); - } - } - /** - * Visits an ExportAssignment node. - * - * @param node The node to visit. - */ - function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; - } - var statements; - var original = node.original; - if (original && hasAssociatedEndOfDeclarationMarker(original)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); - } - else { - statements = appendExportStatement(statements, ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); - } - return ts.singleOrMany(statements); - } - /** - * Visits a FunctionDeclaration node. - * - * @param node The node to visit. - */ - function visitFunctionDeclaration(node) { - var statements; - if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createFunctionDeclaration( - /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), - /*typeParameters*/ undefined, node.parameters, - /*type*/ undefined, node.body, - /*location*/ node), - /*original*/ node)); - } - else { - statements = ts.append(statements, node); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfHoistedDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Visits a ClassDeclaration node. - * - * @param node The node to visit. - */ - function visitClassDeclaration(node) { - var statements; - if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setOriginalNode(ts.createClassDeclaration( - /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), - /*typeParameters*/ undefined, node.heritageClauses, node.members, - /*location*/ node), - /*original*/ node)); - } - else { - statements = ts.append(statements, node); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); - } - else { - statements = appendExportsOfHoistedDeclaration(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Visits a VariableStatement node. - * - * @param node The node to visit. - */ - function visitVariableStatement(node) { - var statements; - var variables; - var expressions; - if (ts.hasModifier(node, 1 /* Export */)) { - var modifiers = void 0; - // If we're exporting these variables, then these just become assignments to 'exports.x'. - // We only want to emit assignments for variables with initializers. - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { - if (!modifiers) { - modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); - } - variables = ts.append(variables, variable); - } - else if (variable.initializer) { - expressions = ts.append(expressions, transformInitializedVariable(variable)); - } - } - if (variables) { - statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); - } - if (expressions) { - statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), /*location*/ node)); - } - } - else { - statements = ts.append(statements, node); - } - if (hasAssociatedEndOfDeclarationMarker(node)) { - // Defer exports until we encounter an EndOfDeclarationMarker node - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); - } - else { - statements = appendExportsOfVariableStatement(statements, node); - } - return ts.singleOrMany(statements); - } - /** - * Transforms an exported variable with an initializer into an expression. - * - * @param node The node to transform. - */ - function transformInitializedVariable(node) { - if (ts.isBindingPattern(node.name)) { - return ts.flattenDestructuringAssignment(node, - /*visitor*/ undefined, context, 0 /* All */, - /*needsValue*/ false, createExportExpression); - } - else { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name, - /*location*/ node.name), node.initializer); - } - } - /** - * Visits a MergeDeclarationMarker used as a placeholder for the beginning of a merged - * and transformed declaration. - * - * @param node The node to visit. - */ - function visitMergeDeclarationMarker(node) { - // For an EnumDeclaration or ModuleDeclaration that merges with a preceeding - // declaration we do not emit a leading variable declaration. To preserve the - // begin/end semantics of the declararation and to properly handle exports - // we wrapped the leading variable declaration in a `MergeDeclarationMarker`. - // - // To balance the declaration, add the exports of the elided variable - // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 205 /* VariableStatement */) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); - } - return node; - } - /** - * Determines whether a node has an associated EndOfDeclarationMarker. - * - * @param node The node to test. - */ - function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 2097152 /* HasEndOfDeclarationMarker */) !== 0; - } - /** - * Visits a DeclarationMarker used as a placeholder for the end of a transformed - * declaration. - * - * @param node The node to visit. - */ - function visitEndOfDeclarationMarker(node) { - // For some transformations we emit an `EndOfDeclarationMarker` to mark the actual - // end of the transformed declaration. We use this marker to emit any deferred exports - // of the declaration. - var id = ts.getOriginalNodeId(node); - var statements = deferredExports[id]; - if (statements) { - delete deferredExports[id]; - return ts.append(statements, node); - } - return node; - } - /** - * Appends the exports of an ImportDeclaration to a statement list, returning the - * statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration whose exports are to be recorded. - */ - function appendExportsOfImportDeclaration(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - var importClause = decl.importClause; - if (!importClause) { - return statements; - } - if (importClause.name) { - statements = appendExportsOfDeclaration(statements, importClause); - } - var namedBindings = importClause.namedBindings; - if (namedBindings) { - switch (namedBindings.kind) { - case 237 /* NamespaceImport */: - statements = appendExportsOfDeclaration(statements, namedBindings); - break; - case 238 /* NamedImports */: - for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { - var importBinding = _a[_i]; - statements = appendExportsOfDeclaration(statements, importBinding); - } - break; - } - } - return statements; - } - /** - * Appends the exports of an ImportEqualsDeclaration to a statement list, returning the - * statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration whose exports are to be recorded. - */ - function appendExportsOfImportEqualsDeclaration(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - return appendExportsOfDeclaration(statements, decl); - } - /** - * Appends the exports of a VariableStatement to a statement list, returning the statement - * list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param node The VariableStatement whose exports are to be recorded. - */ - function appendExportsOfVariableStatement(statements, node) { - if (currentModuleInfo.exportEquals) { - return statements; - } - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - statements = appendExportsOfBindingElement(statements, decl); - } - return statements; - } - /** - * Appends the exports of a VariableDeclaration or BindingElement to a statement list, - * returning the statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration whose exports are to be recorded. - */ - function appendExportsOfBindingElement(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - if (ts.isBindingPattern(decl.name)) { - for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - statements = appendExportsOfBindingElement(statements, element); - } - } - } - else if (!ts.isGeneratedIdentifier(decl.name)) { - statements = appendExportsOfDeclaration(statements, decl); - } - return statements; - } - /** - * Appends the exports of a ClassDeclaration or FunctionDeclaration to a statement list, - * returning the statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration whose exports are to be recorded. - */ - function appendExportsOfHoistedDeclaration(statements, decl) { - if (currentModuleInfo.exportEquals) { - return statements; - } - if (ts.hasModifier(decl, 1 /* Export */)) { - var exportName = ts.hasModifier(decl, 512 /* Default */) ? ts.createIdentifier("default") : decl.name; - statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), /*location*/ decl); - } - if (decl.name) { - statements = appendExportsOfDeclaration(statements, decl); - } - return statements; - } - /** - * Appends the exports of a declaration to a statement list, returning the statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param decl The declaration to export. - */ - function appendExportsOfDeclaration(statements, decl) { - var name = ts.getDeclarationName(decl); - var exportSpecifiers = currentModuleInfo.exportSpecifiers[name.text]; - if (exportSpecifiers) { - for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { - var exportSpecifier = exportSpecifiers_2[_i]; - statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name); - } - } - return statements; - } - /** - * Appends the down-level representation of an export to a statement list, returning the - * statement list. - * - * @param statements A statement list to which the down-level export statements are to be - * appended. If `statements` is `undefined`, a new array is allocated if statements are - * appended. - * @param exportName The name of the export. - * @param expression The expression to export. - * @param location The location to use for source maps and comments for the export. - * @param allowComments Whether to allow comments on the export. - */ - function appendExportStatement(statements, exportName, expression, location, allowComments) { - if (exportName.text === "default") { - var sourceFile = ts.getOriginalNode(currentSourceFile, ts.isSourceFile); - if (sourceFile && !sourceFile.symbol.exports["___esModule"]) { - if (languageVersion === 0 /* ES3 */) { - statements = ts.append(statements, ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); - } - else { - statements = ts.append(statements, ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), - /*typeArguments*/ undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); - } - } - } - statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); - return statements; - } - /** - * Creates a call to the current file's export function to export a value. - * - * @param name The bound name of the export. - * @param value The exported value. - * @param location The location to use for source maps and comments for the export. - * @param allowComments An optional value indicating whether to emit comments for the statement. - */ - function createExportStatement(name, value, location, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value), location); - ts.startOnNewLine(statement); - if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); - } - return statement; - } - /** - * Creates a call to the current file's export function to export a value. - * - * @param name The bound name of the export. - * @param value The exported value. - * @param location The location to use for source maps and comments for the export. - */ - function createExportExpression(name, value, location) { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value, location); - } - // - // Modifier Visitors - // - /** - * Visit nodes to elide module-specific modifiers. - * - * @param node The node to visit. - */ - function modifierVisitor(node) { - // Elide module-specific modifiers. - switch (node.kind) { - case 83 /* ExportKeyword */: - case 78 /* DefaultKeyword */: - return undefined; - } - return node; - } - // - // Emit Notification - // - /** - * Hook for node emit notifications. - * - * @param emitContext A context hint for the emitter. - * @param node The node to emit. - * @param emit A callback used to emit the node in the printer. - */ - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 261 /* SourceFile */) { - currentSourceFile = node; - currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; - noSubstitution = ts.createMap(); - previousOnEmitNode(emitContext, node, emitCallback); - currentSourceFile = undefined; - currentModuleInfo = undefined; - noSubstitution = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - // - // Substitutions - // - /** - * Hooks node substitutions. - * - * @param emitContext A context hint for the emitter. - * @param node The node to substitute. - */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (node.id && noSubstitution[node.id]) { - return node; - } - if (emitContext === 1 /* Expression */) { - return substituteExpression(node); - } - else if (ts.isShorthandPropertyAssignment(node)) { - return substituteShorthandPropertyAssignment(node); - } - return node; - } - /** - * Substitution for a ShorthandPropertyAssignment whose declaration name is an imported - * or exported symbol. - * - * @param node The node to substitute. - */ - function substituteShorthandPropertyAssignment(node) { - var name = node.name; - var exportedOrImportedName = substituteExpressionIdentifier(name); - if (exportedOrImportedName !== name) { - // A shorthand property with an assignment initializer is probably part of a - // destructuring assignment - if (node.objectAssignmentInitializer) { - var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, /*location*/ node); - } - return ts.createPropertyAssignment(name, exportedOrImportedName, /*location*/ node); - } - return node; - } - /** - * Substitution for an Expression that may contain an imported or exported symbol. - * - * @param node The node to substitute. - */ - function substituteExpression(node) { - switch (node.kind) { - case 70 /* Identifier */: - return substituteExpressionIdentifier(node); - case 192 /* BinaryExpression */: - return substituteBinaryExpression(node); - case 191 /* PostfixUnaryExpression */: - case 190 /* PrefixUnaryExpression */: - return substituteUnaryExpression(node); - } - return node; - } - /** - * Substitution for an Identifier expression that may contain an imported or exported - * symbol. - * - * @param node The node to substitute. - */ - function substituteExpressionIdentifier(node) { - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) { - return ts.createPropertyAccess(externalHelpersModuleName, node); - } - return node; - } - if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { - var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 261 /* SourceFile */) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), - /*location*/ node); - } - var importDeclaration = resolver.getReferencedImportDeclaration(node); - if (importDeclaration) { - if (ts.isImportClause(importDeclaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), - /*location*/ node); - } - else if (ts.isImportSpecifier(importDeclaration)) { - var name_38 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_38), + return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name)), /*location*/ node); } } @@ -56943,9 +58789,7 @@ var ts; var expression = node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { var exportName = exportedNames_3[_i]; - // Mark the node to prevent triggering this rule again. - noSubstitution[ts.getNodeId(expression)] = true; - expression = createExportExpression(exportName, expression, /*location*/ node); + expression = createExportExpression(exportName, preventSubstitution(expression)); } return expression; } @@ -56974,15 +58818,17 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 191 /* PostfixUnaryExpression */ - ? ts.createBinary(node.operand, ts.createToken(node.operator === 42 /* PlusPlusToken */ ? 58 /* PlusEqualsToken */ : 59 /* MinusEqualsToken */), ts.createLiteral(1), - /*location*/ node) + var expression = node.kind === 192 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { var exportName = exportedNames_4[_i]; - // Mark the node to prevent triggering this rule again. - noSubstitution[ts.getNodeId(expression)] = true; - expression = createExportExpression(exportName, expression); + expression = createExportExpression(exportName, preventSubstitution(expression)); + } + if (node.kind === 192 /* PostfixUnaryExpression */) { + expression = node.operator === 42 /* PlusPlusToken */ + ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) + : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } return expression; } @@ -56990,31 +58836,144 @@ var ts; return node; } /** - * Gets the additional exports of a name. + * Gets the exports of a name. * * @param name The name. */ function getExports(name) { + var exportedNames; if (!ts.isGeneratedIdentifier(name)) { var valueDeclaration = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { - return currentModuleInfo - && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; + var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); + if (exportContainer && exportContainer.kind === 264 /* SourceFile */) { + exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); + } + exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); } } + return exportedNames; + } + /** + * Prevent substitution of a node for this transformer. + * + * @param node The node which should not be substituted. + */ + function preventSubstitution(node) { + if (noSubstitution === undefined) + noSubstitution = []; + noSubstitution[ts.getNodeId(node)] = true; + return node; + } + /** + * Determines whether a node should not be substituted. + * + * @param node The node to test. + */ + function isSubstitutionPrevented(node) { + return noSubstitution && node.id && noSubstitution[node.id]; } - var _a; } - ts.transformModule = transformModule; - // emit output for the __export helper function - var exportStarHelper = { - name: "typescript:export-star", - scoped: true, - text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" - }; - // emit output for the UMD helper function. - var umdHelper = "\n (function (dependencies, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(dependencies, factory);\n }\n })"; + ts.transformSystemModule = transformSystemModule; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformES2015Module(context) { + var compilerOptions = context.getCompilerOptions(); + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.enableEmitNotification(264 /* SourceFile */); + context.enableSubstitution(70 /* Identifier */); + var currentSourceFile; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); + if (externalHelpersModuleName) { + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements); + ts.append(statements, ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); + } + else { + return ts.visitEachChild(node, visitor, context); + } + } + return node; + } + function visitor(node) { + switch (node.kind) { + case 236 /* ImportEqualsDeclaration */: + // Elide `import=` as it is not legal with --module ES6 + return undefined; + case 242 /* ExportAssignment */: + return visitExportAssignment(node); + } + return node; + } + function visitExportAssignment(node) { + // Elide `export=` as it is not legal with --module ES6 + return node.isExportEquals ? undefined : node; + } + // + // Emit Notification + // + /** + * Hook for node emit. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to emit. + * @param emit A callback used to emit the node in the printer. + */ + function onEmitNode(hint, node, emitCallback) { + if (ts.isSourceFile(node)) { + currentSourceFile = node; + previousOnEmitNode(hint, node, emitCallback); + currentSourceFile = undefined; + } + else { + previousOnEmitNode(hint, node, emitCallback); + } + } + // + // Substitutions + // + /** + * Hooks node substitutions. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to substitute. + */ + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (ts.isIdentifier(node) && hint === 1 /* Expression */) { + return substituteExpressionIdentifier(node); + } + return node; + } + function substituteExpressionIdentifier(node) { + if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); + if (externalHelpersModuleName) { + return ts.createPropertyAccess(externalHelpersModuleName, node); + } + } + return node; + } + } + ts.transformES2015Module = transformES2015Module; })(ts || (ts = {})); /// /// @@ -57031,14 +58990,16 @@ var ts; /* @internal */ var ts; (function (ts) { - var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, - _a[ts.ModuleKind.System] = ts.transformSystemModule, - _a[ts.ModuleKind.AMD] = ts.transformModule, - _a[ts.ModuleKind.CommonJS] = ts.transformModule, - _a[ts.ModuleKind.UMD] = ts.transformModule, - _a[ts.ModuleKind.None] = ts.transformModule, - _a)); + function getModuleTransformer(moduleKind) { + switch (moduleKind) { + case ts.ModuleKind.ES2015: + return ts.transformES2015Module; + case ts.ModuleKind.System: + return ts.transformSystemModule; + default: + return ts.transformModule; + } + } var SyntaxKindFeatureFlags; (function (SyntaxKindFeatureFlags) { SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; @@ -57066,7 +59027,7 @@ var ts; transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } - transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); + transformers.push(getModuleTransformer(moduleKind)); // The ES5 transformer is last so that it can substitute expressions like `exports.default` // for ES3. if (languageVersion < 1 /* ES5 */) { @@ -57084,7 +59045,7 @@ var ts; * @param transforms An array of Transformers. */ function transformFiles(resolver, host, sourceFiles, transformers) { - var enabledSyntaxKindFeatures = new Array(298 /* Count */); + var enabledSyntaxKindFeatures = new Array(301 /* Count */); var lexicalEnvironmentDisabled = false; var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; @@ -57107,19 +59068,22 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, - onSubstituteNode: function (_emitContext, node) { return node; }, + onSubstituteNode: function (_, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, + onEmitNode: function (hint, node, callback) { return callback(hint, node); }, enableEmitNotification: enableEmitNotification, isEmitNotificationEnabled: isEmitNotificationEnabled }; + ts.performance.mark("beforeTransform"); // Chain together and initialize each transformer. var transformation = ts.chain.apply(void 0, transformers)(context); // Transform each source file. var transformed = ts.map(sourceFiles, transformSourceFile); // Disable modification of the lexical environment. lexicalEnvironmentDisabled = true; + ts.performance.mark("afterTransform"); + ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { transformed: transformed, emitNodeWithSubstitution: emitNodeWithSubstitution, @@ -57152,20 +59116,16 @@ var ts; /** * Emits a node with possible substitution. * - * @param emitContext The current emit context. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emitCallback The callback used to emit the node or its substitute. */ - function emitNodeWithSubstitution(emitContext, node, emitCallback) { + function emitNodeWithSubstitution(hint, node, emitCallback) { if (node) { if (isSubstitutionEnabled(node)) { - var substitute = context.onSubstituteNode(emitContext, node); - if (substitute && substitute !== node) { - emitCallback(emitContext, substitute); - return; - } + node = context.onSubstituteNode(hint, node) || node; } - emitCallback(emitContext, node); + emitCallback(hint, node); } } /** @@ -57185,17 +59145,17 @@ var ts; /** * Emits a node with possible emit notification. * - * @param emitContext The current emit context. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emitCallback The callback used to emit the node. */ - function emitNodeWithNotification(emitContext, node, emitCallback) { + function emitNodeWithNotification(hint, node, emitCallback) { if (node) { if (isEmitNotificationEnabled(node)) { - context.onEmitNode(emitContext, node, emitCallback); + context.onEmitNode(hint, node, emitCallback); } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } } @@ -57299,7 +59259,6 @@ var ts; } } ts.transformFiles = transformFiles; - var _a; })(ts || (ts = {})); /// /* @internal */ @@ -57344,10 +59303,9 @@ var ts; * * @param filePath The path to the generated output file. * @param sourceMapFilePath The path to the output source map file. - * @param sourceFiles The input source files for the program. - * @param isBundledEmit A value indicating whether the generated output file is a bundle. + * @param sourceFileOrBundle The input source file or bundle for the program. */ - function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { + function initialize(filePath, sourceMapFilePath, sourceFileOrBundle) { if (disabled) { return; } @@ -57383,11 +59341,10 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (!isBundledEmit) { - ts.Debug.assert(sourceFiles.length === 1); + if (sourceFileOrBundle.kind === 264 /* SourceFile */) { // 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(sourceFiles[0], host, sourceMapDir)); + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { // The relative paths are relative to the common directory @@ -57510,31 +59467,32 @@ var ts; /** * Emits a node with possible leading and trailing source maps. * + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emitCallback The callback used to emit the node. */ - function emitNodeWithSourceMap(emitContext, node, emitCallback) { + function emitNodeWithSourceMap(hint, node, emitCallback) { if (disabled) { - return emitCallback(emitContext, node); + return emitCallback(hint, node); } if (node) { var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 293 /* NotEmittedStatement */ + if (node.kind !== 297 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); } if (emitFlags & 64 /* NoNestedSourceMaps */) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } - if (node.kind !== 293 /* NotEmittedStatement */ + if (node.kind !== 297 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -57669,11 +59627,10 @@ var ts; /* @internal */ var ts; (function (ts) { - function createCommentWriter(host, writer, sourceMap) { - var compilerOptions = host.getCompilerOptions(); - var extendedDiagnostics = compilerOptions.extendedDiagnostics; - var newLine = host.getNewLine(); - var emitPos = sourceMap.emitPos; + function createCommentWriter(printerOptions, emitPos) { + var extendedDiagnostics = printerOptions.extendedDiagnostics; + var newLine = ts.getNewLineCharacter(printerOptions); + var writer; var containerPos = -1; var containerEnd = -1; var declarationListContainerEnd = -1; @@ -57682,17 +59639,19 @@ var ts; var currentLineMap; var detachedCommentsInfo; var hasWrittenComment = false; - var disabled = compilerOptions.removeComments; + var disabled = printerOptions.removeComments; return { reset: reset, + setWriter: setWriter, setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, + emitLeadingCommentsOfPosition: emitLeadingCommentsOfPosition, }; - function emitNodeWithComments(emitContext, node, emitCallback) { + function emitNodeWithComments(hint, node, emitCallback) { if (disabled) { - emitCallback(emitContext, node); + emitCallback(hint, node); return; } if (node) { @@ -57702,18 +59661,18 @@ var ts; // Both pos and end are synthesized, so just emit the node without comments. if (emitFlags & 2048 /* NoNestedComments */) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } else { if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 293 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 297 /* NotEmittedStatement */; var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; // Emit leading comments if the position is not synthesized and the node @@ -57732,7 +59691,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 224 /* VariableDeclarationList */) { + if (node.kind === 226 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -57741,11 +59700,11 @@ var ts; } if (emitFlags & 2048 /* NoNestedComments */) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } if (extendedDiagnostics) { ts.performance.mark("beginEmitNodeWithComment"); @@ -57828,9 +59787,11 @@ var ts; hasWrittenComment = true; } // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -57838,6 +59799,12 @@ var ts; writer.write(" "); } } + function emitLeadingCommentsOfPosition(pos) { + if (disabled || pos === -1) { + return; + } + emitLeadingComments(pos, /*isEmittedNode*/ true); + } function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } @@ -57846,9 +59813,11 @@ var ts; if (!writer.isAtStartOfLine()) { writer.write(" "); } - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -57867,9 +59836,11 @@ var ts; } function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); } @@ -57900,6 +59871,9 @@ var ts; currentLineMap = undefined; detachedCommentsInfo = undefined; } + function setWriter(output) { + writer = output; + } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; currentText = currentSourceFile.text; @@ -57932,9 +59906,11 @@ var ts; } } function writeComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - emitPos(commentPos); + if (emitPos) + emitPos(commentPos); ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) + emitPos(commentEnd); } /** * Determine if the given comment is a triple-slash @@ -57963,15 +59939,17 @@ var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, targetSourceFile) { var declarationDiagnostics = ts.createDiagnosticCollection(); - ts.forEachExpectedEmitFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); + ts.forEachEmittedFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined); - function getDeclarationDiagnosticsFromFile(_a, sources, isBundledEmit) { + function getDeclarationDiagnosticsFromFile(_a, sourceFileOrBundle) { var declarationFilePath = _a.declarationFilePath; - emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit, /*emitOnlyDtsFiles*/ false); + emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sourceFileOrBundle, /*emitOnlyDtsFiles*/ false); } } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles) { + function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles) { + var sourceFiles = sourceFileOrBundle.kind === 265 /* Bundle */ ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var isBundledEmit = sourceFileOrBundle.kind === 265 /* Bundle */; var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -58045,7 +60023,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 235 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 237 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -58071,9 +60049,9 @@ var ts; } }); if (usedTypeDirectiveReferences) { - for (var directive in usedTypeDirectiveReferences) { + ts.forEachKey(usedTypeDirectiveReferences, function (directive) { referencesOutput += "/// " + newLine; - } + }); } return { reportedDeclarationError: reportedDeclarationError, @@ -58098,6 +60076,7 @@ var ts; var writer = ts.createTextWriter(newLine); writer.trackSymbol = trackSymbol; writer.reportInaccessibleThisError = reportInaccessibleThisError; + writer.reportIllegalExtends = reportIllegalExtends; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -58120,10 +60099,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 223 /* VariableDeclaration */) { + if (declaration.kind === 225 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 238 /* NamedImports */ || declaration.kind === 239 /* ImportSpecifier */ || declaration.kind === 236 /* ImportClause */) { + else if (declaration.kind === 240 /* NamedImports */ || declaration.kind === 241 /* ImportSpecifier */ || declaration.kind === 238 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -58141,7 +60120,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 === 235 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 237 /* 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; @@ -58151,12 +60130,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 230 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 232 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 230 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 232 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -58175,8 +60154,8 @@ var ts; } for (var _i = 0, typeReferenceDirectives_1 = typeReferenceDirectives; _i < typeReferenceDirectives_1.length; _i++) { var directive = typeReferenceDirectives_1[_i]; - if (!(directive in usedTypeDirectiveReferences)) { - usedTypeDirectiveReferences[directive] = directive; + if (!usedTypeDirectiveReferences.has(directive)) { + usedTypeDirectiveReferences.set(directive, directive); } } } @@ -58205,6 +60184,12 @@ var ts; handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); } + function reportIllegalExtends() { + if (errorNameNode) { + reportedDeclarationError = true; + emitterDiagnostics.add(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced, ts.declarationNameToString(errorNameNode))); + } + } function reportInaccessibleThisError() { if (errorNameNode) { reportedDeclarationError = true; @@ -58214,13 +60199,19 @@ var ts; function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); - if (type) { + // use the checker's type, not the declared type, + // for non-optional initialized parameters that aren't a parameter property + var shouldUseResolverType = declaration.kind === 145 /* Parameter */ && + resolver.isRequiredInitializedParameter(declaration); + if (type && !shouldUseResolverType) { // Write the type emitType(type); } else { errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); + var format = 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */ | + (shouldUseResolverType ? 4096 /* AddUndefined */ : 0); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer); errorNameNode = undefined; } } @@ -58274,49 +60265,50 @@ var ts; function emitType(type) { switch (type.kind) { case 118 /* AnyKeyword */: - case 134 /* StringKeyword */: + case 135 /* StringKeyword */: case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 135 /* SymbolKeyword */: + case 133 /* ObjectKeyword */: + case 136 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 137 /* UndefinedKeyword */: + case 138 /* UndefinedKeyword */: case 94 /* NullKeyword */: case 129 /* NeverKeyword */: - case 167 /* ThisType */: - case 171 /* LiteralType */: + case 168 /* ThisType */: + case 172 /* LiteralType */: return writeTextOfNode(currentText, type); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return emitTypeReference(type); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return emitTypeQuery(type); - case 162 /* ArrayType */: + case 163 /* ArrayType */: return emitArrayType(type); - case 163 /* TupleType */: + case 164 /* TupleType */: return emitTupleType(type); - case 164 /* UnionType */: + case 165 /* UnionType */: return emitUnionType(type); - case 165 /* IntersectionType */: + case 166 /* IntersectionType */: return emitIntersectionType(type); - case 166 /* ParenthesizedType */: + case 167 /* ParenthesizedType */: return emitParenType(type); - case 168 /* TypeOperator */: + case 169 /* TypeOperator */: return emitTypeOperator(type); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return emitIndexedAccessType(type); - case 170 /* MappedType */: + case 171 /* MappedType */: return emitMappedType(type); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 161 /* TypeLiteral */: + case 162 /* TypeLiteral */: return emitTypeLiteral(type); case 70 /* Identifier */: return emitEntityName(type); - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: return emitEntityName(type); - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -58324,8 +60316,8 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 141 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 141 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 142 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 142 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); @@ -58334,14 +60326,14 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 234 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 236 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 /* Identifier */ || node.expression.kind === 177 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 70 /* Identifier */ || node.expression.kind === 178 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -58450,15 +60442,15 @@ var ts; // do not need to keep track of created temp names. function getExportDefaultTempVariableName() { var baseName = "_default"; - if (!(baseName in currentIdentifiers)) { + if (!currentIdentifiers.has(baseName)) { return baseName; } var count = 0; while (true) { count++; - var name_39 = baseName + "_" + count; - if (!(name_39 in currentIdentifiers)) { - return name_39; + var name = baseName + "_" + count; + if (!currentIdentifiers.has(name)) { + return name; } } } @@ -58505,10 +60497,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 234 /* ImportEqualsDeclaration */ || - (node.parent.kind === 261 /* SourceFile */ && isCurrentFileExternalModule)) { + else if (node.kind === 236 /* ImportEqualsDeclaration */ || + (node.parent.kind === 264 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 264 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -58518,7 +60510,7 @@ var ts; }); } else { - if (node.kind === 235 /* ImportDeclaration */) { + if (node.kind === 237 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -58536,23 +60528,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: return writeVariableStatement(node); - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return writeClassDeclaration(node); - case 228 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -58560,7 +60552,7 @@ var ts; } 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.kind === 261 /* SourceFile */) { + if (node.parent.kind === 264 /* SourceFile */) { var modifiers = ts.getModifierFlags(node); // If the node is exported if (modifiers & 1 /* Export */) { @@ -58569,7 +60561,7 @@ var ts; if (modifiers & 512 /* Default */) { write("default "); } - else if (node.kind !== 227 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 229 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -58621,7 +60613,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 237 /* NamespaceImport */) { + if (namedBindings.kind === 239 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -58645,7 +60637,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 239 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -58666,13 +60658,13 @@ var ts; // the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered // external modules since they are indistinguishable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' // so compiler will treat them as external modules. - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 230 /* ModuleDeclaration */; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 232 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 234 /* ImportEqualsDeclaration */) { + if (parent.kind === 236 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 230 /* ModuleDeclaration */) { + else if (parent.kind === 232 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -58742,7 +60734,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 231 /* ModuleBlock */) { + while (node.body && node.body.kind !== 233 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -58812,7 +60804,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 149 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 150 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -58823,53 +60815,70 @@ 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 === 158 /* FunctionType */ || - node.parent.kind === 159 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 161 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 149 /* MethodDeclaration */ || - node.parent.kind === 148 /* MethodSignature */ || - node.parent.kind === 158 /* FunctionType */ || - node.parent.kind === 159 /* ConstructorType */ || - node.parent.kind === 153 /* CallSignature */ || - node.parent.kind === 154 /* ConstructSignature */); + if (node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 162 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 150 /* MethodDeclaration */ || + node.parent.kind === 149 /* MethodSignature */ || + node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + node.parent.kind === 154 /* CallSignature */ || + node.parent.kind === 155 /* ConstructSignature */); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } + if (node.default && !isPrivateMethodTypeParameter(node)) { + write(" = "); + if (node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 162 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 150 /* MethodDeclaration */ || + node.parent.kind === 149 /* MethodSignature */ || + node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + node.parent.kind === 154 /* CallSignature */ || + node.parent.kind === 155 /* ConstructSignature */); + emitType(node.default); + } + else { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.default, getTypeParameterConstraintVisibilityError); + } + } function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 153 /* CallSignature */: + case 154 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 226 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 228 /* 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 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 228 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -58888,7 +60897,7 @@ var ts; write(">"); } } - function emitHeritageClause(typeReferences, isImplementsList) { + function emitHeritageClause(className, typeReferences, isImplementsList) { if (typeReferences) { write(isImplementsList ? " implements " : " extends "); emitCommaList(typeReferences, emitTypeOfTypeReference); @@ -58902,20 +60911,22 @@ var ts; } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; + errorNameNode = className; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); + errorNameNode = undefined; } function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 226 /* ClassDeclaration */) { + if (node.parent.parent.kind === 228 /* 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; + 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; + diagnosticMessage = ts.Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; } return { diagnosticMessage: diagnosticMessage, @@ -58947,9 +60958,10 @@ var ts; emitTypeParameters(node.typeParameters); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); + node.name; + emitHeritageClause(node.name, [baseTypeNode], /*isImplementsList*/ false); } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); + emitHeritageClause(node.name, ts.getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); write(" {"); writeLine(); increaseIndent(); @@ -58970,7 +60982,7 @@ var ts; emitTypeParameters(node.typeParameters); var interfaceExtendsTypes = ts.filter(ts.getInterfaceBaseTypeNodes(node), function (base) { return ts.isEntityNameExpression(base.expression); }); if (interfaceExtendsTypes && interfaceExtendsTypes.length) { - emitHeritageClause(interfaceExtendsTypes, /*isImplementsList*/ false); + emitHeritageClause(node.name, interfaceExtendsTypes, /*isImplementsList*/ false); } write(" {"); writeLine(); @@ -58994,7 +61006,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 !== 223 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 225 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -59005,11 +61017,11 @@ var ts; writeTextOfNode(currentText, node.name); // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor // we don't want to emit property declaration with "?" - if ((node.kind === 147 /* PropertyDeclaration */ || node.kind === 146 /* PropertySignature */ || - (node.kind === 144 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 148 /* PropertyDeclaration */ || node.kind === 147 /* PropertySignature */ || + (node.kind === 145 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 147 /* PropertyDeclaration */ || node.kind === 146 /* PropertySignature */) && node.parent.kind === 161 /* TypeLiteral */) { + if ((node.kind === 148 /* PropertyDeclaration */ || node.kind === 147 /* PropertySignature */) && node.parent.kind === 162 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -59022,14 +61034,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 223 /* VariableDeclaration */) { + if (node.kind === 225 /* VariableDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 147 /* PropertyDeclaration */ || node.kind === 146 /* PropertySignature */) { + else if (node.kind === 148 /* PropertyDeclaration */ || node.kind === 147 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -59038,7 +61050,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 === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 228 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -59070,7 +61082,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 198 /* OmittedExpression */) { + if (element.kind !== 199 /* OmittedExpression */) { elements.push(element); } } @@ -59140,7 +61152,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 === 151 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 152 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -59153,7 +61165,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 151 /* GetAccessor */ + return accessor.kind === 152 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -59162,7 +61174,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 152 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 153 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? @@ -59212,17 +61224,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 225 /* FunctionDeclaration */) { + if (node.kind === 227 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 149 /* MethodDeclaration */ || node.kind === 150 /* Constructor */) { + else if (node.kind === 150 /* MethodDeclaration */ || node.kind === 151 /* Constructor */) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 225 /* FunctionDeclaration */) { + if (node.kind === 227 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 150 /* Constructor */) { + else if (node.kind === 151 /* Constructor */) { write("constructor"); } else { @@ -59242,17 +61254,17 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 155 /* IndexSignature */) { + if (node.kind === 156 /* IndexSignature */) { // Index signature can have readonly modifier emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { // Construct signature or constructor type write new Signature - if (node.kind === 154 /* ConstructSignature */ || node.kind === 159 /* ConstructorType */) { + if (node.kind === 155 /* ConstructSignature */ || node.kind === 160 /* ConstructorType */) { write("new "); } - else if (node.kind === 158 /* FunctionType */) { + else if (node.kind === 159 /* FunctionType */) { var currentOutput = writer.getText(); // Do not generate incorrect type when function type with type parameters is type argument // This could happen if user used space between two '<' making it error free @@ -59267,22 +61279,22 @@ var ts; } // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 155 /* IndexSignature */) { + if (node.kind === 156 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 158 /* FunctionType */ || node.kind === 159 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 161 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 159 /* FunctionType */ || node.kind === 160 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 162 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 150 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { + else if (node.kind !== 151 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -59296,26 +61308,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 153 /* CallSignature */: + case 154 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -59323,7 +61335,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 === 226 /* ClassDeclaration */) { + else if (node.parent.kind === 228 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -59337,7 +61349,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -59372,9 +61384,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 158 /* FunctionType */ || - node.parent.kind === 159 /* ConstructorType */ || - node.parent.parent.kind === 161 /* TypeLiteral */) { + if (node.parent.kind === 159 /* FunctionType */ || + node.parent.kind === 160 /* ConstructorType */ || + node.parent.parent.kind === 162 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8 /* Private */)) { @@ -59390,29 +61402,29 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 150 /* Constructor */: + case 151 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 153 /* CallSignature */: + case 154 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -59420,7 +61432,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 === 226 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 228 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -59433,7 +61445,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 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -59445,12 +61457,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 === 172 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 173 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 173 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 174 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -59461,7 +61473,7 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 198 /* OmittedExpression */) { + if (bindingElement.kind === 199 /* 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) @@ -59470,7 +61482,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 174 /* BindingElement */) { + else if (bindingElement.kind === 175 /* 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" @@ -59509,40 +61521,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: - case 230 /* ModuleDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 227 /* InterfaceDeclaration */: - case 226 /* ClassDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 229 /* EnumDeclaration */: + case 227 /* FunctionDeclaration */: + case 232 /* ModuleDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 229 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 231 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return emitExportDeclaration(node); - case 150 /* Constructor */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 151 /* Constructor */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: return writeFunctionDeclaration(node); - case 154 /* ConstructSignature */: - case 153 /* CallSignature */: - case 155 /* IndexSignature */: + case 155 /* ConstructSignature */: + case 154 /* CallSignature */: + case 156 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return emitAccessorDeclaration(node); - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return emitPropertyDeclaration(node); - case 260 /* EnumMember */: + case 263 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return emitExportAssignment(node); - case 261 /* SourceFile */: + case 264 /* SourceFile */: return emitSourceFile(node); } } @@ -59560,7 +61572,7 @@ var ts; } else { // Get the declaration file path - ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); } if (declFileName) { declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(declarationFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, @@ -59568,8 +61580,9 @@ var ts; referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, sourceFileOrBundle) { // Dont add reference path to this file if it is a bundled emit and caller asked not emit bundled file path + var isBundledEmit = sourceFileOrBundle.kind === 265 /* Bundle */; if (isBundledEmit && !addBundledFileReference) { return; } @@ -59580,10 +61593,11 @@ var ts; } } /* @internal */ - function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { - var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles); + function writeDeclarationFile(declarationFilePath, sourceFileOrBundle, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { + var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { + var sourceFiles = sourceFileOrBundle.kind === 265 /* Bundle */ ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; var declarationOutput = emitDeclarationResult.referencesOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); ts.writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM, sourceFiles); @@ -59606,63 +61620,56 @@ var ts; } ts.writeDeclarationFile = writeDeclarationFile; })(ts || (ts = {})); -/// +/// /// -/// -/// +/// +/// /// -/* @internal */ var ts; (function (ts) { - // 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 = {})); - var id = function (s) { return s; }; - var nullTransformers = [function (_) { return id; }]; + var delimiters = createDelimiterMap(); + var brackets = createBracketsMap(); + /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { - var delimiters = createDelimiterMap(); - var brackets = createBracketsMap(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = emitOnlyDtsFiles ? nullTransformers : ts.getTransformers(compilerOptions); + var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); - var write = writer.write, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var sourceMap = ts.createSourceMapWriter(host, writer); - var emitNodeWithSourceMap = sourceMap.emitNodeWithSourceMap, emitTokenWithSourceMap = sourceMap.emitTokenWithSourceMap; - var comments = ts.createCommentWriter(host, writer, sourceMap); - var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition; - var nodeIdToGeneratedName; - var autoGeneratedIdToGeneratedName; - var generatedNameSet; - var tempFlags; var currentSourceFile; - var currentText; - var currentFileIdentifiers; var bundledHelpers; var isOwnFileEmit; var emitSkipped = false; var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); // Transform the source files - ts.performance.mark("beforeTransform"); - var _a = ts.transformFiles(resolver, host, sourceFiles, transformers), transformed = _a.transformed, emitNodeWithSubstitution = _a.emitNodeWithSubstitution, emitNodeWithNotification = _a.emitNodeWithNotification; - ts.performance.measure("transformTime", "beforeTransform"); + var transform = ts.transformFiles(resolver, host, sourceFiles, transformers); + // Create a printer to print the nodes + var printer = createPrinter(compilerOptions, { + // resolver hooks + hasGlobalName: resolver.hasGlobalName, + // transform hooks + onEmitNode: transform.emitNodeWithNotification, + onSubstituteNode: transform.emitNodeWithSubstitution, + // sourcemap hooks + onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, + onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, + onEmitSourceMapOfPosition: sourceMap.emitPos, + // emitter hooks + onEmitHelpers: emitHelpers, + onSetSourceFile: setSourceFile, + }); // Emit each output file ts.performance.mark("beforePrint"); - ts.forEachTransformedEmitFile(host, transformed, emitFile, emitOnlyDtsFiles); + ts.forEachEmittedFile(host, emitSourceFileOrBundle, transform.transformed, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); // Clean up emit nodes on parse tree - for (var _b = 0, sourceFiles_4 = sourceFiles; _b < sourceFiles_4.length; _b++) { - var sourceFile = sourceFiles_4[_b]; + for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { + var sourceFile = sourceFiles_2[_a]; ts.disposeEmitNodes(sourceFile); } return { @@ -59671,18 +61678,19 @@ var ts; emittedFiles: emittedFilesList, sourceMaps: sourceMapDataList }; - function emitFile(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, isBundledEmit) { + function emitSourceFileOrBundle(_a, sourceFileOrBundle) { + var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath; // Make sure not to write js file and source map file if any of them cannot be written if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { if (!emitOnlyDtsFiles) { - printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle); } } else { emitSkipped = true; } if (declarationFilePath) { - emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; + emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFileOrBundle(sourceFileOrBundle), host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; } if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { @@ -59696,26 +61704,24 @@ var ts; } } } - function printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit) { - sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); - nodeIdToGeneratedName = []; - autoGeneratedIdToGeneratedName = []; - generatedNameSet = ts.createMap(); - bundledHelpers = isBundledEmit ? ts.createMap() : undefined; - isOwnFileEmit = !isBundledEmit; - // Emit helpers from all the files - if (isBundledEmit && moduleKind) { - for (var _a = 0, sourceFiles_5 = sourceFiles; _a < sourceFiles_5.length; _a++) { - var sourceFile = sourceFiles_5[_a]; - emitHelpers(sourceFile, /*isBundle*/ true); - } + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle) { + var bundle = sourceFileOrBundle.kind === 265 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 264 /* SourceFile */ ? sourceFileOrBundle : undefined; + var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; + sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFileOrBundle); + if (bundle) { + bundledHelpers = ts.createMap(); + isOwnFileEmit = false; + printer.writeBundle(bundle, writer); } - // Print each transformed source file. - ts.forEach(sourceFiles, printSourceFile); - writeLine(); + else { + isOwnFileEmit = true; + printer.writeFile(sourceFile, writer); + } + writer.writeLine(); var sourceMappingURL = sourceMap.getSourceMappingURL(); if (sourceMappingURL) { - write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Sometimes tools can sometimes see this line as a source mapping url comment + writer.write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Sometimes tools can sometimes see this line as a source mapping url comment } // Write the source map if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) { @@ -59729,138 +61735,237 @@ var ts; ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM, sourceFiles); // Reset state sourceMap.reset(); - comments.reset(); writer.reset(); - tempFlags = 0 /* Auto */; currentSourceFile = undefined; - currentText = undefined; + bundledHelpers = undefined; isOwnFileEmit = false; } - function printSourceFile(node) { + function setSourceFile(node) { currentSourceFile = node; - currentText = node.text; - currentFileIdentifiers = node.identifiers; sourceMap.setSourceFile(node); - comments.setSourceFile(node); - pipelineEmitWithNotification(0 /* SourceFile */, node); } - /** - * Emits a node. - */ - function emit(node) { - pipelineEmitWithNotification(3 /* Unspecified */, node); + function emitHelpers(node, writeLines) { + var helpersEmitted = false; + var bundle = node.kind === 265 /* Bundle */ ? node : undefined; + if (bundle && moduleKind === ts.ModuleKind.None) { + return; + } + var numNodes = bundle ? bundle.sourceFiles.length : 1; + for (var i = 0; i < numNodes; i++) { + var currentNode = bundle ? bundle.sourceFiles[i] : node; + var sourceFile = ts.isSourceFile(currentNode) ? currentNode : currentSourceFile; + var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldBundle = ts.isSourceFile(currentNode) && !isOwnFileEmit; + var helpers = ts.getEmitHelpers(currentNode); + if (helpers) { + for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { + var helper = _b[_a]; + if (!helper.scoped) { + // Skip the helper if it can be skipped and the noEmitHelpers compiler + // option is set, or if it can be imported and the importHelpers compiler + // option is set. + if (shouldSkip) + continue; + // Skip the helper if it can be bundled but hasn't already been emitted and we + // are emitting a bundled module. + if (shouldBundle) { + if (bundledHelpers.get(helper.name)) { + continue; + } + bundledHelpers.set(helper.name, true); + } + } + else if (bundle) { + // Skip the helper if it is scoped and we are emitting bundled helpers + continue; + } + writeLines(helper.text); + helpersEmitted = true; + } + } + } + return helpersEmitted; + } + } + ts.emitFiles = emitFiles; + function createPrinter(printerOptions, handlers) { + if (printerOptions === void 0) { printerOptions = {}; } + if (handlers === void 0) { handlers = {}; } + var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, onSubstituteNode = handlers.onSubstituteNode; + var newLine = ts.getNewLineCharacter(printerOptions); + var languageVersion = ts.getEmitScriptTarget(printerOptions); + var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); + var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; + var currentSourceFile; + var nodeIdToGeneratedName; // Map of generated names for specific nodes. + var autoGeneratedIdToGeneratedName; // Map of generated names for temp and loop variables. + var generatedNames; // Set of names generated by the NameGenerator. + var tempFlagsStack; // Stack of enclosing name generation scopes. + var tempFlags; // TempFlags for the current name generation scope. + var writer; + var ownWriter; + reset(); + return { + // public API + printNode: printNode, + printFile: printFile, + printBundle: printBundle, + // internal API + writeNode: writeNode, + writeFile: writeFile, + writeBundle: writeBundle + }; + function printNode(hint, node, sourceFile) { + switch (hint) { + case 0 /* SourceFile */: + ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); + break; + case 2 /* IdentifierName */: + ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); + break; + case 1 /* Expression */: + ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); + break; + } + switch (node.kind) { + case 264 /* SourceFile */: return printFile(node); + case 265 /* Bundle */: return printBundle(node); + } + writeNode(hint, node, sourceFile, beginPrint()); + return endPrint(); + } + function printBundle(bundle) { + writeBundle(bundle, beginPrint()); + return endPrint(); + } + function printFile(sourceFile) { + writeFile(sourceFile, beginPrint()); + return endPrint(); + } + function writeNode(hint, node, sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(hint, node, sourceFile); + reset(); + writer = previousWriter; + } + function writeBundle(bundle, output) { + var previousWriter = writer; + setWriter(output); + emitHelpersIndirect(bundle); + for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + print(0 /* SourceFile */, sourceFile, sourceFile); + } + reset(); + writer = previousWriter; + } + function writeFile(sourceFile, output) { + var previousWriter = writer; + setWriter(output); + print(0 /* SourceFile */, sourceFile, sourceFile); + reset(); + writer = previousWriter; + } + function beginPrint() { + return ownWriter || (ownWriter = ts.createTextWriter(newLine)); + } + function endPrint() { + var text = ownWriter.getText(); + ownWriter.reset(); + return text; + } + function print(hint, node, sourceFile) { + setSourceFile(sourceFile); + pipelineEmitWithNotification(hint, node); + } + function setSourceFile(sourceFile) { + currentSourceFile = sourceFile; + comments.setSourceFile(sourceFile); + if (onSetSourceFile) { + onSetSourceFile(sourceFile); + } + } + function setWriter(output) { + writer = output; + comments.setWriter(output); + } + function reset() { + nodeIdToGeneratedName = []; + autoGeneratedIdToGeneratedName = []; + generatedNames = ts.createMap(); + tempFlagsStack = []; + tempFlags = 0 /* Auto */; + comments.reset(); + setWriter(/*output*/ undefined); + } + function emit(node, hint) { + if (hint === void 0) { hint = 3 /* Unspecified */; } + pipelineEmitWithNotification(hint, node); } - /** - * Emits an IdentifierName. - */ function emitIdentifierName(node) { pipelineEmitWithNotification(2 /* IdentifierName */, node); } - /** - * Emits an expression node. - */ function emitExpression(node) { pipelineEmitWithNotification(1 /* Expression */, node); } - /** - * Emits a node with possible notification. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called from printSourceFile, emit, emitExpression, or - * emitIdentifierName. - */ - function pipelineEmitWithNotification(emitContext, node) { - emitNodeWithNotification(emitContext, node, pipelineEmitWithComments); + function pipelineEmitWithNotification(hint, node) { + if (onEmitNode) { + onEmitNode(hint, node, pipelineEmitWithComments); + } + else { + pipelineEmitWithComments(hint, node); + } } - /** - * Emits a node with comments. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithNotification. - */ - function pipelineEmitWithComments(emitContext, node) { - // Do not emit comments for SourceFile - if (emitContext === 0 /* SourceFile */) { - pipelineEmitWithSourceMap(emitContext, node); + function pipelineEmitWithComments(hint, node) { + if (emitNodeWithComments && hint !== 0 /* SourceFile */) { + emitNodeWithComments(hint, node, pipelineEmitWithSourceMap); + } + else { + pipelineEmitWithSourceMap(hint, node); + } + } + function pipelineEmitWithSourceMap(hint, node) { + if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */) { + onEmitSourceMapOfNode(hint, node, pipelineEmitWithSubstitution); + } + else { + pipelineEmitWithSubstitution(hint, node); + } + } + function pipelineEmitWithSubstitution(hint, node) { + if (onSubstituteNode) { + onSubstituteNode(hint, node, pipelineEmitWithHint); + } + else { + pipelineEmitWithHint(hint, node); + } + } + function pipelineEmitWithHint(hint, node) { + switch (hint) { + case 0 /* SourceFile */: return pipelineEmitSourceFile(node); + case 2 /* IdentifierName */: return pipelineEmitIdentifierName(node); + case 1 /* Expression */: return pipelineEmitExpression(node); + case 3 /* Unspecified */: return pipelineEmitUnspecified(node); + } + } + function pipelineEmitSourceFile(node) { + ts.Debug.assertNode(node, ts.isSourceFile); + emitSourceFile(node); + } + function pipelineEmitIdentifierName(node) { + ts.Debug.assertNode(node, ts.isIdentifier); + emitIdentifier(node); + } + function pipelineEmitUnspecified(node) { + var kind = node.kind; + // Reserved words + // Strict mode reserved words + // Contextual keywords + if (ts.isKeyword(kind)) { + writeTokenText(kind); return; } - emitNodeWithComments(emitContext, node, pipelineEmitWithSourceMap); - } - /** - * Emits a node with source maps. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithComments. - */ - function pipelineEmitWithSourceMap(emitContext, node) { - // Do not emit source mappings for SourceFile or IdentifierName - if (emitContext === 0 /* SourceFile */ - || emitContext === 2 /* IdentifierName */) { - pipelineEmitWithSubstitution(emitContext, node); - return; - } - emitNodeWithSourceMap(emitContext, node, pipelineEmitWithSubstitution); - } - /** - * Emits a node with possible substitution. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithSourceMap or - * pipelineEmitInUnspecifiedContext (when picking a more specific context). - */ - function pipelineEmitWithSubstitution(emitContext, node) { - emitNodeWithSubstitution(emitContext, node, pipelineEmitForContext); - } - /** - * Emits a node. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithSubstitution. - */ - function pipelineEmitForContext(emitContext, node) { - switch (emitContext) { - case 0 /* SourceFile */: return pipelineEmitInSourceFileContext(node); - case 2 /* IdentifierName */: return pipelineEmitInIdentifierNameContext(node); - case 3 /* Unspecified */: return pipelineEmitInUnspecifiedContext(node); - case 1 /* Expression */: return pipelineEmitInExpressionContext(node); - } - } - /** - * Emits a node in the SourceFile EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInSourceFileContext(node) { - var kind = node.kind; - switch (kind) { - // Top-level nodes - case 261 /* SourceFile */: - return emitSourceFile(node); - } - } - /** - * Emits a node in the IdentifierName EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInIdentifierNameContext(node) { - var kind = node.kind; - switch (kind) { - // Identifiers - case 70 /* Identifier */: - return emitIdentifier(node); - } - } - /** - * Emits a node in the Unspecified EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInUnspecifiedContext(node) { - var kind = node.kind; switch (kind) { // Pseudo-literals case 13 /* TemplateHead */: @@ -59870,239 +61975,204 @@ var ts; // Identifiers case 70 /* Identifier */: return emitIdentifier(node); - // Reserved words - case 75 /* ConstKeyword */: - case 78 /* DefaultKeyword */: - case 83 /* ExportKeyword */: - case 104 /* VoidKeyword */: - // Strict mode reserved words - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 113 /* PublicKeyword */: - case 114 /* StaticKeyword */: - // Contextual keywords - case 116 /* AbstractKeyword */: - case 117 /* AsKeyword */: - case 118 /* AnyKeyword */: - case 119 /* AsyncKeyword */: - case 120 /* AwaitKeyword */: - case 121 /* BooleanKeyword */: - case 122 /* ConstructorKeyword */: - case 123 /* DeclareKeyword */: - case 124 /* GetKeyword */: - case 125 /* IsKeyword */: - case 127 /* ModuleKeyword */: - case 128 /* NamespaceKeyword */: - case 129 /* NeverKeyword */: - case 130 /* ReadonlyKeyword */: - case 131 /* RequireKeyword */: - case 132 /* NumberKeyword */: - case 133 /* SetKeyword */: - case 134 /* StringKeyword */: - case 135 /* SymbolKeyword */: - case 136 /* TypeKeyword */: - case 137 /* UndefinedKeyword */: - case 138 /* FromKeyword */: - case 139 /* GlobalKeyword */: - case 140 /* OfKeyword */: - writeTokenText(kind); - return; // Parse tree nodes // Names - case 141 /* QualifiedName */: + case 142 /* QualifiedName */: return emitQualifiedName(node); - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: return emitTypeParameter(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return emitParameter(node); - case 145 /* Decorator */: + case 146 /* Decorator */: return emitDecorator(node); // Type members - case 146 /* PropertySignature */: + case 147 /* PropertySignature */: return emitPropertySignature(node); - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 148 /* MethodSignature */: + case 149 /* MethodSignature */: return emitMethodSignature(node); - case 149 /* MethodDeclaration */: + case 150 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return emitConstructor(node); - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: return emitAccessorDeclaration(node); - case 153 /* CallSignature */: + case 154 /* CallSignature */: return emitCallSignature(node); - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: return emitConstructSignature(node); - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: return emitIndexSignature(node); // Types - case 156 /* TypePredicate */: + case 157 /* TypePredicate */: return emitTypePredicate(node); - case 157 /* TypeReference */: + case 158 /* TypeReference */: return emitTypeReference(node); - case 158 /* FunctionType */: + case 159 /* FunctionType */: return emitFunctionType(node); - case 159 /* ConstructorType */: + case 160 /* ConstructorType */: return emitConstructorType(node); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return emitTypeQuery(node); - case 161 /* TypeLiteral */: + case 162 /* TypeLiteral */: return emitTypeLiteral(node); - case 162 /* ArrayType */: + case 163 /* ArrayType */: return emitArrayType(node); - case 163 /* TupleType */: + case 164 /* TupleType */: return emitTupleType(node); - case 164 /* UnionType */: + case 165 /* UnionType */: return emitUnionType(node); - case 165 /* IntersectionType */: + case 166 /* IntersectionType */: return emitIntersectionType(node); - case 166 /* ParenthesizedType */: + case 167 /* ParenthesizedType */: return emitParenthesizedType(node); - case 199 /* ExpressionWithTypeArguments */: + case 200 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 167 /* ThisType */: + case 168 /* ThisType */: return emitThisType(); - case 168 /* TypeOperator */: + case 169 /* TypeOperator */: return emitTypeOperator(node); - case 169 /* IndexedAccessType */: + case 170 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 170 /* MappedType */: + case 171 /* MappedType */: return emitMappedType(node); - case 171 /* LiteralType */: + case 172 /* LiteralType */: return emitLiteralType(node); // Binding patterns - case 172 /* ObjectBindingPattern */: + case 173 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 173 /* ArrayBindingPattern */: + case 174 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 174 /* BindingElement */: + case 175 /* BindingElement */: return emitBindingElement(node); // Misc - case 202 /* TemplateSpan */: + case 204 /* TemplateSpan */: return emitTemplateSpan(node); - case 203 /* SemicolonClassElement */: + case 205 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 204 /* Block */: + case 206 /* Block */: return emitBlock(node); - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: return emitVariableStatement(node); - case 206 /* EmptyStatement */: + case 208 /* EmptyStatement */: return emitEmptyStatement(); - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return emitExpressionStatement(node); - case 208 /* IfStatement */: + case 210 /* IfStatement */: return emitIfStatement(node); - case 209 /* DoStatement */: + case 211 /* DoStatement */: return emitDoStatement(node); - case 210 /* WhileStatement */: + case 212 /* WhileStatement */: return emitWhileStatement(node); - case 211 /* ForStatement */: + case 213 /* ForStatement */: return emitForStatement(node); - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: return emitForInStatement(node); - case 213 /* ForOfStatement */: + case 215 /* ForOfStatement */: return emitForOfStatement(node); - case 214 /* ContinueStatement */: + case 216 /* ContinueStatement */: return emitContinueStatement(node); - case 215 /* BreakStatement */: + case 217 /* BreakStatement */: return emitBreakStatement(node); - case 216 /* ReturnStatement */: + case 218 /* ReturnStatement */: return emitReturnStatement(node); - case 217 /* WithStatement */: + case 219 /* WithStatement */: return emitWithStatement(node); - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: return emitSwitchStatement(node); - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: return emitLabeledStatement(node); - case 220 /* ThrowStatement */: + case 222 /* ThrowStatement */: return emitThrowStatement(node); - case 221 /* TryStatement */: + case 223 /* TryStatement */: return emitTryStatement(node); - case 222 /* DebuggerStatement */: + case 224 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 224 /* VariableDeclarationList */: + case 226 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 225 /* FunctionDeclaration */: + case 227 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: return emitClassDeclaration(node); - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 228 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 231 /* ModuleBlock */: + case 233 /* ModuleBlock */: return emitModuleBlock(node); - case 232 /* CaseBlock */: + case 234 /* CaseBlock */: return emitCaseBlock(node); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: return emitImportDeclaration(node); - case 236 /* ImportClause */: + case 238 /* ImportClause */: return emitImportClause(node); - case 237 /* NamespaceImport */: + case 239 /* NamespaceImport */: return emitNamespaceImport(node); - case 238 /* NamedImports */: + case 240 /* NamedImports */: return emitNamedImports(node); - case 239 /* ImportSpecifier */: + case 241 /* ImportSpecifier */: return emitImportSpecifier(node); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: return emitExportAssignment(node); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: return emitExportDeclaration(node); - case 242 /* NamedExports */: + case 244 /* NamedExports */: return emitNamedExports(node); - case 243 /* ExportSpecifier */: + case 245 /* ExportSpecifier */: return emitExportSpecifier(node); - case 244 /* MissingDeclaration */: + case 246 /* MissingDeclaration */: return; // Module references - case 245 /* ExternalModuleReference */: + case 247 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 248 /* JsxOpeningElement */: + case 250 /* JsxOpeningElement */: return emitJsxOpeningElement(node); - case 249 /* JsxClosingElement */: + case 251 /* JsxClosingElement */: return emitJsxClosingElement(node); - case 250 /* JsxAttribute */: + case 252 /* JsxAttribute */: return emitJsxAttribute(node); - case 251 /* JsxSpreadAttribute */: + case 253 /* JsxAttributes */: + return emitJsxAttributes(node); + case 254 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 252 /* JsxExpression */: + case 255 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 253 /* CaseClause */: + case 256 /* CaseClause */: return emitCaseClause(node); - case 254 /* DefaultClause */: + case 257 /* DefaultClause */: return emitDefaultClause(node); - case 255 /* HeritageClause */: + case 258 /* HeritageClause */: return emitHeritageClause(node); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 257 /* PropertyAssignment */: + case 260 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 258 /* ShorthandPropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 259 /* SpreadAssignment */: + case 262 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 260 /* EnumMember */: + case 263 /* EnumMember */: return emitEnumMember(node); } // If the node is an expression, try to emit it as an expression with @@ -60111,13 +62181,7 @@ var ts; return pipelineEmitWithSubstitution(1 /* Expression */, node); } } - /** - * Emits a node in the Expression EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInExpressionContext(node) { + function pipelineEmitExpression(node) { var kind = node.kind; switch (kind) { // Literals @@ -60139,68 +62203,81 @@ var ts; writeTokenText(kind); return; // Expressions - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 177 /* PropertyAccessExpression */: + case 178 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 179 /* CallExpression */: + case 180 /* CallExpression */: return emitCallExpression(node); - case 180 /* NewExpression */: + case 181 /* NewExpression */: return emitNewExpression(node); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 182 /* TypeAssertionExpression */: + case 183 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 183 /* ParenthesizedExpression */: + case 184 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 184 /* FunctionExpression */: + case 185 /* FunctionExpression */: return emitFunctionExpression(node); - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: return emitArrowFunction(node); - case 186 /* DeleteExpression */: + case 187 /* DeleteExpression */: return emitDeleteExpression(node); - case 187 /* TypeOfExpression */: + case 188 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 188 /* VoidExpression */: + case 189 /* VoidExpression */: return emitVoidExpression(node); - case 189 /* AwaitExpression */: + case 190 /* AwaitExpression */: return emitAwaitExpression(node); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 191 /* PostfixUnaryExpression */: + case 192 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return emitBinaryExpression(node); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return emitConditionalExpression(node); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: return emitTemplateExpression(node); - case 195 /* YieldExpression */: + case 196 /* YieldExpression */: return emitYieldExpression(node); - case 196 /* SpreadElement */: + case 197 /* SpreadElement */: return emitSpreadExpression(node); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return emitClassExpression(node); - case 198 /* OmittedExpression */: + case 199 /* OmittedExpression */: return; - case 200 /* AsExpression */: + case 201 /* AsExpression */: return emitAsExpression(node); - case 201 /* NonNullExpression */: + case 202 /* NonNullExpression */: return emitNonNullExpression(node); + case 203 /* MetaProperty */: + return emitMetaProperty(node); // JSX - case 246 /* JsxElement */: + case 248 /* JsxElement */: return emitJsxElement(node); - case 247 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); // Transformation nodes - case 294 /* PartiallyEmittedExpression */: + case 298 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 297 /* RawExpression */: - return writeLines(node.text); + } + } + function emitBodyIndirect(node, elements, emitCallback) { + if (emitBodyWithDetachedComments) { + emitBodyWithDetachedComments(node, elements, emitCallback); + } + else { + emitCallback(node); + } + } + function emitHelpersIndirect(node) { + if (onEmitHelpers) { + onEmitHelpers(node, writeLines); } } // @@ -60221,7 +62298,7 @@ var ts; // SyntaxKind.TemplateTail function emitLiteral(node) { var text = getLiteralTextOfNode(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) + if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } @@ -60320,7 +62397,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 151 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 152 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -60423,17 +62500,13 @@ var ts; write("{"); writeLine(); increaseIndent(); - if (node.readonlyToken) { - write("readonly "); - } + writeIfPresent(node.readonlyToken, "readonly "); write("["); emit(node.typeParameter.name); write(" in "); emit(node.typeParameter.constraint); write("]"); - if (node.questionToken) { - write("?"); - } + writeIfPresent(node.questionToken, "?"); write(": "); emit(node.type); write(";"); @@ -60511,7 +62584,7 @@ var ts; var indentAfterDot = false; if (!(ts.getEmitFlags(node) & 65536 /* NoIndentation */)) { var dotRangeStart = node.expression.end; - var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; + var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; var dotToken = { kind: 22 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); @@ -60528,9 +62601,11 @@ var ts; // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal function needsDotDotForPropertyAccess(expression) { if (expression.kind === 8 /* NumericLiteral */) { - // check if numeric literal was originally written with a dot + // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(22 /* DotToken */)) < 0; + return ts.getNumericLiteralFlags(text, /*hint*/ 15 /* All */) === 0 /* None */ + && !expression.isOctalLiteral + && text.indexOf(ts.tokenToString(22 /* DotToken */)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { // check if constant enum value is integer @@ -60538,7 +62613,7 @@ var ts; // isFinite handles cases when constantValue is undefined return isFinite(constantValue) && Math.floor(constantValue) === constantValue - && compilerOptions.removeComments; + && printerOptions.removeComments; } } function emitElementAccessExpression(node) { @@ -60564,11 +62639,9 @@ var ts; emitExpression(node.template); } function emitTypeAssertionExpression(node) { - if (node.type) { - write("<"); - emit(node.type); - write(">"); - } + write("<"); + emit(node.type); + write(">"); emitExpression(node.expression); } function emitParenthesizedExpression(node) { @@ -60627,7 +62700,7 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 190 /* PrefixUnaryExpression */ + return operand.kind === 191 /* PrefixUnaryExpression */ && ((node.operator === 36 /* PlusToken */ && (operand.operator === 36 /* PlusToken */ || operand.operator === 42 /* PlusPlusToken */)) || (node.operator === 37 /* MinusToken */ && (operand.operator === 37 /* MinusToken */ || operand.operator === 43 /* MinusMinusToken */))); } @@ -60693,6 +62766,11 @@ var ts; emitExpression(node.expression); write("!"); } + function emitMetaProperty(node) { + writeToken(node.keywordToken, node.pos); + write("."); + emit(node.name); + } // // Misc // @@ -60712,6 +62790,10 @@ var ts; else { writeToken(16 /* OpenBraceToken */, node.pos, /*contextNode*/ node); emitBlockStatements(node); + // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); writeToken(17 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); } } @@ -60741,27 +62823,27 @@ var ts; writeToken(18 /* OpenParenToken */, openParenPos, node); emitExpression(node.expression); writeToken(19 /* CloseParenToken */, node.expression.end, node); - emitEmbeddedStatement(node.thenStatement); + emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { - writeLine(); + writeLineOrSpace(node); writeToken(81 /* ElseKeyword */, node.thenStatement.end, node); - if (node.elseStatement.kind === 208 /* IfStatement */) { + if (node.elseStatement.kind === 210 /* IfStatement */) { write(" "); emit(node.elseStatement); } else { - emitEmbeddedStatement(node.elseStatement); + emitEmbeddedStatement(node, node.elseStatement); } } } function emitDoStatement(node) { write("do"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { write(" "); } else { - writeLine(); + writeLineOrSpace(node); } write("while ("); emitExpression(node.expression); @@ -60771,7 +62853,7 @@ var ts; write("while ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { var openParenPos = writeToken(87 /* ForKeyword */, node.pos); @@ -60783,7 +62865,7 @@ var ts; write(";"); emitExpressionWithPrefix(" ", node.incrementor); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { var openParenPos = writeToken(87 /* ForKeyword */, node.pos); @@ -60793,7 +62875,7 @@ var ts; write(" in "); emitExpression(node.expression); writeToken(19 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { var openParenPos = writeToken(87 /* ForKeyword */, node.pos); @@ -60803,11 +62885,11 @@ var ts; write(" of "); emitExpression(node.expression); writeToken(19 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 224 /* VariableDeclarationList */) { + if (node.kind === 226 /* VariableDeclarationList */) { emit(node); } else { @@ -60834,7 +62916,7 @@ var ts; write("with ("); emitExpression(node.expression); write(")"); - emitEmbeddedStatement(node.statement); + emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { var openParenPos = writeToken(97 /* SwitchKeyword */, node.pos); @@ -60858,9 +62940,12 @@ var ts; function emitTryStatement(node) { write("try "); emit(node.tryBlock); - emit(node.catchClause); + if (node.catchClause) { + writeLineOrSpace(node); + emit(node.catchClause); + } if (node.finallyBlock) { - writeLine(); + writeLineOrSpace(node); write("finally "); emit(node.finallyBlock); } @@ -60904,11 +62989,10 @@ var ts; emitBlockFunctionBody(body); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); emitSignatureHead(node); emitBlockFunctionBody(body); - tempFlags = savedTempFlags; + popNameGenerationScope(); } if (indentedFlag) { decreaseIndent(); @@ -60963,9 +63047,10 @@ var ts; function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) + var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine - : emitBlockFunctionBodyWorker); + : emitBlockFunctionBodyWorker; + emitBodyIndirect(body, body.statements, emitBlockFunctionBody); decreaseIndent(); writeToken(17 /* CloseBraceToken */, body.statements.end, body); } @@ -60975,8 +63060,9 @@ var ts; function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) { // Emit all the prologue directives (like "use strict"). var statementOffset = emitPrologueDirectives(body.statements, /*startWithNewLine*/ true); - var helpersEmitted = emitHelpers(body); - if (statementOffset === 0 && !helpersEmitted && emitBlockFunctionBodyOnSingleLine) { + var pos = writer.getTextPos(); + emitHelpersIndirect(body); + if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); emitList(body, body.statements, 384 /* SingleLineFunctionBodyStatements */); increaseIndent(); @@ -60999,15 +63085,14 @@ var ts; } emitTypeParameters(node, node.typeParameters); emitList(node, node.heritageClauses, 256 /* ClassHeritageClauses */); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 65 /* ClassMembers */); write("}"); + popNameGenerationScope(); if (indentedFlag) { decreaseIndent(); } - tempFlags = savedTempFlags; } function emitInterfaceDeclaration(node) { emitDecorators(node, node.decorators); @@ -61034,19 +63119,18 @@ var ts; emitModifiers(node, node.modifiers); write("enum "); emit(node.name); - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write(" {"); emitList(node, node.members, 81 /* EnumMembers */); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 230 /* ModuleDeclaration */) { + while (body.kind === 232 /* ModuleDeclaration */) { write("."); emit(body.name); body = body.body; @@ -61059,13 +63143,12 @@ var ts; write("{ }"); } else { - var savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write("{"); increaseIndent(); emitBlockStatements(node); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } } function emitCaseBlock(node) { @@ -61173,14 +63256,20 @@ var ts; write("<"); emitJsxTagName(node.tagName); write(" "); - emitList(node, node.attributes, 131328 /* JsxElementAttributes */); + // We are checking here so we won't re-enter the emiting pipeline and emit extra sourcemap + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write("/>"); } function emitJsxOpeningElement(node) { write("<"); emitJsxTagName(node.tagName); - writeIfAny(node.attributes, " "); - emitList(node, node.attributes, 131328 /* JsxElementAttributes */); + writeIfAny(node.attributes.properties, " "); + // We are checking here so we won't re-enter the emitting pipeline and emit extra sourcemap + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write(">"); } function emitJsxText(node) { @@ -61191,6 +63280,9 @@ var ts; emitJsxTagName(node.tagName); write(">"); } + function emitJsxAttributes(node) { + emitList(node, node.properties, 131328 /* JsxElementAttributes */); + } function emitJsxAttribute(node) { emit(node.name); emitWithPrefix("=", node.initializer); @@ -61203,6 +63295,9 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); + if (node.dotDotDotToken) { + write("..."); + } emitExpression(node.expression); write("}"); } @@ -61250,7 +63345,6 @@ var ts; emitList(node, node.types, 272 /* HeritageClauseTypes */); } function emitCatchClause(node) { - writeLine(); var openParenPos = writeToken(73 /* CatchKeyword */, node.pos); write(" "); writeToken(18 /* OpenParenToken */, openParenPos); @@ -61273,7 +63367,7 @@ var ts; // "comment1" is not considered to be leading comment for node.initializer // but rather a trailing comment on the previous node. var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) { + if (emitTrailingCommentsOfPosition && (ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -61305,16 +63399,15 @@ var ts; function emitSourceFile(node) { writeLine(); emitShebang(); - emitBodyWithDetachedComments(node, node.statements, emitSourceFileWorker); + emitBodyIndirect(node, node.statements, emitSourceFileWorker); } function emitSourceFileWorker(node) { var statements = node.statements; var statementOffset = emitPrologueDirectives(statements); - var savedTempFlags = tempFlags; - tempFlags = 0; - emitHelpers(node); + pushNameGenerationScope(); + emitHelpersIndirect(node); emitList(node, statements, 1 /* MultiLine */, statementOffset); - tempFlags = savedTempFlags; + popNameGenerationScope(); } // Transformation nodes function emitPartiallyEmittedExpression(node) { @@ -61339,76 +63432,11 @@ var ts; } return statements.length; } - function emitHelpers(node, isBundle) { - var sourceFile = ts.isSourceFile(node) ? node : currentSourceFile; - var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); - var shouldBundle = ts.isSourceFile(node) && !isOwnFileEmit; - var helpersEmitted = false; - var helpers = ts.getEmitHelpers(node); - if (helpers) { - for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { - var helper = _b[_a]; - if (!helper.scoped) { - // Skip the helper if it can be skipped and the noEmitHelpers compiler - // option is set, or if it can be imported and the importHelpers compiler - // option is set. - if (shouldSkip) - continue; - // Skip the helper if it can be bundled but hasn't already been emitted and we - // are emitting a bundled module. - if (shouldBundle) { - if (bundledHelpers[helper.name]) { - continue; - } - bundledHelpers[helper.name] = true; - } - } - else if (isBundle) { - // Skip the helper if it is scoped and we are emitting bundled helpers - continue; - } - writeLines(helper.text); - helpersEmitted = true; - } - } - if (helpersEmitted) { - writeLine(); - } - return helpersEmitted; - } - function writeLines(text) { - var lines = text.split(/\r\n?|\n/g); - var indentation = guessIndentation(lines); - for (var i = 0; i < lines.length; i++) { - var line = indentation ? lines[i].slice(indentation) : lines[i]; - if (line.length) { - if (i > 0) { - writeLine(); - } - write(line); - } - } - } - function guessIndentation(lines) { - var indentation; - for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { - var line = lines_1[_a]; - for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { - if (!ts.isWhiteSpace(line.charCodeAt(i))) { - if (indentation === undefined || i < indentation) { - indentation = i; - break; - } - } - } - } - return indentation; - } // // Helpers // function emitShebang() { - var shebang = ts.getShebang(currentText); + var shebang = ts.getShebang(currentSourceFile.text); if (shebang) { write(shebang); writeLine(); @@ -61438,8 +63466,8 @@ var ts; write(suffix); } } - function emitEmbeddedStatement(node) { - if (ts.isBlock(node)) { + function emitEmbeddedStatement(parent, node) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* SingleLine */) { write(" "); emit(node); } @@ -61528,6 +63556,15 @@ var ts; var child = children[start + i]; // Write the delimiter if this is not the first node. if (previousSibling) { + // i.e + // function commentedParameters( + // /* Parameter a */ + // a + // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline + // , + if (delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } write(delimiter); // Write either a line terminator or whitespace to separate the elements. if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { @@ -61544,14 +63581,16 @@ var ts; write(" "); } } + // Emit this child. if (shouldEmitInterveningComments) { - var commentRange = ts.getCommentRange(child); - emitTrailingCommentsOfPosition(commentRange.pos); + if (emitTrailingCommentsOfPosition) { + var commentRange = ts.getCommentRange(child); + emitTrailingCommentsOfPosition(commentRange.pos); + } } else { shouldEmitInterveningComments = mayEmitInterveningComments; } - // Emit this child. emit(child); if (shouldDecreaseIndentAfterEmit) { decreaseIndent(); @@ -61564,6 +63603,15 @@ var ts; if (format & 16 /* CommaDelimited */ && hasTrailingComma) { write(","); } + // Emit any trailing comment of the last element in the list + // i.e + // var array = [... + // 2 + // /* end of element 2 */ + // ]; + if (previousSibling && delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } // Decrease the indent, if requested. if (format & 64 /* Indented */) { decreaseIndent(); @@ -61580,24 +63628,73 @@ var ts; write(getClosingBracket(format)); } } + function write(s) { + writer.write(s); + } + function writeLine() { + writer.writeLine(); + } + function increaseIndent() { + writer.increaseIndent(); + } + function decreaseIndent() { + writer.decreaseIndent(); + } function writeIfAny(nodes, text) { - if (nodes && nodes.length > 0) { + if (ts.some(nodes)) { write(text); } } function writeIfPresent(node, text) { - if (node !== undefined) { + if (node) { write(text); } } function writeToken(token, pos, contextNode) { - return emitTokenWithSourceMap(contextNode, token, pos, writeTokenText); + return onEmitSourceMapOfToken + ? onEmitSourceMapOfToken(contextNode, token, pos, writeTokenText) + : writeTokenText(token, pos); } function writeTokenText(token, pos) { var tokenString = ts.tokenToString(token); write(tokenString); return pos < 0 ? pos : pos + tokenString.length; } + function writeLineOrSpace(node) { + if (ts.getEmitFlags(node) & 1 /* SingleLine */) { + write(" "); + } + else { + writeLine(); + } + } + function writeLines(text) { + var lines = text.split(/\r\n?|\n/g); + var indentation = guessIndentation(lines); + for (var i = 0; i < lines.length; i++) { + var line = indentation ? lines[i].slice(indentation) : lines[i]; + if (line.length) { + writeLine(); + write(line); + writeLine(); + } + } + } + function guessIndentation(lines) { + var indentation; + for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { + var line = lines_1[_a]; + for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { + if (!ts.isWhiteSpace(line.charCodeAt(i))) { + if (indentation === undefined || i < indentation) { + indentation = i; + break; + } + } + } + } + return indentation; + } function increaseIndentIf(value, valueToWriteWhenNotIndenting) { if (value) { increaseIndent(); @@ -61707,15 +63804,23 @@ var ts; && !ts.nodeIsSynthesized(node2) && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } + function isSingleLineEmptyBlock(block) { + return !block.multiLine + && isEmptyBlock(block); + } + function isEmptyBlock(block) { + return block.statements.length === 0 + && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + } function skipSynthesizedParentheses(node) { - while (node.kind === 183 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 184 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; } function getTextOfNode(node, includeTrivia) { if (ts.isGeneratedIdentifier(node)) { - return getGeneratedIdentifier(node); + return generateName(node); } else if (ts.isIdentifier(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { return ts.unescapeIdentifier(node.text); @@ -61740,24 +63845,58 @@ var ts; } return ts.getLiteralText(node, currentSourceFile, languageVersion); } - function isSingleLineEmptyBlock(block) { - return !block.multiLine - && isEmptyBlock(block); + /** + * Push a new name generation scope. + */ + function pushNameGenerationScope() { + tempFlagsStack.push(tempFlags); + tempFlags = 0; } - function isEmptyBlock(block) { - return block.statements.length === 0 - && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + /** + * Pop the current name generation scope. + */ + function popNameGenerationScope() { + tempFlags = tempFlagsStack.pop(); } + /** + * Generate the text for a generated identifier. + */ + function generateName(name) { + if (name.autoGenerateKind === 4 /* Node */) { + // Node names generate unique names based on their original node + // and are cached based on that node's id. + var node = getNodeForGeneratedName(name); + return generateNameCached(node); + } + else { + // Auto, Loop, and Unique names are cached based on their unique + // autoGenerateId. + var autoGenerateId = name.autoGenerateId; + return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(makeName(name))); + } + } + function generateNameCached(node) { + var nodeId = ts.getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); + } + /** + * Returns a value indicating whether a name is unique globally, within the current file, + * or within the NameGenerator. + */ function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentFileIdentifiers, name) && - !ts.hasProperty(generatedNameSet, name); + return !(hasGlobalName && hasGlobalName(name)) + && !currentSourceFile.identifiers.has(name) + && !generatedNames.has(name); } + /** + * Returns a value indicating whether a name is unique within a container. + */ function isUniqueLocalName(name, container) { for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { + if (node.locals) { + var local = node.locals.get(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 */)) { + if (local && local.flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { return false; } } @@ -61765,16 +63904,16 @@ var ts; return true; } /** - * 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. - */ + * 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_40 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_40)) { + var name = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name)) { tempFlags |= flags; - return name_40; + return name; } } while (true) { @@ -61782,19 +63921,21 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_41 = count < 26 + var name = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_41)) { - return name_41; + if (isUniqueName(name)) { + return name; } } } } - // Generate a name that is unique within the current file and doesn't conflict with any names - // in global scope. The name is formed by adding an '_n' suffix to the specified base name, - // where n is a positive integer. Note that names generated by makeTempVariableName and - // makeUniqueName are guaranteed to never conflict. + /** + * 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 /* _ */) { @@ -61804,73 +63945,90 @@ var ts; while (true) { var generatedName = baseName + i; if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; + generatedNames.set(generatedName, generatedName); + return generatedName; } i++; } } + /** + * Generates a unique name for a ModuleDeclaration or EnumDeclaration. + */ function generateNameForModuleOrEnum(node) { var name = getTextOfNode(node.name); // Use module/enum name itself if it is unique, otherwise make a unique variation return isUniqueLocalName(name, node) ? name : makeUniqueName(name); } + /** + * Generates a unique name for an ImportDeclaration or ExportDeclaration. + */ function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); var baseName = expr.kind === 9 /* StringLiteral */ ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; return makeUniqueName(baseName); } + /** + * Generates a unique name for a default export. + */ function generateNameForExportDefault() { return makeUniqueName("default"); } + /** + * Generates a unique name for a class expression. + */ function generateNameForClassExpression() { return makeUniqueName("class"); } + function generateNameForMethodOrAccessor(node) { + if (ts.isIdentifier(node.name)) { + return generateNameCached(node.name); + } + return makeTempVariableName(0 /* Auto */); + } /** * Generates a unique name from a node. - * - * @param node A node. */ function generateNameForNode(node) { switch (node.kind) { case 70 /* Identifier */: return makeUniqueName(getTextOfNode(node)); - case 230 /* ModuleDeclaration */: - case 229 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: + case 231 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 235 /* ImportDeclaration */: - case 241 /* ExportDeclaration */: + case 237 /* ImportDeclaration */: + case 243 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 225 /* FunctionDeclaration */: - case 226 /* ClassDeclaration */: - case 240 /* ExportAssignment */: + case 227 /* FunctionDeclaration */: + case 228 /* ClassDeclaration */: + case 242 /* ExportAssignment */: return generateNameForExportDefault(); - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: return generateNameForClassExpression(); + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0 /* Auto */); } } /** * Generates a unique identifier for a node. - * - * @param name A generated name. */ - function generateName(name) { + function makeName(name) { switch (name.autoGenerateKind) { case 1 /* Auto */: return makeTempVariableName(0 /* Auto */); case 2 /* Loop */: return makeTempVariableName(268435456 /* _i */); case 3 /* Unique */: - return makeUniqueName(name.text); + return makeUniqueName(ts.unescapeIdentifier(name.text)); } ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } /** * Gets the node from which a name should be generated. - * - * @param name A generated name wrapper. */ function getNodeForGeneratedName(name) { var autoGenerateId = name.autoGenerateId; @@ -61890,53 +64048,40 @@ var ts; // otherwise, return the original node for the source; return node; } - /** - * Gets the generated identifier text from a generated identifier. - * - * @param name The generated identifier. - */ - function getGeneratedIdentifier(name) { - if (name.autoGenerateKind === 4 /* Node */) { - // Generated names generate unique names based on their original node - // and are cached based on that node's id - var node = getNodeForGeneratedName(name); - var nodeId = ts.getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = ts.unescapeIdentifier(generateNameForNode(node))); - } - else { - // Auto, Loop, and Unique names are cached based on their unique - // autoGenerateId. - var autoGenerateId = name.autoGenerateId; - return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(generateName(name))); - } - } - function createDelimiterMap() { - var delimiters = []; - delimiters[0 /* None */] = ""; - delimiters[16 /* CommaDelimited */] = ","; - delimiters[4 /* BarDelimited */] = " |"; - delimiters[8 /* AmpersandDelimited */] = " &"; - return delimiters; - } - function getDelimiter(format) { - return delimiters[format & 28 /* DelimitersMask */]; - } - function createBracketsMap() { - var brackets = []; - brackets[512 /* Braces */] = ["{", "}"]; - brackets[1024 /* Parenthesis */] = ["(", ")"]; - brackets[2048 /* AngleBrackets */] = ["<", ">"]; - brackets[4096 /* SquareBrackets */] = ["[", "]"]; - return brackets; - } - function getOpeningBracket(format) { - return brackets[format & 7680 /* BracketsMask */][0]; - } - function getClosingBracket(format) { - return brackets[format & 7680 /* BracketsMask */][1]; - } } - ts.emitFiles = emitFiles; + ts.createPrinter = createPrinter; + function createDelimiterMap() { + var delimiters = []; + delimiters[0 /* None */] = ""; + delimiters[16 /* CommaDelimited */] = ","; + delimiters[4 /* BarDelimited */] = " |"; + delimiters[8 /* AmpersandDelimited */] = " &"; + return delimiters; + } + function getDelimiter(format) { + return delimiters[format & 28 /* DelimitersMask */]; + } + function createBracketsMap() { + var brackets = []; + brackets[512 /* Braces */] = ["{", "}"]; + brackets[1024 /* Parenthesis */] = ["(", ")"]; + brackets[2048 /* AngleBrackets */] = ["<", ">"]; + brackets[4096 /* SquareBrackets */] = ["[", "]"]; + return brackets; + } + function getOpeningBracket(format) { + return brackets[format & 7680 /* BracketsMask */][0]; + } + function getClosingBracket(format) { + return brackets[format & 7680 /* BracketsMask */][1]; + } + // 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 = {})); var ListFormat; (function (ListFormat) { ListFormat[ListFormat["None"] = 0] = "None"; @@ -62046,7 +64191,8 @@ var ts; commonPathComponents = sourcePathComponents; return; } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + var n = Math.min(commonPathComponents.length, sourcePathComponents.length); + for (var i = 0; i < n; i++) { if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { if (i === 0) { // Failed to find any common path component @@ -62100,11 +64246,11 @@ var ts; return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; } function directoryExists(directoryPath) { - if (directoryPath in existingDirectories) { + if (existingDirectories.has(directoryPath)) { return true; } if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; + existingDirectories.set(directoryPath, true); return true; } return false; @@ -62123,10 +64269,11 @@ var ts; } var hash = ts.sys.createHash(data); var mtimeBefore = ts.sys.getModifiedTime(fileName); - if (mtimeBefore && fileName in outputFingerprints) { - var fingerprint = outputFingerprints[fileName]; + if (mtimeBefore) { + var fingerprint = outputFingerprints.get(fileName); // If output has not been changed, and the file has no external modification - if (fingerprint.byteOrderMark === writeByteOrderMark && + if (fingerprint && + fingerprint.byteOrderMark === writeByteOrderMark && fingerprint.hash === hash && fingerprint.mtime.getTime() === mtimeBefore.getTime()) { return; @@ -62134,11 +64281,11 @@ var ts; } ts.sys.writeFile(fileName, data, writeByteOrderMark); var mtimeAfter = ts.sys.getModifiedTime(fileName); - outputFingerprints[fileName] = { + outputFingerprints.set(fileName, { hash: hash, byteOrderMark: writeByteOrderMark, mtime: mtimeAfter - }; + }); } function writeFile(fileName, data, writeByteOrderMark, onError) { try { @@ -62237,10 +64384,14 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_42 = names_1[_i]; - var result = name_42 in cache - ? cache[name_42] - : cache[name_42] = loader(name_42, containingFile); + var name = names_1[_i]; + var result = void 0; + if (cache.has(name)) { + result = cache.get(name); + } + else { + cache.set(name, result = loader(name, containingFile)); + } resolutions.push(result); } return resolutions; @@ -62276,6 +64427,7 @@ var ts; var supportedExtensions = ts.getSupportedExtensions(options); // Map storing if there is emit blocking diagnostics for given input var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); + var moduleResolutionCache; var resolveModuleNamesWorker; if (host.resolveModuleNames) { resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { @@ -62289,7 +64441,8 @@ var ts; }); }; } else { - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -62335,6 +64488,8 @@ var ts; } } } + // unconditionally set moduleResolutionCache to undefined to avoid unnecessary leaks + moduleResolutionCache = undefined; // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; program = { @@ -62369,7 +64524,7 @@ var ts; return program; function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filterSourceFilesInDirectory(files, isSourceFileFromExternalLibrary); + var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified and is valid use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -62393,7 +64548,7 @@ var ts; classifiableNames = ts.createMap(); for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { var sourceFile = files_2[_i]; - ts.copyProperties(sourceFile.classifiableNames, classifiableNames); + ts.copyEntries(sourceFile.classifiableNames, classifiableNames); } } return classifiableNames; @@ -62600,7 +64755,7 @@ var ts; newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } // update fileName -> file mapping - for (var i = 0, len = newSourceFiles.length; i < len; i++) { + for (var i = 0; i < newSourceFiles.length; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; @@ -62629,7 +64784,7 @@ var ts; }; } function isSourceFileFromExternalLibrary(file) { - return sourceFilesFoundSearchingNodeModules[file.path]; + return sourceFilesFoundSearchingNodeModules.get(file.path); } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); @@ -62774,23 +64929,23 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 144 /* Parameter */: - case 147 /* PropertyDeclaration */: + case 145 /* Parameter */: + case 148 /* PropertyDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // Pass through - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: - case 223 /* VariableDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 225 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -62798,35 +64953,35 @@ var ts; } } switch (node.kind) { - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 255 /* HeritageClause */: + case 258 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 107 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 228 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 182 /* TypeAssertionExpression */: + case 183 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; @@ -62841,29 +64996,29 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 226 /* ClassDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: + case 228 /* ClassDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // pass through - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 205 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 207 /* VariableStatement */); } break; - case 147 /* PropertyDeclaration */: + case 148 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { @@ -62875,16 +65030,16 @@ var ts; return; } break; - case 144 /* Parameter */: + case 145 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 199 /* ExpressionWithTypeArguments */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 200 /* ExpressionWithTypeArguments */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -62981,11 +65136,10 @@ var ts; && (options.isolatedModules || isExternalModuleFile) && !file.isDeclarationFile) { // synthesize 'import "tslib"' declaration - var externalHelpersModuleReference = ts.createSynthesizedNode(9 /* StringLiteral */); - externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - var importDecl = ts.createSynthesizedNode(235 /* ImportDeclaration */); - importDecl.parent = file; + var externalHelpersModuleReference = ts.createLiteral(ts.externalHelpersModuleNameText); + var importDecl = ts.createImportDeclaration(undefined, undefined, undefined); externalHelpersModuleReference.parent = importDecl; + importDecl.parent = file; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -63001,9 +65155,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 235 /* ImportDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 241 /* ExportDeclaration */: + case 237 /* ImportDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 243 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -63018,7 +65172,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2 /* Ambient */) || ts.isDeclarationFile(file))) { var moduleName = node.name; // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -63118,18 +65272,18 @@ var ts; } // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { - sourceFilesFoundSearchingNodeModules[file_1.path] = false; + if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth == 0) { + sourceFilesFoundSearchingNodeModules.set(file_1.path, false); if (!options.noResolve) { processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } - else if (file_1 && modulesWithElidedImports[file_1.path]) { + else if (file_1 && modulesWithElidedImports.get(file_1.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports[file_1.path] = false; + modulesWithElidedImports.set(file_1.path, false); processImportedModules(file_1); } } @@ -63146,7 +65300,7 @@ var ts; }); filesByName.set(path, file); if (file) { - sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0); + sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; if (host.useCaseSensitiveFileNames()) { // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case @@ -63195,7 +65349,7 @@ var ts; } function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { // If we already found this library as a primary reference - nothing to do - var previousResolution = resolvedTypeReferenceDirectives[typeReferenceDirective]; + var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { return; } @@ -63229,7 +65383,7 @@ var ts; fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { - resolvedTypeReferenceDirectives[typeReferenceDirective] = resolvedTypeReferenceDirective; + resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); } } function createDiagnostic(refFile, refPos, refEnd, message) { @@ -63278,7 +65432,7 @@ var ts; // This may still end up being an untyped module -- the file won't be included but imports will be allowed. var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { - modulesWithElidedImports[file.path] = true; + modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = ts.toPath(resolvedFileName, currentDirectory, getCanonicalFileName); @@ -63297,8 +65451,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var file = sourceFiles_6[_i]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var file = sourceFiles_3[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -63309,8 +65463,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -63469,7 +65623,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { + ts.forEachEmittedFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -63601,12 +65755,13 @@ var ts; }, { name: "jsx", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "preserve": 1 /* Preserve */, + "react-native": 3 /* ReactNative */, "react": 2 /* React */ }), paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, }, { name: "reactNamespace", @@ -63636,7 +65791,7 @@ var ts; { name: "module", shortName: "m", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "none": ts.ModuleKind.None, "commonjs": ts.ModuleKind.CommonJS, "amd": ts.ModuleKind.AMD, @@ -63650,7 +65805,7 @@ var ts; }, { name: "newLine", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "crlf": 0 /* CarriageReturnLineFeed */, "lf": 1 /* LineFeed */ }), @@ -63748,8 +65903,8 @@ var ts; shortName: "p", type: "string", isFilePath: true, - description: ts.Diagnostics.Compile_the_project_in_the_given_directory, - paramType: ts.Diagnostics.DIRECTORY + description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY }, { name: "removeComments", @@ -63799,7 +65954,7 @@ var ts; { name: "target", shortName: "t", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "es3": 0 /* ES3 */, "es5": 1 /* ES5 */, "es6": 2 /* ES2015 */, @@ -63836,7 +65991,7 @@ var ts; }, { name: "moduleResolution", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "node": ts.ModuleResolutionKind.NodeJs, "classic": ts.ModuleResolutionKind.Classic, }), @@ -63945,7 +66100,7 @@ var ts; type: "list", element: { name: "lib", - type: ts.createMap({ + type: ts.createMapFromTemplate({ // JavaScript only "es5": "lib.es5.d.ts", "es6": "lib.es2015.d.ts", @@ -63994,6 +66149,16 @@ var ts; name: "alwaysStrict", type: "boolean", description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + }, + { + // A list of plugins to load in the language service + name: "plugins", + type: "list", + isTSConfigOnly: true, + element: { + name: "plugin", + type: "object" + } } ]; /* @internal */ @@ -64056,9 +66221,9 @@ var ts; var optionNameMap = ts.createMap(); var shortOptionNames = ts.createMap(); ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; + optionNameMap.set(option.name.toLowerCase(), option); if (option.shortName) { - shortOptionNames[option.shortName] = option.name; + shortOptionNames.set(option.shortName, option.name); } }); optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; @@ -64067,7 +66232,7 @@ var ts; ts.getOptionNameMap = getOptionNameMap; /* @internal */ function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; @@ -64119,11 +66284,12 @@ var ts; 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 (s in shortOptionNames) { - s = shortOptionNames[s]; + var short = shortOptionNames.get(s); + if (short !== undefined) { + s = short; } - if (s in optionNameMap) { - var opt = optionNameMap[s]; + var opt = optionNameMap.get(s); + if (opt) { if (opt.isTSConfigOnly) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); } @@ -64271,21 +66437,20 @@ var ts; } function getNameOfCompilerOptionValue(value, customTypeMap) { // There is a typeMap associated with this command-line option so use it to map value back to its name - for (var key in customTypeMap) { - if (customTypeMap[key] === value) { + return ts.forEachEntry(customTypeMap, function (mapValue, key) { + if (mapValue === value) { return key; } - } - return undefined; + }); } function serializeCompilerOptions(options) { - var result = ts.createMap(); + var result = {}; var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_43 in options) { - if (ts.hasProperty(options, name_43)) { + for (var name in options) { + if (ts.hasProperty(options, name)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - switch (name_43) { + switch (name) { case "init": case "watch": case "version": @@ -64293,14 +66458,14 @@ var ts; case "project": break; default: - var value = options[name_43]; - var optionDefinition = optionsNameMap[name_43.toLowerCase()]; + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { // There is no map associated with this compiler option then use the value as-is // This is the case if the value is expect to be string, number, boolean or list of string - result[name_43] = value; + result[name] = value; } else { if (optionDefinition.type === "list") { @@ -64309,11 +66474,11 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_43] = convertedValue; + result[name] = convertedValue; } else { // There is a typeMap associated with this command-line option so use it to map value back to its name - result[name_43] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -64361,6 +66526,7 @@ var ts; if (resolutionStack === void 0) { resolutionStack = []; } if (extraFileExtensions === void 0) { extraFileExtensions = []; } var errors = []; + basePath = ts.normalizeSlashes(basePath); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -64538,8 +66704,8 @@ var ts; } var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); for (var id in jsonOptions) { - if (id in optionNameMap) { - var opt = optionNameMap[id]; + var opt = optionNameMap.get(id); + if (opt) { defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); } else { @@ -64573,8 +66739,9 @@ var ts; } function convertJsonOptionOfCustomType(opt, value, errors) { var key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; + var val = opt.type.get(key); + if (val !== undefined) { + return val; } else { errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); @@ -64698,7 +66865,7 @@ var ts; for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { var fileName = fileNames_1[_i]; var file = ts.combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; + literalFileMap.set(keyMapper(file), file); } } if (include && include.length > 0) { @@ -64719,14 +66886,13 @@ var ts; // same directory, we should remove it. removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); var key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; + if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) { + wildcardFileMap.set(key, file); } } } - var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); - var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); + var literalFiles = ts.arrayFrom(literalFileMap.values()); + var wildcardFiles = ts.arrayFrom(wildcardFileMap.values()); return { fileNames: literalFiles.concat(wildcardFiles), wildcardDirectories: wildcardDirectories @@ -64734,8 +66900,8 @@ var ts; } function validateSpecs(specs, errors, allowTrailingRecursion) { var validSpecs = []; - for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { - var spec = specs_2[_i]; + for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { + var spec = specs_1[_i]; if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); } @@ -64769,7 +66935,7 @@ var ts; // /a/b/a?z - Watch /a/b directly to catch any new file matching a?z var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - var wildcardDirectories = ts.createMap(); + var wildcardDirectories = {}; if (include !== undefined) { var recursiveKeys = []; for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { @@ -64791,14 +66957,16 @@ var ts; } } // Remove any subpaths under an existing recursively watched directory. - for (var key in wildcardDirectories) { - for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { - var recursiveKey = recursiveKeys_1[_a]; - if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; + for (var key in wildcardDirectories) + if (ts.hasProperty(wildcardDirectories, key)) { + for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { + var recursiveKey = recursiveKeys_1[_a]; + if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; + } } } - } + ; } return wildcardDirectories; } @@ -64825,11 +66993,11 @@ var ts; */ function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); + var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions); for (var i = 0 /* Highest */; i < adjustedExtensionPriority; i++) { var higherPriorityExtension = extensions[i]; var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { return true; } } @@ -64845,23 +67013,13 @@ var ts; */ function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); + var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions); for (var i = nextExtensionPriority; i < extensions.length; i++) { var lowerPriorityExtension = extensions[i]; var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; + wildcardFiles.delete(lowerPriorityPath); } } - /** - * Adds a file to an array of files. - * - * @param output The output array. - * @param file The file path. - */ - function addFileToOutput(output, file) { - output.push(file); - return output; - } /** * Gets a case sensitive key. * @@ -65044,6 +67202,10 @@ var ts; ScriptElementKind.letElement = "let"; ScriptElementKind.directory = "directory"; ScriptElementKind.externalModuleName = "external module name"; + /** + * + **/ + ScriptElementKind.jsxAttribute = "JSX attribute"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; (function (ScriptElementKindModifier) { @@ -65129,33 +67291,34 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 144 /* Parameter */: - case 223 /* VariableDeclaration */: - case 174 /* BindingElement */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: - case 260 /* EnumMember */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 256 /* CatchClause */: + case 145 /* Parameter */: + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 260 /* PropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: + case 263 /* EnumMember */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 259 /* CatchClause */: + case 252 /* JsxAttribute */: return 1 /* Value */; - case 143 /* TypeParameter */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 161 /* TypeLiteral */: + case 144 /* TypeParameter */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 162 /* TypeLiteral */: return 2 /* Type */; - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -65165,22 +67328,25 @@ var ts; else { return 4 /* Namespace */; } - case 238 /* NamedImports */: - case 239 /* ImportSpecifier */: - case 234 /* ImportEqualsDeclaration */: - case 235 /* ImportDeclaration */: - case 240 /* ExportAssignment */: - case 241 /* ExportDeclaration */: + case 240 /* NamedImports */: + case 241 /* ImportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportDeclaration */: + case 242 /* ExportAssignment */: + case 243 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 261 /* SourceFile */: + case 264 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 240 /* ExportAssignment */) { + if (node.kind === 264 /* SourceFile */) { + return 1 /* Value */; + } + else if (node.parent.kind === 242 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -65205,15 +67371,15 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 141 /* QualifiedName */ && + if (node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 234 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 236 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function isInRightSideOfImport(node) { - while (node.parent.kind === 141 /* QualifiedName */) { + while (node.parent.kind === 142 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -65224,27 +67390,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 141 /* QualifiedName */) { - while (root.parent && root.parent.kind === 141 /* QualifiedName */) { + if (root.parent.kind === 142 /* QualifiedName */) { + while (root.parent && root.parent.kind === 142 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 157 /* TypeReference */ && !isLastClause; + return root.parent.kind === 158 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 177 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 177 /* PropertyAccessExpression */) { + if (root.parent.kind === 178 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 178 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 199 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 255 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 200 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 258 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 226 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || - (decl.kind === 227 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); + return (decl.kind === 228 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || + (decl.kind === 229 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); } return false; } @@ -65252,17 +67418,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 157 /* TypeReference */ || - (node.parent.kind === 199 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + return node.parent.kind === 158 /* TypeReference */ || + (node.parent.kind === 200 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || (node.kind === 98 /* ThisKeyword */ && !ts.isPartOfExpression(node)) || - node.kind === 167 /* ThisType */; + node.kind === 168 /* ThisType */; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 179 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 180 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 180 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 181 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -65275,7 +67441,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 219 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 221 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -65285,13 +67451,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 /* Identifier */ && - (node.parent.kind === 215 /* BreakStatement */ || node.parent.kind === 214 /* ContinueStatement */) && + (node.parent.kind === 217 /* BreakStatement */ || node.parent.kind === 216 /* ContinueStatement */) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 /* Identifier */ && - node.parent.kind === 219 /* LabeledStatement */ && + node.parent.kind === 221 /* LabeledStatement */ && node.parent.label === node; } function isLabelName(node) { @@ -65299,15 +67465,15 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 177 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 230 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 232 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -65318,19 +67484,19 @@ var ts; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 257 /* PropertyAssignment */: - case 260 /* EnumMember */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 230 /* ModuleDeclaration */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 260 /* PropertyAssignment */: + case 263 /* EnumMember */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 232 /* ModuleDeclaration */: return node.parent.name === node; - case 178 /* ElementAccessExpression */: + case 179 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 142 /* ComputedPropertyName */: + case 143 /* ComputedPropertyName */: return true; } } @@ -65379,17 +67545,17 @@ var ts; return undefined; } switch (node.kind) { - case 261 /* SourceFile */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: + case 264 /* SourceFile */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: return node; } } @@ -65397,46 +67563,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 261 /* SourceFile */: + case 264 /* SourceFile */: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return ts.ScriptElementKind.moduleElement; - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: return ts.ScriptElementKind.classElement; - case 227 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; - case 228 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; - case 229 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; - case 223 /* VariableDeclaration */: + case 229 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 230 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 231 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; + case 225 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 174 /* BindingElement */: + case 175 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: return ts.ScriptElementKind.functionElement; - case 151 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; - case 152 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 152 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; + case 153 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: return ts.ScriptElementKind.memberFunctionElement; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return ts.ScriptElementKind.memberVariableElement; - case 155 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; - case 154 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; - case 153 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; - case 150 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; - case 143 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; - case 260 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; - case 144 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 234 /* ImportEqualsDeclaration */: - case 239 /* ImportSpecifier */: - case 236 /* ImportClause */: - case 243 /* ExportSpecifier */: - case 237 /* NamespaceImport */: + case 156 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; + case 155 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; + case 154 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; + case 151 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; + case 144 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; + case 263 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; + case 145 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 236 /* ImportEqualsDeclaration */: + case 241 /* ImportSpecifier */: + case 238 /* ImportClause */: + case 245 /* ExportSpecifier */: + case 239 /* NamespaceImport */: return ts.ScriptElementKind.alias; - case 285 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -65451,7 +67617,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 171 /* LiteralType */ ? node.parent : node; + var searchNode = node.parent.kind === 172 /* LiteralType */ ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32 /* StringLiteral */) { return type; @@ -65466,7 +67632,7 @@ var ts; return true; case 70 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 144 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 145 /* Parameter */; default: return false; } @@ -65511,42 +67677,42 @@ var ts; return false; } switch (n.kind) { - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 176 /* ObjectLiteralExpression */: - case 172 /* ObjectBindingPattern */: - case 161 /* TypeLiteral */: - case 204 /* Block */: - case 231 /* ModuleBlock */: - case 232 /* CaseBlock */: - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 177 /* ObjectLiteralExpression */: + case 173 /* ObjectBindingPattern */: + case 162 /* TypeLiteral */: + case 206 /* Block */: + case 233 /* ModuleBlock */: + case 234 /* CaseBlock */: + case 240 /* NamedImports */: + case 244 /* NamedExports */: return nodeEndsWith(n, 17 /* CloseBraceToken */, sourceFile); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 180 /* NewExpression */: + case 181 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 179 /* CallExpression */: - case 183 /* ParenthesizedExpression */: - case 166 /* ParenthesizedType */: + case 180 /* CallExpression */: + case 184 /* ParenthesizedExpression */: + case 167 /* ParenthesizedType */: return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); - case 158 /* FunctionType */: - case 159 /* ConstructorType */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 154 /* ConstructSignature */: - case 153 /* CallSignature */: - case 185 /* ArrowFunction */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 155 /* ConstructSignature */: + case 154 /* CallSignature */: + case 186 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -65556,67 +67722,67 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 19 /* CloseParenToken */, sourceFile); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 208 /* IfStatement */: + case 210 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24 /* SemicolonToken */); - case 175 /* ArrayLiteralExpression */: - case 173 /* ArrayBindingPattern */: - case 178 /* ElementAccessExpression */: - case 142 /* ComputedPropertyName */: - case 163 /* TupleType */: + case 176 /* ArrayLiteralExpression */: + case 174 /* ArrayBindingPattern */: + case 179 /* ElementAccessExpression */: + case 143 /* ComputedPropertyName */: + case 164 /* TupleType */: return nodeEndsWith(n, 21 /* CloseBracketToken */, sourceFile); - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); - case 253 /* CaseClause */: - case 254 /* DefaultClause */: + case 256 /* CaseClause */: + case 257 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 210 /* WhileStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 212 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 209 /* DoStatement */: + case 211 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 105 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 160 /* TypeQuery */: + case 161 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 187 /* TypeOfExpression */: - case 186 /* DeleteExpression */: - case 188 /* VoidExpression */: - case 195 /* YieldExpression */: - case 196 /* SpreadElement */: + case 188 /* TypeOfExpression */: + case 187 /* DeleteExpression */: + case 189 /* VoidExpression */: + case 196 /* YieldExpression */: + case 197 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 181 /* TaggedTemplateExpression */: + case 182 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 194 /* TemplateExpression */: + case 195 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 202 /* TemplateSpan */: + case 204 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 241 /* ExportDeclaration */: - case 235 /* ImportDeclaration */: + case 243 /* ExportDeclaration */: + case 237 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 190 /* PrefixUnaryExpression */: + case 191 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 193 /* ConditionalExpression */: + case 194 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -65672,7 +67838,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 === 292 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 296 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -65739,8 +67905,8 @@ var ts; } } // find the child that contains 'position' - for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { - var child = current.getChildAt(i); + for (var _a = 0, _b = current.getChildren(); _a < _b.length; _a++) { + var child = _b[_a]; // all jsDocComment nodes were already visited if (ts.isJSDocNode(child)) { continue; @@ -65819,7 +67985,7 @@ var ts; return n; } var children = n.getChildren(); - for (var i = 0, len = children.length; i < len; i++) { + for (var i = 0; i < children.length; 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' @@ -65844,7 +68010,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 261 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 264 /* 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. @@ -65903,17 +68069,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 252 /* JsxExpression */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 255 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 252 /* JsxExpression */) { + if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 255 /* JsxExpression */) { return true; } //
|
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 249 /* JsxClosingElement */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 251 /* JsxClosingElement */) { return true; } return false; @@ -66025,17 +68191,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 157 /* TypeReference */ || node.kind === 179 /* CallExpression */) { + if (node.kind === 158 /* TypeReference */ || node.kind === 180 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 226 /* ClassDeclaration */ || node.kind === 227 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 228 /* ClassDeclaration */ || node.kind === 229 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 140 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 141 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { @@ -66094,18 +68260,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 175 /* ArrayLiteralExpression */ || - node.kind === 176 /* ObjectLiteralExpression */) { + if (node.kind === 176 /* ArrayLiteralExpression */ || + node.kind === 177 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 192 /* BinaryExpression */ && + if (node.parent.kind === 193 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 57 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 213 /* ForOfStatement */ && + if (node.parent.kind === 215 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -66113,7 +68279,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 257 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 260 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -66141,12 +68307,32 @@ var ts; } } ts.isInNonReferenceComment = isInNonReferenceComment; + function createTextSpanFromNode(node, sourceFile) { + return ts.createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); + } + ts.createTextSpanFromNode = createTextSpanFromNode; + function isTypeKeyword(kind) { + switch (kind) { + case 118 /* AnyKeyword */: + case 121 /* BooleanKeyword */: + case 129 /* NeverKeyword */: + case 132 /* NumberKeyword */: + case 133 /* ObjectKeyword */: + case 135 /* StringKeyword */: + case 136 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + return true; + default: + return false; + } + } + ts.isTypeKeyword = isTypeKeyword; })(ts || (ts = {})); // Display-part writer helpers /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 144 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 145 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -66170,7 +68356,8 @@ var ts; decreaseIndent: function () { indent--; }, clear: resetWriter, trackSymbol: ts.noop, - reportInaccessibleThisError: ts.noop + reportInaccessibleThisError: ts.noop, + reportIllegalExtends: ts.noop }; function writeIndent() { if (lineStart) { @@ -66327,7 +68514,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location) && - location.parent.kind === 142 /* ComputedPropertyName */) { + location.parent.kind === 143 /* ComputedPropertyName */) { return location.text; } // Try to get the local symbol if we're dealing with an 'export default' @@ -66339,7 +68526,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 239 /* ImportSpecifier */ || location.parent.kind === 243 /* ExportSpecifier */) && + (location.parent.kind === 241 /* ImportSpecifier */ || location.parent.kind === 245 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -66406,6 +68593,11 @@ var ts; }; } ts.sanitizeConfigFile = sanitizeConfigFile; + function getOpenBraceEnd(constructor, sourceFile) { + // First token is the open curly, this is where we want to put the 'super' call. + return constructor.body.getFirstToken(sourceFile).getEnd(); + } + ts.getOpenBraceEnd = getOpenBraceEnd; })(ts || (ts = {})); var ts; (function (ts) { @@ -66454,7 +68646,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 124 /* GetKeyword */ || - keyword2 === 133 /* SetKeyword */ || + keyword2 === 134 /* SetKeyword */ || keyword2 === 122 /* ConstructorKeyword */ || keyword2 === 114 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". @@ -66473,7 +68665,7 @@ var ts; var entries = []; var dense = classifications.spans; var lastEnd = 0; - for (var i = 0, n = dense.length; i < n; i += 3) { + for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; var length_4 = dense[i + 1]; var type = dense[i + 2]; @@ -66613,10 +68805,10 @@ var ts; angleBracketStack--; } else if (token === 118 /* AnyKeyword */ || - token === 134 /* StringKeyword */ || + token === 135 /* StringKeyword */ || token === 132 /* NumberKeyword */ || token === 121 /* BooleanKeyword */ || - token === 135 /* SymbolKeyword */) { + token === 136 /* 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, @@ -66788,7 +68980,7 @@ var ts; } } function isKeyword(token) { - return token >= 71 /* FirstKeyword */ && token <= 140 /* LastKeyword */; + return token >= 71 /* FirstKeyword */ && token <= 141 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -66845,10 +69037,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 230 /* ModuleDeclaration */: - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 225 /* FunctionDeclaration */: + case 232 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 227 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -66899,7 +69091,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 230 /* ModuleDeclaration */ && + return declaration.kind === 232 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -66914,7 +69106,7 @@ var ts; // 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]) { + if (classifiableNames.get(identifier.text)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { var type = classifySymbol(symbol, ts.getMeaningFromLocation(node)); @@ -66960,7 +69152,7 @@ var ts; 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) { + for (var i = 0; i < dense.length; i += 3) { result.push({ textSpan: ts.createTextSpan(dense[i], dense[i + 1]), classificationType: getClassificationTypeName(dense[i + 2]) @@ -67063,16 +69255,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 281 /* JSDocParameterTag */: + case 285 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 284 /* JSDocTemplateTag */: + case 288 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 283 /* JSDocTypeTag */: + case 287 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 282 /* JSDocReturnTag */: + case 286 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -67159,22 +69351,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 248 /* JsxOpeningElement */: + case 250 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 249 /* JsxClosingElement */: + case 251 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 247 /* JsxSelfClosingElement */: + case 249 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 250 /* JsxAttribute */: + case 252 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -67202,17 +69394,17 @@ var ts; if (token) { if (tokenKind === 57 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 223 /* VariableDeclaration */ || - token.parent.kind === 147 /* PropertyDeclaration */ || - token.parent.kind === 144 /* Parameter */ || - token.parent.kind === 250 /* JsxAttribute */) { + if (token.parent.kind === 225 /* VariableDeclaration */ || + token.parent.kind === 148 /* PropertyDeclaration */ || + token.parent.kind === 145 /* Parameter */ || + token.parent.kind === 252 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 192 /* BinaryExpression */ || - token.parent.kind === 190 /* PrefixUnaryExpression */ || - token.parent.kind === 191 /* PostfixUnaryExpression */ || - token.parent.kind === 193 /* ConditionalExpression */) { + if (token.parent.kind === 193 /* BinaryExpression */ || + token.parent.kind === 191 /* PrefixUnaryExpression */ || + token.parent.kind === 192 /* PostfixUnaryExpression */ || + token.parent.kind === 194 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -67222,7 +69414,7 @@ var ts; return 4 /* numericLiteral */; } else if (tokenKind === 9 /* StringLiteral */) { - return token.parent.kind === 250 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 252 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 11 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -67238,32 +69430,32 @@ var ts; else if (tokenKind === 70 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 143 /* TypeParameter */: + case 144 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 144 /* Parameter */: + case 145 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -67280,9 +69472,8 @@ var ts; // Ignore nodes that don't intersect the original span to classify. if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { checkForClassificationCancellation(cancellationToken, element.kind); - var children = element.getChildren(sourceFile); - for (var i = 0, n = children.length; i < n; i++) { - var child = children[i]; + for (var _i = 0, _a = element.getChildren(sourceFile); _i < _a.length; _i++) { + var child = _a[_i]; if (!tryClassifyNode(child)) { // Recurse into our child nodes. processElement(child); @@ -67293,7 +69484,6 @@ var ts; } ts.getEncodedSyntacticClassifications = getEncodedSyntacticClassifications; })(ts || (ts = {})); -/// /* @internal */ var ts; (function (ts) { @@ -67301,10 +69491,10 @@ var ts; (function (Completions) { function getCompletionsAtPosition(host, typeChecker, log, compilerOptions, sourceFile, position) { if (ts.isInReferenceComment(sourceFile, position)) { - return getTripleSlashReferenceCompletion(sourceFile, position); + return getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); } if (ts.isInString(sourceFile, position)) { - return getStringLiteralCompletionEntries(sourceFile, position); + return getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log); } var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (!completionData) { @@ -67317,13 +69507,13 @@ var ts; } var entries = []; if (ts.isSourceFileJavaScript(sourceFile)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true); - ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); + ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target)); } else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 /* JSX */ && - location.parent && location.parent.kind === 249 /* JsxClosingElement */) { + location.parent && location.parent.kind === 251 /* JsxClosingElement */) { // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. // For example: @@ -67340,629 +69530,642 @@ var ts; return undefined; } } - getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true); + getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); } // Add keywords if this is not a member completion list if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { - var entries = []; - var nameTable = ts.getNameTable(sourceFile); - for (var name_44 in nameTable) { - // Skip identifiers produced only from the current location - if (nameTable[name_44] === position) { - continue; + } + Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames, target) { + var entries = []; + var nameTable = ts.getNameTable(sourceFile); + nameTable.forEach(function (pos, name) { + // Skip identifiers produced only from the current location + if (pos === position) { + return; + } + if (!uniqueNames.get(name)) { + uniqueNames.set(name, name); + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name), target, /*performCharacterChecks*/ true); + if (displayName) { + var entry = { + name: displayName, + kind: ts.ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } - if (!uniqueNames[name_44]) { - uniqueNames[name_44] = name_44; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_44), compilerOptions.target, /*performCharacterChecks*/ true); - if (displayName) { - var entry = { - name: displayName, - kind: ts.ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; + } + }); + return entries; + } + function createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target) { + // 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(typeChecker, symbol, target, performCharacterChecks, 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: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), + kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), + sortText: "0", + }; + } + function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks, typeChecker, target, log) { + var start = ts.timestamp(); + var uniqueNames = ts.createMap(); + if (symbols) { + for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { + var symbol = symbols_4[_i]; + var entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target); + if (entry) { + var id = ts.escapeIdentifier(entry.name); + if (!uniqueNames.get(id)) { entries.push(entry); + uniqueNames.set(id, id); } } } - return entries; } - function createCompletionEntry(symbol, location, performCharacterChecks) { - // 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(typeChecker, symbol, compilerOptions.target, performCharacterChecks, location); - if (!displayName) { - return undefined; + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); + return uniqueNames; + } + function getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log) { + var node = ts.findPrecedingToken(position, sourceFile); + if (!node || node.kind !== 9 /* StringLiteral */) { + return undefined; + } + if (node.parent.kind === 260 /* PropertyAssignment */ && + node.parent.parent.kind === 177 /* ObjectLiteralExpression */ && + node.parent.name === node) { + // Get quoted name of properties of the object literal expression + // i.e. interface ConfigFiles { + // 'jspm:dev': string + // } + // let files: ConfigFiles = { + // '/*completion position*/' + // } + // + // function foo(c: ConfigFiles) {} + // foo({ + // '/*completion position*/' + // }); + return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent, typeChecker, compilerOptions.target, log); + } + else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { + // Get all names of properties on the expression + // i.e. interface A { + // 'prop1': string + // } + // let a: A; + // a['/*completion position*/'] + return getStringLiteralCompletionEntriesFromElementAccess(node.parent, typeChecker, compilerOptions.target, log); + } + else if (node.parent.kind === 237 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + // Get all known external module names or complete a path to a module + // i.e. import * as ns from "/*completion position*/"; + // import x = require("/*completion position*/"); + // var y = require("/*completion position*/"); + return getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker); + } + else if (isEqualityExpression(node.parent)) { + // Get completions from the type of the other operand + // i.e. switch (a) { + // case '/*completion position*/' + // } + return getStringLiteralCompletionEntriesFromType(typeChecker.getTypeAtLocation(node.parent.left === node ? node.parent.right : node.parent.left), typeChecker); + } + else if (ts.isCaseOrDefaultClause(node.parent)) { + // Get completions from the type of the switch expression + // i.e. x === '/*completion position' + return getStringLiteralCompletionEntriesFromType(typeChecker.getTypeAtLocation(node.parent.parent.parent.expression), typeChecker); + } + else { + var argumentInfo = ts.SignatureHelp.getImmediatelyContainingArgumentInfo(node, position, sourceFile); + if (argumentInfo) { + // Get string literal completions from specialized signatures of the target + // i.e. declare function f(a: 'A'); + // f("/*completion position*/") + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker); } - // 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: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0", - }; + // Get completion for string literal from string literal type + // i.e. var x: "hi" | "hello" = "/*completion position*/" + return getStringLiteralCompletionEntriesFromType(typeChecker.getContextualType(node), typeChecker); } - function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks) { - var start = ts.timestamp(); - var uniqueNames = ts.createMap(); - if (symbols) { - for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { - var symbol = symbols_4[_i]; - var entry = createCompletionEntry(symbol, location, performCharacterChecks); - if (entry) { - var id = ts.escapeIdentifier(entry.name); - if (!uniqueNames[id]) { - entries.push(entry); - uniqueNames[id] = id; + } + function getStringLiteralCompletionEntriesFromPropertyAssignment(element, typeChecker, target, log) { + var type = typeChecker.getContextualType(element.parent); + var entries = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/ false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + } + } + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker) { + var candidates = []; + var entries = []; + typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); + for (var _i = 0, candidates_3 = candidates; _i < candidates_3.length; _i++) { + var candidate = candidates_3[_i]; + addStringLiteralCompletionsFromType(typeChecker.getParameterType(candidate, argumentInfo.argumentIndex), entries, typeChecker); + } + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; + } + return undefined; + } + function getStringLiteralCompletionEntriesFromElementAccess(node, typeChecker, target, log) { + var type = typeChecker.getTypeAtLocation(node.expression); + var entries = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/ false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + } + return undefined; + } + function getStringLiteralCompletionEntriesFromType(type, typeChecker) { + if (type) { + var entries = []; + addStringLiteralCompletionsFromType(type, entries, typeChecker); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; + } + } + return undefined; + } + function addStringLiteralCompletionsFromType(type, result, typeChecker) { + if (type && type.flags & 16384 /* TypeParameter */) { + type = typeChecker.getApparentType(type); + } + if (!type) { + return; + } + if (type.flags & 65536 /* Union */) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + addStringLiteralCompletionsFromType(t, result, typeChecker); + } + } + else if (type.flags & 32 /* StringLiteral */) { + result.push({ + name: type.text, + kindModifiers: ts.ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.variableElement, + sortText: "0" + }); + } + } + function getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker) { + var literalValue = ts.normalizeSlashes(node.text); + var scriptPath = node.getSourceFile().path; + var scriptDirectory = ts.getDirectoryPath(scriptPath); + var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); + var entries; + if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { + var extensions = ts.getSupportedExtensions(compilerOptions); + if (compilerOptions.rootDirs) { + entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, span, compilerOptions, host, scriptPath); + } + else { + entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, span, host, scriptPath); + } + } + else { + // Check for node modules + entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span, compilerOptions, host, typeChecker); + } + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: entries + }; + } + /** + * Takes a script path and returns paths for all potential folders that could be merged with its + * containing folder via the "rootDirs" compiler option + */ + function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { + // Make all paths absolute/normalized if they are not already + rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); + // Determine the path to the directory containing the script relative to the root directory it is contained within + var relativeDirectory; + for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { + var rootDirectory = rootDirs_1[_i]; + if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { + relativeDirectory = scriptPath.substr(rootDirectory.length); + break; + } + } + // Now find a path for each potential directory that is to be merged with the one containing the script + return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); + } + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, compilerOptions, host, exclude) { + var basePath = compilerOptions.project || host.getCurrentDirectory(); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); + var result = []; + for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { + var baseDirectory = baseDirectories_1[_i]; + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, host, exclude, result); + } + return result; + } + /** + * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. + */ + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, host, exclude, result) { + if (result === void 0) { result = []; } + if (fragment === undefined) { + fragment = ""; + } + fragment = ts.normalizeSlashes(fragment); + /** + * Remove the basename from the path. Note that we don't use the basename to filter completions; + * the client is responsible for refining completions. + */ + fragment = ts.getDirectoryPath(fragment); + if (fragment === "") { + fragment = "." + ts.directorySeparator; + } + fragment = ts.ensureTrailingDirectorySeparator(fragment); + var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); + var baseDirectory = ts.getDirectoryPath(absolutePath); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + if (tryDirectoryExists(host, baseDirectory)) { + // Enumerate the available files if possible + var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + if (files) { + /** + * Multiple file entries might map to the same truncated name once we remove extensions + * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: + * + * both foo.ts and foo.tsx become foo + */ + var foundFiles = ts.createMap(); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var filePath = files_3[_i]; + filePath = ts.normalizePath(filePath); + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { + continue; + } + var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); + if (!foundFiles.get(foundFileName)) { + foundFiles.set(foundFileName, true); + } + } + ts.forEachKey(foundFiles, function (foundFile) { + result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); + }); + } + // If possible, get folder completion as well + var directories = tryGetDirectories(host, baseDirectory); + if (directories) { + for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { + var directory = directories_2[_a]; + var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); + result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); + } + } + } + return result; + } + /** + * Check all of the declared modules and those in node modules. Possible sources of modules: + * Modules that are found by the type checker + * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) + * Modules from node_modules (i.e. those listed in package.json) + * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions + */ + function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span, compilerOptions, host, typeChecker) { + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; + var result; + if (baseUrl) { + var fileExtensions = ts.getSupportedExtensions(compilerOptions); + var projectDir = compilerOptions.project || host.getCurrentDirectory(); + var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); + result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, /*includeExtensions*/ false, span, host); + if (paths) { + for (var path in paths) { + if (paths.hasOwnProperty(path)) { + if (path === "*") { + if (paths[path]) { + for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { + var pattern = _a[_i]; + for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host); _b < _c.length; _b++) { + var match = _c[_b]; + result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + else if (ts.startsWith(path, fragment)) { + var entry = paths[path] && paths[path].length === 1 && paths[path][0]; + if (entry) { + result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); + } } } } } - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); - return uniqueNames; } - function getStringLiteralCompletionEntries(sourceFile, position) { - var node = ts.findPrecedingToken(position, sourceFile); - if (!node || node.kind !== 9 /* StringLiteral */) { - return undefined; + else { + result = []; + } + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); + for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host); _d < _e.length; _d++) { + var moduleName = _e[_d]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + return result; + } + function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { + if (host.readDirectory) { + var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; + if (parsed) { + // The prefix has two effective parts: the directory path and the base component after the filepath that is not a + // full directory component. For example: directory/path/of/prefix/base* + var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); + var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); + var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); + var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; + // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call + var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; + var normalizedSuffix = ts.normalizePath(parsed.suffix); + var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); + var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + // If we have a suffix, then we need to read the directory all the way down. We could create a glob + // that encodes the suffix, but we would have to escape the character "?" which readDirectory + // doesn't support. For now, this is safer but slower + var includeGlob = normalizedSuffix ? "**/*" : "./*"; + var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); + if (matches) { + var result = []; + // Trim away prefix and suffix + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; + var normalizedMatch = ts.normalizePath(match); + if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { + continue; + } + var start = completePrefix.length; + var length_5 = normalizedMatch.length - start - normalizedSuffix.length; + result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); + } + return result; + } } - if (node.parent.kind === 257 /* PropertyAssignment */ && - node.parent.parent.kind === 176 /* ObjectLiteralExpression */ && - node.parent.name === node) { - // Get quoted name of properties of the object literal expression - // i.e. interface ConfigFiles { - // 'jspm:dev': string - // } - // let files: ConfigFiles = { - // '/*completion position*/' - // } - // - // function foo(c: ConfigFiles) {} - // foo({ - // '/*completion position*/' - // }); - return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); + } + return undefined; + } + function enumeratePotentialNonRelativeModules(fragment, scriptPath, options, typeChecker, host) { + // Check If this is a nested module + var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; + var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; + // Get modules that the type checker picked up + var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); + var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); + // Nested modules of the form "module-name/sub" need to be adjusted to only return the string + // after the last '/' that appears in the fragment because that's where the replacement span + // starts + if (isNestedModule) { + var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); + nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { + if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { + return moduleName.substr(moduleNameWithSeperator_1.length); + } + return moduleName; + }); + } + if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { + for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { + var visibleModule = _a[_i]; + if (!isNestedModule) { + nonRelativeModules.push(visibleModule.moduleName); + } + else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { + var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, /*exclude*/ undefined, /*include*/ ["./*"]); + if (nestedFiles) { + for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { + var f = nestedFiles_1[_b]; + f = ts.normalizePath(f); + var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); + nonRelativeModules.push(nestedModule); + } + } + } } - else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { - // Get all names of properties on the expression - // i.e. interface A { - // 'prop1': string - // } - // let a: A; - // a['/*completion position*/'] - return getStringLiteralCompletionEntriesFromElementAccess(node.parent); - } - else if (node.parent.kind === 235 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { - // Get all known external module names or complete a path to a module - // i.e. import * as ns from "/*completion position*/"; - // import x = require("/*completion position*/"); - // var y = require("/*completion position*/"); - return getStringLiteralCompletionEntriesFromModuleNames(node); + } + return ts.deduplicate(nonRelativeModules); + } + function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { + var token = ts.getTokenAtPosition(sourceFile, position); + if (!token) { + return undefined; + } + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + if (!commentRanges || !commentRanges.length) { + return undefined; + } + var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); + if (!range) { + return undefined; + } + var completionInfo = { + /** + * We don't want the editor to offer any other completions, such as snippets, inside a comment. + */ + isGlobalCompletion: false, + isMemberCompletion: false, + /** + * The user may type in a path that doesn't yet exist, creating a "new identifier" + * with respect to the collection of identifiers the server is aware of. + */ + isNewIdentifierLocation: true, + entries: [] + }; + var text = sourceFile.text.substr(range.pos, position - range.pos); + var match = tripleSlashDirectiveFragmentRegex.exec(text); + if (match) { + var prefix = match[1]; + var kind = match[2]; + var toComplete = match[3]; + var scriptPath = ts.getDirectoryPath(sourceFile.path); + if (kind === "path") { + // Give completions for a relative path + var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, span_10, host, sourceFile.path); } else { - var argumentInfo = ts.SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); - if (argumentInfo) { - // Get string literal completions from specialized signatures of the target - // i.e. declare function f(a: 'A'); - // f("/*completion position*/") - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); - } - // Get completion for string literal from string literal type - // i.e. var x: "hi" | "hello" = "/*completion position*/" - return getStringLiteralCompletionEntriesFromContextualType(node); + // Give completions based on the typings available + var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); } } - function getStringLiteralCompletionEntriesFromPropertyAssignment(element) { - var type = typeChecker.getContextualType(element.parent); - var entries = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/ false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + return completionInfo; + } + function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { + if (result === void 0) { result = []; } + // Check for typings specified in compiler options + if (options.types) { + for (var _i = 0, _a = options.types; _i < _a.length; _i++) { + var moduleName = _a[_i]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + } + else if (host.getDirectories) { + var typeRoots = void 0; + try { + // Wrap in try catch because getEffectiveTypeRoots touches the filesystem + typeRoots = ts.getEffectiveTypeRoots(options, host); + } + catch (e) { } + if (typeRoots) { + for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { + var root = typeRoots_2[_b]; + getCompletionEntriesFromDirectories(host, root, span, result); } } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo) { - var candidates = []; - var entries = []; - typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); - for (var _i = 0, candidates_3 = candidates; _i < candidates_3.length; _i++) { - var candidate = candidates_3[_i]; - if (candidate.parameters.length > argumentInfo.argumentIndex) { - var parameter = candidate.parameters[argumentInfo.argumentIndex]; - addStringLiteralCompletionsFromType(typeChecker.getTypeAtLocation(parameter.valueDeclaration), entries); + if (host.getDirectories) { + // Also get all @types typings installed in visible node_modules directories + for (var _c = 0, _d = findPackageJsons(scriptPath, host); _c < _d.length; _c++) { + var packageJson = _d[_c]; + var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(host, typesDir, span, result); + } + } + return result; + } + function getCompletionEntriesFromDirectories(host, directory, span, result) { + if (host.getDirectories && tryDirectoryExists(host, directory)) { + var directories = tryGetDirectories(host, directory); + if (directories) { + for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { + var typeDirectory = directories_3[_i]; + typeDirectory = ts.normalizePath(typeDirectory); + result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); } } - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; - } - return undefined; } - function getStringLiteralCompletionEntriesFromElementAccess(node) { - var type = typeChecker.getTypeAtLocation(node.expression); - var entries = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/ false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } + function findPackageJsons(currentDir, host) { + var paths = []; + var currentConfigPath; + while (true) { + currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + currentDir = ts.getDirectoryPath(currentConfigPath); + var parent = ts.getDirectoryPath(currentDir); + if (currentDir === parent) { + break; } - } - return undefined; - } - function getStringLiteralCompletionEntriesFromContextualType(node) { - var type = typeChecker.getContextualType(node); - if (type) { - var entries_2 = []; - addStringLiteralCompletionsFromType(type, entries_2); - if (entries_2.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries_2 }; - } - } - return undefined; - } - function addStringLiteralCompletionsFromType(type, result) { - if (!type) { - return; - } - if (type.flags & 65536 /* Union */) { - ts.forEach(type.types, function (t) { return addStringLiteralCompletionsFromType(t, result); }); + currentDir = parent; } else { - if (type.flags & 32 /* StringLiteral */) { + break; + } + } + return paths; + } + function enumerateNodeModulesVisibleToScript(host, scriptPath) { + var result = []; + if (host.readFile && host.fileExists) { + for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + var packageJson = _a[_i]; + var contents = tryReadingPackageJson(packageJson); + if (!contents) { + return; + } + var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); + var foundModuleNames = []; + // Provide completions for all non @types dependencies + for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { + var key = nodeModulesDependencyKeys_1[_b]; + addPotentialPackageNames(contents[key], foundModuleNames); + } + for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { + var moduleName = foundModuleNames_1[_c]; + var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); result.push({ - name: type.text, - kindModifiers: ts.ScriptElementKindModifier.none, - kind: ts.ScriptElementKind.variableElement, - sortText: "0" + moduleName: moduleName, + moduleDir: moduleDir }); } } } - function getStringLiteralCompletionEntriesFromModuleNames(node) { - var literalValue = ts.normalizeSlashes(node.text); - var scriptPath = node.getSourceFile().path; - var scriptDirectory = ts.getDirectoryPath(scriptPath); - var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); - var entries; - if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { - if (compilerOptions.rootDirs) { - entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ false, span, scriptPath); - } - else { - entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ false, span, scriptPath); - } + return result; + function tryReadingPackageJson(filePath) { + try { + var fileText = tryReadFile(host, filePath); + return fileText ? JSON.parse(fileText) : undefined; } - else { - // Check for node modules - entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); - } - return { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: entries - }; - } - /** - * Takes a script path and returns paths for all potential folders that could be merged with its - * containing folder via the "rootDirs" compiler option - */ - function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { - // Make all paths absolute/normalized if they are not already - rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); - // Determine the path to the directory containing the script relative to the root directory it is contained within - var relativeDirectory; - for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { - var rootDirectory = rootDirs_1[_i]; - if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { - relativeDirectory = scriptPath.substr(rootDirectory.length); - break; - } - } - // Now find a path for each potential directory that is to be merged with the one containing the script - return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); - } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, exclude) { - var basePath = compilerOptions.project || host.getCurrentDirectory(); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); - var result = []; - for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { - var baseDirectory = baseDirectories_1[_i]; - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, exclude, result); - } - return result; - } - /** - * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. - */ - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, exclude, result) { - if (result === void 0) { result = []; } - if (fragment === undefined) { - fragment = ""; - } - fragment = ts.normalizeSlashes(fragment); - /** - * Remove the basename from the path. Note that we don't use the basename to filter completions; - * the client is responsible for refining completions. - */ - fragment = ts.getDirectoryPath(fragment); - if (fragment === "") { - fragment = "." + ts.directorySeparator; - } - fragment = ts.ensureTrailingDirectorySeparator(fragment); - var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); - var baseDirectory = ts.getDirectoryPath(absolutePath); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (tryDirectoryExists(host, baseDirectory)) { - // Enumerate the available files if possible - var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); - if (files) { - /** - * Multiple file entries might map to the same truncated name once we remove extensions - * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: - * - * both foo.ts and foo.tsx become foo - */ - var foundFiles = ts.createMap(); - for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { - var filePath = files_3[_i]; - filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { - continue; - } - var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); - if (!foundFiles[foundFileName]) { - foundFiles[foundFileName] = true; - } - } - for (var foundFile in foundFiles) { - result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); - } - } - // If possible, get folder completion as well - var directories = tryGetDirectories(host, baseDirectory); - if (directories) { - for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { - var directory = directories_2[_a]; - var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); - } - } - } - return result; - } - /** - * Check all of the declared modules and those in node modules. Possible sources of modules: - * Modules that are found by the type checker - * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) - * Modules from node_modules (i.e. those listed in package.json) - * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions - */ - function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span) { - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var result; - if (baseUrl) { - var fileExtensions = ts.getSupportedExtensions(compilerOptions); - var projectDir = compilerOptions.project || host.getCurrentDirectory(); - var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); - result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, /*includeExtensions*/ false, span); - if (paths) { - for (var path in paths) { - if (paths.hasOwnProperty(path)) { - if (path === "*") { - if (paths[path]) { - for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { - var pattern = _a[_i]; - for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions); _b < _c.length; _b++) { - var match = _c[_b]; - result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - else if (ts.startsWith(path, fragment)) { - var entry = paths[path] && paths[path].length === 1 && paths[path][0]; - if (entry) { - result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - } - } - else { - result = []; - } - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); - for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions); _d < _e.length; _d++) { - var moduleName = _e[_d]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - return result; - } - function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions) { - if (host.readDirectory) { - var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; - if (parsed) { - // The prefix has two effective parts: the directory path and the base component after the filepath that is not a - // full directory component. For example: directory/path/of/prefix/base* - var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); - var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); - var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); - var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; - // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call - var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; - var normalizedSuffix = ts.normalizePath(parsed.suffix); - var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); - var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - // If we have a suffix, then we need to read the directory all the way down. We could create a glob - // that encodes the suffix, but we would have to escape the character "?" which readDirectory - // doesn't support. For now, this is safer but slower - var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); - if (matches) { - var result = []; - // Trim away prefix and suffix - for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { - var match = matches_1[_i]; - var normalizedMatch = ts.normalizePath(match); - if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { - continue; - } - var start = completePrefix.length; - var length_5 = normalizedMatch.length - start - normalizedSuffix.length; - result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); - } - return result; - } - } - } - return undefined; - } - function enumeratePotentialNonRelativeModules(fragment, scriptPath, options) { - // Check If this is a nested module - var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; - var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; - // Get modules that the type checker picked up - var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); - var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); - // Nested modules of the form "module-name/sub" need to be adjusted to only return the string - // after the last '/' that appears in the fragment because that's where the replacement span - // starts - if (isNestedModule) { - var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); - nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { - if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { - return moduleName.substr(moduleNameWithSeperator_1.length); - } - return moduleName; - }); - } - if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { - for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { - var visibleModule = _a[_i]; - if (!isNestedModule) { - nonRelativeModules.push(visibleModule.moduleName); - } - else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { - var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, /*exclude*/ undefined, /*include*/ ["./*"]); - if (nestedFiles) { - for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { - var f = nestedFiles_1[_b]; - f = ts.normalizePath(f); - var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); - nonRelativeModules.push(nestedModule); - } - } - } - } - } - return ts.deduplicate(nonRelativeModules); - } - function getTripleSlashReferenceCompletion(sourceFile, position) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (!token) { + catch (e) { return undefined; } - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - if (!commentRanges || !commentRanges.length) { - return undefined; - } - var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); - if (!range) { - return undefined; - } - var completionInfo = { - /** - * We don't want the editor to offer any other completions, such as snippets, inside a comment. - */ - isGlobalCompletion: false, - isMemberCompletion: false, - /** - * The user may type in a path that doesn't yet exist, creating a "new identifier" - * with respect to the collection of identifiers the server is aware of. - */ - isNewIdentifierLocation: true, - entries: [] - }; - var text = sourceFile.text.substr(range.pos, position - range.pos); - var match = tripleSlashDirectiveFragmentRegex.exec(text); - if (match) { - var prefix = match[1]; - var kind = match[2]; - var toComplete = match[3]; - var scriptPath = ts.getDirectoryPath(sourceFile.path); - if (kind === "path") { - // Give completions for a relative path - var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, span_10, sourceFile.path); - } - else { - // Give completions based on the typings available - var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); - } - } - return completionInfo; } - function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { - if (result === void 0) { result = []; } - // Check for typings specified in compiler options - if (options.types) { - for (var _i = 0, _a = options.types; _i < _a.length; _i++) { - var moduleName = _a[_i]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - } - else if (host.getDirectories) { - var typeRoots = void 0; - try { - // Wrap in try catch because getEffectiveTypeRoots touches the filesystem - typeRoots = ts.getEffectiveTypeRoots(options, host); - } - catch (e) { } - if (typeRoots) { - for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { - var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, root, span, result); + function addPotentialPackageNames(dependencies, result) { + if (dependencies) { + for (var dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { + result.push(dep); } } } - if (host.getDirectories) { - // Also get all @types typings installed in visible node_modules directories - for (var _c = 0, _d = findPackageJsons(scriptPath); _c < _d.length; _c++) { - var packageJson = _d[_c]; - var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, typesDir, span, result); - } - } - return result; - } - function getCompletionEntriesFromDirectories(host, directory, span, result) { - if (host.getDirectories && tryDirectoryExists(host, directory)) { - var directories = tryGetDirectories(host, directory); - if (directories) { - for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { - var typeDirectory = directories_3[_i]; - typeDirectory = ts.normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - function findPackageJsons(currentDir) { - var paths = []; - var currentConfigPath; - while (true) { - currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); - currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_13 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_13) { - break; - } - currentDir = parent_13; - } - else { - break; - } - } - return paths; - } - function enumerateNodeModulesVisibleToScript(host, scriptPath) { - var result = []; - if (host.readFile && host.fileExists) { - for (var _i = 0, _a = findPackageJsons(scriptPath); _i < _a.length; _i++) { - var packageJson = _a[_i]; - var contents = tryReadingPackageJson(packageJson); - if (!contents) { - return; - } - var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); - var foundModuleNames = []; - // Provide completions for all non @types dependencies - for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { - var key = nodeModulesDependencyKeys_1[_b]; - addPotentialPackageNames(contents[key], foundModuleNames); - } - for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { - var moduleName = foundModuleNames_1[_c]; - var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName: moduleName, - moduleDir: moduleDir - }); - } - } - } - return result; - function tryReadingPackageJson(filePath) { - try { - var fileText = tryReadFile(host, filePath); - return fileText ? JSON.parse(fileText) : undefined; - } - catch (e) { - return undefined; - } - } - function addPotentialPackageNames(dependencies, result) { - if (dependencies) { - for (var dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { - result.push(dep); - } - } - } - } - } - function createCompletionEntryForModule(name, kind, replacementSpan) { - return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; - } - // Replace everything after the last directory seperator that appears - function getDirectoryFragmentTextSpan(text, textStart) { - var index = text.lastIndexOf(ts.directorySeparator); - var offset = index !== -1 ? index + 1 : 0; - return { start: textStart + offset, length: text.length - offset }; - } - // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) - function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; - var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; - } - return false; - } - function normalizeAndPreserveTrailingSlash(path) { - return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); } } - Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function createCompletionEntryForModule(name, kind, replacementSpan) { + return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; + } + // Replace everything after the last directory seperator that appears + function getDirectoryFragmentTextSpan(text, textStart) { + var index = text.lastIndexOf(ts.directorySeparator); + var offset = index !== -1 ? index + 1 : 0; + return { start: textStart + offset, length: text.length - offset }; + } + // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) + function isPathRelativeToScript(path) { + if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; + var slashCharCode = path.charCodeAt(slashIndex); + return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; + } + return false; + } + function normalizeAndPreserveTrailingSlash(path) { + return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); + } function getCompletionEntryDetails(typeChecker, log, compilerOptions, sourceFile, position, entryName) { // Compute all the completion symbols again. var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_3 = completionData.location; + var symbols = completionData.symbols, location_1 = completionData.location; // Find the symbol with the matching entry name. // 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(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_3) === entryName ? s : undefined; }); + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_1) === entryName ? s : undefined; }); if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_3, location_3, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { name: entryName, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), @@ -67990,12 +70193,12 @@ var ts; // Compute all the completion symbols again. var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_4 = completionData.location; + var symbols = completionData.symbols, location_2 = completionData.location; // Find the symbol with the matching entry name. // 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. - return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_4) === entryName ? s : undefined; }); + return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_2) === entryName ? s : undefined; }); } return undefined; } @@ -68026,9 +70229,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 283 /* JSDocTypeTag */: - case 281 /* JSDocParameterTag */: - case 282 /* JSDocReturnTag */: + case 287 /* JSDocTypeTag */: + case 285 /* JSDocParameterTag */: + case 286 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -68073,13 +70276,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_14 = contextToken.parent, kind = contextToken.kind; + var parent = contextToken.parent, kind = contextToken.kind; if (kind === 22 /* DotToken */) { - if (parent_14.kind === 177 /* PropertyAccessExpression */) { + if (parent.kind === 178 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_14.kind === 141 /* QualifiedName */) { + else if (parent.kind === 142 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -68090,13 +70293,27 @@ var ts; } } else if (sourceFile.languageVariant === 1 /* JSX */) { - if (kind === 26 /* LessThanToken */) { - isRightOfOpenTag = true; - location = contextToken; - } - else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 249 /* JsxClosingElement */) { - isStartingCloseTag = true; - location = contextToken; + switch (contextToken.parent.kind) { + case 251 /* JsxClosingElement */: + if (kind === 40 /* SlashToken */) { + isStartingCloseTag = true; + location = contextToken; + } + break; + case 193 /* BinaryExpression */: + if (!(contextToken.parent.left.flags & 32768 /* ThisNodeHasError */)) { + // It has a left-hand side, so we're not in an opening JSX tag. + break; + } + // fall through + case 249 /* JsxSelfClosingElement */: + case 248 /* JsxElement */: + case 250 /* JsxOpeningElement */: + if (kind === 26 /* LessThanToken */) { + isRightOfOpenTag = true; + location = contextToken; + } + break; } } } @@ -68143,7 +70360,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 70 /* Identifier */ || node.kind === 141 /* QualifiedName */ || node.kind === 177 /* PropertyAccessExpression */) { + if (node.kind === 70 /* Identifier */ || node.kind === 142 /* QualifiedName */ || node.kind === 178 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -68199,11 +70416,11 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 247 /* JsxSelfClosingElement */) || (jsxContainer.kind === 248 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 249 /* JsxSelfClosingElement */) || (jsxContainer.kind === 250 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element - attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + attrsType = typeChecker.getAllAttributesTypeFromJsxOpeningLikeElement(jsxContainer); if (attrsType) { - symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); + symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes.properties); isMemberCompletion = true; isNewIdentifierLocation = false; return true; @@ -68247,9 +70464,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 261 /* SourceFile */ || - scopeNode.kind === 194 /* TemplateExpression */ || - scopeNode.kind === 252 /* JsxExpression */ || + scopeNode.kind === 264 /* SourceFile */ || + scopeNode.kind === 195 /* TemplateExpression */ || + scopeNode.kind === 255 /* JsxExpression */ || ts.isStatement(scopeNode); } /// TODO filter meaning based on the current context @@ -68282,11 +70499,11 @@ var ts; return true; } if (contextToken.kind === 28 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 248 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 250 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 249 /* JsxClosingElement */ || contextToken.parent.kind === 247 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 246 /* JsxElement */; + if (contextToken.parent.kind === 251 /* JsxClosingElement */ || contextToken.parent.kind === 249 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 248 /* JsxElement */; } } return false; @@ -68296,40 +70513,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 25 /* CommaToken */: - return containingNodeKind === 179 /* CallExpression */ // func( a, | - || containingNodeKind === 150 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 180 /* NewExpression */ // new C(a, | - || containingNodeKind === 175 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 192 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 158 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 180 /* CallExpression */ // func( a, | + || containingNodeKind === 151 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 181 /* NewExpression */ // new C(a, | + || containingNodeKind === 176 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 193 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 159 /* FunctionType */; // var x: (s: string, list| case 18 /* OpenParenToken */: - return containingNodeKind === 179 /* CallExpression */ // func( | - || containingNodeKind === 150 /* Constructor */ // constructor( | - || containingNodeKind === 180 /* NewExpression */ // new C(a| - || containingNodeKind === 183 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 166 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 180 /* CallExpression */ // func( | + || containingNodeKind === 151 /* Constructor */ // constructor( | + || containingNodeKind === 181 /* NewExpression */ // new C(a| + || containingNodeKind === 184 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 167 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 20 /* OpenBracketToken */: - return containingNodeKind === 175 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 155 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 142 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + return containingNodeKind === 176 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 156 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 143 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 127 /* ModuleKeyword */: // module | case 128 /* NamespaceKeyword */: return true; case 22 /* DotToken */: - return containingNodeKind === 230 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 232 /* ModuleDeclaration */; // module A.| case 16 /* OpenBraceToken */: - return containingNodeKind === 226 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 228 /* ClassDeclaration */; // class A{ | case 57 /* EqualsToken */: - return containingNodeKind === 223 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 192 /* BinaryExpression */; // x = a| + return containingNodeKind === 225 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 193 /* BinaryExpression */; // x = a| case 13 /* TemplateHead */: - return containingNodeKind === 194 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 195 /* TemplateExpression */; // `aa ${| case 14 /* TemplateMiddle */: - return containingNodeKind === 202 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 204 /* TemplateSpan */; // `aa ${10} dd ${| case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: - return containingNodeKind === 147 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 148 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -68372,7 +70589,7 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 176 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 177 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; @@ -68382,7 +70599,7 @@ var ts; typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 172 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 173 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -68393,11 +70610,11 @@ var ts; // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 144 /* Parameter */) { + if (!canGetType && rootDeclaration.kind === 145 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 149 /* MethodDeclaration */ || rootDeclaration.parent.kind === 152 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 150 /* MethodDeclaration */ || rootDeclaration.parent.kind === 153 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -68439,9 +70656,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 238 /* NamedImports */ ? - 235 /* ImportDeclaration */ : - 241 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 240 /* NamedImports */ ? + 237 /* ImportDeclaration */ : + 243 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -68449,12 +70666,13 @@ var ts; } isMemberCompletion = true; isNewIdentifierLocation = false; - var exports; - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); + if (!moduleSpecifierSymbol) { + symbols = ts.emptyArray; + return true; } - symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : ts.emptyArray; + var exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); + symbols = filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements); return true; } /** @@ -68466,9 +70684,9 @@ var ts; switch (contextToken.kind) { case 16 /* OpenBraceToken */: // const x = { | case 25 /* CommaToken */: - var parent_15 = contextToken.parent; - if (parent_15 && (parent_15.kind === 176 /* ObjectLiteralExpression */ || parent_15.kind === 172 /* ObjectBindingPattern */)) { - return parent_15; + var parent = contextToken.parent; + if (parent && (parent.kind === 177 /* ObjectLiteralExpression */ || parent.kind === 173 /* ObjectBindingPattern */)) { + return parent; } break; } @@ -68485,8 +70703,8 @@ var ts; case 16 /* OpenBraceToken */: // import { | case 25 /* CommaToken */: switch (contextToken.parent.kind) { - case 238 /* NamedImports */: - case 242 /* NamedExports */: + case 240 /* NamedImports */: + case 244 /* NamedExports */: return contextToken.parent; } } @@ -68495,37 +70713,54 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_16 = contextToken.parent; + var parent = contextToken.parent; switch (contextToken.kind) { case 27 /* LessThanSlashToken */: case 40 /* SlashToken */: case 70 /* Identifier */: - case 250 /* JsxAttribute */: - case 251 /* JsxSpreadAttribute */: - if (parent_16 && (parent_16.kind === 247 /* JsxSelfClosingElement */ || parent_16.kind === 248 /* JsxOpeningElement */)) { - return parent_16; + case 253 /* JsxAttributes */: + case 252 /* JsxAttribute */: + case 254 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 249 /* JsxSelfClosingElement */ || parent.kind === 250 /* JsxOpeningElement */)) { + return parent; } - else if (parent_16.kind === 250 /* JsxAttribute */) { - return parent_16.parent; + else if (parent.kind === 252 /* JsxAttribute */) { + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + return parent.parent.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_16 && ((parent_16.kind === 250 /* JsxAttribute */) || (parent_16.kind === 251 /* JsxSpreadAttribute */))) { - return parent_16.parent; + if (parent && ((parent.kind === 252 /* JsxAttribute */) || (parent.kind === 254 /* JsxSpreadAttribute */))) { + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + return parent.parent.parent; } break; case 17 /* CloseBraceToken */: - if (parent_16 && - parent_16.kind === 252 /* JsxExpression */ && - parent_16.parent && - (parent_16.parent.kind === 250 /* JsxAttribute */)) { - return parent_16.parent.parent; + if (parent && + parent.kind === 255 /* JsxExpression */ && + parent.parent && parent.parent.kind === 252 /* JsxAttribute */) { + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + // each JsxAttribute can have initializer as JsxExpression + return parent.parent.parent.parent; } - if (parent_16 && parent_16.kind === 251 /* JsxSpreadAttribute */) { - return parent_16.parent; + if (parent && parent.kind === 254 /* JsxSpreadAttribute */) { + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + return parent.parent.parent; } break; } @@ -68534,16 +70769,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 155 /* IndexSignature */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 156 /* IndexSignature */: return true; } return false; @@ -68555,66 +70790,66 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25 /* CommaToken */: - return containingNodeKind === 223 /* VariableDeclaration */ || - containingNodeKind === 224 /* VariableDeclarationList */ || - containingNodeKind === 205 /* VariableStatement */ || - containingNodeKind === 229 /* EnumDeclaration */ || + return containingNodeKind === 225 /* VariableDeclaration */ || + containingNodeKind === 226 /* VariableDeclarationList */ || + containingNodeKind === 207 /* VariableStatement */ || + containingNodeKind === 231 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 226 /* ClassDeclaration */ || - containingNodeKind === 197 /* ClassExpression */ || - containingNodeKind === 227 /* InterfaceDeclaration */ || - containingNodeKind === 173 /* ArrayBindingPattern */ || - containingNodeKind === 228 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 228 /* ClassDeclaration */ || + containingNodeKind === 198 /* ClassExpression */ || + containingNodeKind === 229 /* InterfaceDeclaration */ || + containingNodeKind === 174 /* ArrayBindingPattern */ || + containingNodeKind === 230 /* TypeAliasDeclaration */; // type Map, K, | case 22 /* DotToken */: - return containingNodeKind === 173 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 174 /* ArrayBindingPattern */; // var [.| case 55 /* ColonToken */: - return containingNodeKind === 174 /* BindingElement */; // var {x :html| + return containingNodeKind === 175 /* BindingElement */; // var {x :html| case 20 /* OpenBracketToken */: - return containingNodeKind === 173 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 174 /* ArrayBindingPattern */; // var [x| case 18 /* OpenParenToken */: - return containingNodeKind === 256 /* CatchClause */ || + return containingNodeKind === 259 /* CatchClause */ || isFunction(containingNodeKind); case 16 /* OpenBraceToken */: - return containingNodeKind === 229 /* EnumDeclaration */ || - containingNodeKind === 227 /* InterfaceDeclaration */ || - containingNodeKind === 161 /* TypeLiteral */; // const x : { | + return containingNodeKind === 231 /* EnumDeclaration */ || + containingNodeKind === 229 /* InterfaceDeclaration */ || + containingNodeKind === 162 /* TypeLiteral */; // const x : { | case 24 /* SemicolonToken */: - return containingNodeKind === 146 /* PropertySignature */ && + return containingNodeKind === 147 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 227 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 161 /* TypeLiteral */); // const x : { a; | + (contextToken.parent.parent.kind === 229 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 162 /* TypeLiteral */); // const x : { a; | case 26 /* LessThanToken */: - return containingNodeKind === 226 /* ClassDeclaration */ || - containingNodeKind === 197 /* ClassExpression */ || - containingNodeKind === 227 /* InterfaceDeclaration */ || - containingNodeKind === 228 /* TypeAliasDeclaration */ || + return containingNodeKind === 228 /* ClassDeclaration */ || + containingNodeKind === 198 /* ClassExpression */ || + containingNodeKind === 229 /* InterfaceDeclaration */ || + containingNodeKind === 230 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); case 114 /* StaticKeyword */: - return containingNodeKind === 147 /* PropertyDeclaration */; + return containingNodeKind === 148 /* PropertyDeclaration */; case 23 /* DotDotDotToken */: - return containingNodeKind === 144 /* Parameter */ || + return containingNodeKind === 145 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 173 /* ArrayBindingPattern */); // var [...z| + contextToken.parent.parent.kind === 174 /* ArrayBindingPattern */); // var [...z| case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: - return containingNodeKind === 144 /* Parameter */; + return containingNodeKind === 145 /* Parameter */; case 117 /* AsKeyword */: - return containingNodeKind === 239 /* ImportSpecifier */ || - containingNodeKind === 243 /* ExportSpecifier */ || - containingNodeKind === 237 /* NamespaceImport */; + return containingNodeKind === 241 /* ImportSpecifier */ || + containingNodeKind === 245 /* ExportSpecifier */ || + containingNodeKind === 239 /* NamespaceImport */; case 74 /* ClassKeyword */: case 82 /* EnumKeyword */: case 108 /* InterfaceKeyword */: case 88 /* FunctionKeyword */: case 103 /* VarKeyword */: case 124 /* GetKeyword */: - case 133 /* SetKeyword */: + case 134 /* SetKeyword */: case 90 /* ImportKeyword */: case 109 /* LetKeyword */: case 75 /* ConstKeyword */: case 115 /* YieldKeyword */: - case 136 /* TypeKeyword */: + case 137 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -68662,13 +70897,13 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_45 = element.propertyName || element.name; - existingImportsOrExports[name_45.text] = true; + var name = element.propertyName || element.name; + existingImportsOrExports.set(name.text, true); } - if (!ts.someProperties(existingImportsOrExports)) { + if (existingImportsOrExports.size === 0) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); } - return ts.filter(exportsOfModule, function (e) { return e.name !== "default" && !existingImportsOrExports[e.name]; }); + return ts.filter(exportsOfModule, function (e) { return e.name !== "default" && !existingImportsOrExports.get(e.name); }); } /** * Filters out completion suggestions for named imports or exports. @@ -68684,12 +70919,12 @@ var ts; 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 !== 257 /* PropertyAssignment */ && - m.kind !== 258 /* ShorthandPropertyAssignment */ && - m.kind !== 174 /* BindingElement */ && - m.kind !== 149 /* MethodDeclaration */ && - m.kind !== 151 /* GetAccessor */ && - m.kind !== 152 /* SetAccessor */) { + if (m.kind !== 260 /* PropertyAssignment */ && + m.kind !== 261 /* ShorthandPropertyAssignment */ && + m.kind !== 175 /* BindingElement */ && + m.kind !== 150 /* MethodDeclaration */ && + m.kind !== 152 /* GetAccessor */ && + m.kind !== 153 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -68697,7 +70932,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 174 /* BindingElement */ && m.propertyName) { + if (m.kind === 175 /* BindingElement */ && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 70 /* Identifier */) { existingName = m.propertyName.text; @@ -68709,9 +70944,9 @@ var ts; // things like '__proto__' are not filtered out. existingName = m.name.text; } - existingMemberNames[existingName] = true; + existingMemberNames.set(existingName, true); } - return ts.filter(contextualMemberSymbols, function (m) { return !existingMemberNames[m.name]; }); + return ts.filter(contextualMemberSymbols, function (m) { return !existingMemberNames.get(m.name); }); } /** * Filters out completion suggestions from 'symbols' according to existing JSX attributes. @@ -68727,11 +70962,11 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 250 /* JsxAttribute */) { - seenNames[attr.name.text] = true; + if (attr.kind === 252 /* JsxAttribute */) { + seenNames.set(attr.name.text, true); } } - return ts.filter(symbols, function (a) { return !seenNames[a.name]; }); + return ts.filter(symbols, function (a) { return !seenNames.get(a.name); }); } } /** @@ -68777,7 +71012,7 @@ var ts; } // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 71 /* FirstKeyword */; i <= 140 /* LastKeyword */; i++) { + for (var i = 71 /* FirstKeyword */; i <= 141 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -68829,6 +71064,15 @@ var ts; catch (e) { } return undefined; } + function isEqualityExpression(node) { + return ts.isBinaryExpression(node) && isEqualityOperatorKind(node.operatorToken.kind); + } + function isEqualityOperatorKind(kind) { + return kind == 31 /* EqualsEqualsToken */ || + kind === 32 /* ExclamationEqualsToken */ || + kind === 33 /* EqualsEqualsEqualsToken */ || + kind === 34 /* ExclamationEqualsEqualsToken */; + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -68838,534 +71082,519 @@ var ts; (function (DocumentHighlights) { function getDocumentHighlights(typeChecker, cancellationToken, sourceFile, position, sourceFilesToSearch) { var node = ts.getTouchingWord(sourceFile, position); + return node && (getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) || getSyntacticDocumentHighlights(node, sourceFile)); + } + DocumentHighlights.getDocumentHighlights = getDocumentHighlights; + function getHighlightSpanForNode(node, sourceFile) { + var start = node.getStart(sourceFile); + var end = node.getEnd(); + return { + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(start, end), + kind: ts.HighlightSpanKind.none + }; + } + function getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) { + var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch); + return referencedSymbols && convertReferencedSymbols(referencedSymbols); + } + function convertReferencedSymbols(referencedSymbols) { + var fileNameToDocumentHighlights = ts.createMap(); + var result = []; + 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 = referenceEntry.fileName; + var documentHighlights = fileNameToDocumentHighlights.get(fileName); + if (!documentHighlights) { + documentHighlights = { fileName: fileName, highlightSpans: [] }; + fileNameToDocumentHighlights.set(fileName, documentHighlights); + result.push(documentHighlights); + } + documentHighlights.highlightSpans.push({ + textSpan: referenceEntry.textSpan, + kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference + }); + } + } + return result; + } + function getSyntacticDocumentHighlights(node, sourceFile) { + var highlightSpans = getHighlightSpans(node, sourceFile); + if (!highlightSpans || highlightSpans.length === 0) { + return undefined; + } + return [{ fileName: sourceFile.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, sourceFile) { 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: ts.HighlightSpanKind.none - }; + switch (node.kind) { + case 89 /* IfKeyword */: + case 81 /* ElseKeyword */: + if (hasKind(node.parent, 210 /* IfStatement */)) { + return getIfElseOccurrences(node.parent, sourceFile); + } + break; + case 95 /* ReturnKeyword */: + if (hasKind(node.parent, 218 /* ReturnStatement */)) { + return highlightSpans(getReturnOccurrences(node.parent)); + } + break; + case 99 /* ThrowKeyword */: + if (hasKind(node.parent, 222 /* ThrowStatement */)) { + return highlightSpans(getThrowOccurrences(node.parent)); + } + break; + case 101 /* TryKeyword */: + case 73 /* CatchKeyword */: + case 86 /* FinallyKeyword */: + var tryStatement = node.kind === 73 /* CatchKeyword */ ? parent(parent(node)) : parent(node); + if (hasKind(tryStatement, 223 /* TryStatement */)) { + return highlightSpans(getTryCatchFinallyOccurrences(tryStatement, sourceFile)); + } + break; + case 97 /* SwitchKeyword */: + if (hasKind(node.parent, 220 /* SwitchStatement */)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent)); + } + break; + case 72 /* CaseKeyword */: + case 78 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 220 /* SwitchStatement */)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent.parent.parent)); + } + break; + case 71 /* BreakKeyword */: + case 76 /* ContinueKeyword */: + if (hasKind(node.parent, 217 /* BreakStatement */) || hasKind(node.parent, 216 /* ContinueStatement */)) { + return highlightSpans(getBreakOrContinueStatementOccurrences(node.parent)); + } + break; + case 87 /* ForKeyword */: + if (hasKind(node.parent, 213 /* ForStatement */) || + hasKind(node.parent, 214 /* ForInStatement */) || + hasKind(node.parent, 215 /* ForOfStatement */)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case 105 /* WhileKeyword */: + case 80 /* DoKeyword */: + if (hasKind(node.parent, 212 /* WhileStatement */) || hasKind(node.parent, 211 /* DoStatement */)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case 122 /* ConstructorKeyword */: + if (hasKind(node.parent, 151 /* Constructor */)) { + return highlightSpans(getConstructorOccurrences(node.parent)); + } + break; + case 124 /* GetKeyword */: + case 134 /* SetKeyword */: + if (hasKind(node.parent, 152 /* GetAccessor */) || hasKind(node.parent, 153 /* SetAccessor */)) { + return highlightSpans(getGetAndSetOccurrences(node.parent)); + } + break; + default: + if (ts.isModifierKind(node.kind) && node.parent && + (ts.isDeclaration(node.parent) || node.parent.kind === 207 /* VariableStatement */)) { + return highlightSpans(getModifierOccurrences(node.kind, node.parent)); + } } - function getSemanticDocumentHighlights(node) { - if (node.kind === 70 /* Identifier */ || - node.kind === 98 /* ThisKeyword */ || - node.kind === 167 /* ThisType */ || - node.kind === 96 /* SuperKeyword */ || - node.kind === 9 /* StringLiteral */ || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, /*findInStrings*/ false, /*findInComments*/ false, /*implementations*/ false); - return convertReferencedSymbols(referencedSymbols); - } - return undefined; - function convertReferencedSymbols(referencedSymbols) { - if (!referencedSymbols) { - return undefined; - } - var fileNameToDocumentHighlights = ts.createMap(); - var result = []; - 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 = referenceEntry.fileName; - var documentHighlights = fileNameToDocumentHighlights[fileName]; - if (!documentHighlights) { - documentHighlights = { fileName: fileName, highlightSpans: [] }; - fileNameToDocumentHighlights[fileName] = documentHighlights; - result.push(documentHighlights); - } - documentHighlights.highlightSpans.push({ - textSpan: referenceEntry.textSpan, - kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference - }); - } - } - return result; - } + function highlightSpans(nodes) { + return nodes && nodes.map(function (node) { return getHighlightSpanForNode(node, sourceFile); }); } - function getSyntacticDocumentHighlights(node) { - var fileName = sourceFile.fileName; - var highlightSpans = getHighlightSpans(node); - if (!highlightSpans || highlightSpans.length === 0) { - 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 === 222 /* ThrowStatement */) { + statementAccumulator.push(node); } - 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 89 /* IfKeyword */: - case 81 /* ElseKeyword */: - if (hasKind(node.parent, 208 /* IfStatement */)) { - return getIfElseOccurrences(node.parent); - } - break; - case 95 /* ReturnKeyword */: - if (hasKind(node.parent, 216 /* ReturnStatement */)) { - return getReturnOccurrences(node.parent); - } - break; - case 99 /* ThrowKeyword */: - if (hasKind(node.parent, 220 /* ThrowStatement */)) { - return getThrowOccurrences(node.parent); - } - break; - case 73 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 221 /* TryStatement */)) { - return getTryCatchFinallyOccurrences(node.parent.parent); - } - break; - case 101 /* TryKeyword */: - case 86 /* FinallyKeyword */: - if (hasKind(parent(node), 221 /* TryStatement */)) { - return getTryCatchFinallyOccurrences(node.parent); - } - break; - case 97 /* SwitchKeyword */: - if (hasKind(node.parent, 218 /* SwitchStatement */)) { - return getSwitchCaseDefaultOccurrences(node.parent); - } - break; - case 72 /* CaseKeyword */: - case 78 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 218 /* SwitchStatement */)) { - return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); - } - break; - case 71 /* BreakKeyword */: - case 76 /* ContinueKeyword */: - if (hasKind(node.parent, 215 /* BreakStatement */) || hasKind(node.parent, 214 /* ContinueStatement */)) { - return getBreakOrContinueStatementOccurrences(node.parent); - } - break; - case 87 /* ForKeyword */: - if (hasKind(node.parent, 211 /* ForStatement */) || - hasKind(node.parent, 212 /* ForInStatement */) || - hasKind(node.parent, 213 /* ForOfStatement */)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 105 /* WhileKeyword */: - case 80 /* DoKeyword */: - if (hasKind(node.parent, 210 /* WhileStatement */) || hasKind(node.parent, 209 /* DoStatement */)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 122 /* ConstructorKeyword */: - if (hasKind(node.parent, 150 /* Constructor */)) { - return getConstructorOccurrences(node.parent); - } - break; - case 124 /* GetKeyword */: - case 133 /* SetKeyword */: - if (hasKind(node.parent, 151 /* GetAccessor */) || hasKind(node.parent, 152 /* SetAccessor */)) { - return getGetAndSetOccurrences(node.parent); - } - break; - default: - if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 205 /* 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 === 220 /* ThrowStatement */) { - statementAccumulator.push(node); - } - else if (node.kind === 221 /* 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_17 = child.parent; - if (ts.isFunctionBlock(parent_17) || parent_17.kind === 261 /* SourceFile */) { - return parent_17; - } - // 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_17.kind === 221 /* TryStatement */) { - var tryStatement = parent_17; - if (tryStatement.tryBlock === child && tryStatement.catchClause) { - return child; - } - } - child = parent_17; - } - return undefined; - } - function aggregateAllBreakAndContinueStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 215 /* BreakStatement */ || node.kind === 214 /* 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_1 = statement.parent; node_1; node_1 = node_1.parent) { - switch (node_1.kind) { - case 218 /* SwitchStatement */: - if (statement.kind === 214 /* ContinueStatement */) { - continue; - } - // Fall through. - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 210 /* WhileStatement */: - case 209 /* DoStatement */: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; - } - break; - default: - // Don't cross function boundaries. - if (ts.isFunctionLike(node_1)) { - 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 === 226 /* ClassDeclaration */ || - container.kind === 197 /* ClassExpression */ || - (declaration.kind === 144 /* Parameter */ && hasKind(container, 150 /* Constructor */)))) { - return undefined; - } - } - else if (modifier === 114 /* StaticKeyword */) { - if (!(container.kind === 226 /* ClassDeclaration */ || container.kind === 197 /* ClassExpression */)) { - return undefined; - } - } - else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { - if (!(container.kind === 231 /* ModuleBlock */ || container.kind === 261 /* SourceFile */)) { - return undefined; - } - } - else if (modifier === 116 /* AbstractKeyword */) { - if (!(container.kind === 226 /* ClassDeclaration */ || declaration.kind === 226 /* ClassDeclaration */)) { - return undefined; - } + else if (node.kind === 223 /* TryStatement */) { + var tryStatement = node; + if (tryStatement.catchClause) { + aggregate(tryStatement.catchClause); } else { - // unsupported modifier - return undefined; - } - var keywords = []; - var modifierFlag = getFlagFromModifier(modifier); - var nodes; - switch (container.kind) { - case 231 /* ModuleBlock */: - case 261 /* SourceFile */: - // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & 128 /* Abstract */) { - nodes = declaration.members.concat(declaration); - } - else { - nodes = container.statements; - } - break; - case 150 /* Constructor */: - nodes = container.parameters.concat(container.parent.members); - break; - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - nodes = container.members; - // If we're an accessibility modifier, we're in an instance member and should search - // the constructor's parameter list for instance members as well. - if (modifierFlag & 28 /* AccessibilityModifier */) { - var constructor = ts.forEach(container.members, function (member) { - return member.kind === 150 /* Constructor */ && member; - }); - if (constructor) { - nodes = nodes.concat(constructor.parameters); - } - } - else if (modifierFlag & 128 /* Abstract */) { - nodes = nodes.concat(container); - } - break; - default: - ts.Debug.fail("Invalid container kind."); - } - ts.forEach(nodes, function (node) { - if (ts.getModifierFlags(node) & modifierFlag) { - ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - function getFlagFromModifier(modifier) { - switch (modifier) { - case 113 /* PublicKeyword */: - return 4 /* Public */; - case 111 /* PrivateKeyword */: - return 8 /* Private */; - case 112 /* ProtectedKeyword */: - return 16 /* Protected */; - case 114 /* StaticKeyword */: - return 32 /* Static */; - case 83 /* ExportKeyword */: - return 1 /* Export */; - case 123 /* DeclareKeyword */: - return 2 /* Ambient */; - case 116 /* AbstractKeyword */: - return 128 /* 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, 151 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 152 /* 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, 124 /* GetKeyword */, 133 /* 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, 122 /* ConstructorKeyword */); - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getLoopBreakContinueOccurrences(loopNode) { - var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87 /* ForKeyword */, 105 /* WhileKeyword */, 80 /* DoKeyword */)) { - // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 209 /* DoStatement */) { - var loopTokens = loopNode.getChildren(); - for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { - break; - } - } - } - } - var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */, 76 /* ContinueKeyword */); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { - var owner = getBreakOrContinueOwner(breakOrContinueStatement); - if (owner) { - switch (owner.kind) { - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - return getLoopBreakContinueOccurrences(owner); - case 218 /* SwitchStatement */: - return getSwitchCaseDefaultOccurrences(owner); - } - } - return undefined; - } - function getSwitchCaseDefaultOccurrences(switchStatement) { - var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 97 /* SwitchKeyword */); - // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. - ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 72 /* CaseKeyword */, 78 /* DefaultKeyword */); - var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */); - } - }); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getTryCatchFinallyOccurrences(tryStatement) { - var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 101 /* TryKeyword */); - if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73 /* CatchKeyword */); + // Exceptions thrown within a try block lacking a catch clause + // are "owned" in the current context. + aggregate(tryStatement.tryBlock); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 86 /* FinallyKeyword */); + aggregate(tryStatement.finallyBlock); } - 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(), 99 /* ThrowKeyword */); - }); - // If the "owner" is a function, then we equate 'return' and 'throw' statements in their - // ability to "jump out" of the function, and include occurrences for both. - if (ts.isFunctionBlock(owner)) { - ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* 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, 204 /* Block */))) { - return undefined; - } - var keywords = []; - ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); - }); - // Include 'throw' statements that do not occur within a try block. - ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* ThrowKeyword */); - }); - return ts.map(keywords, getHighlightSpanForNode); - } - function getIfElseOccurrences(ifStatement) { - var keywords = []; - // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 208 /* 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], 89 /* IfKeyword */); - // Generally the 'else' keyword is second-to-last, so we traverse backwards. - for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 81 /* ElseKeyword */)) { - break; - } - } - if (!hasKind(ifStatement.elseStatement, 208 /* 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 === 81 /* ElseKeyword */ && i < keywords.length - 1) { - var elseKeyword = keywords[i]; - var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. - var shouldCombindElseAndIf = true; - // Avoid recalculating getStart() by iterating backwards. - for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { - if (!ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { - shouldCombindElseAndIf = false; - break; - } - } - if (shouldCombindElseAndIf) { - result.push({ - fileName: fileName, - textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: ts.HighlightSpanKind.reference - }); - i++; // skip the next keyword - continue; - } - } - // Ordinary case: just highlight the keyword. - result.push(getHighlightSpanForNode(keywords[i])); - } - return result; + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); } } } - DocumentHighlights.getDocumentHighlights = getDocumentHighlights; + /** + * 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_2 = child.parent; + if (ts.isFunctionBlock(parent_2) || parent_2.kind === 264 /* SourceFile */) { + return parent_2; + } + // 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_2.kind === 223 /* TryStatement */) { + var tryStatement = parent_2; + if (tryStatement.tryBlock === child && tryStatement.catchClause) { + return child; + } + } + child = parent_2; + } + return undefined; + } + function aggregateAllBreakAndContinueStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 217 /* BreakStatement */ || node.kind === 216 /* 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 = statement.parent; node; node = node.parent) { + switch (node.kind) { + case 220 /* SwitchStatement */: + if (statement.kind === 216 /* ContinueStatement */) { + continue; + } + // Fall through. + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 212 /* WhileStatement */: + case 211 /* DoStatement */: + if (!statement.label || isLabeledBy(node, statement.label.text)) { + return node; + } + break; + default: + // Don't cross function boundaries. + if (ts.isFunctionLike(node)) { + 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 === 228 /* ClassDeclaration */ || + container.kind === 198 /* ClassExpression */ || + (declaration.kind === 145 /* Parameter */ && hasKind(container, 151 /* Constructor */)))) { + return undefined; + } + } + else if (modifier === 114 /* StaticKeyword */) { + if (!(container.kind === 228 /* ClassDeclaration */ || container.kind === 198 /* ClassExpression */)) { + return undefined; + } + } + else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { + if (!(container.kind === 233 /* ModuleBlock */ || container.kind === 264 /* SourceFile */)) { + return undefined; + } + } + else if (modifier === 116 /* AbstractKeyword */) { + if (!(container.kind === 228 /* ClassDeclaration */ || declaration.kind === 228 /* ClassDeclaration */)) { + return undefined; + } + } + else { + // unsupported modifier + return undefined; + } + var keywords = []; + var modifierFlag = getFlagFromModifier(modifier); + var nodes; + switch (container.kind) { + case 233 /* ModuleBlock */: + case 264 /* SourceFile */: + // Container is either a class declaration or the declaration is a classDeclaration + if (modifierFlag & 128 /* Abstract */) { + nodes = declaration.members.concat(declaration); + } + else { + nodes = container.statements; + } + break; + case 151 /* Constructor */: + nodes = container.parameters.concat(container.parent.members); + break; + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + nodes = container.members; + // If we're an accessibility modifier, we're in an instance member and should search + // the constructor's parameter list for instance members as well. + if (modifierFlag & 28 /* AccessibilityModifier */) { + var constructor = ts.forEach(container.members, function (member) { + return member.kind === 151 /* Constructor */ && member; + }); + if (constructor) { + nodes = nodes.concat(constructor.parameters); + } + } + else if (modifierFlag & 128 /* Abstract */) { + nodes = nodes.concat(container); + } + break; + default: + ts.Debug.fail("Invalid container kind."); + } + ts.forEach(nodes, function (node) { + if (ts.getModifierFlags(node) & modifierFlag) { + ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); + } + }); + return keywords; + function getFlagFromModifier(modifier) { + switch (modifier) { + case 113 /* PublicKeyword */: + return 4 /* Public */; + case 111 /* PrivateKeyword */: + return 8 /* Private */; + case 112 /* ProtectedKeyword */: + return 16 /* Protected */; + case 114 /* StaticKeyword */: + return 32 /* Static */; + case 83 /* ExportKeyword */: + return 1 /* Export */; + case 123 /* DeclareKeyword */: + return 2 /* Ambient */; + case 116 /* AbstractKeyword */: + return 128 /* 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, 152 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 153 /* SetAccessor */); + return keywords; + function tryPushAccessorKeyword(accessorSymbol, accessorKind) { + var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); + if (accessor) { + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124 /* GetKeyword */, 134 /* 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, 122 /* ConstructorKeyword */); + }); + }); + return keywords; + } + function getLoopBreakContinueOccurrences(loopNode) { + var keywords = []; + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87 /* ForKeyword */, 105 /* WhileKeyword */, 80 /* DoKeyword */)) { + // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. + if (loopNode.kind === 211 /* DoStatement */) { + var loopTokens = loopNode.getChildren(); + for (var i = loopTokens.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { + break; + } + } + } + } + var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(loopNode, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */, 76 /* ContinueKeyword */); + } + }); + return keywords; + } + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { + var owner = getBreakOrContinueOwner(breakOrContinueStatement); + if (owner) { + switch (owner.kind) { + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + return getLoopBreakContinueOccurrences(owner); + case 220 /* SwitchStatement */: + return getSwitchCaseDefaultOccurrences(owner); + } + } + return undefined; + } + function getSwitchCaseDefaultOccurrences(switchStatement) { + var keywords = []; + pushKeywordIf(keywords, switchStatement.getFirstToken(), 97 /* SwitchKeyword */); + // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. + ts.forEach(switchStatement.caseBlock.clauses, function (clause) { + pushKeywordIf(keywords, clause.getFirstToken(), 72 /* CaseKeyword */, 78 /* DefaultKeyword */); + var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(switchStatement, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */); + } + }); + }); + return keywords; + } + function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { + var keywords = []; + pushKeywordIf(keywords, tryStatement.getFirstToken(), 101 /* TryKeyword */); + if (tryStatement.catchClause) { + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73 /* CatchKeyword */); + } + if (tryStatement.finallyBlock) { + var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 86 /* FinallyKeyword */); + } + return keywords; + } + function getThrowOccurrences(throwStatement) { + var owner = getThrowStatementOwner(throwStatement); + if (!owner) { + return undefined; + } + var keywords = []; + ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* ThrowKeyword */); + }); + // If the "owner" is a function, then we equate 'return' and 'throw' statements in their + // ability to "jump out" of the function, and include occurrences for both. + if (ts.isFunctionBlock(owner)) { + ts.forEachReturnStatement(owner, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); + }); + } + return keywords; + } + 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, 206 /* Block */))) { + return undefined; + } + var keywords = []; + ts.forEachReturnStatement(func.body, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); + }); + // Include 'throw' statements that do not occur within a try block. + ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* ThrowKeyword */); + }); + return keywords; + } + function getIfElseOccurrences(ifStatement, sourceFile) { + var keywords = []; + // Traverse upwards through all parent if-statements linked by their else-branches. + while (hasKind(ifStatement.parent, 210 /* 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], 89 /* IfKeyword */); + // Generally the 'else' keyword is second-to-last, so we traverse backwards. + for (var i = children.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, children[i], 81 /* ElseKeyword */)) { + break; + } + } + if (!hasKind(ifStatement.elseStatement, 210 /* 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 === 81 /* ElseKeyword */ && i < keywords.length - 1) { + var elseKeyword = keywords[i]; + var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. + var shouldCombindElseAndIf = true; + // Avoid recalculating getStart() by iterating backwards. + for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { + if (!ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { + shouldCombindElseAndIf = false; + break; + } + } + if (shouldCombindElseAndIf) { + result.push({ + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), + kind: ts.HighlightSpanKind.reference + }); + i++; // skip the next keyword + continue; + } + } + // Ordinary case: just highlight the keyword. + result.push(getHighlightSpanForNode(keywords[i], sourceFile)); + } + return result; + } /** * 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 === 219 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 221 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -69386,15 +71615,15 @@ var ts; return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + "|" + settings.allowJs + "|" + settings.baseUrl + "|" + JSON.stringify(settings.typeRoots) + "|" + JSON.stringify(settings.rootDirs) + "|" + JSON.stringify(settings.paths); } function getBucketForCompilationSettings(key, createIfMissing) { - var bucket = buckets[key]; + var bucket = buckets.get(key); if (!bucket && createIfMissing) { - buckets[key] = bucket = ts.createFileMap(); + buckets.set(key, bucket = ts.createFileMap()); } return bucket; } function reportStats() { - var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { - var entries = buckets[name]; + var bucketInfoArray = ts.arrayFrom(buckets.keys()).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { + var entries = buckets.get(name); var sourceFiles = []; entries.forEachValue(function (key, entry) { sourceFiles.push({ @@ -69492,57 +71721,30 @@ var ts; (function (ts) { var FindAllReferences; (function (FindAllReferences) { - function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments) { + function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments, isForRename) { var node = ts.getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); - if (node === sourceFile) { - return undefined; - } - switch (node.kind) { - case 8 /* NumericLiteral */: - if (!ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - break; - } - // Fallthrough - case 70 /* Identifier */: - case 98 /* ThisKeyword */: - // case SyntaxKind.SuperKeyword: TODO:GH#9268 - case 122 /* ConstructorKeyword */: - case 9 /* StringLiteral */: - return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, /*implementations*/ false); - } - return undefined; + return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename); } FindAllReferences.findReferencedSymbols = findReferencedSymbols; - function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, implementations) { + function convertReferences(referenceSymbols) { + return referenceSymbols && ts.flatMap(referenceSymbols, function (r) { return r.references; }); + } + FindAllReferences.convertReferences = convertReferences; + function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename, implementations) { if (!implementations) { - // Labels - if (ts.isLabelName(node)) { - if (ts.isJumpStatementTarget(node)) { - var labelDefinition = ts.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 (ts.isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles); - } - if (node.kind === 96 /* SuperKeyword */) { - return getReferencesForSuperKeyword(node); + var special = getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken); + if (special) { + return special; } } // `getSymbolAtLocation` normally returns the symbol of the class when given the constructor keyword, // so we have to specify that we want the constructor symbol. var symbol = typeChecker.getSymbolAtLocation(node); - if (!implementations && !symbol && node.kind === 9 /* StringLiteral */) { - return getReferencesForStringLiteral(node, sourceFiles); - } // Could not find a symbol e.g. unknown identifier if (!symbol) { + if (!implementations && node.kind === 9 /* StringLiteral */) { + return getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken); + } // Can't have references to something that we have no symbol for. return undefined; } @@ -69551,1040 +71753,1120 @@ var ts; if (!declarations || !declarations.length) { return undefined; } - var result; + var _a = followAliases(symbol, node, typeChecker, isForRename), aliasedSymbol = _a.symbol, shorthandModuleSymbol = _a.shorthandModuleSymbol; + symbol = aliasedSymbol; + // Build the set of symbols to search for, initially it has only the current symbol + var searchSymbols = populateSearchSymbolSet(symbol, node, typeChecker, implementations); + if (shorthandModuleSymbol) { + searchSymbols.push(shorthandModuleSymbol); + } // Compute the meaning from the location and the symbol it references var searchMeaning = getIntersectingMeaningFromDeclarations(ts.getMeaningFromLocation(node), declarations); + var result = []; + // Maps from a symbol ID to the ReferencedSymbol entry in 'result'. + var symbolToIndex = []; + var inheritsFromCache = ts.createMap(); // 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); + getRefs(scope, declaredName); } else { - var internedName = getInternedName(symbol, node); - for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { - var sourceFile = sourceFiles_8[_i]; + var isDefault = ts.isExportDefaultSymbol(symbol); + var internedName = isDefault ? symbol.valueDeclaration.localSymbol.name : getInternedName(symbol, node); + for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { + var sourceFile = sourceFiles_5[_i]; cancellationToken.throwIfCancellationRequested(); - var nameTable = ts.getNameTable(sourceFile); - if (nameTable[internedName] !== undefined) { - result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + var searchName = (isDefault ? getDefaultImportName(symbol, sourceFile, typeChecker) : undefined) || + (sourceFileHasName(sourceFile, internedName) ? declaredName : undefined); + if (searchName !== undefined) { + getRefs(sourceFile, searchName); } } } return result; - function getDefinition(symbol) { - var info = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.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), - displayParts: info.displayParts - }; + function getRefs(scope, searchName) { + getReferencesInNode(scope, symbol, searchName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache); } - function getAliasSymbolForPropertyNameSymbol(symbol, location) { - if (symbol.flags & 8388608 /* Alias */) { - // Default import get alias - var defaultImport = ts.getDeclarationOfKind(symbol, 236 /* ImportClause */); - if (defaultImport) { - return typeChecker.getAliasedSymbol(symbol); - } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 239 /* ImportSpecifier */ || - declaration.kind === 243 /* ExportSpecifier */) ? declaration : undefined; }); - if (importOrExportSpecifier && - // export { a } - (!importOrExportSpecifier.propertyName || - // export {a as class } where a is location - importOrExportSpecifier.propertyName === location)) { - // If Import specifier -> get alias - // else Export specifier -> get local target - return importOrExportSpecifier.kind === 239 /* ImportSpecifier */ ? - typeChecker.getAliasedSymbol(symbol) : - typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); - } + } + FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; + /** getReferencedSymbols for special node kinds. */ + function getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken) { + if (ts.isTypeKeyword(node.kind)) { + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + } + // Labels + if (ts.isLabelName(node)) { + if (ts.isJumpStatementTarget(node)) { + var labelDefinition = ts.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, cancellationToken); } + else { + // it is a label definition and not a target, search within the parent labeledStatement + return getLabelReferencesInNode(node.parent, node, cancellationToken); + } + } + if (ts.isThis(node)) { + return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken); + } + if (node.kind === 96 /* SuperKeyword */) { + return getReferencesForSuperKeyword(node, typeChecker, cancellationToken); + } + return undefined; + } + /** + * Follows aliases to get to the original declaration of a symbol. + * For a shorthand ambient module, we don't follow the alias to it, but we will need to add it to the set of search symbols. + */ + function followAliases(symbol, node, typeChecker, isForRename) { + while (true) { + // When renaming a default import, only rename in the current file + if (isForRename && isImportDefaultSymbol(symbol)) { + return { symbol: symbol }; + } + var aliasedSymbol = getAliasSymbolForPropertyNameSymbol(symbol, node, typeChecker); + // Don't follow alias if it goes to unknown symbol. This can happen if it points to an untyped module. + if (!aliasedSymbol || !aliasedSymbol.declarations) { + return { symbol: symbol }; + } + if (ts.isShorthandAmbientModuleSymbol(aliasedSymbol)) { + return { symbol: symbol, shorthandModuleSymbol: aliasedSymbol }; + } + symbol = aliasedSymbol; + } + } + function sourceFileHasName(sourceFile, name) { + return ts.getNameTable(sourceFile).get(name) !== undefined; + } + /** + * Given a symbol, see if any of the imports in a source file reference it. + * Only call this if `symbol` is a default export. + */ + function getDefaultImportName(symbol, sourceFile, checker) { + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var importSpecifier = _a[_i]; + var importDecl = importSpecifier.parent; + ts.Debug.assert(importDecl.moduleSpecifier === importSpecifier); + var defaultName = importDecl.importClause.name; + var defaultReferencedSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName)); + if (symbol === defaultReferencedSymbol) { + return defaultName.text; + } + } + return undefined; + } + function getDefinition(symbol, node, typeChecker) { + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.getContainerNode(node), node), displayParts = _a.displayParts, symbolKind = _a.symbolKind; + var name = displayParts.map(function (p) { return p.text; }).join(""); + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { return undefined; } - function followAliasIfNecessary(symbol, location) { - return getAliasSymbolForPropertyNameSymbol(symbol, location) || symbol; - } - function getPropertySymbolOfDestructuringAssignment(location) { - return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - typeChecker.getPropertySymbolOfDestructuringAssignment(location); - } - function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 174 /* BindingElement */); - return bindingElement && - bindingElement.parent.kind === 172 /* ObjectBindingPattern */ && - !bindingElement.propertyName; - } - function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 174 /* BindingElement */); - var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); - return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); - } + return { + containerKind: "", + containerName: "", + name: name, + kind: symbolKind, + fileName: declarations[0].getSourceFile().fileName, + textSpan: ts.createTextSpan(declarations[0].getStart(), 0), + displayParts: displayParts + }; + } + function getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) { + if (!(symbol.flags & 8388608 /* Alias */)) { return undefined; } - function getInternedName(symbol, location) { - // If this is an export or import specifier it could have been renamed using the 'as' syntax. - // If so we want to search for whatever under the cursor. - if (ts.isImportOrExportSpecifierName(location)) { - 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); + // Default import get alias + var defaultImport = ts.getDeclarationOfKind(symbol, 238 /* ImportClause */); + if (defaultImport) { + return typeChecker.getAliasedSymbol(symbol); } - /** - * 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 === 184 /* FunctionExpression */ || valueDeclaration.kind === 197 /* ClassExpression */)) { - return valueDeclaration; - } - // If this is private property or method, the scope is the containing class - if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8 /* Private */) ? d : undefined; }); - if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 226 /* ClassDeclaration */); - } - } - // If the symbol is an import we would like to find it if we are looking for what it imports. - // So consider it visible outside its declaration scope. - if (symbol.flags & 8388608 /* Alias */) { - return undefined; - } - // If symbol is of object binding pattern element without property name we would want to - // look for property too and that could be anywhere - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - 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; - var declarations = symbol.getDeclarations(); - if (declarations) { - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; - var container = ts.getContainerNode(declaration); - if (!container) { - return undefined; - } - if (scope && scope !== container) { - // Different declarations have different containers, bail out - return undefined; - } - if (container.kind === 261 /* 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; + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 241 /* ImportSpecifier */ || + declaration.kind === 245 /* ExportSpecifier */) ? declaration : undefined; }); + if (importOrExportSpecifier && + // export { a } + (!importOrExportSpecifier.propertyName || + // export {a as class } where a is location + importOrExportSpecifier.propertyName === location)) { + // If Import specifier -> get alias + // else Export specifier -> get local target + return importOrExportSpecifier.kind === 241 /* ImportSpecifier */ ? + typeChecker.getAliasedSymbol(symbol) : + typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } - 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; + } + function followAliasIfNecessary(symbol, location, typeChecker) { + return getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) || symbol; + } + function getPropertySymbolOfDestructuringAssignment(location, typeChecker) { + return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && + typeChecker.getPropertySymbolOfDestructuringAssignment(location); + } + function isObjectBindingPatternElementWithoutPropertyName(symbol) { + var bindingElement = ts.getDeclarationOfKind(symbol, 175 /* BindingElement */); + return bindingElement && + bindingElement.parent.kind === 173 /* ObjectBindingPattern */ && + !bindingElement.propertyName; + } + function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker) { + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + var bindingElement = ts.getDeclarationOfKind(symbol, 175 /* BindingElement */); + var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); + return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + } + return undefined; + } + function getInternedName(symbol, location) { + // If this is an export or import specifier it could have been renamed using the 'as' syntax. + // If so we want to search for whatever under the cursor. + if (ts.isImportOrExportSpecifierName(location)) { + return location.text; + } + 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 === 185 /* FunctionExpression */ || valueDeclaration.kind === 198 /* ClassExpression */)) { + return valueDeclaration; + } + // If this is private property or method, the scope is the containing class + if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { + var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8 /* Private */) ? d : undefined; }); + if (privateDeclaration) { + return ts.getAncestor(privateDeclaration, 228 /* ClassDeclaration */); } - 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), 5 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5 /* Latest */))) { - // Found a real match. Keep searching. - positions.push(position); + } + // If the symbol is an import we would like to find it if we are looking for what it imports. + // So consider it visible outside its declaration scope. + if (symbol.flags & 8388608 /* Alias */) { + return undefined; + } + // If symbol is of object binding pattern element without property name we would want to + // look for property too and that could be anywhere + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + 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 & 134217728 /* Transient */ && symbol.checkFlags & 2 /* SyntheticProperty */)) { + return undefined; + } + var scope; + var declarations = symbol.getDeclarations(); + if (declarations) { + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; + var container = ts.getContainerNode(declaration); + if (!container) { + return undefined; } - position = text.indexOf(symbolName, position + symbolNameLength + 1); + if (scope && scope !== container) { + // Different declarations have different containers, bail out + return undefined; + } + if (container.kind === 264 /* 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, cancellationToken) { + 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; } - 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 || - (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ts.ScriptElementKind.label, - name: labelName, - textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()), - displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] - }; - return [{ definition: definition, references: references }]; + 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), 5 /* Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5 /* Latest */))) { + // Found a real match. Keep searching. + positions.push(position); + } + position = text.indexOf(symbolName, position + symbolNameLength + 1); } - 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 70 /* Identifier */: - return node.getWidth() === searchSymbolName.length; - case 9 /* StringLiteral */: - if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isNameOfExternalModuleImportOrDeclaration(node)) { - // For string literals we have two additional chars for the quotes - return node.getWidth() === searchSymbolName.length + 2; + return positions; + } + function getLabelReferencesInNode(container, targetLabel, cancellationToken) { + var references = []; + var sourceFile = container.getSourceFile(); + var labelName = targetLabel.text; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd(), cancellationToken); + 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 || + (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { + references.push(getReferenceEntryFromNode(node)); + } + }); + var definition = { + containerKind: "", + containerName: "", + fileName: targetLabel.getSourceFile().fileName, + kind: ts.ScriptElementKind.label, + name: labelName, + textSpan: ts.createTextSpanFromNode(targetLabel, sourceFile), + displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] + }; + return [{ definition: definition, references: references }]; + } + function isValidReferencePosition(node, searchSymbolName) { + // Compare the length so we filter out strict superstrings of the symbol we are looking for + switch (node && node.kind) { + case 70 /* Identifier */: + return node.getWidth() === searchSymbolName.length; + case 9 /* StringLiteral */: + return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && + // For string literals we have two additional chars for the quotes + node.getWidth() === searchSymbolName.length + 2; + case 8 /* NumericLiteral */: + return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; + default: + return false; + } + } + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + var name = ts.tokenToString(keywordKind); + var references = []; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var sourceFile = sourceFiles_6[_i]; + cancellationToken.throwIfCancellationRequested(); + addReferencesForKeywordInFile(sourceFile, keywordKind, name, cancellationToken, references); + } + if (!references.length) + return undefined; + var definition = { + containerKind: "", + containerName: "", + fileName: references[0].fileName, + kind: ts.ScriptElementKind.keyword, + name: name, + textSpan: references[0].textSpan, + displayParts: [{ text: name, kind: ts.ScriptElementKind.keyword }] + }; + return [{ definition: definition, references: references }]; + } + function addReferencesForKeywordInFile(sourceFile, kind, searchText, cancellationToken, references) { + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { + var position = possiblePositions_1[_i]; + cancellationToken.throwIfCancellationRequested(); + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (referenceLocation.kind === kind) { + references.push({ + textSpan: ts.createTextSpanFromNode(referenceLocation), + fileName: sourceFile.fileName, + isWriteAccess: false, + isDefinition: 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, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache) { + var sourceFile = container.getSourceFile(); + var start = findInComments ? container.getFullStart() : container.getStart(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd(), cancellationToken); + var parents = getParentSymbolsOfPropertyAccess(); + for (var _i = 0, possiblePositions_2 = possiblePositions; _i < possiblePositions_2.length; _i++) { + var position = possiblePositions_2[_i]; + cancellationToken.throwIfCancellationRequested(); + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (!isValidReferencePosition(referenceLocation, searchText)) { + // This wasn't the start of a token. Check to see if it might be a + // match in a comment or string if that's what the caller is asking + // for. + if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || + (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { + // In the case where we're looking inside comments/strings, we don't have + // an actual definition. So just use 'undefined' here. Features like + // 'Rename' won't care (as they ignore the definitions), and features like + // 'FindReferences' will just filter out these results. + result.push({ + definition: undefined, + references: [{ + fileName: sourceFile.fileName, + textSpan: ts.createTextSpan(position, searchText.length), + isWriteAccess: false, + isDefinition: false + }] + }); + } + continue; + } + if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { + continue; + } + var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); + if (referenceSymbol) { + var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); + var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, + /*searchLocationIsConstructor*/ searchLocation.kind === 122 /* ConstructorKeyword */, parents, inheritsFromCache, typeChecker); + if (relatedSymbol) { + addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); + } + else if (!(referenceSymbol.flags & 134217728 /* Transient */) && ts.contains(searchSymbols, shorthandValueSymbol)) { + addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); + } + else if (searchLocation.kind === 122 /* ConstructorKeyword */) { + findAdditionalConstructorReferences(referenceSymbol, referenceLocation); + } + } + } + return; + /* If we are just looking for implementations and this is a property access expression, we need to get the + * symbol of the local type of the symbol the property is being accessed on. This is because our search + * symbol may have a different parent symbol if the local type's symbol does not declare the property + * being accessed (i.e. it is declared in some parent class or interface) + */ + function getParentSymbolsOfPropertyAccess() { + if (implementations) { + var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); + if (propertyAccessExpression) { + var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); + if (localParentType) { + if (localParentType.symbol && localParentType.symbol.flags & (32 /* Class */ | 64 /* Interface */) && localParentType.symbol !== searchSymbol.parent) { + return [localParentType.symbol]; } - break; - case 8 /* NumericLiteral */: - if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - return node.getWidth() === searchSymbolName.length; + else if (localParentType.flags & 196608 /* UnionOrIntersection */) { + return getSymbolsForClassAndInterfaceComponents(localParentType); } - break; + } + } + } + } + /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ + function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { + ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); + var referenceClass = referenceLocation.parent; + if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { + ts.Debug.assert(referenceClass.name === referenceLocation); + // This is the class declaration containing the constructor. + addReferences(findOwnConstructorCalls(searchSymbol, sourceFile)); + } + else { + // If this class appears in `extends C`, then the extending class' "super" calls are references. + var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); + if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation, typeChecker) === searchSymbol) { + addReferences(superConstructorAccesses(classExtending)); + } + } + } + function addReferences(references) { + if (references.length) { + var referencedSymbol = getReferencedSymbol(searchSymbol); + ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); + } + } + 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, searchLocation, typeChecker), + references: [] + }); + } + return result[index]; + } + function addReferenceToRelatedSymbol(node, relatedSymbol) { + var references = getReferencedSymbol(relatedSymbol).references; + if (implementations) { + getImplementationReferenceEntryForNode(node, references, typeChecker); + } + else { + references.push(getReferenceEntryFromNode(node)); + } + } + } + function getPropertyAccessExpressionFromRightHandSide(node) { + return ts.isRightSideOfPropertyAccess(node) && node.parent; + } + /** `classSymbol` is the class where the constructor was defined. + * Reference the constructor and all calls to `new this()`. + */ + function findOwnConstructorCalls(classSymbol, sourceFile) { + var result = []; + for (var _i = 0, _a = classSymbol.members.get("__constructor").declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var ctrKeyword = ts.findChildOfKind(decl, 122 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 151 /* Constructor */ && !!ctrKeyword); + result.push(ctrKeyword); + } + classSymbol.exports.forEach(function (member) { + var decl = member.valueDeclaration; + if (decl && decl.kind === 150 /* MethodDeclaration */) { + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 98 /* ThisKeyword */, function (thisKeyword) { + if (ts.isNewExpressionTarget(thisKeyword)) { + result.push(thisKeyword); + } + }); + } + } + }); + return result; + } + /** Find references to `super` in the constructor of an extending class. */ + function superConstructorAccesses(cls) { + var symbol = cls.symbol; + var ctr = symbol.members.get("__constructor"); + if (!ctr) { + return []; + } + var result = []; + for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.Debug.assert(decl.kind === 151 /* Constructor */); + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 96 /* SuperKeyword */, function (node) { + if (ts.isCallExpressionTarget(node)) { + result.push(node); + } + }); + } + } + ; + return result; + } + function getImplementationReferenceEntryForNode(refNode, result, typeChecker) { + // Check if we found a function/propertyAssignment/method with an implementation or initializer + if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { + result.push(getReferenceEntryFromNode(refNode.parent)); + } + else if (refNode.kind === 70 /* Identifier */) { + if (refNode.parent.kind === 261 /* ShorthandPropertyAssignment */) { + // Go ahead and dereference the shorthand assignment by going to its definition + getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); + } + // Check if the node is within an extends or implements clause + var containingClass = getContainingClassIfInHeritageClause(refNode); + if (containingClass) { + result.push(getReferenceEntryFromNode(containingClass)); + return; + } + // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface + var containingTypeReference = getContainingTypeReference(refNode); + if (containingTypeReference) { + var parent = containingTypeReference.parent; + if (ts.isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent.initializer)); + } + else if (ts.isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { + if (parent.body.kind === 206 /* Block */) { + ts.forEachReturnStatement(parent.body, function (returnStatement) { + if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { + maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); + } + }); + } + else if (isImplementationExpression(parent.body)) { + maybeAdd(getReferenceEntryFromNode(parent.body)); + } + } + else if (ts.isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { + maybeAdd(getReferenceEntryFromNode(parent.expression)); + } + } + } + // Type nodes can contain multiple references to the same type. For example: + // let x: Foo & (Foo & Bar) = ... + // Because we are returning the implementation locations and not the identifier locations, + // duplicate entries would be returned here as each of the type references is part of + // the same implementation. For that reason, check before we add a new entry + function maybeAdd(a) { + if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { + result.push(a); + } + } + } + function getSymbolsForClassAndInterfaceComponents(type, result) { + if (result === void 0) { result = []; } + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var componentType = _a[_i]; + if (componentType.symbol && componentType.symbol.getFlags() & (32 /* Class */ | 64 /* Interface */)) { + result.push(componentType.symbol); + } + if (componentType.getFlags() & 196608 /* UnionOrIntersection */) { + getSymbolsForClassAndInterfaceComponents(componentType, result); + } + } + return result; + } + function getContainingTypeReference(node) { + var topLevelTypeReference = undefined; + while (node) { + if (ts.isTypeNode(node)) { + topLevelTypeReference = node; + } + node = node.parent; + } + return topLevelTypeReference; + } + function getContainingClassIfInHeritageClause(node) { + if (node && node.parent) { + if (node.kind === 200 /* ExpressionWithTypeArguments */ + && node.parent.kind === 258 /* HeritageClause */ + && ts.isClassLike(node.parent.parent)) { + return node.parent.parent; + } + else if (node.kind === 70 /* Identifier */ || node.kind === 178 /* PropertyAccessExpression */) { + return getContainingClassIfInHeritageClause(node.parent); + } + } + return undefined; + } + /** + * Returns true if this is an expression that can be considered an implementation + */ + function isImplementationExpression(node) { + switch (node.kind) { + case 184 /* ParenthesizedExpression */: + return isImplementationExpression(node.expression); + case 186 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 177 /* ObjectLiteralExpression */: + case 198 /* ClassExpression */: + case 176 /* ArrayLiteralExpression */: + return true; + default: + return false; + } + } + /** + * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol + * is an interface, determines if some ancestor of the child symbol extends or inherits from it. + * Also takes in a cache of previous results which makes this slightly more efficient and is + * necessary to avoid potential loops like so: + * class A extends B { } + * class B extends A { } + * + * We traverse the AST rather than using the type checker because users are typically only interested + * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling + * implementations of types that share a common ancestor with the type whose implementation we are + * searching for need to be filtered out of the results. The type checker doesn't let us make the + * distinction between structurally compatible implementations and explicit implementations, so we + * must use the AST. + * + * @param child A class or interface Symbol + * @param parent Another class or interface Symbol + * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results + */ + function explicitlyInheritsFrom(child, parent, cachedResults, typeChecker) { + var parentIsInterface = parent.getFlags() & 64 /* Interface */; + return searchHierarchy(child); + function searchHierarchy(symbol) { + if (symbol === parent) { + return true; + } + var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); + var cached = cachedResults.get(key); + if (cached !== undefined) { + return cached; + } + // Set the key so that we don't infinitely recurse + cachedResults.set(key, false); + var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + if (parentIsInterface) { + var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); + if (interfaceReferences) { + for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { + var typeReference = interfaceReferences_1[_i]; + if (searchTypeReference(typeReference)) { + return true; + } + } + } + } + return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + } + else if (declaration.kind === 229 /* InterfaceDeclaration */) { + if (parentIsInterface) { + return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); + } + } + return false; + }); + cachedResults.set(key, inherits); + return inherits; + } + function searchTypeReference(typeReference) { + if (typeReference) { + var type = typeChecker.getTypeAtLocation(typeReference); + if (type && type.symbol) { + return searchHierarchy(type.symbol); } } 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 start = findInComments ? container.getFullStart() : container.getStart(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd()); - var parents = getParentSymbolsOfPropertyAccess(); - var inheritsFromCache = ts.createMap(); - if (possiblePositions.length) { - // Build the set of symbols to search for, initially it has only the current symbol - var searchSymbols_1 = populateSearchSymbolSet(searchSymbol, searchLocation); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); - if (!isValidReferencePosition(referenceLocation, searchText)) { - // This wasn't the start of a token. Check to see if it might be a - // match in a comment or string if that's what the caller is asking - // for. - if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || - (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { - // In the case where we're looking inside comments/strings, we don't have - // an actual definition. So just use 'undefined' here. Features like - // 'Rename' won't care (as they ignore the definitions), and features like - // 'FindReferences' will just filter out these results. - result.push({ - definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: ts.createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] - }); - } - return; - } - if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { - return; - } - var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); - if (referenceSymbol) { - var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, - /*searchLocationIsConstructor*/ searchLocation.kind === 122 /* ConstructorKeyword */, parents, inheritsFromCache); - if (relatedSymbol) { - addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); - } - else if (!(referenceSymbol.flags & 67108864 /* Transient */) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { - addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); - } - else if (searchLocation.kind === 122 /* ConstructorKeyword */) { - findAdditionalConstructorReferences(referenceSymbol, referenceLocation); - } - } - }); - } - return; - /* If we are just looking for implementations and this is a property access expression, we need to get the - * symbol of the local type of the symbol the property is being accessed on. This is because our search - * symbol may have a different parent symbol if the local type's symbol does not declare the property - * being accessed (i.e. it is declared in some parent class or interface) - */ - function getParentSymbolsOfPropertyAccess() { - if (implementations) { - var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); - if (propertyAccessExpression) { - var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); - if (localParentType) { - if (localParentType.symbol && localParentType.symbol.flags & (32 /* Class */ | 64 /* Interface */) && localParentType.symbol !== searchSymbol.parent) { - return [localParentType.symbol]; - } - else if (localParentType.flags & 196608 /* UnionOrIntersection */) { - return getSymbolsForClassAndInterfaceComponents(localParentType); - } - } - } - } - } - function getPropertyAccessExpressionFromRightHandSide(node) { - return ts.isRightSideOfPropertyAccess(node) && node.parent; - } - /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ - function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { - ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); - var referenceClass = referenceLocation.parent; - if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { - ts.Debug.assert(referenceClass.name === referenceLocation); - // This is the class declaration containing the constructor. - addReferences(findOwnConstructorCalls(searchSymbol)); - } - else { - // If this class appears in `extends C`, then the extending class' "super" calls are references. - var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); - if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation) === searchSymbol) { - addReferences(superConstructorAccesses(classExtending)); - } - } - } - function addReferences(references) { - if (references.length) { - var referencedSymbol = getReferencedSymbol(searchSymbol); - ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); - } - } - /** `classSymbol` is the class where the constructor was defined. - * Reference the constructor and all calls to `new this()`. - */ - function findOwnConstructorCalls(classSymbol) { - var result = []; - for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 150 /* Constructor */); - var ctrKeyword = decl.getChildAt(0); - ts.Debug.assert(ctrKeyword.kind === 122 /* ConstructorKeyword */); - result.push(ctrKeyword); - } - ts.forEachProperty(classSymbol.exports, function (member) { - var decl = member.valueDeclaration; - if (decl && decl.kind === 149 /* MethodDeclaration */) { - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 98 /* ThisKeyword */, function (thisKeyword) { - if (ts.isNewExpressionTarget(thisKeyword)) { - result.push(thisKeyword); - } - }); - } - } - }); - return result; - } - /** Find references to `super` in the constructor of an extending class. */ - function superConstructorAccesses(cls) { - var symbol = cls.symbol; - var ctr = symbol.members["__constructor"]; - if (!ctr) { - return []; - } - var result = []; - for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 150 /* Constructor */); - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 96 /* SuperKeyword */, function (node) { - if (ts.isCallExpressionTarget(node)) { - result.push(node); - } - }); - } - } - ; - return result; - } - 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 addReferenceToRelatedSymbol(node, relatedSymbol) { - var references = getReferencedSymbol(relatedSymbol).references; - if (implementations) { - getImplementationReferenceEntryForNode(node, references); - } - else { - references.push(getReferenceEntryFromNode(node)); - } - } - } - function getImplementationReferenceEntryForNode(refNode, result) { - // Check if we found a function/propertyAssignment/method with an implementation or initializer - if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { - result.push(getReferenceEntryFromNode(refNode.parent)); - } - else if (refNode.kind === 70 /* Identifier */) { - if (refNode.parent.kind === 258 /* ShorthandPropertyAssignment */) { - // Go ahead and dereference the shorthand assignment by going to its definition - getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); - } - // Check if the node is within an extends or implements clause - var containingClass = getContainingClassIfInHeritageClause(refNode); - if (containingClass) { - result.push(getReferenceEntryFromNode(containingClass)); - return; - } - // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface - var containingTypeReference = getContainingTypeReference(refNode); - if (containingTypeReference) { - var parent_18 = containingTypeReference.parent; - if (ts.isVariableLike(parent_18) && parent_18.type === containingTypeReference && parent_18.initializer && isImplementationExpression(parent_18.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_18.initializer)); - } - else if (ts.isFunctionLike(parent_18) && parent_18.type === containingTypeReference && parent_18.body) { - if (parent_18.body.kind === 204 /* Block */) { - ts.forEachReturnStatement(parent_18.body, function (returnStatement) { - if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { - maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); - } - }); - } - else if (isImplementationExpression(parent_18.body)) { - maybeAdd(getReferenceEntryFromNode(parent_18.body)); - } - } - else if (ts.isAssertionExpression(parent_18) && isImplementationExpression(parent_18.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_18.expression)); - } - } - } - // Type nodes can contain multiple references to the same type. For example: - // let x: Foo & (Foo & Bar) = ... - // Because we are returning the implementation locations and not the identifier locations, - // duplicate entries would be returned here as each of the type references is part of - // the same implementation. For that reason, check before we add a new entry - function maybeAdd(a) { - if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { - result.push(a); - } - } - } - function getSymbolsForClassAndInterfaceComponents(type, result) { - if (result === void 0) { result = []; } - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var componentType = _a[_i]; - if (componentType.symbol && componentType.symbol.getFlags() & (32 /* Class */ | 64 /* Interface */)) { - result.push(componentType.symbol); - } - if (componentType.getFlags() & 196608 /* UnionOrIntersection */) { - getSymbolsForClassAndInterfaceComponents(componentType, result); - } - } - return result; - } - function getContainingTypeReference(node) { - var topLevelTypeReference = undefined; - while (node) { - if (ts.isTypeNode(node)) { - topLevelTypeReference = node; - } - node = node.parent; - } - return topLevelTypeReference; - } - function getContainingClassIfInHeritageClause(node) { - if (node && node.parent) { - if (node.kind === 199 /* ExpressionWithTypeArguments */ - && node.parent.kind === 255 /* HeritageClause */ - && ts.isClassLike(node.parent.parent)) { - return node.parent.parent; - } - else if (node.kind === 70 /* Identifier */ || node.kind === 177 /* PropertyAccessExpression */) { - return getContainingClassIfInHeritageClause(node.parent); - } - } + } + function getReferencesForSuperKeyword(superKeyword, typeChecker, cancellationToken) { + var searchSpaceNode = ts.getSuperContainer(superKeyword, /*stopOnFunctions*/ false); + if (!searchSpaceNode) { return undefined; } - /** - * Returns true if this is an expression that can be considered an implementation - */ - function isImplementationExpression(node) { - // Unwrap parentheses - if (node.kind === 183 /* ParenthesizedExpression */) { - return isImplementationExpression(node.expression); - } - return node.kind === 185 /* ArrowFunction */ || - node.kind === 184 /* FunctionExpression */ || - node.kind === 176 /* ObjectLiteralExpression */ || - node.kind === 197 /* ClassExpression */ || - node.kind === 175 /* ArrayLiteralExpression */; - } - /** - * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol - * is an interface, determines if some ancestor of the child symbol extends or inherits from it. - * Also takes in a cache of previous results which makes this slightly more efficient and is - * necessary to avoid potential loops like so: - * class A extends B { } - * class B extends A { } - * - * We traverse the AST rather than using the type checker because users are typically only interested - * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling - * implementations of types that share a common ancestor with the type whose implementation we are - * searching for need to be filtered out of the results. The type checker doesn't let us make the - * distinction between structurally compatible implementations and explicit implementations, so we - * must use the AST. - * - * @param child A class or interface Symbol - * @param parent Another class or interface Symbol - * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results - */ - function explicitlyInheritsFrom(child, parent, cachedResults) { - var parentIsInterface = parent.getFlags() & 64 /* Interface */; - return searchHierarchy(child); - function searchHierarchy(symbol) { - if (symbol === parent) { - return true; - } - var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); - if (key in cachedResults) { - return cachedResults[key]; - } - // Set the key so that we don't infinitely recurse - cachedResults[key] = false; - var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - if (parentIsInterface) { - var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); - if (interfaceReferences) { - for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { - var typeReference = interfaceReferences_1[_i]; - if (searchTypeReference(typeReference)) { - return true; - } - } - } - } - return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - } - else if (declaration.kind === 227 /* InterfaceDeclaration */) { - if (parentIsInterface) { - return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); - } - } - return false; - }); - cachedResults[key] = inherits; - return inherits; - } - function searchTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type && type.symbol) { - return searchHierarchy(type.symbol); - } - } - return false; - } - } - function getReferencesForSuperKeyword(superKeyword) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, /*stopOnFunctions*/ false); - if (!searchSpaceNode) { + // Whether 'super' occurs in a static context within a class. + var staticFlag = 32 /* Static */; + switch (searchSpaceNode.kind) { + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + 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(), cancellationToken); + for (var _i = 0, possiblePositions_3 = possiblePositions; _i < possiblePositions_3.length; _i++) { + var position = possiblePositions_3[_i]; + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 96 /* SuperKeyword */) { + continue; } - // Whether 'super' occurs in a static context within a class. - var staticFlag = 32 /* Static */; - switch (searchSpaceNode.kind) { - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + var container = ts.getSuperContainer(node, /*stopOnFunctions*/ 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 && (32 /* Static */ & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + references.push(getReferenceEntryFromNode(node)); + } + } + var definition = getDefinition(searchSpaceNode.symbol, superKeyword, typeChecker); + return [{ definition: definition, references: references }]; + } + function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, typeChecker, cancellationToken) { + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); + // Whether 'this' occurs in a static context within a class. + var staticFlag = 32 /* Static */; + switch (searchSpaceNode.kind) { + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; - default: + } + // fall through + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + break; + case 264 /* SourceFile */: + if (ts.isExternalModule(searchSpaceNode)) { return undefined; - } - var references = []; + } + // Fall through + case 227 /* FunctionDeclaration */: + case 185 /* 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 === 264 /* SourceFile */) { + ts.forEach(sourceFiles, function (sourceFile) { + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); + } + else { var sourceFile = searchSpaceNode.getSourceFile(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); + } + var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); + var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: thisOrSuperKeyword.getSourceFile().fileName, + kind: ts.ScriptElementKind.variableElement, + name: "this", + textSpan: ts.createTextSpanFromNode(thisOrSuperKeyword), + displayParts: displayParts + }, + 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 !== 96 /* SuperKeyword */) { + if (!node || !ts.isThis(node)) { return; } - var container = ts.getSuperContainer(node, /*stopOnFunctions*/ 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 && (32 /* Static */ & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); + var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); + switch (searchSpaceNode.kind) { + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + if (searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 198 /* ClassExpression */: + case 228 /* ClassDeclaration */: + // Make sure the container belongs to the same class + // and has the appropriate static modifier from the original container. + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 264 /* SourceFile */: + if (container.kind === 264 /* SourceFile */ && !ts.isExternalModule(container)) { + result.push(getReferenceEntryFromNode(node)); + } + break; } }); - 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 = 32 /* Static */; - switch (searchSpaceNode.kind) { - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - if (ts.isObjectLiteralMethod(searchSpaceNode)) { - break; + } + function getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken) { + var type = ts.getStringLiteralTypeForNode(node, typeChecker); + if (!type) { + // nothing to do here. moving on + return undefined; + } + var references = []; + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); + } + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ts.ScriptElementKind.variableElement, + name: type.text, + textSpan: ts.createTextSpanFromNode(node), + displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] + }, + references: references + }]; + function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { + for (var _i = 0, possiblePositions_4 = possiblePositions; _i < possiblePositions_4.length; _i++) { + var position = possiblePositions_4[_i]; + cancellationToken.throwIfCancellationRequested(); + var node_2 = ts.getTouchingWord(sourceFile, position); + if (!node_2 || node_2.kind !== 9 /* StringLiteral */) { + return; + } + var type_2 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + if (type_2 === searchType) { + references.push(getReferenceEntryFromNode(node_2)); + } + } + } + } + function populateSearchSymbolSet(symbol, location, typeChecker, implementations) { + // The search set contains at least the current symbol + var result = [symbol]; + // If the location is name of property symbol from object literal destructuring pattern + // Search the property symbol + // for ( { property: p2 } of elems) { } + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(location); + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 261 /* ShorthandPropertyAssignment */) { + var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, typeChecker); + if (propertySymbol) { + result.push(propertySymbol); + } + } + // 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 (containingObjectLiteralElement) { + ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), 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 + * const name = "Foo"; + * const 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 the symbol.valueDeclaration is a property parameter declaration, + // we should include both parameter declaration symbol and property declaration symbol + // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. + // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 145 /* Parameter */ && + ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + ts.addRange(result, typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); + } + // If this is symbol of binding element without propertyName declaration in Object binding pattern + // Include the property in the search + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker); + if (bindingElementPropertySymbol) { + result.push(bindingElementPropertySymbol); + } + // 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 + for (var _i = 0, _a = typeChecker.getRootSymbols(symbol); _i < _a.length; _i++) { + var rootSymbol = _a[_i]; + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap(), typeChecker); + } + } + return result; + } + /** + * Find symbol of the given property-name and add the symbol to the given result array + * @param symbol a symbol to start searching for the given propertyName + * @param propertyName a name of property to search for + * @param result an array of symbol of found property symbols + * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. + * The value of previousIterationSymbol is undefined when the function is first called. + */ + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache, typeChecker) { + if (!symbol) { + return; + } + // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited + // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. + // For example: + // interface C extends C { + // /*findRef*/propName: string; + // } + // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, + // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, + // the function will add any found symbol of the property-name, then its sub-routine will call + // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already + // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. + if (previousIterationSymbolsCache.has(symbol.name)) { + return; + } + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === 229 /* 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.apply(result, typeChecker.getRootSymbols(propertySymbol)); } - // fall through - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class - break; - case 261 /* SourceFile */: - if (ts.isExternalModule(searchSpaceNode)) { + // Visit the typeReference as well to see if it directly or indirectly use that property + previousIterationSymbolsCache.set(symbol.name, symbol); + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, typeChecker); + } + } + } + } + function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker) { + if (ts.contains(searchSymbols, referenceSymbol)) { + // If we are searching for constructor uses, they must be 'new' expressions. + return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) ? referenceSymbol : undefined; + } + // If the reference symbol is an alias, check if what it is aliasing is one of the search + // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. + var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation, typeChecker); + if (aliasSymbol) { + return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker); + } + // 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 + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(referenceLocation); + if (containingObjectLiteralElement) { + var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { + return ts.find(typeChecker.getRootSymbols(contextualSymbol), function (symbol) { return ts.contains(searchSymbols, symbol); }); + }); + if (contextualSymbol) { + return contextualSymbol; + } + // If the reference location is the name of property from object literal destructuring pattern + // Get the property symbol from the object literal's type and look if thats the search symbol + // In below eg. get 'property' from type of elems iterating type + // for ( { property: p2 } of elems) { } + var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, typeChecker); + if (propertySymbol && ts.contains(searchSymbols, propertySymbol)) { + return propertySymbol; + } + } + // If the reference location is the binding element and doesn't have property name + // then include the binding element in the related symbols + // let { a } : { a }; + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, typeChecker); + if (bindingElementPropertySymbol && ts.contains(searchSymbols, bindingElementPropertySymbol)) { + return bindingElementPropertySymbol; + } + // 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 (ts.contains(searchSymbols, rootSymbol)) { + 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 we were passed a parent symbol, only include types that are subtypes of the + // parent symbol + if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + // Parents will only be defined if implementations is true + if (parents) { + if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache, typeChecker); })) { return undefined; } - // Fall through - case 225 /* FunctionDeclaration */: - case 184 /* 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 === 261 /* 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); - } - var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); - var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: "this", - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: displayParts - }, - references: references - }]; - function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || !ts.isThis(node)) { - return; - } - var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); - switch (searchSpaceNode.kind) { - case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 197 /* ClassExpression */: - case 226 /* ClassDeclaration */: - // Make sure the container belongs to the same class - // and has the appropriate static modifier from the original container. - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 261 /* SourceFile */: - if (container.kind === 261 /* SourceFile */ && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); - } - } - function getReferencesForStringLiteral(node, sourceFiles) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (!type) { - // nothing to do here. moving on - return undefined; - } - var references = []; - for (var _i = 0, sourceFiles_9 = sourceFiles; _i < sourceFiles_9.length; _i++) { - var sourceFile = sourceFiles_9[_i]; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd()); - getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); - } - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: type.text, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] - }, - references: references - }]; - function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { - for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { - var position = possiblePositions_1[_i]; - cancellationToken.throwIfCancellationRequested(); - var node_2 = ts.getTouchingWord(sourceFile, position); - if (!node_2 || node_2.kind !== 9 /* StringLiteral */) { - return; - } - var type_1 = ts.getStringLiteralTypeForNode(node_2, typeChecker); - if (type_1 === searchType) { - references.push(getReferenceEntryFromNode(node_2)); - } } + var result = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap(), typeChecker); + return ts.find(result, function (symbol) { return ts.contains(searchSymbols, symbol); }); } - } - function populateSearchSymbolSet(symbol, location) { - // The search set contains at least the current symbol - var result = [symbol]; - // If the location is name of property symbol from object literal destructuring pattern - // Search the property symbol - // for ( { property: p2 } of elems) { } - var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 258 /* ShorthandPropertyAssignment */) { - var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); - if (propertySymbol) { - result.push(propertySymbol); - } - } - // If the symbol is an alias, add what it aliases to the list - // import {a} from "mod"; - // export {a} - // If the symbol is an alias to default declaration, add what it aliases to the list - // declare "mod" { export default class B { } } - // import B from "mod"; - //// For export specifiers, the exported name can be referring to a local symbol, e.g.: - //// import {a} from "mod"; - //// export {a as somethingElse} - //// We want the *local* declaration of 'a' as declared in the import, - //// *not* as declared within "mod" (or farther) - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(symbol, location); - if (aliasSymbol) { - result = result.concat(populateSearchSymbolSet(aliasSymbol, location)); - } - // 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 (containingObjectLiteralElement) { - ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), 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 - * const name = "Foo"; - * const 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 the symbol.valueDeclaration is a property parameter declaration, - // we should include both parameter declaration symbol and property declaration symbol - // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. - // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 144 /* Parameter */ && - ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { - result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); - } - // If this is symbol of binding element without propertyName declaration in Object binding pattern - // Include the property in the search - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol); - if (bindingElementPropertySymbol) { - result.push(bindingElementPropertySymbol); - } - // 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 (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap()); - } - }); - return result; - } - /** - * Find symbol of the given property-name and add the symbol to the given result array - * @param symbol a symbol to start searching for the given propertyName - * @param propertyName a name of property to search for - * @param result an array of symbol of found property symbols - * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. - * The value of previousIterationSymbol is undefined when the function is first called. - */ - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache) { - if (!symbol) { - return; - } - // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited - // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. - // For example: - // interface C extends C { - // /*findRef*/propName: string; - // } - // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, - // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, - // the function will add any found symbol of the property-name, then its sub-routine will call - // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already - // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. - if (symbol.name in previousIterationSymbolsCache) { - return; - } - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === 227 /* 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.apply(result, typeChecker.getRootSymbols(propertySymbol)); - } - // Visit the typeReference as well to see if it directly or indirectly use that property - previousIterationSymbolsCache[symbol.name] = symbol; - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache); - } - } - } - } - function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache) { - if (ts.contains(searchSymbols, referenceSymbol)) { - // If we are searching for constructor uses, they must be 'new' expressions. - return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) && referenceSymbol; - } - // If the reference symbol is an alias, check if what it is aliasing is one of the search - // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation); - if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache); - } - // 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 - var containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation); - if (containingObjectLiteralElement) { - var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), function (contextualSymbol) { - return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - }); - if (contextualSymbol) { - return contextualSymbol; - } - // If the reference location is the name of property from object literal destructuring pattern - // Get the property symbol from the object literal's type and look if thats the search symbol - // In below eg. get 'property' from type of elems iterating type - // for ( { property: p2 } of elems) { } - var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation); - if (propertySymbol && searchSymbols.indexOf(propertySymbol) >= 0) { - return propertySymbol; - } - } - // If the reference location is the binding element and doesn't have property name - // then include the binding element in the related symbols - // let { a } : { a }; - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol); - if (bindingElementPropertySymbol && searchSymbols.indexOf(bindingElementPropertySymbol) >= 0) { - return bindingElementPropertySymbol; - } - // 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 we were passed a parent symbol, only include types that are subtypes of the - // parent symbol - if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - // Parents will only be defined if implementations is true - if (parents) { - if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache); })) { - return undefined; - } - } - var result_4 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_4, /*previousIterationSymbolsCache*/ ts.createMap()); - return ts.forEach(result_4, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - } - return undefined; - }); - } - function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 142 /* ComputedPropertyName */) { - var nameExpression = node.name.expression; - // treat computed property names where expression is string/numeric literal as just string/numeric literal - if (ts.isStringOrNumericLiteral(nameExpression)) { - return nameExpression.text; - } - return undefined; - } - return node.name.text; - } - function getPropertySymbolsFromContextualType(node) { - var objectLiteral = node.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - var name = getNameFromObjectLiteralElement(node); - if (name && contextualType) { - var result_5 = []; - var symbol_2 = contextualType.getProperty(name); - if (symbol_2) { - result_5.push(symbol_2); - } - if (contextualType.flags & 65536 /* Union */) { - ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name); - if (symbol) { - result_5.push(symbol); - } - }); - } - return result_5; + return undefined; + }); + } + function getNameFromObjectLiteralElement(node) { + if (node.name.kind === 143 /* ComputedPropertyName */) { + var nameExpression = node.name.expression; + // treat computed property names where expression is string/numeric literal as just string/numeric literal + if (ts.isStringOrNumericLiteral(nameExpression)) { + return nameExpression.text; } 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 = void 0; - 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, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; - var declarationMeaning = ts.getMeaningFromDeclaration(declaration); - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; - } - } - } while (meaning !== lastIterationMeaning); + return node.name.text; + } + /** Gets all symbols for one property. Does not get symbols for every property. */ + function getPropertySymbolsFromContextualType(node, typeChecker) { + var objectLiteral = node.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name = getNameFromObjectLiteralElement(node); + if (name && contextualType) { + var result_4 = []; + var symbol = contextualType.getProperty(name); + if (symbol) { + result_4.push(symbol); } - return meaning; + if (contextualType.flags & 65536 /* Union */) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_4.push(symbol); + } + }); + } + return result_4; } + return undefined; } - FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; - function convertReferences(referenceSymbols) { - if (!referenceSymbols) { - 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 = void 0; + 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, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; + var declarationMeaning = ts.getMeaningFromDeclaration(declaration); + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; + } + } + } while (meaning !== lastIterationMeaning); } - var referenceEntries = []; - for (var _i = 0, referenceSymbols_1 = referenceSymbols; _i < referenceSymbols_1.length; _i++) { - var referenceSymbol = referenceSymbols_1[_i]; - ts.addRange(referenceEntries, referenceSymbol.references); - } - return referenceEntries; + return meaning; } - FindAllReferences.convertReferences = convertReferences; function isImplementation(node) { if (!node) { return false; @@ -70593,7 +72875,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 223 /* VariableDeclaration */) { + else if (node.kind === 225 /* VariableDeclaration */) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); } @@ -70603,18 +72885,18 @@ var ts; } else { switch (node.kind) { - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 231 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 205 /* VariableStatement */) { - ts.Debug.assert(node.parent.kind === 224 /* VariableDeclarationList */); + if (node.parent && node.parent.parent && node.parent.parent.kind === 207 /* VariableStatement */) { + ts.Debug.assert(node.parent.kind === 226 /* VariableDeclarationList */); return node.parent.parent; } } @@ -70653,10 +72935,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 191 /* PostfixUnaryExpression */ || parent.kind === 190 /* PrefixUnaryExpression */) { + if (parent.kind === 192 /* PostfixUnaryExpression */ || parent.kind === 191 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 192 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 193 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; return 57 /* FirstAssignment */ <= operator && operator <= 69 /* LastAssignment */; } @@ -70671,33 +72953,6 @@ var ts; forEachDescendantOfKind(child, kind, action); }); } - /** - * Returns the containing object literal property declaration given a possible name node, e.g. "a" in x = { "a": 1 } - */ - function getContainingObjectLiteralElement(node) { - switch (node.kind) { - case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - if (node.parent.kind === 142 /* ComputedPropertyName */) { - return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; - } - // intential fall through - case 70 /* Identifier */: - return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; - } - return undefined; - } - function isObjectLiteralPropertyDeclaration(node) { - switch (node.kind) { - case 257 /* PropertyAssignment */: - case 258 /* ShorthandPropertyAssignment */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - return true; - } - return false; - } /** Get `C` given `N` if `N` is in the position `class C extends N` or `class C extends foo.N` where `N` is an identifier. */ function tryGetClassByExtendingIdentifier(node) { return ts.tryGetClassExtendingExpressionWithTypeArguments(ts.climbPastPropertyAccess(node).parent); @@ -70708,6 +72963,9 @@ var ts; } return false; } + function isImportDefaultSymbol(symbol) { + return symbol.declarations[0].kind === 238 /* ImportClause */; + } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); /* @internal */ @@ -70728,11 +72986,9 @@ var ts; // Type reference directives var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { - var referenceFile = program.getResolvedTypeReferenceDirectives()[typeReferenceDirective.fileName]; - if (referenceFile && referenceFile.resolvedFileName) { - return [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; - } - return undefined; + var referenceFile = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); + return referenceFile && referenceFile.resolvedFileName && + [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; } var node = ts.getTouchingPropertyName(sourceFile, position); if (node === sourceFile) { @@ -70742,7 +72998,7 @@ var ts; if (ts.isJumpStatementTarget(node)) { var labelName = node.text; var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ts.ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; + return label ? [createDefinitionInfoFromName(label, ts.ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; } var typeChecker = program.getTypeChecker(); var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); @@ -70768,7 +73024,7 @@ var ts; // if (node.kind === 70 /* Identifier */ && (node.parent === declaration || - (declaration.kind === 239 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 238 /* NamedImports */))) { + (declaration.kind === 241 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 240 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -70777,7 +73033,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 === 258 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 261 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -70788,6 +73044,37 @@ var ts; var shorthandContainerName_1 = typeChecker.symbolToString(symbol.parent, node); return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind_1, shorthandSymbolName_1, shorthandContainerName_1); }); } + if (ts.isJsxOpeningLikeElement(node.parent)) { + // If there are errors when trying to figure out stateless component function, just return the first declaration + // For example: + // declare function /*firstSource*/MainButton(buttonProps: ButtonProps): JSX.Element; + // declare function /*secondSource*/MainButton(linkProps: LinkProps): JSX.Element; + // declare function /*thirdSource*/MainButton(props: ButtonProps | LinkProps): JSX.Element; + // let opt =
; // Error - We get undefined for resolved signature indicating an error, then just return the first declaration + var _a = getSymbolInfo(typeChecker, symbol, node), symbolName = _a.symbolName, symbolKind = _a.symbolKind, containerName = _a.containerName; + return [createDefinitionInfo(symbol.valueDeclaration, symbolKind, symbolName, containerName)]; + } + // If the current location we want to find its definition 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 for goto-definition. + // For example + // interface Props{ + // /*first*/prop1: number + // prop2: boolean + // } + // function Foo(arg: Props) {} + // Foo( { pr/*1*/op1: 10, prop2: true }) + var element = ts.getContainingObjectLiteralElement(node); + if (element) { + if (typeChecker.getContextualType(element.parent)) { + var result = []; + var propertySymbols = ts.getPropertySymbolsFromContextualType(typeChecker, element); + for (var _i = 0, propertySymbols_1 = propertySymbols; _i < propertySymbols_1.length; _i++) { + var propertySymbol = propertySymbols_1[_i]; + result.push.apply(result, getDefinitionFromSymbol(typeChecker, propertySymbol, node)); + } + return result; + } + } return getDefinitionFromSymbol(typeChecker, symbol, node); } GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; @@ -70806,13 +73093,13 @@ var ts; return undefined; } if (type.flags & 65536 /* Union */ && !(type.flags & 16 /* Enum */)) { - var result_6 = []; + var result_5 = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(/*to*/ result_6, /*from*/ getDefinitionFromSymbol(typeChecker, t.symbol, node)); + ts.addRange(/*to*/ result_5, /*from*/ getDefinitionFromSymbol(typeChecker, t.symbol, node)); } }); - return result_6; + return result_5; } if (!type.symbol) { return undefined; @@ -70859,29 +73146,42 @@ var ts; function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { var declarations = []; var definition; - ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 150 /* Constructor */) || - (!selectConstructors && (d.kind === 225 /* FunctionDeclaration */ || d.kind === 149 /* MethodDeclaration */ || d.kind === 148 /* MethodSignature */))) { + for (var _i = 0, signatureDeclarations_1 = signatureDeclarations; _i < signatureDeclarations_1.length; _i++) { + var d = signatureDeclarations_1[_i]; + if (selectConstructors ? d.kind === 151 /* Constructor */ : isSignatureDeclaration(d)) { 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)); + if (declarations.length) { + result.push(createDefinitionInfo(definition || ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); return true; } return false; } } + function isSignatureDeclaration(node) { + switch (node.kind) { + case 151 /* Constructor */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + return true; + default: + return false; + } + } + /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */ function createDefinitionInfo(node, symbolKind, symbolName, containerName) { + return createDefinitionInfoFromName(node.name || node, symbolKind, symbolName, containerName); + } + /** Creates a DefinitionInfo directly from the name of a declaration. */ + function createDefinitionInfoFromName(name, symbolKind, symbolName, containerName) { + var sourceFile = name.getSourceFile(); return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), + fileName: sourceFile.fileName, + textSpan: ts.createTextSpanFromNode(name, sourceFile), kind: symbolKind, name: symbolName, containerKind: undefined, @@ -70929,7 +73229,15 @@ var ts; } function tryGetSignatureDeclaration(typeChecker, node) { var callLike = getAncestorCallLikeExpression(node); - return callLike && typeChecker.getResolvedSignature(callLike).declaration; + var signature = callLike && typeChecker.getResolvedSignature(callLike); + if (signature) { + var decl = signature.declaration; + if (decl && isSignatureDeclaration(decl)) { + return decl; + } + } + // Don't go to a function type, go to the value having that type. + return undefined; } })(GoToDefinition = ts.GoToDefinition || (ts.GoToDefinition = {})); })(ts || (ts = {})); @@ -70941,7 +73249,7 @@ var ts; function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 258 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 261 /* ShorthandPropertyAssignment */) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -70954,7 +73262,7 @@ var ts; } else { // Perform "Find all References" and retrieve only those that are implementations - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, /*findInStrings*/ false, /*findInComments*/ false, /*implementations*/ true); + var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/ false, /*implementations*/ true); var result = ts.flatMap(referencedSymbols, function (symbol) { return ts.map(symbol.references, function (_a) { var textSpan = _a.textSpan, fileName = _a.fileName; @@ -71048,7 +73356,7 @@ var ts; */ function forEachUnique(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (ts.indexOf(array, array[i]) === i) { var result = callback(array[i], i); if (result) { @@ -71108,19 +73416,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 225 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 150 /* Constructor */: - case 226 /* ClassDeclaration */: - case 205 /* VariableStatement */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 151 /* Constructor */: + case 228 /* ClassDeclaration */: + case 207 /* VariableStatement */: break findOwner; - case 261 /* SourceFile */: + case 264 /* SourceFile */: return undefined; - case 230 /* ModuleDeclaration */: + case 232 /* 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 === 230 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 232 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -71135,7 +73443,7 @@ var ts; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; - for (var i = 0, numParams = parameters.length; i < numParams; i++) { + for (var i = 0; i < parameters.length; i++) { var currentName = parameters[i].name; var paramName = currentName.kind === 70 /* Identifier */ ? currentName.text : @@ -71167,7 +73475,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 205 /* VariableStatement */) { + if (commentOwner.kind === 207 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -71185,17 +73493,17 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 183 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 184 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return rightHandSide.parameters; - case 197 /* ClassExpression */: + case 198 /* ClassExpression */: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150 /* Constructor */) { + if (member.kind === 151 /* Constructor */) { return member.parameters; } } @@ -71253,7 +73561,7 @@ var ts; }); if (!safeList) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); - safeList = result.config ? ts.createMap(result.config) : EmptySafeList; + safeList = result.config ? ts.createMapFromTemplate(result.config) : EmptySafeList; } var filesToWatch = []; // Directories to search for package.json, bower.json and other typing information @@ -71280,33 +73588,33 @@ var ts; if (unresolvedImports) { for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { var moduleId = unresolvedImports_1[_a]; - var typingName = moduleId in nodeCoreModules ? "node" : moduleId; - if (!(typingName in inferredTypings)) { - inferredTypings[typingName] = undefined; + var typingName = nodeCoreModules.has(moduleId) ? "node" : moduleId; + if (!inferredTypings.has(typingName)) { + inferredTypings.set(typingName, undefined); } } } // Add the cached typing locations for inferred typings that are already installed - for (var name_46 in packageNameToTypingLocation) { - if (name_46 in inferredTypings && !inferredTypings[name_46]) { - inferredTypings[name_46] = packageNameToTypingLocation[name_46]; + packageNameToTypingLocation.forEach(function (typingLocation, name) { + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined) { + inferredTypings.set(name, typingLocation); } - } + }); // Remove typings that the user has added to the exclude list for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { var excludeTypingName = exclude_1[_b]; - delete inferredTypings[excludeTypingName]; + inferredTypings.delete(excludeTypingName); } var newTypingNames = []; var cachedTypingPaths = []; - for (var typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); + inferredTypings.forEach(function (inferred, typing) { + if (inferred !== undefined) { + cachedTypingPaths.push(inferred); } else { newTypingNames.push(typing); } - } + }); return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; /** * Merge a given list of typingNames to the inferredTypings map @@ -71317,8 +73625,8 @@ var ts; } for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { var typing = typingNames_1[_i]; - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; + if (!inferredTypings.has(typing)) { + inferredTypings.set(typing, undefined); } } } @@ -71357,7 +73665,7 @@ var ts; var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); if (safeList !== EmptySafeList) { - mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); + mergeTypings(ts.filter(cleanedTypingNames, function (f) { return safeList.has(f); })); } var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2 /* JSX */; }); if (hasJsxFile) { @@ -71400,7 +73708,7 @@ var ts; } if (packageJson.typings) { var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; + inferredTypings.set(packageJson.name, absolutePath); } else { typingNames.push(packageJson.name); @@ -71420,47 +73728,49 @@ var ts; function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; - // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] - ts.forEach(sourceFiles, function (sourceFile) { + var _loop_4 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) { - return; + return "continue"; } - var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_47 in nameToDeclarations) { - var declarations = nameToDeclarations[name_47]; + ts.forEachEntry(sourceFile.getNamedDeclarations(), function (declarations, name) { 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_47); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); if (!matches) { - continue; + return; // continue to next named declarations } - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { + var declaration = declarations_12[_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; + return true; // Break out of named declarations and go to the next source file. } - matches = patternMatcher.getMatches(containers, name_47); + matches = patternMatcher.getMatches(containers, name); if (!matches) { - continue; + return; // continue to next named declarations } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_47, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } - } - }); + }); + }; + // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] + for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { + var sourceFile = sourceFiles_8[_i]; + _loop_4(sourceFile); + } // Remove imports when the imported declaration is already in the list and has the same name. rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 236 /* ImportClause */ || decl.kind === 239 /* ImportSpecifier */ || decl.kind === 234 /* ImportEqualsDeclaration */) { + if (decl.kind === 238 /* ImportClause */ || decl.kind === 241 /* ImportSpecifier */ || decl.kind === 236 /* ImportEqualsDeclaration */) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -71502,7 +73812,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 142 /* ComputedPropertyName */) { + else if (declaration.name.kind === 143 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ true); } else { @@ -71523,7 +73833,7 @@ var ts; } return true; } - if (expression.kind === 177 /* PropertyAccessExpression */) { + if (expression.kind === 178 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -71536,7 +73846,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 === 142 /* ComputedPropertyName */) { + if (declaration.name.kind === 143 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } @@ -71582,7 +73892,7 @@ var ts; matchKind: ts.PatternMatchKind[rawItem.matchKind], isCaseSensitive: rawItem.isCaseSensitive, fileName: rawItem.fileName, - textSpan: ts.createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), + textSpan: ts.createTextSpanFromNode(declaration), // 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) : "" @@ -71689,7 +73999,7 @@ var ts; return; } switch (node.kind) { - case 150 /* Constructor */: + case 151 /* Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -71701,21 +74011,21 @@ var ts; } } break; - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 148 /* MethodSignature */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 149 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 236 /* ImportClause */: + case 238 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -71727,7 +74037,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 237 /* NamespaceImport */) { + if (namedBindings.kind === 239 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -71738,12 +74048,12 @@ var ts; } } break; - case 174 /* BindingElement */: - case 223 /* VariableDeclaration */: + case 175 /* BindingElement */: + case 225 /* VariableDeclaration */: var decl = node; - var name_48 = decl.name; - if (ts.isBindingPattern(name_48)) { - addChildrenRecursively(name_48); + var name = decl.name; + if (ts.isBindingPattern(name)) { + addChildrenRecursively(name); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { // For `const x = function() {}`, just use the function node, not the const. @@ -71753,12 +74063,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; - case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -71768,9 +74078,9 @@ var ts; } endNode(); break; - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -71778,21 +74088,21 @@ var ts; } endNode(); break; - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 243 /* ExportSpecifier */: - case 234 /* ImportEqualsDeclaration */: - case 155 /* IndexSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 228 /* TypeAliasDeclaration */: + case 245 /* ExportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 156 /* IndexSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 230 /* TypeAliasDeclaration */: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 285 /* JSDocTypedefTag */) { + if (tag.kind === 289 /* JSDocTypedefTag */) { addLeafNode(tag); } }); @@ -71810,9 +74120,9 @@ var ts; // Anonymous items are never merged. return true; } - var itemsWithSameName = nameToItems[name]; + var itemsWithSameName = nameToItems.get(name); if (!itemsWithSameName) { - nameToItems[name] = child; + nameToItems.set(name, child); return true; } if (itemsWithSameName instanceof Array) { @@ -71830,7 +74140,7 @@ var ts; if (tryMerge(itemWithSameName, child)) { return false; } - nameToItems[name] = [itemWithSameName, child]; + nameToItems.set(name, [itemWithSameName, child]); return true; } function tryMerge(a, b) { @@ -71843,14 +74153,14 @@ var ts; }); /** a and b have the same name, but they may not be mergeable. */ function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 230 /* ModuleDeclaration */ || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 232 /* ModuleDeclaration */ || areSameModule(a, b)); // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 230 /* ModuleDeclaration */) { + if (a.body.kind !== 232 /* ModuleDeclaration */) { return true; } return areSameModule(a.body, b.body); @@ -71878,39 +74188,20 @@ var ts; function compareChildren(child1, child2) { var name1 = tryGetName(child1.node), name2 = tryGetName(child2.node); if (name1 && name2) { - var cmp = localeCompareFix(name1, name2); + var cmp = ts.compareStringsCaseInsensitive(name1, name2); return cmp !== 0 ? cmp : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } else { return name1 ? 1 : name2 ? -1 : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } } - // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". - var localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; - var localeCompareFix = localeCompareIsCorrect ? ts.collator.compare : function (a, b) { - // This isn't perfect, but it passes all of our tests. - for (var i = 0; i < Math.min(a.length, b.length); i++) { - var chA = a.charAt(i), chB = b.charAt(i); - if (chA === "\"" && chB === "'") { - return 1; - } - if (chA === "'" && chB === "\"") { - return -1; - } - var cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); - if (cmp !== 0) { - return cmp; - } - } - return a.length - b.length; - }; /** * This differs from getItemName because this is just used for sorting. * We only sort nodes by name that have a more-or-less "direct" name, as opposed to `new()` and the like. * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 230 /* ModuleDeclaration */) { + if (node.kind === 232 /* ModuleDeclaration */) { return getModuleName(node); } var decl = node; @@ -71918,18 +74209,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 197 /* ClassExpression */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 198 /* ClassExpression */: return getFunctionOrClassName(node); - case 285 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 230 /* ModuleDeclaration */) { + if (node.kind === 232 /* ModuleDeclaration */) { return getModuleName(node); } var name = node.name; @@ -71940,16 +74231,16 @@ var ts; } } switch (node.kind) { - case 261 /* SourceFile */: + case 264 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -71957,15 +74248,15 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 150 /* Constructor */: + case 151 /* Constructor */: return "constructor"; - case 154 /* ConstructSignature */: + case 155 /* ConstructSignature */: return "new()"; - case 153 /* CallSignature */: + case 154 /* CallSignature */: return "()"; - case 155 /* IndexSignature */: + case 156 /* IndexSignature */: return "[]"; - case 285 /* JSDocTypedefTag */: + case 289 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return ""; @@ -71977,7 +74268,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 205 /* VariableStatement */) { + if (parentNode && parentNode.kind === 207 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -72006,24 +74297,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 229 /* EnumDeclaration */: - case 227 /* InterfaceDeclaration */: - case 230 /* ModuleDeclaration */: - case 261 /* SourceFile */: - case 228 /* TypeAliasDeclaration */: - case 285 /* JSDocTypedefTag */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 231 /* EnumDeclaration */: + case 229 /* InterfaceDeclaration */: + case 232 /* ModuleDeclaration */: + case 264 /* SourceFile */: + case 230 /* TypeAliasDeclaration */: + case 289 /* JSDocTypedefTag */: return true; - case 150 /* Constructor */: - case 149 /* MethodDeclaration */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 223 /* VariableDeclaration */: + case 151 /* Constructor */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 225 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 185 /* ArrowFunction */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -72033,10 +74324,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 231 /* ModuleBlock */: - case 261 /* SourceFile */: - case 149 /* MethodDeclaration */: - case 150 /* Constructor */: + case 233 /* ModuleBlock */: + case 264 /* SourceFile */: + case 150 /* MethodDeclaration */: + case 151 /* Constructor */: return true; default: return hasSomeImportantChild(item); @@ -72045,7 +74336,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 223 /* VariableDeclaration */ && childKind !== 174 /* BindingElement */; + return childKind !== 225 /* VariableDeclaration */ && childKind !== 175 /* BindingElement */; }); } } @@ -72056,7 +74347,7 @@ var ts; return { text: getItemName(n.node), kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: ts.map(n.children, convertToTree) }; @@ -72065,7 +74356,7 @@ var ts; return { text: getItemName(n.node), kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, indent: n.indent, @@ -72103,7 +74394,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 === 230 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 232 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -72114,28 +74405,34 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 230 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 232 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 142 /* ComputedPropertyName */; + return !member.name || member.name.kind === 143 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 261 /* SourceFile */ + return node.kind === 264 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) - : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); + : ts.createTextSpanFromNode(node, curSourceFile); + } + function getModifiers(node) { + if (node.parent && node.parent.kind === 225 /* VariableDeclaration */) { + node = node.parent; + } + return ts.getNodeModifiers(node); } function getFunctionOrClassName(node) { if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 223 /* VariableDeclaration */) { + else if (node.parent.kind === 225 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 192 /* BinaryExpression */ && + else if (node.parent.kind === 193 /* BinaryExpression */ && node.parent.operatorToken.kind === 57 /* EqualsToken */) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 257 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 260 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512 /* Default */) { @@ -72146,7 +74443,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 184 /* FunctionExpression */ || node.kind === 185 /* ArrowFunction */ || node.kind === 197 /* ClassExpression */; + return node.kind === 185 /* FunctionExpression */ || node.kind === 186 /* ArrowFunction */ || node.kind === 198 /* ClassExpression */; } /** * Matches all whitespace characters in a string. Eg: @@ -72176,7 +74473,7 @@ var ts; if (hintSpanNode && startElement && endElement) { var span_12 = { textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), - hintSpan: ts.createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), + hintSpan: ts.createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse }; @@ -72236,7 +74533,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 185 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 186 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -72248,30 +74545,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 204 /* Block */: + case 206 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_19 = n.parent; + var parent = n.parent; var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. - if (parent_19.kind === 209 /* DoStatement */ || - parent_19.kind === 212 /* ForInStatement */ || - parent_19.kind === 213 /* ForOfStatement */ || - parent_19.kind === 211 /* ForStatement */ || - parent_19.kind === 208 /* IfStatement */ || - parent_19.kind === 210 /* WhileStatement */ || - parent_19.kind === 217 /* WithStatement */ || - parent_19.kind === 256 /* CatchClause */) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + if (parent.kind === 211 /* DoStatement */ || + parent.kind === 214 /* ForInStatement */ || + parent.kind === 215 /* ForOfStatement */ || + parent.kind === 213 /* ForStatement */ || + parent.kind === 210 /* IfStatement */ || + parent.kind === 212 /* WhileStatement */ || + parent.kind === 219 /* WithStatement */ || + parent.kind === 259 /* CatchClause */) { + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_19.kind === 221 /* TryStatement */) { + if (parent.kind === 223 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_19; + var tryStatement = parent; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -72281,10 +74578,11 @@ var ts; break; } } + // fall through. } // 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_14 = ts.createTextSpanFromBounds(n.getStart(), n.end); + var span_14 = ts.createTextSpanFromNode(n); elements.push({ textSpan: span_14, hintSpan: span_14, @@ -72294,23 +74592,23 @@ var ts; break; } // Fallthrough. - case 231 /* ModuleBlock */: { + case 233 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 176 /* ObjectLiteralExpression */: - case 232 /* CaseBlock */: { + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 177 /* ObjectLiteralExpression */: + case 234 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 20 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -72406,10 +74704,11 @@ var ts; return totalMatch; } function getWordSpans(word) { - if (!(word in stringToWordSpans)) { - stringToWordSpans[word] = breakIntoWordSpans(word); + var spans = stringToWordSpans.get(word); + if (!spans) { + stringToWordSpans.set(word, spans = breakIntoWordSpans(word)); } - return stringToWordSpans[word]; + return spans; } function matchTextChunk(candidate, chunk, punctuationStripped) { var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); @@ -72690,7 +74989,8 @@ var ts; } // Assumes 'value' is already lowercase. function indexOfIgnoringCase(string, value) { - for (var i = 0, n = string.length - value.length; i <= n; i++) { + var n = string.length - value.length; + for (var i = 0; i <= n; i++) { if (startsWithIgnoringCase(string, value, i)) { return i; } @@ -72699,7 +74999,7 @@ var ts; } // Assumes 'value' is already lowercase. function startsWithIgnoringCase(string, value, start) { - for (var i = 0, n = value.length; i < n; i++) { + for (var i = 0; i < value.length; i++) { var ch1 = toLowerCase(string.charCodeAt(i + start)); var ch2 = value.charCodeAt(i); if (ch1 !== ch2) { @@ -72771,7 +75071,7 @@ var ts; function breakIntoSpans(identifier, word) { var result = []; var wordStart = 0; - for (var i = 1, n = identifier.length; i < n; i++) { + for (var i = 1; i < identifier.length; i++) { var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); var currentIsDigit = isDigit(identifier.charCodeAt(i)); var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); @@ -72983,7 +75283,7 @@ var ts; else { if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import d from "mod"; @@ -73014,7 +75314,7 @@ var ts; } if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; @@ -73030,7 +75330,7 @@ var ts; token = nextToken(); if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import * as NS from "mod" @@ -73060,7 +75360,7 @@ var ts; } if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; @@ -73072,7 +75372,7 @@ var ts; } else if (token === 38 /* AsteriskToken */) { token = nextToken(); - if (token === 138 /* FromKeyword */) { + if (token === 139 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export * from "mod" @@ -73224,93 +75524,85 @@ var ts; var Rename; (function (Rename) { function getRenameInfo(typeChecker, defaultLibFileName, getCanonicalFileName, sourceFile, position) { - var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); + var getCanonicalDefaultLibName = ts.memoize(function () { return getCanonicalFileName(ts.normalizePath(defaultLibFileName)); }); var node = ts.getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true); - if (node) { - if (node.kind === 70 /* Identifier */ || - node.kind === 9 /* StringLiteral */ || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - ts.isThis(node)) { - 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. - if (ts.forEach(declarations, isDefinedInLibraryFile)) { - 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 = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - if (kind) { - return { - canRename: true, - kind: kind, - displayName: displayName, - localizedErrorMessage: undefined, - fullDisplayName: typeChecker.getFullyQualifiedName(symbol), - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - else if (node.kind === 9 /* StringLiteral */) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (type) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } - else { - var displayName = ts.stripQuotes(type.text); - return { - canRename: true, - kind: ts.ScriptElementKind.variableElement, - displayName: displayName, - localizedErrorMessage: undefined, - fullDisplayName: displayName, - kindModifiers: ts.ScriptElementKindModifier.none, - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - } - } - 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 - }; - } + var renameInfo = node && nodeIsEligibleForRename(node) + ? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) + : undefined; + return renameInfo || getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); function isDefinedInLibraryFile(declaration) { - if (defaultLibFileName) { - var sourceFile_1 = declaration.getSourceFile(); - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_1.fileName)); - if (canonicalName === canonicalDefaultLibName) { - return true; - } + if (!defaultLibFileName) { + return false; } - return false; - } - function createTriggerSpanForNode(node, sourceFile) { - var start = node.getStart(sourceFile); - var width = node.getWidth(sourceFile); - if (node.kind === 9 /* StringLiteral */) { - // Exclude the quotes - start += 1; - width -= 2; - } - return ts.createTextSpan(start, width); + var sourceFile = declaration.getSourceFile(); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); + return canonicalName === getCanonicalDefaultLibName(); } } Rename.getRenameInfo = getRenameInfo; + function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) { + 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. + if (ts.some(declarations, isDefinedInLibraryFile)) { + return getRenameInfoError(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 = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); + return kind ? getRenameInfoSuccess(displayName, typeChecker.getFullyQualifiedName(symbol), kind, ts.SymbolDisplay.getSymbolModifiers(symbol), node, sourceFile) : undefined; + } + } + else if (node.kind === 9 /* StringLiteral */) { + var type = ts.getStringLiteralTypeForNode(node, typeChecker); + if (type) { + if (isDefinedInLibraryFile(node)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); + } + var displayName = ts.stripQuotes(type.text); + return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); + } + } + } + function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { + return { + canRename: true, + kind: kind, + displayName: displayName, + localizedErrorMessage: undefined, + fullDisplayName: fullDisplayName, + kindModifiers: kindModifiers, + triggerSpan: createTriggerSpanForNode(node, sourceFile) + }; + } + function getRenameInfoError(diagnostic) { + return { + canRename: false, + localizedErrorMessage: ts.getLocaleSpecificMessage(diagnostic), + displayName: undefined, + fullDisplayName: undefined, + kind: undefined, + kindModifiers: undefined, + triggerSpan: undefined + }; + } + function createTriggerSpanForNode(node, sourceFile) { + var start = node.getStart(sourceFile); + var width = node.getWidth(sourceFile); + if (node.kind === 9 /* StringLiteral */) { + // Exclude the quotes + start += 1; + width -= 2; + } + return ts.createTextSpan(start, width); + } + function nodeIsEligibleForRename(node) { + return node.kind === 70 /* Identifier */ || node.kind === 9 /* StringLiteral */ || + ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + ts.isThis(node); + } })(Rename = ts.Rename || (ts.Rename = {})); })(ts || (ts = {})); /// @@ -73457,6 +75749,7 @@ var ts; ArgumentListKind[ArgumentListKind["TypeArguments"] = 0] = "TypeArguments"; ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; + ArgumentListKind[ArgumentListKind["JSXAttributesArguments"] = 3] = "JSXAttributesArguments"; })(ArgumentListKind = SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); @@ -73488,7 +75781,7 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 179 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 180 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. @@ -73496,7 +75789,7 @@ var ts; var expression = callExpression.expression; var name = expression.kind === 70 /* Identifier */ ? expression - : expression.kind === 177 /* PropertyAccessExpression */ + : expression.kind === 178 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -73506,10 +75799,10 @@ var ts; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var nameToDeclarations = sourceFile.getNamedDeclarations(); - var declarations = nameToDeclarations[name.text]; + var declarations = nameToDeclarations.get(name.text); if (declarations) { - for (var _b = 0, declarations_10 = declarations; _b < declarations_10.length; _b++) { - var declaration = declarations_10[_b]; + for (var _b = 0, declarations_13 = declarations; _b < declarations_13.length; _b++) { + var declaration = declarations_13[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -73529,21 +75822,21 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 179 /* CallExpression */ || node.parent.kind === 180 /* NewExpression */) { + if (node.parent.kind === 180 /* CallExpression */ || node.parent.kind === 181 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: - // 1. The token introduces a list, and should begin a sig help session + // 1. The token introduces a list, and should begin a signature help session // 2. The token is either not associated with a list, or ends a list, so the session should end - // 3. The token is buried inside a list, and should give sig help + // 3. The token is buried inside a list, and should give signature help // // The following are examples of each: // // Case 1: - // foo<#T, U>(#a, b) -> The token introduces a list, and should begin a sig help session + // foo<#T, U>(#a, b) -> The token introduces a list, and should begin a signature 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 + // foo(a#, #b#) -> The token is buried inside a list, and should give signature help // Find out if 'node' is an argument, a type argument, or neither if (node.kind === 26 /* LessThanToken */ || node.kind === 18 /* OpenParenToken */) { @@ -73562,7 +75855,7 @@ var ts; } // 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. + // - To the right of the closing parenthesis, 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 @@ -73583,25 +75876,25 @@ var ts; } return undefined; } - else if (node.kind === 12 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 181 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 182 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0, sourceFile); } } - else if (node.kind === 13 /* TemplateHead */ && node.parent.parent.kind === 181 /* TaggedTemplateExpression */) { + else if (node.kind === 13 /* TemplateHead */ && node.parent.parent.kind === 182 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 194 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 195 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 202 /* TemplateSpan */ && node.parent.parent.parent.kind === 181 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 204 /* TemplateSpan */ && node.parent.parent.parent.kind === 182 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 194 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 195 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 15 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -73610,8 +75903,25 @@ var ts; var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position); return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } + else if (node.parent && ts.isJsxOpeningLikeElement(node.parent)) { + // Provide a signature help for JSX opening element or JSX self-closing element. + // This is not guarantee that JSX tag-name is resolved into stateless function component. (that is done in "getSignatureHelpItems") + // i.e + // export function MainButton(props: ButtonProps, context: any): JSX.Element { ... } + // ' '' - // That will give us 2 non-commas. We then add one for the last comma, givin us an + // That will give us 2 non-commas. We then add one for the last comma, giving us an // arg count of 3. var listChildren = argumentsList.getChildren(); var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 25 /* CommaToken */; }); @@ -73719,7 +76029,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 === 194 /* TemplateExpression */) { + if (template.kind === 195 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -73728,7 +76038,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 261 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 264 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -73741,6 +76051,7 @@ var ts; if (argumentInfo) { return argumentInfo; } + // TODO: Handle generic call with incomplete syntax } return undefined; } @@ -73873,7 +76184,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 197 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 198 /* ClassExpression */) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ts.ScriptElementKind.enumElement; @@ -73930,7 +76241,7 @@ var ts; if (flags & 16384 /* Constructor */) return ts.ScriptElementKind.constructorImplementationElement; if (flags & 4 /* Property */) { - if (flags & 268435456 /* SyntheticProperty */) { + if (flags & 134217728 /* Transient */ && symbol.checkFlags & 2 /* 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(); @@ -73950,6 +76261,9 @@ var ts; } return unionPropertyKind; } + if (location.parent && ts.isJsxAttribute(location.parent)) { + return ts.ScriptElementKind.jsxAttribute; + } return ts.ScriptElementKind.memberVariableElement; } return ts.ScriptElementKind.unknown; @@ -73979,7 +76293,7 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 177 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 178 /* 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)) { @@ -73987,21 +76301,24 @@ var ts; } } // try get the call/construct signature from the type if it matches - var callExpression = void 0; - if (location.kind === 179 /* CallExpression */ || location.kind === 180 /* NewExpression */) { - callExpression = location; + var callExpressionLike = void 0; + if (location.kind === 180 /* CallExpression */ || location.kind === 181 /* NewExpression */) { + callExpressionLike = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { - callExpression = location.parent; + callExpressionLike = location.parent; } - if (callExpression) { + else if (location.parent && ts.isJsxOpeningLikeElement(location.parent) && ts.isFunctionLike(symbol.valueDeclaration)) { + callExpressionLike = location.parent; + } + if (callExpressionLike) { var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures); + signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); if (!signature && candidateSignatures.length) { // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 180 /* NewExpression */ || callExpression.expression.kind === 96 /* SuperKeyword */; + var useConstructSignatures = callExpressionLike.kind === 181 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 96 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -74028,6 +76345,7 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { + case ts.ScriptElementKind.jsxAttribute: case ts.ScriptElementKind.memberVariableElement: case ts.ScriptElementKind.variableElement: case ts.ScriptElementKind.constElement: @@ -74054,24 +76372,24 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 122 /* ConstructorKeyword */ && location.parent.kind === 150 /* Constructor */)) { + (location.kind === 122 /* ConstructorKeyword */ && location.parent.kind === 151 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 150 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 151 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 150 /* Constructor */) { + if (functionDeclaration.kind === 151 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 153 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 154 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -74080,7 +76398,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 197 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 198 /* 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 @@ -74103,7 +76421,7 @@ var ts; } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(136 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(137 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); @@ -74124,7 +76442,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 230 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 232 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 70 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 128 /* NamespaceKeyword */ : 127 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -74145,28 +76463,28 @@ var ts; } else { // Method/function type parameter - var declaration = ts.getDeclarationOfKind(symbol, 143 /* TypeParameter */); + var declaration = ts.getDeclarationOfKind(symbol, 144 /* TypeParameter */); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 154 /* ConstructSignature */) { + if (declaration.kind === 155 /* ConstructSignature */) { displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 153 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 154 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 228 /* TypeAliasDeclaration */) { + else if (declaration.kind === 230 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(136 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(137 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -74177,7 +76495,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 260 /* EnumMember */) { + if (declaration.kind === 263 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -74189,7 +76507,7 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 233 /* NamespaceExportDeclaration */) { + if (symbol.declarations[0].kind === 235 /* NamespaceExportDeclaration */) { displayParts.push(ts.keywordPart(83 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(128 /* NamespaceKeyword */)); @@ -74200,7 +76518,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 234 /* ImportEqualsDeclaration */) { + if (declaration.kind === 236 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -74236,6 +76554,7 @@ var ts; } // For properties, variables and local vars: show the type if (symbolKind === ts.ScriptElementKind.memberVariableElement || + symbolKind === ts.ScriptElementKind.jsxAttribute || symbolFlags & 3 /* Variable */ || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { @@ -74273,10 +76592,10 @@ var ts; // For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 261 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 264 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 192 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 193 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -74357,16 +76676,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 184 /* FunctionExpression */) { + if (declaration.kind === 185 /* FunctionExpression */) { return true; } - if (declaration.kind !== 223 /* VariableDeclaration */ && declaration.kind !== 225 /* FunctionDeclaration */) { + if (declaration.kind !== 225 /* VariableDeclaration */ && declaration.kind !== 227 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_20 = declaration.parent; !ts.isFunctionBlock(parent_20); parent_20 = parent_20.parent) { + for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent_20.kind === 261 /* SourceFile */ || parent_20.kind === 231 /* ModuleBlock */) { + if (parent.kind === 264 /* SourceFile */ || parent.kind === 233 /* ModuleBlock */) { return false; } } @@ -74419,7 +76738,7 @@ var ts; sourceFile.moduleName = transpileOptions.moduleName; } if (transpileOptions.renamedDependencies) { - sourceFile.renamedDependencies = ts.createMap(transpileOptions.renamedDependencies); + sourceFile.renamedDependencies = ts.createMapFromTemplate(transpileOptions.renamedDependencies); } var newLine = ts.getNewLineCharacter(options); // Output @@ -74474,10 +76793,10 @@ var ts; function fixupCompilerOptions(options, diagnostics) { // Lazily create this value to fix module loading errors. commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { - return typeof o.type === "object" && !ts.forEachProperty(o.type, function (v) { return typeof v !== "number"; }); + return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_3 = function (opt) { + var _loop_5 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -74488,7 +76807,7 @@ var ts; options[opt.name] = ts.parseCustomTypeOption(opt, value, diagnostics); } else { - if (!ts.forEachProperty(opt.type, function (v) { return v === value; })) { + if (!ts.forEachEntry(opt.type, function (v) { return v === value; })) { // Supplied value isn't a valid enum value. diagnostics.push(ts.createCompilerDiagnosticForInvalidCustomType(opt)); } @@ -74496,7 +76815,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_3(opt); + _loop_5(opt); } return options; } @@ -74604,10 +76923,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 250 /* JsxAttribute */: - case 248 /* JsxOpeningElement */: - case 249 /* JsxClosingElement */: - case 247 /* JsxSelfClosingElement */: + case 252 /* JsxAttribute */: + case 250 /* JsxOpeningElement */: + case 251 /* JsxClosingElement */: + case 249 /* JsxSelfClosingElement */: return node.kind === 70 /* Identifier */; } } @@ -75019,11 +77338,11 @@ var ts; this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Space after }. - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromRange(0 /* FirstToken */, 141 /* LastToken */, [19 /* CloseParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 81 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 105 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 21 /* CloseBracketToken */, 25 /* CommaToken */, 24 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([21 /* CloseBracketToken */, 25 /* CommaToken */, 24 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // No space for dot this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); @@ -75040,10 +77359,10 @@ var ts; this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 80 /* DoKeyword */, 101 /* TryKeyword */, 86 /* FinallyKeyword */, 81 /* ElseKeyword */]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8 /* Delete */)); this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenBraceToken */, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); // Insert new line after { and before } in multi-line contexts. this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); @@ -75073,6 +77392,7 @@ var ts; this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([109 /* LetKeyword */, 75 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95 /* ReturnKeyword */, 24 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); @@ -75083,18 +77403,19 @@ var ts; this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101 /* TryKeyword */, 86 /* FinallyKeyword */]), 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124 /* GetKeyword */, 133 /* SetKeyword */]), 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124 /* GetKeyword */, 134 /* SetKeyword */]), 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); // TypeScript-specific higher priority rules // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses + this.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([127 /* ModuleKeyword */, 131 /* RequireKeyword */]), 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 133 /* SetKeyword */, 114 /* StaticKeyword */, 136 /* TypeKeyword */, 138 /* FromKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 138 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 130 /* ReadonlyKeyword */, 134 /* SetKeyword */, 114 /* StaticKeyword */, 137 /* TypeKeyword */, 139 /* FromKeyword */, 126 /* KeyOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 139 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions @@ -75114,7 +77435,7 @@ var ts; // decorators this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 70 /* Identifier */, 83 /* ExportKeyword */, 78 /* DefaultKeyword */, 74 /* ClassKeyword */, 114 /* StaticKeyword */, 113 /* PublicKeyword */, 111 /* PrivateKeyword */, 112 /* ProtectedKeyword */, 124 /* GetKeyword */, 133 /* SetKeyword */, 20 /* OpenBracketToken */, 38 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 70 /* Identifier */, 83 /* ExportKeyword */, 78 /* DefaultKeyword */, 74 /* ClassKeyword */, 114 /* StaticKeyword */, 113 /* PublicKeyword */, 111 /* PrivateKeyword */, 112 /* ProtectedKeyword */, 124 /* GetKeyword */, 134 /* SetKeyword */, 20 /* OpenBracketToken */, 38 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115 /* YieldKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); @@ -75130,6 +77451,8 @@ var ts; this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* SlashToken */, 28 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57 /* EqualsToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57 /* EqualsToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + // No space before non-null assertion operator + this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50 /* ExclamationToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -75160,7 +77483,7 @@ var ts; this.SpaceBeforeJsxAttribute, this.SpaceBeforeSlashInJsxOpeningElement, this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement, this.NoSpaceBeforeEqualInJsxAttribute, this.NoSpaceAfterEqualInJsxAttribute, // TypeScript-specific rules - this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, + this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, this.SpaceBeforeArrow, this.SpaceAfterArrow, @@ -75175,6 +77498,7 @@ var ts; this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, + this.NoSpaceBeforeNonNullAssertionOperator ]; // These rules are lower in priority than user-configurable rules. this.LowPriorityCommonRules = [ @@ -75184,7 +77508,6 @@ var ts; this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, - this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; /// @@ -75242,9 +77565,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_49 in o) { - if (o[name_49] === rule) { - return name_49; + for (var name in o) { + if (o[name] === rule) { + return name; } } throw new Error("Unknown rule"); @@ -75253,42 +77576,44 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 211 /* ForStatement */; + return context.contextNode.kind === 213 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 192 /* BinaryExpression */: - case 193 /* ConditionalExpression */: - case 200 /* AsExpression */: - case 243 /* ExportSpecifier */: - case 239 /* ImportSpecifier */: - case 156 /* TypePredicate */: - case 164 /* UnionType */: - case 165 /* IntersectionType */: + case 193 /* BinaryExpression */: + case 194 /* ConditionalExpression */: + case 201 /* AsExpression */: + case 245 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: + case 157 /* TypePredicate */: + case 165 /* UnionType */: + case 166 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 174 /* BindingElement */: + case 175 /* BindingElement */: // equals in type X = ... - case 228 /* TypeAliasDeclaration */: + case 230 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 223 /* VariableDeclaration */: + case 225 /* VariableDeclaration */: // equal in p = 0; - case 144 /* Parameter */: - case 260 /* EnumMember */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 145 /* Parameter */: + case 263 /* EnumMember */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return context.currentTokenSpan.kind === 57 /* EqualsToken */ || context.nextTokenSpan.kind === 57 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: + // "in" keyword in [P in keyof T]: T[P] + case 144 /* TypeParameter */: return context.currentTokenSpan.kind === 91 /* InKeyword */ || context.nextTokenSpan.kind === 91 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 213 /* ForOfStatement */: - return context.currentTokenSpan.kind === 140 /* OfKeyword */ || context.nextTokenSpan.kind === 140 /* OfKeyword */; + case 215 /* ForOfStatement */: + return context.currentTokenSpan.kind === 141 /* OfKeyword */ || context.nextTokenSpan.kind === 141 /* OfKeyword */; } return false; }; @@ -75296,7 +77621,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 193 /* ConditionalExpression */; + return context.contextNode.kind === 194 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -75317,6 +77642,9 @@ var ts; //// * ) and { are on different lines. We only need to format if the block is multiline context. So in this case we format. return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; + Rules.IsBraceWrappedContext = function (context) { + return context.contextNode.kind === 173 /* ObjectBindingPattern */ || Rules.IsSingleLineBlockContext(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()); @@ -75340,97 +77668,103 @@ var ts; return true; } switch (node.kind) { - case 204 /* Block */: - case 232 /* CaseBlock */: - case 176 /* ObjectLiteralExpression */: - case 231 /* ModuleBlock */: + case 206 /* Block */: + case 234 /* CaseBlock */: + case 177 /* ObjectLiteralExpression */: + case 233 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 225 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 153 /* CallSignature */: - case 184 /* FunctionExpression */: - case 150 /* Constructor */: - case 185 /* ArrowFunction */: + case 154 /* CallSignature */: + case 185 /* FunctionExpression */: + case 151 /* Constructor */: + case 186 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 227 /* InterfaceDeclaration */: + case 229 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 225 /* FunctionDeclaration */ || context.contextNode.kind === 184 /* FunctionExpression */; + return context.contextNode.kind === 227 /* FunctionDeclaration */ || context.contextNode.kind === 185 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 161 /* TypeLiteral */: - case 230 /* ModuleDeclaration */: - case 241 /* ExportDeclaration */: - case 242 /* NamedExports */: - case 235 /* ImportDeclaration */: - case 238 /* NamedImports */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 162 /* TypeLiteral */: + case 232 /* ModuleDeclaration */: + case 243 /* ExportDeclaration */: + case 244 /* NamedExports */: + case 237 /* ImportDeclaration */: + case 240 /* NamedImports */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 226 /* ClassDeclaration */: - case 230 /* ModuleDeclaration */: - case 229 /* EnumDeclaration */: - case 204 /* Block */: - case 256 /* CatchClause */: - case 231 /* ModuleBlock */: - case 218 /* SwitchStatement */: + case 228 /* ClassDeclaration */: + case 232 /* ModuleDeclaration */: + case 231 /* EnumDeclaration */: + case 259 /* CatchClause */: + case 233 /* ModuleBlock */: + case 220 /* SwitchStatement */: return true; + case 206 /* Block */: { + var blockParent = context.currentTokenParent.parent; + if (blockParent.kind !== 186 /* ArrowFunction */ && + blockParent.kind !== 185 /* FunctionExpression */) { + return true; + } + } } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 208 /* IfStatement */: - case 218 /* SwitchStatement */: - case 211 /* ForStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 210 /* WhileStatement */: - case 221 /* TryStatement */: - case 209 /* DoStatement */: - case 217 /* WithStatement */: + case 210 /* IfStatement */: + case 220 /* SwitchStatement */: + case 213 /* ForStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 212 /* WhileStatement */: + case 223 /* TryStatement */: + case 211 /* DoStatement */: + case 219 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 256 /* CatchClause */: + case 259 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 176 /* ObjectLiteralExpression */; + return context.contextNode.kind === 177 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 179 /* CallExpression */; + return context.contextNode.kind === 180 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 180 /* NewExpression */; + return context.contextNode.kind === 181 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -75442,25 +77776,25 @@ var ts; return context.nextTokenSpan.kind !== 21 /* CloseBracketToken */; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 185 /* ArrowFunction */; + return context.contextNode.kind === 186 /* ArrowFunction */; }; Rules.IsNonJsxSameLineTokenContext = function (context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 246 /* JsxElement */; + return context.contextNode.kind !== 248 /* JsxElement */; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 252 /* JsxExpression */; + return context.contextNode.kind === 255 /* JsxExpression */; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 250 /* JsxAttribute */; + return context.nextTokenParent.kind === 252 /* JsxAttribute */; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 250 /* JsxAttribute */; + return context.contextNode.kind === 252 /* JsxAttribute */; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 247 /* JsxSelfClosingElement */; + return context.contextNode.kind === 249 /* JsxSelfClosingElement */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -75475,41 +77809,42 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 145 /* Decorator */; + return node.kind === 146 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 224 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 226 /* 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 === 230 /* ModuleDeclaration */; + return context.contextNode.kind === 232 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 161 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 162 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 26 /* LessThanToken */ && token.kind !== 28 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 157 /* TypeReference */: - case 182 /* TypeAssertionExpression */: - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 199 /* ExpressionWithTypeArguments */: + case 158 /* TypeReference */: + case 183 /* TypeAssertionExpression */: + case 230 /* TypeAliasDeclaration */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 200 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -75520,13 +77855,16 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 182 /* TypeAssertionExpression */; + return context.contextNode.kind === 183 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 104 /* VoidKeyword */ && context.currentTokenParent.kind === 188 /* VoidExpression */; + return context.currentTokenSpan.kind === 104 /* VoidKeyword */ && context.currentTokenParent.kind === 189 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 195 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 196 /* YieldExpression */ && context.contextNode.expression !== undefined; + }; + Rules.IsNonNullAssertionContext = function (context) { + return context.contextNode.kind === 202 /* NonNullExpression */; }; return Rules; }()); @@ -75550,7 +77888,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 140 /* LastToken */ + 1; + this.mapRowLength = 141 /* 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); @@ -75564,7 +77902,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - ts.Debug.assert(row <= 140 /* LastKeyword */ && column <= 140 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 141 /* LastKeyword */ && column <= 141 /* LastKeyword */, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -75745,7 +78083,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 140 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 141 /* LastToken */; token++) { result.push(token); } return result; @@ -75789,9 +78127,9 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(71 /* FirstKeyword */, 140 /* LastKeyword */); + TokenRange.Keywords = TokenRange.FromRange(71 /* FirstKeyword */, 141 /* LastKeyword */); TokenRange.BinaryOperators = TokenRange.FromRange(26 /* FirstBinaryOperator */, 69 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91 /* InKeyword */, 92 /* InstanceOfKeyword */, 140 /* OfKeyword */, 117 /* AsKeyword */, 125 /* IsKeyword */]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91 /* InKeyword */, 92 /* InstanceOfKeyword */, 141 /* OfKeyword */, 117 /* AsKeyword */, 125 /* IsKeyword */]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42 /* PlusPlusToken */, 43 /* MinusMinusToken */, 51 /* TildeToken */, 50 /* ExclamationToken */]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 70 /* Identifier */, 18 /* OpenParenToken */, 20 /* OpenBracketToken */, 16 /* OpenBraceToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); @@ -75799,7 +78137,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 19 /* CloseParenToken */, 21 /* CloseBracketToken */, 93 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([70 /* Identifier */, 132 /* NumberKeyword */, 134 /* StringKeyword */, 121 /* BooleanKeyword */, 135 /* SymbolKeyword */, 104 /* VoidKeyword */, 118 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([70 /* Identifier */, 132 /* NumberKeyword */, 135 /* StringKeyword */, 121 /* BooleanKeyword */, 136 /* SymbolKeyword */, 104 /* VoidKeyword */, 118 /* AnyKeyword */]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -75846,6 +78184,12 @@ var ts; }; RulesProvider.prototype.createActiveRules = function (options) { var rules = this.globalRules.HighPriorityCommonRules.slice(0); + if (options.insertSpaceAfterConstructor) { + rules.push(this.globalRules.SpaceAfterConstructor); + } + else { + rules.push(this.globalRules.NoSpaceAfterConstructor); + } if (options.insertSpaceAfterCommaDelimiter) { rules.push(this.globalRules.SpaceAfterComma); } @@ -75926,6 +78270,12 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); rules.push(this.globalRules.NoSpaceAfterBinaryOperator); } + if (options.insertSpaceBeforeFunctionParenthesis) { + rules.push(this.globalRules.SpaceBeforeOpenParenInFuncDecl); + } + else { + rules.push(this.globalRules.NoSpaceBeforeOpenParenInFuncDecl); + } if (options.placeOpenBraceOnNewLineForControlBlocks) { rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); } @@ -76058,17 +78408,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 226 /* ClassDeclaration */: - case 227 /* InterfaceDeclaration */: + case 228 /* ClassDeclaration */: + case 229 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 231 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 261 /* SourceFile */: - case 204 /* Block */: - case 231 /* ModuleBlock */: + return body && body.kind === 233 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 264 /* SourceFile */: + case 206 /* Block */: + case 233 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -76273,20 +78623,20 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 226 /* ClassDeclaration */: return 74 /* ClassKeyword */; - case 227 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; - case 225 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; - case 229 /* EnumDeclaration */: return 229 /* EnumDeclaration */; - case 151 /* GetAccessor */: return 124 /* GetKeyword */; - case 152 /* SetAccessor */: return 133 /* SetKeyword */; - case 149 /* MethodDeclaration */: + case 228 /* ClassDeclaration */: return 74 /* ClassKeyword */; + case 229 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; + case 227 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; + case 231 /* EnumDeclaration */: return 231 /* EnumDeclaration */; + case 152 /* GetAccessor */: return 124 /* GetKeyword */; + case 153 /* SetAccessor */: return 134 /* SetKeyword */; + case 150 /* MethodDeclaration */: if (node.asteriskToken) { return 38 /* AsteriskToken */; } /* fall-through */ - case 147 /* PropertyDeclaration */: - case 144 /* Parameter */: + case 148 /* PropertyDeclaration */: + case 145 /* Parameter */: return node.name.kind; } } @@ -76316,18 +78666,31 @@ var ts; // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent case 16 /* OpenBraceToken */: case 17 /* CloseBraceToken */: - case 20 /* OpenBracketToken */: - case 21 /* CloseBracketToken */: case 18 /* OpenParenToken */: case 19 /* CloseParenToken */: case 81 /* ElseKeyword */: case 105 /* WhileKeyword */: case 56 /* AtToken */: return indentation; - default: - // if token line equals to the line of containing node (this is a first token in the node) - use node indentation - return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; + case 40 /* SlashToken */: + case 28 /* GreaterThanToken */: { + if (container.kind === 250 /* JsxOpeningElement */ || + container.kind === 251 /* JsxClosingElement */ || + container.kind === 249 /* JsxSelfClosingElement */) { + return indentation; + } + break; + } + case 20 /* OpenBracketToken */: + case 21 /* CloseBracketToken */: { + if (container.kind !== 171 /* MappedType */) { + return indentation; + } + break; + } } + // 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 + getEffectiveDelta(delta, container) : indentation; }, getIndentation: function () { return indentation; }, getDelta: function (child) { return getEffectiveDelta(delta, child); }, @@ -76383,7 +78746,7 @@ var ts; if (tokenInfo.token.end > node.end) { break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); @@ -76417,7 +78780,7 @@ var ts; // stop when formatting scanner advances past the beginning of the child break; } - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, node); } if (!formattingScanner.isOnToken()) { return inheritedIndentation; @@ -76430,11 +78793,11 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 145 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 146 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 175 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 176 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -76457,11 +78820,11 @@ var ts; 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); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } else { // consume any tokens that precede the list as child elements of 'node' using its indentation scope - consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); } } } @@ -76479,7 +78842,7 @@ var ts; // 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); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } } } @@ -76686,7 +79049,7 @@ var ts; } // shift all parts on the delta size var delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; i++, startLine++) { + for (var i = startIndex; i < parts.length; i++, startLine++) { var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart @@ -76791,12 +79154,12 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 150 /* Constructor */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 185 /* ArrowFunction */: + case 151 /* Constructor */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 186 /* ArrowFunction */: if (node.typeParameters === list) { return 26 /* LessThanToken */; } @@ -76804,8 +79167,8 @@ var ts; return 18 /* OpenParenToken */; } break; - case 179 /* CallExpression */: - case 180 /* NewExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: if (node.typeArguments === list) { return 26 /* LessThanToken */; } @@ -76813,7 +79176,7 @@ var ts; return 18 /* OpenParenToken */; } break; - case 157 /* TypeReference */: + case 158 /* TypeReference */: if (node.typeArguments === list) { return 26 /* LessThanToken */; } @@ -76929,7 +79292,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 25 /* CommaToken */ && precedingToken.parent.kind !== 192 /* BinaryExpression */) { + if (precedingToken.kind === 25 /* CommaToken */ && precedingToken.parent.kind !== 193 /* 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 */) { @@ -77052,7 +79415,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.isStatementButNotDeclaration(current)) && - (parent.kind === 261 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 264 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -77085,7 +79448,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 208 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 210 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -77097,23 +79460,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 157 /* TypeReference */: + case 158 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 176 /* ObjectLiteralExpression */: + case 177 /* ObjectLiteralExpression */: return node.parent.properties; - case 175 /* ArrayLiteralExpression */: + case 176 /* ArrayLiteralExpression */: return node.parent.elements; - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: { + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -77124,8 +79487,8 @@ var ts; } break; } - case 180 /* NewExpression */: - case 179 /* CallExpression */: { + case 181 /* NewExpression */: + case 180 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -77155,8 +79518,8 @@ var ts; if (node.kind === 19 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 179 /* CallExpression */ || - node.parent.kind === 180 /* NewExpression */) && + if (node.parent && (node.parent.kind === 180 /* CallExpression */ || + node.parent.kind === 181 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -77174,10 +79537,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 177 /* PropertyAccessExpression */: - case 178 /* ElementAccessExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 178 /* PropertyAccessExpression */: + case 179 /* ElementAccessExpression */: node = node.expression; break; default: @@ -77241,48 +79604,49 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 207 /* ExpressionStatement */: - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 229 /* EnumDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 175 /* ArrayLiteralExpression */: - case 204 /* Block */: - case 231 /* ModuleBlock */: - case 176 /* ObjectLiteralExpression */: - case 161 /* TypeLiteral */: - case 163 /* TupleType */: - case 232 /* CaseBlock */: - case 254 /* DefaultClause */: - case 253 /* CaseClause */: - case 183 /* ParenthesizedExpression */: - case 177 /* PropertyAccessExpression */: - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 205 /* VariableStatement */: - case 223 /* VariableDeclaration */: - case 240 /* ExportAssignment */: - case 216 /* ReturnStatement */: - case 193 /* ConditionalExpression */: - case 173 /* ArrayBindingPattern */: - case 172 /* ObjectBindingPattern */: - case 248 /* JsxOpeningElement */: - case 247 /* JsxSelfClosingElement */: - case 252 /* JsxExpression */: - case 148 /* MethodSignature */: - case 153 /* CallSignature */: - case 154 /* ConstructSignature */: - case 144 /* Parameter */: - case 158 /* FunctionType */: - case 159 /* ConstructorType */: - case 166 /* ParenthesizedType */: - case 181 /* TaggedTemplateExpression */: - case 189 /* AwaitExpression */: - case 242 /* NamedExports */: - case 238 /* NamedImports */: - case 243 /* ExportSpecifier */: - case 239 /* ImportSpecifier */: + case 209 /* ExpressionStatement */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 231 /* EnumDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 176 /* ArrayLiteralExpression */: + case 206 /* Block */: + case 233 /* ModuleBlock */: + case 177 /* ObjectLiteralExpression */: + case 162 /* TypeLiteral */: + case 171 /* MappedType */: + case 164 /* TupleType */: + case 234 /* CaseBlock */: + case 257 /* DefaultClause */: + case 256 /* CaseClause */: + case 184 /* ParenthesizedExpression */: + case 178 /* PropertyAccessExpression */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 207 /* VariableStatement */: + case 225 /* VariableDeclaration */: + case 242 /* ExportAssignment */: + case 218 /* ReturnStatement */: + case 194 /* ConditionalExpression */: + case 174 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 250 /* JsxOpeningElement */: + case 249 /* JsxSelfClosingElement */: + case 255 /* JsxExpression */: + case 149 /* MethodSignature */: + case 154 /* CallSignature */: + case 155 /* ConstructSignature */: + case 145 /* Parameter */: + case 159 /* FunctionType */: + case 160 /* ConstructorType */: + case 167 /* ParenthesizedType */: + case 182 /* TaggedTemplateExpression */: + case 190 /* AwaitExpression */: + case 244 /* NamedExports */: + case 240 /* NamedImports */: + case 245 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: return true; } return false; @@ -77291,27 +79655,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 209 /* DoStatement */: - case 210 /* WhileStatement */: - case 212 /* ForInStatement */: - case 213 /* ForOfStatement */: - case 211 /* ForStatement */: - case 208 /* IfStatement */: - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 185 /* ArrowFunction */: - case 150 /* Constructor */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - return childKind !== 204 /* Block */; - case 241 /* ExportDeclaration */: - return childKind !== 242 /* NamedExports */; - case 235 /* ImportDeclaration */: - return childKind !== 236 /* ImportClause */ || - (child.namedBindings && child.namedBindings.kind !== 238 /* NamedImports */); - case 246 /* JsxElement */: - return childKind !== 249 /* JsxClosingElement */; + case 211 /* DoStatement */: + case 212 /* WhileStatement */: + case 214 /* ForInStatement */: + case 215 /* ForOfStatement */: + case 213 /* ForStatement */: + case 210 /* IfStatement */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 186 /* ArrowFunction */: + case 151 /* Constructor */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + return childKind !== 206 /* Block */; + case 243 /* ExportDeclaration */: + return childKind !== 244 /* NamedExports */; + case 237 /* ImportDeclaration */: + return childKind !== 238 /* ImportClause */ || + (child.namedBindings && child.namedBindings.kind !== 240 /* NamedImports */); + case 248 /* JsxElement */: + return childKind !== 251 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -77332,7 +79696,7 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var codeFixes = ts.createMap(); + var codeFixes = []; function registerCodeFix(action) { ts.forEach(action.errorCodes, function (error) { var fixes = codeFixes[error]; @@ -77367,25 +79731,128 @@ var ts; (function (ts) { var codefix; (function (codefix) { - function getOpenBraceEnd(constructor, sourceFile) { - // First token is the open curly, this is where we want to put the 'super' call. - return constructor.body.getFirstToken(sourceFile).getEnd(); - } codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 122 /* ConstructorKeyword */) { - return undefined; - } - var newPosition = getOpenBraceEnd(token.parent, sourceFile); - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] - }]; - } + errorCodes: [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code], + getCodeActions: getActionForClassLikeIncorrectImplementsInterface }); + function getActionForClassLikeIncorrectImplementsInterface(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + var classDecl = ts.getContainingClass(token); + if (!classDecl) { + return undefined; + } + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDecl); + var hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, 1 /* Number */); + var hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, 0 /* String */); + var result = []; + for (var _i = 0, implementedTypeNodes_2 = implementedTypeNodes; _i < implementedTypeNodes_2.length; _i++) { + var implementedTypeNode = implementedTypeNodes_2[_i]; + var implementedType = checker.getTypeFromTypeNode(implementedTypeNode); + // Note that this is ultimately derived from a map indexed by symbol names, + // so duplicates cannot occur. + var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); + var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); }); + var insertion = getMissingIndexSignatureInsertion(implementedType, 1 /* Number */, classDecl, hasNumericIndexSignature); + insertion += getMissingIndexSignatureInsertion(implementedType, 0 /* String */, classDecl, hasStringIndexSignature); + insertion += codefix.getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); + var message = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); + if (insertion) { + pushAction(result, insertion, message); + } + } + return result; + function getMissingIndexSignatureInsertion(type, kind, enclosingDeclaration, hasIndexSigOfKind) { + if (!hasIndexSigOfKind) { + var IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); + if (IndexInfoOfKind) { + var writer = ts.getSingleLineStringWriter(); + checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); + var result_6 = writer.string(); + ts.releaseStringWriter(writer); + return result_6; + } + } + return ""; + } + function pushAction(result, insertion, description) { + var newAction = { + description: description, + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }; + result.push(newAction); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1.code], + getCodeActions: getActionForClassLikeMissingAbstractMember + }); + function getActionForClassLikeMissingAbstractMember(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + // This is the identifier in the case of a class declaration + // or the class keyword token in the case of a class expression. + var token = ts.getTokenAtPosition(sourceFile, start); + var checker = context.program.getTypeChecker(); + if (ts.isClassLike(token.parent)) { + var classDecl = token.parent; + var startPos = classDecl.members.pos; + var classType = checker.getTypeAtLocation(classDecl); + var instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + // Note that this is ultimately derived from a map indexed by symbol names, + // so duplicates cannot occur. + var extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); + var abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); + var insertion = codefix.getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); + if (insertion.length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_inherited_abstract_class), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: insertion + }] + }] + }]; + } + } + return undefined; + } + function symbolPointsToNonPrivateAndAbstractMember(symbol) { + var decls = symbol.getDeclarations(); + ts.Debug.assert(!!(decls && decls.length > 0)); + var flags = ts.getModifierFlags(decls[0]); + return !(flags & 8 /* Private */) && !!(flags & 128 /* Abstract */); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { codefix.registerCodeFix({ errorCodes: [ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], getCodeActions: function (context) { @@ -77401,7 +79868,7 @@ var ts; } // figure out if the this access is actuall inside the supercall // i.e. super(this.a), since in that case we won't suggest a fix - if (superCall.expression && superCall.expression.kind == 179 /* CallExpression */) { + if (superCall.expression && superCall.expression.kind == 180 /* CallExpression */) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -77409,7 +79876,7 @@ var ts; } } } - var newPosition = getOpenBraceEnd(constructor, sourceFile); + var newPosition = ts.getOpenBraceEnd(constructor, sourceFile); var changes = [{ fileName: sourceFile.fileName, textChanges: [{ newText: superCall.getText(sourceFile), @@ -77425,7 +79892,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + if (n.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -77439,6 +79906,272 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 122 /* ConstructorKeyword */) { + return undefined; + } + var newPosition = ts.getOpenBraceEnd(token.parent, sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + var classDeclNode = ts.getContainingClass(token); + if (!(token.kind === 70 /* Identifier */ && ts.isClassLike(classDeclNode))) { + return undefined; + } + var heritageClauses = classDeclNode.heritageClauses; + if (!(heritageClauses && heritageClauses.length > 0)) { + return undefined; + } + var extendsToken = heritageClauses[0].getFirstToken(); + if (!(extendsToken && extendsToken.kind === 84 /* ExtendsKeyword */)) { + return undefined; + } + var changeStart = extendsToken.getStart(sourceFile); + var changeEnd = extendsToken.getEnd(); + var textChanges = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + // We replace existing keywords with commas. + for (var i = 1; i < heritageClauses.length; i++) { + var keywordToken = heritageClauses[i].getFirstToken(); + if (keywordToken) { + changeStart = keywordToken.getStart(sourceFile); + changeEnd = keywordToken.getEnd(); + textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + } + } + var result = [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Change_extends_to_implements), + changes: [{ + fileName: sourceFile.fileName, + textChanges: textChanges + }] + }]; + return result; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + var start = token.getStart(sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_this_to_unresolved_variable), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "this.", span: { start: start, length: 0 } }] }] + }]; + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ + ts.Diagnostics._0_is_declared_but_never_used.code, + ts.Diagnostics.Property_0_is_declared_but_never_used.code + ], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + // this handles var ["computed"] = 12; + if (token.kind === 20 /* OpenBracketToken */) { + token = ts.getTokenAtPosition(sourceFile, start + 1); + } + switch (token.kind) { + case 70 /* Identifier */: + switch (token.parent.kind) { + case 225 /* VariableDeclaration */: + switch (token.parent.parent.parent.kind) { + case 213 /* ForStatement */: + var forStatement = token.parent.parent.parent; + var forInitializer = forStatement.initializer; + if (forInitializer.declarations.length === 1) { + return createCodeFixToRemoveNode(forInitializer); + } + else { + return removeSingleItem(forInitializer.declarations, token); + } + case 215 /* ForOfStatement */: + var forOfStatement = token.parent.parent.parent; + if (forOfStatement.initializer.kind === 226 /* VariableDeclarationList */) { + var forOfInitializer = forOfStatement.initializer; + return createCodeFix("{}", forOfInitializer.declarations[0].getStart(), forOfInitializer.declarations[0].getWidth()); + } + break; + case 214 /* ForInStatement */: + // There is no valid fix in the case of: + // for .. in + return undefined; + case 259 /* CatchClause */: + var catchClause = token.parent.parent; + var parameter = catchClause.variableDeclaration.getChildren()[0]; + return createCodeFixToRemoveNode(parameter); + default: + var variableStatement = token.parent.parent.parent; + if (variableStatement.declarationList.declarations.length === 1) { + return createCodeFixToRemoveNode(variableStatement); + } + else { + var declarations = variableStatement.declarationList.declarations; + return removeSingleItem(declarations, token); + } + } + case 144 /* TypeParameter */: + var typeParameters = token.parent.parent.typeParameters; + if (typeParameters.length === 1) { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + } + else { + return removeSingleItem(typeParameters, token); + } + case 145 /* Parameter */: + var functionDeclaration = token.parent.parent; + if (functionDeclaration.parameters.length === 1) { + return createCodeFixToRemoveNode(token.parent); + } + else { + return removeSingleItem(functionDeclaration.parameters, token); + } + // handle case where 'import a = A;' + case 236 /* ImportEqualsDeclaration */: + var importEquals = findImportDeclaration(token); + return createCodeFixToRemoveNode(importEquals); + case 241 /* ImportSpecifier */: + var namedImports = token.parent.parent; + if (namedImports.elements.length === 1) { + // Only 1 import and it is unused. So the entire declaration should be removed. + var importSpec = findImportDeclaration(token); + return createCodeFixToRemoveNode(importSpec); + } + else { + return removeSingleItem(namedImports.elements, token); + } + // handle case where "import d, * as ns from './file'" + // or "'import {a, b as ns} from './file'" + case 238 /* ImportClause */: + var importClause = token.parent; + if (!importClause.namedBindings) { + var importDecl = findImportDeclaration(importClause); + return createCodeFixToRemoveNode(importDecl); + } + else { + // import |d,| * as ns from './file' + var start_4 = importClause.name.getStart(); + var end = findFirstNonSpaceCharPosStarting(importClause.name.end); + if (sourceFile.text.charCodeAt(end) === 44 /* comma */) { + end = findFirstNonSpaceCharPosStarting(end + 1); + } + return createCodeFix("", start_4, end - start_4); + } + case 239 /* NamespaceImport */: + var namespaceImport = token.parent; + if (namespaceImport.name == token && !namespaceImport.parent.name) { + var importDecl = findImportDeclaration(namespaceImport); + return createCodeFixToRemoveNode(importDecl); + } + else { + var start_5 = namespaceImport.parent.name.end; + return createCodeFix("", start_5, namespaceImport.parent.namedBindings.end - start_5); + } + } + break; + case 148 /* PropertyDeclaration */: + case 239 /* NamespaceImport */: + return createCodeFixToRemoveNode(token.parent); + } + if (ts.isDeclarationName(token)) { + return createCodeFixToRemoveNode(token.parent); + } + else if (ts.isLiteralComputedPropertyDeclarationName(token)) { + return createCodeFixToRemoveNode(token.parent.parent); + } + else { + return undefined; + } + function findImportDeclaration(token) { + var importDecl = token; + while (importDecl.kind != 237 /* ImportDeclaration */ && importDecl.parent) { + importDecl = importDecl.parent; + } + return importDecl; + } + function createCodeFixToRemoveNode(node) { + var end = node.getEnd(); + var endCharCode = sourceFile.text.charCodeAt(end); + var afterEndCharCode = sourceFile.text.charCodeAt(end + 1); + if (ts.isLineBreak(endCharCode)) { + end += 1; + } + // in the case of CR LF, you could have two consecutive new line characters for one new line. + // this needs to be differenciated from two LF LF chars that actually mean two new lines. + if (ts.isLineBreak(afterEndCharCode) && endCharCode !== afterEndCharCode) { + end += 1; + } + var start = node.getStart(); + return createCodeFix("", start, end - start); + } + function findFirstNonSpaceCharPosStarting(start) { + while (ts.isWhiteSpace(sourceFile.text.charCodeAt(start))) { + start += 1; + } + return start; + } + function createCodeFix(newText, start, length) { + return [{ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ newText: newText, span: { start: start, length: length } }] + }] + }]; + } + function removeSingleItem(elements, token) { + if (elements[0] === token.parent) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + } + else { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + } + } + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -77450,18 +80183,19 @@ var ts; })(ModuleSpecifierComparison || (ModuleSpecifierComparison = {})); var ImportCodeActionMap = (function () { function ImportCodeActionMap() { - this.symbolIdToActionMap = ts.createMap(); + this.symbolIdToActionMap = []; } ImportCodeActionMap.prototype.addAction = function (symbolId, newAction) { if (!newAction) { return; } - if (!this.symbolIdToActionMap[symbolId]) { + var actions = this.symbolIdToActionMap[symbolId]; + if (!actions) { this.symbolIdToActionMap[symbolId] = [newAction]; return; } if (newAction.kind === "CodeChange") { - this.symbolIdToActionMap[symbolId].push(newAction); + actions.push(newAction); return; } var updatedNewImports = []; @@ -77505,8 +80239,8 @@ var ts; }; ImportCodeActionMap.prototype.getAllActions = function () { var result = []; - for (var symbolId in this.symbolIdToActionMap) { - result = ts.concatenate(result, this.symbolIdToActionMap[symbolId]); + for (var key in this.symbolIdToActionMap) { + result = ts.concatenate(result, this.symbolIdToActionMap[key]); } return result; }; @@ -77538,7 +80272,11 @@ var ts; return ImportCodeActionMap; }()); codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Cannot_find_name_0.code], + errorCodes: [ + ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics.Cannot_find_namespace_0.code, + ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ], getCodeActions: function (context) { var sourceFile = context.sourceFile; var checker = context.program.getTypeChecker(); @@ -77548,8 +80286,13 @@ var ts; var name = token.getText(); var symbolIdActionMap = new ImportCodeActionMap(); // this is a module id -> module import declaration map - var cachedImportDeclarations = ts.createMap(); + var cachedImportDeclarations = []; var cachedNewImportInsertPosition; + var currentTokenMeaning = ts.getMeaningFromLocation(token); + if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { + var symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); + return getCodeActionForImport(symbol, /*isDefault*/ false, /*isNamespaceImport*/ true); + } var allPotentialModules = checker.getAmbientModules(); for (var _i = 0, allSourceFiles_1 = allSourceFiles; _i < allSourceFiles_1.length; _i++) { var otherSourceFile = allSourceFiles_1[_i]; @@ -77557,7 +80300,6 @@ var ts; allPotentialModules.push(otherSourceFile.symbol); } } - var currentTokenMeaning = ts.getMeaningFromLocation(token); for (var _a = 0, allPotentialModules_1 = allPotentialModules; _a < allPotentialModules_1.length; _a++) { var moduleSymbol = allPotentialModules_1[_a]; context.cancellationToken.throwIfCancellationRequested(); @@ -77581,8 +80323,9 @@ var ts; return symbolIdActionMap.getAllActions(); function getImportDeclarations(moduleSymbol) { var moduleSymbolId = getUniqueSymbolId(moduleSymbol); - if (cachedImportDeclarations[moduleSymbolId]) { - return cachedImportDeclarations[moduleSymbolId]; + var cached = cachedImportDeclarations[moduleSymbolId]; + if (cached) { + return cached; } var existingDeclarations = []; for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { @@ -77597,10 +80340,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 235 /* ImportDeclaration */) { + if (node.kind === 237 /* ImportDeclaration */) { return node; } - if (node.kind === 234 /* ImportEqualsDeclaration */) { + if (node.kind === 236 /* ImportEqualsDeclaration */) { return node; } node = node.parent; @@ -77618,7 +80361,7 @@ var ts; var declarations = symbol.getDeclarations(); return declarations ? ts.some(symbol.declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }) : false; } - function getCodeActionForImport(moduleSymbol, isDefault) { + function getCodeActionForImport(moduleSymbol, isDefault, isNamespaceImport) { var existingDeclarations = getImportDeclarations(moduleSymbol); if (existingDeclarations.length > 0) { // With an existing import statement, there are more than one actions the user can do. @@ -77644,11 +80387,11 @@ var ts; var namespaceImportDeclaration; var namedImportDeclaration; var existingModuleSpecifier; - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; - if (declaration.kind === 235 /* ImportDeclaration */) { + for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { + var declaration = declarations_14[_i]; + if (declaration.kind === 237 /* ImportDeclaration */) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 237 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 239 /* NamespaceImport */) { // case: // import * as ns from "foo" namespaceImportDeclaration = declaration; @@ -77672,7 +80415,7 @@ var ts; if (namespaceImportDeclaration) { actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration)); } - if (namedImportDeclaration && namedImportDeclaration.importClause && + if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause && (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { /** * If the existing import declaration already has a named import list, just @@ -77688,7 +80431,7 @@ var ts; } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 245 /* ExternalModuleReference */) { + if (declaration.moduleReference && declaration.moduleReference.kind === 247 /* ExternalModuleReference */) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); @@ -77736,7 +80479,7 @@ var ts; } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 235 /* ImportDeclaration */) { + if (declaration.kind === 237 /* ImportDeclaration */) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { @@ -77773,7 +80516,9 @@ var ts; var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); var importStatementText = isDefault ? "import " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" - : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; + : isNamespaceImport + ? "import * as " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" + : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; // if this file doesn't have any import statements, insert an import statement and then insert a new line // between the only import statement and user code. Otherwise just insert the statement because chances // are there are already a new line seperating code and import statements. @@ -77782,18 +80527,18 @@ var ts; : "" + context.newLineCharacter + importStatementText + ";"; return createCodeAction(ts.Diagnostics.Import_0_from_1, [name, "\"" + moduleSpecifierWithoutQuotes + "\""], newText, { start: cachedNewImportInsertPosition, length: 0 }, sourceFile.fileName, "NewImport", moduleSpecifierWithoutQuotes); function getModuleSpecifierForNewImport() { - var fileName = sourceFile.path; - var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().path; + var fileName = sourceFile.fileName; + var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; var sourceDirectory = ts.getDirectoryPath(fileName); var options = context.program.getCompilerOptions(); return tryGetModuleNameFromAmbientModule() || - tryGetModuleNameFromBaseUrl() || - tryGetModuleNameFromRootDirs() || tryGetModuleNameFromTypeRoots() || tryGetModuleNameAsNodeModule() || + tryGetModuleNameFromBaseUrl() || + tryGetModuleNameFromRootDirs() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 261 /* SourceFile */) { + if (moduleSymbol.valueDeclaration.kind !== 264 /* SourceFile */) { return moduleSymbol.name; } } @@ -77801,11 +80546,11 @@ var ts; if (!options.baseUrl) { return undefined; } - var normalizedBaseUrl = ts.toPath(options.baseUrl, ts.getDirectoryPath(options.baseUrl), getCanonicalFileName); - var relativeName = tryRemoveParentDirectoryName(moduleFileName, normalizedBaseUrl); + var relativeName = getRelativePathIfInDirectory(moduleFileName, options.baseUrl); if (!relativeName) { return undefined; } + var relativeNameWithIndex = ts.removeFileExtension(relativeName); relativeName = removeExtensionAndIndexPostFix(relativeName); if (options.paths) { for (var key in options.paths) { @@ -77825,7 +80570,7 @@ var ts; return key.replace("\*", matchedStar); } } - else if (pattern === relativeName) { + else if (pattern === relativeName || pattern === relativeNameWithIndex) { return key; } } @@ -77835,9 +80580,8 @@ var ts; } function tryGetModuleNameFromRootDirs() { if (options.rootDirs) { - var normalizedRootDirs = ts.map(options.rootDirs, function (rootDir) { return ts.toPath(rootDir, /*basePath*/ undefined, getCanonicalFileName); }); - var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, normalizedRootDirs); - var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, normalizedRootDirs); + var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, options.rootDirs); + var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, options.rootDirs); if (normalizedTargetPath !== undefined) { var relativePath = normalizedSourcePath !== undefined ? getRelativePath(normalizedTargetPath, normalizedSourcePath) : normalizedTargetPath; return ts.removeFileExtension(relativePath); @@ -77901,7 +80645,7 @@ var ts; function getPathRelativeToRootDirs(path, rootDirs) { for (var _i = 0, rootDirs_2 = rootDirs; _i < rootDirs_2.length; _i++) { var rootDir = rootDirs_2[_i]; - var relativeName = tryRemoveParentDirectoryName(path, rootDir); + var relativeName = getRelativePathIfInDirectory(path, rootDir); if (relativeName !== undefined) { return relativeName; } @@ -77915,19 +80659,14 @@ var ts; } return fileName; } + function getRelativePathIfInDirectory(path, directoryPath) { + var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); + return ts.isRootedDiskPath(relativePath) || ts.startsWith(relativePath, "..") ? undefined : relativePath; + } function getRelativePath(path, directoryPath) { var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); return ts.moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath; } - function tryRemoveParentDirectoryName(path, parentDirectory) { - var index = path.indexOf(parentDirectory); - if (index === 0) { - return ts.endsWith(parentDirectory, ts.directorySeparator) - ? path.substring(parentDirectory.length) - : path.substring(parentDirectory.length + 1); - } - return undefined; - } } } function createCodeAction(description, diagnosticArgs, newText, span, fileName, kind, moduleSpecifier) { @@ -77947,156 +80686,150 @@ var ts; (function (ts) { var codefix; (function (codefix) { - codefix.registerCodeFix({ - errorCodes: [ - ts.Diagnostics._0_is_declared_but_never_used.code, - ts.Diagnostics.Property_0_is_declared_but_never_used.code - ], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var start = context.span.start; - var token = ts.getTokenAtPosition(sourceFile, start); - // this handles var ["computed"] = 12; - if (token.kind === 20 /* OpenBracketToken */) { - token = ts.getTokenAtPosition(sourceFile, start + 1); - } - switch (token.kind) { - case 70 /* Identifier */: - switch (token.parent.kind) { - case 223 /* VariableDeclaration */: - switch (token.parent.parent.parent.kind) { - case 211 /* ForStatement */: - var forStatement = token.parent.parent.parent; - var forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); - } - else { - return removeSingleItem(forInitializer.declarations, token); - } - case 213 /* ForOfStatement */: - var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 224 /* VariableDeclarationList */) { - var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); - } - break; - case 212 /* ForInStatement */: - // There is no valid fix in the case of: - // for .. in - return undefined; - case 256 /* CatchClause */: - var catchClause = token.parent.parent; - var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFix("", parameter.pos, parameter.end - parameter.pos); - default: - var variableStatement = token.parent.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); - } - else { - var declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); - } - } - case 143 /* TypeParameter */: - var typeParameters = token.parent.parent.typeParameters; - if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); - } - else { - return removeSingleItem(typeParameters, token); - } - case 144 /* Parameter */: - var functionDeclaration = token.parent.parent; - if (functionDeclaration.parameters.length === 1) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else { - return removeSingleItem(functionDeclaration.parameters, token); - } - // handle case where 'import a = A;' - case 234 /* ImportEqualsDeclaration */: - var importEquals = findImportDeclaration(token); - return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); - case 239 /* ImportSpecifier */: - var namedImports = token.parent.parent; - if (namedImports.elements.length === 1) { - // Only 1 import and it is unused. So the entire declaration should be removed. - var importSpec = findImportDeclaration(token); - return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); - } - else { - return removeSingleItem(namedImports.elements, token); - } - // handle case where "import d, * as ns from './file'" - // or "'import {a, b as ns} from './file'" - case 236 /* ImportClause */: - var importClause = token.parent; - if (!importClause.namedBindings) { - var importDecl = findImportDeclaration(importClause); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); - } - case 237 /* NamespaceImport */: - var namespaceImport = token.parent; - if (namespaceImport.name == token && !namespaceImport.parent.name) { - var importDecl = findImportDeclaration(namespaceImport); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - var start_4 = namespaceImport.parent.name.end; - return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); - } - } - break; - case 147 /* PropertyDeclaration */: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - case 237 /* NamespaceImport */: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - if (ts.isDeclarationName(token)) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); - } - else { - return undefined; - } - function findImportDeclaration(token) { - var importDecl = token; - while (importDecl.kind != 235 /* ImportDeclaration */ && importDecl.parent) { - importDecl = importDecl.parent; + /** + * Finds members of the resolved type that are missing in the class pointed to by class decl + * and generates source code for the missing members. + * @param possiblyMissingSymbols The collection of symbols to filter and then get insertions for. + * @returns Empty string iff there are no member insertions. + */ + function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { + var classMembers = classDeclaration.symbol.members; + var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !classMembers.has(symbol.getName()); }); + var insertion = ""; + for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { + var symbol = missingMembers_1[_i]; + insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + } + return insertion; + } + codefix.getMissingMembersInsertion = getMissingMembersInsertion; + /** + * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`. + */ + function getInsertionForMemberSymbol(symbol, enclosingDeclaration, checker, newlineChar) { + // const name = symbol.getName(); + var type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + var declarations = symbol.getDeclarations(); + if (!(declarations && declarations.length)) { + return ""; + } + var declaration = declarations[0]; + var name = declaration.name ? declaration.name.getText() : undefined; + var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); + switch (declaration.kind) { + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 147 /* PropertySignature */: + case 148 /* PropertyDeclaration */: + var typeString = checker.typeToString(type, enclosingDeclaration, 0 /* None */); + return "" + visibility + name + ": " + typeString + ";" + newlineChar; + case 149 /* MethodSignature */: + case 150 /* MethodDeclaration */: + // The signature for the implementation appears as an entry in `signatures` iff + // there is only one signature. + // If there are overloads and an implementation signature, it appears as an + // extra declaration that isn't a signature for `type`. + // If there is more than one overload but no implementation signature + // (eg: an abstract method or interface declaration), there is a 1-1 + // correspondence of declarations and signatures. + var signatures = checker.getSignaturesOfType(type, 0 /* Call */); + if (!(signatures && signatures.length > 0)) { + return ""; } - return importDecl; - } - function createCodeFix(newText, start, length) { - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText: newText, span: { start: start, length: length } }] - }] - }]; - } - function removeSingleItem(elements, token) { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + if (declarations.length === 1) { + ts.Debug.assert(signatures.length === 1); + var sigString_1 = checker.signatureToString(signatures[0], enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); + return "" + visibility + name + sigString_1 + getMethodBodyStub(newlineChar); + } + var result = ""; + for (var i = 0; i < signatures.length; i++) { + var sigString_2 = checker.signatureToString(signatures[i], enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); + result += "" + visibility + name + sigString_2 + ";" + newlineChar; + } + // If there is a declaration with a body, it is the last declaration, + // and it isn't caught by `getSignaturesOfType`. + var bodySig = undefined; + if (declarations.length > signatures.length) { + bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); } else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + ts.Debug.assert(declarations.length === signatures.length); + bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); } + var sigString = checker.signatureToString(bodySig, enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); + result += "" + visibility + name + sigString + getMethodBodyStub(newlineChar); + return result; + default: + return ""; + } + } + function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { + var newSignatureDeclaration = ts.createNode(154 /* CallSignature */); + newSignatureDeclaration.parent = enclosingDeclaration; + newSignatureDeclaration.name = signatures[0].getDeclaration().name; + var maxNonRestArgs = -1; + var maxArgsIndex = 0; + var minArgumentCount = signatures[0].minArgumentCount; + var hasRestParameter = false; + for (var i = 0; i < signatures.length; i++) { + var sig = signatures[i]; + minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); + hasRestParameter = hasRestParameter || sig.hasRestParameter; + var nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); + if (nonRestLength > maxNonRestArgs) { + maxNonRestArgs = nonRestLength; + maxArgsIndex = i; } } - }); + var maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(function (symbol) { return symbol.getName(); }); + var optionalToken = ts.createToken(54 /* QuestionToken */); + newSignatureDeclaration.parameters = ts.createNodeArray(); + for (var i = 0; i < maxNonRestArgs; i++) { + var newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); + newSignatureDeclaration.parameters.push(newParameter); + } + if (hasRestParameter) { + var restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); + restParameter.dotDotDotToken = ts.createToken(23 /* DotDotDotToken */); + newSignatureDeclaration.parameters.push(restParameter); + } + return checker.getSignatureFromDeclaration(newSignatureDeclaration); + function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { + var newParameter = ts.createNode(145 /* Parameter */); + newParameter.symbol = new SymbolConstructor(1 /* FunctionScopedVariable */, maxArgsParameterSymbolNames[index] || "rest"); + newParameter.symbol.valueDeclaration = newParameter; + newParameter.symbol.declarations = [newParameter]; + newParameter.parent = enclosingSignatureDeclaration; + if (index >= minArgCount) { + newParameter.questionToken = optionalToken; + } + return newParameter; + } + } + function getMethodBodyStub(newLineChar) { + return " {" + newLineChar + "throw new Error('Method not implemented.');" + newLineChar + "}" + newLineChar; + } + function getVisibilityPrefix(flags) { + if (flags & 4 /* Public */) { + return "public "; + } + else if (flags & 16 /* Protected */) { + return "protected "; + } + return ""; + } + var SymbolConstructor = ts.objectAllocator.getSymbolConstructor(); })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); -/// -/// -/// +/// +/// +/// +/// +/// +/// +/// +/// +/// /// /// /// @@ -78122,14 +80855,14 @@ var ts; /// /// /// -/// +/// /// var ts; (function (ts) { /** The version of the language service API */ ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 141 /* FirstNode */ ? new NodeObject(kind, pos, end) : + var node = kind >= 142 /* FirstNode */ ? new NodeObject(kind, pos, end) : kind === 70 /* Identifier */ ? new IdentifierObject(70 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; @@ -78187,7 +80920,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(292 /* SyntaxList */, nodes.pos, nodes.end, this); + var list = createNode(296 /* SyntaxList */, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -78206,11 +80939,11 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 141 /* FirstNode */) { + if (this.kind >= 142 /* FirstNode */) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 278 /* FirstJSDocTagNode */ && this.kind <= 291 /* LastJSDocTagNode */; + var useJSDocScanner_1 = this.kind >= 282 /* FirstJSDocTagNode */ && this.kind <= 295 /* LastJSDocTagNode */; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -78267,8 +81000,10 @@ var ts; if (!children.length) { return undefined; } - var child = children[0]; - return child.kind < 141 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + var child = ts.find(children, function (kid) { return kid.kind < 266 /* FirstJSDocNode */ || kid.kind > 295 /* LastJSDocNode */; }); + return child.kind < 142 /* FirstNode */ ? + child : + child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -78276,7 +81011,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 141 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 142 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -78475,17 +81210,21 @@ var ts; return this.namedDeclarations; }; SourceFileObject.prototype.computeNamedDeclarations = function () { - var result = ts.createMap(); + var result = ts.createMultiMap(); ts.forEachChild(this, visit); return result; function addDeclaration(declaration) { var name = getDeclarationName(declaration); if (name) { - ts.multiMapAdd(result, name, declaration); + result.add(name, declaration); } } function getDeclarations(name) { - return result[name] || (result[name] = []); + var declarations = result.get(name); + if (!declarations) { + result.set(name, declarations = []); + } + return declarations; } function getDeclarationName(declaration) { if (declaration.name) { @@ -78493,9 +81232,9 @@ var ts; if (result_7 !== undefined) { return result_7; } - if (declaration.name.kind === 142 /* ComputedPropertyName */) { + if (declaration.name.kind === 143 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 177 /* PropertyAccessExpression */) { + if (expr.kind === 178 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -78515,10 +81254,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 225 /* FunctionDeclaration */: - case 184 /* FunctionExpression */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: + case 227 /* FunctionDeclaration */: + case 185 /* FunctionExpression */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -78538,32 +81277,32 @@ var ts; } ts.forEachChild(node, visit); break; - case 226 /* ClassDeclaration */: - case 197 /* ClassExpression */: - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: - case 229 /* EnumDeclaration */: - case 230 /* ModuleDeclaration */: - case 234 /* ImportEqualsDeclaration */: - case 243 /* ExportSpecifier */: - case 239 /* ImportSpecifier */: - case 234 /* ImportEqualsDeclaration */: - case 236 /* ImportClause */: - case 237 /* NamespaceImport */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 161 /* TypeLiteral */: + case 228 /* ClassDeclaration */: + case 198 /* ClassExpression */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: + case 231 /* EnumDeclaration */: + case 232 /* ModuleDeclaration */: + case 236 /* ImportEqualsDeclaration */: + case 245 /* ExportSpecifier */: + case 241 /* ImportSpecifier */: + case 236 /* ImportEqualsDeclaration */: + case 238 /* ImportClause */: + case 239 /* NamespaceImport */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 162 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 144 /* Parameter */: + case 145 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // fall through - case 223 /* VariableDeclaration */: - case 174 /* BindingElement */: { + case 225 /* VariableDeclaration */: + case 175 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -78572,19 +81311,19 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 260 /* EnumMember */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 263 /* EnumMember */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: addDeclaration(node); break; - case 241 /* ExportDeclaration */: + case 243 /* 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 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -78596,7 +81335,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 237 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 239 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -79026,6 +81765,7 @@ var ts; ts.Debug.assert(hostFileInformation.scriptKind === oldSourceFile.scriptKind, "Registered script kind (" + oldSourceFile.scriptKind + ") should match new script kind (" + hostFileInformation.scriptKind + ") for file: " + path); return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } + // We didn't already have the file. Fall through and acquire it from the registry. } // Could not find this file in the old program, create a new SourceFile for it. return documentRegistry.acquireDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); @@ -79126,10 +81866,10 @@ var ts; // Try getting just type at this position and show switch (node.kind) { case 70 /* Identifier */: - case 177 /* PropertyAccessExpression */: - case 141 /* QualifiedName */: + case 178 /* PropertyAccessExpression */: + case 142 /* QualifiedName */: case 98 /* ThisKeyword */: - case 167 /* ThisType */: + case 168 /* ThisType */: case 96 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); @@ -79171,10 +81911,10 @@ var ts; function getOccurrencesAtPosition(fileName, position) { var results = getOccurrencesAtPositionCore(fileName, position); if (results) { - var sourceFile_2 = getCanonicalFileName(ts.normalizeSlashes(fileName)); + var sourceFile_1 = 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_2; }); + results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_1; }); } return results; } @@ -79209,21 +81949,21 @@ var ts; } } function findRenameLocations(fileName, position, findInStrings, findInComments) { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments, /*isForRename*/ true); return ts.FindAllReferences.convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/ false); return ts.FindAllReferences.convertReferences(referencedSymbols); } function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/ 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) { + function findReferencedSymbols(fileName, position, findInStrings, findInComments, isForRename) { synchronizeHostData(); - return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments); + return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments, isForRename); } /// NavigateTo function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { @@ -79272,15 +82012,15 @@ var ts; return; } switch (node.kind) { - case 177 /* PropertyAccessExpression */: - case 141 /* QualifiedName */: + case 178 /* PropertyAccessExpression */: + case 142 /* QualifiedName */: case 9 /* StringLiteral */: case 85 /* FalseKeyword */: case 100 /* TrueKeyword */: case 94 /* NullKeyword */: case 96 /* SuperKeyword */: case 98 /* ThisKeyword */: - case 167 /* ThisType */: + case 168 /* ThisType */: case 70 /* Identifier */: break; // Cant create the text span @@ -79297,7 +82037,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 === 230 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 232 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -79440,7 +82180,7 @@ var ts; var span = { start: start, length: end - start }; var newLineChar = ts.getNewLineOrDefaultFromHost(host); var allFixes = []; - ts.forEach(errorCodes, function (error) { + ts.forEach(ts.deduplicate(errorCodes), function (error) { cancellationToken.throwIfCancellationRequested(); var context = { errorCode: error, @@ -79529,7 +82269,7 @@ var ts; continue; } var descriptor = undefined; - for (var i = 0, n = descriptors.length; i < n; i++) { + for (var i = 0; i < descriptors.length; i++) { if (matchArray[i + firstDescriptorCaptureIndex]) { descriptor = descriptors[i]; } @@ -79674,7 +82414,7 @@ var ts; function walk(node) { switch (node.kind) { case 70 /* Identifier */: - nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; + setNameTable(node.text, node); break; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: @@ -79683,10 +82423,10 @@ 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 === 245 /* ExternalModuleReference */ || + node.parent.kind === 247 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { - nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; + setNameTable(node.text, node); } break; default: @@ -79699,11 +82439,72 @@ var ts; } } } + function setNameTable(text, node) { + nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); + } } + function isObjectLiteralElement(node) { + switch (node.kind) { + case 252 /* JsxAttribute */: + case 254 /* JsxSpreadAttribute */: + case 260 /* PropertyAssignment */: + case 261 /* ShorthandPropertyAssignment */: + case 150 /* MethodDeclaration */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + return true; + } + return false; + } + /** + * Returns the containing object literal property declaration given a possible name node, e.g. "a" in x = { "a": 1 } + */ + /* @internal */ + function getContainingObjectLiteralElement(node) { + switch (node.kind) { + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + if (node.parent.kind === 143 /* ComputedPropertyName */) { + return isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; + } + // intentionally fall through + case 70 /* Identifier */: + return isObjectLiteralElement(node.parent) && + (node.parent.parent.kind === 177 /* ObjectLiteralExpression */ || node.parent.parent.kind === 253 /* JsxAttributes */) && + node.parent.name === node ? node.parent : undefined; + } + return undefined; + } + ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; + /* @internal */ + function getPropertySymbolsFromContextualType(typeChecker, node) { + var objectLiteral = node.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name = ts.getTextOfPropertyName(node.name); + if (name && contextualType) { + var result_8 = []; + var symbol = contextualType.getProperty(name); + if (contextualType.flags & 65536 /* Union */) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_8.push(symbol); + } + }); + return result_8; + } + if (symbol) { + result_8.push(symbol); + return result_8; + } + } + return undefined; + } + ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 178 /* ElementAccessExpression */ && + node.parent.kind === 179 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -79719,10 +82520,7 @@ var ts; throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); } ts.getDefaultLibFilePath = getDefaultLibFilePath; - function initializeServices() { - ts.objectAllocator = getServicesObjectAllocator(); - } - initializeServices(); + ts.objectAllocator = getServicesObjectAllocator(); })(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. @@ -79787,113 +82585,113 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 205 /* VariableStatement */: + case 207 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 223 /* VariableDeclaration */: - case 147 /* PropertyDeclaration */: - case 146 /* PropertySignature */: + case 225 /* VariableDeclaration */: + case 148 /* PropertyDeclaration */: + case 147 /* PropertySignature */: return spanInVariableDeclaration(node); - case 144 /* Parameter */: + case 145 /* Parameter */: return spanInParameterDeclaration(node); - case 225 /* FunctionDeclaration */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 150 /* Constructor */: - case 184 /* FunctionExpression */: - case 185 /* ArrowFunction */: + case 227 /* FunctionDeclaration */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 151 /* Constructor */: + case 185 /* FunctionExpression */: + case 186 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 204 /* Block */: + case 206 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 231 /* ModuleBlock */: + case 233 /* ModuleBlock */: return spanInBlock(node); - case 256 /* CatchClause */: + case 259 /* CatchClause */: return spanInBlock(node.block); - case 207 /* ExpressionStatement */: + case 209 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 216 /* ReturnStatement */: + case 218 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 210 /* WhileStatement */: + case 212 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 209 /* DoStatement */: + case 211 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 222 /* DebuggerStatement */: + case 224 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 208 /* IfStatement */: + case 210 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 219 /* LabeledStatement */: + case 221 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 215 /* BreakStatement */: - case 214 /* ContinueStatement */: + case 217 /* BreakStatement */: + case 216 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 211 /* ForStatement */: + case 213 /* ForStatement */: return spanInForStatement(node); - case 212 /* ForInStatement */: + case 214 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 213 /* ForOfStatement */: + case 215 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 218 /* SwitchStatement */: + case 220 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 253 /* CaseClause */: - case 254 /* DefaultClause */: + case 256 /* CaseClause */: + case 257 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 221 /* TryStatement */: + case 223 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 220 /* ThrowStatement */: + case 222 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 240 /* ExportAssignment */: + case 242 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 235 /* ImportDeclaration */: + case 237 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 241 /* ExportDeclaration */: + case 243 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 226 /* ClassDeclaration */: - case 229 /* EnumDeclaration */: - case 260 /* EnumMember */: - case 174 /* BindingElement */: + case 228 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 263 /* EnumMember */: + case 175 /* BindingElement */: // span on complete node return textSpan(node); - case 217 /* WithStatement */: + case 219 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 145 /* Decorator */: + case 146 /* Decorator */: return spanInNodeArray(node.parent.decorators); - case 172 /* ObjectBindingPattern */: - case 173 /* ArrayBindingPattern */: + case 173 /* ObjectBindingPattern */: + case 174 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 227 /* InterfaceDeclaration */: - case 228 /* TypeAliasDeclaration */: + case 229 /* InterfaceDeclaration */: + case 230 /* TypeAliasDeclaration */: return undefined; // Tokens: case 24 /* SemicolonToken */: @@ -79923,7 +82721,7 @@ var ts; case 73 /* CatchKeyword */: case 86 /* FinallyKeyword */: return spanInNextNode(node); - case 140 /* OfKeyword */: + case 141 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -79936,13 +82734,13 @@ var ts; // a or ...c or d: x from // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern if ((node.kind === 70 /* Identifier */ || - node.kind == 196 /* SpreadElement */ || - node.kind === 257 /* PropertyAssignment */ || - node.kind === 258 /* ShorthandPropertyAssignment */) && + node.kind == 197 /* SpreadElement */ || + node.kind === 260 /* PropertyAssignment */ || + node.kind === 261 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 192 /* BinaryExpression */) { + if (node.kind === 193 /* BinaryExpression */) { var binaryExpression = node; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -79965,22 +82763,22 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 209 /* DoStatement */: + case 211 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 145 /* Decorator */: + case 146 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForStatement */: + case 215 /* ForOfStatement */: return textSpan(node); - case 192 /* BinaryExpression */: + case 193 /* BinaryExpression */: if (node.parent.operatorToken.kind === 25 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 185 /* ArrowFunction */: + case 186 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -79989,13 +82787,13 @@ var ts; } } // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 257 /* PropertyAssignment */ && + if (node.parent.kind === 260 /* PropertyAssignment */ && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 182 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 183 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNextNode(node.parent.type); } // return type of function go to previous token @@ -80003,8 +82801,8 @@ var ts; return spanInPreviousNode(node); } // initializer of variable/parameter declaration go to previous node - if ((node.parent.kind === 223 /* VariableDeclaration */ || - node.parent.kind === 144 /* Parameter */)) { + if ((node.parent.kind === 225 /* VariableDeclaration */ || + node.parent.kind === 145 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -80012,7 +82810,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 192 /* BinaryExpression */) { + if (node.parent.kind === 193 /* BinaryExpression */) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -80038,7 +82836,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 212 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 214 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern, set breakpoint in binding pattern @@ -80049,7 +82847,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 213 /* ForOfStatement */) { + variableDeclaration.parent.parent.kind === 215 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -80089,7 +82887,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 226 /* ClassDeclaration */ && functionDeclaration.kind !== 150 /* Constructor */); + (functionDeclaration.parent.kind === 228 /* ClassDeclaration */ && functionDeclaration.kind !== 151 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -80112,25 +82910,25 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 230 /* ModuleDeclaration */: + case 232 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 210 /* WhileStatement */: - case 208 /* IfStatement */: - case 212 /* ForInStatement */: + case 212 /* WhileStatement */: + case 210 /* IfStatement */: + case 214 /* ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: + case 213 /* ForStatement */: + case 215 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 224 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 226 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -80155,23 +82953,23 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 198 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 199 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 174 /* BindingElement */) { + if (bindingPattern.parent.kind === 175 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 173 /* ArrayBindingPattern */ && node.kind !== 172 /* ObjectBindingPattern */); - var elements = node.kind === 175 /* ArrayLiteralExpression */ ? + ts.Debug.assert(node.kind !== 174 /* ArrayBindingPattern */ && node.kind !== 173 /* ObjectBindingPattern */); + var elements = node.kind === 176 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 198 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 199 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -80179,18 +82977,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 192 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 193 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 229 /* EnumDeclaration */: + case 231 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 226 /* ClassDeclaration */: + case 228 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 232 /* CaseBlock */: + case 234 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -80198,24 +82996,24 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 231 /* ModuleBlock */: + case 233 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 229 /* EnumDeclaration */: - case 226 /* ClassDeclaration */: + case 231 /* EnumDeclaration */: + case 228 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 204 /* Block */: + case 206 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through - case 256 /* CatchClause */: + case 259 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 232 /* CaseBlock */: + case 234 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -80223,7 +83021,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 172 /* ObjectBindingPattern */: + case 173 /* ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -80239,7 +83037,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 173 /* ArrayBindingPattern */: + case 174 /* ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -80254,12 +83052,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 209 /* DoStatement */ || - node.parent.kind === 179 /* CallExpression */ || - node.parent.kind === 180 /* NewExpression */) { + if (node.parent.kind === 211 /* DoStatement */ || + node.parent.kind === 180 /* CallExpression */ || + node.parent.kind === 181 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 183 /* ParenthesizedExpression */) { + if (node.parent.kind === 184 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -80268,21 +83066,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 184 /* FunctionExpression */: - case 225 /* FunctionDeclaration */: - case 185 /* ArrowFunction */: - case 149 /* MethodDeclaration */: - case 148 /* MethodSignature */: - case 151 /* GetAccessor */: - case 152 /* SetAccessor */: - case 150 /* Constructor */: - case 210 /* WhileStatement */: - case 209 /* DoStatement */: - case 211 /* ForStatement */: - case 213 /* ForOfStatement */: - case 179 /* CallExpression */: - case 180 /* NewExpression */: - case 183 /* ParenthesizedExpression */: + case 185 /* FunctionExpression */: + case 227 /* FunctionDeclaration */: + case 186 /* ArrowFunction */: + case 150 /* MethodDeclaration */: + case 149 /* MethodSignature */: + case 152 /* GetAccessor */: + case 153 /* SetAccessor */: + case 151 /* Constructor */: + case 212 /* WhileStatement */: + case 211 /* DoStatement */: + case 213 /* ForStatement */: + case 215 /* ForOfStatement */: + case 180 /* CallExpression */: + case 181 /* NewExpression */: + case 184 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -80292,20 +83090,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 257 /* PropertyAssignment */ || - node.parent.kind === 144 /* Parameter */) { + node.parent.kind === 260 /* PropertyAssignment */ || + node.parent.kind === 145 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 182 /* TypeAssertionExpression */) { + if (node.parent.kind === 183 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 209 /* DoStatement */) { + if (node.parent.kind === 211 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -80313,7 +83111,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 213 /* ForOfStatement */) { + if (node.parent.kind === 215 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -80444,7 +83242,10 @@ var ts; if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } - return JSON.parse(settingsJson); + var compilerOptions = JSON.parse(settingsJson); + // permit language service to handle all files (filtering should be performed on the host side) + compilerOptions.allowNonTsExtensions = true; + return compilerOptions; }; LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { var encoded = this.shimHost.getScriptFileNames(); @@ -80952,12 +83753,6 @@ var ts; var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (resolvedFileName && !compilerOptions.allowJs && ts.fileExtensionIs(resolvedFileName, ".js")) { - return { - resolvedFileName: undefined, - failedLookupLocations: [] - }; - } return { resolvedFileName: resolvedFileName, failedLookupLocations: result.failedLookupLocations @@ -81102,7 +83897,7 @@ var ts; this._shims.push(shim); }; TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0, n = this._shims.length; i < n; i++) { + for (var i = 0; i < this._shims.length; i++) { if (this._shims[i] === shim) { delete this._shims[i]; return; @@ -81131,4 +83926,4 @@ var TypeScript; // 'toolsVersion' gets consumed by the managed side, so it's not unused. // TODO: it should be moved into a namespace though. /* @internal */ -var toolsVersion = "2.2"; +var toolsVersion = "2.3"; diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index d8cd324a8d2..a009c63ec7d 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -13,11 +13,16 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ts; (function (ts) { var OperationCanceledException = (function () { @@ -93,32 +98,32 @@ var ts; var measures; function mark(markName) { if (enabled) { - marks[markName] = ts.timestamp(); - counts[markName] = (counts[markName] || 0) + 1; + marks.set(markName, ts.timestamp()); + counts.set(markName, (counts.get(markName) || 0) + 1); profilerEvent(markName); } } performance.mark = mark; function measure(measureName, startMarkName, endMarkName) { if (enabled) { - var end = endMarkName && marks[endMarkName] || ts.timestamp(); - var start = startMarkName && marks[startMarkName] || profilerStart; - measures[measureName] = (measures[measureName] || 0) + (end - start); + var end = endMarkName && marks.get(endMarkName) || ts.timestamp(); + var start = startMarkName && marks.get(startMarkName) || profilerStart; + measures.set(measureName, (measures.get(measureName) || 0) + (end - start)); } } performance.measure = measure; function getCount(markName) { - return counts && counts[markName] || 0; + return counts && counts.get(markName) || 0; } performance.getCount = getCount; function getDuration(measureName) { - return measures && measures[measureName] || 0; + return measures && measures.get(measureName) || 0; } performance.getDuration = getDuration; function forEachMeasure(cb) { - for (var key in measures) { - cb(key, measures[key]); - } + measures.forEach(function (measure, key) { + cb(key, measure); + }); } performance.forEachMeasure = forEachMeasure; function enable() { @@ -137,22 +142,96 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.2.0"; + ts.version = "2.3.0"; })(ts || (ts = {})); (function (ts) { - var createObject = Object.create; - ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - function createMap(template) { - var map = createObject(null); + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(undefined, { usage: "sort", sensitivity: "accent" }) : undefined; + ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + function createDictionaryObject() { + var map = Object.create(null); map["__"] = undefined; delete map["__"]; + return map; + } + function createMap() { + return new MapCtr(); + } + ts.createMap = createMap; + function createMapFromTemplate(template) { + var map = new MapCtr(); for (var key in template) if (hasOwnProperty.call(template, key)) { - map[key] = template[key]; + map.set(key, template[key]); } return map; } - ts.createMap = createMap; + ts.createMapFromTemplate = createMapFromTemplate; + var MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); + function shimMap() { + var MapIterator = (function () { + function MapIterator(data, selector) { + this.index = 0; + this.data = data; + this.selector = selector; + this.keys = Object.keys(data); + } + MapIterator.prototype.next = function () { + var index = this.index; + if (index < this.keys.length) { + this.index++; + return { value: this.selector(this.data, this.keys[index]), done: false }; + } + return { value: undefined, done: true }; + }; + return MapIterator; + }()); + return (function () { + function class_1() { + this.data = createDictionaryObject(); + this.size = 0; + } + class_1.prototype.get = function (key) { + return this.data[key]; + }; + class_1.prototype.set = function (key, value) { + if (!this.has(key)) { + this.size++; + } + this.data[key] = value; + return this; + }; + class_1.prototype.has = function (key) { + return key in this.data; + }; + class_1.prototype.delete = function (key) { + if (this.has(key)) { + this.size--; + delete this.data[key]; + return true; + } + return false; + }; + class_1.prototype.clear = function () { + this.data = createDictionaryObject(); + this.size = 0; + }; + class_1.prototype.keys = function () { + return new MapIterator(this.data, function (_data, key) { return key; }); + }; + class_1.prototype.values = function () { + return new MapIterator(this.data, function (data, key) { return data[key]; }); + }; + class_1.prototype.entries = function () { + return new MapIterator(this.data, function (data, key) { return [key, data[key]]; }); + }; + class_1.prototype.forEach = function (action) { + for (var key in this.data) { + action(this.data[key], key); + } + }; + return class_1; + }()); + } function createFileMap(keyMapper) { var files = createMap(); return { @@ -165,32 +244,27 @@ var ts; clear: clear, }; function forEachValueInMap(f) { - for (var key in files) { - f(key, files[key]); - } + files.forEach(function (file, key) { + f(key, file); + }); } function getKeys() { - var keys = []; - for (var key in files) { - keys.push(key); - } - return keys; + return arrayFrom(files.keys()); } function get(path) { - return files[toKey(path)]; + return files.get(toKey(path)); } function set(path, value) { - files[toKey(path)] = value; + files.set(toKey(path), value); } function contains(path) { - return toKey(path) in files; + return files.has(toKey(path)); } function remove(path) { - var key = toKey(path); - delete files[key]; + files.delete(toKey(path)); } function clear() { - files = createMap(); + files.clear(); } function toKey(path) { return keyMapper ? keyMapper(path) : path; @@ -204,9 +278,13 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + function length(array) { + return array ? array.length : 0; + } + ts.length = length; function forEach(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -225,7 +303,7 @@ var ts; ts.zipWith = zipWith; function every(array, callback) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (!callback(array[i], i)) { return false; } @@ -235,7 +313,7 @@ var ts; } ts.every = every; function find(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -244,8 +322,17 @@ var ts; return undefined; } ts.find = find; + function findIndex(array, predicate) { + for (var i = 0; i < array.length; i++) { + if (predicate(array[i], i)) { + return i; + } + } + return -1; + } + ts.findIndex = findIndex; function findMap(array, callback) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { var result = callback(array[i], i); if (result) { return result; @@ -268,7 +355,7 @@ var ts; ts.contains = contains; function indexOf(array, value) { if (array) { - for (var i = 0, len = array.length; i < len; i++) { + for (var i = 0; i < array.length; i++) { if (array[i] === value) { return i; } @@ -278,7 +365,7 @@ var ts; } ts.indexOf = indexOf; function indexOfAnyCharCode(text, charCodes, start) { - for (var i = start || 0, len = text.length; i < len; i++) { + for (var i = start || 0; i < text.length; i++) { if (contains(charCodes, text.charCodeAt(i))) { return i; } @@ -465,21 +552,18 @@ var ts; return result; } ts.spanMap = spanMap; - function mapObject(object, f) { - var result; - if (object) { - result = {}; - for (var _i = 0, _a = getOwnKeys(object); _i < _a.length; _i++) { - var v = _a[_i]; - var _b = f(v, object[v]) || [undefined, undefined], key = _b[0], value = _b[1]; - if (key !== undefined) { - result[key] = value; - } - } + function mapEntries(map, f) { + if (!map) { + return undefined; } + var result = createMap(); + map.forEach(function (value, key) { + var _a = f(key, value), newKey = _a[0], newValue = _a[1]; + result.set(newKey, newValue); + }); return result; } - ts.mapObject = mapObject; + ts.mapEntries = mapEntries; function some(array, predicate) { if (array) { if (predicate) { @@ -763,38 +847,55 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; - function forEachProperty(map, callback) { - var result; - for (var key in map) { - if (result = callback(map[key], key)) - break; + function arrayFrom(iterator) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(value); } return result; + var _b; } - ts.forEachProperty = forEachProperty; - function someProperties(map, predicate) { - for (var key in map) { - if (!predicate || predicate(map[key], key)) - return true; + ts.arrayFrom = arrayFrom; + function convertToArray(iterator, f) { + var result = []; + for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { + result.push(f(value)); } - return false; + return result; + var _b; } - ts.someProperties = someProperties; - function copyProperties(source, target) { - for (var key in source) { - target[key] = source[key]; + ts.convertToArray = convertToArray; + function forEachEntry(map, callback) { + var iterator = map.entries(); + for (var _a = iterator.next(), pair = _a.value, done = _a.done; !done; _b = iterator.next(), pair = _b.value, done = _b.done, _b) { + var key = pair[0], value = pair[1]; + var result = callback(value, key); + if (result) { + return result; + } } + return undefined; + var _b; } - ts.copyProperties = copyProperties; - function appendProperty(map, key, value) { - if (key === undefined || value === undefined) - return map; - if (map === undefined) - map = createMap(); - map[key] = value; - return map; + ts.forEachEntry = forEachEntry; + function forEachKey(map, callback) { + var iterator = map.keys(); + for (var _a = iterator.next(), key = _a.value, done = _a.done; !done; _b = iterator.next(), key = _b.value, done = _b.done, _b) { + var result = callback(key); + if (result) { + return result; + } + } + return undefined; + var _b; } - ts.appendProperty = appendProperty; + ts.forEachKey = forEachKey; + function copyEntries(source, target) { + source.forEach(function (value, key) { + target.set(key, value); + }); + } + ts.copyEntries = copyEntries; function assign(t) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -810,14 +911,6 @@ var ts; return t; } ts.assign = assign; - function reduceProperties(map, callback, initial) { - var result = initial; - for (var key in map) { - result = callback(result, map[key], String(key)); - } - return result; - } - ts.reduceProperties = reduceProperties; function equalOwnProperties(left, right, equalityComparer) { if (left === right) return true; @@ -842,23 +935,14 @@ var ts; var result = createMap(); for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { var value = array_8[_i]; - result[makeKey(value)] = makeValue ? makeValue(value) : value; + result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; } ts.arrayToMap = arrayToMap; - function isEmpty(map) { - for (var id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - ts.isEmpty = isEmpty; function cloneMap(map) { var clone = createMap(); - copyProperties(map, clone); + copyEntries(map, clone); return clone; } ts.cloneMap = cloneMap; @@ -885,27 +969,32 @@ var ts; return result; } ts.extend = extend; - function multiMapAdd(map, key, value) { - var values = map[key]; + function createMultiMap() { + var map = createMap(); + map.add = multiMapAdd; + map.remove = multiMapRemove; + return map; + } + ts.createMultiMap = createMultiMap; + function multiMapAdd(key, value) { + var values = this.get(key); if (values) { values.push(value); - return values; } else { - return map[key] = [value]; + this.set(key, values = [value]); } + return values; } - ts.multiMapAdd = multiMapAdd; - function multiMapRemove(map, key, value) { - var values = map[key]; + function multiMapRemove(key, value) { + var values = this.get(key); if (values) { unorderedRemoveItem(values, value); if (!values.length) { - delete map[key]; + this.delete(key); } } } - ts.multiMapRemove = multiMapRemove; function isArray(value) { return Array.isArray ? Array.isArray(value) : value instanceof Array; } @@ -981,6 +1070,7 @@ var ts; baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } + ts.formatStringFromArgs = formatStringFromArgs; ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; @@ -1082,8 +1172,10 @@ var ts; if (b === undefined) return 1; if (ignoreCase) { - if (ts.collator && String.prototype.localeCompare) { - var result = a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); + if (ts.collator) { + var result = ts.localeCompareIsCorrect ? + ts.collator.compare(a, b) : + a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 : result > 0 ? 1 : 0; } a = a.toUpperCase(); @@ -1465,36 +1557,26 @@ var ts; var singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; var singleAsteriskRegexFragmentOther = "[^/]*"; function getRegularExpressionForWildcard(specs, basePath, usage) { + var patterns = getRegularExpressionsForWildcards(specs, basePath, usage); + if (!patterns || !patterns.length) { + return undefined; + } + var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var terminator = usage === "exclude" ? "($|/)" : "$"; + return "^(" + pattern + ")" + terminator; + } + ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; + function getRegularExpressionsForWildcards(specs, basePath, usage) { if (specs === undefined || specs.length === 0) { return undefined; } var replaceWildcardCharacter = usage === "files" ? replaceWildCardCharacterFiles : replaceWildCardCharacterOther; var singleAsteriskRegexFragment = usage === "files" ? singleAsteriskRegexFragmentFiles : singleAsteriskRegexFragmentOther; var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; - var pattern = ""; - var hasWrittenSubpattern = false; - for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { - var spec = specs_1[_i]; - if (!spec) { - continue; - } - var subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); - if (subPattern === undefined) { - continue; - } - if (hasWrittenSubpattern) { - pattern += "|"; - } - pattern += "(" + subPattern + ")"; - hasWrittenSubpattern = true; - } - if (!pattern) { - return undefined; - } - var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return flatMap(specs, function (spec) { + return spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + }); } - ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function isImplicitGlob(lastPathComponent) { return !/[.*?]/.test(lastPathComponent); } @@ -1564,6 +1646,7 @@ var ts; currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); return { + includeFilePatterns: map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -1576,34 +1659,48 @@ var ts; currentDirectory = normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; - var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); + var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return new RegExp(pattern, regexFlag); }); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); var excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); - var result = []; + var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]]; + var comparer = useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive; for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; visitDirectory(basePath, combinePaths(currentDirectory, basePath)); } - return result; + return flatten(results); function visitDirectory(path, absolutePath) { var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; + files = files.slice().sort(comparer); + directories = directories.slice().sort(comparer); + var _loop_1 = function (current) { + var name = combinePaths(path, current); + var absoluteName = combinePaths(absolutePath, current); + if (extensions && !fileExtensionIsAny(name, extensions)) + return "continue"; + if (excludeRegex && excludeRegex.test(absoluteName)) + return "continue"; + if (!includeFileRegexes) { + results[0].push(name); + } + else { + var includeIndex = findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); }); + if (includeIndex !== -1) { + results[includeIndex].push(name); + } + } + }; for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var current = files_1[_i]; - var name_1 = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); - if ((!extensions || fileExtensionIsAny(name_1, extensions)) && - (!includeFileRegex || includeFileRegex.test(absoluteName)) && - (!excludeRegex || !excludeRegex.test(absoluteName))) { - result.push(name_1); - } + _loop_1(current); } for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var current = directories_1[_b]; - var name_2 = combinePaths(path, current); + var name = combinePaths(path, current); var absoluteName = combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { - visitDirectory(name_2, absoluteName); + visitDirectory(name, absoluteName); } } } @@ -1619,14 +1716,14 @@ var ts; includeBasePaths.push(getIncludeBasePath(absolute)); } includeBasePaths.sort(useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); - var _loop_1 = function (includeBasePath) { + var _loop_2 = function (includeBasePath) { if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { basePaths.push(includeBasePath); } }; for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) { var includeBasePath = includeBasePaths_1[_a]; - _loop_1(includeBasePath); + _loop_2(includeBasePath); } } return basePaths; @@ -1666,13 +1763,13 @@ var ts; var allSupportedExtensions = ts.supportedTypeScriptExtensions.concat(ts.supportedJavascriptExtensions); function getSupportedExtensions(options, extraFileExtensions) { var needAllExtensions = options && options.allowJs; - if (!extraFileExtensions || extraFileExtensions.length === 0) { + if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } - var extensions = (needAllExtensions ? allSupportedExtensions : ts.supportedTypeScriptExtensions).slice(0); + var extensions = allSupportedExtensions.slice(0); for (var _i = 0, extraFileExtensions_1 = extraFileExtensions; _i < extraFileExtensions_1.length; _i++) { var extInfo = extraFileExtensions_1[_i]; - if (needAllExtensions || extInfo.scriptKind === 3) { + if (extensions.indexOf(extInfo.extension) === -1) { extensions.push(extInfo.extension); } } @@ -1703,30 +1800,30 @@ var ts; function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { - return adjustExtensionPriority(i); + return adjustExtensionPriority(i, supportedExtensions); } } return 0; } ts.getExtensionPriority = getExtensionPriority; - function adjustExtensionPriority(extensionPriority) { + function adjustExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2) { return 0; } - else if (extensionPriority < 5) { + else if (extensionPriority < supportedExtensions.length) { return 2; } else { - return 5; + return supportedExtensions.length; } } ts.adjustExtensionPriority = adjustExtensionPriority; - function getNextLowestExtensionPriority(extensionPriority) { + function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) { if (extensionPriority < 2) { return 2; } else { - return 5; + return supportedExtensions.length; } } ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority; @@ -2073,32 +2170,32 @@ var ts; var useNonPollingWatchers = process.env["TSC_NONPOLLING_WATCHER"]; function createWatchedFileSet() { var dirWatchers = ts.createMap(); - var fileWatcherCallbacks = ts.createMap(); + var fileWatcherCallbacks = ts.createMultiMap(); return { addFile: addFile, removeFile: removeFile }; function reduceDirWatcherRefCountForFile(fileName) { var dirName = ts.getDirectoryPath(fileName); - var watcher = dirWatchers[dirName]; + var watcher = dirWatchers.get(dirName); if (watcher) { watcher.referenceCount -= 1; if (watcher.referenceCount <= 0) { watcher.close(); - delete dirWatchers[dirName]; + dirWatchers.delete(dirName); } } } function addDirWatcher(dirPath) { - var watcher = dirWatchers[dirPath]; + var watcher = dirWatchers.get(dirPath); if (watcher) { watcher.referenceCount += 1; return; } watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); watcher.referenceCount = 1; - dirWatchers[dirPath] = watcher; + dirWatchers.set(dirPath, watcher); return; } function addFileWatcherCallback(filePath, callback) { - ts.multiMapAdd(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.add(filePath, callback); } function addFile(fileName, callback) { addFileWatcherCallback(fileName, callback); @@ -2110,16 +2207,19 @@ var ts; reduceDirWatcherRefCountForFile(watchedFile.fileName); } function removeFileWatcherCallback(filePath, callback) { - ts.multiMapRemove(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.remove(filePath, callback); } function fileEventHandler(eventName, relativeFileName, baseDirPath) { var fileName = typeof relativeFileName !== "string" ? undefined : ts.getNormalizedAbsolutePath(relativeFileName, baseDirPath); - if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks[fileName]) { - for (var _i = 0, _a = fileWatcherCallbacks[fileName]; _i < _a.length; _i++) { - var fileCallback = _a[_i]; - fileCallback(fileName); + if ((eventName === "change" || eventName === "rename")) { + var callbacks = fileWatcherCallbacks.get(fileName); + if (callbacks) { + for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) { + var fileCallback = callbacks_1[_i]; + fileCallback(fileName); + } } } } @@ -2184,10 +2284,10 @@ var ts; if (entry === "." || entry === "..") { continue; } - var name_3 = ts.combinePaths(path, entry); + var name = ts.combinePaths(path, entry); var stat = void 0; try { - stat = _fs.statSync(name_3); + stat = _fs.statSync(name); } catch (e) { continue; @@ -2261,7 +2361,7 @@ var ts; }, watchDirectory: function (directoryName, callback, recursive) { var options; - if (!directoryExists(directoryName)) { + if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { return noOpFileWatcher; } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { @@ -2276,6 +2376,9 @@ var ts; } ; }); + function isUNCPath(s) { + return s.length > 2 && s.charCodeAt(0) === 47 && s.charCodeAt(1) === 47; + } }, resolvePath: function (path) { return _path.resolve(path); @@ -2475,7 +2578,7 @@ var ts; _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, 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." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." }, 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." }, @@ -2586,6 +2689,7 @@ var ts; 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." }, + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", message: "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules." }, 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_Set_the_experimentalDecorators_option_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_Set_t_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", message: "Generators are only available when targeting ECMAScript 2015 or higher." }, @@ -2632,6 +2736,7 @@ var ts; Global_module_exports_may_only_appear_at_top_level: { code: 1316, category: ts.DiagnosticCategory.Error, key: "Global_module_exports_may_only_appear_at_top_level_1316", message: "Global module exports may only appear at top level." }, A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, 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." }, @@ -2861,6 +2966,10 @@ var ts; Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, + Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: { code: 2543, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", message: "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference." }, + Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, + A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: { code: 2545, category: ts.DiagnosticCategory.Error, key: "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", message: "A mixin class must have a constructor with a single rest parameter of type 'any[]'." }, + Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: { code: 2546, category: ts.DiagnosticCategory.Error, key: "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", message: "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union 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." }, @@ -2870,6 +2979,8 @@ var ts; 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" }, + JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, + Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: { code: 2649, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", message: "Cannot augment module '{0}' with value exports because it resolves to a non-module entity." }, 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." }, @@ -2918,9 +3029,15 @@ var ts; The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { code: 2696, category: ts.DiagnosticCategory.Error, key: "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", message: "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?" }, An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, + Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: { code: 2699, category: ts.DiagnosticCategory.Error, key: "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", message: "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'." }, Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, + An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: { code: 2705, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", message: "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option." }, + Required_type_parameters_may_not_follow_optional_type_parameters: { code: 2706, category: ts.DiagnosticCategory.Error, key: "Required_type_parameters_may_not_follow_optional_type_parameters_2706", message: "Required type parameters may not follow optional type parameters." }, + Generic_type_0_requires_between_1_and_2_type_arguments: { code: 2707, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_between_1_and_2_type_arguments_2707", message: "Generic type '{0}' requires between {1} and {2} type arguments." }, 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}'." }, @@ -2931,8 +3048,8 @@ var ts; 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}'." }, + 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}'." }, @@ -2995,6 +3112,7 @@ var ts; Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { code: 4090, category: ts.DiagnosticCategory.Message, key: "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", message: "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", message: "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'." }, Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4092, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", message: "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'." }, + extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced: { code: 4093, category: ts.DiagnosticCategory.Error, key: "extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced_4093", message: "'extends' clause of exported class '{0}' refers to a type whose name cannot be referenced." }, 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." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, @@ -3040,7 +3158,7 @@ var ts; 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." }, + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'" }, 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" }, @@ -3055,6 +3173,7 @@ var ts; LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION_6037", message: "LOCATION" }, DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY_6038", message: "DIRECTORY" }, STRATEGY: { code: 6039, category: ts.DiagnosticCategory.Message, key: "STRATEGY_6039", message: "STRATEGY" }, + FILE_OR_DIRECTORY: { code: 6040, category: ts.DiagnosticCategory.Message, key: "FILE_OR_DIRECTORY_6040", message: "FILE OR 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." }, @@ -3088,7 +3207,8 @@ var ts; 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_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, - 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'" }, + Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'" }, + File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, @@ -3102,12 +3222,12 @@ var ts; Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, - Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", message: "Loading module as file / folder, candidate module location '{0}', target file type '{1}'." }, File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, - Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Loading_module_0_from_node_modules_folder_target_file_type_1: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", message: "Loading module '{0}' from 'node_modules' folder, target file type '{1}'." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, - package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, + package_json_does_not_have_a_0_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_0_field_6100", message: "'package.json' does not have a '{0}' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, @@ -3144,7 +3264,6 @@ var ts; Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, - No_types_specified_in_package_json_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json', so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, @@ -3154,6 +3273,8 @@ var ts; Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, + Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, + Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, 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." }, @@ -3195,7 +3316,7 @@ var ts; 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." }, 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." }, - 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." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: { 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' clause." }, 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." }, Language_service_is_disabled: { code: 9004, category: ts.DiagnosticCategory.Error, key: "Language_service_is_disabled_9004", message: "Language service is disabled." }, 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'." }, @@ -3210,22 +3331,26 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, - Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, - Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, - Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, - Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, + Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: {0}" }, + Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, + Add_this_to_unresolved_variable: { code: 90008, category: ts.DiagnosticCategory.Message, key: "Add_this_to_unresolved_variable_90008", message: "Add 'this.' to unresolved variable." }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, + Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, }; })(ts || (ts = {})); var ts; @@ -3234,7 +3359,7 @@ var ts; return token >= 70; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = ts.createMap({ + var textToToken = ts.createMapFromTemplate({ "abstract": 116, "any": 118, "as": 117, @@ -3258,7 +3383,7 @@ var ts; "false": 85, "finally": 86, "for": 87, - "from": 138, + "from": 139, "function": 88, "get": 124, "if": 89, @@ -3276,27 +3401,28 @@ var ts; "new": 93, "null": 94, "number": 132, + "object": 133, "package": 110, "private": 111, "protected": 112, "public": 113, "readonly": 130, "require": 131, - "global": 139, + "global": 140, "return": 95, - "set": 133, + "set": 134, "static": 114, - "string": 134, + "string": 135, "super": 96, "switch": 97, - "symbol": 135, + "symbol": 136, "this": 98, "throw": 99, "true": 100, "try": 101, - "type": 136, + "type": 137, "typeof": 102, - "undefined": 137, + "undefined": 138, "var": 103, "void": 104, "while": 105, @@ -3304,7 +3430,7 @@ var ts; "yield": 115, "async": 119, "await": 120, - "of": 140, + "of": 141, "{": 16, "}": 17, "(": 18, @@ -3399,9 +3525,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var name_4 in source) { - result[source[name_4]] = name_4; - } + source.forEach(function (value, name) { + result[value] = name; + }); return result; } var tokenStrings = makeReverseMap(textToToken); @@ -3410,7 +3536,7 @@ var ts; } ts.tokenToString = tokenToString; function stringToToken(s) { - return textToToken[s]; + return textToToken.get(s); } ts.stringToToken = stringToToken; function computeLineStarts(text) { @@ -3470,7 +3596,6 @@ var ts; return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - var hasOwnProperty = Object.prototype.hasOwnProperty; function isWhiteSpace(ch) { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } @@ -3606,7 +3731,7 @@ var ts; 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++) { + for (var i = 0; i < mergeConflictMarkerLength; i++) { if (text.charCodeAt(pos + i) !== ch) { return false; } @@ -3792,7 +3917,7 @@ var ts; if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { return false; } - for (var i = 1, n = name.length; i < n; i++) { + for (var i = 1; i < name.length; i++) { if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { return false; } @@ -4129,8 +4254,11 @@ var ts; 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]; + if (ch >= 97 && ch <= 122) { + token = textToToken.get(tokenValue); + if (token !== undefined) { + return token; + } } } return token = 70; @@ -4840,12 +4968,13 @@ var ts; }, { name: "jsx", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "preserve": 1, + "react-native": 3, "react": 2 }), paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, }, { name: "reactNamespace", @@ -4875,7 +5004,7 @@ var ts; { name: "module", shortName: "m", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "none": ts.ModuleKind.None, "commonjs": ts.ModuleKind.CommonJS, "amd": ts.ModuleKind.AMD, @@ -4889,7 +5018,7 @@ var ts; }, { name: "newLine", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "crlf": 0, "lf": 1 }), @@ -4986,8 +5115,8 @@ var ts; shortName: "p", type: "string", isFilePath: true, - description: ts.Diagnostics.Compile_the_project_in_the_given_directory, - paramType: ts.Diagnostics.DIRECTORY + description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY }, { name: "removeComments", @@ -5037,7 +5166,7 @@ var ts; { name: "target", shortName: "t", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "es3": 0, "es5": 1, "es6": 2, @@ -5074,7 +5203,7 @@ var ts; }, { name: "moduleResolution", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "node": ts.ModuleResolutionKind.NodeJs, "classic": ts.ModuleResolutionKind.Classic, }), @@ -5179,7 +5308,7 @@ var ts; type: "list", element: { name: "lib", - type: ts.createMap({ + type: ts.createMapFromTemplate({ "es5": "lib.es5.d.ts", "es6": "lib.es2015.d.ts", "es2015": "lib.es2015.d.ts", @@ -5225,6 +5354,15 @@ var ts; name: "alwaysStrict", type: "boolean", description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + }, + { + name: "plugins", + type: "list", + isTSConfigOnly: true, + element: { + name: "plugin", + type: "object" + } } ]; ts.typeAcquisitionDeclarations = [ @@ -5279,9 +5417,9 @@ var ts; var optionNameMap = ts.createMap(); var shortOptionNames = ts.createMap(); ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; + optionNameMap.set(option.name.toLowerCase(), option); if (option.shortName) { - shortOptionNames[option.shortName] = option.name; + shortOptionNames.set(option.shortName, option.name); } }); optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; @@ -5289,7 +5427,7 @@ var ts; } ts.getOptionNameMap = getOptionNameMap; function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; @@ -5338,11 +5476,12 @@ var ts; } else if (s.charCodeAt(0) === 45) { s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); - if (s in shortOptionNames) { - s = shortOptionNames[s]; + var short = shortOptionNames.get(s); + if (short !== undefined) { + s = short; } - if (s in optionNameMap) { - var opt = optionNameMap[s]; + var opt = optionNameMap.get(s); + if (opt) { if (opt.isTSConfigOnly) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); } @@ -5468,19 +5607,18 @@ var ts; } } function getNameOfCompilerOptionValue(value, customTypeMap) { - for (var key in customTypeMap) { - if (customTypeMap[key] === value) { + return ts.forEachEntry(customTypeMap, function (mapValue, key) { + if (mapValue === value) { return key; } - } - return undefined; + }); } function serializeCompilerOptions(options) { - var result = ts.createMap(); + var result = {}; var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_5 in options) { - if (ts.hasProperty(options, name_5)) { - switch (name_5) { + for (var name in options) { + if (ts.hasProperty(options, name)) { + switch (name) { case "init": case "watch": case "version": @@ -5488,12 +5626,12 @@ var ts; case "project": break; default: - var value = options[name_5]; - var optionDefinition = optionsNameMap[name_5.toLowerCase()]; + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { - result[name_5] = value; + result[name] = value; } else { if (optionDefinition.type === "list") { @@ -5502,10 +5640,10 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_5] = convertedValue; + result[name] = convertedValue; } else { - result[name_5] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -5539,6 +5677,7 @@ var ts; if (resolutionStack === void 0) { resolutionStack = []; } if (extraFileExtensions === void 0) { extraFileExtensions = []; } var errors = []; + basePath = ts.normalizeSlashes(basePath); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); if (resolutionStack.indexOf(resolvedPath) >= 0) { @@ -5711,8 +5850,8 @@ var ts; } var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); for (var id in jsonOptions) { - if (id in optionNameMap) { - var opt = optionNameMap[id]; + var opt = optionNameMap.get(id); + if (opt) { defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); } else { @@ -5746,8 +5885,9 @@ var ts; } function convertJsonOptionOfCustomType(opt, value, errors) { var key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; + var val = opt.type.get(key); + if (val !== undefined) { + return val; } else { errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); @@ -5781,7 +5921,7 @@ var ts; for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { var fileName = fileNames_1[_i]; var file = ts.combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; + literalFileMap.set(keyMapper(file), file); } } if (include && include.length > 0) { @@ -5792,14 +5932,13 @@ var ts; } removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); var key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; + if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) { + wildcardFileMap.set(key, file); } } } - var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); - var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); + var literalFiles = ts.arrayFrom(literalFileMap.values()); + var wildcardFiles = ts.arrayFrom(wildcardFileMap.values()); return { fileNames: literalFiles.concat(wildcardFiles), wildcardDirectories: wildcardDirectories @@ -5807,8 +5946,8 @@ var ts; } function validateSpecs(specs, errors, allowTrailingRecursion) { var validSpecs = []; - for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { - var spec = specs_2[_i]; + for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { + var spec = specs_1[_i]; if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); } @@ -5827,7 +5966,7 @@ var ts; function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - var wildcardDirectories = ts.createMap(); + var wildcardDirectories = {}; if (include !== undefined) { var recursiveKeys = []; for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { @@ -5848,14 +5987,16 @@ var ts; } } } - for (var key in wildcardDirectories) { - for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { - var recursiveKey = recursiveKeys_1[_a]; - if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; + for (var key in wildcardDirectories) + if (ts.hasProperty(wildcardDirectories, key)) { + for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { + var recursiveKey = recursiveKeys_1[_a]; + if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; + } } } - } + ; } return wildcardDirectories; } @@ -5874,11 +6015,11 @@ var ts; } function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); + var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions); for (var i = 0; i < adjustedExtensionPriority; i++) { var higherPriorityExtension = extensions[i]; var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { return true; } } @@ -5886,17 +6027,13 @@ var ts; } function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); + var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions); for (var i = nextExtensionPriority; i < extensions.length; i++) { var lowerPriorityExtension = extensions[i]; var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; + wildcardFiles.delete(lowerPriorityPath); } } - function addFileToOutput(output, file) { - output.push(file); - return output; - } function caseSensitiveKeyMapper(key) { return key; } @@ -5932,7 +6069,7 @@ var ts; }); if (!safeList) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); - safeList = result.config ? ts.createMap(result.config) : EmptySafeList; + safeList = result.config ? ts.createMapFromTemplate(result.config) : EmptySafeList; } var filesToWatch = []; var searchDirs = []; @@ -5957,31 +6094,31 @@ var ts; if (unresolvedImports) { for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { var moduleId = unresolvedImports_1[_a]; - var typingName = moduleId in nodeCoreModules ? "node" : moduleId; - if (!(typingName in inferredTypings)) { - inferredTypings[typingName] = undefined; + var typingName = nodeCoreModules.has(moduleId) ? "node" : moduleId; + if (!inferredTypings.has(typingName)) { + inferredTypings.set(typingName, undefined); } } } - for (var name_6 in packageNameToTypingLocation) { - if (name_6 in inferredTypings && !inferredTypings[name_6]) { - inferredTypings[name_6] = packageNameToTypingLocation[name_6]; + packageNameToTypingLocation.forEach(function (typingLocation, name) { + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined) { + inferredTypings.set(name, typingLocation); } - } + }); for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { var excludeTypingName = exclude_1[_b]; - delete inferredTypings[excludeTypingName]; + inferredTypings.delete(excludeTypingName); } var newTypingNames = []; var cachedTypingPaths = []; - for (var typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); + inferredTypings.forEach(function (inferred, typing) { + if (inferred !== undefined) { + cachedTypingPaths.push(inferred); } else { newTypingNames.push(typing); } - } + }); return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; function mergeTypings(typingNames) { if (!typingNames) { @@ -5989,8 +6126,8 @@ var ts; } for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { var typing = typingNames_1[_i]; - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; + if (!inferredTypings.has(typing)) { + inferredTypings.set(typing, undefined); } } } @@ -6020,7 +6157,7 @@ var ts; var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); if (safeList !== EmptySafeList) { - mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); + mergeTypings(ts.filter(cleanedTypingNames, function (f) { return safeList.has(f); })); } var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); if (hasJsxFile) { @@ -6053,7 +6190,7 @@ var ts; } if (packageJson.typings) { var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; + inferredTypings.set(packageJson.name, absolutePath); } else { typingNames.push(packageJson.name); @@ -6102,6 +6239,12 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; + var Extensions; + (function (Extensions) { + Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; + Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; + Extensions[Extensions["DtsOnly"] = 2] = "DtsOnly"; + })(Extensions || (Extensions = {})); function resolvedTypeScriptOnly(resolved) { if (!resolved) { return undefined; @@ -6109,9 +6252,6 @@ var ts; ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); return resolved.path; } - function resolvedFromAnyFile(path) { - return { path: path, extension: ts.extensionFromPath(path) }; - } function resolvedModuleFromResolved(_a, isExternalLibraryImport) { var path = _a.path, extension = _a.extension; return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; @@ -6123,37 +6263,28 @@ var ts; return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; - function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { + function tryReadPackageJsonFields(readTypes, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); - switch (extensions) { - case 2: - case 0: - return tryReadFromField("typings") || tryReadFromField("types"); - case 1: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; - } + return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); - } - return typesFilePath; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } + if (!ts.hasProperty(jsonContent, fieldName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName); } + return; } + var fileName = jsonContent[fieldName]; + if (typeof fileName !== "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof fileName); + } + return; + } + var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path); + } + return path; } } function readJson(path, host) { @@ -6191,6 +6322,7 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } + return undefined; }); return typeRoots; } @@ -6245,7 +6377,11 @@ var ts; return ts.forEach(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + var directoryExists = directoryProbablyExists(candidateDirectory, host); + if (!directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory); + } + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations, !directoryExists, moduleResolutionState)); }); } else { @@ -6261,7 +6397,8 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, undefined); + resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -6302,31 +6439,116 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { + var directoryToModuleNameMap = ts.createFileMap(); + var moduleNameToDirectoryMap = ts.createMap(); + return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; + function getOrCreateCacheForDirectory(directoryName) { + var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); + var perFolderCache = directoryToModuleNameMap.get(path); + if (!perFolderCache) { + perFolderCache = ts.createMap(); + directoryToModuleNameMap.set(path, perFolderCache); + } + return perFolderCache; + } + function getOrCreateCacheForModuleName(nonRelativeModuleName) { + if (!moduleHasNonRelativeName(nonRelativeModuleName)) { + return undefined; + } + var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); + if (!perModuleNameCache) { + perModuleNameCache = createPerModuleNameCache(); + moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); + } + return perModuleNameCache; + } + function createPerModuleNameCache() { + var directoryPathMap = ts.createFileMap(); + return { get: get, set: set }; + function get(directory) { + return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName)); + } + function set(directory, result) { + var path = ts.toPath(directory, currentDirectory, getCanonicalFileName); + if (directoryPathMap.contains(path)) { + return; + } + directoryPathMap.set(path, result); + var resolvedFileName = result.resolvedModule && result.resolvedModule.resolvedFileName; + var commonPrefix = getCommonPrefix(path, resolvedFileName); + var current = path; + while (true) { + var parent = ts.getDirectoryPath(current); + if (parent === current || directoryPathMap.contains(parent)) { + break; + } + directoryPathMap.set(parent, result); + current = parent; + if (current == commonPrefix) { + break; + } + } + } + function getCommonPrefix(directory, resolution) { + if (resolution === undefined) { + return undefined; + } + var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName); + var i = 0; + while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) { + i++; + } + var sep = directory.lastIndexOf(ts.directorySeparator, i); + if (sep < 0) { + return undefined; + } + return directory.substr(0, sep); + } + } + } + ts.createModuleResolutionCache = createModuleResolutionCache; + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + var containingDirectory = ts.getDirectoryPath(containingFile); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var result = perFolderCache && perFolderCache.get(moduleName); + if (result) { if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + break; + } + if (perFolderCache) { + perFolderCache.set(moduleName, result); + var perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); + if (perModuleNameCache) { + perModuleNameCache.set(containingDirectory, result); + } } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; } if (traceEnabled) { if (result.resolvedModule) { @@ -6451,37 +6673,43 @@ var ts; return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, false); + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, jsOnly) { + if (jsOnly === void 0) { jsOnly = false; } var containingDirectory = ts.getDirectoryPath(containingFile); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; - var result = tryResolve(0) || tryResolve(1); - if (result) { - var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + var result = jsOnly ? tryResolve(Extensions.JavaScript) : (tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript)); + if (result && result.value) { + var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); } return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; function tryResolve(extensions) { - var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); + var loader = function (extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, true); }; + var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); if (resolved) { - return { resolved: resolved, isExternalLibraryImport: false }; + return toSearchResult({ resolved: resolved, isExternalLibraryImport: false }); } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); - return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, cache); + return resolved_1 && { value: resolved_1.value && { resolved: { path: realpath(resolved_1.value.path, host, traceEnabled), extension: resolved_1.value.extension }, isExternalLibraryImport: true } }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); - return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state, true); + return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: false }); } } } - ts.nodeModuleNameResolver = nodeModuleNameResolver; + ts.nodeModuleNameResolverWorker = nodeModuleNameResolverWorker; function realpath(path, host, traceEnabled) { if (!host.realpath) { return path; @@ -6492,12 +6720,35 @@ var ts; } return real; } - function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } - var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); - return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (!ts.pathEndsWithDirectorySeparator(candidate)) { + if (!onlyRecordFailures) { + var parentOfCandidate = ts.getDirectoryPath(candidate); + if (!directoryProbablyExists(parentOfCandidate, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); + } + onlyRecordFailures = true; + } + } + var resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + if (resolvedFromFile) { + return resolvedFromFile; + } + } + if (!onlyRecordFailures) { + var candidateExists = directoryProbablyExists(candidate, state.host); + if (!candidateExists) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); + } + onlyRecordFailures = true; + } + } + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson); } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); @@ -6525,11 +6776,11 @@ var ts; } } switch (extensions) { - case 2: + case Extensions.DtsOnly: return tryExtension(".d.ts", ts.Extension.Dts); - case 0: + case Extensions.TypeScript: return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); - case 1: + case Extensions.JavaScript: return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } function tryExtension(ext, extension) { @@ -6538,113 +6789,168 @@ var ts; } } function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); - } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); - } - failedLookupLocations.push(fileName); - return undefined; - } - } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); - if (fromFile) { - return resolvedFromAnyFile(fromFile); - } - var x = tryAddingExtensions(typesFile, 0, failedLookupLocations, onlyRecordFailures_1, state); - if (x) { - return x; + if (!onlyRecordFailures) { + if (state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); } + return fileName; } else { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); } } } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + failedLookupLocations.push(fileName); + return undefined; + } + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { + if (considerPackageJson === void 0) { considerPackageJson = true; } + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (considerPackageJson) { + var packageJsonPath = pathToPackageJson(candidate); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + var fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; + } + } + else { + if (directoryExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + } + failedLookupLocations.push(packageJsonPath); } - failedLookupLocations.push(packageJsonPath); } return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + if (!file) { + return undefined; + } + var onlyRecordFailures = !directoryProbablyExists(ts.getDirectoryPath(file), state.host); + var fromFile = tryFile(file, failedLookupLocations, onlyRecordFailures, state); + if (fromFile) { + var resolved = fromFile && resolvedIfExtensionMatches(extensions, fromFile); + if (resolved) { + return resolved; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile); + } + } + var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; + return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, false); + } + function resolvedIfExtensionMatches(extensions, path) { + var extension = ts.tryGetExtensionFromPath(path); + return extension !== undefined && extensionIsOk(extensions, extension) ? { path: path, extension: extension } : undefined; + } + function extensionIsOk(extensions, extension) { + switch (extensions) { + case Extensions.JavaScript: + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; + case Extensions.TypeScript: + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; + case Extensions.DtsOnly: + return extension === ts.Extension.Dts; + } + } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false, cache); } function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(2, moduleName, directory, failedLookupLocations, state, true); + return loadModuleFromNodeModulesWorker(Extensions.DtsOnly, moduleName, directory, failedLookupLocations, state, true, undefined); } - function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly, cache) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { - return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state.traceEnabled, state.host); + if (resolutionFromCache) { + return resolutionFromCache; + } + return toSearchResult(loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly)); } }); } function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { if (typesOnly === void 0) { typesOnly = false; } - var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + if (!nodeModulesFolderExists && state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); + } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state); if (packageResult) { return packageResult; } - if (extensions !== 1) { - return loadModuleFromNodeModulesFolder(2, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (extensions !== Extensions.JavaScript) { + var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); + var nodeModulesAtTypesExists = nodeModulesFolderExists; + if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1); + } + nodeModulesAtTypesExists = false; + } + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { + var result = cache && cache.get(containingDirectory); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); + } + return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; + } + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { var traceEnabled = isTraceEnabled(compilerOptions, host); var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; var containingDirectory = ts.getDirectoryPath(containingFile); - var resolved = tryResolve(0) || tryResolve(1); - return createResolvedModuleWithFailedLookupLocations(resolved, false, failedLookupLocations); + var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); if (resolvedUsingSettings) { - return resolvedUsingSettings; + return { value: resolvedUsingSettings }; } + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); + if (resolutionFromCache) { + return resolutionFromCache; + } var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); - return loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); }); if (resolved_3) { return resolved_3; } - if (extensions === 0) { + if (extensions === Extensions.TypeScript) { return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - return loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state); + return toSearchResult(loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state)); } } } @@ -6656,10 +6962,13 @@ var ts; } var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var resolved = loadModuleFromNodeModulesOneLevel(2, moduleName, globalCache, failedLookupLocations, state); + var resolved = loadModuleFromNodeModulesOneLevel(Extensions.DtsOnly, moduleName, globalCache, failedLookupLocations, state); return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + function toSearchResult(value) { + return value !== undefined ? { value: value } : undefined; + } function forEachAncestorDirectory(directory, callback) { while (true) { var result = callback(directory); @@ -6756,7 +7065,7 @@ var ts; if (this.log.isEnabled()) { this.log.writeLine("Closing file watchers for project '" + projectName + "'"); } - var watchers = this.projectWatchers[projectName]; + var watchers = this.projectWatchers.get(projectName); if (!watchers) { if (this.log.isEnabled()) { this.log.writeLine("No watchers are registered for project '" + projectName + "'"); @@ -6767,7 +7076,7 @@ var ts; var w = watchers_1[_i]; w.close(); } - delete this.projectWatchers[projectName]; + this.projectWatchers.delete(projectName); if (this.log.isEnabled()) { this.log.writeLine("Closing file watchers for project '" + projectName + "' - done."); } @@ -6801,7 +7110,7 @@ var ts; if (this.log.isEnabled()) { this.log.writeLine("Processing cache location '" + cacheLocation + "'"); } - if (this.knownCachesSet[cacheLocation]) { + if (this.knownCachesSet.get(cacheLocation)) { if (this.log.isEnabled()) { this.log.writeLine("Cache location was already processed..."); } @@ -6824,10 +7133,10 @@ var ts; } var typingFile = typingToFileName(cacheLocation, packageName, this.installTypingHost, this.log); if (!typingFile) { - this.missingTypingsSet[packageName] = true; + this.missingTypingsSet.set(packageName, true); continue; } - var existingTypingFile = this.packageNameToTypingLocation[packageName]; + var existingTypingFile = this.packageNameToTypingLocation.get(packageName); if (existingTypingFile === typingFile) { continue; } @@ -6839,14 +7148,14 @@ var ts; if (this.log.isEnabled()) { this.log.writeLine("Adding entry into typings cache: '" + packageName + "' => '" + typingFile + "'"); } - this.packageNameToTypingLocation[packageName] = typingFile; + this.packageNameToTypingLocation.set(packageName, typingFile); } } } if (this.log.isEnabled()) { this.log.writeLine("Finished processing cache location '" + cacheLocation + "'"); } - this.knownCachesSet[cacheLocation] = true; + this.knownCachesSet.set(cacheLocation, true); }; TypingsInstaller.prototype.filterTypings = function (typingsToInstall) { if (typingsToInstall.length === 0) { @@ -6855,12 +7164,12 @@ var ts; var result = []; for (var _i = 0, typingsToInstall_1 = typingsToInstall; _i < typingsToInstall_1.length; _i++) { var typing = typingsToInstall_1[_i]; - if (this.missingTypingsSet[typing] || this.packageNameToTypingLocation[typing]) { + if (this.missingTypingsSet.get(typing) || this.packageNameToTypingLocation.get(typing)) { continue; } var validationResult = validatePackageName(typing); if (validationResult === PackageNameValidationResult.Ok) { - if (typing in this.typesRegistry) { + if (this.typesRegistry.has(typing)) { result.push(typing); } else { @@ -6870,7 +7179,7 @@ var ts; } } else { - this.missingTypingsSet[typing] = true; + this.missingTypingsSet.set(typing, true); if (this.log.isEnabled()) { switch (validationResult) { case PackageNameValidationResult.EmptyName: @@ -6916,8 +7225,7 @@ var ts; this.log.writeLine("Installing typings " + JSON.stringify(typingsToInstall)); } var filteredTypings = this.filterTypings(typingsToInstall); - var scopedTypings = filteredTypings.map(function (x) { return "@types/" + x; }); - if (scopedTypings.length === 0) { + if (filteredTypings.length === 0) { if (this.log.isEnabled()) { this.log.writeLine("All typings are known to be missing or invalid - no need to go any further"); } @@ -6932,6 +7240,7 @@ var ts; typingsInstallerVersion: ts.version, projectName: req.projectName }); + var scopedTypings = filteredTypings.map(typingsName); this.installTypingsAsync(requestId, scopedTypings, cachePath, function (ok) { try { if (!ok) { @@ -6940,7 +7249,7 @@ var ts; } for (var _i = 0, filteredTypings_1 = filteredTypings; _i < filteredTypings_1.length; _i++) { var typing = filteredTypings_1[_i]; - _this.missingTypingsSet[typing] = true; + _this.missingTypingsSet.set(typing, true); } return; } @@ -6952,11 +7261,11 @@ var ts; var packageName = filteredTypings_2[_a]; var typingFile = typingToFileName(cachePath, packageName, _this.installTypingHost, _this.log); if (!typingFile) { - _this.missingTypingsSet[packageName] = true; + _this.missingTypingsSet.set(packageName, true); continue; } - if (!_this.packageNameToTypingLocation[packageName]) { - _this.packageNameToTypingLocation[packageName] = typingFile; + if (!_this.packageNameToTypingLocation.has(packageName)) { + _this.packageNameToTypingLocation.set(packageName, typingFile); } installedTypingFiles.push(typingFile); } @@ -7007,7 +7316,7 @@ var ts; }, 2000); watchers.push(w); } - this.projectWatchers[projectName] = watchers; + this.projectWatchers.set(projectName, watchers); }; TypingsInstaller.prototype.createSetTypings = function (request, typings) { return { @@ -7025,7 +7334,7 @@ var ts; }; TypingsInstaller.prototype.executeWithThrottling = function () { var _this = this; - var _loop_2 = function () { + var _loop_3 = function () { this_1.inFlightRequestCount++; var request = this_1.pendingRunRequests.pop(); this_1.installWorker(request.requestId, request.args, request.cwd, function (ok) { @@ -7036,12 +7345,17 @@ var ts; }; var this_1 = this; while (this.inFlightRequestCount < this.throttleLimit && this.pendingRunRequests.length) { - _loop_2(); + _loop_3(); } }; return TypingsInstaller; }()); typingsInstaller.TypingsInstaller = TypingsInstaller; + function typingsName(packageName) { + return "@types/" + packageName + "@ts" + versionMajorMinor; + } + typingsInstaller.typingsName = typingsName; + var versionMajorMinor = ts.version.split(".").slice(0, 2).join("."); })(typingsInstaller = server.typingsInstaller || (server.typingsInstaller = {})); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); @@ -7082,7 +7396,7 @@ var ts; } try { var content = JSON.parse(host.readFile(typesRegistryFilePath)); - return ts.createMap(content.entries); + return ts.createMapFromTemplate(content.entries); } catch (e) { if (log.isEnabled()) { diff --git a/package.json b/package.json index fdb85ea764b..3ffab4bfb13 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "http://typescriptlang.org/", - "version": "2.2.0", + "version": "2.3.0", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ @@ -60,7 +60,7 @@ "gulp-insert": "latest", "gulp-newer": "latest", "gulp-sourcemaps": "latest", - "gulp-typescript": "latest", + "gulp-typescript": "3.1.5", "into-stream": "latest", "istanbul": "latest", "jake": "latest", diff --git a/scripts/buildProtocol.ts b/scripts/buildProtocol.ts index 66f29f577d9..37ebd0105ae 100644 --- a/scripts/buildProtocol.ts +++ b/scripts/buildProtocol.ts @@ -167,7 +167,7 @@ function generateProtocolFile(protocolTs: string, typeScriptServicesDts: string) const sanityCheckProgram = getProgramWithProtocolText(protocolDts, /*includeTypeScriptServices*/ false); const diagnostics = [...sanityCheckProgram.getSyntacticDiagnostics(), ...sanityCheckProgram.getSemanticDiagnostics(), ...sanityCheckProgram.getGlobalDiagnostics()]; if (diagnostics.length) { - const flattenedDiagnostics = diagnostics.map(d => ts.flattenDiagnosticMessageText(d.messageText, "\n")).join("\n"); + const flattenedDiagnostics = diagnostics.map(d => `${ts.flattenDiagnosticMessageText(d.messageText, "\n")} at ${d.file.fileName} line ${d.start}`).join("\n"); throw new Error(`Unexpected errors during sanity check: ${flattenedDiagnostics}`); } return protocolDts; diff --git a/scripts/processDiagnosticMessages.ts b/scripts/processDiagnosticMessages.ts index e5eaa46c8e5..db7a9e0f1f2 100644 --- a/scripts/processDiagnosticMessages.ts +++ b/scripts/processDiagnosticMessages.ts @@ -27,7 +27,7 @@ function main(): void { var inputFilePath = sys.args[0].replace(/\\/g, "/"); var inputStr = sys.readFile(inputFilePath); - + var diagnosticMessages: InputDiagnosticMessageTable = JSON.parse(inputStr); var names = Utilities.getObjectKeys(diagnosticMessages); @@ -44,7 +44,7 @@ function main(): void { function checkForUniqueCodes(messages: string[], diagnosticTable: InputDiagnosticMessageTable) { const originalMessageForCode: string[] = []; let numConflicts = 0; - + for (const currentMessage of messages) { const code = diagnosticTable[currentMessage].code; @@ -74,7 +74,7 @@ function buildUniqueNameMap(names: string[]): ts.Map { var uniqueNames = NameGenerator.ensureUniqueness(names, /* isCaseSensitive */ false, /* isFixed */ undefined); for (var i = 0; i < names.length; i++) { - nameMap[names[i]] = uniqueNames[i]; + nameMap.set(names[i], uniqueNames[i]); } return nameMap; @@ -91,7 +91,7 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap: for (var i = 0; i < names.length; i++) { var name = names[i]; var diagnosticDetails = messageTable[name]; - var propName = convertPropertyName(nameMap[name]); + var propName = convertPropertyName(nameMap.get(name)); result += ' ' + propName + @@ -114,7 +114,7 @@ function buildDiagnosticMessageOutput(messageTable: InputDiagnosticMessageTable, for (var i = 0; i < names.length; i++) { var name = names[i]; var diagnosticDetails = messageTable[name]; - var propName = convertPropertyName(nameMap[name]); + var propName = convertPropertyName(nameMap.get(name)); result += '\r\n "' + createKey(propName, diagnosticDetails.code) + '"' + ' : "' + name.replace(/[\"]/g, '\\"') + '"'; if (i !== names.length - 1) { diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 275f7cfe38b..51830c50bfe 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -265,6 +265,7 @@ namespace ts { return "export="; case SpecialPropertyAssignmentKind.ExportsProperty: case SpecialPropertyAssignmentKind.ThisProperty: + case SpecialPropertyAssignmentKind.Property: // exports.x = ... or this.y = ... return ((node as BinaryExpression).left as PropertyAccessExpression).name.text; case SpecialPropertyAssignmentKind.PrototypeProperty: @@ -349,17 +350,20 @@ namespace ts { // Otherwise, we'll be merging into a compatible existing symbol (for example when // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. - symbol = symbolTable[name] || (symbolTable[name] = createSymbol(SymbolFlags.None, name)); + symbol = symbolTable.get(name); + if (!symbol) { + symbolTable.set(name, symbol = createSymbol(SymbolFlags.None, name)); + } if (name && (includes & SymbolFlags.Classifiable)) { - classifiableNames[name] = name; + classifiableNames.set(name, name); } if (symbol.flags & excludes) { if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. - symbol = symbolTable[name] = createSymbol(SymbolFlags.None, name); + symbolTable.set(name, symbol = createSymbol(SymbolFlags.None, name)); } else { if (node.name) { @@ -953,6 +957,9 @@ namespace ts { const postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; + if (node.kind === SyntaxKind.ForOfStatement) { + bind(node.awaitModifier); + } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); @@ -1042,7 +1049,35 @@ namespace ts { if (node.finallyBlock) { // in finally flow is combined from pre-try/flow from try/flow from catch // pre-flow is necessary to make sure that finally is reachable even if finally flows in both try and finally blocks are unreachable - addAntecedent(preFinallyLabel, preTryFlow); + + // also for finally blocks we inject two extra edges into the flow graph. + // first -> edge that connects pre-try flow with the label at the beginning of the finally block, it has lock associated with it + // second -> edge that represents post-finally flow. + // these edges are used in following scenario: + // let a; (1) + // try { a = someOperation(); (2)} + // finally { (3) console.log(a) } (4) + // (5) a + + // flow graph for this case looks roughly like this (arrows show ): + // (1-pre-try-flow) <--.. <-- (2-post-try-flow) + // ^ ^ + // |*****(3-pre-finally-label) -----| + // ^ + // |-- ... <-- (4-post-finally-label) <--- (5) + // In case when we walk the flow starting from inside the finally block we want to take edge '*****' into account + // since it ensures that finally is always reachable. However when we start outside the finally block and go through label (5) + // then edge '*****' should be discarded because label 4 is only reachable if post-finally label-4 is reachable + // Simply speaking code inside finally block is treated as reachable as pre-try-flow + // since we conservatively assume that any line in try block can throw or return in which case we'll enter finally. + // However code after finally is reachable only if control flow was not abrupted in try/catch or finally blocks - it should be composed from + // final flows of these blocks without taking pre-try flow into account. + // + // extra edges that we inject allows to control this behavior + // if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped. + const preFinallyFlow: PreFinallyFlow = { flags: FlowFlags.PreFinally, antecedent: preTryFlow, lock: {} }; + addAntecedent(preFinallyLabel, preFinallyFlow); + currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); // if flow after finally is unreachable - keep it @@ -1058,6 +1093,11 @@ namespace ts { : unreachableFlow; } } + if (!(currentFlow.flags & FlowFlags.Unreachable)) { + const afterFinallyFlow: AfterFinallyFlow = { flags: FlowFlags.AfterFinally, antecedent: currentFlow }; + preFinallyFlow.lock = afterFinallyFlow; + currentFlow = afterFinallyFlow; + } } else { currentFlow = finishFlowLabel(preFinallyLabel); @@ -1328,6 +1368,7 @@ namespace ts { case SyntaxKind.TypeLiteral: case SyntaxKind.JSDocTypeLiteral: case SyntaxKind.JSDocRecordType: + case SyntaxKind.JsxAttributes: return ContainerFlags.IsContainer; case SyntaxKind.InterfaceDeclaration: @@ -1434,6 +1475,7 @@ namespace ts { case SyntaxKind.InterfaceDeclaration: case SyntaxKind.JSDocRecordType: case SyntaxKind.JSDocTypeLiteral: + case SyntaxKind.JsxAttributes: // 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 @@ -1509,7 +1551,7 @@ namespace ts { errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (isExternalModuleAugmentation(node)) { - declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes); + declareModuleSymbol(node); } else { let pattern: Pattern | undefined; @@ -1531,12 +1573,8 @@ namespace ts { } } else { - const state = getModuleInstanceState(node); - if (state === ModuleInstanceState.NonInstantiated) { - declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes); - } - else { - declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); + const state = declareModuleSymbol(node); + if (state !== ModuleInstanceState.NonInstantiated) { if (node.symbol.flags & (SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.RegularEnum)) { // if module was already merged with some function, class or non-const enum // treat is a non-const-enum-only @@ -1557,6 +1595,15 @@ namespace ts { } } + function declareModuleSymbol(node: ModuleDeclaration): ModuleInstanceState { + const state = getModuleInstanceState(node); + const instantiated = state !== ModuleInstanceState.NonInstantiated; + declareSymbolAndAddToSymbolTable(node, + instantiated ? SymbolFlags.ValueModule : SymbolFlags.NamespaceModule, + instantiated ? SymbolFlags.ValueModuleExcludes : SymbolFlags.NamespaceModuleExcludes); + return state; + } + function bindFunctionOrConstructorType(node: SignatureDeclaration): void { // For a given function symbol "<...>(...) => T" we want to generate a symbol identical // to the one we would get for: { <...>(...): T } @@ -1570,7 +1617,7 @@ namespace ts { const typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral); typeLiteralSymbol.members = createMap(); - typeLiteralSymbol.members[symbol.name] = symbol; + typeLiteralSymbol.members.set(symbol.name, symbol); } function bindObjectLiteralExpression(node: ObjectLiteralExpression) { @@ -1601,9 +1648,9 @@ namespace ts { ? ElementKind.Property : ElementKind.Accessor; - const existingKind = seen[identifier.text]; + const existingKind = seen.get(identifier.text); if (!existingKind) { - seen[identifier.text] = currentKind; + seen.set(identifier.text, currentKind); continue; } @@ -1618,6 +1665,14 @@ namespace ts { return bindAnonymousDeclaration(node, SymbolFlags.ObjectLiteral, "__object"); } + function bindJsxAttributes(node: JsxAttributes) { + return bindAnonymousDeclaration(node, SymbolFlags.ObjectLiteral, "__jsxAttributes"); + } + + function bindJsxAttribute(node: JsxAttribute, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { + return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); + } + function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: string) { const symbol = createSymbol(symbolFlags, name); addDeclarationToSymbol(symbol, node, symbolFlags); @@ -1918,6 +1973,9 @@ namespace ts { case SpecialPropertyAssignmentKind.ThisProperty: bindThisPropertyAssignment(node); break; + case SpecialPropertyAssignmentKind.Property: + bindStaticPropertyAssignment(node); + break; case SpecialPropertyAssignmentKind.None: // Nothing to do break; @@ -2039,6 +2097,12 @@ namespace ts { case SyntaxKind.ModuleDeclaration: return bindModuleDeclaration(node); + // Jsx-attributes + case SyntaxKind.JsxAttributes: + return bindJsxAttributes(node); + case SyntaxKind.JsxAttribute: + return bindJsxAttribute(node, SymbolFlags.Property, SymbolFlags.PropertyExcludes); + // Imports and exports case SyntaxKind.ImportEqualsDeclaration: case SyntaxKind.NamespaceImport: @@ -2208,18 +2272,41 @@ namespace ts { constructorFunction.parent = classPrototype; classPrototype.parent = leftSideOfAssignment; - const funcSymbol = container.locals[constructorFunction.text]; - if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) { + bindPropertyAssignment(constructorFunction.text, leftSideOfAssignment, /*isPrototypeProperty*/ true); + } + + function bindStaticPropertyAssignment(node: BinaryExpression) { + // We saw a node of the form 'x.y = z'. Declare a 'member' y on x if x was a function. + + // Look up the function in the local scope, since prototype assignments should + // follow the function declaration + const leftSideOfAssignment = node.left as PropertyAccessExpression; + const target = leftSideOfAssignment.expression as Identifier; + + // Fix up parent pointers since we're going to use these nodes before we bind into them + leftSideOfAssignment.parent = node; + target.parent = leftSideOfAssignment; + + bindPropertyAssignment(target.text, leftSideOfAssignment, /*isPrototypeProperty*/ false); + } + + function bindPropertyAssignment(functionName: string, propertyAccessExpression: PropertyAccessExpression, isPrototypeProperty: boolean) { + let targetSymbol = container.locals.get(functionName); + if (targetSymbol && isDeclarationOfFunctionOrClassExpression(targetSymbol)) { + targetSymbol = (targetSymbol.valueDeclaration as VariableDeclaration).initializer.symbol; + } + + if (!targetSymbol || !(targetSymbol.flags & (SymbolFlags.Function | SymbolFlags.Class))) { return; } // Set up the members collection if it doesn't exist already - if (!funcSymbol.members) { - funcSymbol.members = createMap(); - } + const symbolTable = isPrototypeProperty ? + (targetSymbol.members || (targetSymbol.members = createMap())) : + (targetSymbol.exports || (targetSymbol.exports = createMap())); // Declare the method/property - declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, SymbolFlags.Property, SymbolFlags.PropertyExcludes); + declareSymbol(symbolTable, targetSymbol, propertyAccessExpression, SymbolFlags.Property, SymbolFlags.PropertyExcludes); } function bindCallExpression(node: CallExpression) { @@ -2239,7 +2326,7 @@ namespace ts { bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName); // Add name of class expression into the map for semantic classifier if (node.name) { - classifiableNames[node.name.text] = node.name.text; + classifiableNames.set(node.name.text, node.name.text); } } @@ -2255,14 +2342,14 @@ namespace ts { // module might have an exported variable called 'prototype'. We can't allow that as // that would clash with the built-in 'prototype' for the class. const prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype"); - if (symbol.exports[prototypeSymbol.name]) { + const symbolExport = symbol.exports.get(prototypeSymbol.name); + if (symbolExport) { if (node.name) { node.name.parent = node; } - file.bindDiagnostics.push(createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], - Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); + file.bindDiagnostics.push(createDiagnosticForNode(symbolExport.declarations[0], Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; + symbol.exports.set(prototypeSymbol.name, prototypeSymbol); prototypeSymbol.parent = symbol; } @@ -2323,7 +2410,7 @@ namespace ts { function bindFunctionDeclaration(node: FunctionDeclaration) { if (!isDeclarationFile(file) && !isInAmbientContext(node)) { - if (isAsyncFunctionLike(node)) { + if (isAsyncFunction(node)) { emitFlags |= NodeFlags.HasAsyncFunctions; } } @@ -2340,7 +2427,7 @@ namespace ts { function bindFunctionExpression(node: FunctionExpression) { if (!isDeclarationFile(file) && !isInAmbientContext(node)) { - if (isAsyncFunctionLike(node)) { + if (isAsyncFunction(node)) { emitFlags |= NodeFlags.HasAsyncFunctions; } } @@ -2354,7 +2441,7 @@ namespace ts { function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { if (!isDeclarationFile(file) && !isInAmbientContext(node)) { - if (isAsyncFunctionLike(node)) { + if (isAsyncFunction(node)) { emitFlags |= NodeFlags.HasAsyncFunctions; } } @@ -2788,11 +2875,10 @@ namespace ts { // An async method declaration is ES2017 syntax. if (hasModifier(node, ModifierFlags.Async)) { - transformFlags |= TransformFlags.AssertES2017; + transformFlags |= node.asteriskToken ? TransformFlags.AssertESNext : TransformFlags.AssertES2017; } - // Currently, we only support generators that were originally async function bodies. - if (node.asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { + if (node.asteriskToken) { transformFlags |= TransformFlags.AssertGenerator; } @@ -2858,7 +2944,7 @@ namespace ts { // An async function declaration is ES2017 syntax. if (modifierFlags & ModifierFlags.Async) { - transformFlags |= TransformFlags.AssertES2017; + transformFlags |= node.asteriskToken ? TransformFlags.AssertESNext : TransformFlags.AssertES2017; } // function declarations with object rest destructuring are ES Next syntax @@ -2878,7 +2964,7 @@ namespace ts { // down-level generator. // Currently we do not support transforming any other generator fucntions // down level. - if (node.asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { + if (node.asteriskToken) { transformFlags |= TransformFlags.AssertGenerator; } } @@ -2900,7 +2986,7 @@ namespace ts { // An async function expression is ES2017 syntax. if (hasModifier(node, ModifierFlags.Async)) { - transformFlags |= TransformFlags.AssertES2017; + transformFlags |= node.asteriskToken ? TransformFlags.AssertESNext : TransformFlags.AssertES2017; } // function expressions with object rest destructuring are ES Next syntax @@ -2919,9 +3005,7 @@ namespace ts { // If a FunctionExpression is generator function and is the body of a // transformed async function, then this node can be transformed to a // down-level generator. - // Currently we do not support transforming any other generator fucntions - // down level. - if (node.asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { + if (node.asteriskToken) { transformFlags |= TransformFlags.AssertGenerator; } @@ -3089,8 +3173,8 @@ namespace ts { switch (kind) { case SyntaxKind.AsyncKeyword: case SyntaxKind.AwaitExpression: - // async/await is ES2017 syntax - transformFlags |= TransformFlags.AssertES2017; + // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) + transformFlags |= TransformFlags.AssertESNext | TransformFlags.AssertES2017; break; case SyntaxKind.PublicKeyword: @@ -3115,16 +3199,13 @@ namespace ts { case SyntaxKind.JsxText: case SyntaxKind.JsxClosingElement: case SyntaxKind.JsxAttribute: + case SyntaxKind.JsxAttributes: case SyntaxKind.JsxSpreadAttribute: case SyntaxKind.JsxExpression: // These nodes are Jsx syntax. transformFlags |= TransformFlags.AssertJsx; break; - case SyntaxKind.ForOfStatement: - // for-of might be ESNext if it has a rest destructuring - transformFlags |= TransformFlags.AssertESNext; - // FALLTHROUGH case SyntaxKind.NoSubstitutionTemplateLiteral: case SyntaxKind.TemplateHead: case SyntaxKind.TemplateMiddle: @@ -3138,14 +3219,24 @@ namespace ts { transformFlags |= TransformFlags.AssertES2015; break; + case SyntaxKind.ForOfStatement: + // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). + if ((node).awaitModifier) { + transformFlags |= TransformFlags.AssertESNext; + } + transformFlags |= TransformFlags.AssertES2015; + break; + case SyntaxKind.YieldExpression: - // This node is ES6 syntax. - transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsYield; + // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async + // generator). + transformFlags |= TransformFlags.AssertESNext | TransformFlags.AssertES2015 | TransformFlags.ContainsYield; break; case SyntaxKind.AnyKeyword: case SyntaxKind.NumberKeyword: case SyntaxKind.NeverKeyword: + case SyntaxKind.ObjectKeyword: case SyntaxKind.StringKeyword: case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: @@ -3344,6 +3435,7 @@ namespace ts { case SyntaxKind.NumberKeyword: case SyntaxKind.NeverKeyword: case SyntaxKind.StringKeyword: + case SyntaxKind.ObjectKeyword: case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: case SyntaxKind.VoidKeyword: diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2900932bc00..d6a8933eeec 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -52,7 +52,7 @@ namespace ts { const emptySymbols = createMap(); const compilerOptions = host.getCompilerOptions(); - const languageVersion = compilerOptions.target || ScriptTarget.ES3; + const languageVersion = getEmitScriptTarget(compilerOptions); const modulekind = getEmitModuleKind(compilerOptions); const noUnusedIdentifiers = !!compilerOptions.noUnusedLocals || !!compilerOptions.noUnusedParameters; const allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ModuleKind.System; @@ -60,10 +60,15 @@ namespace ts { const emitResolver = createResolver(); - const undefinedSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "undefined"); + const undefinedSymbol = createSymbol(SymbolFlags.Property, "undefined"); undefinedSymbol.declarations = []; - const argumentsSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "arguments"); + const argumentsSymbol = createSymbol(SymbolFlags.Property, "arguments"); + // for public members that accept a Node or one of its subtypes, we must guard against + // synthetic nodes created during transformations by calling `getParseTreeNode`. + // for most of these, we perform the guard only on `checker` to avoid any possible + // extra cost of calling `getParseTreeNode` when calling these functions from inside the + // checker. const checker: TypeChecker = { getNodeCount: () => sum(host.getSourceFiles(), "nodeCount"), getIdentifierCount: () => sum(host.getSourceFiles(), "identifierCount"), @@ -74,8 +79,15 @@ namespace ts { isUnknownSymbol: symbol => symbol === unknownSymbol, getDiagnostics, getGlobalDiagnostics, - getTypeOfSymbolAtLocation, - getSymbolsOfParameterPropertyDeclaration, + getTypeOfSymbolAtLocation: (symbol, location) => { + location = getParseTreeNode(location); + return location ? getTypeOfSymbolAtLocation(symbol, location) : unknownType; + }, + getSymbolsOfParameterPropertyDeclaration: (parameter, parameterName) => { + parameter = getParseTreeNode(parameter, isParameter); + Debug.assert(parameter !== undefined, "Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node."); + return getSymbolsOfParameterPropertyDeclaration(parameter, parameterName); + }, getDeclaredTypeOfSymbol, getPropertiesOfType, getPropertyOfType, @@ -83,35 +95,90 @@ namespace ts { getSignaturesOfType, getIndexTypeOfType, getBaseTypes, - getTypeFromTypeNode, + getBaseTypeOfLiteralType, + getWidenedType, + getTypeFromTypeNode: node => { + node = getParseTreeNode(node, isTypeNode); + return node ? getTypeFromTypeNode(node) : unknownType; + }, + getParameterType: getTypeAtPosition, getReturnTypeOfSignature, getNonNullableType, - getSymbolsInScope, - getSymbolAtLocation, - getShorthandAssignmentValueSymbol, - getExportSpecifierLocalTargetSymbol, - getTypeAtLocation: getTypeOfNode, - getPropertySymbolOfDestructuringAssignment, - signatureToString, - typeToString, + getSymbolsInScope: (location, meaning) => { + location = getParseTreeNode(location); + return location ? getSymbolsInScope(location, meaning) : []; + }, + getSymbolAtLocation: node => { + node = getParseTreeNode(node); + return node ? getSymbolAtLocation(node) : undefined; + }, + getShorthandAssignmentValueSymbol: node => { + node = getParseTreeNode(node); + return node ? getShorthandAssignmentValueSymbol(node) : undefined; + }, + getExportSpecifierLocalTargetSymbol: node => { + node = getParseTreeNode(node, isExportSpecifier); + return node ? getExportSpecifierLocalTargetSymbol(node) : undefined; + }, + getTypeAtLocation: node => { + node = getParseTreeNode(node); + return node ? getTypeOfNode(node) : unknownType; + }, + getPropertySymbolOfDestructuringAssignment: location => { + location = getParseTreeNode(location, isIdentifier); + return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined; + }, + signatureToString: (signature, enclosingDeclaration?, flags?, kind?) => { + return signatureToString(signature, getParseTreeNode(enclosingDeclaration), flags, kind); + }, + typeToString: (type, enclosingDeclaration?, flags?) => { + return typeToString(type, getParseTreeNode(enclosingDeclaration), flags); + }, getSymbolDisplayBuilder, - symbolToString, + symbolToString: (symbol, enclosingDeclaration?, meaning?) => { + return symbolToString(symbol, getParseTreeNode(enclosingDeclaration), meaning); + }, getAugmentedPropertiesOfType, getRootSymbols, - getContextualType, + getContextualType: node => { + node = getParseTreeNode(node, isExpression) + return node ? getContextualType(node) : undefined; + }, getFullyQualifiedName, - getResolvedSignature, - getConstantValue, - isValidPropertyAccess, - getSignatureFromDeclaration, - isImplementationOfOverload, + getResolvedSignature: (node, candidatesOutArray?) => { + node = getParseTreeNode(node, isCallLikeExpression); + return node ? getResolvedSignature(node, candidatesOutArray) : undefined; + }, + getConstantValue: node => { + node = getParseTreeNode(node, canHaveConstantValue); + return node ? getConstantValue(node) : undefined; + }, + isValidPropertyAccess: (node, propertyName) => { + node = getParseTreeNode(node, isPropertyAccessOrQualifiedName); + return node ? isValidPropertyAccess(node, propertyName) : false; + }, + getSignatureFromDeclaration: declaration => { + declaration = getParseTreeNode(declaration, isFunctionLike); + return declaration ? getSignatureFromDeclaration(declaration) : undefined; + }, + isImplementationOfOverload: node => { + node = getParseTreeNode(node, isFunctionLike); + return node ? isImplementationOfOverload(node) : undefined; + }, getAliasedSymbol: resolveAlias, getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, + getExportsAndPropertiesOfModule, getAmbientModules, - getJsxElementAttributesType, + getAllAttributesTypeFromJsxOpeningLikeElement: node => { + node = getParseTreeNode(node, isJsxOpeningLikeElement); + return node ? getAllAttributesTypeFromJsxOpeningLikeElement(node) : undefined; + }, getJsxIntrinsicTagNames, - isOptionalParameter, + isOptionalParameter: node => { + node = getParseTreeNode(node, isParameter); + return node ? isOptionalParameter(node) : false; + }, tryGetMemberInModuleExports, tryFindAmbientModuleWithoutAugmentations: moduleName => { // we deliberately exclude augmentations @@ -129,8 +196,8 @@ namespace ts { const indexedAccessTypes = createMap(); const evolvingArrayTypes: EvolvingArrayType[] = []; - const unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown"); - const resolvingSymbol = createSymbol(SymbolFlags.Transient, "__resolving__"); + const unknownSymbol = createSymbol(SymbolFlags.Property, "unknown"); + const resolvingSymbol = createSymbol(0, "__resolving__"); const anyType = createIntrinsicType(TypeFlags.Any, "any"); const autoType = createIntrinsicType(TypeFlags.Any, "any"); @@ -148,10 +215,11 @@ namespace ts { const voidType = createIntrinsicType(TypeFlags.Void, "void"); const neverType = createIntrinsicType(TypeFlags.Never, "never"); const silentNeverType = createIntrinsicType(TypeFlags.Never, "never"); + const nonPrimitiveType = createIntrinsicType(TypeFlags.NonPrimitive, "object"); const emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - const emptyTypeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral | SymbolFlags.Transient, "__type"); + const emptyTypeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type"); emptyTypeLiteralSymbol.members = createMap(); const emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -164,6 +232,7 @@ namespace ts { anyFunctionType.flags |= TypeFlags.ContainsAnyFunctionType; const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + const circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); const anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); const unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); @@ -180,11 +249,6 @@ namespace ts { */ let patternAmbientModules: PatternAmbientModule[]; - let getGlobalESSymbolConstructorSymbol: () => Symbol; - - let getGlobalPromiseConstructorSymbol: () => Symbol; - let tryGetGlobalPromiseConstructorSymbol: () => Symbol; - let globalObjectType: ObjectType; let globalFunctionType: ObjectType; let globalArrayType: GenericType; @@ -200,26 +264,20 @@ namespace ts { // The library files are only loaded when the feature is used. // This allows users to just specify library files they want to used through --lib // and they will not get an error from not having unrelated library files - let getGlobalTemplateStringsArrayType: () => ObjectType; - - let getGlobalESSymbolType: () => ObjectType; - let getGlobalIterableType: () => GenericType; - let getGlobalIteratorType: () => GenericType; - let getGlobalIterableIteratorType: () => GenericType; - - let getGlobalClassDecoratorType: () => ObjectType; - let getGlobalParameterDecoratorType: () => ObjectType; - let getGlobalPropertyDecoratorType: () => ObjectType; - let getGlobalMethodDecoratorType: () => ObjectType; - let getGlobalTypedPropertyDescriptorType: () => ObjectType; - let getGlobalPromiseType: () => ObjectType; - let tryGetGlobalPromiseType: () => ObjectType; - let getGlobalPromiseLikeType: () => ObjectType; - let getInstantiatedGlobalPromiseLikeType: () => ObjectType; - let getGlobalPromiseConstructorLikeType: () => ObjectType; - let getGlobalThenableType: () => ObjectType; - - let jsxElementClassType: Type; + let deferredGlobalESSymbolConstructorSymbol: Symbol; + let deferredGlobalESSymbolType: ObjectType; + let deferredGlobalTypedPropertyDescriptorType: GenericType; + let deferredGlobalPromiseType: GenericType; + let deferredGlobalPromiseConstructorSymbol: Symbol; + let deferredGlobalPromiseConstructorLikeType: ObjectType; + let deferredGlobalIterableType: GenericType; + let deferredGlobalIteratorType: GenericType; + let deferredGlobalIterableIteratorType: GenericType; + let deferredGlobalAsyncIterableType: GenericType; + let deferredGlobalAsyncIteratorType: GenericType; + let deferredGlobalAsyncIterableIteratorType: GenericType; + let deferredGlobalTemplateStringsArrayType: ObjectType; + let deferredJsxElementClassType: Type; let deferredNodes: Node[]; let deferredUnusedIdentifierNodes: Node[]; @@ -313,7 +371,7 @@ namespace ts { NullFacts = TypeofEQObject | TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNESymbol | TypeofNEFunction | TypeofNEHostObject | EQNull | EQUndefinedOrNull | NEUndefined | Falsy, } - const typeofEQFacts = createMap({ + const typeofEQFacts = createMapFromTemplate({ "string": TypeFacts.TypeofEQString, "number": TypeFacts.TypeofEQNumber, "boolean": TypeFacts.TypeofEQBoolean, @@ -322,8 +380,7 @@ namespace ts { "object": TypeFacts.TypeofEQObject, "function": TypeFacts.TypeofEQFunction }); - - const typeofNEFacts = createMap({ + const typeofNEFacts = createMapFromTemplate({ "string": TypeFacts.TypeofNEString, "number": TypeFacts.TypeofNENumber, "boolean": TypeFacts.TypeofNEBoolean, @@ -332,14 +389,14 @@ namespace ts { "object": TypeFacts.TypeofNEObject, "function": TypeFacts.TypeofNEFunction }); - - const typeofTypesByName = createMap({ + const typeofTypesByName = createMapFromTemplate({ "string": stringType, "number": numberType, "boolean": booleanType, "symbol": esSymbolType, "undefined": undefinedType }); + const typeofType = createTypeofType(); let jsxElementType: Type; let _jsxNamespace: string; @@ -376,7 +433,7 @@ namespace ts { } const builtinGlobals = createMap(); - builtinGlobals[undefinedSymbol.name] = undefinedSymbol; + builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); initializeTypeChecker(); @@ -412,9 +469,11 @@ namespace ts { diagnostics.add(diagnostic); } - function createSymbol(flags: SymbolFlags, name: string): Symbol { + function createSymbol(flags: SymbolFlags, name: string) { symbolCount++; - return new Symbol(flags, name); + const symbol = (new Symbol(flags | SymbolFlags.Transient, name)); + symbol.checkFlags = 0; + return symbol; } function getExcludedSymbolFlags(flags: SymbolFlags): SymbolFlags { @@ -447,7 +506,7 @@ namespace ts { } function cloneSymbol(symbol: Symbol): Symbol { - const result = createSymbol(symbol.flags | SymbolFlags.Merged, symbol.name); + const result = createSymbol(symbol.flags, symbol.name); result.declarations = symbol.declarations.slice(0); result.parent = symbol.parent; if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; @@ -482,6 +541,9 @@ namespace ts { } recordMergedSymbol(target, source); } + else if (target.flags & SymbolFlags.NamespaceModule) { + error(source.valueDeclaration.name, Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + } else { const message = target.flags & SymbolFlags.BlockScopedVariable || source.flags & SymbolFlags.BlockScopedVariable ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0; @@ -495,18 +557,19 @@ namespace ts { } function mergeSymbolTable(target: SymbolTable, source: SymbolTable) { - for (const id in source) { - let targetSymbol = target[id]; + source.forEach((sourceSymbol, id) => { + let targetSymbol = target.get(id); if (!targetSymbol) { - target[id] = source[id]; + target.set(id, sourceSymbol); } else { - if (!(targetSymbol.flags & SymbolFlags.Merged)) { - target[id] = targetSymbol = cloneSymbol(targetSymbol); + if (!(targetSymbol.flags & SymbolFlags.Transient)) { + targetSymbol = cloneSymbol(targetSymbol); + target.set(id, targetSymbol); } - mergeSymbol(targetSymbol, source[id]); + mergeSymbol(targetSymbol, sourceSymbol); } - } + }); } function mergeModuleAugmentation(moduleName: LiteralExpression): void { @@ -537,7 +600,7 @@ namespace ts { if (mainModule.flags & SymbolFlags.Namespace) { // if module symbol has already been merged - it is safe to use it. // otherwise clone it - mainModule = mainModule.flags & SymbolFlags.Merged ? mainModule : cloneSymbol(mainModule); + mainModule = mainModule.flags & SymbolFlags.Transient ? mainModule : cloneSymbol(mainModule); mergeSymbol(mainModule, moduleAugmentation.symbol); } else { @@ -547,15 +610,16 @@ namespace ts { } function addToSymbolTable(target: SymbolTable, source: SymbolTable, message: DiagnosticMessage) { - for (const id in source) { - if (target[id]) { + source.forEach((sourceSymbol, id) => { + const targetSymbol = target.get(id); + if (targetSymbol) { // Error on redeclarations - forEach(target[id].declarations, addDeclarationDiagnostic(id, message)); + forEach(targetSymbol.declarations, addDeclarationDiagnostic(id, message)); } else { - target[id] = source[id]; + target.set(id, sourceSymbol); } - } + }); function addDeclarationDiagnostic(id: string, message: DiagnosticMessage) { return (declaration: Declaration) => diagnostics.add(createDiagnosticForNode(declaration, message, id)); @@ -577,15 +641,19 @@ namespace ts { return type.flags & TypeFlags.Object ? (type).objectFlags : 0; } + function getCheckFlags(symbol: Symbol): CheckFlags { + return symbol.flags & SymbolFlags.Transient ? (symbol).checkFlags : 0; + } + function isGlobalSourceFile(node: Node) { return node.kind === SyntaxKind.SourceFile && !isExternalOrCommonJsModule(node); } function getSymbol(symbols: SymbolTable, name: string, meaning: SymbolFlags): Symbol { if (meaning) { - const symbol = symbols[name]; + const symbol = symbols.get(name); if (symbol) { - Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0, "Should never get an instantiated symbol here."); + Debug.assert((getCheckFlags(symbol) & CheckFlags.Instantiated) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } @@ -632,7 +700,7 @@ namespace ts { } // declaration is after usage // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) - if (isUsedInFunctionOrNonStaticProperty(usage)) { + if (isUsedInFunctionOrInstanceProperty(usage)) { return true; } const sourceFiles = host.getSourceFiles(); @@ -659,10 +727,12 @@ namespace ts { } - // declaration is after usage - // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) + // declaration is after usage, but it can still be legal if usage is deferred: + // 1. inside a function + // 2. inside an instance property initializer, a reference to a non-instance property const container = getEnclosingBlockScopeContainer(declaration); - return isUsedInFunctionOrNonStaticProperty(usage, container); + const isInstanceProperty = declaration.kind === SyntaxKind.PropertyDeclaration && !(getModifierFlags(declaration) & ModifierFlags.Static); + return isUsedInFunctionOrInstanceProperty(usage, isInstanceProperty, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration: VariableDeclaration, usage: Node): boolean { const container = getEnclosingBlockScopeContainer(declaration); @@ -691,7 +761,7 @@ namespace ts { return false; } - function isUsedInFunctionOrNonStaticProperty(usage: Node, container?: Node): boolean { + function isUsedInFunctionOrInstanceProperty(usage: Node, isDeclarationInstanceProperty?: boolean, container?: Node): boolean { let current = usage; while (current) { if (current === container) { @@ -702,13 +772,13 @@ namespace ts { return true; } - const initializerOfNonStaticProperty = current.parent && + const initializerOfInstanceProperty = current.parent && current.parent.kind === SyntaxKind.PropertyDeclaration && (getModifierFlags(current.parent) & ModifierFlags.Static) === 0 && (current.parent).initializer === current; - if (initializerOfNonStaticProperty) { - return true; + if (initializerOfInstanceProperty) { + return !isDeclarationInstanceProperty; } current = current.parent; @@ -791,7 +861,7 @@ namespace ts { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. - if (result = moduleExports["default"]) { + if (result = moduleExports.get("default")) { const localSymbol = getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { break loop; @@ -810,9 +880,10 @@ namespace ts { // 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 (moduleExports[name] && - moduleExports[name].flags === SymbolFlags.Alias && - getDeclarationOfKind(moduleExports[name], SyntaxKind.ExportSpecifier)) { + const moduleExport = moduleExports.get(name); + if (moduleExport && + moduleExport.flags === SymbolFlags.Alias && + getDeclarationOfKind(moduleExport, SyntaxKind.ExportSpecifier)) { break; } } @@ -848,6 +919,11 @@ namespace ts { case SyntaxKind.ClassExpression: case SyntaxKind.InterfaceDeclaration: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & SymbolFlags.Type)) { + if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { + // ignore type parameters not declared in this container + result = undefined; + break; + } if (lastLocation && getModifierFlags(lastLocation) & ModifierFlags.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 @@ -976,10 +1052,10 @@ namespace ts { // interface 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 + // The foo at /*1*/ and /*2*/ will share same symbol with two meanings: + // block-scoped 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 + // we want to check for block-scoped if (meaning & SymbolFlags.BlockScopedVariable) { const exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & SymbolFlags.BlockScopedVariable) { @@ -998,12 +1074,22 @@ namespace ts { return result; } + function isTypeParameterSymbolDeclaredInContainer(symbol: Symbol, container: Node) { + for (const decl of symbol.declarations) { + if (decl.kind === SyntaxKind.TypeParameter && decl.parent === container) { + return true; + } + } + + return false; + } + function checkAndReportErrorForMissingPrefix(errorLocation: Node, name: string, nameArg: string | Identifier): boolean { if ((errorLocation.kind === SyntaxKind.Identifier && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } - const container = getThisContainer(errorLocation, /* includeArrowFunctions */ true); + const container = getThisContainer(errorLocation, /*includeArrowFunctions*/ true); let location = container; while (location) { if (isClassLike(location.parent)) { @@ -1140,11 +1226,16 @@ namespace ts { const moduleSymbol = resolveExternalModuleName(node, (node.parent).moduleSpecifier); if (moduleSymbol) { - const exportDefaultSymbol = isShorthandAmbientModuleSymbol(moduleSymbol) ? - moduleSymbol : - moduleSymbol.exports["export="] ? - getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") : - resolveSymbol(moduleSymbol.exports["default"]); + let exportDefaultSymbol: Symbol; + if (isShorthandAmbientModuleSymbol(moduleSymbol)) { + exportDefaultSymbol = moduleSymbol; + } + else { + const exportValue = moduleSymbol.exports.get("export="); + exportDefaultSymbol = exportValue + ? getPropertyOfType(getTypeOfSymbol(exportValue), "default") + : resolveSymbol(moduleSymbol.exports.get("default")); + } if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); @@ -1194,7 +1285,7 @@ namespace ts { function getExportOfModule(symbol: Symbol, name: string): Symbol { if (symbol.flags & SymbolFlags.Module) { - const exportedSymbol = getExportsOfSymbol(symbol)[name]; + const exportedSymbol = getExportsOfSymbol(symbol).get(name); if (exportedSymbol) { return resolveSymbol(exportedSymbol); } @@ -1222,7 +1313,7 @@ namespace ts { let symbolFromVariable: Symbol; // First check if module was specified with "export=". If so, get the member from the resolved type - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) { symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.text); } else { @@ -1411,7 +1502,7 @@ namespace ts { else { Debug.fail("Unknown entity name kind."); } - Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0, "Should never get an instantiated symbol here."); + Debug.assert((getCheckFlags(symbol) & CheckFlags.Instantiated) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); } @@ -1502,7 +1593,7 @@ namespace ts { // 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: Symbol): Symbol { - return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports["export="])) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="))) || moduleSymbol; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' @@ -1518,17 +1609,26 @@ namespace ts { } function hasExportAssignmentSymbol(moduleSymbol: Symbol): boolean { - return moduleSymbol.exports["export="] !== undefined; + return moduleSymbol.exports.get("export=") !== undefined; } function getExportsOfModuleAsArray(moduleSymbol: Symbol): Symbol[] { return symbolsToArray(getExportsOfModule(moduleSymbol)); } + function getExportsAndPropertiesOfModule(moduleSymbol: Symbol): Symbol[] { + const exports = getExportsOfModuleAsArray(moduleSymbol); + const exportEquals = resolveExternalModuleSymbol(moduleSymbol); + if (exportEquals !== moduleSymbol) { + addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + } + return exports; + } + function tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined { const symbolTable = getExportsOfModule(moduleSymbol); if (symbolTable) { - return symbolTable[memberName]; + return symbolTable.get(memberName); } } @@ -1551,24 +1651,28 @@ namespace ts { * Not passing `lookupTable` and `exportNode` disables this collection, and just extends the tables */ function extendExportSymbols(target: SymbolTable, source: SymbolTable, lookupTable?: Map, exportNode?: ExportDeclaration) { - for (const id in source) { - if (id !== "default" && !target[id]) { - target[id] = source[id]; + source && source.forEach((sourceSymbol, id) => { + if (id === "default") return; + + const targetSymbol = target.get(id); + if (!targetSymbol) { + target.set(id, sourceSymbol); if (lookupTable && exportNode) { - lookupTable[id] = { + lookupTable.set(id, { specifierText: getTextOfNode(exportNode.moduleSpecifier) - } as ExportCollisionTracker; + } as ExportCollisionTracker); } } - else if (lookupTable && exportNode && id !== "default" && target[id] && resolveSymbol(target[id]) !== resolveSymbol(source[id])) { - if (!lookupTable[id].exportsWithDuplicate) { - lookupTable[id].exportsWithDuplicate = [exportNode]; + else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) { + const collisionTracker = lookupTable.get(id); + if (!collisionTracker.exportsWithDuplicate) { + collisionTracker.exportsWithDuplicate = [exportNode]; } else { - lookupTable[id].exportsWithDuplicate.push(exportNode); + collisionTracker.exportsWithDuplicate.push(exportNode); } } - } + }); } function getExportsForModule(moduleSymbol: Symbol): SymbolTable { @@ -1588,7 +1692,7 @@ namespace ts { visitedSymbols.push(symbol); const symbols = cloneMap(symbol.exports); // All export * declarations are collected in an __export symbol by the binder - const exportStars = symbol.exports["__export"]; + const exportStars = symbol.exports.get("__export"); if (exportStars) { const nestedSymbols = createMap(); const lookupTable = createMap(); @@ -1602,21 +1706,20 @@ namespace ts { node as ExportDeclaration ); } - for (const id in lookupTable) { - const { exportsWithDuplicate } = lookupTable[id]; + lookupTable.forEach(({ exportsWithDuplicate }, id) => { // It's not an error if the file with multiple `export *`s with duplicate names exports a member with that name itself - if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols[id]) { - continue; + if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) { + return; } for (const node of exportsWithDuplicate) { diagnostics.add(createDiagnosticForNode( node, Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, - lookupTable[id].specifierText, + lookupTable.get(id).specifierText, id )); } - } + }); extendExportSymbols(symbols, nestedSymbols); } return symbols; @@ -1643,23 +1746,7 @@ namespace ts { } function symbolIsValue(symbol: Symbol): boolean { - // 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 & SymbolFlags.Instantiated) { - return symbolIsValue(getSymbolLinks(symbol).target); - } - - // If the symbol has the value flag, it is trivially a value. - if (symbol.flags & SymbolFlags.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 & SymbolFlags.Alias) { - return (resolveAlias(symbol).flags & SymbolFlags.Value) !== 0; - } - - return false; + return !!(symbol.flags & SymbolFlags.Value || symbol.flags & SymbolFlags.Alias && resolveAlias(symbol).flags & SymbolFlags.Value); } function findConstructorDeclaration(node: ClassLikeDeclaration): ConstructorDeclaration { @@ -1698,6 +1785,10 @@ namespace ts { return type; } + function createTypeofType() { + return getUnionType(convertToArray(typeofEQFacts.keys(), s => getLiteralTypeForText(TypeFlags.StringLiteral, s))); + } + // 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 @@ -1711,15 +1802,14 @@ namespace ts { function getNamedMembers(members: SymbolTable): Symbol[] { let result: Symbol[]; - for (const id in members) { + members.forEach((symbol, id) => { if (!isReservedMemberName(id)) { if (!result) result = []; - const symbol = members[id]; if (symbolIsValue(symbol)) { result.push(symbol); } } - } + }); return result || emptyArray; } @@ -1805,12 +1895,12 @@ namespace ts { function trySymbolTable(symbols: SymbolTable) { // If symbol is directly available by its name in the symbol table - if (isAccessible(symbols[symbol.name])) { + if (isAccessible(symbols.get(symbol.name))) { return [symbol]; } // Check if symbol is any of the alias - return forEachProperty(symbols, symbolFromSymbolTable => { + return forEachEntry(symbols, symbolFromSymbolTable => { if (symbolFromSymbolTable.flags & SymbolFlags.Alias && symbolFromSymbolTable.name !== "export=" && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) { @@ -1846,7 +1936,7 @@ namespace ts { let qualify = false; forEachSymbolTableInScope(enclosingDeclaration, symbolTable => { // If symbol of this name is not available in the symbol table we are ok - let symbolFromSymbolTable = symbolTable[symbol.name]; + let symbolFromSymbolTable = symbolTable.get(symbol.name); if (!symbolFromSymbolTable) { // Continue to the next symbol table return false; @@ -2148,24 +2238,27 @@ namespace ts { return type.flags & TypeFlags.StringLiteral ? `"${escapeString((type).text)}"` : (type).text; } - function getSymbolDisplayBuilder(): SymbolDisplayBuilder { - - function getNameOfSymbol(symbol: Symbol): string { - if (symbol.declarations && symbol.declarations.length) { - const declaration = symbol.declarations[0]; - if (declaration.name) { - return declarationNameToString(declaration.name); - } - switch (declaration.kind) { - case SyntaxKind.ClassExpression: - return "(Anonymous class)"; - case SyntaxKind.FunctionExpression: - case SyntaxKind.ArrowFunction: - return "(Anonymous function)"; - } + function getNameOfSymbol(symbol: Symbol): string { + if (symbol.declarations && symbol.declarations.length) { + const declaration = symbol.declarations[0]; + if (declaration.name) { + return declarationNameToString(declaration.name); + } + if (declaration.parent && declaration.parent.kind === SyntaxKind.VariableDeclaration) { + return declarationNameToString((declaration.parent).name); + } + switch (declaration.kind) { + case SyntaxKind.ClassExpression: + return "(Anonymous class)"; + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + return "(Anonymous function)"; } - return symbol.name; } + return symbol.name; + } + + function getSymbolDisplayBuilder(): SymbolDisplayBuilder { /** * Writes only the name of the symbol out to the writer. Uses the original source text @@ -2211,7 +2304,7 @@ namespace ts { if (parentSymbol) { // Write type arguments of instantiated class/interface here if (flags & SymbolFormatFlags.WriteTypeParametersOrArguments) { - if (symbol.flags & SymbolFlags.Instantiated) { + if (getCheckFlags(symbol) & CheckFlags.Instantiated) { buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), (symbol).mapper, writer, enclosingDeclaration); } @@ -2314,7 +2407,7 @@ namespace ts { else if (!(flags & TypeFormatFlags.InTypeAlias) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === SymbolAccessibility.Accessible) { const typeArguments = type.aliasTypeArguments; - writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); + writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, length(typeArguments), nextFlags); } else if (type.flags & TypeFlags.UnionOrIntersection) { writeUnionOrIntersectionType(type, nextFlags); @@ -2438,7 +2531,8 @@ namespace ts { 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)) { + if (symbol.flags & SymbolFlags.Class && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule)) { writeTypeOfSymbol(type, flags); } else if (shouldWriteTypeOfFunctionSymbol()) { @@ -2648,6 +2742,13 @@ namespace ts { writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } + const defaultType = getDefaultFromTypeParameter(tp); + if (defaultType) { + writeSpace(writer); + writePunctuation(writer, SyntaxKind.EqualsToken); + writeSpace(writer); + buildTypeDisplay(defaultType, writer, enclosingDeclaration, flags, symbolStack); + } } function buildParameterDisplay(p: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { @@ -2667,7 +2768,11 @@ namespace ts { writePunctuation(writer, SyntaxKind.ColonToken); writeSpace(writer); - buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); + let type = getTypeOfSymbol(p); + if (isRequiredInitializedParameter(parameterNode)) { + type = includeFalsyTypes(type, TypeFlags.Undefined); + } + buildTypeDisplay(type, writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern: BindingPattern, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { @@ -3118,15 +3223,14 @@ namespace ts { const members = createMap(); const names = createMap(); for (const name of properties) { - names[getTextOfPropertyName(name)] = true; + names.set(getTextOfPropertyName(name), true); } for (const prop of getPropertiesOfType(source)) { - const inNamesToRemove = prop.name in names; + const inNamesToRemove = names.has(prop.name); const isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (ModifierFlags.Private | ModifierFlags.Protected); - const isMethod = prop.flags & SymbolFlags.Method; const isSetOnlyAccessor = prop.flags & SymbolFlags.SetAccessor && !(prop.flags & SymbolFlags.GetAccessor); - if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { - members[prop.name] = prop; + if (!inNamesToRemove && !isPrivate && !isClassMethod(prop) && !isSetOnlyAccessor) { + members.set(prop.name, prop); } } const stringIndexInfo = getIndexInfoOfType(source, IndexKind.String); @@ -3195,7 +3299,7 @@ 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). - const elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false); + const elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false, /*allowAsyncIterable*/ false); if (declaration.dotDotDotToken) { // Rest element has an array type with the same element type as the parent type type = createArrayType(elementType); @@ -3227,7 +3331,7 @@ namespace ts { type; } - function getTypeForVariableLikeDeclarationFromJSDocComment(declaration: VariableLikeDeclaration) { + function getTypeForDeclarationFromJSDocComment(declaration: Node ) { const jsdocType = getJSDocType(declaration); if (jsdocType) { return getTypeFromTypeNode(jsdocType); @@ -3249,13 +3353,23 @@ namespace ts { return strictNullChecks && optional ? includeFalsyTypes(type, TypeFlags.Undefined) : type; } + /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ + function removeOptionalityFromAnnotation(annotatedType: Type, declaration: VariableLikeDeclaration): Type { + const annotationIncludesUndefined = strictNullChecks && + declaration.kind === SyntaxKind.Parameter && + declaration.initializer && + getFalsyFlags(annotatedType) & TypeFlags.Undefined && + !(getFalsyFlags(checkExpression(declaration.initializer)) & TypeFlags.Undefined); + return annotationIncludesUndefined ? getNonNullableType(annotatedType) : annotatedType; + } + // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration: VariableLikeDeclaration, includeOptionality: boolean): Type { if (declaration.flags & NodeFlags.JavaScriptFile) { // If this is a variable in a JavaScript file, then use the JSDoc type (if it has // one as its type), otherwise fallback to the below standard TS codepaths to // try to figure it out. - const type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); + const type = getTypeForDeclarationFromJSDocComment(declaration); if (type && type !== unknownType) { return type; } @@ -3273,7 +3387,8 @@ namespace ts { // 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; + const forOfStatement = declaration.parent.parent; + return checkRightHandSideOfForOf(forOfStatement.expression, forOfStatement.awaitModifier) || anyType; } if (isBindingPattern(declaration.parent)) { @@ -3282,7 +3397,8 @@ namespace ts { // Use type from type annotation if one is present if (declaration.type) { - return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); + const declaredType = removeOptionalityFromAnnotation(getTypeFromTypeNode(declaration.type), declaration); + return addOptionality(declaredType, /*optional*/ declaration.questionToken && includeOptionality); } if ((compilerOptions.noImplicitAny || declaration.flags & NodeFlags.JavaScriptFile) && @@ -3336,6 +3452,12 @@ namespace ts { return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality); } + if (isJsxAttribute(declaration)) { + // if JSX attribute doesn't have initializer, by default the attribute will have boolean value of true. + // I.e is sugar for + return trueType; + } + // If it is a short-hand property assignment, use the type of the identifier if (declaration.kind === SyntaxKind.ShorthandPropertyAssignment) { return checkIdentifier(declaration.name); @@ -3350,6 +3472,27 @@ namespace ts { return undefined; } + // Return the inferred type for a variable, parameter, or property declaration + function getTypeForJSSpecialPropertyDeclaration(declaration: Declaration): Type { + const expression = declaration.kind === SyntaxKind.BinaryExpression ? declaration : + declaration.kind === SyntaxKind.PropertyAccessExpression ? getAncestor(declaration, SyntaxKind.BinaryExpression) : + undefined; + + if (!expression) { + return unknownType; + } + + if (expression.flags & NodeFlags.JavaScriptFile) { + // If there is a JSDoc type, use it + const type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type && type !== unknownType) { + return getWidenedType(type); + } + } + + return getWidenedLiteralType(checkExpressionCached(expression.right)); + } + // 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. @@ -3384,11 +3527,11 @@ namespace ts { } const text = getTextOfPropertyName(name); - const flags = SymbolFlags.Property | SymbolFlags.Transient | (e.initializer ? SymbolFlags.Optional : 0); - const symbol = createSymbol(flags, text); + const flags = SymbolFlags.Property | (e.initializer ? SymbolFlags.Optional : 0); + const symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; - members[symbol.name] = symbol; + members.set(symbol.name, symbol); }); const result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); if (includePatternInType) { @@ -3504,18 +3647,7 @@ namespace ts { // * className.prototype.method = expr if (declaration.kind === SyntaxKind.BinaryExpression || declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) { - // Use JS Doc type if present on parent expression statement - if (declaration.flags & NodeFlags.JavaScriptFile) { - const jsdocType = getJSDocType(declaration.parent); - if (jsdocType) { - return links.type = getTypeFromTypeNode(jsdocType); - } - } - const declaredTypes = map(symbol.declarations, - decl => decl.kind === SyntaxKind.BinaryExpression ? - checkExpressionCached((decl).right) : - checkExpressionCached((decl.parent).right)); - type = getUnionType(declaredTypes, /*subtypeReduction*/ true); + type = getWidenedType(getUnionType(map(symbol.declarations, getTypeForJSSpecialPropertyDeclaration), /*subtypeReduction*/ true)); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); @@ -3558,7 +3690,7 @@ namespace ts { const setter = getDeclarationOfKind(symbol, SyntaxKind.SetAccessor); if (getter && getter.flags & NodeFlags.JavaScriptFile) { - const jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); + const jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; } @@ -3613,6 +3745,11 @@ namespace ts { return links.type; } + function getBaseTypeVariableOfClass(symbol: Symbol) { + const baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); + return baseConstructorType.flags & TypeFlags.TypeVariable ? baseConstructorType : undefined; + } + function getTypeOfFuncClassEnumModule(symbol: Symbol): Type { const links = getSymbolLinks(symbol); if (!links.type) { @@ -3621,8 +3758,13 @@ namespace ts { } else { const type = createObjectType(ObjectFlags.Anonymous, symbol); - links.type = strictNullChecks && symbol.flags & SymbolFlags.Optional ? - includeFalsyTypes(type, TypeFlags.Undefined) : type; + if (symbol.flags & SymbolFlags.Class) { + const baseTypeVariable = getBaseTypeVariableOfClass(symbol); + links.type = baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; + } + else { + links.type = strictNullChecks && symbol.flags & SymbolFlags.Optional ? includeFalsyTypes(type, TypeFlags.Undefined) : type; + } } } return links.type; @@ -3684,7 +3826,7 @@ namespace ts { } function getTypeOfSymbol(symbol: Symbol): Type { - if (symbol.flags & SymbolFlags.Instantiated) { + if (getCheckFlags(symbol) & CheckFlags.Instantiated) { return getTypeOfInstantiatedSymbol(symbol); } if (symbol.flags & (SymbolFlags.Variable | SymbolFlags.Property)) { @@ -3705,15 +3847,27 @@ namespace ts { return unknownType; } + function isReferenceToType(type: Type, target: Type) { + return type !== undefined + && target !== undefined + && (getObjectFlags(type) & ObjectFlags.Reference) !== 0 + && (type).target === target; + } + function getTargetType(type: Type): Type { return getObjectFlags(type) & ObjectFlags.Reference ? (type).target : type; } - function hasBaseType(type: InterfaceType, checkBase: InterfaceType) { + function hasBaseType(type: Type, checkBase: Type) { return check(type); - function check(type: InterfaceType): boolean { - const target = getTargetType(type); - return target === checkBase || forEach(getBaseTypes(target), check); + function check(type: Type): boolean { + if (getObjectFlags(type) & (ObjectFlags.ClassOrInterface | ObjectFlags.Reference)) { + const target = getTargetType(type); + return target === checkBase || forEach(getBaseTypes(target), check); + } + else if (type.flags & TypeFlags.Intersection) { + return forEach((type).types, check); + } } } @@ -3781,8 +3935,26 @@ namespace ts { return concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } + // A type is a mixin constructor if it has a single construct signature taking no type parameters and a single + // rest parameter of type any[]. + function isMixinConstructorType(type: Type) { + const signatures = getSignaturesOfType(type, SignatureKind.Construct); + if (signatures.length === 1) { + const s = signatures[0]; + return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + } + return false; + } + function isConstructorType(type: Type): boolean { - return type.flags & TypeFlags.Object && getSignaturesOfType(type, SignatureKind.Construct).length > 0; + if (isValidBaseType(type) && getSignaturesOfType(type, SignatureKind.Construct).length > 0) { + return true; + } + if (type.flags & TypeFlags.TypeVariable) { + const constraint = getBaseConstraintOfType(type); + return isValidBaseType(constraint) && isMixinConstructorType(constraint); + } + return false; } function getBaseTypeNodeOfClass(type: InterfaceType): ExpressionWithTypeArguments { @@ -3790,9 +3962,9 @@ namespace ts { } function getConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[]): Signature[] { - const typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; + const typeArgCount = length(typeArgumentNodes); return filter(getSignaturesOfType(type, SignatureKind.Construct), - sig => (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount); + sig => typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= length(sig.typeParameters)); } function getInstantiatedConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[]): Signature[] { @@ -3821,7 +3993,7 @@ namespace ts { return unknownType; } const baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & TypeFlags.Object) { + if (baseConstructorType.flags & (TypeFlags.Object | TypeFlags.Intersection)) { // 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); @@ -3839,7 +4011,7 @@ namespace ts { return type.resolvedBaseConstructorType; } - function getBaseTypes(type: InterfaceType): ObjectType[] { + function getBaseTypes(type: InterfaceType): BaseType[] { if (!type.resolvedBaseTypes) { if (type.objectFlags & ObjectFlags.Tuple) { type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; @@ -3861,8 +4033,8 @@ namespace ts { function resolveBaseTypesOfClass(type: InterfaceType): void { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - const baseConstructorType = getBaseConstructorTypeOfClass(type); - if (!(baseConstructorType.flags & TypeFlags.Object)) { + const baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); + if (!(baseConstructorType.flags & (TypeFlags.Object | TypeFlags.Intersection))) { return; } const baseTypeNode = getBaseTypeNodeOfClass(type); @@ -3899,11 +4071,11 @@ namespace ts { if (baseType === unknownType) { return; } - if (!(getObjectFlags(getTargetType(baseType)) & ObjectFlags.ClassOrInterface)) { + if (!isValidBaseType(baseType)) { error(baseTypeNode.expression, Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } - if (type === baseType || hasBaseType(baseType, type)) { + if (type === baseType || hasBaseType(baseType, type)) { error(valueDecl, Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType)); return; @@ -3928,6 +4100,13 @@ namespace ts { return true; } + // A valid base type is any non-generic object type or intersection of non-generic + // object types. + function isValidBaseType(type: Type): boolean { + return type.flags & (TypeFlags.Object | TypeFlags.NonPrimitive) && !isGenericMappedType(type) || + type.flags & TypeFlags.Intersection && !forEach((type).types, t => !isValidBaseType(t)); + } + function resolveBaseTypesOfInterface(type: InterfaceType): void { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (const declaration of type.symbol.declarations) { @@ -3935,8 +4114,8 @@ namespace ts { for (const node of getInterfaceBaseTypeNodes(declaration)) { const baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { - if (getObjectFlags(getTargetType(baseType)) & ObjectFlags.ClassOrInterface) { - if (type !== baseType && !hasBaseType(baseType, type)) { + if (isValidBaseType(baseType)) { + if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; } @@ -4000,7 +4179,7 @@ namespace ts { type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; (type).instantiations = createMap(); - (type).instantiations[getTypeListId(type.typeParameters)] = type; + (type).instantiations.set(getTypeListId(type.typeParameters), type); (type).target = type; (type).typeArguments = type.typeParameters; type.thisType = createType(TypeFlags.TypeParameter); @@ -4043,7 +4222,7 @@ namespace ts { // an instantiation of the type alias with the type parameters supplied as type arguments. links.typeParameters = typeParameters; links.instantiations = createMap(); - links.instantiations[getTypeListId(typeParameters)] = type; + links.instantiations.set(getTypeListId(typeParameters), type); } } else { @@ -4063,7 +4242,7 @@ namespace ts { return expr.kind === SyntaxKind.NumericLiteral || expr.kind === SyntaxKind.PrefixUnaryExpression && (expr).operator === SyntaxKind.MinusToken && (expr).operand.kind === SyntaxKind.NumericLiteral || - expr.kind === SyntaxKind.Identifier && !!symbol.exports[(expr).text]; + expr.kind === SyntaxKind.Identifier && !!symbol.exports.get((expr).text); } function enumHasLiteralMembers(symbol: Symbol) { @@ -4094,7 +4273,7 @@ namespace ts { enumType.symbol = symbol; if (enumHasLiteralMembers(symbol)) { const memberTypeList: Type[] = []; - const memberTypes = createMap(); + const memberTypes: EnumLiteralType[] = []; for (const declaration of enumType.symbol.declarations) { if (declaration.kind === SyntaxKind.EnumDeclaration) { computeEnumMemberValues(declaration); @@ -4112,7 +4291,7 @@ namespace ts { if (memberTypeList.length > 1) { enumType.flags |= TypeFlags.Union; (enumType).types = memberTypeList; - unionTypes[getTypeListId(memberTypeList)] = enumType; + unionTypes.set(getTypeListId(memberTypeList), enumType); } } } @@ -4135,9 +4314,6 @@ namespace ts { if (!links.declaredType) { const type = createType(TypeFlags.TypeParameter); type.symbol = symbol; - if (!(getDeclarationOfKind(symbol, SyntaxKind.TypeParameter)).constraint) { - type.constraint = noConstraintType; - } links.declaredType = type; } return links.declaredType; @@ -4152,7 +4328,6 @@ namespace ts { } function getDeclaredTypeOfSymbol(symbol: Symbol): Type { - Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0); if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { return getDeclaredTypeOfClassOrInterface(symbol); } @@ -4196,6 +4371,7 @@ namespace ts { case SyntaxKind.NumberKeyword: case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: + case SyntaxKind.ObjectKeyword: case SyntaxKind.VoidKeyword: case SyntaxKind.UndefinedKeyword: case SyntaxKind.NullKeyword: @@ -4256,7 +4432,7 @@ namespace ts { function createSymbolTable(symbols: Symbol[]): SymbolTable { const result = createMap(); for (const symbol of symbols) { - result[symbol.name] = symbol; + result.set(symbol.name, symbol); } return result; } @@ -4266,15 +4442,15 @@ namespace ts { function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper, mappingThisOnly: boolean): SymbolTable { const result = createMap(); for (const symbol of symbols) { - result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); + result.set(symbol.name, mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; } function addInheritedMembers(symbols: SymbolTable, baseSymbols: Symbol[]) { for (const s of baseSymbols) { - if (!symbols[s.name]) { - symbols[s.name] = s; + if (!symbols.has(s.name)) { + symbols.set(s.name, s); } } } @@ -4283,8 +4459,8 @@ namespace ts { if (!(type).declaredProperties) { const symbol = type.symbol; (type).declaredProperties = getNamedMembers(symbol.members); - (type).declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); - (type).declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); + (type).declaredCallSignatures = getSignaturesOfSymbol(symbol.members.get("__call")); + (type).declaredConstructSignatures = getSignaturesOfSymbol(symbol.members.get("__new")); (type).declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.String); (type).declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.Number); } @@ -4293,8 +4469,14 @@ namespace ts { function getTypeWithThisArgument(type: Type, thisArgument?: Type): Type { if (getObjectFlags(type) & ObjectFlags.Reference) { - return createTypeReference((type).target, - concatenate((type).typeArguments, [thisArgument || (type).target.thisType])); + const target = (type).target; + const typeArguments = (type).typeArguments; + if (length(target.typeParameters) === length(typeArguments)) { + return createTypeReference(target, concatenate(typeArguments, [thisArgument || target.thisType])); + } + } + else if (type.flags & TypeFlags.Intersection) { + return getIntersectionType(map((type).types, t => getTypeWithThisArgument(t, thisArgument))); } return type; } @@ -4329,8 +4511,8 @@ namespace ts { } const thisArgument = lastOrUndefined(typeArguments); for (const baseType of baseTypes) { - const instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + const instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); callSignatures = concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, SignatureKind.Call)); constructSignatures = concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, SignatureKind.Construct)); stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, IndexKind.String); @@ -4380,12 +4562,13 @@ namespace ts { } const baseTypeNode = getBaseTypeNodeOfClass(classType); const typeArguments = map(baseTypeNode.typeArguments, getTypeFromTypeNode); - const typeArgCount = typeArguments ? typeArguments.length : 0; + const typeArgCount = length(typeArguments); const result: Signature[] = []; for (const baseSig of baseSignatures) { - const typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; - if (typeParamCount === typeArgCount) { - const sig = typeParamCount ? createSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + const minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); + const typeParamCount = length(baseSig.typeParameters); + if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) { + const sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -4449,7 +4632,7 @@ namespace ts { s = cloneSignature(signature); if (forEach(unionSignatures, sig => sig.thisParameter)) { const thisType = getUnionType(map(unionSignatures, sig => getTypeOfSymbol(sig.thisParameter) || anyType), /*subtypeReduction*/ true); - s.thisParameter = createTransientSymbol(signature.thisParameter, thisType); + s.thisParameter = createSymbolWithType(signature.thisParameter, thisType); } // Clear resolved return type we possibly got from cloneSignature s.resolvedReturnType = undefined; @@ -4501,16 +4684,47 @@ namespace ts { getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly); } + function includeMixinType(type: Type, types: Type[], index: number): Type { + const mixedTypes: Type[] = []; + for (let i = 0; i < types.length; i++) { + if (i === index) { + mixedTypes.push(type); + } + else if (isMixinConstructorType(types[i])) { + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], SignatureKind.Construct)[0])); + } + } + return getIntersectionType(mixedTypes); + } + function resolveIntersectionTypeMembers(type: IntersectionType) { // 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). let callSignatures: Signature[] = emptyArray; let constructSignatures: Signature[] = emptyArray; - let stringIndexInfo: IndexInfo = undefined; - let numberIndexInfo: IndexInfo = undefined; - for (const t of type.types) { + let stringIndexInfo: IndexInfo; + let numberIndexInfo: IndexInfo; + const types = type.types; + const mixinCount = countWhere(types, isMixinConstructorType); + for (let i = 0; i < types.length; i++) { + const t = type.types[i]; + // When an intersection type contains mixin constructor types, the construct signatures from + // those types are discarded and their return types are mixed into the return types of all + // other construct signatures in the intersection type. For example, the intersection type + // '{ new(...args: any[]) => A } & { new(s: string) => B }' has a single construct signature + // 'new(s: string) => A & B'. + if (mixinCount === 0 || mixinCount === types.length && i === 0 || !isMixinConstructorType(t)) { + let signatures = getSignaturesOfType(t, SignatureKind.Construct); + if (signatures.length && mixinCount > 0) { + signatures = map(signatures, s => { + const clone = cloneSignature(s); + clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, i); + return clone; + }); + } + constructSignatures = concatenate(constructSignatures, signatures); + } callSignatures = concatenate(callSignatures, getSignaturesOfType(t, SignatureKind.Call)); - constructSignatures = concatenate(constructSignatures, getSignaturesOfType(t, SignatureKind.Construct)); stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, IndexKind.String)); numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, IndexKind.Number)); } @@ -4532,8 +4746,8 @@ namespace ts { } else if (symbol.flags & SymbolFlags.TypeLiteral) { const members = symbol.members; - const callSignatures = getSignaturesOfSymbol(members["__call"]); - const constructSignatures = getSignaturesOfSymbol(members["__new"]); + const callSignatures = getSignaturesOfSymbol(members.get("__call")); + const constructSignatures = getSignaturesOfSymbol(members.get("__new")); const stringIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.String); const numberIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.Number); setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -4542,19 +4756,19 @@ namespace ts { // Combinations of function, class, enum and module let members = emptySymbols; let constructSignatures: Signature[] = emptyArray; - if (symbol.flags & SymbolFlags.HasExports) { + if (symbol.exports) { members = getExportsOfSymbol(symbol); } if (symbol.flags & SymbolFlags.Class) { const classType = getDeclaredTypeOfClassOrInterface(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); + constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } const baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & TypeFlags.Object) { + if (baseConstructorType.flags & (TypeFlags.Object | TypeFlags.Intersection | TypeFlags.TypeVariable)) { members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); + addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } } const numberIndexInfo = symbol.flags & SymbolFlags.Enum ? enumNumberIndexInfo : undefined; @@ -4580,12 +4794,14 @@ namespace ts { const typeParameter = getTypeParameterFromMappedType(type); const constraintType = getConstraintTypeFromMappedType(type); const templateType = getTemplateTypeFromMappedType(type); - const modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); + const modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' const templateReadonly = !!type.declaration.readonlyToken; const templateOptional = !!type.declaration.questionToken; if (type.declaration.typeParameter.constraint.kind === SyntaxKind.TypeOperator) { // We have a { [P in keyof T]: X } - forEachType(getLiteralTypeFromPropertyNames(modifiersType), addMemberForKeyType); + for (const propertySymbol of getPropertiesOfType(modifiersType)) { + addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol); + } if (getIndexInfoOfType(modifiersType, IndexKind.String)) { addMemberForKeyType(stringType); } @@ -4600,11 +4816,11 @@ namespace ts { } setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, undefined); - function addMemberForKeyType(t: Type) { + function addMemberForKeyType(t: Type, propertySymbol?: Symbol) { // Create a mapper from T to the current iteration type constituent. Then, if the // mapped type is itself an instantiated type, combine the iteration mapper with the // instantiation mapper. - const iterationMapper = createUnaryTypeMapper(typeParameter, t); + const iterationMapper = createTypeMapper([typeParameter], [t]); const templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; const propType = instantiateType(templateType, templateMapper); // If the current iteration type constituent is a string literal type, create a property. @@ -4613,10 +4829,13 @@ namespace ts { const propName = (t).text; const modifiersProp = getPropertyOfType(modifiersType, propName); const isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & SymbolFlags.Optional); - const prop = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | (isOptional ? SymbolFlags.Optional : 0), propName); + const prop = createSymbol(SymbolFlags.Property | (isOptional ? SymbolFlags.Optional : 0), propName); + prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? CheckFlags.Readonly : 0; prop.type = propType; - prop.isReadonly = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp); - members[propName] = prop; + if (propertySymbol) { + prop.mappedTypeOrigin = propertySymbol; + } + members.set(propName, prop); } else if (t.flags & TypeFlags.String) { stringIndexInfo = createIndexInfo(propType, templateReadonly); @@ -4663,10 +4882,6 @@ namespace ts { return type.modifiersType; } - function getErasedTemplateTypeFromMappedType(type: MappedType) { - return instantiateType(getTemplateTypeFromMappedType(type), createUnaryTypeMapper(getTypeParameterFromMappedType(type), anyType)); - } - function isGenericMappedType(type: Type) { if (getObjectFlags(type) & ObjectFlags.Mapped) { const constraintType = getConstraintTypeFromMappedType(type); @@ -4714,7 +4929,7 @@ namespace ts { function getPropertyOfObjectType(type: Type, name: string): Symbol { if (type.flags & TypeFlags.Object) { const resolved = resolveStructuredTypeMembers(type); - const symbol = resolved.members[name]; + const symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } @@ -4722,29 +4937,26 @@ namespace ts { } function getPropertiesOfUnionOrIntersectionType(type: UnionOrIntersectionType): Symbol[] { - for (const current of type.types) { - for (const prop of getPropertiesOfType(current)) { - getUnionOrIntersectionProperty(type, prop.name); - } - // The properties of a union type are those that are present in all constituent types, so - // we only need to check the properties of the first type - if (type.flags & TypeFlags.Union) { - break; - } - } - const props = type.resolvedProperties; - if (props) { - const result: Symbol[] = []; - for (const key in props) { - const prop = props[key]; - // We need to filter out partial properties in union types - if (!(prop.flags & SymbolFlags.SyntheticProperty && (prop).isPartial)) { - result.push(prop); + if (!type.resolvedProperties) { + const members = createMap(); + for (const current of type.types) { + for (const prop of getPropertiesOfType(current)) { + if (!members.has(prop.name)) { + const combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.name); + if (combinedProp) { + members.set(prop.name, combinedProp); + } + } + } + // 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 & TypeFlags.Union) { + break; } } - return result; + type.resolvedProperties = getNamedMembers(members); } - return emptyArray; + return type.resolvedProperties; } function getPropertiesOfType(type: Type): Symbol[] { @@ -4754,19 +4966,106 @@ namespace ts { getPropertiesOfObjectType(type); } + function getConstraintOfType(type: TypeVariable | UnionOrIntersectionType): Type { + return type.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + } + + function getConstraintOfTypeParameter(typeParameter: TypeParameter): Type { + return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; + } + + function getBaseConstraintOfType(type: TypeVariable | UnionOrIntersectionType): Type { + const constraint = getResolvedBaseConstraint(type); + return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + } + + function hasNonCircularBaseConstraint(type: TypeVariable): boolean { + return getResolvedBaseConstraint(type) !== circularConstraintType; + } + /** - * The apparent type of a type parameter is the base constraint instantiated with the type parameter - * as the type argument for the 'this' type. + * Return the resolved base constraint of a type variable. The noConstraintType singleton is returned if the + * type variable has no constraint, and the circularConstraintType singleton is returned if the constraint + * circularly references the type variable. */ - function getApparentTypeOfTypeVariable(type: TypeVariable) { - if (!type.resolvedApparentType) { - let constraintType = getConstraintOfTypeVariable(type); - while (constraintType && constraintType.flags & TypeFlags.TypeParameter) { - constraintType = getConstraintOfTypeVariable(constraintType); - } - type.resolvedApparentType = getTypeWithThisArgument(constraintType || emptyObjectType, type); + function getResolvedBaseConstraint(type: TypeVariable | UnionOrIntersectionType): Type { + let typeStack: Type[]; + let circular: boolean; + if (!type.resolvedBaseConstraint) { + typeStack = []; + const constraint = getBaseConstraint(type); + type.resolvedBaseConstraint = circular ? circularConstraintType : getTypeWithThisArgument(constraint || noConstraintType, type); } - return type.resolvedApparentType; + return type.resolvedBaseConstraint; + + function getBaseConstraint(t: Type): Type { + if (contains(typeStack, t)) { + circular = true; + return undefined; + } + typeStack.push(t); + const result = computeBaseConstraint(t); + typeStack.pop(); + return result; + } + + function computeBaseConstraint(t: Type): Type { + if (t.flags & TypeFlags.TypeParameter) { + const constraint = getConstraintFromTypeParameter(t); + return (t).isThisType ? constraint : + constraint ? getBaseConstraint(constraint) : undefined; + } + if (t.flags & TypeFlags.UnionOrIntersection) { + const types = (t).types; + const baseTypes: Type[] = []; + for (const type of types) { + const baseType = getBaseConstraint(type); + if (baseType) { + baseTypes.push(baseType); + } + } + return t.flags & TypeFlags.Union && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & TypeFlags.Intersection && baseTypes.length ? getIntersectionType(baseTypes) : + undefined; + } + if (t.flags & TypeFlags.Index) { + return stringType; + } + if (t.flags & TypeFlags.IndexedAccess) { + const baseObjectType = getBaseConstraint((t).objectType); + const baseIndexType = getBaseConstraint((t).indexType); + const baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; + return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + } + return t; + } + } + + function getApparentTypeOfIntersectionType(type: IntersectionType) { + return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type)); + } + + /** + * Gets the default type for a type parameter. + * + * If the type parameter is the result of an instantiation, this gets the instantiated + * default type of its target. If the type parameter has no default type, `undefined` + * is returned. + * + * This function *does not* perform a circularity check. + */ + function getDefaultFromTypeParameter(typeParameter: TypeParameter): Type | undefined { + if (!typeParameter.default) { + if (typeParameter.target) { + const targetDefault = getDefaultFromTypeParameter(typeParameter.target); + typeParameter.default = targetDefault ? instantiateType(targetDefault, typeParameter.mapper) : noConstraintType; + } + else { + const defaultDeclaration = typeParameter.symbol && forEach(typeParameter.symbol.declarations, decl => isTypeParameter(decl) && decl.default); + typeParameter.default = defaultDeclaration ? getTypeFromTypeNode(defaultDeclaration) : noConstraintType; + } + } + return typeParameter.default === noConstraintType ? undefined : typeParameter.default; } /** @@ -4775,26 +5074,30 @@ namespace ts { * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type: Type): Type { - const t = type.flags & TypeFlags.TypeVariable ? getApparentTypeOfTypeVariable(type) : type; - return t.flags & TypeFlags.StringLike ? globalStringType : + const t = type.flags & TypeFlags.TypeVariable ? getBaseConstraintOfType(type) || emptyObjectType : type; + return t.flags & TypeFlags.Intersection ? getApparentTypeOfIntersectionType(t) : + t.flags & TypeFlags.StringLike ? globalStringType : t.flags & TypeFlags.NumberLike ? globalNumberType : t.flags & TypeFlags.BooleanLike ? globalBooleanType : - t.flags & TypeFlags.ESSymbol ? getGlobalESSymbolType() : + t.flags & TypeFlags.ESSymbol ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2015) : + t.flags & TypeFlags.NonPrimitive ? emptyObjectType : t; } function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: string): Symbol { - const types = containingType.types; let props: Symbol[]; + const types = containingType.types; + const isUnion = containingType.flags & TypeFlags.Union; + const excludeModifiers = isUnion ? ModifierFlags.NonPublicAccessibilityModifier : 0; // Flags we want to propagate to the result if they exist in all source symbols - let commonFlags = (containingType.flags & TypeFlags.Intersection) ? SymbolFlags.Optional : SymbolFlags.None; - let isReadonly = false; - let isPartial = false; + let commonFlags = isUnion ? SymbolFlags.None : SymbolFlags.Optional; + let checkFlags = CheckFlags.SyntheticProperty; for (const current of types) { const type = getApparentType(current); if (type !== unknownType) { const prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationModifierFlagsFromSymbol(prop) & (ModifierFlags.Private | ModifierFlags.Protected))) { + const modifiers = prop ? getDeclarationModifierFlagsFromSymbol(prop) : 0; + if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; if (!props) { props = [prop]; @@ -4802,26 +5105,26 @@ namespace ts { else if (!contains(props, prop)) { props.push(prop); } - if (isReadonlySymbol(prop)) { - isReadonly = true; - } - + checkFlags |= (isReadonlySymbol(prop) ? CheckFlags.Readonly : 0) | + (!(modifiers & ModifierFlags.NonPublicAccessibilityModifier) ? CheckFlags.ContainsPublic : 0) | + (modifiers & ModifierFlags.Protected ? CheckFlags.ContainsProtected : 0) | + (modifiers & ModifierFlags.Private ? CheckFlags.ContainsPrivate : 0) | + (modifiers & ModifierFlags.Static ? CheckFlags.ContainsStatic : 0); } - else if (containingType.flags & TypeFlags.Union) { - isPartial = true; + else if (isUnion) { + checkFlags |= CheckFlags.Partial; } } } if (!props) { return undefined; } - if (props.length === 1 && !isPartial) { + if (props.length === 1 && !(checkFlags & CheckFlags.Partial)) { return props[0]; } const propTypes: Type[] = []; const declarations: Declaration[] = []; let commonType: Type = undefined; - let hasNonUniformType = false; for (const prop of props) { if (prop.declarations) { addRange(declarations, prop.declarations); @@ -4831,17 +5134,15 @@ namespace ts { commonType = type; } else if (type !== commonType) { - hasNonUniformType = true; + checkFlags |= CheckFlags.HasNonUniformType; } propTypes.push(type); } - const result = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | SymbolFlags.SyntheticProperty | commonFlags, name); + const result = createSymbol(SymbolFlags.Property | commonFlags, name); + result.checkFlags = checkFlags; result.containingType = containingType; - result.hasNonUniformType = hasNonUniformType; - result.isPartial = isPartial; result.declarations = declarations; - result.isReadonly = isReadonly; - result.type = containingType.flags & TypeFlags.Union ? getUnionType(propTypes) : getIntersectionType(propTypes); + result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } @@ -4851,12 +5152,12 @@ namespace ts { // these partial properties when identifying discriminant properties, but otherwise they are filtered out // and do not appear to be present in the union type. function getUnionOrIntersectionProperty(type: UnionOrIntersectionType, name: string): Symbol { - const properties = type.resolvedProperties || (type.resolvedProperties = createMap()); - let property = properties[name]; + const properties = type.propertyCache || (type.propertyCache = createMap()); + let property = properties.get(name); if (!property) { property = createUnionOrIntersectionProperty(type, name); if (property) { - properties[name] = property; + properties.set(name, property); } } return property; @@ -4865,7 +5166,7 @@ namespace ts { function getPropertyOfUnionOrIntersectionType(type: UnionOrIntersectionType, name: string): Symbol { const property = getUnionOrIntersectionProperty(type, name); // We need to filter out partial properties in union types - return property && !(property.flags & SymbolFlags.SyntheticProperty && (property).isPartial) ? property : undefined; + return property && !(getCheckFlags(property) & CheckFlags.Partial) ? property : undefined; } /** @@ -4880,7 +5181,7 @@ namespace ts { type = getApparentType(type); if (type.flags & TypeFlags.Object) { const resolved = resolveStructuredTypeMembers(type); - const symbol = resolved.members[name]; + const symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { return symbol; } @@ -4979,11 +5280,11 @@ namespace ts { function symbolsToArray(symbols: SymbolTable): Symbol[] { const result: Symbol[] = []; - for (const id in symbols) { + symbols.forEach((symbol, id) => { if (!isReservedMemberName(id)) { - result.push(symbols[id]); + result.push(symbol); } - } + }); return result; } @@ -5028,6 +5329,12 @@ namespace ts { Debug.assert(parameterIndex >= 0); return parameterIndex >= signature.minArgumentCount; } + const iife = getImmediatelyInvokedFunctionExpression(node.parent); + if (iife) { + return !node.type && + !node.dotDotDotToken && + indexOf((node.parent as SignatureDeclaration).parameters, node) >= iife.arguments.length; + } return false; } @@ -5050,15 +5357,66 @@ namespace ts { } } + /** + * Gets the minimum number of type arguments needed to satisfy all non-optional type + * parameters. + */ + function getMinTypeArgumentCount(typeParameters: TypeParameter[] | undefined): number { + let minTypeArgumentCount = 0; + if (typeParameters) { + for (let i = 0; i < typeParameters.length; i++) { + if (!getDefaultFromTypeParameter(typeParameters[i])) { + minTypeArgumentCount = i + 1; + } + } + } + return minTypeArgumentCount; + } + + /** + * Fill in default types for unsupplied type arguments. If `typeArguments` is undefined + * when a default type is supplied, a new array will be created and returned. + * + * @param typeArguments The supplied type arguments. + * @param typeParameters The requested type parameters. + * @param minTypeArgumentCount The minimum number of required type arguments. + */ + function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number) { + const numTypeParameters = length(typeParameters); + if (numTypeParameters) { + const numTypeArguments = length(typeArguments); + if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) { + if (!typeArguments) { + typeArguments = []; + } + + // Map an unsatisfied type parameter with a default type. + // If a type parameter does not have a default type, or if the default type + // is a forward reference, the empty object type is used. + for (let i = numTypeArguments; i < numTypeParameters; i++) { + typeArguments[i] = emptyObjectType; + } + for (let i = numTypeArguments; i < numTypeParameters; i++) { + const mapper = createTypeMapper(typeParameters, typeArguments); + const defaultType = getDefaultFromTypeParameter(typeParameters[i]); + typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType; + } + } + } + return typeArguments; + } + function getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature { const links = getNodeLinks(declaration); if (!links.resolvedSignature) { const parameters: Symbol[] = []; let hasLiteralTypes = false; - let minArgumentCount = -1; + let minArgumentCount = 0; let thisParameter: Symbol = undefined; let hasThisParameter: boolean; + const iife = getImmediatelyInvokedFunctionExpression(declaration); const isJSConstructSignature = isJSDocConstructSignature(declaration); + const isUntypedSignatureInJSFile = !iife && !isJSConstructSignature && isInJavaScriptFile(declaration) && !hasJSDocParameterTags(declaration); // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct @@ -5084,14 +5442,13 @@ namespace ts { hasLiteralTypes = true; } - if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { - if (minArgumentCount < 0) { - minArgumentCount = i - (hasThisParameter ? 1 : 0); - } - } - else { - // If we see any required parameters, it means the prior ones were not in fact optional. - minArgumentCount = -1; + // Record a new minimum argument count if this is not an optional parameter + const isOptionalParameter = param.initializer || param.questionToken || param.dotDotDotToken || + iife && parameters.length > iife.arguments.length && !param.type || + isJSDocOptionalParameter(param) || + isUntypedSignatureInJSFile; + if (!isOptionalParameter) { + minArgumentCount = parameters.length; } } @@ -5106,13 +5463,6 @@ namespace ts { } } - if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); - } - if (isJSConstructSignature) { - minArgumentCount--; - } - const classType = declaration.kind === SyntaxKind.Constructor ? getDeclaredTypeOfClassOrInterface(getMergedSymbol((declaration.parent).symbol)) : undefined; @@ -5255,9 +5605,14 @@ namespace ts { } function getSignatureInstantiation(signature: Signature, typeArguments: Type[]): Signature { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); const instantiations = signature.instantiations || (signature.instantiations = createMap()); const id = getTypeListId(typeArguments); - return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments)); + let instantiation = instantiations.get(id); + if (!instantiation) { + instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments)); + } + return instantiation; } function createSignatureInstantiation(signature: Signature, typeArguments: Type[]): Signature { @@ -5291,7 +5646,7 @@ namespace ts { } function getIndexSymbol(symbol: Symbol): Symbol { - return symbol.members["__index"]; + return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol: Symbol, kind: IndexKind): SignatureDeclaration { @@ -5329,20 +5684,7 @@ namespace ts { return (getDeclarationOfKind(type.symbol, SyntaxKind.TypeParameter)).constraint; } - function hasConstraintReferenceTo(type: Type, target: TypeParameter): boolean { - let checked: Type[]; - while (type && type.flags & TypeFlags.TypeParameter && !((type as TypeParameter).isThisType) && !contains(checked, type)) { - if (type === target) { - return true; - } - (checked || (checked = [])).push(type); - const constraintDeclaration = getConstraintDeclaration(type); - type = constraintDeclaration && getTypeFromTypeNode(constraintDeclaration); - } - return false; - } - - function getConstraintOfTypeParameter(typeParameter: TypeParameter): Type { + function getConstraintFromTypeParameter(typeParameter: TypeParameter): Type { if (!typeParameter.constraint) { if (typeParameter.target) { const targetConstraint = getConstraintOfTypeParameter(typeParameter.target); @@ -5350,23 +5692,12 @@ namespace ts { } else { const constraintDeclaration = getConstraintDeclaration(typeParameter); - let constraint = getTypeFromTypeNode(constraintDeclaration); - if (hasConstraintReferenceTo(constraint, typeParameter)) { - error(constraintDeclaration, Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); - constraint = unknownType; - } - typeParameter.constraint = constraint; + typeParameter.constraint = constraintDeclaration ? getTypeFromTypeNode(constraintDeclaration) : noConstraintType; } } return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } - function getConstraintOfTypeVariable(type: TypeVariable): Type { - return type.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(type) : - type.flags & TypeFlags.IndexedAccess ? (type).constraint : - undefined; - } - function getParentSymbolOfTypeParameter(typeParameter: TypeParameter): Symbol { return getSymbolOfNode(getDeclarationOfKind(typeParameter.symbol, SyntaxKind.TypeParameter).parent); } @@ -5411,9 +5742,10 @@ namespace ts { function createTypeReference(target: GenericType, typeArguments: Type[]): TypeReference { const id = getTypeListId(typeArguments); - let type = target.instantiations[id]; + let type = target.instantiations.get(id); if (!type) { - type = target.instantiations[id] = createObjectType(ObjectFlags.Reference, target.symbol); + type = createObjectType(ObjectFlags.Reference, target.symbol); + target.instantiations.set(id, type); type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; type.typeArguments = typeArguments; @@ -5431,7 +5763,7 @@ namespace ts { } function getTypeReferenceArity(type: TypeReference): number { - return type.target.typeParameters ? type.target.typeParameters.length : 0; + return length(type.target.typeParameters); } // Get type from reference to class or interface @@ -5439,14 +5771,23 @@ namespace ts { const type = getDeclaredTypeOfSymbol(getMergedSymbol(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); + const numTypeArguments = length(node.typeArguments); + const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, + minTypeArgumentCount === typeParameters.length + ? Diagnostics.Generic_type_0_requires_1_type_argument_s + : Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, + typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType), + minTypeArgumentCount, + 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, concatenate(type.outerTypeParameters, map(node.typeArguments, getTypeFromTypeNode))); + const typeArguments = concatenate(type.outerTypeParameters, fillMissingTypeArguments(map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount)); + return createTypeReference(type, typeArguments); } if (node.typeArguments) { error(node, Diagnostics.Type_0_is_not_generic, typeToString(type)); @@ -5460,7 +5801,11 @@ namespace ts { const links = getSymbolLinks(symbol); const typeParameters = links.typeParameters; const id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + let instantiation = links.instantiations.get(id); + if (!instantiation) { + links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + } + return instantiation; } // Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include @@ -5470,8 +5815,16 @@ namespace ts { const type = getDeclaredTypeOfSymbol(symbol); const typeParameters = getSymbolLinks(symbol).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); + const numTypeArguments = length(node.typeArguments); + const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + error(node, + minTypeArgumentCount === typeParameters.length + ? Diagnostics.Generic_type_0_requires_1_type_argument_s + : Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, + symbolToString(symbol), + minTypeArgumentCount, + typeParameters.length); return unknownType; } const typeArguments = map(node.typeArguments, getTypeFromTypeNode); @@ -5609,27 +5962,82 @@ namespace ts { error(getTypeDeclaration(symbol), 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) { + if (length((type).typeParameters) !== arity) { error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); return arity ? emptyGenericType : emptyObjectType; } return type; } - function getGlobalValueSymbol(name: string): Symbol { - return getGlobalSymbol(name, SymbolFlags.Value, Diagnostics.Cannot_find_global_value_0); + function getGlobalValueSymbol(name: string, reportErrors: boolean): Symbol { + return getGlobalSymbol(name, SymbolFlags.Value, reportErrors ? Diagnostics.Cannot_find_global_value_0 : undefined); } - function getGlobalTypeSymbol(name: string): Symbol { - return getGlobalSymbol(name, SymbolFlags.Type, Diagnostics.Cannot_find_global_type_0); + function getGlobalTypeSymbol(name: string, reportErrors: boolean): Symbol { + return getGlobalSymbol(name, SymbolFlags.Type, reportErrors ? Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name: string, meaning: SymbolFlags, diagnostic: DiagnosticMessage): Symbol { return resolveName(undefined, name, meaning, diagnostic, name); } - function getGlobalType(name: string, arity = 0): ObjectType { - return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); + function getGlobalType(name: string, arity: 0, reportErrors: boolean): ObjectType; + function getGlobalType(name: string, arity: number, reportErrors: boolean): GenericType; + function getGlobalType(name: string, arity: number, reportErrors: boolean): ObjectType { + const symbol = getGlobalTypeSymbol(name, reportErrors); + return symbol || reportErrors ? getTypeOfGlobalSymbol(symbol, arity) : undefined; + } + + function getGlobalTypedPropertyDescriptorType() { + return deferredGlobalTypedPropertyDescriptorType || (deferredGlobalTypedPropertyDescriptorType = getGlobalType("TypedPropertyDescriptor", /*arity*/ 1, /*reportErrors*/ true)) || emptyGenericType; + } + + function getGlobalTemplateStringsArrayType() { + return deferredGlobalTemplateStringsArrayType || (deferredGlobalTemplateStringsArrayType = getGlobalType("TemplateStringsArray", /*arity*/ 0, /*reportErrors*/ true)) || emptyObjectType; + } + + function getGlobalESSymbolConstructorSymbol(reportErrors: boolean) { + return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors)); + } + + function getGlobalESSymbolType(reportErrors: boolean) { + return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, reportErrors)) || emptyObjectType; + } + + function getGlobalPromiseType(reportErrors: boolean) { + return deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + + function getGlobalPromiseConstructorSymbol(reportErrors: boolean): Symbol | undefined { + return deferredGlobalPromiseConstructorSymbol || (deferredGlobalPromiseConstructorSymbol = getGlobalValueSymbol("Promise", reportErrors)); + } + + function getGlobalPromiseConstructorLikeType(reportErrors: boolean) { + return deferredGlobalPromiseConstructorLikeType || (deferredGlobalPromiseConstructorLikeType = getGlobalType("PromiseConstructorLike", /*arity*/ 0, reportErrors)) || emptyObjectType; + } + + function getGlobalAsyncIterableType(reportErrors: boolean) { + return deferredGlobalAsyncIterableType || (deferredGlobalAsyncIterableType = getGlobalType("AsyncIterable", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + + function getGlobalAsyncIteratorType(reportErrors: boolean) { + return deferredGlobalAsyncIteratorType || (deferredGlobalAsyncIteratorType = getGlobalType("AsyncIterator", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + + function getGlobalAsyncIterableIteratorType(reportErrors: boolean) { + return deferredGlobalAsyncIterableIteratorType || (deferredGlobalAsyncIterableIteratorType = getGlobalType("AsyncIterableIterator", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + + function getGlobalIterableType(reportErrors: boolean) { + return deferredGlobalIterableType || (deferredGlobalIterableType = getGlobalType("Iterable", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + + function getGlobalIteratorType(reportErrors: boolean) { + return deferredGlobalIteratorType || (deferredGlobalIteratorType = getGlobalType("Iterator", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + + function getGlobalIterableIteratorType(reportErrors: boolean) { + return deferredGlobalIterableIteratorType || (deferredGlobalIterableIteratorType = getGlobalType("IterableIterator", /*arity*/ 1, reportErrors)) || emptyGenericType; } /** @@ -5642,16 +6050,6 @@ namespace ts { return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } - /** - * Creates a TypeReference for a generic `TypedPropertyDescriptor`. - */ - function createTypedPropertyDescriptorType(propertyType: Type): Type { - const globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyGenericType - ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) - : emptyObjectType; - } - /** * Instantiates a global type that is generic with some element type, and returns that instantiation. */ @@ -5659,12 +6057,24 @@ namespace ts { return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } - function createIterableType(elementType: Type): Type { - return createTypeFromGenericGlobalType(getGlobalIterableType(), [elementType]); + function createTypedPropertyDescriptorType(propertyType: Type): Type { + return createTypeFromGenericGlobalType(getGlobalTypedPropertyDescriptorType(), [propertyType]); } - function createIterableIteratorType(elementType: Type): Type { - return createTypeFromGenericGlobalType(getGlobalIterableIteratorType(), [elementType]); + function createAsyncIterableType(iteratedType: Type): Type { + return createTypeFromGenericGlobalType(getGlobalAsyncIterableType(/*reportErrors*/ true), [iteratedType]); + } + + function createAsyncIterableIteratorType(iteratedType: Type): Type { + return createTypeFromGenericGlobalType(getGlobalAsyncIterableIteratorType(/*reportErrors*/ true), [iteratedType]); + } + + function createIterableType(iteratedType: Type): Type { + return createTypeFromGenericGlobalType(getGlobalIterableType(/*reportErrors*/ true), [iteratedType]); + } + + function createIterableIteratorType(iteratedType: Type): Type { + return createTypeFromGenericGlobalType(getGlobalIterableIteratorType(/*reportErrors*/ true), [iteratedType]); } function createArrayType(elementType: Type): ObjectType { @@ -5692,7 +6102,7 @@ namespace ts { for (let i = 0; i < arity; i++) { const typeParameter = createType(TypeFlags.TypeParameter); typeParameters.push(typeParameter); - const property = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "" + i); + const property = createSymbol(SymbolFlags.Property, "" + i); property.type = typeParameter; properties.push(property); } @@ -5701,7 +6111,7 @@ namespace ts { type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; type.instantiations = createMap(); - type.instantiations[getTypeListId(type.typeParameters)] = type; + type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; type.thisType = createType(TypeFlags.TypeParameter); @@ -5906,10 +6316,11 @@ namespace ts { return types[0]; } const id = getTypeListId(types); - let type = unionTypes[id]; + let type = unionTypes.get(id); if (!type) { const propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ TypeFlags.Nullable); - type = unionTypes[id] = createType(TypeFlags.Union | propagatedFlags); + type = createType(TypeFlags.Union | propagatedFlags); + unionTypes.set(id, type); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -5937,7 +6348,10 @@ namespace ts { if (type.flags & TypeFlags.Union && typeSet.unionIndex === undefined) { typeSet.unionIndex = typeSet.length; } - typeSet.push(type); + if (!(type.flags & TypeFlags.Object && (type).objectFlags & ObjectFlags.Anonymous && + type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && containsIdenticalType(typeSet, type))) { + typeSet.push(type); + } } } @@ -5980,10 +6394,11 @@ namespace ts { /*subtypeReduction*/ false, aliasSymbol, aliasTypeArguments); } const id = getTypeListId(typeSet); - let type = intersectionTypes[id]; + let type = intersectionTypes.get(id); if (!type) { const propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ TypeFlags.Nullable); - type = intersectionTypes[id] = createType(TypeFlags.Intersection | propagatedFlags); + type = createType(TypeFlags.Intersection | propagatedFlags); + intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -6042,24 +6457,6 @@ namespace ts { const type = createType(TypeFlags.IndexedAccess); type.objectType = objectType; type.indexType = indexType; - // We eagerly compute the constraint of the indexed access type such that circularity - // errors are immediately caught and reported. For example, class C { x: this["x"] } - // becomes an error only when the constraint is eagerly computed. - if (type.objectType.flags & TypeFlags.StructuredType) { - // The constraint of T[K], where T is an object, union, or intersection type, - // is the type of the string index signature of T, if any. - type.constraint = getIndexTypeOfType(type.objectType, IndexKind.String); - } - else if (type.objectType.flags & TypeFlags.TypeVariable) { - // The constraint of T[K], where T is a type variable, is A[K], where A is the - // apparent type of T. - const apparentType = getApparentTypeOfTypeVariable(type.objectType); - if (apparentType !== emptyObjectType) { - type.constraint = isTypeOfKind((type).indexType, TypeFlags.StringLike) ? - getIndexedAccessType(apparentType, (type).indexType) : - getIndexTypeOfType(apparentType, IndexKind.String); - } - } return type; } @@ -6132,7 +6529,7 @@ namespace ts { error(accessExpression, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); return unknownType; } - const mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); + const mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); const templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } @@ -6150,13 +6547,6 @@ namespace ts { if (objectType.flags & TypeFlags.Any) { return objectType; } - // We first check that the index type is assignable to 'keyof T' for the object type. - if (accessNode) { - if (!isTypeAssignableTo(indexType, getIndexType(objectType))) { - error(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); - return unknownType; - } - } // If the object type is a mapped type { [P in K]: E }, we instantiate E using a mapper that substitutes // the index type for P. For example, for an index access { [P in K]: Box }[X], we construct the // type Box. @@ -6165,7 +6555,11 @@ namespace ts { } // Otherwise we defer the operation by creating an indexed access type. const id = objectType.id + "," + indexType.id; - return indexedAccessTypes[id] || (indexedAccessTypes[id] = createIndexedAccessType(objectType, indexType)); + let type = indexedAccessTypes.get(id); + if (!type) { + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType)); + } + return type; } // In the following we resolve T[K] to the type of the property in T selected by K. const apparentObjectType = getApparentType(objectType); @@ -6211,7 +6605,7 @@ namespace ts { if (!links.resolvedType) { // Deferred resolution of members is handled by resolveObjectTypeMembers const aliasSymbol = getAliasSymbolForTypeNode(node); - if (isEmpty(node.symbol.members) && !aliasSymbol) { + if (node.symbol.members.size === 0 && !aliasSymbol) { links.resolvedType = emptyTypeLiteralType; } else { @@ -6238,7 +6632,7 @@ namespace ts { * this function should be called in a left folding style, with left = previous result of getSpreadType * and right = the new element to be spread. */ - function getSpreadType(left: Type, right: Type, isFromObjectLiteral: boolean): Type { + function getSpreadType(left: Type, right: Type): Type { if (left.flags & TypeFlags.Any || right.flags & TypeFlags.Any) { return anyType; } @@ -6251,10 +6645,13 @@ namespace ts { return left; } if (left.flags & TypeFlags.Union) { - return mapType(left, t => getSpreadType(t, right, isFromObjectLiteral)); + return mapType(left, t => getSpreadType(t, right)); } if (right.flags & TypeFlags.Union) { - return mapType(right, t => getSpreadType(left, t, isFromObjectLiteral)); + return mapType(right, t => getSpreadType(left, t)); + } + if (right.flags & TypeFlags.NonPrimitive) { + return emptyObjectType; } const members = createMap(); @@ -6273,42 +6670,46 @@ namespace ts { for (const rightProp of getPropertiesOfType(right)) { // we approximate own properties as non-methods plus methods that are inside the object literal - const isOwnProperty = !(rightProp.flags & SymbolFlags.Method) || isFromObjectLiteral; const isSetterWithoutGetter = rightProp.flags & SymbolFlags.SetAccessor && !(rightProp.flags & SymbolFlags.GetAccessor); if (getDeclarationModifierFlagsFromSymbol(rightProp) & (ModifierFlags.Private | ModifierFlags.Protected)) { - skippedPrivateMembers[rightProp.name] = true; + skippedPrivateMembers.set(rightProp.name, true); } - else if (isOwnProperty && !isSetterWithoutGetter) { - members[rightProp.name] = rightProp; + else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { + members.set(rightProp.name, rightProp); } } for (const leftProp of getPropertiesOfType(left)) { if (leftProp.flags & SymbolFlags.SetAccessor && !(leftProp.flags & SymbolFlags.GetAccessor) - || leftProp.name in skippedPrivateMembers) { + || skippedPrivateMembers.has(leftProp.name) + || isClassMethod(leftProp)) { continue; } - if (leftProp.name in members) { - const rightProp = members[leftProp.name]; + if (members.has(leftProp.name)) { + const rightProp = members.get(leftProp.name); const rightType = getTypeOfSymbol(rightProp); if (maybeTypeOfKind(rightType, TypeFlags.Undefined) || rightProp.flags & SymbolFlags.Optional) { const declarations: Declaration[] = concatenate(leftProp.declarations, rightProp.declarations); - const flags = SymbolFlags.Property | SymbolFlags.Transient | (leftProp.flags & SymbolFlags.Optional); - const result = createSymbol(flags, leftProp.name); + const flags = SymbolFlags.Property | (leftProp.flags & SymbolFlags.Optional); + const result = createSymbol(flags, leftProp.name); + result.checkFlags = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp) ? CheckFlags.Readonly : 0; result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, TypeFacts.NEUndefined)]); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; - result.isReadonly = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp); - members[leftProp.name] = result; + members.set(leftProp.name, result); } } else { - members[leftProp.name] = leftProp; + members.set(leftProp.name, leftProp); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } + function isClassMethod(prop: Symbol) { + return prop.flags & SymbolFlags.Method && find(prop.declarations, decl => isClassLike(decl.parent)); + } + function createLiteralType(flags: TypeFlags, text: string) { const type = createType(flags); type.text = text; @@ -6333,7 +6734,11 @@ namespace ts { function getLiteralTypeForText(flags: TypeFlags, text: string) { const map = flags & TypeFlags.StringLiteral ? stringLiteralTypes : numericLiteralTypes; - return map[text] || (map[text] = createLiteralType(flags, text)); + let type = map.get(text); + if (!type) { + map.set(text, type = createLiteralType(flags, text)); + } + return type; } function getTypeFromLiteralTypeNode(node: LiteralTypeNode): Type { @@ -6405,6 +6810,8 @@ namespace ts { return nullType; case SyntaxKind.NeverKeyword: return neverType; + case SyntaxKind.ObjectKeyword: + return nonPrimitiveType; case SyntaxKind.JSDocNullKeyword: return nullType; case SyntaxKind.JSDocUndefinedKeyword: @@ -6497,16 +6904,16 @@ namespace ts { return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); } - function createUnaryTypeMapper(source: Type, target: Type): TypeMapper { - return t => t === source ? target : t; + function makeUnaryTypeMapper(source: Type, target: Type) { + return (t: Type) => t === source ? target : t; } - function createBinaryTypeMapper(source1: Type, target1: Type, source2: Type, target2: Type): TypeMapper { - return t => t === source1 ? target1 : t === source2 ? target2 : t; + function makeBinaryTypeMapper(source1: Type, target1: Type, source2: Type, target2: Type) { + return (t: Type) => t === source1 ? target1 : t === source2 ? target2 : t; } - function createArrayTypeMapper(sources: Type[], targets: Type[]): TypeMapper { - return t => { + function makeArrayTypeMapper(sources: Type[], targets: Type[]) { + return (t: Type) => { for (let i = 0; i < sources.length; i++) { if (t === sources[i]) { return targets ? targets[i] : anyType; @@ -6517,11 +6924,9 @@ namespace ts { } function createTypeMapper(sources: Type[], targets: Type[]): TypeMapper { - const count = sources.length; - const mapper: TypeMapper = - count == 1 ? createUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : - count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : - createArrayTypeMapper(sources, targets); + const mapper: TypeMapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : + makeArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; return mapper; } @@ -6530,6 +6935,16 @@ namespace ts { return createTypeMapper(sources, undefined); } + /** + * Maps forward-references to later types parameters to the empty object type. + * This is used during inference when instantiating type parameter defaults. + */ + function createBackreferenceMapper(typeParameters: TypeParameter[], index: number) { + const mapper: TypeMapper = t => indexOf(typeParameters, t) >= index ? emptyObjectType : t; + mapper.mappedTypes = typeParameters; + return mapper; + } + function getInferenceMapper(context: InferenceContext): TypeMapper { if (!context.mapper) { const mapper: TypeMapper = t => { @@ -6555,7 +6970,13 @@ namespace ts { function combineTypeMappers(mapper1: TypeMapper, mapper2: TypeMapper): TypeMapper { const mapper: TypeMapper = t => instantiateType(mapper1(t), mapper2); - mapper.mappedTypes = mapper1.mappedTypes; + mapper.mappedTypes = concatenate(mapper1.mappedTypes, mapper2.mappedTypes); + return mapper; + } + + function createReplacementMapper(source: Type, target: Type, baseMapper: TypeMapper) { + const mapper: TypeMapper = t => t === source ? target : baseMapper(t); + mapper.mappedTypes = baseMapper.mappedTypes; return mapper; } @@ -6611,7 +7032,7 @@ namespace ts { } function instantiateSymbol(symbol: Symbol, mapper: TypeMapper): Symbol { - if (symbol.flags & SymbolFlags.Instantiated) { + if (getCheckFlags(symbol) & CheckFlags.Instantiated) { 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 @@ -6619,10 +7040,10 @@ namespace ts { 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. - const result = createSymbol(SymbolFlags.Instantiated | SymbolFlags.Transient | symbol.flags, symbol.name); + const result = createSymbol(symbol.flags, symbol.name); + result.checkFlags = CheckFlags.Instantiated; result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -6630,7 +7051,6 @@ namespace ts { if (symbol.valueDeclaration) { result.valueDeclaration = symbol.valueDeclaration; } - return result; } @@ -6657,10 +7077,7 @@ namespace ts { if (typeVariable !== mappedTypeVariable) { return mapType(mappedTypeVariable, t => { if (isMappableType(t)) { - const replacementMapper = createUnaryTypeMapper(typeVariable, t); - const combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); - combinedMapper.mappedTypes = mapper.mappedTypes; - return instantiateMappedObjectType(type, combinedMapper); + return instantiateMappedObjectType(type, createReplacementMapper(typeVariable, t, mapper)); } return t; }); @@ -6726,6 +7143,11 @@ namespace ts { } } break; + case SyntaxKind.MappedType: + if (contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode((node).typeParameter)))) { + return true; + } + break; case SyntaxKind.JSDocFunctionType: const func = node as JSDocFunctionType; for (const p of func.parameters) { @@ -6826,7 +7248,7 @@ namespace 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: Expression | MethodDeclaration | ObjectLiteralElementLike): boolean { + function isContextSensitive(node: Expression | MethodDeclaration | ObjectLiteralElementLike | JsxAttributeLike): boolean { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); switch (node.kind) { case SyntaxKind.FunctionExpression: @@ -6849,6 +7271,14 @@ namespace ts { return isContextSensitiveFunctionLikeDeclaration(node); case SyntaxKind.ParenthesizedExpression: return isContextSensitive((node).expression); + case SyntaxKind.JsxAttributes: + return forEach((node).properties, isContextSensitive); + case SyntaxKind.JsxAttribute: + // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. + return (node).initializer && isContextSensitive((node).initializer); + case SyntaxKind.JsxExpression: + // It is possible to that node.expression is undefined (e.g
) + return (node).expression && isContextSensitive((node).expression); } return false; @@ -6888,9 +7318,12 @@ namespace ts { result.properties = resolved.properties; result.callSignatures = emptyArray; result.constructSignatures = emptyArray; - type = result; + return result; } } + else if (type.flags & TypeFlags.Intersection) { + return getIntersectionType(map((type).types, getTypeWithoutSignatures)); + } return type; } @@ -6920,7 +7353,7 @@ namespace ts { // subtype of T but not structurally identical to T. This specifically means that two distinct but // structurally identical types (such as two classes) are not considered instances of each other. function isTypeInstanceOf(source: Type, target: Type): boolean { - return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + return getTargetType(source) === getTargetType(target) || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); } /** @@ -7128,13 +7561,15 @@ namespace ts { return true; } const id = source.id + "," + target.id; - if (enumRelation[id] !== undefined) { - return enumRelation[id]; + const relation = enumRelation.get(id); + if (relation !== undefined) { + return relation; } if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & SymbolFlags.RegularEnum) || !(target.symbol.flags & SymbolFlags.RegularEnum) || (source.flags & TypeFlags.Union) !== (target.flags & TypeFlags.Union)) { - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } const targetEnumType = getTypeOfSymbol(target.symbol); for (const property of getPropertiesOfType(getTypeOfSymbol(source.symbol))) { @@ -7145,11 +7580,13 @@ namespace ts { errorReporter(Diagnostics.Property_0_is_missing_in_type_1, property.name, typeToString(target, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType)); } - return enumRelation[id] = false; + enumRelation.set(id, false); + return false; } } } - return enumRelation[id] = true; + enumRelation.set(id, true); + return true; } function isSimpleTypeRelatedTo(source: Type, target: Type, relation: Map, errorReporter?: ErrorReporter) { @@ -7162,6 +7599,7 @@ namespace ts { if (source.flags & TypeFlags.Enum && target.flags & TypeFlags.Enum && isEnumTypeRelatedTo(source, target, errorReporter)) return true; if (source.flags & TypeFlags.Undefined && (!strictNullChecks || target.flags & (TypeFlags.Undefined | TypeFlags.Void))) return true; if (source.flags & TypeFlags.Null && (!strictNullChecks || target.flags & TypeFlags.Null)) return true; + if (source.flags & TypeFlags.Object && target.flags & TypeFlags.NonPrimitive) return true; if (relation === assignableRelation || relation === comparableRelation) { if (source.flags & TypeFlags.Any) return true; if ((source.flags & TypeFlags.Number | source.flags & TypeFlags.NumberLiteral) && target.flags & TypeFlags.EnumLike) return true; @@ -7192,12 +7630,12 @@ namespace ts { } if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) { const id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - const related = relation[id]; + const related = relation.get(id); if (related !== undefined) { return related === RelationComparisonResult.Succeeded; } } - if (source.flags & TypeFlags.StructuredOrTypeParameter || target.flags & TypeFlags.StructuredOrTypeParameter) { + if (source.flags & TypeFlags.StructuredOrTypeVariable || target.flags & TypeFlags.StructuredOrTypeVariable) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -7279,7 +7717,7 @@ namespace ts { if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || - (getGlobalESSymbolType() === source && esSymbolType === target)) { + (getGlobalESSymbolType(/*reportErrors*/ false) === source && esSymbolType === target)) { reportError(Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType); } } @@ -7397,16 +7835,6 @@ namespace ts { } } } - else { - // Given a type parameter K with a constraint keyof T, a type S is - // assignable to K if S is assignable to keyof T. - const constraint = getConstraintOfTypeParameter(target); - if (constraint && constraint.flags & TypeFlags.Index) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - return result; - } - } - } } else if (target.flags & TypeFlags.Index) { // A keyof S is related to a keyof T if T is related to S. @@ -7415,14 +7843,12 @@ namespace ts { return result; } } - // Given a type variable T with a constraint C, a type S is assignable to - // keyof T if S is assignable to keyof C. - if ((target).type.flags & TypeFlags.TypeVariable) { - const constraint = getConstraintOfTypeVariable((target).type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } + // A type S is assignable to keyof T if S is assignable to keyof C, where C is the + // constraint of T. + const constraint = getConstraintOfType((target).type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; } } } @@ -7436,8 +7862,9 @@ namespace ts { } // A type S is related to a type T[K] if S is related to A[K], where K is string-like and // A is the apparent type of S. - if ((target).constraint) { - if (result = isRelatedTo(source, (target).constraint, reportErrors)) { + const constraint = getBaseConstraintOfType(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -7456,27 +7883,28 @@ namespace ts { } else { let constraint = getConstraintOfTypeParameter(source); - - if (!constraint || constraint.flags & TypeFlags.Any) { - constraint = emptyObjectType; - } - - // The constraint may need to be further instantiated with its 'this' type. - constraint = getTypeWithThisArgument(constraint, source); - - // Report constraint errors only if the constraint is not the empty object type - const reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; + // A type parameter with no constraint is not related to the non-primitive object type. + if (constraint || !(target.flags & TypeFlags.NonPrimitive)) { + if (!constraint || constraint.flags & TypeFlags.Any) { + constraint = emptyObjectType; + } + // The constraint may need to be further instantiated with its 'this' type. + constraint = getTypeWithThisArgument(constraint, source); + // Report constraint errors only if the constraint is not the empty object type + const reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } } else if (source.flags & TypeFlags.IndexedAccess) { // A type S[K] is related to a type T if A[K] is related to T, where K is string-like and // A is the apparent type of S. - if ((source).constraint) { - if (result = isRelatedTo((source).constraint, target, reportErrors)) { + const constraint = getBaseConstraintOfType(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -7543,19 +7971,24 @@ namespace ts { // 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: Type, name: string): boolean { + function isKnownProperty(type: Type, name: string, isComparingJsxAttributes: boolean): boolean { if (type.flags & TypeFlags.Object) { const resolved = resolveStructuredTypeMembers(type); - if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) || - resolved.stringIndexInfo || - (resolved.numberIndexInfo && isNumericLiteralName(name)) || - getPropertyOfType(type, name)) { + if ((relation === assignableRelation || relation === comparableRelation) && + (type === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(resolved)))) { + return true; + } + else if (resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name))) { + return true; + } + else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) { + // For JSXAttributes, if the attribute has a hyphenated name, consider that the attribute to be known. return true; } } else if (type.flags & TypeFlags.UnionOrIntersection) { for (const t of (type).types) { - if (isKnownProperty(t, name)) { + if (isKnownProperty(t, name, isComparingJsxAttributes)) { return true; } } @@ -7563,7 +7996,7 @@ namespace ts { return false; } - function isEmptyObjectType(t: ResolvedType) { + function isEmptyResolvedType(t: ResolvedType) { return t.properties.length === 0 && t.callSignatures.length === 0 && t.constructSignatures.length === 0 && @@ -7571,18 +8004,30 @@ namespace ts { !t.numberIndexInfo; } + function isEmptyObjectType(type: Type) { + return type.flags & TypeFlags.Object && isEmptyResolvedType(resolveStructuredTypeMembers(type)); + } + function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean { if (maybeTypeOfKind(target, TypeFlags.Object) && !(getObjectFlags(target) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) { + const isComparingJsxAttributes = !!(source.flags & TypeFlags.JsxAttributes); for (const prop of getPropertiesOfObjectType(source)) { - if (!isKnownProperty(target, prop.name)) { + if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) { 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. Debug.assert(!!errorNode); - errorNode = prop.valueDeclaration; - reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, - symbolToString(prop), typeToString(target)); + if (isJsxAttributes(errorNode)) { + // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. + // However, using an object-literal error message will be very confusing to the users so we give different a message. + reportError(Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); + } + else { + errorNode = prop.valueDeclaration; + reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, + symbolToString(prop), typeToString(target)); + } } return true; } @@ -7609,16 +8054,36 @@ namespace ts { if (target.flags & TypeFlags.Union && containsType(targetTypes, source)) { return Ternary.True; } - const len = targetTypes.length; - for (let i = 0; i < len; i++) { - const related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); + for (const type of targetTypes) { + const related = isRelatedTo(source, type, /*reportErrors*/ false); if (related) { return related; } } + if (reportErrors) { + const discriminantType = findMatchingDiscriminantType(source, target); + isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); + } return Ternary.False; } + function findMatchingDiscriminantType(source: Type, target: UnionOrIntersectionType) { + const sourceProperties = getPropertiesOfObjectType(source); + if (sourceProperties) { + for (const sourceProperty of sourceProperties) { + if (isDiscriminantProperty(target, sourceProperty.name)) { + const sourceType = getTypeOfSymbol(sourceProperty); + for (const type of target.types) { + const targetType = getTypeOfPropertyOfType(type, sourceProperty.name); + if (targetType && isRelatedTo(sourceType, targetType)) { + return type; + } + } + } + } + } + } + function typeRelatedToEachType(source: Type, target: UnionOrIntersectionType, reportErrors: boolean): Ternary { let result = Ternary.True; const targetTypes = target.types; @@ -7688,12 +8153,12 @@ namespace ts { return Ternary.False; } const id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; - const related = relation[id]; + const related = relation.get(id); if (related !== undefined) { if (reportErrors && related === RelationComparisonResult.Failed) { // We are elaborating errors and the cached result is an unreported failure. Record the result as a reported // failure and continue computing the relation such that errors get reported. - relation[id] = RelationComparisonResult.FailedAndReported; + relation.set(id, RelationComparisonResult.FailedAndReported); } else { return related === RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False; @@ -7702,7 +8167,7 @@ namespace ts { if (depth > 0) { for (let i = 0; i < depth; i++) { // If source and target are already being compared, consider them related with assumptions - if (maybeStack[i][id]) { + if (maybeStack[i].get(id)) { return Ternary.Maybe; } } @@ -7720,7 +8185,7 @@ namespace ts { sourceStack[depth] = source; targetStack[depth] = target; maybeStack[depth] = createMap(); - maybeStack[depth][id] = RelationComparisonResult.Succeeded; + maybeStack[depth].set(id, RelationComparisonResult.Succeeded); depth++; const saveExpandingFlags = expandingFlags; if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) expandingFlags |= 1; @@ -7753,42 +8218,45 @@ namespace ts { const maybeCache = maybeStack[depth]; // If result is definitely true, copy assumptions to global cache, else copy to next level up const destinationCache = (result === Ternary.True || depth === 0) ? relation : maybeStack[depth - 1]; - copyProperties(maybeCache, destinationCache); + copyEntries(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 ? RelationComparisonResult.FailedAndReported : RelationComparisonResult.Failed; + relation.set(id, reportErrors ? RelationComparisonResult.FailedAndReported : RelationComparisonResult.Failed); } return result; } - // A type [P in S]: X is related to a type [P in T]: Y if T is related to S and X is related to Y. + // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is + // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice + // that S and T are contra-variant whereas X and Y are co-variant. function mappedTypeRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { - let result: Ternary; - if (relation === identityRelation) { - const readonlyMatches = !(source).declaration.readonlyToken === !(target).declaration.readonlyToken; - const optionalMatches = !(source).declaration.questionToken === !(target).declaration.questionToken; - if (readonlyMatches && optionalMatches) { - if (result = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result & isRelatedTo(getErasedTemplateTypeFromMappedType(source), getErasedTemplateTypeFromMappedType(target), reportErrors); - } - } - } - else { - if (relation === comparableRelation || !(source).declaration.questionToken || (target).declaration.questionToken) { - if (result = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { - return result & isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors); - } + const sourceReadonly = !!(source).declaration.readonlyToken; + const sourceOptional = !!(source).declaration.questionToken; + const targetReadonly = !!(target).declaration.readonlyToken; + const targetOptional = !!(target).declaration.questionToken; + const modifiersRelated = relation === identityRelation ? + sourceReadonly === targetReadonly && sourceOptional === targetOptional : + relation === comparableRelation || !sourceOptional || targetOptional; + if (modifiersRelated) { + let result: Ternary; + if (result = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { + const mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); + return result & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } + else if ((target).declaration.questionToken && isEmptyObjectType(source)) { + return Ternary.True; + + } } else if (relation !== identityRelation) { const resolved = resolveStructuredTypeMembers(target); - if (isEmptyObjectType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & TypeFlags.Any) { + if (isEmptyResolvedType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & TypeFlags.Any) { return Ternary.True; } } @@ -7818,6 +8286,12 @@ namespace ts { const sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); const targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & ModifierFlags.Private || targetPropFlags & ModifierFlags.Private) { + if (getCheckFlags(sourceProp) & CheckFlags.ContainsPrivate) { + if (reportErrors) { + reportError(Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); + } + return Ternary.False; + } if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { if (sourcePropFlags & ModifierFlags.Private && targetPropFlags & ModifierFlags.Private) { @@ -7833,13 +8307,10 @@ namespace ts { } } else if (targetPropFlags & ModifierFlags.Protected) { - const sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & SymbolFlags.Class; - const sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(getParentOfSymbol(sourceProp)) : undefined; - const targetClass = getDeclaredTypeOfSymbol(getParentOfSymbol(targetProp)); - if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { + if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors) { - reportError(Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, - symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); + reportError(Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), + typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } return Ternary.False; } @@ -8081,6 +8552,49 @@ namespace ts { } } + // Invoke the callback for each underlying property symbol of the given symbol and return the first + // value that isn't undefined. + function forEachProperty(prop: Symbol, callback: (p: Symbol) => T): T { + if (getCheckFlags(prop) & CheckFlags.SyntheticProperty) { + for (const t of (prop).containingType.types) { + const p = getPropertyOfType(t, prop.name); + const result = p && forEachProperty(p, callback); + if (result) { + return result; + } + } + return undefined; + } + return callback(prop); + } + + // Return the declaring class type of a property or undefined if property not declared in class + function getDeclaringClass(prop: Symbol) { + return prop.parent && prop.parent.flags & SymbolFlags.Class ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + } + + // Return true if some underlying source property is declared in a class that derives + // from the given base class. + function isPropertyInClassDerivedFrom(prop: Symbol, baseClass: Type) { + return forEachProperty(prop, sp => { + const sourceClass = getDeclaringClass(sp); + return sourceClass ? hasBaseType(sourceClass, baseClass) : false; + }); + } + + // Return true if source property is a valid override of protected parts of target property. + function isValidOverrideOf(sourceProp: Symbol, targetProp: Symbol) { + return !forEachProperty(targetProp, tp => getDeclarationModifierFlagsFromSymbol(tp) & ModifierFlags.Protected ? + !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false); + } + + // Return true if the given class derives from each of the declaring classes of the protected + // constituents of the given property. + function isClassDerivedFromDeclaringClasses(checkClass: Type, prop: Symbol) { + return forEachProperty(prop, p => getDeclarationModifierFlagsFromSymbol(p) & ModifierFlags.Protected ? + !hasBaseType(checkClass, getDeclaringClass(p)) : false) ? undefined : checkClass; + } + // Return true if the given type is the constructor type for an abstract class function isAbstractConstructorType(type: Type) { if (getObjectFlags(type) & ObjectFlags.Anonymous) { @@ -8185,7 +8699,7 @@ namespace ts { // the constraints with a common set of type arguments to get relatable entities in places where // type parameters occur in the constraints. The complexity of doing that doesn't seem worthwhile, // particularly as we're comparing erased versions of the signatures below. - if ((source.typeParameters ? source.typeParameters.length : 0) !== (target.typeParameters ? target.typeParameters.length : 0)) { + if (length(source.typeParameters) !== length(target.typeParameters)) { return Ternary.False; } // Spec 1.0 Section 3.8.3 & 3.8.4: @@ -8390,7 +8904,7 @@ namespace ts { if (flags & TypeFlags.Void) types.push(voidType); if (flags & TypeFlags.Undefined) types.push(undefinedType); if (flags & TypeFlags.Null) types.push(nullType); - return getUnionType(types, /*subtypeReduction*/ true); + return getUnionType(types); } function removeDefinitelyFalsyTypes(type: Type): Type { @@ -8413,8 +8927,8 @@ namespace ts { getSignaturesOfType(type, SignatureKind.Construct).length === 0; } - function createTransientSymbol(source: Symbol, type: Type) { - const symbol = createSymbol(source.flags | SymbolFlags.Transient, source.name); + function createSymbolWithType(source: Symbol, type: Type) { + const symbol = createSymbol(source.flags, source.name); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -8430,7 +8944,7 @@ namespace ts { for (const property of getPropertiesOfObjectType(type)) { const original = getTypeOfSymbol(property); const updated = f(original); - members[property.name] = updated === original ? property : createTransientSymbol(property, updated); + members.set(property.name, updated === original ? property : createSymbolWithType(property, updated)); }; return members; } @@ -8668,11 +9182,11 @@ namespace ts { if (!inferredPropType) { return undefined; } - const inferredProp = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | prop.flags & optionalMask, prop.name); + const inferredProp = createSymbol(SymbolFlags.Property | prop.flags & optionalMask, prop.name); + inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? CheckFlags.Readonly : 0; inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; - inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop); - members[prop.name] = inferredProp; + members.set(prop.name, inferredProp); } if (indexInfo) { const inferredIndexType = inferTargetType(indexInfo.type); @@ -8847,10 +9361,10 @@ namespace ts { return; } const key = source.id + "," + target.id; - if (visited[key]) { + if (visited.get(key)) { return; } - visited[key] = true; + visited.set(key, true); if (depth === 0) { sourceStack = []; targetStack = []; @@ -9008,11 +9522,24 @@ namespace ts { 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. + // Infer either the default or 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; + const defaultType = getDefaultFromTypeParameter(context.signature.typeParameters[index]); + if (defaultType) { + // Instantiate the default type. Any forward reference to a type + // parameter should be instantiated to the empty object type. + inferredType = instantiateType(defaultType, + combineTypeMappers( + createBackreferenceMapper(context.signature.typeParameters, index), + getInferenceMapper(context))); + } + else { + inferredType = emptyObjectType; + } + inferenceSucceeded = true; } context.inferredTypes[index] = inferredType; @@ -9153,9 +9680,9 @@ namespace ts { function isDiscriminantProperty(type: Type, name: string) { if (type && type.flags & TypeFlags.Union) { const prop = getUnionOrIntersectionProperty(type, name); - if (prop && prop.flags & SymbolFlags.SyntheticProperty) { + if (prop && getCheckFlags(prop) & CheckFlags.SyntheticProperty) { if ((prop).isDiscriminantProperty === undefined) { - (prop).isDiscriminantProperty = (prop).hasNonUniformType && isLiteralType(getTypeOfSymbol(prop)); + (prop).isDiscriminantProperty = (prop).checkFlags & CheckFlags.HasNonUniformType && isLiteralType(getTypeOfSymbol(prop)); } return (prop).isDiscriminantProperty; } @@ -9231,7 +9758,7 @@ namespace ts { // check. This gives us a quicker out in the common case where an object type is not a function. const resolved = resolveStructuredTypeMembers(type); return !!(resolved.callSignatures.length || resolved.constructSignatures.length || - resolved.members["bind"] && isTypeSubtypeOf(type, globalFunctionType)); + resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type: Type): TypeFacts { @@ -9275,6 +9802,9 @@ namespace ts { if (flags & TypeFlags.ESSymbol) { return strictNullChecks ? TypeFacts.SymbolStrictFacts : TypeFacts.SymbolFacts; } + if (flags & TypeFlags.NonPrimitive) { + return strictNullChecks ? TypeFacts.ObjectStrictFacts : TypeFacts.ObjectFacts; + } if (flags & TypeFlags.TypeParameter) { const constraint = getConstraintOfTypeParameter(type); return getTypeFacts(constraint || emptyObjectType); @@ -9307,20 +9837,28 @@ namespace ts { function getTypeOfDestructuredArrayElement(type: Type, index: number) { return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || - checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || + checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType; } function getTypeOfDestructuredSpreadExpression(type: Type) { - return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType); + return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node: BinaryExpression): Type { - return node.parent.kind === SyntaxKind.ArrayLiteralExpression || node.parent.kind === SyntaxKind.PropertyAssignment ? + const isDestructuringDefaultAssignment = + node.parent.kind === SyntaxKind.ArrayLiteralExpression && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === SyntaxKind.PropertyAssignment && isDestructuringAssignmentTarget(node.parent.parent); + return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } + function isDestructuringAssignmentTarget(parent: Node) { + return parent.parent.kind === SyntaxKind.BinaryExpression && (parent.parent as BinaryExpression).left === parent || + parent.parent.kind === SyntaxKind.ForOfStatement && (parent.parent as ForOfStatement).initializer === parent; + } + function getAssignedTypeOfArrayLiteralElement(node: ArrayLiteralExpression, element: Expression): Type { return getTypeOfDestructuredArrayElement(getAssignedType(node), indexOf(node.elements, element)); } @@ -9343,7 +9881,7 @@ namespace ts { case SyntaxKind.ForInStatement: return stringType; case SyntaxKind.ForOfStatement: - return checkRightHandSideOfForOf((parent).expression) || unknownType; + return checkRightHandSideOfForOf((parent).expression, (parent).awaitModifier) || unknownType; case SyntaxKind.BinaryExpression: return getAssignedTypeOfBinaryExpression(parent); case SyntaxKind.DeleteExpression: @@ -9387,7 +9925,7 @@ namespace ts { return stringType; } if (node.parent.parent.kind === SyntaxKind.ForOfStatement) { - return checkRightHandSideOfForOf((node.parent.parent).expression) || unknownType; + return checkRightHandSideOfForOf((node.parent.parent).expression, (node.parent.parent).awaitModifier) || unknownType; } return unknownType; } @@ -9662,7 +10200,19 @@ namespace ts { } } let type: FlowType; - if (flow.flags & FlowFlags.Assignment) { + if (flow.flags & FlowFlags.AfterFinally) { + // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement + (flow).locked = true; + type = getTypeAtFlowNode((flow).antecedent); + (flow).locked = false; + } + else if (flow.flags & FlowFlags.PreFinally) { + // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel + // so here just redirect to antecedent + flow = (flow).antecedent; + continue; + } + else if (flow.flags & FlowFlags.Assignment) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = (flow).antecedent; @@ -9818,6 +10368,12 @@ namespace ts { let subtypeReduction = false; let seenIncomplete = false; for (const antecedent of flow.antecedents) { + if (antecedent.flags & FlowFlags.PreFinally && (antecedent).lock.locked) { + // if flow correspond to branch from pre-try to finally and this branch is locked - this means that + // we initially have started following the flow outside the finally block. + // in this case we should ignore this branch. + continue; + } const flowType = getTypeAtFlowNode(antecedent); const type = getTypeFromFlowType(flowType); // If the type at a particular antecedent path is the declared type and the @@ -9851,8 +10407,9 @@ namespace ts { if (!key) { key = getFlowCacheKey(reference); } - if (cache[key]) { - return cache[key]; + const cached = cache.get(key); + if (cached) { + return cached; } // If this flow loop junction and reference are already being processed, return // the union of the types computed for each branch so far, marked as incomplete. @@ -9886,8 +10443,9 @@ namespace ts { // If we see a value appear in the cache it is a sign that control flow analysis // was restarted and completed by checkExpressionCached. We can simply pick up // the resulting type and bail out. - if (cache[key]) { - return cache[key]; + const cached = cache.get(key); + if (cached) { + return cached; } if (!contains(antecedentTypes, type)) { antecedentTypes.push(type); @@ -9911,7 +10469,8 @@ namespace ts { if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } - return cache[key] = result; + cache.set(key, result); + return result; } function isMatchingReferenceDiscriminant(expr: Expression) { @@ -10034,14 +10593,14 @@ namespace ts { // We narrow a non-union type to an exact primitive type if the non-union type // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. - const targetType = typeofTypesByName[literal.text]; + const targetType = typeofTypesByName.get(literal.text); if (targetType && isTypeSubtypeOf(targetType, type)) { return targetType; } } const facts = assumeTrue ? - typeofEQFacts[literal.text] || TypeFacts.TypeofEQHostObject : - typeofNEFacts[literal.text] || TypeFacts.TypeofNEHostObject; + typeofEQFacts.get(literal.text) || TypeFacts.TypeofEQHostObject : + typeofNEFacts.get(literal.text) || TypeFacts.TypeofNEHostObject; return getTypeWithFacts(type, facts); } @@ -10923,23 +11482,23 @@ namespace ts { const func = parameter.parent; if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { const iife = getImmediatelyInvokedFunctionExpression(func); - if (iife) { + if (iife && iife.arguments) { const indexOfParameter = indexOf(func.parameters, parameter); - if (iife.arguments && indexOfParameter < iife.arguments.length) { - if (parameter.dotDotDotToken) { - const restTypes: Type[] = []; - for (let i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return createArrayType(getUnionType(restTypes)); + if (parameter.dotDotDotToken) { + const restTypes: Type[] = []; + for (let i = indexOfParameter; i < iife.arguments.length; i++) { + restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); } - const links = getNodeLinks(iife); - const cached = links.resolvedSignature; - links.resolvedSignature = anySignature; - const type = getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])); - links.resolvedSignature = cached; - return type; + return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; } + const links = getNodeLinks(iife); + const cached = links.resolvedSignature; + links.resolvedSignature = anySignature; + const type = indexOfParameter < iife.arguments.length ? + getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + parameter.initializer ? undefined : undefinedWideningType; + links.resolvedSignature = cached; + return type; } const contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -11002,31 +11561,29 @@ namespace ts { function getContextualTypeForReturnExpression(node: Expression): Type { const func = getContainingFunction(node); - - if (isAsyncFunctionLike(func)) { - const contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getPromisedType(contextualReturnType); + if (func) { + const functionFlags = getFunctionFlags(func); + if (functionFlags & FunctionFlags.Generator) { // AsyncGenerator function or Generator function + return undefined; } - return undefined; + const contextualReturnType = getContextualReturnType(func); + return functionFlags & FunctionFlags.Async + ? contextualReturnType && getAwaitedTypeOfPromise(contextualReturnType) // Async function + : contextualReturnType; // Regular function } - - if (func && !func.asteriskToken) { - return getContextualReturnType(func); - } - return undefined; } function getContextualTypeForYieldOperand(node: YieldExpression): Type { const func = getContainingFunction(node); if (func) { + const functionFlags = getFunctionFlags(func); const contextualReturnType = getContextualReturnType(func); if (contextualReturnType) { return node.asteriskToken ? contextualReturnType - : getElementTypeOfIterableIterator(contextualReturnType); + : getIteratedTypeOfGenerator(contextualReturnType, (functionFlags & FunctionFlags.Async) !== 0); } } @@ -11204,7 +11761,7 @@ namespace ts { const index = indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, IndexKind.Number) - || (languageVersion >= ScriptTarget.ES2015 ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); + || getIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false, /*checkAssignability*/ false); } return undefined; } @@ -11216,21 +11773,20 @@ namespace ts { } function getContextualTypeForJsxAttribute(attribute: JsxAttribute | JsxSpreadAttribute) { - const kind = attribute.kind; - const jsxElement = attribute.parent as JsxOpeningLikeElement; - const attrsType = getJsxElementAttributesType(jsxElement); + // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type + // which is a type of the parameter of the signature we are trying out. + // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName + const attributesType = getContextualType(attribute.parent); - if (attribute.kind === SyntaxKind.JsxAttribute) { - if (!attrsType || isTypeAny(attrsType)) { + if (isJsxAttribute(attribute)) { + if (!attributesType || isTypeAny(attributesType)) { return undefined; } - return getTypeOfPropertyOfType(attrsType, (attribute as JsxAttribute).name.text); + return getTypeOfPropertyOfType(attributesType, (attribute as JsxAttribute).name.text); } - else if (attribute.kind === SyntaxKind.JsxSpreadAttribute) { - return attrsType; + else { + return attributesType; } - - Debug.fail(`Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[${kind}]`); } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily @@ -11303,6 +11859,9 @@ namespace ts { case SyntaxKind.JsxAttribute: case SyntaxKind.JsxSpreadAttribute: return getContextualTypeForJsxAttribute(parent); + case SyntaxKind.JsxOpeningElement: + case SyntaxKind.JsxSelfClosingElement: + return getAttributesTypeFromJsxOpeningLikeElement(parent); } return undefined; } @@ -11417,8 +11976,12 @@ namespace ts { } function checkSpreadExpression(node: SpreadElement, contextualMapper?: TypeMapper): Type { + if (languageVersion < ScriptTarget.ES2015 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, ExternalEmitHelpers.SpreadIncludes); + } + const arrayOrIterableType = checkExpression(node.expression, contextualMapper); - return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); + return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterable*/ false); } function hasDefaultValue(node: BindingElement | Expression): boolean { @@ -11447,7 +12010,7 @@ namespace ts { // if there is no index type / iterated type. const restArrayType = checkExpression((e).expression, contextualMapper); const restElementType = getIndexTypeOfType(restArrayType, IndexKind.Number) || - (languageVersion >= ScriptTarget.ES2015 ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); + getIteratedTypeOrElementType(restArrayType, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false, /*checkAssignability*/ false); if (restElementType) { elementTypes.push(restElementType); } @@ -11606,7 +12169,7 @@ namespace ts { } typeFlags |= type.flags; - const prop = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name); + const prop = createSymbol(SymbolFlags.Property | 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. @@ -11644,11 +12207,11 @@ namespace ts { member = prop; } else if (memberDecl.kind === SyntaxKind.SpreadAssignment) { - if (languageVersion < ScriptTarget.ESNext) { + if (languageVersion < ScriptTarget.ES2015) { checkExternalEmitHelpers(memberDecl, ExternalEmitHelpers.Assign); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); + spread = getSpreadType(spread, createObjectLiteralType()); propertiesArray = []; propertiesTable = createMap(); hasComputedStringProperty = false; @@ -11660,7 +12223,7 @@ namespace ts { error(memberDecl, Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } - spread = getSpreadType(spread, type, /*isFromObjectLiteral*/ false); + spread = getSpreadType(spread, type); offset = i + 1; continue; } @@ -11683,7 +12246,7 @@ namespace ts { } } else { - propertiesTable[member.name] = member; + propertiesTable.set(member.name, member); } propertiesArray.push(member); } @@ -11692,12 +12255,12 @@ namespace ts { // type with those properties for which the binding pattern specifies a default value. if (contextualTypeHasPattern) { for (const prop of getPropertiesOfType(contextualType)) { - if (!propertiesTable[prop.name]) { + if (!propertiesTable.get(prop.name)) { if (!(prop.flags & SymbolFlags.Optional)) { error(prop.valueDeclaration || (prop).bindingElement, Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } - propertiesTable[prop.name] = prop; + propertiesTable.set(prop.name, prop); propertiesArray.push(prop); } } @@ -11705,7 +12268,7 @@ namespace ts { if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); + spread = getSpreadType(spread, createObjectLiteralType()); } if (spread.flags & TypeFlags.Object) { // only set the symbol and flags if this is a (fresh) object type @@ -11738,7 +12301,7 @@ namespace ts { } function isValidSpreadType(type: Type): boolean { - return !!(type.flags & (TypeFlags.Any | TypeFlags.Null | TypeFlags.Undefined) || + return !!(type.flags & (TypeFlags.Any | TypeFlags.Null | TypeFlags.Undefined | TypeFlags.NonPrimitive) || type.flags & TypeFlags.Object && !isGenericMappedType(type) || type.flags & TypeFlags.UnionOrIntersection && !forEach((type).types, t => !isValidSpreadType(t))); } @@ -11799,76 +12362,105 @@ namespace ts { } } - function checkJsxAttribute(node: JsxAttribute, elementAttributesType: Type, nameTable: Map) { - let correspondingPropType: Type = undefined; + /** + * Get attributes type of the JSX opening-like element. The result is from resolving "attributes" property of the opening-like element. + * + * @param openingLikeElement a JSX opening-like element + * @param filter a function to remove attributes that will not participate in checking whether attributes are assignable + * @return an anonymous type (similar to the one returned by checkObjectLiteral) in which its properties are attributes property. + * @remarks Because this function calls getSpreadType, it needs to use the same checks as checkObjectLiteral, + * which also calls getSpreadType. + */ + function createJsxAttributesTypeFromAttributesProperty(openingLikeElement: JsxOpeningLikeElement, filter?: (symbol: Symbol) => boolean, contextualMapper?: TypeMapper) { + const attributes = openingLikeElement.attributes; + let attributesTable = createMap(); + let spread: Type = emptyObjectType; + let attributesArray: Symbol[] = []; + for (const attributeDecl of attributes.properties) { + const member = attributeDecl.symbol; + if (isJsxAttribute(attributeDecl)) { + const exprType = attributeDecl.initializer ? + checkExpression(attributeDecl.initializer, contextualMapper) : + trueType; // is sugar for - // 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, Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); - } - else if (elementAttributesType && !isTypeAny(elementAttributesType)) { - const correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); - correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - if (isUnhyphenatedJsxName(node.name.text)) { - const attributeType = getTypeOfPropertyOfType(elementAttributesType, getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, IndexKind.String); - if (attributeType) { - correspondingPropType = attributeType; + const attributeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name); + attributeSymbol.declarations = member.declarations; + attributeSymbol.parent = member.parent; + if (member.valueDeclaration) { + attributeSymbol.valueDeclaration = member.valueDeclaration; } - else { - // If there's no corresponding property with this name, error - if (!correspondingPropType) { - error(node.name, Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; - } + attributeSymbol.type = exprType; + attributeSymbol.target = member; + attributesTable.set(attributeSymbol.name, attributeSymbol); + attributesArray.push(attributeSymbol); + } + else { + Debug.assert(attributeDecl.kind === SyntaxKind.JsxSpreadAttribute); + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = createMap(); } + const exprType = checkExpression(attributeDecl.expression); + if (!isValidSpreadType(exprType)) { + error(attributeDecl, Diagnostics.Spread_types_may_only_be_created_from_object_types); + return anyType; + } + if (isTypeAny(exprType)) { + return anyType; + } + spread = getSpreadType(spread, exprType); } } - let exprType: Type; - if (node.initializer) { - exprType = checkExpression(node.initializer); - } - else { - // is sugar for - exprType = booleanType; + if (spread !== emptyObjectType) { + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + attributesArray = []; + attributesTable = createMap(); + } + attributesArray = getPropertiesOfType(spread); } - if (correspondingPropType) { - checkTypeAssignableTo(exprType, correspondingPropType, node); + attributesTable = createMap(); + if (attributesArray) { + forEach(attributesArray, (attr) => { + if (!filter || filter(attr)) { + attributesTable.set(attr.name, attr); + } + }); } + return createJsxAttributesType(attributes.symbol, attributesTable); - nameTable[node.name.text] = true; - return exprType; + /** + * Create anonymous type from given attributes symbol table. + * @param symbol a symbol of JsxAttributes containing attributes corresponding to attributesTable + * @param attributesTable a symbol table of attributes property + */ + function createJsxAttributesType(symbol: Symbol, attributesTable: Map) { + const result = createAnonymousType(symbol, attributesTable, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshLiteral; + result.flags |= TypeFlags.JsxAttributes | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag; + result.objectFlags |= ObjectFlags.ObjectLiteral; + return result; + } } - function checkJsxSpreadAttribute(node: JsxSpreadAttribute, elementAttributesType: Type, nameTable: Map) { - if (compilerOptions.jsx === JsxEmit.React) { - checkExternalEmitHelpers(node, ExternalEmitHelpers.Assign); - } - 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]) { - const targetPropSym = getPropertyOfType(elementAttributesType, prop.name); - if (targetPropSym) { - 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); - } - - nameTable[prop.name] = true; - } - } - return type; + /** + * Check attributes property of opening-like element. This function is called during chooseOverload to get call signature of a JSX opening-like element. + * (See "checkApplicableSignatureForJsxOpeningLikeElement" for how the function is used) + * @param node a JSXAttributes to be resolved of its type + */ + function checkJsxAttributes(node: JsxAttributes, contextualMapper?: TypeMapper) { + return createJsxAttributesTypeFromAttributesProperty(node.parent as JsxOpeningLikeElement, /*filter*/ undefined, contextualMapper); } function getJsxType(name: string) { - if (jsxTypes[name] === undefined) { - return jsxTypes[name] = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType; + let jsxType = jsxTypes.get(name); + if (jsxType === undefined) { + jsxTypes.set(name, jsxType = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType); } - return jsxTypes[name]; + return jsxType; } /** @@ -11975,29 +12567,137 @@ namespace ts { } /** - * Given React element instance type and the class type, resolve the Jsx type - * Pass elemType to handle individual type in the union typed element type. + * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. + * Return only attributes type of successfully resolved call signature. + * This function assumes that the caller handled other possible element type of the JSX element (e.g. stateful component) + * Unlike tryGetAllJsxStatelessFunctionAttributesType, this function is a default behavior of type-checkers. + * @param openingLikeElement a JSX opening-like element to find attributes type + * @param elementType a type of the opening-like element. This elementType can't be an union type + * @param elemInstanceType an element instance type (the result of newing or invoking this tag) + * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global */ - function getResolvedJsxType(node: JsxOpeningLikeElement, elemType?: Type, elemClassType?: Type): Type { - if (!elemType) { - elemType = checkExpression(node.tagName); + function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement: JsxOpeningLikeElement, elementType: Type, elemInstanceType: Type, elementClassType?: Type): Type { + Debug.assert(!(elementType.flags & TypeFlags.Union)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + if (jsxElementType) { + // We don't call getResolvedSignature here because we have already resolve the type of JSX Element. + const callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, /*candidatesOutArray*/ undefined); + if (callSignature !== unknownSignature) { + const callReturnType = callSignature && getReturnTypeOfSignature(callSignature); + let paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + // Intersect in JSX.IntrinsicAttributes if it exists + const intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + paramType = intersectTypes(intrinsicAttributes, paramType); + } + return paramType; + } + } + } } - if (elemType.flags & TypeFlags.Union) { - const types = (elemType).types; - return getUnionType(map(types, type => { - return getResolvedJsxType(node, type, elemClassType); + return undefined; + } + + /** + * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. + * Return all attributes type of resolved call signature including candidate signatures. + * This function assumes that the caller handled other possible element type of the JSX element. + * This function is a behavior used by language service when looking up completion in JSX element. + * @param openingLikeElement a JSX opening-like element to find attributes type + * @param elementType a type of the opening-like element. This elementType can't be an union type + * @param elemInstanceType an element instance type (the result of newing or invoking this tag) + * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global + */ + function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement: JsxOpeningLikeElement, elementType: Type, elemInstanceType: Type, elementClassType?: Type): Type { + Debug.assert(!(elementType.flags & TypeFlags.Union)); + if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { + // Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type + if (jsxElementType) { + // We don't call getResolvedSignature because here we have already resolve the type of JSX Element. + const candidatesOutArray: Signature[] = []; + getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); + let result: Type; + let allMatchingAttributesType: Type; + for (const candidate of candidatesOutArray) { + const callReturnType = getReturnTypeOfSignature(candidate); + const paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); + if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + let shouldBeCandidate = true; + for (const attribute of openingLikeElement.attributes.properties) { + if (isJsxAttribute(attribute) && + isUnhyphenatedJsxName(attribute.name.text) && + !getPropertyOfType(paramType, attribute.name.text)) { + shouldBeCandidate = false; + break; + } + } + if (shouldBeCandidate) { + result = intersectTypes(result, paramType); + } + allMatchingAttributesType = intersectTypes(allMatchingAttributesType, paramType); + } + } + + // If we can't find any matching, just return everything. + if (!result) { + result = allMatchingAttributesType; + } + // Intersect in JSX.IntrinsicAttributes if it exists + const intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); + if (intrinsicAttributes !== unknownType) { + result = intersectTypes(intrinsicAttributes, result); + } + return result; + } + } + return undefined; + } + + /** + * Resolve attributes type of the given opening-like element. The attributes type is a type of attributes associated with the given elementType. + * For instance: + * declare function Foo(attr: { p1: string}): JSX.Element; + * ; // This function will try resolve "Foo" and return an attributes type of "Foo" which is "{ p1: string }" + * + * The function is intended to initially be called from getAttributesTypeFromJsxOpeningLikeElement which already handle JSX-intrinsic-element.. + * This function will try to resolve custom JSX attributes type in following order: string literal, stateless function, and stateful component + * + * @param openingLikeElement a non-intrinsic JSXOPeningLikeElement + * @param shouldIncludeAllStatelessAttributesType a boolean indicating whether to include all attributes types from all stateless function signature + * @param elementType an instance type of the given opening-like element. If undefined, the function will check type openinglikeElement's tagname. + * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global (imported from react.d.ts) + * @return attributes type if able to resolve the type of node + * anyType if there is no type ElementAttributesProperty or there is an error + * emptyObjectType if there is no "prop" in the element instance type + **/ + function resolveCustomJsxElementAttributesType(openingLikeElement: JsxOpeningLikeElement, + shouldIncludeAllStatelessAttributesType: boolean, + elementType?: Type, + elementClassType?: Type): Type { + if (!elementType) { + elementType = checkExpression(openingLikeElement.tagName); + } + + if (elementType.flags & TypeFlags.Union) { + const types = (elementType as UnionType).types; + return getUnionType(types.map(type => { + return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); }), /*subtypeReduction*/ true); } // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - if (elemType.flags & TypeFlags.String) { + if (elementType.flags & TypeFlags.String) { return anyType; } - else if (elemType.flags & TypeFlags.StringLiteral) { + else if (elementType.flags & TypeFlags.StringLiteral) { // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type + // For example: + // var CustomTag: "h1" = "h1"; + // Hello World const intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); if (intrinsicElementsType !== unknownType) { - const stringLiteralTypeName = (elemType).text; + const stringLiteralTypeName = (elementType).text; const intrinsicProp = getPropertyOfType(intrinsicElementsType, stringLiteralTypeName); if (intrinsicProp) { return getTypeOfSymbol(intrinsicProp); @@ -12006,37 +12706,28 @@ namespace ts { if (indexSignatureType) { return indexSignatureType; } - error(node, Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); + error(openingLikeElement, Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); } // If we need to report an error, we already done so here. So just return any to prevent any more error downstream return anyType; } // Get the element instance type (the result of newing or invoking this tag) - const elemInstanceType = getJsxElementInstanceType(node, elemType); + const elemInstanceType = getJsxElementInstanceType(openingLikeElement, elementType); - if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { - // Is this is a stateless function component? See if its single signature's return type is - // assignable to the JSX Element Type - if (jsxElementType) { - const callSignatures = elemType && getSignaturesOfType(elemType, SignatureKind.Call); - const callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; - const callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - let paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { - // Intersect in JSX.IntrinsicAttributes if it exists - const intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); - if (intrinsicAttributes !== unknownType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } - } + // If we should include all stateless attributes type, then get all attributes type from all stateless function signature. + // Otherwise get only attributes type from the signature picked by choose-overload logic. + const statelessAttributesType = shouldIncludeAllStatelessAttributesType ? + tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : + defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); + + if (statelessAttributesType) { + return statelessAttributesType; } // Issue an error if this return type isn't assignable to JSX.ElementClass - if (elemClassType) { - checkTypeRelatedTo(elemInstanceType, elemClassType, assignableRelation, node, Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + if (elementClassType) { + checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } if (isTypeAny(elemInstanceType)) { @@ -12065,7 +12756,7 @@ namespace ts { } else if (attributesType.flags & TypeFlags.Union) { // Props cannot be a union type - error(node.tagName, Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); + error(openingLikeElement.tagName, Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); return anyType; } else { @@ -12095,30 +12786,71 @@ namespace ts { } /** - * 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. + * Get attributes type of the given intrinsic opening-like Jsx element by resolving the tag name. + * The function is intended to be called from a function which has checked that the opening element is an intrinsic element. + * @param node an intrinsic JSX opening-like element */ - function getJsxElementAttributesType(node: JsxOpeningLikeElement): Type { + function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node: JsxOpeningLikeElement): Type { + Debug.assert(isJsxIntrinsicIdentifier(node.tagName)); const links = getNodeLinks(node); - if (!links.resolvedJsxType) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - const symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & JsxFlags.IntrinsicNamedElement) { - return links.resolvedJsxType = getTypeOfSymbol(symbol); - } - else if (links.jsxFlags & JsxFlags.IntrinsicIndexedElement) { - return links.resolvedJsxType = getIndexInfoOfSymbol(symbol, IndexKind.String).type; - } - else { - return links.resolvedJsxType = unknownType; - } + if (!links.resolvedJsxElementAttributesType) { + const symbol = getIntrinsicTagSymbol(node); + if (links.jsxFlags & JsxFlags.IntrinsicNamedElement) { + return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol); + } + else if (links.jsxFlags & JsxFlags.IntrinsicIndexedElement) { + return links.resolvedJsxElementAttributesType = getIndexInfoOfSymbol(symbol, IndexKind.String).type; } else { - const elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxType = getResolvedJsxType(node, undefined, elemClassType); + return links.resolvedJsxElementAttributesType = unknownType; } } - return links.resolvedJsxType; + return links.resolvedJsxElementAttributesType; + } + + /** + * Get attributes type of the given custom opening-like JSX element. + * This function is intended to be called from a caller that handles intrinsic JSX element already. + * @param node a custom JSX opening-like element + * @param shouldIncludeAllStatelessAttributesType a boolean value used by language service to get all possible attributes type from an overload stateless function component + */ + function getCustomJsxElementAttributesType(node: JsxOpeningLikeElement, shouldIncludeAllStatelessAttributesType: boolean): Type { + const links = getNodeLinks(node); + if (!links.resolvedJsxElementAttributesType) { + const elemClassType = getJsxGlobalElementClassType(); + return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); + } + return links.resolvedJsxElementAttributesType; + } + + /** + * Get all possible attributes type, especially from an overload stateless function component, of the given JSX opening-like element. + * This function is called by language service (see: completions-tryGetGlobalSymbols). + * @param node a JSX opening-like element to get attributes type for + */ + function getAllAttributesTypeFromJsxOpeningLikeElement(node: JsxOpeningLikeElement): Type { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + // Because in language service, the given JSX opening-like element may be incomplete and therefore, + // we can't resolve to exact signature if the element is a stateless function component so the best thing to do is return all attributes type from all overloads. + return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ true); + } + } + + /** + * Get the attributes type, which indicates the attributes that are valid on the given JSXOpeningLikeElement. + * @param node a JSXOpeningLikeElement node + * @return an attributes type of the given node + */ + function getAttributesTypeFromJsxOpeningLikeElement(node: JsxOpeningLikeElement): Type { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + } + else { + return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ false); + } } /** @@ -12127,19 +12859,21 @@ namespace ts { * that have no matching element attributes type property. */ function getJsxAttributePropertySymbol(attrib: JsxAttribute): Symbol { - const attributesType = getJsxElementAttributesType(attrib.parent); + const attributesType = getAttributesTypeFromJsxOpeningLikeElement(attrib.parent.parent as JsxOpeningElement); const prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } function getJsxGlobalElementClassType(): Type { - if (!jsxElementClassType) { - jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); + if (!deferredJsxElementClassType) { + deferredJsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); } - return jsxElementClassType; + return deferredJsxElementClassType; } - /// Returns all the properties of the Jsx.IntrinsicElements interface + /** + * Returns all the properties of the Jsx.IntrinsicElements interface + */ function getJsxIntrinsicTagNames(): Symbol[] { const intrinsics = getJsxType(JsxNames.IntrinsicElements); return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; @@ -12177,43 +12911,48 @@ namespace ts { } } - const targetAttributesType = getJsxElementAttributesType(node); + checkJsxAttributesAssignableToTagNameAttributes(node); + } - const nameTable = createMap(); - // 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 - let sawSpreadedAny = false; - for (let i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === SyntaxKind.JsxAttribute) { - checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); - } - else { - Debug.assert(node.attributes[i].kind === SyntaxKind.JsxSpreadAttribute); - const spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); - if (isTypeAny(spreadType)) { - sawSpreadedAny = true; - } - } + /** + * Check whether the given attributes of JSX opening-like element is assignable to the tagName attributes. + * Get the attributes type of the opening-like element through resolving the tagName, "target attributes" + * Check assignablity between given attributes property, "source attributes", and the "target attributes" + * @param openingLikeElement an opening-like JSX element to check its JSXAttributes + */ + function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement: JsxOpeningLikeElement) { + // The function involves following steps: + // 1. Figure out expected attributes type by resolving tagName of the JSX opening-like element, targetAttributesType. + // During these steps, we will try to resolve the tagName as intrinsic name, stateless function, stateful component (in the order) + // 2. Solved JSX attributes type given by users, sourceAttributesType, which is by resolving "attributes" property of the JSX opening-like element. + // 3. Check if the two are assignable to each other + + // targetAttributesType is a type of an attributes from resolving tagName of an opening-like JSX element. + const targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? + getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : + getCustomJsxElementAttributesType(openingLikeElement, /*shouldIncludeAllStatelessAttributesType*/ false); + + // sourceAttributesType is a type of an attributes properties. + // i.e
+ // attr1 and attr2 are treated as JSXAttributes attached in the JsxOpeningLikeElement as "attributes". + const sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement, + attribute => { + return isUnhyphenatedJsxName(attribute.name) || !!(getPropertyOfType(targetAttributesType, attribute.name)); + }); + + // If the targetAttributesType is an emptyObjectType, indicating that there is no property named 'props' on this instance type. + // but there exists a sourceAttributesType, we need to explicitly give an error as normal assignability check allow excess properties and will pass. + if (targetAttributesType === emptyObjectType && (isTypeAny(sourceAttributesType) || (sourceAttributesType).properties.length > 0)) { + error(openingLikeElement, Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); } - - // 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) { - const targetProperties = getPropertiesOfType(targetAttributesType); - for (let i = 0; i < targetProperties.length; i++) { - if (!(targetProperties[i].flags & SymbolFlags.Optional) && - !nameTable[targetProperties[i].name]) { - - error(node, Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); - } - } + else { + checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.attributes.properties.length > 0 ? openingLikeElement.attributes : openingLikeElement); } } - function checkJsxExpression(node: JsxExpression) { + function checkJsxExpression(node: JsxExpression, contextualMapper?: TypeMapper) { if (node.expression) { - const type = checkExpression(node.expression); + const type = checkExpression(node.expression, contextualMapper); if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { error(node, Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); } @@ -12231,7 +12970,22 @@ namespace ts { } function getDeclarationModifierFlagsFromSymbol(s: Symbol): ModifierFlags { - return s.valueDeclaration ? getCombinedModifierFlags(s.valueDeclaration) : s.flags & SymbolFlags.Prototype ? ModifierFlags.Public | ModifierFlags.Static : 0; + if (s.valueDeclaration) { + const flags = getCombinedModifierFlags(s.valueDeclaration); + return s.parent && s.parent.flags & SymbolFlags.Class ? flags : flags & ~ModifierFlags.AccessibilityModifier; + } + if (getCheckFlags(s) & CheckFlags.SyntheticProperty) { + const checkFlags = (s).checkFlags; + const accessModifier = checkFlags & CheckFlags.ContainsPrivate ? ModifierFlags.Private : + checkFlags & CheckFlags.ContainsPublic ? ModifierFlags.Public : + ModifierFlags.Protected; + const staticModifier = checkFlags & CheckFlags.ContainsStatic ? ModifierFlags.Static : 0; + return accessModifier | staticModifier; + } + if (s.flags & SymbolFlags.Prototype) { + return ModifierFlags.Public | ModifierFlags.Static; + } + return 0; } function getDeclarationNodeFlagsFromSymbol(s: Symbol): NodeFlags { @@ -12246,12 +13000,18 @@ namespace ts { * @param type The type of left. * @param prop The symbol for the right hand side of the property access. */ - function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName | VariableLikeDeclaration, left: Expression | QualifiedName, type: Type, prop: Symbol): boolean { + function checkPropertyAccessibility(node: PropertyAccessExpression | QualifiedName | VariableLikeDeclaration, left: Expression | QualifiedName, type: Type, prop: Symbol): boolean { const flags = getDeclarationModifierFlagsFromSymbol(prop); - const declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); const errorNode = node.kind === SyntaxKind.PropertyAccessExpression || node.kind === SyntaxKind.VariableDeclaration ? (node).name : (node).right; + + if (getCheckFlags(prop) & CheckFlags.ContainsPrivate) { + // Synthetic property with private constituent property + error(errorNode, Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); + return false; + } + if (left.kind === SyntaxKind.SuperKeyword) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or @@ -12260,21 +13020,22 @@ namespace ts { // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < ScriptTarget.ES2015 && getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { - // `prop` refers to a *property* declared in the super class - // rather than a *method*, so it does not satisfy the above criteria. + if (languageVersion < ScriptTarget.ES2015) { + const propKind = getDeclarationKindFromSymbol(prop); + if (propKind !== SyntaxKind.MethodDeclaration && propKind !== SyntaxKind.MethodSignature) { + // `prop` refers to a *property* declared in the super class + // rather than a *method*, so it does not satisfy the above criteria. - error(errorNode, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - return false; + error(errorNode, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } } - if (flags & ModifierFlags.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, Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } } @@ -12290,7 +13051,7 @@ namespace ts { if (flags & ModifierFlags.Private) { const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(node, declaringClassDeclaration)) { - error(errorNode, Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); return false; } return true; @@ -12303,15 +13064,15 @@ namespace ts { return true; } - // Get the enclosing class that has the declaring class as its base type + // Find the first enclosing class that has the declaring classes of the protected constituents + // of the property as base classes const enclosingClass = forEachEnclosingClass(node, enclosingDeclaration => { const enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); - return hasBaseType(enclosingClass, declaringClass) ? enclosingClass : undefined; + return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; }); - // A protected property is accessible if the property is within the declaring class or classes derived from it if (!enclosingClass) { - error(errorNode, Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); + error(errorNode, Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); return false; } // No further restrictions for static properties @@ -12323,9 +13084,7 @@ namespace ts { // 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 (!(getObjectFlags(getTargetType(type)) & ObjectFlags.ClassOrInterface && hasBaseType(type, enclosingClass))) { + if (!(getObjectFlags(getTargetType(type)) & ObjectFlags.ClassOrInterface && hasBaseType(type, enclosingClass))) { error(errorNode, Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; } @@ -12333,16 +13092,18 @@ namespace ts { } function checkNonNullExpression(node: Expression | QualifiedName) { - const type = checkExpression(node); - if (strictNullChecks) { - const kind = getFalsyFlags(type) & TypeFlags.Nullable; - if (kind) { - error(node, kind & TypeFlags.Undefined ? kind & TypeFlags.Null ? - Diagnostics.Object_is_possibly_null_or_undefined : - Diagnostics.Object_is_possibly_undefined : - Diagnostics.Object_is_possibly_null); - } - return getNonNullableType(type); + return checkNonNullType(checkExpression(node), node); + } + + function checkNonNullType(type: Type, errorNode: Node): Type { + const kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & TypeFlags.Nullable; + if (kind) { + error(errorNode, kind & TypeFlags.Undefined ? kind & TypeFlags.Null ? + Diagnostics.Object_is_possibly_null_or_undefined : + Diagnostics.Object_is_possibly_undefined : + Diagnostics.Object_is_possibly_null); + const t = getNonNullableType(type); + return t.flags & (TypeFlags.Nullable | TypeFlags.Never) ? unknownType : t; } return type; } @@ -12374,9 +13135,8 @@ namespace ts { noUnusedIdentifiers && (prop.flags & SymbolFlags.ClassMember) && prop.valueDeclaration && (getModifierFlags(prop.valueDeclaration) & ModifierFlags.Private)) { - if (prop.flags & SymbolFlags.Instantiated) { + if (getCheckFlags(prop) & CheckFlags.Instantiated) { getSymbolLinks(prop).target.isReferenced = true; - } else { prop.isReferenced = true; @@ -12384,6 +13144,16 @@ namespace ts { } } + function isInPropertyInitializer(node: Node): boolean { + while (node) { + if (node.parent && node.parent.kind === SyntaxKind.PropertyDeclaration && (node.parent as PropertyDeclaration).initializer === node) { + return true; + } + node = node.parent; + } + return false; + } + function checkPropertyAccessExpressionOrQualifiedName(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, right: Identifier) { const type = checkNonNullExpression(left); if (isTypeAny(type) || type === silentNeverType) { @@ -12397,19 +13167,26 @@ namespace ts { } const prop = getPropertyOfType(apparentType, right.text); if (!prop) { + const stringIndexType = getIndexTypeOfType(apparentType, IndexKind.String); + if (stringIndexType) { + return stringIndexType; + } if (right.text && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType ? apparentType : type); } return unknownType; } + if (prop.valueDeclaration && + isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + } markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; - if (prop.parent && prop.parent.flags & SymbolFlags.Class) { - checkClassPropertyAccess(node, left, apparentType, prop); - } + checkPropertyAccessibility(node, left, apparentType, prop); const propType = getTypeOfSymbol(prop); const assignmentKind = getAssignmentTargetKind(node); @@ -12441,8 +13218,8 @@ namespace ts { const type = checkExpression(left); if (type !== unknownType && !isTypeAny(type)) { const prop = getPropertyOfType(getWidenedType(type), propertyName); - if (prop && prop.parent && prop.parent.flags & SymbolFlags.Class) { - return checkClassPropertyAccess(node, left, type, prop); + if (prop) { + return checkPropertyAccessibility(node, left, type, prop); } } return true; @@ -12528,7 +13305,7 @@ namespace ts { return unknownType; } - return getIndexedAccessType(objectType, indexType, node); + return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression: Expression, expressionType: Type, reportError: boolean): boolean { @@ -12557,7 +13334,7 @@ namespace ts { return false; } - const globalESSymbol = getGlobalESSymbolConstructorSymbol(); + const globalESSymbol = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ true); if (!globalESSymbol) { // Already errored when we tried to look up the symbol return false; @@ -12661,6 +13438,11 @@ namespace ts { let isDecorator: boolean; let spreadArgIndex = -1; + if (isJsxOpeningLikeElement(node)) { + // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". + return true; + } + if (node.kind === SyntaxKind.TaggedTemplateExpression) { const tagExpression = node; @@ -12702,7 +13484,7 @@ namespace ts { argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; - // If we are missing the close paren, the call is incomplete. + // If we are missing the close parenthesis, the call is incomplete. callIsIncomplete = callExpression.arguments.end === callExpression.end; typeArguments = callExpression.typeArguments; @@ -12711,8 +13493,10 @@ 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. + const numTypeParameters = length(signature.typeParameters); + const minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters); const hasRightNumberOfTypeArgs = !typeArguments || - (signature.typeParameters && typeArguments.length === signature.typeParameters.length); + (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters); if (!hasRightNumberOfTypeArgs) { return false; } @@ -12834,7 +13618,7 @@ namespace ts { const typeParameters = signature.typeParameters; let typeArgumentsAreAssignable = true; let mapper: TypeMapper; - for (let i = 0; i < typeParameters.length; i++) { + for (let i = 0; i < typeArgumentNodes.length; i++) { if (typeArgumentsAreAssignable /* so far */) { const constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { @@ -12860,7 +13644,44 @@ namespace ts { return typeArgumentsAreAssignable; } + /** + * Check if the given signature can possibly be a signature called by the JSX opening-like element. + * @param node a JSX opening-like element we are trying to figure its call signature + * @param signature a candidate signature we are trying whether it is a call signature + * @param relation a relationship to check parameter and argument type + * @param excludeArgument + */ + function checkApplicableSignatureForJsxOpeningLikeElement(node: JsxOpeningLikeElement, signature: Signature, relation: Map) { + // JSX opening-like element has correct arity for stateless-function component if the one of the following condition is true: + // 1. callIsIncomplete + // 2. attributes property has same number of properties as the parameter object type. + // We can figure that out by resolving attributes property and check number of properties in the resolved type + // If the call has correct arity, we will then check if the argument type and parameter type is assignable + + const callIsIncomplete = node.attributes.end === node.end; // If we are missing the close "/>", the call is incomplete + if (callIsIncomplete) { + return true; + } + + const headMessage = Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + // Stateless function components can have maximum of three arguments: "props", "context", and "updater". + // However "context" and "updater" are implicit and can't be specify by users. Only the first parameter, props, + // can be specified by users through attributes property. + const paramType = getTypeAtPosition(signature, 0); + const attributesType = checkExpressionWithContextualType(node.attributes, paramType, /*contextualMapper*/ undefined); + const argProperties = getPropertiesOfType(attributesType); + for (const arg of argProperties) { + if (!getPropertyOfType(paramType, arg.name) && isUnhyphenatedJsxName(arg.name)) { + return false; + } + } + return checkTypeRelatedTo(attributesType, paramType, relation, /*errorNode*/ undefined, headMessage); + } + function checkApplicableSignature(node: CallLikeExpression, args: Expression[], signature: Signature, relation: Map, excludeArgument: boolean[], reportErrors: boolean) { + if (isJsxOpeningLikeElement(node)) { + return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); + } const thisType = getThisTypeOfSignature(signature); if (thisType && thisType !== voidType && node.kind !== SyntaxKind.NewExpression) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType @@ -12942,8 +13763,11 @@ namespace ts { // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. return undefined; } + else if (isJsxOpeningLikeElement(node)) { + args = node.attributes.properties.length > 0 ? [node.attributes] : emptyArray; + } else { - args = (node).arguments || emptyArray; + args = node.arguments || emptyArray; } return args; @@ -13224,10 +14048,11 @@ namespace ts { function resolveCall(node: CallLikeExpression, signatures: Signature[], candidatesOutArray: Signature[], headMessage?: DiagnosticMessage): Signature { const isTaggedTemplate = node.kind === SyntaxKind.TaggedTemplateExpression; const isDecorator = node.kind === SyntaxKind.Decorator; + const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node); let typeArguments: TypeNode[]; - if (!isTaggedTemplate && !isDecorator) { + if (!isTaggedTemplate && !isDecorator && !isJsxOpeningOrSelfClosingElement) { typeArguments = (node).typeArguments; // We already perform checking on the type arguments on the class declaration itself. @@ -13334,6 +14159,10 @@ namespace ts { // If candidate is undefined, it means that no candidates had a suitable arity. In that case, // skip the checkApplicableSignature check. if (candidateForArgumentError) { + if (isJsxOpeningOrSelfClosingElement) { + // We do not report any error here because any error will be handled in "resolveCustomJsxElementAttributesType". + return 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 @@ -13359,7 +14188,7 @@ namespace ts { diagnosticChainHead = chainDiagnosticMessages(diagnosticChainHead, headMessage); } - reportNoCommonSupertypeError(inferenceCandidates, (node).expression || (node).tag, diagnosticChainHead); + reportNoCommonSupertypeError(inferenceCandidates, (node).tagName || (node).expression || (node).tag, diagnosticChainHead); } } else { @@ -13409,15 +14238,15 @@ namespace ts { while (true) { candidate = originalCandidate; if (candidate.typeParameters) { - let typeArgumentTypes: Type[]; + let typeArgumentTypes: Type[] | undefined; if (typeArguments) { - typeArgumentTypes = map(typeArguments, getTypeFromTypeNode); + typeArgumentTypes = fillMissingTypeArguments(map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); } else { inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); - typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; typeArgumentTypes = inferenceContext.inferredTypes; + typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; } if (!typeArgumentsAreValid) { break; @@ -13737,6 +14566,53 @@ namespace ts { return resolveCall(node, callSignatures, candidatesOutArray, headMessage); } + /** + * This function is similar to getResolvedSignature but is exclusively for trying to resolve JSX stateless-function component. + * The main reason we have to use this function instead of getResolvedSignature because, the caller of this function will already check the type of openingLikeElement's tagName + * and pass the type as elementType. The elementType can not be a union (as such case should be handled by the caller of this function) + * Note: at this point, we are still not sure whether the opening-like element is a stateless function component or not. + * @param openingLikeElement an opening-like JSX element to try to resolve as JSX stateless function + * @param elementType an element type of the opneing-like element by checking opening-like element's tagname. + * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; + * the function will fill it up with appropriate candidate signatures + */ + function getResolvedJsxStatelessFunctionSignature(openingLikeElement: JsxOpeningLikeElement, elementType: Type, candidatesOutArray: Signature[]): Signature { + Debug.assert(!(elementType.flags & TypeFlags.Union)); + const callSignature = resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray); + return callSignature; + } + + /** + * Try treating a given opening-like element as stateless function component and resolve a tagName to a function signature. + * @param openingLikeElement an JSX opening-like element we want to try resolve its stateless function if possible + * @param elementType a type of the opening-like JSX element, a result of resolving tagName in opening-like element. + * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; + * the function will fill it up with appropriate candidate signatures + * @return a resolved signature if we can find function matching function signature through resolve call or a first signature in the list of functions. + * otherwise return undefined if tag-name of the opening-like element doesn't have call signatures + */ + function resolveStatelessJsxOpeningLikeElement(openingLikeElement: JsxOpeningLikeElement, elementType: Type, candidatesOutArray: Signature[]): Signature { + // If this function is called from language service, elementType can be a union type. This is not possible if the function is called from compiler (see: resolveCustomJsxElementAttributesType) + if (elementType.flags & TypeFlags.Union) { + const types = (elementType as UnionType).types; + let result: Signature; + for (const type of types) { + result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); + } + + return result; + } + + const callSignatures = elementType && getSignaturesOfType(elementType, SignatureKind.Call); + if (callSignatures && callSignatures.length > 0) { + let callSignature: Signature; + callSignature = resolveCall(openingLikeElement, callSignatures, candidatesOutArray); + return callSignature; + } + + return undefined; + } + function resolveSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature { switch (node.kind) { case SyntaxKind.CallExpression: @@ -13747,12 +14623,21 @@ namespace ts { return resolveTaggedTemplateExpression(node, candidatesOutArray); case SyntaxKind.Decorator: return resolveDecorator(node, candidatesOutArray); + case SyntaxKind.JsxOpeningElement: + case SyntaxKind.JsxSelfClosingElement: + // This code-path is called by language service + return resolveStatelessJsxOpeningLikeElement(node, checkExpression((node).tagName), candidatesOutArray); } Debug.fail("Branch in 'resolveSignature' should be unreachable."); } - // candidatesOutArray is passed by signature help in the language service, and collectCandidates - // must fill it up with the appropriate candidate signatures + /** + * Resolve a signature of a given call-like expression. + * @param node a call-like expression to try resolve a signature for + * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; + * the function will fill it up with appropriate candidate signatures + * @return a signature of the call-like expression or undefined if one can't be found + */ function getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature { const links = getNodeLinks(node); // If getResolvedSignature has already been called, we will have cached the resolvedSignature. @@ -13815,10 +14700,13 @@ namespace ts { // in a JS file // Note:JS inferred classes might come from a variable declaration instead of a function declaration. // In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration. - const funcSymbol = node.expression.kind === SyntaxKind.Identifier ? + let funcSymbol = node.expression.kind === SyntaxKind.Identifier ? getResolvedSymbol(node.expression as Identifier) : checkExpression(node.expression).symbol; - if (funcSymbol && funcSymbol.members && (funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) { + if (funcSymbol && isDeclarationOfFunctionOrClassExpression(funcSymbol)) { + funcSymbol = getSymbolOfNode((funcSymbol.valueDeclaration).initializer); + } + if (funcSymbol && funcSymbol.members && funcSymbol.flags & SymbolFlags.Function) { return getInferredClassType(funcSymbol); } else if (compilerOptions.noImplicitAny) { @@ -13922,6 +14810,10 @@ namespace ts { pos < signature.parameters.length ? getTypeOfParameter(signature.parameters[pos]) : anyType; } + function getTypeOfFirstParameterOfSignature(signature: Signature) { + return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : neverType; + } + function assignContextualParameterTypes(signature: Signature, context: Signature, mapper: TypeMapper) { const len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); if (isInferentialContext(mapper)) { @@ -13936,7 +14828,7 @@ namespace ts { const parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !(parameter.valueDeclaration).type) { if (!parameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + signature.thisParameter = createSymbolWithType(context.thisParameter, undefined); } assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } @@ -14029,10 +14921,10 @@ namespace ts { function createPromiseType(promisedType: Type): Type { // creates a `Promise` type where `T` is the promisedType argument - const globalPromiseType = getGlobalPromiseType(); + const globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true); if (globalPromiseType !== emptyGenericType) { // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type - promisedType = getAwaitedType(promisedType); + promisedType = getAwaitedType(promisedType) || emptyObjectType; return createTypeReference(globalPromiseType, [promisedType]); } @@ -14045,6 +14937,9 @@ namespace ts { error(func, Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } + else if (!getGlobalPromiseConstructorSymbol(/*reportErrors*/ true)) { + error(func, Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } return promiseType; } @@ -14055,25 +14950,26 @@ namespace ts { return unknownType; } - const isAsync = isAsyncFunctionLike(func); + const functionFlags = getFunctionFlags(func); let type: Type; if (func.body.kind !== SyntaxKind.Block) { type = checkExpressionCached(func.body, contextualMapper); - if (isAsync) { + if (functionFlags & FunctionFlags.Async) { // 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, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + type = checkAwaitedType(type, /*errorNode*/ func); } } else { let types: Type[]; - const funcIsGenerator = !!func.asteriskToken; - if (funcIsGenerator) { + if (functionFlags & FunctionFlags.Generator) { // Generator or AsyncGenerator function types = checkAndAggregateYieldOperandTypes(func, contextualMapper); if (types.length === 0) { - const iterableIteratorAny = createIterableIteratorType(anyType); + const iterableIteratorAny = functionFlags & FunctionFlags.Async + ? createAsyncIterableIteratorType(anyType) // AsyncGenerator function + : createIterableIteratorType(anyType); // Generator function 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)); @@ -14085,23 +14981,31 @@ namespace ts { types = checkAndAggregateReturnExpressionTypes(func, contextualMapper); if (!types) { // For an async function, the return type will not be never, but rather a Promise for never. - return isAsync ? createPromiseReturnType(func, neverType) : neverType; + return functionFlags & FunctionFlags.Async + ? createPromiseReturnType(func, neverType) // Async function + : neverType; // Normal function } if (types.length === 0) { // For an async function, the return type will not be void, but rather a Promise for void. - return isAsync ? createPromiseReturnType(func, voidType) : voidType; + return functionFlags & FunctionFlags.Async + ? createPromiseReturnType(func, voidType) // Async function + : voidType; // Normal function } } // Return a union of the return expression types. type = getUnionType(types, /*subtypeReduction*/ true); - if (funcIsGenerator) { - type = createIterableIteratorType(type); + if (functionFlags & FunctionFlags.Generator) { // AsyncGenerator function or Generator function + type = functionFlags & FunctionFlags.Async + ? createAsyncIterableIteratorType(type) // AsyncGenerator function + : createIterableIteratorType(type); // Generator function } } + if (!contextualSignature) { reportErrorsFromWidening(func, type); } + if (isUnitType(type) && !(contextualSignature && isLiteralContextualType( @@ -14113,22 +15017,22 @@ namespace ts { // 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. - return isAsync ? createPromiseReturnType(func, widenedType) : widenedType; + return (functionFlags & FunctionFlags.AsyncOrAsyncGenerator) === FunctionFlags.Async + ? createPromiseReturnType(func, widenedType) // Async function + : widenedType; // Generator function, AsyncGenerator function, or normal function } function checkAndAggregateYieldOperandTypes(func: FunctionLikeDeclaration, contextualMapper: TypeMapper): Type[] { const aggregatedTypes: Type[] = []; - + const functionFlags = getFunctionFlags(func); forEachYieldExpression(func.body, yieldExpression => { const expr = yieldExpression.expression; if (expr) { let type = checkExpressionCached(expr, contextualMapper); - if (yieldExpression.asteriskToken) { // A yield* expression effectively yields everything that its operand yields - type = checkElementTypeOfIterable(type, yieldExpression.expression); + type = checkIteratedTypeOrElementType(type, yieldExpression.expression, /*allowStringInput*/ false, (functionFlags & FunctionFlags.Async) !== 0); } - if (!contains(aggregatedTypes, type)) { aggregatedTypes.push(type); } @@ -14165,7 +15069,7 @@ namespace ts { } function checkAndAggregateReturnExpressionTypes(func: FunctionLikeDeclaration, contextualMapper: TypeMapper): Type[] { - const isAsync = isAsyncFunctionLike(func); + const functionFlags = getFunctionFlags(func); const aggregatedTypes: Type[] = []; let hasReturnWithNoExpression = functionHasImplicitReturn(func); let hasReturnOfTypeNever = false; @@ -14173,12 +15077,12 @@ namespace ts { const expr = returnStatement.expression; if (expr) { let type = checkExpressionCached(expr, contextualMapper); - if (isAsync) { + if (functionFlags & FunctionFlags.Async) { // 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, func, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + type = checkAwaitedType(type, func); } if (type.flags & TypeFlags.Never) { hasReturnOfTypeNever = true; @@ -14322,9 +15226,13 @@ namespace ts { function checkFunctionExpressionOrObjectLiteralMethodDeferred(node: ArrowFunction | FunctionExpression | MethodDeclaration) { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); - const isAsync = isAsyncFunctionLike(node); - const returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); - if (!node.asteriskToken) { + const functionFlags = getFunctionFlags(node); + const returnOrPromisedType = node.type && + ((functionFlags & FunctionFlags.AsyncOrAsyncGenerator) === FunctionFlags.Async ? + checkAsyncFunctionReturnType(node) : // Async function + getTypeFromTypeNode(node.type)); // AsyncGenerator function, Generator function, or normal function + + if ((functionFlags & FunctionFlags.Generator) === 0) { // Async function or normal function // return is not necessary in the body of generators checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); } @@ -14350,11 +15258,11 @@ namespace ts { // its return type annotation. const exprType = checkExpression(node.body); if (returnOrPromisedType) { - if (isAsync) { - const awaitedType = checkAwaitedType(exprType, node.body, Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + if ((functionFlags & FunctionFlags.AsyncOrAsyncGenerator) === FunctionFlags.Async) { // Async function + const awaitedType = checkAwaitedType(exprType, node.body); checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); } - else { + else { // Normal function checkTypeAssignableTo(exprType, returnOrPromisedType, node.body); } } @@ -14378,11 +15286,11 @@ namespace ts { // Get accessors without matching set accessors // Enum members // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) - return symbol.isReadonly || - symbol.flags & SymbolFlags.Property && (getDeclarationModifierFlagsFromSymbol(symbol) & ModifierFlags.Readonly) !== 0 || - symbol.flags & SymbolFlags.Variable && (getDeclarationNodeFlagsFromSymbol(symbol) & NodeFlags.Const) !== 0 || + return !!(getCheckFlags(symbol) & CheckFlags.Readonly || + symbol.flags & SymbolFlags.Property && getDeclarationModifierFlagsFromSymbol(symbol) & ModifierFlags.Readonly || + symbol.flags & SymbolFlags.Variable && getDeclarationNodeFlagsFromSymbol(symbol) & NodeFlags.Const || symbol.flags & SymbolFlags.Accessor && !(symbol.flags & SymbolFlags.SetAccessor) || - (symbol.flags & SymbolFlags.EnumMember) !== 0; + symbol.flags & SymbolFlags.EnumMember); } function isReferenceToReadonlyEntity(expr: Expression, symbol: Symbol): boolean { @@ -14446,7 +15354,7 @@ namespace ts { function checkTypeOfExpression(node: TypeOfExpression): Type { checkExpression(node.expression); - return stringType; + return typeofType; } function checkVoidExpression(node: VoidExpression): Type { @@ -14482,6 +15390,7 @@ namespace ts { case SyntaxKind.PlusToken: case SyntaxKind.MinusToken: case SyntaxKind.TildeToken: + checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, TypeFlags.ESSymbol)) { error(node.operand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(node.operator)); } @@ -14493,7 +15402,7 @@ namespace ts { booleanType; case SyntaxKind.PlusPlusToken: case SyntaxKind.MinusMinusToken: - const ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), + const ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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 @@ -14509,7 +15418,7 @@ namespace ts { if (operandType === silentNeverType) { return silentNeverType; } - const ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), + const ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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 @@ -14576,14 +15485,17 @@ namespace ts { } // 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. + // and the right operand to be of type Any, a subtype of the 'Function' interface type, or have a call or construct signature. // 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 (isTypeOfKind(leftType, TypeFlags.Primitive)) { error(left, 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))) { + if (!(isTypeAny(rightType) || + getSignaturesOfType(rightType, SignatureKind.Call).length || + getSignaturesOfType(rightType, SignatureKind.Construct).length || + isTypeSubtypeOf(rightType, globalFunctionType))) { error(right, 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; @@ -14593,6 +15505,8 @@ namespace ts { if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); // 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. @@ -14663,10 +15577,14 @@ namespace ts { } function checkArrayLiteralAssignment(node: ArrayLiteralExpression, sourceType: Type, contextualMapper?: TypeMapper): Type { + if (languageVersion < ScriptTarget.ES2015 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, ExternalEmitHelpers.Read); + } + // 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). - const elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false) || unknownType; + const elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType; const elements = node.elements; for (let i = 0; i < elements.length; i++) { checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, contextualMapper); @@ -14877,17 +15795,9 @@ namespace ts { if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - // 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 & TypeFlags.Nullable) leftType = rightType; - if (rightType.flags & TypeFlags.Nullable) rightType = leftType; - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); let suggestedOperator: SyntaxKind; // if a user tries to apply a bitwise operator to 2 boolean operands @@ -14912,16 +15822,11 @@ namespace ts { if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - // 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 & TypeFlags.Nullable) leftType = rightType; - if (rightType.flags & TypeFlags.Nullable) rightType = leftType; - - leftType = getNonNullableType(leftType); - rightType = getNonNullableType(rightType); + if (!isTypeOfKind(leftType, TypeFlags.Any | TypeFlags.StringLike) && !isTypeOfKind(rightType, TypeFlags.Any | TypeFlags.StringLike)) { + leftType = checkNonNullType(leftType, left); + rightType = checkNonNullType(rightType, right); + } let resultType: Type; if (isTypeOfKind(leftType, TypeFlags.NumberLike) && isTypeOfKind(rightType, TypeFlags.NumberLike)) { @@ -14960,8 +15865,8 @@ namespace ts { case SyntaxKind.LessThanEqualsToken: case SyntaxKind.GreaterThanEqualsToken: if (checkForDisallowedESSymbolOperand(operator)) { - leftType = getBaseTypeOfLiteralType(leftType); - rightType = getBaseTypeOfLiteralType(rightType); + leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); + rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } @@ -15087,18 +15992,31 @@ namespace ts { 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) { + const functionFlags = func && getFunctionFlags(func); + if (node.asteriskToken) { + if (functionFlags & FunctionFlags.Async) { + if (languageVersion < ScriptTarget.ES2017) { + checkExternalEmitHelpers(node, ExternalEmitHelpers.AsyncDelegator); + } + } + else if (languageVersion < ScriptTarget.ES2015 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, ExternalEmitHelpers.Values); + } + } + + if (functionFlags & FunctionFlags.Generator) { const expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); let expressionElementType: Type; const nodeIsYieldStar = !!node.asteriskToken; if (nodeIsYieldStar) { - expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); + expressionElementType = checkIteratedTypeOrElementType(expressionType, node.expression, /*allowStringInput*/ false, (functionFlags & FunctionFlags.Async) !== 0); } + // 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) { - const signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; + const signatureElementType = getIteratedTypeOfGenerator(getTypeFromTypeNode(func.type), (functionFlags & FunctionFlags.Async) !== 0) || anyType; if (nodeIsYieldStar) { checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); } @@ -15186,14 +16104,14 @@ namespace ts { function isLiteralContextualType(contextualType: Type) { if (contextualType) { if (contextualType.flags & TypeFlags.TypeVariable) { - const apparentType = getApparentTypeOfTypeVariable(contextualType); + const constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; // If the type parameter is constrained to the base primitive type we're checking for, // consider this a literal context. For example, given a type parameter 'T extends string', // this causes us to infer string literal types for T. - if (apparentType.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum)) { + if (constraint.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum)) { return true; } - contextualType = apparentType; + contextualType = constraint; } return maybeTypeOfKind(contextualType, (TypeFlags.Literal | TypeFlags.Index)); } @@ -15371,11 +16289,13 @@ namespace ts { case SyntaxKind.YieldExpression: return checkYieldExpression(node); case SyntaxKind.JsxExpression: - return checkJsxExpression(node); + return checkJsxExpression(node, contextualMapper); case SyntaxKind.JsxElement: return checkJsxElement(node); case SyntaxKind.JsxSelfClosingElement: return checkJsxSelfClosingElement(node); + case SyntaxKind.JsxAttributes: + return checkJsxAttributes(node, contextualMapper); case SyntaxKind.JsxOpeningElement: Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } @@ -15391,7 +16311,16 @@ namespace ts { } checkSourceElement(node.constraint); - getConstraintOfTypeParameter(getDeclaredTypeOfTypeParameter(getSymbolOfNode(node))); + checkSourceElement(node.default); + const typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); + if (!hasNonCircularBaseConstraint(typeParameter)) { + error(node.constraint, Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(typeParameter)); + } + const constraintType = getConstraintOfTypeParameter(typeParameter); + const defaultType = getDefaultFromTypeParameter(typeParameter); + if (constraintType && defaultType) { + checkTypeAssignableTo(defaultType, getTypeWithThisArgument(constraintType, defaultType), node.default, Diagnostics.Type_0_does_not_satisfy_the_constraint_1); + } if (produceDiagnostics) { checkTypeNameIsReserved(node.name, Diagnostics.Type_parameter_name_cannot_be_0); } @@ -15433,16 +16362,6 @@ namespace ts { } } - function isSyntacticallyValidGenerator(node: SignatureDeclaration): boolean { - if (!(node).asteriskToken || !(node).body) { - return false; - } - - return node.kind === SyntaxKind.MethodDeclaration || - node.kind === SyntaxKind.FunctionDeclaration || - node.kind === SyntaxKind.FunctionExpression; - } - function getTypePredicateParameterIndex(parameterList: NodeArray, parameter: Identifier): number { if (parameterList) { for (let i = 0; i < parameterList.length; i++) { @@ -15562,13 +16481,23 @@ namespace ts { checkGrammarFunctionLikeDeclaration(node); } - if (isAsyncFunctionLike(node) && languageVersion < ScriptTarget.ES2017) { + const functionFlags = getFunctionFlags(node); + if ((functionFlags & FunctionFlags.InvalidAsyncOrAsyncGenerator) === FunctionFlags.Async && languageVersion < ScriptTarget.ES2017) { checkExternalEmitHelpers(node, ExternalEmitHelpers.Awaiter); if (languageVersion < ScriptTarget.ES2015) { checkExternalEmitHelpers(node, ExternalEmitHelpers.Generator); } } + if ((functionFlags & FunctionFlags.InvalidGenerator) === FunctionFlags.Generator) { + if (functionFlags & FunctionFlags.Async && languageVersion < ScriptTarget.ES2017) { + checkExternalEmitHelpers(node, ExternalEmitHelpers.AsyncGenerator); + } + else if (languageVersion < ScriptTarget.ES2015) { + checkExternalEmitHelpers(node, ExternalEmitHelpers.Generator); + } + } + checkTypeParameters(node.typeParameters); forEach(node.parameters, checkParameter); @@ -15591,14 +16520,17 @@ namespace ts { } if (node.type) { - if (languageVersion >= ScriptTarget.ES2015 && isSyntacticallyValidGenerator(node)) { + const functionFlags = getFunctionFlags(node); + if ((functionFlags & FunctionFlags.InvalidGenerator) === FunctionFlags.Generator) { const returnType = getTypeFromTypeNode(node.type); if (returnType === voidType) { error(node.type, Diagnostics.A_generator_cannot_have_a_void_type_annotation); } else { - const generatorElementType = getElementTypeOfIterableIterator(returnType) || anyType; - const iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); + const generatorElementType = getIteratedTypeOfGenerator(returnType, (functionFlags & FunctionFlags.Async) !== 0) || anyType; + const iterableIteratorInstantiation = functionFlags & FunctionFlags.Async + ? createAsyncIterableIteratorType(generatorElementType) // AsyncGenerator function + : createIterableIteratorType(generatorElementType); // Generator function // Naively, one could check that IterableIterator is assignable to the return type annotation. // However, that would not catch the error in the following case. @@ -15609,7 +16541,7 @@ namespace ts { checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); } } - else if (isAsyncFunctionLike(node)) { + else if ((functionFlags & FunctionFlags.AsyncOrAsyncGenerator) === FunctionFlags.Async) { checkAsyncFunctionReturnType(node); } } @@ -15620,57 +16552,99 @@ namespace ts { } function checkClassForDuplicateDeclarations(node: ClassLikeDeclaration) { - const enum Accessor { + const enum Declaration { Getter = 1, Setter = 2, + Method = 4, Property = Getter | Setter } - const instanceNames = createMap(); - const staticNames = createMap(); + const instanceNames = createMap(); + const staticNames = createMap(); for (const member of node.members) { if (member.kind === SyntaxKind.Constructor) { for (const param of (member as ConstructorDeclaration).parameters) { if (isParameterPropertyDeclaration(param)) { - addName(instanceNames, param.name, (param.name as Identifier).text, Accessor.Property); + addName(instanceNames, param.name, (param.name as Identifier).text, Declaration.Property); } } } else { - const isStatic = forEach(member.modifiers, m => m.kind === SyntaxKind.StaticKeyword); + const isStatic = getModifierFlags(member) & ModifierFlags.Static; const names = isStatic ? staticNames : instanceNames; const memberName = member.name && getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { case SyntaxKind.GetAccessor: - addName(names, member.name, memberName, Accessor.Getter); + addName(names, member.name, memberName, Declaration.Getter); break; case SyntaxKind.SetAccessor: - addName(names, member.name, memberName, Accessor.Setter); + addName(names, member.name, memberName, Declaration.Setter); break; case SyntaxKind.PropertyDeclaration: - addName(names, member.name, memberName, Accessor.Property); + addName(names, member.name, memberName, Declaration.Property); + break; + + case SyntaxKind.MethodDeclaration: + addName(names, member.name, memberName, Declaration.Method); break; } } } } - function addName(names: Map, location: Node, name: string, meaning: Accessor) { - const prev = names[name]; + function addName(names: Map, location: Node, name: string, meaning: Declaration) { + const prev = names.get(name); if (prev) { - if (prev & meaning) { + if (prev & Declaration.Method) { + if (meaning !== Declaration.Method) { + error(location, Diagnostics.Duplicate_identifier_0, getTextOfNode(location)); + } + } + else if (prev & meaning) { error(location, Diagnostics.Duplicate_identifier_0, getTextOfNode(location)); } else { - names[name] = prev | meaning; + names.set(name, prev | meaning); } } else { - names[name] = meaning; + names.set(name, meaning); + } + } + } + + /** + * Static members being set on a constructor function may conflict with built-in properties + * of Function. Esp. in ECMAScript 5 there are non-configurable and non-writable + * built-in properties. This check issues a transpile error when a class has a static + * member with the same name as a non-writable built-in property. + * + * @see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.3 + * @see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.5 + * @see http://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-the-function-constructor + * @see http://www.ecma-international.org/ecma-262/6.0/#sec-function-instances + */ + function checkClassForStaticPropertyNameConflicts(node: ClassLikeDeclaration) { + for (const member of node.members) { + const memberNameNode = member.name; + const isStatic = getModifierFlags(member) & ModifierFlags.Static; + if (isStatic && memberNameNode) { + const memberName = getPropertyNameForPropertyNameNode(memberNameNode); + switch (memberName) { + case "name": + case "length": + case "caller": + case "arguments": + case "prototype": + const message = Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1; + const className = getNameOfSymbol(getSymbolOfNode(node)); + error(memberNameNode, message, memberName, className); + break; + } } } } @@ -15690,12 +16664,12 @@ namespace ts { continue; } - if (names[memberName]) { + if (names.get(memberName)) { error(member.symbol.valueDeclaration.name, Diagnostics.Duplicate_identifier_0, memberName); error(member.name, Diagnostics.Duplicate_identifier_0, memberName); } else { - names[memberName] = true; + names.set(memberName, true); } } } @@ -15942,6 +16916,7 @@ namespace ts { } function checkTypeArgumentConstraints(typeParameters: TypeParameter[], typeArgumentNodes: TypeNode[]): boolean { + const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); let typeArguments: Type[]; let mapper: TypeMapper; let result = true; @@ -15949,7 +16924,7 @@ namespace ts { const constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = map(typeArgumentNodes, getTypeFromTypeNode); + typeArguments = fillMissingTypeArguments(map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); mapper = createTypeMapper(typeParameters, typeArguments); } const typeArgument = typeArguments[i]; @@ -16014,8 +16989,30 @@ namespace ts { forEach(node.types, checkSourceElement); } + function checkIndexedAccessIndexType(type: Type, accessNode: ElementAccessExpression | IndexedAccessTypeNode) { + if (!(type.flags & TypeFlags.IndexedAccess)) { + return type; + } + // Check if the index type is assignable to 'keyof T' for the object type. + const objectType = (type).objectType; + const indexType = (type).indexType; + if (isTypeAssignableTo(indexType, getIndexType(objectType))) { + return type; + } + // Check if we're indexing with a numeric type and the object type is a generic + // type with a constraint that has a numeric index signature. + if (maybeTypeOfKind(objectType, TypeFlags.TypeVariable) && isTypeOfKind(indexType, TypeFlags.NumberLike)) { + const constraint = getBaseConstraintOfType(objectType); + if (constraint && getIndexInfoOfType(constraint, IndexKind.Number)) { + return type; + } + } + error(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); + return type; + } + function checkIndexedAccessType(node: IndexedAccessTypeNode) { - getTypeFromIndexedAccessTypeNode(node); + checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node: MappedTypeNode) { @@ -16023,8 +17020,7 @@ namespace ts { checkSourceElement(node.type); const type = getTypeFromMappedTypeNode(node); const constraintType = getConstraintTypeFromMappedType(type); - const keyType = constraintType.flags & TypeFlags.TypeVariable ? getApparentTypeOfTypeVariable(constraintType) : constraintType; - checkTypeAssignableTo(keyType, stringType, node.typeParameter.constraint); + checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node: Node): boolean { @@ -16346,22 +17342,9 @@ namespace ts { } } - function checkNonThenableType(type: Type, location?: Node, message?: DiagnosticMessage): Type { - type = getWidenedType(type); - const apparentType = getApparentType(type); - if ((apparentType.flags & (TypeFlags.Any | TypeFlags.Never)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { - if (location) { - if (!message) { - message = Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; - } - - error(location, message); - } - - return unknownType; - } - - return type; + function getAwaitedTypeOfPromise(type: Type, errorNode?: Node): Type | undefined { + const promisedType = getPromisedTypeOfPromise(type, errorNode); + return promisedType && getAwaitedType(promisedType, errorNode); } /** @@ -16369,7 +17352,7 @@ namespace ts { * @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: Type): Type { + function getPromisedTypeOfPromise(promise: Type, errorNode?: Node): Type { // // { // promise // then( // thenFunction @@ -16384,25 +17367,25 @@ namespace ts { return undefined; } - if (getObjectFlags(promise) & ObjectFlags.Reference) { - if ((promise).target === tryGetGlobalPromiseType() - || (promise).target === getGlobalPromiseLikeType()) { - return (promise).typeArguments[0]; - } + const typeAsPromise = promise; + if (typeAsPromise.promisedTypeOfPromise) { + return typeAsPromise.promisedTypeOfPromise; } - const globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); - if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { - return undefined; + if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) { + return typeAsPromise.promisedTypeOfPromise = (promise).typeArguments[0]; } const thenFunction = getTypeOfPropertyOfType(promise, "then"); - if (!thenFunction || isTypeAny(thenFunction)) { + if (isTypeAny(thenFunction)) { return undefined; } - const thenSignatures = getSignaturesOfType(thenFunction, SignatureKind.Call); + const thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, SignatureKind.Call) : emptyArray; if (thenSignatures.length === 0) { + if (errorNode) { + error(errorNode, Diagnostics.A_promise_must_have_a_then_method); + } return undefined; } @@ -16413,14 +17396,13 @@ namespace ts { const onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, SignatureKind.Call); if (onfulfilledParameterSignatures.length === 0) { + if (errorNode) { + error(errorNode, Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback); + } return undefined; } - return getUnionType(map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), /*subtypeReduction*/ true); - } - - function getTypeOfFirstParameterOfSignature(signature: Signature) { - return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : neverType; + return typeAsPromise.promisedTypeOfPromise = getUnionType(map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), /*subtypeReduction*/ true); } /** @@ -16430,96 +17412,111 @@ namespace ts { * 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: Type) { - return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined); + function checkAwaitedType(type: Type, errorNode: Node): Type { + return getAwaitedType(type, errorNode) || unknownType; } - function checkAwaitedType(type: Type, location?: Node, message?: DiagnosticMessage) { - return checkAwaitedTypeWorker(type); - - function checkAwaitedTypeWorker(type: Type): Type { - if (type.flags & TypeFlags.Union) { - const types: Type[] = []; - for (const constituentType of (type).types) { - types.push(checkAwaitedTypeWorker(constituentType)); - } - - return getUnionType(types, /*subtypeReduction*/ true); - } - else { - 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 - // 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 || indexOf(awaitedTypeStack, 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, - 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); - const awaitedType = checkAwaitedTypeWorker(promisedType); - awaitedTypeStack.pop(); - return awaitedType; - } - } + function getAwaitedType(type: Type, errorNode?: Node): Type | undefined { + const typeAsAwaitable = type; + if (typeAsAwaitable.awaitedTypeOfType) { + return typeAsAwaitable.awaitedTypeOfType; } + + if (isTypeAny(type)) { + return typeAsAwaitable.awaitedTypeOfType = type; + } + + if (type.flags & TypeFlags.Union) { + let types: Type[]; + for (const constituentType of (type).types) { + types = append(types, getAwaitedType(constituentType, errorNode)); + } + + if (!types) { + return undefined; + } + + return typeAsAwaitable.awaitedTypeOfType = getUnionType(types, /*subtypeReduction*/ true); + } + + const promisedType = getPromisedTypeOfPromise(type); + if (promisedType) { + if (type.id === promisedType.id || indexOf(awaitedTypeStack, promisedType.id) >= 0) { + // Verify that we don't have a bad actor in the form of a promise whose + // promised type is the same as the promise type, or a mutually recursive + // promise. If so, we return undefined 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 (errorNode) { + error(errorNode, Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method); + } + return undefined; + } + + // 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); + const awaitedType = getAwaitedType(promisedType, errorNode); + awaitedTypeStack.pop(); + + if (!awaitedType) { + return undefined; + } + + return typeAsAwaitable.awaitedTypeOfType = awaitedType; + } + + // The type was not a promise, 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 be reported in + // the call to getNonThenableType and we will return undefined. + // + // An example of a non-promise "thenable" might be: + // + // await { then(): void {} } + // + // The "thenable" does not match the minimal definition for a promise. 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 . + const thenFunction = getTypeOfPropertyOfType(type, "then"); + if (thenFunction && getSignaturesOfType(thenFunction, SignatureKind.Call).length > 0) { + if (errorNode) { + error(errorNode, Diagnostics.Type_used_as_operand_to_await_or_the_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + } + return undefined; + } + + return typeAsAwaitable.awaitedTypeOfType = type; } /** @@ -16566,8 +17563,8 @@ namespace ts { if (returnType === unknownType) { return unknownType; } - const globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyGenericType && globalPromiseType !== getTargetType(returnType)) { + const globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true); + if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { // The promise type was not a valid type reference to the global promise type, so we // report an error and return the unknown type. error(node.type, Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); @@ -16591,11 +17588,16 @@ namespace ts { const promiseConstructorSymbol = resolveEntityName(promiseConstructorName, SymbolFlags.Value, /*ignoreErrors*/ true); const promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; if (promiseConstructorType === unknownType) { - error(node.type, Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, entityNameToString(promiseConstructorName)); + if (promiseConstructorName.kind === SyntaxKind.Identifier && promiseConstructorName.text === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + error(node.type, Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + } + else { + error(node.type, Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, entityNameToString(promiseConstructorName)); + } return unknownType; } - const globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + const globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(/*reportErrors*/ true); if (globalPromiseConstructorLikeType === emptyObjectType) { // If we couldn't resolve the global PromiseConstructorLike type we cannot verify // compatibility with __awaiter. @@ -16620,7 +17622,7 @@ namespace ts { } // Get and return the awaited type of the return type. - return checkAwaitedType(returnType, node, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return checkAwaitedType(returnType, node); } /** Check a decorator */ @@ -16766,7 +17768,7 @@ namespace ts { function checkFunctionOrMethodDeclaration(node: FunctionDeclaration | MethodDeclaration): void { checkDecorators(node); checkSignatureDeclaration(node); - const isAsync = isAsyncFunctionLike(node); + const functionFlags = getFunctionFlags(node); // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including @@ -16808,8 +17810,10 @@ namespace ts { checkSourceElement(node.body); - if (!node.asteriskToken) { - const returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); + if ((functionFlags & FunctionFlags.Generator) === 0) { // Async function or normal function + const returnOrPromisedType = node.type && (functionFlags & FunctionFlags.Async + ? checkAsyncFunctionReturnType(node) // Async function + : getTypeFromTypeNode(node.type)); // normal function checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); } @@ -16820,7 +17824,7 @@ namespace ts { reportImplicitAnyError(node, anyType); } - if (node.asteriskToken && nodeIsPresent(node.body)) { + if (functionFlags & FunctionFlags.Generator && 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. @@ -16887,8 +17891,7 @@ namespace ts { function checkUnusedLocalsAndParameters(node: Node): void { if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && noUnusedIdentifiers && !isInAmbientContext(node)) { - for (const key in node.locals) { - const local = node.locals[key]; + node.locals.forEach(local => { if (!local.isReferenced) { if (local.valueDeclaration && getRootDeclaration(local.valueDeclaration).kind === SyntaxKind.Parameter) { const parameter = getRootDeclaration(local.valueDeclaration); @@ -16903,7 +17906,7 @@ namespace ts { forEach(local.declarations, d => errorUnusedLocal(d.name || d, local.name)); } } - } + }); } } @@ -16980,8 +17983,7 @@ namespace ts { function checkUnusedModuleMembers(node: ModuleDeclaration | SourceFile): void { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { - for (const key in node.locals) { - const local = node.locals[key]; + node.locals.forEach(local => { if (!local.isReferenced && !local.exportSymbol) { for (const declaration of local.declarations) { if (!isAmbientModule(declaration)) { @@ -16989,7 +17991,7 @@ namespace ts { } } } - } + }); } } @@ -17319,7 +18321,7 @@ namespace ts { } if (node.kind === SyntaxKind.BindingElement) { - if (node.parent.kind === SyntaxKind.ObjectBindingPattern && languageVersion < ScriptTarget.ESNext && !isInAmbientContext(node)) { + if (node.parent.kind === SyntaxKind.ObjectBindingPattern && languageVersion < ScriptTarget.ESNext) { checkExternalEmitHelpers(node, ExternalEmitHelpers.Rest); } // check computed properties inside property names of binding elements @@ -17333,13 +18335,17 @@ namespace ts { const name = node.propertyName || node.name; const property = getPropertyOfType(parentType, getTextOfPropertyName(name)); markPropertyAsReferenced(property); - if (parent.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent, parent.initializer, parentType, property); + if (parent.initializer && property) { + checkPropertyAccessibility(parent, parent.initializer, parentType, property); } } // For a binding pattern, check contained binding elements if (isBindingPattern(node.name)) { + if (node.name.kind === SyntaxKind.ArrayBindingPattern && languageVersion < ScriptTarget.ES2015 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, ExternalEmitHelpers.Read); + } + forEach((node.name).elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body @@ -17433,10 +18439,10 @@ namespace ts { forEach(node.declarationList.declarations, checkSourceElement); } - function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node: Node) { + function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node: MethodDeclaration) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression if (node.modifiers && node.parent.kind === SyntaxKind.ObjectLiteralExpression) { - if (isAsyncFunctionLike(node)) { + if (getFunctionFlags(node) & FunctionFlags.Async) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); } @@ -17512,6 +18518,17 @@ namespace ts { function checkForOfStatement(node: ForOfStatement): void { checkGrammarForInOrForOfStatement(node); + if (node.kind === SyntaxKind.ForOfStatement) { + if ((node).awaitModifier) { + if (languageVersion < ScriptTarget.ES2017) { + checkExternalEmitHelpers(node, ExternalEmitHelpers.ForAwaitOfIncludes); + } + } + else if (languageVersion < ScriptTarget.ES2015 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, ExternalEmitHelpers.ForOfIncludes); + } + } + // 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. @@ -17522,7 +18539,7 @@ namespace ts { } else { const varExpr = node.initializer; - const iteratedType = checkRightHandSideOfForOf(node.expression); + const iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side if (varExpr.kind === SyntaxKind.ArrayLiteralExpression || varExpr.kind === SyntaxKind.ObjectLiteralExpression) { @@ -17608,56 +18625,126 @@ namespace ts { } } - function checkRightHandSideOfForOf(rhsExpression: Expression): Type { + function checkRightHandSideOfForOf(rhsExpression: Expression, awaitModifier: AwaitKeywordToken | undefined): Type { const expressionType = checkNonNullExpression(rhsExpression); - return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true); + return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true, awaitModifier !== undefined); } - function checkIteratedTypeOrElementType(inputType: Type, errorNode: Node, allowStringInput: boolean): Type { + function checkIteratedTypeOrElementType(inputType: Type, errorNode: Node, allowStringInput: boolean, allowAsyncIterable: boolean): Type { if (isTypeAny(inputType)) { return inputType; } - if (languageVersion >= ScriptTarget.ES2015) { - return checkElementTypeOfIterable(inputType, errorNode); - } - if (allowStringInput) { - return checkElementTypeOfArrayOrString(inputType, errorNode); - } - if (isArrayLikeType(inputType)) { - const indexType = getIndexTypeOfType(inputType, IndexKind.Number); - if (indexType) { - return indexType; - } - } - if (errorNode) { - error(errorNode, Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType)); - } - return unknownType; + + return getIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterable, /*checkAssignability*/ true) || anyType; } /** - * When errorNode is undefined, it means we should not report any errors. + * When consuming an iterable type in a for..of, spread, or iterator destructuring assignment + * we want to get the iterated type of an iterable for ES2015 or later, or the iterated type + * of a iterable (if defined globally) or element type of an array like for ES2015 or earlier. */ - function checkElementTypeOfIterable(iterable: Type, errorNode: Node): Type { - 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) { - checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); + function getIteratedTypeOrElementType(inputType: Type, errorNode: Node, allowStringInput: boolean, allowAsyncIterable: boolean, checkAssignability: boolean): Type { + const uplevelIteration = languageVersion >= ScriptTarget.ES2015; + const downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; + + // Get the iterated type of an `Iterable` or `IterableIterator` only in ES2015 + // or higher, when inside of an async generator or for-await-if, or when + // downlevelIteration is requested. + if (uplevelIteration || downlevelIteration || allowAsyncIterable) { + // We only report errors for an invalid iterable type in ES2015 or higher. + const iteratedType = getIteratedTypeOfIterable(inputType, uplevelIteration ? errorNode : undefined, allowAsyncIterable, allowAsyncIterable, checkAssignability); + if (iteratedType || uplevelIteration) { + return iteratedType; + } } - return elementType || anyType; + let arrayType = inputType; + let reportedError = false; + let hasStringConstituent = false; + + // If strings are permitted, remove any string-like constituents from the array type. + // This allows us to find other non-string element types from an array unioned with + // a string. + if (allowStringInput) { + if (arrayType.flags & TypeFlags.Union) { + // After we remove all types that are StringLike, we will know if there was a string constituent + // based on whether the result of filter is a new array. + const arrayTypes = (inputType).types; + const filteredTypes = filter(arrayTypes, t => !(t.flags & TypeFlags.StringLike)); + if (filteredTypes !== arrayTypes) { + arrayType = getUnionType(filteredTypes, /*subtypeReduction*/ true); + } + } + else if (arrayType.flags & TypeFlags.StringLike) { + arrayType = neverType; + } + + hasStringConstituent = arrayType !== inputType; + if (hasStringConstituent) { + if (languageVersion < ScriptTarget.ES5) { + if (errorNode) { + error(errorNode, 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.flags & TypeFlags.Never) { + return stringType; + } + } + } + + if (!isArrayLikeType(arrayType)) { + if (errorNode && !reportedError) { + // Which error we report depends on whether we allow strings or if 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 and string input is allowed, we want to say that number is not an + // array type or a string type. + const diagnostic = !allowStringInput || hasStringConstituent + ? downlevelIteration + ? Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator + : Diagnostics.Type_0_is_not_an_array_type + : downlevelIteration + ? Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator + : Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; + error(errorNode, diagnostic, typeToString(arrayType)); + } + return hasStringConstituent ? stringType : undefined; + } + + const arrayElementType = getIndexTypeOfType(arrayType, IndexKind.Number); + if (hasStringConstituent && arrayElementType) { + // This is just an optimization for the case where arrayOrStringType is string | string[] + if (arrayElementType.flags & TypeFlags.StringLike) { + return stringType; + } + + return getUnionType([arrayElementType, stringType], /*subtypeReduction*/ true); + } + + return arrayElementType; } /** * 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 + * { // iterable + * [Symbol.iterator]: { // iteratorMethod + * (): Iterator + * } + * } + * + * For an async iterable, we expect the following structure: + * + * { // iterable + * [Symbol.asyncIterator]: { // iteratorMethod + * (): AsyncIterator + * } * } - * } * * 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. @@ -17669,187 +18756,190 @@ namespace ts { * 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'. + * + * For a **for-of** statement, `yield*` (in a normal generator), spread, array + * destructuring, or normal generator we will only ever look for a `[Symbol.iterator]()` + * method. + * + * For an async generator we will only ever look at the `[Symbol.asyncIterator]()` method. + * + * For a **for-await-of** statement or a `yield*` in an async generator we will look for + * the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method. */ - function getElementTypeOfIterable(type: Type, errorNode: Node): Type { + function getIteratedTypeOfIterable(type: Type, errorNode: Node | undefined, isAsyncIterable: boolean, allowNonAsyncIterables: boolean, checkAssignability: boolean): Type | undefined { if (isTypeAny(type)) { return undefined; } 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. - if ((getObjectFlags(type) & ObjectFlags.Reference) && (type).target === getGlobalIterableType()) { - typeAsIterable.iterableElementType = (type).typeArguments[0]; - } - else { - const iteratorFunction = getTypeOfPropertyOfType(type, getPropertyNameForKnownSymbolName("iterator")); - if (isTypeAny(iteratorFunction)) { - return undefined; - } + if (isAsyncIterable ? typeAsIterable.iteratedTypeOfAsyncIterable : typeAsIterable.iteratedTypeOfIterable) { + return isAsyncIterable ? typeAsIterable.iteratedTypeOfAsyncIterable : typeAsIterable.iteratedTypeOfIterable; + } - 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); - } - return undefined; - } - - typeAsIterable.iterableElementType = getElementTypeOfIterator(getUnionType(map(iteratorFunctionSignatures, getReturnTypeOfSignature), /*subtypeReduction*/ true), errorNode); + if (isAsyncIterable) { + // As an optimization, if the type is an instantiation of the global `AsyncIterable` + // or the global `AsyncIterableIterator` then just grab its type argument. + if (isReferenceToType(type, getGlobalAsyncIterableType(/*reportErrors*/ false)) || + isReferenceToType(type, getGlobalAsyncIterableIteratorType(/*reportErrors*/ false))) { + return typeAsIterable.iteratedTypeOfAsyncIterable = (type).typeArguments[0]; } } - return typeAsIterable.iterableElementType; + if (!isAsyncIterable || allowNonAsyncIterables) { + // As an optimization, if the type is an instantiation of the global `Iterable` or + // `IterableIterator` then just grab its type argument. + if (isReferenceToType(type, getGlobalIterableType(/*reportErrors*/ false)) || + isReferenceToType(type, getGlobalIterableIteratorType(/*reportErrors*/ false))) { + return isAsyncIterable + ? typeAsIterable.iteratedTypeOfAsyncIterable = (type).typeArguments[0] + : typeAsIterable.iteratedTypeOfIterable = (type).typeArguments[0]; + } + } + + let iteratorMethodSignatures: Signature[]; + let mayBeIterable = false; + if (isAsyncIterable) { + const iteratorMethod = getTypeOfPropertyOfType(type, getPropertyNameForKnownSymbolName("asyncIterator")); + if (isTypeAny(iteratorMethod)) { + return undefined; + } + iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, SignatureKind.Call); + } + + if (!isAsyncIterable || (allowNonAsyncIterables && !some(iteratorMethodSignatures))) { + const iteratorMethod = getTypeOfPropertyOfType(type, getPropertyNameForKnownSymbolName("iterator")); + if (isTypeAny(iteratorMethod)) { + return undefined; + } + iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, SignatureKind.Call); + mayBeIterable = true; + } + + if (some(iteratorMethodSignatures)) { + const iteratorMethodReturnType = getUnionType(map(iteratorMethodSignatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); + const iteratedType = getIteratedTypeOfIterator(iteratorMethodReturnType, errorNode, /*isAsyncIterator*/ false); + if (checkAssignability && errorNode && iteratedType) { + // If `checkAssignability` was specified, we were called from + // `checkIteratedTypeOrElementType`. As such, we need to validate that + // the type passed in is actually an Iterable. + checkTypeAssignableTo(type, mayBeIterable + ? createIterableType(iteratedType) + : createAsyncIterableType(iteratedType), errorNode); + } + return isAsyncIterable + ? typeAsIterable.iteratedTypeOfAsyncIterable = iteratedType + : typeAsIterable.iteratedTypeOfIterable = iteratedType; + } + + if (errorNode) { + error(errorNode, + isAsyncIterable + ? Diagnostics.Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator + : Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); + } + + return undefined; } /** - * This function has very similar logic as getElementTypeOfIterable, except that it operates on + * This function has very similar logic as getIteratedTypeOfIterable, except that it operates on * Iterators instead of Iterables. Here is the structure: * * { // iterator - * next: { // iteratorNextFunction - * (): { // iteratorNextResult - * value: T // iteratorNextValue + * next: { // nextMethod + * (): { // nextResult + * value: T // nextValue * } * } * } * + * For an async iterator, we expect the following structure: + * + * { // iterator + * next: { // nextMethod + * (): PromiseLike<{ // nextResult + * value: T // nextValue + * }> + * } + * } */ - function getElementTypeOfIterator(type: Type, errorNode: Node): Type { + function getIteratedTypeOfIterator(type: Type, errorNode: Node | undefined, isAsyncIterator: boolean): Type | undefined { if (isTypeAny(type)) { return undefined; } 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. - if ((getObjectFlags(type) & ObjectFlags.Reference) && (type).target === getGlobalIteratorType()) { - typeAsIterator.iteratorElementType = (type).typeArguments[0]; - } - else { - const iteratorNextFunction = getTypeOfPropertyOfType(type, "next"); - if (isTypeAny(iteratorNextFunction)) { - return undefined; - } - - const iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, SignatureKind.Call) : emptyArray; - if (iteratorNextFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, Diagnostics.An_iterator_must_have_a_next_method); - } - return undefined; - } - - const iteratorNextResult = getUnionType(map(iteratorNextFunctionSignatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); - if (isTypeAny(iteratorNextResult)) { - return undefined; - } - - 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); - } - return undefined; - } - - typeAsIterator.iteratorElementType = iteratorNextValue; - } + if (isAsyncIterator ? typeAsIterator.iteratedTypeOfAsyncIterator : typeAsIterator.iteratedTypeOfIterator) { + return isAsyncIterator ? typeAsIterator.iteratedTypeOfAsyncIterator : typeAsIterator.iteratedTypeOfIterator; } - return typeAsIterator.iteratorElementType; - } + // As an optimization, if the type is an instantiation of the global `Iterator` (for + // a non-async iterator) or the global `AsyncIterator` (for an async-iterator) then + // just grab its type argument. + const getIteratorType = isAsyncIterator ? getGlobalAsyncIteratorType : getGlobalIteratorType; + if (isReferenceToType(type, getIteratorType(/*reportErrors*/ false))) { + return isAsyncIterator + ? typeAsIterator.iteratedTypeOfAsyncIterator = (type).typeArguments[0] + : typeAsIterator.iteratedTypeOfIterator = (type).typeArguments[0]; + } - function getElementTypeOfIterableIterator(type: Type): Type { - if (isTypeAny(type)) { + // Both async and non-async iterators must have a `next` method. + const nextMethod = getTypeOfPropertyOfType(type, "next"); + if (isTypeAny(nextMethod)) { return undefined; } - // As an optimization, if the type is instantiated directly using the globalIterableIteratorType (IterableIterator), - // then just grab its type argument. - if ((getObjectFlags(type) & ObjectFlags.Reference) && (type).target === getGlobalIterableIteratorType()) { - return (type).typeArguments[0]; + const nextMethodSignatures = nextMethod ? getSignaturesOfType(nextMethod, SignatureKind.Call) : emptyArray; + if (nextMethodSignatures.length === 0) { + if (errorNode) { + error(errorNode, isAsyncIterator + ? Diagnostics.An_async_iterator_must_have_a_next_method + : Diagnostics.An_iterator_must_have_a_next_method); + } + return undefined; } - return getElementTypeOfIterable(type, /*errorNode*/ undefined) || - getElementTypeOfIterator(type, /*errorNode*/ undefined); + let nextResult = getUnionType(map(nextMethodSignatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); + if (isTypeAny(nextResult)) { + return undefined; + } + + // For an async iterator, we must get the awaited type of the return type. + if (isAsyncIterator) { + nextResult = getAwaitedTypeOfPromise(nextResult, errorNode); + if (isTypeAny(nextResult)) { + return undefined; + } + } + + const nextValue = nextResult && getTypeOfPropertyOfType(nextResult, "value"); + if (!nextValue) { + if (errorNode) { + error(errorNode, isAsyncIterator + ? Diagnostics.The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property + : Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); + } + return undefined; + } + + return isAsyncIterator + ? typeAsIterator.iteratedTypeOfAsyncIterator = nextValue + : typeAsIterator.iteratedTypeOfIterator = nextValue; } /** - * 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 constituent. - * - * 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). + * A generator may have a return type of `Iterator`, `Iterable`, or + * `IterableIterator`. An async generator may have a return type of `AsyncIterator`, + * `AsyncIterable`, or `AsyncIterableIterator`. This function can be used to extract + * the iterated type from this return type for contextual typing and verifying signatures. */ - function checkElementTypeOfArrayOrString(arrayOrStringType: Type, errorNode: Node): Type { - Debug.assert(languageVersion < ScriptTarget.ES2015); - - let arrayType = arrayOrStringType; - if (arrayOrStringType.flags & TypeFlags.Union) { - // After we remove all types that are StringLike, we will know if there was a string constituent - // based on whether the result of filter is a new array. - const arrayTypes = (arrayOrStringType as UnionType).types; - const filteredTypes = filter(arrayTypes, t => !(t.flags & TypeFlags.StringLike)); - if (filteredTypes !== arrayTypes) { - arrayType = getUnionType(filteredTypes, /*subtypeReduction*/ true); - } - } - else if (arrayOrStringType.flags & TypeFlags.StringLike) { - arrayType = neverType; - } - const hasStringConstituent = arrayOrStringType !== arrayType; - let reportedError = false; - if (hasStringConstituent) { - if (languageVersion < ScriptTarget.ES5) { - error(errorNode, 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.flags & TypeFlags.Never) { - return stringType; - } + function getIteratedTypeOfGenerator(returnType: Type, isAsyncGenerator: boolean): Type { + if (isTypeAny(returnType)) { + return undefined; } - 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. - 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)); - } - return hasStringConstituent ? stringType : 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) { - return stringType; - } - - return getUnionType([arrayElementType, stringType], /*subtypeReduction*/ true); - } - - return arrayElementType; + return getIteratedTypeOfIterable(returnType, /*errorNode*/ undefined, isAsyncGenerator, /*allowNonAsyncIterables*/ false, /*checkAssignability*/ false) + || getIteratedTypeOfIterator(returnType, /*errorNode*/ undefined, isAsyncGenerator); } function checkBreakOrContinueStatement(node: BreakOrContinueStatement) { @@ -17864,7 +18954,9 @@ namespace ts { } function isUnwrappedReturnTypeVoidOrAny(func: FunctionLikeDeclaration, returnType: Type): boolean { - const unwrappedReturnType = isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; + const unwrappedReturnType = (getFunctionFlags(func) & FunctionFlags.AsyncOrAsyncGenerator) === FunctionFlags.Async + ? getPromisedTypeOfPromise(returnType) // Async function + : returnType; // AsyncGenerator function, Generator function, or normal function return unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, TypeFlags.Void | TypeFlags.Any); } @@ -17883,8 +18975,8 @@ namespace ts { const returnType = getReturnTypeOfSignature(signature); if (strictNullChecks || node.expression || returnType.flags & TypeFlags.Never) { const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - - if (func.asteriskToken) { + const functionFlags = getFunctionFlags(func); + if (functionFlags & FunctionFlags.Generator) { // AsyncGenerator function or Generator function // 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 @@ -17894,27 +18986,27 @@ namespace ts { if (func.kind === SyntaxKind.SetAccessor) { if (node.expression) { - error(node.expression, Diagnostics.Setters_cannot_return_a_value); + error(node, Diagnostics.Setters_cannot_return_a_value); } } else if (func.kind === SyntaxKind.Constructor) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { - error(node.expression, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); + if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + error(node, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { - if (isAsyncFunctionLike(func)) { - const promisedType = getPromisedType(returnType); - const awaitedType = checkAwaitedType(exprType, node.expression || node, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + if (functionFlags & FunctionFlags.Async) { // Async function + const promisedType = getPromisedTypeOfPromise(returnType); + const awaitedType = checkAwaitedType(exprType, node); 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 || node); + checkTypeAssignableTo(awaitedType, promisedType, node); } } else { - checkTypeAssignableTo(exprType, returnType, node.expression || node); + checkTypeAssignableTo(exprType, returnType, node); } } } @@ -18043,12 +19135,12 @@ namespace ts { else { const blockLocals = catchClause.block.locals; if (blockLocals) { - for (const caughtName in catchClause.locals) { - const blockLocal = blockLocals[caughtName]; + forEachKey(catchClause.locals, caughtName => { + const blockLocal = blockLocals.get(caughtName); if (blockLocal && (blockLocal.flags & SymbolFlags.BlockScopedVariable) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } - } + }); } } } @@ -18117,16 +19209,18 @@ namespace ts { return; } + const propDeclaration = prop.valueDeclaration; + // index is numeric and property name is not valid numeric literal - if (indexKind === IndexKind.Number && !isNumericName(prop.valueDeclaration.name)) { + if (indexKind === IndexKind.Number && !(propDeclaration ? isNumericName(propDeclaration.name) : isNumericLiteralName(prop.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 let errorNode: Node; - if (prop.valueDeclaration.name.kind === SyntaxKind.ComputedPropertyName || prop.parent === containingType.symbol) { - errorNode = prop.valueDeclaration; + if (propDeclaration && (propDeclaration.name.kind === SyntaxKind.ComputedPropertyName || prop.parent === containingType.symbol)) { + errorNode = propDeclaration; } else if (indexDeclaration) { errorNode = indexDeclaration; @@ -18159,18 +19253,28 @@ namespace ts { case "string": case "symbol": case "void": + case "object": error(name, message, (name).text); } } - /** Check each type parameter and check that type parameters have no duplicate type parameter declarations */ + /** + * Check each type parameter and check that type parameters have no duplicate type parameter declarations + */ function checkTypeParameters(typeParameterDeclarations: TypeParameterDeclaration[]) { if (typeParameterDeclarations) { + let seenDefault = false; for (let i = 0; i < typeParameterDeclarations.length; i++) { const node = typeParameterDeclarations[i]; checkTypeParameter(node); if (produceDiagnostics) { + if (node.default) { + seenDefault = true; + } + else if (seenDefault) { + error(node, Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters); + } for (let j = 0; j < i; j++) { if (typeParameterDeclarations[j].symbol === node.symbol) { error(node.name, Diagnostics.Duplicate_identifier_0, declarationNameToString(node.name)); @@ -18182,23 +19286,73 @@ namespace ts { } /** Check that type parameter lists are identical across multiple declarations */ - function checkTypeParameterListsIdentical(node: ClassLikeDeclaration | InterfaceDeclaration, symbol: Symbol) { + function checkTypeParameterListsIdentical(symbol: Symbol) { if (symbol.declarations.length === 1) { return; } - let firstDecl: ClassLikeDeclaration | InterfaceDeclaration; - for (const declaration of symbol.declarations) { - if (declaration.kind === SyntaxKind.ClassDeclaration || declaration.kind === SyntaxKind.InterfaceDeclaration) { - if (!firstDecl) { - firstDecl = declaration; - } - else if (!areTypeParametersIdentical(firstDecl.typeParameters, node.typeParameters)) { - error(node.name, Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); + + const links = getSymbolLinks(symbol); + if (!links.typeParametersChecked) { + links.typeParametersChecked = true; + const declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); + if (declarations.length <= 1) { + return; + } + + const type = getDeclaredTypeOfSymbol(symbol); + if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { + // Report an error on every conflicting declaration. + const name = symbolToString(symbol); + for (const declaration of declarations) { + error(declaration.name, Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } } } + function areTypeParametersIdentical(declarations: (ClassDeclaration | InterfaceDeclaration)[], typeParameters: TypeParameter[]) { + const maxTypeArgumentCount = length(typeParameters); + const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + + for (const declaration of declarations) { + // If this declaration has too few or too many type parameters, we report an error + const numTypeParameters = length(declaration.typeParameters); + if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { + return false; + } + + for (let i = 0; i < numTypeParameters; i++) { + const source = declaration.typeParameters[i]; + const target = typeParameters[i]; + + // If the type parameter node does not have the same as the resolved type + // parameter at this position, we report an error. + if (source.name.text !== target.symbol.name) { + return false; + } + + // If the type parameter node does not have an identical constraint as the resolved + // type parameter at this position, we report an error. + const sourceConstraint = source.constraint && getTypeFromTypeNode(source.constraint); + const targetConstraint = getConstraintFromTypeParameter(target); + if ((sourceConstraint || targetConstraint) && + (!sourceConstraint || !targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint))) { + return false; + } + + // If the type parameter node has a default and it is not identical to the default + // for the type parameter at this position, we report an error. + const sourceDefault = source.default && getTypeFromTypeNode(source.default); + const targetDefault = getDefaultFromTypeParameter(target); + if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) { + return false; + } + } + } + + return true; + } + function checkClassExpression(node: ClassExpression): Type { checkClassLikeDeclaration(node); checkNodeDeferred(node); @@ -18236,19 +19390,25 @@ namespace ts { const type = getDeclaredTypeOfSymbol(symbol); const typeWithThis = getTypeWithThisArgument(type); const staticType = getTypeOfSymbol(symbol); - checkTypeParameterListsIdentical(node, symbol); + checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); + // Only check for reserved static identifiers on non-ambient context. + if (!isInAmbientContext(node)) { + checkClassForStaticPropertyNameConflicts(node); + } + const baseTypeNode = getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (languageVersion < ScriptTarget.ES2015 && !isInAmbientContext(node)) { + if (languageVersion < ScriptTarget.ES2015) { checkExternalEmitHelpers(baseTypeNode.parent, ExternalEmitHelpers.Extends); } const baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { const baseType = baseTypes[0]; - const staticBaseType = getBaseConstructorTypeOfClass(type); + const baseConstructorType = getBaseConstructorTypeOfClass(type); + const staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { @@ -18262,8 +19422,11 @@ namespace ts { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); + if (baseConstructorType.flags & TypeFlags.TypeVariable && !isMixinConstructorType(staticType)) { + error(node.name || node, Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); + } - if (baseType.symbol.valueDeclaration && + if (baseType.symbol && baseType.symbol.valueDeclaration && !isInAmbientContext(baseType.symbol.valueDeclaration) && baseType.symbol.valueDeclaration.kind === SyntaxKind.ClassDeclaration) { if (!isBlockScopedNameDeclaredBeforeUse(baseType.symbol.valueDeclaration, node)) { @@ -18271,7 +19434,7 @@ namespace ts { } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class) && !(baseConstructorType.flags & TypeFlags.TypeVariable)) { // 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 @@ -18295,8 +19458,7 @@ namespace ts { if (produceDiagnostics) { const t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - const declaredType = getObjectFlags(t) & ObjectFlags.Reference ? (t).target : t; - if (getObjectFlags(declaredType) & ObjectFlags.ClassOrInterface) { + if (isValidBaseType(t)) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1); } else { @@ -18329,14 +19491,19 @@ namespace ts { function getTargetSymbol(s: Symbol) { // 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 & SymbolFlags.Instantiated ? getSymbolLinks(s).target : s; + return getCheckFlags(s) & CheckFlags.Instantiated ? (s).target : s; } function getClassLikeDeclarationOfSymbol(symbol: Symbol): Declaration { return forEach(symbol.declarations, d => isClassLike(d) ? d : undefined); } - function checkKindsOfPropertyMemberOverrides(type: InterfaceType, baseType: ObjectType): void { + function getClassOrInterfaceDeclarationsOfSymbol(symbol: Symbol) { + return filter(symbol.declarations, (d: Declaration): d is ClassDeclaration | InterfaceDeclaration => + d.kind === SyntaxKind.ClassDeclaration || d.kind === SyntaxKind.InterfaceDeclaration); + } + + function checkKindsOfPropertyMemberOverrides(type: InterfaceType, baseType: BaseType): void { // TypeScript 1.0 spec (April 2014): 8.2.3 // A derived class inherits all members from its base class it doesn't override. @@ -18353,7 +19520,7 @@ namespace ts { // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration - const baseProperties = getPropertiesOfObjectType(baseType); + const baseProperties = getPropertiesOfType(baseType); for (const baseProperty of baseProperties) { const base = getTargetSymbol(baseProperty); @@ -18437,35 +19604,6 @@ namespace ts { return kind === SyntaxKind.GetAccessor || kind === SyntaxKind.SetAccessor; } - function areTypeParametersIdentical(list1: TypeParameterDeclaration[], list2: TypeParameterDeclaration[]) { - 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 (let i = 0; i < list1.length; i++) { - const tp1 = list1[i]; - const 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: InterfaceType, typeNode: Node): boolean { const baseTypes = getBaseTypes(type); if (baseTypes.length < 2) { @@ -18473,15 +19611,15 @@ namespace ts { } const seen = createMap<{ prop: Symbol; containingType: Type }>(); - forEach(resolveDeclaredMembers(type).declaredProperties, p => { seen[p.name] = { prop: p, containingType: type }; }); + forEach(resolveDeclaredMembers(type).declaredProperties, p => { seen.set(p.name, { prop: p, containingType: type }); }); let ok = true; for (const base of baseTypes) { - const properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); + const properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); for (const prop of properties) { - const existing = seen[prop.name]; + const existing = seen.get(prop.name); if (!existing) { - seen[prop.name] = { prop: prop, containingType: base }; + seen.set(prop.name, { prop: prop, containingType: base }); } else { const isInheritedProperty = existing.containingType !== type; @@ -18512,7 +19650,7 @@ namespace ts { checkExportsOnMergedDeclarations(node); const symbol = getSymbolOfNode(node); - checkTypeParameterListsIdentical(node, symbol); + checkTypeParameterListsIdentical(symbol); // Only check this symbol once const firstInterfaceDecl = getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration); @@ -18907,7 +20045,7 @@ namespace ts { // We can detect if augmentation was applied using following rules: // - augmentation for a global scope is always applied // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). - const checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & SymbolFlags.Merged); + const checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & SymbolFlags.Transient); if (checkBody && node.body) { // body of ambient external module is always a module block for (const statement of (node.body).statements) { @@ -18986,7 +20124,7 @@ namespace ts { // this is done it two steps // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error // 2. main check - report error if value declaration of the parent symbol is module augmentation) - let reportError = !(symbol.flags & SymbolFlags.Merged); + let reportError = !(symbol.flags & SymbolFlags.Transient); if (!reportError) { // symbol should not originate in augmentation reportError = isExternalModuleAugmentation(symbol.parent.declarations[0]); @@ -19150,7 +20288,9 @@ namespace ts { forEach(node.exportClause.elements, checkExportSpecifier); const inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && isAmbientModule(node.parent.parent); - if (node.parent.kind !== SyntaxKind.SourceFile && !inAmbientExternalModule) { + const inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === SyntaxKind.ModuleBlock && + !node.moduleSpecifier && isInAmbientContext(node); + if (node.parent.kind !== SyntaxKind.SourceFile && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -19235,19 +20375,14 @@ namespace ts { } function hasExportedMembers(moduleSymbol: Symbol) { - for (const id in moduleSymbol.exports) { - if (id !== "export=") { - return true; - } - } - return false; + return forEachEntry(moduleSymbol.exports, (_, id) => id !== "export="); } function checkExternalModuleExports(node: SourceFile | ModuleDeclaration) { const moduleSymbol = getSymbolOfNode(node); const links = getSymbolLinks(moduleSymbol); if (!links.exportsChecked) { - const exportEqualsSymbol = moduleSymbol.exports["export="]; + const exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { const declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; if (!isTopLevelInExternalModuleAugmentation(declaration)) { @@ -19256,21 +20391,20 @@ namespace ts { } // Checks for export * conflicts const exports = getExportsOfModule(moduleSymbol); - for (const id in exports) { + exports && exports.forEach(({ declarations, flags }, id) => { if (id === "__export") { - continue; + return; } - const { declarations, flags } = exports[id]; // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. // (TS Exceptions: namespaces, function overloads, enums, and interfaces) if (flags & (SymbolFlags.Namespace | SymbolFlags.Interface | SymbolFlags.Enum)) { - continue; + return; } const exportedDeclarationsCount = countWhere(declarations, isNotOverload); if (flags & SymbolFlags.TypeAlias && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) - continue; + return; } if (exportedDeclarationsCount > 1) { for (const declaration of declarations) { @@ -19279,7 +20413,7 @@ namespace ts { } } } - } + }); links.exportsChecked = true; } @@ -19590,14 +20724,14 @@ namespace ts { } function getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[] { - const symbols = createMap(); - let memberFlags: ModifierFlags = ModifierFlags.None; - if (isInsideWithStatementBody(location)) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } + const symbols = createMap(); + let memberFlags: ModifierFlags = ModifierFlags.None; + populateSymbols(); return symbolsToArray(symbols); @@ -19668,18 +20802,17 @@ namespace ts { // 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 (!symbols[id]) { - symbols[id] = symbol; + if (!symbols.has(id)) { + symbols.set(id, symbol); } } } function copySymbols(source: SymbolTable, meaning: SymbolFlags): void { if (meaning) { - for (const id in source) { - const symbol = source[id]; + source.forEach(symbol => { copySymbol(symbol, meaning); - } + }); } } } @@ -19756,22 +20889,29 @@ namespace ts { return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; } + function getSpecialPropertyAssignmentSymbolFromEntityName(entityName: EntityName | PropertyAccessExpression) { + const specialPropertyAssignmentKind = getSpecialPropertyAssignmentKind(entityName.parent.parent); + switch (specialPropertyAssignmentKind) { + case SpecialPropertyAssignmentKind.ExportsProperty: + case SpecialPropertyAssignmentKind.PrototypeProperty: + return getSymbolOfNode(entityName.parent); + case SpecialPropertyAssignmentKind.ThisProperty: + case SpecialPropertyAssignmentKind.ModuleExports: + case SpecialPropertyAssignmentKind.Property: + return getSymbolOfNode(entityName.parent.parent); + } + } + function getSymbolOfEntityNameOrPropertyAccessExpression(entityName: EntityName | PropertyAccessExpression): Symbol | undefined { if (isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } if (isInJavaScriptFile(entityName) && entityName.parent.kind === SyntaxKind.PropertyAccessExpression) { - const specialPropertyAssignmentKind = getSpecialPropertyAssignmentKind(entityName.parent.parent); - switch (specialPropertyAssignmentKind) { - case SpecialPropertyAssignmentKind.ExportsProperty: - case SpecialPropertyAssignmentKind.PrototypeProperty: - return getSymbolOfNode(entityName.parent); - case SpecialPropertyAssignmentKind.ThisProperty: - case SpecialPropertyAssignmentKind.ModuleExports: - return getSymbolOfNode(entityName.parent.parent); - default: - // Fall through if it is not a special property assignment + // Check if this is a special property assignment + const specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); + if (specialPropertyAssignmentSymbol) { + return specialPropertyAssignmentSymbol; } } @@ -19858,6 +20998,7 @@ namespace ts { if (node.kind === SyntaxKind.SourceFile) { return isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } + if (isInsideWithStatementBody(node)) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; @@ -20029,7 +21170,7 @@ namespace ts { // for ( { a } of elems) { // } if (expr.parent.kind === SyntaxKind.ForOfStatement) { - const iteratedType = checkRightHandSideOfForOf((expr.parent).expression); + const iteratedType = checkRightHandSideOfForOf((expr.parent).expression, (expr.parent).awaitModifier); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from "for" initializer @@ -20048,7 +21189,7 @@ namespace ts { Debug.assert(expr.parent.kind === SyntaxKind.ArrayLiteralExpression); // [{ property1: p1, property2 }] = elems; const typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); - const elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false) || unknownType; + const elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, indexOf((expr.parent).elements, expr), elementType || unknownType); } @@ -20090,8 +21231,8 @@ namespace ts { const propsByName = createSymbolTable(getPropertiesOfType(type)); if (getSignaturesOfType(type, SignatureKind.Call).length || getSignaturesOfType(type, SignatureKind.Construct).length) { forEach(getPropertiesOfType(globalFunctionType), p => { - if (!propsByName[p.name]) { - propsByName[p.name] = p; + if (!propsByName.has(p.name)) { + propsByName.set(p.name, p); } }); } @@ -20099,7 +21240,7 @@ namespace ts { } function getRootSymbols(symbol: Symbol): Symbol[] { - if (symbol.flags & SymbolFlags.SyntheticProperty) { + if (getCheckFlags(symbol) & CheckFlags.SyntheticProperty) { const symbols: Symbol[] = []; const name = symbol.name; forEach(getSymbolLinks(symbol).containingType.types, t => { @@ -20115,6 +21256,10 @@ namespace ts { const links = symbol as SymbolLinks; return [links.leftSpread, links.rightSpread]; } + if ((symbol as SymbolLinks).mappedTypeOrigin) { + return getRootSymbols((symbol as SymbolLinks).mappedTypeOrigin); + } + let target: Symbol; let next = symbol; while (next = getSymbolLinks(next).target) { @@ -20133,7 +21278,8 @@ namespace ts { if (!isGeneratedIdentifier(node)) { node = getParseTreeNode(node, isIdentifier); if (node) { - return getReferencedValueSymbol(node) === argumentsSymbol; + const isPropertyName = node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).name === node; + return !isPropertyName && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -20158,7 +21304,7 @@ namespace ts { // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment ? !!(moduleSymbol.flags & SymbolFlags.Value) - : forEachProperty(getExportsOfModule(moduleSymbol), isValue); + : forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; @@ -20303,12 +21449,6 @@ namespace ts { } function isValueAliasDeclaration(node: Node): boolean { - node = getParseTreeNode(node); - if (node === undefined) { - // A synthesized node comes from an emit transformation and is always a value. - return true; - } - switch (node.kind) { case SyntaxKind.ImportEqualsDeclaration: case SyntaxKind.ImportClause: @@ -20355,12 +21495,6 @@ namespace ts { } function isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean { - node = getParseTreeNode(node); - // Purely synthesized nodes are always emitted. - if (node === undefined) { - return true; - } - if (isAliasSymbolDeclaration(node)) { const symbol = getSymbolOfNode(node); if (symbol && getSymbolLinks(symbol).referenced) { @@ -20395,9 +21529,15 @@ namespace ts { return false; } + function isRequiredInitializedParameter(parameter: ParameterDeclaration) { + return strictNullChecks && + !isOptionalParameter(parameter) && + parameter.initializer && + !(getModifierFlags(parameter) & ModifierFlags.ParameterPropertyModifier); + } + function getNodeCheckFlags(node: Node): NodeCheckFlags { - node = getParseTreeNode(node); - return node ? getNodeLinks(node).flags : undefined; + return getNodeLinks(node).flags; } function getEnumMemberValue(node: EnumMember): number { @@ -20405,6 +21545,16 @@ namespace ts { return getNodeLinks(node).enumMemberValue; } + function canHaveConstantValue(node: Node): node is EnumMember | PropertyAccessExpression | ElementAccessExpression { + switch (node.kind) { + case SyntaxKind.EnumMember: + case SyntaxKind.PropertyAccessExpression: + case SyntaxKind.ElementAccessExpression: + return true; + } + return false; + } + function getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number { if (node.kind === SyntaxKind.EnumMember) { return getEnumMemberValue(node); @@ -20428,18 +21578,21 @@ namespace ts { function getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind { // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. const valueSymbol = resolveEntityName(typeName, SymbolFlags.Value, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); - const globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); - if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { - return TypeReferenceSerializationKind.Promise; - } - - 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. const typeSymbol = resolveEntityName(typeName, SymbolFlags.Type, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + if (valueSymbol && valueSymbol === typeSymbol) { + const globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); + if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { + return TypeReferenceSerializationKind.Promise; + } + + const constructorType = getTypeOfSymbol(valueSymbol); + if (constructorType && isConstructorType(constructorType)) { + return TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + } + // We might not be able to resolve type symbol so use unknown type in that case (eg error case) if (!typeSymbol) { return TypeReferenceSerializationKind.ObjectType; @@ -20483,10 +21636,12 @@ 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 const symbol = getSymbolOfNode(declaration); - const type = symbol && !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature)) + let type = symbol && !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : unknownType; - + if (flags & TypeFormatFlags.AddUndefined) { + type = includeFalsyTypes(type, TypeFlags.Undefined); + } getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } @@ -20504,11 +21659,14 @@ namespace ts { const classType = getDeclaredTypeOfSymbol(getSymbolOfNode(node)); resolveBaseTypesOfClass(classType); const baseType = classType.resolvedBaseTypes.length ? classType.resolvedBaseTypes[0] : unknownType; + if (!baseType.symbol) { + writer.reportIllegalExtends(); + } getSymbolDisplayBuilder().buildTypeDisplay(baseType, writer, enclosingDeclaration, flags); } function hasGlobalName(name: string): boolean { - return !!globals[name]; + return globals.has(name); } function getReferencedValueSymbol(reference: Identifier, startInDeclarationContainer?: boolean): Symbol { @@ -20565,34 +21723,48 @@ namespace ts { if (resolvedTypeReferenceDirectives) { // populate reverse mapping: file path -> type reference directive that was resolved to this file fileToDirective = createFileMap(); - for (const key in resolvedTypeReferenceDirectives) { - const resolvedDirective = resolvedTypeReferenceDirectives[key]; + resolvedTypeReferenceDirectives.forEach((resolvedDirective, key) => { if (!resolvedDirective) { - continue; + return; } const file = host.getSourceFile(resolvedDirective.resolvedFileName); fileToDirective.set(file.path, key); - } + }); } return { getReferencedExportContainer, getReferencedImportDeclaration, getReferencedDeclarationWithCollidingName, isDeclarationWithCollidingName, - isValueAliasDeclaration, + isValueAliasDeclaration: node => { + node = getParseTreeNode(node); + // Synthesized nodes are always treated like values. + return node ? isValueAliasDeclaration(node) : true; + }, hasGlobalName, - isReferencedAliasDeclaration, - getNodeCheckFlags, + isReferencedAliasDeclaration: (node, checkChildren?) => { + node = getParseTreeNode(node); + // Synthesized nodes are always treated as referenced. + return node ? isReferencedAliasDeclaration(node, checkChildren) : true; + }, + getNodeCheckFlags: node => { + node = getParseTreeNode(node); + return node ? getNodeCheckFlags(node) : undefined; + }, isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible, isImplementationOfOverload, + isRequiredInitializedParameter, writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration, writeTypeOfExpression, writeBaseConstructorTypeOfClass, isSymbolAccessible, isEntityNameVisible, - getConstantValue, + getConstantValue: node => { + node = getParseTreeNode(node, canHaveConstantValue); + return node ? getConstantValue(node) : undefined; + }, collectLinkedAliases, getReferencedValueDeclaration, getTypeReferenceSerializationKind, @@ -20716,11 +21888,11 @@ namespace ts { if (file.symbol && file.symbol.globalExports) { // Merge in UMD exports with first-in-wins semantics (see #9771) const source = file.symbol.globalExports; - for (const id in source) { - if (!(id in globals)) { - globals[id] = source[id]; + source.forEach((sourceSymbol, id) => { + if (!globals.has(id)) { + globals.set(id, sourceSymbol); } - } + }); } } @@ -20738,49 +21910,18 @@ namespace ts { addToSymbolTable(globals, builtinGlobals, Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0); getSymbolLinks(undefinedSymbol).type = undefinedWideningType; - getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); + getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", /*arity*/ 0, /*reportErrors*/ true); getSymbolLinks(unknownSymbol).type = unknownType; // 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"); - + globalArrayType = getGlobalType("Array", /*arity*/ 1, /*reportErrors*/ true); + globalObjectType = getGlobalType("Object", /*arity*/ 0, /*reportErrors*/ true); + globalFunctionType = getGlobalType("Function", /*arity*/ 0, /*reportErrors*/ true); + globalStringType = getGlobalType("String", /*arity*/ 0, /*reportErrors*/ true); + globalNumberType = getGlobalType("Number", /*arity*/ 0, /*reportErrors*/ true); + globalBooleanType = getGlobalType("Boolean", /*arity*/ 0, /*reportErrors*/ true); + globalRegExpType = getGlobalType("RegExp", /*arity*/ 0, /*reportErrors*/ true); jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); - getGlobalClassDecoratorType = memoize(() => getGlobalType("ClassDecorator")); - getGlobalPropertyDecoratorType = memoize(() => getGlobalType("PropertyDecorator")); - getGlobalMethodDecoratorType = memoize(() => getGlobalType("MethodDecorator")); - getGlobalParameterDecoratorType = memoize(() => getGlobalType("ParameterDecorator")); - getGlobalTypedPropertyDescriptorType = memoize(() => getGlobalType("TypedPropertyDescriptor", /*arity*/ 1)); - getGlobalESSymbolConstructorSymbol = memoize(() => getGlobalValueSymbol("Symbol")); - getGlobalPromiseType = memoize(() => getGlobalType("Promise", /*arity*/ 1)); - tryGetGlobalPromiseType = memoize(() => getGlobalSymbol("Promise", SymbolFlags.Type, /*diagnostic*/ undefined) && getGlobalPromiseType()); - getGlobalPromiseLikeType = memoize(() => getGlobalType("PromiseLike", /*arity*/ 1)); - getInstantiatedGlobalPromiseLikeType = memoize(createInstantiatedPromiseLikeType); - getGlobalPromiseConstructorSymbol = memoize(() => getGlobalValueSymbol("Promise")); - tryGetGlobalPromiseConstructorSymbol = memoize(() => getGlobalSymbol("Promise", SymbolFlags.Value, /*diagnostic*/ undefined) && getGlobalPromiseConstructorSymbol()); - getGlobalPromiseConstructorLikeType = memoize(() => getGlobalType("PromiseConstructorLike")); - getGlobalThenableType = memoize(createThenableType); - - getGlobalTemplateStringsArrayType = memoize(() => getGlobalType("TemplateStringsArray")); - - if (languageVersion >= ScriptTarget.ES2015) { - getGlobalESSymbolType = memoize(() => getGlobalType("Symbol")); - getGlobalIterableType = memoize(() => getGlobalType("Iterable", /*arity*/ 1)); - getGlobalIteratorType = memoize(() => getGlobalType("Iterator", /*arity*/ 1)); - getGlobalIterableIteratorType = memoize(() => getGlobalType("IterableIterator", /*arity*/ 1)); - } - else { - getGlobalESSymbolType = memoize(() => emptyObjectType); - getGlobalIterableType = memoize(() => emptyGenericType); - getGlobalIteratorType = memoize(() => emptyGenericType); - getGlobalIterableIteratorType = memoize(() => emptyGenericType); - } - anyArrayType = createArrayType(anyType); autoArrayType = createArrayType(autoType); @@ -20792,7 +21933,7 @@ namespace ts { function checkExternalEmitHelpers(location: Node, helpers: ExternalEmitHelpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { const sourceFile = getSourceFileOfNode(location); - if (!isDeclarationFile(sourceFile) && isEffectiveExternalModule(sourceFile, compilerOptions)) { + if (isEffectiveExternalModule(sourceFile, compilerOptions) && !isInAmbientContext(location)) { const helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { const uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; @@ -20821,6 +21962,12 @@ namespace ts { case ExternalEmitHelpers.Param: return "__param"; case ExternalEmitHelpers.Awaiter: return "__awaiter"; case ExternalEmitHelpers.Generator: return "__generator"; + case ExternalEmitHelpers.Values: return "__values"; + case ExternalEmitHelpers.Read: return "__read"; + case ExternalEmitHelpers.Spread: return "__spread"; + case ExternalEmitHelpers.AsyncGenerator: return "__asyncGenerator"; + case ExternalEmitHelpers.AsyncDelegator: return "__asyncDelegator"; + case ExternalEmitHelpers.AsyncValues: return "__asyncValues"; case ExternalEmitHelpers.ExportStar: return "__exportStar"; default: Debug.fail("Unrecognized helper"); } @@ -20833,29 +21980,6 @@ namespace ts { return externalHelpersModule; } - - function createInstantiatedPromiseLikeType(): ObjectType { - const 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`. - const thenPropertySymbol = createSymbol(SymbolFlags.Transient | SymbolFlags.Property, "then"); - getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - - const thenableType = createObjectType(ObjectFlags.Anonymous); - thenableType.properties = [thenPropertySymbol]; - thenableType.members = createSymbolTable(thenableType.properties); - thenableType.callSignatures = []; - thenableType.constructSignatures = []; - return thenableType; - } - // GRAMMAR CHECKING function checkGrammarDecorators(node: Node): boolean { if (!node.decorators) { @@ -21147,10 +22271,7 @@ namespace ts { case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: - if (!(node).asteriskToken) { - return false; - } - break; + return false; } return grammarErrorOnNode(asyncModifier, Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -21395,9 +22516,6 @@ namespace ts { if (!node.body) { return grammarErrorOnNode(node.asteriskToken, Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); } - if (languageVersion < ScriptTarget.ES2015) { - return grammarErrorOnNode(node.asteriskToken, Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher); - } } } @@ -21474,17 +22592,17 @@ namespace ts { continue; } - if (!seen[effectiveName]) { - seen[effectiveName] = currentKind; + const existingKind = seen.get(effectiveName); + if (!existingKind) { + seen.set(effectiveName, currentKind); } else { - const existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { grammarErrorOnNode(name, Diagnostics.Duplicate_identifier_0, getTextOfNode(name)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[effectiveName] = currentKind | existingKind; + seen.set(effectiveName, currentKind | existingKind); } else { return grammarErrorOnNode(name, Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); @@ -21499,15 +22617,16 @@ namespace ts { function checkGrammarJsxElement(node: JsxOpeningLikeElement) { const seen = createMap(); - for (const attr of node.attributes) { + + for (const attr of node.attributes.properties) { if (attr.kind === SyntaxKind.JsxSpreadAttribute) { continue; } const jsxAttr = (attr); const name = jsxAttr.name; - if (!seen[name.text]) { - seen[name.text] = true; + if (!seen.get(name.text)) { + seen.set(name.text, true); } else { return grammarErrorOnNode(name, Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); @@ -21525,6 +22644,12 @@ namespace ts { return true; } + if (forInOrOfStatement.kind === SyntaxKind.ForOfStatement && forInOrOfStatement.awaitModifier) { + if ((forInOrOfStatement.flags & NodeFlags.AwaitContext) === NodeFlags.None) { + return grammarErrorOnNode(forInOrOfStatement.awaitModifier, Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); + } + } + if (forInOrOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList) { const variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { @@ -21777,6 +22902,11 @@ namespace ts { } } + if (compilerOptions.module !== ModuleKind.ES2015 && compilerOptions.module !== ModuleKind.System && !compilerOptions.noEmit && + !isInAmbientContext(node.parent.parent) && hasModifier(node.parent.parent, ModifierFlags.Export)) { + checkESModuleMarker(node.name); + } + const checkLetConstNames = (isLet(node) || isConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; @@ -21789,6 +22919,22 @@ namespace ts { return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } + function checkESModuleMarker(name: Identifier | BindingPattern): boolean { + if (name.kind === SyntaxKind.Identifier) { + if (unescapeIdentifier(name.text) === "__esModule") { + return grammarErrorOnNode(name, Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); + } + } + else { + const elements = (name).elements; + for (const element of elements) { + if (!isOmittedExpression(element)) { + return checkESModuleMarker(element.name); + } + } + } + } + function checkGrammarNameInLetOrConstDeclarations(name: Identifier | BindingPattern): boolean { if (name.kind === SyntaxKind.Identifier) { if ((name).originalKeywordKind === SyntaxKind.LetKeyword) { @@ -22026,11 +23172,11 @@ namespace ts { function getAmbientModules(): Symbol[] { const result: Symbol[] = []; - for (const sym in globals) { + globals.forEach((global, sym) => { if (ambientModuleSymbolRegex.test(sym)) { - result.push(globals[sym]); + result.push(global); } - } + }); return result; } } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 2e2c5c0bdb6..6b4e9ff590e 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// @@ -65,12 +65,13 @@ namespace ts { }, { name: "jsx", - type: createMap({ + type: createMapFromTemplate({ "preserve": JsxEmit.Preserve, + "react-native": JsxEmit.ReactNative, "react": JsxEmit.React }), paramType: Diagnostics.KIND, - description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, }, { name: "reactNamespace", @@ -100,7 +101,7 @@ namespace ts { { name: "module", shortName: "m", - type: createMap({ + type: createMapFromTemplate({ "none": ModuleKind.None, "commonjs": ModuleKind.CommonJS, "amd": ModuleKind.AMD, @@ -114,7 +115,7 @@ namespace ts { }, { name: "newLine", - type: createMap({ + type: createMapFromTemplate({ "crlf": NewLineKind.CarriageReturnLineFeed, "lf": NewLineKind.LineFeed }), @@ -212,8 +213,8 @@ namespace ts { shortName: "p", type: "string", isFilePath: true, - description: Diagnostics.Compile_the_project_in_the_given_directory, - paramType: Diagnostics.DIRECTORY + description: Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + paramType: Diagnostics.FILE_OR_DIRECTORY }, { name: "removeComments", @@ -263,7 +264,7 @@ namespace ts { { name: "target", shortName: "t", - type: createMap({ + type: createMapFromTemplate({ "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5, "es6": ScriptTarget.ES2015, @@ -300,7 +301,7 @@ namespace ts { }, { name: "moduleResolution", - type: createMap({ + type: createMapFromTemplate({ "node": ModuleResolutionKind.NodeJs, "classic": ModuleResolutionKind.Classic, }), @@ -332,6 +333,11 @@ namespace ts { type: "boolean", description: Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file }, + { + name: "downlevelIteration", + type: "boolean", + description: Diagnostics.Use_full_down_level_iteration_for_iterables_and_arrays_for_for_of_spread_and_destructuring_in_ES5_Slash3 + }, { name: "baseUrl", type: "string", @@ -409,7 +415,7 @@ namespace ts { type: "list", element: { name: "lib", - type: createMap({ + type: createMapFromTemplate({ // JavaScript only "es5": "lib.es5.d.ts", "es6": "lib.es2015.d.ts", @@ -417,6 +423,7 @@ namespace ts { "es7": "lib.es2016.d.ts", "es2016": "lib.es2016.d.ts", "es2017": "lib.es2017.d.ts", + "esnext": "lib.esnext.d.ts", // Host only "dom": "lib.dom.d.ts", "dom.iterable": "lib.dom.iterable.d.ts", @@ -436,6 +443,7 @@ namespace ts { "es2017.object": "lib.es2017.object.d.ts", "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", "es2017.string": "lib.es2017.string.d.ts", + "esnext.asynciterable": "lib.esnext.asynciterable.d.ts", }), }, description: Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon @@ -458,6 +466,16 @@ namespace ts { name: "alwaysStrict", type: "boolean", description: Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + }, + { + // A list of plugins to load in the language service + name: "plugins", + type: "list", + isTSConfigOnly: true, + element: { + name: "plugin", + type: "object" + } } ]; @@ -517,7 +535,7 @@ namespace ts { include: typeAcquisition.include || [], exclude: typeAcquisition.exclude || [] }; - return result; + return result; } return typeAcquisition; } @@ -531,9 +549,9 @@ namespace ts { const optionNameMap = createMap(); const shortOptionNames = createMap(); forEach(optionDeclarations, option => { - optionNameMap[option.name.toLowerCase()] = option; + optionNameMap.set(option.name.toLowerCase(), option); if (option.shortName) { - shortOptionNames[option.shortName] = option.name; + shortOptionNames.set(option.shortName, option.name); } }); @@ -543,7 +561,7 @@ namespace ts { /* @internal */ export function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic { - const namesOfType = Object.keys(opt.type).map(key => `'${key}'`).join(", "); + const namesOfType = arrayFrom(opt.type.keys()).map(key => `'${key}'`).join(", "); return createCompilerDiagnostic(Diagnostics.Argument_for_0_option_must_be_Colon_1, `--${opt.name}`, namesOfType); } @@ -597,13 +615,13 @@ namespace ts { s = s.slice(s.charCodeAt(1) === CharacterCodes.minus ? 2 : 1).toLowerCase(); // Try to translate short option names to their full equivalents. - if (s in shortOptionNames) { - s = shortOptionNames[s]; + const short = shortOptionNames.get(s); + if (short !== undefined) { + s = short; } - if (s in optionNameMap) { - const opt = optionNameMap[s]; - + const opt = optionNameMap.get(s); + if (opt) { if (opt.isTSConfigOnly) { errors.push(createCompilerDiagnostic(Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); } @@ -726,7 +744,7 @@ namespace ts { * @param fileNames array of filenames to be generated into tsconfig.json */ /* @internal */ - export function generateTSConfig(options: CompilerOptions, fileNames: string[]): { compilerOptions: Map } { + export function generateTSConfig(options: CompilerOptions, fileNames: string[]): { compilerOptions: MapLike } { const compilerOptions = extend(options, defaultInitCompilerOptions); const configurations: any = { compilerOptions: serializeCompilerOptions(compilerOptions) @@ -751,18 +769,17 @@ namespace ts { } } - function getNameOfCompilerOptionValue(value: CompilerOptionsValue, customTypeMap: MapLike): string | undefined { + function getNameOfCompilerOptionValue(value: CompilerOptionsValue, customTypeMap: Map): string | undefined { // There is a typeMap associated with this command-line option so use it to map value back to its name - for (const key in customTypeMap) { - if (customTypeMap[key] === value) { + return forEachEntry(customTypeMap, (mapValue, key) => { + if (mapValue === value) { return key; } - } - return undefined; + }); } - function serializeCompilerOptions(options: CompilerOptions): Map { - const result = createMap(); + function serializeCompilerOptions(options: CompilerOptions): MapLike { + const result: ts.MapLike = {}; const optionsNameMap = getOptionNameMap().optionNameMap; for (const name in options) { @@ -778,7 +795,7 @@ namespace ts { break; default: const value = options[name]; - const optionDefinition = optionsNameMap[name.toLowerCase()]; + const optionDefinition = optionsNameMap.get(name.toLowerCase()); if (optionDefinition) { const customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { @@ -840,7 +857,7 @@ namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: FileExtensionInfo[] = []): ParsedCommandLine { + export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: JsFileExtensionInfo[] = []): ParsedCommandLine { const errors: Diagnostic[] = []; basePath = normalizeSlashes(basePath); const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames); @@ -1049,8 +1066,8 @@ namespace ts { const optionNameMap = arrayToMap(optionDeclarations, opt => opt.name); for (const id in jsonOptions) { - if (id in optionNameMap) { - const opt = optionNameMap[id]; + const opt = optionNameMap.get(id); + if (opt) { defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); } else { @@ -1086,8 +1103,9 @@ namespace ts { function convertJsonOptionOfCustomType(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]) { const key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; + const val = opt.type.get(key); + if (val !== undefined) { + return val; } else { errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); @@ -1185,7 +1203,7 @@ namespace ts { * @param host The host used to resolve files and directories. * @param errors An array for diagnostic reporting. */ - function matchFileNames(fileNames: string[], include: string[], exclude: string[], basePath: string, options: CompilerOptions, host: ParseConfigHost, errors: Diagnostic[], extraFileExtensions: FileExtensionInfo[]): ExpandResult { + function matchFileNames(fileNames: string[], include: string[], exclude: string[], basePath: string, options: CompilerOptions, host: ParseConfigHost, errors: Diagnostic[], extraFileExtensions: JsFileExtensionInfo[]): ExpandResult { basePath = normalizePath(basePath); // The exclude spec list is converted into a regular expression, which allows us to quickly @@ -1215,7 +1233,7 @@ namespace ts { // file map that marks whether it was a regular wildcard match (with a `*` or `?` token), // or a recursive directory. This information is used by filesystem watchers to monitor for // new entries in these paths. - const wildcardDirectories: Map = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); + const wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); // Rather than requery this for each file and filespec, we query the supported extensions // once and store it on the expansion context. @@ -1226,7 +1244,7 @@ namespace ts { if (fileNames) { for (const fileName of fileNames) { const file = combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; + literalFileMap.set(keyMapper(file), file); } } @@ -1249,15 +1267,14 @@ namespace ts { removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); const key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; + if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) { + wildcardFileMap.set(key, file); } } } - const literalFiles = reduceProperties(literalFileMap, addFileToOutput, []); - const wildcardFiles = reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); + const literalFiles = arrayFrom(literalFileMap.values()); + const wildcardFiles = arrayFrom(wildcardFileMap.values()); return { fileNames: literalFiles.concat(wildcardFiles), wildcardDirectories @@ -1287,7 +1304,7 @@ namespace ts { /** * Gets directories in a set of include patterns that should be watched for changes. */ - function getWildcardDirectories(include: string[], exclude: string[], path: string, useCaseSensitiveFileNames: boolean): Map { + function getWildcardDirectories(include: string[], exclude: string[], path: string, useCaseSensitiveFileNames: boolean): MapLike { // We watch a directory recursively if it contains a wildcard anywhere in a directory segment // of the pattern: // @@ -1302,7 +1319,7 @@ namespace ts { // /a/b/a?z - Watch /a/b directly to catch any new file matching a?z const rawExcludeRegex = getRegularExpressionForWildcard(exclude, path, "exclude"); const excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - const wildcardDirectories = createMap(); + const wildcardDirectories: ts.MapLike = {}; if (include !== undefined) { const recursiveKeys: string[] = []; for (const file of include) { @@ -1325,13 +1342,13 @@ namespace ts { } // Remove any subpaths under an existing recursively watched directory. - for (const key in wildcardDirectories) { + for (const key in wildcardDirectories) if (hasProperty(wildcardDirectories, key)) { for (const recursiveKey of recursiveKeys) { if (key !== recursiveKey && containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { delete wildcardDirectories[key]; } } - } + }; } return wildcardDirectories; @@ -1361,11 +1378,11 @@ namespace ts { */ function hasFileWithHigherPriorityExtension(file: string, literalFiles: Map, wildcardFiles: Map, extensions: string[], keyMapper: (value: string) => string) { const extensionPriority = getExtensionPriority(file, extensions); - const adjustedExtensionPriority = adjustExtensionPriority(extensionPriority); + const adjustedExtensionPriority = adjustExtensionPriority(extensionPriority, extensions); for (let i = ExtensionPriority.Highest; i < adjustedExtensionPriority; i++) { const higherPriorityExtension = extensions[i]; const higherPriorityPath = keyMapper(changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { return true; } } @@ -1383,25 +1400,14 @@ namespace ts { */ function removeWildcardFilesWithLowerPriorityExtension(file: string, wildcardFiles: Map, extensions: string[], keyMapper: (value: string) => string) { const extensionPriority = getExtensionPriority(file, extensions); - const nextExtensionPriority = getNextLowestExtensionPriority(extensionPriority); + const nextExtensionPriority = getNextLowestExtensionPriority(extensionPriority, extensions); for (let i = nextExtensionPriority; i < extensions.length; i++) { const lowerPriorityExtension = extensions[i]; const lowerPriorityPath = keyMapper(changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; + wildcardFiles.delete(lowerPriorityPath); } } - /** - * Adds a file to an array of files. - * - * @param output The output array. - * @param file The file path. - */ - function addFileToOutput(output: string[], file: string) { - output.push(file); - return output; - } - /** * Gets a case sensitive key. * diff --git a/src/compiler/comments.ts b/src/compiler/comments.ts index bd9190dbec7..9e077ebfaa8 100644 --- a/src/compiler/comments.ts +++ b/src/compiler/comments.ts @@ -5,17 +5,17 @@ namespace ts { export interface CommentWriter { reset(): void; setSourceFile(sourceFile: SourceFile): void; - emitNodeWithComments(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; + setWriter(writer: EmitTextWriter): void; + emitNodeWithComments(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; emitBodyWithDetachedComments(node: Node, detachedRange: TextRange, emitCallback: (node: Node) => void): void; emitTrailingCommentsOfPosition(pos: number): void; + emitLeadingCommentsOfPosition(pos: number): void; } - export function createCommentWriter(host: EmitHost, writer: EmitTextWriter, sourceMap: SourceMapWriter): CommentWriter { - const compilerOptions = host.getCompilerOptions(); - const extendedDiagnostics = compilerOptions.extendedDiagnostics; - const newLine = host.getNewLine(); - const { emitPos } = sourceMap; - + export function createCommentWriter(printerOptions: PrinterOptions, emitPos: ((pos: number) => void) | undefined): CommentWriter { + const extendedDiagnostics = printerOptions.extendedDiagnostics; + const newLine = getNewLineCharacter(printerOptions); + let writer: EmitTextWriter; let containerPos = -1; let containerEnd = -1; let declarationListContainerEnd = -1; @@ -24,35 +24,33 @@ namespace ts { let currentLineMap: number[]; let detachedCommentsInfo: { nodePos: number, detachedCommentEndPos: number}[]; let hasWrittenComment = false; - let disabled: boolean = compilerOptions.removeComments; + let disabled: boolean = printerOptions.removeComments; return { reset, + setWriter, setSourceFile, emitNodeWithComments, emitBodyWithDetachedComments, emitTrailingCommentsOfPosition, + emitLeadingCommentsOfPosition, }; - function emitNodeWithComments(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) { + function emitNodeWithComments(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) { if (disabled) { - emitCallback(emitContext, node); + emitCallback(hint, node); return; } if (node) { - const { pos, end } = getCommentRange(node); - const emitFlags = getEmitFlags(node); + hasWrittenComment = false; + + const emitNode = node.emitNode; + const emitFlags = emitNode && emitNode.flags; + const { pos, end } = emitNode && emitNode.commentRange || node; if ((pos < 0 && end < 0) || (pos === end)) { // Both pos and end are synthesized, so just emit the node without comments. - if (emitFlags & EmitFlags.NoNestedComments) { - disabled = true; - emitCallback(emitContext, node); - disabled = false; - } - else { - emitCallback(emitContext, node); - } + emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); } else { if (extendedDiagnostics) { @@ -92,17 +90,10 @@ namespace ts { performance.measure("commentTime", "preEmitNodeWithComment"); } - if (emitFlags & EmitFlags.NoNestedComments) { - disabled = true; - emitCallback(emitContext, node); - disabled = false; - } - else { - emitCallback(emitContext, node); - } + emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); if (extendedDiagnostics) { - performance.mark("beginEmitNodeWithComment"); + performance.mark("postEmitNodeWithComment"); } // Restore previous container state. @@ -117,12 +108,88 @@ namespace ts { } if (extendedDiagnostics) { - performance.measure("commentTime", "beginEmitNodeWithComment"); + performance.measure("commentTime", "postEmitNodeWithComment"); } } } } + function emitNodeWithSynthesizedComments(hint: EmitHint, node: Node, emitNode: EmitNode, emitFlags: EmitFlags, emitCallback: (hint: EmitHint, node: Node) => void) { + const leadingComments = emitNode && emitNode.leadingComments; + if (some(leadingComments)) { + if (extendedDiagnostics) { + performance.mark("preEmitNodeWithSynthesizedComments"); + } + + forEach(leadingComments, emitLeadingSynthesizedComment); + + if (extendedDiagnostics) { + performance.measure("commentTime", "preEmitNodeWithSynthesizedComments"); + } + } + + emitNodeWithNestedComments(hint, node, emitFlags, emitCallback); + + const trailingComments = emitNode && emitNode.trailingComments; + if (some(trailingComments)) { + if (extendedDiagnostics) { + performance.mark("postEmitNodeWithSynthesizedComments"); + } + + forEach(trailingComments, emitTrailingSynthesizedComment); + + if (extendedDiagnostics) { + performance.measure("commentTime", "postEmitNodeWithSynthesizedComments"); + } + } + } + + function emitLeadingSynthesizedComment(comment: SynthesizedComment) { + if (comment.kind === SyntaxKind.SingleLineCommentTrivia) { + writer.writeLine(); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine || comment.kind === SyntaxKind.SingleLineCommentTrivia) { + writer.writeLine(); + } + else { + writer.write(" "); + } + } + + function emitTrailingSynthesizedComment(comment: SynthesizedComment) { + if (!writer.isAtStartOfLine()) { + writer.write(" "); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + } + + function writeSynthesizedComment(comment: SynthesizedComment) { + const text = formatSynthesizedComment(comment); + const lineMap = comment.kind === SyntaxKind.MultiLineCommentTrivia ? computeLineStarts(text) : undefined; + writeCommentRange(text, lineMap, writer, 0, text.length, newLine); + } + + function formatSynthesizedComment(comment: SynthesizedComment) { + return comment.kind === SyntaxKind.MultiLineCommentTrivia + ? `/*${comment.text}*/` + : `//${comment.text}`; + } + + function emitNodeWithNestedComments(hint: EmitHint, node: Node, emitFlags: EmitFlags, emitCallback: (hint: EmitHint, node: Node) => void) { + if (emitFlags & EmitFlags.NoNestedComments) { + disabled = true; + emitCallback(hint, node); + disabled = false; + } + else { + emitCallback(hint, node); + } + } + function emitBodyWithDetachedComments(node: Node, detachedRange: TextRange, emitCallback: (node: Node) => void) { if (extendedDiagnostics) { performance.mark("preEmitBodyWithDetachedComments"); @@ -198,9 +265,9 @@ namespace ts { } // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - emitPos(commentPos); + if (emitPos) emitPos(commentPos); writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); @@ -210,6 +277,14 @@ namespace ts { } } + function emitLeadingCommentsOfPosition(pos: number) { + if (disabled || pos === -1) { + return; + } + + emitLeadingComments(pos, /*isEmittedNode*/ true); + } + function emitTrailingComments(pos: number) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } @@ -220,9 +295,9 @@ namespace ts { writer.write(" "); } - emitPos(commentPos); + if (emitPos) emitPos(commentPos); writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); @@ -248,9 +323,9 @@ namespace ts { function emitTrailingCommentOfPosition(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean) { // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space - emitPos(commentPos); + if (emitPos) emitPos(commentPos); writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) emitPos(commentEnd); if (hasTrailingNewLine) { writer.writeLine(); @@ -286,6 +361,10 @@ namespace ts { detachedCommentsInfo = undefined; } + function setWriter(output: EmitTextWriter): void { + writer = output; + } + function setSourceFile(sourceFile: SourceFile) { currentSourceFile = sourceFile; currentText = currentSourceFile.text; @@ -323,9 +402,9 @@ namespace ts { } function writeComment(text: string, lineMap: number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) { - emitPos(commentPos); + if (emitPos) emitPos(commentPos); writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); - emitPos(commentEnd); + if (emitPos) emitPos(commentEnd); } /** diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 22e65a3299e..71c0f55c9af 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -3,7 +3,7 @@ namespace ts { /** The version of the TypeScript compiler release */ - export const version = "2.2.0"; + export const version = "2.3.0"; } /* @internal */ @@ -23,13 +23,14 @@ namespace ts { True = -1 } - const createObject = Object.create; - // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. - export const collator: { compare(a: string, b: string): number } = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; + export const collator: { compare(a: string, b: string): number } = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(/*locales*/ undefined, { usage: "sort", sensitivity: "accent" }) : undefined; + // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". + export const localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; - export function createMap(template?: MapLike): Map { - const map: Map = createObject(null); // tslint:disable-line:no-null-keyword + /** Create a MapLike with good performance. */ + function createDictionaryObject(): MapLike { + const map = Object.create(null); // tslint:disable-line:no-null-keyword // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is @@ -37,17 +38,113 @@ namespace ts { map["__"] = undefined; delete map["__"]; + return map; + } + + /** Create a new map. If a template object is provided, the map will copy entries from it. */ + export function createMap(): Map { + return new MapCtr(); + } + + export function createMapFromTemplate(template?: MapLike): Map { + const map: Map = new MapCtr(); + // Copies keys/values from template. Note that for..in will not throw if // template is undefined, and instead will just exit the loop. for (const key in template) if (hasOwnProperty.call(template, key)) { - map[key] = template[key]; + map.set(key, template[key]); } return map; } + // The global Map object. This may not be available, so we must test for it. + declare const Map: { new(): Map } | undefined; + // Internet Explorer's Map doesn't support iteration, so don't use it. + // tslint:disable-next-line:no-in-operator + const MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); + + // Keep the class inside a function so it doesn't get compiled if it's not used. + function shimMap(): { new(): Map } { + + class MapIterator { + private data: MapLike; + private keys: string[]; + private index = 0; + private selector: (data: MapLike, key: string) => U; + constructor(data: MapLike, selector: (data: MapLike, key: string) => U) { + this.data = data; + this.selector = selector; + this.keys = Object.keys(data); + } + + public next(): { value: U, done: false } | { value: never, done: true } { + const index = this.index; + if (index < this.keys.length) { + this.index++; + return { value: this.selector(this.data, this.keys[index]), done: false }; + } + return { value: undefined as never, done: true } + } + } + + return class implements Map { + private data = createDictionaryObject(); + public size = 0; + + get(key: string): T { + return this.data[key]; + } + + set(key: string, value: T): this { + if (!this.has(key)) { + this.size++; + } + this.data[key] = value; + return this; + } + + has(key: string): boolean { + // tslint:disable-next-line:no-in-operator + return key in this.data; + } + + delete(key: string): boolean { + if (this.has(key)) { + this.size--; + delete this.data[key]; + return true; + } + return false; + } + + clear(): void { + this.data = createDictionaryObject(); + this.size = 0; + } + + keys() { + return new MapIterator(this.data, (_data, key) => key); + } + + values() { + return new MapIterator(this.data, (data, key) => data[key]); + } + + entries() { + return new MapIterator(this.data, (data, key) => [key, data[key]] as [string, T]); + } + + forEach(action: (value: T, key: string) => void): void { + for (const key in this.data) { + action(this.data[key], key); + } + } + } + } + export function createFileMap(keyMapper?: (key: string) => string): FileMap { - let files = createMap(); + const files = createMap(); return { get, set, @@ -59,39 +156,34 @@ namespace ts { }; function forEachValueInMap(f: (key: Path, value: T) => void) { - for (const key in files) { - f(key, files[key]); - } + files.forEach((file, key) => { + f(key, file); + }); } function getKeys() { - const keys: Path[] = []; - for (const key in files) { - keys.push(key); - } - return keys; + return arrayFrom(files.keys()) as Path[]; } // path should already be well-formed so it does not need to be normalized function get(path: Path): T { - return files[toKey(path)]; + return files.get(toKey(path)); } function set(path: Path, value: T) { - files[toKey(path)] = value; + files.set(toKey(path), value); } function contains(path: Path) { - return toKey(path) in files; + return files.has(toKey(path)); } function remove(path: Path) { - const key = toKey(path); - delete files[key]; + files.delete(toKey(path)); } function clear() { - files = createMap(); + files.clear(); } function toKey(path: Path): string { @@ -112,6 +204,10 @@ namespace ts { GreaterThan = 1 } + export function length(array: any[]) { + return array ? array.length : 0; + } + /** * 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. @@ -164,6 +260,16 @@ namespace ts { return undefined; } + /** Works like Array.prototype.findIndex, returning `-1` if no element satisfying the predicate is found. */ + export function findIndex(array: T[], predicate: (element: T, index: number) => boolean): number { + for (let i = 0; i < array.length; i++) { + if (predicate(array[i], i)) { + return i; + } + } + return -1; + } + /** * Returns the first truthy result of `callback`, or else fails. * This is like `forEach`, but never returns undefined. @@ -420,17 +526,16 @@ namespace ts { return result; } - export function mapObject(object: MapLike, f: (key: string, x: T) => [string, U]): MapLike { - let result: MapLike; - if (object) { - result = {}; - for (const v of getOwnKeys(object)) { - const [key, value]: [string, U] = f(v, object[v]) || [undefined, undefined]; - if (key !== undefined) { - result[key] = value; - } - } + export function mapEntries(map: Map, f: (key: string, value: T) => [string, U]): Map { + if (!map) { + return undefined; } + + const result = createMap(); + map.forEach((value, key) => { + const [newKey, newValue] = f(key, value); + result.set(newKey, newValue); + }); return result; } @@ -748,9 +853,6 @@ namespace ts { /** * Indicates whether a map-like contains an own property with the specified key. * - * NOTE: This is intended for use only with MapLike objects. For Map objects, use - * the 'in' operator. - * * @param map A map-like. * @param key A property key. */ @@ -761,9 +863,6 @@ namespace ts { /** * Gets the value of an owned property in a map-like. * - * NOTE: This is intended for use only with MapLike objects. For Map objects, use - * an indexer. - * * @param map A map-like. * @param key A property key. */ @@ -787,50 +886,56 @@ namespace ts { return keys; } - /** - * Enumerates the properties of a Map, invoking a callback and returning the first truthy result. - * - * @param map A map for which properties should be enumerated. - * @param callback A callback to invoke for each property. - */ - export function forEachProperty(map: Map, callback: (value: T, key: string) => U): U { - let result: U; - for (const key in map) { - if (result = callback(map[key], key)) break; + /** Shims `Array.from`. */ + export function arrayFrom(iterator: Iterator): T[] { + const result: T[] = []; + for (let { value, done } = iterator.next(); !done; { value, done } = iterator.next()) { + result.push(value); + } + return result; + } + + export function convertToArray(iterator: Iterator, f: (value: T) => U) { + const result: U[] = []; + for (let { value, done } = iterator.next(); !done; { value, done } = iterator.next()) { + result.push(f(value)); } return result; } /** - * Returns true if a Map has some matching property. - * - * @param map A map whose properties should be tested. - * @param predicate An optional callback used to test each property. + * Calls `callback` for each entry in the map, returning the first truthy result. + * Use `map.forEach` instead for normal iteration. */ - export function someProperties(map: Map, predicate?: (value: T, key: string) => boolean) { - for (const key in map) { - if (!predicate || predicate(map[key], key)) return true; + export function forEachEntry(map: Map, callback: (value: T, key: string) => U | undefined): U | undefined { + const iterator = map.entries(); + for (let { value: pair, done } = iterator.next(); !done; { value: pair, done } = iterator.next()) { + const [key, value] = pair; + const result = callback(value, key); + if (result) { + return result; + } } - return false; + return undefined; } - /** - * Performs a shallow copy of the properties from a source Map to a target MapLike - * - * @param source A map from which properties should be copied. - * @param target A map to which properties should be copied. - */ - export function copyProperties(source: Map, target: MapLike): void { - for (const key in source) { - target[key] = source[key]; + /** `forEachEntry` for just keys. */ + export function forEachKey(map: Map<{}>, callback: (key: string) => T | undefined): T | undefined { + const iterator = map.keys(); + for (let { value: key, done } = iterator.next(); !done; { value: key, done } = iterator.next()) { + const result = callback(key); + if (result) { + return result; + } } + return undefined; } - export function appendProperty(map: Map, key: string | number, value: T): Map { - if (key === undefined || value === undefined) return map; - if (map === undefined) map = createMap(); - map[key] = value; - return map; + /** Copy entries from `source` to `target`. */ + export function copyEntries(source: Map, target: Map): void { + source.forEach((value, key) => { + target.set(key, value); + }); } export function assign, T2, T3>(t: T1, arg1: T2, arg2: T3): T1 & T2 & T3; @@ -845,24 +950,6 @@ namespace ts { return t; } - /** - * Reduce the properties of a map. - * - * NOTE: This is intended for use with Map objects. For MapLike objects, use - * reduceOwnProperties instead as it offers better runtime safety. - * - * @param map The map to reduce - * @param callback An aggregation function that is called for each entry in the map - * @param initial The initial value for the reduction. - */ - export function reduceProperties(map: Map, callback: (aggregate: U, value: T, key: string) => U, initial: U): U { - let result = initial; - for (const key in map) { - result = callback(result, map[key], String(key)); - } - return result; - } - /** * Performs a shallow equality comparison of the contents of two map-likes. * @@ -897,23 +984,14 @@ namespace ts { export function arrayToMap(array: T[], makeKey: (value: T) => string, makeValue?: (value: T) => U): Map { const result = createMap(); for (const value of array) { - result[makeKey(value)] = makeValue ? makeValue(value) : value; + result.set(makeKey(value), makeValue ? makeValue(value) : value); } return result; } - export function isEmpty(map: Map) { - for (const id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - export function cloneMap(map: Map) { const clone = createMap(); - copyProperties(map, clone); + copyEntries(map, clone); return clone; } @@ -938,32 +1016,43 @@ namespace ts { return result; } - /** - * Adds the value to an array of values associated with the key, and returns the array. - * Creates the array if it does not already exist. - */ - export function multiMapAdd(map: Map, key: string | number, value: V): V[] { - const values = map[key]; - if (values) { - values.push(value); - return values; - } - else { - return map[key] = [value]; - } + export interface MultiMap extends Map { + /** + * Adds the value to an array of values associated with the key, and returns the array. + * Creates the array if it does not already exist. + */ + add(key: string, value: T): T[]; + /** + * Removes a value from an array of values associated with the key. + * Does not preserve the order of those values. + * Does nothing if `key` is not in `map`, or `value` is not in `map[key]`. + */ + remove(key: string, value: T): void; } - /** - * Removes a value from an array of values associated with the key. - * Does not preserve the order of those values. - * Does nothing if `key` is not in `map`, or `value` is not in `map[key]`. - */ - export function multiMapRemove(map: Map, key: string, value: V): void { - const values = map[key]; + export function createMultiMap(): MultiMap { + const map = createMap() as MultiMap; + map.add = multiMapAdd; + map.remove = multiMapRemove; + return map; + } + function multiMapAdd(this: MultiMap, key: string, value: T) { + let values = this.get(key); + if (values) { + values.push(value); + } + else { + this.set(key, values = [value]); + } + return values; + + } + function multiMapRemove(this: MultiMap, key: string, value: T) { + const values = this.get(key); if (values) { unorderedRemoveItem(values, value); if (!values.length) { - delete map[key]; + this.delete(key); } } } @@ -1066,7 +1155,7 @@ namespace ts { return text.replace(/{(\d+)}/g, (_match, index?) => args[+index + baseIndex]); } - export let localizedDiagnosticMessages: Map = undefined; + export let localizedDiagnosticMessages: MapLike = undefined; export function getLocaleSpecificMessage(message: DiagnosticMessage) { return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message; @@ -1182,9 +1271,12 @@ namespace ts { if (a === undefined) return Comparison.LessThan; if (b === undefined) return Comparison.GreaterThan; if (ignoreCase) { - if (collator && String.prototype.localeCompare) { - // accent means a ≠ b, a ≠ á, a = A - const result = a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); + // Checking if "collator exists indicates that Intl is available. + // We still have to check if "collator.compare" is correct. If it is not, use "String.localeComapre" + if (collator) { + const result = localeCompareIsCorrect ? + collator.compare(a, b) : + a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); // accent means a ≠ b, a ≠ á, a = A return result < 0 ? Comparison.LessThan : result > 0 ? Comparison.GreaterThan : Comparison.EqualTo; } @@ -1363,7 +1455,7 @@ namespace ts { return /^\.\.?($|[\\/])/.test(moduleName); } - export function getEmitScriptTarget(compilerOptions: CompilerOptions) { + export function getEmitScriptTarget(compilerOptions: CompilerOptions | PrinterOptions) { return compilerOptions.target || ScriptTarget.ES3; } @@ -1650,7 +1742,19 @@ namespace ts { const singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; const singleAsteriskRegexFragmentOther = "[^/]*"; - export function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude") { + export function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude"): string | undefined { + const patterns = getRegularExpressionsForWildcards(specs, basePath, usage); + if (!patterns || !patterns.length) { + return undefined; + } + + const pattern = patterns.map(pattern => `(${pattern})`).join("|"); + // If excluding, match "foo/bar/baz...", but if including, only allow "foo". + const terminator = usage === "exclude" ? "($|/)" : "$"; + return `^(${pattern})${terminator}`; + } + + function getRegularExpressionsForWildcards(specs: string[], basePath: string, usage: "files" | "directories" | "exclude"): string[] | undefined { if (specs === undefined || specs.length === 0) { return undefined; } @@ -1664,33 +1768,8 @@ namespace ts { */ const doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; - let pattern = ""; - let hasWrittenSubpattern = false; - for (const spec of specs) { - if (!spec) { - continue; - } - - const subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); - if (subPattern === undefined) { - continue; - } - - if (hasWrittenSubpattern) { - pattern += "|"; - } - - pattern += "(" + subPattern + ")"; - hasWrittenSubpattern = true; - } - - if (!pattern) { - return undefined; - } - - // If excluding, match "foo/bar/baz...", but if including, only allow "foo". - const terminator = usage === "exclude" ? "($|/)" : "$"; - return `^(${pattern})${terminator}`; + return flatMap(specs, spec => + spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter)); } /** @@ -1785,6 +1864,9 @@ namespace ts { } export interface FileMatcherPatterns { + /** One pattern for each "include" spec. */ + includeFilePatterns: string[]; + /** One pattern matching one of any of the "include" specs. */ includeFilePattern: string; includeDirectoryPattern: string; excludePattern: string; @@ -1797,6 +1879,7 @@ namespace ts { const absolutePath = combinePaths(currentDirectory, path); return { + includeFilePatterns: map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), pattern => `^${pattern}$`), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -1811,26 +1894,39 @@ namespace ts { const patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); const regexFlag = useCaseSensitiveFileNames ? "" : "i"; - const includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); + const includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(pattern => new RegExp(pattern, regexFlag)); const includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); const excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); - const result: string[] = []; + // Associate an array of results with each include regex. This keeps results in order of the "include" order. + // If there are no "includes", then just put everything in results[0]. + const results: string[][] = includeFileRegexes ? includeFileRegexes.map(() => []) : [[]]; + + const comparer = useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive; for (const basePath of patterns.basePaths) { visitDirectory(basePath, combinePaths(currentDirectory, basePath)); } - return result; + + return flatten(results); function visitDirectory(path: string, absolutePath: string) { - const { files, directories } = getFileSystemEntries(path); + let { files, directories } = getFileSystemEntries(path); + files = files.slice().sort(comparer); + directories = directories.slice().sort(comparer); for (const current of files) { const name = combinePaths(path, current); const absoluteName = combinePaths(absolutePath, current); - if ((!extensions || fileExtensionIsAny(name, extensions)) && - (!includeFileRegex || includeFileRegex.test(absoluteName)) && - (!excludeRegex || !excludeRegex.test(absoluteName))) { - result.push(name); + if (extensions && !fileExtensionIsAny(name, extensions)) continue; + if (excludeRegex && excludeRegex.test(absoluteName)) continue; + if (!includeFileRegexes) { + results[0].push(name); + } + else { + const includeIndex = findIndex(includeFileRegexes, re => re.test(absoluteName)); + if (includeIndex !== -1) { + results[includeIndex].push(name); + } } } @@ -1924,14 +2020,14 @@ namespace ts { export const supportedJavascriptExtensions = [".js", ".jsx"]; const allSupportedExtensions = supportedTypeScriptExtensions.concat(supportedJavascriptExtensions); - export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: FileExtensionInfo[]): string[] { + export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: JsFileExtensionInfo[]): string[] { const needAllExtensions = options && options.allowJs; - if (!extraFileExtensions || extraFileExtensions.length === 0) { + if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : supportedTypeScriptExtensions; } - const extensions = (needAllExtensions ? allSupportedExtensions : supportedTypeScriptExtensions).slice(0); + const extensions = allSupportedExtensions.slice(0); for (const extInfo of extraFileExtensions) { - if (needAllExtensions || extInfo.scriptKind === ScriptKind.TS) { + if (extensions.indexOf(extInfo.extension) === -1) { extensions.push(extInfo.extension); } } @@ -1946,7 +2042,7 @@ namespace ts { return forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension)); } - export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: FileExtensionInfo[]) { + export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: JsFileExtensionInfo[]) { if (!fileName) { return false; } for (const extension of getSupportedExtensions(compilerOptions, extraFileExtensions)) { @@ -1965,7 +2061,6 @@ namespace ts { export const enum ExtensionPriority { TypeScriptFiles = 0, DeclarationAndJavaScriptFiles = 2, - Limit = 5, Highest = TypeScriptFiles, Lowest = DeclarationAndJavaScriptFiles, @@ -1974,7 +2069,7 @@ namespace ts { export function getExtensionPriority(path: string, supportedExtensions: string[]): ExtensionPriority { for (let i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { - return adjustExtensionPriority(i); + return adjustExtensionPriority(i, supportedExtensions); } } @@ -1986,27 +2081,26 @@ namespace ts { /** * Adjusts an extension priority to be the highest priority within the same range. */ - export function adjustExtensionPriority(extensionPriority: ExtensionPriority): ExtensionPriority { + export function adjustExtensionPriority(extensionPriority: ExtensionPriority, supportedExtensions: string[]): ExtensionPriority { if (extensionPriority < ExtensionPriority.DeclarationAndJavaScriptFiles) { return ExtensionPriority.TypeScriptFiles; } - else if (extensionPriority < ExtensionPriority.Limit) { + else if (extensionPriority < supportedExtensions.length) { return ExtensionPriority.DeclarationAndJavaScriptFiles; } else { - return ExtensionPriority.Limit; - } - } + return supportedExtensions.length; + } } /** * Gets the next lowest extension priority for a given priority. */ - export function getNextLowestExtensionPriority(extensionPriority: ExtensionPriority): ExtensionPriority { + export function getNextLowestExtensionPriority(extensionPriority: ExtensionPriority, supportedExtensions: string[]): ExtensionPriority { if (extensionPriority < ExtensionPriority.DeclarationAndJavaScriptFiles) { return ExtensionPriority.DeclarationAndJavaScriptFiles; } else { - return ExtensionPriority.Limit; + return supportedExtensions.length; } } diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index cd98622e080..12411cabd56 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -32,16 +32,18 @@ namespace ts { export function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[] { const declarationDiagnostics = createDiagnosticCollection(); - forEachExpectedEmitFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); + forEachEmittedFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile); return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined); - function getDeclarationDiagnosticsFromFile({ declarationFilePath }: EmitFileNames, sources: SourceFile[], isBundledEmit: boolean) { - emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit, /*emitOnlyDtsFiles*/ false); + function getDeclarationDiagnosticsFromFile({ declarationFilePath }: EmitFileNames, sourceFileOrBundle: SourceFile | Bundle) { + emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sourceFileOrBundle, /*emitOnlyDtsFiles*/ false); } } function emitDeclarations(host: EmitHost, resolver: EmitResolver, emitterDiagnostics: DiagnosticCollection, declarationFilePath: string, - sourceFiles: SourceFile[], isBundledEmit: boolean, emitOnlyDtsFiles: boolean): DeclarationEmit { + sourceFileOrBundle: SourceFile | Bundle, emitOnlyDtsFiles: boolean): DeclarationEmit { + const sourceFiles = sourceFileOrBundle.kind === SyntaxKind.Bundle ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + const isBundledEmit = sourceFileOrBundle.kind === SyntaxKind.Bundle; const newLine = host.getNewLine(); const compilerOptions = host.getCompilerOptions(); @@ -156,9 +158,9 @@ namespace ts { }); if (usedTypeDirectiveReferences) { - for (const directive in usedTypeDirectiveReferences) { + forEachKey(usedTypeDirectiveReferences, directive => { referencesOutput += `/// ${newLine}`; - } + }); } return { @@ -188,6 +190,7 @@ namespace ts { const writer = createTextWriter(newLine); writer.trackSymbol = trackSymbol; writer.reportInaccessibleThisError = reportInaccessibleThisError; + writer.reportIllegalExtends = reportIllegalExtends; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -271,8 +274,8 @@ namespace ts { usedTypeDirectiveReferences = createMap(); } for (const directive of typeReferenceDirectives) { - if (!(directive in usedTypeDirectiveReferences)) { - usedTypeDirectiveReferences[directive] = directive; + if (!usedTypeDirectiveReferences.has(directive)) { + usedTypeDirectiveReferences.set(directive, directive); } } } @@ -311,6 +314,14 @@ namespace ts { recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); } + function reportIllegalExtends() { + if (errorNameNode) { + reportedDeclarationError = true; + emitterDiagnostics.add(createDiagnosticForNode(errorNameNode, Diagnostics.extends_clause_of_exported_class_0_refers_to_a_type_whose_name_cannot_be_referenced, + declarationNameToString(errorNameNode))); + } + } + function reportInaccessibleThisError() { if (errorNameNode) { reportedDeclarationError = true; @@ -322,13 +333,20 @@ namespace ts { function writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, type: TypeNode, getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); - if (type) { + + // use the checker's type, not the declared type, + // for non-optional initialized parameters that aren't a parameter property + const shouldUseResolverType = declaration.kind === SyntaxKind.Parameter && + resolver.isRequiredInitializedParameter(declaration as ParameterDeclaration); + if (type && !shouldUseResolverType) { // Write the type emitType(type); } else { errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer); + const format = TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue | + (shouldUseResolverType ? TypeFormatFlags.AddUndefined : 0); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer); errorNameNode = undefined; } } @@ -390,6 +408,7 @@ namespace ts { case SyntaxKind.StringKeyword: case SyntaxKind.NumberKeyword: case SyntaxKind.BooleanKeyword: + case SyntaxKind.ObjectKeyword: case SyntaxKind.SymbolKeyword: case SyntaxKind.VoidKeyword: case SyntaxKind.UndefinedKeyword: @@ -581,14 +600,14 @@ namespace ts { // do not need to keep track of created temp names. function getExportDefaultTempVariableName(): string { const baseName = "_default"; - if (!(baseName in currentIdentifiers)) { + if (!currentIdentifiers.has(baseName)) { return baseName; } let count = 0; while (true) { count++; const name = baseName + "_" + count; - if (!(name in currentIdentifiers)) { + if (!currentIdentifiers.has(name)) { return name; } } @@ -1000,6 +1019,23 @@ namespace ts { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } + if (node.default && !isPrivateMethodTypeParameter(node)) { + write(" = "); + if (node.parent.kind === SyntaxKind.FunctionType || + node.parent.kind === SyntaxKind.ConstructorType || + (node.parent.parent && node.parent.parent.kind === SyntaxKind.TypeLiteral)) { + Debug.assert(node.parent.kind === SyntaxKind.MethodDeclaration || + node.parent.kind === SyntaxKind.MethodSignature || + node.parent.kind === SyntaxKind.FunctionType || + node.parent.kind === SyntaxKind.ConstructorType || + node.parent.kind === SyntaxKind.CallSignature || + node.parent.kind === SyntaxKind.ConstructSignature); + emitType(node.default); + } + else { + emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.default, getTypeParameterConstraintVisibilityError); + } + } function getTypeParameterConstraintVisibilityError(): SymbolAccessibilityDiagnostic { // Type parameter constraints are named by user so we should always be able to name it @@ -1061,7 +1097,7 @@ namespace ts { } } - function emitHeritageClause(typeReferences: ExpressionWithTypeArguments[], isImplementsList: boolean) { + function emitHeritageClause(className: Identifier, typeReferences: ExpressionWithTypeArguments[], isImplementsList: boolean) { if (typeReferences) { write(isImplementsList ? " implements " : " extends "); emitCommaList(typeReferences, emitTypeOfTypeReference); @@ -1076,7 +1112,9 @@ namespace ts { } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; + errorNameNode = className; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer); + errorNameNode = undefined; } function getHeritageClauseVisibilityError(): SymbolAccessibilityDiagnostic { @@ -1086,11 +1124,11 @@ namespace ts { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : - Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; + Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } else { // interface is inaccessible - diagnosticMessage = Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; + diagnosticMessage = Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; } return { @@ -1126,9 +1164,10 @@ namespace ts { emitTypeParameters(node.typeParameters); const baseTypeNode = getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); + node.name + emitHeritageClause(node.name, [baseTypeNode], /*isImplementsList*/ false); } - emitHeritageClause(getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); + emitHeritageClause(node.name, getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); write(" {"); writeLine(); increaseIndent(); @@ -1150,7 +1189,7 @@ namespace ts { emitTypeParameters(node.typeParameters); const interfaceExtendsTypes = filter(getInterfaceBaseTypeNodes(node), base => isEntityNameExpression(base.expression)); if (interfaceExtendsTypes && interfaceExtendsTypes.length) { - emitHeritageClause(interfaceExtendsTypes, /*isImplementsList*/ false); + emitHeritageClause(node.name, interfaceExtendsTypes, /*isImplementsList*/ false); } write(" {"); writeLine(); @@ -1787,7 +1826,7 @@ namespace ts { } else { // Get the declaration file path - forEachExpectedEmitFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); + forEachEmittedFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); } if (declFileName) { @@ -1802,8 +1841,9 @@ namespace ts { } return addedBundledEmitReference; - function getDeclFileName(emitFileNames: EmitFileNames, _sourceFiles: SourceFile[], isBundledEmit: boolean) { + function getDeclFileName(emitFileNames: EmitFileNames, sourceFileOrBundle: SourceFile | Bundle) { // Dont add reference path to this file if it is a bundled emit and caller asked not emit bundled file path + const isBundledEmit = sourceFileOrBundle.kind === SyntaxKind.Bundle; if (isBundledEmit && !addBundledFileReference) { return; } @@ -1816,10 +1856,11 @@ namespace ts { } /* @internal */ - export function writeDeclarationFile(declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean, host: EmitHost, resolver: EmitResolver, emitterDiagnostics: DiagnosticCollection, emitOnlyDtsFiles: boolean) { - const emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles); + export function writeDeclarationFile(declarationFilePath: string, sourceFileOrBundle: SourceFile | Bundle, host: EmitHost, resolver: EmitResolver, emitterDiagnostics: DiagnosticCollection, emitOnlyDtsFiles: boolean) { + const emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles); const emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { + const sourceFiles = sourceFileOrBundle.kind === SyntaxKind.Bundle ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; const declarationOutput = emitDeclarationResult.referencesOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM, sourceFiles); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index ec5ca292b99..6d45b53f7fe 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -175,15 +175,15 @@ "category": "Error", "code": 1057 }, - "Operand for 'await' does not have a valid callable 'then' member.": { + "Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member.": { "category": "Error", "code": 1058 }, - "Return expression in async function does not have a valid callable 'then' member.": { + "A promise must have a 'then' method.": { "category": "Error", "code": 1059 }, - "Expression body for async arrow function does not have a valid callable 'then' member.": { + "The first parameter of the 'then' method of a promise must be a callback.": { "category": "Error", "code": 1060 }, @@ -191,7 +191,7 @@ "category": "Error", "code": 1061 }, - "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method.": { + "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method.": { "category": "Error", "code": 1062 }, @@ -291,6 +291,10 @@ "category": "Error", "code": 1102 }, + "A 'for-await-of' statement is only allowed within an async function or async generator.": { + "category": "Error", + "code": 1103 + }, "A 'continue' statement can only be used within an enclosing iteration statement.": { "category": "Error", "code": 1104 @@ -671,6 +675,10 @@ "category": "Error", "code": 1215 }, + "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules.": { + "category": "Error", + "code": 1216 + }, "Export assignment is not supported when '--module' flag is 'system'.": { "category": "Error", "code": 1218 @@ -1627,6 +1635,10 @@ "category": "Error", "code": 2503 }, + "Type must have a '[Symbol.asyncIterator]()' method that returns an async iterator.": { + "category": "Error", + "code": 2504 + }, "A generator cannot have a 'void' type annotation.": { "category": "Error", "code": 2505 @@ -1683,6 +1695,10 @@ "category": "Error", "code": 2518 }, + "An async iterator must have a 'next()' method.": { + "category": "Error", + "code": 2519 + }, "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions.": { "category": "Error", "code": 2520 @@ -1783,6 +1799,26 @@ "category": "Error", "code": 2544 }, + "A mixin class must have a constructor with a single rest parameter of type 'any[]'.": { + "category": "Error", + "code": 2545 + }, + "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'.": { + "category": "Error", + "code": 2546 + }, + "The type returned by the 'next()' method of an async iterator must be a promise for a type with a 'value' property.": { + "category": "Error", + "code": 2547 + }, + "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator.": { + "category": "Error", + "code": 2548 + }, + "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator.": { + "category": "Error", + "code": 2549 + }, "JSX element attributes type '{0}' may not be a union type.": { "category": "Error", "code": 2600 @@ -1823,6 +1859,10 @@ "category": "Error", "code": 2609 }, + "Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": { + "category": "Error", + "code": 2649 + }, "Cannot emit namespaced JSX elements in React": { "category": "Error", "code": 2650 @@ -2015,6 +2055,10 @@ "category": "Error", "code": 2698 }, + "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'.": { + "category": "Error", + "code": 2699 + }, "Rest types may only be created from object types.": { "category": "Error", "code": 2700 @@ -2035,6 +2079,18 @@ "category": "Error", "code": 2704 }, + "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.": { + "category": "Error", + "code": 2705 + }, + "Required type parameters may not follow optional type parameters.": { + "category": "Error", + "code": 2706 + }, + "Generic type '{0}' requires between {1} and {2} type arguments.": { + "category": "Error", + "code": 2707 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", @@ -2076,11 +2132,11 @@ "category": "Error", "code": 4019 }, - "Extends 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}'.": { "category": "Error", "code": 4020 }, - "Extends clause of exported interface '{0}' has or is using private name '{1}'.": { + "'extends' clause of exported interface '{0}' has or is using private name '{1}'.": { "category": "Error", "code": 4022 }, @@ -2332,6 +2388,10 @@ "category": "Error", "code": 4092 }, + "'extends' clause of exported class '{0}' refers to a type whose name cannot be referenced.": { + "category": "Error", + "code": 4093 + }, "The current host does not support the '{0}' option.": { "category": "Error", @@ -2513,7 +2573,7 @@ "category": "Message", "code": 6019 }, - "Compile the project in the given directory.": { + "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'": { "category": "Message", "code": 6020 }, @@ -2573,6 +2633,10 @@ "category": "Message", "code": 6039 }, + "FILE OR DIRECTORY": { + "category": "Message", + "code": 6040 + }, "Compilation complete. Watching for file changes.": { "category": "Message", "code": 6042 @@ -2705,7 +2769,7 @@ "category": "Message", "code": 6079 }, - "Specify JSX code generation: 'preserve' or 'react'": { + "Specify JSX code generation: 'preserve', 'react-native', or 'react'": { "category": "Message", "code": 6080 }, @@ -2785,7 +2849,7 @@ "category": "Message", "code": 6099 }, - "'package.json' does not have a 'types' or 'main' field.": { + "'package.json' does not have a '{0}' field.": { "category": "Message", "code": 6100 }, @@ -2933,10 +2997,6 @@ "category": "Message", "code": 6136 }, - "No types specified in 'package.json', so returning 'main' value of '{0}'": { - "category": "Message", - "code": 6137 - }, "Property '{0}' is declared but never used.": { "category": "Error", "code": 6138 @@ -2981,6 +3041,10 @@ "category": "Message", "code": 6148 }, + "Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3.": { + "category": "Message", + "code": 6149 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 @@ -3145,7 +3209,7 @@ "category": "Error", "code": 8016 }, - "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.": { + "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause.": { "category": "Error", "code": 9002 }, @@ -3243,7 +3307,7 @@ "category": "Message", "code": 90003 }, - "Remove unused identifiers.": { + "Remove declaration for: {0}": { "category": "Message", "code": 90004 }, @@ -3255,6 +3319,10 @@ "category": "Message", "code": 90007 }, + "Add 'this.' to unresolved variable.": { + "category": "Message", + "code": 90008 + }, "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig": { "category": "Error", "code": 90009 @@ -3275,6 +3343,14 @@ "category": "Message", "code": 90015 }, + "Add declaration for missing property '{0}'": { + "category": "Message", + "code": 90016 + }, + "Add index signature for missing property '{0}'": { + "category": "Message", + "code": 90017 + }, "Octal literal types must use ES2015 syntax. Use the syntax '{0}'.": { "category": "Error", "code": 8017 diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 69bd4a8b6e1..06472db58b2 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1,61 +1,26 @@ -/// +/// /// -/// -/// +/// +/// /// -/* @internal */ namespace ts { - // Flags enum to track count of temp variables and a few dedicated names - const enum TempFlags { - Auto = 0x00000000, // No preferred name - CountMask = 0x0FFFFFFF, // Temp variable counter - _i = 0x10000000, // Use/preference flag for '_i' - } - - const id = (s: SourceFile) => s; - const nullTransformers: Transformer[] = [_ => id]; + const delimiters = createDelimiterMap(); + const brackets = createBracketsMap(); + /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile, emitOnlyDtsFiles?: boolean): EmitResult { - const delimiters = createDelimiterMap(); - const brackets = createBracketsMap(); + export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile, emitOnlyDtsFiles?: boolean, transformers?: TransformerFactory[]): EmitResult { const compilerOptions = host.getCompilerOptions(); - const languageVersion = getEmitScriptTarget(compilerOptions); const moduleKind = getEmitModuleKind(compilerOptions); const sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; const emittedFilesList: string[] = compilerOptions.listEmittedFiles ? [] : undefined; const emitterDiagnostics = createDiagnosticCollection(); const newLine = host.getNewLine(); - const transformers: Transformer[] = emitOnlyDtsFiles ? nullTransformers : getTransformers(compilerOptions); const writer = createTextWriter(newLine); - const { - write, - writeLine, - increaseIndent, - decreaseIndent - } = writer; - const sourceMap = createSourceMapWriter(host, writer); - const { - emitNodeWithSourceMap, - emitTokenWithSourceMap - } = sourceMap; - const comments = createCommentWriter(host, writer, sourceMap); - const { - emitNodeWithComments, - emitBodyWithDetachedComments, - emitTrailingCommentsOfPosition - } = comments; - - let nodeIdToGeneratedName: string[]; - let autoGeneratedIdToGeneratedName: string[]; - let generatedNameSet: Map; - let tempFlags: TempFlags; let currentSourceFile: SourceFile; - let currentText: string; - let currentFileIdentifiers: Map; let bundledHelpers: Map; let isOwnFileEmit: boolean; let emitSkipped = false; @@ -63,23 +28,34 @@ namespace ts { const sourceFiles = getSourceFilesToEmit(host, targetSourceFile); // Transform the source files - performance.mark("beforeTransform"); - const { - transformed, - emitNodeWithSubstitution, - emitNodeWithNotification - } = transformFiles(resolver, host, sourceFiles, transformers); - performance.measure("transformTime", "beforeTransform"); + const transform = transformNodes(resolver, host, compilerOptions, sourceFiles, transformers, /*allowDtsFiles*/ false); + + // Create a printer to print the nodes + const printer = createPrinter(compilerOptions, { + // resolver hooks + hasGlobalName: resolver.hasGlobalName, + + // transform hooks + onEmitNode: transform.emitNodeWithNotification, + substituteNode: transform.substituteNode, + + // sourcemap hooks + onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, + onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, + onEmitSourceMapOfPosition: sourceMap.emitPos, + + // emitter hooks + onEmitHelpers: emitHelpers, + onSetSourceFile: setSourceFile, + }); // Emit each output file performance.mark("beforePrint"); - forEachTransformedEmitFile(host, transformed, emitFile, emitOnlyDtsFiles); + forEachEmittedFile(host, emitSourceFileOrBundle, transform.transformed, emitOnlyDtsFiles); performance.measure("printTime", "beforePrint"); // Clean up emit nodes on parse tree - for (const sourceFile of sourceFiles) { - disposeEmitNodes(sourceFile); - } + transform.dispose(); return { emitSkipped, @@ -88,11 +64,11 @@ namespace ts { sourceMaps: sourceMapDataList }; - function emitFile(jsFilePath: string, sourceMapFilePath: string, declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) { + function emitSourceFileOrBundle({ jsFilePath, sourceMapFilePath, declarationFilePath }: EmitFileNames, sourceFileOrBundle: SourceFile | Bundle) { // Make sure not to write js file and source map file if any of them cannot be written if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { if (!emitOnlyDtsFiles) { - printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle); } } else { @@ -100,7 +76,7 @@ namespace ts { } if (declarationFilePath) { - emitSkipped = writeDeclarationFile(declarationFilePath, getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; + emitSkipped = writeDeclarationFile(declarationFilePath, getOriginalSourceFileOrBundle(sourceFileOrBundle), host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; } if (!emitSkipped && emittedFilesList) { @@ -116,34 +92,32 @@ namespace ts { } } - function printFile(jsFilePath: string, sourceMapFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) { - sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); - nodeIdToGeneratedName = []; - autoGeneratedIdToGeneratedName = []; - generatedNameSet = createMap(); - bundledHelpers = isBundledEmit ? createMap() : undefined; - isOwnFileEmit = !isBundledEmit; + function printSourceFileOrBundle(jsFilePath: string, sourceMapFilePath: string, sourceFileOrBundle: SourceFile | Bundle) { + const bundle = sourceFileOrBundle.kind === SyntaxKind.Bundle ? sourceFileOrBundle : undefined; + const sourceFile = sourceFileOrBundle.kind === SyntaxKind.SourceFile ? sourceFileOrBundle : undefined; + const sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; + sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFileOrBundle); - // Emit helpers from all the files - if (isBundledEmit && moduleKind) { - for (const sourceFile of sourceFiles) { - emitHelpers(sourceFile, /*isBundle*/ true); - } + if (bundle) { + bundledHelpers = createMap(); + isOwnFileEmit = false; + printer.writeBundle(bundle, writer); + } + else { + isOwnFileEmit = true; + printer.writeFile(sourceFile, writer); } - // Print each transformed source file. - forEach(sourceFiles, printSourceFile); - - writeLine(); + writer.writeLine(); const sourceMappingURL = sourceMap.getSourceMappingURL(); if (sourceMappingURL) { - write(`//# ${"sourceMappingURL"}=${sourceMappingURL}`); // Sometimes tools can sometimes see this line as a source mapping url comment + writer.write(`//# ${"sourceMappingURL"}=${sourceMappingURL}`); // Sometimes tools can sometimes see this line as a source mapping url comment } // Write the source map if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) { - writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), /*writeByteOrderMark*/ false, sourceFiles); + writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), /*writeByteOrderMark*/ false, sourceFiles); } // Record source map data for the test harness. @@ -156,153 +130,274 @@ namespace ts { // Reset state sourceMap.reset(); - comments.reset(); writer.reset(); - tempFlags = TempFlags.Auto; currentSourceFile = undefined; - currentText = undefined; + bundledHelpers = undefined; isOwnFileEmit = false; } - function printSourceFile(node: SourceFile) { + function setSourceFile(node: SourceFile) { currentSourceFile = node; - currentText = node.text; - currentFileIdentifiers = node.identifiers; sourceMap.setSourceFile(node); - comments.setSourceFile(node); - pipelineEmitWithNotification(EmitContext.SourceFile, node); } - /** - * Emits a node. - */ + function emitHelpers(node: Node, writeLines: (text: string) => void) { + let helpersEmitted = false; + const bundle = node.kind === SyntaxKind.Bundle ? node : undefined; + if (bundle && moduleKind === ModuleKind.None) { + return; + } + + const numNodes = bundle ? bundle.sourceFiles.length : 1; + for (let i = 0; i < numNodes; i++) { + const currentNode = bundle ? bundle.sourceFiles[i] : node; + const sourceFile = isSourceFile(currentNode) ? currentNode : currentSourceFile; + const shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && getExternalHelpersModuleName(sourceFile) !== undefined); + const shouldBundle = isSourceFile(currentNode) && !isOwnFileEmit; + const helpers = getEmitHelpers(currentNode); + if (helpers) { + for (const helper of stableSort(helpers, compareEmitHelpers)) { + if (!helper.scoped) { + // Skip the helper if it can be skipped and the noEmitHelpers compiler + // option is set, or if it can be imported and the importHelpers compiler + // option is set. + if (shouldSkip) continue; + + // Skip the helper if it can be bundled but hasn't already been emitted and we + // are emitting a bundled module. + if (shouldBundle) { + if (bundledHelpers.get(helper.name)) { + continue; + } + + bundledHelpers.set(helper.name, true); + } + } + else if (bundle) { + // Skip the helper if it is scoped and we are emitting bundled helpers + continue; + } + + writeLines(helper.text); + helpersEmitted = true; + } + } + } + + return helpersEmitted; + } + } + + export function createPrinter(printerOptions: PrinterOptions = {}, handlers: PrintHandlers = {}): Printer { + const { + hasGlobalName, + onEmitSourceMapOfNode, + onEmitSourceMapOfToken, + onEmitSourceMapOfPosition, + onEmitNode, + onEmitHelpers, + onSetSourceFile, + substituteNode, + } = handlers; + + const newLine = getNewLineCharacter(printerOptions); + const languageVersion = getEmitScriptTarget(printerOptions); + const comments = createCommentWriter(printerOptions, onEmitSourceMapOfPosition); + const { + emitNodeWithComments, + emitBodyWithDetachedComments, + emitTrailingCommentsOfPosition, + emitLeadingCommentsOfPosition, + } = comments; + + let currentSourceFile: SourceFile; + let nodeIdToGeneratedName: string[]; // Map of generated names for specific nodes. + let autoGeneratedIdToGeneratedName: string[]; // Map of generated names for temp and loop variables. + let generatedNames: Map; // Set of names generated by the NameGenerator. + let tempFlagsStack: TempFlags[]; // Stack of enclosing name generation scopes. + let tempFlags: TempFlags; // TempFlags for the current name generation scope. + let writer: EmitTextWriter; + let ownWriter: EmitTextWriter; + + reset(); + return { + // public API + printNode, + printFile, + printBundle, + + // internal API + writeNode, + writeFile, + writeBundle + }; + + function printNode(hint: EmitHint, node: Node, sourceFile: SourceFile): string { + switch (hint) { + case EmitHint.SourceFile: + Debug.assert(isSourceFile(node), "Expected a SourceFile node."); + break; + case EmitHint.IdentifierName: + Debug.assert(isIdentifier(node), "Expected an Identifier node."); + break; + case EmitHint.Expression: + Debug.assert(isExpression(node), "Expected an Expression node."); + break; + } + switch (node.kind) { + case SyntaxKind.SourceFile: return printFile(node); + case SyntaxKind.Bundle: return printBundle(node); + } + writeNode(hint, node, sourceFile, beginPrint()); + return endPrint(); + } + + function printBundle(bundle: Bundle): string { + writeBundle(bundle, beginPrint()); + return endPrint(); + } + + function printFile(sourceFile: SourceFile): string { + writeFile(sourceFile, beginPrint()); + return endPrint(); + } + + function writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile, output: EmitTextWriter) { + const previousWriter = writer; + setWriter(output); + print(hint, node, sourceFile); + reset(); + writer = previousWriter; + } + + function writeBundle(bundle: Bundle, output: EmitTextWriter) { + const previousWriter = writer; + setWriter(output); + emitHelpersIndirect(bundle); + for (const sourceFile of bundle.sourceFiles) { + print(EmitHint.SourceFile, sourceFile, sourceFile); + } + reset(); + writer = previousWriter; + } + + function writeFile(sourceFile: SourceFile, output: EmitTextWriter) { + const previousWriter = writer; + setWriter(output); + print(EmitHint.SourceFile, sourceFile, sourceFile); + reset(); + writer = previousWriter; + } + + function beginPrint() { + return ownWriter || (ownWriter = createTextWriter(newLine)); + } + + function endPrint() { + const text = ownWriter.getText(); + ownWriter.reset(); + return text; + } + + function print(hint: EmitHint, node: Node, sourceFile: SourceFile) { + setSourceFile(sourceFile); + pipelineEmitWithNotification(hint, node); + } + + function setSourceFile(sourceFile: SourceFile) { + currentSourceFile = sourceFile; + comments.setSourceFile(sourceFile); + if (onSetSourceFile) { + onSetSourceFile(sourceFile); + } + } + + function setWriter(output: EmitTextWriter | undefined) { + writer = output; + comments.setWriter(output); + } + + function reset() { + nodeIdToGeneratedName = []; + autoGeneratedIdToGeneratedName = []; + generatedNames = createMap(); + tempFlagsStack = []; + tempFlags = TempFlags.Auto; + comments.reset(); + setWriter(/*output*/ undefined); + } + function emit(node: Node) { - pipelineEmitWithNotification(EmitContext.Unspecified, node); + pipelineEmitWithNotification(EmitHint.Unspecified, node); } - /** - * Emits an IdentifierName. - */ function emitIdentifierName(node: Identifier) { - pipelineEmitWithNotification(EmitContext.IdentifierName, node); + pipelineEmitWithNotification(EmitHint.IdentifierName, node); } - /** - * Emits an expression node. - */ function emitExpression(node: Expression) { - pipelineEmitWithNotification(EmitContext.Expression, node); + pipelineEmitWithNotification(EmitHint.Expression, node); } - /** - * Emits a node with possible notification. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called from printSourceFile, emit, emitExpression, or - * emitIdentifierName. - */ - function pipelineEmitWithNotification(emitContext: EmitContext, node: Node) { - emitNodeWithNotification(emitContext, node, pipelineEmitWithComments); + function pipelineEmitWithNotification(hint: EmitHint, node: Node) { + if (onEmitNode) { + onEmitNode(hint, node, pipelineEmitWithComments); + } + else { + pipelineEmitWithComments(hint, node); + } } - /** - * Emits a node with comments. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithNotification. - */ - function pipelineEmitWithComments(emitContext: EmitContext, node: Node) { - // Do not emit comments for SourceFile - if (emitContext === EmitContext.SourceFile) { - pipelineEmitWithSourceMap(emitContext, node); + function pipelineEmitWithComments(hint: EmitHint, node: Node) { + node = trySubstituteNode(hint, node); + if (emitNodeWithComments && hint !== EmitHint.SourceFile) { + emitNodeWithComments(hint, node, pipelineEmitWithSourceMap); + } + else { + pipelineEmitWithSourceMap(hint, node); + } + } + + function pipelineEmitWithSourceMap(hint: EmitHint, node: Node) { + if (onEmitSourceMapOfNode && hint !== EmitHint.SourceFile && hint !== EmitHint.IdentifierName) { + onEmitSourceMapOfNode(hint, node, pipelineEmitWithHint); + } + else { + pipelineEmitWithHint(hint, node); + } + } + + function pipelineEmitWithHint(hint: EmitHint, node: Node): void { + switch (hint) { + case EmitHint.SourceFile: return pipelineEmitSourceFile(node); + case EmitHint.IdentifierName: return pipelineEmitIdentifierName(node); + case EmitHint.Expression: return pipelineEmitExpression(node); + case EmitHint.Unspecified: return pipelineEmitUnspecified(node); + } + } + + function pipelineEmitSourceFile(node: Node): void { + Debug.assertNode(node, isSourceFile); + emitSourceFile(node); + } + + function pipelineEmitIdentifierName(node: Node): void { + Debug.assertNode(node, isIdentifier); + emitIdentifier(node); + } + + function pipelineEmitUnspecified(node: Node): void { + const kind = node.kind; + + // Reserved words + // Strict mode reserved words + // Contextual keywords + if (isKeyword(kind)) { + writeTokenText(kind); return; } - emitNodeWithComments(emitContext, node, pipelineEmitWithSourceMap); - } - - /** - * Emits a node with source maps. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithComments. - */ - function pipelineEmitWithSourceMap(emitContext: EmitContext, node: Node) { - // Do not emit source mappings for SourceFile or IdentifierName - if (emitContext === EmitContext.SourceFile - || emitContext === EmitContext.IdentifierName) { - pipelineEmitWithSubstitution(emitContext, node); - return; - } - - emitNodeWithSourceMap(emitContext, node, pipelineEmitWithSubstitution); - } - - /** - * Emits a node with possible substitution. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithSourceMap or - * pipelineEmitInUnspecifiedContext (when picking a more specific context). - */ - function pipelineEmitWithSubstitution(emitContext: EmitContext, node: Node) { - emitNodeWithSubstitution(emitContext, node, pipelineEmitForContext); - } - - /** - * Emits a node. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitWithSubstitution. - */ - function pipelineEmitForContext(emitContext: EmitContext, node: Node): void { - switch (emitContext) { - case EmitContext.SourceFile: return pipelineEmitInSourceFileContext(node); - case EmitContext.IdentifierName: return pipelineEmitInIdentifierNameContext(node); - case EmitContext.Unspecified: return pipelineEmitInUnspecifiedContext(node); - case EmitContext.Expression: return pipelineEmitInExpressionContext(node); - } - } - - /** - * Emits a node in the SourceFile EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInSourceFileContext(node: Node): void { - const kind = node.kind; - switch (kind) { - // Top-level nodes - case SyntaxKind.SourceFile: - return emitSourceFile(node); - } - } - - /** - * Emits a node in the IdentifierName EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInIdentifierNameContext(node: Node): void { - const kind = node.kind; - switch (kind) { - // Identifiers - case SyntaxKind.Identifier: - return emitIdentifier(node); - } - } - - /** - * Emits a node in the Unspecified EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInUnspecifiedContext(node: Node): void { - const kind = node.kind; switch (kind) { // Pseudo-literals case SyntaxKind.TemplateHead: @@ -314,46 +409,6 @@ namespace ts { case SyntaxKind.Identifier: return emitIdentifier(node); - // Reserved words - case SyntaxKind.ConstKeyword: - case SyntaxKind.DefaultKeyword: - case SyntaxKind.ExportKeyword: - case SyntaxKind.VoidKeyword: - - // Strict mode reserved words - case SyntaxKind.PrivateKeyword: - case SyntaxKind.ProtectedKeyword: - case SyntaxKind.PublicKeyword: - case SyntaxKind.StaticKeyword: - - // Contextual keywords - case SyntaxKind.AbstractKeyword: - case SyntaxKind.AsKeyword: - case SyntaxKind.AnyKeyword: - case SyntaxKind.AsyncKeyword: - case SyntaxKind.AwaitKeyword: - case SyntaxKind.BooleanKeyword: - case SyntaxKind.ConstructorKeyword: - case SyntaxKind.DeclareKeyword: - case SyntaxKind.GetKeyword: - case SyntaxKind.IsKeyword: - case SyntaxKind.ModuleKeyword: - case SyntaxKind.NamespaceKeyword: - case SyntaxKind.NeverKeyword: - case SyntaxKind.ReadonlyKeyword: - case SyntaxKind.RequireKeyword: - case SyntaxKind.NumberKeyword: - case SyntaxKind.SetKeyword: - case SyntaxKind.StringKeyword: - case SyntaxKind.SymbolKeyword: - case SyntaxKind.TypeKeyword: - case SyntaxKind.UndefinedKeyword: - case SyntaxKind.FromKeyword: - case SyntaxKind.GlobalKeyword: - case SyntaxKind.OfKeyword: - writeTokenText(kind); - return; - // Parse tree nodes // Names @@ -538,6 +593,8 @@ namespace ts { return emitJsxClosingElement(node); case SyntaxKind.JsxAttribute: return emitJsxAttribute(node); + case SyntaxKind.JsxAttributes: + return emitJsxAttributes(node); case SyntaxKind.JsxSpreadAttribute: return emitJsxSpreadAttribute(node); case SyntaxKind.JsxExpression: @@ -572,17 +629,11 @@ namespace ts { // If the node is an expression, try to emit it as an expression with // substitution. if (isExpression(node)) { - return pipelineEmitWithSubstitution(EmitContext.Expression, node); + return pipelineEmitExpression(trySubstituteNode(EmitHint.Expression, node)); } } - /** - * Emits a node in the Expression EmitContext. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from pipelineEmitForContext. - */ - function pipelineEmitInExpressionContext(node: Node): void { + function pipelineEmitExpression(node: Node): void { const kind = node.kind; switch (kind) { // Literals @@ -675,6 +726,25 @@ namespace ts { } } + function trySubstituteNode(hint: EmitHint, node: Node) { + return node && substituteNode && substituteNode(hint, node) || node; + } + + function emitBodyIndirect(node: Node, elements: NodeArray, emitCallback: (node: Node) => void): void { + if (emitBodyWithDetachedComments) { + emitBodyWithDetachedComments(node, elements, emitCallback); + } + else { + emitCallback(node); + } + } + + function emitHelpersIndirect(node: Node) { + if (onEmitHelpers) { + onEmitHelpers(node, writeLines); + } + } + // // Literals/Pseudo-literals // @@ -682,9 +752,6 @@ namespace ts { // SyntaxKind.NumericLiteral function emitNumericLiteral(node: NumericLiteral) { emitLiteral(node); - if (node.trailingComment) { - write(` /*${node.trailingComment}*/`); - } } // SyntaxKind.StringLiteral @@ -695,7 +762,7 @@ namespace ts { // SyntaxKind.TemplateTail function emitLiteral(node: LiteralLikeNode) { const text = getLiteralTextOfNode(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) + if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) && (node.kind === SyntaxKind.StringLiteral || isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } @@ -934,17 +1001,13 @@ namespace ts { write("{"); writeLine(); increaseIndent(); - if (node.readonlyToken) { - write("readonly "); - } + writeIfPresent(node.readonlyToken, "readonly "); write("["); emit(node.typeParameter.name); write(" in "); emit(node.typeParameter.constraint); write("]"); - if (node.questionToken) { - write("?"); - } + writeIfPresent(node.questionToken, "?"); write(": "); emit(node.type); write(";"); @@ -1033,7 +1096,7 @@ namespace ts { let indentAfterDot = false; if (!(getEmitFlags(node) & EmitFlags.NoIndentation)) { const dotRangeStart = node.expression.end; - const dotRangeEnd = skipTrivia(currentText, node.expression.end) + 1; + const dotRangeEnd = skipTrivia(currentSourceFile.text, node.expression.end) + 1; const dotToken = { kind: SyntaxKind.DotToken, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); @@ -1054,9 +1117,11 @@ namespace ts { // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal function needsDotDotForPropertyAccess(expression: Expression) { if (expression.kind === SyntaxKind.NumericLiteral) { - // check if numeric literal was originally written with a dot + // check if numeric literal is a decimal literal that was originally written with a dot const text = getLiteralTextOfNode(expression); - return text.indexOf(tokenToString(SyntaxKind.DotToken)) < 0; + return getNumericLiteralFlags(text, /*hint*/ NumericLiteralFlags.All) === NumericLiteralFlags.None + && !(expression).isOctalLiteral + && text.indexOf(tokenToString(SyntaxKind.DotToken)) < 0; } else if (isPropertyAccessExpression(expression) || isElementAccessExpression(expression)) { // check if constant enum value is integer @@ -1064,7 +1129,7 @@ namespace ts { // isFinite handles cases when constantValue is undefined return isFinite(constantValue) && Math.floor(constantValue) === constantValue - && compilerOptions.removeComments; + && printerOptions.removeComments; } } @@ -1095,12 +1160,9 @@ namespace ts { } function emitTypeAssertionExpression(node: TypeAssertion) { - if (node.type) { - write("<"); - emit(node.type); - write(">"); - } - + write("<"); + emit(node.type); + write(">"); emitExpression(node.expression); } @@ -1277,6 +1339,10 @@ namespace ts { else { writeToken(SyntaxKind.OpenBraceToken, node.pos, /*contextNode*/ node); emitBlockStatements(node); + // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); writeToken(SyntaxKind.CloseBraceToken, node.statements.end, /*contextNode*/ node); } } @@ -1374,6 +1440,7 @@ namespace ts { function emitForOfStatement(node: ForOfStatement) { const openParenPos = writeToken(SyntaxKind.ForKeyword, node.pos); write(" "); + emitWithSuffix(node.awaitModifier, " "); writeToken(SyntaxKind.OpenParenToken, openParenPos); emitForBinding(node.initializer); write(" of "); @@ -1500,11 +1567,10 @@ namespace ts { emitBlockFunctionBody(body); } else { - const savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); emitSignatureHead(node); emitBlockFunctionBody(body); - tempFlags = savedTempFlags; + popNameGenerationScope(); } if (indentedFlag) { @@ -1572,10 +1638,11 @@ namespace ts { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, - shouldEmitBlockFunctionBodyOnSingleLine(body) - ? emitBlockFunctionBodyOnSingleLine - : emitBlockFunctionBodyWorker); + const emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) + ? emitBlockFunctionBodyOnSingleLine + : emitBlockFunctionBodyWorker; + + emitBodyIndirect(body, body.statements, emitBlockFunctionBody); decreaseIndent(); writeToken(SyntaxKind.CloseBraceToken, body.statements.end, body); @@ -1588,9 +1655,9 @@ namespace ts { function emitBlockFunctionBodyWorker(body: Block, emitBlockFunctionBodyOnSingleLine?: boolean) { // Emit all the prologue directives (like "use strict"). const statementOffset = emitPrologueDirectives(body.statements, /*startWithNewLine*/ true); - const helpersEmitted = emitHelpers(body); - - if (statementOffset === 0 && !helpersEmitted && emitBlockFunctionBodyOnSingleLine) { + const pos = writer.getTextPos(); + emitHelpersIndirect(body); + if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); emitList(body, body.statements, ListFormat.SingleLineFunctionBodyStatements); increaseIndent(); @@ -1618,18 +1685,15 @@ namespace ts { emitTypeParameters(node, node.typeParameters); emitList(node, node.heritageClauses, ListFormat.ClassHeritageClauses); - const savedTempFlags = tempFlags; - tempFlags = 0; - + pushNameGenerationScope(); write(" {"); emitList(node, node.members, ListFormat.ClassMembers); write("}"); + popNameGenerationScope(); if (indentedFlag) { decreaseIndent(); } - - tempFlags = savedTempFlags; } function emitInterfaceDeclaration(node: InterfaceDeclaration) { @@ -1659,14 +1723,11 @@ namespace ts { emitModifiers(node, node.modifiers); write("enum "); emit(node.name); - - const savedTempFlags = tempFlags; - tempFlags = 0; - + pushNameGenerationScope(); write(" {"); emitList(node, node.members, ListFormat.EnumMembers); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } function emitModuleDeclaration(node: ModuleDeclaration) { @@ -1690,13 +1751,12 @@ namespace ts { write("{ }"); } else { - const savedTempFlags = tempFlags; - tempFlags = 0; + pushNameGenerationScope(); write("{"); increaseIndent(); emitBlockStatements(node); write("}"); - tempFlags = savedTempFlags; + popNameGenerationScope(); } } @@ -1824,15 +1884,21 @@ namespace ts { write("<"); emitJsxTagName(node.tagName); write(" "); - emitList(node, node.attributes, ListFormat.JsxElementAttributes); + // We are checking here so we won't re-enter the emiting pipeline and emit extra sourcemap + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write("/>"); } function emitJsxOpeningElement(node: JsxOpeningElement) { write("<"); emitJsxTagName(node.tagName); - writeIfAny(node.attributes, " "); - emitList(node, node.attributes, ListFormat.JsxElementAttributes); + writeIfAny(node.attributes.properties, " "); + // We are checking here so we won't re-enter the emitting pipeline and emit extra sourcemap + if (node.attributes.properties && node.attributes.properties.length > 0) { + emit(node.attributes); + } write(">"); } @@ -1846,6 +1912,10 @@ namespace ts { write(">"); } + function emitJsxAttributes(node: JsxAttributes) { + emitList(node, node.properties, ListFormat.JsxElementAttributes); + } + function emitJsxAttribute(node: JsxAttribute) { emit(node.name); emitWithPrefix("=", node.initializer); @@ -1921,7 +1991,6 @@ namespace ts { } function emitCatchClause(node: CatchClause) { - writeLine(); const openParenPos = writeToken(SyntaxKind.CatchKeyword, node.pos); write(" "); writeToken(SyntaxKind.OpenParenToken, openParenPos); @@ -1946,11 +2015,10 @@ namespace ts { // "comment1" is not considered to be leading comment for node.initializer // but rather a trailing comment on the previous node. const initializer = node.initializer; - if ((getEmitFlags(initializer) & EmitFlags.NoLeadingComments) === 0) { + if (emitTrailingCommentsOfPosition && (getEmitFlags(initializer) & EmitFlags.NoLeadingComments) === 0) { const commentRange = getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } - emitExpression(initializer); } @@ -1985,17 +2053,16 @@ namespace ts { function emitSourceFile(node: SourceFile) { writeLine(); emitShebang(); - emitBodyWithDetachedComments(node, node.statements, emitSourceFileWorker); + emitBodyIndirect(node, node.statements, emitSourceFileWorker); } function emitSourceFileWorker(node: SourceFile) { const statements = node.statements; const statementOffset = emitPrologueDirectives(statements); - const savedTempFlags = tempFlags; - tempFlags = 0; - emitHelpers(node); + pushNameGenerationScope(); + emitHelpersIndirect(node); emitList(node, statements, ListFormat.MultiLine, statementOffset); - tempFlags = savedTempFlags; + popNameGenerationScope(); } // Transformation nodes @@ -2025,83 +2092,12 @@ namespace ts { return statements.length; } - function emitHelpers(node: Node, isBundle?: boolean) { - const sourceFile = isSourceFile(node) ? node : currentSourceFile; - const shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && getExternalHelpersModuleName(sourceFile) !== undefined); - const shouldBundle = isSourceFile(node) && !isOwnFileEmit; - - let helpersEmitted = false; - const helpers = getEmitHelpers(node); - if (helpers) { - for (const helper of stableSort(helpers, compareEmitHelpers)) { - if (!helper.scoped) { - // Skip the helper if it can be skipped and the noEmitHelpers compiler - // option is set, or if it can be imported and the importHelpers compiler - // option is set. - if (shouldSkip) continue; - - // Skip the helper if it can be bundled but hasn't already been emitted and we - // are emitting a bundled module. - if (shouldBundle) { - if (bundledHelpers[helper.name]) { - continue; - } - - bundledHelpers[helper.name] = true; - } - } - else if (isBundle) { - // Skip the helper if it is scoped and we are emitting bundled helpers - continue; - } - - writeLines(helper.text); - helpersEmitted = true; - } - } - - if (helpersEmitted) { - writeLine(); - } - - return helpersEmitted; - } - - function writeLines(text: string): void { - const lines = text.split(/\r\n?|\n/g); - const indentation = guessIndentation(lines); - for (let i = 0; i < lines.length; i++) { - const line = indentation ? lines[i].slice(indentation) : lines[i]; - if (line.length) { - if (i > 0) { - writeLine(); - } - write(line); - } - } - } - - function guessIndentation(lines: string[]) { - let indentation: number; - for (const line of lines) { - for (let i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { - if (!isWhiteSpace(line.charCodeAt(i))) { - if (indentation === undefined || i < indentation) { - indentation = i; - break; - } - } - } - } - return indentation; - } - // // Helpers // function emitShebang() { - const shebang = getShebang(currentText); + const shebang = getShebang(currentSourceFile.text); if (shebang) { write(shebang); writeLine(); @@ -2240,6 +2236,15 @@ namespace ts { // Write the delimiter if this is not the first node. if (previousSibling) { + // i.e + // function commentedParameters( + // /* Parameter a */ + // a + // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline + // , + if (delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } write(delimiter); // Write either a line terminator or whitespace to separate the elements. @@ -2259,15 +2264,17 @@ namespace ts { } } + // Emit this child. if (shouldEmitInterveningComments) { - const commentRange = getCommentRange(child); - emitTrailingCommentsOfPosition(commentRange.pos); + if (emitTrailingCommentsOfPosition) { + const commentRange = getCommentRange(child); + emitTrailingCommentsOfPosition(commentRange.pos); + } } else { shouldEmitInterveningComments = mayEmitInterveningComments; } - // Emit this child. emit(child); if (shouldDecreaseIndentAfterEmit) { @@ -2284,6 +2291,17 @@ namespace ts { write(","); } + + // Emit any trailing comment of the last element in the list + // i.e + // var array = [... + // 2 + // /* end of element 2 */ + // ]; + if (previousSibling && delimiter && previousSibling.end !== parentNode.end) { + emitLeadingCommentsOfPosition(previousSibling.end); + } + // Decrease the indent, if requested. if (format & ListFormat.Indented) { decreaseIndent(); @@ -2303,6 +2321,46 @@ namespace ts { } } + function write(s: string) { + writer.write(s); + } + + function writeLine() { + writer.writeLine(); + } + + function increaseIndent() { + writer.increaseIndent(); + } + + function decreaseIndent() { + writer.decreaseIndent(); + } + + function writeIfAny(nodes: NodeArray, text: string) { + if (some(nodes)) { + write(text); + } + } + + function writeIfPresent(node: Node, text: string) { + if (node) { + write(text); + } + } + + function writeToken(token: SyntaxKind, pos: number, contextNode?: Node) { + return onEmitSourceMapOfToken + ? onEmitSourceMapOfToken(contextNode, token, pos, writeTokenText) + : writeTokenText(token, pos); + } + + function writeTokenText(token: SyntaxKind, pos?: number) { + const tokenString = tokenToString(token); + write(tokenString); + return pos < 0 ? pos : pos + tokenString.length; + } + function writeLineOrSpace(node: Node) { if (getEmitFlags(node) & EmitFlags.SingleLine) { write(" "); @@ -2312,26 +2370,32 @@ namespace ts { } } - function writeIfAny(nodes: NodeArray, text: string) { - if (nodes && nodes.length > 0) { - write(text); + function writeLines(text: string): void { + const lines = text.split(/\r\n?|\n/g); + const indentation = guessIndentation(lines); + for (let i = 0; i < lines.length; i++) { + const line = indentation ? lines[i].slice(indentation) : lines[i]; + if (line.length) { + writeLine(); + write(line); + writeLine(); + } } } - function writeIfPresent(node: Node, text: string) { - if (node !== undefined) { - write(text); + function guessIndentation(lines: string[]) { + let indentation: number; + for (const line of lines) { + for (let i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { + if (!isWhiteSpace(line.charCodeAt(i))) { + if (indentation === undefined || i < indentation) { + indentation = i; + break; + } + } + } } - } - - function writeToken(token: SyntaxKind, pos: number, contextNode?: Node) { - return emitTokenWithSourceMap(contextNode, token, pos, writeTokenText); - } - - function writeTokenText(token: SyntaxKind, pos?: number) { - const tokenString = tokenToString(token); - write(tokenString); - return pos < 0 ? pos : pos + tokenString.length; + return indentation; } function increaseIndentIf(value: boolean, valueToWriteWhenNotIndenting?: string) { @@ -2457,6 +2521,16 @@ namespace ts { && !rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } + function isSingleLineEmptyBlock(block: Block) { + return !block.multiLine + && isEmptyBlock(block); + } + + function isEmptyBlock(block: BlockLike) { + return block.statements.length === 0 + && rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + } + function skipSynthesizedParentheses(node: Node) { while (node.kind === SyntaxKind.ParenthesizedExpression && nodeIsSynthesized(node)) { node = (node).expression; @@ -2467,7 +2541,7 @@ namespace ts { function getTextOfNode(node: Node, includeTrivia?: boolean): string { if (isGeneratedIdentifier(node)) { - return getGeneratedIdentifier(node); + return generateName(node); } else if (isIdentifier(node) && (nodeIsSynthesized(node) || !node.parent)) { return unescapeIdentifier(node.text); @@ -2496,27 +2570,63 @@ namespace ts { return getLiteralText(node, currentSourceFile, languageVersion); } - function isSingleLineEmptyBlock(block: Block) { - return !block.multiLine - && isEmptyBlock(block); + /** + * Push a new name generation scope. + */ + function pushNameGenerationScope() { + tempFlagsStack.push(tempFlags); + tempFlags = 0; } - function isEmptyBlock(block: BlockLike) { - return block.statements.length === 0 - && rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + /** + * Pop the current name generation scope. + */ + function popNameGenerationScope() { + tempFlags = tempFlagsStack.pop(); } + /** + * Generate the text for a generated identifier. + */ + function generateName(name: GeneratedIdentifier) { + if (name.autoGenerateKind === GeneratedIdentifierKind.Node) { + // Node names generate unique names based on their original node + // and are cached based on that node's id. + const node = getNodeForGeneratedName(name); + return generateNameCached(node); + } + else { + // Auto, Loop, and Unique names are cached based on their unique + // autoGenerateId. + const autoGenerateId = name.autoGenerateId; + return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = unescapeIdentifier(makeName(name))); + } + } + + function generateNameCached(node: Node) { + const nodeId = getNodeId(node); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = unescapeIdentifier(generateNameForNode(node))); + } + + /** + * Returns a value indicating whether a name is unique globally, within the current file, + * or within the NameGenerator. + */ function isUniqueName(name: string): boolean { - return !resolver.hasGlobalName(name) && - !hasProperty(currentFileIdentifiers, name) && - !hasProperty(generatedNameSet, name); + return !(hasGlobalName && hasGlobalName(name)) + && !currentSourceFile.identifiers.has(name) + && !generatedNames.has(name); } + /** + * Returns a value indicating whether a name is unique within a container. + */ function isUniqueLocalName(name: string, container: Node): boolean { for (let node = container; isNodeDescendantOf(node, container); node = node.nextContainer) { - if (node.locals && hasProperty(node.locals, name)) { + if (node.locals) { + const local = node.locals.get(name); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (node.locals[name].flags & (SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias)) { + if (local && local.flags & (SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias)) { return false; } } @@ -2525,10 +2635,10 @@ namespace ts { } /** - * 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. - */ + * Return the next available name in the pattern _a ... _z, _0, _1, ... + * TempFlags._i or TempFlags._n may be used to express a preference for that dedicated name. + * Note that names generated by makeTempVariableName and makeUniqueName will never conflict. + */ function makeTempVariableName(flags: TempFlags): string { if (flags && !(tempFlags & flags)) { const name = flags === TempFlags._i ? "_i" : "_n"; @@ -2552,10 +2662,12 @@ namespace ts { } } - // 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. + /** + * Generate a name that is unique within the current file and doesn't conflict with any names + * in global scope. The name is formed by adding an '_n' suffix to the specified base name, + * where n is a positive integer. Note that names generated by makeTempVariableName and + * makeUniqueName are guaranteed to never conflict. + */ function makeUniqueName(baseName: string): string { // Find the first unique 'name_n', where n is a positive number if (baseName.charCodeAt(baseName.length - 1) !== CharacterCodes._) { @@ -2565,18 +2677,25 @@ namespace ts { while (true) { const generatedName = baseName + i; if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; + generatedNames.set(generatedName, generatedName); + return generatedName; } i++; } } + /** + * Generates a unique name for a ModuleDeclaration or EnumDeclaration. + */ function generateNameForModuleOrEnum(node: ModuleDeclaration | EnumDeclaration) { const name = getTextOfNode(node.name); // Use module/enum name itself if it is unique, otherwise make a unique variation return isUniqueLocalName(name, node) ? name : makeUniqueName(name); } + /** + * Generates a unique name for an ImportDeclaration or ExportDeclaration. + */ function generateNameForImportOrExportDeclaration(node: ImportDeclaration | ExportDeclaration) { const expr = getExternalModuleName(node); const baseName = expr.kind === SyntaxKind.StringLiteral ? @@ -2584,25 +2703,29 @@ namespace ts { return makeUniqueName(baseName); } + /** + * Generates a unique name for a default export. + */ function generateNameForExportDefault() { return makeUniqueName("default"); } + /** + * Generates a unique name for a class expression. + */ function generateNameForClassExpression() { return makeUniqueName("class"); } function generateNameForMethodOrAccessor(node: MethodDeclaration | AccessorDeclaration) { if (isIdentifier(node.name)) { - return generateNameForNodeCached(node.name); + return generateNameCached(node.name); } return makeTempVariableName(TempFlags.Auto); } /** * Generates a unique name from a node. - * - * @param node A node. */ function generateNameForNode(node: Node): string { switch (node.kind) { @@ -2631,17 +2754,15 @@ namespace ts { /** * Generates a unique identifier for a node. - * - * @param name A generated name. */ - function generateName(name: Identifier) { + function makeName(name: GeneratedIdentifier) { switch (name.autoGenerateKind) { case GeneratedIdentifierKind.Auto: return makeTempVariableName(TempFlags.Auto); case GeneratedIdentifierKind.Loop: return makeTempVariableName(TempFlags._i); case GeneratedIdentifierKind.Unique: - return makeUniqueName(name.text); + return makeUniqueName(unescapeIdentifier(name.text)); } Debug.fail("Unsupported GeneratedIdentifierKind."); @@ -2649,10 +2770,8 @@ namespace ts { /** * Gets the node from which a name should be generated. - * - * @param name A generated name wrapper. */ - function getNodeForGeneratedName(name: Identifier) { + function getNodeForGeneratedName(name: GeneratedIdentifier) { const autoGenerateId = name.autoGenerateId; let node = name as Node; let original = node.original; @@ -2673,61 +2792,43 @@ namespace ts { // otherwise, return the original node for the source; return node; } + } - function generateNameForNodeCached(node: Node) { - const nodeId = getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = unescapeIdentifier(generateNameForNode(node))); - } + function createDelimiterMap() { + const delimiters: string[] = []; + delimiters[ListFormat.None] = ""; + delimiters[ListFormat.CommaDelimited] = ","; + delimiters[ListFormat.BarDelimited] = " |"; + delimiters[ListFormat.AmpersandDelimited] = " &"; + return delimiters; + } - /** - * Gets the generated identifier text from a generated identifier. - * - * @param name The generated identifier. - */ - function getGeneratedIdentifier(name: Identifier) { - if (name.autoGenerateKind === GeneratedIdentifierKind.Node) { - // Generated names generate unique names based on their original node - // and are cached based on that node's id - const node = getNodeForGeneratedName(name); - return generateNameForNodeCached(node); - } - else { - // Auto, Loop, and Unique names are cached based on their unique - // autoGenerateId. - const autoGenerateId = name.autoGenerateId; - return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = unescapeIdentifier(generateName(name))); - } - } + function getDelimiter(format: ListFormat) { + return delimiters[format & ListFormat.DelimitersMask]; + } - function createDelimiterMap() { - const delimiters: string[] = []; - delimiters[ListFormat.None] = ""; - delimiters[ListFormat.CommaDelimited] = ","; - delimiters[ListFormat.BarDelimited] = " |"; - delimiters[ListFormat.AmpersandDelimited] = " &"; - return delimiters; - } + function createBracketsMap() { + const brackets: string[][] = []; + brackets[ListFormat.Braces] = ["{", "}"]; + brackets[ListFormat.Parenthesis] = ["(", ")"]; + brackets[ListFormat.AngleBrackets] = ["<", ">"]; + brackets[ListFormat.SquareBrackets] = ["[", "]"]; + return brackets; + } - function getDelimiter(format: ListFormat) { - return delimiters[format & ListFormat.DelimitersMask]; - } + function getOpeningBracket(format: ListFormat) { + return brackets[format & ListFormat.BracketsMask][0]; + } - function createBracketsMap() { - const brackets: string[][] = []; - brackets[ListFormat.Braces] = ["{", "}"]; - brackets[ListFormat.Parenthesis] = ["(", ")"]; - brackets[ListFormat.AngleBrackets] = ["<", ">"]; - brackets[ListFormat.SquareBrackets] = ["[", "]"]; - return brackets; - } + function getClosingBracket(format: ListFormat) { + return brackets[format & ListFormat.BracketsMask][1]; + } - function getOpeningBracket(format: ListFormat) { - return brackets[format & ListFormat.BracketsMask][0]; - } - - function getClosingBracket(format: ListFormat) { - return brackets[format & ListFormat.BracketsMask][1]; - } + // Flags enum to track count of temp variables and a few dedicated names + const enum TempFlags { + Auto = 0x00000000, // No preferred name + CountMask = 0x0FFFFFFF, // Temp variable counter + _i = 0x10000000, // Use/preference flag for '_i' } const enum ListFormat { @@ -2754,7 +2855,7 @@ namespace ts { SpaceBetweenSiblings = 1 << 8, // Inserts a space between each sibling node. // Brackets/Braces - Braces = 1 << 9, // The list is surrounded by "{" and "}". + Braces = 1 << 9, // The list is surrounded by "{" and "}". Parenthesis = 1 << 10, // The list is surrounded by "(" and ")". AngleBrackets = 1 << 11, // The list is surrounded by "<" and ">". SquareBrackets = 1 << 12, // The list is surrounded by "[" and "]". diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 033d694ade2..bfacb3cd2d3 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -1,28 +1,18 @@ -/// +/// /// -/* @internal */ namespace ts { - let NodeConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node; - let SourceFileConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node; - - function createNode(kind: SyntaxKind, location?: TextRange, flags?: NodeFlags): Node { - const ConstructorForKind = kind === SyntaxKind.SourceFile - ? (SourceFileConstructor || (SourceFileConstructor = objectAllocator.getSourceFileConstructor())) - : (NodeConstructor || (NodeConstructor = objectAllocator.getNodeConstructor())); - - const node = location - ? new ConstructorForKind(kind, location.pos, location.end) - : new ConstructorForKind(kind, /*pos*/ -1, /*end*/ -1); - - node.flags = flags | NodeFlags.Synthesized; - + function createSynthesizedNode(kind: SyntaxKind): Node { + const node = createNode(kind, -1, -1); + node.flags |= NodeFlags.Synthesized; return node; } + /* @internal */ export function updateNode(updated: T, original: T): T { if (updated !== original) { setOriginalNode(updated, original); + setTextRange(updated, original); if (original.startsOnNewLine) { updated.startsOnNewLine = true; } @@ -31,7 +21,10 @@ namespace ts { return updated; } - export function createNodeArray(elements?: T[], location?: TextRange, hasTrailingComma?: boolean): NodeArray { + /** + * Make `elements` into a `NodeArray`. If `elements` is `undefined`, returns an empty `NodeArray`. + */ + export function createNodeArray(elements?: T[], hasTrailingComma?: boolean): NodeArray { if (elements) { if (isNodeArray(elements)) { return elements; @@ -42,40 +35,22 @@ namespace ts { } const array = >elements; - if (location) { - array.pos = location.pos; - array.end = location.end; - } - else { - array.pos = -1; - array.end = -1; - } - - if (hasTrailingComma) { - array.hasTrailingComma = true; - } - + array.pos = -1; + array.end = -1; + array.hasTrailingComma = hasTrailingComma; return array; } - export function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node { - const node = createNode(kind, /*location*/ undefined); - node.startsOnNewLine = startsOnNewLine; - return node; - } - - export function createSynthesizedNodeArray(elements?: T[]): NodeArray { - return createNodeArray(elements, /*location*/ undefined); - } - /** * Creates a shallow, memberwise clone of a node with no source map location. */ + /* @internal */ export function getSynthesizedClone(node: T): T { // We don't use "clone" from core.ts here, as we need to preserve the prototype chain of // the original node. We also need to exclude specific properties and only include own- // properties (to skip members already defined on the shared prototype). - const clone = createNode(node.kind, /*location*/ undefined, node.flags); + const clone = createSynthesizedNode(node.kind); + clone.flags |= node.flags; setOriginalNode(clone, node); for (const key in node) { @@ -89,63 +64,62 @@ namespace ts { return clone; } - /** - * Creates a shallow, memberwise clone of a node for mutation. - */ - export function getMutableClone(node: T): T { - const clone = getSynthesizedClone(node); - clone.pos = node.pos; - clone.end = node.end; - clone.parent = node.parent; - return clone; - } - // Literals - export function createLiteral(textSource: StringLiteral | NumericLiteral | Identifier, location?: TextRange): StringLiteral; - export function createLiteral(value: string, location?: TextRange): StringLiteral; - export function createLiteral(value: number, location?: TextRange): NumericLiteral; - export function createLiteral(value: boolean, location?: TextRange): BooleanLiteral; - export function createLiteral(value: string | number | boolean, location?: TextRange): PrimaryExpression; - export function createLiteral(value: string | number | boolean | StringLiteral | NumericLiteral | Identifier, location?: TextRange): PrimaryExpression { + export function createLiteral(value: string): StringLiteral; + export function createLiteral(value: number): NumericLiteral; + export function createLiteral(value: boolean): BooleanLiteral; + /** Create a string literal whose source text is read from a source node during emit. */ + export function createLiteral(sourceNode: StringLiteral | NumericLiteral | Identifier): StringLiteral; + export function createLiteral(value: string | number | boolean): PrimaryExpression; + export function createLiteral(value: string | number | boolean | StringLiteral | NumericLiteral | Identifier): PrimaryExpression { if (typeof value === "number") { - const node = createNode(SyntaxKind.NumericLiteral, location, /*flags*/ undefined); - node.text = value.toString(); - return node; + return createNumericLiteral(value + ""); } - else if (typeof value === "boolean") { - return createNode(value ? SyntaxKind.TrueKeyword : SyntaxKind.FalseKeyword, location, /*flags*/ undefined); + if (typeof value === "boolean") { + return value ? createTrue() : createFalse(); } - else if (typeof value === "string") { - const node = createNode(SyntaxKind.StringLiteral, location, /*flags*/ undefined); - node.text = value; - return node; - } - else if (value) { - const node = createNode(SyntaxKind.StringLiteral, location, /*flags*/ undefined); - node.textSourceNode = value; - node.text = value.text; - return node; + if (typeof value === "string") { + return createStringLiteral(value); } + return createLiteralFromNode(value); } + export function createNumericLiteral(value: string): NumericLiteral { + const node = createSynthesizedNode(SyntaxKind.NumericLiteral); + node.text = value; + return node; + } + + function createStringLiteral(text: string): StringLiteral { + const node = createSynthesizedNode(SyntaxKind.StringLiteral); + node.text = text; + return node; + } + + function createLiteralFromNode(sourceNode: StringLiteral | NumericLiteral | Identifier): StringLiteral { + const node = createStringLiteral(sourceNode.text); + node.textSourceNode = sourceNode; + return node; + } + + // Identifiers - let nextAutoGenerateId = 0; - - export function createIdentifier(text: string, location?: TextRange): Identifier { - const node = createNode(SyntaxKind.Identifier, location); + export function createIdentifier(text: string): Identifier { + const node = createSynthesizedNode(SyntaxKind.Identifier); node.text = escapeIdentifier(text); - node.originalKeywordKind = stringToToken(text); + node.originalKeywordKind = text ? stringToToken(text) : SyntaxKind.Unknown; node.autoGenerateKind = GeneratedIdentifierKind.None; node.autoGenerateId = 0; return node; } - export function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, location?: TextRange): Identifier { - const name = createNode(SyntaxKind.Identifier, location); - name.text = ""; - name.originalKeywordKind = SyntaxKind.Unknown; + let nextAutoGenerateId = 0; + + /** Create a unique temporary variable. */ + export function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier { + const name = createIdentifier(""); name.autoGenerateKind = GeneratedIdentifierKind.Auto; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; @@ -155,33 +129,30 @@ namespace ts { return name; } - export function createLoopVariable(location?: TextRange): Identifier { - const name = createNode(SyntaxKind.Identifier, location); - name.text = ""; - name.originalKeywordKind = SyntaxKind.Unknown; + /** Create a unique temporary variable for use in a loop. */ + export function createLoopVariable(): Identifier { + const name = createIdentifier(""); name.autoGenerateKind = GeneratedIdentifierKind.Loop; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } - export function createUniqueName(text: string, location?: TextRange): Identifier { - const name = createNode(SyntaxKind.Identifier, location); - name.text = text; - name.originalKeywordKind = SyntaxKind.Unknown; + /** Create a unique name based on the supplied text. */ + export function createUniqueName(text: string): Identifier { + const name = createIdentifier(text); name.autoGenerateKind = GeneratedIdentifierKind.Unique; name.autoGenerateId = nextAutoGenerateId; nextAutoGenerateId++; return name; } - export function getGeneratedNameForNode(node: Node, location?: TextRange): Identifier { - const name = createNode(SyntaxKind.Identifier, location); - name.original = node; - name.text = ""; - name.originalKeywordKind = SyntaxKind.Unknown; + /** Create a unique name generated for a node. */ + export function getGeneratedNameForNode(node: Node): Identifier { + const name = createIdentifier(""); name.autoGenerateKind = GeneratedIdentifierKind.Node; name.autoGenerateId = nextAutoGenerateId; + name.original = node; nextAutoGenerateId++; return name; } @@ -189,107 +160,149 @@ namespace ts { // Punctuation export function createToken(token: TKind) { - return >createNode(token); + return >createSynthesizedNode(token); } // Reserved words export function createSuper() { - const node = createNode(SyntaxKind.SuperKeyword); - return node; + return createSynthesizedNode(SyntaxKind.SuperKeyword); } - export function createThis(location?: TextRange) { - const node = createNode(SyntaxKind.ThisKeyword, location); - return node; + export function createThis() { + return createSynthesizedNode(SyntaxKind.ThisKeyword); } export function createNull() { - const node = createNode(SyntaxKind.NullKeyword); - return node; + return createSynthesizedNode(SyntaxKind.NullKeyword); + } + + export function createTrue() { + return createSynthesizedNode(SyntaxKind.TrueKeyword); + } + + export function createFalse() { + return createSynthesizedNode(SyntaxKind.FalseKeyword); } // Names - export function createComputedPropertyName(expression: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.ComputedPropertyName, location); + export function createQualifiedName(left: EntityName, right: string | Identifier) { + const node = createSynthesizedNode(SyntaxKind.QualifiedName); + node.left = left; + node.right = asName(right); + return node; + } + + export function updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier) { + return node.left !== left + || node.right !== right + ? updateNode(createQualifiedName(left, right), node) + : node; + } + + export function createComputedPropertyName(expression: Expression) { + const node = createSynthesizedNode(SyntaxKind.ComputedPropertyName); node.expression = expression; return node; } export function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression) { - if (node.expression !== expression) { - return updateNode(createComputedPropertyName(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createComputedPropertyName(expression), node) + : node; } // Signature elements - export function createParameter(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression, location?: TextRange, flags?: NodeFlags) { - const node = createNode(SyntaxKind.Parameter, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + export function createParameter(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression) { + const node = createSynthesizedNode(SyntaxKind.Parameter); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); node.questionToken = questionToken; node.type = type; node.initializer = initializer ? parenthesizeExpressionForList(initializer) : undefined; return node; } - export function updateParameter(node: ParameterDeclaration, decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: BindingName, type: TypeNode, initializer: Expression) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer, /*location*/ node, /*flags*/ node.flags), node); - } + export function updateParameter(node: ParameterDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) + : node; + } + export function createDecorator(expression: Expression) { + const node = createSynthesizedNode(SyntaxKind.Decorator); + node.expression = parenthesizeForAccess(expression); return node; } + export function updateDecorator(node: Decorator, expression: Expression) { + return node.expression !== expression + ? updateNode(createDecorator(expression), node) + : node; + } + // Type members - export function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: QuestionToken, type: TypeNode, initializer: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.PropertyDeclaration, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + export function createProperty(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression) { + const node = createSynthesizedNode(SyntaxKind.PropertyDeclaration); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.questionToken = questionToken; node.type = type; node.initializer = initializer; return node; } - export function updateProperty(node: PropertyDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, type: TypeNode, initializer: Expression) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer, node), node); - } - return node; + export function updateProperty(node: PropertyDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, type: TypeNode | undefined, initializer: Expression) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer), node) + : node; } - export function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) { - const node = createNode(SyntaxKind.MethodDeclaration, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + export function createMethod(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { + const node = createSynthesizedNode(SyntaxKind.MethodDeclaration); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; return node; } - export function updateMethod(node: MethodDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + export function updateMethod(node: MethodDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.asteriskToken !== asteriskToken + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } - export function createConstructor(decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block, location?: TextRange, flags?: NodeFlags) { - const node = createNode(SyntaxKind.Constructor, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + export function createConstructor(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], body: Block | undefined) { + const node = createSynthesizedNode(SyntaxKind.Constructor); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = undefined; @@ -297,18 +310,20 @@ namespace ts { return node; } - export function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.parameters !== parameters || node.body !== body) { - return updateNode(createConstructor(decorators, modifiers, parameters, body, /*location*/ node, node.flags), node); - } - return node; + export function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], body: Block | undefined) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.parameters !== parameters + || node.body !== body + ? updateNode(createConstructor(decorators, modifiers, parameters, body), node) + : node; } - export function createGetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) { - const node = createNode(SyntaxKind.GetAccessor, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + export function createGetAccessor(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { + const node = createSynthesizedNode(SyntaxKind.GetAccessor); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.type = type; @@ -316,79 +331,86 @@ namespace ts { return node; } - export function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + export function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body), node) + : node; } - export function createSetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], body: Block, location?: TextRange, flags?: NodeFlags) { - const node = createNode(SyntaxKind.SetAccessor, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; + export function createSetAccessor(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, parameters: ParameterDeclaration[], body: Block | undefined) { + const node = createSynthesizedNode(SyntaxKind.SetAccessor); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); node.typeParameters = undefined; node.parameters = createNodeArray(parameters); node.body = body; return node; } - export function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], body: Block) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.body !== body) { - return updateNode(createSetAccessor(decorators, modifiers, name, parameters, body, /*location*/ node, node.flags), node); - } - return node; + export function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, parameters: ParameterDeclaration[], body: Block | undefined) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.parameters !== parameters + || node.body !== body + ? updateNode(createSetAccessor(decorators, modifiers, name, parameters, body), node) + : node; } // Binding Patterns - export function createObjectBindingPattern(elements: BindingElement[], location?: TextRange) { - const node = createNode(SyntaxKind.ObjectBindingPattern, location); + export function createObjectBindingPattern(elements: BindingElement[]) { + const node = createSynthesizedNode(SyntaxKind.ObjectBindingPattern); node.elements = createNodeArray(elements); return node; } export function updateObjectBindingPattern(node: ObjectBindingPattern, elements: BindingElement[]) { - if (node.elements !== elements) { - return updateNode(createObjectBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createObjectBindingPattern(elements), node) + : node; } - export function createArrayBindingPattern(elements: ArrayBindingElement[], location?: TextRange) { - const node = createNode(SyntaxKind.ArrayBindingPattern, location); + export function createArrayBindingPattern(elements: ArrayBindingElement[]) { + const node = createSynthesizedNode(SyntaxKind.ArrayBindingPattern); node.elements = createNodeArray(elements); return node; } export function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ArrayBindingElement[]) { - if (node.elements !== elements) { - return updateNode(createArrayBindingPattern(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayBindingPattern(elements), node) + : node; } - export function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: DotDotDotToken, name: string | BindingName, initializer?: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.BindingElement, location); - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + export function createBindingElement(dotDotDotToken: DotDotDotToken | undefined, propertyName: string | PropertyName | undefined, name: string | BindingName, initializer?: Expression) { + const node = createSynthesizedNode(SyntaxKind.BindingElement); node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.propertyName = asName(propertyName); + node.name = asName(name); node.initializer = initializer; return node; } - export function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken, propertyName: PropertyName, name: BindingName, initializer: Expression) { - if (node.propertyName !== propertyName || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.initializer !== initializer) { - return updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer, node), node); - } - return node; + export function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken | undefined, propertyName: PropertyName | undefined, name: BindingName, initializer: Expression | undefined) { + return node.propertyName !== propertyName + || node.dotDotDotToken !== dotDotDotToken + || node.name !== name + || node.initializer !== initializer + ? updateNode(createBindingElement(dotDotDotToken, propertyName, name, initializer), node) + : node; } // Expression - export function createArrayLiteral(elements?: Expression[], location?: TextRange, multiLine?: boolean) { - const node = createNode(SyntaxKind.ArrayLiteralExpression, location); + export function createArrayLiteral(elements?: Expression[], multiLine?: boolean) { + const node = createSynthesizedNode(SyntaxKind.ArrayLiteralExpression); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -398,14 +420,13 @@ namespace ts { } export function updateArrayLiteral(node: ArrayLiteralExpression, elements: Expression[]) { - if (node.elements !== elements) { - return updateNode(createArrayLiteral(elements, node, node.multiLine), node); - } - return node; + return node.elements !== elements + ? updateNode(createArrayLiteral(elements, node.multiLine), node) + : node; } - export function createObjectLiteral(properties?: ObjectLiteralElementLike[], location?: TextRange, multiLine?: boolean) { - const node = createNode(SyntaxKind.ObjectLiteralExpression, location); + export function createObjectLiteral(properties?: ObjectLiteralElementLike[], multiLine?: boolean) { + const node = createSynthesizedNode(SyntaxKind.ObjectLiteralExpression); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -414,127 +435,142 @@ namespace ts { } export function updateObjectLiteral(node: ObjectLiteralExpression, properties: ObjectLiteralElementLike[]) { - if (node.properties !== properties) { - return updateNode(createObjectLiteral(properties, node, node.multiLine), node); - } - return node; + return node.properties !== properties + ? updateNode(createObjectLiteral(properties, node.multiLine), node) + : node; } - export function createPropertyAccess(expression: Expression, name: string | Identifier, location?: TextRange, flags?: NodeFlags) { - const node = createNode(SyntaxKind.PropertyAccessExpression, location, flags); + export function createPropertyAccess(expression: Expression, name: string | Identifier) { + const node = createSynthesizedNode(SyntaxKind.PropertyAccessExpression); node.expression = parenthesizeForAccess(expression); - (node.emitNode || (node.emitNode = {})).flags |= EmitFlags.NoIndentation; - node.name = typeof name === "string" ? createIdentifier(name) : name; + node.name = asName(name); + setEmitFlags(node, EmitFlags.NoIndentation); return node; } export function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier) { - if (node.expression !== expression || node.name !== name) { - const propertyAccess = createPropertyAccess(expression, name, /*location*/ node, node.flags); - // Because we are updating existed propertyAccess we want to inherit its emitFlags instead of using default from createPropertyAccess - (propertyAccess.emitNode || (propertyAccess.emitNode = {})).flags = getEmitFlags(node); - return updateNode(propertyAccess, node); - } - return node; + // Because we are updating existed propertyAccess we want to inherit its emitFlags + // instead of using the default from createPropertyAccess + return node.expression !== expression + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccess(expression, name), getEmitFlags(node)), node) + : node; } - export function createElementAccess(expression: Expression, index: number | Expression, location?: TextRange) { - const node = createNode(SyntaxKind.ElementAccessExpression, location); + export function createElementAccess(expression: Expression, index: number | Expression) { + const node = createSynthesizedNode(SyntaxKind.ElementAccessExpression); node.expression = parenthesizeForAccess(expression); - node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; + node.argumentExpression = asExpression(index); return node; } export function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression) { - if (node.expression !== expression || node.argumentExpression !== argumentExpression) { - return updateNode(createElementAccess(expression, argumentExpression, node), node); - } - return node; + return node.expression !== expression + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccess(expression, argumentExpression), node) + : node; } - export function createCall(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[], location?: TextRange, flags?: NodeFlags) { - const node = createNode(SyntaxKind.CallExpression, location, flags); + export function createCall(expression: Expression, typeArguments: TypeNode[] | undefined, argumentsArray: Expression[]) { + const node = createSynthesizedNode(SyntaxKind.CallExpression); node.expression = parenthesizeForAccess(expression); - if (typeArguments) { - node.typeArguments = createNodeArray(typeArguments); - } - + node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizeListElements(createNodeArray(argumentsArray)); return node; } - export function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]) { - if (expression !== node.expression || typeArguments !== node.typeArguments || argumentsArray !== node.arguments) { - return updateNode(createCall(expression, typeArguments, argumentsArray, /*location*/ node, node.flags), node); - } - return node; + export function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[] | undefined, argumentsArray: Expression[]) { + return expression !== node.expression + || typeArguments !== node.typeArguments + || argumentsArray !== node.arguments + ? updateNode(createCall(expression, typeArguments, argumentsArray), node) + : node; } - export function createNew(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[], location?: TextRange, flags?: NodeFlags) { - const node = createNode(SyntaxKind.NewExpression, location, flags); + export function createNew(expression: Expression, typeArguments: TypeNode[] | undefined, argumentsArray: Expression[] | undefined) { + const node = createSynthesizedNode(SyntaxKind.NewExpression); node.expression = parenthesizeForNew(expression); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; + node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; return node; } - export function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]) { - if (node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray) { - return updateNode(createNew(expression, typeArguments, argumentsArray, /*location*/ node, node.flags), node); - } - return node; + export function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[] | undefined, argumentsArray: Expression[] | undefined) { + return node.expression !== expression + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createNew(expression, typeArguments, argumentsArray), node) + : node; } - export function createTaggedTemplate(tag: Expression, template: TemplateLiteral, location?: TextRange) { - const node = createNode(SyntaxKind.TaggedTemplateExpression, location); + export function createTaggedTemplate(tag: Expression, template: TemplateLiteral) { + const node = createSynthesizedNode(SyntaxKind.TaggedTemplateExpression); node.tag = parenthesizeForAccess(tag); node.template = template; return node; } export function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral) { - if (node.tag !== tag || node.template !== template) { - return updateNode(createTaggedTemplate(tag, template, node), node); - } + return node.tag !== tag + || node.template !== template + ? updateNode(createTaggedTemplate(tag, template), node) + : node; + } + + export function createTypeAssertion(type: TypeNode, expression: Expression) { + const node = createSynthesizedNode(SyntaxKind.TypeAssertionExpression); + node.type = type; + node.expression = parenthesizePrefixOperand(expression); return node; } - export function createParen(expression: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.ParenthesizedExpression, location); + export function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression) { + return node.type !== type + || node.expression !== expression + ? updateNode(createTypeAssertion(type, expression), node) + : node; + } + + export function createParen(expression: Expression) { + const node = createSynthesizedNode(SyntaxKind.ParenthesizedExpression); node.expression = expression; return node; } export function updateParen(node: ParenthesizedExpression, expression: Expression) { - if (node.expression !== expression) { - return updateNode(createParen(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createParen(expression), node) + : node; } - export function createFunctionExpression(modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) { - const node = createNode(SyntaxKind.FunctionExpression, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + export function createFunctionExpression(modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block) { + const node = createSynthesizedNode(SyntaxKind.FunctionExpression); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; return node; } - export function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block) { - if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + export function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block) { + return node.name !== name + || node.modifiers !== modifiers + || node.asteriskToken !== asteriskToken + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } - export function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody, location?: TextRange, flags?: NodeFlags) { - const node = createNode(SyntaxKind.ArrowFunction, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + export function createArrowFunction(modifiers: Modifier[] | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody) { + const node = createSynthesizedNode(SyntaxKind.ArrowFunction); + node.modifiers = asNodeArray(modifiers); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(SyntaxKind.EqualsGreaterThanToken); @@ -542,97 +578,94 @@ namespace ts { return node; } - export function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: ConciseBody) { - if (node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body, /*location*/ node, node.flags), node); - } - return node; + export function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[] | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: ConciseBody) { + return node.modifiers !== modifiers + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body), node) + : node; } - export function createDelete(expression: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.DeleteExpression, location); + export function createDelete(expression: Expression) { + const node = createSynthesizedNode(SyntaxKind.DeleteExpression); node.expression = parenthesizePrefixOperand(expression); return node; } export function updateDelete(node: DeleteExpression, expression: Expression) { - if (node.expression !== expression) { - return updateNode(createDelete(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createDelete(expression), node) + : node; } - export function createTypeOf(expression: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.TypeOfExpression, location); + export function createTypeOf(expression: Expression) { + const node = createSynthesizedNode(SyntaxKind.TypeOfExpression); node.expression = parenthesizePrefixOperand(expression); return node; } export function updateTypeOf(node: TypeOfExpression, expression: Expression) { - if (node.expression !== expression) { - return updateNode(createTypeOf(expression, node), expression); - } - return node; + return node.expression !== expression + ? updateNode(createTypeOf(expression), node) + : node; } - export function createVoid(expression: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.VoidExpression, location); + export function createVoid(expression: Expression) { + const node = createSynthesizedNode(SyntaxKind.VoidExpression); node.expression = parenthesizePrefixOperand(expression); return node; } export function updateVoid(node: VoidExpression, expression: Expression) { - if (node.expression !== expression) { - return updateNode(createVoid(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createVoid(expression), node) + : node; } - export function createAwait(expression: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.AwaitExpression, location); + export function createAwait(expression: Expression) { + const node = createSynthesizedNode(SyntaxKind.AwaitExpression); node.expression = parenthesizePrefixOperand(expression); return node; } export function updateAwait(node: AwaitExpression, expression: Expression) { - if (node.expression !== expression) { - return updateNode(createAwait(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createAwait(expression), node) + : node; } - export function createPrefix(operator: PrefixUnaryOperator, operand: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.PrefixUnaryExpression, location); + export function createPrefix(operator: PrefixUnaryOperator, operand: Expression) { + const node = createSynthesizedNode(SyntaxKind.PrefixUnaryExpression); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; } export function updatePrefix(node: PrefixUnaryExpression, operand: Expression) { - if (node.operand !== operand) { - return updateNode(createPrefix(node.operator, operand, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPrefix(node.operator, operand), node) + : node; } - export function createPostfix(operand: Expression, operator: PostfixUnaryOperator, location?: TextRange) { - const node = createNode(SyntaxKind.PostfixUnaryExpression, location); + export function createPostfix(operand: Expression, operator: PostfixUnaryOperator) { + const node = createSynthesizedNode(SyntaxKind.PostfixUnaryExpression); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; } export function updatePostfix(node: PostfixUnaryExpression, operand: Expression) { - if (node.operand !== operand) { - return updateNode(createPostfix(operand, node.operator, node), node); - } - return node; + return node.operand !== operand + ? updateNode(createPostfix(operand, node.operator), node) + : node; } - export function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression, location?: TextRange) { - const operatorToken = typeof operator === "number" ? createToken(operator) : operator; + export function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression) { + const node = createSynthesizedNode(SyntaxKind.BinaryExpression); + const operatorToken = asToken(operator); const operatorKind = operatorToken.kind; - const node = createNode(SyntaxKind.BinaryExpression, location); node.left = parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, /*isLeftSideOfBinary*/ false, node.left); @@ -640,261 +673,276 @@ namespace ts { } export function updateBinary(node: BinaryExpression, left: Expression, right: Expression) { - if (node.left !== left || node.right !== right) { - return updateNode(createBinary(left, node.operatorToken, right, /*location*/ node), node); - } - return node; + return node.left !== left + || node.right !== right + ? updateNode(createBinary(left, node.operatorToken, right), node) + : node; } - export function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression, location?: TextRange): ConditionalExpression; - export function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression, location?: TextRange): ConditionalExpression; - export function createConditional(condition: Expression, questionTokenOrWhenTrue: QuestionToken | Expression, whenTrueOrWhenFalse: Expression, colonTokenOrLocation?: ColonToken | TextRange, whenFalse?: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.ConditionalExpression, whenFalse ? location : colonTokenOrLocation); + export function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + export function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; + export function createConditional(condition: Expression, questionTokenOrWhenTrue: QuestionToken | Expression, whenTrueOrWhenFalse: Expression, colonToken?: ColonToken, whenFalse?: Expression) { + const node = createSynthesizedNode(SyntaxKind.ConditionalExpression); node.condition = parenthesizeForConditionalHead(condition); - if (whenFalse) { - // second overload - node.questionToken = questionTokenOrWhenTrue; - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - node.colonToken = colonTokenOrLocation; - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenFalse); - } - else { - // first overload - node.questionToken = createToken(SyntaxKind.QuestionToken); - node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(questionTokenOrWhenTrue); - node.colonToken = createToken(SyntaxKind.ColonToken); - node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); - } + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(SyntaxKind.QuestionToken); + node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); + node.colonToken = whenFalse ? colonToken : createToken(SyntaxKind.ColonToken); + node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } export function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression) { - if (node.condition !== condition || node.whenTrue !== whenTrue || node.whenFalse !== whenFalse) { - return updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse, node), node); - } - return node; + return node.condition !== condition + || node.whenTrue !== whenTrue + || node.whenFalse !== whenFalse + ? updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse), node) + : node; } - export function createTemplateExpression(head: TemplateHead, templateSpans: TemplateSpan[], location?: TextRange) { - const node = createNode(SyntaxKind.TemplateExpression, location); + export function createTemplateExpression(head: TemplateHead, templateSpans: TemplateSpan[]) { + const node = createSynthesizedNode(SyntaxKind.TemplateExpression); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; } export function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: TemplateSpan[]) { - if (node.head !== head || node.templateSpans !== templateSpans) { - return updateNode(createTemplateExpression(head, templateSpans, node), node); - } + return node.head !== head + || node.templateSpans !== templateSpans + ? updateNode(createTemplateExpression(head, templateSpans), node) + : node; + } + + export function createYield(expression?: Expression): YieldExpression; + export function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression; + export function createYield(asteriskTokenOrExpression?: AsteriskToken | Expression, expression?: Expression) { + const node = createSynthesizedNode(SyntaxKind.YieldExpression); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === SyntaxKind.AsteriskToken ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== SyntaxKind.AsteriskToken ? asteriskTokenOrExpression : expression; return node; } - export function createYield(asteriskToken: AsteriskToken, expression: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.YieldExpression, location); - node.asteriskToken = asteriskToken; - node.expression = expression; - return node; + export function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression) { + return node.expression !== expression + || node.asteriskToken !== asteriskToken + ? updateNode(createYield(asteriskToken, expression), node) + : node; } - export function updateYield(node: YieldExpression, expression: Expression) { - if (node.expression !== expression) { - return updateNode(createYield(node.asteriskToken, expression, node), node); - } - return node; - } - - export function createSpread(expression: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.SpreadElement, location); + export function createSpread(expression: Expression) { + const node = createSynthesizedNode(SyntaxKind.SpreadElement); node.expression = parenthesizeExpressionForList(expression); return node; } export function updateSpread(node: SpreadElement, expression: Expression) { - if (node.expression !== expression) { - return updateNode(createSpread(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createSpread(expression), node) + : node; } - export function createClassExpression(modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[], location?: TextRange) { - const node = createNode(SyntaxKind.ClassExpression, location); + export function createClassExpression(modifiers: Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]) { + const node = createSynthesizedNode(SyntaxKind.ClassExpression); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } - export function updateClassExpression(node: ClassExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]) { - if (node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members, node), node); - } - return node; + export function updateClassExpression(node: ClassExpression, modifiers: Modifier[] | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]) { + return node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members), node) + : node; } - export function createOmittedExpression(location?: TextRange) { - const node = createNode(SyntaxKind.OmittedExpression, location); - return node; + export function createOmittedExpression() { + return createSynthesizedNode(SyntaxKind.OmittedExpression); } - export function createExpressionWithTypeArguments(typeArguments: TypeNode[], expression: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.ExpressionWithTypeArguments, location); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; + export function createExpressionWithTypeArguments(typeArguments: TypeNode[], expression: Expression) { + const node = createSynthesizedNode(SyntaxKind.ExpressionWithTypeArguments); node.expression = parenthesizeForAccess(expression); + node.typeArguments = asNodeArray(typeArguments); return node; } export function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: TypeNode[], expression: Expression) { - if (node.typeArguments !== typeArguments || node.expression !== expression) { - return updateNode(createExpressionWithTypeArguments(typeArguments, expression, node), node); - } + return node.typeArguments !== typeArguments + || node.expression !== expression + ? updateNode(createExpressionWithTypeArguments(typeArguments, expression), node) + : node; + } + + export function createAsExpression(expression: Expression, type: TypeNode) { + const node = createSynthesizedNode(SyntaxKind.AsExpression); + node.expression = expression; + node.type = type; return node; } + export function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode) { + return node.expression !== expression + || node.type !== type + ? updateNode(createAsExpression(expression, type), node) + : node; + } + + export function createNonNullExpression(expression: Expression) { + const node = createSynthesizedNode(SyntaxKind.NonNullExpression); + node.expression = parenthesizeForAccess(expression); + return node; + } + + export function updateNonNullExpression(node: NonNullExpression, expression: Expression) { + return node.expression !== expression + ? updateNode(createNonNullExpression(expression), node) + : node; + } // Misc - export function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail, location?: TextRange) { - const node = createNode(SyntaxKind.TemplateSpan, location); + export function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail) { + const node = createSynthesizedNode(SyntaxKind.TemplateSpan); node.expression = expression; node.literal = literal; return node; } export function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail) { - if (node.expression !== expression || node.literal !== literal) { - return updateNode(createTemplateSpan(expression, literal, node), node); - } - return node; + return node.expression !== expression + || node.literal !== literal + ? updateNode(createTemplateSpan(expression, literal), node) + : node; } // Element - export function createBlock(statements: Statement[], location?: TextRange, multiLine?: boolean, flags?: NodeFlags): Block { - const block = createNode(SyntaxKind.Block, location, flags); + export function createBlock(statements: Statement[], multiLine?: boolean): Block { + const block = createSynthesizedNode(SyntaxKind.Block); block.statements = createNodeArray(statements); - if (multiLine) { - block.multiLine = true; - } + if (multiLine) block.multiLine = multiLine; return block; } export function updateBlock(node: Block, statements: Statement[]) { - if (statements !== node.statements) { - return updateNode(createBlock(statements, /*location*/ node, node.multiLine, node.flags), node); - } - - return node; + return statements !== node.statements + ? updateNode(createBlock(statements, node.multiLine), node) + : node; } - export function createVariableStatement(modifiers: Modifier[], declarationList: VariableDeclarationList | VariableDeclaration[], location?: TextRange, flags?: NodeFlags): VariableStatement { - const node = createNode(SyntaxKind.VariableStatement, location, flags); + export function createVariableStatement(modifiers: Modifier[] | undefined, declarationList: VariableDeclarationList | VariableDeclaration[]) { + const node = createSynthesizedNode(SyntaxKind.VariableStatement); node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.modifiers = asNodeArray(modifiers); node.declarationList = isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; return node; } - export function updateVariableStatement(node: VariableStatement, modifiers: Modifier[], declarationList: VariableDeclarationList): VariableStatement { - if (node.modifiers !== modifiers || node.declarationList !== declarationList) { - return updateNode(createVariableStatement(modifiers, declarationList, /*location*/ node, node.flags), node); - } - return node; + export function updateVariableStatement(node: VariableStatement, modifiers: Modifier[] | undefined, declarationList: VariableDeclarationList) { + return node.modifiers !== modifiers + || node.declarationList !== declarationList + ? updateNode(createVariableStatement(modifiers, declarationList), node) + : node; } - export function createVariableDeclarationList(declarations: VariableDeclaration[], location?: TextRange, flags?: NodeFlags): VariableDeclarationList { - const node = createNode(SyntaxKind.VariableDeclarationList, location, flags); + export function createVariableDeclarationList(declarations: VariableDeclaration[], flags?: NodeFlags) { + const node = createSynthesizedNode(SyntaxKind.VariableDeclarationList); + node.flags |= flags; node.declarations = createNodeArray(declarations); return node; } export function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]) { - if (node.declarations !== declarations) { - return updateNode(createVariableDeclarationList(declarations, /*location*/ node, node.flags), node); - } - return node; + return node.declarations !== declarations + ? updateNode(createVariableDeclarationList(declarations, node.flags), node) + : node; } - export function createVariableDeclaration(name: string | BindingPattern | Identifier, type?: TypeNode, initializer?: Expression, location?: TextRange, flags?: NodeFlags): VariableDeclaration { - const node = createNode(SyntaxKind.VariableDeclaration, location, flags); - node.name = typeof name === "string" ? createIdentifier(name) : name; + export function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression) { + const node = createSynthesizedNode(SyntaxKind.VariableDeclaration); + node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; return node; } - export function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode, initializer: Expression) { - if (node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createVariableDeclaration(name, type, initializer, /*location*/ node, node.flags), node); - } - return node; + export function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined) { + return node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createVariableDeclaration(name, type, initializer), node) + : node; } - export function createEmptyStatement(location: TextRange) { - return createNode(SyntaxKind.EmptyStatement, location); + export function createEmptyStatement() { + return createSynthesizedNode(SyntaxKind.EmptyStatement); } - export function createStatement(expression: Expression, location?: TextRange, flags?: NodeFlags): ExpressionStatement { - const node = createNode(SyntaxKind.ExpressionStatement, location, flags); + export function createStatement(expression: Expression) { + const node = createSynthesizedNode(SyntaxKind.ExpressionStatement); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } export function updateStatement(node: ExpressionStatement, expression: Expression) { - if (node.expression !== expression) { - return updateNode(createStatement(expression, /*location*/ node, node.flags), node); - } - - return node; + return node.expression !== expression + ? updateNode(createStatement(expression), node) + : node; } - export function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement, location?: TextRange) { - const node = createNode(SyntaxKind.IfStatement, location); + export function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement) { + const node = createSynthesizedNode(SyntaxKind.IfStatement); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; return node; } - export function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement) { - if (node.expression !== expression || node.thenStatement !== thenStatement || node.elseStatement !== elseStatement) { - return updateNode(createIf(expression, thenStatement, elseStatement, /*location*/ node), node); - } - return node; + export function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement | undefined) { + return node.expression !== expression + || node.thenStatement !== thenStatement + || node.elseStatement !== elseStatement + ? updateNode(createIf(expression, thenStatement, elseStatement), node) + : node; } - export function createDo(statement: Statement, expression: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.DoStatement, location); + export function createDo(statement: Statement, expression: Expression) { + const node = createSynthesizedNode(SyntaxKind.DoStatement); node.statement = statement; node.expression = expression; return node; } export function updateDo(node: DoStatement, statement: Statement, expression: Expression) { - if (node.statement !== statement || node.expression !== expression) { - return updateNode(createDo(statement, expression, node), node); - } - return node; + return node.statement !== statement + || node.expression !== expression + ? updateNode(createDo(statement, expression), node) + : node; } - export function createWhile(expression: Expression, statement: Statement, location?: TextRange) { - const node = createNode(SyntaxKind.WhileStatement, location); + export function createWhile(expression: Expression, statement: Statement) { + const node = createSynthesizedNode(SyntaxKind.WhileStatement); node.expression = expression; node.statement = statement; return node; } export function updateWhile(node: WhileStatement, expression: Expression, statement: Statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWhile(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWhile(expression, statement), node) + : node; } - export function createFor(initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement, location?: TextRange) { - const node = createNode(SyntaxKind.ForStatement, location, /*flags*/ undefined); + export function createFor(initializer: ForInitializer | undefined, condition: Expression | undefined, incrementor: Expression | undefined, statement: Statement) { + const node = createSynthesizedNode(SyntaxKind.ForStatement); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -902,15 +950,17 @@ namespace ts { return node; } - export function updateFor(node: ForStatement, initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement) { - if (node.initializer !== initializer || node.condition !== condition || node.incrementor !== incrementor || node.statement !== statement) { - return updateNode(createFor(initializer, condition, incrementor, statement, node), node); - } - return node; + export function updateFor(node: ForStatement, initializer: ForInitializer | undefined, condition: Expression | undefined, incrementor: Expression | undefined, statement: Statement) { + return node.initializer !== initializer + || node.condition !== condition + || node.incrementor !== incrementor + || node.statement !== statement + ? updateNode(createFor(initializer, condition, incrementor, statement), node) + : node; } - export function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement, location?: TextRange) { - const node = createNode(SyntaxKind.ForInStatement, location); + export function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement) { + const node = createSynthesizedNode(SyntaxKind.ForInStatement); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -918,324 +968,412 @@ namespace ts { } export function updateForIn(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForIn(initializer, expression, statement, node), node); - } - return node; + return node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForIn(initializer, expression, statement), node) + : node; } - export function createForOf(initializer: ForInitializer, expression: Expression, statement: Statement, location?: TextRange) { - const node = createNode(SyntaxKind.ForOfStatement, location); + export function createForOf(awaitModifier: AwaitKeywordToken, initializer: ForInitializer, expression: Expression, statement: Statement) { + const node = createSynthesizedNode(SyntaxKind.ForOfStatement); + node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; node.statement = statement; return node; } - export function updateForOf(node: ForOfStatement, initializer: ForInitializer, expression: Expression, statement: Statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForOf(initializer, expression, statement, node), node); - } + export function updateForOf(node: ForOfStatement, awaitModifier: AwaitKeywordToken, initializer: ForInitializer, expression: Expression, statement: Statement) { + return node.awaitModifier !== awaitModifier + || node.initializer !== initializer + || node.expression !== expression + || node.statement !== statement + ? updateNode(createForOf(awaitModifier, initializer, expression, statement), node) + : node; + } + + export function createContinue(label?: string | Identifier): ContinueStatement { + const node = createSynthesizedNode(SyntaxKind.ContinueStatement); + node.label = asName(label); return node; } - export function createContinue(label?: Identifier, location?: TextRange): ContinueStatement { - const node = createNode(SyntaxKind.ContinueStatement, location); - if (label) { - node.label = label; - } + export function updateContinue(node: ContinueStatement, label: Identifier | undefined) { + return node.label !== label + ? updateNode(createContinue(label), node) + : node; + } + + export function createBreak(label?: string | Identifier): BreakStatement { + const node = createSynthesizedNode(SyntaxKind.BreakStatement); + node.label = asName(label); return node; } - export function updateContinue(node: ContinueStatement, label: Identifier) { - if (node.label !== label) { - return updateNode(createContinue(label, node), node); - } - return node; + export function updateBreak(node: BreakStatement, label: Identifier | undefined) { + return node.label !== label + ? updateNode(createBreak(label), node) + : node; } - export function createBreak(label?: Identifier, location?: TextRange): BreakStatement { - const node = createNode(SyntaxKind.BreakStatement, location); - if (label) { - node.label = label; - } - return node; - } - - export function updateBreak(node: BreakStatement, label: Identifier) { - if (node.label !== label) { - return updateNode(createBreak(label, node), node); - } - return node; - } - - export function createReturn(expression?: Expression, location?: TextRange): ReturnStatement { - const node = createNode(SyntaxKind.ReturnStatement, location); + export function createReturn(expression?: Expression): ReturnStatement { + const node = createSynthesizedNode(SyntaxKind.ReturnStatement); node.expression = expression; return node; } - export function updateReturn(node: ReturnStatement, expression: Expression) { - if (node.expression !== expression) { - return updateNode(createReturn(expression, /*location*/ node), node); - } - return node; + export function updateReturn(node: ReturnStatement, expression: Expression | undefined) { + return node.expression !== expression + ? updateNode(createReturn(expression), node) + : node; } - export function createWith(expression: Expression, statement: Statement, location?: TextRange) { - const node = createNode(SyntaxKind.WithStatement, location); + export function createWith(expression: Expression, statement: Statement) { + const node = createSynthesizedNode(SyntaxKind.WithStatement); node.expression = expression; node.statement = statement; return node; } export function updateWith(node: WithStatement, expression: Expression, statement: Statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWith(expression, statement, node), node); - } - return node; + return node.expression !== expression + || node.statement !== statement + ? updateNode(createWith(expression, statement), node) + : node; } - export function createSwitch(expression: Expression, caseBlock: CaseBlock, location?: TextRange): SwitchStatement { - const node = createNode(SyntaxKind.SwitchStatement, location); + export function createSwitch(expression: Expression, caseBlock: CaseBlock): SwitchStatement { + const node = createSynthesizedNode(SyntaxKind.SwitchStatement); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; } export function updateSwitch(node: SwitchStatement, expression: Expression, caseBlock: CaseBlock) { - if (node.expression !== expression || node.caseBlock !== caseBlock) { - return updateNode(createSwitch(expression, caseBlock, node), node); - } - return node; + return node.expression !== expression + || node.caseBlock !== caseBlock + ? updateNode(createSwitch(expression, caseBlock), node) + : node; } - export function createLabel(label: string | Identifier, statement: Statement, location?: TextRange) { - const node = createNode(SyntaxKind.LabeledStatement, location); - node.label = typeof label === "string" ? createIdentifier(label) : label; + export function createLabel(label: string | Identifier, statement: Statement) { + const node = createSynthesizedNode(SyntaxKind.LabeledStatement); + node.label = asName(label); node.statement = statement; return node; } export function updateLabel(node: LabeledStatement, label: Identifier, statement: Statement) { - if (node.label !== label || node.statement !== statement) { - return updateNode(createLabel(label, statement, node), node); - } - return node; + return node.label !== label + || node.statement !== statement + ? updateNode(createLabel(label, statement), node) + : node; } - export function createThrow(expression: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.ThrowStatement, location); + export function createThrow(expression: Expression) { + const node = createSynthesizedNode(SyntaxKind.ThrowStatement); node.expression = expression; return node; } export function updateThrow(node: ThrowStatement, expression: Expression) { - if (node.expression !== expression) { - return updateNode(createThrow(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createThrow(expression), node) + : node; } - export function createTry(tryBlock: Block, catchClause: CatchClause, finallyBlock: Block, location?: TextRange) { - const node = createNode(SyntaxKind.TryStatement, location); + export function createTry(tryBlock: Block, catchClause: CatchClause | undefined, finallyBlock: Block | undefined) { + const node = createSynthesizedNode(SyntaxKind.TryStatement); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; return node; } - export function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause, finallyBlock: Block) { - if (node.tryBlock !== tryBlock || node.catchClause !== catchClause || node.finallyBlock !== finallyBlock) { - return updateNode(createTry(tryBlock, catchClause, finallyBlock, node), node); - } - return node; + export function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause | undefined, finallyBlock: Block | undefined) { + return node.tryBlock !== tryBlock + || node.catchClause !== catchClause + || node.finallyBlock !== finallyBlock + ? updateNode(createTry(tryBlock, catchClause, finallyBlock), node) + : node; } - export function createCaseBlock(clauses: CaseOrDefaultClause[], location?: TextRange): CaseBlock { - const node = createNode(SyntaxKind.CaseBlock, location); - node.clauses = createNodeArray(clauses); - return node; - } - - export function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]) { - if (node.clauses !== clauses) { - return updateNode(createCaseBlock(clauses, node), node); - } - return node; - } - - export function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) { - const node = createNode(SyntaxKind.FunctionDeclaration, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + export function createFunctionDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { + const node = createSynthesizedNode(SyntaxKind.FunctionDeclaration); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; return node; } - export function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); - } - return node; + export function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.asteriskToken !== asteriskToken + || node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.body !== body + ? updateNode(createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) + : node; } - export function createClassDeclaration(decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[], location?: TextRange) { - const node = createNode(SyntaxKind.ClassDeclaration, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); + export function createClassDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]) { + const node = createSynthesizedNode(SyntaxKind.ClassDeclaration); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); node.members = createNodeArray(members); return node; } - export function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, node), node); - } + export function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node) + : node; + } + + export function createEnumDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, members: EnumMember[]) { + const node = createSynthesizedNode(SyntaxKind.EnumDeclaration); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.members = createNodeArray(members); return node; } - export function createImportDeclaration(decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier?: Expression, location?: TextRange): ImportDeclaration { - const node = createNode(SyntaxKind.ImportDeclaration, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + export function updateEnumDeclaration(node: EnumDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, members: EnumMember[]) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.members !== members + ? updateNode(createEnumDeclaration(decorators, modifiers, name, members), node) + : node; + } + + export function createModuleDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags) { + const node = createSynthesizedNode(SyntaxKind.ModuleDeclaration); + node.flags |= flags; + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = name; + node.body = body; + return node; + } + + export function updateModuleDeclaration(node: ModuleDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.body !== body + ? updateNode(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node) + : node; + } + + export function createModuleBlock(statements: Statement[]) { + const node = createSynthesizedNode(SyntaxKind.CaseBlock); + node.statements = createNodeArray(statements); + return node; + } + + export function updateModuleBlock(node: ModuleBlock, statements: Statement[]) { + return node.statements !== statements + ? updateNode(createModuleBlock(statements), node) + : node; + } + + export function createCaseBlock(clauses: CaseOrDefaultClause[]): CaseBlock { + const node = createSynthesizedNode(SyntaxKind.CaseBlock); + node.clauses = createNodeArray(clauses); + return node; + } + + export function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]) { + return node.clauses !== clauses + ? updateNode(createCaseBlock(clauses), node) + : node; + } + + export function createImportEqualsDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, moduleReference: ModuleReference) { + const node = createSynthesizedNode(SyntaxKind.ImportEqualsDeclaration); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.moduleReference = moduleReference; + return node; + } + + export function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, moduleReference: ModuleReference) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.moduleReference !== moduleReference + ? updateNode(createImportEqualsDeclaration(decorators, modifiers, name, moduleReference), node) + : node; + } + + export function createImportDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier?: Expression): ImportDeclaration { + const node = createSynthesizedNode(SyntaxKind.ImportDeclaration); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; return node; } - export function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier: Expression) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, node), node); - } - return node; + export function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression | undefined) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node) + : node; } - export function createImportClause(name: Identifier, namedBindings: NamedImportBindings, location?: TextRange): ImportClause { - const node = createNode(SyntaxKind.ImportClause, location); + export function createImportClause(name: Identifier, namedBindings: NamedImportBindings): ImportClause { + const node = createSynthesizedNode(SyntaxKind.ImportClause); node.name = name; node.namedBindings = namedBindings; return node; } export function updateImportClause(node: ImportClause, name: Identifier, namedBindings: NamedImportBindings) { - if (node.name !== name || node.namedBindings !== namedBindings) { - return updateNode(createImportClause(name, namedBindings, node), node); - } - return node; + return node.name !== name + || node.namedBindings !== namedBindings + ? updateNode(createImportClause(name, namedBindings), node) + : node; } - export function createNamespaceImport(name: Identifier, location?: TextRange): NamespaceImport { - const node = createNode(SyntaxKind.NamespaceImport, location); + export function createNamespaceImport(name: Identifier): NamespaceImport { + const node = createSynthesizedNode(SyntaxKind.NamespaceImport); node.name = name; return node; } export function updateNamespaceImport(node: NamespaceImport, name: Identifier) { - if (node.name !== name) { - return updateNode(createNamespaceImport(name, node), node); - } - return node; + return node.name !== name + ? updateNode(createNamespaceImport(name), node) + : node; } - export function createNamedImports(elements: ImportSpecifier[], location?: TextRange): NamedImports { - const node = createNode(SyntaxKind.NamedImports, location); + export function createNamedImports(elements: ImportSpecifier[]): NamedImports { + const node = createSynthesizedNode(SyntaxKind.NamedImports); node.elements = createNodeArray(elements); return node; } export function updateNamedImports(node: NamedImports, elements: ImportSpecifier[]) { - if (node.elements !== elements) { - return updateNode(createNamedImports(elements, node), node); - } - return node; + return node.elements !== elements + ? updateNode(createNamedImports(elements), node) + : node; } - export function createImportSpecifier(propertyName: Identifier, name: Identifier, location?: TextRange) { - const node = createNode(SyntaxKind.ImportSpecifier, location); + export function createImportSpecifier(propertyName: Identifier | undefined, name: Identifier) { + const node = createSynthesizedNode(SyntaxKind.ImportSpecifier); node.propertyName = propertyName; node.name = name; return node; } - export function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier, name: Identifier) { - if (node.propertyName !== propertyName || node.name !== name) { - return updateNode(createImportSpecifier(propertyName, name, node), node); - } - return node; + export function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier) { + return node.propertyName !== propertyName + || node.name !== name + ? updateNode(createImportSpecifier(propertyName, name), node) + : node; } - export function createExportAssignment(decorators: Decorator[], modifiers: Modifier[], isExportEquals: boolean, expression: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.ExportAssignment, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + export function createExportAssignment(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, isExportEquals: boolean, expression: Expression) { + const node = createSynthesizedNode(SyntaxKind.ExportAssignment); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; node.expression = expression; return node; } - export function updateExportAssignment(node: ExportAssignment, decorators: Decorator[], modifiers: Modifier[], expression: Expression) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.expression !== expression) { - return updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression, node), node); - } - return node; + export function updateExportAssignment(node: ExportAssignment, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, expression: Expression) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.expression !== expression + ? updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node) + : node; } - export function createExportDeclaration(decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier?: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.ExportDeclaration, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + export function createExportDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression) { + const node = createSynthesizedNode(SyntaxKind.ExportDeclaration); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; return node; } - export function updateExportDeclaration(node: ExportDeclaration, decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier: Expression) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.exportClause !== exportClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, node), node); - } - return node; + export function updateExportDeclaration(node: ExportDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.exportClause !== exportClause + || node.moduleSpecifier !== moduleSpecifier + ? updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier), node) + : node; } - export function createNamedExports(elements: ExportSpecifier[], location?: TextRange) { - const node = createNode(SyntaxKind.NamedExports, location); + export function createNamedExports(elements: ExportSpecifier[]) { + const node = createSynthesizedNode(SyntaxKind.NamedExports); node.elements = createNodeArray(elements); return node; } export function updateNamedExports(node: NamedExports, elements: ExportSpecifier[]) { - if (node.elements !== elements) { - return updateNode(createNamedExports(elements, node), node); - } + return node.elements !== elements + ? updateNode(createNamedExports(elements), node) + : node; + } + + export function createExportSpecifier(propertyName: string | Identifier | undefined, name: string | Identifier) { + const node = createSynthesizedNode(SyntaxKind.ExportSpecifier); + node.propertyName = asName(propertyName); + node.name = asName(name); return node; } - export function createExportSpecifier(name: string | Identifier, propertyName?: string | Identifier, location?: TextRange) { - const node = createNode(SyntaxKind.ExportSpecifier, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + export function updateExportSpecifier(node: ExportSpecifier, propertyName: Identifier | undefined, name: Identifier) { + return node.propertyName !== propertyName + || node.name !== name + ? updateNode(createExportSpecifier(propertyName, name), node) + : node; + } + + // Module references + + export function createExternalModuleReference(expression: Expression) { + const node = createSynthesizedNode(SyntaxKind.ExternalModuleReference); + node.expression = expression; return node; } - export function updateExportSpecifier(node: ExportSpecifier, name: Identifier, propertyName: Identifier) { - if (node.name !== name || node.propertyName !== propertyName) { - return updateNode(createExportSpecifier(name, propertyName, node), node); - } - return node; + export function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression) { + return node.expression !== expression + ? updateNode(createExternalModuleReference(expression), node) + : node; } // JSX - export function createJsxElement(openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement, location?: TextRange) { - const node = createNode(SyntaxKind.JsxElement, location); + export function createJsxElement(openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement) { + const node = createSynthesizedNode(SyntaxKind.JsxElement); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -1243,98 +1381,109 @@ namespace ts { } export function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement) { - if (node.openingElement !== openingElement || node.children !== children || node.closingElement !== closingElement) { - return updateNode(createJsxElement(openingElement, children, closingElement, node), node); - } - return node; + return node.openingElement !== openingElement + || node.children !== children + || node.closingElement !== closingElement + ? updateNode(createJsxElement(openingElement, children, closingElement), node) + : node; } - export function createJsxSelfClosingElement(tagName: JsxTagNameExpression, attributes: JsxAttributeLike[], location?: TextRange) { - const node = createNode(SyntaxKind.JsxSelfClosingElement, location); + export function createJsxSelfClosingElement(tagName: JsxTagNameExpression, attributes: JsxAttributes) { + const node = createSynthesizedNode(SyntaxKind.JsxSelfClosingElement); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } - export function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, attributes: JsxAttributeLike[]) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxSelfClosingElement(tagName, attributes, node), node); - } - return node; + export function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, attributes: JsxAttributes) { + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxSelfClosingElement(tagName, attributes), node) + : node; } - export function createJsxOpeningElement(tagName: JsxTagNameExpression, attributes: JsxAttributeLike[], location?: TextRange) { - const node = createNode(SyntaxKind.JsxOpeningElement, location); + export function createJsxOpeningElement(tagName: JsxTagNameExpression, attributes: JsxAttributes) { + const node = createSynthesizedNode(SyntaxKind.JsxOpeningElement); node.tagName = tagName; - node.attributes = createNodeArray(attributes); + node.attributes = attributes; return node; } - export function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, attributes: JsxAttributeLike[]) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxOpeningElement(tagName, attributes, node), node); - } - return node; + export function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, attributes: JsxAttributes) { + return node.tagName !== tagName + || node.attributes !== attributes + ? updateNode(createJsxOpeningElement(tagName, attributes), node) + : node; } - export function createJsxClosingElement(tagName: JsxTagNameExpression, location?: TextRange) { - const node = createNode(SyntaxKind.JsxClosingElement, location); + export function createJsxClosingElement(tagName: JsxTagNameExpression) { + const node = createSynthesizedNode(SyntaxKind.JsxClosingElement); node.tagName = tagName; return node; } export function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression) { - if (node.tagName !== tagName) { - return updateNode(createJsxClosingElement(tagName, node), node); - } - return node; + return node.tagName !== tagName + ? updateNode(createJsxClosingElement(tagName), node) + : node; } - export function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression, location?: TextRange) { - const node = createNode(SyntaxKind.JsxAttribute, location); + export function createJsxAttributes(properties: JsxAttributeLike[]) { + const jsxAttributes = createSynthesizedNode(SyntaxKind.JsxAttributes); + jsxAttributes.properties = createNodeArray(properties); + return jsxAttributes; + } + + export function updateJsxAttributes(jsxAttributes: JsxAttributes, properties: JsxAttributeLike[]) { + if (jsxAttributes.properties !== properties) { + return updateNode(createJsxAttributes(properties), jsxAttributes); + } + return jsxAttributes; + } + + export function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression) { + const node = createSynthesizedNode(SyntaxKind.JsxAttribute); node.name = name; node.initializer = initializer; return node; } export function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression) { - if (node.name !== name || node.initializer !== initializer) { - return updateNode(createJsxAttribute(name, initializer, node), node); - } - return node; + return node.name !== name + || node.initializer !== initializer + ? updateNode(createJsxAttribute(name, initializer), node) + : node; } - export function createJsxSpreadAttribute(expression: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.JsxSpreadAttribute, location); + export function createJsxSpreadAttribute(expression: Expression) { + const node = createSynthesizedNode(SyntaxKind.JsxSpreadAttribute); node.expression = expression; return node; } export function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression) { - if (node.expression !== expression) { - return updateNode(createJsxSpreadAttribute(expression, node), node); - } - return node; + return node.expression !== expression + ? updateNode(createJsxSpreadAttribute(expression), node) + : node; } - export function createJsxExpression(expression: Expression, dotDotDotToken: Token, location?: TextRange) { - const node = createNode(SyntaxKind.JsxExpression, location); + export function createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined) { + const node = createSynthesizedNode(SyntaxKind.JsxExpression); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; } - export function updateJsxExpression(node: JsxExpression, expression: Expression) { - if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node.dotDotDotToken, node), node); - } - return node; + export function updateJsxExpression(node: JsxExpression, expression: Expression | undefined) { + return node.expression !== expression + ? updateNode(createJsxExpression(node.dotDotDotToken, expression), node) + : node; } // Clauses - export function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[], location?: TextRange) { - const node = createNode(SyntaxKind.HeritageClause, location); + export function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[]) { + const node = createSynthesizedNode(SyntaxKind.HeritageClause); node.token = token; node.types = createNodeArray(types); return node; @@ -1342,13 +1491,13 @@ namespace ts { export function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]) { if (node.types !== types) { - return updateNode(createHeritageClause(node.token, types, node), node); + return updateNode(createHeritageClause(node.token, types), node); } return node; } - export function createCaseClause(expression: Expression, statements: Statement[], location?: TextRange) { - const node = createNode(SyntaxKind.CaseClause, location); + export function createCaseClause(expression: Expression, statements: Statement[]) { + const node = createSynthesizedNode(SyntaxKind.CaseClause); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -1356,26 +1505,26 @@ namespace ts { export function updateCaseClause(node: CaseClause, expression: Expression, statements: Statement[]) { if (node.expression !== expression || node.statements !== statements) { - return updateNode(createCaseClause(expression, statements, node), node); + return updateNode(createCaseClause(expression, statements), node); } return node; } - export function createDefaultClause(statements: Statement[], location?: TextRange) { - const node = createNode(SyntaxKind.DefaultClause, location); + export function createDefaultClause(statements: Statement[]) { + const node = createSynthesizedNode(SyntaxKind.DefaultClause); node.statements = createNodeArray(statements); return node; } export function updateDefaultClause(node: DefaultClause, statements: Statement[]) { if (node.statements !== statements) { - return updateNode(createDefaultClause(statements, node), node); + return updateNode(createDefaultClause(statements), node); } return node; } - export function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block, location?: TextRange) { - const node = createNode(SyntaxKind.CatchClause, location); + export function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block) { + const node = createSynthesizedNode(SyntaxKind.CatchClause); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -1383,16 +1532,16 @@ namespace ts { export function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block) { if (node.variableDeclaration !== variableDeclaration || node.block !== block) { - return updateNode(createCatchClause(variableDeclaration, block, node), node); + return updateNode(createCatchClause(variableDeclaration, block), node); } return node; } // Property assignments - export function createPropertyAssignment(name: string | PropertyName, initializer: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.PropertyAssignment, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; + export function createPropertyAssignment(name: string | PropertyName, initializer: Expression) { + const node = createSynthesizedNode(SyntaxKind.PropertyAssignment); + node.name = asName(name); node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; return node; @@ -1400,43 +1549,60 @@ namespace ts { export function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression) { if (node.name !== name || node.initializer !== initializer) { - return updateNode(createPropertyAssignment(name, initializer, node), node); + return updateNode(createPropertyAssignment(name, initializer), node); } return node; } - export function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.ShorthandPropertyAssignment, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; + export function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer?: Expression) { + const node = createSynthesizedNode(SyntaxKind.ShorthandPropertyAssignment); + node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } - export function createSpreadAssignment(expression: Expression, location?: TextRange) { - const node = createNode(SyntaxKind.SpreadAssignment, location); - node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; + export function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression | undefined) { + if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { + return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node); + } return node; } - export function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression) { - if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { - return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node); - } + export function createSpreadAssignment(expression: Expression) { + const node = createSynthesizedNode(SyntaxKind.SpreadAssignment); + node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; return node; } export function updateSpreadAssignment(node: SpreadAssignment, expression: Expression) { if (node.expression !== expression) { - return updateNode(createSpreadAssignment(expression, node), node); + return updateNode(createSpreadAssignment(expression), node); } return node; } + // Enum + + export function createEnumMember(name: string | PropertyName, initializer?: Expression) { + const node = createSynthesizedNode(SyntaxKind.EnumMember); + node.name = asName(name); + node.initializer = initializer && parenthesizeExpressionForList(initializer); + return node; + } + + export function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined) { + return node.name !== name + || node.initializer !== initializer + ? updateNode(createEnumMember(name, initializer), node) + : node; + } + // Top-level nodes export function updateSourceFileNode(node: SourceFile, statements: Statement[]) { if (node.statements !== statements) { - const updated = createNode(SyntaxKind.SourceFile, /*location*/ node, node.flags); + const updated = createSynthesizedNode(SyntaxKind.SourceFile); + updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -1472,6 +1638,17 @@ namespace ts { return node; } + /** + * Creates a shallow, memberwise clone of a node for mutation. + */ + export function getMutableClone(node: T): T { + const clone = getSynthesizedClone(node); + clone.pos = node.pos; + clone.end = node.end; + clone.parent = node.parent; + return clone; + } + // Transformation nodes /** @@ -1481,8 +1658,9 @@ namespace ts { * @param original The original statement. */ export function createNotEmittedStatement(original: Node) { - const node = createNode(SyntaxKind.NotEmittedStatement, /*location*/ original); + const node = createSynthesizedNode(SyntaxKind.NotEmittedStatement); node.original = original; + setTextRange(node, original); return node; } @@ -1490,8 +1668,9 @@ namespace ts { * Creates a synthetic element to act as a placeholder for the end of an emitted declaration in * order to properly emit exports. */ + /* @internal */ export function createEndOfDeclarationMarker(original: Node) { - const node = createNode(SyntaxKind.EndOfDeclarationMarker); + const node = createSynthesizedNode(SyntaxKind.EndOfDeclarationMarker); node.emitNode = {}; node.original = original; return node; @@ -1501,8 +1680,9 @@ namespace ts { * Creates a synthetic element to act as a placeholder for the beginning of a merged declaration in * order to properly emit exports. */ + /* @internal */ export function createMergeDeclarationMarker(original: Node) { - const node = createNode(SyntaxKind.MergeDeclarationMarker); + const node = createSynthesizedNode(SyntaxKind.MergeDeclarationMarker); node.emitNode = {}; node.original = original; return node; @@ -1516,16 +1696,30 @@ namespace ts { * @param original The original outer expression. * @param location The location for the expression. Defaults to the positions from "original" if provided. */ - export function createPartiallyEmittedExpression(expression: Expression, original?: Node, location?: TextRange) { - const node = createNode(SyntaxKind.PartiallyEmittedExpression, /*location*/ location || original); + export function createPartiallyEmittedExpression(expression: Expression, original?: Node) { + const node = createSynthesizedNode(SyntaxKind.PartiallyEmittedExpression); node.expression = expression; node.original = original; + setTextRange(node, original); return node; } export function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression) { if (node.expression !== expression) { - return updateNode(createPartiallyEmittedExpression(expression, node.original, node), node); + return updateNode(createPartiallyEmittedExpression(expression, node.original), node); + } + return node; + } + + export function createBundle(sourceFiles: SourceFile[]) { + const node = createNode(SyntaxKind.Bundle); + node.sourceFiles = sourceFiles; + return node; + } + + export function updateBundle(node: Bundle, sourceFiles: SourceFile[]) { + if (node.sourceFiles !== sourceFiles) { + return createBundle(sourceFiles); } return node; } @@ -1536,14 +1730,14 @@ namespace ts { return createBinary(left, SyntaxKind.CommaToken, right); } - export function createLessThan(left: Expression, right: Expression, location?: TextRange) { - return createBinary(left, SyntaxKind.LessThanToken, right, location); + export function createLessThan(left: Expression, right: Expression) { + return createBinary(left, SyntaxKind.LessThanToken, right); } - export function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression, location?: TextRange): DestructuringAssignment; - export function createAssignment(left: Expression, right: Expression, location?: TextRange): BinaryExpression; - export function createAssignment(left: Expression, right: Expression, location?: TextRange) { - return createBinary(left, SyntaxKind.EqualsToken, right, location); + export function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; + export function createAssignment(left: Expression, right: Expression): BinaryExpression; + export function createAssignment(left: Expression, right: Expression) { + return createBinary(left, SyntaxKind.EqualsToken, right); } export function createStrictEquality(left: Expression, right: Expression) { @@ -1562,8 +1756,8 @@ namespace ts { return createBinary(left, SyntaxKind.MinusToken, right); } - export function createPostfixIncrement(operand: Expression, location?: TextRange) { - return createPostfix(operand, SyntaxKind.PlusPlusToken, location); + export function createPostfixIncrement(operand: Expression) { + return createPostfix(operand, SyntaxKind.PlusPlusToken); } export function createLogicalAnd(left: Expression, right: Expression) { @@ -1582,6 +1776,330 @@ namespace ts { return createVoid(createLiteral(0)); } + export function createExportDefault(expression: Expression) { + return createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportEquals*/ false, expression); + } + + export function createExternalModuleExport(exportName: Identifier) { + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(/*propertyName*/ undefined, exportName)])); + } + + // Utilities + + function asName(name: string | Identifier): Identifier; + function asName(name: string | BindingName): BindingName; + function asName(name: string | PropertyName): PropertyName; + function asName(name: string | Identifier | BindingName | PropertyName) { + return typeof name === "string" ? createIdentifier(name) : name; + } + + function asExpression(value: string | number | Expression) { + return typeof value === "string" || typeof value === "number" ? createLiteral(value) : value; + } + + function asNodeArray(array: T[] | undefined): NodeArray | undefined { + return array ? createNodeArray(array) : undefined; + } + + function asToken(value: TKind | Token): Token { + return typeof value === "number" ? createToken(value) : value; + } + + /** + * Clears any EmitNode entries from parse-tree nodes. + * @param sourceFile A source file. + */ + export function disposeEmitNodes(sourceFile: SourceFile) { + // During transformation we may need to annotate a parse tree node with transient + // transformation properties. As parse tree nodes live longer than transformation + // nodes, we need to make sure we reclaim any memory allocated for custom ranges + // from these nodes to ensure we do not hold onto entire subtrees just for position + // information. We also need to reset these nodes to a pre-transformation state + // for incremental parsing scenarios so that we do not impact later emit. + sourceFile = getSourceFileOfNode(getParseTreeNode(sourceFile)); + const emitNode = sourceFile && sourceFile.emitNode; + const annotatedNodes = emitNode && emitNode.annotatedNodes; + if (annotatedNodes) { + for (const node of annotatedNodes) { + node.emitNode = undefined; + } + } + } + + /** + * Associates a node with the current transformation, initializing + * various transient transformation properties. + */ + /* @internal */ + export function getOrCreateEmitNode(node: Node) { + if (!node.emitNode) { + if (isParseTreeNode(node)) { + // To avoid holding onto transformation artifacts, we keep track of any + // parse tree node we are annotating. This allows us to clean them up after + // all transformations have completed. + if (node.kind === SyntaxKind.SourceFile) { + return node.emitNode = { annotatedNodes: [node] }; + } + + const sourceFile = getSourceFileOfNode(node); + getOrCreateEmitNode(sourceFile).annotatedNodes.push(node); + } + + node.emitNode = {}; + } + + return node.emitNode; + } + + export function setTextRange(range: T, location: TextRange | undefined): T { + if (location) { + range.pos = location.pos; + range.end = location.end; + } + return range; + } + + /** + * Gets flags that control emit behavior of a node. + */ + export function getEmitFlags(node: Node): EmitFlags | undefined { + const emitNode = node.emitNode; + return emitNode && emitNode.flags; + } + + /** + * Sets flags that control emit behavior of a node. + */ + export function setEmitFlags(node: T, emitFlags: EmitFlags) { + getOrCreateEmitNode(node).flags = emitFlags; + return node; + } + + /** + * Gets a custom text range to use when emitting source maps. + */ + export function getSourceMapRange(node: Node) { + const emitNode = node.emitNode; + return (emitNode && emitNode.sourceMapRange) || node; + } + + /** + * Sets a custom text range to use when emitting source maps. + */ + export function setSourceMapRange(node: T, range: TextRange | undefined) { + getOrCreateEmitNode(node).sourceMapRange = range; + return node; + } + + /** + * Gets the TextRange to use for source maps for a token of a node. + */ + export function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange | undefined { + const emitNode = node.emitNode; + const tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; + return tokenSourceMapRanges && tokenSourceMapRanges[token]; + } + + /** + * Sets the TextRange to use for source maps for a token of a node. + */ + export function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange | undefined) { + const emitNode = getOrCreateEmitNode(node); + const tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = []); + tokenSourceMapRanges[token] = range; + return node; + } + + /** + * Gets a custom text range to use when emitting comments. + */ + export function getCommentRange(node: Node) { + const emitNode = node.emitNode; + return (emitNode && emitNode.commentRange) || node; + } + + /** + * Sets a custom text range to use when emitting comments. + */ + export function setCommentRange(node: T, range: TextRange) { + getOrCreateEmitNode(node).commentRange = range; + return node; + } + + export function getSyntheticLeadingComments(node: Node): SynthesizedComment[] | undefined { + const emitNode = node.emitNode; + return emitNode && emitNode.leadingComments; + } + + export function setSyntheticLeadingComments(node: T, comments: SynthesizedComment[]) { + getOrCreateEmitNode(node).leadingComments = comments; + return node; + } + + export function addSyntheticLeadingComment(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean) { + return setSyntheticLeadingComments(node, append(getSyntheticLeadingComments(node), { kind, pos: -1, end: -1, hasTrailingNewLine, text })); + } + + export function getSyntheticTrailingComments(node: Node): SynthesizedComment[] | undefined { + const emitNode = node.emitNode; + return emitNode && emitNode.trailingComments; + } + + export function setSyntheticTrailingComments(node: T, comments: SynthesizedComment[]) { + getOrCreateEmitNode(node).trailingComments = comments; + return node; + } + + export function addSyntheticTrailingComment(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean) { + return setSyntheticTrailingComments(node, append(getSyntheticTrailingComments(node), { kind, pos: -1, end: -1, hasTrailingNewLine, text })); + } + + /** + * Gets the constant value to emit for an expression. + */ + export function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression) { + const emitNode = node.emitNode; + return emitNode && emitNode.constantValue; + } + + /** + * Sets the constant value to emit for an expression. + */ + export function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number) { + const emitNode = getOrCreateEmitNode(node); + emitNode.constantValue = value; + return node; + } + + /** + * Adds an EmitHelper to a node. + */ + export function addEmitHelper(node: T, helper: EmitHelper): T { + const emitNode = getOrCreateEmitNode(node); + emitNode.helpers = append(emitNode.helpers, helper); + return node; + } + + /** + * Add EmitHelpers to a node. + */ + export function addEmitHelpers(node: T, helpers: EmitHelper[] | undefined): T { + if (some(helpers)) { + const emitNode = getOrCreateEmitNode(node); + for (const helper of helpers) { + if (!contains(emitNode.helpers, helper)) { + emitNode.helpers = append(emitNode.helpers, helper); + } + } + } + return node; + } + + /** + * Removes an EmitHelper from a node. + */ + export function removeEmitHelper(node: Node, helper: EmitHelper): boolean { + const emitNode = node.emitNode; + if (emitNode) { + const helpers = emitNode.helpers; + if (helpers) { + return orderedRemoveItem(helpers, helper); + } + } + return false; + } + + /** + * Gets the EmitHelpers of a node. + */ + export function getEmitHelpers(node: Node): EmitHelper[] | undefined { + const emitNode = node.emitNode; + return emitNode && emitNode.helpers; + } + + /** + * Moves matching emit helpers from a source node to a target node. + */ + export function moveEmitHelpers(source: Node, target: Node, predicate: (helper: EmitHelper) => boolean) { + const sourceEmitNode = source.emitNode; + const sourceEmitHelpers = sourceEmitNode && sourceEmitNode.helpers; + if (!some(sourceEmitHelpers)) return; + + const targetEmitNode = getOrCreateEmitNode(target); + let helpersRemoved = 0; + for (let i = 0; i < sourceEmitHelpers.length; i++) { + const helper = sourceEmitHelpers[i]; + if (predicate(helper)) { + helpersRemoved++; + if (!contains(targetEmitNode.helpers, helper)) { + targetEmitNode.helpers = append(targetEmitNode.helpers, helper); + } + } + else if (helpersRemoved > 0) { + sourceEmitHelpers[i - helpersRemoved] = helper; + } + } + + if (helpersRemoved > 0) { + sourceEmitHelpers.length -= helpersRemoved; + } + } + + /* @internal */ + export function compareEmitHelpers(x: EmitHelper, y: EmitHelper) { + if (x === y) return Comparison.EqualTo; + if (x.priority === y.priority) return Comparison.EqualTo; + if (x.priority === undefined) return Comparison.GreaterThan; + if (y.priority === undefined) return Comparison.LessThan; + return compareValues(x.priority, y.priority); + } + + export function setOriginalNode(node: T, original: Node | undefined): T { + node.original = original; + if (original) { + const emitNode = original.emitNode; + if (emitNode) node.emitNode = mergeEmitNode(emitNode, node.emitNode); + } + return node; + } + + function mergeEmitNode(sourceEmitNode: EmitNode, destEmitNode: EmitNode) { + const { + flags, + leadingComments, + trailingComments, + commentRange, + sourceMapRange, + tokenSourceMapRanges, + constantValue, + helpers + } = sourceEmitNode; + if (!destEmitNode) destEmitNode = {}; + if (leadingComments) destEmitNode.leadingComments = addRange(leadingComments.slice(), destEmitNode.leadingComments); + if (trailingComments) destEmitNode.trailingComments = addRange(trailingComments.slice(), destEmitNode.trailingComments); + if (flags) destEmitNode.flags = flags; + if (commentRange) destEmitNode.commentRange = commentRange; + if (sourceMapRange) destEmitNode.sourceMapRange = sourceMapRange; + if (tokenSourceMapRanges) destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); + if (constantValue !== undefined) destEmitNode.constantValue = constantValue; + if (helpers) destEmitNode.helpers = addRange(destEmitNode.helpers, helpers); + return destEmitNode; + } + + function mergeTokenSourceMapRanges(sourceRanges: TextRange[], destRanges: TextRange[]) { + if (!destRanges) destRanges = []; + for (const key in sourceRanges) { + destRanges[key] = sourceRanges[key]; + } + return destRanges; + } +} + +/* @internal */ +namespace ts { + + // Compound nodes + export type TypeOfTag = "undefined" | "number" | "boolean" | "string" | "symbol" | "object" | "function"; export function createTypeCheck(value: Expression, tag: TypeOfTag) { @@ -1592,35 +2110,43 @@ namespace ts { export function createMemberAccessForPropertyName(target: Expression, memberName: PropertyName, location?: TextRange): MemberExpression { if (isComputedPropertyName(memberName)) { - return createElementAccess(target, memberName.expression, location); + return setTextRange(createElementAccess(target, memberName.expression), location); } else { - const expression = isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); - (expression.emitNode || (expression.emitNode = {})).flags |= EmitFlags.NoNestedSourceMaps; + const expression = setTextRange( + isIdentifier(memberName) + ? createPropertyAccess(target, memberName) + : createElementAccess(target, memberName), + memberName + ); + getOrCreateEmitNode(expression).flags |= EmitFlags.NoNestedSourceMaps; return expression; } } export function createFunctionCall(func: Expression, thisArg: Expression, argumentsList: Expression[], location?: TextRange) { - return createCall( - createPropertyAccess(func, "call"), - /*typeArguments*/ undefined, - [ - thisArg, - ...argumentsList - ], + return setTextRange( + createCall( + createPropertyAccess(func, "call"), + /*typeArguments*/ undefined, + [ + thisArg, + ...argumentsList + ]), location ); } export function createFunctionApply(func: Expression, thisArg: Expression, argumentsExpression: Expression, location?: TextRange) { - return createCall( - createPropertyAccess(func, "apply"), - /*typeArguments*/ undefined, - [ - thisArg, - argumentsExpression - ], + return setTextRange( + createCall( + createPropertyAccess(func, "apply"), + /*typeArguments*/ undefined, + [ + thisArg, + argumentsExpression + ] + ), location ); } @@ -1643,10 +2169,12 @@ namespace ts { } export function createMathPow(left: Expression, right: Expression, location?: TextRange) { - return createCall( - createPropertyAccess(createIdentifier("Math"), "pow"), - /*typeArguments*/ undefined, - [left, right], + return setTextRange( + createCall( + createPropertyAccess(createIdentifier("Math"), "pow"), + /*typeArguments*/ undefined, + [left, right] + ), location ); } @@ -1666,7 +2194,7 @@ namespace ts { function createJsxFactoryExpressionFromEntityName(jsxFactory: EntityName, parent: JsxOpeningLikeElement): Expression { if (isQualifiedName(jsxFactory)) { const left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent); - const right = createSynthesizedNode(SyntaxKind.Identifier); + const right = createIdentifier(jsxFactory.right.text); right.text = jsxFactory.right.text; return createPropertyAccess(left, right); } @@ -1706,42 +2234,145 @@ namespace ts { } } - return createCall( - createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), - /*typeArguments*/ undefined, - argumentsList, + return setTextRange( + createCall( + createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), + /*typeArguments*/ undefined, + argumentsList + ), location ); } - export function createExportDefault(expression: Expression) { - return createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportEquals*/ false, expression); - } - - export function createExternalModuleExport(exportName: Identifier) { - return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(exportName)])); - } - - export function createLetStatement(name: Identifier, initializer: Expression, location?: TextRange) { - return createVariableStatement(/*modifiers*/ undefined, createLetDeclarationList([createVariableDeclaration(name, /*type*/ undefined, initializer)]), location); - } - - export function createLetDeclarationList(declarations: VariableDeclaration[], location?: TextRange) { - return createVariableDeclarationList(declarations, location, NodeFlags.Let); - } - - export function createConstDeclarationList(declarations: VariableDeclaration[], location?: TextRange) { - return createVariableDeclarationList(declarations, location, NodeFlags.Const); - } - // Helpers export function getHelperName(name: string) { return setEmitFlags(createIdentifier(name), EmitFlags.HelperName | EmitFlags.AdviseOnEmitNode); } + const valuesHelper: EmitHelper = { + name: "typescript:values", + scoped: false, + text: ` + var __values = (this && this.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + }; + ` + }; + + export function createValuesHelper(context: TransformationContext, expression: Expression, location?: TextRange) { + context.requestEmitHelper(valuesHelper); + return setTextRange( + createCall( + getHelperName("__values"), + /*typeArguments*/ undefined, + [expression] + ), + location + ); + } + + const readHelper: EmitHelper = { + name: "typescript:read", + scoped: false, + text: ` + var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; + }; + ` + }; + + export function createReadHelper(context: TransformationContext, iteratorRecord: Expression, count: number | undefined, location?: TextRange) { + context.requestEmitHelper(readHelper); + return setTextRange( + createCall( + getHelperName("__read"), + /*typeArguments*/ undefined, + count !== undefined + ? [iteratorRecord, createLiteral(count)] + : [iteratorRecord] + ), + location + ); + } + + const spreadHelper: EmitHelper = { + name: "typescript:spread", + scoped: false, + text: ` + var __spread = (this && this.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; + };` + }; + + export function createSpreadHelper(context: TransformationContext, argumentList: Expression[], location?: TextRange) { + context.requestEmitHelper(readHelper); + context.requestEmitHelper(spreadHelper); + return setTextRange( + createCall( + getHelperName("__spread"), + /*typeArguments*/ undefined, + argumentList + ), + location + ); + } + // Utilities + export function createForOfBindingStatement(node: ForInitializer, boundValue: Expression): Statement { + if (isVariableDeclarationList(node)) { + const firstDeclaration = firstOrUndefined(node.declarations); + const updatedDeclaration = updateVariableDeclaration( + firstDeclaration, + firstDeclaration.name, + /*typeNode*/ undefined, + boundValue + ); + return setTextRange( + createVariableStatement( + /*modifiers*/ undefined, + updateVariableDeclarationList(node, [updatedDeclaration]) + ), + /*location*/ node + ); + } + else { + const updatedExpression = setTextRange(createAssignment(node, boundValue), /*location*/ node); + return setTextRange(createStatement(updatedExpression), /*location*/ node); + } + } + + export function insertLeadingStatement(dest: Statement, source: Statement) { + if (isBlock(dest)) { + return updateBlock(dest, setTextRange(createNodeArray([source, ...dest.statements]), dest.statements)); + } + else { + return createBlock(createNodeArray([dest, source]), /*multiLine*/ true); + } + } + export function restoreEnclosingLabel(node: Statement, outermostLabeledStatement: LabeledStatement, afterRestoreLabelCallback?: (node: LabeledStatement) => void): Statement { if (!outermostLabeledStatement) { return node; @@ -1796,7 +2427,13 @@ namespace ts { } else if (callee.kind === SyntaxKind.SuperKeyword) { thisArg = createThis(); - target = languageVersion < ScriptTarget.ES2015 ? createIdentifier("_super", /*location*/ callee) : callee; + target = languageVersion < ScriptTarget.ES2015 + ? setTextRange(createIdentifier("_super"), callee) + : callee; + } + else if (getEmitFlags(callee) & EmitFlags.HelperName) { + thisArg = createVoidZero(); + target = parenthesizeForAccess(callee); } else { switch (callee.kind) { @@ -1805,14 +2442,16 @@ namespace ts { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = createTempVariable(recordTempVariable); target = createPropertyAccess( - createAssignment( - thisArg, - (callee).expression, - /*location*/ (callee).expression + setTextRange( + createAssignment( + thisArg, + (callee).expression + ), + (callee).expression ), - (callee).name, - /*location*/ callee + (callee).name ); + setTextRange(target, callee); } else { thisArg = (callee).expression; @@ -1826,14 +2465,16 @@ namespace ts { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = createTempVariable(recordTempVariable); target = createElementAccess( - createAssignment( - thisArg, - (callee).expression, - /*location*/ (callee).expression + setTextRange( + createAssignment( + thisArg, + (callee).expression + ), + (callee).expression ), - (callee).argumentExpression, - /*location*/ callee + (callee).argumentExpression ); + setTextRange(target, callee); } else { thisArg = (callee).expression; @@ -1863,7 +2504,7 @@ namespace ts { if (isQualifiedName(node)) { const left = createExpressionFromEntityName(node.left); const right = getMutableClone(node.right); - return createPropertyAccess(left, right, /*location*/ node); + return setTextRange(createPropertyAccess(left, right), node); } else { return getMutableClone(node); @@ -1872,7 +2513,7 @@ namespace ts { export function createExpressionForPropertyName(memberName: PropertyName): Expression { if (isIdentifier(memberName)) { - return createLiteral(memberName, /*location*/ undefined); + return createLiteral(memberName); } else if (isComputedPropertyName(memberName)) { return getMutableClone(memberName.expression); @@ -1908,9 +2549,9 @@ namespace ts { /*typeParameters*/ undefined, getAccessor.parameters, /*type*/ undefined, - getAccessor.body, - /*location*/ getAccessor + getAccessor.body ); + setTextRange(getterFunction, getAccessor); setOriginalNode(getterFunction, getAccessor); const getter = createPropertyAssignment("get", getterFunction); properties.push(getter); @@ -1924,25 +2565,27 @@ namespace ts { /*typeParameters*/ undefined, setAccessor.parameters, /*type*/ undefined, - setAccessor.body, - /*location*/ setAccessor + setAccessor.body ); + setTextRange(setterFunction, setAccessor); setOriginalNode(setterFunction, setAccessor); const setter = createPropertyAssignment("set", setterFunction); properties.push(setter); } - properties.push(createPropertyAssignment("enumerable", createLiteral(true))); - properties.push(createPropertyAssignment("configurable", createLiteral(true))); + properties.push(createPropertyAssignment("enumerable", createTrue())); + properties.push(createPropertyAssignment("configurable", createTrue())); - const expression = createCall( - createPropertyAccess(createIdentifier("Object"), "defineProperty"), - /*typeArguments*/ undefined, - [ - receiver, - createExpressionForPropertyName(property.name), - createObjectLiteral(properties, /*location*/ undefined, multiLine) - ], + const expression = setTextRange( + createCall( + createPropertyAccess(createIdentifier("Object"), "defineProperty"), + /*typeArguments*/ undefined, + [ + receiver, + createExpressionForPropertyName(property.name), + createObjectLiteral(properties, multiLine) + ] + ), /*location*/ firstAccessor ); @@ -1955,12 +2598,14 @@ namespace ts { function createExpressionForPropertyAssignment(property: PropertyAssignment, receiver: Expression) { return aggregateTransformFlags( setOriginalNode( - createAssignment( - createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), - property.initializer, - /*location*/ property + setTextRange( + createAssignment( + createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), + property.initializer + ), + property ), - /*original*/ property + property ) ); } @@ -1968,9 +2613,11 @@ namespace ts { function createExpressionForShorthandPropertyAssignment(property: ShorthandPropertyAssignment, receiver: Expression) { return aggregateTransformFlags( setOriginalNode( - createAssignment( - createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), - getSynthesizedClone(property.name), + setTextRange( + createAssignment( + createMemberAccessForPropertyName(receiver, property.name, /*location*/ property.name), + getSynthesizedClone(property.name) + ), /*location*/ property ), /*original*/ property @@ -1981,20 +2628,24 @@ namespace ts { function createExpressionForMethodDeclaration(method: MethodDeclaration, receiver: Expression) { return aggregateTransformFlags( setOriginalNode( - createAssignment( - createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), - setOriginalNode( - createFunctionExpression( - method.modifiers, - method.asteriskToken, - /*name*/ undefined, - /*typeParameters*/ undefined, - method.parameters, - /*type*/ undefined, - method.body, - /*location*/ method - ), - /*original*/ method + setTextRange( + createAssignment( + createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), + setOriginalNode( + setTextRange( + createFunctionExpression( + method.modifiers, + method.asteriskToken, + /*name*/ undefined, + /*typeParameters*/ undefined, + method.parameters, + /*type*/ undefined, + method.body + ), + /*location*/ method + ), + /*original*/ method + ) ), /*location*/ method ), @@ -2096,7 +2747,8 @@ namespace ts { * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ export function getNamespaceMemberName(ns: Identifier, name: Identifier, allowComments?: boolean, allowSourceMaps?: boolean): PropertyAccessExpression { - const qualifiedName = createPropertyAccess(ns, nodeIsSynthesized(name) ? name : getSynthesizedClone(name), /*location*/ name); + const qualifiedName = createPropertyAccess(ns, nodeIsSynthesized(name) ? name : getSynthesizedClone(name)); + setTextRange(qualifiedName, name); let emitFlags: EmitFlags; if (!allowSourceMaps) emitFlags |= EmitFlags.NoSourceMap; if (!allowComments) emitFlags |= EmitFlags.NoComments; @@ -2105,7 +2757,7 @@ namespace ts { } export function convertToFunctionBody(node: ConciseBody, multiLine?: boolean) { - return isBlock(node) ? node : createBlock([createReturn(node, /*location*/ node)], /*location*/ node, multiLine); + return isBlock(node) ? node : setTextRange(createBlock([setTextRange(createReturn(node), node)], multiLine), node); } function isUseStrictPrologue(node: ExpressionStatement): boolean { @@ -2184,15 +2836,28 @@ namespace ts { } if (!foundUseStrict) { - return createNodeArray([ - startOnNewLine(createStatement(createLiteral("use strict"))), - ...statements - ], statements); + return setTextRange( + createNodeArray([ + startOnNewLine(createStatement(createLiteral("use strict"))), + ...statements + ]), + statements + ); } return statements; } + export function parenthesizeConditionalHead(condition: Expression) { + const conditionalPrecedence = getOperatorPrecedence(SyntaxKind.ConditionalExpression, SyntaxKind.QuestionToken); + const emittedCondition = skipPartiallyEmittedExpressions(condition); + const conditionPrecedence = getExpressionPrecedence(emittedCondition); + if (compareValues(conditionPrecedence, conditionalPrecedence) === Comparison.LessThan) { + return createParen(condition); + } + return condition; + } + /** * Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended * order of operations. @@ -2380,7 +3045,7 @@ namespace ts { return condition; } - function parenthesizeSubexpressionOfConditionalExpression(e: Expression): Expression { + export function parenthesizeSubexpressionOfConditionalExpression(e: Expression): Expression { // per ES grammar both 'whenTrue' and 'whenFalse' parts of conditional expression are assignment expressions // so in case when comma expression is introduced as a part of previous transformations // if should be wrapped in parens since comma operator has the lowest precedence @@ -2432,22 +3097,22 @@ namespace ts { return expression; } - return createParen(expression, /*location*/ expression); + return setTextRange(createParen(expression), expression); } export function parenthesizePostfixOperand(operand: Expression) { return isLeftHandSideExpression(operand) ? operand - : createParen(operand, /*location*/ operand); + : setTextRange(createParen(operand), operand); } export function parenthesizePrefixOperand(operand: Expression) { return isUnaryExpression(operand) ? operand - : createParen(operand, /*location*/ operand); + : setTextRange(createParen(operand), operand); } - function parenthesizeListElements(elements: NodeArray) { + export function parenthesizeListElements(elements: NodeArray) { let result: Expression[]; for (let i = 0; i < elements.length; i++) { const element = parenthesizeExpressionForList(elements[i]); @@ -2461,7 +3126,7 @@ namespace ts { } if (result !== undefined) { - return createNodeArray(result, elements, elements.hasTrailingComma); + return setTextRange(createNodeArray(result, elements.hasTrailingComma), elements); } return elements; @@ -2473,7 +3138,7 @@ namespace ts { const commaPrecedence = getOperatorPrecedence(SyntaxKind.BinaryExpression, SyntaxKind.CommaToken); return expressionPrecedence > commaPrecedence ? expression - : createParen(expression, /*location*/ expression); + : setTextRange(createParen(expression), expression); } export function parenthesizeExpressionForExpressionStatement(expression: Expression) { @@ -2483,14 +3148,14 @@ namespace ts { const kind = skipPartiallyEmittedExpressions(callee).kind; if (kind === SyntaxKind.FunctionExpression || kind === SyntaxKind.ArrowFunction) { const mutableCall = getMutableClone(emittedExpression); - mutableCall.expression = createParen(callee, /*location*/ callee); + mutableCall.expression = setTextRange(createParen(callee), callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); } } else { const leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; if (leftmostExpressionKind === SyntaxKind.ObjectLiteralExpression || leftmostExpressionKind === SyntaxKind.FunctionExpression) { - return createParen(expression, /*location*/ expression); + return setTextRange(createParen(expression), expression); } } @@ -2546,7 +3211,7 @@ namespace ts { export function parenthesizeConciseBody(body: ConciseBody): ConciseBody { const emittedBody = skipPartiallyEmittedExpressions(body); if (emittedBody.kind === SyntaxKind.ObjectLiteralExpression) { - return createParen(body, /*location*/ body); + return setTextRange(createParen(body), body); } return body; @@ -2618,190 +3283,6 @@ namespace ts { return node; } - export function setOriginalNode(node: T, original: Node): T { - node.original = original; - if (original) { - const emitNode = original.emitNode; - if (emitNode) node.emitNode = mergeEmitNode(emitNode, node.emitNode); - } - return node; - } - - function mergeEmitNode(sourceEmitNode: EmitNode, destEmitNode: EmitNode) { - const { - flags, - commentRange, - sourceMapRange, - tokenSourceMapRanges, - constantValue, - helpers - } = sourceEmitNode; - if (!destEmitNode) destEmitNode = {}; - if (flags) destEmitNode.flags = flags; - if (commentRange) destEmitNode.commentRange = commentRange; - if (sourceMapRange) destEmitNode.sourceMapRange = sourceMapRange; - if (tokenSourceMapRanges) destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); - if (constantValue !== undefined) destEmitNode.constantValue = constantValue; - if (helpers) destEmitNode.helpers = addRange(destEmitNode.helpers, helpers); - return destEmitNode; - } - - function mergeTokenSourceMapRanges(sourceRanges: Map, destRanges: Map) { - if (!destRanges) destRanges = createMap(); - copyProperties(sourceRanges, destRanges); - return destRanges; - } - - /** - * Clears any EmitNode entries from parse-tree nodes. - * @param sourceFile A source file. - */ - export function disposeEmitNodes(sourceFile: SourceFile) { - // During transformation we may need to annotate a parse tree node with transient - // transformation properties. As parse tree nodes live longer than transformation - // nodes, we need to make sure we reclaim any memory allocated for custom ranges - // from these nodes to ensure we do not hold onto entire subtrees just for position - // information. We also need to reset these nodes to a pre-transformation state - // for incremental parsing scenarios so that we do not impact later emit. - sourceFile = getSourceFileOfNode(getParseTreeNode(sourceFile)); - const emitNode = sourceFile && sourceFile.emitNode; - const annotatedNodes = emitNode && emitNode.annotatedNodes; - if (annotatedNodes) { - for (const node of annotatedNodes) { - node.emitNode = undefined; - } - } - } - - /** - * Associates a node with the current transformation, initializing - * various transient transformation properties. - * - * @param node The node. - */ - export function getOrCreateEmitNode(node: Node) { - if (!node.emitNode) { - if (isParseTreeNode(node)) { - // To avoid holding onto transformation artifacts, we keep track of any - // parse tree node we are annotating. This allows us to clean them up after - // all transformations have completed. - if (node.kind === SyntaxKind.SourceFile) { - return node.emitNode = { annotatedNodes: [node] }; - } - - const sourceFile = getSourceFileOfNode(node); - getOrCreateEmitNode(sourceFile).annotatedNodes.push(node); - } - - node.emitNode = {}; - } - - return node.emitNode; - } - - /** - * Gets flags that control emit behavior of a node. - * - * @param node The node. - */ - export function getEmitFlags(node: Node) { - const emitNode = node.emitNode; - return emitNode && emitNode.flags; - } - - /** - * Sets flags that control emit behavior of a node. - * - * @param node The node. - * @param emitFlags The NodeEmitFlags for the node. - */ - export function setEmitFlags(node: T, emitFlags: EmitFlags) { - getOrCreateEmitNode(node).flags = emitFlags; - return node; - } - - /** - * Gets a custom text range to use when emitting source maps. - * - * @param node The node. - */ - export function getSourceMapRange(node: Node) { - const emitNode = node.emitNode; - return (emitNode && emitNode.sourceMapRange) || node; - } - - /** - * Sets a custom text range to use when emitting source maps. - * - * @param node The node. - * @param range The text range. - */ - export function setSourceMapRange(node: T, range: TextRange) { - getOrCreateEmitNode(node).sourceMapRange = range; - return node; - } - - /** - * Gets the TextRange to use for source maps for a token of a node. - * - * @param node The node. - * @param token The token. - */ - export function getTokenSourceMapRange(node: Node, token: SyntaxKind) { - const emitNode = node.emitNode; - const tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; - return tokenSourceMapRanges && tokenSourceMapRanges[token]; - } - - /** - * Sets the TextRange to use for source maps for a token of a node. - * - * @param node The node. - * @param token The token. - * @param range The text range. - */ - export function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange) { - const emitNode = getOrCreateEmitNode(node); - const tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = createMap()); - tokenSourceMapRanges[token] = range; - return node; - } - - /** - * Gets a custom text range to use when emitting comments. - * - * @param node The node. - */ - export function getCommentRange(node: Node) { - const emitNode = node.emitNode; - return (emitNode && emitNode.commentRange) || node; - } - - /** - * Sets a custom text range to use when emitting comments. - */ - export function setCommentRange(node: T, range: TextRange) { - getOrCreateEmitNode(node).commentRange = range; - return node; - } - - /** - * Gets the constant value to emit for an expression. - */ - export function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression) { - const emitNode = node.emitNode; - return emitNode && emitNode.constantValue; - } - - /** - * Sets the constant value to emit for an expression. - */ - export function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number) { - const emitNode = getOrCreateEmitNode(node); - emitNode.constantValue = value; - return node; - } - export function getExternalHelpersModuleName(node: SourceFile) { const parseNode = getOriginalNode(node, isSourceFile); const emitNode = parseNode && parseNode.emitNode; @@ -2839,111 +3320,6 @@ namespace ts { } } - /** - * Adds an EmitHelper to a node. - */ - export function addEmitHelper(node: T, helper: EmitHelper): T { - const emitNode = getOrCreateEmitNode(node); - emitNode.helpers = append(emitNode.helpers, helper); - return node; - } - - /** - * Adds an EmitHelper to a node. - */ - export function addEmitHelpers(node: T, helpers: EmitHelper[] | undefined): T { - if (some(helpers)) { - const emitNode = getOrCreateEmitNode(node); - for (const helper of helpers) { - if (!contains(emitNode.helpers, helper)) { - emitNode.helpers = append(emitNode.helpers, helper); - } - } - } - return node; - } - - /** - * Removes an EmitHelper from a node. - */ - export function removeEmitHelper(node: Node, helper: EmitHelper): boolean { - const emitNode = node.emitNode; - if (emitNode) { - const helpers = emitNode.helpers; - if (helpers) { - return orderedRemoveItem(helpers, helper); - } - } - return false; - } - - /** - * Gets the EmitHelpers of a node. - */ - export function getEmitHelpers(node: Node): EmitHelper[] | undefined { - const emitNode = node.emitNode; - return emitNode && emitNode.helpers; - } - - /** - * Moves matching emit helpers from a source node to a target node. - */ - export function moveEmitHelpers(source: Node, target: Node, predicate: (helper: EmitHelper) => boolean) { - const sourceEmitNode = source.emitNode; - const sourceEmitHelpers = sourceEmitNode && sourceEmitNode.helpers; - if (!some(sourceEmitHelpers)) return; - - const targetEmitNode = getOrCreateEmitNode(target); - let helpersRemoved = 0; - for (let i = 0; i < sourceEmitHelpers.length; i++) { - const helper = sourceEmitHelpers[i]; - if (predicate(helper)) { - helpersRemoved++; - if (!contains(targetEmitNode.helpers, helper)) { - targetEmitNode.helpers = append(targetEmitNode.helpers, helper); - } - } - else if (helpersRemoved > 0) { - sourceEmitHelpers[i - helpersRemoved] = helper; - } - } - - if (helpersRemoved > 0) { - sourceEmitHelpers.length -= helpersRemoved; - } - } - - export function compareEmitHelpers(x: EmitHelper, y: EmitHelper) { - if (x === y) return Comparison.EqualTo; - if (x.priority === y.priority) return Comparison.EqualTo; - if (x.priority === undefined) return Comparison.GreaterThan; - if (y.priority === undefined) return Comparison.LessThan; - return compareValues(x.priority, y.priority); - } - - export function setTextRange(node: T, location: TextRange): T { - if (location) { - node.pos = location.pos; - node.end = location.end; - } - return node; - } - - export function setNodeFlags(node: T, flags: NodeFlags): T { - node.flags = flags; - return node; - } - - export function setMultiLine(node: T, multiLine: boolean): T { - node.multiLine = multiLine; - return node; - } - - export function setHasTrailingComma(nodes: NodeArray, hasTrailingComma: boolean): NodeArray { - nodes.hasTrailingComma = hasTrailingComma; - return nodes; - } - /** * Get the name of that target module from an import or export declaration */ @@ -2986,10 +3362,8 @@ namespace ts { * Here we check if alternative name was provided for a given moduleName and return it if possible. */ function tryRenameExternalModule(moduleName: LiteralExpression, sourceFile: SourceFile) { - if (sourceFile.renamedDependencies && hasProperty(sourceFile.renamedDependencies, moduleName.text)) { - return createLiteral(sourceFile.renamedDependencies[moduleName.text]); - } - return undefined; + const rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text); + return rename && createLiteral(rename); } /** @@ -3222,10 +3596,18 @@ namespace ts { if (isBindingElement(element)) { if (element.dotDotDotToken) { Debug.assertNode(element.name, isIdentifier); - return setOriginalNode(createSpread(element.name, element), element); + return setOriginalNode(setTextRange(createSpread(element.name), element), element); } const expression = convertToAssignmentElementTarget(element.name); - return element.initializer ? setOriginalNode(createAssignment(expression, element.initializer, element), element) : expression; + return element.initializer + ? setOriginalNode( + setTextRange( + createAssignment(expression, element.initializer), + element + ), + element + ) + : expression; } Debug.assertNode(element, isExpression); return element; @@ -3235,14 +3617,14 @@ namespace ts { if (isBindingElement(element)) { if (element.dotDotDotToken) { Debug.assertNode(element.name, isIdentifier); - return setOriginalNode(createSpreadAssignment(element.name, element), element); + return setOriginalNode(setTextRange(createSpreadAssignment(element.name), element), element); } if (element.propertyName) { const expression = convertToAssignmentElementTarget(element.name); - return setOriginalNode(createPropertyAssignment(element.propertyName, element.initializer ? createAssignment(expression, element.initializer) : expression, element), element); + return setOriginalNode(setTextRange(createPropertyAssignment(element.propertyName, element.initializer ? createAssignment(expression, element.initializer) : expression), element), element); } Debug.assertNode(element.name, isIdentifier); - return setOriginalNode(createShorthandPropertyAssignment(element.name, element.initializer, element), element); + return setOriginalNode(setTextRange(createShorthandPropertyAssignment(element.name, element.initializer), element), element); } Debug.assertNode(element, isObjectLiteralElementLike); return element; @@ -3262,7 +3644,13 @@ namespace ts { export function convertToObjectAssignmentPattern(node: ObjectBindingOrAssignmentPattern) { if (isObjectBindingPattern(node)) { - return setOriginalNode(createObjectLiteral(map(node.elements, convertToObjectAssignmentElement), node), node); + return setOriginalNode( + setTextRange( + createObjectLiteral(map(node.elements, convertToObjectAssignmentElement)), + node + ), + node + ); } Debug.assertNode(node, isObjectLiteralExpression); return node; @@ -3270,7 +3658,13 @@ namespace ts { export function convertToArrayAssignmentPattern(node: ArrayBindingOrAssignmentPattern) { if (isArrayBindingPattern(node)) { - return setOriginalNode(createArrayLiteral(map(node.elements, convertToArrayAssignmentElement), node), node); + return setOriginalNode( + setTextRange( + createArrayLiteral(map(node.elements, convertToArrayAssignmentElement)), + node + ), + node + ); } Debug.assertNode(node, isArrayLiteralExpression); return node; @@ -3289,7 +3683,7 @@ namespace ts { externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]; // imports of other external modules externalHelpersImportDeclaration: ImportDeclaration | undefined; // import of external helpers exportSpecifiers: Map; // export specifiers by name - exportedBindings: Map; // exported names of local declarations + exportedBindings: Identifier[][]; // exported names of local declarations exportedNames: Identifier[]; // all exported names local to module exportEquals: ExportAssignment | undefined; // an export= declaration if one was present hasExportStarsToExportValues: boolean; // whether this module contains export* @@ -3297,8 +3691,8 @@ namespace ts { export function collectExternalModuleInfo(sourceFile: SourceFile, resolver: EmitResolver, compilerOptions: CompilerOptions): ExternalModuleInfo { const externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[] = []; - const exportSpecifiers = createMap(); - const exportedBindings = createMap(); + const exportSpecifiers = createMultiMap(); + const exportedBindings: Identifier[][] = []; const uniqueExports = createMap(); let exportedNames: Identifier[]; let hasExportDefault = false; @@ -3338,18 +3732,18 @@ namespace ts { else { // export { x, y } for (const specifier of (node).exportClause.elements) { - if (!uniqueExports[specifier.name.text]) { + if (!uniqueExports.get(specifier.name.text)) { const name = specifier.propertyName || specifier.name; - multiMapAdd(exportSpecifiers, name.text, specifier); + exportSpecifiers.add(name.text, specifier); const decl = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name); if (decl) { - multiMapAdd(exportedBindings, getOriginalNodeId(decl), specifier.name); + multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name); } - uniqueExports[specifier.name.text] = true; + uniqueExports.set(specifier.name.text, true); exportedNames = append(exportedNames, specifier.name); } } @@ -3376,16 +3770,16 @@ namespace ts { if (hasModifier(node, ModifierFlags.Default)) { // export default function() { } if (!hasExportDefault) { - multiMapAdd(exportedBindings, getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { // export function x() { } const name = (node).name; - if (!uniqueExports[name.text]) { - multiMapAdd(exportedBindings, getOriginalNodeId(node), name); - uniqueExports[name.text] = true; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); exportedNames = append(exportedNames, name); } } @@ -3397,16 +3791,16 @@ namespace ts { if (hasModifier(node, ModifierFlags.Default)) { // export default class { } if (!hasExportDefault) { - multiMapAdd(exportedBindings, getOriginalNodeId(node), getDeclarationName(node)); + multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), getDeclarationName(node)); hasExportDefault = true; } } else { // export class x { } const name = (node).name; - if (!uniqueExports[name.text]) { - multiMapAdd(exportedBindings, getOriginalNodeId(node), name); - uniqueExports[name.text] = true; + if (!uniqueExports.get(name.text)) { + multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name); + uniqueExports.set(name.text, true); exportedNames = append(exportedNames, name); } } @@ -3438,11 +3832,23 @@ namespace ts { } } else if (!isGeneratedIdentifier(decl.name)) { - if (!uniqueExports[decl.name.text]) { - uniqueExports[decl.name.text] = true; + if (!uniqueExports.get(decl.name.text)) { + uniqueExports.set(decl.name.text, true); exportedNames = append(exportedNames, decl.name); } } return exportedNames; } + + /** Use a sparse array as a multi-map. */ + function multiMapSparseArrayAdd(map: V[][], key: number, value: V): V[] { + let values = map[key]; + if (values) { + values.push(value); + } + else { + map[key] = values = [value]; + } + return values; + } } diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index e915103f3ce..f9fbe5b01c1 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -15,7 +15,7 @@ namespace ts { } /** Array that is only intended to be pushed to, never read. */ - interface Push { + export interface Push { push(value: T): void; } @@ -67,40 +67,31 @@ namespace ts { } /** Reads from "main" or "types"/"typings" depending on `extensions`. */ - function tryReadPackageJsonMainOrTypes(extensions: Extensions, packageJsonPath: string, baseDirectory: string, state: ModuleResolutionState): string { + function tryReadPackageJsonFields(readTypes: boolean, packageJsonPath: string, baseDirectory: string, state: ModuleResolutionState): string | undefined { const jsonContent = readJson(packageJsonPath, state.host); + return readTypes ? tryReadFromField("typings") || tryReadFromField("types") : tryReadFromField("main"); - switch (extensions) { - case Extensions.DtsOnly: - case Extensions.TypeScript: - return tryReadFromField("typings") || tryReadFromField("types"); - - case Extensions.JavaScript: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return normalizePath(combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; - } - - function tryReadFromField(fieldName: string) { - if (hasProperty(jsonContent, fieldName)) { - const typesFile = (jsonContent)[fieldName]; - if (typeof typesFile === "string") { - const typesFilePath = normalizePath(combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); - } - return typesFilePath; - } - else { - if (state.traceEnabled) { - trace(state.host, Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } + function tryReadFromField(fieldName: "typings" | "types" | "main"): string | undefined { + if (!hasProperty(jsonContent, fieldName)) { + if (state.traceEnabled) { + trace(state.host, Diagnostics.package_json_does_not_have_a_0_field, fieldName); } + return; } + + const fileName = jsonContent[fieldName]; + if (typeof fileName !== "string") { + if (state.traceEnabled) { + trace(state.host, Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof fileName); + } + return; + } + + const path = normalizePath(combinePaths(baseDirectory, fileName)); + if (state.traceEnabled) { + trace(state.host, Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path); + } + return path; } } @@ -144,7 +135,7 @@ namespace ts { } let typeRoots: string[]; - forEachAncestorDirectory(currentDirectory, directory => { + forEachAncestorDirectory(ts.normalizePath(currentDirectory), directory => { const atTypes = combinePaths(directory, nodeModulesAtTypes); if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); @@ -336,9 +327,10 @@ namespace ts { if (!moduleHasNonRelativeName(nonRelativeModuleName)) { return undefined; } - let perModuleNameCache = moduleNameToDirectoryMap[nonRelativeModuleName]; + let perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); if (!perModuleNameCache) { - moduleNameToDirectoryMap[nonRelativeModuleName] = perModuleNameCache = createPerModuleNameCache(); + perModuleNameCache = createPerModuleNameCache(); + moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); } return perModuleNameCache; } @@ -357,7 +349,7 @@ namespace ts { * Then it computes the set of parent folders for 'directory' that should have the same module resolution result * and for every parent folder in set it adds entry: parent -> module resolution. . * Lets say we first directory name: /a/b/c/d/e and resolution result is: /a/b/bar.ts. - * Set of parent folders that should have the same result will be: + * Set of parent folders that should have the same result will be: * [ * /a/b/c/d, /a/b/c, /a/b * ] @@ -391,7 +383,7 @@ namespace ts { } } } - + function getCommonPrefix(directory: Path, resolution: string) { if (resolution === undefined) { return undefined; @@ -421,8 +413,8 @@ namespace ts { trace(host, Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); } const containingDirectory = getDirectoryPath(containingFile); - let perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); - let result = perFolderCache && perFolderCache[moduleName]; + const perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + let result = perFolderCache && perFolderCache.get(moduleName); if (result) { if (traceEnabled) { @@ -453,7 +445,7 @@ namespace ts { } if (perFolderCache) { - perFolderCache[moduleName] = result; + perFolderCache.set(moduleName, result); // put result in per-module name cache const perModuleNameCache = cache.getOrCreateCacheForModuleName(moduleName); if (perModuleNameCache) { @@ -683,13 +675,18 @@ namespace ts { } export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations { + return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /* jsOnly*/ false); + } + + /* @internal */ + export function nodeModuleNameResolverWorker(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, jsOnly = false): ResolvedModuleWithFailedLookupLocations { const containingDirectory = getDirectoryPath(containingFile); const traceEnabled = isTraceEnabled(compilerOptions, host); const failedLookupLocations: string[] = []; const state: ModuleResolutionState = { compilerOptions, host, traceEnabled }; - const result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); + const result = jsOnly ? tryResolve(Extensions.JavaScript) : (tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript)); if (result && result.value) { const { resolved, isExternalLibraryImport } = result.value; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); @@ -697,7 +694,8 @@ namespace ts { return { resolvedModule: undefined, failedLookupLocations }; function tryResolve(extensions: Extensions): SearchResult<{ resolved: Resolved, isExternalLibraryImport: boolean }> { - const resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); + const loader: ResolutionKindSpecificLoader = (extensions, candidate, failedLookupLocations, onlyRecordFailures, state) => nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, /*considerPackageJson*/true); + const resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); if (resolved) { return toSearchResult({ resolved, isExternalLibraryImport: false }); } @@ -712,7 +710,7 @@ namespace ts { } else { const candidate = normalizePath(combinePaths(containingDirectory, moduleName)); - const resolved = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); + const resolved = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/true); return resolved && toSearchResult({ resolved, isExternalLibraryImport: false }); } } @@ -730,7 +728,7 @@ namespace ts { return real; } - function nodeLoadModuleByRelativeName(extensions: Extensions, candidate: string, failedLookupLocations: Push, onlyRecordFailures: boolean, state: ModuleResolutionState): Resolved | undefined { + function nodeLoadModuleByRelativeName(extensions: Extensions, candidate: string, failedLookupLocations: Push, onlyRecordFailures: boolean, state: ModuleResolutionState, considerPackageJson: boolean): Resolved | undefined { if (state.traceEnabled) { trace(state.host, Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); } @@ -758,7 +756,7 @@ namespace ts { onlyRecordFailures = true; } } - return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + return loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson); } /* @internal */ @@ -834,50 +832,57 @@ namespace ts { return undefined; } - function loadNodeModuleFromDirectory(extensions: Extensions, candidate: string, failedLookupLocations: Push, onlyRecordFailures: boolean, state: ModuleResolutionState): Resolved | undefined { - const packageJsonPath = pathToPackageJson(candidate); + function loadNodeModuleFromDirectory(extensions: Extensions, candidate: string, failedLookupLocations: Push, onlyRecordFailures: boolean, state: ModuleResolutionState, considerPackageJson = true): Resolved | undefined { const directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, Diagnostics.Found_package_json_at_0, packageJsonPath); - } - const mainOrTypesFile = tryReadPackageJsonMainOrTypes(extensions, packageJsonPath, candidate, state); - if (mainOrTypesFile) { - const onlyRecordFailures = !directoryProbablyExists(getDirectoryPath(mainOrTypesFile), state.host); - // A package.json "typings" may specify an exact filename, or may choose to omit an extension. - const fromExactFile = tryFile(mainOrTypesFile, failedLookupLocations, onlyRecordFailures, state); - if (fromExactFile) { - const resolved = fromExactFile && resolvedIfExtensionMatches(extensions, fromExactFile); - if (resolved) { - return resolved; - } - if (state.traceEnabled) { - trace(state.host, Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); - } - } - const resolved = tryAddingExtensions(mainOrTypesFile, Extensions.TypeScript, failedLookupLocations, onlyRecordFailures, state); - if (resolved) { - return resolved; + if (considerPackageJson) { + const packageJsonPath = pathToPackageJson(candidate); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + const fromPackageJson = loadModuleFromPackageJson(packageJsonPath, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; } } else { - if (state.traceEnabled) { - trace(state.host, Diagnostics.package_json_does_not_have_a_types_or_main_field); + if (directoryExists && state.traceEnabled) { + trace(state.host, Diagnostics.File_0_does_not_exist, packageJsonPath); } + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocations.push(packageJsonPath); } } - else { - if (directoryExists && state.traceEnabled) { - trace(state.host, Diagnostics.File_0_does_not_exist, packageJsonPath); - } - // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results - failedLookupLocations.push(packageJsonPath); - } return loadModuleFromFile(extensions, combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); } + function loadModuleFromPackageJson(packageJsonPath: string, extensions: Extensions, candidate: string, failedLookupLocations: Push, state: ModuleResolutionState): Resolved | undefined { + if (state.traceEnabled) { + trace(state.host, Diagnostics.Found_package_json_at_0, packageJsonPath); + } + + const file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, packageJsonPath, candidate, state); + if (!file) { + return undefined; + } + + const onlyRecordFailures = !directoryProbablyExists(getDirectoryPath(file), state.host); + const fromFile = tryFile(file, failedLookupLocations, onlyRecordFailures, state); + if (fromFile) { + const resolved = fromFile && resolvedIfExtensionMatches(extensions, fromFile); + if (resolved) { + return resolved; + } + if (state.traceEnabled) { + trace(state.host, Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile); + } + } + + // Even if extensions is DtsOnly, we can still look up a .ts file as a result of package.json "types" + const nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions; + // Don't do package.json lookup recursively, because Node.js' package lookup doesn't. + return nodeLoadModuleByRelativeName(nextExtensions, file, failedLookupLocations, onlyRecordFailures, state, /*considerPackageJson*/ false); + } + /** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */ function resolvedIfExtensionMatches(extensions: Extensions, path: string): Resolved | undefined { const extension = tryGetExtensionFromPath(path); @@ -1022,7 +1027,7 @@ namespace ts { /** * Represents result of search. Normally when searching among several alternatives we treat value `undefined` as indicator - * that search fails and we should try another option. + * that search fails and we should try another option. * However this does not allow us to represent final result that should be used instead of further searching (i.e. a final result that was found in cache). * SearchResult is used to deal with this issue, its values represents following outcomes: * - undefined - not found, continue searching @@ -1030,7 +1035,7 @@ namespace ts { * - { value: } - found - stop searching */ type SearchResult = { value: T | undefined } | undefined; - + /** * Wraps value to SearchResult. * @returns undefined if value is undefined or { value } otherwise @@ -1039,7 +1044,6 @@ namespace ts { return value !== undefined ? { value } : undefined; } - /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ function forEachAncestorDirectory(directory: string, callback: (directory: string) => SearchResult): SearchResult { while (true) { @@ -1056,4 +1060,4 @@ namespace ts { directory = parentPath; } } -} \ No newline at end of file +} diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index e214bbd67ca..308d3a317f9 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -66,6 +66,7 @@ namespace ts { case SyntaxKind.TypeParameter: return visitNode(cbNode, (node).name) || visitNode(cbNode, (node).constraint) || + visitNode(cbNode, (node).default) || visitNode(cbNode, (node).expression); case SyntaxKind.ShorthandPropertyAssignment: return visitNodes(cbNodes, node.decorators) || @@ -242,7 +243,8 @@ namespace ts { visitNode(cbNode, (node).expression) || visitNode(cbNode, (node).statement); case SyntaxKind.ForOfStatement: - return visitNode(cbNode, (node).initializer) || + return visitNode(cbNode, (node).awaitModifier) || + visitNode(cbNode, (node).initializer) || visitNode(cbNode, (node).expression) || visitNode(cbNode, (node).statement); case SyntaxKind.ContinueStatement: @@ -368,7 +370,9 @@ namespace ts { case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.JsxOpeningElement: return visitNode(cbNode, (node).tagName) || - visitNodes(cbNodes, (node).attributes); + visitNode(cbNode, (node).attributes); + case SyntaxKind.JsxAttributes: + return visitNodes(cbNodes, (node).properties); case SyntaxKind.JsxAttribute: return visitNode(cbNode, (node).name) || visitNode(cbNode, (node).initializer); @@ -1134,7 +1138,11 @@ namespace ts { function internIdentifier(text: string): string { text = escapeIdentifier(text); - return identifiers[text] || (identifiers[text] = text); + let identifier = identifiers.get(text); + if (identifier === undefined) { + identifiers.set(text, identifier = text); + } + return identifier; } // An identifier that starts with two underscores has an extra underscore character prepended to it to avoid issues @@ -2098,6 +2106,10 @@ namespace ts { } } + if (parseOptional(SyntaxKind.EqualsToken)) { + node.default = parseType(); + } + return finishNode(node); } @@ -2510,6 +2522,7 @@ namespace ts { case SyntaxKind.SymbolKeyword: case SyntaxKind.UndefinedKeyword: case SyntaxKind.NeverKeyword: + case SyntaxKind.ObjectKeyword: // If these are followed by a dot, then parse these out as a dotted type reference instead. const node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); @@ -2568,6 +2581,7 @@ namespace ts { case SyntaxKind.NumericLiteral: case SyntaxKind.TrueKeyword: case SyntaxKind.FalseKeyword: + case SyntaxKind.ObjectKeyword: return true; case SyntaxKind.MinusToken: return lookAhead(nextTokenIsNumericLiteral); @@ -3859,14 +3873,20 @@ namespace ts { return result; } + function parseJsxAttributes(): JsxAttributes { + const jsxAttributes = createNode(SyntaxKind.JsxAttributes); + jsxAttributes.properties = parseList(ParsingContext.JsxAttributes, parseJsxAttribute); + return finishNode(jsxAttributes); + } + function parseJsxOpeningOrSelfClosingElement(inExpressionContext: boolean): JsxOpeningElement | JsxSelfClosingElement { const fullStart = scanner.getStartPos(); parseExpected(SyntaxKind.LessThanToken); const tagName = parseJsxElementName(); + const attributes = parseJsxAttributes(); - const attributes = parseList(ParsingContext.JsxAttributes, parseJsxAttribute); let node: JsxOpeningLikeElement; if (token() === SyntaxKind.GreaterThanToken) { @@ -4442,6 +4462,7 @@ namespace ts { function parseForOrForInOrForOfStatement(): Statement { const pos = getNodePos(); parseExpected(SyntaxKind.ForKeyword); + const awaitToken = parseOptionalToken(SyntaxKind.AwaitKeyword); parseExpected(SyntaxKind.OpenParenToken); let initializer: VariableDeclarationList | Expression = undefined; @@ -4454,20 +4475,21 @@ namespace ts { } } let forOrForInOrForOfStatement: IterationStatement; - if (parseOptional(SyntaxKind.InKeyword)) { + if (awaitToken ? parseExpected(SyntaxKind.OfKeyword) : parseOptional(SyntaxKind.OfKeyword)) { + const forOfStatement = createNode(SyntaxKind.ForOfStatement, pos); + forOfStatement.awaitModifier = awaitToken; + forOfStatement.initializer = initializer; + forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); + parseExpected(SyntaxKind.CloseParenToken); + forOrForInOrForOfStatement = forOfStatement; + } + else if (parseOptional(SyntaxKind.InKeyword)) { const forInStatement = createNode(SyntaxKind.ForInStatement, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(SyntaxKind.CloseParenToken); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(SyntaxKind.OfKeyword)) { - const forOfStatement = createNode(SyntaxKind.ForOfStatement, pos); - forOfStatement.initializer = initializer; - forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(SyntaxKind.CloseParenToken); - forOrForInOrForOfStatement = forOfStatement; - } else { const forStatement = createNode(SyntaxKind.ForStatement, pos); forStatement.initializer = initializer; @@ -5810,7 +5832,11 @@ namespace ts { } } - const range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() }; + const range = { + kind: triviaScanner.getToken(), + pos: triviaScanner.getTokenPos(), + end: triviaScanner.getTextPos(), + }; const comment = sourceText.substring(range.pos, range.end); const referencePathMatchResult = getFileReferenceFromReferencePath(comment, range); @@ -6037,6 +6063,7 @@ namespace ts { case SyntaxKind.NullKeyword: case SyntaxKind.UndefinedKeyword: case SyntaxKind.NeverKeyword: + case SyntaxKind.ObjectKeyword: return parseTokenNode(); case SyntaxKind.StringLiteral: case SyntaxKind.NumericLiteral: @@ -6686,10 +6713,15 @@ namespace ts { typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0); if (typedefTag.fullName) { let rightNode = typedefTag.fullName; - while (rightNode.kind !== SyntaxKind.Identifier) { + while (true) { + if (rightNode.kind === SyntaxKind.Identifier || !rightNode.body) { + // if node is identifier - use it as name + // otherwise use name of the rightmost part that we were able to parse + typedefTag.name = rightNode.kind === SyntaxKind.Identifier ? rightNode : rightNode.name; + break; + } rightNode = rightNode.body; } - typedefTag.name = rightNode; } typedefTag.typeExpression = typeExpression; skipWhitespace(); diff --git a/src/compiler/performance.ts b/src/compiler/performance.ts index a48eb117e28..8c24b3b9f1b 100644 --- a/src/compiler/performance.ts +++ b/src/compiler/performance.ts @@ -27,8 +27,8 @@ namespace ts.performance { */ export function mark(markName: string) { if (enabled) { - marks[markName] = timestamp(); - counts[markName] = (counts[markName] || 0) + 1; + marks.set(markName, timestamp()); + counts.set(markName, (counts.get(markName) || 0) + 1); profilerEvent(markName); } } @@ -44,9 +44,9 @@ namespace ts.performance { */ export function measure(measureName: string, startMarkName?: string, endMarkName?: string) { if (enabled) { - const end = endMarkName && marks[endMarkName] || timestamp(); - const start = startMarkName && marks[startMarkName] || profilerStart; - measures[measureName] = (measures[measureName] || 0) + (end - start); + const end = endMarkName && marks.get(endMarkName) || timestamp(); + const start = startMarkName && marks.get(startMarkName) || profilerStart; + measures.set(measureName, (measures.get(measureName) || 0) + (end - start)); } } @@ -56,7 +56,7 @@ namespace ts.performance { * @param markName The name of the mark. */ export function getCount(markName: string) { - return counts && counts[markName] || 0; + return counts && counts.get(markName) || 0; } /** @@ -65,7 +65,7 @@ namespace ts.performance { * @param measureName The name of the measure whose durations should be accumulated. */ export function getDuration(measureName: string) { - return measures && measures[measureName] || 0; + return measures && measures.get(measureName) || 0; } /** @@ -74,9 +74,9 @@ namespace ts.performance { * @param cb The action to perform for each measure */ export function forEachMeasure(cb: (measureName: string, duration: number) => void) { - for (const key in measures) { - cb(key, measures[key]); - } + measures.forEach((measure, key) => { + cb(key, measure); + }); } /** Enables (and resets) performance measurements for the compiler. */ diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 1099e126912..eb9f0f0e0a1 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -111,11 +111,11 @@ namespace ts { } function directoryExists(directoryPath: string): boolean { - if (directoryPath in existingDirectories) { + if (existingDirectories.has(directoryPath)) { return true; } if (sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; + existingDirectories.set(directoryPath, true); return true; } return false; @@ -139,11 +139,11 @@ namespace ts { const hash = sys.createHash(data); const mtimeBefore = sys.getModifiedTime(fileName); - if (mtimeBefore && fileName in outputFingerprints) { - const fingerprint = outputFingerprints[fileName]; - + if (mtimeBefore) { + const fingerprint = outputFingerprints.get(fileName); // If output has not been changed, and the file has no external modification - if (fingerprint.byteOrderMark === writeByteOrderMark && + if (fingerprint && + fingerprint.byteOrderMark === writeByteOrderMark && fingerprint.hash === hash && fingerprint.mtime.getTime() === mtimeBefore.getTime()) { return; @@ -154,11 +154,11 @@ namespace ts { const mtimeAfter = sys.getModifiedTime(fileName); - outputFingerprints[fileName] = { + outputFingerprints.set(fileName, { hash, byteOrderMark: writeByteOrderMark, mtime: mtimeAfter - }; + }); } function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) { @@ -278,9 +278,13 @@ namespace ts { const resolutions: T[] = []; const cache = createMap(); for (const name of names) { - const result = name in cache - ? cache[name] - : cache[name] = loader(name, containingFile); + let result: T; + if (cache.has(name)) { + result = cache.get(name); + } + else { + cache.set(name, result = loader(name, containingFile)); + } resolutions.push(result); } return resolutions; @@ -435,7 +439,7 @@ namespace ts { function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - const emittedFiles = filterSourceFilesInDirectory(files, isSourceFileFromExternalLibrary); + const emittedFiles = filter(files, file => sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary)); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified and is valid use it as the commonSourceDirectory commonSourceDirectory = getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -460,7 +464,7 @@ namespace ts { classifiableNames = createMap(); for (const sourceFile of files) { - copyProperties(sourceFile.classifiableNames, classifiableNames); + copyEntries(sourceFile.classifiableNames, classifiableNames); } } @@ -735,7 +739,7 @@ namespace ts { } function isSourceFileFromExternalLibrary(file: SourceFile): boolean { - return sourceFilesFoundSearchingNodeModules[file.path]; + return sourceFilesFoundSearchingNodeModules.get(file.path); } function getDiagnosticsProducingTypeChecker() { @@ -750,15 +754,15 @@ namespace ts { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean): EmitResult { - return runWithCancellationToken(() => emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles)); + function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, transformers?: CustomTransformers): EmitResult { + return runWithCancellationToken(() => emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers)); } function isEmitBlocked(emitFileName: string): boolean { return hasEmitBlockingDiagnostics.contains(toPath(emitFileName, currentDirectory, getCanonicalFileName)); } - function emitWorker(program: Program, sourceFile: SourceFile, writeFileCallback: WriteFileCallback, cancellationToken: CancellationToken, emitOnlyDtsFiles?: boolean): EmitResult { + function emitWorker(program: Program, sourceFile: SourceFile, writeFileCallback: WriteFileCallback, cancellationToken: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult { let declarationDiagnostics: Diagnostic[] = []; if (options.noEmit) { @@ -800,11 +804,13 @@ namespace ts { performance.mark("beforeEmit"); + const transformers = emitOnlyDtsFiles ? [] : getTransformers(options, customTransformers); const emitResult = emitFiles( emitResolver, getEmitHost(writeFileCallback), sourceFile, - emitOnlyDtsFiles); + emitOnlyDtsFiles, + transformers); performance.mark("afterEmit"); performance.measure("Emit", "beforeEmit", "afterEmit"); @@ -1148,13 +1154,10 @@ namespace ts { && (options.isolatedModules || isExternalModuleFile) && !file.isDeclarationFile) { // synthesize 'import "tslib"' declaration - const externalHelpersModuleReference = createSynthesizedNode(SyntaxKind.StringLiteral); - externalHelpersModuleReference.text = externalHelpersModuleNameText; - const importDecl = createSynthesizedNode(SyntaxKind.ImportDeclaration); - - importDecl.parent = file; + const externalHelpersModuleReference = createLiteral(externalHelpersModuleNameText); + const importDecl = createImportDeclaration(undefined, undefined, undefined); externalHelpersModuleReference.parent = importDecl; - + importDecl.parent = file; imports = [externalHelpersModuleReference]; } @@ -1298,20 +1301,20 @@ namespace ts { // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file && sourceFilesFoundSearchingNodeModules[file.path] && currentNodeModulesDepth == 0) { - sourceFilesFoundSearchingNodeModules[file.path] = false; + if (file && sourceFilesFoundSearchingNodeModules.get(file.path) && currentNodeModulesDepth == 0) { + sourceFilesFoundSearchingNodeModules.set(file.path, false); if (!options.noResolve) { processReferencedFiles(file, isDefaultLib); processTypeReferenceDirectives(file); } - modulesWithElidedImports[file.path] = false; + modulesWithElidedImports.set(file.path, false); processImportedModules(file); } // See if we need to reprocess the imports due to prior skipped imports - else if (file && modulesWithElidedImports[file.path]) { + else if (file && modulesWithElidedImports.get(file.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports[file.path] = false; + modulesWithElidedImports.set(file.path, false); processImportedModules(file); } } @@ -1332,7 +1335,7 @@ namespace ts { filesByName.set(path, file); if (file) { - sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0); + sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; if (host.useCaseSensitiveFileNames()) { @@ -1393,7 +1396,7 @@ namespace ts { refFile?: SourceFile, refPos?: number, refEnd?: number): void { // If we already found this library as a primary reference - nothing to do - const previousResolution = resolvedTypeReferenceDirectives[typeReferenceDirective]; + const previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { return; } @@ -1433,7 +1436,7 @@ namespace ts { } if (saveResolution) { - resolvedTypeReferenceDirectives[typeReferenceDirective] = resolvedTypeReferenceDirective; + resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); } } @@ -1486,7 +1489,7 @@ namespace ts { const shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { - modulesWithElidedImports[file.path] = true; + modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { const path = toPath(resolvedFileName, currentDirectory, getCanonicalFileName); @@ -1703,7 +1706,7 @@ namespace ts { if (!options.noEmit && !options.suppressOutputPathCheck) { const emitHost = getEmitHost(); const emitFilesSeen = createFileMap(!host.useCaseSensitiveFileNames() ? key => key.toLocaleLowerCase() : undefined); - forEachExpectedEmitFile(emitHost, (emitFileNames) => { + forEachEmittedFile(emitHost, (emitFileNames) => { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen); }); diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index a2ca6057845..fb91b0ff5b7 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -56,7 +56,7 @@ namespace ts { tryScan(callback: () => T): T; } - const textToToken = createMap({ + const textToToken = createMapFromTemplate({ "abstract": SyntaxKind.AbstractKeyword, "any": SyntaxKind.AnyKeyword, "as": SyntaxKind.AsKeyword, @@ -98,6 +98,7 @@ namespace ts { "new": SyntaxKind.NewKeyword, "null": SyntaxKind.NullKeyword, "number": SyntaxKind.NumberKeyword, + "object": SyntaxKind.ObjectKeyword, "package": SyntaxKind.PackageKeyword, "private": SyntaxKind.PrivateKeyword, "protected": SyntaxKind.ProtectedKeyword, @@ -275,9 +276,9 @@ namespace ts { function makeReverseMap(source: Map): string[] { const result: string[] = []; - for (const name in source) { - result[source[name]] = name; - } + source.forEach((value, name) => { + result[value] = name; + }); return result; } @@ -289,7 +290,7 @@ namespace ts { /* @internal */ export function stringToToken(s: string): SyntaxKind { - return textToToken[s]; + return textToToken.get(s); } /* @internal */ @@ -363,8 +364,6 @@ namespace ts { return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } - const hasOwnProperty = Object.prototype.hasOwnProperty; - export function isWhiteSpace(ch: number): boolean { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } @@ -609,10 +608,10 @@ namespace ts { * @returns If "reduce" is true, the accumulated value. If "reduce" is false, the first truthy * return value of the callback. */ - function iterateCommentRanges(reduce: boolean, text: string, pos: number, trailing: boolean, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial?: U): U { + function iterateCommentRanges(reduce: boolean, text: string, pos: number, trailing: boolean, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial?: U): U { let pendingPos: number; let pendingEnd: number; - let pendingKind: SyntaxKind; + let pendingKind: CommentKind; let pendingHasTrailingNewLine: boolean; let hasPendingCommentRange = false; let collecting = trailing || pos === 0; @@ -708,36 +707,36 @@ namespace ts { return accumulator; } - export function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T) { + export function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T) { return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ false, cb, state); } - export function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T) { + export function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T) { return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ true, cb, state); } - export function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U) { + export function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U) { return iterateCommentRanges(/*reduce*/ true, text, pos, /*trailing*/ false, cb, state, initial); } - export function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U) { + export function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U) { return iterateCommentRanges(/*reduce*/ true, text, pos, /*trailing*/ true, cb, state, initial); } - function appendCommentRange(pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, _state: any, comments: CommentRange[]) { + function appendCommentRange(pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, _state: any, comments: CommentRange[]) { if (!comments) { comments = []; } - comments.push({ pos, end, hasTrailingNewLine, kind }); + comments.push({ kind, pos, end, hasTrailingNewLine }); return comments; } - export function getLeadingCommentRanges(text: string, pos: number): CommentRange[] { + export function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined { return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined); } - export function getTrailingCommentRanges(text: string, pos: number): CommentRange[] { + export function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined { return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined); } @@ -1183,8 +1182,11 @@ namespace ts { const len = tokenValue.length; if (len >= 2 && len <= 11) { const ch = tokenValue.charCodeAt(0); - if (ch >= CharacterCodes.a && ch <= CharacterCodes.z && hasOwnProperty.call(textToToken, tokenValue)) { - return token = textToToken[tokenValue]; + if (ch >= CharacterCodes.a && ch <= CharacterCodes.z) { + token = textToToken.get(tokenValue); + if (token !== undefined) { + return token; + } } } return token = SyntaxKind.Identifier; diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index 650b9b0ef02..d743f488e75 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -8,10 +8,9 @@ namespace ts { * * @param filePath The path to the generated output file. * @param sourceMapFilePath The path to the output source map file. - * @param sourceFiles The input source files for the program. - * @param isBundledEmit A value indicating whether the generated output file is a bundle. + * @param sourceFileOrBundle The input source file or bundle for the program. */ - initialize(filePath: string, sourceMapFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean): void; + initialize(filePath: string, sourceMapFilePath: string, sourceFileOrBundle: SourceFile | Bundle): void; /** * Reset the SourceMapWriter to an empty state. @@ -38,11 +37,11 @@ namespace ts { /** * Emits a node with possible leading and trailing source maps. * - * @param emitContext The current emit context + * @param hint The current emit context * @param node The node to emit. * @param emitCallback The callback used to emit the node. */ - emitNodeWithSourceMap(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; + emitNodeWithSourceMap(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; /** * Emits a token of a node node with possible leading and trailing source maps. @@ -115,10 +114,9 @@ namespace ts { * * @param filePath The path to the generated output file. * @param sourceMapFilePath The path to the output source map file. - * @param sourceFiles The input source files for the program. - * @param isBundledEmit A value indicating whether the generated output file is a bundle. + * @param sourceFileOrBundle The input source file or bundle for the program. */ - function initialize(filePath: string, sourceMapFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) { + function initialize(filePath: string, sourceMapFilePath: string, sourceFileOrBundle: SourceFile | Bundle) { if (disabled) { return; } @@ -161,11 +159,10 @@ namespace ts { if (compilerOptions.mapRoot) { sourceMapDir = normalizeSlashes(compilerOptions.mapRoot); - if (!isBundledEmit) { // emitting single module file - Debug.assert(sourceFiles.length === 1); + if (sourceFileOrBundle.kind === SyntaxKind.SourceFile) { // emitting single module file // 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 = getDirectoryPath(getSourceFilePathInNewDir(sourceFiles[0], host, sourceMapDir)); + sourceMapDir = getDirectoryPath(getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); } if (!isRootedDiskPath(sourceMapDir) && !isUrl(sourceMapDir)) { @@ -311,12 +308,13 @@ namespace ts { /** * Emits a node with possible leading and trailing source maps. * + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emitCallback The callback used to emit the node. */ - function emitNodeWithSourceMap(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) { + function emitNodeWithSourceMap(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) { if (disabled) { - return emitCallback(emitContext, node); + return emitCallback(hint, node); } if (node) { @@ -332,11 +330,11 @@ namespace ts { if (emitFlags & EmitFlags.NoNestedSourceMaps) { disabled = true; - emitCallback(emitContext, node); + emitCallback(hint, node); disabled = false; } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } if (node.kind !== SyntaxKind.NotEmittedStatement diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 8e140375dd0..cf50ab6482b 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -1,4 +1,7 @@ -/// +/// + +declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; +declare function clearTimeout(handle: any): void; namespace ts { export type FileWatcherCallback = (fileName: string, removed?: boolean) => void; @@ -18,7 +21,7 @@ namespace ts { getFileSize?(path: string): number; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; /** - * @pollingInterval - this parameter is used in polling-based watchers and ignored in watchers that + * @pollingInterval - this parameter is used in polling-based watchers and ignored in watchers that * use native OS file watching */ watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; @@ -56,6 +59,21 @@ namespace ts { declare var global: any; declare var __filename: string; + export function getNodeMajorVersion() { + if (typeof process === "undefined") { + return undefined; + } + const version: string = process.version; + if (!version) { + return undefined; + } + const dot = version.indexOf("."); + if (dot === -1) { + return undefined; + } + return parseInt(version.substring(1, dot)); + } + declare class Enumerator { public atEnd(): boolean; public moveNext(): boolean; @@ -243,23 +261,23 @@ namespace ts { function createWatchedFileSet() { const dirWatchers = createMap(); // One file can have multiple watchers - const fileWatcherCallbacks = createMap(); + const fileWatcherCallbacks = createMultiMap(); return { addFile, removeFile }; function reduceDirWatcherRefCountForFile(fileName: string) { const dirName = getDirectoryPath(fileName); - const watcher = dirWatchers[dirName]; + const watcher = dirWatchers.get(dirName); if (watcher) { watcher.referenceCount -= 1; if (watcher.referenceCount <= 0) { watcher.close(); - delete dirWatchers[dirName]; + dirWatchers.delete(dirName); } } } function addDirWatcher(dirPath: string): void { - let watcher = dirWatchers[dirPath]; + let watcher = dirWatchers.get(dirPath); if (watcher) { watcher.referenceCount += 1; return; @@ -270,12 +288,12 @@ namespace ts { (eventName: string, relativeFileName: string) => fileEventHandler(eventName, relativeFileName, dirPath) ); watcher.referenceCount = 1; - dirWatchers[dirPath] = watcher; + dirWatchers.set(dirPath, watcher); return; } function addFileWatcherCallback(filePath: string, callback: FileWatcherCallback): void { - multiMapAdd(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.add(filePath, callback); } function addFile(fileName: string, callback: FileWatcherCallback): WatchedFile { @@ -291,7 +309,7 @@ namespace ts { } function removeFileWatcherCallback(filePath: string, callback: FileWatcherCallback) { - multiMapRemove(fileWatcherCallbacks, filePath, callback); + fileWatcherCallbacks.remove(filePath, callback); } function fileEventHandler(eventName: string, relativeFileName: string, baseDirPath: string) { @@ -300,18 +318,20 @@ namespace ts { ? undefined : ts.getNormalizedAbsolutePath(relativeFileName, baseDirPath); // Some applications save a working file via rename operations - if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks[fileName]) { - for (const fileCallback of fileWatcherCallbacks[fileName]) { - fileCallback(fileName); + if ((eventName === "change" || eventName === "rename")) { + const callbacks = fileWatcherCallbacks.get(fileName); + if (callbacks) { + for (const fileCallback of callbacks) { + fileCallback(fileName); + } } } } } const watchedFileSet = createWatchedFileSet(); - function isNode4OrLater(): boolean { - return parseInt(process.version.charAt(1)) >= 4; - } + const nodeVersion = getNodeMajorVersion(); + const isNode4OrLater = nodeVersion >= 4; function isFileSystemCaseSensitive(): boolean { // win32\win64 are case insensitive platforms @@ -480,10 +500,11 @@ namespace ts { // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643) let options: any; if (!directoryExists(directoryName)) { + // do nothing if target folder does not exist return noOpFileWatcher; } - if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { + if (isNode4OrLater && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; } else { diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 10a718448e9..b9a75015f41 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// @@ -13,25 +13,36 @@ /* @internal */ namespace ts { - const moduleTransformerMap = createMap({ - [ModuleKind.ES2015]: transformES2015Module, - [ModuleKind.System]: transformSystemModule, - [ModuleKind.AMD]: transformModule, - [ModuleKind.CommonJS]: transformModule, - [ModuleKind.UMD]: transformModule, - [ModuleKind.None]: transformModule, - }); + function getModuleTransformer(moduleKind: ModuleKind): TransformerFactory { + switch (moduleKind) { + case ModuleKind.ES2015: + return transformES2015Module; + case ModuleKind.System: + return transformSystemModule; + default: + return transformModule; + } + } + + const enum TransformationState { + Uninitialized, + Initialized, + Completed, + Disposed + } const enum SyntaxKindFeatureFlags { Substitution = 1 << 0, EmitNotifications = 1 << 1, } - export function getTransformers(compilerOptions: CompilerOptions) { + export function getTransformers(compilerOptions: CompilerOptions, customTransformers?: CustomTransformers) { const jsx = compilerOptions.jsx; const languageVersion = getEmitScriptTarget(compilerOptions); const moduleKind = getEmitModuleKind(compilerOptions); - const transformers: Transformer[] = []; + const transformers: TransformerFactory[] = []; + + addRange(transformers, customTransformers && customTransformers.before); transformers.push(transformTypeScript); @@ -56,7 +67,7 @@ namespace ts { transformers.push(transformGenerators); } - transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ModuleKind.None]); + transformers.push(getModuleTransformer(moduleKind)); // The ES5 transformer is last so that it can substitute expressions like `exports.default` // for ES3. @@ -64,6 +75,8 @@ namespace ts { transformers.push(transformES5); } + addRange(transformers, customTransformers && customTransformers.after); + return transformers; } @@ -71,28 +84,29 @@ namespace ts { * Transforms an array of SourceFiles by passing them through each transformer. * * @param resolver The emit resolver provided by the checker. - * @param host The emit host. - * @param sourceFiles An array of source files - * @param transforms An array of Transformers. + * @param host The emit host object used to interact with the file system. + * @param options Compiler options to surface in the `TransformationContext`. + * @param nodes An array of nodes to transform. + * @param transforms An array of `TransformerFactory` callbacks. + * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ - export function transformFiles(resolver: EmitResolver, host: EmitHost, sourceFiles: SourceFile[], transformers: Transformer[]): TransformationResult { + export function transformNodes(resolver: EmitResolver, host: EmitHost, options: CompilerOptions, nodes: T[], transformers: TransformerFactory[], allowDtsFiles: boolean): TransformationResult { const enabledSyntaxKindFeatures = new Array(SyntaxKind.Count); - - let lexicalEnvironmentDisabled = false; - let lexicalEnvironmentVariableDeclarations: VariableDeclaration[]; let lexicalEnvironmentFunctionDeclarations: FunctionDeclaration[]; let lexicalEnvironmentVariableDeclarationsStack: VariableDeclaration[][] = []; let lexicalEnvironmentFunctionDeclarationsStack: FunctionDeclaration[][] = []; let lexicalEnvironmentStackOffset = 0; let lexicalEnvironmentSuspended = false; - let emitHelpers: EmitHelper[]; + let onSubstituteNode: TransformationContext["onSubstituteNode"] = (_, node) => node; + let onEmitNode: TransformationContext["onEmitNode"] = (hint, node, callback) => callback(hint, node); + let state = TransformationState.Uninitialized; // The transformation context is provided to each transformer as part of transformer // initialization. const context: TransformationContext = { - getCompilerOptions: () => host.getCompilerOptions(), + getCompilerOptions: () => options, getEmitResolver: () => resolver, getEmitHost: () => host, startLexicalEnvironment, @@ -103,46 +117,62 @@ namespace ts { hoistFunctionDeclaration, requestEmitHelper, readEmitHelpers, - onSubstituteNode: (_emitContext, node) => node, enableSubstitution, - isSubstitutionEnabled, - onEmitNode: (node, emitContext, emitCallback) => emitCallback(node, emitContext), enableEmitNotification, - isEmitNotificationEnabled + isSubstitutionEnabled, + isEmitNotificationEnabled, + get onSubstituteNode() { return onSubstituteNode }, + set onSubstituteNode(value) { + Debug.assert(state < TransformationState.Initialized, "Cannot modify transformation hooks after initialization has completed."); + Debug.assert(value !== undefined, "Value must not be 'undefined'"); + onSubstituteNode = value; + }, + get onEmitNode() { return onEmitNode }, + set onEmitNode(value) { + Debug.assert(state < TransformationState.Initialized, "Cannot modify transformation hooks after initialization has completed."); + Debug.assert(value !== undefined, "Value must not be 'undefined'"); + onEmitNode = value; + } }; + // Ensure the parse tree is clean before applying transformations + for (const node of nodes) { + disposeEmitNodes(getSourceFileOfNode(getParseTreeNode(node))); + } + + performance.mark("beforeTransform"); + // Chain together and initialize each transformer. const transformation = chain(...transformers)(context); - // Transform each source file. - const transformed = map(sourceFiles, transformSourceFile); + // prevent modification of transformation hooks. + state = TransformationState.Initialized; - // Disable modification of the lexical environment. - lexicalEnvironmentDisabled = true; + // Transform each node. + const transformed = map(nodes, allowDtsFiles ? transformation : transformRoot); + + // prevent modification of the lexical environment. + state = TransformationState.Completed; + + performance.mark("afterTransform"); + performance.measure("transformTime", "beforeTransform", "afterTransform"); return { transformed, - emitNodeWithSubstitution, - emitNodeWithNotification + substituteNode, + emitNodeWithNotification, + dispose }; - /** - * Transforms a source file. - * - * @param sourceFile The source file to transform. - */ - function transformSourceFile(sourceFile: SourceFile) { - if (isDeclarationFile(sourceFile)) { - return sourceFile; - } - - return transformation(sourceFile); + function transformRoot(node: T) { + return node && (!isSourceFile(node) || !isDeclarationFile(node)) ? transformation(node) : node; } /** * Enables expression substitutions in the pretty printer for the provided SyntaxKind. */ function enableSubstitution(kind: SyntaxKind) { + Debug.assert(state < TransformationState.Completed, "Cannot modify the transformation context after transformation has completed."); enabledSyntaxKindFeatures[kind] |= SyntaxKindFeatureFlags.Substitution; } @@ -157,28 +187,20 @@ namespace ts { /** * Emits a node with possible substitution. * - * @param emitContext The current emit context. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emitCallback The callback used to emit the node or its substitute. */ - function emitNodeWithSubstitution(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) { - if (node) { - if (isSubstitutionEnabled(node)) { - const substitute = context.onSubstituteNode(emitContext, node); - if (substitute && substitute !== node) { - emitCallback(emitContext, substitute); - return; - } - } - - emitCallback(emitContext, node); - } + function substituteNode(hint: EmitHint, node: Node) { + Debug.assert(state < TransformationState.Disposed, "Cannot substitute a node after the result is disposed."); + return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node; } /** * Enables before/after emit notifications in the pretty printer for the provided SyntaxKind. */ function enableEmitNotification(kind: SyntaxKind) { + Debug.assert(state < TransformationState.Completed, "Cannot modify the transformation context after transformation has completed."); enabledSyntaxKindFeatures[kind] |= SyntaxKindFeatureFlags.EmitNotifications; } @@ -194,17 +216,18 @@ namespace ts { /** * Emits a node with possible emit notification. * - * @param emitContext The current emit context. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emitCallback The callback used to emit the node. */ - function emitNodeWithNotification(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) { + function emitNodeWithNotification(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) { + Debug.assert(state < TransformationState.Disposed, "Cannot invoke TransformationResult callbacks after the result is disposed."); if (node) { if (isEmitNotificationEnabled(node)) { - context.onEmitNode(emitContext, node, emitCallback); + onEmitNode(hint, node, emitCallback); } else { - emitCallback(emitContext, node); + emitCallback(hint, node); } } } @@ -213,7 +236,8 @@ namespace ts { * Records a hoisted variable declaration for the provided name within a lexical environment. */ function hoistVariableDeclaration(name: Identifier): void { - Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the lexical environment during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot modify the lexical environment after transformation has completed."); const decl = createVariableDeclaration(name); if (!lexicalEnvironmentVariableDeclarations) { lexicalEnvironmentVariableDeclarations = [decl]; @@ -227,7 +251,8 @@ namespace ts { * Records a hoisted function declaration within a lexical environment. */ function hoistFunctionDeclaration(func: FunctionDeclaration): void { - Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the lexical environment during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot modify the lexical environment after transformation has completed."); if (!lexicalEnvironmentFunctionDeclarations) { lexicalEnvironmentFunctionDeclarations = [func]; } @@ -241,7 +266,8 @@ namespace ts { * are pushed onto a stack, and the related storage variables are reset. */ function startLexicalEnvironment(): void { - Debug.assert(!lexicalEnvironmentDisabled, "Cannot start a lexical environment during the print phase."); + Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the lexical environment during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot modify the lexical environment after transformation has completed."); Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); // Save the current lexical environment. Rather than resizing the array we adjust the @@ -257,14 +283,16 @@ namespace ts { /** Suspends the current lexical environment, usually after visiting a parameter list. */ function suspendLexicalEnvironment(): void { - Debug.assert(!lexicalEnvironmentDisabled, "Cannot suspend a lexical environment during the print phase."); + Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the lexical environment during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot modify the lexical environment after transformation has completed."); Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended."); lexicalEnvironmentSuspended = true; } /** Resumes a suspended lexical environment, usually before visiting a function body. */ function resumeLexicalEnvironment(): void { - Debug.assert(!lexicalEnvironmentDisabled, "Cannot resume a lexical environment during the print phase."); + Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the lexical environment during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot modify the lexical environment after transformation has completed."); Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended."); lexicalEnvironmentSuspended = false; } @@ -274,7 +302,8 @@ namespace ts { * any hoisted declarations added in this environment are returned. */ function endLexicalEnvironment(): Statement[] { - Debug.assert(!lexicalEnvironmentDisabled, "Cannot end a lexical environment during the print phase."); + Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the lexical environment during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot modify the lexical environment after transformation has completed."); Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); let statements: Statement[]; @@ -310,16 +339,39 @@ namespace ts { } function requestEmitHelper(helper: EmitHelper): void { - Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the transformation context during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot modify the transformation context after transformation has completed."); Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); emitHelpers = append(emitHelpers, helper); } function readEmitHelpers(): EmitHelper[] | undefined { - Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the transformation context during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot modify the transformation context after transformation has completed."); const helpers = emitHelpers; emitHelpers = undefined; return helpers; } + + function dispose() { + if (state < TransformationState.Disposed) { + // Clean up emit nodes on parse tree + for (const node of nodes) { + disposeEmitNodes(getSourceFileOfNode(getParseTreeNode(node))); + } + + // Release references to external entries for GC purposes. + lexicalEnvironmentVariableDeclarations = undefined; + lexicalEnvironmentVariableDeclarationsStack = undefined; + lexicalEnvironmentFunctionDeclarations = undefined; + lexicalEnvironmentFunctionDeclarationsStack = undefined; + onSubstituteNode = undefined; + onEmitNode = undefined; + emitHelpers = undefined; + + // Prevent further use of the transformation result. + state = TransformationState.Disposed; + } + } } } diff --git a/src/compiler/transformers/destructuring.ts b/src/compiler/transformers/destructuring.ts index 8e32259ff0f..bb129cd1187 100644 --- a/src/compiler/transformers/destructuring.ts +++ b/src/compiler/transformers/destructuring.ts @@ -6,6 +6,7 @@ namespace ts { interface FlattenContext { context: TransformationContext; level: FlattenLevel; + downlevelIteration: boolean; hoistTempVariables: boolean; emitExpression: (value: Expression) => void; emitBindingOrAssignment: (target: BindingOrAssignmentElementTarget, value: Expression, location: TextRange, original: Node) => void; @@ -57,6 +58,7 @@ namespace ts { const flattenContext: FlattenContext = { context, level, + downlevelIteration: context.getCompilerOptions().downlevelIteration, hoistTempVariables: true, emitExpression, emitBindingOrAssignment, @@ -112,7 +114,10 @@ namespace ts { Debug.assertNode(target, createAssignmentCallback ? isIdentifier : isExpression); const expression = createAssignmentCallback ? createAssignmentCallback(target, value, location) - : createAssignment(visitNode(target, visitor, isExpression), value, location); + : setTextRange( + createAssignment(visitNode(target, visitor, isExpression), value), + location + ); expression.original = original; emitExpression(expression); } @@ -143,6 +148,7 @@ namespace ts { const flattenContext: FlattenContext = { context, level, + downlevelIteration: context.getCompilerOptions().downlevelIteration, hoistTempVariables, emitExpression, emitBindingOrAssignment, @@ -174,9 +180,10 @@ namespace ts { const variable = createVariableDeclaration( name, /*type*/ undefined, - pendingExpressions ? inlineExpressions(append(pendingExpressions, value)) : value, - location); + pendingExpressions ? inlineExpressions(append(pendingExpressions, value)) : value + ); variable.original = original; + setTextRange(variable, location); if (isIdentifier(name)) { setEmitFlags(variable, EmitFlags.NoNestedSourceMaps); } @@ -308,7 +315,23 @@ namespace ts { function flattenArrayBindingOrAssignmentPattern(flattenContext: FlattenContext, parent: BindingOrAssignmentElement, pattern: ArrayBindingOrAssignmentPattern, value: Expression, location: TextRange) { const elements = getElementsOfBindingOrAssignmentPattern(pattern); const numElements = elements.length; - if (numElements !== 1 && (flattenContext.level < FlattenLevel.ObjectRest || numElements === 0)) { + if (flattenContext.level < FlattenLevel.ObjectRest && flattenContext.downlevelIteration) { + // Read the elements of the iterable into an array + value = ensureIdentifier( + flattenContext, + createReadHelper( + flattenContext.context, + value, + numElements > 0 && getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1]) + ? undefined + : numElements, + location + ), + /*reuseIdentifierExpressions*/ false, + location + ); + } + else if (numElements !== 1 && (flattenContext.level < FlattenLevel.ObjectRest || numElements === 0)) { // 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, @@ -416,7 +439,7 @@ namespace ts { const temp = createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { flattenContext.context.hoistVariableDeclaration(temp); - flattenContext.emitExpression(createAssignment(temp, value, location)); + flattenContext.emitExpression(setTextRange(createAssignment(temp, value), location)); } else { flattenContext.emitBindingOrAssignment(temp, value, location, /*original*/ undefined); @@ -444,7 +467,7 @@ namespace ts { } function makeBindingElement(name: Identifier) { - return createBindingElement(/*propertyName*/ undefined, /*dotDotDotToken*/ undefined, name); + return createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, name); } function makeAssignmentElement(name: Identifier) { @@ -492,6 +515,15 @@ namespace ts { } } } - return createCall(getHelperName("__rest"), undefined, [value, createArrayLiteral(propertyNames, location)]); + return createCall( + getHelperName("__rest"), + undefined, + [ + value, + setTextRange( + createArrayLiteral(propertyNames), + location + ) + ]); } } diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index e295ba11526..03d4b9ce328 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -1,5 +1,6 @@ /// /// +/// /*@internal*/ namespace ts { @@ -268,6 +269,7 @@ namespace ts { hoistVariableDeclaration, } = context; + const compilerOptions = context.getCompilerOptions(); const resolver = context.getEmitResolver(); const previousOnSubstituteNode = context.onSubstituteNode; const previousOnEmitNode = context.onEmitNode; @@ -514,7 +516,7 @@ namespace ts { exitSubtree(ancestorFacts, HierarchyFacts.None, HierarchyFacts.None); return updateSourceFileNode( node, - createNodeArray(statements, node.statements) + setTextRange(createNodeArray(statements), node.statements) ); } @@ -585,7 +587,7 @@ namespace ts { if (isGeneratedIdentifier(node)) { return node; } - if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + if (node.text !== "arguments" || !resolver.isArgumentsLocalBinding(node)) { return node; } return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = createUniqueName("arguments")); @@ -599,7 +601,7 @@ namespace ts { // - break/continue is non-labeled and located in non-converted loop/switch statement const jump = node.kind === SyntaxKind.BreakStatement ? Jump.Break : Jump.Continue; const canUseBreakOrContinue = - (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + (node.label && convertedLoopState.labels && convertedLoopState.labels.get(node.label.text)) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { @@ -671,9 +673,10 @@ namespace ts { setOriginalNode(variable, node); const statements: Statement[] = []; - const statement = createVariableStatement(/*modifiers*/ undefined, createVariableDeclarationList([variable]), /*location*/ node); + const statement = createVariableStatement(/*modifiers*/ undefined, createVariableDeclarationList([variable])); setOriginalNode(statement, node); + setTextRange(statement, node); startOnNewLine(statement); statements.push(statement); @@ -818,7 +821,7 @@ namespace ts { addRange(statements, endLexicalEnvironment()); - const block = createBlock(createNodeArray(statements, /*location*/ node.members), /*location*/ undefined, /*multiLine*/ true); + const block = createBlock(setTextRange(createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); setEmitFlags(block, EmitFlags.NoComments); return block; } @@ -833,8 +836,10 @@ namespace ts { function addExtendsHelperIfNeeded(statements: Statement[], node: ClassExpression | ClassDeclaration, extendsClauseElement: ExpressionWithTypeArguments): void { if (extendsClauseElement) { statements.push( - createStatement( - createExtendsHelper(context, getLocalName(node)), + setTextRange( + createStatement( + createExtendsHelper(context, getLocalName(node)) + ), /*location*/ extendsClauseElement ) ); @@ -854,19 +859,18 @@ namespace ts { const ancestorFacts = enterSubtree(HierarchyFacts.ConstructorExcludes, HierarchyFacts.ConstructorIncludes); const constructor = getFirstConstructorWithBody(node); const hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - const constructorFunction = - createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - getDeclarationName(node), - /*typeParameters*/ undefined, - transformConstructorParameters(constructor, hasSynthesizedSuper), - /*type*/ undefined, - transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), - /*location*/ constructor || node - ); + const constructorFunction = createFunctionDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + getDeclarationName(node), + /*typeParameters*/ undefined, + transformConstructorParameters(constructor, hasSynthesizedSuper), + /*type*/ undefined, + transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) + ); + setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { setEmitFlags(constructorFunction, EmitFlags.CapturesThis); } @@ -925,7 +929,10 @@ namespace ts { } - const superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + // determine whether the class is known syntactically to be a derived class (e.g. a + // class that extends a value that is not syntactically known to be `null`). + const isDerivedClass = extendsClauseElement && skipOuterExpressions(extendsClauseElement.expression).kind !== SyntaxKind.NullKeyword; + const superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); // The last statement expression was replaced. Skip it. if (superCaptureStatus === SuperCaptureResult.ReplaceSuperCapture || superCaptureStatus === SuperCaptureResult.ReplaceWithReturn) { @@ -942,7 +949,7 @@ namespace ts { // Return `_this` unless we're sure enough that it would be pointless to add a return statement. // If there's a constructor that we can tell returns in enough places, then we *do not* want to add a return. - if (extendsClauseElement + if (isDerivedClass && superCaptureStatus !== SuperCaptureResult.ReplaceWithReturn && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push( @@ -959,14 +966,16 @@ namespace ts { } const block = createBlock( - createNodeArray( - statements, + setTextRange( + createNodeArray( + statements + ), /*location*/ constructor ? constructor.body.statements : node.members ), - /*location*/ constructor ? constructor.body : node, /*multiLine*/ true ); + setTextRange(block, constructor ? constructor.body : node); if (!constructor) { setEmitFlags(block, EmitFlags.NoComments); } @@ -1011,11 +1020,11 @@ namespace ts { function declareOrCaptureOrReturnThisForConstructorIfNeeded( statements: Statement[], ctor: ConstructorDeclaration | undefined, - hasExtendsClause: boolean, + isDerivedClass: boolean, hasSynthesizedSuper: boolean, statementOffset: number) { // If this isn't a derived class, just capture 'this' for arrow functions if necessary. - if (!hasExtendsClause) { + if (!isDerivedClass) { if (ctor) { addCaptureThisForNodeIfNeeded(statements, ctor); } @@ -1091,7 +1100,7 @@ namespace ts { } // Perform the capture. - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement); // If we're actually replacing the original statement, we need to signal this to the caller. if (superCallExpression) { @@ -1101,15 +1110,25 @@ namespace ts { return SuperCaptureResult.NoReplacement; } + function createActualThis() { + return setEmitFlags(createThis(), EmitFlags.NoSubstitution); + } + function createDefaultSuperCallOrThis() { - const actualThis = createThis(); - setEmitFlags(actualThis, EmitFlags.NoSubstitution); - const superCall = createFunctionApply( - createIdentifier("_super"), - actualThis, - createIdentifier("arguments"), + return createLogicalOr( + createLogicalAnd( + createStrictInequality( + createIdentifier("_super"), + createNull() + ), + createFunctionApply( + createIdentifier("_super"), + createActualThis(), + createIdentifier("arguments"), + ) + ), + createActualThis() ); - return createLogicalOr(superCall, actualThis); } /** @@ -1126,14 +1145,16 @@ namespace ts { // Binding patterns are converted into a generated name and are // evaluated inside the function body. return setOriginalNode( - createParameter( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, - getGeneratedNameForNode(node), - /*questionToken*/ undefined, - /*type*/ undefined, - /*initializer*/ undefined, + setTextRange( + createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + getGeneratedNameForNode(node), + /*questionToken*/ undefined, + /*type*/ undefined, + /*initializer*/ undefined + ), /*location*/ node ), /*original*/ node @@ -1142,14 +1163,16 @@ namespace ts { else if (node.initializer) { // Initializers are elided return setOriginalNode( - createParameter( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, - node.name, - /*questionToken*/ undefined, - /*type*/ undefined, - /*initializer*/ undefined, + setTextRange( + createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + node.name, + /*questionToken*/ undefined, + /*type*/ undefined, + /*initializer*/ undefined + ), /*location*/ node ), /*original*/ node @@ -1261,21 +1284,25 @@ namespace ts { const statement = createIf( createTypeCheck(getSynthesizedClone(name), "undefined"), setEmitFlags( - createBlock([ - createStatement( - createAssignment( - setEmitFlags(getMutableClone(name), EmitFlags.NoSourceMap), - setEmitFlags(initializer, EmitFlags.NoSourceMap | getEmitFlags(initializer)), - /*location*/ parameter + setTextRange( + createBlock([ + createStatement( + setTextRange( + createAssignment( + setEmitFlags(getMutableClone(name), EmitFlags.NoSourceMap), + setEmitFlags(initializer, EmitFlags.NoSourceMap | getEmitFlags(initializer)) + ), + parameter + ) ) - ) - ], /*location*/ parameter), + ]), + parameter + ), EmitFlags.SingleLine | EmitFlags.NoTrailingSourceMap | EmitFlags.NoTokenSourceMaps - ), - /*elseStatement*/ undefined, - /*location*/ parameter + ) ); statement.startsOnNewLine = true; + setTextRange(statement, parameter); setEmitFlags(statement, EmitFlags.NoTokenSourceMaps | EmitFlags.NoTrailingSourceMap | EmitFlags.CustomPrologue); statements.push(statement); } @@ -1319,15 +1346,17 @@ namespace ts { // var param = []; statements.push( setEmitFlags( - createVariableStatement( - /*modifiers*/ undefined, - createVariableDeclarationList([ - createVariableDeclaration( - declarationName, - /*type*/ undefined, - createArrayLiteral([]) - ) - ]), + setTextRange( + createVariableStatement( + /*modifiers*/ undefined, + createVariableDeclarationList([ + createVariableDeclaration( + declarationName, + /*type*/ undefined, + createArrayLiteral([]) + ) + ]) + ), /*location*/ parameter ), EmitFlags.CustomPrologue @@ -1338,26 +1367,33 @@ namespace ts { // param[_i - restIndex] = arguments[_i]; // } const forStatement = createFor( - createVariableDeclarationList([ - createVariableDeclaration(temp, /*type*/ undefined, createLiteral(restIndex)) - ], /*location*/ parameter), - createLessThan( - temp, - createPropertyAccess(createIdentifier("arguments"), "length"), - /*location*/ parameter + setTextRange( + createVariableDeclarationList([ + createVariableDeclaration(temp, /*type*/ undefined, createLiteral(restIndex)) + ]), + parameter ), - createPostfixIncrement(temp, /*location*/ parameter), + setTextRange( + createLessThan( + temp, + createPropertyAccess(createIdentifier("arguments"), "length") + ), + parameter + ), + setTextRange(createPostfixIncrement(temp), parameter), createBlock([ startOnNewLine( - createStatement( - createAssignment( - createElementAccess( - expressionName, - restIndex === 0 - ? temp - : createSubtract(temp, createLiteral(restIndex)) - ), - createElementAccess(createIdentifier("arguments"), temp) + setTextRange( + createStatement( + createAssignment( + createElementAccess( + expressionName, + restIndex === 0 + ? temp + : createSubtract(temp, createLiteral(restIndex)) + ), + createElementAccess(createIdentifier("arguments"), temp) + ) ), /*location*/ parameter ) @@ -1392,11 +1428,10 @@ namespace ts { /*type*/ undefined, initializer ) - ]), - originalStatement + ]) ); - setEmitFlags(captureThisStatement, EmitFlags.NoComments | EmitFlags.CustomPrologue); + setTextRange(captureThisStatement, originalStatement); setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } @@ -1516,7 +1551,7 @@ namespace ts { * @param member The SemicolonClassElement node. */ function transformSemicolonClassElementToStatement(member: SemicolonClassElement) { - return createEmptyStatement(/*location*/ member); + return setTextRange(createEmptyStatement(), member); } /** @@ -1534,8 +1569,10 @@ namespace ts { setEmitFlags(memberFunction, EmitFlags.NoComments); setSourceMapRange(memberFunction, sourceMapRange); - const statement = createStatement( - createAssignment(memberName, memberFunction), + const statement = setTextRange( + createStatement( + createAssignment(memberName, memberFunction) + ), /*location*/ member ); @@ -1558,15 +1595,12 @@ namespace ts { * @param accessors The set of related get/set accessors. */ function transformAccessorsToStatement(receiver: LeftHandSideExpression, accessors: AllAccessorDeclarations, container: Node): Statement { - const statement = createStatement( - transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false), - /*location*/ getSourceMapRange(accessors.firstAccessor) - ); - + const statement = createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false)); // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. setEmitFlags(statement, EmitFlags.NoComments); + setSourceMapRange(statement, getSourceMapRange(accessors.firstAccessor)); return statement; } @@ -1609,8 +1643,8 @@ namespace ts { } properties.push( - createPropertyAssignment("enumerable", createLiteral(true)), - createPropertyAssignment("configurable", createLiteral(true)) + createPropertyAssignment("enumerable", createTrue()), + createPropertyAssignment("configurable", createTrue()) ); const call = createCall( @@ -1619,7 +1653,7 @@ namespace ts { [ target, propertyName, - createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true) + createObjectLiteral(properties, /*multiLine*/ true) ] ); if (startsOnNewLine) { @@ -1649,9 +1683,9 @@ namespace ts { /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, - transformFunctionBody(node), - node + transformFunctionBody(node) ); + setTextRange(func, node); setOriginalNode(func, node); setEmitFlags(func, EmitFlags.CapturesThis); exitSubtree(ancestorFacts, HierarchyFacts.None, HierarchyFacts.None); @@ -1684,6 +1718,7 @@ namespace ts { return updateFunctionExpression( node, /*modifiers*/ undefined, + node.asteriskToken, name, /*typeParameters*/ undefined, parameters, @@ -1715,6 +1750,7 @@ namespace ts { node, /*decorators*/ undefined, visitNodes(node.modifiers, visitor, isModifier), + node.asteriskToken, name, /*typeParameters*/ undefined, parameters, @@ -1745,14 +1781,16 @@ namespace ts { exitSubtree(ancestorFacts, HierarchyFacts.PropagateNewTargetMask, HierarchyFacts.None); convertedLoopState = savedConvertedLoopState; return setOriginalNode( - createFunctionExpression( - /*modifiers*/ undefined, - node.asteriskToken, - name, - /*typeParameters*/ undefined, - parameters, - /*type*/ undefined, - body, + setTextRange( + createFunctionExpression( + /*modifiers*/ undefined, + node.asteriskToken, + name, + /*typeParameters*/ undefined, + parameters, + /*type*/ undefined, + body + ), location ), /*original*/ node @@ -1819,7 +1857,8 @@ namespace ts { } const expression = visitNode(body, visitor, isExpression); - const returnStatement = createReturn(expression, /*location*/ body); + const returnStatement = createReturn(expression); + setTextRange(returnStatement, body); setEmitFlags(returnStatement, EmitFlags.NoTokenSourceMaps | EmitFlags.NoTrailingSourceMap | EmitFlags.NoTrailingComments); statements.push(returnStatement); @@ -1838,7 +1877,8 @@ namespace ts { multiLine = true; } - const block = createBlock(createNodeArray(statements, statementsLocation), node.body, multiLine); + const block = createBlock(setTextRange(createNodeArray(statements), statementsLocation), multiLine); + setTextRange(block, node.body); if (!multiLine && singleLine) { setEmitFlags(block, EmitFlags.SingleLine); } @@ -1855,8 +1895,10 @@ namespace ts { const updated = visitFunctionBody(node.body, functionBodyVisitor, context); return updateBlock( updated, - createNodeArray( - prependCaptureNewTargetIfNeeded(updated.statements, node, /*copyOnWrite*/ true), + setTextRange( + createNodeArray( + prependCaptureNewTargetIfNeeded(updated.statements, node, /*copyOnWrite*/ true) + ), /*location*/ updated.statements ) ); @@ -1901,6 +1943,9 @@ namespace ts { function visitParenthesizedExpression(node: ParenthesizedExpression, needsDestructuringValue: boolean): ParenthesizedExpression { // If we are here it is most likely because our expression is a destructuring assignment. if (!needsDestructuringValue) { + // By default we always emit the RHS at the end of a flattened destructuring + // expression. If we are in a state where we do not need the destructuring value, + // we pass that information along to the children that care about it. switch (node.expression.kind) { case SyntaxKind.ParenthesizedExpression: return updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); @@ -1952,11 +1997,12 @@ namespace ts { else { assignment = createBinary(decl.name, SyntaxKind.EqualsToken, visitNode(decl.initializer, visitor, isExpression)); } - (assignments || (assignments = [])).push(assignment); + + assignments = append(assignments, assignment); } } if (assignments) { - updated = createStatement(reduceLeft(assignments, (acc, v) => createBinary(v, SyntaxKind.CommaToken, acc)), node); + updated = setTextRange(createStatement(reduceLeft(assignments, (acc, v) => createBinary(v, SyntaxKind.CommaToken, acc))), node); } else { // none of declarations has initializer - the entire variable statement can be deleted @@ -1986,8 +2032,9 @@ namespace ts { ? visitVariableDeclarationInLetDeclarationList : visitVariableDeclaration)); - const declarationList = createVariableDeclarationList(declarations, /*location*/ node); + const declarationList = createVariableDeclarationList(declarations); setOriginalNode(declarationList, node); + setTextRange(declarationList, node); setCommentRange(declarationList, node); if (node.transformFlags & TransformFlags.ContainsBindingPattern @@ -2122,23 +2169,37 @@ namespace ts { } function recordLabel(node: LabeledStatement) { - convertedLoopState.labels[node.label.text] = node.label.text; + convertedLoopState.labels.set(node.label.text, node.label.text); } function resetLabel(node: LabeledStatement) { - convertedLoopState.labels[node.label.text] = undefined; + convertedLoopState.labels.set(node.label.text, undefined); } function visitLabeledStatement(node: LabeledStatement): VisitResult { if (convertedLoopState && !convertedLoopState.labels) { convertedLoopState.labels = createMap(); } - const statement = unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); - return isIterationStatement(statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(statement) + const statement = unwrapInnermostStatementOfLabel(node, convertedLoopState && recordLabel); + return isIterationStatement(statement, /*lookInLabeledStatements*/ false) ? visitIterationStatement(statement, /*outermostLabeledStatement*/ node) : restoreEnclosingLabel(visitNode(statement, visitor, isStatement), node, convertedLoopState && resetLabel); } + function visitIterationStatement(node: IterationStatement, outermostLabeledStatement: LabeledStatement) { + switch (node.kind) { + case SyntaxKind.DoStatement: + case SyntaxKind.WhileStatement: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case SyntaxKind.ForStatement: + return visitForStatement(node, outermostLabeledStatement); + case SyntaxKind.ForInStatement: + return visitForInStatement(node, outermostLabeledStatement); + case SyntaxKind.ForOfStatement: + return visitForOfStatement(node, outermostLabeledStatement); + } + } + function visitIterationStatementWithFacts(excludeFacts: HierarchyFacts, includeFacts: HierarchyFacts, node: IterationStatement, outermostLabeledStatement: LabeledStatement, convert?: LoopConverter) { const ancestorFacts = enterSubtree(excludeFacts, includeFacts); const updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); @@ -2176,10 +2237,116 @@ namespace ts { HierarchyFacts.ForInOrForOfStatementIncludes, node, outermostLabeledStatement, - convertForOfToFor); + compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); } - function convertForOfToFor(node: ForOfStatement, outermostLabeledStatement: LabeledStatement, convertedLoopBodyStatements: Statement[]): Statement { + function convertForOfStatementHead(node: ForOfStatement, boundValue: Expression, convertedLoopBodyStatements: Statement[]) { + const statements: Statement[] = []; + if (isVariableDeclarationList(node.initializer)) { + if (node.initializer.flags & NodeFlags.BlockScoped) { + enableSubstitutionsForBlockScopedBindings(); + } + + const firstOriginalDeclaration = firstOrUndefined(node.initializer.declarations); + if (firstOriginalDeclaration && isBindingPattern(firstOriginalDeclaration.name)) { + // This works whether the declaration is a var, let, or const. + // It will use rhsIterationValue _a[_i] as the initializer. + const declarations = flattenDestructuringBinding( + firstOriginalDeclaration, + visitor, + context, + FlattenLevel.All, + boundValue + ); + + const declarationList = setTextRange(createVariableDeclarationList(declarations), node.initializer); + setOriginalNode(declarationList, node.initializer); + + // Adjust the source map range for the first declaration to align with the old + // emitter. + const firstDeclaration = declarations[0]; + const lastDeclaration = lastOrUndefined(declarations); + setSourceMapRange(declarationList, createRange(firstDeclaration.pos, lastDeclaration.end)); + + statements.push( + createVariableStatement( + /*modifiers*/ undefined, + declarationList + ) + ); + } + else { + // The following call does not include the initializer, so we have + // to emit it separately. + statements.push( + setTextRange( + createVariableStatement( + /*modifiers*/ undefined, + setOriginalNode( + setTextRange( + createVariableDeclarationList([ + createVariableDeclaration( + firstOriginalDeclaration ? firstOriginalDeclaration.name : createTempVariable(/*recordTempVariable*/ undefined), + /*type*/ undefined, + boundValue + ) + ]), + moveRangePos(node.initializer, -1) + ), + node.initializer + ) + ), + moveRangeEnd(node.initializer, -1) + ) + ); + } + } + else { + // Initializer is an expression. Emit the expression in the body, so that it's + // evaluated on every iteration. + const assignment = createAssignment(node.initializer, boundValue); + if (isDestructuringAssignment(assignment)) { + aggregateTransformFlags(assignment); + statements.push(createStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); + } + else { + assignment.end = node.initializer.end; + statements.push(setTextRange(createStatement(visitNode(assignment, visitor, isExpression)), moveRangeEnd(node.initializer, -1))); + } + } + + let bodyLocation: TextRange; + let statementsLocation: TextRange; + if (convertedLoopBodyStatements) { + addRange(statements, convertedLoopBodyStatements); + } + else { + const statement = visitNode(node.statement, visitor, isStatement, liftToBlock); + if (isBlock(statement)) { + addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); + } + } + + // The old emitter does not emit source maps for the block. + // We add the location to preserve comments. + return setEmitFlags( + setTextRange( + createBlock( + setTextRange(createNodeArray(statements), statementsLocation), + /*multiLine*/ true + ), + bodyLocation, + ), + EmitFlags.NoSourceMap | EmitFlags.NoTokenSourceMaps + ); + } + + function convertForOfStatementForArray(node: ForOfStatement, outermostLabeledStatement: LabeledStatement, convertedLoopBodyStatements: Statement[]): Statement { // The following ES6 code: // // for (let v of expr) { } @@ -2202,8 +2369,6 @@ namespace ts { // for-of bodies are always emitted as blocks. const expression = visitNode(node.expression, visitor, isExpression); - const initializer = node.initializer; - const statements: Statement[] = []; // In the case where the user wrote an identifier as the RHS, like this: // @@ -2211,156 +2376,150 @@ namespace ts { // // we don't want to emit a temporary variable for the RHS, just use it directly. const counter = createLoopVariable(); - const rhsReference = expression.kind === SyntaxKind.Identifier - ? createUniqueName((expression).text) - : createTempVariable(/*recordTempVariable*/ undefined); - const elementAccess = createElementAccess(rhsReference, counter); - - // Initialize LHS - // var v = _a[_i]; - if (isVariableDeclarationList(initializer)) { - if (initializer.flags & NodeFlags.BlockScoped) { - enableSubstitutionsForBlockScopedBindings(); - } - - const firstOriginalDeclaration = firstOrUndefined(initializer.declarations); - if (firstOriginalDeclaration && isBindingPattern(firstOriginalDeclaration.name)) { - // This works whether the declaration is a var, let, or const. - // It will use rhsIterationValue _a[_i] as the initializer. - const declarations = flattenDestructuringBinding( - firstOriginalDeclaration, - visitor, - context, - FlattenLevel.All, - elementAccess - ); - - const declarationList = createVariableDeclarationList(declarations, /*location*/ initializer); - setOriginalNode(declarationList, initializer); - - // Adjust the source map range for the first declaration to align with the old - // emitter. - const firstDeclaration = declarations[0]; - const lastDeclaration = lastOrUndefined(declarations); - setSourceMapRange(declarationList, createRange(firstDeclaration.pos, lastDeclaration.end)); - - statements.push( - createVariableStatement( - /*modifiers*/ undefined, - declarationList - ) - ); - } - else { - // The following call does not include the initializer, so we have - // to emit it separately. - statements.push( - createVariableStatement( - /*modifiers*/ undefined, - setOriginalNode( - createVariableDeclarationList([ - createVariableDeclaration( - firstOriginalDeclaration ? firstOriginalDeclaration.name : createTempVariable(/*recordTempVariable*/ undefined), - /*type*/ undefined, - createElementAccess(rhsReference, counter) - ) - ], /*location*/ moveRangePos(initializer, -1)), - initializer - ), - /*location*/ moveRangeEnd(initializer, -1) - ) - ); - } - } - else { - // Initializer is an expression. Emit the expression in the body, so that it's - // evaluated on every iteration. - const assignment = createAssignment(initializer, elementAccess); - if (isDestructuringAssignment(assignment)) { - // This is a destructuring pattern, so we flatten the destructuring instead. - statements.push( - createStatement( - flattenDestructuringAssignment( - assignment, - visitor, - context, - FlattenLevel.All - ) - ) - ); - } - else { - // Currently there is not way to check that assignment is binary expression of destructing assignment - // so we have to cast never type to binaryExpression - (assignment).end = initializer.end; - statements.push(createStatement(assignment, /*location*/ moveRangeEnd(initializer, -1))); - } - } - - let bodyLocation: TextRange; - let statementsLocation: TextRange; - if (convertedLoopBodyStatements) { - addRange(statements, convertedLoopBodyStatements); - } - else { - const statement = visitNode(node.statement, visitor, isStatement); - if (isBlock(statement)) { - addRange(statements, statement.statements); - bodyLocation = statement; - statementsLocation = statement.statements; - } - else { - statements.push(statement); - } - } + const rhsReference = isIdentifier(expression) ? getGeneratedNameForNode(expression) : createTempVariable(/*recordTempVariable*/ undefined); // The old emitter does not emit source maps for the expression setEmitFlags(expression, EmitFlags.NoSourceMap | getEmitFlags(expression)); - // The old emitter does not emit source maps for the block. - // We add the location to preserve comments. - const body = createBlock( - createNodeArray(statements, /*location*/ statementsLocation), - /*location*/ bodyLocation - ); - - setEmitFlags(body, EmitFlags.NoSourceMap | EmitFlags.NoTokenSourceMaps); - - const forStatement = createFor( - setEmitFlags( - createVariableDeclarationList([ - createVariableDeclaration(counter, /*type*/ undefined, createLiteral(0), /*location*/ moveRangePos(node.expression, -1)), - createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) - ], /*location*/ node.expression), - EmitFlags.NoHoisting + const forStatement = setTextRange( + createFor( + /*initializer*/ setEmitFlags( + setTextRange( + createVariableDeclarationList([ + setTextRange(createVariableDeclaration(counter, /*type*/ undefined, createLiteral(0)), moveRangePos(node.expression, -1)), + setTextRange(createVariableDeclaration(rhsReference, /*type*/ undefined, expression), node.expression) + ]), + node.expression + ), + EmitFlags.NoHoisting + ), + /*condition*/ setTextRange( + createLessThan( + counter, + createPropertyAccess(rhsReference, "length") + ), + node.expression + ), + /*incrementor*/ setTextRange(createPostfixIncrement(counter), node.expression), + /*statement*/ convertForOfStatementHead( + node, + createElementAccess(rhsReference, counter), + convertedLoopBodyStatements + ) ), - createLessThan( - counter, - createPropertyAccess(rhsReference, "length"), - /*location*/ node.expression - ), - createPostfixIncrement(counter, /*location*/ node.expression), - body, /*location*/ node ); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. setEmitFlags(forStatement, EmitFlags.NoTokenTrailingSourceMaps); + setTextRange(forStatement, node); return restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } - function visitIterationStatement(node: IterationStatement, outermostLabeledStatement: LabeledStatement) { - switch (node.kind) { - case SyntaxKind.DoStatement: - case SyntaxKind.WhileStatement: - return visitDoOrWhileStatement(node, outermostLabeledStatement); - case SyntaxKind.ForStatement: - return visitForStatement(node, outermostLabeledStatement); - case SyntaxKind.ForInStatement: - return visitForInStatement(node, outermostLabeledStatement); - case SyntaxKind.ForOfStatement: - return visitForOfStatement(node, outermostLabeledStatement); - } + function convertForOfStatementForIterable(node: ForOfStatement, outermostLabeledStatement: LabeledStatement, convertedLoopBodyStatements: Statement[]): Statement { + const expression = visitNode(node.expression, visitor, isExpression); + const iterator = isIdentifier(expression) ? getGeneratedNameForNode(expression) : createTempVariable(/*recordTempVariable*/ undefined); + const result = isIdentifier(expression) ? getGeneratedNameForNode(iterator) : createTempVariable(/*recordTempVariable*/ undefined); + const errorRecord = createUniqueName("e"); + const catchVariable = getGeneratedNameForNode(errorRecord); + const returnMethod = createTempVariable(/*recordTempVariable*/ undefined); + const values = createValuesHelper(context, expression, node.expression); + const next = createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, []); + + hoistVariableDeclaration(errorRecord); + hoistVariableDeclaration(returnMethod); + + const forStatement = setEmitFlags( + setTextRange( + createFor( + /*initializer*/ setEmitFlags( + setTextRange( + createVariableDeclarationList([ + setTextRange(createVariableDeclaration(iterator, /*type*/ undefined, values), node.expression), + createVariableDeclaration(result, /*type*/ undefined, next) + ]), + node.expression + ), + EmitFlags.NoHoisting + ), + /*condition*/ createLogicalNot(createPropertyAccess(result, "done")), + /*incrementor*/ createAssignment(result, next), + /*statement*/ convertForOfStatementHead( + node, + createPropertyAccess(result, "value"), + convertedLoopBodyStatements + ) + ), + /*location*/ node + ), + EmitFlags.NoTokenTrailingSourceMaps + ); + + return createTry( + createBlock([ + restoreEnclosingLabel( + forStatement, + outermostLabeledStatement, + convertedLoopState && resetLabel + ) + ]), + createCatchClause(createVariableDeclaration(catchVariable), + setEmitFlags( + createBlock([ + createStatement( + createAssignment( + errorRecord, + createObjectLiteral([ + createPropertyAssignment("error", catchVariable) + ]) + ) + ) + ]), + EmitFlags.SingleLine + ) + ), + createBlock([ + createTry( + /*tryBlock*/ createBlock([ + setEmitFlags( + createIf( + createLogicalAnd( + createLogicalAnd( + result, + createLogicalNot( + createPropertyAccess(result, "done") + ) + ), + createAssignment( + returnMethod, + createPropertyAccess(iterator, "return") + ) + ), + createStatement( + createFunctionCall(returnMethod, iterator, []) + ) + ), + EmitFlags.SingleLine + ), + ]), + /*catchClause*/ undefined, + /*finallyBlock*/ setEmitFlags( + createBlock([ + setEmitFlags( + createIf( + errorRecord, + createThrow( + createPropertyAccess(errorRecord, "error") + ) + ), + EmitFlags.SingleLine + ) + ]), + EmitFlags.SingleLine + ) + ) + ]) + ); } /** @@ -2405,7 +2564,6 @@ namespace ts { setEmitFlags( createObjectLiteral( visitNodes(properties, visitor, isObjectLiteralElementLike, 0, numInitialProperties), - /*location*/ undefined, node.multiLine ), EmitFlags.Indented @@ -2521,7 +2679,7 @@ namespace ts { } startLexicalEnvironment(); - let loopBody = visitNode(node.statement, visitor, isStatement, /*optional*/ false, liftToBlock); + let loopBody = visitNode(node.statement, visitor, isStatement, liftToBlock); const lexicalEnvironment = endLexicalEnvironment(); const currentState = convertedLoopState; @@ -2533,14 +2691,14 @@ namespace ts { copyOutParameters(loopOutParameters, CopyDirection.ToOutParameter, statements); } addRange(statements, lexicalEnvironment) - loopBody = createBlock(statements, /*location*/ undefined, /*multiline*/ true); + loopBody = createBlock(statements, /*multiline*/ true); } if (isBlock(loopBody)) { loopBody.multiLine = true; } else { - loopBody = createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); + loopBody = createBlock([loopBody], /*multiline*/ true); } const isAsyncBlockContainingAwait = @@ -2663,6 +2821,7 @@ namespace ts { } const convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); + let loop: Statement; if (convert) { loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); @@ -2674,12 +2833,7 @@ namespace ts { // visit childnodes to transform initializer/condition/incrementor parts clone = visitEachChild(clone, visitor, context); // set loop statement - clone.statement = createBlock( - convertedLoopBodyStatements, - /*location*/ undefined, - /*multiline*/ true - ); - + clone.statement = createBlock(convertedLoopBodyStatements, /*multiline*/ true); // reset and re-aggregate the transform flags clone.transformFlags = 0; aggregateTransformFlags(clone); @@ -2785,13 +2939,13 @@ namespace ts { if (!state.labeledNonLocalBreaks) { state.labeledNonLocalBreaks = createMap(); } - state.labeledNonLocalBreaks[labelText] = labelMarker; + state.labeledNonLocalBreaks.set(labelText, labelMarker); } else { if (!state.labeledNonLocalContinues) { state.labeledNonLocalContinues = createMap(); } - state.labeledNonLocalContinues[labelText] = labelMarker; + state.labeledNonLocalContinues.set(labelText, labelMarker); } } @@ -2799,13 +2953,12 @@ namespace ts { if (!table) { return; } - for (const labelText in table) { - const labelMarker = table[labelText]; + table.forEach((labelMarker, labelText) => { const statements: Statement[] = []; // 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 (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) { const label = createIdentifier(labelText); statements.push(isBreak ? createBreak(label) : createContinue(label)); } @@ -2814,7 +2967,7 @@ namespace ts { statements.push(createReturn(loopResultName)); } caseClauses.push(createCaseClause(createLiteral(labelMarker), statements)); - } + }); } function processLoopVariableDeclaration(decl: VariableDeclaration | BindingElement, loopParameters: ParameterDeclaration[], loopOutParameters: LoopOutParameter[]) { @@ -2829,7 +2982,7 @@ namespace ts { else { loopParameters.push(createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); if (resolver.getNodeCheckFlags(decl) & NodeCheckFlags.NeedsLoopOutParameter) { - const outParamName = createUniqueName("out_" + name.text); + const outParamName = createUniqueName("out_" + unescapeIdentifier(name.text)); loopOutParameters.push({ originalName: name, outParamName }); } } @@ -2891,9 +3044,9 @@ namespace ts { receiver, visitNode(property.name, visitor, isPropertyName) ), - visitNode(property.initializer, visitor, isExpression), - /*location*/ property + visitNode(property.initializer, visitor, isExpression) ); + setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -2913,9 +3066,9 @@ namespace ts { receiver, visitNode(property.name, visitor, isPropertyName) ), - getSynthesizedClone(property.name), - /*location*/ property + getSynthesizedClone(property.name) ); + setTextRange(expression, property); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -2936,9 +3089,9 @@ namespace ts { receiver, visitNode(method.name, visitor, isPropertyName) ), - transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined, container), - /*location*/ method + transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined, container) ); + setTextRange(expression, method); if (startsOnNewLine) { expression.startsOnNewLine = true; } @@ -2951,7 +3104,8 @@ namespace ts { let updated: CatchClause; if (isBindingPattern(node.variableDeclaration.name)) { const temp = createTempVariable(undefined); - const newVariableDeclaration = createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + const newVariableDeclaration = createVariableDeclaration(temp); + setTextRange(newVariableDeclaration, node.variableDeclaration); const vars = flattenDestructuringBinding( node.variableDeclaration, visitor, @@ -2959,8 +3113,9 @@ namespace ts { FlattenLevel.All, temp ); - const list = createVariableDeclarationList(vars, /*location*/node.variableDeclaration, /*flags*/node.variableDeclaration.flags); - const destructure = createVariableStatement(undefined, list); + const list = createVariableDeclarationList(vars); + setTextRange(list, node.variableDeclaration); + const destructure = createVariableStatement(/*modifiers*/ undefined, list); updated = updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); } else { @@ -2989,9 +3144,11 @@ namespace ts { Debug.assert(!isComputedPropertyName(node.name)); const functionExpression = transformFunctionLikeToExpression(node, /*location*/ moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); setEmitFlags(functionExpression, EmitFlags.NoLeadingComments | getEmitFlags(functionExpression)); - return createPropertyAssignment( - node.name, - functionExpression, + return setTextRange( + createPropertyAssignment( + node.name, + functionExpression + ), /*location*/ node ); } @@ -3018,9 +3175,11 @@ namespace ts { * @param node A ShorthandPropertyAssignment node. */ function visitShorthandPropertyAssignment(node: ShorthandPropertyAssignment): ObjectLiteralElementLike { - return createPropertyAssignment( - node.name, - getSynthesizedClone(node.name), + return setTextRange( + createPropertyAssignment( + node.name, + getSynthesizedClone(node.name) + ), /*location*/ node ); } @@ -3190,15 +3349,30 @@ namespace ts { ) ); - if (segments.length === 1) { - const firstElement = elements[0]; - return needsUniqueCopy && isSpreadExpression(firstElement) && firstElement.expression.kind !== SyntaxKind.ArrayLiteralExpression - ? createArraySlice(segments[0]) - : segments[0]; - } + if (compilerOptions.downlevelIteration) { + if (segments.length === 1) { + const firstSegment = segments[0]; + if (isCallExpression(firstSegment) + && isIdentifier(firstSegment.expression) + && (getEmitFlags(firstSegment.expression) & EmitFlags.HelperName) + && firstSegment.expression.text === "___spread") { + return segments[0]; + } + } - // Rewrite using the pattern .concat(, , ...) - return createArrayConcat(segments.shift(), segments); + return createSpreadHelper(context, segments); + } + else { + if (segments.length === 1) { + const firstElement = elements[0]; + return needsUniqueCopy && isSpreadExpression(firstElement) && firstElement.expression.kind !== SyntaxKind.ArrayLiteralExpression + ? createArraySlice(segments[0]) + : segments[0]; + } + + // Rewrite using the pattern .concat(, , ...) + return createArrayConcat(segments.shift(), segments); + } } function partitionSpread(node: Expression) { @@ -3213,8 +3387,7 @@ namespace ts { function visitSpanOfNonSpreads(chunk: Expression[], multiLine: boolean, hasTrailingComma: boolean): VisitResult { return createArrayLiteral( - visitNodes(createNodeArray(chunk, /*location*/ undefined, hasTrailingComma), visitor, isExpression), - /*location*/ undefined, + visitNodes(createNodeArray(chunk, hasTrailingComma), visitor, isExpression), multiLine ); } @@ -3238,7 +3411,7 @@ namespace ts { * @param node A template literal. */ function visitTemplateLiteral(node: LiteralExpression): LeftHandSideExpression { - return createLiteral(node.text, /*location*/ node); + return setTextRange(createLiteral(node.text), node); } /** @@ -3306,7 +3479,7 @@ namespace ts { // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's // and LineTerminatorSequences are normalized to for both TV and TRV. text = text.replace(/\r\n?/g, "\n"); - return createLiteral(text, /*location*/ node); + return setTextRange(createLiteral(text), node); } /** @@ -3330,7 +3503,8 @@ namespace ts { // "abc" + (1 << 2) + "" const expression = reduceLeft(expressions, createAdd); if (nodeIsSynthesized(expression)) { - setTextRange(expression, node); + expression.pos = node.pos; + expression.end = node.end; } return expression; @@ -3423,9 +3597,11 @@ namespace ts { /** * Called by the printer just before a node is printed. * + * @param hint A hint as to the intended usage of the node. * @param node The node to be printed. + * @param emitCallback The callback used to emit the node. */ - function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) { + function onEmitNode(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) { if (enabledSubstitutions & ES2015SubstitutionFlags.CapturedThis && isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. const ancestorFacts = enterSubtree( @@ -3433,11 +3609,11 @@ namespace ts { getEmitFlags(node) & EmitFlags.CapturesThis ? HierarchyFacts.FunctionIncludes | HierarchyFacts.CapturesThis : HierarchyFacts.FunctionIncludes); - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); exitSubtree(ancestorFacts, HierarchyFacts.None, HierarchyFacts.None); return; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } /** @@ -3472,13 +3648,13 @@ namespace ts { /** * Hooks node substitutions. * - * @param emitContext The context for the emitter. + * @param hint The context for the emitter. * @param node The node to substitute. */ - function onSubstituteNode(emitContext: EmitContext, node: Node) { - node = previousOnSubstituteNode(emitContext, node); + function onSubstituteNode(hint: EmitHint, node: Node) { + node = previousOnSubstituteNode(hint, node); - if (emitContext === EmitContext.Expression) { + if (hint === EmitHint.Expression) { return substituteExpression(node); } @@ -3498,7 +3674,7 @@ namespace ts { if (enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings) { const original = getParseTreeNode(node, isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { - return getGeneratedNameForNode(original); + return setTextRange(getGeneratedNameForNode(original), node); } } @@ -3551,7 +3727,7 @@ namespace ts { if (enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings) { const declaration = resolver.getReferencedDeclarationWithCollidingName(node); if (declaration) { - return getGeneratedNameForNode(declaration.name); + return setTextRange(getGeneratedNameForNode(declaration.name), node); } } @@ -3566,7 +3742,7 @@ namespace ts { function substituteThisKeyword(node: PrimaryExpression): PrimaryExpression { if (enabledSubstitutions & ES2015SubstitutionFlags.CapturedThis && hierarchyFacts & HierarchyFacts.CapturesThis) { - return createIdentifier("_this", /*location*/ node); + return setTextRange(createIdentifier("_this"), node); } return node; } @@ -3627,10 +3803,15 @@ namespace ts { scoped: false, priority: 0, text: ` - 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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })();` }; } diff --git a/src/compiler/transformers/es2016.ts b/src/compiler/transformers/es2016.ts index 5959753fcef..1118e6ad9b6 100644 --- a/src/compiler/transformers/es2016.ts +++ b/src/compiler/transformers/es2016.ts @@ -48,29 +48,37 @@ namespace ts { // Transforms `a[x] **= b` into `(_a = a)[_x = x] = Math.pow(_a[_x], b)` const expressionTemp = createTempVariable(hoistVariableDeclaration); const argumentExpressionTemp = createTempVariable(hoistVariableDeclaration); - target = createElementAccess( - createAssignment(expressionTemp, left.expression, /*location*/ left.expression), - createAssignment(argumentExpressionTemp, left.argumentExpression, /*location*/ left.argumentExpression), - /*location*/ left + target = setTextRange( + createElementAccess( + setTextRange(createAssignment(expressionTemp, left.expression), left.expression), + setTextRange(createAssignment(argumentExpressionTemp, left.argumentExpression), left.argumentExpression) + ), + left ); - value = createElementAccess( - expressionTemp, - argumentExpressionTemp, - /*location*/ left + value = setTextRange( + createElementAccess( + expressionTemp, + argumentExpressionTemp + ), + left ); } else if (isPropertyAccessExpression(left)) { // Transforms `a.x **= b` into `(_a = a).x = Math.pow(_a.x, b)` const expressionTemp = createTempVariable(hoistVariableDeclaration); - target = createPropertyAccess( - createAssignment(expressionTemp, left.expression, /*location*/ left.expression), - left.name, - /*location*/ left + target = setTextRange( + createPropertyAccess( + setTextRange(createAssignment(expressionTemp, left.expression), left.expression), + left.name + ), + left ); - value = createPropertyAccess( - expressionTemp, - left.name, - /*location*/ left + value = setTextRange( + createPropertyAccess( + expressionTemp, + left.name + ), + left ); } else { @@ -78,7 +86,13 @@ namespace ts { target = left; value = left; } - return createAssignment(target, createMathPow(value, right, /*location*/ node), /*location*/ node); + return setTextRange( + createAssignment( + target, + createMathPow(value, right, /*location*/ node) + ), + node + ); } function visitExponentiationExpression(node: BinaryExpression) { diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index c87dbe32518..31aae5055a0 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -14,7 +14,7 @@ namespace ts { const { startLexicalEnvironment, resumeLexicalEnvironment, - endLexicalEnvironment, + endLexicalEnvironment } = context; const resolver = context.getEmitResolver(); @@ -34,7 +34,7 @@ namespace ts { * This keeps track of containers where `super` is valid, for use with * just-in-time substitution for `super` expressions inside of async methods. */ - let currentSuperContainer: SuperContainer; + let enclosingSuperContainerFlags: NodeCheckFlags = 0; // Save the previous transformation hooks. const previousOnEmitNode = context.onEmitNode; @@ -71,23 +71,18 @@ namespace ts { return undefined; case SyntaxKind.AwaitExpression: - // ES2017 'await' expressions must be transformed for targets < ES2017. return visitAwaitExpression(node); case SyntaxKind.MethodDeclaration: - // ES2017 method declarations may be 'async' return visitMethodDeclaration(node); case SyntaxKind.FunctionDeclaration: - // ES2017 function declarations may be 'async' return visitFunctionDeclaration(node); case SyntaxKind.FunctionExpression: - // ES2017 function expressions may be 'async' return visitFunctionExpression(node); case SyntaxKind.ArrowFunction: - // ES2017 arrow functions may be 'async' return visitArrowFunction(node); default: @@ -104,10 +99,12 @@ namespace ts { */ function visitAwaitExpression(node: AwaitExpression): Expression { return setOriginalNode( - createYield( - /*asteriskToken*/ undefined, - visitNode(node.expression, visitor, isExpression), - /*location*/ node + setTextRange( + createYield( + /*asteriskToken*/ undefined, + visitNode(node.expression, visitor, isExpression) + ), + node ), node ); @@ -126,11 +123,12 @@ namespace ts { node, /*decorators*/ undefined, visitNodes(node.modifiers, visitor, isModifier), + node.asteriskToken, node.name, /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, - isAsyncFunctionLike(node) + getFunctionFlags(node) & FunctionFlags.Async ? transformAsyncFunctionBody(node) : visitFunctionBody(node.body, visitor, context) ); @@ -149,11 +147,12 @@ namespace ts { node, /*decorators*/ undefined, visitNodes(node.modifiers, visitor, isModifier), + node.asteriskToken, node.name, /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, - isAsyncFunctionLike(node) + getFunctionFlags(node) & FunctionFlags.Async ? transformAsyncFunctionBody(node) : visitFunctionBody(node.body, visitor, context) ); @@ -168,17 +167,15 @@ namespace ts { * @param node The node to visit. */ function visitFunctionExpression(node: FunctionExpression): Expression { - if (nodeIsMissing(node.body)) { - return createOmittedExpression(); - } return updateFunctionExpression( node, - /*modifiers*/ undefined, + visitNodes(node.modifiers, visitor, isModifier), + node.asteriskToken, node.name, /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, - isAsyncFunctionLike(node) + getFunctionFlags(node) & FunctionFlags.Async ? transformAsyncFunctionBody(node) : visitFunctionBody(node.body, visitor, context) ); @@ -199,7 +196,7 @@ namespace ts { /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, - isAsyncFunctionLike(node) + getFunctionFlags(node) & FunctionFlags.Async ? transformAsyncFunctionBody(node) : visitFunctionBody(node.body, visitor, context) ); @@ -238,7 +235,8 @@ namespace ts { addRange(statements, endLexicalEnvironment()); - const block = createBlock(statements, /*location*/ node.body, /*multiLine*/ true); + const block = createBlock(statements, /*multiLine*/ true); + setTextRange(block, node.body); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. @@ -266,7 +264,7 @@ namespace ts { const declarations = endLexicalEnvironment(); if (some(declarations)) { const block = convertToFunctionBody(expression); - return updateBlock(block, createNodeArray(concatenate(block.statements, declarations), block.statements)); + return updateBlock(block, setTextRange(createNodeArray(concatenate(block.statements, declarations)), block.statements)); } return expression; @@ -281,7 +279,7 @@ namespace ts { startLexicalEnvironment(); const visited = convertToFunctionBody(visitNode(body, visitor, isConciseBody)); const declarations = endLexicalEnvironment(); - return updateBlock(visited, createNodeArray(concatenate(visited.statements, declarations), visited.statements)); + return updateBlock(visited, setTextRange(createNodeArray(concatenate(visited.statements, declarations)), visited.statements)); } } @@ -317,6 +315,44 @@ namespace ts { } } + /** + * Hook for node emit. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to emit. + * @param emit A callback used to emit the node in the printer. + */ + function onEmitNode(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void { + // If we need to support substitutions for `super` in an async method, + // we should track it here. + if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper && isSuperContainer(node)) { + const superContainerFlags = resolver.getNodeCheckFlags(node) & (NodeCheckFlags.AsyncMethodWithSuper | NodeCheckFlags.AsyncMethodWithSuperBinding); + if (superContainerFlags !== enclosingSuperContainerFlags) { + const savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; + enclosingSuperContainerFlags = superContainerFlags; + previousOnEmitNode(hint, node, emitCallback); + enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags; + return; + } + } + previousOnEmitNode(hint, node, emitCallback); + } + + /** + * Hooks node substitutions. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to substitute. + */ + function onSubstituteNode(hint: EmitHint, node: Node) { + node = previousOnSubstituteNode(hint, node); + if (hint === EmitHint.Expression && enclosingSuperContainerFlags) { + return substituteExpression(node); + } + + return node; + } + function substituteExpression(node: Expression) { switch (node.kind) { case SyntaxKind.PropertyAccessExpression: @@ -324,62 +360,45 @@ namespace ts { case SyntaxKind.ElementAccessExpression: return substituteElementAccessExpression(node); case SyntaxKind.CallExpression: - if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper) { - return substituteCallExpression(node); - } - break; + return substituteCallExpression(node); } - return node; } function substitutePropertyAccessExpression(node: PropertyAccessExpression) { - if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper && node.expression.kind === SyntaxKind.SuperKeyword) { - const flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod( - createLiteral(node.name.text), - flags, - node - ); - } + if (node.expression.kind === SyntaxKind.SuperKeyword) { + return createSuperAccessInAsyncMethod( + createLiteral(node.name.text), + node + ); } - return node; } function substituteElementAccessExpression(node: ElementAccessExpression) { - if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper && node.expression.kind === SyntaxKind.SuperKeyword) { - const flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod( - node.argumentExpression, - flags, - node - ); - } + if (node.expression.kind === SyntaxKind.SuperKeyword) { + return createSuperAccessInAsyncMethod( + node.argumentExpression, + node + ); } - return node; } function substituteCallExpression(node: CallExpression): Expression { const expression = node.expression; if (isSuperProperty(expression)) { - const flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - const argumentExpression = isPropertyAccessExpression(expression) - ? substitutePropertyAccessExpression(expression) - : substituteElementAccessExpression(expression); - return createCall( - createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, - [ - createThis(), - ...node.arguments - ] - ); - } + const argumentExpression = isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return createCall( + createPropertyAccess(argumentExpression, "call"), + /*typeArguments*/ undefined, + [ + createThis(), + ...node.arguments + ] + ); } return node; } @@ -393,72 +412,51 @@ namespace ts { || kind === SyntaxKind.SetAccessor; } - /** - * Hook for node emit. - * - * @param node The node to emit. - * @param emit A callback used to emit the node in the printer. - */ - function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void { - // If we need to support substitutions for `super` in an async method, - // we should track it here. - if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper && isSuperContainer(node)) { - const savedCurrentSuperContainer = currentSuperContainer; - currentSuperContainer = node; - previousOnEmitNode(emitContext, node, emitCallback); - currentSuperContainer = savedCurrentSuperContainer; + function createSuperAccessInAsyncMethod(argumentExpression: Expression, location: TextRange): LeftHandSideExpression { + if (enclosingSuperContainerFlags & NodeCheckFlags.AsyncMethodWithSuperBinding) { + return setTextRange( + createPropertyAccess( + createCall( + createIdentifier("_super"), + /*typeArguments*/ undefined, + [argumentExpression] + ), + "value" + ), + location + ); } else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - - /** - * Hooks node substitutions. - * - * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. - */ - function onSubstituteNode(emitContext: EmitContext, node: Node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === EmitContext.Expression) { - return substituteExpression(node); - } - - return node; - } - - function createSuperAccessInAsyncMethod(argumentExpression: Expression, flags: NodeCheckFlags, location: TextRange): LeftHandSideExpression { - if (flags & NodeCheckFlags.AsyncMethodWithSuperBinding) { - return createPropertyAccess( + return setTextRange( createCall( createIdentifier("_super"), /*typeArguments*/ undefined, [argumentExpression] ), - "value", location ); } - else { - return createCall( - createIdentifier("_super"), - /*typeArguments*/ undefined, - [argumentExpression], - location - ); - } - } - - function getSuperContainerAsyncMethodFlags() { - return currentSuperContainer !== undefined - && resolver.getNodeCheckFlags(currentSuperContainer) & (NodeCheckFlags.AsyncMethodWithSuper | NodeCheckFlags.AsyncMethodWithSuperBinding); } } + const awaiterHelper: EmitHelper = { + name: "typescript:awaiter", + scoped: false, + priority: 5, + text: ` + var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + };` + }; + function createAwaiterHelper(context: TransformationContext, hasLexicalArguments: boolean, promiseConstructor: EntityName | Expression, body: Block) { context.requestEmitHelper(awaiterHelper); + const generatorFunc = createFunctionExpression( /*modifiers*/ undefined, createToken(SyntaxKind.AsteriskToken), @@ -484,35 +482,22 @@ namespace ts { ); } - const awaiterHelper: EmitHelper = { - name: "typescript:awaiter", - scoped: false, - priority: 5, - text: ` - var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - };` - }; - - const asyncSuperHelper: EmitHelper = { + export const asyncSuperHelper: EmitHelper = { name: "typescript:async-super", scoped: true, text: ` - const _super = name => super[name];` + const _super = name => super[name]; + ` }; - const advancedAsyncSuperHelper: EmitHelper = { + export const advancedAsyncSuperHelper: EmitHelper = { name: "typescript:advanced-async-super", scoped: true, text: ` const _super = (function (geti, seti) { const cache = Object.create(null); return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } }); - })(name => super[name], (name, value) => super[name] = value);` + })(name => super[name], (name, value) => super[name] = value); + ` }; } diff --git a/src/compiler/transformers/es5.ts b/src/compiler/transformers/es5.ts index 6dd875965d9..bcecb86e75d 100644 --- a/src/compiler/transformers/es5.ts +++ b/src/compiler/transformers/es5.ts @@ -11,10 +11,10 @@ namespace ts { export function transformES5(context: TransformationContext) { const compilerOptions = context.getCompilerOptions(); - // enable emit notification only if using --jsx preserve - let previousOnEmitNode: (emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) => void; + // enable emit notification only if using --jsx preserve or react-native + let previousOnEmitNode: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void; let noSubstitution: boolean[]; - if (compilerOptions.jsx === JsxEmit.Preserve) { + if (compilerOptions.jsx === JsxEmit.Preserve || compilerOptions.jsx === JsxEmit.ReactNative) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; context.enableEmitNotification(SyntaxKind.JsxOpeningElement); @@ -41,9 +41,11 @@ namespace ts { /** * Called by the printer just before a node is printed. * - * @param node The node to be printed. + * @param hint A hint as to the intended usage of the node. + * @param node The node to emit. + * @param emitCallback A callback used to emit the node. */ - function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) { + function onEmitNode(hint: EmitHint, node: Node, emitCallback: (emitContext: EmitHint, node: Node) => void) { switch (node.kind) { case SyntaxKind.JsxOpeningElement: case SyntaxKind.JsxClosingElement: @@ -53,21 +55,21 @@ namespace ts { break; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } /** * Hooks node substitutions. * - * @param emitContext The context for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ - function onSubstituteNode(emitContext: EmitContext, node: Node) { + function onSubstituteNode(hint: EmitHint, node: Node) { if (node.id && noSubstitution && noSubstitution[node.id]) { - return previousOnSubstituteNode(emitContext, node); + return previousOnSubstituteNode(hint, node); } - node = previousOnSubstituteNode(emitContext, node); + node = previousOnSubstituteNode(hint, node); if (isPropertyAccessExpression(node)) { return substitutePropertyAccessExpression(node); } @@ -85,7 +87,7 @@ namespace ts { function substitutePropertyAccessExpression(node: PropertyAccessExpression): Expression { const literalName = trySubstituteReservedName(node.name); if (literalName) { - return createElementAccess(node.expression, literalName, /*location*/ node); + return setTextRange(createElementAccess(node.expression, literalName), node); } return node; } @@ -111,9 +113,9 @@ namespace ts { function trySubstituteReservedName(name: Identifier) { const token = name.originalKeywordKind || (nodeIsSynthesized(name) ? stringToToken(name.text) : undefined); if (token >= SyntaxKind.FirstReservedWord && token <= SyntaxKind.LastReservedWord) { - return createLiteral(name, /*location*/ name); + return setTextRange(createLiteral(name), name); } return undefined; } } -} \ No newline at end of file +} diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index 0a529a8e871..971dddd20ea 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -1,13 +1,35 @@ /// /// +/// /*@internal*/ namespace ts { + const enum ESNextSubstitutionFlags { + /** Enables substitutions for async methods with `super` calls. */ + AsyncMethodsWithSuper = 1 << 0 + } + export function transformESNext(context: TransformationContext) { const { resumeLexicalEnvironment, - endLexicalEnvironment + endLexicalEnvironment, + hoistVariableDeclaration } = context; + + const resolver = context.getEmitResolver(); + const compilerOptions = context.getCompilerOptions(); + const languageVersion = getEmitScriptTarget(compilerOptions); + + const previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + + const previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + + let enabledSubstitutions: ESNextSubstitutionFlags; + let enclosingFunctionFlags: FunctionFlags; + let enclosingSuperContainerFlags: NodeCheckFlags = 0; + return transformSourceFile; function transformSourceFile(node: SourceFile) { @@ -28,12 +50,25 @@ namespace ts { return visitorWorker(node, /*noDestructuringValue*/ true); } + function visitorNoAsyncModifier(node: Node): VisitResult { + if (node.kind === SyntaxKind.AsyncKeyword) { + return undefined; + } + return node; + } + function visitorWorker(node: Node, noDestructuringValue: boolean): VisitResult { if ((node.transformFlags & TransformFlags.ContainsESNext) === 0) { return node; } switch (node.kind) { + case SyntaxKind.AwaitExpression: + return visitAwaitExpression(node as AwaitExpression); + case SyntaxKind.YieldExpression: + return visitYieldExpression(node as YieldExpression); + case SyntaxKind.LabeledStatement: + return visitLabeledStatement(node as LabeledStatement); case SyntaxKind.ObjectLiteralExpression: return visitObjectLiteralExpression(node as ObjectLiteralExpression); case SyntaxKind.BinaryExpression: @@ -41,7 +76,7 @@ namespace ts { case SyntaxKind.VariableDeclaration: return visitVariableDeclaration(node as VariableDeclaration); case SyntaxKind.ForOfStatement: - return visitForOfStatement(node as ForOfStatement); + return visitForOfStatement(node as ForOfStatement, /*outermostLabeledStatement*/ undefined); case SyntaxKind.ForStatement: return visitForStatement(node as ForStatement); case SyntaxKind.VoidExpression: @@ -71,6 +106,52 @@ namespace ts { } } + function visitAwaitExpression(node: AwaitExpression) { + if (enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator) { + const expression = visitNode(node.expression, visitor, isExpression); + return setOriginalNode( + setTextRange( + createYield( + /*asteriskToken*/ undefined, + createArrayLiteral([createLiteral("await"), expression]) + ), + /*location*/ node + ), + node + ); + } + return visitEachChild(node, visitor, context); + } + + function visitYieldExpression(node: YieldExpression) { + if (enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator) { + const expression = visitNode(node.expression, visitor, isExpression); + return updateYield( + node, + node.asteriskToken, + node.asteriskToken + ? createAsyncDelegatorHelper(context, expression, expression) + : createArrayLiteral( + expression + ? [createLiteral("yield"), expression] + : [createLiteral("yield")] + ) + ); + } + return visitEachChild(node, visitor, context); + } + + function visitLabeledStatement(node: LabeledStatement) { + if (enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator) { + const statement = unwrapInnermostStatementOfLabel(node); + if (statement.kind === SyntaxKind.ForOfStatement && (statement).awaitModifier) { + return visitForOfStatement(statement, node); + } + return restoreEnclosingLabel(visitEachChild(node, visitor, context), node); + } + return visitEachChild(node, visitor, context); + } + function chunkObjectLiteralElements(elements: ObjectLiteralElement[]): Expression[] { let chunkObject: (ShorthandPropertyAssignment | PropertyAssignment)[]; const objects: Expression[] = []; @@ -189,63 +270,199 @@ namespace ts { * * @param node A ForOfStatement. */ - function visitForOfStatement(node: ForOfStatement): VisitResult { - let leadingStatements: Statement[]; - let temp: Identifier; - const initializer = skipParentheses(node.initializer); - if (initializer.transformFlags & TransformFlags.ContainsObjectRest) { - if (isVariableDeclarationList(initializer)) { - temp = createTempVariable(/*recordTempVariable*/ undefined); - const firstDeclaration = firstOrUndefined(initializer.declarations); - const declarations = flattenDestructuringBinding( - firstDeclaration, - visitor, - context, - FlattenLevel.ObjectRest, - temp, - /*doNotRecordTempVariablesInLine*/ false, - /*skipInitializer*/ true, - ); - if (some(declarations)) { - const statement = createVariableStatement( - /*modifiers*/ undefined, - updateVariableDeclarationList(initializer, declarations), - /*location*/ initializer - ); - leadingStatements = append(leadingStatements, statement); - } - } - else if (isAssignmentPattern(initializer)) { - temp = createTempVariable(/*recordTempVariable*/ undefined); - const expression = flattenDestructuringAssignment( - aggregateTransformFlags(createAssignment(initializer, temp, /*location*/ node.initializer)), - visitor, - context, - FlattenLevel.ObjectRest - ); - leadingStatements = append(leadingStatements, createStatement(expression, /*location*/ node.initializer)); - } + function visitForOfStatement(node: ForOfStatement, outermostLabeledStatement: LabeledStatement): VisitResult { + if (node.initializer.transformFlags & TransformFlags.ContainsObjectRest) { + node = transformForOfStatementWithObjectRest(node); } - if (temp) { - const expression = visitNode(node.expression, visitor, isExpression); - const statement = visitNode(node.statement, visitor, isStatement); - const block = isBlock(statement) - ? updateBlock(statement, createNodeArray(concatenate(leadingStatements, statement.statements), statement.statements)) - : createBlock(append(leadingStatements, statement), statement, /*multiLine*/ true); + if (node.awaitModifier) { + return transformForAwaitOfStatement(node, outermostLabeledStatement); + } + else { + return restoreEnclosingLabel(visitEachChild(node, visitor, context), outermostLabeledStatement); + } + } + + function transformForOfStatementWithObjectRest(node: ForOfStatement) { + const initializerWithoutParens = skipParentheses(node.initializer) as ForInitializer; + if (isVariableDeclarationList(initializerWithoutParens) || isAssignmentPattern(initializerWithoutParens)) { + let bodyLocation: TextRange; + let statementsLocation: TextRange; + const temp = createTempVariable(/*recordTempVariable*/ undefined); + const statements: Statement[] = [createForOfBindingStatement(initializerWithoutParens, temp)]; + if (isBlock(node.statement)) { + addRange(statements, node.statement.statements); + bodyLocation = node.statement; + statementsLocation = node.statement.statements; + } return updateForOf( node, - createVariableDeclarationList( - [ - createVariableDeclaration(temp, /*type*/ undefined, /*initializer*/ undefined, node.initializer) - ], - node.initializer, - NodeFlags.Let + node.awaitModifier, + setTextRange( + createVariableDeclarationList( + [ + setTextRange(createVariableDeclaration(temp), node.initializer) + ], + NodeFlags.Let + ), + node.initializer ), - expression, - block + node.expression, + setTextRange( + createBlock( + setTextRange(createNodeArray(statements), statementsLocation), + /*multiLine*/ true + ), + bodyLocation + ) ); } - return visitEachChild(node, visitor, context); + return node; + } + + function convertForOfStatementHead(node: ForOfStatement, boundValue: Expression) { + const binding = createForOfBindingStatement(node.initializer, boundValue); + + let bodyLocation: TextRange; + let statementsLocation: TextRange; + const statements: Statement[] = [visitNode(binding, visitor, isStatement)]; + const statement = visitNode(node.statement, visitor, isStatement); + if (isBlock(statement)) { + addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); + } + + return setEmitFlags( + setTextRange( + createBlock( + setTextRange(createNodeArray(statements), statementsLocation), + /*multiLine*/ true + ), + bodyLocation + ), + EmitFlags.NoSourceMap | EmitFlags.NoTokenSourceMaps + ); + } + + function transformForAwaitOfStatement(node: ForOfStatement, outermostLabeledStatement: LabeledStatement) { + const expression = visitNode(node.expression, visitor, isExpression); + const iterator = isIdentifier(expression) ? getGeneratedNameForNode(expression) : createTempVariable(/*recordTempVariable*/ undefined); + const result = isIdentifier(expression) ? getGeneratedNameForNode(iterator) : createTempVariable(/*recordTempVariable*/ undefined); + const errorRecord = createUniqueName("e"); + const catchVariable = getGeneratedNameForNode(errorRecord); + const returnMethod = createTempVariable(/*recordTempVariable*/ undefined); + const values = createAsyncValuesHelper(context, expression, /*location*/ node.expression); + const next = createYield( + /*asteriskToken*/ undefined, + enclosingFunctionFlags & FunctionFlags.Generator + ? createArrayLiteral([ + createLiteral("await"), + createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, []) + ]) + : createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, []) + ); + + hoistVariableDeclaration(errorRecord); + hoistVariableDeclaration(returnMethod); + + const forStatement = setEmitFlags( + setTextRange( + createFor( + /*initializer*/ setEmitFlags( + setTextRange( + createVariableDeclarationList([ + setTextRange(createVariableDeclaration(iterator, /*type*/ undefined, values), node.expression), + createVariableDeclaration(result, /*type*/ undefined, next) + ]), + node.expression + ), + EmitFlags.NoHoisting + ), + /*condition*/ createLogicalNot(createPropertyAccess(result, "done")), + /*incrementor*/ createAssignment(result, next), + /*statement*/ convertForOfStatementHead(node, createPropertyAccess(result, "value")) + ), + /*location*/ node + ), + EmitFlags.NoTokenTrailingSourceMaps + ); + + return createTry( + createBlock([ + restoreEnclosingLabel( + forStatement, + outermostLabeledStatement + ) + ]), + createCatchClause( + createVariableDeclaration(catchVariable), + setEmitFlags( + createBlock([ + createStatement( + createAssignment( + errorRecord, + createObjectLiteral([ + createPropertyAssignment("error", catchVariable) + ]) + ) + ) + ]), + EmitFlags.SingleLine + ) + ), + createBlock([ + createTry( + /*tryBlock*/ createBlock([ + setEmitFlags( + createIf( + createLogicalAnd( + createLogicalAnd( + result, + createLogicalNot( + createPropertyAccess(result, "done") + ) + ), + createAssignment( + returnMethod, + createPropertyAccess(iterator, "return") + ) + ), + createStatement( + createYield( + /*asteriskToken*/ undefined, + enclosingFunctionFlags & FunctionFlags.Generator + ? createArrayLiteral([ + createLiteral("await"), + createFunctionCall(returnMethod, iterator, []) + ]) + : createFunctionCall(returnMethod, iterator, []) + ) + ) + ), + EmitFlags.SingleLine + ) + ]), + /*catchClause*/ undefined, + /*finallyBlock*/ setEmitFlags( + createBlock([ + setEmitFlags( + createIf( + errorRecord, + createThrow( + createPropertyAccess(errorRecord, "error") + ) + ), + EmitFlags.SingleLine + ) + ]), + EmitFlags.SingleLine + ) + ) + ]) + ); } function visitParameter(node: ParameterDeclaration): ParameterDeclaration { @@ -266,17 +483,23 @@ namespace ts { } function visitConstructorDeclaration(node: ConstructorDeclaration) { - return updateConstructor( + const savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = FunctionFlags.Normal; + const updated = updateConstructor( node, /*decorators*/ undefined, node.modifiers, visitParameterList(node.parameters, visitor, context), transformFunctionBody(node) ); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitGetAccessorDeclaration(node: GetAccessorDeclaration) { - return updateGetAccessor( + const savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = FunctionFlags.Normal; + const updated = updateGetAccessor( node, /*decorators*/ undefined, node.modifiers, @@ -285,10 +508,14 @@ namespace ts { /*type*/ undefined, transformFunctionBody(node) ); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitSetAccessorDeclaration(node: SetAccessorDeclaration) { - return updateSetAccessor( + const savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = FunctionFlags.Normal; + const updated = updateSetAccessor( node, /*decorators*/ undefined, node.modifiers, @@ -296,36 +523,62 @@ namespace ts { visitParameterList(node.parameters, visitor, context), transformFunctionBody(node) ); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitMethodDeclaration(node: MethodDeclaration) { - return updateMethod( + const savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = getFunctionFlags(node); + const updated = updateMethod( node, /*decorators*/ undefined, - node.modifiers, + enclosingFunctionFlags & FunctionFlags.Generator + ? visitNodes(node.modifiers, visitorNoAsyncModifier, isModifier) + : node.modifiers, + enclosingFunctionFlags & FunctionFlags.Async + ? undefined + : node.asteriskToken, visitNode(node.name, visitor, isPropertyName), /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, - transformFunctionBody(node) + enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator + ? transformAsyncGeneratorFunctionBody(node) + : transformFunctionBody(node) ); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitFunctionDeclaration(node: FunctionDeclaration) { - return updateFunctionDeclaration( + const savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = getFunctionFlags(node); + const updated = updateFunctionDeclaration( node, /*decorators*/ undefined, - node.modifiers, + enclosingFunctionFlags & FunctionFlags.Generator + ? visitNodes(node.modifiers, visitorNoAsyncModifier, isModifier) + : node.modifiers, + enclosingFunctionFlags & FunctionFlags.Async + ? undefined + : node.asteriskToken, node.name, /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, - transformFunctionBody(node) + enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator + ? transformAsyncGeneratorFunctionBody(node) + : transformFunctionBody(node) ); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitArrowFunction(node: ArrowFunction) { - return updateArrowFunction( + const savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = getFunctionFlags(node); + const updated = updateArrowFunction( node, node.modifiers, /*typeParameters*/ undefined, @@ -333,25 +586,92 @@ namespace ts { /*type*/ undefined, transformFunctionBody(node) ); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitFunctionExpression(node: FunctionExpression) { - return updateFunctionExpression( + const savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = getFunctionFlags(node); + const updated = updateFunctionExpression( node, - node.modifiers, + enclosingFunctionFlags & FunctionFlags.Generator + ? visitNodes(node.modifiers, visitorNoAsyncModifier, isModifier) + : node.modifiers, + enclosingFunctionFlags & FunctionFlags.Async + ? undefined + : node.asteriskToken, node.name, /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, - transformFunctionBody(node) + enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator + ? transformAsyncGeneratorFunctionBody(node) + : transformFunctionBody(node) ); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; + } + + function transformAsyncGeneratorFunctionBody(node: MethodDeclaration | AccessorDeclaration | FunctionDeclaration | FunctionExpression): FunctionBody { + resumeLexicalEnvironment(); + const statements: Statement[] = []; + const statementOffset = addPrologueDirectives(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); + appendObjectRestAssignmentsIfNeeded(statements, node); + + statements.push( + createReturn( + createAsyncGeneratorHelper( + context, + createFunctionExpression( + /*modifiers*/ undefined, + createToken(SyntaxKind.AsteriskToken), + node.name && getGeneratedNameForNode(node.name), + /*typeParameters*/ undefined, + /*parameters*/ [], + /*type*/ undefined, + updateBlock( + node.body, + visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset) + ) + ) + ) + ) + ); + + addRange(statements, endLexicalEnvironment()); + const block = updateBlock(node.body, statements); + + // Minor optimization, emit `_super` helper to capture `super` access in an arrow. + // This step isn't needed if we eventually transform this to ES5. + if (languageVersion >= ScriptTarget.ES2015) { + if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuperBinding) { + enableSubstitutionForAsyncMethodsWithSuper(); + addEmitHelper(block, advancedAsyncSuperHelper); + } + else if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuper) { + enableSubstitutionForAsyncMethodsWithSuper(); + addEmitHelper(block, asyncSuperHelper); + } + } + return block; } function transformFunctionBody(node: FunctionDeclaration | FunctionExpression | ConstructorDeclaration | MethodDeclaration | AccessorDeclaration): FunctionBody; function transformFunctionBody(node: ArrowFunction): ConciseBody; function transformFunctionBody(node: FunctionLikeDeclaration): ConciseBody { resumeLexicalEnvironment(); - let leadingStatements: Statement[]; + const leadingStatements = appendObjectRestAssignmentsIfNeeded(/*statements*/ undefined, node); + const body = visitNode(node.body, visitor, isConciseBody); + const trailingStatements = endLexicalEnvironment(); + if (some(leadingStatements) || some(trailingStatements)) { + const block = convertToFunctionBody(body, /*multiLine*/ true); + return updateBlock(block, setTextRange(createNodeArray(concatenate(concatenate(leadingStatements, block.statements), trailingStatements)), block.statements)); + } + return body; + } + + function appendObjectRestAssignmentsIfNeeded(statements: Statement[], node: FunctionLikeDeclaration): Statement[] { for (const parameter of node.parameters) { if (parameter.transformFlags & TransformFlags.ContainsObjectRest) { const temp = getGeneratedNameForNode(parameter); @@ -372,17 +692,153 @@ namespace ts { ) ); setEmitFlags(statement, EmitFlags.CustomPrologue); - leadingStatements = append(leadingStatements, statement); + statements = append(statements, statement); } } } - const body = visitNode(node.body, visitor, isConciseBody); - const trailingStatements = endLexicalEnvironment(); - if (some(leadingStatements) || some(trailingStatements)) { - const block = convertToFunctionBody(body, /*multiLine*/ true); - return updateBlock(block, createNodeArray(concatenate(concatenate(leadingStatements, block.statements), trailingStatements), block.statements)); + return statements; + } + + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & ESNextSubstitutionFlags.AsyncMethodsWithSuper) === 0) { + enabledSubstitutions |= ESNextSubstitutionFlags.AsyncMethodsWithSuper; + + // We need to enable substitutions for call, property access, and element access + // if we need to rewrite super calls. + context.enableSubstitution(SyntaxKind.CallExpression); + context.enableSubstitution(SyntaxKind.PropertyAccessExpression); + context.enableSubstitution(SyntaxKind.ElementAccessExpression); + + // We need to be notified when entering and exiting declarations that bind super. + context.enableEmitNotification(SyntaxKind.ClassDeclaration); + context.enableEmitNotification(SyntaxKind.MethodDeclaration); + context.enableEmitNotification(SyntaxKind.GetAccessor); + context.enableEmitNotification(SyntaxKind.SetAccessor); + context.enableEmitNotification(SyntaxKind.Constructor); + } + } + + /** + * Called by the printer just before a node is printed. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to be printed. + * @param emitCallback The callback used to emit the node. + */ + function onEmitNode(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) { + // If we need to support substitutions for `super` in an async method, + // we should track it here. + if (enabledSubstitutions & ESNextSubstitutionFlags.AsyncMethodsWithSuper && isSuperContainer(node)) { + const superContainerFlags = resolver.getNodeCheckFlags(node) & (NodeCheckFlags.AsyncMethodWithSuper | NodeCheckFlags.AsyncMethodWithSuperBinding); + if (superContainerFlags !== enclosingSuperContainerFlags) { + const savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; + enclosingSuperContainerFlags = superContainerFlags; + previousOnEmitNode(hint, node, emitCallback); + enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags; + return; + } + } + + previousOnEmitNode(hint, node, emitCallback); + } + + /** + * Hooks node substitutions. + * + * @param hint The context for the emitter. + * @param node The node to substitute. + */ + function onSubstituteNode(hint: EmitHint, node: Node) { + node = previousOnSubstituteNode(hint, node); + if (hint === EmitHint.Expression && enclosingSuperContainerFlags) { + return substituteExpression(node); + } + return node; + } + + function substituteExpression(node: Expression) { + switch (node.kind) { + case SyntaxKind.PropertyAccessExpression: + return substitutePropertyAccessExpression(node); + case SyntaxKind.ElementAccessExpression: + return substituteElementAccessExpression(node); + case SyntaxKind.CallExpression: + return substituteCallExpression(node); + } + return node; + } + + function substitutePropertyAccessExpression(node: PropertyAccessExpression) { + if (node.expression.kind === SyntaxKind.SuperKeyword) { + return createSuperAccessInAsyncMethod( + createLiteral(node.name.text), + node + ); + } + return node; + } + + function substituteElementAccessExpression(node: ElementAccessExpression) { + if (node.expression.kind === SyntaxKind.SuperKeyword) { + return createSuperAccessInAsyncMethod( + node.argumentExpression, + node + ); + } + return node; + } + + function substituteCallExpression(node: CallExpression): Expression { + const expression = node.expression; + if (isSuperProperty(expression)) { + const argumentExpression = isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return createCall( + createPropertyAccess(argumentExpression, "call"), + /*typeArguments*/ undefined, + [ + createThis(), + ...node.arguments + ] + ); + } + return node; + } + + function isSuperContainer(node: Node) { + const kind = node.kind; + return kind === SyntaxKind.ClassDeclaration + || kind === SyntaxKind.Constructor + || kind === SyntaxKind.MethodDeclaration + || kind === SyntaxKind.GetAccessor + || kind === SyntaxKind.SetAccessor; + } + + function createSuperAccessInAsyncMethod(argumentExpression: Expression, location: TextRange): LeftHandSideExpression { + if (enclosingSuperContainerFlags & NodeCheckFlags.AsyncMethodWithSuperBinding) { + return setTextRange( + createPropertyAccess( + createCall( + createIdentifier("_super"), + /*typeArguments*/ undefined, + [argumentExpression] + ), + "value" + ), + location + ); + } + else { + return setTextRange( + createCall( + createIdentifier("_super"), + /*typeArguments*/ undefined, + [argumentExpression] + ), + location + ); } - return body; } } @@ -402,6 +858,11 @@ namespace ts { }; export function createAssignHelper(context: TransformationContext, attributesSegments: Expression[]) { + if (context.getCompilerOptions().target >= ScriptTarget.ES2015) { + return createCall(createPropertyAccess(createIdentifier("Object"), "assign"), + /*typeArguments*/ undefined, + attributesSegments); + } context.requestEmitHelper(assignHelper); return createCall( getHelperName("__assign"), @@ -409,4 +870,89 @@ namespace ts { attributesSegments ); } + + const asyncGeneratorHelper: EmitHelper = { + name: "typescript:asyncGenerator", + scoped: false, + text: ` + var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } + }; + ` + }; + + function createAsyncGeneratorHelper(context: TransformationContext, generatorFunc: FunctionExpression) { + context.requestEmitHelper(asyncGeneratorHelper); + + // Mark this node as originally an async function + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= EmitFlags.AsyncFunctionBody; + + return createCall( + getHelperName("__asyncGenerator"), + /*typeArguments*/ undefined, + [ + createThis(), + createIdentifier("arguments"), + generatorFunc + ] + ); + } + + const asyncDelegator: EmitHelper = { + name: "typescript:asyncDelegator", + scoped: false, + text: ` + var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } + }; + ` + }; + + function createAsyncDelegatorHelper(context: TransformationContext, expression: Expression, location?: TextRange) { + context.requestEmitHelper(asyncDelegator); + return setTextRange( + createCall( + getHelperName("__asyncDelegator"), + /*typeArguments*/ undefined, + [expression] + ), + location + ); + } + + const asyncValues: EmitHelper = { + name: "typescript:asyncValues", + scoped: false, + text: ` + var __asyncValues = (this && this.__asyncIterator) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator]; + return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + }; + ` + }; + + function createAsyncValuesHelper(context: TransformationContext, expression: Expression, location?: TextRange) { + context.requestEmitHelper(asyncValues); + return setTextRange( + createCall( + getHelperName("__asyncValues"), + /*typeArguments*/ undefined, + [expression] + ), + location + ); + } } diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index 1b909da4f6a..ff832188b5b 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -1,4 +1,4 @@ -/// +/// /// // Transforms generator functions into a compatible ES5 representation with similar runtime @@ -217,20 +217,22 @@ namespace ts { Endfinally = 7, } - const instructionNames = createMap({ - [Instruction.Return]: "return", - [Instruction.Break]: "break", - [Instruction.Yield]: "yield", - [Instruction.YieldStar]: "yield*", - [Instruction.Endfinally]: "endfinally", - }); + function getInstructionName(instruction: Instruction): string { + switch (instruction) { + case Instruction.Return: return "return"; + case Instruction.Break: return "break"; + case Instruction.Yield: return "yield"; + case Instruction.YieldStar: return "yield*"; + case Instruction.Endfinally: return "endfinally"; + } + } export function transformGenerators(context: TransformationContext) { const { resumeLexicalEnvironment, endLexicalEnvironment, hoistFunctionDeclaration, - hoistVariableDeclaration, + hoistVariableDeclaration } = context; const compilerOptions = context.getCompilerOptions(); @@ -241,7 +243,7 @@ namespace ts { let currentSourceFile: SourceFile; let renamedCatchVariables: Map; - let renamedCatchVariableDeclarations: Map; + let renamedCatchVariableDeclarations: Identifier[]; let inGeneratorFunctionBody: boolean; let inStatementContainingYield: boolean; @@ -446,17 +448,19 @@ namespace ts { */ function visitFunctionDeclaration(node: FunctionDeclaration): Statement { // Currently, we only support generators that were originally async functions. - if (node.asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { + if (node.asteriskToken) { node = setOriginalNode( - createFunctionDeclaration( - /*decorators*/ undefined, - node.modifiers, - /*asteriskToken*/ undefined, - node.name, - /*typeParameters*/ undefined, - visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, - transformGeneratorFunctionBody(node.body), + setTextRange( + createFunctionDeclaration( + /*decorators*/ undefined, + node.modifiers, + /*asteriskToken*/ undefined, + node.name, + /*typeParameters*/ undefined, + visitParameterList(node.parameters, visitor, context), + /*type*/ undefined, + transformGeneratorFunctionBody(node.body) + ), /*location*/ node ), node @@ -494,16 +498,18 @@ namespace ts { */ function visitFunctionExpression(node: FunctionExpression): Expression { // Currently, we only support generators that were originally async functions. - if (node.asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { + if (node.asteriskToken) { node = setOriginalNode( - createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - node.name, - /*typeParameters*/ undefined, - visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, - transformGeneratorFunctionBody(node.body), + setTextRange( + createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + node.name, + /*typeParameters*/ undefined, + visitParameterList(node.parameters, visitor, context), + /*type*/ undefined, + transformGeneratorFunctionBody(node.body) + ), /*location*/ node ), node @@ -604,7 +610,7 @@ namespace ts { operationLocations = savedOperationLocations; state = savedState; - return createBlock(statements, /*location*/ body, body.multiLine); + return setTextRange(createBlock(statements, body.multiLine), body); } /** @@ -737,14 +743,17 @@ namespace ts { const operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return createBinary( - target, - SyntaxKind.EqualsToken, - createBinary( - cacheExpression(target), - getOperatorForCompoundAssignment(operator), - visitNode(right, visitor, isExpression), - node + return setTextRange( + createAssignment( + target, + setTextRange( + createBinary( + cacheExpression(target), + getOperatorForCompoundAssignment(operator), + visitNode(right, visitor, isExpression) + ), + node + ) ), node ); @@ -927,11 +936,10 @@ namespace ts { // .mark resumeLabel // x = %sent%; - // NOTE: we are explicitly not handling YieldStar at this time. const resumeLabel = defineLabel(); const expression = visitNode(node.expression, visitor, isExpression); if (node.asteriskToken) { - emitYieldStar(expression, /*location*/ node); + emitYieldStar(createValuesHelper(context, expression, /*location*/ node), /*location*/ node); } else { emitYield(expression, /*location*/ node); @@ -969,9 +977,10 @@ namespace ts { // ar = _a.concat([%sent%, 2]); const numInitialElements = countInitialNodesWithoutYield(elements); - const temp = declareLocal(); - let hasAssignedTemp = false; + + let temp: Identifier; if (numInitialElements > 0) { + temp = declareLocal(); const initialElements = visitNodes(elements, visitor, isExpression, 0, numInitialElements); emitAssignment(temp, createArrayLiteral( @@ -981,30 +990,35 @@ namespace ts { ) ); leadingElement = undefined; - hasAssignedTemp = true; } const expressions = reduceLeft(elements, reduceElement, [], numInitialElements); - return hasAssignedTemp - ? createArrayConcat(temp, [createArrayLiteral(expressions, /*location*/ undefined, multiLine)]) - : createArrayLiteral(leadingElement ? [leadingElement, ...expressions] : expressions, location, multiLine); + return temp + ? createArrayConcat(temp, [createArrayLiteral(expressions, multiLine)]) + : setTextRange( + createArrayLiteral(leadingElement ? [leadingElement, ...expressions] : expressions, multiLine), + location + ); function reduceElement(expressions: Expression[], element: Expression) { if (containsYield(element) && expressions.length > 0) { + const hasAssignedTemp = temp !== undefined; + if (!temp) { + temp = declareLocal(); + } + emitAssignment( temp, hasAssignedTemp ? createArrayConcat( temp, - [createArrayLiteral(expressions, /*location*/ undefined, multiLine)] + [createArrayLiteral(expressions, multiLine)] ) : createArrayLiteral( leadingElement ? [leadingElement, ...expressions] : expressions, - /*location*/ undefined, multiLine ) ); - hasAssignedTemp = true; leadingElement = undefined; expressions = []; } @@ -1041,7 +1055,6 @@ namespace ts { emitAssignment(temp, createObjectLiteral( visitNodes(properties, visitor, isObjectLiteralElementLike, 0, numInitialProperties), - /*location*/ undefined, multiLine ) ); @@ -1137,18 +1150,20 @@ namespace ts { const { target, thisArg } = createCallBinding(createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration); return setOriginalNode( - createNew( - createFunctionApply( - cacheExpression(visitNode(target, visitor, isExpression)), - thisArg, - visitElements( - node.arguments, - /*leadingElement*/ createVoidZero() - ) + setTextRange( + createNew( + createFunctionApply( + cacheExpression(visitNode(target, visitor, isExpression)), + thisArg, + visitElements( + node.arguments, + /*leadingElement*/ createVoidZero() + ) + ), + /*typeArguments*/ undefined, + [] ), - /*typeArguments*/ undefined, - [], - /*location*/ node + node ), node ); @@ -1215,7 +1230,7 @@ namespace ts { case SyntaxKind.TryStatement: return transformAndEmitTryStatement(node); default: - return emitStatement(visitNode(node, visitor, isStatement, /*optional*/ true)); + return emitStatement(visitNode(node, visitor, isStatement)); } } @@ -1421,9 +1436,11 @@ namespace ts { } else { emitStatement( - createStatement( - visitNode(initializer, visitor, isExpression), - /*location*/ initializer + setTextRange( + createStatement( + visitNode(initializer, visitor, isExpression) + ), + initializer ) ); } @@ -1439,9 +1456,11 @@ namespace ts { markLabel(incrementLabel); if (node.incrementor) { emitStatement( - createStatement( - visitNode(node.incrementor, visitor, isExpression), - /*location*/ node.incrementor + setTextRange( + createStatement( + visitNode(node.incrementor, visitor, isExpression) + ), + node.incrementor ) ); } @@ -1469,9 +1488,9 @@ namespace ts { variables.length > 0 ? inlineExpressions(map(variables, transformInitializedVariable)) : undefined, - visitNode(node.condition, visitor, isExpression, /*optional*/ true), - visitNode(node.incrementor, visitor, isExpression, /*optional*/ true), - visitNode(node.statement, visitor, isStatement, /*optional*/ false, liftToBlock) + visitNode(node.condition, visitor, isExpression), + visitNode(node.incrementor, visitor, isExpression), + visitNode(node.statement, visitor, isStatement, liftToBlock) ); } else { @@ -1593,7 +1612,7 @@ namespace ts { node = updateForIn(node, initializer.declarations[0].name, visitNode(node.expression, visitor, isExpression), - visitNode(node.statement, visitor, isStatement, /*optional*/ false, liftToBlock) + visitNode(node.statement, visitor, isStatement, liftToBlock) ); } else { @@ -1643,14 +1662,14 @@ namespace ts { function transformAndEmitReturnStatement(node: ReturnStatement): void { emitReturn( - visitNode(node.expression, visitor, isExpression, /*optional*/ true), + visitNode(node.expression, visitor, isExpression), /*location*/ node ); } function visitReturnStatement(node: ReturnStatement) { return createInlineReturn( - visitNode(node.expression, visitor, isExpression, /*optional*/ true), + visitNode(node.expression, visitor, isExpression), /*location*/ node ); } @@ -1907,9 +1926,9 @@ namespace ts { return -1; } - function onSubstituteNode(emitContext: EmitContext, node: Node): Node { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === EmitContext.Expression) { + function onSubstituteNode(hint: EmitHint, node: Node): Node { + node = previousOnSubstituteNode(hint, node); + if (hint === EmitHint.Expression) { return substituteExpression(node); } return node; @@ -1923,12 +1942,12 @@ namespace ts { } function substituteExpressionIdentifier(node: Identifier) { - if (renamedCatchVariables && hasProperty(renamedCatchVariables, node.text)) { + if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { const original = getOriginalNode(node); if (isIdentifier(original) && original.parent) { const declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - const name = getProperty(renamedCatchVariableDeclarations, String(getOriginalNodeId(declaration))); + const name = renamedCatchVariableDeclarations[getOriginalNodeId(declaration)]; if (name) { const clone = getMutableClone(name); setSourceMapRange(clone, node); @@ -1944,7 +1963,7 @@ namespace ts { function cacheExpression(node: Expression): Identifier { let temp: Identifier; - if (isGeneratedIdentifier(node)) { + if (isGeneratedIdentifier(node) || getEmitFlags(node) & EmitFlags.HelperName) { return node; } @@ -2094,11 +2113,11 @@ namespace ts { if (!renamedCatchVariables) { renamedCatchVariables = createMap(); - renamedCatchVariableDeclarations = createMap(); + renamedCatchVariableDeclarations = []; context.enableSubstitution(SyntaxKind.Identifier); } - renamedCatchVariables[text] = true; + renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[getOriginalNodeId(variable)] = name; const exception = peekBlock(); @@ -2403,7 +2422,7 @@ namespace ts { */ function createInstruction(instruction: Instruction): NumericLiteral { const literal = createLiteral(instruction); - literal.trailingComment = instructionNames[instruction]; + addSyntheticTrailingComment(literal, SyntaxKind.MultiLineCommentTrivia, getInstructionName(instruction)); return literal; } @@ -2415,11 +2434,13 @@ namespace ts { */ function createInlineBreak(label: Label, location?: TextRange): ReturnStatement { Debug.assert(label > 0, `Invalid label: ${label}`); - return createReturn( - createArrayLiteral([ - createInstruction(Instruction.Break), - createLabel(label) - ]), + return setTextRange( + createReturn( + createArrayLiteral([ + createInstruction(Instruction.Break), + createLabel(label) + ]) + ), location ); } @@ -2431,10 +2452,12 @@ namespace ts { * @param location An optional source map location for the statement. */ function createInlineReturn(expression?: Expression, location?: TextRange): ReturnStatement { - return createReturn( - createArrayLiteral(expression - ? [createInstruction(Instruction.Return), expression] - : [createInstruction(Instruction.Return)] + return setTextRange( + createReturn( + createArrayLiteral(expression + ? [createInstruction(Instruction.Return), expression] + : [createInstruction(Instruction.Return)] + ) ), location ); @@ -2444,7 +2467,14 @@ namespace ts { * Creates an expression that can be used to resume from a Yield operation. */ function createGeneratorResume(location?: TextRange): LeftHandSideExpression { - return createCall(createPropertyAccess(state, "sent"), /*typeArguments*/ undefined, [], location); + return setTextRange( + createCall( + createPropertyAccess(state, "sent"), + /*typeArguments*/ undefined, + [] + ), + location + ); } /** @@ -2612,7 +2642,6 @@ namespace ts { /*type*/ undefined, createBlock( buildResult, - /*location*/ undefined, /*multiLine*/ buildResult.length > 0 ) ), @@ -2942,7 +2971,7 @@ namespace ts { * @param operationLocation The source map location for the operation. */ function writeAssign(left: Expression, right: Expression, operationLocation: TextRange): void { - writeStatement(createStatement(createAssignment(left, right), operationLocation)); + writeStatement(setTextRange(createStatement(createAssignment(left, right)), operationLocation)); } /** @@ -2954,7 +2983,7 @@ namespace ts { function writeThrow(expression: Expression, operationLocation: TextRange): void { lastOperationWasAbrupt = true; lastOperationWasCompletion = true; - writeStatement(createThrow(expression, operationLocation)); + writeStatement(setTextRange(createThrow(expression), operationLocation)); } /** @@ -2968,10 +2997,12 @@ namespace ts { lastOperationWasCompletion = true; writeStatement( setEmitFlags( - createReturn( - createArrayLiteral(expression - ? [createInstruction(Instruction.Return), expression] - : [createInstruction(Instruction.Return)] + setTextRange( + createReturn( + createArrayLiteral(expression + ? [createInstruction(Instruction.Return), expression] + : [createInstruction(Instruction.Return)] + ) ), operationLocation ), @@ -2990,11 +3021,13 @@ namespace ts { lastOperationWasAbrupt = true; writeStatement( setEmitFlags( - createReturn( - createArrayLiteral([ - createInstruction(Instruction.Break), - createLabel(label) - ]), + setTextRange( + createReturn( + createArrayLiteral([ + createInstruction(Instruction.Break), + createLabel(label) + ]) + ), operationLocation ), EmitFlags.NoTokenSourceMaps @@ -3015,11 +3048,13 @@ namespace ts { createIf( condition, setEmitFlags( - createReturn( - createArrayLiteral([ - createInstruction(Instruction.Break), - createLabel(label) - ]), + setTextRange( + createReturn( + createArrayLiteral([ + createInstruction(Instruction.Break), + createLabel(label) + ]) + ), operationLocation ), EmitFlags.NoTokenSourceMaps @@ -3043,11 +3078,13 @@ namespace ts { createIf( createLogicalNot(condition), setEmitFlags( - createReturn( - createArrayLiteral([ - createInstruction(Instruction.Break), - createLabel(label) - ]), + setTextRange( + createReturn( + createArrayLiteral([ + createInstruction(Instruction.Break), + createLabel(label) + ]) + ), operationLocation ), EmitFlags.NoTokenSourceMaps @@ -3068,11 +3105,13 @@ namespace ts { lastOperationWasAbrupt = true; writeStatement( setEmitFlags( - createReturn( - createArrayLiteral( - expression - ? [createInstruction(Instruction.Yield), expression] - : [createInstruction(Instruction.Yield)] + setTextRange( + createReturn( + createArrayLiteral( + expression + ? [createInstruction(Instruction.Yield), expression] + : [createInstruction(Instruction.Yield)] + ) ), operationLocation ), @@ -3091,11 +3130,13 @@ namespace ts { lastOperationWasAbrupt = true; writeStatement( setEmitFlags( - createReturn( - createArrayLiteral([ - createInstruction(Instruction.YieldStar), - expression - ]), + setTextRange( + createReturn( + createArrayLiteral([ + createInstruction(Instruction.YieldStar), + expression + ]) + ), operationLocation ), EmitFlags.NoTokenSourceMaps @@ -3191,8 +3232,8 @@ namespace ts { priority: 6, text: ` var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t; - return { next: verb(0), "throw": verb(1), "return": verb(2) }; + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index ecb5dd053e0..e9455490a5d 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -6,7 +6,6 @@ namespace ts { export function transformJsx(context: TransformationContext) { const compilerOptions = context.getCompilerOptions(); - let currentSourceFile: SourceFile; return transformSourceFile; @@ -20,12 +19,8 @@ namespace ts { return node; } - currentSourceFile = node; - const visited = visitEachChild(node, visitor, context); addEmitHelpers(visited, context.readEmitHelpers()); - - currentSourceFile = undefined; return visited; } @@ -85,7 +80,7 @@ namespace ts { function visitJsxOpeningLikeElement(node: JsxOpeningLikeElement, children: JsxChild[], isChild: boolean, location: TextRange) { const tagName = getTagName(node); let objectProperties: Expression; - const attrs = node.attributes; + const attrs = node.attributes.properties; if (attrs.length === 0) { // When there are no attributes, React wants "null" objectProperties = createNull(); @@ -143,13 +138,16 @@ namespace ts { function transformJsxAttributeInitializer(node: StringLiteral | JsxExpression) { if (node === undefined) { - return createLiteral(true); + return createTrue(); } else if (node.kind === SyntaxKind.StringLiteral) { const decoded = tryDecodeEntities((node).text); - return decoded ? createLiteral(decoded, /*location*/ node) : node; + return decoded ? setTextRange(createLiteral(decoded), node) : node; } else if (node.kind === SyntaxKind.JsxExpression) { + if (node.expression === undefined) { + return createTrue(); + } return visitJsxExpression(node); } else { @@ -157,33 +155,50 @@ namespace ts { } } - function visitJsxText(node: JsxText) { - const text = getTextOfNode(node, /*includeTrivia*/ true); - let parts: Expression[]; + function visitJsxText(node: JsxText): StringLiteral | undefined { + const fixed = fixupWhitespaceAndDecodeEntities(getTextOfNode(node, /*includeTrivia*/ true)); + return fixed === undefined ? undefined : createLiteral(fixed); + } + + /** + * 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 + * See also https://www.w3.org/TR/html4/struct/text.html#h-9.1 and https://www.w3.org/TR/CSS2/text.html#white-space-model + * + * An equivalent algorithm would be: + * - If there is only one line, return it. + * - If there is only whitespace (but multiple lines), return `undefined`. + * - Split the text into lines. + * - 'trimRight' the first line, 'trimLeft' the last line, 'trim' middle lines. + * - Decode entities on each line (individually). + * - Remove empty lines and join the rest with " ". + */ + function fixupWhitespaceAndDecodeEntities(text: string): string | undefined { + let acc: string | undefined; + // First non-whitespace character on this line. let firstNonWhitespace = 0; + // Last non-whitespace character on this line. let lastNonWhitespace = -1; + // These initial values are special because the first line is: + // firstNonWhitespace = 0 to indicate that we want leading whitsepace, + // but lastNonWhitespace = -1 as a special flag to indicate that we *don't* include the line if it's all whitespace. - // 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 (let i = 0; i < text.length; i++) { const c = text.charCodeAt(i); if (isLineBreak(c)) { - if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - const part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - if (!parts) { - parts = []; - } - - // We do not escape the string here as that is handled by the printer - // when it emits the literal. We do, however, need to decode JSX entities. - parts.push(createLiteral(decodeEntities(part))); + // If we've seen any non-whitespace characters on this line, add the 'trim' of the line. + // (lastNonWhitespace === -1 is a special flag to detect whether the first line is all whitespace.) + if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) { + acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1)); } + // Reset firstNonWhitespace for the next line. + // Don't bother to reset lastNonWhitespace because we ignore it if firstNonWhitespace = -1. firstNonWhitespace = -1; } - else if (!isWhiteSpace(c)) { + else if (!isWhiteSpaceSingleLine(c)) { lastNonWhitespace = i; if (firstNonWhitespace === -1) { firstNonWhitespace = i; @@ -191,29 +206,18 @@ namespace ts { } } - if (firstNonWhitespace !== -1) { - const part = text.substr(firstNonWhitespace); - if (!parts) { - parts = []; - } - - // We do not escape the string here as that is handled by the printer - // when it emits the literal. We do, however, need to decode JSX entities. - parts.push(createLiteral(decodeEntities(part))); - } - - if (parts) { - return reduceLeft(parts, aggregateJsxTextParts); - } - - return undefined; + return firstNonWhitespace !== -1 + // Last line had a non-whitespace character. Emit the 'trimLeft', meaning keep trailing whitespace. + ? addLineOfJsxText(acc, text.substr(firstNonWhitespace)) + // Last line was all whitespace, so ignore it + : acc; } - /** - * Aggregates two expressions by interpolating them with a whitespace literal. - */ - function aggregateJsxTextParts(left: Expression, right: Expression) { - return createAdd(createAdd(left, createLiteral(" ")), right); + function addLineOfJsxText(acc: string | undefined, trimmedLine: string): string { + // We do not escape the string here as that is handled by the printer + // when it emits the literal. We do, however, need to decode JSX entities. + const decoded = decodeEntities(trimmedLine); + return acc === undefined ? decoded : acc + " " + decoded; } /** @@ -229,7 +233,7 @@ namespace ts { return String.fromCharCode(parseInt(hex, 16)); } else { - const ch = entities[word]; + const ch = entities.get(word); // If this is not a valid entity, then just use `match` (replace it with itself, i.e. don't replace) return ch ? String.fromCharCode(ch) : match; } @@ -277,7 +281,7 @@ namespace ts { } } - const entities = createMap({ + const entities = createMapFromTemplate({ "quot": 0x0022, "amp": 0x0026, "apos": 0x0027, diff --git a/src/compiler/transformers/module/es2015.ts b/src/compiler/transformers/module/es2015.ts index 5611f890164..7028e235961 100644 --- a/src/compiler/transformers/module/es2015.ts +++ b/src/compiler/transformers/module/es2015.ts @@ -37,7 +37,7 @@ namespace ts { addRange(statements, visitNodes(node.statements, visitor, isStatement, statementOffset)); return updateSourceFileNode( node, - createNodeArray(statements, node.statements)); + setTextRange(createNodeArray(statements), node.statements)); } else { return visitEachChild(node, visitor, context); @@ -71,18 +71,18 @@ namespace ts { /** * Hook for node emit. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ - function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void { + function onEmitNode(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void { if (isSourceFile(node)) { currentSourceFile = node; - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } @@ -93,14 +93,15 @@ namespace ts { /** * Hooks node substitutions. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ - function onSubstituteNode(emitContext: EmitContext, node: Node) { - node = previousOnSubstituteNode(emitContext, node); - if (isIdentifier(node) && emitContext === EmitContext.Expression) { + function onSubstituteNode(hint: EmitHint, node: Node) { + node = previousOnSubstituteNode(hint, node); + if (isIdentifier(node) && hint === EmitHint.Expression) { return substituteExpressionIdentifier(node); } + return node; } diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index da8a55ed3bc..1cd212c61c4 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -1,5 +1,6 @@ -/// +/// /// +/// /*@internal*/ namespace ts { @@ -10,12 +11,13 @@ namespace ts { importAliasNames: ParameterDeclaration[]; } - const transformModuleDelegates = createMap<(node: SourceFile) => SourceFile>({ - [ModuleKind.None]: transformCommonJSModule, - [ModuleKind.CommonJS]: transformCommonJSModule, - [ModuleKind.AMD]: transformAMDModule, - [ModuleKind.UMD]: transformUMDModule, - }); + function getTransformModuleDelegate(moduleKind: ModuleKind): (node: SourceFile) => SourceFile { + switch (moduleKind) { + case ModuleKind.AMD: return transformAMDModule; + case ModuleKind.UMD: return transformUMDModule; + default: return transformCommonJSModule; + } + } const { startLexicalEnvironment, @@ -38,12 +40,12 @@ namespace ts { context.enableSubstitution(SyntaxKind.ShorthandPropertyAssignment); // Substitutes shorthand property assignments for imported/exported symbols. context.enableEmitNotification(SyntaxKind.SourceFile); // Restore state when substituting nodes in a file. - const moduleInfoMap = createMap(); // The ExternalModuleInfo for each file. - const deferredExports = createMap(); // Exports to defer until an EndOfDeclarationMarker is found. + const moduleInfoMap: ExternalModuleInfo[] = []; // The ExternalModuleInfo for each file. + const deferredExports: Statement[][] = []; // Exports to defer until an EndOfDeclarationMarker is found. let currentSourceFile: SourceFile; // The current file. let currentModuleInfo: ExternalModuleInfo; // The ExternalModuleInfo for the current file. - let noSubstitution: Map; // Set of nodes for which substitution rules should be ignored. + let noSubstitution: boolean[]; // Set of nodes for which substitution rules should be ignored. return transformSourceFile; @@ -60,10 +62,11 @@ namespace ts { } currentSourceFile = node; - currentModuleInfo = moduleInfoMap[getOriginalNodeId(node)] = collectExternalModuleInfo(node, resolver, compilerOptions); + currentModuleInfo = collectExternalModuleInfo(node, resolver, compilerOptions); + moduleInfoMap[getOriginalNodeId(node)] = currentModuleInfo; // Perform the transformation. - const transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ModuleKind.None]; + const transformModule = getTransformModuleDelegate(moduleKind); const updated = transformModule(node); currentSourceFile = undefined; @@ -81,16 +84,22 @@ namespace ts { const statements: Statement[] = []; const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - append(statements, visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, isStatement, /*optional*/ true)); - addRange(statements, visitNodes(node.statements, sourceElementVisitor, isStatement, statementOffset)); - addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); - const updated = updateSourceFileNode(node, createNodeArray(statements, node.statements)); - if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { - addEmitHelper(updated, exportStarHelper); + if (!currentModuleInfo.exportEquals) { + append(statements, createUnderscoreUnderscoreESModule()); } + append(statements, visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, isStatement)); + addRange(statements, visitNodes(node.statements, sourceElementVisitor, isStatement, statementOffset)); + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); + addRange(statements, endLexicalEnvironment()); + + const updated = updateSourceFileNode(node, setTextRange(createNodeArray(statements), node.statements)); + if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { + // If we have any `export * from ...` declarations + // we need to inform the emitter to add the __export helper. + addEmitHelper(updated, exportStarHelper); + } return updated; } @@ -129,47 +138,49 @@ namespace ts { // Create an updated SourceFile: // // define(moduleName?, ["module1", "module2"], function ... - return updateSourceFileNode(node, createNodeArray( - [ - createStatement( - createCall( - define, - /*typeArguments*/ undefined, - [ - // Add the module name (if provided). - ...(moduleName ? [moduleName] : []), + return updateSourceFileNode(node, + setTextRange( + createNodeArray([ + createStatement( + createCall( + define, + /*typeArguments*/ undefined, + [ + // Add the module name (if provided). + ...(moduleName ? [moduleName] : []), - // Add the dependency array argument: - // - // ["require", "exports", module1", "module2", ...] - createArrayLiteral([ - createLiteral("require"), - createLiteral("exports"), - ...aliasedModuleNames, - ...unaliasedModuleNames - ]), + // Add the dependency array argument: + // + // ["require", "exports", module1", "module2", ...] + createArrayLiteral([ + createLiteral("require"), + createLiteral("exports"), + ...aliasedModuleNames, + ...unaliasedModuleNames + ]), - // Add the module body function argument: - // - // function (require, exports, module1, module2) ... - createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, - [ - createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), - createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports"), - ...importAliasNames - ], - /*type*/ undefined, - transformAsynchronousModuleBody(node) - ) - ] + // Add the module body function argument: + // + // function (require, exports, module1, module2) ... + createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, + [ + createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), + createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports"), + ...importAliasNames + ], + /*type*/ undefined, + transformAsynchronousModuleBody(node) + ) + ] + ) ) - ) - ], - /*location*/ node.statements) + ]), + /*location*/ node.statements + ) ); } @@ -187,74 +198,76 @@ namespace ts { /*typeParameters*/ undefined, [createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "factory")], /*type*/ undefined, - createBlock( - [ - createIf( - createLogicalAnd( - createTypeCheck(createIdentifier("module"), "object"), - createTypeCheck(createPropertyAccess(createIdentifier("module"), "exports"), "object") - ), - createBlock([ - createVariableStatement( - /*modifiers*/ undefined, - [ - createVariableDeclaration( - "v", - /*type*/ undefined, + setTextRange( + createBlock( + [ + createIf( + createLogicalAnd( + createTypeCheck(createIdentifier("module"), "object"), + createTypeCheck(createPropertyAccess(createIdentifier("module"), "exports"), "object") + ), + createBlock([ + createVariableStatement( + /*modifiers*/ undefined, + [ + createVariableDeclaration( + "v", + /*type*/ undefined, + createCall( + createIdentifier("factory"), + /*typeArguments*/ undefined, + [ + createIdentifier("require"), + createIdentifier("exports") + ] + ) + ) + ] + ), + setEmitFlags( + createIf( + createStrictInequality( + createIdentifier("v"), + createIdentifier("undefined") + ), + createStatement( + createAssignment( + createPropertyAccess(createIdentifier("module"), "exports"), + createIdentifier("v") + ) + ) + ), + EmitFlags.SingleLine + ) + ]), + createIf( + createLogicalAnd( + createTypeCheck(createIdentifier("define"), "function"), + createPropertyAccess(createIdentifier("define"), "amd") + ), + createBlock([ + createStatement( createCall( - createIdentifier("factory"), + createIdentifier("define"), /*typeArguments*/ undefined, [ - createIdentifier("require"), - createIdentifier("exports") + createArrayLiteral([ + createLiteral("require"), + createLiteral("exports"), + ...aliasedModuleNames, + ...unaliasedModuleNames + ]), + createIdentifier("factory") ] ) ) - ] - ), - setEmitFlags( - createIf( - createStrictInequality( - createIdentifier("v"), - createIdentifier("undefined") - ), - createStatement( - createAssignment( - createPropertyAccess(createIdentifier("module"), "exports"), - createIdentifier("v") - ) - ) - ), - EmitFlags.SingleLine + ]) ) - ]), - createIf( - createLogicalAnd( - createTypeCheck(createIdentifier("define"), "function"), - createPropertyAccess(createIdentifier("define"), "amd") - ), - createBlock([ - createStatement( - createCall( - createIdentifier("define"), - /*typeArguments*/ undefined, - [ - createArrayLiteral([ - createLiteral("require"), - createLiteral("exports"), - ...aliasedModuleNames, - ...unaliasedModuleNames - ]), - createIdentifier("factory") - ] - ) - ) - ]) ) - ) - ], - /*location*/ undefined, - /*multiLine*/ true + ], + /*multiLine*/ true + ), + /*location*/ undefined ) ); @@ -272,8 +285,8 @@ namespace ts { return updateSourceFileNode( node, - createNodeArray( - [ + setTextRange( + createNodeArray([ createStatement( createCall( umdHeader, @@ -298,7 +311,7 @@ namespace ts { ] ) ) - ], + ]), /*location*/ node.statements ) ); @@ -365,18 +378,22 @@ namespace ts { const statements: Statement[] = []; const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (!currentModuleInfo.exportEquals) { + append(statements, createUnderscoreUnderscoreESModule()); + } + // Visit each statement of the module body. - append(statements, visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, isStatement, /*optional*/ true)); + append(statements, visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, isStatement)); addRange(statements, visitNodes(node.statements, sourceElementVisitor, isStatement, statementOffset)); + // Append the 'export =' statement if provided. + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); + // End the lexical environment for the module body // and merge any new lexical declarations. addRange(statements, endLexicalEnvironment()); - // Append the 'export =' statement if provided. - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); - - const body = createBlock(statements, /*location*/ undefined, /*multiLine*/ true); + const body = createBlock(statements, /*multiLine*/ true); if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { // If we have any `export * from ...` declarations // we need to inform the emitter to add the __export helper. @@ -397,11 +414,8 @@ namespace ts { function addExportEqualsIfNeeded(statements: Statement[], emitAsReturn: boolean) { if (currentModuleInfo.exportEquals) { if (emitAsReturn) { - const statement = createReturn( - currentModuleInfo.exportEquals.expression, - /*location*/ currentModuleInfo.exportEquals - ); - + const statement = createReturn(currentModuleInfo.exportEquals.expression); + setTextRange(statement, currentModuleInfo.exportEquals); setEmitFlags(statement, EmitFlags.NoTokenSourceMaps | EmitFlags.NoComments); statements.push(statement); } @@ -413,10 +427,10 @@ namespace ts { "exports" ), currentModuleInfo.exportEquals.expression - ), - /*location*/ currentModuleInfo.exportEquals + ) ); + setTextRange(statement, currentModuleInfo.exportEquals); setEmitFlags(statement, EmitFlags.NoComments); statements.push(statement); } @@ -479,7 +493,7 @@ namespace ts { if (moduleKind !== ModuleKind.AMD) { if (!node.importClause) { // import "mod"; - return createStatement(createRequireCall(node), /*location*/ node); + return setTextRange(createStatement(createRequireCall(node)), node); } else { const variables: VariableDeclaration[] = []; @@ -518,12 +532,13 @@ namespace ts { } statements = append(statements, - createVariableStatement( - /*modifiers*/ undefined, - createVariableDeclarationList( - variables, - /*location*/ undefined, - languageVersion >= ScriptTarget.ES2015 ? NodeFlags.Const : NodeFlags.None + setTextRange( + createVariableStatement( + /*modifiers*/ undefined, + createVariableDeclarationList( + variables, + languageVersion >= ScriptTarget.ES2015 ? NodeFlags.Const : NodeFlags.None + ) ), /*location*/ node ) @@ -537,14 +552,15 @@ namespace ts { /*modifiers*/ undefined, createVariableDeclarationList( [ - createVariableDeclaration( - getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, - getGeneratedNameForNode(node), + setTextRange( + createVariableDeclaration( + getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, + getGeneratedNameForNode(node) + ), /*location*/ node ) ], - /*location*/ undefined, languageVersion >= ScriptTarget.ES2015 ? NodeFlags.Const : NodeFlags.None ) ) @@ -590,31 +606,34 @@ namespace ts { if (moduleKind !== ModuleKind.AMD) { if (hasModifier(node, ModifierFlags.Export)) { statements = append(statements, - createStatement( - createExportExpression( - node.name, - createRequireCall(node) + setTextRange( + createStatement( + createExportExpression( + node.name, + createRequireCall(node) + ) ), - /*location*/ node + node ) ); } else { statements = append(statements, - createVariableStatement( - /*modifiers*/ undefined, - createVariableDeclarationList( - [ - createVariableDeclaration( - getSynthesizedClone(node.name), - /*type*/ undefined, - createRequireCall(node) - ) - ], - /*location*/ undefined, - /*flags*/ languageVersion >= ScriptTarget.ES2015 ? NodeFlags.Const : NodeFlags.None + setTextRange( + createVariableStatement( + /*modifiers*/ undefined, + createVariableDeclarationList( + [ + createVariableDeclaration( + getSynthesizedClone(node.name), + /*type*/ undefined, + createRequireCall(node) + ) + ], + /*flags*/ languageVersion >= ScriptTarget.ES2015 ? NodeFlags.Const : NodeFlags.None + ) ), - /*location*/ node + node ) ); } @@ -622,9 +641,11 @@ namespace ts { else { if (hasModifier(node, ModifierFlags.Export)) { statements = append(statements, - createStatement( - createExportExpression(getExportName(node), getLocalName(node)), - /*location*/ node + setTextRange( + createStatement( + createExportExpression(getExportName(node), getLocalName(node)) + ), + node ) ); } @@ -655,20 +676,23 @@ namespace ts { } const generatedName = getGeneratedNameForNode(node); + if (node.exportClause) { const statements: Statement[] = []; // export { x, y } from "mod"; if (moduleKind !== ModuleKind.AMD) { statements.push( - createVariableStatement( - /*modifiers*/ undefined, - createVariableDeclarationList([ - createVariableDeclaration( - generatedName, - /*type*/ undefined, - createRequireCall(node) - ) - ]), + setTextRange( + createVariableStatement( + /*modifiers*/ undefined, + createVariableDeclarationList([ + createVariableDeclaration( + generatedName, + /*type*/ undefined, + createRequireCall(node) + ) + ]) + ), /*location*/ node ) ); @@ -679,9 +703,11 @@ namespace ts { specifier.propertyName || specifier.name ); statements.push( - createStatement( - createExportExpression(getExportName(specifier), exportedValue), - /*location*/ specifier + setTextRange( + createStatement( + createExportExpression(getExportName(specifier), exportedValue) + ), + specifier ) ); } @@ -690,9 +716,11 @@ namespace ts { } else { // export * from "mod"; - return createStatement( - createExportStarHelper(context, moduleKind !== ModuleKind.AMD ? createRequireCall(node) : generatedName), - /*location*/ node + return setTextRange( + createStatement( + createExportStarHelper(context, moduleKind !== ModuleKind.AMD ? createRequireCall(node) : generatedName) + ), + node ); } } @@ -731,15 +759,17 @@ namespace ts { if (hasModifier(node, ModifierFlags.Export)) { statements = append(statements, setOriginalNode( - createFunctionDeclaration( - /*decorators*/ undefined, - visitNodes(node.modifiers, modifierVisitor, isModifier), - node.asteriskToken, - getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), - /*typeParameters*/ undefined, - node.parameters, - /*type*/ undefined, - node.body, + setTextRange( + createFunctionDeclaration( + /*decorators*/ undefined, + visitNodes(node.modifiers, modifierVisitor, isModifier), + node.asteriskToken, + getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), + /*typeParameters*/ undefined, + node.parameters, + /*type*/ undefined, + node.body + ), /*location*/ node ), /*original*/ node @@ -772,16 +802,18 @@ namespace ts { if (hasModifier(node, ModifierFlags.Export)) { statements = append(statements, setOriginalNode( - createClassDeclaration( - /*decorators*/ undefined, - visitNodes(node.modifiers, modifierVisitor, isModifier), - getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), - /*typeParameters*/ undefined, - node.heritageClauses, - node.members, - /*location*/ node + setTextRange( + createClassDeclaration( + /*decorators*/ undefined, + visitNodes(node.modifiers, modifierVisitor, isModifier), + getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), + /*typeParameters*/ undefined, + node.heritageClauses, + node.members + ), + node ), - /*original*/ node + node ) ); } @@ -810,6 +842,7 @@ namespace ts { let statements: Statement[]; let variables: VariableDeclaration[]; let expressions: Expression[]; + if (hasModifier(node, ModifierFlags.Export)) { let modifiers: NodeArray; @@ -833,7 +866,7 @@ namespace ts { } if (expressions) { - statements = append(statements, createStatement(inlineExpressions(expressions), /*location*/ node)); + statements = append(statements, setTextRange(createStatement(inlineExpressions(expressions)), node)); } } else { @@ -870,9 +903,11 @@ namespace ts { } else { return createAssignment( - createPropertyAccess( - createIdentifier("exports"), - node.name, + setTextRange( + createPropertyAccess( + createIdentifier("exports"), + node.name + ), /*location*/ node.name ), node.initializer @@ -1075,7 +1110,7 @@ namespace ts { */ function appendExportsOfDeclaration(statements: Statement[] | undefined, decl: Declaration): Statement[] | undefined { const name = getDeclarationName(decl); - const exportSpecifiers = currentModuleInfo.exportSpecifiers[name.text]; + const exportSpecifiers = currentModuleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { for (const exportSpecifier of exportSpecifiers) { statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name); @@ -1097,43 +1132,39 @@ namespace ts { * @param allowComments Whether to allow comments on the export. */ function appendExportStatement(statements: Statement[] | undefined, exportName: Identifier, expression: Expression, location?: TextRange, allowComments?: boolean): Statement[] | undefined { - if (exportName.text === "default") { - const sourceFile = getOriginalNode(currentSourceFile, isSourceFile); - if (sourceFile && !sourceFile.symbol.exports["___esModule"]) { - if (languageVersion === ScriptTarget.ES3) { - statements = append(statements, - createStatement( - createExportExpression( - createIdentifier("__esModule"), - createLiteral(true) - ) - ) - ); - } - else { - statements = append(statements, - createStatement( - createCall( - createPropertyAccess(createIdentifier("Object"), "defineProperty"), - /*typeArguments*/ undefined, - [ - createIdentifier("exports"), - createLiteral("__esModule"), - createObjectLiteral([ - createPropertyAssignment("value", createLiteral(true)) - ]) - ] - ) - ) - ); - } - } - } - statements = append(statements, createExportStatement(exportName, expression, location, allowComments)); return statements; } + function createUnderscoreUnderscoreESModule() { + let statement: Statement; + if (languageVersion === ScriptTarget.ES3) { + statement = createStatement( + createExportExpression( + createIdentifier("__esModule"), + createLiteral(true) + ) + ) + } + else { + statement = createStatement( + createCall( + createPropertyAccess(createIdentifier("Object"), "defineProperty"), + /*typeArguments*/ undefined, + [ + createIdentifier("exports"), + createLiteral("__esModule"), + createObjectLiteral([ + createPropertyAssignment("value", createLiteral(true)) + ]) + ] + ) + ); + } + setEmitFlags(statement, EmitFlags.CustomPrologue); + return statement; + } + /** * Creates a call to the current file's export function to export a value. * @@ -1143,7 +1174,7 @@ namespace ts { * @param allowComments An optional value indicating whether to emit comments for the statement. */ function createExportStatement(name: Identifier, value: Expression, location?: TextRange, allowComments?: boolean) { - const statement = createStatement(createExportExpression(name, value), location); + const statement = setTextRange(createStatement(createExportExpression(name, value)), location); startOnNewLine(statement); if (!allowComments) { setEmitFlags(statement, EmitFlags.NoComments); @@ -1160,12 +1191,14 @@ namespace ts { * @param location The location to use for source maps and comments for the export. */ function createExportExpression(name: Identifier, value: Expression, location?: TextRange) { - return createAssignment( - createPropertyAccess( - createIdentifier("exports"), - getSynthesizedClone(name) + return setTextRange( + createAssignment( + createPropertyAccess( + createIdentifier("exports"), + getSynthesizedClone(name) + ), + value ), - value, location ); } @@ -1197,24 +1230,24 @@ namespace ts { /** * Hook for node emit notifications. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ - function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void { + function onEmitNode(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void { if (node.kind === SyntaxKind.SourceFile) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[getOriginalNodeId(currentSourceFile)]; - noSubstitution = createMap(); + noSubstitution = []; - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; currentModuleInfo = undefined; noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } @@ -1225,16 +1258,16 @@ namespace ts { /** * Hooks node substitutions. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ - function onSubstituteNode(emitContext: EmitContext, node: Node) { - node = previousOnSubstituteNode(emitContext, node); + function onSubstituteNode(hint: EmitHint, node: Node) { + node = previousOnSubstituteNode(hint, node); if (node.id && noSubstitution[node.id]) { return node; } - if (emitContext === EmitContext.Expression) { + if (hint === EmitHint.Expression) { return substituteExpression(node); } else if (isShorthandPropertyAssignment(node)) { @@ -1258,9 +1291,9 @@ namespace ts { // destructuring assignment if (node.objectAssignmentInitializer) { const initializer = createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return createPropertyAssignment(name, initializer, /*location*/ node); + return setTextRange(createPropertyAssignment(name, initializer), node); } - return createPropertyAssignment(name, exportedOrImportedName, /*location*/ node); + return setTextRange(createPropertyAssignment(name, exportedOrImportedName), node); } return node; } @@ -1296,15 +1329,18 @@ namespace ts { if (externalHelpersModuleName) { return createPropertyAccess(externalHelpersModuleName, node); } + return node; } if (!isGeneratedIdentifier(node) && !isLocalName(node)) { const exportContainer = resolver.getReferencedExportContainer(node, isExportName(node)); if (exportContainer && exportContainer.kind === SyntaxKind.SourceFile) { - return createPropertyAccess( - createIdentifier("exports"), - getSynthesizedClone(node), + return setTextRange( + createPropertyAccess( + createIdentifier("exports"), + getSynthesizedClone(node) + ), /*location*/ node ); } @@ -1312,17 +1348,21 @@ namespace ts { const importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { if (isImportClause(importDeclaration)) { - return createPropertyAccess( - getGeneratedNameForNode(importDeclaration.parent), - createIdentifier("default"), + return setTextRange( + createPropertyAccess( + getGeneratedNameForNode(importDeclaration.parent), + createIdentifier("default") + ), /*location*/ node ); } else if (isImportSpecifier(importDeclaration)) { const name = importDeclaration.propertyName || importDeclaration.name; - return createPropertyAccess( - getGeneratedNameForNode(importDeclaration.parent.parent.parent), - getSynthesizedClone(name), + return setTextRange( + createPropertyAccess( + getGeneratedNameForNode(importDeclaration.parent.parent.parent), + getSynthesizedClone(name) + ), /*location*/ node ); } @@ -1390,10 +1430,12 @@ namespace ts { const exportedNames = getExports(node.operand); if (exportedNames) { let expression: Expression = node.kind === SyntaxKind.PostfixUnaryExpression - ? createBinary( - node.operand, - createToken(node.operator === SyntaxKind.PlusPlusToken ? SyntaxKind.PlusEqualsToken : SyntaxKind.MinusEqualsToken), - createLiteral(1), + ? setTextRange( + createBinary( + node.operand, + createToken(node.operator === SyntaxKind.PlusPlusToken ? SyntaxKind.PlusEqualsToken : SyntaxKind.MinusEqualsToken), + createLiteral(1) + ), /*location*/ node) : node; for (const exportName of exportedNames) { diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 0e3a42da0d2..7488c51ed91 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -1,5 +1,6 @@ -/// +/// /// +/// /*@internal*/ namespace ts { @@ -28,10 +29,10 @@ namespace ts { context.enableSubstitution(SyntaxKind.PostfixUnaryExpression); // Substitutes updates to exported symbols. context.enableEmitNotification(SyntaxKind.SourceFile); // Restore state when substituting nodes in a file. - const moduleInfoMap = createMap(); // The ExternalModuleInfo for each file. - const deferredExports = createMap(); // Exports to defer until an EndOfDeclarationMarker is found. - const exportFunctionsMap = createMap(); // The export function associated with a source file. - const noSubstitutionMap = createMap>(); // Set of nodes for which substitution rules should be ignored for each file. + const moduleInfoMap: ExternalModuleInfo[] = []; // The ExternalModuleInfo for each file. + const deferredExports: Statement[][] = []; // Exports to defer until an EndOfDeclarationMarker is found. + const exportFunctionsMap: Identifier[] = []; // The export function associated with a source file. + const noSubstitutionMap: boolean[][] = []; // Set of nodes for which substitution rules should be ignored for each file. let currentSourceFile: SourceFile; // The current file. let moduleInfo: ExternalModuleInfo; // ExternalModuleInfo for the current file. @@ -39,7 +40,7 @@ namespace ts { let contextObject: Identifier; // The context object for the current file. let hoistedStatements: Statement[]; let enclosingBlockScopedContainer: Node; - let noSubstitution: Map; // Set of nodes for which substitution rules should be ignored. + let noSubstitution: boolean[]; // Set of nodes for which substitution rules should be ignored. return transformSourceFile; @@ -77,7 +78,8 @@ namespace ts { // Make sure that the name of the 'exports' function does not conflict with // existing identifiers. - exportFunction = exportFunctionsMap[id] = createUniqueName("exports"); + exportFunction = createUniqueName("exports"); + exportFunctionsMap[id] = exportFunction; contextObject = createUniqueName("context"); // Add the body of the module. @@ -104,17 +106,20 @@ namespace ts { const updated = setEmitFlags( updateSourceFileNode( node, - createNodeArray([ - createStatement( - createCall( - createPropertyAccess(createIdentifier("System"), "register"), - /*typeArguments*/ undefined, - moduleName - ? [moduleName, dependencies, moduleBodyFunction] - : [dependencies, moduleBodyFunction] + setTextRange( + createNodeArray([ + createStatement( + createCall( + createPropertyAccess(createIdentifier("System"), "register"), + /*typeArguments*/ undefined, + moduleName + ? [moduleName, dependencies, moduleBodyFunction] + : [dependencies, moduleBodyFunction] + ) ) - ) - ], node.statements) + ]), + node.statements + ) ), EmitFlags.NoTrailingComments); if (!(compilerOptions.outFile || compilerOptions.out)) { @@ -132,7 +137,6 @@ namespace ts { contextObject = undefined; hoistedStatements = undefined; enclosingBlockScopedContainer = undefined; - return aggregateTransformFlags(updated); } @@ -148,13 +152,13 @@ namespace ts { const externalImport = externalImports[i]; const externalModuleName = getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); const text = externalModuleName.text; - if (hasProperty(groupIndices, text)) { + const groupIndex = groupIndices.get(text); + if (groupIndex !== undefined) { // deduplicate/group entries in dependency list by the dependency name - const groupIndex = groupIndices[text]; dependencyGroups[groupIndex].externalImports.push(externalImport); } else { - groupIndices[text] = dependencyGroups.length; + groupIndices.set(text, dependencyGroups.length); dependencyGroups.push({ name: externalModuleName, externalImports: [externalImport] @@ -241,7 +245,7 @@ namespace ts { ); // Visit the synthetic external helpers import declaration if present - visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, isStatement, /*optional*/ true); + visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, isStatement); // Visit the statements of the source file, emitting any transformations into // the `executeStatements` array. We do this *before* we fill the `setters` array @@ -259,35 +263,26 @@ namespace ts { addRange(statements, endLexicalEnvironment()); const exportStarFunction = addExportStarIfNeeded(statements); - statements.push( - createReturn( - setMultiLine( - createObjectLiteral([ - createPropertyAssignment("setters", - createSettersArray(exportStarFunction, dependencyGroups) - ), - createPropertyAssignment("execute", - createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, - /*parameters*/ [], - /*type*/ undefined, - createBlock( - executeStatements, - /*location*/ undefined, - /*multiLine*/ true - ) - ) - ) - ]), - /*multiLine*/ true + const moduleObject = createObjectLiteral([ + createPropertyAssignment("setters", + createSettersArray(exportStarFunction, dependencyGroups) + ), + createPropertyAssignment("execute", + createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, + /*parameters*/ [], + /*type*/ undefined, + createBlock(executeStatements, /*multiLine*/ true) ) ) - ); + ]); - return createBlock(statements, /*location*/ undefined, /*multiLine*/ true); + moduleObject.multiLine = true; + statements.push(createReturn(moduleObject)); + return createBlock(statements, /*multiLine*/ true); } /** @@ -306,7 +301,7 @@ namespace ts { // this set is used to filter names brought by star expors. // local names set should only be added if we have anything exported - if (!moduleInfo.exportedNames && isEmpty(moduleInfo.exportSpecifiers)) { + if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) { // no exported declarations (export var ...) or export specifiers (export {x}) // check if we have any non star export declarations. let hasExportDeclarationWithExportClause = false; @@ -336,7 +331,7 @@ namespace ts { exportedNames.push( createPropertyAssignment( createLiteral(exportedLocalName), - createLiteral(true) + createTrue() ) ); } @@ -358,7 +353,7 @@ namespace ts { exportedNames.push( createPropertyAssignment( createLiteral((element.name || element.propertyName).text), - createLiteral(true) + createTrue() ) ); } @@ -372,7 +367,7 @@ namespace ts { createVariableDeclaration( exportedNamesStorageRef, /*type*/ undefined, - createObjectLiteral(exportedNames, /*location*/ undefined, /*multiline*/ true) + createObjectLiteral(exportedNames, /*multiline*/ true) ) ]) ) @@ -455,9 +450,7 @@ namespace ts { [exports] ) ) - ], - /*location*/ undefined, - /*multiline*/ true) + ], /*multiline*/ true) ); } @@ -524,7 +517,7 @@ namespace ts { createCall( exportFunction, /*typeArguments*/ undefined, - [createObjectLiteral(properties, /*location*/ undefined, /*multiline*/ true)] + [createObjectLiteral(properties, /*multiline*/ true)] ) ) ); @@ -557,12 +550,12 @@ namespace ts { /*typeParameters*/ undefined, [createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], /*type*/ undefined, - createBlock(statements, /*location*/ undefined, /*multiLine*/ true) + createBlock(statements, /*multiLine*/ true) ) ); } - return createArrayLiteral(setters, /*location*/ undefined, /*multiLine*/ true); + return createArrayLiteral(setters, /*multiLine*/ true); } // @@ -676,6 +669,7 @@ namespace ts { node, node.decorators, visitNodes(node.modifiers, modifierVisitor, isModifier), + node.asteriskToken, getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, visitNodes(node.parameters, destructuringVisitor, isParameterDeclaration), @@ -712,19 +706,23 @@ namespace ts { // Rewrite the class declaration into an assignment of a class expression. statements = append(statements, - createStatement( - createAssignment( - name, - createClassExpression( - /*modifiers*/ undefined, - node.name, - /*typeParameters*/ undefined, - visitNodes(node.heritageClauses, destructuringVisitor, isHeritageClause), - visitNodes(node.members, destructuringVisitor, isClassElement), - /*location*/ node + setTextRange( + createStatement( + createAssignment( + name, + setTextRange( + createClassExpression( + /*modifiers*/ undefined, + node.name, + /*typeParameters*/ undefined, + visitNodes(node.heritageClauses, destructuringVisitor, isHeritageClause), + visitNodes(node.members, destructuringVisitor, isClassElement) + ), + node + ) ) ), - /*location*/ node + node ) ); @@ -765,7 +763,7 @@ namespace ts { let statements: Statement[]; if (expressions) { - statements = append(statements, createStatement(inlineExpressions(expressions), /*location*/ node)); + statements = append(statements, setTextRange(createStatement(inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { @@ -863,8 +861,8 @@ namespace ts { function createVariableAssignment(name: Identifier, value: Expression, location: TextRange, isExportedDeclaration: boolean) { hoistVariableDeclaration(getSynthesizedClone(name)); return isExportedDeclaration - ? createExportExpression(name, preventSubstitution(createAssignment(name, value, location))) - : preventSubstitution(createAssignment(name, value, location)); + ? createExportExpression(name, preventSubstitution(setTextRange(createAssignment(name, value), location))) + : preventSubstitution(setTextRange(createAssignment(name, value), location)); } /** @@ -1081,7 +1079,7 @@ namespace ts { } const name = getDeclarationName(decl); - const exportSpecifiers = moduleInfo.exportSpecifiers[name.text]; + const exportSpecifiers = moduleInfo.exportSpecifiers.get(name.text); if (exportSpecifiers) { for (const exportSpecifier of exportSpecifiers) { if (exportSpecifier.name.text !== excludeName) { @@ -1221,8 +1219,8 @@ namespace ts { node = updateFor( node, visitForInitializer(node.initializer), - visitNode(node.condition, destructuringVisitor, isExpression, /*optional*/ true), - visitNode(node.incrementor, destructuringVisitor, isExpression, /*optional*/ true), + visitNode(node.condition, destructuringVisitor, isExpression), + visitNode(node.incrementor, destructuringVisitor, isExpression), visitNode(node.statement, nestedElementVisitor, isStatement) ); @@ -1243,7 +1241,7 @@ namespace ts { node, visitForInitializer(node.initializer), visitNode(node.expression, destructuringVisitor, isExpression), - visitNode(node.statement, nestedElementVisitor, isStatement, /*optional*/ false, liftToBlock) + visitNode(node.statement, nestedElementVisitor, isStatement, liftToBlock) ); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; @@ -1261,9 +1259,10 @@ namespace ts { node = updateForOf( node, + node.awaitModifier, visitForInitializer(node.initializer), visitNode(node.expression, destructuringVisitor, isExpression), - visitNode(node.statement, nestedElementVisitor, isStatement, /*optional*/ false, liftToBlock) + visitNode(node.statement, nestedElementVisitor, isStatement, liftToBlock) ); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; @@ -1308,7 +1307,7 @@ namespace ts { function visitDoStatement(node: DoStatement): VisitResult { return updateDo( node, - visitNode(node.statement, nestedElementVisitor, isStatement, /*optional*/ false, liftToBlock), + visitNode(node.statement, nestedElementVisitor, isStatement, liftToBlock), visitNode(node.expression, destructuringVisitor, isExpression) ); } @@ -1322,7 +1321,7 @@ namespace ts { return updateWhile( node, visitNode(node.expression, destructuringVisitor, isExpression), - visitNode(node.statement, nestedElementVisitor, isStatement, /*optional*/ false, liftToBlock) + visitNode(node.statement, nestedElementVisitor, isStatement, liftToBlock) ); } @@ -1335,7 +1334,7 @@ namespace ts { return updateLabel( node, node.label, - visitNode(node.statement, nestedElementVisitor, isStatement, /*optional*/ false, liftToBlock) + visitNode(node.statement, nestedElementVisitor, isStatement, liftToBlock) ); } @@ -1348,7 +1347,7 @@ namespace ts { return updateWith( node, visitNode(node.expression, destructuringVisitor, isExpression), - visitNode(node.statement, nestedElementVisitor, isStatement, /*optional*/ false, liftToBlock) + visitNode(node.statement, nestedElementVisitor, isStatement, liftToBlock) ); } @@ -1495,7 +1494,7 @@ namespace ts { * @param node The destructuring target. */ function hasExportedReferenceInDestructuringTarget(node: Expression | ObjectLiteralElementLike): boolean { - if (isAssignmentExpression(node)) { + if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { return hasExportedReferenceInDestructuringTarget(node.left); } else if (isSpreadExpression(node)) { @@ -1547,11 +1546,11 @@ namespace ts { /** * Hook for node emit notifications. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. - * @param emit A callback used to emit the node in the printer. + * @param emitCallback A callback used to emit the node in the printer. */ - function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void { + function onEmitNode(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void { if (node.kind === SyntaxKind.SourceFile) { const id = getOriginalNodeId(node); currentSourceFile = node; @@ -1563,7 +1562,7 @@ namespace ts { delete noSubstitutionMap[id]; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; moduleInfo = undefined; @@ -1571,7 +1570,7 @@ namespace ts { noSubstitution = undefined; } else { - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); } } @@ -1582,16 +1581,16 @@ namespace ts { /** * Hooks node substitutions. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ - function onSubstituteNode(emitContext: EmitContext, node: Node) { - node = previousOnSubstituteNode(emitContext, node); + function onSubstituteNode(hint: EmitHint, node: Node) { + node = previousOnSubstituteNode(hint, node); if (isSubstitutionPrevented(node)) { return node; } - if (emitContext === EmitContext.Expression) { + if (hint === EmitHint.Expression) { return substituteExpression(node); } @@ -1628,6 +1627,7 @@ namespace ts { if (externalHelpersModuleName) { return createPropertyAccess(externalHelpersModuleName, node); } + return node; } @@ -1641,16 +1641,20 @@ namespace ts { const importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { if (isImportClause(importDeclaration)) { - return createPropertyAccess( - getGeneratedNameForNode(importDeclaration.parent), - createIdentifier("default"), + return setTextRange( + createPropertyAccess( + getGeneratedNameForNode(importDeclaration.parent), + createIdentifier("default") + ), /*location*/ node ); } else if (isImportSpecifier(importDeclaration)) { - return createPropertyAccess( - getGeneratedNameForNode(importDeclaration.parent.parent.parent), - getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name), + return setTextRange( + createPropertyAccess( + getGeneratedNameForNode(importDeclaration.parent.parent.parent), + getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name) + ), /*location*/ node ); } @@ -1717,10 +1721,13 @@ namespace ts { const exportedNames = getExports(node.operand); if (exportedNames) { let expression: Expression = node.kind === SyntaxKind.PostfixUnaryExpression - ? createPrefix( - node.operator, - node.operand, - /*location*/ node) + ? setTextRange( + createPrefix( + node.operator, + node.operand + ), + node + ) : node; for (const exportName of exportedNames) { @@ -1770,7 +1777,7 @@ namespace ts { * @param node The node which should not be substituted. */ function preventSubstitution(node: T): T { - if (noSubstitution === undefined) noSubstitution = createMap(); + if (noSubstitution === undefined) noSubstitution = []; noSubstitution[getNodeId(node)] = true; return node; } diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 775f60355d8..e712393b2f0 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -1,4 +1,4 @@ -/// +/// /// /// @@ -60,7 +60,7 @@ namespace ts { * A map that keeps track of aliases created for classes with decorators to avoid issues * with the double-binding behavior of classes. */ - let classAliases: Map; + let classAliases: Identifier[]; /** * Keeps track of whether we are within any containing namespaces when performing @@ -588,17 +588,17 @@ namespace ts { name, /*typeParameters*/ undefined, visitNodes(node.heritageClauses, visitor, isHeritageClause), - transformClassMembers(node, hasExtendsClause), - node); - - let emitFlags = getEmitFlags(node); + transformClassMembers(node, hasExtendsClause) + ); // To better align with the old emitter, we should not emit a trailing source map // entry if the class has static properties. + let emitFlags = getEmitFlags(node); if (hasStaticProperties) { emitFlags |= EmitFlags.NoTrailingSourceMap; } + setTextRange(classDeclaration, node); setOriginalNode(classDeclaration, node); setEmitFlags(classDeclaration, emitFlags); return classDeclaration; @@ -709,13 +709,24 @@ namespace ts { // } const heritageClauses = visitNodes(node.heritageClauses, visitor, isHeritageClause); const members = transformClassMembers(node, hasExtendsClause); - const classExpression = createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members, location); + const classExpression = createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members); setOriginalNode(classExpression, node); + setTextRange(classExpression, location); // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference // or decoratedClassAlias if the class contain self-reference. - const statement = createLetStatement(declName, classAlias ? createAssignment(classAlias, classExpression) : classExpression, location); + const statement = createVariableStatement( + /*modifiers*/ undefined, + createVariableDeclarationList([ + createVariableDeclaration( + declName, + /*type*/ undefined, + classAlias ? createAssignment(classAlias, classExpression) : classExpression + ) + ], NodeFlags.Let) + ); setOriginalNode(statement, node); + setTextRange(statement, location); setCommentRange(statement, node); return statement; } @@ -734,18 +745,17 @@ namespace ts { const heritageClauses = visitNodes(node.heritageClauses, visitor, isHeritageClause); const members = transformClassMembers(node, some(heritageClauses, c => c.token === SyntaxKind.ExtendsKeyword)); - const classExpression = setOriginalNode( - createClassExpression( - /*modifiers*/ undefined, - node.name, - /*typeParameters*/ undefined, - heritageClauses, - members, - /*location*/ node - ), - node + const classExpression = createClassExpression( + /*modifiers*/ undefined, + node.name, + /*typeParameters*/ undefined, + heritageClauses, + members ); + setOriginalNode(classExpression, node); + setTextRange(classExpression, node); + if (staticProperties.length > 0) { const expressions: Expression[] = []; const temp = createTempVariable(hoistVariableDeclaration); @@ -781,7 +791,7 @@ namespace ts { } addRange(members, visitNodes(node.members, classElementVisitor, isClassElement)); - return createNodeArray(members, /*location*/ node.members); + return setTextRange(createNodeArray(members), /*location*/ node.members); } /** @@ -812,12 +822,14 @@ namespace ts { // } return startOnNewLine( setOriginalNode( - createConstructor( - /*decorators*/ undefined, - /*modifiers*/ undefined, - parameters, - body, - /*location*/ constructor || node + setTextRange( + createConstructor( + /*decorators*/ undefined, + /*modifiers*/ undefined, + parameters, + body + ), + constructor || node ), constructor ) @@ -860,7 +872,7 @@ namespace ts { * @param hasExtendsClause A value indicating whether the class has an extends clause. */ function transformConstructorBody(node: ClassExpression | ClassDeclaration, constructor: ConstructorDeclaration, hasExtendsClause: boolean) { - const statements: Statement[] = []; + let statements: Statement[] = []; let indexOfFirstStatement = 0; resumeLexicalEnvironment(); @@ -918,14 +930,16 @@ namespace ts { } // End the lexical environment. - addRange(statements, endLexicalEnvironment()); - return createBlock( - createNodeArray( - statements, - /*location*/ constructor ? constructor.body.statements : node.members + statements = mergeLexicalEnvironment(statements, endLexicalEnvironment()); + return setTextRange( + createBlock( + setTextRange( + createNodeArray(statements), + /*location*/ constructor ? constructor.body.statements : node.members + ), + /*multiLine*/ true ), - /*location*/ constructor ? constructor.body : /*location*/ undefined, - /*multiLine*/ true + /*location*/ constructor ? constructor.body : undefined ); } @@ -991,16 +1005,20 @@ namespace ts { setEmitFlags(localName, EmitFlags.NoComments); return startOnNewLine( - createStatement( - createAssignment( - createPropertyAccess( - createThis(), - propertyName, - /*location*/ node.name - ), - localName + setTextRange( + createStatement( + createAssignment( + setTextRange( + createPropertyAccess( + createThis(), + propertyName + ), + node.name + ), + localName + ) ), - /*location*/ moveRangePos(node, -1) + moveRangePos(node, -1) ) ); } @@ -1504,7 +1522,7 @@ namespace ts { (properties || (properties = [])).push(createPropertyAssignment("returnType", createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, createToken(SyntaxKind.EqualsGreaterThanToken), serializeReturnTypeOfNode(node)))); } if (properties) { - decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true))); + decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", createObjectLiteral(properties, /*multiLine*/ true))); } } } @@ -1633,7 +1651,7 @@ namespace ts { if (isFunctionLike(node) && node.type) { return serializeTypeNode(node.type); } - else if (isAsyncFunctionLike(node)) { + else if (isAsyncFunction(node)) { return createIdentifier("Promise"); } @@ -1939,10 +1957,7 @@ namespace ts { expression = createAssignment(generatedName, expression); } - return setOriginalNode( - createComputedPropertyName(expression, /*location*/ name), - name - ); + return updateComputedPropertyName(name, expression); } else { return name; @@ -1961,9 +1976,11 @@ namespace ts { function visitHeritageClause(node: HeritageClause): HeritageClause { if (node.token === SyntaxKind.ExtendsKeyword) { const types = visitNodes(node.types, visitor, isExpressionWithTypeArguments, 0, 1); - return createHeritageClause( - SyntaxKind.ExtendsKeyword, - types, + return setTextRange( + createHeritageClause( + SyntaxKind.ExtendsKeyword, + types + ), node ); } @@ -1980,11 +1997,10 @@ namespace ts { * @param node The ExpressionWithTypeArguments to transform. */ function visitExpressionWithTypeArguments(node: ExpressionWithTypeArguments): ExpressionWithTypeArguments { - const expression = visitNode(node.expression, visitor, isLeftHandSideExpression); - return createExpressionWithTypeArguments( + return updateExpressionWithTypeArguments( + node, /*typeArguments*/ undefined, - expression, - node + visitNode(node.expression, visitor, isLeftHandSideExpression) ); } @@ -2003,7 +2019,13 @@ namespace ts { return undefined; } - return visitEachChild(node, visitor, context); + return updateConstructor( + node, + visitNodes(node.decorators, visitor, isDecorator), + visitNodes(node.modifiers, visitor, isModifier), + visitParameterList(node.parameters, visitor, context), + visitFunctionBody(node.body, visitor, context) + ); } /** @@ -2024,6 +2046,7 @@ namespace ts { node, /*decorators*/ undefined, visitNodes(node.modifiers, modifierVisitor, isModifier), + node.asteriskToken, visitPropertyNameOfClassElement(node), /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), @@ -2128,6 +2151,7 @@ namespace ts { node, /*decorators*/ undefined, visitNodes(node.modifiers, modifierVisitor, isModifier), + node.asteriskToken, node.name, /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), @@ -2151,17 +2175,18 @@ namespace ts { * @param node The function expression node. */ function visitFunctionExpression(node: FunctionExpression): Expression { - if (nodeIsMissing(node.body)) { + if (!shouldEmitFunctionLikeDeclaration(node)) { return createOmittedExpression(); } const updated = updateFunctionExpression( node, visitNodes(node.modifiers, modifierVisitor, isModifier), + node.asteriskToken, node.name, /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, - visitFunctionBody(node.body, visitor, context) + visitFunctionBody(node.body, visitor, context) || createBlock([]) ); return updated; } @@ -2205,13 +2230,13 @@ namespace ts { visitNode(node.name, visitor, isBindingName), /*questionToken*/ undefined, /*type*/ undefined, - visitNode(node.initializer, visitor, isExpression), - /*location*/ moveRangePastModifiers(node) + visitNode(node.initializer, visitor, isExpression) ); // While we emit the source map for the node after skipping decorators and modifiers, // we need to emit the comments for the original range. setOriginalNode(parameter, node); + setTextRange(parameter, moveRangePastModifiers(node)); setCommentRange(parameter, node); setSourceMapRange(parameter, moveRangePastModifiers(node)); setEmitFlags(parameter.name, EmitFlags.NoTrailingSourceMap); @@ -2233,11 +2258,13 @@ namespace ts { return undefined; } - return createStatement( - inlineExpressions( - map(variables, transformInitializedVariable) + return setTextRange( + createStatement( + inlineExpressions( + map(variables, transformInitializedVariable) + ) ), - /*location*/ node + node ); } else { @@ -2258,9 +2285,11 @@ namespace ts { ); } else { - return createAssignment( - getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), - visitNode(node.initializer, visitor, isExpression), + return setTextRange( + createAssignment( + getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), + visitNode(node.initializer, visitor, isExpression) + ), /*location*/ node ); } @@ -2418,11 +2447,11 @@ namespace ts { ), /*typeArguments*/ undefined, [moduleArg] - ), - /*location*/ node + ) ); setOriginalNode(enumStatement, node); + setTextRange(enumStatement, node); setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); @@ -2448,8 +2477,7 @@ namespace ts { currentNamespaceContainerName = savedCurrentNamespaceLocalName; return createBlock( - createNodeArray(statements, /*location*/ node.members), - /*location*/ undefined, + setTextRange(createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true ); } @@ -2464,22 +2492,26 @@ namespace ts { // we pass false as 'generateNameForComputedPropertyName' for a backward compatibility purposes // old emitter always generate 'expression' part of the name as-is. const name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); - return createStatement( - createAssignment( - createElementAccess( - currentNamespaceContainerName, + return setTextRange( + createStatement( + setTextRange( createAssignment( createElementAccess( currentNamespaceContainerName, - name + createAssignment( + createElementAccess( + currentNamespaceContainerName, + name + ), + transformEnumMemberDeclarationValue(member) + ) ), - transformEnumMemberDeclarationValue(member) - ) - ), - name, - /*location*/ member + name + ), + member + ) ), - /*location*/ member + member ); } @@ -2538,8 +2570,8 @@ namespace ts { currentScopeFirstDeclarationsOfName = createMap(); } - if (!(name in currentScopeFirstDeclarationsOfName)) { - currentScopeFirstDeclarationsOfName[name] = node; + if (!currentScopeFirstDeclarationsOfName.has(name)) { + currentScopeFirstDeclarationsOfName.set(name, node); } } } @@ -2552,7 +2584,7 @@ namespace ts { if (currentScopeFirstDeclarationsOfName) { const name = node.symbol && node.symbol.name; if (name) { - return currentScopeFirstDeclarationsOfName[name] === node; + return currentScopeFirstDeclarationsOfName.get(name) === node; } } @@ -2697,11 +2729,11 @@ namespace ts { ), /*typeArguments*/ undefined, [moduleArg] - ), - /*location*/ node + ) ); setOriginalNode(moduleStatement, node); + setTextRange(moduleStatement, node); setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); @@ -2756,13 +2788,13 @@ namespace ts { currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; const block = createBlock( - createNodeArray( - statements, + setTextRange( + createNodeArray(statements), /*location*/ statementsLocation ), - /*location*/ blockLocation, /*multiLine*/ true ); + setTextRange(block, blockLocation); // namespace hello.hi.world { // function foo() {} @@ -2810,7 +2842,7 @@ namespace ts { } // Elide the declaration if the import clause was elided. - const importClause = visitNode(node.importClause, visitImportClause, isImportClause, /*optional*/ true); + const importClause = visitNode(node.importClause, visitImportClause, isImportClause); return importClause ? updateImportDeclaration( node, @@ -2829,7 +2861,7 @@ namespace ts { function visitImportClause(node: ImportClause): VisitResult { // Elide the import clause if we elide both its name and its named bindings. const name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; - const namedBindings = visitNode(node.namedBindings, visitNamedImportBindings, isNamedImportBindings, /*optional*/ true); + const namedBindings = visitNode(node.namedBindings, visitNamedImportBindings, isNamedImportBindings); return (name || namedBindings) ? updateImportClause(node, name, namedBindings) : undefined; } @@ -2891,7 +2923,7 @@ namespace ts { } // Elide the export declaration if all of its named exports are elided. - const exportClause = visitNode(node.exportClause, visitNamedExports, isNamedExports, /*optional*/ true); + const exportClause = visitNode(node.exportClause, visitNamedExports, isNamedExports); return exportClause ? updateExportDeclaration( node, @@ -2962,18 +2994,20 @@ namespace ts { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; return setOriginalNode( - createVariableStatement( - visitNodes(node.modifiers, modifierVisitor, isModifier), - createVariableDeclarationList([ - setOriginalNode( - createVariableDeclaration( - node.name, - /*type*/ undefined, - moduleReference - ), - node - ) - ]), + setTextRange( + createVariableStatement( + visitNodes(node.modifiers, modifierVisitor, isModifier), + createVariableDeclarationList([ + setOriginalNode( + createVariableDeclaration( + node.name, + /*type*/ undefined, + moduleReference + ), + node + ) + ]) + ), node ), node @@ -3034,7 +3068,7 @@ namespace ts { * Creates a statement for the provided expression. This is used in calls to `map`. */ function expressionToStatement(expression: Expression) { - return createStatement(expression, /*location*/ undefined); + return createStatement(expression); } function addExportMemberAssignment(statements: Statement[], node: ClassDeclaration | FunctionDeclaration) { @@ -3050,17 +3084,19 @@ namespace ts { } function createNamespaceExport(exportName: Identifier, exportValue: Expression, location?: TextRange) { - return createStatement( - createAssignment( - getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), - exportValue + return setTextRange( + createStatement( + createAssignment( + getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), + exportValue + ) ), location ); } function createNamespaceExportExpression(exportName: Identifier, exportValue: Expression, location?: TextRange) { - return createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue, location); + return setTextRange(createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); } function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name: Identifier) { @@ -3092,7 +3128,7 @@ namespace ts { function getClassAliasIfNeeded(node: ClassDeclaration) { if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.ClassWithConstructorReference) { enableSubstitutionForClassAliases(); - const classAlias = createUniqueName(node.name && !isGeneratedIdentifier(node.name) ? node.name.text : "default"); + const classAlias = createUniqueName(node.name && !isGeneratedIdentifier(node.name) ? unescapeIdentifier(node.name.text) : "default"); classAliases[getOriginalNodeId(node)] = classAlias; hoistVariableDeclaration(classAlias); return classAlias; @@ -3125,7 +3161,7 @@ namespace ts { context.enableSubstitution(SyntaxKind.Identifier); // Keep track of class aliases. - classAliases = createMap(); + classAliases = []; } } @@ -3154,12 +3190,17 @@ namespace ts { /** * Hook for node emit. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ - function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void { + function onEmitNode(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void { const savedApplicableSubstitutions = applicableSubstitutions; + const savedCurrentSourceFile = currentSourceFile; + + if (isSourceFile(node)) { + currentSourceFile = node; + } if (enabledSubstitutions & TypeScriptSubstitutionFlags.NamespaceExports && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= TypeScriptSubstitutionFlags.NamespaceExports; @@ -3169,20 +3210,21 @@ namespace ts { applicableSubstitutions |= TypeScriptSubstitutionFlags.NonQualifiedEnumMembers; } - previousOnEmitNode(emitContext, node, emitCallback); + previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; + currentSourceFile = savedCurrentSourceFile; } /** * Hooks node substitutions. * - * @param emitContext A context hint for the emitter. + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. */ - function onSubstituteNode(emitContext: EmitContext, node: Node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === EmitContext.Expression) { + function onSubstituteNode(hint: EmitHint, node: Node) { + node = previousOnSubstituteNode(hint, node); + if (hint === EmitHint.Expression) { return substituteExpression(node); } else if (isShorthandPropertyAssignment(node)) { @@ -3201,9 +3243,9 @@ namespace ts { // destructuring assignment if (node.objectAssignmentInitializer) { const initializer = createAssignment(exportedName, node.objectAssignmentInitializer); - return createPropertyAssignment(name, initializer, /*location*/ node); + return setTextRange(createPropertyAssignment(name, initializer), node); } - return createPropertyAssignment(name, exportedName, /*location*/ node); + return setTextRange(createPropertyAssignment(name, exportedName), node); } } return node; @@ -3263,7 +3305,10 @@ namespace ts { (applicableSubstitutions & TypeScriptSubstitutionFlags.NamespaceExports && container.kind === SyntaxKind.ModuleDeclaration) || (applicableSubstitutions & TypeScriptSubstitutionFlags.NonQualifiedEnumMembers && container.kind === SyntaxKind.EnumDeclaration); if (substitute) { - return createPropertyAccess(getGeneratedNameForNode(container), node, /*location*/ node); + return setTextRange( + createPropertyAccess(getGeneratedNameForNode(container), node), + /*location*/ node + ); } } } @@ -3282,17 +3327,18 @@ namespace ts { function substituteConstantValue(node: PropertyAccessExpression | ElementAccessExpression): LeftHandSideExpression { const constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { + // track the constant value on the node for the printer in needsDotDotForPropertyAccess + setConstantValue(node, constantValue); + const substitute = createLiteral(constantValue); - setSourceMapRange(substitute, node); - setCommentRange(substitute, node); if (!compilerOptions.removeComments) { const propertyName = isPropertyAccessExpression(node) ? declarationNameToString(node.name) : getTextOfNode(node.argumentExpression); - substitute.trailingComment = ` ${propertyName} `; + + addSyntheticTrailingComment(substitute, SyntaxKind.MultiLineCommentTrivia, ` ${propertyName} `); } - setConstantValue(node, constantValue); return substitute; } @@ -3310,51 +3356,28 @@ namespace ts { } } - const paramHelper: EmitHelper = { - name: "typescript:param", - scoped: false, - priority: 4, - text: ` - var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } - };` - }; + function createDecorateHelper(context: TransformationContext, decoratorExpressions: Expression[], target: Expression, memberName?: Expression, descriptor?: Expression, location?: TextRange) { + const argumentsArray: Expression[] = []; + argumentsArray.push(createArrayLiteral(decoratorExpressions, /*multiLine*/ true)); + argumentsArray.push(target); + if (memberName) { + argumentsArray.push(memberName); + if (descriptor) { + argumentsArray.push(descriptor); + } + } - function createParamHelper(context: TransformationContext, expression: Expression, parameterOffset: number, location?: TextRange) { - context.requestEmitHelper(paramHelper); - return createCall( - getHelperName("__param"), - /*typeArguments*/ undefined, - [ - createLiteral(parameterOffset), - expression - ], + context.requestEmitHelper(decorateHelper); + return setTextRange( + createCall( + getHelperName("__decorate"), + /*typeArguments*/ undefined, + argumentsArray + ), location ); } - const metadataHelper: EmitHelper = { - name: "typescript:metadata", - scoped: false, - priority: 3, - text: ` - var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); - };` - }; - - function createMetadataHelper(context: TransformationContext, metadataKey: string, metadataValue: Expression) { - context.requestEmitHelper(metadataHelper); - return createCall( - getHelperName("__metadata"), - /*typeArguments*/ undefined, - [ - createLiteral(metadataKey), - metadataValue - ] - ); - } - const decorateHelper: EmitHelper = { name: "typescript:decorate", scoped: false, @@ -3368,18 +3391,50 @@ namespace ts { };` }; - function createDecorateHelper(context: TransformationContext, decoratorExpressions: Expression[], target: Expression, memberName?: Expression, descriptor?: Expression, location?: TextRange) { - context.requestEmitHelper(decorateHelper); - const argumentsArray: Expression[] = []; - argumentsArray.push(createArrayLiteral(decoratorExpressions, /*location*/ undefined, /*multiLine*/ true)); - argumentsArray.push(target); - if (memberName) { - argumentsArray.push(memberName); - if (descriptor) { - argumentsArray.push(descriptor); - } - } - - return createCall(getHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray, location); + function createMetadataHelper(context: TransformationContext, metadataKey: string, metadataValue: Expression) { + context.requestEmitHelper(metadataHelper); + return createCall( + getHelperName("__metadata"), + /*typeArguments*/ undefined, + [ + createLiteral(metadataKey), + metadataValue + ] + ); } + + const metadataHelper: EmitHelper = { + name: "typescript:metadata", + scoped: false, + priority: 3, + text: ` + var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); + };` + }; + + function createParamHelper(context: TransformationContext, expression: Expression, parameterOffset: number, location?: TextRange) { + context.requestEmitHelper(paramHelper); + return setTextRange( + createCall( + getHelperName("__param"), + /*typeArguments*/ undefined, + [ + createLiteral(parameterOffset), + expression + ] + ), + location + ); + } + + const paramHelper: EmitHelper = { + name: "typescript:param", + scoped: false, + priority: 4, + text: ` + var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } + };` + }; } diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index a7304eebe4b..b1ffcff43a4 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { @@ -67,11 +67,13 @@ namespace ts { const gutterSeparator = " "; const resetEscapeSequence = "\u001b[0m"; const ellipsis = "..."; - const categoryFormatMap = createMap({ - [DiagnosticCategory.Warning]: yellowForegroundEscapeSequence, - [DiagnosticCategory.Error]: redForegroundEscapeSequence, - [DiagnosticCategory.Message]: blueForegroundEscapeSequence, - }); + function getCategoryFormat(category: DiagnosticCategory): string { + switch (category) { + case DiagnosticCategory.Warning: return yellowForegroundEscapeSequence; + case DiagnosticCategory.Error: return redForegroundEscapeSequence; + case DiagnosticCategory.Message: return blueForegroundEscapeSequence; + } + } function formatAndReset(text: string, formatStyle: string) { return formatStyle + text + resetEscapeSequence; @@ -139,7 +141,7 @@ namespace ts { output += `${ relativeFileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `; } - const categoryColor = categoryFormatMap[diagnostic.category]; + const categoryColor = getCategoryFormat(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; @@ -155,7 +157,7 @@ namespace ts { output += `${ diagnostic.file.fileName }(${ loc.line + 1 },${ loc.character + 1 }): `; } - output += `${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`; + output += `${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine + sys.newLine + sys.newLine }`; sys.write(output); } @@ -378,9 +380,11 @@ namespace ts { } function cachedFileExists(fileName: string): boolean { - return fileName in cachedExistingFiles - ? cachedExistingFiles[fileName] - : cachedExistingFiles[fileName] = hostFileExists(fileName); + let fileExists = cachedExistingFiles.get(fileName); + if (fileExists === undefined) { + cachedExistingFiles.set(fileName, fileExists = hostFileExists(fileName)); + } + return fileExists; } function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void) { @@ -674,13 +678,9 @@ namespace ts { if (option.name === "lib") { description = getDiagnosticText(option.description); - const options: string[] = []; const element = (option).element; const typeMap = >element.type; - for (const key in typeMap) { - options.push(`'${key}'`); - } - optionsDescriptionMap[description] = options; + optionsDescriptionMap.set(description, arrayFrom(typeMap.keys()).map(key => `'${key}'`)); } else { description = getDiagnosticText(option.description); @@ -702,7 +702,7 @@ namespace ts { for (let i = 0; i < usageColumn.length; i++) { const usage = usageColumn[i]; const description = descriptionColumn[i]; - const kindsList = optionsDescriptionMap[description]; + const kindsList = optionsDescriptionMap.get(description); output.push(usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine); if (kindsList) { diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index cbbdbb04d50..52bb92ee1f0 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -1,18 +1,9 @@ { + "extends": "../tsconfig-base", "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": true, "removeComments": true, - "preserveConstEnums": true, - "pretty": true, "outFile": "../../built/local/tsc.js", - "sourceMap": true, - "declaration": true, - "stripInternal": true, - "target": "es5", - "noUnusedLocals": true, - "noUnusedParameters": true, - "types": [ ] + "declaration": true }, "files": [ "core.ts", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 26045ba1688..8ac6951dc14 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1,11 +1,30 @@ -namespace ts { - +namespace ts { + /** + * Type of objects whose values are all of the same type. + * The `in` and `for-in` operators can *not* be safely used, + * since `Object.prototype` may be modified by outside code. + */ export interface MapLike { [index: string]: T; } - export interface Map extends MapLike { - __mapBrand: any; + /** ES6 Map interface. */ + export interface Map { + get(key: string): T; + has(key: string): boolean; + set(key: string, value: T): this; + delete(key: string): boolean; + clear(): void; + forEach(action: (value: T, key: string) => void): void; + readonly size: number; + keys(): Iterator; + values(): Iterator; + entries(): Iterator<[string, T]>; + } + + /** ES6 Iterator type. */ + export interface Iterator { + next(): { value: T, done: false } | { value: never, done: true }; } // branded string type used to store absolute, normalized and canonicalized paths @@ -175,6 +194,7 @@ namespace ts { ReadonlyKeyword, RequireKeyword, NumberKeyword, + ObjectKeyword, SetKeyword, StringKeyword, SymbolKeyword, @@ -310,6 +330,7 @@ namespace ts { JsxOpeningElement, JsxClosingElement, JsxAttribute, + JsxAttributes, JsxSpreadAttribute, JsxExpression, @@ -328,6 +349,7 @@ namespace ts { EnumMember, // Top-level nodes SourceFile, + Bundle, // JSDoc nodes JSDocTypeExpression, @@ -401,7 +423,7 @@ namespace ts { LastBinaryOperator = CaretEqualsToken, FirstNode = QualifiedName, FirstJSDocNode = JSDocTypeExpression, - LastJSDocNode = JSDocLiteralType, + LastJSDocNode = JSDocNeverKeyword, FirstJSDocTagNode = JSDocComment, LastJSDocTagNode = JSDocNeverKeyword } @@ -520,6 +542,7 @@ namespace ts { export type EndOfFileToken = Token; export type AtToken = Token; export type ReadonlyToken = Token; + export type AwaitKeywordToken = Token; export type Modifier = Token @@ -603,6 +626,7 @@ namespace ts { kind: SyntaxKind.TypeParameter; name: Identifier; constraint?: TypeNode; + default?: TypeNode; // For error recovery purposes. expression?: Expression; @@ -676,7 +700,13 @@ namespace ts { name?: PropertyName; } - export type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | MethodDeclaration | AccessorDeclaration | SpreadAssignment; + export type ObjectLiteralElementLike + = PropertyAssignment + | ShorthandPropertyAssignment + | SpreadAssignment + | MethodDeclaration + | AccessorDeclaration + ; export interface PropertyAssignment extends ObjectLiteralElement { kind: SyntaxKind.PropertyAssignment; @@ -705,6 +735,7 @@ namespace ts { // SyntaxKind.BindingElement // SyntaxKind.Property // SyntaxKind.PropertyAssignment + // SyntaxKind.JsxAttribute // SyntaxKind.ShorthandPropertyAssignment // SyntaxKind.EnumMember // SyntaxKind.JSDocPropertyTag @@ -816,6 +847,7 @@ namespace ts { export interface KeywordTypeNode extends TypeNode { kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword + | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword @@ -936,8 +968,7 @@ namespace ts { } // Represents an expression that is elided as part of a transformation to emit comments on a - // not-emitted node. The 'expression' property of a NotEmittedExpression should be emitted. - // @internal + // not-emitted node. The 'expression' property of a PartiallyEmittedExpression should be emitted. export interface PartiallyEmittedExpression extends LeftHandSideExpression { kind: SyntaxKind.PartiallyEmittedExpression; expression: Expression; @@ -1292,7 +1323,6 @@ namespace ts { export interface NumericLiteral extends LiteralExpression { kind: SyntaxKind.NumericLiteral; - trailingComment?: string; } export interface TemplateHead extends LiteralLikeNode { @@ -1423,7 +1453,7 @@ namespace ts { template: TemplateLiteral; } - export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; + export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; export interface AsExpression extends Expression { kind: SyntaxKind.AsExpression; @@ -1460,35 +1490,38 @@ namespace ts { closingElement: JsxClosingElement; } + /// Either the opening tag in a ... pair, or the lone in a self-closing form + export type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + + export type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; + export type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; + export interface JsxAttributes extends ObjectLiteralExpressionBase { + } + /// The opening element of a ... JsxElement export interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; tagName: JsxTagNameExpression; - attributes: NodeArray; + attributes: JsxAttributes; } /// A JSX expression of the form export interface JsxSelfClosingElement extends PrimaryExpression { kind: SyntaxKind.JsxSelfClosingElement; tagName: JsxTagNameExpression; - attributes: NodeArray; + attributes: JsxAttributes; } - /// Either the opening tag in a ... pair, or the lone in a self-closing form - export type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; - - export type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - - export interface JsxAttribute extends Node { + export interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; name: Identifier; /// JSX attribute initializers are optional; is sugar for initializer?: StringLiteral | JsxExpression; } - export interface JsxSpreadAttribute extends Node { + export interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; expression: Expression; } @@ -1516,7 +1549,6 @@ namespace ts { // Represents a statement that is elided as part of a transformation to emit comments on a // not-emitted node. - // @internal export interface NotEmittedStatement extends Statement { kind: SyntaxKind.NotEmittedStatement; } @@ -1550,7 +1582,7 @@ namespace ts { name?: Identifier; } - export type BlockLike = SourceFile | Block | ModuleBlock | CaseClause; + export type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; export interface Block extends Statement { kind: SyntaxKind.Block; @@ -1611,6 +1643,7 @@ namespace ts { export interface ForOfStatement extends IterationStatement { kind: SyntaxKind.ForOfStatement; + awaitModifier?: AwaitKeywordToken; initializer: ForInitializer; expression: Expression; } @@ -1751,24 +1784,28 @@ namespace ts { members: NodeArray; } - export type ModuleBody = ModuleBlock | ModuleDeclaration; - export type ModuleName = Identifier | StringLiteral; + export type ModuleBody = NamespaceBody | JSDocNamespaceBody; + export interface ModuleDeclaration extends DeclarationStatement { kind: SyntaxKind.ModuleDeclaration; name: Identifier | StringLiteral; - body?: ModuleBlock | NamespaceDeclaration | JSDocNamespaceDeclaration | Identifier; + body?: ModuleBody | JSDocNamespaceDeclaration | Identifier; } + export type NamespaceBody = ModuleBlock | NamespaceDeclaration; + export interface NamespaceDeclaration extends ModuleDeclaration { name: Identifier; - body: ModuleBlock | NamespaceDeclaration; + body: NamespaceBody; } + export type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; + export interface JSDocNamespaceDeclaration extends ModuleDeclaration { name: Identifier; - body: JSDocNamespaceDeclaration | Identifier; + body: JSDocNamespaceBody; } export interface ModuleBlock extends Node, Statement { @@ -1869,9 +1906,17 @@ namespace ts { fileName: string; } + export type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; + export interface CommentRange extends TextRange { hasTrailingNewLine?: boolean; - kind: SyntaxKind; + kind: CommentKind; + } + + export interface SynthesizedComment extends CommentRange { + text: string; + pos: -1; + end: -1; } // represents a top level: { type } expression in a JSDoc comment. @@ -2047,10 +2092,25 @@ namespace ts { ArrayMutation = 1 << 8, // Potential array mutation Referenced = 1 << 9, // Referenced as antecedent once Shared = 1 << 10, // Referenced as antecedent more than once + PreFinally = 1 << 11, // Injected edge that links pre-finally label and pre-try flow + AfterFinally = 1 << 12, // Injected edge that links post-finally flow with the rest of the graph Label = BranchLabel | LoopLabel, Condition = TrueCondition | FalseCondition } + export interface FlowLock { + locked?: boolean; + } + + export interface AfterFinallyFlow extends FlowNode, FlowLock { + antecedent: FlowNode; + } + + export interface PreFinallyFlow extends FlowNode { + antecedent: FlowNode; + lock: FlowLock; + } + export interface FlowNode { flags: FlowFlags; id?: number; // Node id used by flow type cache in checker @@ -2180,6 +2240,11 @@ namespace ts { /* @internal */ ambientModuleNames: string[]; } + export interface Bundle extends Node { + kind: SyntaxKind.Bundle; + sourceFiles: SourceFile[]; + } + export interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; getSourceFile(fileName: string): SourceFile; @@ -2236,7 +2301,7 @@ namespace ts { * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the JavaScript and declaration files. */ - emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean): EmitResult; + emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; @@ -2270,6 +2335,13 @@ namespace ts { /* @internal */ structureIsReused?: boolean; } + export interface CustomTransformers { + /** Custom transformers to evaluate before built-in transformations. */ + before?: TransformerFactory[]; + /** Custom transformers to evaluate after built-in transformations. */ + after?: TransformerFactory[]; + } + export interface SourceMapSpan { /** Line number in the .js file. */ emittedLine: number; @@ -2337,8 +2409,15 @@ namespace ts { getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; - getBaseTypes(type: InterfaceType): ObjectType[]; + getBaseTypes(type: InterfaceType): BaseType[]; + getBaseTypeOfLiteralType(type: Type): Type; + getWidenedType(type: Type): Type; getReturnTypeOfSignature(signature: Signature): Type; + /** + * Gets the type of a parameter at a given position in a signature. + * Returns `any` if the index is not valid. + */ + /* @internal */ getParameterType(signature: Signature, parameterIndex: number): Type; getNonNullableType(type: Type): Type; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; @@ -2368,8 +2447,10 @@ namespace ts { isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; + /** Unlike `getExportsOfModule`, this includes properties of an `export =` value. */ + /* @internal */ getExportsAndPropertiesOfModule(moduleSymbol: Symbol): Symbol[]; - getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; + getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; @@ -2423,6 +2504,7 @@ namespace ts { // with import statements it previously saw (but chose not to emit). trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; reportInaccessibleThisError(): void; + reportIllegalExtends(): void; } export const enum TypeFormatFlags { @@ -2438,7 +2520,8 @@ namespace ts { InFirstTypeArgument = 0x00000100, // Writing first type argument of the instantiated type InTypeAlias = 0x00000200, // Writing type in type alias declaration UseTypeAliasValue = 0x00000400, // Serialize the type instead of using type-alias. This is needed when we emit declaration file. - SuppressAnyReturnType = 0x00000800, // If the return type is any-like, don't offer a return type. + SuppressAnyReturnType = 0x00000800, // If the return type is any-like, don't offer a return type. + AddUndefined = 0x00001000, // Add undefined to types of initialized, non-optional parameters } export const enum SymbolFormatFlags { @@ -2543,6 +2626,7 @@ namespace ts { isDeclarationVisible(node: Declaration): boolean; collectLinkedAliases(node: Identifier): Node[]; isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; + isRequiredInitializedParameter(node: ParameterDeclaration): boolean; writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; @@ -2566,37 +2650,34 @@ namespace ts { export const enum SymbolFlags { None = 0, - FunctionScopedVariable = 0x00000001, // Variable (var) or parameter - BlockScopedVariable = 0x00000002, // A block-scoped variable (let or const) - Property = 0x00000004, // Property or enum member - EnumMember = 0x00000008, // Enum member - Function = 0x00000010, // Function - Class = 0x00000020, // Class - Interface = 0x00000040, // Interface - ConstEnum = 0x00000080, // Const enum - RegularEnum = 0x00000100, // Enum - ValueModule = 0x00000200, // Instantiated module - NamespaceModule = 0x00000400, // Uninstantiated module - TypeLiteral = 0x00000800, // Type Literal or mapped type - ObjectLiteral = 0x00001000, // Object Literal - Method = 0x00002000, // Method - Constructor = 0x00004000, // Constructor - GetAccessor = 0x00008000, // Get accessor - SetAccessor = 0x00010000, // Set accessor - Signature = 0x00020000, // Call, construct, or index signature - TypeParameter = 0x00040000, // Type parameter - TypeAlias = 0x00080000, // Type alias - ExportValue = 0x00100000, // Exported value marker (see comment in declareModuleMember in binder) - ExportType = 0x00200000, // Exported type marker (see comment in declareModuleMember in binder) - ExportNamespace = 0x00400000, // Exported namespace marker (see comment in declareModuleMember in binder) - Alias = 0x00800000, // An alias for another symbol (see comment in isAliasSymbolDeclaration in checker) - Instantiated = 0x01000000, // Instantiated symbol - Merged = 0x02000000, // Merged symbol (created during program binding) - Transient = 0x04000000, // Transient symbol (created during type check) - Prototype = 0x08000000, // Prototype property (no source representation) - SyntheticProperty = 0x10000000, // Property in union or intersection type - Optional = 0x20000000, // Optional property - ExportStar = 0x40000000, // Export * declaration + FunctionScopedVariable = 1 << 0, // Variable (var) or parameter + BlockScopedVariable = 1 << 1, // A block-scoped variable (let or const) + Property = 1 << 2, // Property or enum member + EnumMember = 1 << 3, // Enum member + Function = 1 << 4, // Function + Class = 1 << 5, // Class + Interface = 1 << 6, // Interface + ConstEnum = 1 << 7, // Const enum + RegularEnum = 1 << 8, // Enum + ValueModule = 1 << 9, // Instantiated module + NamespaceModule = 1 << 10, // Uninstantiated module + TypeLiteral = 1 << 11, // Type Literal or mapped type + ObjectLiteral = 1 << 12, // Object Literal + Method = 1 << 13, // Method + Constructor = 1 << 14, // Constructor + GetAccessor = 1 << 15, // Get accessor + SetAccessor = 1 << 16, // Set accessor + Signature = 1 << 17, // Call, construct, or index signature + TypeParameter = 1 << 18, // Type parameter + TypeAlias = 1 << 19, // Type alias + ExportValue = 1 << 20, // Exported value marker (see comment in declareModuleMember in binder) + ExportType = 1 << 21, // Exported type marker (see comment in declareModuleMember in binder) + ExportNamespace = 1 << 22, // Exported namespace marker (see comment in declareModuleMember in binder) + Alias = 1 << 23, // An alias for another symbol (see comment in isAliasSymbolDeclaration in checker) + Prototype = 1 << 24, // Prototype property (no source representation) + ExportStar = 1 << 25, // Export * declaration + Optional = 1 << 26, // Optional property + Transient = 1 << 27, // Transient symbol (created during type check) Enum = RegularEnum | ConstEnum, Variable = FunctionScopedVariable | BlockScopedVariable, @@ -2656,11 +2737,9 @@ namespace ts { name: string; // Name of symbol declarations?: Declaration[]; // Declarations associated with this symbol valueDeclaration?: Declaration; // First value declaration of the symbol - members?: SymbolTable; // Class, interface or literal instance members exports?: SymbolTable; // Module exports globalExports?: SymbolTable; // Conditional global UMD exports - /* @internal */ isReadonly?: boolean; // readonly? (set only for intersections and unions) /* @internal */ id?: number; // Unique id (used to look up SymbolLinks) /* @internal */ mergeId?: number; // Merge id (used to look up merged symbol) /* @internal */ parent?: Symbol; // Parent symbol @@ -2684,18 +2763,33 @@ namespace ts { containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property leftSpread?: Symbol; // Left source for synthetic spread property rightSpread?: Symbol; // Right source for synthetic spread property - hasNonUniformType?: boolean; // True if constituents have non-uniform types - isPartial?: boolean; // True if syntheric property of union type occurs in some but not all constituents + mappedTypeOrigin?: Symbol; // For a property on a mapped type, points back to the orignal 'T' from 'keyof T'. isDiscriminantProperty?: boolean; // True if discriminant synthetic property resolvedExports?: SymbolTable; // Resolved exports of module exportsChecked?: boolean; // True if exports of external module have been checked + typeParametersChecked?: boolean; // True if type parameters of merged class and interface declarations have been checked. isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration bindingElement?: BindingElement; // Binding element associated with property symbol exportsSomeValue?: boolean; // True if module exports some value (not just types) } /* @internal */ - export interface TransientSymbol extends Symbol, SymbolLinks { } + export const enum CheckFlags { + Instantiated = 1 << 0, // Instantiated symbol + SyntheticProperty = 1 << 1, // Property in union or intersection type + Readonly = 1 << 2, // Readonly transient symbol + Partial = 1 << 3, // Synthetic property present in some but not all constituents + HasNonUniformType = 1 << 4, // Synthetic property with non-uniform type in constituents + ContainsPublic = 1 << 5, // Synthetic property with public constituent(s) + ContainsProtected = 1 << 6, // Synthetic property with protected constituent(s) + ContainsPrivate = 1 << 7, // Synthetic property with private constituent(s) + ContainsStatic = 1 << 8, // Synthetic property with static constituent(s) + } + + /* @internal */ + export interface TransientSymbol extends Symbol, SymbolLinks { + checkFlags: CheckFlags; + } export type SymbolTable = Map; @@ -2750,7 +2844,7 @@ namespace ts { isVisible?: boolean; // Is this node visible hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context jsxFlags?: JsxFlags; // flags for knowing what kind of element/attributes we're dealing with - resolvedJsxType?: Type; // resolved element attributes type of a JSX openinglike element + resolvedJsxElementAttributesType?: Type; // resolved element attributes type of a JSX openinglike element hasSuperCall?: boolean; // recorded result when we try to find super-call. We only try to find one if this flag is undefined, indicating that we haven't made an attempt. superCall?: ExpressionStatement; // Cached first super-call found in the constructor. Used in checking whether super is called before this-accessing switchTypes?: Type[]; // Cached array of switch case expression types @@ -2785,6 +2879,9 @@ namespace ts { ContainsObjectLiteral = 1 << 22, // Type is or contains object literal type /* @internal */ ContainsAnyFunctionType = 1 << 23, // Type is or contains object literal type + NonPrimitive = 1 << 24, // intrinsic object type + /* @internal */ + JsxAttributes = 1 << 25, // Jsx attributes type /* @internal */ Nullable = Undefined | Null, @@ -2794,7 +2891,7 @@ namespace ts { DefinitelyFalsy = StringLiteral | NumberLiteral | BooleanLiteral | Void | Undefined | Null, PossiblyFalsy = DefinitelyFalsy | String | Number | Boolean, /* @internal */ - Intrinsic = Any | String | Number | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never, + Intrinsic = Any | String | Number | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never | NonPrimitive, /* @internal */ Primitive = String | Number | Boolean | Enum | ESSymbol | Void | Undefined | Null | Literal, StringLike = String | StringLiteral | Index, @@ -2803,13 +2900,13 @@ namespace ts { EnumLike = Enum | EnumLiteral, UnionOrIntersection = Union | Intersection, StructuredType = Object | Union | Intersection, - StructuredOrTypeParameter = StructuredType | TypeParameter | Index, + StructuredOrTypeVariable = StructuredType | TypeParameter | Index | IndexedAccess, TypeVariable = TypeParameter | IndexedAccess, // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol, - NotUnionOrUnit = Any | ESSymbol | Object, + Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol | NonPrimitive, + NotUnionOrUnit = Any | ESSymbol | Object | NonPrimitive, /* @internal */ RequiresWidening = ContainsWideningType | ContainsObjectLiteral, /* @internal */ @@ -2844,7 +2941,7 @@ namespace ts { // Enum types (TypeFlags.Enum) export interface EnumType extends Type { - memberTypes: Map; + memberTypes: EnumLiteralType[]; } // Enum types (TypeFlags.EnumLiteral) @@ -2863,6 +2960,7 @@ namespace ts { ObjectLiteral = 1 << 7, // Originates in an object literal EvolvingArray = 1 << 8, // Evolving array type ObjectLiteralPatternWithComputedProperties = 1 << 9, // Object literal pattern with computed properties + NonPrimitive = 1 << 10, // NonPrimitive object type ClassOrInterface = Class | Interface } @@ -2880,9 +2978,12 @@ namespace ts { /* @internal */ resolvedBaseConstructorType?: Type; // Resolved base constructor type of class /* @internal */ - resolvedBaseTypes: ObjectType[]; // Resolved base types + resolvedBaseTypes: BaseType[]; // Resolved base types } + // Object type or intersection of object types + export type BaseType = ObjectType | IntersectionType; + export interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; // Declared members declaredCallSignatures: Signature[]; // Declared call signatures @@ -2915,16 +3016,23 @@ namespace ts { export interface UnionOrIntersectionType extends Type { types: Type[]; // Constituent types /* @internal */ - resolvedProperties: SymbolTable; // Cache of resolved properties + propertyCache: SymbolTable; // Cache of resolved properties + /* @internal */ + resolvedProperties: Symbol[]; /* @internal */ resolvedIndexType: IndexType; /* @internal */ + resolvedBaseConstraint: Type; + /* @internal */ couldContainTypeVariables: boolean; } export interface UnionType extends UnionOrIntersectionType { } - export interface IntersectionType extends UnionOrIntersectionType { } + export interface IntersectionType extends UnionOrIntersectionType { + /* @internal */ + resolvedApparentType: Type; + } export type StructuredType = ObjectType | UnionType | IntersectionType; @@ -2963,7 +3071,7 @@ namespace ts { /* @internal */ // Object literals are initially marked fresh. Freshness disappears following an assignment, - // before a type assertion, or when when an object literal's type is widened. The regular + // before a type assertion, or when an object literal's type is widened. The regular // version of a fresh type is identical except for the TypeFlags.FreshObjectLiteral flag. export interface FreshObjectLiteralType extends ResolvedType { regularType: ResolvedType; // Regular version of fresh type @@ -2972,13 +3080,22 @@ namespace ts { // Just a place to cache element types of iterables and iterators /* @internal */ export interface IterableOrIteratorType extends ObjectType, UnionType { - iterableElementType?: Type; - iteratorElementType?: Type; + iteratedTypeOfIterable?: Type; + iteratedTypeOfIterator?: Type; + iteratedTypeOfAsyncIterable?: Type; + iteratedTypeOfAsyncIterator?: Type; + } + + /* @internal */ + export interface PromiseOrAwaitableType extends ObjectType, UnionType { + promiseTypeOfPromiseConstructor?: Type; + promisedTypeOfPromise?: Type; + awaitedTypeOfType?: Type; } export interface TypeVariable extends Type { /* @internal */ - resolvedApparentType: Type; + resolvedBaseConstraint: Type; /* @internal */ resolvedIndexType: IndexType; } @@ -2986,12 +3103,15 @@ namespace ts { // Type parameters (TypeFlags.TypeParameter) export interface TypeParameter extends TypeVariable { constraint: Type; // Constraint + default?: Type; /* @internal */ target?: TypeParameter; // Instantiation target /* @internal */ mapper?: TypeMapper; // Instantiation mapper /* @internal */ isThisType?: boolean; + /* @internal */ + resolvedDefaultType?: Type; } // Indexed access types (TypeFlags.IndexedAccess) @@ -3093,12 +3213,13 @@ namespace ts { /// className.prototype.name = expr PrototypeProperty, /// this.name = expr - ThisProperty + ThisProperty, + // F.name = expr + Property } - export interface FileExtensionInfo { + export interface JsFileExtensionInfo { extension: string; - scriptKind: ScriptKind; isMixedContent: boolean; } @@ -3142,7 +3263,11 @@ namespace ts { NodeJs = 2 } - export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; + export interface PluginImport { + name: string + } + + export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[]; export interface CompilerOptions { allowJs?: boolean; @@ -3159,6 +3284,7 @@ namespace ts { /* @internal */ diagnostics?: boolean; /* @internal */ extendedDiagnostics?: boolean; disableSizeLimit?: boolean; + downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; experimentalDecorators?: boolean; @@ -3197,6 +3323,7 @@ namespace ts { outDir?: string; outFile?: string; paths?: MapLike; + /*@internal*/ plugins?: PluginImport[]; preserveConstEnums?: boolean; project?: string; /* @internal */ pretty?: DiagnosticStyle; @@ -3258,7 +3385,8 @@ namespace ts { export const enum JsxEmit { None = 0, Preserve = 1, - React = 2 + React = 2, + ReactNative = 3 } export const enum NewLineKind { @@ -3279,7 +3407,8 @@ namespace ts { JS = 1, JSX = 2, TS = 3, - TSX = 4 + TSX = 4, + External = 5 } export const enum ScriptTarget { @@ -3354,7 +3483,7 @@ namespace ts { /* @internal */ export interface CommandLineOptionOfListType extends CommandLineOptionBase { type: "list"; - element: CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType; + element: CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType | TsConfigOnlyOption; } /* @internal */ @@ -3674,15 +3803,16 @@ namespace ts { export interface EmitNode { annotatedNodes?: Node[]; // Tracks Parse-tree nodes with EmitNodes for eventual cleanup. flags?: EmitFlags; // Flags that customize emit + leadingComments?: SynthesizedComment[]; // Synthesized leading comments + trailingComments?: SynthesizedComment[]; // Synthesized trailing comments commentRange?: TextRange; // The text range to use when emitting leading or trailing comments sourceMapRange?: TextRange; // The text range to use when emitting leading or trailing source mappings - tokenSourceMapRanges?: Map; // The text range to use when emitting source mappings for tokens + tokenSourceMapRanges?: TextRange[]; // The text range to use when emitting source mappings for tokens constantValue?: number; // The constant value of an expression externalHelpersModuleName?: Identifier; // The local name for an imported helpers module helpers?: EmitHelper[]; // Emit helpers for the node } - /* @internal */ export const enum EmitFlags { SingleLine = 1 << 0, // The contents of this node should be emitted on a single line. AdviseOnEmitNode = 1 << 1, // The printer should invoke the onEmitNode callback when printing this node. @@ -3711,10 +3841,9 @@ namespace ts { HasEndOfDeclarationMarker = 1 << 21, // Declaration has an associated NotEmittedStatement to mark the end of the declaration } - /* @internal */ export interface EmitHelper { readonly name: string; // A unique name for this helper. - readonly scoped: boolean; // Indicates whether ther helper MUST be emitted in the current scope. + readonly scoped: boolean; // Indicates whether the helper MUST be emitted in the current scope. readonly text: string; // ES3-compatible raw script text. readonly priority?: number; // Helpers with a higher priority are emitted earlier than other helpers on the node. } @@ -3733,14 +3862,28 @@ namespace ts { Param = 1 << 5, // __param (used by TypeScript decorators transformation) Awaiter = 1 << 6, // __awaiter (used by ES2017 async functions transformation) Generator = 1 << 7, // __generator (used by ES2015 generator transformation) - ExportStar = 1 << 8, // __exportStar (used by CommonJS/AMD/UMD module transformation) + Values = 1 << 8, // __values (used by ES2015 for..of and yield* transformations) + Read = 1 << 9, // __read (used by ES2015 iterator destructuring transformation) + Spread = 1 << 10, // __spread (used by ES2015 array spread and argument list spread transformations) + AsyncGenerator = 1 << 11, // __asyncGenerator (used by ES2017 async generator transformation) + AsyncDelegator = 1 << 12, // __asyncDelegator (used by ES2017 async generator yield* transformation) + AsyncValues = 1 << 13, // __asyncValues (used by ES2017 for..await..of transformation) + ExportStar = 1 << 14, // __exportStar (used by CommonJS/AMD/UMD module transformation) + + // Helpers included by ES2015 for..of + ForOfIncludes = Values, + + // Helpers included by ES2017 for..await..of + ForAwaitOfIncludes = AsyncValues, + + // Helpers included by ES2015 spread + SpreadIncludes = Read | Spread, FirstEmitHelper = Extends, LastEmitHelper = ExportStar } - /* @internal */ - export const enum EmitContext { + export const enum EmitHint { SourceFile, // Emitting a SourceFile Expression, // Emitting an Expression IdentifierName, // Emitting an IdentifierName @@ -3763,11 +3906,12 @@ namespace ts { writeFile: WriteFileCallback; } - /* @internal */ export interface TransformationContext { + /*@internal*/ getEmitResolver(): EmitResolver; + /*@internal*/ getEmitHost(): EmitHost; + + /** Gets the compiler options supplied to the transformer. */ getCompilerOptions(): CompilerOptions; - getEmitResolver(): EmitResolver; - getEmitHost(): EmitHost; /** Starts a new lexical environment. */ startLexicalEnvironment(): void; @@ -3781,41 +3925,32 @@ namespace ts { /** Ends a lexical environment, returning any declarations. */ endLexicalEnvironment(): Statement[]; - /** - * Hoists a function declaration to the containing scope. - */ + /** Hoists a function declaration to the containing scope. */ hoistFunctionDeclaration(node: FunctionDeclaration): void; - /** - * Hoists a variable declaration to the containing scope. - */ + /** Hoists a variable declaration to the containing scope. */ hoistVariableDeclaration(node: Identifier): void; - /** - * Records a request for a non-scoped emit helper in the current context. - */ + /** Records a request for a non-scoped emit helper in the current context. */ requestEmitHelper(helper: EmitHelper): void; - /** - * Gets and resets the requested non-scoped emit helpers. - */ + /** Gets and resets the requested non-scoped emit helpers. */ readEmitHelpers(): EmitHelper[] | undefined; - /** - * Enables expression substitutions in the pretty printer for the provided SyntaxKind. - */ + /** Enables expression substitutions in the pretty printer for the provided SyntaxKind. */ enableSubstitution(kind: SyntaxKind): void; - /** - * Determines whether expression substitutions are enabled for the provided node. - */ + /** Determines whether expression substitutions are enabled for the provided node. */ isSubstitutionEnabled(node: Node): boolean; /** * Hook used by transformers to substitute expressions just before they * are emitted by the pretty printer. + * + * NOTE: Transformation hooks should only be modified during `Transformer` initialization, + * before returning the `NodeTransformer` callback. */ - onSubstituteNode?: (emitContext: EmitContext, node: Node) => Node; + onSubstituteNode: (hint: EmitHint, node: Node) => Node; /** * Enables before/after emit notifications in the pretty printer for the provided @@ -3832,38 +3967,164 @@ namespace ts { /** * Hook used to allow transformers to capture state before or after * the printer emits a node. + * + * NOTE: Transformation hooks should only be modified during `Transformer` initialization, + * before returning the `NodeTransformer` callback. */ - onEmitNode?: (emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) => void; + onEmitNode: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void; } - /* @internal */ - export interface TransformationResult { - /** - * Gets the transformed source files. - */ - transformed: SourceFile[]; + export interface TransformationResult { + /** Gets the transformed source files. */ + transformed: T[]; + + /** Gets diagnostics for the transformation. */ + diagnostics?: Diagnostic[]; /** - * Emits the substitute for a node, if one is available; otherwise, emits the node. + * Gets a substitute for a node, if one is available; otherwise, returns the original node. * - * @param emitContext The current emit context. + * @param hint A hint as to the intended usage of the node. * @param node The node to substitute. - * @param emitCallback A callback used to emit the node or its substitute. */ - emitNodeWithSubstitution(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; + substituteNode(hint: EmitHint, node: Node): Node; /** * Emits a node with possible notification. * - * @param emitContext The current emit context. + * @param hint A hint as to the intended usage of the node. * @param node The node to emit. * @param emitCallback A callback used to emit the node. */ - emitNodeWithNotification(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; + emitNodeWithNotification(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + + /** + * Clean up EmitNode entries on any parse-tree nodes. + */ + dispose(): void; } - /* @internal */ - export type Transformer = (context: TransformationContext) => (node: SourceFile) => SourceFile; + /** + * A function that is used to initialize and return a `Transformer` callback, which in turn + * will be used to transform one or more nodes. + */ + export type TransformerFactory = (context: TransformationContext) => Transformer; + + /** + * A function that transforms a node. + */ + export type Transformer = (node: T) => T; + + /** + * A function that accepts and possible transforms a node. + */ + export type Visitor = (node: Node) => VisitResult; + + export type VisitResult = T | T[]; + + export interface Printer { + /** + * Print a node and its subtree as-is, without any emit transformations. + * @param hint A value indicating the purpose of a node. This is primarily used to + * distinguish between an `Identifier` used in an expression position, versus an + * `Identifier` used as an `IdentifierName` as part of a declaration. For most nodes you + * should just pass `Unspecified`. + * @param node The node to print. The node and its subtree are printed as-is, without any + * emit transformations. + * @param sourceFile A source file that provides context for the node. The source text of + * the file is used to emit the original source content for literals and identifiers, while + * the identifiers of the source file are used when generating unique names to avoid + * collisions. + */ + printNode(hint: EmitHint, node: Node, sourceFile: SourceFile): string; + /** + * Prints a source file as-is, without any emit transformations. + */ + printFile(sourceFile: SourceFile): string; + /** + * Prints a bundle of source files as-is, without any emit transformations. + */ + printBundle(bundle: Bundle): string; + /*@internal*/ writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile, writer: EmitTextWriter): void; + /*@internal*/ writeFile(sourceFile: SourceFile, writer: EmitTextWriter): void; + /*@internal*/ writeBundle(bundle: Bundle, writer: EmitTextWriter): void; + } + + export interface PrintHandlers { + /** + * A hook used by the Printer when generating unique names to avoid collisions with + * globally defined names that exist outside of the current source file. + */ + hasGlobalName?(name: string): boolean; + /** + * A hook used by the Printer to provide notifications prior to emitting a node. A + * compatible implementation **must** invoke `emitCallback` with the provided `hint` and + * `node` values. + * @param hint A hint indicating the intended purpose of the node. + * @param node The node to emit. + * @param emitCallback A callback that, when invoked, will emit the node. + * @example + * ```ts + * var printer = createPrinter(printerOptions, { + * onEmitNode(hint, node, emitCallback) { + * // set up or track state prior to emitting the node... + * emitCallback(hint, node); + * // restore state after emitting the node... + * } + * }); + * ``` + */ + onEmitNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + /** + * A hook used by the Printer to perform just-in-time substitution of a node. This is + * primarily used by node transformations that need to substitute one node for another, + * such as replacing `myExportedVar` with `exports.myExportedVar`. + * @param hint A hint indicating the intended purpose of the node. + * @param node The node to emit. + * @example + * ```ts + * var printer = createPrinter(printerOptions, { + * substituteNode(hint, node) { + * // perform substitution if necessary... + * return node; + * } + * }); + * ``` + */ + substituteNode?(hint: EmitHint, node: Node): Node; + /*@internal*/ onEmitSourceMapOfNode?: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void; + /*@internal*/ onEmitSourceMapOfToken?: (node: Node, token: SyntaxKind, pos: number, emitCallback: (token: SyntaxKind, pos: number) => number) => number; + /*@internal*/ onEmitSourceMapOfPosition?: (pos: number) => void; + /*@internal*/ onEmitHelpers?: (node: Node, writeLines: (text: string) => void) => void; + /*@internal*/ onSetSourceFile?: (node: SourceFile) => void; + } + + export interface PrinterOptions { + target?: ScriptTarget; + removeComments?: boolean; + newLine?: NewLineKind; + /*@internal*/ sourceMap?: boolean; + /*@internal*/ inlineSourceMap?: boolean; + /*@internal*/ extendedDiagnostics?: boolean; + } + + /*@internal*/ + export interface EmitTextWriter { + write(s: string): void; + writeTextOfNode(text: string, node: Node): void; + writeLine(): void; + increaseIndent(): void; + decreaseIndent(): void; + getText(): string; + rawWrite(s: string): void; + writeLiteral(s: string): void; + getTextPos(): number; + getLine(): number; + getColumn(): number; + getIndent(): number; + isAtStartOfLine(): boolean; + reset(): void; + } export interface TextSpan { start: number; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 192ef888b11..66bf693d831 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1,4 +1,4 @@ -/// +/// /* @internal */ namespace ts { @@ -24,6 +24,20 @@ namespace ts { return undefined; } + export function findDeclaration(symbol: Symbol, predicate: (node: Declaration) => node is T): T | undefined; + export function findDeclaration(symbol: Symbol, predicate: (node: Declaration) => boolean): Declaration | undefined; + export function findDeclaration(symbol: Symbol, predicate: (node: Declaration) => boolean): Declaration | undefined { + const declarations = symbol.declarations; + if (declarations) { + for (const declaration of declarations) { + if (predicate(declaration)) { + return declaration; + } + } + } + return undefined; + } + export interface StringSymbolWriter extends SymbolWriter { string(): string; } @@ -53,7 +67,8 @@ namespace ts { decreaseIndent: noop, clear: () => str = "", trackSymbol: noop, - reportInaccessibleThisError: noop + reportInaccessibleThisError: noop, + reportIllegalExtends: noop }; } @@ -70,11 +85,11 @@ namespace ts { } export function hasResolvedModule(sourceFile: SourceFile, moduleNameText: string): boolean { - return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); + return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText)); } export function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModuleFull { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules.get(moduleNameText) : undefined; } export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModuleFull): void { @@ -82,7 +97,7 @@ namespace ts { sourceFile.resolvedModules = createMap(); } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; + sourceFile.resolvedModules.set(moduleNameText, resolvedModule); } export function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeReferenceDirectiveName: string, resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective): void { @@ -90,7 +105,7 @@ namespace ts { sourceFile.resolvedTypeReferenceDirectiveNames = createMap(); } - sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; + sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective); } /* @internal */ @@ -112,7 +127,7 @@ namespace ts { } for (let i = 0; i < names.length; i++) { const newResolution = newResolutions[i]; - const oldResolution = oldResolutions && oldResolutions[names[i]]; + const oldResolution = oldResolutions && oldResolutions.get(names[i]); const changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) @@ -341,16 +356,52 @@ namespace ts { } export function isBinaryOrOctalIntegerLiteral(node: LiteralLikeNode, text: string) { - if (node.kind === SyntaxKind.NumericLiteral && text.length > 1) { + return node.kind === SyntaxKind.NumericLiteral + && (getNumericLiteralFlags(text, /*hint*/ NumericLiteralFlags.BinaryOrOctal) & NumericLiteralFlags.BinaryOrOctal) !== 0; + } + + export const enum NumericLiteralFlags { + None = 0, + Hexadecimal = 1 << 0, + Binary = 1 << 1, + Octal = 1 << 2, + Scientific = 1 << 3, + + BinaryOrOctal = Binary | Octal, + BinaryOrOctalOrHexadecimal = BinaryOrOctal | Hexadecimal, + All = Hexadecimal | Binary | Octal | Scientific, + } + + /** + * Scans a numeric literal string to determine the form of the number. + * @param text Numeric literal text + * @param hint If `Scientific` or `All` is specified, performs a more expensive check to scan for scientific notation. + */ + export function getNumericLiteralFlags(text: string, hint?: NumericLiteralFlags) { + if (text.length > 1) { switch (text.charCodeAt(1)) { case CharacterCodes.b: case CharacterCodes.B: + return NumericLiteralFlags.Binary; case CharacterCodes.o: case CharacterCodes.O: - return true; + return NumericLiteralFlags.Octal; + case CharacterCodes.x: + case CharacterCodes.X: + return NumericLiteralFlags.Hexadecimal; + } + + if (hint & NumericLiteralFlags.Scientific) { + for (let i = text.length - 1; i >= 0; i--) { + switch (text.charCodeAt(i)) { + case CharacterCodes.e: + case CharacterCodes.E: + return NumericLiteralFlags.Scientific; + } + } } } - return false; + return NumericLiteralFlags.None; } function getQuotedEscapedLiteralText(leftQuote: string, text: string, rightQuote: string) { @@ -362,11 +413,6 @@ namespace ts { return identifier.length >= 2 && identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._ ? "_" + identifier : identifier; } - // Remove extra underscore from escaped identifier - export function unescapeIdentifier(identifier: string): string { - return identifier.length >= 3 && identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._ && identifier.charCodeAt(2) === CharacterCodes._ ? identifier.substr(1) : identifier; - } - // Make an identifier from an external module name by extracting the string after the last "/" and replacing // all non-alphanumeric characters with underscores export function makeIdentifierFromModuleName(moduleName: string): string { @@ -395,7 +441,7 @@ namespace ts { function isShorthandAmbientModule(node: Node): boolean { // The only kind of module that can be missing a body is a shorthand ambient module. - return node.kind === SyntaxKind.ModuleDeclaration && (!(node).body); + return node && node.kind === SyntaxKind.ModuleDeclaration && (!(node).body); } export function isBlockScopedContainerTopLevel(node: Node): boolean { @@ -914,7 +960,7 @@ namespace ts { return false; } - export function unwrapInnermostStatmentOfLabel(node: LabeledStatement, beforeUnwrapLabelCallback?: (node: LabeledStatement) => void) { + export function unwrapInnermostStatementOfLabel(node: LabeledStatement, beforeUnwrapLabelCallback?: (node: LabeledStatement) => void) { while (true) { if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); @@ -1133,6 +1179,8 @@ namespace ts { export function isCallLikeExpression(node: Node): node is CallLikeExpression { switch (node.kind) { + case SyntaxKind.JsxOpeningElement: + case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: case SyntaxKind.TaggedTemplateExpression: @@ -1147,6 +1195,9 @@ namespace ts { if (node.kind === SyntaxKind.TaggedTemplateExpression) { return (node).tag; } + else if (isJsxOpeningLikeElement(node)) { + return node.tagName; + } // Will either be a CallExpression, NewExpression, or Decorator. return (node).expression; @@ -1366,10 +1417,10 @@ namespace ts { * Returns true if the node is a variable declaration whose initializer is a function expression. * This function does not test if the node is in a JavaScript file or not. */ - export function isDeclarationOfFunctionExpression(s: Symbol) { + export function isDeclarationOfFunctionOrClassExpression(s: Symbol) { if (s.valueDeclaration && s.valueDeclaration.kind === SyntaxKind.VariableDeclaration) { const declaration = s.valueDeclaration as VariableDeclaration; - return declaration.initializer && declaration.initializer.kind === SyntaxKind.FunctionExpression; + return declaration.initializer && (declaration.initializer.kind === SyntaxKind.FunctionExpression || declaration.initializer.kind === SyntaxKind.ClassExpression); } return false; } @@ -1398,6 +1449,10 @@ namespace ts { // module.exports = expr return SpecialPropertyAssignmentKind.ModuleExports; } + else { + // F.x = expr + return SpecialPropertyAssignmentKind.Property; + } } else if (lhs.expression.kind === SyntaxKind.ThisKeyword) { return SpecialPropertyAssignmentKind.ThisProperty; @@ -1417,6 +1472,7 @@ namespace ts { } } + return SpecialPropertyAssignmentKind.None; } @@ -1482,6 +1538,11 @@ namespace ts { return map(getJSDocs(node), doc => doc.comment); } + export function hasJSDocParameterTags(node: FunctionLikeDeclaration | SignatureDeclaration) { + const parameterTags = getJSDocTags(node, SyntaxKind.JSDocParameterTag); + return parameterTags && parameterTags.length > 0; + } + function getJSDocTags(node: Node, kind: SyntaxKind): JSDocTag[] { const docs = getJSDocs(node); if (docs) { @@ -1662,11 +1723,15 @@ namespace ts { node = parent; break; case SyntaxKind.ShorthandPropertyAssignment: - if ((parent).name !== node) { + if ((parent as ShorthandPropertyAssignment).name !== node) { return AssignmentKind.None; } - // Fall through + node = parent.parent; + break; case SyntaxKind.PropertyAssignment: + if ((parent as ShorthandPropertyAssignment).name === node) { + return AssignmentKind.None; + } node = parent.parent; break; default: @@ -1678,7 +1743,8 @@ namespace ts { // 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'. + // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ a }] = xxx'. + // (Note that `p` is not a target in the above examples, only `a`.) export function isAssignmentTarget(node: Node): boolean { return getAssignmentTargetKind(node) !== AssignmentKind.None; } @@ -1884,8 +1950,51 @@ namespace ts { return SyntaxKind.FirstTriviaToken <= token && token <= SyntaxKind.LastTriviaToken; } - export function isAsyncFunctionLike(node: Node): boolean { - return isFunctionLike(node) && hasModifier(node, ModifierFlags.Async) && !isAccessor(node); + export const enum FunctionFlags { + Normal = 0, + Generator = 1 << 0, + Async = 1 << 1, + AsyncOrAsyncGenerator = Async | Generator, + Invalid = 1 << 2, + InvalidAsyncOrAsyncGenerator = AsyncOrAsyncGenerator | Invalid, + InvalidGenerator = Generator | Invalid, + } + + export function getFunctionFlags(node: FunctionLikeDeclaration) { + let flags = FunctionFlags.Normal; + switch (node.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + case SyntaxKind.MethodDeclaration: + if (node.asteriskToken) { + flags |= FunctionFlags.Generator; + } + // fall through + case SyntaxKind.ArrowFunction: + if (hasModifier(node, ModifierFlags.Async)) { + flags |= FunctionFlags.Async; + } + break; + } + + if (!node.body) { + flags |= FunctionFlags.Invalid; + } + + return flags; + } + + export function isAsyncFunction(node: Node): boolean { + switch (node.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + case SyntaxKind.MethodDeclaration: + return (node).body !== undefined + && (node).asteriskToken === undefined + && hasModifier(node, ModifierFlags.Async); + } + return false; } export function isStringOrNumericLiteral(node: Node): node is StringLiteral | NumericLiteral { @@ -2001,67 +2110,19 @@ namespace ts { || positionIsSynthesized(node.end); } - export function getOriginalNode(node: Node): Node; - export function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; - export function getOriginalNode(node: Node, nodeTest?: (node: Node) => boolean): Node { - if (node) { - while (node.original !== undefined) { - node = node.original; - } + export function getOriginalSourceFileOrBundle(sourceFileOrBundle: SourceFile | Bundle) { + if (sourceFileOrBundle.kind === SyntaxKind.Bundle) { + return updateBundle(sourceFileOrBundle, sameMap(sourceFileOrBundle.sourceFiles, getOriginalSourceFile)); } - - return !nodeTest || nodeTest(node) ? node : undefined; + return getOriginalSourceFile(sourceFileOrBundle); } - /** - * Gets a value indicating whether a node originated in the parse tree. - * - * @param node The node to test. - */ - export function isParseTreeNode(node: Node): boolean { - return (node.flags & NodeFlags.Synthesized) === 0; - } - - /** - * Gets the original parse tree node for a node. - * - * @param node The original node. - * @returns The original parse tree node if found; otherwise, undefined. - */ - export function getParseTreeNode(node: Node): Node; - - /** - * Gets the original parse tree node for a node. - * - * @param node The original node. - * @param nodeTest A callback used to ensure the correct type of parse tree node is returned. - * @returns The original parse tree node if found; otherwise, undefined. - */ - export function getParseTreeNode(node: Node, nodeTest?: (node: Node) => node is T): T; - export function getParseTreeNode(node: Node, nodeTest?: (node: Node) => boolean): Node { - if (isParseTreeNode(node)) { - return node; - } - - node = getOriginalNode(node); - - if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { - return node; - } - - return undefined; + function getOriginalSourceFile(sourceFile: SourceFile) { + return getParseTreeNode(sourceFile, isSourceFile) || sourceFile; } export function getOriginalSourceFiles(sourceFiles: SourceFile[]) { - const originalSourceFiles: SourceFile[] = []; - for (const sourceFile of sourceFiles) { - const originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); - if (originalSourceFile) { - originalSourceFiles.push(originalSourceFile); - } - } - - return originalSourceFiles; + return sameMap(sourceFiles, getOriginalSourceFile); } export function getOriginalNodeId(node: Node) { @@ -2285,22 +2346,16 @@ namespace ts { } function reattachFileDiagnostics(newFile: SourceFile): void { - if (!hasProperty(fileDiagnostics, newFile.fileName)) { - return; - } - - for (const diagnostic of fileDiagnostics[newFile.fileName]) { - diagnostic.file = newFile; - } + forEach(fileDiagnostics.get(newFile.fileName), diagnostic => diagnostic.file = newFile); } function add(diagnostic: Diagnostic): void { let diagnostics: Diagnostic[]; if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); if (!diagnostics) { diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; + fileDiagnostics.set(diagnostic.file.fileName, diagnostics); } } else { @@ -2320,7 +2375,7 @@ namespace ts { function getDiagnostics(fileName?: string): Diagnostic[] { sortAndDeduplicate(); if (fileName) { - return fileDiagnostics[fileName] || []; + return fileDiagnostics.get(fileName) || []; } const allDiagnostics: Diagnostic[] = []; @@ -2330,9 +2385,9 @@ namespace ts { forEach(nonFileDiagnostics, pushDiagnostic); - for (const key in fileDiagnostics) { - forEach(fileDiagnostics[key], pushDiagnostic); - } + fileDiagnostics.forEach(diagnostics => { + forEach(diagnostics, pushDiagnostic); + }); return sortAndDeduplicateDiagnostics(allDiagnostics); } @@ -2345,9 +2400,9 @@ namespace ts { diagnosticsModified = false; nonFileDiagnostics = sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (const key in fileDiagnostics) { - fileDiagnostics[key] = sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } + fileDiagnostics.forEach((diagnostics, key) => { + fileDiagnostics.set(key, sortAndDeduplicateDiagnostics(diagnostics)); + }); } } @@ -2357,7 +2412,7 @@ namespace ts { // 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. const escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - const escapedCharsMap = createMap({ + const escapedCharsMap = createMapFromTemplate({ "\0": "\\0", "\t": "\\t", "\v": "\\v", @@ -2383,7 +2438,7 @@ namespace ts { } function getReplacement(c: string) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); } export function isIntrinsicJsxName(name: string) { @@ -2406,23 +2461,6 @@ namespace ts { s; } - export interface EmitTextWriter { - write(s: string): void; - writeTextOfNode(text: string, node: Node): void; - writeLine(): void; - increaseIndent(): void; - decreaseIndent(): void; - getText(): string; - rawWrite(s: string): void; - writeLiteral(s: string): void; - getTextPos(): number; - getLine(): number; - getColumn(): number; - getIndent(): number; - isAtStartOfLine(): boolean; - reset(): void; - } - const indentStrings: string[] = ["", " "]; export function getIndentString(level: number) { if (indentStrings[level] === undefined) { @@ -2574,102 +2612,57 @@ namespace ts { * @param host An EmitHost. * @param targetSourceFile An optional target source file to emit. */ - export function getSourceFilesToEmit(host: EmitHost, targetSourceFile?: SourceFile) { + export function getSourceFilesToEmit(host: EmitHost, targetSourceFile?: SourceFile): SourceFile[] { const options = host.getCompilerOptions(); + const isSourceFileFromExternalLibrary = (file: SourceFile) => host.isSourceFileFromExternalLibrary(file); if (options.outFile || options.out) { const moduleKind = getEmitModuleKind(options); const moduleEmitEnabled = moduleKind === ModuleKind.AMD || moduleKind === ModuleKind.System; - const sourceFiles = getAllEmittableSourceFiles(); // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified - return filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); + return filter(host.getSourceFiles(), sourceFile => + (moduleEmitEnabled || !isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary)); } else { - const sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; - return filterSourceFilesInDirectory(sourceFiles, file => host.isSourceFileFromExternalLibrary(file)); - } - - function getAllEmittableSourceFiles() { - return options.noEmitForJsFiles ? filter(host.getSourceFiles(), sourceFile => !isSourceFileJavaScript(sourceFile)) : host.getSourceFiles(); + const sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + return filter(sourceFiles, sourceFile => sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary)); } } - /** Don't call this for `--outFile`, just for `--outDir` or plain emit. */ - export function filterSourceFilesInDirectory(sourceFiles: SourceFile[], isSourceFileFromExternalLibrary: (file: SourceFile) => boolean): SourceFile[] { - return filter(sourceFiles, file => shouldEmitInDirectory(file, isSourceFileFromExternalLibrary)); - } - - function isNonDeclarationFile(sourceFile: SourceFile) { - return !isDeclarationFile(sourceFile); + /** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */ + export function sourceFileMayBeEmitted(sourceFile: SourceFile, options: CompilerOptions, isSourceFileFromExternalLibrary: (file: SourceFile) => boolean) { + return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !isDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); } /** - * Whether a file should be emitted in a non-`--outFile` case. - * Don't emit if source file is a declaration file, or was located under node_modules - */ - function shouldEmitInDirectory(sourceFile: SourceFile, isSourceFileFromExternalLibrary: (file: SourceFile) => boolean): boolean { - return isNonDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); - } - - function isBundleEmitNonExternalModule(sourceFile: SourceFile) { - return isNonDeclarationFile(sourceFile) && !isExternalModule(sourceFile); - } - - /** - * Iterates over each source file to emit. The source files are expected to have been - * transformed for use by the pretty printer. - * - * Originally part of `forEachExpectedEmitFile`, this functionality was extracted to support - * transformations. + * Iterates over the source files that are expected to have an emit output. * * @param host An EmitHost. - * @param sourceFiles The transformed source files to emit. * @param action The action to execute. + * @param sourceFilesOrTargetSourceFile + * If an array, the full list of source files to emit. + * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - export function forEachTransformedEmitFile(host: EmitHost, sourceFiles: SourceFile[], - action: (jsFilePath: string, sourceMapFilePath: string, declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) => void, + export function forEachEmittedFile( + host: EmitHost, action: (emitFileNames: EmitFileNames, sourceFileOrBundle: SourceFile | Bundle, emitOnlyDtsFiles: boolean) => void, + sourceFilesOrTargetSourceFile?: SourceFile[] | SourceFile, emitOnlyDtsFiles?: boolean) { + + const sourceFiles = isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); const options = host.getCompilerOptions(); - // Emit on each source file if (options.outFile || options.out) { - onBundledEmit(sourceFiles); - } - else { - for (const sourceFile of sourceFiles) { - // Don't emit if source file is a declaration file, or was located under node_modules - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } - } - } - - function onSingleFileEmit(host: EmitHost, sourceFile: SourceFile) { - // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. - // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. - // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve - let extension = ".js"; - if (options.jsx === JsxEmit.Preserve) { - if (isSourceFileJavaScript(sourceFile)) { - if (fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === LanguageVariant.JSX) { - // TypeScript source file preserving JSX syntax - extension = ".jsx"; - } - } - const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - const declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], /*isBundledEmit*/ false); - } - - function onBundledEmit(sourceFiles: SourceFile[]) { if (sourceFiles.length) { const jsFilePath = options.outFile || options.out; const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); const declarationFilePath = options.declaration ? removeFileExtension(jsFilePath) + ".d.ts" : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, /*isBundledEmit*/ true); + action({ jsFilePath, sourceMapFilePath, declarationFilePath }, createBundle(sourceFiles), emitOnlyDtsFiles); + } + } + else { + for (const sourceFile of sourceFiles) { + const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); + const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + const declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + action({ jsFilePath, sourceMapFilePath, declarationFilePath }, sourceFile, emitOnlyDtsFiles); } } } @@ -2678,77 +2671,22 @@ namespace ts { return options.sourceMap ? jsFilePath + ".map" : undefined; } - /** - * Iterates over the source files that are expected to have an emit output. This function - * is used by the legacy emitter and the declaration emitter and should not be used by - * the tree transforming emitter. - * - * @param host An EmitHost. - * @param action The action to execute. - * @param targetSourceFile An optional target source file to emit. - */ - export function forEachExpectedEmitFile(host: EmitHost, - action: (emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean, emitOnlyDtsFiles: boolean) => void, - targetSourceFile?: SourceFile, - emitOnlyDtsFiles?: boolean) { - const options = host.getCompilerOptions(); - // Emit on each source file - if (options.outFile || options.out) { - onBundledEmit(host); - } - else { - const sourceFiles = targetSourceFile === undefined ? getSourceFilesToEmit(host) : [targetSourceFile]; - for (const sourceFile of sourceFiles) { - if (shouldEmitInDirectory(sourceFile, file => host.isSourceFileFromExternalLibrary(file))) { - onSingleFileEmit(host, sourceFile); + // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. + // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. + // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve + function getOutputExtension(sourceFile: SourceFile, options: CompilerOptions): string { + if (options.jsx === JsxEmit.Preserve) { + if (isSourceFileJavaScript(sourceFile)) { + if (fileExtensionIs(sourceFile.fileName, ".jsx")) { + return ".jsx"; } } - } - - function onSingleFileEmit(host: EmitHost, sourceFile: SourceFile) { - // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. - // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. - // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve - let extension = ".js"; - if (options.jsx === JsxEmit.Preserve) { - if (isSourceFileJavaScript(sourceFile)) { - if (fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === LanguageVariant.JSX) { - // TypeScript source file preserving JSX syntax - extension = ".jsx"; - } - } - const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - const declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - const emitFileNames: EmitFileNames = { - jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath - }; - action(emitFileNames, [sourceFile], /*isBundledEmit*/false, emitOnlyDtsFiles); - } - - function onBundledEmit(host: EmitHost) { - // Can emit only sources that are not declaration file and are either non module code or module with - // --module or --target es6 specified. Files included by searching under node_modules are also not emitted. - const bundledSources = filter(getSourceFilesToEmit(host), - sourceFile => !isDeclarationFile(sourceFile) && - !host.isSourceFileFromExternalLibrary(sourceFile) && - (!isExternalModule(sourceFile) || - !!getEmitModuleKind(options))); - if (bundledSources.length) { - const jsFilePath = options.outFile || options.out; - const emitFileNames: EmitFileNames = { - jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: options.declaration ? removeFileExtension(jsFilePath) + ".d.ts" : undefined - }; - action(emitFileNames, bundledSources, /*isBundledEmit*/true, emitOnlyDtsFiles); + else if (sourceFile.languageVariant === LanguageVariant.JSX) { + // TypeScript source file preserving JSX syntax + return ".jsx"; } } + return ".js"; } export function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string) { @@ -3210,7 +3148,11 @@ namespace ts { } export function getLocalSymbolForExportDefault(symbol: Symbol) { - return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, ModifierFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined; + return isExportDefaultSymbol(symbol) ? symbol.valueDeclaration.localSymbol : undefined; + } + + export function isExportDefaultSymbol(symbol: Symbol): boolean { + return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, ModifierFlags.Default); } /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ @@ -3295,7 +3237,7 @@ namespace ts { const carriageReturnLineFeed = "\r\n"; const lineFeed = "\n"; - export function getNewLineCharacter(options: CompilerOptions): string { + export function getNewLineCharacter(options: CompilerOptions | PrinterOptions): string { if (options.newLine === NewLineKind.CarriageReturnLineFeed) { return carriageReturnLineFeed; } @@ -3383,18 +3325,21 @@ namespace ts { return false; } - const syntaxKindCache = createMap(); + const syntaxKindCache: string[] = []; export function formatSyntaxKind(kind: SyntaxKind): string { const syntaxKindEnum = (ts).SyntaxKind; if (syntaxKindEnum) { - if (syntaxKindCache[kind]) { - return syntaxKindCache[kind]; + const cached = syntaxKindCache[kind]; + if (cached !== undefined) { + return cached; } for (const name in syntaxKindEnum) { if (syntaxKindEnum[name] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name + ")"; + const result = `${kind} (${name})`; + syntaxKindCache[kind] = result; + return result; } } } @@ -3403,6 +3348,14 @@ namespace ts { } } + export function getRangePos(range: TextRange | undefined) { + return range ? range.pos : -1; + } + + export function getRangeEnd(range: TextRange | undefined) { + return range ? range.end : -1; + } + /** * Increases (or decreases) a position by the provided amount. * @@ -3846,6 +3799,12 @@ namespace ts { return node.kind === SyntaxKind.PropertyAccessExpression; } + export function isPropertyAccessOrQualifiedName(node: Node): node is PropertyAccessExpression | QualifiedName { + const kind = node.kind; + return kind === SyntaxKind.PropertyAccessExpression + || kind === SyntaxKind.QualifiedName; + } + export function isElementAccessExpression(node: Node): node is ElementAccessExpression { return node.kind === SyntaxKind.ElementAccessExpression; } @@ -4002,6 +3961,19 @@ namespace ts { export function isModuleBody(node: Node): node is ModuleBody { const kind = node.kind; return kind === SyntaxKind.ModuleBlock + || kind === SyntaxKind.ModuleDeclaration + || kind === SyntaxKind.Identifier; + } + + export function isNamespaceBody(node: Node): node is NamespaceBody { + const kind = node.kind; + return kind === SyntaxKind.ModuleBlock + || kind === SyntaxKind.ModuleDeclaration; + } + + export function isJSDocNamespaceBody(node: Node): node is JSDocNamespaceBody { + const kind = node.kind; + return kind === SyntaxKind.Identifier || kind === SyntaxKind.ModuleDeclaration; } @@ -4051,6 +4023,7 @@ namespace ts { || kind === SyntaxKind.ImportEqualsDeclaration || kind === SyntaxKind.ImportSpecifier || kind === SyntaxKind.InterfaceDeclaration + || kind === SyntaxKind.JsxAttribute || kind === SyntaxKind.MethodDeclaration || kind === SyntaxKind.MethodSignature || kind === SyntaxKind.ModuleDeclaration @@ -4163,6 +4136,11 @@ namespace ts { || kind === SyntaxKind.JsxText; } + export function isJsxAttributes(node: Node): node is JsxAttributes { + const kind = node.kind; + return kind === SyntaxKind.JsxAttributes; + } + export function isJsxAttributeLike(node: Node): node is JsxAttributeLike { const kind = node.kind; return kind === SyntaxKind.JsxAttribute @@ -4183,6 +4161,12 @@ namespace ts { || kind === SyntaxKind.JsxExpression; } + export function isJsxOpeningLikeElement(node: Node): node is JsxOpeningLikeElement { + const kind = node.kind; + return kind === SyntaxKind.JsxOpeningElement + || kind === SyntaxKind.JsxSelfClosingElement; + } + // Clauses export function isCaseOrDefaultClause(node: Node): node is CaseOrDefaultClause { @@ -4237,7 +4221,6 @@ namespace ts { return "lib.es2016.d.ts"; case ScriptTarget.ES2015: return "lib.es6.d.ts"; - default: return "lib.d.ts"; } @@ -4594,4 +4577,65 @@ namespace ts { return true; } } + + export function getOriginalNode(node: Node): Node; + export function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; + export function getOriginalNode(node: Node, nodeTest?: (node: Node) => boolean): Node { + if (node) { + while (node.original !== undefined) { + node = node.original; + } + } + + return !nodeTest || nodeTest(node) ? node : undefined; + } + + /** + * Gets a value indicating whether a node originated in the parse tree. + * + * @param node The node to test. + */ + export function isParseTreeNode(node: Node): boolean { + return (node.flags & NodeFlags.Synthesized) === 0; + } + + /** + * Gets the original parse tree node for a node. + * + * @param node The original node. + * @returns The original parse tree node if found; otherwise, undefined. + */ + export function getParseTreeNode(node: Node): Node; + + /** + * Gets the original parse tree node for a node. + * + * @param node The original node. + * @param nodeTest A callback used to ensure the correct type of parse tree node is returned. + * @returns The original parse tree node if found; otherwise, undefined. + */ + export function getParseTreeNode(node: Node, nodeTest?: (node: Node) => node is T): T; + export function getParseTreeNode(node: Node, nodeTest?: (node: Node) => boolean): Node { + if (node == undefined || isParseTreeNode(node)) { + return node; + } + + node = getOriginalNode(node); + + if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { + return node; + } + + return undefined; + } + + /** + * Remove extra underscore from escaped identifier text content. + * + * @param identifier The escaped identifier text. + * @returns The unescaped identifier text. + */ + export function unescapeIdentifier(identifier: string): string { + return identifier.length >= 3 && identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._ && identifier.charCodeAt(2) === CharacterCodes._ ? identifier.substr(1) : identifier; + } } diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 5fc80bb014d..2d75d646128 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -1,123 +1,785 @@ -/// +/// /// /// +namespace ts { + /** + * Visits a Node using the supplied visitor, possibly returning a new Node in its place. + * + * @param node The Node to visit. + * @param visitor The callback used to visit the Node. + * @param test A callback to execute to verify the Node is valid. + * @param lift An optional callback to execute to lift a NodeArray into a valid Node. + */ + export function visitNode(node: T, visitor: Visitor, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T; + + /** + * Visits a Node using the supplied visitor, possibly returning a new Node in its place. + * + * @param node The Node to visit. + * @param visitor The callback used to visit the Node. + * @param test A callback to execute to verify the Node is valid. + * @param lift An optional callback to execute to lift a NodeArray into a valid Node. + */ + export function visitNode(node: T | undefined, visitor: Visitor, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T | undefined; + + export function visitNode(node: T | undefined, visitor: Visitor, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T | undefined { + if (node === undefined || visitor === undefined) { + return node; + } + + aggregateTransformFlags(node); + const visited = visitor(node); + if (visited === node) { + return node; + } + + let visitedNode: Node; + if (visited === undefined) { + return undefined; + } + else if (isArray(visited)) { + visitedNode = (lift || extractSingleNode)(visited); + } + else { + visitedNode = visited; + } + + Debug.assertNode(visitedNode, test); + aggregateTransformFlags(visitedNode); + return visitedNode; + } + + /** + * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. + * + * @param nodes The NodeArray to visit. + * @param visitor The callback used to visit a Node. + * @param test A node test to execute for each node. + * @param start An optional value indicating the starting offset at which to start visiting. + * @param count An optional value indicating the maximum number of nodes to visit. + */ + export function visitNodes(nodes: NodeArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray; + + /** + * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. + * + * @param nodes The NodeArray to visit. + * @param visitor The callback used to visit a Node. + * @param test A node test to execute for each node. + * @param start An optional value indicating the starting offset at which to start visiting. + * @param count An optional value indicating the maximum number of nodes to visit. + */ + export function visitNodes(nodes: NodeArray | undefined, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | undefined; + + /** + * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. + * + * @param nodes The NodeArray to visit. + * @param visitor The callback used to visit a Node. + * @param test A node test to execute for each node. + * @param start An optional value indicating the starting offset at which to start visiting. + * @param count An optional value indicating the maximum number of nodes to visit. + */ + export function visitNodes(nodes: NodeArray | undefined, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | undefined { + if (nodes === undefined || visitor === undefined) { + return nodes; + } + + let updated: NodeArray; + + // Ensure start and count have valid values + const length = nodes.length; + if (start === undefined || start < 0) { + start = 0; + } + + if (count === undefined || count > length - start) { + count = length - start; + } + + if (start > 0 || count < length) { + // If we are not visiting all of the original nodes, we must always create a new array. + // Since this is a fragment of a node array, we do not copy over the previous location + // and will only copy over `hasTrailingComma` if we are including the last element. + updated = createNodeArray([], /*hasTrailingComma*/ nodes.hasTrailingComma && start + count === length); + } + + // Visit each original node. + for (let i = 0; i < count; i++) { + const node = nodes[i + start]; + aggregateTransformFlags(node); + const visited = node !== undefined ? visitor(node) : undefined; + if (updated !== undefined || visited === undefined || visited !== node) { + if (updated === undefined) { + // Ensure we have a copy of `nodes`, up to the current index. + updated = createNodeArray(nodes.slice(0, i), nodes.hasTrailingComma); + setTextRange(updated, nodes); + } + if (visited) { + if (isArray(visited)) { + for (const visitedNode of visited) { + Debug.assertNode(visitedNode, test); + aggregateTransformFlags(visitedNode); + updated.push(visitedNode); + } + } + else { + Debug.assertNode(visited, test); + aggregateTransformFlags(visited); + updated.push(visited); + } + } + } + } + + return updated || nodes; + } + + /** + * Starts a new lexical environment and visits a statement list, ending the lexical environment + * and merging hoisted declarations upon completion. + */ + export function visitLexicalEnvironment(statements: NodeArray, visitor: Visitor, context: TransformationContext, start?: number, ensureUseStrict?: boolean) { + context.startLexicalEnvironment(); + statements = visitNodes(statements, visitor, isStatement, start); + if (ensureUseStrict && !startsWithUseStrict(statements)) { + statements = setTextRange(createNodeArray([createStatement(createLiteral("use strict")), ...statements]), statements); + } + const declarations = context.endLexicalEnvironment(); + return setTextRange(createNodeArray(concatenate(statements, declarations)), statements); + } + + /** + * Starts a new lexical environment and visits a parameter list, suspending the lexical + * environment upon completion. + */ + export function visitParameterList(nodes: NodeArray, visitor: Visitor, context: TransformationContext) { + context.startLexicalEnvironment(); + const updated = visitNodes(nodes, visitor, isParameterDeclaration); + context.suspendLexicalEnvironment(); + return updated; + } + + /** + * Resumes a suspended lexical environment and visits a function body, ending the lexical + * environment and merging hoisted declarations upon completion. + */ + export function visitFunctionBody(node: FunctionBody, visitor: Visitor, context: TransformationContext): FunctionBody; + /** + * Resumes a suspended lexical environment and visits a function body, ending the lexical + * environment and merging hoisted declarations upon completion. + */ + export function visitFunctionBody(node: FunctionBody | undefined, visitor: Visitor, context: TransformationContext): FunctionBody | undefined; + /** + * Resumes a suspended lexical environment and visits a concise body, ending the lexical + * environment and merging hoisted declarations upon completion. + */ + export function visitFunctionBody(node: ConciseBody, visitor: Visitor, context: TransformationContext): ConciseBody; + export function visitFunctionBody(node: ConciseBody, visitor: Visitor, context: TransformationContext): ConciseBody { + context.resumeLexicalEnvironment(); + const updated = visitNode(node, visitor, isConciseBody); + const declarations = context.endLexicalEnvironment(); + if (some(declarations)) { + const block = convertToFunctionBody(updated); + const statements = mergeLexicalEnvironment(block.statements, declarations); + return updateBlock(block, statements); + } + return updated; + } + + /** + * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place. + * + * @param node The Node whose children will be visited. + * @param visitor The callback used to visit each child. + * @param context A lexical environment context for the visitor. + */ + export function visitEachChild(node: T, visitor: Visitor, context: TransformationContext): T; + + /** + * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place. + * + * @param node The Node whose children will be visited. + * @param visitor The callback used to visit each child. + * @param context A lexical environment context for the visitor. + */ + export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext): T | undefined; + + export function visitEachChild(node: Node, visitor: Visitor, context: TransformationContext): Node { + if (node === undefined) { + return undefined; + } + + const kind = node.kind; + // No need to visit nodes with no children. + if ((kind > SyntaxKind.FirstToken && kind <= SyntaxKind.LastToken)) { + return node; + } + + // We do not yet support types. + if ((kind >= SyntaxKind.TypePredicate && kind <= SyntaxKind.LiteralType)) { + return node; + } + + switch (node.kind) { + case SyntaxKind.SemicolonClassElement: + case SyntaxKind.EmptyStatement: + case SyntaxKind.OmittedExpression: + case SyntaxKind.DebuggerStatement: + // No need to visit nodes with no children. + return node; + + // Names + case SyntaxKind.QualifiedName: + return updateQualifiedName(node, + visitNode((node).left, visitor, isEntityName), + visitNode((node).right, visitor, isIdentifier)); + + case SyntaxKind.ComputedPropertyName: + return updateComputedPropertyName(node, + visitNode((node).expression, visitor, isExpression)); + + // Signature elements + case SyntaxKind.Parameter: + return updateParameter(node, + visitNodes((node).decorators, visitor, isDecorator), + visitNodes((node).modifiers, visitor, isModifier), + (node).dotDotDotToken, + visitNode((node).name, visitor, isBindingName), + visitNode((node).type, visitor, isTypeNode), + visitNode((node).initializer, visitor, isExpression)); + + case SyntaxKind.Decorator: + return updateDecorator(node, + visitNode((node).expression, visitor, isExpression)); + + // Type member + case SyntaxKind.PropertyDeclaration: + return updateProperty(node, + visitNodes((node).decorators, visitor, isDecorator), + visitNodes((node).modifiers, visitor, isModifier), + visitNode((node).name, visitor, isPropertyName), + visitNode((node).type, visitor, isTypeNode), + visitNode((node).initializer, visitor, isExpression)); + + case SyntaxKind.MethodDeclaration: + return updateMethod(node, + visitNodes((node).decorators, visitor, isDecorator), + visitNodes((node).modifiers, visitor, isModifier), + (node).asteriskToken, + visitNode((node).name, visitor, isPropertyName), + visitNodes((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context), + visitNode((node).type, visitor, isTypeNode), + visitFunctionBody((node).body, visitor, context)); + + case SyntaxKind.Constructor: + return updateConstructor(node, + visitNodes((node).decorators, visitor, isDecorator), + visitNodes((node).modifiers, visitor, isModifier), + visitParameterList((node).parameters, visitor, context), + visitFunctionBody((node).body, visitor, context)); + + case SyntaxKind.GetAccessor: + return updateGetAccessor(node, + visitNodes((node).decorators, visitor, isDecorator), + visitNodes((node).modifiers, visitor, isModifier), + visitNode((node).name, visitor, isPropertyName), + visitParameterList((node).parameters, visitor, context), + visitNode((node).type, visitor, isTypeNode), + visitFunctionBody((node).body, visitor, context)); + + case SyntaxKind.SetAccessor: + return updateSetAccessor(node, + visitNodes((node).decorators, visitor, isDecorator), + visitNodes((node).modifiers, visitor, isModifier), + visitNode((node).name, visitor, isPropertyName), + visitParameterList((node).parameters, visitor, context), + visitFunctionBody((node).body, visitor, context)); + + // Binding patterns + case SyntaxKind.ObjectBindingPattern: + return updateObjectBindingPattern(node, + visitNodes((node).elements, visitor, isBindingElement)); + + case SyntaxKind.ArrayBindingPattern: + return updateArrayBindingPattern(node, + visitNodes((node).elements, visitor, isArrayBindingElement)); + + case SyntaxKind.BindingElement: + return updateBindingElement(node, + (node).dotDotDotToken, + visitNode((node).propertyName, visitor, isPropertyName), + visitNode((node).name, visitor, isBindingName), + visitNode((node).initializer, visitor, isExpression)); + + // Expression + case SyntaxKind.ArrayLiteralExpression: + return updateArrayLiteral(node, + visitNodes((node).elements, visitor, isExpression)); + + case SyntaxKind.ObjectLiteralExpression: + return updateObjectLiteral(node, + visitNodes((node).properties, visitor, isObjectLiteralElementLike)); + + case SyntaxKind.PropertyAccessExpression: + return updatePropertyAccess(node, + visitNode((node).expression, visitor, isExpression), + visitNode((node).name, visitor, isIdentifier)); + + case SyntaxKind.ElementAccessExpression: + return updateElementAccess(node, + visitNode((node).expression, visitor, isExpression), + visitNode((node).argumentExpression, visitor, isExpression)); + + case SyntaxKind.CallExpression: + return updateCall(node, + visitNode((node).expression, visitor, isExpression), + visitNodes((node).typeArguments, visitor, isTypeNode), + visitNodes((node).arguments, visitor, isExpression)); + + case SyntaxKind.NewExpression: + return updateNew(node, + visitNode((node).expression, visitor, isExpression), + visitNodes((node).typeArguments, visitor, isTypeNode), + visitNodes((node).arguments, visitor, isExpression)); + + case SyntaxKind.TaggedTemplateExpression: + return updateTaggedTemplate(node, + visitNode((node).tag, visitor, isExpression), + visitNode((node).template, visitor, isTemplateLiteral)); + + case SyntaxKind.TypeAssertionExpression: + return updateTypeAssertion(node, + visitNode((node).type, visitor, isTypeNode), + visitNode((node).expression, visitor, isExpression)); + + case SyntaxKind.ParenthesizedExpression: + return updateParen(node, + visitNode((node).expression, visitor, isExpression)); + + case SyntaxKind.FunctionExpression: + return updateFunctionExpression(node, + visitNodes((node).modifiers, visitor, isModifier), + (node).asteriskToken, + visitNode((node).name, visitor, isIdentifier), + visitNodes((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context), + visitNode((node).type, visitor, isTypeNode), + visitFunctionBody((node).body, visitor, context)); + + case SyntaxKind.ArrowFunction: + return updateArrowFunction(node, + visitNodes((node).modifiers, visitor, isModifier), + visitNodes((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context), + visitNode((node).type, visitor, isTypeNode), + visitFunctionBody((node).body, visitor, context)); + + case SyntaxKind.DeleteExpression: + return updateDelete(node, + visitNode((node).expression, visitor, isExpression)); + + case SyntaxKind.TypeOfExpression: + return updateTypeOf(node, + visitNode((node).expression, visitor, isExpression)); + + case SyntaxKind.VoidExpression: + return updateVoid(node, + visitNode((node).expression, visitor, isExpression)); + + case SyntaxKind.AwaitExpression: + return updateAwait(node, + visitNode((node).expression, visitor, isExpression)); + + case SyntaxKind.BinaryExpression: + return updateBinary(node, + visitNode((node).left, visitor, isExpression), + visitNode((node).right, visitor, isExpression)); + + case SyntaxKind.PrefixUnaryExpression: + return updatePrefix(node, + visitNode((node).operand, visitor, isExpression)); + + case SyntaxKind.PostfixUnaryExpression: + return updatePostfix(node, + visitNode((node).operand, visitor, isExpression)); + + case SyntaxKind.ConditionalExpression: + return updateConditional(node, + visitNode((node).condition, visitor, isExpression), + visitNode((node).whenTrue, visitor, isExpression), + visitNode((node).whenFalse, visitor, isExpression)); + + case SyntaxKind.TemplateExpression: + return updateTemplateExpression(node, + visitNode((node).head, visitor, isTemplateHead), + visitNodes((node).templateSpans, visitor, isTemplateSpan)); + + case SyntaxKind.YieldExpression: + return updateYield(node, + (node).asteriskToken, + visitNode((node).expression, visitor, isExpression)); + + case SyntaxKind.SpreadElement: + return updateSpread(node, + visitNode((node).expression, visitor, isExpression)); + + case SyntaxKind.ClassExpression: + return updateClassExpression(node, + visitNodes((node).modifiers, visitor, isModifier), + visitNode((node).name, visitor, isIdentifier), + visitNodes((node).typeParameters, visitor, isTypeParameter), + visitNodes((node).heritageClauses, visitor, isHeritageClause), + visitNodes((node).members, visitor, isClassElement)); + + case SyntaxKind.ExpressionWithTypeArguments: + return updateExpressionWithTypeArguments(node, + visitNodes((node).typeArguments, visitor, isTypeNode), + visitNode((node).expression, visitor, isExpression)); + + case SyntaxKind.AsExpression: + return updateAsExpression(node, + visitNode((node).expression, visitor, isExpression), + visitNode((node).type, visitor, isTypeNode)); + + case SyntaxKind.NonNullExpression: + return updateNonNullExpression(node, + visitNode((node).expression, visitor, isExpression)); + + // Misc + case SyntaxKind.TemplateSpan: + return updateTemplateSpan(node, + visitNode((node).expression, visitor, isExpression), + visitNode((node).literal, visitor, isTemplateMiddleOrTemplateTail)); + + // Element + case SyntaxKind.Block: + return updateBlock(node, + visitNodes((node).statements, visitor, isStatement)); + + case SyntaxKind.VariableStatement: + return updateVariableStatement(node, + visitNodes((node).modifiers, visitor, isModifier), + visitNode((node).declarationList, visitor, isVariableDeclarationList)); + + case SyntaxKind.ExpressionStatement: + return updateStatement(node, + visitNode((node).expression, visitor, isExpression)); + + case SyntaxKind.IfStatement: + return updateIf(node, + visitNode((node).expression, visitor, isExpression), + visitNode((node).thenStatement, visitor, isStatement, liftToBlock), + visitNode((node).elseStatement, visitor, isStatement, liftToBlock)); + + case SyntaxKind.DoStatement: + return updateDo(node, + visitNode((node).statement, visitor, isStatement, liftToBlock), + visitNode((node).expression, visitor, isExpression)); + + case SyntaxKind.WhileStatement: + return updateWhile(node, + visitNode((node).expression, visitor, isExpression), + visitNode((node).statement, visitor, isStatement, liftToBlock)); + + case SyntaxKind.ForStatement: + return updateFor(node, + visitNode((node).initializer, visitor, isForInitializer), + visitNode((node).condition, visitor, isExpression), + visitNode((node).incrementor, visitor, isExpression), + visitNode((node).statement, visitor, isStatement, liftToBlock)); + + case SyntaxKind.ForInStatement: + return updateForIn(node, + visitNode((node).initializer, visitor, isForInitializer), + visitNode((node).expression, visitor, isExpression), + visitNode((node).statement, visitor, isStatement, liftToBlock)); + + case SyntaxKind.ForOfStatement: + return updateForOf(node, + (node).awaitModifier, + visitNode((node).initializer, visitor, isForInitializer), + visitNode((node).expression, visitor, isExpression), + visitNode((node).statement, visitor, isStatement, liftToBlock)); + + case SyntaxKind.ContinueStatement: + return updateContinue(node, + visitNode((node).label, visitor, isIdentifier)); + + case SyntaxKind.BreakStatement: + return updateBreak(node, + visitNode((node).label, visitor, isIdentifier)); + + case SyntaxKind.ReturnStatement: + return updateReturn(node, + visitNode((node).expression, visitor, isExpression)); + + case SyntaxKind.WithStatement: + return updateWith(node, + visitNode((node).expression, visitor, isExpression), + visitNode((node).statement, visitor, isStatement, liftToBlock)); + + case SyntaxKind.SwitchStatement: + return updateSwitch(node, + visitNode((node).expression, visitor, isExpression), + visitNode((node).caseBlock, visitor, isCaseBlock)); + + case SyntaxKind.LabeledStatement: + return updateLabel(node, + visitNode((node).label, visitor, isIdentifier), + visitNode((node).statement, visitor, isStatement, liftToBlock)); + + case SyntaxKind.ThrowStatement: + return updateThrow(node, + visitNode((node).expression, visitor, isExpression)); + + case SyntaxKind.TryStatement: + return updateTry(node, + visitNode((node).tryBlock, visitor, isBlock), + visitNode((node).catchClause, visitor, isCatchClause), + visitNode((node).finallyBlock, visitor, isBlock)); + + case SyntaxKind.VariableDeclaration: + return updateVariableDeclaration(node, + visitNode((node).name, visitor, isBindingName), + visitNode((node).type, visitor, isTypeNode), + visitNode((node).initializer, visitor, isExpression)); + + case SyntaxKind.VariableDeclarationList: + return updateVariableDeclarationList(node, + visitNodes((node).declarations, visitor, isVariableDeclaration)); + + case SyntaxKind.FunctionDeclaration: + return updateFunctionDeclaration(node, + visitNodes((node).decorators, visitor, isDecorator), + visitNodes((node).modifiers, visitor, isModifier), + (node).asteriskToken, + visitNode((node).name, visitor, isIdentifier), + visitNodes((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context), + visitNode((node).type, visitor, isTypeNode), + visitFunctionBody((node).body, visitor, context)); + + case SyntaxKind.ClassDeclaration: + return updateClassDeclaration(node, + visitNodes((node).decorators, visitor, isDecorator), + visitNodes((node).modifiers, visitor, isModifier), + visitNode((node).name, visitor, isIdentifier), + visitNodes((node).typeParameters, visitor, isTypeParameter), + visitNodes((node).heritageClauses, visitor, isHeritageClause), + visitNodes((node).members, visitor, isClassElement)); + + case SyntaxKind.EnumDeclaration: + return updateEnumDeclaration(node, + visitNodes((node).decorators, visitor, isDecorator), + visitNodes((node).modifiers, visitor, isModifier), + visitNode((node).name, visitor, isIdentifier), + visitNodes((node).members, visitor, isEnumMember)); + + case SyntaxKind.ModuleDeclaration: + return updateModuleDeclaration(node, + visitNodes((node).decorators, visitor, isDecorator), + visitNodes((node).modifiers, visitor, isModifier), + visitNode((node).name, visitor, isIdentifier), + visitNode((node).body, visitor, isModuleBody)); + + case SyntaxKind.ModuleBlock: + return updateModuleBlock(node, + visitNodes((node).statements, visitor, isStatement)); + + case SyntaxKind.CaseBlock: + return updateCaseBlock(node, + visitNodes((node).clauses, visitor, isCaseOrDefaultClause)); + + case SyntaxKind.ImportEqualsDeclaration: + return updateImportEqualsDeclaration(node, + visitNodes((node).decorators, visitor, isDecorator), + visitNodes((node).modifiers, visitor, isModifier), + visitNode((node).name, visitor, isIdentifier), + visitNode((node).moduleReference, visitor, isModuleReference)); + + case SyntaxKind.ImportDeclaration: + return updateImportDeclaration(node, + visitNodes((node).decorators, visitor, isDecorator), + visitNodes((node).modifiers, visitor, isModifier), + visitNode((node).importClause, visitor, isImportClause), + visitNode((node).moduleSpecifier, visitor, isExpression)); + + case SyntaxKind.ImportClause: + return updateImportClause(node, + visitNode((node).name, visitor, isIdentifier), + visitNode((node).namedBindings, visitor, isNamedImportBindings)); + + case SyntaxKind.NamespaceImport: + return updateNamespaceImport(node, + visitNode((node).name, visitor, isIdentifier)); + + case SyntaxKind.NamedImports: + return updateNamedImports(node, + visitNodes((node).elements, visitor, isImportSpecifier)); + + case SyntaxKind.ImportSpecifier: + return updateImportSpecifier(node, + visitNode((node).propertyName, visitor, isIdentifier), + visitNode((node).name, visitor, isIdentifier)); + + case SyntaxKind.ExportAssignment: + return updateExportAssignment(node, + visitNodes((node).decorators, visitor, isDecorator), + visitNodes((node).modifiers, visitor, isModifier), + visitNode((node).expression, visitor, isExpression)); + + case SyntaxKind.ExportDeclaration: + return updateExportDeclaration(node, + visitNodes((node).decorators, visitor, isDecorator), + visitNodes((node).modifiers, visitor, isModifier), + visitNode((node).exportClause, visitor, isNamedExports), + visitNode((node).moduleSpecifier, visitor, isExpression)); + + case SyntaxKind.NamedExports: + return updateNamedExports(node, + visitNodes((node).elements, visitor, isExportSpecifier)); + + case SyntaxKind.ExportSpecifier: + return updateExportSpecifier(node, + visitNode((node).propertyName, visitor, isIdentifier), + visitNode((node).name, visitor, isIdentifier)); + + // Module references + case SyntaxKind.ExternalModuleReference: + return updateExternalModuleReference(node, + visitNode((node).expression, visitor, isExpression)); + + // JSX + case SyntaxKind.JsxElement: + return updateJsxElement(node, + visitNode((node).openingElement, visitor, isJsxOpeningElement), + visitNodes((node).children, visitor, isJsxChild), + visitNode((node).closingElement, visitor, isJsxClosingElement)); + + case SyntaxKind.JsxAttributes: + return updateJsxAttributes(node, + visitNodes((node).properties, visitor, isJsxAttributeLike)); + + case SyntaxKind.JsxSelfClosingElement: + return updateJsxSelfClosingElement(node, + visitNode((node).tagName, visitor, isJsxTagNameExpression), + visitNode((node).attributes, visitor, isJsxAttributes)); + + case SyntaxKind.JsxOpeningElement: + return updateJsxOpeningElement(node, + visitNode((node).tagName, visitor, isJsxTagNameExpression), + visitNode((node).attributes, visitor, isJsxAttributes)); + + case SyntaxKind.JsxClosingElement: + return updateJsxClosingElement(node, + visitNode((node).tagName, visitor, isJsxTagNameExpression)); + + case SyntaxKind.JsxAttribute: + return updateJsxAttribute(node, + visitNode((node).name, visitor, isIdentifier), + visitNode((node).initializer, visitor, isStringLiteralOrJsxExpression)); + + case SyntaxKind.JsxSpreadAttribute: + return updateJsxSpreadAttribute(node, + visitNode((node).expression, visitor, isExpression)); + + case SyntaxKind.JsxExpression: + return updateJsxExpression(node, + visitNode((node).expression, visitor, isExpression)); + + // Clauses + case SyntaxKind.CaseClause: + return updateCaseClause(node, + visitNode((node).expression, visitor, isExpression), + visitNodes((node).statements, visitor, isStatement)); + + case SyntaxKind.DefaultClause: + return updateDefaultClause(node, + visitNodes((node).statements, visitor, isStatement)); + + case SyntaxKind.HeritageClause: + return updateHeritageClause(node, + visitNodes((node).types, visitor, isExpressionWithTypeArguments)); + + case SyntaxKind.CatchClause: + return updateCatchClause(node, + visitNode((node).variableDeclaration, visitor, isVariableDeclaration), + visitNode((node).block, visitor, isBlock)); + + // Property assignments + case SyntaxKind.PropertyAssignment: + return updatePropertyAssignment(node, + visitNode((node).name, visitor, isPropertyName), + visitNode((node).initializer, visitor, isExpression)); + + case SyntaxKind.ShorthandPropertyAssignment: + return updateShorthandPropertyAssignment(node, + visitNode((node).name, visitor, isIdentifier), + visitNode((node).objectAssignmentInitializer, visitor, isExpression)); + + case SyntaxKind.SpreadAssignment: + return updateSpreadAssignment(node, + visitNode((node).expression, visitor, isExpression)); + + // Enum + case SyntaxKind.EnumMember: + return updateEnumMember(node, + visitNode((node).name, visitor, isPropertyName), + visitNode((node).initializer, visitor, isExpression)); + + // Top-level nodes + case SyntaxKind.SourceFile: + return updateSourceFileNode(node, + visitLexicalEnvironment((node).statements, visitor, context)); + + // Transformation nodes + case SyntaxKind.PartiallyEmittedExpression: + return updatePartiallyEmittedExpression(node, + visitNode((node).expression, visitor, isExpression)); + + default: + return node; + } + } + + /** + * Extracts the single node from a NodeArray. + * + * @param nodes The NodeArray. + */ + function extractSingleNode(nodes: Node[]): Node { + Debug.assert(nodes.length <= 1, "Too many nodes written to output."); + return singleOrUndefined(nodes); + } +} + /* @internal */ namespace ts { - export type VisitResult = T | T[]; - - /** - * Describes an edge of a Node, used when traversing a syntax tree. - */ - interface NodeEdge { - /** The property name for the edge. */ - name: string; - - /** Indicates that the result is optional. */ - optional?: boolean; - - /** A callback used to test whether a node is valid. */ - test?: (node: Node) => node is Node; - - /** A callback used to lift a NodeArrayNode into a valid node. */ - lift?: (nodes: NodeArray) => Node; - - /** A callback used to parenthesize a node to preserve the intended order of operations. */ - parenthesize?: (value: Node, parentNode: Node) => Node; - }; - - /** - * Describes the shape of a Node. - */ - type NodeTraversalPath = NodeEdge[]; - - /** - * This map contains information about the shape of each Node in "types.ts" pertaining to how - * each node should be traversed during a transformation. - * - * Each edge corresponds to a property in a Node subtype that should be traversed when visiting - * each child. The properties are assigned in the order in which traversal should occur. - * - * We only add entries for nodes that do not have a create/update pair defined in factory.ts - * - * NOTE: This needs to be kept up to date with changes to nodes in "types.ts". Currently, this - * map is not comprehensive. Only node edges relevant to tree transformation are - * currently defined. We may extend this to be more comprehensive, and eventually - * supplant the existing `forEachChild` implementation if performance is not - * significantly impacted. - */ - const nodeEdgeTraversalMap = createMap({ - [SyntaxKind.QualifiedName]: [ - { name: "left", test: isEntityName }, - { name: "right", test: isIdentifier } - ], - [SyntaxKind.Decorator]: [ - { name: "expression", test: isLeftHandSideExpression } - ], - [SyntaxKind.TypeAssertionExpression]: [ - { name: "type", test: isTypeNode }, - { name: "expression", test: isUnaryExpression } - ], - [SyntaxKind.AsExpression]: [ - { name: "expression", test: isExpression }, - { name: "type", test: isTypeNode } - ], - [SyntaxKind.NonNullExpression]: [ - { name: "expression", test: isLeftHandSideExpression } - ], - [SyntaxKind.EnumDeclaration]: [ - { name: "decorators", test: isDecorator }, - { name: "modifiers", test: isModifier }, - { name: "name", test: isIdentifier }, - { name: "members", test: isEnumMember } - ], - [SyntaxKind.ModuleDeclaration]: [ - { name: "decorators", test: isDecorator }, - { name: "modifiers", test: isModifier }, - { name: "name", test: isModuleName }, - { name: "body", test: isModuleBody } - ], - [SyntaxKind.ModuleBlock]: [ - { name: "statements", test: isStatement } - ], - [SyntaxKind.ImportEqualsDeclaration]: [ - { name: "decorators", test: isDecorator }, - { name: "modifiers", test: isModifier }, - { name: "name", test: isIdentifier }, - { name: "moduleReference", test: isModuleReference } - ], - [SyntaxKind.ExternalModuleReference]: [ - { name: "expression", test: isExpression, optional: true } - ], - [SyntaxKind.EnumMember]: [ - { name: "name", test: isPropertyName }, - { name: "initializer", test: isExpression, optional: true, parenthesize: parenthesizeExpressionForList } - ] - }); - function reduceNode(node: Node, f: (memo: T, node: Node) => T, initial: T) { return node ? f(initial, node) : initial; } - function reduceNodeArray(nodes: Node[], f: (memo: T, nodes: Node[]) => T, initial: T) { + function reduceNodeArray(nodes: NodeArray, f: (memo: T, nodes: NodeArray) => T, initial: T) { return nodes ? f(initial, nodes) : initial; } /** * Similar to `reduceLeft`, performs a reduction against each child of a node. - * NOTE: Unlike `forEachChild`, this does *not* visit every node. Only nodes added to the - * `nodeEdgeTraversalMap` above will be visited. + * NOTE: Unlike `forEachChild`, this does *not* visit every node. * * @param node The node containing the children to reduce. * @param initial The initial value to supply to the reduction. * @param f The callback function */ - export function reduceEachChild(node: Node, initial: T, cbNode: (memo: T, node: Node) => T, cbNodeArray?: (memo: T, nodes: Node[]) => T): T { + export function reduceEachChild(node: Node, initial: T, cbNode: (memo: T, node: Node) => T, cbNodeArray?: (memo: T, nodes: NodeArray) => T): T { if (node === undefined) { return initial; } - const reduceNodes: (nodes: Node[], f: (memo: T, node: Node | Node[]) => T, initial: T) => T = cbNodeArray ? reduceNodeArray : reduceLeft; + const reduceNodes: (nodes: NodeArray, f: (memo: T, node: Node | NodeArray) => T, initial: T) => T = cbNodeArray ? reduceNodeArray : reduceLeft; const cbNodes = cbNodeArray || cbNode; const kind = node.kind; @@ -143,6 +805,11 @@ namespace ts { break; // Names + case SyntaxKind.QualifiedName: + result = reduceNode((node).left, cbNode, result); + result = reduceNode((node).right, cbNode, result); + break; + case SyntaxKind.ComputedPropertyName: result = reduceNode((node).expression, cbNode, result); break; @@ -250,6 +917,11 @@ namespace ts { result = reduceNode((node).template, cbNode, result); break; + case SyntaxKind.TypeAssertionExpression: + result = reduceNode((node).type, cbNode, result); + result = reduceNode((node).expression, cbNode, result); + break; + case SyntaxKind.FunctionExpression: result = reduceNodes((node).modifiers, cbNodes, result); result = reduceNode((node).name, cbNode, result); @@ -312,6 +984,15 @@ namespace ts { result = reduceNodes((node).typeArguments, cbNodes, result); break; + case SyntaxKind.AsExpression: + result = reduceNode((node).expression, cbNode, result); + result = reduceNode((node).type, cbNode, result); + break; + + case SyntaxKind.NonNullExpression: + result = reduceNode((node).expression, cbNode, result); + break; + // Misc case SyntaxKind.TemplateSpan: result = reduceNode((node).expression, cbNode, result); @@ -413,10 +1094,35 @@ namespace ts { result = reduceNodes((node).members, cbNodes, result); break; + case SyntaxKind.EnumDeclaration: + result = reduceNodes((node).decorators, cbNodes, result); + result = reduceNodes((node).modifiers, cbNodes, result); + result = reduceNode((node).name, cbNode, result); + result = reduceNodes((node).members, cbNodes, result); + break; + + case SyntaxKind.ModuleDeclaration: + result = reduceNodes((node).decorators, cbNodes, result); + result = reduceNodes((node).modifiers, cbNodes, result); + result = reduceNode((node).name, cbNode, result); + result = reduceNode((node).body, cbNode, result); + break; + + case SyntaxKind.ModuleBlock: + result = reduceNodes((node).statements, cbNodes, result); + break; + case SyntaxKind.CaseBlock: result = reduceNodes((node).clauses, cbNodes, result); break; + case SyntaxKind.ImportEqualsDeclaration: + result = reduceNodes((node).decorators, cbNodes, result); + result = reduceNodes((node).modifiers, cbNodes, result); + result = reduceNode((node).name, cbNode, result); + result = reduceNode((node).moduleReference, cbNode, result); + break; + case SyntaxKind.ImportDeclaration: result = reduceNodes((node).decorators, cbNodes, result); result = reduceNodes((node).modifiers, cbNodes, result); @@ -457,6 +1163,11 @@ namespace ts { result = reduceNode((node).moduleSpecifier, cbNode, result); break; + // Module references + case SyntaxKind.ExternalModuleReference: + result = reduceNode((node).expression, cbNode, result); + break; + // JSX case SyntaxKind.JsxElement: result = reduceNode((node).openingElement, cbNode, result); @@ -467,9 +1178,12 @@ namespace ts { case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.JsxOpeningElement: result = reduceNode((node).tagName, cbNode, result); - result = reduceNodes((node).attributes, cbNodes, result); + result = reduceNode((node).attributes, cbNode, result); break; + case SyntaxKind.JsxAttributes: + result = reduceNodes((node).properties, cbNodes, result); + case SyntaxKind.JsxClosingElement: result = reduceNode((node).tagName, cbNode, result); break; @@ -517,706 +1231,36 @@ namespace ts { break; case SyntaxKind.SpreadAssignment: - result = reduceNode((node as SpreadAssignment).expression, cbNode, result); + result = reduceNode((node).expression, cbNode, result); break; + // Enum + case SyntaxKind.EnumMember: + result = reduceNode((node).name, cbNode, result); + result = reduceNode((node).initializer, cbNode, result); + // Top-level nodes case SyntaxKind.SourceFile: result = reduceNodes((node).statements, cbNodes, result); break; + // Transformation nodes case SyntaxKind.PartiallyEmittedExpression: result = reduceNode((node).expression, cbNode, result); break; default: - const edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (const edge of edgeTraversalPath) { - const value = (>node)[edge.name]; - if (value !== undefined) { - result = isArray(value) - ? reduceNodes(>value, cbNodes, result) - : cbNode(result, value); - } - } - } break; } return result; } - /** - * Visits a Node using the supplied visitor, possibly returning a new Node in its place. - * - * @param node The Node to visit. - * @param visitor The callback used to visit the Node. - * @param test A callback to execute to verify the Node is valid. - * @param optional An optional value indicating whether the Node is itself optional. - * @param lift An optional callback to execute to lift a NodeArrayNode into a valid Node. - */ - export function visitNode(node: T, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, optional?: boolean, lift?: (node: NodeArray) => T): T; - export function visitNode(node: T, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, optional: boolean, lift: (node: NodeArray) => T, parenthesize: (node: Node, parentNode: Node) => Node, parentNode: Node): T; - export function visitNode(node: Node, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, optional?: boolean, lift?: (node: Node[]) => Node, parenthesize?: (node: Node, parentNode: Node) => Node, parentNode?: Node): Node { - if (node === undefined || visitor === undefined) { - return node; - } - - aggregateTransformFlags(node); - const visited = visitor(node); - if (visited === node) { - return node; - } - - let visitedNode: Node; - if (visited === undefined) { - if (!optional) { - Debug.failNotOptional(); - } - - return undefined; - } - else if (isArray(visited)) { - visitedNode = (lift || extractSingleNode)(visited); - } - else { - visitedNode = visited; - } - - if (parenthesize !== undefined) { - visitedNode = parenthesize(visitedNode, parentNode); - } - - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); - return visitedNode; - } - - /** - * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. - * - * @param nodes The NodeArray to visit. - * @param visitor The callback used to visit a Node. - * @param test A node test to execute for each node. - * @param start An optional value indicating the starting offset at which to start visiting. - * @param count An optional value indicating the maximum number of nodes to visit. - */ - export function visitNodes(nodes: NodeArray, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, start?: number, count?: number): NodeArray; - export function visitNodes(nodes: NodeArray, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, start: number, count: number, parenthesize: (node: Node, parentNode: Node) => Node, parentNode: Node): NodeArray; - export function visitNodes(nodes: NodeArray, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, start?: number, count?: number, parenthesize?: (node: Node, parentNode: Node) => Node, parentNode?: Node): NodeArray { - if (nodes === undefined) { - return undefined; - } - - let updated: NodeArray; - - // Ensure start and count have valid values - const length = nodes.length; - if (start === undefined || start < 0) { - start = 0; - } - - if (count === undefined || count > length - start) { - count = length - start; - } - - if (start > 0 || count < length) { - // If we are not visiting all of the original nodes, we must always create a new array. - // Since this is a fragment of a node array, we do not copy over the previous location - // and will only copy over `hasTrailingComma` if we are including the last element. - updated = createNodeArray([], /*location*/ undefined, - /*hasTrailingComma*/ nodes.hasTrailingComma && start + count === length); - } - - // Visit each original node. - for (let i = 0; i < count; i++) { - const node = nodes[i + start]; - aggregateTransformFlags(node); - const visited = node !== undefined ? visitor(node) : undefined; - if (updated !== undefined || visited === undefined || visited !== node) { - if (updated === undefined) { - // Ensure we have a copy of `nodes`, up to the current index. - updated = createNodeArray(nodes.slice(0, i), /*location*/ nodes, nodes.hasTrailingComma); - } - if (visited) { - if (isArray(visited)) { - for (let visitedNode of visited) { - visitedNode = parenthesize - ? parenthesize(visitedNode, parentNode) - : visitedNode; - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); - updated.push(visitedNode); - } - } - else { - const visitedNode = parenthesize - ? parenthesize(visited, parentNode) - : visited; - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); - updated.push(visitedNode); - } - } - } - } - - return updated || nodes; - } - - /** - * Starts a new lexical environment and visits a statement list, ending the lexical environment - * and merging hoisted declarations upon completion. - */ - export function visitLexicalEnvironment(statements: NodeArray, visitor: (node: Node) => VisitResult, context: TransformationContext, start?: number, ensureUseStrict?: boolean) { - context.startLexicalEnvironment(); - statements = visitNodes(statements, visitor, isStatement, start); - if (ensureUseStrict && !startsWithUseStrict(statements)) { - statements = createNodeArray([createStatement(createLiteral("use strict")), ...statements], statements); - } - const declarations = context.endLexicalEnvironment(); - return createNodeArray(concatenate(statements, declarations), statements); - } - - /** - * Starts a new lexical environment and visits a parameter list, suspending the lexical - * environment upon completion. - */ - export function visitParameterList(nodes: NodeArray, visitor: (node: Node) => VisitResult, context: TransformationContext) { - context.startLexicalEnvironment(); - const updated = visitNodes(nodes, visitor, isParameterDeclaration); - context.suspendLexicalEnvironment(); - return updated; - } - - /** - * Resumes a suspended lexical environment and visits a function body, ending the lexical - * environment and merging hoisted declarations upon completion. - */ - export function visitFunctionBody(node: FunctionBody, visitor: (node: Node) => VisitResult, context: TransformationContext): FunctionBody; - /** - * Resumes a suspended lexical environment and visits a concise body, ending the lexical - * environment and merging hoisted declarations upon completion. - */ - export function visitFunctionBody(node: ConciseBody, visitor: (node: Node) => VisitResult, context: TransformationContext): ConciseBody; - export function visitFunctionBody(node: ConciseBody, visitor: (node: Node) => VisitResult, context: TransformationContext): ConciseBody { - context.resumeLexicalEnvironment(); - const updated = visitNode(node, visitor, isConciseBody); - const declarations = context.endLexicalEnvironment(); - if (some(declarations)) { - const block = convertToFunctionBody(updated); - const statements = mergeLexicalEnvironment(block.statements, declarations); - return updateBlock(block, statements); - } - return updated; - } - - /** - * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place. - * - * @param node The Node whose children will be visited. - * @param visitor The callback used to visit each child. - * @param context A lexical environment context for the visitor. - */ - export function visitEachChild(node: T, visitor: (node: Node) => VisitResult, context: TransformationContext): T; - export function visitEachChild(node: Node, visitor: (node: Node) => VisitResult, context: TransformationContext): Node { - if (node === undefined) { - return undefined; - } - - const kind = node.kind; - // No need to visit nodes with no children. - if ((kind > SyntaxKind.FirstToken && kind <= SyntaxKind.LastToken)) { - return node; - } - - // We do not yet support types. - if ((kind >= SyntaxKind.TypePredicate && kind <= SyntaxKind.LiteralType)) { - return node; - } - - switch (node.kind) { - case SyntaxKind.SemicolonClassElement: - case SyntaxKind.EmptyStatement: - case SyntaxKind.OmittedExpression: - case SyntaxKind.DebuggerStatement: - // No need to visit nodes with no children. - return node; - - // Names - case SyntaxKind.ComputedPropertyName: - return updateComputedPropertyName(node, - visitNode((node).expression, visitor, isExpression)); - - // Signature elements - case SyntaxKind.Parameter: - return updateParameter(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), - (node).dotDotDotToken, - visitNode((node).name, visitor, isBindingName), - visitNode((node).type, visitor, isTypeNode, /*optional*/ true), - visitNode((node).initializer, visitor, isExpression, /*optional*/ true)); - - // Type member - case SyntaxKind.PropertyDeclaration: - return updateProperty(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), - visitNode((node).name, visitor, isPropertyName), - visitNode((node).type, visitor, isTypeNode, /*optional*/ true), - visitNode((node).initializer, visitor, isExpression, /*optional*/ true)); - - case SyntaxKind.MethodDeclaration: - return updateMethod(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), - visitNode((node).name, visitor, isPropertyName), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context), - visitNode((node).type, visitor, isTypeNode, /*optional*/ true), - visitFunctionBody((node).body, visitor, context)); - - case SyntaxKind.Constructor: - return updateConstructor(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), - visitParameterList((node).parameters, visitor, context), - visitFunctionBody((node).body, visitor, context)); - - case SyntaxKind.GetAccessor: - return updateGetAccessor(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), - visitNode((node).name, visitor, isPropertyName), - visitParameterList((node).parameters, visitor, context), - visitNode((node).type, visitor, isTypeNode, /*optional*/ true), - visitFunctionBody((node).body, visitor, context)); - - case SyntaxKind.SetAccessor: - return updateSetAccessor(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), - visitNode((node).name, visitor, isPropertyName), - visitParameterList((node).parameters, visitor, context), - visitFunctionBody((node).body, visitor, context)); - - // Binding patterns - case SyntaxKind.ObjectBindingPattern: - return updateObjectBindingPattern(node, - visitNodes((node).elements, visitor, isBindingElement)); - - case SyntaxKind.ArrayBindingPattern: - return updateArrayBindingPattern(node, - visitNodes((node).elements, visitor, isArrayBindingElement)); - - case SyntaxKind.BindingElement: - return updateBindingElement(node, - (node).dotDotDotToken, - visitNode((node).propertyName, visitor, isPropertyName, /*optional*/ true), - visitNode((node).name, visitor, isBindingName), - visitNode((node).initializer, visitor, isExpression, /*optional*/ true)); - - // Expression - case SyntaxKind.ArrayLiteralExpression: - return updateArrayLiteral(node, - visitNodes((node).elements, visitor, isExpression)); - - case SyntaxKind.ObjectLiteralExpression: - return updateObjectLiteral(node, - visitNodes((node).properties, visitor, isObjectLiteralElementLike)); - - case SyntaxKind.PropertyAccessExpression: - return updatePropertyAccess(node, - visitNode((node).expression, visitor, isExpression), - visitNode((node).name, visitor, isIdentifier)); - - case SyntaxKind.ElementAccessExpression: - return updateElementAccess(node, - visitNode((node).expression, visitor, isExpression), - visitNode((node).argumentExpression, visitor, isExpression)); - - case SyntaxKind.CallExpression: - return updateCall(node, - visitNode((node).expression, visitor, isExpression), - visitNodes((node).typeArguments, visitor, isTypeNode), - visitNodes((node).arguments, visitor, isExpression)); - - case SyntaxKind.NewExpression: - return updateNew(node, - visitNode((node).expression, visitor, isExpression), - visitNodes((node).typeArguments, visitor, isTypeNode), - visitNodes((node).arguments, visitor, isExpression)); - - case SyntaxKind.TaggedTemplateExpression: - return updateTaggedTemplate(node, - visitNode((node).tag, visitor, isExpression), - visitNode((node).template, visitor, isTemplateLiteral)); - - case SyntaxKind.ParenthesizedExpression: - return updateParen(node, - visitNode((node).expression, visitor, isExpression)); - - case SyntaxKind.FunctionExpression: - return updateFunctionExpression(node, - visitNodes((node).modifiers, visitor, isModifier), - visitNode((node).name, visitor, isPropertyName), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context), - visitNode((node).type, visitor, isTypeNode, /*optional*/ true), - visitFunctionBody((node).body, visitor, context)); - - case SyntaxKind.ArrowFunction: - return updateArrowFunction(node, - visitNodes((node).modifiers, visitor, isModifier), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context), - visitNode((node).type, visitor, isTypeNode, /*optional*/ true), - visitFunctionBody((node).body, visitor, context)); - - case SyntaxKind.DeleteExpression: - return updateDelete(node, - visitNode((node).expression, visitor, isExpression)); - - case SyntaxKind.TypeOfExpression: - return updateTypeOf(node, - visitNode((node).expression, visitor, isExpression)); - - case SyntaxKind.VoidExpression: - return updateVoid(node, - visitNode((node).expression, visitor, isExpression)); - - case SyntaxKind.AwaitExpression: - return updateAwait(node, - visitNode((node).expression, visitor, isExpression)); - - case SyntaxKind.BinaryExpression: - return updateBinary(node, - visitNode((node).left, visitor, isExpression), - visitNode((node).right, visitor, isExpression)); - - case SyntaxKind.PrefixUnaryExpression: - return updatePrefix(node, - visitNode((node).operand, visitor, isExpression)); - - case SyntaxKind.PostfixUnaryExpression: - return updatePostfix(node, - visitNode((node).operand, visitor, isExpression)); - - case SyntaxKind.ConditionalExpression: - return updateConditional(node, - visitNode((node).condition, visitor, isExpression), - visitNode((node).whenTrue, visitor, isExpression), - visitNode((node).whenFalse, visitor, isExpression)); - - case SyntaxKind.TemplateExpression: - return updateTemplateExpression(node, - visitNode((node).head, visitor, isTemplateHead), - visitNodes((node).templateSpans, visitor, isTemplateSpan)); - - case SyntaxKind.YieldExpression: - return updateYield(node, - visitNode((node).expression, visitor, isExpression)); - - case SyntaxKind.SpreadElement: - return updateSpread(node, - visitNode((node).expression, visitor, isExpression)); - - case SyntaxKind.ClassExpression: - return updateClassExpression(node, - visitNodes((node).modifiers, visitor, isModifier), - visitNode((node).name, visitor, isIdentifier, /*optional*/ true), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitNodes((node).heritageClauses, visitor, isHeritageClause), - visitNodes((node).members, visitor, isClassElement)); - - case SyntaxKind.ExpressionWithTypeArguments: - return updateExpressionWithTypeArguments(node, - visitNodes((node).typeArguments, visitor, isTypeNode), - visitNode((node).expression, visitor, isExpression)); - - // Misc - case SyntaxKind.TemplateSpan: - return updateTemplateSpan(node, - visitNode((node).expression, visitor, isExpression), - visitNode((node).literal, visitor, isTemplateMiddleOrTemplateTail)); - - // Element - case SyntaxKind.Block: - return updateBlock(node, - visitNodes((node).statements, visitor, isStatement)); - - case SyntaxKind.VariableStatement: - return updateVariableStatement(node, - visitNodes((node).modifiers, visitor, isModifier), - visitNode((node).declarationList, visitor, isVariableDeclarationList)); - - case SyntaxKind.ExpressionStatement: - return updateStatement(node, - visitNode((node).expression, visitor, isExpression)); - - case SyntaxKind.IfStatement: - return updateIf(node, - visitNode((node).expression, visitor, isExpression), - visitNode((node).thenStatement, visitor, isStatement, /*optional*/ false, liftToBlock), - visitNode((node).elseStatement, visitor, isStatement, /*optional*/ true, liftToBlock)); - - case SyntaxKind.DoStatement: - return updateDo(node, - visitNode((node).statement, visitor, isStatement, /*optional*/ false, liftToBlock), - visitNode((node).expression, visitor, isExpression)); - - case SyntaxKind.WhileStatement: - return updateWhile(node, - visitNode((node).expression, visitor, isExpression), - visitNode((node).statement, visitor, isStatement, /*optional*/ false, liftToBlock)); - - case SyntaxKind.ForStatement: - return updateFor(node, - visitNode((node).initializer, visitor, isForInitializer), - visitNode((node).condition, visitor, isExpression), - visitNode((node).incrementor, visitor, isExpression), - visitNode((node).statement, visitor, isStatement, /*optional*/ false, liftToBlock)); - - case SyntaxKind.ForInStatement: - return updateForIn(node, - visitNode((node).initializer, visitor, isForInitializer), - visitNode((node).expression, visitor, isExpression), - visitNode((node).statement, visitor, isStatement, /*optional*/ false, liftToBlock)); - - case SyntaxKind.ForOfStatement: - return updateForOf(node, - visitNode((node).initializer, visitor, isForInitializer), - visitNode((node).expression, visitor, isExpression), - visitNode((node).statement, visitor, isStatement, /*optional*/ false, liftToBlock)); - - case SyntaxKind.ContinueStatement: - return updateContinue(node, - visitNode((node).label, visitor, isIdentifier, /*optional*/ true)); - - case SyntaxKind.BreakStatement: - return updateBreak(node, - visitNode((node).label, visitor, isIdentifier, /*optional*/ true)); - - case SyntaxKind.ReturnStatement: - return updateReturn(node, - visitNode((node).expression, visitor, isExpression, /*optional*/ true)); - - case SyntaxKind.WithStatement: - return updateWith(node, - visitNode((node).expression, visitor, isExpression), - visitNode((node).statement, visitor, isStatement, /*optional*/ false, liftToBlock)); - - case SyntaxKind.SwitchStatement: - return updateSwitch(node, - visitNode((node).expression, visitor, isExpression), - visitNode((node).caseBlock, visitor, isCaseBlock)); - - case SyntaxKind.LabeledStatement: - return updateLabel(node, - visitNode((node).label, visitor, isIdentifier), - visitNode((node).statement, visitor, isStatement, /*optional*/ false, liftToBlock)); - - case SyntaxKind.ThrowStatement: - return updateThrow(node, - visitNode((node).expression, visitor, isExpression)); - - case SyntaxKind.TryStatement: - return updateTry(node, - visitNode((node).tryBlock, visitor, isBlock), - visitNode((node).catchClause, visitor, isCatchClause, /*optional*/ true), - visitNode((node).finallyBlock, visitor, isBlock, /*optional*/ true)); - - case SyntaxKind.VariableDeclaration: - return updateVariableDeclaration(node, - visitNode((node).name, visitor, isBindingName), - visitNode((node).type, visitor, isTypeNode, /*optional*/ true), - visitNode((node).initializer, visitor, isExpression, /*optional*/ true)); - - case SyntaxKind.VariableDeclarationList: - return updateVariableDeclarationList(node, - visitNodes((node).declarations, visitor, isVariableDeclaration)); - - case SyntaxKind.FunctionDeclaration: - return updateFunctionDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), - visitNode((node).name, visitor, isPropertyName), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context), - visitNode((node).type, visitor, isTypeNode, /*optional*/ true), - visitFunctionBody((node).body, visitor, context)); - - case SyntaxKind.ClassDeclaration: - return updateClassDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), - visitNode((node).name, visitor, isIdentifier, /*optional*/ true), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitNodes((node).heritageClauses, visitor, isHeritageClause), - visitNodes((node).members, visitor, isClassElement)); - - case SyntaxKind.CaseBlock: - return updateCaseBlock(node, - visitNodes((node).clauses, visitor, isCaseOrDefaultClause)); - - case SyntaxKind.ImportDeclaration: - return updateImportDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), - visitNode((node).importClause, visitor, isImportClause, /*optional*/ true), - visitNode((node).moduleSpecifier, visitor, isExpression)); - - case SyntaxKind.ImportClause: - return updateImportClause(node, - visitNode((node).name, visitor, isIdentifier, /*optional*/ true), - visitNode((node).namedBindings, visitor, isNamedImportBindings, /*optional*/ true)); - - case SyntaxKind.NamespaceImport: - return updateNamespaceImport(node, - visitNode((node).name, visitor, isIdentifier)); - - case SyntaxKind.NamedImports: - return updateNamedImports(node, - visitNodes((node).elements, visitor, isImportSpecifier)); - - case SyntaxKind.ImportSpecifier: - return updateImportSpecifier(node, - visitNode((node).propertyName, visitor, isIdentifier, /*optional*/ true), - visitNode((node).name, visitor, isIdentifier)); - - case SyntaxKind.ExportAssignment: - return updateExportAssignment(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), - visitNode((node).expression, visitor, isExpression)); - - case SyntaxKind.ExportDeclaration: - return updateExportDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), - visitNode((node).exportClause, visitor, isNamedExports, /*optional*/ true), - visitNode((node).moduleSpecifier, visitor, isExpression, /*optional*/ true)); - - case SyntaxKind.NamedExports: - return updateNamedExports(node, - visitNodes((node).elements, visitor, isExportSpecifier)); - - case SyntaxKind.ExportSpecifier: - return updateExportSpecifier(node, - visitNode((node).propertyName, visitor, isIdentifier, /*optional*/ true), - visitNode((node).name, visitor, isIdentifier)); - - // JSX - case SyntaxKind.JsxElement: - return updateJsxElement(node, - visitNode((node).openingElement, visitor, isJsxOpeningElement), - visitNodes((node).children, visitor, isJsxChild), - visitNode((node).closingElement, visitor, isJsxClosingElement)); - - case SyntaxKind.JsxSelfClosingElement: - return updateJsxSelfClosingElement(node, - visitNode((node).tagName, visitor, isJsxTagNameExpression), - visitNodes((node).attributes, visitor, isJsxAttributeLike)); - - case SyntaxKind.JsxOpeningElement: - return updateJsxOpeningElement(node, - visitNode((node).tagName, visitor, isJsxTagNameExpression), - visitNodes((node).attributes, visitor, isJsxAttributeLike)); - - case SyntaxKind.JsxClosingElement: - return updateJsxClosingElement(node, - visitNode((node).tagName, visitor, isJsxTagNameExpression)); - - case SyntaxKind.JsxAttribute: - return updateJsxAttribute(node, - visitNode((node).name, visitor, isIdentifier), - visitNode((node).initializer, visitor, isStringLiteralOrJsxExpression)); - - case SyntaxKind.JsxSpreadAttribute: - return updateJsxSpreadAttribute(node, - visitNode((node).expression, visitor, isExpression)); - - case SyntaxKind.JsxExpression: - return updateJsxExpression(node, - visitNode((node).expression, visitor, isExpression)); - - // Clauses - case SyntaxKind.CaseClause: - return updateCaseClause(node, - visitNode((node).expression, visitor, isExpression), - visitNodes((node).statements, visitor, isStatement)); - - case SyntaxKind.DefaultClause: - return updateDefaultClause(node, - visitNodes((node).statements, visitor, isStatement)); - - case SyntaxKind.HeritageClause: - return updateHeritageClause(node, - visitNodes((node).types, visitor, isExpressionWithTypeArguments)); - - case SyntaxKind.CatchClause: - return updateCatchClause(node, - visitNode((node).variableDeclaration, visitor, isVariableDeclaration), - visitNode((node).block, visitor, isBlock)); - - // Property assignments - case SyntaxKind.PropertyAssignment: - return updatePropertyAssignment(node, - visitNode((node).name, visitor, isPropertyName), - visitNode((node).initializer, visitor, isExpression)); - - case SyntaxKind.ShorthandPropertyAssignment: - return updateShorthandPropertyAssignment(node, - visitNode((node).name, visitor, isIdentifier), - visitNode((node).objectAssignmentInitializer, visitor, isExpression)); - - case SyntaxKind.SpreadAssignment: - return updateSpreadAssignment(node as SpreadAssignment, - visitNode((node as SpreadAssignment).expression, visitor, isExpression)); - - // Top-level nodes - case SyntaxKind.SourceFile: - return updateSourceFileNode(node, - visitLexicalEnvironment((node).statements, visitor, context)); - - // Transformation nodes - case SyntaxKind.PartiallyEmittedExpression: - return updatePartiallyEmittedExpression(node, - visitNode((node).expression, visitor, isExpression)); - - default: - let updated: Node & MapLike; - const edgeTraversalPath = nodeEdgeTraversalMap[kind]; - if (edgeTraversalPath) { - for (const edge of edgeTraversalPath) { - const value = >(>node)[edge.name]; - if (value !== undefined) { - const visited = isArray(value) - ? visitNodes(value, visitor, edge.test, 0, value.length, edge.parenthesize, node) - : visitNode(value, visitor, edge.test, edge.optional, edge.lift, edge.parenthesize, node); - if (updated !== undefined || visited !== value) { - if (updated === undefined) { - updated = getMutableClone(node); - } - if (visited !== value) { - updated[edge.name] = visited; - } - } - } - } - } - return updated ? updateNode(updated, node) : node; - } - - // return node; - } - /** * Merges generated lexical declarations into a new statement list. */ export function mergeLexicalEnvironment(statements: NodeArray, declarations: Statement[]): NodeArray; + /** * Appends generated lexical declarations to an array of statements. */ @@ -1225,43 +1269,12 @@ namespace ts { if (!some(declarations)) { return statements; } + return isNodeArray(statements) - ? createNodeArray(concatenate(statements, declarations), statements) + ? setTextRange(createNodeArray(concatenate(statements, declarations)), statements) : addRange(statements, declarations); } - - /** - * Merges generated lexical declarations into the FunctionBody of a non-arrow function-like declaration. - * - * @param node The ConciseBody of an arrow function. - * @param declarations The lexical declarations to merge. - */ - export function mergeFunctionBodyLexicalEnvironment(body: FunctionBody, declarations: Statement[]): FunctionBody; - - /** - * Merges generated lexical declarations into the ConciseBody of an ArrowFunction. - * - * @param node The ConciseBody of an arrow function. - * @param declarations The lexical declarations to merge. - */ - export function mergeFunctionBodyLexicalEnvironment(body: ConciseBody, declarations: Statement[]): ConciseBody; - - export function mergeFunctionBodyLexicalEnvironment(body: ConciseBody, declarations: Statement[]): ConciseBody { - if (body && declarations !== undefined && declarations.length > 0) { - if (isBlock(body)) { - return updateBlock(body, createNodeArray(concatenate(body.statements, declarations), body.statements)); - } - else { - return createBlock( - createNodeArray([createReturn(body, /*location*/ body), ...declarations], body), - /*location*/ body, - /*multiLine*/ true); - } - } - return body; - } - /** * Lifts a NodeArray containing only Statement nodes to a block. * @@ -1272,16 +1285,6 @@ namespace ts { return singleOrUndefined(nodes) || createBlock(>nodes); } - /** - * Extracts the single node from a NodeArray. - * - * @param nodes The NodeArray. - */ - function extractSingleNode(nodes: Node[]): Node { - Debug.assert(nodes.length <= 1, "Too many nodes written to output."); - return singleOrUndefined(nodes); - } - /** * Aggregates the TransformFlags for a Node and its subtree. */ @@ -1349,10 +1352,6 @@ namespace ts { } export namespace Debug { - export const failNotOptional = shouldAssert(AssertionLevel.Normal) - ? (message?: string) => assert(false, message || "Node not optional.") - : noop; - export const failBadSyntaxKind = shouldAssert(AssertionLevel.Normal) ? (node: Node, message?: string) => assert(false, message || "Unexpected node.", () => `Node ${formatSyntaxKind(node.kind)} was unexpected.`) : noop; diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 3dd6b504615..49d1336c874 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -40,16 +40,16 @@ namespace FourSlash { files: FourSlashFile[]; // A mapping from marker names to name/position pairs - markerPositions: { [index: string]: Marker; }; + markerPositions: ts.Map; markers: Marker[]; /** * Inserted in source files by surrounding desired text * in a range with `[|` and `|]`. For example, - * + * * [|text in range|] - * + * * is a range with `text in range` "selected". */ ranges: Range[]; @@ -61,10 +61,6 @@ namespace FourSlash { data?: any; } - interface MarkerMap { - [index: string]: Marker; - } - export interface Range { fileName: string; start: number; @@ -94,7 +90,7 @@ namespace FourSlash { export import IndentStyle = ts.IndentStyle; - const entityMap = ts.createMap({ + const entityMap = ts.createMapFromTemplate({ "&": "&", "\"": """, "'": "'", @@ -104,7 +100,7 @@ namespace FourSlash { }); export function escapeXmlAttributeValue(s: string) { - return s.replace(/[&<>"'\/]/g, ch => entityMap[ch]); + return s.replace(/[&<>"'\/]/g, ch => entityMap.get(ch)); } // Name of testcase metadata including ts.CompilerOptions properties that will be used by globalOptions @@ -187,7 +183,7 @@ namespace FourSlash { // The current caret position in the active file public currentCaretPosition = 0; - public lastKnownMarker: string = ""; + public lastKnownMarker = ""; // The file that's currently 'opened' public activeFile: FourSlashFile; @@ -230,7 +226,7 @@ namespace FourSlash { } function tryAdd(path: string) { - const inputFile = inputFiles[path]; + const inputFile = inputFiles.get(path); if (inputFile && !Harness.isDefaultLibraryFile(path)) { languageServiceAdapterHost.addScript(path, inputFile, /*isRootFile*/ true); return true; @@ -262,13 +258,15 @@ namespace FourSlash { // Initialize the language service with all the scripts let startResolveFileRef: FourSlashFile; + let configFileName: string; ts.forEach(testData.files, file => { // Create map between fileName and its content for easily looking up when resolveReference flag is specified - this.inputFiles[file.fileName] = file.content; - + this.inputFiles.set(file.fileName, file.content); if (ts.getBaseFileName(file.fileName).toLowerCase() === "tsconfig.json") { const configJson = ts.parseConfigFileTextToJson(file.fileName, file.content); - assert.isTrue(configJson.config !== undefined); + if (configJson.config === undefined) { + throw new Error(`Failed to parse test tsconfig.json: ${configJson.error.messageText}`); + } // Extend our existing compiler options so that we can also support tsconfig only options if (configJson.config.compilerOptions) { @@ -279,6 +277,7 @@ namespace FourSlash { compilationOptions = ts.extend(compilationOptions, tsConfig.options); } } + configFileName = file.fileName; } if (!startResolveFileRef && file.fileOptions[metadataOptionNames.resolveReference] === "true") { @@ -290,6 +289,21 @@ namespace FourSlash { } }); + if (configFileName) { + const baseDir = ts.normalizePath(ts.getDirectoryPath(configFileName)); + const host = new Utils.MockParseConfigHost(baseDir, /*ignoreCase*/ false, this.inputFiles); + + const configJsonObj = ts.parseConfigFileTextToJson(configFileName, this.inputFiles.get(configFileName)); + assert.isTrue(configJsonObj.config !== undefined); + + const { options, errors } = ts.parseJsonConfigFileContent(configJsonObj.config, host, baseDir); + + // Extend our existing compiler options so that we can also support tsconfig only options + if (!errors || errors.length === 0) { + compilationOptions = ts.extend(compilationOptions, options); + } + } + if (compilationOptions.typeRoots) { compilationOptions.typeRoots = compilationOptions.typeRoots.map(p => ts.getNormalizedAbsolutePath(p, this.basePath)); @@ -330,11 +344,11 @@ namespace FourSlash { } else { // resolveReference file-option is not specified then do not resolve any files and include all inputFiles - for (const fileName in this.inputFiles) { + this.inputFiles.forEach((file, fileName) => { if (!Harness.isDefaultLibraryFile(fileName)) { - this.languageServiceAdapterHost.addScript(fileName, this.inputFiles[fileName], /*isRootFile*/ true); + this.languageServiceAdapterHost.addScript(fileName, file, /*isRootFile*/ true); } - } + }); this.languageServiceAdapterHost.addScript(Harness.Compiler.defaultLibFileName, Harness.Compiler.getDefaultLibrarySourceFile().text, /*isRootFile*/ false); } @@ -372,8 +386,8 @@ namespace FourSlash { } // Entry points from fourslash.ts - public goToMarker(name = "") { - const marker = this.getMarkerByName(name); + public goToMarker(name: string | Marker = "") { + const marker = typeof name === "string" ? this.getMarkerByName(name) : name; if (this.activeFile.fileName !== marker.fileName) { this.openFile(marker.fileName); } @@ -382,10 +396,37 @@ namespace FourSlash { if (marker.position === -1 || marker.position > content.length) { throw new Error(`Marker "${name}" has been invalidated by unrecoverable edits to the file.`); } - this.lastKnownMarker = name; + const mName = typeof name === "string" ? name : this.markerName(marker); + this.lastKnownMarker = mName; this.goToPosition(marker.position); } + public goToEachMarker(action: () => void) { + const markers = this.getMarkers(); + assert(markers.length); + for (const marker of markers) { + this.goToMarker(marker); + action(); + } + } + + public goToEachRange(action: () => void) { + const ranges = this.getRanges(); + assert(ranges.length); + for (const range of ranges) { + this.goToRangeStart(range); + action(); + } + } + + private markerName(m: Marker): string { + return ts.forEachEntry(this.testData.markerPositions, (marker, name) => { + if (marker === m) { + return name; + } + })!; + } + public goToPosition(pos: number) { this.currentCaretPosition = pos; } @@ -421,12 +462,12 @@ namespace FourSlash { } private raiseError(message: string) { - message = this.messageAtLastKnownMarker(message); - throw new Error(message); + throw new Error(this.messageAtLastKnownMarker(message)); } private messageAtLastKnownMarker(message: string) { - return "Marker: " + this.lastKnownMarker + "\n" + message; + const locationDescription = this.lastKnownMarker ? this.lastKnownMarker : this.getLineColStringAtPosition(this.currentCaretPosition); + return `At ${locationDescription}: ${message}`; } private assertionMessageAtLastKnownMarker(msg: string) { @@ -536,53 +577,61 @@ namespace FourSlash { } public verifyGoToDefinitionIs(endMarker: string | string[]) { - this.verifyGoToDefinitionWorker(endMarker instanceof Array ? endMarker : [endMarker]); + this.verifyGoToXWorker(toArray(endMarker), () => this.getGoToDefinition()); } public verifyGoToDefinition(arg0: any, endMarkerNames?: string | string[]) { + this.verifyGoToX(arg0, endMarkerNames, () => this.getGoToDefinition()); + } + + private getGoToDefinition(): ts.DefinitionInfo[] { + return this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition) + } + + public verifyGoToType(arg0: any, endMarkerNames?: string | string[]) { + this.verifyGoToX(arg0, endMarkerNames, () => + this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition)); + } + + private verifyGoToX(arg0: any, endMarkerNames: string | string[] | undefined, getDefs: () => ts.DefinitionInfo[] | undefined) { if (endMarkerNames) { - this.verifyGoToDefinitionPlain(arg0, endMarkerNames); + this.verifyGoToXPlain(arg0, endMarkerNames, getDefs); } - else if (arg0 instanceof Array) { + else if (ts.isArray(arg0)) { const pairs: [string | string[], string | string[]][] = arg0; for (const [start, end] of pairs) { - this.verifyGoToDefinitionPlain(start, end); + this.verifyGoToXPlain(start, end, getDefs); } } else { const obj: { [startMarkerName: string]: string | string[] } = arg0; for (const startMarkerName in obj) { if (ts.hasProperty(obj, startMarkerName)) { - this.verifyGoToDefinitionPlain(startMarkerName, obj[startMarkerName]); + this.verifyGoToXPlain(startMarkerName, obj[startMarkerName], getDefs); } } } } - private verifyGoToDefinitionPlain(startMarkerNames: string | string[], endMarkerNames: string | string[]) { - if (startMarkerNames instanceof Array) { - for (const start of startMarkerNames) { - this.verifyGoToDefinitionSingle(start, endMarkerNames); - } - } - else { - this.verifyGoToDefinitionSingle(startMarkerNames, endMarkerNames); + private verifyGoToXPlain(startMarkerNames: string | string[], endMarkerNames: string | string[], getDefs: () => ts.DefinitionInfo[] | undefined) { + for (const start of toArray(startMarkerNames)) { + this.verifyGoToXSingle(start, endMarkerNames, getDefs); } } public verifyGoToDefinitionForMarkers(markerNames: string[]) { for (const markerName of markerNames) { - this.verifyGoToDefinitionSingle(`${markerName}Reference`, `${markerName}Definition`); + this.verifyGoToXSingle(`${markerName}Reference`, `${markerName}Definition`, () => this.getGoToDefinition()); } } - private verifyGoToDefinitionSingle(startMarkerName: string, endMarkerNames: string | string[]) { + private verifyGoToXSingle(startMarkerName: string, endMarkerNames: string | string[], getDefs: () => ts.DefinitionInfo[] | undefined) { this.goToMarker(startMarkerName); - this.verifyGoToDefinitionWorker(endMarkerNames instanceof Array ? endMarkerNames : [endMarkerNames]); + this.verifyGoToXWorker(toArray(endMarkerNames), getDefs); } - private verifyGoToDefinitionWorker(endMarkers: string[]) { - const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition) || []; + private verifyGoToXWorker(endMarkers: string[], getDefs: () => ts.DefinitionInfo[] | undefined) { + const definitions = getDefs() || []; if (endMarkers.length !== definitions.length) { this.raiseError(`goToDefinitions failed - expected to find ${endMarkers.length} definitions but got ${definitions.length}`); @@ -668,11 +717,12 @@ namespace FourSlash { const completions = this.getCompletionListAtCaret(); const uniqueItems = ts.createMap(); for (const item of completions.entries) { - if (!(item.name in uniqueItems)) { - uniqueItems[item.name] = item.kind; + const uniqueItem = uniqueItems.get(item.name); + if (!uniqueItem) { + uniqueItems.set(item.name, item.kind); } else { - assert.equal(item.kind, uniqueItems[item.name], `Items should have the same kind, got ${item.kind} and ${uniqueItems[item.name]}`); + assert.equal(item.kind, uniqueItem, `Items should have the same kind, got ${item.kind} and ${uniqueItem}`); } } } @@ -706,6 +756,27 @@ namespace FourSlash { } } + public verifyCompletionsAt(markerName: string, expected: string[]) { + this.goToMarker(markerName); + + const actualCompletions = this.getCompletionListAtCaret(); + if (!actualCompletions) { + this.raiseError(`No completions at position '${this.currentCaretPosition}'.`); + } + + const actual = actualCompletions.entries; + + if (actual.length !== expected.length) { + this.raiseError(`Expected ${expected.length} completions, got ${actual.map(a => a.name)}.`); + } + + ts.zipWith(actual, expected, (completion, expectedCompletion, index) => { + if (completion.name !== expectedCompletion) { + this.raiseError(`Expected completion at index ${index} to be ${expectedCompletion}, got ${completion.name}`); + } + }); + } + public verifyCompletionListContains(symbol: string, text?: string, documentation?: string, kind?: string, spanIndex?: number) { const completions = this.getCompletionListAtCaret(); if (completions) { @@ -825,9 +896,8 @@ namespace FourSlash { } } - public verifyReferencesOf({fileName, start}: Range, references: Range[]) { - this.openFile(fileName); - this.goToPosition(start); + public verifyReferencesOf(range: Range, references: Range[]) { + this.goToRangeStart(range); this.verifyReferencesAre(references); } @@ -839,8 +909,74 @@ namespace FourSlash { } } - public verifyRangesWithSameTextReferenceEachOther() { - ts.forEachProperty(this.rangesByText(), ranges => this.verifyRangesReferenceEachOther(ranges)); + public verifyReferenceGroups(startRanges: Range | Range[], parts: Array<{ definition: string, ranges: Range[] }>): void { + interface ReferenceJson { definition: string; ranges: ts.ReferenceEntry[]; } + type ReferencesJson = ReferenceJson[]; + const fullExpected = parts.map(({ definition, ranges }) => ({ definition, ranges: ranges.map(rangeToReferenceEntry) })); + + for (const startRange of toArray(startRanges)) { + this.goToRangeStart(startRange); + const fullActual = this.findReferencesAtCaret().map(({ definition, references }) => ({ + definition: definition.displayParts.map(d => d.text).join(""), + ranges: references + })); + this.assertObjectsEqual(fullActual, fullExpected); + } + + function rangeToReferenceEntry(r: Range) { + let { isWriteAccess, isDefinition } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false }; + isWriteAccess = !!isWriteAccess; isDefinition = !!isDefinition; + return { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition } + } + } + + public verifyNoReferences(markerNameOrRange?: string | Range) { + if (markerNameOrRange) { + if (typeof markerNameOrRange === "string") { + this.goToMarker(markerNameOrRange); + } + else { + this.goToRangeStart(markerNameOrRange); + } + } + + const refs = this.getReferencesAtCaret(); + if (refs && refs.length) { + console.log(refs); + this.raiseError("Expected getReferences to fail"); + } + } + + public verifySingleReferenceGroup(definition: string, ranges?: Range[]) { + ranges = ranges || this.getRanges(); + this.verifyReferenceGroups(ranges, [{ definition, ranges }]); + } + + private assertObjectsEqual(fullActual: T, fullExpected: T, msgPrefix = ""): void { + const recur = (actual: U, expected: U, path: string) => { + const fail = (msg: string) => { + console.log("Expected:", stringify(fullExpected)); + console.log("Actual: ", stringify(fullActual)); + this.raiseError(`${msgPrefix}At ${path}: ${msg}`); + }; + + for (const key in actual) if (ts.hasProperty(actual as any, key)) { + const ak = actual[key], ek = expected[key]; + if (typeof ak === "object" && typeof ek === "object") { + recur(ak, ek, path ? path + "." + key : key); + } + else if (ak !== ek) { + fail(`Expected '${key}' to be '${ek}', got '${ak}'`); + } + } + for (const key in expected) if (ts.hasProperty(expected as any, key)) { + if (!ts.hasProperty(actual as any, key)) { + fail(`${msgPrefix}Missing property '${key}'`); + } + } + }; + recur(fullActual, fullExpected, ""); + } public verifyDisplayPartsOfReferencedSymbol(expected: ts.SymbolDisplayPart[]) { @@ -912,8 +1048,9 @@ namespace FourSlash { } public verifyQuickInfos(namesAndTexts: { [name: string]: string | [string, string] }) { - ts.forEachProperty(ts.createMap(namesAndTexts), (text, name) => { - if (text instanceof Array) { + for (const name in namesAndTexts) if (ts.hasProperty(namesAndTexts, name)) { + const text = namesAndTexts[name]; + if (ts.isArray(text)) { assert(text.length === 2); const [expectedText, expectedDocumentation] = text; this.verifyQuickInfoAt(name, expectedText, expectedDocumentation); @@ -921,7 +1058,7 @@ namespace FourSlash { else { this.verifyQuickInfoAt(name, text); } - }); + } } public verifyQuickInfoString(expectedText: string, expectedDocumentation?: string) { @@ -1350,13 +1487,6 @@ namespace FourSlash { Harness.IO.log(membersString); } - public printReferences() { - const references = this.getReferencesAtCaret(); - ts.forEach(references, entry => { - Harness.IO.log(stringify(entry)); - }); - } - public printContext() { ts.forEach(this.languageServiceAdapterHost.getFilenames(), Harness.IO.log); } @@ -1634,6 +1764,11 @@ namespace FourSlash { this.goToPosition(len); } + public goToRangeStart({fileName, start}: Range) { + this.openFile(fileName); + this.goToPosition(start); + } + public goToTypeDefinition(definitionIndex: number) { const definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); if (!definitions || !definitions.length) { @@ -1759,7 +1894,7 @@ namespace FourSlash { } public getMarkerNames(): string[] { - return Object.keys(this.testData.markerPositions); + return ts.arrayFrom(this.testData.markerPositions.keys()); } public getRanges(): Range[] { @@ -1767,10 +1902,10 @@ namespace FourSlash { } public rangesByText(): ts.Map { - const result = ts.createMap(); + const result = ts.createMultiMap(); for (const range of this.getRanges()) { const text = this.rangeText(range); - ts.multiMapAdd(result, text, range); + result.add(text, range); } return result; } @@ -1983,11 +2118,11 @@ namespace FourSlash { * Compares expected text to the text that would be in the sole range * (ie: [|...|]) in the file after applying the codefix sole codefix * in the source file. - * + * * Because codefixes are only applied on the working file, it is unsafe * to apply this more than once (consider a refactoring across files). */ - public verifyRangeAfterCodeFix(expectedText: string, errorCode?: number) { + public verifyRangeAfterCodeFix(expectedText: string, includeWhiteSpace?: boolean, errorCode?: number, index?: number) { const ranges = this.getRanges(); if (ranges.length !== 1) { this.raiseError("Exactly one range should be specified in the testfile."); @@ -1995,11 +2130,15 @@ namespace FourSlash { const fileName = this.activeFile.fileName; - this.applyCodeFixActions(fileName, this.getCodeFixActions(fileName, errorCode)); + this.applyCodeAction(fileName, this.getCodeFixActions(fileName, errorCode), index); const actualText = this.rangeText(ranges[0]); - if (this.removeWhitespace(actualText) !== this.removeWhitespace(expectedText)) { + const result = includeWhiteSpace + ? actualText === expectedText + : this.removeWhitespace(actualText) === this.removeWhitespace(expectedText) + + if (!result) { this.raiseError(`Actual text doesn't match expected text. Actual:\n'${actualText}'\nExpected:\n'${expectedText}'`); } } @@ -2016,7 +2155,7 @@ namespace FourSlash { public verifyFileAfterCodeFix(expectedContents: string, fileName?: string) { fileName = fileName ? fileName : this.activeFile.fileName; - this.applyCodeFixActions(fileName, this.getCodeFixActions(fileName)); + this.applyCodeAction(fileName, this.getCodeFixActions(fileName)); const actualContents: string = this.getFileContent(fileName); if (this.removeWhitespace(actualContents) !== this.removeWhitespace(expectedContents)) { @@ -2029,10 +2168,18 @@ namespace FourSlash { * @param fileName Path to file where error should be retrieved from. */ private getCodeFixActions(fileName: string, errorCode?: number): ts.CodeAction[] { - const diagnostics: ts.Diagnostic[] = this.getDiagnostics(fileName); + const diagnosticsForCodeFix = this.getDiagnostics(fileName).map(diagnostic => { + return { + start: diagnostic.start, + length: diagnostic.length, + code: diagnostic.code + } + }); + const dedupedDiagnositcs = ts.deduplicate(diagnosticsForCodeFix, ts.equalOwnProperties); let actions: ts.CodeAction[] = undefined; - for (const diagnostic of diagnostics) { + + for (const diagnostic of dedupedDiagnositcs) { if (errorCode && errorCode !== diagnostic.code) { continue; @@ -2046,12 +2193,20 @@ namespace FourSlash { return actions; } - private applyCodeFixActions(fileName: string, actions: ts.CodeAction[]): void { - if (!(actions && actions.length === 1)) { - this.raiseError(`Should find exactly one codefix, but ${actions ? actions.length : "none"} found.`); + private applyCodeAction(fileName: string, actions: ts.CodeAction[], index?: number): void { + if (index === undefined) { + if (!(actions && actions.length === 1)) { + this.raiseError(`Should find exactly one codefix, but ${actions ? actions.length : "none"} found.`); + } + index = 0; + } + else { + if (!(actions && actions.length >= index + 1)) { + this.raiseError(`Should find at least ${index + 1} codefix(es), but ${actions ? actions.length : "none"} found.`); + } } - const fileChanges = ts.find(actions[0].changes, change => change.fileName === fileName); + const fileChanges = ts.find(actions[index].changes, change => change.fileName === fileName); if (!fileChanges) { this.raiseError("The CodeFix found doesn't provide any changes in this file."); } @@ -2126,7 +2281,7 @@ namespace FourSlash { public verifyBraceCompletionAtPosition(negative: boolean, openingBrace: string) { - const openBraceMap = ts.createMap({ + const openBraceMap = ts.createMapFromTemplate({ "(": ts.CharacterCodes.openParen, "{": ts.CharacterCodes.openBrace, "[": ts.CharacterCodes.openBracket, @@ -2136,7 +2291,7 @@ namespace FourSlash { "<": ts.CharacterCodes.lessThan }); - const charCode = openBraceMap[openingBrace]; + const charCode = openBraceMap.get(openingBrace); if (!charCode) { this.raiseError(`Invalid openingBrace '${openingBrace}' specified.`); @@ -2326,40 +2481,60 @@ namespace FourSlash { return this.languageService.getDocumentHighlights(this.activeFile.fileName, this.currentCaretPosition, filesToSearch); } - public verifyDocumentHighlightsAtPositionListContains(fileName: string, start: number, end: number, fileNamesToSearch: string[], kind?: string) { - const documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNamesToSearch); - - if (!documentHighlights || documentHighlights.length === 0) { - this.raiseError("verifyDocumentHighlightsAtPositionListContains failed - found 0 highlights, expected at least one."); + public verifyRangesAreOccurrences(isWriteAccess?: boolean) { + const ranges = this.getRanges(); + for (const r of ranges) { + this.goToRangeStart(r); + this.verifyOccurrencesAtPositionListCount(ranges.length); + for (const range of ranges) { + this.verifyOccurrencesAtPositionListContains(range.fileName, range.start, range.end, isWriteAccess); + } } + } - for (const documentHighlight of documentHighlights) { - if (documentHighlight.fileName === fileName) { - const { highlightSpans } = documentHighlight; + public verifyRangesAreRenameLocations(findInStrings: boolean, findInComments: boolean) { + this.goToEachRange(() => this.verifyRenameLocations(findInStrings, findInComments)); + } - 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}.`); - } - return; - } - } + public verifyRangesWithSameTextAreDocumentHighlights() { + this.rangesByText().forEach(ranges => this.verifyRangesAreDocumentHighlights(ranges)); + } + + public verifyRangesAreDocumentHighlights(ranges?: Range[]) { + ranges = ranges || this.getRanges(); + const fileNames = unique(ranges, range => range.fileName); + for (const range of ranges) { + this.goToRangeStart(range); + this.verifyDocumentHighlights(ranges, fileNames); + } + } + + private verifyDocumentHighlights(expectedRanges: Range[], fileNames: string[] = [this.activeFile.fileName]) { + const documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNames) || []; + + for (const dh of documentHighlights) { + if (fileNames.indexOf(dh.fileName) === -1) { + this.raiseError(`verifyDocumentHighlights failed - got highlights in unexpected file name ${dh.fileName}`); } } - const missingItem = { fileName: fileName, start: start, end: end, kind: kind }; - this.raiseError(`verifyDocumentHighlightsAtPositionListContains failed - could not find the item: ${stringify(missingItem)} in the returned list: (${stringify(documentHighlights)})`); - } + for (const fileName of fileNames) { + const expectedRangesInFile = expectedRanges.filter(r => r.fileName === fileName); + const highlights = ts.find(documentHighlights, dh => dh.fileName === fileName); + if (!highlights) { + this.raiseError(`verifyDocumentHighlights failed - found no highlights in ${fileName}`); + } + const spansInFile = highlights.highlightSpans.sort((s1, s2) => s1.textSpan.start - s2.textSpan.start); - public verifyDocumentHighlightsAtPositionListCount(expectedCount: number, fileNamesToSearch: string[]) { - const documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNamesToSearch); - const actualCount = documentHighlights - ? documentHighlights.reduce((currentCount, { highlightSpans }) => currentCount + highlightSpans.length, 0) - : 0; + if (expectedRangesInFile.length !== spansInFile.length) { + this.raiseError(`verifyDocumentHighlights failed - In ${fileName}, expected ${expectedRangesInFile.length} highlights, got ${spansInFile.length}`); + } - if (expectedCount !== actualCount) { - this.raiseError("verifyDocumentHighlightsAtPositionListCount failed - actual: " + actualCount + ", expected:" + expectedCount); + ts.zipWith(expectedRangesInFile, spansInFile, (expectedRange, span) => { + if (span.textSpan.start !== expectedRange.start || ts.textSpanEnd(span.textSpan) !== expectedRange.end) { + this.raiseError(`verifyDocumentHighlights failed - span does not match, actual: ${JSON.stringify(span.textSpan)}, expected: ${expectedRange.start}--${expectedRange.end}`); + } + }); } } @@ -2492,11 +2667,9 @@ namespace FourSlash { } public getMarkerByName(markerName: string) { - const markerPos = this.testData.markerPositions[markerName]; + const markerPos = this.testData.markerPositions.get(markerName); if (markerPos === undefined) { - 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(", ")}`); + throw new Error(`Unknown marker "${markerName}" Available markers: ${this.getMarkerNames().map(m => "\"" + m + "\"").join(", ")}`); } else { return markerPos; @@ -2589,7 +2762,7 @@ ${code} // we have to string-based splitting instead and try to figure out the delimiting chars const lines = contents.split("\n"); - const markerPositions: MarkerMap = {}; + const markerPositions = ts.createMap(); const markers: Marker[] = []; const ranges: Range[] = []; @@ -2728,7 +2901,7 @@ ${code} throw new Error(errorMessage); } - function recordObjectMarker(fileName: string, location: LocationInformation, text: string, markerMap: MarkerMap, markers: Marker[]): Marker { + function recordObjectMarker(fileName: string, location: LocationInformation, text: string, markerMap: ts.Map, markers: Marker[]): Marker { let markerValue: any = undefined; try { // Attempt to parse the marker value as JSON @@ -2751,7 +2924,7 @@ ${code} // Object markers can be anonymous if (markerValue.name) { - markerMap[markerValue.name] = marker; + markerMap.set(markerValue.name, marker); } markers.push(marker); @@ -2759,26 +2932,26 @@ ${code} return marker; } - function recordMarker(fileName: string, location: LocationInformation, name: string, markerMap: MarkerMap, markers: Marker[]): Marker { + function recordMarker(fileName: string, location: LocationInformation, name: string, markerMap: ts.Map, markers: Marker[]): Marker { const marker: Marker = { fileName, position: location.position }; // Verify markers for uniqueness - if (markerMap[name] !== undefined) { + if (markerMap.has(name)) { const message = "Marker '" + name + "' is duplicated in the source file contents."; reportError(marker.fileName, location.sourceLine, location.sourceColumn, message); return undefined; } else { - markerMap[name] = marker; + markerMap.set(name, marker); markers.push(marker); return marker; } } - function parseFileContent(content: string, fileName: string, markerMap: MarkerMap, markers: Marker[], ranges: Range[]): FourSlashFile { + function parseFileContent(content: string, fileName: string, markerMap: ts.Map, markers: Marker[], ranges: Range[]): FourSlashFile { content = chompLeadingSpace(content); // Any slash-star comment with a character not in this string is not a marker. @@ -2988,6 +3161,20 @@ ${code} function stringify(data: any, replacer?: (key: string, value: any) => any): string { return JSON.stringify(data, replacer, 2); } + + /** Collects an array of unique outputs. */ + function unique(inputs: T[], getOutput: (t: T) => string): string[] { + const set = ts.createMap(); + for (const input of inputs) { + const out = getOutput(input); + set.set(out, true); + } + return ts.arrayFrom(set.keys()); + } + + function toArray(x: T | T[]): T[] { + return ts.isArray(x) ? x : [x]; + } } namespace FourSlashInterface { @@ -3026,10 +3213,22 @@ namespace FourSlashInterface { // Moves the caret to the specified marker, // or the anonymous marker ('/**/') if no name // is given - public marker(name?: string) { + public marker(name?: string | FourSlash.Marker) { this.state.goToMarker(name); } + public eachMarker(action: () => void) { + this.state.goToEachMarker(action); + } + + public rangeStart(range: FourSlash.Range) { + this.state.goToRangeStart(range); + } + + public eachRange(action: () => void) { + this.state.goToEachRange(action); + } + public bof() { this.state.goToBOF(); } @@ -3038,10 +3237,6 @@ namespace FourSlashInterface { this.state.goToEOF(); } - public type(definitionIndex = 0) { - this.state.goToTypeDefinition(definitionIndex); - } - public implementation() { this.state.goToImplementation(); } @@ -3153,6 +3348,10 @@ namespace FourSlashInterface { super(state); } + public completionsAt(markerName: string, completions: string[]) { + this.state.verifyCompletionsAt(markerName, completions); + } + public quickInfoIs(expectedText: string, expectedDocumentation?: string) { this.state.verifyQuickInfoString(expectedText, expectedDocumentation); } @@ -3209,6 +3408,13 @@ namespace FourSlashInterface { this.state.verifyGoToDefinition(arg0, endMarkerName); } + public goToType(startMarkerName: string | string[], endMarkerName: string | string[]): void; + public goToType(startsAndEnds: [string | string[], string | string[]][]): void; + public goToType(startsAndEnds: { [startMarkerName: string]: string | string[] }): void; + public goToType(arg0: any, endMarkerName?: string | string[]) { + this.state.verifyGoToType(arg0, endMarkerName); + } + public goToDefinitionForMarkers(...markerNames: string[]) { this.state.verifyGoToDefinitionForMarkers(markerNames); } @@ -3233,6 +3439,18 @@ namespace FourSlashInterface { this.state.verifyReferencesOf(start, references); } + public referenceGroups(startRanges: FourSlash.Range[], parts: Array<{ definition: string, ranges: FourSlash.Range[] }>) { + this.state.verifyReferenceGroups(startRanges, parts); + } + + public noReferences(markerNameOrRange?: string | FourSlash.Range) { + this.state.verifyNoReferences(markerNameOrRange); + } + + public singleReferenceGroup(definition: string, ranges?: FourSlash.Range[]) { + this.state.verifySingleReferenceGroup(definition, ranges); + } + public rangesReferenceEachOther(ranges?: FourSlash.Range[]) { this.state.verifyRangesReferenceEachOther(ranges); } @@ -3241,10 +3459,6 @@ namespace FourSlashInterface { this.state.verifyDisplayPartsOfReferencedSymbol(expected); } - public rangesWithSameTextReferenceEachOther() { - this.state.verifyRangesWithSameTextReferenceEachOther(); - } - public currentParameterHelpArgumentNameIs(name: string) { this.state.verifyCurrentParameterHelpName(name); } @@ -3329,8 +3543,8 @@ namespace FourSlashInterface { this.DocCommentTemplate(/*expectedText*/ undefined, /*expectedOffset*/ undefined, /*empty*/ true); } - public rangeAfterCodeFix(expectedText: string, errorCode?: number): void { - this.state.verifyRangeAfterCodeFix(expectedText, errorCode); + public rangeAfterCodeFix(expectedText: string, includeWhiteSpace?: boolean, errorCode?: number, index?: number): void { + this.state.verifyRangeAfterCodeFix(expectedText, includeWhiteSpace, errorCode, index); } public importFixAtPosition(expectedTextArray: string[], errorCode?: number): void { @@ -3373,12 +3587,20 @@ namespace FourSlashInterface { this.state.verifyOccurrencesAtPositionListCount(expectedCount); } - public documentHighlightsAtPositionContains(range: FourSlash.Range, fileNamesToSearch: string[], kind?: string) { - this.state.verifyDocumentHighlightsAtPositionListContains(range.fileName, range.start, range.end, fileNamesToSearch, kind); + public rangesAreOccurrences(isWriteAccess?: boolean) { + this.state.verifyRangesAreOccurrences(isWriteAccess); } - public documentHighlightsAtPositionCount(expectedCount: number, fileNamesToSearch: string[]) { - this.state.verifyDocumentHighlightsAtPositionListCount(expectedCount, fileNamesToSearch); + public rangesAreRenameLocations(findInStrings = false, findInComments = false) { + this.state.verifyRangesAreRenameLocations(findInStrings, findInComments); + } + + public rangesAreDocumentHighlights(ranges?: FourSlash.Range[]) { + this.state.verifyRangesAreDocumentHighlights(ranges); + } + + public rangesWithSameTextAreDocumentHighlights() { + this.state.verifyRangesWithSameTextAreDocumentHighlights(); } public completionEntryDetailIs(entryName: string, text: string, documentation?: string, kind?: string) { @@ -3539,10 +3761,6 @@ namespace FourSlashInterface { this.state.printNavigationBar(); } - public printReferences() { - this.state.printReferences(); - } - public printContext() { this.state.printContext(); } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 4094fc773ea..8935da642d4 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -40,6 +40,19 @@ declare namespace NodeJS { ActiveXObject: typeof ActiveXObject; } } + +declare var window: {}; +declare var XMLHttpRequest: { + new(): XMLHttpRequest; +} +interface XMLHttpRequest { + readonly readyState: number; + readonly responseText: string; + readonly status: number; + open(method: string, url: string, async?: boolean, user?: string, password?: string): void; + send(data?: string): void; + setRequestHeader(header: string, value: string): void; +} /* tslint:enable:no-var-keyword */ namespace Utils { @@ -909,19 +922,25 @@ namespace Harness { export const defaultLibFileName = "lib.d.ts"; export const es2015DefaultLibFileName = "lib.es2015.d.ts"; - const libFileNameSourceFileMap = ts.createMap({ + // Cache of lib files from "built/local" + const libFileNameSourceFileMap = ts.createMapFromTemplate({ [defaultLibFileName]: createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.es5.d.ts"), /*languageVersion*/ ts.ScriptTarget.Latest) }); + // Cache of lib files from "tests/lib/" + const testLibFileNameSourceFileMap = ts.createMap(); + const es6TestLibFileNameSourceFileMap = ts.createMap(); + export function getDefaultLibrarySourceFile(fileName = defaultLibFileName): ts.SourceFile { if (!isDefaultLibraryFile(fileName)) { return undefined; } - if (!libFileNameSourceFileMap[fileName]) { - libFileNameSourceFileMap[fileName] = createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest); + let sourceFile = libFileNameSourceFileMap.get(fileName); + if (!sourceFile) { + libFileNameSourceFileMap.set(fileName, sourceFile = createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest)); } - return libFileNameSourceFileMap[fileName]; + return sourceFile; } export function getDefaultLibFileName(options: ts.CompilerOptions): string { @@ -953,7 +972,8 @@ namespace Harness { useCaseSensitiveFileNames: boolean, // the currentDirectory is needed for rwcRunner to passed in specified current directory to compiler host currentDirectory: string, - newLineKind?: ts.NewLineKind): ts.CompilerHost { + newLineKind?: ts.NewLineKind, + libFiles?: string): ts.CompilerHost { // Local get canonical file name function, that depends on passed in parameter for useCaseSensitiveFileNames const getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); @@ -985,6 +1005,24 @@ namespace Harness { } } + if (libFiles) { + // Because @libFiles don't change between execution. We would cache the result of the files and reuse it to speed help compilation + for (const fileName of libFiles.split(",")) { + const libFileName = "tests/lib/" + fileName; + + if (scriptTarget <= ts.ScriptTarget.ES5) { + if (!testLibFileNameSourceFileMap.get(libFileName)) { + testLibFileNameSourceFileMap.set(libFileName, createSourceFileAndAssertInvariants(libFileName, IO.readFile(libFileName), scriptTarget)); + } + } + else { + if (!es6TestLibFileNameSourceFileMap.get(libFileName)) { + es6TestLibFileNameSourceFileMap.set(libFileName, createSourceFileAndAssertInvariants(libFileName, IO.readFile(libFileName), scriptTarget)) + } + } + } + } + function getSourceFile(fileName: string) { fileName = ts.normalizePath(fileName); const fromFileMap = fileMap.get(toPath(fileName)); @@ -996,6 +1034,9 @@ namespace Harness { fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget); return fourslashSourceFile; } + else if (ts.startsWith(fileName, "tests/lib/")) { + return scriptTarget <= ts.ScriptTarget.ES5 ? testLibFileNameSourceFileMap.get(fileName) : es6TestLibFileNameSourceFileMap.get(fileName); + } else { // Don't throw here -- the compiler might be looking for a test that actually doesn't exist as part of the TC // Return if it is other library file, otherwise return undefined @@ -1103,10 +1144,10 @@ namespace Harness { optionsIndex = ts.createMap(); const optionDeclarations = harnessOptionDeclarations.concat(ts.optionDeclarations); for (const option of optionDeclarations) { - optionsIndex[option.name.toLowerCase()] = option; + optionsIndex.set(option.name.toLowerCase(), option); } } - return optionsIndex[name.toLowerCase()]; + return optionsIndex.get(name.toLowerCase()); } export function setCompilerOptionsFromHarnessSetting(settings: Harness.TestCaseParser.CompilerSettings, options: ts.CompilerOptions & HarnessOptions): void { @@ -1207,7 +1248,8 @@ namespace Harness { if (options.libFiles) { for (const fileName of options.libFiles.split(",")) { const libFileName = "tests/lib/" + fileName; - programFiles.push({ unitName: libFileName, content: normalizeLineEndings(IO.readFile(libFileName), Harness.IO.newLine()) }); + // Content is undefined here because in createCompilerHost we will create sourceFile for the lib file and cache the result + programFiles.push({ unitName: libFileName, content: undefined }); } } @@ -1220,7 +1262,8 @@ namespace Harness { options.target, useCaseSensitiveFileNames, currentDirectory, - options.newLine); + options.newLine, + options.libFiles); let traceResults: string[]; if (options.traceResolution) { @@ -1466,7 +1509,7 @@ namespace Harness { const fullResults = ts.createMap(); for (const sourceFile of allFiles) { - fullResults[sourceFile.unitName] = fullWalker.getTypeAndSymbols(sourceFile.unitName); + fullResults.set(sourceFile.unitName, fullWalker.getTypeAndSymbols(sourceFile.unitName)); } // Produce baselines. The first gives the types for all expressions. @@ -1519,7 +1562,7 @@ namespace Harness { allFiles.forEach(file => { const codeLines = file.content.split("\n"); - typeWriterResults[file.unitName].forEach(result => { + typeWriterResults.get(file.unitName).forEach(result => { if (isSymbolBaseline && !result.symbol) { return; } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index a49f8926729..202b429fcbc 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -5,7 +5,7 @@ namespace Harness.LanguageService { export class ScriptInfo { - public version: number = 1; + public version = 1; public editRanges: { length: number; textChangeRange: ts.TextChangeRange; }[] = []; private lineMap: number[] = undefined; @@ -126,7 +126,7 @@ namespace Harness.LanguageService { protected virtualFileSystem: Utils.VirtualFileSystem = new Utils.VirtualFileSystem(virtualFileSystemRoot, /*useCaseSensitiveFilenames*/false); constructor(protected cancellationToken = DefaultHostCancellationToken.Instance, - protected settings = ts.getDefaultCompilerOptions()) { + protected settings = ts.getDefaultCompilerOptions()) { } public getNewLine(): string { @@ -135,7 +135,7 @@ namespace Harness.LanguageService { public getFilenames(): string[] { const fileNames: string[] = []; - for (const virtualEntry of this.virtualFileSystem.getAllFileEntries()){ + for (const virtualEntry of this.virtualFileSystem.getAllFileEntries()) { const scriptInfo = virtualEntry.content; if (scriptInfo.isRootFile) { // only include root files here @@ -211,8 +211,8 @@ namespace Harness.LanguageService { readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[] { return ts.matchFiles(path, extensions, exclude, include, /*useCaseSensitiveFileNames*/false, - this.getCurrentDirectory(), - (p) => this.virtualFileSystem.getAccessibleFileSystemEntries(p)); + this.getCurrentDirectory(), + (p) => this.virtualFileSystem.getAccessibleFileSystemEntries(p)); } readFile(path: string): string { const snapshot = this.getScriptSnapshot(path); @@ -262,7 +262,7 @@ namespace Harness.LanguageService { this.getModuleResolutionsForFile = (fileName) => { const scriptInfo = this.getScriptInfo(fileName); const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ true); - const imports = ts.createMap(); + const imports: ts.MapLike = {}; for (const module of preprocessInfo.importedFiles) { const resolutionInfo = ts.resolveModuleName(module.fileName, fileName, compilerOptions, moduleResolutionHost); if (resolutionInfo.resolvedModule) { @@ -275,7 +275,7 @@ namespace Harness.LanguageService { const scriptInfo = this.getScriptInfo(fileName); if (scriptInfo) { const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ false); - const resolutions = ts.createMap(); + const resolutions: ts.MapLike = {}; const settings = this.nativeHost.getCompilationSettings(); for (const typeReferenceDirective of preprocessInfo.typeReferenceDirectives) { const resolutionInfo = ts.resolveTypeReferenceDirective(typeReferenceDirective.fileName, fileName, settings, moduleResolutionHost); @@ -594,7 +594,7 @@ namespace Harness.LanguageService { class SessionServerHost implements ts.server.ServerHost, ts.server.Logger { args: string[] = []; newLine: string; - useCaseSensitiveFileNames: boolean = false; + useCaseSensitiveFileNames = false; constructor(private host: NativeLanguageServiceHost) { this.newLine = this.host.getNewLine(); @@ -724,6 +724,87 @@ namespace Harness.LanguageService { createHash(s: string) { return s; } + + require(_initialDir: string, _moduleName: string): ts.server.RequireResult { + switch (_moduleName) { + // Adds to the Quick Info a fixed string and a string from the config file + // and replaces the first display part + case "quickinfo-augmeneter": + return { + module: () => ({ + create(info: ts.server.PluginCreateInfo) { + const proxy = makeDefaultProxy(info); + const langSvc: any = info.languageService; + proxy.getQuickInfoAtPosition = function () { + const parts = langSvc.getQuickInfoAtPosition.apply(langSvc, arguments); + if (parts.displayParts.length > 0) { + parts.displayParts[0].text = "Proxied"; + } + parts.displayParts.push({ text: info.config.message, kind: "punctuation" }); + return parts; + }; + + return proxy; + } + }), + error: undefined + }; + + // Throws during initialization + case "create-thrower": + return { + module: () => ({ + create() { + throw new Error("I am not a well-behaved plugin"); + } + }), + error: undefined + }; + + // Adds another diagnostic + case "diagnostic-adder": + return { + module: () => ({ + create(info: ts.server.PluginCreateInfo) { + const proxy = makeDefaultProxy(info); + proxy.getSemanticDiagnostics = function (filename: string) { + const prev = info.languageService.getSemanticDiagnostics(filename); + const sourceFile: ts.SourceFile = info.languageService.getSourceFile(filename); + prev.push({ + category: ts.DiagnosticCategory.Warning, + file: sourceFile, + code: 9999, + length: 3, + messageText: `Plugin diagnostic`, + start: 0 + }); + return prev; + } + return proxy; + } + }), + error: undefined + }; + + default: + return { + module: undefined, + error: "Could not resolve module" + }; + } + + function makeDefaultProxy(info: ts.server.PluginCreateInfo) { + // tslint:disable-next-line:no-null-keyword + const proxy = Object.create(null); + const langSvc: any = info.languageService; + for (const k of Object.keys(langSvc)) { + proxy[k] = function () { + return langSvc[k].apply(langSvc, arguments); + }; + } + return proxy; + } + } } export class ServerLanguageServiceAdapter implements LanguageServiceAdapter { @@ -738,7 +819,7 @@ namespace Harness.LanguageService { // host to answer server queries about files on disk const serverHost = new SessionServerHost(clientHost); const server = new ts.server.Session(serverHost, - { isCancellationRequested: () => false }, + ts.server.nullCancellationToken, /*useOneInferredProject*/ false, /*typingsInstaller*/ undefined, Utils.byteLength, diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index f7541dc9bfe..f1cc992c4a7 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -256,17 +256,20 @@ class ProjectRunner extends RunnerBase { // Set the values specified using json const optionNameMap = ts.arrayToMap(ts.optionDeclarations, option => option.name); for (const name in testCase) { - if (name !== "mapRoot" && name !== "sourceRoot" && name in optionNameMap) { - const option = optionNameMap[name]; - const optType = option.type; - let value = testCase[name]; - if (typeof optType !== "string") { - const key = value.toLowerCase(); - if (key in optType) { - value = optType[key]; + if (name !== "mapRoot" && name !== "sourceRoot") { + const option = optionNameMap.get(name); + if (option) { + const optType = option.type; + let value = testCase[name]; + if (typeof optType !== "string") { + const key = value.toLowerCase(); + const optTypeValue = optType.get(key); + if (optTypeValue) { + value = optTypeValue; + } } + compilerOptions[option.name] = value; } - compilerOptions[option.name] = value; } } diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 6b83cf249a7..32af0eb2601 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -1,19 +1,12 @@ { + "extends": "../tsconfig-base", "compilerOptions": { - "noImplicitAny": true, - "pretty": true, "removeComments": false, - "preserveConstEnums": true, "outFile": "../../built/local/run.js", - "sourceMap": true, "declaration": false, - "stripInternal": true, "types": [ "node", "mocha", "chai" - ], - "target": "es5", - "noUnusedLocals": true, - "noUnusedParameters": true + ] }, "files": [ "../compiler/core.ts", @@ -84,8 +77,8 @@ "../services/codefixes/helpers.ts", "../services/codefixes/importFixes.ts", "../services/codefixes/unusedIdentifierFixes.ts", - "../services/harness.ts", - + + "harness.ts", "sourceMapRecorder.ts", "harnessLanguageService.ts", "fourslash.ts", @@ -125,6 +118,9 @@ "./unittests/initializeTSConfig.ts", "./unittests/compileOnSave.ts", "./unittests/typingsInstaller.ts", - "./unittests/projectErrors.ts" + "./unittests/projectErrors.ts", + "./unittests/printer.ts", + "./unittests/transform.ts", + "./unittests/customTransforms.ts" ] } diff --git a/src/harness/unittests/cachingInServerLSHost.ts b/src/harness/unittests/cachingInServerLSHost.ts index 4286d3555d8..caeab18958e 100644 --- a/src/harness/unittests/cachingInServerLSHost.ts +++ b/src/harness/unittests/cachingInServerLSHost.ts @@ -1,4 +1,4 @@ -/// +/// namespace ts { interface File { @@ -8,25 +8,28 @@ namespace ts { function createDefaultServerHost(fileMap: Map): server.ServerHost { const existingDirectories = createMap(); - for (const name in fileMap) { + forEachKey(fileMap, name => { let dir = getDirectoryPath(name); let previous: string; do { - existingDirectories[dir] = true; + existingDirectories.set(dir, true); previous = dir; dir = getDirectoryPath(dir); } while (dir !== previous); - } + }); return { args: [], newLine: "\r\n", useCaseSensitiveFileNames: false, write: noop, - readFile: path => path in fileMap ? fileMap[path].content : undefined, + readFile: path => { + const file = fileMap.get(path); + return file && file.content; + }, writeFile: notImplemented, resolvePath: notImplemented, - fileExists: path => path in fileMap, - directoryExists: path => existingDirectories[path] || false, + fileExists: path => fileMap.has(path), + directoryExists: path => existingDirectories.get(path) || false, createDirectory: noop, getExecutingFilePath: () => "", getCurrentDirectory: () => "", @@ -83,7 +86,7 @@ namespace ts { content: `foo()` }; - const serverHost = createDefaultServerHost(createMap({ [root.name]: root, [imported.name]: imported })); + const serverHost = createDefaultServerHost(createMapFromTemplate({ [root.name]: root, [imported.name]: imported })); const { project, rootScriptInfo } = createProject(root.name, serverHost); // ensure that imported file was found @@ -167,7 +170,7 @@ namespace ts { content: `export var y = 1` }; - const fileMap = createMap({ [root.name]: root }); + const fileMap = createMapFromTemplate({ [root.name]: root }); const serverHost = createDefaultServerHost(fileMap); const originalFileExists = serverHost.fileExists; @@ -191,7 +194,7 @@ namespace ts { assert.isTrue(typeof diags[0].messageText === "string" && ((diags[0].messageText).indexOf("Cannot find module") === 0), "should be 'cannot find module' message"); // assert that import will success once file appear on disk - fileMap[imported.name] = imported; + fileMap.set(imported.name, imported); fileExistsCalledForBar = false; rootScriptInfo.editContent(0, root.content.length, `import {y} from "bar"`); diff --git a/src/harness/unittests/commandLineParsing.ts b/src/harness/unittests/commandLineParsing.ts index 8c691992043..8e5ed5f3534 100644 --- a/src/harness/unittests/commandLineParsing.ts +++ b/src/harness/unittests/commandLineParsing.ts @@ -60,7 +60,7 @@ namespace ts { assertParseResult(["--lib", "es5,invalidOption", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string'", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'esnext.asynciterable'", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, @@ -87,7 +87,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--jsx' option must be: 'preserve', 'react'", + messageText: "Argument for '--jsx' option must be: 'preserve', 'react-native', 'react'", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, @@ -263,7 +263,7 @@ namespace ts { assertParseResult(["--lib", "es5,", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string'", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'esnext.asynciterable'", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, @@ -283,7 +283,7 @@ namespace ts { assertParseResult(["--lib", "es5, ", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string'", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'esnext.asynciterable'", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, diff --git a/src/harness/unittests/compileOnSave.ts b/src/harness/unittests/compileOnSave.ts index c8deb9e7554..48558b5c1a3 100644 --- a/src/harness/unittests/compileOnSave.ts +++ b/src/harness/unittests/compileOnSave.ts @@ -4,6 +4,7 @@ namespace ts.projectSystem { import CommandNames = server.CommandNames; + const nullCancellationToken = server.nullCancellationToken; function createTestTypingsInstaller(host: server.ServerHost) { return new TestTypingsInstaller("/a/data/", /*throttleLimit*/5, host); @@ -520,7 +521,7 @@ namespace ts.projectSystem { const expectedEmittedFileName = "/a/b/f1.js"; assert.isTrue(host.fileExists(expectedEmittedFileName)); - assert.equal(host.readFile(expectedEmittedFileName), `"use strict";\r\nfunction Foo() { return 10; }\r\nexports.Foo = Foo;\r\n`); + assert.equal(host.readFile(expectedEmittedFileName), `"use strict";\r\nexports.__esModule = true;\r\nfunction Foo() { return 10; }\r\nexports.Foo = Foo;\r\n`); }); it("shoud not emit js files in external projects", () => { diff --git a/src/harness/unittests/configurationExtension.ts b/src/harness/unittests/configurationExtension.ts index 8e845925eb2..886ee5d54b5 100644 --- a/src/harness/unittests/configurationExtension.ts +++ b/src/harness/unittests/configurationExtension.ts @@ -2,7 +2,7 @@ /// namespace ts { - const testContents = { + const testContents = createMapFromTemplate({ "/dev/tsconfig.json": `{ "extends": "./configs/base", "files": [ @@ -86,10 +86,10 @@ namespace ts { "/dev/tests/utils.ts": "", "/dev/tests/scenarios/first.json": "", "/dev/tests/baselines/first/output.ts": "" - }; + }); const caseInsensitiveBasePath = "c:/dev/"; - const caseInsensitiveHost = new Utils.MockParseConfigHost(caseInsensitiveBasePath, /*useCaseSensitiveFileNames*/ false, mapObject(testContents, (key, content) => [`c:${key}`, content])); + const caseInsensitiveHost = new Utils.MockParseConfigHost(caseInsensitiveBasePath, /*useCaseSensitiveFileNames*/ false, mapEntries(testContents, (key, content) => [`c:${key}`, content])); const caseSensitiveBasePath = "/dev/"; const caseSensitiveHost = new Utils.MockParseConfigHost(caseSensitiveBasePath, /*useCaseSensitiveFileNames*/ true, testContents); diff --git a/src/harness/unittests/convertCompilerOptionsFromJson.ts b/src/harness/unittests/convertCompilerOptionsFromJson.ts index f44dc259710..26ca8e26df1 100644 --- a/src/harness/unittests/convertCompilerOptionsFromJson.ts +++ b/src/harness/unittests/convertCompilerOptionsFromJson.ts @@ -94,7 +94,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--jsx' option must be: 'preserve', 'react'", + messageText: "Argument for '--jsx' option must be: 'preserve', 'react-native', 'react'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] @@ -233,7 +233,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string'", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'esnext.asynciterable'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] @@ -264,7 +264,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string'", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'esnext.asynciterable'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] @@ -295,7 +295,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string'", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'esnext.asynciterable'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] @@ -326,7 +326,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string'", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'esnext', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'esnext.asynciterable'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] diff --git a/src/harness/unittests/customTransforms.ts b/src/harness/unittests/customTransforms.ts new file mode 100644 index 00000000000..4b05ebb9ea7 --- /dev/null +++ b/src/harness/unittests/customTransforms.ts @@ -0,0 +1,86 @@ +/// +/// + +namespace ts { + describe("customTransforms", () => { + function emitsCorrectly(name: string, sources: { file: string, text: string }[], customTransformers: CustomTransformers) { + it(name, () => { + const roots = sources.map(source => createSourceFile(source.file, source.text, ScriptTarget.ES2015)); + const fileMap = arrayToMap(roots, file => file.fileName); + const outputs = createMap(); + const options: CompilerOptions = {}; + const host: CompilerHost = { + getSourceFile: (fileName) => fileMap.get(fileName), + getDefaultLibFileName: () => "lib.d.ts", + getCurrentDirectory: () => "", + getDirectories: () => [], + getCanonicalFileName: (fileName) => fileName, + useCaseSensitiveFileNames: () => true, + getNewLine: () => "\n", + fileExists: (fileName) => fileMap.has(fileName), + readFile: (fileName) => fileMap.has(fileName) ? fileMap.get(fileName).text : undefined, + writeFile: (fileName, text) => outputs.set(fileName, text), + }; + + const program = createProgram(arrayFrom(fileMap.keys()), options, host); + program.emit(/*targetSourceFile*/ undefined, host.writeFile, /*cancellationToken*/ undefined, /*emitOnlyDtsFiles*/ false, customTransformers); + Harness.Baseline.runBaseline(`customTransforms/${name}.js`, () => { + let content = ""; + for (const [file, text] of arrayFrom(outputs.entries())) { + if (content) content += "\n\n"; + content += `// [${file}]\n`; + content += text; + } + return content; + }); + }); + } + + const sources = [{ + file: "source.ts", + text: ` + function f1() { } + class c() { } + enum e { } + // leading + function f2() { } // trailing + ` + }]; + + const before: TransformerFactory = context => { + return file => visitEachChild(file, visit, context); + function visit(node: Node): VisitResult { + switch (node.kind) { + case SyntaxKind.FunctionDeclaration: + return visitFunction(node); + default: + return visitEachChild(node, visit, context); + } + } + function visitFunction(node: FunctionDeclaration) { + addSyntheticLeadingComment(node, SyntaxKind.MultiLineCommentTrivia, "@before", /*hasTrailingNewLine*/ true); + return node; + } + }; + + const after: TransformerFactory = context => { + return file => visitEachChild(file, visit, context); + function visit(node: Node): VisitResult { + switch (node.kind) { + case SyntaxKind.VariableStatement: + return visitVariableStatement(node); + default: + return visitEachChild(node, visit, context); + } + } + function visitVariableStatement(node: VariableStatement) { + addSyntheticLeadingComment(node, SyntaxKind.SingleLineCommentTrivia, "@after"); + return node; + } + }; + + emitsCorrectly("before", sources, { before: [before] }); + emitsCorrectly("after", sources, { after: [after] }); + emitsCorrectly("both", sources, { before: [before], after: [after] }); + }); +} \ No newline at end of file diff --git a/src/harness/unittests/jsDocParsing.ts b/src/harness/unittests/jsDocParsing.ts index addd01b0e0a..98c32c77778 100644 --- a/src/harness/unittests/jsDocParsing.ts +++ b/src/harness/unittests/jsDocParsing.ts @@ -288,5 +288,24 @@ namespace ts { */`); }); }); + describe("getFirstToken", () => { + it("gets jsdoc", () => { + const root = ts.createSourceFile("foo.ts", "/** comment */var a = true;", ts.ScriptTarget.ES5, /*setParentNodes*/ true); + assert.isDefined(root); + assert.equal(root.kind, ts.SyntaxKind.SourceFile); + const first = root.getFirstToken(); + assert.isDefined(first); + assert.equal(first.kind, ts.SyntaxKind.VarKeyword); + }); + }); + describe("getLastToken", () => { + it("gets jsdoc", () => { + const root = ts.createSourceFile("foo.ts", "var a = true;/** comment */", ts.ScriptTarget.ES5, /*setParentNodes*/ true); + assert.isDefined(root); + const last = root.getLastToken(); + assert.isDefined(last); + assert.equal(last.kind, ts.SyntaxKind.EndOfFileToken); + }); + }); }); } diff --git a/src/harness/unittests/matchFiles.ts b/src/harness/unittests/matchFiles.ts index c562fcefe91..0a450c50151 100644 --- a/src/harness/unittests/matchFiles.ts +++ b/src/harness/unittests/matchFiles.ts @@ -346,9 +346,9 @@ namespace ts { fileNames: [ "c:/dev/a.ts", "c:/dev/b.ts", + "c:/dev/node_modules/a.ts", "c:/dev/bower_components/a.ts", - "c:/dev/jspm_packages/a.ts", - "c:/dev/node_modules/a.ts" + "c:/dev/jspm_packages/a.ts" ], wildcardDirectories: {}, }; @@ -373,9 +373,9 @@ namespace ts { options: {}, errors: [], fileNames: [ + "c:/dev/node_modules/a.ts", "c:/dev/bower_components/a.ts", - "c:/dev/jspm_packages/a.ts", - "c:/dev/node_modules/a.ts" + "c:/dev/jspm_packages/a.ts" ], wildcardDirectories: {}, }; @@ -398,9 +398,9 @@ namespace ts { fileNames: [ "c:/dev/a.ts", "c:/dev/b.ts", + "c:/dev/node_modules/a.ts", "c:/dev/bower_components/a.ts", - "c:/dev/jspm_packages/a.ts", - "c:/dev/node_modules/a.ts" + "c:/dev/jspm_packages/a.ts" ], wildcardDirectories: {}, }; @@ -410,6 +410,36 @@ namespace ts { }); describe("with wildcard include list", () => { + it("is sorted in include order, then in alphabetical order", () => { + const json = { + include: [ + "z/*.ts", + "x/*.ts" + ] + }; + const expected: ts.ParsedCommandLine = { + options: {}, + errors: [], + fileNames: [ + "c:/dev/z/a.ts", + "c:/dev/z/aba.ts", + "c:/dev/z/abz.ts", + "c:/dev/z/b.ts", + "c:/dev/z/bba.ts", + "c:/dev/z/bbz.ts", + "c:/dev/x/a.ts", + "c:/dev/x/aa.ts", + "c:/dev/x/b.ts" + ], + wildcardDirectories: { + "c:/dev/z": ts.WatchDirectoryFlags.None, + "c:/dev/x": ts.WatchDirectoryFlags.None + }, + }; + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + assertParsed(actual, expected); + }); + it("same named declarations are excluded", () => { const json = { include: [ @@ -506,8 +536,8 @@ namespace ts { options: {}, errors: [], fileNames: [ - "c:/dev/x/a.ts", "c:/dev/x/y/a.ts", + "c:/dev/x/a.ts", "c:/dev/z/a.ts" ], wildcardDirectories: { @@ -909,6 +939,31 @@ namespace ts { const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath); assertParsed(actual, expected); }); + it("with jsx=react-native, allowJs=false", () => { + const json = { + compilerOptions: { + jsx: "react-native", + allowJs: false + } + }; + const expected: ts.ParsedCommandLine = { + options: { + jsx: ts.JsxEmit.ReactNative, + allowJs: false + }, + errors: [], + fileNames: [ + "c:/dev/a.ts", + "c:/dev/b.tsx", + "c:/dev/c.tsx", + ], + wildcardDirectories: { + "c:/dev": ts.WatchDirectoryFlags.Recursive + } + }; + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath); + assertParsed(actual, expected); + }); it("with jsx=none, allowJs=true", () => { const json = { compilerOptions: { @@ -961,6 +1016,33 @@ namespace ts { const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath); assertParsed(actual, expected); }); + it("with jsx=react-native, allowJs=true", () => { + const json = { + compilerOptions: { + jsx: "react-native", + allowJs: true + } + }; + const expected: ts.ParsedCommandLine = { + options: { + jsx: ts.JsxEmit.ReactNative, + allowJs: true + }, + errors: [], + fileNames: [ + "c:/dev/a.ts", + "c:/dev/b.tsx", + "c:/dev/c.tsx", + "c:/dev/d.js", + "c:/dev/e.jsx", + ], + wildcardDirectories: { + "c:/dev": ts.WatchDirectoryFlags.Recursive + } + }; + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath); + assertParsed(actual, expected); + }); it("exclude .min.js files using wildcards", () => { const json = { compilerOptions: { @@ -1230,8 +1312,8 @@ namespace ts { options: {}, errors: [], fileNames: [ - "c:/dev/.z/.b.ts", - "c:/dev/x/.y/a.ts" + "c:/dev/x/.y/a.ts", + "c:/dev/.z/.b.ts" ], wildcardDirectories: {} }; @@ -1271,8 +1353,8 @@ namespace ts { options: {}, errors: [], fileNames: [ - "c:/dev/.z/.b.ts", - "c:/dev/x/.y/a.ts" + "c:/dev/x/.y/a.ts", + "c:/dev/.z/.b.ts" ], wildcardDirectories: { "c:/dev/.z": ts.WatchDirectoryFlags.Recursive, @@ -1306,4 +1388,4 @@ namespace ts { }); }); }); -} \ No newline at end of file +} diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index 35313e15308..aa30f1e01e2 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -36,7 +36,7 @@ namespace ts { for (const f of files) { let name = getDirectoryPath(f.name); while (true) { - directories[name] = name; + directories.set(name, name); const baseName = getDirectoryPath(name); if (baseName === name) { break; @@ -46,20 +46,19 @@ namespace ts { } return { readFile, - directoryExists: path => { - return path in directories; - }, + directoryExists: path => directories.has(path), fileExists: path => { - assert.isTrue(getDirectoryPath(path) in directories, `'fileExists' '${path}' request in non-existing directory`); - return path in map; + assert.isTrue(directories.has(getDirectoryPath(path)), `'fileExists' '${path}' request in non-existing directory`); + return map.has(path); } }; } else { - return { readFile, fileExists: path => path in map, }; + return { readFile, fileExists: path => map.has(path) }; } function readFile(path: string): string { - return path in map ? map[path].content : undefined; + const file = map.get(path); + return file && file.content; } } @@ -300,7 +299,8 @@ namespace ts { const host: CompilerHost = { getSourceFile: (fileName: string, languageVersion: ScriptTarget) => { const path = normalizePath(combinePaths(currentDirectory, fileName)); - return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined; + const file = files.get(path); + return file && createSourceFile(fileName, file, languageVersion); }, getDefaultLibFileName: () => "lib.d.ts", writeFile: notImplemented, @@ -311,7 +311,7 @@ namespace ts { useCaseSensitiveFileNames: () => false, fileExists: fileName => { const path = normalizePath(combinePaths(currentDirectory, fileName)); - return path in files; + return files.has(path); }, readFile: notImplemented }; @@ -331,7 +331,7 @@ namespace ts { } it("should find all modules", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/b/c/first/shared.ts": ` class A {} export = A`, @@ -350,7 +350,7 @@ export = C; }); it("should find modules in node_modules", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/parent/node_modules/mod/index.d.ts": "export var x", "/parent/app/myapp.ts": `import {x} from "mod"` }); @@ -358,7 +358,7 @@ export = C; }); it("should find file referenced via absolute and relative names", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/b/c.ts": `/// `, "/a/b/b.ts": "var x" }); @@ -371,7 +371,11 @@ export = C; function test(files: Map, options: CompilerOptions, currentDirectory: string, useCaseSensitiveFileNames: boolean, rootFiles: string[], diagnosticCodes: number[]): void { const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); if (!useCaseSensitiveFileNames) { - files = reduceProperties(files, (files, file, fileName) => (files[getCanonicalFileName(fileName)] = file, files), createMap()); + const oldFiles = files; + files = createMap(); + oldFiles.forEach((file, fileName) => { + files.set(getCanonicalFileName(fileName), file); + }); } const host: CompilerHost = { @@ -380,7 +384,8 @@ export = C; return library; } const path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName))); - return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined; + const file = files.get(path); + return file && createSourceFile(fileName, file, languageVersion); }, getDefaultLibFileName: () => "lib.d.ts", writeFile: notImplemented, @@ -391,7 +396,7 @@ export = C; useCaseSensitiveFileNames: () => useCaseSensitiveFileNames, fileExists: fileName => { const path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName))); - return path in files; + return files.has(path); }, readFile: notImplemented }; @@ -404,7 +409,7 @@ export = C; } it("should succeed when the same file is referenced using absolute and relative names", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/b/c.ts": `/// `, "/a/b/d.ts": "var x" }); @@ -412,7 +417,7 @@ export = C; }); it("should fail when two files used in program differ only in casing (tripleslash references)", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/b/c.ts": `/// `, "/a/b/d.ts": "var x" }); @@ -420,7 +425,7 @@ export = C; }); it("should fail when two files used in program differ only in casing (imports)", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/b/c.ts": `import {x} from "D"`, "/a/b/d.ts": "export var x" }); @@ -428,7 +433,7 @@ export = C; }); it("should fail when two files used in program differ only in casing (imports, relative module names)", () => { - const files = createMap({ + const files = createMapFromTemplate({ "moduleA.ts": `import {x} from "./ModuleB"`, "moduleB.ts": "export var x" }); @@ -436,7 +441,7 @@ export = C; }); it("should fail when two files exist on disk that differs only in casing", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/b/c.ts": `import {x} from "D"`, "/a/b/D.ts": "export var x", "/a/b/d.ts": "export var y" @@ -445,7 +450,7 @@ export = C; }); it("should fail when module name in 'require' calls has inconsistent casing", () => { - const files = createMap({ + const files = createMapFromTemplate({ "moduleA.ts": `import a = require("./ModuleC")`, "moduleB.ts": `import a = require("./moduleC")`, "moduleC.ts": "export var x" @@ -454,7 +459,7 @@ export = C; }); it("should fail when module names in 'require' calls has inconsistent casing and current directory has uppercase chars", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/B/c/moduleA.ts": `import a = require("./ModuleC")`, "/a/B/c/moduleB.ts": `import a = require("./moduleC")`, "/a/B/c/moduleC.ts": "export var x", @@ -466,7 +471,7 @@ import b = require("./moduleB"); test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "/a/B/c", /*useCaseSensitiveFileNames*/ false, ["moduleD.ts"], [1149]); }); it("should not fail when module names in 'require' calls has consistent casing and current directory has uppercase chars", () => { - const files = createMap({ + const files = createMapFromTemplate({ "/a/B/c/moduleA.ts": `import a = require("./moduleC")`, "/a/B/c/moduleB.ts": `import a = require("./moduleC")`, "/a/B/c/moduleC.ts": "export var x", @@ -1020,8 +1025,8 @@ import b = require("./moduleB"); const names = map(files, f => f.name); const sourceFiles = arrayToMap(map(files, f => createSourceFile(f.name, f.content, ScriptTarget.ES2015)), f => f.fileName); const compilerHost: CompilerHost = { - fileExists : fileName => fileName in sourceFiles, - getSourceFile: fileName => sourceFiles[fileName], + fileExists : fileName => sourceFiles.has(fileName), + getSourceFile: fileName => sourceFiles.get(fileName), getDefaultLibFileName: () => "lib.d.ts", writeFile: notImplemented, getCurrentDirectory: () => "/", @@ -1029,7 +1034,10 @@ import b = require("./moduleB"); getCanonicalFileName: f => f.toLowerCase(), getNewLine: () => "\r\n", useCaseSensitiveFileNames: () => false, - readFile: fileName => fileName in sourceFiles ? sourceFiles[fileName].text : undefined + readFile: fileName => { + const file = sourceFiles.get(fileName); + return file && file.text; + } }; const program1 = createProgram(names, {}, compilerHost); const diagnostics1 = program1.getFileProcessingDiagnostics().getDiagnostics(); diff --git a/src/harness/unittests/printer.ts b/src/harness/unittests/printer.ts new file mode 100644 index 00000000000..2496a880bc5 --- /dev/null +++ b/src/harness/unittests/printer.ts @@ -0,0 +1,97 @@ +/// +/// + +namespace ts { + describe("PrinterAPI", () => { + function makePrintsCorrectly(prefix: string) { + return function printsCorrectly(name: string, options: PrinterOptions, printCallback: (printer: Printer) => string) { + it(name, () => { + Harness.Baseline.runBaseline(`printerApi/${prefix}.${name}.js`, () => + printCallback(createPrinter({ newLine: NewLineKind.CarriageReturnLineFeed, ...options }))); + }); + } + } + + describe("printFile", () => { + const printsCorrectly = makePrintsCorrectly("printsFileCorrectly"); + const sourceFile = createSourceFile("source.ts", ` + interface A { + // comment1 + readonly prop?: T; + + // comment2 + method(): void; + + // comment3 + new (): A; + + // comment4 + (): A; + } + + // comment5 + type B = number | string | object; + type C = A & { x: string; }; // comment6 + + // comment7 + enum E1 { + // comment8 + first + } + + const enum E2 { + second + } + + // comment9 + console.log(1 + 2); + `, ScriptTarget.ES2015); + + printsCorrectly("default", {}, printer => printer.printFile(sourceFile)); + printsCorrectly("removeComments", { removeComments: true }, printer => printer.printFile(sourceFile)); + }); + + describe("printBundle", () => { + const printsCorrectly = makePrintsCorrectly("printsBundleCorrectly"); + const bundle = createBundle([ + createSourceFile("a.ts", ` + /*! [a.ts] */ + + // comment0 + const a = 1; + `, ScriptTarget.ES2015), + createSourceFile("b.ts", ` + /*! [b.ts] */ + + // comment1 + const b = 2; + `, ScriptTarget.ES2015) + ]); + printsCorrectly("default", {}, printer => printer.printBundle(bundle)); + printsCorrectly("removeComments", { removeComments: true }, printer => printer.printBundle(bundle)); + }); + + describe("printNode", () => { + const printsCorrectly = makePrintsCorrectly("printsNodeCorrectly"); + const sourceFile = createSourceFile("source.ts", "", ScriptTarget.ES2015); + const syntheticNode = createClassDeclaration( + undefined, + undefined, + /*name*/ createIdentifier("C"), + undefined, + undefined, + createNodeArray([ + createProperty( + undefined, + createNodeArray([createToken(SyntaxKind.PublicKeyword)]), + createIdentifier("prop"), + undefined, + undefined, + undefined + ) + ]) + ); + printsCorrectly("class", {}, printer => printer.printNode(EmitHint.Unspecified, syntheticNode, sourceFile)); + }); + }); +} diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 6dbd74e71d2..d13dd7a26fa 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { @@ -122,7 +122,7 @@ namespace ts { trace: s => trace.push(s), getTrace: () => trace, getSourceFile(fileName): SourceFile { - return files[fileName]; + return files.get(fileName); }, getDefaultLibFileName(): string { return "lib.d.ts"; @@ -143,9 +143,10 @@ namespace ts { getNewLine(): string { return sys ? sys.newLine : newLine; }, - fileExists: fileName => fileName in files, + fileExists: fileName => files.has(fileName), readFile: fileName => { - return fileName in files ? files[fileName].text : undefined; + const file = files.get(fileName); + return file && file.text; }, }; } @@ -188,10 +189,24 @@ namespace ts { } else { assert.isTrue(cache !== undefined, `expected ${caption} to be set`); - assert.isTrue(equalOwnProperties(expectedContent, cache, entryChecker), `contents of ${caption} did not match the expected contents.`); + assert.isTrue(mapsAreEqual(expectedContent, cache, entryChecker), `contents of ${caption} did not match the expected contents.`); } } + /** True if the maps have the same keys and values. */ + function mapsAreEqual(left: Map, right: Map, valuesAreEqual?: (left: T, right: T) => boolean): boolean { + if (left === right) return true; + if (!left || !right) return false; + const someInLeftHasNoMatch = forEachEntry(left, (leftValue, leftKey) => { + if (!right.has(leftKey)) return true; + const rightValue = right.get(leftKey); + return !(valuesAreEqual ? valuesAreEqual(leftValue, rightValue) : leftValue === rightValue); + }); + if (someInLeftHasNoMatch) return false; + const someInRightHasNoMatch = forEachKey(right, rightKey => !left.has(rightKey)); + return !someInRightHasNoMatch; + } + function checkResolvedModulesCache(program: Program, fileName: string, expectedContent: Map): void { checkCache("resolved modules", program, fileName, expectedContent, f => f.resolvedModules, checkResolvedModule); } @@ -307,7 +322,7 @@ namespace ts { const options: CompilerOptions = { target }; const program_1 = newProgram(files, ["a.ts"], options); - checkResolvedModulesCache(program_1, "a.ts", createMap({ "b": createResolvedModule("b.ts") })); + checkResolvedModulesCache(program_1, "a.ts", createMapFromTemplate({ "b": createResolvedModule("b.ts") })); checkResolvedModulesCache(program_1, "b.ts", undefined); const program_2 = updateProgram(program_1, ["a.ts"], options, files => { @@ -316,7 +331,7 @@ namespace ts { assert.isTrue(program_1.structureIsReused); // content of resolution cache should not change - checkResolvedModulesCache(program_1, "a.ts", createMap({ "b": createResolvedModule("b.ts") })); + checkResolvedModulesCache(program_1, "a.ts", createMapFromTemplate({ "b": createResolvedModule("b.ts") })); checkResolvedModulesCache(program_1, "b.ts", undefined); // imports has changed - program is not reused @@ -333,7 +348,7 @@ namespace ts { files[0].text = files[0].text.updateImportsAndExports(newImports); }); assert.isTrue(!program_3.structureIsReused); - checkResolvedModulesCache(program_4, "a.ts", createMap({ "b": createResolvedModule("b.ts"), "c": undefined })); + checkResolvedModulesCache(program_4, "a.ts", createMapFromTemplate({ "b": createResolvedModule("b.ts"), "c": undefined })); }); it("resolved type directives cache follows type directives", () => { @@ -344,7 +359,7 @@ namespace ts { const options: CompilerOptions = { target, typeRoots: ["/types"] }; const program_1 = newProgram(files, ["/a.ts"], options); - checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMap({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); + checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMapFromTemplate({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); checkResolvedTypeDirectivesCache(program_1, "/types/typedefs/index.d.ts", undefined); const program_2 = updateProgram(program_1, ["/a.ts"], options, files => { @@ -353,7 +368,7 @@ namespace ts { assert.isTrue(program_1.structureIsReused); // content of resolution cache should not change - checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMap({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); + checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMapFromTemplate({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); checkResolvedTypeDirectivesCache(program_1, "/types/typedefs/index.d.ts", undefined); // type reference directives has changed - program is not reused @@ -371,7 +386,7 @@ namespace ts { files[0].text = files[0].text.updateReferences(newReferences); }); assert.isTrue(!program_3.structureIsReused); - checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMap({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); + checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMapFromTemplate({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); }); it("can reuse ambient module declarations from non-modified files", () => { diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index 8800e84474b..8d306a6099b 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -1,4 +1,4 @@ -/// +/// const expect: typeof _chai.expect = _chai.expect; @@ -27,7 +27,7 @@ namespace ts.server { clearImmediate: noop, createHash: s => s }; - const nullCancellationToken: HostCancellationToken = { isCancellationRequested: () => false }; + const mockLogger: Logger = { close: noop, hasLevel(): boolean { return false; }, @@ -416,14 +416,15 @@ namespace ts.server { class InProcClient { private server: InProcSession; private seq = 0; - private callbacks = createMap<(resp: protocol.Response) => void>(); + private callbacks: Array<(resp: protocol.Response) => void> = []; private eventHandlers = createMap<(args: any) => void>(); handle(msg: protocol.Message): void { if (msg.type === "response") { const response = msg; - if (response.request_seq in this.callbacks) { - this.callbacks[response.request_seq](response); + const handler = this.callbacks[response.request_seq]; + if (handler) { + handler(response); delete this.callbacks[response.request_seq]; } } @@ -434,13 +435,14 @@ namespace ts.server { } emit(name: string, args: any): void { - if (name in this.eventHandlers) { - this.eventHandlers[name](args); + const handler = this.eventHandlers.get(name); + if (handler) { + handler(args); } } on(name: string, handler: (args: any) => void): void { - this.eventHandlers[name] = handler; + this.eventHandlers.set(name, handler); } connect(session: InProcSession): void { diff --git a/src/harness/unittests/transform.ts b/src/harness/unittests/transform.ts new file mode 100644 index 00000000000..ae2caf4f23b --- /dev/null +++ b/src/harness/unittests/transform.ts @@ -0,0 +1,43 @@ +/// +/// + +namespace ts { + describe("TransformAPI", () => { + function transformsCorrectly(name: string, source: string, transformers: TransformerFactory[]) { + it(name, () => { + Harness.Baseline.runBaseline(`transformApi/transformsCorrectly.${name}.js`, () => { + const transformed = transform(createSourceFile("source.ts", source, ScriptTarget.ES2015), transformers); + const printer = createPrinter({ newLine: NewLineKind.CarriageReturnLineFeed }, { + onEmitNode: transformed.emitNodeWithNotification, + substituteNode: transformed.substituteNode + }); + const result = printer.printBundle(createBundle(transformed.transformed)); + transformed.dispose(); + return result; + }); + }); + } + + transformsCorrectly("substitution", ` + var a = undefined; + `, [ + context => { + const previousOnSubstituteNode = context.onSubstituteNode; + context.enableSubstitution(SyntaxKind.Identifier); + context.onSubstituteNode = (hint, node) => { + node = previousOnSubstituteNode(hint, node); + if (hint === EmitHint.Expression && node.kind === SyntaxKind.Identifier && (node).text === "undefined") { + node = createPartiallyEmittedExpression( + addSyntheticTrailingComment( + setTextRange( + createVoidZero(), + node), + SyntaxKind.MultiLineCommentTrivia, "undefined")); + } + return node; + }; + return file => file; + } + ]); + }); +} diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 9d8a1fe084d..7446cc84deb 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts.projectSystem { @@ -34,10 +34,6 @@ namespace ts.projectSystem { getLogFileName: (): string => undefined }; - export const nullCancellationToken: HostCancellationToken = { - isCancellationRequested: () => false - }; - export const { content: libFileContent } = Harness.getDefaultLibraryFile(Harness.IO); export const libFile: FileOrFolder = { path: "/a/lib/lib.d.ts", @@ -158,17 +154,33 @@ namespace ts.projectSystem { } class TestSession extends server.Session { + private seq = 0; + getProjectService() { return this.projectService; } + + public getSeq() { + return this.seq; + } + + public getNextSeq() { + return this.seq + 1; + } + + public executeCommandSeq(request: Partial) { + this.seq++; + request.seq = this.seq; + request.type = "request"; + return this.executeCommand(request); + } }; - export function createSession(host: server.ServerHost, typingsInstaller?: server.ITypingsInstaller, projectServiceEventHandler?: server.ProjectServiceEventHandler) { + export function createSession(host: server.ServerHost, typingsInstaller?: server.ITypingsInstaller, projectServiceEventHandler?: server.ProjectServiceEventHandler, cancellationToken?: server.ServerCancellationToken) { if (typingsInstaller === undefined) { typingsInstaller = new TestTypingsInstaller("/a/data/", /*throttleLimit*/5, host); } - - return new TestSession(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ projectServiceEventHandler !== undefined, projectServiceEventHandler); + return new TestSession(host, cancellationToken || server.nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ projectServiceEventHandler !== undefined, projectServiceEventHandler); } export interface CreateProjectServiceParameters { @@ -191,7 +203,7 @@ namespace ts.projectSystem { } } export function createProjectService(host: server.ServerHost, parameters: CreateProjectServiceParameters = {}) { - const cancellationToken = parameters.cancellationToken || nullCancellationToken; + const cancellationToken = parameters.cancellationToken || server.nullCancellationToken; const logger = parameters.logger || nullLogger; const useSingleInferredProject = parameters.useSingleInferredProject !== undefined ? parameters.useSingleInferredProject : false; return new TestProjectService(host, logger, cancellationToken, useSingleInferredProject, parameters.typingsInstaller, parameters.eventHandler); @@ -244,9 +256,9 @@ namespace ts.projectSystem { } export function checkMapKeys(caption: string, map: Map, expectedKeys: string[]) { - assert.equal(reduceProperties(map, count => count + 1, 0), expectedKeys.length, `${caption}: incorrect size of map`); + assert.equal(map.size, expectedKeys.length, `${caption}: incorrect size of map`); for (const name of expectedKeys) { - assert.isTrue(name in map, `${caption} is expected to contain ${name}, actual keys: ${Object.keys(map)}`); + assert.isTrue(map.has(name), `${caption} is expected to contain ${name}, actual keys: ${arrayFrom(map.keys())}`); } } @@ -292,7 +304,7 @@ namespace ts.projectSystem { } export class Callbacks { - private map: { [n: number]: TimeOutCallback } = {}; + private map: TimeOutCallback[] = []; private nextId = 1; register(cb: (...args: any[]) => void, args: any[]) { @@ -310,20 +322,16 @@ namespace ts.projectSystem { count() { let n = 0; for (const _ in this.map) { - // TODO: GH#11734 - _; n++; } return n; } invoke() { - for (const id in this.map) { - if (hasProperty(this.map, id)) { - this.map[id](); - } + for (const key in this.map) { + this.map[key](); } - this.map = {}; + this.map = []; } } @@ -332,14 +340,16 @@ namespace ts.projectSystem { export class TestServerHost implements server.ServerHost { args: string[] = []; + private readonly output: string[] = []; + private fs: ts.FileMap; private getCanonicalFileName: (s: string) => string; private toPath: (f: string) => Path; private timeoutCallbacks = new Callbacks(); private immediateCallbacks = new Callbacks(); - readonly watchedDirectories = createMap<{ cb: DirectoryWatcherCallback, recursive: boolean }[]>(); - readonly watchedFiles = createMap(); + readonly watchedDirectories = createMultiMap<{ cb: DirectoryWatcherCallback, recursive: boolean }>(); + readonly watchedFiles = createMultiMap(); private filesOrFolders: FileOrFolder[]; @@ -425,11 +435,11 @@ namespace ts.projectSystem { watchDirectory(directoryName: string, callback: DirectoryWatcherCallback, recursive: boolean): DirectoryWatcher { const path = this.toPath(directoryName); const cbWithRecursive = { cb: callback, recursive }; - multiMapAdd(this.watchedDirectories, path, cbWithRecursive); + this.watchedDirectories.add(path, cbWithRecursive); return { referenceCount: 0, directoryName, - close: () => multiMapRemove(this.watchedDirectories, path, cbWithRecursive) + close: () => this.watchedDirectories.remove(path, cbWithRecursive) }; } @@ -439,7 +449,7 @@ namespace ts.projectSystem { triggerDirectoryWatcherCallback(directoryName: string, fileName: string): void { const path = this.toPath(directoryName); - const callbacks = this.watchedDirectories[path]; + const callbacks = this.watchedDirectories.get(path); if (callbacks) { for (const callback of callbacks) { callback.cb(fileName); @@ -449,7 +459,7 @@ namespace ts.projectSystem { triggerFileWatcherCallback(fileName: string, removed?: boolean): void { const path = this.toPath(fileName); - const callbacks = this.watchedFiles[path]; + const callbacks = this.watchedFiles.get(path); if (callbacks) { for (const callback of callbacks) { callback(path, removed); @@ -459,8 +469,8 @@ namespace ts.projectSystem { watchFile(fileName: string, callback: FileWatcherCallback) { const path = this.toPath(fileName); - multiMapAdd(this.watchedFiles, path, callback); - return { close: () => multiMapRemove(this.watchedFiles, path, callback) }; + this.watchedFiles.add(path, callback); + return { close: () => this.watchedFiles.remove(path, callback) }; } // TOOD: record and invoke callbacks to simulate timer events @@ -481,6 +491,10 @@ namespace ts.projectSystem { this.timeoutCallbacks.invoke(); } + runQueuedImmediateCallbacks() { + this.immediateCallbacks.invoke(); + } + setImmediate(callback: TimeOutCallback, _time: number, ...args: any[]) { return this.immediateCallbacks.register(callback, args); } @@ -513,7 +527,17 @@ namespace ts.projectSystem { this.reloadFS(filesOrFolders); } - write() { } + write(message: string) { + this.output.push(message); + } + + getOutput(): ReadonlyArray { + return this.output; + } + + clearOutput() { + this.output.length = 0; + } readonly readFile = (s: string) => (this.fs.get(this.toPath(s))).content; readonly resolvePath = (s: string) => s; @@ -1593,6 +1617,41 @@ namespace ts.projectSystem { checkProjectActualFiles(projectService.inferredProjects[1], [file2.path]); }); + it ("loading files with correct priority", () => { + const f1 = { + path: "/a/main.ts", + content: "let x = 1" + }; + const f2 = { + path: "/a/main.js", + content: "var y = 1" + }; + const config = { + path: "/a/tsconfig.json", + content: JSON.stringify({ + compilerOptions: { allowJs: true } + }) + }; + const host = createServerHost([f1, f2, config]); + const projectService = createProjectService(host); + projectService.setHostConfiguration({ + extraFileExtensions: [ + { extension: ".js", isMixedContent: false }, + { extension: ".html", isMixedContent: true } + ] + }); + projectService.openClientFile(f1.path); + projectService.checkNumberOfProjects({ configuredProjects: 1 }); + checkProjectActualFiles(projectService.configuredProjects[0], [ f1.path ]); + + projectService.closeClientFile(f1.path); + + projectService.openClientFile(f2.path); + projectService.checkNumberOfProjects({ configuredProjects: 1, inferredProjects: 1 }); + checkProjectActualFiles(projectService.configuredProjects[0], [ f1.path ]); + checkProjectActualFiles(projectService.inferredProjects[0], [ f2.path ]); + }); + it("tsconfig script block support", () => { const file1 = { path: "/a/b/f1.ts", @@ -1620,7 +1679,7 @@ namespace ts.projectSystem { const configureHostRequest = makeSessionRequest(CommandNames.Configure, { extraFileExtensions }); session.executeCommand(configureHostRequest).response; - // HTML file still not included in the project as it is closed + // HTML file still not included in the project as it is closed checkNumberOfProjects(projectService, { configuredProjects: 1 }); checkProjectActualFiles(projectService.configuredProjects[0], [file1.path]); @@ -1654,6 +1713,115 @@ namespace ts.projectSystem { assert(completions && completions.entries[0].name !== "hello", `unexpected hello entry in completion list`); }); + it("no tsconfig script block diagnostic errors", () => { + + // #1. Ensure no diagnostic errors when allowJs is true + const file1 = { + path: "/a/b/f1.ts", + content: ` ` + }; + const file2 = { + path: "/a/b/f2.html", + content: `var hello = "hello";` + }; + const config1 = { + path: "/a/b/tsconfig.json", + content: JSON.stringify({ compilerOptions: { allowJs: true } }) + }; + + let host = createServerHost([file1, file2, config1, libFile], { executingFilePath: combinePaths(getDirectoryPath(libFile.path), "tsc.js") }); + let session = createSession(host); + + // Specify .html extension as mixed content in a configure host request + const extraFileExtensions = [{ extension: ".html", scriptKind: ScriptKind.JS, isMixedContent: true }]; + const configureHostRequest = makeSessionRequest(CommandNames.Configure, { extraFileExtensions }); + session.executeCommand(configureHostRequest).response; + + openFilesForSession([file1], session); + let projectService = session.getProjectService(); + + checkNumberOfProjects(projectService, { configuredProjects: 1 }); + + let diagnostics = projectService.configuredProjects[0].getLanguageService().getCompilerOptionsDiagnostics(); + assert.deepEqual(diagnostics, []); + + // #2. Ensure no errors when allowJs is false + const config2 = { + path: "/a/b/tsconfig.json", + content: JSON.stringify({ compilerOptions: { allowJs: false } }) + }; + + host = createServerHost([file1, file2, config2, libFile], { executingFilePath: combinePaths(getDirectoryPath(libFile.path), "tsc.js") }); + session = createSession(host); + + session.executeCommand(configureHostRequest).response; + + openFilesForSession([file1], session); + projectService = session.getProjectService(); + + checkNumberOfProjects(projectService, { configuredProjects: 1 }); + + diagnostics = projectService.configuredProjects[0].getLanguageService().getCompilerOptionsDiagnostics(); + assert.deepEqual(diagnostics, []); + + // #3. Ensure no errors when compiler options aren't specified + const config3 = { + path: "/a/b/tsconfig.json", + content: JSON.stringify({ }) + }; + + host = createServerHost([file1, file2, config3, libFile], { executingFilePath: combinePaths(getDirectoryPath(libFile.path), "tsc.js") }); + session = createSession(host); + + session.executeCommand(configureHostRequest).response; + + openFilesForSession([file1], session); + projectService = session.getProjectService(); + + checkNumberOfProjects(projectService, { configuredProjects: 1 }); + + diagnostics = projectService.configuredProjects[0].getLanguageService().getCompilerOptionsDiagnostics(); + assert.deepEqual(diagnostics, []); + + // #4. Ensure no errors when files are explicitly specified in tsconfig + const config4 = { + path: "/a/b/tsconfig.json", + content: JSON.stringify({ compilerOptions: { allowJs: true }, files: [file1.path, file2.path] }) + }; + + host = createServerHost([file1, file2, config4, libFile], { executingFilePath: combinePaths(getDirectoryPath(libFile.path), "tsc.js") }); + session = createSession(host); + + session.executeCommand(configureHostRequest).response; + + openFilesForSession([file1], session); + projectService = session.getProjectService(); + + checkNumberOfProjects(projectService, { configuredProjects: 1 }); + + diagnostics = projectService.configuredProjects[0].getLanguageService().getCompilerOptionsDiagnostics(); + assert.deepEqual(diagnostics, []); + + // #4. Ensure no errors when files are explicitly excluded in tsconfig + const config5 = { + path: "/a/b/tsconfig.json", + content: JSON.stringify({ compilerOptions: { allowJs: true }, exclude: [file2.path] }) + }; + + host = createServerHost([file1, file2, config5, libFile], { executingFilePath: combinePaths(getDirectoryPath(libFile.path), "tsc.js") }); + session = createSession(host); + + session.executeCommand(configureHostRequest).response; + + openFilesForSession([file1], session); + projectService = session.getProjectService(); + + checkNumberOfProjects(projectService, { configuredProjects: 1 }); + + diagnostics = projectService.configuredProjects[0].getLanguageService().getCompilerOptionsDiagnostics(); + assert.deepEqual(diagnostics, []); + }); + it("project structure update is deferred if files are not added\removed", () => { const file1 = { path: "/a/b/f1.ts", @@ -2867,6 +3035,33 @@ namespace ts.projectSystem { const inferredProject = projectService.inferredProjects[0]; assert.isTrue(inferredProject.containsFile(file1.path)); }); + + it("should be able to handle @types if input file list is empty", () => { + const f = { + path: "/a/app.ts", + content: "let x = 1" + }; + const config = { + path: "/a/tsconfig.json", + content: JSON.stringify({ + compiler: {}, + files: [] + }) + }; + const t1 = { + path: "/a/node_modules/@types/typings/index.d.ts", + content: `export * from "./lib"` + }; + const t2 = { + path: "/a/node_modules/@types/typings/lib.d.ts", + content: `export const x: number` + }; + const host = createServerHost([f, config, t1, t2], { currentDirectory: getDirectoryPath(f.path) }); + const projectService = createProjectService(host); + + projectService.openClientFile(f.path); + projectService.checkNumberOfProjects({ configuredProjects: 1, inferredProjects: 1 }); + }); }); describe("reload", () => { @@ -3035,6 +3230,54 @@ namespace ts.projectSystem { }); }); + describe("emit with outFile or out setting", () => { + function test(opts: CompilerOptions, expectedUsesOutFile: boolean) { + const f1 = { + path: "/a/a.ts", + content: "let x = 1" + }; + const f2 = { + path: "/a/b.ts", + content: "let y = 1" + }; + const config = { + path: "/a/tsconfig.json", + content: JSON.stringify({ + compilerOptions: opts, + compileOnSave: true + }) + }; + const host = createServerHost([f1, f2, config]); + const session = createSession(host); + session.executeCommand({ + seq: 1, + type: "request", + command: "open", + arguments: { file: f1.path } + }); + checkNumberOfProjects(session.getProjectService(), { configuredProjects: 1 }); + const { response } = session.executeCommand({ + seq: 2, + type: "request", + command: "compileOnSaveAffectedFileList", + arguments: { file: f1.path } + }); + assert.equal((response).length, 1, "expected output for 1 project"); + assert.equal((response)[0].fileNames.length, 2, "expected output for 1 project"); + assert.equal((response)[0].projectUsesOutFile, expectedUsesOutFile, "usesOutFile"); + } + + it ("projectUsesOutFile should not be returned if not set", () => { + test({}, /*expectedUsesOutFile*/ false); + }); + it ("projectUsesOutFile should be true if outFile is set", () => { + test({ outFile: "/a/out.js" }, /*expectedUsesOutFile*/ true); + }); + it ("projectUsesOutFile should be true if out is set", () => { + test({ out: "/a/out.js" }, /*expectedUsesOutFile*/ true); + }); + }); + describe("import helpers", () => { it("should not crash in tsserver", () => { const f1 = { @@ -3051,4 +3294,252 @@ namespace ts.projectSystem { service.checkNumberOfProjects({ externalProjects: 1 }); }); }); + + describe("cancellationToken", () => { + it("is attached to request", () => { + const f1 = { + path: "/a/b/app.ts", + content: "let xyz = 1;" + }; + const host = createServerHost([f1]); + let expectedRequestId: number; + const cancellationToken: server.ServerCancellationToken = { + isCancellationRequested: () => false, + setRequest: requestId => { + if (expectedRequestId === undefined) { + assert.isTrue(false, "unexpected call") + } + assert.equal(requestId, expectedRequestId); + }, + resetRequest: noop + } + const session = createSession(host, /*typingsInstaller*/ undefined, /*projectServiceEventHandler*/ undefined, cancellationToken); + + expectedRequestId = session.getNextSeq(); + session.executeCommandSeq({ + command: "open", + arguments: { file: f1.path } + }); + + expectedRequestId = session.getNextSeq(); + session.executeCommandSeq({ + command: "geterr", + arguments: { files: [f1.path] } + }); + + expectedRequestId = session.getNextSeq(); + session.executeCommandSeq({ + command: "occurrences", + arguments: { file: f1.path, line: 1, offset: 6 } + }); + + expectedRequestId = 2; + host.runQueuedImmediateCallbacks(); + expectedRequestId = 2; + host.runQueuedImmediateCallbacks(); + }); + + it("Geterr is cancellable", () => { + const f1 = { + path: "/a/app.ts", + content: "let x = 1" + }; + const config = { + path: "/a/tsconfig.json", + content: JSON.stringify({ + compilerOptions: {} + }) + }; + + let requestToCancel = -1; + const cancellationToken: server.ServerCancellationToken = (function(){ + let currentId: number; + return { + setRequest(requestId) { + currentId = requestId; + }, + resetRequest(requestId) { + assert.equal(requestId, currentId, "unexpected request id in cancellation") + currentId = undefined; + }, + isCancellationRequested() { + return requestToCancel === currentId; + } + } + })(); + const host = createServerHost([f1, config]); + const session = createSession(host, /*typingsInstaller*/ undefined, () => {}, cancellationToken); + { + session.executeCommandSeq({ + command: "open", + arguments: { file: f1.path } + }); + // send geterr for missing file + session.executeCommandSeq({ + command: "geterr", + arguments: { files: ["/a/missing"] } + }); + // no files - expect 'completed' event + assert.equal(host.getOutput().length, 1, "expect 1 message"); + verifyRequestCompleted(session.getSeq(), 0); + } + { + const getErrId = session.getNextSeq(); + // send geterr for a valid file + session.executeCommandSeq({ + command: "geterr", + arguments: { files: [f1.path] } + }); + + assert.equal(host.getOutput().length, 0, "expect 0 messages"); + + // run new request + session.executeCommandSeq({ + command: "projectInfo", + arguments: { file: f1.path } + }); + host.clearOutput(); + + // cancel previously issued Geterr + requestToCancel = getErrId; + host.runQueuedTimeoutCallbacks(); + + assert.equal(host.getOutput().length, 1, "expect 1 message"); + verifyRequestCompleted(getErrId, 0); + + requestToCancel = -1; + } + { + const getErrId = session.getNextSeq(); + session.executeCommandSeq({ + command: "geterr", + arguments: { files: [f1.path] } + }); + assert.equal(host.getOutput().length, 0, "expect 0 messages"); + + // run first step + host.runQueuedTimeoutCallbacks(); + assert.equal(host.getOutput().length, 1, "expect 1 messages"); + const e1 = getMessage(0); + assert.equal(e1.event, "syntaxDiag"); + host.clearOutput(); + + requestToCancel = getErrId; + host.runQueuedImmediateCallbacks(); + assert.equal(host.getOutput().length, 1, "expect 1 message"); + verifyRequestCompleted(getErrId, 0); + + requestToCancel = -1; + } + { + const getErrId = session.getNextSeq(); + session.executeCommandSeq({ + command: "geterr", + arguments: { files: [f1.path] } + }); + assert.equal(host.getOutput().length, 0, "expect 0 messages"); + + // run first step + host.runQueuedTimeoutCallbacks(); + assert.equal(host.getOutput().length, 1, "expect 1 messages"); + const e1 = getMessage(0); + assert.equal(e1.event, "syntaxDiag"); + host.clearOutput(); + + host.runQueuedImmediateCallbacks(); + assert.equal(host.getOutput().length, 2, "expect 2 messages"); + const e2 = getMessage(0); + assert.equal(e2.event, "semanticDiag"); + verifyRequestCompleted(getErrId, 1); + + requestToCancel = -1; + } + { + const getErr1 = session.getNextSeq(); + session.executeCommandSeq({ + command: "geterr", + arguments: { files: [f1.path] } + }); + assert.equal(host.getOutput().length, 0, "expect 0 messages"); + // run first step + host.runQueuedTimeoutCallbacks(); + assert.equal(host.getOutput().length, 1, "expect 1 messages"); + const e1 = getMessage(0); + assert.equal(e1.event, "syntaxDiag"); + host.clearOutput(); + + session.executeCommandSeq({ + command: "geterr", + arguments: { files: [f1.path] } + }); + // make sure that getErr1 is completed + verifyRequestCompleted(getErr1, 0); + } + + function verifyRequestCompleted(expectedSeq: number, n: number) { + const event = getMessage(n); + assert.equal(event.event, "requestCompleted"); + assert.equal(event.body.request_seq, expectedSeq, "expectedSeq"); + host.clearOutput(); + } + + function getMessage(n: number) { + return JSON.parse(server.extractMessage(host.getOutput()[n])); + } + }); + }); + + describe("maxNodeModuleJsDepth for inferred projects", () => { + it("should be set to 2 if the project has js root files", () => { + const file1: FileOrFolder = { + path: "/a/b/file1.js", + content: `var t = require("test"); t.` + }; + const moduleFile: FileOrFolder = { + path: "/a/b/node_modules/test/index.js", + content: `var v = 10; module.exports = v;` + }; + + const host = createServerHost([file1, moduleFile]); + const projectService = createProjectService(host); + projectService.openClientFile(file1.path); + + let project = projectService.inferredProjects[0]; + let options = project.getCompilerOptions(); + assert.isTrue(options.maxNodeModuleJsDepth === 2); + + // Assert the option sticks + projectService.setCompilerOptionsForInferredProjects({ target: ScriptTarget.ES2016 }); + project = projectService.inferredProjects[0]; + options = project.getCompilerOptions(); + assert.isTrue(options.maxNodeModuleJsDepth === 2); + }); + + it("should return to normal state when all js root files are removed from project", () => { + const file1 = { + path: "/a/file1.ts", + content: "let x =1;" + }; + const file2 = { + path: "/a/file2.js", + content: "let x =1;" + }; + + const host = createServerHost([file1, file2, libFile]); + const projectService = createProjectService(host, { useSingleInferredProject: true }); + + projectService.openClientFile(file1.path); + checkNumberOfInferredProjects(projectService, 1); + let project = projectService.inferredProjects[0]; + assert.isUndefined(project.getCompilerOptions().maxNodeModuleJsDepth); + + projectService.openClientFile(file2.path); + project = projectService.inferredProjects[0]; + assert.isTrue(project.getCompilerOptions().maxNodeModuleJsDepth === 2); + + projectService.closeClientFile(file2.path); + project = projectService.inferredProjects[0]; + assert.isUndefined(project.getCompilerOptions().maxNodeModuleJsDepth); + }); + }); } \ No newline at end of file diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index 62d2f7ac801..29076df80f2 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -14,7 +14,7 @@ namespace ts.projectSystem { function createTypesRegistry(...list: string[]): Map { const map = createMap(); for (const l of list) { - map[l] = undefined; + map.set(l, undefined); } return map; } @@ -44,6 +44,47 @@ namespace ts.projectSystem { }); } + import typingsName = server.typingsInstaller.typingsName; + + describe("local module", () => { + it("should not be picked up", () => { + const f1 = { + path: "/a/app.js", + content: "const c = require('./config');" + }; + const f2 = { + path: "/a/config.js", + content: "export let x = 1" + }; + const typesCache = "/cache" + const typesConfig = { + path: typesCache + "/node_modules/@types/config/index.d.ts", + content: "export let y: number;" + }; + const config = { + path: "/a/jsconfig.json", + content: JSON.stringify({ + compilerOptions: { moduleResolution: "commonjs" }, + typeAcquisition: { enable: true } + }) + }; + const host = createServerHost([f1, f2, config, typesConfig]); + const installer = new (class extends Installer { + constructor() { + super(host, { typesRegistry: createTypesRegistry("config"), globalTypingsCacheLocation: typesCache }); + } + installWorker(_requestId: number, _args: string[], _cwd: string, _cb: server.typingsInstaller.RequestCompletedAction) { + assert(false, "should not be called") + } + })(); + const service = createProjectService(host, { typingsInstaller: installer }); + service.openClientFile(f1.path); + service.checkNumberOfProjects({ configuredProjects: 1 }); + checkProjectActualFiles(service.configuredProjects[0], [f1.path, f2.path]); + installer.installAll(0); + }); + }); + describe("typingsInstaller", () => { it("configured projects (typings installed) 1", () => { const file1 = { @@ -519,32 +560,32 @@ namespace ts.projectSystem { const commander = { path: "/a/data/node_modules/@types/commander/index.d.ts", content: "declare const commander: { x: number }", - typings: "@types/commander" + typings: typingsName("commander") }; const jquery = { path: "/a/data/node_modules/@types/jquery/index.d.ts", content: "declare const jquery: { x: number }", - typings: "@types/jquery" + typings: typingsName("jquery") }; const lodash = { path: "/a/data/node_modules/@types/lodash/index.d.ts", content: "declare const lodash: { x: number }", - typings: "@types/lodash" + typings: typingsName("lodash") }; const cordova = { path: "/a/data/node_modules/@types/cordova/index.d.ts", content: "declare const cordova: { x: number }", - typings: "@types/cordova" + typings: typingsName("cordova") }; const grunt = { path: "/a/data/node_modules/@types/grunt/index.d.ts", content: "declare const grunt: { x: number }", - typings: "@types/grunt" + typings: typingsName("grunt") }; const gulp = { path: "/a/data/node_modules/@types/gulp/index.d.ts", content: "declare const gulp: { x: number }", - typings: "@types/gulp" + typings: typingsName("gulp") }; const host = createServerHost([lodashJs, commanderJs, file3]); @@ -554,7 +595,7 @@ namespace ts.projectSystem { } installWorker(_requestId: number, args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { let typingFiles: (FileOrFolder & { typings: string })[] = []; - if (args.indexOf("@types/commander") >= 0) { + if (args.indexOf(typingsName("commander")) >= 0) { typingFiles = [commander, jquery, lodash, cordova]; } else { @@ -944,7 +985,7 @@ namespace ts.projectSystem { content: "" }; const host = createServerHost([f, node]); - const cache = createMap({ "node": node.path }); + const cache = createMapFromTemplate({ "node": node.path }); const result = JsTyping.discoverTypings(host, [f.path], getDirectoryPath(f.path), /*safeListPath*/ undefined, cache, { enable: true }, ["fs", "bar"]); assert.deepEqual(result.cachedTypingPaths, [node.path]); assert.deepEqual(result.newTypingNames, ["bar"]); @@ -982,7 +1023,7 @@ namespace ts.projectSystem { return; } if (response.kind === server.EventEndInstallTypes) { - assert.deepEqual(response.packagesToInstall, ["@types/commander"]); + assert.deepEqual(response.packagesToInstall, [typingsName("commander")]); seenTelemetryEvent = true; return; } diff --git a/src/harness/virtualFileSystem.ts b/src/harness/virtualFileSystem.ts index 852363b3658..e409af9d4e7 100644 --- a/src/harness/virtualFileSystem.ts +++ b/src/harness/virtualFileSystem.ts @@ -195,11 +195,17 @@ namespace Utils { } export class MockParseConfigHost extends VirtualFileSystem implements ts.ParseConfigHost { - constructor(currentDirectory: string, ignoreCase: boolean, files: ts.MapLike | string[]) { + constructor(currentDirectory: string, ignoreCase: boolean, files: ts.Map | string[]) { super(currentDirectory, ignoreCase); - const fileNames = (files instanceof Array) ? files : ts.getOwnKeys(files); - for (const file of fileNames) { - this.addFile(file, new Harness.LanguageService.ScriptInfo(file, (files as ts.MapLike)[file], /*isRootFile*/false)); + if (files instanceof Array) { + for (const file of files) { + this.addFile(file, new Harness.LanguageService.ScriptInfo(file, undefined, /*isRootFile*/false)); + } + } + else { + files.forEach((fileContent, fileName) => { + this.addFile(fileName, new Harness.LanguageService.ScriptInfo(fileName, fileContent, /*isRootFile*/false)); + }); } } diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index d9825897ebc..5d4bb9ce6e4 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -3,18 +3,50 @@ /// IE DOM APIs ///////////////////////////// +interface Account { + rpDisplayName?: string; + displayName?: string; + id?: string; + name?: string; + imageURL?: string; +} + interface Algorithm { name: string; } -interface AriaRequestEventInit extends EventInit { - attributeName?: string; - attributeValue?: string; +interface AnimationEventInit extends EventInit { + animationName?: string; + elapsedTime?: number; } -interface CommandEventInit extends EventInit { - commandName?: string; - detail?: string; +interface AssertionOptions { + timeoutSeconds?: number; + rpId?: USVString; + allowList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface CacheQueryOptions { + ignoreSearch?: boolean; + ignoreMethod?: boolean; + ignoreVary?: boolean; + cacheName?: string; +} + +interface ClientData { + challenge?: string; + origin?: string; + rpId?: string; + hashAlg?: string | Algorithm; + tokenBinding?: string; + extensions?: WebAuthnExtensions; +} + +interface CloseEventInit extends EventInit { + wasClean?: boolean; + code?: number; + reason?: string; } interface CompositionEventInit extends UIEventInit { @@ -54,6 +86,13 @@ interface CustomEventInit extends EventInit { detail?: any; } +interface DOMRectInit { + x?: any; + y?: any; + width?: any; + height?: any; +} + interface DeviceAccelerationDict { x?: number; y?: number; @@ -64,6 +103,20 @@ interface DeviceLightEventInit extends EventInit { value?: number; } +interface DeviceMotionEventInit extends EventInit { + acceleration?: DeviceAccelerationDict; + accelerationIncludingGravity?: DeviceAccelerationDict; + rotationRate?: DeviceRotationRateDict; + interval?: number; +} + +interface DeviceOrientationEventInit extends EventInit { + alpha?: number; + beta?: number; + gamma?: number; + absolute?: boolean; +} + interface DeviceRotationRateDict { alpha?: number; beta?: number; @@ -75,6 +128,14 @@ interface DoubleRange { min?: number; } +interface ErrorEventInit extends EventInit { + message?: string; + filename?: string; + lineno?: number; + colno?: number; + error?: any; +} + interface EventInit { scoped?: boolean; bubbles?: boolean; @@ -107,6 +168,29 @@ interface FocusEventInit extends UIEventInit { relatedTarget?: EventTarget; } +interface FocusNavigationEventInit extends EventInit { + navigationReason?: string; + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface FocusNavigationOrigin { + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface GamepadEventInit extends EventInit { + gamepad?: Gamepad; +} + +interface GetNotificationOptions { + tag?: string; +} + interface HashChangeEventInit extends EventInit { newURL?: string; oldURL?: string; @@ -122,6 +206,20 @@ interface IDBObjectStoreParameters { keyPath?: IDBKeyPath; } +interface IntersectionObserverEntryInit { + time?: number; + rootBounds?: DOMRectInit; + boundingClientRect?: DOMRectInit; + intersectionRect?: DOMRectInit; + target?: Element; +} + +interface IntersectionObserverInit { + root?: Element; + rootMargin?: string; + threshold?: number | number[]; +} + interface KeyAlgorithm { name?: string; } @@ -324,6 +422,11 @@ interface MSPayloadBase extends RTCStats { payloadDescription?: string; } +interface MSPortRange { + min?: number; + max?: number; +} + interface MSRelayAddress { relayAddress?: string; port?: number; @@ -374,7 +477,7 @@ interface MSUtilization { } interface MSVideoPayload extends MSPayloadBase { - resoluton?: string; + resolution?: string; videoBitRateAvg?: number; videoBitRateMax?: number; videoFrameRateAvg?: number; @@ -457,6 +560,10 @@ interface MediaStreamErrorEventInit extends EventInit { error?: MediaStreamError; } +interface MediaStreamEventInit extends EventInit { + stream?: MediaStream; +} + interface MediaStreamTrackEventInit extends EventInit { track?: MediaStreamTrack; } @@ -521,6 +628,15 @@ interface MediaTrackSupportedConstraints { groupId?: boolean; } +interface MessageEventInit extends EventInit { + lastEventId?: string; + channel?: string; + data?: any; + origin?: string; + source?: Window; + ports?: MessagePort[]; +} + interface MouseEventInit extends EventModifierInit { screenX?: number; screenY?: number; @@ -550,10 +666,68 @@ interface MutationObserverInit { attributeFilter?: string[]; } +interface NotificationOptions { + dir?: string; + lang?: string; + body?: string; + tag?: string; + icon?: string; +} + interface ObjectURLOptions { oneTimeOnly?: boolean; } +interface PaymentCurrencyAmount { + currency?: string; + value?: string; + currencySystem?: string; +} + +interface PaymentDetails { + total?: PaymentItem; + displayItems?: PaymentItem[]; + shippingOptions?: PaymentShippingOption[]; + modifiers?: PaymentDetailsModifier[]; + error?: string; +} + +interface PaymentDetailsModifier { + supportedMethods?: string[]; + total?: PaymentItem; + additionalDisplayItems?: PaymentItem[]; + data?: any; +} + +interface PaymentItem { + label?: string; + amount?: PaymentCurrencyAmount; + pending?: boolean; +} + +interface PaymentMethodData { + supportedMethods?: string[]; + data?: any; +} + +interface PaymentOptions { + requestPayerName?: boolean; + requestPayerEmail?: boolean; + requestPayerPhone?: boolean; + requestShipping?: boolean; + shippingType?: string; +} + +interface PaymentRequestUpdateEventInit extends EventInit { +} + +interface PaymentShippingOption { + id?: string; + label?: string; + amount?: PaymentCurrencyAmount; + selected?: boolean; +} + interface PeriodicWaveConstraints { disableNormalization?: boolean; } @@ -569,12 +743,34 @@ interface PointerEventInit extends MouseEventInit { isPrimary?: boolean; } +interface PopStateEventInit extends EventInit { + state?: any; +} + interface PositionOptions { enableHighAccuracy?: boolean; timeout?: number; maximumAge?: number; } +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + +interface PushSubscriptionOptionsInit { + userVisibleOnly?: boolean; + applicationServerKey?: any; +} + +interface RTCConfiguration { + iceServers?: RTCIceServer[]; + iceTransportPolicy?: string; + bundlePolicy?: string; + peerIdentity?: string; +} + interface RTCDTMFToneChangeEventInit extends EventInit { tone?: string; } @@ -589,18 +785,6 @@ interface RTCDtlsParameters { fingerprints?: RTCDtlsFingerprint[]; } -interface RTCIceCandidate { - foundation?: string; - priority?: number; - ip?: string; - protocol?: string; - port?: number; - type?: string; - tcpType?: string; - relatedAddress?: string; - relatedPort?: number; -} - interface RTCIceCandidateAttributes extends RTCStats { ipAddress?: string; portNumber?: number; @@ -613,9 +797,28 @@ interface RTCIceCandidateAttributes extends RTCStats { interface RTCIceCandidateComplete { } +interface RTCIceCandidateDictionary { + foundation?: string; + priority?: number; + ip?: string; + protocol?: string; + port?: number; + type?: string; + tcpType?: string; + relatedAddress?: string; + relatedPort?: number; + msMTurnSessionId?: string; +} + +interface RTCIceCandidateInit { + candidate?: string; + sdpMid?: string; + sdpMLineIndex?: number; +} + interface RTCIceCandidatePair { - local?: RTCIceCandidate; - remote?: RTCIceCandidate; + local?: RTCIceCandidateDictionary; + remote?: RTCIceCandidateDictionary; } interface RTCIceCandidatePairStats extends RTCStats { @@ -637,11 +840,13 @@ interface RTCIceCandidatePairStats extends RTCStats { interface RTCIceGatherOptions { gatherPolicy?: string; iceservers?: RTCIceServer[]; + portRange?: MSPortRange; } interface RTCIceParameters { usernameFragment?: string; password?: string; + iceLite?: boolean; } interface RTCIceServer { @@ -675,6 +880,13 @@ interface RTCMediaStreamTrackStats extends RTCStats { echoReturnLossEnhancement?: number; } +interface RTCOfferOptions { + offerToReceiveVideo?: number; + offerToReceiveAudio?: number; + voiceActivityDetection?: boolean; + iceRestart?: boolean; +} + interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { packetsSent?: number; bytesSent?: number; @@ -682,6 +894,10 @@ interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { roundTripTime?: number; } +interface RTCPeerConnectionIceEventInit extends EventInit { + candidate?: RTCIceCandidate; +} + interface RTCRTPStreamStats extends RTCStats { ssrc?: string; associateStatsId?: string; @@ -719,6 +935,7 @@ interface RTCRtpCodecCapability { clockRate?: number; preferredPayloadType?: number; maxptime?: number; + ptime?: number; numChannels?: number; rtcpFeedback?: RTCRtcpFeedback[]; parameters?: any; @@ -733,6 +950,7 @@ interface RTCRtpCodecParameters { payloadType?: any; clockRate?: number; maxptime?: number; + ptime?: number; numChannels?: number; rtcpFeedback?: RTCRtcpFeedback[]; parameters?: any; @@ -752,9 +970,9 @@ interface RTCRtpEncodingParameters { priority?: number; maxBitrate?: number; minQuality?: number; - framerateBias?: number; resolutionScale?: number; framerateScale?: number; + maxFramerate?: number; active?: boolean; encodingId?: string; dependencyEncodingIds?: string[]; @@ -785,6 +1003,7 @@ interface RTCRtpParameters { headerExtensions?: RTCRtpHeaderExtensionParameters[]; encodings?: RTCRtpEncodingParameters[]; rtcp?: RTCRtcpParameters; + degradationPreference?: string; } interface RTCRtpRtxParameters { @@ -797,6 +1016,11 @@ interface RTCRtpUnhandled { muxId?: string; } +interface RTCSessionDescriptionInit { + type?: string; + sdp?: string; +} + interface RTCSrtpKeyParam { keyMethod?: string; keySalt?: string; @@ -837,6 +1061,64 @@ interface RTCTransportStats extends RTCStats { remoteCertificateId?: string; } +interface RegistrationOptions { + scope?: string; +} + +interface RequestInit { + method?: string; + headers?: any; + body?: any; + referrer?: string; + referrerPolicy?: string; + mode?: string; + credentials?: string; + cache?: string; + redirect?: string; + integrity?: string; + keepalive?: boolean; + window?: any; +} + +interface ResponseInit { + status?: number; + statusText?: string; + headers?: any; +} + +interface ScopedCredentialDescriptor { + type?: string; + id?: any; + transports?: string[]; +} + +interface ScopedCredentialOptions { + timeoutSeconds?: number; + rpId?: USVString; + excludeList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface ScopedCredentialParameters { + type?: string; + algorithm?: string | Algorithm; +} + +interface ServiceWorkerMessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + source?: ServiceWorker | MessagePort; + ports?: MessagePort[]; +} + +interface SpeechSynthesisEventInit extends EventInit { + utterance?: SpeechSynthesisUtterance; + charIndex?: number; + elapsedTime?: number; + name?: string; +} + interface StoreExceptionsInformation extends ExceptionInformation { siteName?: string; explanationString?: string; @@ -847,11 +1129,23 @@ interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformat arrayOfDomainStrings?: string[]; } +interface TrackEventInit extends EventInit { + track?: VideoTrack | AudioTrack | TextTrack; +} + +interface TransitionEventInit extends EventInit { + propertyName?: string; + elapsedTime?: number; +} + interface UIEventInit extends EventInit { view?: Window; detail?: number; } +interface WebAuthnExtensions { +} + interface WebGLContextAttributes { failIfMajorPerformanceCaveat?: boolean; alpha?: boolean; @@ -877,6 +1171,18 @@ interface EventListener { (evt: Event): void; } +interface WebKitEntriesCallback { + (evt: Event): void; +} + +interface WebKitErrorCallback { + (evt: Event): void; +} + +interface WebKitFileCallback { + (evt: Event): void; +} + interface ANGLE_instanced_arrays { drawArraysInstancedANGLE(mode: number, first: number, count: number, primcount: number): void; drawElementsInstancedANGLE(mode: number, count: number, type: number, offset: number, primcount: number): void; @@ -915,14 +1221,14 @@ interface AnimationEvent extends Event { declare var AnimationEvent: { prototype: AnimationEvent; - new(): AnimationEvent; + new(typeArg: string, eventInitDict?: AnimationEventInit): AnimationEvent; } interface ApplicationCacheEventMap { "cached": Event; "checking": Event; "downloading": Event; - "error": ErrorEvent; + "error": Event; "noupdate": Event; "obsolete": Event; "progress": ProgressEvent; @@ -933,7 +1239,7 @@ interface ApplicationCache extends EventTarget { oncached: (this: ApplicationCache, ev: Event) => any; onchecking: (this: ApplicationCache, ev: Event) => any; ondownloading: (this: ApplicationCache, ev: Event) => any; - onerror: (this: ApplicationCache, ev: ErrorEvent) => any; + onerror: (this: ApplicationCache, ev: Event) => any; onnoupdate: (this: ApplicationCache, ev: Event) => any; onobsolete: (this: ApplicationCache, ev: Event) => any; onprogress: (this: ApplicationCache, ev: ProgressEvent) => any; @@ -963,16 +1269,6 @@ declare var ApplicationCache: { readonly UPDATEREADY: number; } -interface AriaRequestEvent extends Event { - readonly attributeName: string; - attributeValue: string | null; -} - -declare var AriaRequestEvent: { - prototype: AriaRequestEvent; - new(type: string, eventInitDict?: AriaRequestEventInit): AriaRequestEvent; -} - interface Attr extends Node { readonly name: string; readonly ownerElement: Element; @@ -1024,12 +1320,18 @@ declare var AudioBufferSourceNode: { new(): AudioBufferSourceNode; } -interface AudioContext extends EventTarget { +interface AudioContextEventMap { + "statechange": Event; +} + +interface AudioContextBase extends EventTarget { readonly currentTime: number; readonly destination: AudioDestinationNode; readonly listener: AudioListener; + onstatechange: (this: AudioContext, ev: Event) => any; readonly sampleRate: number; - state: string; + readonly state: string; + close(): Promise; createAnalyser(): AnalyserNode; createBiquadFilter(): BiquadFilterNode; createBuffer(numberOfChannels: number, length: number, sampleRate: number): AudioBuffer; @@ -1040,6 +1342,7 @@ interface AudioContext extends EventTarget { createDelay(maxDelayTime?: number): DelayNode; createDynamicsCompressor(): DynamicsCompressorNode; createGain(): GainNode; + createIIRFilter(feedforward: number[], feedback: number[]): IIRFilterNode; createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; createMediaStreamSource(mediaStream: MediaStream): MediaStreamAudioSourceNode; createOscillator(): OscillatorNode; @@ -1048,7 +1351,14 @@ interface AudioContext extends EventTarget { createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; createStereoPanner(): StereoPannerNode; createWaveShaper(): WaveShaperNode; - decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): PromiseLike; + decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): Promise; + resume(): Promise; + addEventListener(type: K, listener: (this: AudioContext, ev: AudioContextEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface AudioContext extends AudioContextBase { + suspend(): Promise; } declare var AudioContext: { @@ -1085,7 +1395,7 @@ interface AudioNode extends EventTarget { readonly context: AudioContext; readonly numberOfInputs: number; readonly numberOfOutputs: number; - connect(destination: AudioNode, output?: number, input?: number): void; + connect(destination: AudioNode, output?: number, input?: number): AudioNode; disconnect(output?: number): void; disconnect(destination: AudioNode, output?: number, input?: number): void; disconnect(destination: AudioParam, output?: number): void; @@ -1099,12 +1409,12 @@ declare var AudioNode: { interface AudioParam { readonly defaultValue: number; value: number; - cancelScheduledValues(startTime: number): void; - exponentialRampToValueAtTime(value: number, endTime: number): void; - linearRampToValueAtTime(value: number, endTime: number): void; - setTargetAtTime(target: number, startTime: number, timeConstant: number): void; - setValueAtTime(value: number, startTime: number): void; - setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): void; + cancelScheduledValues(startTime: number): AudioParam; + exponentialRampToValueAtTime(value: number, endTime: number): AudioParam; + linearRampToValueAtTime(value: number, endTime: number): AudioParam; + setTargetAtTime(target: number, startTime: number, timeConstant: number): AudioParam; + setValueAtTime(value: number, startTime: number): AudioParam; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): AudioParam; } declare var AudioParam: { @@ -1481,10 +1791,16 @@ interface CSSStyleDeclaration { imeMode: string | null; justifyContent: string | null; kerning: string | null; + layoutGrid: string | null; + layoutGridChar: string | null; + layoutGridLine: string | null; + layoutGridMode: string | null; + layoutGridType: string | null; left: string | null; readonly length: number; letterSpacing: string | null; lightingColor: string | null; + lineBreak: string | null; lineHeight: string | null; listStyle: string | null; listStyleImage: string | null; @@ -1556,6 +1872,7 @@ interface CSSStyleDeclaration { orphans: string | null; outline: string | null; outlineColor: string | null; + outlineOffset: string | null; outlineStyle: string | null; outlineWidth: string | null; overflow: string | null; @@ -1576,9 +1893,11 @@ interface CSSStyleDeclaration { position: string | null; quotes: string | null; right: string | null; + rotate: string | null; rubyAlign: string | null; rubyOverhang: string | null; rubyPosition: string | null; + scale: string | null; stopColor: string | null; stopOpacity: string | null; stroke: string | null; @@ -1612,6 +1931,7 @@ interface CSSStyleDeclaration { transitionDuration: string | null; transitionProperty: string | null; transitionTimingFunction: string | null; + translate: string | null; unicodeBidi: string | null; verticalAlign: string | null; visibility: string | null; @@ -1672,6 +1992,9 @@ interface CSSStyleDeclaration { webkitTapHighlightColor: string | null; webkitTextFillColor: string | null; webkitTextSizeAdjust: any; + webkitTextStroke: string | null; + webkitTextStrokeColor: string | null; + webkitTextStrokeWidth: string | null; webkitTransform: string | null; webkitTransformOrigin: string | null; webkitTransformStyle: string | null; @@ -1693,6 +2016,7 @@ interface CSSStyleDeclaration { zIndex: string | null; zoom: string | null; resize: string | null; + userSelect: string | null; getPropertyPriority(propertyName: string): string; getPropertyValue(propertyName: string): string; item(index: number): string; @@ -1720,7 +2044,6 @@ declare var CSSStyleRule: { interface CSSStyleSheet extends StyleSheet { readonly cssRules: CSSRuleList; cssText: string; - readonly href: string; readonly id: string; readonly imports: StyleSheetList; readonly isAlternate: boolean; @@ -1752,6 +2075,34 @@ declare var CSSSupportsRule: { new(): CSSSupportsRule; } +interface Cache { + add(request: RequestInfo): Promise; + addAll(requests: RequestInfo[]): Promise; + delete(request: RequestInfo, options?: CacheQueryOptions): Promise; + keys(request?: RequestInfo, options?: CacheQueryOptions): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + put(request: RequestInfo, response: Response): Promise; +} + +declare var Cache: { + prototype: Cache; + new(): Cache; +} + +interface CacheStorage { + delete(cacheName: string): Promise; + has(cacheName: string): Promise; + keys(): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + open(cacheName: string): Promise; +} + +declare var CacheStorage: { + prototype: CacheStorage; + new(): CacheStorage; +} + interface CanvasGradient { addColorStop(offset: number, color: string): void; } @@ -1776,13 +2127,13 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { font: string; globalAlpha: number; globalCompositeOperation: string; + imageSmoothingEnabled: boolean; lineCap: string; lineDashOffset: number; lineJoin: string; lineWidth: number; miterLimit: number; msFillRule: string; - msImageSmoothingEnabled: boolean; shadowBlur: number; shadowColor: string; shadowOffsetX: number; @@ -1800,6 +2151,7 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; + drawFocusIfNeeded(element: Element): void; drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; fill(fillRule?: string): void; fillRect(x: number, y: number, w: number, h: number): void; @@ -1815,7 +2167,7 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { scale(x: number, y: number): void; setLineDash(segments: number[]): void; setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; - stroke(): void; + stroke(path?: Path2D): void; strokeRect(x: number, y: number, w: number, h: number): void; strokeText(text: string, x: number, y: number, maxWidth?: number): void; transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; @@ -1901,17 +2253,7 @@ interface CloseEvent extends Event { declare var CloseEvent: { prototype: CloseEvent; - new(): CloseEvent; -} - -interface CommandEvent extends Event { - readonly commandName: string; - readonly detail: string | null; -} - -declare var CommandEvent: { - prototype: CommandEvent; - new(type: string, eventInitDict?: CommandEventInit): CommandEvent; + new(typeArg: string, eventInitDict?: CloseEventInit): CloseEvent; } interface Comment extends CharacterData { @@ -1938,7 +2280,7 @@ interface Console { assert(test?: boolean, message?: string, ...optionalParams: any[]): void; clear(): void; count(countTitle?: string): void; - debug(message?: string, ...optionalParams: any[]): void; + debug(message?: any, ...optionalParams: any[]): void; dir(value?: any, ...optionalParams: any[]): void; dirxml(value: any): void; error(message?: any, ...optionalParams: any[]): void; @@ -2108,9 +2450,9 @@ declare var DOMException: { interface DOMImplementation { createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType): Document; - createDocumentType(qualifiedName: string, publicId: string | null, systemId: string | null): DocumentType; + createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; createHTMLDocument(title: string): Document; - hasFeature(feature: string | null, version: string | null): boolean; + hasFeature(): boolean; } declare var DOMImplementation: { @@ -2149,7 +2491,7 @@ declare var DOMStringList: { } interface DOMStringMap { - [name: string]: string; + [name: string]: string | undefined; } declare var DOMStringMap: { @@ -2175,7 +2517,7 @@ declare var DOMTokenList: { interface DataCue extends TextTrackCue { data: ArrayBuffer; - addEventListener(type: K, listener: (this: TextTrackCue, ev: TextTrackCueEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: DataCue, ev: TextTrackCueEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -2205,6 +2547,7 @@ interface DataTransferItem { readonly type: string; getAsFile(): File | null; getAsString(_callback: FunctionStringCallback | null): void; + webkitGetAsEntry(): any; } declare var DataTransferItem: { @@ -2265,7 +2608,7 @@ interface DeviceLightEvent extends Event { declare var DeviceLightEvent: { prototype: DeviceLightEvent; - new(type: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; + new(typeArg: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; } interface DeviceMotionEvent extends Event { @@ -2278,7 +2621,7 @@ interface DeviceMotionEvent extends Event { declare var DeviceMotionEvent: { prototype: DeviceMotionEvent; - new(): DeviceMotionEvent; + new(typeArg: string, eventInitDict?: DeviceMotionEventInit): DeviceMotionEvent; } interface DeviceOrientationEvent extends Event { @@ -2291,7 +2634,7 @@ interface DeviceOrientationEvent extends Event { declare var DeviceOrientationEvent: { prototype: DeviceOrientationEvent; - new(): DeviceOrientationEvent; + new(typeArg: string, eventInitDict?: DeviceOrientationEventInit): DeviceOrientationEvent; } interface DeviceRotationRate { @@ -2373,7 +2716,7 @@ interface DocumentEventMap extends GlobalEventHandlersEventMap { "pointerlockerror": Event; "progress": ProgressEvent; "ratechange": Event; - "readystatechange": ProgressEvent; + "readystatechange": Event; "reset": Event; "scroll": UIEvent; "seeked": Event; @@ -2444,10 +2787,6 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven readonly compatMode: string; cookie: string; readonly currentScript: HTMLScriptElement | SVGScriptElement; - /** - * Gets the default character set from the current regional language settings. - */ - readonly defaultCharset: string; readonly defaultView: Window; /** * Sets or gets a value that indicates whether the document can be edited. @@ -2754,7 +3093,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Fires when the state of the object has changed. * @param ev The event */ - onreadystatechange: (this: Document, ev: ProgressEvent) => any; + onreadystatechange: (this: Document, ev: Event) => any; /** * Fires when the user resets a form. * @param ev The event. @@ -3122,8 +3461,8 @@ interface DocumentType extends Node, ChildNode { readonly internalSubset: string | null; readonly name: string; readonly notations: NamedNodeMap; - readonly publicId: string | null; - readonly systemId: string | null; + readonly publicId: string; + readonly systemId: string; } declare var DocumentType: { @@ -3146,7 +3485,7 @@ interface DynamicsCompressorNode extends AudioNode { readonly attack: AudioParam; readonly knee: AudioParam; readonly ratio: AudioParam; - readonly reduction: AudioParam; + readonly reduction: number; readonly release: AudioParam; readonly threshold: AudioParam; } @@ -3177,8 +3516,8 @@ declare var EXT_texture_filter_anisotropic: { } interface ElementEventMap extends GlobalEventHandlersEventMap { - "ariarequest": AriaRequestEvent; - "command": CommandEvent; + "ariarequest": Event; + "command": Event; "gotpointercapture": PointerEvent; "lostpointercapture": PointerEvent; "MSGestureChange": MSGestureEvent; @@ -3214,10 +3553,11 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec readonly clientTop: number; readonly clientWidth: number; id: string; + innerHTML: string; msContentZoomFactor: number; readonly msRegionOverflow: string; - onariarequest: (this: Element, ev: AriaRequestEvent) => any; - oncommand: (this: Element, ev: CommandEvent) => any; + onariarequest: (this: Element, ev: Event) => any; + oncommand: (this: Element, ev: Event) => any; ongotpointercapture: (this: Element, ev: PointerEvent) => any; onlostpointercapture: (this: Element, ev: PointerEvent) => any; onmsgesturechange: (this: Element, ev: MSGestureEvent) => any; @@ -3243,13 +3583,13 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec ontouchstart: (ev: TouchEvent) => any; onwebkitfullscreenchange: (this: Element, ev: Event) => any; onwebkitfullscreenerror: (this: Element, ev: Event) => any; + outerHTML: string; readonly prefix: string | null; readonly scrollHeight: number; scrollLeft: number; scrollTop: number; readonly scrollWidth: number; readonly tagName: string; - innerHTML: string; readonly assignedSlot: HTMLSlotElement | null; slot: string; readonly shadowRoot: ShadowRoot | null; @@ -3273,7 +3613,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec msSetPointerCapture(pointerId: number): void; msZoomTo(args: MsZoomToOptions): void; releasePointerCapture(pointerId: number): void; - removeAttribute(name?: string): void; + removeAttribute(qualifiedName: string): void; removeAttributeNS(namespaceURI: string, localName: string): void; removeAttributeNode(oldAttr: Attr): Attr; requestFullscreen(): void; @@ -3320,7 +3660,7 @@ interface ErrorEvent extends Event { declare var ErrorEvent: { prototype: ErrorEvent; - new(): ErrorEvent; + new(type: string, errorEventInitDict?: ErrorEventInit): ErrorEvent; } interface Event { @@ -3349,7 +3689,7 @@ interface Event { declare var Event: { prototype: Event; - new(type: string, eventInitDict?: EventInit): Event; + new(typeArg: string, eventInitDict?: EventInit): Event; readonly AT_TARGET: number; readonly BUBBLING_PHASE: number; readonly CAPTURING_PHASE: number; @@ -3366,6 +3706,21 @@ declare var EventTarget: { new(): EventTarget; } +interface ExtensionScriptApis { + extensionIdToShortId(extensionId: string): number; + fireExtensionApiTelemetry(functionName: string, isSucceeded: boolean, isSupported: boolean): void; + genericFunction(routerAddress: any, parameters?: string, callbackId?: number): void; + genericSynchronousFunction(functionId: number, parameters?: string): string; + getExtensionId(): string; + registerGenericFunctionCallbackHandler(callbackHandler: any): void; + registerGenericPersistentCallbackHandler(callbackHandler: any): void; +} + +declare var ExtensionScriptApis: { + prototype: ExtensionScriptApis; + new(): ExtensionScriptApis; +} + interface External { } @@ -3402,7 +3757,7 @@ interface FileReader extends EventTarget, MSBaseReader { readAsBinaryString(blob: Blob): void; readAsDataURL(blob: Blob): void; readAsText(blob: Blob, encoding?: string): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3421,6 +3776,20 @@ declare var FocusEvent: { new(typeArg: string, eventInitDict?: FocusEventInit): FocusEvent; } +interface FocusNavigationEvent extends Event { + readonly navigationReason: string; + readonly originHeight: number; + readonly originLeft: number; + readonly originTop: number; + readonly originWidth: number; + requestFocus(): void; +} + +declare var FocusNavigationEvent: { + prototype: FocusNavigationEvent; + new(type: string, eventInitDict?: FocusNavigationEventInit): FocusNavigationEvent; +} + interface FormData { append(name: any, value: any, blobName?: string): void; } @@ -3470,7 +3839,7 @@ interface GamepadEvent extends Event { declare var GamepadEvent: { prototype: GamepadEvent; - new(): GamepadEvent; + new(typeArg: string, eventInitDict?: GamepadEventInit): GamepadEvent; } interface Geolocation { @@ -3484,8 +3853,11 @@ declare var Geolocation: { new(): Geolocation; } -interface HTMLAllCollection extends HTMLCollection { - namedItem(name: string): Element; +interface HTMLAllCollection { + readonly length: number; + item(nameOrIndex?: string): HTMLCollection | Element | null; + namedItem(name: string): HTMLCollection | Element | null; + [index: number]: Element; } declare var HTMLAllCollection: { @@ -3573,7 +3945,7 @@ interface HTMLAnchorElement extends HTMLElement { * Returns a string representation of an object. */ toString(): string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAnchorElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3647,7 +4019,7 @@ interface HTMLAppletElement extends HTMLElement { useMap: string; vspace: number; width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAppletElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3715,7 +4087,7 @@ interface HTMLAreaElement extends HTMLElement { * Returns a string representation of an object. */ toString(): string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3724,15 +4096,7 @@ declare var HTMLAreaElement: { new(): HTMLAreaElement; } -interface HTMLAreasCollection extends HTMLCollection { - /** - * Adds an element to the areas, controlRange, or options collection. - */ - add(element: HTMLElement, before?: HTMLElement | number): void; - /** - * Removes an element from the collection. - */ - remove(index?: number): void; +interface HTMLAreasCollection extends HTMLCollectionBase { } declare var HTMLAreasCollection: { @@ -3741,7 +4105,7 @@ declare var HTMLAreasCollection: { } interface HTMLAudioElement extends HTMLMediaElement { - addEventListener(type: K, listener: (this: HTMLMediaElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLAudioElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3755,7 +4119,7 @@ interface HTMLBRElement extends HTMLElement { * Sets or retrieves the side on which floating objects are not to be positioned when any IHTMLBlockElement is inserted into the document. */ clear: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3773,7 +4137,7 @@ interface HTMLBaseElement extends HTMLElement { * Sets or retrieves the window or frame at which to target content. */ target: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBaseElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3791,7 +4155,7 @@ interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty * Sets or retrieves the font size of the object. */ size: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLBaseFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3817,6 +4181,7 @@ interface HTMLBodyElementEventMap extends HTMLElementEventMap { "pageshow": PageTransitionEvent; "popstate": PopStateEvent; "resize": UIEvent; + "scroll": UIEvent; "storage": StorageEvent; "unload": Event; } @@ -3844,6 +4209,7 @@ interface HTMLBodyElement extends HTMLElement { onpageshow: (this: HTMLBodyElement, ev: PageTransitionEvent) => any; onpopstate: (this: HTMLBodyElement, ev: PopStateEvent) => any; onresize: (this: HTMLBodyElement, ev: UIEvent) => any; + onscroll: (this: HTMLBodyElement, ev: UIEvent) => any; onstorage: (this: HTMLBodyElement, ev: StorageEvent) => any; onunload: (this: HTMLBodyElement, ev: Event) => any; text: any; @@ -3921,7 +4287,7 @@ interface HTMLButtonElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLButtonElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3956,7 +4322,7 @@ interface HTMLCanvasElement extends HTMLElement { */ toDataURL(type?: string, ...args: any[]): string; toBlob(callback: (result: Blob | null) => void, type?: string, ...arguments: any[]): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLCanvasElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3965,7 +4331,7 @@ declare var HTMLCanvasElement: { new(): HTMLCanvasElement; } -interface HTMLCollection { +interface HTMLCollectionBase { /** * Sets or retrieves the number of objects in a collection. */ @@ -3974,11 +4340,14 @@ interface HTMLCollection { * Retrieves an object from various collections. */ item(index: number): Element; + [index: number]: Element; +} + +interface HTMLCollection extends HTMLCollectionBase { /** * Retrieves a select object or an object from an options collection. */ - namedItem(name: string): Element; - [index: number]: Element; + namedItem(name: string): Element | null; } declare var HTMLCollection: { @@ -3988,7 +4357,7 @@ declare var HTMLCollection: { interface HTMLDListElement extends HTMLElement { compact: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3997,9 +4366,20 @@ declare var HTMLDListElement: { new(): HTMLDListElement; } +interface HTMLDataElement extends HTMLElement { + value: string; + addEventListener(type: K, listener: (this: HTMLDataElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDataElement: { + prototype: HTMLDataElement; + new(): HTMLDataElement; +} + interface HTMLDataListElement extends HTMLElement { options: HTMLCollectionOf; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDataListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4010,7 +4390,7 @@ declare var HTMLDataListElement: { interface HTMLDirectoryElement extends HTMLElement { compact: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDirectoryElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4028,7 +4408,7 @@ interface HTMLDivElement extends HTMLElement { * Sets or retrieves whether the browser automatically performs wordwrap. */ noWrap: boolean; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDivElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4038,7 +4418,7 @@ declare var HTMLDivElement: { } interface HTMLDocument extends Document { - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4126,7 +4506,6 @@ interface HTMLElement extends Element { draggable: boolean; hidden: boolean; hideFocus: boolean; - innerHTML: string; innerText: string; readonly isContentEditable: boolean; lang: string; @@ -4202,7 +4581,6 @@ interface HTMLElement extends Element { ontimeupdate: (this: HTMLElement, ev: Event) => any; onvolumechange: (this: HTMLElement, ev: Event) => any; onwaiting: (this: HTMLElement, ev: Event) => any; - outerHTML: string; outerText: string; spellcheck: boolean; readonly style: CSSStyleDeclaration; @@ -4213,7 +4591,6 @@ interface HTMLElement extends Element { dragDrop(): boolean; focus(): void; msGetInputContext(): MSInputMethodContext; - setActive(): void; addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4270,7 +4647,7 @@ interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { * Sets or retrieves the width of the object. */ width: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLEmbedElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4289,6 +4666,7 @@ interface HTMLFieldSetElement extends HTMLElement { * Retrieves a reference to the form that the object is embedded in. */ readonly form: HTMLFormElement; + name: string; /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. */ @@ -4310,7 +4688,7 @@ interface HTMLFieldSetElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFieldSetElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4324,7 +4702,7 @@ interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOM * Sets or retrieves the current typeface family. */ face: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4333,6 +4711,15 @@ declare var HTMLFontElement: { new(): HTMLFontElement; } +interface HTMLFormControlsCollection extends HTMLCollectionBase { + namedItem(name: string): HTMLCollection | Element | null; +} + +declare var HTMLFormControlsCollection: { + prototype: HTMLFormControlsCollection; + new(): HTMLFormControlsCollection; +} + interface HTMLFormElement extends HTMLElement { /** * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. @@ -4349,7 +4736,7 @@ interface HTMLFormElement extends HTMLElement { /** * Retrieves a collection, in source order, of all controls in a given form. */ - readonly elements: HTMLCollection; + readonly elements: HTMLFormControlsCollection; /** * Sets or retrieves the MIME encoding for the form. */ @@ -4400,7 +4787,7 @@ interface HTMLFormElement extends HTMLElement { * Fires when a FORM is about to be submitted. */ submit(): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLFormElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; [name: string]: any; } @@ -4489,6 +4876,7 @@ declare var HTMLFrameElement: { } interface HTMLFrameSetElementEventMap extends HTMLElementEventMap { + "afterprint": Event; "beforeprint": Event; "beforeunload": BeforeUnloadEvent; "blur": FocusEvent; @@ -4502,7 +4890,9 @@ interface HTMLFrameSetElementEventMap extends HTMLElementEventMap { "orientationchange": Event; "pagehide": PageTransitionEvent; "pageshow": PageTransitionEvent; + "popstate": PopStateEvent; "resize": UIEvent; + "scroll": UIEvent; "storage": StorageEvent; "unload": Event; } @@ -4546,7 +4936,9 @@ interface HTMLFrameSetElement extends HTMLElement { onorientationchange: (this: HTMLFrameSetElement, ev: Event) => any; onpagehide: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; onpageshow: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; + onpopstate: (this: HTMLFrameSetElement, ev: PopStateEvent) => any; onresize: (this: HTMLFrameSetElement, ev: UIEvent) => any; + onscroll: (this: HTMLFrameSetElement, ev: UIEvent) => any; onstorage: (this: HTMLFrameSetElement, ev: StorageEvent) => any; onunload: (this: HTMLFrameSetElement, ev: Event) => any; /** @@ -4575,7 +4967,7 @@ interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2 * Sets or retrieves the width of the object. */ width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4586,7 +4978,7 @@ declare var HTMLHRElement: { interface HTMLHeadElement extends HTMLElement { profile: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHeadElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4600,7 +4992,7 @@ interface HTMLHeadingElement extends HTMLElement { * Sets or retrieves a value that indicates the table alignment. */ align: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHeadingElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4614,7 +5006,7 @@ interface HTMLHtmlElement extends HTMLElement { * Sets or retrieves the DTD version that governs the current document. */ version: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLHtmlElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -4633,6 +5025,7 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { */ align: string; allowFullscreen: boolean; + allowPaymentRequest: boolean; /** * Specifies the properties of a border drawn around an object. */ @@ -4728,7 +5121,7 @@ interface HTMLImageElement extends HTMLElement { * Retrieves whether the object is fully loaded. */ readonly complete: boolean; - crossOrigin: string; + crossOrigin: string | null; readonly currentSrc: string; /** * Sets or retrieves the height of the object. @@ -4793,14 +5186,13 @@ interface HTMLImageElement extends HTMLElement { readonly x: number; readonly y: number; msGetAsCastingSource(): any; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLImageElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLImageElement: { prototype: HTMLImageElement; new(): HTMLImageElement; - create(): HTMLImageElement; } interface HTMLInputElement extends HTMLElement { @@ -5006,7 +5398,7 @@ interface HTMLInputElement extends HTMLElement { * @param n Value to increment the value by. */ stepUp(n?: number): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLInputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5021,7 +5413,7 @@ interface HTMLLIElement extends HTMLElement { * Sets or retrieves the value of a list item. */ value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLIElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5039,7 +5431,7 @@ interface HTMLLabelElement extends HTMLElement { * Sets or retrieves the object to which the given label object is assigned. */ htmlFor: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLabelElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5057,7 +5449,7 @@ interface HTMLLegendElement extends HTMLElement { * Retrieves a reference to the form that the object is embedded in. */ readonly form: HTMLFormElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5102,7 +5494,7 @@ interface HTMLLinkElement extends HTMLElement, LinkStyle { type: string; import?: Document; integrity: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLLinkElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5120,7 +5512,7 @@ interface HTMLMapElement extends HTMLElement { * Sets or retrieves the name of the object. */ name: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMapElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5183,7 +5575,7 @@ interface HTMLMediaElement extends HTMLElement { * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). */ controls: boolean; - crossOrigin: string; + crossOrigin: string | null; /** * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. */ @@ -5324,7 +5716,7 @@ interface HTMLMediaElement extends HTMLElement { * Loads and starts playback of a media resource. */ play(): void; - setMediaKeys(mediaKeys: MediaKeys | null): PromiseLike; + setMediaKeys(mediaKeys: MediaKeys | null): Promise; readonly HAVE_CURRENT_DATA: number; readonly HAVE_ENOUGH_DATA: number; readonly HAVE_FUTURE_DATA: number; @@ -5355,7 +5747,7 @@ declare var HTMLMediaElement: { interface HTMLMenuElement extends HTMLElement { compact: boolean; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMenuElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5389,7 +5781,7 @@ interface HTMLMetaElement extends HTMLElement { * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. */ url: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMetaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5405,7 +5797,7 @@ interface HTMLMeterElement extends HTMLElement { min: number; optimum: number; value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLMeterElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5423,7 +5815,7 @@ interface HTMLModElement extends HTMLElement { * Sets or retrieves the date and time of a modification to the object. */ dateTime: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLModElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5439,7 +5831,7 @@ interface HTMLOListElement extends HTMLElement { */ start: number; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5517,10 +5909,6 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { * Sets or retrieves the name of the object. */ name: string; - /** - * Retrieves the contained object. - */ - readonly object: any; readonly readyState: number; /** * Sets or retrieves a message to be displayed while an object is loading. @@ -5560,7 +5948,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLObjectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5599,7 +5987,7 @@ interface HTMLOptGroupElement extends HTMLElement { * Sets or retrieves the value which is returned to the server when the form control is submitted. */ value: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOptGroupElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5638,14 +6026,13 @@ interface HTMLOptionElement extends HTMLElement { * Sets or retrieves the value which is returned to the server when the form control is submitted. */ value: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLOptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLOptionElement: { prototype: HTMLOptionElement; new(): HTMLOptionElement; - create(): HTMLOptionElement; } interface HTMLOptionsCollection extends HTMLCollectionOf { @@ -5660,13 +6047,35 @@ declare var HTMLOptionsCollection: { new(): HTMLOptionsCollection; } +interface HTMLOutputElement extends HTMLElement { + defaultValue: string; + readonly form: HTMLFormElement; + readonly htmlFor: DOMSettableTokenList; + name: string; + readonly type: string; + readonly validationMessage: string; + readonly validity: ValidityState; + value: string; + readonly willValidate: boolean; + checkValidity(): boolean; + reportValidity(): boolean; + setCustomValidity(error: string): void; + addEventListener(type: K, listener: (this: HTMLOutputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLOutputElement: { + prototype: HTMLOutputElement; + new(): HTMLOutputElement; +} + interface HTMLParagraphElement extends HTMLElement { /** * Sets or retrieves how the object is aligned with adjacent text. */ align: string; clear: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLParagraphElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5692,7 +6101,7 @@ interface HTMLParamElement extends HTMLElement { * Sets or retrieves the data type of the value attribute. */ valueType: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLParamElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5702,7 +6111,7 @@ declare var HTMLParamElement: { } interface HTMLPictureElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLPictureElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5716,7 +6125,7 @@ interface HTMLPreElement extends HTMLElement { * Sets or gets a value that you can use to implement your own width functionality for the object. */ width: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLPreElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5742,7 +6151,7 @@ interface HTMLProgressElement extends HTMLElement { * Sets or gets the current value of a progress element. The value must be a non-negative number between 0 and the max value. */ value: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLProgressElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5756,7 +6165,7 @@ interface HTMLQuoteElement extends HTMLElement { * Sets or retrieves reference information about the object. */ cite: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLQuoteElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5771,6 +6180,7 @@ interface HTMLScriptElement extends HTMLElement { * Sets or retrieves the character set used to encode the object. */ charset: string; + crossOrigin: string | null; /** * Sets or retrieves the status of the script. */ @@ -5796,7 +6206,7 @@ interface HTMLScriptElement extends HTMLElement { */ type: string; integrity: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLScriptElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5892,7 +6302,7 @@ interface HTMLSelectElement extends HTMLElement { * @param error Sets a custom error message that is displayed when a form is submitted. */ setCustomValidity(error: string): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSelectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; [name: string]: any; } @@ -5918,7 +6328,7 @@ interface HTMLSourceElement extends HTMLElement { * Gets or sets the MIME type of a media resource. */ type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSourceElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5928,7 +6338,7 @@ declare var HTMLSourceElement: { } interface HTMLSpanElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLSpanElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5947,7 +6357,7 @@ interface HTMLStyleElement extends HTMLElement, LinkStyle { * Retrieves the CSS language in which the style sheet is written. */ type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLStyleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5965,7 +6375,7 @@ interface HTMLTableCaptionElement extends HTMLElement { * Sets or retrieves whether the caption appears at the top or bottom of the table. */ vAlign: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableCaptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6020,7 +6430,7 @@ interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment { * Sets or retrieves the width of the object. */ width: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6042,7 +6452,7 @@ interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { * Sets or retrieves the width of the object. */ width: any; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableColElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6052,6 +6462,8 @@ declare var HTMLTableColElement: { } interface HTMLTableDataCellElement extends HTMLTableCellElement { + addEventListener(type: K, listener: (this: HTMLTableDataCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLTableDataCellElement: { @@ -6163,7 +6575,7 @@ interface HTMLTableElement extends HTMLElement { * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. */ insertRow(index?: number): HTMLTableRowElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6177,6 +6589,8 @@ interface HTMLTableHeaderCellElement extends HTMLTableCellElement { * Sets or retrieves the group of cells in a table to which the object's information applies. */ scope: string; + addEventListener(type: K, listener: (this: HTMLTableHeaderCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var HTMLTableHeaderCellElement: { @@ -6216,7 +6630,7 @@ interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment { * @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. */ insertCell(index?: number): HTMLTableDataCellElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableRowElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6244,7 +6658,7 @@ interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment { * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. */ insertRow(index?: number): HTMLTableRowElement; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTableSectionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6255,7 +6669,7 @@ declare var HTMLTableSectionElement: { interface HTMLTemplateElement extends HTMLElement { readonly content: DocumentFragment; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTemplateElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6362,7 +6776,7 @@ interface HTMLTextAreaElement extends HTMLElement { * @param end The offset into the text field for the end of the selection. */ setSelectionRange(start: number, end: number): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTextAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6371,12 +6785,23 @@ declare var HTMLTextAreaElement: { new(): HTMLTextAreaElement; } +interface HTMLTimeElement extends HTMLElement { + dateTime: string; + addEventListener(type: K, listener: (this: HTMLTimeElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTimeElement: { + prototype: HTMLTimeElement; + new(): HTMLTimeElement; +} + interface HTMLTitleElement extends HTMLElement { /** * Retrieves or sets the text of the object as a string. */ text: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTitleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6397,7 +6822,7 @@ interface HTMLTrackElement extends HTMLElement { readonly LOADED: number; readonly LOADING: number; readonly NONE: number; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLTrackElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6413,7 +6838,7 @@ declare var HTMLTrackElement: { interface HTMLUListElement extends HTMLElement { compact: boolean; type: string; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLUListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6423,7 +6848,7 @@ declare var HTMLUListElement: { } interface HTMLUnknownElement extends HTMLElement { - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: HTMLUnknownElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6494,7 +6919,21 @@ interface HashChangeEvent extends Event { declare var HashChangeEvent: { prototype: HashChangeEvent; - new(type: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; + new(typeArg: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; +} + +interface Headers { + append(name: string, value: string): void; + delete(name: string): void; + forEach(callback: ForEachCallback): void; + get(name: string): string | null; + has(name: string): boolean; + set(name: string, value: string): void; +} + +declare var Headers: { + prototype: Headers; + new(init?: any): Headers; } interface History { @@ -6548,14 +6987,14 @@ declare var IDBCursorWithValue: { interface IDBDatabaseEventMap { "abort": Event; - "error": ErrorEvent; + "error": Event; } interface IDBDatabase extends EventTarget { readonly name: string; readonly objectStoreNames: DOMStringList; onabort: (this: IDBDatabase, ev: Event) => any; - onerror: (this: IDBDatabase, ev: ErrorEvent) => any; + onerror: (this: IDBDatabase, ev: Event) => any; version: number; onversionchange: (ev: IDBVersionChangeEvent) => any; close(): void; @@ -6658,13 +7097,13 @@ declare var IDBOpenDBRequest: { } interface IDBRequestEventMap { - "error": ErrorEvent; + "error": Event; "success": Event; } interface IDBRequest extends EventTarget { readonly error: DOMError; - onerror: (this: IDBRequest, ev: ErrorEvent) => any; + onerror: (this: IDBRequest, ev: Event) => any; onsuccess: (this: IDBRequest, ev: Event) => any; readonly readyState: string; readonly result: any; @@ -6682,7 +7121,7 @@ declare var IDBRequest: { interface IDBTransactionEventMap { "abort": Event; "complete": Event; - "error": ErrorEvent; + "error": Event; } interface IDBTransaction extends EventTarget { @@ -6691,7 +7130,7 @@ interface IDBTransaction extends EventTarget { readonly mode: string; onabort: (this: IDBTransaction, ev: Event) => any; oncomplete: (this: IDBTransaction, ev: Event) => any; - onerror: (this: IDBTransaction, ev: ErrorEvent) => any; + onerror: (this: IDBTransaction, ev: Event) => any; abort(): void; objectStore(name: string): IDBObjectStore; readonly READ_ONLY: string; @@ -6719,6 +7158,15 @@ declare var IDBVersionChangeEvent: { new(): IDBVersionChangeEvent; } +interface IIRFilterNode extends AudioNode { + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; +} + +declare var IIRFilterNode: { + prototype: IIRFilterNode; + new(): IIRFilterNode; +} + interface ImageData { data: Uint8ClampedArray; readonly height: number; @@ -6731,6 +7179,35 @@ declare var ImageData: { new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +interface IntersectionObserver { + readonly root: Element | null; + readonly rootMargin: string; + readonly thresholds: number[]; + disconnect(): void; + observe(target: Element): void; + takeRecords(): IntersectionObserverEntry[]; + unobserve(target: Element): void; +} + +declare var IntersectionObserver: { + prototype: IntersectionObserver; + new(callback: IntersectionObserverCallback, options?: IntersectionObserverInit): IntersectionObserver; +} + +interface IntersectionObserverEntry { + readonly boundingClientRect: ClientRect; + readonly intersectionRatio: number; + readonly intersectionRect: ClientRect; + readonly rootBounds: ClientRect; + readonly target: Element; + readonly time: number; +} + +declare var IntersectionObserverEntry: { + prototype: IntersectionObserverEntry; + new(intersectionObserverEntryInit: IntersectionObserverEntryInit): IntersectionObserverEntry; +} + interface KeyboardEvent extends UIEvent { readonly altKey: boolean; readonly char: string | null; @@ -6817,7 +7294,7 @@ interface MSApp { execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; getCurrentPriority(): string; - getHtmlPrintDocumentSourceAsync(htmlDoc: any): PromiseLike; + getHtmlPrintDocumentSourceAsync(htmlDoc: any): Promise; getViewId(view: any): any; isTaskScheduledAtPriorityOrHigher(priority: string): boolean; pageHandlesAllApplicationActivations(enabled: boolean): void; @@ -6832,13 +7309,13 @@ declare var MSApp: MSApp; interface MSAppAsyncOperationEventMap { "complete": Event; - "error": ErrorEvent; + "error": Event; } interface MSAppAsyncOperation extends EventTarget { readonly error: DOMError; oncomplete: (this: MSAppAsyncOperation, ev: Event) => any; - onerror: (this: MSAppAsyncOperation, ev: ErrorEvent) => any; + onerror: (this: MSAppAsyncOperation, ev: Event) => any; readonly readyState: number; readonly result: any; start(): void; @@ -6878,8 +7355,8 @@ declare var MSBlobBuilder: { } interface MSCredentials { - getAssertion(challenge: string, filter?: MSCredentialFilter, params?: MSSignatureParameters): PromiseLike; - makeCredential(accountInfo: MSAccountInfo, params: MSCredentialParameters[], challenge?: string): PromiseLike; + getAssertion(challenge: string, filter?: MSCredentialFilter, params?: MSSignatureParameters): Promise; + makeCredential(accountInfo: MSAccountInfo, params: MSCredentialParameters[], challenge?: string): Promise; } declare var MSCredentials: { @@ -6995,12 +7472,13 @@ interface MSHTMLWebViewElement extends HTMLElement { goForward(): void; invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; navigate(uri: string): void; + navigateFocus(navigationReason: string, origin: FocusNavigationOrigin): void; navigateToLocalStreamUri(source: string, streamResolver: any): void; navigateToString(contents: string): void; navigateWithHttpRequestMessage(requestMessage: any): void; refresh(): void; stop(): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: MSHTMLWebViewElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7192,7 +7670,7 @@ interface MSStreamReader extends EventTarget, MSBaseReader { readAsBlob(stream: MSStream, size?: number): void; readAsDataURL(stream: MSStream, size?: number): void; readAsText(stream: MSStream, encoding?: string, size?: number): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: MSStreamReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7203,13 +7681,13 @@ declare var MSStreamReader: { interface MSWebViewAsyncOperationEventMap { "complete": Event; - "error": ErrorEvent; + "error": Event; } interface MSWebViewAsyncOperation extends EventTarget { readonly error: DOMError; oncomplete: (this: MSWebViewAsyncOperation, ev: Event) => any; - onerror: (this: MSWebViewAsyncOperation, ev: ErrorEvent) => any; + onerror: (this: MSWebViewAsyncOperation, ev: Event) => any; readonly readyState: number; readonly result: any; readonly target: MSHTMLWebViewElement; @@ -7266,7 +7744,7 @@ interface MediaDevices extends EventTarget { ondevicechange: (this: MediaDevices, ev: Event) => any; enumerateDevices(): any; getSupportedConstraints(): MediaTrackSupportedConstraints; - getUserMedia(constraints: MediaStreamConstraints): PromiseLike; + getUserMedia(constraints: MediaStreamConstraints): Promise; addEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7325,15 +7803,15 @@ declare var MediaKeyMessageEvent: { } interface MediaKeySession extends EventTarget { - readonly closed: PromiseLike; + readonly closed: Promise; readonly expiration: number; readonly keyStatuses: MediaKeyStatusMap; readonly sessionId: string; - close(): PromiseLike; - generateRequest(initDataType: string, initData: any): PromiseLike; - load(sessionId: string): PromiseLike; - remove(): PromiseLike; - update(response: any): PromiseLike; + close(): Promise; + generateRequest(initDataType: string, initData: any): Promise; + load(sessionId: string): Promise; + remove(): Promise; + update(response: any): Promise; } declare var MediaKeySession: { @@ -7355,7 +7833,7 @@ declare var MediaKeyStatusMap: { interface MediaKeySystemAccess { readonly keySystem: string; - createMediaKeys(): PromiseLike; + createMediaKeys(): Promise; getConfiguration(): MediaKeySystemConfiguration; } @@ -7366,7 +7844,7 @@ declare var MediaKeySystemAccess: { interface MediaKeys { createSession(sessionType?: string): MediaKeySession; - setServerCertificate(serverCertificate: any): PromiseLike; + setServerCertificate(serverCertificate: any): Promise; } declare var MediaKeys: { @@ -7419,18 +7897,18 @@ declare var MediaSource: { interface MediaStreamEventMap { "active": Event; - "addtrack": TrackEvent; + "addtrack": MediaStreamTrackEvent; "inactive": Event; - "removetrack": TrackEvent; + "removetrack": MediaStreamTrackEvent; } interface MediaStream extends EventTarget { readonly active: boolean; readonly id: string; onactive: (this: MediaStream, ev: Event) => any; - onaddtrack: (this: MediaStream, ev: TrackEvent) => any; + onaddtrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; oninactive: (this: MediaStream, ev: Event) => any; - onremovetrack: (this: MediaStream, ev: TrackEvent) => any; + onremovetrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; addTrack(track: MediaStreamTrack): void; clone(): MediaStream; getAudioTracks(): MediaStreamTrack[]; @@ -7473,7 +7951,16 @@ interface MediaStreamErrorEvent extends Event { declare var MediaStreamErrorEvent: { prototype: MediaStreamErrorEvent; - new(type: string, eventInitDict?: MediaStreamErrorEventInit): MediaStreamErrorEvent; + new(typeArg: string, eventInitDict?: MediaStreamErrorEventInit): MediaStreamErrorEvent; +} + +interface MediaStreamEvent extends Event { + readonly stream: MediaStream | null; +} + +declare var MediaStreamEvent: { + prototype: MediaStreamEvent; + new(type: string, eventInitDict: MediaStreamEventInit): MediaStreamEvent; } interface MediaStreamTrackEventMap { @@ -7496,7 +7983,7 @@ interface MediaStreamTrack extends EventTarget { readonly readonly: boolean; readonly readyState: string; readonly remote: boolean; - applyConstraints(constraints: MediaTrackConstraints): PromiseLike; + applyConstraints(constraints: MediaTrackConstraints): Promise; clone(): MediaStreamTrack; getCapabilities(): MediaTrackCapabilities; getConstraints(): MediaTrackConstraints; @@ -7517,7 +8004,7 @@ interface MediaStreamTrackEvent extends Event { declare var MediaStreamTrackEvent: { prototype: MediaStreamTrackEvent; - new(type: string, eventInitDict?: MediaStreamTrackEventInit): MediaStreamTrackEvent; + new(typeArg: string, eventInitDict?: MediaStreamTrackEventInit): MediaStreamTrackEvent; } interface MessageChannel { @@ -7550,7 +8037,7 @@ interface MessagePortEventMap { interface MessagePort extends EventTarget { onmessage: (this: MessagePort, ev: MessageEvent) => any; close(): void; - postMessage(message?: any, ports?: any): void; + postMessage(message?: any, transfer?: any[]): void; start(): void; addEventListener(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -7712,9 +8199,10 @@ declare var NavigationEventWithReferrer: { new(): NavigationEventWithReferrer; } -interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorUserMedia { - readonly appCodeName: string; +interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorUserMedia { + readonly authentication: WebAuthentication; readonly cookieEnabled: boolean; + gamepadInputEmulation: string; readonly language: string; readonly maxTouchPoints: number; readonly mimeTypes: MimeTypeArray; @@ -7723,12 +8211,13 @@ interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorConte readonly msPointerEnabled: boolean; readonly plugins: PluginArray; readonly pointerEnabled: boolean; + readonly serviceWorker: ServiceWorkerContainer; readonly webdriver: boolean; readonly hardwareConcurrency: number; getGamepads(): Gamepad[]; javaEnabled(): boolean; msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; - requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): PromiseLike; + requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): Promise; vibrate(pattern: number | number[]): boolean; } @@ -7754,7 +8243,7 @@ interface Node extends EventTarget { readonly parentNode: Node | null; readonly previousSibling: Node | null; textContent: string | null; - appendChild(newChild: Node): Node; + appendChild(newChild: T): T; cloneNode(deep?: boolean): Node; compareDocumentPosition(other: Node): number; contains(child: Node): boolean; @@ -7861,6 +8350,36 @@ declare var NodeList: { new(): NodeList; } +interface NotificationEventMap { + "click": Event; + "close": Event; + "error": Event; + "show": Event; +} + +interface Notification extends EventTarget { + readonly body: string; + readonly dir: string; + readonly icon: string; + readonly lang: string; + onclick: (this: Notification, ev: Event) => any; + onclose: (this: Notification, ev: Event) => any; + onerror: (this: Notification, ev: Event) => any; + onshow: (this: Notification, ev: Event) => any; + readonly permission: string; + readonly tag: string; + readonly title: string; + close(): void; + addEventListener(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Notification: { + prototype: Notification; + new(title: string, options?: NotificationOptions): Notification; + requestPermission(callback?: NotificationPermissionCallback): Promise; +} + interface OES_element_index_uint { } @@ -7895,6 +8414,24 @@ declare var OES_texture_float_linear: { new(): OES_texture_float_linear; } +interface OES_texture_half_float { + readonly HALF_FLOAT_OES: number; +} + +declare var OES_texture_half_float: { + prototype: OES_texture_half_float; + new(): OES_texture_half_float; + readonly HALF_FLOAT_OES: number; +} + +interface OES_texture_half_float_linear { +} + +declare var OES_texture_half_float_linear: { + prototype: OES_texture_half_float_linear; + new(): OES_texture_half_float_linear; +} + interface OfflineAudioCompletionEvent extends Event { readonly renderedBuffer: AudioBuffer; } @@ -7904,13 +8441,15 @@ declare var OfflineAudioCompletionEvent: { new(): OfflineAudioCompletionEvent; } -interface OfflineAudioContextEventMap { - "complete": Event; +interface OfflineAudioContextEventMap extends AudioContextEventMap { + "complete": OfflineAudioCompletionEvent; } -interface OfflineAudioContext extends AudioContext { - oncomplete: (this: OfflineAudioContext, ev: Event) => any; - startRendering(): PromiseLike; +interface OfflineAudioContext extends AudioContextBase { + readonly length: number; + oncomplete: (this: OfflineAudioContext, ev: OfflineAudioCompletionEvent) => any; + startRendering(): Promise; + suspend(suspendTime: number): Promise; addEventListener(type: K, listener: (this: OfflineAudioContext, ev: OfflineAudioContextEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7986,6 +8525,82 @@ declare var PannerNode: { new(): PannerNode; } +interface Path2D extends Object, CanvasPathMethods { +} + +declare var Path2D: { + prototype: Path2D; + new(path?: Path2D): Path2D; +} + +interface PaymentAddress { + readonly addressLine: string[]; + readonly city: string; + readonly country: string; + readonly dependentLocality: string; + readonly languageCode: string; + readonly organization: string; + readonly phone: string; + readonly postalCode: string; + readonly recipient: string; + readonly region: string; + readonly sortingCode: string; + toJSON(): any; +} + +declare var PaymentAddress: { + prototype: PaymentAddress; + new(): PaymentAddress; +} + +interface PaymentRequestEventMap { + "shippingaddresschange": Event; + "shippingoptionchange": Event; +} + +interface PaymentRequest extends EventTarget { + onshippingaddresschange: (this: PaymentRequest, ev: Event) => any; + onshippingoptionchange: (this: PaymentRequest, ev: Event) => any; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + readonly shippingType: string | null; + abort(): Promise; + show(): Promise; + addEventListener(type: K, listener: (this: PaymentRequest, ev: PaymentRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var PaymentRequest: { + prototype: PaymentRequest; + new(methodData: PaymentMethodData[], details: PaymentDetails, options?: PaymentOptions): PaymentRequest; +} + +interface PaymentRequestUpdateEvent extends Event { + updateWith(d: Promise): void; +} + +declare var PaymentRequestUpdateEvent: { + prototype: PaymentRequestUpdateEvent; + new(type: string, eventInitDict?: PaymentRequestUpdateEventInit): PaymentRequestUpdateEvent; +} + +interface PaymentResponse { + readonly details: any; + readonly methodName: string; + readonly payerEmail: string | null; + readonly payerName: string | null; + readonly payerPhone: string | null; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + complete(result?: string): Promise; + toJSON(): any; +} + +declare var PaymentResponse: { + prototype: PaymentResponse; + new(): PaymentResponse; +} + interface PerfWidgetExternal { readonly activeNetworkRequestCount: number; readonly averageFrameTime: number; @@ -8251,7 +8866,7 @@ interface PopStateEvent extends Event { declare var PopStateEvent: { prototype: PopStateEvent; - new(): PopStateEvent; + new(typeArg: string, eventInitDict?: PopStateEventInit): PopStateEvent; } interface Position { @@ -8302,23 +8917,57 @@ declare var ProgressEvent: { new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } +interface PushManager { + getSubscription(): Promise; + permissionState(options?: PushSubscriptionOptionsInit): Promise; + subscribe(options?: PushSubscriptionOptionsInit): Promise; +} + +declare var PushManager: { + prototype: PushManager; + new(): PushManager; +} + +interface PushSubscription { + readonly endpoint: USVString; + readonly options: PushSubscriptionOptions; + getKey(name: string): ArrayBuffer | null; + toJSON(): any; + unsubscribe(): Promise; +} + +declare var PushSubscription: { + prototype: PushSubscription; + new(): PushSubscription; +} + +interface PushSubscriptionOptions { + readonly applicationServerKey: ArrayBuffer | null; + readonly userVisibleOnly: boolean; +} + +declare var PushSubscriptionOptions: { + prototype: PushSubscriptionOptions; + new(): PushSubscriptionOptions; +} + interface RTCDTMFToneChangeEvent extends Event { readonly tone: string; } declare var RTCDTMFToneChangeEvent: { prototype: RTCDTMFToneChangeEvent; - new(type: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; + new(typeArg: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; } interface RTCDtlsTransportEventMap { "dtlsstatechange": RTCDtlsTransportStateChangedEvent; - "error": ErrorEvent; + "error": Event; } interface RTCDtlsTransport extends RTCStatsProvider { ondtlsstatechange: ((this: RTCDtlsTransport, ev: RTCDtlsTransportStateChangedEvent) => any) | null; - onerror: ((this: RTCDtlsTransport, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCDtlsTransport, ev: Event) => any) | null; readonly state: string; readonly transport: RTCIceTransport; getLocalParameters(): RTCDtlsParameters; @@ -8365,6 +9014,18 @@ declare var RTCDtmfSender: { new(sender: RTCRtpSender): RTCDtmfSender; } +interface RTCIceCandidate { + candidate: string | null; + sdpMLineIndex: number | null; + sdpMid: string | null; + toJSON(): any; +} + +declare var RTCIceCandidate: { + prototype: RTCIceCandidate; + new(candidateInitDict?: RTCIceCandidateInit): RTCIceCandidate; +} + interface RTCIceCandidatePairChangedEvent extends Event { readonly pair: RTCIceCandidatePair; } @@ -8375,16 +9036,16 @@ declare var RTCIceCandidatePairChangedEvent: { } interface RTCIceGathererEventMap { - "error": ErrorEvent; + "error": Event; "localcandidate": RTCIceGathererEvent; } interface RTCIceGatherer extends RTCStatsProvider { readonly component: string; - onerror: ((this: RTCIceGatherer, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCIceGatherer, ev: Event) => any) | null; onlocalcandidate: ((this: RTCIceGatherer, ev: RTCIceGathererEvent) => any) | null; createAssociatedGatherer(): RTCIceGatherer; - getLocalCandidates(): RTCIceCandidate[]; + getLocalCandidates(): RTCIceCandidateDictionary[]; getLocalParameters(): RTCIceParameters; addEventListener(type: K, listener: (this: RTCIceGatherer, ev: RTCIceGathererEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -8396,7 +9057,7 @@ declare var RTCIceGatherer: { } interface RTCIceGathererEvent extends Event { - readonly candidate: RTCIceCandidate | RTCIceCandidateComplete; + readonly candidate: RTCIceCandidateDictionary | RTCIceCandidateComplete; } declare var RTCIceGathererEvent: { @@ -8416,12 +9077,12 @@ interface RTCIceTransport extends RTCStatsProvider { onicestatechange: ((this: RTCIceTransport, ev: RTCIceTransportStateChangedEvent) => any) | null; readonly role: string; readonly state: string; - addRemoteCandidate(remoteCandidate: RTCIceCandidate | RTCIceCandidateComplete): void; + addRemoteCandidate(remoteCandidate: RTCIceCandidateDictionary | RTCIceCandidateComplete): void; createAssociatedTransport(): RTCIceTransport; getNominatedCandidatePair(): RTCIceCandidatePair | null; - getRemoteCandidates(): RTCIceCandidate[]; + getRemoteCandidates(): RTCIceCandidateDictionary[]; getRemoteParameters(): RTCIceParameters | null; - setRemoteCandidates(remoteCandidates: RTCIceCandidate[]): void; + setRemoteCandidates(remoteCandidates: RTCIceCandidateDictionary[]): void; start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: string): void; stop(): void; addEventListener(type: K, listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any, useCapture?: boolean): void; @@ -8442,12 +9103,67 @@ declare var RTCIceTransportStateChangedEvent: { new(): RTCIceTransportStateChangedEvent; } +interface RTCPeerConnectionEventMap { + "addstream": MediaStreamEvent; + "icecandidate": RTCPeerConnectionIceEvent; + "iceconnectionstatechange": Event; + "icegatheringstatechange": Event; + "negotiationneeded": Event; + "removestream": MediaStreamEvent; + "signalingstatechange": Event; +} + +interface RTCPeerConnection extends EventTarget { + readonly canTrickleIceCandidates: boolean | null; + readonly iceConnectionState: string; + readonly iceGatheringState: string; + readonly localDescription: RTCSessionDescription | null; + onaddstream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onicecandidate: (this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any; + oniceconnectionstatechange: (this: RTCPeerConnection, ev: Event) => any; + onicegatheringstatechange: (this: RTCPeerConnection, ev: Event) => any; + onnegotiationneeded: (this: RTCPeerConnection, ev: Event) => any; + onremovestream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onsignalingstatechange: (this: RTCPeerConnection, ev: Event) => any; + readonly remoteDescription: RTCSessionDescription | null; + readonly signalingState: string; + addIceCandidate(candidate: RTCIceCandidate, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addStream(stream: MediaStream): void; + close(): void; + createAnswer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + createOffer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback, options?: RTCOfferOptions): Promise; + getConfiguration(): RTCConfiguration; + getLocalStreams(): MediaStream[]; + getRemoteStreams(): MediaStream[]; + getStats(selector: MediaStreamTrack | null, successCallback?: RTCStatsCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + getStreamById(streamId: string): MediaStream | null; + removeStream(stream: MediaStream): void; + setLocalDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + setRemoteDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addEventListener(type: K, listener: (this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCPeerConnection: { + prototype: RTCPeerConnection; + new(configuration: RTCConfiguration): RTCPeerConnection; +} + +interface RTCPeerConnectionIceEvent extends Event { + readonly candidate: RTCIceCandidate; +} + +declare var RTCPeerConnectionIceEvent: { + prototype: RTCPeerConnectionIceEvent; + new(type: string, eventInitDict: RTCPeerConnectionIceEventInit): RTCPeerConnectionIceEvent; +} + interface RTCRtpReceiverEventMap { - "error": ErrorEvent; + "error": Event; } interface RTCRtpReceiver extends RTCStatsProvider { - onerror: ((this: RTCRtpReceiver, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCRtpReceiver, ev: Event) => any) | null; readonly rtcpTransport: RTCDtlsTransport; readonly track: MediaStreamTrack | null; readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; @@ -8467,12 +9183,12 @@ declare var RTCRtpReceiver: { } interface RTCRtpSenderEventMap { - "error": ErrorEvent; + "error": Event; "ssrcconflict": RTCSsrcConflictEvent; } interface RTCRtpSender extends RTCStatsProvider { - onerror: ((this: RTCRtpSender, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCRtpSender, ev: Event) => any) | null; onssrcconflict: ((this: RTCRtpSender, ev: RTCSsrcConflictEvent) => any) | null; readonly rtcpTransport: RTCDtlsTransport; readonly track: MediaStreamTrack; @@ -8491,12 +9207,23 @@ declare var RTCRtpSender: { getCapabilities(kind?: string): RTCRtpCapabilities; } +interface RTCSessionDescription { + sdp: string | null; + type: string | null; + toJSON(): any; +} + +declare var RTCSessionDescription: { + prototype: RTCSessionDescription; + new(descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription; +} + interface RTCSrtpSdesTransportEventMap { - "error": ErrorEvent; + "error": Event; } interface RTCSrtpSdesTransport extends EventTarget { - onerror: ((this: RTCSrtpSdesTransport, ev: ErrorEvent) => any) | null; + onerror: ((this: RTCSrtpSdesTransport, ev: Event) => any) | null; readonly transport: RTCIceTransport; addEventListener(type: K, listener: (this: RTCSrtpSdesTransport, ev: RTCSrtpSdesTransportEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -8518,8 +9245,8 @@ declare var RTCSsrcConflictEvent: { } interface RTCStatsProvider extends EventTarget { - getStats(): PromiseLike; - msGetStats(): PromiseLike; + getStats(): Promise; + msGetStats(): Promise; } declare var RTCStatsProvider: { @@ -8571,9 +9298,69 @@ declare var Range: { readonly START_TO_START: number; } -interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface ReadableStream { + readonly locked: boolean; + cancel(): Promise; + getReader(): ReadableStreamReader; +} + +declare var ReadableStream: { + prototype: ReadableStream; + new(): ReadableStream; +} + +interface ReadableStreamReader { + cancel(): Promise; + read(): Promise; + releaseLock(): void; +} + +declare var ReadableStreamReader: { + prototype: ReadableStreamReader; + new(): ReadableStreamReader; +} + +interface Request extends Object, Body { + readonly cache: string; + readonly credentials: string; + readonly destination: string; + readonly headers: Headers; + readonly integrity: string; + readonly keepalive: boolean; + readonly method: string; + readonly mode: string; + readonly redirect: string; + readonly referrer: string; + readonly referrerPolicy: string; + readonly type: string; + readonly url: string; + clone(): Request; +} + +declare var Request: { + prototype: Request; + new(input: Request | string, init?: RequestInit): Request; +} + +interface Response extends Object, Body { + readonly body: ReadableStream | null; + readonly headers: Headers; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly type: string; + readonly url: string; + clone(): Response; +} + +declare var Response: { + prototype: Response; + new(body?: any, init?: ResponseInit): Response; +} + +interface SVGAElement extends SVGGraphicsElement, SVGURIReference { readonly target: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8726,11 +9513,11 @@ declare var SVGAnimatedTransformList: { new(): SVGAnimatedTransformList; } -interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGCircleElement extends SVGGraphicsElement { readonly cx: SVGAnimatedLength; readonly cy: SVGAnimatedLength; readonly r: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGCircleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8739,9 +9526,9 @@ declare var SVGCircleElement: { new(): SVGCircleElement; } -interface SVGClipPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { +interface SVGClipPathElement extends SVGGraphicsElement, SVGUnitTypes { readonly clipPathUnits: SVGAnimatedEnumeration; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGClipPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8764,7 +9551,7 @@ interface SVGComponentTransferFunctionElement extends SVGElement { readonly SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; readonly SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGComponentTransferFunctionElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8779,8 +9566,8 @@ declare var SVGComponentTransferFunctionElement: { readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; } -interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGDefsElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGDefsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8789,8 +9576,8 @@ declare var SVGDefsElement: { new(): SVGDefsElement; } -interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGDescElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGDescElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8813,6 +9600,7 @@ interface SVGElementEventMap extends ElementEventMap { } interface SVGElement extends Element { + className: any; onclick: (this: SVGElement, ev: MouseEvent) => any; ondblclick: (this: SVGElement, ev: MouseEvent) => any; onfocusin: (this: SVGElement, ev: FocusEvent) => any; @@ -8824,9 +9612,9 @@ interface SVGElement extends Element { onmouseover: (this: SVGElement, ev: MouseEvent) => any; onmouseup: (this: SVGElement, ev: MouseEvent) => any; readonly ownerSVGElement: SVGSVGElement; + readonly style: CSSStyleDeclaration; readonly viewportElement: SVGElement; xmlbase: string; - className: any; addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8862,12 +9650,12 @@ declare var SVGElementInstanceList: { new(): SVGElementInstanceList; } -interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGEllipseElement extends SVGGraphicsElement { readonly cx: SVGAnimatedLength; readonly cy: SVGAnimatedLength; readonly rx: SVGAnimatedLength; readonly ry: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGEllipseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8897,7 +9685,7 @@ interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttrib readonly SVG_FEBLEND_MODE_SCREEN: number; readonly SVG_FEBLEND_MODE_SOFT_LIGHT: number; readonly SVG_FEBLEND_MODE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEBlendElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8932,7 +9720,7 @@ interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandard readonly SVG_FECOLORMATRIX_TYPE_MATRIX: number; readonly SVG_FECOLORMATRIX_TYPE_SATURATE: number; readonly SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEColorMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8948,7 +9736,7 @@ declare var SVGFEColorMatrixElement: { interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEComponentTransferElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8972,7 +9760,7 @@ interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAt readonly SVG_FECOMPOSITE_OPERATOR_OVER: number; readonly SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; readonly SVG_FECOMPOSITE_OPERATOR_XOR: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFECompositeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9005,7 +9793,7 @@ interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStand readonly SVG_EDGEMODE_NONE: number; readonly SVG_EDGEMODE_UNKNOWN: number; readonly SVG_EDGEMODE_WRAP: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEConvolveMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9024,7 +9812,7 @@ interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStan readonly kernelUnitLengthX: SVGAnimatedNumber; readonly kernelUnitLengthY: SVGAnimatedNumber; readonly surfaceScale: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDiffuseLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9044,7 +9832,7 @@ interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStan readonly SVG_CHANNEL_G: number; readonly SVG_CHANNEL_R: number; readonly SVG_CHANNEL_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDisplacementMapElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9061,7 +9849,7 @@ declare var SVGFEDisplacementMapElement: { interface SVGFEDistantLightElement extends SVGElement { readonly azimuth: SVGAnimatedNumber; readonly elevation: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEDistantLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9071,7 +9859,7 @@ declare var SVGFEDistantLightElement: { } interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEFloodElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9081,6 +9869,8 @@ declare var SVGFEFloodElement: { } interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncAElement: { @@ -9089,6 +9879,8 @@ declare var SVGFEFuncAElement: { } interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncBElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncBElement: { @@ -9097,6 +9889,8 @@ declare var SVGFEFuncBElement: { } interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncGElement: { @@ -9105,6 +9899,8 @@ declare var SVGFEFuncGElement: { } interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncRElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEFuncRElement: { @@ -9117,7 +9913,7 @@ interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandar readonly stdDeviationX: SVGAnimatedNumber; readonly stdDeviationY: SVGAnimatedNumber; setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEGaussianBlurElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9126,9 +9922,9 @@ declare var SVGFEGaussianBlurElement: { new(): SVGFEGaussianBlurElement; } -interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { +interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGURIReference { readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9138,7 +9934,7 @@ declare var SVGFEImageElement: { } interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMergeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9149,7 +9945,7 @@ declare var SVGFEMergeElement: { interface SVGFEMergeNodeElement extends SVGElement { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMergeNodeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9166,7 +9962,7 @@ interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardA readonly SVG_MORPHOLOGY_OPERATOR_DILATE: number; readonly SVG_MORPHOLOGY_OPERATOR_ERODE: number; readonly SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEMorphologyElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9182,7 +9978,7 @@ interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttri readonly dx: SVGAnimatedNumber; readonly dy: SVGAnimatedNumber; readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEOffsetElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9195,7 +9991,7 @@ interface SVGFEPointLightElement extends SVGElement { readonly x: SVGAnimatedNumber; readonly y: SVGAnimatedNumber; readonly z: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFEPointLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9211,7 +10007,7 @@ interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveSta readonly specularConstant: SVGAnimatedNumber; readonly specularExponent: SVGAnimatedNumber; readonly surfaceScale: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFESpecularLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9229,7 +10025,7 @@ interface SVGFESpotLightElement extends SVGElement { readonly x: SVGAnimatedNumber; readonly y: SVGAnimatedNumber; readonly z: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFESpotLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9240,7 +10036,7 @@ declare var SVGFESpotLightElement: { interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { readonly in1: SVGAnimatedString; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFETileElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9262,7 +10058,7 @@ interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardA readonly SVG_TURBULENCE_TYPE_FRACTALNOISE: number; readonly SVG_TURBULENCE_TYPE_TURBULENCE: number; readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFETurbulenceElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9277,7 +10073,7 @@ declare var SVGFETurbulenceElement: { readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; } -interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { +interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGURIReference { readonly filterResX: SVGAnimatedInteger; readonly filterResY: SVGAnimatedInteger; readonly filterUnits: SVGAnimatedEnumeration; @@ -9287,7 +10083,7 @@ interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLan readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; setFilterRes(filterResX: number, filterResY: number): void; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGFilterElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9296,12 +10092,12 @@ declare var SVGFilterElement: { new(): SVGFilterElement; } -interface SVGForeignObjectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGForeignObjectElement extends SVGGraphicsElement { readonly height: SVGAnimatedLength; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGForeignObjectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9310,8 +10106,8 @@ declare var SVGForeignObjectElement: { new(): SVGForeignObjectElement; } -interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGGElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9320,7 +10116,7 @@ declare var SVGGElement: { new(): SVGGElement; } -interface SVGGradientElement extends SVGElement, SVGStylable, SVGExternalResourcesRequired, SVGURIReference, SVGUnitTypes { +interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGURIReference { readonly gradientTransform: SVGAnimatedTransformList; readonly gradientUnits: SVGAnimatedEnumeration; readonly spreadMethod: SVGAnimatedEnumeration; @@ -9328,7 +10124,7 @@ interface SVGGradientElement extends SVGElement, SVGStylable, SVGExternalResourc readonly SVG_SPREADMETHOD_REFLECT: number; readonly SVG_SPREADMETHOD_REPEAT: number; readonly SVG_SPREADMETHOD_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9341,13 +10137,30 @@ declare var SVGGradientElement: { readonly SVG_SPREADMETHOD_UNKNOWN: number; } -interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface SVGGraphicsElement extends SVGElement, SVGTests { + readonly farthestViewportElement: SVGElement; + readonly nearestViewportElement: SVGElement; + readonly transform: SVGAnimatedTransformList; + getBBox(): SVGRect; + getCTM(): SVGMatrix; + getScreenCTM(): SVGMatrix; + getTransformToElement(element: SVGElement): SVGMatrix; + addEventListener(type: K, listener: (this: SVGGraphicsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGraphicsElement: { + prototype: SVGGraphicsElement; + new(): SVGGraphicsElement; +} + +interface SVGImageElement extends SVGGraphicsElement, SVGURIReference { readonly height: SVGAnimatedLength; readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9408,12 +10221,12 @@ declare var SVGLengthList: { new(): SVGLengthList; } -interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGLineElement extends SVGGraphicsElement { readonly x1: SVGAnimatedLength; readonly x2: SVGAnimatedLength; readonly y1: SVGAnimatedLength; readonly y2: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGLineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9427,6 +10240,8 @@ interface SVGLinearGradientElement extends SVGGradientElement { readonly x2: SVGAnimatedLength; readonly y1: SVGAnimatedLength; readonly y2: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGLinearGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGLinearGradientElement: { @@ -9434,7 +10249,7 @@ declare var SVGLinearGradientElement: { new(): SVGLinearGradientElement; } -interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { +interface SVGMarkerElement extends SVGElement, SVGFitToViewBox { readonly markerHeight: SVGAnimatedLength; readonly markerUnits: SVGAnimatedEnumeration; readonly markerWidth: SVGAnimatedLength; @@ -9450,7 +10265,7 @@ interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExt readonly SVG_MARKER_ORIENT_ANGLE: number; readonly SVG_MARKER_ORIENT_AUTO: number; readonly SVG_MARKER_ORIENT_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMarkerElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9465,14 +10280,14 @@ declare var SVGMarkerElement: { readonly SVG_MARKER_ORIENT_UNKNOWN: number; } -interface SVGMaskElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { +interface SVGMaskElement extends SVGElement, SVGTests, SVGUnitTypes { readonly height: SVGAnimatedLength; readonly maskContentUnits: SVGAnimatedEnumeration; readonly maskUnits: SVGAnimatedEnumeration; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMaskElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9507,7 +10322,7 @@ declare var SVGMatrix: { } interface SVGMetadataElement extends SVGElement { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGMetadataElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9541,7 +10356,8 @@ declare var SVGNumberList: { new(): SVGNumberList; } -interface SVGPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPathData { +interface SVGPathElement extends SVGGraphicsElement { + readonly pathSegList: SVGPathSegList; createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; createSVGPathSegClosePath(): SVGPathSegClosePath; @@ -9564,7 +10380,7 @@ interface SVGPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGT getPathSegAtLength(distance: number): number; getPointAtLength(distance: number): SVGPoint; getTotalLength(): number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9849,7 +10665,7 @@ declare var SVGPathSegMovetoRel: { new(): SVGPathSegMovetoRel; } -interface SVGPatternElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGURIReference, SVGUnitTypes { +interface SVGPatternElement extends SVGElement, SVGTests, SVGUnitTypes, SVGFitToViewBox, SVGURIReference { readonly height: SVGAnimatedLength; readonly patternContentUnits: SVGAnimatedEnumeration; readonly patternTransform: SVGAnimatedTransformList; @@ -9857,7 +10673,7 @@ interface SVGPatternElement extends SVGElement, SVGStylable, SVGTests, SVGLangSp readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGPatternElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9893,8 +10709,8 @@ declare var SVGPointList: { new(): SVGPointList; } -interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPoints { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGPolygonElement extends SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolygonElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9903,8 +10719,8 @@ declare var SVGPolygonElement: { new(): SVGPolygonElement; } -interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPoints { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGPolylineElement extends SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolylineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9957,6 +10773,8 @@ interface SVGRadialGradientElement extends SVGGradientElement { readonly fx: SVGAnimatedLength; readonly fy: SVGAnimatedLength; readonly r: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGRadialGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGRadialGradientElement: { @@ -9976,14 +10794,14 @@ declare var SVGRect: { new(): SVGRect; } -interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGRectElement extends SVGGraphicsElement { readonly height: SVGAnimatedLength; readonly rx: SVGAnimatedLength; readonly ry: SVGAnimatedLength; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGRectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10001,7 +10819,7 @@ interface SVGSVGElementEventMap extends SVGElementEventMap { "SVGZoom": SVGZoomEvent; } -interface SVGSVGElement extends SVGElement, DocumentEvent, SVGLocatable, SVGTests, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { +interface SVGSVGElement extends SVGGraphicsElement, DocumentEvent, SVGFitToViewBox, SVGZoomAndPan { contentScriptType: string; contentStyleType: string; currentScale: number; @@ -10053,9 +10871,9 @@ declare var SVGSVGElement: { new(): SVGSVGElement; } -interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { +interface SVGScriptElement extends SVGElement, SVGURIReference { type: string; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGScriptElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10064,9 +10882,9 @@ declare var SVGScriptElement: { new(): SVGScriptElement; } -interface SVGStopElement extends SVGElement, SVGStylable { +interface SVGStopElement extends SVGElement { readonly offset: SVGAnimatedNumber; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGStopElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10091,12 +10909,12 @@ declare var SVGStringList: { new(): SVGStringList; } -interface SVGStyleElement extends SVGElement, SVGLangSpace { +interface SVGStyleElement extends SVGElement { disabled: boolean; media: string; title: string; type: string; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGStyleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10105,8 +10923,8 @@ declare var SVGStyleElement: { new(): SVGStyleElement; } -interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGSwitchElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGSwitchElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10115,8 +10933,8 @@ declare var SVGSwitchElement: { new(): SVGSwitchElement; } -interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGSymbolElement extends SVGElement, SVGFitToViewBox { + addEventListener(type: K, listener: (this: SVGSymbolElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10126,6 +10944,8 @@ declare var SVGSymbolElement: { } interface SVGTSpanElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTSpanElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTSpanElement: { @@ -10133,7 +10953,7 @@ declare var SVGTSpanElement: { new(): SVGTSpanElement; } -interface SVGTextContentElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { +interface SVGTextContentElement extends SVGGraphicsElement { readonly lengthAdjust: SVGAnimatedEnumeration; readonly textLength: SVGAnimatedLength; getCharNumAtPosition(point: SVGPoint): number; @@ -10148,7 +10968,7 @@ interface SVGTextContentElement extends SVGElement, SVGStylable, SVGTests, SVGLa readonly LENGTHADJUST_SPACING: number; readonly LENGTHADJUST_SPACINGANDGLYPHS: number; readonly LENGTHADJUST_UNKNOWN: number; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGTextContentElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10160,7 +10980,9 @@ declare var SVGTextContentElement: { readonly LENGTHADJUST_UNKNOWN: number; } -interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { +interface SVGTextElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTextElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextElement: { @@ -10178,6 +11000,8 @@ interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { readonly TEXTPATH_SPACINGTYPE_AUTO: number; readonly TEXTPATH_SPACINGTYPE_EXACT: number; readonly TEXTPATH_SPACINGTYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGTextPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextPathElement: { @@ -10197,6 +11021,8 @@ interface SVGTextPositioningElement extends SVGTextContentElement { readonly rotate: SVGAnimatedNumberList; readonly x: SVGAnimatedLengthList; readonly y: SVGAnimatedLengthList; + addEventListener(type: K, listener: (this: SVGTextPositioningElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextPositioningElement: { @@ -10204,8 +11030,8 @@ declare var SVGTextPositioningElement: { new(): SVGTextPositioningElement; } -interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; +interface SVGTitleElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGTitleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10270,14 +11096,14 @@ interface SVGUnitTypes { } declare var SVGUnitTypes: SVGUnitTypes; -interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { +interface SVGUseElement extends SVGGraphicsElement, SVGURIReference { readonly animatedInstanceRoot: SVGElementInstance; readonly height: SVGAnimatedLength; readonly instanceRoot: SVGElementInstance; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGUseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10286,9 +11112,9 @@ declare var SVGUseElement: { new(): SVGUseElement; } -interface SVGViewElement extends SVGElement, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { +interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox { readonly viewTarget: SVGStringList; - addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: SVGViewElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10320,6 +11146,26 @@ declare var SVGZoomEvent: { new(): SVGZoomEvent; } +interface ScopedCredential { + readonly id: ArrayBuffer; + readonly type: string; +} + +declare var ScopedCredential: { + prototype: ScopedCredential; + new(): ScopedCredential; +} + +interface ScopedCredentialInfo { + readonly credential: ScopedCredential; + readonly publicKey: CryptoKey; +} + +declare var ScopedCredentialInfo: { + prototype: ScopedCredentialInfo; + new(): ScopedCredentialInfo; +} + interface ScreenEventMap { "MSOrientationChange": Event; } @@ -10381,6 +11227,10 @@ declare var ScriptProcessorNode: { interface Selection { readonly anchorNode: Node; readonly anchorOffset: number; + readonly baseNode: Node; + readonly baseOffset: number; + readonly extentNode: Node; + readonly extentOffset: number; readonly focusNode: Node; readonly focusOffset: number; readonly isCollapsed: boolean; @@ -10399,6 +11249,7 @@ interface Selection { removeRange(range: Range): void; selectAllChildren(parentNode: Node): void; setBaseAndExtent(baseNode: Node, baseOffset: number, extentNode: Node, extentOffset: number): void; + setPosition(parentNode: Node, offset: number): void; toString(): string; } @@ -10407,6 +11258,84 @@ declare var Selection: { new(): Selection; } +interface ServiceWorkerEventMap extends AbstractWorkerEventMap { + "statechange": Event; +} + +interface ServiceWorker extends EventTarget, AbstractWorker { + onstatechange: (this: ServiceWorker, ev: Event) => any; + readonly scriptURL: USVString; + readonly state: string; + postMessage(message: any, transfer?: any[]): void; + addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorker: { + prototype: ServiceWorker; + new(): ServiceWorker; +} + +interface ServiceWorkerContainerEventMap { + "controllerchange": Event; + "message": ServiceWorkerMessageEvent; +} + +interface ServiceWorkerContainer extends EventTarget { + readonly controller: ServiceWorker | null; + oncontrollerchange: (this: ServiceWorkerContainer, ev: Event) => any; + onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any; + readonly ready: Promise; + getRegistration(clientURL?: USVString): Promise; + getRegistrations(): any; + register(scriptURL: USVString, options?: RegistrationOptions): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerContainer: { + prototype: ServiceWorkerContainer; + new(): ServiceWorkerContainer; +} + +interface ServiceWorkerMessageEvent extends Event { + readonly data: any; + readonly lastEventId: string; + readonly origin: string; + readonly ports: MessagePort[] | null; + readonly source: ServiceWorker | MessagePort | null; +} + +declare var ServiceWorkerMessageEvent: { + prototype: ServiceWorkerMessageEvent; + new(type: string, eventInitDict?: ServiceWorkerMessageEventInit): ServiceWorkerMessageEvent; +} + +interface ServiceWorkerRegistrationEventMap { + "updatefound": Event; +} + +interface ServiceWorkerRegistration extends EventTarget { + readonly active: ServiceWorker | null; + readonly installing: ServiceWorker | null; + onupdatefound: (this: ServiceWorkerRegistration, ev: Event) => any; + readonly pushManager: PushManager; + readonly scope: USVString; + readonly sync: SyncManager; + readonly waiting: ServiceWorker | null; + getNotifications(filter?: GetNotificationOptions): any; + showNotification(title: string, options?: NotificationOptions): Promise; + unregister(): Promise; + update(): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerRegistration: { + prototype: ServiceWorkerRegistration; + new(): ServiceWorkerRegistration; +} + interface SourceBuffer extends EventTarget { appendWindowEnd: number; appendWindowStart: number; @@ -10438,6 +11367,87 @@ declare var SourceBufferList: { new(): SourceBufferList; } +interface SpeechSynthesisEventMap { + "voiceschanged": Event; +} + +interface SpeechSynthesis extends EventTarget { + onvoiceschanged: (this: SpeechSynthesis, ev: Event) => any; + readonly paused: boolean; + readonly pending: boolean; + readonly speaking: boolean; + cancel(): void; + getVoices(): SpeechSynthesisVoice[]; + pause(): void; + resume(): void; + speak(utterance: SpeechSynthesisUtterance): void; + addEventListener(type: K, listener: (this: SpeechSynthesis, ev: SpeechSynthesisEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesis: { + prototype: SpeechSynthesis; + new(): SpeechSynthesis; +} + +interface SpeechSynthesisEvent extends Event { + readonly charIndex: number; + readonly elapsedTime: number; + readonly name: string; + readonly utterance: SpeechSynthesisUtterance | null; +} + +declare var SpeechSynthesisEvent: { + prototype: SpeechSynthesisEvent; + new(type: string, eventInitDict?: SpeechSynthesisEventInit): SpeechSynthesisEvent; +} + +interface SpeechSynthesisUtteranceEventMap { + "boundary": Event; + "end": Event; + "error": Event; + "mark": Event; + "pause": Event; + "resume": Event; + "start": Event; +} + +interface SpeechSynthesisUtterance extends EventTarget { + lang: string; + onboundary: (this: SpeechSynthesisUtterance, ev: Event) => any; + onend: (this: SpeechSynthesisUtterance, ev: Event) => any; + onerror: (this: SpeechSynthesisUtterance, ev: Event) => any; + onmark: (this: SpeechSynthesisUtterance, ev: Event) => any; + onpause: (this: SpeechSynthesisUtterance, ev: Event) => any; + onresume: (this: SpeechSynthesisUtterance, ev: Event) => any; + onstart: (this: SpeechSynthesisUtterance, ev: Event) => any; + pitch: number; + rate: number; + text: string; + voice: SpeechSynthesisVoice; + volume: number; + addEventListener(type: K, listener: (this: SpeechSynthesisUtterance, ev: SpeechSynthesisUtteranceEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesisUtterance: { + prototype: SpeechSynthesisUtterance; + new(text?: string): SpeechSynthesisUtterance; +} + +interface SpeechSynthesisVoice { + readonly default: boolean; + readonly lang: string; + readonly localService: boolean; + readonly name: string; + readonly voiceURI: string; +} + +declare var SpeechSynthesisVoice: { + prototype: SpeechSynthesisVoice; + new(): SpeechSynthesisVoice; +} + interface StereoPannerNode extends AudioNode { readonly pan: AudioParam; } @@ -10549,6 +11559,16 @@ declare var SubtleCrypto: { new(): SubtleCrypto; } +interface SyncManager { + getTags(): any; + register(tag: string): Promise; +} + +declare var SyncManager: { + prototype: SyncManager; + new(): SyncManager; +} + interface Text extends CharacterData { readonly wholeText: string; readonly assignedSlot: HTMLSlotElement | null; @@ -10603,7 +11623,7 @@ declare var TextMetrics: { interface TextTrackEventMap { "cuechange": Event; - "error": ErrorEvent; + "error": Event; "load": Event; } @@ -10616,7 +11636,7 @@ interface TextTrack extends EventTarget { readonly language: string; mode: any; oncuechange: (this: TextTrack, ev: Event) => any; - onerror: (this: TextTrack, ev: ErrorEvent) => any; + onerror: (this: TextTrack, ev: Event) => any; onload: (this: TextTrack, ev: Event) => any; readonly readyState: number; addCue(cue: TextTrackCue): void; @@ -10728,11 +11748,14 @@ declare var Touch: { interface TouchEvent extends UIEvent { readonly altKey: boolean; readonly changedTouches: TouchList; + readonly charCode: number; readonly ctrlKey: boolean; + readonly keyCode: number; readonly metaKey: boolean; readonly shiftKey: boolean; readonly targetTouches: TouchList; readonly touches: TouchList; + readonly which: number; } declare var TouchEvent: { @@ -10752,12 +11775,12 @@ declare var TouchList: { } interface TrackEvent extends Event { - readonly track: any; + readonly track: VideoTrack | AudioTrack | TextTrack | null; } declare var TrackEvent: { prototype: TrackEvent; - new(): TrackEvent; + new(typeArg: string, eventInitDict?: TrackEventInit): TrackEvent; } interface TransitionEvent extends Event { @@ -10768,7 +11791,7 @@ interface TransitionEvent extends Event { declare var TransitionEvent: { prototype: TransitionEvent; - new(): TransitionEvent; + new(typeArg: string, eventInitDict?: TransitionEventInit): TransitionEvent; } interface TreeWalker { @@ -10799,7 +11822,7 @@ interface UIEvent extends Event { declare var UIEvent: { prototype: UIEvent; - new(type: string, eventInitDict?: UIEventInit): UIEvent; + new(typeArg: string, eventInitDict?: UIEventInit): UIEvent; } interface URL { @@ -10814,6 +11837,7 @@ interface URL { protocol: string; search: string; username: string; + readonly searchparams: URLSearchParams; toString(): string; } @@ -10950,6 +11974,28 @@ declare var WaveShaperNode: { new(): WaveShaperNode; } +interface WebAuthentication { + getAssertion(assertionChallenge: any, options?: AssertionOptions): Promise; + makeCredential(accountInformation: Account, cryptoParameters: ScopedCredentialParameters[], attestationChallenge: any, options?: ScopedCredentialOptions): Promise; +} + +declare var WebAuthentication: { + prototype: WebAuthentication; + new(): WebAuthentication; +} + +interface WebAuthnAssertion { + readonly authenticatorData: ArrayBuffer; + readonly clientData: ArrayBuffer; + readonly credential: ScopedCredential; + readonly signature: ArrayBuffer; +} + +declare var WebAuthnAssertion: { + prototype: WebAuthnAssertion; + new(): WebAuthnAssertion; +} + interface WebGLActiveInfo { readonly name: string; readonly size: number; @@ -10975,7 +12021,7 @@ interface WebGLContextEvent extends Event { declare var WebGLContextEvent: { prototype: WebGLContextEvent; - new(type: string, eventInitDict?: WebGLContextEventInit): WebGLContextEvent; + new(typeArg: string, eventInitDict?: WebGLContextEventInit): WebGLContextEvent; } interface WebGLFramebuffer extends WebGLObject { @@ -11102,7 +12148,7 @@ interface WebGLRenderingContext { isTexture(texture: WebGLTexture | null): boolean; lineWidth(width: number): void; linkProgram(program: WebGLProgram | null): void; - pixelStorei(pname: number, param: number): void; + pixelStorei(pname: number, param: number | boolean): void; polygonOffset(factor: number, units: number): void; readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView | null): void; renderbufferStorage(target: number, internalformat: number, width: number, height: number): void; @@ -11828,6 +12874,56 @@ declare var WebKitCSSMatrix: { new(text?: string): WebKitCSSMatrix; } +interface WebKitDirectoryEntry extends WebKitEntry { + createReader(): WebKitDirectoryReader; +} + +declare var WebKitDirectoryEntry: { + prototype: WebKitDirectoryEntry; + new(): WebKitDirectoryEntry; +} + +interface WebKitDirectoryReader { + readEntries(successCallback: WebKitEntriesCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitDirectoryReader: { + prototype: WebKitDirectoryReader; + new(): WebKitDirectoryReader; +} + +interface WebKitEntry { + readonly filesystem: WebKitFileSystem; + readonly fullPath: string; + readonly isDirectory: boolean; + readonly isFile: boolean; + readonly name: string; +} + +declare var WebKitEntry: { + prototype: WebKitEntry; + new(): WebKitEntry; +} + +interface WebKitFileEntry extends WebKitEntry { + file(successCallback: WebKitFileCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitFileEntry: { + prototype: WebKitFileEntry; + new(): WebKitFileEntry; +} + +interface WebKitFileSystem { + readonly name: string; + readonly root: WebKitDirectoryEntry; +} + +declare var WebKitFileSystem: { + prototype: WebKitFileSystem; + new(): WebKitFileSystem; +} + interface WebKitPoint { x: number; y: number; @@ -11840,7 +12936,7 @@ declare var WebKitPoint: { interface WebSocketEventMap { "close": CloseEvent; - "error": ErrorEvent; + "error": Event; "message": MessageEvent; "open": Event; } @@ -11850,7 +12946,7 @@ interface WebSocket extends EventTarget { readonly bufferedAmount: number; readonly extensions: string; onclose: (this: WebSocket, ev: CloseEvent) => any; - onerror: (this: WebSocket, ev: ErrorEvent) => any; + onerror: (this: WebSocket, ev: Event) => any; onmessage: (this: WebSocket, ev: MessageEvent) => any; onopen: (this: WebSocket, ev: Event) => any; readonly protocol: string; @@ -11987,8 +13083,9 @@ interface WindowEventMap extends GlobalEventHandlersEventMap { "waiting": Event; } -interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64 { +interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch { readonly applicationCache: ApplicationCache; + readonly caches: CacheStorage; readonly clientInformation: Navigator; readonly closed: boolean; readonly crypto: Crypto; @@ -12003,10 +13100,12 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly history: History; readonly innerHeight: number; readonly innerWidth: number; + readonly isSecureContext: boolean; readonly length: number; readonly location: Location; readonly locationbar: BarProp; readonly menubar: BarProp; + readonly msContentScript: ExtensionScriptApis; readonly msCredentials: MSCredentials; name: string; readonly navigator: Navigator; @@ -12120,6 +13219,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly scrollY: number; readonly scrollbars: BarProp; readonly self: Window; + readonly speechSynthesis: SpeechSynthesis; status: string; readonly statusbar: BarProp; readonly styleMedia: StyleMedia; @@ -12128,12 +13228,14 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly window: Window; URL: typeof URL; Blob: typeof Blob; + customElements: CustomElementRegistry; alert(message?: any): void; blur(): void; cancelAnimationFrame(handle: number): void; captureEvents(): void; close(): void; confirm(message?: string): boolean; + departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; focus(): void; getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -12153,6 +13255,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window scroll(x?: number, y?: number): void; scrollBy(x?: number, y?: number): void; scrollTo(x?: number, y?: number): void; + stop(): void; webkitCancelAnimationFrame(handle: number): void; webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; @@ -12175,7 +13278,7 @@ interface WorkerEventMap extends AbstractWorkerEventMap { interface Worker extends EventTarget, AbstractWorker { onmessage: (this: Worker, ev: MessageEvent) => any; - postMessage(message: any, ports?: any): void; + postMessage(message: any, transfer?: any[]): void; terminate(): void; addEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -12187,7 +13290,7 @@ declare var Worker: { } interface XMLDocument extends Document { - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: XMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12206,14 +13309,14 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly response: any; readonly responseText: string; responseType: string; - readonly responseXML: any; + readonly responseURL: string; + readonly responseXML: Document | null; readonly status: number; readonly statusText: string; timeout: number; readonly upload: XMLHttpRequestUpload; withCredentials: boolean; msCaching?: string; - readonly responseURL: string; abort(): void; getAllResponseHeaders(): string; getResponseHeader(header: string): string | null; @@ -12241,11 +13344,10 @@ declare var XMLHttpRequest: { readonly LOADING: number; readonly OPENED: number; readonly UNSENT: number; - create(): XMLHttpRequest; } interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { - addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12345,6 +13447,16 @@ declare var XSLTProcessor: { new(): XSLTProcessor; } +interface webkitRTCPeerConnection extends RTCPeerConnection { + addEventListener(type: K, listener: (this: webkitRTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var webkitRTCPeerConnection: { + prototype: webkitRTCPeerConnection; + new(configuration: RTCConfiguration): webkitRTCPeerConnection; +} + interface AbstractWorkerEventMap { "error": ErrorEvent; } @@ -12355,6 +13467,14 @@ interface AbstractWorker { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface Body { + readonly bodyUsed: boolean; + arrayBuffer(): Promise; + blob(): Promise; + json(): Promise; + text(): Promise; +} + interface CanvasPathMethods { arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; @@ -12381,12 +13501,10 @@ interface DOML2DeprecatedSizeProperty { interface DocumentEvent { createEvent(eventInterface:"AnimationEvent"): AnimationEvent; - createEvent(eventInterface:"AriaRequestEvent"): AriaRequestEvent; createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent; createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent; createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent; createEvent(eventInterface:"CloseEvent"): CloseEvent; - createEvent(eventInterface:"CommandEvent"): CommandEvent; createEvent(eventInterface:"CompositionEvent"): CompositionEvent; createEvent(eventInterface:"CustomEvent"): CustomEvent; createEvent(eventInterface:"DeviceLightEvent"): DeviceLightEvent; @@ -12397,6 +13515,7 @@ interface DocumentEvent { createEvent(eventInterface:"Event"): Event; createEvent(eventInterface:"Events"): Event; createEvent(eventInterface:"FocusEvent"): FocusEvent; + createEvent(eventInterface:"FocusNavigationEvent"): FocusNavigationEvent; createEvent(eventInterface:"GamepadEvent"): GamepadEvent; createEvent(eventInterface:"HashChangeEvent"): HashChangeEvent; createEvent(eventInterface:"IDBVersionChangeEvent"): IDBVersionChangeEvent; @@ -12412,6 +13531,7 @@ interface DocumentEvent { createEvent(eventInterface:"MediaEncryptedEvent"): MediaEncryptedEvent; createEvent(eventInterface:"MediaKeyMessageEvent"): MediaKeyMessageEvent; createEvent(eventInterface:"MediaStreamErrorEvent"): MediaStreamErrorEvent; + createEvent(eventInterface:"MediaStreamEvent"): MediaStreamEvent; createEvent(eventInterface:"MediaStreamTrackEvent"): MediaStreamTrackEvent; createEvent(eventInterface:"MessageEvent"): MessageEvent; createEvent(eventInterface:"MouseEvent"): MouseEvent; @@ -12424,6 +13544,7 @@ interface DocumentEvent { createEvent(eventInterface:"OfflineAudioCompletionEvent"): OfflineAudioCompletionEvent; createEvent(eventInterface:"OverflowEvent"): OverflowEvent; createEvent(eventInterface:"PageTransitionEvent"): PageTransitionEvent; + createEvent(eventInterface:"PaymentRequestUpdateEvent"): PaymentRequestUpdateEvent; createEvent(eventInterface:"PermissionRequestedEvent"): PermissionRequestedEvent; createEvent(eventInterface:"PointerEvent"): PointerEvent; createEvent(eventInterface:"PopStateEvent"): PopStateEvent; @@ -12433,10 +13554,13 @@ interface DocumentEvent { createEvent(eventInterface:"RTCIceCandidatePairChangedEvent"): RTCIceCandidatePairChangedEvent; createEvent(eventInterface:"RTCIceGathererEvent"): RTCIceGathererEvent; createEvent(eventInterface:"RTCIceTransportStateChangedEvent"): RTCIceTransportStateChangedEvent; + createEvent(eventInterface:"RTCPeerConnectionIceEvent"): RTCPeerConnectionIceEvent; createEvent(eventInterface:"RTCSsrcConflictEvent"): RTCSsrcConflictEvent; createEvent(eventInterface:"SVGZoomEvent"): SVGZoomEvent; createEvent(eventInterface:"SVGZoomEvents"): SVGZoomEvent; createEvent(eventInterface:"ScriptNotifyEvent"): ScriptNotifyEvent; + createEvent(eventInterface:"ServiceWorkerMessageEvent"): ServiceWorkerMessageEvent; + createEvent(eventInterface:"SpeechSynthesisEvent"): SpeechSynthesisEvent; createEvent(eventInterface:"StorageEvent"): StorageEvent; createEvent(eventInterface:"TextEvent"): TextEvent; createEvent(eventInterface:"TouchEvent"): TouchEvent; @@ -12452,10 +13576,10 @@ interface DocumentEvent { interface ElementTraversal { readonly childElementCount: number; - readonly firstElementChild: Element; - readonly lastElementChild: Element; - readonly nextElementSibling: Element; - readonly previousElementSibling: Element; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; + readonly nextElementSibling: Element | null; + readonly previousElementSibling: Element | null; } interface GetSVGDocument { @@ -12488,6 +13612,10 @@ interface GlobalEventHandlers { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface GlobalFetch { + fetch(input: RequestInfo, init?: RequestInit): Promise; +} + interface HTMLTableAlignment { /** * Sets or retrieves a value that you can use to implement your own ch functionality for the object. @@ -12551,6 +13679,14 @@ interface MSNavigatorDoNotTrack { storeWebWideTrackingException(args: StoreExceptionsInformation): void; } +interface NavigatorBeacon { + sendBeacon(url: USVString, data?: BodyInit): boolean; +} + +interface NavigatorConcurrentHardware { + readonly hardwareConcurrency: number; +} + interface NavigatorContentUtils { } @@ -12559,6 +13695,7 @@ interface NavigatorGeolocation { } interface NavigatorID { + readonly appCodeName: string; readonly appName: string; readonly appVersion: string; readonly platform: string; @@ -12592,20 +13729,12 @@ interface RandomSource { getRandomValues(array: ArrayBufferView): ArrayBufferView; } -interface SVGAnimatedPathData { - readonly pathSegList: SVGPathSegList; -} - interface SVGAnimatedPoints { readonly animatedPoints: SVGPointList; readonly points: SVGPointList; } -interface SVGExternalResourcesRequired { - readonly externalResourcesRequired: SVGAnimatedBoolean; -} - -interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { +interface SVGFilterPrimitiveStandardAttributes { readonly height: SVGAnimatedLength; readonly result: SVGAnimatedString; readonly width: SVGAnimatedLength; @@ -12618,25 +13747,6 @@ interface SVGFitToViewBox { readonly viewBox: SVGAnimatedRect; } -interface SVGLangSpace { - xmllang: string; - xmlspace: string; -} - -interface SVGLocatable { - readonly farthestViewportElement: SVGElement; - readonly nearestViewportElement: SVGElement; - getBBox(): SVGRect; - getCTM(): SVGMatrix; - getScreenCTM(): SVGMatrix; - getTransformToElement(element: SVGElement): SVGMatrix; -} - -interface SVGStylable { - className: any; - readonly style: CSSStyleDeclaration; -} - interface SVGTests { readonly requiredExtensions: SVGStringList; readonly requiredFeatures: SVGStringList; @@ -12644,10 +13754,6 @@ interface SVGTests { hasExtension(extension: string): boolean; } -interface SVGTransformable extends SVGLocatable { - readonly transform: SVGAnimatedTransformList; -} - interface SVGURIReference { readonly href: SVGAnimatedString; } @@ -12706,6 +13812,14 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface ErrorEventInit { + message?: string; + filename?: string; + lineno?: number; + conlno?: number; + error?: any; +} + interface StorageEventInit extends EventInit { key?: string; oldValue?: string; @@ -12721,6 +13835,41 @@ interface Canvas2DContextAttributes { [attribute: string]: boolean | string | undefined; } +interface URLSearchParams { + /** + * Appends a specified key/value pair as a new search parameter. + */ + append(name: string, value: string): void; + /** + * Deletes the given search parameter, and its associated value, from the list of all search parameters. + */ + delete(name: string): void; + /** + * Returns the first value associated to the given search parameter. + */ + get(name: string): string | null; + /** + * Returns all the values association with a given search parameter. + */ + getAll(name: string): string[]; + /** + * Returns a Boolean indicating if such a search parameter exists. + */ + has(name: string): boolean; + /** + * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. + */ + set(name: string, value: string): void; +} + +declare var URLSearchParams: { + prototype: URLSearchParams; + /** + * Constructor returning a URLSearchParams object. + */ + new (init?: string | URLSearchParams): URLSearchParams; +} + interface NodeListOf extends NodeList { length: number; item(index: number): TNode; @@ -12730,7 +13879,6 @@ interface NodeListOf extends NodeList { interface HTMLCollectionOf extends HTMLCollection { item(index: number): T; namedItem(name: string): T; - [index: number]: T; } interface BlobPropertyBag { @@ -12747,15 +13895,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -interface MessageEventInit extends EventInit { - data?: any; - origin?: string; - lastEventId?: string; - channel?: string; - source?: any; - ports?: MessagePort[]; -} - interface ProgressEventInit extends EventInit { lengthComputable?: boolean; loaded?: number; @@ -12957,8 +14096,8 @@ interface JsonWebKey { interface ParentNode { readonly children: HTMLCollection; - readonly firstElementChild: Element; - readonly lastElementChild: Element; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; readonly childElementCount: number; } @@ -12989,6 +14128,26 @@ interface AssignedNodesOptions { flatten?: boolean; } +interface ElementDefinitionOptions { + extends: string; +} + +interface CustomElementRegistry { + define(name: string, constructor: Function, options?: ElementDefinitionOptions): void; + get(name: string): any; + whenDefined(name: string): PromiseLike; +} + +interface PromiseRejectionEvent extends Event { + readonly promise: PromiseLike; + readonly reason: any; +} + +interface PromiseRejectionEventInit extends EventInit { + promise: PromiseLike; + reason?: any; +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -13024,6 +14183,18 @@ interface DecodeSuccessCallback { interface DecodeErrorCallback { (error: DOMException): void; } +interface VoidFunction { + (): void; +} +interface RTCSessionDescriptionCallback { + (sdp: RTCSessionDescription): void; +} +interface RTCPeerConnectionErrorCallback { + (error: DOMError): void; +} +interface RTCStatsCallback { + (report: RTCStatsReport): void; +} interface FunctionStringCallback { (data: string): void; } @@ -13036,6 +14207,12 @@ interface NavigatorUserMediaErrorCallback { interface ForEachCallback { (keyId: any, status: string): void; } +interface NotificationPermissionCallback { + (permission: string): void; +} +interface IntersectionObserverCallback { + (entries: IntersectionObserverEntry[], observer: IntersectionObserver): void; +} interface HTMLElementTagNameMap { "a": HTMLAnchorElement; "applet": HTMLAppletElement; @@ -13051,6 +14228,7 @@ interface HTMLElementTagNameMap { "caption": HTMLTableCaptionElement; "col": HTMLTableColElement; "colgroup": HTMLTableColElement; + "data": HTMLDataElement; "datalist": HTMLDataListElement; "del": HTMLModElement; "dir": HTMLDirectoryElement; @@ -13091,6 +14269,7 @@ interface HTMLElementTagNameMap { "ol": HTMLOListElement; "optgroup": HTMLOptGroupElement; "option": HTMLOptionElement; + "output": HTMLOutputElement; "p": HTMLParagraphElement; "param": HTMLParamElement; "picture": HTMLPictureElement; @@ -13110,6 +14289,7 @@ interface HTMLElementTagNameMap { "tfoot": HTMLTableSectionElement; "th": HTMLTableHeaderCellElement; "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; "title": HTMLTitleElement; "tr": HTMLTableRowElement; "track": HTMLTrackElement; @@ -13147,6 +14327,7 @@ interface ElementTagNameMap { "code": HTMLElement; "col": HTMLTableColElement; "colgroup": HTMLTableColElement; + "data": HTMLDataElement; "datalist": HTMLDataListElement; "dd": HTMLElement; "defs": SVGDefsElement; @@ -13240,6 +14421,7 @@ interface ElementTagNameMap { "ol": HTMLOListElement; "optgroup": HTMLOptGroupElement; "option": HTMLOptionElement; + "output": HTMLOutputElement; "p": HTMLParagraphElement; "param": HTMLParamElement; "path": SVGPathElement; @@ -13282,6 +14464,7 @@ interface ElementTagNameMap { "tfoot": HTMLTableSectionElement; "th": HTMLTableHeaderCellElement; "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; "title": HTMLTitleElement; "tr": HTMLTableRowElement; "track": HTMLTrackElement; @@ -13326,6 +14509,7 @@ interface ElementListTagNameMap { "code": NodeListOf; "col": NodeListOf; "colgroup": NodeListOf; + "data": NodeListOf; "datalist": NodeListOf; "dd": NodeListOf; "defs": NodeListOf; @@ -13419,6 +14603,7 @@ interface ElementListTagNameMap { "ol": NodeListOf; "optgroup": NodeListOf; "option": NodeListOf; + "output": NodeListOf; "p": NodeListOf; "param": NodeListOf; "path": NodeListOf; @@ -13461,6 +14646,7 @@ interface ElementListTagNameMap { "tfoot": NodeListOf; "th": NodeListOf; "thead": NodeListOf; + "time": NodeListOf; "title": NodeListOf; "tr": NodeListOf; "track": NodeListOf; @@ -13481,6 +14667,7 @@ declare var Audio: {new(src?: string): HTMLAudioElement; }; declare var Image: {new(width?: number, height?: number): HTMLImageElement; }; declare var Option: {new(text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; }; declare var applicationCache: ApplicationCache; +declare var caches: CacheStorage; declare var clientInformation: Navigator; declare var closed: boolean; declare var crypto: Crypto; @@ -13495,10 +14682,12 @@ declare var frames: Window; declare var history: History; declare var innerHeight: number; declare var innerWidth: number; +declare var isSecureContext: boolean; declare var length: number; declare var location: Location; declare var locationbar: BarProp; declare var menubar: BarProp; +declare var msContentScript: ExtensionScriptApis; declare var msCredentials: MSCredentials; declare const name: never; declare var navigator: Navigator; @@ -13612,18 +14801,21 @@ declare var scrollX: number; declare var scrollY: number; declare var scrollbars: BarProp; declare var self: Window; +declare var speechSynthesis: SpeechSynthesis; declare var status: string; declare var statusbar: BarProp; declare var styleMedia: StyleMedia; declare var toolbar: BarProp; declare var top: Window; declare var window: Window; +declare var customElements: CustomElementRegistry; declare function alert(message?: any): void; declare function blur(): void; declare function cancelAnimationFrame(handle: number): void; declare function captureEvents(): void; declare function close(): void; declare function confirm(message?: string): boolean; +declare function departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; declare function focus(): void; declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; declare function getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -13643,6 +14835,7 @@ declare function resizeTo(x?: number, y?: number): void; declare function scroll(x?: number, y?: number): void; declare function scrollBy(x?: number, y?: number): void; declare function scrollTo(x?: number, y?: number): void; +declare function stop(): void; declare function webkitCancelAnimationFrame(handle: number): void; declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; @@ -13677,10 +14870,13 @@ declare var onwheel: (this: Window, ev: WheelEvent) => any; declare var indexedDB: IDBFactory; declare function atob(encodedString: string): string; declare function btoa(rawString: string): string; +declare function fetch(input: RequestInfo, init?: RequestInit): Promise; declare function addEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; type AAGUID = string; type AlgorithmIdentifier = string | Algorithm; +type BodyInit = any; +type ByteString = string; type ConstrainBoolean = boolean | ConstrainBooleanParameters; type ConstrainDOMString = string | string[] | ConstrainDOMStringParameters; type ConstrainDouble = number | ConstrainDoubleRange; @@ -13700,6 +14896,7 @@ type GLsizeiptr = number; type GLubyte = number; type GLuint = number; type GLushort = number; +type HeadersInit = any; type IDBKeyPath = string; type KeyFormat = string; type KeyType = string; @@ -13707,8 +14904,10 @@ type KeyUsage = string; type MSInboundPayload = MSVideoRecvPayload | MSAudioRecvPayload; type MSLocalClientEvent = MSLocalClientEventBase | MSAudioLocalClientEvent; type MSOutboundPayload = MSVideoSendPayload | MSAudioSendPayload; -type RTCIceGatherCandidate = RTCIceCandidate | RTCIceCandidateComplete; +type RTCIceGatherCandidate = RTCIceCandidateDictionary | RTCIceCandidateComplete; type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport; +type RequestInfo = Request | string; +type USVString = string; type payloadtype = number; type ScrollBehavior = "auto" | "instant" | "smooth"; type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; diff --git a/src/lib/es2015.collection.d.ts b/src/lib/es2015.collection.d.ts index 6a2c43cd050..5b90333f1d5 100644 --- a/src/lib/es2015.collection.d.ts +++ b/src/lib/es2015.collection.d.ts @@ -4,7 +4,7 @@ interface Map { forEach(callbackfn: (value: V, key: K, map: Map) => void, thisArg?: any): void; get(key: K): V | undefined; has(key: K): boolean; - set(key: K, value?: V): this; + set(key: K, value: V): this; readonly size: number; } @@ -22,16 +22,16 @@ interface ReadonlyMap { readonly size: number; } -interface WeakMap { +interface WeakMap { delete(key: K): boolean; get(key: K): V | undefined; has(key: K): boolean; - set(key: K, value?: V): this; + set(key: K, value: V): this; } interface WeakMapConstructor { new (): WeakMap; - new (entries?: [K, V][]): WeakMap; + new (entries?: [K, V][]): WeakMap; readonly prototype: WeakMap; } declare var WeakMap: WeakMapConstructor; diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index 356512ecf58..eb23ce7901f 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -325,7 +325,7 @@ interface ObjectConstructor { * @param o The object to change its prototype. * @param proto The value of the new prototype or null. */ - setPrototypeOf(o: any, proto: any): any; + setPrototypeOf(o: any, proto: object | null): any; /** * Gets the own property descriptor of the specified object. diff --git a/src/lib/es2015.iterable.d.ts b/src/lib/es2015.iterable.d.ts index de339e2bf2c..247017bae7d 100644 --- a/src/lib/es2015.iterable.d.ts +++ b/src/lib/es2015.iterable.d.ts @@ -1,8 +1,8 @@ /// interface SymbolConstructor { - /** - * A method that returns the default iterator for an object. Called by the semantics of the + /** + * A method that returns the default iterator for an object. Called by the semantics of the * for-of statement. */ readonly iterator: symbol; @@ -31,17 +31,17 @@ interface Array { /** Iterator */ [Symbol.iterator](): IterableIterator; - /** + /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, T]>; - /** + /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** + /** * Returns an list of values in the array */ values(): IterableIterator; @@ -55,7 +55,7 @@ interface ArrayConstructor { * @param thisArg Value of 'this' used to invoke the mapfn. */ from(iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): Array; - + /** * Creates an array from an iterable object. * @param iterable An iterable object to convert to an array. @@ -67,17 +67,17 @@ interface ReadonlyArray { /** Iterator */ [Symbol.iterator](): IterableIterator; - /** + /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, T]>; - /** + /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** + /** * Returns an list of values in the array */ values(): IterableIterator; @@ -99,10 +99,10 @@ interface MapConstructor { new (iterable: Iterable<[K, V]>): Map; } -interface WeakMap { } +interface WeakMap { } interface WeakMapConstructor { - new (iterable: Iterable<[K, V]>): WeakMap; + new (iterable: Iterable<[K, V]>): WeakMap; } interface Set { @@ -126,15 +126,15 @@ interface Promise { } interface PromiseConstructor { /** - * Creates a Promise that is resolved with an array of results when all of the provided Promises + * Creates a Promise that is resolved with an array of results when all of the provided Promises * resolve, or rejected when any Promise is rejected. * @param values An array of Promises. * @returns A new Promise. */ all(values: Iterable>): Promise; - + /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved * or rejected. * @param values An array of Promises. * @returns A new Promise. @@ -152,20 +152,20 @@ interface String { } /** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Int8Array { [Symbol.iterator](): IterableIterator; - /** + /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** + /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** + /** * Returns an list of values in the array */ values(): IterableIterator; @@ -184,20 +184,20 @@ interface Int8ArrayConstructor { } /** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint8Array { [Symbol.iterator](): IterableIterator; - /** + /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** + /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** + /** * Returns an list of values in the array */ values(): IterableIterator; @@ -216,22 +216,22 @@ interface Uint8ArrayConstructor { } /** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. * If the requested number of bytes could not be allocated an exception is raised. */ interface Uint8ClampedArray { [Symbol.iterator](): IterableIterator; - /** + /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** + /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** + /** * Returns an list of values in the array */ values(): IterableIterator; @@ -251,22 +251,22 @@ interface Uint8ClampedArrayConstructor { } /** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int16Array { [Symbol.iterator](): IterableIterator; - /** + /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** + /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** + /** * Returns an list of values in the array */ values(): IterableIterator; @@ -285,20 +285,20 @@ interface Int16ArrayConstructor { } /** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint16Array { [Symbol.iterator](): IterableIterator; - /** + /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** + /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** + /** * Returns an list of values in the array */ values(): IterableIterator; @@ -317,20 +317,20 @@ interface Uint16ArrayConstructor { } /** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int32Array { [Symbol.iterator](): IterableIterator; - /** + /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** + /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** + /** * Returns an list of values in the array */ values(): IterableIterator; @@ -349,20 +349,20 @@ interface Int32ArrayConstructor { } /** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint32Array { [Symbol.iterator](): IterableIterator; - /** + /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** + /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** + /** * Returns an list of values in the array */ values(): IterableIterator; @@ -386,15 +386,15 @@ interface Uint32ArrayConstructor { */ interface Float32Array { [Symbol.iterator](): IterableIterator; - /** + /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** + /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** + /** * Returns an list of values in the array */ values(): IterableIterator; @@ -413,20 +413,20 @@ interface Float32ArrayConstructor { } /** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Float64Array { [Symbol.iterator](): IterableIterator; - /** + /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** + /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** + /** * Returns an list of values in the array */ values(): IterableIterator; @@ -442,4 +442,4 @@ interface Float64ArrayConstructor { * @param thisArg Value of 'this' used to invoke the mapfn. */ from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; -} \ No newline at end of file +} diff --git a/src/lib/es2015.promise.d.ts b/src/lib/es2015.promise.d.ts index e27da2ce11b..208e5c1cdc2 100644 --- a/src/lib/es2015.promise.d.ts +++ b/src/lib/es2015.promise.d.ts @@ -1,54 +1,3 @@ -/** - * Represents the completion of an asynchronous operation - */ -interface Promise { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled?: ((value: T) => T | PromiseLike) | undefined | null, onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): Promise; - - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled: ((value: T) => T | PromiseLike) | undefined | null, onrejected: (reason: any) => TResult | PromiseLike): Promise; - - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled: (value: T) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; - - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled: (value: T) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; - - /** - * Attaches a callback for only the rejection of the Promise. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of the callback. - */ - catch(onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): Promise; - - /** - * Attaches a callback for only the rejection of the Promise. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of the callback. - */ - catch(onrejected: (reason: any) => TResult | PromiseLike): Promise; -} - interface PromiseConstructor { /** * A reference to the prototype. diff --git a/src/lib/es2015.proxy.d.ts b/src/lib/es2015.proxy.d.ts index 34aedce0128..efccfd47cc5 100644 --- a/src/lib/es2015.proxy.d.ts +++ b/src/lib/es2015.proxy.d.ts @@ -1,5 +1,5 @@ interface ProxyHandler { - getPrototypeOf? (target: T): {} | null; + getPrototypeOf? (target: T): object | null; setPrototypeOf? (target: T, v: any): boolean; isExtensible? (target: T): boolean; preventExtensions? (target: T): boolean; @@ -12,7 +12,7 @@ interface ProxyHandler { enumerate? (target: T): PropertyKey[]; ownKeys? (target: T): PropertyKey[]; apply? (target: T, thisArg: any, argArray?: any): any; - construct? (target: T, argArray: any, newTarget?: any): {}; + construct? (target: T, argArray: any, newTarget?: any): object } interface ProxyConstructor { diff --git a/src/lib/es2015.symbol.d.ts b/src/lib/es2015.symbol.d.ts index cd7e45595f0..d7ea4fa0328 100644 --- a/src/lib/es2015.symbol.d.ts +++ b/src/lib/es2015.symbol.d.ts @@ -3,7 +3,7 @@ interface Symbol { toString(): string; /** Returns the primitive value of the specified object. */ - valueOf(): Object; + valueOf(): symbol; } interface SymbolConstructor { diff --git a/src/lib/es2015.symbol.wellknown.d.ts b/src/lib/es2015.symbol.wellknown.d.ts index 145d8af6b10..7177b78e483 100644 --- a/src/lib/es2015.symbol.wellknown.d.ts +++ b/src/lib/es2015.symbol.wellknown.d.ts @@ -110,7 +110,7 @@ interface Map { readonly [Symbol.toStringTag]: "Map"; } -interface WeakMap{ +interface WeakMap{ readonly [Symbol.toStringTag]: "WeakMap"; } @@ -324,4 +324,4 @@ interface Float32Array { */ interface Float64Array { readonly [Symbol.toStringTag]: "Float64Array"; -} \ No newline at end of file +} diff --git a/src/lib/es2017.d.ts b/src/lib/es2017.d.ts index c234a9edb24..7b8c7cbb7d5 100644 --- a/src/lib/es2017.d.ts +++ b/src/lib/es2017.d.ts @@ -1,4 +1,4 @@ /// /// /// -/// +/// \ No newline at end of file diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index e5eabe950a2..262c2ba21fe 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -137,23 +137,17 @@ interface ObjectConstructor { getOwnPropertyNames(o: any): string[]; /** - * Creates an object that has null prototype. - * @param o Object to use as a prototype. May be null + * Creates an object that has the specified prototype or that has null prototype. + * @param o Object to use as a prototype. May be null. */ - create(o: null): any; - - /** - * Creates an object that has the specified prototype, and that optionally contains specified properties. - * @param o Object to use as a prototype. May be null - */ - create(o: T): T; + create(o: object | null): any; /** * Creates an object that has the specified prototype, and that optionally contains specified properties. * @param o Object to use as a prototype. May be null * @param properties JavaScript object that contains one or more property descriptors. */ - create(o: any, properties: PropertyDescriptorMap): any; + create(o: object | null, properties: PropertyDescriptorMap): any; /** * Adds a property to an object, or modifies attributes of an existing property. @@ -341,14 +335,14 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string that represents the regular expression. + * @param searchValue A string to search for. * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string that represents the regular expression. + * @param searchValue A string to search for. * @param replacer A function that returns the replacement text. */ replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; @@ -1316,39 +1310,27 @@ interface PromiseLike { * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ - then( - onfulfilled?: ((value: T) => T | PromiseLike) | undefined | null, - onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): PromiseLike; + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): PromiseLike; +} +/** + * Represents the completion of an asynchronous operation + */ +interface Promise { /** * Attaches callbacks for the resolution and/or rejection of the Promise. * @param onfulfilled The callback to execute when the Promise is resolved. * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ - then( - onfulfilled: ((value: T) => T | PromiseLike) | undefined | null, - onrejected: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Promise; /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. + * Attaches a callback for only the rejection of the Promise. * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. + * @returns A Promise for the completion of the callback. */ - then( - onfulfilled: (value: T) => TResult | PromiseLike, - onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): PromiseLike; - - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then( - onfulfilled: (value: T) => TResult1 | PromiseLike, - onrejected: (reason: any) => TResult2 | PromiseLike): PromiseLike; + catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; } interface ArrayLike { diff --git a/src/lib/esnext.asynciterable.d.ts b/src/lib/esnext.asynciterable.d.ts new file mode 100644 index 00000000000..8379ba5ba6c --- /dev/null +++ b/src/lib/esnext.asynciterable.d.ts @@ -0,0 +1,24 @@ +/// +/// + +interface SymbolConstructor { + /** + * A method that returns the default async iterator for an object. Called by the semantics of + * the for-await-of statement. + */ + readonly asyncIterator: symbol; +} + +interface AsyncIterator { + next(value?: any): Promise>; + return?(value?: any): Promise>; + throw?(e?: any): Promise>; +} + +interface AsyncIterable { + [Symbol.asyncIterator](): AsyncIterator; +} + +interface AsyncIterableIterator extends AsyncIterator { + [Symbol.asyncIterator](): AsyncIterableIterator; +} \ No newline at end of file diff --git a/src/lib/esnext.d.ts b/src/lib/esnext.d.ts new file mode 100644 index 00000000000..71fab82a866 --- /dev/null +++ b/src/lib/esnext.d.ts @@ -0,0 +1,2 @@ +/// +/// diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index 089d0bdc5d5..e9563db1bcd 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -7,12 +7,29 @@ interface Algorithm { name: string; } +interface CacheQueryOptions { + ignoreSearch?: boolean; + ignoreMethod?: boolean; + ignoreVary?: boolean; + cacheName?: string; +} + +interface CloseEventInit extends EventInit { + wasClean?: boolean; + code?: number; + reason?: string; +} + interface EventInit { scoped?: boolean; bubbles?: boolean; cancelable?: boolean; } +interface GetNotificationOptions { + tag?: string; +} + interface IDBIndexParameters { multiEntry?: boolean; unique?: boolean; @@ -27,10 +44,101 @@ interface KeyAlgorithm { name?: string; } +interface MessageEventInit extends EventInit { + lastEventId?: string; + channel?: string; + data?: any; + origin?: string; + source?: any; + ports?: MessagePort[]; +} + +interface NotificationOptions { + dir?: string; + lang?: string; + body?: string; + tag?: string; + icon?: string; +} + +interface PushSubscriptionOptionsInit { + userVisibleOnly?: boolean; + applicationServerKey?: any; +} + +interface RequestInit { + method?: string; + headers?: any; + body?: any; + referrer?: string; + referrerPolicy?: string; + mode?: string; + credentials?: string; + cache?: string; + redirect?: string; + integrity?: string; + keepalive?: boolean; + window?: any; +} + +interface ResponseInit { + status?: number; + statusText?: string; + headers?: any; +} + +interface ClientQueryOptions { + includeUncontrolled?: boolean; + type?: string; +} + +interface ExtendableEventInit extends EventInit { +} + +interface ExtendableMessageEventInit extends ExtendableEventInit { + data?: any; + origin?: string; + lastEventId?: string; + source?: Client | ServiceWorker | MessagePort; + ports?: MessagePort[]; +} + +interface FetchEventInit extends ExtendableEventInit { + request?: Request; + clientId?: string; + isReload?: boolean; +} + +interface NotificationEventInit extends ExtendableEventInit { + notification?: Notification; + action?: string; +} + +interface PushEventInit extends ExtendableEventInit { + data?: any; +} + +interface SyncEventInit extends ExtendableEventInit { + tag?: string; + lastChance?: boolean; +} + interface EventListener { (evt: Event): void; } +interface WebKitEntriesCallback { + (evt: Event): void; +} + +interface WebKitErrorCallback { + (evt: Event): void; +} + +interface WebKitFileCallback { + (evt: Event): void; +} + interface AudioBuffer { readonly duration: number; readonly length: number; @@ -59,6 +167,34 @@ declare var Blob: { new (blobParts?: any[], options?: BlobPropertyBag): Blob; } +interface Cache { + add(request: RequestInfo): Promise; + addAll(requests: RequestInfo[]): Promise; + delete(request: RequestInfo, options?: CacheQueryOptions): Promise; + keys(request?: RequestInfo, options?: CacheQueryOptions): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + put(request: RequestInfo, response: Response): Promise; +} + +declare var Cache: { + prototype: Cache; + new(): Cache; +} + +interface CacheStorage { + delete(cacheName: string): Promise; + has(cacheName: string): Promise; + keys(): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + open(cacheName: string): Promise; +} + +declare var CacheStorage: { + prototype: CacheStorage; + new(): CacheStorage; +} + interface CloseEvent extends Event { readonly code: number; readonly reason: string; @@ -68,14 +204,14 @@ interface CloseEvent extends Event { declare var CloseEvent: { prototype: CloseEvent; - new(): CloseEvent; + new(typeArg: string, eventInitDict?: CloseEventInit): CloseEvent; } interface Console { assert(test?: boolean, message?: string, ...optionalParams: any[]): void; clear(): void; count(countTitle?: string): void; - debug(message?: string, ...optionalParams: any[]): void; + debug(message?: any, ...optionalParams: any[]): void; dir(value?: any, ...optionalParams: any[]): void; dirxml(value: any): void; error(message?: any, ...optionalParams: any[]): void; @@ -227,7 +363,7 @@ interface ErrorEvent extends Event { declare var ErrorEvent: { prototype: ErrorEvent; - new(): ErrorEvent; + new(type: string, errorEventInitDict?: ErrorEventInit): ErrorEvent; } interface Event { @@ -256,7 +392,7 @@ interface Event { declare var Event: { prototype: Event; - new(type: string, eventInitDict?: EventInit): Event; + new(typeArg: string, eventInitDict?: EventInit): Event; readonly AT_TARGET: number; readonly BUBBLING_PHASE: number; readonly CAPTURING_PHASE: number; @@ -301,7 +437,7 @@ interface FileReader extends EventTarget, MSBaseReader { readAsBinaryString(blob: Blob): void; readAsDataURL(blob: Blob): void; readAsText(blob: Blob, encoding?: string): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -310,6 +446,20 @@ declare var FileReader: { new(): FileReader; } +interface Headers { + append(name: string, value: string): void; + delete(name: string): void; + forEach(callback: ForEachCallback): void; + get(name: string): string | null; + has(name: string): boolean; + set(name: string, value: string): void; +} + +declare var Headers: { + prototype: Headers; + new(init?: any): Headers; +} + interface IDBCursor { readonly direction: string; key: IDBKeyRange | IDBValidKey; @@ -345,14 +495,14 @@ declare var IDBCursorWithValue: { interface IDBDatabaseEventMap { "abort": Event; - "error": ErrorEvent; + "error": Event; } interface IDBDatabase extends EventTarget { readonly name: string; readonly objectStoreNames: DOMStringList; onabort: (this: IDBDatabase, ev: Event) => any; - onerror: (this: IDBDatabase, ev: ErrorEvent) => any; + onerror: (this: IDBDatabase, ev: Event) => any; version: number; onversionchange: (ev: IDBVersionChangeEvent) => any; close(): void; @@ -455,13 +605,13 @@ declare var IDBOpenDBRequest: { } interface IDBRequestEventMap { - "error": ErrorEvent; + "error": Event; "success": Event; } interface IDBRequest extends EventTarget { readonly error: DOMError; - onerror: (this: IDBRequest, ev: ErrorEvent) => any; + onerror: (this: IDBRequest, ev: Event) => any; onsuccess: (this: IDBRequest, ev: Event) => any; readonly readyState: string; readonly result: any; @@ -479,7 +629,7 @@ declare var IDBRequest: { interface IDBTransactionEventMap { "abort": Event; "complete": Event; - "error": ErrorEvent; + "error": Event; } interface IDBTransaction extends EventTarget { @@ -488,7 +638,7 @@ interface IDBTransaction extends EventTarget { readonly mode: string; onabort: (this: IDBTransaction, ev: Event) => any; oncomplete: (this: IDBTransaction, ev: Event) => any; - onerror: (this: IDBTransaction, ev: ErrorEvent) => any; + onerror: (this: IDBTransaction, ev: Event) => any; abort(): void; objectStore(name: string): IDBObjectStore; readonly READ_ONLY: string; @@ -528,105 +678,6 @@ declare var ImageData: { new(array: Uint8ClampedArray, width: number, height: number): ImageData; } -interface MSApp { - clearTemporaryWebDataAsync(): MSAppAsyncOperation; - createBlobFromRandomAccessStream(type: string, seeker: any): Blob; - createDataPackage(object: any): any; - createDataPackageFromSelection(): any; - createFileFromStorageFile(storageFile: any): File; - createStreamFromInputStream(type: string, inputStream: any): MSStream; - execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; - execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; - getCurrentPriority(): string; - getHtmlPrintDocumentSourceAsync(htmlDoc: any): PromiseLike; - getViewId(view: any): any; - isTaskScheduledAtPriorityOrHigher(priority: string): boolean; - pageHandlesAllApplicationActivations(enabled: boolean): void; - suppressSubdownloadCredentialPrompts(suppress: boolean): void; - terminateApp(exceptionObject: any): void; - readonly CURRENT: string; - readonly HIGH: string; - readonly IDLE: string; - readonly NORMAL: string; -} -declare var MSApp: MSApp; - -interface MSAppAsyncOperationEventMap { - "complete": Event; - "error": ErrorEvent; -} - -interface MSAppAsyncOperation extends EventTarget { - readonly error: DOMError; - oncomplete: (this: MSAppAsyncOperation, ev: Event) => any; - onerror: (this: MSAppAsyncOperation, ev: ErrorEvent) => any; - readonly readyState: number; - readonly result: any; - start(): void; - readonly COMPLETED: number; - readonly ERROR: number; - readonly STARTED: number; - addEventListener(type: K, listener: (this: MSAppAsyncOperation, ev: MSAppAsyncOperationEventMap[K]) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var MSAppAsyncOperation: { - prototype: MSAppAsyncOperation; - new(): MSAppAsyncOperation; - readonly COMPLETED: number; - readonly ERROR: number; - readonly STARTED: number; -} - -interface MSBlobBuilder { - append(data: any, endings?: string): void; - getBlob(contentType?: string): Blob; -} - -declare var MSBlobBuilder: { - prototype: MSBlobBuilder; - new(): MSBlobBuilder; -} - -interface MSStream { - readonly type: string; - msClose(): void; - msDetachStream(): any; -} - -declare var MSStream: { - prototype: MSStream; - new(): MSStream; -} - -interface MSStreamReader extends EventTarget, MSBaseReader { - readonly error: DOMError; - readAsArrayBuffer(stream: MSStream, size?: number): void; - readAsBinaryString(stream: MSStream, size?: number): void; - readAsBlob(stream: MSStream, size?: number): void; - readAsDataURL(stream: MSStream, size?: number): void; - readAsText(stream: MSStream, encoding?: string, size?: number): void; - addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - -declare var MSStreamReader: { - prototype: MSStreamReader; - new(): MSStreamReader; -} - -interface MediaQueryList { - readonly matches: boolean; - readonly media: string; - addListener(listener: MediaQueryListListener): void; - removeListener(listener: MediaQueryListListener): void; -} - -declare var MediaQueryList: { - prototype: MediaQueryList; - new(): MediaQueryList; -} - interface MessageChannel { readonly port1: MessagePort; readonly port2: MessagePort; @@ -657,7 +708,7 @@ interface MessagePortEventMap { interface MessagePort extends EventTarget { onmessage: (this: MessagePort, ev: MessageEvent) => any; close(): void; - postMessage(message?: any, ports?: any): void; + postMessage(message?: any, transfer?: any[]): void; start(): void; addEventListener(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -668,6 +719,109 @@ declare var MessagePort: { new(): MessagePort; } +interface NotificationEventMap { + "click": Event; + "close": Event; + "error": Event; + "show": Event; +} + +interface Notification extends EventTarget { + readonly body: string; + readonly dir: string; + readonly icon: string; + readonly lang: string; + onclick: (this: Notification, ev: Event) => any; + onclose: (this: Notification, ev: Event) => any; + onerror: (this: Notification, ev: Event) => any; + onshow: (this: Notification, ev: Event) => any; + readonly permission: string; + readonly tag: string; + readonly title: string; + close(): void; + addEventListener(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Notification: { + prototype: Notification; + new(title: string, options?: NotificationOptions): Notification; + requestPermission(callback?: NotificationPermissionCallback): Promise; +} + +interface Performance { + readonly navigation: PerformanceNavigation; + readonly timing: PerformanceTiming; + clearMarks(markName?: string): void; + clearMeasures(measureName?: string): void; + clearResourceTimings(): void; + getEntries(): any; + getEntriesByName(name: string, entryType?: string): any; + getEntriesByType(entryType: string): any; + getMarks(markName?: string): any; + getMeasures(measureName?: string): any; + mark(markName: string): void; + measure(measureName: string, startMarkName?: string, endMarkName?: string): void; + now(): number; + setResourceTimingBufferSize(maxSize: number): void; + toJSON(): any; +} + +declare var Performance: { + prototype: Performance; + new(): Performance; +} + +interface PerformanceNavigation { + readonly redirectCount: number; + readonly type: number; + toJSON(): any; + readonly TYPE_BACK_FORWARD: number; + readonly TYPE_NAVIGATE: number; + readonly TYPE_RELOAD: number; + readonly TYPE_RESERVED: number; +} + +declare var PerformanceNavigation: { + prototype: PerformanceNavigation; + new(): PerformanceNavigation; + readonly TYPE_BACK_FORWARD: number; + readonly TYPE_NAVIGATE: number; + readonly TYPE_RELOAD: number; + readonly TYPE_RESERVED: number; +} + +interface PerformanceTiming { + readonly connectEnd: number; + readonly connectStart: number; + readonly domComplete: number; + readonly domContentLoadedEventEnd: number; + readonly domContentLoadedEventStart: number; + readonly domInteractive: number; + readonly domLoading: number; + readonly domainLookupEnd: number; + readonly domainLookupStart: number; + readonly fetchStart: number; + readonly loadEventEnd: number; + readonly loadEventStart: number; + readonly msFirstPaint: number; + readonly navigationStart: number; + readonly redirectEnd: number; + readonly redirectStart: number; + readonly requestStart: number; + readonly responseEnd: number; + readonly responseStart: number; + readonly unloadEventEnd: number; + readonly unloadEventStart: number; + readonly secureConnectionStart: number; + toJSON(): any; +} + +declare var PerformanceTiming: { + prototype: PerformanceTiming; + new(): PerformanceTiming; +} + interface Position { readonly coords: Coordinates; readonly timestamp: number; @@ -707,9 +861,156 @@ declare var ProgressEvent: { new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } +interface PushManager { + getSubscription(): Promise; + permissionState(options?: PushSubscriptionOptionsInit): Promise; + subscribe(options?: PushSubscriptionOptionsInit): Promise; +} + +declare var PushManager: { + prototype: PushManager; + new(): PushManager; +} + +interface PushSubscription { + readonly endpoint: USVString; + readonly options: PushSubscriptionOptions; + getKey(name: string): ArrayBuffer | null; + toJSON(): any; + unsubscribe(): Promise; +} + +declare var PushSubscription: { + prototype: PushSubscription; + new(): PushSubscription; +} + +interface PushSubscriptionOptions { + readonly applicationServerKey: ArrayBuffer | null; + readonly userVisibleOnly: boolean; +} + +declare var PushSubscriptionOptions: { + prototype: PushSubscriptionOptions; + new(): PushSubscriptionOptions; +} + +interface ReadableStream { + readonly locked: boolean; + cancel(): Promise; + getReader(): ReadableStreamReader; +} + +declare var ReadableStream: { + prototype: ReadableStream; + new(): ReadableStream; +} + +interface ReadableStreamReader { + cancel(): Promise; + read(): Promise; + releaseLock(): void; +} + +declare var ReadableStreamReader: { + prototype: ReadableStreamReader; + new(): ReadableStreamReader; +} + +interface Request extends Object, Body { + readonly cache: string; + readonly credentials: string; + readonly destination: string; + readonly headers: Headers; + readonly integrity: string; + readonly keepalive: boolean; + readonly method: string; + readonly mode: string; + readonly redirect: string; + readonly referrer: string; + readonly referrerPolicy: string; + readonly type: string; + readonly url: string; + clone(): Request; +} + +declare var Request: { + prototype: Request; + new(input: Request | string, init?: RequestInit): Request; +} + +interface Response extends Object, Body { + readonly body: ReadableStream | null; + readonly headers: Headers; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly type: string; + readonly url: string; + clone(): Response; +} + +declare var Response: { + prototype: Response; + new(body?: any, init?: ResponseInit): Response; +} + +interface ServiceWorkerEventMap extends AbstractWorkerEventMap { + "statechange": Event; +} + +interface ServiceWorker extends EventTarget, AbstractWorker { + onstatechange: (this: ServiceWorker, ev: Event) => any; + readonly scriptURL: USVString; + readonly state: string; + postMessage(message: any, transfer?: any[]): void; + addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorker: { + prototype: ServiceWorker; + new(): ServiceWorker; +} + +interface ServiceWorkerRegistrationEventMap { + "updatefound": Event; +} + +interface ServiceWorkerRegistration extends EventTarget { + readonly active: ServiceWorker | null; + readonly installing: ServiceWorker | null; + onupdatefound: (this: ServiceWorkerRegistration, ev: Event) => any; + readonly pushManager: PushManager; + readonly scope: USVString; + readonly sync: SyncManager; + readonly waiting: ServiceWorker | null; + getNotifications(filter?: GetNotificationOptions): any; + showNotification(title: string, options?: NotificationOptions): Promise; + unregister(): Promise; + update(): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerRegistration: { + prototype: ServiceWorkerRegistration; + new(): ServiceWorkerRegistration; +} + +interface SyncManager { + getTags(): any; + register(tag: string): Promise; +} + +declare var SyncManager: { + prototype: SyncManager; + new(): SyncManager; +} + interface WebSocketEventMap { "close": CloseEvent; - "error": ErrorEvent; + "error": Event; "message": MessageEvent; "open": Event; } @@ -719,7 +1020,7 @@ interface WebSocket extends EventTarget { readonly bufferedAmount: number; readonly extensions: string; onclose: (this: WebSocket, ev: CloseEvent) => any; - onerror: (this: WebSocket, ev: ErrorEvent) => any; + onerror: (this: WebSocket, ev: Event) => any; onmessage: (this: WebSocket, ev: MessageEvent) => any; onopen: (this: WebSocket, ev: Event) => any; readonly protocol: string; @@ -750,7 +1051,7 @@ interface WorkerEventMap extends AbstractWorkerEventMap { interface Worker extends EventTarget, AbstractWorker { onmessage: (this: Worker, ev: MessageEvent) => any; - postMessage(message: any, ports?: any): void; + postMessage(message: any, transfer?: any[]): void; terminate(): void; addEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -771,6 +1072,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly response: any; readonly responseText: string; responseType: string; + readonly responseURL: string; readonly responseXML: any; readonly status: number; readonly statusText: string; @@ -778,7 +1080,6 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly upload: XMLHttpRequestUpload; withCredentials: boolean; msCaching?: string; - readonly responseURL: string; abort(): void; getAllResponseHeaders(): string; getResponseHeader(header: string): string | null; @@ -805,11 +1106,10 @@ declare var XMLHttpRequest: { readonly LOADING: number; readonly OPENED: number; readonly UNSENT: number; - create(): XMLHttpRequest; } interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { - addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -828,6 +1128,18 @@ interface AbstractWorker { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface Body { + readonly bodyUsed: boolean; + arrayBuffer(): Promise; + blob(): Promise; + json(): Promise; + text(): Promise; +} + +interface GlobalFetch { + fetch(input: RequestInfo, init?: RequestInit): Promise; +} + interface MSBaseReaderEventMap { "abort": Event; "error": ErrorEvent; @@ -854,7 +1166,16 @@ interface MSBaseReader { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface NavigatorBeacon { + sendBeacon(url: USVString, data?: BodyInit): boolean; +} + +interface NavigatorConcurrentHardware { + readonly hardwareConcurrency: number; +} + interface NavigatorID { + readonly appCodeName: string; readonly appName: string; readonly appVersion: string; readonly platform: string; @@ -900,6 +1221,81 @@ interface XMLHttpRequestEventTarget { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface Client { + readonly frameType: string; + readonly id: string; + readonly url: USVString; + postMessage(message: any, transfer?: any[]): void; +} + +declare var Client: { + prototype: Client; + new(): Client; +} + +interface Clients { + claim(): Promise; + get(id: string): Promise; + matchAll(options?: ClientQueryOptions): any; + openWindow(url: USVString): Promise; +} + +declare var Clients: { + prototype: Clients; + new(): Clients; +} + +interface DedicatedWorkerGlobalScopeEventMap extends WorkerGlobalScopeEventMap { + "message": MessageEvent; +} + +interface DedicatedWorkerGlobalScope extends WorkerGlobalScope { + onmessage: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any; + close(): void; + postMessage(message: any, transfer?: any[]): void; + addEventListener(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var DedicatedWorkerGlobalScope: { + prototype: DedicatedWorkerGlobalScope; + new(): DedicatedWorkerGlobalScope; +} + +interface ExtendableEvent extends Event { + waitUntil(f: Promise): void; +} + +declare var ExtendableEvent: { + prototype: ExtendableEvent; + new(type: string, eventInitDict?: ExtendableEventInit): ExtendableEvent; +} + +interface ExtendableMessageEvent extends ExtendableEvent { + readonly data: any; + readonly lastEventId: string; + readonly origin: string; + readonly ports: MessagePort[] | null; + readonly source: Client | ServiceWorker | MessagePort | null; +} + +declare var ExtendableMessageEvent: { + prototype: ExtendableMessageEvent; + new(type: string, eventInitDict?: ExtendableMessageEventInit): ExtendableMessageEvent; +} + +interface FetchEvent extends ExtendableEvent { + readonly clientId: string | null; + readonly isReload: boolean; + readonly request: Request; + respondWith(r: Promise): void; +} + +declare var FetchEvent: { + prototype: FetchEvent; + new(type: string, eventInitDict: FetchEventInit): FetchEvent; +} + interface FileReaderSync { readAsArrayBuffer(blob: Blob): any; readAsBinaryString(blob: Blob): void; @@ -912,17 +1308,105 @@ declare var FileReaderSync: { new(): FileReaderSync; } -interface WorkerGlobalScopeEventMap extends DedicatedWorkerGlobalScopeEventMap { +interface NotificationEvent extends ExtendableEvent { + readonly action: string; + readonly notification: Notification; +} + +declare var NotificationEvent: { + prototype: NotificationEvent; + new(type: string, eventInitDict: NotificationEventInit): NotificationEvent; +} + +interface PushEvent extends ExtendableEvent { + readonly data: PushMessageData | null; +} + +declare var PushEvent: { + prototype: PushEvent; + new(type: string, eventInitDict?: PushEventInit): PushEvent; +} + +interface PushMessageData { + arrayBuffer(): ArrayBuffer; + blob(): Blob; + json(): JSON; + text(): USVString; +} + +declare var PushMessageData: { + prototype: PushMessageData; + new(): PushMessageData; +} + +interface ServiceWorkerGlobalScopeEventMap extends WorkerGlobalScopeEventMap { + "activate": ExtendableEvent; + "fetch": FetchEvent; + "install": ExtendableEvent; + "message": ExtendableMessageEvent; + "notificationclick": NotificationEvent; + "notificationclose": NotificationEvent; + "push": PushEvent; + "pushsubscriptionchange": ExtendableEvent; + "sync": SyncEvent; +} + +interface ServiceWorkerGlobalScope extends WorkerGlobalScope { + readonly clients: Clients; + onactivate: (this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any; + onfetch: (this: ServiceWorkerGlobalScope, ev: FetchEvent) => any; + oninstall: (this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any; + onmessage: (this: ServiceWorkerGlobalScope, ev: ExtendableMessageEvent) => any; + onnotificationclick: (this: ServiceWorkerGlobalScope, ev: NotificationEvent) => any; + onnotificationclose: (this: ServiceWorkerGlobalScope, ev: NotificationEvent) => any; + onpush: (this: ServiceWorkerGlobalScope, ev: PushEvent) => any; + onpushsubscriptionchange: (this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any; + onsync: (this: ServiceWorkerGlobalScope, ev: SyncEvent) => any; + readonly registration: ServiceWorkerRegistration; + skipWaiting(): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerGlobalScope: { + prototype: ServiceWorkerGlobalScope; + new(): ServiceWorkerGlobalScope; +} + +interface SyncEvent extends ExtendableEvent { + readonly lastChance: boolean; + readonly tag: string; +} + +declare var SyncEvent: { + prototype: SyncEvent; + new(type: string, init: SyncEventInit): SyncEvent; +} + +interface WindowClient extends Client { + readonly focused: boolean; + readonly visibilityState: string; + focus(): Promise; + navigate(url: USVString): Promise; +} + +declare var WindowClient: { + prototype: WindowClient; + new(): WindowClient; +} + +interface WorkerGlobalScopeEventMap { "error": ErrorEvent; } -interface WorkerGlobalScope extends EventTarget, WorkerUtils, DedicatedWorkerGlobalScope, WindowConsole { +interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, GlobalFetch { + readonly caches: CacheStorage; + readonly isSecureContext: boolean; readonly location: WorkerLocation; onerror: (this: WorkerGlobalScope, ev: ErrorEvent) => any; + readonly performance: Performance; readonly self: WorkerGlobalScope; - close(): void; msWriteProfilerMark(profilerMarkName: string): void; - toString(): string; addEventListener(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -937,6 +1421,7 @@ interface WorkerLocation { readonly host: string; readonly hostname: string; readonly href: string; + readonly origin: string; readonly pathname: string; readonly port: string; readonly protocol: string; @@ -949,7 +1434,7 @@ declare var WorkerLocation: { new(): WorkerLocation; } -interface WorkerNavigator extends Object, NavigatorID, NavigatorOnLine { +interface WorkerNavigator extends Object, NavigatorID, NavigatorOnLine, NavigatorBeacon, NavigatorConcurrentHardware { readonly hardwareConcurrency: number; } @@ -958,17 +1443,6 @@ declare var WorkerNavigator: { new(): WorkerNavigator; } -interface DedicatedWorkerGlobalScopeEventMap { - "message": MessageEvent; -} - -interface DedicatedWorkerGlobalScope { - onmessage: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any; - postMessage(data: any): void; - addEventListener(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -} - interface WorkerUtils extends Object, WindowBase64 { readonly indexedDB: IDBFactory; readonly msIndexedDB: IDBFactory; @@ -985,6 +1459,14 @@ interface WorkerUtils extends Object, WindowBase64 { setTimeout(handler: any, timeout?: any, ...args: any[]): number; } +interface ErrorEventInit { + message?: string; + filename?: string; + lineno?: number; + conlno?: number; + error?: any; +} + interface BlobPropertyBag { type?: string; endings?: string; @@ -999,15 +1481,6 @@ interface EventListenerObject { handleEvent(evt: Event): void; } -interface MessageEventInit extends EventInit { - data?: any; - origin?: string; - lastEventId?: string; - channel?: string; - source?: any; - ports?: MessagePort[]; -} - interface ProgressEventInit extends EventInit { lengthComputable?: boolean; loaded?: number; @@ -1199,18 +1672,6 @@ interface PositionCallback { interface PositionErrorCallback { (error: PositionError): void; } -interface MediaQueryListListener { - (mql: MediaQueryList): void; -} -interface MSLaunchUriCallback { - (): void; -} -interface MSUnsafeFunctionCallback { - (): any; -} -interface MSExecAtPriorityFunctionCallback { - (...args: any[]): any; -} interface DecodeSuccessCallback { (decodedData: AudioBuffer): void; } @@ -1220,12 +1681,22 @@ interface DecodeErrorCallback { interface FunctionStringCallback { (data: string): void; } -declare var location: WorkerLocation; -declare var onerror: (this: WorkerGlobalScope, ev: ErrorEvent) => any; -declare var self: WorkerGlobalScope; +interface ForEachCallback { + (keyId: any, status: string): void; +} +interface NotificationPermissionCallback { + (permission: string): void; +} +declare var onmessage: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any; declare function close(): void; +declare function postMessage(message: any, transfer?: any[]): void; +declare var caches: CacheStorage; +declare var isSecureContext: boolean; +declare var location: WorkerLocation; +declare var onerror: (this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any; +declare var performance: Performance; +declare var self: WorkerGlobalScope; declare function msWriteProfilerMark(profilerMarkName: string): void; -declare function toString(): string; declare function dispatchEvent(evt: Event): boolean; declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; declare var indexedDB: IDBFactory; @@ -1243,12 +1714,16 @@ declare function setTimeout(handler: (...args: any[]) => void, timeout: number): declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; declare function atob(encodedString: string): string; declare function btoa(rawString: string): string; -declare var onmessage: (this: WorkerGlobalScope, ev: MessageEvent) => any; -declare function postMessage(data: any): void; declare var console: Console; -declare function addEventListener(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; +declare function fetch(input: RequestInfo, init?: RequestInit): Promise; +declare function dispatchEvent(evt: Event): boolean; +declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function addEventListener(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; type AlgorithmIdentifier = string | Algorithm; +type BodyInit = any; type IDBKeyPath = string; +type RequestInfo = Request | string; +type USVString = string; type IDBValidKey = number | string | Date | IDBArrayKey; type BufferSource = ArrayBuffer | ArrayBufferView; \ No newline at end of file diff --git a/src/server/builder.ts b/src/server/builder.ts index 60f56dc3241..a5e7b06e64b 100644 --- a/src/server/builder.ts +++ b/src/server/builder.ts @@ -356,24 +356,24 @@ namespace ts.server { // Use slice to clone the array to avoid manipulating in place const queue = fileInfo.referencedBy.slice(0); const fileNameSet = createMap(); - fileNameSet[scriptInfo.fileName] = scriptInfo; + fileNameSet.set(scriptInfo.fileName, scriptInfo); while (queue.length > 0) { const processingFileInfo = queue.pop(); if (processingFileInfo.updateShapeSignature() && processingFileInfo.referencedBy.length > 0) { for (const potentialFileInfo of processingFileInfo.referencedBy) { - if (!fileNameSet[potentialFileInfo.scriptInfo.fileName]) { + if (!fileNameSet.has(potentialFileInfo.scriptInfo.fileName)) { queue.push(potentialFileInfo); } } } - fileNameSet[processingFileInfo.scriptInfo.fileName] = processingFileInfo.scriptInfo; + fileNameSet.set(processingFileInfo.scriptInfo.fileName, processingFileInfo.scriptInfo); } const result: string[] = []; - for (const fileName in fileNameSet) { - if (shouldEmitFile(fileNameSet[fileName])) { + fileNameSet.forEach((scriptInfo, fileName) => { + if (shouldEmitFile(scriptInfo)) { result.push(fileName); } - } + }); return result; } } diff --git a/src/server/cancellationToken/cancellationToken.ts b/src/server/cancellationToken/cancellationToken.ts index 6d3dec67cc6..71a31d14016 100644 --- a/src/server/cancellationToken/cancellationToken.ts +++ b/src/server/cancellationToken/cancellationToken.ts @@ -1,14 +1,24 @@ -/// - - -// TODO: extract services types -interface HostCancellationToken { - isCancellationRequested(): boolean; -} +/// import fs = require("fs"); -function createCancellationToken(args: string[]): HostCancellationToken { +interface ServerCancellationToken { + isCancellationRequested(): boolean; + setRequest(requestId: number): void; + resetRequest(requestId: number): void; +} + +function pipeExists(name: string): boolean { + try { + fs.statSync(name); + return true; + } + catch (e) { + return false; + } +} + +function createCancellationToken(args: string[]): ServerCancellationToken { let cancellationPipeName: string; for (let i = 0; i < args.length - 1; i++) { if (args[i] === "--cancellationPipeName") { @@ -17,18 +27,44 @@ function createCancellationToken(args: string[]): HostCancellationToken { } } if (!cancellationPipeName) { - return { isCancellationRequested: () => false }; + return { + isCancellationRequested: () => false, + setRequest: (_requestId: number): void => void 0, + resetRequest: (_requestId: number): void => void 0 + }; } - return { - isCancellationRequested() { - try { - fs.statSync(cancellationPipeName); - return true; - } - catch (e) { - return false; - } + // cancellationPipeName is a string without '*' inside that can optionally end with '*' + // when client wants to signal cancellation it should create a named pipe with name= + // server will synchronously check the presence of the pipe and treat its existance as indicator that current request should be canceled. + // in case if client prefers to use more fine-grained schema than one name for all request it can add '*' to the end of cancelellationPipeName. + // in this case pipe name will be build dynamically as . + if (cancellationPipeName.charAt(cancellationPipeName.length - 1) === "*") { + const namePrefix = cancellationPipeName.slice(0, -1); + if (namePrefix.length === 0 || namePrefix.indexOf("*") >= 0) { + throw new Error("Invalid name for template cancellation pipe: it should have length greater than 2 characters and contain only one '*'."); } - }; + let perRequestPipeName: string; + let currentRequestId: number; + return { + isCancellationRequested: () => perRequestPipeName !== undefined && pipeExists(perRequestPipeName), + setRequest(requestId: number) { + currentRequestId = currentRequestId; + perRequestPipeName = namePrefix + requestId; + }, + resetRequest(requestId: number) { + if (currentRequestId !== requestId) { + throw new Error(`Mismatched request id, expected ${currentRequestId}, actual ${requestId}`); + } + perRequestPipeName = undefined; + } + }; + } + else { + return { + isCancellationRequested: () => pipeExists(cancellationPipeName), + setRequest: (_requestId: number): void => void 0, + resetRequest: (_requestId: number): void => void 0 + }; + } } export = createCancellationToken; \ No newline at end of file diff --git a/src/server/cancellationToken/tsconfig.json b/src/server/cancellationToken/tsconfig.json index 1c4c0d60826..fa7f88ca994 100644 --- a/src/server/cancellationToken/tsconfig.json +++ b/src/server/cancellationToken/tsconfig.json @@ -1,19 +1,11 @@ { + "extends": "../../tsconfig-base", "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": true, "removeComments": true, - "preserveConstEnums": true, - "pretty": true, "module": "commonjs", - "sourceMap": true, - "stripInternal": true, "types": [ "node" - ], - "target": "es5", - "noUnusedLocals": true, - "noUnusedParameters": true + ] }, "files": [ "cancellationToken.ts" diff --git a/src/server/client.ts b/src/server/client.ts index 3b09a926754..6f784db1682 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -13,6 +13,25 @@ namespace ts.server { findInComments: boolean; } + /* @internal */ + export function extractMessage(message: string) { + // Read the content length + const contentLengthPrefix = "Content-Length: "; + const lines = message.split(/\r?\n/); + Debug.assert(lines.length >= 2, "Malformed response: Expected 3 lines in the response."); + + const contentLengthText = lines[0]; + Debug.assert(contentLengthText.indexOf(contentLengthPrefix) === 0, "Malformed response: Response text did not contain content-length header."); + const contentLength = parseInt(contentLengthText.substring(contentLengthPrefix.length)); + + // Read the body + const responseBody = lines[2]; + + // Verify content length + Debug.assert(responseBody.length + 1 === contentLength, "Malformed response: Content length did not match the response's body length."); + return responseBody; + } + export class SessionClient implements LanguageService { private sequence: number = 0; private lineMaps: ts.Map = ts.createMap(); @@ -31,10 +50,11 @@ namespace ts.server { } private getLineMap(fileName: string): number[] { - let lineMap = this.lineMaps[fileName]; + let lineMap = this.lineMaps.get(fileName); if (!lineMap) { const scriptSnapshot = this.host.getScriptSnapshot(fileName); - lineMap = this.lineMaps[fileName] = ts.computeLineStarts(scriptSnapshot.getText(0, scriptSnapshot.getLength())); + lineMap = ts.computeLineStarts(scriptSnapshot.getText(0, scriptSnapshot.getLength())); + this.lineMaps.set(fileName, lineMap); } return lineMap; } @@ -83,7 +103,7 @@ namespace ts.server { while (!foundResponseMessage) { lastMessage = this.messages.shift(); Debug.assert(!!lastMessage, "Did not receive any responses."); - const responseBody = processMessage(lastMessage); + const responseBody = extractMessage(lastMessage); try { response = JSON.parse(responseBody); // the server may emit events before emitting the response. We @@ -108,24 +128,6 @@ namespace ts.server { Debug.assert(!!response.body, "Malformed response: Unexpected empty response body."); return response; - - function processMessage(message: string) { - // Read the content length - const contentLengthPrefix = "Content-Length: "; - const lines = message.split("\r\n"); - Debug.assert(lines.length >= 2, "Malformed response: Expected 3 lines in the response."); - - const contentLengthText = lines[0]; - Debug.assert(contentLengthText.indexOf(contentLengthPrefix) === 0, "Malformed response: Response text did not contain content-length header."); - const contentLength = parseInt(contentLengthText.substring(contentLengthPrefix.length)); - - // Read the body - const responseBody = lines[2]; - - // Verify content length - Debug.assert(responseBody.length + 1 === contentLength, "Malformed response: Content length did not match the response's body length."); - return responseBody; - } } openFile(fileName: string, content?: string, scriptKindName?: "TS" | "JS" | "TSX" | "JSX"): void { @@ -140,7 +142,7 @@ namespace ts.server { changeFile(fileName: string, start: number, end: number, newText: string): void { // clear the line map after an edit - this.lineMaps[fileName] = undefined; + this.lineMaps.set(fileName, undefined); const lineOffset = this.positionToOneBasedLineOffset(fileName, start); const endLineOffset = this.positionToOneBasedLineOffset(fileName, end); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 00df53e1e35..d0535e2f528 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// @@ -41,17 +41,17 @@ namespace ts.server { if (typeof option.type === "object") { const optionMap = >option.type; // verify that map contains only numbers - for (const id in optionMap) { - Debug.assert(typeof optionMap[id] === "number"); - } - map[option.name] = optionMap; + optionMap.forEach(value => { + Debug.assert(typeof value === "number"); + }); + map.set(option.name, optionMap); } } return map; } const compilerOptionConverters = prepareConvertersForEnumLikeCompilerOptions(optionDeclarations); - const indentStyle = createMap({ + const indentStyle = createMapFromTemplate({ "none": IndentStyle.None, "block": IndentStyle.Block, "smart": IndentStyle.Smart @@ -59,20 +59,19 @@ namespace ts.server { export function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings { if (typeof protocolOptions.indentStyle === "string") { - protocolOptions.indentStyle = indentStyle[protocolOptions.indentStyle.toLowerCase()]; + protocolOptions.indentStyle = indentStyle.get(protocolOptions.indentStyle.toLowerCase()); Debug.assert(protocolOptions.indentStyle !== undefined); } return protocolOptions; } export function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin { - for (const id in compilerOptionConverters) { + compilerOptionConverters.forEach((mappedValues, id) => { const propertyValue = protocolOptions[id]; if (typeof propertyValue === "string") { - const mappedValues = compilerOptionConverters[id]; - protocolOptions[id] = mappedValues[propertyValue.toLowerCase()]; + protocolOptions[id] = mappedValues.get(propertyValue.toLowerCase()); } - } + }); return protocolOptions; } @@ -108,7 +107,7 @@ namespace ts.server { export interface HostConfiguration { formatCodeOptions: FormatCodeSettings; hostInfo: string; - extraFileExtensions?: FileExtensionInfo[]; + extraFileExtensions?: JsFileExtensionInfo[]; } interface ConfigFileConversionResult { @@ -133,7 +132,7 @@ namespace ts.server { interface FilePropertyReader { getFileName(f: T): string; getScriptKind(f: T): ScriptKind; - hasMixedContent(f: T, extraFileExtensions: FileExtensionInfo[]): boolean; + hasMixedContent(f: T, extraFileExtensions: JsFileExtensionInfo[]): boolean; } const fileNamePropertyReader: FilePropertyReader = { @@ -193,11 +192,12 @@ namespace ts.server { stopWatchingDirectory(directory: string) { // if the ref count for this directory watcher drops to 0, it's time to close it - this.directoryWatchersRefCount[directory]--; - if (this.directoryWatchersRefCount[directory] === 0) { + const refCount = this.directoryWatchersRefCount.get(directory) - 1; + this.directoryWatchersRefCount.set(directory, refCount); + if (refCount === 0) { this.projectService.logger.info(`Close directory watcher for: ${directory}`); - this.directoryWatchersForTsconfig[directory].close(); - delete this.directoryWatchersForTsconfig[directory]; + this.directoryWatchersForTsconfig.get(directory).close(); + this.directoryWatchersForTsconfig.delete(directory); } } @@ -205,13 +205,13 @@ namespace ts.server { let currentPath = getDirectoryPath(fileName); let parentPath = getDirectoryPath(currentPath); while (currentPath != parentPath) { - if (!this.directoryWatchersForTsconfig[currentPath]) { + if (!this.directoryWatchersForTsconfig.has(currentPath)) { this.projectService.logger.info(`Add watcher for: ${currentPath}`); - this.directoryWatchersForTsconfig[currentPath] = this.projectService.host.watchDirectory(currentPath, callback); - this.directoryWatchersRefCount[currentPath] = 1; + this.directoryWatchersForTsconfig.set(currentPath, this.projectService.host.watchDirectory(currentPath, callback)); + this.directoryWatchersRefCount.set(currentPath, 1); } else { - this.directoryWatchersRefCount[currentPath] += 1; + this.directoryWatchersRefCount.set(currentPath, this.directoryWatchersRefCount.get(currentPath) + 1); } project.directoriesWatchedForTsconfig.push(currentPath); currentPath = parentPath; @@ -293,6 +293,7 @@ namespace ts.server { this.documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory()); } + /* @internal */ getChangedFiles_TestOnly() { return this.changedFiles; } @@ -430,7 +431,7 @@ namespace ts.server { } else { if (info && (!info.isScriptOpen())) { - // file has been changed which might affect the set of referenced files in projects that include + // file has been changed which might affect the set of referenced files in projects that include // this file and set of inferred projects info.reloadFromFile(); this.updateProjectGraphs(info.containingProjects); @@ -449,7 +450,7 @@ namespace ts.server { this.filenameToScriptInfo.remove(info.path); this.lastDeletedFile = info; - // capture list of projects since detachAllProjects will wipe out original list + // capture list of projects since detachAllProjects will wipe out original list const containingProjects = info.containingProjects.slice(); info.detachAllProjects(); @@ -605,7 +606,7 @@ namespace ts.server { const inferredProject = this.createInferredProjectWithRootFileIfNecessary(info); if (!this.useSingleInferredProject) { // if useOneInferredProject is not set then try to fixup ownership of open files - // check 'defaultProject !== inferredProject' is necessary to handle cases + // check 'defaultProject !== inferredProject' is necessary to handle cases // when creation inferred project for some file has added other open files into this project (i.e. as referenced files) // we definitely don't want to delete the project that was just created for (const f of this.openFiles) { @@ -615,7 +616,7 @@ namespace ts.server { } const defaultProject = f.getDefaultProject(); if (isRootFileInInferredProject(info) && defaultProject !== inferredProject && inferredProject.containsScriptInfo(f)) { - // open file used to be root in inferred project, + // open file used to be root in inferred project, // this inferred project is different from the one we've just created for current file // and new inferred project references this open file. // We should delete old inferred project and attach open file to the new one @@ -844,7 +845,7 @@ namespace ts.server { files: parsedCommandLine.fileNames, compilerOptions: parsedCommandLine.options, configHasFilesProperty: config["files"] !== undefined, - wildcardDirectories: createMap(parsedCommandLine.wildcardDirectories), + wildcardDirectories: createMapFromTemplate(parsedCommandLine.wildcardDirectories), typeAcquisition: parsedCommandLine.typeAcquisition, compileOnSave: parsedCommandLine.compileOnSave }; @@ -947,9 +948,9 @@ namespace ts.server { private openConfigFile(configFileName: NormalizedPath, clientFileName?: string): OpenConfigFileResult { const conversionResult = this.convertConfigFileContentToProjectOptions(configFileName); - const projectOptions = conversionResult.success + const projectOptions: ProjectOptions = conversionResult.success ? conversionResult.projectOptions - : { files: [], compilerOptions: {} }; + : { files: [], compilerOptions: {}, typeAcquisition: { enable: false } }; const project = this.createAndAddConfiguredProject(configFileName, projectOptions, conversionResult.configFileErrors, clientFileName); return { success: conversionResult.success, @@ -1006,7 +1007,7 @@ namespace ts.server { if (toAdd) { for (const f of toAdd) { if (f.isScriptOpen() && isRootFileInInferredProject(f)) { - // if file is already root in some inferred project + // if file is already root in some inferred project // - remove the file from that project and delete the project if necessary const inferredProject = f.containingProjects[0]; inferredProject.removeFile(f); @@ -1159,7 +1160,7 @@ namespace ts.server { this.logger.info(`Host information ${args.hostInfo}`); } if (args.formatOptions) { - mergeMaps(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); + mergeMapLikes(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); this.logger.info("Format host information updated"); } if (args.extraFileExtensions) { @@ -1274,6 +1275,7 @@ namespace ts.server { } } + /* @internal */ synchronizeProjectList(knownProjects: protocol.ProjectVersionInfo[]): ProjectFilesWithTSDiagnostics[] { const files: ProjectFilesWithTSDiagnostics[] = []; this.collectChanges(knownProjects, this.externalProjects, files); @@ -1282,6 +1284,7 @@ namespace ts.server { return files; } + /* @internal */ applyChangesInOpenFiles(openFiles: protocol.ExternalFile[], changedFiles: protocol.ChangedOpenFile[], closedFiles: string[]): void { const recordChangedFiles = changedFiles && !openFiles && !closedFiles; if (openFiles) { @@ -1297,7 +1300,7 @@ namespace ts.server { for (const file of changedFiles) { const scriptInfo = this.getScriptInfo(file.fileName); Debug.assert(!!scriptInfo); - // apply changes in reverse order + // apply changes in reverse order for (let i = file.changes.length - 1; i >= 0; i--) { const change = file.changes[i]; scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText); @@ -1334,7 +1337,7 @@ namespace ts.server { closeExternalProject(uncheckedFileName: string, suppressRefresh = false): void { const fileName = toNormalizedPath(uncheckedFileName); - const configFiles = this.externalProjectToConfiguredProjectMap[fileName]; + const configFiles = this.externalProjectToConfiguredProjectMap.get(fileName); if (configFiles) { let shouldRefreshInferredProjects = false; for (const configFile of configFiles) { @@ -1342,7 +1345,7 @@ namespace ts.server { shouldRefreshInferredProjects = true; } } - delete this.externalProjectToConfiguredProjectMap[fileName]; + this.externalProjectToConfiguredProjectMap.delete(fileName); if (shouldRefreshInferredProjects && !suppressRefresh) { this.refreshInferredProjects(); } @@ -1362,20 +1365,20 @@ namespace ts.server { openExternalProjects(projects: protocol.ExternalProject[]): void { // record project list before the update const projectsToClose = arrayToMap(this.externalProjects, p => p.getProjectName(), _ => true); - for (const externalProjectName in this.externalProjectToConfiguredProjectMap) { - projectsToClose[externalProjectName] = true; - } + forEachKey(this.externalProjectToConfiguredProjectMap, externalProjectName => { + projectsToClose.set(externalProjectName, true); + }); for (const externalProject of projects) { this.openExternalProject(externalProject, /*suppressRefreshOfInferredProjects*/ true); // delete project that is present in input list - delete projectsToClose[externalProject.projectFileName]; + projectsToClose.delete(externalProject.projectFileName); } // close projects that were missing in the input list - for (const externalProjectName in projectsToClose) { + forEachKey(projectsToClose, externalProjectName => { this.closeExternalProject(externalProjectName, /*suppressRefresh*/ true) - } + }); this.refreshInferredProjects(); } @@ -1425,7 +1428,7 @@ namespace ts.server { // close existing project and later we'll open a set of configured projects for these files this.closeExternalProject(proj.projectFileName, /*suppressRefresh*/ true); } - else if (this.externalProjectToConfiguredProjectMap[proj.projectFileName]) { + else if (this.externalProjectToConfiguredProjectMap.get(proj.projectFileName)) { // this project used to include config files if (!tsConfigFiles) { // config files were removed from the project - close existing external project which in turn will close configured projects @@ -1433,7 +1436,7 @@ namespace ts.server { } else { // project previously had some config files - compare them with new set of files and close all configured projects that correspond to unused files - const oldConfigFiles = this.externalProjectToConfiguredProjectMap[proj.projectFileName]; + const oldConfigFiles = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName); let iNew = 0; let iOld = 0; while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) { @@ -1461,7 +1464,7 @@ namespace ts.server { } if (tsConfigFiles) { // store the list of tsconfig files that belong to the external project - this.externalProjectToConfiguredProjectMap[proj.projectFileName] = tsConfigFiles; + this.externalProjectToConfiguredProjectMap.set(proj.projectFileName, tsConfigFiles); for (const tsconfigFile of tsConfigFiles) { let project = this.findConfiguredProjectByProjectName(tsconfigFile); if (!project) { @@ -1477,7 +1480,7 @@ namespace ts.server { } else { // no config files - remove the item from the collection - delete this.externalProjectToConfiguredProjectMap[proj.projectFileName]; + this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName); this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition); } if (!suppressRefreshOfInferredProjects) { diff --git a/src/server/lsHost.ts b/src/server/lsHost.ts index 98b3dd9a8c0..eee80d82e7f 100644 --- a/src/server/lsHost.ts +++ b/src/server/lsHost.ts @@ -28,7 +28,7 @@ namespace ts.server { : undefined; const primaryResult = resolveModuleName(moduleName, containingFile, compilerOptions, host); // return result immediately only if it is .ts, .tsx or .d.ts - if (!(primaryResult.resolvedModule && extensionIsTypeScript(primaryResult.resolvedModule.extension)) && globalCache !== undefined) { + if (moduleHasNonRelativeName(moduleName) && !(primaryResult.resolvedModule && extensionIsTypeScript(primaryResult.resolvedModule.extension)) && globalCache !== undefined) { // otherwise try to load typings from @types // create different collection of failed lookup locations for second pass @@ -75,15 +75,16 @@ namespace ts.server { for (const name of names) { // check if this is a duplicate entry in the list - let resolution = newResolutions[name]; + let resolution = newResolutions.get(name); if (!resolution) { - const existingResolution = currentResolutionsInFile && currentResolutionsInFile[name]; + const existingResolution = currentResolutionsInFile && currentResolutionsInFile.get(name); if (moduleResolutionIsValid(existingResolution)) { // ok, it is safe to use existing name resolution results resolution = existingResolution; } else { - newResolutions[name] = resolution = loader(name, containingFile, compilerOptions, this); + resolution = loader(name, containingFile, compilerOptions, this); + newResolutions.set(name, resolution); } if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { this.filesWithChangedSetOfUnresolvedImports.push(path); diff --git a/src/server/project.ts b/src/server/project.ts index 6085ee05159..e4669ea191b 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// @@ -58,6 +58,7 @@ namespace ts.server { return counts.ts === 0 && counts.tsx === 0; } + /* @internal */ export interface ProjectFilesWithTSDiagnostics extends protocol.ProjectFiles { projectErrors: Diagnostic[]; } @@ -90,19 +91,38 @@ namespace ts.server { } } + export interface PluginCreateInfo { + project: Project; + languageService: LanguageService; + languageServiceHost: LanguageServiceHost; + serverHost: ServerHost; + config: any; + } + + export interface PluginModule { + create(createInfo: PluginCreateInfo): LanguageService; + getExternalFiles?(proj: Project): string[]; + } + + export interface PluginModuleFactory { + (mod: { typescript: typeof ts }): PluginModule; + } + export abstract class Project { private rootFiles: ScriptInfo[] = []; private rootFilesMap: FileMap = createFileMap(); - private lsHost: LSHost; private program: ts.Program; private cachedUnresolvedImportsPerFile = new UnresolvedImportsMap(); private lastCachedUnresolvedImportsList: SortedReadonlyArray; - private readonly languageService: LanguageService; + // wrapper over the real language service that will suppress all semantic operations + protected languageService: LanguageService; public languageServiceEnabled = true; + protected readonly lsHost: LSHost; + builder: Builder; /** * Set of files names that were updated since the last call to getChangesSinceVersion. @@ -149,6 +169,17 @@ namespace ts.server { return this.cachedUnresolvedImportsPerFile; } + public static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void): {} { + const resolvedPath = normalizeSlashes(host.resolvePath(combinePaths(initialDir, "node_modules"))); + log(`Loading ${moduleName} from ${initialDir} (resolved to ${resolvedPath})`); + const result = host.require(resolvedPath, moduleName); + if (result.error) { + log(`Failed to load module: ${JSON.stringify(result.error)}`); + return undefined; + } + return result.module; + } + constructor( private readonly projectName: string, readonly projectKind: ProjectKind, @@ -164,8 +195,8 @@ namespace ts.server { this.compilerOptions.allowNonTsExtensions = true; this.compilerOptions.allowJs = true; } - else if (hasExplicitListOfFiles) { - // If files are listed explicitly, allow all extensions + else if (hasExplicitListOfFiles || this.compilerOptions.allowJs) { + // If files are listed explicitly or allowJs is specified, allow all extensions this.compilerOptions.allowNonTsExtensions = true; } @@ -236,6 +267,10 @@ namespace ts.server { abstract getProjectRootPath(): string | undefined; abstract getTypeAcquisition(): TypeAcquisition; + getExternalFiles(): string[] { + return []; + } + getSourceFile(path: Path) { if (!this.program) { return undefined; @@ -395,7 +430,9 @@ namespace ts.server { } removeFile(info: ScriptInfo, detachFromProject = true) { - this.removeRootFileIfNecessary(info); + if (this.isRoot(info)) { + this.removeRoot(info); + } this.lsHost.notifyFileRemoved(info); this.cachedUnresolvedImportsPerFile.remove(info.path); @@ -407,7 +444,7 @@ namespace ts.server { } registerFileUpdate(fileName: string) { - (this.updatedFileNames || (this.updatedFileNames = createMap()))[fileName] = fileName; + (this.updatedFileNames || (this.updatedFileNames = createMap())).set(fileName, fileName); } markAsDirty() { @@ -425,9 +462,9 @@ namespace ts.server { } let unresolvedImports: string[]; if (file.resolvedModules) { - for (const name in file.resolvedModules) { + file.resolvedModules.forEach((resolvedModule, name) => { // pick unresolved non-relative names - if (!file.resolvedModules[name] && !isExternalModuleNameRelative(name)) { + if (!resolvedModule && !isExternalModuleNameRelative(name)) { // for non-scoped names extract part up-to the first slash // for scoped names - extract up to the second slash let trimmed = name.trim(); @@ -441,7 +478,7 @@ namespace ts.server { (unresolvedImports || (unresolvedImports = [])).push(trimmed); result.push(trimmed); } - } + }); } this.cachedUnresolvedImportsPerFile.set(file.path, unresolvedImports || emptyArray); } @@ -463,7 +500,7 @@ namespace ts.server { } // 1. no changes in structure, no changes in unresolved imports - do nothing - // 2. no changes in structure, unresolved imports were changed - collect unresolved imports for all files + // 2. no changes in structure, unresolved imports were changed - collect unresolved imports for all files // (can reuse cached imports for files that were not changed) // 3. new files were added/removed, but compilation settings stays the same - collect unresolved imports for all new/modified files // (can reuse cached imports for files that were not changed) @@ -566,9 +603,6 @@ namespace ts.server { setCompilerOptions(compilerOptions: CompilerOptions) { if (compilerOptions) { - if (this.projectKind === ProjectKind.Inferred) { - compilerOptions.allowJs = true; - } compilerOptions.allowNonTsExtensions = true; if (changesAffectModuleResolution(this.compilerOptions, compilerOptions)) { // reset cached unresolved imports if changes in compiler options affected module resolution @@ -593,6 +627,7 @@ namespace ts.server { return false; } + /* @internal */ getChangesSinceVersion(lastKnownVersion?: number): ProjectFilesWithTSDiagnostics { this.updateGraph(); @@ -617,17 +652,18 @@ namespace ts.server { const added: string[] = []; const removed: string[] = []; - const updated: string[] = getOwnKeys(updatedFileNames); - for (const id in currentFiles) { - if (!hasProperty(lastReportedFileNames, id)) { + const updated: string[] = arrayFrom(updatedFileNames.keys()); + + forEachKey(currentFiles, id => { + if (!lastReportedFileNames.has(id)) { added.push(id); } - } - for (const id in lastReportedFileNames) { - if (!hasProperty(currentFiles, id)) { + }); + forEachKey(lastReportedFileNames, id => { + if (!currentFiles.has(id)) { removed.push(id); } - } + }); this.lastReportedFileNames = currentFiles; this.lastReportedVersion = this.projectStructureVersion; return { info, changes: { added, removed, updated }, projectErrors: this.projectErrors }; @@ -661,7 +697,7 @@ namespace ts.server { if (symbol && symbol.declarations && symbol.declarations[0]) { const declarationSourceFile = symbol.declarations[0].getSourceFile(); if (declarationSourceFile) { - referencedFiles[declarationSourceFile.path] = true; + referencedFiles.set(declarationSourceFile.path, true); } } } @@ -673,34 +709,31 @@ namespace ts.server { if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) { for (const referencedFile of sourceFile.referencedFiles) { const referencedPath = toPath(referencedFile.fileName, currentDirectory, getCanonicalFileName); - referencedFiles[referencedPath] = true; + referencedFiles.set(referencedPath, true); } } // Handle type reference directives if (sourceFile.resolvedTypeReferenceDirectiveNames) { - for (const typeName in sourceFile.resolvedTypeReferenceDirectiveNames) { - const resolvedTypeReferenceDirective = sourceFile.resolvedTypeReferenceDirectiveNames[typeName]; + sourceFile.resolvedTypeReferenceDirectiveNames.forEach((resolvedTypeReferenceDirective) => { if (!resolvedTypeReferenceDirective) { - continue; + return; } const fileName = resolvedTypeReferenceDirective.resolvedFileName; const typeFilePath = toPath(fileName, currentDirectory, getCanonicalFileName); - referencedFiles[typeFilePath] = true; - } + referencedFiles.set(typeFilePath, true); + }) } - const allFileNames = map(Object.keys(referencedFiles), key => key); + const allFileNames = arrayFrom(referencedFiles.keys()) as Path[]; return filter(allFileNames, file => this.projectService.host.fileExists(file)); } // remove a root file from project - private removeRootFileIfNecessary(info: ScriptInfo): void { - if (this.isRoot(info)) { - remove(this.rootFiles, info); - this.rootFilesMap.remove(info.path); - } + protected removeRoot(info: ScriptInfo): void { + remove(this.rootFiles, info); + this.rootFilesMap.remove(info.path); } } @@ -715,6 +748,32 @@ namespace ts.server { } })(); + private _isJsInferredProject = false; + + toggleJsInferredProject(isJsInferredProject: boolean) { + if (isJsInferredProject !== this._isJsInferredProject) { + this._isJsInferredProject = isJsInferredProject; + this.setCompilerOptions(); + } + } + + setCompilerOptions(options?: CompilerOptions) { + // Avoid manipulating the given options directly + const newOptions = options ? clone(options) : this.getCompilerOptions(); + if (!newOptions) { + return; + } + + if (this._isJsInferredProject && typeof newOptions.maxNodeModuleJsDepth !== "number") { + newOptions.maxNodeModuleJsDepth = 2; + } + else if (!this._isJsInferredProject) { + newOptions.maxNodeModuleJsDepth = undefined; + } + newOptions.allowJs = true; + super.setCompilerOptions(newOptions); + } + // Used to keep track of what directories are watched for this project directoriesWatchedForTsconfig: string[] = []; @@ -729,6 +788,22 @@ namespace ts.server { /*compileOnSaveEnabled*/ false); } + addRoot(info: ScriptInfo) { + if (!this._isJsInferredProject && info.isJavaScript()) { + this.toggleJsInferredProject(/*isJsInferredProject*/ true); + } + super.addRoot(info); + } + + removeRoot(info: ScriptInfo) { + if (this._isJsInferredProject && info.isJavaScript()) { + if (filter(this.getRootScriptInfos(), info => info.isJavaScript()).length === 0) { + this.toggleJsInferredProject(/*isJsInferredProject*/ false); + } + } + super.removeRoot(info); + } + getProjectRootPath() { // Single inferred project does not have a project root. if (this.projectService.useSingleInferredProject) { @@ -763,10 +838,12 @@ namespace ts.server { private typeRootsWatchers: FileWatcher[]; readonly canonicalConfigFilePath: NormalizedPath; + private plugins: PluginModule[] = []; + /** Used for configured projects which may have multiple open roots */ openRefCount = 0; - constructor(configFileName: NormalizedPath, + constructor(private configFileName: NormalizedPath, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, @@ -776,12 +853,64 @@ namespace ts.server { public compileOnSaveEnabled: boolean) { super(configFileName, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled); this.canonicalConfigFilePath = asNormalizedPath(projectService.toCanonicalFileName(configFileName)); + this.enablePlugins(); } getConfigFilePath() { return this.getProjectName(); } + enablePlugins() { + const host = this.projectService.host; + const options = this.getCompilerOptions(); + const log = (message: string) => { + this.projectService.logger.info(message); + }; + + if (!(options.plugins && options.plugins.length)) { + this.projectService.logger.info("No plugins exist"); + // No plugins + return; + } + + if (!host.require) { + this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); + return; + } + + for (const pluginConfigEntry of options.plugins) { + const searchPath = getDirectoryPath(this.configFileName); + const resolvedModule = Project.resolveModule(pluginConfigEntry.name, searchPath, host, log); + if (resolvedModule) { + this.enableProxy(resolvedModule, pluginConfigEntry); + } + } + } + + private enableProxy(pluginModuleFactory: PluginModuleFactory, configEntry: PluginImport) { + try { + if (typeof pluginModuleFactory !== "function") { + this.projectService.logger.info(`Skipped loading plugin ${configEntry.name} because it did expose a proper factory function`); + return; + } + + const info: PluginCreateInfo = { + config: configEntry, + project: this, + languageService: this.languageService, + languageServiceHost: this.lsHost, + serverHost: this.projectService.host + }; + + const pluginModule = pluginModuleFactory({ typescript: ts }); + this.languageService = pluginModule.create(info); + this.plugins.push(pluginModule); + } + catch (e) { + this.projectService.logger.info(`Plugin activation failed: ${e}`); + } + } + getProjectRootPath() { return getDirectoryPath(this.getConfigFilePath()); } @@ -798,6 +927,21 @@ namespace ts.server { return this.typeAcquisition; } + getExternalFiles(): string[] { + const items: string[] = []; + for (const plugin of this.plugins) { + if (typeof plugin.getExternalFiles === "function") { + try { + items.push(...plugin.getExternalFiles(this)); + } + catch (e) { + this.projectService.logger.info(`A plugin threw an exception in getExternalFiles: ${e}`); + } + } + } + return items; + } + watchConfigFile(callback: (project: ConfiguredProject) => void) { this.projectFileWatcher = this.projectService.host.watchFile(this.getConfigFilePath(), _ => callback(this)); } @@ -827,18 +971,19 @@ namespace ts.server { return; } const configDirectoryPath = getDirectoryPath(this.getConfigFilePath()); - this.directoriesWatchedForWildcards = reduceProperties(this.wildcardDirectories, (watchers, flag, directory) => { + + this.directoriesWatchedForWildcards = createMap(); + this.wildcardDirectories.forEach((flag, directory) => { if (comparePaths(configDirectoryPath, directory, ".", !this.projectService.host.useCaseSensitiveFileNames) !== Comparison.EqualTo) { const recursive = (flag & WatchDirectoryFlags.Recursive) !== 0; this.projectService.logger.info(`Add ${recursive ? "recursive " : ""}watcher for: ${directory}`); - watchers[directory] = this.projectService.host.watchDirectory( + this.directoriesWatchedForWildcards.set(directory, this.projectService.host.watchDirectory( directory, path => callback(this, path), recursive - ); + )); } - return watchers; - }, >{}); + }); } stopWatchingDirectory() { @@ -862,9 +1007,9 @@ namespace ts.server { this.typeRootsWatchers = undefined; } - for (const id in this.directoriesWatchedForWildcards) { - this.directoriesWatchedForWildcards[id].close(); - } + this.directoriesWatchedForWildcards.forEach(watcher => { + watcher.close(); + }); this.directoriesWatchedForWildcards = undefined; this.stopWatchingDirectory(); diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 680b81dff99..c7d27d80d25 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -417,7 +417,7 @@ namespace ts.server.protocol { startOffset: number; /** - * Position (can be specified instead of line/offset pair) + * Position (can be specified instead of line/offset pair) */ /* @internal */ startPosition?: number; @@ -433,7 +433,7 @@ namespace ts.server.protocol { endOffset: number; /** - * Position (can be specified instead of line/offset pair) + * Position (can be specified instead of line/offset pair) */ /* @internal */ endPosition?: number; @@ -445,7 +445,7 @@ namespace ts.server.protocol { } /** - * Response for GetCodeFixes request. + * Response for GetCodeFixes request. */ export interface GetCodeFixesResponse extends Response { body?: CodeAction[]; @@ -820,7 +820,7 @@ namespace ts.server.protocol { * Represents a file in external project. * External project is project whose set of files, compilation options and open\close state * is maintained by the client (i.e. if all this data come from .csproj file in Visual Studio). - * External project will exist even if all files in it are closed and should be closed explicity. + * External project will exist even if all files in it are closed and should be closed explicitly. * If external project includes one or more tsconfig.json/jsconfig.json files then tsserver will * create configured project for every config file but will maintain a link that these projects were created * as a result of opening external project so they should be removed once external project is closed. @@ -1001,9 +1001,9 @@ namespace ts.server.protocol { formatOptions?: FormatCodeSettings; /** - * The host's additional supported file extensions + * The host's additional supported .js file extensions */ - extraFileExtensions?: FileExtensionInfo[]; + extraFileExtensions?: JsFileExtensionInfo[]; } /** @@ -1239,6 +1239,11 @@ namespace ts.server.protocol { * List of files names that should be recompiled */ fileNames: string[]; + + /** + * true if project uses outFile or out compiler option + */ + projectUsesOutFile: boolean; } /** @@ -1761,6 +1766,20 @@ namespace ts.server.protocol { arguments: GeterrRequestArgs; } + export type RequestCompletedEventName = "requestCompleted"; + + /** + * Event that is sent when server have finished processing request with specified id. + */ + export interface RequestCompletedEvent extends Event { + event: RequestCompletedEventName; + body: RequestCompletedEventBody; + } + + export interface RequestCompletedEventBody { + request_seq: number; + } + /** * Item of diagnostic information found in a DiagnosticEvent message. */ @@ -2248,6 +2267,7 @@ namespace ts.server.protocol { outDir?: string; outFile?: string; paths?: MapLike; + plugins?: PluginImport[]; preserveConstEnums?: boolean; project?: string; reactNamespace?: string; @@ -2272,10 +2292,11 @@ namespace ts.server.protocol { export namespace JsxEmit { export type None = "None"; export type Preserve = "Preserve"; + export type ReactNative = "ReactNative"; export type React = "React"; } - export type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React; + export type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React | JsxEmit.ReactNative; export namespace ModuleKind { export type None = "None"; diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index 0acd45d0287..be3ef34ce3a 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -278,7 +278,7 @@ namespace ts.server { if (!this.formatCodeSettings) { this.formatCodeSettings = getDefaultFormatCodeSettings(this.host); } - mergeMaps(this.formatCodeSettings, formatSettings); + mergeMapLikes(this.formatCodeSettings, formatSettings); } } @@ -355,5 +355,9 @@ namespace ts.server { positionToLineOffset(position: number): ILineInfo { return this.textStorage.positionToLineOffset(position); } + + public isJavaScript() { + return this.scriptKind === ScriptKind.JS || this.scriptKind === ScriptKind.JSX; + } } } \ No newline at end of file diff --git a/src/server/server.ts b/src/server/server.ts index e689a2fc782..2a5990f4252 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -12,6 +12,7 @@ namespace ts.server { const childProcess: { fork(modulePath: string, args: string[], options?: { execArgv: string[], env?: MapLike }): NodeChildProcess; + execFileSync(file: string, args: string[], options: { stdio: "ignore", env: MapLike }): string | Buffer; } = require("child_process"); const os: { @@ -59,7 +60,7 @@ namespace ts.server { interface NodeChildProcess { send(message: any, sendHandle?: any): void; - on(message: "message", f: (m: any) => void): void; + on(message: "message" | "exit", f: (m: any) => void): void; kill(): void; pid: number; } @@ -99,6 +100,8 @@ namespace ts.server { birthtime: Date; } + type RequireResult = { module: {}, error: undefined } | { module: undefined, error: {} }; + const readline: { createInterface(options: ReadLineOptions): NodeJS.EventEmitter; } = require("readline"); @@ -354,7 +357,7 @@ namespace ts.server { class IOSession extends Session { constructor( host: ServerHost, - cancellationToken: HostCancellationToken, + cancellationToken: ServerCancellationToken, installerEventPort: number, canUseEvents: boolean, useSingleInferredProject: boolean, @@ -574,7 +577,84 @@ namespace ts.server { } } + function extractWatchDirectoryCacheKey(path: string, currentDriveKey: string) { + path = normalizeSlashes(path); + if (isUNCPath(path)) { + // UNC path: extract server name + // //server/location + // ^ <- from 0 to this position + const firstSlash = path.indexOf(directorySeparator, 2); + return firstSlash !== -1 ? path.substring(0, firstSlash).toLowerCase() : path; + } + const rootLength = getRootLength(path); + if (rootLength === 0) { + // relative path - assume file is on the current drive + return currentDriveKey; + } + if (path.charCodeAt(1) === CharacterCodes.colon && path.charCodeAt(2) === CharacterCodes.slash) { + // rooted path that starts with c:/... - extract drive letter + return path.charAt(0).toLowerCase(); + } + if (path.charCodeAt(0) === CharacterCodes.slash && path.charCodeAt(1) !== CharacterCodes.slash) { + // rooted path that starts with slash - /somename - use key for current drive + return currentDriveKey; + } + // do not cache any other cases + return undefined; + } + + function isUNCPath(s: string): boolean { + return s.length > 2 && s.charCodeAt(0) === CharacterCodes.slash && s.charCodeAt(1) === CharacterCodes.slash; + } + const sys = ts.sys; + // use watchGuard process on Windows when node version is 4 or later + const useWatchGuard = process.platform === "win32" && getNodeMajorVersion() >= 4; + if (useWatchGuard) { + const currentDrive = extractWatchDirectoryCacheKey(sys.resolvePath(sys.getCurrentDirectory()), /*currentDriveKey*/ undefined); + const statusCache = createMap(); + const originalWatchDirectory = sys.watchDirectory; + sys.watchDirectory = function (path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher { + const cacheKey = extractWatchDirectoryCacheKey(path, currentDrive); + let status = cacheKey && statusCache.get(cacheKey); + if (status === undefined) { + if (logger.hasLevel(LogLevel.verbose)) { + logger.info(`${cacheKey} for path ${path} not found in cache...`); + } + try { + const args = [combinePaths(__dirname, "watchGuard.js"), path]; + if (logger.hasLevel(LogLevel.verbose)) { + logger.info(`Starting ${process.execPath} with args ${JSON.stringify(args)}`); + } + childProcess.execFileSync(process.execPath, args, { stdio: "ignore", env: { "ELECTRON_RUN_AS_NODE": "1" } }); + status = true; + if (logger.hasLevel(LogLevel.verbose)) { + logger.info(`WatchGuard for path ${path} returned: OK`); + } + } + catch (e) { + status = false; + if (logger.hasLevel(LogLevel.verbose)) { + logger.info(`WatchGuard for path ${path} returned: ${e.message}`); + } + } + if (cacheKey) { + statusCache.set(cacheKey, status); + } + } + else if (logger.hasLevel(LogLevel.verbose)) { + logger.info(`watchDirectory for ${path} uses cached drive information.`); + } + if (status) { + // this drive is safe to use - call real 'watchDirectory' + return originalWatchDirectory.call(sys, path, callback, recursive); + } + else { + // this drive is unsafe - return no-op watcher + return { close() { } }; + } + } + } // Override sys.write because fs.writeSync is not reliable on Node 4 sys.write = (s: string) => writeMessage(new Buffer(s, "utf8")); @@ -593,15 +673,23 @@ namespace ts.server { sys.gc = () => global.gc(); } - let cancellationToken: HostCancellationToken; + sys.require = (initialDir: string, moduleName: string): RequireResult => { + const result = nodeModuleNameResolverWorker(moduleName, initialDir + "/program.ts", { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, sys, undefined, /*jsOnly*/ true); + try { + return { module: require(result.resolvedModule.resolvedFileName), error: undefined }; + } + catch (e) { + return { module: undefined, error: e }; + } + }; + + let cancellationToken: ServerCancellationToken; try { const factory = require("./cancellationToken"); cancellationToken = factory(sys.args); } catch (e) { - cancellationToken = { - isCancellationRequested: () => false - }; + cancellationToken = nullCancellationToken; }; let eventPort: number; diff --git a/src/server/session.ts b/src/server/session.ts index 5c382aae7d3..262ba8da1da 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -8,6 +8,17 @@ namespace ts.server { stack?: string; } + export interface ServerCancellationToken extends HostCancellationToken { + setRequest(requestId: number): void; + resetRequest(requestId: number): void; + } + + export const nullCancellationToken: ServerCancellationToken = { + isCancellationRequested: () => false, + setRequest: () => void 0, + resetRequest: () => void 0 + }; + function hrTimeToMilliseconds(time: number[]): number { const seconds = time[0]; const nanoseconds = time[1]; @@ -88,50 +99,65 @@ namespace ts.server { export namespace CommandNames { export const Brace: protocol.CommandTypes.Brace = "brace"; + /* @internal */ export const BraceFull: protocol.CommandTypes.BraceFull = "brace-full"; export const BraceCompletion: protocol.CommandTypes.BraceCompletion = "braceCompletion"; export const Change: protocol.CommandTypes.Change = "change"; export const Close: protocol.CommandTypes.Close = "close"; export const Completions: protocol.CommandTypes.Completions = "completions"; + /* @internal */ export const CompletionsFull: protocol.CommandTypes.CompletionsFull = "completions-full"; export const CompletionDetails: protocol.CommandTypes.CompletionDetails = "completionEntryDetails"; export const CompileOnSaveAffectedFileList: protocol.CommandTypes.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; export const CompileOnSaveEmitFile: protocol.CommandTypes.CompileOnSaveEmitFile = "compileOnSaveEmitFile"; export const Configure: protocol.CommandTypes.Configure = "configure"; export const Definition: protocol.CommandTypes.Definition = "definition"; + /* @internal */ export const DefinitionFull: protocol.CommandTypes.DefinitionFull = "definition-full"; export const Exit: protocol.CommandTypes.Exit = "exit"; export const Format: protocol.CommandTypes.Format = "format"; export const Formatonkey: protocol.CommandTypes.Formatonkey = "formatonkey"; + /* @internal */ export const FormatFull: protocol.CommandTypes.FormatFull = "format-full"; + /* @internal */ export const FormatonkeyFull: protocol.CommandTypes.FormatonkeyFull = "formatonkey-full"; + /* @internal */ export const FormatRangeFull: protocol.CommandTypes.FormatRangeFull = "formatRange-full"; export const Geterr: protocol.CommandTypes.Geterr = "geterr"; export const GeterrForProject: protocol.CommandTypes.GeterrForProject = "geterrForProject"; export const Implementation: protocol.CommandTypes.Implementation = "implementation"; + /* @internal */ export const ImplementationFull: protocol.CommandTypes.ImplementationFull = "implementation-full"; export const SemanticDiagnosticsSync: protocol.CommandTypes.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; export const SyntacticDiagnosticsSync: protocol.CommandTypes.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; export const NavBar: protocol.CommandTypes.NavBar = "navbar"; + /* @internal */ export const NavBarFull: protocol.CommandTypes.NavBarFull = "navbar-full"; export const NavTree: protocol.CommandTypes.NavTree = "navtree"; export const NavTreeFull: protocol.CommandTypes.NavTreeFull = "navtree-full"; export const Navto: protocol.CommandTypes.Navto = "navto"; + /* @internal */ export const NavtoFull: protocol.CommandTypes.NavtoFull = "navto-full"; export const Occurrences: protocol.CommandTypes.Occurrences = "occurrences"; export const DocumentHighlights: protocol.CommandTypes.DocumentHighlights = "documentHighlights"; + /* @internal */ export const DocumentHighlightsFull: protocol.CommandTypes.DocumentHighlightsFull = "documentHighlights-full"; export const Open: protocol.CommandTypes.Open = "open"; export const Quickinfo: protocol.CommandTypes.Quickinfo = "quickinfo"; + /* @internal */ export const QuickinfoFull: protocol.CommandTypes.QuickinfoFull = "quickinfo-full"; export const References: protocol.CommandTypes.References = "references"; + /* @internal */ export const ReferencesFull: protocol.CommandTypes.ReferencesFull = "references-full"; export const Reload: protocol.CommandTypes.Reload = "reload"; export const Rename: protocol.CommandTypes.Rename = "rename"; + /* @internal */ export const RenameInfoFull: protocol.CommandTypes.RenameInfoFull = "rename-full"; + /* @internal */ export const RenameLocationsFull: protocol.CommandTypes.RenameLocationsFull = "renameLocations-full"; export const Saveto: protocol.CommandTypes.Saveto = "saveto"; export const SignatureHelp: protocol.CommandTypes.SignatureHelp = "signatureHelp"; + /* @internal */ export const SignatureHelpFull: protocol.CommandTypes.SignatureHelpFull = "signatureHelp-full"; export const TypeDefinition: protocol.CommandTypes.TypeDefinition = "typeDefinition"; export const ProjectInfo: protocol.CommandTypes.ProjectInfo = "projectInfo"; @@ -140,19 +166,28 @@ namespace ts.server { export const OpenExternalProject: protocol.CommandTypes.OpenExternalProject = "openExternalProject"; export const OpenExternalProjects: protocol.CommandTypes.OpenExternalProjects = "openExternalProjects"; export const CloseExternalProject: protocol.CommandTypes.CloseExternalProject = "closeExternalProject"; + /* @internal */ export const SynchronizeProjectList: protocol.CommandTypes.SynchronizeProjectList = "synchronizeProjectList"; + /* @internal */ export const ApplyChangedToOpenFiles: protocol.CommandTypes.ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; + /* @internal */ export const EncodedSemanticClassificationsFull: protocol.CommandTypes.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; + /* @internal */ export const Cleanup: protocol.CommandTypes.Cleanup = "cleanup"; + /* @internal */ export const OutliningSpans: protocol.CommandTypes.OutliningSpans = "outliningSpans"; export const TodoComments: protocol.CommandTypes.TodoComments = "todoComments"; export const Indentation: protocol.CommandTypes.Indentation = "indentation"; export const DocCommentTemplate: protocol.CommandTypes.DocCommentTemplate = "docCommentTemplate"; + /* @internal */ export const CompilerOptionsDiagnosticsFull: protocol.CommandTypes.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; + /* @internal */ export const NameOrDottedNameSpan: protocol.CommandTypes.NameOrDottedNameSpan = "nameOrDottedNameSpan"; + /* @internal */ export const BreakpointStatement: protocol.CommandTypes.BreakpointStatement = "breakpointStatement"; export const CompilerOptionsForInferredProjects: protocol.CommandTypes.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; export const GetCodeFixes: protocol.CommandTypes.GetCodeFixes = "getCodeFixes"; + /* @internal */ export const GetCodeFixesFull: protocol.CommandTypes.GetCodeFixesFull = "getCodeFixes-full"; export const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes = "getSupportedCodeFixes"; } @@ -169,18 +204,134 @@ namespace ts.server { return `Content-Length: ${1 + len}\r\n\r\n${json}${newLine}`; } + /** + * Allows to schedule next step in multistep operation + */ + interface NextStep { + immediate(action: () => void): void; + delay(ms: number, action: () => void): void; + } + + /** + * External capabilities used by multistep operation + */ + interface MultistepOperationHost { + getCurrentRequestId(): number; + sendRequestCompletedEvent(requestId: number): void; + getServerHost(): ServerHost; + isCancellationRequested(): boolean; + executeWithRequestId(requestId: number, action: () => void): void; + logError(error: Error, message: string): void; + } + + /** + * Represents operation that can schedule its next step to be executed later. + * Scheduling is done via instance of NextStep. If on current step subsequent step was not scheduled - operation is assumed to be completed. + */ + class MultistepOperation { + private requestId: number; + private timerHandle: any; + private immediateId: any; + private completed = true; + private readonly next: NextStep; + + constructor(private readonly operationHost: MultistepOperationHost) { + this.next = { + immediate: action => this.immediate(action), + delay: (ms, action) => this.delay(ms, action) + } + } + + public startNew(action: (next: NextStep) => void) { + this.complete(); + this.requestId = this.operationHost.getCurrentRequestId(); + this.completed = false; + this.executeAction(action); + } + + private complete() { + if (!this.completed) { + if (this.requestId) { + this.operationHost.sendRequestCompletedEvent(this.requestId); + } + this.completed = true; + } + this.setTimerHandle(undefined); + this.setImmediateId(undefined); + } + + private immediate(action: () => void) { + const requestId = this.requestId; + Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "immediate: incorrect request id") + this.setImmediateId(this.operationHost.getServerHost().setImmediate(() => { + this.immediateId = undefined; + this.operationHost.executeWithRequestId(requestId, () => this.executeAction(action)); + })); + } + + private delay(ms: number, action: () => void) { + const requestId = this.requestId; + Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "delay: incorrect request id") + this.setTimerHandle(this.operationHost.getServerHost().setTimeout(() => { + this.timerHandle = undefined; + this.operationHost.executeWithRequestId(requestId, () => this.executeAction(action)); + }, ms)); + } + + private executeAction(action: (next: NextStep) => void) { + let stop = false; + try { + if (this.operationHost.isCancellationRequested()) { + stop = true; + } + else { + action(this.next); + } + } + catch (e) { + stop = true; + // ignore cancellation request + if (!(e instanceof OperationCanceledException)) { + this.operationHost.logError(e, `delayed processing of request ${this.requestId}`); + } + } + if (stop || !this.hasPendingWork()) { + this.complete(); + } + } + + private setTimerHandle(timerHandle: any) {; + if (this.timerHandle !== undefined) { + this.operationHost.getServerHost().clearTimeout(this.timerHandle); + } + this.timerHandle = timerHandle; + } + + private setImmediateId(immediateId: number) { + if (this.immediateId !== undefined) { + this.operationHost.getServerHost().clearImmediate(this.immediateId); + } + this.immediateId = immediateId; + } + + private hasPendingWork() { + return !!this.timerHandle || !!this.immediateId; + } + } + export class Session implements EventSender { private readonly gcTimer: GcTimer; protected projectService: ProjectService; - private errorTimer: any; /*NodeJS.Timer | number*/ - private immediateId: any; private changeSeq = 0; + private currentRequestId: number; + private errorCheck: MultistepOperation; + private eventHander: ProjectServiceEventHandler; constructor( private host: ServerHost, - cancellationToken: HostCancellationToken, + private readonly cancellationToken: ServerCancellationToken, useSingleInferredProject: boolean, protected readonly typingsInstaller: ITypingsInstaller, private byteLength: (buf: string, encoding?: string) => number, @@ -193,17 +344,35 @@ namespace ts.server { ? eventHandler || (event => this.defaultEventHandler(event)) : undefined; + const multistepOperationHost: MultistepOperationHost = { + executeWithRequestId: (requestId, action) => this.executeWithRequestId(requestId, action), + getCurrentRequestId: () => this.currentRequestId, + getServerHost: () => this.host, + logError: (err, cmd) => this.logError(err, cmd), + sendRequestCompletedEvent: requestId => this.sendRequestCompletedEvent(requestId), + isCancellationRequested: () => cancellationToken.isCancellationRequested() + } + this.errorCheck = new MultistepOperation(multistepOperationHost); this.projectService = new ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); this.gcTimer = new GcTimer(host, /*delay*/ 7000, logger); } + private sendRequestCompletedEvent(requestId: number): void { + const event: protocol.RequestCompletedEvent = { + seq: 0, + type: "event", + event: "requestCompleted", + body: { request_seq: requestId } + }; + this.send(event); + } + private defaultEventHandler(event: ProjectServiceEvent) { switch (event.eventName) { case ContextEvent: const { project, fileName } = event.data; this.projectService.logger.info(`got context event, updating diagnostics for ${fileName}`); - this.updateErrorCheck([{ fileName, project }], this.changeSeq, - (n) => n === this.changeSeq, 100); + this.errorCheck.startNew(next => this.updateErrorCheck(next, [{ fileName, project }], this.changeSeq, (n) => n === this.changeSeq, 100)); break; case ConfigFileDiagEvent: const { triggerFile, configFileName, diagnostics } = event.data; @@ -260,7 +429,7 @@ namespace ts.server { seq: 0, type: "event", event: eventName, - body: info, + body: info }; this.send(ev); } @@ -318,18 +487,11 @@ namespace ts.server { }, ms); } - private updateErrorCheck(checkList: PendingErrorCheck[], seq: number, - matchSeq: (seq: number) => boolean, ms = 1500, followMs = 200, requireOpen = true) { + private updateErrorCheck(next: NextStep, checkList: PendingErrorCheck[], seq: number, matchSeq: (seq: number) => boolean, ms = 1500, followMs = 200, requireOpen = true) { if (followMs > ms) { followMs = ms; } - if (this.errorTimer) { - this.host.clearTimeout(this.errorTimer); - } - if (this.immediateId) { - this.host.clearImmediate(this.immediateId); - this.immediateId = undefined; - } + let index = 0; const checkOne = () => { if (matchSeq(seq)) { @@ -337,21 +499,18 @@ namespace ts.server { index++; if (checkSpec.project.containsFile(checkSpec.fileName, requireOpen)) { this.syntacticCheck(checkSpec.fileName, checkSpec.project); - this.immediateId = this.host.setImmediate(() => { + next.immediate(() => { this.semanticCheck(checkSpec.fileName, checkSpec.project); - this.immediateId = undefined; if (checkList.length > index) { - this.errorTimer = this.host.setTimeout(checkOne, followMs); - } - else { - this.errorTimer = undefined; + next.delay(followMs, checkOne); } }); } } }; + if ((checkList.length > index) && (matchSeq(seq))) { - this.errorTimer = this.host.setTimeout(checkOne, ms); + next.delay(ms, checkOne); } } @@ -460,18 +619,20 @@ namespace ts.server { private getImplementation(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.FileSpan[] | ImplementationLocation[] { const { file, project } = this.getFileAndProject(args); - const scriptInfo = project.getScriptInfoForNormalizedPath(file); - const position = this.getPosition(args, scriptInfo); + const position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); const implementations = project.getLanguageService().getImplementationAtPosition(file, position); if (!implementations) { return []; } if (simplifiedResult) { - return implementations.map(impl => ({ - file: impl.fileName, - start: scriptInfo.positionToLineOffset(impl.textSpan.start), - end: scriptInfo.positionToLineOffset(ts.textSpanEnd(impl.textSpan)) - })); + return implementations.map(({ fileName, textSpan }) => { + const scriptInfo = project.getScriptInfo(fileName); + return { + file: fileName, + start: scriptInfo.positionToLineOffset(textSpan.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)) + }; + }); } else { return implementations; @@ -1014,7 +1175,8 @@ namespace ts.server { if (project.compileOnSaveEnabled && project.languageServiceEnabled) { result.push({ projectFileName: project.getProjectName(), - fileNames: project.getCompileOnSaveAffectedFileList(info) + fileNames: project.getCompileOnSaveAffectedFileList(info), + projectUsesOutFile: !!project.getCompilerOptions().outFile || !!project.getCompilerOptions().out }); } } @@ -1060,7 +1222,7 @@ namespace ts.server { } } - private getDiagnostics(delay: number, fileNames: string[]) { + private getDiagnostics(next: NextStep, delay: number, fileNames: string[]): void { const checkList = fileNames.reduce((accum: PendingErrorCheck[], uncheckedFileName: string) => { const fileName = toNormalizedPath(uncheckedFileName); const project = this.projectService.getDefaultProjectForFile(fileName, /*refreshInferredProjects*/ true); @@ -1071,7 +1233,7 @@ namespace ts.server { }, []); if (checkList.length > 0) { - this.updateErrorCheck(checkList, this.changeSeq, (n) => n === this.changeSeq, delay); + this.updateErrorCheck(next, checkList, this.changeSeq, (n) => n === this.changeSeq, delay); } } @@ -1308,7 +1470,7 @@ namespace ts.server { : spans; } - getDiagnosticsForProject(delay: number, fileName: string) { + private getDiagnosticsForProject(next: NextStep, delay: number, fileName: string): void { const { fileNames, languageServiceDisabled } = this.getProjectInfoWorker(fileName, /*projectFileName*/ undefined, /*needFileNameList*/ true); if (languageServiceDisabled) { return; @@ -1346,7 +1508,7 @@ namespace ts.server { const checkList = fileNamesInProject.map(fileName => ({ fileName, project })); // Project level error analysis runs on background files too, therefore // doesn't require the file to be opened - this.updateErrorCheck(checkList, this.changeSeq, (n) => n == this.changeSeq, delay, 200, /*requireOpen*/ false); + this.updateErrorCheck(next, checkList, this.changeSeq, (n) => n == this.changeSeq, delay, 200, /*requireOpen*/ false); } } @@ -1366,7 +1528,7 @@ namespace ts.server { return { response, responseRequired: true }; } - private handlers = createMap<(request: protocol.Request) => { response?: any, responseRequired?: boolean }>({ + private handlers = createMapFromTemplate<(request: protocol.Request) => { response?: any, responseRequired?: boolean }>({ [CommandNames.OpenExternalProject]: (request: protocol.OpenExternalProjectRequest) => { this.projectService.openExternalProject(request.arguments, /*suppressRefreshOfInferredProjects*/ false); // TODO: report errors @@ -1523,13 +1685,13 @@ namespace ts.server { [CommandNames.SyntacticDiagnosticsSync]: (request: protocol.SyntacticDiagnosticsSyncRequest) => { return this.requiredResponse(this.getSyntacticDiagnosticsSync(request.arguments)); }, - [CommandNames.Geterr]: (request: protocol.Request) => { - const geterrArgs = request.arguments; - return { response: this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false }; + [CommandNames.Geterr]: (request: protocol.GeterrRequest) => { + this.errorCheck.startNew(next => this.getDiagnostics(next, request.arguments.delay, request.arguments.files)); + return this.notRequired(); }, - [CommandNames.GeterrForProject]: (request: protocol.Request) => { - const { file, delay } = request.arguments; - return { response: this.getDiagnosticsForProject(delay, file), responseRequired: false }; + [CommandNames.GeterrForProject]: (request: protocol.GeterrForProjectRequest) => { + this.errorCheck.startNew(next => this.getDiagnosticsForProject(next, request.arguments.delay, request.arguments.file)); + return this.notRequired(); }, [CommandNames.Change]: (request: protocol.ChangeRequest) => { this.change(request.arguments); @@ -1610,16 +1772,38 @@ namespace ts.server { }); public addProtocolHandler(command: string, handler: (request: protocol.Request) => { response?: any, responseRequired: boolean }) { - if (command in this.handlers) { + if (this.handlers.has(command)) { throw new Error(`Protocol handler already exists for command "${command}"`); } - this.handlers[command] = handler; + this.handlers.set(command, handler); + } + + private setCurrentRequest(requestId: number): void { + Debug.assert(this.currentRequestId === undefined); + this.currentRequestId = requestId; + this.cancellationToken.setRequest(requestId); + } + + private resetCurrentRequest(requestId: number): void { + Debug.assert(this.currentRequestId === requestId); + this.currentRequestId = undefined; + this.cancellationToken.resetRequest(requestId); + } + + public executeWithRequestId(requestId: number, f: () => T) { + try { + this.setCurrentRequest(requestId); + return f(); + } + finally { + this.resetCurrentRequest(requestId); + } } public executeCommand(request: protocol.Request): { response?: any, responseRequired?: boolean } { - const handler = this.handlers[request.command]; + const handler = this.handlers.get(request.command); if (handler) { - return handler(request); + return this.executeWithRequestId(request.seq, () => handler(request)); } else { this.logger.msg(`Unrecognized JSON command: ${JSON.stringify(request)}`, Msg.Err); diff --git a/src/server/shared.ts b/src/server/shared.ts index c56d4098e75..77f66fc5a2d 100644 --- a/src/server/shared.ts +++ b/src/server/shared.ts @@ -1,4 +1,4 @@ -/// +/// namespace ts.server { export const ActionSet: ActionSet = "action::set"; diff --git a/src/server/tsconfig.json b/src/server/tsconfig.json index 85c88679164..b0eb4965ea6 100644 --- a/src/server/tsconfig.json +++ b/src/server/tsconfig.json @@ -1,19 +1,12 @@ { + "extends": "../tsconfig-base", "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": true, "removeComments": true, - "preserveConstEnums": true, - "pretty": true, "outFile": "../../built/local/tsserver.js", - "sourceMap": true, - "stripInternal": true, + "preserveConstEnums": true, "types": [ "node" - ], - "target": "es5", - "noUnusedLocals": true, - "noUnusedParameters": true + ] }, "files": [ "../services/shims.ts", diff --git a/src/server/tsconfig.library.json b/src/server/tsconfig.library.json index 5483cc8ec28..76d700dd291 100644 --- a/src/server/tsconfig.library.json +++ b/src/server/tsconfig.library.json @@ -1,29 +1,30 @@ { "compilerOptions": { "noImplicitAny": true, - "removeComments": true, + "noImplicitThis": true, "preserveConstEnums": true, + "pretty": true, "outFile": "../../built/local/tsserverlibrary.js", "sourceMap": true, "stripInternal": true, - "declaration": true, - "types": [], "target": "es5", "noUnusedLocals": true, - "noUnusedParameters": true + "noUnusedParameters": true, + "declaration": true }, "files": [ - "../services/shims.ts", - "../services/utilities.ts", - "shared.ts", - "utilities.ts", - "scriptVersionCache.ts", - "scriptInfo.ts", - "lshost.ts", - "typingsCache.ts", - "project.ts", "editorServices.ts", - "protocol.d.ts", - "session.ts" + "lsHost.ts", + "project.ts", + "protocol.ts", + "scriptInfo.ts", + "scriptVersionCache.ts", + "session.ts", + "shared.ts", + "types.ts", + "typingsCache.ts", + "utilities.ts", + "../services/shims.ts", + "../services/utilities.ts" ] } diff --git a/src/server/types.d.ts b/src/server/types.ts similarity index 91% rename from src/server/types.d.ts rename to src/server/types.ts index 9f53fa8def1..6edf424cbe6 100644 --- a/src/server/types.d.ts +++ b/src/server/types.ts @@ -9,6 +9,7 @@ declare namespace ts.server { data: any; } + type RequireResult = { module: {}, error: undefined } | { module: undefined, error: {} }; export interface ServerHost extends System { setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; clearTimeout(timeoutId: any): void; @@ -16,6 +17,7 @@ declare namespace ts.server { clearImmediate(timeoutId: any): void; gc?(): void; trace?(s: string): void; + require?(initialPath: string, moduleName: string): RequireResult; } export interface SortedReadonlyArray extends ReadonlyArray { @@ -82,6 +84,7 @@ declare namespace ts.server { readonly installSuccess: boolean; } + /* @internal */ export interface InstallTypingHost extends JsTyping.TypingResolutionHost { writeFile(path: string, content: string): void; createDirectory(path: string): void; diff --git a/src/server/typingsCache.ts b/src/server/typingsCache.ts index 8b03d59003c..9379ae82d0e 100644 --- a/src/server/typingsCache.ts +++ b/src/server/typingsCache.ts @@ -35,17 +35,18 @@ namespace ts.server { let unique = 0; for (const v of arr1) { - if (set[v] !== true) { - set[v] = true; + if (set.get(v) !== true) { + set.set(v, true); unique++; } } for (const v of arr2) { - if (!hasProperty(set, v)) { + const isSet = set.get(v); + if (isSet === undefined) { return false; } - if (set[v] === true) { - set[v] = false; + if (isSet === true) { + set.set(v, false); unique--; } } @@ -83,7 +84,7 @@ namespace ts.server { return emptyArray; } - const entry = this.perProjectCache[project.getProjectName()]; + const entry = this.perProjectCache.get(project.getProjectName()); const result: SortedReadonlyArray = entry ? entry.typings : emptyArray; if (forceRefresh || !entry || @@ -92,13 +93,13 @@ namespace ts.server { unresolvedImportsChanged(unresolvedImports, entry.unresolvedImports)) { // Note: entry is now poisoned since it does not really contain typings for a given combination of compiler options\typings options. // instead it acts as a placeholder to prevent issuing multiple requests - this.perProjectCache[project.getProjectName()] = { + this.perProjectCache.set(project.getProjectName(), { compilerOptions: project.getCompilerOptions(), typeAcquisition, typings: result, unresolvedImports, poisoned: true - }; + }); // something has been changed, issue a request to update typings this.installer.enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports); } @@ -106,21 +107,21 @@ namespace ts.server { } updateTypingsForProject(projectName: string, compilerOptions: CompilerOptions, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, newTypings: string[]) { - this.perProjectCache[projectName] = { + this.perProjectCache.set(projectName, { compilerOptions, typeAcquisition, typings: toSortedReadonlyArray(newTypings), unresolvedImports, poisoned: false - }; + }); } deleteTypingsForProject(projectName: string) { - delete this.perProjectCache[projectName]; + this.perProjectCache.delete(projectName); } onProjectClosed(project: Project) { - delete this.perProjectCache[project.getProjectName()]; + this.perProjectCache.delete(project.getProjectName()); this.installer.onProjectClosed(project); } } diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index 19f794ad57c..ff20e89e2d7 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -46,7 +46,7 @@ namespace ts.server.typingsInstaller { } try { const content = JSON.parse(host.readFile(typesRegistryFilePath)); - return createMap(content.entries); + return createMapFromTemplate(content.entries); } catch (e) { if (log.isEnabled()) { diff --git a/src/server/typingsInstaller/tsconfig.json b/src/server/typingsInstaller/tsconfig.json index c6031b19aae..7bfb6c8b1ed 100644 --- a/src/server/typingsInstaller/tsconfig.json +++ b/src/server/typingsInstaller/tsconfig.json @@ -1,22 +1,14 @@ { + "extends": "../../tsconfig-base", "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": true, "removeComments": true, - "preserveConstEnums": true, - "pretty": true, "outFile": "../../../built/local/typingsInstaller.js", - "sourceMap": true, - "stripInternal": true, "types": [ "node" - ], - "target": "es5", - "noUnusedLocals": true, - "noUnusedParameters": true + ] }, "files": [ - "../types.d.ts", + "../types.ts", "../shared.ts", "typingsInstaller.ts", "nodeTypingsInstaller.ts" diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index 7a09c1f6c21..e889f98789a 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -1,7 +1,7 @@ /// /// /// -/// +/// /// namespace ts.server.typingsInstaller { @@ -112,7 +112,7 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`Closing file watchers for project '${projectName}'`); } - const watchers = this.projectWatchers[projectName]; + const watchers = this.projectWatchers.get(projectName); if (!watchers) { if (this.log.isEnabled()) { this.log.writeLine(`No watchers are registered for project '${projectName}'`); @@ -123,7 +123,7 @@ namespace ts.server.typingsInstaller { w.close(); } - delete this.projectWatchers[projectName]; + this.projectWatchers.delete(projectName); if (this.log.isEnabled()) { this.log.writeLine(`Closing file watchers for project '${projectName}' - done.`); @@ -177,7 +177,7 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`Processing cache location '${cacheLocation}'`); } - if (this.knownCachesSet[cacheLocation]) { + if (this.knownCachesSet.get(cacheLocation)) { if (this.log.isEnabled()) { this.log.writeLine(`Cache location was already processed...`); } @@ -201,10 +201,10 @@ namespace ts.server.typingsInstaller { } const typingFile = typingToFileName(cacheLocation, packageName, this.installTypingHost, this.log); if (!typingFile) { - this.missingTypingsSet[packageName] = true; + this.missingTypingsSet.set(packageName, true); continue; } - const existingTypingFile = this.packageNameToTypingLocation[packageName]; + const existingTypingFile = this.packageNameToTypingLocation.get(packageName); if (existingTypingFile === typingFile) { continue; } @@ -216,14 +216,14 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`Adding entry into typings cache: '${packageName}' => '${typingFile}'`); } - this.packageNameToTypingLocation[packageName] = typingFile; + this.packageNameToTypingLocation.set(packageName, typingFile); } } } if (this.log.isEnabled()) { this.log.writeLine(`Finished processing cache location '${cacheLocation}'`); } - this.knownCachesSet[cacheLocation] = true; + this.knownCachesSet.set(cacheLocation, true); } private filterTypings(typingsToInstall: string[]) { @@ -232,12 +232,12 @@ namespace ts.server.typingsInstaller { } const result: string[] = []; for (const typing of typingsToInstall) { - if (this.missingTypingsSet[typing] || this.packageNameToTypingLocation[typing]) { + if (this.missingTypingsSet.get(typing) || this.packageNameToTypingLocation.get(typing)) { continue; } const validationResult = validatePackageName(typing); if (validationResult === PackageNameValidationResult.Ok) { - if (typing in this.typesRegistry) { + if (this.typesRegistry.has(typing)) { result.push(typing); } else { @@ -248,7 +248,7 @@ namespace ts.server.typingsInstaller { } else { // add typing name to missing set so we won't process it again - this.missingTypingsSet[typing] = true; + this.missingTypingsSet.set(typing, true); if (this.log.isEnabled()) { switch (validationResult) { case PackageNameValidationResult.EmptyName: @@ -295,8 +295,7 @@ namespace ts.server.typingsInstaller { this.log.writeLine(`Installing typings ${JSON.stringify(typingsToInstall)}`); } const filteredTypings = this.filterTypings(typingsToInstall); - const scopedTypings = filteredTypings.map(x => `@types/${x}`); - if (scopedTypings.length === 0) { + if (filteredTypings.length === 0) { if (this.log.isEnabled()) { this.log.writeLine(`All typings are known to be missing or invalid - no need to go any further`); } @@ -316,6 +315,7 @@ namespace ts.server.typingsInstaller { projectName: req.projectName }); + const scopedTypings = filteredTypings.map(typingsName); this.installTypingsAsync(requestId, scopedTypings, cachePath, ok => { try { if (!ok) { @@ -323,7 +323,7 @@ namespace ts.server.typingsInstaller { this.log.writeLine(`install request failed, marking packages as missing to prevent repeated requests: ${JSON.stringify(filteredTypings)}`); } for (const typing of filteredTypings) { - this.missingTypingsSet[typing] = true; + this.missingTypingsSet.set(typing, true); } return; } @@ -336,11 +336,11 @@ namespace ts.server.typingsInstaller { for (const packageName of filteredTypings) { const typingFile = typingToFileName(cachePath, packageName, this.installTypingHost, this.log); if (!typingFile) { - this.missingTypingsSet[packageName] = true; + this.missingTypingsSet.set(packageName, true); continue; } - if (!this.packageNameToTypingLocation[packageName]) { - this.packageNameToTypingLocation[packageName] = typingFile; + if (!this.packageNameToTypingLocation.has(packageName)) { + this.packageNameToTypingLocation.set(packageName, typingFile); } installedTypingFiles.push(typingFile); } @@ -395,7 +395,7 @@ namespace ts.server.typingsInstaller { }, /*pollingInterval*/ 2000); watchers.push(w); } - this.projectWatchers[projectName] = watchers; + this.projectWatchers.set(projectName, watchers); } private createSetTypings(request: DiscoverTypings, typings: string[]): SetTypings { @@ -429,4 +429,10 @@ namespace ts.server.typingsInstaller { protected abstract installWorker(requestId: number, args: string[], cwd: string, onRequestCompleted: RequestCompletedAction): void; protected abstract sendResponse(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes): void; } + + /* @internal */ + export function typingsName(packageName: string): string { + return `@types/${packageName}@ts${versionMajorMinor}`; + } + const versionMajorMinor = version.split(".").slice(0, 2).join("."); } \ No newline at end of file diff --git a/src/server/utilities.ts b/src/server/utilities.ts index d0790b93dba..af1f8e9826f 100644 --- a/src/server/utilities.ts +++ b/src/server/utilities.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts.server { @@ -95,7 +95,7 @@ namespace ts.server { }; } - export function mergeMaps(target: MapLike, source: MapLike ): void { + export function mergeMapLikes(target: MapLike, source: MapLike ): void { for (const key in source) { if (hasProperty(source, key)) { target[key] = source[key]; @@ -145,20 +145,20 @@ namespace ts.server { export function createNormalizedPathMap(): NormalizedPathMap { /* tslint:disable:no-null-keyword */ - const map: Map = Object.create(null); + const map = createMap(); /* tslint:enable:no-null-keyword */ return { get(path) { - return map[path]; + return map.get(path); }, set(path, value) { - map[path] = value; + map.set(path, value); }, contains(path) { - return hasProperty(map, path); + return map.has(path); }, remove(path) { - delete map[path]; + map.delete(path); } }; } @@ -198,16 +198,17 @@ namespace ts.server { } public schedule(operationId: string, delay: number, cb: () => void) { - if (hasProperty(this.pendingTimeouts, operationId)) { + const pendingTimeout = this.pendingTimeouts.get(operationId); + if (pendingTimeout) { // another operation was already scheduled for this id - cancel it - this.host.clearTimeout(this.pendingTimeouts[operationId]); + this.host.clearTimeout(pendingTimeout); } // schedule new operation, pass arguments - this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); + this.pendingTimeouts.set(operationId, this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb)); } private static run(self: ThrottledOperations, operationId: string, cb: () => void) { - delete self.pendingTimeouts[operationId]; + self.pendingTimeouts.delete(operationId); cb(); } } diff --git a/src/server/watchGuard/tsconfig.json b/src/server/watchGuard/tsconfig.json new file mode 100644 index 00000000000..ef9b0ab0603 --- /dev/null +++ b/src/server/watchGuard/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig-base", + "compilerOptions": { + "removeComments": true, + "outFile": "../../../built/local/watchGuard.js" + }, + "files": [ + "watchGuard.ts" + ] +} \ No newline at end of file diff --git a/src/server/watchGuard/watchGuard.ts b/src/server/watchGuard/watchGuard.ts new file mode 100644 index 00000000000..7a0307a9120 --- /dev/null +++ b/src/server/watchGuard/watchGuard.ts @@ -0,0 +1,19 @@ +/// + +if (process.argv.length < 3) { + process.exit(1); +} +const directoryName = process.argv[2]; +const fs: { watch(directoryName: string, options: any, callback: () => {}): any } = require("fs"); +// main reason why we need separate process to check if it is safe to watch some path +// is to guard against crashes that cannot be intercepted with protected blocks and +// code in tsserver already can handle normal cases, like non-existing folders. +// This means that here we treat any result (success or exception) from fs.watch as success since it does not tear down the process. +// The only case that should be considered as failure - when watchGuard process crashes. +try { + const watcher = fs.watch(directoryName, { recursive: true }, () => ({})) + watcher.close(); +} +catch (_e) { +} +process.exit(0); \ No newline at end of file diff --git a/src/services/classifier.ts b/src/services/classifier.ts index 4f553924b99..c15b65b0c39 100644 --- a/src/services/classifier.ts +++ b/src/services/classifier.ts @@ -557,7 +557,7 @@ namespace ts { // 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]) { + if (classifiableNames.get(identifier.text)) { const symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { const type = classifySymbol(symbol, getMeaningFromLocation(node)); diff --git a/src/services/codeFixProvider.ts b/src/services/codeFixProvider.ts index e4489fc2dca..10d0b8eef34 100644 --- a/src/services/codeFixProvider.ts +++ b/src/services/codeFixProvider.ts @@ -16,7 +16,7 @@ namespace ts { } export namespace codefix { - const codeFixes = createMap(); + const codeFixes: CodeFix[][] = []; export function registerCodeFix(action: CodeFix) { forEach(action.errorCodes, error => { diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts new file mode 100644 index 00000000000..6ae2ba3f51c --- /dev/null +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -0,0 +1,67 @@ +/* @internal */ +namespace ts.codefix { + registerCodeFix({ + errorCodes: [Diagnostics.Property_0_does_not_exist_on_type_1.code], + getCodeActions: getActionsForAddMissingMember + }); + + function getActionsForAddMissingMember(context: CodeFixContext): CodeAction[] | undefined { + + const sourceFile = context.sourceFile; + const start = context.span.start; + // This is the identifier of the missing property. eg: + // this.missing = 1; + // ^^^^^^^ + const token = getTokenAtPosition(sourceFile, start); + + if (token.kind != SyntaxKind.Identifier) { + return undefined; + } + + const classDeclaration = getContainingClass(token); + if (!classDeclaration) { + return undefined; + } + + if (!(token.parent && token.parent.kind === SyntaxKind.PropertyAccessExpression)) { + return undefined; + } + + if ((token.parent as PropertyAccessExpression).expression.kind !== SyntaxKind.ThisKeyword) { + return undefined; + } + + let typeString = "any"; + + if (token.parent.parent.kind === SyntaxKind.BinaryExpression) { + const binaryExpression = token.parent.parent as BinaryExpression; + + const checker = context.program.getTypeChecker(); + const widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(binaryExpression.right))); + typeString = checker.typeToString(widenedType); + } + + const startPos = classDeclaration.members.pos; + + return [{ + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: `${token.getFullText(sourceFile)}: ${typeString};` + }] + }] + }, + { + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_index_signature_for_missing_property_0), [token.getText()]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: `[name: string]: ${typeString};` + }] + }] + }]; + } +} \ No newline at end of file diff --git a/src/services/codefixes/fixForgottenThisPropertyAccess.ts b/src/services/codefixes/fixForgottenThisPropertyAccess.ts new file mode 100644 index 00000000000..c9d59dd8337 --- /dev/null +++ b/src/services/codefixes/fixForgottenThisPropertyAccess.ts @@ -0,0 +1,16 @@ +/* @internal */ +namespace ts.codefix { + registerCodeFix({ + errorCodes: [Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code], + getCodeActions: (context: CodeFixContext) => { + const sourceFile = context.sourceFile; + const token = getTokenAtPosition(sourceFile, context.span.start); + const start = token.getStart(sourceFile); + + return [{ + description: getLocaleSpecificMessage(Diagnostics.Add_this_to_unresolved_variable), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "this.", span: { start, length: 0 } }] }] + }]; + } + }); +} \ No newline at end of file diff --git a/src/services/codefixes/fixes.ts b/src/services/codefixes/fixes.ts index 10d6fa50158..76be34c67cd 100644 --- a/src/services/codefixes/fixes.ts +++ b/src/services/codefixes/fixes.ts @@ -1,9 +1,10 @@ /// +/// /// /// /// /// +/// /// /// /// - diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index d539ef0d68b..3eab994f84c 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -9,7 +9,7 @@ namespace ts.codefix { */ export function getMissingMembersInsertion(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: Symbol[], checker: TypeChecker, newlineChar: string): string { const classMembers = classDeclaration.symbol.members; - const missingMembers = possiblyMissingSymbols.filter(symbol => !(symbol.getName() in classMembers)); + const missingMembers = possiblyMissingSymbols.filter(symbol => !classMembers.has(symbol.getName())); let insertion = ""; @@ -32,7 +32,7 @@ namespace ts.codefix { const declaration = declarations[0] as Declaration; const name = declaration.name ? declaration.name.getText() : undefined; - const visibility = getVisibilityPrefix(getModifierFlags(declaration)); + const visibility = getVisibilityPrefixWithSpace(getModifierFlags(declaration)); switch (declaration.kind) { case SyntaxKind.GetAccessor: @@ -58,7 +58,7 @@ namespace ts.codefix { if (declarations.length === 1) { Debug.assert(signatures.length === 1); const sigString = checker.signatureToString(signatures[0], enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); - return `${visibility}${name}${sigString}${getMethodBodyStub(newlineChar)}`; + return getStubbedMethod(visibility, name, sigString, newlineChar); } let result = ""; @@ -78,7 +78,7 @@ namespace ts.codefix { bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); } const sigString = checker.signatureToString(bodySig, enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); - result += `${visibility}${name}${sigString}${getMethodBodyStub(newlineChar)}`; + result += getStubbedMethod(visibility, name, sigString, newlineChar); return result; default: @@ -138,11 +138,15 @@ namespace ts.codefix { } } - function getMethodBodyStub(newLineChar: string) { - return ` {${newLineChar}throw new Error('Method not implemented.');${newLineChar}}${newLineChar}`; + export function getStubbedMethod(visibility: string, name: string, sigString = "()", newlineChar: string): string { + return `${visibility}${name}${sigString}${getMethodBodyStub(newlineChar)}`; } - function getVisibilityPrefix(flags: ModifierFlags): string { + function getMethodBodyStub(newlineChar: string) { + return ` {${newlineChar}throw new Error('Method not implemented.');${newlineChar}}${newlineChar}`; + } + + function getVisibilityPrefixWithSpace(flags: ModifierFlags): string { if (flags & ModifierFlags.Public) { return "public "; } diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 3dc33e39897..1f1b499d03b 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -14,20 +14,21 @@ namespace ts.codefix { } class ImportCodeActionMap { - private symbolIdToActionMap = createMap(); + private symbolIdToActionMap: ImportCodeAction[][] = []; addAction(symbolId: number, newAction: ImportCodeAction) { if (!newAction) { return; } - if (!this.symbolIdToActionMap[symbolId]) { + const actions = this.symbolIdToActionMap[symbolId]; + if (!actions) { this.symbolIdToActionMap[symbolId] = [newAction]; return; } if (newAction.kind === "CodeChange") { - this.symbolIdToActionMap[symbolId].push(newAction); + actions.push(newAction); return; } @@ -73,8 +74,8 @@ namespace ts.codefix { getAllActions() { let result: ImportCodeAction[] = []; - for (const symbolId in this.symbolIdToActionMap) { - result = concatenate(result, this.symbolIdToActionMap[symbolId]); + for (const key in this.symbolIdToActionMap) { + result = concatenate(result, this.symbolIdToActionMap[key]) } return result; } @@ -114,6 +115,7 @@ namespace ts.codefix { registerCodeFix({ errorCodes: [ Diagnostics.Cannot_find_name_0.code, + Diagnostics.Cannot_find_namespace_0.code, Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code ], getCodeActions: (context: CodeFixContext) => { @@ -127,7 +129,7 @@ namespace ts.codefix { const symbolIdActionMap = new ImportCodeActionMap(); // this is a module id -> module import declaration map - const cachedImportDeclarations = createMap<(ImportDeclaration | ImportEqualsDeclaration)[]>(); + const cachedImportDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[][] = []; let cachedNewImportInsertPosition: number; const currentTokenMeaning = getMeaningFromLocation(token); @@ -170,8 +172,9 @@ namespace ts.codefix { function getImportDeclarations(moduleSymbol: Symbol) { const moduleSymbolId = getUniqueSymbolId(moduleSymbol); - if (cachedImportDeclarations[moduleSymbolId]) { - return cachedImportDeclarations[moduleSymbolId]; + const cached = cachedImportDeclarations[moduleSymbolId]; + if (cached) { + return cached; } const existingDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[] = []; @@ -414,16 +417,16 @@ namespace ts.codefix { ); function getModuleSpecifierForNewImport() { - const fileName = sourceFile.path; - const moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().path; + const fileName = sourceFile.fileName; + const moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; const sourceDirectory = getDirectoryPath(fileName); const options = context.program.getCompilerOptions(); return tryGetModuleNameFromAmbientModule() || - tryGetModuleNameFromBaseUrl() || - tryGetModuleNameFromRootDirs() || tryGetModuleNameFromTypeRoots() || tryGetModuleNameAsNodeModule() || + tryGetModuleNameFromBaseUrl() || + tryGetModuleNameFromRootDirs() || removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule(): string { @@ -437,12 +440,12 @@ namespace ts.codefix { return undefined; } - const normalizedBaseUrl = toPath(options.baseUrl, getDirectoryPath(options.baseUrl), getCanonicalFileName); - let relativeName = tryRemoveParentDirectoryName(moduleFileName, normalizedBaseUrl); + let relativeName = getRelativePathIfInDirectory(moduleFileName, options.baseUrl); if (!relativeName) { return undefined; } + const relativeNameWithIndex = removeFileExtension(relativeName); relativeName = removeExtensionAndIndexPostFix(relativeName); if (options.paths) { @@ -462,7 +465,7 @@ namespace ts.codefix { return key.replace("\*", matchedStar); } } - else if (pattern === relativeName) { + else if (pattern === relativeName || pattern === relativeNameWithIndex) { return key; } } @@ -474,9 +477,8 @@ namespace ts.codefix { function tryGetModuleNameFromRootDirs() { if (options.rootDirs) { - const normalizedRootDirs = map(options.rootDirs, rootDir => toPath(rootDir, /*basePath*/ undefined, getCanonicalFileName)); - const normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, normalizedRootDirs); - const normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, normalizedRootDirs); + const normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, options.rootDirs); + const normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, options.rootDirs); if (normalizedTargetPath !== undefined) { const relativePath = normalizedSourcePath !== undefined ? getRelativePath(normalizedTargetPath, normalizedSourcePath) : normalizedTargetPath; return removeFileExtension(relativePath); @@ -543,9 +545,9 @@ namespace ts.codefix { } } - function getPathRelativeToRootDirs(path: Path, rootDirs: Path[]) { + function getPathRelativeToRootDirs(path: string, rootDirs: string[]) { for (const rootDir of rootDirs) { - const relativeName = tryRemoveParentDirectoryName(path, rootDir); + const relativeName = getRelativePathIfInDirectory(path, rootDir); if (relativeName !== undefined) { return relativeName; } @@ -561,20 +563,15 @@ namespace ts.codefix { return fileName; } + function getRelativePathIfInDirectory(path: string, directoryPath: string) { + const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); + return isRootedDiskPath(relativePath) || startsWith(relativePath, "..") ? undefined : relativePath; + } + function getRelativePath(path: string, directoryPath: string) { const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); return moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath; } - - function tryRemoveParentDirectoryName(path: Path, parentDirectory: Path) { - const index = path.indexOf(parentDirectory); - if (index === 0) { - return endsWith(parentDirectory, directorySeparator) - ? path.substring(parentDirectory.length) - : path.substring(parentDirectory.length + 1); - } - return undefined; - } } } diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index 8e14bdcb73e..a45a3c26dba 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -25,7 +25,7 @@ namespace ts.codefix { const forStatement = token.parent.parent.parent; const forInitializer = forStatement.initializer; if (forInitializer.declarations.length === 1) { - return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); + return createCodeFixToRemoveNode(forInitializer); } else { return removeSingleItem(forInitializer.declarations, token); @@ -35,7 +35,7 @@ namespace ts.codefix { const forOfStatement = token.parent.parent.parent; if (forOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList) { const forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); + return createCodeFix("{}", forOfInitializer.declarations[0].getStart(), forOfInitializer.declarations[0].getWidth()); } break; @@ -47,12 +47,12 @@ namespace ts.codefix { case SyntaxKind.CatchClause: const catchClause = token.parent.parent; const parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFix("", parameter.pos, parameter.end - parameter.pos); + return createCodeFixToRemoveNode(parameter); default: const variableStatement = token.parent.parent.parent; if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); + return createCodeFixToRemoveNode(variableStatement); } else { const declarations = variableStatement.declarationList.declarations; @@ -72,7 +72,7 @@ namespace ts.codefix { case ts.SyntaxKind.Parameter: const functionDeclaration = token.parent.parent; if (functionDeclaration.parameters.length === 1) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + return createCodeFixToRemoveNode(token.parent); } else { return removeSingleItem(functionDeclaration.parameters, token); @@ -81,36 +81,43 @@ namespace ts.codefix { // handle case where 'import a = A;' case SyntaxKind.ImportEqualsDeclaration: const importEquals = findImportDeclaration(token); - return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); + return createCodeFixToRemoveNode(importEquals); case SyntaxKind.ImportSpecifier: const namedImports = token.parent.parent; if (namedImports.elements.length === 1) { // Only 1 import and it is unused. So the entire declaration should be removed. const importSpec = findImportDeclaration(token); - return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); + return createCodeFixToRemoveNode(importSpec); } else { return removeSingleItem(namedImports.elements, token); } - // handle case where "import d, * as ns from './file'" + // handle case where "import d, * as ns from './file'" // or "'import {a, b as ns} from './file'" - case SyntaxKind.ImportClause: // this covers both 'import |d|' and 'import |d,| *' + case SyntaxKind.ImportClause: // this covers both 'import |d|' and 'import |d,| *' const importClause = token.parent; if (!importClause.namedBindings) { // |import d from './file'| or |import * as ns from './file'| const importDecl = findImportDeclaration(importClause); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + return createCodeFixToRemoveNode(importDecl); } - else { // import |d,| * as ns from './file' - return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); + else { + // import |d,| * as ns from './file' + const start = importClause.name.getStart(); + let end = findFirstNonSpaceCharPosStarting(importClause.name.end); + if (sourceFile.text.charCodeAt(end) === CharacterCodes.comma) { + end = findFirstNonSpaceCharPosStarting(end + 1); + } + + return createCodeFix("", start, end - start); } case SyntaxKind.NamespaceImport: const namespaceImport = token.parent; if (namespaceImport.name == token && !(namespaceImport.parent).name) { const importDecl = findImportDeclaration(namespaceImport); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + return createCodeFixToRemoveNode(importDecl); } else { const start = (namespaceImport.parent).name.end; @@ -120,16 +127,14 @@ namespace ts.codefix { break; case SyntaxKind.PropertyDeclaration: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - case SyntaxKind.NamespaceImport: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + return createCodeFixToRemoveNode(token.parent); } if (isDeclarationName(token)) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + return createCodeFixToRemoveNode(token.parent); } else if (isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); + return createCodeFixToRemoveNode(token.parent.parent); } else { return undefined; @@ -144,9 +149,33 @@ namespace ts.codefix { return importDecl; } + function createCodeFixToRemoveNode(node: Node) { + let end = node.getEnd(); + const endCharCode = sourceFile.text.charCodeAt(end); + const afterEndCharCode = sourceFile.text.charCodeAt(end + 1); + if (isLineBreak(endCharCode)) { + end += 1; + } + // in the case of CR LF, you could have two consecutive new line characters for one new line. + // this needs to be differenciated from two LF LF chars that actually mean two new lines. + if (isLineBreak(afterEndCharCode) && endCharCode !== afterEndCharCode) { + end += 1; + } + + const start = node.getStart(); + return createCodeFix("", start, end - start); + } + + function findFirstNonSpaceCharPosStarting(start: number) { + while (isWhiteSpace(sourceFile.text.charCodeAt(start))) { + start += 1; + } + return start; + } + function createCodeFix(newText: string, start: number, length: number): CodeAction[] { return [{ - description: getLocaleSpecificMessage(Diagnostics.Remove_unused_identifiers), + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText, span: { start, length } }] diff --git a/src/services/completions.ts b/src/services/completions.ts index f0daa696474..1bf57d33fdc 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1,14 +1,14 @@ -/// - /* @internal */ namespace ts.Completions { - export function getCompletionsAtPosition(host: LanguageServiceHost, typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number): CompletionInfo { + export type Log = (message: string) => void; + + export function getCompletionsAtPosition(host: LanguageServiceHost, typeChecker: TypeChecker, log: Log, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number): CompletionInfo | undefined { if (isInReferenceComment(sourceFile, position)) { - return getTripleSlashReferenceCompletion(sourceFile, position); + return getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); } if (isInString(sourceFile, position)) { - return getStringLiteralCompletionEntries(sourceFile, position); + return getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log); } const completionData = getCompletionData(typeChecker, log, sourceFile, position); @@ -26,8 +26,8 @@ namespace ts.Completions { const entries: CompletionEntry[] = []; if (isSourceFileJavaScript(sourceFile)) { - const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true); - addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); + const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); + addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target)); } else { if (!symbols || symbols.length === 0) { @@ -50,7 +50,7 @@ namespace ts.Completions { } } - getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true); + getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); } // Add keywords if this is not a member completion list @@ -59,694 +59,701 @@ namespace ts.Completions { } return { isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries }; + } - function getJavaScriptCompletionEntries(sourceFile: SourceFile, position: number, uniqueNames: Map): CompletionEntry[] { - const entries: CompletionEntry[] = []; + function getJavaScriptCompletionEntries(sourceFile: SourceFile, position: number, uniqueNames: Map, target: ScriptTarget): CompletionEntry[] { + const entries: CompletionEntry[] = []; - const nameTable = getNameTable(sourceFile); - for (const name in nameTable) { - // Skip identifiers produced only from the current location - if (nameTable[name] === position) { - continue; + const nameTable = getNameTable(sourceFile); + nameTable.forEach((pos, name) => { + // Skip identifiers produced only from the current location + if (pos === position) { + return; + } + + if (!uniqueNames.get(name)) { + uniqueNames.set(name, name); + const displayName = getCompletionEntryDisplayName(unescapeIdentifier(name), target, /*performCharacterChecks*/ true); + if (displayName) { + const entry = { + name: displayName, + kind: ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } + } + }); - if (!uniqueNames[name]) { - uniqueNames[name] = name; - const displayName = getCompletionEntryDisplayName(unescapeIdentifier(name), compilerOptions.target, /*performCharacterChecks*/ true); - if (displayName) { - const entry = { - name: displayName, - kind: ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; + return entries; + } + + function createCompletionEntry(symbol: Symbol, location: Node, performCharacterChecks: boolean, typeChecker: TypeChecker, target: ScriptTarget): CompletionEntry { + // 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) + const displayName = getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, target, performCharacterChecks, 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: SymbolDisplay.getSymbolKind(typeChecker, symbol, location), + kindModifiers: SymbolDisplay.getSymbolModifiers(symbol), + sortText: "0", + }; + } + + function getCompletionEntriesFromSymbols(symbols: Symbol[], entries: Push, location: Node, performCharacterChecks: boolean, typeChecker: TypeChecker, target: ScriptTarget, log: Log): Map { + const start = timestamp(); + const uniqueNames = createMap(); + if (symbols) { + for (const symbol of symbols) { + const entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target); + if (entry) { + const id = escapeIdentifier(entry.name); + if (!uniqueNames.get(id)) { entries.push(entry); + uniqueNames.set(id, id); } } } - - return entries; } - function createCompletionEntry(symbol: Symbol, location: Node, performCharacterChecks: boolean): CompletionEntry { - // 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) - const displayName = getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, compilerOptions.target, performCharacterChecks, location); - if (!displayName) { - return undefined; + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (timestamp() - start)); + return uniqueNames; + } + + function getStringLiteralCompletionEntries(sourceFile: SourceFile, position: number, typeChecker: TypeChecker, compilerOptions: CompilerOptions, host: LanguageServiceHost, log: Log): CompletionInfo | undefined { + const node = findPrecedingToken(position, sourceFile); + if (!node || node.kind !== SyntaxKind.StringLiteral) { + return undefined; + } + + if (node.parent.kind === SyntaxKind.PropertyAssignment && + node.parent.parent.kind === SyntaxKind.ObjectLiteralExpression && + (node.parent).name === node) { + // Get quoted name of properties of the object literal expression + // i.e. interface ConfigFiles { + // 'jspm:dev': string + // } + // let files: ConfigFiles = { + // '/*completion position*/' + // } + // + // function foo(c: ConfigFiles) {} + // foo({ + // '/*completion position*/' + // }); + return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent, typeChecker, compilerOptions.target, log); + } + else if (isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { + // Get all names of properties on the expression + // i.e. interface A { + // 'prop1': string + // } + // let a: A; + // a['/*completion position*/'] + return getStringLiteralCompletionEntriesFromElementAccess(node.parent, typeChecker, compilerOptions.target, log); + } + else if (node.parent.kind === SyntaxKind.ImportDeclaration || isExpressionOfExternalModuleImportEqualsDeclaration(node) || isRequireCall(node.parent, false)) { + // Get all known external module names or complete a path to a module + // i.e. import * as ns from "/*completion position*/"; + // import x = require("/*completion position*/"); + // var y = require("/*completion position*/"); + return getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker); + } + else if (isEqualityExpression(node.parent)) { + // Get completions from the type of the other operand + // i.e. switch (a) { + // case '/*completion position*/' + // } + return getStringLiteralCompletionEntriesFromType(typeChecker.getTypeAtLocation(node.parent.left === node ? node.parent.right : node.parent.left), typeChecker); + } + else if (isCaseOrDefaultClause(node.parent)) { + // Get completions from the type of the switch expression + // i.e. x === '/*completion position' + return getStringLiteralCompletionEntriesFromType(typeChecker.getTypeAtLocation((node.parent.parent.parent).expression), typeChecker); + } + else { + const argumentInfo = SignatureHelp.getImmediatelyContainingArgumentInfo(node, position, sourceFile); + if (argumentInfo) { + // Get string literal completions from specialized signatures of the target + // i.e. declare function f(a: 'A'); + // f("/*completion position*/") + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, typeChecker); } - // 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. + // Get completion for string literal from string literal type + // i.e. var x: "hi" | "hello" = "/*completion position*/" + return getStringLiteralCompletionEntriesFromType(typeChecker.getContextualType(node), typeChecker); + } + } - // Use a 'sortText' of 0' so that all symbol completion entries come before any other - // entries (like JavaScript identifier entries). - return { - name: displayName, - kind: SymbolDisplay.getSymbolKind(typeChecker, symbol, location), - kindModifiers: SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0", - }; + function getStringLiteralCompletionEntriesFromPropertyAssignment(element: ObjectLiteralElement, typeChecker: TypeChecker, target: ScriptTarget, log: Log): CompletionInfo | undefined { + const type = typeChecker.getContextualType((element.parent)); + const entries: CompletionEntry[] = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries }; + } + } + } + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo, typeChecker: TypeChecker): CompletionInfo | undefined { + const candidates: Signature[] = []; + const entries: CompletionEntry[] = []; + + typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); + + for (const candidate of candidates) { + addStringLiteralCompletionsFromType(typeChecker.getParameterType(candidate, argumentInfo.argumentIndex), entries, typeChecker); } - function getCompletionEntriesFromSymbols(symbols: Symbol[], entries: CompletionEntry[], location: Node, performCharacterChecks: boolean): Map { - const start = timestamp(); - const uniqueNames = createMap(); - if (symbols) { - for (const symbol of symbols) { - const entry = createCompletionEntry(symbol, location, performCharacterChecks); - if (entry) { - const id = escapeIdentifier(entry.name); - if (!uniqueNames[id]) { - entries.push(entry); - uniqueNames[id] = id; + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries }; + } + + return undefined; + } + + function getStringLiteralCompletionEntriesFromElementAccess(node: ElementAccessExpression, typeChecker: TypeChecker, target: ScriptTarget, log: Log): CompletionInfo | undefined { + const type = typeChecker.getTypeAtLocation(node.expression); + const entries: CompletionEntry[] = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/false, typeChecker, target, log); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries }; + } + } + return undefined; + } + + function getStringLiteralCompletionEntriesFromType(type: Type, typeChecker: TypeChecker): CompletionInfo | undefined { + if (type) { + const entries: CompletionEntry[] = []; + addStringLiteralCompletionsFromType(type, entries, typeChecker); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries }; + } + } + return undefined; + } + + function addStringLiteralCompletionsFromType(type: Type, result: Push, typeChecker: TypeChecker): void { + if (type && type.flags & TypeFlags.TypeParameter) { + type = typeChecker.getApparentType(type); + } + if (!type) { + return; + } + if (type.flags & TypeFlags.Union) { + for (const t of (type).types) { + addStringLiteralCompletionsFromType(t, result, typeChecker); + } + } + else if (type.flags & TypeFlags.StringLiteral) { + result.push({ + name: (type).text, + kindModifiers: ScriptElementKindModifier.none, + kind: ScriptElementKind.variableElement, + sortText: "0" + }); + } + } + + function getStringLiteralCompletionEntriesFromModuleNames(node: StringLiteral, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker): CompletionInfo { + const literalValue = normalizeSlashes(node.text); + + const scriptPath = node.getSourceFile().path; + const scriptDirectory = getDirectoryPath(scriptPath); + + const span = getDirectoryFragmentTextSpan((node).text, node.getStart() + 1); + let entries: CompletionEntry[]; + if (isPathRelativeToScript(literalValue) || isRootedDiskPath(literalValue)) { + const extensions = getSupportedExtensions(compilerOptions); + if (compilerOptions.rootDirs) { + entries = getCompletionEntriesForDirectoryFragmentWithRootDirs( + compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, /*includeExtensions*/false, span, compilerOptions, host, scriptPath); + } + else { + entries = getCompletionEntriesForDirectoryFragment( + literalValue, scriptDirectory, extensions, /*includeExtensions*/false, span, host, scriptPath); + } + } + else { + // Check for node modules + entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span, compilerOptions, host, typeChecker); + } + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries + }; + } + + /** + * Takes a script path and returns paths for all potential folders that could be merged with its + * containing folder via the "rootDirs" compiler option + */ + function getBaseDirectoriesFromRootDirs(rootDirs: string[], basePath: string, scriptPath: string, ignoreCase: boolean): string[] { + // Make all paths absolute/normalized if they are not already + rootDirs = map(rootDirs, rootDirectory => normalizePath(isRootedDiskPath(rootDirectory) ? rootDirectory : combinePaths(basePath, rootDirectory))); + + // Determine the path to the directory containing the script relative to the root directory it is contained within + let relativeDirectory: string; + for (const rootDirectory of rootDirs) { + if (containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { + relativeDirectory = scriptPath.substr(rootDirectory.length); + break; + } + } + + // Now find a path for each potential directory that is to be merged with the one containing the script + return deduplicate(map(rootDirs, rootDirectory => combinePaths(rootDirectory, relativeDirectory))); + } + + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[], fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, compilerOptions: CompilerOptions, host: LanguageServiceHost, exclude?: string): CompletionEntry[] { + const basePath = compilerOptions.project || host.getCurrentDirectory(); + const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + const baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); + + const result: CompletionEntry[] = []; + + for (const baseDirectory of baseDirectories) { + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, host, exclude, result); + } + + return result; + } + + /** + * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. + */ + function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, host: LanguageServiceHost, exclude?: string, result: CompletionEntry[] = []): CompletionEntry[] { + if (fragment === undefined) { + fragment = ""; + } + + fragment = normalizeSlashes(fragment); + + /** + * Remove the basename from the path. Note that we don't use the basename to filter completions; + * the client is responsible for refining completions. + */ + fragment = getDirectoryPath(fragment); + + if (fragment === "") { + fragment = "." + directorySeparator; + } + + fragment = ensureTrailingDirectorySeparator(fragment); + + const absolutePath = normalizeAndPreserveTrailingSlash(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment)); + const baseDirectory = getDirectoryPath(absolutePath); + const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + + if (tryDirectoryExists(host, baseDirectory)) { + // Enumerate the available files if possible + const files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/undefined, /*include*/["./*"]); + + if (files) { + /** + * Multiple file entries might map to the same truncated name once we remove extensions + * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: + * + * both foo.ts and foo.tsx become foo + */ + const foundFiles = createMap(); + for (let filePath of files) { + filePath = normalizePath(filePath); + if (exclude && comparePaths(filePath, exclude, scriptPath, ignoreCase) === Comparison.EqualTo) { + continue; + } + + const foundFileName = includeExtensions ? getBaseFileName(filePath) : removeFileExtension(getBaseFileName(filePath)); + + if (!foundFiles.get(foundFileName)) { + foundFiles.set(foundFileName, true); + } + } + + forEachKey(foundFiles, foundFile => { + result.push(createCompletionEntryForModule(foundFile, ScriptElementKind.scriptElement, span)); + }); + } + + // If possible, get folder completion as well + const directories = tryGetDirectories(host, baseDirectory); + + if (directories) { + for (const directory of directories) { + const directoryName = getBaseFileName(normalizePath(directory)); + + result.push(createCompletionEntryForModule(directoryName, ScriptElementKind.directory, span)); + } + } + } + + return result; + } + + /** + * Check all of the declared modules and those in node modules. Possible sources of modules: + * Modules that are found by the type checker + * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) + * Modules from node_modules (i.e. those listed in package.json) + * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions + */ + function getCompletionEntriesForNonRelativeModules(fragment: string, scriptPath: string, span: TextSpan, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker): CompletionEntry[] { + const { baseUrl, paths } = compilerOptions; + + let result: CompletionEntry[]; + + if (baseUrl) { + const fileExtensions = getSupportedExtensions(compilerOptions); + const projectDir = compilerOptions.project || host.getCurrentDirectory(); + const absolute = isRootedDiskPath(baseUrl) ? baseUrl : combinePaths(projectDir, baseUrl); + result = getCompletionEntriesForDirectoryFragment(fragment, normalizePath(absolute), fileExtensions, /*includeExtensions*/false, span, host); + + if (paths) { + for (const path in paths) { + if (paths.hasOwnProperty(path)) { + if (path === "*") { + if (paths[path]) { + for (const pattern of paths[path]) { + for (const match of getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host)) { + result.push(createCompletionEntryForModule(match, ScriptElementKind.externalModuleName, span)); + } + } + } + } + else if (startsWith(path, fragment)) { + const entry = paths[path] && paths[path].length === 1 && paths[path][0]; + if (entry) { + result.push(createCompletionEntryForModule(path, ScriptElementKind.externalModuleName, span)); + } } } } } - - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (timestamp() - start)); - return uniqueNames; + } + else { + result = []; } - function getStringLiteralCompletionEntries(sourceFile: SourceFile, position: number) { - const node = findPrecedingToken(position, sourceFile); - if (!node || node.kind !== SyntaxKind.StringLiteral) { - return undefined; - } + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); - if (node.parent.kind === SyntaxKind.PropertyAssignment && - node.parent.parent.kind === SyntaxKind.ObjectLiteralExpression && - (node.parent).name === node) { - // Get quoted name of properties of the object literal expression - // i.e. interface ConfigFiles { - // 'jspm:dev': string - // } - // let files: ConfigFiles = { - // '/*completion position*/' - // } - // - // function foo(c: ConfigFiles) {} - // foo({ - // '/*completion position*/' - // }); - return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); + for (const moduleName of enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host)) { + result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); + } + + return result; + } + + function getModulesForPathsPattern(fragment: string, baseUrl: string, pattern: string, fileExtensions: string[], host: LanguageServiceHost): string[] { + if (host.readDirectory) { + const parsed = hasZeroOrOneAsteriskCharacter(pattern) ? tryParsePattern(pattern) : undefined; + if (parsed) { + // The prefix has two effective parts: the directory path and the base component after the filepath that is not a + // full directory component. For example: directory/path/of/prefix/base* + const normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); + const normalizedPrefixDirectory = getDirectoryPath(normalizedPrefix); + const normalizedPrefixBase = getBaseFileName(normalizedPrefix); + + const fragmentHasPath = fragment.indexOf(directorySeparator) !== -1; + + // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call + const expandedPrefixDirectory = fragmentHasPath ? combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + getDirectoryPath(fragment)) : normalizedPrefixDirectory; + + const normalizedSuffix = normalizePath(parsed.suffix); + const baseDirectory = combinePaths(baseUrl, expandedPrefixDirectory); + const completePrefix = fragmentHasPath ? baseDirectory : ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + + // If we have a suffix, then we need to read the directory all the way down. We could create a glob + // that encodes the suffix, but we would have to escape the character "?" which readDirectory + // doesn't support. For now, this is safer but slower + const includeGlob = normalizedSuffix ? "**/*" : "./*"; + + const matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); + if (matches) { + const result: string[] = []; + + // Trim away prefix and suffix + for (const match of matches) { + const normalizedMatch = normalizePath(match); + if (!endsWith(normalizedMatch, normalizedSuffix) || !startsWith(normalizedMatch, completePrefix)) { + continue; + } + + const start = completePrefix.length; + const length = normalizedMatch.length - start - normalizedSuffix.length; + + result.push(removeFileExtension(normalizedMatch.substr(start, length))); + } + return result; + } } - else if (isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { - // Get all names of properties on the expression - // i.e. interface A { - // 'prop1': string - // } - // let a: A; - // a['/*completion position*/'] - return getStringLiteralCompletionEntriesFromElementAccess(node.parent); + } + + return undefined; + } + + function enumeratePotentialNonRelativeModules(fragment: string, scriptPath: string, options: CompilerOptions, typeChecker: TypeChecker, host: LanguageServiceHost): string[] { + // Check If this is a nested module + const isNestedModule = fragment.indexOf(directorySeparator) !== -1; + const moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(directorySeparator)) : undefined; + + // Get modules that the type checker picked up + const ambientModules = map(typeChecker.getAmbientModules(), sym => stripQuotes(sym.name)); + let nonRelativeModules = filter(ambientModules, moduleName => startsWith(moduleName, fragment)); + + // Nested modules of the form "module-name/sub" need to be adjusted to only return the string + // after the last '/' that appears in the fragment because that's where the replacement span + // starts + if (isNestedModule) { + const moduleNameWithSeperator = ensureTrailingDirectorySeparator(moduleNameFragment); + nonRelativeModules = map(nonRelativeModules, moduleName => { + if (startsWith(fragment, moduleNameWithSeperator)) { + return moduleName.substr(moduleNameWithSeperator.length); + } + return moduleName; + }); + } + + + if (!options.moduleResolution || options.moduleResolution === ModuleResolutionKind.NodeJs) { + for (const visibleModule of enumerateNodeModulesVisibleToScript(host, scriptPath)) { + if (!isNestedModule) { + nonRelativeModules.push(visibleModule.moduleName); + } + else if (startsWith(visibleModule.moduleName, moduleNameFragment)) { + const nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]); + if (nestedFiles) { + for (let f of nestedFiles) { + f = normalizePath(f); + const nestedModule = removeFileExtension(getBaseFileName(f)); + nonRelativeModules.push(nestedModule); + } + } + } } - else if (node.parent.kind === SyntaxKind.ImportDeclaration || isExpressionOfExternalModuleImportEqualsDeclaration(node) || isRequireCall(node.parent, false)) { - // Get all known external module names or complete a path to a module - // i.e. import * as ns from "/*completion position*/"; - // import x = require("/*completion position*/"); - // var y = require("/*completion position*/"); - return getStringLiteralCompletionEntriesFromModuleNames(node); + } + + return deduplicate(nonRelativeModules); + } + + function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: number, compilerOptions: CompilerOptions, host: LanguageServiceHost): CompletionInfo { + const token = getTokenAtPosition(sourceFile, position); + if (!token) { + return undefined; + } + const commentRanges: CommentRange[] = getLeadingCommentRanges(sourceFile.text, token.pos); + + if (!commentRanges || !commentRanges.length) { + return undefined; + } + + const range = forEach(commentRanges, commentRange => position >= commentRange.pos && position <= commentRange.end && commentRange); + + if (!range) { + return undefined; + } + + const completionInfo: CompletionInfo = { + /** + * We don't want the editor to offer any other completions, such as snippets, inside a comment. + */ + isGlobalCompletion: false, + isMemberCompletion: false, + /** + * The user may type in a path that doesn't yet exist, creating a "new identifier" + * with respect to the collection of identifiers the server is aware of. + */ + isNewIdentifierLocation: true, + + entries: [] + }; + + const text = sourceFile.text.substr(range.pos, position - range.pos); + + const match = tripleSlashDirectiveFragmentRegex.exec(text); + + if (match) { + const prefix = match[1]; + const kind = match[2]; + const toComplete = match[3]; + + const scriptPath = getDirectoryPath(sourceFile.path); + if (kind === "path") { + // Give completions for a relative path + const span: TextSpan = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(compilerOptions), /*includeExtensions*/true, span, host, sourceFile.path); } else { - const argumentInfo = SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); - if (argumentInfo) { - // Get string literal completions from specialized signatures of the target - // i.e. declare function f(a: 'A'); - // f("/*completion position*/") - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); - } - - // Get completion for string literal from string literal type - // i.e. var x: "hi" | "hello" = "/*completion position*/" - return getStringLiteralCompletionEntriesFromContextualType(node); + // Give completions based on the typings available + const span: TextSpan = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span); } } - function getStringLiteralCompletionEntriesFromPropertyAssignment(element: ObjectLiteralElement) { - const type = typeChecker.getContextualType((element.parent)); - const entries: CompletionEntry[] = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries }; + return completionInfo; + } + + function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, span: TextSpan, result: CompletionEntry[] = []): CompletionEntry[] { + // Check for typings specified in compiler options + if (options.types) { + for (const moduleName of options.types) { + result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); + } + } + else if (host.getDirectories) { + let typeRoots: string[]; + try { + // Wrap in try catch because getEffectiveTypeRoots touches the filesystem + typeRoots = getEffectiveTypeRoots(options, host); + } + catch (e) {} + + if (typeRoots) { + for (const root of typeRoots) { + getCompletionEntriesFromDirectories(host, root, span, result); } } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo) { - const candidates: Signature[] = []; - const entries: CompletionEntry[] = []; - - typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); - - for (const candidate of candidates) { - if (candidate.parameters.length > argumentInfo.argumentIndex) { - const parameter = candidate.parameters[argumentInfo.argumentIndex]; - addStringLiteralCompletionsFromType(typeChecker.getTypeAtLocation(parameter.valueDeclaration), entries); - } + if (host.getDirectories) { + // Also get all @types typings installed in visible node_modules directories + for (const packageJson of findPackageJsons(scriptPath, host)) { + const typesDir = combinePaths(getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(host, typesDir, span, result); } - - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries }; - } - - return undefined; } - function getStringLiteralCompletionEntriesFromElementAccess(node: ElementAccessExpression) { - const type = typeChecker.getTypeAtLocation(node.expression); - const entries: CompletionEntry[] = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries }; + return result; + } + + function getCompletionEntriesFromDirectories(host: LanguageServiceHost, directory: string, span: TextSpan, result: Push) { + if (host.getDirectories && tryDirectoryExists(host, directory)) { + const directories = tryGetDirectories(host, directory); + if (directories) { + for (let typeDirectory of directories) { + typeDirectory = normalizePath(typeDirectory); + result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName, span)); } } - return undefined; } + } - function getStringLiteralCompletionEntriesFromContextualType(node: StringLiteral) { - const type = typeChecker.getContextualType(node); - if (type) { - const entries: CompletionEntry[] = []; - addStringLiteralCompletionsFromType(type, entries); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries }; + function findPackageJsons(currentDir: string, host: LanguageServiceHost): string[] { + const paths: string[] = []; + let currentConfigPath: string; + while (true) { + currentConfigPath = findConfigFile(currentDir, (f) => tryFileExists(host, f), "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + + currentDir = getDirectoryPath(currentConfigPath); + const parent = getDirectoryPath(currentDir); + if (currentDir === parent) { + break; } - } - return undefined; - } - - function addStringLiteralCompletionsFromType(type: Type, result: CompletionEntry[]): void { - if (type && type.flags & TypeFlags.TypeParameter) { - type = typeChecker.getApparentType(type); - } - if (!type) { - return; - } - if (type.flags & TypeFlags.Union) { - forEach((type).types, t => addStringLiteralCompletionsFromType(t, result)); + currentDir = parent; } else { - if (type.flags & TypeFlags.StringLiteral) { + break; + } + } + + return paths; + } + + function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string) { + const result: VisibleModuleInfo[] = []; + + if (host.readFile && host.fileExists) { + for (const packageJson of findPackageJsons(scriptPath, host)) { + const contents = tryReadingPackageJson(packageJson); + if (!contents) { + return; + } + + const nodeModulesDir = combinePaths(getDirectoryPath(packageJson), "node_modules"); + const foundModuleNames: string[] = []; + + // Provide completions for all non @types dependencies + for (const key of nodeModulesDependencyKeys) { + addPotentialPackageNames(contents[key], foundModuleNames); + } + + for (const moduleName of foundModuleNames) { + const moduleDir = combinePaths(nodeModulesDir, moduleName); result.push({ - name: (type).text, - kindModifiers: ScriptElementKindModifier.none, - kind: ScriptElementKind.variableElement, - sortText: "0" + moduleName, + moduleDir }); } } } - function getStringLiteralCompletionEntriesFromModuleNames(node: StringLiteral): CompletionInfo { - const literalValue = normalizeSlashes(node.text); + return result; - const scriptPath = node.getSourceFile().path; - const scriptDirectory = getDirectoryPath(scriptPath); - - const span = getDirectoryFragmentTextSpan((node).text, node.getStart() + 1); - let entries: CompletionEntry[]; - if (isPathRelativeToScript(literalValue) || isRootedDiskPath(literalValue)) { - if (compilerOptions.rootDirs) { - entries = getCompletionEntriesForDirectoryFragmentWithRootDirs( - compilerOptions.rootDirs, literalValue, scriptDirectory, getSupportedExtensions(compilerOptions), /*includeExtensions*/false, span, scriptPath); - } - else { - entries = getCompletionEntriesForDirectoryFragment( - literalValue, scriptDirectory, getSupportedExtensions(compilerOptions), /*includeExtensions*/false, span, scriptPath); - } + function tryReadingPackageJson(filePath: string) { + try { + const fileText = tryReadFile(host, filePath); + return fileText ? JSON.parse(fileText) : undefined; } - else { - // Check for node modules - entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); - } - return { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries - }; - } - - /** - * Takes a script path and returns paths for all potential folders that could be merged with its - * containing folder via the "rootDirs" compiler option - */ - function getBaseDirectoriesFromRootDirs(rootDirs: string[], basePath: string, scriptPath: string, ignoreCase: boolean): string[] { - // Make all paths absolute/normalized if they are not already - rootDirs = map(rootDirs, rootDirectory => normalizePath(isRootedDiskPath(rootDirectory) ? rootDirectory : combinePaths(basePath, rootDirectory))); - - // Determine the path to the directory containing the script relative to the root directory it is contained within - let relativeDirectory: string; - for (const rootDirectory of rootDirs) { - if (containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { - relativeDirectory = scriptPath.substr(rootDirectory.length); - break; - } - } - - // Now find a path for each potential directory that is to be merged with the one containing the script - return deduplicate(map(rootDirs, rootDirectory => combinePaths(rootDirectory, relativeDirectory))); - } - - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[], fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, exclude?: string): CompletionEntry[] { - const basePath = compilerOptions.project || host.getCurrentDirectory(); - const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - const baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); - - const result: CompletionEntry[] = []; - - for (const baseDirectory of baseDirectories) { - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, exclude, result); - } - - return result; - } - - /** - * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. - */ - function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, exclude?: string, result: CompletionEntry[] = []): CompletionEntry[] { - if (fragment === undefined) { - fragment = ""; - } - - fragment = normalizeSlashes(fragment); - - /** - * Remove the basename from the path. Note that we don't use the basename to filter completions; - * the client is responsible for refining completions. - */ - fragment = getDirectoryPath(fragment); - - if (fragment === "") { - fragment = "." + directorySeparator; - } - - fragment = ensureTrailingDirectorySeparator(fragment); - - const absolutePath = normalizeAndPreserveTrailingSlash(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment)); - const baseDirectory = getDirectoryPath(absolutePath); - const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - - if (tryDirectoryExists(host, baseDirectory)) { - // Enumerate the available files if possible - const files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/undefined, /*include*/["./*"]); - - if (files) { - /** - * Multiple file entries might map to the same truncated name once we remove extensions - * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: - * - * both foo.ts and foo.tsx become foo - */ - const foundFiles = createMap(); - for (let filePath of files) { - filePath = normalizePath(filePath); - if (exclude && comparePaths(filePath, exclude, scriptPath, ignoreCase) === Comparison.EqualTo) { - continue; - } - - const foundFileName = includeExtensions ? getBaseFileName(filePath) : removeFileExtension(getBaseFileName(filePath)); - - if (!foundFiles[foundFileName]) { - foundFiles[foundFileName] = true; - } - } - - for (const foundFile in foundFiles) { - result.push(createCompletionEntryForModule(foundFile, ScriptElementKind.scriptElement, span)); - } - } - - // If possible, get folder completion as well - const directories = tryGetDirectories(host, baseDirectory); - - if (directories) { - for (const directory of directories) { - const directoryName = getBaseFileName(normalizePath(directory)); - - result.push(createCompletionEntryForModule(directoryName, ScriptElementKind.directory, span)); - } - } - } - - return result; - } - - /** - * Check all of the declared modules and those in node modules. Possible sources of modules: - * Modules that are found by the type checker - * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) - * Modules from node_modules (i.e. those listed in package.json) - * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions - */ - function getCompletionEntriesForNonRelativeModules(fragment: string, scriptPath: string, span: TextSpan): CompletionEntry[] { - const { baseUrl, paths } = compilerOptions; - - let result: CompletionEntry[]; - - if (baseUrl) { - const fileExtensions = getSupportedExtensions(compilerOptions); - const projectDir = compilerOptions.project || host.getCurrentDirectory(); - const absolute = isRootedDiskPath(baseUrl) ? baseUrl : combinePaths(projectDir, baseUrl); - result = getCompletionEntriesForDirectoryFragment(fragment, normalizePath(absolute), fileExtensions, /*includeExtensions*/false, span); - - if (paths) { - for (const path in paths) { - if (paths.hasOwnProperty(path)) { - if (path === "*") { - if (paths[path]) { - for (const pattern of paths[path]) { - for (const match of getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions)) { - result.push(createCompletionEntryForModule(match, ScriptElementKind.externalModuleName, span)); - } - } - } - } - else if (startsWith(path, fragment)) { - const entry = paths[path] && paths[path].length === 1 && paths[path][0]; - if (entry) { - result.push(createCompletionEntryForModule(path, ScriptElementKind.externalModuleName, span)); - } - } - } - } - } - } - else { - result = []; - } - - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); - - for (const moduleName of enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions)) { - result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); - } - - return result; - } - - function getModulesForPathsPattern(fragment: string, baseUrl: string, pattern: string, fileExtensions: string[]): string[] { - if (host.readDirectory) { - const parsed = hasZeroOrOneAsteriskCharacter(pattern) ? tryParsePattern(pattern) : undefined; - if (parsed) { - // The prefix has two effective parts: the directory path and the base component after the filepath that is not a - // full directory component. For example: directory/path/of/prefix/base* - const normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); - const normalizedPrefixDirectory = getDirectoryPath(normalizedPrefix); - const normalizedPrefixBase = getBaseFileName(normalizedPrefix); - - const fragmentHasPath = fragment.indexOf(directorySeparator) !== -1; - - // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call - const expandedPrefixDirectory = fragmentHasPath ? combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + getDirectoryPath(fragment)) : normalizedPrefixDirectory; - - const normalizedSuffix = normalizePath(parsed.suffix); - const baseDirectory = combinePaths(baseUrl, expandedPrefixDirectory); - const completePrefix = fragmentHasPath ? baseDirectory : ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - - // If we have a suffix, then we need to read the directory all the way down. We could create a glob - // that encodes the suffix, but we would have to escape the character "?" which readDirectory - // doesn't support. For now, this is safer but slower - const includeGlob = normalizedSuffix ? "**/*" : "./*"; - - const matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); - if (matches) { - const result: string[] = []; - - // Trim away prefix and suffix - for (const match of matches) { - const normalizedMatch = normalizePath(match); - if (!endsWith(normalizedMatch, normalizedSuffix) || !startsWith(normalizedMatch, completePrefix)) { - continue; - } - - const start = completePrefix.length; - const length = normalizedMatch.length - start - normalizedSuffix.length; - - result.push(removeFileExtension(normalizedMatch.substr(start, length))); - } - return result; - } - } - } - - return undefined; - } - - function enumeratePotentialNonRelativeModules(fragment: string, scriptPath: string, options: CompilerOptions): string[] { - // Check If this is a nested module - const isNestedModule = fragment.indexOf(directorySeparator) !== -1; - const moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(directorySeparator)) : undefined; - - // Get modules that the type checker picked up - const ambientModules = map(typeChecker.getAmbientModules(), sym => stripQuotes(sym.name)); - let nonRelativeModules = filter(ambientModules, moduleName => startsWith(moduleName, fragment)); - - // Nested modules of the form "module-name/sub" need to be adjusted to only return the string - // after the last '/' that appears in the fragment because that's where the replacement span - // starts - if (isNestedModule) { - const moduleNameWithSeperator = ensureTrailingDirectorySeparator(moduleNameFragment); - nonRelativeModules = map(nonRelativeModules, moduleName => { - if (startsWith(fragment, moduleNameWithSeperator)) { - return moduleName.substr(moduleNameWithSeperator.length); - } - return moduleName; - }); - } - - - if (!options.moduleResolution || options.moduleResolution === ModuleResolutionKind.NodeJs) { - for (const visibleModule of enumerateNodeModulesVisibleToScript(host, scriptPath)) { - if (!isNestedModule) { - nonRelativeModules.push(visibleModule.moduleName); - } - else if (startsWith(visibleModule.moduleName, moduleNameFragment)) { - const nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]); - if (nestedFiles) { - for (let f of nestedFiles) { - f = normalizePath(f); - const nestedModule = removeFileExtension(getBaseFileName(f)); - nonRelativeModules.push(nestedModule); - } - } - } - } - } - - return deduplicate(nonRelativeModules); - } - - function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: number): CompletionInfo { - const token = getTokenAtPosition(sourceFile, position); - if (!token) { + catch (e) { return undefined; } - const commentRanges: CommentRange[] = getLeadingCommentRanges(sourceFile.text, token.pos); - - if (!commentRanges || !commentRanges.length) { - return undefined; - } - - const range = forEach(commentRanges, commentRange => position >= commentRange.pos && position <= commentRange.end && commentRange); - - if (!range) { - return undefined; - } - - const completionInfo: CompletionInfo = { - /** - * We don't want the editor to offer any other completions, such as snippets, inside a comment. - */ - isGlobalCompletion: false, - isMemberCompletion: false, - /** - * The user may type in a path that doesn't yet exist, creating a "new identifier" - * with respect to the collection of identifiers the server is aware of. - */ - isNewIdentifierLocation: true, - - entries: [] - }; - - const text = sourceFile.text.substr(range.pos, position - range.pos); - - const match = tripleSlashDirectiveFragmentRegex.exec(text); - - if (match) { - const prefix = match[1]; - const kind = match[2]; - const toComplete = match[3]; - - const scriptPath = getDirectoryPath(sourceFile.path); - if (kind === "path") { - // Give completions for a relative path - const span: TextSpan = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(compilerOptions), /*includeExtensions*/true, span, sourceFile.path); - } - else { - // Give completions based on the typings available - const span: TextSpan = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span); - } - } - - return completionInfo; } - function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, span: TextSpan, result: CompletionEntry[] = []): CompletionEntry[] { - // Check for typings specified in compiler options - if (options.types) { - for (const moduleName of options.types) { - result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); - } - } - else if (host.getDirectories) { - let typeRoots: string[]; - try { - // Wrap in try catch because getEffectiveTypeRoots touches the filesystem - typeRoots = getEffectiveTypeRoots(options, host); - } - catch (e) {} - - if (typeRoots) { - for (const root of typeRoots) { - getCompletionEntriesFromDirectories(host, root, span, result); - } - } - } - - if (host.getDirectories) { - // Also get all @types typings installed in visible node_modules directories - for (const packageJson of findPackageJsons(scriptPath)) { - const typesDir = combinePaths(getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, typesDir, span, result); - } - } - - return result; - } - - function getCompletionEntriesFromDirectories(host: LanguageServiceHost, directory: string, span: TextSpan, result: CompletionEntry[]) { - if (host.getDirectories && tryDirectoryExists(host, directory)) { - const directories = tryGetDirectories(host, directory); - if (directories) { - for (let typeDirectory of directories) { - typeDirectory = normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName, span)); + function addPotentialPackageNames(dependencies: any, result: string[]) { + if (dependencies) { + for (const dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && !startsWith(dep, "@types/")) { + result.push(dep); } } } } + } - function findPackageJsons(currentDir: string): string[] { - const paths: string[] = []; - let currentConfigPath: string; - while (true) { - currentConfigPath = findConfigFile(currentDir, (f) => tryFileExists(host, f), "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); + function createCompletionEntryForModule(name: string, kind: string, replacementSpan: TextSpan): CompletionEntry { + return { name, kind, kindModifiers: ScriptElementKindModifier.none, sortText: name, replacementSpan }; + } - currentDir = getDirectoryPath(currentConfigPath); - const parent = getDirectoryPath(currentDir); - if (currentDir === parent) { - break; - } - currentDir = parent; - } - else { - break; - } - } + // Replace everything after the last directory seperator that appears + function getDirectoryFragmentTextSpan(text: string, textStart: number): TextSpan { + const index = text.lastIndexOf(directorySeparator); + const offset = index !== -1 ? index + 1 : 0; + return { start: textStart + offset, length: text.length - offset }; + } - return paths; + // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) + function isPathRelativeToScript(path: string) { + if (path && path.length >= 2 && path.charCodeAt(0) === CharacterCodes.dot) { + const slashIndex = path.length >= 3 && path.charCodeAt(1) === CharacterCodes.dot ? 2 : 1; + const slashCharCode = path.charCodeAt(slashIndex); + return slashCharCode === CharacterCodes.slash || slashCharCode === CharacterCodes.backslash; } + return false; + } - - function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string) { - const result: VisibleModuleInfo[] = []; - - if (host.readFile && host.fileExists) { - for (const packageJson of findPackageJsons(scriptPath)) { - const contents = tryReadingPackageJson(packageJson); - if (!contents) { - return; - } - - const nodeModulesDir = combinePaths(getDirectoryPath(packageJson), "node_modules"); - const foundModuleNames: string[] = []; - - // Provide completions for all non @types dependencies - for (const key of nodeModulesDependencyKeys) { - addPotentialPackageNames(contents[key], foundModuleNames); - } - - for (const moduleName of foundModuleNames) { - const moduleDir = combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName, - moduleDir - }); - } - } - } - - return result; - - function tryReadingPackageJson(filePath: string) { - try { - const fileText = tryReadFile(host, filePath); - return fileText ? JSON.parse(fileText) : undefined; - } - catch (e) { - return undefined; - } - } - - function addPotentialPackageNames(dependencies: any, result: string[]) { - if (dependencies) { - for (const dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && !startsWith(dep, "@types/")) { - result.push(dep); - } - } - } - } - } - - function createCompletionEntryForModule(name: string, kind: string, replacementSpan: TextSpan): CompletionEntry { - return { name, kind, kindModifiers: ScriptElementKindModifier.none, sortText: name, replacementSpan }; - } - - // Replace everything after the last directory seperator that appears - function getDirectoryFragmentTextSpan(text: string, textStart: number): TextSpan { - const index = text.lastIndexOf(directorySeparator); - const offset = index !== -1 ? index + 1 : 0; - return { start: textStart + offset, length: text.length - offset }; - } - - // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) - function isPathRelativeToScript(path: string) { - if (path && path.length >= 2 && path.charCodeAt(0) === CharacterCodes.dot) { - const slashIndex = path.length >= 3 && path.charCodeAt(1) === CharacterCodes.dot ? 2 : 1; - const slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === CharacterCodes.slash || slashCharCode === CharacterCodes.backslash; - } - return false; - } - - function normalizeAndPreserveTrailingSlash(path: string) { - return hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalizePath(path)) : normalizePath(path); - } + function normalizeAndPreserveTrailingSlash(path: string) { + return hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalizePath(path)) : normalizePath(path); } export function getCompletionEntryDetails(typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number, entryName: string): CompletionEntryDetails { @@ -908,13 +915,29 @@ namespace ts.Completions { } } else if (sourceFile.languageVariant === LanguageVariant.JSX) { - if (kind === SyntaxKind.LessThanToken) { - isRightOfOpenTag = true; - location = contextToken; - } - else if (kind === SyntaxKind.SlashToken && contextToken.parent.kind === SyntaxKind.JsxClosingElement) { - isStartingCloseTag = true; - location = contextToken; + switch (contextToken.parent.kind) { + case SyntaxKind.JsxClosingElement: + if (kind === SyntaxKind.SlashToken) { + isStartingCloseTag = true; + location = contextToken; + } + break; + + case SyntaxKind.BinaryExpression: + if (!((contextToken.parent as BinaryExpression).left.flags & NodeFlags.ThisNodeHasError)) { + // It has a left-hand side, so we're not in an opening JSX tag. + break; + } + // fall through + + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.JsxElement: + case SyntaxKind.JsxOpeningElement: + if (kind === SyntaxKind.LessThanToken) { + isRightOfOpenTag = true; + location = contextToken; + } + break; } } } @@ -1033,10 +1056,10 @@ namespace ts.Completions { let attrsType: Type; if ((jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) || (jsxContainer.kind === SyntaxKind.JsxOpeningElement)) { // Cursor is inside a JSX self-closing element or opening element - attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + attrsType = typeChecker.getAllAttributesTypeFromJsxOpeningLikeElement(jsxContainer); if (attrsType) { - symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), (jsxContainer).attributes); + symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), (jsxContainer).attributes.properties); isMemberCompletion = true; isNewIdentifierLocation = false; return true; @@ -1320,14 +1343,14 @@ namespace ts.Completions { isMemberCompletion = true; isNewIdentifierLocation = false; - let exports: Symbol[]; - const moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + const moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); + if (!moduleSpecifierSymbol) { + symbols = emptyArray; + return true; } - symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : emptyArray; - + const exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); + symbols = filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements); return true; } @@ -1378,13 +1401,18 @@ namespace ts.Completions { case SyntaxKind.LessThanSlashToken: case SyntaxKind.SlashToken: case SyntaxKind.Identifier: + case SyntaxKind.JsxAttributes: case SyntaxKind.JsxAttribute: case SyntaxKind.JsxSpreadAttribute: if (parent && (parent.kind === SyntaxKind.JsxSelfClosingElement || parent.kind === SyntaxKind.JsxOpeningElement)) { return parent; } else if (parent.kind === SyntaxKind.JsxAttribute) { - return parent.parent; + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + return parent.parent.parent as JsxOpeningLikeElement; } break; @@ -1393,7 +1421,11 @@ namespace ts.Completions { // whose parent is a JsxOpeningLikeElement case SyntaxKind.StringLiteral: if (parent && ((parent.kind === SyntaxKind.JsxAttribute) || (parent.kind === SyntaxKind.JsxSpreadAttribute))) { - return parent.parent; + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + return parent.parent.parent as JsxOpeningLikeElement; } break; @@ -1401,13 +1433,21 @@ namespace ts.Completions { case SyntaxKind.CloseBraceToken: if (parent && parent.kind === SyntaxKind.JsxExpression && - parent.parent && - (parent.parent.kind === SyntaxKind.JsxAttribute)) { - return parent.parent.parent; + parent.parent && parent.parent.kind === SyntaxKind.JsxAttribute) { + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + // each JsxAttribute can have initializer as JsxExpression + return parent.parent.parent.parent as JsxOpeningLikeElement; } if (parent && parent.kind === SyntaxKind.JsxSpreadAttribute) { - return parent.parent; + // Currently we parse JsxOpeningLikeElement as: + // JsxOpeningLikeElement + // attributes: JsxAttributes + // properties: NodeArray + return parent.parent.parent as JsxOpeningLikeElement; } break; @@ -1566,14 +1606,14 @@ namespace ts.Completions { } const name = element.propertyName || element.name; - existingImportsOrExports[name.text] = true; + existingImportsOrExports.set(name.text, true); } - if (!someProperties(existingImportsOrExports)) { + if (existingImportsOrExports.size === 0) { return filter(exportsOfModule, e => e.name !== "default"); } - return filter(exportsOfModule, e => e.name !== "default" && !existingImportsOrExports[e.name]); + return filter(exportsOfModule, e => e.name !== "default" && !existingImportsOrExports.get(e.name)); } /** @@ -1619,10 +1659,10 @@ namespace ts.Completions { existingName = (m.name).text; } - existingMemberNames[existingName] = true; + existingMemberNames.set(existingName, true); } - return filter(contextualMemberSymbols, m => !existingMemberNames[m.name]); + return filter(contextualMemberSymbols, m => !existingMemberNames.get(m.name)); } /** @@ -1640,11 +1680,11 @@ namespace ts.Completions { } if (attr.kind === SyntaxKind.JsxAttribute) { - seenNames[(attr).name.text] = true; + seenNames.set((attr).name.text, true); } } - return filter(symbols, a => !seenNames[a.name]); + return filter(symbols, a => !seenNames.get(a.name)); } } @@ -1760,4 +1800,15 @@ namespace ts.Completions { catch (e) {} return undefined; } + + function isEqualityExpression(node: Node): node is BinaryExpression { + return isBinaryExpression(node) && isEqualityOperatorKind(node.operatorToken.kind); + } + + function isEqualityOperatorKind(kind: SyntaxKind) { + return kind == SyntaxKind.EqualsEqualsToken || + kind === SyntaxKind.ExclamationEqualsToken || + kind === SyntaxKind.EqualsEqualsEqualsToken || + kind === SyntaxKind.ExclamationEqualsEqualsToken; + } } diff --git a/src/services/documentHighlights.ts b/src/services/documentHighlights.ts index 0f18427e568..ff2b819ec26 100644 --- a/src/services/documentHighlights.ts +++ b/src/services/documentHighlights.ts @@ -2,626 +2,606 @@ namespace ts.DocumentHighlights { export function getDocumentHighlights(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, position: number, sourceFilesToSearch: SourceFile[]): DocumentHighlights[] { const node = getTouchingWord(sourceFile, position); + return node && (getSemanticDocumentHighlights(node, typeChecker, cancellationToken, sourceFilesToSearch) || getSyntacticDocumentHighlights(node, sourceFile)); + } + + function getHighlightSpanForNode(node: Node, sourceFile: SourceFile): HighlightSpan { + const start = node.getStart(sourceFile); + const end = node.getEnd(); + + return { + fileName: sourceFile.fileName, + textSpan: createTextSpanFromBounds(start, end), + kind: HighlightSpanKind.none + }; + } + + function getSemanticDocumentHighlights(node: Node, typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFilesToSearch: SourceFile[]): DocumentHighlights[] { + const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch); + return referencedSymbols && convertReferencedSymbols(referencedSymbols); + } + + function convertReferencedSymbols(referencedSymbols: ReferencedSymbol[]): DocumentHighlights[] { + const fileNameToDocumentHighlights = createMap(); + const result: DocumentHighlights[] = []; + for (const referencedSymbol of referencedSymbols) { + for (const referenceEntry of referencedSymbol.references) { + const fileName = referenceEntry.fileName; + let documentHighlights = fileNameToDocumentHighlights.get(fileName); + if (!documentHighlights) { + documentHighlights = { fileName, highlightSpans: [] }; + + fileNameToDocumentHighlights.set(fileName, documentHighlights); + result.push(documentHighlights); + } + + documentHighlights.highlightSpans.push({ + textSpan: referenceEntry.textSpan, + kind: referenceEntry.isWriteAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference + }); + } + } + + return result; + } + + function getSyntacticDocumentHighlights(node: Node, sourceFile: SourceFile): DocumentHighlights[] { + const highlightSpans = getHighlightSpans(node, sourceFile); + if (!highlightSpans || highlightSpans.length === 0) { + return undefined; + } + + return [{ fileName: sourceFile.fileName, highlightSpans }]; + } + + // returns true if 'node' is defined and has a matching 'kind'. + function hasKind(node: Node, kind: SyntaxKind) { + return node !== undefined && node.kind === kind; + } + + // Null-propagating 'parent' function. + function parent(node: Node): Node { + return node && node.parent; + } + + function getHighlightSpans(node: Node, sourceFile: SourceFile): HighlightSpan[] { if (!node) { return undefined; } - return getSemanticDocumentHighlights(node) || getSyntacticDocumentHighlights(node); - - function getHighlightSpanForNode(node: Node): HighlightSpan { - const start = node.getStart(); - const end = node.getEnd(); - - return { - fileName: sourceFile.fileName, - textSpan: createTextSpanFromBounds(start, end), - kind: HighlightSpanKind.none - }; + switch (node.kind) { + case SyntaxKind.IfKeyword: + case SyntaxKind.ElseKeyword: + if (hasKind(node.parent, SyntaxKind.IfStatement)) { + return getIfElseOccurrences(node.parent, sourceFile); + } + break; + case SyntaxKind.ReturnKeyword: + if (hasKind(node.parent, SyntaxKind.ReturnStatement)) { + return highlightSpans(getReturnOccurrences(node.parent)); + } + break; + case SyntaxKind.ThrowKeyword: + if (hasKind(node.parent, SyntaxKind.ThrowStatement)) { + return highlightSpans(getThrowOccurrences(node.parent)); + } + break; + case SyntaxKind.TryKeyword: + case SyntaxKind.CatchKeyword: + case SyntaxKind.FinallyKeyword: + const tryStatement = node.kind === SyntaxKind.CatchKeyword ? parent(parent(node)) : parent(node); + if (hasKind(tryStatement, SyntaxKind.TryStatement)) { + return highlightSpans(getTryCatchFinallyOccurrences(tryStatement, sourceFile)); + } + break; + case SyntaxKind.SwitchKeyword: + if (hasKind(node.parent, SyntaxKind.SwitchStatement)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent)); + } + break; + case SyntaxKind.CaseKeyword: + case SyntaxKind.DefaultKeyword: + if (hasKind(parent(parent(parent(node))), SyntaxKind.SwitchStatement)) { + return highlightSpans(getSwitchCaseDefaultOccurrences(node.parent.parent.parent)); + } + break; + case SyntaxKind.BreakKeyword: + case SyntaxKind.ContinueKeyword: + if (hasKind(node.parent, SyntaxKind.BreakStatement) || hasKind(node.parent, SyntaxKind.ContinueStatement)) { + return highlightSpans(getBreakOrContinueStatementOccurrences(node.parent)); + } + break; + case SyntaxKind.ForKeyword: + if (hasKind(node.parent, SyntaxKind.ForStatement) || + hasKind(node.parent, SyntaxKind.ForInStatement) || + hasKind(node.parent, SyntaxKind.ForOfStatement)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case SyntaxKind.WhileKeyword: + case SyntaxKind.DoKeyword: + if (hasKind(node.parent, SyntaxKind.WhileStatement) || hasKind(node.parent, SyntaxKind.DoStatement)) { + return highlightSpans(getLoopBreakContinueOccurrences(node.parent)); + } + break; + case SyntaxKind.ConstructorKeyword: + if (hasKind(node.parent, SyntaxKind.Constructor)) { + return highlightSpans(getConstructorOccurrences(node.parent)); + } + break; + case SyntaxKind.GetKeyword: + case SyntaxKind.SetKeyword: + if (hasKind(node.parent, SyntaxKind.GetAccessor) || hasKind(node.parent, SyntaxKind.SetAccessor)) { + return highlightSpans(getGetAndSetOccurrences(node.parent)); + } + break; + default: + if (isModifierKind(node.kind) && node.parent && + (isDeclaration(node.parent) || node.parent.kind === SyntaxKind.VariableStatement)) { + return highlightSpans(getModifierOccurrences(node.kind, node.parent)); + } } - function getSemanticDocumentHighlights(node: Node): DocumentHighlights[] { - if (node.kind === SyntaxKind.Identifier || - node.kind === SyntaxKind.ThisKeyword || - node.kind === SyntaxKind.ThisType || - node.kind === SyntaxKind.SuperKeyword || - node.kind === SyntaxKind.StringLiteral || - isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - - const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, /*findInStrings*/ false, /*findInComments*/ false, /*implementations*/false); - return convertReferencedSymbols(referencedSymbols); - - } - - return undefined; - - function convertReferencedSymbols(referencedSymbols: ReferencedSymbol[]): DocumentHighlights[] { - if (!referencedSymbols) { - return undefined; - } - - const fileNameToDocumentHighlights = createMap(); - const result: DocumentHighlights[] = []; - for (const referencedSymbol of referencedSymbols) { - for (const referenceEntry of referencedSymbol.references) { - const fileName = referenceEntry.fileName; - let documentHighlights = fileNameToDocumentHighlights[fileName]; - if (!documentHighlights) { - documentHighlights = { fileName, highlightSpans: [] }; - - fileNameToDocumentHighlights[fileName] = documentHighlights; - result.push(documentHighlights); - } - - documentHighlights.highlightSpans.push({ - textSpan: referenceEntry.textSpan, - kind: referenceEntry.isWriteAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference - }); - } - } - - return result; - } + function highlightSpans(nodes: Node[]): HighlightSpan[] { + return nodes && nodes.map(node => getHighlightSpanForNode(node, sourceFile)); } + } - function getSyntacticDocumentHighlights(node: Node): DocumentHighlights[] { - const fileName = sourceFile.fileName; + /** + * Aggregates all throw-statements within this node *without* crossing + * into function boundaries and try-blocks with catch-clauses. + */ + function aggregateOwnedThrowStatements(node: Node): ThrowStatement[] { + const statementAccumulator: ThrowStatement[] = []; + aggregate(node); + return statementAccumulator; - const highlightSpans = getHighlightSpans(node); - if (!highlightSpans || highlightSpans.length === 0) { - return undefined; + function aggregate(node: Node): void { + if (node.kind === SyntaxKind.ThrowStatement) { + statementAccumulator.push(node); } - - return [{ fileName, highlightSpans }]; - - // returns true if 'node' is defined and has a matching 'kind'. - function hasKind(node: Node, kind: SyntaxKind) { - return node !== undefined && node.kind === kind; - } - - // Null-propagating 'parent' function. - function parent(node: Node): Node { - return node && node.parent; - } - - function getHighlightSpans(node: Node): HighlightSpan[] { - if (node) { - switch (node.kind) { - case SyntaxKind.IfKeyword: - case SyntaxKind.ElseKeyword: - if (hasKind(node.parent, SyntaxKind.IfStatement)) { - return getIfElseOccurrences(node.parent); - } - break; - case SyntaxKind.ReturnKeyword: - if (hasKind(node.parent, SyntaxKind.ReturnStatement)) { - return getReturnOccurrences(node.parent); - } - break; - case SyntaxKind.ThrowKeyword: - if (hasKind(node.parent, SyntaxKind.ThrowStatement)) { - return getThrowOccurrences(node.parent); - } - break; - case SyntaxKind.CatchKeyword: - if (hasKind(parent(parent(node)), SyntaxKind.TryStatement)) { - return getTryCatchFinallyOccurrences(node.parent.parent); - } - break; - case SyntaxKind.TryKeyword: - case SyntaxKind.FinallyKeyword: - if (hasKind(parent(node), SyntaxKind.TryStatement)) { - return getTryCatchFinallyOccurrences(node.parent); - } - break; - case SyntaxKind.SwitchKeyword: - if (hasKind(node.parent, SyntaxKind.SwitchStatement)) { - return getSwitchCaseDefaultOccurrences(node.parent); - } - break; - case SyntaxKind.CaseKeyword: - case SyntaxKind.DefaultKeyword: - if (hasKind(parent(parent(parent(node))), SyntaxKind.SwitchStatement)) { - return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); - } - break; - case SyntaxKind.BreakKeyword: - case SyntaxKind.ContinueKeyword: - if (hasKind(node.parent, SyntaxKind.BreakStatement) || hasKind(node.parent, SyntaxKind.ContinueStatement)) { - return getBreakOrContinueStatementOccurrences(node.parent); - } - break; - case SyntaxKind.ForKeyword: - if (hasKind(node.parent, SyntaxKind.ForStatement) || - hasKind(node.parent, SyntaxKind.ForInStatement) || - hasKind(node.parent, SyntaxKind.ForOfStatement)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case SyntaxKind.WhileKeyword: - case SyntaxKind.DoKeyword: - if (hasKind(node.parent, SyntaxKind.WhileStatement) || hasKind(node.parent, SyntaxKind.DoStatement)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case SyntaxKind.ConstructorKeyword: - if (hasKind(node.parent, SyntaxKind.Constructor)) { - return getConstructorOccurrences(node.parent); - } - break; - case SyntaxKind.GetKeyword: - case SyntaxKind.SetKeyword: - if (hasKind(node.parent, SyntaxKind.GetAccessor) || hasKind(node.parent, SyntaxKind.SetAccessor)) { - return getGetAndSetOccurrences(node.parent); - } - break; - default: - if (isModifierKind(node.kind) && node.parent && - (isDeclaration(node.parent) || node.parent.kind === SyntaxKind.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: Node): ThrowStatement[] { - const statementAccumulator: ThrowStatement[] = []; - aggregate(node); - return statementAccumulator; - - function aggregate(node: Node): void { - if (node.kind === SyntaxKind.ThrowStatement) { - statementAccumulator.push(node); - } - else if (node.kind === SyntaxKind.TryStatement) { - const 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); - } - } - // Do not cross function boundaries. - else if (!isFunctionLike(node)) { - 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: ThrowStatement): Node { - let child: Node = throwStatement; - - while (child.parent) { - const parent = child.parent; - - if (isFunctionBlock(parent) || parent.kind === SyntaxKind.SourceFile) { - return parent; - } - - // 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.kind === SyntaxKind.TryStatement) { - const tryStatement = parent; - - if (tryStatement.tryBlock === child && tryStatement.catchClause) { - return child; - } - } - - child = parent; - } - - return undefined; - } - - function aggregateAllBreakAndContinueStatements(node: Node): BreakOrContinueStatement[] { - const statementAccumulator: BreakOrContinueStatement[] = []; - aggregate(node); - return statementAccumulator; - - function aggregate(node: Node): void { - if (node.kind === SyntaxKind.BreakStatement || node.kind === SyntaxKind.ContinueStatement) { - statementAccumulator.push(node); - } - // Do not cross function boundaries. - else if (!isFunctionLike(node)) { - forEachChild(node, aggregate); - } - } - } - - function ownsBreakOrContinueStatement(owner: Node, statement: BreakOrContinueStatement): boolean { - const actualOwner = getBreakOrContinueOwner(statement); - - return actualOwner && actualOwner === owner; - } - - function getBreakOrContinueOwner(statement: BreakOrContinueStatement): Node { - for (let node = statement.parent; node; node = node.parent) { - switch (node.kind) { - case SyntaxKind.SwitchStatement: - if (statement.kind === SyntaxKind.ContinueStatement) { - continue; - } - // Fall through. - case SyntaxKind.ForStatement: - case SyntaxKind.ForInStatement: - case SyntaxKind.ForOfStatement: - case SyntaxKind.WhileStatement: - case SyntaxKind.DoStatement: - if (!statement.label || isLabeledBy(node, statement.label.text)) { - return node; - } - break; - default: - // Don't cross function boundaries. - if (isFunctionLike(node)) { - return undefined; - } - break; - } - } - - return undefined; - } - - function getModifierOccurrences(modifier: SyntaxKind, declaration: Node): HighlightSpan[] { - const container = declaration.parent; - - // Make sure we only highlight the keyword when it makes sense to do so. - if (isAccessibilityModifier(modifier)) { - if (!(container.kind === SyntaxKind.ClassDeclaration || - container.kind === SyntaxKind.ClassExpression || - (declaration.kind === SyntaxKind.Parameter && hasKind(container, SyntaxKind.Constructor)))) { - return undefined; - } - } - else if (modifier === SyntaxKind.StaticKeyword) { - if (!(container.kind === SyntaxKind.ClassDeclaration || container.kind === SyntaxKind.ClassExpression)) { - return undefined; - } - } - else if (modifier === SyntaxKind.ExportKeyword || modifier === SyntaxKind.DeclareKeyword) { - if (!(container.kind === SyntaxKind.ModuleBlock || container.kind === SyntaxKind.SourceFile)) { - return undefined; - } - } - else if (modifier === SyntaxKind.AbstractKeyword) { - if (!(container.kind === SyntaxKind.ClassDeclaration || declaration.kind === SyntaxKind.ClassDeclaration)) { - return undefined; - } - } - else { - // unsupported modifier - return undefined; - } - - const keywords: Node[] = []; - const modifierFlag: ModifierFlags = getFlagFromModifier(modifier); - - let nodes: Node[]; - switch (container.kind) { - case SyntaxKind.ModuleBlock: - case SyntaxKind.SourceFile: - // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & ModifierFlags.Abstract) { - nodes = ((declaration).members).concat(declaration); - } - else { - nodes = (container).statements; - } - break; - case SyntaxKind.Constructor: - nodes = ((container).parameters).concat( - (container.parent).members); - break; - case SyntaxKind.ClassDeclaration: - case SyntaxKind.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 & ModifierFlags.AccessibilityModifier) { - const constructor = forEach((container).members, member => { - return member.kind === SyntaxKind.Constructor && member; - }); - - if (constructor) { - nodes = nodes.concat(constructor.parameters); - } - } - else if (modifierFlag & ModifierFlags.Abstract) { - nodes = nodes.concat(container); - } - break; - default: - Debug.fail("Invalid container kind."); - } - - forEach(nodes, node => { - if (getModifierFlags(node) & modifierFlag) { - forEach(node.modifiers, child => pushKeywordIf(keywords, child, modifier)); - } - }); - - return map(keywords, getHighlightSpanForNode); - - function getFlagFromModifier(modifier: SyntaxKind) { - switch (modifier) { - case SyntaxKind.PublicKeyword: - return ModifierFlags.Public; - case SyntaxKind.PrivateKeyword: - return ModifierFlags.Private; - case SyntaxKind.ProtectedKeyword: - return ModifierFlags.Protected; - case SyntaxKind.StaticKeyword: - return ModifierFlags.Static; - case SyntaxKind.ExportKeyword: - return ModifierFlags.Export; - case SyntaxKind.DeclareKeyword: - return ModifierFlags.Ambient; - case SyntaxKind.AbstractKeyword: - return ModifierFlags.Abstract; - default: - Debug.fail(); - } - } - } - - function pushKeywordIf(keywordList: Node[], token: Node, ...expected: SyntaxKind[]): boolean { - if (token && contains(expected, token.kind)) { - keywordList.push(token); - return true; - } - - return false; - } - - function getGetAndSetOccurrences(accessorDeclaration: AccessorDeclaration): HighlightSpan[] { - const keywords: Node[] = []; - - tryPushAccessorKeyword(accessorDeclaration.symbol, SyntaxKind.GetAccessor); - tryPushAccessorKeyword(accessorDeclaration.symbol, SyntaxKind.SetAccessor); - - return map(keywords, getHighlightSpanForNode); - - function tryPushAccessorKeyword(accessorSymbol: Symbol, accessorKind: SyntaxKind): void { - const accessor = getDeclarationOfKind(accessorSymbol, accessorKind); - - if (accessor) { - forEach(accessor.getChildren(), child => pushKeywordIf(keywords, child, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword)); - } - } - } - - function getConstructorOccurrences(constructorDeclaration: ConstructorDeclaration): HighlightSpan[] { - const declarations = constructorDeclaration.symbol.getDeclarations(); - - const keywords: Node[] = []; - - forEach(declarations, declaration => { - forEach(declaration.getChildren(), token => { - return pushKeywordIf(keywords, token, SyntaxKind.ConstructorKeyword); - }); - }); - - return map(keywords, getHighlightSpanForNode); - } - - function getLoopBreakContinueOccurrences(loopNode: IterationStatement): HighlightSpan[] { - const keywords: Node[] = []; - - if (pushKeywordIf(keywords, loopNode.getFirstToken(), SyntaxKind.ForKeyword, SyntaxKind.WhileKeyword, SyntaxKind.DoKeyword)) { - // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === SyntaxKind.DoStatement) { - const loopTokens = loopNode.getChildren(); - - for (let i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], SyntaxKind.WhileKeyword)) { - break; - } - } - } - } - - const breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); - - forEach(breaksAndContinues, statement => { - if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), SyntaxKind.BreakKeyword, SyntaxKind.ContinueKeyword); - } - }); - - return map(keywords, getHighlightSpanForNode); - } - - function getBreakOrContinueStatementOccurrences(breakOrContinueStatement: BreakOrContinueStatement): HighlightSpan[] { - const owner = getBreakOrContinueOwner(breakOrContinueStatement); - - if (owner) { - switch (owner.kind) { - case SyntaxKind.ForStatement: - case SyntaxKind.ForInStatement: - case SyntaxKind.ForOfStatement: - case SyntaxKind.DoStatement: - case SyntaxKind.WhileStatement: - return getLoopBreakContinueOccurrences(owner); - case SyntaxKind.SwitchStatement: - return getSwitchCaseDefaultOccurrences(owner); - - } - } - - return undefined; - } - - function getSwitchCaseDefaultOccurrences(switchStatement: SwitchStatement): HighlightSpan[] { - const keywords: Node[] = []; - - pushKeywordIf(keywords, switchStatement.getFirstToken(), SyntaxKind.SwitchKeyword); - - // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. - forEach(switchStatement.caseBlock.clauses, clause => { - pushKeywordIf(keywords, clause.getFirstToken(), SyntaxKind.CaseKeyword, SyntaxKind.DefaultKeyword); - - const breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); - - forEach(breaksAndContinues, statement => { - if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), SyntaxKind.BreakKeyword); - } - }); - }); - - return map(keywords, getHighlightSpanForNode); - } - - function getTryCatchFinallyOccurrences(tryStatement: TryStatement): HighlightSpan[] { - const keywords: Node[] = []; - - pushKeywordIf(keywords, tryStatement.getFirstToken(), SyntaxKind.TryKeyword); + else if (node.kind === SyntaxKind.TryStatement) { + const tryStatement = node; if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), SyntaxKind.CatchKeyword); + 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) { - const finallyKeyword = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile); - pushKeywordIf(keywords, finallyKeyword, SyntaxKind.FinallyKeyword); + aggregate(tryStatement.finallyBlock); } - - return map(keywords, getHighlightSpanForNode); } - - function getThrowOccurrences(throwStatement: ThrowStatement): HighlightSpan[] { - const owner = getThrowStatementOwner(throwStatement); - - if (!owner) { - return undefined; - } - - const keywords: Node[] = []; - - forEach(aggregateOwnedThrowStatements(owner), throwStatement => { - pushKeywordIf(keywords, throwStatement.getFirstToken(), SyntaxKind.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 (isFunctionBlock(owner)) { - forEachReturnStatement(owner, returnStatement => { - pushKeywordIf(keywords, returnStatement.getFirstToken(), SyntaxKind.ReturnKeyword); - }); - } - - return map(keywords, getHighlightSpanForNode); - } - - function getReturnOccurrences(returnStatement: ReturnStatement): HighlightSpan[] { - const func = getContainingFunction(returnStatement); - - // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, SyntaxKind.Block))) { - return undefined; - } - - const keywords: Node[] = []; - forEachReturnStatement(func.body, returnStatement => { - pushKeywordIf(keywords, returnStatement.getFirstToken(), SyntaxKind.ReturnKeyword); - }); - - // Include 'throw' statements that do not occur within a try block. - forEach(aggregateOwnedThrowStatements(func.body), throwStatement => { - pushKeywordIf(keywords, throwStatement.getFirstToken(), SyntaxKind.ThrowKeyword); - }); - - return map(keywords, getHighlightSpanForNode); - } - - function getIfElseOccurrences(ifStatement: IfStatement): HighlightSpan[] { - const keywords: Node[] = []; - - // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, SyntaxKind.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) { - const children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], SyntaxKind.IfKeyword); - - // Generally the 'else' keyword is second-to-last, so we traverse backwards. - for (let i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], SyntaxKind.ElseKeyword)) { - break; - } - } - - if (!hasKind(ifStatement.elseStatement, SyntaxKind.IfStatement)) { - break; - } - - ifStatement = ifStatement.elseStatement; - } - - const result: HighlightSpan[] = []; - - // 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 (let i = 0; i < keywords.length; i++) { - if (keywords[i].kind === SyntaxKind.ElseKeyword && i < keywords.length - 1) { - const elseKeyword = keywords[i]; - const ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. - - let shouldCombindElseAndIf = true; - - // Avoid recalculating getStart() by iterating backwards. - for (let j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { - if (!isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { - shouldCombindElseAndIf = false; - break; - } - } - - if (shouldCombindElseAndIf) { - result.push({ - fileName: fileName, - textSpan: 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; + // Do not cross function boundaries. + else if (!isFunctionLike(node)) { + 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: ThrowStatement): Node { + let child: Node = throwStatement; + + while (child.parent) { + const parent = child.parent; + + if (isFunctionBlock(parent) || parent.kind === SyntaxKind.SourceFile) { + return parent; + } + + // 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.kind === SyntaxKind.TryStatement) { + const tryStatement = parent; + + if (tryStatement.tryBlock === child && tryStatement.catchClause) { + return child; + } + } + + child = parent; + } + + return undefined; + } + + function aggregateAllBreakAndContinueStatements(node: Node): BreakOrContinueStatement[] { + const statementAccumulator: BreakOrContinueStatement[] = []; + aggregate(node); + return statementAccumulator; + + function aggregate(node: Node): void { + if (node.kind === SyntaxKind.BreakStatement || node.kind === SyntaxKind.ContinueStatement) { + statementAccumulator.push(node); + } + // Do not cross function boundaries. + else if (!isFunctionLike(node)) { + forEachChild(node, aggregate); + } + } + } + + function ownsBreakOrContinueStatement(owner: Node, statement: BreakOrContinueStatement): boolean { + const actualOwner = getBreakOrContinueOwner(statement); + + return actualOwner && actualOwner === owner; + } + + function getBreakOrContinueOwner(statement: BreakOrContinueStatement): Node { + for (let node = statement.parent; node; node = node.parent) { + switch (node.kind) { + case SyntaxKind.SwitchStatement: + if (statement.kind === SyntaxKind.ContinueStatement) { + continue; + } + // Fall through. + case SyntaxKind.ForStatement: + case SyntaxKind.ForInStatement: + case SyntaxKind.ForOfStatement: + case SyntaxKind.WhileStatement: + case SyntaxKind.DoStatement: + if (!statement.label || isLabeledBy(node, statement.label.text)) { + return node; + } + break; + default: + // Don't cross function boundaries. + if (isFunctionLike(node)) { + return undefined; + } + break; + } + } + + return undefined; + } + + function getModifierOccurrences(modifier: SyntaxKind, declaration: Node): Node[] { + const container = declaration.parent; + + // Make sure we only highlight the keyword when it makes sense to do so. + if (isAccessibilityModifier(modifier)) { + if (!(container.kind === SyntaxKind.ClassDeclaration || + container.kind === SyntaxKind.ClassExpression || + (declaration.kind === SyntaxKind.Parameter && hasKind(container, SyntaxKind.Constructor)))) { + return undefined; + } + } + else if (modifier === SyntaxKind.StaticKeyword) { + if (!(container.kind === SyntaxKind.ClassDeclaration || container.kind === SyntaxKind.ClassExpression)) { + return undefined; + } + } + else if (modifier === SyntaxKind.ExportKeyword || modifier === SyntaxKind.DeclareKeyword) { + if (!(container.kind === SyntaxKind.ModuleBlock || container.kind === SyntaxKind.SourceFile)) { + return undefined; + } + } + else if (modifier === SyntaxKind.AbstractKeyword) { + if (!(container.kind === SyntaxKind.ClassDeclaration || declaration.kind === SyntaxKind.ClassDeclaration)) { + return undefined; + } + } + else { + // unsupported modifier + return undefined; + } + + const keywords: Node[] = []; + const modifierFlag: ModifierFlags = getFlagFromModifier(modifier); + + let nodes: Node[]; + switch (container.kind) { + case SyntaxKind.ModuleBlock: + case SyntaxKind.SourceFile: + // Container is either a class declaration or the declaration is a classDeclaration + if (modifierFlag & ModifierFlags.Abstract) { + nodes = ((declaration).members).concat(declaration); + } + else { + nodes = (container).statements; + } + break; + case SyntaxKind.Constructor: + nodes = ((container).parameters).concat( + (container.parent).members); + break; + case SyntaxKind.ClassDeclaration: + case SyntaxKind.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 & ModifierFlags.AccessibilityModifier) { + const constructor = forEach((container).members, member => { + return member.kind === SyntaxKind.Constructor && member; + }); + + if (constructor) { + nodes = nodes.concat(constructor.parameters); + } + } + else if (modifierFlag & ModifierFlags.Abstract) { + nodes = nodes.concat(container); + } + break; + default: + Debug.fail("Invalid container kind."); + } + + forEach(nodes, node => { + if (getModifierFlags(node) & modifierFlag) { + forEach(node.modifiers, child => pushKeywordIf(keywords, child, modifier)); + } + }); + + return keywords; + + function getFlagFromModifier(modifier: SyntaxKind) { + switch (modifier) { + case SyntaxKind.PublicKeyword: + return ModifierFlags.Public; + case SyntaxKind.PrivateKeyword: + return ModifierFlags.Private; + case SyntaxKind.ProtectedKeyword: + return ModifierFlags.Protected; + case SyntaxKind.StaticKeyword: + return ModifierFlags.Static; + case SyntaxKind.ExportKeyword: + return ModifierFlags.Export; + case SyntaxKind.DeclareKeyword: + return ModifierFlags.Ambient; + case SyntaxKind.AbstractKeyword: + return ModifierFlags.Abstract; + default: + Debug.fail(); + } + } + } + + function pushKeywordIf(keywordList: Node[], token: Node, ...expected: SyntaxKind[]): boolean { + if (token && contains(expected, token.kind)) { + keywordList.push(token); + return true; + } + + return false; + } + + function getGetAndSetOccurrences(accessorDeclaration: AccessorDeclaration): Node[] { + const keywords: Node[] = []; + + tryPushAccessorKeyword(accessorDeclaration.symbol, SyntaxKind.GetAccessor); + tryPushAccessorKeyword(accessorDeclaration.symbol, SyntaxKind.SetAccessor); + + return keywords; + + function tryPushAccessorKeyword(accessorSymbol: Symbol, accessorKind: SyntaxKind): void { + const accessor = getDeclarationOfKind(accessorSymbol, accessorKind); + + if (accessor) { + forEach(accessor.getChildren(), child => pushKeywordIf(keywords, child, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword)); + } + } + } + + function getConstructorOccurrences(constructorDeclaration: ConstructorDeclaration): Node[] { + const declarations = constructorDeclaration.symbol.getDeclarations(); + + const keywords: Node[] = []; + + forEach(declarations, declaration => { + forEach(declaration.getChildren(), token => { + return pushKeywordIf(keywords, token, SyntaxKind.ConstructorKeyword); + }); + }); + + return keywords; + } + + function getLoopBreakContinueOccurrences(loopNode: IterationStatement): Node[] { + const keywords: Node[] = []; + + if (pushKeywordIf(keywords, loopNode.getFirstToken(), SyntaxKind.ForKeyword, SyntaxKind.WhileKeyword, SyntaxKind.DoKeyword)) { + // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. + if (loopNode.kind === SyntaxKind.DoStatement) { + const loopTokens = loopNode.getChildren(); + + for (let i = loopTokens.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, loopTokens[i], SyntaxKind.WhileKeyword)) { + break; + } + } + } + } + + const breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); + + forEach(breaksAndContinues, statement => { + if (ownsBreakOrContinueStatement(loopNode, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), SyntaxKind.BreakKeyword, SyntaxKind.ContinueKeyword); + } + }); + + return keywords; + } + + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement: BreakOrContinueStatement): Node[] { + const owner = getBreakOrContinueOwner(breakOrContinueStatement); + + if (owner) { + switch (owner.kind) { + case SyntaxKind.ForStatement: + case SyntaxKind.ForInStatement: + case SyntaxKind.ForOfStatement: + case SyntaxKind.DoStatement: + case SyntaxKind.WhileStatement: + return getLoopBreakContinueOccurrences(owner); + case SyntaxKind.SwitchStatement: + return getSwitchCaseDefaultOccurrences(owner); + + } + } + + return undefined; + } + + function getSwitchCaseDefaultOccurrences(switchStatement: SwitchStatement): Node[] { + const keywords: Node[] = []; + + pushKeywordIf(keywords, switchStatement.getFirstToken(), SyntaxKind.SwitchKeyword); + + // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. + forEach(switchStatement.caseBlock.clauses, clause => { + pushKeywordIf(keywords, clause.getFirstToken(), SyntaxKind.CaseKeyword, SyntaxKind.DefaultKeyword); + + const breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); + + forEach(breaksAndContinues, statement => { + if (ownsBreakOrContinueStatement(switchStatement, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), SyntaxKind.BreakKeyword); + } + }); + }); + + return keywords; + } + + function getTryCatchFinallyOccurrences(tryStatement: TryStatement, sourceFile: SourceFile): Node[] { + const keywords: Node[] = []; + + pushKeywordIf(keywords, tryStatement.getFirstToken(), SyntaxKind.TryKeyword); + + if (tryStatement.catchClause) { + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), SyntaxKind.CatchKeyword); + } + + if (tryStatement.finallyBlock) { + const finallyKeyword = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile); + pushKeywordIf(keywords, finallyKeyword, SyntaxKind.FinallyKeyword); + } + + return keywords; + } + + function getThrowOccurrences(throwStatement: ThrowStatement): Node[] { + const owner = getThrowStatementOwner(throwStatement); + + if (!owner) { + return undefined; + } + + const keywords: Node[] = []; + + forEach(aggregateOwnedThrowStatements(owner), throwStatement => { + pushKeywordIf(keywords, throwStatement.getFirstToken(), SyntaxKind.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 (isFunctionBlock(owner)) { + forEachReturnStatement(owner, returnStatement => { + pushKeywordIf(keywords, returnStatement.getFirstToken(), SyntaxKind.ReturnKeyword); + }); + } + + return keywords; + } + + function getReturnOccurrences(returnStatement: ReturnStatement): Node[] { + const func = getContainingFunction(returnStatement); + + // If we didn't find a containing function with a block body, bail out. + if (!(func && hasKind(func.body, SyntaxKind.Block))) { + return undefined; + } + + const keywords: Node[] = []; + forEachReturnStatement(func.body, returnStatement => { + pushKeywordIf(keywords, returnStatement.getFirstToken(), SyntaxKind.ReturnKeyword); + }); + + // Include 'throw' statements that do not occur within a try block. + forEach(aggregateOwnedThrowStatements(func.body), throwStatement => { + pushKeywordIf(keywords, throwStatement.getFirstToken(), SyntaxKind.ThrowKeyword); + }); + + return keywords; + } + + function getIfElseOccurrences(ifStatement: IfStatement, sourceFile: SourceFile): HighlightSpan[] { + const keywords: Node[] = []; + + // Traverse upwards through all parent if-statements linked by their else-branches. + while (hasKind(ifStatement.parent, SyntaxKind.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) { + const children = ifStatement.getChildren(); + pushKeywordIf(keywords, children[0], SyntaxKind.IfKeyword); + + // Generally the 'else' keyword is second-to-last, so we traverse backwards. + for (let i = children.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, children[i], SyntaxKind.ElseKeyword)) { + break; + } + } + + if (!hasKind(ifStatement.elseStatement, SyntaxKind.IfStatement)) { + break; + } + + ifStatement = ifStatement.elseStatement; + } + + const result: HighlightSpan[] = []; + + // 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 (let i = 0; i < keywords.length; i++) { + if (keywords[i].kind === SyntaxKind.ElseKeyword && i < keywords.length - 1) { + const elseKeyword = keywords[i]; + const ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. + + let shouldCombindElseAndIf = true; + + // Avoid recalculating getStart() by iterating backwards. + for (let j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { + if (!isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { + shouldCombindElseAndIf = false; + break; + } + } + + if (shouldCombindElseAndIf) { + result.push({ + fileName: sourceFile.fileName, + textSpan: 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], sourceFile)); + } + + return result; + } + /** * Whether or not a 'node' is preceded by a label of the given string. * Note: 'node' cannot be a SourceFile. diff --git a/src/services/documentRegistry.ts b/src/services/documentRegistry.ts index d73e4d3b0a1..80b0133ccfe 100644 --- a/src/services/documentRegistry.ts +++ b/src/services/documentRegistry.ts @@ -1,4 +1,4 @@ -namespace ts { +namespace ts { /** * 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) @@ -113,16 +113,16 @@ namespace ts { } function getBucketForCompilationSettings(key: DocumentRegistryBucketKey, createIfMissing: boolean): FileMap { - let bucket = buckets[key]; + let bucket = buckets.get(key); if (!bucket && createIfMissing) { - buckets[key] = bucket = createFileMap(); + buckets.set(key, bucket = createFileMap()); } return bucket; } function reportStats() { - const bucketInfoArray = Object.keys(buckets).filter(name => name && name.charAt(0) === "_").map(name => { - const entries = buckets[name]; + const bucketInfoArray = arrayFrom(buckets.keys()).filter(name => name && name.charAt(0) === "_").map(name => { + const entries = buckets.get(name); const sourceFiles: { name: string; refCount: number; references: string[]; }[] = []; entries.forEachValue((key, entry) => { sourceFiles.push({ diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 313a3d2ea3e..24d7d648272 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1,63 +1,31 @@ -/* @internal */ +/* @internal */ namespace ts.FindAllReferences { - export function findReferencedSymbols(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] { + export function findReferencedSymbols(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, findInStrings: boolean, findInComments: boolean, isForRename: boolean): ReferencedSymbol[] | undefined { const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); - if (node === sourceFile) { - return undefined; - } - - switch (node.kind) { - case SyntaxKind.NumericLiteral: - if (!isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - break; - } - // Fallthrough - case SyntaxKind.Identifier: - case SyntaxKind.ThisKeyword: - // case SyntaxKind.SuperKeyword: TODO:GH#9268 - case SyntaxKind.ConstructorKeyword: - case SyntaxKind.StringLiteral: - return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, /*implementations*/false); - } - return undefined; + return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename); } - export function getReferencedSymbolsForNode(typeChecker: TypeChecker, cancellationToken: CancellationToken, node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean, implementations: boolean): ReferencedSymbol[] { + export function convertReferences(referenceSymbols: ReferencedSymbol[]): ReferenceEntry[] { + return referenceSymbols && flatMap(referenceSymbols, r => r.references); + } + + export function getReferencedSymbolsForNode(typeChecker: TypeChecker, cancellationToken: CancellationToken, node: Node, sourceFiles: SourceFile[], findInStrings?: boolean, findInComments?: boolean, isForRename?: boolean, implementations?: boolean): ReferencedSymbol[] | undefined { if (!implementations) { - // Labels - if (isLabelName(node)) { - if (isJumpStatementTarget(node)) { - const 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 (isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles); - } - - if (node.kind === SyntaxKind.SuperKeyword) { - return getReferencesForSuperKeyword(node); + const special = getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken); + if (special) { + return special; } } // `getSymbolAtLocation` normally returns the symbol of the class when given the constructor keyword, // so we have to specify that we want the constructor symbol. - const symbol = typeChecker.getSymbolAtLocation(node); - - if (!implementations && !symbol && node.kind === SyntaxKind.StringLiteral) { - return getReferencesForStringLiteral(node, sourceFiles); - } - + let symbol = typeChecker.getSymbolAtLocation(node); // Could not find a symbol e.g. unknown identifier if (!symbol) { + if (!implementations && node.kind === SyntaxKind.StringLiteral) { + return getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken); + } // Can't have references to something that we have no symbol for. return undefined; } @@ -69,11 +37,23 @@ namespace ts.FindAllReferences { return undefined; } - let result: ReferencedSymbol[]; + const { symbol: aliasedSymbol, shorthandModuleSymbol } = followAliases(symbol, node, typeChecker, isForRename); + symbol = aliasedSymbol; + + // Build the set of symbols to search for, initially it has only the current symbol + const searchSymbols = populateSearchSymbolSet(symbol, node, typeChecker, implementations); + if (shorthandModuleSymbol) { + searchSymbols.push(shorthandModuleSymbol); + } // Compute the meaning from the location and the symbol it references const searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); + const result: ReferencedSymbol[] = []; + // Maps from a symbol ID to the ReferencedSymbol entry in 'result'. + const symbolToIndex: number[] = []; + const inheritsFromCache: Map = createMap(); + // Get the text to search for. // Note: if this is an external module symbol, the name doesn't include quotes. const declaredName = stripQuotes(getDeclaredName(typeChecker, symbol, node)); @@ -81,1190 +61,1265 @@ namespace ts.FindAllReferences { // 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). const scope = getSymbolScope(symbol); - - // Maps from a symbol ID to the ReferencedSymbol entry in 'result'. - const symbolToIndex: number[] = []; - if (scope) { - result = []; - getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + getRefs(scope, declaredName); } else { - const internedName = getInternedName(symbol, node); + const isDefault = isExportDefaultSymbol(symbol); + const internedName = isDefault ? symbol.valueDeclaration.localSymbol.name : getInternedName(symbol, node); for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); - - const nameTable = getNameTable(sourceFile); - - if (nameTable[internedName] !== undefined) { - result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + const searchName = (isDefault ? getDefaultImportName(symbol, sourceFile, typeChecker) : undefined) || + (sourceFileHasName(sourceFile, internedName) ? declaredName : undefined); + if (searchName !== undefined) { + getRefs(sourceFile, searchName); } } } return result; - function getDefinition(symbol: Symbol): ReferencedSymbolDefinitionInfo { - const info = SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), getContainerNode(node), node); - const name = map(info.displayParts, p => p.text).join(""); - const declarations = symbol.declarations; - if (!declarations || declarations.length === 0) { - return undefined; - } - - return { - containerKind: "", - containerName: "", - name, - kind: info.symbolKind, - fileName: declarations[0].getSourceFile().fileName, - textSpan: createTextSpan(declarations[0].getStart(), 0), - displayParts: info.displayParts - }; - } - - function getAliasSymbolForPropertyNameSymbol(symbol: Symbol, location: Node): Symbol | undefined { - if (symbol.flags & SymbolFlags.Alias) { - // Default import get alias - const defaultImport = getDeclarationOfKind(symbol, SyntaxKind.ImportClause); - if (defaultImport) { - return typeChecker.getAliasedSymbol(symbol); - } - - const importOrExportSpecifier = forEach(symbol.declarations, - declaration => (declaration.kind === SyntaxKind.ImportSpecifier || - declaration.kind === SyntaxKind.ExportSpecifier) ? declaration : undefined); - if (importOrExportSpecifier && - // export { a } - (!importOrExportSpecifier.propertyName || - // export {a as class } where a is location - importOrExportSpecifier.propertyName === location)) { - // If Import specifier -> get alias - // else Export specifier -> get local target - return importOrExportSpecifier.kind === SyntaxKind.ImportSpecifier ? - typeChecker.getAliasedSymbol(symbol) : - typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); - } - } - return undefined; - } - - function followAliasIfNecessary(symbol: Symbol, location: Node): Symbol { - return getAliasSymbolForPropertyNameSymbol(symbol, location) || symbol; - } - - function getPropertySymbolOfDestructuringAssignment(location: Node) { - return isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - typeChecker.getPropertySymbolOfDestructuringAssignment(location); - } - - function isObjectBindingPatternElementWithoutPropertyName(symbol: Symbol) { - const bindingElement = getDeclarationOfKind(symbol, SyntaxKind.BindingElement); - return bindingElement && - bindingElement.parent.kind === SyntaxKind.ObjectBindingPattern && - !bindingElement.propertyName; - } - - function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol: Symbol) { - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - const bindingElement = getDeclarationOfKind(symbol, SyntaxKind.BindingElement); - const typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); - return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, (bindingElement.name).text); - } - return undefined; - } - - function getInternedName(symbol: Symbol, location: Node): string { - // 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 (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. - const localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol); - symbol = localExportDefaultSymbol || symbol; - - return 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: Symbol): Node { - // If this is the symbol of a named function expression or named class expression, - // then named references are limited to its own scope. - const valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === SyntaxKind.FunctionExpression || valueDeclaration.kind === SyntaxKind.ClassExpression)) { - return valueDeclaration; - } - - // If this is private property or method, the scope is the containing class - if (symbol.flags & (SymbolFlags.Property | SymbolFlags.Method)) { - const privateDeclaration = forEach(symbol.getDeclarations(), d => (getModifierFlags(d) & ModifierFlags.Private) ? d : undefined); - if (privateDeclaration) { - return getAncestor(privateDeclaration, SyntaxKind.ClassDeclaration); - } - } - - // If the symbol is an import we would like to find it if we are looking for what it imports. - // So consider it visible outside its declaration scope. - if (symbol.flags & SymbolFlags.Alias) { - return undefined; - } - - // If symbol is of object binding pattern element without property name we would want to - // look for property too and that could be anywhere - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - 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 & SymbolFlags.SyntheticProperty)) { - return undefined; - } - - let scope: Node; - - const declarations = symbol.getDeclarations(); - if (declarations) { - for (const declaration of declarations) { - const container = getContainerNode(declaration); - - if (!container) { - return undefined; - } - - if (scope && scope !== container) { - // Different declarations have different containers, bail out - return undefined; - } - - if (container.kind === SyntaxKind.SourceFile && !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: SourceFile, symbolName: string, start: number, end: number): number[] { - const positions: number[] = []; - - /// 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; - } - - const text = sourceFile.text; - const sourceLength = text.length; - const symbolNameLength = symbolName.length; - - let 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). - const endPosition = position + symbolNameLength; - - if ((position === 0 || !isIdentifierPart(text.charCodeAt(position - 1), ScriptTarget.Latest)) && - (endPosition === sourceLength || !isIdentifierPart(text.charCodeAt(endPosition), ScriptTarget.Latest))) { - // Found a real match. Keep searching. - positions.push(position); - } - position = text.indexOf(symbolName, position + symbolNameLength + 1); - } - - return positions; - } - - function getLabelReferencesInNode(container: Node, targetLabel: Identifier): ReferencedSymbol[] { - const references: ReferenceEntry[] = []; - const sourceFile = container.getSourceFile(); - const labelName = targetLabel.text; - const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); - forEach(possiblePositions, position => { - cancellationToken.throwIfCancellationRequested(); - - const node = 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)); - } - }); - - const definition: ReferencedSymbolDefinitionInfo = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ScriptElementKind.label, - name: labelName, - textSpan: createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()), - displayParts: [displayPart(labelName, SymbolDisplayPartKind.text)] - }; - - return [{ definition, references }]; - } - - function isValidReferencePosition(node: Node, searchSymbolName: string): boolean { - if (node) { - // Compare the length so we filter out strict superstrings of the symbol we are looking for - switch (node.kind) { - case SyntaxKind.Identifier: - return node.getWidth() === searchSymbolName.length; - - case SyntaxKind.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 SyntaxKind.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: Node, - searchSymbol: Symbol, - searchText: string, - searchLocation: Node, - searchMeaning: SemanticMeaning, - findInStrings: boolean, - findInComments: boolean, - result: ReferencedSymbol[], - symbolToIndex: number[]): void { - - const sourceFile = container.getSourceFile(); - - const start = findInComments ? container.getFullStart() : container.getStart(); - const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd()); - - const parents = getParentSymbolsOfPropertyAccess(); - const inheritsFromCache: Map = createMap(); - - if (possiblePositions.length) { - // Build the set of symbols to search for, initially it has only the current symbol - const searchSymbols = populateSearchSymbolSet(searchSymbol, searchLocation); - - forEach(possiblePositions, position => { - cancellationToken.throwIfCancellationRequested(); - - const referenceLocation = getTouchingPropertyName(sourceFile, position); - if (!isValidReferencePosition(referenceLocation, searchText)) { - // This wasn't the start of a token. Check to see if it might be a - // match in a comment or string if that's what the caller is asking - // for. - if (!implementations && ((findInStrings && isInString(sourceFile, position)) || - (findInComments && isInNonReferenceComment(sourceFile, position)))) { - - // In the case where we're looking inside comments/strings, we don't have - // an actual definition. So just use 'undefined' here. Features like - // 'Rename' won't care (as they ignore the definitions), and features like - // 'FindReferences' will just filter out these results. - result.push({ - definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] - }); - } - return; - } - - if (!(getMeaningFromLocation(referenceLocation) & searchMeaning)) { - return; - } - - const referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); - if (referenceSymbol) { - const referenceSymbolDeclaration = referenceSymbol.valueDeclaration; - const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, - /*searchLocationIsConstructor*/ searchLocation.kind === SyntaxKind.ConstructorKeyword, parents, inheritsFromCache); - - if (relatedSymbol) { - addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); - } - /* Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment - * has two meaning : property name and property value. Therefore when we do findAllReference at the position where - * an identifier is declared, the language service should return the position of the variable declaration as well as - * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the - * position of property accessing, the referenceEntry of such position will be handled in the first case. - */ - else if (!(referenceSymbol.flags & SymbolFlags.Transient) && searchSymbols.indexOf(shorthandValueSymbol) >= 0) { - addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); - } - else if (searchLocation.kind === SyntaxKind.ConstructorKeyword) { - findAdditionalConstructorReferences(referenceSymbol, referenceLocation); - } - } - }); - } - return; - - /* If we are just looking for implementations and this is a property access expression, we need to get the - * symbol of the local type of the symbol the property is being accessed on. This is because our search - * symbol may have a different parent symbol if the local type's symbol does not declare the property - * being accessed (i.e. it is declared in some parent class or interface) - */ - function getParentSymbolsOfPropertyAccess(): Symbol[] | undefined { - if (implementations) { - const propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); - if (propertyAccessExpression) { - const localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); - if (localParentType) { - if (localParentType.symbol && localParentType.symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) && localParentType.symbol !== searchSymbol.parent) { - return [localParentType.symbol]; - } - else if (localParentType.flags & TypeFlags.UnionOrIntersection) { - return getSymbolsForClassAndInterfaceComponents(localParentType); - } - } - } - } - } - - function getPropertyAccessExpressionFromRightHandSide(node: Node): PropertyAccessExpression { - return isRightSideOfPropertyAccess(node) && node.parent; - } - - /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ - function findAdditionalConstructorReferences(referenceSymbol: Symbol, referenceLocation: Node): void { - Debug.assert(isClassLike(searchSymbol.valueDeclaration)); - - const referenceClass = referenceLocation.parent; - if (referenceSymbol === searchSymbol && isClassLike(referenceClass)) { - Debug.assert(referenceClass.name === referenceLocation); - // This is the class declaration containing the constructor. - addReferences(findOwnConstructorCalls(searchSymbol)); - } - else { - // If this class appears in `extends C`, then the extending class' "super" calls are references. - const classExtending = tryGetClassByExtendingIdentifier(referenceLocation); - if (classExtending && isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation) === searchSymbol) { - addReferences(superConstructorAccesses(classExtending)); - } - } - } - - function addReferences(references: Node[]): void { - if (references.length) { - const referencedSymbol = getReferencedSymbol(searchSymbol); - addRange(referencedSymbol.references, map(references, getReferenceEntryFromNode)); - } - } - - /** `classSymbol` is the class where the constructor was defined. - * Reference the constructor and all calls to `new this()`. - */ - function findOwnConstructorCalls(classSymbol: Symbol): Node[] { - const result: Node[] = []; - - for (const decl of classSymbol.members["__constructor"].declarations) { - Debug.assert(decl.kind === SyntaxKind.Constructor); - const ctrKeyword = decl.getChildAt(0); - Debug.assert(ctrKeyword.kind === SyntaxKind.ConstructorKeyword); - result.push(ctrKeyword); - } - - forEachProperty(classSymbol.exports, member => { - const decl = member.valueDeclaration; - if (decl && decl.kind === SyntaxKind.MethodDeclaration) { - const body = (decl).body; - if (body) { - forEachDescendantOfKind(body, SyntaxKind.ThisKeyword, thisKeyword => { - if (isNewExpressionTarget(thisKeyword)) { - result.push(thisKeyword); - } - }); - } - } - }); - - return result; - } - - /** Find references to `super` in the constructor of an extending class. */ - function superConstructorAccesses(cls: ClassLikeDeclaration): Node[] { - const symbol = cls.symbol; - const ctr = symbol.members["__constructor"]; - if (!ctr) { - return []; - } - - const result: Node[] = []; - for (const decl of ctr.declarations) { - Debug.assert(decl.kind === SyntaxKind.Constructor); - const body = (decl).body; - if (body) { - forEachDescendantOfKind(body, SyntaxKind.SuperKeyword, node => { - if (isCallExpressionTarget(node)) { - result.push(node); - } - }); - } - }; - return result; - } - - function getReferencedSymbol(symbol: Symbol): ReferencedSymbol { - const symbolId = getSymbolId(symbol); - let index = symbolToIndex[symbolId]; - if (index === undefined) { - index = result.length; - symbolToIndex[symbolId] = index; - - result.push({ - definition: getDefinition(symbol), - references: [] - }); - } - - return result[index]; - } - - function addReferenceToRelatedSymbol(node: Node, relatedSymbol: Symbol) { - const references = getReferencedSymbol(relatedSymbol).references; - if (implementations) { - getImplementationReferenceEntryForNode(node, references); - } - else { - references.push(getReferenceEntryFromNode(node)); - } - } - } - - function getImplementationReferenceEntryForNode(refNode: Node, result: ReferenceEntry[]): void { - // Check if we found a function/propertyAssignment/method with an implementation or initializer - if (isDeclarationName(refNode) && isImplementation(refNode.parent)) { - result.push(getReferenceEntryFromNode(refNode.parent)); - } - else if (refNode.kind === SyntaxKind.Identifier) { - if (refNode.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { - // Go ahead and dereference the shorthand assignment by going to its definition - getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); - } - - // Check if the node is within an extends or implements clause - const containingClass = getContainingClassIfInHeritageClause(refNode); - if (containingClass) { - result.push(getReferenceEntryFromNode(containingClass)); - return; - } - - // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface - const containingTypeReference = getContainingTypeReference(refNode); - if (containingTypeReference) { - const parent = containingTypeReference.parent; - if (isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent.initializer)); - } - else if (isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { - if (parent.body.kind === SyntaxKind.Block) { - forEachReturnStatement(parent.body, returnStatement => { - if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { - maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); - } - }); - } - else if (isImplementationExpression(parent.body)) { - maybeAdd(getReferenceEntryFromNode(parent.body)); - } - } - else if (isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { - maybeAdd(getReferenceEntryFromNode(parent.expression)); - } - } - } - - // Type nodes can contain multiple references to the same type. For example: - // let x: Foo & (Foo & Bar) = ... - // Because we are returning the implementation locations and not the identifier locations, - // duplicate entries would be returned here as each of the type references is part of - // the same implementation. For that reason, check before we add a new entry - function maybeAdd(a: ReferenceEntry) { - if (!forEach(result, b => a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length)) { - result.push(a); - } - } - } - - function getSymbolsForClassAndInterfaceComponents(type: UnionOrIntersectionType, result: Symbol[] = []): Symbol[] { - for (const componentType of type.types) { - if (componentType.symbol && componentType.symbol.getFlags() & (SymbolFlags.Class | SymbolFlags.Interface)) { - result.push(componentType.symbol); - } - if (componentType.getFlags() & TypeFlags.UnionOrIntersection) { - getSymbolsForClassAndInterfaceComponents(componentType, result); - } - } - return result; - } - - function getContainingTypeReference(node: Node): Node { - let topLevelTypeReference: Node = undefined; - - while (node) { - if (isTypeNode(node)) { - topLevelTypeReference = node; - } - node = node.parent; - } - - return topLevelTypeReference; - } - - function getContainingClassIfInHeritageClause(node: Node): ClassLikeDeclaration { - if (node && node.parent) { - if (node.kind === SyntaxKind.ExpressionWithTypeArguments - && node.parent.kind === SyntaxKind.HeritageClause - && isClassLike(node.parent.parent)) { - return node.parent.parent; - } - - else if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.PropertyAccessExpression) { - return getContainingClassIfInHeritageClause(node.parent); - } - } - return undefined; - } - - /** - * Returns true if this is an expression that can be considered an implementation - */ - function isImplementationExpression(node: Expression): boolean { - // Unwrap parentheses - if (node.kind === SyntaxKind.ParenthesizedExpression) { - return isImplementationExpression((node).expression); - } - - return node.kind === SyntaxKind.ArrowFunction || - node.kind === SyntaxKind.FunctionExpression || - node.kind === SyntaxKind.ObjectLiteralExpression || - node.kind === SyntaxKind.ClassExpression || - node.kind === SyntaxKind.ArrayLiteralExpression; - } - - /** - * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol - * is an interface, determines if some ancestor of the child symbol extends or inherits from it. - * Also takes in a cache of previous results which makes this slightly more efficient and is - * necessary to avoid potential loops like so: - * class A extends B { } - * class B extends A { } - * - * We traverse the AST rather than using the type checker because users are typically only interested - * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling - * implementations of types that share a common ancestor with the type whose implementation we are - * searching for need to be filtered out of the results. The type checker doesn't let us make the - * distinction between structurally compatible implementations and explicit implementations, so we - * must use the AST. - * - * @param child A class or interface Symbol - * @param parent Another class or interface Symbol - * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results - */ - function explicitlyInheritsFrom(child: Symbol, parent: Symbol, cachedResults: Map): boolean { - const parentIsInterface = parent.getFlags() & SymbolFlags.Interface; - return searchHierarchy(child); - - function searchHierarchy(symbol: Symbol): boolean { - if (symbol === parent) { - return true; - } - - const key = getSymbolId(symbol) + "," + getSymbolId(parent); - if (key in cachedResults) { - return cachedResults[key]; - } - - // Set the key so that we don't infinitely recurse - cachedResults[key] = false; - - const inherits = forEach(symbol.getDeclarations(), declaration => { - if (isClassLike(declaration)) { - if (parentIsInterface) { - const interfaceReferences = getClassImplementsHeritageClauseElements(declaration); - if (interfaceReferences) { - for (const typeReference of interfaceReferences) { - if (searchTypeReference(typeReference)) { - return true; - } - } - } - } - return searchTypeReference(getClassExtendsHeritageClauseElement(declaration)); - } - else if (declaration.kind === SyntaxKind.InterfaceDeclaration) { - if (parentIsInterface) { - return forEach(getInterfaceBaseTypeNodes(declaration), searchTypeReference); - } - } - return false; - }); - - cachedResults[key] = inherits; - return inherits; - } - - function searchTypeReference(typeReference: ExpressionWithTypeArguments): boolean { - if (typeReference) { - const type = typeChecker.getTypeAtLocation(typeReference); - if (type && type.symbol) { - return searchHierarchy(type.symbol); - } - } - return false; - } - } - - function getReferencesForSuperKeyword(superKeyword: Node): ReferencedSymbol[] { - let searchSpaceNode = getSuperContainer(superKeyword, /*stopOnFunctions*/ false); - if (!searchSpaceNode) { - return undefined; - } - // Whether 'super' occurs in a static context within a class. - let staticFlag = ModifierFlags.Static; - - switch (searchSpaceNode.kind) { - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.Constructor: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - staticFlag &= getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class - break; - default: - return undefined; - } - - const references: ReferenceEntry[] = []; - - const sourceFile = searchSpaceNode.getSourceFile(); - const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - forEach(possiblePositions, position => { - cancellationToken.throwIfCancellationRequested(); - - const node = getTouchingWord(sourceFile, position); - - if (!node || node.kind !== SyntaxKind.SuperKeyword) { - return; - } - - const container = getSuperContainer(node, /*stopOnFunctions*/ 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 && (ModifierFlags.Static & getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); - } - }); - - const definition = getDefinition(searchSpaceNode.symbol); - return [{ definition, references }]; - } - - function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: SourceFile[]): ReferencedSymbol[] { - let searchSpaceNode = getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); - - // Whether 'this' occurs in a static context within a class. - let staticFlag = ModifierFlags.Static; - - switch (searchSpaceNode.kind) { - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - if (isObjectLiteralMethod(searchSpaceNode)) { - break; - } - // fall through - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - case SyntaxKind.Constructor: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - staticFlag &= getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class - break; - case SyntaxKind.SourceFile: - if (isExternalModule(searchSpaceNode)) { - return undefined; - } - // Fall through - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.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; - } - - const references: ReferenceEntry[] = []; - - let possiblePositions: number[]; - if (searchSpaceNode.kind === SyntaxKind.SourceFile) { - forEach(sourceFiles, sourceFile => { - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); - }); - } - else { - const sourceFile = searchSpaceNode.getSourceFile(); - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); - } - - const thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); - - const displayParts = thisOrSuperSymbol && SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind( - typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; - - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ScriptElementKind.variableElement, - name: "this", - textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts - }, - references: references - }]; - - function getThisReferencesInFile(sourceFile: SourceFile, searchSpaceNode: Node, possiblePositions: number[], result: ReferenceEntry[]): void { - forEach(possiblePositions, position => { - cancellationToken.throwIfCancellationRequested(); - - const node = getTouchingWord(sourceFile, position); - if (!node || !isThis(node)) { - return; - } - - const container = getThisContainer(node, /* includeArrowFunctions */ false); - - switch (searchSpaceNode.kind) { - case SyntaxKind.FunctionExpression: - case SyntaxKind.FunctionDeclaration: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - if (isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case SyntaxKind.ClassExpression: - case SyntaxKind.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 && (getModifierFlags(container) & ModifierFlags.Static) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case SyntaxKind.SourceFile: - if (container.kind === SyntaxKind.SourceFile && !isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); - } - } - - - function getReferencesForStringLiteral(node: StringLiteral, sourceFiles: SourceFile[]): ReferencedSymbol[] { - const type = getStringLiteralTypeForNode(node, typeChecker); - - if (!type) { - // nothing to do here. moving on - return undefined; - } - - const references: ReferenceEntry[] = []; - - for (const sourceFile of sourceFiles) { - const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd()); - getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); - } - - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ScriptElementKind.variableElement, - name: type.text, - textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: [displayPart(getTextOfNode(node), SymbolDisplayPartKind.stringLiteral)] - }, - references: references - }]; - - function getReferencesForStringLiteralInFile(sourceFile: SourceFile, searchType: Type, possiblePositions: number[], references: ReferenceEntry[]): void { - for (const position of possiblePositions) { - cancellationToken.throwIfCancellationRequested(); - - const node = getTouchingWord(sourceFile, position); - if (!node || node.kind !== SyntaxKind.StringLiteral) { - return; - } - - const type = getStringLiteralTypeForNode(node, typeChecker); - if (type === searchType) { - references.push(getReferenceEntryFromNode(node)); - } - } - } - } - - function populateSearchSymbolSet(symbol: Symbol, location: Node): Symbol[] { - // The search set contains at least the current symbol - let result = [symbol]; - - // If the location is name of property symbol from object literal destructuring pattern - // Search the property symbol - // for ( { property: p2 } of elems) { } - const containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== SyntaxKind.ShorthandPropertyAssignment) { - const propertySymbol = getPropertySymbolOfDestructuringAssignment(location); - if (propertySymbol) { - result.push(propertySymbol); - } - } - - // If the symbol is an alias, add what it aliases to the list - // import {a} from "mod"; - // export {a} - // If the symbol is an alias to default declaration, add what it aliases to the list - // declare "mod" { export default class B { } } - // import B from "mod"; - //// For export specifiers, the exported name can be referring to a local symbol, e.g.: - //// import {a} from "mod"; - //// export {a as somethingElse} - //// We want the *local* declaration of 'a' as declared in the import, - //// *not* as declared within "mod" (or farther) - const aliasSymbol = getAliasSymbolForPropertyNameSymbol(symbol, location); - if (aliasSymbol) { - result = result.concat(populateSearchSymbolSet(aliasSymbol, location)); - } - - // 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 (containingObjectLiteralElement) { - forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), contextualSymbol => { - 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 - * const name = "Foo"; - * const 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. - */ - const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); - if (shorthandValueSymbol) { - result.push(shorthandValueSymbol); - } - } - - // If the symbol.valueDeclaration is a property parameter declaration, - // we should include both parameter declaration symbol and property declaration symbol - // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. - // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === SyntaxKind.Parameter && - isParameterPropertyDeclaration(symbol.valueDeclaration)) { - result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); - } - - // If this is symbol of binding element without propertyName declaration in Object binding pattern - // Include the property in the search - const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol); - if (bindingElementPropertySymbol) { - result.push(bindingElementPropertySymbol); - } - - // 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 - forEach(typeChecker.getRootSymbols(symbol), rootSymbol => { - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - - // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap()); - } - }); - - return result; - } - - /** - * Find symbol of the given property-name and add the symbol to the given result array - * @param symbol a symbol to start searching for the given propertyName - * @param propertyName a name of property to search for - * @param result an array of symbol of found property symbols - * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. - * The value of previousIterationSymbol is undefined when the function is first called. - */ - function getPropertySymbolsFromBaseTypes(symbol: Symbol, propertyName: string, result: Symbol[], - previousIterationSymbolsCache: SymbolTable): void { - if (!symbol) { - return; - } - - // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited - // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. - // For example: - // interface C extends C { - // /*findRef*/propName: string; - // } - // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, - // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, - // the function will add any found symbol of the property-name, then its sub-routine will call - // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already - // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. - if (symbol.name in previousIterationSymbolsCache) { - return; - } - - if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - forEach(symbol.getDeclarations(), declaration => { - if (isClassLike(declaration)) { - getPropertySymbolFromTypeReference(getClassExtendsHeritageClauseElement(declaration)); - forEach(getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === SyntaxKind.InterfaceDeclaration) { - forEach(getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); - } - }); - } - return; - - function getPropertySymbolFromTypeReference(typeReference: ExpressionWithTypeArguments) { - if (typeReference) { - const type = typeChecker.getTypeAtLocation(typeReference); - if (type) { - const propertySymbol = typeChecker.getPropertyOfType(type, propertyName); - if (propertySymbol) { - result.push(...typeChecker.getRootSymbols(propertySymbol)); - } - - // Visit the typeReference as well to see if it directly or indirectly use that property - previousIterationSymbolsCache[symbol.name] = symbol; - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache); - } - } - } - } - - function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node, searchLocationIsConstructor: boolean, parents: Symbol[] | undefined, cache: Map): Symbol { - if (contains(searchSymbols, referenceSymbol)) { - // If we are searching for constructor uses, they must be 'new' expressions. - return (!searchLocationIsConstructor || isNewExpressionTarget(referenceLocation)) && referenceSymbol; - } - - // If the reference symbol is an alias, check if what it is aliasing is one of the search - // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. - const aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation); - if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache); - } - - // 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 - const containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation); - if (containingObjectLiteralElement) { - const contextualSymbol = forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), contextualSymbol => { - return forEach(typeChecker.getRootSymbols(contextualSymbol), s => searchSymbols.indexOf(s) >= 0 ? s : undefined); - }); - - if (contextualSymbol) { - return contextualSymbol; - } - - // If the reference location is the name of property from object literal destructuring pattern - // Get the property symbol from the object literal's type and look if thats the search symbol - // In below eg. get 'property' from type of elems iterating type - // for ( { property: p2 } of elems) { } - const propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation); - if (propertySymbol && searchSymbols.indexOf(propertySymbol) >= 0) { - return propertySymbol; - } - } - - // If the reference location is the binding element and doesn't have property name - // then include the binding element in the related symbols - // let { a } : { a }; - const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol); - if (bindingElementPropertySymbol && searchSymbols.indexOf(bindingElementPropertySymbol) >= 0) { - return bindingElementPropertySymbol; - } - - // 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 forEach(typeChecker.getRootSymbols(referenceSymbol), 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 we were passed a parent symbol, only include types that are subtypes of the - // parent symbol - if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - // Parents will only be defined if implementations is true - if (parents) { - if (!forEach(parents, parent => explicitlyInheritsFrom(rootSymbol.parent, parent, cache))) { - return undefined; - } - } - - const result: Symbol[] = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap()); - return forEach(result, s => searchSymbols.indexOf(s) >= 0 ? s : undefined); - } - - return undefined; - }); - } - - function getNameFromObjectLiteralElement(node: ObjectLiteralElement) { - if (node.name.kind === SyntaxKind.ComputedPropertyName) { - const nameExpression = (node.name).expression; - // treat computed property names where expression is string/numeric literal as just string/numeric literal - if (isStringOrNumericLiteral(nameExpression)) { - return (nameExpression).text; - } - return undefined; - } - return (node.name).text; - } - - function getPropertySymbolsFromContextualType(node: ObjectLiteralElement): Symbol[] { - const objectLiteral = node.parent; - const contextualType = typeChecker.getContextualType(objectLiteral); - const name = getNameFromObjectLiteralElement(node); - if (name && contextualType) { - const result: Symbol[] = []; - const symbol = contextualType.getProperty(name); - if (symbol) { - result.push(symbol); - } - - if (contextualType.flags & TypeFlags.Union) { - forEach((contextualType).types, t => { - const symbol = t.getProperty(name); - if (symbol) { - result.push(symbol); - } - }); - } - return result; - } - 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: SemanticMeaning, declarations: Declaration[]): SemanticMeaning { - if (declarations) { - let lastIterationMeaning: SemanticMeaning; - 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 (const declaration of declarations) { - const declarationMeaning = getMeaningFromDeclaration(declaration); - - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; - } - } - } - while (meaning !== lastIterationMeaning); - } - return meaning; + function getRefs(scope: ts.Node, searchName: string): void { + getReferencesInNode(scope, symbol, searchName, node, searchMeaning, findInStrings, findInComments, result, + symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache); } } - export function convertReferences(referenceSymbols: ReferencedSymbol[]): ReferenceEntry[] { - if (!referenceSymbols) { + /** getReferencedSymbols for special node kinds. */ + function getReferencedSymbolsSpecial(node: Node, sourceFiles: SourceFile[], typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] | undefined { + if (isTypeKeyword(node.kind)) { + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + } + + // Labels + if (isLabelName(node)) { + if (isJumpStatementTarget(node)) { + const 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, cancellationToken); + } + else { + // it is a label definition and not a target, search within the parent labeledStatement + return getLabelReferencesInNode(node.parent, node, cancellationToken); + } + } + + if (isThis(node)) { + return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken); + } + + if (node.kind === SyntaxKind.SuperKeyword) { + return getReferencesForSuperKeyword(node, typeChecker, cancellationToken); + } + + return undefined; + } + + /** + * Follows aliases to get to the original declaration of a symbol. + * For a shorthand ambient module, we don't follow the alias to it, but we will need to add it to the set of search symbols. + */ + function followAliases(symbol: Symbol, node: Node, typeChecker: TypeChecker, isForRename: boolean): { symbol: Symbol, shorthandModuleSymbol?: Symbol } { + while (true) { + // When renaming a default import, only rename in the current file + if (isForRename && isImportDefaultSymbol(symbol)) { + return { symbol }; + } + + const aliasedSymbol = getAliasSymbolForPropertyNameSymbol(symbol, node, typeChecker); + // Don't follow alias if it goes to unknown symbol. This can happen if it points to an untyped module. + if (!aliasedSymbol || !aliasedSymbol.declarations) { + return { symbol }; + } + + if (ts.isShorthandAmbientModuleSymbol(aliasedSymbol)) { + return { symbol, shorthandModuleSymbol: aliasedSymbol }; + } + + symbol = aliasedSymbol; + } + } + + function sourceFileHasName(sourceFile: SourceFile, name: string): boolean { + return getNameTable(sourceFile).get(name) !== undefined; + } + + /** + * Given a symbol, see if any of the imports in a source file reference it. + * Only call this if `symbol` is a default export. + */ + function getDefaultImportName(symbol: Symbol, sourceFile: SourceFile, checker: ts.TypeChecker): string | undefined { + for (const importSpecifier of sourceFile.imports) { + const importDecl = importSpecifier.parent as ts.ImportDeclaration; + Debug.assert(importDecl.moduleSpecifier === importSpecifier); + const defaultName = importDecl.importClause.name; + const defaultReferencedSymbol = defaultName && checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName)); + if (symbol === defaultReferencedSymbol) { + return defaultName.text; + } + } + return undefined; + } + + function getDefinition(symbol: Symbol, node: Node, typeChecker: TypeChecker): ReferencedSymbolDefinitionInfo { + const { displayParts, symbolKind } = SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), getContainerNode(node), node); + const name = displayParts.map(p => p.text).join(""); + const declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { return undefined; } - const referenceEntries: ReferenceEntry[] = []; + return { + containerKind: "", + containerName: "", + name, + kind: symbolKind, + fileName: declarations[0].getSourceFile().fileName, + textSpan: createTextSpan(declarations[0].getStart(), 0), + displayParts + }; + } - for (const referenceSymbol of referenceSymbols) { - addRange(referenceEntries, referenceSymbol.references); + function getAliasSymbolForPropertyNameSymbol(symbol: Symbol, location: Node, typeChecker: TypeChecker): Symbol | undefined { + if (!(symbol.flags & SymbolFlags.Alias)) { + return undefined; } - return referenceEntries; + // Default import get alias + const defaultImport = getDeclarationOfKind(symbol, SyntaxKind.ImportClause); + if (defaultImport) { + return typeChecker.getAliasedSymbol(symbol); + } + + const importOrExportSpecifier = forEach(symbol.declarations, + declaration => (declaration.kind === SyntaxKind.ImportSpecifier || + declaration.kind === SyntaxKind.ExportSpecifier) ? declaration : undefined); + if (importOrExportSpecifier && + // export { a } + (!importOrExportSpecifier.propertyName || + // export {a as class } where a is location + importOrExportSpecifier.propertyName === location)) { + // If Import specifier -> get alias + // else Export specifier -> get local target + return importOrExportSpecifier.kind === SyntaxKind.ImportSpecifier ? + typeChecker.getAliasedSymbol(symbol) : + typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); + } + } + + function followAliasIfNecessary(symbol: Symbol, location: Node, typeChecker: TypeChecker): Symbol { + return getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) || symbol; + } + + function getPropertySymbolOfDestructuringAssignment(location: Node, typeChecker: TypeChecker) { + return isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && + typeChecker.getPropertySymbolOfDestructuringAssignment(location); + } + + function isObjectBindingPatternElementWithoutPropertyName(symbol: Symbol) { + const bindingElement = getDeclarationOfKind(symbol, SyntaxKind.BindingElement); + return bindingElement && + bindingElement.parent.kind === SyntaxKind.ObjectBindingPattern && + !bindingElement.propertyName; + } + + function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol: Symbol, typeChecker: TypeChecker) { + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + const bindingElement = getDeclarationOfKind(symbol, SyntaxKind.BindingElement); + const typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); + return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, (bindingElement.name).text); + } + return undefined; + } + + function getInternedName(symbol: Symbol, location: Node): string { + // 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 (isImportOrExportSpecifierName(location)) { + return location.text; + } + + return 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: Symbol): Node { + // If this is the symbol of a named function expression or named class expression, + // then named references are limited to its own scope. + const valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && (valueDeclaration.kind === SyntaxKind.FunctionExpression || valueDeclaration.kind === SyntaxKind.ClassExpression)) { + return valueDeclaration; + } + + // If this is private property or method, the scope is the containing class + if (symbol.flags & (SymbolFlags.Property | SymbolFlags.Method)) { + const privateDeclaration = forEach(symbol.getDeclarations(), d => (getModifierFlags(d) & ModifierFlags.Private) ? d : undefined); + if (privateDeclaration) { + return getAncestor(privateDeclaration, SyntaxKind.ClassDeclaration); + } + } + + // If the symbol is an import we would like to find it if we are looking for what it imports. + // So consider it visible outside its declaration scope. + if (symbol.flags & SymbolFlags.Alias) { + return undefined; + } + + // If symbol is of object binding pattern element without property name we would want to + // look for property too and that could be anywhere + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + 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 & SymbolFlags.Transient && (symbol).checkFlags & CheckFlags.SyntheticProperty)) { + return undefined; + } + + let scope: Node; + + const declarations = symbol.getDeclarations(); + if (declarations) { + for (const declaration of declarations) { + const container = getContainerNode(declaration); + + if (!container) { + return undefined; + } + + if (scope && scope !== container) { + // Different declarations have different containers, bail out + return undefined; + } + + if (container.kind === SyntaxKind.SourceFile && !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: SourceFile, symbolName: string, start: number, end: number, cancellationToken: CancellationToken): number[] { + const positions: number[] = []; + + /// 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; + } + + const text = sourceFile.text; + const sourceLength = text.length; + const symbolNameLength = symbolName.length; + + let 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). + const endPosition = position + symbolNameLength; + + if ((position === 0 || !isIdentifierPart(text.charCodeAt(position - 1), ScriptTarget.Latest)) && + (endPosition === sourceLength || !isIdentifierPart(text.charCodeAt(endPosition), ScriptTarget.Latest))) { + // Found a real match. Keep searching. + positions.push(position); + } + position = text.indexOf(symbolName, position + symbolNameLength + 1); + } + + return positions; + } + + function getLabelReferencesInNode(container: Node, targetLabel: Identifier, cancellationToken: CancellationToken): ReferencedSymbol[] { + const references: ReferenceEntry[] = []; + const sourceFile = container.getSourceFile(); + const labelName = targetLabel.text; + const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd(), cancellationToken); + forEach(possiblePositions, position => { + cancellationToken.throwIfCancellationRequested(); + + const node = 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)); + } + }); + + const definition: ReferencedSymbolDefinitionInfo = { + containerKind: "", + containerName: "", + fileName: targetLabel.getSourceFile().fileName, + kind: ScriptElementKind.label, + name: labelName, + textSpan: createTextSpanFromNode(targetLabel, sourceFile), + displayParts: [displayPart(labelName, SymbolDisplayPartKind.text)] + }; + + return [{ definition, references }]; + } + + function isValidReferencePosition(node: Node, searchSymbolName: string): boolean { + // Compare the length so we filter out strict superstrings of the symbol we are looking for + switch (node && node.kind) { + case SyntaxKind.Identifier: + return node.getWidth() === searchSymbolName.length; + + case SyntaxKind.StringLiteral: + return (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && + // For string literals we have two additional chars for the quotes + node.getWidth() === searchSymbolName.length + 2; + + case SyntaxKind.NumericLiteral: + return isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; + + default: + return false; + } + } + + function getAllReferencesForKeyword(sourceFiles: SourceFile[], keywordKind: ts.SyntaxKind, cancellationToken: CancellationToken): ReferencedSymbol[] { + const name = tokenToString(keywordKind); + const references: ReferenceEntry[] = []; + for (const sourceFile of sourceFiles) { + cancellationToken.throwIfCancellationRequested(); + addReferencesForKeywordInFile(sourceFile, keywordKind, name, cancellationToken, references); + } + + if (!references.length) return undefined; + + const definition: ReferencedSymbolDefinitionInfo = { + containerKind: "", + containerName: "", + fileName: references[0].fileName, + kind: ScriptElementKind.keyword, + name, + textSpan: references[0].textSpan, + displayParts: [{ text: name, kind: ScriptElementKind.keyword }] + } + + return [{ definition, references }]; + } + + function addReferencesForKeywordInFile(sourceFile: SourceFile, kind: SyntaxKind, searchText: string, cancellationToken: CancellationToken, references: Push): void { + const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + for (const position of possiblePositions) { + cancellationToken.throwIfCancellationRequested(); + const referenceLocation = getTouchingPropertyName(sourceFile, position); + if (referenceLocation.kind === kind) { + references.push({ + textSpan: createTextSpanFromNode(referenceLocation), + fileName: sourceFile.fileName, + isWriteAccess: false, + isDefinition: 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: Node, + searchSymbol: Symbol, + searchText: string, + searchLocation: Node, + searchMeaning: SemanticMeaning, + findInStrings: boolean, + findInComments: boolean, + result: ReferencedSymbol[], + symbolToIndex: number[], + implementations: boolean, + typeChecker: TypeChecker, + cancellationToken: CancellationToken, + searchSymbols: Symbol[], + inheritsFromCache: Map): void { + + const sourceFile = container.getSourceFile(); + + const start = findInComments ? container.getFullStart() : container.getStart(); + const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd(), cancellationToken); + + const parents = getParentSymbolsOfPropertyAccess(); + + for (const position of possiblePositions) { + cancellationToken.throwIfCancellationRequested(); + + const referenceLocation = getTouchingPropertyName(sourceFile, position); + if (!isValidReferencePosition(referenceLocation, searchText)) { + // This wasn't the start of a token. Check to see if it might be a + // match in a comment or string if that's what the caller is asking + // for. + if (!implementations && ((findInStrings && isInString(sourceFile, position)) || + (findInComments && isInNonReferenceComment(sourceFile, position)))) { + + // In the case where we're looking inside comments/strings, we don't have + // an actual definition. So just use 'undefined' here. Features like + // 'Rename' won't care (as they ignore the definitions), and features like + // 'FindReferences' will just filter out these results. + result.push({ + definition: undefined, + references: [{ + fileName: sourceFile.fileName, + textSpan: createTextSpan(position, searchText.length), + isWriteAccess: false, + isDefinition: false + }] + }); + } + continue; + } + + if (!(getMeaningFromLocation(referenceLocation) & searchMeaning)) { + continue; + } + + const referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); + if (referenceSymbol) { + const referenceSymbolDeclaration = referenceSymbol.valueDeclaration; + const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); + const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, + /*searchLocationIsConstructor*/ searchLocation.kind === SyntaxKind.ConstructorKeyword, parents, inheritsFromCache, typeChecker); + + if (relatedSymbol) { + addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); + } + /* Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment + * has two meanings: property name and property value. Therefore when we do findAllReference at the position where + * an identifier is declared, the language service should return the position of the variable declaration as well as + * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the + * position of property accessing, the referenceEntry of such position will be handled in the first case. + */ + else if (!(referenceSymbol.flags & SymbolFlags.Transient) && contains(searchSymbols, shorthandValueSymbol)) { + addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); + } + else if (searchLocation.kind === SyntaxKind.ConstructorKeyword) { + findAdditionalConstructorReferences(referenceSymbol, referenceLocation); + } + } + } + return; + + /* If we are just looking for implementations and this is a property access expression, we need to get the + * symbol of the local type of the symbol the property is being accessed on. This is because our search + * symbol may have a different parent symbol if the local type's symbol does not declare the property + * being accessed (i.e. it is declared in some parent class or interface) + */ + function getParentSymbolsOfPropertyAccess(): Symbol[] | undefined { + if (implementations) { + const propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); + if (propertyAccessExpression) { + const localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); + if (localParentType) { + if (localParentType.symbol && localParentType.symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) && localParentType.symbol !== searchSymbol.parent) { + return [localParentType.symbol]; + } + else if (localParentType.flags & TypeFlags.UnionOrIntersection) { + return getSymbolsForClassAndInterfaceComponents(localParentType); + } + } + } + } + } + + /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ + function findAdditionalConstructorReferences(referenceSymbol: Symbol, referenceLocation: Node): void { + Debug.assert(isClassLike(searchSymbol.valueDeclaration)); + + const referenceClass = referenceLocation.parent; + if (referenceSymbol === searchSymbol && isClassLike(referenceClass)) { + Debug.assert(referenceClass.name === referenceLocation); + // This is the class declaration containing the constructor. + addReferences(findOwnConstructorCalls(searchSymbol, sourceFile)); + } + else { + // If this class appears in `extends C`, then the extending class' "super" calls are references. + const classExtending = tryGetClassByExtendingIdentifier(referenceLocation); + if (classExtending && isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation, typeChecker) === searchSymbol) { + addReferences(superConstructorAccesses(classExtending)); + } + } + } + + function addReferences(references: Node[]): void { + if (references.length) { + const referencedSymbol = getReferencedSymbol(searchSymbol); + addRange(referencedSymbol.references, map(references, getReferenceEntryFromNode)); + } + } + + function getReferencedSymbol(symbol: Symbol): ReferencedSymbol { + const symbolId = getSymbolId(symbol); + let index = symbolToIndex[symbolId]; + if (index === undefined) { + index = result.length; + symbolToIndex[symbolId] = index; + + result.push({ + definition: getDefinition(symbol, searchLocation, typeChecker), + references: [] + }); + } + + return result[index]; + } + + function addReferenceToRelatedSymbol(node: Node, relatedSymbol: Symbol) { + const references = getReferencedSymbol(relatedSymbol).references; + if (implementations) { + getImplementationReferenceEntryForNode(node, references, typeChecker); + } + else { + references.push(getReferenceEntryFromNode(node)); + } + } + } + + function getPropertyAccessExpressionFromRightHandSide(node: Node): PropertyAccessExpression { + return isRightSideOfPropertyAccess(node) && node.parent; + } + + /** `classSymbol` is the class where the constructor was defined. + * Reference the constructor and all calls to `new this()`. + */ + function findOwnConstructorCalls(classSymbol: Symbol, sourceFile: SourceFile): Node[] { + const result: Node[] = []; + + for (const decl of classSymbol.members.get("__constructor").declarations) { + const ctrKeyword = ts.findChildOfKind(decl, ts.SyntaxKind.ConstructorKeyword, sourceFile)! + Debug.assert(decl.kind === SyntaxKind.Constructor && !!ctrKeyword); + result.push(ctrKeyword); + } + + classSymbol.exports.forEach(member => { + const decl = member.valueDeclaration; + if (decl && decl.kind === SyntaxKind.MethodDeclaration) { + const body = (decl).body; + if (body) { + forEachDescendantOfKind(body, SyntaxKind.ThisKeyword, thisKeyword => { + if (isNewExpressionTarget(thisKeyword)) { + result.push(thisKeyword); + } + }); + } + } + }); + + return result; + } + + /** Find references to `super` in the constructor of an extending class. */ + function superConstructorAccesses(cls: ClassLikeDeclaration): Node[] { + const symbol = cls.symbol; + const ctr = symbol.members.get("__constructor"); + if (!ctr) { + return []; + } + + const result: Node[] = []; + for (const decl of ctr.declarations) { + Debug.assert(decl.kind === SyntaxKind.Constructor); + const body = (decl).body; + if (body) { + forEachDescendantOfKind(body, SyntaxKind.SuperKeyword, node => { + if (isCallExpressionTarget(node)) { + result.push(node); + } + }); + } + }; + return result; + } + + function getImplementationReferenceEntryForNode(refNode: Node, result: ReferenceEntry[], typeChecker: TypeChecker): void { + // Check if we found a function/propertyAssignment/method with an implementation or initializer + if (isDeclarationName(refNode) && isImplementation(refNode.parent)) { + result.push(getReferenceEntryFromNode(refNode.parent)); + } + else if (refNode.kind === SyntaxKind.Identifier) { + if (refNode.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { + // Go ahead and dereference the shorthand assignment by going to its definition + getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); + } + + // Check if the node is within an extends or implements clause + const containingClass = getContainingClassIfInHeritageClause(refNode); + if (containingClass) { + result.push(getReferenceEntryFromNode(containingClass)); + return; + } + + // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface + const containingTypeReference = getContainingTypeReference(refNode); + if (containingTypeReference) { + const parent = containingTypeReference.parent; + if (isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent.initializer)); + } + else if (isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { + if (parent.body.kind === SyntaxKind.Block) { + forEachReturnStatement(parent.body, returnStatement => { + if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { + maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); + } + }); + } + else if (isImplementationExpression(parent.body)) { + maybeAdd(getReferenceEntryFromNode(parent.body)); + } + } + else if (isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { + maybeAdd(getReferenceEntryFromNode(parent.expression)); + } + } + } + + // Type nodes can contain multiple references to the same type. For example: + // let x: Foo & (Foo & Bar) = ... + // Because we are returning the implementation locations and not the identifier locations, + // duplicate entries would be returned here as each of the type references is part of + // the same implementation. For that reason, check before we add a new entry + function maybeAdd(a: ReferenceEntry) { + if (!forEach(result, b => a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length)) { + result.push(a); + } + } + } + + function getSymbolsForClassAndInterfaceComponents(type: UnionOrIntersectionType, result: Symbol[] = []): Symbol[] { + for (const componentType of type.types) { + if (componentType.symbol && componentType.symbol.getFlags() & (SymbolFlags.Class | SymbolFlags.Interface)) { + result.push(componentType.symbol); + } + if (componentType.getFlags() & TypeFlags.UnionOrIntersection) { + getSymbolsForClassAndInterfaceComponents(componentType, result); + } + } + return result; + } + + function getContainingTypeReference(node: Node): Node { + let topLevelTypeReference: Node = undefined; + + while (node) { + if (isTypeNode(node)) { + topLevelTypeReference = node; + } + node = node.parent; + } + + return topLevelTypeReference; + } + + function getContainingClassIfInHeritageClause(node: Node): ClassLikeDeclaration { + if (node && node.parent) { + if (node.kind === SyntaxKind.ExpressionWithTypeArguments + && node.parent.kind === SyntaxKind.HeritageClause + && isClassLike(node.parent.parent)) { + return node.parent.parent; + } + + else if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.PropertyAccessExpression) { + return getContainingClassIfInHeritageClause(node.parent); + } + } + return undefined; + } + + /** + * Returns true if this is an expression that can be considered an implementation + */ + function isImplementationExpression(node: Expression): boolean { + switch (node.kind) { + case SyntaxKind.ParenthesizedExpression: + return isImplementationExpression((node).expression); + case SyntaxKind.ArrowFunction: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ObjectLiteralExpression: + case SyntaxKind.ClassExpression: + case SyntaxKind.ArrayLiteralExpression: + return true; + default: + return false; + } + } + + /** + * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol + * is an interface, determines if some ancestor of the child symbol extends or inherits from it. + * Also takes in a cache of previous results which makes this slightly more efficient and is + * necessary to avoid potential loops like so: + * class A extends B { } + * class B extends A { } + * + * We traverse the AST rather than using the type checker because users are typically only interested + * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling + * implementations of types that share a common ancestor with the type whose implementation we are + * searching for need to be filtered out of the results. The type checker doesn't let us make the + * distinction between structurally compatible implementations and explicit implementations, so we + * must use the AST. + * + * @param child A class or interface Symbol + * @param parent Another class or interface Symbol + * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results + */ + function explicitlyInheritsFrom(child: Symbol, parent: Symbol, cachedResults: Map, typeChecker: TypeChecker): boolean { + const parentIsInterface = parent.getFlags() & SymbolFlags.Interface; + return searchHierarchy(child); + + function searchHierarchy(symbol: Symbol): boolean { + if (symbol === parent) { + return true; + } + + const key = getSymbolId(symbol) + "," + getSymbolId(parent); + const cached = cachedResults.get(key); + if (cached !== undefined) { + return cached; + } + + // Set the key so that we don't infinitely recurse + cachedResults.set(key, false); + + const inherits = forEach(symbol.getDeclarations(), declaration => { + if (isClassLike(declaration)) { + if (parentIsInterface) { + const interfaceReferences = getClassImplementsHeritageClauseElements(declaration); + if (interfaceReferences) { + for (const typeReference of interfaceReferences) { + if (searchTypeReference(typeReference)) { + return true; + } + } + } + } + return searchTypeReference(getClassExtendsHeritageClauseElement(declaration)); + } + else if (declaration.kind === SyntaxKind.InterfaceDeclaration) { + if (parentIsInterface) { + return forEach(getInterfaceBaseTypeNodes(declaration), searchTypeReference); + } + } + return false; + }); + + cachedResults.set(key, inherits); + return inherits; + } + + function searchTypeReference(typeReference: ExpressionWithTypeArguments): boolean { + if (typeReference) { + const type = typeChecker.getTypeAtLocation(typeReference); + if (type && type.symbol) { + return searchHierarchy(type.symbol); + } + } + return false; + } + } + + function getReferencesForSuperKeyword(superKeyword: Node, typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] { + let searchSpaceNode = getSuperContainer(superKeyword, /*stopOnFunctions*/ false); + if (!searchSpaceNode) { + return undefined; + } + // Whether 'super' occurs in a static context within a class. + let staticFlag = ModifierFlags.Static; + + switch (searchSpaceNode.kind) { + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + case SyntaxKind.Constructor: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + staticFlag &= getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + break; + default: + return undefined; + } + + const references: ReferenceEntry[] = []; + + const sourceFile = searchSpaceNode.getSourceFile(); + const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + for (const position of possiblePositions) { + cancellationToken.throwIfCancellationRequested(); + + const node = getTouchingWord(sourceFile, position); + + if (!node || node.kind !== SyntaxKind.SuperKeyword) { + continue; + } + + const container = getSuperContainer(node, /*stopOnFunctions*/ 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 && (ModifierFlags.Static & getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + references.push(getReferenceEntryFromNode(node)); + } + } + + const definition = getDefinition(searchSpaceNode.symbol, superKeyword, typeChecker); + return [{ definition, references }]; + } + + function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: SourceFile[], typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] { + let searchSpaceNode = getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); + + // Whether 'this' occurs in a static context within a class. + let staticFlag = ModifierFlags.Static; + + switch (searchSpaceNode.kind) { + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + if (isObjectLiteralMethod(searchSpaceNode)) { + break; + } + // fall through + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.Constructor: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + staticFlag &= getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + break; + case SyntaxKind.SourceFile: + if (isExternalModule(searchSpaceNode)) { + return undefined; + } + // Fall through + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.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; + } + + const references: ReferenceEntry[] = []; + + let possiblePositions: number[]; + if (searchSpaceNode.kind === SyntaxKind.SourceFile) { + forEach(sourceFiles, sourceFile => { + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); + } + else { + const sourceFile = searchSpaceNode.getSourceFile(); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); + } + + const thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); + + const displayParts = thisOrSuperSymbol && SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind( + typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; + + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: thisOrSuperKeyword.getSourceFile().fileName, + kind: ScriptElementKind.variableElement, + name: "this", + textSpan: createTextSpanFromNode(thisOrSuperKeyword), + displayParts + }, + references: references + }]; + + function getThisReferencesInFile(sourceFile: SourceFile, searchSpaceNode: Node, possiblePositions: number[], result: ReferenceEntry[]): void { + forEach(possiblePositions, position => { + cancellationToken.throwIfCancellationRequested(); + + const node = getTouchingWord(sourceFile, position); + if (!node || !isThis(node)) { + return; + } + + const container = getThisContainer(node, /* includeArrowFunctions */ false); + + switch (searchSpaceNode.kind) { + case SyntaxKind.FunctionExpression: + case SyntaxKind.FunctionDeclaration: + if (searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + if (isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case SyntaxKind.ClassExpression: + case SyntaxKind.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 && (getModifierFlags(container) & ModifierFlags.Static) === staticFlag) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case SyntaxKind.SourceFile: + if (container.kind === SyntaxKind.SourceFile && !isExternalModule(container)) { + result.push(getReferenceEntryFromNode(node)); + } + break; + } + }); + } + } + + function getReferencesForStringLiteral(node: StringLiteral, sourceFiles: SourceFile[], typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] { + const type = getStringLiteralTypeForNode(node, typeChecker); + + if (!type) { + // nothing to do here. moving on + return undefined; + } + + const references: ReferenceEntry[] = []; + + for (const sourceFile of sourceFiles) { + const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); + getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); + } + + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ScriptElementKind.variableElement, + name: type.text, + textSpan: createTextSpanFromNode(node), + displayParts: [displayPart(getTextOfNode(node), SymbolDisplayPartKind.stringLiteral)] + }, + references: references + }]; + + function getReferencesForStringLiteralInFile(sourceFile: SourceFile, searchType: Type, possiblePositions: number[], references: ReferenceEntry[]): void { + for (const position of possiblePositions) { + cancellationToken.throwIfCancellationRequested(); + + const node = getTouchingWord(sourceFile, position); + if (!node || node.kind !== SyntaxKind.StringLiteral) { + return; + } + + const type = getStringLiteralTypeForNode(node, typeChecker); + if (type === searchType) { + references.push(getReferenceEntryFromNode(node)); + } + } + } + } + + function populateSearchSymbolSet(symbol: Symbol, location: Node, typeChecker: TypeChecker, implementations: boolean): Symbol[] { + // The search set contains at least the current symbol + const result = [symbol]; + + // If the location is name of property symbol from object literal destructuring pattern + // Search the property symbol + // for ( { property: p2 } of elems) { } + const containingObjectLiteralElement = getContainingObjectLiteralElement(location); + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== SyntaxKind.ShorthandPropertyAssignment) { + const propertySymbol = getPropertySymbolOfDestructuringAssignment(location, typeChecker); + if (propertySymbol) { + result.push(propertySymbol); + } + } + + // 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 (containingObjectLiteralElement) { + forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), contextualSymbol => { + 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 + * const name = "Foo"; + * const 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. + */ + const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); + if (shorthandValueSymbol) { + result.push(shorthandValueSymbol); + } + } + + // If the symbol.valueDeclaration is a property parameter declaration, + // we should include both parameter declaration symbol and property declaration symbol + // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. + // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === SyntaxKind.Parameter && + isParameterPropertyDeclaration(symbol.valueDeclaration)) { + addRange(result, typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); + } + + // If this is symbol of binding element without propertyName declaration in Object binding pattern + // Include the property in the search + const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker); + if (bindingElementPropertySymbol) { + result.push(bindingElementPropertySymbol); + } + + // 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 + for (const rootSymbol of typeChecker.getRootSymbols(symbol)) { + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + + // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap(), typeChecker); + } + } + + return result; + } + + /** + * Find symbol of the given property-name and add the symbol to the given result array + * @param symbol a symbol to start searching for the given propertyName + * @param propertyName a name of property to search for + * @param result an array of symbol of found property symbols + * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. + * The value of previousIterationSymbol is undefined when the function is first called. + */ + function getPropertySymbolsFromBaseTypes(symbol: Symbol, propertyName: string, result: Symbol[], + previousIterationSymbolsCache: SymbolTable, typeChecker: TypeChecker): void { + if (!symbol) { + return; + } + + // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited + // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. + // For example: + // interface C extends C { + // /*findRef*/propName: string; + // } + // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, + // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, + // the function will add any found symbol of the property-name, then its sub-routine will call + // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already + // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. + if (previousIterationSymbolsCache.has(symbol.name)) { + return; + } + + if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + forEach(symbol.getDeclarations(), declaration => { + if (isClassLike(declaration)) { + getPropertySymbolFromTypeReference(getClassExtendsHeritageClauseElement(declaration)); + forEach(getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === SyntaxKind.InterfaceDeclaration) { + forEach(getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); + } + }); + } + return; + + function getPropertySymbolFromTypeReference(typeReference: ExpressionWithTypeArguments) { + if (typeReference) { + const type = typeChecker.getTypeAtLocation(typeReference); + if (type) { + const propertySymbol = typeChecker.getPropertyOfType(type, propertyName); + if (propertySymbol) { + result.push(...typeChecker.getRootSymbols(propertySymbol)); + } + + // Visit the typeReference as well to see if it directly or indirectly use that property + previousIterationSymbolsCache.set(symbol.name, symbol); + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, typeChecker); + } + } + } + } + + function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node, searchLocationIsConstructor: boolean, parents: Symbol[] | undefined, cache: Map, typeChecker: TypeChecker): Symbol | undefined { + if (contains(searchSymbols, referenceSymbol)) { + // If we are searching for constructor uses, they must be 'new' expressions. + return (!searchLocationIsConstructor || isNewExpressionTarget(referenceLocation)) ? referenceSymbol : undefined; + } + + // If the reference symbol is an alias, check if what it is aliasing is one of the search + // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. + const aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation, typeChecker); + if (aliasSymbol) { + return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker); + } + + // 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 + const containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation); + if (containingObjectLiteralElement) { + const contextualSymbol = forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), contextualSymbol => + find(typeChecker.getRootSymbols(contextualSymbol), symbol => contains(searchSymbols, symbol))); + + if (contextualSymbol) { + return contextualSymbol; + } + + // If the reference location is the name of property from object literal destructuring pattern + // Get the property symbol from the object literal's type and look if thats the search symbol + // In below eg. get 'property' from type of elems iterating type + // for ( { property: p2 } of elems) { } + const propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, typeChecker); + if (propertySymbol && contains(searchSymbols, propertySymbol)) { + return propertySymbol; + } + } + + // If the reference location is the binding element and doesn't have property name + // then include the binding element in the related symbols + // let { a } : { a }; + const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, typeChecker); + if (bindingElementPropertySymbol && contains(searchSymbols, bindingElementPropertySymbol)) { + return bindingElementPropertySymbol; + } + + // 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 forEach(typeChecker.getRootSymbols(referenceSymbol), rootSymbol => { + // if it is in the list, then we are done + if (contains(searchSymbols, rootSymbol)) { + 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 we were passed a parent symbol, only include types that are subtypes of the + // parent symbol + if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + // Parents will only be defined if implementations is true + if (parents) { + if (!forEach(parents, parent => explicitlyInheritsFrom(rootSymbol.parent, parent, cache, typeChecker))) { + return undefined; + } + } + + const result: Symbol[] = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap(), typeChecker); + return find(result, symbol => contains(searchSymbols, symbol)); + } + + return undefined; + }); + } + + function getNameFromObjectLiteralElement(node: ObjectLiteralElement) { + if (node.name.kind === SyntaxKind.ComputedPropertyName) { + const nameExpression = (node.name).expression; + // treat computed property names where expression is string/numeric literal as just string/numeric literal + if (isStringOrNumericLiteral(nameExpression)) { + return (nameExpression).text; + } + return undefined; + } + return (node.name).text; + } + + /** Gets all symbols for one property. Does not get symbols for every property. */ + function getPropertySymbolsFromContextualType(node: ObjectLiteralElement, typeChecker: TypeChecker): Symbol[] | undefined { + const objectLiteral = node.parent; + const contextualType = typeChecker.getContextualType(objectLiteral); + const name = getNameFromObjectLiteralElement(node); + if (name && contextualType) { + const result: Symbol[] = []; + const symbol = contextualType.getProperty(name); + if (symbol) { + result.push(symbol); + } + + if (contextualType.flags & TypeFlags.Union) { + forEach((contextualType).types, t => { + const symbol = t.getProperty(name); + if (symbol) { + result.push(symbol); + } + }); + } + return result; + } + 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: SemanticMeaning, declarations: Declaration[]): SemanticMeaning { + if (declarations) { + let lastIterationMeaning: SemanticMeaning; + 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 (const declaration of declarations) { + const declarationMeaning = getMeaningFromDeclaration(declaration); + + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; + } + } + } + while (meaning !== lastIterationMeaning); + } + return meaning; } function isImplementation(node: Node): boolean { @@ -1361,35 +1416,6 @@ namespace ts.FindAllReferences { }); } - /** - * Returns the containing object literal property declaration given a possible name node, e.g. "a" in x = { "a": 1 } - */ - function getContainingObjectLiteralElement(node: Node): ObjectLiteralElement { - switch (node.kind) { - case SyntaxKind.StringLiteral: - case SyntaxKind.NumericLiteral: - if (node.parent.kind === SyntaxKind.ComputedPropertyName) { - return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; - } - // intential fall through - case SyntaxKind.Identifier: - return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; - } - return undefined; - } - - function isObjectLiteralPropertyDeclaration(node: Node): node is ObjectLiteralElement { - switch (node.kind) { - case SyntaxKind.PropertyAssignment: - case SyntaxKind.ShorthandPropertyAssignment: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - return true; - } - return false; - } - /** Get `C` given `N` if `N` is in the position `class C extends N` or `class C extends foo.N` where `N` is an identifier. */ function tryGetClassByExtendingIdentifier(node: Node): ClassLikeDeclaration | undefined { return tryGetClassExtendingExpressionWithTypeArguments(climbPastPropertyAccess(node).parent); @@ -1402,4 +1428,8 @@ namespace ts.FindAllReferences { return false; } + + function isImportDefaultSymbol(symbol: Symbol): boolean { + return symbol.declarations[0].kind === SyntaxKind.ImportClause; + } } diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index b9cf85b5b60..b182b8e01f3 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -4,7 +4,7 @@ namespace ts.formatting { export class Rules { public getRuleName(rule: Rule) { - const o: ts.Map = this; + const o: ts.MapLike = this; for (const name in o) { if (o[name] === rule) { return name; diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 4c005640d6a..0ac6c9f7812 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.GoToDefinition { export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number): DefinitionInfo[] { /// Triple slash reference comments @@ -14,11 +14,9 @@ namespace ts.GoToDefinition { // Type reference directives const typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { - const referenceFile = program.getResolvedTypeReferenceDirectives()[typeReferenceDirective.fileName]; - if (referenceFile && referenceFile.resolvedFileName) { - return [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; - } - return undefined; + const referenceFile = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); + return referenceFile && referenceFile.resolvedFileName && + [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; } const node = getTouchingPropertyName(sourceFile, position); @@ -30,7 +28,7 @@ namespace ts.GoToDefinition { if (isJumpStatementTarget(node)) { const labelName = (node).text; const label = getTargetLabel((node.parent), (node).text); - return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; + return label ? [createDefinitionInfoFromName(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; } const typeChecker = program.getTypeChecker(); @@ -87,6 +85,37 @@ namespace ts.GoToDefinition { declaration => createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName)); } + if (isJsxOpeningLikeElement(node.parent)) { + // If there are errors when trying to figure out stateless component function, just return the first declaration + // For example: + // declare function /*firstSource*/MainButton(buttonProps: ButtonProps): JSX.Element; + // declare function /*secondSource*/MainButton(linkProps: LinkProps): JSX.Element; + // declare function /*thirdSource*/MainButton(props: ButtonProps | LinkProps): JSX.Element; + // let opt =
; // Error - We get undefined for resolved signature indicating an error, then just return the first declaration + const {symbolName, symbolKind, containerName} = getSymbolInfo(typeChecker, symbol, node); + return [createDefinitionInfo(symbol.valueDeclaration, symbolKind, symbolName, containerName)]; + } + + // If the current location we want to find its definition 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 for goto-definition. + // For example + // interface Props{ + // /*first*/prop1: number + // prop2: boolean + // } + // function Foo(arg: Props) {} + // Foo( { pr/*1*/op1: 10, prop2: true }) + const element = getContainingObjectLiteralElement(node); + if (element) { + if (typeChecker.getContextualType(element.parent as Expression)) { + const result: DefinitionInfo[] = []; + const propertySymbols = getPropertySymbolsFromContextualType(typeChecker, element); + for (const propertySymbol of propertySymbols) { + result.push(...getDefinitionFromSymbol(typeChecker, propertySymbol, node)); + } + return result; + } + } return getDefinitionFromSymbol(typeChecker, symbol, node); } @@ -171,33 +200,46 @@ namespace ts.GoToDefinition { function tryAddSignature(signatureDeclarations: Declaration[], selectConstructors: boolean, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) { const declarations: Declaration[] = []; - let definition: Declaration; + let definition: Declaration | undefined; - forEach(signatureDeclarations, d => { - if ((selectConstructors && d.kind === SyntaxKind.Constructor) || - (!selectConstructors && (d.kind === SyntaxKind.FunctionDeclaration || d.kind === SyntaxKind.MethodDeclaration || d.kind === SyntaxKind.MethodSignature))) { + for (const d of signatureDeclarations) { + if (selectConstructors ? d.kind === SyntaxKind.Constructor : isSignatureDeclaration(d)) { 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(lastOrUndefined(declarations), symbolKind, symbolName, containerName)); - return true; } + if (declarations.length) { + result.push(createDefinitionInfo(definition || lastOrUndefined(declarations), symbolKind, symbolName, containerName)); + return true; + } return false; } } - function createDefinitionInfo(node: Node, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo { + function isSignatureDeclaration(node: Node): boolean { + switch (node.kind) { + case ts.SyntaxKind.Constructor: + case ts.SyntaxKind.FunctionDeclaration: + case ts.SyntaxKind.MethodDeclaration: + case ts.SyntaxKind.MethodSignature: + return true; + default: + return false; + } + } + + /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */ + function createDefinitionInfo(node: Declaration, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo { + return createDefinitionInfoFromName(node.name || node, symbolKind, symbolName, containerName); + } + + /** Creates a DefinitionInfo directly from the name of a declaration. */ + function createDefinitionInfoFromName(name: Node, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo { + const sourceFile = name.getSourceFile(); return { - fileName: node.getSourceFile().fileName, - textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()), + fileName: sourceFile.fileName, + textSpan: createTextSpanFromNode(name, sourceFile), kind: symbolKind, name: symbolName, containerKind: undefined, @@ -251,6 +293,14 @@ namespace ts.GoToDefinition { function tryGetSignatureDeclaration(typeChecker: TypeChecker, node: Node): SignatureDeclaration | undefined { const callLike = getAncestorCallLikeExpression(node); - return callLike && typeChecker.getResolvedSignature(callLike).declaration; + const signature = callLike && typeChecker.getResolvedSignature(callLike); + if (signature) { + const decl = signature.declaration; + if (decl && isSignatureDeclaration(decl)) { + return decl; + } + } + // Don't go to a function type, go to the value having that type. + return undefined; } } diff --git a/src/services/goToImplementation.ts b/src/services/goToImplementation.ts index 123d29630ad..9135e1fe0f0 100644 --- a/src/services/goToImplementation.ts +++ b/src/services/goToImplementation.ts @@ -17,7 +17,7 @@ namespace ts.GoToImplementation { else { // Perform "Find all References" and retrieve only those that are implementations const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, - node, sourceFiles, /*findInStrings*/false, /*findInComments*/false, /*implementations*/true); + node, sourceFiles, /*findInStrings*/false, /*findInComments*/false, /*isForRename*/false, /*implementations*/true); const result = flatMap(referencedSymbols, symbol => map(symbol.references, ({ textSpan, fileName }) => ({ textSpan, fileName }))); diff --git a/src/services/jsTyping.ts b/src/services/jsTyping.ts index 04ac60c4e74..248ceef1bd3 100644 --- a/src/services/jsTyping.ts +++ b/src/services/jsTyping.ts @@ -17,11 +17,11 @@ namespace ts.JsTyping { interface PackageJson { _requiredBy?: string[]; - dependencies?: Map; - devDependencies?: Map; + dependencies?: MapLike; + devDependencies?: MapLike; name?: string; - optionalDependencies?: Map; - peerDependencies?: Map; + optionalDependencies?: MapLike; + peerDependencies?: MapLike; typings?: string; }; @@ -76,7 +76,7 @@ namespace ts.JsTyping { if (!safeList) { const result = readConfigFile(safeListPath, (path: string) => host.readFile(path)); - safeList = result.config ? createMap(result.config) : EmptySafeList; + safeList = result.config ? createMapFromTemplate(result.config) : EmptySafeList; } const filesToWatch: string[] = []; @@ -107,34 +107,34 @@ namespace ts.JsTyping { // add typings for unresolved imports if (unresolvedImports) { for (const moduleId of unresolvedImports) { - const typingName = moduleId in nodeCoreModules ? "node" : moduleId; - if (!(typingName in inferredTypings)) { - inferredTypings[typingName] = undefined; + const typingName = nodeCoreModules.has(moduleId) ? "node" : moduleId; + if (!inferredTypings.has(typingName)) { + inferredTypings.set(typingName, undefined); } } } // Add the cached typing locations for inferred typings that are already installed - for (const name in packageNameToTypingLocation) { - if (name in inferredTypings && !inferredTypings[name]) { - inferredTypings[name] = packageNameToTypingLocation[name]; + packageNameToTypingLocation.forEach((typingLocation, name) => { + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined) { + inferredTypings.set(name, typingLocation); } - } + }); // Remove typings that the user has added to the exclude list for (const excludeTypingName of exclude) { - delete inferredTypings[excludeTypingName]; + inferredTypings.delete(excludeTypingName); } const newTypingNames: string[] = []; const cachedTypingPaths: string[] = []; - for (const typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); + inferredTypings.forEach((inferred, typing) => { + if (inferred !== undefined) { + cachedTypingPaths.push(inferred); } else { newTypingNames.push(typing); } - } + }); return { cachedTypingPaths, newTypingNames, filesToWatch }; /** @@ -146,8 +146,8 @@ namespace ts.JsTyping { } for (const typing of typingNames) { - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; + if (!inferredTypings.has(typing)) { + inferredTypings.set(typing, undefined); } } } @@ -189,7 +189,7 @@ namespace ts.JsTyping { const cleanedTypingNames = map(inferredTypingNames, f => f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, "")); if (safeList !== EmptySafeList) { - mergeTypings(filter(cleanedTypingNames, f => f in safeList)); + mergeTypings(filter(cleanedTypingNames, f => safeList.has(f))); } const hasJsxFile = forEach(fileNames, f => ensureScriptKind(f, getScriptKindFromFileName(f)) === ScriptKind.JSX); @@ -236,7 +236,7 @@ namespace ts.JsTyping { } if (packageJson.typings) { const absolutePath = getNormalizedAbsolutePath(packageJson.typings, getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; + inferredTypings.set(packageJson.name, absolutePath); } else { typingNames.push(packageJson.name); diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 82f4dd49f2b..05ccbcc71f4 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.NavigateTo { type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration }; @@ -7,23 +7,21 @@ namespace ts.NavigateTo { let rawItems: RawNavigateToItem[] = []; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] - forEach(sourceFiles, sourceFile => { + for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && fileExtensionIs(sourceFile.fileName, ".d.ts")) { - return; + continue; } - const nameToDeclarations = sourceFile.getNamedDeclarations(); - for (const name in nameToDeclarations) { - const declarations = nameToDeclarations[name]; + forEachEntry(sourceFile.getNamedDeclarations(), (declarations, name) => { 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. let matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); if (!matches) { - continue; + return; // continue to next named declarations } for (const declaration of declarations) { @@ -32,13 +30,13 @@ namespace ts.NavigateTo { if (patternMatcher.patternContainsDots) { const containers = getContainers(declaration); if (!containers) { - return undefined; + return true; // Break out of named declarations and go to the next source file. } matches = patternMatcher.getMatches(containers, name); if (!matches) { - continue; + return; // continue to next named declarations } } @@ -47,8 +45,8 @@ namespace ts.NavigateTo { rawItems.push({ name, fileName, matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration }); } } - } - }); + }); + } // Remove imports when the imported declaration is already in the list and has the same name. rawItems = filter(rawItems, item => { @@ -199,7 +197,7 @@ namespace ts.NavigateTo { matchKind: PatternMatchKind[rawItem.matchKind], isCaseSensitive: rawItem.isCaseSensitive, fileName: rawItem.fileName, - textSpan: createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), + textSpan: createTextSpanFromNode(declaration), // 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 ? getNodeKind(container) : "" diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 4e5986abc01..25059d1f57d 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -248,9 +248,9 @@ namespace ts.NavigationBar { return true; } - const itemsWithSameName = nameToItems[name]; + const itemsWithSameName = nameToItems.get(name); if (!itemsWithSameName) { - nameToItems[name] = child; + nameToItems.set(name, child); return true; } @@ -268,7 +268,7 @@ namespace ts.NavigationBar { if (tryMerge(itemWithSameName, child)) { return false; } - nameToItems[name] = [itemWithSameName, child]; + nameToItems.set(name, [itemWithSameName, child]); return true; } @@ -322,7 +322,7 @@ namespace ts.NavigationBar { function compareChildren(child1: NavigationBarNode, child2: NavigationBarNode): number { const name1 = tryGetName(child1.node), name2 = tryGetName(child2.node); if (name1 && name2) { - const cmp = localeCompareFix(name1, name2); + const cmp = ts.compareStringsCaseInsensitive(name1, name2); return cmp !== 0 ? cmp : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } else { @@ -330,26 +330,6 @@ namespace ts.NavigationBar { } } - // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". - const localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; - const localeCompareFix: (a: string, b: string) => number = localeCompareIsCorrect ? collator.compare : function(a, b) { - // This isn't perfect, but it passes all of our tests. - for (let i = 0; i < Math.min(a.length, b.length); i++) { - const chA = a.charAt(i), chB = b.charAt(i); - if (chA === "\"" && chB === "'") { - return 1; - } - if (chA === "'" && chB === "\"") { - return -1; - } - const cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); - if (cmp !== 0) { - return cmp; - } - } - return a.length - b.length; - }; - /** * This differs from getItemName because this is just used for sorting. * We only sort nodes by name that have a more-or-less "direct" name, as opposed to `new()` and the like. @@ -514,7 +494,7 @@ namespace ts.NavigationBar { return { text: getItemName(n.node), kind: getNodeKind(n.node), - kindModifiers: getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: map(n.children, convertToTree) }; @@ -524,7 +504,7 @@ namespace ts.NavigationBar { return { text: getItemName(n.node), kind: getNodeKind(n.node), - kindModifiers: getNodeModifiers(n.node), + kindModifiers: getModifiers(n.node), spans: getSpans(n), childItems: map(n.children, convertToChildItem) || emptyChildItemArray, indent: n.indent, @@ -591,7 +571,14 @@ namespace ts.NavigationBar { function getNodeSpan(node: Node): TextSpan { return node.kind === SyntaxKind.SourceFile ? createTextSpanFromBounds(node.getFullStart(), node.getEnd()) - : createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); + : createTextSpanFromNode(node, curSourceFile); + } + + function getModifiers(node: ts.Node): string { + if (node.parent && node.parent.kind === SyntaxKind.VariableDeclaration) { + node = node.parent; + } + return getNodeModifiers(node); } function getFunctionOrClassName(node: FunctionExpression | FunctionDeclaration | ArrowFunction | ClassLikeDeclaration): string { @@ -626,15 +613,15 @@ namespace ts.NavigationBar { /** * Matches all whitespace characters in a string. Eg: - * + * * "app. - * + * * onactivated" - * + * * matches because of the newline, whereas - * + * * "app.onactivated" - * + * * does not match. */ const whiteSpaceRegex = /\s+/g; diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index dc2e4a59773..43054a10f5d 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -8,7 +8,7 @@ namespace ts.OutliningElementsCollector { if (hintSpanNode && startElement && endElement) { const span: OutliningSpan = { textSpan: createTextSpanFromBounds(startElement.pos, endElement.end), - hintSpan: createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), + hintSpan: createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse }; @@ -67,10 +67,10 @@ namespace ts.OutliningElementsCollector { // Only outline spans of two or more consecutive single line comments if (count > 1) { - const multipleSingleLineComments = { + const multipleSingleLineComments: CommentRange = { + kind: SyntaxKind.SingleLineCommentTrivia, pos: start, end: end, - kind: SyntaxKind.SingleLineCommentTrivia }; addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false); @@ -135,7 +135,7 @@ namespace ts.OutliningElementsCollector { // Block was a standalone block. In this case we want to only collapse // the span of the block, independent of any parent span. - const span = createTextSpanFromBounds(n.getStart(), n.end); + const span = createTextSpanFromNode(n); elements.push({ textSpan: span, hintSpan: span, diff --git a/src/services/patternMatcher.ts b/src/services/patternMatcher.ts index ad638099695..396e53810ce 100644 --- a/src/services/patternMatcher.ts +++ b/src/services/patternMatcher.ts @@ -188,11 +188,11 @@ namespace ts { } function getWordSpans(word: string): TextSpan[] { - if (!(word in stringToWordSpans)) { - stringToWordSpans[word] = breakIntoWordSpans(word); + let spans = stringToWordSpans.get(word); + if (!spans) { + stringToWordSpans.set(word, spans = breakIntoWordSpans(word)); } - - return stringToWordSpans[word]; + return spans; } function matchTextChunk(candidate: string, chunk: TextChunk, punctuationStripped: boolean): PatternMatch { diff --git a/src/services/rename.ts b/src/services/rename.ts index 6f28e505f79..2e9396888ef 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -1,98 +1,92 @@ /* @internal */ namespace ts.Rename { export function getRenameInfo(typeChecker: TypeChecker, defaultLibFileName: string, getCanonicalFileName: (fileName: string) => string, sourceFile: SourceFile, position: number): RenameInfo { - const canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); - + const getCanonicalDefaultLibName = memoize(() => getCanonicalFileName(ts.normalizePath(defaultLibFileName))); const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true); - - if (node) { - if (node.kind === SyntaxKind.Identifier || - node.kind === SyntaxKind.StringLiteral || - isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isThis(node)) { - const symbol = typeChecker.getSymbolAtLocation(node); - - // Only allow a symbol to be renamed if it actually has at least one declaration. - if (symbol) { - const declarations = symbol.getDeclarations(); - if (declarations && declarations.length > 0) { - // Disallow rename for elements that are defined in the standard TypeScript library. - if (forEach(declarations, isDefinedInLibraryFile)) { - return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } - - const displayName = stripQuotes(getDeclaredName(typeChecker, symbol, node)); - const kind = SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - if (kind) { - return { - canRename: true, - kind, - displayName, - localizedErrorMessage: undefined, - fullDisplayName: typeChecker.getFullyQualifiedName(symbol), - kindModifiers: SymbolDisplay.getSymbolModifiers(symbol), - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - else if (node.kind === SyntaxKind.StringLiteral) { - const type = getStringLiteralTypeForNode(node, typeChecker); - if (type) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } - else { - const displayName = stripQuotes(type.text); - return { - canRename: true, - kind: ScriptElementKind.variableElement, - displayName, - localizedErrorMessage: undefined, - fullDisplayName: displayName, - kindModifiers: ScriptElementKindModifier.none, - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - } - } - - return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_this_element)); - - function getRenameInfoError(localizedErrorMessage: string): RenameInfo { - return { - canRename: false, - localizedErrorMessage: localizedErrorMessage, - displayName: undefined, - fullDisplayName: undefined, - kind: undefined, - kindModifiers: undefined, - triggerSpan: undefined - }; - } + const renameInfo = node && nodeIsEligibleForRename(node) + ? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) + : undefined; + return renameInfo || getRenameInfoError(Diagnostics.You_cannot_rename_this_element); function isDefinedInLibraryFile(declaration: Node) { - if (defaultLibFileName) { - const sourceFile = declaration.getSourceFile(); - const canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); - if (canonicalName === canonicalDefaultLibName) { - return true; - } + if (!defaultLibFileName) { + return false; } - return false; - } - function createTriggerSpanForNode(node: Node, sourceFile: SourceFile) { - let start = node.getStart(sourceFile); - let width = node.getWidth(sourceFile); - if (node.kind === SyntaxKind.StringLiteral) { - // Exclude the quotes - start += 1; - width -= 2; - } - return createTextSpan(start, width); + const sourceFile = declaration.getSourceFile(); + const canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); + return canonicalName === getCanonicalDefaultLibName(); } } + + function getRenameInfoForNode(node: Node, typeChecker: TypeChecker, sourceFile: SourceFile, isDefinedInLibraryFile: (declaration: Node) => boolean): RenameInfo | undefined { + const symbol = typeChecker.getSymbolAtLocation(node); + + // Only allow a symbol to be renamed if it actually has at least one declaration. + if (symbol) { + const declarations = symbol.getDeclarations(); + if (declarations && declarations.length > 0) { + // Disallow rename for elements that are defined in the standard TypeScript library. + if (some(declarations, isDefinedInLibraryFile)) { + return getRenameInfoError(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); + } + + const displayName = stripQuotes(getDeclaredName(typeChecker, symbol, node)); + const kind = SymbolDisplay.getSymbolKind(typeChecker, symbol, node); + return kind ? getRenameInfoSuccess(displayName, typeChecker.getFullyQualifiedName(symbol), kind, SymbolDisplay.getSymbolModifiers(symbol), node, sourceFile) : undefined; + } + } + else if (node.kind === SyntaxKind.StringLiteral) { + const type = getStringLiteralTypeForNode(node, typeChecker); + if (type) { + if (isDefinedInLibraryFile(node)) { + return getRenameInfoError(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); + } + + const displayName = stripQuotes(type.text); + return getRenameInfoSuccess(displayName, displayName, ScriptElementKind.variableElement, ScriptElementKindModifier.none, node, sourceFile); + } + } + } + + function getRenameInfoSuccess(displayName: string, fullDisplayName: string, kind: string, kindModifiers: string, node: Node, sourceFile: SourceFile): RenameInfo { + return { + canRename: true, + kind, + displayName, + localizedErrorMessage: undefined, + fullDisplayName, + kindModifiers, + triggerSpan: createTriggerSpanForNode(node, sourceFile) + }; + } + + function getRenameInfoError(diagnostic: DiagnosticMessage): RenameInfo { + return { + canRename: false, + localizedErrorMessage: getLocaleSpecificMessage(diagnostic), + displayName: undefined, + fullDisplayName: undefined, + kind: undefined, + kindModifiers: undefined, + triggerSpan: undefined + }; + } + + function createTriggerSpanForNode(node: Node, sourceFile: SourceFile) { + let start = node.getStart(sourceFile); + let width = node.getWidth(sourceFile); + if (node.kind === SyntaxKind.StringLiteral) { + // Exclude the quotes + start += 1; + width -= 2; + } + return createTextSpan(start, width); + } + + function nodeIsEligibleForRename(node: Node) { + return node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.StringLiteral || + isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + isThis(node); + } } diff --git a/src/services/services.ts b/src/services/services.ts index fac7715033b..0c7b5d97d26 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -193,9 +193,10 @@ namespace ts { return undefined; } - const child = children[0]; - - return child.kind < SyntaxKind.FirstNode ? child : child.getFirstToken(sourceFile); + const child = ts.find(children, kid => kid.kind < SyntaxKind.FirstJSDocNode || kid.kind > SyntaxKind.LastJSDocNode); + return child.kind < SyntaxKind.FirstNode ? + child : + child.getFirstToken(sourceFile); } public getLastToken(sourceFile?: SourceFile): Node { @@ -379,7 +380,7 @@ namespace ts { getNumberIndexType(): Type { return this.checker.getIndexTypeOfType(this, IndexKind.Number); } - getBaseTypes(): ObjectType[] { + getBaseTypes(): BaseType[] { return this.flags & TypeFlags.Object && this.objectFlags & (ObjectFlags.Class | ObjectFlags.Interface) ? this.checker.getBaseTypes(this) : undefined; @@ -396,6 +397,7 @@ namespace ts { parameters: Symbol[]; thisParameter: Symbol; resolvedReturnType: Type; + minTypeArgumentCount: number; minArgumentCount: number; hasRestParameter: boolean; hasLiteralTypes: boolean; @@ -518,7 +520,7 @@ namespace ts { } private computeNamedDeclarations(): Map { - const result = createMap(); + const result = createMultiMap(); forEachChild(this, visit); @@ -527,12 +529,16 @@ namespace ts { function addDeclaration(declaration: Declaration) { const name = getDeclarationName(declaration); if (name) { - multiMapAdd(result, name, declaration); + result.add(name, declaration); } } function getDeclarations(name: string) { - return result[name] || (result[name] = []); + let declarations = result.get(name); + if (!declarations) { + result.set(name, declarations = []); + } + return declarations; } function getDeclarationName(declaration: Declaration) { @@ -1399,25 +1405,24 @@ namespace ts { } function findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] { - const referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + const referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments, /*isForRename*/true); return FindAllReferences.convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] { - const referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false); + const referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/false); return FindAllReferences.convertReferences(referencedSymbols); } function findReferences(fileName: string, position: number): ReferencedSymbol[] { - const referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false); - + const referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/false); // Only include referenced symbols that have a valid definition. return filter(referencedSymbols, rs => !!rs.definition); } - function findReferencedSymbols(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] { + function findReferencedSymbols(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, isForRename: boolean): ReferencedSymbol[] { synchronizeHostData(); - return FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments); + return FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments, isForRename); } /// NavigateTo @@ -1442,7 +1447,8 @@ namespace ts { }); } - const emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles); + const customTransformers = host.getCustomTransformers && host.getCustomTransformers(); + const emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); return { outputFiles, @@ -1684,7 +1690,7 @@ namespace ts { let allFixes: CodeAction[] = []; - forEach(errorCodes, error => { + forEach(deduplicate(errorCodes), error => { cancellationToken.throwIfCancellationRequested(); const context = { @@ -1956,7 +1962,7 @@ namespace ts { function walk(node: Node) { switch (node.kind) { case SyntaxKind.Identifier: - nameTable[(node).text] = nameTable[(node).text] === undefined ? node.pos : -1; + setNameTable((node).text, node); break; case SyntaxKind.StringLiteral: case SyntaxKind.NumericLiteral: @@ -1968,8 +1974,7 @@ namespace ts { node.parent.kind === SyntaxKind.ExternalModuleReference || isArgumentOfElementAccessExpression(node) || isLiteralComputedPropertyDeclarationName(node)) { - - nameTable[(node).text] = nameTable[(node).text] === undefined ? node.pos : -1; + setNameTable((node).text, node); } break; default: @@ -1981,6 +1986,70 @@ namespace ts { } } } + + function setNameTable(text: string, node: ts.Node): void { + nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); + } + } + + function isObjectLiteralElement(node: Node): node is ObjectLiteralElement { + switch (node.kind) { + case SyntaxKind.JsxAttribute: + case SyntaxKind.JsxSpreadAttribute: + case SyntaxKind.PropertyAssignment: + case SyntaxKind.ShorthandPropertyAssignment: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + return true; + } + return false; + } + + /** + * Returns the containing object literal property declaration given a possible name node, e.g. "a" in x = { "a": 1 } + */ + /* @internal */ + export function getContainingObjectLiteralElement(node: Node): ObjectLiteralElement { + switch (node.kind) { + case SyntaxKind.StringLiteral: + case SyntaxKind.NumericLiteral: + if (node.parent.kind === SyntaxKind.ComputedPropertyName) { + return isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; + } + // intentionally fall through + case SyntaxKind.Identifier: + return isObjectLiteralElement(node.parent) && + (node.parent.parent.kind === SyntaxKind.ObjectLiteralExpression || node.parent.parent.kind === SyntaxKind.JsxAttributes) && + (node.parent).name === node ? node.parent as ObjectLiteralElement : undefined; + } + return undefined; + } + + /* @internal */ + export function getPropertySymbolsFromContextualType(typeChecker: TypeChecker, node: ObjectLiteralElement): Symbol[] { + const objectLiteral = node.parent; + const contextualType = typeChecker.getContextualType(objectLiteral); + const name = getTextOfPropertyName(node.name); + if (name && contextualType) { + const result: Symbol[] = []; + const symbol = contextualType.getProperty(name); + if (contextualType.flags & TypeFlags.Union) { + forEach((contextualType).types, t => { + const symbol = t.getProperty(name); + if (symbol) { + result.push(symbol); + } + }); + return result; + } + + if (symbol) { + result.push(symbol); + return result; + } + } + return undefined; } function isArgumentOfElementAccessExpression(node: Node) { @@ -2007,9 +2076,5 @@ namespace ts { throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); } - function initializeServices() { - objectAllocator = getServicesObjectAllocator(); - } - - initializeServices(); + objectAllocator = getServicesObjectAllocator(); } diff --git a/src/services/shims.ts b/src/services/shims.ts index cf6bceb816c..6fe9aed144e 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -385,7 +385,10 @@ namespace ts { if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } - return JSON.parse(settingsJson); + const compilerOptions = JSON.parse(settingsJson); + // permit language service to handle all files (filtering should be performed on the host side) + compilerOptions.allowNonTsExtensions = true; + return compilerOptions; } public getScriptFileNames(): string[] { @@ -1061,12 +1064,6 @@ namespace ts { const compilerOptions = JSON.parse(compilerOptionsJson); const result = resolveModuleName(moduleName, normalizeSlashes(fileName), compilerOptions, this.host); const resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (resolvedFileName && !compilerOptions.allowJs && fileExtensionIs(resolvedFileName, ".js")) { - return { - resolvedFileName: undefined, - failedLookupLocations: [] - }; - } return { resolvedFileName, failedLookupLocations: result.failedLookupLocations @@ -1272,4 +1269,4 @@ namespace TypeScript.Services { // TODO: it should be moved into a namespace though. /* @internal */ -const toolsVersion = "2.2"; \ No newline at end of file +const toolsVersion = "2.3"; \ No newline at end of file diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 44c2ede9fbb..3b22fcef956 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -168,7 +168,8 @@ namespace ts.SignatureHelp { export const enum ArgumentListKind { TypeArguments, CallArguments, - TaggedTemplateArguments + TaggedTemplateArguments, + JSXAttributesArguments } export interface ArgumentListInfo { @@ -237,7 +238,7 @@ namespace ts.SignatureHelp { const typeChecker = program.getTypeChecker(); for (const sourceFile of program.getSourceFiles()) { const nameToDeclarations = sourceFile.getNamedDeclarations(); - const declarations = nameToDeclarations[name.text]; + const declarations = nameToDeclarations.get(name.text); if (declarations) { for (const declaration of declarations) { @@ -260,22 +261,22 @@ namespace ts.SignatureHelp { * Returns relevant information for the argument list and the current argument if we are * in the argument of an invocation; returns undefined otherwise. */ - function getImmediatelyContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile): ArgumentListInfo { + export function getImmediatelyContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile): ArgumentListInfo { if (node.parent.kind === SyntaxKind.CallExpression || node.parent.kind === SyntaxKind.NewExpression) { const callExpression = node.parent; // There are 3 cases to handle: - // 1. The token introduces a list, and should begin a sig help session + // 1. The token introduces a list, and should begin a signature help session // 2. The token is either not associated with a list, or ends a list, so the session should end - // 3. The token is buried inside a list, and should give sig help + // 3. The token is buried inside a list, and should give signature help // // The following are examples of each: // // Case 1: - // foo<#T, U>(#a, b) -> The token introduces a list, and should begin a sig help session + // foo<#T, U>(#a, b) -> The token introduces a list, and should begin a signature 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 + // foo(a#, #b#) -> The token is buried inside a list, and should give signature help // Find out if 'node' is an argument, a type argument, or neither if (node.kind === SyntaxKind.LessThanToken || node.kind === SyntaxKind.OpenParenToken) { @@ -295,7 +296,7 @@ namespace ts.SignatureHelp { // 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. + // - To the right of the closing parenthesis, 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 @@ -352,6 +353,22 @@ namespace ts.SignatureHelp { return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } + else if (node.parent && isJsxOpeningLikeElement(node.parent)) { + // Provide a signature help for JSX opening element or JSX self-closing element. + // This is not guarantee that JSX tag-name is resolved into stateless function component. (that is done in "getSignatureHelpItems") + // i.e + // export function MainButton(props: ButtonProps, context: any): JSX.Element { ... } + // ' '' - // That will give us 2 non-commas. We then add one for the last comma, givin us an + // That will give us 2 non-commas. We then add one for the last comma, giving us an // arg count of 3. const listChildren = argumentsList.getChildren(); @@ -435,7 +452,6 @@ namespace ts.SignatureHelp { : (tagExpression.template).templateSpans.length + 1; Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, `argumentCount < argumentIndex, ${argumentCount} < ${argumentIndex}`); - return { kind: ArgumentListKind.TaggedTemplateArguments, invocation: tagExpression, diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index b32bd8f331d..a6afce1cc4f 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -51,7 +51,7 @@ namespace ts.SymbolDisplay { if (flags & SymbolFlags.Constructor) return ScriptElementKind.constructorImplementationElement; if (flags & SymbolFlags.Property) { - if (flags & SymbolFlags.SyntheticProperty) { + if (flags & SymbolFlags.Transient && (symbol).checkFlags & CheckFlags.SyntheticProperty) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property const unionPropertyKind = forEach(typeChecker.getRootSymbols(symbol), rootSymbol => { const rootSymbolFlags = rootSymbol.getFlags(); @@ -71,6 +71,9 @@ namespace ts.SymbolDisplay { } return unionPropertyKind; } + if (location.parent && isJsxAttribute(location.parent)) { + return ScriptElementKind.jsxAttribute; + } return ScriptElementKind.memberVariableElement; } @@ -114,23 +117,27 @@ namespace ts.SymbolDisplay { } // try get the call/construct signature from the type if it matches - let callExpression: CallExpression | NewExpression; + let callExpressionLike: CallExpression | NewExpression | JsxOpeningLikeElement; if (location.kind === SyntaxKind.CallExpression || location.kind === SyntaxKind.NewExpression) { - callExpression = location; + callExpressionLike = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { - callExpression = location.parent; + callExpressionLike = location.parent; + } + else if (location.parent && isJsxOpeningLikeElement(location.parent) && isFunctionLike(symbol.valueDeclaration)) { + callExpressionLike = location.parent; } - if (callExpression) { + if (callExpressionLike) { const candidateSignatures: Signature[] = []; - signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures); + signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); if (!signature && candidateSignatures.length) { // Use the first candidate: signature = candidateSignatures[0]; } - const useConstructSignatures = callExpression.kind === SyntaxKind.NewExpression || callExpression.expression.kind === SyntaxKind.SuperKeyword; + const useConstructSignatures = callExpressionLike.kind === SyntaxKind.NewExpression || (isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === SyntaxKind.SuperKeyword); + const allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!contains(allSignatures, signature.target) && !contains(allSignatures, signature)) { @@ -160,6 +167,7 @@ namespace ts.SymbolDisplay { } switch (symbolKind) { + case ScriptElementKind.jsxAttribute: case ScriptElementKind.memberVariableElement: case ScriptElementKind.variableElement: case ScriptElementKind.constElement: @@ -373,6 +381,7 @@ namespace ts.SymbolDisplay { // For properties, variables and local vars: show the type if (symbolKind === ScriptElementKind.memberVariableElement || + symbolKind === ScriptElementKind.jsxAttribute || symbolFlags & SymbolFlags.Variable || symbolKind === ScriptElementKind.localVariableElement || isThisExpression) { diff --git a/src/services/transform.ts b/src/services/transform.ts new file mode 100644 index 00000000000..07fc3c759e2 --- /dev/null +++ b/src/services/transform.ts @@ -0,0 +1,18 @@ +/// +/// +namespace ts { + /** + * Transform one or more nodes using the supplied transformers. + * @param source A single `Node` or an array of `Node` objects. + * @param transformers An array of `TransformerFactory` callbacks used to process the transformation. + * @param compilerOptions Optional compiler options. + */ + export function transform(source: T | T[], transformers: TransformerFactory[], compilerOptions?: CompilerOptions) { + const diagnostics: Diagnostic[] = []; + compilerOptions = fixupCompilerOptions(compilerOptions, diagnostics); + const nodes = isArray(source) ? source : [source]; + const result = transformNodes(/*resolver*/ undefined, /*emitHost*/ undefined, compilerOptions, nodes, transformers, /*allowDtsFiles*/ true); + result.diagnostics = concatenate(result.diagnostics, diagnostics); + return result; + } +} \ No newline at end of file diff --git a/src/services/transpile.ts b/src/services/transpile.ts index da54faed1a2..86c6a3e8904 100644 --- a/src/services/transpile.ts +++ b/src/services/transpile.ts @@ -1,4 +1,4 @@ -namespace ts { +namespace ts { export interface TranspileOptions { compilerOptions?: CompilerOptions; fileName?: string; @@ -63,7 +63,7 @@ namespace ts { } if (transpileOptions.renamedDependencies) { - sourceFile.renamedDependencies = createMap(transpileOptions.renamedDependencies); + sourceFile.renamedDependencies = createMapFromTemplate(transpileOptions.renamedDependencies); } const newLine = getNewLineCharacter(options); @@ -123,10 +123,11 @@ namespace ts { let commandLineOptionsStringToEnum: CommandLineOptionOfCustomType[]; /** JS users may pass in string values for enum compiler options (such as ModuleKind), so convert. */ - function fixupCompilerOptions(options: CompilerOptions, diagnostics: Diagnostic[]): CompilerOptions { + /*@internal*/ + export function fixupCompilerOptions(options: CompilerOptions, diagnostics: Diagnostic[]): CompilerOptions { // Lazily create this value to fix module loading errors. commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || filter(optionDeclarations, o => - typeof o.type === "object" && !forEachProperty(o.type, v => typeof v !== "number")); + typeof o.type === "object" && !forEachEntry(o.type, v => typeof v !== "number")); options = clone(options); @@ -142,7 +143,7 @@ namespace ts { options[opt.name] = parseCustomTypeOption(opt, value, diagnostics); } else { - if (!forEachProperty(opt.type, v => v === value)) { + if (!forEachEntry(opt.type, v => v === value)) { // Supplied value isn't a valid enum value. diagnostics.push(createCompilerDiagnosticForInvalidCustomType(opt)); } diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 921ee7762f8..ae2150d981d 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -1,19 +1,9 @@ { + "extends": "../tsconfig-base", "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": true, "removeComments": false, - "preserveConstEnums": true, - "pretty": true, "outFile": "../../built/local/typescriptServices.js", - "sourceMap": true, - "stripInternal": true, - "noResolve": false, - "declaration": true, - "target": "es5", - "noUnusedLocals": true, - "noUnusedParameters": true, - "types": [] + "declaration": true }, "files": [ "../compiler/core.ts", @@ -67,6 +57,7 @@ "preProcess.ts", "rename.ts", "services.ts", + "transform.ts", "transpile.ts", "shims.ts", "signatureHelp.ts", @@ -88,11 +79,13 @@ "formatting/smartIndenter.ts", "formatting/tokenRange.ts", "codeFixProvider.ts", + "codefixes/fixAddMissingMember.ts", "codefixes/fixExtendsInterfaceBecomesImplements.ts", "codefixes/fixClassIncorrectlyImplementsInterface.ts", "codefixes/fixClassDoesntImplementInheritedAbstractMember.ts", "codefixes/fixClassSuperMustPrecedeThisAccess.ts", "codefixes/fixConstructorForDerivedNeedSuperCall.ts", + "codefixes/fixForgottenThisPropertyAccess.ts", "codefixes/fixes.ts", "codefixes/helpers.ts", "codefixes/importFixes.ts", diff --git a/src/services/types.ts b/src/services/types.ts index 88ffe2950ce..a577fb20aac 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -33,7 +33,7 @@ namespace ts { getConstructSignatures(): Signature[]; getStringIndexType(): Type; getNumberIndexType(): Type; - getBaseTypes(): ObjectType[]; + getBaseTypes(): BaseType[]; getNonNullableType(): Type; } @@ -170,6 +170,11 @@ namespace ts { * completions will not be provided */ getDirectories?(directoryName: string): string[]; + + /** + * Gets a set of custom transformers to use during emit. + */ + getCustomTransformers?(): CustomTransformers | undefined; } // @@ -495,7 +500,7 @@ namespace ts { export interface SymbolDisplayPart { text: string; - kind: string; + kind: string; // A ScriptElementKind } export interface QuickInfo { @@ -765,6 +770,11 @@ namespace ts { export const directory = "directory"; export const externalModuleName = "external module name"; + + /** + * + **/ + export const jsxAttribute = "JSX attribute"; } export namespace ScriptElementKindModifier { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 76a3b43da21..a4f574b9c28 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1,4 +1,4 @@ -// These utilities are common to multiple language service features. +// These utilities are common to multiple language service features. /* @internal */ namespace ts { export const scanner: Scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true); @@ -31,6 +31,7 @@ namespace ts { case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: case SyntaxKind.CatchClause: + case SyntaxKind.JsxAttribute: return SemanticMeaning.Value; case SyntaxKind.TypeParameter: @@ -71,7 +72,10 @@ namespace ts { } export function getMeaningFromLocation(node: Node): SemanticMeaning { - if (node.parent.kind === SyntaxKind.ExportAssignment) { + if (node.kind === SyntaxKind.SourceFile) { + return SemanticMeaning.Value; + } + else if (node.parent.kind === SyntaxKind.ExportAssignment) { return SemanticMeaning.Value | SemanticMeaning.Type | SemanticMeaning.Namespace; } else if (isInRightSideOfImport(node)) { @@ -600,7 +604,7 @@ namespace ts { return !!findChildOfKind(n, kind, sourceFile); } - export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node { + export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node | undefined { return forEach(n.getChildren(sourceFile), c => c.kind === kind && c); } @@ -1112,6 +1116,26 @@ namespace ts { return !tripleSlashDirectivePrefixRegex.test(commentText); } } + + export function createTextSpanFromNode(node: Node, sourceFile?: SourceFile): TextSpan { + return createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); + } + + export function isTypeKeyword(kind: SyntaxKind): boolean { + switch (kind) { + case SyntaxKind.AnyKeyword: + case SyntaxKind.BooleanKeyword: + case SyntaxKind.NeverKeyword: + case SyntaxKind.NumberKeyword: + case SyntaxKind.ObjectKeyword: + case SyntaxKind.StringKeyword: + case SyntaxKind.SymbolKeyword: + case SyntaxKind.VoidKeyword: + return true; + default: + return false; + } + } } // Display-part writer helpers @@ -1143,7 +1167,8 @@ namespace ts { decreaseIndent: () => { indent--; }, clear: resetWriter, trackSymbol: noop, - reportInaccessibleThisError: noop + reportInaccessibleThisError: noop, + reportIllegalExtends: noop }; function writeIndent() { @@ -1296,7 +1321,7 @@ namespace ts { return name; } - export function isImportOrExportSpecifierName(location: Node): boolean { + export function isImportOrExportSpecifierName(location: Node): location is Identifier { return location.parent && (location.parent.kind === SyntaxKind.ImportSpecifier || location.parent.kind === SyntaxKind.ExportSpecifier) && (location.parent).propertyName === location; @@ -1363,4 +1388,4 @@ namespace ts { // First token is the open curly, this is where we want to put the 'super' call. return constructor.body.getFirstToken(sourceFile).getEnd(); } -} \ No newline at end of file +} diff --git a/src/tsconfig-base.json b/src/tsconfig-base.json new file mode 100644 index 00000000000..078fdcc91e7 --- /dev/null +++ b/src/tsconfig-base.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "lib": ["es5", "scripthost"], + "noEmitOnError": true, + "noImplicitAny": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "pretty": true, + "preserveConstEnums": true, + "stripInternal": true, + "sourceMap": true, + "target": "es5", + "types": [] + } +} \ No newline at end of file diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index 5f55c04c9f9..0315fd516b5 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -41,6 +41,7 @@ compile(process.argv.slice(2), { * Please log a "breaking change" issue for any API breaking change affecting this issue */ "use strict"; +exports.__esModule = true; var ts = require("typescript"); function compile(fileNames, options) { var program = ts.createProgram(fileNames, options); diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 1421b53a00c..57ebd64c4e2 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -71,6 +71,7 @@ fileNames.forEach(fileName => { * Please log a "breaking change" issue for any API breaking change affecting this issue */ "use strict"; +exports.__esModule = true; var ts = require("typescript"); function delint(sourceFile) { delintNode(sourceFile); diff --git a/tests/baselines/reference/APISample_parseConfig.js b/tests/baselines/reference/APISample_parseConfig.js index 75ab80d3f23..77f0a07c1df 100644 --- a/tests/baselines/reference/APISample_parseConfig.js +++ b/tests/baselines/reference/APISample_parseConfig.js @@ -43,6 +43,7 @@ export function createProgram(rootFiles: string[], compilerOptionsJson: string): * Please log a "breaking change" issue for any API breaking change affecting this issue */ "use strict"; +exports.__esModule = true; var ts = require("typescript"); function printError(error) { if (!error) { diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index b0783d42a06..0716e59edb7 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -23,6 +23,7 @@ console.log(JSON.stringify(result)); * Please log a "breaking change" issue for any API breaking change affecting this issue */ "use strict"; +exports.__esModule = true; var ts = require("typescript"); var source = "let x: string = 'string'"; var result = ts.transpile(source, { module: ts.ModuleKind.CommonJS }); diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index cb7fc3a4c5c..f4400ccda4c 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -116,6 +116,7 @@ watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS }); * Please log a "breaking change" issue for any API breaking change affecting this issue */ "use strict"; +exports.__esModule = true; var ts = require("typescript"); function watch(rootFileNames, options) { var files = {}; diff --git a/tests/baselines/reference/ES5For-of33.errors.txt b/tests/baselines/reference/ES5For-of33.errors.txt new file mode 100644 index 00000000000..02ba889c542 --- /dev/null +++ b/tests/baselines/reference/ES5For-of33.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/statements/for-ofStatements/ES5For-of33.ts(2,5): error TS2304: Cannot find name 'console'. + + +==== tests/cases/conformance/statements/for-ofStatements/ES5For-of33.ts (1 errors) ==== + for (var v of ['a', 'b', 'c']) { + console.log(v); + ~~~~~~~ +!!! error TS2304: Cannot find name 'console'. + } \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of33.js b/tests/baselines/reference/ES5For-of33.js new file mode 100644 index 00000000000..729c37b8120 --- /dev/null +++ b/tests/baselines/reference/ES5For-of33.js @@ -0,0 +1,31 @@ +//// [ES5For-of33.ts] +for (var v of ['a', 'b', 'c']) { + console.log(v); +} + +//// [ES5For-of33.js] +var __values = (this && this.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; +try { + for (var _a = __values(['a', 'b', 'c']), _b = _a.next(); !_b.done; _b = _a.next()) { + var v = _b.value; + console.log(v); + } +} +catch (e_1_1) { e_1 = { error: e_1_1 }; } +finally { + try { + if (_b && !_b.done && (_c = _a["return"])) _c.call(_a); + } + finally { if (e_1) throw e_1.error; } +} +var e_1, _c; +//# sourceMappingURL=ES5For-of33.js.map \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of33.js.map b/tests/baselines/reference/ES5For-of33.js.map new file mode 100644 index 00000000000..5d5969b4585 --- /dev/null +++ b/tests/baselines/reference/ES5For-of33.js.map @@ -0,0 +1,2 @@ +//// [ES5For-of33.js.map] +{"version":3,"file":"ES5For-of33.js","sourceRoot":"","sources":["ES5For-of33.ts"],"names":[],"mappings":";;;;;;;;;;;IAAA,GAAG,CAAC,CAAU,IAAA,KAAA,SAAA,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA,gBAAA;QAAxB,IAAI,CAAC,WAAA;QACN,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAClB"} \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of33.sourcemap.txt b/tests/baselines/reference/ES5For-of33.sourcemap.txt new file mode 100644 index 00000000000..12dd243cf0e --- /dev/null +++ b/tests/baselines/reference/ES5For-of33.sourcemap.txt @@ -0,0 +1,128 @@ +=================================================================== +JsFile: ES5For-of33.js +mapUrl: ES5For-of33.js.map +sourceRoot: +sources: ES5For-of33.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/conformance/statements/for-ofStatements/ES5For-of33.js +sourceFile:ES5For-of33.ts +------------------------------------------------------------------- +>>>var __values = (this && this.__values) || function (o) { +>>> var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; +>>> if (m) return m.call(o); +>>> return { +>>> next: function () { +>>> if (o && i >= o.length) o = void 0; +>>> return { value: o && o[i++], done: !o }; +>>> } +>>> }; +>>>}; +>>>try { +>>> for (var _a = __values(['a', 'b', 'c']), _b = _a.next(); !_b.done; _b = _a.next()) { +1 >^^^^ +2 > ^^^ +3 > ^ +4 > ^ +5 > ^^^^ +6 > ^^^^^ +7 > ^^^^^^^^^ +8 > ^ +9 > ^^^ +10> ^^ +11> ^^^ +12> ^^ +13> ^^^ +14> ^ +15> ^ +16> ^^^^^^^^^^^^^^^^ +1 > +2 > for +3 > +4 > (var v of +5 > +6 > +7 > +8 > [ +9 > 'a' +10> , +11> 'b' +12> , +13> 'c' +14> ] +15> +16> +1 >Emitted(12, 5) Source(1, 1) + SourceIndex(0) +2 >Emitted(12, 8) Source(1, 4) + SourceIndex(0) +3 >Emitted(12, 9) Source(1, 5) + SourceIndex(0) +4 >Emitted(12, 10) Source(1, 15) + SourceIndex(0) +5 >Emitted(12, 14) Source(1, 15) + SourceIndex(0) +6 >Emitted(12, 19) Source(1, 15) + SourceIndex(0) +7 >Emitted(12, 28) Source(1, 15) + SourceIndex(0) +8 >Emitted(12, 29) Source(1, 16) + SourceIndex(0) +9 >Emitted(12, 32) Source(1, 19) + SourceIndex(0) +10>Emitted(12, 34) Source(1, 21) + SourceIndex(0) +11>Emitted(12, 37) Source(1, 24) + SourceIndex(0) +12>Emitted(12, 39) Source(1, 26) + SourceIndex(0) +13>Emitted(12, 42) Source(1, 29) + SourceIndex(0) +14>Emitted(12, 43) Source(1, 30) + SourceIndex(0) +15>Emitted(12, 44) Source(1, 30) + SourceIndex(0) +16>Emitted(12, 60) Source(1, 30) + SourceIndex(0) +--- +>>> var v = _b.value; +1 >^^^^^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^^^^^^^^^ +1 > +2 > var +3 > v +4 > +1 >Emitted(13, 9) Source(1, 6) + SourceIndex(0) +2 >Emitted(13, 13) Source(1, 10) + SourceIndex(0) +3 >Emitted(13, 14) Source(1, 11) + SourceIndex(0) +4 >Emitted(13, 25) Source(1, 11) + SourceIndex(0) +--- +>>> console.log(v); +1 >^^^^^^^^ +2 > ^^^^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^ +7 > ^ +8 > ^ +1 > of ['a', 'b', 'c']) { + > +2 > console +3 > . +4 > log +5 > ( +6 > v +7 > ) +8 > ; +1 >Emitted(14, 9) Source(2, 5) + SourceIndex(0) +2 >Emitted(14, 16) Source(2, 12) + SourceIndex(0) +3 >Emitted(14, 17) Source(2, 13) + SourceIndex(0) +4 >Emitted(14, 20) Source(2, 16) + SourceIndex(0) +5 >Emitted(14, 21) Source(2, 17) + SourceIndex(0) +6 >Emitted(14, 22) Source(2, 18) + SourceIndex(0) +7 >Emitted(14, 23) Source(2, 19) + SourceIndex(0) +8 >Emitted(14, 24) Source(2, 20) + SourceIndex(0) +--- +>>> } +1 >^^^^^ +1 > + >} +1 >Emitted(15, 6) Source(3, 2) + SourceIndex(0) +--- +>>>} +>>>catch (e_1_1) { e_1 = { error: e_1_1 }; } +>>>finally { +>>> try { +>>> if (_b && !_b.done && (_c = _a["return"])) _c.call(_a); +>>> } +>>> finally { if (e_1) throw e_1.error; } +>>>} +>>>var e_1, _c; +>>>//# sourceMappingURL=ES5For-of33.js.map \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of34.errors.txt b/tests/baselines/reference/ES5For-of34.errors.txt new file mode 100644 index 00000000000..46f9666f776 --- /dev/null +++ b/tests/baselines/reference/ES5For-of34.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/statements/for-ofStatements/ES5For-of34.ts(4,6): error TS2322: Type 'string' is not assignable to type 'number'. + + +==== tests/cases/conformance/statements/for-ofStatements/ES5For-of34.ts (1 errors) ==== + function foo() { + return { x: 0 }; + } + for (foo().x of ['a', 'b', 'c']) { + ~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + var p = foo().x; + } \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of34.js b/tests/baselines/reference/ES5For-of34.js new file mode 100644 index 00000000000..307a7505d09 --- /dev/null +++ b/tests/baselines/reference/ES5For-of34.js @@ -0,0 +1,37 @@ +//// [ES5For-of34.ts] +function foo() { + return { x: 0 }; +} +for (foo().x of ['a', 'b', 'c']) { + var p = foo().x; +} + +//// [ES5For-of34.js] +var __values = (this && this.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; +function foo() { + return { x: 0 }; +} +try { + for (var _a = __values(['a', 'b', 'c']), _b = _a.next(); !_b.done; _b = _a.next()) { + foo().x = _b.value; + var p = foo().x; + } +} +catch (e_1_1) { e_1 = { error: e_1_1 }; } +finally { + try { + if (_b && !_b.done && (_c = _a["return"])) _c.call(_a); + } + finally { if (e_1) throw e_1.error; } +} +var e_1, _c; +//# sourceMappingURL=ES5For-of34.js.map \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of34.js.map b/tests/baselines/reference/ES5For-of34.js.map new file mode 100644 index 00000000000..041fda734b5 --- /dev/null +++ b/tests/baselines/reference/ES5For-of34.js.map @@ -0,0 +1,2 @@ +//// [ES5For-of34.js.map] +{"version":3,"file":"ES5For-of34.js","sourceRoot":"","sources":["ES5For-of34.ts"],"names":[],"mappings":";;;;;;;;;;AAAA;IACI,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACpB,CAAC;;IACD,GAAG,CAAC,CAAY,IAAA,KAAA,SAAA,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA,gBAAA;QAA1B,GAAG,EAAE,CAAC,CAAC,WAAA;QACR,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;KACnB"} \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of34.sourcemap.txt b/tests/baselines/reference/ES5For-of34.sourcemap.txt new file mode 100644 index 00000000000..540d52cc581 --- /dev/null +++ b/tests/baselines/reference/ES5For-of34.sourcemap.txt @@ -0,0 +1,184 @@ +=================================================================== +JsFile: ES5For-of34.js +mapUrl: ES5For-of34.js.map +sourceRoot: +sources: ES5For-of34.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/conformance/statements/for-ofStatements/ES5For-of34.js +sourceFile:ES5For-of34.ts +------------------------------------------------------------------- +>>>var __values = (this && this.__values) || function (o) { +>>> var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; +>>> if (m) return m.call(o); +>>> return { +>>> next: function () { +>>> if (o && i >= o.length) o = void 0; +>>> return { value: o && o[i++], done: !o }; +>>> } +>>> }; +>>>}; +>>>function foo() { +1 > +2 >^^^^^^^^^^^^^^^^^^^^^-> +1 > +1 >Emitted(11, 1) Source(1, 1) + SourceIndex(0) +--- +>>> return { x: 0 }; +1->^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^ +7 > ^ +8 > ^^ +9 > ^ +1->function foo() { + > +2 > return +3 > +4 > { +5 > x +6 > : +7 > 0 +8 > } +9 > ; +1->Emitted(12, 5) Source(2, 5) + SourceIndex(0) +2 >Emitted(12, 11) Source(2, 11) + SourceIndex(0) +3 >Emitted(12, 12) Source(2, 12) + SourceIndex(0) +4 >Emitted(12, 14) Source(2, 14) + SourceIndex(0) +5 >Emitted(12, 15) Source(2, 15) + SourceIndex(0) +6 >Emitted(12, 17) Source(2, 17) + SourceIndex(0) +7 >Emitted(12, 18) Source(2, 18) + SourceIndex(0) +8 >Emitted(12, 20) Source(2, 20) + SourceIndex(0) +9 >Emitted(12, 21) Source(2, 21) + SourceIndex(0) +--- +>>>} +1 > +2 >^ +3 > ^^^^^-> +1 > + > +2 >} +1 >Emitted(13, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(13, 2) Source(3, 2) + SourceIndex(0) +--- +>>>try { +>>> for (var _a = __values(['a', 'b', 'c']), _b = _a.next(); !_b.done; _b = _a.next()) { +1->^^^^ +2 > ^^^ +3 > ^ +4 > ^ +5 > ^^^^ +6 > ^^^^^ +7 > ^^^^^^^^^ +8 > ^ +9 > ^^^ +10> ^^ +11> ^^^ +12> ^^ +13> ^^^ +14> ^ +15> ^ +16> ^^^^^^^^^^^^^^^^ +1-> + > +2 > for +3 > +4 > (foo().x of +5 > +6 > +7 > +8 > [ +9 > 'a' +10> , +11> 'b' +12> , +13> 'c' +14> ] +15> +16> +1->Emitted(15, 5) Source(4, 1) + SourceIndex(0) +2 >Emitted(15, 8) Source(4, 4) + SourceIndex(0) +3 >Emitted(15, 9) Source(4, 5) + SourceIndex(0) +4 >Emitted(15, 10) Source(4, 17) + SourceIndex(0) +5 >Emitted(15, 14) Source(4, 17) + SourceIndex(0) +6 >Emitted(15, 19) Source(4, 17) + SourceIndex(0) +7 >Emitted(15, 28) Source(4, 17) + SourceIndex(0) +8 >Emitted(15, 29) Source(4, 18) + SourceIndex(0) +9 >Emitted(15, 32) Source(4, 21) + SourceIndex(0) +10>Emitted(15, 34) Source(4, 23) + SourceIndex(0) +11>Emitted(15, 37) Source(4, 26) + SourceIndex(0) +12>Emitted(15, 39) Source(4, 28) + SourceIndex(0) +13>Emitted(15, 42) Source(4, 31) + SourceIndex(0) +14>Emitted(15, 43) Source(4, 32) + SourceIndex(0) +15>Emitted(15, 44) Source(4, 32) + SourceIndex(0) +16>Emitted(15, 60) Source(4, 32) + SourceIndex(0) +--- +>>> foo().x = _b.value; +1 >^^^^^^^^ +2 > ^^^ +3 > ^^ +4 > ^ +5 > ^ +6 > ^^^^^^^^^^^ +1 > +2 > foo +3 > () +4 > . +5 > x +6 > +1 >Emitted(16, 9) Source(4, 6) + SourceIndex(0) +2 >Emitted(16, 12) Source(4, 9) + SourceIndex(0) +3 >Emitted(16, 14) Source(4, 11) + SourceIndex(0) +4 >Emitted(16, 15) Source(4, 12) + SourceIndex(0) +5 >Emitted(16, 16) Source(4, 13) + SourceIndex(0) +6 >Emitted(16, 27) Source(4, 13) + SourceIndex(0) +--- +>>> var p = foo().x; +1 >^^^^^^^^ +2 > ^^^^ +3 > ^ +4 > ^^^ +5 > ^^^ +6 > ^^ +7 > ^ +8 > ^ +9 > ^ +1 > of ['a', 'b', 'c']) { + > +2 > var +3 > p +4 > = +5 > foo +6 > () +7 > . +8 > x +9 > ; +1 >Emitted(17, 9) Source(5, 5) + SourceIndex(0) +2 >Emitted(17, 13) Source(5, 9) + SourceIndex(0) +3 >Emitted(17, 14) Source(5, 10) + SourceIndex(0) +4 >Emitted(17, 17) Source(5, 13) + SourceIndex(0) +5 >Emitted(17, 20) Source(5, 16) + SourceIndex(0) +6 >Emitted(17, 22) Source(5, 18) + SourceIndex(0) +7 >Emitted(17, 23) Source(5, 19) + SourceIndex(0) +8 >Emitted(17, 24) Source(5, 20) + SourceIndex(0) +9 >Emitted(17, 25) Source(5, 21) + SourceIndex(0) +--- +>>> } +1 >^^^^^ +1 > + >} +1 >Emitted(18, 6) Source(6, 2) + SourceIndex(0) +--- +>>>} +>>>catch (e_1_1) { e_1 = { error: e_1_1 }; } +>>>finally { +>>> try { +>>> if (_b && !_b.done && (_c = _a["return"])) _c.call(_a); +>>> } +>>> finally { if (e_1) throw e_1.error; } +>>>} +>>>var e_1, _c; +>>>//# sourceMappingURL=ES5For-of34.js.map \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of35.errors.txt b/tests/baselines/reference/ES5For-of35.errors.txt new file mode 100644 index 00000000000..8c43d959888 --- /dev/null +++ b/tests/baselines/reference/ES5For-of35.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/statements/for-ofStatements/ES5For-of35.ts(1,13): error TS2459: Type 'number' has no property 'x' and no string index signature. +tests/cases/conformance/statements/for-ofStatements/ES5For-of35.ts(1,23): error TS2459: Type 'number' has no property 'y' and no string index signature. + + +==== tests/cases/conformance/statements/for-ofStatements/ES5For-of35.ts (2 errors) ==== + for (const {x: a = 0, y: b = 1} of [2, 3]) { + ~ +!!! error TS2459: Type 'number' has no property 'x' and no string index signature. + ~ +!!! error TS2459: Type 'number' has no property 'y' and no string index signature. + a; + b; + } \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of35.js b/tests/baselines/reference/ES5For-of35.js new file mode 100644 index 00000000000..597296cacae --- /dev/null +++ b/tests/baselines/reference/ES5For-of35.js @@ -0,0 +1,33 @@ +//// [ES5For-of35.ts] +for (const {x: a = 0, y: b = 1} of [2, 3]) { + a; + b; +} + +//// [ES5For-of35.js] +var __values = (this && this.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; +try { + for (var _a = __values([2, 3]), _b = _a.next(); !_b.done; _b = _a.next()) { + var _c = _b.value, _d = _c.x, a = _d === void 0 ? 0 : _d, _e = _c.y, b = _e === void 0 ? 1 : _e; + a; + b; + } +} +catch (e_1_1) { e_1 = { error: e_1_1 }; } +finally { + try { + if (_b && !_b.done && (_f = _a["return"])) _f.call(_a); + } + finally { if (e_1) throw e_1.error; } +} +var e_1, _f; +//# sourceMappingURL=ES5For-of35.js.map \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of35.js.map b/tests/baselines/reference/ES5For-of35.js.map new file mode 100644 index 00000000000..f1ee2418d17 --- /dev/null +++ b/tests/baselines/reference/ES5For-of35.js.map @@ -0,0 +1,2 @@ +//// [ES5For-of35.js.map] +{"version":3,"file":"ES5For-of35.js","sourceRoot":"","sources":["ES5For-of35.ts"],"names":[],"mappings":";;;;;;;;;;;IAAA,GAAG,CAAC,CAA+B,IAAA,KAAA,SAAA,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA,gBAAA;QAA9B,IAAA,aAAoB,EAAnB,SAAQ,EAAR,0BAAQ,EAAE,SAAQ,EAAR,0BAAQ;QAC1B,CAAC,CAAC;QACF,CAAC,CAAC;KACL"} \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of35.sourcemap.txt b/tests/baselines/reference/ES5For-of35.sourcemap.txt new file mode 100644 index 00000000000..1961188da49 --- /dev/null +++ b/tests/baselines/reference/ES5For-of35.sourcemap.txt @@ -0,0 +1,142 @@ +=================================================================== +JsFile: ES5For-of35.js +mapUrl: ES5For-of35.js.map +sourceRoot: +sources: ES5For-of35.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/conformance/statements/for-ofStatements/ES5For-of35.js +sourceFile:ES5For-of35.ts +------------------------------------------------------------------- +>>>var __values = (this && this.__values) || function (o) { +>>> var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; +>>> if (m) return m.call(o); +>>> return { +>>> next: function () { +>>> if (o && i >= o.length) o = void 0; +>>> return { value: o && o[i++], done: !o }; +>>> } +>>> }; +>>>}; +>>>try { +>>> for (var _a = __values([2, 3]), _b = _a.next(); !_b.done; _b = _a.next()) { +1 >^^^^ +2 > ^^^ +3 > ^ +4 > ^ +5 > ^^^^ +6 > ^^^^^ +7 > ^^^^^^^^^ +8 > ^ +9 > ^ +10> ^^ +11> ^ +12> ^ +13> ^ +14> ^^^^^^^^^^^^^^^^ +15> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 > for +3 > +4 > (const {x: a = 0, y: b = 1} of +5 > +6 > +7 > +8 > [ +9 > 2 +10> , +11> 3 +12> ] +13> +14> +1 >Emitted(12, 5) Source(1, 1) + SourceIndex(0) +2 >Emitted(12, 8) Source(1, 4) + SourceIndex(0) +3 >Emitted(12, 9) Source(1, 5) + SourceIndex(0) +4 >Emitted(12, 10) Source(1, 36) + SourceIndex(0) +5 >Emitted(12, 14) Source(1, 36) + SourceIndex(0) +6 >Emitted(12, 19) Source(1, 36) + SourceIndex(0) +7 >Emitted(12, 28) Source(1, 36) + SourceIndex(0) +8 >Emitted(12, 29) Source(1, 37) + SourceIndex(0) +9 >Emitted(12, 30) Source(1, 38) + SourceIndex(0) +10>Emitted(12, 32) Source(1, 40) + SourceIndex(0) +11>Emitted(12, 33) Source(1, 41) + SourceIndex(0) +12>Emitted(12, 34) Source(1, 42) + SourceIndex(0) +13>Emitted(12, 35) Source(1, 42) + SourceIndex(0) +14>Emitted(12, 51) Source(1, 42) + SourceIndex(0) +--- +>>> var _c = _b.value, _d = _c.x, a = _d === void 0 ? 0 : _d, _e = _c.y, b = _e === void 0 ? 1 : _e; +1->^^^^^^^^ +2 > ^^^^ +3 > ^^^^^^^^^^^^^ +4 > ^^ +5 > ^^^^^^^^^ +6 > ^^ +7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ +8 > ^^ +9 > ^^^^^^^^^ +10> ^^ +11> ^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 > +3 > {x: a = 0, y: b = 1} +4 > +5 > x: a = 0 +6 > +7 > x: a = 0 +8 > , +9 > y: b = 1 +10> +11> y: b = 1 +1->Emitted(13, 9) Source(1, 12) + SourceIndex(0) +2 >Emitted(13, 13) Source(1, 12) + SourceIndex(0) +3 >Emitted(13, 26) Source(1, 32) + SourceIndex(0) +4 >Emitted(13, 28) Source(1, 13) + SourceIndex(0) +5 >Emitted(13, 37) Source(1, 21) + SourceIndex(0) +6 >Emitted(13, 39) Source(1, 13) + SourceIndex(0) +7 >Emitted(13, 65) Source(1, 21) + SourceIndex(0) +8 >Emitted(13, 67) Source(1, 23) + SourceIndex(0) +9 >Emitted(13, 76) Source(1, 31) + SourceIndex(0) +10>Emitted(13, 78) Source(1, 23) + SourceIndex(0) +11>Emitted(13, 104) Source(1, 31) + SourceIndex(0) +--- +>>> a; +1 >^^^^^^^^ +2 > ^ +3 > ^ +4 > ^-> +1 >} of [2, 3]) { + > +2 > a +3 > ; +1 >Emitted(14, 9) Source(2, 5) + SourceIndex(0) +2 >Emitted(14, 10) Source(2, 6) + SourceIndex(0) +3 >Emitted(14, 11) Source(2, 7) + SourceIndex(0) +--- +>>> b; +1->^^^^^^^^ +2 > ^ +3 > ^ +1-> + > +2 > b +3 > ; +1->Emitted(15, 9) Source(3, 5) + SourceIndex(0) +2 >Emitted(15, 10) Source(3, 6) + SourceIndex(0) +3 >Emitted(15, 11) Source(3, 7) + SourceIndex(0) +--- +>>> } +1 >^^^^^ +1 > + >} +1 >Emitted(16, 6) Source(4, 2) + SourceIndex(0) +--- +>>>} +>>>catch (e_1_1) { e_1 = { error: e_1_1 }; } +>>>finally { +>>> try { +>>> if (_b && !_b.done && (_f = _a["return"])) _f.call(_a); +>>> } +>>> finally { if (e_1) throw e_1.error; } +>>>} +>>>var e_1, _f; +>>>//# sourceMappingURL=ES5For-of35.js.map \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of36.errors.txt b/tests/baselines/reference/ES5For-of36.errors.txt new file mode 100644 index 00000000000..86a40dcffa5 --- /dev/null +++ b/tests/baselines/reference/ES5For-of36.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/statements/for-ofStatements/ES5For-of36.ts(1,10): error TS2548: Type 'number' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator. + + +==== tests/cases/conformance/statements/for-ofStatements/ES5For-of36.ts (1 errors) ==== + for (let [a = 0, b = 1] of [2, 3]) { + ~~~~~~~~~~~~~~ +!!! error TS2548: Type 'number' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator. + a; + b; + } \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of36.js b/tests/baselines/reference/ES5For-of36.js new file mode 100644 index 00000000000..fca89ee922b --- /dev/null +++ b/tests/baselines/reference/ES5For-of36.js @@ -0,0 +1,49 @@ +//// [ES5For-of36.ts] +for (let [a = 0, b = 1] of [2, 3]) { + a; + b; +} + +//// [ES5For-of36.js] +var __values = (this && this.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +try { + for (var _a = __values([2, 3]), _b = _a.next(); !_b.done; _b = _a.next()) { + var _c = __read(_b.value, 2), _d = _c[0], a = _d === void 0 ? 0 : _d, _e = _c[1], b = _e === void 0 ? 1 : _e; + a; + b; + } +} +catch (e_1_1) { e_1 = { error: e_1_1 }; } +finally { + try { + if (_b && !_b.done && (_f = _a["return"])) _f.call(_a); + } + finally { if (e_1) throw e_1.error; } +} +var e_1, _f; +//# sourceMappingURL=ES5For-of36.js.map \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of36.js.map b/tests/baselines/reference/ES5For-of36.js.map new file mode 100644 index 00000000000..f53bc850818 --- /dev/null +++ b/tests/baselines/reference/ES5For-of36.js.map @@ -0,0 +1,2 @@ +//// [ES5For-of36.js.map] +{"version":3,"file":"ES5For-of36.js","sourceRoot":"","sources":["ES5For-of36.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA,GAAG,CAAC,CAAuB,IAAA,KAAA,SAAA,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA,gBAAA;QAAxB,IAAA,wBAAc,EAAb,UAAK,EAAL,0BAAK,EAAE,UAAK,EAAL,0BAAK;QAClB,CAAC,CAAC;QACF,CAAC,CAAC;KACL"} \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of36.sourcemap.txt b/tests/baselines/reference/ES5For-of36.sourcemap.txt new file mode 100644 index 00000000000..4b16e02b3b1 --- /dev/null +++ b/tests/baselines/reference/ES5For-of36.sourcemap.txt @@ -0,0 +1,158 @@ +=================================================================== +JsFile: ES5For-of36.js +mapUrl: ES5For-of36.js.map +sourceRoot: +sources: ES5For-of36.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/conformance/statements/for-ofStatements/ES5For-of36.js +sourceFile:ES5For-of36.ts +------------------------------------------------------------------- +>>>var __values = (this && this.__values) || function (o) { +>>> var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; +>>> if (m) return m.call(o); +>>> return { +>>> next: function () { +>>> if (o && i >= o.length) o = void 0; +>>> return { value: o && o[i++], done: !o }; +>>> } +>>> }; +>>>}; +>>>var __read = (this && this.__read) || function (o, n) { +>>> var m = typeof Symbol === "function" && o[Symbol.iterator]; +>>> if (!m) return o; +>>> var i = m.call(o), r, ar = [], e; +>>> try { +>>> while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); +>>> } +>>> catch (error) { e = { error: error }; } +>>> finally { +>>> try { +>>> if (r && !r.done && (m = i["return"])) m.call(i); +>>> } +>>> finally { if (e) throw e.error; } +>>> } +>>> return ar; +>>>}; +>>>try { +>>> for (var _a = __values([2, 3]), _b = _a.next(); !_b.done; _b = _a.next()) { +1 >^^^^ +2 > ^^^ +3 > ^ +4 > ^ +5 > ^^^^ +6 > ^^^^^ +7 > ^^^^^^^^^ +8 > ^ +9 > ^ +10> ^^ +11> ^ +12> ^ +13> ^ +14> ^^^^^^^^^^^^^^^^ +15> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 > for +3 > +4 > (let [a = 0, b = 1] of +5 > +6 > +7 > +8 > [ +9 > 2 +10> , +11> 3 +12> ] +13> +14> +1 >Emitted(28, 5) Source(1, 1) + SourceIndex(0) +2 >Emitted(28, 8) Source(1, 4) + SourceIndex(0) +3 >Emitted(28, 9) Source(1, 5) + SourceIndex(0) +4 >Emitted(28, 10) Source(1, 28) + SourceIndex(0) +5 >Emitted(28, 14) Source(1, 28) + SourceIndex(0) +6 >Emitted(28, 19) Source(1, 28) + SourceIndex(0) +7 >Emitted(28, 28) Source(1, 28) + SourceIndex(0) +8 >Emitted(28, 29) Source(1, 29) + SourceIndex(0) +9 >Emitted(28, 30) Source(1, 30) + SourceIndex(0) +10>Emitted(28, 32) Source(1, 32) + SourceIndex(0) +11>Emitted(28, 33) Source(1, 33) + SourceIndex(0) +12>Emitted(28, 34) Source(1, 34) + SourceIndex(0) +13>Emitted(28, 35) Source(1, 34) + SourceIndex(0) +14>Emitted(28, 51) Source(1, 34) + SourceIndex(0) +--- +>>> var _c = __read(_b.value, 2), _d = _c[0], a = _d === void 0 ? 0 : _d, _e = _c[1], b = _e === void 0 ? 1 : _e; +1->^^^^^^^^ +2 > ^^^^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^ +4 > ^^ +5 > ^^^^^^^^^^ +6 > ^^ +7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ +8 > ^^ +9 > ^^^^^^^^^^ +10> ^^ +11> ^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +2 > +3 > [a = 0, b = 1] +4 > +5 > a = 0 +6 > +7 > a = 0 +8 > , +9 > b = 1 +10> +11> b = 1 +1->Emitted(29, 9) Source(1, 10) + SourceIndex(0) +2 >Emitted(29, 13) Source(1, 10) + SourceIndex(0) +3 >Emitted(29, 37) Source(1, 24) + SourceIndex(0) +4 >Emitted(29, 39) Source(1, 11) + SourceIndex(0) +5 >Emitted(29, 49) Source(1, 16) + SourceIndex(0) +6 >Emitted(29, 51) Source(1, 11) + SourceIndex(0) +7 >Emitted(29, 77) Source(1, 16) + SourceIndex(0) +8 >Emitted(29, 79) Source(1, 18) + SourceIndex(0) +9 >Emitted(29, 89) Source(1, 23) + SourceIndex(0) +10>Emitted(29, 91) Source(1, 18) + SourceIndex(0) +11>Emitted(29, 117) Source(1, 23) + SourceIndex(0) +--- +>>> a; +1 >^^^^^^^^ +2 > ^ +3 > ^ +4 > ^-> +1 >] of [2, 3]) { + > +2 > a +3 > ; +1 >Emitted(30, 9) Source(2, 5) + SourceIndex(0) +2 >Emitted(30, 10) Source(2, 6) + SourceIndex(0) +3 >Emitted(30, 11) Source(2, 7) + SourceIndex(0) +--- +>>> b; +1->^^^^^^^^ +2 > ^ +3 > ^ +1-> + > +2 > b +3 > ; +1->Emitted(31, 9) Source(3, 5) + SourceIndex(0) +2 >Emitted(31, 10) Source(3, 6) + SourceIndex(0) +3 >Emitted(31, 11) Source(3, 7) + SourceIndex(0) +--- +>>> } +1 >^^^^^ +1 > + >} +1 >Emitted(32, 6) Source(4, 2) + SourceIndex(0) +--- +>>>} +>>>catch (e_1_1) { e_1 = { error: e_1_1 }; } +>>>finally { +>>> try { +>>> if (_b && !_b.done && (_f = _a["return"])) _f.call(_a); +>>> } +>>> finally { if (e_1) throw e_1.error; } +>>>} +>>>var e_1, _f; +>>>//# sourceMappingURL=ES5For-of36.js.map \ No newline at end of file diff --git a/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js b/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js index ec0ed5494a4..c3084700547 100644 --- a/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js +++ b/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js @@ -21,11 +21,16 @@ module A { //// [ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A; (function (A) { var Point = (function () { @@ -38,7 +43,7 @@ var A; var Point3d = (function (_super) { __extends(Point3d, _super); function Point3d() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Point3d; }(Point)); diff --git a/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js b/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js index bae9593fb98..fe4308281d1 100644 --- a/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js +++ b/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js @@ -25,11 +25,16 @@ module A { //// [ExportClassWithInaccessibleTypeInTypeParameterConstraint.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A; (function (A) { var Point = (function () { @@ -41,7 +46,7 @@ var A; var Point3d = (function (_super) { __extends(Point3d, _super); function Point3d() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Point3d; }(Point)); diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.js b/tests/baselines/reference/FunctionDeclaration10_es6.js index 6ac2ec8d194..aca7c00e58c 100644 --- a/tests/baselines/reference/FunctionDeclaration10_es6.js +++ b/tests/baselines/reference/FunctionDeclaration10_es6.js @@ -3,9 +3,7 @@ function * foo(a = yield => yield) { } //// [FunctionDeclaration10_es6.js] -function* foo(a) { - if (a === void 0) { a = yield; } -} +function* foo(a = yield) { } yield; { } diff --git a/tests/baselines/reference/FunctionDeclaration11_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration11_es6.errors.txt deleted file mode 100644 index 4db3842e91d..00000000000 --- a/tests/baselines/reference/FunctionDeclaration11_es6.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - - -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts (1 errors) ==== - function * yield() { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration11_es6.symbols b/tests/baselines/reference/FunctionDeclaration11_es6.symbols new file mode 100644 index 00000000000..a51b763e4bf --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration11_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts === +function * yield() { +>yield : Symbol(yield, Decl(FunctionDeclaration11_es6.ts, 0, 0)) +} diff --git a/tests/baselines/reference/FunctionDeclaration11_es6.types b/tests/baselines/reference/FunctionDeclaration11_es6.types new file mode 100644 index 00000000000..0a312c2661c --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration11_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts === +function * yield() { +>yield : () => IterableIterator +} diff --git a/tests/baselines/reference/FunctionDeclaration12_es6.js b/tests/baselines/reference/FunctionDeclaration12_es6.js index 87ea08215fe..5d55d3231b0 100644 --- a/tests/baselines/reference/FunctionDeclaration12_es6.js +++ b/tests/baselines/reference/FunctionDeclaration12_es6.js @@ -2,4 +2,4 @@ var v = function * yield() { } //// [FunctionDeclaration12_es6.js] -var v = function* () { }, yield = function () { }; +var v = function* () { }, yield = () => { }; diff --git a/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt index fa675446617..1f921475fd3 100644 --- a/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt @@ -1,11 +1,8 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(3,11): error TS2304: Cannot find name 'yield'. -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts (1 errors) ==== function * foo() { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. // Legal to use 'yield' in a type context. var v: yield; ~~~~~ diff --git a/tests/baselines/reference/FunctionDeclaration1_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration1_es6.errors.txt deleted file mode 100644 index d3dab521926..00000000000 --- a/tests/baselines/reference/FunctionDeclaration1_es6.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - - -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts (1 errors) ==== - function * foo() { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration1_es6.symbols b/tests/baselines/reference/FunctionDeclaration1_es6.symbols new file mode 100644 index 00000000000..7683664cb93 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration1_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts === +function * foo() { +>foo : Symbol(foo, Decl(FunctionDeclaration1_es6.ts, 0, 0)) +} diff --git a/tests/baselines/reference/FunctionDeclaration1_es6.types b/tests/baselines/reference/FunctionDeclaration1_es6.types new file mode 100644 index 00000000000..548b1eb98d6 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration1_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts === +function * foo() { +>foo : () => IterableIterator +} diff --git a/tests/baselines/reference/FunctionDeclaration3_es6.js b/tests/baselines/reference/FunctionDeclaration3_es6.js index e1df936dd21..eebce92f5b9 100644 --- a/tests/baselines/reference/FunctionDeclaration3_es6.js +++ b/tests/baselines/reference/FunctionDeclaration3_es6.js @@ -3,6 +3,5 @@ function f(yield = yield) { } //// [FunctionDeclaration3_es6.js] -function f(yield) { - if (yield === void 0) { yield = yield; } +function f(yield = yield) { } diff --git a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt index 60798f7dbd6..04806c7aae9 100644 --- a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt @@ -1,11 +1,8 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2523: 'yield' expressions cannot be used in a parameter initializer. -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts (1 errors) ==== function*foo(a = yield) { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. ~~~~~ !!! error TS2523: 'yield' expressions cannot be used in a parameter initializer. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration6_es6.js b/tests/baselines/reference/FunctionDeclaration6_es6.js index e0b871a9172..bc8c3b030ae 100644 --- a/tests/baselines/reference/FunctionDeclaration6_es6.js +++ b/tests/baselines/reference/FunctionDeclaration6_es6.js @@ -3,6 +3,5 @@ function*foo(a = yield) { } //// [FunctionDeclaration6_es6.js] -function* foo(a) { - if (a === void 0) { a = yield; } +function* foo(a = yield) { } diff --git a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt index 3c1b950bea5..e0273c3bb44 100644 --- a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt @@ -1,16 +1,10 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,11): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2523: 'yield' expressions cannot be used in a parameter initializer. -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (3 errors) ==== +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (1 errors) ==== function*bar() { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. // 'yield' here is an identifier, and not a yield expression. function*foo(a = yield) { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. ~~~~~ !!! error TS2523: 'yield' expressions cannot be used in a parameter initializer. } diff --git a/tests/baselines/reference/FunctionDeclaration7_es6.js b/tests/baselines/reference/FunctionDeclaration7_es6.js index 49b43e2a2db..18256461aeb 100644 --- a/tests/baselines/reference/FunctionDeclaration7_es6.js +++ b/tests/baselines/reference/FunctionDeclaration7_es6.js @@ -8,7 +8,6 @@ function*bar() { //// [FunctionDeclaration7_es6.js] function* bar() { // 'yield' here is an identifier, and not a yield expression. - function* foo(a) { - if (a === void 0) { a = yield; } + function* foo(a = yield) { } } diff --git a/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt deleted file mode 100644 index a2d2121d7fa..00000000000 --- a/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - - -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (1 errors) ==== - function * foo() { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - var v = { [yield]: foo } - } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration9_es6.js b/tests/baselines/reference/FunctionDeclaration9_es6.js index 720e276ccba..b5be11778ac 100644 --- a/tests/baselines/reference/FunctionDeclaration9_es6.js +++ b/tests/baselines/reference/FunctionDeclaration9_es6.js @@ -5,6 +5,5 @@ function * foo() { //// [FunctionDeclaration9_es6.js] function* foo() { - var v = (_a = {}, _a[yield] = foo, _a); - var _a; + var v = { [yield]: foo }; } diff --git a/tests/baselines/reference/FunctionDeclaration9_es6.symbols b/tests/baselines/reference/FunctionDeclaration9_es6.symbols new file mode 100644 index 00000000000..0797c51331c --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration9_es6.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts === +function * foo() { +>foo : Symbol(foo, Decl(FunctionDeclaration9_es6.ts, 0, 0)) + + var v = { [yield]: foo } +>v : Symbol(v, Decl(FunctionDeclaration9_es6.ts, 1, 5)) +>foo : Symbol(foo, Decl(FunctionDeclaration9_es6.ts, 0, 0)) +} diff --git a/tests/baselines/reference/FunctionDeclaration9_es6.types b/tests/baselines/reference/FunctionDeclaration9_es6.types new file mode 100644 index 00000000000..182b90b3f7a --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration9_es6.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts === +function * foo() { +>foo : () => IterableIterator + + var v = { [yield]: foo } +>v : { [x: number]: () => IterableIterator; } +>{ [yield]: foo } : { [x: number]: () => IterableIterator; } +>yield : any +>foo : () => IterableIterator +} diff --git a/tests/baselines/reference/FunctionExpression1_es6.errors.txt b/tests/baselines/reference/FunctionExpression1_es6.errors.txt deleted file mode 100644 index 9c1f798c5ad..00000000000 --- a/tests/baselines/reference/FunctionExpression1_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts(1,18): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - - -==== tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts (1 errors) ==== - var v = function * () { } - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionExpression1_es6.symbols b/tests/baselines/reference/FunctionExpression1_es6.symbols new file mode 100644 index 00000000000..4e1ed33ea1c --- /dev/null +++ b/tests/baselines/reference/FunctionExpression1_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts === +var v = function * () { } +>v : Symbol(v, Decl(FunctionExpression1_es6.ts, 0, 3)) + diff --git a/tests/baselines/reference/FunctionExpression1_es6.types b/tests/baselines/reference/FunctionExpression1_es6.types new file mode 100644 index 00000000000..1bba41f11f2 --- /dev/null +++ b/tests/baselines/reference/FunctionExpression1_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts === +var v = function * () { } +>v : () => IterableIterator +>function * () { } : () => IterableIterator + diff --git a/tests/baselines/reference/FunctionExpression2_es6.errors.txt b/tests/baselines/reference/FunctionExpression2_es6.errors.txt deleted file mode 100644 index 9248962e620..00000000000 --- a/tests/baselines/reference/FunctionExpression2_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts(1,18): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - - -==== tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts (1 errors) ==== - var v = function * foo() { } - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionExpression2_es6.symbols b/tests/baselines/reference/FunctionExpression2_es6.symbols new file mode 100644 index 00000000000..1fc8c3c10d6 --- /dev/null +++ b/tests/baselines/reference/FunctionExpression2_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts === +var v = function * foo() { } +>v : Symbol(v, Decl(FunctionExpression2_es6.ts, 0, 3)) +>foo : Symbol(foo, Decl(FunctionExpression2_es6.ts, 0, 7)) + diff --git a/tests/baselines/reference/FunctionExpression2_es6.types b/tests/baselines/reference/FunctionExpression2_es6.types new file mode 100644 index 00000000000..7a421dd1abf --- /dev/null +++ b/tests/baselines/reference/FunctionExpression2_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts === +var v = function * foo() { } +>v : () => IterableIterator +>function * foo() { } : () => IterableIterator +>foo : () => IterableIterator + diff --git a/tests/baselines/reference/FunctionPropertyAssignments1_es6.errors.txt b/tests/baselines/reference/FunctionPropertyAssignments1_es6.errors.txt deleted file mode 100644 index fd463eed02d..00000000000 --- a/tests/baselines/reference/FunctionPropertyAssignments1_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts(1,11): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - - -==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts (1 errors) ==== - var v = { *foo() { } } - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionPropertyAssignments1_es6.js b/tests/baselines/reference/FunctionPropertyAssignments1_es6.js index 5975745391a..be89637c5ea 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments1_es6.js +++ b/tests/baselines/reference/FunctionPropertyAssignments1_es6.js @@ -2,4 +2,4 @@ var v = { *foo() { } } //// [FunctionPropertyAssignments1_es6.js] -var v = { foo: function* () { } }; +var v = { *foo() { } }; diff --git a/tests/baselines/reference/FunctionPropertyAssignments1_es6.symbols b/tests/baselines/reference/FunctionPropertyAssignments1_es6.symbols new file mode 100644 index 00000000000..79aee0f4700 --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments1_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts === +var v = { *foo() { } } +>v : Symbol(v, Decl(FunctionPropertyAssignments1_es6.ts, 0, 3)) +>foo : Symbol(foo, Decl(FunctionPropertyAssignments1_es6.ts, 0, 9)) + diff --git a/tests/baselines/reference/FunctionPropertyAssignments1_es6.types b/tests/baselines/reference/FunctionPropertyAssignments1_es6.types new file mode 100644 index 00000000000..90b8615003e --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments1_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts === +var v = { *foo() { } } +>v : { foo(): IterableIterator; } +>{ *foo() { } } : { foo(): IterableIterator; } +>foo : () => IterableIterator + diff --git a/tests/baselines/reference/FunctionPropertyAssignments2_es6.js b/tests/baselines/reference/FunctionPropertyAssignments2_es6.js index b055960b6a8..b0f66e94c78 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments2_es6.js +++ b/tests/baselines/reference/FunctionPropertyAssignments2_es6.js @@ -2,4 +2,4 @@ var v = { *() { } } //// [FunctionPropertyAssignments2_es6.js] -var v = { : function* () { } }; +var v = { *() { } }; diff --git a/tests/baselines/reference/FunctionPropertyAssignments3_es6.js b/tests/baselines/reference/FunctionPropertyAssignments3_es6.js index 9642c28529d..f13810af3ca 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments3_es6.js +++ b/tests/baselines/reference/FunctionPropertyAssignments3_es6.js @@ -2,4 +2,4 @@ var v = { *{ } } //// [FunctionPropertyAssignments3_es6.js] -var v = { : function* () { } }; +var v = { *() { } }; diff --git a/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt index 35185fdb7c6..143b764c08c 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt +++ b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt @@ -1,10 +1,7 @@ -tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,13): error TS2304: Cannot find name 'foo'. -==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (1 errors) ==== var v = { *[foo()]() { } } - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. ~~~ !!! error TS2304: Cannot find name 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionPropertyAssignments5_es6.js b/tests/baselines/reference/FunctionPropertyAssignments5_es6.js index ba25922b670..027dc6fb41e 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments5_es6.js +++ b/tests/baselines/reference/FunctionPropertyAssignments5_es6.js @@ -2,5 +2,4 @@ var v = { *[foo()]() { } } //// [FunctionPropertyAssignments5_es6.js] -var v = (_a = {}, _a[foo()] = function* () { }, _a); -var _a; +var v = { *[foo()]() { } }; diff --git a/tests/baselines/reference/FunctionPropertyAssignments6_es6.js b/tests/baselines/reference/FunctionPropertyAssignments6_es6.js index edcd227f7b9..e3f7b7e6332 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments6_es6.js +++ b/tests/baselines/reference/FunctionPropertyAssignments6_es6.js @@ -2,4 +2,4 @@ var v = { *() { } } //// [FunctionPropertyAssignments6_es6.js] -var v = { : function* () { } }; +var v = { *() { } }; diff --git a/tests/baselines/reference/MemberFunctionDeclaration1_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration1_es6.errors.txt deleted file mode 100644 index 25cb4ba4240..00000000000 --- a/tests/baselines/reference/MemberFunctionDeclaration1_es6.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts(2,4): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - - -==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts (1 errors) ==== - class C { - *foo() { } - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - } \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration1_es6.js b/tests/baselines/reference/MemberFunctionDeclaration1_es6.js index ec37b3370b0..3eec7c188cd 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration1_es6.js +++ b/tests/baselines/reference/MemberFunctionDeclaration1_es6.js @@ -4,9 +4,6 @@ class C { } //// [MemberFunctionDeclaration1_es6.js] -var C = (function () { - function C() { - } - C.prototype.foo = function* () { }; - return C; -}()); +class C { + *foo() { } +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration1_es6.symbols b/tests/baselines/reference/MemberFunctionDeclaration1_es6.symbols new file mode 100644 index 00000000000..a1862ea9209 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration1_es6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts === +class C { +>C : Symbol(C, Decl(MemberFunctionDeclaration1_es6.ts, 0, 0)) + + *foo() { } +>foo : Symbol(C.foo, Decl(MemberFunctionDeclaration1_es6.ts, 0, 9)) +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration1_es6.types b/tests/baselines/reference/MemberFunctionDeclaration1_es6.types new file mode 100644 index 00000000000..89eec59bb1c --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration1_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts === +class C { +>C : C + + *foo() { } +>foo : () => IterableIterator +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration2_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration2_es6.errors.txt deleted file mode 100644 index 8277d6f1f67..00000000000 --- a/tests/baselines/reference/MemberFunctionDeclaration2_es6.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts(2,11): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - - -==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts (1 errors) ==== - class C { - public * foo() { } - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - } \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration2_es6.js b/tests/baselines/reference/MemberFunctionDeclaration2_es6.js index 54550ef72e7..9dd6bbfb9f9 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration2_es6.js +++ b/tests/baselines/reference/MemberFunctionDeclaration2_es6.js @@ -4,9 +4,6 @@ class C { } //// [MemberFunctionDeclaration2_es6.js] -var C = (function () { - function C() { - } - C.prototype.foo = function* () { }; - return C; -}()); +class C { + *foo() { } +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration2_es6.symbols b/tests/baselines/reference/MemberFunctionDeclaration2_es6.symbols new file mode 100644 index 00000000000..ac380db0268 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration2_es6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts === +class C { +>C : Symbol(C, Decl(MemberFunctionDeclaration2_es6.ts, 0, 0)) + + public * foo() { } +>foo : Symbol(C.foo, Decl(MemberFunctionDeclaration2_es6.ts, 0, 9)) +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration2_es6.types b/tests/baselines/reference/MemberFunctionDeclaration2_es6.types new file mode 100644 index 00000000000..bfc83ccfd27 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration2_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts === +class C { +>C : C + + public * foo() { } +>foo : () => IterableIterator +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt index 3fd821bafdf..fdfe7425320 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt +++ b/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt @@ -1,12 +1,9 @@ -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,4): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,6): error TS2304: Cannot find name 'foo'. -==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts (1 errors) ==== class C { *[foo]() { } - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. ~~~ !!! error TS2304: Cannot find name 'foo'. } \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration3_es6.js b/tests/baselines/reference/MemberFunctionDeclaration3_es6.js index 07d9a021fcd..0cfc1732c99 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration3_es6.js +++ b/tests/baselines/reference/MemberFunctionDeclaration3_es6.js @@ -4,9 +4,6 @@ class C { } //// [MemberFunctionDeclaration3_es6.js] -var C = (function () { - function C() { - } - C.prototype[foo] = function* () { }; - return C; -}()); +class C { + *[foo]() { } +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration4_es6.js b/tests/baselines/reference/MemberFunctionDeclaration4_es6.js index f791d4a1156..73b8f395a92 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration4_es6.js +++ b/tests/baselines/reference/MemberFunctionDeclaration4_es6.js @@ -4,9 +4,6 @@ class C { } //// [MemberFunctionDeclaration4_es6.js] -var C = (function () { - function C() { - } - C.prototype. = function* () { }; - return C; -}()); +class C { + *() { } +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration5_es6.js b/tests/baselines/reference/MemberFunctionDeclaration5_es6.js index 2303c5e0f62..bbba43eae05 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration5_es6.js +++ b/tests/baselines/reference/MemberFunctionDeclaration5_es6.js @@ -4,8 +4,5 @@ class C { } //// [MemberFunctionDeclaration5_es6.js] -var C = (function () { - function C() { - } - return C; -}()); +class C { +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration6_es6.js b/tests/baselines/reference/MemberFunctionDeclaration6_es6.js index b2a753d7ce0..370697051e6 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration6_es6.js +++ b/tests/baselines/reference/MemberFunctionDeclaration6_es6.js @@ -4,8 +4,5 @@ class C { } //// [MemberFunctionDeclaration6_es6.js] -var C = (function () { - function C() { - } - return C; -}()); +class C { +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration7_es6.errors.txt deleted file mode 100644 index cd4c49bdd6d..00000000000 --- a/tests/baselines/reference/MemberFunctionDeclaration7_es6.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts(2,4): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - - -==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts (1 errors) ==== - class C { - *foo() { } - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - } \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration7_es6.js b/tests/baselines/reference/MemberFunctionDeclaration7_es6.js index 8e19f0db333..78bf55457f7 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration7_es6.js +++ b/tests/baselines/reference/MemberFunctionDeclaration7_es6.js @@ -4,9 +4,6 @@ class C { } //// [MemberFunctionDeclaration7_es6.js] -var C = (function () { - function C() { - } - C.prototype.foo = function* () { }; - return C; -}()); +class C { + *foo() { } +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration7_es6.symbols b/tests/baselines/reference/MemberFunctionDeclaration7_es6.symbols new file mode 100644 index 00000000000..fa07b61e4a6 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration7_es6.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts === +class C { +>C : Symbol(C, Decl(MemberFunctionDeclaration7_es6.ts, 0, 0)) + + *foo() { } +>foo : Symbol(C.foo, Decl(MemberFunctionDeclaration7_es6.ts, 0, 9)) +>T : Symbol(T, Decl(MemberFunctionDeclaration7_es6.ts, 1, 8)) +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration7_es6.types b/tests/baselines/reference/MemberFunctionDeclaration7_es6.types new file mode 100644 index 00000000000..b5e65110c68 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration7_es6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts === +class C { +>C : C + + *foo() { } +>foo : () => IterableIterator +>T : T +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration8_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration8_es6.errors.txt index b21af664a69..94198b36c90 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration8_es6.errors.txt +++ b/tests/baselines/reference/MemberFunctionDeclaration8_es6.errors.txt @@ -18,7 +18,7 @@ tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration !!! error TS1109: Expression expected. ~~~ !!! error TS2304: Cannot find name 'bar'. - return bar; + return bar; ~~~ !!! error TS2304: Cannot find name 'bar'. } diff --git a/tests/baselines/reference/MemberFunctionDeclaration8_es6.js b/tests/baselines/reference/MemberFunctionDeclaration8_es6.js index 8000a2d5c42..853310e5a3e 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration8_es6.js +++ b/tests/baselines/reference/MemberFunctionDeclaration8_es6.js @@ -3,20 +3,17 @@ class C { foo() { // Make sure we don't think of *bar as the start of a generator method. if (a) # * bar; - return bar; + return bar; } } //// [MemberFunctionDeclaration8_es6.js] -var C = (function () { - function C() { - } - C.prototype.foo = function () { +class C { + foo() { // Make sure we don't think of *bar as the start of a generator method. if (a) ; * bar; return bar; - }; - return C; -}()); + } +} diff --git a/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.js b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.js index 03a504a888a..a68614c0ed4 100644 --- a/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.js +++ b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.js @@ -31,6 +31,7 @@ export module A { //// [part1.js] "use strict"; +exports.__esModule = true; var A; (function (A) { var Utils; @@ -44,6 +45,7 @@ var A; })(A = exports.A || (exports.A = {})); //// [part2.js] "use strict"; +exports.__esModule = true; var A; (function (A) { // collision with 'Origin' var in other part of merged module diff --git a/tests/baselines/reference/TypeGuardWithEnumUnion.types b/tests/baselines/reference/TypeGuardWithEnumUnion.types index d33411c4c7c..8ee4aaca363 100644 --- a/tests/baselines/reference/TypeGuardWithEnumUnion.types +++ b/tests/baselines/reference/TypeGuardWithEnumUnion.types @@ -12,7 +12,7 @@ function f1(x: Color | string) { if (typeof x === "number") { >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | Color >"number" : "number" @@ -41,7 +41,7 @@ function f2(x: Color | string | string[]) { if (typeof x === "object") { >typeof x === "object" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | Color | string[] >"object" : "object" @@ -54,7 +54,7 @@ function f2(x: Color | string | string[]) { } if (typeof x === "number") { >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | Color | string[] >"number" : "number" @@ -76,7 +76,7 @@ function f2(x: Color | string | string[]) { } if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | Color | string[] >"string" : "string" diff --git a/tests/baselines/reference/YieldExpression10_es6.errors.txt b/tests/baselines/reference/YieldExpression10_es6.errors.txt index 7bf534e4188..9e48fefc10a 100644 --- a/tests/baselines/reference/YieldExpression10_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression10_es6.errors.txt @@ -1,11 +1,8 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(1,11): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(2,11): error TS2304: Cannot find name 'foo'. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts (1 errors) ==== var v = { * foo() { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. yield(foo); ~~~ !!! error TS2304: Cannot find name 'foo'. diff --git a/tests/baselines/reference/YieldExpression10_es6.js b/tests/baselines/reference/YieldExpression10_es6.js index e1dd44b676b..f32dd1decf7 100644 --- a/tests/baselines/reference/YieldExpression10_es6.js +++ b/tests/baselines/reference/YieldExpression10_es6.js @@ -6,7 +6,7 @@ var v = { * foo() { //// [YieldExpression10_es6.js] -var v = { foo: function* () { +var v = { *foo() { yield (foo); } }; diff --git a/tests/baselines/reference/YieldExpression11_es6.errors.txt b/tests/baselines/reference/YieldExpression11_es6.errors.txt index f5d3458520f..223389e4e39 100644 --- a/tests/baselines/reference/YieldExpression11_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression11_es6.errors.txt @@ -1,12 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(2,3): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(3,11): error TS2663: Cannot find name 'foo'. Did you mean the instance member 'this.foo'? -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts (1 errors) ==== class C { *foo() { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. yield(foo); ~~~ !!! error TS2663: Cannot find name 'foo'. Did you mean the instance member 'this.foo'? diff --git a/tests/baselines/reference/YieldExpression11_es6.js b/tests/baselines/reference/YieldExpression11_es6.js index fb4f83c7197..46adf673634 100644 --- a/tests/baselines/reference/YieldExpression11_es6.js +++ b/tests/baselines/reference/YieldExpression11_es6.js @@ -6,11 +6,8 @@ class C { } //// [YieldExpression11_es6.js] -var C = (function () { - function C() { - } - C.prototype.foo = function* () { +class C { + *foo() { yield (foo); - }; - return C; -}()); + } +} diff --git a/tests/baselines/reference/YieldExpression12_es6.js b/tests/baselines/reference/YieldExpression12_es6.js index 7211d41cb86..d0ff7e9d6b8 100644 --- a/tests/baselines/reference/YieldExpression12_es6.js +++ b/tests/baselines/reference/YieldExpression12_es6.js @@ -6,9 +6,8 @@ class C { } //// [YieldExpression12_es6.js] -var C = (function () { - function C() { +class C { + constructor() { yield foo; } - return C; -}()); +} diff --git a/tests/baselines/reference/YieldExpression13_es6.errors.txt b/tests/baselines/reference/YieldExpression13_es6.errors.txt deleted file mode 100644 index 99088448886..00000000000 --- a/tests/baselines/reference/YieldExpression13_es6.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - - -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts (1 errors) ==== - function* foo() { yield } - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression13_es6.symbols b/tests/baselines/reference/YieldExpression13_es6.symbols new file mode 100644 index 00000000000..f2e1b100c9d --- /dev/null +++ b/tests/baselines/reference/YieldExpression13_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts === +function* foo() { yield } +>foo : Symbol(foo, Decl(YieldExpression13_es6.ts, 0, 0)) + diff --git a/tests/baselines/reference/YieldExpression13_es6.types b/tests/baselines/reference/YieldExpression13_es6.types new file mode 100644 index 00000000000..011ac1e09e8 --- /dev/null +++ b/tests/baselines/reference/YieldExpression13_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts === +function* foo() { yield } +>foo : () => IterableIterator +>yield : any + diff --git a/tests/baselines/reference/YieldExpression14_es6.js b/tests/baselines/reference/YieldExpression14_es6.js index e8c33c2085e..e25a29e606f 100644 --- a/tests/baselines/reference/YieldExpression14_es6.js +++ b/tests/baselines/reference/YieldExpression14_es6.js @@ -6,11 +6,8 @@ class C { } //// [YieldExpression14_es6.js] -var C = (function () { - function C() { - } - C.prototype.foo = function () { +class C { + foo() { yield foo; - }; - return C; -}()); + } +} diff --git a/tests/baselines/reference/YieldExpression15_es6.js b/tests/baselines/reference/YieldExpression15_es6.js index 1e4431d6168..d03699922f6 100644 --- a/tests/baselines/reference/YieldExpression15_es6.js +++ b/tests/baselines/reference/YieldExpression15_es6.js @@ -4,6 +4,6 @@ var v = () => { } //// [YieldExpression15_es6.js] -var v = function () { +var v = () => { yield foo; }; diff --git a/tests/baselines/reference/YieldExpression16_es6.errors.txt b/tests/baselines/reference/YieldExpression16_es6.errors.txt index 0645f5d818a..94e082f4c27 100644 --- a/tests/baselines/reference/YieldExpression16_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression16_es6.errors.txt @@ -1,11 +1,8 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): error TS1163: A 'yield' expression is only allowed in a generator body. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts (1 errors) ==== function* foo() { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. function bar() { yield foo; ~~~~~ diff --git a/tests/baselines/reference/YieldExpression17_es6.errors.txt b/tests/baselines/reference/YieldExpression17_es6.errors.txt index f987517371f..540b1a889f0 100644 --- a/tests/baselines/reference/YieldExpression17_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression17_es6.errors.txt @@ -1,13 +1,10 @@ -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. tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): error TS1163: A 'yield' expression is only allowed in a generator body. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts (3 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts (2 errors) ==== var v = { get foo() { yield foo; } } ~~~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~~ !!! 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/YieldExpression19_es6.errors.txt b/tests/baselines/reference/YieldExpression19_es6.errors.txt deleted file mode 100644 index f07cfc1db78..00000000000 --- a/tests/baselines/reference/YieldExpression19_es6.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. -tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(3,13): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - - -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts (2 errors) ==== - function*foo() { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - function bar() { - function* quux() { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - yield(foo); - } - } - } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression19_es6.symbols b/tests/baselines/reference/YieldExpression19_es6.symbols new file mode 100644 index 00000000000..609102001c4 --- /dev/null +++ b/tests/baselines/reference/YieldExpression19_es6.symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts === +function*foo() { +>foo : Symbol(foo, Decl(YieldExpression19_es6.ts, 0, 0)) + + function bar() { +>bar : Symbol(bar, Decl(YieldExpression19_es6.ts, 0, 16)) + + function* quux() { +>quux : Symbol(quux, Decl(YieldExpression19_es6.ts, 1, 18)) + + yield(foo); +>foo : Symbol(foo, Decl(YieldExpression19_es6.ts, 0, 0)) + } + } +} diff --git a/tests/baselines/reference/YieldExpression19_es6.types b/tests/baselines/reference/YieldExpression19_es6.types new file mode 100644 index 00000000000..f57b175d53c --- /dev/null +++ b/tests/baselines/reference/YieldExpression19_es6.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts === +function*foo() { +>foo : () => IterableIterator + + function bar() { +>bar : () => void + + function* quux() { +>quux : () => IterableIterator<() => IterableIterator> + + yield(foo); +>yield(foo) : any +>(foo) : () => IterableIterator +>foo : () => IterableIterator + } + } +} diff --git a/tests/baselines/reference/YieldExpression3_es6.errors.txt b/tests/baselines/reference/YieldExpression3_es6.errors.txt deleted file mode 100644 index 9f07c13184e..00000000000 --- a/tests/baselines/reference/YieldExpression3_es6.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - - -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts (1 errors) ==== - function* foo() { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - yield - yield - } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression3_es6.symbols b/tests/baselines/reference/YieldExpression3_es6.symbols new file mode 100644 index 00000000000..4ab5b42688f --- /dev/null +++ b/tests/baselines/reference/YieldExpression3_es6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts === +function* foo() { +>foo : Symbol(foo, Decl(YieldExpression3_es6.ts, 0, 0)) + + yield + yield +} diff --git a/tests/baselines/reference/YieldExpression3_es6.types b/tests/baselines/reference/YieldExpression3_es6.types new file mode 100644 index 00000000000..9e2f810d911 --- /dev/null +++ b/tests/baselines/reference/YieldExpression3_es6.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts === +function* foo() { +>foo : () => IterableIterator + + yield +>yield : any + + yield +>yield : any +} diff --git a/tests/baselines/reference/YieldExpression4_es6.errors.txt b/tests/baselines/reference/YieldExpression4_es6.errors.txt deleted file mode 100644 index 6c9a5796ee8..00000000000 --- a/tests/baselines/reference/YieldExpression4_es6.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - - -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts (1 errors) ==== - function* foo() { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - yield; - yield; - } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression4_es6.symbols b/tests/baselines/reference/YieldExpression4_es6.symbols new file mode 100644 index 00000000000..7954fb705e6 --- /dev/null +++ b/tests/baselines/reference/YieldExpression4_es6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts === +function* foo() { +>foo : Symbol(foo, Decl(YieldExpression4_es6.ts, 0, 0)) + + yield; + yield; +} diff --git a/tests/baselines/reference/YieldExpression4_es6.types b/tests/baselines/reference/YieldExpression4_es6.types new file mode 100644 index 00000000000..929bef38edd --- /dev/null +++ b/tests/baselines/reference/YieldExpression4_es6.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts === +function* foo() { +>foo : () => IterableIterator + + yield; +>yield : any + + yield; +>yield : any +} diff --git a/tests/baselines/reference/YieldExpression6_es6.errors.txt b/tests/baselines/reference/YieldExpression6_es6.errors.txt index f2fc90b81b4..b8c0967864c 100644 --- a/tests/baselines/reference/YieldExpression6_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression6_es6.errors.txt @@ -1,11 +1,8 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(2,9): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts (1 errors) ==== function* foo() { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. yield*foo ~~~ !!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. diff --git a/tests/baselines/reference/YieldExpression7_es6.errors.txt b/tests/baselines/reference/YieldExpression7_es6.errors.txt deleted file mode 100644 index f929dff0a2a..00000000000 --- a/tests/baselines/reference/YieldExpression7_es6.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - - -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts (1 errors) ==== - function* foo() { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - yield foo - } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression7_es6.symbols b/tests/baselines/reference/YieldExpression7_es6.symbols new file mode 100644 index 00000000000..53737c94be9 --- /dev/null +++ b/tests/baselines/reference/YieldExpression7_es6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts === +function* foo() { +>foo : Symbol(foo, Decl(YieldExpression7_es6.ts, 0, 0)) + + yield foo +>foo : Symbol(foo, Decl(YieldExpression7_es6.ts, 0, 0)) +} diff --git a/tests/baselines/reference/YieldExpression7_es6.types b/tests/baselines/reference/YieldExpression7_es6.types new file mode 100644 index 00000000000..44dcc196c3b --- /dev/null +++ b/tests/baselines/reference/YieldExpression7_es6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts === +function* foo() { +>foo : () => IterableIterator + + yield foo +>yield foo : any +>foo : () => IterableIterator +} diff --git a/tests/baselines/reference/YieldExpression8_es6.errors.txt b/tests/baselines/reference/YieldExpression8_es6.errors.txt index aef1fbc122d..f4dd30b1a19 100644 --- a/tests/baselines/reference/YieldExpression8_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression8_es6.errors.txt @@ -1,13 +1,10 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(1,1): error TS2304: Cannot find name 'yield'. -tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(2,9): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts (1 errors) ==== yield(foo); ~~~~~ !!! error TS2304: Cannot find name 'yield'. function* foo() { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. yield(foo); } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression9_es6.errors.txt b/tests/baselines/reference/YieldExpression9_es6.errors.txt index 2ad925a90a0..1241e615f79 100644 --- a/tests/baselines/reference/YieldExpression9_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression9_es6.errors.txt @@ -1,11 +1,8 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(1,17): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(2,9): error TS2304: Cannot find name 'foo'. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts (1 errors) ==== var v = function*() { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. yield(foo); ~~~ !!! error TS2304: Cannot find name 'foo'. diff --git a/tests/baselines/reference/YieldStarExpression4_es6.errors.txt b/tests/baselines/reference/YieldStarExpression4_es6.errors.txt deleted file mode 100644 index c58844a9288..00000000000 --- a/tests/baselines/reference/YieldStarExpression4_es6.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. -tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts(2,13): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. - - -==== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts (2 errors) ==== - function *g() { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - yield * []; - ~~ -!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. - } \ No newline at end of file diff --git a/tests/baselines/reference/YieldStarExpression4_es6.symbols b/tests/baselines/reference/YieldStarExpression4_es6.symbols new file mode 100644 index 00000000000..c23e2ac8895 --- /dev/null +++ b/tests/baselines/reference/YieldStarExpression4_es6.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts === +function *g() { +>g : Symbol(g, Decl(YieldStarExpression4_es6.ts, 0, 0)) + + yield * []; +} diff --git a/tests/baselines/reference/YieldStarExpression4_es6.types b/tests/baselines/reference/YieldStarExpression4_es6.types new file mode 100644 index 00000000000..1d72e6dc506 --- /dev/null +++ b/tests/baselines/reference/YieldStarExpression4_es6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts === +function *g() { +>g : () => IterableIterator + + yield * []; +>yield * [] : any +>[] : undefined[] +} diff --git a/tests/baselines/reference/abstractClassInLocalScope.js b/tests/baselines/reference/abstractClassInLocalScope.js index db5144be399..d841911b0bf 100644 --- a/tests/baselines/reference/abstractClassInLocalScope.js +++ b/tests/baselines/reference/abstractClassInLocalScope.js @@ -8,11 +8,16 @@ //// [abstractClassInLocalScope.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); (function () { var A = (function () { function A() { @@ -22,7 +27,7 @@ var __extends = (this && this.__extends) || function (d, b) { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.js b/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.js index 1b3e11cfa32..a513ce3d88e 100644 --- a/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.js +++ b/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.js @@ -8,11 +8,16 @@ //// [abstractClassInLocalScopeIsAbstract.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); (function () { var A = (function () { function A() { @@ -22,7 +27,7 @@ var __extends = (this && this.__extends) || function (d, b) { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/abstractProperty.js b/tests/baselines/reference/abstractProperty.js index fb7deaa09dd..f4b2d432f24 100644 --- a/tests/baselines/reference/abstractProperty.js +++ b/tests/baselines/reference/abstractProperty.js @@ -22,11 +22,16 @@ class C extends B { } //// [abstractProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B() { } @@ -35,7 +40,7 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.raw = "edge"; _this.ro = "readonly please"; return _this; diff --git a/tests/baselines/reference/abstractPropertyNegative.js b/tests/baselines/reference/abstractPropertyNegative.js index bebf9026a0e..5ff6708b89a 100644 --- a/tests/baselines/reference/abstractPropertyNegative.js +++ b/tests/baselines/reference/abstractPropertyNegative.js @@ -44,11 +44,16 @@ abstract class AbstractAccessorMismatch { //// [abstractPropertyNegative.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B() { } @@ -57,7 +62,7 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.ro = "readonly please"; return _this; } @@ -78,7 +83,7 @@ var WrongTypeProperty = (function () { var WrongTypePropertyImpl = (function (_super) { __extends(WrongTypePropertyImpl, _super); function WrongTypePropertyImpl() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.num = "nope, wrong"; return _this; } @@ -92,7 +97,7 @@ var WrongTypeAccessor = (function () { var WrongTypeAccessorImpl = (function (_super) { __extends(WrongTypeAccessorImpl, _super); function WrongTypeAccessorImpl() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(WrongTypeAccessorImpl.prototype, "num", { get: function () { return "nope, wrong"; }, @@ -104,7 +109,7 @@ var WrongTypeAccessorImpl = (function (_super) { var WrongTypeAccessorImpl2 = (function (_super) { __extends(WrongTypeAccessorImpl2, _super); function WrongTypeAccessorImpl2() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.num = "nope, wrong"; return _this; } diff --git a/tests/baselines/reference/accessOverriddenBaseClassMember1.js b/tests/baselines/reference/accessOverriddenBaseClassMember1.js index 02d092dfd39..1fdf137a7e7 100644 --- a/tests/baselines/reference/accessOverriddenBaseClassMember1.js +++ b/tests/baselines/reference/accessOverriddenBaseClassMember1.js @@ -16,11 +16,16 @@ class ColoredPoint extends Point { //// [accessOverriddenBaseClassMember1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Point = (function () { function Point(x, y) { this.x = x; diff --git a/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt b/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt index 5393eee87d4..278de87e729 100644 --- a/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt +++ b/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,55): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,48): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,54): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,47): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(6,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(8,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(9,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -20,13 +20,13 @@ tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(12,16): error TS1 public get AnnotatedSetter_SetterFirst() { return ""; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~ + ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'number'. public get AnnotatedSetter_SetterLast() { return ""; } ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~ + ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'number'. public set AnnotatedSetter_SetterLast(a: number) { } ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/accessors_spec_section-4.5_inference.js b/tests/baselines/reference/accessors_spec_section-4.5_inference.js index dbaeec1f688..8d9ef160e2e 100644 --- a/tests/baselines/reference/accessors_spec_section-4.5_inference.js +++ b/tests/baselines/reference/accessors_spec_section-4.5_inference.js @@ -25,11 +25,16 @@ class LanguageSpec_section_4_5_inference { } //// [accessors_spec_section-4.5_inference.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -38,7 +43,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.errors.txt b/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.errors.txt index d18a9a13d8c..5f0d78c59d5 100644 --- a/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.errors.txt +++ b/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(11,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(12,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(13,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(14,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(15,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(16,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(19,10): error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'true' and 'true'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(21,10): error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(22,11): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(23,11): error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(11,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(12,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(13,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(14,14): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(15,14): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(16,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(19,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(20,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(21,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(22,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(23,11): error TS2531: Object is possibly 'null'. ==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts (11 errors) ==== @@ -23,37 +23,37 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe // null + boolean/Object var r1 = null + a; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r2 = null + b; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r3 = null + c; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r4 = a + null; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r5 = b + null; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r6 = null + c; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. // other cases var r7 = null + d; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r8 = null + true; - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'true' and 'true'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r9 = null + { a: '' }; - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r10 = null + foo(); - ~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r11 = null + (() => { }); - ~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'. \ No newline at end of file + ~~~~ +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.errors.txt b/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.errors.txt new file mode 100644 index 00000000000..db01a42c8bd --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.errors.txt @@ -0,0 +1,63 @@ +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(15,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(16,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(17,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(18,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(19,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(20,14): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(21,14): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(22,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(23,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(24,20): error TS2531: Object is possibly 'null'. + + +==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts (10 errors) ==== + // If one operand is the null or undefined value, it is treated as having the type of the other operand. + + enum E { a, b, c } + + var a: any; + var b: number; + var c: E; + var d: string; + + // null + any + var r1: any = null + a; + var r2: any = a + null; + + // null + number/enum + var r3 = null + b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4 = null + 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r5 = null + c; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r6 = null + E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r7 = null + E['a']; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r8 = b + null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r9 = 1 + null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r10 = c + null + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r11 = E.a + null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r12 = E['a'] + null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // null + string + var r13 = null + d; + var r14 = null + ''; + var r15 = d + null; + var r16 = '' + null; \ No newline at end of file diff --git a/tests/baselines/reference/additionOperatorWithOnlyNullValueOrUndefinedValue.errors.txt b/tests/baselines/reference/additionOperatorWithOnlyNullValueOrUndefinedValue.errors.txt index 9e7e4c01ad2..aef66891be0 100644 --- a/tests/baselines/reference/additionOperatorWithOnlyNullValueOrUndefinedValue.errors.txt +++ b/tests/baselines/reference/additionOperatorWithOnlyNullValueOrUndefinedValue.errors.txt @@ -1,20 +1,32 @@ -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(2,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(3,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(4,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(5,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(2,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(2,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(3,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(3,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(4,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(4,22): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(5,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(5,22): error TS2532: Object is possibly 'undefined'. -==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts (4 errors) ==== +==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts (8 errors) ==== // bug 819721 var r1 = null + null; - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r2 = null + undefined; - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r3 = undefined + null; - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r4 = undefined + undefined; - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. \ No newline at end of file + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/additionOperatorWithTypeParameter.errors.txt b/tests/baselines/reference/additionOperatorWithTypeParameter.errors.txt index ff7120c145d..478c4fdee3f 100644 --- a/tests/baselines/reference/additionOperatorWithTypeParameter.errors.txt +++ b/tests/baselines/reference/additionOperatorWithTypeParameter.errors.txt @@ -8,8 +8,8 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(27,15): error TS2365: Operator '+' cannot be applied to types 'Object' and 'T'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(28,15): error TS2365: Operator '+' cannot be applied to types 'E' and 'T'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(29,15): error TS2365: Operator '+' cannot be applied to types 'void' and 'T'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(32,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'T'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(33,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'T'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(32,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(33,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(34,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'T'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(35,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'U'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(36,15): error TS2365: Operator '+' cannot be applied to types 'T' and '() => void'. @@ -69,11 +69,11 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe // other cases var r15 = t + null; - ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'T'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r16 = t + undefined; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'T'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r17 = t + t; ~~~~~ !!! error TS2365: Operator '+' cannot be applied to types 'T' and 'T'. diff --git a/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.errors.txt b/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.errors.txt index d61f101a544..06e8c67b105 100644 --- a/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.errors.txt +++ b/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(11,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(12,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(13,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(14,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(15,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(16,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(19,10): error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'true' and 'true'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(21,10): error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(22,11): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(23,11): error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(11,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(12,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(13,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(14,14): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(15,14): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(16,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(19,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(20,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(21,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(22,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(23,11): error TS2532: Object is possibly 'undefined'. ==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts (11 errors) ==== @@ -23,37 +23,37 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe // undefined + boolean/Object var r1 = undefined + a; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r2 = undefined + b; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r3 = undefined + c; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r4 = a + undefined; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r5 = b + undefined; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r6 = undefined + c; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // other cases var r7 = undefined + d; - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r8 = undefined + true; - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'true' and 'true'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r9 = undefined + { a: '' }; - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r10 = undefined + foo(); - ~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r11 = undefined + (() => { }); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'. \ No newline at end of file + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.errors.txt b/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.errors.txt new file mode 100644 index 00000000000..04c0e2f3266 --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.errors.txt @@ -0,0 +1,63 @@ +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(15,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(16,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(17,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(18,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(19,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(20,14): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(21,14): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(22,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(23,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(24,20): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts (10 errors) ==== + // If one operand is the null or undefined value, it is treated as having the type of the other operand. + + enum E { a, b, c } + + var a: any; + var b: number; + var c: E; + var d: string; + + // undefined + any + var r1: any = undefined + a; + var r2: any = a + undefined; + + // undefined + number/enum + var r3 = undefined + b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r4 = undefined + 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r5 = undefined + c; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r6 = undefined + E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r7 = undefined + E['a']; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r8 = b + undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r9 = 1 + undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r10 = c + undefined + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r11 = E.a + undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var r12 = E['a'] + undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // undefined + string + var r13 = undefined + d; + var r14 = undefined + ''; + var r15 = d + undefined; + var r16 = '' + undefined; \ No newline at end of file diff --git a/tests/baselines/reference/aliasAssignments.js b/tests/baselines/reference/aliasAssignments.js index 7aef6de22e6..c21fe575e76 100644 --- a/tests/baselines/reference/aliasAssignments.js +++ b/tests/baselines/reference/aliasAssignments.js @@ -15,6 +15,7 @@ y = moduleA; // should be error //// [aliasAssignments_moduleA.js] "use strict"; +exports.__esModule = true; var someClass = (function () { function someClass() { } @@ -23,6 +24,7 @@ var someClass = (function () { exports.someClass = someClass; //// [aliasAssignments_1.js] "use strict"; +exports.__esModule = true; var moduleA = require("./aliasAssignments_moduleA"); var x = moduleA; x = 1; // Should be error diff --git a/tests/baselines/reference/aliasOnMergedModuleInterface.js b/tests/baselines/reference/aliasOnMergedModuleInterface.js index ee9562e7b77..d3d312e53bb 100644 --- a/tests/baselines/reference/aliasOnMergedModuleInterface.js +++ b/tests/baselines/reference/aliasOnMergedModuleInterface.js @@ -24,6 +24,7 @@ var x: foo.A = foo.bar("hello"); // foo.A should be ok but foo.bar should be err //// [aliasOnMergedModuleInterface_0.js] //// [aliasOnMergedModuleInterface_1.js] "use strict"; +exports.__esModule = true; var z; z.bar("hello"); // This should be ok var x = foo.bar("hello"); // foo.A should be ok but foo.bar should be error diff --git a/tests/baselines/reference/aliasUsageInAccessorsOfClass.js b/tests/baselines/reference/aliasUsageInAccessorsOfClass.js index 8b60ed8e76d..883cbb84ee3 100644 --- a/tests/baselines/reference/aliasUsageInAccessorsOfClass.js +++ b/tests/baselines/reference/aliasUsageInAccessorsOfClass.js @@ -29,6 +29,7 @@ class C2 { //// [aliasUsage1_backbone.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var Model = (function () { function Model() { } @@ -37,22 +38,29 @@ var Model = (function () { exports.Model = Model; //// [aliasUsage1_moduleA.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); var Backbone = require("./aliasUsage1_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); exports.VisualizationModel = VisualizationModel; //// [aliasUsage1_main.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var moduleA = require("./aliasUsage1_moduleA"); var C2 = (function () { function C2() { diff --git a/tests/baselines/reference/aliasUsageInArray.js b/tests/baselines/reference/aliasUsageInArray.js index bf573aa9abb..1ccbc958aec 100644 --- a/tests/baselines/reference/aliasUsageInArray.js +++ b/tests/baselines/reference/aliasUsageInArray.js @@ -23,6 +23,7 @@ var xs2: typeof moduleA[] = [moduleA]; //// [aliasUsageInArray_backbone.js] "use strict"; +exports.__esModule = true; var Model = (function () { function Model() { } @@ -31,22 +32,29 @@ var Model = (function () { exports.Model = Model; //// [aliasUsageInArray_moduleA.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var Backbone = require("./aliasUsageInArray_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInArray_main.js] "use strict"; +exports.__esModule = true; var moduleA = require("./aliasUsageInArray_moduleA"); var xs = [moduleA]; var xs2 = [moduleA]; diff --git a/tests/baselines/reference/aliasUsageInFunctionExpression.js b/tests/baselines/reference/aliasUsageInFunctionExpression.js index 49bdd493aac..de661ae803e 100644 --- a/tests/baselines/reference/aliasUsageInFunctionExpression.js +++ b/tests/baselines/reference/aliasUsageInFunctionExpression.js @@ -22,6 +22,7 @@ f = (x) => moduleA; //// [aliasUsageInFunctionExpression_backbone.js] "use strict"; +exports.__esModule = true; var Model = (function () { function Model() { } @@ -30,22 +31,29 @@ var Model = (function () { exports.Model = Model; //// [aliasUsageInFunctionExpression_moduleA.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var Backbone = require("./aliasUsageInFunctionExpression_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInFunctionExpression_main.js] "use strict"; +exports.__esModule = true; var moduleA = require("./aliasUsageInFunctionExpression_moduleA"); var f = function (x) { return x; }; f = function (x) { return moduleA; }; diff --git a/tests/baselines/reference/aliasUsageInGenericFunction.js b/tests/baselines/reference/aliasUsageInGenericFunction.js index dc3a8a88bab..2ca49ea8dfc 100644 --- a/tests/baselines/reference/aliasUsageInGenericFunction.js +++ b/tests/baselines/reference/aliasUsageInGenericFunction.js @@ -26,6 +26,7 @@ var r2 = foo({ a: null }); //// [aliasUsageInGenericFunction_backbone.js] "use strict"; +exports.__esModule = true; var Model = (function () { function Model() { } @@ -34,22 +35,29 @@ var Model = (function () { exports.Model = Model; //// [aliasUsageInGenericFunction_moduleA.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var Backbone = require("./aliasUsageInGenericFunction_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInGenericFunction_main.js] "use strict"; +exports.__esModule = true; var moduleA = require("./aliasUsageInGenericFunction_moduleA"); function foo(x) { return x; diff --git a/tests/baselines/reference/aliasUsageInIndexerOfClass.js b/tests/baselines/reference/aliasUsageInIndexerOfClass.js index cb7ad3027ca..81084b8b92f 100644 --- a/tests/baselines/reference/aliasUsageInIndexerOfClass.js +++ b/tests/baselines/reference/aliasUsageInIndexerOfClass.js @@ -28,6 +28,7 @@ class N2 { //// [aliasUsageInIndexerOfClass_backbone.js] "use strict"; +exports.__esModule = true; var Model = (function () { function Model() { } @@ -36,22 +37,29 @@ var Model = (function () { exports.Model = Model; //// [aliasUsageInIndexerOfClass_moduleA.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var Backbone = require("./aliasUsageInIndexerOfClass_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInIndexerOfClass_main.js] "use strict"; +exports.__esModule = true; var moduleA = require("./aliasUsageInIndexerOfClass_moduleA"); var N = (function () { function N() { diff --git a/tests/baselines/reference/aliasUsageInObjectLiteral.js b/tests/baselines/reference/aliasUsageInObjectLiteral.js index 81e3e621e85..6f4adfae58c 100644 --- a/tests/baselines/reference/aliasUsageInObjectLiteral.js +++ b/tests/baselines/reference/aliasUsageInObjectLiteral.js @@ -23,6 +23,7 @@ var c: { y: { z: IHasVisualizationModel } } = { y: { z: moduleA } }; //// [aliasUsageInObjectLiteral_backbone.js] "use strict"; +exports.__esModule = true; var Model = (function () { function Model() { } @@ -31,22 +32,29 @@ var Model = (function () { exports.Model = Model; //// [aliasUsageInObjectLiteral_moduleA.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var Backbone = require("./aliasUsageInObjectLiteral_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInObjectLiteral_main.js] "use strict"; +exports.__esModule = true; var moduleA = require("./aliasUsageInObjectLiteral_moduleA"); var a = { x: moduleA }; var b = { x: moduleA }; diff --git a/tests/baselines/reference/aliasUsageInOrExpression.js b/tests/baselines/reference/aliasUsageInOrExpression.js index 4faa41dd034..178ccaaee23 100644 --- a/tests/baselines/reference/aliasUsageInOrExpression.js +++ b/tests/baselines/reference/aliasUsageInOrExpression.js @@ -26,6 +26,7 @@ var f: { x: IHasVisualizationModel } = <{ x: IHasVisualizationModel }>null ? { x //// [aliasUsageInOrExpression_backbone.js] "use strict"; +exports.__esModule = true; var Model = (function () { function Model() { } @@ -34,22 +35,29 @@ var Model = (function () { exports.Model = Model; //// [aliasUsageInOrExpression_moduleA.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var Backbone = require("./aliasUsageInOrExpression_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInOrExpression_main.js] "use strict"; +exports.__esModule = true; var moduleA = require("./aliasUsageInOrExpression_moduleA"); var i; var d1 = i || moduleA; diff --git a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js index 2cf4aefab6c..5ac28396fba 100644 --- a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js +++ b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js @@ -26,6 +26,7 @@ class D extends C { //// [aliasUsageInTypeArgumentOfExtendsClause_backbone.js] "use strict"; +exports.__esModule = true; var Model = (function () { function Model() { } @@ -34,27 +35,39 @@ var Model = (function () { exports.Model = Model; //// [aliasUsageInTypeArgumentOfExtendsClause_moduleA.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInTypeArgumentOfExtendsClause_main.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var moduleA = require("./aliasUsageInTypeArgumentOfExtendsClause_moduleA"); var C = (function () { function C() { @@ -64,7 +77,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = moduleA; return _this; } diff --git a/tests/baselines/reference/aliasUsageInVarAssignment.js b/tests/baselines/reference/aliasUsageInVarAssignment.js index 80bb2dca20e..a85d61fd34c 100644 --- a/tests/baselines/reference/aliasUsageInVarAssignment.js +++ b/tests/baselines/reference/aliasUsageInVarAssignment.js @@ -22,6 +22,7 @@ var m: typeof moduleA = i; //// [aliasUsageInVarAssignment_backbone.js] "use strict"; +exports.__esModule = true; var Model = (function () { function Model() { } @@ -30,21 +31,28 @@ var Model = (function () { exports.Model = Model; //// [aliasUsageInVarAssignment_moduleA.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var Backbone = require("./aliasUsageInVarAssignment_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInVarAssignment_main.js] "use strict"; +exports.__esModule = true; var i; var m = i; diff --git a/tests/baselines/reference/aliasUsedAsNameValue.js b/tests/baselines/reference/aliasUsedAsNameValue.js index 9495f8890b6..168567eb80f 100644 --- a/tests/baselines/reference/aliasUsedAsNameValue.js +++ b/tests/baselines/reference/aliasUsedAsNameValue.js @@ -20,12 +20,15 @@ export var a = function () { //// [aliasUsedAsNameValue_0.js] "use strict"; +exports.__esModule = true; //// [aliasUsedAsNameValue_1.js] "use strict"; +exports.__esModule = true; function b(a) { return null; } exports.b = b; //// [aliasUsedAsNameValue_2.js] "use strict"; +exports.__esModule = true; /// /// var mod = require("./aliasUsedAsNameValue_0"); diff --git a/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.js b/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.js index 8304be3a036..58565bbb916 100644 --- a/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.js +++ b/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.js @@ -12,6 +12,8 @@ var d = b.q3; //// [aliasWithInterfaceExportAssignmentUsedInVarInitializer_0.js] "use strict"; +exports.__esModule = true; //// [aliasWithInterfaceExportAssignmentUsedInVarInitializer_1.js] "use strict"; +exports.__esModule = true; var d = b.q3; diff --git a/tests/baselines/reference/allowSyntheticDefaultImports1.js b/tests/baselines/reference/allowSyntheticDefaultImports1.js index 3789410a54b..a659eb60151 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports1.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports1.js @@ -12,6 +12,7 @@ export class Foo { //// [b.js] "use strict"; +exports.__esModule = true; var Foo = (function () { function Foo() { } @@ -20,5 +21,6 @@ var Foo = (function () { exports.Foo = Foo; //// [a.js] "use strict"; +exports.__esModule = true; var b_1 = require("./b"); exports.x = new b_1["default"].Foo(); diff --git a/tests/baselines/reference/allowSyntheticDefaultImports10.js b/tests/baselines/reference/allowSyntheticDefaultImports10.js index 396cd75b574..ad3ed5715c0 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports10.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports10.js @@ -12,6 +12,7 @@ Foo.default.default.foo(); //// [a.js] "use strict"; +exports.__esModule = true; var Foo = require("./b"); Foo["default"].bar(); Foo["default"]["default"].foo(); diff --git a/tests/baselines/reference/allowSyntheticDefaultImports4.js b/tests/baselines/reference/allowSyntheticDefaultImports4.js index 747f59dc904..762c032b812 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports4.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports4.js @@ -13,5 +13,6 @@ export var x = new Foo(); //// [a.js] "use strict"; +exports.__esModule = true; var b_1 = require("./b"); exports.x = new b_1["default"](); diff --git a/tests/baselines/reference/allowSyntheticDefaultImports9.js b/tests/baselines/reference/allowSyntheticDefaultImports9.js index 15810ccaaf7..2d8ab463d83 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports9.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports9.js @@ -12,6 +12,7 @@ Foo.foo(); //// [a.js] "use strict"; +exports.__esModule = true; var b_1 = require("./b"); b_1["default"].bar(); b_1["default"].foo(); diff --git a/tests/baselines/reference/alwaysStrictModule4.js b/tests/baselines/reference/alwaysStrictModule4.js index 1444f351bbd..dcaafdfeee6 100644 --- a/tests/baselines/reference/alwaysStrictModule4.js +++ b/tests/baselines/reference/alwaysStrictModule4.js @@ -5,5 +5,6 @@ export const a = 1 //// [alwaysStrictModule4.js] "use strict"; +exports.__esModule = true; // Module commonjs exports.a = 1; diff --git a/tests/baselines/reference/alwaysStrictModule6.js b/tests/baselines/reference/alwaysStrictModule6.js index 9a603926169..cd97b55b67b 100644 --- a/tests/baselines/reference/alwaysStrictModule6.js +++ b/tests/baselines/reference/alwaysStrictModule6.js @@ -5,5 +5,6 @@ export const a = 1; //// [alwaysStrictModule6.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); // Targeting ES5 exports.a = 1; diff --git a/tests/baselines/reference/ambientDeclarationsExternal.js b/tests/baselines/reference/ambientDeclarationsExternal.js index b92993128ab..dfff030b78f 100644 --- a/tests/baselines/reference/ambientDeclarationsExternal.js +++ b/tests/baselines/reference/ambientDeclarationsExternal.js @@ -28,6 +28,7 @@ var n: number; // Ambient external import declaration referencing ambient external module using top level module name //// [consumer.js] "use strict"; +exports.__esModule = true; // Ambient external module members are always exported with or without export keyword when module lacks export assignment var imp3 = require("equ2"); var n = imp3.x; diff --git a/tests/baselines/reference/ambientDeclarationsPatterns.js b/tests/baselines/reference/ambientDeclarationsPatterns.js index 143f26550e9..84088d11d4e 100644 --- a/tests/baselines/reference/ambientDeclarationsPatterns.js +++ b/tests/baselines/reference/ambientDeclarationsPatterns.js @@ -34,6 +34,7 @@ foo(fileText); //// [user.js] "use strict"; +exports.__esModule = true; /// var foobarbaz_1 = require("foobarbaz"); foobarbaz_1.foo(foobarbaz_1.baz); diff --git a/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.js b/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.js index bb0d3a907ae..401af4b5214 100644 --- a/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.js +++ b/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.js @@ -4,4 +4,5 @@ export declare module "M" { } //// [ambientExternalModuleInsideNonAmbientExternalModule.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/ambientExternalModuleMerging.js b/tests/baselines/reference/ambientExternalModuleMerging.js index 217d7cb90c1..6c2de62c90a 100644 --- a/tests/baselines/reference/ambientExternalModuleMerging.js +++ b/tests/baselines/reference/ambientExternalModuleMerging.js @@ -19,6 +19,7 @@ declare module "M" { //// [ambientExternalModuleMerging_use.js] define(["require", "exports", "M"], function (require, exports, M) { "use strict"; + exports.__esModule = true; // Should be strings var x = M.x; var y = M.y; diff --git a/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.js b/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.js index c91adaff864..9efd9e4ada9 100644 --- a/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.js +++ b/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.js @@ -22,5 +22,6 @@ var c = new A(); //// [ambientExternalModuleWithInternalImportDeclaration_1.js] define(["require", "exports", "M"], function (require, exports, A) { "use strict"; + exports.__esModule = true; var c = new A(); }); diff --git a/tests/baselines/reference/ambientExternalModuleWithoutInternalImportDeclaration.js b/tests/baselines/reference/ambientExternalModuleWithoutInternalImportDeclaration.js index 4c70a338bc3..98d3d46912a 100644 --- a/tests/baselines/reference/ambientExternalModuleWithoutInternalImportDeclaration.js +++ b/tests/baselines/reference/ambientExternalModuleWithoutInternalImportDeclaration.js @@ -21,5 +21,6 @@ var c = new A(); //// [ambientExternalModuleWithoutInternalImportDeclaration_1.js] define(["require", "exports", "M"], function (require, exports, A) { "use strict"; + exports.__esModule = true; var c = new A(); }); diff --git a/tests/baselines/reference/ambientInsideNonAmbientExternalModule.js b/tests/baselines/reference/ambientInsideNonAmbientExternalModule.js index 0e2d08ae07b..689cd6a1242 100644 --- a/tests/baselines/reference/ambientInsideNonAmbientExternalModule.js +++ b/tests/baselines/reference/ambientInsideNonAmbientExternalModule.js @@ -8,4 +8,5 @@ export declare module M { } //// [ambientInsideNonAmbientExternalModule.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/ambientNameRestrictions.js b/tests/baselines/reference/ambientNameRestrictions.js index cd4fbf29371..b35f1241b2d 100644 --- a/tests/baselines/reference/ambientNameRestrictions.js +++ b/tests/baselines/reference/ambientNameRestrictions.js @@ -6,3 +6,4 @@ export declare namespace Foo { //// [ambientNameRestrictions.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/ambientShorthand.js b/tests/baselines/reference/ambientShorthand.js index 109264fc91b..a7513e7eb58 100644 --- a/tests/baselines/reference/ambientShorthand.js +++ b/tests/baselines/reference/ambientShorthand.js @@ -15,6 +15,7 @@ foo(bar, baz, boom); //// [user.js] "use strict"; +exports.__esModule = true; /// var jquery_1 = require("jquery"); var baz = require("fs"); diff --git a/tests/baselines/reference/ambientShorthand_duplicate.js b/tests/baselines/reference/ambientShorthand_duplicate.js index d99eb3d27dc..08d03c83ed0 100644 --- a/tests/baselines/reference/ambientShorthand_duplicate.js +++ b/tests/baselines/reference/ambientShorthand_duplicate.js @@ -14,3 +14,4 @@ import foo from "foo"; //// [user.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/ambientShorthand_merging.js b/tests/baselines/reference/ambientShorthand_merging.js index f0aaefc6366..15714a48997 100644 --- a/tests/baselines/reference/ambientShorthand_merging.js +++ b/tests/baselines/reference/ambientShorthand_merging.js @@ -16,3 +16,4 @@ import foo, {bar} from "foo"; //// [user.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/ambientShorthand_reExport.js b/tests/baselines/reference/ambientShorthand_reExport.js index bdfc0ee0821..6842d0f7554 100644 --- a/tests/baselines/reference/ambientShorthand_reExport.js +++ b/tests/baselines/reference/ambientShorthand_reExport.js @@ -18,6 +18,7 @@ x($); //// [reExportX.js] "use strict"; +exports.__esModule = true; var jquery_1 = require("jquery"); exports.x = jquery_1.x; //// [reExportAll.js] @@ -25,9 +26,11 @@ exports.x = jquery_1.x; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } +exports.__esModule = true; __export(require("jquery")); //// [reExportUser.js] "use strict"; +exports.__esModule = true; var reExportX_1 = require("./reExportX"); var $ = require("./reExportAll"); // '$' is not callable, it is an object. diff --git a/tests/baselines/reference/ambientWithStatements.errors.txt b/tests/baselines/reference/ambientWithStatements.errors.txt index 6fb6aafd864..3e134970a1f 100644 --- a/tests/baselines/reference/ambientWithStatements.errors.txt +++ b/tests/baselines/reference/ambientWithStatements.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/ambientWithStatements.ts(2,5): error TS1036: Statements are not allowed in ambient contexts. tests/cases/compiler/ambientWithStatements.ts(3,5): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. -tests/cases/compiler/ambientWithStatements.ts(7,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +tests/cases/compiler/ambientWithStatements.ts(7,15): error TS2531: Object is possibly 'null'. tests/cases/compiler/ambientWithStatements.ts(11,5): error TS1108: A 'return' statement can only be used within a function body. tests/cases/compiler/ambientWithStatements.ts(25,5): error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'. @@ -18,7 +18,7 @@ tests/cases/compiler/ambientWithStatements.ts(25,5): error TS2410: The 'with' st var x; for (x in null) { } ~~~~ -!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. +!!! error TS2531: Object is possibly 'null'. if (true) { } else { } 1; L: var y; diff --git a/tests/baselines/reference/ambiguousOverloadResolution.js b/tests/baselines/reference/ambiguousOverloadResolution.js index 01002792921..12d0f01cf4a 100644 --- a/tests/baselines/reference/ambiguousOverloadResolution.js +++ b/tests/baselines/reference/ambiguousOverloadResolution.js @@ -9,11 +9,16 @@ var x: B; var t: number = f(x, x); // Not an error //// [ambiguousOverloadResolution.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -22,7 +27,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/amdDependencyComment1.js b/tests/baselines/reference/amdDependencyComment1.js index 2c0bdd551fa..6be26909f3a 100644 --- a/tests/baselines/reference/amdDependencyComment1.js +++ b/tests/baselines/reference/amdDependencyComment1.js @@ -7,5 +7,6 @@ m1.f(); //// [amdDependencyComment1.js] /// "use strict"; +exports.__esModule = true; var m1 = require("m2"); m1.f(); diff --git a/tests/baselines/reference/amdDependencyComment2.js b/tests/baselines/reference/amdDependencyComment2.js index 6867b03f606..222093cf159 100644 --- a/tests/baselines/reference/amdDependencyComment2.js +++ b/tests/baselines/reference/amdDependencyComment2.js @@ -8,5 +8,6 @@ m1.f(); /// define(["require", "exports", "m2", "bar"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; m1.f(); }); diff --git a/tests/baselines/reference/amdDependencyCommentName1.js b/tests/baselines/reference/amdDependencyCommentName1.js index 19024a09f3c..d0e4d73fb7a 100644 --- a/tests/baselines/reference/amdDependencyCommentName1.js +++ b/tests/baselines/reference/amdDependencyCommentName1.js @@ -7,5 +7,6 @@ m1.f(); //// [amdDependencyCommentName1.js] /// "use strict"; +exports.__esModule = true; var m1 = require("m2"); m1.f(); diff --git a/tests/baselines/reference/amdDependencyCommentName2.js b/tests/baselines/reference/amdDependencyCommentName2.js index d60207e2bec..c39902371a0 100644 --- a/tests/baselines/reference/amdDependencyCommentName2.js +++ b/tests/baselines/reference/amdDependencyCommentName2.js @@ -8,5 +8,6 @@ m1.f(); /// define(["require", "exports", "bar", "m2"], function (require, exports, b, m1) { "use strict"; + exports.__esModule = true; m1.f(); }); diff --git a/tests/baselines/reference/amdDependencyCommentName3.js b/tests/baselines/reference/amdDependencyCommentName3.js index 1792c0c2aa0..f842ad0cbf8 100644 --- a/tests/baselines/reference/amdDependencyCommentName3.js +++ b/tests/baselines/reference/amdDependencyCommentName3.js @@ -12,5 +12,6 @@ m1.f(); /// define(["require", "exports", "bar", "goo", "m2", "foo"], function (require, exports, b, c, m1) { "use strict"; + exports.__esModule = true; m1.f(); }); diff --git a/tests/baselines/reference/amdDependencyCommentName4.js b/tests/baselines/reference/amdDependencyCommentName4.js index 52b10100365..6542aa14fa2 100644 --- a/tests/baselines/reference/amdDependencyCommentName4.js +++ b/tests/baselines/reference/amdDependencyCommentName4.js @@ -27,6 +27,7 @@ import "unaliasedModule2"; /// define(["require", "exports", "aliasedModule5", "aliasedModule6", "aliasedModule1", "aliasedModule2", "aliasedModule3", "aliasedModule4", "unaliasedModule3", "unaliasedModule4", "unaliasedModule1", "unaliasedModule2"], function (require, exports, n1, n2, r1, aliasedModule2_1, aliasedModule3_1, ns) { "use strict"; + exports.__esModule = true; r1; aliasedModule2_1.p1; aliasedModule3_1["default"]; diff --git a/tests/baselines/reference/amdImportAsPrimaryExpression.js b/tests/baselines/reference/amdImportAsPrimaryExpression.js index 3c2e9c041fa..69d3e095dc7 100644 --- a/tests/baselines/reference/amdImportAsPrimaryExpression.js +++ b/tests/baselines/reference/amdImportAsPrimaryExpression.js @@ -15,6 +15,7 @@ if(foo.E1.A === 0){ //// [foo_0.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var E1; (function (E1) { E1[E1["A"] = 0] = "A"; @@ -25,6 +26,8 @@ define(["require", "exports"], function (require, exports) { //// [foo_1.js] define(["require", "exports", "./foo_0"], function (require, exports, foo) { "use strict"; + exports.__esModule = true; if (foo.E1.A === 0) { + // Should cause runtime import - interesting optimization possibility, as gets inlined to 0. } }); diff --git a/tests/baselines/reference/amdImportNotAsPrimaryExpression.js b/tests/baselines/reference/amdImportNotAsPrimaryExpression.js index a0bd7c83d64..651ae7a6d39 100644 --- a/tests/baselines/reference/amdImportNotAsPrimaryExpression.js +++ b/tests/baselines/reference/amdImportNotAsPrimaryExpression.js @@ -34,6 +34,7 @@ var e: number = 0; //// [foo_0.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var C1 = (function () { function C1() { this.m1 = 42; @@ -52,6 +53,7 @@ define(["require", "exports"], function (require, exports) { //// [foo_1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var i; var x = {}; var y = false; diff --git a/tests/baselines/reference/anonymousClassExpression1.types b/tests/baselines/reference/anonymousClassExpression1.types index 0fbffffdf4b..3bc01960492 100644 --- a/tests/baselines/reference/anonymousClassExpression1.types +++ b/tests/baselines/reference/anonymousClassExpression1.types @@ -4,7 +4,7 @@ function f() { return typeof class {} === "function"; >typeof class {} === "function" : boolean ->typeof class {} : string +>typeof class {} : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >class {} : typeof (Anonymous class) >"function" : "function" } diff --git a/tests/baselines/reference/anonymousDefaultExportsAmd.js b/tests/baselines/reference/anonymousDefaultExportsAmd.js index bb5cd587a83..24e833b7542 100644 --- a/tests/baselines/reference/anonymousDefaultExportsAmd.js +++ b/tests/baselines/reference/anonymousDefaultExportsAmd.js @@ -9,15 +9,15 @@ export default function() {} //// [a.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); class default_1 { } - Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; }); //// [b.js] define(["require", "exports"], function (require, exports) { "use strict"; - function default_1() { } Object.defineProperty(exports, "__esModule", { value: true }); + function default_1() { } exports.default = default_1; }); diff --git a/tests/baselines/reference/anonymousDefaultExportsCommonjs.js b/tests/baselines/reference/anonymousDefaultExportsCommonjs.js index 754ffdb7c9b..e22000856d6 100644 --- a/tests/baselines/reference/anonymousDefaultExportsCommonjs.js +++ b/tests/baselines/reference/anonymousDefaultExportsCommonjs.js @@ -8,12 +8,12 @@ export default function() {} //// [a.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); class default_1 { } -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; //// [b.js] "use strict"; -function default_1() { } Object.defineProperty(exports, "__esModule", { value: true }); +function default_1() { } exports.default = default_1; diff --git a/tests/baselines/reference/anonymousDefaultExportsUmd.js b/tests/baselines/reference/anonymousDefaultExportsUmd.js index 85ed1d30444..484238b8722 100644 --- a/tests/baselines/reference/anonymousDefaultExportsUmd.js +++ b/tests/baselines/reference/anonymousDefaultExportsUmd.js @@ -17,9 +17,9 @@ export default function() {} } })(function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); class default_1 { } - Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; }); //// [b.js] @@ -33,7 +33,7 @@ export default function() {} } })(function (require, exports) { "use strict"; - function default_1() { } Object.defineProperty(exports, "__esModule", { value: true }); + function default_1() { } exports.default = default_1; }); diff --git a/tests/baselines/reference/apparentTypeSubtyping.js b/tests/baselines/reference/apparentTypeSubtyping.js index 6ca9d343a72..df266c20951 100644 --- a/tests/baselines/reference/apparentTypeSubtyping.js +++ b/tests/baselines/reference/apparentTypeSubtyping.js @@ -24,11 +24,16 @@ class Derived2 extends Base2 { // error because of the prototy //// [apparentTypeSubtyping.js] // subtype checks use the apparent type of the target type // S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S: -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -38,7 +43,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -51,7 +56,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/apparentTypeSupertype.js b/tests/baselines/reference/apparentTypeSupertype.js index c6d3378872e..16d43e8316c 100644 --- a/tests/baselines/reference/apparentTypeSupertype.js +++ b/tests/baselines/reference/apparentTypeSupertype.js @@ -14,11 +14,16 @@ class Derived extends Base { // error //// [apparentTypeSupertype.js] // subtype checks use the apparent type of the target type // S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S: -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -28,7 +33,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/argsInScope.js b/tests/baselines/reference/argsInScope.js index 90906426d24..a38bc778039 100644 --- a/tests/baselines/reference/argsInScope.js +++ b/tests/baselines/reference/argsInScope.js @@ -17,6 +17,7 @@ var C = (function () { } C.prototype.P = function (ii, j, k) { for (var i = 0; i < arguments.length; i++) { + // WScript.Echo("param: " + arguments[i]); } }; return C; diff --git a/tests/baselines/reference/argumentsAsPropertyName.js b/tests/baselines/reference/argumentsAsPropertyName.js new file mode 100644 index 00000000000..a4197c0a1d2 --- /dev/null +++ b/tests/baselines/reference/argumentsAsPropertyName.js @@ -0,0 +1,29 @@ +//// [argumentsAsPropertyName.ts] +// target: es5 +type MyType = { + arguments: Array +} + +declare function use(s: any); + +function myFunction(myType: MyType) { + for (let i = 0; i < 10; i++) { + use(myType.arguments[i]); + // create closure so that tsc will turn loop body into function + const x = 5; + [1, 2, 3].forEach(function(j) { use(x); }) + } +} + +//// [argumentsAsPropertyName.js] +function myFunction(myType) { + var _loop_1 = function (i) { + use(myType.arguments[i]); + // create closure so that tsc will turn loop body into function + var x = 5; + [1, 2, 3].forEach(function (j) { use(x); }); + }; + for (var i = 0; i < 10; i++) { + _loop_1(i); + } +} diff --git a/tests/baselines/reference/argumentsAsPropertyName.symbols b/tests/baselines/reference/argumentsAsPropertyName.symbols new file mode 100644 index 00000000000..1e3e41abb6e --- /dev/null +++ b/tests/baselines/reference/argumentsAsPropertyName.symbols @@ -0,0 +1,43 @@ +=== tests/cases/compiler/argumentsAsPropertyName.ts === +// target: es5 +type MyType = { +>MyType : Symbol(MyType, Decl(argumentsAsPropertyName.ts, 0, 0)) + + arguments: Array +>arguments : Symbol(arguments, Decl(argumentsAsPropertyName.ts, 1, 15)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +} + +declare function use(s: any); +>use : Symbol(use, Decl(argumentsAsPropertyName.ts, 3, 1)) +>s : Symbol(s, Decl(argumentsAsPropertyName.ts, 5, 21)) + +function myFunction(myType: MyType) { +>myFunction : Symbol(myFunction, Decl(argumentsAsPropertyName.ts, 5, 29)) +>myType : Symbol(myType, Decl(argumentsAsPropertyName.ts, 7, 20)) +>MyType : Symbol(MyType, Decl(argumentsAsPropertyName.ts, 0, 0)) + + for (let i = 0; i < 10; i++) { +>i : Symbol(i, Decl(argumentsAsPropertyName.ts, 8, 12)) +>i : Symbol(i, Decl(argumentsAsPropertyName.ts, 8, 12)) +>i : Symbol(i, Decl(argumentsAsPropertyName.ts, 8, 12)) + + use(myType.arguments[i]); +>use : Symbol(use, Decl(argumentsAsPropertyName.ts, 3, 1)) +>myType.arguments : Symbol(arguments, Decl(argumentsAsPropertyName.ts, 1, 15)) +>myType : Symbol(myType, Decl(argumentsAsPropertyName.ts, 7, 20)) +>arguments : Symbol(arguments, Decl(argumentsAsPropertyName.ts, 1, 15)) +>i : Symbol(i, Decl(argumentsAsPropertyName.ts, 8, 12)) + + // create closure so that tsc will turn loop body into function + const x = 5; +>x : Symbol(x, Decl(argumentsAsPropertyName.ts, 11, 13)) + + [1, 2, 3].forEach(function(j) { use(x); }) +>[1, 2, 3].forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>j : Symbol(j, Decl(argumentsAsPropertyName.ts, 12, 35)) +>use : Symbol(use, Decl(argumentsAsPropertyName.ts, 3, 1)) +>x : Symbol(x, Decl(argumentsAsPropertyName.ts, 11, 13)) + } +} diff --git a/tests/baselines/reference/argumentsAsPropertyName.types b/tests/baselines/reference/argumentsAsPropertyName.types new file mode 100644 index 00000000000..d0aaaa1cc72 --- /dev/null +++ b/tests/baselines/reference/argumentsAsPropertyName.types @@ -0,0 +1,57 @@ +=== tests/cases/compiler/argumentsAsPropertyName.ts === +// target: es5 +type MyType = { +>MyType : MyType + + arguments: Array +>arguments : string[] +>Array : T[] +} + +declare function use(s: any); +>use : (s: any) => any +>s : any + +function myFunction(myType: MyType) { +>myFunction : (myType: MyType) => void +>myType : MyType +>MyType : MyType + + for (let i = 0; i < 10; i++) { +>i : number +>0 : 0 +>i < 10 : boolean +>i : number +>10 : 10 +>i++ : number +>i : number + + use(myType.arguments[i]); +>use(myType.arguments[i]) : any +>use : (s: any) => any +>myType.arguments[i] : string +>myType.arguments : string[] +>myType : MyType +>arguments : string[] +>i : number + + // create closure so that tsc will turn loop body into function + const x = 5; +>x : 5 +>5 : 5 + + [1, 2, 3].forEach(function(j) { use(x); }) +>[1, 2, 3].forEach(function(j) { use(x); }) : void +>[1, 2, 3].forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void +>function(j) { use(x); } : (j: number) => void +>j : number +>use(x) : any +>use : (s: any) => any +>x : 5 + } +} diff --git a/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.errors.txt b/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.errors.txt index c043cda8e68..16a0264a805 100644 --- a/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.errors.txt +++ b/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.errors.txt @@ -1,234 +1,246 @@ -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(9,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(9,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(9,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(10,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(10,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(10,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(11,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(11,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(11,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(13,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(13,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(13,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(14,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(14,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(14,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(15,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(15,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(17,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(15,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(17,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(17,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(18,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(18,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(18,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(19,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(19,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(19,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(21,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(21,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(21,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(22,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(22,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(22,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(23,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(23,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(26,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(23,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(26,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(26,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(27,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(27,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(27,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(28,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(28,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(28,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(30,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(30,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(30,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(31,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(31,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(31,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(32,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(32,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(34,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(32,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(34,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(34,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(35,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(35,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(35,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(36,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(36,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(36,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(38,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(38,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(38,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(39,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(39,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(39,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(40,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(40,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(43,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(40,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(43,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(43,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(44,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(44,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(44,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(45,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(45,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(45,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(47,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(47,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(47,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(48,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(48,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(48,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(49,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(49,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(51,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(49,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(51,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(51,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(52,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(52,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(52,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(53,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(53,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(53,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(55,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(55,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(55,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(56,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(56,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(56,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(57,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(57,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(60,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(57,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(60,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(60,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(61,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(61,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(61,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(62,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(62,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(62,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(64,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(64,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(64,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(65,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(65,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(65,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(66,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(66,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(68,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(66,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(68,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(68,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(69,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(69,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(69,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(70,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(70,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(70,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(72,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(72,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(72,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(73,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(73,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(73,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(74,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(74,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(77,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(74,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(77,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(77,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(78,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(78,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(78,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(79,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(79,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(79,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(81,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(81,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(81,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(82,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(82,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(82,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(83,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(83,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(85,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(83,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(85,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(85,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(86,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(86,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(86,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(87,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(87,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(87,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(89,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(89,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(89,20): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(90,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(90,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(90,18): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(91,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(91,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(94,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(91,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(94,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(94,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(95,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(95,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(95,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(96,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(96,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(96,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(98,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(98,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(98,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(99,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(99,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(99,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(100,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(100,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(102,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(100,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(102,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(102,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(103,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(103,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(103,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(104,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(104,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(104,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(106,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(106,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(106,20): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(107,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(107,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(107,18): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(108,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(108,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(111,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(108,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(111,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(111,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(112,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(112,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(112,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(113,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(113,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(113,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(115,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(115,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(115,18): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(116,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(116,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(116,18): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(117,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(117,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(119,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(117,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(119,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(119,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(120,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(120,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(120,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(121,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(121,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(121,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(123,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(123,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(123,21): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(124,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(124,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(124,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(125,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(125,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(128,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(129,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(125,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(128,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(128,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(129,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(129,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(130,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(130,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(130,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(132,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(132,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(132,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(133,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(133,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(133,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(134,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(134,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(136,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(137,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(134,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(136,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(136,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(137,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(137,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(138,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(138,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(138,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(140,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(140,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(140,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(141,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(141,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(141,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(142,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(142,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(145,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(146,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(142,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(145,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(145,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(146,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(146,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(147,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(147,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(147,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(149,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(149,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(149,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(150,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(150,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(150,16): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(151,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(151,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(153,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(154,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(151,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(153,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(153,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(154,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(154,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(155,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(155,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(155,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(157,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(157,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(157,19): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(158,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(158,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(158,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(159,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(159,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(162,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(163,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(159,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(162,13): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(162,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(163,13): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(163,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(164,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(164,13): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(164,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(166,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(166,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(166,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(167,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(167,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(167,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(168,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(168,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(170,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(171,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(168,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(170,13): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(170,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(171,13): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(171,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(172,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(172,13): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(172,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(174,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(174,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(174,20): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(175,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(175,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(175,18): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(176,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(176,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(176,18): error TS2531: Object is possibly 'null'. -==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts (228 errors) ==== +==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts (240 errors) ==== // If one operand is the null or undefined value, it is treated as having the type of the // other operand. @@ -239,17 +251,17 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti // operator * var r1a1 = null * a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a2 = null * b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a3 = null * c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -257,31 +269,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! 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 TS2531: Object is possibly 'null'. var r1b2 = b * null; ~ !!! 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 TS2531: Object is possibly 'null'. var r1b3 = c * null; ~ !!! 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 TS2531: Object is possibly 'null'. var r1c1 = null * true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c2 = null * ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c3 = null * {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -289,32 +301,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! 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 TS2531: Object is possibly 'null'. var r1d2 = '' * null; ~~ !!! 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 TS2531: Object is possibly 'null'. var r1d3 = {} * null; ~~ !!! 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 TS2531: Object is possibly 'null'. // operator / var r2a1 = null / a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2a2 = null / b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2a3 = null / c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -322,31 +334,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! 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 TS2531: Object is possibly 'null'. var r2b2 = b / null; ~ !!! 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 TS2531: Object is possibly 'null'. var r2b3 = c / null; ~ !!! 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 TS2531: Object is possibly 'null'. var r2c1 = null / true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2c2 = null / ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2c3 = null / {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -354,32 +366,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! 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 TS2531: Object is possibly 'null'. var r2d2 = '' / null; ~~ !!! 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 TS2531: Object is possibly 'null'. var r2d3 = {} / null; ~~ !!! 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 TS2531: Object is possibly 'null'. // operator % var r3a1 = null % a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3a2 = null % b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3a3 = null % c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -387,31 +399,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! 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 TS2531: Object is possibly 'null'. var r3b2 = b % null; ~ !!! 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 TS2531: Object is possibly 'null'. var r3b3 = c % null; ~ !!! 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 TS2531: Object is possibly 'null'. var r3c1 = null % true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3c2 = null % ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3c3 = null % {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -419,32 +431,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! 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 TS2531: Object is possibly 'null'. var r3d2 = '' % null; ~~ !!! 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 TS2531: Object is possibly 'null'. var r3d3 = {} % null; ~~ !!! 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 TS2531: Object is possibly 'null'. // operator - var r4a1 = null - a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4a2 = null - b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4a3 = null - c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -452,31 +464,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! 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 TS2531: Object is possibly 'null'. var r4b2 = b - null; ~ !!! 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 TS2531: Object is possibly 'null'. var r4b3 = c - null; ~ !!! 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 TS2531: Object is possibly 'null'. var r4c1 = null - true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4c2 = null - ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4c3 = null - {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -484,32 +496,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! 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 TS2531: Object is possibly 'null'. var r4d2 = '' - null; ~~ !!! 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 TS2531: Object is possibly 'null'. var r4d3 = {} - null; ~~ !!! 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 TS2531: Object is possibly 'null'. // operator << var r5a1 = null << a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5a2 = null << b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5a3 = null << c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -517,31 +529,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! 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 TS2531: Object is possibly 'null'. var r5b2 = b << null; ~ !!! 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 TS2531: Object is possibly 'null'. var r5b3 = c << null; ~ !!! 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 TS2531: Object is possibly 'null'. var r5c1 = null << true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5c2 = null << ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5c3 = null << {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -549,32 +561,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! 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 TS2531: Object is possibly 'null'. var r5d2 = '' << null; ~~ !!! 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 TS2531: Object is possibly 'null'. var r5d3 = {} << null; ~~ !!! 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 TS2531: Object is possibly 'null'. // operator >> var r6a1 = null >> a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6a2 = null >> b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6a3 = null >> c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -582,31 +594,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! 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 TS2531: Object is possibly 'null'. var r6b2 = b >> null; ~ !!! 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 TS2531: Object is possibly 'null'. var r6b3 = c >> null; ~ !!! 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 TS2531: Object is possibly 'null'. var r6c1 = null >> true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6c2 = null >> ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6c3 = null >> {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -614,32 +626,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! 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 TS2531: Object is possibly 'null'. var r6d2 = '' >> null; ~~ !!! 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 TS2531: Object is possibly 'null'. var r6d3 = {} >> null; ~~ !!! 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 TS2531: Object is possibly 'null'. // operator >>> var r7a1 = null >>> a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7a2 = null >>> b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7a3 = null >>> c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -647,31 +659,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! 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 TS2531: Object is possibly 'null'. var r7b2 = b >>> null; ~ !!! 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 TS2531: Object is possibly 'null'. var r7b3 = c >>> null; ~ !!! 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 TS2531: Object is possibly 'null'. var r7c1 = null >>> true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7c2 = null >>> ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7c3 = null >>> {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -679,185 +691,209 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! 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 TS2531: Object is possibly 'null'. var r7d2 = '' >>> null; ~~ !!! 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 TS2531: Object is possibly 'null'. var r7d3 = {} >>> null; ~~ !!! 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 TS2531: Object is possibly 'null'. // operator & var r8a1 = null & a; - ~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8a2 = null & b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8a3 = null & c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8b1 = a & null; - ~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r8b2 = b & null; ~ !!! 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 TS2531: Object is possibly 'null'. var r8b3 = c & null; ~ !!! 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 TS2531: Object is possibly 'null'. var r8c1 = null & true; - ~~~~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8c2 = null & ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8c3 = null & {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8d1 = true & null; - ~~~~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r8d2 = '' & null; ~~ !!! 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 TS2531: Object is possibly 'null'. var r8d3 = {} & null; ~~ !!! 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 TS2531: Object is possibly 'null'. // operator ^ var r9a1 = null ^ a; - ~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9a2 = null ^ b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9a3 = null ^ c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9b1 = a ^ null; - ~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r9b2 = b ^ null; ~ !!! 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 TS2531: Object is possibly 'null'. var r9b3 = c ^ null; ~ !!! 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 TS2531: Object is possibly 'null'. var r9c1 = null ^ true; - ~~~~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9c2 = null ^ ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9c3 = null ^ {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9d1 = true ^ null; - ~~~~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r9d2 = '' ^ null; ~~ !!! 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 TS2531: Object is possibly 'null'. var r9d3 = {} ^ null; ~~ !!! 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 TS2531: Object is possibly 'null'. // operator | var r10a1 = null | a; - ~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10a2 = null | b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10a3 = null | c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10b1 = a | null; - ~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r10b2 = b | null; ~ !!! 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 TS2531: Object is possibly 'null'. var r10b3 = c | null; ~ !!! 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 TS2531: Object is possibly 'null'. var r10c1 = null | true; - ~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10c2 = null | ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10c3 = null | {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10d1 = true | null; - ~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var r10d2 = '' | null; ~~ !!! 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 TS2531: Object is possibly 'null'. var r10d3 = {} | null; ~~ !!! 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. \ No newline at end of file +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.errors.txt b/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.errors.txt new file mode 100644 index 00000000000..426db291224 --- /dev/null +++ b/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.errors.txt @@ -0,0 +1,353 @@ +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(13,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(14,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(15,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(16,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(17,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(18,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(19,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(20,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(23,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(24,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(25,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(26,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(27,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(28,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(29,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(30,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(33,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(34,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(35,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(36,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(37,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(38,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(39,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(40,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(43,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(44,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(45,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(46,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(47,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(48,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(49,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(50,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(53,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(54,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(55,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(56,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(57,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(58,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(59,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(60,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(63,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(64,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(65,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(66,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(67,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(68,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(69,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(70,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(73,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(74,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(75,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(76,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(77,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(78,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(79,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(80,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(83,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(84,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(85,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(86,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(87,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(88,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(89,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(90,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(93,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(94,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(95,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(96,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(97,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(98,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(99,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(100,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(103,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(104,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(105,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(106,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(107,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(108,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(109,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts(110,17): error TS2531: Object is possibly 'null'. + + +==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndValidOperands.ts (80 errors) ==== + // If one operand is the null or undefined value, it is treated as having the type of the + // other operand. + + enum E { + a, + b + } + + var a: any; + var b: number; + + // operator * + var ra1 = null * a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra2 = null * b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra3 = null * 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra4 = null * E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra5 = a * null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra6 = b * null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra7 = 0 * null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra8 = E.b * null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator / + var rb1 = null / a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb2 = null / b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb3 = null / 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb4 = null / E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb5 = a / null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb6 = b / null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb7 = 0 / null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb8 = E.b / null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator % + var rc1 = null % a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc2 = null % b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc3 = null % 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc4 = null % E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc5 = a % null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc6 = b % null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc7 = 0 % null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc8 = E.b % null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator - + var rd1 = null - a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd2 = null - b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd3 = null - 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd4 = null - E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd5 = a - null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd6 = b - null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd7 = 0 - null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd8 = E.b - null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator << + var re1 = null << a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re2 = null << b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re3 = null << 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re4 = null << E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re5 = a << null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re6 = b << null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re7 = 0 << null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var re8 = E.b << null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator >> + var rf1 = null >> a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf2 = null >> b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf3 = null >> 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf4 = null >> E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf5 = a >> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf6 = b >> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf7 = 0 >> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rf8 = E.b >> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator >>> + var rg1 = null >>> a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg2 = null >>> b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg3 = null >>> 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg4 = null >>> E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg5 = a >>> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg6 = b >>> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg7 = 0 >>> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rg8 = E.b >>> null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator & + var rh1 = null & a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh2 = null & b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh3 = null & 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh4 = null & E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh5 = a & null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh6 = b & null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh7 = 0 & null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rh8 = E.b & null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator ^ + var ri1 = null ^ a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri2 = null ^ b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri3 = null ^ 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri4 = null ^ E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri5 = a ^ null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri6 = b ^ null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri7 = 0 ^ null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ri8 = E.b ^ null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator | + var rj1 = null | a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj2 = null | b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj3 = null | 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj4 = null | E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj5 = a | null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj6 = b | null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj7 = 0 | null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rj8 = E.b | null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.errors.txt b/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.errors.txt index d00eee1d4dd..e67db44a780 100644 --- a/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.errors.txt +++ b/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.errors.txt @@ -1,302 +1,302 @@ -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(2,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.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/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(3,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(3,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(4,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(4,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(5,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(5,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(8,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(8,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(9,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(9,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(10,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(10,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(11,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(11,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(14,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(14,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(15,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(15,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(16,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(16,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(17,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(17,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(20,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(20,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(21,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(21,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(22,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(22,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(23,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(23,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(26,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(26,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(27,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(27,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(28,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(28,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(29,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(29,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(32,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(32,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(33,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(33,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(34,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(34,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(35,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(35,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(38,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(38,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(39,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(39,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(40,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(40,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(41,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(41,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(44,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(44,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(45,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(45,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(46,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(46,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(47,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(47,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(50,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(50,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(51,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(51,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(52,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(52,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(53,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(53,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(56,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(56,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(57,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(57,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(58,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(58,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(59,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(59,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(2,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(2,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(3,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(3,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(4,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(4,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(5,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(5,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(8,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(8,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(9,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(9,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(10,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(10,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(11,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(11,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(14,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(14,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(15,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(15,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(16,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(16,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(17,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(17,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(20,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(20,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(21,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(21,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(22,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(22,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(23,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(23,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(26,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(26,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(27,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(27,19): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(28,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(28,24): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(29,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(29,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(32,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(32,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(33,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(33,19): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(34,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(34,24): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(35,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(35,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(38,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(38,20): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(39,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(39,20): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(40,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(40,25): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(41,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(41,25): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(44,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(44,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(45,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(45,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(46,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(46,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(47,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(47,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(50,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(50,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(51,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(51,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(52,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(52,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(53,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(53,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(56,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(56,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(57,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(57,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(58,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(58,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(59,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts(59,23): error TS2532: Object is possibly 'undefined'. ==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts (80 errors) ==== // operator * var ra1 = null * null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var ra2 = null * undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var ra3 = undefined * null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var ra4 = undefined * undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator / var rb1 = null / null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rb2 = null / undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rb3 = undefined / null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rb4 = undefined / undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator % var rc1 = null % null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rc2 = null % undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rc3 = undefined % null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rc4 = undefined % undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator - var rd1 = null - null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rd2 = null - undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rd3 = undefined - null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rd4 = undefined - undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator << var re1 = null << null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var re2 = null << undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var re3 = undefined << null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var re4 = undefined << undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator >> var rf1 = null >> null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rf2 = null >> undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rf3 = undefined >> null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rf4 = undefined >> undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator >>> var rg1 = null >>> null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rg2 = null >>> undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rg3 = undefined >>> null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rg4 = undefined >>> undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator & var rh1 = null & null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rh2 = null & undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rh3 = undefined & null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rh4 = undefined & undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator ^ var ri1 = null ^ null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var ri2 = null ^ undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var ri3 = undefined ^ null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var ri4 = undefined ^ undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // operator | var rj1 = null | null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rj2 = null | undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var rj3 = undefined | null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var rj4 = undefined | undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.errors.txt b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.errors.txt index 9ee53c2f15c..8a9d014f2c2 100644 --- a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.errors.txt +++ b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.errors.txt @@ -1,234 +1,246 @@ -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(9,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(9,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(9,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(10,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(10,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(10,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(11,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(11,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(11,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(13,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(13,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(13,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(14,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(14,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(14,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(15,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(15,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(17,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(15,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(17,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(17,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(18,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(18,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(18,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(19,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(19,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(19,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(21,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(21,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(21,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(22,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(22,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(22,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(23,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(23,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(26,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(23,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(26,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(26,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(27,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(27,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(27,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(28,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(28,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(28,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(30,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(30,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(30,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(31,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(31,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(31,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(32,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(32,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(34,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(32,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(34,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(34,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(35,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(35,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(35,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(36,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(36,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(36,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(38,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(38,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(38,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(39,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(39,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(39,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(40,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(40,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(43,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(40,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(43,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(43,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(44,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(44,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(44,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(45,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(45,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(45,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(47,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(47,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(47,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(48,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(48,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(48,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(49,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(49,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(51,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(49,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(51,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(51,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(52,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(52,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(52,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(53,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(53,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(53,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(55,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(55,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(55,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(56,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(56,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(56,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(57,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(57,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(60,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(57,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(60,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(60,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(61,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(61,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(61,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(62,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(62,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(62,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(64,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(64,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(64,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(65,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(65,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(65,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(66,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(66,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(68,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(66,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(68,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(68,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(69,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(69,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(69,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(70,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(70,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(70,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(72,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(72,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(72,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(73,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(73,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(73,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(74,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(74,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(77,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(74,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(77,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(77,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(78,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(78,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(78,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(79,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(79,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(79,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(81,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(81,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(81,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(82,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(82,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(82,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(83,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(83,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(85,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(83,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(85,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(85,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(86,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(86,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(86,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(87,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(87,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(87,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(89,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(89,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(89,20): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(90,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(90,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(90,18): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(91,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(91,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(94,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(91,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(94,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(94,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(95,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(95,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(95,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(96,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(96,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(96,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(98,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(98,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(98,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(99,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(99,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(99,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(100,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(100,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(102,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(100,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(102,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(102,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(103,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(103,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(103,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(104,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(104,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(104,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(106,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(106,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(106,20): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(107,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(107,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(107,18): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(108,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(108,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(111,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(108,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(111,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(111,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(112,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(112,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(112,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(113,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(113,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(113,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(115,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(115,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(115,18): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(116,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(116,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(116,18): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(117,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(117,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(119,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(117,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(119,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(119,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(120,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(120,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(120,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(121,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(121,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(121,26): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(123,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(123,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(123,21): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(124,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(124,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(124,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(125,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(125,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(128,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(129,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(125,19): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(128,12): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(128,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(129,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(129,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(130,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(130,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(130,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(132,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(132,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(132,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(133,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(133,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(133,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(134,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(134,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(136,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(137,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(134,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(136,12): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(136,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(137,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(137,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(138,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(138,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(138,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(140,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(140,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(140,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(141,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(141,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(141,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(142,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(142,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(145,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(146,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(142,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(145,12): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(145,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(146,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(146,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(147,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(147,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(147,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(149,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(149,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(149,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(150,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(150,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(150,16): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(151,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(151,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(153,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(154,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(151,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(153,12): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(153,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(154,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(154,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(155,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(155,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(155,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(157,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(157,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(157,19): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(158,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(158,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(158,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(159,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(159,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(162,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(163,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(159,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(162,13): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(162,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(163,13): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(163,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(164,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(164,13): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(164,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(166,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(166,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(166,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(167,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(167,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(167,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(168,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(168,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(170,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(171,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(168,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(170,13): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(170,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(171,13): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(171,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(172,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(172,13): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(172,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(174,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(174,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(174,20): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(175,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(175,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(175,18): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(176,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(176,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(176,18): error TS2532: Object is possibly 'undefined'. -==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts (228 errors) ==== +==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts (240 errors) ==== // If one operand is the undefined or undefined value, it is treated as having the type of the // other operand. @@ -239,17 +251,17 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti // operator * var r1a1 = undefined * a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a2 = undefined * b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a3 = undefined * c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -257,31 +269,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! 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 TS2532: Object is possibly 'undefined'. var r1b2 = b * undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r1b3 = c * undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r1c1 = undefined * true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c2 = undefined * ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c3 = undefined * {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -289,32 +301,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! 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 TS2532: Object is possibly 'undefined'. var r1d2 = '' * undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var r1d3 = {} * undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. // operator / var r2a1 = undefined / a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2a2 = undefined / b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2a3 = undefined / c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -322,31 +334,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! 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 TS2532: Object is possibly 'undefined'. var r2b2 = b / undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r2b3 = c / undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r2c1 = undefined / true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2c2 = undefined / ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r2c3 = undefined / {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -354,32 +366,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! 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 TS2532: Object is possibly 'undefined'. var r2d2 = '' / undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var r2d3 = {} / undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. // operator % var r3a1 = undefined % a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3a2 = undefined % b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3a3 = undefined % c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -387,31 +399,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! 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 TS2532: Object is possibly 'undefined'. var r3b2 = b % undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r3b3 = c % undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r3c1 = undefined % true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3c2 = undefined % ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r3c3 = undefined % {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -419,32 +431,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! 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 TS2532: Object is possibly 'undefined'. var r3d2 = '' % undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var r3d3 = {} % undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. // operator - var r4a1 = undefined - a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4a2 = undefined - b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4a3 = undefined - c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -452,31 +464,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! 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 TS2532: Object is possibly 'undefined'. var r4b2 = b - undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r4b3 = c - undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r4c1 = undefined - true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4c2 = undefined - ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r4c3 = undefined - {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -484,32 +496,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! 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 TS2532: Object is possibly 'undefined'. var r4d2 = '' - undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var r4d3 = {} - undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. // operator << var r5a1 = undefined << a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5a2 = undefined << b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5a3 = undefined << c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -517,31 +529,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! 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 TS2532: Object is possibly 'undefined'. var r5b2 = b << undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r5b3 = c << undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r5c1 = undefined << true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5c2 = undefined << ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r5c3 = undefined << {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -549,32 +561,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! 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 TS2532: Object is possibly 'undefined'. var r5d2 = '' << undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var r5d3 = {} << undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. // operator >> var r6a1 = undefined >> a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6a2 = undefined >> b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6a3 = undefined >> c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -582,31 +594,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! 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 TS2532: Object is possibly 'undefined'. var r6b2 = b >> undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r6b3 = c >> undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r6c1 = undefined >> true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6c2 = undefined >> ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r6c3 = undefined >> {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -614,32 +626,32 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! 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 TS2532: Object is possibly 'undefined'. var r6d2 = '' >> undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var r6d3 = {} >> undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. // operator >>> var r7a1 = undefined >>> a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7a2 = undefined >>> b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7a3 = undefined >>> c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -647,31 +659,31 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~ !!! 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 TS2532: Object is possibly 'undefined'. var r7b2 = b >>> undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r7b3 = c >>> undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r7c1 = undefined >>> true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7c2 = undefined >>> ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r7c3 = undefined >>> {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -679,185 +691,209 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti ~~~~ !!! 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 TS2532: Object is possibly 'undefined'. var r7d2 = '' >>> undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var r7d3 = {} >>> undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. // operator & var r8a1 = undefined & a; - ~~~~~~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8a2 = undefined & b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8a3 = undefined & c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8b1 = a & undefined; - ~~~~~~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r8b2 = b & undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r8b3 = c & undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r8c1 = undefined & true; - ~~~~~~~~~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8c2 = undefined & ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8c3 = undefined & {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r8d1 = true & undefined; - ~~~~~~~~~~~~~~~~ -!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r8d2 = '' & undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var r8d3 = {} & undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. // operator ^ var r9a1 = undefined ^ a; - ~~~~~~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9a2 = undefined ^ b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9a3 = undefined ^ c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9b1 = a ^ undefined; - ~~~~~~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r9b2 = b ^ undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r9b3 = c ^ undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r9c1 = undefined ^ true; - ~~~~~~~~~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9c2 = undefined ^ ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9c3 = undefined ^ {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r9d1 = true ^ undefined; - ~~~~~~~~~~~~~~~~ -!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r9d2 = '' ^ undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var r9d3 = {} ^ undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. // operator | var r10a1 = undefined | a; - ~~~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10a2 = undefined | b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10a3 = undefined | c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10b1 = a | undefined; - ~~~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r10b2 = b | undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r10b3 = c | undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r10c1 = undefined | true; - ~~~~~~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10c2 = undefined | ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10c3 = undefined | {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r10d1 = true | undefined; - ~~~~~~~~~~~~~~~~ -!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead. + ~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var r10d2 = '' | undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var r10d3 = {} | undefined; ~~ !!! 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. \ No newline at end of file +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.errors.txt b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.errors.txt new file mode 100644 index 00000000000..246b642603c --- /dev/null +++ b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.errors.txt @@ -0,0 +1,353 @@ +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(13,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(14,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(15,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(16,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(17,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(18,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(19,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(20,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(23,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(24,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(25,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(26,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(27,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(28,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(29,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(30,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(33,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(34,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(35,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(36,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(37,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(38,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(39,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(40,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(43,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(44,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(45,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(46,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(47,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(48,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(49,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(50,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(53,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(54,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(55,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(56,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(57,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(58,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(59,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(60,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(63,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(64,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(65,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(66,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(67,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(68,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(69,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(70,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(73,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(74,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(75,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(76,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(77,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(78,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(79,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(80,19): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(83,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(84,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(85,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(86,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(87,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(88,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(89,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(90,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(93,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(94,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(95,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(96,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(97,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(98,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(99,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(100,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(103,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(104,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(105,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(106,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(107,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(108,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(109,15): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts(110,17): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndValidOperands.ts (80 errors) ==== + // If one operand is the undefined or undefined value, it is treated as having the type of the + // other operand. + + enum E { + a, + b + } + + var a: any; + var b: number; + + // operator * + var ra1 = undefined * a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra2 = undefined * b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra3 = undefined * 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra4 = undefined * E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra5 = a * undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra6 = b * undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra7 = 0 * undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ra8 = E.b * undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator / + var rb1 = undefined / a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb2 = undefined / b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb3 = undefined / 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb4 = undefined / E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb5 = a / undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb6 = b / undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb7 = 0 / undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rb8 = E.b / undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator % + var rc1 = undefined % a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc2 = undefined % b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc3 = undefined % 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc4 = undefined % E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc5 = a % undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc6 = b % undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc7 = 0 % undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rc8 = E.b % undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator - + var rd1 = undefined - a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd2 = undefined - b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd3 = undefined - 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd4 = undefined - E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd5 = a - undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd6 = b - undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd7 = 0 - undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rd8 = E.b - undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator << + var re1 = undefined << a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re2 = undefined << b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re3 = undefined << 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re4 = undefined << E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re5 = a << undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re6 = b << undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re7 = 0 << undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var re8 = E.b << undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator >> + var rf1 = undefined >> a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf2 = undefined >> b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf3 = undefined >> 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf4 = undefined >> E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf5 = a >> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf6 = b >> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf7 = 0 >> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rf8 = E.b >> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator >>> + var rg1 = undefined >>> a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg2 = undefined >>> b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg3 = undefined >>> 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg4 = undefined >>> E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg5 = a >>> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg6 = b >>> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg7 = 0 >>> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rg8 = E.b >>> undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator & + var rh1 = undefined & a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh2 = undefined & b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh3 = undefined & 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh4 = undefined & E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh5 = a & undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh6 = b & undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh7 = 0 & undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rh8 = E.b & undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator ^ + var ri1 = undefined ^ a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri2 = undefined ^ b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri3 = undefined ^ 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri4 = undefined ^ E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri5 = a ^ undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri6 = b ^ undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri7 = 0 ^ undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var ri8 = E.b ^ undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator | + var rj1 = undefined | a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj2 = undefined | b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj3 = undefined | 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj4 = undefined | E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj5 = a | undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj6 = b | undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj7 = 0 | undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rj8 = E.b | undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/arrayAssignmentTest1.js b/tests/baselines/reference/arrayAssignmentTest1.js index a887203cd5e..511d37b1752 100644 --- a/tests/baselines/reference/arrayAssignmentTest1.js +++ b/tests/baselines/reference/arrayAssignmentTest1.js @@ -86,11 +86,16 @@ arr_any = c3; // should be an error - is arr_any = i1; // should be an error - is //// [arrayAssignmentTest1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1() { } @@ -101,7 +106,7 @@ var C1 = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C2.prototype.C2M1 = function () { return null; }; return C2; diff --git a/tests/baselines/reference/arrayAssignmentTest2.js b/tests/baselines/reference/arrayAssignmentTest2.js index d82dedff29d..233ea1b1159 100644 --- a/tests/baselines/reference/arrayAssignmentTest2.js +++ b/tests/baselines/reference/arrayAssignmentTest2.js @@ -60,11 +60,16 @@ arr_any = i1; // should be an error - is //// [arrayAssignmentTest2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1() { } @@ -75,7 +80,7 @@ var C1 = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C2.prototype.C2M1 = function () { return null; }; return C2; diff --git a/tests/baselines/reference/arrayBestCommonTypes.js b/tests/baselines/reference/arrayBestCommonTypes.js index b7ddaa5d6da..3a0ab1a5cf5 100644 --- a/tests/baselines/reference/arrayBestCommonTypes.js +++ b/tests/baselines/reference/arrayBestCommonTypes.js @@ -108,11 +108,16 @@ module NonEmptyTypes { //// [arrayBestCommonTypes.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var EmptyTypes; (function (EmptyTypes) { var base = (function () { @@ -128,7 +133,7 @@ var EmptyTypes; var derived = (function (_super) { __extends(derived, _super); function derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return derived; }(base)); @@ -187,7 +192,7 @@ var NonEmptyTypes; var derived = (function (_super) { __extends(derived, _super); function derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return derived; }(base)); diff --git a/tests/baselines/reference/arrayLiteralSpreadES5iterable.js b/tests/baselines/reference/arrayLiteralSpreadES5iterable.js new file mode 100644 index 00000000000..d71f49242dd --- /dev/null +++ b/tests/baselines/reference/arrayLiteralSpreadES5iterable.js @@ -0,0 +1,66 @@ +//// [arrayLiteralSpreadES5iterable.ts] +function f0() { + var a = [1, 2, 3]; + var a1 = [...a]; + var a2 = [1, ...a]; + var a3 = [1, 2, ...a]; + var a4 = [...a, 1]; + var a5 = [...a, 1, 2]; + var a6 = [1, 2, ...a, 1, 2]; + var a7 = [1, ...a, 2, ...a]; + var a8 = [...a, ...a, ...a]; +} + +function f1() { + var a = [1, 2, 3]; + var b = ["hello", ...a, true]; + var b: (string | number | boolean)[]; +} + +function f2() { + var a = [...[...[...[...[...[]]]]]]; + var b = [...[...[...[...[...[5]]]]]]; +} + + +//// [arrayLiteralSpreadES5iterable.js] +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spread = (this && this.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; +function f0() { + var a = [1, 2, 3]; + var a1 = __spread(a); + var a2 = __spread([1], a); + var a3 = __spread([1, 2], a); + var a4 = __spread(a, [1]); + var a5 = __spread(a, [1, 2]); + var a6 = __spread([1, 2], a, [1, 2]); + var a7 = __spread([1], a, [2], a); + var a8 = __spread(a, a, a); +} +function f1() { + var a = [1, 2, 3]; + var b = __spread(["hello"], a, [true]); + var b; +} +function f2() { + var a = __spread([]); + var b = __spread([5]); +} diff --git a/tests/baselines/reference/arrayLiteralSpreadES5iterable.symbols b/tests/baselines/reference/arrayLiteralSpreadES5iterable.symbols new file mode 100644 index 00000000000..e31cc74e013 --- /dev/null +++ b/tests/baselines/reference/arrayLiteralSpreadES5iterable.symbols @@ -0,0 +1,67 @@ +=== tests/cases/conformance/es6/spread/arrayLiteralSpreadES5iterable.ts === +function f0() { +>f0 : Symbol(f0, Decl(arrayLiteralSpreadES5iterable.ts, 0, 0)) + + var a = [1, 2, 3]; +>a : Symbol(a, Decl(arrayLiteralSpreadES5iterable.ts, 1, 7)) + + var a1 = [...a]; +>a1 : Symbol(a1, Decl(arrayLiteralSpreadES5iterable.ts, 2, 7)) +>a : Symbol(a, Decl(arrayLiteralSpreadES5iterable.ts, 1, 7)) + + var a2 = [1, ...a]; +>a2 : Symbol(a2, Decl(arrayLiteralSpreadES5iterable.ts, 3, 7)) +>a : Symbol(a, Decl(arrayLiteralSpreadES5iterable.ts, 1, 7)) + + var a3 = [1, 2, ...a]; +>a3 : Symbol(a3, Decl(arrayLiteralSpreadES5iterable.ts, 4, 7)) +>a : Symbol(a, Decl(arrayLiteralSpreadES5iterable.ts, 1, 7)) + + var a4 = [...a, 1]; +>a4 : Symbol(a4, Decl(arrayLiteralSpreadES5iterable.ts, 5, 7)) +>a : Symbol(a, Decl(arrayLiteralSpreadES5iterable.ts, 1, 7)) + + var a5 = [...a, 1, 2]; +>a5 : Symbol(a5, Decl(arrayLiteralSpreadES5iterable.ts, 6, 7)) +>a : Symbol(a, Decl(arrayLiteralSpreadES5iterable.ts, 1, 7)) + + var a6 = [1, 2, ...a, 1, 2]; +>a6 : Symbol(a6, Decl(arrayLiteralSpreadES5iterable.ts, 7, 7)) +>a : Symbol(a, Decl(arrayLiteralSpreadES5iterable.ts, 1, 7)) + + var a7 = [1, ...a, 2, ...a]; +>a7 : Symbol(a7, Decl(arrayLiteralSpreadES5iterable.ts, 8, 7)) +>a : Symbol(a, Decl(arrayLiteralSpreadES5iterable.ts, 1, 7)) +>a : Symbol(a, Decl(arrayLiteralSpreadES5iterable.ts, 1, 7)) + + var a8 = [...a, ...a, ...a]; +>a8 : Symbol(a8, Decl(arrayLiteralSpreadES5iterable.ts, 9, 7)) +>a : Symbol(a, Decl(arrayLiteralSpreadES5iterable.ts, 1, 7)) +>a : Symbol(a, Decl(arrayLiteralSpreadES5iterable.ts, 1, 7)) +>a : Symbol(a, Decl(arrayLiteralSpreadES5iterable.ts, 1, 7)) +} + +function f1() { +>f1 : Symbol(f1, Decl(arrayLiteralSpreadES5iterable.ts, 10, 1)) + + var a = [1, 2, 3]; +>a : Symbol(a, Decl(arrayLiteralSpreadES5iterable.ts, 13, 7)) + + var b = ["hello", ...a, true]; +>b : Symbol(b, Decl(arrayLiteralSpreadES5iterable.ts, 14, 7), Decl(arrayLiteralSpreadES5iterable.ts, 15, 7)) +>a : Symbol(a, Decl(arrayLiteralSpreadES5iterable.ts, 13, 7)) + + var b: (string | number | boolean)[]; +>b : Symbol(b, Decl(arrayLiteralSpreadES5iterable.ts, 14, 7), Decl(arrayLiteralSpreadES5iterable.ts, 15, 7)) +} + +function f2() { +>f2 : Symbol(f2, Decl(arrayLiteralSpreadES5iterable.ts, 16, 1)) + + var a = [...[...[...[...[...[]]]]]]; +>a : Symbol(a, Decl(arrayLiteralSpreadES5iterable.ts, 19, 7)) + + var b = [...[...[...[...[...[5]]]]]]; +>b : Symbol(b, Decl(arrayLiteralSpreadES5iterable.ts, 20, 7)) +} + diff --git a/tests/baselines/reference/arrayLiteralSpreadES5iterable.types b/tests/baselines/reference/arrayLiteralSpreadES5iterable.types new file mode 100644 index 00000000000..21c41bb6dce --- /dev/null +++ b/tests/baselines/reference/arrayLiteralSpreadES5iterable.types @@ -0,0 +1,133 @@ +=== tests/cases/conformance/es6/spread/arrayLiteralSpreadES5iterable.ts === +function f0() { +>f0 : () => void + + var a = [1, 2, 3]; +>a : number[] +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 + + var a1 = [...a]; +>a1 : number[] +>[...a] : number[] +>...a : number +>a : number[] + + var a2 = [1, ...a]; +>a2 : number[] +>[1, ...a] : number[] +>1 : 1 +>...a : number +>a : number[] + + var a3 = [1, 2, ...a]; +>a3 : number[] +>[1, 2, ...a] : number[] +>1 : 1 +>2 : 2 +>...a : number +>a : number[] + + var a4 = [...a, 1]; +>a4 : number[] +>[...a, 1] : number[] +>...a : number +>a : number[] +>1 : 1 + + var a5 = [...a, 1, 2]; +>a5 : number[] +>[...a, 1, 2] : number[] +>...a : number +>a : number[] +>1 : 1 +>2 : 2 + + var a6 = [1, 2, ...a, 1, 2]; +>a6 : number[] +>[1, 2, ...a, 1, 2] : number[] +>1 : 1 +>2 : 2 +>...a : number +>a : number[] +>1 : 1 +>2 : 2 + + var a7 = [1, ...a, 2, ...a]; +>a7 : number[] +>[1, ...a, 2, ...a] : number[] +>1 : 1 +>...a : number +>a : number[] +>2 : 2 +>...a : number +>a : number[] + + var a8 = [...a, ...a, ...a]; +>a8 : number[] +>[...a, ...a, ...a] : number[] +>...a : number +>a : number[] +>...a : number +>a : number[] +>...a : number +>a : number[] +} + +function f1() { +>f1 : () => void + + var a = [1, 2, 3]; +>a : number[] +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 + + var b = ["hello", ...a, true]; +>b : (string | number | boolean)[] +>["hello", ...a, true] : (string | number | boolean)[] +>"hello" : "hello" +>...a : number +>a : number[] +>true : true + + var b: (string | number | boolean)[]; +>b : (string | number | boolean)[] +} + +function f2() { +>f2 : () => void + + var a = [...[...[...[...[...[]]]]]]; +>a : any[] +>[...[...[...[...[...[]]]]]] : undefined[] +>...[...[...[...[...[]]]]] : undefined +>[...[...[...[...[]]]]] : undefined[] +>...[...[...[...[]]]] : undefined +>[...[...[...[]]]] : undefined[] +>...[...[...[]]] : undefined +>[...[...[]]] : undefined[] +>...[...[]] : undefined +>[...[]] : undefined[] +>...[] : undefined +>[] : undefined[] + + var b = [...[...[...[...[...[5]]]]]]; +>b : number[] +>[...[...[...[...[...[5]]]]]] : number[] +>...[...[...[...[...[5]]]]] : number +>[...[...[...[...[5]]]]] : number[] +>...[...[...[...[5]]]] : number +>[...[...[...[5]]]] : number[] +>...[...[...[5]]] : number +>[...[...[5]]] : number[] +>...[...[5]] : number +>[...[5]] : number[] +>...[5] : number +>[5] : number[] +>5 : 5 +} + diff --git a/tests/baselines/reference/arrayLiteralTypeInference.js b/tests/baselines/reference/arrayLiteralTypeInference.js index 919d3a5e922..d9b830e8184 100644 --- a/tests/baselines/reference/arrayLiteralTypeInference.js +++ b/tests/baselines/reference/arrayLiteralTypeInference.js @@ -52,11 +52,16 @@ var z3: { id: number }[] = //// [arrayLiteralTypeInference.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Action = (function () { function Action() { } @@ -65,14 +70,14 @@ var Action = (function () { var ActionA = (function (_super) { __extends(ActionA, _super); function ActionA() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ActionA; }(Action)); var ActionB = (function (_super) { __extends(ActionB, _super); function ActionB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ActionB; }(Action)); diff --git a/tests/baselines/reference/arrayLiterals.js b/tests/baselines/reference/arrayLiterals.js index 530cdedec73..8041ac399f0 100644 --- a/tests/baselines/reference/arrayLiterals.js +++ b/tests/baselines/reference/arrayLiterals.js @@ -38,11 +38,16 @@ var context4: Base[] = [new Derived1(), new Derived1()]; //// [arrayLiterals.js] // Empty array literal with no contextual type has type Undefined[] -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var arr1 = [[], [1], ['']]; var arr2 = [[null], [1], ['']]; // Array literal with elements of only EveryType E has type E[] @@ -70,7 +75,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived1; }(Base)); @@ -78,7 +83,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js index c0f320ac1e5..8321a572178 100644 --- a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js +++ b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js @@ -26,11 +26,16 @@ var myDerivedList: DerivedList; var as = [list, myDerivedList]; // List[] //// [arrayLiteralsWithRecursiveGenerics.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var List = (function () { function List() { } @@ -39,7 +44,7 @@ var List = (function () { var DerivedList = (function (_super) { __extends(DerivedList, _super); function DerivedList() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return DerivedList; }(List)); diff --git a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js index d1d75e8041c..b2164a07b81 100644 --- a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js +++ b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js @@ -20,11 +20,16 @@ rrb = cra; // error: 'A' is not assignable to 'B' //// [arrayOfSubtypeIsAssignableToReadonlyArray.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -33,14 +38,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(Array)); diff --git a/tests/baselines/reference/arrowFunctionContexts.js b/tests/baselines/reference/arrowFunctionContexts.js index 1af0797b41f..2285aadd3d5 100644 --- a/tests/baselines/reference/arrowFunctionContexts.js +++ b/tests/baselines/reference/arrowFunctionContexts.js @@ -97,11 +97,16 @@ var asserted2: any; //// [arrowFunctionContexts.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var _this = this; // Arrow function used in with statement with (window) { diff --git a/tests/baselines/reference/arrowFunctionErrorSpan.js b/tests/baselines/reference/arrowFunctionErrorSpan.js index 2557113e89b..ca1f966f517 100644 --- a/tests/baselines/reference/arrowFunctionErrorSpan.js +++ b/tests/baselines/reference/arrowFunctionErrorSpan.js @@ -83,7 +83,9 @@ f(// comment 1 // comment 2 function () { // comment 4 -}); +} +// comment 5 +); // body is not a block f(function (_) { return 1 + 2; }); diff --git a/tests/baselines/reference/asOperator4.js b/tests/baselines/reference/asOperator4.js index 41edf92416b..3a43f328f35 100644 --- a/tests/baselines/reference/asOperator4.js +++ b/tests/baselines/reference/asOperator4.js @@ -14,10 +14,12 @@ import { foo } from './foo'; //// [foo.js] "use strict"; +exports.__esModule = true; function foo() { } exports.foo = foo; //// [bar.js] "use strict"; +exports.__esModule = true; var foo_1 = require("./foo"); // These should emit identically foo_1.foo; diff --git a/tests/baselines/reference/assignObjectToNonPrimitive.js b/tests/baselines/reference/assignObjectToNonPrimitive.js new file mode 100644 index 00000000000..ec0015fba8a --- /dev/null +++ b/tests/baselines/reference/assignObjectToNonPrimitive.js @@ -0,0 +1,14 @@ +//// [assignObjectToNonPrimitive.ts] +var x = {}; +var y = {foo: "bar"}; +var a: object; +a = x; +a = y; + + +//// [assignObjectToNonPrimitive.js] +var x = {}; +var y = { foo: "bar" }; +var a; +a = x; +a = y; diff --git a/tests/baselines/reference/assignObjectToNonPrimitive.symbols b/tests/baselines/reference/assignObjectToNonPrimitive.symbols new file mode 100644 index 00000000000..5c806e09b94 --- /dev/null +++ b/tests/baselines/reference/assignObjectToNonPrimitive.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/types/nonPrimitive/assignObjectToNonPrimitive.ts === +var x = {}; +>x : Symbol(x, Decl(assignObjectToNonPrimitive.ts, 0, 3)) + +var y = {foo: "bar"}; +>y : Symbol(y, Decl(assignObjectToNonPrimitive.ts, 1, 3)) +>foo : Symbol(foo, Decl(assignObjectToNonPrimitive.ts, 1, 9)) + +var a: object; +>a : Symbol(a, Decl(assignObjectToNonPrimitive.ts, 2, 3)) + +a = x; +>a : Symbol(a, Decl(assignObjectToNonPrimitive.ts, 2, 3)) +>x : Symbol(x, Decl(assignObjectToNonPrimitive.ts, 0, 3)) + +a = y; +>a : Symbol(a, Decl(assignObjectToNonPrimitive.ts, 2, 3)) +>y : Symbol(y, Decl(assignObjectToNonPrimitive.ts, 1, 3)) + diff --git a/tests/baselines/reference/assignObjectToNonPrimitive.types b/tests/baselines/reference/assignObjectToNonPrimitive.types new file mode 100644 index 00000000000..f16c2287155 --- /dev/null +++ b/tests/baselines/reference/assignObjectToNonPrimitive.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/types/nonPrimitive/assignObjectToNonPrimitive.ts === +var x = {}; +>x : {} +>{} : {} + +var y = {foo: "bar"}; +>y : { foo: string; } +>{foo: "bar"} : { foo: string; } +>foo : string +>"bar" : "bar" + +var a: object; +>a : object + +a = x; +>a = x : {} +>a : object +>x : {} + +a = y; +>a = y : { foo: string; } +>a : object +>y : { foo: string; } + diff --git a/tests/baselines/reference/assigningFromObjectToAnythingElse.errors.txt b/tests/baselines/reference/assigningFromObjectToAnythingElse.errors.txt index 289883d7471..d3395c7ebc9 100644 --- a/tests/baselines/reference/assigningFromObjectToAnythingElse.errors.txt +++ b/tests/baselines/reference/assigningFromObjectToAnythingElse.errors.txt @@ -1,11 +1,8 @@ tests/cases/compiler/assigningFromObjectToAnythingElse.ts(3,1): error TS2322: Type 'Object' is not assignable to type 'RegExp'. The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? Property 'exec' is missing in type 'Object'. -tests/cases/compiler/assigningFromObjectToAnythingElse.ts(5,5): error TS2322: Type 'Object' is not assignable to type 'String'. - The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? - Property 'charAt' is missing in type 'Object'. -tests/cases/compiler/assigningFromObjectToAnythingElse.ts(6,5): error TS2322: Type 'Number' is not assignable to type 'String'. - Property 'charAt' is missing in type 'Number'. +tests/cases/compiler/assigningFromObjectToAnythingElse.ts(5,17): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/assigningFromObjectToAnythingElse.ts(6,17): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/assigningFromObjectToAnythingElse.ts(8,5): error TS2322: Type 'Object' is not assignable to type 'Error'. The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? Property 'name' is missing in type 'Object'. @@ -21,14 +18,11 @@ tests/cases/compiler/assigningFromObjectToAnythingElse.ts(8,5): error TS2322: Ty !!! error TS2322: Property 'exec' is missing in type 'Object'. var a: String = Object.create(""); - ~ -!!! error TS2322: Type 'Object' is not assignable to type 'String'. -!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? -!!! error TS2322: Property 'charAt' is missing in type 'Object'. + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var c: String = Object.create(1); - ~ -!!! error TS2322: Type 'Number' is not assignable to type 'String'. -!!! error TS2322: Property 'charAt' is missing in type 'Number'. + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. var w: Error = new Object(); ~ diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures3.js b/tests/baselines/reference/assignmentCompatWithCallSignatures3.js index c5a1f415437..58fd19326ee 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures3.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures3.js @@ -101,11 +101,16 @@ b18 = a18; // ok //// [assignmentCompatWithCallSignatures3.js] // these are all permitted with the current rules, since we do not do contextual signature instantiation -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -114,21 +119,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.js b/tests/baselines/reference/assignmentCompatWithCallSignatures4.js index 58faf663ea8..37030895006 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures4.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.js @@ -100,11 +100,16 @@ module Errors { //// [assignmentCompatWithCallSignatures4.js] // These are mostly permitted with the current loose rules. All ok unless otherwise noted. -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Errors; (function (Errors) { var Base = (function () { @@ -115,21 +120,21 @@ var Errors; var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures5.js b/tests/baselines/reference/assignmentCompatWithCallSignatures5.js index 87506cad08f..17ebf51308b 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures5.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures5.js @@ -67,11 +67,16 @@ b18 = a18; // ok //// [assignmentCompatWithCallSignatures5.js] // checking assignment compat for function types. No errors in this file -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -80,21 +85,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures6.js b/tests/baselines/reference/assignmentCompatWithCallSignatures6.js index 2c05d5960b2..905ef432786 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures6.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures6.js @@ -44,11 +44,16 @@ b16 = x.a16; //// [assignmentCompatWithCallSignatures6.js] // checking assignment compatibility relations for function types. All valid -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -57,21 +62,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js index 76ad53e4e05..25f267c19c8 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js @@ -101,11 +101,16 @@ b18 = a18; // ok //// [assignmentCompatWithConstructSignatures3.js] // checking assignment compatibility relations for function types. All of these are valid. -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -114,21 +119,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js index f516df153c6..879b24a3dde 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js @@ -100,11 +100,16 @@ module Errors { //// [assignmentCompatWithConstructSignatures4.js] // checking assignment compatibility relations for function types. -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Errors; (function (Errors) { var Base = (function () { @@ -115,21 +120,21 @@ var Errors; var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js index ef7de7f011b..b2d722c6791 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js @@ -67,11 +67,16 @@ b18 = a18; // ok //// [assignmentCompatWithConstructSignatures5.js] // checking assignment compat for function types. All valid -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -80,21 +85,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js index 3d58ae707a5..6c68a3edbfe 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js @@ -44,11 +44,16 @@ b16 = x.a16; //// [assignmentCompatWithConstructSignatures6.js] // checking assignment compatibility relations for function types. All valid. -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -57,21 +62,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer.js b/tests/baselines/reference/assignmentCompatWithNumericIndexer.js index 37160506683..e05538472fe 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer.js +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer.js @@ -45,11 +45,16 @@ module Generics { //// [assignmentCompatWithNumericIndexer.js] // Derived type indexer must be subtype of base type indexer -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -72,7 +77,7 @@ var Generics; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js index 2e6ecd72741..6ea115fde33 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js @@ -42,11 +42,16 @@ module Generics { //// [assignmentCompatWithNumericIndexer3.js] // Derived type indexer must be subtype of base type indexer -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -59,7 +64,7 @@ b = a; // ok var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembers4.js b/tests/baselines/reference/assignmentCompatWithObjectMembers4.js index 2cc2510c8da..bdd502ee027 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembers4.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembers4.js @@ -93,11 +93,16 @@ module WithBase { //// [assignmentCompatWithObjectMembers4.js] // members N and M of types S and T have the same name, same accessibility, same optionality, and N is not assignable M -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var OnlyDerived; (function (OnlyDerived) { var Base = (function () { @@ -108,14 +113,14 @@ var OnlyDerived; var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); @@ -167,14 +172,14 @@ var WithBase; var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js index 3b12701b3d9..b5274280b31 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js @@ -90,11 +90,16 @@ module SourceHasOptional { //// [assignmentCompatWithObjectMembersOptionality.js] // Derived member is not optional but base member is, should be ok -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -103,14 +108,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js index f965d18e2ce..e158a787878 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js @@ -92,11 +92,16 @@ module SourceHasOptional { //// [assignmentCompatWithObjectMembersOptionality2.js] // M is optional and S contains no property with the same name as M // N is optional and T contains no property with the same name as N -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -105,14 +110,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer.js b/tests/baselines/reference/assignmentCompatWithStringIndexer.js index 8d081c90794..8f3b23cfffb 100644 --- a/tests/baselines/reference/assignmentCompatWithStringIndexer.js +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer.js @@ -55,11 +55,16 @@ module Generics { //// [assignmentCompatWithStringIndexer.js] // index signatures must be compatible in assignments -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -82,7 +87,7 @@ var Generics; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -93,7 +98,7 @@ var Generics; var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); diff --git a/tests/baselines/reference/assignmentLHSIsValue.js b/tests/baselines/reference/assignmentLHSIsValue.js index 155fa26fa81..34e0df7cacd 100644 --- a/tests/baselines/reference/assignmentLHSIsValue.js +++ b/tests/baselines/reference/assignmentLHSIsValue.js @@ -71,11 +71,16 @@ foo() = value; (foo()) = value; //// [assignmentLHSIsValue.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // expected error for all the LHS of assignments var value; // this diff --git a/tests/baselines/reference/assignmentNestedInLiterals.js b/tests/baselines/reference/assignmentNestedInLiterals.js new file mode 100644 index 00000000000..8a048082565 --- /dev/null +++ b/tests/baselines/reference/assignmentNestedInLiterals.js @@ -0,0 +1,21 @@ +//// [assignmentNestedInLiterals.ts] +var target, x, y; +target = [x = 1, y = x]; + +var aegis, a, b; +aegis = { x: a = 1, y: b = a }; + +var kowloona, c, d; +for (kowloona of [c = 1, d = c]) { +} + + +//// [assignmentNestedInLiterals.js] +var target, x, y; +target = [x = 1, y = x]; +var aegis, a, b; +aegis = { x: a = 1, y: b = a }; +var kowloona, c, d; +for (var _i = 0, _a = [c = 1, d = c]; _i < _a.length; _i++) { + kowloona = _a[_i]; +} diff --git a/tests/baselines/reference/assignmentNestedInLiterals.symbols b/tests/baselines/reference/assignmentNestedInLiterals.symbols new file mode 100644 index 00000000000..761930ab9ce --- /dev/null +++ b/tests/baselines/reference/assignmentNestedInLiterals.symbols @@ -0,0 +1,37 @@ +=== tests/cases/compiler/assignmentNestedInLiterals.ts === +var target, x, y; +>target : Symbol(target, Decl(assignmentNestedInLiterals.ts, 0, 3)) +>x : Symbol(x, Decl(assignmentNestedInLiterals.ts, 0, 11)) +>y : Symbol(y, Decl(assignmentNestedInLiterals.ts, 0, 14)) + +target = [x = 1, y = x]; +>target : Symbol(target, Decl(assignmentNestedInLiterals.ts, 0, 3)) +>x : Symbol(x, Decl(assignmentNestedInLiterals.ts, 0, 11)) +>y : Symbol(y, Decl(assignmentNestedInLiterals.ts, 0, 14)) +>x : Symbol(x, Decl(assignmentNestedInLiterals.ts, 0, 11)) + +var aegis, a, b; +>aegis : Symbol(aegis, Decl(assignmentNestedInLiterals.ts, 3, 3)) +>a : Symbol(a, Decl(assignmentNestedInLiterals.ts, 3, 10)) +>b : Symbol(b, Decl(assignmentNestedInLiterals.ts, 3, 13)) + +aegis = { x: a = 1, y: b = a }; +>aegis : Symbol(aegis, Decl(assignmentNestedInLiterals.ts, 3, 3)) +>x : Symbol(x, Decl(assignmentNestedInLiterals.ts, 4, 9)) +>a : Symbol(a, Decl(assignmentNestedInLiterals.ts, 3, 10)) +>y : Symbol(y, Decl(assignmentNestedInLiterals.ts, 4, 19)) +>b : Symbol(b, Decl(assignmentNestedInLiterals.ts, 3, 13)) +>a : Symbol(a, Decl(assignmentNestedInLiterals.ts, 3, 10)) + +var kowloona, c, d; +>kowloona : Symbol(kowloona, Decl(assignmentNestedInLiterals.ts, 6, 3)) +>c : Symbol(c, Decl(assignmentNestedInLiterals.ts, 6, 13)) +>d : Symbol(d, Decl(assignmentNestedInLiterals.ts, 6, 16)) + +for (kowloona of [c = 1, d = c]) { +>kowloona : Symbol(kowloona, Decl(assignmentNestedInLiterals.ts, 6, 3)) +>c : Symbol(c, Decl(assignmentNestedInLiterals.ts, 6, 13)) +>d : Symbol(d, Decl(assignmentNestedInLiterals.ts, 6, 16)) +>c : Symbol(c, Decl(assignmentNestedInLiterals.ts, 6, 13)) +} + diff --git a/tests/baselines/reference/assignmentNestedInLiterals.types b/tests/baselines/reference/assignmentNestedInLiterals.types new file mode 100644 index 00000000000..8ab73f80691 --- /dev/null +++ b/tests/baselines/reference/assignmentNestedInLiterals.types @@ -0,0 +1,51 @@ +=== tests/cases/compiler/assignmentNestedInLiterals.ts === +var target, x, y; +>target : any +>x : any +>y : any + +target = [x = 1, y = x]; +>target = [x = 1, y = x] : number[] +>target : any +>[x = 1, y = x] : number[] +>x = 1 : 1 +>x : any +>1 : 1 +>y = x : number +>y : any +>x : number + +var aegis, a, b; +>aegis : any +>a : any +>b : any + +aegis = { x: a = 1, y: b = a }; +>aegis = { x: a = 1, y: b = a } : { x: number; y: number; } +>aegis : any +>{ x: a = 1, y: b = a } : { x: number; y: number; } +>x : number +>a = 1 : 1 +>a : any +>1 : 1 +>y : number +>b = a : number +>b : any +>a : number + +var kowloona, c, d; +>kowloona : any +>c : any +>d : any + +for (kowloona of [c = 1, d = c]) { +>kowloona : any +>[c = 1, d = c] : number[] +>c = 1 : 1 +>c : any +>1 : 1 +>d = c : number +>d : any +>c : number +} + diff --git a/tests/baselines/reference/asyncAliasReturnType_es6.symbols b/tests/baselines/reference/asyncAliasReturnType_es6.symbols index 61de47e4092..fccb2e5c737 100644 --- a/tests/baselines/reference/asyncAliasReturnType_es6.symbols +++ b/tests/baselines/reference/asyncAliasReturnType_es6.symbols @@ -2,7 +2,7 @@ type PromiseAlias = Promise; >PromiseAlias : Symbol(PromiseAlias, Decl(asyncAliasReturnType_es6.ts, 0, 0)) >T : Symbol(T, Decl(asyncAliasReturnType_es6.ts, 0, 18)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >T : Symbol(T, Decl(asyncAliasReturnType_es6.ts, 0, 18)) async function f(): PromiseAlias { diff --git a/tests/baselines/reference/asyncArrowFunction1_es2017.symbols b/tests/baselines/reference/asyncArrowFunction1_es2017.symbols index 35fd033d6b4..239a057aa88 100644 --- a/tests/baselines/reference/asyncArrowFunction1_es2017.symbols +++ b/tests/baselines/reference/asyncArrowFunction1_es2017.symbols @@ -2,6 +2,6 @@ var foo = async (): Promise => { >foo : Symbol(foo, Decl(asyncArrowFunction1_es2017.ts, 1, 3)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) }; diff --git a/tests/baselines/reference/asyncArrowFunction1_es5.symbols b/tests/baselines/reference/asyncArrowFunction1_es5.symbols index c37985dc347..9f09c3ac9ad 100644 --- a/tests/baselines/reference/asyncArrowFunction1_es5.symbols +++ b/tests/baselines/reference/asyncArrowFunction1_es5.symbols @@ -2,6 +2,6 @@ var foo = async (): Promise => { >foo : Symbol(foo, Decl(asyncArrowFunction1_es5.ts, 1, 3)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) }; diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.symbols b/tests/baselines/reference/asyncArrowFunction1_es6.symbols index a2f62f82990..bc3557865ee 100644 --- a/tests/baselines/reference/asyncArrowFunction1_es6.symbols +++ b/tests/baselines/reference/asyncArrowFunction1_es6.symbols @@ -2,6 +2,6 @@ var foo = async (): Promise => { >foo : Symbol(foo, Decl(asyncArrowFunction1_es6.ts, 1, 3)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) }; diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es5.js b/tests/baselines/reference/asyncAwaitIsolatedModules_es5.js index 49404267009..335bd8a340e 100644 --- a/tests/baselines/reference/asyncAwaitIsolatedModules_es5.js +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es5.js @@ -50,8 +50,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t; - return { next: verb(0), "throw": verb(1), "return": verb(2) }; + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); @@ -77,6 +77,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var _this = this; +Object.defineProperty(exports, "__esModule", { value: true }); var missing_1 = require("missing"); function f0() { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { diff --git a/tests/baselines/reference/asyncAwaitWithCapturedBlockScopeVar.js b/tests/baselines/reference/asyncAwaitWithCapturedBlockScopeVar.js index 6d167a00089..edceab4cf96 100644 --- a/tests/baselines/reference/asyncAwaitWithCapturedBlockScopeVar.js +++ b/tests/baselines/reference/asyncAwaitWithCapturedBlockScopeVar.js @@ -58,7 +58,7 @@ function fn1() { _a.label = 1; case 1: if (!(i < 1)) return [3 /*break*/, 4]; - return [5 /*yield**/, _loop_1(i)]; + return [5 /*yield**/, __values(_loop_1(i))]; case 2: _a.sent(); _a.label = 3; @@ -92,7 +92,7 @@ function fn2() { _a.label = 1; case 1: if (!(i < 1)) return [3 /*break*/, 4]; - return [5 /*yield**/, _loop_2(i)]; + return [5 /*yield**/, __values(_loop_2(i))]; case 2: state_1 = _a.sent(); if (state_1 === "break") @@ -128,7 +128,7 @@ function fn3() { _a.label = 1; case 1: if (!(i < 1)) return [3 /*break*/, 4]; - return [5 /*yield**/, _loop_3(i)]; + return [5 /*yield**/, __values(_loop_3(i))]; case 2: _a.sent(); _a.label = 3; @@ -162,7 +162,7 @@ function fn4() { _a.label = 1; case 1: if (!(i < 1)) return [3 /*break*/, 4]; - return [5 /*yield**/, _loop_4(i)]; + return [5 /*yield**/, __values(_loop_4(i))]; case 2: state_2 = _a.sent(); if (typeof state_2 === "object") diff --git a/tests/baselines/reference/asyncAwaitWithCapturedBlockScopeVar.symbols b/tests/baselines/reference/asyncAwaitWithCapturedBlockScopeVar.symbols index 12a60509f4f..acd490f5266 100644 --- a/tests/baselines/reference/asyncAwaitWithCapturedBlockScopeVar.symbols +++ b/tests/baselines/reference/asyncAwaitWithCapturedBlockScopeVar.symbols @@ -65,7 +65,7 @@ async function fn3() { async function fn4(): Promise { >fn4 : Symbol(fn4, Decl(asyncAwaitWithCapturedBlockScopeVar.ts, 24, 1)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) let ar = []; >ar : Symbol(ar, Decl(asyncAwaitWithCapturedBlockScopeVar.ts, 27, 7)) diff --git a/tests/baselines/reference/asyncAwait_es2017.symbols b/tests/baselines/reference/asyncAwait_es2017.symbols index 34dc9802a25..a456a224295 100644 --- a/tests/baselines/reference/asyncAwait_es2017.symbols +++ b/tests/baselines/reference/asyncAwait_es2017.symbols @@ -2,16 +2,16 @@ type MyPromise = Promise; >MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) >T : Symbol(T, Decl(asyncAwait_es2017.ts, 0, 15)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >T : Symbol(T, Decl(asyncAwait_es2017.ts, 0, 15)) declare var MyPromise: typeof Promise; >MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare var p: Promise; >p : Symbol(p, Decl(asyncAwait_es2017.ts, 2, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare var mp: MyPromise; >mp : Symbol(mp, Decl(asyncAwait_es2017.ts, 3, 11)) @@ -22,7 +22,7 @@ async function f0() { } async function f1(): Promise { } >f1 : Symbol(f1, Decl(asyncAwait_es2017.ts, 5, 23)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) async function f3(): MyPromise { } >f3 : Symbol(f3, Decl(asyncAwait_es2017.ts, 6, 38)) @@ -33,7 +33,7 @@ let f4 = async function() { } let f5 = async function(): Promise { } >f5 : Symbol(f5, Decl(asyncAwait_es2017.ts, 10, 3)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) let f6 = async function(): MyPromise { } >f6 : Symbol(f6, Decl(asyncAwait_es2017.ts, 11, 3)) @@ -44,7 +44,7 @@ let f7 = async () => { }; let f8 = async (): Promise => { }; >f8 : Symbol(f8, Decl(asyncAwait_es2017.ts, 14, 3)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) let f9 = async (): MyPromise => { }; >f9 : Symbol(f9, Decl(asyncAwait_es2017.ts, 15, 3)) @@ -60,7 +60,7 @@ let f11 = async () => mp; let f12 = async (): Promise => mp; >f12 : Symbol(f12, Decl(asyncAwait_es2017.ts, 18, 3)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >mp : Symbol(mp, Decl(asyncAwait_es2017.ts, 3, 11)) let f13 = async (): MyPromise => p; @@ -76,7 +76,7 @@ let o = { async m2(): Promise { }, >m2 : Symbol(m2, Decl(asyncAwait_es2017.ts, 22, 16)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) async m3(): MyPromise { } >m3 : Symbol(m3, Decl(asyncAwait_es2017.ts, 23, 31)) @@ -92,7 +92,7 @@ class C { async m2(): Promise { } >m2 : Symbol(C.m2, Decl(asyncAwait_es2017.ts, 28, 15)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) async m3(): MyPromise { } >m3 : Symbol(C.m3, Decl(asyncAwait_es2017.ts, 29, 30)) @@ -103,7 +103,7 @@ class C { static async m5(): Promise { } >m5 : Symbol(C.m5, Decl(asyncAwait_es2017.ts, 31, 22)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) static async m6(): MyPromise { } >m6 : Symbol(C.m6, Decl(asyncAwait_es2017.ts, 32, 37)) diff --git a/tests/baselines/reference/asyncAwait_es5.js b/tests/baselines/reference/asyncAwait_es5.js index e4dc62ea1cf..f49f4472b13 100644 --- a/tests/baselines/reference/asyncAwait_es5.js +++ b/tests/baselines/reference/asyncAwait_es5.js @@ -49,8 +49,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t; - return { next: verb(0), "throw": verb(1), "return": verb(2) }; + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); diff --git a/tests/baselines/reference/asyncAwait_es5.symbols b/tests/baselines/reference/asyncAwait_es5.symbols index 2f80a025ade..cdc52137ff4 100644 --- a/tests/baselines/reference/asyncAwait_es5.symbols +++ b/tests/baselines/reference/asyncAwait_es5.symbols @@ -2,16 +2,16 @@ type MyPromise = Promise; >MyPromise : Symbol(MyPromise, Decl(asyncAwait_es5.ts, 0, 0), Decl(asyncAwait_es5.ts, 1, 11)) >T : Symbol(T, Decl(asyncAwait_es5.ts, 0, 15)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >T : Symbol(T, Decl(asyncAwait_es5.ts, 0, 15)) declare var MyPromise: typeof Promise; >MyPromise : Symbol(MyPromise, Decl(asyncAwait_es5.ts, 0, 0), Decl(asyncAwait_es5.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare var p: Promise; >p : Symbol(p, Decl(asyncAwait_es5.ts, 2, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare var mp: MyPromise; >mp : Symbol(mp, Decl(asyncAwait_es5.ts, 3, 11)) @@ -22,7 +22,7 @@ async function f0() { } async function f1(): Promise { } >f1 : Symbol(f1, Decl(asyncAwait_es5.ts, 5, 23)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) async function f3(): MyPromise { } >f3 : Symbol(f3, Decl(asyncAwait_es5.ts, 6, 38)) @@ -33,7 +33,7 @@ let f4 = async function() { } let f5 = async function(): Promise { } >f5 : Symbol(f5, Decl(asyncAwait_es5.ts, 10, 3)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) let f6 = async function(): MyPromise { } >f6 : Symbol(f6, Decl(asyncAwait_es5.ts, 11, 3)) @@ -44,7 +44,7 @@ let f7 = async () => { }; let f8 = async (): Promise => { }; >f8 : Symbol(f8, Decl(asyncAwait_es5.ts, 14, 3)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) let f9 = async (): MyPromise => { }; >f9 : Symbol(f9, Decl(asyncAwait_es5.ts, 15, 3)) @@ -60,7 +60,7 @@ let f11 = async () => mp; let f12 = async (): Promise => mp; >f12 : Symbol(f12, Decl(asyncAwait_es5.ts, 18, 3)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >mp : Symbol(mp, Decl(asyncAwait_es5.ts, 3, 11)) let f13 = async (): MyPromise => p; @@ -76,7 +76,7 @@ let o = { async m2(): Promise { }, >m2 : Symbol(m2, Decl(asyncAwait_es5.ts, 22, 16)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) async m3(): MyPromise { } >m3 : Symbol(m3, Decl(asyncAwait_es5.ts, 23, 31)) @@ -92,7 +92,7 @@ class C { async m2(): Promise { } >m2 : Symbol(C.m2, Decl(asyncAwait_es5.ts, 28, 15)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) async m3(): MyPromise { } >m3 : Symbol(C.m3, Decl(asyncAwait_es5.ts, 29, 30)) @@ -103,7 +103,7 @@ class C { static async m5(): Promise { } >m5 : Symbol(C.m5, Decl(asyncAwait_es5.ts, 31, 22)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) static async m6(): MyPromise { } >m6 : Symbol(C.m6, Decl(asyncAwait_es5.ts, 32, 37)) diff --git a/tests/baselines/reference/asyncAwait_es6.symbols b/tests/baselines/reference/asyncAwait_es6.symbols index 26295e72f78..25032b1a943 100644 --- a/tests/baselines/reference/asyncAwait_es6.symbols +++ b/tests/baselines/reference/asyncAwait_es6.symbols @@ -2,16 +2,16 @@ type MyPromise = Promise; >MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) >T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15)) declare var MyPromise: typeof Promise; >MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare var p: Promise; >p : Symbol(p, Decl(asyncAwait_es6.ts, 2, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare var mp: MyPromise; >mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) @@ -22,7 +22,7 @@ async function f0() { } async function f1(): Promise { } >f1 : Symbol(f1, Decl(asyncAwait_es6.ts, 5, 23)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) async function f3(): MyPromise { } >f3 : Symbol(f3, Decl(asyncAwait_es6.ts, 6, 38)) @@ -33,7 +33,7 @@ let f4 = async function() { } let f5 = async function(): Promise { } >f5 : Symbol(f5, Decl(asyncAwait_es6.ts, 10, 3)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) let f6 = async function(): MyPromise { } >f6 : Symbol(f6, Decl(asyncAwait_es6.ts, 11, 3)) @@ -44,7 +44,7 @@ let f7 = async () => { }; let f8 = async (): Promise => { }; >f8 : Symbol(f8, Decl(asyncAwait_es6.ts, 14, 3)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) let f9 = async (): MyPromise => { }; >f9 : Symbol(f9, Decl(asyncAwait_es6.ts, 15, 3)) @@ -60,7 +60,7 @@ let f11 = async () => mp; let f12 = async (): Promise => mp; >f12 : Symbol(f12, Decl(asyncAwait_es6.ts, 18, 3)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) let f13 = async (): MyPromise => p; @@ -76,7 +76,7 @@ let o = { async m2(): Promise { }, >m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 22, 16)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) async m3(): MyPromise { } >m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 23, 31)) @@ -92,7 +92,7 @@ class C { async m2(): Promise { } >m2 : Symbol(C.m2, Decl(asyncAwait_es6.ts, 28, 15)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) async m3(): MyPromise { } >m3 : Symbol(C.m3, Decl(asyncAwait_es6.ts, 29, 30)) @@ -103,7 +103,7 @@ class C { static async m5(): Promise { } >m5 : Symbol(C.m5, Decl(asyncAwait_es6.ts, 31, 22)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) static async m6(): MyPromise { } >m6 : Symbol(C.m6, Decl(asyncAwait_es6.ts, 32, 37)) diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt index d5da3432264..33cd913a2eb 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt @@ -4,10 +4,11 @@ tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclarati tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,33): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,38): error TS1005: ';' expected. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,39): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,49): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,53): error TS1109: Expression expected. -==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts (7 errors) ==== +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts (8 errors) ==== async function foo(a = await => await): Promise { ~~~~~~~~~ !!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. @@ -21,6 +22,8 @@ tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclarati !!! error TS1005: ';' expected. ~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es5.errors.txt index dc814e9c887..b974eacd882 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es5.errors.txt @@ -4,10 +4,11 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1 tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,33): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,38): error TS1005: ';' expected. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,39): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,49): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,53): error TS1109: Expression expected. -==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts (7 errors) ==== +==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts (8 errors) ==== async function foo(a = await => await): Promise { ~~~~~~~~~ !!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. @@ -21,6 +22,8 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1 !!! error TS1005: ';' expected. ~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt index 15ceb3e60c7..b752ec94a45 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt @@ -4,10 +4,11 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,38): error TS1005: ';' expected. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,39): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,49): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,53): error TS1109: Expression expected. -==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts (7 errors) ==== +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts (8 errors) ==== async function foo(a = await => await): Promise { ~~~~~~~~~ !!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. @@ -21,6 +22,8 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1 !!! error TS1005: ';' expected. ~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration11_es2017.symbols index 02c35d81d62..d9ae9715c2e 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration11_es2017.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es2017.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration11_es2017.ts === async function await(): Promise { >await : Symbol(await, Decl(asyncFunctionDeclaration11_es2017.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es5.symbols b/tests/baselines/reference/asyncFunctionDeclaration11_es5.symbols index fc20251d567..f0a8bbd4903 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration11_es5.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es5.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration11_es5.ts === async function await(): Promise { >await : Symbol(await, Decl(asyncFunctionDeclaration11_es5.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols index c9288f42763..4f1aea28635 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts === async function await(): Promise { >await : Symbol(await, Decl(asyncFunctionDeclaration11_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es5.js b/tests/baselines/reference/asyncFunctionDeclaration12_es5.js index 4123175b22c..21651a42796 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es5.js +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es5.js @@ -2,4 +2,8 @@ var v = async function await(): Promise { } //// [asyncFunctionDeclaration12_es5.js] -var v = , await = function () { }; +var v = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); +}, await = function () { }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.js b/tests/baselines/reference/asyncFunctionDeclaration12_es6.js index dae33682ce6..9943c3896b6 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.js @@ -2,4 +2,6 @@ var v = async function await(): Promise { } //// [asyncFunctionDeclaration12_es6.js] -var v = , await = () => { }; +var v = function () { + return __awaiter(this, void 0, void 0, function* () { }); +}, await = () => { }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration14_es2017.symbols index 1b5bca844c0..0c410ece27d 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration14_es2017.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es2017.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration14_es2017.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration14_es2017.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) return; } diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es5.symbols b/tests/baselines/reference/asyncFunctionDeclaration14_es5.symbols index 1126618cfe7..2458c22324a 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration14_es5.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es5.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration14_es5.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration14_es5.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) return; } diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols index d036632ff86..2aa5c7e0b23 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration14_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) return; } diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration15_es5.errors.txt index 5fa33233912..f8029687fb1 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration15_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration15_es5.errors.txt @@ -6,10 +6,10 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1 tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(10,23): error TS1055: Type 'typeof Thenable' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. Type 'Thenable' is not assignable to type 'PromiseLike'. Types of property 'then' are incompatible. - Type '() => void' is not assignable to type '{ (onfulfilled?: (value: any) => any, onrejected?: (reason: any) => any): PromiseLike; (onfulfilled: (value: any) => any, onrejected: (reason: any) => TResult | PromiseLike): PromiseLike; (onfulfilled: (value: any) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; (onfulfilled: (value: any) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): PromiseLike; }'. + Type '() => void' is not assignable to type '(onfulfilled?: (value: any) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. Type 'void' is not assignable to type 'PromiseLike'. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(17,16): error TS1059: Return expression in async function does not have a valid callable 'then' member. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(23,25): error TS1058: Operand for 'await' does not have a valid callable 'then' member. +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(17,16): error TS1058: Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member. +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(23,25): error TS1058: Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member. ==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts (8 errors) ==== @@ -37,7 +37,7 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1 !!! error TS1055: Type 'typeof Thenable' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. !!! error TS1055: Type 'Thenable' is not assignable to type 'PromiseLike'. !!! error TS1055: Types of property 'then' are incompatible. -!!! error TS1055: Type '() => void' is not assignable to type '{ (onfulfilled?: (value: any) => any, onrejected?: (reason: any) => any): PromiseLike; (onfulfilled: (value: any) => any, onrejected: (reason: any) => TResult | PromiseLike): PromiseLike; (onfulfilled: (value: any) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; (onfulfilled: (value: any) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): PromiseLike; }'. +!!! error TS1055: Type '() => void' is not assignable to type '(onfulfilled?: (value: any) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. !!! error TS1055: Type 'void' is not assignable to type 'PromiseLike'. async function fn7() { return; } // valid: Promise async function fn8() { return 1; } // valid: Promise @@ -47,7 +47,7 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1 async function fn12() { return obj; } // valid: Promise<{ then: string; }> async function fn13() { return thenable; } // error ~~~~ -!!! error TS1059: Return expression in async function does not have a valid callable 'then' member. +!!! error TS1058: Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member. async function fn14() { await 1; } // valid: Promise async function fn15() { await null; } // valid: Promise async function fn16() { await undefined; } // valid: Promise @@ -55,5 +55,5 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1 async function fn18() { await obj; } // valid: Promise async function fn19() { await thenable; } // error ~~~~~~~~~~~~~~ -!!! error TS1058: Operand for 'await' does not have a valid callable 'then' member. +!!! error TS1058: Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member. \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration15_es6.errors.txt index e8d3e7d79b1..60f57f3dfbf 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration15_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration15_es6.errors.txt @@ -3,8 +3,8 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(8,23): error TS1064: The return type of an async function or method must be the global Promise type. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(9,23): error TS1064: The return type of an async function or method must be the global Promise type. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(10,23): error TS1064: The return type of an async function or method must be the global Promise type. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(17,16): error TS1059: Return expression in async function does not have a valid callable 'then' member. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(23,25): error TS1058: Operand for 'await' does not have a valid callable 'then' member. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(17,16): error TS1058: Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(23,25): error TS1058: Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member. ==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts (7 errors) ==== @@ -36,7 +36,7 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1 async function fn12() { return obj; } // valid: Promise<{ then: string; }> async function fn13() { return thenable; } // error ~~~~ -!!! error TS1059: Return expression in async function does not have a valid callable 'then' member. +!!! error TS1058: Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member. async function fn14() { await 1; } // valid: Promise async function fn15() { await null; } // valid: Promise async function fn16() { await undefined; } // valid: Promise @@ -44,5 +44,5 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1 async function fn18() { await obj; } // valid: Promise async function fn19() { await thenable; } // error ~~~~~~~~~~~~~~ -!!! error TS1058: Operand for 'await' does not have a valid callable 'then' member. +!!! error TS1058: Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member. \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration1_es2017.symbols index a712df45896..32b86eb69c7 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration1_es2017.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es2017.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration1_es2017.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration1_es2017.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es5.symbols b/tests/baselines/reference/asyncFunctionDeclaration1_es5.symbols index ba7616ac293..610af242e03 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration1_es5.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es5.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1_es5.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration1_es5.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols index 019d2db4f07..fc645fa038e 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration1_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt index ad8c0280206..1fc74dfa0a2 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt @@ -2,10 +2,11 @@ tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclarati tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,20): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,25): error TS1005: ';' expected. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,26): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,36): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,40): error TS1109: Expression expected. -==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts (5 errors) ==== +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts (6 errors) ==== async function foo(await): Promise { ~~~~~ !!! error TS1138: Parameter declaration expected. @@ -15,6 +16,8 @@ tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclarati !!! error TS1005: ';' expected. ~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration5_es5.errors.txt index 3060c2c836b..48299773218 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es5.errors.txt @@ -2,10 +2,11 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5 tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,20): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,25): error TS1005: ';' expected. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,26): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,36): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts(1,40): error TS1109: Expression expected. -==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts (5 errors) ==== +==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts (6 errors) ==== async function foo(await): Promise { ~~~~~ !!! error TS1138: Parameter declaration expected. @@ -15,6 +16,8 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5 !!! error TS1005: ';' expected. ~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt index a6944e0c6e6..2e907d13400 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es6.errors.txt @@ -2,10 +2,11 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5 tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,20): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,25): error TS1005: ';' expected. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,26): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,36): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts(1,40): error TS1109: Expression expected. -==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts (5 errors) ==== +==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts (6 errors) ==== async function foo(await): Promise { ~~~~~ !!! error TS1138: Parameter declaration expected. @@ -15,6 +16,8 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5 !!! error TS1005: ';' expected. ~ !!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionNoReturnType.errors.txt b/tests/baselines/reference/asyncFunctionNoReturnType.errors.txt index 89a61ff648f..5d4a87a186c 100644 --- a/tests/baselines/reference/asyncFunctionNoReturnType.errors.txt +++ b/tests/baselines/reference/asyncFunctionNoReturnType.errors.txt @@ -1,22 +1,16 @@ -error TS2318: Cannot find global type 'Promise'. -tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS2697: An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option. -tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS7030: Not all code paths return a value. +error TS2468: Cannot find global value 'Promise'. +tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option. tests/cases/compiler/asyncFunctionNoReturnType.ts(2,9): error TS2304: Cannot find name 'window'. -tests/cases/compiler/asyncFunctionNoReturnType.ts(3,9): error TS7030: Not all code paths return a value. -!!! error TS2318: Cannot find global type 'Promise'. -==== tests/cases/compiler/asyncFunctionNoReturnType.ts (4 errors) ==== +!!! error TS2468: Cannot find global value 'Promise'. +==== tests/cases/compiler/asyncFunctionNoReturnType.ts (2 errors) ==== async () => { ~~~~~~~~~~~~~ -!!! error TS2697: An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option. - ~~~~~~~~~~~~~ -!!! error TS7030: Not all code paths return a value. +!!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option. if (window) ~~~~~~ !!! error TS2304: Cannot find name 'window'. return; - ~~~~~~~ -!!! error TS7030: Not all code paths return a value. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionNoReturnType.js b/tests/baselines/reference/asyncFunctionNoReturnType.js index b1c55416566..6f4a3795118 100644 --- a/tests/baselines/reference/asyncFunctionNoReturnType.js +++ b/tests/baselines/reference/asyncFunctionNoReturnType.js @@ -15,8 +15,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t; - return { next: verb(0), "throw": verb(1), "return": verb(2) }; + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); diff --git a/tests/baselines/reference/asyncFunctionReturnType.symbols b/tests/baselines/reference/asyncFunctionReturnType.symbols index d5aa71c9e51..7939fe7e83c 100644 --- a/tests/baselines/reference/asyncFunctionReturnType.symbols +++ b/tests/baselines/reference/asyncFunctionReturnType.symbols @@ -8,7 +8,7 @@ async function fAsync() { async function fAsyncExplicit(): Promise<[number, boolean]> { >fAsyncExplicit : Symbol(fAsyncExplicit, Decl(asyncFunctionReturnType.ts, 3, 1)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) // This is contextually typed as a tuple. return [1, true]; @@ -29,7 +29,7 @@ async function fIndexedTypeForStringProp(obj: Obj): Promise { >fIndexedTypeForStringProp : Symbol(fIndexedTypeForStringProp, Decl(asyncFunctionReturnType.ts, 14, 1)) >obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 16, 41)) >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) return obj.stringProp; @@ -42,12 +42,12 @@ async function fIndexedTypeForPromiseOfStringProp(obj: Obj): PromisefIndexedTypeForPromiseOfStringProp : Symbol(fIndexedTypeForPromiseOfStringProp, Decl(asyncFunctionReturnType.ts, 18, 1)) >obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 20, 50)) >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) return Promise.resolve(obj.stringProp); >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >obj.stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15)) >obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 20, 50)) @@ -58,12 +58,12 @@ async function fIndexedTypeForExplicitPromiseOfStringProp(obj: Obj): PromisefIndexedTypeForExplicitPromiseOfStringProp : Symbol(fIndexedTypeForExplicitPromiseOfStringProp, Decl(asyncFunctionReturnType.ts, 22, 1)) >obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 24, 58)) >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) return Promise.resolve(obj.stringProp); >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) >obj.stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15)) @@ -75,7 +75,7 @@ async function fIndexedTypeForAnyProp(obj: Obj): Promise { >fIndexedTypeForAnyProp : Symbol(fIndexedTypeForAnyProp, Decl(asyncFunctionReturnType.ts, 26, 1)) >obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 28, 38)) >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) return obj.anyProp; @@ -88,12 +88,12 @@ async function fIndexedTypeForPromiseOfAnyProp(obj: Obj): PromisefIndexedTypeForPromiseOfAnyProp : Symbol(fIndexedTypeForPromiseOfAnyProp, Decl(asyncFunctionReturnType.ts, 30, 1)) >obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 32, 47)) >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) return Promise.resolve(obj.anyProp); >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >obj.anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23)) >obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 32, 47)) @@ -104,12 +104,12 @@ async function fIndexedTypeForExplicitPromiseOfAnyProp(obj: Obj): PromisefIndexedTypeForExplicitPromiseOfAnyProp : Symbol(fIndexedTypeForExplicitPromiseOfAnyProp, Decl(asyncFunctionReturnType.ts, 34, 1)) >obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 36, 55)) >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) return Promise.resolve(obj.anyProp); >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) >obj.anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23)) @@ -123,7 +123,7 @@ async function fGenericIndexedTypeForStringProp(obj: TObj): Pr >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) >obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 40, 66)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 40, 48)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 40, 48)) return obj.stringProp; @@ -138,12 +138,12 @@ async function fGenericIndexedTypeForPromiseOfStringProp(obj: >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) >obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 44, 75)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 44, 57)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 44, 57)) return Promise.resolve(obj.stringProp); >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >obj.stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15)) >obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 44, 75)) @@ -156,12 +156,12 @@ async function fGenericIndexedTypeForExplicitPromiseOfStringPropObj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) >obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 48, 83)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 48, 65)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 48, 65)) return Promise.resolve(obj.stringProp); >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 48, 65)) >obj.stringProp : Symbol(Obj.stringProp, Decl(asyncFunctionReturnType.ts, 11, 15)) @@ -175,7 +175,7 @@ async function fGenericIndexedTypeForAnyProp(obj: TObj): Promi >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) >obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 52, 63)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 52, 45)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 52, 45)) return obj.anyProp; @@ -190,12 +190,12 @@ async function fGenericIndexedTypeForPromiseOfAnyProp(obj: TOb >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) >obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 56, 72)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 56, 54)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 56, 54)) return Promise.resolve(obj.anyProp); >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >obj.anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23)) >obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 56, 72)) @@ -208,12 +208,12 @@ async function fGenericIndexedTypeForExplicitPromiseOfAnyProp( >Obj : Symbol(Obj, Decl(asyncFunctionReturnType.ts, 8, 1)) >obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 60, 80)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 60, 62)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 60, 62)) return Promise.resolve(obj.anyProp); >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 60, 62)) >obj.anyProp : Symbol(Obj.anyProp, Decl(asyncFunctionReturnType.ts, 12, 23)) @@ -231,7 +231,7 @@ async function fGenericIndexedTypeForKPropTObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 64, 43)) >key : Symbol(key, Decl(asyncFunctionReturnType.ts, 64, 93)) >K : Symbol(K, Decl(asyncFunctionReturnType.ts, 64, 60)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 64, 43)) >K : Symbol(K, Decl(asyncFunctionReturnType.ts, 64, 60)) @@ -250,13 +250,13 @@ async function fGenericIndexedTypeForPromiseOfKPropTObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 68, 52)) >key : Symbol(key, Decl(asyncFunctionReturnType.ts, 68, 102)) >K : Symbol(K, Decl(asyncFunctionReturnType.ts, 68, 69)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 68, 52)) >K : Symbol(K, Decl(asyncFunctionReturnType.ts, 68, 69)) return Promise.resolve(obj[key]); >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >obj : Symbol(obj, Decl(asyncFunctionReturnType.ts, 68, 92)) >key : Symbol(key, Decl(asyncFunctionReturnType.ts, 68, 102)) @@ -272,13 +272,13 @@ async function fGenericIndexedTypeForExplicitPromiseOfKPropTObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 72, 60)) >key : Symbol(key, Decl(asyncFunctionReturnType.ts, 72, 110)) >K : Symbol(K, Decl(asyncFunctionReturnType.ts, 72, 77)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 72, 60)) >K : Symbol(K, Decl(asyncFunctionReturnType.ts, 72, 77)) return Promise.resolve(obj[key]); >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >TObj : Symbol(TObj, Decl(asyncFunctionReturnType.ts, 72, 60)) >K : Symbol(K, Decl(asyncFunctionReturnType.ts, 72, 77)) diff --git a/tests/baselines/reference/asyncFunctionsAndStrictNullChecks.symbols b/tests/baselines/reference/asyncFunctionsAndStrictNullChecks.symbols index 2d10183133d..116406f7652 100644 --- a/tests/baselines/reference/asyncFunctionsAndStrictNullChecks.symbols +++ b/tests/baselines/reference/asyncFunctionsAndStrictNullChecks.symbols @@ -106,7 +106,7 @@ declare function resolve1(value: T): Promise; >T : Symbol(T, Decl(asyncFunctionsAndStrictNullChecks.ts, 18, 26)) >value : Symbol(value, Decl(asyncFunctionsAndStrictNullChecks.ts, 18, 29)) >T : Symbol(T, Decl(asyncFunctionsAndStrictNullChecks.ts, 18, 26)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >T : Symbol(T, Decl(asyncFunctionsAndStrictNullChecks.ts, 18, 26)) declare function resolve2(value: T): Windows.Foundation.IPromise; diff --git a/tests/baselines/reference/asyncImportedPromise_es5.js b/tests/baselines/reference/asyncImportedPromise_es5.js index 641b8e0381f..8a6ec4240ca 100644 --- a/tests/baselines/reference/asyncImportedPromise_es5.js +++ b/tests/baselines/reference/asyncImportedPromise_es5.js @@ -11,15 +11,21 @@ class Test { //// [task.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); var Task = (function (_super) { __extends(Task, _super); function Task() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Task; }(Promise)); @@ -35,8 +41,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t; - return { next: verb(0), "throw": verb(1), "return": verb(2) }; + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); @@ -61,6 +67,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; +Object.defineProperty(exports, "__esModule", { value: true }); var task_1 = require("./task"); var Test = (function () { function Test() { diff --git a/tests/baselines/reference/asyncImportedPromise_es5.symbols b/tests/baselines/reference/asyncImportedPromise_es5.symbols index b889299bd7e..c4ff901f5b9 100644 --- a/tests/baselines/reference/asyncImportedPromise_es5.symbols +++ b/tests/baselines/reference/asyncImportedPromise_es5.symbols @@ -2,7 +2,7 @@ export class Task extends Promise { } >Task : Symbol(Task, Decl(task.ts, 0, 0)) >T : Symbol(T, Decl(task.ts, 0, 18)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >T : Symbol(T, Decl(task.ts, 0, 18)) === tests/cases/conformance/async/es5/test.ts === diff --git a/tests/baselines/reference/asyncImportedPromise_es6.js b/tests/baselines/reference/asyncImportedPromise_es6.js index 6c6e34e7b1d..6b84f5615b3 100644 --- a/tests/baselines/reference/asyncImportedPromise_es6.js +++ b/tests/baselines/reference/asyncImportedPromise_es6.js @@ -11,6 +11,7 @@ class Test { //// [task.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); class Task extends Promise { } exports.Task = Task; @@ -24,6 +25,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; +Object.defineProperty(exports, "__esModule", { value: true }); class Test { example() { return __awaiter(this, void 0, void 0, function* () { return; }); diff --git a/tests/baselines/reference/asyncMethodWithSuper_es5.js b/tests/baselines/reference/asyncMethodWithSuper_es5.js index 235f2763f9f..c68b1ed036f 100644 --- a/tests/baselines/reference/asyncMethodWithSuper_es5.js +++ b/tests/baselines/reference/asyncMethodWithSuper_es5.js @@ -61,7 +61,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } // async method with only call/get on 'super' does not require a binding B.prototype.simple = function () { diff --git a/tests/baselines/reference/asyncMultiFile_es5.js b/tests/baselines/reference/asyncMultiFile_es5.js index 547135e5c19..67a3ce258b4 100644 --- a/tests/baselines/reference/asyncMultiFile_es5.js +++ b/tests/baselines/reference/asyncMultiFile_es5.js @@ -15,8 +15,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t; - return { next: verb(0), "throw": verb(1), "return": verb(2) }; + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); diff --git a/tests/baselines/reference/asyncQualifiedReturnType_es5.js b/tests/baselines/reference/asyncQualifiedReturnType_es5.js index dd54f6ee833..3cae9ea6b56 100644 --- a/tests/baselines/reference/asyncQualifiedReturnType_es5.js +++ b/tests/baselines/reference/asyncQualifiedReturnType_es5.js @@ -13,7 +13,7 @@ var X; var MyPromise = (function (_super) { __extends(MyPromise, _super); function MyPromise() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return MyPromise; }(Promise)); diff --git a/tests/baselines/reference/asyncQualifiedReturnType_es5.symbols b/tests/baselines/reference/asyncQualifiedReturnType_es5.symbols index 1fcc5d4e609..8964074ed61 100644 --- a/tests/baselines/reference/asyncQualifiedReturnType_es5.symbols +++ b/tests/baselines/reference/asyncQualifiedReturnType_es5.symbols @@ -5,7 +5,7 @@ namespace X { export class MyPromise extends Promise { >MyPromise : Symbol(MyPromise, Decl(asyncQualifiedReturnType_es5.ts, 0, 13)) >T : Symbol(T, Decl(asyncQualifiedReturnType_es5.ts, 1, 27)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >T : Symbol(T, Decl(asyncQualifiedReturnType_es5.ts, 1, 27)) } } diff --git a/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.symbols b/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.symbols index b5f83de6021..d1de246fa93 100644 --- a/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.symbols +++ b/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.symbols @@ -3,7 +3,7 @@ declare function someOtherFunction(i: any): Promise; >someOtherFunction : Symbol(someOtherFunction, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 0, 0)) >i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 1, 35)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) const x = async i => await someOtherFunction(i) >x : Symbol(x, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 2, 5)) diff --git a/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es5.symbols b/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es5.symbols index 0f43ba7773e..82b73a199ea 100644 --- a/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es5.symbols +++ b/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es5.symbols @@ -3,7 +3,7 @@ declare function someOtherFunction(i: any): Promise; >someOtherFunction : Symbol(someOtherFunction, Decl(asyncUnParenthesizedArrowFunction_es5.ts, 0, 0)) >i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es5.ts, 1, 35)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) const x = async i => await someOtherFunction(i) >x : Symbol(x, Decl(asyncUnParenthesizedArrowFunction_es5.ts, 2, 5)) diff --git a/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es6.symbols b/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es6.symbols index 018c2399258..fee86b56cee 100644 --- a/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es6.symbols +++ b/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es6.symbols @@ -3,7 +3,7 @@ declare function someOtherFunction(i: any): Promise; >someOtherFunction : Symbol(someOtherFunction, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 0, 0)) >i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 1, 35)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) const x = async i => await someOtherFunction(i) >x : Symbol(x, Decl(asyncUnParenthesizedArrowFunction_es6.ts, 2, 5)) diff --git a/tests/baselines/reference/asyncUseStrict_es2017.symbols b/tests/baselines/reference/asyncUseStrict_es2017.symbols index 23fd654ca29..ecd5c992cd8 100644 --- a/tests/baselines/reference/asyncUseStrict_es2017.symbols +++ b/tests/baselines/reference/asyncUseStrict_es2017.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(asyncUseStrict_es2017.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) async function func(): Promise { >func : Symbol(func, Decl(asyncUseStrict_es2017.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) "use strict"; var b = await p || a; diff --git a/tests/baselines/reference/asyncUseStrict_es5.symbols b/tests/baselines/reference/asyncUseStrict_es5.symbols index a70f3ca546a..925f348249b 100644 --- a/tests/baselines/reference/asyncUseStrict_es5.symbols +++ b/tests/baselines/reference/asyncUseStrict_es5.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(asyncUseStrict_es5.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) async function func(): Promise { >func : Symbol(func, Decl(asyncUseStrict_es5.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) "use strict"; var b = await p || a; diff --git a/tests/baselines/reference/asyncUseStrict_es6.symbols b/tests/baselines/reference/asyncUseStrict_es6.symbols index f94c16664e7..8aa3606c3b4 100644 --- a/tests/baselines/reference/asyncUseStrict_es6.symbols +++ b/tests/baselines/reference/asyncUseStrict_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(asyncUseStrict_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) async function func(): Promise { >func : Symbol(func, Decl(asyncUseStrict_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) "use strict"; var b = await p || a; diff --git a/tests/baselines/reference/augmentExportEquals1.js b/tests/baselines/reference/augmentExportEquals1.js index 98322c01a34..7b0bfcf7335 100644 --- a/tests/baselines/reference/augmentExportEquals1.js +++ b/tests/baselines/reference/augmentExportEquals1.js @@ -28,9 +28,11 @@ define(["require", "exports"], function (require, exports) { //// [file2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [file3.js] define(["require", "exports", "./file2"], function (require, exports) { "use strict"; + exports.__esModule = true; var a; // should not work }); diff --git a/tests/baselines/reference/augmentExportEquals1_1.js b/tests/baselines/reference/augmentExportEquals1_1.js index 08f032ff33f..51bc67e7fa4 100644 --- a/tests/baselines/reference/augmentExportEquals1_1.js +++ b/tests/baselines/reference/augmentExportEquals1_1.js @@ -25,9 +25,11 @@ let a: x.A; // should not work //// [file2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [file3.js] define(["require", "exports", "file2"], function (require, exports) { "use strict"; + exports.__esModule = true; var a; // should not work }); diff --git a/tests/baselines/reference/augmentExportEquals2.js b/tests/baselines/reference/augmentExportEquals2.js index fc373173e3c..efdce1bc0cf 100644 --- a/tests/baselines/reference/augmentExportEquals2.js +++ b/tests/baselines/reference/augmentExportEquals2.js @@ -27,9 +27,11 @@ define(["require", "exports"], function (require, exports) { //// [file2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [file3.js] define(["require", "exports", "./file2"], function (require, exports) { "use strict"; + exports.__esModule = true; var a; // should not work }); diff --git a/tests/baselines/reference/augmentExportEquals2_1.js b/tests/baselines/reference/augmentExportEquals2_1.js index 9046157bb26..322ab3b36bf 100644 --- a/tests/baselines/reference/augmentExportEquals2_1.js +++ b/tests/baselines/reference/augmentExportEquals2_1.js @@ -25,9 +25,11 @@ let a: x.A; // should not work //// [file2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [file3.js] define(["require", "exports", "file2"], function (require, exports) { "use strict"; + exports.__esModule = true; var a; // should not work }); diff --git a/tests/baselines/reference/augmentExportEquals3.js b/tests/baselines/reference/augmentExportEquals3.js index 94cb0f8ce95..387ef86ff79 100644 --- a/tests/baselines/reference/augmentExportEquals3.js +++ b/tests/baselines/reference/augmentExportEquals3.js @@ -36,11 +36,13 @@ define(["require", "exports"], function (require, exports) { //// [file2.js] define(["require", "exports", "./file1"], function (require, exports, x) { "use strict"; + exports.__esModule = true; x.b = 1; }); //// [file3.js] define(["require", "exports", "./file1", "./file2"], function (require, exports, x) { "use strict"; + exports.__esModule = true; var a; var b = x.b; }); diff --git a/tests/baselines/reference/augmentExportEquals3_1.js b/tests/baselines/reference/augmentExportEquals3_1.js index fc6b7b1cec3..e91ca4498dd 100644 --- a/tests/baselines/reference/augmentExportEquals3_1.js +++ b/tests/baselines/reference/augmentExportEquals3_1.js @@ -30,11 +30,13 @@ let b = x.b; //// [file2.js] define(["require", "exports", "file1"], function (require, exports, x) { "use strict"; + exports.__esModule = true; x.b = 1; }); //// [file3.js] define(["require", "exports", "file1", "file2"], function (require, exports, x) { "use strict"; + exports.__esModule = true; var a; var b = x.b; }); diff --git a/tests/baselines/reference/augmentExportEquals4.js b/tests/baselines/reference/augmentExportEquals4.js index ff0cbd44e0b..37be30731de 100644 --- a/tests/baselines/reference/augmentExportEquals4.js +++ b/tests/baselines/reference/augmentExportEquals4.js @@ -40,11 +40,13 @@ define(["require", "exports"], function (require, exports) { //// [file2.js] define(["require", "exports", "./file1"], function (require, exports, x) { "use strict"; + exports.__esModule = true; x.b = 1; }); //// [file3.js] define(["require", "exports", "./file1", "./file2"], function (require, exports, x) { "use strict"; + exports.__esModule = true; var a; var b = x.b; }); diff --git a/tests/baselines/reference/augmentExportEquals4_1.js b/tests/baselines/reference/augmentExportEquals4_1.js index b4ba932d44b..71d39aedb1f 100644 --- a/tests/baselines/reference/augmentExportEquals4_1.js +++ b/tests/baselines/reference/augmentExportEquals4_1.js @@ -31,11 +31,13 @@ let b = x.b; //// [file2.js] define(["require", "exports", "file1"], function (require, exports, x) { "use strict"; + exports.__esModule = true; x.b = 1; }); //// [file3.js] define(["require", "exports", "file1", "file2"], function (require, exports, x) { "use strict"; + exports.__esModule = true; var a; var b = x.b; }); diff --git a/tests/baselines/reference/augmentExportEquals5.js b/tests/baselines/reference/augmentExportEquals5.js index 49b6c3fed56..7bc5102ca9d 100644 --- a/tests/baselines/reference/augmentExportEquals5.js +++ b/tests/baselines/reference/augmentExportEquals5.js @@ -85,10 +85,12 @@ const y = x.id; //// [augmentation.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [consumer.js] define(["require", "exports", "./augmentation"], function (require, exports) { "use strict"; + exports.__esModule = true; var x; var y = x.id; }); diff --git a/tests/baselines/reference/augmentExportEquals6.js b/tests/baselines/reference/augmentExportEquals6.js index 3f9cbbb0af8..4299f8653dd 100644 --- a/tests/baselines/reference/augmentExportEquals6.js +++ b/tests/baselines/reference/augmentExportEquals6.js @@ -52,11 +52,13 @@ define(["require", "exports"], function (require, exports) { //// [file2.js] define(["require", "exports", "./file1"], function (require, exports, x) { "use strict"; + exports.__esModule = true; x.B.b = 1; }); //// [file3.js] define(["require", "exports", "./file1", "./file2"], function (require, exports, x) { "use strict"; + exports.__esModule = true; var a; var b = a.a; var c = x.B.b; diff --git a/tests/baselines/reference/augmentExportEquals6_1.js b/tests/baselines/reference/augmentExportEquals6_1.js index c7c560183cc..e69728a766b 100644 --- a/tests/baselines/reference/augmentExportEquals6_1.js +++ b/tests/baselines/reference/augmentExportEquals6_1.js @@ -29,10 +29,12 @@ let b = a.a; //// [file2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [file3.js] define(["require", "exports", "file2"], function (require, exports) { "use strict"; + exports.__esModule = true; var a; var b = a.a; }); diff --git a/tests/baselines/reference/augmentExportEquals7.errors.txt b/tests/baselines/reference/augmentExportEquals7.errors.txt new file mode 100644 index 00000000000..e13cf037023 --- /dev/null +++ b/tests/baselines/reference/augmentExportEquals7.errors.txt @@ -0,0 +1,16 @@ +/node_modules/@types/lib-extender/index.d.ts(2,16): error TS2649: Cannot augment module 'lib' with value exports because it resolves to a non-module entity. + + +==== /node_modules/lib/index.d.ts (0 errors) ==== + declare var lib: () => void; + declare namespace lib {} + export = lib; + +==== /node_modules/@types/lib-extender/index.d.ts (1 errors) ==== + import * as lib from "lib"; + declare module "lib" { + ~~~~~ +!!! error TS2649: Cannot augment module 'lib' with value exports because it resolves to a non-module entity. + export function fn(): void; + } + \ No newline at end of file diff --git a/tests/baselines/reference/augmentedTypesExternalModule1.js b/tests/baselines/reference/augmentedTypesExternalModule1.js index 65525e8187e..0a8b7404bd1 100644 --- a/tests/baselines/reference/augmentedTypesExternalModule1.js +++ b/tests/baselines/reference/augmentedTypesExternalModule1.js @@ -6,6 +6,7 @@ module c5 { } // should be ok everywhere //// [augmentedTypesExternalModule1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.a = 1; var c5 = (function () { function c5() { diff --git a/tests/baselines/reference/autolift4.js b/tests/baselines/reference/autolift4.js index 1c29bfeeff7..6d91c61d59d 100644 --- a/tests/baselines/reference/autolift4.js +++ b/tests/baselines/reference/autolift4.js @@ -24,11 +24,16 @@ class Point3D extends Point { //// [autolift4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Point = (function () { function Point(x, y) { this.x = x; diff --git a/tests/baselines/reference/awaitBinaryExpression1_es2017.symbols b/tests/baselines/reference/awaitBinaryExpression1_es2017.symbols index 827769b3db5..b763a454458 100644 --- a/tests/baselines/reference/awaitBinaryExpression1_es2017.symbols +++ b/tests/baselines/reference/awaitBinaryExpression1_es2017.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression1_es2017.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function before(): void; >before : Symbol(before, Decl(awaitBinaryExpression1_es2017.ts, 1, 32)) @@ -14,7 +14,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression1_es2017.ts, 3, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitBinaryExpression1_es2017.ts, 1, 32)) diff --git a/tests/baselines/reference/awaitBinaryExpression1_es5.symbols b/tests/baselines/reference/awaitBinaryExpression1_es5.symbols index 84d3b17b126..b1b3b04d6aa 100644 --- a/tests/baselines/reference/awaitBinaryExpression1_es5.symbols +++ b/tests/baselines/reference/awaitBinaryExpression1_es5.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression1_es5.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare function before(): void; >before : Symbol(before, Decl(awaitBinaryExpression1_es5.ts, 1, 32)) @@ -14,7 +14,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression1_es5.ts, 3, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitBinaryExpression1_es5.ts, 1, 32)) diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols index 0f05f6521cb..f6782d36636 100644 --- a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression1_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function before(): void; >before : Symbol(before, Decl(awaitBinaryExpression1_es6.ts, 1, 32)) @@ -14,7 +14,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression1_es6.ts, 3, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitBinaryExpression1_es6.ts, 1, 32)) diff --git a/tests/baselines/reference/awaitBinaryExpression2_es2017.symbols b/tests/baselines/reference/awaitBinaryExpression2_es2017.symbols index 549eb49cf92..7f97d409b51 100644 --- a/tests/baselines/reference/awaitBinaryExpression2_es2017.symbols +++ b/tests/baselines/reference/awaitBinaryExpression2_es2017.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression2_es2017.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function before(): void; >before : Symbol(before, Decl(awaitBinaryExpression2_es2017.ts, 1, 32)) @@ -14,7 +14,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression2_es2017.ts, 3, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitBinaryExpression2_es2017.ts, 1, 32)) diff --git a/tests/baselines/reference/awaitBinaryExpression2_es5.symbols b/tests/baselines/reference/awaitBinaryExpression2_es5.symbols index e44238d4172..1f8bafa8a37 100644 --- a/tests/baselines/reference/awaitBinaryExpression2_es5.symbols +++ b/tests/baselines/reference/awaitBinaryExpression2_es5.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression2_es5.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare function before(): void; >before : Symbol(before, Decl(awaitBinaryExpression2_es5.ts, 1, 32)) @@ -14,7 +14,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression2_es5.ts, 3, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitBinaryExpression2_es5.ts, 1, 32)) diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols index 518e6eec528..e2b724e2c2d 100644 --- a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression2_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function before(): void; >before : Symbol(before, Decl(awaitBinaryExpression2_es6.ts, 1, 32)) @@ -14,7 +14,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression2_es6.ts, 3, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitBinaryExpression2_es6.ts, 1, 32)) diff --git a/tests/baselines/reference/awaitBinaryExpression3_es2017.symbols b/tests/baselines/reference/awaitBinaryExpression3_es2017.symbols index 29c8fb7f398..1d7e1ff74a0 100644 --- a/tests/baselines/reference/awaitBinaryExpression3_es2017.symbols +++ b/tests/baselines/reference/awaitBinaryExpression3_es2017.symbols @@ -4,7 +4,7 @@ declare var a: number; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression3_es2017.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function before(): void; >before : Symbol(before, Decl(awaitBinaryExpression3_es2017.ts, 1, 31)) @@ -14,7 +14,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression3_es2017.ts, 3, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitBinaryExpression3_es2017.ts, 1, 31)) diff --git a/tests/baselines/reference/awaitBinaryExpression3_es5.symbols b/tests/baselines/reference/awaitBinaryExpression3_es5.symbols index d9480fdf524..7e8cd107b42 100644 --- a/tests/baselines/reference/awaitBinaryExpression3_es5.symbols +++ b/tests/baselines/reference/awaitBinaryExpression3_es5.symbols @@ -4,7 +4,7 @@ declare var a: number; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression3_es5.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare function before(): void; >before : Symbol(before, Decl(awaitBinaryExpression3_es5.ts, 1, 31)) @@ -14,7 +14,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression3_es5.ts, 3, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitBinaryExpression3_es5.ts, 1, 31)) diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols index 0d653c1ff7b..afd2ae97641 100644 --- a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols @@ -4,7 +4,7 @@ declare var a: number; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression3_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function before(): void; >before : Symbol(before, Decl(awaitBinaryExpression3_es6.ts, 1, 31)) @@ -14,7 +14,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression3_es6.ts, 3, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitBinaryExpression3_es6.ts, 1, 31)) diff --git a/tests/baselines/reference/awaitBinaryExpression4_es2017.symbols b/tests/baselines/reference/awaitBinaryExpression4_es2017.symbols index 0db5a20e0c1..cf01d5ec858 100644 --- a/tests/baselines/reference/awaitBinaryExpression4_es2017.symbols +++ b/tests/baselines/reference/awaitBinaryExpression4_es2017.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression4_es2017.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function before(): void; >before : Symbol(before, Decl(awaitBinaryExpression4_es2017.ts, 1, 32)) @@ -14,7 +14,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression4_es2017.ts, 3, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitBinaryExpression4_es2017.ts, 1, 32)) diff --git a/tests/baselines/reference/awaitBinaryExpression4_es5.symbols b/tests/baselines/reference/awaitBinaryExpression4_es5.symbols index ab2cbeadfc5..19ffe817b15 100644 --- a/tests/baselines/reference/awaitBinaryExpression4_es5.symbols +++ b/tests/baselines/reference/awaitBinaryExpression4_es5.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression4_es5.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare function before(): void; >before : Symbol(before, Decl(awaitBinaryExpression4_es5.ts, 1, 32)) @@ -14,7 +14,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression4_es5.ts, 3, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitBinaryExpression4_es5.ts, 1, 32)) diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols index 18a59322558..61e12001c6a 100644 --- a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression4_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function before(): void; >before : Symbol(before, Decl(awaitBinaryExpression4_es6.ts, 1, 32)) @@ -14,7 +14,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression4_es6.ts, 3, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitBinaryExpression4_es6.ts, 1, 32)) diff --git a/tests/baselines/reference/awaitBinaryExpression5_es2017.symbols b/tests/baselines/reference/awaitBinaryExpression5_es2017.symbols index e2d30c658f7..4b684c44f77 100644 --- a/tests/baselines/reference/awaitBinaryExpression5_es2017.symbols +++ b/tests/baselines/reference/awaitBinaryExpression5_es2017.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression5_es2017.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function before(): void; >before : Symbol(before, Decl(awaitBinaryExpression5_es2017.ts, 1, 32)) @@ -14,7 +14,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression5_es2017.ts, 3, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitBinaryExpression5_es2017.ts, 1, 32)) diff --git a/tests/baselines/reference/awaitBinaryExpression5_es5.symbols b/tests/baselines/reference/awaitBinaryExpression5_es5.symbols index ad258355d38..b7255d25a57 100644 --- a/tests/baselines/reference/awaitBinaryExpression5_es5.symbols +++ b/tests/baselines/reference/awaitBinaryExpression5_es5.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression5_es5.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare function before(): void; >before : Symbol(before, Decl(awaitBinaryExpression5_es5.ts, 1, 32)) @@ -14,7 +14,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression5_es5.ts, 3, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitBinaryExpression5_es5.ts, 1, 32)) diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols index 57a7958a13c..fb50640ce7c 100644 --- a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression5_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function before(): void; >before : Symbol(before, Decl(awaitBinaryExpression5_es6.ts, 1, 32)) @@ -14,7 +14,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression5_es6.ts, 3, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitBinaryExpression5_es6.ts, 1, 32)) diff --git a/tests/baselines/reference/awaitCallExpression1_es2017.symbols b/tests/baselines/reference/awaitCallExpression1_es2017.symbols index 68c28d15350..373654dd11a 100644 --- a/tests/baselines/reference/awaitCallExpression1_es2017.symbols +++ b/tests/baselines/reference/awaitCallExpression1_es2017.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression1_es2017.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression1_es2017.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression1_es2017.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es2017.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es2017.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression1_es2017.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression1_es2017.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression1_es2017.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es2017.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es2017.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression1_es2017.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression1_es2017.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression1_es5.symbols b/tests/baselines/reference/awaitCallExpression1_es5.symbols index b172db760e3..61851ae77f7 100644 --- a/tests/baselines/reference/awaitCallExpression1_es5.symbols +++ b/tests/baselines/reference/awaitCallExpression1_es5.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression1_es5.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression1_es5.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression1_es5.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es5.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es5.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression1_es5.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression1_es5.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression1_es5.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es5.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es5.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression1_es5.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression1_es5.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression1_es6.symbols b/tests/baselines/reference/awaitCallExpression1_es6.symbols index 1b1deb0f579..a81586bc4fe 100644 --- a/tests/baselines/reference/awaitCallExpression1_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression1_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression1_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression1_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression1_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression1_es6.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression1_es6.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression2_es2017.symbols b/tests/baselines/reference/awaitCallExpression2_es2017.symbols index 4528ae4c074..6bf77f40d19 100644 --- a/tests/baselines/reference/awaitCallExpression2_es2017.symbols +++ b/tests/baselines/reference/awaitCallExpression2_es2017.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression2_es2017.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression2_es2017.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression2_es2017.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es2017.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es2017.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression2_es2017.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression2_es2017.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression2_es2017.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es2017.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es2017.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression2_es2017.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression2_es2017.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression2_es5.js b/tests/baselines/reference/awaitCallExpression2_es5.js index 6b0d6e4b648..d9c51e84822 100644 --- a/tests/baselines/reference/awaitCallExpression2_es5.js +++ b/tests/baselines/reference/awaitCallExpression2_es5.js @@ -16,15 +16,15 @@ async function func(): Promise { //// [awaitCallExpression2_es5.js] function func() { return __awaiter(this, void 0, void 0, function () { - var b, _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { + var b, _a; + return __generator(this, function (_b) { + switch (_b.label) { case 0: before(); _a = fn; return [4 /*yield*/, p]; case 1: - b = _a.apply(void 0, [_c.sent(), a, a]); + b = _a.apply(void 0, [_b.sent(), a, a]); after(); return [2 /*return*/]; } diff --git a/tests/baselines/reference/awaitCallExpression2_es5.symbols b/tests/baselines/reference/awaitCallExpression2_es5.symbols index 95e1f650030..71ecc53a3c9 100644 --- a/tests/baselines/reference/awaitCallExpression2_es5.symbols +++ b/tests/baselines/reference/awaitCallExpression2_es5.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression2_es5.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression2_es5.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression2_es5.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es5.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es5.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression2_es5.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression2_es5.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression2_es5.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es5.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es5.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression2_es5.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression2_es5.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression2_es6.symbols b/tests/baselines/reference/awaitCallExpression2_es6.symbols index d7f3cc0d4bd..91de39742dc 100644 --- a/tests/baselines/reference/awaitCallExpression2_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression2_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression2_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression2_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression2_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression2_es6.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression2_es6.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression3_es2017.symbols b/tests/baselines/reference/awaitCallExpression3_es2017.symbols index a1120103fb0..f42254489ce 100644 --- a/tests/baselines/reference/awaitCallExpression3_es2017.symbols +++ b/tests/baselines/reference/awaitCallExpression3_es2017.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression3_es2017.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression3_es2017.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression3_es2017.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es2017.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es2017.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression3_es2017.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression3_es2017.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression3_es2017.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es2017.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es2017.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression3_es2017.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression3_es2017.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression3_es5.symbols b/tests/baselines/reference/awaitCallExpression3_es5.symbols index 2c18507340a..66ef232948d 100644 --- a/tests/baselines/reference/awaitCallExpression3_es5.symbols +++ b/tests/baselines/reference/awaitCallExpression3_es5.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression3_es5.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression3_es5.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression3_es5.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es5.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es5.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression3_es5.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression3_es5.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression3_es5.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es5.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es5.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression3_es5.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression3_es5.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression3_es6.symbols b/tests/baselines/reference/awaitCallExpression3_es6.symbols index 14b6f35bc30..6b559d847d9 100644 --- a/tests/baselines/reference/awaitCallExpression3_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression3_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression3_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression3_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression3_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression3_es6.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression3_es6.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression4_es2017.symbols b/tests/baselines/reference/awaitCallExpression4_es2017.symbols index fb607d9841f..60fc9f643f9 100644 --- a/tests/baselines/reference/awaitCallExpression4_es2017.symbols +++ b/tests/baselines/reference/awaitCallExpression4_es2017.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression4_es2017.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression4_es2017.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression4_es2017.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es2017.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es2017.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression4_es2017.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression4_es2017.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression4_es2017.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es2017.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es2017.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression4_es2017.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression4_es2017.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression4_es5.symbols b/tests/baselines/reference/awaitCallExpression4_es5.symbols index 46a5b942956..f52e6d2b59e 100644 --- a/tests/baselines/reference/awaitCallExpression4_es5.symbols +++ b/tests/baselines/reference/awaitCallExpression4_es5.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression4_es5.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression4_es5.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression4_es5.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es5.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es5.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression4_es5.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression4_es5.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression4_es5.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es5.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es5.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression4_es5.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression4_es5.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression4_es6.symbols b/tests/baselines/reference/awaitCallExpression4_es6.symbols index d7e90fc4a53..33117d2d80b 100644 --- a/tests/baselines/reference/awaitCallExpression4_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression4_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression4_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression4_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression4_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression4_es6.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression4_es6.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression5_es2017.symbols b/tests/baselines/reference/awaitCallExpression5_es2017.symbols index 3854353314a..ffad2bda5a6 100644 --- a/tests/baselines/reference/awaitCallExpression5_es2017.symbols +++ b/tests/baselines/reference/awaitCallExpression5_es2017.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression5_es2017.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression5_es2017.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression5_es2017.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es2017.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es2017.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression5_es2017.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression5_es2017.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression5_es2017.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es2017.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es2017.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression5_es2017.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression5_es2017.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression5_es5.symbols b/tests/baselines/reference/awaitCallExpression5_es5.symbols index 9f34c3e9fe8..2d7b9bd875e 100644 --- a/tests/baselines/reference/awaitCallExpression5_es5.symbols +++ b/tests/baselines/reference/awaitCallExpression5_es5.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression5_es5.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression5_es5.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression5_es5.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es5.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es5.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression5_es5.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression5_es5.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression5_es5.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es5.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es5.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression5_es5.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression5_es5.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression5_es6.symbols b/tests/baselines/reference/awaitCallExpression5_es6.symbols index ba8f9878188..cf6afde09ed 100644 --- a/tests/baselines/reference/awaitCallExpression5_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression5_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression5_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression5_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression5_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression5_es6.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression5_es6.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression6_es2017.symbols b/tests/baselines/reference/awaitCallExpression6_es2017.symbols index 6a651510328..f540e418f4a 100644 --- a/tests/baselines/reference/awaitCallExpression6_es2017.symbols +++ b/tests/baselines/reference/awaitCallExpression6_es2017.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression6_es2017.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression6_es2017.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression6_es2017.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es2017.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es2017.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression6_es2017.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression6_es2017.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression6_es2017.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es2017.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es2017.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression6_es2017.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression6_es2017.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression6_es5.js b/tests/baselines/reference/awaitCallExpression6_es5.js index acc4261eacb..23def82fee7 100644 --- a/tests/baselines/reference/awaitCallExpression6_es5.js +++ b/tests/baselines/reference/awaitCallExpression6_es5.js @@ -16,15 +16,15 @@ async function func(): Promise { //// [awaitCallExpression6_es5.js] function func() { return __awaiter(this, void 0, void 0, function () { - var b, _a, _b, _c; - return __generator(this, function (_d) { - switch (_d.label) { + var b, _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { case 0: before(); _b = (_a = o).fn; return [4 /*yield*/, p]; case 1: - b = _b.apply(_a, [_d.sent(), a, a]); + b = _b.apply(_a, [_c.sent(), a, a]); after(); return [2 /*return*/]; } diff --git a/tests/baselines/reference/awaitCallExpression6_es5.symbols b/tests/baselines/reference/awaitCallExpression6_es5.symbols index fc3ae4cbdbb..a361b7ea736 100644 --- a/tests/baselines/reference/awaitCallExpression6_es5.symbols +++ b/tests/baselines/reference/awaitCallExpression6_es5.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression6_es5.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression6_es5.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression6_es5.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es5.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es5.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression6_es5.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression6_es5.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression6_es5.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es5.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es5.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression6_es5.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression6_es5.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression6_es6.symbols b/tests/baselines/reference/awaitCallExpression6_es6.symbols index 938c49d1d41..35feb7c8ea0 100644 --- a/tests/baselines/reference/awaitCallExpression6_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression6_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression6_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression6_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression6_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression6_es6.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression6_es6.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression7_es2017.symbols b/tests/baselines/reference/awaitCallExpression7_es2017.symbols index e95078c6850..525af853729 100644 --- a/tests/baselines/reference/awaitCallExpression7_es2017.symbols +++ b/tests/baselines/reference/awaitCallExpression7_es2017.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression7_es2017.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression7_es2017.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression7_es2017.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es2017.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es2017.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression7_es2017.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression7_es2017.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression7_es2017.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es2017.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es2017.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression7_es2017.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression7_es2017.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression7_es5.symbols b/tests/baselines/reference/awaitCallExpression7_es5.symbols index 96a7252ef04..3b56d8520b0 100644 --- a/tests/baselines/reference/awaitCallExpression7_es5.symbols +++ b/tests/baselines/reference/awaitCallExpression7_es5.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression7_es5.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression7_es5.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression7_es5.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es5.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es5.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression7_es5.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression7_es5.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression7_es5.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es5.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es5.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression7_es5.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression7_es5.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression7_es6.symbols b/tests/baselines/reference/awaitCallExpression7_es6.symbols index f366417b23f..fe6c1fb0eeb 100644 --- a/tests/baselines/reference/awaitCallExpression7_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression7_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression7_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression7_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression7_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression7_es6.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression7_es6.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression8_es2017.symbols b/tests/baselines/reference/awaitCallExpression8_es2017.symbols index e3fd465c120..53ba162671d 100644 --- a/tests/baselines/reference/awaitCallExpression8_es2017.symbols +++ b/tests/baselines/reference/awaitCallExpression8_es2017.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression8_es2017.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression8_es2017.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression8_es2017.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es2017.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es2017.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression8_es2017.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression8_es2017.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression8_es2017.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es2017.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es2017.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression8_es2017.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression8_es2017.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression8_es5.symbols b/tests/baselines/reference/awaitCallExpression8_es5.symbols index 50b564481b9..e7f1659a7e7 100644 --- a/tests/baselines/reference/awaitCallExpression8_es5.symbols +++ b/tests/baselines/reference/awaitCallExpression8_es5.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression8_es5.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression8_es5.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression8_es5.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es5.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es5.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression8_es5.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression8_es5.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression8_es5.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es5.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es5.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression8_es5.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression8_es5.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitCallExpression8_es6.symbols b/tests/baselines/reference/awaitCallExpression8_es6.symbols index 89441ea3e37..037ab79b68f 100644 --- a/tests/baselines/reference/awaitCallExpression8_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression8_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression8_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression8_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression8_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 5, 43)) @@ -42,7 +42,7 @@ declare function after(): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression8_es6.ts, 7, 31)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) before(); >before : Symbol(before, Decl(awaitCallExpression8_es6.ts, 5, 84)) diff --git a/tests/baselines/reference/awaitClassExpression_es2017.symbols b/tests/baselines/reference/awaitClassExpression_es2017.symbols index bebffa2bbad..1c497d80951 100644 --- a/tests/baselines/reference/awaitClassExpression_es2017.symbols +++ b/tests/baselines/reference/awaitClassExpression_es2017.symbols @@ -4,12 +4,12 @@ declare class C { } declare var p: Promise; >p : Symbol(p, Decl(awaitClassExpression_es2017.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >C : Symbol(C, Decl(awaitClassExpression_es2017.ts, 0, 0)) async function func(): Promise { >func : Symbol(func, Decl(awaitClassExpression_es2017.ts, 1, 33)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) class D extends (await p) { >D : Symbol(D, Decl(awaitClassExpression_es2017.ts, 3, 38)) diff --git a/tests/baselines/reference/awaitClassExpression_es5.js b/tests/baselines/reference/awaitClassExpression_es5.js index b207ba08f8d..1ef7338fb12 100644 --- a/tests/baselines/reference/awaitClassExpression_es5.js +++ b/tests/baselines/reference/awaitClassExpression_es5.js @@ -10,20 +10,20 @@ async function func(): Promise { //// [awaitClassExpression_es5.js] function func() { return __awaiter(this, void 0, void 0, function () { - var D, _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { + var D, _a; + return __generator(this, function (_b) { + switch (_b.label) { case 0: _a = function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }; return [4 /*yield*/, p]; case 1: - D = (_a.apply(void 0, [(_c.sent())])); + D = (_a.apply(void 0, [(_b.sent())])); return [2 /*return*/]; } }); diff --git a/tests/baselines/reference/awaitClassExpression_es5.symbols b/tests/baselines/reference/awaitClassExpression_es5.symbols index 1f550576c09..18b742e4437 100644 --- a/tests/baselines/reference/awaitClassExpression_es5.symbols +++ b/tests/baselines/reference/awaitClassExpression_es5.symbols @@ -4,12 +4,12 @@ declare class C { } declare var p: Promise; >p : Symbol(p, Decl(awaitClassExpression_es5.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >C : Symbol(C, Decl(awaitClassExpression_es5.ts, 0, 0)) async function func(): Promise { >func : Symbol(func, Decl(awaitClassExpression_es5.ts, 1, 33)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) class D extends (await p) { >D : Symbol(D, Decl(awaitClassExpression_es5.ts, 3, 38)) diff --git a/tests/baselines/reference/awaitClassExpression_es6.symbols b/tests/baselines/reference/awaitClassExpression_es6.symbols index 6d1e9f1a103..b7c485e88c6 100644 --- a/tests/baselines/reference/awaitClassExpression_es6.symbols +++ b/tests/baselines/reference/awaitClassExpression_es6.symbols @@ -4,12 +4,12 @@ declare class C { } declare var p: Promise; >p : Symbol(p, Decl(awaitClassExpression_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >C : Symbol(C, Decl(awaitClassExpression_es6.ts, 0, 0)) async function func(): Promise { >func : Symbol(func, Decl(awaitClassExpression_es6.ts, 1, 33)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) class D extends (await p) { >D : Symbol(D, Decl(awaitClassExpression_es6.ts, 3, 38)) diff --git a/tests/baselines/reference/awaitInheritedPromise_es2017.symbols b/tests/baselines/reference/awaitInheritedPromise_es2017.symbols index ef68d16b678..f4cf33bfe83 100644 --- a/tests/baselines/reference/awaitInheritedPromise_es2017.symbols +++ b/tests/baselines/reference/awaitInheritedPromise_es2017.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/async/es2017/awaitInheritedPromise_es2017.ts === interface A extends Promise {} >A : Symbol(A, Decl(awaitInheritedPromise_es2017.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) declare var a: A; >a : Symbol(a, Decl(awaitInheritedPromise_es2017.ts, 1, 11)) diff --git a/tests/baselines/reference/badExternalModuleReference.js b/tests/baselines/reference/badExternalModuleReference.js index 4f9e1aae507..c1608b4c57e 100644 --- a/tests/baselines/reference/badExternalModuleReference.js +++ b/tests/baselines/reference/badExternalModuleReference.js @@ -9,4 +9,5 @@ export declare var a: { //// [badExternalModuleReference.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/bangInModuleName.js b/tests/baselines/reference/bangInModuleName.js index 2fe13e00cf0..f58827e1ae5 100644 --- a/tests/baselines/reference/bangInModuleName.js +++ b/tests/baselines/reference/bangInModuleName.js @@ -21,4 +21,5 @@ import * as http from 'intern/dojo/node!http'; /// define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/baseCheck.js b/tests/baselines/reference/baseCheck.js index 870f811c09f..2b4f90d27b1 100644 --- a/tests/baselines/reference/baseCheck.js +++ b/tests/baselines/reference/baseCheck.js @@ -30,11 +30,16 @@ function f() { //// [baseCheck.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C(x, y) { } diff --git a/tests/baselines/reference/baseIndexSignatureResolution.js b/tests/baselines/reference/baseIndexSignatureResolution.js index 7e922cf83b2..e57e5272ade 100644 --- a/tests/baselines/reference/baseIndexSignatureResolution.js +++ b/tests/baselines/reference/baseIndexSignatureResolution.js @@ -25,11 +25,16 @@ var z: Derived = b.foo(); */ //// [baseIndexSignatureResolution.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -38,7 +43,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/baseTypeOrderChecking.js b/tests/baselines/reference/baseTypeOrderChecking.js index ec96b80a999..06e7dd0c681 100644 --- a/tests/baselines/reference/baseTypeOrderChecking.js +++ b/tests/baselines/reference/baseTypeOrderChecking.js @@ -37,11 +37,16 @@ class Class4 extends Class3 //// [baseTypeOrderChecking.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var someVariable; var Class1 = (function () { function Class1() { @@ -51,7 +56,7 @@ var Class1 = (function () { var Class2 = (function (_super) { __extends(Class2, _super); function Class2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Class2; }(Class1)); @@ -63,7 +68,7 @@ var Class3 = (function () { var Class4 = (function (_super) { __extends(Class4, _super); function Class4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Class4; }(Class3)); diff --git a/tests/baselines/reference/baseTypeWrappingInstantiationChain.js b/tests/baselines/reference/baseTypeWrappingInstantiationChain.js index 5f8dcbd0e10..7442d1e0e6a 100644 --- a/tests/baselines/reference/baseTypeWrappingInstantiationChain.js +++ b/tests/baselines/reference/baseTypeWrappingInstantiationChain.js @@ -28,11 +28,16 @@ class C extends CBase { //// [baseTypeWrappingInstantiationChain.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var CBaseBase = (function () { function CBaseBase(x) { } @@ -41,7 +46,7 @@ var CBaseBase = (function () { var CBase = (function (_super) { __extends(CBase, _super); function CBase() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return CBase; }(CBaseBase)); @@ -59,7 +64,7 @@ var Wrapper = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.works = function () { new CBaseBase(this); diff --git a/tests/baselines/reference/bases.js b/tests/baselines/reference/bases.js index 6b73eb9556b..529eacfad04 100644 --- a/tests/baselines/reference/bases.js +++ b/tests/baselines/reference/bases.js @@ -21,11 +21,16 @@ new C().y; //// [bases.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B() { this.y; @@ -36,7 +41,7 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - var _this; + var _this = this; _this.x; any; return _this; diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js index 6d0f19dd37d..efd55a9ca18 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js @@ -29,11 +29,16 @@ function foo5(t: T, u: U): Object { //// [bestCommonTypeOfConditionalExpressions.js] // conditional expressions return the best common type of the branches plus contextual type (using the first candidate if multiple BCTs exist) // no errors expected here -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a; var b; var Base = (function () { @@ -44,14 +49,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js index 2e2d0bcb1e2..b68b5c3d97c 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js @@ -27,11 +27,16 @@ function foo3(t: T, u: U) { //// [bestCommonTypeOfConditionalExpressions2.js] // conditional expressions return the best common type of the branches plus contextual type (using the first candidate if multiple BCTs exist) // these are errors -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -40,14 +45,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/bestCommonTypeOfTuple2.js b/tests/baselines/reference/bestCommonTypeOfTuple2.js index 928909f4c38..39712f873bc 100644 --- a/tests/baselines/reference/bestCommonTypeOfTuple2.js +++ b/tests/baselines/reference/bestCommonTypeOfTuple2.js @@ -23,11 +23,16 @@ var e51 = t5[2]; // {} //// [bestCommonTypeOfTuple2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -46,7 +51,7 @@ var E = (function () { var F = (function (_super) { __extends(F, _super); function F() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return F; }(C)); @@ -59,7 +64,7 @@ var C1 = (function () { var D1 = (function (_super) { __extends(D1, _super); function D1() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.i = "bar"; return _this; } diff --git a/tests/baselines/reference/binaryArithmatic1.errors.txt b/tests/baselines/reference/binaryArithmatic1.errors.txt new file mode 100644 index 00000000000..51c0b649890 --- /dev/null +++ b/tests/baselines/reference/binaryArithmatic1.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/binaryArithmatic1.ts(1,13): error TS2531: Object is possibly 'null'. + + +==== tests/cases/compiler/binaryArithmatic1.ts (1 errors) ==== + var v = 4 | null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/binaryArithmatic2.errors.txt b/tests/baselines/reference/binaryArithmatic2.errors.txt new file mode 100644 index 00000000000..28f379c30e2 --- /dev/null +++ b/tests/baselines/reference/binaryArithmatic2.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/binaryArithmatic2.ts(1,13): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/compiler/binaryArithmatic2.ts (1 errors) ==== + var v = 4 | undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/binaryArithmatic3.errors.txt b/tests/baselines/reference/binaryArithmatic3.errors.txt index 6dffe5e150c..1457407a7b8 100644 --- a/tests/baselines/reference/binaryArithmatic3.errors.txt +++ b/tests/baselines/reference/binaryArithmatic3.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/binaryArithmatic3.ts(1,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/compiler/binaryArithmatic3.ts(1,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/compiler/binaryArithmatic3.ts(1,9): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/binaryArithmatic3.ts(1,21): error TS2532: Object is possibly 'undefined'. ==== tests/cases/compiler/binaryArithmatic3.ts (2 errors) ==== var v = undefined | undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/binaryArithmatic4.errors.txt b/tests/baselines/reference/binaryArithmatic4.errors.txt index f72c23073ca..fe7523e0884 100644 --- a/tests/baselines/reference/binaryArithmatic4.errors.txt +++ b/tests/baselines/reference/binaryArithmatic4.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/binaryArithmatic4.ts(1,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/compiler/binaryArithmatic4.ts(1,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/compiler/binaryArithmatic4.ts(1,9): error TS2531: Object is possibly 'null'. +tests/cases/compiler/binaryArithmatic4.ts(1,16): error TS2531: Object is possibly 'null'. ==== tests/cases/compiler/binaryArithmatic4.ts (2 errors) ==== var v = null | null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.errors.txt index 66d4cbb628e..c3e9f220a3a 100644 --- a/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.errors.txt @@ -1,9 +1,14 @@ -tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(47,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(48,26): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(49,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(35,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(36,24): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(47,26): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(47,33): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(48,26): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(48,33): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(49,26): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(49,38): error TS2532: Object is possibly 'undefined'. -==== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts (3 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts (8 errors) ==== // ~ operator on any type @@ -39,7 +44,11 @@ tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNot // any type literal var ResultIsNumber6 = ~undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber7 = ~null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. // any type expressions var ResultIsNumber8 = ~ANY2[0] @@ -51,14 +60,20 @@ tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNot var ResultIsNumber14 = ~A.foo(); var ResultIsNumber15 = ~(ANY + ANY1); var ResultIsNumber16 = ~(null + undefined); - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber17 = ~(null + null); - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber18 = ~(undefined + undefined); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // multiple ~ operators var ResultIsNumber19 = ~~ANY; diff --git a/tests/baselines/reference/bluebirdStaticThis.errors.txt b/tests/baselines/reference/bluebirdStaticThis.errors.txt index 1c22a12c341..b9e28711715 100644 --- a/tests/baselines/reference/bluebirdStaticThis.errors.txt +++ b/tests/baselines/reference/bluebirdStaticThis.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/bluebirdStaticThis.ts(5,15): error TS2420: Class 'Promise' incorrectly implements interface 'Thenable'. +tests/cases/compiler/bluebirdStaticThis.ts(5,22): error TS2420: Class 'Promise' incorrectly implements interface 'Thenable'. Property 'then' is missing in type 'Promise'. -tests/cases/compiler/bluebirdStaticThis.ts(22,51): error TS2694: Namespace 'Promise' has no exported member 'Resolver'. -tests/cases/compiler/bluebirdStaticThis.ts(57,109): error TS2694: Namespace 'Promise' has no exported member 'Inspection'. -tests/cases/compiler/bluebirdStaticThis.ts(58,91): error TS2694: Namespace 'Promise' has no exported member 'Inspection'. -tests/cases/compiler/bluebirdStaticThis.ts(59,91): error TS2694: Namespace 'Promise' has no exported member 'Inspection'. -tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2694: Namespace 'Promise' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(22,51): error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Resolver'. +tests/cases/compiler/bluebirdStaticThis.ts(57,109): error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(58,91): error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(59,91): error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Inspection'. ==== tests/cases/compiler/bluebirdStaticThis.ts (6 errors) ==== @@ -12,8 +12,8 @@ tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2694: Namespace 'Prom // and all the comments. // Then it adds explicit `this` arguments to the static members. // Tests by: Bart van der Schoor - declare class Promise implements Promise.Thenable { - ~~~~~~~ + export declare class Promise implements Promise.Thenable { + ~~~~~~~ !!! error TS2420: Class 'Promise' incorrectly implements interface 'Thenable'. !!! error TS2420: Property 'then' is missing in type 'Promise'. constructor(callback: (resolve: (thenableOrResult: R | Promise.Thenable) => void, reject: (error: any) => void) => void); @@ -34,7 +34,7 @@ tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2694: Namespace 'Prom static defer(dit: typeof Promise): Promise.Resolver; ~~~~~~~~ -!!! error TS2694: Namespace 'Promise' has no exported member 'Resolver'. +!!! error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Resolver'. static cast(dit: typeof Promise, value: Promise.Thenable): Promise; static cast(dit: typeof Promise, value: R): Promise; @@ -71,16 +71,16 @@ tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2694: Namespace 'Prom static settle(dit: typeof Promise, values: Promise.Thenable[]>): Promise[]>; ~~~~~~~~~~ -!!! error TS2694: Namespace 'Promise' has no exported member 'Inspection'. +!!! error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Inspection'. static settle(dit: typeof Promise, values: Promise.Thenable): Promise[]>; ~~~~~~~~~~ -!!! error TS2694: Namespace 'Promise' has no exported member 'Inspection'. +!!! error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Inspection'. static settle(dit: typeof Promise, values: Promise.Thenable[]): Promise[]>; ~~~~~~~~~~ -!!! error TS2694: Namespace 'Promise' has no exported member 'Inspection'. +!!! error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Inspection'. static settle(dit: typeof Promise, values: R[]): Promise[]>; ~~~~~~~~~~ -!!! error TS2694: Namespace 'Promise' has no exported member 'Inspection'. +!!! error TS2694: Namespace '"tests/cases/compiler/bluebirdStaticThis".Promise' has no exported member 'Inspection'. static any(dit: typeof Promise, values: Promise.Thenable[]>): Promise; static any(dit: typeof Promise, values: Promise.Thenable): Promise; @@ -131,7 +131,7 @@ tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2694: Namespace 'Prom static filter(dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; } - declare module Promise { + export declare module Promise { export interface Thenable { then(onFulfilled: (value: R) => Thenable, onRejected: (error: any) => Thenable): Thenable; then(onFulfilled: (value: R) => Thenable, onRejected?: (error: any) => U): Thenable; @@ -141,9 +141,6 @@ tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2694: Namespace 'Prom } - declare module 'bluebird' { - export = Promise; - } interface Foo { a: number; b: string; diff --git a/tests/baselines/reference/bluebirdStaticThis.js b/tests/baselines/reference/bluebirdStaticThis.js index 606f778323f..1d8d8f2ec43 100644 --- a/tests/baselines/reference/bluebirdStaticThis.js +++ b/tests/baselines/reference/bluebirdStaticThis.js @@ -3,7 +3,7 @@ // and all the comments. // Then it adds explicit `this` arguments to the static members. // Tests by: Bart van der Schoor -declare class Promise implements Promise.Thenable { +export declare class Promise implements Promise.Thenable { constructor(callback: (resolve: (thenableOrResult: R | Promise.Thenable) => void, reject: (error: any) => void) => void); static try(dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; static try(dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; @@ -109,7 +109,7 @@ declare class Promise implements Promise.Thenable { static filter(dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; } -declare module Promise { +export declare module Promise { export interface Thenable { then(onFulfilled: (value: R) => Thenable, onRejected: (error: any) => Thenable): Thenable; then(onFulfilled: (value: R) => Thenable, onRejected?: (error: any) => U): Thenable; @@ -119,9 +119,6 @@ declare module Promise { } -declare module 'bluebird' { - export = Promise; -} interface Foo { a: number; b: string; @@ -142,6 +139,8 @@ fooProm = Promise.try(Promise, () => { }, arr, x); //// [bluebirdStaticThis.js] +"use strict"; +exports.__esModule = true; var x; var arr; var foo; diff --git a/tests/baselines/reference/cacheResolutions.js b/tests/baselines/reference/cacheResolutions.js index 1d0f918bf98..6b28c90e321 100644 --- a/tests/baselines/reference/cacheResolutions.js +++ b/tests/baselines/reference/cacheResolutions.js @@ -13,15 +13,18 @@ export let x = 1; //// [app.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.x = 1; }); //// [lib1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.x = 1; }); //// [lib2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.x = 1; }); diff --git a/tests/baselines/reference/cachedModuleResolution1.js b/tests/baselines/reference/cachedModuleResolution1.js index 9071b60d6c1..d93133cca40 100644 --- a/tests/baselines/reference/cachedModuleResolution1.js +++ b/tests/baselines/reference/cachedModuleResolution1.js @@ -12,5 +12,7 @@ import {x} from "foo"; //// [app.js] "use strict"; +exports.__esModule = true; //// [lib.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/cachedModuleResolution2.js b/tests/baselines/reference/cachedModuleResolution2.js index 7c84a92abaf..c5c3357f65a 100644 --- a/tests/baselines/reference/cachedModuleResolution2.js +++ b/tests/baselines/reference/cachedModuleResolution2.js @@ -13,5 +13,7 @@ import {x} from "foo"; //// [lib.js] "use strict"; +exports.__esModule = true; //// [app.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/cachedModuleResolution3.js b/tests/baselines/reference/cachedModuleResolution3.js index 032c1afee0e..d476eafd2e8 100644 --- a/tests/baselines/reference/cachedModuleResolution3.js +++ b/tests/baselines/reference/cachedModuleResolution3.js @@ -12,5 +12,7 @@ import {x} from "foo"; //// [app.js] "use strict"; +exports.__esModule = true; //// [lib.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/cachedModuleResolution4.js b/tests/baselines/reference/cachedModuleResolution4.js index 6089de9706b..4cc656d73d3 100644 --- a/tests/baselines/reference/cachedModuleResolution4.js +++ b/tests/baselines/reference/cachedModuleResolution4.js @@ -13,5 +13,7 @@ import {x} from "foo"; //// [lib.js] "use strict"; +exports.__esModule = true; //// [app.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/cachedModuleResolution5.js b/tests/baselines/reference/cachedModuleResolution5.js index 33561e8eae2..35fad11d90e 100644 --- a/tests/baselines/reference/cachedModuleResolution5.js +++ b/tests/baselines/reference/cachedModuleResolution5.js @@ -12,5 +12,7 @@ import {x} from "foo"; //// [app.js] "use strict"; +exports.__esModule = true; //// [lib.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/cachedModuleResolution6.js b/tests/baselines/reference/cachedModuleResolution6.js index f21f491a921..1e6803b115c 100644 --- a/tests/baselines/reference/cachedModuleResolution6.js +++ b/tests/baselines/reference/cachedModuleResolution6.js @@ -9,5 +9,7 @@ import {x} from "foo"; //// [app.js] "use strict"; +exports.__esModule = true; //// [lib.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/cachedModuleResolution7.js b/tests/baselines/reference/cachedModuleResolution7.js index 8b86dcd55af..044eefff73a 100644 --- a/tests/baselines/reference/cachedModuleResolution7.js +++ b/tests/baselines/reference/cachedModuleResolution7.js @@ -10,5 +10,7 @@ import {x} from "foo"; //// [lib.js] "use strict"; +exports.__esModule = true; //// [app.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/cachedModuleResolution8.js b/tests/baselines/reference/cachedModuleResolution8.js index 1c00b171f21..fe89a8f288f 100644 --- a/tests/baselines/reference/cachedModuleResolution8.js +++ b/tests/baselines/reference/cachedModuleResolution8.js @@ -9,5 +9,7 @@ import {x} from "foo"; //// [app.js] "use strict"; +exports.__esModule = true; //// [lib.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/cachedModuleResolution9.js b/tests/baselines/reference/cachedModuleResolution9.js index 32f8848736c..c27ababcb95 100644 --- a/tests/baselines/reference/cachedModuleResolution9.js +++ b/tests/baselines/reference/cachedModuleResolution9.js @@ -11,5 +11,7 @@ import {x} from "foo"; //// [lib.js] "use strict"; +exports.__esModule = true; //// [app.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js index 0ae7648c7f9..a71613bc545 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js @@ -71,11 +71,16 @@ interface I extends A { //// [callSignatureAssignabilityInInheritance2.js] // checking subtype relations for function types as it relates to contextual signature instantiation -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -84,21 +89,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js index 7a7791280ad..7f9d616281b 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js @@ -116,11 +116,16 @@ module Errors { //// [callSignatureAssignabilityInInheritance3.js] // checking subtype relations for function types as it relates to contextual signature instantiation // error cases -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Errors; (function (Errors) { var Base = (function () { @@ -131,21 +136,21 @@ var Errors; var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js index 19d66ce8d46..6c5d7508fc9 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js @@ -51,11 +51,16 @@ interface I extends A { //// [callSignatureAssignabilityInInheritance4.js] // checking subtype relations for function types as it relates to contextual signature instantiation -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -64,21 +69,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js index 1c53de5d26e..fe260d62119 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js @@ -51,11 +51,16 @@ interface I extends B { //// [callSignatureAssignabilityInInheritance5.js] // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithCallSignatures2 just with an extra level of indirection in the inheritance chain -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -64,21 +69,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js index c42e36389ca..c6054d2411d 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js @@ -54,11 +54,16 @@ interface I9 extends A { // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithCallSignatures4 but using class type parameters instead of generic signatures // all are errors -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -67,21 +72,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types index 0b515750aec..658eff38bbb 100644 --- a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types +++ b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types @@ -103,17 +103,17 @@ var r6 = foo6(1); >1 : 1 function foo7(x) { ->foo7 : (x: any) => string +>foo7 : (x: any) => "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : any return typeof x; ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : any } var r7 = foo7(1); ->r7 : string ->foo7(1) : string ->foo7 : (x: any) => string +>r7 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>foo7(1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>foo7 : (x: any) => "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >1 : 1 // object types diff --git a/tests/baselines/reference/callWithSpread.js b/tests/baselines/reference/callWithSpread.js index 69f7e4e30b0..23c1fff2d09 100644 --- a/tests/baselines/reference/callWithSpread.js +++ b/tests/baselines/reference/callWithSpread.js @@ -59,11 +59,16 @@ class D extends C { //// [callWithSpread.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function foo(x, y) { var z = []; for (var _i = 2; _i < arguments.length; _i++) { diff --git a/tests/baselines/reference/captureSuperPropertyAccessInSuperCall01.js b/tests/baselines/reference/captureSuperPropertyAccessInSuperCall01.js index 4f350c1a3a3..98ca7cb47d7 100644 --- a/tests/baselines/reference/captureSuperPropertyAccessInSuperCall01.js +++ b/tests/baselines/reference/captureSuperPropertyAccessInSuperCall01.js @@ -12,11 +12,16 @@ class B extends A { } //// [captureSuperPropertyAccessInSuperCall01.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(f) { } diff --git a/tests/baselines/reference/captureThisInSuperCall.js b/tests/baselines/reference/captureThisInSuperCall.js index 069871f598e..ccca2e6562f 100644 --- a/tests/baselines/reference/captureThisInSuperCall.js +++ b/tests/baselines/reference/captureThisInSuperCall.js @@ -9,11 +9,16 @@ class B extends A { } //// [captureThisInSuperCall.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(p) { } diff --git a/tests/baselines/reference/capturedLetConstInLoop13.js b/tests/baselines/reference/capturedLetConstInLoop13.js new file mode 100644 index 00000000000..a2e0921ab1d --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop13.js @@ -0,0 +1,52 @@ +//// [capturedLetConstInLoop13.ts] +class Main { + + constructor() { + this.register("a", "b", "c"); + } + + private register(...names: string[]): void { + for (let name of names) { + + this.bar({ + [name + ".a"]: () => { this.foo(name); }, + }); + } + } + + private bar(a: any): void { } + + private foo(name: string): void { } + +} + +new Main(); + +//// [capturedLetConstInLoop13.js] +var Main = (function () { + function Main() { + this.register("a", "b", "c"); + } + Main.prototype.register = function () { + var _this = this; + var names = []; + for (var _i = 0; _i < arguments.length; _i++) { + names[_i] = arguments[_i]; + } + var _loop_1 = function (name) { + this_1.bar((_a = {}, + _a[name + ".a"] = function () { _this.foo(name); }, + _a)); + var _a; + }; + var this_1 = this; + for (var _a = 0, names_1 = names; _a < names_1.length; _a++) { + var name = names_1[_a]; + _loop_1(name); + } + }; + Main.prototype.bar = function (a) { }; + Main.prototype.foo = function (name) { }; + return Main; +}()); +new Main(); diff --git a/tests/baselines/reference/capturedLetConstInLoop13.symbols b/tests/baselines/reference/capturedLetConstInLoop13.symbols new file mode 100644 index 00000000000..c7a824d26fa --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop13.symbols @@ -0,0 +1,48 @@ +=== tests/cases/compiler/capturedLetConstInLoop13.ts === +class Main { +>Main : Symbol(Main, Decl(capturedLetConstInLoop13.ts, 0, 0)) + + constructor() { + this.register("a", "b", "c"); +>this.register : Symbol(Main.register, Decl(capturedLetConstInLoop13.ts, 4, 5)) +>this : Symbol(Main, Decl(capturedLetConstInLoop13.ts, 0, 0)) +>register : Symbol(Main.register, Decl(capturedLetConstInLoop13.ts, 4, 5)) + } + + private register(...names: string[]): void { +>register : Symbol(Main.register, Decl(capturedLetConstInLoop13.ts, 4, 5)) +>names : Symbol(names, Decl(capturedLetConstInLoop13.ts, 6, 21)) + + for (let name of names) { +>name : Symbol(name, Decl(capturedLetConstInLoop13.ts, 7, 16)) +>names : Symbol(names, Decl(capturedLetConstInLoop13.ts, 6, 21)) + + this.bar({ +>this.bar : Symbol(Main.bar, Decl(capturedLetConstInLoop13.ts, 13, 5)) +>this : Symbol(Main, Decl(capturedLetConstInLoop13.ts, 0, 0)) +>bar : Symbol(Main.bar, Decl(capturedLetConstInLoop13.ts, 13, 5)) + + [name + ".a"]: () => { this.foo(name); }, +>name : Symbol(name, Decl(capturedLetConstInLoop13.ts, 7, 16)) +>this.foo : Symbol(Main.foo, Decl(capturedLetConstInLoop13.ts, 15, 33)) +>this : Symbol(Main, Decl(capturedLetConstInLoop13.ts, 0, 0)) +>foo : Symbol(Main.foo, Decl(capturedLetConstInLoop13.ts, 15, 33)) +>name : Symbol(name, Decl(capturedLetConstInLoop13.ts, 7, 16)) + + }); + } + } + + private bar(a: any): void { } +>bar : Symbol(Main.bar, Decl(capturedLetConstInLoop13.ts, 13, 5)) +>a : Symbol(a, Decl(capturedLetConstInLoop13.ts, 15, 16)) + + private foo(name: string): void { } +>foo : Symbol(Main.foo, Decl(capturedLetConstInLoop13.ts, 15, 33)) +>name : Symbol(name, Decl(capturedLetConstInLoop13.ts, 17, 16)) + +} + +new Main(); +>Main : Symbol(Main, Decl(capturedLetConstInLoop13.ts, 0, 0)) + diff --git a/tests/baselines/reference/capturedLetConstInLoop13.types b/tests/baselines/reference/capturedLetConstInLoop13.types new file mode 100644 index 00000000000..e6f97255d75 --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop13.types @@ -0,0 +1,59 @@ +=== tests/cases/compiler/capturedLetConstInLoop13.ts === +class Main { +>Main : Main + + constructor() { + this.register("a", "b", "c"); +>this.register("a", "b", "c") : void +>this.register : (...names: string[]) => void +>this : this +>register : (...names: string[]) => void +>"a" : "a" +>"b" : "b" +>"c" : "c" + } + + private register(...names: string[]): void { +>register : (...names: string[]) => void +>names : string[] + + for (let name of names) { +>name : string +>names : string[] + + this.bar({ +>this.bar({ [name + ".a"]: () => { this.foo(name); }, }) : void +>this.bar : (a: any) => void +>this : this +>bar : (a: any) => void +>{ [name + ".a"]: () => { this.foo(name); }, } : { [x: string]: () => void; } + + [name + ".a"]: () => { this.foo(name); }, +>name + ".a" : string +>name : string +>".a" : ".a" +>() => { this.foo(name); } : () => void +>this.foo(name) : void +>this.foo : (name: string) => void +>this : this +>foo : (name: string) => void +>name : string + + }); + } + } + + private bar(a: any): void { } +>bar : (a: any) => void +>a : any + + private foo(name: string): void { } +>foo : (name: string) => void +>name : string + +} + +new Main(); +>new Main() : Main +>Main : typeof Main + diff --git a/tests/baselines/reference/castExpressionParentheses.types b/tests/baselines/reference/castExpressionParentheses.types index dafe3377aea..aa633825eec 100644 --- a/tests/baselines/reference/castExpressionParentheses.types +++ b/tests/baselines/reference/castExpressionParentheses.types @@ -182,7 +182,7 @@ declare var A; >(typeof A).x : any >(typeof A) : any >typeof A : any ->typeof A : string +>typeof A : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >A : any >x : any diff --git a/tests/baselines/reference/castOfAwait.types b/tests/baselines/reference/castOfAwait.types index 30220ca2ab6..afe075b67d9 100644 --- a/tests/baselines/reference/castOfAwait.types +++ b/tests/baselines/reference/castOfAwait.types @@ -8,7 +8,7 @@ async function f() { >0 : 0 typeof await 0; ->typeof await 0 : string +>typeof await 0 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >await 0 : 0 >0 : 0 @@ -18,10 +18,10 @@ async function f() { >0 : 0 await void typeof void await 0; ->await void typeof void await 0 : any +>await void typeof void await 0 : undefined >void typeof void await 0 : undefined > typeof void await 0 : string ->typeof void await 0 : string +>typeof void await 0 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" > void await 0 : number >void await 0 : undefined >await 0 : 0 diff --git a/tests/baselines/reference/castOfYield.errors.txt b/tests/baselines/reference/castOfYield.errors.txt index abafe678784..0d40a4dcd98 100644 --- a/tests/baselines/reference/castOfYield.errors.txt +++ b/tests/baselines/reference/castOfYield.errors.txt @@ -1,6 +1,8 @@ +error TS2318: Cannot find global type 'IterableIterator'. tests/cases/compiler/castOfYield.ts(4,14): error TS1109: Expression expected. +!!! error TS2318: Cannot find global type 'IterableIterator'. ==== tests/cases/compiler/castOfYield.ts (1 errors) ==== function* f() { (yield 0); diff --git a/tests/baselines/reference/castOfYield.js b/tests/baselines/reference/castOfYield.js index 633f780a6a1..9ad9ec52a31 100644 --- a/tests/baselines/reference/castOfYield.js +++ b/tests/baselines/reference/castOfYield.js @@ -7,9 +7,45 @@ function* f() { //// [castOfYield.js] -function* f() { - (yield 0); - // Unlike await, yield is not allowed to appear in a simple unary expression. - ; - yield 0; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +function f() { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, 0]; + case 1: + (_a.sent()); + // Unlike await, yield is not allowed to appear in a simple unary expression. + ; + return [4 /*yield*/, 0]; + case 2: + _a.sent(); + return [2 /*return*/]; + } + }); } diff --git a/tests/baselines/reference/castingTuple.js b/tests/baselines/reference/castingTuple.js index f0178dcbbf0..fea3bd9a238 100644 --- a/tests/baselines/reference/castingTuple.js +++ b/tests/baselines/reference/castingTuple.js @@ -33,11 +33,16 @@ t4[2] = 10; //// [castingTuple.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { this.a = 10; @@ -59,7 +64,7 @@ var D = (function () { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(A)); @@ -67,7 +72,7 @@ var E = (function (_super) { var F = (function (_super) { __extends(F, _super); function F() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return F; }(A)); diff --git a/tests/baselines/reference/chainedAssignment3.js b/tests/baselines/reference/chainedAssignment3.js index 3857867043c..c85845f6d35 100644 --- a/tests/baselines/reference/chainedAssignment3.js +++ b/tests/baselines/reference/chainedAssignment3.js @@ -23,11 +23,16 @@ a = b = new A(); //// [chainedAssignment3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -36,7 +41,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js index 26d341e1f6a..99bd90139ae 100644 --- a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js +++ b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.js @@ -20,11 +20,16 @@ class C extends B { (new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A); //// [chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Chain = (function () { function Chain(value) { this.value = value; @@ -42,14 +47,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); diff --git a/tests/baselines/reference/chainedImportAlias.js b/tests/baselines/reference/chainedImportAlias.js index a6113d5f241..8fcdd501707 100644 --- a/tests/baselines/reference/chainedImportAlias.js +++ b/tests/baselines/reference/chainedImportAlias.js @@ -13,6 +13,7 @@ y.m.foo(); //// [chainedImportAlias_file0.js] "use strict"; +exports.__esModule = true; var m; (function (m) { function foo() { } @@ -20,6 +21,7 @@ var m; })(m = exports.m || (exports.m = {})); //// [chainedImportAlias_file1.js] "use strict"; +exports.__esModule = true; var x = require("./chainedImportAlias_file0"); var y = x; y.m.foo(); diff --git a/tests/baselines/reference/checkForObjectTooStrict.js b/tests/baselines/reference/checkForObjectTooStrict.js index ade99e9319b..6d330285f6e 100644 --- a/tests/baselines/reference/checkForObjectTooStrict.js +++ b/tests/baselines/reference/checkForObjectTooStrict.js @@ -32,11 +32,16 @@ class Baz extends Object { //// [checkForObjectTooStrict.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo; (function (Foo) { var Object = (function () { diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing1.js b/tests/baselines/reference/checkSuperCallBeforeThisAccessing1.js index 8ced6fce500..40717cb4759 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing1.js +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing1.js @@ -11,11 +11,16 @@ class Derived extends Based { } //// [checkSuperCallBeforeThisAccessing1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Based = (function () { function Based() { } diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing2.js b/tests/baselines/reference/checkSuperCallBeforeThisAccessing2.js index 95b34f27b68..bbe56823ee5 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing2.js +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing2.js @@ -11,11 +11,16 @@ class Derived extends Based { } //// [checkSuperCallBeforeThisAccessing2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Based = (function () { function Based() { } @@ -24,7 +29,7 @@ var Based = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this; + var _this = this; _this.x = 100; _this = _super.call(this) || this; _this.x = 10; diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.js b/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.js index 0e882f71fdb..dc7e0309ab6 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.js +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.js @@ -16,11 +16,16 @@ class Derived extends Based { } //// [checkSuperCallBeforeThisAccessing3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Based = (function () { function Based() { } @@ -29,7 +34,7 @@ var Based = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this; + var _this = this; var innver = (function () { function innver() { this.y = true; diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing4.js b/tests/baselines/reference/checkSuperCallBeforeThisAccessing4.js index 00f2ed22fbf..b8240b27aea 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing4.js +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing4.js @@ -20,11 +20,16 @@ class Derived extends Based { } //// [checkSuperCallBeforeThisAccessing4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Based = (function () { function Based() { } @@ -33,7 +38,7 @@ var Based = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this; + var _this = this; (function () { _this; // No error }); diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing5.js b/tests/baselines/reference/checkSuperCallBeforeThisAccessing5.js index ded73f57baf..9936c7d97dc 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing5.js +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing5.js @@ -8,11 +8,16 @@ class Derived extends Based { } //// [checkSuperCallBeforeThisAccessing5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Based = (function () { function Based() { var arg = []; diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing6.js b/tests/baselines/reference/checkSuperCallBeforeThisAccessing6.js index 782e3236271..a40791a4eba 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing6.js +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing6.js @@ -11,11 +11,16 @@ class Super extends Base { } //// [checkSuperCallBeforeThisAccessing6.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { var arg = []; @@ -28,7 +33,7 @@ var Base = (function () { var Super = (function (_super) { __extends(Super, _super); function Super() { - var _this; + var _this = this; (function () { return _this; }); // No Error _this = _super.call(this) || this; return _this; diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing7.js b/tests/baselines/reference/checkSuperCallBeforeThisAccessing7.js index 364aed4d4b0..4cb05a35aa0 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing7.js +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing7.js @@ -10,11 +10,16 @@ class Super extends Base { } //// [checkSuperCallBeforeThisAccessing7.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(func) { } diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing8.js b/tests/baselines/reference/checkSuperCallBeforeThisAccessing8.js index 5dd3708a3bb..92f13921d2a 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing8.js +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing8.js @@ -11,11 +11,16 @@ class Super extends Base { } //// [checkSuperCallBeforeThisAccessing8.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { var arg = []; @@ -28,7 +33,7 @@ var Base = (function () { var Super = (function (_super) { __extends(Super, _super); function Super() { - var _this; + var _this = this; var that = _this; _this = _super.call(this) || this; return _this; diff --git a/tests/baselines/reference/circularImportAlias.js b/tests/baselines/reference/circularImportAlias.js index 6fe5e604e57..7c05d6dc3d3 100644 --- a/tests/baselines/reference/circularImportAlias.js +++ b/tests/baselines/reference/circularImportAlias.js @@ -21,18 +21,23 @@ var c = new B.a.C(); //// [circularImportAlias.js] // expected no error -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B; (function (B) { B.a = A; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(B.a.C)); diff --git a/tests/baselines/reference/circularIndexedAccessErrors.errors.txt b/tests/baselines/reference/circularIndexedAccessErrors.errors.txt index e3076e08b7e..f76cfca073e 100644 --- a/tests/baselines/reference/circularIndexedAccessErrors.errors.txt +++ b/tests/baselines/reference/circularIndexedAccessErrors.errors.txt @@ -1,14 +1,12 @@ tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(3,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(7,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. -tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(15,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(19,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(23,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. -tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(27,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. -tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(28,5): error TS2502: 'y' is referenced directly or indirectly in its own type annotation. -tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(29,5): error TS2502: 'z' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(38,24): error TS2313: Type parameter 'T' has a circular constraint. +tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(38,30): error TS2536: Type '"hello"' cannot be used to index type 'T'. -==== tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts (8 errors) ==== +==== tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts (6 errors) ==== type T1 = { x: T1["x"]; // Error @@ -27,9 +25,7 @@ tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(29,5): error let x2x = x2.x; interface T3> { - x: T["x"]; // Error - ~~~~~~~~~~ -!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation. + x: T["x"]; } interface T4> { @@ -45,13 +41,21 @@ tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(29,5): error } class C2 { - x: this["y"]; // Error - ~~~~~~~~~~~~~ -!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation. - y: this["z"]; // Error - ~~~~~~~~~~~~~ -!!! error TS2502: 'y' is referenced directly or indirectly in its own type annotation. - z: this["x"]; // Error - ~~~~~~~~~~~~~ -!!! error TS2502: 'z' is referenced directly or indirectly in its own type annotation. - } \ No newline at end of file + x: this["y"]; + y: this["z"]; + z: this["x"]; + } + + // Repro from #12627 + + interface Foo { + hello: boolean; + } + + function foo() { + ~~~~~~~~~~~~~~~~ +!!! error TS2313: Type parameter 'T' has a circular constraint. + ~~~~~~~~~~ +!!! error TS2536: Type '"hello"' cannot be used to index type 'T'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/circularIndexedAccessErrors.js b/tests/baselines/reference/circularIndexedAccessErrors.js index 46784ae8d18..97d059bce19 100644 --- a/tests/baselines/reference/circularIndexedAccessErrors.js +++ b/tests/baselines/reference/circularIndexedAccessErrors.js @@ -13,7 +13,7 @@ declare let x2: T2<"x">; let x2x = x2.x; interface T3> { - x: T["x"]; // Error + x: T["x"]; } interface T4> { @@ -25,10 +25,20 @@ class C1 { } class C2 { - x: this["y"]; // Error - y: this["z"]; // Error - z: this["x"]; // Error -} + x: this["y"]; + y: this["z"]; + z: this["x"]; +} + +// Repro from #12627 + +interface Foo { + hello: boolean; +} + +function foo() { +} + //// [circularIndexedAccessErrors.js] var x2x = x2.x; @@ -42,6 +52,8 @@ var C2 = (function () { } return C2; }()); +function foo() { +} //// [circularIndexedAccessErrors.d.ts] @@ -68,3 +80,7 @@ declare class C2 { y: this["z"]; z: this["x"]; } +interface Foo { + hello: boolean; +} +declare function foo(): void; diff --git a/tests/baselines/reference/circularReference.js b/tests/baselines/reference/circularReference.js index 193b3e1da07..198a886f026 100644 --- a/tests/baselines/reference/circularReference.js +++ b/tests/baselines/reference/circularReference.js @@ -35,6 +35,7 @@ export module M1 { //// [foo1.js] "use strict"; +exports.__esModule = true; var foo2 = require("./foo2"); var M1; (function (M1) { @@ -50,6 +51,7 @@ var M1; })(M1 = exports.M1 || (exports.M1 = {})); //// [foo2.js] "use strict"; +exports.__esModule = true; var foo1 = require("./foo1"); var M1; (function (M1) { diff --git a/tests/baselines/reference/circularReferenceInImport.js b/tests/baselines/reference/circularReferenceInImport.js index a9cf0925c34..8b49f45dbd2 100644 --- a/tests/baselines/reference/circularReferenceInImport.js +++ b/tests/baselines/reference/circularReferenceInImport.js @@ -17,6 +17,7 @@ export function foo() { //// [app.js] "use strict"; +exports.__esModule = true; function foo() { return new Object(); } diff --git a/tests/baselines/reference/circularTypeofWithFunctionModule.js b/tests/baselines/reference/circularTypeofWithFunctionModule.js index 1c38b9625e3..a94de5d55e2 100644 --- a/tests/baselines/reference/circularTypeofWithFunctionModule.js +++ b/tests/baselines/reference/circularTypeofWithFunctionModule.js @@ -14,11 +14,16 @@ namespace maker { //// [circularTypeofWithFunctionModule.js] // Repro from #6072 -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -31,7 +36,7 @@ function maker(value) { var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar; }(Foo)); diff --git a/tests/baselines/reference/classAbstractConstructorAssignability.js b/tests/baselines/reference/classAbstractConstructorAssignability.js index 35d9e75884f..5df6d169e04 100644 --- a/tests/baselines/reference/classAbstractConstructorAssignability.js +++ b/tests/baselines/reference/classAbstractConstructorAssignability.js @@ -15,11 +15,16 @@ new BB; new CC; //// [classAbstractConstructorAssignability.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -28,14 +33,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); diff --git a/tests/baselines/reference/classAbstractCrashedOnce.js b/tests/baselines/reference/classAbstractCrashedOnce.js index fe23e60c94f..7801b61cdd9 100644 --- a/tests/baselines/reference/classAbstractCrashedOnce.js +++ b/tests/baselines/reference/classAbstractCrashedOnce.js @@ -11,11 +11,16 @@ class bar extends foo { var x = new bar(); //// [classAbstractCrashedOnce.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var foo = (function () { function foo() { } @@ -24,7 +29,7 @@ var foo = (function () { var bar = (function (_super) { __extends(bar, _super); function bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } bar.prototype.test = function () { this. diff --git a/tests/baselines/reference/classAbstractExtends.js b/tests/baselines/reference/classAbstractExtends.js index e899cb82d6d..69c962509db 100644 --- a/tests/baselines/reference/classAbstractExtends.js +++ b/tests/baselines/reference/classAbstractExtends.js @@ -17,11 +17,16 @@ class E extends B { } //// [classAbstractExtends.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -31,28 +36,28 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(B)); var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.prototype.bar = function () { }; return E; diff --git a/tests/baselines/reference/classAbstractFactoryFunction.js b/tests/baselines/reference/classAbstractFactoryFunction.js index 50e232a9fca..abc3235a3d3 100644 --- a/tests/baselines/reference/classAbstractFactoryFunction.js +++ b/tests/baselines/reference/classAbstractFactoryFunction.js @@ -18,11 +18,16 @@ NewB(A); NewB(B); //// [classAbstractFactoryFunction.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -31,7 +36,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/classAbstractGeneric.js b/tests/baselines/reference/classAbstractGeneric.js index 96df8f5f19e..6d20869ba73 100644 --- a/tests/baselines/reference/classAbstractGeneric.js +++ b/tests/baselines/reference/classAbstractGeneric.js @@ -26,11 +26,16 @@ class G extends A { } //// [classAbstractGeneric.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -39,28 +44,28 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); // error -- inherits abstract methods var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(A)); // error -- inherits abstract methods var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.prototype.foo = function () { return this.t; }; return E; @@ -68,7 +73,7 @@ var E = (function (_super) { var F = (function (_super) { __extends(F, _super); function F() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } F.prototype.bar = function (t) { }; return F; @@ -76,7 +81,7 @@ var F = (function (_super) { var G = (function (_super) { __extends(G, _super); function G() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } G.prototype.foo = function () { return this.t; }; G.prototype.bar = function (t) { }; diff --git a/tests/baselines/reference/classAbstractInAModule.js b/tests/baselines/reference/classAbstractInAModule.js index c6a9e206bcc..4bbe7a40dc5 100644 --- a/tests/baselines/reference/classAbstractInAModule.js +++ b/tests/baselines/reference/classAbstractInAModule.js @@ -8,11 +8,16 @@ new M.A; new M.B; //// [classAbstractInAModule.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M; (function (M) { var A = (function () { @@ -24,7 +29,7 @@ var M; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/classAbstractInheritance.js b/tests/baselines/reference/classAbstractInheritance.js index 297a80dd99c..a39ef662d76 100644 --- a/tests/baselines/reference/classAbstractInheritance.js +++ b/tests/baselines/reference/classAbstractInheritance.js @@ -22,11 +22,16 @@ class FF extends CC {} abstract class GG extends CC {} //// [classAbstractInheritance.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -35,14 +40,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); @@ -54,42 +59,42 @@ var AA = (function () { var BB = (function (_super) { __extends(BB, _super); function BB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return BB; }(AA)); var CC = (function (_super) { __extends(CC, _super); function CC() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return CC; }(AA)); var DD = (function (_super) { __extends(DD, _super); function DD() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return DD; }(BB)); var EE = (function (_super) { __extends(EE, _super); function EE() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return EE; }(BB)); var FF = (function (_super) { __extends(FF, _super); function FF() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return FF; }(CC)); var GG = (function (_super) { __extends(GG, _super); function GG() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return GG; }(CC)); diff --git a/tests/baselines/reference/classAbstractInstantiations1.js b/tests/baselines/reference/classAbstractInstantiations1.js index 5abbb9c1baa..6722665b62d 100644 --- a/tests/baselines/reference/classAbstractInstantiations1.js +++ b/tests/baselines/reference/classAbstractInstantiations1.js @@ -28,11 +28,16 @@ c = new B; // // Calling new with (non)abstract classes. // -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -41,14 +46,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); diff --git a/tests/baselines/reference/classAbstractInstantiations2.js b/tests/baselines/reference/classAbstractInstantiations2.js index dea4c744ae0..7d400c9fb05 100644 --- a/tests/baselines/reference/classAbstractInstantiations2.js +++ b/tests/baselines/reference/classAbstractInstantiations2.js @@ -52,11 +52,16 @@ class H { // error -- not declared abstract } //// [classAbstractInstantiations2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -82,21 +87,21 @@ new x; // okay -- undefined behavior at runtime var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); // error -- not declared abstract var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(B)); // okay var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.prototype.bar = function () { return 1; }; return E; @@ -104,7 +109,7 @@ var E = (function (_super) { var F = (function (_super) { __extends(F, _super); function F() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } F.prototype.bar = function () { return 2; }; return F; diff --git a/tests/baselines/reference/classAbstractOverrideWithAbstract.js b/tests/baselines/reference/classAbstractOverrideWithAbstract.js index 4ecebdf7b32..496dc7f241a 100644 --- a/tests/baselines/reference/classAbstractOverrideWithAbstract.js +++ b/tests/baselines/reference/classAbstractOverrideWithAbstract.js @@ -24,11 +24,16 @@ class DD extends BB { } //// [classAbstractOverrideWithAbstract.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -38,7 +43,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -51,7 +56,7 @@ var AA = (function () { var BB = (function (_super) { __extends(BB, _super); function BB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } BB.prototype.bar = function () { }; return BB; @@ -59,14 +64,14 @@ var BB = (function (_super) { var CC = (function (_super) { __extends(CC, _super); function CC() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return CC; }(BB)); // error var DD = (function (_super) { __extends(DD, _super); function DD() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } DD.prototype.foo = function () { }; return DD; diff --git a/tests/baselines/reference/classAbstractSuperCalls.js b/tests/baselines/reference/classAbstractSuperCalls.js index 0197f48a429..125f5b3883f 100644 --- a/tests/baselines/reference/classAbstractSuperCalls.js +++ b/tests/baselines/reference/classAbstractSuperCalls.js @@ -28,11 +28,16 @@ abstract class BB extends AA { //// [classAbstractSuperCalls.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -42,7 +47,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function () { _super.prototype.foo.call(this); }; B.prototype.baz = function () { return this.foo; }; @@ -51,7 +56,7 @@ var B = (function (_super) { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.foo = function () { return 2; }; C.prototype.qux = function () { return _super.prototype.foo.call(this) || _super.prototype.foo; }; // 2 errors, foo is abstract @@ -68,7 +73,7 @@ var AA = (function () { var BB = (function (_super) { __extends(BB, _super); function BB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return BB; }(AA)); diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethod1.js b/tests/baselines/reference/classAbstractUsingAbstractMethod1.js index 74b5d62aaf5..8781fc6c05f 100644 --- a/tests/baselines/reference/classAbstractUsingAbstractMethod1.js +++ b/tests/baselines/reference/classAbstractUsingAbstractMethod1.js @@ -18,11 +18,16 @@ a = new C; // error, cannot instantiate abstract class. a.foo(); //// [classAbstractUsingAbstractMethod1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -31,7 +36,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.foo = function () { return 1; }; return B; @@ -39,7 +44,7 @@ var B = (function (_super) { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethods2.js b/tests/baselines/reference/classAbstractUsingAbstractMethods2.js index 25cf1a307c7..6016ab249f1 100644 --- a/tests/baselines/reference/classAbstractUsingAbstractMethods2.js +++ b/tests/baselines/reference/classAbstractUsingAbstractMethods2.js @@ -28,11 +28,16 @@ class DD extends AA { } //// [classAbstractUsingAbstractMethods2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -41,21 +46,21 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.foo = function () { }; return D; @@ -63,7 +68,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.prototype.foo = function () { }; return E; @@ -76,21 +81,21 @@ var AA = (function () { var BB = (function (_super) { __extends(BB, _super); function BB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return BB; }(AA)); var CC = (function (_super) { __extends(CC, _super); function CC() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return CC; }(AA)); var DD = (function (_super) { __extends(DD, _super); function DD() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } DD.prototype.foo = function () { }; return DD; diff --git a/tests/baselines/reference/classConstructorAccessibility2.js b/tests/baselines/reference/classConstructorAccessibility2.js index ef637611e8d..7c77d13dffb 100644 --- a/tests/baselines/reference/classConstructorAccessibility2.js +++ b/tests/baselines/reference/classConstructorAccessibility2.js @@ -47,11 +47,16 @@ var dc = new DerivedC(1); //// [classConstructorAccessibility2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var BaseA = (function () { function BaseA(x) { this.x = x; diff --git a/tests/baselines/reference/classConstructorAccessibility4.js b/tests/baselines/reference/classConstructorAccessibility4.js index 4772ac68d11..f6370729971 100644 --- a/tests/baselines/reference/classConstructorAccessibility4.js +++ b/tests/baselines/reference/classConstructorAccessibility4.js @@ -31,11 +31,16 @@ class D { } //// [classConstructorAccessibility4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -51,7 +56,7 @@ var A = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); @@ -73,7 +78,7 @@ var D = (function () { var F = (function (_super) { __extends(F, _super); function F() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return F; }(D)); diff --git a/tests/baselines/reference/classConstructorAccessibility5.js b/tests/baselines/reference/classConstructorAccessibility5.js index d658349c2a5..d409265d89d 100644 --- a/tests/baselines/reference/classConstructorAccessibility5.js +++ b/tests/baselines/reference/classConstructorAccessibility5.js @@ -12,11 +12,16 @@ class Unrelated { //// [classConstructorAccessibility5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -25,7 +30,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.make = function () { new Base(); }; // ok return Derived; diff --git a/tests/baselines/reference/classConstructorParametersAccessibility.js b/tests/baselines/reference/classConstructorParametersAccessibility.js index e0e75bcfeeb..497f662a8b0 100644 --- a/tests/baselines/reference/classConstructorParametersAccessibility.js +++ b/tests/baselines/reference/classConstructorParametersAccessibility.js @@ -27,11 +27,16 @@ class Derived extends C3 { //// [classConstructorParametersAccessibility.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1(x) { this.x = x; diff --git a/tests/baselines/reference/classConstructorParametersAccessibility2.js b/tests/baselines/reference/classConstructorParametersAccessibility2.js index 84da66c3e3c..7a885bbd8d6 100644 --- a/tests/baselines/reference/classConstructorParametersAccessibility2.js +++ b/tests/baselines/reference/classConstructorParametersAccessibility2.js @@ -27,11 +27,16 @@ class Derived extends C3 { //// [classConstructorParametersAccessibility2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1(x) { this.x = x; diff --git a/tests/baselines/reference/classConstructorParametersAccessibility3.js b/tests/baselines/reference/classConstructorParametersAccessibility3.js index db9f94cf0fb..f96f0171046 100644 --- a/tests/baselines/reference/classConstructorParametersAccessibility3.js +++ b/tests/baselines/reference/classConstructorParametersAccessibility3.js @@ -14,11 +14,16 @@ var d: Derived; d.p; // public, OK //// [classConstructorParametersAccessibility3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(p) { this.p = p; diff --git a/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.js b/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.js index 5a5440a92b5..4a0edb610d5 100644 --- a/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.js +++ b/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.js @@ -12,11 +12,16 @@ module M { } //// [classDeclarationMergedInModuleWithContinuation.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M; (function (M) { var N = (function () { @@ -33,7 +38,7 @@ var M; var O = (function (_super) { __extends(O, _super); function O() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return O; }(M.N)); diff --git a/tests/baselines/reference/classDeclaredBeforeClassFactory.js b/tests/baselines/reference/classDeclaredBeforeClassFactory.js index 3dd1e7a4aaf..40cfd576644 100644 --- a/tests/baselines/reference/classDeclaredBeforeClassFactory.js +++ b/tests/baselines/reference/classDeclaredBeforeClassFactory.js @@ -8,16 +8,21 @@ function makeBaseClass() { //// [classDeclaredBeforeClassFactory.js] -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // Should be OK due to hoisting var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(makeBaseClass())); diff --git a/tests/baselines/reference/classDoesNotDependOnBaseTypes.js b/tests/baselines/reference/classDoesNotDependOnBaseTypes.js index 076412e164d..c1642125fe9 100644 --- a/tests/baselines/reference/classDoesNotDependOnBaseTypes.js +++ b/tests/baselines/reference/classDoesNotDependOnBaseTypes.js @@ -13,11 +13,16 @@ class StringTreeCollectionBase { class StringTreeCollection extends StringTreeCollectionBase { } //// [classDoesNotDependOnBaseTypes.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x; if (typeof x !== "string") { x[0] = ""; @@ -31,7 +36,7 @@ var StringTreeCollectionBase = (function () { var StringTreeCollection = (function (_super) { __extends(StringTreeCollection, _super); function StringTreeCollection() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return StringTreeCollection; }(StringTreeCollectionBase)); diff --git a/tests/baselines/reference/classDoesNotDependOnBaseTypes.types b/tests/baselines/reference/classDoesNotDependOnBaseTypes.types index 5ac20c6e0fa..54b67dfd6a7 100644 --- a/tests/baselines/reference/classDoesNotDependOnBaseTypes.types +++ b/tests/baselines/reference/classDoesNotDependOnBaseTypes.types @@ -5,7 +5,7 @@ var x: StringTree; if (typeof x !== "string") { >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : StringTree >"string" : "string" diff --git a/tests/baselines/reference/classExpression2.js b/tests/baselines/reference/classExpression2.js index 59b62c60cfe..7f48463e81a 100644 --- a/tests/baselines/reference/classExpression2.js +++ b/tests/baselines/reference/classExpression2.js @@ -3,11 +3,16 @@ class D { } var v = class C extends D {}; //// [classExpression2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var D = (function () { function D() { } @@ -16,7 +21,7 @@ var D = (function () { var v = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(D)); diff --git a/tests/baselines/reference/classExpression3.js b/tests/baselines/reference/classExpression3.js index c0376c54c27..2582aa80398 100644 --- a/tests/baselines/reference/classExpression3.js +++ b/tests/baselines/reference/classExpression3.js @@ -7,15 +7,20 @@ c.c; //// [classExpression3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(class_1, _super); function class_1() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.c = 3; return _this; } @@ -23,7 +28,7 @@ var C = (function (_super) { }((function (_super) { __extends(class_2, _super); function class_2() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.b = 2; return _this; } diff --git a/tests/baselines/reference/classExpression3.symbols b/tests/baselines/reference/classExpression3.symbols index bc1b263a000..fbd5f7b5331 100644 --- a/tests/baselines/reference/classExpression3.symbols +++ b/tests/baselines/reference/classExpression3.symbols @@ -3,7 +3,7 @@ let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; >C : Symbol(C, Decl(classExpression3.ts, 0, 3)) >a : Symbol((Anonymous class).a, Decl(classExpression3.ts, 0, 43)) >b : Symbol((Anonymous class).b, Decl(classExpression3.ts, 0, 53)) ->c : Symbol((Anonymous class).c, Decl(classExpression3.ts, 0, 63)) +>c : Symbol(C.c, Decl(classExpression3.ts, 0, 63)) let c = new C(); >c : Symbol(c, Decl(classExpression3.ts, 1, 3)) @@ -20,7 +20,7 @@ c.b; >b : Symbol((Anonymous class).b, Decl(classExpression3.ts, 0, 53)) c.c; ->c.c : Symbol((Anonymous class).c, Decl(classExpression3.ts, 0, 63)) +>c.c : Symbol(C.c, Decl(classExpression3.ts, 0, 63)) >c : Symbol(c, Decl(classExpression3.ts, 1, 3)) ->c : Symbol((Anonymous class).c, Decl(classExpression3.ts, 0, 63)) +>c : Symbol(C.c, Decl(classExpression3.ts, 0, 63)) diff --git a/tests/baselines/reference/classExpression3.types b/tests/baselines/reference/classExpression3.types index 51798f300d4..713407fa8d4 100644 --- a/tests/baselines/reference/classExpression3.types +++ b/tests/baselines/reference/classExpression3.types @@ -1,7 +1,7 @@ === tests/cases/conformance/classes/classExpressions/classExpression3.ts === let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; ->C : typeof (Anonymous class) ->class extends class extends class { a = 1 } { b = 2 } { c = 3 } : typeof (Anonymous class) +>C : typeof C +>class extends class extends class { a = 1 } { b = 2 } { c = 3 } : typeof C >class extends class { a = 1 } { b = 2 } : (Anonymous class) >class { a = 1 } : (Anonymous class) >a : number @@ -12,22 +12,22 @@ let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; >3 : 3 let c = new C(); ->c : (Anonymous class) ->new C() : (Anonymous class) ->C : typeof (Anonymous class) +>c : C +>new C() : C +>C : typeof C c.a; >c.a : number ->c : (Anonymous class) +>c : C >a : number c.b; >c.b : number ->c : (Anonymous class) +>c : C >b : number c.c; >c.c : number ->c : (Anonymous class) +>c : C >c : number diff --git a/tests/baselines/reference/classExpression4.symbols b/tests/baselines/reference/classExpression4.symbols index 4df5302cecc..47a03bc4c96 100644 --- a/tests/baselines/reference/classExpression4.symbols +++ b/tests/baselines/reference/classExpression4.symbols @@ -3,7 +3,7 @@ let C = class { >C : Symbol(C, Decl(classExpression4.ts, 0, 3)) foo() { ->foo : Symbol((Anonymous class).foo, Decl(classExpression4.ts, 0, 15)) +>foo : Symbol(C.foo, Decl(classExpression4.ts, 0, 15)) return new C(); >C : Symbol(C, Decl(classExpression4.ts, 0, 3)) @@ -11,7 +11,7 @@ let C = class { }; let x = (new C).foo(); >x : Symbol(x, Decl(classExpression4.ts, 5, 3)) ->(new C).foo : Symbol((Anonymous class).foo, Decl(classExpression4.ts, 0, 15)) +>(new C).foo : Symbol(C.foo, Decl(classExpression4.ts, 0, 15)) >C : Symbol(C, Decl(classExpression4.ts, 0, 3)) ->foo : Symbol((Anonymous class).foo, Decl(classExpression4.ts, 0, 15)) +>foo : Symbol(C.foo, Decl(classExpression4.ts, 0, 15)) diff --git a/tests/baselines/reference/classExpression4.types b/tests/baselines/reference/classExpression4.types index 066f169ae74..849a7459bbe 100644 --- a/tests/baselines/reference/classExpression4.types +++ b/tests/baselines/reference/classExpression4.types @@ -1,22 +1,22 @@ === tests/cases/conformance/classes/classExpressions/classExpression4.ts === let C = class { ->C : typeof (Anonymous class) ->class { foo() { return new C(); }} : typeof (Anonymous class) +>C : typeof C +>class { foo() { return new C(); }} : typeof C foo() { ->foo : () => (Anonymous class) +>foo : () => C return new C(); ->new C() : (Anonymous class) ->C : typeof (Anonymous class) +>new C() : C +>C : typeof C } }; let x = (new C).foo(); ->x : (Anonymous class) ->(new C).foo() : (Anonymous class) ->(new C).foo : () => (Anonymous class) ->(new C) : (Anonymous class) ->new C : (Anonymous class) ->C : typeof (Anonymous class) ->foo : () => (Anonymous class) +>x : C +>(new C).foo() : C +>(new C).foo : () => C +>(new C) : C +>new C : C +>C : typeof C +>foo : () => C diff --git a/tests/baselines/reference/classExpressionES63.symbols b/tests/baselines/reference/classExpressionES63.symbols index 4e52d5ee9dd..f74b2893f73 100644 --- a/tests/baselines/reference/classExpressionES63.symbols +++ b/tests/baselines/reference/classExpressionES63.symbols @@ -3,7 +3,7 @@ let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; >C : Symbol(C, Decl(classExpressionES63.ts, 0, 3)) >a : Symbol((Anonymous class).a, Decl(classExpressionES63.ts, 0, 43)) >b : Symbol((Anonymous class).b, Decl(classExpressionES63.ts, 0, 53)) ->c : Symbol((Anonymous class).c, Decl(classExpressionES63.ts, 0, 63)) +>c : Symbol(C.c, Decl(classExpressionES63.ts, 0, 63)) let c = new C(); >c : Symbol(c, Decl(classExpressionES63.ts, 1, 3)) @@ -20,7 +20,7 @@ c.b; >b : Symbol((Anonymous class).b, Decl(classExpressionES63.ts, 0, 53)) c.c; ->c.c : Symbol((Anonymous class).c, Decl(classExpressionES63.ts, 0, 63)) +>c.c : Symbol(C.c, Decl(classExpressionES63.ts, 0, 63)) >c : Symbol(c, Decl(classExpressionES63.ts, 1, 3)) ->c : Symbol((Anonymous class).c, Decl(classExpressionES63.ts, 0, 63)) +>c : Symbol(C.c, Decl(classExpressionES63.ts, 0, 63)) diff --git a/tests/baselines/reference/classExpressionES63.types b/tests/baselines/reference/classExpressionES63.types index c5c8de91c17..f597edab9db 100644 --- a/tests/baselines/reference/classExpressionES63.types +++ b/tests/baselines/reference/classExpressionES63.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/classExpressions/classExpressionES63.ts === let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; ->C : typeof (Anonymous class) ->class extends class extends class { a = 1 } { b = 2 } { c = 3 } : typeof (Anonymous class) +>C : typeof C +>class extends class extends class { a = 1 } { b = 2 } { c = 3 } : typeof C >class extends class { a = 1 } { b = 2 } : (Anonymous class) >class { a = 1 } : (Anonymous class) >a : number @@ -12,22 +12,22 @@ let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; >3 : 3 let c = new C(); ->c : (Anonymous class) ->new C() : (Anonymous class) ->C : typeof (Anonymous class) +>c : C +>new C() : C +>C : typeof C c.a; >c.a : number ->c : (Anonymous class) +>c : C >a : number c.b; >c.b : number ->c : (Anonymous class) +>c : C >b : number c.c; >c.c : number ->c : (Anonymous class) +>c : C >c : number diff --git a/tests/baselines/reference/classExpressionExtendingAbstractClass.js b/tests/baselines/reference/classExpressionExtendingAbstractClass.js index 7312ab6567d..814753be4d7 100644 --- a/tests/baselines/reference/classExpressionExtendingAbstractClass.js +++ b/tests/baselines/reference/classExpressionExtendingAbstractClass.js @@ -9,11 +9,16 @@ var C = class extends A { // no error reported! //// [classExpressionExtendingAbstractClass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -22,7 +27,7 @@ var A = (function () { var C = (function (_super) { __extends(class_1, _super); function class_1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class_1; }(A)); diff --git a/tests/baselines/reference/classExtendingBuiltinType.js b/tests/baselines/reference/classExtendingBuiltinType.js index 4c95e3008ea..6fdead50a44 100644 --- a/tests/baselines/reference/classExtendingBuiltinType.js +++ b/tests/baselines/reference/classExtendingBuiltinType.js @@ -12,78 +12,83 @@ class C10 extends Array { } //// [classExtendingBuiltinType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function (_super) { __extends(C1, _super); function C1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C1; }(Object)); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(Function)); var C3 = (function (_super) { __extends(C3, _super); function C3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C3; }(String)); var C4 = (function (_super) { __extends(C4, _super); function C4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C4; }(Boolean)); var C5 = (function (_super) { __extends(C5, _super); function C5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C5; }(Number)); var C6 = (function (_super) { __extends(C6, _super); function C6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C6; }(Date)); var C7 = (function (_super) { __extends(C7, _super); function C7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C7; }(RegExp)); var C8 = (function (_super) { __extends(C8, _super); function C8() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C8; }(Error)); var C9 = (function (_super) { __extends(C9, _super); function C9() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C9; }(Array)); var C10 = (function (_super) { __extends(C10, _super); function C10() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C10; }(Array)); diff --git a/tests/baselines/reference/classExtendingClass.js b/tests/baselines/reference/classExtendingClass.js index 91e3752980c..52b415ccb77 100644 --- a/tests/baselines/reference/classExtendingClass.js +++ b/tests/baselines/reference/classExtendingClass.js @@ -32,11 +32,16 @@ var r7 = d2.thing(''); var r8 = D2.other(1); //// [classExtendingClass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -47,7 +52,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); @@ -66,7 +71,7 @@ var C2 = (function () { var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(C2)); diff --git a/tests/baselines/reference/classExtendingClassLikeType.js b/tests/baselines/reference/classExtendingClassLikeType.js index bfc10c23563..6ba82a0a08b 100644 --- a/tests/baselines/reference/classExtendingClassLikeType.js +++ b/tests/baselines/reference/classExtendingClassLikeType.js @@ -59,16 +59,21 @@ class D5 extends getBadBase() { //// [classExtendingClassLikeType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // Error, no Base constructor function var D0 = (function (_super) { __extends(D0, _super); function D0() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D0; }(Base)); @@ -107,7 +112,7 @@ var D3 = (function (_super) { var D4 = (function (_super) { __extends(D4, _super); function D4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D4; }(getBase())); @@ -115,7 +120,7 @@ var D4 = (function (_super) { var D5 = (function (_super) { __extends(D5, _super); function D5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D5; }(getBadBase())); diff --git a/tests/baselines/reference/classExtendingNonConstructor.js b/tests/baselines/reference/classExtendingNonConstructor.js index 574d5004486..bfe716b0029 100644 --- a/tests/baselines/reference/classExtendingNonConstructor.js +++ b/tests/baselines/reference/classExtendingNonConstructor.js @@ -15,11 +15,16 @@ class C7 extends foo { } //// [classExtendingNonConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x; function foo() { this.x = 1; @@ -27,49 +32,49 @@ function foo() { var C1 = (function (_super) { __extends(C1, _super); function C1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C1; }(undefined)); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(true)); var C3 = (function (_super) { __extends(C3, _super); function C3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C3; }(false)); var C4 = (function (_super) { __extends(C4, _super); function C4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C4; }(42)); var C5 = (function (_super) { __extends(C5, _super); function C5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C5; }("hello")); var C6 = (function (_super) { __extends(C6, _super); function C6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C6; }(x)); var C7 = (function (_super) { __extends(C7, _super); function C7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C7; }(foo)); diff --git a/tests/baselines/reference/classExtendingNull.js b/tests/baselines/reference/classExtendingNull.js index 8d5d73329aa..6725bcc7d9e 100644 --- a/tests/baselines/reference/classExtendingNull.js +++ b/tests/baselines/reference/classExtendingNull.js @@ -4,22 +4,25 @@ class C2 extends (null) { } //// [classExtendingNull.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function (_super) { __extends(C1, _super); function C1() { - return _super.apply(this, arguments) || this; } return C1; }(null)); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; } return C2; }((null))); diff --git a/tests/baselines/reference/classExtendingPrimitive.js b/tests/baselines/reference/classExtendingPrimitive.js index 53cb45c2081..fac6ada65ec 100644 --- a/tests/baselines/reference/classExtendingPrimitive.js +++ b/tests/baselines/reference/classExtendingPrimitive.js @@ -16,36 +16,41 @@ class C8 extends E { } //// [classExtendingPrimitive.js] // classes cannot extend primitives -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(number)); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(string)); var C3 = (function (_super) { __extends(C3, _super); function C3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C3; }(boolean)); var C4 = (function (_super) { __extends(C4, _super); function C4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C4; }(Void)); @@ -58,28 +63,27 @@ void {}; var C5 = (function (_super) { __extends(C5, _super); function C5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C5; }(Null)); var C5a = (function (_super) { __extends(C5a, _super); function C5a() { - return _super.apply(this, arguments) || this; } return C5a; }(null)); var C6 = (function (_super) { __extends(C6, _super); function C6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C6; }(undefined)); var C7 = (function (_super) { __extends(C7, _super); function C7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C7; }(Undefined)); @@ -90,7 +94,7 @@ var E; var C8 = (function (_super) { __extends(C8, _super); function C8() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C8; }(E)); diff --git a/tests/baselines/reference/classExtendingPrimitive2.js b/tests/baselines/reference/classExtendingPrimitive2.js index b32dc31a5b4..2b9cd6de6b6 100644 --- a/tests/baselines/reference/classExtendingPrimitive2.js +++ b/tests/baselines/reference/classExtendingPrimitive2.js @@ -6,11 +6,16 @@ class C5a extends null { } //// [classExtendingPrimitive2.js] // classes cannot extend primitives -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C4a = (function () { function C4a() { } @@ -20,7 +25,6 @@ void {}; var C5a = (function (_super) { __extends(C5a, _super); function C5a() { - return _super.apply(this, arguments) || this; } return C5a; }(null)); diff --git a/tests/baselines/reference/classExtendingQualifiedName.js b/tests/baselines/reference/classExtendingQualifiedName.js index fced8c2a373..24c61fd0bd6 100644 --- a/tests/baselines/reference/classExtendingQualifiedName.js +++ b/tests/baselines/reference/classExtendingQualifiedName.js @@ -8,11 +8,16 @@ module M { } //// [classExtendingQualifiedName.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M; (function (M) { var C = (function () { @@ -23,7 +28,7 @@ var M; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(M.C)); diff --git a/tests/baselines/reference/classExtendingQualifiedName2.js b/tests/baselines/reference/classExtendingQualifiedName2.js index c133ceb87dc..633cd4d9ef4 100644 --- a/tests/baselines/reference/classExtendingQualifiedName2.js +++ b/tests/baselines/reference/classExtendingQualifiedName2.js @@ -8,11 +8,16 @@ module M { } //// [classExtendingQualifiedName2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M; (function (M) { var C = (function () { @@ -24,7 +29,7 @@ var M; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(M.C)); diff --git a/tests/baselines/reference/classExtendsAcrossFiles.js b/tests/baselines/reference/classExtendsAcrossFiles.js index 5be0ab8f9c0..933f92cad64 100644 --- a/tests/baselines/reference/classExtendsAcrossFiles.js +++ b/tests/baselines/reference/classExtendsAcrossFiles.js @@ -21,11 +21,17 @@ export const b = { //// [b.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); var a_1 = require("./a"); exports.b = { f: function () { @@ -37,7 +43,7 @@ exports.b = { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -46,11 +52,17 @@ exports.b = { }; //// [a.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); var b_1 = require("./b"); exports.a = { f: function () { @@ -62,7 +74,7 @@ exports.a = { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.js b/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.js index 91f96450d87..3b835f86755 100644 --- a/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.js +++ b/tests/baselines/reference/classExtendsClauseClassMergedWithModuleNotReferingConstructor.js @@ -14,11 +14,16 @@ module Foo { } //// [classExtendsClauseClassMergedWithModuleNotReferingConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -32,7 +37,7 @@ var Foo; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.js b/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.js index 6c3dc789445..d0377bdfc18 100644 --- a/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.js +++ b/tests/baselines/reference/classExtendsClauseClassNotReferringConstructor.js @@ -7,11 +7,16 @@ module Foo { //// [classExtendsClauseClassNotReferringConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -23,7 +28,7 @@ var Foo; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/classExtendsEveryObjectType.js b/tests/baselines/reference/classExtendsEveryObjectType.js index a19f5d5cdd6..946f2c70f91 100644 --- a/tests/baselines/reference/classExtendsEveryObjectType.js +++ b/tests/baselines/reference/classExtendsEveryObjectType.js @@ -17,22 +17,27 @@ class C5 extends foo { } // error class C6 extends []{ } // error //// [classExtendsEveryObjectType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(I)); // error var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }({ foo: string })); // error @@ -40,7 +45,7 @@ var x; var C3 = (function (_super) { __extends(C3, _super); function C3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C3; }(x)); // error @@ -51,7 +56,7 @@ var M; var C4 = (function (_super) { __extends(C4, _super); function C4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C4; }(M)); // error @@ -59,14 +64,14 @@ function foo() { } var C5 = (function (_super) { __extends(C5, _super); function C5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C5; }(foo)); // error var C6 = (function (_super) { __extends(C6, _super); function C6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C6; }([])); // error diff --git a/tests/baselines/reference/classExtendsEveryObjectType2.js b/tests/baselines/reference/classExtendsEveryObjectType2.js index fbc364ca5da..d8dbdbb5721 100644 --- a/tests/baselines/reference/classExtendsEveryObjectType2.js +++ b/tests/baselines/reference/classExtendsEveryObjectType2.js @@ -4,22 +4,27 @@ class C2 extends { foo: string; } { } // error class C6 extends []{ } // error //// [classExtendsEveryObjectType2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }({ foo: string })); // error var C6 = (function (_super) { __extends(C6, _super); function C6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C6; }([])); // error diff --git a/tests/baselines/reference/classExtendsInterface.js b/tests/baselines/reference/classExtendsInterface.js index b5946224317..cd86c42ae0b 100644 --- a/tests/baselines/reference/classExtendsInterface.js +++ b/tests/baselines/reference/classExtendsInterface.js @@ -9,15 +9,20 @@ class B2 implements Comparable2 {} //// [classExtendsInterface.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function (_super) { __extends(A, _super); function A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A; }(Comparable)); @@ -29,7 +34,7 @@ var B = (function () { var A2 = (function (_super) { __extends(A2, _super); function A2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A2; }(Comparable2)); diff --git a/tests/baselines/reference/classExtendsInterfaceInExpression.js b/tests/baselines/reference/classExtendsInterfaceInExpression.js index 9dcd8dd7279..1bbdae0370e 100644 --- a/tests/baselines/reference/classExtendsInterfaceInExpression.js +++ b/tests/baselines/reference/classExtendsInterfaceInExpression.js @@ -9,18 +9,23 @@ class C extends factory(A) {} //// [classExtendsInterfaceInExpression.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function factory(a) { return null; } var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(factory(A))); diff --git a/tests/baselines/reference/classExtendsInterfaceInModule.js b/tests/baselines/reference/classExtendsInterfaceInModule.js index 9da8831a138..96b2906e54f 100644 --- a/tests/baselines/reference/classExtendsInterfaceInModule.js +++ b/tests/baselines/reference/classExtendsInterfaceInModule.js @@ -16,29 +16,34 @@ class D extends Mod.Nested.I {} //// [classExtendsInterfaceInModule.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function (_super) { __extends(C1, _super); function C1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C1; }(M.I1)); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(M.I2)); var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(Mod.Nested.I)); diff --git a/tests/baselines/reference/classExtendsItself.js b/tests/baselines/reference/classExtendsItself.js index 36f2263d671..197f76edb80 100644 --- a/tests/baselines/reference/classExtendsItself.js +++ b/tests/baselines/reference/classExtendsItself.js @@ -6,29 +6,34 @@ class D extends D { } // error class E extends E { } // error //// [classExtendsItself.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(C)); // error var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(D)); // error var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(E)); // error diff --git a/tests/baselines/reference/classExtendsItselfIndirectly.js b/tests/baselines/reference/classExtendsItselfIndirectly.js index 0f3f48d2f2c..e5bd50ae80a 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly.js +++ b/tests/baselines/reference/classExtendsItselfIndirectly.js @@ -12,50 +12,55 @@ class D2 extends C2 { bar: T; } class E2 extends D2 { baz: T; } //// [classExtendsItselfIndirectly.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(E)); // error var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(D)); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(E2)); // error var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(C2)); var E2 = (function (_super) { __extends(E2, _super); function E2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E2; }(D2)); diff --git a/tests/baselines/reference/classExtendsItselfIndirectly2.js b/tests/baselines/reference/classExtendsItselfIndirectly2.js index e215a07c357..ae3bf4ed788 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly2.js +++ b/tests/baselines/reference/classExtendsItselfIndirectly2.js @@ -23,15 +23,20 @@ module O { } //// [classExtendsItselfIndirectly2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(N.E)); // error @@ -40,7 +45,7 @@ var M; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); @@ -51,7 +56,7 @@ var N; var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(M.D)); @@ -62,7 +67,7 @@ var O; var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(Q.E2)); // error @@ -71,7 +76,7 @@ var O; var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(C2)); @@ -82,7 +87,7 @@ var O; var E2 = (function (_super) { __extends(E2, _super); function E2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E2; }(P.D2)); diff --git a/tests/baselines/reference/classExtendsItselfIndirectly3.js b/tests/baselines/reference/classExtendsItselfIndirectly3.js index f8366d77e13..8f004a44cfe 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly3.js +++ b/tests/baselines/reference/classExtendsItselfIndirectly3.js @@ -19,80 +19,110 @@ class D2 extends C2 { bar: T; } class E2 extends D2 { baz: T; } //// [classExtendsItselfIndirectly_file1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(E)); // error //// [classExtendsItselfIndirectly_file2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); //// [classExtendsItselfIndirectly_file3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(D)); //// [classExtendsItselfIndirectly_file4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(E2)); // error //// [classExtendsItselfIndirectly_file5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(C2)); //// [classExtendsItselfIndirectly_file6.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var E2 = (function (_super) { __extends(E2, _super); function E2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E2; }(D2)); diff --git a/tests/baselines/reference/classExtendsMultipleBaseClasses.js b/tests/baselines/reference/classExtendsMultipleBaseClasses.js index cd9c28ad283..830bf6fb988 100644 --- a/tests/baselines/reference/classExtendsMultipleBaseClasses.js +++ b/tests/baselines/reference/classExtendsMultipleBaseClasses.js @@ -4,11 +4,16 @@ class B { } class C extends A,B { } //// [classExtendsMultipleBaseClasses.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -22,7 +27,7 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/classExtendsNull.js b/tests/baselines/reference/classExtendsNull.js index 1eeb5172cad..674b212f98e 100644 --- a/tests/baselines/reference/classExtendsNull.js +++ b/tests/baselines/reference/classExtendsNull.js @@ -13,15 +13,20 @@ class D extends null { } //// [classExtendsNull.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - var _this = _super.call(this) || this; + _this = _super.call(this) || this; return Object.create(null); } return C; @@ -29,7 +34,6 @@ var C = (function (_super) { var D = (function (_super) { __extends(D, _super); function D() { - var _this; return Object.create(null); } return D; diff --git a/tests/baselines/reference/classExtendsShadowedConstructorFunction.js b/tests/baselines/reference/classExtendsShadowedConstructorFunction.js index ddaadc2dc62..391a6e52fa3 100644 --- a/tests/baselines/reference/classExtendsShadowedConstructorFunction.js +++ b/tests/baselines/reference/classExtendsShadowedConstructorFunction.js @@ -9,11 +9,16 @@ module M { } //// [classExtendsShadowedConstructorFunction.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -25,7 +30,7 @@ var M; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/classExtendsValidConstructorFunction.js b/tests/baselines/reference/classExtendsValidConstructorFunction.js index 31bff6e430c..e6f9b389739 100644 --- a/tests/baselines/reference/classExtendsValidConstructorFunction.js +++ b/tests/baselines/reference/classExtendsValidConstructorFunction.js @@ -6,17 +6,22 @@ var x = new foo(); // can be used as a constructor function class C extends foo { } // error, cannot extend it though //// [classExtendsValidConstructorFunction.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function foo() { } var x = new foo(); // can be used as a constructor function var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(foo)); // error, cannot extend it though diff --git a/tests/baselines/reference/classHeritageWithTrailingSeparator.js b/tests/baselines/reference/classHeritageWithTrailingSeparator.js index 12265f569bd..4d863741ada 100644 --- a/tests/baselines/reference/classHeritageWithTrailingSeparator.js +++ b/tests/baselines/reference/classHeritageWithTrailingSeparator.js @@ -4,11 +4,16 @@ class D extends C, { } //// [classHeritageWithTrailingSeparator.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -17,7 +22,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/classImplementsClass2.js b/tests/baselines/reference/classImplementsClass2.js index 5e3eae46543..330a9a7dece 100644 --- a/tests/baselines/reference/classImplementsClass2.js +++ b/tests/baselines/reference/classImplementsClass2.js @@ -14,11 +14,16 @@ c = c2; c2 = c; //// [classImplementsClass2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -33,7 +38,7 @@ var C = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C2.prototype.foo = function () { return 1; diff --git a/tests/baselines/reference/classImplementsClass3.js b/tests/baselines/reference/classImplementsClass3.js index 5fd003e93b9..649afb528a3 100644 --- a/tests/baselines/reference/classImplementsClass3.js +++ b/tests/baselines/reference/classImplementsClass3.js @@ -15,11 +15,16 @@ c = c2; c2 = c; //// [classImplementsClass3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -37,7 +42,7 @@ var C = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(A)); diff --git a/tests/baselines/reference/classImplementsClass4.js b/tests/baselines/reference/classImplementsClass4.js index 477288972df..0d7a8661ed1 100644 --- a/tests/baselines/reference/classImplementsClass4.js +++ b/tests/baselines/reference/classImplementsClass4.js @@ -17,11 +17,16 @@ c = c2; c2 = c; //// [classImplementsClass4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { this.x = 1; @@ -40,7 +45,7 @@ var C = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(A)); diff --git a/tests/baselines/reference/classImplementsClass5.js b/tests/baselines/reference/classImplementsClass5.js index 0ec258ab77b..4b5229bdfc6 100644 --- a/tests/baselines/reference/classImplementsClass5.js +++ b/tests/baselines/reference/classImplementsClass5.js @@ -18,11 +18,16 @@ c = c2; c2 = c; //// [classImplementsClass5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { this.x = 1; @@ -42,7 +47,7 @@ var C = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(A)); diff --git a/tests/baselines/reference/classImplementsClass6.js b/tests/baselines/reference/classImplementsClass6.js index 0771c56415c..fb42e9451a7 100644 --- a/tests/baselines/reference/classImplementsClass6.js +++ b/tests/baselines/reference/classImplementsClass6.js @@ -22,11 +22,16 @@ c.bar(); // error c2.bar(); // should error //// [classImplementsClass6.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -47,7 +52,7 @@ var C = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(A)); diff --git a/tests/baselines/reference/classIndexer3.js b/tests/baselines/reference/classIndexer3.js index 2e55c894645..344baf039e1 100644 --- a/tests/baselines/reference/classIndexer3.js +++ b/tests/baselines/reference/classIndexer3.js @@ -11,11 +11,16 @@ class D123 extends C123 { } //// [classIndexer3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C123 = (function () { function C123() { } @@ -24,7 +29,7 @@ var C123 = (function () { var D123 = (function (_super) { __extends(D123, _super); function D123() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D123; }(C123)); diff --git a/tests/baselines/reference/classInheritence.js b/tests/baselines/reference/classInheritence.js index f68d76fad47..a43cf9c8bb8 100644 --- a/tests/baselines/reference/classInheritence.js +++ b/tests/baselines/reference/classInheritence.js @@ -3,22 +3,27 @@ class B extends A { } class A extends A { } //// [classInheritence.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var A = (function (_super) { __extends(A, _super); function A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A; }(A)); diff --git a/tests/baselines/reference/classIsSubtypeOfBaseType.js b/tests/baselines/reference/classIsSubtypeOfBaseType.js index 52300987d8e..adfa94b4b7e 100644 --- a/tests/baselines/reference/classIsSubtypeOfBaseType.js +++ b/tests/baselines/reference/classIsSubtypeOfBaseType.js @@ -16,11 +16,16 @@ class Derived2 extends Base<{ bar: string; }> { } //// [classIsSubtypeOfBaseType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -29,14 +34,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/classMemberInitializerWithLamdaScoping3.js b/tests/baselines/reference/classMemberInitializerWithLamdaScoping3.js index d310ccd53bc..d4df05f2ea3 100644 --- a/tests/baselines/reference/classMemberInitializerWithLamdaScoping3.js +++ b/tests/baselines/reference/classMemberInitializerWithLamdaScoping3.js @@ -21,6 +21,7 @@ export class Test1 { var field1; //// [classMemberInitializerWithLamdaScoping3_1.js] "use strict"; +exports.__esModule = true; var Test1 = (function () { function Test1(field1) { this.field1 = field1; diff --git a/tests/baselines/reference/classMemberInitializerWithLamdaScoping4.js b/tests/baselines/reference/classMemberInitializerWithLamdaScoping4.js index 161bceca04d..76835e757e0 100644 --- a/tests/baselines/reference/classMemberInitializerWithLamdaScoping4.js +++ b/tests/baselines/reference/classMemberInitializerWithLamdaScoping4.js @@ -17,8 +17,10 @@ export class Test1 { //// [classMemberInitializerWithLamdaScoping3_0.js] "use strict"; +exports.__esModule = true; //// [classMemberInitializerWithLamdaScoping3_1.js] "use strict"; +exports.__esModule = true; var Test1 = (function () { function Test1(field1) { this.field1 = field1; diff --git a/tests/baselines/reference/classOrder2.js b/tests/baselines/reference/classOrder2.js index 63490fa29b1..897089b8b57 100644 --- a/tests/baselines/reference/classOrder2.js +++ b/tests/baselines/reference/classOrder2.js @@ -20,15 +20,20 @@ a.foo(); //// [classOrder2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function (_super) { __extends(A, _super); function A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } A.prototype.foo = function () { this.bar(); }; return A; diff --git a/tests/baselines/reference/classOrderBug.js b/tests/baselines/reference/classOrderBug.js index e21a5ed64cf..71f407a14f5 100644 --- a/tests/baselines/reference/classOrderBug.js +++ b/tests/baselines/reference/classOrderBug.js @@ -16,11 +16,16 @@ class foo extends baz {} //// [classOrderBug.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var bar = (function () { function bar() { this.baz = new foo(); @@ -35,7 +40,7 @@ var baz = (function () { var foo = (function (_super) { __extends(foo, _super); function foo() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return foo; }(baz)); diff --git a/tests/baselines/reference/classSideInheritance1.js b/tests/baselines/reference/classSideInheritance1.js index 9443509032c..549d9451199 100644 --- a/tests/baselines/reference/classSideInheritance1.js +++ b/tests/baselines/reference/classSideInheritance1.js @@ -16,11 +16,16 @@ A.bar(); // valid C2.bar(); // valid //// [classSideInheritance1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -33,7 +38,7 @@ var A = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(A)); diff --git a/tests/baselines/reference/classSideInheritance2.js b/tests/baselines/reference/classSideInheritance2.js index 67ee666749b..9887472615f 100644 --- a/tests/baselines/reference/classSideInheritance2.js +++ b/tests/baselines/reference/classSideInheritance2.js @@ -21,11 +21,16 @@ class TextBase implements IText { } //// [classSideInheritance2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var SubText = (function (_super) { __extends(SubText, _super); function SubText(text, span) { diff --git a/tests/baselines/reference/classSideInheritance3.js b/tests/baselines/reference/classSideInheritance3.js index 589dd81c5c6..9ce60d012f4 100644 --- a/tests/baselines/reference/classSideInheritance3.js +++ b/tests/baselines/reference/classSideInheritance3.js @@ -19,11 +19,16 @@ var r2: new (x: string) => A = B; // error var r3: typeof A = C; // ok //// [classSideInheritance3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(x) { this.x = x; diff --git a/tests/baselines/reference/classUpdateTests.js b/tests/baselines/reference/classUpdateTests.js index 53ef71d0e4b..84a619d0461 100644 --- a/tests/baselines/reference/classUpdateTests.js +++ b/tests/baselines/reference/classUpdateTests.js @@ -114,11 +114,16 @@ class R { } //// [classUpdateTests.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // // test codegen for instance properties // @@ -157,7 +162,7 @@ var D = (function () { var E = (function (_super) { __extends(E, _super); function E() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.p1 = 0; return _this; } @@ -166,7 +171,7 @@ var E = (function (_super) { var F = (function (_super) { __extends(F, _super); function F() { - var _this; + var _this = this; return _this; } // ERROR - super call required return F; @@ -205,7 +210,7 @@ var J = (function (_super) { var K = (function (_super) { __extends(K, _super); function K(p1) { - var _this; + var _this = this; _this.p1 = p1; var i = 0; _this = _super.call(this) || this; @@ -225,7 +230,7 @@ var L = (function (_super) { var M = (function (_super) { __extends(M, _super); function M(p1) { - var _this; + var _this = this; _this.p1 = p1; var i = 0; _this = _super.call(this) || this; diff --git a/tests/baselines/reference/classWithBaseClassButNoConstructor.js b/tests/baselines/reference/classWithBaseClassButNoConstructor.js index c25687d3c74..a9f7fbc7700 100644 --- a/tests/baselines/reference/classWithBaseClassButNoConstructor.js +++ b/tests/baselines/reference/classWithBaseClassButNoConstructor.js @@ -41,11 +41,16 @@ var d5 = new D(); // error var d6 = new D(1); // ok //// [classWithBaseClassButNoConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(x) { } @@ -54,7 +59,7 @@ var Base = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(Base)); @@ -69,7 +74,7 @@ var Base2 = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(Base2)); @@ -80,7 +85,7 @@ var d2 = new D(1); // ok var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(Base2)); @@ -90,7 +95,7 @@ var d4 = new D(1); // ok var D3 = (function (_super) { __extends(D3, _super); function D3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D3; }(Base2)); diff --git a/tests/baselines/reference/classWithConstructors.js b/tests/baselines/reference/classWithConstructors.js index f445d22d18f..822f1e3014f 100644 --- a/tests/baselines/reference/classWithConstructors.js +++ b/tests/baselines/reference/classWithConstructors.js @@ -50,11 +50,16 @@ module Generics { } //// [classWithConstructors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var NonGeneric; (function (NonGeneric) { var C = (function () { @@ -75,7 +80,7 @@ var NonGeneric; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C2)); @@ -103,7 +108,7 @@ var Generics; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C2)); diff --git a/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt b/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt new file mode 100644 index 00000000000..325db86d47d --- /dev/null +++ b/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt @@ -0,0 +1,31 @@ +tests/cases/compiler/classWithDuplicateIdentifier.ts(3,5): error TS2300: Duplicate identifier 'a'. +tests/cases/compiler/classWithDuplicateIdentifier.ts(6,5): error TS2300: Duplicate identifier 'b'. +tests/cases/compiler/classWithDuplicateIdentifier.ts(7,5): error TS2300: Duplicate identifier 'b'. +tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2300: Duplicate identifier 'c'. +tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'c' must be of type 'number', but here has type 'string'. + + +==== tests/cases/compiler/classWithDuplicateIdentifier.ts (5 errors) ==== + class C { + a(): number { return 0; } // error: duplicate identifier + a: number; + ~ +!!! error TS2300: Duplicate identifier 'a'. + } + class K { + b: number; // error: duplicate identifier + ~ +!!! error TS2300: Duplicate identifier 'b'. + b(): number { return 0; } + ~ +!!! error TS2300: Duplicate identifier 'b'. + } + class D { + c: number; + c: string; + ~ +!!! error TS2300: Duplicate identifier 'c'. + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'c' must be of type 'number', but here has type 'string'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/classWithDuplicateIdentifier.js b/tests/baselines/reference/classWithDuplicateIdentifier.js new file mode 100644 index 00000000000..515b1749aa3 --- /dev/null +++ b/tests/baselines/reference/classWithDuplicateIdentifier.js @@ -0,0 +1,33 @@ +//// [classWithDuplicateIdentifier.ts] +class C { + a(): number { return 0; } // error: duplicate identifier + a: number; +} +class K { + b: number; // error: duplicate identifier + b(): number { return 0; } +} +class D { + c: number; + c: string; +} + + +//// [classWithDuplicateIdentifier.js] +var C = (function () { + function C() { + } + C.prototype.a = function () { return 0; }; // error: duplicate identifier + return C; +}()); +var K = (function () { + function K() { + } + K.prototype.b = function () { return 0; }; + return K; +}()); +var D = (function () { + function D() { + } + return D; +}()); diff --git a/tests/baselines/reference/classWithProtectedProperty.js b/tests/baselines/reference/classWithProtectedProperty.js index 2cb8a4e0a50..2b12741d38f 100644 --- a/tests/baselines/reference/classWithProtectedProperty.js +++ b/tests/baselines/reference/classWithProtectedProperty.js @@ -29,11 +29,16 @@ class D extends C { //// [classWithProtectedProperty.js] // accessing any protected outside the class is an error -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { this.a = ''; @@ -48,7 +53,7 @@ C.g = function () { return ''; }; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.method = function () { // No errors diff --git a/tests/baselines/reference/classWithStaticMembers.js b/tests/baselines/reference/classWithStaticMembers.js index 9e79780d5cc..e4f4805b42f 100644 --- a/tests/baselines/reference/classWithStaticMembers.js +++ b/tests/baselines/reference/classWithStaticMembers.js @@ -20,11 +20,16 @@ var r2 = r.x; var r3 = r.foo; //// [classWithStaticMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C(a, b) { this.a = a; @@ -45,7 +50,7 @@ var r3 = r.foo; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/classdecl.js b/tests/baselines/reference/classdecl.js index a3059757d2f..e1e1313dae2 100644 --- a/tests/baselines/reference/classdecl.js +++ b/tests/baselines/reference/classdecl.js @@ -94,11 +94,16 @@ class e { } //// [classdecl.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a(ns) { } @@ -136,7 +141,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); @@ -161,7 +166,7 @@ var m2; var c = (function (_super) { __extends(c, _super); function c() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return c; }(b)); @@ -177,7 +182,7 @@ var m2; var c = (function (_super) { __extends(c, _super); function c() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return c; }(m1.b)); diff --git a/tests/baselines/reference/clodulesDerivedClasses.js b/tests/baselines/reference/clodulesDerivedClasses.js index ea4bfcf301f..e643ed17578 100644 --- a/tests/baselines/reference/clodulesDerivedClasses.js +++ b/tests/baselines/reference/clodulesDerivedClasses.js @@ -23,11 +23,16 @@ module Path.Utils { //// [clodulesDerivedClasses.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Shape = (function () { function Shape() { } @@ -43,7 +48,7 @@ var Shape = (function () { var Path = (function (_super) { __extends(Path, _super); function Path() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Path; }(Shape)); diff --git a/tests/baselines/reference/collisionExportsRequireAndAlias.js b/tests/baselines/reference/collisionExportsRequireAndAlias.js index d7785dc73cf..487553bb004 100644 --- a/tests/baselines/reference/collisionExportsRequireAndAlias.js +++ b/tests/baselines/reference/collisionExportsRequireAndAlias.js @@ -20,6 +20,7 @@ export function foo2() { //// [collisionExportsRequireAndAlias_file1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; function bar() { } exports.bar = bar; @@ -27,6 +28,7 @@ define(["require", "exports"], function (require, exports) { //// [collisionExportsRequireAndAlias_file3333.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; function bar2() { } exports.bar2 = bar2; @@ -34,6 +36,7 @@ define(["require", "exports"], function (require, exports) { //// [collisionExportsRequireAndAlias_file2.js] define(["require", "exports", "collisionExportsRequireAndAlias_file1", "collisionExportsRequireAndAlias_file3333"], function (require, exports, require, exports) { "use strict"; + exports.__esModule = true; function foo() { require.bar(); } diff --git a/tests/baselines/reference/collisionExportsRequireAndAmbientClass.js b/tests/baselines/reference/collisionExportsRequireAndAmbientClass.js index 3083e9c586b..1a16f4a2d5f 100644 --- a/tests/baselines/reference/collisionExportsRequireAndAmbientClass.js +++ b/tests/baselines/reference/collisionExportsRequireAndAmbientClass.js @@ -40,6 +40,7 @@ module m4 { //// [collisionExportsRequireAndAmbientClass_externalmodule.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var m2; (function (m2) { })(m2 || (m2 = {})); diff --git a/tests/baselines/reference/collisionExportsRequireAndAmbientEnum.js b/tests/baselines/reference/collisionExportsRequireAndAmbientEnum.js index 7f0f76381a3..0e717b01d3b 100644 --- a/tests/baselines/reference/collisionExportsRequireAndAmbientEnum.js +++ b/tests/baselines/reference/collisionExportsRequireAndAmbientEnum.js @@ -63,6 +63,7 @@ module m4 { //// [collisionExportsRequireAndAmbientEnum_externalmodule.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var m2; (function (m2) { })(m2 || (m2 = {})); diff --git a/tests/baselines/reference/collisionExportsRequireAndAmbientFunction.js b/tests/baselines/reference/collisionExportsRequireAndAmbientFunction.js index 37b1a724c28..050799d4c2b 100644 --- a/tests/baselines/reference/collisionExportsRequireAndAmbientFunction.js +++ b/tests/baselines/reference/collisionExportsRequireAndAmbientFunction.js @@ -16,6 +16,7 @@ module m2 { //// [collisionExportsRequireAndAmbientFunction.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var m2; (function (m2) { var a = 10; diff --git a/tests/baselines/reference/collisionExportsRequireAndAmbientModule.js b/tests/baselines/reference/collisionExportsRequireAndAmbientModule.js index 7f0a5c82d9a..2eb5ea74f92 100644 --- a/tests/baselines/reference/collisionExportsRequireAndAmbientModule.js +++ b/tests/baselines/reference/collisionExportsRequireAndAmbientModule.js @@ -97,6 +97,7 @@ module m4 { //// [collisionExportsRequireAndAmbientModule_externalmodule.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; function foo() { return null; } diff --git a/tests/baselines/reference/collisionExportsRequireAndAmbientVar.js b/tests/baselines/reference/collisionExportsRequireAndAmbientVar.js index 1e63364a396..8454248845a 100644 --- a/tests/baselines/reference/collisionExportsRequireAndAmbientVar.js +++ b/tests/baselines/reference/collisionExportsRequireAndAmbientVar.js @@ -29,6 +29,7 @@ module m4 { //// [collisionExportsRequireAndAmbientVar_externalmodule.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var m2; (function (m2) { var a = 10; diff --git a/tests/baselines/reference/collisionExportsRequireAndClass.js b/tests/baselines/reference/collisionExportsRequireAndClass.js index 962df0344ed..0bc56b97cf1 100644 --- a/tests/baselines/reference/collisionExportsRequireAndClass.js +++ b/tests/baselines/reference/collisionExportsRequireAndClass.js @@ -39,6 +39,7 @@ module m4 { //// [collisionExportsRequireAndClass_externalmodule.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var require = (function () { function require() { } diff --git a/tests/baselines/reference/collisionExportsRequireAndEnum.js b/tests/baselines/reference/collisionExportsRequireAndEnum.js index 47d127e8a67..4bb6614ffe7 100644 --- a/tests/baselines/reference/collisionExportsRequireAndEnum.js +++ b/tests/baselines/reference/collisionExportsRequireAndEnum.js @@ -63,6 +63,7 @@ module m4 { //// [collisionExportsRequireAndEnum_externalmodule.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var require; (function (require) { require[require["_thisVal1"] = 0] = "_thisVal1"; diff --git a/tests/baselines/reference/collisionExportsRequireAndFunction.js b/tests/baselines/reference/collisionExportsRequireAndFunction.js index 0fe5405cfb3..1da8cf29d66 100644 --- a/tests/baselines/reference/collisionExportsRequireAndFunction.js +++ b/tests/baselines/reference/collisionExportsRequireAndFunction.js @@ -25,6 +25,7 @@ module m2 { //// [collisionExportsRequireAndFunction.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; function exports() { return 1; } diff --git a/tests/baselines/reference/collisionExportsRequireAndInternalModuleAlias.js b/tests/baselines/reference/collisionExportsRequireAndInternalModuleAlias.js index 1842e415d88..9cb3c4e797e 100644 --- a/tests/baselines/reference/collisionExportsRequireAndInternalModuleAlias.js +++ b/tests/baselines/reference/collisionExportsRequireAndInternalModuleAlias.js @@ -25,6 +25,7 @@ module m2 { //// [collisionExportsRequireAndInternalModuleAlias.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var m; (function (m) { var c = (function () { diff --git a/tests/baselines/reference/collisionExportsRequireAndModule.js b/tests/baselines/reference/collisionExportsRequireAndModule.js index b29364aebe3..42820955004 100644 --- a/tests/baselines/reference/collisionExportsRequireAndModule.js +++ b/tests/baselines/reference/collisionExportsRequireAndModule.js @@ -94,6 +94,7 @@ module m4 { //// [collisionExportsRequireAndModule_externalmodule.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var require; (function (require) { var C = (function () { diff --git a/tests/baselines/reference/collisionExportsRequireAndUninstantiatedModule.js b/tests/baselines/reference/collisionExportsRequireAndUninstantiatedModule.js index 6270cf65c02..b9552c16223 100644 --- a/tests/baselines/reference/collisionExportsRequireAndUninstantiatedModule.js +++ b/tests/baselines/reference/collisionExportsRequireAndUninstantiatedModule.js @@ -17,6 +17,7 @@ export function foo2(): exports.I { //// [collisionExportsRequireAndUninstantiatedModule.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; function foo() { return null; } diff --git a/tests/baselines/reference/collisionExportsRequireAndVar.js b/tests/baselines/reference/collisionExportsRequireAndVar.js index 0686b932921..9a20472ea68 100644 --- a/tests/baselines/reference/collisionExportsRequireAndVar.js +++ b/tests/baselines/reference/collisionExportsRequireAndVar.js @@ -29,6 +29,7 @@ module m4 { //// [collisionExportsRequireAndVar_externalmodule.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; function foo() { } exports.foo = foo; diff --git a/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js b/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js index 85c0e398fbd..7d8e23cd508 100644 --- a/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js +++ b/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js @@ -40,11 +40,16 @@ class c extends Foo { } //// [collisionSuperAndLocalFunctionInAccessors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function _super() { } var Foo = (function () { @@ -68,7 +73,7 @@ var Foo = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(b.prototype, "prop2", { get: function () { @@ -88,7 +93,7 @@ var b = (function (_super) { var c = (function (_super) { __extends(c, _super); function c() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(c.prototype, "prop2", { get: function () { diff --git a/tests/baselines/reference/collisionSuperAndLocalFunctionInConstructor.js b/tests/baselines/reference/collisionSuperAndLocalFunctionInConstructor.js index d4a22b731f2..d516c06ad18 100644 --- a/tests/baselines/reference/collisionSuperAndLocalFunctionInConstructor.js +++ b/tests/baselines/reference/collisionSuperAndLocalFunctionInConstructor.js @@ -25,11 +25,16 @@ class c extends Foo { } //// [collisionSuperAndLocalFunctionInConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function _super() { } var Foo = (function () { diff --git a/tests/baselines/reference/collisionSuperAndLocalFunctionInMethod.js b/tests/baselines/reference/collisionSuperAndLocalFunctionInMethod.js index 81c069da169..b211b3e4eac 100644 --- a/tests/baselines/reference/collisionSuperAndLocalFunctionInMethod.js +++ b/tests/baselines/reference/collisionSuperAndLocalFunctionInMethod.js @@ -29,11 +29,16 @@ class c extends Foo { } //// [collisionSuperAndLocalFunctionInMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function _super() { } var Foo = (function () { @@ -50,7 +55,7 @@ var Foo = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.prototype.foo = function () { function _super() { @@ -63,7 +68,7 @@ var b = (function (_super) { var c = (function (_super) { __extends(c, _super); function c() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } c.prototype.foo = function () { var x = function () { diff --git a/tests/baselines/reference/collisionSuperAndLocalFunctionInProperty.js b/tests/baselines/reference/collisionSuperAndLocalFunctionInProperty.js index 67b7f0e3991..9701e9b4fc4 100644 --- a/tests/baselines/reference/collisionSuperAndLocalFunctionInProperty.js +++ b/tests/baselines/reference/collisionSuperAndLocalFunctionInProperty.js @@ -19,11 +19,16 @@ class b extends Foo { } //// [collisionSuperAndLocalFunctionInProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function _super() { } var Foo = (function () { @@ -40,7 +45,7 @@ var Foo = (function () { var b = (function (_super) { __extends(b, _super); function b() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.prop2 = { doStuff: function () { function _super() { diff --git a/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js b/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js index 26f782c0d17..3a6e8b9e772 100644 --- a/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js +++ b/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js @@ -33,11 +33,16 @@ class c extends Foo { } //// [collisionSuperAndLocalVarInAccessors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var _super = 10; // No Error var Foo = (function () { function Foo() { @@ -58,7 +63,7 @@ var Foo = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(b.prototype, "prop2", { get: function () { @@ -76,7 +81,7 @@ var b = (function (_super) { var c = (function (_super) { __extends(c, _super); function c() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(c.prototype, "prop2", { get: function () { diff --git a/tests/baselines/reference/collisionSuperAndLocalVarInConstructor.js b/tests/baselines/reference/collisionSuperAndLocalVarInConstructor.js index e3069352c08..dcbf08024a9 100644 --- a/tests/baselines/reference/collisionSuperAndLocalVarInConstructor.js +++ b/tests/baselines/reference/collisionSuperAndLocalVarInConstructor.js @@ -21,11 +21,16 @@ class c extends Foo { } //// [collisionSuperAndLocalVarInConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var _super = 10; // No Error var Foo = (function () { function Foo() { diff --git a/tests/baselines/reference/collisionSuperAndLocalVarInMethod.js b/tests/baselines/reference/collisionSuperAndLocalVarInMethod.js index 0524d993ba1..c6cce551d93 100644 --- a/tests/baselines/reference/collisionSuperAndLocalVarInMethod.js +++ b/tests/baselines/reference/collisionSuperAndLocalVarInMethod.js @@ -19,11 +19,16 @@ class c extends Foo { } //// [collisionSuperAndLocalVarInMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var _super = 10; // No Error var Foo = (function () { function Foo() { @@ -36,7 +41,7 @@ var Foo = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.prototype.foo = function () { var _super = 10; // Should be error @@ -46,7 +51,7 @@ var b = (function (_super) { var c = (function (_super) { __extends(c, _super); function c() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } c.prototype.foo = function () { var x = function () { diff --git a/tests/baselines/reference/collisionSuperAndLocalVarInProperty.js b/tests/baselines/reference/collisionSuperAndLocalVarInProperty.js index d793e022c6b..b88513b53dd 100644 --- a/tests/baselines/reference/collisionSuperAndLocalVarInProperty.js +++ b/tests/baselines/reference/collisionSuperAndLocalVarInProperty.js @@ -18,11 +18,16 @@ class b extends Foo { } //// [collisionSuperAndLocalVarInProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var _super = 10; // No Error var Foo = (function () { function Foo() { @@ -38,7 +43,7 @@ var Foo = (function () { var b = (function (_super) { __extends(b, _super); function b() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.prop2 = { doStuff: function () { var _super = 10; // Should be error diff --git a/tests/baselines/reference/collisionSuperAndNameResolution.js b/tests/baselines/reference/collisionSuperAndNameResolution.js index cb5636ec904..c35c30ec84e 100644 --- a/tests/baselines/reference/collisionSuperAndNameResolution.js +++ b/tests/baselines/reference/collisionSuperAndNameResolution.js @@ -12,11 +12,16 @@ class Foo extends base { } //// [collisionSuperAndNameResolution.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var console; var _super = 10; // No error var base = (function () { @@ -27,7 +32,7 @@ var base = (function () { var Foo = (function (_super) { __extends(Foo, _super); function Foo() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Foo.prototype.x = function () { console.log(_super); // Error as this doesnt not resolve to user defined _super diff --git a/tests/baselines/reference/collisionSuperAndParameter.js b/tests/baselines/reference/collisionSuperAndParameter.js index f5765043c55..e2771fadf1f 100644 --- a/tests/baselines/reference/collisionSuperAndParameter.js +++ b/tests/baselines/reference/collisionSuperAndParameter.js @@ -63,11 +63,16 @@ class Foo4 extends Foo { } //// [collisionSuperAndParameter.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } diff --git a/tests/baselines/reference/collisionSuperAndParameter1.js b/tests/baselines/reference/collisionSuperAndParameter1.js index ed19500f9d4..8bc3fc19b5b 100644 --- a/tests/baselines/reference/collisionSuperAndParameter1.js +++ b/tests/baselines/reference/collisionSuperAndParameter1.js @@ -10,11 +10,16 @@ class Foo2 extends Foo { } //// [collisionSuperAndParameter1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -23,7 +28,7 @@ var Foo = (function () { var Foo2 = (function (_super) { __extends(Foo2, _super); function Foo2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Foo2.prototype.x = function () { var lambda = function (_super) { diff --git a/tests/baselines/reference/collisionSuperAndPropertyNameAsConstuctorParameter.js b/tests/baselines/reference/collisionSuperAndPropertyNameAsConstuctorParameter.js index 5fa7fe29091..f905e520866 100644 --- a/tests/baselines/reference/collisionSuperAndPropertyNameAsConstuctorParameter.js +++ b/tests/baselines/reference/collisionSuperAndPropertyNameAsConstuctorParameter.js @@ -31,11 +31,16 @@ class b4 extends a { } //// [collisionSuperAndPropertyNameAsConstuctorParameter.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } diff --git a/tests/baselines/reference/collisionThisExpressionAndLocalVarWithSuperExperssion.js b/tests/baselines/reference/collisionThisExpressionAndLocalVarWithSuperExperssion.js index 9e8132c6883..d0d5059adec 100644 --- a/tests/baselines/reference/collisionThisExpressionAndLocalVarWithSuperExperssion.js +++ b/tests/baselines/reference/collisionThisExpressionAndLocalVarWithSuperExperssion.js @@ -19,11 +19,16 @@ class b2 extends a { } //// [collisionThisExpressionAndLocalVarWithSuperExperssion.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -34,7 +39,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.prototype.foo = function () { var _this = this; @@ -46,7 +51,7 @@ var b = (function (_super) { var b2 = (function (_super) { __extends(b2, _super); function b2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b2.prototype.foo = function () { var _this = this; diff --git a/tests/baselines/reference/commentLeadingCloseBrace.js b/tests/baselines/reference/commentLeadingCloseBrace.js new file mode 100644 index 00000000000..d5f5afbb884 --- /dev/null +++ b/tests/baselines/reference/commentLeadingCloseBrace.js @@ -0,0 +1,24 @@ +//// [commentLeadingCloseBrace.ts] +declare function commentedParameters(...args): any; + +function ifelse() { + if (commentedParameters(1, 2)) { + /*comment1*/ + commentedParameters(3, 4); + /*comment2*/ + } else { + commentedParameters(5, 6); + } +} + +//// [commentLeadingCloseBrace.js] +function ifelse() { + if (commentedParameters(1, 2)) { + /*comment1*/ + commentedParameters(3, 4); + /*comment2*/ + } + else { + commentedParameters(5, 6); + } +} diff --git a/tests/baselines/reference/commentLeadingCloseBrace.symbols b/tests/baselines/reference/commentLeadingCloseBrace.symbols new file mode 100644 index 00000000000..72dcfb1e047 --- /dev/null +++ b/tests/baselines/reference/commentLeadingCloseBrace.symbols @@ -0,0 +1,21 @@ +=== tests/cases/compiler/commentLeadingCloseBrace.ts === +declare function commentedParameters(...args): any; +>commentedParameters : Symbol(commentedParameters, Decl(commentLeadingCloseBrace.ts, 0, 0)) +>args : Symbol(args, Decl(commentLeadingCloseBrace.ts, 0, 37)) + +function ifelse() { +>ifelse : Symbol(ifelse, Decl(commentLeadingCloseBrace.ts, 0, 51)) + + if (commentedParameters(1, 2)) { +>commentedParameters : Symbol(commentedParameters, Decl(commentLeadingCloseBrace.ts, 0, 0)) + + /*comment1*/ + commentedParameters(3, 4); +>commentedParameters : Symbol(commentedParameters, Decl(commentLeadingCloseBrace.ts, 0, 0)) + + /*comment2*/ + } else { + commentedParameters(5, 6); +>commentedParameters : Symbol(commentedParameters, Decl(commentLeadingCloseBrace.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/commentLeadingCloseBrace.types b/tests/baselines/reference/commentLeadingCloseBrace.types new file mode 100644 index 00000000000..444320737a6 --- /dev/null +++ b/tests/baselines/reference/commentLeadingCloseBrace.types @@ -0,0 +1,30 @@ +=== tests/cases/compiler/commentLeadingCloseBrace.ts === +declare function commentedParameters(...args): any; +>commentedParameters : (...args: any[]) => any +>args : any[] + +function ifelse() { +>ifelse : () => void + + if (commentedParameters(1, 2)) { +>commentedParameters(1, 2) : any +>commentedParameters : (...args: any[]) => any +>1 : 1 +>2 : 2 + + /*comment1*/ + commentedParameters(3, 4); +>commentedParameters(3, 4) : any +>commentedParameters : (...args: any[]) => any +>3 : 3 +>4 : 4 + + /*comment2*/ + } else { + commentedParameters(5, 6); +>commentedParameters(5, 6) : any +>commentedParameters : (...args: any[]) => any +>5 : 5 +>6 : 6 + } +} diff --git a/tests/baselines/reference/commentOnArrayElement1.js b/tests/baselines/reference/commentOnArrayElement1.js new file mode 100644 index 00000000000..960df336dbb --- /dev/null +++ b/tests/baselines/reference/commentOnArrayElement1.js @@ -0,0 +1,17 @@ +//// [commentOnArrayElement1.ts] +var array = [ + /* element 1*/ + 1 + /* end of element 1 */, + 2 + /* end of element 2 */ +]; + +//// [commentOnArrayElement1.js] +var array = [ + /* element 1*/ + 1 + /* end of element 1 */ , + 2 + /* end of element 2 */ +]; diff --git a/tests/baselines/reference/commentOnArrayElement1.symbols b/tests/baselines/reference/commentOnArrayElement1.symbols new file mode 100644 index 00000000000..a504aec5c32 --- /dev/null +++ b/tests/baselines/reference/commentOnArrayElement1.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/commentOnArrayElement1.ts === +var array = [ +>array : Symbol(array, Decl(commentOnArrayElement1.ts, 0, 3)) + + /* element 1*/ + 1 + /* end of element 1 */, + 2 + /* end of element 2 */ +]; diff --git a/tests/baselines/reference/commentOnArrayElement1.types b/tests/baselines/reference/commentOnArrayElement1.types new file mode 100644 index 00000000000..f6b541ec300 --- /dev/null +++ b/tests/baselines/reference/commentOnArrayElement1.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/commentOnArrayElement1.ts === +var array = [ +>array : number[] +>[ /* element 1*/ 1 /* end of element 1 */, 2 /* end of element 2 */] : number[] + + /* element 1*/ + 1 +>1 : 1 + + /* end of element 1 */, + 2 +>2 : 2 + + /* end of element 2 */ +]; diff --git a/tests/baselines/reference/commentOnArrayElement2.js b/tests/baselines/reference/commentOnArrayElement2.js new file mode 100644 index 00000000000..1c146caed65 --- /dev/null +++ b/tests/baselines/reference/commentOnArrayElement2.js @@ -0,0 +1,15 @@ +//// [commentOnArrayElement2.ts] +var array = [ + /* element 1*/ + 1 /* end of element 1 */, + 2 + /* end of element 2 */ +]; + +//// [commentOnArrayElement2.js] +var array = [ + /* element 1*/ + 1 /* end of element 1 */, + 2 + /* end of element 2 */ +]; diff --git a/tests/baselines/reference/commentOnArrayElement2.symbols b/tests/baselines/reference/commentOnArrayElement2.symbols new file mode 100644 index 00000000000..7a6c231664b --- /dev/null +++ b/tests/baselines/reference/commentOnArrayElement2.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/commentOnArrayElement2.ts === +var array = [ +>array : Symbol(array, Decl(commentOnArrayElement2.ts, 0, 3)) + + /* element 1*/ + 1 /* end of element 1 */, + 2 + /* end of element 2 */ +]; diff --git a/tests/baselines/reference/commentOnArrayElement2.types b/tests/baselines/reference/commentOnArrayElement2.types new file mode 100644 index 00000000000..85647da74e0 --- /dev/null +++ b/tests/baselines/reference/commentOnArrayElement2.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/commentOnArrayElement2.ts === +var array = [ +>array : number[] +>[ /* element 1*/ 1 /* end of element 1 */, 2 /* end of element 2 */] : number[] + + /* element 1*/ + 1 /* end of element 1 */, +>1 : 1 + + 2 +>2 : 2 + + /* end of element 2 */ +]; diff --git a/tests/baselines/reference/commentOnArrayElement3.js b/tests/baselines/reference/commentOnArrayElement3.js new file mode 100644 index 00000000000..e31f8adf26a --- /dev/null +++ b/tests/baselines/reference/commentOnArrayElement3.js @@ -0,0 +1,19 @@ +//// [commentOnArrayElement3.ts] +var array = [ + /* element 1*/ + 1 + /* end of element 1 */, + 2 + /* end of element 2 */, , + /* extra comment */ +]; + +//// [commentOnArrayElement3.js] +var array = [ + /* element 1*/ + 1 + /* end of element 1 */ , + 2 + /* end of element 2 */ , + , +]; diff --git a/tests/baselines/reference/commentOnArrayElement3.symbols b/tests/baselines/reference/commentOnArrayElement3.symbols new file mode 100644 index 00000000000..a1c61f7155a --- /dev/null +++ b/tests/baselines/reference/commentOnArrayElement3.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/commentOnArrayElement3.ts === +var array = [ +>array : Symbol(array, Decl(commentOnArrayElement3.ts, 0, 3)) + + /* element 1*/ + 1 + /* end of element 1 */, + 2 + /* end of element 2 */, , + /* extra comment */ +]; diff --git a/tests/baselines/reference/commentOnArrayElement3.types b/tests/baselines/reference/commentOnArrayElement3.types new file mode 100644 index 00000000000..cd75c5a8db9 --- /dev/null +++ b/tests/baselines/reference/commentOnArrayElement3.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/commentOnArrayElement3.ts === +var array = [ +>array : number[] +>[ /* element 1*/ 1 /* end of element 1 */, 2 /* end of element 2 */, , /* extra comment */] : number[] + + /* element 1*/ + 1 +>1 : 1 + + /* end of element 1 */, + 2 +>2 : 2 + + /* end of element 2 */, , +> : undefined + + /* extra comment */ +]; diff --git a/tests/baselines/reference/commentOnExportEnumDeclaration.js b/tests/baselines/reference/commentOnExportEnumDeclaration.js index 61307b95b1c..353b70f4d3c 100644 --- a/tests/baselines/reference/commentOnExportEnumDeclaration.js +++ b/tests/baselines/reference/commentOnExportEnumDeclaration.js @@ -8,6 +8,7 @@ export enum Color { //// [commentOnExportEnumDeclaration.js] "use strict"; +exports.__esModule = true; /** * comment */ diff --git a/tests/baselines/reference/commentOnImportStatement1.js b/tests/baselines/reference/commentOnImportStatement1.js index d9506e00724..a9d68d299ce 100644 --- a/tests/baselines/reference/commentOnImportStatement1.js +++ b/tests/baselines/reference/commentOnImportStatement1.js @@ -8,4 +8,5 @@ import foo = require('./foo'); /* Copyright */ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/commentOnImportStatement2.js b/tests/baselines/reference/commentOnImportStatement2.js index e7550582dfe..5156fcdd0d1 100644 --- a/tests/baselines/reference/commentOnImportStatement2.js +++ b/tests/baselines/reference/commentOnImportStatement2.js @@ -4,3 +4,4 @@ import foo = require('./foo'); //// [commentOnImportStatement2.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/commentOnImportStatement3.js b/tests/baselines/reference/commentOnImportStatement3.js index f716fa32baa..c33088408e8 100644 --- a/tests/baselines/reference/commentOnImportStatement3.js +++ b/tests/baselines/reference/commentOnImportStatement3.js @@ -7,3 +7,4 @@ import foo = require('./foo'); //// [commentOnImportStatement3.js] /* copyright */ "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/commentOnParameter1.js b/tests/baselines/reference/commentOnParameter1.js new file mode 100644 index 00000000000..10ae2af1264 --- /dev/null +++ b/tests/baselines/reference/commentOnParameter1.js @@ -0,0 +1,20 @@ +//// [commentOnParameter1.ts] +function commentedParameters( +/* Parameter a */ +a +/* End of parameter a */ +/* Parameter b */ +, +b +/* End of parameter b */ +){} + +//// [commentOnParameter1.js] +function commentedParameters( + /* Parameter a */ + a + /* End of parameter a */ + /* Parameter b */ + , b + /* End of parameter b */ +) { } diff --git a/tests/baselines/reference/commentOnParameter1.symbols b/tests/baselines/reference/commentOnParameter1.symbols new file mode 100644 index 00000000000..13d91ac7abb --- /dev/null +++ b/tests/baselines/reference/commentOnParameter1.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/commentOnParameter1.ts === +function commentedParameters( +>commentedParameters : Symbol(commentedParameters, Decl(commentOnParameter1.ts, 0, 0)) + +/* Parameter a */ +a +>a : Symbol(a, Decl(commentOnParameter1.ts, 0, 29)) + +/* End of parameter a */ +/* Parameter b */ +, +b +>b : Symbol(b, Decl(commentOnParameter1.ts, 5, 1)) + +/* End of parameter b */ +){} diff --git a/tests/baselines/reference/commentOnParameter1.types b/tests/baselines/reference/commentOnParameter1.types new file mode 100644 index 00000000000..2a98a9a3f6f --- /dev/null +++ b/tests/baselines/reference/commentOnParameter1.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/commentOnParameter1.ts === +function commentedParameters( +>commentedParameters : (a: any, b: any) => void + +/* Parameter a */ +a +>a : any + +/* End of parameter a */ +/* Parameter b */ +, +b +>b : any + +/* End of parameter b */ +){} diff --git a/tests/baselines/reference/commentOnParameter2.js b/tests/baselines/reference/commentOnParameter2.js new file mode 100644 index 00000000000..d0c024a6b3b --- /dev/null +++ b/tests/baselines/reference/commentOnParameter2.js @@ -0,0 +1,18 @@ +//// [commentOnParameter2.ts] +function commentedParameters( +/* Parameter a */ +a /* End of parameter a */ +/* Parameter b */ +, +b +/* End of parameter b */ +){} + +//// [commentOnParameter2.js] +function commentedParameters( + /* Parameter a */ + a /* End of parameter a */ + /* Parameter b */ + , b + /* End of parameter b */ +) { } diff --git a/tests/baselines/reference/commentOnParameter2.symbols b/tests/baselines/reference/commentOnParameter2.symbols new file mode 100644 index 00000000000..5a6e904ed0b --- /dev/null +++ b/tests/baselines/reference/commentOnParameter2.symbols @@ -0,0 +1,15 @@ +=== tests/cases/compiler/commentOnParameter2.ts === +function commentedParameters( +>commentedParameters : Symbol(commentedParameters, Decl(commentOnParameter2.ts, 0, 0)) + +/* Parameter a */ +a /* End of parameter a */ +>a : Symbol(a, Decl(commentOnParameter2.ts, 0, 29)) + +/* Parameter b */ +, +b +>b : Symbol(b, Decl(commentOnParameter2.ts, 4, 1)) + +/* End of parameter b */ +){} diff --git a/tests/baselines/reference/commentOnParameter2.types b/tests/baselines/reference/commentOnParameter2.types new file mode 100644 index 00000000000..2d4c14db809 --- /dev/null +++ b/tests/baselines/reference/commentOnParameter2.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/commentOnParameter2.ts === +function commentedParameters( +>commentedParameters : (a: any, b: any) => void + +/* Parameter a */ +a /* End of parameter a */ +>a : any + +/* Parameter b */ +, +b +>b : any + +/* End of parameter b */ +){} diff --git a/tests/baselines/reference/commentOnParameter3.js b/tests/baselines/reference/commentOnParameter3.js new file mode 100644 index 00000000000..56172af473c --- /dev/null +++ b/tests/baselines/reference/commentOnParameter3.js @@ -0,0 +1,9 @@ +//// [commentOnParameter3.ts] +function commentedParameters( +a /* parameter a */, +b /* parameter b */, +/* extra comment */ +) { } + +//// [commentOnParameter3.js] +function commentedParameters(a /* parameter a */, b /* parameter b */) { } diff --git a/tests/baselines/reference/commentOnParameter3.symbols b/tests/baselines/reference/commentOnParameter3.symbols new file mode 100644 index 00000000000..4dda5f6d0e8 --- /dev/null +++ b/tests/baselines/reference/commentOnParameter3.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/commentOnParameter3.ts === +function commentedParameters( +>commentedParameters : Symbol(commentedParameters, Decl(commentOnParameter3.ts, 0, 0)) + +a /* parameter a */, +>a : Symbol(a, Decl(commentOnParameter3.ts, 0, 29)) + +b /* parameter b */, +>b : Symbol(b, Decl(commentOnParameter3.ts, 1, 20)) + +/* extra comment */ +) { } diff --git a/tests/baselines/reference/commentOnParameter3.types b/tests/baselines/reference/commentOnParameter3.types new file mode 100644 index 00000000000..f5b23dbceb3 --- /dev/null +++ b/tests/baselines/reference/commentOnParameter3.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/commentOnParameter3.ts === +function commentedParameters( +>commentedParameters : (a: any, b: any) => void + +a /* parameter a */, +>a : any + +b /* parameter b */, +>b : any + +/* extra comment */ +) { } diff --git a/tests/baselines/reference/commentsBeforeVariableStatement1.js b/tests/baselines/reference/commentsBeforeVariableStatement1.js index f172c40cc0d..9a06a3e7c22 100644 --- a/tests/baselines/reference/commentsBeforeVariableStatement1.js +++ b/tests/baselines/reference/commentsBeforeVariableStatement1.js @@ -6,4 +6,5 @@ export var b: number; //// [commentsBeforeVariableStatement1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/commentsDottedModuleName.js b/tests/baselines/reference/commentsDottedModuleName.js index b4819ce9ca3..1c1df104039 100644 --- a/tests/baselines/reference/commentsDottedModuleName.js +++ b/tests/baselines/reference/commentsDottedModuleName.js @@ -10,6 +10,7 @@ export module outerModule.InnerModule { //// [commentsDottedModuleName.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); /** this is multi declare module*/ var outerModule; (function (outerModule) { diff --git a/tests/baselines/reference/commentsExternalModules.js b/tests/baselines/reference/commentsExternalModules.js index 1fe24c676a7..39002f90d91 100644 --- a/tests/baselines/reference/commentsExternalModules.js +++ b/tests/baselines/reference/commentsExternalModules.js @@ -64,6 +64,7 @@ var newVar2 = new extMod.m4.m2.c(); //// [commentsExternalModules_0.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); /** Module comment*/ var m1; (function (m1) { @@ -128,6 +129,7 @@ define(["require", "exports"], function (require, exports) { //// [commentsExternalModules_1.js] define(["require", "exports", "commentsExternalModules_0"], function (require, exports, extMod) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); extMod.m1.fooExport(); var newVar = new extMod.m1.m2.c(); extMod.m4.fooExport(); diff --git a/tests/baselines/reference/commentsExternalModules2.js b/tests/baselines/reference/commentsExternalModules2.js index 18f3564ec7f..d06c588425f 100644 --- a/tests/baselines/reference/commentsExternalModules2.js +++ b/tests/baselines/reference/commentsExternalModules2.js @@ -64,6 +64,7 @@ export var newVar2 = new extMod.m4.m2.c(); //// [commentsExternalModules2_0.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); /** Module comment*/ var m1; (function (m1) { @@ -128,6 +129,7 @@ define(["require", "exports"], function (require, exports) { //// [commentsExternalModules_1.js] define(["require", "exports", "commentsExternalModules2_0"], function (require, exports, extMod) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); extMod.m1.fooExport(); exports.newVar = new extMod.m1.m2.c(); extMod.m4.fooExport(); diff --git a/tests/baselines/reference/commentsExternalModules3.js b/tests/baselines/reference/commentsExternalModules3.js index 85fbcfe019f..81e90a159d5 100644 --- a/tests/baselines/reference/commentsExternalModules3.js +++ b/tests/baselines/reference/commentsExternalModules3.js @@ -63,6 +63,7 @@ export var newVar2 = new extMod.m4.m2.c(); //// [commentsExternalModules2_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); /** Module comment*/ var m1; (function (m1) { @@ -125,6 +126,7 @@ m4.fooExport(); var myvar2 = new m4.m2.c(); //// [commentsExternalModules_1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); /**This is on import declaration*/ var extMod = require("./commentsExternalModules2_0"); // trailing comment 1 extMod.m1.fooExport(); diff --git a/tests/baselines/reference/commentsInheritance.js b/tests/baselines/reference/commentsInheritance.js index 3527f5d23bb..53fcab2cf3f 100644 --- a/tests/baselines/reference/commentsInheritance.js +++ b/tests/baselines/reference/commentsInheritance.js @@ -152,11 +152,16 @@ i2_i = i3_i; //// [commentsInheritance.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var c1 = (function () { function c1() { } @@ -258,7 +263,7 @@ c2_i = c3_i; var c4 = (function (_super) { __extends(c4, _super); function c4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return c4; }(c2)); diff --git a/tests/baselines/reference/commentsMultiModuleMultiFile.js b/tests/baselines/reference/commentsMultiModuleMultiFile.js index 67794577226..25dd8a90780 100644 --- a/tests/baselines/reference/commentsMultiModuleMultiFile.js +++ b/tests/baselines/reference/commentsMultiModuleMultiFile.js @@ -39,6 +39,7 @@ new multiM.d(); //// [commentsMultiModuleMultiFile_0.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); /** this is multi declare module*/ var multiM; (function (multiM) { @@ -73,6 +74,7 @@ define(["require", "exports"], function (require, exports) { //// [commentsMultiModuleMultiFile_1.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); /** this is multi module 3 comment*/ var multiM; (function (multiM) { diff --git a/tests/baselines/reference/commentsOnRequireStatement.js b/tests/baselines/reference/commentsOnRequireStatement.js index 9cfd75c0211..eee05c80493 100644 --- a/tests/baselines/reference/commentsOnRequireStatement.js +++ b/tests/baselines/reference/commentsOnRequireStatement.js @@ -19,12 +19,15 @@ export {subject1} from './1'; //// [0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.subject = 10; //// [1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.subject1 = 10; //// [2.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); /* blah0 */ // blah // blah diff --git a/tests/baselines/reference/commonJSImportAsPrimaryExpression.js b/tests/baselines/reference/commonJSImportAsPrimaryExpression.js index b8cf42ea762..cd62c1583bc 100644 --- a/tests/baselines/reference/commonJSImportAsPrimaryExpression.js +++ b/tests/baselines/reference/commonJSImportAsPrimaryExpression.js @@ -15,6 +15,7 @@ if(foo.C1.s1){ //// [foo_0.js] "use strict"; +exports.__esModule = true; var C1 = (function () { function C1() { this.m1 = 42; @@ -25,6 +26,8 @@ C1.s1 = true; exports.C1 = C1; //// [foo_1.js] "use strict"; +exports.__esModule = true; var foo = require("./foo_0"); if (foo.C1.s1) { + // Should cause runtime import } diff --git a/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js b/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js index eb77d1baa3c..5ac0e3fcc64 100644 --- a/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js +++ b/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js @@ -33,6 +33,7 @@ var e: number = 0; //// [foo_0.js] "use strict"; +exports.__esModule = true; var C1 = (function () { function C1() { this.m1 = 42; @@ -49,6 +50,7 @@ var E1; })(E1 = exports.E1 || (exports.E1 = {})); //// [foo_1.js] "use strict"; +exports.__esModule = true; var i; var x = {}; var y = false; diff --git a/tests/baselines/reference/commonSourceDir5.js b/tests/baselines/reference/commonSourceDir5.js index 1e404b26e13..ef6e97f4d5e 100644 --- a/tests/baselines/reference/commonSourceDir5.js +++ b/tests/baselines/reference/commonSourceDir5.js @@ -19,15 +19,18 @@ export var y = x * i; //// [concat.js] define("B:/baz", ["require", "exports", "A:/bar", "A:/foo"], function (require, exports, bar_1, foo_1) { "use strict"; + exports.__esModule = true; exports.pi = Math.PI; exports.y = bar_1.x * foo_1.i; }); define("A:/foo", ["require", "exports", "B:/baz"], function (require, exports, baz_1) { "use strict"; + exports.__esModule = true; exports.i = Math.sqrt(-1); exports.z = baz_1.pi * baz_1.pi; }); define("A:/bar", ["require", "exports", "A:/foo"], function (require, exports, foo_2) { "use strict"; + exports.__esModule = true; exports.x = foo_2.z + foo_2.z; }); diff --git a/tests/baselines/reference/commonSourceDir6.js b/tests/baselines/reference/commonSourceDir6.js index 88f5828a500..071953afcdc 100644 --- a/tests/baselines/reference/commonSourceDir6.js +++ b/tests/baselines/reference/commonSourceDir6.js @@ -18,15 +18,18 @@ export var y = x * i; //// [concat.js] define("baz", ["require", "exports", "a/bar", "a/foo"], function (require, exports, bar_1, foo_1) { "use strict"; + exports.__esModule = true; exports.pi = Math.PI; exports.y = bar_1.x * foo_1.i; }); define("a/foo", ["require", "exports", "baz"], function (require, exports, baz_1) { "use strict"; + exports.__esModule = true; exports.i = Math.sqrt(-1); exports.z = baz_1.pi * baz_1.pi; }); define("a/bar", ["require", "exports", "a/foo"], function (require, exports, foo_2) { "use strict"; + exports.__esModule = true; exports.x = foo_2.z + foo_2.z; }); diff --git a/tests/baselines/reference/commonSourceDirectory.js b/tests/baselines/reference/commonSourceDirectory.js index 1a863dbecbd..5569ae6d52b 100644 --- a/tests/baselines/reference/commonSourceDirectory.js +++ b/tests/baselines/reference/commonSourceDirectory.js @@ -19,6 +19,7 @@ x + y; //// [/app/bin/index.js] "use strict"; +exports.__esModule = true; /// var foo_1 = require("foo"); var bar_1 = require("bar"); diff --git a/tests/baselines/reference/commonSourceDirectory.js.map b/tests/baselines/reference/commonSourceDirectory.js.map index 8e3f925eee9..fd88719859b 100644 --- a/tests/baselines/reference/commonSourceDirectory.js.map +++ b/tests/baselines/reference/commonSourceDirectory.js.map @@ -1,2 +1,2 @@ //// [/app/bin/index.js.map] -{"version":3,"file":"index.js","sourceRoot":"/app/mySourceRoot/","sources":["index.ts"],"names":[],"mappings":";AAAA,yCAAyC;AACzC,2BAAwB;AACxB,2BAAwB;AACxB,OAAC,GAAG,OAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"/app/mySourceRoot/","sources":["index.ts"],"names":[],"mappings":";;AAAA,yCAAyC;AACzC,2BAAwB;AACxB,2BAAwB;AACxB,OAAC,GAAG,OAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/commonSourceDirectory.sourcemap.txt b/tests/baselines/reference/commonSourceDirectory.sourcemap.txt index ac198eaf02c..c880d2d0059 100644 --- a/tests/baselines/reference/commonSourceDirectory.sourcemap.txt +++ b/tests/baselines/reference/commonSourceDirectory.sourcemap.txt @@ -9,13 +9,14 @@ emittedFile:/app/bin/index.js sourceFile:index.ts ------------------------------------------------------------------- >>>"use strict"; +>>>exports.__esModule = true; >>>/// 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 > 2 >/// -1 >Emitted(2, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(2, 42) Source(1, 42) + SourceIndex(0) +1 >Emitted(3, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(3, 42) Source(1, 42) + SourceIndex(0) --- >>>var foo_1 = require("foo"); 1 > @@ -24,8 +25,8 @@ sourceFile:index.ts 1 > > 2 >import { x } from "foo"; -1 >Emitted(3, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(3, 28) Source(2, 25) + SourceIndex(0) +1 >Emitted(4, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(4, 28) Source(2, 25) + SourceIndex(0) --- >>>var bar_1 = require("bar"); 1-> @@ -33,8 +34,8 @@ sourceFile:index.ts 1-> > 2 >import { y } from "bar"; -1->Emitted(4, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(4, 28) Source(3, 25) + SourceIndex(0) +1->Emitted(5, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(5, 28) Source(3, 25) + SourceIndex(0) --- >>>foo_1.x + bar_1.y; 1 > @@ -49,10 +50,10 @@ sourceFile:index.ts 3 > + 4 > y 5 > ; -1 >Emitted(5, 1) Source(4, 1) + SourceIndex(0) -2 >Emitted(5, 8) Source(4, 2) + SourceIndex(0) -3 >Emitted(5, 11) Source(4, 5) + SourceIndex(0) -4 >Emitted(5, 18) Source(4, 6) + SourceIndex(0) -5 >Emitted(5, 19) Source(4, 7) + SourceIndex(0) +1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) +2 >Emitted(6, 8) Source(4, 2) + SourceIndex(0) +3 >Emitted(6, 11) Source(4, 5) + SourceIndex(0) +4 >Emitted(6, 18) Source(4, 6) + SourceIndex(0) +5 >Emitted(6, 19) Source(4, 7) + SourceIndex(0) --- >>>//# sourceMappingURL=/app/myMapRoot/index.js.map \ No newline at end of file diff --git a/tests/baselines/reference/commonSourceDirectory_dts.js b/tests/baselines/reference/commonSourceDirectory_dts.js index 8aa0bd04e11..249edeceddd 100644 --- a/tests/baselines/reference/commonSourceDirectory_dts.js +++ b/tests/baselines/reference/commonSourceDirectory_dts.js @@ -12,6 +12,7 @@ export const x = y; //// [/app/bin/index.js] "use strict"; +exports.__esModule = true; /// exports.x = y; //# sourceMappingURL=/app/myMapRoot/index.js.map diff --git a/tests/baselines/reference/commonSourceDirectory_dts.js.map b/tests/baselines/reference/commonSourceDirectory_dts.js.map index b33518dd04c..552da577884 100644 --- a/tests/baselines/reference/commonSourceDirectory_dts.js.map +++ b/tests/baselines/reference/commonSourceDirectory_dts.js.map @@ -1,2 +1,2 @@ //// [/app/bin/index.js.map] -{"version":3,"file":"index.js","sourceRoot":"/app/mySourceRoot/","sources":["index.ts"],"names":[],"mappings":";AAAA,wCAAwC;AAC3B,QAAA,CAAC,GAAG,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"/app/mySourceRoot/","sources":["index.ts"],"names":[],"mappings":";;AAAA,wCAAwC;AAC3B,QAAA,CAAC,GAAG,CAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/commonSourceDirectory_dts.sourcemap.txt b/tests/baselines/reference/commonSourceDirectory_dts.sourcemap.txt index 90603ae3652..925a3d30ed4 100644 --- a/tests/baselines/reference/commonSourceDirectory_dts.sourcemap.txt +++ b/tests/baselines/reference/commonSourceDirectory_dts.sourcemap.txt @@ -9,13 +9,14 @@ emittedFile:/app/bin/index.js sourceFile:index.ts ------------------------------------------------------------------- >>>"use strict"; +>>>exports.__esModule = true; >>>/// 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 > 2 >/// -1 >Emitted(2, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(2, 41) Source(1, 41) + SourceIndex(0) +1 >Emitted(3, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(3, 41) Source(1, 41) + SourceIndex(0) --- >>>exports.x = y; 1 > @@ -32,11 +33,11 @@ sourceFile:index.ts 4 > = 5 > y 6 > ; -1 >Emitted(3, 1) Source(2, 14) + SourceIndex(0) -2 >Emitted(3, 9) Source(2, 14) + SourceIndex(0) -3 >Emitted(3, 10) Source(2, 15) + SourceIndex(0) -4 >Emitted(3, 13) Source(2, 18) + SourceIndex(0) -5 >Emitted(3, 14) Source(2, 19) + SourceIndex(0) -6 >Emitted(3, 15) Source(2, 20) + SourceIndex(0) +1 >Emitted(4, 1) Source(2, 14) + SourceIndex(0) +2 >Emitted(4, 9) Source(2, 14) + SourceIndex(0) +3 >Emitted(4, 10) Source(2, 15) + SourceIndex(0) +4 >Emitted(4, 13) Source(2, 18) + SourceIndex(0) +5 >Emitted(4, 14) Source(2, 19) + SourceIndex(0) +6 >Emitted(4, 15) Source(2, 20) + SourceIndex(0) --- >>>//# sourceMappingURL=/app/myMapRoot/index.js.map \ No newline at end of file diff --git a/tests/baselines/reference/commonjsSafeImport.js b/tests/baselines/reference/commonjsSafeImport.js index 93439a418f6..e7a251e9cee 100644 --- a/tests/baselines/reference/commonjsSafeImport.js +++ b/tests/baselines/reference/commonjsSafeImport.js @@ -12,10 +12,12 @@ Foo(); //// [10_lib.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); function Foo() { } exports.Foo = Foo; //// [main.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var _10_lib_1 = require("./10_lib"); _10_lib_1.Foo(); diff --git a/tests/baselines/reference/comparisonOperatorWithIdenticalObjects.js b/tests/baselines/reference/comparisonOperatorWithIdenticalObjects.js index a263a30e382..f017fe974bc 100644 --- a/tests/baselines/reference/comparisonOperatorWithIdenticalObjects.js +++ b/tests/baselines/reference/comparisonOperatorWithIdenticalObjects.js @@ -195,11 +195,16 @@ var r8b6 = b5 !== a5; var r8b7 = b6 !== a6; //// [comparisonOperatorWithIdenticalObjects.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A1 = (function () { function A1() { } @@ -227,14 +232,14 @@ var Base = (function () { var A2 = (function (_super) { __extends(A2, _super); function A2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A2; }(Base)); var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithIdenticalPrimitiveType.errors.txt b/tests/baselines/reference/comparisonOperatorWithIdenticalPrimitiveType.errors.txt new file mode 100644 index 00000000000..ad41a280aad --- /dev/null +++ b/tests/baselines/reference/comparisonOperatorWithIdenticalPrimitiveType.errors.txt @@ -0,0 +1,130 @@ +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(15,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(15,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(16,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(16,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(24,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(24,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(25,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(25,23): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(33,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(33,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(34,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(34,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(42,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(42,19): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(43,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts(43,24): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts (16 errors) ==== + enum E { a, b, c } + + var a: number; + var b: boolean; + var c: string; + var d: void; + var e: E; + + // operator < + var ra1 = a < a; + var ra2 = b < b; + var ra3 = c < c; + var ra4 = d < d; + var ra5 = e < e; + var ra6 = null < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var ra7 = undefined < undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator > + var rb1 = a > a; + var rb2 = b > b; + var rb3 = c > c; + var rb4 = d > d; + var rb5 = e > e; + var rb6 = null > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rb7 = undefined > undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator <= + var rc1 = a <= a; + var rc2 = b <= b; + var rc3 = c <= c; + var rc4 = d <= d; + var rc5 = e <= e; + var rc6 = null <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rc7 = undefined <= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator >= + var rd1 = a >= a; + var rd2 = b >= b; + var rd3 = c >= c; + var rd4 = d >= d; + var rd5 = e >= e; + var rd6 = null >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var rd7 = undefined >= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + // operator == + var re1 = a == a; + var re2 = b == b; + var re3 = c == c; + var re4 = d == d; + var re5 = e == e; + var re6 = null == null; + var re7 = undefined == undefined; + + // operator != + var rf1 = a != a; + var rf2 = b != b; + var rf3 = c != c; + var rf4 = d != d; + var rf5 = e != e; + var rf6 = null != null; + var rf7 = undefined != undefined; + + // operator === + var rg1 = a === a; + var rg2 = b === b; + var rg3 = c === c; + var rg4 = d === d; + var rg5 = e === e; + var rg6 = null === null; + var rg7 = undefined === undefined; + + // operator !== + var rh1 = a !== a; + var rh2 = b !== b; + var rh3 = c !== c; + var rh4 = d !== d; + var rh5 = e !== e; + var rh6 = null !== null; + var rh7 = undefined !== undefined; \ No newline at end of file diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.js index b8584522b7b..b63b2fa7110 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.js @@ -169,11 +169,16 @@ var r8b6 = b6 !== a6; var r8b7 = b7 !== a7; //// [comparisonOperatorWithNoRelationshipObjectsOnCallSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -182,7 +187,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.js index 93e1e876a7f..cecdb97e164 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.js @@ -169,11 +169,16 @@ var r8b6 = b6 !== a6; var r8b7 = b7 !== a7; //// [comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -182,7 +187,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.js index a8973bf2c10..6fc8effabd0 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.js @@ -112,11 +112,16 @@ var r8b3 = b3 !== a3; var r8b4 = b4 !== a4; //// [comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -125,7 +130,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.js index 4539538782d..fd9f0ffabe1 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.js @@ -150,11 +150,16 @@ var r8b5 = b5 !== a5; var r8b6 = b6 !== a6; //// [comparisonOperatorWithNoRelationshipObjectsOnInstantiatedCallSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -163,7 +168,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.js b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.js index 5e8412bc361..5898bdd6f2b 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.js @@ -150,11 +150,16 @@ var r8b5 = b5 !== a5; var r8b6 = b6 !== a6; //// [comparisonOperatorWithNoRelationshipObjectsOnInstantiatedConstructorSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -163,7 +168,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithOneOperandIsNull.errors.txt b/tests/baselines/reference/comparisonOperatorWithOneOperandIsNull.errors.txt new file mode 100644 index 00000000000..c74ab997a59 --- /dev/null +++ b/tests/baselines/reference/comparisonOperatorWithOneOperandIsNull.errors.txt @@ -0,0 +1,360 @@ +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(4,22): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(5,22): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(6,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(7,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(13,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(14,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(15,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(16,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(32,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(33,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(34,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(35,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(36,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(37,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(38,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(40,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(41,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(42,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(43,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(44,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(45,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(46,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(49,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(50,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(51,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(52,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(53,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(54,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(55,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(57,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(58,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(59,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(60,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(61,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(62,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(63,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(66,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(67,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(68,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(69,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(70,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(71,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(72,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(74,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(75,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(76,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(77,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(78,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(79,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(80,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(83,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(84,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(85,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(86,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(87,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(88,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(89,12): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(91,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(92,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(93,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(94,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(95,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(96,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts(97,17): error TS2531: Object is possibly 'null'. + + +==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts (64 errors) ==== + enum E { a, b, c } + + function foo(t: T) { + var foo_r1 = t < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r2 = t > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r3 = t <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r4 = t >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r5 = t == null; + var foo_r6 = t != null; + var foo_r7 = t === null; + var foo_r8 = t !== null; + + var foo_r1 = null < t; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r2 = null > t; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r3 = null <= t; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r4 = null >= t; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var foo_r5 = null == t; + var foo_r6 = null != t; + var foo_r7 = null === t; + var foo_r8 = null !== t; + } + + var a: boolean; + var b: number; + var c: string; + var d: void; + var e: E; + var f: {}; + var g: string[]; + + // operator < + var r1a1 = null < a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1a2 = null < b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1a3 = null < c; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1a4 = null < d; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1a5 = null < e; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1a6 = null < f; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1a7 = null < g; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + var r1b1 = a < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1b2 = b < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1b3 = c < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1b4 = d < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1b5 = e < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1b6 = f < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r1b7 = g < null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator > + var r2a1 = null > a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2a2 = null > b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2a3 = null > c; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2a4 = null > d; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2a5 = null > e; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2a6 = null > f; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2a7 = null > g; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + var r2b1 = a > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2b2 = b > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2b3 = c > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2b4 = d > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2b5 = e > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2b6 = f > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2b7 = g > null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator <= + var r3a1 = null <= a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3a2 = null <= b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3a3 = null <= c; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3a4 = null <= d; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3a5 = null <= e; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3a6 = null <= f; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3a7 = null <= g; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + var r3b1 = a <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3b2 = b <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3b3 = c <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3b4 = d <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3b5 = e <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3b6 = f <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3b7 = g <= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator >= + var r4a1 = null >= a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4a2 = null >= b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4a3 = null >= c; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4a4 = null >= d; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4a5 = null >= e; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4a6 = null >= f; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4a7 = null >= g; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + var r4b1 = a >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4b2 = b >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4b3 = c >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4b4 = d >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4b5 = e >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4b6 = f >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4b7 = g >= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + + // operator == + var r5a1 = null == a; + var r5a2 = null == b; + var r5a3 = null == c; + var r5a4 = null == d; + var r5a5 = null == e; + var r5a6 = null == f; + var r5a7 = null == g; + + var r5b1 = a == null; + var r5b2 = b == null; + var r5b3 = c == null; + var r5b4 = d == null; + var r5b5 = e == null; + var r5b6 = f == null; + var r5b7 = g == null; + + // operator != + var r6a1 = null != a; + var r6a2 = null != b; + var r6a3 = null != c; + var r6a4 = null != d; + var r6a5 = null != e; + var r6a6 = null != f; + var r6a7 = null != g; + + var r6b1 = a != null; + var r6b2 = b != null; + var r6b3 = c != null; + var r6b4 = d != null; + var r6b5 = e != null; + var r6b6 = f != null; + var r6b7 = g != null; + + // operator === + var r7a1 = null === a; + var r7a2 = null === b; + var r7a3 = null === c; + var r7a4 = null === d; + var r7a5 = null === e; + var r7a6 = null === f; + var r7a7 = null === g; + + var r7b1 = a === null; + var r7b2 = b === null; + var r7b3 = c === null; + var r7b4 = d === null; + var r7b5 = e === null; + var r7b6 = f === null; + var r7b7 = g === null; + + // operator !== + var r8a1 = null !== a; + var r8a2 = null !== b; + var r8a3 = null !== c; + var r8a4 = null !== d; + var r8a5 = null !== e; + var r8a6 = null !== f; + var r8a7 = null !== g; + + var r8b1 = a !== null; + var r8b2 = b !== null; + var r8b3 = c !== null; + var r8b4 = d !== null; + var r8b5 = e !== null; + var r8b6 = f !== null; + var r8b7 = g !== null; \ No newline at end of file diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js index d30c3586b12..1a3bdca7d95 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js @@ -260,11 +260,16 @@ var r8b11 = b11 !== a11; //var r8b12 = b12 !== a12; //// [comparisonOperatorWithSubtypeObjectOnCallSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -273,7 +278,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js index 4235c1352d4..8f23651af05 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js @@ -222,11 +222,16 @@ var r8b9 = b9 !== a9; //var r8b10 = b10 !== a10; //// [comparisonOperatorWithSubtypeObjectOnConstructorSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -235,7 +240,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnIndexSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnIndexSignature.js index 9a6fecd668d..b77b5dd6e4a 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnIndexSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnIndexSignature.js @@ -108,11 +108,16 @@ var r8b1 = b3 !== a3; var r8b1 = b4 !== a4; //// [comparisonOperatorWithSubtypeObjectOnIndexSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -121,7 +126,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js index 5721a452486..b82063b4aed 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js @@ -165,11 +165,16 @@ var r8b6 = b6 !== a6; //var r8b7 = b7 !== a7; //// [comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -178,7 +183,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js index b6bf8a16e61..d83b7b2d5c0 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js @@ -165,11 +165,16 @@ var r8b6 = b6 !== a6; //var r8b7 = b7 !== a7; //// [comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -178,7 +183,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnProperty.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnProperty.js index 690214fc00f..e0befa2237e 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnProperty.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnProperty.js @@ -79,11 +79,16 @@ var rh3 = b1 !== a1; var rh4 = b2 !== a2; //// [comparisonOperatorWithSubtypeObjectOnProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -92,7 +97,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -114,7 +119,7 @@ var A2 = (function () { var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A2)); diff --git a/tests/baselines/reference/complexClassRelationships.js b/tests/baselines/reference/complexClassRelationships.js index 4f48e5fc2c5..2bc345bd499 100644 --- a/tests/baselines/reference/complexClassRelationships.js +++ b/tests/baselines/reference/complexClassRelationships.js @@ -48,16 +48,21 @@ class FooBase { } //// [complexClassRelationships.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // There should be no errors in this file var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.createEmpty = function () { var item = new Derived(); diff --git a/tests/baselines/reference/complexNarrowingWithAny.js b/tests/baselines/reference/complexNarrowingWithAny.js index 0a137f5d793..4408d64acbf 100644 --- a/tests/baselines/reference/complexNarrowingWithAny.js +++ b/tests/baselines/reference/complexNarrowingWithAny.js @@ -562,6 +562,7 @@ export function viewFactory_AppComponent0(viewUtils:any,parentInjector:any,decla //// [complexNarrowingWithAny.js] // Repro from #10869 "use strict"; +exports.__esModule = true; /** * This file is generated by the Angular 2 template compiler. * Do not edit. diff --git a/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.js b/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.js index 326c0830c4f..bc9bbcdaa16 100644 --- a/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.js +++ b/tests/baselines/reference/complicatedGenericRecursiveBaseClassReference.js @@ -6,15 +6,20 @@ class S18 extends S18 //// [complicatedGenericRecursiveBaseClassReference.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var S18 = (function (_super) { __extends(S18, _super); function S18() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return S18; }(S18)); diff --git a/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.errors.txt b/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.errors.txt new file mode 100644 index 00000000000..08d8fd0c6d3 --- /dev/null +++ b/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.errors.txt @@ -0,0 +1,65 @@ +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(32,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(33,7): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(39,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(40,7): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts (4 errors) ==== + enum E { a, b } + + var a: any; + var b: void; + + var x1: any; + x1 += a; + x1 += b; + x1 += true; + x1 += 0; + x1 += ''; + x1 += E.a; + x1 += {}; + x1 += null; + x1 += undefined; + + var x2: string; + x2 += a; + x2 += b; + x2 += true; + x2 += 0; + x2 += ''; + x2 += E.a; + x2 += {}; + x2 += null; + x2 += undefined; + + var x3: number; + x3 += a; + x3 += 0; + x3 += E.a; + x3 += null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x3 += undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + var x4: E; + x4 += a; + x4 += 0; + x4 += E.a; + x4 += null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x4 += undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + var x5: boolean; + x5 += a; + + var x6: {}; + x6 += a; + x6 += ''; + + var x7: void; + x7 += a; \ No newline at end of file diff --git a/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt b/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt index cadc5c945d1..1812065f149 100644 --- a/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt +++ b/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt @@ -3,22 +3,22 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(8,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and '0'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(9,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'E.a'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(10,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and '{}'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(11,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'boolean'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(12,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'boolean'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(11,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(12,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(15,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'void'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(16,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'true'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(17,1): error TS2365: Operator '+=' cannot be applied to types '{}' and '0'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(18,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'E.a'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(19,1): error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(20,1): error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(21,1): error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(20,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(21,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(24,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(25,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'true'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(26,1): error TS2365: Operator '+=' cannot be applied to types 'void' and '0'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(27,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'E.a'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(28,1): error TS2365: Operator '+=' cannot be applied to types 'void' and '{}'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(29,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(30,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(29,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(30,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(33,1): error TS2365: Operator '+=' cannot be applied to types 'number' and 'void'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(34,1): error TS2365: Operator '+=' cannot be applied to types 'number' and 'true'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(35,1): error TS2365: Operator '+=' cannot be applied to types 'number' and '{}'. @@ -49,11 +49,11 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen ~~~~~~~~ !!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and '{}'. x1 += null; - ~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'boolean'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. x1 += undefined; - ~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'boolean'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x2: {}; x2 += a; @@ -72,11 +72,11 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen ~~~~~~~~ !!! error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. x2 += null; - ~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. x2 += undefined; - ~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x3: void; x3 += a; @@ -95,11 +95,11 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen ~~~~~~~~ !!! error TS2365: Operator '+=' cannot be applied to types 'void' and '{}'. x3 += null; - ~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. x3 += undefined; - ~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x4: number; x4 += a; diff --git a/tests/baselines/reference/compoundArithmeticAssignmentLHSCanBeAssigned.errors.txt b/tests/baselines/reference/compoundArithmeticAssignmentLHSCanBeAssigned.errors.txt new file mode 100644 index 00000000000..f438045a45f --- /dev/null +++ b/tests/baselines/reference/compoundArithmeticAssignmentLHSCanBeAssigned.errors.txt @@ -0,0 +1,47 @@ +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts(11,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts(12,7): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts(18,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts(19,7): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts(25,7): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts(26,7): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts (6 errors) ==== + enum E { a, b, c } + + var a: any; + var b: number; + var c: E; + + var x1: any; + x1 *= a; + x1 *= b; + x1 *= c; + x1 *= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x1 *= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + var x2: number; + x2 *= a; + x2 *= b; + x2 *= c; + x2 *= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x2 *= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + var x3: E; + x3 *= a; + x3 *= b; + x3 *= c; + x3 *= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x3 *= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/compoundArithmeticAssignmentWithInvalidOperands.errors.txt b/tests/baselines/reference/compoundArithmeticAssignmentWithInvalidOperands.errors.txt index 9367285ef93..7429445b422 100644 --- a/tests/baselines/reference/compoundArithmeticAssignmentWithInvalidOperands.errors.txt +++ b/tests/baselines/reference/compoundArithmeticAssignmentWithInvalidOperands.errors.txt @@ -10,9 +10,9 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(13,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/compoundArithmeticAssignmentWithInvalidOperands.ts(13,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(14,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/compoundArithmeticAssignmentWithInvalidOperands.ts(14,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(14,7): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(15,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/compoundArithmeticAssignmentWithInvalidOperands.ts(15,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(15,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(18,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/compoundArithmeticAssignmentWithInvalidOperands.ts(19,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/compoundArithmeticAssignmentWithInvalidOperands.ts(19,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -25,9 +25,9 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(24,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/compoundArithmeticAssignmentWithInvalidOperands.ts(24,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(25,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/compoundArithmeticAssignmentWithInvalidOperands.ts(25,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(25,7): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(26,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/compoundArithmeticAssignmentWithInvalidOperands.ts(26,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(26,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(29,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/compoundArithmeticAssignmentWithInvalidOperands.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/compoundArithmeticAssignmentWithInvalidOperands.ts(30,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -40,9 +40,9 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(35,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/compoundArithmeticAssignmentWithInvalidOperands.ts(35,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(36,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/compoundArithmeticAssignmentWithInvalidOperands.ts(36,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(36,7): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.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/compoundArithmeticAssignmentWithInvalidOperands.ts(37,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(37,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.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/compoundArithmeticAssignmentWithInvalidOperands.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/compoundArithmeticAssignmentWithInvalidOperands.ts(41,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -55,9 +55,9 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.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/compoundArithmeticAssignmentWithInvalidOperands.ts(46,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.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/compoundArithmeticAssignmentWithInvalidOperands.ts(47,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(47,7): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.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/compoundArithmeticAssignmentWithInvalidOperands.ts(48,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(48,7): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(51,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(52,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentWithInvalidOperands.ts(53,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -108,12 +108,12 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm ~~ !!! 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 TS2531: Object is possibly 'null'. x1 *= undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var x2: string; x2 *= a; @@ -149,12 +149,12 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm ~~ !!! 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 TS2531: Object is possibly 'null'. x2 *= undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var x3: {}; x3 *= a; @@ -190,12 +190,12 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm ~~ !!! 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 TS2531: Object is possibly 'null'. x3 *= undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var x4: void; x4 *= a; @@ -231,12 +231,12 @@ tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignm ~~ !!! 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 TS2531: Object is possibly 'null'. x4 *= undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var x5: number; x5 *= b; diff --git a/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt b/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt index bc6bb41b27f..8948467c590 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt +++ b/tests/baselines/reference/compoundAssignmentLHSIsValue.errors.txt @@ -17,6 +17,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(41,1): error TS2539: Cannot assign to 'foo' because it is not a variable. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(42,1): error TS2539: Cannot assign to 'foo' because it is not a variable. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(45,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(45,1): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(46,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. 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: The left-hand side of an assignment expression must be a variable or a property access. @@ -55,6 +56,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(104,2): error TS2539: Cannot assign to 'foo' because it is not a variable. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(105,2): error TS2539: Cannot assign to 'foo' because it is not a variable. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(106,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(106,1): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(107,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. 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: The left-hand side of an assignment expression must be a variable or a property access. @@ -74,7 +76,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(123,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. -==== tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts (74 errors) ==== +==== tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts (76 errors) ==== // expected error for all the LHS of compound assignments (arithmetic and addition) var value: any; @@ -158,6 +160,8 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa null *= value; ~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. + ~~~~ +!!! error TS2531: Object is possibly 'null'. null += value; ~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. @@ -295,6 +299,8 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa (null) *= value; ~~~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. + ~~~~~~ +!!! error TS2531: Object is possibly 'null'. (null) += value; ~~~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. diff --git a/tests/baselines/reference/compoundAssignmentLHSIsValue.js b/tests/baselines/reference/compoundAssignmentLHSIsValue.js index df3015731c7..064f2157c1e 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsValue.js +++ b/tests/baselines/reference/compoundAssignmentLHSIsValue.js @@ -124,11 +124,16 @@ foo() += value; (foo()) += value; //// [compoundAssignmentLHSIsValue.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // expected error for all the LHS of compound assignments (arithmetic and addition) var value; // this diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSCanBeAssigned1.errors.txt b/tests/baselines/reference/compoundExponentiationAssignmentLHSCanBeAssigned1.errors.txt new file mode 100644 index 00000000000..26f23028dfa --- /dev/null +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSCanBeAssigned1.errors.txt @@ -0,0 +1,47 @@ +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts(11,8): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts(12,8): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts(18,8): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts(19,8): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts(25,8): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts(26,8): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts (6 errors) ==== + enum E { a, b, c } + + var a: any; + var b: number; + var c: E; + + var x1: any; + x1 **= a; + x1 **= b; + x1 **= c; + x1 **= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x1 **= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + var x2: number; + x2 **= a; + x2 **= b; + x2 **= c; + x2 **= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x2 **= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + var x3: E; + x3 **= a; + x3 **= b; + x3 **= c; + x3 **= null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + x3 **= undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSCannotBeAssigned.errors.txt b/tests/baselines/reference/compoundExponentiationAssignmentLHSCannotBeAssigned.errors.txt index 8d152712808..6d48d968638 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSCannotBeAssigned.errors.txt +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSCannotBeAssigned.errors.txt @@ -10,9 +10,9 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(13,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/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(13,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(14,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/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(14,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(14,8): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(15,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/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(15,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(15,8): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(18,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/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(19,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/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(19,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -25,9 +25,9 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(24,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/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(24,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(25,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/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(25,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(25,8): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(26,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/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(26,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(26,8): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(29,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/compoundExponentiationAssignmentLHSCannotBeAssigned.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/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(30,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -40,9 +40,9 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(35,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/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(35,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(36,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/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(36,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(36,8): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.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/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(37,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(37,8): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.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/compoundExponentiationAssignmentLHSCannotBeAssigned.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/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(41,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -55,9 +55,9 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.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/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(46,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.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/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(47,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(47,8): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.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/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(48,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(48,8): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(51,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(52,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCannotBeAssigned.ts(53,8): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -108,12 +108,12 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm ~~ !!! 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 TS2531: Object is possibly 'null'. x1 **= undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var x2: string; x2 **= a; @@ -149,12 +149,12 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm ~~ !!! 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 TS2531: Object is possibly 'null'. x2 **= undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var x3: {}; x3 **= a; @@ -190,12 +190,12 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm ~~ !!! 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 TS2531: Object is possibly 'null'. x3 **= undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var x4: void; x4 **= a; @@ -231,12 +231,12 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm ~~ !!! 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 TS2531: Object is possibly 'null'. x4 **= undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var x5: number; x5 **= b; diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt index 22eeb18ac4a..51b69f81620 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.errors.txt @@ -8,6 +8,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(30,1): error TS2539: Cannot assign to 'E' because it is not a variable. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(32,1): error TS2539: Cannot assign to 'foo' because it is not a variable. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(35,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(35,1): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(36,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,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(38,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. @@ -28,6 +29,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(75,2): error TS2539: Cannot assign to 'E' because it is not a variable. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(76,2): error TS2539: Cannot assign to 'foo' because it is not a variable. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(77,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(77,1): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(78,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(79,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(80,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -38,7 +40,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 (38 errors) ==== +==== tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts (40 errors) ==== // expected error for all the LHS of compound assignments (arithmetic and addition) var value: any; @@ -94,6 +96,8 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm null **= value; ~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. + ~~~~ +!!! error TS2531: Object is possibly 'null'. true **= value; ~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -176,6 +180,8 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm (null) **= value; ~~~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. + ~~~~~~ +!!! error TS2531: Object is possibly 'null'. (true) **= value; ~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.js b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.js index d188a592588..bd152ea11ad 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.js +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.js @@ -86,11 +86,16 @@ foo() **= value; (foo()) **= value; //// [compoundExponentiationAssignmentLHSIsValue.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // expected error for all the LHS of compound assignments (arithmetic and addition) var value; // this diff --git a/tests/baselines/reference/computedPropertyNames10_ES5.types b/tests/baselines/reference/computedPropertyNames10_ES5.types index 650890fb10e..96130979298 100644 --- a/tests/baselines/reference/computedPropertyNames10_ES5.types +++ b/tests/baselines/reference/computedPropertyNames10_ES5.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: () => void; [x: number]: () => void; [0](): void; [""](): void; } ->{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [x: string]: () => void; [x: number]: () => void; [0](): void; [""](): void; } +>v : { [x: string]: () => void; [x: number]: () => void; [""](): void; [0](): void; } +>{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [x: string]: () => void; [x: number]: () => void; [""](): void; [0](): void; } [s]() { }, >s : string diff --git a/tests/baselines/reference/computedPropertyNames10_ES6.types b/tests/baselines/reference/computedPropertyNames10_ES6.types index 2ff86ed9712..5bbda2e8f19 100644 --- a/tests/baselines/reference/computedPropertyNames10_ES6.types +++ b/tests/baselines/reference/computedPropertyNames10_ES6.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: () => void; [x: number]: () => void; [0](): void; [""](): void; } ->{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [x: string]: () => void; [x: number]: () => void; [0](): void; [""](): void; } +>v : { [x: string]: () => void; [x: number]: () => void; [""](): void; [0](): void; } +>{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [x: string]: () => void; [x: number]: () => void; [""](): void; [0](): void; } [s]() { }, >s : string diff --git a/tests/baselines/reference/computedPropertyNames11_ES5.types b/tests/baselines/reference/computedPropertyNames11_ES5.types index 0787a889f40..88fbc690323 100644 --- a/tests/baselines/reference/computedPropertyNames11_ES5.types +++ b/tests/baselines/reference/computedPropertyNames11_ES5.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: any; [x: number]: any; readonly [0]: number; [""]: any; } ->{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : { [x: string]: any; [x: number]: any; readonly [0]: number; [""]: any; } +>v : { [x: string]: any; [x: number]: any; [""]: any; readonly [0]: number; } +>{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : { [x: string]: any; [x: number]: any; [""]: any; readonly [0]: number; } get [s]() { return 0; }, >s : string diff --git a/tests/baselines/reference/computedPropertyNames11_ES6.types b/tests/baselines/reference/computedPropertyNames11_ES6.types index 4783d07a2af..458d6d1de49 100644 --- a/tests/baselines/reference/computedPropertyNames11_ES6.types +++ b/tests/baselines/reference/computedPropertyNames11_ES6.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: any; [x: number]: any; readonly [0]: number; [""]: any; } ->{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : { [x: string]: any; [x: number]: any; readonly [0]: number; [""]: any; } +>v : { [x: string]: any; [x: number]: any; [""]: any; readonly [0]: number; } +>{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : { [x: string]: any; [x: number]: any; [""]: any; readonly [0]: number; } get [s]() { return 0; }, >s : string diff --git a/tests/baselines/reference/computedPropertyNames24_ES5.js b/tests/baselines/reference/computedPropertyNames24_ES5.js index ff9112755bd..dd229bdcae2 100644 --- a/tests/baselines/reference/computedPropertyNames24_ES5.js +++ b/tests/baselines/reference/computedPropertyNames24_ES5.js @@ -9,11 +9,16 @@ class C extends Base { } //// [computedPropertyNames24_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -25,7 +30,7 @@ var Base = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype[_super.bar.call(this)] = function () { }; return C; diff --git a/tests/baselines/reference/computedPropertyNames25_ES5.js b/tests/baselines/reference/computedPropertyNames25_ES5.js index dad9c5c291a..18ee07301e7 100644 --- a/tests/baselines/reference/computedPropertyNames25_ES5.js +++ b/tests/baselines/reference/computedPropertyNames25_ES5.js @@ -14,11 +14,16 @@ class C extends Base { } //// [computedPropertyNames25_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -30,7 +35,7 @@ var Base = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.foo = function () { var obj = (_a = {}, diff --git a/tests/baselines/reference/computedPropertyNames26_ES5.js b/tests/baselines/reference/computedPropertyNames26_ES5.js index 5db7768270a..78a7ef3af77 100644 --- a/tests/baselines/reference/computedPropertyNames26_ES5.js +++ b/tests/baselines/reference/computedPropertyNames26_ES5.js @@ -11,11 +11,16 @@ class C extends Base { } //// [computedPropertyNames26_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -27,7 +32,7 @@ var Base = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype[(_a = {}, _a[_super.bar.call(this)] = 1, _a)[0]] = function () { }; return C; diff --git a/tests/baselines/reference/computedPropertyNames27_ES5.js b/tests/baselines/reference/computedPropertyNames27_ES5.js index 381805659e2..9af56a8835b 100644 --- a/tests/baselines/reference/computedPropertyNames27_ES5.js +++ b/tests/baselines/reference/computedPropertyNames27_ES5.js @@ -6,11 +6,16 @@ class C extends Base { } //// [computedPropertyNames27_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -19,7 +24,7 @@ var Base = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype[(_this = _super.call(this) || this, "prop")] = function () { }; return C; diff --git a/tests/baselines/reference/computedPropertyNames28_ES5.js b/tests/baselines/reference/computedPropertyNames28_ES5.js index ab765c56dd7..c6e2c5d7732 100644 --- a/tests/baselines/reference/computedPropertyNames28_ES5.js +++ b/tests/baselines/reference/computedPropertyNames28_ES5.js @@ -11,11 +11,16 @@ class C extends Base { } //// [computedPropertyNames28_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } diff --git a/tests/baselines/reference/computedPropertyNames30_ES5.js b/tests/baselines/reference/computedPropertyNames30_ES5.js index c2c7cddd971..f029b9b8651 100644 --- a/tests/baselines/reference/computedPropertyNames30_ES5.js +++ b/tests/baselines/reference/computedPropertyNames30_ES5.js @@ -16,11 +16,16 @@ class C extends Base { } //// [computedPropertyNames30_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } diff --git a/tests/baselines/reference/computedPropertyNames31_ES5.js b/tests/baselines/reference/computedPropertyNames31_ES5.js index 00cc765f4cc..95caabc4bda 100644 --- a/tests/baselines/reference/computedPropertyNames31_ES5.js +++ b/tests/baselines/reference/computedPropertyNames31_ES5.js @@ -16,11 +16,16 @@ class C extends Base { } //// [computedPropertyNames31_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -32,7 +37,7 @@ var Base = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.foo = function () { var _this = this; diff --git a/tests/baselines/reference/computedPropertyNames43_ES5.js b/tests/baselines/reference/computedPropertyNames43_ES5.js index b1bb0fec72c..100683519ec 100644 --- a/tests/baselines/reference/computedPropertyNames43_ES5.js +++ b/tests/baselines/reference/computedPropertyNames43_ES5.js @@ -13,11 +13,16 @@ class D extends C { } //// [computedPropertyNames43_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -36,7 +41,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(D.prototype, "get1", { // Computed properties diff --git a/tests/baselines/reference/computedPropertyNames44_ES5.js b/tests/baselines/reference/computedPropertyNames44_ES5.js index bf940f15014..0291e337591 100644 --- a/tests/baselines/reference/computedPropertyNames44_ES5.js +++ b/tests/baselines/reference/computedPropertyNames44_ES5.js @@ -12,11 +12,16 @@ class D extends C { } //// [computedPropertyNames44_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -40,7 +45,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(D.prototype, "set1", { set: function (p) { }, diff --git a/tests/baselines/reference/computedPropertyNames45_ES5.js b/tests/baselines/reference/computedPropertyNames45_ES5.js index 5b5d64f9bf0..3bc7e6e350d 100644 --- a/tests/baselines/reference/computedPropertyNames45_ES5.js +++ b/tests/baselines/reference/computedPropertyNames45_ES5.js @@ -13,11 +13,16 @@ class D extends C { } //// [computedPropertyNames45_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -41,7 +46,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(D.prototype, "set1", { set: function (p) { }, diff --git a/tests/baselines/reference/computedPropertyNames4_ES5.types b/tests/baselines/reference/computedPropertyNames4_ES5.types index 64ef5f6a611..6f875aaddac 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES5.types +++ b/tests/baselines/reference/computedPropertyNames4_ES5.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: string | number; [x: number]: string | number; [0]: number; [""]: number; } ->{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [0]: number; [""]: number; } +>v : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } +>{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } [s]: 0, >s : string diff --git a/tests/baselines/reference/computedPropertyNames4_ES6.types b/tests/baselines/reference/computedPropertyNames4_ES6.types index 0c608e21601..e9feac0a81f 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES6.types +++ b/tests/baselines/reference/computedPropertyNames4_ES6.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: string | number; [x: number]: string | number; [0]: number; [""]: number; } ->{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [0]: number; [""]: number; } +>v : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } +>{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } [s]: 0, >s : string diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types index 91ad88c8ade..f144bb9d020 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types @@ -19,7 +19,7 @@ declare function foo(obj: I): T foo({ >foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[] >foo : (obj: I) => T ->{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: true | "" | (() => void) | 0 | number[]; [x: number]: (() => void) | 0 | number[]; 0: () => void; p: ""; } +>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: true | "" | (() => void) | 0 | number[]; [x: number]: (() => void) | 0 | number[]; p: ""; 0: () => void; } p: "", >p : string diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types index 131e49dd173..6b8c8ae2e34 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types @@ -19,7 +19,7 @@ declare function foo(obj: I): T foo({ >foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[] >foo : (obj: I) => T ->{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: true | "" | (() => void) | 0 | number[]; [x: number]: (() => void) | 0 | number[]; 0: () => void; p: ""; } +>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: true | "" | (() => void) | 0 | number[]; [x: number]: (() => void) | 0 | number[]; p: ""; 0: () => void; } p: "", >p : string diff --git a/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.types b/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.types index f19769b1c58..610b80ef612 100644 --- a/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.types +++ b/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.types @@ -120,7 +120,7 @@ true ? exprString1 : exprBoolean1; // union typeof "123" == "string" ? exprBoolean1 : exprBoolean2; >typeof "123" == "string" ? exprBoolean1 : exprBoolean2 : boolean >typeof "123" == "string" : boolean ->typeof "123" : string +>typeof "123" : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >"123" : "123" >"string" : "string" >exprBoolean1 : boolean @@ -262,7 +262,7 @@ var resultIsBoolean3 = typeof "123" == "string" ? exprBoolean1 : exprBoolean2; >resultIsBoolean3 : boolean >typeof "123" == "string" ? exprBoolean1 : exprBoolean2 : boolean >typeof "123" == "string" : boolean ->typeof "123" : string +>typeof "123" : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >"123" : "123" >"string" : "string" >exprBoolean1 : boolean @@ -299,7 +299,7 @@ var resultIsStringOrBoolean4 = typeof "123" === "string" ? exprString1 : exprBoo >resultIsStringOrBoolean4 : string | boolean >typeof "123" === "string" ? exprString1 : exprBoolean1 : string | boolean >typeof "123" === "string" : boolean ->typeof "123" : string +>typeof "123" : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >"123" : "123" >"string" : "string" >exprString1 : string diff --git a/tests/baselines/reference/conditionalOperatorConditoinIsStringType.types b/tests/baselines/reference/conditionalOperatorConditoinIsStringType.types index a6906d7024a..33e34bea635 100644 --- a/tests/baselines/reference/conditionalOperatorConditoinIsStringType.types +++ b/tests/baselines/reference/conditionalOperatorConditoinIsStringType.types @@ -123,7 +123,7 @@ var array = ["1", "2", "3"]; typeof condString ? exprAny1 : exprAny2; >typeof condString ? exprAny1 : exprAny2 : any ->typeof condString : string +>typeof condString : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >condString : string >exprAny1 : any >exprAny2 : any @@ -254,7 +254,7 @@ var resultIsStringOrBoolean2 = "hello" ? exprString1 : exprBoolean1; // union var resultIsAny3 = typeof condString ? exprAny1 : exprAny2; >resultIsAny3 : any >typeof condString ? exprAny1 : exprAny2 : any ->typeof condString : string +>typeof condString : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >condString : string >exprAny1 : any >exprAny2 : any @@ -297,7 +297,7 @@ var resultIsObject3 = array[1] ? exprIsObject1 : exprIsObject2; var resultIsStringOrBoolean3 = typeof condString ? exprString1 : exprBoolean1; // union >resultIsStringOrBoolean3 : string | boolean >typeof condString ? exprString1 : exprBoolean1 : string | boolean ->typeof condString : string +>typeof condString : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >condString : string >exprString1 : string >exprBoolean1 : boolean diff --git a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.js b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.js index 408571af42a..5d864bce0d6 100644 --- a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.js +++ b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.js @@ -48,11 +48,16 @@ var result11: any = true ? 1 : 'string'; //// [conditionalOperatorWithIdenticalBCT.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); //Cond ? Expr1 : Expr2, Expr1 and Expr2 have identical best common type var X = (function () { function X() { @@ -63,7 +68,7 @@ var X = (function () { var A = (function (_super) { __extends(A, _super); function A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A; }(X)); @@ -71,7 +76,7 @@ var A = (function (_super) { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(X)); diff --git a/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js b/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js index 0ac935a582a..b5715163ad5 100644 --- a/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js +++ b/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.js @@ -24,11 +24,16 @@ var result61: (t: X) => number| string = true ? (m) => m.propertyX1 : (n) => n.p //// [conditionalOperatorWithoutIdenticalBCT.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); //Cond ? Expr1 : Expr2, Expr1 and Expr2 have no identical best common type var X = (function () { function X() { @@ -39,7 +44,7 @@ var X = (function () { var A = (function (_super) { __extends(A, _super); function A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A; }(X)); @@ -47,7 +52,7 @@ var A = (function (_super) { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(X)); diff --git a/tests/baselines/reference/constDeclarations-access5.js b/tests/baselines/reference/constDeclarations-access5.js index 1da0cf40fcd..f02b9611541 100644 --- a/tests/baselines/reference/constDeclarations-access5.js +++ b/tests/baselines/reference/constDeclarations-access5.js @@ -51,11 +51,13 @@ m.x.toString(); //// [constDeclarations_access_1.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.x = 0; }); //// [constDeclarations_access_2.js] define(["require", "exports", "constDeclarations_access_1"], function (require, exports, m) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); // Errors m.x = 1; m.x += 2; diff --git a/tests/baselines/reference/constEnumExternalModule.js b/tests/baselines/reference/constEnumExternalModule.js index e0a3f46ee89..8ea5625ac07 100644 --- a/tests/baselines/reference/constEnumExternalModule.js +++ b/tests/baselines/reference/constEnumExternalModule.js @@ -13,9 +13,11 @@ var v = A.V; //// [m1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [m2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var v = 100 /* V */; }); diff --git a/tests/baselines/reference/constLocalsInFunctionExpressions.types b/tests/baselines/reference/constLocalsInFunctionExpressions.types index db1da04e0ca..07d3392045c 100644 --- a/tests/baselines/reference/constLocalsInFunctionExpressions.types +++ b/tests/baselines/reference/constLocalsInFunctionExpressions.types @@ -12,7 +12,7 @@ function f1() { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -35,7 +35,7 @@ function f2() { if (typeof x !== "string") { >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -59,7 +59,7 @@ function f3() { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -82,7 +82,7 @@ function f4() { if (typeof x !== "string") { >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -106,7 +106,7 @@ function f5() { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" diff --git a/tests/baselines/reference/constantOverloadFunction.js b/tests/baselines/reference/constantOverloadFunction.js index 160191c5ca0..f501623bae5 100644 --- a/tests/baselines/reference/constantOverloadFunction.js +++ b/tests/baselines/reference/constantOverloadFunction.js @@ -14,11 +14,16 @@ function foo(tagName: any): Base { //// [constantOverloadFunction.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -28,7 +33,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.prototype.bar = function () { }; return Derived1; @@ -36,7 +41,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived2.prototype.baz = function () { }; return Derived2; @@ -44,7 +49,7 @@ var Derived2 = (function (_super) { var Derived3 = (function (_super) { __extends(Derived3, _super); function Derived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived3.prototype.biz = function () { }; return Derived3; diff --git a/tests/baselines/reference/constantOverloadFunctionNoSubtypeError.js b/tests/baselines/reference/constantOverloadFunctionNoSubtypeError.js index 509f9ba70e6..2a86fb0c9a3 100644 --- a/tests/baselines/reference/constantOverloadFunctionNoSubtypeError.js +++ b/tests/baselines/reference/constantOverloadFunctionNoSubtypeError.js @@ -15,11 +15,16 @@ function foo(tagName: any): Base { //// [constantOverloadFunctionNoSubtypeError.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -29,7 +34,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.prototype.bar = function () { }; return Derived1; @@ -37,7 +42,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived2.prototype.baz = function () { }; return Derived2; @@ -45,7 +50,7 @@ var Derived2 = (function (_super) { var Derived3 = (function (_super) { __extends(Derived3, _super); function Derived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived3.prototype.biz = function () { }; return Derived3; diff --git a/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.js b/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.js index 7908d36a56a..5b69a2dfae1 100644 --- a/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.js +++ b/tests/baselines/reference/constraintCheckInGenericBaseTypeReference.js @@ -20,11 +20,16 @@ class Container { } //// [constraintCheckInGenericBaseTypeReference.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // No errors var Constraint = (function () { function Constraint() { @@ -40,7 +45,7 @@ var GenericBase = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(GenericBase)); diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js index 6b308d88896..742a03577e5 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js @@ -71,11 +71,16 @@ interface I extends A { //// [constructSignatureAssignabilityInInheritance2.js] // checking subtype relations for function types as it relates to contextual signature instantiation -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -84,21 +89,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.js index 09abd6e0868..fd083159fb1 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.js @@ -114,11 +114,16 @@ module Errors { //// [constructSignatureAssignabilityInInheritance3.js] // checking subtype relations for function types as it relates to contextual signature instantiation // error cases -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Errors; (function (Errors) { var Base = (function () { @@ -129,21 +134,21 @@ var Errors; var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.js index 4e9a8c59bf9..f1fad68d4ca 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance4.js @@ -61,11 +61,16 @@ interface I extends A { //// [constructSignatureAssignabilityInInheritance4.js] // checking subtype relations for function types as it relates to contextual signature instantiation -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -74,21 +79,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js index 91ec3b313bb..dc08f25c912 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js @@ -51,11 +51,16 @@ interface I extends B { //// [constructSignatureAssignabilityInInheritance5.js] // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithConstructSignatures2 just with an extra level of indirection in the inheritance chain -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -64,21 +69,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.js index edafb009916..e755e3cacc3 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.js @@ -54,11 +54,16 @@ interface I9 extends A { // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithConstructSignatures4 but using class type parameters instead of generic signatures // all are errors -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -67,21 +72,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/constructSignaturesWithOverloads2.errors.txt b/tests/baselines/reference/constructSignaturesWithOverloads2.errors.txt index 617f7b1502f..35b130f7d6c 100644 --- a/tests/baselines/reference/constructSignaturesWithOverloads2.errors.txt +++ b/tests/baselines/reference/constructSignaturesWithOverloads2.errors.txt @@ -1,7 +1,8 @@ +tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithOverloads2.ts(27,11): error TS2428: All declarations of 'I' must have identical type parameters. tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithOverloads2.ts(32,11): error TS2428: All declarations of 'I' must have identical type parameters. -==== tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithOverloads2.ts (1 errors) ==== +==== tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithOverloads2.ts (2 errors) ==== // No errors expected for basic overloads of construct signatures with merged declarations // clodules @@ -29,6 +30,8 @@ tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSig // merged interfaces interface I { + ~ +!!! error TS2428: All declarations of 'I' must have identical type parameters. new (x: number, y?: string): C; new (x: number, y: string): C; } diff --git a/tests/baselines/reference/constructorArgs.js b/tests/baselines/reference/constructorArgs.js index 6bbea0fddf7..877cef3dd0a 100644 --- a/tests/baselines/reference/constructorArgs.js +++ b/tests/baselines/reference/constructorArgs.js @@ -16,11 +16,16 @@ class Sub extends Super { //// [constructorArgs.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Super = (function () { function Super(value) { } diff --git a/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType.js b/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType.js index 45ed976e191..323c9a4c6d8 100644 --- a/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType.js +++ b/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType.js @@ -20,11 +20,16 @@ class Derived2 extends Base { } //// [constructorFunctionTypeIsAssignableToBaseType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -33,14 +38,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.js b/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.js index c5e27748f52..56891defbe0 100644 --- a/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.js +++ b/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.js @@ -34,11 +34,16 @@ class Derived2 extends Base { //// [constructorFunctionTypeIsAssignableToBaseType2.js] // the constructor function itself does not need to be a subtype of the base type constructor function -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(x) { } diff --git a/tests/baselines/reference/constructorHasPrototypeProperty.js b/tests/baselines/reference/constructorHasPrototypeProperty.js index a16694cdbf5..64fa9d9099d 100644 --- a/tests/baselines/reference/constructorHasPrototypeProperty.js +++ b/tests/baselines/reference/constructorHasPrototypeProperty.js @@ -32,11 +32,16 @@ module Generic { } //// [constructorHasPrototypeProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var NonGeneric; (function (NonGeneric) { var C = (function () { @@ -47,7 +52,7 @@ var NonGeneric; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); @@ -66,7 +71,7 @@ var Generic; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/constructorOverloads2.js b/tests/baselines/reference/constructorOverloads2.js index 2d26194f2e7..291ea545733 100644 --- a/tests/baselines/reference/constructorOverloads2.js +++ b/tests/baselines/reference/constructorOverloads2.js @@ -26,11 +26,16 @@ f1.bar1(); //// [constructorOverloads2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var FooBase = (function () { function FooBase(x) { } diff --git a/tests/baselines/reference/constructorOverloads3.js b/tests/baselines/reference/constructorOverloads3.js index c0ae9b452f9..94b29ad89ab 100644 --- a/tests/baselines/reference/constructorOverloads3.js +++ b/tests/baselines/reference/constructorOverloads3.js @@ -23,15 +23,20 @@ f1.bar1(); //// [constructorOverloads3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function (_super) { __extends(Foo, _super); function Foo(x, y) { - var _this; + var _this = this; return _this; } Foo.prototype.bar1 = function () { }; diff --git a/tests/baselines/reference/constructorReturnsInvalidType.errors.txt b/tests/baselines/reference/constructorReturnsInvalidType.errors.txt index a1a5c5e75b9..a615d7177cf 100644 --- a/tests/baselines/reference/constructorReturnsInvalidType.errors.txt +++ b/tests/baselines/reference/constructorReturnsInvalidType.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2322: Type '1' is not assignable to type 'X'. -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(3,9): error TS2322: Type '1' is not assignable to type 'X'. +tests/cases/compiler/constructorReturnsInvalidType.ts(3,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class ==== tests/cases/compiler/constructorReturnsInvalidType.ts (2 errors) ==== class X { constructor() { return 1; - ~ + ~~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'X'. - ~ + ~~~~~~~~~ !!! 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 77c63a217e7..f5948382d64 100644 --- a/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt +++ b/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,16): error TS2322: Type '1' is not assignable to type 'D'. -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'. +tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,9): error TS2322: Type '1' is not assignable to type 'D'. +tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,9): 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,9): 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(26,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class ==== tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts (4 errors) ==== @@ -19,9 +19,9 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl x: number; constructor() { return 1; // error - ~ + ~~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'D'. - ~ + ~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } @@ -37,11 +37,11 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl x: T; 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/constructorWithCapturedSuper.js b/tests/baselines/reference/constructorWithCapturedSuper.js index 895f78eb04b..503742de9fe 100644 --- a/tests/baselines/reference/constructorWithCapturedSuper.js +++ b/tests/baselines/reference/constructorWithCapturedSuper.js @@ -53,11 +53,16 @@ class D extends A { } //// [constructorWithCapturedSuper.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var oneA; var A = (function () { function A() { diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js index d4cd737ab46..afdfa36e4a6 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js @@ -281,11 +281,16 @@ TypeScriptAllInOne.Program.Main(); //// [constructorWithIncompleteTypeAnnotation.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var fs = module; ("fs"); var TypeScriptAllInOne; @@ -525,7 +530,7 @@ method2(); var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.method2 = function () { return this.method1(2); diff --git a/tests/baselines/reference/contextualTypingArrayOfLambdas.js b/tests/baselines/reference/contextualTypingArrayOfLambdas.js index caf7ed445e5..5d8b40e39f0 100644 --- a/tests/baselines/reference/contextualTypingArrayOfLambdas.js +++ b/tests/baselines/reference/contextualTypingArrayOfLambdas.js @@ -15,11 +15,16 @@ var xs = [(x: A) => { }, (x: B) => { }, (x: C) => { }]; //// [contextualTypingArrayOfLambdas.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -28,14 +33,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/contextualTypingOfConditionalExpression.js b/tests/baselines/reference/contextualTypingOfConditionalExpression.js index a6ce98f61e2..fd5ec50ebb4 100644 --- a/tests/baselines/reference/contextualTypingOfConditionalExpression.js +++ b/tests/baselines/reference/contextualTypingOfConditionalExpression.js @@ -15,11 +15,16 @@ var x2: (a: A) => void = true ? (a) => a.foo : (b) => b.foo; //// [contextualTypingOfConditionalExpression.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x = true ? function (a) { return a.toExponential(); } : function (b) { return b.toFixed(); }; var A = (function () { function A() { @@ -29,14 +34,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/contextualTypingOfConditionalExpression2.js b/tests/baselines/reference/contextualTypingOfConditionalExpression2.js index e3bd1643cfb..f5063fa003a 100644 --- a/tests/baselines/reference/contextualTypingOfConditionalExpression2.js +++ b/tests/baselines/reference/contextualTypingOfConditionalExpression2.js @@ -13,11 +13,16 @@ var x2: (a: A) => void = true ? (a: C) => a.foo : (b: number) => { }; //// [contextualTypingOfConditionalExpression2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -26,14 +31,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/contextuallyTypedIife.js b/tests/baselines/reference/contextuallyTypedIife.js index d2eaaf9c2d5..0f3315d66a2 100644 --- a/tests/baselines/reference/contextuallyTypedIife.js +++ b/tests/baselines/reference/contextuallyTypedIife.js @@ -28,6 +28,9 @@ // contextually typed parameters. let twelve = (f => f(12))(i => i); let eleven = (o => o.a(11))({ a: function(n) { return n; } }); +// missing arguments +(function(x, undefined) { return x; })(42); +((x, y, z) => 42)(); //// [contextuallyTypedIife.js] @@ -102,3 +105,6 @@ let eleven = (o => o.a(11))({ a: function(n) { return n; } }); // contextually typed parameters. var twelve = (function (f) { return f(12); })(function (i) { return i; }); var eleven = (function (o) { return o.a(11); })({ a: function (n) { return n; } }); +// missing arguments +(function (x, undefined) { return x; })(42); +(function (x, y, z) { return 42; })(); diff --git a/tests/baselines/reference/contextuallyTypedIife.symbols b/tests/baselines/reference/contextuallyTypedIife.symbols index 4512b4db8a2..7a73beaad16 100644 --- a/tests/baselines/reference/contextuallyTypedIife.symbols +++ b/tests/baselines/reference/contextuallyTypedIife.symbols @@ -119,3 +119,14 @@ let eleven = (o => o.a(11))({ a: function(n) { return n; } }); >n : Symbol(n, Decl(contextuallyTypedIife.ts, 28, 42)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 28, 42)) +// missing arguments +(function(x, undefined) { return x; })(42); +>x : Symbol(x, Decl(contextuallyTypedIife.ts, 30, 10)) +>undefined : Symbol(undefined, Decl(contextuallyTypedIife.ts, 30, 12)) +>x : Symbol(x, Decl(contextuallyTypedIife.ts, 30, 10)) + +((x, y, z) => 42)(); +>x : Symbol(x, Decl(contextuallyTypedIife.ts, 31, 2)) +>y : Symbol(y, Decl(contextuallyTypedIife.ts, 31, 4)) +>z : Symbol(z, Decl(contextuallyTypedIife.ts, 31, 7)) + diff --git a/tests/baselines/reference/contextuallyTypedIife.types b/tests/baselines/reference/contextuallyTypedIife.types index e6f41265e9a..676755fb341 100644 --- a/tests/baselines/reference/contextuallyTypedIife.types +++ b/tests/baselines/reference/contextuallyTypedIife.types @@ -250,3 +250,22 @@ let eleven = (o => o.a(11))({ a: function(n) { return n; } }); >n : any >n : any +// missing arguments +(function(x, undefined) { return x; })(42); +>(function(x, undefined) { return x; })(42) : number +>(function(x, undefined) { return x; }) : (x: number, undefined?: any) => number +>function(x, undefined) { return x; } : (x: number, undefined?: any) => number +>x : number +>undefined : any +>x : number +>42 : 42 + +((x, y, z) => 42)(); +>((x, y, z) => 42)() : number +>((x, y, z) => 42) : (x?: any, y?: any, z?: any) => number +>(x, y, z) => 42 : (x?: any, y?: any, z?: any) => number +>x : any +>y : any +>z : any +>42 : 42 + diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.errors.txt b/tests/baselines/reference/contextuallyTypedIifeStrict.errors.txt new file mode 100644 index 00000000000..220204fc536 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts(14,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts(15,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts(16,17): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts (3 errors) ==== + // arrow + (jake => { })("build"); + // function expression + (function (cats) { })("lol"); + // Lots of Irritating Superfluous Parentheses + (function (x) { } ("!")); + ((((function (y) { }))))("-"); + // multiple arguments + ((a, b, c) => { })("foo", 101, false); + // default parameters + ((m = 10) => m + 1)(12); + ((n = 10) => n + 1)(); + // optional parameters + ((j?) => j + 1)(12); + ~ +!!! error TS2532: Object is possibly 'undefined'. + ((k?) => k + 1)(); + ~ +!!! error TS2532: Object is possibly 'undefined'. + ((l, o?) => l + o)(12); // o should be any + ~ +!!! error TS2532: Object is possibly 'undefined'. + // rest parameters + ((...numbers) => numbers.every(n => n > 0))(5,6,7); + ((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); + ((...noNumbers) => noNumbers.some(n => n > 0))(); + ((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); + // destructuring parameters (with defaults too!) + (({ q }) => q)({ q : 13 }); + (({ p = 14 }) => p)({ p : 15 }); + (({ r = 17 } = { r: 18 }) => r)({r : 19}); + (({ u = 22 } = { u: 23 }) => u)(); + // contextually typed parameters. + let twelve = (f => f(12))(i => i); + let eleven = (o => o.a(11))({ a: function(n) { return n; } }); + // missing arguments + (function(x, undefined) { return x; })(42); + ((x, y, z) => 42)(); + \ No newline at end of file diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.js b/tests/baselines/reference/contextuallyTypedIifeStrict.js new file mode 100644 index 00000000000..c5455ab84c8 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.js @@ -0,0 +1,110 @@ +//// [contextuallyTypedIifeStrict.ts] +// arrow +(jake => { })("build"); +// function expression +(function (cats) { })("lol"); +// Lots of Irritating Superfluous Parentheses +(function (x) { } ("!")); +((((function (y) { }))))("-"); +// multiple arguments +((a, b, c) => { })("foo", 101, false); +// default parameters +((m = 10) => m + 1)(12); +((n = 10) => n + 1)(); +// optional parameters +((j?) => j + 1)(12); +((k?) => k + 1)(); +((l, o?) => l + o)(12); // o should be any +// rest parameters +((...numbers) => numbers.every(n => n > 0))(5,6,7); +((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); +((...noNumbers) => noNumbers.some(n => n > 0))(); +((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); +// destructuring parameters (with defaults too!) +(({ q }) => q)({ q : 13 }); +(({ p = 14 }) => p)({ p : 15 }); +(({ r = 17 } = { r: 18 }) => r)({r : 19}); +(({ u = 22 } = { u: 23 }) => u)(); +// contextually typed parameters. +let twelve = (f => f(12))(i => i); +let eleven = (o => o.a(11))({ a: function(n) { return n; } }); +// missing arguments +(function(x, undefined) { return x; })(42); +((x, y, z) => 42)(); + + +//// [contextuallyTypedIifeStrict.js] +// arrow +(function (jake) { })("build"); +// function expression +(function (cats) { })("lol"); +// Lots of Irritating Superfluous Parentheses +(function (x) { }("!")); +((((function (y) { }))))("-"); +// multiple arguments +(function (a, b, c) { })("foo", 101, false); +// default parameters +(function (m) { + if (m === void 0) { m = 10; } + return m + 1; +})(12); +(function (n) { + if (n === void 0) { n = 10; } + return n + 1; +})(); +// optional parameters +(function (j) { return j + 1; })(12); +(function (k) { return k + 1; })(); +(function (l, o) { return l + o; })(12); // o should be any +// rest parameters +(function () { + var numbers = []; + for (var _i = 0; _i < arguments.length; _i++) { + numbers[_i] = arguments[_i]; + } + return numbers.every(function (n) { return n > 0; }); +})(5, 6, 7); +(function () { + var mixed = []; + for (var _i = 0; _i < arguments.length; _i++) { + mixed[_i] = arguments[_i]; + } + return mixed.every(function (n) { return !!n; }); +})(5, 'oops', 'oh no'); +(function () { + var noNumbers = []; + for (var _i = 0; _i < arguments.length; _i++) { + noNumbers[_i] = arguments[_i]; + } + return noNumbers.some(function (n) { return n > 0; }); +})(); +(function (first) { + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + return first ? [] : rest.map(function (n) { return n > 0; }); +})(8, 9, 10); +// destructuring parameters (with defaults too!) +(function (_a) { + var q = _a.q; + return q; +})({ q: 13 }); +(function (_a) { + var _b = _a.p, p = _b === void 0 ? 14 : _b; + return p; +})({ p: 15 }); +(function (_a) { + var _b = (_a === void 0 ? { r: 18 } : _a).r, r = _b === void 0 ? 17 : _b; + return r; +})({ r: 19 }); +(function (_a) { + var _b = (_a === void 0 ? { u: 23 } : _a).u, u = _b === void 0 ? 22 : _b; + return u; +})(); +// contextually typed parameters. +var twelve = (function (f) { return f(12); })(function (i) { return i; }); +var eleven = (function (o) { return o.a(11); })({ a: function (n) { return n; } }); +// missing arguments +(function (x, undefined) { return x; })(42); +(function (x, y, z) { return 42; })(); diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.symbols b/tests/baselines/reference/contextuallyTypedIifeStrict.symbols new file mode 100644 index 00000000000..f76c9caa104 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.symbols @@ -0,0 +1,132 @@ +=== tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts === +// arrow +(jake => { })("build"); +>jake : Symbol(jake, Decl(contextuallyTypedIifeStrict.ts, 1, 1)) + +// function expression +(function (cats) { })("lol"); +>cats : Symbol(cats, Decl(contextuallyTypedIifeStrict.ts, 3, 11)) + +// Lots of Irritating Superfluous Parentheses +(function (x) { } ("!")); +>x : Symbol(x, Decl(contextuallyTypedIifeStrict.ts, 5, 11)) + +((((function (y) { }))))("-"); +>y : Symbol(y, Decl(contextuallyTypedIifeStrict.ts, 6, 14)) + +// multiple arguments +((a, b, c) => { })("foo", 101, false); +>a : Symbol(a, Decl(contextuallyTypedIifeStrict.ts, 8, 2)) +>b : Symbol(b, Decl(contextuallyTypedIifeStrict.ts, 8, 4)) +>c : Symbol(c, Decl(contextuallyTypedIifeStrict.ts, 8, 7)) + +// default parameters +((m = 10) => m + 1)(12); +>m : Symbol(m, Decl(contextuallyTypedIifeStrict.ts, 10, 2)) +>m : Symbol(m, Decl(contextuallyTypedIifeStrict.ts, 10, 2)) + +((n = 10) => n + 1)(); +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 11, 2)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 11, 2)) + +// optional parameters +((j?) => j + 1)(12); +>j : Symbol(j, Decl(contextuallyTypedIifeStrict.ts, 13, 2)) +>j : Symbol(j, Decl(contextuallyTypedIifeStrict.ts, 13, 2)) + +((k?) => k + 1)(); +>k : Symbol(k, Decl(contextuallyTypedIifeStrict.ts, 14, 2)) +>k : Symbol(k, Decl(contextuallyTypedIifeStrict.ts, 14, 2)) + +((l, o?) => l + o)(12); // o should be any +>l : Symbol(l, Decl(contextuallyTypedIifeStrict.ts, 15, 2)) +>o : Symbol(o, Decl(contextuallyTypedIifeStrict.ts, 15, 4)) +>l : Symbol(l, Decl(contextuallyTypedIifeStrict.ts, 15, 2)) +>o : Symbol(o, Decl(contextuallyTypedIifeStrict.ts, 15, 4)) + +// rest parameters +((...numbers) => numbers.every(n => n > 0))(5,6,7); +>numbers : Symbol(numbers, Decl(contextuallyTypedIifeStrict.ts, 17, 2)) +>numbers.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>numbers : Symbol(numbers, Decl(contextuallyTypedIifeStrict.ts, 17, 2)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 17, 31)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 17, 31)) + +((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); +>mixed : Symbol(mixed, Decl(contextuallyTypedIifeStrict.ts, 18, 2)) +>mixed.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>mixed : Symbol(mixed, Decl(contextuallyTypedIifeStrict.ts, 18, 2)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 18, 27)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 18, 27)) + +((...noNumbers) => noNumbers.some(n => n > 0))(); +>noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIifeStrict.ts, 19, 2)) +>noNumbers.some : Symbol(Array.some, Decl(lib.d.ts, --, --)) +>noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIifeStrict.ts, 19, 2)) +>some : Symbol(Array.some, Decl(lib.d.ts, --, --)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 19, 34)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 19, 34)) + +((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); +>first : Symbol(first, Decl(contextuallyTypedIifeStrict.ts, 20, 2)) +>rest : Symbol(rest, Decl(contextuallyTypedIifeStrict.ts, 20, 8)) +>first : Symbol(first, Decl(contextuallyTypedIifeStrict.ts, 20, 2)) +>rest.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>rest : Symbol(rest, Decl(contextuallyTypedIifeStrict.ts, 20, 8)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 20, 43)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 20, 43)) + +// destructuring parameters (with defaults too!) +(({ q }) => q)({ q : 13 }); +>q : Symbol(q, Decl(contextuallyTypedIifeStrict.ts, 22, 3)) +>q : Symbol(q, Decl(contextuallyTypedIifeStrict.ts, 22, 3)) +>q : Symbol(q, Decl(contextuallyTypedIifeStrict.ts, 22, 16)) + +(({ p = 14 }) => p)({ p : 15 }); +>p : Symbol(p, Decl(contextuallyTypedIifeStrict.ts, 23, 3)) +>p : Symbol(p, Decl(contextuallyTypedIifeStrict.ts, 23, 3)) +>p : Symbol(p, Decl(contextuallyTypedIifeStrict.ts, 23, 21)) + +(({ r = 17 } = { r: 18 }) => r)({r : 19}); +>r : Symbol(r, Decl(contextuallyTypedIifeStrict.ts, 24, 3)) +>r : Symbol(r, Decl(contextuallyTypedIifeStrict.ts, 24, 16)) +>r : Symbol(r, Decl(contextuallyTypedIifeStrict.ts, 24, 3)) +>r : Symbol(r, Decl(contextuallyTypedIifeStrict.ts, 24, 33)) + +(({ u = 22 } = { u: 23 }) => u)(); +>u : Symbol(u, Decl(contextuallyTypedIifeStrict.ts, 25, 3)) +>u : Symbol(u, Decl(contextuallyTypedIifeStrict.ts, 25, 16)) +>u : Symbol(u, Decl(contextuallyTypedIifeStrict.ts, 25, 3)) + +// contextually typed parameters. +let twelve = (f => f(12))(i => i); +>twelve : Symbol(twelve, Decl(contextuallyTypedIifeStrict.ts, 27, 3)) +>f : Symbol(f, Decl(contextuallyTypedIifeStrict.ts, 27, 14)) +>f : Symbol(f, Decl(contextuallyTypedIifeStrict.ts, 27, 14)) +>i : Symbol(i, Decl(contextuallyTypedIifeStrict.ts, 27, 26)) +>i : Symbol(i, Decl(contextuallyTypedIifeStrict.ts, 27, 26)) + +let eleven = (o => o.a(11))({ a: function(n) { return n; } }); +>eleven : Symbol(eleven, Decl(contextuallyTypedIifeStrict.ts, 28, 3)) +>o : Symbol(o, Decl(contextuallyTypedIifeStrict.ts, 28, 14)) +>o.a : Symbol(a, Decl(contextuallyTypedIifeStrict.ts, 28, 29)) +>o : Symbol(o, Decl(contextuallyTypedIifeStrict.ts, 28, 14)) +>a : Symbol(a, Decl(contextuallyTypedIifeStrict.ts, 28, 29)) +>a : Symbol(a, Decl(contextuallyTypedIifeStrict.ts, 28, 29)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 28, 42)) +>n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 28, 42)) + +// missing arguments +(function(x, undefined) { return x; })(42); +>x : Symbol(x, Decl(contextuallyTypedIifeStrict.ts, 30, 10)) +>undefined : Symbol(undefined, Decl(contextuallyTypedIifeStrict.ts, 30, 12)) +>x : Symbol(x, Decl(contextuallyTypedIifeStrict.ts, 30, 10)) + +((x, y, z) => 42)(); +>x : Symbol(x, Decl(contextuallyTypedIifeStrict.ts, 31, 2)) +>y : Symbol(y, Decl(contextuallyTypedIifeStrict.ts, 31, 4)) +>z : Symbol(z, Decl(contextuallyTypedIifeStrict.ts, 31, 7)) + diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.types b/tests/baselines/reference/contextuallyTypedIifeStrict.types new file mode 100644 index 00000000000..cbeee53ec2e --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.types @@ -0,0 +1,271 @@ +=== tests/cases/conformance/expressions/functions/contextuallyTypedIifeStrict.ts === +// arrow +(jake => { })("build"); +>(jake => { })("build") : void +>(jake => { }) : (jake: string) => void +>jake => { } : (jake: string) => void +>jake : string +>"build" : "build" + +// function expression +(function (cats) { })("lol"); +>(function (cats) { })("lol") : void +>(function (cats) { }) : (cats: string) => void +>function (cats) { } : (cats: string) => void +>cats : string +>"lol" : "lol" + +// Lots of Irritating Superfluous Parentheses +(function (x) { } ("!")); +>(function (x) { } ("!")) : void +>function (x) { } ("!") : void +>function (x) { } : (x: string) => void +>x : string +>"!" : "!" + +((((function (y) { }))))("-"); +>((((function (y) { }))))("-") : void +>((((function (y) { })))) : (y: string) => void +>(((function (y) { }))) : (y: string) => void +>((function (y) { })) : (y: string) => void +>(function (y) { }) : (y: string) => void +>function (y) { } : (y: string) => void +>y : string +>"-" : "-" + +// multiple arguments +((a, b, c) => { })("foo", 101, false); +>((a, b, c) => { })("foo", 101, false) : void +>((a, b, c) => { }) : (a: string, b: number, c: boolean) => void +>(a, b, c) => { } : (a: string, b: number, c: boolean) => void +>a : string +>b : number +>c : boolean +>"foo" : "foo" +>101 : 101 +>false : false + +// default parameters +((m = 10) => m + 1)(12); +>((m = 10) => m + 1)(12) : number +>((m = 10) => m + 1) : (m?: number) => number +>(m = 10) => m + 1 : (m?: number) => number +>m : number +>10 : 10 +>m + 1 : number +>m : number +>1 : 1 +>12 : 12 + +((n = 10) => n + 1)(); +>((n = 10) => n + 1)() : number +>((n = 10) => n + 1) : (n?: number) => number +>(n = 10) => n + 1 : (n?: number) => number +>n : number +>10 : 10 +>n + 1 : number +>n : number +>1 : 1 + +// optional parameters +((j?) => j + 1)(12); +>((j?) => j + 1)(12) : number +>((j?) => j + 1) : (j?: number | undefined) => number +>(j?) => j + 1 : (j?: number | undefined) => number +>j : number | undefined +>j + 1 : number +>j : number | undefined +>1 : 1 +>12 : 12 + +((k?) => k + 1)(); +>((k?) => k + 1)() : number +>((k?) => k + 1) : (k?: undefined) => number +>(k?) => k + 1 : (k?: undefined) => number +>k : undefined +>k + 1 : number +>k : undefined +>1 : 1 + +((l, o?) => l + o)(12); // o should be any +>((l, o?) => l + o)(12) : number +>((l, o?) => l + o) : (l: number, o?: undefined) => number +>(l, o?) => l + o : (l: number, o?: undefined) => number +>l : number +>o : undefined +>l + o : number +>l : number +>o : undefined +>12 : 12 + +// rest parameters +((...numbers) => numbers.every(n => n > 0))(5,6,7); +>((...numbers) => numbers.every(n => n > 0))(5,6,7) : boolean +>((...numbers) => numbers.every(n => n > 0)) : (...numbers: number[]) => boolean +>(...numbers) => numbers.every(n => n > 0) : (...numbers: number[]) => boolean +>numbers : number[] +>numbers.every(n => n > 0) : boolean +>numbers.every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>numbers : number[] +>every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>n => n > 0 : (n: number) => boolean +>n : number +>n > 0 : boolean +>n : number +>0 : 0 +>5 : 5 +>6 : 6 +>7 : 7 + +((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); +>((...mixed) => mixed.every(n => !!n))(5,'oops','oh no') : boolean +>((...mixed) => mixed.every(n => !!n)) : (...mixed: (string | number)[]) => boolean +>(...mixed) => mixed.every(n => !!n) : (...mixed: (string | number)[]) => boolean +>mixed : (string | number)[] +>mixed.every(n => !!n) : boolean +>mixed.every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean +>mixed : (string | number)[] +>every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean +>n => !!n : (n: string | number) => boolean +>n : string | number +>!!n : boolean +>!n : boolean +>n : string | number +>5 : 5 +>'oops' : "oops" +>'oh no' : "oh no" + +((...noNumbers) => noNumbers.some(n => n > 0))(); +>((...noNumbers) => noNumbers.some(n => n > 0))() : boolean +>((...noNumbers) => noNumbers.some(n => n > 0)) : (...noNumbers: any[]) => boolean +>(...noNumbers) => noNumbers.some(n => n > 0) : (...noNumbers: any[]) => boolean +>noNumbers : any[] +>noNumbers.some(n => n > 0) : boolean +>noNumbers.some : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean +>noNumbers : any[] +>some : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean +>n => n > 0 : (n: any) => boolean +>n : any +>n > 0 : boolean +>n : any +>0 : 0 + +((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); +>((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10) : boolean[] +>((first, ...rest) => first ? [] : rest.map(n => n > 0)) : (first: number, ...rest: number[]) => boolean[] +>(first, ...rest) => first ? [] : rest.map(n => n > 0) : (first: number, ...rest: number[]) => boolean[] +>first : number +>rest : number[] +>first ? [] : rest.map(n => n > 0) : boolean[] +>first : number +>[] : never[] +>rest.map(n => n > 0) : boolean[] +>rest.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>rest : number[] +>map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>n => n > 0 : (n: number) => boolean +>n : number +>n > 0 : boolean +>n : number +>0 : 0 +>8 : 8 +>9 : 9 +>10 : 10 + +// destructuring parameters (with defaults too!) +(({ q }) => q)({ q : 13 }); +>(({ q }) => q)({ q : 13 }) : number +>(({ q }) => q) : ({q}: { q: number; }) => number +>({ q }) => q : ({q}: { q: number; }) => number +>q : number +>q : number +>{ q : 13 } : { q: number; } +>q : number +>13 : 13 + +(({ p = 14 }) => p)({ p : 15 }); +>(({ p = 14 }) => p)({ p : 15 }) : number +>(({ p = 14 }) => p) : ({p}: { p: number; }) => number +>({ p = 14 }) => p : ({p}: { p: number; }) => number +>p : number +>14 : 14 +>p : number +>{ p : 15 } : { p: number; } +>p : number +>15 : 15 + +(({ r = 17 } = { r: 18 }) => r)({r : 19}); +>(({ r = 17 } = { r: 18 }) => r)({r : 19}) : number +>(({ r = 17 } = { r: 18 }) => r) : ({r}?: { r: number; }) => number +>({ r = 17 } = { r: 18 }) => r : ({r}?: { r: number; }) => number +>r : number +>17 : 17 +>{ r: 18 } : { r: number; } +>r : number +>18 : 18 +>r : number +>{r : 19} : { r: number; } +>r : number +>19 : 19 + +(({ u = 22 } = { u: 23 }) => u)(); +>(({ u = 22 } = { u: 23 }) => u)() : number +>(({ u = 22 } = { u: 23 }) => u) : ({u}?: { u?: number; }) => number +>({ u = 22 } = { u: 23 }) => u : ({u}?: { u?: number; }) => number +>u : number +>22 : 22 +>{ u: 23 } : { u?: number; } +>u : number +>23 : 23 +>u : number + +// contextually typed parameters. +let twelve = (f => f(12))(i => i); +>twelve : any +>(f => f(12))(i => i) : any +>(f => f(12)) : (f: (i: any) => any) => any +>f => f(12) : (f: (i: any) => any) => any +>f : (i: any) => any +>f(12) : any +>f : (i: any) => any +>12 : 12 +>i => i : (i: any) => any +>i : any +>i : any + +let eleven = (o => o.a(11))({ a: function(n) { return n; } }); +>eleven : any +>(o => o.a(11))({ a: function(n) { return n; } }) : any +>(o => o.a(11)) : (o: { a: (n: any) => any; }) => any +>o => o.a(11) : (o: { a: (n: any) => any; }) => any +>o : { a: (n: any) => any; } +>o.a(11) : any +>o.a : (n: any) => any +>o : { a: (n: any) => any; } +>a : (n: any) => any +>11 : 11 +>{ a: function(n) { return n; } } : { a: (n: any) => any; } +>a : (n: any) => any +>function(n) { return n; } : (n: any) => any +>n : any +>n : any + +// missing arguments +(function(x, undefined) { return x; })(42); +>(function(x, undefined) { return x; })(42) : number +>(function(x, undefined) { return x; }) : (x: number, undefined: undefined) => number +>function(x, undefined) { return x; } : (x: number, undefined: undefined) => number +>x : number +>undefined : undefined +>x : number +>42 : 42 + +((x, y, z) => 42)(); +>((x, y, z) => 42)() : number +>((x, y, z) => 42) : (x: undefined, y: undefined, z: undefined) => number +>(x, y, z) => 42 : (x: undefined, y: undefined, z: undefined) => number +>x : undefined +>y : undefined +>z : undefined +>42 : 42 + diff --git a/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.errors.txt b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.errors.txt index 48e11fb1221..47d0b8c839a 100644 --- a/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.errors.txt +++ b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.errors.txt @@ -1,5 +1,9 @@ -tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx(16,15): error TS2322: Type '"f"' is not assignable to type '"A" | "B" | "C"'. -tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx(17,15): error TS2322: Type '"f"' is not assignable to type '"A" | "B" | "C"'. +tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx(16,15): error TS2322: Type '{ foo: "f"; }' is not assignable to type '{ foo: "A" | "B" | "C"; }'. + Types of property 'foo' are incompatible. + Type '"f"' is not assignable to type '"A" | "B" | "C"'. +tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx(17,15): error TS2322: Type '{ foo: "f"; }' is not assignable to type '{ foo: "A" | "B" | "C"; }'. + Types of property 'foo' are incompatible. + Type '"f"' is not assignable to type '"A" | "B" | "C"'. ==== tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx (2 errors) ==== @@ -20,7 +24,11 @@ tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStr ; ~~~~~~~~~ -!!! error TS2322: Type '"f"' is not assignable to type '"A" | "B" | "C"'. +!!! error TS2322: Type '{ foo: "f"; }' is not assignable to type '{ foo: "A" | "B" | "C"; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type '"f"' is not assignable to type '"A" | "B" | "C"'. ; ~~~~~~~ -!!! error TS2322: Type '"f"' is not assignable to type '"A" | "B" | "C"'. \ No newline at end of file +!!! error TS2322: Type '{ foo: "f"; }' is not assignable to type '{ foo: "A" | "B" | "C"; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type '"f"' is not assignable to type '"A" | "B" | "C"'. \ No newline at end of file diff --git a/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.errors.txt b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.errors.txt new file mode 100644 index 00000000000..0ef067e5bbc --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.errors.txt @@ -0,0 +1,71 @@ +tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(28,24): error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. + Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. +tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(29,24): error TS2322: Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. + Property 'onClick' does not exist on type 'IntrinsicAttributes & LinkProps'. +tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(30,24): error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. + Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. +tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(31,24): error TS2322: Type '{ goTo: "home"; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. + Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. +tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(34,25): error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'. + Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'. +tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(37,25): error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. + Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. + + +==== tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx (6 errors) ==== + + import React = require('react') + + export interface ClickableProps { + children?: string; + className?: string; + } + + export interface ButtonProps extends ClickableProps { + onClick: (k: "left" | "right") => void; + } + + export interface LinkProps extends ClickableProps { + goTo: "home" | "contact"; + } + + export function MainButton(buttonProps: ButtonProps): JSX.Element; + export function MainButton(linkProps: LinkProps): JSX.Element; + export function MainButton(props: ButtonProps | LinkProps): JSX.Element { + const linkProps = props as LinkProps; + if(linkProps.goTo) { + return this._buildMainLink(props); + } + + return this._buildMainButton(props); + } + + const b0 = {console.log(k)}}} extra />; // k has type "left" | "right" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. +!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. + const b2 = {console.log(k)}} extra />; // k has type "left" | "right" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. +!!! error TS2322: Property 'onClick' does not exist on type 'IntrinsicAttributes & LinkProps'. + const b3 = ; // goTo has type"home" | "contact" + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. +!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. + const b4 = ; // goTo has type "home" | "contact" + ~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ goTo: "home"; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. +!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. + + export function NoOverload(buttonProps: ButtonProps): JSX.Element { return undefined } + const c1 = {console.log(k)}}} extra />; // k has type any + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'. +!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'. + + export function NoOverload1(linkProps: LinkProps): JSX.Element { return undefined } + const d1 = ; // goTo has type "home" | "contact" + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. +!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. + \ No newline at end of file diff --git a/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.js b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.js new file mode 100644 index 00000000000..6f195cabebd --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.js @@ -0,0 +1,63 @@ +//// [file.tsx] + +import React = require('react') + +export interface ClickableProps { + children?: string; + className?: string; +} + +export interface ButtonProps extends ClickableProps { + onClick: (k: "left" | "right") => void; +} + +export interface LinkProps extends ClickableProps { + goTo: "home" | "contact"; +} + +export function MainButton(buttonProps: ButtonProps): JSX.Element; +export function MainButton(linkProps: LinkProps): JSX.Element; +export function MainButton(props: ButtonProps | LinkProps): JSX.Element { + const linkProps = props as LinkProps; + if(linkProps.goTo) { + return this._buildMainLink(props); + } + + return this._buildMainButton(props); +} + +const b0 = {console.log(k)}}} extra />; // k has type "left" | "right" +const b2 = {console.log(k)}} extra />; // k has type "left" | "right" +const b3 = ; // goTo has type"home" | "contact" +const b4 = ; // goTo has type "home" | "contact" + +export function NoOverload(buttonProps: ButtonProps): JSX.Element { return undefined } +const c1 = {console.log(k)}}} extra />; // k has type any + +export function NoOverload1(linkProps: LinkProps): JSX.Element { return undefined } +const d1 = ; // goTo has type "home" | "contact" + + +//// [file.jsx] +define(["require", "exports", "react"], function (require, exports, React) { + "use strict"; + exports.__esModule = true; + function MainButton(props) { + var linkProps = props; + if (linkProps.goTo) { + return this._buildMainLink(props); + } + return this._buildMainButton(props); + } + exports.MainButton = MainButton; + var b0 = ; // k has type "left" | "right" + var b2 = ; // k has type "left" | "right" + var b3 = ; // goTo has type"home" | "contact" + var b4 = ; // goTo has type "home" | "contact" + function NoOverload(buttonProps) { return undefined; } + exports.NoOverload = NoOverload; + var c1 = ; // k has type any + function NoOverload1(linkProps) { return undefined; } + exports.NoOverload1 = NoOverload1; + var d1 = ; // goTo has type "home" | "contact" +}); diff --git a/tests/baselines/reference/controlFlowBinaryOrExpression.js b/tests/baselines/reference/controlFlowBinaryOrExpression.js index fb48c5a23e0..752479cf4e9 100644 --- a/tests/baselines/reference/controlFlowBinaryOrExpression.js +++ b/tests/baselines/reference/controlFlowBinaryOrExpression.js @@ -38,6 +38,7 @@ if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) { //// [controlFlowBinaryOrExpression.js] "use strict"; +exports.__esModule = true; var x; var cond; (x = "") || (x = 0); diff --git a/tests/baselines/reference/controlFlowCommaOperator.types b/tests/baselines/reference/controlFlowCommaOperator.types index 52fd3d7b87d..d4e073295d7 100644 --- a/tests/baselines/reference/controlFlowCommaOperator.types +++ b/tests/baselines/reference/controlFlowCommaOperator.types @@ -17,7 +17,7 @@ function f(x: string | number | boolean) { >y : string | number | boolean >"" : "" >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -36,7 +36,7 @@ function f(x: string | number | boolean) { >z : string | number | boolean >1 : 1 >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"number" : "number" diff --git a/tests/baselines/reference/controlFlowDoWhileStatement.types b/tests/baselines/reference/controlFlowDoWhileStatement.types index 24f3e92b144..baa585bc14d 100644 --- a/tests/baselines/reference/controlFlowDoWhileStatement.types +++ b/tests/baselines/reference/controlFlowDoWhileStatement.types @@ -66,7 +66,7 @@ function c() { if (typeof x === "string") continue; >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" diff --git a/tests/baselines/reference/controlFlowForStatement.types b/tests/baselines/reference/controlFlowForStatement.types index d227e87ea1d..f82a018573b 100644 --- a/tests/baselines/reference/controlFlowForStatement.types +++ b/tests/baselines/reference/controlFlowForStatement.types @@ -82,7 +82,7 @@ function d() { >x : string | number | boolean >"" : "" >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" >x = 5 : 5 @@ -107,7 +107,7 @@ function e() { >"" : "" >0 : 0 >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | true >"string" : "string" >x = "" || true : true @@ -128,7 +128,7 @@ function f() { for (; typeof x !== "string";) { >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -137,7 +137,7 @@ function f() { if (typeof x === "number") break; >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"number" : "number" diff --git a/tests/baselines/reference/controlFlowIIFE.types b/tests/baselines/reference/controlFlowIIFE.types index 7cf4337b53b..1c2e8290394 100644 --- a/tests/baselines/reference/controlFlowIIFE.types +++ b/tests/baselines/reference/controlFlowIIFE.types @@ -13,7 +13,7 @@ function f1() { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -41,7 +41,7 @@ function f2() { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -73,7 +73,7 @@ function f3() { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" diff --git a/tests/baselines/reference/controlFlowIfStatement.types b/tests/baselines/reference/controlFlowIfStatement.types index fd8f25b9ee3..e0ce68db7b1 100644 --- a/tests/baselines/reference/controlFlowIfStatement.types +++ b/tests/baselines/reference/controlFlowIfStatement.types @@ -100,7 +100,7 @@ function c(data: string | T): T { if (typeof data === 'string') { >typeof data === 'string' : boolean ->typeof data : string +>typeof data : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >data : string | T >'string' : "string" @@ -124,7 +124,7 @@ function d(data: string | T): never { if (typeof data === 'string') { >typeof data === 'string' : boolean ->typeof data : string +>typeof data : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >data : string | T >'string' : "string" diff --git a/tests/baselines/reference/controlFlowInstanceof.symbols b/tests/baselines/reference/controlFlowInstanceof.symbols index 31894827990..19304ada888 100644 --- a/tests/baselines/reference/controlFlowInstanceof.symbols +++ b/tests/baselines/reference/controlFlowInstanceof.symbols @@ -46,7 +46,7 @@ function f2(s: Set | Set) { if (s instanceof Promise) { >s : Symbol(s, Decl(controlFlowInstanceof.ts, 13, 12)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) s; // Set & Promise >s : Symbol(s, Decl(controlFlowInstanceof.ts, 13, 12)) diff --git a/tests/baselines/reference/controlFlowPropertyDeclarations.js b/tests/baselines/reference/controlFlowPropertyDeclarations.js index 748f63ea858..27fce9a9a12 100644 --- a/tests/baselines/reference/controlFlowPropertyDeclarations.js +++ b/tests/baselines/reference/controlFlowPropertyDeclarations.js @@ -151,6 +151,7 @@ export class StyleParser { //// [controlFlowPropertyDeclarations.js] // Repro from ##8913 "use strict"; +exports.__esModule = true; var HTMLDOMPropertyConfig = require('react/lib/HTMLDOMPropertyConfig'); // Populate property map with ReactJS's attribute and property mappings // TODO handle/use .Properties value eg: MUST_USE_PROPERTY is not HTML attr diff --git a/tests/baselines/reference/controlFlowSelfReferentialLoop.js b/tests/baselines/reference/controlFlowSelfReferentialLoop.js index f7dbc0a2324..0a7eff198ff 100644 --- a/tests/baselines/reference/controlFlowSelfReferentialLoop.js +++ b/tests/baselines/reference/controlFlowSelfReferentialLoop.js @@ -104,6 +104,7 @@ export default md5; //// [controlFlowSelfReferentialLoop.js] // Repro from #12319 "use strict"; +exports.__esModule = true; function md5(string) { function FF(a, b, c, d, x, s, ac) { return 0; @@ -203,5 +204,4 @@ function md5(string) { b = II(b, c, d, a, x[k + 9], S44, 0xEB86D391); } } -exports.__esModule = true; exports["default"] = md5; diff --git a/tests/baselines/reference/controlFlowWhileStatement.types b/tests/baselines/reference/controlFlowWhileStatement.types index 19f7fc49d02..4576e1a4f62 100644 --- a/tests/baselines/reference/controlFlowWhileStatement.types +++ b/tests/baselines/reference/controlFlowWhileStatement.types @@ -69,7 +69,7 @@ function c() { if (typeof x === "string") continue; >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" diff --git a/tests/baselines/reference/controlFlowWithIncompleteTypes.types b/tests/baselines/reference/controlFlowWithIncompleteTypes.types index 784f22a3966..f5e8f2bcf24 100644 --- a/tests/baselines/reference/controlFlowWithIncompleteTypes.types +++ b/tests/baselines/reference/controlFlowWithIncompleteTypes.types @@ -16,7 +16,7 @@ function foo1() { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -49,7 +49,7 @@ function foo2() { if (typeof x === "number") { >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"number" : "number" diff --git a/tests/baselines/reference/copyrightWithNewLine1.js b/tests/baselines/reference/copyrightWithNewLine1.js index 006c29597b9..f7c1ac602dd 100644 --- a/tests/baselines/reference/copyrightWithNewLine1.js +++ b/tests/baselines/reference/copyrightWithNewLine1.js @@ -15,6 +15,7 @@ greeter.start(); ****************************/ define(["require", "exports", "./greeter"], function (require, exports, model) { "use strict"; + exports.__esModule = true; var el = document.getElementById('content'); var greeter = new model.Greeter(el); /** things */ diff --git a/tests/baselines/reference/copyrightWithoutNewLine1.js b/tests/baselines/reference/copyrightWithoutNewLine1.js index 15e3c9f79be..0f479c3db7f 100644 --- a/tests/baselines/reference/copyrightWithoutNewLine1.js +++ b/tests/baselines/reference/copyrightWithoutNewLine1.js @@ -11,6 +11,7 @@ greeter.start(); //// [copyrightWithoutNewLine1.js] define(["require", "exports", "./greeter"], function (require, exports, model) { "use strict"; + exports.__esModule = true; var el = document.getElementById('content'); var greeter = new model.Greeter(el); /** things */ diff --git a/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.js b/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.js index 89979da4812..725409c2c7f 100644 --- a/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.js +++ b/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.js @@ -11,11 +11,16 @@ var a: D = foo("hi", []); //// [crashInsourcePropertyIsRelatableToTargetProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { this.x = 1; @@ -25,7 +30,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/crashIntypeCheckInvocationExpression.js b/tests/baselines/reference/crashIntypeCheckInvocationExpression.js index 549d7948fcb..d555d3f3bca 100644 --- a/tests/baselines/reference/crashIntypeCheckInvocationExpression.js +++ b/tests/baselines/reference/crashIntypeCheckInvocationExpression.js @@ -15,6 +15,7 @@ export var compileServer = task(() => { //// [crashIntypeCheckInvocationExpression.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var nake; function doCompile(fileset, moduleType) { return undefined; diff --git a/tests/baselines/reference/crashIntypeCheckObjectCreationExpression.js b/tests/baselines/reference/crashIntypeCheckObjectCreationExpression.js index 00f4dbdc377..a115e7ab0a3 100644 --- a/tests/baselines/reference/crashIntypeCheckObjectCreationExpression.js +++ b/tests/baselines/reference/crashIntypeCheckObjectCreationExpression.js @@ -11,6 +11,7 @@ export class BuildWorkspaceService { //// [crashIntypeCheckObjectCreationExpression.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var BuildWorkspaceService = (function () { function BuildWorkspaceService() { } diff --git a/tests/baselines/reference/customTransforms/after.js b/tests/baselines/reference/customTransforms/after.js new file mode 100644 index 00000000000..63c95725f43 --- /dev/null +++ b/tests/baselines/reference/customTransforms/after.js @@ -0,0 +1,15 @@ +// [source.js] +function f1() { } +//@after +var c = (function () { + function c() { + } + return c; +}()); +(function () { }); +//@after +var e; +(function (e) { +})(e || (e = {})); +// leading +function f2() { } // trailing diff --git a/tests/baselines/reference/customTransforms/before.js b/tests/baselines/reference/customTransforms/before.js new file mode 100644 index 00000000000..4ee133afdbc --- /dev/null +++ b/tests/baselines/reference/customTransforms/before.js @@ -0,0 +1,15 @@ +// [source.js] +/*@before*/ +function f1() { } +var c = (function () { + function c() { + } + return c; +}()); +(function () { }); +var e; +(function (e) { +})(e || (e = {})); +// leading +/*@before*/ +function f2() { } // trailing diff --git a/tests/baselines/reference/customTransforms/both.js b/tests/baselines/reference/customTransforms/both.js new file mode 100644 index 00000000000..3013e7f8780 --- /dev/null +++ b/tests/baselines/reference/customTransforms/both.js @@ -0,0 +1,17 @@ +// [source.js] +/*@before*/ +function f1() { } +//@after +var c = (function () { + function c() { + } + return c; +}()); +(function () { }); +//@after +var e; +(function (e) { +})(e || (e = {})); +// leading +/*@before*/ +function f2() { } // trailing diff --git a/tests/baselines/reference/declFileAccessors.js b/tests/baselines/reference/declFileAccessors.js index 2bd51bfbfb2..64a99bb8438 100644 --- a/tests/baselines/reference/declFileAccessors.js +++ b/tests/baselines/reference/declFileAccessors.js @@ -103,6 +103,7 @@ class c2 { //// [declFileAccessors_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); /** This is comment for c1*/ var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/declFileAliasUseBeforeDeclaration.js b/tests/baselines/reference/declFileAliasUseBeforeDeclaration.js index e5219508329..56b8992811b 100644 --- a/tests/baselines/reference/declFileAliasUseBeforeDeclaration.js +++ b/tests/baselines/reference/declFileAliasUseBeforeDeclaration.js @@ -10,6 +10,7 @@ import foo = require("./declFileAliasUseBeforeDeclaration_foo"); //// [declFileAliasUseBeforeDeclaration_foo.js] "use strict"; +exports.__esModule = true; var Foo = (function () { function Foo() { } @@ -18,6 +19,7 @@ var Foo = (function () { exports.Foo = Foo; //// [declFileAliasUseBeforeDeclaration_test.js] "use strict"; +exports.__esModule = true; function bar(a) { } exports.bar = bar; diff --git a/tests/baselines/reference/declFileAmbientExternalModuleWithSingleExportedModule.js b/tests/baselines/reference/declFileAmbientExternalModuleWithSingleExportedModule.js index f98e2f6aafb..6d626e2963d 100644 --- a/tests/baselines/reference/declFileAmbientExternalModuleWithSingleExportedModule.js +++ b/tests/baselines/reference/declFileAmbientExternalModuleWithSingleExportedModule.js @@ -21,6 +21,7 @@ export var x: SubModule.m.m3.c; //// [declFileAmbientExternalModuleWithSingleExportedModule_0.js] //// [declFileAmbientExternalModuleWithSingleExportedModule_1.js] "use strict"; +exports.__esModule = true; //// [declFileAmbientExternalModuleWithSingleExportedModule_0.d.ts] diff --git a/tests/baselines/reference/declFileCallSignatures.js b/tests/baselines/reference/declFileCallSignatures.js index 10b87d4e777..8f79ae6341e 100644 --- a/tests/baselines/reference/declFileCallSignatures.js +++ b/tests/baselines/reference/declFileCallSignatures.js @@ -67,6 +67,7 @@ interface IGlobalCallSignatureWithOwnTypeParametes { //// [declFileCallSignatures_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); //// [declFileCallSignatures_1.js] diff --git a/tests/baselines/reference/declFileClassExtendsNull.js b/tests/baselines/reference/declFileClassExtendsNull.js index 30ddc3f08bf..a7ea02011fe 100644 --- a/tests/baselines/reference/declFileClassExtendsNull.js +++ b/tests/baselines/reference/declFileClassExtendsNull.js @@ -4,15 +4,19 @@ class ExtendsNull extends null { } //// [declFileClassExtendsNull.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ExtendsNull = (function (_super) { __extends(ExtendsNull, _super); function ExtendsNull() { - return _super.apply(this, arguments) || this; } return ExtendsNull; }(null)); diff --git a/tests/baselines/reference/declFileClassWithStaticMethodReturningConstructor.js b/tests/baselines/reference/declFileClassWithStaticMethodReturningConstructor.js index 844559232e4..ee1964415c9 100644 --- a/tests/baselines/reference/declFileClassWithStaticMethodReturningConstructor.js +++ b/tests/baselines/reference/declFileClassWithStaticMethodReturningConstructor.js @@ -8,6 +8,7 @@ export class Enhancement { //// [declFileClassWithStaticMethodReturningConstructor.js] "use strict"; +exports.__esModule = true; var Enhancement = (function () { function Enhancement() { } diff --git a/tests/baselines/reference/declFileConstructSignatures.js b/tests/baselines/reference/declFileConstructSignatures.js index 993c8ea4637..309f7133873 100644 --- a/tests/baselines/reference/declFileConstructSignatures.js +++ b/tests/baselines/reference/declFileConstructSignatures.js @@ -67,6 +67,7 @@ interface IGlobalConstructSignatureWithOwnTypeParametes { //// [declFileConstructSignatures_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); //// [declFileConstructSignatures_1.js] diff --git a/tests/baselines/reference/declFileConstructors.js b/tests/baselines/reference/declFileConstructors.js index 44e816712fb..214620193b7 100644 --- a/tests/baselines/reference/declFileConstructors.js +++ b/tests/baselines/reference/declFileConstructors.js @@ -99,6 +99,7 @@ class GlobalConstructorWithParameterInitializer { //// [declFileConstructors_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var SimpleConstructor = (function () { /** This comment should appear for foo*/ function SimpleConstructor() { diff --git a/tests/baselines/reference/declFileExportAssignmentOfGenericInterface.js b/tests/baselines/reference/declFileExportAssignmentOfGenericInterface.js index c54c3c7e731..1caa9207193 100644 --- a/tests/baselines/reference/declFileExportAssignmentOfGenericInterface.js +++ b/tests/baselines/reference/declFileExportAssignmentOfGenericInterface.js @@ -15,10 +15,12 @@ x.a; //// [declFileExportAssignmentOfGenericInterface_0.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [declFileExportAssignmentOfGenericInterface_1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.x.a; }); diff --git a/tests/baselines/reference/declFileExportImportChain.js b/tests/baselines/reference/declFileExportImportChain.js index 99affd5eb4d..2af2103b62a 100644 --- a/tests/baselines/reference/declFileExportImportChain.js +++ b/tests/baselines/reference/declFileExportImportChain.js @@ -44,6 +44,7 @@ define(["require", "exports"], function (require, exports) { //// [declFileExportImportChain_b.js] define(["require", "exports", "declFileExportImportChain_a"], function (require, exports, a) { "use strict"; + exports.__esModule = true; exports.a = a; }); //// [declFileExportImportChain_b1.js] @@ -54,11 +55,13 @@ define(["require", "exports", "declFileExportImportChain_b"], function (require, //// [declFileExportImportChain_c.js] define(["require", "exports", "declFileExportImportChain_b1"], function (require, exports, b1) { "use strict"; + exports.__esModule = true; exports.b1 = b1; }); //// [declFileExportImportChain_d.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/declFileExportImportChain2.js b/tests/baselines/reference/declFileExportImportChain2.js index 27c61e9e43d..70478fdf430 100644 --- a/tests/baselines/reference/declFileExportImportChain2.js +++ b/tests/baselines/reference/declFileExportImportChain2.js @@ -46,11 +46,13 @@ define(["require", "exports", "declFileExportImportChain2_a"], function (require //// [declFileExportImportChain2_c.js] define(["require", "exports", "declFileExportImportChain2_b"], function (require, exports, b) { "use strict"; + exports.__esModule = true; exports.b = b; }); //// [declFileExportImportChain2_d.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/declFileForExportedImport.js b/tests/baselines/reference/declFileForExportedImport.js index 6870e16f941..809f01878d4 100644 --- a/tests/baselines/reference/declFileForExportedImport.js +++ b/tests/baselines/reference/declFileForExportedImport.js @@ -13,8 +13,10 @@ var z = b.x; //// [declFileForExportedImport_0.js] "use strict"; +exports.__esModule = true; //// [declFileForExportedImport_1.js] "use strict"; +exports.__esModule = true; /// exports.a = require("./declFileForExportedImport_0"); var y = exports.a.x; diff --git a/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.js b/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.js index 442007d9b9a..9bdd0fc09a7 100644 --- a/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.js +++ b/tests/baselines/reference/declFileForFunctionTypeAsTypeParameter.js @@ -10,11 +10,16 @@ interface I extends X<() => number> { //// [declFileForFunctionTypeAsTypeParameter.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var X = (function () { function X() { } @@ -23,7 +28,7 @@ var X = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(X)); diff --git a/tests/baselines/reference/declFileFunctions.js b/tests/baselines/reference/declFileFunctions.js index e4f674d43c0..f62b7772b41 100644 --- a/tests/baselines/reference/declFileFunctions.js +++ b/tests/baselines/reference/declFileFunctions.js @@ -79,6 +79,7 @@ function globalfooWithOverloads(a: any): any { //// [declFileFunctions_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); /** This comment should appear for foo*/ function foo() { } diff --git a/tests/baselines/reference/declFileGenericClassWithGenericExtendedClass.js b/tests/baselines/reference/declFileGenericClassWithGenericExtendedClass.js index 47593dc9d68..58d7bb774f1 100644 --- a/tests/baselines/reference/declFileGenericClassWithGenericExtendedClass.js +++ b/tests/baselines/reference/declFileGenericClassWithGenericExtendedClass.js @@ -13,11 +13,16 @@ class Baz implements IBar { //// [declFileGenericClassWithGenericExtendedClass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -26,7 +31,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/declFileGenericType.js b/tests/baselines/reference/declFileGenericType.js index b2e99a73ad7..f56abaf6b97 100644 --- a/tests/baselines/reference/declFileGenericType.js +++ b/tests/baselines/reference/declFileGenericType.js @@ -41,11 +41,17 @@ export var j = C.F6; //// [declFileGenericType.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var C; (function (C) { var A = (function () { @@ -91,7 +97,7 @@ exports.g = C.F5(); var h = (function (_super) { __extends(h, _super); function h() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return h; }(C.A)); diff --git a/tests/baselines/reference/declFileGenericType2.js b/tests/baselines/reference/declFileGenericType2.js index 720be79b28d..1c6f2002da2 100644 --- a/tests/baselines/reference/declFileGenericType2.js +++ b/tests/baselines/reference/declFileGenericType2.js @@ -43,11 +43,16 @@ module templa.dom.mvc.composite { //// [declFileGenericType2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // Module var templa; (function (templa) { diff --git a/tests/baselines/reference/declFileImportModuleWithExportAssignment.js b/tests/baselines/reference/declFileImportModuleWithExportAssignment.js index a733e1332a7..110539774df 100644 --- a/tests/baselines/reference/declFileImportModuleWithExportAssignment.js +++ b/tests/baselines/reference/declFileImportModuleWithExportAssignment.js @@ -32,6 +32,7 @@ var m2; module.exports = m2; //// [declFileImportModuleWithExportAssignment_1.js] "use strict"; +exports.__esModule = true; /**This is on import declaration*/ var a1 = require("./declFileImportModuleWithExportAssignment_0"); exports.a = a1; diff --git a/tests/baselines/reference/declFileIndexSignatures.js b/tests/baselines/reference/declFileIndexSignatures.js index 4d3f3847ca1..b7b2698b11b 100644 --- a/tests/baselines/reference/declFileIndexSignatures.js +++ b/tests/baselines/reference/declFileIndexSignatures.js @@ -37,6 +37,7 @@ interface IGlobalIndexSignatureWithTypeParameter { //// [declFileIndexSignatures_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); //// [declFileIndexSignatures_1.js] diff --git a/tests/baselines/reference/declFileMethods.js b/tests/baselines/reference/declFileMethods.js index 4a317a4e720..61e2bfab700 100644 --- a/tests/baselines/reference/declFileMethods.js +++ b/tests/baselines/reference/declFileMethods.js @@ -192,6 +192,7 @@ interface I2 { //// [declFileMethods_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var c1 = (function () { function c1() { } diff --git a/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.js b/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.js index 17d885788dd..da1ebb2a8f3 100644 --- a/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.js +++ b/tests/baselines/reference/declFileWithClassNameConflictingWithClassReferredByExtendsClause.js @@ -21,11 +21,16 @@ module X.Y.base.Z { //// [declFileWithClassNameConflictingWithClassReferredByExtendsClause.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var X; (function (X) { var Y; @@ -35,7 +40,7 @@ var X; var W = (function (_super) { __extends(W, _super); function W() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return W; }(A.B.Base.W)); @@ -53,7 +58,7 @@ var X; var W = (function (_super) { __extends(W, _super); function W() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return W; }(X.Y.base.W)); diff --git a/tests/baselines/reference/declFileWithExtendsClauseThatHasItsContainerNameConflict.js b/tests/baselines/reference/declFileWithExtendsClauseThatHasItsContainerNameConflict.js index 70d0cd5a3dd..d369da3902b 100644 --- a/tests/baselines/reference/declFileWithExtendsClauseThatHasItsContainerNameConflict.js +++ b/tests/baselines/reference/declFileWithExtendsClauseThatHasItsContainerNameConflict.js @@ -19,11 +19,16 @@ module A.B.C { } //// [declFileWithExtendsClauseThatHasItsContainerNameConflict.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A; (function (A) { var B; @@ -44,7 +49,7 @@ var A; var ContextMenu = (function (_super) { __extends(ContextMenu, _super); function ContextMenu() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ContextMenu; }(B.EventManager)); diff --git a/tests/baselines/reference/declarationEmitClassMemberNameConflict.js b/tests/baselines/reference/declarationEmitClassMemberNameConflict.js index 23c83276201..698622a8650 100644 --- a/tests/baselines/reference/declarationEmitClassMemberNameConflict.js +++ b/tests/baselines/reference/declarationEmitClassMemberNameConflict.js @@ -38,6 +38,7 @@ export class C4 { //// [declarationEmitClassMemberNameConflict.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var C1 = (function () { function C1() { } diff --git a/tests/baselines/reference/declarationEmitExportAssignment.js b/tests/baselines/reference/declarationEmitExportAssignment.js index 8c97ef8eb07..223376ef8ff 100644 --- a/tests/baselines/reference/declarationEmitExportAssignment.js +++ b/tests/baselines/reference/declarationEmitExportAssignment.js @@ -12,6 +12,7 @@ export = foo; //// [utils.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); function foo() { } exports.foo = foo; function bar() { } diff --git a/tests/baselines/reference/declarationEmitExportDeclaration.js b/tests/baselines/reference/declarationEmitExportDeclaration.js index dfbed90742d..57c39b95e64 100644 --- a/tests/baselines/reference/declarationEmitExportDeclaration.js +++ b/tests/baselines/reference/declarationEmitExportDeclaration.js @@ -15,12 +15,14 @@ export {bar}; //// [utils.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); function foo() { } exports.foo = foo; function bar() { } exports.bar = bar; //// [index.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = require("./utils"); exports.bar = utils_1.bar; utils_1.foo(); diff --git a/tests/baselines/reference/declarationEmitExpressionInExtends.js b/tests/baselines/reference/declarationEmitExpressionInExtends.js index 726c7b22446..884897a9cf6 100644 --- a/tests/baselines/reference/declarationEmitExpressionInExtends.js +++ b/tests/baselines/reference/declarationEmitExpressionInExtends.js @@ -15,11 +15,16 @@ var q: B; q.s; //// [declarationEmitExpressionInExtends.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x; var Q = (function () { function Q() { @@ -29,7 +34,7 @@ var Q = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(x)); diff --git a/tests/baselines/reference/declarationEmitExpressionInExtends2.js b/tests/baselines/reference/declarationEmitExpressionInExtends2.js index 4081de6d3ed..86c79dda8a8 100644 --- a/tests/baselines/reference/declarationEmitExpressionInExtends2.js +++ b/tests/baselines/reference/declarationEmitExpressionInExtends2.js @@ -13,11 +13,16 @@ class MyClass extends getClass(2) { } //// [declarationEmitExpressionInExtends2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -29,7 +34,7 @@ function getClass(c) { var MyClass = (function (_super) { __extends(MyClass, _super); function MyClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return MyClass; }(getClass(2))); diff --git a/tests/baselines/reference/declarationEmitExpressionInExtends3.errors.txt b/tests/baselines/reference/declarationEmitExpressionInExtends3.errors.txt index 5ed622caafe..8bc4d9ac8d2 100644 --- a/tests/baselines/reference/declarationEmitExpressionInExtends3.errors.txt +++ b/tests/baselines/reference/declarationEmitExpressionInExtends3.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/declarationEmitExpressionInExtends3.ts(29,30): error TS4020: Extends clause of exported class 'MyClass' has or is using private name 'LocalClass'. -tests/cases/compiler/declarationEmitExpressionInExtends3.ts(37,31): error TS4020: Extends clause of exported class 'MyClass3' has or is using private name 'LocalInterface'. +tests/cases/compiler/declarationEmitExpressionInExtends3.ts(29,30): error TS4020: 'extends' clause of exported class 'MyClass' has or is using private name 'LocalClass'. +tests/cases/compiler/declarationEmitExpressionInExtends3.ts(37,31): error TS4020: 'extends' clause of exported class 'MyClass3' has or is using private name 'LocalInterface'. ==== tests/cases/compiler/declarationEmitExpressionInExtends3.ts (2 errors) ==== @@ -33,7 +33,7 @@ tests/cases/compiler/declarationEmitExpressionInExtends3.ts(37,31): error TS4020 export class MyClass extends getLocalClass(undefined) { // error LocalClass is inaccisible ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS4020: Extends clause of exported class 'MyClass' has or is using private name 'LocalClass'. +!!! error TS4020: 'extends' clause of exported class 'MyClass' has or is using private name 'LocalClass'. } @@ -43,7 +43,7 @@ tests/cases/compiler/declarationEmitExpressionInExtends3.ts(37,31): error TS4020 export class MyClass3 extends getExportedClass(undefined) { // Error LocalInterface is inaccisble ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS4020: Extends clause of exported class 'MyClass3' has or is using private name 'LocalInterface'. +!!! error TS4020: 'extends' clause of exported class 'MyClass3' has or is using private name 'LocalInterface'. } diff --git a/tests/baselines/reference/declarationEmitExpressionInExtends3.js b/tests/baselines/reference/declarationEmitExpressionInExtends3.js index f36a7e250a2..a02eac46dba 100644 --- a/tests/baselines/reference/declarationEmitExpressionInExtends3.js +++ b/tests/baselines/reference/declarationEmitExpressionInExtends3.js @@ -45,11 +45,17 @@ export class MyClass4 extends getExportedClass(undefined) { + ~ +!!! error TS4093: 'extends' clause of exported class 'C' refers to a type whose name cannot be referenced. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'D' is not generic. } class C2 extends SomeUndefinedFunction() { + ~~ +!!! error TS4093: 'extends' clause of exported class 'C2' refers to a type whose name cannot be referenced. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'SomeUndefinedFunction'. @@ -30,6 +36,6 @@ tests/cases/compiler/declarationEmitExpressionInExtends4.ts(15,18): error TS4020 ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'SomeUndefinedFunction'. ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS4020: Extends clause of exported class 'C3' has or is using private name 'SomeUndefinedFunction'. +!!! error TS4020: 'extends' clause of exported class 'C3' has or is using private name 'SomeUndefinedFunction'. } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitExpressionInExtends4.js b/tests/baselines/reference/declarationEmitExpressionInExtends4.js index b90c1275197..d6c33023c12 100644 --- a/tests/baselines/reference/declarationEmitExpressionInExtends4.js +++ b/tests/baselines/reference/declarationEmitExpressionInExtends4.js @@ -18,11 +18,16 @@ class C3 extends SomeUndefinedFunction { } //// [declarationEmitExpressionInExtends4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function getSomething() { return (function () { function D() { @@ -33,21 +38,21 @@ function getSomething() { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(getSomething())); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(SomeUndefinedFunction())); var C3 = (function (_super) { __extends(C3, _super); function C3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C3; }(SomeUndefinedFunction)); diff --git a/tests/baselines/reference/declarationEmitIdentifierPredicates01.js b/tests/baselines/reference/declarationEmitIdentifierPredicates01.js index 73141eb9af9..08208c2435d 100644 --- a/tests/baselines/reference/declarationEmitIdentifierPredicates01.js +++ b/tests/baselines/reference/declarationEmitIdentifierPredicates01.js @@ -6,6 +6,7 @@ export function f(x: any): x is number { //// [declarationEmitIdentifierPredicates01.js] "use strict"; +exports.__esModule = true; function f(x) { return typeof x === "number"; } diff --git a/tests/baselines/reference/declarationEmitIdentifierPredicates01.types b/tests/baselines/reference/declarationEmitIdentifierPredicates01.types index 1129012a80a..1aeb3ea824d 100644 --- a/tests/baselines/reference/declarationEmitIdentifierPredicates01.types +++ b/tests/baselines/reference/declarationEmitIdentifierPredicates01.types @@ -7,7 +7,7 @@ export function f(x: any): x is number { return typeof x === "number"; >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : any >"number" : "number" } diff --git a/tests/baselines/reference/declarationEmitIdentifierPredicatesWithPrivateName01.js b/tests/baselines/reference/declarationEmitIdentifierPredicatesWithPrivateName01.js index 234542d8d99..5829e9b4427 100644 --- a/tests/baselines/reference/declarationEmitIdentifierPredicatesWithPrivateName01.js +++ b/tests/baselines/reference/declarationEmitIdentifierPredicatesWithPrivateName01.js @@ -10,6 +10,7 @@ export function f(x: any): x is I { //// [declarationEmitIdentifierPredicatesWithPrivateName01.js] "use strict"; +exports.__esModule = true; function f(x) { return typeof x.a === "number"; } diff --git a/tests/baselines/reference/declarationEmitIndexTypeNotFound.js b/tests/baselines/reference/declarationEmitIndexTypeNotFound.js index 22100e5cb72..b1fac7c3cc2 100644 --- a/tests/baselines/reference/declarationEmitIndexTypeNotFound.js +++ b/tests/baselines/reference/declarationEmitIndexTypeNotFound.js @@ -7,3 +7,4 @@ export interface Test { //// [declarationEmitIndexTypeNotFound.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias1.js b/tests/baselines/reference/declarationEmitInferedTypeAlias1.js index 05ce74e3bad..4e41c8558c6 100644 --- a/tests/baselines/reference/declarationEmitInferedTypeAlias1.js +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias1.js @@ -14,11 +14,13 @@ export { v } //// [0.js] "use strict"; +exports.__esModule = true; { var obj = true; } //// [1.js] "use strict"; +exports.__esModule = true; var v = "str" || true; exports.v = v; diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias2.js b/tests/baselines/reference/declarationEmitInferedTypeAlias2.js index 307a9b82d67..601026ab6f3 100644 --- a/tests/baselines/reference/declarationEmitInferedTypeAlias2.js +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias2.js @@ -17,11 +17,13 @@ export { v, bar } //// [0.js] "use strict"; +exports.__esModule = true; { var obj = true; } //// [1.js] "use strict"; +exports.__esModule = true; var v = "str" || true; exports.v = v; function bar() { diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias3.js b/tests/baselines/reference/declarationEmitInferedTypeAlias3.js index c99e5c429dd..30df7e38b01 100644 --- a/tests/baselines/reference/declarationEmitInferedTypeAlias3.js +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias3.js @@ -14,13 +14,14 @@ export default x; //// [0.js] "use strict"; +exports.__esModule = true; { var obj = true; } //// [1.js] "use strict"; -var x = "hi" || 5; exports.__esModule = true; +var x = "hi" || 5; exports["default"] = x; diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias5.js b/tests/baselines/reference/declarationEmitInferedTypeAlias5.js index 79d28d3d181..24f2a52c5d8 100644 --- a/tests/baselines/reference/declarationEmitInferedTypeAlias5.js +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias5.js @@ -13,9 +13,11 @@ export { v } //// [0.js] "use strict"; +exports.__esModule = true; var obj = true; //// [1.js] "use strict"; +exports.__esModule = true; //let v2: Z.Data; var v = "str" || true; exports.v = v; diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias6.js b/tests/baselines/reference/declarationEmitInferedTypeAlias6.js index 924f73d0ed9..5b14a3738e4 100644 --- a/tests/baselines/reference/declarationEmitInferedTypeAlias6.js +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias6.js @@ -14,11 +14,13 @@ export { v } //// [0.js] "use strict"; +exports.__esModule = true; { var obj = true; } //// [1.js] "use strict"; +exports.__esModule = true; var v = "str" || true; exports.v = v; diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias7.js b/tests/baselines/reference/declarationEmitInferedTypeAlias7.js index 2fba057fc91..9a9b1247e24 100644 --- a/tests/baselines/reference/declarationEmitInferedTypeAlias7.js +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias7.js @@ -11,9 +11,11 @@ export { v } //// [0.js] "use strict"; +exports.__esModule = true; var obj = true; //// [1.js] "use strict"; +exports.__esModule = true; var v = "str" || true; exports.v = v; diff --git a/tests/baselines/reference/declarationEmitInferedTypeAlias9.js b/tests/baselines/reference/declarationEmitInferedTypeAlias9.js index 667acdff49c..cddb4630740 100644 --- a/tests/baselines/reference/declarationEmitInferedTypeAlias9.js +++ b/tests/baselines/reference/declarationEmitInferedTypeAlias9.js @@ -9,6 +9,7 @@ export function returnSomeGlobalValue() { //// [declarationEmitInferedTypeAlias9.js] "use strict"; +exports.__esModule = true; var x; function returnSomeGlobalValue() { return x; diff --git a/tests/baselines/reference/declarationEmitInvalidExport.js b/tests/baselines/reference/declarationEmitInvalidExport.js index 18ed73b0a5a..d4280cd00c6 100644 --- a/tests/baselines/reference/declarationEmitInvalidExport.js +++ b/tests/baselines/reference/declarationEmitInvalidExport.js @@ -9,6 +9,7 @@ export type MyClass = typeof myClass; //// [declarationEmitInvalidExport.js] "use strict"; +exports.__esModule = true; if (false) { export var myClass = 0; } diff --git a/tests/baselines/reference/declarationEmitNameConflicts.js b/tests/baselines/reference/declarationEmitNameConflicts.js index 6d848b42869..5440f3d3584 100644 --- a/tests/baselines/reference/declarationEmitNameConflicts.js +++ b/tests/baselines/reference/declarationEmitNameConflicts.js @@ -63,6 +63,7 @@ var f; module.exports = f; //// [declarationEmit_nameConflicts_0.js] "use strict"; +exports.__esModule = true; var im = require("./declarationEmit_nameConflicts_1"); var M; (function (M) { diff --git a/tests/baselines/reference/declarationEmitNameConflicts3.js b/tests/baselines/reference/declarationEmitNameConflicts3.js index ffcfead83bf..f093ff5b3b2 100644 --- a/tests/baselines/reference/declarationEmitNameConflicts3.js +++ b/tests/baselines/reference/declarationEmitNameConflicts3.js @@ -27,11 +27,16 @@ module M.P { } //// [declarationEmitNameConflicts3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M; (function (M) { var D; @@ -63,7 +68,7 @@ var M; var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(C)); diff --git a/tests/baselines/reference/declarationEmitNameConflictsWithAlias.js b/tests/baselines/reference/declarationEmitNameConflictsWithAlias.js index b49e3ad314d..4b4aca4f4b2 100644 --- a/tests/baselines/reference/declarationEmitNameConflictsWithAlias.js +++ b/tests/baselines/reference/declarationEmitNameConflictsWithAlias.js @@ -8,6 +8,7 @@ export module M { //// [declarationEmitNameConflictsWithAlias.js] "use strict"; +exports.__esModule = true; var M; (function (M) { })(M = exports.M || (exports.M = {})); diff --git a/tests/baselines/reference/declarationEmitPromise.js b/tests/baselines/reference/declarationEmitPromise.js index 9e820a789c9..7444a956a2a 100644 --- a/tests/baselines/reference/declarationEmitPromise.js +++ b/tests/baselines/reference/declarationEmitPromise.js @@ -32,6 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; +Object.defineProperty(exports, "__esModule", { value: true }); class bluebird { } exports.bluebird = bluebird; diff --git a/tests/baselines/reference/declarationEmitProtectedMembers.js b/tests/baselines/reference/declarationEmitProtectedMembers.js index 9ae8e8a2437..7b3b42e7c97 100644 --- a/tests/baselines/reference/declarationEmitProtectedMembers.js +++ b/tests/baselines/reference/declarationEmitProtectedMembers.js @@ -51,11 +51,16 @@ class C4 { } //// [declarationEmitProtectedMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // Class with protected members var C1 = (function () { function C1() { @@ -88,7 +93,7 @@ var C1 = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C2.prototype.f = function () { return _super.prototype.f.call(this) + this.x; @@ -102,7 +107,7 @@ var C2 = (function (_super) { var C3 = (function (_super) { __extends(C3, _super); function C3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C3.prototype.f = function () { return _super.prototype.f.call(this); diff --git a/tests/baselines/reference/declarationEmitThisPredicates01.js b/tests/baselines/reference/declarationEmitThisPredicates01.js index ad9b7a70373..e95a7db05ed 100644 --- a/tests/baselines/reference/declarationEmitThisPredicates01.js +++ b/tests/baselines/reference/declarationEmitThisPredicates01.js @@ -11,11 +11,17 @@ export class D extends C { //// [declarationEmitThisPredicates01.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var C = (function () { function C() { } @@ -28,7 +34,7 @@ exports.C = C; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/declarationEmitThisPredicates02.js b/tests/baselines/reference/declarationEmitThisPredicates02.js index e938a615b6d..0e7c99df1f3 100644 --- a/tests/baselines/reference/declarationEmitThisPredicates02.js +++ b/tests/baselines/reference/declarationEmitThisPredicates02.js @@ -15,6 +15,7 @@ export const obj = { //// [declarationEmitThisPredicates02.js] "use strict"; +exports.__esModule = true; exports.obj = { m: function () { var dis = this; diff --git a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName01.js b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName01.js index fe7995462ef..a0f611d2d29 100644 --- a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName01.js +++ b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName01.js @@ -11,11 +11,17 @@ class D extends C { //// [declarationEmitThisPredicatesWithPrivateName01.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var C = (function () { function C() { } @@ -28,7 +34,7 @@ exports.C = C; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.js b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.js index df0d5b7903a..7ec7ba5dec8 100644 --- a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.js +++ b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.js @@ -15,6 +15,7 @@ export const obj = { //// [declarationEmitThisPredicatesWithPrivateName02.js] "use strict"; +exports.__esModule = true; exports.obj = { m: function () { var dis = this; diff --git a/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters1.js b/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters1.js index 6079de35964..84b55a9792f 100644 --- a/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters1.js +++ b/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters1.js @@ -6,6 +6,7 @@ export const y = (x: Foo) => 1 //// [declarationEmitTypeAliasWithTypeParameters1.js] "use strict"; +exports.__esModule = true; exports.y = function (x) { return 1; }; diff --git a/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters2.js b/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters2.js index d5bf31bd755..1bb6beac9e1 100644 --- a/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters2.js +++ b/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters2.js @@ -7,6 +7,7 @@ export const y = (x: Baa) => 1 //// [declarationEmitTypeAliasWithTypeParameters2.js] "use strict"; +exports.__esModule = true; exports.y = function (x) { return 1; }; diff --git a/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters5.js b/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters5.js index 2f4fff7d72c..28997a75496 100644 --- a/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters5.js +++ b/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters5.js @@ -12,6 +12,7 @@ function foo() { //// [declarationEmitTypeAliasWithTypeParameters5.js] "use strict"; +exports.__esModule = true; function foo() { return {}; } diff --git a/tests/baselines/reference/declarationEmitUnknownImport.js b/tests/baselines/reference/declarationEmitUnknownImport.js index bccf2337e08..1ac1e934578 100644 --- a/tests/baselines/reference/declarationEmitUnknownImport.js +++ b/tests/baselines/reference/declarationEmitUnknownImport.js @@ -5,5 +5,6 @@ export {Foo} //// [declarationEmitUnknownImport.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var Foo = SomeNonExistingName; exports.Foo = Foo; diff --git a/tests/baselines/reference/declarationEmitUnknownImport2.js b/tests/baselines/reference/declarationEmitUnknownImport2.js index 08afa34f8c8..1f291312913 100644 --- a/tests/baselines/reference/declarationEmitUnknownImport2.js +++ b/tests/baselines/reference/declarationEmitUnknownImport2.js @@ -5,7 +5,7 @@ export default Foo //// [declarationEmitUnknownImport2.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var Foo = From; './Foo'; // Syntax error -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Foo; diff --git a/tests/baselines/reference/declarationMerging2.js b/tests/baselines/reference/declarationMerging2.js index 3157445fa36..64a6cf2d849 100644 --- a/tests/baselines/reference/declarationMerging2.js +++ b/tests/baselines/reference/declarationMerging2.js @@ -18,6 +18,7 @@ declare module "./a" { //// [a.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var A = (function () { function A() { } @@ -29,4 +30,5 @@ define(["require", "exports"], function (require, exports) { //// [b.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/declareDottedExtend.js b/tests/baselines/reference/declareDottedExtend.js index 3c7588d2b6c..1256602ee1e 100644 --- a/tests/baselines/reference/declareDottedExtend.js +++ b/tests/baselines/reference/declareDottedExtend.js @@ -12,23 +12,28 @@ class E extends A.B.C{ } //// [declareDottedExtend.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ab = A.B; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(ab.C)); var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(A.B.C)); diff --git a/tests/baselines/reference/decoratedClassExportsCommonJS1.js b/tests/baselines/reference/decoratedClassExportsCommonJS1.js index 7ef4369f975..b624c11e79d 100644 --- a/tests/baselines/reference/decoratedClassExportsCommonJS1.js +++ b/tests/baselines/reference/decoratedClassExportsCommonJS1.js @@ -14,6 +14,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, 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; return c > 3 && r && Object.defineProperty(target, key, r), r; }; +Object.defineProperty(exports, "__esModule", { value: true }); let Testing123 = Testing123_1 = class Testing123 { }; Testing123.prop1 = Testing123_1.prop0; diff --git a/tests/baselines/reference/decoratedClassExportsCommonJS2.js b/tests/baselines/reference/decoratedClassExportsCommonJS2.js index 994178cbb79..978d8f18402 100644 --- a/tests/baselines/reference/decoratedClassExportsCommonJS2.js +++ b/tests/baselines/reference/decoratedClassExportsCommonJS2.js @@ -13,6 +13,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, 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; return c > 3 && r && Object.defineProperty(target, key, r), r; }; +Object.defineProperty(exports, "__esModule", { value: true }); let Testing123 = Testing123_1 = class Testing123 { }; Testing123 = Testing123_1 = __decorate([ diff --git a/tests/baselines/reference/decoratedDefaultExportsGetExportedAmd.js b/tests/baselines/reference/decoratedDefaultExportsGetExportedAmd.js index 14ede865a2f..dadaa5ed6df 100644 --- a/tests/baselines/reference/decoratedDefaultExportsGetExportedAmd.js +++ b/tests/baselines/reference/decoratedDefaultExportsGetExportedAmd.js @@ -22,13 +22,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, }; define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var decorator; let Foo = class Foo { }; Foo = __decorate([ decorator ], Foo); - Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Foo; }); //// [b.js] @@ -40,12 +40,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, }; define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var decorator; let default_1 = class { }; default_1 = __decorate([ decorator ], default_1); - Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; }); diff --git a/tests/baselines/reference/decoratedDefaultExportsGetExportedCommonjs.js b/tests/baselines/reference/decoratedDefaultExportsGetExportedCommonjs.js index ecc04859234..f6c7b7cbc8b 100644 --- a/tests/baselines/reference/decoratedDefaultExportsGetExportedCommonjs.js +++ b/tests/baselines/reference/decoratedDefaultExportsGetExportedCommonjs.js @@ -21,13 +21,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, 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; return c > 3 && r && Object.defineProperty(target, key, r), r; }; +Object.defineProperty(exports, "__esModule", { value: true }); var decorator; let Foo = class Foo { }; Foo = __decorate([ decorator ], Foo); -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Foo; //// [b.js] "use strict"; @@ -37,11 +37,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, 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; return c > 3 && r && Object.defineProperty(target, key, r), r; }; +Object.defineProperty(exports, "__esModule", { value: true }); var decorator; let default_1 = class { }; default_1 = __decorate([ decorator ], default_1); -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; diff --git a/tests/baselines/reference/decoratedDefaultExportsGetExportedUmd.js b/tests/baselines/reference/decoratedDefaultExportsGetExportedUmd.js index 47f9a524432..beb5fa26755 100644 --- a/tests/baselines/reference/decoratedDefaultExportsGetExportedUmd.js +++ b/tests/baselines/reference/decoratedDefaultExportsGetExportedUmd.js @@ -30,13 +30,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, } })(function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var decorator; let Foo = class Foo { }; Foo = __decorate([ decorator ], Foo); - Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Foo; }); //// [b.js] @@ -56,12 +56,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, } })(function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var decorator; let default_1 = class { }; default_1 = __decorate([ decorator ], default_1); - Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; }); diff --git a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js index fc8dc1c5515..22e4a448f1e 100644 --- a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js +++ b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js @@ -23,6 +23,7 @@ class Wat { //// [a.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); // from #3108 exports.test = 'abc'; //// [b.js] @@ -33,6 +34,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, 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; return c > 3 && r && Object.defineProperty(target, key, r), r; }; +Object.defineProperty(exports, "__esModule", { value: true }); var a_1 = require("./a"); function filter(handler) { return function (target, propertyKey) { diff --git a/tests/baselines/reference/decoratorMetadata.js b/tests/baselines/reference/decoratorMetadata.js index cb253d43c16..9998ae3d08a 100644 --- a/tests/baselines/reference/decoratorMetadata.js +++ b/tests/baselines/reference/decoratorMetadata.js @@ -20,12 +20,12 @@ class MyComponent { //// [service.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var Service = (function () { function Service() { } return Service; }()); -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Service; //// [component.js] "use strict"; @@ -38,6 +38,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +Object.defineProperty(exports, "__esModule", { value: true }); var service_1 = require("./service"); var MyComponent = (function () { function MyComponent(Service) { diff --git a/tests/baselines/reference/decoratorMetadataOnInferredType.js b/tests/baselines/reference/decoratorMetadataOnInferredType.js index 43cdaa79ab8..6f247637729 100644 --- a/tests/baselines/reference/decoratorMetadataOnInferredType.js +++ b/tests/baselines/reference/decoratorMetadataOnInferredType.js @@ -19,6 +19,7 @@ export class B { //// [decoratorMetadataOnInferredType.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var A = (function () { function A() { console.log('new A'); diff --git a/tests/baselines/reference/decoratorMetadataPromise.symbols b/tests/baselines/reference/decoratorMetadataPromise.symbols index b0ebe05e8c1..6eec0fe4623 100644 --- a/tests/baselines/reference/decoratorMetadataPromise.symbols +++ b/tests/baselines/reference/decoratorMetadataPromise.symbols @@ -18,7 +18,7 @@ class A { async bar(): Promise { return 0; } >bar : Symbol(A.bar, Decl(decoratorMetadataPromise.ts, 5, 18)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) @decorator >decorator : Symbol(decorator, Decl(decoratorMetadataPromise.ts, 1, 13)) @@ -26,8 +26,8 @@ class A { baz(n: Promise): Promise { return n; } >baz : Symbol(A.baz, Decl(decoratorMetadataPromise.ts, 7, 46)) >n : Symbol(n, Decl(decoratorMetadataPromise.ts, 9, 8)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >n : Symbol(n, Decl(decoratorMetadataPromise.ts, 9, 8)) } diff --git a/tests/baselines/reference/decoratorMetadataRestParameterWithImportedType.js b/tests/baselines/reference/decoratorMetadataRestParameterWithImportedType.js index be249800d57..a65ba5b2f73 100644 --- a/tests/baselines/reference/decoratorMetadataRestParameterWithImportedType.js +++ b/tests/baselines/reference/decoratorMetadataRestParameterWithImportedType.js @@ -42,6 +42,7 @@ export class ClassA { //// [aux.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var SomeClass = (function () { function SomeClass() { } @@ -50,6 +51,7 @@ var SomeClass = (function () { exports.SomeClass = SomeClass; //// [aux1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var SomeClass1 = (function () { function SomeClass1() { } @@ -58,6 +60,7 @@ var SomeClass1 = (function () { exports.SomeClass1 = SomeClass1; //// [aux2.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var SomeClass2 = (function () { function SomeClass2() { } @@ -75,6 +78,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +Object.defineProperty(exports, "__esModule", { value: true }); var aux_1 = require("./aux"); var aux1_1 = require("./aux1"); function annotation() { diff --git a/tests/baselines/reference/decoratorMetadataWithConstructorType.js b/tests/baselines/reference/decoratorMetadataWithConstructorType.js index 2c14c9b5bda..10aa42ddce7 100644 --- a/tests/baselines/reference/decoratorMetadataWithConstructorType.js +++ b/tests/baselines/reference/decoratorMetadataWithConstructorType.js @@ -19,6 +19,7 @@ export class B { //// [decoratorMetadataWithConstructorType.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var A = (function () { function A() { console.log('new A'); diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js index 258635a5f3a..b0e23a78971 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js @@ -25,6 +25,7 @@ export {MyClass}; //// [db.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var db = (function () { function db() { } @@ -35,6 +36,7 @@ var db = (function () { exports.db = db; //// [service.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var db_1 = require("./db"); function someDecorator(target) { return target; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js index 104e449bc0c..f03190cff0c 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js @@ -25,6 +25,7 @@ export {MyClass}; //// [db.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var db = (function () { function db() { } @@ -35,6 +36,7 @@ var db = (function () { exports.db = db; //// [service.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var db_1 = require("./db"); function someDecorator(target) { return target; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js index 2925cad6afe..c1eca081527 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js @@ -25,6 +25,7 @@ export {MyClass}; //// [db.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var db = (function () { function db() { } @@ -35,6 +36,7 @@ var db = (function () { exports.db = db; //// [service.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var db = require("./db"); function someDecorator(target) { return target; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js index 33eb93f380f..7d78cf7adbe 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js @@ -25,6 +25,7 @@ export {MyClass}; //// [db.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var db = (function () { function db() { } @@ -35,6 +36,7 @@ var db = (function () { exports.db = db; //// [service.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var db_1 = require("./db"); // error no default export function someDecorator(target) { return target; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js index b99621fd7e2..3f7069902ce 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js @@ -25,6 +25,7 @@ export {MyClass}; //// [db.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var db = (function () { function db() { } @@ -32,10 +33,10 @@ var db = (function () { }; return db; }()); -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = db; //// [service.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var db_1 = require("./db"); function someDecorator(target) { return target; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js index 4970dca3201..66eb30dc710 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js @@ -25,6 +25,7 @@ export {MyClass}; //// [db.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var db = (function () { function db() { } @@ -32,10 +33,10 @@ var db = (function () { }; return db; }()); -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = db; //// [service.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var db_1 = require("./db"); function someDecorator(target) { return target; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js index 28d403044bb..1dd09c3a177 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js @@ -25,6 +25,7 @@ export {MyClass}; //// [db.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var db = (function () { function db() { } @@ -32,10 +33,10 @@ var db = (function () { }; return db; }()); -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = db; //// [service.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var db_1 = require("./db"); function someDecorator(target) { return target; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js index dd5cee66f8b..830e6bc80ee 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js @@ -25,6 +25,7 @@ export {MyClass}; //// [db.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var db = (function () { function db() { } @@ -35,6 +36,7 @@ var db = (function () { exports.db = db; //// [service.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var database = require("./db"); function someDecorator(target) { return target; diff --git a/tests/baselines/reference/decoratorOnClass2.js b/tests/baselines/reference/decoratorOnClass2.js index 4d9c2007ad0..77020e7cb77 100644 --- a/tests/baselines/reference/decoratorOnClass2.js +++ b/tests/baselines/reference/decoratorOnClass2.js @@ -13,6 +13,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, 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; return c > 3 && r && Object.defineProperty(target, key, r), r; }; +Object.defineProperty(exports, "__esModule", { value: true }); var C = (function () { function C() { } diff --git a/tests/baselines/reference/decoratorOnClassConstructor2.js b/tests/baselines/reference/decoratorOnClassConstructor2.js index ce323e8ed1e..2af3b0426dc 100644 --- a/tests/baselines/reference/decoratorOnClassConstructor2.js +++ b/tests/baselines/reference/decoratorOnClassConstructor2.js @@ -16,6 +16,7 @@ export class C extends base{ //// [0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var base = (function () { function base() { } @@ -26,11 +27,16 @@ function foo(target, propertyKey, parameterIndex) { } exports.foo = foo; //// [2.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); @@ -40,6 +46,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; +Object.defineProperty(exports, "__esModule", { value: true }); var _0_ts_1 = require("./0.ts"); var _0_ts_2 = require("./0.ts"); var C = (function (_super) { diff --git a/tests/baselines/reference/decoratorOnClassConstructor3.js b/tests/baselines/reference/decoratorOnClassConstructor3.js index f06bf80b21d..4ed401284a9 100644 --- a/tests/baselines/reference/decoratorOnClassConstructor3.js +++ b/tests/baselines/reference/decoratorOnClassConstructor3.js @@ -18,6 +18,7 @@ export class C extends base{ //// [0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var base = (function () { function base() { } @@ -28,11 +29,16 @@ function foo(target, propertyKey, parameterIndex) { } exports.foo = foo; //// [2.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); @@ -42,6 +48,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; +Object.defineProperty(exports, "__esModule", { value: true }); var _0_1 = require("./0"); var _0_2 = require("./0"); /* Comment on the Class Declaration */ diff --git a/tests/baselines/reference/decoratorOnClassConstructor4.js b/tests/baselines/reference/decoratorOnClassConstructor4.js index 22414e89e43..75286943417 100644 --- a/tests/baselines/reference/decoratorOnClassConstructor4.js +++ b/tests/baselines/reference/decoratorOnClassConstructor4.js @@ -15,11 +15,16 @@ class C extends A { } //// [decoratorOnClassConstructor4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); @@ -49,7 +54,7 @@ B = __decorate([ var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/decoratorOnClassMethod12.js b/tests/baselines/reference/decoratorOnClassMethod12.js index 7dd5f698182..c9ff30307f0 100644 --- a/tests/baselines/reference/decoratorOnClassMethod12.js +++ b/tests/baselines/reference/decoratorOnClassMethod12.js @@ -10,11 +10,16 @@ module M { } //// [decoratorOnClassMethod12.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); @@ -32,7 +37,7 @@ var M; var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.method = function () { }; return C; diff --git a/tests/baselines/reference/decoratorOnImportEquals2.js b/tests/baselines/reference/decoratorOnImportEquals2.js index 5e6b6b4a623..aa8273699e3 100644 --- a/tests/baselines/reference/decoratorOnImportEquals2.js +++ b/tests/baselines/reference/decoratorOnImportEquals2.js @@ -11,5 +11,7 @@ declare function dec(target: T): T; //// [decoratorOnImportEquals2_0.js] "use strict"; +exports.__esModule = true; //// [decoratorOnImportEquals2_1.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/decrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt b/tests/baselines/reference/decrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt index e42b6ff67b4..33e31bc9478 100644 --- a/tests/baselines/reference/decrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt +++ b/tests/baselines/reference/decrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt @@ -9,29 +9,37 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(33,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(34,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(37,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(39,26): error TS2539: Cannot assign to 'undefined' because it is not a variable. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(42,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(43,24): error TS2539: Cannot assign to 'undefined' because it is not a variable. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(46,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(47,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,34): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,34): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,39): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(51,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(52,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(54,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(55,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,32): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,32): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,37): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(59,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(60,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(63,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -50,7 +58,7 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(72,12): error TS1109: Expression expected. -==== tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts (50 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts (58 errors) ==== // -- operator on any type var ANY1: any; var ANY2: any[] = ["", ""]; @@ -112,14 +120,18 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. var ResultIsNumber12 = --null; ~~~~ -!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber13 = --undefined; ~~~~~~~~~ !!! error TS2539: Cannot assign to 'undefined' because it is not a variable. var ResultIsNumber14 = null--; ~~~~ -!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber15 = {}--; ~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -137,18 +149,24 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp var ResultIsNumber19 = --(null + undefined); ~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber20 = --(null + null); ~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber21 = --(undefined + undefined); ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber22 = --obj1.x; ~~~~~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -165,18 +183,24 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp var ResultIsNumber26 = (null + undefined)--; ~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber27 = (null + null)--; ~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber28 = (undefined + undefined)--; ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber29 = obj1.x--; ~~~~~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. diff --git a/tests/baselines/reference/defaultExportInAwaitExpression01.js b/tests/baselines/reference/defaultExportInAwaitExpression01.js index 66d100ad07d..6a31461fe3c 100644 --- a/tests/baselines/reference/defaultExportInAwaitExpression01.js +++ b/tests/baselines/reference/defaultExportInAwaitExpression01.js @@ -23,8 +23,8 @@ import x from './a'; } })(function (require, exports) { "use strict"; - const x = new Promise((resolve, reject) => { resolve({}); }); Object.defineProperty(exports, "__esModule", { value: true }); + const x = new Promise((resolve, reject) => { resolve({}); }); exports.default = x; }); //// [b.js] @@ -46,6 +46,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } })(function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); const a_1 = require("./a"); (function () { return __awaiter(this, void 0, void 0, function* () { diff --git a/tests/baselines/reference/defaultExportInAwaitExpression01.symbols b/tests/baselines/reference/defaultExportInAwaitExpression01.symbols index eb833f63895..9b77ee1a68b 100644 --- a/tests/baselines/reference/defaultExportInAwaitExpression01.symbols +++ b/tests/baselines/reference/defaultExportInAwaitExpression01.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/modules/a.ts === const x = new Promise( ( resolve, reject ) => { resolve( {} ); } ); >x : Symbol(x, Decl(a.ts, 0, 5)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(resolve, Decl(a.ts, 0, 24)) >reject : Symbol(reject, Decl(a.ts, 0, 33)) >resolve : Symbol(resolve, Decl(a.ts, 0, 24)) diff --git a/tests/baselines/reference/defaultExportInAwaitExpression02.js b/tests/baselines/reference/defaultExportInAwaitExpression02.js index 8499164f675..565cfb41617 100644 --- a/tests/baselines/reference/defaultExportInAwaitExpression02.js +++ b/tests/baselines/reference/defaultExportInAwaitExpression02.js @@ -14,8 +14,8 @@ import x from './a'; //// [a.js] "use strict"; -const x = new Promise((resolve, reject) => { resolve({}); }); Object.defineProperty(exports, "__esModule", { value: true }); +const x = new Promise((resolve, reject) => { resolve({}); }); exports.default = x; //// [b.js] "use strict"; @@ -27,6 +27,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; +Object.defineProperty(exports, "__esModule", { value: true }); const a_1 = require("./a"); (function () { return __awaiter(this, void 0, void 0, function* () { diff --git a/tests/baselines/reference/defaultExportInAwaitExpression02.symbols b/tests/baselines/reference/defaultExportInAwaitExpression02.symbols index eb833f63895..9b77ee1a68b 100644 --- a/tests/baselines/reference/defaultExportInAwaitExpression02.symbols +++ b/tests/baselines/reference/defaultExportInAwaitExpression02.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/modules/a.ts === const x = new Promise( ( resolve, reject ) => { resolve( {} ); } ); >x : Symbol(x, Decl(a.ts, 0, 5)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(resolve, Decl(a.ts, 0, 24)) >reject : Symbol(reject, Decl(a.ts, 0, 33)) >resolve : Symbol(resolve, Decl(a.ts, 0, 24)) diff --git a/tests/baselines/reference/defaultExportWithOverloads01.js b/tests/baselines/reference/defaultExportWithOverloads01.js index 770b685378d..a273b891679 100644 --- a/tests/baselines/reference/defaultExportWithOverloads01.js +++ b/tests/baselines/reference/defaultExportWithOverloads01.js @@ -7,11 +7,11 @@ export default function f(...args: any[]) { //// [defaultExportWithOverloads01.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); function f() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } } -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = f; diff --git a/tests/baselines/reference/defaultExportsCannotMerge01.js b/tests/baselines/reference/defaultExportsCannotMerge01.js index 24a37cad2c3..aaadfaefebb 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge01.js +++ b/tests/baselines/reference/defaultExportsCannotMerge01.js @@ -32,10 +32,10 @@ Entity.y; //// [m1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); function Decl() { return 0; } -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Decl; var Decl; (function (Decl) { @@ -44,6 +44,7 @@ var Decl; })(Decl = exports.Decl || (exports.Decl = {})); //// [m2.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var m1_1 = require("m1"); m1_1.default(); var x; diff --git a/tests/baselines/reference/defaultExportsCannotMerge02.js b/tests/baselines/reference/defaultExportsCannotMerge02.js index f327c62e571..b83d54548ca 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge02.js +++ b/tests/baselines/reference/defaultExportsCannotMerge02.js @@ -27,15 +27,16 @@ var sum = z.p1 + z.p2 //// [m1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var Decl = (function () { function Decl() { } return Decl; }()); -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Decl; //// [m2.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var m1_1 = require("m1"); m1_1.default(); var x; diff --git a/tests/baselines/reference/defaultExportsCannotMerge03.js b/tests/baselines/reference/defaultExportsCannotMerge03.js index 4369392c6e9..254723ec5f1 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge03.js +++ b/tests/baselines/reference/defaultExportsCannotMerge03.js @@ -27,15 +27,16 @@ var sum = z.p1 + z.p2 //// [m1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var Decl = (function () { function Decl() { } return Decl; }()); -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Decl; //// [m2.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var m1_1 = require("m1"); m1_1.default(); var x; diff --git a/tests/baselines/reference/defaultExportsCannotMerge04.js b/tests/baselines/reference/defaultExportsCannotMerge04.js index 7c9bd88bc16..38ab4861c62 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge04.js +++ b/tests/baselines/reference/defaultExportsCannotMerge04.js @@ -15,9 +15,9 @@ export interface Foo { //// [defaultExportsCannotMerge04.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); function Foo() { } -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Foo; var Foo; (function (Foo) { diff --git a/tests/baselines/reference/defaultExportsGetExportedAmd.js b/tests/baselines/reference/defaultExportsGetExportedAmd.js index fc0385254c0..c5037364b00 100644 --- a/tests/baselines/reference/defaultExportsGetExportedAmd.js +++ b/tests/baselines/reference/defaultExportsGetExportedAmd.js @@ -10,15 +10,15 @@ export default function foo() {} //// [a.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); class Foo { } - Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Foo; }); //// [b.js] define(["require", "exports"], function (require, exports) { "use strict"; - function foo() { } Object.defineProperty(exports, "__esModule", { value: true }); + function foo() { } exports.default = foo; }); diff --git a/tests/baselines/reference/defaultExportsGetExportedCommonjs.js b/tests/baselines/reference/defaultExportsGetExportedCommonjs.js index 1290404099d..051ab7bbf03 100644 --- a/tests/baselines/reference/defaultExportsGetExportedCommonjs.js +++ b/tests/baselines/reference/defaultExportsGetExportedCommonjs.js @@ -9,12 +9,12 @@ export default function foo() {} //// [a.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); class Foo { } -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Foo; //// [b.js] "use strict"; -function foo() { } Object.defineProperty(exports, "__esModule", { value: true }); +function foo() { } exports.default = foo; diff --git a/tests/baselines/reference/defaultExportsGetExportedUmd.js b/tests/baselines/reference/defaultExportsGetExportedUmd.js index 71aa347ce32..5417b9b9a96 100644 --- a/tests/baselines/reference/defaultExportsGetExportedUmd.js +++ b/tests/baselines/reference/defaultExportsGetExportedUmd.js @@ -18,9 +18,9 @@ export default function foo() {} } })(function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); class Foo { } - Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Foo; }); //// [b.js] @@ -34,7 +34,7 @@ export default function foo() {} } })(function (require, exports) { "use strict"; - function foo() { } Object.defineProperty(exports, "__esModule", { value: true }); + function foo() { } exports.default = foo; }); diff --git a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.js b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.js new file mode 100644 index 00000000000..329c2fb19ce --- /dev/null +++ b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.js @@ -0,0 +1,112 @@ +//// [defaultParameterAddsUndefinedWithStrictNullChecks.ts] +function f(addUndefined1 = "J", addUndefined2?: number) { + return addUndefined1.length + (addUndefined2 || 0); +} +function g(addUndefined = "J", addDefined: number) { + return addUndefined.length + addDefined; +} +let total = f() + f('a', 1) + f('b') + f(undefined, 2); +total = g('c', 3) + g(undefined, 4); + +function foo1(x: string = "string", b: number) { + x.length; +} + +function foo2(x = "string", b: number) { + x.length; // ok, should be string +} + +function foo3(x: string | undefined = "string", b: number) { + x.length; // ok, should be string +} + +function foo4(x: string | undefined = undefined, b: number) { + x; // should be string | undefined +} + + + +// .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4 +foo1(undefined, 1); +foo2(undefined, 1); +foo3(undefined, 1); +foo4(undefined, 1); + + +function removeUndefinedButNotFalse(x = true) { + if (x === false) { + return x; + } +} + +declare const cond: boolean; +function removeNothing(y = cond ? true : undefined) { + if (y !== undefined) { + if (y === false) { + return y; + } + } + return true; +} + + +//// [defaultParameterAddsUndefinedWithStrictNullChecks.js] +function f(addUndefined1, addUndefined2) { + if (addUndefined1 === void 0) { addUndefined1 = "J"; } + return addUndefined1.length + (addUndefined2 || 0); +} +function g(addUndefined, addDefined) { + if (addUndefined === void 0) { addUndefined = "J"; } + return addUndefined.length + addDefined; +} +var total = f() + f('a', 1) + f('b') + f(undefined, 2); +total = g('c', 3) + g(undefined, 4); +function foo1(x, b) { + if (x === void 0) { x = "string"; } + x.length; +} +function foo2(x, b) { + if (x === void 0) { x = "string"; } + x.length; // ok, should be string +} +function foo3(x, b) { + if (x === void 0) { x = "string"; } + x.length; // ok, should be string +} +function foo4(x, b) { + if (x === void 0) { x = undefined; } + x; // should be string | undefined +} +// .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4 +foo1(undefined, 1); +foo2(undefined, 1); +foo3(undefined, 1); +foo4(undefined, 1); +function removeUndefinedButNotFalse(x) { + if (x === void 0) { x = true; } + if (x === false) { + return x; + } +} +function removeNothing(y) { + if (y === void 0) { y = cond ? true : undefined; } + if (y !== undefined) { + if (y === false) { + return y; + } + } + return true; +} + + +//// [defaultParameterAddsUndefinedWithStrictNullChecks.d.ts] +declare function f(addUndefined1?: string, addUndefined2?: number): number; +declare function g(addUndefined: string | undefined, addDefined: number): number; +declare let total: number; +declare function foo1(x: string | undefined, b: number): void; +declare function foo2(x: string | undefined, b: number): void; +declare function foo3(x: string | undefined, b: number): void; +declare function foo4(x: string | undefined, b: number): void; +declare function removeUndefinedButNotFalse(x?: boolean): false | undefined; +declare const cond: boolean; +declare function removeNothing(y?: boolean | undefined): boolean; diff --git a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.symbols b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.symbols new file mode 100644 index 00000000000..fb0fce7dc7f --- /dev/null +++ b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.symbols @@ -0,0 +1,135 @@ +=== tests/cases/compiler/defaultParameterAddsUndefinedWithStrictNullChecks.ts === +function f(addUndefined1 = "J", addUndefined2?: number) { +>f : Symbol(f, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 0, 0)) +>addUndefined1 : Symbol(addUndefined1, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 0, 11)) +>addUndefined2 : Symbol(addUndefined2, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 0, 31)) + + return addUndefined1.length + (addUndefined2 || 0); +>addUndefined1.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>addUndefined1 : Symbol(addUndefined1, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 0, 11)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>addUndefined2 : Symbol(addUndefined2, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 0, 31)) +} +function g(addUndefined = "J", addDefined: number) { +>g : Symbol(g, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 2, 1)) +>addUndefined : Symbol(addUndefined, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 3, 11)) +>addDefined : Symbol(addDefined, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 3, 30)) + + return addUndefined.length + addDefined; +>addUndefined.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>addUndefined : Symbol(addUndefined, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 3, 11)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>addDefined : Symbol(addDefined, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 3, 30)) +} +let total = f() + f('a', 1) + f('b') + f(undefined, 2); +>total : Symbol(total, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 6, 3)) +>f : Symbol(f, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 0, 0)) +>f : Symbol(f, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 0, 0)) +>f : Symbol(f, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 0, 0)) +>f : Symbol(f, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 0, 0)) +>undefined : Symbol(undefined) + +total = g('c', 3) + g(undefined, 4); +>total : Symbol(total, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 6, 3)) +>g : Symbol(g, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 2, 1)) +>g : Symbol(g, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 2, 1)) +>undefined : Symbol(undefined) + +function foo1(x: string = "string", b: number) { +>foo1 : Symbol(foo1, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 7, 36)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 9, 14)) +>b : Symbol(b, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 9, 35)) + + x.length; +>x.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 9, 14)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) +} + +function foo2(x = "string", b: number) { +>foo2 : Symbol(foo2, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 11, 1)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 13, 14)) +>b : Symbol(b, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 13, 27)) + + x.length; // ok, should be string +>x.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 13, 14)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) +} + +function foo3(x: string | undefined = "string", b: number) { +>foo3 : Symbol(foo3, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 15, 1)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 17, 14)) +>b : Symbol(b, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 17, 47)) + + x.length; // ok, should be string +>x.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 17, 14)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) +} + +function foo4(x: string | undefined = undefined, b: number) { +>foo4 : Symbol(foo4, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 19, 1)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 21, 14)) +>undefined : Symbol(undefined) +>b : Symbol(b, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 21, 48)) + + x; // should be string | undefined +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 21, 14)) +} + + + +// .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4 +foo1(undefined, 1); +>foo1 : Symbol(foo1, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 7, 36)) +>undefined : Symbol(undefined) + +foo2(undefined, 1); +>foo2 : Symbol(foo2, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 11, 1)) +>undefined : Symbol(undefined) + +foo3(undefined, 1); +>foo3 : Symbol(foo3, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 15, 1)) +>undefined : Symbol(undefined) + +foo4(undefined, 1); +>foo4 : Symbol(foo4, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 19, 1)) +>undefined : Symbol(undefined) + + +function removeUndefinedButNotFalse(x = true) { +>removeUndefinedButNotFalse : Symbol(removeUndefinedButNotFalse, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 31, 19)) +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 34, 36)) + + if (x === false) { +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 34, 36)) + + return x; +>x : Symbol(x, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 34, 36)) + } +} + +declare const cond: boolean; +>cond : Symbol(cond, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 40, 13)) + +function removeNothing(y = cond ? true : undefined) { +>removeNothing : Symbol(removeNothing, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 40, 28)) +>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 41, 23)) +>cond : Symbol(cond, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 40, 13)) +>undefined : Symbol(undefined) + + if (y !== undefined) { +>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 41, 23)) +>undefined : Symbol(undefined) + + if (y === false) { +>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 41, 23)) + + return y; +>y : Symbol(y, Decl(defaultParameterAddsUndefinedWithStrictNullChecks.ts, 41, 23)) + } + } + return true; +} + diff --git a/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types new file mode 100644 index 00000000000..d95f9259891 --- /dev/null +++ b/tests/baselines/reference/defaultParameterAddsUndefinedWithStrictNullChecks.types @@ -0,0 +1,180 @@ +=== tests/cases/compiler/defaultParameterAddsUndefinedWithStrictNullChecks.ts === +function f(addUndefined1 = "J", addUndefined2?: number) { +>f : (addUndefined1?: string, addUndefined2?: number | undefined) => number +>addUndefined1 : string +>"J" : "J" +>addUndefined2 : number | undefined + + return addUndefined1.length + (addUndefined2 || 0); +>addUndefined1.length + (addUndefined2 || 0) : number +>addUndefined1.length : number +>addUndefined1 : string +>length : number +>(addUndefined2 || 0) : number +>addUndefined2 || 0 : number +>addUndefined2 : number | undefined +>0 : 0 +} +function g(addUndefined = "J", addDefined: number) { +>g : (addUndefined: string | undefined, addDefined: number) => number +>addUndefined : string +>"J" : "J" +>addDefined : number + + return addUndefined.length + addDefined; +>addUndefined.length + addDefined : number +>addUndefined.length : number +>addUndefined : string +>length : number +>addDefined : number +} +let total = f() + f('a', 1) + f('b') + f(undefined, 2); +>total : number +>f() + f('a', 1) + f('b') + f(undefined, 2) : number +>f() + f('a', 1) + f('b') : number +>f() + f('a', 1) : number +>f() : number +>f : (addUndefined1?: string, addUndefined2?: number | undefined) => number +>f('a', 1) : number +>f : (addUndefined1?: string, addUndefined2?: number | undefined) => number +>'a' : "a" +>1 : 1 +>f('b') : number +>f : (addUndefined1?: string, addUndefined2?: number | undefined) => number +>'b' : "b" +>f(undefined, 2) : number +>f : (addUndefined1?: string, addUndefined2?: number | undefined) => number +>undefined : undefined +>2 : 2 + +total = g('c', 3) + g(undefined, 4); +>total = g('c', 3) + g(undefined, 4) : number +>total : number +>g('c', 3) + g(undefined, 4) : number +>g('c', 3) : number +>g : (addUndefined: string | undefined, addDefined: number) => number +>'c' : "c" +>3 : 3 +>g(undefined, 4) : number +>g : (addUndefined: string | undefined, addDefined: number) => number +>undefined : undefined +>4 : 4 + +function foo1(x: string = "string", b: number) { +>foo1 : (x: string | undefined, b: number) => void +>x : string +>"string" : "string" +>b : number + + x.length; +>x.length : number +>x : string +>length : number +} + +function foo2(x = "string", b: number) { +>foo2 : (x: string | undefined, b: number) => void +>x : string +>"string" : "string" +>b : number + + x.length; // ok, should be string +>x.length : number +>x : string +>length : number +} + +function foo3(x: string | undefined = "string", b: number) { +>foo3 : (x: string | undefined, b: number) => void +>x : string +>"string" : "string" +>b : number + + x.length; // ok, should be string +>x.length : number +>x : string +>length : number +} + +function foo4(x: string | undefined = undefined, b: number) { +>foo4 : (x: string | undefined, b: number) => void +>x : string | undefined +>undefined : undefined +>b : number + + x; // should be string | undefined +>x : string | undefined +} + + + +// .d.ts should have `string | undefined` for foo1, foo2, foo3 and foo4 +foo1(undefined, 1); +>foo1(undefined, 1) : void +>foo1 : (x: string | undefined, b: number) => void +>undefined : undefined +>1 : 1 + +foo2(undefined, 1); +>foo2(undefined, 1) : void +>foo2 : (x: string | undefined, b: number) => void +>undefined : undefined +>1 : 1 + +foo3(undefined, 1); +>foo3(undefined, 1) : void +>foo3 : (x: string | undefined, b: number) => void +>undefined : undefined +>1 : 1 + +foo4(undefined, 1); +>foo4(undefined, 1) : void +>foo4 : (x: string | undefined, b: number) => void +>undefined : undefined +>1 : 1 + + +function removeUndefinedButNotFalse(x = true) { +>removeUndefinedButNotFalse : (x?: boolean) => false | undefined +>x : boolean +>true : true + + if (x === false) { +>x === false : boolean +>x : boolean +>false : false + + return x; +>x : false + } +} + +declare const cond: boolean; +>cond : boolean + +function removeNothing(y = cond ? true : undefined) { +>removeNothing : (y?: boolean | undefined) => boolean +>y : boolean | undefined +>cond ? true : undefined : true | undefined +>cond : boolean +>true : true +>undefined : undefined + + if (y !== undefined) { +>y !== undefined : boolean +>y : boolean | undefined +>undefined : undefined + + if (y === false) { +>y === false : boolean +>y : boolean +>false : false + + return y; +>y : false + } + } + return true; +>true : true +} + diff --git a/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt index 69153fc235c..819f1c39050 100644 --- a/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt @@ -9,12 +9,15 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(42,32): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(43,32): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(44,33): error TS2703: The operand of a delete operator must be a property reference -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,33): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,33): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,33): error TS2703: The operand of a delete operator must be a property reference -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,33): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,40): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,33): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,33): error TS2703: The operand of a delete operator must be a property reference -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,33): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,40): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,33): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,33): error TS2703: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,45): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(50,32): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(50,39): error TS2703: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,32): error TS2703: The operand of a delete operator must be a property reference @@ -25,7 +28,7 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(57,8): error TS2703: The operand of a delete operator must be a property reference -==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts (25 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts (28 errors) ==== // delete operator on any type var ANY: any; @@ -93,20 +96,26 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator ~~~~~~~~~~ !!! error TS2703: The operand of a delete operator must be a property reference var ResultIsBoolean17 = delete (null + undefined); - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~~~~~~~~ !!! error TS2703: The operand of a delete operator must be a property reference + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsBoolean18 = delete (null + null); - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~~~ !!! error TS2703: The operand of a delete operator must be a property reference + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsBoolean19 = delete (undefined + undefined); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2703: The operand of a delete operator must be a property reference + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // multiple delete operators var ResultIsBoolean20 = delete delete ANY; diff --git a/tests/baselines/reference/dependencyViaImportAlias.js b/tests/baselines/reference/dependencyViaImportAlias.js index 8e12bb9bd2c..285cfbcda16 100644 --- a/tests/baselines/reference/dependencyViaImportAlias.js +++ b/tests/baselines/reference/dependencyViaImportAlias.js @@ -13,6 +13,7 @@ export = A; //// [A.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var A = (function () { function A() { } diff --git a/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.js b/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.js index 4ab447d8e32..a1e9399c563 100644 --- a/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.js +++ b/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.js @@ -35,11 +35,16 @@ class D extends C { } //// [derivedClassConstructorWithExplicitReturns01.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C(value) { this.cProp = 10; diff --git a/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.js.map b/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.js.map index 8b9037e40c9..f2acf9427cf 100644 --- a/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.js.map +++ b/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.js.map @@ -1,2 +1,2 @@ //// [derivedClassConstructorWithExplicitReturns01.js.map] -{"version":3,"file":"derivedClassConstructorWithExplicitReturns01.js","sourceRoot":"","sources":["derivedClassConstructorWithExplicitReturns01.ts"],"names":[],"mappings":";;;;;AACA;IAKI,WAAY,KAAa;QAJzB,UAAK,GAAG,EAAE,CAAC;QAKP,MAAM,CAAC;YACH,KAAK,EAAE,KAAK;YACZ,GAAG;gBACC,MAAM,CAAC,8BAA8B,CAAC;YAC1C,CAAC;SACJ,CAAA;IACL,CAAC;IATD,eAAG,GAAH,cAAQ,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC;IAU7C,QAAC;AAAD,CAAC,AAbD,IAaC;AAED;IAAgB,qBAAC;IAGb,WAAY,CAAO;QAAP,kBAAA,EAAA,OAAO;QAAnB,YACI,kBAAM,CAAC,CAAC,SAYX;QAfD,WAAK,GAAG,cAAM,OAAA,KAAI,EAAJ,CAAI,CAAC;QAKf,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;YACtB,UAAU,CAAA;YACV,MAAM,CAAC;gBACH,KAAK,EAAE,CAAC;gBACR,KAAK,EAAE,cAAM,OAAA,KAAI,EAAJ,CAAI;gBACjB,GAAG,gBAAK,MAAM,CAAC,cAAc,CAAA,CAAC,CAAC;aAClC,CAAC;QACN,CAAC;QACD,IAAI;YACA,MAAM,CAAC,IAAI,CAAC;IACpB,CAAC;IACL,QAAC;AAAD,CAAC,AAjBD,CAAgB,CAAC,GAiBhB"} \ No newline at end of file +{"version":3,"file":"derivedClassConstructorWithExplicitReturns01.js","sourceRoot":"","sources":["derivedClassConstructorWithExplicitReturns01.ts"],"names":[],"mappings":";;;;;;;;;;AACA;IAKI,WAAY,KAAa;QAJzB,UAAK,GAAG,EAAE,CAAC;QAKP,MAAM,CAAC;YACH,KAAK,EAAE,KAAK;YACZ,GAAG;gBACC,MAAM,CAAC,8BAA8B,CAAC;YAC1C,CAAC;SACJ,CAAA;IACL,CAAC;IATD,eAAG,GAAH,cAAQ,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC;IAU7C,QAAC;AAAD,CAAC,AAbD,IAaC;AAED;IAAgB,qBAAC;IAGb,WAAY,CAAO;QAAP,kBAAA,EAAA,OAAO;QAAnB,YACI,kBAAM,CAAC,CAAC,SAYX;QAfD,WAAK,GAAG,cAAM,OAAA,KAAI,EAAJ,CAAI,CAAC;QAKf,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;YACtB,UAAU,CAAA;YACV,MAAM,CAAC;gBACH,KAAK,EAAE,CAAC;gBACR,KAAK,EAAE,cAAM,OAAA,KAAI,EAAJ,CAAI;gBACjB,GAAG,gBAAK,MAAM,CAAC,cAAc,CAAA,CAAC,CAAC;aAClC,CAAC;QACN,CAAC;QACD,IAAI;YACA,MAAM,CAAC,IAAI,CAAC;IACpB,CAAC;IACL,QAAC;AAAD,CAAC,AAjBD,CAAgB,CAAC,GAiBhB"} \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.sourcemap.txt b/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.sourcemap.txt index d452115ceb7..42d415430e2 100644 --- a/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.sourcemap.txt +++ b/tests/baselines/reference/derivedClassConstructorWithExplicitReturns01.sourcemap.txt @@ -8,17 +8,22 @@ sources: derivedClassConstructorWithExplicitReturns01.ts emittedFile:tests/cases/compiler/derivedClassConstructorWithExplicitReturns01.js sourceFile:derivedClassConstructorWithExplicitReturns01.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 __extends = (this && this.__extends) || (function () { +>>> var extendStatics = Object.setPrototypeOf || +>>> ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || +>>> function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; +>>> return function (d, b) { +>>> extendStatics(d, b); +>>> function __() { this.constructor = d; } +>>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +>>> }; +>>>})(); >>>var C = (function () { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(6, 1) Source(2, 1) + SourceIndex(0) +1 >Emitted(11, 1) Source(2, 1) + SourceIndex(0) --- >>> function C(value) { 1->^^^^ @@ -33,9 +38,9 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts > 2 > constructor( 3 > value: number -1->Emitted(7, 5) Source(7, 5) + SourceIndex(0) -2 >Emitted(7, 16) Source(7, 17) + SourceIndex(0) -3 >Emitted(7, 21) Source(7, 30) + SourceIndex(0) +1->Emitted(12, 5) Source(7, 5) + SourceIndex(0) +2 >Emitted(12, 16) Source(7, 17) + SourceIndex(0) +3 >Emitted(12, 21) Source(7, 30) + SourceIndex(0) --- >>> this.cProp = 10; 1->^^^^^^^^ @@ -48,11 +53,11 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 3 > = 4 > 10 5 > ; -1->Emitted(8, 9) Source(3, 5) + SourceIndex(0) -2 >Emitted(8, 19) Source(3, 10) + SourceIndex(0) -3 >Emitted(8, 22) Source(3, 13) + SourceIndex(0) -4 >Emitted(8, 24) Source(3, 15) + SourceIndex(0) -5 >Emitted(8, 25) Source(3, 16) + SourceIndex(0) +1->Emitted(13, 9) Source(3, 5) + SourceIndex(0) +2 >Emitted(13, 19) Source(3, 10) + SourceIndex(0) +3 >Emitted(13, 22) Source(3, 13) + SourceIndex(0) +4 >Emitted(13, 24) Source(3, 15) + SourceIndex(0) +5 >Emitted(13, 25) Source(3, 16) + SourceIndex(0) --- >>> return { 1 >^^^^^^^^ @@ -67,9 +72,9 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts > 2 > return 3 > -1 >Emitted(9, 9) Source(8, 9) + SourceIndex(0) -2 >Emitted(9, 15) Source(8, 15) + SourceIndex(0) -3 >Emitted(9, 16) Source(8, 16) + SourceIndex(0) +1 >Emitted(14, 9) Source(8, 9) + SourceIndex(0) +2 >Emitted(14, 15) Source(8, 15) + SourceIndex(0) +3 >Emitted(14, 16) Source(8, 16) + SourceIndex(0) --- >>> cProp: value, 1->^^^^^^^^^^^^ @@ -82,10 +87,10 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 2 > cProp 3 > : 4 > value -1->Emitted(10, 13) Source(9, 13) + SourceIndex(0) -2 >Emitted(10, 18) Source(9, 18) + SourceIndex(0) -3 >Emitted(10, 20) Source(9, 20) + SourceIndex(0) -4 >Emitted(10, 25) Source(9, 25) + SourceIndex(0) +1->Emitted(15, 13) Source(9, 13) + SourceIndex(0) +2 >Emitted(15, 18) Source(9, 18) + SourceIndex(0) +3 >Emitted(15, 20) Source(9, 20) + SourceIndex(0) +4 >Emitted(15, 25) Source(9, 25) + SourceIndex(0) --- >>> foo: function () { 1->^^^^^^^^^^^^ @@ -94,8 +99,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1->, > 2 > foo -1->Emitted(11, 13) Source(10, 13) + SourceIndex(0) -2 >Emitted(11, 16) Source(10, 16) + SourceIndex(0) +1->Emitted(16, 13) Source(10, 13) + SourceIndex(0) +2 >Emitted(16, 16) Source(10, 16) + SourceIndex(0) --- >>> return "well this looks kinda C-ish."; 1->^^^^^^^^^^^^^^^^ @@ -109,11 +114,11 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 3 > 4 > "well this looks kinda C-ish." 5 > ; -1->Emitted(12, 17) Source(11, 17) + SourceIndex(0) -2 >Emitted(12, 23) Source(11, 23) + SourceIndex(0) -3 >Emitted(12, 24) Source(11, 24) + SourceIndex(0) -4 >Emitted(12, 54) Source(11, 54) + SourceIndex(0) -5 >Emitted(12, 55) Source(11, 55) + SourceIndex(0) +1->Emitted(17, 17) Source(11, 17) + SourceIndex(0) +2 >Emitted(17, 23) Source(11, 23) + SourceIndex(0) +3 >Emitted(17, 24) Source(11, 24) + SourceIndex(0) +4 >Emitted(17, 54) Source(11, 54) + SourceIndex(0) +5 >Emitted(17, 55) Source(11, 55) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^ @@ -121,8 +126,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1 > > 2 > } -1 >Emitted(13, 13) Source(12, 13) + SourceIndex(0) -2 >Emitted(13, 14) Source(12, 14) + SourceIndex(0) +1 >Emitted(18, 13) Source(12, 13) + SourceIndex(0) +2 >Emitted(18, 14) Source(12, 14) + SourceIndex(0) --- >>> }; 1 >^^^^^^^^^ @@ -130,8 +135,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1 > > } 2 > -1 >Emitted(14, 10) Source(13, 10) + SourceIndex(0) -2 >Emitted(14, 11) Source(13, 10) + SourceIndex(0) +1 >Emitted(19, 10) Source(13, 10) + SourceIndex(0) +2 >Emitted(19, 11) Source(13, 10) + SourceIndex(0) --- >>> } 1 >^^^^ @@ -140,8 +145,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1 > > 2 > } -1 >Emitted(15, 5) Source(14, 5) + SourceIndex(0) -2 >Emitted(15, 6) Source(14, 6) + SourceIndex(0) +1 >Emitted(20, 5) Source(14, 5) + SourceIndex(0) +2 >Emitted(20, 6) Source(14, 6) + SourceIndex(0) --- >>> C.prototype.foo = function () { return "this never gets used."; }; 1->^^^^ @@ -164,16 +169,16 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 8 > ; 9 > 10> } -1->Emitted(16, 5) Source(5, 5) + SourceIndex(0) -2 >Emitted(16, 20) Source(5, 8) + SourceIndex(0) -3 >Emitted(16, 23) Source(5, 5) + SourceIndex(0) -4 >Emitted(16, 37) Source(5, 13) + SourceIndex(0) -5 >Emitted(16, 43) Source(5, 19) + SourceIndex(0) -6 >Emitted(16, 44) Source(5, 20) + SourceIndex(0) -7 >Emitted(16, 67) Source(5, 43) + SourceIndex(0) -8 >Emitted(16, 68) Source(5, 44) + SourceIndex(0) -9 >Emitted(16, 69) Source(5, 45) + SourceIndex(0) -10>Emitted(16, 70) Source(5, 46) + SourceIndex(0) +1->Emitted(21, 5) Source(5, 5) + SourceIndex(0) +2 >Emitted(21, 20) Source(5, 8) + SourceIndex(0) +3 >Emitted(21, 23) Source(5, 5) + SourceIndex(0) +4 >Emitted(21, 37) Source(5, 13) + SourceIndex(0) +5 >Emitted(21, 43) Source(5, 19) + SourceIndex(0) +6 >Emitted(21, 44) Source(5, 20) + SourceIndex(0) +7 >Emitted(21, 67) Source(5, 43) + SourceIndex(0) +8 >Emitted(21, 68) Source(5, 44) + SourceIndex(0) +9 >Emitted(21, 69) Source(5, 45) + SourceIndex(0) +10>Emitted(21, 70) Source(5, 46) + SourceIndex(0) --- >>> return C; 1 >^^^^ @@ -190,8 +195,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts > } > 2 > } -1 >Emitted(17, 5) Source(15, 1) + SourceIndex(0) -2 >Emitted(17, 13) Source(15, 2) + SourceIndex(0) +1 >Emitted(22, 5) Source(15, 1) + SourceIndex(0) +2 >Emitted(22, 13) Source(15, 2) + SourceIndex(0) --- >>>}()); 1 > @@ -216,10 +221,10 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts > } > } > } -1 >Emitted(18, 1) Source(15, 1) + SourceIndex(0) -2 >Emitted(18, 2) Source(15, 2) + SourceIndex(0) -3 >Emitted(18, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(18, 6) Source(15, 2) + SourceIndex(0) +1 >Emitted(23, 1) Source(15, 1) + SourceIndex(0) +2 >Emitted(23, 2) Source(15, 2) + SourceIndex(0) +3 >Emitted(23, 2) Source(2, 1) + SourceIndex(0) +4 >Emitted(23, 6) Source(15, 2) + SourceIndex(0) --- >>>var D = (function (_super) { 1-> @@ -227,15 +232,15 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1-> > > -1->Emitted(19, 1) Source(17, 1) + SourceIndex(0) +1->Emitted(24, 1) Source(17, 1) + SourceIndex(0) --- >>> __extends(D, _super); 1->^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^ 1->class D extends 2 > C -1->Emitted(20, 5) Source(17, 17) + SourceIndex(0) -2 >Emitted(20, 26) Source(17, 18) + SourceIndex(0) +1->Emitted(25, 5) Source(17, 17) + SourceIndex(0) +2 >Emitted(25, 26) Source(17, 18) + SourceIndex(0) --- >>> function D(a) { 1 >^^^^ @@ -248,9 +253,9 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts > 2 > constructor( 3 > a = 100 -1 >Emitted(21, 5) Source(20, 5) + SourceIndex(0) -2 >Emitted(21, 16) Source(20, 17) + SourceIndex(0) -3 >Emitted(21, 17) Source(20, 24) + SourceIndex(0) +1 >Emitted(26, 5) Source(20, 5) + SourceIndex(0) +2 >Emitted(26, 16) Source(20, 17) + SourceIndex(0) +3 >Emitted(26, 17) Source(20, 24) + SourceIndex(0) --- >>> if (a === void 0) { a = 100; } 1->^^^^^^^^ @@ -262,10 +267,10 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 2 > 3 > 4 > a = 100 -1->Emitted(22, 9) Source(20, 17) + SourceIndex(0) -2 >Emitted(22, 27) Source(20, 17) + SourceIndex(0) -3 >Emitted(22, 29) Source(20, 17) + SourceIndex(0) -4 >Emitted(22, 36) Source(20, 24) + SourceIndex(0) +1->Emitted(27, 9) Source(20, 17) + SourceIndex(0) +2 >Emitted(27, 27) Source(20, 17) + SourceIndex(0) +3 >Emitted(27, 29) Source(20, 17) + SourceIndex(0) +4 >Emitted(27, 36) Source(20, 24) + SourceIndex(0) --- >>> var _this = _super.call(this, a) || this; 1->^^^^^^^^ @@ -294,12 +299,12 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts > else > return null; > } -1->Emitted(23, 9) Source(20, 5) + SourceIndex(0) -2 >Emitted(23, 21) Source(21, 9) + SourceIndex(0) -3 >Emitted(23, 39) Source(21, 15) + SourceIndex(0) -4 >Emitted(23, 40) Source(21, 16) + SourceIndex(0) -5 >Emitted(23, 41) Source(21, 17) + SourceIndex(0) -6 >Emitted(23, 50) Source(33, 6) + SourceIndex(0) +1->Emitted(28, 9) Source(20, 5) + SourceIndex(0) +2 >Emitted(28, 21) Source(21, 9) + SourceIndex(0) +3 >Emitted(28, 39) Source(21, 15) + SourceIndex(0) +4 >Emitted(28, 40) Source(21, 16) + SourceIndex(0) +5 >Emitted(28, 41) Source(21, 17) + SourceIndex(0) +6 >Emitted(28, 50) Source(33, 6) + SourceIndex(0) --- >>> _this.dProp = function () { return _this; }; 1->^^^^^^^^ @@ -320,15 +325,15 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 7 > 8 > this 9 > ; -1->Emitted(24, 9) Source(18, 5) + SourceIndex(0) -2 >Emitted(24, 20) Source(18, 10) + SourceIndex(0) -3 >Emitted(24, 23) Source(18, 13) + SourceIndex(0) -4 >Emitted(24, 37) Source(18, 19) + SourceIndex(0) -5 >Emitted(24, 44) Source(18, 19) + SourceIndex(0) -6 >Emitted(24, 49) Source(18, 23) + SourceIndex(0) -7 >Emitted(24, 51) Source(18, 19) + SourceIndex(0) -8 >Emitted(24, 52) Source(18, 23) + SourceIndex(0) -9 >Emitted(24, 53) Source(18, 24) + SourceIndex(0) +1->Emitted(29, 9) Source(18, 5) + SourceIndex(0) +2 >Emitted(29, 20) Source(18, 10) + SourceIndex(0) +3 >Emitted(29, 23) Source(18, 13) + SourceIndex(0) +4 >Emitted(29, 37) Source(18, 19) + SourceIndex(0) +5 >Emitted(29, 44) Source(18, 19) + SourceIndex(0) +6 >Emitted(29, 49) Source(18, 23) + SourceIndex(0) +7 >Emitted(29, 51) Source(18, 19) + SourceIndex(0) +8 >Emitted(29, 52) Source(18, 23) + SourceIndex(0) +9 >Emitted(29, 53) Source(18, 24) + SourceIndex(0) --- >>> if (Math.random() < 0.5) { 1 >^^^^^^^^ @@ -362,19 +367,19 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 11> ) 12> 13> { -1 >Emitted(25, 9) Source(23, 9) + SourceIndex(0) -2 >Emitted(25, 11) Source(23, 11) + SourceIndex(0) -3 >Emitted(25, 12) Source(23, 12) + SourceIndex(0) -4 >Emitted(25, 13) Source(23, 13) + SourceIndex(0) -5 >Emitted(25, 17) Source(23, 17) + SourceIndex(0) -6 >Emitted(25, 18) Source(23, 18) + SourceIndex(0) -7 >Emitted(25, 24) Source(23, 24) + SourceIndex(0) -8 >Emitted(25, 26) Source(23, 26) + SourceIndex(0) -9 >Emitted(25, 29) Source(23, 29) + SourceIndex(0) -10>Emitted(25, 32) Source(23, 32) + SourceIndex(0) -11>Emitted(25, 33) Source(23, 33) + SourceIndex(0) -12>Emitted(25, 34) Source(23, 34) + SourceIndex(0) -13>Emitted(25, 35) Source(23, 35) + SourceIndex(0) +1 >Emitted(30, 9) Source(23, 9) + SourceIndex(0) +2 >Emitted(30, 11) Source(23, 11) + SourceIndex(0) +3 >Emitted(30, 12) Source(23, 12) + SourceIndex(0) +4 >Emitted(30, 13) Source(23, 13) + SourceIndex(0) +5 >Emitted(30, 17) Source(23, 17) + SourceIndex(0) +6 >Emitted(30, 18) Source(23, 18) + SourceIndex(0) +7 >Emitted(30, 24) Source(23, 24) + SourceIndex(0) +8 >Emitted(30, 26) Source(23, 26) + SourceIndex(0) +9 >Emitted(30, 29) Source(23, 29) + SourceIndex(0) +10>Emitted(30, 32) Source(23, 32) + SourceIndex(0) +11>Emitted(30, 33) Source(23, 33) + SourceIndex(0) +12>Emitted(30, 34) Source(23, 34) + SourceIndex(0) +13>Emitted(30, 35) Source(23, 35) + SourceIndex(0) --- >>> "You win!"; 1 >^^^^^^^^^^^^ @@ -384,9 +389,9 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts > 2 > "You win!" 3 > -1 >Emitted(26, 13) Source(24, 13) + SourceIndex(0) -2 >Emitted(26, 23) Source(24, 23) + SourceIndex(0) -3 >Emitted(26, 24) Source(24, 23) + SourceIndex(0) +1 >Emitted(31, 13) Source(24, 13) + SourceIndex(0) +2 >Emitted(31, 23) Source(24, 23) + SourceIndex(0) +3 >Emitted(31, 24) Source(24, 23) + SourceIndex(0) --- >>> return { 1 >^^^^^^^^^^^^ @@ -397,9 +402,9 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts > 2 > return 3 > -1 >Emitted(27, 13) Source(25, 13) + SourceIndex(0) -2 >Emitted(27, 19) Source(25, 19) + SourceIndex(0) -3 >Emitted(27, 20) Source(25, 20) + SourceIndex(0) +1 >Emitted(32, 13) Source(25, 13) + SourceIndex(0) +2 >Emitted(32, 19) Source(25, 19) + SourceIndex(0) +3 >Emitted(32, 20) Source(25, 20) + SourceIndex(0) --- >>> cProp: 1, 1->^^^^^^^^^^^^^^^^ @@ -412,10 +417,10 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 2 > cProp 3 > : 4 > 1 -1->Emitted(28, 17) Source(26, 17) + SourceIndex(0) -2 >Emitted(28, 22) Source(26, 22) + SourceIndex(0) -3 >Emitted(28, 24) Source(26, 24) + SourceIndex(0) -4 >Emitted(28, 25) Source(26, 25) + SourceIndex(0) +1->Emitted(33, 17) Source(26, 17) + SourceIndex(0) +2 >Emitted(33, 22) Source(26, 22) + SourceIndex(0) +3 >Emitted(33, 24) Source(26, 24) + SourceIndex(0) +4 >Emitted(33, 25) Source(26, 25) + SourceIndex(0) --- >>> dProp: function () { return _this; }, 1->^^^^^^^^^^^^^^^^ @@ -436,14 +441,14 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 6 > this 7 > 8 > this -1->Emitted(29, 17) Source(27, 17) + SourceIndex(0) -2 >Emitted(29, 22) Source(27, 22) + SourceIndex(0) -3 >Emitted(29, 24) Source(27, 24) + SourceIndex(0) -4 >Emitted(29, 38) Source(27, 30) + SourceIndex(0) -5 >Emitted(29, 45) Source(27, 30) + SourceIndex(0) -6 >Emitted(29, 50) Source(27, 34) + SourceIndex(0) -7 >Emitted(29, 52) Source(27, 30) + SourceIndex(0) -8 >Emitted(29, 53) Source(27, 34) + SourceIndex(0) +1->Emitted(34, 17) Source(27, 17) + SourceIndex(0) +2 >Emitted(34, 22) Source(27, 22) + SourceIndex(0) +3 >Emitted(34, 24) Source(27, 24) + SourceIndex(0) +4 >Emitted(34, 38) Source(27, 30) + SourceIndex(0) +5 >Emitted(34, 45) Source(27, 30) + SourceIndex(0) +6 >Emitted(34, 50) Source(27, 34) + SourceIndex(0) +7 >Emitted(34, 52) Source(27, 30) + SourceIndex(0) +8 >Emitted(34, 53) Source(27, 34) + SourceIndex(0) --- >>> foo: function () { return "You win!!!!!"; } 1->^^^^^^^^^^^^^^^^ @@ -465,15 +470,15 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 7 > 8 > 9 > } -1->Emitted(30, 17) Source(28, 17) + SourceIndex(0) -2 >Emitted(30, 20) Source(28, 20) + SourceIndex(0) -3 >Emitted(30, 36) Source(28, 25) + SourceIndex(0) -4 >Emitted(30, 42) Source(28, 31) + SourceIndex(0) -5 >Emitted(30, 43) Source(28, 32) + SourceIndex(0) -6 >Emitted(30, 57) Source(28, 46) + SourceIndex(0) -7 >Emitted(30, 58) Source(28, 46) + SourceIndex(0) -8 >Emitted(30, 59) Source(28, 47) + SourceIndex(0) -9 >Emitted(30, 60) Source(28, 48) + SourceIndex(0) +1->Emitted(35, 17) Source(28, 17) + SourceIndex(0) +2 >Emitted(35, 20) Source(28, 20) + SourceIndex(0) +3 >Emitted(35, 36) Source(28, 25) + SourceIndex(0) +4 >Emitted(35, 42) Source(28, 31) + SourceIndex(0) +5 >Emitted(35, 43) Source(28, 32) + SourceIndex(0) +6 >Emitted(35, 57) Source(28, 46) + SourceIndex(0) +7 >Emitted(35, 58) Source(28, 46) + SourceIndex(0) +8 >Emitted(35, 59) Source(28, 47) + SourceIndex(0) +9 >Emitted(35, 60) Source(28, 48) + SourceIndex(0) --- >>> }; 1 >^^^^^^^^^^^^^ @@ -481,8 +486,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1 > > } 2 > ; -1 >Emitted(31, 14) Source(29, 14) + SourceIndex(0) -2 >Emitted(31, 15) Source(29, 15) + SourceIndex(0) +1 >Emitted(36, 14) Source(29, 14) + SourceIndex(0) +2 >Emitted(36, 15) Source(29, 15) + SourceIndex(0) --- >>> } 1 >^^^^^^^^ @@ -491,8 +496,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1 > > 2 > } -1 >Emitted(32, 9) Source(30, 9) + SourceIndex(0) -2 >Emitted(32, 10) Source(30, 10) + SourceIndex(0) +1 >Emitted(37, 9) Source(30, 9) + SourceIndex(0) +2 >Emitted(37, 10) Source(30, 10) + SourceIndex(0) --- >>> else 1->^^^^^^^^ @@ -501,8 +506,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1-> > 2 > else -1->Emitted(33, 9) Source(31, 9) + SourceIndex(0) -2 >Emitted(33, 13) Source(31, 13) + SourceIndex(0) +1->Emitted(38, 9) Source(31, 9) + SourceIndex(0) +2 >Emitted(38, 13) Source(31, 13) + SourceIndex(0) --- >>> return null; 1->^^^^^^^^^^^^ @@ -516,11 +521,11 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 3 > 4 > null 5 > ; -1->Emitted(34, 13) Source(32, 13) + SourceIndex(0) -2 >Emitted(34, 19) Source(32, 19) + SourceIndex(0) -3 >Emitted(34, 20) Source(32, 20) + SourceIndex(0) -4 >Emitted(34, 24) Source(32, 24) + SourceIndex(0) -5 >Emitted(34, 25) Source(32, 25) + SourceIndex(0) +1->Emitted(39, 13) Source(32, 13) + SourceIndex(0) +2 >Emitted(39, 19) Source(32, 19) + SourceIndex(0) +3 >Emitted(39, 20) Source(32, 20) + SourceIndex(0) +4 >Emitted(39, 24) Source(32, 24) + SourceIndex(0) +5 >Emitted(39, 25) Source(32, 25) + SourceIndex(0) --- >>> } 1 >^^^^ @@ -529,8 +534,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1 > > 2 > } -1 >Emitted(35, 5) Source(33, 5) + SourceIndex(0) -2 >Emitted(35, 6) Source(33, 6) + SourceIndex(0) +1 >Emitted(40, 5) Source(33, 5) + SourceIndex(0) +2 >Emitted(40, 6) Source(33, 6) + SourceIndex(0) --- >>> return D; 1->^^^^ @@ -538,8 +543,8 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts 1-> > 2 > } -1->Emitted(36, 5) Source(34, 1) + SourceIndex(0) -2 >Emitted(36, 13) Source(34, 2) + SourceIndex(0) +1->Emitted(41, 5) Source(34, 1) + SourceIndex(0) +2 >Emitted(41, 13) Source(34, 2) + SourceIndex(0) --- >>>}(C)); 1 > @@ -572,11 +577,11 @@ sourceFile:derivedClassConstructorWithExplicitReturns01.ts > return null; > } > } -1 >Emitted(37, 1) Source(34, 1) + SourceIndex(0) -2 >Emitted(37, 2) Source(34, 2) + SourceIndex(0) -3 >Emitted(37, 2) Source(17, 1) + SourceIndex(0) -4 >Emitted(37, 3) Source(17, 17) + SourceIndex(0) -5 >Emitted(37, 4) Source(17, 18) + SourceIndex(0) -6 >Emitted(37, 7) Source(34, 2) + SourceIndex(0) +1 >Emitted(42, 1) Source(34, 1) + SourceIndex(0) +2 >Emitted(42, 2) Source(34, 2) + SourceIndex(0) +3 >Emitted(42, 2) Source(17, 1) + SourceIndex(0) +4 >Emitted(42, 3) Source(17, 17) + SourceIndex(0) +5 >Emitted(42, 4) Source(17, 18) + SourceIndex(0) +6 >Emitted(42, 7) Source(34, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=derivedClassConstructorWithExplicitReturns01.js.map \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.js b/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.js index e76f3445c8e..960fea90a0c 100644 --- a/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.js +++ b/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.js @@ -34,11 +34,16 @@ class Derived4 extends Base2 { //// [derivedClassConstructorWithoutSuperCall.js] // derived class constructors must contain a super call -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -47,7 +52,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this; + var _this = this; return _this; } return Derived; @@ -60,7 +65,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - var _this; + var _this = this; var r2 = function () { return _this = _super.call(this) || this; }; // error for misplaced super call (nested function) return _this; } @@ -69,7 +74,7 @@ var Derived2 = (function (_super) { var Derived3 = (function (_super) { __extends(Derived3, _super); function Derived3() { - var _this; + var _this = this; var r = function () { _this = _super.call(this) || this; }; // error return _this; } @@ -78,7 +83,7 @@ var Derived3 = (function (_super) { var Derived4 = (function (_super) { __extends(Derived4, _super); function Derived4() { - var _this; + var _this = this; var r = _this = _super.call(this) || this; // ok return _this; } diff --git a/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js b/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js index 7f6b83593ca..23a4233d124 100644 --- a/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js +++ b/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js @@ -15,11 +15,16 @@ class Derived extends Base { } //// [derivedClassFunctionOverridesBaseClassAccessor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -38,7 +43,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.prototype.x = function () { return 1; diff --git a/tests/baselines/reference/derivedClassIncludesInheritedMembers.js b/tests/baselines/reference/derivedClassIncludesInheritedMembers.js index 8224473cb54..8d2010b3346 100644 --- a/tests/baselines/reference/derivedClassIncludesInheritedMembers.js +++ b/tests/baselines/reference/derivedClassIncludesInheritedMembers.js @@ -41,11 +41,16 @@ var r8 = d2[1]; //// [derivedClassIncludesInheritedMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(x) { } @@ -68,7 +73,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -89,7 +94,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/derivedClassOverridesIndexersWithAssignmentCompatibility.js b/tests/baselines/reference/derivedClassOverridesIndexersWithAssignmentCompatibility.js index 4753e395390..fceefd905cc 100644 --- a/tests/baselines/reference/derivedClassOverridesIndexersWithAssignmentCompatibility.js +++ b/tests/baselines/reference/derivedClassOverridesIndexersWithAssignmentCompatibility.js @@ -18,11 +18,16 @@ class Derived2 extends Base2 { } //// [derivedClassOverridesIndexersWithAssignmentCompatibility.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -32,7 +37,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -45,7 +50,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/derivedClassOverridesPrivateFunction1.js b/tests/baselines/reference/derivedClassOverridesPrivateFunction1.js index 981c072d47c..a7c35a96ac3 100644 --- a/tests/baselines/reference/derivedClassOverridesPrivateFunction1.js +++ b/tests/baselines/reference/derivedClassOverridesPrivateFunction1.js @@ -16,11 +16,16 @@ class DerivedClass extends BaseClass { new DerivedClass(); //// [derivedClassOverridesPrivateFunction1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var BaseClass = (function () { function BaseClass() { this._init(); diff --git a/tests/baselines/reference/derivedClassOverridesPrivates.js b/tests/baselines/reference/derivedClassOverridesPrivates.js index 1a58c038fea..642453857c5 100644 --- a/tests/baselines/reference/derivedClassOverridesPrivates.js +++ b/tests/baselines/reference/derivedClassOverridesPrivates.js @@ -16,11 +16,16 @@ class Derived2 extends Base2 { } //// [derivedClassOverridesPrivates.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -29,7 +34,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -41,7 +46,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers.js b/tests/baselines/reference/derivedClassOverridesProtectedMembers.js index b8997769eb7..9230a295f5b 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers.js +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers.js @@ -37,11 +37,16 @@ class Derived extends Base { //// [derivedClassOverridesProtectedMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x; var y; var Base = (function () { diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers2.js b/tests/baselines/reference/derivedClassOverridesProtectedMembers2.js index 6797eef0e77..6eef011e0f4 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers2.js +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers2.js @@ -64,11 +64,16 @@ var r8 = d2[1]; //// [derivedClassOverridesProtectedMembers2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x; var y; var Base = (function () { @@ -131,7 +136,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers3.js b/tests/baselines/reference/derivedClassOverridesProtectedMembers3.js index d0d9d8fa0f5..615bdcddcf0 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers3.js +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers3.js @@ -72,11 +72,16 @@ class Derived10 extends Base { } //// [derivedClassOverridesProtectedMembers3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x; var y; var Base = (function () { diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers4.js b/tests/baselines/reference/derivedClassOverridesProtectedMembers4.js index 06f80997600..594e8166e5e 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers4.js +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers4.js @@ -15,11 +15,16 @@ class Derived2 extends Derived1 { } //// [derivedClassOverridesProtectedMembers4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x; var y; var Base = (function () { @@ -30,14 +35,14 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived1; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived1)); diff --git a/tests/baselines/reference/derivedClassOverridesPublicMembers.js b/tests/baselines/reference/derivedClassOverridesPublicMembers.js index 7943d904dea..af9a013a3d8 100644 --- a/tests/baselines/reference/derivedClassOverridesPublicMembers.js +++ b/tests/baselines/reference/derivedClassOverridesPublicMembers.js @@ -63,11 +63,16 @@ var r8 = d2[1]; //// [derivedClassOverridesPublicMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x; var y; var Base = (function () { @@ -129,7 +134,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/derivedClassOverridesWithoutSubtype.js b/tests/baselines/reference/derivedClassOverridesWithoutSubtype.js index e42ff9c9e1d..fa7eb924653 100644 --- a/tests/baselines/reference/derivedClassOverridesWithoutSubtype.js +++ b/tests/baselines/reference/derivedClassOverridesWithoutSubtype.js @@ -24,11 +24,16 @@ class Derived2 extends Base2 { } //// [derivedClassOverridesWithoutSubtype.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -37,7 +42,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -49,7 +54,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/derivedClassParameterProperties.js b/tests/baselines/reference/derivedClassParameterProperties.js index 27dcc4b7d5d..d8d93e35078 100644 --- a/tests/baselines/reference/derivedClassParameterProperties.js +++ b/tests/baselines/reference/derivedClassParameterProperties.js @@ -96,11 +96,16 @@ class Derived10 extends Base2 { //// [derivedClassParameterProperties.js] // ordering of super calls in derived constructors matters depending on other class contents -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -109,7 +114,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived(y) { - var _this; + var _this = this; var a = 1; _this = _super.call(this) || this; // ok return _this; @@ -119,7 +124,7 @@ var Derived = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2(y) { - var _this; + var _this = this; _this.y = y; var a = 1; _this = _super.call(this) || this; // error @@ -140,7 +145,7 @@ var Derived3 = (function (_super) { var Derived4 = (function (_super) { __extends(Derived4, _super); function Derived4(y) { - var _this; + var _this = this; _this.a = 1; var b = 2; _this = _super.call(this) || this; // error @@ -161,7 +166,7 @@ var Derived5 = (function (_super) { var Derived6 = (function (_super) { __extends(Derived6, _super); function Derived6(y) { - var _this; + var _this = this; _this.a = 1; var b = 2; _this = _super.call(this) || this; // error: "super" has to be called before "this" accessing @@ -172,7 +177,7 @@ var Derived6 = (function (_super) { var Derived7 = (function (_super) { __extends(Derived7, _super); function Derived7(y) { - var _this; + var _this = this; _this.a = 1; _this.a = 3; _this.b = 3; @@ -201,7 +206,7 @@ var Base2 = (function () { var Derived9 = (function (_super) { __extends(Derived9, _super); function Derived9(y) { - var _this; + var _this = this; _this.a = 1; _this.a = 3; _this.b = 3; diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js index b778d7bbca2..8703215a631 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js @@ -33,11 +33,16 @@ class Derived extends Base { //// [derivedClassSuperCallsInNonConstructorMembers.js] // error to use super calls outside a constructor -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -46,7 +51,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.a = _this = _super.call(this) || this; return _this; } diff --git a/tests/baselines/reference/derivedClassSuperCallsWithThisArg.js b/tests/baselines/reference/derivedClassSuperCallsWithThisArg.js index 039e25919f8..f63a8076a0b 100644 --- a/tests/baselines/reference/derivedClassSuperCallsWithThisArg.js +++ b/tests/baselines/reference/derivedClassSuperCallsWithThisArg.js @@ -29,11 +29,16 @@ class Derived4 extends Base { } //// [derivedClassSuperCallsWithThisArg.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(a) { } diff --git a/tests/baselines/reference/derivedClassTransitivity.js b/tests/baselines/reference/derivedClassTransitivity.js index a76ac8101a0..83a750c707d 100644 --- a/tests/baselines/reference/derivedClassTransitivity.js +++ b/tests/baselines/reference/derivedClassTransitivity.js @@ -22,11 +22,16 @@ var r2 = e.foo(''); //// [derivedClassTransitivity.js] // subclassing is not transitive when you can remove required parameters and add optional parameters -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -36,7 +41,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.foo = function () { }; // ok to drop parameters return D; @@ -44,7 +49,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.prototype.foo = function (x) { }; // ok to add optional parameters return E; diff --git a/tests/baselines/reference/derivedClassTransitivity2.js b/tests/baselines/reference/derivedClassTransitivity2.js index a3894863696..7cd7d73d604 100644 --- a/tests/baselines/reference/derivedClassTransitivity2.js +++ b/tests/baselines/reference/derivedClassTransitivity2.js @@ -22,11 +22,16 @@ var r2 = e.foo(1, ''); //// [derivedClassTransitivity2.js] // subclassing is not transitive when you can remove required parameters and add optional parameters -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -36,7 +41,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.foo = function (x) { }; // ok to drop parameters return D; @@ -44,7 +49,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.prototype.foo = function (x, y) { }; // ok to add optional parameters return E; diff --git a/tests/baselines/reference/derivedClassTransitivity3.js b/tests/baselines/reference/derivedClassTransitivity3.js index 71dfecb346f..35a080f1800 100644 --- a/tests/baselines/reference/derivedClassTransitivity3.js +++ b/tests/baselines/reference/derivedClassTransitivity3.js @@ -22,11 +22,16 @@ var r2 = e.foo('', 1); //// [derivedClassTransitivity3.js] // subclassing is not transitive when you can remove required parameters and add optional parameters -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -36,7 +41,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.foo = function (x) { }; // ok to drop parameters return D; @@ -44,7 +49,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.prototype.foo = function (x, y) { }; // ok to add optional parameters return E; diff --git a/tests/baselines/reference/derivedClassTransitivity4.js b/tests/baselines/reference/derivedClassTransitivity4.js index 0030ce702d8..e0f82d55a7c 100644 --- a/tests/baselines/reference/derivedClassTransitivity4.js +++ b/tests/baselines/reference/derivedClassTransitivity4.js @@ -22,11 +22,16 @@ var r2 = e.foo(''); //// [derivedClassTransitivity4.js] // subclassing is not transitive when you can remove required parameters and add optional parameters on protected members -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -36,7 +41,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.foo = function () { }; // ok to drop parameters return D; @@ -44,7 +49,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.prototype.foo = function (x) { }; // ok to add optional parameters return E; diff --git a/tests/baselines/reference/derivedClassWithAny.js b/tests/baselines/reference/derivedClassWithAny.js index 2a199e55861..c8ed8ce5cad 100644 --- a/tests/baselines/reference/derivedClassWithAny.js +++ b/tests/baselines/reference/derivedClassWithAny.js @@ -60,11 +60,16 @@ var r = c.foo(); // e.foo would return string //// [derivedClassWithAny.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -91,7 +96,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(D.prototype, "X", { get: function () { @@ -119,7 +124,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(E.prototype, "X", { get: function () { return ''; }, diff --git a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingProtectedInstance.js b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingProtectedInstance.js index 0542815c4e4..07cc9c43539 100644 --- a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingProtectedInstance.js +++ b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingProtectedInstance.js @@ -23,11 +23,16 @@ class Derived extends Base { //// [derivedClassWithPrivateInstanceShadowingProtectedInstance.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -46,7 +51,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.prototype.fn = function () { return ''; diff --git a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js index 41869cad416..36c6cb56563 100644 --- a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js +++ b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js @@ -33,11 +33,16 @@ var r6 = Derived.a; // error Derived.a = 2; // error //// [derivedClassWithPrivateInstanceShadowingPublicInstance.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -56,7 +61,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.prototype.fn = function () { return ''; diff --git a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingProtectedStatic.js b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingProtectedStatic.js index 10ae3cb35c8..52a50a8aa77 100644 --- a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingProtectedStatic.js +++ b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingProtectedStatic.js @@ -22,11 +22,16 @@ class Derived extends Base { } //// [derivedClassWithPrivateStaticShadowingProtectedStatic.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -45,7 +50,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.fn = function () { return ''; diff --git a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js index 3f2c2a3b811..6e39028ce34 100644 --- a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js +++ b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js @@ -34,11 +34,16 @@ var r6 = Derived.a; // error Derived.a = 2; // error //// [derivedClassWithPrivateStaticShadowingPublicStatic.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -58,7 +63,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.fn = function () { return ''; diff --git a/tests/baselines/reference/derivedClassWithoutExplicitConstructor.js b/tests/baselines/reference/derivedClassWithoutExplicitConstructor.js index 7a6a7ecbb63..1fd02f5ba62 100644 --- a/tests/baselines/reference/derivedClassWithoutExplicitConstructor.js +++ b/tests/baselines/reference/derivedClassWithoutExplicitConstructor.js @@ -26,11 +26,16 @@ var d = new D(); // error var d2 = new D(new Date()); // ok //// [derivedClassWithoutExplicitConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(x) { this.a = 1; @@ -41,7 +46,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = 1; _this.y = 'hello'; return _this; @@ -59,7 +64,7 @@ var Base2 = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = 2; _this.y = null; return _this; diff --git a/tests/baselines/reference/derivedClassWithoutExplicitConstructor2.js b/tests/baselines/reference/derivedClassWithoutExplicitConstructor2.js index 62beb4bf28f..178ca2be16d 100644 --- a/tests/baselines/reference/derivedClassWithoutExplicitConstructor2.js +++ b/tests/baselines/reference/derivedClassWithoutExplicitConstructor2.js @@ -34,11 +34,16 @@ var d3 = new D(new Date(), new Date()); var d4 = new D(new Date(), new Date(), new Date()); //// [derivedClassWithoutExplicitConstructor2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(x) { this.a = 1; @@ -49,7 +54,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = 1; _this.y = 'hello'; return _this; @@ -69,7 +74,7 @@ var Base2 = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = 2; _this.y = null; return _this; diff --git a/tests/baselines/reference/derivedClassWithoutExplicitConstructor3.js b/tests/baselines/reference/derivedClassWithoutExplicitConstructor3.js index c96d0c96723..86f69433504 100644 --- a/tests/baselines/reference/derivedClassWithoutExplicitConstructor3.js +++ b/tests/baselines/reference/derivedClassWithoutExplicitConstructor3.js @@ -48,11 +48,16 @@ var d3 = new D2(new Date(), new Date()); // ok //// [derivedClassWithoutExplicitConstructor3.js] // automatic constructors with a class hieararchy of depth > 2 -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(x) { this.a = 1; @@ -73,7 +78,7 @@ var Derived = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = 1; _this.y = 'hello'; return _this; @@ -102,7 +107,7 @@ var D = (function (_super) { var D2 = (function (_super) { __extends(D2, _super); function D2() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = 2; _this.y = null; return _this; diff --git a/tests/baselines/reference/derivedClasses.js b/tests/baselines/reference/derivedClasses.js index 3e097a9b139..b23161d00d2 100644 --- a/tests/baselines/reference/derivedClasses.js +++ b/tests/baselines/reference/derivedClasses.js @@ -31,15 +31,20 @@ b.hue(); //// [derivedClasses.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Red = (function (_super) { __extends(Red, _super); function Red() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Red.prototype.shade = function () { var _this = this; @@ -58,7 +63,7 @@ var Color = (function () { var Blue = (function (_super) { __extends(Blue, _super); function Blue() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Blue.prototype.shade = function () { var _this = this; diff --git a/tests/baselines/reference/derivedGenericClassWithAny.errors.txt b/tests/baselines/reference/derivedGenericClassWithAny.errors.txt index 81e43f7d8fe..359fab212e9 100644 --- a/tests/baselines/reference/derivedGenericClassWithAny.errors.txt +++ b/tests/baselines/reference/derivedGenericClassWithAny.errors.txt @@ -2,8 +2,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(11,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(19,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,25): error TS2322: Type '""' is not assignable to type 'T'. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(32,16): error TS2322: Type '""' is not assignable to type 'T'. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,18): error TS2322: Type '""' is not assignable to type 'T'. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(32,9): error TS2322: Type '""' is not assignable to type 'T'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(41,1): error TS2322: Type 'E' is not assignable to type 'C'. Types of property 'x' are incompatible. Type 'string' is not assignable to type 'number'. @@ -48,11 +48,11 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC get X(): T { return ''; } // error ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~ + ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'T'. foo(): T { return ''; // error - ~~ + ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'T'. } } diff --git a/tests/baselines/reference/derivedGenericClassWithAny.js b/tests/baselines/reference/derivedGenericClassWithAny.js index 1822f3fcc47..0cf4c316a44 100644 --- a/tests/baselines/reference/derivedGenericClassWithAny.js +++ b/tests/baselines/reference/derivedGenericClassWithAny.js @@ -43,11 +43,16 @@ c = e; var r = c.foo(); // e.foo would return string //// [derivedGenericClassWithAny.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -64,7 +69,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(D.prototype, "X", { get: function () { @@ -92,7 +97,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(E.prototype, "X", { get: function () { return ''; } // error diff --git a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.js b/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.js index c17922e05ee..a190b26901c 100644 --- a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.js +++ b/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.js @@ -18,11 +18,16 @@ class Derived extends Base { } //// [derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -34,7 +39,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.prototype.foo = function (x) { return null; diff --git a/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.js b/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.js index 6fe690fd692..26f4408e41e 100644 --- a/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.js +++ b/tests/baselines/reference/derivedTypeDoesNotRequireExtendsClause.js @@ -21,11 +21,16 @@ b = d2; var r: Base[] = [d1, d2]; //// [derivedTypeDoesNotRequireExtendsClause.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -39,7 +44,7 @@ var Derived = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5iterable.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5iterable.errors.txt new file mode 100644 index 00000000000..6a2647013fb --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5iterable.errors.txt @@ -0,0 +1,65 @@ +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5iterable.ts(43,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5iterable.ts(44,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5iterable.ts(44,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + + +==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5iterable.ts (3 errors) ==== + /* AssignmentPattern: + * ObjectAssignmentPattern + * ArrayAssignmentPattern + * ArrayAssignmentPattern: + * [Elision AssignmentRestElementopt ] + * [AssignmentElementList] + * [AssignmentElementList, Elision AssignmentRestElementopt ] + * AssignmentElementList: + * Elision AssignmentElement + * AssignmentElementList, Elisionopt AssignmentElement + * AssignmentElement: + * LeftHandSideExpression Initialiseropt + * AssignmentPattern Initialiseropt + * AssignmentRestElement: + * ... LeftHandSideExpression + */ + + // In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + // An expression of type S is considered assignable to an assignment target V if one of the following is true + + // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, + // S is the type Any, or + + var [a0, a1]: any = undefined; + var [a2 = false, a3 = 1]: any = undefined; + + // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, + // S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, + // where N is the numeric index of E in the array assignment pattern, or + var [b0, b1, b2] = [2, 3, 4]; + var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; + + function foo() { + return [1, 2, 3]; + } + + var [b6, b7] = foo(); + var [...b8] = foo(); + + // S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. + var temp = [1,2,3] + var [c0, c1] = [...temp]; + var [c2] = []; + ~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] + ~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + ~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + var [[c5], c6]: [[string|number], boolean] = [[1], true]; + var [, c7] = [1, 2, 3]; + var [,,, c8] = [1, 2, 3, 4]; + var [,,, c9] = [1, 2, 3, 4]; + var [,,,...c10] = [1, 2, 3, 4, "hello"]; + var [c11, c12, ...c13] = [1, 2, "string"]; + var [c14, c15, c16] = [1, 2, "string"]; + + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5iterable.js b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5iterable.js new file mode 100644 index 00000000000..acb56cfb8ad --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5iterable.js @@ -0,0 +1,120 @@ +//// [destructuringArrayBindingPatternAndAssignment1ES5iterable.ts] +/* AssignmentPattern: + * ObjectAssignmentPattern + * ArrayAssignmentPattern + * ArrayAssignmentPattern: + * [Elision AssignmentRestElementopt ] + * [AssignmentElementList] + * [AssignmentElementList, Elision AssignmentRestElementopt ] + * AssignmentElementList: + * Elision AssignmentElement + * AssignmentElementList, Elisionopt AssignmentElement + * AssignmentElement: + * LeftHandSideExpression Initialiseropt + * AssignmentPattern Initialiseropt + * AssignmentRestElement: + * ... LeftHandSideExpression + */ + +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is the type Any, or + +var [a0, a1]: any = undefined; +var [a2 = false, a3 = 1]: any = undefined; + +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, +// where N is the numeric index of E in the array assignment pattern, or +var [b0, b1, b2] = [2, 3, 4]; +var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; + +function foo() { + return [1, 2, 3]; +} + +var [b6, b7] = foo(); +var [...b8] = foo(); + +// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. +var temp = [1,2,3] +var [c0, c1] = [...temp]; +var [c2] = []; +var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] +var [[c5], c6]: [[string|number], boolean] = [[1], true]; +var [, c7] = [1, 2, 3]; +var [,,, c8] = [1, 2, 3, 4]; +var [,,, c9] = [1, 2, 3, 4]; +var [,,,...c10] = [1, 2, 3, 4, "hello"]; +var [c11, c12, ...c13] = [1, 2, "string"]; +var [c14, c15, c16] = [1, 2, "string"]; + + + +//// [destructuringArrayBindingPatternAndAssignment1ES5iterable.js] +/* AssignmentPattern: + * ObjectAssignmentPattern + * ArrayAssignmentPattern + * ArrayAssignmentPattern: + * [Elision AssignmentRestElementopt ] + * [AssignmentElementList] + * [AssignmentElementList, Elision AssignmentRestElementopt ] + * AssignmentElementList: + * Elision AssignmentElement + * AssignmentElementList, Elisionopt AssignmentElement + * AssignmentElement: + * LeftHandSideExpression Initialiseropt + * AssignmentPattern Initialiseropt + * AssignmentRestElement: + * ... LeftHandSideExpression + */ +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spread = (this && this.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; +// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. +// An expression of type S is considered assignable to an assignment target V if one of the following is true +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is the type Any, or +var _a = __read(undefined, 2), a0 = _a[0], a1 = _a[1]; +var _b = __read(undefined, 2), _c = _b[0], a2 = _c === void 0 ? false : _c, _d = _b[1], a3 = _d === void 0 ? 1 : _d; +// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, +// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, +// where N is the numeric index of E in the array assignment pattern, or +var _e = __read([2, 3, 4], 3), b0 = _e[0], b1 = _e[1], b2 = _e[2]; +var _f = __read([1, 2, "string"], 3), b3 = _f[0], b4 = _f[1], b5 = _f[2]; +function foo() { + return [1, 2, 3]; +} +var _g = __read(foo(), 2), b6 = _g[0], b7 = _g[1]; +var _h = __read(foo()), b8 = _h.slice(0); +// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. +var temp = [1, 2, 3]; +var _j = __read(__spread(temp), 2), c0 = _j[0], c1 = _j[1]; +var _k = __read([], 1), c2 = _k[0]; +var _l = __read([[[]], [[[[]]]]], 2), _m = __read(_l[0], 1), _o = __read(_m[0], 1), c3 = _o[0], _p = __read(_l[1], 1), _q = __read(_p[0], 1), _r = __read(_q[0], 1), _s = __read(_r[0], 1), c4 = _s[0]; +var _t = __read([[1], true], 2), _u = __read(_t[0], 1), c5 = _u[0], c6 = _t[1]; +var _v = __read([1, 2, 3], 2), c7 = _v[1]; +var _w = __read([1, 2, 3, 4], 4), c8 = _w[3]; +var _x = __read([1, 2, 3, 4], 4), c9 = _x[3]; +var _y = __read([1, 2, 3, 4, "hello"]), c10 = _y.slice(3); +var _z = __read([1, 2, "string"]), c11 = _z[0], c12 = _z[1], c13 = _z.slice(2); +var _0 = __read([1, 2, "string"], 3), c14 = _0[0], c15 = _0[1], c16 = _0[2]; diff --git a/tests/baselines/reference/destructuringInVariableDeclarations1.js b/tests/baselines/reference/destructuringInVariableDeclarations1.js index 707218b41e2..a7645ceabe9 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations1.js +++ b/tests/baselines/reference/destructuringInVariableDeclarations1.js @@ -7,6 +7,7 @@ export let { toString } = 1; //// [destructuringInVariableDeclarations1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.toString = (1).toString; { let { toFixed } = 1; diff --git a/tests/baselines/reference/destructuringInVariableDeclarations2.js b/tests/baselines/reference/destructuringInVariableDeclarations2.js index 9c1366bd8e0..43a2f740c94 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations2.js +++ b/tests/baselines/reference/destructuringInVariableDeclarations2.js @@ -8,6 +8,7 @@ export {}; //// [destructuringInVariableDeclarations2.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); let { toString } = 1; { let { toFixed } = 1; diff --git a/tests/baselines/reference/destructuringInVariableDeclarations3.js b/tests/baselines/reference/destructuringInVariableDeclarations3.js index 8da039fe98e..2522a704e18 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations3.js +++ b/tests/baselines/reference/destructuringInVariableDeclarations3.js @@ -8,6 +8,7 @@ export let { toString } = 1; //// [destructuringInVariableDeclarations3.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.toString = (1).toString; { let { toFixed } = 1; diff --git a/tests/baselines/reference/destructuringInVariableDeclarations4.js b/tests/baselines/reference/destructuringInVariableDeclarations4.js index d4b30405143..867417cf01f 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations4.js +++ b/tests/baselines/reference/destructuringInVariableDeclarations4.js @@ -9,6 +9,7 @@ export {}; //// [destructuringInVariableDeclarations4.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); let { toString } = 1; { let { toFixed } = 1; diff --git a/tests/baselines/reference/destructuringInVariableDeclarations5.js b/tests/baselines/reference/destructuringInVariableDeclarations5.js index 94530d8d258..20a094a0375 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations5.js +++ b/tests/baselines/reference/destructuringInVariableDeclarations5.js @@ -16,6 +16,7 @@ export let { toString } = 1; } })(function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.toString = (1).toString; { let { toFixed } = 1; diff --git a/tests/baselines/reference/destructuringInVariableDeclarations6.js b/tests/baselines/reference/destructuringInVariableDeclarations6.js index c16a0a7d0a2..583a2cd1f1d 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations6.js +++ b/tests/baselines/reference/destructuringInVariableDeclarations6.js @@ -17,6 +17,7 @@ export {}; } })(function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); let { toString } = 1; { let { toFixed } = 1; diff --git a/tests/baselines/reference/destructuringParameterDeclaration1ES5iterable.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration1ES5iterable.errors.txt new file mode 100644 index 00000000000..101a37fc84a --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration1ES5iterable.errors.txt @@ -0,0 +1,106 @@ +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5iterable.ts(62,10): error TS2393: Duplicate function implementation. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5iterable.ts(63,10): error TS2393: Duplicate function implementation. + + +==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5iterable.ts (2 errors) ==== + // A parameter declaration may specify either an identifier or a binding pattern. + // The identifiers specified in parameter declarations and binding patterns + // in a parameter list must be unique within that parameter list. + + // If the declaration includes a type annotation, the parameter is of that type + function a1([a, b, [[c]]]: [number, number, string[][]]) { } + function a2(o: { x: number, a: number }) { } + function a3({j, k, l: {m, n}, q: [a, b, c]}: { j: number, k: string, l: { m: boolean, n: number }, q: (number|string)[] }) { }; + function a4({x, a}: { x: number, a: number }) { } + + a1([1, 2, [["world"]]]); + a1([1, 2, [["world"]], 3]); + + // If the declaration includes an initializer expression (which is permitted only + // when the parameter list occurs in conjunction with a function body), + // the parameter type is the widened form (section 3.11) of the type of the initializer expression. + + function b1(z = [undefined, null]) { }; + function b2(z = null, o = { x: 0, y: undefined }) { } + function b3({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { } + + interface F1 { + b5(z, y, [, a, b], {p, m: { q, r}}); + } + + function b6([a, z, y] = [undefined, null, undefined]) { } + function b7([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { } + + b1([1, 2, 3]); // z is widen to the type any[] + b2("string", { x: 200, y: "string" }); + b2("string", { x: 200, y: true }); + b6(["string", 1, 2]); // Shouldn't be an error + b7([["string"], 1, [[true, false]]]); // Shouldn't be an error + + + // If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) + enum Foo { a } + function c0({z: {x, y: {j}}}) { } + function c1({z} = { z: 10 }) { } + function c2({z = 10}) { } + function c3({b}: { b: number|string} = { b: "hello" }) { } + function c5([a, b, [[c]]]) { } + function c6([a, b, [[c=1]]]) { } + + c0({z : { x: 1, y: { j: "world" } }}); // Implied type is { z: {x: any, y: {j: any}} } + c0({z : { x: "string", y: { j: true } }}); // Implied type is { z: {x: any, y: {j: any}} } + + c1(); // Implied type is {z:number}? + c1({ z: 1 }) // Implied type is {z:number}? + + c2({}); // Implied type is {z?: number} + c2({z:1}); // Implied type is {z?: number} + + c3({ b: 1 }); // Implied type is { b: number|string }. + + c5([1, 2, [["string"]]]); // Implied type is is [any, any, [[any]]] + c5([1, 2, [["string"]], false, true]); // Implied type is is [any, any, [[any]]] + + // A parameter can be marked optional by following its name or binding pattern with a question mark (?) + // or by including an initializer. + + function d0(x?) { } + ~~ +!!! error TS2393: Duplicate function implementation. + function d0(x = 10) { } + ~~ +!!! error TS2393: Duplicate function implementation. + + interface F2 { + d3([a, b, c]?); + d4({x, y, z}?); + e0([a, b, c]); + } + + class C2 implements F2 { + constructor() { } + d3() { } + d4() { } + e0([a, b, c]) { } + } + + class C3 implements F2 { + d3([a, b, c]) { } + d4({x, y, z}) { } + e0([a, b, c]) { } + } + + + function d5({x, y} = { x: 1, y: 2 }) { } + d5(); // Parameter is optional as its declaration included an initializer + + // Destructuring parameter declarations do not permit type annotations on the individual binding patterns, + // as such annotations would conflict with the already established meaning of colons in object literals. + // Type annotations must instead be written on the top- level parameter declaration + + function e1({x: number}) { } // x has type any NOT number + function e2({x}: { x: number }) { } // x is type number + function e3({x}: { x?: number }) { } // x is an optional with type number + function e4({x: [number,string,any] }) { } // x has type [any, any, any] + function e5({x: [a, b, c]}: { x: [number, number, number] }) { } // x has type [any, any, any] + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringParameterDeclaration1ES5iterable.js b/tests/baselines/reference/destructuringParameterDeclaration1ES5iterable.js new file mode 100644 index 00000000000..d9036186035 --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration1ES5iterable.js @@ -0,0 +1,242 @@ +//// [destructuringParameterDeclaration1ES5iterable.ts] +// A parameter declaration may specify either an identifier or a binding pattern. +// The identifiers specified in parameter declarations and binding patterns +// in a parameter list must be unique within that parameter list. + +// If the declaration includes a type annotation, the parameter is of that type +function a1([a, b, [[c]]]: [number, number, string[][]]) { } +function a2(o: { x: number, a: number }) { } +function a3({j, k, l: {m, n}, q: [a, b, c]}: { j: number, k: string, l: { m: boolean, n: number }, q: (number|string)[] }) { }; +function a4({x, a}: { x: number, a: number }) { } + +a1([1, 2, [["world"]]]); +a1([1, 2, [["world"]], 3]); + +// If the declaration includes an initializer expression (which is permitted only +// when the parameter list occurs in conjunction with a function body), +// the parameter type is the widened form (section 3.11) of the type of the initializer expression. + +function b1(z = [undefined, null]) { }; +function b2(z = null, o = { x: 0, y: undefined }) { } +function b3({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { } + +interface F1 { + b5(z, y, [, a, b], {p, m: { q, r}}); +} + +function b6([a, z, y] = [undefined, null, undefined]) { } +function b7([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { } + +b1([1, 2, 3]); // z is widen to the type any[] +b2("string", { x: 200, y: "string" }); +b2("string", { x: 200, y: true }); +b6(["string", 1, 2]); // Shouldn't be an error +b7([["string"], 1, [[true, false]]]); // Shouldn't be an error + + +// If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) +enum Foo { a } +function c0({z: {x, y: {j}}}) { } +function c1({z} = { z: 10 }) { } +function c2({z = 10}) { } +function c3({b}: { b: number|string} = { b: "hello" }) { } +function c5([a, b, [[c]]]) { } +function c6([a, b, [[c=1]]]) { } + +c0({z : { x: 1, y: { j: "world" } }}); // Implied type is { z: {x: any, y: {j: any}} } +c0({z : { x: "string", y: { j: true } }}); // Implied type is { z: {x: any, y: {j: any}} } + +c1(); // Implied type is {z:number}? +c1({ z: 1 }) // Implied type is {z:number}? + +c2({}); // Implied type is {z?: number} +c2({z:1}); // Implied type is {z?: number} + +c3({ b: 1 }); // Implied type is { b: number|string }. + +c5([1, 2, [["string"]]]); // Implied type is is [any, any, [[any]]] +c5([1, 2, [["string"]], false, true]); // Implied type is is [any, any, [[any]]] + +// A parameter can be marked optional by following its name or binding pattern with a question mark (?) +// or by including an initializer. + +function d0(x?) { } +function d0(x = 10) { } + +interface F2 { + d3([a, b, c]?); + d4({x, y, z}?); + e0([a, b, c]); +} + +class C2 implements F2 { + constructor() { } + d3() { } + d4() { } + e0([a, b, c]) { } +} + +class C3 implements F2 { + d3([a, b, c]) { } + d4({x, y, z}) { } + e0([a, b, c]) { } +} + + +function d5({x, y} = { x: 1, y: 2 }) { } +d5(); // Parameter is optional as its declaration included an initializer + +// Destructuring parameter declarations do not permit type annotations on the individual binding patterns, +// as such annotations would conflict with the already established meaning of colons in object literals. +// Type annotations must instead be written on the top- level parameter declaration + +function e1({x: number}) { } // x has type any NOT number +function e2({x}: { x: number }) { } // x is type number +function e3({x}: { x?: number }) { } // x is an optional with type number +function e4({x: [number,string,any] }) { } // x has type [any, any, any] +function e5({x: [a, b, c]}: { x: [number, number, number] }) { } // x has type [any, any, any] + + +//// [destructuringParameterDeclaration1ES5iterable.js] +// A parameter declaration may specify either an identifier or a binding pattern. +// The identifiers specified in parameter declarations and binding patterns +// in a parameter list must be unique within that parameter list. +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +// If the declaration includes a type annotation, the parameter is of that type +function a1(_a) { + var _b = __read(_a, 3), a = _b[0], b = _b[1], _c = __read(_b[2], 1), _d = __read(_c[0], 1), c = _d[0]; +} +function a2(o) { } +function a3(_a) { + var j = _a.j, k = _a.k, _b = _a.l, m = _b.m, n = _b.n, _c = __read(_a.q, 3), a = _c[0], b = _c[1], c = _c[2]; +} +; +function a4(_a) { + var x = _a.x, a = _a.a; +} +a1([1, 2, [["world"]]]); +a1([1, 2, [["world"]], 3]); +// If the declaration includes an initializer expression (which is permitted only +// when the parameter list occurs in conjunction with a function body), +// the parameter type is the widened form (section 3.11) of the type of the initializer expression. +function b1(z) { + if (z === void 0) { z = [undefined, null]; } +} +; +function b2(z, o) { + if (z === void 0) { z = null; } + if (o === void 0) { o = { x: 0, y: undefined }; } +} +function b3(_a) { + var _b = (_a === void 0 ? { z: { x: "hi", y: { j: 1 } } } : _a).z, x = _b.x, j = _b.y.j; +} +function b6(_a) { + var _b = __read(_a === void 0 ? [undefined, null, undefined] : _a, 3), a = _b[0], z = _b[1], y = _b[2]; +} +function b7(_a) { + var _b = __read(_a === void 0 ? [[undefined], undefined, [[undefined, undefined]]] : _a, 3), _c = __read(_b[0], 1), a = _c[0], b = _b[1], _d = __read(_b[2], 1), _e = __read(_d[0], 2), c = _e[0], d = _e[1]; +} +b1([1, 2, 3]); // z is widen to the type any[] +b2("string", { x: 200, y: "string" }); +b2("string", { x: 200, y: true }); +b6(["string", 1, 2]); // Shouldn't be an error +b7([["string"], 1, [[true, false]]]); // Shouldn't be an error +// If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) +var Foo; +(function (Foo) { + Foo[Foo["a"] = 0] = "a"; +})(Foo || (Foo = {})); +function c0(_a) { + var _b = _a.z, x = _b.x, j = _b.y.j; +} +function c1(_a) { + var z = (_a === void 0 ? { z: 10 } : _a).z; +} +function c2(_a) { + var _b = _a.z, z = _b === void 0 ? 10 : _b; +} +function c3(_a) { + var b = (_a === void 0 ? { b: "hello" } : _a).b; +} +function c5(_a) { + var _b = __read(_a, 3), a = _b[0], b = _b[1], _c = __read(_b[2], 1), _d = __read(_c[0], 1), c = _d[0]; +} +function c6(_a) { + var _b = __read(_a, 3), a = _b[0], b = _b[1], _c = __read(_b[2], 1), _d = __read(_c[0], 1), _e = _d[0], c = _e === void 0 ? 1 : _e; +} +c0({ z: { x: 1, y: { j: "world" } } }); // Implied type is { z: {x: any, y: {j: any}} } +c0({ z: { x: "string", y: { j: true } } }); // Implied type is { z: {x: any, y: {j: any}} } +c1(); // Implied type is {z:number}? +c1({ z: 1 }); // Implied type is {z:number}? +c2({}); // Implied type is {z?: number} +c2({ z: 1 }); // Implied type is {z?: number} +c3({ b: 1 }); // Implied type is { b: number|string }. +c5([1, 2, [["string"]]]); // Implied type is is [any, any, [[any]]] +c5([1, 2, [["string"]], false, true]); // Implied type is is [any, any, [[any]]] +// A parameter can be marked optional by following its name or binding pattern with a question mark (?) +// or by including an initializer. +function d0(x) { } +function d0(x) { + if (x === void 0) { x = 10; } +} +var C2 = (function () { + function C2() { + } + C2.prototype.d3 = function () { }; + C2.prototype.d4 = function () { }; + C2.prototype.e0 = function (_a) { + var _b = __read(_a, 3), a = _b[0], b = _b[1], c = _b[2]; + }; + return C2; +}()); +var C3 = (function () { + function C3() { + } + C3.prototype.d3 = function (_a) { + var _b = __read(_a, 3), a = _b[0], b = _b[1], c = _b[2]; + }; + C3.prototype.d4 = function (_a) { + var x = _a.x, y = _a.y, z = _a.z; + }; + C3.prototype.e0 = function (_a) { + var _b = __read(_a, 3), a = _b[0], b = _b[1], c = _b[2]; + }; + return C3; +}()); +function d5(_a) { + var _b = _a === void 0 ? { x: 1, y: 2 } : _a, x = _b.x, y = _b.y; +} +d5(); // Parameter is optional as its declaration included an initializer +// Destructuring parameter declarations do not permit type annotations on the individual binding patterns, +// as such annotations would conflict with the already established meaning of colons in object literals. +// Type annotations must instead be written on the top- level parameter declaration +function e1(_a) { + var number = _a.x; +} // x has type any NOT number +function e2(_a) { + var x = _a.x; +} // x is type number +function e3(_a) { + var x = _a.x; +} // x is an optional with type number +function e4(_a) { + var _b = __read(_a.x, 3), number = _b[0], string = _b[1], any = _b[2]; +} // x has type [any, any, any] +function e5(_a) { + var _b = __read(_a.x, 3), a = _b[0], b = _b[1], c = _b[2]; +} // x has type [any, any, any] diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.js b/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.js new file mode 100644 index 00000000000..ab00e874e3e --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.js @@ -0,0 +1,141 @@ +//// [destructuringParameterDeclaration3ES5iterable.ts] + +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. + +// RestParameter: +// ... Identifier TypeAnnotation(opt) + +type arrayString = Array +type someArray = Array | number[]; +type stringOrNumArray = Array; + +function a1(...x: (number|string)[]) { } +function a2(...a) { } +function a3(...a: Array) { } +function a4(...a: arrayString) { } +function a5(...a: stringOrNumArray) { } +function a9([a, b, [[c]]]) { } +function a10([a, b, [[c]], ...x]) { } +function a11([a, b, c, ...x]: number[]) { } + + +var array = [1, 2, 3]; +var array2 = [true, false, "hello"]; +a2([...array]); +a1(...array); + +a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]] + +a10([1, 2, [["string"]], false, true]); // Parameter type is any[] +a10([1, 2, 3, false, true]); // Parameter type is any[] +a10([1, 2]); // Parameter type is any[] +a11([1, 2]); // Parameter type is number[] + +// Rest parameter with generic +function foo(...a: T[]) { } +foo("hello", 1, 2); +foo("hello", "world"); + +enum E { a, b } +const enum E1 { a, b } +function foo1(...a: T[]) { } +foo1(1, 2, 3, E.a); +foo1(1, 2, 3, E1.a, E.b); + + + + +//// [destructuringParameterDeclaration3ES5iterable.js] +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spread = (this && this.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; +function a1() { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i] = arguments[_i]; + } +} +function a2() { + var a = []; + for (var _i = 0; _i < arguments.length; _i++) { + a[_i] = arguments[_i]; + } +} +function a3() { + var a = []; + for (var _i = 0; _i < arguments.length; _i++) { + a[_i] = arguments[_i]; + } +} +function a4() { + var a = []; + for (var _i = 0; _i < arguments.length; _i++) { + a[_i] = arguments[_i]; + } +} +function a5() { + var a = []; + for (var _i = 0; _i < arguments.length; _i++) { + a[_i] = arguments[_i]; + } +} +function a9(_a) { + var _b = __read(_a, 3), a = _b[0], b = _b[1], _c = __read(_b[2], 1), _d = __read(_c[0], 1), c = _d[0]; +} +function a10(_a) { + var _b = __read(_a), a = _b[0], b = _b[1], _c = __read(_b[2], 1), _d = __read(_c[0], 1), c = _d[0], x = _b.slice(3); +} +function a11(_a) { + var _b = __read(_a), a = _b[0], b = _b[1], c = _b[2], x = _b.slice(3); +} +var array = [1, 2, 3]; +var array2 = [true, false, "hello"]; +a2(__spread(array)); +a1.apply(void 0, __spread(array)); +a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]] +a10([1, 2, [["string"]], false, true]); // Parameter type is any[] +a10([1, 2, 3, false, true]); // Parameter type is any[] +a10([1, 2]); // Parameter type is any[] +a11([1, 2]); // Parameter type is number[] +// Rest parameter with generic +function foo() { + var a = []; + for (var _i = 0; _i < arguments.length; _i++) { + a[_i] = arguments[_i]; + } +} +foo("hello", 1, 2); +foo("hello", "world"); +var E; +(function (E) { + E[E["a"] = 0] = "a"; + E[E["b"] = 1] = "b"; +})(E || (E = {})); +function foo1() { + var a = []; + for (var _i = 0; _i < arguments.length; _i++) { + a[_i] = arguments[_i]; + } +} +foo1(1, 2, 3, E.a); +foo1(1, 2, 3, 0 /* a */, E.b); diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.symbols new file mode 100644 index 00000000000..52b2d290fa0 --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.symbols @@ -0,0 +1,145 @@ +=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5iterable.ts === + +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. + +// RestParameter: +// ... Identifier TypeAnnotation(opt) + +type arrayString = Array +>arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES5iterable.ts, 0, 0)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +type someArray = Array | number[]; +>someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES5iterable.ts, 7, 32)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +type stringOrNumArray = Array; +>stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES5iterable.ts, 8, 42)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +function a1(...x: (number|string)[]) { } +>a1 : Symbol(a1, Decl(destructuringParameterDeclaration3ES5iterable.ts, 9, 45)) +>x : Symbol(x, Decl(destructuringParameterDeclaration3ES5iterable.ts, 11, 12)) + +function a2(...a) { } +>a2 : Symbol(a2, Decl(destructuringParameterDeclaration3ES5iterable.ts, 11, 40)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5iterable.ts, 12, 12)) + +function a3(...a: Array) { } +>a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES5iterable.ts, 12, 21)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5iterable.ts, 13, 12)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +function a4(...a: arrayString) { } +>a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES5iterable.ts, 13, 36)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5iterable.ts, 14, 12)) +>arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES5iterable.ts, 0, 0)) + +function a5(...a: stringOrNumArray) { } +>a5 : Symbol(a5, Decl(destructuringParameterDeclaration3ES5iterable.ts, 14, 34)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5iterable.ts, 15, 12)) +>stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES5iterable.ts, 8, 42)) + +function a9([a, b, [[c]]]) { } +>a9 : Symbol(a9, Decl(destructuringParameterDeclaration3ES5iterable.ts, 15, 39)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5iterable.ts, 16, 13)) +>b : Symbol(b, Decl(destructuringParameterDeclaration3ES5iterable.ts, 16, 15)) +>c : Symbol(c, Decl(destructuringParameterDeclaration3ES5iterable.ts, 16, 21)) + +function a10([a, b, [[c]], ...x]) { } +>a10 : Symbol(a10, Decl(destructuringParameterDeclaration3ES5iterable.ts, 16, 30)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5iterable.ts, 17, 14)) +>b : Symbol(b, Decl(destructuringParameterDeclaration3ES5iterable.ts, 17, 16)) +>c : Symbol(c, Decl(destructuringParameterDeclaration3ES5iterable.ts, 17, 22)) +>x : Symbol(x, Decl(destructuringParameterDeclaration3ES5iterable.ts, 17, 26)) + +function a11([a, b, c, ...x]: number[]) { } +>a11 : Symbol(a11, Decl(destructuringParameterDeclaration3ES5iterable.ts, 17, 37)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5iterable.ts, 18, 14)) +>b : Symbol(b, Decl(destructuringParameterDeclaration3ES5iterable.ts, 18, 16)) +>c : Symbol(c, Decl(destructuringParameterDeclaration3ES5iterable.ts, 18, 19)) +>x : Symbol(x, Decl(destructuringParameterDeclaration3ES5iterable.ts, 18, 22)) + + +var array = [1, 2, 3]; +>array : Symbol(array, Decl(destructuringParameterDeclaration3ES5iterable.ts, 21, 3)) + +var array2 = [true, false, "hello"]; +>array2 : Symbol(array2, Decl(destructuringParameterDeclaration3ES5iterable.ts, 22, 3)) + +a2([...array]); +>a2 : Symbol(a2, Decl(destructuringParameterDeclaration3ES5iterable.ts, 11, 40)) +>array : Symbol(array, Decl(destructuringParameterDeclaration3ES5iterable.ts, 21, 3)) + +a1(...array); +>a1 : Symbol(a1, Decl(destructuringParameterDeclaration3ES5iterable.ts, 9, 45)) +>array : Symbol(array, Decl(destructuringParameterDeclaration3ES5iterable.ts, 21, 3)) + +a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]] +>a9 : Symbol(a9, Decl(destructuringParameterDeclaration3ES5iterable.ts, 15, 39)) + +a10([1, 2, [["string"]], false, true]); // Parameter type is any[] +>a10 : Symbol(a10, Decl(destructuringParameterDeclaration3ES5iterable.ts, 16, 30)) + +a10([1, 2, 3, false, true]); // Parameter type is any[] +>a10 : Symbol(a10, Decl(destructuringParameterDeclaration3ES5iterable.ts, 16, 30)) + +a10([1, 2]); // Parameter type is any[] +>a10 : Symbol(a10, Decl(destructuringParameterDeclaration3ES5iterable.ts, 16, 30)) + +a11([1, 2]); // Parameter type is number[] +>a11 : Symbol(a11, Decl(destructuringParameterDeclaration3ES5iterable.ts, 17, 37)) + +// Rest parameter with generic +function foo(...a: T[]) { } +>foo : Symbol(foo, Decl(destructuringParameterDeclaration3ES5iterable.ts, 31, 12)) +>T : Symbol(T, Decl(destructuringParameterDeclaration3ES5iterable.ts, 34, 13)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5iterable.ts, 34, 16)) +>T : Symbol(T, Decl(destructuringParameterDeclaration3ES5iterable.ts, 34, 13)) + +foo("hello", 1, 2); +>foo : Symbol(foo, Decl(destructuringParameterDeclaration3ES5iterable.ts, 31, 12)) + +foo("hello", "world"); +>foo : Symbol(foo, Decl(destructuringParameterDeclaration3ES5iterable.ts, 31, 12)) + +enum E { a, b } +>E : Symbol(E, Decl(destructuringParameterDeclaration3ES5iterable.ts, 36, 22)) +>a : Symbol(E.a, Decl(destructuringParameterDeclaration3ES5iterable.ts, 38, 8)) +>b : Symbol(E.b, Decl(destructuringParameterDeclaration3ES5iterable.ts, 38, 11)) + +const enum E1 { a, b } +>E1 : Symbol(E1, Decl(destructuringParameterDeclaration3ES5iterable.ts, 38, 15)) +>a : Symbol(E1.a, Decl(destructuringParameterDeclaration3ES5iterable.ts, 39, 15)) +>b : Symbol(E1.b, Decl(destructuringParameterDeclaration3ES5iterable.ts, 39, 18)) + +function foo1(...a: T[]) { } +>foo1 : Symbol(foo1, Decl(destructuringParameterDeclaration3ES5iterable.ts, 39, 22)) +>T : Symbol(T, Decl(destructuringParameterDeclaration3ES5iterable.ts, 40, 14)) +>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5iterable.ts, 40, 32)) +>T : Symbol(T, Decl(destructuringParameterDeclaration3ES5iterable.ts, 40, 14)) + +foo1(1, 2, 3, E.a); +>foo1 : Symbol(foo1, Decl(destructuringParameterDeclaration3ES5iterable.ts, 39, 22)) +>E.a : Symbol(E.a, Decl(destructuringParameterDeclaration3ES5iterable.ts, 38, 8)) +>E : Symbol(E, Decl(destructuringParameterDeclaration3ES5iterable.ts, 36, 22)) +>a : Symbol(E.a, Decl(destructuringParameterDeclaration3ES5iterable.ts, 38, 8)) + +foo1(1, 2, 3, E1.a, E.b); +>foo1 : Symbol(foo1, Decl(destructuringParameterDeclaration3ES5iterable.ts, 39, 22)) +>E1.a : Symbol(E1.a, Decl(destructuringParameterDeclaration3ES5iterable.ts, 39, 15)) +>E1 : Symbol(E1, Decl(destructuringParameterDeclaration3ES5iterable.ts, 38, 15)) +>a : Symbol(E1.a, Decl(destructuringParameterDeclaration3ES5iterable.ts, 39, 15)) +>E.b : Symbol(E.b, Decl(destructuringParameterDeclaration3ES5iterable.ts, 38, 11)) +>E : Symbol(E, Decl(destructuringParameterDeclaration3ES5iterable.ts, 36, 22)) +>b : Symbol(E.b, Decl(destructuringParameterDeclaration3ES5iterable.ts, 38, 11)) + + + diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.types b/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.types new file mode 100644 index 00000000000..d003531c67b --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.types @@ -0,0 +1,206 @@ +=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5iterable.ts === + +// If the parameter is a rest parameter, the parameter type is any[] +// A type annotation for a rest parameter must denote an array type. + +// RestParameter: +// ... Identifier TypeAnnotation(opt) + +type arrayString = Array +>arrayString : String[] +>Array : T[] +>String : String + +type someArray = Array | number[]; +>someArray : someArray +>Array : T[] +>String : String + +type stringOrNumArray = Array; +>stringOrNumArray : (String | Number)[] +>Array : T[] +>String : String +>Number : Number + +function a1(...x: (number|string)[]) { } +>a1 : (...x: (string | number)[]) => void +>x : (string | number)[] + +function a2(...a) { } +>a2 : (...a: any[]) => void +>a : any[] + +function a3(...a: Array) { } +>a3 : (...a: String[]) => void +>a : String[] +>Array : T[] +>String : String + +function a4(...a: arrayString) { } +>a4 : (...a: String[]) => void +>a : String[] +>arrayString : String[] + +function a5(...a: stringOrNumArray) { } +>a5 : (...a: (String | Number)[]) => void +>a : (String | Number)[] +>stringOrNumArray : (String | Number)[] + +function a9([a, b, [[c]]]) { } +>a9 : ([a, b, [[c]]]: [any, any, [[any]]]) => void +>a : any +>b : any +>c : any + +function a10([a, b, [[c]], ...x]) { } +>a10 : ([a, b, [[c]], ...x]: any[]) => void +>a : any +>b : any +>c : any +>x : any[] + +function a11([a, b, c, ...x]: number[]) { } +>a11 : ([a, b, c, ...x]: number[]) => void +>a : number +>b : number +>c : number +>x : number[] + + +var array = [1, 2, 3]; +>array : number[] +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 + +var array2 = [true, false, "hello"]; +>array2 : (string | boolean)[] +>[true, false, "hello"] : (string | boolean)[] +>true : true +>false : false +>"hello" : "hello" + +a2([...array]); +>a2([...array]) : void +>a2 : (...a: any[]) => void +>[...array] : number[] +>...array : number +>array : number[] + +a1(...array); +>a1(...array) : void +>a1 : (...x: (string | number)[]) => void +>...array : number +>array : number[] + +a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]] +>a9([1, 2, [["string"]], false, true]) : void +>a9 : ([a, b, [[c]]]: [any, any, [[any]]]) => void +>[1, 2, [["string"]], false, true] : [number, number, [[string]], boolean, boolean] +>1 : 1 +>2 : 2 +>[["string"]] : [[string]] +>["string"] : [string] +>"string" : "string" +>false : false +>true : true + +a10([1, 2, [["string"]], false, true]); // Parameter type is any[] +>a10([1, 2, [["string"]], false, true]) : void +>a10 : ([a, b, [[c]], ...x]: any[]) => void +>[1, 2, [["string"]], false, true] : (number | boolean | string[][])[] +>1 : 1 +>2 : 2 +>[["string"]] : string[][] +>["string"] : string[] +>"string" : "string" +>false : false +>true : true + +a10([1, 2, 3, false, true]); // Parameter type is any[] +>a10([1, 2, 3, false, true]) : void +>a10 : ([a, b, [[c]], ...x]: any[]) => void +>[1, 2, 3, false, true] : (number | boolean)[] +>1 : 1 +>2 : 2 +>3 : 3 +>false : false +>true : true + +a10([1, 2]); // Parameter type is any[] +>a10([1, 2]) : void +>a10 : ([a, b, [[c]], ...x]: any[]) => void +>[1, 2] : number[] +>1 : 1 +>2 : 2 + +a11([1, 2]); // Parameter type is number[] +>a11([1, 2]) : void +>a11 : ([a, b, c, ...x]: number[]) => void +>[1, 2] : number[] +>1 : 1 +>2 : 2 + +// Rest parameter with generic +function foo(...a: T[]) { } +>foo : (...a: T[]) => void +>T : T +>a : T[] +>T : T + +foo("hello", 1, 2); +>foo("hello", 1, 2) : void +>foo : (...a: T[]) => void +>"hello" : "hello" +>1 : 1 +>2 : 2 + +foo("hello", "world"); +>foo("hello", "world") : void +>foo : (...a: T[]) => void +>"hello" : "hello" +>"world" : "world" + +enum E { a, b } +>E : E +>a : E.a +>b : E.b + +const enum E1 { a, b } +>E1 : E1 +>a : E1.a +>b : E1.b + +function foo1(...a: T[]) { } +>foo1 : (...a: T[]) => void +>T : T +>Number : Number +>a : T[] +>T : T + +foo1(1, 2, 3, E.a); +>foo1(1, 2, 3, E.a) : void +>foo1 : (...a: T[]) => void +>1 : 1 +>2 : 2 +>3 : 3 +>E.a : E.a +>E : typeof E +>a : E.a + +foo1(1, 2, 3, E1.a, E.b); +>foo1(1, 2, 3, E1.a, E.b) : void +>foo1 : (...a: T[]) => void +>1 : 1 +>2 : 2 +>3 : 3 +>E1.a : E1.a +>E1 : typeof E1 +>a : E1.a +>E.b : E.b +>E : typeof E +>b : E.b + + + diff --git a/tests/baselines/reference/destructuringParameterDeclaration5.js b/tests/baselines/reference/destructuringParameterDeclaration5.js index 7ba178823df..d2499528735 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration5.js +++ b/tests/baselines/reference/destructuringParameterDeclaration5.js @@ -52,11 +52,16 @@ d3({ y: "world" }); //// [destructuringParameterDeclaration5.js] // Parameter Declaration with generic -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Class = (function () { function Class() { } diff --git a/tests/baselines/reference/destructuringParameterDeclaration7ES5iterable.js b/tests/baselines/reference/destructuringParameterDeclaration7ES5iterable.js new file mode 100644 index 00000000000..818ea428c1d --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration7ES5iterable.js @@ -0,0 +1,43 @@ +//// [destructuringParameterDeclaration7ES5iterable.ts] + +interface ISomething { + foo: string, + bar: string +} + +function foo({}, {foo, bar}: ISomething) {} + +function baz([], {foo, bar}: ISomething) {} + +function one([], {}) {} + +function two([], [a, b, c]: number[]) {} + + +//// [destructuringParameterDeclaration7ES5iterable.js] +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +function foo(_a, _b) { + var foo = _b.foo, bar = _b.bar; +} +function baz(_a, _b) { + var foo = _b.foo, bar = _b.bar; +} +function one(_a, _b) { } +function two(_a, _b) { + var _c = __read(_b, 3), a = _c[0], b = _c[1], c = _c[2]; +} diff --git a/tests/baselines/reference/destructuringParameterDeclaration7ES5iterable.symbols b/tests/baselines/reference/destructuringParameterDeclaration7ES5iterable.symbols new file mode 100644 index 00000000000..0548f1247f6 --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration7ES5iterable.symbols @@ -0,0 +1,33 @@ +=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5iterable.ts === + +interface ISomething { +>ISomething : Symbol(ISomething, Decl(destructuringParameterDeclaration7ES5iterable.ts, 0, 0)) + + foo: string, +>foo : Symbol(ISomething.foo, Decl(destructuringParameterDeclaration7ES5iterable.ts, 1, 22)) + + bar: string +>bar : Symbol(ISomething.bar, Decl(destructuringParameterDeclaration7ES5iterable.ts, 2, 16)) +} + +function foo({}, {foo, bar}: ISomething) {} +>foo : Symbol(foo, Decl(destructuringParameterDeclaration7ES5iterable.ts, 4, 1)) +>foo : Symbol(foo, Decl(destructuringParameterDeclaration7ES5iterable.ts, 6, 18)) +>bar : Symbol(bar, Decl(destructuringParameterDeclaration7ES5iterable.ts, 6, 22)) +>ISomething : Symbol(ISomething, Decl(destructuringParameterDeclaration7ES5iterable.ts, 0, 0)) + +function baz([], {foo, bar}: ISomething) {} +>baz : Symbol(baz, Decl(destructuringParameterDeclaration7ES5iterable.ts, 6, 43)) +>foo : Symbol(foo, Decl(destructuringParameterDeclaration7ES5iterable.ts, 8, 18)) +>bar : Symbol(bar, Decl(destructuringParameterDeclaration7ES5iterable.ts, 8, 22)) +>ISomething : Symbol(ISomething, Decl(destructuringParameterDeclaration7ES5iterable.ts, 0, 0)) + +function one([], {}) {} +>one : Symbol(one, Decl(destructuringParameterDeclaration7ES5iterable.ts, 8, 43)) + +function two([], [a, b, c]: number[]) {} +>two : Symbol(two, Decl(destructuringParameterDeclaration7ES5iterable.ts, 10, 23)) +>a : Symbol(a, Decl(destructuringParameterDeclaration7ES5iterable.ts, 12, 18)) +>b : Symbol(b, Decl(destructuringParameterDeclaration7ES5iterable.ts, 12, 20)) +>c : Symbol(c, Decl(destructuringParameterDeclaration7ES5iterable.ts, 12, 23)) + diff --git a/tests/baselines/reference/destructuringParameterDeclaration7ES5iterable.types b/tests/baselines/reference/destructuringParameterDeclaration7ES5iterable.types new file mode 100644 index 00000000000..402ea7ac5e1 --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration7ES5iterable.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration7ES5iterable.ts === + +interface ISomething { +>ISomething : ISomething + + foo: string, +>foo : string + + bar: string +>bar : string +} + +function foo({}, {foo, bar}: ISomething) {} +>foo : ({}: {}, {foo, bar}: ISomething) => void +>foo : string +>bar : string +>ISomething : ISomething + +function baz([], {foo, bar}: ISomething) {} +>baz : ([]: any[], {foo, bar}: ISomething) => void +>foo : string +>bar : string +>ISomething : ISomething + +function one([], {}) {} +>one : ([]: any[], {}: {}) => void + +function two([], [a, b, c]: number[]) {} +>two : ([]: any[], [a, b, c]: number[]) => void +>a : number +>b : number +>c : number + diff --git a/tests/baselines/reference/destructuringPropertyAssignmentNameIsNotAssignmentTarget.js b/tests/baselines/reference/destructuringPropertyAssignmentNameIsNotAssignmentTarget.js new file mode 100644 index 00000000000..b2ba970ef51 --- /dev/null +++ b/tests/baselines/reference/destructuringPropertyAssignmentNameIsNotAssignmentTarget.js @@ -0,0 +1,17 @@ +//// [destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts] +// test for #10668 +function qux(bar: { value: number }) { + let foo: number; + ({ value: foo } = bar); + let x = () => bar; +} + + + +//// [destructuringPropertyAssignmentNameIsNotAssignmentTarget.js] +// test for #10668 +function qux(bar) { + var foo; + (foo = bar.value); + var x = function () { return bar; }; +} diff --git a/tests/baselines/reference/destructuringPropertyAssignmentNameIsNotAssignmentTarget.symbols b/tests/baselines/reference/destructuringPropertyAssignmentNameIsNotAssignmentTarget.symbols new file mode 100644 index 00000000000..b9ebe219f65 --- /dev/null +++ b/tests/baselines/reference/destructuringPropertyAssignmentNameIsNotAssignmentTarget.symbols @@ -0,0 +1,21 @@ +=== tests/cases/compiler/destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts === +// test for #10668 +function qux(bar: { value: number }) { +>qux : Symbol(qux, Decl(destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts, 0, 0)) +>bar : Symbol(bar, Decl(destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts, 1, 13)) +>value : Symbol(value, Decl(destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts, 1, 19)) + + let foo: number; +>foo : Symbol(foo, Decl(destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts, 2, 7)) + + ({ value: foo } = bar); +>value : Symbol(value, Decl(destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts, 3, 6)) +>foo : Symbol(foo, Decl(destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts, 2, 7)) +>bar : Symbol(bar, Decl(destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts, 1, 13)) + + let x = () => bar; +>x : Symbol(x, Decl(destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts, 4, 7)) +>bar : Symbol(bar, Decl(destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts, 1, 13)) +} + + diff --git a/tests/baselines/reference/destructuringPropertyAssignmentNameIsNotAssignmentTarget.types b/tests/baselines/reference/destructuringPropertyAssignmentNameIsNotAssignmentTarget.types new file mode 100644 index 00000000000..e0428fc959f --- /dev/null +++ b/tests/baselines/reference/destructuringPropertyAssignmentNameIsNotAssignmentTarget.types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/destructuringPropertyAssignmentNameIsNotAssignmentTarget.ts === +// test for #10668 +function qux(bar: { value: number }) { +>qux : (bar: { value: number; }) => void +>bar : { value: number; } +>value : number + + let foo: number; +>foo : number + + ({ value: foo } = bar); +>({ value: foo } = bar) : { value: number; } +>{ value: foo } = bar : { value: number; } +>{ value: foo } : { value: number; } +>value : number +>foo : number +>bar : { value: number; } + + let x = () => bar; +>x : () => { value: number; } +>() => bar : () => { value: number; } +>bar : { value: number; } +} + + diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5iterable.js b/tests/baselines/reference/destructuringVariableDeclaration1ES5iterable.js new file mode 100644 index 00000000000..83fb3de04fc --- /dev/null +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5iterable.js @@ -0,0 +1,97 @@ +//// [destructuringVariableDeclaration1ES5iterable.ts] +// The type T associated with a destructuring variable declaration is determined as follows: +// If the declaration includes a type annotation, T is that type. +var {a1, a2}: { a1: number, a2: string } = { a1: 10, a2: "world" } +var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; + +// The type T associated with a destructuring variable declaration is determined as follows: +// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. +var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; +var temp = { t1: true, t2: "false" }; +var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; +var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; + +// The type T associated with a binding element is determined as follows: +// If the binding element is a rest element, T is an array type with +// an element type E, where E is the type of the numeric index signature of S. +var [...c1] = [1,2,3]; +var [...c2] = [1,2,3, "string"]; + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Let N be the zero-based index of the binding element in the array binding pattern. +// If S has a property with the numerical name N, T is the type of that property. +var [d1,d2] = [1,"string"] + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Otherwise, if S has a numeric index signature, T is the type of the numeric index signature. +var temp1 = [true, false, true] +var [d3, d4] = [1, "string", ...temp1]; + +// Combining both forms of destructuring, +var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; +var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; + +// When a destructuring variable declaration, binding property, or binding element specifies +// an initializer expression, the type of the initializer expression is required to be assignable +// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. +var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; +var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } }; + + + +//// [destructuringVariableDeclaration1ES5iterable.js] +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spread = (this && this.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; +// The type T associated with a destructuring variable declaration is determined as follows: +// If the declaration includes a type annotation, T is that type. +var _a = { a1: 10, a2: "world" }, a1 = _a.a1, a2 = _a.a2; +var _b = __read([1, [["hello"]], true], 3), a3 = _b[0], _c = __read(_b[1], 1), _d = __read(_c[0], 1), a4 = _d[0], a5 = _b[2]; +// The type T associated with a destructuring variable declaration is determined as follows: +// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. +var _e = { b1: { b11: "world" } }.b1, b11 = (_e === void 0 ? { b11: "string" } : _e).b11; +var temp = { t1: true, t2: "false" }; +var _f = __read([3, false, { t1: false, t2: "hello" }], 3), _g = _f[0], b2 = _g === void 0 ? 3 : _g, _h = _f[1], b3 = _h === void 0 ? true : _h, _j = _f[2], b4 = _j === void 0 ? temp : _j; +var _k = __read([undefined, undefined, undefined], 3), _l = _k[0], b5 = _l === void 0 ? 3 : _l, _m = _k[1], b6 = _m === void 0 ? true : _m, _o = _k[2], b7 = _o === void 0 ? temp : _o; +// The type T associated with a binding element is determined as follows: +// If the binding element is a rest element, T is an array type with +// an element type E, where E is the type of the numeric index signature of S. +var _p = __read([1, 2, 3]), c1 = _p.slice(0); +var _q = __read([1, 2, 3, "string"]), c2 = _q.slice(0); +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Let N be the zero-based index of the binding element in the array binding pattern. +// If S has a property with the numerical name N, T is the type of that property. +var _r = __read([1, "string"], 2), d1 = _r[0], d2 = _r[1]; +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Otherwise, if S has a numeric index signature, T is the type of the numeric index signature. +var temp1 = [true, false, true]; +var _s = __read(__spread([1, "string"], temp1), 2), d3 = _s[0], d4 = _s[1]; +// Combining both forms of destructuring, +var _t = __read({ e: [1, 2, { b1: 4, b4: 0 }] }.e, 3), e1 = _t[0], e2 = _t[1], _u = _t[2], e3 = _u === void 0 ? { b1: 1000, b4: 200 } : _u; +var _v = __read({ f: [1, 2, { f3: 4, f5: 0 }] }.f, 4), f1 = _v[0], f2 = _v[1], _w = _v[2], f4 = _w.f3, f5 = _w.f5; +// When a destructuring variable declaration, binding property, or binding element specifies +// an initializer expression, the type of the initializer expression is required to be assignable +// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. +var _x = { g: { g1: [1, 2] } }.g.g1, g1 = _x === void 0 ? [undefined, null] : _x; +var _y = { h: { h1: [1, 2] } }.h.h1, h1 = _y === void 0 ? [undefined, null] : _y; diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5iterable.symbols b/tests/baselines/reference/destructuringVariableDeclaration1ES5iterable.symbols new file mode 100644 index 00000000000..b0ed4280cb6 --- /dev/null +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5iterable.symbols @@ -0,0 +1,120 @@ +=== tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration1ES5iterable.ts === +// The type T associated with a destructuring variable declaration is determined as follows: +// If the declaration includes a type annotation, T is that type. +var {a1, a2}: { a1: number, a2: string } = { a1: 10, a2: "world" } +>a1 : Symbol(a1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 2, 5)) +>a2 : Symbol(a2, Decl(destructuringVariableDeclaration1ES5iterable.ts, 2, 8)) +>a1 : Symbol(a1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 2, 15)) +>a2 : Symbol(a2, Decl(destructuringVariableDeclaration1ES5iterable.ts, 2, 27)) +>a1 : Symbol(a1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 2, 44)) +>a2 : Symbol(a2, Decl(destructuringVariableDeclaration1ES5iterable.ts, 2, 52)) + +var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; +>a3 : Symbol(a3, Decl(destructuringVariableDeclaration1ES5iterable.ts, 3, 5)) +>a4 : Symbol(a4, Decl(destructuringVariableDeclaration1ES5iterable.ts, 3, 11)) +>a5 : Symbol(a5, Decl(destructuringVariableDeclaration1ES5iterable.ts, 3, 16)) + +// The type T associated with a destructuring variable declaration is determined as follows: +// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. +var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; +>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 7, 44)) +>b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES5iterable.ts, 7, 11)) +>b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES5iterable.ts, 7, 21)) +>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 7, 44)) +>b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES5iterable.ts, 7, 50)) + +var temp = { t1: true, t2: "false" }; +>temp : Symbol(temp, Decl(destructuringVariableDeclaration1ES5iterable.ts, 8, 3)) +>t1 : Symbol(t1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 8, 12)) +>t2 : Symbol(t2, Decl(destructuringVariableDeclaration1ES5iterable.ts, 8, 22)) + +var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; +>b2 : Symbol(b2, Decl(destructuringVariableDeclaration1ES5iterable.ts, 9, 5)) +>b3 : Symbol(b3, Decl(destructuringVariableDeclaration1ES5iterable.ts, 9, 12)) +>b4 : Symbol(b4, Decl(destructuringVariableDeclaration1ES5iterable.ts, 9, 23)) +>temp : Symbol(temp, Decl(destructuringVariableDeclaration1ES5iterable.ts, 8, 3)) +>t1 : Symbol(t1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 9, 49)) +>t2 : Symbol(t2, Decl(destructuringVariableDeclaration1ES5iterable.ts, 9, 60)) + +var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; +>b5 : Symbol(b5, Decl(destructuringVariableDeclaration1ES5iterable.ts, 10, 5)) +>b6 : Symbol(b6, Decl(destructuringVariableDeclaration1ES5iterable.ts, 10, 12)) +>b7 : Symbol(b7, Decl(destructuringVariableDeclaration1ES5iterable.ts, 10, 23)) +>temp : Symbol(temp, Decl(destructuringVariableDeclaration1ES5iterable.ts, 8, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +// The type T associated with a binding element is determined as follows: +// If the binding element is a rest element, T is an array type with +// an element type E, where E is the type of the numeric index signature of S. +var [...c1] = [1,2,3]; +>c1 : Symbol(c1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 15, 5)) + +var [...c2] = [1,2,3, "string"]; +>c2 : Symbol(c2, Decl(destructuringVariableDeclaration1ES5iterable.ts, 16, 5)) + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Let N be the zero-based index of the binding element in the array binding pattern. +// If S has a property with the numerical name N, T is the type of that property. +var [d1,d2] = [1,"string"] +>d1 : Symbol(d1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 22, 5)) +>d2 : Symbol(d2, Decl(destructuringVariableDeclaration1ES5iterable.ts, 22, 8)) + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Otherwise, if S has a numeric index signature, T is the type of the numeric index signature. +var temp1 = [true, false, true] +>temp1 : Symbol(temp1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 27, 3)) + +var [d3, d4] = [1, "string", ...temp1]; +>d3 : Symbol(d3, Decl(destructuringVariableDeclaration1ES5iterable.ts, 28, 5)) +>d4 : Symbol(d4, Decl(destructuringVariableDeclaration1ES5iterable.ts, 28, 8)) +>temp1 : Symbol(temp1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 27, 3)) + +// Combining both forms of destructuring, +var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; +>e : Symbol(e, Decl(destructuringVariableDeclaration1ES5iterable.ts, 31, 49)) +>e1 : Symbol(e1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 31, 9)) +>e2 : Symbol(e2, Decl(destructuringVariableDeclaration1ES5iterable.ts, 31, 12)) +>e3 : Symbol(e3, Decl(destructuringVariableDeclaration1ES5iterable.ts, 31, 16)) +>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 31, 23)) +>b4 : Symbol(b4, Decl(destructuringVariableDeclaration1ES5iterable.ts, 31, 33)) +>e : Symbol(e, Decl(destructuringVariableDeclaration1ES5iterable.ts, 31, 49)) +>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 31, 61)) +>b4 : Symbol(b4, Decl(destructuringVariableDeclaration1ES5iterable.ts, 31, 68)) + +var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; +>f : Symbol(f, Decl(destructuringVariableDeclaration1ES5iterable.ts, 32, 41)) +>f1 : Symbol(f1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 32, 9)) +>f2 : Symbol(f2, Decl(destructuringVariableDeclaration1ES5iterable.ts, 32, 12)) +>f3 : Symbol(f3, Decl(destructuringVariableDeclaration1ES5iterable.ts, 32, 53)) +>f4 : Symbol(f4, Decl(destructuringVariableDeclaration1ES5iterable.ts, 32, 18)) +>f5 : Symbol(f5, Decl(destructuringVariableDeclaration1ES5iterable.ts, 32, 26)) +>f : Symbol(f, Decl(destructuringVariableDeclaration1ES5iterable.ts, 32, 41)) +>f3 : Symbol(f3, Decl(destructuringVariableDeclaration1ES5iterable.ts, 32, 53)) +>f5 : Symbol(f5, Decl(destructuringVariableDeclaration1ES5iterable.ts, 32, 60)) + +// When a destructuring variable declaration, binding property, or binding element specifies +// an initializer expression, the type of the initializer expression is required to be assignable +// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. +var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; +>g : Symbol(g, Decl(destructuringVariableDeclaration1ES5iterable.ts, 37, 36)) +>g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 37, 9)) +>undefined : Symbol(undefined) +>g : Symbol(g, Decl(destructuringVariableDeclaration1ES5iterable.ts, 37, 36)) +>g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 37, 41)) +>g : Symbol(g, Decl(destructuringVariableDeclaration1ES5iterable.ts, 37, 59)) +>g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 37, 64)) + +var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } }; +>h : Symbol(h, Decl(destructuringVariableDeclaration1ES5iterable.ts, 38, 36)) +>h1 : Symbol(h1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 38, 9)) +>undefined : Symbol(undefined) +>h : Symbol(h, Decl(destructuringVariableDeclaration1ES5iterable.ts, 38, 36)) +>h1 : Symbol(h1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 38, 41)) +>h : Symbol(h, Decl(destructuringVariableDeclaration1ES5iterable.ts, 38, 62)) +>h1 : Symbol(h1, Decl(destructuringVariableDeclaration1ES5iterable.ts, 38, 67)) + + diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5iterable.types b/tests/baselines/reference/destructuringVariableDeclaration1ES5iterable.types new file mode 100644 index 00000000000..6ef4c3d5749 --- /dev/null +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5iterable.types @@ -0,0 +1,200 @@ +=== tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration1ES5iterable.ts === +// The type T associated with a destructuring variable declaration is determined as follows: +// If the declaration includes a type annotation, T is that type. +var {a1, a2}: { a1: number, a2: string } = { a1: 10, a2: "world" } +>a1 : number +>a2 : string +>a1 : number +>a2 : string +>{ a1: 10, a2: "world" } : { a1: number; a2: string; } +>a1 : number +>10 : 10 +>a2 : string +>"world" : "world" + +var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; +>a3 : number +>a4 : string +>a5 : boolean +>[1, [["hello"]], true] : [number, [[string]], true] +>1 : 1 +>[["hello"]] : [[string]] +>["hello"] : [string] +>"hello" : "hello" +>true : true + +// The type T associated with a destructuring variable declaration is determined as follows: +// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. +var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; +>b1 : any +>b11 : string +>{ b11: "string" } : { b11: string; } +>b11 : string +>"string" : "string" +>{ b1: { b11: "world" } } : { b1?: { b11: string; }; } +>b1 : { b11: string; } +>{ b11: "world" } : { b11: string; } +>b11 : string +>"world" : "world" + +var temp = { t1: true, t2: "false" }; +>temp : { t1: boolean; t2: string; } +>{ t1: true, t2: "false" } : { t1: boolean; t2: string; } +>t1 : boolean +>true : true +>t2 : string +>"false" : "false" + +var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; +>b2 : number +>3 : 3 +>b3 : boolean +>true : true +>b4 : { t1: boolean; t2: string; } +>temp : { t1: boolean; t2: string; } +>[3, false, { t1: false, t2: "hello" }] : [number, false, { t1: false; t2: string; }] +>3 : 3 +>false : false +>{ t1: false, t2: "hello" } : { t1: false; t2: string; } +>t1 : boolean +>false : false +>t2 : string +>"hello" : "hello" + +var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; +>b5 : 3 +>3 : 3 +>b6 : true +>true : true +>b7 : { t1: boolean; t2: string; } +>temp : { t1: boolean; t2: string; } +>[undefined, undefined, undefined] : [undefined, undefined, undefined] +>undefined : undefined +>undefined : undefined +>undefined : undefined + +// The type T associated with a binding element is determined as follows: +// If the binding element is a rest element, T is an array type with +// an element type E, where E is the type of the numeric index signature of S. +var [...c1] = [1,2,3]; +>c1 : number[] +>[1,2,3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 + +var [...c2] = [1,2,3, "string"]; +>c2 : (string | number)[] +>[1,2,3, "string"] : (string | number)[] +>1 : 1 +>2 : 2 +>3 : 3 +>"string" : "string" + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Let N be the zero-based index of the binding element in the array binding pattern. +// If S has a property with the numerical name N, T is the type of that property. +var [d1,d2] = [1,"string"] +>d1 : number +>d2 : string +>[1,"string"] : [number, string] +>1 : 1 +>"string" : "string" + +// The type T associated with a binding element is determined as follows: +// Otherwise, if S is a tuple- like type (section 3.3.3): +// Otherwise, if S has a numeric index signature, T is the type of the numeric index signature. +var temp1 = [true, false, true] +>temp1 : boolean[] +>[true, false, true] : boolean[] +>true : true +>false : false +>true : true + +var [d3, d4] = [1, "string", ...temp1]; +>d3 : string | number | boolean +>d4 : string | number | boolean +>[1, "string", ...temp1] : (string | number | boolean)[] +>1 : 1 +>"string" : "string" +>...temp1 : boolean +>temp1 : boolean[] + +// Combining both forms of destructuring, +var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; +>e : any +>e1 : number +>e2 : number +>e3 : { b1: number; b4: number; } +>{ b1: 1000, b4: 200 } : { b1: number; b4: number; } +>b1 : number +>1000 : 1000 +>b4 : number +>200 : 200 +>{ e: [1, 2, { b1: 4, b4: 0 }] } : { e: [number, number, { b1: number; b4: number; }]; } +>e : [number, number, { b1: number; b4: number; }] +>[1, 2, { b1: 4, b4: 0 }] : [number, number, { b1: number; b4: number; }] +>1 : 1 +>2 : 2 +>{ b1: 4, b4: 0 } : { b1: number; b4: number; } +>b1 : number +>4 : 4 +>b4 : number +>0 : 0 + +var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; +>f : any +>f1 : number +>f2 : number +>f3 : any +>f4 : number +>f5 : number +> : undefined +>{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }, any]; } +>f : [number, number, { f3: number; f5: number; }, any] +>[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }, any] +>1 : 1 +>2 : 2 +>{ f3: 4, f5: 0 } : { f3: number; f5: number; } +>f3 : number +>4 : 4 +>f5 : number +>0 : 0 + +// When a destructuring variable declaration, binding property, or binding element specifies +// an initializer expression, the type of the initializer expression is required to be assignable +// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. +var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; +>g : any +>g1 : any[] +>[undefined, null] : null[] +>undefined : undefined +>null : null +>g : { g1: any[]; } +>g1 : any[] +>{ g: { g1: [1, 2] } } : { g: { g1: number[]; }; } +>g : { g1: number[]; } +>{ g1: [1, 2] } : { g1: number[]; } +>g1 : number[] +>[1, 2] : number[] +>1 : 1 +>2 : 2 + +var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } }; +>h : any +>h1 : number[] +>[undefined, null] : null[] +>undefined : undefined +>null : null +>h : { h1: number[]; } +>h1 : number[] +>{ h: { h1: [1, 2] } } : { h: { h1: number[]; }; } +>h : { h1: number[]; } +>{ h1: [1, 2] } : { h1: number[]; } +>h1 : number[] +>[1, 2] : number[] +>1 : 1 +>2 : 2 + + diff --git a/tests/baselines/reference/discriminantsAndPrimitives.types b/tests/baselines/reference/discriminantsAndPrimitives.types index d3e1b70e599..0870d17948f 100644 --- a/tests/baselines/reference/discriminantsAndPrimitives.types +++ b/tests/baselines/reference/discriminantsAndPrimitives.types @@ -30,7 +30,7 @@ function f1(x: Foo | Bar | string) { if (typeof x !== 'string') { >typeof x !== 'string' : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | Foo | Bar >'string' : "string" @@ -58,7 +58,7 @@ function f2(x: Foo | Bar | string | undefined) { if (typeof x === "object") { >typeof x === "object" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | Foo | Bar | undefined >"object" : "object" @@ -89,7 +89,7 @@ function f3(x: Foo | Bar | string | null) { >x && typeof x !== "string" : boolean | "" | null >x : string | Foo | Bar | null >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | Foo | Bar >"string" : "string" @@ -120,7 +120,7 @@ function f4(x: Foo | Bar | string | number | null) { >x && typeof x === "object" : boolean | "" | 0 | null >x : string | number | Foo | Bar | null >typeof x === "object" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | Foo | Bar >"object" : "object" diff --git a/tests/baselines/reference/discriminatedUnionErrorMessage.errors.txt b/tests/baselines/reference/discriminatedUnionErrorMessage.errors.txt new file mode 100644 index 00000000000..6f1eb511d37 --- /dev/null +++ b/tests/baselines/reference/discriminatedUnionErrorMessage.errors.txt @@ -0,0 +1,23 @@ +tests/cases/compiler/discriminatedUnionErrorMessage.ts(8,5): error TS2322: Type '{ kind: "sq"; x: number; y: number; }' is not assignable to type 'Shape'. + Type '{ kind: "sq"; x: number; y: number; }' is not assignable to type 'Square'. + Property 'size' is missing in type '{ kind: "sq"; x: number; y: number; }'. + + +==== tests/cases/compiler/discriminatedUnionErrorMessage.ts (1 errors) ==== + type Square = { kind: "sq", size: number } + type Rectangle = { kind: "rt", x: number, y: number } + type Circle = { kind: "cr", radius: number } + type Shape = + | Square + | Rectangle + | Circle; + let shape: Shape = { + ~~~~~ +!!! error TS2322: Type '{ kind: "sq"; x: number; y: number; }' is not assignable to type 'Shape'. +!!! error TS2322: Type '{ kind: "sq"; x: number; y: number; }' is not assignable to type 'Square'. +!!! error TS2322: Property 'size' is missing in type '{ kind: "sq"; x: number; y: number; }'. + kind: "sq", + x: 12, + y: 13, + } + \ No newline at end of file diff --git a/tests/baselines/reference/discriminatedUnionErrorMessage.js b/tests/baselines/reference/discriminatedUnionErrorMessage.js new file mode 100644 index 00000000000..10c94b19a44 --- /dev/null +++ b/tests/baselines/reference/discriminatedUnionErrorMessage.js @@ -0,0 +1,21 @@ +//// [discriminatedUnionErrorMessage.ts] +type Square = { kind: "sq", size: number } +type Rectangle = { kind: "rt", x: number, y: number } +type Circle = { kind: "cr", radius: number } +type Shape = + | Square + | Rectangle + | Circle; +let shape: Shape = { + kind: "sq", + x: 12, + y: 13, +} + + +//// [discriminatedUnionErrorMessage.js] +var shape = { + kind: "sq", + x: 12, + y: 13 +}; diff --git a/tests/baselines/reference/downlevelLetConst13.js b/tests/baselines/reference/downlevelLetConst13.js index b6baf850800..324c0cd9293 100644 --- a/tests/baselines/reference/downlevelLetConst13.js +++ b/tests/baselines/reference/downlevelLetConst13.js @@ -21,6 +21,7 @@ export module M { //// [downlevelLetConst13.js] 'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); // exported let\const bindings should not be renamed exports.foo = 10; exports.bar = "123"; diff --git a/tests/baselines/reference/duplicateLocalVariable1.js b/tests/baselines/reference/duplicateLocalVariable1.js index 734b01eaed7..c1417de9dfe 100644 --- a/tests/baselines/reference/duplicateLocalVariable1.js +++ b/tests/baselines/reference/duplicateLocalVariable1.js @@ -347,6 +347,7 @@ export var tests: TestRunner = (function () { //// [duplicateLocalVariable1.js] "use strict"; +exports.__esModule = true; / /; commonjs; var TestFileDir = ".\\TempTestFiles"; @@ -391,6 +392,7 @@ var TestRunner = (function () { } } if (testResult === false) { + //console.log(e.message); } } if ((testcase.errorMessageRegEx !== undefined) && !exception) { diff --git a/tests/baselines/reference/duplicateLocalVariable2.js b/tests/baselines/reference/duplicateLocalVariable2.js index d6f5c26d628..2962e544b9b 100644 --- a/tests/baselines/reference/duplicateLocalVariable2.js +++ b/tests/baselines/reference/duplicateLocalVariable2.js @@ -38,6 +38,7 @@ export var tests: TestRunner = (function () { //// [duplicateLocalVariable2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var TestCase = (function () { function TestCase(name, test, errorMessageRegEx) { this.name = name; diff --git a/tests/baselines/reference/duplicateStringNamedProperty1.js b/tests/baselines/reference/duplicateStringNamedProperty1.js index 102fba9c3d6..5a6d5d7a8db 100644 --- a/tests/baselines/reference/duplicateStringNamedProperty1.js +++ b/tests/baselines/reference/duplicateStringNamedProperty1.js @@ -6,3 +6,4 @@ export interface Album { //// [duplicateStringNamedProperty1.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/duplicateSymbolsExportMatching.js b/tests/baselines/reference/duplicateSymbolsExportMatching.js index 9f977f5fd58..5f5590e2b41 100644 --- a/tests/baselines/reference/duplicateSymbolsExportMatching.js +++ b/tests/baselines/reference/duplicateSymbolsExportMatching.js @@ -68,6 +68,7 @@ export interface D { } //// [duplicateSymbolsExportMatching.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; // Should report error only once for instantiated module var M; (function (M) { diff --git a/tests/baselines/reference/dynamicModuleTypecheckError.js b/tests/baselines/reference/dynamicModuleTypecheckError.js index ef39270c9d1..2c94e692dd0 100644 --- a/tests/baselines/reference/dynamicModuleTypecheckError.js +++ b/tests/baselines/reference/dynamicModuleTypecheckError.js @@ -10,6 +10,7 @@ for(var i = 0; i < 30; i++) { //// [dynamicModuleTypecheckError.js] "use strict"; +exports.__esModule = true; exports.x = 1; for (var i = 0; i < 30; i++) { exports.x = i * 1000; // should not be an error here diff --git a/tests/baselines/reference/elidingImportNames.js b/tests/baselines/reference/elidingImportNames.js index 94fa1f7e852..f878c5044ea 100644 --- a/tests/baselines/reference/elidingImportNames.js +++ b/tests/baselines/reference/elidingImportNames.js @@ -17,12 +17,15 @@ export var main = 10; //// [elidingImportNames_main.js] "use strict"; +exports.__esModule = true; exports.main = 10; //// [elidingImportNames_main1.js] "use strict"; +exports.__esModule = true; exports.main = 10; //// [elidingImportNames_test.js] "use strict"; +exports.__esModule = true; var a = require("./elidingImportNames_main"); // alias used in typeof var b = a; var x; diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types index 94a5f2173aa..32e5b33e411 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types @@ -1,8 +1,8 @@ === tests/cases/conformance/es7/exponentiationOperator/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts === var object = { ->object : { 0: number; _0: number; } ->{ _0: 2, get 0() { return this._0; }, set 0(x: number) { this._0 = x; },} : { 0: number; _0: number; } +>object : { _0: number; 0: number; } +>{ _0: 2, get 0() { return this._0; }, set 0(x: number) { this._0 = x; },} : { _0: number; 0: number; } _0: 2, >_0 : number @@ -30,31 +30,31 @@ var object = { object[0] **= object[0]; >object[0] **= object[0] : number >object[0] : number ->object : { 0: number; _0: number; } +>object : { _0: number; 0: number; } >0 : 0 >object[0] : number ->object : { 0: number; _0: number; } +>object : { _0: number; 0: number; } >0 : 0 object[0] **= object[0] **= 2; >object[0] **= object[0] **= 2 : number >object[0] : number ->object : { 0: number; _0: number; } +>object : { _0: number; 0: number; } >0 : 0 >object[0] **= 2 : number >object[0] : number ->object : { 0: number; _0: number; } +>object : { _0: number; 0: number; } >0 : 0 >2 : 2 object[0] **= object[0] ** 2; >object[0] **= object[0] ** 2 : number >object[0] : number ->object : { 0: number; _0: number; } +>object : { _0: number; 0: number; } >0 : 0 >object[0] ** 2 : number >object[0] : number ->object : { 0: number; _0: number; } +>object : { _0: number; 0: number; } >0 : 0 >2 : 2 diff --git a/tests/baselines/reference/emitExponentiationOperator4.errors.txt b/tests/baselines/reference/emitExponentiationOperator4.errors.txt new file mode 100644 index 00000000000..e8f46874ad8 --- /dev/null +++ b/tests/baselines/reference/emitExponentiationOperator4.errors.txt @@ -0,0 +1,70 @@ +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(14,1): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(15,1): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(16,1): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(17,1): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(18,1): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(21,6): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(22,6): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(23,6): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(24,6): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts(25,6): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/es7/exponentiationOperator/emitExponentiationOperator4.ts (10 errors) ==== + var temp: any; + + (temp) ** 3; + (--temp) ** 3; + (++temp) ** 3; + (temp--) ** 3; + (temp++) ** 3; + + 1 ** (--temp) ** 3; + 1 ** (++temp) ** 3; + 1 ** (temp--) ** 3; + 1 ** (temp++) ** 3; + + (void --temp) ** 3; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + (void temp--) ** 3; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + (void 3) ** 4; + ~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + (void temp++) ** 4; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + (void temp--) ** 4; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + + 1 ** (void --temp) ** 3; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + 1 ** (void temp--) ** 3; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + 1 ** (void 3) ** 4; + ~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + 1 ** (void temp++) ** 4; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + 1 ** (void temp--) ** 4; + ~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + (~ --temp) ** 3; + (~ temp--) ** 3; + (~ 3) ** 4; + (~ temp++) ** 4; + (~ temp--) ** 4; + + 1 ** (~ --temp) ** 3; + 1 ** (~ temp--) ** 3; + 1 ** (~ 3) ** 4; + 1 ** (~ temp++) ** 4; + 1 ** (~ temp--) ** 4; \ No newline at end of file diff --git a/tests/baselines/reference/emitExponentiationOperatorInTempalteString4.types b/tests/baselines/reference/emitExponentiationOperatorInTempalteString4.types index 7991ef224f0..d11846227f2 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTempalteString4.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTempalteString4.types @@ -64,7 +64,7 @@ var s; `${typeof (t1 ** t2 ** t1) } world`; >`${typeof (t1 ** t2 ** t1) } world` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -162,14 +162,14 @@ var s; `${typeof (t1 ** t2 ** t1)} hello world ${typeof (t1 ** t2 ** t1)}`; >`${typeof (t1 ** t2 ** t1)} hello world ${typeof (t1 ** t2 ** t1)}` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -223,7 +223,7 @@ var s; `hello ${typeof (t1 ** t2 ** t1)}`; >`hello ${typeof (t1 ** t2 ** t1)}` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTempalteString4ES6.types b/tests/baselines/reference/emitExponentiationOperatorInTempalteString4ES6.types index 981829dd42b..610c3a64a6e 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTempalteString4ES6.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTempalteString4ES6.types @@ -64,7 +64,7 @@ var s; `${typeof (t1 ** t2 ** t1) } world`; >`${typeof (t1 ** t2 ** t1) } world` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -162,14 +162,14 @@ var s; `${typeof (t1 ** t2 ** t1)} hello world ${typeof (t1 ** t2 ** t1)}`; >`${typeof (t1 ** t2 ** t1)} hello world ${typeof (t1 ** t2 ** t1)}` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -223,7 +223,7 @@ var s; `hello ${typeof (t1 ** t2 ** t1)}`; >`hello ${typeof (t1 ** t2 ** t1)}` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTemplateString1.types b/tests/baselines/reference/emitExponentiationOperatorInTemplateString1.types index bbfb5b88e04..4f78cd61fcc 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTemplateString1.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTemplateString1.types @@ -54,7 +54,7 @@ var s; `${typeof (t1 ** t2 ** t1) }`; >`${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -66,7 +66,7 @@ var s; >`${1 + typeof (t1 ** t2 ** t1) }` : string >1 + typeof (t1 ** t2 ** t1) : string >1 : 1 ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -141,14 +141,14 @@ var s; `${typeof (t1 ** t2 ** t1)}${typeof (t1 ** t2 ** t1)}`; >`${typeof (t1 ** t2 ** t1)}${typeof (t1 ** t2 ** t1)}` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -223,14 +223,14 @@ var s; `${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1) }`; >`${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTemplateString1ES6.types b/tests/baselines/reference/emitExponentiationOperatorInTemplateString1ES6.types index a005dd07463..0bc65c31b12 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTemplateString1ES6.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTemplateString1ES6.types @@ -54,7 +54,7 @@ var s; `${typeof (t1 ** t2 ** t1) }`; >`${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -66,7 +66,7 @@ var s; >`${1 + typeof (t1 ** t2 ** t1) }` : string >1 + typeof (t1 ** t2 ** t1) : string >1 : 1 ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -141,14 +141,14 @@ var s; `${typeof (t1 ** t2 ** t1)}${typeof (t1 ** t2 ** t1)}`; >`${typeof (t1 ** t2 ** t1)}${typeof (t1 ** t2 ** t1)}` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -223,14 +223,14 @@ var s; `${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1) }`; >`${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTemplateString2.types b/tests/baselines/reference/emitExponentiationOperatorInTemplateString2.types index 156851b60b9..9b77f4bc3fc 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTemplateString2.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTemplateString2.types @@ -54,7 +54,7 @@ var s; `hello ${typeof (t1 ** t2 ** t1) }`; >`hello ${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -66,7 +66,7 @@ var s; >`hello ${1 + typeof (t1 ** t2 ** t1) }` : string >1 + typeof (t1 ** t2 ** t1) : string >1 : 1 ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -141,14 +141,14 @@ var s; `hello ${typeof (t1 ** t2 ** t1) }${typeof (t1 ** t2 ** t1) }`; >`hello ${typeof (t1 ** t2 ** t1) }${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -223,14 +223,14 @@ var s; `hello ${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1) }`; >`hello ${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTemplateString2ES6.types b/tests/baselines/reference/emitExponentiationOperatorInTemplateString2ES6.types index dbeee05554e..ed0be973e5b 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTemplateString2ES6.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTemplateString2ES6.types @@ -54,7 +54,7 @@ var s; `hello ${typeof (t1 ** t2 ** t1) }`; >`hello ${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -66,7 +66,7 @@ var s; >`hello ${1 + typeof (t1 ** t2 ** t1) }` : string >1 + typeof (t1 ** t2 ** t1) : string >1 : 1 ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -141,14 +141,14 @@ var s; `hello ${typeof (t1 ** t2 ** t1) }${typeof (t1 ** t2 ** t1) }`; >`hello ${typeof (t1 ** t2 ** t1) }${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -223,14 +223,14 @@ var s; `hello ${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1) }`; >`hello ${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTemplateString3.types b/tests/baselines/reference/emitExponentiationOperatorInTemplateString3.types index d3472beac12..16fe31dde5e 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTemplateString3.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTemplateString3.types @@ -54,7 +54,7 @@ var s; `${typeof (t1 ** t2 ** t1) } world`; >`${typeof (t1 ** t2 ** t1) } world` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -66,7 +66,7 @@ var s; >`${1 + typeof (t1 ** t2 ** t1) } world` : string >1 + typeof (t1 ** t2 ** t1) : string >1 : 1 ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -141,14 +141,14 @@ var s; `${typeof (t1 ** t2 ** t1) }${typeof (t1 ** t2 ** t1) } world`; >`${typeof (t1 ** t2 ** t1) }${typeof (t1 ** t2 ** t1) } world` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -223,14 +223,14 @@ var s; `${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1)} !!`; >`${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1)} !!` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTemplateString3ES6.types b/tests/baselines/reference/emitExponentiationOperatorInTemplateString3ES6.types index 239ef02a529..86eb42efc05 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTemplateString3ES6.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTemplateString3ES6.types @@ -54,7 +54,7 @@ var s; `${typeof (t1 ** t2 ** t1) } world`; >`${typeof (t1 ** t2 ** t1) } world` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -66,7 +66,7 @@ var s; >`${1 + typeof (t1 ** t2 ** t1) } world` : string >1 + typeof (t1 ** t2 ** t1) : string >1 : 1 ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -141,14 +141,14 @@ var s; `${typeof (t1 ** t2 ** t1) }${typeof (t1 ** t2 ** t1) } world`; >`${typeof (t1 ** t2 ** t1) }${typeof (t1 ** t2 ** t1) } world` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -223,14 +223,14 @@ var s; `${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1)} !!`; >`${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1)} !!` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js index 05b061116d3..3a8bbdb0c73 100644 --- a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js +++ b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js @@ -14,11 +14,16 @@ class B extends A { //// [emitSuperCallBeforeEmitParameterPropertyDeclaration1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { this.blub = 6; diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.js b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.js index 2cf2cb02073..d8145f6dc27 100644 --- a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.js +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.js @@ -16,11 +16,16 @@ class B extends A { } //// [emitSuperCallBeforeEmitPropertyDeclaration1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { this.blub = 6; diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js index eaa52e39285..75c618d84db 100644 --- a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js @@ -14,11 +14,16 @@ class B extends A { } //// [emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { this.blub = 6; diff --git a/tests/baselines/reference/emitThisInSuperMethodCall.js b/tests/baselines/reference/emitThisInSuperMethodCall.js index 1f7ed8bfa94..2d800d562c2 100644 --- a/tests/baselines/reference/emitThisInSuperMethodCall.js +++ b/tests/baselines/reference/emitThisInSuperMethodCall.js @@ -28,11 +28,16 @@ class RegisteredUser extends User { //// [emitThisInSuperMethodCall.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var User = (function () { function User() { } @@ -43,7 +48,7 @@ var User = (function () { var RegisteredUser = (function (_super) { __extends(RegisteredUser, _super); function RegisteredUser() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } RegisteredUser.prototype.f = function () { (function () { diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.js b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.js new file mode 100644 index 00000000000..ba4902102b1 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.js @@ -0,0 +1,266 @@ +//// [tests/cases/conformance/emitter/es2015/asyncGenerators/emitter.asyncGenerators.classMethods.es2015.ts] //// + +//// [C1.ts] +class C1 { + async * f() { + } +} +//// [C2.ts] +class C2 { + async * f() { + const x = yield; + } +} +//// [C3.ts] +class C3 { + async * f() { + const x = yield 1; + } +} +//// [C4.ts] +class C4 { + async * f() { + const x = yield* [1]; + } +} +//// [C5.ts] +class C5 { + async * f() { + const x = yield* (async function*() { yield 1; })(); + } +} +//// [C6.ts] +class C6 { + async * f() { + const x = await 1; + } +} +//// [C7.ts] +class C7 { + async * f() { + return 1; + } +} +//// [C8.ts] +class C8 { + g() { + } + async * f() { + this.g(); + } +} +//// [C9.ts] +class B9 { + g() {} +} +class C9 extends B9 { + async * f() { + super.g(); + } +} + + +//// [C1.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +class C1 { + f() { + return __asyncGenerator(this, arguments, function* f_1() { + }); + } +} +//// [C2.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +class C2 { + f() { + return __asyncGenerator(this, arguments, function* f_1() { + const x = yield ["yield"]; + }); + } +} +//// [C3.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +class C3 { + f() { + return __asyncGenerator(this, arguments, function* f_1() { + const x = yield ["yield", 1]; + }); + } +} +//// [C4.js] +var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +class C4 { + f() { + return __asyncGenerator(this, arguments, function* f_1() { + const x = yield* __asyncDelegator([1]); + }); + } +} +//// [C5.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } +}; +class C5 { + f() { + return __asyncGenerator(this, arguments, function* f_1() { + const x = yield* __asyncDelegator((function () { return __asyncGenerator(this, arguments, function* () { yield ["yield", 1]; }); })()); + }); + } +} +//// [C6.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +class C6 { + f() { + return __asyncGenerator(this, arguments, function* f_1() { + const x = yield ["await", 1]; + }); + } +} +//// [C7.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +class C7 { + f() { + return __asyncGenerator(this, arguments, function* f_1() { + return 1; + }); + } +} +//// [C8.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +class C8 { + g() { + } + f() { + return __asyncGenerator(this, arguments, function* f_1() { + this.g(); + }); + } +} +//// [C9.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +class B9 { + g() { } +} +class C9 extends B9 { + f() { + const _super = name => super[name]; + return __asyncGenerator(this, arguments, function* f_1() { + _super("g").call(this); + }); + } +} diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.symbols b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.symbols new file mode 100644 index 00000000000..5db32d5c4d8 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.symbols @@ -0,0 +1,110 @@ +=== tests/cases/conformance/emitter/es2015/asyncGenerators/C1.ts === +class C1 { +>C1 : Symbol(C1, Decl(C1.ts, 0, 0)) + + async * f() { +>f : Symbol(C1.f, Decl(C1.ts, 0, 10)) + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/C2.ts === +class C2 { +>C2 : Symbol(C2, Decl(C2.ts, 0, 0)) + + async * f() { +>f : Symbol(C2.f, Decl(C2.ts, 0, 10)) + + const x = yield; +>x : Symbol(x, Decl(C2.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/C3.ts === +class C3 { +>C3 : Symbol(C3, Decl(C3.ts, 0, 0)) + + async * f() { +>f : Symbol(C3.f, Decl(C3.ts, 0, 10)) + + const x = yield 1; +>x : Symbol(x, Decl(C3.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/C4.ts === +class C4 { +>C4 : Symbol(C4, Decl(C4.ts, 0, 0)) + + async * f() { +>f : Symbol(C4.f, Decl(C4.ts, 0, 10)) + + const x = yield* [1]; +>x : Symbol(x, Decl(C4.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/C5.ts === +class C5 { +>C5 : Symbol(C5, Decl(C5.ts, 0, 0)) + + async * f() { +>f : Symbol(C5.f, Decl(C5.ts, 0, 10)) + + const x = yield* (async function*() { yield 1; })(); +>x : Symbol(x, Decl(C5.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/C6.ts === +class C6 { +>C6 : Symbol(C6, Decl(C6.ts, 0, 0)) + + async * f() { +>f : Symbol(C6.f, Decl(C6.ts, 0, 10)) + + const x = await 1; +>x : Symbol(x, Decl(C6.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/C7.ts === +class C7 { +>C7 : Symbol(C7, Decl(C7.ts, 0, 0)) + + async * f() { +>f : Symbol(C7.f, Decl(C7.ts, 0, 10)) + + return 1; + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/C8.ts === +class C8 { +>C8 : Symbol(C8, Decl(C8.ts, 0, 0)) + + g() { +>g : Symbol(C8.g, Decl(C8.ts, 0, 10)) + } + async * f() { +>f : Symbol(C8.f, Decl(C8.ts, 2, 5)) + + this.g(); +>this.g : Symbol(C8.g, Decl(C8.ts, 0, 10)) +>this : Symbol(C8, Decl(C8.ts, 0, 0)) +>g : Symbol(C8.g, Decl(C8.ts, 0, 10)) + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/C9.ts === +class B9 { +>B9 : Symbol(B9, Decl(C9.ts, 0, 0)) + + g() {} +>g : Symbol(B9.g, Decl(C9.ts, 0, 10)) +} +class C9 extends B9 { +>C9 : Symbol(C9, Decl(C9.ts, 2, 1)) +>B9 : Symbol(B9, Decl(C9.ts, 0, 0)) + + async * f() { +>f : Symbol(C9.f, Decl(C9.ts, 3, 21)) + + super.g(); +>super.g : Symbol(B9.g, Decl(C9.ts, 0, 10)) +>super : Symbol(B9, Decl(C9.ts, 0, 0)) +>g : Symbol(B9.g, Decl(C9.ts, 0, 10)) + } +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types new file mode 100644 index 00000000000..524f7c9b71b --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types @@ -0,0 +1,127 @@ +=== tests/cases/conformance/emitter/es2015/asyncGenerators/C1.ts === +class C1 { +>C1 : C1 + + async * f() { +>f : () => AsyncIterableIterator + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/C2.ts === +class C2 { +>C2 : C2 + + async * f() { +>f : () => AsyncIterableIterator + + const x = yield; +>x : any +>yield : any + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/C3.ts === +class C3 { +>C3 : C3 + + async * f() { +>f : () => AsyncIterableIterator<1> + + const x = yield 1; +>x : any +>yield 1 : any +>1 : 1 + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/C4.ts === +class C4 { +>C4 : C4 + + async * f() { +>f : () => AsyncIterableIterator + + const x = yield* [1]; +>x : any +>yield* [1] : any +>[1] : number[] +>1 : 1 + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/C5.ts === +class C5 { +>C5 : C5 + + async * f() { +>f : () => AsyncIterableIterator<1> + + const x = yield* (async function*() { yield 1; })(); +>x : any +>yield* (async function*() { yield 1; })() : any +>(async function*() { yield 1; })() : AsyncIterableIterator<1> +>(async function*() { yield 1; }) : () => AsyncIterableIterator<1> +>async function*() { yield 1; } : () => AsyncIterableIterator<1> +>yield 1 : any +>1 : 1 + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/C6.ts === +class C6 { +>C6 : C6 + + async * f() { +>f : () => AsyncIterableIterator + + const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/C7.ts === +class C7 { +>C7 : C7 + + async * f() { +>f : () => AsyncIterableIterator + + return 1; +>1 : 1 + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/C8.ts === +class C8 { +>C8 : C8 + + g() { +>g : () => void + } + async * f() { +>f : () => AsyncIterableIterator + + this.g(); +>this.g() : void +>this.g : () => void +>this : this +>g : () => void + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/C9.ts === +class B9 { +>B9 : B9 + + g() {} +>g : () => void +} +class C9 extends B9 { +>C9 : C9 +>B9 : B9 + + async * f() { +>f : () => AsyncIterableIterator + + super.g(); +>super.g() : void +>super.g : () => void +>super : B9 +>g : () => void + } +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.js b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.js new file mode 100644 index 00000000000..74a65673e5a --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.js @@ -0,0 +1,628 @@ +//// [tests/cases/conformance/emitter/es5/asyncGenerators/emitter.asyncGenerators.classMethods.es5.ts] //// + +//// [C1.ts] +class C1 { + async * f() { + } +} +//// [C2.ts] +class C2 { + async * f() { + const x = yield; + } +} +//// [C3.ts] +class C3 { + async * f() { + const x = yield 1; + } +} +//// [C4.ts] +class C4 { + async * f() { + const x = yield* [1]; + } +} +//// [C5.ts] +class C5 { + async * f() { + const x = yield* (async function*() { yield 1; })(); + } +} +//// [C6.ts] +class C6 { + async * f() { + const x = await 1; + } +} +//// [C7.ts] +class C7 { + async * f() { + return 1; + } +} +//// [C8.ts] +class C8 { + g() { + } + async * f() { + this.g(); + } +} +//// [C9.ts] +class B9 { + g() {} +} +class C9 extends B9 { + async * f() { + super.g(); + } +} + + +//// [C1.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var C1 = (function () { + function C1() { + } + C1.prototype.f = function () { + return __asyncGenerator(this, arguments, function f_1() { + return __generator(this, function (_a) { + return [2 /*return*/]; + }); + }); + }; + return C1; +}()); +//// [C2.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var C2 = (function () { + function C2() { + } + C2.prototype.f = function () { + return __asyncGenerator(this, arguments, function f_1() { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, ["yield"]]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); + }; + return C2; +}()); +//// [C3.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var C3 = (function () { + function C3() { + } + C3.prototype.f = function () { + return __asyncGenerator(this, arguments, function f_1() { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, ["yield", 1]]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); + }; + return C3; +}()); +//// [C4.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var __values = (this && this.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; +var C4 = (function () { + function C4() { + } + C4.prototype.f = function () { + return __asyncGenerator(this, arguments, function f_1() { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [5 /*yield**/, __values(__asyncDelegator([1]))]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); + }; + return C4; +}()); +//// [C5.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } +}; +var __values = (this && this.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; +var C5 = (function () { + function C5() { + } + C5.prototype.f = function () { + return __asyncGenerator(this, arguments, function f_1() { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [5 /*yield**/, __values(__asyncDelegator((function () { return __asyncGenerator(this, arguments, function () { return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, ["yield", 1]]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); }); })()))]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); + }; + return C5; +}()); +//// [C6.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var C6 = (function () { + function C6() { + } + C6.prototype.f = function () { + return __asyncGenerator(this, arguments, function f_1() { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, ["await", 1]]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); + }; + return C6; +}()); +//// [C7.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var C7 = (function () { + function C7() { + } + C7.prototype.f = function () { + return __asyncGenerator(this, arguments, function f_1() { + return __generator(this, function (_a) { + return [2 /*return*/, 1]; + }); + }); + }; + return C7; +}()); +//// [C8.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var C8 = (function () { + function C8() { + } + C8.prototype.g = function () { + }; + C8.prototype.f = function () { + return __asyncGenerator(this, arguments, function f_1() { + return __generator(this, function (_a) { + this.g(); + return [2 /*return*/]; + }); + }); + }; + return C8; +}()); +//// [C9.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var B9 = (function () { + function B9() { + } + B9.prototype.g = function () { }; + return B9; +}()); +var C9 = (function (_super) { + __extends(C9, _super); + function C9() { + return _super !== null && _super.apply(this, arguments) || this; + } + C9.prototype.f = function () { + return __asyncGenerator(this, arguments, function f_1() { + return __generator(this, function (_a) { + _super.prototype.g.call(this); + return [2 /*return*/]; + }); + }); + }; + return C9; +}(B9)); diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.symbols b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.symbols new file mode 100644 index 00000000000..de82f07faac --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.symbols @@ -0,0 +1,110 @@ +=== tests/cases/conformance/emitter/es5/asyncGenerators/C1.ts === +class C1 { +>C1 : Symbol(C1, Decl(C1.ts, 0, 0)) + + async * f() { +>f : Symbol(C1.f, Decl(C1.ts, 0, 10)) + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/C2.ts === +class C2 { +>C2 : Symbol(C2, Decl(C2.ts, 0, 0)) + + async * f() { +>f : Symbol(C2.f, Decl(C2.ts, 0, 10)) + + const x = yield; +>x : Symbol(x, Decl(C2.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/C3.ts === +class C3 { +>C3 : Symbol(C3, Decl(C3.ts, 0, 0)) + + async * f() { +>f : Symbol(C3.f, Decl(C3.ts, 0, 10)) + + const x = yield 1; +>x : Symbol(x, Decl(C3.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/C4.ts === +class C4 { +>C4 : Symbol(C4, Decl(C4.ts, 0, 0)) + + async * f() { +>f : Symbol(C4.f, Decl(C4.ts, 0, 10)) + + const x = yield* [1]; +>x : Symbol(x, Decl(C4.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/C5.ts === +class C5 { +>C5 : Symbol(C5, Decl(C5.ts, 0, 0)) + + async * f() { +>f : Symbol(C5.f, Decl(C5.ts, 0, 10)) + + const x = yield* (async function*() { yield 1; })(); +>x : Symbol(x, Decl(C5.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/C6.ts === +class C6 { +>C6 : Symbol(C6, Decl(C6.ts, 0, 0)) + + async * f() { +>f : Symbol(C6.f, Decl(C6.ts, 0, 10)) + + const x = await 1; +>x : Symbol(x, Decl(C6.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/C7.ts === +class C7 { +>C7 : Symbol(C7, Decl(C7.ts, 0, 0)) + + async * f() { +>f : Symbol(C7.f, Decl(C7.ts, 0, 10)) + + return 1; + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/C8.ts === +class C8 { +>C8 : Symbol(C8, Decl(C8.ts, 0, 0)) + + g() { +>g : Symbol(C8.g, Decl(C8.ts, 0, 10)) + } + async * f() { +>f : Symbol(C8.f, Decl(C8.ts, 2, 5)) + + this.g(); +>this.g : Symbol(C8.g, Decl(C8.ts, 0, 10)) +>this : Symbol(C8, Decl(C8.ts, 0, 0)) +>g : Symbol(C8.g, Decl(C8.ts, 0, 10)) + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/C9.ts === +class B9 { +>B9 : Symbol(B9, Decl(C9.ts, 0, 0)) + + g() {} +>g : Symbol(B9.g, Decl(C9.ts, 0, 10)) +} +class C9 extends B9 { +>C9 : Symbol(C9, Decl(C9.ts, 2, 1)) +>B9 : Symbol(B9, Decl(C9.ts, 0, 0)) + + async * f() { +>f : Symbol(C9.f, Decl(C9.ts, 3, 21)) + + super.g(); +>super.g : Symbol(B9.g, Decl(C9.ts, 0, 10)) +>super : Symbol(B9, Decl(C9.ts, 0, 0)) +>g : Symbol(B9.g, Decl(C9.ts, 0, 10)) + } +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types new file mode 100644 index 00000000000..c20e0d35010 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types @@ -0,0 +1,127 @@ +=== tests/cases/conformance/emitter/es5/asyncGenerators/C1.ts === +class C1 { +>C1 : C1 + + async * f() { +>f : () => AsyncIterableIterator + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/C2.ts === +class C2 { +>C2 : C2 + + async * f() { +>f : () => AsyncIterableIterator + + const x = yield; +>x : any +>yield : any + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/C3.ts === +class C3 { +>C3 : C3 + + async * f() { +>f : () => AsyncIterableIterator<1> + + const x = yield 1; +>x : any +>yield 1 : any +>1 : 1 + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/C4.ts === +class C4 { +>C4 : C4 + + async * f() { +>f : () => AsyncIterableIterator + + const x = yield* [1]; +>x : any +>yield* [1] : any +>[1] : number[] +>1 : 1 + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/C5.ts === +class C5 { +>C5 : C5 + + async * f() { +>f : () => AsyncIterableIterator<1> + + const x = yield* (async function*() { yield 1; })(); +>x : any +>yield* (async function*() { yield 1; })() : any +>(async function*() { yield 1; })() : AsyncIterableIterator<1> +>(async function*() { yield 1; }) : () => AsyncIterableIterator<1> +>async function*() { yield 1; } : () => AsyncIterableIterator<1> +>yield 1 : any +>1 : 1 + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/C6.ts === +class C6 { +>C6 : C6 + + async * f() { +>f : () => AsyncIterableIterator + + const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/C7.ts === +class C7 { +>C7 : C7 + + async * f() { +>f : () => AsyncIterableIterator + + return 1; +>1 : 1 + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/C8.ts === +class C8 { +>C8 : C8 + + g() { +>g : () => void + } + async * f() { +>f : () => AsyncIterableIterator + + this.g(); +>this.g() : void +>this.g : () => void +>this : this +>g : () => void + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/C9.ts === +class B9 { +>B9 : B9 + + g() {} +>g : () => void +} +class C9 extends B9 { +>C9 : C9 +>B9 : B9 + + async * f() { +>f : () => AsyncIterableIterator + + super.g(); +>super.g() : void +>super.g : () => void +>super : B9 +>g : () => void + } +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.js b/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.js new file mode 100644 index 00000000000..84c8aaf009b --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.js @@ -0,0 +1,120 @@ +//// [tests/cases/conformance/emitter/esnext/asyncGenerators/emitter.asyncGenerators.classMethods.esnext.ts] //// + +//// [C1.ts] +class C1 { + async * f() { + } +} +//// [C2.ts] +class C2 { + async * f() { + const x = yield; + } +} +//// [C3.ts] +class C3 { + async * f() { + const x = yield 1; + } +} +//// [C4.ts] +class C4 { + async * f() { + const x = yield* [1]; + } +} +//// [C5.ts] +class C5 { + async * f() { + const x = yield* (async function*() { yield 1; })(); + } +} +//// [C6.ts] +class C6 { + async * f() { + const x = await 1; + } +} +//// [C7.ts] +class C7 { + async * f() { + return 1; + } +} +//// [C8.ts] +class C8 { + g() { + } + async * f() { + this.g(); + } +} +//// [C9.ts] +class B9 { + g() {} +} +class C9 extends B9 { + async * f() { + super.g(); + } +} + + +//// [C1.js] +class C1 { + async *f() { + } +} +//// [C2.js] +class C2 { + async *f() { + const x = yield; + } +} +//// [C3.js] +class C3 { + async *f() { + const x = yield 1; + } +} +//// [C4.js] +class C4 { + async *f() { + const x = yield* [1]; + } +} +//// [C5.js] +class C5 { + async *f() { + const x = yield* (async function* () { yield 1; })(); + } +} +//// [C6.js] +class C6 { + async *f() { + const x = await 1; + } +} +//// [C7.js] +class C7 { + async *f() { + return 1; + } +} +//// [C8.js] +class C8 { + g() { + } + async *f() { + this.g(); + } +} +//// [C9.js] +class B9 { + g() { } +} +class C9 extends B9 { + async *f() { + super.g(); + } +} diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.symbols b/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.symbols new file mode 100644 index 00000000000..99450781f82 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.symbols @@ -0,0 +1,110 @@ +=== tests/cases/conformance/emitter/esnext/asyncGenerators/C1.ts === +class C1 { +>C1 : Symbol(C1, Decl(C1.ts, 0, 0)) + + async * f() { +>f : Symbol(C1.f, Decl(C1.ts, 0, 10)) + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/C2.ts === +class C2 { +>C2 : Symbol(C2, Decl(C2.ts, 0, 0)) + + async * f() { +>f : Symbol(C2.f, Decl(C2.ts, 0, 10)) + + const x = yield; +>x : Symbol(x, Decl(C2.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/C3.ts === +class C3 { +>C3 : Symbol(C3, Decl(C3.ts, 0, 0)) + + async * f() { +>f : Symbol(C3.f, Decl(C3.ts, 0, 10)) + + const x = yield 1; +>x : Symbol(x, Decl(C3.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/C4.ts === +class C4 { +>C4 : Symbol(C4, Decl(C4.ts, 0, 0)) + + async * f() { +>f : Symbol(C4.f, Decl(C4.ts, 0, 10)) + + const x = yield* [1]; +>x : Symbol(x, Decl(C4.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/C5.ts === +class C5 { +>C5 : Symbol(C5, Decl(C5.ts, 0, 0)) + + async * f() { +>f : Symbol(C5.f, Decl(C5.ts, 0, 10)) + + const x = yield* (async function*() { yield 1; })(); +>x : Symbol(x, Decl(C5.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/C6.ts === +class C6 { +>C6 : Symbol(C6, Decl(C6.ts, 0, 0)) + + async * f() { +>f : Symbol(C6.f, Decl(C6.ts, 0, 10)) + + const x = await 1; +>x : Symbol(x, Decl(C6.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/C7.ts === +class C7 { +>C7 : Symbol(C7, Decl(C7.ts, 0, 0)) + + async * f() { +>f : Symbol(C7.f, Decl(C7.ts, 0, 10)) + + return 1; + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/C8.ts === +class C8 { +>C8 : Symbol(C8, Decl(C8.ts, 0, 0)) + + g() { +>g : Symbol(C8.g, Decl(C8.ts, 0, 10)) + } + async * f() { +>f : Symbol(C8.f, Decl(C8.ts, 2, 5)) + + this.g(); +>this.g : Symbol(C8.g, Decl(C8.ts, 0, 10)) +>this : Symbol(C8, Decl(C8.ts, 0, 0)) +>g : Symbol(C8.g, Decl(C8.ts, 0, 10)) + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/C9.ts === +class B9 { +>B9 : Symbol(B9, Decl(C9.ts, 0, 0)) + + g() {} +>g : Symbol(B9.g, Decl(C9.ts, 0, 10)) +} +class C9 extends B9 { +>C9 : Symbol(C9, Decl(C9.ts, 2, 1)) +>B9 : Symbol(B9, Decl(C9.ts, 0, 0)) + + async * f() { +>f : Symbol(C9.f, Decl(C9.ts, 3, 21)) + + super.g(); +>super.g : Symbol(B9.g, Decl(C9.ts, 0, 10)) +>super : Symbol(B9, Decl(C9.ts, 0, 0)) +>g : Symbol(B9.g, Decl(C9.ts, 0, 10)) + } +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types new file mode 100644 index 00000000000..b5230006f1b --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types @@ -0,0 +1,127 @@ +=== tests/cases/conformance/emitter/esnext/asyncGenerators/C1.ts === +class C1 { +>C1 : C1 + + async * f() { +>f : () => AsyncIterableIterator + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/C2.ts === +class C2 { +>C2 : C2 + + async * f() { +>f : () => AsyncIterableIterator + + const x = yield; +>x : any +>yield : any + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/C3.ts === +class C3 { +>C3 : C3 + + async * f() { +>f : () => AsyncIterableIterator<1> + + const x = yield 1; +>x : any +>yield 1 : any +>1 : 1 + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/C4.ts === +class C4 { +>C4 : C4 + + async * f() { +>f : () => AsyncIterableIterator + + const x = yield* [1]; +>x : any +>yield* [1] : any +>[1] : number[] +>1 : 1 + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/C5.ts === +class C5 { +>C5 : C5 + + async * f() { +>f : () => AsyncIterableIterator<1> + + const x = yield* (async function*() { yield 1; })(); +>x : any +>yield* (async function*() { yield 1; })() : any +>(async function*() { yield 1; })() : AsyncIterableIterator<1> +>(async function*() { yield 1; }) : () => AsyncIterableIterator<1> +>async function*() { yield 1; } : () => AsyncIterableIterator<1> +>yield 1 : any +>1 : 1 + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/C6.ts === +class C6 { +>C6 : C6 + + async * f() { +>f : () => AsyncIterableIterator + + const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/C7.ts === +class C7 { +>C7 : C7 + + async * f() { +>f : () => AsyncIterableIterator + + return 1; +>1 : 1 + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/C8.ts === +class C8 { +>C8 : C8 + + g() { +>g : () => void + } + async * f() { +>f : () => AsyncIterableIterator + + this.g(); +>this.g() : void +>this.g : () => void +>this : this +>g : () => void + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/C9.ts === +class B9 { +>B9 : B9 + + g() {} +>g : () => void +} +class C9 extends B9 { +>C9 : C9 +>B9 : B9 + + async * f() { +>f : () => AsyncIterableIterator + + super.g(); +>super.g() : void +>super.g : () => void +>super : B9 +>g : () => void + } +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.js b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.js new file mode 100644 index 00000000000..2b0d6db5353 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.js @@ -0,0 +1,173 @@ +//// [tests/cases/conformance/emitter/es2015/asyncGenerators/emitter.asyncGenerators.functionDeclarations.es2015.ts] //// + +//// [F1.ts] +async function * f1() { +} +//// [F2.ts] +async function * f2() { + const x = yield; +} +//// [F3.ts] +async function * f3() { + const x = yield 1; +} +//// [F4.ts] +async function * f4() { + const x = yield* [1]; +} +//// [F5.ts] +async function * f5() { + const x = yield* (async function*() { yield 1; })(); +} +//// [F6.ts] +async function * f6() { + const x = await 1; +} +//// [F7.ts] +async function * f7() { + return 1; +} + + +//// [F1.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +function f1() { + return __asyncGenerator(this, arguments, function* f1_1() { + }); +} +//// [F2.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +function f2() { + return __asyncGenerator(this, arguments, function* f2_1() { + const x = yield ["yield"]; + }); +} +//// [F3.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +function f3() { + return __asyncGenerator(this, arguments, function* f3_1() { + const x = yield ["yield", 1]; + }); +} +//// [F4.js] +var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +function f4() { + return __asyncGenerator(this, arguments, function* f4_1() { + const x = yield* __asyncDelegator([1]); + }); +} +//// [F5.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } +}; +function f5() { + return __asyncGenerator(this, arguments, function* f5_1() { + const x = yield* __asyncDelegator((function () { return __asyncGenerator(this, arguments, function* () { yield ["yield", 1]; }); })()); + }); +} +//// [F6.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +function f6() { + return __asyncGenerator(this, arguments, function* f6_1() { + const x = yield ["await", 1]; + }); +} +//// [F7.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +function f7() { + return __asyncGenerator(this, arguments, function* f7_1() { + return 1; + }); +} diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.symbols b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.symbols new file mode 100644 index 00000000000..8c2c8b1aead --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.symbols @@ -0,0 +1,46 @@ +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F1.ts === +async function * f1() { +>f1 : Symbol(f1, Decl(F1.ts, 0, 0)) +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F2.ts === +async function * f2() { +>f2 : Symbol(f2, Decl(F2.ts, 0, 0)) + + const x = yield; +>x : Symbol(x, Decl(F2.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F3.ts === +async function * f3() { +>f3 : Symbol(f3, Decl(F3.ts, 0, 0)) + + const x = yield 1; +>x : Symbol(x, Decl(F3.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F4.ts === +async function * f4() { +>f4 : Symbol(f4, Decl(F4.ts, 0, 0)) + + const x = yield* [1]; +>x : Symbol(x, Decl(F4.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F5.ts === +async function * f5() { +>f5 : Symbol(f5, Decl(F5.ts, 0, 0)) + + const x = yield* (async function*() { yield 1; })(); +>x : Symbol(x, Decl(F5.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F6.ts === +async function * f6() { +>f6 : Symbol(f6, Decl(F6.ts, 0, 0)) + + const x = await 1; +>x : Symbol(x, Decl(F6.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F7.ts === +async function * f7() { +>f7 : Symbol(f7, Decl(F7.ts, 0, 0)) + + return 1; +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types new file mode 100644 index 00000000000..5d57519d140 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types @@ -0,0 +1,61 @@ +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F1.ts === +async function * f1() { +>f1 : () => AsyncIterableIterator +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F2.ts === +async function * f2() { +>f2 : () => AsyncIterableIterator + + const x = yield; +>x : any +>yield : any +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F3.ts === +async function * f3() { +>f3 : () => AsyncIterableIterator<1> + + const x = yield 1; +>x : any +>yield 1 : any +>1 : 1 +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F4.ts === +async function * f4() { +>f4 : () => AsyncIterableIterator + + const x = yield* [1]; +>x : any +>yield* [1] : any +>[1] : number[] +>1 : 1 +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F5.ts === +async function * f5() { +>f5 : () => AsyncIterableIterator<1> + + const x = yield* (async function*() { yield 1; })(); +>x : any +>yield* (async function*() { yield 1; })() : any +>(async function*() { yield 1; })() : AsyncIterableIterator<1> +>(async function*() { yield 1; }) : () => AsyncIterableIterator<1> +>async function*() { yield 1; } : () => AsyncIterableIterator<1> +>yield 1 : any +>1 : 1 +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F6.ts === +async function * f6() { +>f6 : () => AsyncIterableIterator + + const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F7.ts === +async function * f7() { +>f7 : () => AsyncIterableIterator + + return 1; +>1 : 1 +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.js b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.js new file mode 100644 index 00000000000..42098455ed1 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.js @@ -0,0 +1,434 @@ +//// [tests/cases/conformance/emitter/es5/asyncGenerators/emitter.asyncGenerators.functionDeclarations.es5.ts] //// + +//// [F1.ts] +async function * f1() { +} +//// [F2.ts] +async function * f2() { + const x = yield; +} +//// [F3.ts] +async function * f3() { + const x = yield 1; +} +//// [F4.ts] +async function * f4() { + const x = yield* [1]; +} +//// [F5.ts] +async function * f5() { + const x = yield* (async function*() { yield 1; })(); +} +//// [F6.ts] +async function * f6() { + const x = await 1; +} +//// [F7.ts] +async function * f7() { + return 1; +} + + +//// [F1.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +function f1() { + return __asyncGenerator(this, arguments, function f1_1() { + return __generator(this, function (_a) { + return [2 /*return*/]; + }); + }); +} +//// [F2.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +function f2() { + return __asyncGenerator(this, arguments, function f2_1() { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, ["yield"]]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); +} +//// [F3.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +function f3() { + return __asyncGenerator(this, arguments, function f3_1() { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, ["yield", 1]]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); +} +//// [F4.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var __values = (this && this.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; +function f4() { + return __asyncGenerator(this, arguments, function f4_1() { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [5 /*yield**/, __values(__asyncDelegator([1]))]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); +} +//// [F5.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } +}; +var __values = (this && this.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; +function f5() { + return __asyncGenerator(this, arguments, function f5_1() { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [5 /*yield**/, __values(__asyncDelegator((function () { return __asyncGenerator(this, arguments, function () { return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, ["yield", 1]]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); }); })()))]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); +} +//// [F6.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +function f6() { + return __asyncGenerator(this, arguments, function f6_1() { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, ["await", 1]]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); +} +//// [F7.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +function f7() { + return __asyncGenerator(this, arguments, function f7_1() { + return __generator(this, function (_a) { + return [2 /*return*/, 1]; + }); + }); +} diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.symbols b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.symbols new file mode 100644 index 00000000000..416d5349811 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.symbols @@ -0,0 +1,46 @@ +=== tests/cases/conformance/emitter/es5/asyncGenerators/F1.ts === +async function * f1() { +>f1 : Symbol(f1, Decl(F1.ts, 0, 0)) +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F2.ts === +async function * f2() { +>f2 : Symbol(f2, Decl(F2.ts, 0, 0)) + + const x = yield; +>x : Symbol(x, Decl(F2.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F3.ts === +async function * f3() { +>f3 : Symbol(f3, Decl(F3.ts, 0, 0)) + + const x = yield 1; +>x : Symbol(x, Decl(F3.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F4.ts === +async function * f4() { +>f4 : Symbol(f4, Decl(F4.ts, 0, 0)) + + const x = yield* [1]; +>x : Symbol(x, Decl(F4.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F5.ts === +async function * f5() { +>f5 : Symbol(f5, Decl(F5.ts, 0, 0)) + + const x = yield* (async function*() { yield 1; })(); +>x : Symbol(x, Decl(F5.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F6.ts === +async function * f6() { +>f6 : Symbol(f6, Decl(F6.ts, 0, 0)) + + const x = await 1; +>x : Symbol(x, Decl(F6.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F7.ts === +async function * f7() { +>f7 : Symbol(f7, Decl(F7.ts, 0, 0)) + + return 1; +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types new file mode 100644 index 00000000000..2c3063eca59 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types @@ -0,0 +1,61 @@ +=== tests/cases/conformance/emitter/es5/asyncGenerators/F1.ts === +async function * f1() { +>f1 : () => AsyncIterableIterator +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F2.ts === +async function * f2() { +>f2 : () => AsyncIterableIterator + + const x = yield; +>x : any +>yield : any +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F3.ts === +async function * f3() { +>f3 : () => AsyncIterableIterator<1> + + const x = yield 1; +>x : any +>yield 1 : any +>1 : 1 +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F4.ts === +async function * f4() { +>f4 : () => AsyncIterableIterator + + const x = yield* [1]; +>x : any +>yield* [1] : any +>[1] : number[] +>1 : 1 +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F5.ts === +async function * f5() { +>f5 : () => AsyncIterableIterator<1> + + const x = yield* (async function*() { yield 1; })(); +>x : any +>yield* (async function*() { yield 1; })() : any +>(async function*() { yield 1; })() : AsyncIterableIterator<1> +>(async function*() { yield 1; }) : () => AsyncIterableIterator<1> +>async function*() { yield 1; } : () => AsyncIterableIterator<1> +>yield 1 : any +>1 : 1 +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F6.ts === +async function * f6() { +>f6 : () => AsyncIterableIterator + + const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F7.ts === +async function * f7() { +>f7 : () => AsyncIterableIterator + + return 1; +>1 : 1 +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.js b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.js new file mode 100644 index 00000000000..57708e027a3 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.js @@ -0,0 +1,58 @@ +//// [tests/cases/conformance/emitter/esnext/asyncGenerators/emitter.asyncGenerators.functionDeclarations.esnext.ts] //// + +//// [F1.ts] +async function * f1() { +} +//// [F2.ts] +async function * f2() { + const x = yield; +} +//// [F3.ts] +async function * f3() { + const x = yield 1; +} +//// [F4.ts] +async function * f4() { + const x = yield* [1]; +} +//// [F5.ts] +async function * f5() { + const x = yield* (async function*() { yield 1; })(); +} +//// [F6.ts] +async function * f6() { + const x = await 1; +} +//// [F7.ts] +async function * f7() { + return 1; +} + + +//// [F1.js] +async function* f1() { +} +//// [F2.js] +async function* f2() { + const x = yield; +} +//// [F3.js] +async function* f3() { + const x = yield 1; +} +//// [F4.js] +async function* f4() { + const x = yield* [1]; +} +//// [F5.js] +async function* f5() { + const x = yield* (async function* () { yield 1; })(); +} +//// [F6.js] +async function* f6() { + const x = await 1; +} +//// [F7.js] +async function* f7() { + return 1; +} diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.symbols b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.symbols new file mode 100644 index 00000000000..018b7d7e07a --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.symbols @@ -0,0 +1,46 @@ +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F1.ts === +async function * f1() { +>f1 : Symbol(f1, Decl(F1.ts, 0, 0)) +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F2.ts === +async function * f2() { +>f2 : Symbol(f2, Decl(F2.ts, 0, 0)) + + const x = yield; +>x : Symbol(x, Decl(F2.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F3.ts === +async function * f3() { +>f3 : Symbol(f3, Decl(F3.ts, 0, 0)) + + const x = yield 1; +>x : Symbol(x, Decl(F3.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F4.ts === +async function * f4() { +>f4 : Symbol(f4, Decl(F4.ts, 0, 0)) + + const x = yield* [1]; +>x : Symbol(x, Decl(F4.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F5.ts === +async function * f5() { +>f5 : Symbol(f5, Decl(F5.ts, 0, 0)) + + const x = yield* (async function*() { yield 1; })(); +>x : Symbol(x, Decl(F5.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F6.ts === +async function * f6() { +>f6 : Symbol(f6, Decl(F6.ts, 0, 0)) + + const x = await 1; +>x : Symbol(x, Decl(F6.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F7.ts === +async function * f7() { +>f7 : Symbol(f7, Decl(F7.ts, 0, 0)) + + return 1; +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types new file mode 100644 index 00000000000..5eb09901ac8 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types @@ -0,0 +1,61 @@ +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F1.ts === +async function * f1() { +>f1 : () => AsyncIterableIterator +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F2.ts === +async function * f2() { +>f2 : () => AsyncIterableIterator + + const x = yield; +>x : any +>yield : any +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F3.ts === +async function * f3() { +>f3 : () => AsyncIterableIterator<1> + + const x = yield 1; +>x : any +>yield 1 : any +>1 : 1 +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F4.ts === +async function * f4() { +>f4 : () => AsyncIterableIterator + + const x = yield* [1]; +>x : any +>yield* [1] : any +>[1] : number[] +>1 : 1 +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F5.ts === +async function * f5() { +>f5 : () => AsyncIterableIterator<1> + + const x = yield* (async function*() { yield 1; })(); +>x : any +>yield* (async function*() { yield 1; })() : any +>(async function*() { yield 1; })() : AsyncIterableIterator<1> +>(async function*() { yield 1; }) : () => AsyncIterableIterator<1> +>async function*() { yield 1; } : () => AsyncIterableIterator<1> +>yield 1 : any +>1 : 1 +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F6.ts === +async function * f6() { +>f6 : () => AsyncIterableIterator + + const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F7.ts === +async function * f7() { +>f7 : () => AsyncIterableIterator + + return 1; +>1 : 1 +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.js b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.js new file mode 100644 index 00000000000..90f4b70e9bd --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.js @@ -0,0 +1,173 @@ +//// [tests/cases/conformance/emitter/es2015/asyncGenerators/emitter.asyncGenerators.functionExpressions.es2015.ts] //// + +//// [F1.ts] +const f1 = async function * () { +} +//// [F2.ts] +const f2 = async function * () { + const x = yield; +} +//// [F3.ts] +const f3 = async function * () { + const x = yield 1; +} +//// [F4.ts] +const f4 = async function * () { + const x = yield* [1]; +} +//// [F5.ts] +const f5 = async function * () { + const x = yield* (async function*() { yield 1; })(); +} +//// [F6.ts] +const f6 = async function * () { + const x = await 1; +} +//// [F7.ts] +const f7 = async function * () { + return 1; +} + + +//// [F1.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +const f1 = function () { + return __asyncGenerator(this, arguments, function* () { + }); +}; +//// [F2.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +const f2 = function () { + return __asyncGenerator(this, arguments, function* () { + const x = yield ["yield"]; + }); +}; +//// [F3.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +const f3 = function () { + return __asyncGenerator(this, arguments, function* () { + const x = yield ["yield", 1]; + }); +}; +//// [F4.js] +var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +const f4 = function () { + return __asyncGenerator(this, arguments, function* () { + const x = yield* __asyncDelegator([1]); + }); +}; +//// [F5.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } +}; +const f5 = function () { + return __asyncGenerator(this, arguments, function* () { + const x = yield* __asyncDelegator((function () { return __asyncGenerator(this, arguments, function* () { yield ["yield", 1]; }); })()); + }); +}; +//// [F6.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +const f6 = function () { + return __asyncGenerator(this, arguments, function* () { + const x = yield ["await", 1]; + }); +}; +//// [F7.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +const f7 = function () { + return __asyncGenerator(this, arguments, function* () { + return 1; + }); +}; diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.symbols b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.symbols new file mode 100644 index 00000000000..ff315c7f82e --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.symbols @@ -0,0 +1,46 @@ +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F1.ts === +const f1 = async function * () { +>f1 : Symbol(f1, Decl(F1.ts, 0, 5)) +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F2.ts === +const f2 = async function * () { +>f2 : Symbol(f2, Decl(F2.ts, 0, 5)) + + const x = yield; +>x : Symbol(x, Decl(F2.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F3.ts === +const f3 = async function * () { +>f3 : Symbol(f3, Decl(F3.ts, 0, 5)) + + const x = yield 1; +>x : Symbol(x, Decl(F3.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F4.ts === +const f4 = async function * () { +>f4 : Symbol(f4, Decl(F4.ts, 0, 5)) + + const x = yield* [1]; +>x : Symbol(x, Decl(F4.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F5.ts === +const f5 = async function * () { +>f5 : Symbol(f5, Decl(F5.ts, 0, 5)) + + const x = yield* (async function*() { yield 1; })(); +>x : Symbol(x, Decl(F5.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F6.ts === +const f6 = async function * () { +>f6 : Symbol(f6, Decl(F6.ts, 0, 5)) + + const x = await 1; +>x : Symbol(x, Decl(F6.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F7.ts === +const f7 = async function * () { +>f7 : Symbol(f7, Decl(F7.ts, 0, 5)) + + return 1; +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types new file mode 100644 index 00000000000..ab41ffd9c71 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F1.ts === +const f1 = async function * () { +>f1 : () => AsyncIterableIterator +>async function * () {} : () => AsyncIterableIterator +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F2.ts === +const f2 = async function * () { +>f2 : () => AsyncIterableIterator +>async function * () { const x = yield;} : () => AsyncIterableIterator + + const x = yield; +>x : any +>yield : any +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F3.ts === +const f3 = async function * () { +>f3 : () => AsyncIterableIterator<1> +>async function * () { const x = yield 1;} : () => AsyncIterableIterator<1> + + const x = yield 1; +>x : any +>yield 1 : any +>1 : 1 +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F4.ts === +const f4 = async function * () { +>f4 : () => AsyncIterableIterator +>async function * () { const x = yield* [1];} : () => AsyncIterableIterator + + const x = yield* [1]; +>x : any +>yield* [1] : any +>[1] : number[] +>1 : 1 +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F5.ts === +const f5 = async function * () { +>f5 : () => AsyncIterableIterator<1> +>async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator<1> + + const x = yield* (async function*() { yield 1; })(); +>x : any +>yield* (async function*() { yield 1; })() : any +>(async function*() { yield 1; })() : AsyncIterableIterator<1> +>(async function*() { yield 1; }) : () => AsyncIterableIterator<1> +>async function*() { yield 1; } : () => AsyncIterableIterator<1> +>yield 1 : any +>1 : 1 +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F6.ts === +const f6 = async function * () { +>f6 : () => AsyncIterableIterator +>async function * () { const x = await 1;} : () => AsyncIterableIterator + + const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/F7.ts === +const f7 = async function * () { +>f7 : () => AsyncIterableIterator +>async function * () { return 1;} : () => AsyncIterableIterator + + return 1; +>1 : 1 +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.js b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.js new file mode 100644 index 00000000000..a6265063fde --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.js @@ -0,0 +1,434 @@ +//// [tests/cases/conformance/emitter/es5/asyncGenerators/emitter.asyncGenerators.functionExpressions.es5.ts] //// + +//// [F1.ts] +const f1 = async function * () { +} +//// [F2.ts] +const f2 = async function * () { + const x = yield; +} +//// [F3.ts] +const f3 = async function * () { + const x = yield 1; +} +//// [F4.ts] +const f4 = async function * () { + const x = yield* [1]; +} +//// [F5.ts] +const f5 = async function * () { + const x = yield* (async function*() { yield 1; })(); +} +//// [F6.ts] +const f6 = async function * () { + const x = await 1; +} +//// [F7.ts] +const f7 = async function * () { + return 1; +} + + +//// [F1.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var f1 = function () { + return __asyncGenerator(this, arguments, function () { + return __generator(this, function (_a) { + return [2 /*return*/]; + }); + }); +}; +//// [F2.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var f2 = function () { + return __asyncGenerator(this, arguments, function () { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, ["yield"]]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); +}; +//// [F3.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var f3 = function () { + return __asyncGenerator(this, arguments, function () { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, ["yield", 1]]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); +}; +//// [F4.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var __values = (this && this.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; +var f4 = function () { + return __asyncGenerator(this, arguments, function () { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [5 /*yield**/, __values(__asyncDelegator([1]))]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); +}; +//// [F5.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } +}; +var __values = (this && this.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; +var f5 = function () { + return __asyncGenerator(this, arguments, function () { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [5 /*yield**/, __values(__asyncDelegator((function () { return __asyncGenerator(this, arguments, function () { return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, ["yield", 1]]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); }); })()))]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); +}; +//// [F6.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var f6 = function () { + return __asyncGenerator(this, arguments, function () { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, ["await", 1]]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); +}; +//// [F7.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var f7 = function () { + return __asyncGenerator(this, arguments, function () { + return __generator(this, function (_a) { + return [2 /*return*/, 1]; + }); + }); +}; diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.symbols b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.symbols new file mode 100644 index 00000000000..88a9631c0bb --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.symbols @@ -0,0 +1,46 @@ +=== tests/cases/conformance/emitter/es5/asyncGenerators/F1.ts === +const f1 = async function * () { +>f1 : Symbol(f1, Decl(F1.ts, 0, 5)) +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F2.ts === +const f2 = async function * () { +>f2 : Symbol(f2, Decl(F2.ts, 0, 5)) + + const x = yield; +>x : Symbol(x, Decl(F2.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F3.ts === +const f3 = async function * () { +>f3 : Symbol(f3, Decl(F3.ts, 0, 5)) + + const x = yield 1; +>x : Symbol(x, Decl(F3.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F4.ts === +const f4 = async function * () { +>f4 : Symbol(f4, Decl(F4.ts, 0, 5)) + + const x = yield* [1]; +>x : Symbol(x, Decl(F4.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F5.ts === +const f5 = async function * () { +>f5 : Symbol(f5, Decl(F5.ts, 0, 5)) + + const x = yield* (async function*() { yield 1; })(); +>x : Symbol(x, Decl(F5.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F6.ts === +const f6 = async function * () { +>f6 : Symbol(f6, Decl(F6.ts, 0, 5)) + + const x = await 1; +>x : Symbol(x, Decl(F6.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F7.ts === +const f7 = async function * () { +>f7 : Symbol(f7, Decl(F7.ts, 0, 5)) + + return 1; +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types new file mode 100644 index 00000000000..424f09cf53b --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/emitter/es5/asyncGenerators/F1.ts === +const f1 = async function * () { +>f1 : () => AsyncIterableIterator +>async function * () {} : () => AsyncIterableIterator +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F2.ts === +const f2 = async function * () { +>f2 : () => AsyncIterableIterator +>async function * () { const x = yield;} : () => AsyncIterableIterator + + const x = yield; +>x : any +>yield : any +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F3.ts === +const f3 = async function * () { +>f3 : () => AsyncIterableIterator<1> +>async function * () { const x = yield 1;} : () => AsyncIterableIterator<1> + + const x = yield 1; +>x : any +>yield 1 : any +>1 : 1 +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F4.ts === +const f4 = async function * () { +>f4 : () => AsyncIterableIterator +>async function * () { const x = yield* [1];} : () => AsyncIterableIterator + + const x = yield* [1]; +>x : any +>yield* [1] : any +>[1] : number[] +>1 : 1 +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F5.ts === +const f5 = async function * () { +>f5 : () => AsyncIterableIterator<1> +>async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator<1> + + const x = yield* (async function*() { yield 1; })(); +>x : any +>yield* (async function*() { yield 1; })() : any +>(async function*() { yield 1; })() : AsyncIterableIterator<1> +>(async function*() { yield 1; }) : () => AsyncIterableIterator<1> +>async function*() { yield 1; } : () => AsyncIterableIterator<1> +>yield 1 : any +>1 : 1 +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F6.ts === +const f6 = async function * () { +>f6 : () => AsyncIterableIterator +>async function * () { const x = await 1;} : () => AsyncIterableIterator + + const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/F7.ts === +const f7 = async function * () { +>f7 : () => AsyncIterableIterator +>async function * () { return 1;} : () => AsyncIterableIterator + + return 1; +>1 : 1 +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.js b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.js new file mode 100644 index 00000000000..349fea53b7a --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.js @@ -0,0 +1,58 @@ +//// [tests/cases/conformance/emitter/esnext/asyncGenerators/emitter.asyncGenerators.functionExpressions.esnext.ts] //// + +//// [F1.ts] +const f1 = async function * () { +} +//// [F2.ts] +const f2 = async function * () { + const x = yield; +} +//// [F3.ts] +const f3 = async function * () { + const x = yield 1; +} +//// [F4.ts] +const f4 = async function * () { + const x = yield* [1]; +} +//// [F5.ts] +const f5 = async function * () { + const x = yield* (async function*() { yield 1; })(); +} +//// [F6.ts] +const f6 = async function * () { + const x = await 1; +} +//// [F7.ts] +const f7 = async function * () { + return 1; +} + + +//// [F1.js] +const f1 = async function* () { +}; +//// [F2.js] +const f2 = async function* () { + const x = yield; +}; +//// [F3.js] +const f3 = async function* () { + const x = yield 1; +}; +//// [F4.js] +const f4 = async function* () { + const x = yield* [1]; +}; +//// [F5.js] +const f5 = async function* () { + const x = yield* (async function* () { yield 1; })(); +}; +//// [F6.js] +const f6 = async function* () { + const x = await 1; +}; +//// [F7.js] +const f7 = async function* () { + return 1; +}; diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.symbols b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.symbols new file mode 100644 index 00000000000..e59d8429fb7 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.symbols @@ -0,0 +1,46 @@ +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F1.ts === +const f1 = async function * () { +>f1 : Symbol(f1, Decl(F1.ts, 0, 5)) +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F2.ts === +const f2 = async function * () { +>f2 : Symbol(f2, Decl(F2.ts, 0, 5)) + + const x = yield; +>x : Symbol(x, Decl(F2.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F3.ts === +const f3 = async function * () { +>f3 : Symbol(f3, Decl(F3.ts, 0, 5)) + + const x = yield 1; +>x : Symbol(x, Decl(F3.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F4.ts === +const f4 = async function * () { +>f4 : Symbol(f4, Decl(F4.ts, 0, 5)) + + const x = yield* [1]; +>x : Symbol(x, Decl(F4.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F5.ts === +const f5 = async function * () { +>f5 : Symbol(f5, Decl(F5.ts, 0, 5)) + + const x = yield* (async function*() { yield 1; })(); +>x : Symbol(x, Decl(F5.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F6.ts === +const f6 = async function * () { +>f6 : Symbol(f6, Decl(F6.ts, 0, 5)) + + const x = await 1; +>x : Symbol(x, Decl(F6.ts, 1, 9)) +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F7.ts === +const f7 = async function * () { +>f7 : Symbol(f7, Decl(F7.ts, 0, 5)) + + return 1; +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types new file mode 100644 index 00000000000..e4559e3ecef --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F1.ts === +const f1 = async function * () { +>f1 : () => AsyncIterableIterator +>async function * () {} : () => AsyncIterableIterator +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F2.ts === +const f2 = async function * () { +>f2 : () => AsyncIterableIterator +>async function * () { const x = yield;} : () => AsyncIterableIterator + + const x = yield; +>x : any +>yield : any +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F3.ts === +const f3 = async function * () { +>f3 : () => AsyncIterableIterator<1> +>async function * () { const x = yield 1;} : () => AsyncIterableIterator<1> + + const x = yield 1; +>x : any +>yield 1 : any +>1 : 1 +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F4.ts === +const f4 = async function * () { +>f4 : () => AsyncIterableIterator +>async function * () { const x = yield* [1];} : () => AsyncIterableIterator + + const x = yield* [1]; +>x : any +>yield* [1] : any +>[1] : number[] +>1 : 1 +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F5.ts === +const f5 = async function * () { +>f5 : () => AsyncIterableIterator<1> +>async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator<1> + + const x = yield* (async function*() { yield 1; })(); +>x : any +>yield* (async function*() { yield 1; })() : any +>(async function*() { yield 1; })() : AsyncIterableIterator<1> +>(async function*() { yield 1; }) : () => AsyncIterableIterator<1> +>async function*() { yield 1; } : () => AsyncIterableIterator<1> +>yield 1 : any +>1 : 1 +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F6.ts === +const f6 = async function * () { +>f6 : () => AsyncIterableIterator +>async function * () { const x = await 1;} : () => AsyncIterableIterator + + const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/F7.ts === +const f7 = async function * () { +>f7 : () => AsyncIterableIterator +>async function * () { return 1;} : () => AsyncIterableIterator + + return 1; +>1 : 1 +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.js b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.js new file mode 100644 index 00000000000..817b3904f02 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.js @@ -0,0 +1,201 @@ +//// [tests/cases/conformance/emitter/es2015/asyncGenerators/emitter.asyncGenerators.objectLiteralMethods.es2015.ts] //// + +//// [O1.ts] +const o1 = { + async * f() { + } +} +//// [O2.ts] +const o2 = { + async * f() { + const x = yield; + } +} +//// [O3.ts] +const o3 = { + async * f() { + const x = yield 1; + } +} +//// [O4.ts] +const o4 = { + async * f() { + const x = yield* [1]; + } +} +//// [O5.ts] +const o5 = { + async * f() { + const x = yield* (async function*() { yield 1; })(); + } +} +//// [O6.ts] +const o6 = { + async * f() { + const x = await 1; + } +} +//// [O7.ts] +const o7 = { + async * f() { + return 1; + } +} + + +//// [O1.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +const o1 = { + f() { + return __asyncGenerator(this, arguments, function* f_1() { + }); + } +}; +//// [O2.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +const o2 = { + f() { + return __asyncGenerator(this, arguments, function* f_1() { + const x = yield ["yield"]; + }); + } +}; +//// [O3.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +const o3 = { + f() { + return __asyncGenerator(this, arguments, function* f_1() { + const x = yield ["yield", 1]; + }); + } +}; +//// [O4.js] +var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +const o4 = { + f() { + return __asyncGenerator(this, arguments, function* f_1() { + const x = yield* __asyncDelegator([1]); + }); + } +}; +//// [O5.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } +}; +const o5 = { + f() { + return __asyncGenerator(this, arguments, function* f_1() { + const x = yield* __asyncDelegator((function () { return __asyncGenerator(this, arguments, function* () { yield ["yield", 1]; }); })()); + }); + } +}; +//// [O6.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +const o6 = { + f() { + return __asyncGenerator(this, arguments, function* f_1() { + const x = yield ["await", 1]; + }); + } +}; +//// [O7.js] +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +const o7 = { + f() { + return __asyncGenerator(this, arguments, function* f_1() { + return 1; + }); + } +}; diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.symbols b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.symbols new file mode 100644 index 00000000000..7f03bf6eef0 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.symbols @@ -0,0 +1,74 @@ +=== tests/cases/conformance/emitter/es2015/asyncGenerators/O1.ts === +const o1 = { +>o1 : Symbol(o1, Decl(O1.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O1.ts, 0, 12)) + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/O2.ts === +const o2 = { +>o2 : Symbol(o2, Decl(O2.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O2.ts, 0, 12)) + + const x = yield; +>x : Symbol(x, Decl(O2.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/O3.ts === +const o3 = { +>o3 : Symbol(o3, Decl(O3.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O3.ts, 0, 12)) + + const x = yield 1; +>x : Symbol(x, Decl(O3.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/O4.ts === +const o4 = { +>o4 : Symbol(o4, Decl(O4.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O4.ts, 0, 12)) + + const x = yield* [1]; +>x : Symbol(x, Decl(O4.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/O5.ts === +const o5 = { +>o5 : Symbol(o5, Decl(O5.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O5.ts, 0, 12)) + + const x = yield* (async function*() { yield 1; })(); +>x : Symbol(x, Decl(O5.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/O6.ts === +const o6 = { +>o6 : Symbol(o6, Decl(O6.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O6.ts, 0, 12)) + + const x = await 1; +>x : Symbol(x, Decl(O6.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/O7.ts === +const o7 = { +>o7 : Symbol(o7, Decl(O7.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O7.ts, 0, 12)) + + return 1; + } +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types new file mode 100644 index 00000000000..0e89d9a1ca6 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types @@ -0,0 +1,96 @@ +=== tests/cases/conformance/emitter/es2015/asyncGenerators/O1.ts === +const o1 = { +>o1 : { f(): AsyncIterableIterator; } +>{ async * f() { }} : { f(): AsyncIterableIterator; } + + async * f() { +>f : () => AsyncIterableIterator + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/O2.ts === +const o2 = { +>o2 : { f(): AsyncIterableIterator; } +>{ async * f() { const x = yield; }} : { f(): AsyncIterableIterator; } + + async * f() { +>f : () => AsyncIterableIterator + + const x = yield; +>x : any +>yield : any + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/O3.ts === +const o3 = { +>o3 : { f(): AsyncIterableIterator<1>; } +>{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator<1>; } + + async * f() { +>f : () => AsyncIterableIterator<1> + + const x = yield 1; +>x : any +>yield 1 : any +>1 : 1 + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/O4.ts === +const o4 = { +>o4 : { f(): AsyncIterableIterator; } +>{ async * f() { const x = yield* [1]; }} : { f(): AsyncIterableIterator; } + + async * f() { +>f : () => AsyncIterableIterator + + const x = yield* [1]; +>x : any +>yield* [1] : any +>[1] : number[] +>1 : 1 + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/O5.ts === +const o5 = { +>o5 : { f(): AsyncIterableIterator<1>; } +>{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator<1>; } + + async * f() { +>f : () => AsyncIterableIterator<1> + + const x = yield* (async function*() { yield 1; })(); +>x : any +>yield* (async function*() { yield 1; })() : any +>(async function*() { yield 1; })() : AsyncIterableIterator<1> +>(async function*() { yield 1; }) : () => AsyncIterableIterator<1> +>async function*() { yield 1; } : () => AsyncIterableIterator<1> +>yield 1 : any +>1 : 1 + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/O6.ts === +const o6 = { +>o6 : { f(): AsyncIterableIterator; } +>{ async * f() { const x = await 1; }} : { f(): AsyncIterableIterator; } + + async * f() { +>f : () => AsyncIterableIterator + + const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 + } +} +=== tests/cases/conformance/emitter/es2015/asyncGenerators/O7.ts === +const o7 = { +>o7 : { f(): AsyncIterableIterator; } +>{ async * f() { return 1; }} : { f(): AsyncIterableIterator; } + + async * f() { +>f : () => AsyncIterableIterator + + return 1; +>1 : 1 + } +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.js b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.js new file mode 100644 index 00000000000..a0839d8258d --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.js @@ -0,0 +1,462 @@ +//// [tests/cases/conformance/emitter/es5/asyncGenerators/emitter.asyncGenerators.objectLiteralMethods.es5.ts] //// + +//// [O1.ts] +const o1 = { + async * f() { + } +} +//// [O2.ts] +const o2 = { + async * f() { + const x = yield; + } +} +//// [O3.ts] +const o3 = { + async * f() { + const x = yield 1; + } +} +//// [O4.ts] +const o4 = { + async * f() { + const x = yield* [1]; + } +} +//// [O5.ts] +const o5 = { + async * f() { + const x = yield* (async function*() { yield 1; })(); + } +} +//// [O6.ts] +const o6 = { + async * f() { + const x = await 1; + } +} +//// [O7.ts] +const o7 = { + async * f() { + return 1; + } +} + + +//// [O1.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var o1 = { + f: function () { + return __asyncGenerator(this, arguments, function f_1() { + return __generator(this, function (_a) { + return [2 /*return*/]; + }); + }); + } +}; +//// [O2.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var o2 = { + f: function () { + return __asyncGenerator(this, arguments, function f_1() { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, ["yield"]]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); + } +}; +//// [O3.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var o3 = { + f: function () { + return __asyncGenerator(this, arguments, function f_1() { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, ["yield", 1]]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); + } +}; +//// [O4.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var __values = (this && this.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; +var o4 = { + f: function () { + return __asyncGenerator(this, arguments, function f_1() { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [5 /*yield**/, __values(__asyncDelegator([1]))]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); + } +}; +//// [O5.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } +}; +var __values = (this && this.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; +var o5 = { + f: function () { + return __asyncGenerator(this, arguments, function f_1() { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [5 /*yield**/, __values(__asyncDelegator((function () { return __asyncGenerator(this, arguments, function () { return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, ["yield", 1]]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); }); })()))]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); + } +}; +//// [O6.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var o6 = { + f: function () { + return __asyncGenerator(this, arguments, function f_1() { + var x; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, ["await", 1]]; + case 1: + x = _a.sent(); + return [2 /*return*/]; + } + }); + }); + } +}; +//// [O7.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +var o7 = { + f: function () { + return __asyncGenerator(this, arguments, function f_1() { + return __generator(this, function (_a) { + return [2 /*return*/, 1]; + }); + }); + } +}; diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.symbols b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.symbols new file mode 100644 index 00000000000..fbf78969742 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.symbols @@ -0,0 +1,74 @@ +=== tests/cases/conformance/emitter/es5/asyncGenerators/O1.ts === +const o1 = { +>o1 : Symbol(o1, Decl(O1.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O1.ts, 0, 12)) + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/O2.ts === +const o2 = { +>o2 : Symbol(o2, Decl(O2.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O2.ts, 0, 12)) + + const x = yield; +>x : Symbol(x, Decl(O2.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/O3.ts === +const o3 = { +>o3 : Symbol(o3, Decl(O3.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O3.ts, 0, 12)) + + const x = yield 1; +>x : Symbol(x, Decl(O3.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/O4.ts === +const o4 = { +>o4 : Symbol(o4, Decl(O4.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O4.ts, 0, 12)) + + const x = yield* [1]; +>x : Symbol(x, Decl(O4.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/O5.ts === +const o5 = { +>o5 : Symbol(o5, Decl(O5.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O5.ts, 0, 12)) + + const x = yield* (async function*() { yield 1; })(); +>x : Symbol(x, Decl(O5.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/O6.ts === +const o6 = { +>o6 : Symbol(o6, Decl(O6.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O6.ts, 0, 12)) + + const x = await 1; +>x : Symbol(x, Decl(O6.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/O7.ts === +const o7 = { +>o7 : Symbol(o7, Decl(O7.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O7.ts, 0, 12)) + + return 1; + } +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types new file mode 100644 index 00000000000..4c8ae47b6a2 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types @@ -0,0 +1,96 @@ +=== tests/cases/conformance/emitter/es5/asyncGenerators/O1.ts === +const o1 = { +>o1 : { f(): AsyncIterableIterator; } +>{ async * f() { }} : { f(): AsyncIterableIterator; } + + async * f() { +>f : () => AsyncIterableIterator + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/O2.ts === +const o2 = { +>o2 : { f(): AsyncIterableIterator; } +>{ async * f() { const x = yield; }} : { f(): AsyncIterableIterator; } + + async * f() { +>f : () => AsyncIterableIterator + + const x = yield; +>x : any +>yield : any + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/O3.ts === +const o3 = { +>o3 : { f(): AsyncIterableIterator<1>; } +>{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator<1>; } + + async * f() { +>f : () => AsyncIterableIterator<1> + + const x = yield 1; +>x : any +>yield 1 : any +>1 : 1 + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/O4.ts === +const o4 = { +>o4 : { f(): AsyncIterableIterator; } +>{ async * f() { const x = yield* [1]; }} : { f(): AsyncIterableIterator; } + + async * f() { +>f : () => AsyncIterableIterator + + const x = yield* [1]; +>x : any +>yield* [1] : any +>[1] : number[] +>1 : 1 + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/O5.ts === +const o5 = { +>o5 : { f(): AsyncIterableIterator<1>; } +>{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator<1>; } + + async * f() { +>f : () => AsyncIterableIterator<1> + + const x = yield* (async function*() { yield 1; })(); +>x : any +>yield* (async function*() { yield 1; })() : any +>(async function*() { yield 1; })() : AsyncIterableIterator<1> +>(async function*() { yield 1; }) : () => AsyncIterableIterator<1> +>async function*() { yield 1; } : () => AsyncIterableIterator<1> +>yield 1 : any +>1 : 1 + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/O6.ts === +const o6 = { +>o6 : { f(): AsyncIterableIterator; } +>{ async * f() { const x = await 1; }} : { f(): AsyncIterableIterator; } + + async * f() { +>f : () => AsyncIterableIterator + + const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 + } +} +=== tests/cases/conformance/emitter/es5/asyncGenerators/O7.ts === +const o7 = { +>o7 : { f(): AsyncIterableIterator; } +>{ async * f() { return 1; }} : { f(): AsyncIterableIterator; } + + async * f() { +>f : () => AsyncIterableIterator + + return 1; +>1 : 1 + } +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.js b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.js new file mode 100644 index 00000000000..a1877b38184 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.js @@ -0,0 +1,86 @@ +//// [tests/cases/conformance/emitter/esnext/asyncGenerators/emitter.asyncGenerators.objectLiteralMethods.esnext.ts] //// + +//// [O1.ts] +const o1 = { + async * f() { + } +} +//// [O2.ts] +const o2 = { + async * f() { + const x = yield; + } +} +//// [O3.ts] +const o3 = { + async * f() { + const x = yield 1; + } +} +//// [O4.ts] +const o4 = { + async * f() { + const x = yield* [1]; + } +} +//// [O5.ts] +const o5 = { + async * f() { + const x = yield* (async function*() { yield 1; })(); + } +} +//// [O6.ts] +const o6 = { + async * f() { + const x = await 1; + } +} +//// [O7.ts] +const o7 = { + async * f() { + return 1; + } +} + + +//// [O1.js] +const o1 = { + async *f() { + } +}; +//// [O2.js] +const o2 = { + async *f() { + const x = yield; + } +}; +//// [O3.js] +const o3 = { + async *f() { + const x = yield 1; + } +}; +//// [O4.js] +const o4 = { + async *f() { + const x = yield* [1]; + } +}; +//// [O5.js] +const o5 = { + async *f() { + const x = yield* (async function* () { yield 1; })(); + } +}; +//// [O6.js] +const o6 = { + async *f() { + const x = await 1; + } +}; +//// [O7.js] +const o7 = { + async *f() { + return 1; + } +}; diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.symbols b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.symbols new file mode 100644 index 00000000000..c1c7847c592 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.symbols @@ -0,0 +1,74 @@ +=== tests/cases/conformance/emitter/esnext/asyncGenerators/O1.ts === +const o1 = { +>o1 : Symbol(o1, Decl(O1.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O1.ts, 0, 12)) + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/O2.ts === +const o2 = { +>o2 : Symbol(o2, Decl(O2.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O2.ts, 0, 12)) + + const x = yield; +>x : Symbol(x, Decl(O2.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/O3.ts === +const o3 = { +>o3 : Symbol(o3, Decl(O3.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O3.ts, 0, 12)) + + const x = yield 1; +>x : Symbol(x, Decl(O3.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/O4.ts === +const o4 = { +>o4 : Symbol(o4, Decl(O4.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O4.ts, 0, 12)) + + const x = yield* [1]; +>x : Symbol(x, Decl(O4.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/O5.ts === +const o5 = { +>o5 : Symbol(o5, Decl(O5.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O5.ts, 0, 12)) + + const x = yield* (async function*() { yield 1; })(); +>x : Symbol(x, Decl(O5.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/O6.ts === +const o6 = { +>o6 : Symbol(o6, Decl(O6.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O6.ts, 0, 12)) + + const x = await 1; +>x : Symbol(x, Decl(O6.ts, 2, 13)) + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/O7.ts === +const o7 = { +>o7 : Symbol(o7, Decl(O7.ts, 0, 5)) + + async * f() { +>f : Symbol(f, Decl(O7.ts, 0, 12)) + + return 1; + } +} + diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types new file mode 100644 index 00000000000..511cd7ec9e0 --- /dev/null +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types @@ -0,0 +1,96 @@ +=== tests/cases/conformance/emitter/esnext/asyncGenerators/O1.ts === +const o1 = { +>o1 : { f(): AsyncIterableIterator; } +>{ async * f() { }} : { f(): AsyncIterableIterator; } + + async * f() { +>f : () => AsyncIterableIterator + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/O2.ts === +const o2 = { +>o2 : { f(): AsyncIterableIterator; } +>{ async * f() { const x = yield; }} : { f(): AsyncIterableIterator; } + + async * f() { +>f : () => AsyncIterableIterator + + const x = yield; +>x : any +>yield : any + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/O3.ts === +const o3 = { +>o3 : { f(): AsyncIterableIterator<1>; } +>{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator<1>; } + + async * f() { +>f : () => AsyncIterableIterator<1> + + const x = yield 1; +>x : any +>yield 1 : any +>1 : 1 + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/O4.ts === +const o4 = { +>o4 : { f(): AsyncIterableIterator; } +>{ async * f() { const x = yield* [1]; }} : { f(): AsyncIterableIterator; } + + async * f() { +>f : () => AsyncIterableIterator + + const x = yield* [1]; +>x : any +>yield* [1] : any +>[1] : number[] +>1 : 1 + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/O5.ts === +const o5 = { +>o5 : { f(): AsyncIterableIterator<1>; } +>{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator<1>; } + + async * f() { +>f : () => AsyncIterableIterator<1> + + const x = yield* (async function*() { yield 1; })(); +>x : any +>yield* (async function*() { yield 1; })() : any +>(async function*() { yield 1; })() : AsyncIterableIterator<1> +>(async function*() { yield 1; }) : () => AsyncIterableIterator<1> +>async function*() { yield 1; } : () => AsyncIterableIterator<1> +>yield 1 : any +>1 : 1 + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/O6.ts === +const o6 = { +>o6 : { f(): AsyncIterableIterator; } +>{ async * f() { const x = await 1; }} : { f(): AsyncIterableIterator; } + + async * f() { +>f : () => AsyncIterableIterator + + const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 + } +} +=== tests/cases/conformance/emitter/esnext/asyncGenerators/O7.ts === +const o7 = { +>o7 : { f(): AsyncIterableIterator; } +>{ async * f() { return 1; }} : { f(): AsyncIterableIterator; } + + async * f() { +>f : () => AsyncIterableIterator + + return 1; +>1 : 1 + } +} + diff --git a/tests/baselines/reference/emitter.forAwait.es2015.js b/tests/baselines/reference/emitter.forAwait.es2015.js new file mode 100644 index 00000000000..a76c3e0b545 --- /dev/null +++ b/tests/baselines/reference/emitter.forAwait.es2015.js @@ -0,0 +1,165 @@ +//// [tests/cases/conformance/emitter/es2015/forAwait/emitter.forAwait.es2015.ts] //// + +//// [file1.ts] +async function f1() { + let y: any; + for await (const x of y) { + } +} +//// [file2.ts] +async function f2() { + let x: any, y: any; + for await (x of y) { + } +} +//// [file3.ts] +async function* f3() { + let y: any; + for await (const x of y) { + } +} +//// [file4.ts] +async function* f4() { + let x: any, y: any; + for await (x of y) { + } +} + +//// [file1.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __asyncValues = (this && this.__asyncIterator) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator]; + return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); +}; +function f1() { + return __awaiter(this, void 0, void 0, function* () { + let y; + try { + for (var y_1 = __asyncValues(y), y_1_1 = yield y_1.next(); !y_1_1.done; y_1_1 = yield y_1.next()) { + const x = y_1_1.value; + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (y_1_1 && !y_1_1.done && (_a = y_1.return)) yield _a.call(y_1); + } + finally { if (e_1) throw e_1.error; } + } + var e_1, _a; + }); +} +//// [file2.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __asyncValues = (this && this.__asyncIterator) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator]; + return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); +}; +function f2() { + return __awaiter(this, void 0, void 0, function* () { + let x, y; + try { + for (var y_1 = __asyncValues(y), y_1_1 = yield y_1.next(); !y_1_1.done; y_1_1 = yield y_1.next()) { + x = y_1_1.value; + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (y_1_1 && !y_1_1.done && (_a = y_1.return)) yield _a.call(y_1); + } + finally { if (e_1) throw e_1.error; } + } + var e_1, _a; + }); +} +//// [file3.js] +var __asyncValues = (this && this.__asyncIterator) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator]; + return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +function f3() { + return __asyncGenerator(this, arguments, function* f3_1() { + let y; + try { + for (var y_1 = __asyncValues(y), y_1_1 = yield ["await", y_1.next()]; !y_1_1.done; y_1_1 = yield ["await", y_1.next()]) { + const x = y_1_1.value; + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (y_1_1 && !y_1_1.done && (_a = y_1.return)) yield ["await", _a.call(y_1)]; + } + finally { if (e_1) throw e_1.error; } + } + var e_1, _a; + }); +} +//// [file4.js] +var __asyncValues = (this && this.__asyncIterator) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator]; + return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +function f4() { + return __asyncGenerator(this, arguments, function* f4_1() { + let x, y; + try { + for (var y_1 = __asyncValues(y), y_1_1 = yield ["await", y_1.next()]; !y_1_1.done; y_1_1 = yield ["await", y_1.next()]) { + x = y_1_1.value; + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (y_1_1 && !y_1_1.done && (_a = y_1.return)) yield ["await", _a.call(y_1)]; + } + finally { if (e_1) throw e_1.error; } + } + var e_1, _a; + }); +} diff --git a/tests/baselines/reference/emitter.forAwait.es2015.symbols b/tests/baselines/reference/emitter.forAwait.es2015.symbols new file mode 100644 index 00000000000..6c4ed3b10e9 --- /dev/null +++ b/tests/baselines/reference/emitter.forAwait.es2015.symbols @@ -0,0 +1,50 @@ +=== tests/cases/conformance/emitter/es2015/forAwait/file1.ts === +async function f1() { +>f1 : Symbol(f1, Decl(file1.ts, 0, 0)) + + let y: any; +>y : Symbol(y, Decl(file1.ts, 1, 7)) + + for await (const x of y) { +>x : Symbol(x, Decl(file1.ts, 2, 20)) +>y : Symbol(y, Decl(file1.ts, 1, 7)) + } +} +=== tests/cases/conformance/emitter/es2015/forAwait/file2.ts === +async function f2() { +>f2 : Symbol(f2, Decl(file2.ts, 0, 0)) + + let x: any, y: any; +>x : Symbol(x, Decl(file2.ts, 1, 7)) +>y : Symbol(y, Decl(file2.ts, 1, 15)) + + for await (x of y) { +>x : Symbol(x, Decl(file2.ts, 1, 7)) +>y : Symbol(y, Decl(file2.ts, 1, 15)) + } +} +=== tests/cases/conformance/emitter/es2015/forAwait/file3.ts === +async function* f3() { +>f3 : Symbol(f3, Decl(file3.ts, 0, 0)) + + let y: any; +>y : Symbol(y, Decl(file3.ts, 1, 7)) + + for await (const x of y) { +>x : Symbol(x, Decl(file3.ts, 2, 20)) +>y : Symbol(y, Decl(file3.ts, 1, 7)) + } +} +=== tests/cases/conformance/emitter/es2015/forAwait/file4.ts === +async function* f4() { +>f4 : Symbol(f4, Decl(file4.ts, 0, 0)) + + let x: any, y: any; +>x : Symbol(x, Decl(file4.ts, 1, 7)) +>y : Symbol(y, Decl(file4.ts, 1, 15)) + + for await (x of y) { +>x : Symbol(x, Decl(file4.ts, 1, 7)) +>y : Symbol(y, Decl(file4.ts, 1, 15)) + } +} diff --git a/tests/baselines/reference/emitter.forAwait.es2015.types b/tests/baselines/reference/emitter.forAwait.es2015.types new file mode 100644 index 00000000000..ac7321e43b4 --- /dev/null +++ b/tests/baselines/reference/emitter.forAwait.es2015.types @@ -0,0 +1,50 @@ +=== tests/cases/conformance/emitter/es2015/forAwait/file1.ts === +async function f1() { +>f1 : () => Promise + + let y: any; +>y : any + + for await (const x of y) { +>x : any +>y : any + } +} +=== tests/cases/conformance/emitter/es2015/forAwait/file2.ts === +async function f2() { +>f2 : () => Promise + + let x: any, y: any; +>x : any +>y : any + + for await (x of y) { +>x : any +>y : any + } +} +=== tests/cases/conformance/emitter/es2015/forAwait/file3.ts === +async function* f3() { +>f3 : () => AsyncIterableIterator + + let y: any; +>y : any + + for await (const x of y) { +>x : any +>y : any + } +} +=== tests/cases/conformance/emitter/es2015/forAwait/file4.ts === +async function* f4() { +>f4 : () => AsyncIterableIterator + + let x: any, y: any; +>x : any +>y : any + + for await (x of y) { +>x : any +>y : any + } +} diff --git a/tests/baselines/reference/emitter.forAwait.es5.js b/tests/baselines/reference/emitter.forAwait.es5.js new file mode 100644 index 00000000000..efbbe872b3f --- /dev/null +++ b/tests/baselines/reference/emitter.forAwait.es5.js @@ -0,0 +1,369 @@ +//// [tests/cases/conformance/emitter/es5/forAwait/emitter.forAwait.es5.ts] //// + +//// [file1.ts] +async function f1() { + let y: any; + for await (const x of y) { + } +} +//// [file2.ts] +async function f2() { + let x: any, y: any; + for await (x of y) { + } +} +//// [file3.ts] +async function* f3() { + let y: any; + for await (const x of y) { + } +} +//// [file4.ts] +async function* f4() { + let x: any, y: any; + for await (x of y) { + } +} + +//// [file1.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncValues = (this && this.__asyncIterator) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator]; + return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); +}; +function f1() { + return __awaiter(this, void 0, void 0, function () { + var y, y_1, y_1_1, x, _a, e_1, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + _c.trys.push([0, 6, 7, 12]); + y_1 = __asyncValues(y); + return [4 /*yield*/, y_1.next()]; + case 1: + y_1_1 = _c.sent(); + _c.label = 2; + case 2: + if (!!y_1_1.done) return [3 /*break*/, 5]; + x = y_1_1.value; + _c.label = 3; + case 3: return [4 /*yield*/, y_1.next()]; + case 4: + y_1_1 = _c.sent(); + return [3 /*break*/, 2]; + case 5: return [3 /*break*/, 12]; + case 6: + _a = _c.sent(); + e_1 = { error: e_1_1 }; + return [3 /*break*/, 12]; + case 7: + _c.trys.push([7, , 10, 11]); + if (!(y_1_1 && !y_1_1.done && (_b = y_1.return))) return [3 /*break*/, 9]; + return [4 /*yield*/, _b.call(y_1)]; + case 8: + _c.sent(); + _c.label = 9; + case 9: return [3 /*break*/, 11]; + case 10: + if (e_1) throw e_1.error; + return [7 /*endfinally*/]; + case 11: return [7 /*endfinally*/]; + case 12: return [2 /*return*/]; + } + }); + }); +} +//// [file2.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncValues = (this && this.__asyncIterator) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator]; + return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); +}; +function f2() { + return __awaiter(this, void 0, void 0, function () { + var x, y, y_1, y_1_1, _a, e_1, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + _c.trys.push([0, 6, 7, 12]); + y_1 = __asyncValues(y); + return [4 /*yield*/, y_1.next()]; + case 1: + y_1_1 = _c.sent(); + _c.label = 2; + case 2: + if (!!y_1_1.done) return [3 /*break*/, 5]; + x = y_1_1.value; + _c.label = 3; + case 3: return [4 /*yield*/, y_1.next()]; + case 4: + y_1_1 = _c.sent(); + return [3 /*break*/, 2]; + case 5: return [3 /*break*/, 12]; + case 6: + _a = _c.sent(); + e_1 = { error: e_1_1 }; + return [3 /*break*/, 12]; + case 7: + _c.trys.push([7, , 10, 11]); + if (!(y_1_1 && !y_1_1.done && (_b = y_1.return))) return [3 /*break*/, 9]; + return [4 /*yield*/, _b.call(y_1)]; + case 8: + _c.sent(); + _c.label = 9; + case 9: return [3 /*break*/, 11]; + case 10: + if (e_1) throw e_1.error; + return [7 /*endfinally*/]; + case 11: return [7 /*endfinally*/]; + case 12: return [2 /*return*/]; + } + }); + }); +} +//// [file3.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncValues = (this && this.__asyncIterator) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator]; + return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +function f3() { + return __asyncGenerator(this, arguments, function f3_1() { + var y, y_1, y_1_1, x, _a, e_1, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + _c.trys.push([0, 6, 7, 12]); + y_1 = __asyncValues(y); + return [4 /*yield*/, ["await", y_1.next()]]; + case 1: + y_1_1 = _c.sent(); + _c.label = 2; + case 2: + if (!!y_1_1.done) return [3 /*break*/, 5]; + x = y_1_1.value; + _c.label = 3; + case 3: return [4 /*yield*/, ["await", y_1.next()]]; + case 4: + y_1_1 = _c.sent(); + return [3 /*break*/, 2]; + case 5: return [3 /*break*/, 12]; + case 6: + _a = _c.sent(); + e_1 = { error: e_1_1 }; + return [3 /*break*/, 12]; + case 7: + _c.trys.push([7, , 10, 11]); + if (!(y_1_1 && !y_1_1.done && (_b = y_1.return))) return [3 /*break*/, 9]; + return [4 /*yield*/, ["await", _b.call(y_1)]]; + case 8: + _c.sent(); + _c.label = 9; + case 9: return [3 /*break*/, 11]; + case 10: + if (e_1) throw e_1.error; + return [7 /*endfinally*/]; + case 11: return [7 /*endfinally*/]; + case 12: return [2 /*return*/]; + } + }); + }); +} +//// [file4.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncValues = (this && this.__asyncIterator) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator]; + return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); +}; +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), q = [], c, i; + return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } + function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } + function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } + function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { c = void 0, f(v), next(); } +}; +function f4() { + return __asyncGenerator(this, arguments, function f4_1() { + var x, y, y_1, y_1_1, _a, e_1, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + _c.trys.push([0, 6, 7, 12]); + y_1 = __asyncValues(y); + return [4 /*yield*/, ["await", y_1.next()]]; + case 1: + y_1_1 = _c.sent(); + _c.label = 2; + case 2: + if (!!y_1_1.done) return [3 /*break*/, 5]; + x = y_1_1.value; + _c.label = 3; + case 3: return [4 /*yield*/, ["await", y_1.next()]]; + case 4: + y_1_1 = _c.sent(); + return [3 /*break*/, 2]; + case 5: return [3 /*break*/, 12]; + case 6: + _a = _c.sent(); + e_1 = { error: e_1_1 }; + return [3 /*break*/, 12]; + case 7: + _c.trys.push([7, , 10, 11]); + if (!(y_1_1 && !y_1_1.done && (_b = y_1.return))) return [3 /*break*/, 9]; + return [4 /*yield*/, ["await", _b.call(y_1)]]; + case 8: + _c.sent(); + _c.label = 9; + case 9: return [3 /*break*/, 11]; + case 10: + if (e_1) throw e_1.error; + return [7 /*endfinally*/]; + case 11: return [7 /*endfinally*/]; + case 12: return [2 /*return*/]; + } + }); + }); +} diff --git a/tests/baselines/reference/emitter.forAwait.es5.symbols b/tests/baselines/reference/emitter.forAwait.es5.symbols new file mode 100644 index 00000000000..40c5562453c --- /dev/null +++ b/tests/baselines/reference/emitter.forAwait.es5.symbols @@ -0,0 +1,50 @@ +=== tests/cases/conformance/emitter/es5/forAwait/file1.ts === +async function f1() { +>f1 : Symbol(f1, Decl(file1.ts, 0, 0)) + + let y: any; +>y : Symbol(y, Decl(file1.ts, 1, 7)) + + for await (const x of y) { +>x : Symbol(x, Decl(file1.ts, 2, 20)) +>y : Symbol(y, Decl(file1.ts, 1, 7)) + } +} +=== tests/cases/conformance/emitter/es5/forAwait/file2.ts === +async function f2() { +>f2 : Symbol(f2, Decl(file2.ts, 0, 0)) + + let x: any, y: any; +>x : Symbol(x, Decl(file2.ts, 1, 7)) +>y : Symbol(y, Decl(file2.ts, 1, 15)) + + for await (x of y) { +>x : Symbol(x, Decl(file2.ts, 1, 7)) +>y : Symbol(y, Decl(file2.ts, 1, 15)) + } +} +=== tests/cases/conformance/emitter/es5/forAwait/file3.ts === +async function* f3() { +>f3 : Symbol(f3, Decl(file3.ts, 0, 0)) + + let y: any; +>y : Symbol(y, Decl(file3.ts, 1, 7)) + + for await (const x of y) { +>x : Symbol(x, Decl(file3.ts, 2, 20)) +>y : Symbol(y, Decl(file3.ts, 1, 7)) + } +} +=== tests/cases/conformance/emitter/es5/forAwait/file4.ts === +async function* f4() { +>f4 : Symbol(f4, Decl(file4.ts, 0, 0)) + + let x: any, y: any; +>x : Symbol(x, Decl(file4.ts, 1, 7)) +>y : Symbol(y, Decl(file4.ts, 1, 15)) + + for await (x of y) { +>x : Symbol(x, Decl(file4.ts, 1, 7)) +>y : Symbol(y, Decl(file4.ts, 1, 15)) + } +} diff --git a/tests/baselines/reference/emitter.forAwait.es5.types b/tests/baselines/reference/emitter.forAwait.es5.types new file mode 100644 index 00000000000..8c8f6dec723 --- /dev/null +++ b/tests/baselines/reference/emitter.forAwait.es5.types @@ -0,0 +1,50 @@ +=== tests/cases/conformance/emitter/es5/forAwait/file1.ts === +async function f1() { +>f1 : () => Promise + + let y: any; +>y : any + + for await (const x of y) { +>x : any +>y : any + } +} +=== tests/cases/conformance/emitter/es5/forAwait/file2.ts === +async function f2() { +>f2 : () => Promise + + let x: any, y: any; +>x : any +>y : any + + for await (x of y) { +>x : any +>y : any + } +} +=== tests/cases/conformance/emitter/es5/forAwait/file3.ts === +async function* f3() { +>f3 : () => AsyncIterableIterator + + let y: any; +>y : any + + for await (const x of y) { +>x : any +>y : any + } +} +=== tests/cases/conformance/emitter/es5/forAwait/file4.ts === +async function* f4() { +>f4 : () => AsyncIterableIterator + + let x: any, y: any; +>x : any +>y : any + + for await (x of y) { +>x : any +>y : any + } +} diff --git a/tests/baselines/reference/emitter.forAwait.esnext.js b/tests/baselines/reference/emitter.forAwait.esnext.js new file mode 100644 index 00000000000..7a6c6837c9a --- /dev/null +++ b/tests/baselines/reference/emitter.forAwait.esnext.js @@ -0,0 +1,51 @@ +//// [tests/cases/conformance/emitter/esnext/forAwait/emitter.forAwait.esnext.ts] //// + +//// [file1.ts] +async function f1() { + let y: any; + for await (const x of y) { + } +} +//// [file2.ts] +async function f2() { + let x: any, y: any; + for await (x of y) { + } +} +//// [file3.ts] +async function* f3() { + let y: any; + for await (const x of y) { + } +} +//// [file4.ts] +async function* f4() { + let x: any, y: any; + for await (x of y) { + } +} + +//// [file1.js] +async function f1() { + let y; + for await (const x of y) { + } +} +//// [file2.js] +async function f2() { + let x, y; + for await (x of y) { + } +} +//// [file3.js] +async function* f3() { + let y; + for await (const x of y) { + } +} +//// [file4.js] +async function* f4() { + let x, y; + for await (x of y) { + } +} diff --git a/tests/baselines/reference/emitter.forAwait.esnext.symbols b/tests/baselines/reference/emitter.forAwait.esnext.symbols new file mode 100644 index 00000000000..137ebed0802 --- /dev/null +++ b/tests/baselines/reference/emitter.forAwait.esnext.symbols @@ -0,0 +1,50 @@ +=== tests/cases/conformance/emitter/esnext/forAwait/file1.ts === +async function f1() { +>f1 : Symbol(f1, Decl(file1.ts, 0, 0)) + + let y: any; +>y : Symbol(y, Decl(file1.ts, 1, 7)) + + for await (const x of y) { +>x : Symbol(x, Decl(file1.ts, 2, 20)) +>y : Symbol(y, Decl(file1.ts, 1, 7)) + } +} +=== tests/cases/conformance/emitter/esnext/forAwait/file2.ts === +async function f2() { +>f2 : Symbol(f2, Decl(file2.ts, 0, 0)) + + let x: any, y: any; +>x : Symbol(x, Decl(file2.ts, 1, 7)) +>y : Symbol(y, Decl(file2.ts, 1, 15)) + + for await (x of y) { +>x : Symbol(x, Decl(file2.ts, 1, 7)) +>y : Symbol(y, Decl(file2.ts, 1, 15)) + } +} +=== tests/cases/conformance/emitter/esnext/forAwait/file3.ts === +async function* f3() { +>f3 : Symbol(f3, Decl(file3.ts, 0, 0)) + + let y: any; +>y : Symbol(y, Decl(file3.ts, 1, 7)) + + for await (const x of y) { +>x : Symbol(x, Decl(file3.ts, 2, 20)) +>y : Symbol(y, Decl(file3.ts, 1, 7)) + } +} +=== tests/cases/conformance/emitter/esnext/forAwait/file4.ts === +async function* f4() { +>f4 : Symbol(f4, Decl(file4.ts, 0, 0)) + + let x: any, y: any; +>x : Symbol(x, Decl(file4.ts, 1, 7)) +>y : Symbol(y, Decl(file4.ts, 1, 15)) + + for await (x of y) { +>x : Symbol(x, Decl(file4.ts, 1, 7)) +>y : Symbol(y, Decl(file4.ts, 1, 15)) + } +} diff --git a/tests/baselines/reference/emitter.forAwait.esnext.types b/tests/baselines/reference/emitter.forAwait.esnext.types new file mode 100644 index 00000000000..ae52bd1080d --- /dev/null +++ b/tests/baselines/reference/emitter.forAwait.esnext.types @@ -0,0 +1,50 @@ +=== tests/cases/conformance/emitter/esnext/forAwait/file1.ts === +async function f1() { +>f1 : () => Promise + + let y: any; +>y : any + + for await (const x of y) { +>x : any +>y : any + } +} +=== tests/cases/conformance/emitter/esnext/forAwait/file2.ts === +async function f2() { +>f2 : () => Promise + + let x: any, y: any; +>x : any +>y : any + + for await (x of y) { +>x : any +>y : any + } +} +=== tests/cases/conformance/emitter/esnext/forAwait/file3.ts === +async function* f3() { +>f3 : () => AsyncIterableIterator + + let y: any; +>y : any + + for await (const x of y) { +>x : any +>y : any + } +} +=== tests/cases/conformance/emitter/esnext/forAwait/file4.ts === +async function* f4() { +>f4 : () => AsyncIterableIterator + + let x: any, y: any; +>x : any +>y : any + + for await (x of y) { +>x : any +>y : any + } +} diff --git a/tests/baselines/reference/emptyAssignmentPatterns01_ES5iterable.js b/tests/baselines/reference/emptyAssignmentPatterns01_ES5iterable.js new file mode 100644 index 00000000000..7123841025f --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns01_ES5iterable.js @@ -0,0 +1,15 @@ +//// [emptyAssignmentPatterns01_ES5iterable.ts] + +var a: any; + +({} = a); +([] = a); + +//// [emptyAssignmentPatterns01_ES5iterable.js] +var a; +(a); +(a); + + +//// [emptyAssignmentPatterns01_ES5iterable.d.ts] +declare var a: any; diff --git a/tests/baselines/reference/emptyAssignmentPatterns01_ES5iterable.symbols b/tests/baselines/reference/emptyAssignmentPatterns01_ES5iterable.symbols new file mode 100644 index 00000000000..8811c61dd9e --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns01_ES5iterable.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES5iterable.ts === + +var a: any; +>a : Symbol(a, Decl(emptyAssignmentPatterns01_ES5iterable.ts, 1, 3)) + +({} = a); +>a : Symbol(a, Decl(emptyAssignmentPatterns01_ES5iterable.ts, 1, 3)) + +([] = a); +>a : Symbol(a, Decl(emptyAssignmentPatterns01_ES5iterable.ts, 1, 3)) + diff --git a/tests/baselines/reference/emptyAssignmentPatterns01_ES5iterable.types b/tests/baselines/reference/emptyAssignmentPatterns01_ES5iterable.types new file mode 100644 index 00000000000..4a5e17d7cde --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns01_ES5iterable.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES5iterable.ts === + +var a: any; +>a : any + +({} = a); +>({} = a) : any +>{} = a : any +>{} : {} +>a : any + +([] = a); +>([] = a) : any +>[] = a : any +>[] : undefined[] +>a : any + diff --git a/tests/baselines/reference/emptyAssignmentPatterns02_ES5iterable.js b/tests/baselines/reference/emptyAssignmentPatterns02_ES5iterable.js new file mode 100644 index 00000000000..45cd426549e --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns02_ES5iterable.js @@ -0,0 +1,35 @@ +//// [emptyAssignmentPatterns02_ES5iterable.ts] + +var a: any; +let x, y, z, a1, a2, a3; + +({} = { x, y, z } = a); +([] = [ a1, a2, a3] = a); + +//// [emptyAssignmentPatterns02_ES5iterable.js] +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var a; +var x, y, z, a1, a2, a3; +(x = a.x, y = a.y, z = a.z); +(_a = __read(a, 3), a1 = _a[0], a2 = _a[1], a3 = _a[2]); +var _a; + + +//// [emptyAssignmentPatterns02_ES5iterable.d.ts] +declare var a: any; +declare let x: any, y: any, z: any, a1: any, a2: any, a3: any; diff --git a/tests/baselines/reference/emptyAssignmentPatterns02_ES5iterable.symbols b/tests/baselines/reference/emptyAssignmentPatterns02_ES5iterable.symbols new file mode 100644 index 00000000000..fc90df74d1d --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns02_ES5iterable.symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES5iterable.ts === + +var a: any; +>a : Symbol(a, Decl(emptyAssignmentPatterns02_ES5iterable.ts, 1, 3)) + +let x, y, z, a1, a2, a3; +>x : Symbol(x, Decl(emptyAssignmentPatterns02_ES5iterable.ts, 2, 3)) +>y : Symbol(y, Decl(emptyAssignmentPatterns02_ES5iterable.ts, 2, 6)) +>z : Symbol(z, Decl(emptyAssignmentPatterns02_ES5iterable.ts, 2, 9)) +>a1 : Symbol(a1, Decl(emptyAssignmentPatterns02_ES5iterable.ts, 2, 12)) +>a2 : Symbol(a2, Decl(emptyAssignmentPatterns02_ES5iterable.ts, 2, 16)) +>a3 : Symbol(a3, Decl(emptyAssignmentPatterns02_ES5iterable.ts, 2, 20)) + +({} = { x, y, z } = a); +>x : Symbol(x, Decl(emptyAssignmentPatterns02_ES5iterable.ts, 4, 7)) +>y : Symbol(y, Decl(emptyAssignmentPatterns02_ES5iterable.ts, 4, 10)) +>z : Symbol(z, Decl(emptyAssignmentPatterns02_ES5iterable.ts, 4, 13)) +>a : Symbol(a, Decl(emptyAssignmentPatterns02_ES5iterable.ts, 1, 3)) + +([] = [ a1, a2, a3] = a); +>a1 : Symbol(a1, Decl(emptyAssignmentPatterns02_ES5iterable.ts, 2, 12)) +>a2 : Symbol(a2, Decl(emptyAssignmentPatterns02_ES5iterable.ts, 2, 16)) +>a3 : Symbol(a3, Decl(emptyAssignmentPatterns02_ES5iterable.ts, 2, 20)) +>a : Symbol(a, Decl(emptyAssignmentPatterns02_ES5iterable.ts, 1, 3)) + diff --git a/tests/baselines/reference/emptyAssignmentPatterns02_ES5iterable.types b/tests/baselines/reference/emptyAssignmentPatterns02_ES5iterable.types new file mode 100644 index 00000000000..5f19cd98ec4 --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns02_ES5iterable.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES5iterable.ts === + +var a: any; +>a : any + +let x, y, z, a1, a2, a3; +>x : any +>y : any +>z : any +>a1 : any +>a2 : any +>a3 : any + +({} = { x, y, z } = a); +>({} = { x, y, z } = a) : any +>{} = { x, y, z } = a : any +>{} : {} +>{ x, y, z } = a : any +>{ x, y, z } : { x: any; y: any; z: any; } +>x : any +>y : any +>z : any +>a : any + +([] = [ a1, a2, a3] = a); +>([] = [ a1, a2, a3] = a) : any +>[] = [ a1, a2, a3] = a : any +>[] : undefined[] +>[ a1, a2, a3] = a : any +>[ a1, a2, a3] : [any, any, any] +>a1 : any +>a2 : any +>a3 : any +>a : any + diff --git a/tests/baselines/reference/emptyAssignmentPatterns03_ES5iterable.js b/tests/baselines/reference/emptyAssignmentPatterns03_ES5iterable.js new file mode 100644 index 00000000000..79806e5994d --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns03_ES5iterable.js @@ -0,0 +1,15 @@ +//// [emptyAssignmentPatterns03_ES5iterable.ts] + +var a: any; + +({} = {} = a); +([] = [] = a); + +//// [emptyAssignmentPatterns03_ES5iterable.js] +var a; +(a); +(a); + + +//// [emptyAssignmentPatterns03_ES5iterable.d.ts] +declare var a: any; diff --git a/tests/baselines/reference/emptyAssignmentPatterns03_ES5iterable.symbols b/tests/baselines/reference/emptyAssignmentPatterns03_ES5iterable.symbols new file mode 100644 index 00000000000..e1ac0ea4c5c --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns03_ES5iterable.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES5iterable.ts === + +var a: any; +>a : Symbol(a, Decl(emptyAssignmentPatterns03_ES5iterable.ts, 1, 3)) + +({} = {} = a); +>a : Symbol(a, Decl(emptyAssignmentPatterns03_ES5iterable.ts, 1, 3)) + +([] = [] = a); +>a : Symbol(a, Decl(emptyAssignmentPatterns03_ES5iterable.ts, 1, 3)) + diff --git a/tests/baselines/reference/emptyAssignmentPatterns03_ES5iterable.types b/tests/baselines/reference/emptyAssignmentPatterns03_ES5iterable.types new file mode 100644 index 00000000000..273d360d92f --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns03_ES5iterable.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES5iterable.ts === + +var a: any; +>a : any + +({} = {} = a); +>({} = {} = a) : any +>{} = {} = a : any +>{} : {} +>{} = a : any +>{} : {} +>a : any + +([] = [] = a); +>([] = [] = a) : any +>[] = [] = a : any +>[] : undefined[] +>[] = a : any +>[] : undefined[] +>a : any + diff --git a/tests/baselines/reference/emptyAssignmentPatterns04_ES5iterable.js b/tests/baselines/reference/emptyAssignmentPatterns04_ES5iterable.js new file mode 100644 index 00000000000..5cb4a63b03d --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns04_ES5iterable.js @@ -0,0 +1,35 @@ +//// [emptyAssignmentPatterns04_ES5iterable.ts] + +var a: any; +let x, y, z, a1, a2, a3; + +({ x, y, z } = {} = a); +([ a1, a2, a3] = [] = a); + +//// [emptyAssignmentPatterns04_ES5iterable.js] +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var a; +var x, y, z, a1, a2, a3; +(x = a.x, y = a.y, z = a.z); +(_a = __read(a, 3), a1 = _a[0], a2 = _a[1], a3 = _a[2]); +var _a; + + +//// [emptyAssignmentPatterns04_ES5iterable.d.ts] +declare var a: any; +declare let x: any, y: any, z: any, a1: any, a2: any, a3: any; diff --git a/tests/baselines/reference/emptyAssignmentPatterns04_ES5iterable.symbols b/tests/baselines/reference/emptyAssignmentPatterns04_ES5iterable.symbols new file mode 100644 index 00000000000..d433a0f125c --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns04_ES5iterable.symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES5iterable.ts === + +var a: any; +>a : Symbol(a, Decl(emptyAssignmentPatterns04_ES5iterable.ts, 1, 3)) + +let x, y, z, a1, a2, a3; +>x : Symbol(x, Decl(emptyAssignmentPatterns04_ES5iterable.ts, 2, 3)) +>y : Symbol(y, Decl(emptyAssignmentPatterns04_ES5iterable.ts, 2, 6)) +>z : Symbol(z, Decl(emptyAssignmentPatterns04_ES5iterable.ts, 2, 9)) +>a1 : Symbol(a1, Decl(emptyAssignmentPatterns04_ES5iterable.ts, 2, 12)) +>a2 : Symbol(a2, Decl(emptyAssignmentPatterns04_ES5iterable.ts, 2, 16)) +>a3 : Symbol(a3, Decl(emptyAssignmentPatterns04_ES5iterable.ts, 2, 20)) + +({ x, y, z } = {} = a); +>x : Symbol(x, Decl(emptyAssignmentPatterns04_ES5iterable.ts, 4, 2)) +>y : Symbol(y, Decl(emptyAssignmentPatterns04_ES5iterable.ts, 4, 5)) +>z : Symbol(z, Decl(emptyAssignmentPatterns04_ES5iterable.ts, 4, 8)) +>a : Symbol(a, Decl(emptyAssignmentPatterns04_ES5iterable.ts, 1, 3)) + +([ a1, a2, a3] = [] = a); +>a1 : Symbol(a1, Decl(emptyAssignmentPatterns04_ES5iterable.ts, 2, 12)) +>a2 : Symbol(a2, Decl(emptyAssignmentPatterns04_ES5iterable.ts, 2, 16)) +>a3 : Symbol(a3, Decl(emptyAssignmentPatterns04_ES5iterable.ts, 2, 20)) +>a : Symbol(a, Decl(emptyAssignmentPatterns04_ES5iterable.ts, 1, 3)) + diff --git a/tests/baselines/reference/emptyAssignmentPatterns04_ES5iterable.types b/tests/baselines/reference/emptyAssignmentPatterns04_ES5iterable.types new file mode 100644 index 00000000000..c926ec31bfa --- /dev/null +++ b/tests/baselines/reference/emptyAssignmentPatterns04_ES5iterable.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES5iterable.ts === + +var a: any; +>a : any + +let x, y, z, a1, a2, a3; +>x : any +>y : any +>z : any +>a1 : any +>a2 : any +>a3 : any + +({ x, y, z } = {} = a); +>({ x, y, z } = {} = a) : any +>{ x, y, z } = {} = a : any +>{ x, y, z } : { x: any; y: any; z: any; } +>x : any +>y : any +>z : any +>{} = a : any +>{} : {} +>a : any + +([ a1, a2, a3] = [] = a); +>([ a1, a2, a3] = [] = a) : any +>[ a1, a2, a3] = [] = a : any +>[ a1, a2, a3] : [any, any, any] +>a1 : any +>a2 : any +>a3 : any +>[] = a : any +>[] : undefined[] +>a : any + diff --git a/tests/baselines/reference/emptyModuleName.js b/tests/baselines/reference/emptyModuleName.js index 3ed21cf217a..d98359d94bb 100644 --- a/tests/baselines/reference/emptyModuleName.js +++ b/tests/baselines/reference/emptyModuleName.js @@ -5,16 +5,22 @@ class B extends A { //// [emptyModuleName.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var A = require(""); var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5iterable.js b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5iterable.js new file mode 100644 index 00000000000..c4eeb9994e6 --- /dev/null +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5iterable.js @@ -0,0 +1,182 @@ +//// [emptyVariableDeclarationBindingPatterns01_ES5iterable.ts] + +(function () { + var a: any; + + var {} = a; + let {} = a; + const {} = a; + + var [] = a; + let [] = a; + const [] = a; + + var {} = a, [] = a; + let {} = a, [] = a; + const {} = a, [] = a; + + var { p1: {}, p2: [] } = a; + let { p1: {}, p2: [] } = a; + const { p1: {}, p2: [] } = a; + + for (var {} = {}, {} = {}; false; void 0) { + } + + function f({} = a, [] = a, { p: {} = a} = a) { + return ({} = a, [] = a, { p: {} = a } = a) => a; + } +})(); + +(function () { + const ns: number[][] = []; + + for (var {} of ns) { + } + + for (let {} of ns) { + } + + for (const {} of ns) { + } + + for (var [] of ns) { + } + + for (let [] of ns) { + } + + for (const [] of ns) { + } +})(); + +//// [emptyVariableDeclarationBindingPatterns01_ES5iterable.js] +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __values = (this && this.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; +(function () { + var a; + var _a = a; + var _b = a; + var _c = a; + var _d = __read(a, 0); + var _e = __read(a, 0); + var _f = __read(a, 0); + var _g = a, _h = __read(a, 0); + var _j = a, _k = __read(a, 0); + var _l = a, _m = __read(a, 0); + var _o = a.p1, _p = __read(a.p2, 0); + var _q = a.p1, _r = __read(a.p2, 0); + var _s = a.p1, _t = __read(a.p2, 0); + for (var _u = {}, _v = {}; false; void 0) { + } + function f(_a, _b, _c) { + _a = a; + _b = a; + var _d = (_c === void 0 ? a : _c).p, _e = _d === void 0 ? a : _d; + return function (_a, _b, _c) { + _a = a; + _b = a; + var _d = (_c === void 0 ? a : _c).p, _e = _d === void 0 ? a : _d; + return a; + }; + } +})(); +(function () { + var ns = []; + try { + for (var ns_1 = __values(ns), ns_1_1 = ns_1.next(); !ns_1_1.done; ns_1_1 = ns_1.next()) { + var _a = ns_1_1.value; + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (ns_1_1 && !ns_1_1.done && (_b = ns_1.return)) _b.call(ns_1); + } + finally { if (e_1) throw e_1.error; } + } + try { + for (var ns_2 = __values(ns), ns_2_1 = ns_2.next(); !ns_2_1.done; ns_2_1 = ns_2.next()) { + var _c = ns_2_1.value; + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (ns_2_1 && !ns_2_1.done && (_d = ns_2.return)) _d.call(ns_2); + } + finally { if (e_2) throw e_2.error; } + } + try { + for (var ns_3 = __values(ns), ns_3_1 = ns_3.next(); !ns_3_1.done; ns_3_1 = ns_3.next()) { + var _e = ns_3_1.value; + } + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (ns_3_1 && !ns_3_1.done && (_f = ns_3.return)) _f.call(ns_3); + } + finally { if (e_3) throw e_3.error; } + } + try { + for (var ns_4 = __values(ns), ns_4_1 = ns_4.next(); !ns_4_1.done; ns_4_1 = ns_4.next()) { + var _g = __read(ns_4_1.value, 0); + } + } + catch (e_4_1) { e_4 = { error: e_4_1 }; } + finally { + try { + if (ns_4_1 && !ns_4_1.done && (_h = ns_4.return)) _h.call(ns_4); + } + finally { if (e_4) throw e_4.error; } + } + try { + for (var ns_5 = __values(ns), ns_5_1 = ns_5.next(); !ns_5_1.done; ns_5_1 = ns_5.next()) { + var _j = __read(ns_5_1.value, 0); + } + } + catch (e_5_1) { e_5 = { error: e_5_1 }; } + finally { + try { + if (ns_5_1 && !ns_5_1.done && (_k = ns_5.return)) _k.call(ns_5); + } + finally { if (e_5) throw e_5.error; } + } + try { + for (var ns_6 = __values(ns), ns_6_1 = ns_6.next(); !ns_6_1.done; ns_6_1 = ns_6.next()) { + var _l = __read(ns_6_1.value, 0); + } + } + catch (e_6_1) { e_6 = { error: e_6_1 }; } + finally { + try { + if (ns_6_1 && !ns_6_1.done && (_m = ns_6.return)) _m.call(ns_6); + } + finally { if (e_6) throw e_6.error; } + } + var e_1, _b, e_2, _d, e_3, _f, e_4, _h, e_5, _k, e_6, _m; +})(); diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5iterable.symbols b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5iterable.symbols new file mode 100644 index 00000000000..d77525cf767 --- /dev/null +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5iterable.symbols @@ -0,0 +1,92 @@ +=== tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5iterable.ts === + +(function () { + var a: any; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) + + var {} = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) + + let {} = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) + + const {} = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) + + var [] = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) + + let [] = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) + + const [] = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) + + var {} = a, [] = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) + + let {} = a, [] = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) + + const {} = a, [] = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) + + var { p1: {}, p2: [] } = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) + + let { p1: {}, p2: [] } = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) + + const { p1: {}, p2: [] } = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) + + for (var {} = {}, {} = {}; false; void 0) { + } + + function f({} = a, [] = a, { p: {} = a} = a) { +>f : Symbol(f, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 21, 5)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) + + return ({} = a, [] = a, { p: {} = a } = a) => a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 2, 7)) + } +})(); + +(function () { + const ns: number[][] = []; +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 29, 9)) + + for (var {} of ns) { +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 29, 9)) + } + + for (let {} of ns) { +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 29, 9)) + } + + for (const {} of ns) { +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 29, 9)) + } + + for (var [] of ns) { +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 29, 9)) + } + + for (let [] of ns) { +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 29, 9)) + } + + for (const [] of ns) { +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5iterable.ts, 29, 9)) + } +})(); diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5iterable.types b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5iterable.types new file mode 100644 index 00000000000..591b149ac07 --- /dev/null +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5iterable.types @@ -0,0 +1,115 @@ +=== tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5iterable.ts === + +(function () { +>(function () { var a: any; var {} = a; let {} = a; const {} = a; var [] = a; let [] = a; const [] = a; var {} = a, [] = a; let {} = a, [] = a; const {} = a, [] = a; var { p1: {}, p2: [] } = a; let { p1: {}, p2: [] } = a; const { p1: {}, p2: [] } = a; for (var {} = {}, {} = {}; false; void 0) { } function f({} = a, [] = a, { p: {} = a} = a) { return ({} = a, [] = a, { p: {} = a } = a) => a; }})() : void +>(function () { var a: any; var {} = a; let {} = a; const {} = a; var [] = a; let [] = a; const [] = a; var {} = a, [] = a; let {} = a, [] = a; const {} = a, [] = a; var { p1: {}, p2: [] } = a; let { p1: {}, p2: [] } = a; const { p1: {}, p2: [] } = a; for (var {} = {}, {} = {}; false; void 0) { } function f({} = a, [] = a, { p: {} = a} = a) { return ({} = a, [] = a, { p: {} = a } = a) => a; }}) : () => void +>function () { var a: any; var {} = a; let {} = a; const {} = a; var [] = a; let [] = a; const [] = a; var {} = a, [] = a; let {} = a, [] = a; const {} = a, [] = a; var { p1: {}, p2: [] } = a; let { p1: {}, p2: [] } = a; const { p1: {}, p2: [] } = a; for (var {} = {}, {} = {}; false; void 0) { } function f({} = a, [] = a, { p: {} = a} = a) { return ({} = a, [] = a, { p: {} = a } = a) => a; }} : () => void + + var a: any; +>a : any + + var {} = a; +>a : any + + let {} = a; +>a : any + + const {} = a; +>a : any + + var [] = a; +>a : any + + let [] = a; +>a : any + + const [] = a; +>a : any + + var {} = a, [] = a; +>a : any +>a : any + + let {} = a, [] = a; +>a : any +>a : any + + const {} = a, [] = a; +>a : any +>a : any + + var { p1: {}, p2: [] } = a; +>p1 : any +>p2 : any +>a : any + + let { p1: {}, p2: [] } = a; +>p1 : any +>p2 : any +>a : any + + const { p1: {}, p2: [] } = a; +>p1 : any +>p2 : any +>a : any + + for (var {} = {}, {} = {}; false; void 0) { +>{} : {} +>{} : {} +>false : false +>void 0 : undefined +>0 : 0 + } + + function f({} = a, [] = a, { p: {} = a} = a) { +>f : ({}?: any, []?: any, {p: {}}?: any) => ({}?: any, []?: any, {p: {}}?: any) => any +>a : any +>a : any +>p : any +>a : any +>a : any + + return ({} = a, [] = a, { p: {} = a } = a) => a; +>({} = a, [] = a, { p: {} = a } = a) => a : ({}?: any, []?: any, {p: {}}?: any) => any +>a : any +>a : any +>p : any +>a : any +>a : any +>a : any + } +})(); + +(function () { +>(function () { const ns: number[][] = []; for (var {} of ns) { } for (let {} of ns) { } for (const {} of ns) { } for (var [] of ns) { } for (let [] of ns) { } for (const [] of ns) { }})() : void +>(function () { const ns: number[][] = []; for (var {} of ns) { } for (let {} of ns) { } for (const {} of ns) { } for (var [] of ns) { } for (let [] of ns) { } for (const [] of ns) { }}) : () => void +>function () { const ns: number[][] = []; for (var {} of ns) { } for (let {} of ns) { } for (const {} of ns) { } for (var [] of ns) { } for (let [] of ns) { } for (const [] of ns) { }} : () => void + + const ns: number[][] = []; +>ns : number[][] +>[] : undefined[] + + for (var {} of ns) { +>ns : number[][] + } + + for (let {} of ns) { +>ns : number[][] + } + + for (const {} of ns) { +>ns : number[][] + } + + for (var [] of ns) { +>ns : number[][] + } + + for (let [] of ns) { +>ns : number[][] + } + + for (const [] of ns) { +>ns : number[][] + } +})(); diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES5iterable.errors.txt b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES5iterable.errors.txt new file mode 100644 index 00000000000..453f44be10c --- /dev/null +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES5iterable.errors.txt @@ -0,0 +1,31 @@ +tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5iterable.ts(3,9): error TS1182: A destructuring declaration must have an initializer. +tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5iterable.ts(4,9): error TS1182: A destructuring declaration must have an initializer. +tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5iterable.ts(5,11): error TS1182: A destructuring declaration must have an initializer. +tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5iterable.ts(7,9): error TS1182: A destructuring declaration must have an initializer. +tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5iterable.ts(8,9): error TS1182: A destructuring declaration must have an initializer. +tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5iterable.ts(9,11): error TS1182: A destructuring declaration must have an initializer. + + +==== tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5iterable.ts (6 errors) ==== + + (function () { + var {}; + ~~ +!!! error TS1182: A destructuring declaration must have an initializer. + let {}; + ~~ +!!! error TS1182: A destructuring declaration must have an initializer. + const {}; + ~~ +!!! error TS1182: A destructuring declaration must have an initializer. + + var []; + ~~ +!!! error TS1182: A destructuring declaration must have an initializer. + let []; + ~~ +!!! error TS1182: A destructuring declaration must have an initializer. + const []; + ~~ +!!! error TS1182: A destructuring declaration must have an initializer. + })(); \ No newline at end of file diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES5iterable.js b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES5iterable.js new file mode 100644 index 00000000000..b5457d0a2ec --- /dev/null +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES5iterable.js @@ -0,0 +1,40 @@ +//// [emptyVariableDeclarationBindingPatterns02_ES5iterable.ts] + +(function () { + var {}; + let {}; + const {}; + + var []; + let []; + const []; +})(); + +//// [emptyVariableDeclarationBindingPatterns02_ES5iterable.js] +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +(function () { + var _a = void 0; + var _b = void 0; + var _c = void 0; + var _d = __read(void 0, 0); + var _e = __read(void 0, 0); + var _f = __read(void 0, 0); +})(); + + +//// [emptyVariableDeclarationBindingPatterns02_ES5iterable.d.ts] diff --git a/tests/baselines/reference/enumFromExternalModule.js b/tests/baselines/reference/enumFromExternalModule.js index a6e9f6b6076..2a1865d3ccd 100644 --- a/tests/baselines/reference/enumFromExternalModule.js +++ b/tests/baselines/reference/enumFromExternalModule.js @@ -12,12 +12,14 @@ var x = f.Mode.Open; //// [enumFromExternalModule_0.js] "use strict"; +exports.__esModule = true; var Mode; (function (Mode) { Mode[Mode["Open"] = 0] = "Open"; })(Mode = exports.Mode || (exports.Mode = {})); //// [enumFromExternalModule_1.js] "use strict"; +exports.__esModule = true; /// var f = require("./enumFromExternalModule_0"); var x = f.Mode.Open; diff --git a/tests/baselines/reference/equalityStrictNulls.errors.txt b/tests/baselines/reference/equalityStrictNulls.errors.txt index e0793542b84..16772d8eeab 100644 --- a/tests/baselines/reference/equalityStrictNulls.errors.txt +++ b/tests/baselines/reference/equalityStrictNulls.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(60,9): error TS2365: Operator '>' cannot be applied to types 'number' and 'undefined'. -tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(62,9): error TS2365: Operator '<' cannot be applied to types 'number' and 'undefined'. -tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(64,9): error TS2365: Operator '>=' cannot be applied to types 'number' and 'undefined'. -tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(66,9): error TS2365: Operator '<=' cannot be applied to types 'number' and 'undefined'. +tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(60,13): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(62,13): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(64,14): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(66,14): error TS2532: Object is possibly 'undefined'. ==== tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts (4 errors) ==== @@ -65,20 +65,20 @@ tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.t function f4(x: number) { if (x > undefined) { - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'number' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. } if (x < undefined) { - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'number' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. } if (x >= undefined) { - ~~~~~~~~~~~~~~ -!!! error TS2365: Operator '>=' cannot be applied to types 'number' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. } if (x <= undefined) { - ~~~~~~~~~~~~~~ -!!! error TS2365: Operator '<=' cannot be applied to types 'number' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. } } function f5(x: string) { diff --git a/tests/baselines/reference/errorForwardReferenceForwadingConstructor.js b/tests/baselines/reference/errorForwardReferenceForwadingConstructor.js index ed2e1aa7f06..27f05f3f8ea 100644 --- a/tests/baselines/reference/errorForwardReferenceForwadingConstructor.js +++ b/tests/baselines/reference/errorForwardReferenceForwadingConstructor.js @@ -12,11 +12,16 @@ class derived extends base { } //// [errorForwardReferenceForwadingConstructor.js] // Error forward referencing derived class with forwarding constructor -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function f() { var d1 = new derived(); var d2 = new derived(4); @@ -30,7 +35,7 @@ var base = (function () { var derived = (function (_super) { __extends(derived, _super); function derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return derived; }(base)); diff --git a/tests/baselines/reference/errorSuperCalls.js b/tests/baselines/reference/errorSuperCalls.js index 720894e50c0..ebe9de27f42 100644 --- a/tests/baselines/reference/errorSuperCalls.js +++ b/tests/baselines/reference/errorSuperCalls.js @@ -75,11 +75,16 @@ class OtherDerived extends OtherBase { //// [errorSuperCalls.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); //super call in class constructor with no base type var NoBase = (function () { function NoBase() { @@ -132,7 +137,7 @@ var Derived = (function (_super) { __extends(Derived, _super); //super call with type arguments function Derived() { - var _this; + var _this = this; _super.prototype..call(_this); _this = _super.call(this) || this; return _this; @@ -147,7 +152,7 @@ var OtherBase = (function () { var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; //super call in class member initializer of derived type _this.t = _this = _super.call(this) || this; return _this; diff --git a/tests/baselines/reference/errorSuperPropertyAccess.js b/tests/baselines/reference/errorSuperPropertyAccess.js index e12a758b053..b33755e245a 100644 --- a/tests/baselines/reference/errorSuperPropertyAccess.js +++ b/tests/baselines/reference/errorSuperPropertyAccess.js @@ -129,11 +129,16 @@ var obj = { n: super.wat, p: super.foo() }; //// [errorSuperPropertyAccess.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); //super property access in constructor of class with no base type //super property access in instance member function of class with no base type //super property access in instance member accessor(get and set) of class with no base type @@ -247,7 +252,7 @@ var SomeDerived2 = (function (_super) { var SomeDerived3 = (function (_super) { __extends(SomeDerived3, _super); function SomeDerived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SomeDerived3.fn = function () { _super.publicStaticMember = 3; diff --git a/tests/baselines/reference/errorsInGenericTypeReference.js b/tests/baselines/reference/errorsInGenericTypeReference.js index 6dd9f62edcb..2e54d0cf71c 100644 --- a/tests/baselines/reference/errorsInGenericTypeReference.js +++ b/tests/baselines/reference/errorsInGenericTypeReference.js @@ -73,11 +73,16 @@ interface testInterface2 { //// [errorsInGenericTypeReference.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -135,7 +140,7 @@ var testClass6 = (function () { var testClass7 = (function (_super) { __extends(testClass7, _super); function testClass7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return testClass7; }(Foo)); // error: could not find symbol V diff --git a/tests/baselines/reference/errorsOnImportedSymbol.js b/tests/baselines/reference/errorsOnImportedSymbol.js index 4c7dca8274e..15ae0c90bd1 100644 --- a/tests/baselines/reference/errorsOnImportedSymbol.js +++ b/tests/baselines/reference/errorsOnImportedSymbol.js @@ -17,7 +17,9 @@ var y = Sammy.Sammy(); //// [errorsOnImportedSymbol_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); //// [errorsOnImportedSymbol_1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var x = new Sammy.Sammy(); var y = Sammy.Sammy(); diff --git a/tests/baselines/reference/es2017basicAsync.symbols b/tests/baselines/reference/es2017basicAsync.symbols index d79faf1502a..fc73741ba82 100644 --- a/tests/baselines/reference/es2017basicAsync.symbols +++ b/tests/baselines/reference/es2017basicAsync.symbols @@ -1,7 +1,7 @@ === tests/cases/compiler/es2017basicAsync.ts === async (): Promise => { ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 0; } @@ -14,7 +14,7 @@ async function asyncFunc() { const asyncArrowFunc = async (): Promise => { >asyncArrowFunc : Symbol(asyncArrowFunc, Decl(es2017basicAsync.ts, 9, 5)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 0; } @@ -25,20 +25,20 @@ async function asyncIIFE() { await 0; await (async function(): Promise { ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 1; })(); await (async function asyncNamedFunc(): Promise { >asyncNamedFunc : Symbol(asyncNamedFunc, Decl(es2017basicAsync.ts, 20, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 1; })(); await (async (): Promise => { ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 1; })(); @@ -49,7 +49,7 @@ class AsyncClass { asyncPropFunc = async function(): Promise { >asyncPropFunc : Symbol(AsyncClass.asyncPropFunc, Decl(es2017basicAsync.ts, 29, 18)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; } @@ -57,21 +57,21 @@ class AsyncClass { asyncPropNamedFunc = async function namedFunc(): Promise { >asyncPropNamedFunc : Symbol(AsyncClass.asyncPropNamedFunc, Decl(es2017basicAsync.ts, 32, 5)) >namedFunc : Symbol(namedFunc, Decl(es2017basicAsync.ts, 34, 24)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; } asyncPropArrowFunc = async (): Promise => { >asyncPropArrowFunc : Symbol(AsyncClass.asyncPropArrowFunc, Decl(es2017basicAsync.ts, 36, 5)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; } async asyncMethod(): Promise { >asyncMethod : Symbol(AsyncClass.asyncMethod, Decl(es2017basicAsync.ts, 40, 5)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; } diff --git a/tests/baselines/reference/es3-jsx-preserve.js b/tests/baselines/reference/es3-jsx-preserve.js new file mode 100644 index 00000000000..cb1ba2a887d --- /dev/null +++ b/tests/baselines/reference/es3-jsx-preserve.js @@ -0,0 +1,11 @@ +//// [es3-jsx-preserve.tsx] + +const React: any = null; + +const elem =
; + + + +//// [es3-jsx-preserve.jsx] +var React = null; +var elem =
; diff --git a/tests/baselines/reference/es3-jsx-preserve.symbols b/tests/baselines/reference/es3-jsx-preserve.symbols new file mode 100644 index 00000000000..61c9260223f --- /dev/null +++ b/tests/baselines/reference/es3-jsx-preserve.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/es3-jsx-preserve.tsx === + +const React: any = null; +>React : Symbol(React, Decl(es3-jsx-preserve.tsx, 1, 5)) + +const elem =
; +>elem : Symbol(elem, Decl(es3-jsx-preserve.tsx, 3, 5)) +>div : Symbol(unknown) +>div : Symbol(unknown) + + diff --git a/tests/baselines/reference/es3-jsx-preserve.types b/tests/baselines/reference/es3-jsx-preserve.types new file mode 100644 index 00000000000..b37fe8af567 --- /dev/null +++ b/tests/baselines/reference/es3-jsx-preserve.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/es3-jsx-preserve.tsx === + +const React: any = null; +>React : any +>null : null + +const elem =
; +>elem : any +>
: any +>div : any +>div : any + + diff --git a/tests/baselines/reference/es3-jsx-react-native.js b/tests/baselines/reference/es3-jsx-react-native.js new file mode 100644 index 00000000000..08e6e25502b --- /dev/null +++ b/tests/baselines/reference/es3-jsx-react-native.js @@ -0,0 +1,11 @@ +//// [es3-jsx-react-native.tsx] + +const React: any = null; + +const elem =
; + + + +//// [es3-jsx-react-native.js] +var React = null; +var elem =
; diff --git a/tests/baselines/reference/es3-jsx-react-native.symbols b/tests/baselines/reference/es3-jsx-react-native.symbols new file mode 100644 index 00000000000..e7f010bd2ea --- /dev/null +++ b/tests/baselines/reference/es3-jsx-react-native.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/es3-jsx-react-native.tsx === + +const React: any = null; +>React : Symbol(React, Decl(es3-jsx-react-native.tsx, 1, 5)) + +const elem =
; +>elem : Symbol(elem, Decl(es3-jsx-react-native.tsx, 3, 5)) +>div : Symbol(unknown) +>div : Symbol(unknown) + + diff --git a/tests/baselines/reference/es3-jsx-react-native.types b/tests/baselines/reference/es3-jsx-react-native.types new file mode 100644 index 00000000000..1bf199606f2 --- /dev/null +++ b/tests/baselines/reference/es3-jsx-react-native.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/es3-jsx-react-native.tsx === + +const React: any = null; +>React : any +>null : null + +const elem =
; +>elem : any +>
: any +>div : any +>div : any + + diff --git a/tests/baselines/reference/es3-jsx-react.js b/tests/baselines/reference/es3-jsx-react.js new file mode 100644 index 00000000000..861dde74c86 --- /dev/null +++ b/tests/baselines/reference/es3-jsx-react.js @@ -0,0 +1,11 @@ +//// [es3-jsx-react.tsx] + +const React: any = null; + +const elem =
; + + + +//// [es3-jsx-react.js] +var React = null; +var elem = React.createElement("div", null); diff --git a/tests/baselines/reference/es3-jsx-react.symbols b/tests/baselines/reference/es3-jsx-react.symbols new file mode 100644 index 00000000000..465cfab7ea9 --- /dev/null +++ b/tests/baselines/reference/es3-jsx-react.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/es3-jsx-react.tsx === + +const React: any = null; +>React : Symbol(React, Decl(es3-jsx-react.tsx, 1, 5)) + +const elem =
; +>elem : Symbol(elem, Decl(es3-jsx-react.tsx, 3, 5)) +>div : Symbol(unknown) +>div : Symbol(unknown) + + diff --git a/tests/baselines/reference/es3-jsx-react.types b/tests/baselines/reference/es3-jsx-react.types new file mode 100644 index 00000000000..b7734ffc1f0 --- /dev/null +++ b/tests/baselines/reference/es3-jsx-react.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/es3-jsx-react.tsx === + +const React: any = null; +>React : any +>null : null + +const elem =
; +>elem : any +>
: any +>div : any +>div : any + + diff --git a/tests/baselines/reference/es3defaultAliasIsQuoted.js b/tests/baselines/reference/es3defaultAliasIsQuoted.js index 89fd0c47a7e..d3bb3d006e5 100644 --- a/tests/baselines/reference/es3defaultAliasIsQuoted.js +++ b/tests/baselines/reference/es3defaultAliasIsQuoted.js @@ -16,6 +16,7 @@ assert(Foo.CONSTANT === "Foo"); //// [es3defaultAliasQuoted_file0.js] "use strict"; +exports.__esModule = true; var Foo = (function () { function Foo() { } @@ -27,9 +28,9 @@ function assert(value) { if (!value) throw new Error("Assertion failed!"); } -exports.__esModule = true; exports["default"] = assert; //// [es3defaultAliasQuoted_file1.js] "use strict"; +exports.__esModule = true; var es3defaultAliasQuoted_file0_1 = require("./es3defaultAliasQuoted_file0"); es3defaultAliasQuoted_file0_1["default"](es3defaultAliasQuoted_file0_1.Foo.CONSTANT === "Foo"); diff --git a/tests/baselines/reference/es5-asyncFunction.js b/tests/baselines/reference/es5-asyncFunction.js index 6f04c7ed7ef..21bd517adc2 100644 --- a/tests/baselines/reference/es5-asyncFunction.js +++ b/tests/baselines/reference/es5-asyncFunction.js @@ -18,8 +18,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t; - return { next: verb(0), "throw": verb(1), "return": verb(2) }; + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); diff --git a/tests/baselines/reference/es5-asyncFunctionArrayLiterals.js b/tests/baselines/reference/es5-asyncFunctionArrayLiterals.js index c8a4733aa94..d3f570d5882 100644 --- a/tests/baselines/reference/es5-asyncFunctionArrayLiterals.js +++ b/tests/baselines/reference/es5-asyncFunctionArrayLiterals.js @@ -36,12 +36,11 @@ async function arrayLiteral7() { //// [es5-asyncFunctionArrayLiterals.js] function arrayLiteral0() { return __awaiter(this, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { + return __generator(this, function (_a) { + switch (_a.label) { case 0: return [4 /*yield*/, y]; case 1: - x = [_b.sent(), z]; + x = [_a.sent(), z]; return [2 /*return*/]; } }); @@ -76,14 +75,14 @@ function arrayLiteral2() { } function arrayLiteral3() { return __awaiter(this, void 0, void 0, function () { - var _a, _b, _c, _d; - return __generator(this, function (_e) { - switch (_e.label) { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { case 0: _b = (_a = y).concat; return [4 /*yield*/, z]; case 1: - x = _b.apply(_a, [[_e.sent()]]); + x = _b.apply(_a, [[_c.sent()]]); return [2 /*return*/]; } }); @@ -91,12 +90,11 @@ function arrayLiteral3() { } function arrayLiteral4() { return __awaiter(this, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { + return __generator(this, function (_a) { + switch (_a.label) { case 0: return [4 /*yield*/, y]; case 1: - x = [_b.sent()].concat(z); + x = [_a.sent()].concat(z); return [2 /*return*/]; } }); @@ -104,14 +102,14 @@ function arrayLiteral4() { } function arrayLiteral5() { return __awaiter(this, void 0, void 0, function () { - var _a, _b, _c; - return __generator(this, function (_d) { - switch (_d.label) { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { case 0: _b = (_a = [y]).concat; return [4 /*yield*/, z]; case 1: - x = _b.apply(_a, [(_d.sent())]); + x = _b.apply(_a, [(_c.sent())]); return [2 /*return*/]; } }); diff --git a/tests/baselines/reference/es5-asyncFunctionBinaryExpressions.js b/tests/baselines/reference/es5-asyncFunctionBinaryExpressions.js index 23a79cef343..809f6254f08 100644 --- a/tests/baselines/reference/es5-asyncFunctionBinaryExpressions.js +++ b/tests/baselines/reference/es5-asyncFunctionBinaryExpressions.js @@ -518,19 +518,19 @@ function binaryCompoundAssignment8() { } function binaryExponentiation() { return __awaiter(this, void 0, void 0, function () { - var _a, _b, _c, _d, _e, _f; - return __generator(this, function (_g) { - switch (_g.label) { + var _a, _b, _c, _d, _e; + return __generator(this, function (_f) { + switch (_f.label) { case 0: _b = (_a = Math).pow; return [4 /*yield*/, x]; case 1: - _b.apply(_a, [(_g.sent()), y]); - _e = (_d = Math).pow; - _f = [x]; + _b.apply(_a, [(_f.sent()), y]); + _d = (_c = Math).pow; + _e = [x]; return [4 /*yield*/, y]; case 2: - _e.apply(_d, _f.concat([_g.sent()])); + _d.apply(_c, _e.concat([_f.sent()])); return [2 /*return*/]; } }); diff --git a/tests/baselines/reference/es5-asyncFunctionBinaryExpressions.symbols b/tests/baselines/reference/es5-asyncFunctionBinaryExpressions.symbols index 6c6a1820717..eada06414bf 100644 --- a/tests/baselines/reference/es5-asyncFunctionBinaryExpressions.symbols +++ b/tests/baselines/reference/es5-asyncFunctionBinaryExpressions.symbols @@ -259,7 +259,7 @@ async function binaryComma0() { async function binaryComma1(): Promise { >binaryComma1 : Symbol(binaryComma1, Decl(es5-asyncFunctionBinaryExpressions.ts, 117, 1)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) return x, await y; >x : Symbol(x, Decl(es5-asyncFunctionBinaryExpressions.ts, 0, 11)) diff --git a/tests/baselines/reference/es5-asyncFunctionCallExpressions.js b/tests/baselines/reference/es5-asyncFunctionCallExpressions.js index 93c4dcfd3cb..452a5e1cc90 100644 --- a/tests/baselines/reference/es5-asyncFunctionCallExpressions.js +++ b/tests/baselines/reference/es5-asyncFunctionCallExpressions.js @@ -113,14 +113,14 @@ function callExpression1() { } function callExpression2() { return __awaiter(this, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { case 0: _a = x; return [4 /*yield*/, y]; case 1: - _a.apply(void 0, [_c.sent(), z]); + _a.apply(void 0, [_b.sent(), z]); return [2 /*return*/]; } }); @@ -184,16 +184,16 @@ function callExpression6() { } function callExpression7() { return __awaiter(this, void 0, void 0, function () { - var _a, _b, _c, _d, _e, _f, _g; - return __generator(this, function (_h) { - switch (_h.label) { + var _a, _b, _c, _d, _e; + return __generator(this, function (_f) { + switch (_f.label) { case 0: _b = (_a = x).apply; _c = [void 0]; _e = (_d = y).concat; return [4 /*yield*/, z]; case 1: - _b.apply(_a, _c.concat([_e.apply(_d, [[_h.sent()]])])); + _b.apply(_a, _c.concat([_e.apply(_d, [[_f.sent()]])])); return [2 /*return*/]; } }); @@ -201,15 +201,15 @@ function callExpression7() { } function callExpression8() { return __awaiter(this, void 0, void 0, function () { - var _a, _b, _c, _d; - return __generator(this, function (_e) { - switch (_e.label) { + var _a, _b, _c; + return __generator(this, function (_d) { + switch (_d.label) { case 0: _b = (_a = x).apply; _c = [void 0]; return [4 /*yield*/, y]; case 1: - _b.apply(_a, _c.concat([[_e.sent()].concat(z)])); + _b.apply(_a, _c.concat([[_d.sent()].concat(z)])); return [2 /*return*/]; } }); @@ -217,16 +217,16 @@ function callExpression8() { } function callExpression9() { return __awaiter(this, void 0, void 0, function () { - var _a, _b, _c, _d, _e, _f; - return __generator(this, function (_g) { - switch (_g.label) { + var _a, _b, _c, _d, _e; + return __generator(this, function (_f) { + switch (_f.label) { case 0: _b = (_a = x).apply; _c = [void 0]; _e = (_d = [y]).concat; return [4 /*yield*/, z]; case 1: - _b.apply(_a, _c.concat([_e.apply(_d, [(_g.sent())])])); + _b.apply(_a, _c.concat([_e.apply(_d, [(_f.sent())])])); return [2 /*return*/]; } }); @@ -270,14 +270,14 @@ function callExpression12() { } function callExpression13() { return __awaiter(this, void 0, void 0, function () { - var _a, _b, _c; - return __generator(this, function (_d) { - switch (_d.label) { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { case 0: _b = (_a = x).a; return [4 /*yield*/, y]; case 1: - _b.apply(_a, [_d.sent(), z]); + _b.apply(_a, [_c.sent(), z]); return [2 /*return*/]; } }); @@ -352,14 +352,14 @@ function callExpression18() { } function callExpression19() { return __awaiter(this, void 0, void 0, function () { - var _a, _b, _c; - return __generator(this, function (_d) { - switch (_d.label) { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { case 0: _b = (_a = x)[a]; return [4 /*yield*/, y]; case 1: - _b.apply(_a, [_d.sent(), z]); + _b.apply(_a, [_c.sent(), z]); return [2 /*return*/]; } }); diff --git a/tests/baselines/reference/es5-asyncFunctionNewExpressions.js b/tests/baselines/reference/es5-asyncFunctionNewExpressions.js index 0fb1140f129..ba1331afd20 100644 --- a/tests/baselines/reference/es5-asyncFunctionNewExpressions.js +++ b/tests/baselines/reference/es5-asyncFunctionNewExpressions.js @@ -112,14 +112,14 @@ function newExpression1() { } function newExpression2() { return __awaiter(this, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { + var _a; + return __generator(this, function (_b) { + switch (_b.label) { case 0: _a = x.bind; return [4 /*yield*/, y]; case 1: - new (_a.apply(x, [void 0, _c.sent(), z]))(); + new (_a.apply(x, [void 0, _b.sent(), z]))(); return [2 /*return*/]; } }); @@ -168,16 +168,16 @@ function newExpression5() { } function newExpression6() { return __awaiter(this, void 0, void 0, function () { - var _a, _b, _c, _d, _e, _f; - return __generator(this, function (_g) { - switch (_g.label) { + var _a, _b, _c, _d, _e; + return __generator(this, function (_f) { + switch (_f.label) { case 0: _b = (_a = x.bind).apply; _c = [x]; _e = (_d = [void 0]).concat; return [4 /*yield*/, y]; case 1: - new (_b.apply(_a, _c.concat([_e.apply(_d, [(_g.sent()), [z]])])))(); + new (_b.apply(_a, _c.concat([_e.apply(_d, [(_f.sent()), [z]])])))(); return [2 /*return*/]; } }); @@ -185,9 +185,9 @@ function newExpression6() { } function newExpression7() { return __awaiter(this, void 0, void 0, function () { - var _a, _b, _c, _d, _e, _f, _g; - return __generator(this, function (_h) { - switch (_h.label) { + var _a, _b, _c, _d, _e, _f; + return __generator(this, function (_g) { + switch (_g.label) { case 0: _b = (_a = x.bind).apply; _c = [x]; @@ -195,7 +195,7 @@ function newExpression7() { _f = [y]; return [4 /*yield*/, z]; case 1: - new (_b.apply(_a, _c.concat([_e.apply(_d, _f.concat([[_h.sent()]]))])))(); + new (_b.apply(_a, _c.concat([_e.apply(_d, _f.concat([[_g.sent()]]))])))(); return [2 /*return*/]; } }); @@ -220,16 +220,16 @@ function newExpression8() { } function newExpression9() { return __awaiter(this, void 0, void 0, function () { - var _a, _b, _c, _d, _e, _f; - return __generator(this, function (_g) { - switch (_g.label) { + var _a, _b, _c, _d, _e; + return __generator(this, function (_f) { + switch (_f.label) { case 0: _b = (_a = x.bind).apply; _c = [x]; _e = (_d = [void 0, y]).concat; return [4 /*yield*/, z]; case 1: - new (_b.apply(_a, _c.concat([_e.apply(_d, [(_g.sent())])])))(); + new (_b.apply(_a, _c.concat([_e.apply(_d, [(_f.sent())])])))(); return [2 /*return*/]; } }); @@ -273,14 +273,14 @@ function newExpression12() { } function newExpression13() { return __awaiter(this, void 0, void 0, function () { - var _a, _b, _c; - return __generator(this, function (_d) { - switch (_d.label) { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { case 0: _b = (_a = x.a).bind; return [4 /*yield*/, y]; case 1: - new (_b.apply(_a, [void 0, _d.sent(), z]))(); + new (_b.apply(_a, [void 0, _c.sent(), z]))(); return [2 /*return*/]; } }); @@ -355,14 +355,14 @@ function newExpression18() { } function newExpression19() { return __awaiter(this, void 0, void 0, function () { - var _a, _b, _c; - return __generator(this, function (_d) { - switch (_d.label) { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { case 0: _b = (_a = x[a]).bind; return [4 /*yield*/, y]; case 1: - new (_b.apply(_a, [void 0, _d.sent(), z]))(); + new (_b.apply(_a, [void 0, _c.sent(), z]))(); return [2 /*return*/]; } }); diff --git a/tests/baselines/reference/es5-asyncFunctionReturnStatements.symbols b/tests/baselines/reference/es5-asyncFunctionReturnStatements.symbols index 651af244e70..f2e6667c27e 100644 --- a/tests/baselines/reference/es5-asyncFunctionReturnStatements.symbols +++ b/tests/baselines/reference/es5-asyncFunctionReturnStatements.symbols @@ -9,14 +9,14 @@ declare var x, y, z, a, b, c; async function returnStatement0(): Promise { >returnStatement0 : Symbol(returnStatement0, Decl(es5-asyncFunctionReturnStatements.ts, 0, 29)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) return; } async function returnStatement1(): Promise { >returnStatement1 : Symbol(returnStatement1, Decl(es5-asyncFunctionReturnStatements.ts, 4, 1)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) return x; >x : Symbol(x, Decl(es5-asyncFunctionReturnStatements.ts, 0, 11)) @@ -24,7 +24,7 @@ async function returnStatement1(): Promise { async function returnStatement2(): Promise { >returnStatement2 : Symbol(returnStatement2, Decl(es5-asyncFunctionReturnStatements.ts, 8, 1)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) return await x; >x : Symbol(x, Decl(es5-asyncFunctionReturnStatements.ts, 0, 11)) @@ -32,14 +32,14 @@ async function returnStatement2(): Promise { async function returnStatement3(): Promise { >returnStatement3 : Symbol(returnStatement3, Decl(es5-asyncFunctionReturnStatements.ts, 12, 1)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) { return; } } async function returnStatement4(): Promise { >returnStatement4 : Symbol(returnStatement4, Decl(es5-asyncFunctionReturnStatements.ts, 16, 1)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) await x; >x : Symbol(x, Decl(es5-asyncFunctionReturnStatements.ts, 0, 11)) @@ -49,7 +49,7 @@ async function returnStatement4(): Promise { async function returnStatement5(): Promise{ >returnStatement5 : Symbol(returnStatement5, Decl(es5-asyncFunctionReturnStatements.ts, 21, 1)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) { return await x; } >x : Symbol(x, Decl(es5-asyncFunctionReturnStatements.ts, 0, 11)) diff --git a/tests/baselines/reference/es5-asyncFunctionTryStatements.symbols b/tests/baselines/reference/es5-asyncFunctionTryStatements.symbols index 52a4ec8df76..fc73f21f622 100644 --- a/tests/baselines/reference/es5-asyncFunctionTryStatements.symbols +++ b/tests/baselines/reference/es5-asyncFunctionTryStatements.symbols @@ -66,7 +66,7 @@ async function tryCatch2() { async function tryCatch3(): Promise { >tryCatch3 : Symbol(tryCatch3, Decl(es5-asyncFunctionTryStatements.ts, 30, 1)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) var x: any, y: any; diff --git a/tests/baselines/reference/es5-commonjs.js b/tests/baselines/reference/es5-commonjs.js index 6a301f9a2ac..8ebcfb01be6 100644 --- a/tests/baselines/reference/es5-commonjs.js +++ b/tests/baselines/reference/es5-commonjs.js @@ -16,6 +16,7 @@ export default class A //// [es5-commonjs.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var A = (function () { function A() { } @@ -24,5 +25,4 @@ var A = (function () { }; return A; }()); -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = A; diff --git a/tests/baselines/reference/es5-commonjs3.errors.txt b/tests/baselines/reference/es5-commonjs3.errors.txt new file mode 100644 index 00000000000..fddabf56fac --- /dev/null +++ b/tests/baselines/reference/es5-commonjs3.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/es5-commonjs3.ts(3,12): error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. + + +==== tests/cases/compiler/es5-commonjs3.ts (1 errors) ==== + + export default "test"; + export var __esModule = 1; + ~~~~~~~~~~ +!!! error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. + \ No newline at end of file diff --git a/tests/baselines/reference/es5-commonjs3.js b/tests/baselines/reference/es5-commonjs3.js index b2c1c5d6890..15c11b189a3 100644 --- a/tests/baselines/reference/es5-commonjs3.js +++ b/tests/baselines/reference/es5-commonjs3.js @@ -6,5 +6,6 @@ export var __esModule = 1; //// [es5-commonjs3.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.default = "test"; exports.__esModule = 1; diff --git a/tests/baselines/reference/es5-commonjs4.errors.txt b/tests/baselines/reference/es5-commonjs4.errors.txt new file mode 100644 index 00000000000..9a901728cfb --- /dev/null +++ b/tests/baselines/reference/es5-commonjs4.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/es5-commonjs4.ts(14,12): error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. + + +==== tests/cases/compiler/es5-commonjs4.ts (1 errors) ==== + + export default class A + { + constructor () + { + + } + + public B() + { + return 42; + } + } + export var __esModule = 1; + ~~~~~~~~~~ +!!! error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. + \ No newline at end of file diff --git a/tests/baselines/reference/es5-commonjs4.js b/tests/baselines/reference/es5-commonjs4.js index b67c771df3c..d2530d1bdf2 100644 --- a/tests/baselines/reference/es5-commonjs4.js +++ b/tests/baselines/reference/es5-commonjs4.js @@ -17,6 +17,7 @@ export var __esModule = 1; //// [es5-commonjs4.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var A = (function () { function A() { } diff --git a/tests/baselines/reference/es5-commonjs5.js b/tests/baselines/reference/es5-commonjs5.js index 73c859bb778..bbc9bbba7c2 100644 --- a/tests/baselines/reference/es5-commonjs5.js +++ b/tests/baselines/reference/es5-commonjs5.js @@ -7,8 +7,8 @@ export default function () { //// [es5-commonjs5.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); function default_1() { return "test"; } -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; diff --git a/tests/baselines/reference/es5-commonjs7.symbols b/tests/baselines/reference/es5-commonjs7.symbols new file mode 100644 index 00000000000..14c4cc71376 --- /dev/null +++ b/tests/baselines/reference/es5-commonjs7.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/test.d.ts === + +export default "test"; +export var __esModule; +>__esModule : Symbol(__esModule, Decl(test.d.ts, 2, 10)) + diff --git a/tests/baselines/reference/es5-commonjs7.types b/tests/baselines/reference/es5-commonjs7.types new file mode 100644 index 00000000000..e2236a61c7b --- /dev/null +++ b/tests/baselines/reference/es5-commonjs7.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/test.d.ts === + +export default "test"; +export var __esModule; +>__esModule : any + diff --git a/tests/baselines/reference/es5-commonjs8.symbols b/tests/baselines/reference/es5-commonjs8.symbols new file mode 100644 index 00000000000..93041cc8b7f --- /dev/null +++ b/tests/baselines/reference/es5-commonjs8.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/es5-commonjs8.ts === + +export default "test"; +export var __esModule = 1; +>__esModule : Symbol(__esModule, Decl(es5-commonjs8.ts, 2, 10)) + diff --git a/tests/baselines/reference/es5-commonjs8.types b/tests/baselines/reference/es5-commonjs8.types new file mode 100644 index 00000000000..be206bf5162 --- /dev/null +++ b/tests/baselines/reference/es5-commonjs8.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/es5-commonjs8.ts === + +export default "test"; +export var __esModule = 1; +>__esModule : number +>1 : 1 + diff --git a/tests/baselines/reference/es5-importHelpersAsyncFunctions.js b/tests/baselines/reference/es5-importHelpersAsyncFunctions.js index 71c4af8d559..9e5b63b23e9 100644 --- a/tests/baselines/reference/es5-importHelpersAsyncFunctions.js +++ b/tests/baselines/reference/es5-importHelpersAsyncFunctions.js @@ -19,6 +19,7 @@ export declare function __generator(body: Function): any; //// [external.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); function foo() { return tslib_1.__awaiter(this, void 0, void 0, function () { @@ -38,8 +39,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t; - return { next: verb(0), "throw": verb(1), "return": verb(2) }; + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); diff --git a/tests/baselines/reference/es5-system2.js b/tests/baselines/reference/es5-system2.js new file mode 100644 index 00000000000..39b5e5daca2 --- /dev/null +++ b/tests/baselines/reference/es5-system2.js @@ -0,0 +1,16 @@ +//// [es5-system2.ts] + +export var __esModule = 1; + +//// [es5-system2.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var __esModule; + return { + setters: [], + execute: function () { + exports_1("__esModule", __esModule = 1); + } + }; +}); diff --git a/tests/baselines/reference/es5-system2.symbols b/tests/baselines/reference/es5-system2.symbols new file mode 100644 index 00000000000..2c8779b730b --- /dev/null +++ b/tests/baselines/reference/es5-system2.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/es5-system2.ts === + +export var __esModule = 1; +>__esModule : Symbol(__esModule, Decl(es5-system2.ts, 1, 10)) + diff --git a/tests/baselines/reference/es5-system2.types b/tests/baselines/reference/es5-system2.types new file mode 100644 index 00000000000..e67258a8732 --- /dev/null +++ b/tests/baselines/reference/es5-system2.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/es5-system2.ts === + +export var __esModule = 1; +>__esModule : number +>1 : 1 + diff --git a/tests/baselines/reference/es5-umd2.js b/tests/baselines/reference/es5-umd2.js index 76333572abe..b55422ca7b1 100644 --- a/tests/baselines/reference/es5-umd2.js +++ b/tests/baselines/reference/es5-umd2.js @@ -25,6 +25,7 @@ export class A } })(function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var A = (function () { function A() { } diff --git a/tests/baselines/reference/es5-umd3.js b/tests/baselines/reference/es5-umd3.js index 0689ef19da3..37b19ece1ac 100644 --- a/tests/baselines/reference/es5-umd3.js +++ b/tests/baselines/reference/es5-umd3.js @@ -25,6 +25,7 @@ export default class A } })(function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var A = (function () { function A() { } @@ -33,6 +34,5 @@ export default class A }; return A; }()); - Object.defineProperty(exports, "__esModule", { value: true }); exports.default = A; }); diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration.js b/tests/baselines/reference/es5ExportDefaultClassDeclaration.js index fc8acfb95ea..25a1db0a25f 100644 --- a/tests/baselines/reference/es5ExportDefaultClassDeclaration.js +++ b/tests/baselines/reference/es5ExportDefaultClassDeclaration.js @@ -7,13 +7,13 @@ export default class C { //// [es5ExportDefaultClassDeclaration.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var C = (function () { function C() { } C.prototype.method = function () { }; return C; }()); -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = C; diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js b/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js index 0f60a104a7e..931eab75c72 100644 --- a/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js +++ b/tests/baselines/reference/es5ExportDefaultClassDeclaration2.js @@ -7,13 +7,13 @@ export default class { //// [es5ExportDefaultClassDeclaration2.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var default_1 = (function () { function default_1() { } default_1.prototype.method = function () { }; return default_1; }()); -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration3.js b/tests/baselines/reference/es5ExportDefaultClassDeclaration3.js index 00af2676a0d..927536114ef 100644 --- a/tests/baselines/reference/es5ExportDefaultClassDeclaration3.js +++ b/tests/baselines/reference/es5ExportDefaultClassDeclaration3.js @@ -16,6 +16,7 @@ var t: typeof C = C; //// [es5ExportDefaultClassDeclaration3.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var before = new C(); var C = (function () { function C() { @@ -25,7 +26,6 @@ var C = (function () { }; return C; }()); -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = C; var after = new C(); var t = C; diff --git a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration.js b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration.js index 55de6b62b83..068a966faa2 100644 --- a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration.js +++ b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration.js @@ -5,8 +5,8 @@ export default function f() { } //// [es5ExportDefaultFunctionDeclaration.js] "use strict"; -function f() { } Object.defineProperty(exports, "__esModule", { value: true }); +function f() { } exports.default = f; diff --git a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js index e6007cc9147..ab44c4cb584 100644 --- a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js +++ b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration2.js @@ -5,8 +5,8 @@ export default function () { } //// [es5ExportDefaultFunctionDeclaration2.js] "use strict"; -function default_1() { } Object.defineProperty(exports, "__esModule", { value: true }); +function default_1() { } exports.default = default_1; diff --git a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration3.js b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration3.js index 54a2658470e..c4bbcd4373e 100644 --- a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration3.js +++ b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration3.js @@ -10,11 +10,11 @@ var after: typeof func = func(); //// [es5ExportDefaultFunctionDeclaration3.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var before = func(); function func() { return func; } -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = func; var after = func(); diff --git a/tests/baselines/reference/es5ExportDefaultIdentifier.js b/tests/baselines/reference/es5ExportDefaultIdentifier.js index b3840caf145..d60fba590ac 100644 --- a/tests/baselines/reference/es5ExportDefaultIdentifier.js +++ b/tests/baselines/reference/es5ExportDefaultIdentifier.js @@ -7,9 +7,9 @@ export default f; //// [es5ExportDefaultIdentifier.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); function f() { } exports.f = f; -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = f; diff --git a/tests/baselines/reference/es5ModuleInternalNamedImports.js b/tests/baselines/reference/es5ModuleInternalNamedImports.js index cc596980889..abc81b3dc94 100644 --- a/tests/baselines/reference/es5ModuleInternalNamedImports.js +++ b/tests/baselines/reference/es5ModuleInternalNamedImports.js @@ -39,6 +39,7 @@ import M3 from "M3"; //// [es5ModuleInternalNamedImports.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var M; (function (M) { // variable diff --git a/tests/baselines/reference/es5ModuleWithModuleGenAmd.js b/tests/baselines/reference/es5ModuleWithModuleGenAmd.js index 7060153f0d0..dc55545617d 100644 --- a/tests/baselines/reference/es5ModuleWithModuleGenAmd.js +++ b/tests/baselines/reference/es5ModuleWithModuleGenAmd.js @@ -14,6 +14,7 @@ export class A //// [es5ModuleWithModuleGenAmd.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var A = (function () { function A() { } diff --git a/tests/baselines/reference/es5ModuleWithModuleGenCommonjs.js b/tests/baselines/reference/es5ModuleWithModuleGenCommonjs.js index e5f995fb5e0..93056203f9b 100644 --- a/tests/baselines/reference/es5ModuleWithModuleGenCommonjs.js +++ b/tests/baselines/reference/es5ModuleWithModuleGenCommonjs.js @@ -13,6 +13,7 @@ export class A //// [es5ModuleWithModuleGenCommonjs.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var A = (function () { function A() { } diff --git a/tests/baselines/reference/es5ModuleWithoutModuleGenTarget.js b/tests/baselines/reference/es5ModuleWithoutModuleGenTarget.js index 34ad74818b2..89d11045dda 100644 --- a/tests/baselines/reference/es5ModuleWithoutModuleGenTarget.js +++ b/tests/baselines/reference/es5ModuleWithoutModuleGenTarget.js @@ -13,6 +13,7 @@ export class A //// [es5ModuleWithoutModuleGenTarget.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var A = (function () { function A() { } diff --git a/tests/baselines/reference/es6-umd2.js b/tests/baselines/reference/es6-umd2.js index dc094122d9d..c0707b869cc 100644 --- a/tests/baselines/reference/es6-umd2.js +++ b/tests/baselines/reference/es6-umd2.js @@ -24,6 +24,7 @@ export class A } })(function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); class A { constructor() { } diff --git a/tests/baselines/reference/es6ClassSuperCodegenBug.js b/tests/baselines/reference/es6ClassSuperCodegenBug.js index 2eec250211e..1945726d218 100644 --- a/tests/baselines/reference/es6ClassSuperCodegenBug.js +++ b/tests/baselines/reference/es6ClassSuperCodegenBug.js @@ -15,11 +15,16 @@ class B extends A { //// [es6ClassSuperCodegenBug.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(str1, str2) { } @@ -28,7 +33,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - var _this; + var _this = this; if (true) { _this = _super.call(this, 'a1', 'b1') || this; } diff --git a/tests/baselines/reference/es6ClassTest.js b/tests/baselines/reference/es6ClassTest.js index 067e57c2581..9d66d2d8dc8 100644 --- a/tests/baselines/reference/es6ClassTest.js +++ b/tests/baselines/reference/es6ClassTest.js @@ -85,11 +85,16 @@ declare module AmbientMod { //// [es6ClassTest.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Bar = (function () { function Bar(n) { } diff --git a/tests/baselines/reference/es6ClassTest2.js b/tests/baselines/reference/es6ClassTest2.js index 533b332422d..e86d04bccd0 100644 --- a/tests/baselines/reference/es6ClassTest2.js +++ b/tests/baselines/reference/es6ClassTest2.js @@ -159,11 +159,16 @@ var ccwc = new ChildClassWithoutConstructor(1, "s"); //// [es6ClassTest2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var BasicMonster = (function () { function BasicMonster(name, health) { this.name = name; @@ -314,7 +319,7 @@ var BaseClassWithConstructor = (function () { var ChildClassWithoutConstructor = (function (_super) { __extends(ChildClassWithoutConstructor, _super); function ChildClassWithoutConstructor() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ChildClassWithoutConstructor; }(BaseClassWithConstructor)); diff --git a/tests/baselines/reference/es6ClassTest7.js b/tests/baselines/reference/es6ClassTest7.js index f786fce4461..8251d5ec476 100644 --- a/tests/baselines/reference/es6ClassTest7.js +++ b/tests/baselines/reference/es6ClassTest7.js @@ -9,15 +9,20 @@ class Bar extends M.Foo { //// [es6ClassTest7.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar; }(M.Foo)); diff --git a/tests/baselines/reference/es6ExportAllInEs5.js b/tests/baselines/reference/es6ExportAllInEs5.js index 73de2e7cce3..91910ba2616 100644 --- a/tests/baselines/reference/es6ExportAllInEs5.js +++ b/tests/baselines/reference/es6ExportAllInEs5.js @@ -18,6 +18,7 @@ export * from "./server"; //// [server.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var c = (function () { function c() { } @@ -34,6 +35,7 @@ exports.x = 10; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } +Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./server")); diff --git a/tests/baselines/reference/es6ExportClauseInEs5.js b/tests/baselines/reference/es6ExportClauseInEs5.js index f602f1ff609..3d3625aad18 100644 --- a/tests/baselines/reference/es6ExportClauseInEs5.js +++ b/tests/baselines/reference/es6ExportClauseInEs5.js @@ -18,6 +18,7 @@ export { x }; //// [server.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var c = (function () { function c() { } diff --git a/tests/baselines/reference/es6ExportClauseWithAssignmentInEs5.js b/tests/baselines/reference/es6ExportClauseWithAssignmentInEs5.js index 5add71a06f2..d8aa8e607e3 100644 --- a/tests/baselines/reference/es6ExportClauseWithAssignmentInEs5.js +++ b/tests/baselines/reference/es6ExportClauseWithAssignmentInEs5.js @@ -19,6 +19,7 @@ export { foo, baz, baz as quux, buzz, bizz }; //// [server.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var foo = 2; exports.foo = foo; exports.foo = foo = 3; diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js index ab9bd3d98c8..ecfccd5d843 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js @@ -22,6 +22,7 @@ export { x } from "./server"; //// [server.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var c = (function () { function c() { } @@ -35,6 +36,7 @@ var m; exports.x = 10; //// [client.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var server_1 = require("./server"); exports.c = server_1.c; var server_2 = require("./server"); diff --git a/tests/baselines/reference/es6ExportEqualsInterop.js b/tests/baselines/reference/es6ExportEqualsInterop.js index 49a8a7e435a..d1f8de5faa7 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.js +++ b/tests/baselines/reference/es6ExportEqualsInterop.js @@ -213,6 +213,7 @@ export * from "class-module"; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } +exports.__esModule = true; var z2 = require("variable"); var z3 = require("interface-variable"); var z4 = require("module"); diff --git a/tests/baselines/reference/es6ImportDefaultBindingAmd.js b/tests/baselines/reference/es6ImportDefaultBindingAmd.js index 9de16453c6e..977b94f8790 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingAmd.js +++ b/tests/baselines/reference/es6ImportDefaultBindingAmd.js @@ -14,13 +14,14 @@ import defaultBinding2 from "es6ImportDefaultBindingAmd_0"; // elide this import //// [es6ImportDefaultBindingAmd_0.js] define(["require", "exports"], function (require, exports) { "use strict"; - var a = 10; Object.defineProperty(exports, "__esModule", { value: true }); + var a = 10; exports.default = a; }); //// [es6ImportDefaultBindingAmd_1.js] define(["require", "exports", "es6ImportDefaultBindingAmd_0"], function (require, exports, es6ImportDefaultBindingAmd_0_1) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var x = es6ImportDefaultBindingAmd_0_1.default; }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingDts.js index dbc90cb80a3..94b824a3766 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingDts.js @@ -13,15 +13,16 @@ import defaultBinding2 from "./server"; // elide this import since defaultBindin //// [server.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var c = (function () { function c() { } return c; }()); -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = c; //// [client.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var server_1 = require("./server"); exports.x = new server_1.default(); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js index 4bff2abf82d..8335a1953de 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js @@ -24,13 +24,14 @@ var x1: number = m; //// [es6ImportDefaultBindingFollowedWithNamedImport_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; exports.x = exports.a; exports.m = exports.a; -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = {}; //// [es6ImportDefaultBindingFollowedWithNamedImport_1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); const es6ImportDefaultBindingFollowedWithNamedImport_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0"); var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_1.a; const es6ImportDefaultBindingFollowedWithNamedImport_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0"); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js index fde7556edea..8eb76b487f8 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js @@ -22,11 +22,12 @@ var x: number = defaultBinding6; //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0.js] "use strict"; -var a = 10; Object.defineProperty(exports, "__esModule", { value: true }); +var a = 10; exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1.default; var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js index 6131ff40624..d72751c7610 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js @@ -22,11 +22,12 @@ export var x1: number = defaultBinding6; //// [server.js] "use strict"; -var a = 10; Object.defineProperty(exports, "__esModule", { value: true }); +var a = 10; exports.default = a; //// [client.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var server_1 = require("./server"); exports.x1 = server_1.default; var server_2 = require("./server"); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js index a0916932d4c..5bf268709d3 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js @@ -26,6 +26,7 @@ export var x6 = new m(); //// [server.js] "use strict"; +exports.__esModule = true; var a = (function () { function a() { } @@ -64,6 +65,7 @@ var x11 = (function () { exports.x11 = x11; //// [client.js] "use strict"; +exports.__esModule = true; var server_1 = require("./server"); exports.x1 = new server_1.a(); var server_2 = require("./server"); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js index b588c9516e9..307dcc92f46 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js @@ -21,15 +21,16 @@ export var x6 = new defaultBinding6(); //// [server.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var a = (function () { function a() { } return a; }()); -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; //// [client.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var server_1 = require("./server"); exports.x1 = new server_1.default(); var server_2 = require("./server"); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js index c075c5c934f..2e9d8104a39 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js @@ -23,11 +23,13 @@ var x1: number = m; //// [es6ImportDefaultBindingFollowedWithNamedImportInEs5_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; exports.x = exports.a; exports.m = exports.a; //// [es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1.a; var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js index aa89c8d4380..77266084bda 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js @@ -25,15 +25,16 @@ export var x1: number = m; //// [server.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; exports.x = exports.a; exports.m = exports.a; - Object.defineProperty(exports, "__esModule", { value: true }); exports.default = {}; }); //// [client.js] define(["require", "exports", "server", "server", "server", "server", "server"], function (require, exports, server_1, server_2, server_3, server_4, server_5) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.x1 = server_1.a; exports.x1 = server_2.a; exports.x1 = server_3.x; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js index 0a0e028b696..c1c41968934 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js @@ -11,11 +11,12 @@ var x: number = defaultBinding; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.js] "use strict"; -var a = 10; Object.defineProperty(exports, "__esModule", { value: true }); +var a = 10; exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1.default; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js index 5f2cb4e97e0..b82fb9aeee9 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js @@ -12,13 +12,14 @@ export var x: number = defaultBinding; //// [server.js] define(["require", "exports"], function (require, exports) { "use strict"; - var a = 10; Object.defineProperty(exports, "__esModule", { value: true }); + var a = 10; exports.default = a; }); //// [client.js] define(["require", "exports", "server"], function (require, exports, server_1) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.x = server_1.default; }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js index 60bdc654842..8d033c69536 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js @@ -10,6 +10,7 @@ export var x = new nameSpaceBinding.a(); //// [server.js] "use strict"; +exports.__esModule = true; var a = (function () { function a() { } @@ -18,6 +19,7 @@ var a = (function () { exports.a = a; //// [client.js] "use strict"; +exports.__esModule = true; var nameSpaceBinding = require("./server"); exports.x = new nameSpaceBinding.a(); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js index 8752157eddd..c488db3e88e 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js @@ -12,17 +12,18 @@ export var x = new defaultBinding(); //// [server.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var a = (function () { function a() { } return a; }()); - Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; }); //// [client.js] define(["require", "exports", "server"], function (require, exports, server_1) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.x = new server_1.default(); }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js index 9d11e154755..0db21dfd064 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js @@ -10,9 +10,11 @@ var x: number = nameSpaceBinding.a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var nameSpaceBinding = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js index e16ebf99957..96720294a8a 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js @@ -10,9 +10,11 @@ export var x: number = nameSpaceBinding.a; //// [server.js] "use strict"; +exports.__esModule = true; exports.a = 10; //// [client.js] "use strict"; +exports.__esModule = true; var nameSpaceBinding = require("./server"); exports.x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingInEs5.js index 257e76bfe02..f6ea8348118 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingInEs5.js @@ -14,6 +14,7 @@ var a = 10; module.exports = a; //// [es6ImportDefaultBindingInEs5_1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); //// [es6ImportDefaultBindingInEs5_0.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js index e686c3f33c9..4c51a54462d 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js +++ b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js @@ -18,11 +18,12 @@ import defaultBinding3 from "./es6ImportDefaultBindingMergeErrors_0"; // SHould //// [es6ImportDefaultBindingMergeErrors_0.js] "use strict"; -var a = 10; Object.defineProperty(exports, "__esModule", { value: true }); +var a = 10; exports.default = a; //// [es6ImportDefaultBindingMergeErrors_1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var es6ImportDefaultBindingMergeErrors_0_1 = require("./es6ImportDefaultBindingMergeErrors_0"); var x = es6ImportDefaultBindingMergeErrors_0_1.default; var defaultBinding2 = "hello world"; diff --git a/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.js b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.js index 5513ae565f2..e294c08befa 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.js +++ b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.js @@ -10,6 +10,8 @@ import defaultBinding from "./es6ImportDefaultBindingNoDefaultProperty_0"; //// [es6ImportDefaultBindingNoDefaultProperty_0.js] "use strict"; +exports.__esModule = true; exports.a = 10; //// [es6ImportDefaultBindingNoDefaultProperty_1.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/es6ImportDefaultBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingWithExport.js index cc90d280914..a9f760f1278 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingWithExport.js @@ -13,13 +13,14 @@ export import defaultBinding2 from "server"; // non referenced //// [server.js] define(["require", "exports"], function (require, exports) { "use strict"; - var a = 10; Object.defineProperty(exports, "__esModule", { value: true }); + var a = 10; exports.default = a; }); //// [client.js] define(["require", "exports", "server"], function (require, exports, server_1) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.x = server_1.default; }); diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.js b/tests/baselines/reference/es6ImportNameSpaceImport.js index 8e109779f45..b5296d15f9b 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImport.js +++ b/tests/baselines/reference/es6ImportNameSpaceImport.js @@ -12,9 +12,11 @@ import * as nameSpaceBinding2 from "./es6ImportNameSpaceImport_0"; // elide this //// [es6ImportNameSpaceImport_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; //// [es6ImportNameSpaceImport_1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); const nameSpaceBinding = require("./es6ImportNameSpaceImport_0"); var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportAmd.js b/tests/baselines/reference/es6ImportNameSpaceImportAmd.js index 093e8385bae..200f49a2986 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportAmd.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportAmd.js @@ -13,11 +13,13 @@ import * as nameSpaceBinding2 from "es6ImportNameSpaceImportAmd_0"; // elide thi //// [es6ImportNameSpaceImportAmd_0.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.a = 10; }); //// [es6ImportNameSpaceImportAmd_1.js] define(["require", "exports", "es6ImportNameSpaceImportAmd_0"], function (require, exports, nameSpaceBinding) { "use strict"; + exports.__esModule = true; var x = nameSpaceBinding.a; }); diff --git a/tests/baselines/reference/es6ImportNameSpaceImportDts.js b/tests/baselines/reference/es6ImportNameSpaceImportDts.js index cf66c08331e..cae90885ce2 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportDts.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportDts.js @@ -11,6 +11,7 @@ import * as nameSpaceBinding2 from "./server"; // unreferenced //// [server.js] "use strict"; +exports.__esModule = true; var c = (function () { function c() { } @@ -20,6 +21,7 @@ exports.c = c; ; //// [client.js] "use strict"; +exports.__esModule = true; var nameSpaceBinding = require("./server"); exports.x = new nameSpaceBinding.c(); diff --git a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js index 252d131f824..ee00df9a2cc 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js @@ -12,9 +12,11 @@ import * as nameSpaceBinding2 from "./es6ImportNameSpaceImportInEs5_0"; // elide //// [es6ImportNameSpaceImportInEs5_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; //// [es6ImportNameSpaceImportInEs5_1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var nameSpaceBinding = require("./es6ImportNameSpaceImportInEs5_0"); var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.js b/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.js index 9bdd0318310..39594102007 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.js @@ -17,7 +17,9 @@ var nameSpaceBinding3 = 10; //// [es6ImportNameSpaceImportMergeErrors_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; //// [es6ImportNameSpaceImportMergeErrors_1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var nameSpaceBinding3 = 10; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js index 8ece816fd3b..0276c44f8ab 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js @@ -14,3 +14,4 @@ var a = 10; module.exports = a; //// [es6ImportNameSpaceImportNoNamedExports_1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/es6ImportNameSpaceImportWithExport.js b/tests/baselines/reference/es6ImportNameSpaceImportWithExport.js index e21ab603f82..3c8b40f550e 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportWithExport.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportWithExport.js @@ -13,11 +13,13 @@ export import * as nameSpaceBinding2 from "server"; // Not referenced imports //// [server.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.a = 10; }); //// [client.js] define(["require", "exports", "server"], function (require, exports, nameSpaceBinding) { "use strict"; + exports.__esModule = true; exports.x = nameSpaceBinding.a; }); diff --git a/tests/baselines/reference/es6ImportNamedImport.js b/tests/baselines/reference/es6ImportNamedImport.js index 8dbdf7ce6f1..a9fcb861ec5 100644 --- a/tests/baselines/reference/es6ImportNamedImport.js +++ b/tests/baselines/reference/es6ImportNamedImport.js @@ -43,6 +43,7 @@ import { aaaa as bbbb } from "./es6ImportNamedImport_0"; //// [es6ImportNamedImport_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; exports.x = exports.a; exports.m = exports.a; @@ -53,6 +54,7 @@ exports.z2 = 10; exports.aaaa = 10; //// [es6ImportNamedImport_1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); const es6ImportNamedImport_0_1 = require("./es6ImportNamedImport_0"); var xxxx = es6ImportNamedImport_0_1.a; const es6ImportNamedImport_0_2 = require("./es6ImportNamedImport_0"); diff --git a/tests/baselines/reference/es6ImportNamedImportAmd.js b/tests/baselines/reference/es6ImportNamedImportAmd.js index 278e4ee07d2..bd6213f259f 100644 --- a/tests/baselines/reference/es6ImportNamedImportAmd.js +++ b/tests/baselines/reference/es6ImportNamedImportAmd.js @@ -44,6 +44,7 @@ import { aaaa as bbbb } from "es6ImportNamedImportAmd_0"; //// [es6ImportNamedImportAmd_0.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.a = 10; exports.x = exports.a; exports.m = exports.a; @@ -56,6 +57,7 @@ define(["require", "exports"], function (require, exports) { //// [es6ImportNamedImportAmd_1.js] define(["require", "exports", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0", "es6ImportNamedImportAmd_0"], function (require, exports, es6ImportNamedImportAmd_0_1, es6ImportNamedImportAmd_0_2, es6ImportNamedImportAmd_0_3, es6ImportNamedImportAmd_0_4, es6ImportNamedImportAmd_0_5, es6ImportNamedImportAmd_0_6, es6ImportNamedImportAmd_0_7, es6ImportNamedImportAmd_0_8, es6ImportNamedImportAmd_0_9) { "use strict"; + exports.__esModule = true; var xxxx = es6ImportNamedImportAmd_0_1.a; var xxxx = es6ImportNamedImportAmd_0_2.a; var xxxx = es6ImportNamedImportAmd_0_3.x; diff --git a/tests/baselines/reference/es6ImportNamedImportDts.js b/tests/baselines/reference/es6ImportNamedImportDts.js index 7fdf620164b..d68ffd794a7 100644 --- a/tests/baselines/reference/es6ImportNamedImportDts.js +++ b/tests/baselines/reference/es6ImportNamedImportDts.js @@ -48,6 +48,7 @@ import { aaaa1 as bbbb } from "./server"; //// [server.js] "use strict"; +exports.__esModule = true; var a = (function () { function a() { } @@ -134,6 +135,7 @@ var aaaa1 = (function () { exports.aaaa1 = aaaa1; //// [client.js] "use strict"; +exports.__esModule = true; var server_1 = require("./server"); exports.xxxx = new server_1.a(); var server_2 = require("./server"); diff --git a/tests/baselines/reference/es6ImportNamedImportInEs5.js b/tests/baselines/reference/es6ImportNamedImportInEs5.js index 3f3e4694758..9e025dca61b 100644 --- a/tests/baselines/reference/es6ImportNamedImportInEs5.js +++ b/tests/baselines/reference/es6ImportNamedImportInEs5.js @@ -43,6 +43,7 @@ import { aaaa as bbbb } from "./es6ImportNamedImportInEs5_0"; //// [es6ImportNamedImportInEs5_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; exports.x = exports.a; exports.m = exports.a; @@ -53,6 +54,7 @@ exports.z2 = 10; exports.aaaa = 10; //// [es6ImportNamedImportInEs5_1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var es6ImportNamedImportInEs5_0_1 = require("./es6ImportNamedImportInEs5_0"); var xxxx = es6ImportNamedImportInEs5_0_1.a; var es6ImportNamedImportInEs5_0_2 = require("./es6ImportNamedImportInEs5_0"); diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js index 38766d32cd9..d64b517c50f 100644 --- a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js +++ b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js @@ -10,6 +10,7 @@ export = a; //// [es6ImportNamedImportInExportAssignment_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; //// [es6ImportNamedImportInExportAssignment_1.js] "use strict"; diff --git a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js index 3e85778de58..38cda17bd7e 100644 --- a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js +++ b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js @@ -14,6 +14,7 @@ export = x; //// [es6ImportNamedImportInIndirectExportAssignment_0.js] "use strict"; +exports.__esModule = true; var a; (function (a) { var c = (function () { diff --git a/tests/baselines/reference/es6ImportNamedImportMergeErrors.js b/tests/baselines/reference/es6ImportNamedImportMergeErrors.js index 002aa5a49ce..261039bcc10 100644 --- a/tests/baselines/reference/es6ImportNamedImportMergeErrors.js +++ b/tests/baselines/reference/es6ImportNamedImportMergeErrors.js @@ -22,11 +22,13 @@ import { z1 as z } from "./es6ImportNamedImportMergeErrors_0"; // should be erro //// [es6ImportNamedImportMergeErrors_0.js] "use strict"; +exports.__esModule = true; exports.a = 10; exports.x = exports.a; exports.z = exports.a; exports.z1 = exports.a; //// [es6ImportNamedImportMergeErrors_1.js] "use strict"; +exports.__esModule = true; var x = 10; var x44 = 10; diff --git a/tests/baselines/reference/es6ImportNamedImportNoExportMember.js b/tests/baselines/reference/es6ImportNamedImportNoExportMember.js index 71159983b9a..4e78df34b6d 100644 --- a/tests/baselines/reference/es6ImportNamedImportNoExportMember.js +++ b/tests/baselines/reference/es6ImportNamedImportNoExportMember.js @@ -11,7 +11,9 @@ import { x1 as x } from "./es6ImportNamedImportNoExportMember_0"; //// [es6ImportNamedImportNoExportMember_0.js] "use strict"; +exports.__esModule = true; exports.a = 10; exports.x = exports.a; //// [es6ImportNamedImport_1.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/es6ImportNamedImportNoNamedExports.js b/tests/baselines/reference/es6ImportNamedImportNoNamedExports.js index 2198df11f78..a02116b314d 100644 --- a/tests/baselines/reference/es6ImportNamedImportNoNamedExports.js +++ b/tests/baselines/reference/es6ImportNamedImportNoNamedExports.js @@ -15,3 +15,4 @@ var a = 10; module.exports = a; //// [es6ImportNamedImportNoNamedExports_1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/es6ImportNamedImportWithExport.js b/tests/baselines/reference/es6ImportNamedImportWithExport.js index 21ccb29a57b..13e2d40144b 100644 --- a/tests/baselines/reference/es6ImportNamedImportWithExport.js +++ b/tests/baselines/reference/es6ImportNamedImportWithExport.js @@ -42,6 +42,7 @@ export import { aaaa as bbbb } from "./server"; //// [server.js] "use strict"; +exports.__esModule = true; exports.a = 10; exports.x = exports.a; exports.m = exports.a; @@ -52,6 +53,7 @@ exports.z2 = 10; exports.aaaa = 10; //// [client.js] "use strict"; +exports.__esModule = true; var server_1 = require("./server"); exports.xxxx = server_1.a; var server_2 = require("./server"); diff --git a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js index 583a008f0ac..0aa3214e5d7 100644 --- a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js +++ b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js @@ -22,6 +22,7 @@ export var cVal = new C(); //// [server.js] "use strict"; +exports.__esModule = true; var C = (function () { function C() { this.prop = "hello"; @@ -38,6 +39,7 @@ var C2 = (function () { exports.C2 = C2; //// [client.js] "use strict"; +exports.__esModule = true; var server_1 = require("./server"); // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file exports.cVal = new server_1.C(); diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseAmd.js b/tests/baselines/reference/es6ImportWithoutFromClauseAmd.js index ea533a9a963..d83ba9370ee 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClauseAmd.js +++ b/tests/baselines/reference/es6ImportWithoutFromClauseAmd.js @@ -16,16 +16,19 @@ var _b = 10; //// [es6ImportWithoutFromClauseAmd_0.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.a = 10; }); //// [es6ImportWithoutFromClauseAmd_1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.b = 10; }); //// [es6ImportWithoutFromClauseAmd_2.js] define(["require", "exports", "es6ImportWithoutFromClauseAmd_0", "es6ImportWithoutFromClauseAmd_2"], function (require, exports) { "use strict"; + exports.__esModule = true; var _a = 10; var _b = 10; }); diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.js b/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.js index d0f7c9fbe65..b11e2ea9a07 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.js +++ b/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.js @@ -9,9 +9,11 @@ import "es6ImportWithoutFromClauseInEs5_0"; //// [es6ImportWithoutFromClauseInEs5_0.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; //// [es6ImportWithoutFromClauseInEs5_1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); require("es6ImportWithoutFromClauseInEs5_0"); diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseWithExport.js b/tests/baselines/reference/es6ImportWithoutFromClauseWithExport.js index 5ff5b62d8ec..99214d2a2c6 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClauseWithExport.js +++ b/tests/baselines/reference/es6ImportWithoutFromClauseWithExport.js @@ -9,9 +9,11 @@ export import "server"; //// [server.js] "use strict"; +exports.__esModule = true; exports.a = 10; //// [client.js] "use strict"; +exports.__esModule = true; require("server"); diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.js b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.js index 172ce2a8729..4ced3a35ab2 100644 --- a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.js +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.js @@ -14,6 +14,7 @@ export class A //// [es6ModuleWithModuleGenTargetAmd.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); class A { constructor() { } diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.js b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.js index f932bb7072f..187ece7e718 100644 --- a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.js +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.js @@ -13,6 +13,7 @@ export class A //// [es6ModuleWithModuleGenTargetCommonjs.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); class A { constructor() { } diff --git a/tests/baselines/reference/exponentiationOperatorSyntaxError2.errors.txt b/tests/baselines/reference/exponentiationOperatorSyntaxError2.errors.txt index 6ac93ecf27a..1075c505794 100644 --- a/tests/baselines/reference/exponentiationOperatorSyntaxError2.errors.txt +++ b/tests/baselines/reference/exponentiationOperatorSyntaxError2.errors.txt @@ -42,15 +42,25 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxE tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(25,6): error TS17006: An unary expression with the 'typeof' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(26,6): 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/exponentiationOperatorSyntaxError2.ts(26,6): error TS17006: An unary expression with the 'typeof' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(28,1): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(28,1): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(29,1): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(29,1): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(30,1): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(30,1): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(31,1): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(31,1): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(32,1): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(32,1): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(34,6): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(34,6): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(35,6): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(35,6): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(36,6): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(36,6): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(37,6): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(37,6): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(38,6): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(38,6): error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(40,1): error TS17006: An unary expression with the '~' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(41,1): error TS17006: An unary expression with the '~' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. @@ -89,7 +99,7 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxE tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(68,1): error TS17007: A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. -==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts (89 errors) ==== +==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts (99 errors) ==== // Error: early syntax error using ES7 SimpleUnaryExpression on left-hand side without () var temp: any; @@ -207,34 +217,54 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxE void --temp ** 3; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. void temp-- ** 3; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. void 3 ** 4; ~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. void temp++ ** 4; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. void temp-- ** 4; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. 1 ** void --temp ** 3; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. 1 ** void temp-- ** 3; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. 1 ** void 3 ** 4; ~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. 1 ** void temp++ ** 4; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. 1 ** void temp-- ** 4 ; ~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'void' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. ~ --temp ** 3; diff --git a/tests/baselines/reference/exponentiationOperatorWithNullValueAndInvalidOperands.errors.txt b/tests/baselines/reference/exponentiationOperatorWithNullValueAndInvalidOperands.errors.txt index 99535985628..2d0b76f28cc 100644 --- a/tests/baselines/reference/exponentiationOperatorWithNullValueAndInvalidOperands.errors.txt +++ b/tests/baselines/reference/exponentiationOperatorWithNullValueAndInvalidOperands.errors.txt @@ -1,27 +1,27 @@ -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(9,12): 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/exponentiationOperatorWithNullValueAndInvalidOperands.ts(9,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(9,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(10,12): 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/exponentiationOperatorWithNullValueAndInvalidOperands.ts(10,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(10,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(11,12): 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/exponentiationOperatorWithNullValueAndInvalidOperands.ts(11,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(11,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(13,12): 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/exponentiationOperatorWithNullValueAndInvalidOperands.ts(13,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(13,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(14,12): 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/exponentiationOperatorWithNullValueAndInvalidOperands.ts(14,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(14,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(15,12): 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/exponentiationOperatorWithNullValueAndInvalidOperands.ts(15,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(17,12): 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/exponentiationOperatorWithNullValueAndInvalidOperands.ts(15,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(17,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(17,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(18,12): 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/exponentiationOperatorWithNullValueAndInvalidOperands.ts(18,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(18,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(19,12): 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/exponentiationOperatorWithNullValueAndInvalidOperands.ts(19,12): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(19,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(21,12): 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/exponentiationOperatorWithNullValueAndInvalidOperands.ts(21,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(21,20): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(22,12): 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/exponentiationOperatorWithNullValueAndInvalidOperands.ts(22,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(22,18): error TS2531: Object is possibly 'null'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(23,12): 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/exponentiationOperatorWithNullValueAndInvalidOperands.ts(23,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts(23,18): error TS2531: Object is possibly 'null'. ==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndInvalidOperands.ts (24 errors) ==== @@ -35,17 +35,17 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNul // operator ** var r1a1 = null ** a; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a2 = null ** b; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a3 = null ** c; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -53,31 +53,31 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNul ~ !!! 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 TS2531: Object is possibly 'null'. var r1b2 = b ** null; ~ !!! 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 TS2531: Object is possibly 'null'. var r1b3 = c ** null; ~ !!! 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 TS2531: Object is possibly 'null'. var r1c1 = null ** true; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c2 = null ** ''; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c3 = null ** {}; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -85,14 +85,14 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNul ~~~~ !!! 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 TS2531: Object is possibly 'null'. var r1d2 = '' ** null; ~~ !!! 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 TS2531: Object is possibly 'null'. var r1d3 = {} ** null; ~~ !!! 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. \ No newline at end of file +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/exponentiationOperatorWithNullValueAndValidOperands.errors.txt b/tests/baselines/reference/exponentiationOperatorWithNullValueAndValidOperands.errors.txt new file mode 100644 index 00000000000..c8a462c0f54 --- /dev/null +++ b/tests/baselines/reference/exponentiationOperatorWithNullValueAndValidOperands.errors.txt @@ -0,0 +1,47 @@ +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(13,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(14,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(15,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(16,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(17,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(18,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(19,15): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts(20,17): error TS2531: Object is possibly 'null'. + + +==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithNullValueAndValidOperands.ts (8 errors) ==== + // If one operand is the null or undefined value, it is treated as having the type of the + // other operand. + + enum E { + a, + b + } + + var a: any; + var b: number; + + // operator ** + var r1 = null ** a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r2 = null ** b; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r3 = null ** 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r4 = null ** E.a; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r5 = a ** null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r6 = b ** null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r7 = 0 ** null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var r8 = E.b ** null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.errors.txt b/tests/baselines/reference/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.errors.txt index 86f4930e77c..20b004625ca 100644 --- a/tests/baselines/reference/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.errors.txt +++ b/tests/baselines/reference/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.errors.txt @@ -1,33 +1,33 @@ -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.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/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.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/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(3,10): 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/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(3,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(4,10): 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/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(4,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(5,10): 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/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(5,23): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(2,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(2,18): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(3,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(3,18): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(4,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(4,23): error TS2531: Object is possibly 'null'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(5,10): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts(5,23): error TS2532: Object is possibly 'undefined'. ==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithOnlyNullValueOrUndefinedValue.ts (8 errors) ==== // operator ** var r1 = null ** null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r2 = null ** undefined; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var r3 = undefined ** null; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var r4 = undefined ** undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndInvalidOperands.errors.txt b/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndInvalidOperands.errors.txt index f456e0f554f..ce14298d02d 100644 --- a/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndInvalidOperands.errors.txt +++ b/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndInvalidOperands.errors.txt @@ -1,27 +1,27 @@ -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(9,12): 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/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(9,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(9,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(10,12): 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/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(10,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(10,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(11,12): 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/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(11,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(11,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(13,12): 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/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(13,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(13,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(14,12): 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/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(14,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(14,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(15,12): 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/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(15,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(17,12): 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/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(15,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(17,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(17,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(18,12): 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/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(18,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(18,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(19,12): 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/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(19,12): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(19,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(21,12): 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/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(21,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(21,20): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(22,12): 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/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(22,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(22,18): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(23,12): 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/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(23,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts(23,18): error TS2532: Object is possibly 'undefined'. ==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndInvalidOperands.ts (24 errors) ==== @@ -35,17 +35,17 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUnd // operator ** var r1a1 = undefined ** a; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a2 = undefined ** b; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1a3 = undefined ** c; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -53,31 +53,31 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUnd ~ !!! 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 TS2532: Object is possibly 'undefined'. var r1b2 = b ** undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r1b3 = c ** undefined; ~ !!! 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 TS2532: Object is possibly 'undefined'. var r1c1 = undefined ** true; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c2 = undefined ** ''; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. var r1c3 = undefined ** {}; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -85,14 +85,14 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUnd ~~~~ !!! 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 TS2532: Object is possibly 'undefined'. var r1d2 = '' ** undefined; ~~ !!! 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 TS2532: Object is possibly 'undefined'. var r1d3 = {} ** undefined; ~~ !!! 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. \ No newline at end of file +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndValidOperands.errors.txt b/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndValidOperands.errors.txt new file mode 100644 index 00000000000..ce9843a9612 --- /dev/null +++ b/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndValidOperands.errors.txt @@ -0,0 +1,47 @@ +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(13,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(14,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(15,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(16,11): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(17,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(18,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(19,16): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts(20,18): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithUndefinedValueAndValidOperands.ts (8 errors) ==== + // If one operand is the undefined or undefined value, it is treated as having the type of the + // other operand. + + enum E { + a, + b + } + + var a: any; + var b: number; + + // operator * + var rk1 = undefined ** a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk2 = undefined ** b; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk3 = undefined ** 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk4 = undefined ** E.a; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk5 = a ** undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk6 = b ** undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk7 = 0 ** undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + var rk8 = E.b ** undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/exportAndImport-es3-amd.js b/tests/baselines/reference/exportAndImport-es3-amd.js index 5f37f0f0220..d19de0c78b0 100644 --- a/tests/baselines/reference/exportAndImport-es3-amd.js +++ b/tests/baselines/reference/exportAndImport-es3-amd.js @@ -15,17 +15,17 @@ export default function f2() { //// [m1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; function f1() { } - exports.__esModule = true; exports["default"] = f1; }); //// [m2.js] define(["require", "exports", "./m1"], function (require, exports, m1_1) { "use strict"; + exports.__esModule = true; function f2() { m1_1["default"](); } - exports.__esModule = true; exports["default"] = f2; }); diff --git a/tests/baselines/reference/exportAndImport-es3.js b/tests/baselines/reference/exportAndImport-es3.js index ee1f562258f..13b6f1eaf48 100644 --- a/tests/baselines/reference/exportAndImport-es3.js +++ b/tests/baselines/reference/exportAndImport-es3.js @@ -14,15 +14,15 @@ export default function f2() { //// [m1.js] "use strict"; +exports.__esModule = true; function f1() { } -exports.__esModule = true; exports["default"] = f1; //// [m2.js] "use strict"; +exports.__esModule = true; var m1_1 = require("./m1"); function f2() { m1_1["default"](); } -exports.__esModule = true; exports["default"] = f2; diff --git a/tests/baselines/reference/exportAndImport-es5-amd.js b/tests/baselines/reference/exportAndImport-es5-amd.js index 0e2cb890d2a..60b1246b616 100644 --- a/tests/baselines/reference/exportAndImport-es5-amd.js +++ b/tests/baselines/reference/exportAndImport-es5-amd.js @@ -15,17 +15,17 @@ export default function f2() { //// [m1.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); function f1() { } - Object.defineProperty(exports, "__esModule", { value: true }); exports.default = f1; }); //// [m2.js] define(["require", "exports", "./m1"], function (require, exports, m1_1) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); function f2() { m1_1.default(); } - Object.defineProperty(exports, "__esModule", { value: true }); exports.default = f2; }); diff --git a/tests/baselines/reference/exportAndImport-es5.js b/tests/baselines/reference/exportAndImport-es5.js index 1d2511735c7..f4bc496e6b2 100644 --- a/tests/baselines/reference/exportAndImport-es5.js +++ b/tests/baselines/reference/exportAndImport-es5.js @@ -14,15 +14,15 @@ export default function f2() { //// [m1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); function f1() { } -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = f1; //// [m2.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var m1_1 = require("./m1"); function f2() { m1_1.default(); } -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = f2; diff --git a/tests/baselines/reference/exportArrayBindingPattern.js b/tests/baselines/reference/exportArrayBindingPattern.js index 386419e5725..b5568109763 100644 --- a/tests/baselines/reference/exportArrayBindingPattern.js +++ b/tests/baselines/reference/exportArrayBindingPattern.js @@ -5,6 +5,7 @@ export { a, b }; //// [exportArrayBindingPattern.js] "use strict"; +exports.__esModule = true; // issue: https://github.com/Microsoft/TypeScript/issues/10778 var _a = [1, 2, 3], a = _a[0], b = _a[2]; exports.a = a; diff --git a/tests/baselines/reference/exportAssignClassAndModule.js b/tests/baselines/reference/exportAssignClassAndModule.js index bdfceef6b80..9f3eaf78480 100644 --- a/tests/baselines/reference/exportAssignClassAndModule.js +++ b/tests/baselines/reference/exportAssignClassAndModule.js @@ -28,6 +28,7 @@ var Foo = (function () { module.exports = Foo; //// [exportAssignClassAndModule_1.js] "use strict"; +exports.__esModule = true; var z; var zz; zz.x; diff --git a/tests/baselines/reference/exportAssignDottedName.js b/tests/baselines/reference/exportAssignDottedName.js index c9c3ffa80c4..592d97dbaa0 100644 --- a/tests/baselines/reference/exportAssignDottedName.js +++ b/tests/baselines/reference/exportAssignDottedName.js @@ -12,6 +12,7 @@ export = foo1.x; // Ok //// [foo1.js] "use strict"; +exports.__esModule = true; function x() { return true; } diff --git a/tests/baselines/reference/exportAssignImportedIdentifier.js b/tests/baselines/reference/exportAssignImportedIdentifier.js index a469e90b619..208df4eff63 100644 --- a/tests/baselines/reference/exportAssignImportedIdentifier.js +++ b/tests/baselines/reference/exportAssignImportedIdentifier.js @@ -16,6 +16,7 @@ var x = foo2(); // should be boolean //// [foo1.js] "use strict"; +exports.__esModule = true; function x() { return true; } @@ -27,5 +28,6 @@ var x = foo1.x; module.exports = x; //// [foo3.js] "use strict"; +exports.__esModule = true; var foo2 = require("./foo2"); var x = foo2(); // should be boolean diff --git a/tests/baselines/reference/exportAssignTypes.js b/tests/baselines/reference/exportAssignTypes.js index 02b34715483..bed4480f393 100644 --- a/tests/baselines/reference/exportAssignTypes.js +++ b/tests/baselines/reference/exportAssignTypes.js @@ -85,6 +85,7 @@ function x(a) { module.exports = x; //// [consumer.js] "use strict"; +exports.__esModule = true; var iString = require("./expString"); var v1 = iString; var iNumber = require("./expNumber"); diff --git a/tests/baselines/reference/exportAssignedTypeAsTypeAnnotation.js b/tests/baselines/reference/exportAssignedTypeAsTypeAnnotation.js index 26a43e10c6c..d4b6961cfe9 100644 --- a/tests/baselines/reference/exportAssignedTypeAsTypeAnnotation.js +++ b/tests/baselines/reference/exportAssignedTypeAsTypeAnnotation.js @@ -17,9 +17,11 @@ var t2: test; // should not raise a 'container type' error //// [exportAssignedTypeAsTypeAnnotation_0.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [exportAssignedTypeAsTypeAnnotation_1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var t2; // should not raise a 'container type' error }); diff --git a/tests/baselines/reference/exportAssignmentClass.js b/tests/baselines/reference/exportAssignmentClass.js index 02c74fe1f39..549ad5bbd4d 100644 --- a/tests/baselines/reference/exportAssignmentClass.js +++ b/tests/baselines/reference/exportAssignmentClass.js @@ -25,6 +25,7 @@ define(["require", "exports"], function (require, exports) { //// [exportAssignmentClass_B.js] define(["require", "exports", "exportAssignmentClass_A"], function (require, exports, D) { "use strict"; + exports.__esModule = true; var d = new D(); var x = d.p; }); diff --git a/tests/baselines/reference/exportAssignmentConstrainedGenericType.js b/tests/baselines/reference/exportAssignmentConstrainedGenericType.js index c0b8f2b50c1..eddbddf8d6d 100644 --- a/tests/baselines/reference/exportAssignmentConstrainedGenericType.js +++ b/tests/baselines/reference/exportAssignmentConstrainedGenericType.js @@ -24,6 +24,7 @@ var Foo = (function () { module.exports = Foo; //// [foo_1.js] "use strict"; +exports.__esModule = true; var foo = require("./foo_0"); var x = new foo(true); // Should error var y = new foo({ a: "test", b: 42 }); // Should be OK diff --git a/tests/baselines/reference/exportAssignmentEnum.js b/tests/baselines/reference/exportAssignmentEnum.js index a4ae6898bce..a32da0a2e3f 100644 --- a/tests/baselines/reference/exportAssignmentEnum.js +++ b/tests/baselines/reference/exportAssignmentEnum.js @@ -27,6 +27,7 @@ var E; module.exports = E; //// [exportAssignmentEnum_B.js] "use strict"; +exports.__esModule = true; var EnumE = require("./exportAssignmentEnum_A"); var a = EnumE.A; var b = EnumE.B; diff --git a/tests/baselines/reference/exportAssignmentFunction.js b/tests/baselines/reference/exportAssignmentFunction.js index c8e90571cdb..775bb6b1af1 100644 --- a/tests/baselines/reference/exportAssignmentFunction.js +++ b/tests/baselines/reference/exportAssignmentFunction.js @@ -19,5 +19,6 @@ define(["require", "exports"], function (require, exports) { //// [exportAssignmentFunction_B.js] define(["require", "exports", "exportAssignmentFunction_A"], function (require, exports, fooFunc) { "use strict"; + exports.__esModule = true; var n = fooFunc(); }); diff --git a/tests/baselines/reference/exportAssignmentGenericType.js b/tests/baselines/reference/exportAssignmentGenericType.js index 390a929ce35..95563aa36a9 100644 --- a/tests/baselines/reference/exportAssignmentGenericType.js +++ b/tests/baselines/reference/exportAssignmentGenericType.js @@ -22,6 +22,7 @@ var Foo = (function () { module.exports = Foo; //// [foo_1.js] "use strict"; +exports.__esModule = true; var foo = require("./foo_0"); var x = new foo(); var y = x.test; diff --git a/tests/baselines/reference/exportAssignmentInterface.js b/tests/baselines/reference/exportAssignmentInterface.js index be3f696b19b..f3cc9ae9bbe 100644 --- a/tests/baselines/reference/exportAssignmentInterface.js +++ b/tests/baselines/reference/exportAssignmentInterface.js @@ -17,10 +17,12 @@ var n: number = i.p1; //// [exportAssignmentInterface_A.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [exportAssignmentInterface_B.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var i; var n = i.p1; }); diff --git a/tests/baselines/reference/exportAssignmentInternalModule.js b/tests/baselines/reference/exportAssignmentInternalModule.js index 7b2443fc26d..b5c45785f8f 100644 --- a/tests/baselines/reference/exportAssignmentInternalModule.js +++ b/tests/baselines/reference/exportAssignmentInternalModule.js @@ -23,5 +23,6 @@ define(["require", "exports"], function (require, exports) { //// [exportAssignmentInternalModule_B.js] define(["require", "exports", "exportAssignmentInternalModule_A"], function (require, exports, modM) { "use strict"; + exports.__esModule = true; var n = modM.x; }); diff --git a/tests/baselines/reference/exportAssignmentMergedInterface.js b/tests/baselines/reference/exportAssignmentMergedInterface.js index 97c6941cc33..3ee760dedfa 100644 --- a/tests/baselines/reference/exportAssignmentMergedInterface.js +++ b/tests/baselines/reference/exportAssignmentMergedInterface.js @@ -25,10 +25,12 @@ z = x.d; //// [foo_0.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [foo_1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var x; x("test"); x(42); diff --git a/tests/baselines/reference/exportAssignmentMergedModule.js b/tests/baselines/reference/exportAssignmentMergedModule.js index aa2a7082f76..ef48895b5cb 100644 --- a/tests/baselines/reference/exportAssignmentMergedModule.js +++ b/tests/baselines/reference/exportAssignmentMergedModule.js @@ -47,6 +47,7 @@ var Foo; module.exports = Foo; //// [foo_1.js] "use strict"; +exports.__esModule = true; var foo = require("./foo_0"); var a = foo.a(); if (!!foo.b) { diff --git a/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.js b/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.js index a2ddd50511c..6c61eeedfc1 100644 --- a/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.js +++ b/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.js @@ -18,8 +18,10 @@ var b = z(); // call signature - no error //// [exportAssignmentOfDeclaredExternalModule_0.js] "use strict"; +exports.__esModule = true; //// [exportAssignmentOfDeclaredExternalModule_1.js] "use strict"; +exports.__esModule = true; var x = new Sammy(); // error to use as constructor as there is not constructor symbol var y = Sammy(); // error to use interface name as call target var z; // no error - z is of type interface Sammy from module 'M' diff --git a/tests/baselines/reference/exportAssignmentOfGenericType1.js b/tests/baselines/reference/exportAssignmentOfGenericType1.js index 7c1831ecac4..9cd15ec01a4 100644 --- a/tests/baselines/reference/exportAssignmentOfGenericType1.js +++ b/tests/baselines/reference/exportAssignmentOfGenericType1.js @@ -24,17 +24,23 @@ define(["require", "exports"], function (require, exports) { return T; }); //// [exportAssignmentOfGenericType1_1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); define(["require", "exports", "exportAssignmentOfGenericType1_0"], function (require, exports, q) { "use strict"; + exports.__esModule = true; var M = (function (_super) { __extends(M, _super); function M() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return M; }(q)); diff --git a/tests/baselines/reference/exportAssignmentTopLevelClodule.js b/tests/baselines/reference/exportAssignmentTopLevelClodule.js index 9e073462aac..f4001e5ab15 100644 --- a/tests/baselines/reference/exportAssignmentTopLevelClodule.js +++ b/tests/baselines/reference/exportAssignmentTopLevelClodule.js @@ -33,6 +33,7 @@ define(["require", "exports"], function (require, exports) { //// [foo_1.js] define(["require", "exports", "./foo_0"], function (require, exports, foo) { "use strict"; + exports.__esModule = true; if (foo.answer === 42) { var x = new foo(); } diff --git a/tests/baselines/reference/exportAssignmentTopLevelEnumdule.js b/tests/baselines/reference/exportAssignmentTopLevelEnumdule.js index 5043a684326..7ba5a655c20 100644 --- a/tests/baselines/reference/exportAssignmentTopLevelEnumdule.js +++ b/tests/baselines/reference/exportAssignmentTopLevelEnumdule.js @@ -34,6 +34,7 @@ define(["require", "exports"], function (require, exports) { //// [foo_1.js] define(["require", "exports", "./foo_0"], function (require, exports, foo) { "use strict"; + exports.__esModule = true; var color; if (color === foo.green) { color = foo.answer; diff --git a/tests/baselines/reference/exportAssignmentTopLevelFundule.js b/tests/baselines/reference/exportAssignmentTopLevelFundule.js index 0549700e464..f122b8fbe8b 100644 --- a/tests/baselines/reference/exportAssignmentTopLevelFundule.js +++ b/tests/baselines/reference/exportAssignmentTopLevelFundule.js @@ -30,6 +30,7 @@ define(["require", "exports"], function (require, exports) { //// [foo_1.js] define(["require", "exports", "./foo_0"], function (require, exports, foo) { "use strict"; + exports.__esModule = true; if (foo.answer === 42) { var x = foo(); } diff --git a/tests/baselines/reference/exportAssignmentTopLevelIdentifier.js b/tests/baselines/reference/exportAssignmentTopLevelIdentifier.js index 03b4ae26af9..a7acbaf3496 100644 --- a/tests/baselines/reference/exportAssignmentTopLevelIdentifier.js +++ b/tests/baselines/reference/exportAssignmentTopLevelIdentifier.js @@ -25,6 +25,7 @@ define(["require", "exports"], function (require, exports) { //// [foo_1.js] define(["require", "exports", "./foo_0"], function (require, exports, foo) { "use strict"; + exports.__esModule = true; if (foo.answer === 42) { } }); diff --git a/tests/baselines/reference/exportAssignmentVariable.js b/tests/baselines/reference/exportAssignmentVariable.js index 68a195230df..e6ccdb46f9a 100644 --- a/tests/baselines/reference/exportAssignmentVariable.js +++ b/tests/baselines/reference/exportAssignmentVariable.js @@ -16,5 +16,6 @@ var x = 0; module.exports = x; //// [exportAssignmentVariable_B.js] "use strict"; +exports.__esModule = true; var y = require("./exportAssignmentVariable_A"); var n = y; diff --git a/tests/baselines/reference/exportClassExtendingIntersection.errors.txt b/tests/baselines/reference/exportClassExtendingIntersection.errors.txt new file mode 100644 index 00000000000..eb94869fdc2 --- /dev/null +++ b/tests/baselines/reference/exportClassExtendingIntersection.errors.txt @@ -0,0 +1,39 @@ +tests/cases/compiler/FinalClass.ts(4,14): error TS4093: 'extends' clause of exported class 'MyExtendedClass' refers to a type whose name cannot be referenced. + + +==== tests/cases/compiler/BaseClass.ts (0 errors) ==== + export type Constructor = new (...args: any[]) => T; + + export class MyBaseClass { + baseProperty: string; + constructor(value: T) {} + } +==== tests/cases/compiler/MixinClass.ts (0 errors) ==== + import { Constructor, MyBaseClass } from './BaseClass'; + + export interface MyMixin { + mixinProperty: string; + } + + export function MyMixin>>(base: T): T & Constructor { + return class extends base { + mixinProperty: string; + } + } +==== tests/cases/compiler/FinalClass.ts (1 errors) ==== + import { MyBaseClass } from './BaseClass'; + import { MyMixin } from './MixinClass'; + + export class MyExtendedClass extends MyMixin(MyBaseClass) { + ~~~~~~~~~~~~~~~ +!!! error TS4093: 'extends' clause of exported class 'MyExtendedClass' refers to a type whose name cannot be referenced. + extendedClassProperty: number; + } +==== tests/cases/compiler/Main.ts (0 errors) ==== + import { MyExtendedClass } from './FinalClass'; + import { MyMixin } from './MixinClass'; + + const myExtendedClass = new MyExtendedClass('string'); + + const AnotherMixedClass = MyMixin(MyExtendedClass); + \ No newline at end of file diff --git a/tests/baselines/reference/exportClassExtendingIntersection.js b/tests/baselines/reference/exportClassExtendingIntersection.js new file mode 100644 index 00000000000..2309a9af9b6 --- /dev/null +++ b/tests/baselines/reference/exportClassExtendingIntersection.js @@ -0,0 +1,114 @@ +//// [tests/cases/compiler/exportClassExtendingIntersection.ts] //// + +//// [BaseClass.ts] +export type Constructor = new (...args: any[]) => T; + +export class MyBaseClass { + baseProperty: string; + constructor(value: T) {} +} +//// [MixinClass.ts] +import { Constructor, MyBaseClass } from './BaseClass'; + +export interface MyMixin { + mixinProperty: string; +} + +export function MyMixin>>(base: T): T & Constructor { + return class extends base { + mixinProperty: string; + } +} +//// [FinalClass.ts] +import { MyBaseClass } from './BaseClass'; +import { MyMixin } from './MixinClass'; + +export class MyExtendedClass extends MyMixin(MyBaseClass) { + extendedClassProperty: number; +} +//// [Main.ts] +import { MyExtendedClass } from './FinalClass'; +import { MyMixin } from './MixinClass'; + +const myExtendedClass = new MyExtendedClass('string'); + +const AnotherMixedClass = MyMixin(MyExtendedClass); + + +//// [BaseClass.js] +"use strict"; +exports.__esModule = true; +var MyBaseClass = (function () { + function MyBaseClass(value) { + } + return MyBaseClass; +}()); +exports.MyBaseClass = MyBaseClass; +//// [MixinClass.js] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +function MyMixin(base) { + return (function (_super) { + __extends(class_1, _super); + function class_1() { + return _super !== null && _super.apply(this, arguments) || this; + } + return class_1; + }(base)); +} +exports.MyMixin = MyMixin; +//// [FinalClass.js] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var BaseClass_1 = require("./BaseClass"); +var MixinClass_1 = require("./MixinClass"); +var MyExtendedClass = (function (_super) { + __extends(MyExtendedClass, _super); + function MyExtendedClass() { + return _super !== null && _super.apply(this, arguments) || this; + } + return MyExtendedClass; +}(MixinClass_1.MyMixin(BaseClass_1.MyBaseClass))); +exports.MyExtendedClass = MyExtendedClass; +//// [Main.js] +"use strict"; +exports.__esModule = true; +var FinalClass_1 = require("./FinalClass"); +var MixinClass_1 = require("./MixinClass"); +var myExtendedClass = new FinalClass_1.MyExtendedClass('string'); +var AnotherMixedClass = MixinClass_1.MyMixin(FinalClass_1.MyExtendedClass); + + +//// [BaseClass.d.ts] +export declare type Constructor = new (...args: any[]) => T; +export declare class MyBaseClass { + baseProperty: string; + constructor(value: T); +} +//// [MixinClass.d.ts] +import { Constructor, MyBaseClass } from './BaseClass'; +export interface MyMixin { + mixinProperty: string; +} +export declare function MyMixin>>(base: T): T & Constructor; +//// [Main.d.ts] diff --git a/tests/baselines/reference/exportDeclarationInInternalModule.js b/tests/baselines/reference/exportDeclarationInInternalModule.js index b6d6d982a32..dde865bd2c7 100644 --- a/tests/baselines/reference/exportDeclarationInInternalModule.js +++ b/tests/baselines/reference/exportDeclarationInInternalModule.js @@ -19,11 +19,16 @@ var a: Bbb.SomeType; //// [exportDeclarationInInternalModule.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Bbb = (function () { function Bbb() { } @@ -32,7 +37,7 @@ var Bbb = (function () { var Aaa = (function (_super) { __extends(Aaa, _super); function Aaa() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Aaa; }(Bbb)); diff --git a/tests/baselines/reference/exportDeclarationWithModuleSpecifierNameOnNextLine1.js b/tests/baselines/reference/exportDeclarationWithModuleSpecifierNameOnNextLine1.js index 19f872bad27..e0165098b20 100644 --- a/tests/baselines/reference/exportDeclarationWithModuleSpecifierNameOnNextLine1.js +++ b/tests/baselines/reference/exportDeclarationWithModuleSpecifierNameOnNextLine1.js @@ -22,18 +22,23 @@ export { x as a, } from //// [t1.js] "use strict"; +exports.__esModule = true; exports.x = "x"; //// [t2.js] "use strict"; +exports.__esModule = true; var t1_1 = require("./t1"); exports.x = t1_1.x; //// [t3.js] "use strict"; +exports.__esModule = true; //// [t4.js] "use strict"; +exports.__esModule = true; var t1_1 = require("./t1"); exports.a = t1_1.x; //// [t5.js] "use strict"; +exports.__esModule = true; var t1_1 = require("./t1"); exports.a = t1_1.x; diff --git a/tests/baselines/reference/exportDeclarationsInAmbientNamespaces.js b/tests/baselines/reference/exportDeclarationsInAmbientNamespaces.js new file mode 100644 index 00000000000..d458433aed4 --- /dev/null +++ b/tests/baselines/reference/exportDeclarationsInAmbientNamespaces.js @@ -0,0 +1,13 @@ +//// [exportDeclarationsInAmbientNamespaces.ts] + +declare namespace Q { + function _try(method: Function, ...args: any[]): any; + export { _try as try }; +} + +Q.try(() => { }); + + + +//// [exportDeclarationsInAmbientNamespaces.js] +Q["try"](function () { }); diff --git a/tests/baselines/reference/exportDeclarationsInAmbientNamespaces.symbols b/tests/baselines/reference/exportDeclarationsInAmbientNamespaces.symbols new file mode 100644 index 00000000000..99e70fe4595 --- /dev/null +++ b/tests/baselines/reference/exportDeclarationsInAmbientNamespaces.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/exportDeclarationsInAmbientNamespaces.ts === + +declare namespace Q { +>Q : Symbol(Q, Decl(exportDeclarationsInAmbientNamespaces.ts, 0, 0)) + + function _try(method: Function, ...args: any[]): any; +>_try : Symbol(_try, Decl(exportDeclarationsInAmbientNamespaces.ts, 1, 21)) +>method : Symbol(method, Decl(exportDeclarationsInAmbientNamespaces.ts, 2, 18)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>args : Symbol(args, Decl(exportDeclarationsInAmbientNamespaces.ts, 2, 35)) + + export { _try as try }; +>_try : Symbol(try, Decl(exportDeclarationsInAmbientNamespaces.ts, 3, 12)) +>try : Symbol(try, Decl(exportDeclarationsInAmbientNamespaces.ts, 3, 12)) +} + +Q.try(() => { }); +>Q.try : Symbol(Q.try, Decl(exportDeclarationsInAmbientNamespaces.ts, 3, 12)) +>Q : Symbol(Q, Decl(exportDeclarationsInAmbientNamespaces.ts, 0, 0)) +>try : Symbol(Q.try, Decl(exportDeclarationsInAmbientNamespaces.ts, 3, 12)) + + diff --git a/tests/baselines/reference/exportDeclarationsInAmbientNamespaces.types b/tests/baselines/reference/exportDeclarationsInAmbientNamespaces.types new file mode 100644 index 00000000000..a46d99454f9 --- /dev/null +++ b/tests/baselines/reference/exportDeclarationsInAmbientNamespaces.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/exportDeclarationsInAmbientNamespaces.ts === + +declare namespace Q { +>Q : typeof Q + + function _try(method: Function, ...args: any[]): any; +>_try : (method: Function, ...args: any[]) => any +>method : Function +>Function : Function +>args : any[] + + export { _try as try }; +>_try : (method: Function, ...args: any[]) => any +>try : (method: Function, ...args: any[]) => any +} + +Q.try(() => { }); +>Q.try(() => { }) : any +>Q.try : (method: Function, ...args: any[]) => any +>Q : typeof Q +>try : (method: Function, ...args: any[]) => any +>() => { } : () => void + + diff --git a/tests/baselines/reference/exportDeclarationsInAmbientNamespaces2.errors.txt b/tests/baselines/reference/exportDeclarationsInAmbientNamespaces2.errors.txt new file mode 100644 index 00000000000..54c04bd9b1d --- /dev/null +++ b/tests/baselines/reference/exportDeclarationsInAmbientNamespaces2.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/exportDeclarationsInAmbientNamespaces2.ts(7,23): error TS1194: Export declarations are not permitted in a namespace. + + +==== tests/cases/compiler/exportDeclarationsInAmbientNamespaces2.ts (1 errors) ==== + + declare module "mod" { + export var x: number; + } + + declare namespace N { + export { x } from "mod"; // Error + ~~~~~ +!!! error TS1194: Export declarations are not permitted in a namespace. + } + + \ No newline at end of file diff --git a/tests/baselines/reference/exportDeclarationsInAmbientNamespaces2.js b/tests/baselines/reference/exportDeclarationsInAmbientNamespaces2.js new file mode 100644 index 00000000000..6896f13025d --- /dev/null +++ b/tests/baselines/reference/exportDeclarationsInAmbientNamespaces2.js @@ -0,0 +1,13 @@ +//// [exportDeclarationsInAmbientNamespaces2.ts] + +declare module "mod" { + export var x: number; +} + +declare namespace N { + export { x } from "mod"; // Error +} + + + +//// [exportDeclarationsInAmbientNamespaces2.js] diff --git a/tests/baselines/reference/exportDeclareClass1.js b/tests/baselines/reference/exportDeclareClass1.js index 18ced8df9d6..950b3db26e5 100644 --- a/tests/baselines/reference/exportDeclareClass1.js +++ b/tests/baselines/reference/exportDeclareClass1.js @@ -12,6 +12,7 @@ //// [exportDeclareClass1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; ; ; }); diff --git a/tests/baselines/reference/exportDeclaredModule.js b/tests/baselines/reference/exportDeclaredModule.js index 419fecf42e0..473ebaa0492 100644 --- a/tests/baselines/reference/exportDeclaredModule.js +++ b/tests/baselines/reference/exportDeclaredModule.js @@ -17,5 +17,6 @@ var x: number = foo1.b(); module.exports = M1; //// [foo2.js] "use strict"; +exports.__esModule = true; var foo1 = require("./foo1"); var x = foo1.b(); diff --git a/tests/baselines/reference/exportDefaultAsyncFunction.symbols b/tests/baselines/reference/exportDefaultAsyncFunction.symbols index 47178519558..a86226fe678 100644 --- a/tests/baselines/reference/exportDefaultAsyncFunction.symbols +++ b/tests/baselines/reference/exportDefaultAsyncFunction.symbols @@ -1,7 +1,7 @@ === tests/cases/compiler/exportDefaultAsyncFunction.ts === export default async function foo(): Promise {} >foo : Symbol(foo, Decl(exportDefaultAsyncFunction.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) foo(); >foo : Symbol(foo, Decl(exportDefaultAsyncFunction.ts, 0, 0)) diff --git a/tests/baselines/reference/exportDefaultAsyncFunction2.symbols b/tests/baselines/reference/exportDefaultAsyncFunction2.symbols index 013d0d7f697..cffbf284573 100644 --- a/tests/baselines/reference/exportDefaultAsyncFunction2.symbols +++ b/tests/baselines/reference/exportDefaultAsyncFunction2.symbols @@ -18,7 +18,7 @@ export default async(() => await(Promise.resolve(1))); >async : Symbol(async, Decl(a.ts, 0, 8)) >await : Symbol(await, Decl(a.ts, 0, 15)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) === tests/cases/compiler/b.ts === diff --git a/tests/baselines/reference/exportDefaultProperty.js b/tests/baselines/reference/exportDefaultProperty.js index 2dcef41d761..dddea6a6b73 100644 --- a/tests/baselines/reference/exportDefaultProperty.js +++ b/tests/baselines/reference/exportDefaultProperty.js @@ -43,6 +43,7 @@ fooLength + 1; //// [a.js] "use strict"; +exports.__esModule = true; var A; (function (A) { var B = (function () { @@ -55,7 +56,6 @@ var A; B.b = 0; })(B = A.B || (A.B = {})); })(A || (A = {})); -exports.__esModule = true; exports["default"] = A.B; //// [b.js] "use strict"; @@ -63,6 +63,7 @@ exports.__esModule = true; exports["default"] = "foo".length; //// [index.js] "use strict"; +exports.__esModule = true; /// var foobar_1 = require("foobar"); var X = foobar_1["default"].X; diff --git a/tests/baselines/reference/exportDefaultProperty2.js b/tests/baselines/reference/exportDefaultProperty2.js index 2b0a5dce526..4922738430a 100644 --- a/tests/baselines/reference/exportDefaultProperty2.js +++ b/tests/baselines/reference/exportDefaultProperty2.js @@ -20,14 +20,15 @@ const x: B = { c: B }; //// [a.js] // This test is just like exportEqualsProperty2, but with `export default`. "use strict"; +exports.__esModule = true; var C = (function () { function C() { } return C; }()); -exports.__esModule = true; exports["default"] = C.B; //// [b.js] "use strict"; +exports.__esModule = true; var a_1 = require("./a"); var x = { c: a_1["default"] }; diff --git a/tests/baselines/reference/exportEqualCallable.js b/tests/baselines/reference/exportEqualCallable.js index 9138da0d33d..177e3943ac7 100644 --- a/tests/baselines/reference/exportEqualCallable.js +++ b/tests/baselines/reference/exportEqualCallable.js @@ -22,5 +22,6 @@ define(["require", "exports"], function (require, exports) { //// [exportEqualCallable_1.js] define(["require", "exports", "exportEqualCallable_0"], function (require, exports, connect) { "use strict"; + exports.__esModule = true; connect(); }); diff --git a/tests/baselines/reference/exportEqualErrorType.js b/tests/baselines/reference/exportEqualErrorType.js index aa715b7d9f2..4a65ce5fd49 100644 --- a/tests/baselines/reference/exportEqualErrorType.js +++ b/tests/baselines/reference/exportEqualErrorType.js @@ -30,5 +30,6 @@ define(["require", "exports"], function (require, exports) { //// [exportEqualErrorType_1.js] define(["require", "exports", "exportEqualErrorType_0"], function (require, exports, connect) { "use strict"; + exports.__esModule = true; connect().use(connect.static('foo')); // Error 1 The property 'static' does not exist on value of type ''. }); diff --git a/tests/baselines/reference/exportEqualMemberMissing.js b/tests/baselines/reference/exportEqualMemberMissing.js index 39074e10372..68ac9485f5f 100644 --- a/tests/baselines/reference/exportEqualMemberMissing.js +++ b/tests/baselines/reference/exportEqualMemberMissing.js @@ -27,6 +27,7 @@ var server; module.exports = server; //// [exportEqualMemberMissing_1.js] "use strict"; +exports.__esModule = true; /// var connect = require("./exportEqualMemberMissing_0"); connect().use(connect.static('foo')); // Error 1 The property 'static' does not exist on value of type ''. diff --git a/tests/baselines/reference/exportEqualsDefaultProperty.js b/tests/baselines/reference/exportEqualsDefaultProperty.js index 6d75ef5d95d..9cf7a7b2ee8 100644 --- a/tests/baselines/reference/exportEqualsDefaultProperty.js +++ b/tests/baselines/reference/exportEqualsDefaultProperty.js @@ -23,5 +23,6 @@ var x = { module.exports = x; //// [imp.js] "use strict"; +exports.__esModule = true; var exp_1 = require("./exp"); exp_1["default"].toExponential(2); diff --git a/tests/baselines/reference/exportEqualsProperty.js b/tests/baselines/reference/exportEqualsProperty.js index 9acb1ee49b7..e6bd09d5367 100644 --- a/tests/baselines/reference/exportEqualsProperty.js +++ b/tests/baselines/reference/exportEqualsProperty.js @@ -60,6 +60,7 @@ module.exports = A.B; module.exports = "foo".length; //// [index.js] "use strict"; +exports.__esModule = true; /// var foobar_1 = require("foobar"); var X2 = require("foobarx"); diff --git a/tests/baselines/reference/exportEqualsProperty2.js b/tests/baselines/reference/exportEqualsProperty2.js index b5d91431722..36fcbdf3446 100644 --- a/tests/baselines/reference/exportEqualsProperty2.js +++ b/tests/baselines/reference/exportEqualsProperty2.js @@ -28,5 +28,6 @@ var C = (function () { module.exports = C.B; //// [b.js] "use strict"; +exports.__esModule = true; var B = require("./a"); var x = { c: B }; diff --git a/tests/baselines/reference/exportImport.js b/tests/baselines/reference/exportImport.js index 8f785282080..615f3d266ab 100644 --- a/tests/baselines/reference/exportImport.js +++ b/tests/baselines/reference/exportImport.js @@ -29,11 +29,13 @@ define(["require", "exports"], function (require, exports) { //// [exporter.js] define(["require", "exports", "./w1"], function (require, exports, w) { "use strict"; + exports.__esModule = true; exports.w = w; }); //// [consumer.js] define(["require", "exports", "./exporter"], function (require, exports, e) { "use strict"; + exports.__esModule = true; function w() { return new e.w(); } diff --git a/tests/baselines/reference/exportImportMultipleFiles.js b/tests/baselines/reference/exportImportMultipleFiles.js index 345d2a6885a..31f5f218d65 100644 --- a/tests/baselines/reference/exportImportMultipleFiles.js +++ b/tests/baselines/reference/exportImportMultipleFiles.js @@ -15,17 +15,20 @@ lib.math.add(3, 4); // Shouldnt be error //// [exportImportMultipleFiles_math.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; function add(a, b) { return a + b; } exports.add = add; }); //// [exportImportMultipleFiles_library.js] define(["require", "exports", "exportImportMultipleFiles_math"], function (require, exports, math) { "use strict"; + exports.__esModule = true; exports.math = math; exports.math.add(3, 4); // OK }); //// [exportImportMultipleFiles_userCode.js] define(["require", "exports", "./exportImportMultipleFiles_library"], function (require, exports, lib) { "use strict"; + exports.__esModule = true; lib.math.add(3, 4); // Shouldnt be error }); diff --git a/tests/baselines/reference/exportImportNonInstantiatedModule2.js b/tests/baselines/reference/exportImportNonInstantiatedModule2.js index 401183a5ead..1394d7492dd 100644 --- a/tests/baselines/reference/exportImportNonInstantiatedModule2.js +++ b/tests/baselines/reference/exportImportNonInstantiatedModule2.js @@ -18,14 +18,17 @@ export function w(): e.w { // Should be OK //// [w1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [exporter.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [consumer.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; function w() { return { name: 'value' }; } diff --git a/tests/baselines/reference/exportNonInitializedVariablesAMD.js b/tests/baselines/reference/exportNonInitializedVariablesAMD.js index d8dd17a562c..f7ee0b8d4d8 100644 --- a/tests/baselines/reference/exportNonInitializedVariablesAMD.js +++ b/tests/baselines/reference/exportNonInitializedVariablesAMD.js @@ -37,6 +37,7 @@ export let h1: D = new D; //// [exportNonInitializedVariablesAMD.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var ; let; var ; diff --git a/tests/baselines/reference/exportNonInitializedVariablesCommonJS.js b/tests/baselines/reference/exportNonInitializedVariablesCommonJS.js index f986ef7f36b..7623127aee8 100644 --- a/tests/baselines/reference/exportNonInitializedVariablesCommonJS.js +++ b/tests/baselines/reference/exportNonInitializedVariablesCommonJS.js @@ -36,6 +36,7 @@ export let h1: D = new D; //// [exportNonInitializedVariablesCommonJS.js] "use strict"; +exports.__esModule = true; var ; let; var ; diff --git a/tests/baselines/reference/exportNonInitializedVariablesUMD.js b/tests/baselines/reference/exportNonInitializedVariablesUMD.js index 796818c650c..504c6e70084 100644 --- a/tests/baselines/reference/exportNonInitializedVariablesUMD.js +++ b/tests/baselines/reference/exportNonInitializedVariablesUMD.js @@ -45,6 +45,7 @@ export let h1: D = new D; } })(function (require, exports) { "use strict"; + exports.__esModule = true; var ; let; var ; diff --git a/tests/baselines/reference/exportRedeclarationTypeAliases.js b/tests/baselines/reference/exportRedeclarationTypeAliases.js index b1e2e200634..c3e97cf3e10 100644 --- a/tests/baselines/reference/exportRedeclarationTypeAliases.js +++ b/tests/baselines/reference/exportRedeclarationTypeAliases.js @@ -5,5 +5,6 @@ export function Foo(): any {} //// [exportRedeclarationTypeAliases.js] "use strict"; +exports.__esModule = true; function Foo() { } exports.Foo = Foo; diff --git a/tests/baselines/reference/exportSameNameFuncVar.js b/tests/baselines/reference/exportSameNameFuncVar.js index 2bc77e079fb..dc0b24b98c3 100644 --- a/tests/baselines/reference/exportSameNameFuncVar.js +++ b/tests/baselines/reference/exportSameNameFuncVar.js @@ -6,6 +6,7 @@ export function a() { //// [exportSameNameFuncVar.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.a = 10; function a() { } diff --git a/tests/baselines/reference/exportSpecifierForAGlobal.js b/tests/baselines/reference/exportSpecifierForAGlobal.js index ac79a9bf69d..fe59f5071f2 100644 --- a/tests/baselines/reference/exportSpecifierForAGlobal.js +++ b/tests/baselines/reference/exportSpecifierForAGlobal.js @@ -14,6 +14,7 @@ export function f() { //// [b.js] "use strict"; +exports.__esModule = true; function f() { var x; return x; diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.js b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.js index cb06a818b08..0a8ebd10ee4 100644 --- a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.js +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.js @@ -10,3 +10,4 @@ export declare function foo(): X.bar; //// [exportSpecifierReferencingOuterDeclaration2_A.js] //// [exportSpecifierReferencingOuterDeclaration2_B.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.js b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.js index 1badf469996..f0c6dd55984 100644 --- a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.js +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.js @@ -12,3 +12,4 @@ export declare function bar(): X.bar; // error //// [exportSpecifierReferencingOuterDeclaration2_A.js] //// [exportSpecifierReferencingOuterDeclaration2_B.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/exportStar-amd.js b/tests/baselines/reference/exportStar-amd.js index bd4c112ff2e..f25a68a5aa6 100644 --- a/tests/baselines/reference/exportStar-amd.js +++ b/tests/baselines/reference/exportStar-amd.js @@ -32,6 +32,7 @@ foo; //// [t1.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.x = 1; exports.y = 2; }); @@ -46,6 +47,7 @@ define(["require", "exports"], function (require, exports) { //// [t3.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var x = "x"; exports.x = x; var y = "y"; @@ -59,6 +61,7 @@ define(["require", "exports", "./t1", "./t2", "./t3"], function (require, export function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } + Object.defineProperty(exports, "__esModule", { value: true }); __export(t1_1); __export(t2_1); __export(t3_1); @@ -66,6 +69,7 @@ define(["require", "exports", "./t1", "./t2", "./t3"], function (require, export //// [main.js] define(["require", "exports", "./t4"], function (require, exports, t4_1) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); t4_1.default; t4_1.x; t4_1.y; diff --git a/tests/baselines/reference/exportStar.js b/tests/baselines/reference/exportStar.js index a2bc44720fb..a188cefd8b6 100644 --- a/tests/baselines/reference/exportStar.js +++ b/tests/baselines/reference/exportStar.js @@ -31,6 +31,7 @@ foo; //// [t1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.x = 1; exports.y = 2; //// [t2.js] @@ -41,6 +42,7 @@ function foo() { } exports.foo = foo; //// [t3.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var x = "x"; exports.x = x; var y = "y"; @@ -52,11 +54,13 @@ exports.z = z; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } +Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./t1")); __export(require("./t2")); __export(require("./t3")); //// [main.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var t4_1 = require("./t4"); t4_1.default; t4_1.x; diff --git a/tests/baselines/reference/exportStarForValues.js b/tests/baselines/reference/exportStarForValues.js index dd432ecc1d3..8376ec1927e 100644 --- a/tests/baselines/reference/exportStarForValues.js +++ b/tests/baselines/reference/exportStarForValues.js @@ -11,9 +11,11 @@ var x; //// [file1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [file2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var x; }); diff --git a/tests/baselines/reference/exportStarForValues2.js b/tests/baselines/reference/exportStarForValues2.js index e45d5bdd3ba..f18f9f1c587 100644 --- a/tests/baselines/reference/exportStarForValues2.js +++ b/tests/baselines/reference/exportStarForValues2.js @@ -15,14 +15,17 @@ var x = 1; //// [file1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [file2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var x = 1; }); //// [file3.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var x = 1; }); diff --git a/tests/baselines/reference/exportStarForValues3.js b/tests/baselines/reference/exportStarForValues3.js index 9efe5ccf8e5..5ccd12f8a37 100644 --- a/tests/baselines/reference/exportStarForValues3.js +++ b/tests/baselines/reference/exportStarForValues3.js @@ -27,24 +27,29 @@ var x = 1; //// [file1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [file2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var x = 1; }); //// [file3.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var x = 1; }); //// [file4.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var x = 1; }); //// [file5.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var x = 1; }); diff --git a/tests/baselines/reference/exportStarForValues4.js b/tests/baselines/reference/exportStarForValues4.js index 34b13bb00f3..e06b5e26207 100644 --- a/tests/baselines/reference/exportStarForValues4.js +++ b/tests/baselines/reference/exportStarForValues4.js @@ -19,14 +19,17 @@ var x = 1; //// [file1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [file3.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var x = 1; }); //// [file2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var x = 1; }); diff --git a/tests/baselines/reference/exportStarForValues5.js b/tests/baselines/reference/exportStarForValues5.js index dc4d4c8b68e..37c8d59c91a 100644 --- a/tests/baselines/reference/exportStarForValues5.js +++ b/tests/baselines/reference/exportStarForValues5.js @@ -11,8 +11,10 @@ export var x; //// [file1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [file2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/exportStarForValues7.js b/tests/baselines/reference/exportStarForValues7.js index 39a152fdc89..1f5163dd9cd 100644 --- a/tests/baselines/reference/exportStarForValues7.js +++ b/tests/baselines/reference/exportStarForValues7.js @@ -15,10 +15,12 @@ export var x = 1; //// [file1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [file2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.x = 1; }); //// [file3.js] @@ -27,6 +29,7 @@ define(["require", "exports", "file2"], function (require, exports, file2_1) { function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } + exports.__esModule = true; __export(file2_1); exports.x = 1; }); diff --git a/tests/baselines/reference/exportStarForValues8.js b/tests/baselines/reference/exportStarForValues8.js index f8e7678a40c..6f52bce89f9 100644 --- a/tests/baselines/reference/exportStarForValues8.js +++ b/tests/baselines/reference/exportStarForValues8.js @@ -27,15 +27,18 @@ export var x = 1; //// [file1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [file2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.x = 1; }); //// [file3.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.x = 1; }); //// [file4.js] @@ -44,6 +47,7 @@ define(["require", "exports", "file2", "file3"], function (require, exports, fil function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } + exports.__esModule = true; __export(file2_1); __export(file3_1); exports.x = 1; @@ -54,6 +58,7 @@ define(["require", "exports", "file4"], function (require, exports, file4_1) { function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } + exports.__esModule = true; __export(file4_1); exports.x = 1; }); diff --git a/tests/baselines/reference/exportStarForValues9.js b/tests/baselines/reference/exportStarForValues9.js index e057e4d4027..3c34bb1afdb 100644 --- a/tests/baselines/reference/exportStarForValues9.js +++ b/tests/baselines/reference/exportStarForValues9.js @@ -19,6 +19,7 @@ export var x = 1; //// [file1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [file3.js] define(["require", "exports", "file2"], function (require, exports, file2_1) { @@ -26,6 +27,7 @@ define(["require", "exports", "file2"], function (require, exports, file2_1) { function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } + exports.__esModule = true; __export(file2_1); exports.x = 1; }); @@ -35,6 +37,7 @@ define(["require", "exports", "file3"], function (require, exports, file3_1) { function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } + exports.__esModule = true; __export(file3_1); exports.x = 1; }); diff --git a/tests/baselines/reference/exportStarFromEmptyModule.js b/tests/baselines/reference/exportStarFromEmptyModule.js index afb4d2f10c1..4fcac9312b9 100644 --- a/tests/baselines/reference/exportStarFromEmptyModule.js +++ b/tests/baselines/reference/exportStarFromEmptyModule.js @@ -25,6 +25,7 @@ X.A.r; // Error //// [exportStarFromEmptyModule_module1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var A = (function () { function A() { } @@ -38,6 +39,7 @@ exports.A = A; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } +Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./exportStarFromEmptyModule_module2")); __export(require("./exportStarFromEmptyModule_module1")); var A = (function () { @@ -48,6 +50,7 @@ var A = (function () { exports.A = A; //// [exportStarFromEmptyModule_module4.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var X = require("./exportStarFromEmptyModule_module3"); var s; X.A.q; diff --git a/tests/baselines/reference/exportToString.js b/tests/baselines/reference/exportToString.js index 190d1693c24..d527a02741c 100644 --- a/tests/baselines/reference/exportToString.js +++ b/tests/baselines/reference/exportToString.js @@ -5,5 +5,6 @@ export { toString }; //// [exportToString.js] "use strict"; +exports.__esModule = true; var toString = 0; exports.toString = toString; diff --git a/tests/baselines/reference/exportVisibility.js b/tests/baselines/reference/exportVisibility.js index a49cd744441..fbb2555d54b 100644 --- a/tests/baselines/reference/exportVisibility.js +++ b/tests/baselines/reference/exportVisibility.js @@ -11,6 +11,7 @@ export function test(foo: Foo) { //// [exportVisibility.js] "use strict"; +exports.__esModule = true; var Foo = (function () { function Foo() { } diff --git a/tests/baselines/reference/exportedBlockScopedDeclarations.js b/tests/baselines/reference/exportedBlockScopedDeclarations.js index 3e77c3c684b..068ac5db23b 100644 --- a/tests/baselines/reference/exportedBlockScopedDeclarations.js +++ b/tests/baselines/reference/exportedBlockScopedDeclarations.js @@ -20,6 +20,7 @@ namespace NS1 { //// [exportedBlockScopedDeclarations.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var foo = foo; // compile error exports.bar = exports.bar; // should be compile error function f() { diff --git a/tests/baselines/reference/exportedInterfaceInaccessibleInCallbackInModule.js b/tests/baselines/reference/exportedInterfaceInaccessibleInCallbackInModule.js index 6c39978e37d..75b9378c3f4 100644 --- a/tests/baselines/reference/exportedInterfaceInaccessibleInCallbackInModule.js +++ b/tests/baselines/reference/exportedInterfaceInaccessibleInCallbackInModule.js @@ -15,4 +15,5 @@ export declare class TPromise { //// [exportedInterfaceInaccessibleInCallbackInModule.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/exportedVariable1.js b/tests/baselines/reference/exportedVariable1.js index da472fc8790..80a7fc6a391 100644 --- a/tests/baselines/reference/exportedVariable1.js +++ b/tests/baselines/reference/exportedVariable1.js @@ -6,6 +6,7 @@ var upper = foo.name.toUpperCase(); //// [exportedVariable1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.foo = { name: "Bill" }; var upper = exports.foo.name.toUpperCase(); }); diff --git a/tests/baselines/reference/exportingContainingVisibleType.js b/tests/baselines/reference/exportingContainingVisibleType.js index f2d78fe9a88..d50a2a35f06 100644 --- a/tests/baselines/reference/exportingContainingVisibleType.js +++ b/tests/baselines/reference/exportingContainingVisibleType.js @@ -13,6 +13,7 @@ export var x = 5; //// [exportingContainingVisibleType.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var Foo = (function () { function Foo() { } diff --git a/tests/baselines/reference/exportsAndImports1-amd.js b/tests/baselines/reference/exportsAndImports1-amd.js index 9e04b3485d2..87761c779fa 100644 --- a/tests/baselines/reference/exportsAndImports1-amd.js +++ b/tests/baselines/reference/exportsAndImports1-amd.js @@ -37,6 +37,7 @@ export { v, f, C, I, E, D, M, N, T, a }; //// [t1.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var v = 1; exports.v = v; function f() { } @@ -64,6 +65,7 @@ define(["require", "exports"], function (require, exports) { //// [t2.js] define(["require", "exports", "./t1"], function (require, exports, t1_1) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.v = t1_1.v; exports.f = t1_1.f; exports.C = t1_1.C; @@ -74,6 +76,7 @@ define(["require", "exports", "./t1"], function (require, exports, t1_1) { //// [t3.js] define(["require", "exports", "./t1"], function (require, exports, t1_1) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.v = t1_1.v; exports.f = t1_1.f; exports.C = t1_1.C; diff --git a/tests/baselines/reference/exportsAndImports1-es6.js b/tests/baselines/reference/exportsAndImports1-es6.js index 3ac5aeb0dc5..6b9a40f0ea2 100644 --- a/tests/baselines/reference/exportsAndImports1-es6.js +++ b/tests/baselines/reference/exportsAndImports1-es6.js @@ -36,6 +36,7 @@ export { v, f, C, I, E, D, M, N, T, a }; //// [t1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var v = 1; exports.v = v; function f() { } @@ -58,6 +59,7 @@ var a = M.x; exports.a = a; //// [t2.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var t1_1 = require("./t1"); exports.v = t1_1.v; exports.f = t1_1.f; @@ -67,6 +69,7 @@ exports.M = t1_1.M; exports.a = t1_1.a; //// [t3.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); const t1_1 = require("./t1"); exports.v = t1_1.v; exports.f = t1_1.f; diff --git a/tests/baselines/reference/exportsAndImports1.js b/tests/baselines/reference/exportsAndImports1.js index 46eda0656ad..56f74d27473 100644 --- a/tests/baselines/reference/exportsAndImports1.js +++ b/tests/baselines/reference/exportsAndImports1.js @@ -36,6 +36,7 @@ export { v, f, C, I, E, D, M, N, T, a }; //// [t1.js] "use strict"; +exports.__esModule = true; var v = 1; exports.v = v; function f() { } @@ -61,6 +62,7 @@ var a = M.x; exports.a = a; //// [t2.js] "use strict"; +exports.__esModule = true; var t1_1 = require("./t1"); exports.v = t1_1.v; exports.f = t1_1.f; @@ -70,6 +72,7 @@ exports.M = t1_1.M; exports.a = t1_1.a; //// [t3.js] "use strict"; +exports.__esModule = true; var t1_1 = require("./t1"); exports.v = t1_1.v; exports.f = t1_1.f; diff --git a/tests/baselines/reference/exportsAndImports2-amd.js b/tests/baselines/reference/exportsAndImports2-amd.js index 18803de4004..5154751b21e 100644 --- a/tests/baselines/reference/exportsAndImports2-amd.js +++ b/tests/baselines/reference/exportsAndImports2-amd.js @@ -16,18 +16,21 @@ export { x as y, y as x }; //// [t1.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.x = "x"; exports.y = "y"; }); //// [t2.js] define(["require", "exports", "./t1"], function (require, exports, t1_1) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.y = t1_1.x; exports.x = t1_1.y; }); //// [t3.js] define(["require", "exports", "./t1"], function (require, exports, t1_1) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.y = t1_1.x; exports.x = t1_1.y; }); diff --git a/tests/baselines/reference/exportsAndImports2-es6.js b/tests/baselines/reference/exportsAndImports2-es6.js index 56639bdbecf..b0714b83c39 100644 --- a/tests/baselines/reference/exportsAndImports2-es6.js +++ b/tests/baselines/reference/exportsAndImports2-es6.js @@ -15,15 +15,18 @@ export { x as y, y as x }; //// [t1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.x = "x"; exports.y = "y"; //// [t2.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var t1_1 = require("./t1"); exports.y = t1_1.x; exports.x = t1_1.y; //// [t3.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); const t1_1 = require("./t1"); exports.y = t1_1.x; exports.x = t1_1.y; diff --git a/tests/baselines/reference/exportsAndImports2.js b/tests/baselines/reference/exportsAndImports2.js index 3790510979c..5b3fe689d90 100644 --- a/tests/baselines/reference/exportsAndImports2.js +++ b/tests/baselines/reference/exportsAndImports2.js @@ -15,15 +15,18 @@ export { x as y, y as x }; //// [t1.js] "use strict"; +exports.__esModule = true; exports.x = "x"; exports.y = "y"; //// [t2.js] "use strict"; +exports.__esModule = true; var t1_1 = require("./t1"); exports.y = t1_1.x; exports.x = t1_1.y; //// [t3.js] "use strict"; +exports.__esModule = true; var t1_1 = require("./t1"); exports.y = t1_1.x; exports.x = t1_1.y; diff --git a/tests/baselines/reference/exportsAndImports3-amd.js b/tests/baselines/reference/exportsAndImports3-amd.js index cbf30735182..a6af4adb5f4 100644 --- a/tests/baselines/reference/exportsAndImports3-amd.js +++ b/tests/baselines/reference/exportsAndImports3-amd.js @@ -37,6 +37,7 @@ export { v, f, C, I, E, D, M, N, T, a }; //// [t1.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.v = 1; exports.v1 = exports.v; function f() { } @@ -66,6 +67,7 @@ define(["require", "exports"], function (require, exports) { //// [t2.js] define(["require", "exports", "./t1"], function (require, exports, t1_1) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.v = t1_1.v1; exports.f = t1_1.f1; exports.C = t1_1.C1; @@ -76,6 +78,7 @@ define(["require", "exports", "./t1"], function (require, exports, t1_1) { //// [t3.js] define(["require", "exports", "./t1"], function (require, exports, t1_1) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.v = t1_1.v1; exports.f = t1_1.f1; exports.C = t1_1.C1; diff --git a/tests/baselines/reference/exportsAndImports3-es6.js b/tests/baselines/reference/exportsAndImports3-es6.js index 85daa3f0f5c..1ac23446807 100644 --- a/tests/baselines/reference/exportsAndImports3-es6.js +++ b/tests/baselines/reference/exportsAndImports3-es6.js @@ -36,6 +36,7 @@ export { v, f, C, I, E, D, M, N, T, a }; //// [t1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.v = 1; exports.v1 = exports.v; function f() { } @@ -60,6 +61,7 @@ exports.a = M.x; exports.a1 = exports.a; //// [t2.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var t1_1 = require("./t1"); exports.v = t1_1.v1; exports.f = t1_1.f1; @@ -69,6 +71,7 @@ exports.M = t1_1.M1; exports.a = t1_1.a1; //// [t3.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); const t1_1 = require("./t1"); exports.v = t1_1.v1; exports.f = t1_1.f1; diff --git a/tests/baselines/reference/exportsAndImports3.js b/tests/baselines/reference/exportsAndImports3.js index dbcd9486215..4dfa0411946 100644 --- a/tests/baselines/reference/exportsAndImports3.js +++ b/tests/baselines/reference/exportsAndImports3.js @@ -36,6 +36,7 @@ export { v, f, C, I, E, D, M, N, T, a }; //// [t1.js] "use strict"; +exports.__esModule = true; exports.v = 1; exports.v1 = exports.v; function f() { } @@ -63,6 +64,7 @@ exports.a = M.x; exports.a1 = exports.a; //// [t2.js] "use strict"; +exports.__esModule = true; var t1_1 = require("./t1"); exports.v = t1_1.v1; exports.f = t1_1.f1; @@ -72,6 +74,7 @@ exports.M = t1_1.M1; exports.a = t1_1.a1; //// [t3.js] "use strict"; +exports.__esModule = true; var t1_1 = require("./t1"); exports.v = t1_1.v1; exports.f = t1_1.f1; diff --git a/tests/baselines/reference/exportsAndImports4-amd.js b/tests/baselines/reference/exportsAndImports4-amd.js index 3ed3f9bf910..ed31f42ebc7 100644 --- a/tests/baselines/reference/exportsAndImports4-amd.js +++ b/tests/baselines/reference/exportsAndImports4-amd.js @@ -48,6 +48,7 @@ define(["require", "exports"], function (require, exports) { //// [t3.js] define(["require", "exports", "./t1", "./t1", "./t1", "./t1", "./t1", "./t1"], function (require, exports, a, t1_1, c, t1_2, t1_3, t1_4) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); exports.a = a; a.default; exports.b = t1_1.default; diff --git a/tests/baselines/reference/exportsAndImports4-es6.js b/tests/baselines/reference/exportsAndImports4-es6.js index 8a8d4f81225..d8c51d03bb1 100644 --- a/tests/baselines/reference/exportsAndImports4-es6.js +++ b/tests/baselines/reference/exportsAndImports4-es6.js @@ -45,6 +45,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = "hello"; //// [t3.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); const a = require("./t1"); exports.a = a; a.default; diff --git a/tests/baselines/reference/exportsAndImports4.js b/tests/baselines/reference/exportsAndImports4.js index 361d1305bda..99f81a6b875 100644 --- a/tests/baselines/reference/exportsAndImports4.js +++ b/tests/baselines/reference/exportsAndImports4.js @@ -45,6 +45,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = "hello"; //// [t3.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var a = require("./t1"); exports.a = a; a.default; diff --git a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.js b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.js index fb6946ce928..068afdc346b 100644 --- a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.js +++ b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.js @@ -21,6 +21,7 @@ import { get } from "./t1"; //// [t1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var set = { set foo(x) { } @@ -30,7 +31,10 @@ var get = 10; exports.get = get; //// [t2.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); //// [t3.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); //// [t4.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js index 219916b3047..8b1deff064f 100644 --- a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js +++ b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js @@ -19,15 +19,19 @@ import { as } from "./t1"; //// [t1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var as = 100; exports.return = as; exports.as = as; //// [t2.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var as = require("./t1"); var x = as.as; var y = as.return; //// [t3.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); //// [t4.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/exportsAndImportsWithUnderscores1.js b/tests/baselines/reference/exportsAndImportsWithUnderscores1.js index d14eab3c251..207d2948fa4 100644 --- a/tests/baselines/reference/exportsAndImportsWithUnderscores1.js +++ b/tests/baselines/reference/exportsAndImportsWithUnderscores1.js @@ -16,8 +16,8 @@ const { __, _, ___ } = R; //// [m1.js] "use strict"; -var R; exports.__esModule = true; +var R; exports["default"] = R = { "__": 20, "_": 10, @@ -25,5 +25,6 @@ exports["default"] = R = { }; //// [m2.js] "use strict"; +exports.__esModule = true; var m1_1 = require("./m1"); var __ = m1_1["default"].__, _ = m1_1["default"]._, ___ = m1_1["default"].___; diff --git a/tests/baselines/reference/exportsAndImportsWithUnderscores2.js b/tests/baselines/reference/exportsAndImportsWithUnderscores2.js index 5d1dcbb9322..a53d4662e97 100644 --- a/tests/baselines/reference/exportsAndImportsWithUnderscores2.js +++ b/tests/baselines/reference/exportsAndImportsWithUnderscores2.js @@ -15,13 +15,14 @@ const { __esmodule, __proto__ } = R; //// [m1.js] "use strict"; -var R; exports.__esModule = true; +var R; exports["default"] = R = { "__esmodule": true, "__proto__": {} }; //// [m2.js] "use strict"; +exports.__esModule = true; var m1_1 = require("./m1"); var __esmodule = m1_1["default"].__esmodule, __proto__ = m1_1["default"].__proto__; diff --git a/tests/baselines/reference/exportsAndImportsWithUnderscores3.js b/tests/baselines/reference/exportsAndImportsWithUnderscores3.js index 477f870742d..3a5bba1deed 100644 --- a/tests/baselines/reference/exportsAndImportsWithUnderscores3.js +++ b/tests/baselines/reference/exportsAndImportsWithUnderscores3.js @@ -16,8 +16,8 @@ const { ___, ___hello, _hi } = R; //// [m1.js] "use strict"; -var R; exports.__esModule = true; +var R; exports["default"] = R = { "___": 30, "___hello": 21, @@ -25,5 +25,6 @@ exports["default"] = R = { }; //// [m2.js] "use strict"; +exports.__esModule = true; var m1_1 = require("./m1"); var ___ = m1_1["default"].___, ___hello = m1_1["default"].___hello, _hi = m1_1["default"]._hi; diff --git a/tests/baselines/reference/exportsAndImportsWithUnderscores4.js b/tests/baselines/reference/exportsAndImportsWithUnderscores4.js index 22cd7c2e71a..718d048b9a2 100644 --- a/tests/baselines/reference/exportsAndImportsWithUnderscores4.js +++ b/tests/baselines/reference/exportsAndImportsWithUnderscores4.js @@ -36,6 +36,7 @@ _hi(); //// [m1.js] "use strict"; +exports.__esModule = true; function _() { console.log("_"); } @@ -66,6 +67,7 @@ function ___hello() { exports.___hello = ___hello; //// [m2.js] "use strict"; +exports.__esModule = true; var m1_1 = require("./m1"); m1_1._(); m1_1.__(); diff --git a/tests/baselines/reference/extBaseClass1.js b/tests/baselines/reference/extBaseClass1.js index 91dfba7a9bf..6cf7b42962e 100644 --- a/tests/baselines/reference/extBaseClass1.js +++ b/tests/baselines/reference/extBaseClass1.js @@ -20,11 +20,16 @@ module N { //// [extBaseClass1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M; (function (M) { var B = (function () { @@ -37,7 +42,7 @@ var M; var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); @@ -47,7 +52,7 @@ var M; var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(M.B)); @@ -58,7 +63,7 @@ var N; var C3 = (function (_super) { __extends(C3, _super); function C3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C3; }(M.B)); diff --git a/tests/baselines/reference/extBaseClass2.js b/tests/baselines/reference/extBaseClass2.js index 3ab217eb019..7ef8adec3df 100644 --- a/tests/baselines/reference/extBaseClass2.js +++ b/tests/baselines/reference/extBaseClass2.js @@ -11,17 +11,22 @@ module M { //// [extBaseClass2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var N; (function (N) { var C4 = (function (_super) { __extends(C4, _super); function C4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C4; }(M.B)); @@ -32,7 +37,7 @@ var M; var C5 = (function (_super) { __extends(C5, _super); function C5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C5; }(B)); diff --git a/tests/baselines/reference/extendAndImplementTheSameBaseType.js b/tests/baselines/reference/extendAndImplementTheSameBaseType.js index 74bbf3a27ac..d2942220bf1 100644 --- a/tests/baselines/reference/extendAndImplementTheSameBaseType.js +++ b/tests/baselines/reference/extendAndImplementTheSameBaseType.js @@ -14,11 +14,16 @@ d.baz(); d.foo; //// [extendAndImplementTheSameBaseType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -28,7 +33,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.baz = function () { }; return D; diff --git a/tests/baselines/reference/extendAndImplementTheSameBaseType2.js b/tests/baselines/reference/extendAndImplementTheSameBaseType2.js index fa7963487d5..40b3425966e 100644 --- a/tests/baselines/reference/extendAndImplementTheSameBaseType2.js +++ b/tests/baselines/reference/extendAndImplementTheSameBaseType2.js @@ -17,11 +17,16 @@ var r3: string = d.bar(); var r4: number = d.bar(); //// [extendAndImplementTheSameBaseType2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -33,7 +38,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.baz = function () { }; return D; diff --git a/tests/baselines/reference/extendBaseClassBeforeItsDeclared.js b/tests/baselines/reference/extendBaseClassBeforeItsDeclared.js index 596ab319b2c..28c9ef2f22e 100644 --- a/tests/baselines/reference/extendBaseClassBeforeItsDeclared.js +++ b/tests/baselines/reference/extendBaseClassBeforeItsDeclared.js @@ -4,15 +4,20 @@ class derived extends base { } class base { constructor (public n: number) { } } //// [extendBaseClassBeforeItsDeclared.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var derived = (function (_super) { __extends(derived, _super); function derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return derived; }(base)); diff --git a/tests/baselines/reference/extendClassExpressionFromModule.js b/tests/baselines/reference/extendClassExpressionFromModule.js index 895cdedfaff..28c9488f7fa 100644 --- a/tests/baselines/reference/extendClassExpressionFromModule.js +++ b/tests/baselines/reference/extendClassExpressionFromModule.js @@ -21,17 +21,23 @@ var x = (function () { module.exports = x; //// [foo2.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var foo1 = require("./foo1"); var x = foo1; var y = (function (_super) { __extends(y, _super); function y() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return y; }(x)); diff --git a/tests/baselines/reference/extendConstructSignatureInInterface.js b/tests/baselines/reference/extendConstructSignatureInInterface.js index 4bf92dd0315..3067fdc706e 100644 --- a/tests/baselines/reference/extendConstructSignatureInInterface.js +++ b/tests/baselines/reference/extendConstructSignatureInInterface.js @@ -11,16 +11,21 @@ var e: E = new E(1); //// [extendConstructSignatureInInterface.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var CStatic; var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(CStatic)); diff --git a/tests/baselines/reference/extendNonClassSymbol1.js b/tests/baselines/reference/extendNonClassSymbol1.js index b23b601bc29..b4e59aa9711 100644 --- a/tests/baselines/reference/extendNonClassSymbol1.js +++ b/tests/baselines/reference/extendNonClassSymbol1.js @@ -4,11 +4,16 @@ var x = A; class C extends x { } // error, could not find symbol xs //// [extendNonClassSymbol1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -19,7 +24,7 @@ var x = A; var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(x)); // error, could not find symbol xs diff --git a/tests/baselines/reference/extendNonClassSymbol2.js b/tests/baselines/reference/extendNonClassSymbol2.js index 78dfaa91827..f029193175f 100644 --- a/tests/baselines/reference/extendNonClassSymbol2.js +++ b/tests/baselines/reference/extendNonClassSymbol2.js @@ -6,11 +6,16 @@ var x = new Foo(); // legal, considered a constructor function class C extends Foo {} // error, could not find symbol Foo //// [extendNonClassSymbol2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function Foo() { this.x = 1; } @@ -18,7 +23,7 @@ var x = new Foo(); // legal, considered a constructor function var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(Foo)); // error, could not find symbol Foo diff --git a/tests/baselines/reference/extendPrivateConstructorClass.js b/tests/baselines/reference/extendPrivateConstructorClass.js index 8893e9735ff..12540d9cd38 100644 --- a/tests/baselines/reference/extendPrivateConstructorClass.js +++ b/tests/baselines/reference/extendPrivateConstructorClass.js @@ -10,15 +10,20 @@ class C extends abc.XYZ { //// [extendPrivateConstructorClass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(abc.XYZ)); diff --git a/tests/baselines/reference/extendedInterfacesWithDuplicateTypeParameters.errors.txt b/tests/baselines/reference/extendedInterfacesWithDuplicateTypeParameters.errors.txt index 7b47fee05af..942ead52be3 100644 --- a/tests/baselines/reference/extendedInterfacesWithDuplicateTypeParameters.errors.txt +++ b/tests/baselines/reference/extendedInterfacesWithDuplicateTypeParameters.errors.txt @@ -1,9 +1,10 @@ tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts(1,42): error TS2300: Duplicate identifier 'A'. +tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts(5,11): error TS2428: All declarations of 'InterfaceWithSomeTypars' must have identical type parameters. tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts(9,11): error TS2428: All declarations of 'InterfaceWithSomeTypars' must have identical type parameters. tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts(9,38): error TS2300: Duplicate identifier 'C'. -==== tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts (3 errors) ==== +==== tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts (4 errors) ==== interface InterfaceWithMultipleTypars { // should error ~ !!! error TS2300: Duplicate identifier 'A'. @@ -11,6 +12,8 @@ tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts(9,38): err } interface InterfaceWithSomeTypars { // should not error + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2428: All declarations of 'InterfaceWithSomeTypars' must have identical type parameters. bar(): void; } diff --git a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js index da081154d8a..c8f7719faf0 100644 --- a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js +++ b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js @@ -34,6 +34,7 @@ var visModel = new moduleMap[moduleName].VisualizationModel(); //// [extendingClassFromAliasAndUsageInIndexer_backbone.js] "use strict"; +exports.__esModule = true; var Model = (function () { function Model() { } @@ -42,38 +43,51 @@ var Model = (function () { exports.Model = Model; //// [extendingClassFromAliasAndUsageInIndexer_moduleA.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); exports.VisualizationModel = VisualizationModel; //// [extendingClassFromAliasAndUsageInIndexer_moduleB.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return VisualizationModel; }(Backbone.Model)); exports.VisualizationModel = VisualizationModel; //// [extendingClassFromAliasAndUsageInIndexer_main.js] "use strict"; +exports.__esModule = true; var moduleA = require("./extendingClassFromAliasAndUsageInIndexer_moduleA"); var moduleB = require("./extendingClassFromAliasAndUsageInIndexer_moduleB"); var moduleATyped = moduleA; diff --git a/tests/baselines/reference/extendsClauseAlreadySeen.js b/tests/baselines/reference/extendsClauseAlreadySeen.js index 267cd86eed0..f6e43d5ddc6 100644 --- a/tests/baselines/reference/extendsClauseAlreadySeen.js +++ b/tests/baselines/reference/extendsClauseAlreadySeen.js @@ -7,11 +7,16 @@ class D extends C extends C { } //// [extendsClauseAlreadySeen.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -20,7 +25,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.baz = function () { }; return D; diff --git a/tests/baselines/reference/extendsClauseAlreadySeen2.js b/tests/baselines/reference/extendsClauseAlreadySeen2.js index 76fbc3365af..99bccf44479 100644 --- a/tests/baselines/reference/extendsClauseAlreadySeen2.js +++ b/tests/baselines/reference/extendsClauseAlreadySeen2.js @@ -7,11 +7,16 @@ class D extends C extends C { } //// [extendsClauseAlreadySeen2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -20,7 +25,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.baz = function () { }; return D; diff --git a/tests/baselines/reference/externalModuleAssignToVar.js b/tests/baselines/reference/externalModuleAssignToVar.js index 47958ddd2ff..70ce2281ad3 100644 --- a/tests/baselines/reference/externalModuleAssignToVar.js +++ b/tests/baselines/reference/externalModuleAssignToVar.js @@ -29,6 +29,7 @@ y3 = ext3; // ok //// [externalModuleAssignToVar_core_require.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var C = (function () { function C() { } @@ -59,6 +60,7 @@ define(["require", "exports"], function (require, exports) { //// [externalModuleAssignToVar_core.js] define(["require", "exports", "externalModuleAssignToVar_core_require", "externalModuleAssignToVar_core_require2", "externalModuleAssignToVar_ext"], function (require, exports, ext, ext2, ext3) { "use strict"; + exports.__esModule = true; var y1 = ext; y1 = ext; // ok var y2 = ext2; diff --git a/tests/baselines/reference/externalModuleExportingGenericClass.js b/tests/baselines/reference/externalModuleExportingGenericClass.js index e327e17160e..33aa1776e94 100644 --- a/tests/baselines/reference/externalModuleExportingGenericClass.js +++ b/tests/baselines/reference/externalModuleExportingGenericClass.js @@ -25,6 +25,7 @@ var C = (function () { module.exports = C; //// [externalModuleExportingGenericClass_file1.js] "use strict"; +exports.__esModule = true; var a = require("./externalModuleExportingGenericClass_file0"); var v; // this should report error var v2 = (new a()).foo; diff --git a/tests/baselines/reference/externalModuleImmutableBindings.js b/tests/baselines/reference/externalModuleImmutableBindings.js index b50845024f4..7e2a78a4728 100644 --- a/tests/baselines/reference/externalModuleImmutableBindings.js +++ b/tests/baselines/reference/externalModuleImmutableBindings.js @@ -53,9 +53,11 @@ for ((stuff[n]) of []) {} //// [f1.js] "use strict"; +exports.__esModule = true; exports.x = 1; //// [f2.js] "use strict"; +exports.__esModule = true; // all mutations below are illegal and should be fixed var stuff = require("./f1"); var n = 'baz'; diff --git a/tests/baselines/reference/externalModuleQualification.js b/tests/baselines/reference/externalModuleQualification.js index 26255ac3fcd..0402847a13a 100644 --- a/tests/baselines/reference/externalModuleQualification.js +++ b/tests/baselines/reference/externalModuleQualification.js @@ -13,6 +13,7 @@ class NavigateAction { //// [externalModuleQualification.js] "use strict"; +exports.__esModule = true; exports.ID = "test"; var DiffEditor = (function () { function DiffEditor(id) { diff --git a/tests/baselines/reference/externalModuleReferenceOfImportDeclarationWithExportModifier.js b/tests/baselines/reference/externalModuleReferenceOfImportDeclarationWithExportModifier.js index 8a25c3711b2..e5a854077c5 100644 --- a/tests/baselines/reference/externalModuleReferenceOfImportDeclarationWithExportModifier.js +++ b/tests/baselines/reference/externalModuleReferenceOfImportDeclarationWithExportModifier.js @@ -11,6 +11,7 @@ file1.foo(); //// [externalModuleReferenceOfImportDeclarationWithExportModifier_0.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; function foo() { } exports.foo = foo; ; @@ -18,6 +19,7 @@ define(["require", "exports"], function (require, exports) { //// [externalModuleReferenceOfImportDeclarationWithExportModifier_1.js] define(["require", "exports", "externalModuleReferenceOfImportDeclarationWithExportModifier_0"], function (require, exports, file1) { "use strict"; + exports.__esModule = true; exports.file1 = file1; exports.file1.foo(); }); diff --git a/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.js b/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.js index 5b0de7324ac..3a930d8e03a 100644 --- a/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.js +++ b/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.js @@ -20,11 +20,13 @@ file1.bar(); //// [externalModuleRefernceResolutionOrderInImportDeclaration_file2.js] //// [externalModuleRefernceResolutionOrderInImportDeclaration_file1.js] "use strict"; +exports.__esModule = true; function foo() { } exports.foo = foo; ; //// [externalModuleRefernceResolutionOrderInImportDeclaration_file3.js] "use strict"; +exports.__esModule = true; /// var file1 = require("./externalModuleRefernceResolutionOrderInImportDeclaration_file1"); file1.foo(); diff --git a/tests/baselines/reference/externalModuleResolution.js b/tests/baselines/reference/externalModuleResolution.js index 40b320ee37e..1ef5be53883 100644 --- a/tests/baselines/reference/externalModuleResolution.js +++ b/tests/baselines/reference/externalModuleResolution.js @@ -25,5 +25,6 @@ var M2; module.exports = M2; //// [consumer.js] "use strict"; +exports.__esModule = true; var x = require("./foo"); x.Y; // .ts should be picked diff --git a/tests/baselines/reference/externalModuleResolution2.js b/tests/baselines/reference/externalModuleResolution2.js index 44753c9f16d..2c3c9facff1 100644 --- a/tests/baselines/reference/externalModuleResolution2.js +++ b/tests/baselines/reference/externalModuleResolution2.js @@ -26,5 +26,6 @@ var M2; module.exports = M2; //// [consumer.js] "use strict"; +exports.__esModule = true; var x = require("./foo"); x.X; // .ts should be picked diff --git a/tests/baselines/reference/externalModuleWithoutCompilerFlag1.js b/tests/baselines/reference/externalModuleWithoutCompilerFlag1.js index 0b1f17612b0..fa98fbe2223 100644 --- a/tests/baselines/reference/externalModuleWithoutCompilerFlag1.js +++ b/tests/baselines/reference/externalModuleWithoutCompilerFlag1.js @@ -6,3 +6,4 @@ //// [externalModuleWithoutCompilerFlag1.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/fieldAndGetterWithSameName.js b/tests/baselines/reference/fieldAndGetterWithSameName.js index eb5171acd75..673a0372f05 100644 --- a/tests/baselines/reference/fieldAndGetterWithSameName.js +++ b/tests/baselines/reference/fieldAndGetterWithSameName.js @@ -7,6 +7,7 @@ export class C { //// [fieldAndGetterWithSameName.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var C = (function () { function C() { } diff --git a/tests/baselines/reference/filesEmittingIntoSameOutputWithOutOption.js b/tests/baselines/reference/filesEmittingIntoSameOutputWithOutOption.js index 0c6f1c8034d..9b48439ad56 100644 --- a/tests/baselines/reference/filesEmittingIntoSameOutputWithOutOption.js +++ b/tests/baselines/reference/filesEmittingIntoSameOutputWithOutOption.js @@ -12,6 +12,7 @@ function foo() { //// [a.js] define("a", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var c = (function () { function c() { } diff --git a/tests/baselines/reference/fixSignatureCaching.errors.txt b/tests/baselines/reference/fixSignatureCaching.errors.txt index 6677afc174a..7a5c43c966e 100644 --- a/tests/baselines/reference/fixSignatureCaching.errors.txt +++ b/tests/baselines/reference/fixSignatureCaching.errors.txt @@ -1,4 +1,3 @@ -tests/cases/conformance/fixSignatureCaching.ts(3,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/fixSignatureCaching.ts(9,10): error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. tests/cases/conformance/fixSignatureCaching.ts(284,10): error TS2339: Property 'detectMobileBrowsers' does not exist on type '{}'. tests/cases/conformance/fixSignatureCaching.ts(293,10): error TS2339: Property 'FALLBACK_PHONE' does not exist on type '{}'. @@ -62,7 +61,6 @@ tests/cases/conformance/fixSignatureCaching.ts(961,57): error TS2339: Property ' tests/cases/conformance/fixSignatureCaching.ts(964,22): error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. tests/cases/conformance/fixSignatureCaching.ts(968,18): error TS2339: Property '_impl' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. tests/cases/conformance/fixSignatureCaching.ts(970,18): error TS2339: Property 'version' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. -tests/cases/conformance/fixSignatureCaching.ts(974,4): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/fixSignatureCaching.ts(975,16): error TS2304: Cannot find name 'module'. tests/cases/conformance/fixSignatureCaching.ts(975,42): error TS2304: Cannot find name 'module'. tests/cases/conformance/fixSignatureCaching.ts(976,37): error TS2304: Cannot find name 'module'. @@ -73,2128 +71,1131 @@ tests/cases/conformance/fixSignatureCaching.ts(979,23): error TS2304: Cannot fin tests/cases/conformance/fixSignatureCaching.ts(980,37): error TS2304: Cannot find name 'window'. -==== tests/cases/conformance/fixSignatureCaching.ts (73 errors) ==== +==== tests/cases/conformance/fixSignatureCaching.ts (71 errors) ==== // Repro from #10697 (function (define, undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ define(function () { - ~~~~~~~~~~~~~~~~~~~~ 'use strict'; - ~~~~~~~~~~~~~~~~~ - var impl = {}; - ~~~~~~~~~~~~~~~~~~ - impl.mobileDetectRules = { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. "phones": { - ~~~~~~~~~~~~~~~ "iPhone": "\\biPhone\\b|\\biPod\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BlackBerry": "BlackBerry|\\bBB10\\b|rim[0-9]+", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "HTC": "HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\\bEVO\\b|T-Mobile G1|Z520m", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Nexus": "Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Dell": "Dell.*Streak|Dell.*Aero|Dell.*Venue|DELL.*Venue Pro|Dell Flash|Dell Smoke|Dell Mini 3iX|XCD28|XCD35|\\b001DL\\b|\\b101DL\\b|\\bGS01\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Motorola": "Motorola|DROIDX|DROID BIONIC|\\bDroid\\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925|XT1021|\\bMoto E\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Samsung": "Samsung|SM-G9250|GT-19300|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|SM-G900W8|SHV-E160K|SCH-P709|SCH-P729|SM-T2558|GT-I9205|SM-G9350|SM-J120F", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "LG": "\\bLG\\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|MS323)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Sony": "SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Asus": "Asus.*Galaxy|PadFone.*Mobile", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NokiaLumia": "Lumia [0-9]{3,4}", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Micromax": "Micromax.*\\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Palm": "PalmSource|Palm", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Vertu": "Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Pantech": "PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Fly": "IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Wiko": "KITE 4G|HIGHWAY|GETAWAY|STAIRWAY|DARKSIDE|DARKFULL|DARKNIGHT|DARKMOON|SLIDE|WAX 4G|RAINBOW|BLOOM|SUNSET|GOA(?!nna)|LENNY|BARRY|IGGY|OZZY|CINK FIVE|CINK PEAX|CINK PEAX 2|CINK SLIM|CINK SLIM 2|CINK +|CINK KING|CINK PEAX|CINK SLIM|SUBLIM", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iMobile": "i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SimValley": "\\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Wolfgang": "AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Alcatel": "Alcatel", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Nintendo": "Nintendo 3DS", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Amoi": "Amoi", - ~~~~~~~~~~~~~~~~~~~~~~~ "INQ": "INQ", - ~~~~~~~~~~~~~~~~~~~~~ "GenericPhone": "Tapatalk|PDA;|SAGEM|\\bmmp\\b|pocket|\\bpsp\\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\\bwap\\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~ "tablets": { - ~~~~~~~~~~~~~~~~ "iPad": "iPad|iPad.*Mobile", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NexusTablet": "Android.*Nexus[\\s]+(7|9|10)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SamsungTablet": "SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Kindle": "Kindle|Silk.*Accelerated|Android.*\\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SurfaceTablet": "Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "HPTablet": "HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AsusTablet": "^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\\bK00F\\b|\\bK00C\\b|\\bK00E\\b|\\bK00L\\b|TX201LA|ME176C|ME102A|\\bM80TA\\b|ME372CL|ME560CG|ME372CG|ME302KL| K010 | K017 |ME572C|ME103K|ME170C|ME171C|\\bME70C\\b|ME581C|ME581CL|ME8510C|ME181C|P01Y|PO1MA", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BlackBerryTablet": "PlayBook|RIM Tablet", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "HTCtablet": "HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MotorolaTablet": "xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NookTablet": "Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AcerTablet": "Android.*; \\b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\\b|W3-810|\\bA3-A10\\b|\\bA3-A11\\b|\\bA3-A20", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ToshibaTablet": "Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "LGTablet": "\\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "FujitsuTablet": "Android.*\\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PrestigioTablet": "PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "LenovoTablet": "Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DellTablet": "Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "YarvikTablet": "Android.*\\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MedionTablet": "Android.*\\bOYO\\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ArnovaTablet": "AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "IntensoTablet": "INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "IRUTablet": "M702pro", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MegafonTablet": "MegaFon V9|\\bZTE V9\\b|Android.*\\bMT7A\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "EbodaTablet": "E-Boda (Supreme|Impresspeed|Izzycomm|Essential)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AllViewTablet": "Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ArchosTablet": "\\b(101G9|80G9|A101IT)\\b|Qilive 97R|Archos5|\\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|)(G10| Cobalt| TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AinolTablet": "NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NokiaLumiaTablet": "Lumia 2520", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SonyTablet": "Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201|SGP351|SGP341|SGP511|SGP512|SGP521|SGP541|SGP551|SGP621|SGP612|SOT31", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PhilipsTablet": "\\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CubeTablet": "Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CobyTablet": "MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MIDTablet": "M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733|MID4X10", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MSITablet": "MSI \\b(Primo 73K|Primo 73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|Primo 91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SMiTTablet": "Android.*(\\bMID\\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "RockChipTablet": "Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "FlyTablet": "IQ310|Fly Vision", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "bqTablet": "Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris E10)|Maxwell.*Lite|Maxwell.*Plus", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "HuaweiTablet": "MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NecTablet": "\\bN-06D|\\bN-08D", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PantechTablet": "Pantech.*P4100", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BronchoTablet": "Broncho.*(N701|N708|N802|a710)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "VersusTablet": "TOUCHPAD.*[78910]|\\bTOUCHTAB\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ZyncTablet": "z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PositivoTablet": "TB07STA|TB10STA|TB07FTA|TB10FTA", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NabiTablet": "Android.*\\bNabi", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "KoboTablet": "Kobo Touch|\\bK080\\b|\\bVox\\b Build|\\bArc\\b Build", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DanewTablet": "DSlide.*\\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TexetTablet": "NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PlaystationTablet": "Playstation.*(Portable|Vita)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TrekstorTablet": "ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PyleAudioTablet": "\\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AdvanTablet": "Android.* \\b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\\b ", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DanyTechTablet": "Genius Tab G3|Genius Tab S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|Genius TAB GII|Genius TAB GIII|Genius Tab S1", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "GalapadTablet": "Android.*\\bG1\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MicromaxTablet": "Funbook|Micromax.*\\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "KarbonnTablet": "Android.*\\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AllFineTablet": "Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PROSCANTablet": "\\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "YONESTablet": "BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ChangJiaTablet": "TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "GUTablet": "TX-A1301|TX-M9002|Q702|kf026", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PointOfViewTablet": "TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "OvermaxTablet": "OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "HCLTablet": "HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DPSTablet": "DPS Dream 9|DPS Dual 7", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "VistureTablet": "V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CrestaTablet": "CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MediatekTablet": "\\bMT8125|MT8389|MT8135|MT8377\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ConcordeTablet": "Concorde([ ]+)?Tab|ConCorde ReadMan", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "GoCleverTablet": "GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ModecomTablet": "FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "VoninoTablet": "\\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\\bQ8\\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ECSTablet": "V07OT2|TM105A|S10OT1|TR10CS1", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "StorexTablet": "eZee[_']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "VodafoneTablet": "SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "EssentielBTablet": "Smart[ ']?TAB[ ]+?[0-9]+|Family[ ']?TAB2", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "RossMoorTablet": "RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iMobileTablet": "i-mobile i-note", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TolinoTablet": "tolino tab [0-9.]+|tolino shine", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AudioSonicTablet": "\\bC-22Q|T7-QC|T-17B|T-17P\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AMPETablet": "Android.* A78 ", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SkkTablet": "Android.* (SKYPAD|PHOENIX|CYCLOPS)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TecnoTablet": "TECNO P9", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "JXDTablet": "Android.* \\b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iJoyTablet": "Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "FX2Tablet": "FX2 PAD7|FX2 PAD10", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "XoroTablet": "KidsPAD 701|PAD[ ]?712|PAD[ ]?714|PAD[ ]?716|PAD[ ]?717|PAD[ ]?718|PAD[ ]?720|PAD[ ]?721|PAD[ ]?722|PAD[ ]?790|PAD[ ]?792|PAD[ ]?900|PAD[ ]?9715D|PAD[ ]?9716DR|PAD[ ]?9718DR|PAD[ ]?9719QR|PAD[ ]?9720QR|TelePAD1030|Telepad1032|TelePAD730|TelePAD731|TelePAD732|TelePAD735Q|TelePAD830|TelePAD9730|TelePAD795|MegaPAD 1331|MegaPAD 1851|MegaPAD 2151", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ViewsonicTablet": "ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "OdysTablet": "LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\\bXELIO\\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CaptivaTablet": "CAPTIVA PAD", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "IconbitTablet": "NetTAB|NT-3702|NT-3702S|NT-3702S|NT-3603P|NT-3603P|NT-0704S|NT-0704S|NT-3805C|NT-3805C|NT-0806C|NT-0806C|NT-0909T|NT-0909T|NT-0907S|NT-0907S|NT-0902S|NT-0902S", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TeclastTablet": "T98 4G|\\bP80\\b|\\bX90HD\\b|X98 Air|X98 Air 3G|\\bX89\\b|P80 3G|\\bX80h\\b|P98 Air|\\bX89HD\\b|P98 3G|\\bP90HD\\b|P89 3G|X98 3G|\\bP70h\\b|P79HD 3G|G18d 3G|\\bP79HD\\b|\\bP89s\\b|\\bA88\\b|\\bP10HD\\b|\\bP19HD\\b|G18 3G|\\bP78HD\\b|\\bA78\\b|\\bP75\\b|G17s 3G|G17h 3G|\\bP85t\\b|\\bP90\\b|\\bP11\\b|\\bP98t\\b|\\bP98HD\\b|\\bG18d\\b|\\bP85s\\b|\\bP11HD\\b|\\bP88s\\b|\\bA80HD\\b|\\bA80se\\b|\\bA10h\\b|\\bP89\\b|\\bP78s\\b|\\bG18\\b|\\bP85\\b|\\bA70h\\b|\\bA70\\b|\\bG17\\b|\\bP18\\b|\\bA80s\\b|\\bA11s\\b|\\bP88HD\\b|\\bA80h\\b|\\bP76s\\b|\\bP76h\\b|\\bP98\\b|\\bA10HD\\b|\\bP78\\b|\\bP88\\b|\\bA11\\b|\\bA10t\\b|\\bP76a\\b|\\bP76t\\b|\\bP76e\\b|\\bP85HD\\b|\\bP85a\\b|\\bP86\\b|\\bP75HD\\b|\\bP76v\\b|\\bA12\\b|\\bP75a\\b|\\bA15\\b|\\bP76Ti\\b|\\bP81HD\\b|\\bA10\\b|\\bT760VE\\b|\\bT720HD\\b|\\bP76\\b|\\bP73\\b|\\bP71\\b|\\bP72\\b|\\bT720SE\\b|\\bC520Ti\\b|\\bT760\\b|\\bT720VE\\b|T720-3GE|T720-WiFi", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "OndaTablet": "\\b(V975i|Vi30|VX530|V701|Vi60|V701s|Vi50|V801s|V719|Vx610w|VX610W|V819i|Vi10|VX580W|Vi10|V711s|V813|V811|V820w|V820|Vi20|V711|VI30W|V712|V891w|V972|V819w|V820w|Vi60|V820w|V711|V813s|V801|V819|V975s|V801|V819|V819|V818|V811|V712|V975m|V101w|V961w|V812|V818|V971|V971s|V919|V989|V116w|V102w|V973|Vi40)\\b[\\s]+", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "JaytechTablet": "TPC-PA762", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BlaupunktTablet": "Endeavour 800NG|Endeavour 1010", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DigmaTablet": "\\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "EvolioTablet": "ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\\bEvotab\\b|\\bNeura\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "LavaTablet": "QPAD E704|\\bIvoryS\\b|E-TAB IVORY|\\bE-TAB\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "AocTablet": "MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MpmanTablet": "MP11 OCTA|MP10 OCTA|MPQC1114|MPQC1004|MPQC994|MPQC974|MPQC973|MPQC804|MPQC784|MPQC780|\\bMPG7\\b|MPDCG75|MPDCG71|MPDC1006|MP101DC|MPDC9000|MPDC905|MPDC706HD|MPDC706|MPDC705|MPDC110|MPDC100|MPDC99|MPDC97|MPDC88|MPDC8|MPDC77|MP709|MID701|MID711|MID170|MPDC703|MPQC1010", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CelkonTablet": "CT695|CT888|CT[\\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\\bCT-1\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "WolderTablet": "miTab \\b(DIAMOND|SPACE|BROOKLYN|NEO|FLY|MANHATTAN|FUNK|EVOLUTION|SKY|GOCAR|IRON|GENIUS|POP|MINT|EPSILON|BROADWAY|JUMP|HOP|LEGEND|NEW AGE|LINE|ADVANCE|FEEL|FOLLOW|LIKE|LINK|LIVE|THINK|FREEDOM|CHICAGO|CLEVELAND|BALTIMORE-GH|IOWA|BOSTON|SEATTLE|PHOENIX|DALLAS|IN 101|MasterChef)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MiTablet": "\\bMI PAD\\b|\\bHM NOTE 1W\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NibiruTablet": "Nibiru M1|Nibiru Jupiter One", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NexoTablet": "NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "LeaderTablet": "TBLT10Q|TBLT10I|TBL-10WDKB|TBL-10WDKBO2013|TBL-W230V2|TBL-W450|TBL-W500|SV572|TBLT7I|TBA-AC7-8G|TBLT79|TBL-8W16|TBL-10W32|TBL-10WKB|TBL-W100", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "UbislateTablet": "UbiSlate[\\s]?7C", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PocketBookTablet": "Pocketbook", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "KocasoTablet": "\\b(TB-1207)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Hudl": "Hudl HT7S3|Hudl 2", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TelstraTablet": "T-Hub2", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "GenericTablet": "Android.*\\b97D\\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\\bA7EB\\b|CatNova8|A1_07|CT704|CT1002|\\bM721\\b|rk30sdk|\\bEVOTAB\\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\\bM6pro\\b|CT1020W|arc 10HD|\\bJolla\\b|\\bTP750\\b" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~ "oss": { - ~~~~~~~~~~~~ "AndroidOS": "Android", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BlackBerryOS": "blackberry|\\bBB10\\b|rim tablet os", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PalmOS": "PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "SymbianOS": "Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\\bS60\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "WindowsMobileOS": "Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "WindowsPhoneOS": "Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iOS": "\\biPhone.*Mobile|\\biPod|\\biPad", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MeeGoOS": "MeeGo", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MaemoOS": "Maemo", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "JavaOS": "J2ME\/|\\bMIDP\\b|\\bCLDC\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "webOS": "webOS|hpwOS", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "badaOS": "\\bBada\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BREWOS": "BREW" - ~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~ "uas": { - ~~~~~~~~~~~~ "Vivaldi": "Vivaldi", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Chrome": "\\bCrMo\\b|CriOS|Android.*Chrome\/[.0-9]* (Mobile)?", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Dolfin": "\\bDolfin\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Opera": "Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR\/[0-9.]+|Coast\/[0-9.]+", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Skyfire": "Skyfire", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Edge": "Mobile Safari\/[.0-9]* Edge", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "IE": "IEMobile|MSIEMobile", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Firefox": "fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Bolt": "bolt", - ~~~~~~~~~~~~~~~~~~~~~~~ "TeaShark": "teashark", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Blazer": "Blazer", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Safari": "Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Tizen": "Tizen", - ~~~~~~~~~~~~~~~~~~~~~~~~~ "UCBrowser": "UC.*Browser|UCWEB", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "baiduboxapp": "baiduboxapp", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "baidubrowser": "baidubrowser", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DiigoBrowser": "DiigoBrowser", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Puffin": "Puffin", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Mercury": "\\bMercury\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "ObigoBrowser": "Obigo", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NetFront": "NF-Browser", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "GenericBrowser": "NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PaleMoon": "Android.*PaleMoon|Mobile.*PaleMoon" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~ "props": { - ~~~~~~~~~~~~~~ "Mobile": "Mobile\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Build": "Build\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Version": "Version\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "VendorID": "VendorID\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iPad": "iPad.*CPU[a-z ]+[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iPhone": "iPhone.*CPU[a-z ]+[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iPod": "iPod.*CPU[a-z ]+[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Kindle": "Kindle\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Chrome": [ - ~~~~~~~~~~~~~~~~~~~ "Chrome\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CriOS\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "CrMo\/[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "Coast": [ - ~~~~~~~~~~~~~~~~~~ "Coast\/[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "Dolfin": "Dolfin\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Firefox": "Firefox\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Fennec": "Fennec\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Edge": "Edge\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "IE": [ - ~~~~~~~~~~~~~~~ "IEMobile\/[VER];", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "IEMobile [VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MSIE [VER];", - ~~~~~~~~~~~~~~~~~~~~~~~~~~ "Trident\/[0-9.]+;.*rv:[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "NetFront": "NetFront\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "NokiaBrowser": "NokiaBrowser\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Opera": [ - ~~~~~~~~~~~~~~~~~~ " OPR\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~ "Opera Mini\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Version\/[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "Opera Mini": "Opera Mini\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Opera Mobi": "Version\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "UC Browser": "UC Browser[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MQQBrowser": "MQQBrowser\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MicroMessenger": "MicroMessenger\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "baiduboxapp": "baiduboxapp\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "baidubrowser": "baidubrowser\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Iron": "Iron\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Safari": [ - ~~~~~~~~~~~~~~~~~~~ "Version\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Safari\/[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "Skyfire": "Skyfire\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Tizen": "Tizen\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Webkit": "webkit[ \/][VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "PaleMoon": "PaleMoon\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Gecko": "Gecko\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Trident": "Trident\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Presto": "Presto\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Goanna": "Goanna\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "iOS": " \\bi?OS\\b [VER][ ;]{1}", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Android": "Android [VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BlackBerry": [ - ~~~~~~~~~~~~~~~~~~~~~~~ "BlackBerry[\\w]+\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "BlackBerry.*Version\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Version\/[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "BREW": "BREW [VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Java": "Java\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Windows Phone OS": [ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Windows Phone OS [VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Windows Phone [VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "Windows Phone": "Windows Phone [VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Windows CE": "Windows CE\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Windows NT": "Windows NT [VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Symbian": [ - ~~~~~~~~~~~~~~~~~~~~ "SymbianOS\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Symbian\/[VER]" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ], - ~~~~~~~~~~ "webOS": [ - ~~~~~~~~~~~~~~~~~~ "webOS\/[VER]", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "hpwOS\/[VER];" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ] - ~~~~~~~~~ }, - ~~~~~~ "utils": { - ~~~~~~~~~~~~~~ "Bot": "Googlebot|facebookexternalhit|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "MobileBot": "Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker\/M1A1-R2D2", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "DesktopMode": "WPDesktop", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "TV": "SonyDTV|HbbTV", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "WebKit": "(webkit)[ \/]([\\w.]+)", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Console": "\\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\\b", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Watch": "SM-V700" - ~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ }; - ~~ - // following patterns come from http://detectmobilebrowsers.com/ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ impl.detectMobileBrowsers = { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'detectMobileBrowsers' does not exist on type '{}'. fullPattern: /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ shortPattern: /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tabletPattern: /android|ipad|playbook|silk/i - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~ - var hasOwnProp = Object.prototype.hasOwnProperty, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ isArray; - ~~~~~~~~~~~~~~~~ - impl.FALLBACK_PHONE = 'UnknownPhone'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_PHONE' does not exist on type '{}'. impl.FALLBACK_TABLET = 'UnknownTablet'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_TABLET' does not exist on type '{}'. impl.FALLBACK_MOBILE = 'UnknownMobile'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_MOBILE' does not exist on type '{}'. - isArray = ('isArray' in Array) ? - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Array.isArray : function (value) { return Object.prototype.toString.call(value) === '[object Array]'; }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - function equalIC(a, b) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return a != null && b != null && a.toLowerCase() === b.toLowerCase(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ - function containsIC(array, value) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var valueLC, i, len = array.length; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (!len || !value) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return false; - ~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ valueLC = value.toLowerCase(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (i = 0; i < len; ++i) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (valueLC === array[i].toLowerCase()) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return true; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } - ~~~~~~~~~ return false; - ~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ - function convertPropsToRegExp(object) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (var key in object) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (hasOwnProp.call(object, key)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ object[key] = new RegExp(object[key], 'i'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } - ~~~~~~~~~ } - ~~~~~ - (function init() { - ~~~~~~~~~~~~~~~~~~~~~~ var key, values, value, i, len, verPos, mobileDetectRules = impl.mobileDetectRules; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. for (key in mobileDetectRules.props) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (hasOwnProp.call(mobileDetectRules.props, key)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ values = mobileDetectRules.props[key]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (!isArray(values)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ values = [values]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~~~~~ len = values.length; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (i = 0; i < len; ++i) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value = values[i]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ verPos = value.indexOf('[VER]'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (verPos >= 0) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value = value.substring(0, verPos) + '([\\w._\\+]+)' + value.substring(verPos + 5); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~~~~~~~~~ values[i] = new RegExp(value, 'i'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~~~~~ mobileDetectRules.props[key] = values; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } - ~~~~~~~~~ convertPropsToRegExp(mobileDetectRules.oss); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ convertPropsToRegExp(mobileDetectRules.phones); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ convertPropsToRegExp(mobileDetectRules.tablets); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ convertPropsToRegExp(mobileDetectRules.uas); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ convertPropsToRegExp(mobileDetectRules.utils); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // copy some patterns to oss0 which are tested first (see issue#15) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mobileDetectRules.oss0 = { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WindowsPhoneOS: mobileDetectRules.oss.WindowsPhoneOS, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WindowsMobileOS: mobileDetectRules.oss.WindowsMobileOS - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~~~~~ }()); - ~~~~~~~~~ - /** - ~~~~~~~ * Test userAgent string against a set of rules and find the first matched key. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {Object} rules (key is String, value is RegExp) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {String} userAgent the navigator.userAgent (or HTTP-Header 'User-Agent'). - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @returns {String|null} the matched key if found, otherwise null - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @private - ~~~~~~~~~~~~~~~ */ - ~~~~~~~ impl.findMatch = function(rules, userAgent) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. for (var key in rules) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (hasOwnProp.call(rules, key)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (rules[key].test(userAgent)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return key; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } - ~~~~~~~~~ return null; - ~~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~ - /** - ~~~~~~~ * Test userAgent string against a set of rules and return an array of matched keys. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {Object} rules (key is String, value is RegExp) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {String} userAgent the navigator.userAgent (or HTTP-Header 'User-Agent'). - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @returns {Array} an array of matched keys, may be empty when there is no match, but not null - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @private - ~~~~~~~~~~~~~~~ */ - ~~~~~~~ impl.findMatches = function(rules, userAgent) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS2339: Property 'findMatches' does not exist on type '{}'. var result = []; - ~~~~~~~~~~~~~~~~~~~~~~~~ for (var key in rules) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (hasOwnProp.call(rules, key)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (rules[key].test(userAgent)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ result.push(key); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } - ~~~~~~~~~ return result; - ~~~~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~ - /** - ~~~~~~~ * Check the version of the given property in the User-Agent. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~ * @param {String} propertyName - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {String} userAgent - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @return {String} version or null if version not found - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @private - ~~~~~~~~~~~~~~~ */ - ~~~~~~~ impl.getVersionStr = function (propertyName, userAgent) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2339: Property 'getVersionStr' does not exist on type '{}'. var props = impl.mobileDetectRules.props, patterns, i, len, match; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. if (hasOwnProp.call(props, propertyName)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ patterns = props[propertyName]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ len = patterns.length; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (i = 0; i < len; ++i) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ match = patterns[i].exec(userAgent); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (match !== null) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return match[1]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } - ~~~~~~~~~ return null; - ~~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~ - /** - ~~~~~~~ * Check the version of the given property in the User-Agent. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~ * @param {String} propertyName - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {String} userAgent - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @return {Number} version or NaN if version not found - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @private - ~~~~~~~~~~~~~~~ */ - ~~~~~~~ impl.getVersion = function (propertyName, userAgent) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ !!! error TS2339: Property 'getVersion' does not exist on type '{}'. var version = impl.getVersionStr(propertyName, userAgent); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2339: Property 'getVersionStr' does not exist on type '{}'. return version ? impl.prepareVersionNo(version) : NaN; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareVersionNo' does not exist on type '{}'. }; - ~~~~~~ - /** - ~~~~~~~ * Prepare the version number. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~ * @param {String} version - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @return {Number} the version number as a floating number - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @private - ~~~~~~~~~~~~~~~ */ - ~~~~~~~ impl.prepareVersionNo = function (version) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareVersionNo' does not exist on type '{}'. var numbers; - ~~~~~~~~~~~~~~~~~~~~ - numbers = version.split(/[a-z._ \/\-]/i); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (numbers.length === 1) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ version = numbers[0]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ if (numbers.length > 1) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ version = numbers[0] + '.'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ numbers.shift(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ version += numbers.join(''); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ return Number(version); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~ - impl.isMobileFallback = function (userAgent) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'isMobileFallback' does not exist on type '{}'. return impl.detectMobileBrowsers.fullPattern.test(userAgent) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'detectMobileBrowsers' does not exist on type '{}'. impl.detectMobileBrowsers.shortPattern.test(userAgent.substr(0,4)); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'detectMobileBrowsers' does not exist on type '{}'. }; - ~~~~~~ - impl.isTabletFallback = function (userAgent) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'isTabletFallback' does not exist on type '{}'. return impl.detectMobileBrowsers.tabletPattern.test(userAgent); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'detectMobileBrowsers' does not exist on type '{}'. }; - ~~~~~~ - impl.prepareDetectionCache = function (cache, userAgent, maxPhoneWidth) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. if (cache.mobile !== undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return; - ~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ var phone, tablet, phoneSized; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // first check for stronger tablet rules, then phone (see issue#5) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tablet = impl.findMatch(impl.mobileDetectRules.tablets, userAgent); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. if (tablet) { - ~~~~~~~~~~~~~~~~~~~~~ cache.mobile = cache.tablet = tablet; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cache.phone = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return; // unambiguously identified as tablet - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ - phone = impl.findMatch(impl.mobileDetectRules.phones, userAgent); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. if (phone) { - ~~~~~~~~~~~~~~~~~~~~ cache.mobile = cache.phone = phone; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cache.tablet = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return; // unambiguously identified as phone - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ - // our rules haven't found a match -> try more general fallback rules - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (impl.isMobileFallback(userAgent)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'isMobileFallback' does not exist on type '{}'. phoneSized = MobileDetect.isPhoneSized(maxPhoneWidth); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ !!! error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. if (phoneSized === undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cache.mobile = impl.FALLBACK_MOBILE; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_MOBILE' does not exist on type '{}'. cache.tablet = cache.phone = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else if (phoneSized) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cache.mobile = cache.phone = impl.FALLBACK_PHONE; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_PHONE' does not exist on type '{}'. cache.tablet = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else { - ~~~~~~~~~~~~~~~~~~~~ cache.mobile = cache.tablet = impl.FALLBACK_TABLET; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_TABLET' does not exist on type '{}'. cache.phone = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ } else if (impl.isTabletFallback(userAgent)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'isTabletFallback' does not exist on type '{}'. cache.mobile = cache.tablet = impl.FALLBACK_TABLET; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ !!! error TS2339: Property 'FALLBACK_TABLET' does not exist on type '{}'. cache.phone = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else { - ~~~~~~~~~~~~~~~~ // not mobile at all! - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cache.mobile = cache.tablet = cache.phone = null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ }; - ~~~~~~ - // t is a reference to a MobileDetect instance - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ impl.mobileGrade = function (t) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS2339: Property 'mobileGrade' does not exist on type '{}'. // impl note: - ~~~~~~~~~~~~~~~~~~~~~ // To keep in sync w/ Mobile_Detect.php easily, the following code is tightly aligned to the PHP version. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // When changes are made in Mobile_Detect.php, copy this method and replace: - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // $this-> / t. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ // self::MOBILE_GRADE_(.) / '$1' - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // , self::VERSION_TYPE_FLOAT / (nothing) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // isIOS() / os('iOS') - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // [reg] / (nothing) <-- jsdelivr complaining about unescaped unicode character U+00AE - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var $isMobile = t.mobile() !== null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - if ( - ~~~~~~~~~~~~ // Apple iOS 3.2-5.1 - Tested on the original iPad (4.3 / 5.0), iPad 2 (4.3), iPad 3 (5.1), original iPhone (3.1), iPhone 3 (3.2), 3GS (4.3), 4 (4.3 / 5.0), and 4S (5.1) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.os('iOS') && t.version('iPad')>=4.3 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.os('iOS') && t.version('iPhone')>=3.1 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.os('iOS') && t.version('iPod')>=3.1 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Android 2.1-2.3 - Tested on the HTC Incredible (2.2), original Droid (2.2), HTC Aria (2.1), Google Nexus S (2.3). Functional on 1.5 & 1.6 but performance may be sluggish, tested on Google G1 (1.5) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.version('Android')>2.1 && t.is('Webkit') ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Windows Phone 7-7.5 - Tested on the HTC Surround (7.0) HTC Trophy (7.5), LG-E900 (7.5), Nokia Lumia 800 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('Windows Phone OS')>=7.0 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Blackberry 7 - Tested on BlackBerry Torch 9810 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Blackberry 6.0 - Tested on the Torch 9800 and Style 9670 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('BlackBerry') && t.version('BlackBerry')>=6.0 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Blackberry Playbook (1.0-2.0) - Tested on PlayBook - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.match('Playbook.*Tablet') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Palm WebOS (1.4-2.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.version('webOS')>=1.4 && t.match('Palm|Pre|Pixi') ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Palm WebOS 3.0 - Tested on HP TouchPad - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.match('hp.*TouchPad') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Firefox Mobile (12 Beta) - Tested on Android 2.3 device - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.is('Firefox') && t.version('Firefox')>=12 ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Chrome for Android - Tested on Android 4.0, 4.1 device - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.is('Chrome') && t.is('AndroidOS') && t.version('Android')>=4.0 ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Skyfire 4.1 - Tested on Android 2.3 device - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.is('Skyfire') && t.version('Skyfire')>=4.1 && t.is('AndroidOS') && t.version('Android')>=2.3 ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Opera Mobile 11.5-12: Tested on Android 2.3 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.is('Opera') && t.version('Opera Mobi')>11 && t.is('AndroidOS') ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Meego 1.2 - Tested on Nokia 950 and N9 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('MeeGoOS') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Tizen (pre-release) - Tested on early hardware - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('Tizen') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @todo: more tests here! - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('Dolfin') && t.version('Bada')>=2.0 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // UC Browser - Tested on Android 2.3 device - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( (t.is('UC Browser') || t.is('Dolfin')) && t.version('Android')>=2.3 ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Kindle 3 and Fire - Tested on the built-in WebKit browser for each - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.match('Kindle Fire') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('Kindle') && t.version('Kindle')>=3.0 ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('AndroidOS') && t.is('NookTablet') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Chrome Desktop 11-21 - Tested on OS X 10.7 and Windows 7 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('Chrome')>=11 && !$isMobile || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Safari Desktop 4-5 - Tested on OS X 10.7 and Windows 7 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('Safari')>=5.0 && !$isMobile || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Firefox Desktop 4-13 - Tested on OS X 10.7 and Windows 7 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('Firefox')>=4.0 && !$isMobile || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('MSIE')>=7.0 && !$isMobile || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @reference: http://my.opera.com/community/openweb/idopera/ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('Opera')>=10 && !$isMobile - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ){ - ~~~~~~~~~~~~~~ return 'A'; - ~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ - if ( - ~~~~~~~~~~~~ t.os('iOS') && t.version('iPad')<4.3 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.os('iOS') && t.version('iPhone')<3.1 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.os('iOS') && t.version('iPod')<3.1 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.is('Blackberry') && t.version('BlackBerry')>=5 && t.version('BlackBerry')<6 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ( t.version('Opera Mini')>=5.0 && t.version('Opera Mini')<=6.5 && - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (t.version('Android')>=2.3 || t.is('iOS')) ) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // @todo: report this (tested on Nokia N71) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('Opera Mobi')>=11 && t.is('SymbianOS') - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ){ - ~~~~~~~~~~~~~~ return 'B'; - ~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ - if ( - ~~~~~~~~~~~~ // Blackberry 4.x - Tested on the Curve 8330 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.version('BlackBerry')<5.0 || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Windows Mobile - Tested on the HTC Leo (WinMo 5.2) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.match('MSIEMobile|Windows CE.*Mobile') || t.version('Windows Mobile')<=5.2 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ){ - ~~~~~~~~~~~~~~ return 'C'; - ~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ - //All older smartphone platforms and featurephones - Any device that doesn't support media queries - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //will receive the basic, C grade experience. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return 'C'; - ~~~~~~~~~~~~~~~~~~~ }; - ~~~~~~ - impl.detectOS = function (ua) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ !!! error TS2339: Property 'detectOS' does not exist on type '{}'. return impl.findMatch(impl.mobileDetectRules.oss0, ua) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. impl.findMatch(impl.mobileDetectRules.oss, ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. }; - ~~~~~~ - impl.getDeviceSmallerSide = function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'getDeviceSmallerSide' does not exist on type '{}'. return window.screen.width < window.screen.height ? - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'window'. ~~~~~~ !!! error TS2304: Cannot find name 'window'. window.screen.width : - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'window'. window.screen.height; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'window'. }; - ~~~~~~ - /** - ~~~~~~~ * Constructor for MobileDetect object. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~ * Such an object will keep a reference to the given user-agent string and cache most of the detect queries.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Find information how to download and install: - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * github.com/hgoebl/mobile-detect.js/ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~ * - ~~~~~~ * @example
-    ~~~~~~~~~~~~~~~~~~~~~
          *     var md = new MobileDetect(window.navigator.userAgent);
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          *     if (md.mobile()) {
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          *         location.href = (md.mobileGrade() === 'A') ? '/mobile/' : '/lynx/';
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          *     }
-    ~~~~~~~~~~~~
          * 
- ~~~~~~~~~~~~~ * - ~~~~~~ * @param {string} userAgent typically taken from window.navigator.userAgent or http_header['User-Agent'] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {number} [maxPhoneWidth=600] only for browsers specify a value for the maximum - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * width of smallest device side (in logical "CSS" pixels) until a device detected as mobile will be handled - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * as phone. - ~~~~~~~~~~~~~~~~~~~~~~~ * This is only used in cases where the device cannot be classified as phone or tablet.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * See Declaring Tablet Layouts - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * for Android.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * If you provide a value < 0, then this "fuzzy" check is disabled. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @constructor - ~~~~~~~~~~~~~~~~~~~ * @global - ~~~~~~~~~~~~~~ */ - ~~~~~~~ function MobileDetect(userAgent, maxPhoneWidth) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this.ua = userAgent || ''; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this._cache = {}; - ~~~~~~~~~~~~~~~~~~~~~~~~~ //600dp is typical 7" tablet minimum width - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this.maxPhoneWidth = maxPhoneWidth || 600; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ - MobileDetect.prototype = { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ constructor: MobileDetect, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns the detected phone or tablet type or null if it is not a mobile device. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * For a list of possible return values see {@link MobileDetect#phone} and {@link MobileDetect#tablet}.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * If the device is not detected by the regular expressions from Mobile-Detect, a test is made against - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * the patterns of detectmobilebrowsers.com. If this test - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * is positive, a value of UnknownPhone, UnknownTablet or - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * UnknownMobile is returned.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * When used in browser, the decision whether phone or tablet is made based on screen.width/height.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * When used server-side (node.js), there is no way to tell the difference between UnknownTablet - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * and UnknownMobile, so you will get UnknownMobile here.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Be aware that since v1.0.0 in this special case you will get UnknownMobile only for: - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * {@link MobileDetect#mobile}, not for {@link MobileDetect#phone} and {@link MobileDetect#tablet}. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * In versions before v1.0.0 all 3 methods returned UnknownMobile which was tedious to use. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * In most cases you will use the return value just as a boolean. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} the key for the phone family or tablet family, e.g. "Nexus". - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#mobile - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ mobile: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ impl.prepareDetectionCache(this._cache, this.ua, this.maxPhoneWidth); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. return this._cache.mobile; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns the detected phone type/family string or null. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * The returned tablet (family or producer) is one of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
iPhone, BlackBerry, HTC, Nexus, Dell, Motorola, Samsung, LG, Sony, Asus, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * NokiaLumia, Micromax, Palm, Vertu, Pantech, Fly, Wiko, iMobile, SimValley, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Wolfgang, Alcatel, Nintendo, Amoi, INQ, GenericPhone
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * If the device is not detected by the regular expressions from Mobile-Detect, a test is made against - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * the patterns of detectmobilebrowsers.com. If this test - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * is positive, a value of UnknownPhone or UnknownMobile is returned.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * When used in browser, the decision whether phone or tablet is made based on screen.width/height.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * When used server-side (node.js), there is no way to tell the difference between UnknownTablet - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * and UnknownMobile, so you will get null here, while {@link MobileDetect#mobile} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * will return UnknownMobile.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Be aware that since v1.0.0 in this special case you will get UnknownMobile only for: - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * {@link MobileDetect#mobile}, not for {@link MobileDetect#phone} and {@link MobileDetect#tablet}. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * In versions before v1.0.0 all 3 methods returned UnknownMobile which was tedious to use. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * In most cases you will use the return value just as a boolean. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} the key of the phone family or producer, e.g. "iPhone" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#phone - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ phone: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ impl.prepareDetectionCache(this._cache, this.ua, this.maxPhoneWidth); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. return this._cache.phone; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns the detected tablet type/family string or null. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * The returned tablet (family or producer) is one of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
iPad, NexusTablet, SamsungTablet, Kindle, SurfaceTablet, HPTablet, AsusTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * BlackBerryTablet, HTCtablet, MotorolaTablet, NookTablet, AcerTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * ToshibaTablet, LGTablet, FujitsuTablet, PrestigioTablet, LenovoTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * DellTablet, YarvikTablet, MedionTablet, ArnovaTablet, IntensoTablet, IRUTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * MegafonTablet, EbodaTablet, AllViewTablet, ArchosTablet, AinolTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * NokiaLumiaTablet, SonyTablet, PhilipsTablet, CubeTablet, CobyTablet, MIDTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * MSITablet, SMiTTablet, RockChipTablet, FlyTablet, bqTablet, HuaweiTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * NecTablet, PantechTablet, BronchoTablet, VersusTablet, ZyncTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * PositivoTablet, NabiTablet, KoboTablet, DanewTablet, TexetTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * PlaystationTablet, TrekstorTablet, PyleAudioTablet, AdvanTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * DanyTechTablet, GalapadTablet, MicromaxTablet, KarbonnTablet, AllFineTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * PROSCANTablet, YONESTablet, ChangJiaTablet, GUTablet, PointOfViewTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * OvermaxTablet, HCLTablet, DPSTablet, VistureTablet, CrestaTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * MediatekTablet, ConcordeTablet, GoCleverTablet, ModecomTablet, VoninoTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * ECSTablet, StorexTablet, VodafoneTablet, EssentielBTablet, RossMoorTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * iMobileTablet, TolinoTablet, AudioSonicTablet, AMPETablet, SkkTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * TecnoTablet, JXDTablet, iJoyTablet, FX2Tablet, XoroTablet, ViewsonicTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * OdysTablet, CaptivaTablet, IconbitTablet, TeclastTablet, OndaTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * JaytechTablet, BlaupunktTablet, DigmaTablet, EvolioTablet, LavaTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * AocTablet, MpmanTablet, CelkonTablet, WolderTablet, MiTablet, NibiruTablet, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * NexoTablet, LeaderTablet, UbislateTablet, PocketBookTablet, KocasoTablet, Hudl, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * TelstraTablet, GenericTablet
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * If the device is not detected by the regular expressions from Mobile-Detect, a test is made against - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * the patterns of detectmobilebrowsers.com. If this test - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * is positive, a value of UnknownTablet or UnknownMobile is returned.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * When used in browser, the decision whether phone or tablet is made based on screen.width/height.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * When used server-side (node.js), there is no way to tell the difference between UnknownTablet - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * and UnknownMobile, so you will get null here, while {@link MobileDetect#mobile} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * will return UnknownMobile.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Be aware that since v1.0.0 in this special case you will get UnknownMobile only for: - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * {@link MobileDetect#mobile}, not for {@link MobileDetect#phone} and {@link MobileDetect#tablet}. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * In versions before v1.0.0 all 3 methods returned UnknownMobile which was tedious to use. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * In most cases you will use the return value just as a boolean. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} the key of the tablet family or producer, e.g. "SamsungTablet" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#tablet - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ tablet: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ impl.prepareDetectionCache(this._cache, this.ua, this.maxPhoneWidth); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'prepareDetectionCache' does not exist on type '{}'. return this._cache.tablet; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns the (first) detected user-agent string or null. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * The returned user-agent is one of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
Vivaldi, Chrome, Dolfin, Opera, Skyfire, Edge, IE, Firefox, Bolt, TeaShark, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Blazer, Safari, Tizen, UCBrowser, baiduboxapp, baidubrowser, DiigoBrowser, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Puffin, Mercury, ObigoBrowser, NetFront, GenericBrowser, PaleMoon
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * In most cases calling {@link MobileDetect#userAgent} will be sufficient. But there are rare - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * cases where a mobile device pretends to be more than one particular browser. You can get the - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * list of all matches with {@link MobileDetect#userAgents} or check for a particular value by - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * providing one of the defined keys as first argument to {@link MobileDetect#is}. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} the key for the detected user-agent or null - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#userAgent - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ userAgent: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this._cache.userAgent === undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this._cache.userAgent = impl.findMatch(impl.mobileDetectRules.uas, this.ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2339: Property 'findMatch' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. } - ~~~~~~~~~~~~~ return this._cache.userAgent; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns all detected user-agent strings. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * The array is empty or contains one or more of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
Vivaldi, Chrome, Dolfin, Opera, Skyfire, Edge, IE, Firefox, Bolt, TeaShark, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Blazer, Safari, Tizen, UCBrowser, baiduboxapp, baidubrowser, DiigoBrowser, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Puffin, Mercury, ObigoBrowser, NetFront, GenericBrowser, PaleMoon
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * In most cases calling {@link MobileDetect#userAgent} will be sufficient. But there are rare - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * cases where a mobile device pretends to be more than one particular browser. You can get the - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * list of all matches with {@link MobileDetect#userAgents} or check for a particular value by - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * providing one of the defined keys as first argument to {@link MobileDetect#is}. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {Array} the array of detected user-agent keys or [] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#userAgents - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ userAgents: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this._cache.userAgents === undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this._cache.userAgents = impl.findMatches(impl.mobileDetectRules.uas, this.ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS2339: Property 'findMatches' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. } - ~~~~~~~~~~~~~ return this._cache.userAgents; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns the detected operating system string or null. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * The operating system is one of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
AndroidOS, BlackBerryOS, PalmOS, SymbianOS, WindowsMobileOS, WindowsPhoneOS, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * iOS, MeeGoOS, MaemoOS, JavaOS, webOS, badaOS, BREWOS
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} the key for the detected operating system. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#os - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ os: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~ if (this._cache.os === undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this._cache.os = impl.detectOS(this.ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ !!! error TS2339: Property 'detectOS' does not exist on type '{}'. } - ~~~~~~~~~~~~~ return this._cache.os; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Get the version (as Number) of the given property in the User-Agent. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @param {String} key a key defining a thing which has a version.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * You can use one of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
Mobile, Build, Version, VendorID, iPad, iPhone, iPod, Kindle, Chrome, Coast, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Dolfin, Firefox, Fennec, Edge, IE, NetFront, NokiaBrowser, Opera, Opera Mini, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Opera Mobi, UC Browser, MQQBrowser, MicroMessenger, baiduboxapp, baidubrowser, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Iron, Safari, Skyfire, Tizen, Webkit, PaleMoon, Gecko, Trident, Presto, Goanna, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * iOS, Android, BlackBerry, BREW, Java, Windows Phone OS, Windows Phone, Windows - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * CE, Windows NT, Symbian, webOS
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {Number} the version as float or NaN if User-Agent doesn't contain this version. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Be careful when comparing this value with '==' operator! - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#version - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ version: function (key) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return impl.getVersion(key, this.ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ !!! error TS2339: Property 'getVersion' does not exist on type '{}'. }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Get the version (as String) of the given property in the User-Agent. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @param {String} key a key defining a thing which has a version.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * You can use one of following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
Mobile, Build, Version, VendorID, iPad, iPhone, iPod, Kindle, Chrome, Coast, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Dolfin, Firefox, Fennec, Edge, IE, NetFront, NokiaBrowser, Opera, Opera Mini, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Opera Mobi, UC Browser, MQQBrowser, MicroMessenger, baiduboxapp, baidubrowser, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Iron, Safari, Skyfire, Tizen, Webkit, PaleMoon, Gecko, Trident, Presto, Goanna, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * iOS, Android, BlackBerry, BREW, Java, Windows Phone OS, Windows Phone, Windows - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * CE, Windows NT, Symbian, webOS
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} the "raw" version as String or null if User-Agent doesn't contain this version. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @function MobileDetect#versionStr - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ versionStr: function (key) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return impl.getVersionStr(key, this.ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ !!! error TS2339: Property 'getVersionStr' does not exist on type '{}'. }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Global test key against userAgent, os, phone, tablet and some other properties of userAgent string. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @param {String} key the key (case-insensitive) of a userAgent, an operating system, phone or - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * tablet family.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * For a complete list of possible values, see {@link MobileDetect#userAgent}, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * {@link MobileDetect#os}, {@link MobileDetect#phone}, {@link MobileDetect#tablet}.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Additionally you have following keys:
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
Bot, MobileBot, DesktopMode, TV, WebKit, Console, Watch
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {boolean} true when the given key is one of the defined keys of userAgent, os, phone, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * tablet or one of the listed additional keys, otherwise false - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#is - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ is: function (key) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return containsIC(this.userAgents(), key) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ equalIC(key, this.os()) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ equalIC(key, this.phone()) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ equalIC(key, this.tablet()) || - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ containsIC(impl.findMatches(impl.mobileDetectRules.utils, this.ua), key); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS2339: Property 'findMatches' does not exist on type '{}'. ~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'mobileDetectRules' does not exist on type '{}'. }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Do a quick test against navigator::userAgent. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @param {String|RegExp} pattern the pattern, either as String or RegExp - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * (a string will be converted to a case-insensitive RegExp). - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @returns {boolean} true when the pattern matches, otherwise false - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#match - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ match: function (pattern) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (!(pattern instanceof RegExp)) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pattern = new RegExp(pattern, 'i'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~~~~~ return pattern.test(this.ua); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Checks whether the mobile device can be considered as phone regarding screen.width. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
- ~~~~~~~~~~~~~~~ * Obviously this method makes sense in browser environments only (not for Node.js)! - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {number} [maxPhoneWidth] the maximum logical pixels (aka. CSS-pixels) to be considered as phone.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * The argument is optional and if not present or falsy, the value of the constructor is taken. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @returns {boolean|undefined} undefined if screen size wasn't detectable, else true - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * when screen.width is less or equal to maxPhoneWidth, otherwise false.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Will always return undefined server-side. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ isPhoneSized: function (maxPhoneWidth) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return MobileDetect.isPhoneSized(maxPhoneWidth || this.maxPhoneWidth); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ !!! error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. }, - ~~~~~~~~~~ - /** - ~~~~~~~~~~~ * Returns the mobile grade ('A', 'B', 'C'). - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - ~~~~~~~~~~ * @returns {String} one of the mobile grades ('A', 'B', 'C'). - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @function MobileDetect#mobileGrade - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~~~~~ mobileGrade: function () { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this._cache.grade === undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this._cache.grade = impl.mobileGrade(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS2339: Property 'mobileGrade' does not exist on type '{}'. } - ~~~~~~~~~~~~~ return this._cache.grade; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ }; - ~~~~~~ - // environment-dependent - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (typeof window !== 'undefined' && window.screen) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'window'. ~~~~~~ !!! error TS2304: Cannot find name 'window'. MobileDetect.isPhoneSized = function (maxPhoneWidth) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ !!! error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. return maxPhoneWidth < 0 ? undefined : impl.getDeviceSmallerSide() <= maxPhoneWidth; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'getDeviceSmallerSide' does not exist on type '{}'. }; - ~~~~~~~~~~ } else { - ~~~~~~~~~~~~ MobileDetect.isPhoneSized = function () {}; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ !!! error TS2339: Property 'isPhoneSized' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. } - ~~~~~ - // should not be replaced by a completely new object - just overwrite existing methods - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MobileDetect._impl = impl; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ !!! error TS2339: Property '_impl' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. - ~~~~ MobileDetect.version = '1.3.3 2016-07-31'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~ !!! error TS2339: Property 'version' does not exist on type '(userAgent: any, maxPhoneWidth: any) => void'. - return MobileDetect; - ~~~~~~~~~~~~~~~~~~~~~~~~ }); // end of call of define() - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ })((function (undefined) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~ if (typeof module !== 'undefined' && module.exports) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'module'. ~~~~~~ !!! error TS2304: Cannot find name 'module'. return function (factory) { module.exports = factory(); }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'module'. } else if (typeof define === 'function' && define.amd) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'define'. ~~~~~~ !!! error TS2304: Cannot find name 'define'. return define; - ~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'define'. } else if (typeof window !== 'undefined') { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'window'. return function (factory) { window.MobileDetect = factory(); }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ !!! error TS2304: Cannot find name 'window'. } else { - ~~~~~~~~~~~~ - ~~~~~~~~~~~~ // please file a bug if you get this error! - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ throw new Error('unknown environment'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ - ~~~~~ - })()); - ~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. - ~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file + })()); \ No newline at end of file diff --git a/tests/baselines/reference/flowAfterFinally1.js b/tests/baselines/reference/flowAfterFinally1.js new file mode 100644 index 00000000000..93f3425d506 --- /dev/null +++ b/tests/baselines/reference/flowAfterFinally1.js @@ -0,0 +1,25 @@ +//// [flowAfterFinally1.ts] +declare function openFile(): void +declare function closeFile(): void +declare function someOperation(): {} + +var result: {} +openFile() +try { + result = someOperation() +} finally { + closeFile() +} + +result // should not error here + +//// [flowAfterFinally1.js] +var result; +openFile(); +try { + result = someOperation(); +} +finally { + closeFile(); +} +result; // should not error here diff --git a/tests/baselines/reference/flowAfterFinally1.symbols b/tests/baselines/reference/flowAfterFinally1.symbols new file mode 100644 index 00000000000..ad0ffbeb5cf --- /dev/null +++ b/tests/baselines/reference/flowAfterFinally1.symbols @@ -0,0 +1,29 @@ +=== tests/cases/compiler/flowAfterFinally1.ts === +declare function openFile(): void +>openFile : Symbol(openFile, Decl(flowAfterFinally1.ts, 0, 0)) + +declare function closeFile(): void +>closeFile : Symbol(closeFile, Decl(flowAfterFinally1.ts, 0, 33)) + +declare function someOperation(): {} +>someOperation : Symbol(someOperation, Decl(flowAfterFinally1.ts, 1, 34)) + +var result: {} +>result : Symbol(result, Decl(flowAfterFinally1.ts, 4, 3)) + +openFile() +>openFile : Symbol(openFile, Decl(flowAfterFinally1.ts, 0, 0)) + +try { + result = someOperation() +>result : Symbol(result, Decl(flowAfterFinally1.ts, 4, 3)) +>someOperation : Symbol(someOperation, Decl(flowAfterFinally1.ts, 1, 34)) + +} finally { + closeFile() +>closeFile : Symbol(closeFile, Decl(flowAfterFinally1.ts, 0, 33)) +} + +result // should not error here +>result : Symbol(result, Decl(flowAfterFinally1.ts, 4, 3)) + diff --git a/tests/baselines/reference/flowAfterFinally1.types b/tests/baselines/reference/flowAfterFinally1.types new file mode 100644 index 00000000000..93aae4764b6 --- /dev/null +++ b/tests/baselines/reference/flowAfterFinally1.types @@ -0,0 +1,33 @@ +=== tests/cases/compiler/flowAfterFinally1.ts === +declare function openFile(): void +>openFile : () => void + +declare function closeFile(): void +>closeFile : () => void + +declare function someOperation(): {} +>someOperation : () => {} + +var result: {} +>result : {} + +openFile() +>openFile() : void +>openFile : () => void + +try { + result = someOperation() +>result = someOperation() : {} +>result : {} +>someOperation() : {} +>someOperation : () => {} + +} finally { + closeFile() +>closeFile() : void +>closeFile : () => void +} + +result // should not error here +>result : {} + diff --git a/tests/baselines/reference/fluentClasses.js b/tests/baselines/reference/fluentClasses.js index ac44416e133..f9c8181aa49 100644 --- a/tests/baselines/reference/fluentClasses.js +++ b/tests/baselines/reference/fluentClasses.js @@ -19,11 +19,16 @@ var z = c.foo().bar().baz(); // Fluent pattern //// [fluentClasses.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -35,7 +40,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function () { return this; @@ -45,7 +50,7 @@ var B = (function (_super) { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.baz = function () { return this; diff --git a/tests/baselines/reference/for-inStatements.js b/tests/baselines/reference/for-inStatements.js index 15d771bf587..18ccb37b416 100644 --- a/tests/baselines/reference/for-inStatements.js +++ b/tests/baselines/reference/for-inStatements.js @@ -81,11 +81,16 @@ for (var x in Color.Blue) { } //// [for-inStatements.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var aString; for (aString in {}) { } var anAny; @@ -126,7 +131,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.boz = function () { for (var x in this.biz()) { } diff --git a/tests/baselines/reference/for-inStatementsInvalid.js b/tests/baselines/reference/for-inStatementsInvalid.js index d1181760a36..d70da450f08 100644 --- a/tests/baselines/reference/for-inStatementsInvalid.js +++ b/tests/baselines/reference/for-inStatementsInvalid.js @@ -64,11 +64,16 @@ for (var x in i[42]) { } //// [for-inStatementsInvalid.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var aNumber; for (aNumber in {}) { } var aBoolean; @@ -107,7 +112,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.boz = function () { for (var x in this.biz()) { } diff --git a/tests/baselines/reference/forStatementsMultipleInvalidDecl.js b/tests/baselines/reference/forStatementsMultipleInvalidDecl.js index 3666ad930a6..27284f8b272 100644 --- a/tests/baselines/reference/forStatementsMultipleInvalidDecl.js +++ b/tests/baselines/reference/forStatementsMultipleInvalidDecl.js @@ -55,11 +55,16 @@ for(var m: typeof M;;){} for( var m = M.A;;){} //// [forStatementsMultipleInvalidDecl.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -68,7 +73,7 @@ var C = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(C)); diff --git a/tests/baselines/reference/forwardRefInClassProperties.errors.txt b/tests/baselines/reference/forwardRefInClassProperties.errors.txt new file mode 100644 index 00000000000..dcf153076ed --- /dev/null +++ b/tests/baselines/reference/forwardRefInClassProperties.errors.txt @@ -0,0 +1,27 @@ +tests/cases/compiler/forwardRefInClassProperties.ts(3,15): error TS2448: Block-scoped variable '_a' used before its declaration. +tests/cases/compiler/forwardRefInClassProperties.ts(6,22): error TS2448: Block-scoped variable '_A' used before its declaration. +tests/cases/compiler/forwardRefInClassProperties.ts(11,17): error TS2448: Block-scoped variable 'b' used before its declaration. + + +==== tests/cases/compiler/forwardRefInClassProperties.ts (3 errors) ==== + class Test + { + _b = this._a; // undefined, no error/warning + ~~ +!!! error TS2448: Block-scoped variable '_a' used before its declaration. + _a = 3; + + static _B = Test._A; // undefined, no error/warning + ~~ +!!! error TS2448: Block-scoped variable '_A' used before its declaration. + static _A = 3; + + method() + { + let a = b; // Block-scoped variable 'b' used before its declaration + ~ +!!! error TS2448: Block-scoped variable 'b' used before its declaration. + let b = 3; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/forwardRefInClassProperties.js b/tests/baselines/reference/forwardRefInClassProperties.js new file mode 100644 index 00000000000..1dc455729ab --- /dev/null +++ b/tests/baselines/reference/forwardRefInClassProperties.js @@ -0,0 +1,31 @@ +//// [forwardRefInClassProperties.ts] +class Test +{ + _b = this._a; // undefined, no error/warning + _a = 3; + + static _B = Test._A; // undefined, no error/warning + static _A = 3; + + method() + { + let a = b; // Block-scoped variable 'b' used before its declaration + let b = 3; + } +} + + +//// [forwardRefInClassProperties.js] +var Test = (function () { + function Test() { + this._b = this._a; // undefined, no error/warning + this._a = 3; + } + Test.prototype.method = function () { + var a = b; // Block-scoped variable 'b' used before its declaration + var b = 3; + }; + return Test; +}()); +Test._B = Test._A; // undefined, no error/warning +Test._A = 3; diff --git a/tests/baselines/reference/functionAndImportNameConflict.js b/tests/baselines/reference/functionAndImportNameConflict.js index 8391823aa3a..2bc6d91b2c3 100644 --- a/tests/baselines/reference/functionAndImportNameConflict.js +++ b/tests/baselines/reference/functionAndImportNameConflict.js @@ -11,11 +11,13 @@ export function f() { //// [f1.js] "use strict"; +exports.__esModule = true; function f() { } exports.f = f; //// [f2.js] "use strict"; +exports.__esModule = true; function f() { } exports.f = f; diff --git a/tests/baselines/reference/functionImplementationErrors.js b/tests/baselines/reference/functionImplementationErrors.js index 433418af41d..e227693b386 100644 --- a/tests/baselines/reference/functionImplementationErrors.js +++ b/tests/baselines/reference/functionImplementationErrors.js @@ -75,11 +75,16 @@ var f13 = () => { //// [functionImplementationErrors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // FunctionExpression with no return type annotation with multiple return statements with unrelated types var f1 = function () { return ''; @@ -134,14 +139,14 @@ var AnotherClass = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived1; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/functionImplementations.js b/tests/baselines/reference/functionImplementations.js index 86636b84a87..994ff36da56 100644 --- a/tests/baselines/reference/functionImplementations.js +++ b/tests/baselines/reference/functionImplementations.js @@ -158,11 +158,16 @@ var f12: (x: number) => any = x => { // should be (x: number) => Base | AnotherC } //// [functionImplementations.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // FunctionExpression with no return type annotation and no return statement returns void var v = function () { }(); // FunctionExpression f with no return type annotation and directly references f in its body returns any @@ -236,7 +241,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -287,7 +292,7 @@ function f6() { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/functionLikeInParameterInitializer.js b/tests/baselines/reference/functionLikeInParameterInitializer.js index bf1d887b435..9bf71aff1ea 100644 --- a/tests/baselines/reference/functionLikeInParameterInitializer.js +++ b/tests/baselines/reference/functionLikeInParameterInitializer.js @@ -21,6 +21,7 @@ export function baz3(func = class { x = foo }) { //// [functionLikeInParameterInitializer.js] "use strict"; +exports.__esModule = true; // error function bar(func) { if (func === void 0) { func = function () { return foo; }; } diff --git a/tests/baselines/reference/functionSubtypingOfVarArgs.js b/tests/baselines/reference/functionSubtypingOfVarArgs.js index 55917962184..a4b43c3a1a1 100644 --- a/tests/baselines/reference/functionSubtypingOfVarArgs.js +++ b/tests/baselines/reference/functionSubtypingOfVarArgs.js @@ -15,11 +15,16 @@ class StringEvent extends EventBase { // should work //// [functionSubtypingOfVarArgs.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var EventBase = (function () { function EventBase() { this._listeners = []; @@ -32,7 +37,7 @@ var EventBase = (function () { var StringEvent = (function (_super) { __extends(StringEvent, _super); function StringEvent() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } StringEvent.prototype.add = function (listener) { _super.prototype.add.call(this, listener); diff --git a/tests/baselines/reference/functionSubtypingOfVarArgs2.js b/tests/baselines/reference/functionSubtypingOfVarArgs2.js index a676316459f..829440c12d4 100644 --- a/tests/baselines/reference/functionSubtypingOfVarArgs2.js +++ b/tests/baselines/reference/functionSubtypingOfVarArgs2.js @@ -15,11 +15,16 @@ class StringEvent extends EventBase { //// [functionSubtypingOfVarArgs2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var EventBase = (function () { function EventBase() { this._listeners = []; @@ -32,7 +37,7 @@ var EventBase = (function () { var StringEvent = (function (_super) { __extends(StringEvent, _super); function StringEvent() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } StringEvent.prototype.add = function (listener) { _super.prototype.add.call(this, listener); diff --git a/tests/baselines/reference/functionsInClassExpressions.symbols b/tests/baselines/reference/functionsInClassExpressions.symbols index a1da3a3175c..4aa62da8e33 100644 --- a/tests/baselines/reference/functionsInClassExpressions.symbols +++ b/tests/baselines/reference/functionsInClassExpressions.symbols @@ -4,24 +4,24 @@ let Foo = class { constructor() { this.bar++; ->this.bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5)) ->this : Symbol((Anonymous class), Decl(functionsInClassExpressions.ts, 0, 9)) ->bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5)) +>this.bar : Symbol(Foo.bar, Decl(functionsInClassExpressions.ts, 3, 5)) +>this : Symbol(Foo, Decl(functionsInClassExpressions.ts, 0, 9)) +>bar : Symbol(Foo.bar, Decl(functionsInClassExpressions.ts, 3, 5)) } bar = 0; ->bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5)) +>bar : Symbol(Foo.bar, Decl(functionsInClassExpressions.ts, 3, 5)) inc = () => { ->inc : Symbol((Anonymous class).inc, Decl(functionsInClassExpressions.ts, 4, 12)) +>inc : Symbol(Foo.inc, Decl(functionsInClassExpressions.ts, 4, 12)) this.bar++; ->this.bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5)) ->this : Symbol((Anonymous class), Decl(functionsInClassExpressions.ts, 0, 9)) ->bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5)) +>this.bar : Symbol(Foo.bar, Decl(functionsInClassExpressions.ts, 3, 5)) +>this : Symbol(Foo, Decl(functionsInClassExpressions.ts, 0, 9)) +>bar : Symbol(Foo.bar, Decl(functionsInClassExpressions.ts, 3, 5)) } m() { return this.bar; } ->m : Symbol((Anonymous class).m, Decl(functionsInClassExpressions.ts, 7, 5)) ->this.bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5)) ->this : Symbol((Anonymous class), Decl(functionsInClassExpressions.ts, 0, 9)) ->bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5)) +>m : Symbol(Foo.m, Decl(functionsInClassExpressions.ts, 7, 5)) +>this.bar : Symbol(Foo.bar, Decl(functionsInClassExpressions.ts, 3, 5)) +>this : Symbol(Foo, Decl(functionsInClassExpressions.ts, 0, 9)) +>bar : Symbol(Foo.bar, Decl(functionsInClassExpressions.ts, 3, 5)) } diff --git a/tests/baselines/reference/functionsInClassExpressions.types b/tests/baselines/reference/functionsInClassExpressions.types index b00f3df3490..7352f6e6b12 100644 --- a/tests/baselines/reference/functionsInClassExpressions.types +++ b/tests/baselines/reference/functionsInClassExpressions.types @@ -1,7 +1,7 @@ === tests/cases/compiler/functionsInClassExpressions.ts === let Foo = class { ->Foo : typeof (Anonymous class) ->class { constructor() { this.bar++; } bar = 0; inc = () => { this.bar++; } m() { return this.bar; }} : typeof (Anonymous class) +>Foo : typeof Foo +>class { constructor() { this.bar++; } bar = 0; inc = () => { this.bar++; } m() { return this.bar; }} : typeof Foo constructor() { this.bar++; diff --git a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt index 1ccc296b75b..e0c552141b2 100644 --- a/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt +++ b/tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt @@ -1,10 +1,11 @@ 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(101,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(106,16): error TS2378: A 'get' accessor must return a value. +tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(128,15): error TS2532: Object is possibly 'undefined'. tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(129,5): error TS1003: Identifier expected. -==== tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts (4 errors) ==== +==== tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts (5 errors) ==== function f1(): string { @@ -139,6 +140,8 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(129,5): e // if no return statements are present but we are a get accessor. throw null; throw undefined. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. } ~ !!! error TS1003: Identifier expected. diff --git a/tests/baselines/reference/fuzzy.errors.txt b/tests/baselines/reference/fuzzy.errors.txt index 19f0ad56a5e..c3f05fd7f2f 100644 --- a/tests/baselines/reference/fuzzy.errors.txt +++ b/tests/baselines/reference/fuzzy.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/fuzzy.ts(13,18): error TS2420: Class 'C' incorrectly implements interface 'I'. Property 'alsoWorks' is missing in type 'C'. -tests/cases/compiler/fuzzy.ts(21,20): error TS2322: Type '{ anything: number; oneI: this; }' is not assignable to type 'R'. +tests/cases/compiler/fuzzy.ts(21,13): error TS2322: Type '{ anything: number; oneI: this; }' is not assignable to type 'R'. Types of property 'oneI' are incompatible. Type 'this' is not assignable to type 'I'. Type 'C' is not assignable to type 'I'. @@ -33,7 +33,7 @@ tests/cases/compiler/fuzzy.ts(25,20): error TS2352: Type '{ oneI: this; }' canno doesntWork():R { return { anything:1, oneI:this }; - ~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ anything: number; oneI: this; }' is not assignable to type 'R'. !!! error TS2322: Types of property 'oneI' are incompatible. !!! error TS2322: Type 'this' is not assignable to type 'I'. diff --git a/tests/baselines/reference/generatedContextualTyping.js b/tests/baselines/reference/generatedContextualTyping.js index 2a6911d9cf5..f8dc2863470 100644 --- a/tests/baselines/reference/generatedContextualTyping.js +++ b/tests/baselines/reference/generatedContextualTyping.js @@ -356,11 +356,16 @@ var x355 = function(n: (s: Base[]) => any) { }; x355(n => { var n: Base[]; retur var x356 = function(n: Genric) { }; x356({ func: n => { return [d1, d2]; } }); //// [generatedContextualTyping.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -369,14 +374,14 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived1; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/generatorES6InAMDModule.js b/tests/baselines/reference/generatorES6InAMDModule.js index 594d2c3263c..b7e460af9b1 100644 --- a/tests/baselines/reference/generatorES6InAMDModule.js +++ b/tests/baselines/reference/generatorES6InAMDModule.js @@ -6,6 +6,7 @@ export function* foo() { //// [generatorES6InAMDModule.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); function* foo() { yield; } diff --git a/tests/baselines/reference/genericAndNonGenericInterfaceWithTheSameName.errors.txt b/tests/baselines/reference/genericAndNonGenericInterfaceWithTheSameName.errors.txt index 8d9ebb8d276..963613b9c2d 100644 --- a/tests/baselines/reference/genericAndNonGenericInterfaceWithTheSameName.errors.txt +++ b/tests/baselines/reference/genericAndNonGenericInterfaceWithTheSameName.errors.txt @@ -1,12 +1,17 @@ +tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts(3,11): error TS2428: All declarations of 'A' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts(7,11): error TS2428: All declarations of 'A' must have identical type parameters. +tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts(12,15): error TS2428: All declarations of 'A' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts(16,15): error TS2428: All declarations of 'A' must have identical type parameters. +tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts(34,22): error TS2428: All declarations of 'A' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts(40,22): error TS2428: All declarations of 'A' must have identical type parameters. -==== tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts (3 errors) ==== +==== tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts (6 errors) ==== // generic and non-generic interfaces with the same name do not merge interface A { + ~ +!!! error TS2428: All declarations of 'A' must have identical type parameters. foo: string; } @@ -18,6 +23,8 @@ tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterf module M { interface A { + ~ +!!! error TS2428: All declarations of 'A' must have identical type parameters. bar: T; } @@ -42,6 +49,8 @@ tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterf module M3 { export interface A { + ~ +!!! error TS2428: All declarations of 'A' must have identical type parameters. foo: string; } } diff --git a/tests/baselines/reference/genericArrayExtenstions.js b/tests/baselines/reference/genericArrayExtenstions.js index 63c67a13760..87a7fba25c1 100644 --- a/tests/baselines/reference/genericArrayExtenstions.js +++ b/tests/baselines/reference/genericArrayExtenstions.js @@ -7,3 +7,4 @@ concat(...items: T[]): T[]; //// [genericArrayExtenstions.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/genericBaseClassLiteralProperty.js b/tests/baselines/reference/genericBaseClassLiteralProperty.js index a075eff9550..0c3a5ee6129 100644 --- a/tests/baselines/reference/genericBaseClassLiteralProperty.js +++ b/tests/baselines/reference/genericBaseClassLiteralProperty.js @@ -13,11 +13,16 @@ class SubClass extends BaseClass { } //// [genericBaseClassLiteralProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var BaseClass = (function () { function BaseClass() { } @@ -26,7 +31,7 @@ var BaseClass = (function () { var SubClass = (function (_super) { __extends(SubClass, _super); function SubClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SubClass.prototype.Error = function () { var x = this._getValue1(); diff --git a/tests/baselines/reference/genericBaseClassLiteralProperty2.js b/tests/baselines/reference/genericBaseClassLiteralProperty2.js index 2b562742bf7..e2ef30f9ce8 100644 --- a/tests/baselines/reference/genericBaseClassLiteralProperty2.js +++ b/tests/baselines/reference/genericBaseClassLiteralProperty2.js @@ -16,11 +16,16 @@ class DataView2 extends BaseCollection2 { //// [genericBaseClassLiteralProperty2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var CollectionItem2 = (function () { function CollectionItem2() { } @@ -35,7 +40,7 @@ var BaseCollection2 = (function () { var DataView2 = (function (_super) { __extends(DataView2, _super); function DataView2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } DataView2.prototype.fillItems = function (item) { this._itemsByKey['dummy'] = item; diff --git a/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference.js b/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference.js index afef6224ba1..3ccdb5b6b55 100644 --- a/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference.js +++ b/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference.js @@ -109,11 +109,16 @@ var r11 = i.foo8(); // Base //// [genericCallWithConstraintsTypeArgumentInference.js] // Basic type inference with generic calls and constraints, no errors expected -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -122,14 +127,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgs2.js b/tests/baselines/reference/genericCallWithObjectTypeArgs2.js index 7b621b3ffd9..c5de24019b2 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgs2.js +++ b/tests/baselines/reference/genericCallWithObjectTypeArgs2.js @@ -33,11 +33,16 @@ var i: I; var r4 = f2(i); // Base => Derived //// [genericCallWithObjectTypeArgs2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -46,14 +51,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints2.js b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints2.js index 892cda0ee2d..a4f8172a312 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints2.js +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints2.js @@ -41,11 +41,16 @@ var r7 = f3(null, x => x); // any //// [genericCallWithObjectTypeArgsAndConstraints2.js] // Generic call with constraints infering type parameter from object member properties // No errors expected -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -54,7 +59,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.js b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.js index addfbc756a8..074b25fdeea 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.js +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.js @@ -39,11 +39,16 @@ var r6 = f3(x => x, null); //// [genericCallWithObjectTypeArgsAndConstraints3.js] // Generic call with constraints infering type parameter from object member properties -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -52,14 +57,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/genericCallbacksAndClassHierarchy.js b/tests/baselines/reference/genericCallbacksAndClassHierarchy.js index c2ad2ba29a3..b7b9e35a543 100644 --- a/tests/baselines/reference/genericCallbacksAndClassHierarchy.js +++ b/tests/baselines/reference/genericCallbacksAndClassHierarchy.js @@ -24,11 +24,16 @@ module M { } //// [genericCallbacksAndClassHierarchy.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M; (function (M) { var C1 = (function () { @@ -46,7 +51,7 @@ var M; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(C1)); diff --git a/tests/baselines/reference/genericClassExpressionInFunction.js b/tests/baselines/reference/genericClassExpressionInFunction.js index dc574dedb00..e1a47ffaac7 100644 --- a/tests/baselines/reference/genericClassExpressionInFunction.js +++ b/tests/baselines/reference/genericClassExpressionInFunction.js @@ -32,11 +32,16 @@ s.genericVar = 12; //// [genericClassExpressionInFunction.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -47,7 +52,7 @@ function B1() { return (function (_super) { __extends(class_1, _super); function class_1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class_1; }(A)); @@ -57,7 +62,7 @@ var B2 = (function () { this.anon = (function (_super) { __extends(class_2, _super); function class_2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class_2; }(A)); @@ -68,7 +73,7 @@ function B3() { return (function (_super) { __extends(Inner, _super); function Inner() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Inner; }(A)); @@ -77,14 +82,14 @@ function B3() { var K = (function (_super) { __extends(K, _super); function K() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return K; }(B1())); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }((new B2().anon))); @@ -92,7 +97,7 @@ var b3Number = B3(); var S = (function (_super) { __extends(S, _super); function S() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return S; }(b3Number)); diff --git a/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.js b/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.js index 1f3a6e17f14..c8a5b3ac0c4 100644 --- a/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.js +++ b/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.js @@ -6,22 +6,27 @@ class C { } //// [genericClassInheritsConstructorFromNonGenericClass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function (_super) { __extends(A, _super); function A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A; }(B)); var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(C)); diff --git a/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.js b/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.js index 28eaf464968..b5c8f47bfd4 100644 --- a/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.js +++ b/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.js @@ -76,11 +76,16 @@ class ViewModel implements Contract { //// [genericClassPropertyInheritanceSpecialization.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Portal; (function (Portal) { var Controls; diff --git a/tests/baselines/reference/genericClassStaticMethod.js b/tests/baselines/reference/genericClassStaticMethod.js index 4609e3bc9db..803950f58df 100644 --- a/tests/baselines/reference/genericClassStaticMethod.js +++ b/tests/baselines/reference/genericClassStaticMethod.js @@ -11,11 +11,16 @@ class Bar extends Foo { //// [genericClassStaticMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -26,7 +31,7 @@ var Foo = (function () { var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Bar.getFoo = function () { }; diff --git a/tests/baselines/reference/genericClasses3.js b/tests/baselines/reference/genericClasses3.js index 5371e2479aa..95eb5db106a 100644 --- a/tests/baselines/reference/genericClasses3.js +++ b/tests/baselines/reference/genericClasses3.js @@ -18,11 +18,16 @@ var z = v2.b; //// [genericClasses3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B() { } @@ -31,7 +36,7 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); diff --git a/tests/baselines/reference/genericClassesInModule2.js b/tests/baselines/reference/genericClassesInModule2.js index a17d9272c5b..738fa996cf7 100644 --- a/tests/baselines/reference/genericClassesInModule2.js +++ b/tests/baselines/reference/genericClassesInModule2.js @@ -23,6 +23,7 @@ export class B { //// [genericClassesInModule2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var A = (function () { function A(callback) { this.callback = callback; diff --git a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.js b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.js index d990f76d2c3..c66279ec873 100644 --- a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.js +++ b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.js @@ -27,11 +27,16 @@ module EndGate.Tweening { } //// [genericConstraintOnExtendedBuiltinTypes.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var EndGate; (function (EndGate) { var Tweening; diff --git a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.js b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.js index 4291b315933..af5f46c3c57 100644 --- a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.js +++ b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.js @@ -26,11 +26,16 @@ module EndGate.Tweening { } //// [genericConstraintOnExtendedBuiltinTypes2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var EndGate; (function (EndGate) { var Tweening; diff --git a/tests/baselines/reference/genericDefaults.js b/tests/baselines/reference/genericDefaults.js new file mode 100644 index 00000000000..45d889fc49c --- /dev/null +++ b/tests/baselines/reference/genericDefaults.js @@ -0,0 +1,1005 @@ +//// [genericDefaults.ts] +interface A { a: number; } +interface B { b: number; } +interface C { c: number; } +interface D { d: number; } +interface AB { a: number; b: number; } +interface BC { b: number; c: number; } + +declare const a: A; +declare const b: B; +declare const c: C; +declare const d: D; +declare const ab: AB; +declare const bc: BC; +declare const x: any; + +// function without type parameters +declare function f00(a?: A): A; +// no inference +f00(); +f00(a); + +// function with a type parameter without a default +declare function f01(a?: T): T; +// inference +f01(); +f01(a); +// no inference, fully supplied +f01(); +f01(a); + +// function with a type paramter with a default +declare function f02(a?: T): T; +// inference +f02(); +f02(a); +f02(b); +// no inference, fully supplied +f02(); +f02(a); +f02(); +f02(b); + +// function with a type parameter with a default that refers to itself +declare function f03(a?: T): T; +// inference +f03(); +f03(a); +f03(b); +// no inference, fully supplied +f03(); +f03(a); +f03(); +f03(b); + +// function with a type paramter without a default and a type parameter with a default +declare function f04(a?: T, b?: U): [T, U]; +// inference +f04(); +f04(a); +f04(a, b); +f04(a, c); +// no inference, partially supplied +f04(); +f04(a); +f04(a, b); +// no inference, fully supplied +f04(); +f04(a); +f04(a, b); +f04(); +f04(a); +f04(a, c); + +// function with a type parameter without a default and a type parameter with a default that refers to an earlier type parameter +declare function f05(a?: T, b?: U): [T, U]; +// inference +f05(); +f05(a); +f05(a, a); +f05(a, b); +// no inference, partially supplied +f05(); +f05(a); +f05(a, a); +// no inference, fully supplied +f05(); +f05(a); +f05(a, b); + +// function with a type parameter with a default that refers to an earlier type parameter with a default +declare function f06(a?: T, b?: U): [T, U]; +// inference +f06(); +f06(a); +f06(a, a); +f06(a, b); +f06(b, a); +f06(b, b); +// no inference, partially supplied +f06(); +f06(a); +f06(a, a); +f06(); +f06(b); +f06(b, b); +// no inference, fully supplied +f06(); +f06(a); +f06(a, b); +f06(); +f06(b); +f06(b, c); + +// function with a type parameter without a default and a type parameter with a default that refers to an earlier type parameter with a default +declare function f07(a?: T, b?: U, c?: V): [T, U, V]; +// inference +f07(); +f07(a, b); +f07(a, c); +f07(a, b, b); +f07(a, b, c); +f07(a, c, b); +f07(a, c, c); +// no inference, partially supplied +f07(); +f07(a); +f07(a, b); +f07(a, b, b); +f07(); +f07(a); +f07(a, b); +f07(a, b, b); +f07(); +f07(a); +f07(a, c); +f07(a, c, c); +// no inference, fully supplied +f07(); +f07(a); +f07(a, b); +f07(a, b, c); +f07(); +f07(a); +f07(a, c); +f07(a, c, d); + +// function with a type parameter with a default that refers to an earlier type parameter with a constraint +declare function f08(a?: T, b?: U): [T, U]; +// inference +f08(); +f08(a); +f08(a, a); +f08(a, b); +// no inference, partially supplied +f08(); +f08(a); +f08(a, a); +// no inference, fully supplied +f08(); +f08(a); +f08(a, b); + +// function with a type parameter with a constraint and a default that refers to an earlier type parameter +declare function f09(a?: T, b?: U): [T, U]; +// inference +f09(); +f09(a); +f09(a, a); +f09(a, ab); +// no inference, partially supplied +f09(); +f09(a); +f09(a, a); +f09(a, ab); +// no inference, fully supplied +f09(); +f09(a); +f09(a, ab); + +// function with a type parameter with a constraint and a default that refers to an earlier type parameter with a constraint +declare function f10(a?: T, b?: U): [T, U]; +// inference +f10(); +f10(a); +f10(a, a); +f10(a, ab); +// no inference, partially supplied +f10(); +f10(a); +f10(a, a); +f10(a, ab); +// no inference, fully supplied +f10(); +f10(a); +f10(a, a); +f10(a, ab); +f10(); +f10(a); +f10(a, ab); + +// function with a type parameter with a default that refers to an earier type parameter in a union +declare function f11(a?: T, b?: U): [T, U]; +// inference +f11(); +f11(a); +f11(a, a); +f11(a, b); +f11(a, c); +// no inference, partially supplied +f11(); +f11(a); +f11(a, a); +f11(a, b); +// no inference, fully supplied +f11(); +f11(a); +f11(a, c); + +// function with a type parameter with a default that refers to an earlier type parameter in an intersection +declare function f12(a?: T, b?: U): [T, U]; +// inference +f12(); +f12(a); +f12(a, a); +f12(a, b); +f12(a, c); +// no inference, partially supplied +f12(); +f12(a); +f12(a, ab); +// no inference, fully supplied +f12(); +f12(a); +f12(a, c); + +// function with a type parameter with a default that refers to a later type parameter with a default +declare function f13(a?: T, b?: U): [T, U]; +// inference +f13(); +f13(a); +f13(a, b); +f13(a, c); +// no inference, partially supplied +f13(); +f13(a); +f13(a, b); +// no inference, fully supplied +f13(); +f13(a); +f13(a, c); +f13(a, c); + +// function with a type parameter without a default and a type parameter with a default that refers to a later type parameter with a default +declare function f14(a?: T, b?: U, c?: V): [T, U, V]; +// inference +f14(); +f14(a); +f14(a, b); +f14(a, b, c); +f14(a, b, d); +// no inference, partially supplied +f14(); +f14(a); +f14(a, b); +f14(a, b, c); +f14(); +f14(a); +f14(a, b); +f14(a, b, c); +// no inference fully supplied +f14(); +f14(a); +f14(a, b); +f14(a, b, d); + +// function with two type parameters with defaults that mutually refer to each other +declare function f15(a?: T, b?: U): [T, U]; +// inference +f15(); +f15(a); +f15(a, b); +// no inference, partially supplied +f15(); +f15(a); +f15(a, a); +// no inference, fully supplied +f15(); +f15(a); +f15(a, b); + +// function with a type parameter without a default and two type parameters with defaults that mutually refer to each other +declare function f16(a?: T, b?: U, c?: V): [T, U, V]; +// no inference +f16(); +f16(a); +f16(a, b); +f16(a, b, b); +// no inference, partially supplied +f16(); +f16(a); +f16(a, b); +f16(a, b, b); +f16(); +f16(a); +f16(a, b); +f16(a, b, b); +// no inference, fully supplied +f16(); +f16(a); +f16(a, b); +f16(a, b, d); + +// function with a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in a union +declare function f17(a?: T, b?: U): [T, U]; +// inference +f17(); +f17(a); +f17(a, a); +f17(a, b); +f17(a, c); +// no inference, partially supplied +f17(); +f17(a); +f17(a, a); +f17(a, b); +// no inference, fully supplied +f17(); +f17(a); +f17(a, c); + +// function with a type parameter without a default and a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in a union +declare function f18(a?: T, b?: U, c?: V): [T, U, V]; +// inference +f18(); +f18(a); +f18(a, b); +f18(a, b, b); +f18(a, b, c); +// no inference, partially supplied +f18(); +f18(a); +f18(a, b); +f18(a, b, b); +f18(a, b, c); +f18(); +f18(a); +f18(a, b); +f18(a, b, b); +f18(a, b, c); +// no inference, fully supplied +f18(); +f18(a); +f18(a, b); +f18(a, b, d); + +// function with a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in an intersection +declare function f19(a?: T, b?: U): [T, U]; +// inference +f19(); +f19(a); +f19(a, a); +f19(a, b); +f19(a, ab); +f19(a, c); +// no inference, partially supplied +f19(); +f19(a); +f19(a, ab); +// no inference, fully supplied +f19(); +f19(a); +f19(a, c); + +// function with a type parameter without a default and a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in an intersection +declare function f20(a?: T, b?: U, c?: V): [T, U, V]; +// inference +f20(); +f20(a); +f20(a, b); +f20(a, b, c); +// no inference, partially supplied +f20(); +f20(a); +f20(a, b); +f20(a, b, bc); +f20(); +f20(a); +f20(a, b); +f20(a, b, bc); +// no inference, fully supplied +f20(); +f20(a); +f20(a, b); +f20(a, b, d); + +interface i00 { a: T; } +const i00c00 = (x).a; +const i00c01 = (>x).a; + +interface i01 { a: [T, U]; } +const i01c00 = (>x).a; +const i01c01 = (>x).a; + +interface i02 { a: [T, U]; } +const i02c00 = (>x).a; +const i02c01 = (>x).a; +const i02c02 = (>x).a; +const i02c03 = (>x).a; +const i02c04 = (>x).a; + +interface i03 { a: [T, U]; } +const i03c00 = (>x).a; +const i03c01 = (>x).a; +const i03c02 = (>x).a; +const i03c03 = (>x).a; +const i03c04 = (>x).a; + +interface i04 {} +interface i04 {} +interface i04 {} +interface i04 {} + +interface i05 { a: T; } +const i05c00 = (x).a; +const i05c01 = (>x).a; + +interface i06 { a: [T, U]; } +const i06c00 = (x).a; +const i06c01 = (>x).a; +const i06c02 = (>x).a; + +interface i07 { a: A; } +interface i07 { b: A; } +const i07c00 = (x).a; +const i07c01 = (x).b; +const i07c02 = (>x).a; +const i07c03 = (>x).b; + +interface Base01 { a: T; } +interface Base01Constructor { new (a?: T): Base01; } + +declare const Base01: Base01Constructor; +const Base01c00 = new Base01(); +const Base01c01 = new Base01(1); +const Base01c02 = new Base01(); +const Base01c03 = new Base01(1); + +declare class Derived01 extends Base01 { } +const Derived01c00 = new Derived01(); +const Derived01c01 = new Derived01(1); +const Derived01c02 = new Derived01(); +const Derived01c03 = new Derived01(1); + +declare class Derived02 extends Base01 { } +const Derived02c00 = new Derived02(); +const Derived02c01 = new Derived02(1); +const Derived02c02 = new Derived02(); +const Derived02c03 = new Derived02(1); + +type t00 = { a: T; } +const t00c00 = (x).a; +const t00c01 = (>x).a; + +type t01 = { a: [T, U]; } +const t01c00 = (>x).a; +const t01c01 = (>x).a; + +type t02 = { a: [T, U]; } +const t02c00 = (>x).a; +const t02c01 = (>x).a; +const t02c02 = (>x).a; +const t02c03 = (>x).a; +const t02c04 = (>x).a; + +type t03 = { a: [T, U]; } +const t03c00 = (>x).a; +const t03c01 = (>x).a; +const t03c02 = (>x).a; +const t03c03 = (>x).a; +const t03c04 = (>x).a; + + +//// [genericDefaults.js] +// no inference +f00(); +f00(a); +// inference +f01(); +f01(a); +// no inference, fully supplied +f01(); +f01(a); +// inference +f02(); +f02(a); +f02(b); +// no inference, fully supplied +f02(); +f02(a); +f02(); +f02(b); +// inference +f03(); +f03(a); +f03(b); +// no inference, fully supplied +f03(); +f03(a); +f03(); +f03(b); +// inference +f04(); +f04(a); +f04(a, b); +f04(a, c); +// no inference, partially supplied +f04(); +f04(a); +f04(a, b); +// no inference, fully supplied +f04(); +f04(a); +f04(a, b); +f04(); +f04(a); +f04(a, c); +// inference +f05(); +f05(a); +f05(a, a); +f05(a, b); +// no inference, partially supplied +f05(); +f05(a); +f05(a, a); +// no inference, fully supplied +f05(); +f05(a); +f05(a, b); +// inference +f06(); +f06(a); +f06(a, a); +f06(a, b); +f06(b, a); +f06(b, b); +// no inference, partially supplied +f06(); +f06(a); +f06(a, a); +f06(); +f06(b); +f06(b, b); +// no inference, fully supplied +f06(); +f06(a); +f06(a, b); +f06(); +f06(b); +f06(b, c); +// inference +f07(); +f07(a, b); +f07(a, c); +f07(a, b, b); +f07(a, b, c); +f07(a, c, b); +f07(a, c, c); +// no inference, partially supplied +f07(); +f07(a); +f07(a, b); +f07(a, b, b); +f07(); +f07(a); +f07(a, b); +f07(a, b, b); +f07(); +f07(a); +f07(a, c); +f07(a, c, c); +// no inference, fully supplied +f07(); +f07(a); +f07(a, b); +f07(a, b, c); +f07(); +f07(a); +f07(a, c); +f07(a, c, d); +// inference +f08(); +f08(a); +f08(a, a); +f08(a, b); +// no inference, partially supplied +f08(); +f08(a); +f08(a, a); +// no inference, fully supplied +f08(); +f08(a); +f08(a, b); +// inference +f09(); +f09(a); +f09(a, a); +f09(a, ab); +// no inference, partially supplied +f09(); +f09(a); +f09(a, a); +f09(a, ab); +// no inference, fully supplied +f09(); +f09(a); +f09(a, ab); +// inference +f10(); +f10(a); +f10(a, a); +f10(a, ab); +// no inference, partially supplied +f10(); +f10(a); +f10(a, a); +f10(a, ab); +// no inference, fully supplied +f10(); +f10(a); +f10(a, a); +f10(a, ab); +f10(); +f10(a); +f10(a, ab); +// inference +f11(); +f11(a); +f11(a, a); +f11(a, b); +f11(a, c); +// no inference, partially supplied +f11(); +f11(a); +f11(a, a); +f11(a, b); +// no inference, fully supplied +f11(); +f11(a); +f11(a, c); +// inference +f12(); +f12(a); +f12(a, a); +f12(a, b); +f12(a, c); +// no inference, partially supplied +f12(); +f12(a); +f12(a, ab); +// no inference, fully supplied +f12(); +f12(a); +f12(a, c); +// inference +f13(); +f13(a); +f13(a, b); +f13(a, c); +// no inference, partially supplied +f13(); +f13(a); +f13(a, b); +// no inference, fully supplied +f13(); +f13(a); +f13(a, c); +f13(a, c); +// inference +f14(); +f14(a); +f14(a, b); +f14(a, b, c); +f14(a, b, d); +// no inference, partially supplied +f14(); +f14(a); +f14(a, b); +f14(a, b, c); +f14(); +f14(a); +f14(a, b); +f14(a, b, c); +// no inference fully supplied +f14(); +f14(a); +f14(a, b); +f14(a, b, d); +// inference +f15(); +f15(a); +f15(a, b); +// no inference, partially supplied +f15(); +f15(a); +f15(a, a); +// no inference, fully supplied +f15(); +f15(a); +f15(a, b); +// no inference +f16(); +f16(a); +f16(a, b); +f16(a, b, b); +// no inference, partially supplied +f16(); +f16(a); +f16(a, b); +f16(a, b, b); +f16(); +f16(a); +f16(a, b); +f16(a, b, b); +// no inference, fully supplied +f16(); +f16(a); +f16(a, b); +f16(a, b, d); +// inference +f17(); +f17(a); +f17(a, a); +f17(a, b); +f17(a, c); +// no inference, partially supplied +f17(); +f17(a); +f17(a, a); +f17(a, b); +// no inference, fully supplied +f17(); +f17(a); +f17(a, c); +// inference +f18(); +f18(a); +f18(a, b); +f18(a, b, b); +f18(a, b, c); +// no inference, partially supplied +f18(); +f18(a); +f18(a, b); +f18(a, b, b); +f18(a, b, c); +f18(); +f18(a); +f18(a, b); +f18(a, b, b); +f18(a, b, c); +// no inference, fully supplied +f18(); +f18(a); +f18(a, b); +f18(a, b, d); +// inference +f19(); +f19(a); +f19(a, a); +f19(a, b); +f19(a, ab); +f19(a, c); +// no inference, partially supplied +f19(); +f19(a); +f19(a, ab); +// no inference, fully supplied +f19(); +f19(a); +f19(a, c); +// inference +f20(); +f20(a); +f20(a, b); +f20(a, b, c); +// no inference, partially supplied +f20(); +f20(a); +f20(a, b); +f20(a, b, bc); +f20(); +f20(a); +f20(a, b); +f20(a, b, bc); +// no inference, fully supplied +f20(); +f20(a); +f20(a, b); +f20(a, b, d); +var i00c00 = x.a; +var i00c01 = x.a; +var i01c00 = x.a; +var i01c01 = x.a; +var i02c00 = x.a; +var i02c01 = x.a; +var i02c02 = x.a; +var i02c03 = x.a; +var i02c04 = x.a; +var i03c00 = x.a; +var i03c01 = x.a; +var i03c02 = x.a; +var i03c03 = x.a; +var i03c04 = x.a; +var i05c00 = x.a; +var i05c01 = x.a; +var i06c00 = x.a; +var i06c01 = x.a; +var i06c02 = x.a; +var i07c00 = x.a; +var i07c01 = x.b; +var i07c02 = x.a; +var i07c03 = x.b; +var Base01c00 = new Base01(); +var Base01c01 = new Base01(1); +var Base01c02 = new Base01(); +var Base01c03 = new Base01(1); +var Derived01c00 = new Derived01(); +var Derived01c01 = new Derived01(1); +var Derived01c02 = new Derived01(); +var Derived01c03 = new Derived01(1); +var Derived02c00 = new Derived02(); +var Derived02c01 = new Derived02(1); +var Derived02c02 = new Derived02(); +var Derived02c03 = new Derived02(1); +var t00c00 = x.a; +var t00c01 = x.a; +var t01c00 = x.a; +var t01c01 = x.a; +var t02c00 = x.a; +var t02c01 = x.a; +var t02c02 = x.a; +var t02c03 = x.a; +var t02c04 = x.a; +var t03c00 = x.a; +var t03c01 = x.a; +var t03c02 = x.a; +var t03c03 = x.a; +var t03c04 = x.a; + + +//// [genericDefaults.d.ts] +interface A { + a: number; +} +interface B { + b: number; +} +interface C { + c: number; +} +interface D { + d: number; +} +interface AB { + a: number; + b: number; +} +interface BC { + b: number; + c: number; +} +declare const a: A; +declare const b: B; +declare const c: C; +declare const d: D; +declare const ab: AB; +declare const bc: BC; +declare const x: any; +declare function f00(a?: A): A; +declare function f01(a?: T): T; +declare function f02(a?: T): T; +declare function f03(a?: T): T; +declare function f04(a?: T, b?: U): [T, U]; +declare function f05(a?: T, b?: U): [T, U]; +declare function f06(a?: T, b?: U): [T, U]; +declare function f07(a?: T, b?: U, c?: V): [T, U, V]; +declare function f08(a?: T, b?: U): [T, U]; +declare function f09(a?: T, b?: U): [T, U]; +declare function f10(a?: T, b?: U): [T, U]; +declare function f11(a?: T, b?: U): [T, U]; +declare function f12(a?: T, b?: U): [T, U]; +declare function f13(a?: T, b?: U): [T, U]; +declare function f14(a?: T, b?: U, c?: V): [T, U, V]; +declare function f15(a?: T, b?: U): [T, U]; +declare function f16(a?: T, b?: U, c?: V): [T, U, V]; +declare function f17(a?: T, b?: U): [T, U]; +declare function f18(a?: T, b?: U, c?: V): [T, U, V]; +declare function f19(a?: T, b?: U): [T, U]; +declare function f20(a?: T, b?: U, c?: V): [T, U, V]; +interface i00 { + a: T; +} +declare const i00c00: number; +declare const i00c01: number; +interface i01 { + a: [T, U]; +} +declare const i01c00: [number, number]; +declare const i01c01: [number, string]; +interface i02 { + a: [T, U]; +} +declare const i02c00: [number, number]; +declare const i02c01: [1, 1]; +declare const i02c02: [number, number]; +declare const i02c03: [1, number]; +declare const i02c04: [number, 1]; +interface i03 { + a: [T, U]; +} +declare const i03c00: [number, number]; +declare const i03c01: [1, 1]; +declare const i03c02: [number, number]; +declare const i03c03: [1, 1]; +declare const i03c04: [number, 1]; +interface i04 { +} +interface i04 { +} +interface i04 { +} +interface i04 { +} +interface i05 { + a: T; +} +declare const i05c00: {}; +declare const i05c01: number; +interface i06 { + a: [T, U]; +} +declare const i06c00: [{}, {}]; +declare const i06c01: [number, number]; +declare const i06c02: [number, string]; +interface i07 { + a: A; +} +interface i07 { + b: A; +} +declare const i07c00: A; +declare const i07c01: number; +declare const i07c02: A; +declare const i07c03: B; +interface Base01 { + a: T; +} +interface Base01Constructor { + new (a?: T): Base01; +} +declare const Base01: Base01Constructor; +declare const Base01c00: Base01; +declare const Base01c01: Base01; +declare const Base01c02: Base01; +declare const Base01c03: Base01; +declare class Derived01 extends Base01 { +} +declare const Derived01c00: Derived01<{}>; +declare const Derived01c01: Derived01; +declare const Derived01c02: Derived01; +declare const Derived01c03: Derived01; +declare class Derived02 extends Base01 { +} +declare const Derived02c00: Derived02; +declare const Derived02c01: Derived02; +declare const Derived02c02: Derived02; +declare const Derived02c03: Derived02; +declare type t00 = { + a: T; +}; +declare const t00c00: number; +declare const t00c01: number; +declare type t01 = { + a: [T, U]; +}; +declare const t01c00: [number, number]; +declare const t01c01: [number, string]; +declare type t02 = { + a: [T, U]; +}; +declare const t02c00: [number, number]; +declare const t02c01: [1, 1]; +declare const t02c02: [number, number]; +declare const t02c03: [1, number]; +declare const t02c04: [number, 1]; +declare type t03 = { + a: [T, U]; +}; +declare const t03c00: [number, number]; +declare const t03c01: [1, 1]; +declare const t03c02: [number, number]; +declare const t03c03: [1, 1]; +declare const t03c04: [number, 1]; diff --git a/tests/baselines/reference/genericDefaults.symbols b/tests/baselines/reference/genericDefaults.symbols new file mode 100644 index 00000000000..2250e9ea95a --- /dev/null +++ b/tests/baselines/reference/genericDefaults.symbols @@ -0,0 +1,2257 @@ +=== tests/cases/compiler/genericDefaults.ts === +interface A { a: number; } +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(A.a, Decl(genericDefaults.ts, 0, 13)) + +interface B { b: number; } +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>b : Symbol(B.b, Decl(genericDefaults.ts, 1, 13)) + +interface C { c: number; } +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>c : Symbol(C.c, Decl(genericDefaults.ts, 2, 13)) + +interface D { d: number; } +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) +>d : Symbol(D.d, Decl(genericDefaults.ts, 3, 13)) + +interface AB { a: number; b: number; } +>AB : Symbol(AB, Decl(genericDefaults.ts, 3, 26)) +>a : Symbol(AB.a, Decl(genericDefaults.ts, 4, 14)) +>b : Symbol(AB.b, Decl(genericDefaults.ts, 4, 25)) + +interface BC { b: number; c: number; } +>BC : Symbol(BC, Decl(genericDefaults.ts, 4, 38)) +>b : Symbol(BC.b, Decl(genericDefaults.ts, 5, 14)) +>c : Symbol(BC.c, Decl(genericDefaults.ts, 5, 25)) + +declare const a: A; +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +declare const b: B; +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) + +declare const c: C; +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) + +declare const d: D; +>d : Symbol(d, Decl(genericDefaults.ts, 10, 13)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) + +declare const ab: AB; +>ab : Symbol(ab, Decl(genericDefaults.ts, 11, 13)) +>AB : Symbol(AB, Decl(genericDefaults.ts, 3, 26)) + +declare const bc: BC; +>bc : Symbol(bc, Decl(genericDefaults.ts, 12, 13)) +>BC : Symbol(BC, Decl(genericDefaults.ts, 4, 38)) + +declare const x: any; +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) + +// function without type parameters +declare function f00(a?: A): A; +>f00 : Symbol(f00, Decl(genericDefaults.ts, 13, 21)) +>a : Symbol(a, Decl(genericDefaults.ts, 16, 21)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +// no inference +f00(); +>f00 : Symbol(f00, Decl(genericDefaults.ts, 13, 21)) + +f00(a); +>f00 : Symbol(f00, Decl(genericDefaults.ts, 13, 21)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +// function with a type parameter without a default +declare function f01(a?: T): T; +>f01 : Symbol(f01, Decl(genericDefaults.ts, 19, 7)) +>T : Symbol(T, Decl(genericDefaults.ts, 22, 21)) +>a : Symbol(a, Decl(genericDefaults.ts, 22, 24)) +>T : Symbol(T, Decl(genericDefaults.ts, 22, 21)) +>T : Symbol(T, Decl(genericDefaults.ts, 22, 21)) + +// inference +f01(); +>f01 : Symbol(f01, Decl(genericDefaults.ts, 19, 7)) + +f01(a); +>f01 : Symbol(f01, Decl(genericDefaults.ts, 19, 7)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +// no inference, fully supplied +f01(); +>f01 : Symbol(f01, Decl(genericDefaults.ts, 19, 7)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f01(a); +>f01 : Symbol(f01, Decl(genericDefaults.ts, 19, 7)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +// function with a type paramter with a default +declare function f02(a?: T): T; +>f02 : Symbol(f02, Decl(genericDefaults.ts, 28, 10)) +>T : Symbol(T, Decl(genericDefaults.ts, 31, 21)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 31, 28)) +>T : Symbol(T, Decl(genericDefaults.ts, 31, 21)) +>T : Symbol(T, Decl(genericDefaults.ts, 31, 21)) + +// inference +f02(); +>f02 : Symbol(f02, Decl(genericDefaults.ts, 28, 10)) + +f02(a); +>f02 : Symbol(f02, Decl(genericDefaults.ts, 28, 10)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f02(b); +>f02 : Symbol(f02, Decl(genericDefaults.ts, 28, 10)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +// no inference, fully supplied +f02(); +>f02 : Symbol(f02, Decl(genericDefaults.ts, 28, 10)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f02(a); +>f02 : Symbol(f02, Decl(genericDefaults.ts, 28, 10)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f02(); +>f02 : Symbol(f02, Decl(genericDefaults.ts, 28, 10)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) + +f02(b); +>f02 : Symbol(f02, Decl(genericDefaults.ts, 28, 10)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +// function with a type parameter with a default that refers to itself +declare function f03(a?: T): T; +>f03 : Symbol(f03, Decl(genericDefaults.ts, 40, 10)) +>T : Symbol(T, Decl(genericDefaults.ts, 43, 21)) +>T : Symbol(T, Decl(genericDefaults.ts, 43, 21)) +>a : Symbol(a, Decl(genericDefaults.ts, 43, 28)) +>T : Symbol(T, Decl(genericDefaults.ts, 43, 21)) +>T : Symbol(T, Decl(genericDefaults.ts, 43, 21)) + +// inference +f03(); +>f03 : Symbol(f03, Decl(genericDefaults.ts, 40, 10)) + +f03(a); +>f03 : Symbol(f03, Decl(genericDefaults.ts, 40, 10)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f03(b); +>f03 : Symbol(f03, Decl(genericDefaults.ts, 40, 10)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +// no inference, fully supplied +f03(); +>f03 : Symbol(f03, Decl(genericDefaults.ts, 40, 10)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f03(a); +>f03 : Symbol(f03, Decl(genericDefaults.ts, 40, 10)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f03(); +>f03 : Symbol(f03, Decl(genericDefaults.ts, 40, 10)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) + +f03(b); +>f03 : Symbol(f03, Decl(genericDefaults.ts, 40, 10)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +// function with a type paramter without a default and a type parameter with a default +declare function f04(a?: T, b?: U): [T, U]; +>f04 : Symbol(f04, Decl(genericDefaults.ts, 52, 10)) +>T : Symbol(T, Decl(genericDefaults.ts, 55, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 55, 23)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 55, 31)) +>T : Symbol(T, Decl(genericDefaults.ts, 55, 21)) +>b : Symbol(b, Decl(genericDefaults.ts, 55, 37)) +>U : Symbol(U, Decl(genericDefaults.ts, 55, 23)) +>T : Symbol(T, Decl(genericDefaults.ts, 55, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 55, 23)) + +// inference +f04(); +>f04 : Symbol(f04, Decl(genericDefaults.ts, 52, 10)) + +f04(a); +>f04 : Symbol(f04, Decl(genericDefaults.ts, 52, 10)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f04(a, b); +>f04 : Symbol(f04, Decl(genericDefaults.ts, 52, 10)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f04(a, c); +>f04 : Symbol(f04, Decl(genericDefaults.ts, 52, 10)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// no inference, partially supplied +f04(); +>f04 : Symbol(f04, Decl(genericDefaults.ts, 52, 10)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f04(a); +>f04 : Symbol(f04, Decl(genericDefaults.ts, 52, 10)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f04(a, b); +>f04 : Symbol(f04, Decl(genericDefaults.ts, 52, 10)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +// no inference, fully supplied +f04(); +>f04 : Symbol(f04, Decl(genericDefaults.ts, 52, 10)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) + +f04(a); +>f04 : Symbol(f04, Decl(genericDefaults.ts, 52, 10)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f04(a, b); +>f04 : Symbol(f04, Decl(genericDefaults.ts, 52, 10)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f04(); +>f04 : Symbol(f04, Decl(genericDefaults.ts, 52, 10)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) + +f04(a); +>f04 : Symbol(f04, Decl(genericDefaults.ts, 52, 10)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f04(a, c); +>f04 : Symbol(f04, Decl(genericDefaults.ts, 52, 10)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// function with a type parameter without a default and a type parameter with a default that refers to an earlier type parameter +declare function f05(a?: T, b?: U): [T, U]; +>f05 : Symbol(f05, Decl(genericDefaults.ts, 71, 16)) +>T : Symbol(T, Decl(genericDefaults.ts, 74, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 74, 23)) +>T : Symbol(T, Decl(genericDefaults.ts, 74, 21)) +>a : Symbol(a, Decl(genericDefaults.ts, 74, 31)) +>T : Symbol(T, Decl(genericDefaults.ts, 74, 21)) +>b : Symbol(b, Decl(genericDefaults.ts, 74, 37)) +>U : Symbol(U, Decl(genericDefaults.ts, 74, 23)) +>T : Symbol(T, Decl(genericDefaults.ts, 74, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 74, 23)) + +// inference +f05(); +>f05 : Symbol(f05, Decl(genericDefaults.ts, 71, 16)) + +f05(a); +>f05 : Symbol(f05, Decl(genericDefaults.ts, 71, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f05(a, a); +>f05 : Symbol(f05, Decl(genericDefaults.ts, 71, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f05(a, b); +>f05 : Symbol(f05, Decl(genericDefaults.ts, 71, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +// no inference, partially supplied +f05(); +>f05 : Symbol(f05, Decl(genericDefaults.ts, 71, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f05(a); +>f05 : Symbol(f05, Decl(genericDefaults.ts, 71, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f05(a, a); +>f05 : Symbol(f05, Decl(genericDefaults.ts, 71, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +// no inference, fully supplied +f05(); +>f05 : Symbol(f05, Decl(genericDefaults.ts, 71, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) + +f05(a); +>f05 : Symbol(f05, Decl(genericDefaults.ts, 71, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f05(a, b); +>f05 : Symbol(f05, Decl(genericDefaults.ts, 71, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +// function with a type parameter with a default that refers to an earlier type parameter with a default +declare function f06(a?: T, b?: U): [T, U]; +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) +>T : Symbol(T, Decl(genericDefaults.ts, 90, 21)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>U : Symbol(U, Decl(genericDefaults.ts, 90, 27)) +>T : Symbol(T, Decl(genericDefaults.ts, 90, 21)) +>a : Symbol(a, Decl(genericDefaults.ts, 90, 35)) +>T : Symbol(T, Decl(genericDefaults.ts, 90, 21)) +>b : Symbol(b, Decl(genericDefaults.ts, 90, 41)) +>U : Symbol(U, Decl(genericDefaults.ts, 90, 27)) +>T : Symbol(T, Decl(genericDefaults.ts, 90, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 90, 27)) + +// inference +f06(); +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) + +f06(a); +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f06(a, a); +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f06(a, b); +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f06(b, a); +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f06(b, b); +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +// no inference, partially supplied +f06(); +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f06(a); +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f06(a, a); +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f06(); +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) + +f06(b); +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f06(b, b); +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +// no inference, fully supplied +f06(); +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) + +f06(a); +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f06(a, b); +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f06(); +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) + +f06(b); +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f06(b, c); +>f06 : Symbol(f06, Decl(genericDefaults.ts, 87, 16)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// function with a type parameter without a default and a type parameter with a default that refers to an earlier type parameter with a default +declare function f07(a?: T, b?: U, c?: V): [T, U, V]; +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>T : Symbol(T, Decl(genericDefaults.ts, 114, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 114, 23)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>V : Symbol(V, Decl(genericDefaults.ts, 114, 30)) +>U : Symbol(U, Decl(genericDefaults.ts, 114, 23)) +>a : Symbol(a, Decl(genericDefaults.ts, 114, 38)) +>T : Symbol(T, Decl(genericDefaults.ts, 114, 21)) +>b : Symbol(b, Decl(genericDefaults.ts, 114, 44)) +>U : Symbol(U, Decl(genericDefaults.ts, 114, 23)) +>c : Symbol(c, Decl(genericDefaults.ts, 114, 51)) +>V : Symbol(V, Decl(genericDefaults.ts, 114, 30)) +>T : Symbol(T, Decl(genericDefaults.ts, 114, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 114, 23)) +>V : Symbol(V, Decl(genericDefaults.ts, 114, 30)) + +// inference +f07(); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) + +f07(a, b); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f07(a, c); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +f07(a, b, b); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f07(a, b, c); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +f07(a, c, b); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f07(a, c, c); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// no inference, partially supplied +f07(); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f07(a); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f07(a, b); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f07(a, b, b); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f07(); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) + +f07(a); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f07(a, b); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f07(a, b, b); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f07(); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) + +f07(a); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f07(a, c); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +f07(a, c, c); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// no inference, fully supplied +f07(); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) + +f07(a); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f07(a, b); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f07(a, b, c); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +f07(); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f07(a); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f07(a, c); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +f07(a, c, d); +>f07 : Symbol(f07, Decl(genericDefaults.ts, 111, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) +>d : Symbol(d, Decl(genericDefaults.ts, 10, 13)) + +// function with a type parameter with a default that refers to an earlier type parameter with a constraint +declare function f08(a?: T, b?: U): [T, U]; +>f08 : Symbol(f08, Decl(genericDefaults.ts, 144, 22)) +>T : Symbol(T, Decl(genericDefaults.ts, 147, 21)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>U : Symbol(U, Decl(genericDefaults.ts, 147, 33)) +>T : Symbol(T, Decl(genericDefaults.ts, 147, 21)) +>a : Symbol(a, Decl(genericDefaults.ts, 147, 41)) +>T : Symbol(T, Decl(genericDefaults.ts, 147, 21)) +>b : Symbol(b, Decl(genericDefaults.ts, 147, 47)) +>U : Symbol(U, Decl(genericDefaults.ts, 147, 33)) +>T : Symbol(T, Decl(genericDefaults.ts, 147, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 147, 33)) + +// inference +f08(); +>f08 : Symbol(f08, Decl(genericDefaults.ts, 144, 22)) + +f08(a); +>f08 : Symbol(f08, Decl(genericDefaults.ts, 144, 22)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f08(a, a); +>f08 : Symbol(f08, Decl(genericDefaults.ts, 144, 22)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f08(a, b); +>f08 : Symbol(f08, Decl(genericDefaults.ts, 144, 22)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +// no inference, partially supplied +f08(); +>f08 : Symbol(f08, Decl(genericDefaults.ts, 144, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f08(a); +>f08 : Symbol(f08, Decl(genericDefaults.ts, 144, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f08(a, a); +>f08 : Symbol(f08, Decl(genericDefaults.ts, 144, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +// no inference, fully supplied +f08(); +>f08 : Symbol(f08, Decl(genericDefaults.ts, 144, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) + +f08(a); +>f08 : Symbol(f08, Decl(genericDefaults.ts, 144, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f08(a, b); +>f08 : Symbol(f08, Decl(genericDefaults.ts, 144, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +// function with a type parameter with a constraint and a default that refers to an earlier type parameter +declare function f09(a?: T, b?: U): [T, U]; +>f09 : Symbol(f09, Decl(genericDefaults.ts, 160, 16)) +>T : Symbol(T, Decl(genericDefaults.ts, 163, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 163, 23)) +>T : Symbol(T, Decl(genericDefaults.ts, 163, 21)) +>T : Symbol(T, Decl(genericDefaults.ts, 163, 21)) +>a : Symbol(a, Decl(genericDefaults.ts, 163, 41)) +>T : Symbol(T, Decl(genericDefaults.ts, 163, 21)) +>b : Symbol(b, Decl(genericDefaults.ts, 163, 47)) +>U : Symbol(U, Decl(genericDefaults.ts, 163, 23)) +>T : Symbol(T, Decl(genericDefaults.ts, 163, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 163, 23)) + +// inference +f09(); +>f09 : Symbol(f09, Decl(genericDefaults.ts, 160, 16)) + +f09(a); +>f09 : Symbol(f09, Decl(genericDefaults.ts, 160, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f09(a, a); +>f09 : Symbol(f09, Decl(genericDefaults.ts, 160, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f09(a, ab); +>f09 : Symbol(f09, Decl(genericDefaults.ts, 160, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>ab : Symbol(ab, Decl(genericDefaults.ts, 11, 13)) + +// no inference, partially supplied +f09(); +>f09 : Symbol(f09, Decl(genericDefaults.ts, 160, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f09(a); +>f09 : Symbol(f09, Decl(genericDefaults.ts, 160, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f09(a, a); +>f09 : Symbol(f09, Decl(genericDefaults.ts, 160, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f09(a, ab); +>f09 : Symbol(f09, Decl(genericDefaults.ts, 160, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>ab : Symbol(ab, Decl(genericDefaults.ts, 11, 13)) + +// no inference, fully supplied +f09(); +>f09 : Symbol(f09, Decl(genericDefaults.ts, 160, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>AB : Symbol(AB, Decl(genericDefaults.ts, 3, 26)) + +f09(a); +>f09 : Symbol(f09, Decl(genericDefaults.ts, 160, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>AB : Symbol(AB, Decl(genericDefaults.ts, 3, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f09(a, ab); +>f09 : Symbol(f09, Decl(genericDefaults.ts, 160, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>AB : Symbol(AB, Decl(genericDefaults.ts, 3, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>ab : Symbol(ab, Decl(genericDefaults.ts, 11, 13)) + +// function with a type parameter with a constraint and a default that refers to an earlier type parameter with a constraint +declare function f10(a?: T, b?: U): [T, U]; +>f10 : Symbol(f10, Decl(genericDefaults.ts, 177, 18)) +>T : Symbol(T, Decl(genericDefaults.ts, 180, 21)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>U : Symbol(U, Decl(genericDefaults.ts, 180, 33)) +>T : Symbol(T, Decl(genericDefaults.ts, 180, 21)) +>T : Symbol(T, Decl(genericDefaults.ts, 180, 21)) +>a : Symbol(a, Decl(genericDefaults.ts, 180, 51)) +>T : Symbol(T, Decl(genericDefaults.ts, 180, 21)) +>b : Symbol(b, Decl(genericDefaults.ts, 180, 57)) +>U : Symbol(U, Decl(genericDefaults.ts, 180, 33)) +>T : Symbol(T, Decl(genericDefaults.ts, 180, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 180, 33)) + +// inference +f10(); +>f10 : Symbol(f10, Decl(genericDefaults.ts, 177, 18)) + +f10(a); +>f10 : Symbol(f10, Decl(genericDefaults.ts, 177, 18)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f10(a, a); +>f10 : Symbol(f10, Decl(genericDefaults.ts, 177, 18)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f10(a, ab); +>f10 : Symbol(f10, Decl(genericDefaults.ts, 177, 18)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>ab : Symbol(ab, Decl(genericDefaults.ts, 11, 13)) + +// no inference, partially supplied +f10(); +>f10 : Symbol(f10, Decl(genericDefaults.ts, 177, 18)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f10(a); +>f10 : Symbol(f10, Decl(genericDefaults.ts, 177, 18)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f10(a, a); +>f10 : Symbol(f10, Decl(genericDefaults.ts, 177, 18)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f10(a, ab); +>f10 : Symbol(f10, Decl(genericDefaults.ts, 177, 18)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>ab : Symbol(ab, Decl(genericDefaults.ts, 11, 13)) + +// no inference, fully supplied +f10(); +>f10 : Symbol(f10, Decl(genericDefaults.ts, 177, 18)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f10(a); +>f10 : Symbol(f10, Decl(genericDefaults.ts, 177, 18)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f10(a, a); +>f10 : Symbol(f10, Decl(genericDefaults.ts, 177, 18)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f10(a, ab); +>f10 : Symbol(f10, Decl(genericDefaults.ts, 177, 18)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>ab : Symbol(ab, Decl(genericDefaults.ts, 11, 13)) + +f10(); +>f10 : Symbol(f10, Decl(genericDefaults.ts, 177, 18)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>AB : Symbol(AB, Decl(genericDefaults.ts, 3, 26)) + +f10(a); +>f10 : Symbol(f10, Decl(genericDefaults.ts, 177, 18)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>AB : Symbol(AB, Decl(genericDefaults.ts, 3, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f10(a, ab); +>f10 : Symbol(f10, Decl(genericDefaults.ts, 177, 18)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>AB : Symbol(AB, Decl(genericDefaults.ts, 3, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>ab : Symbol(ab, Decl(genericDefaults.ts, 11, 13)) + +// function with a type parameter with a default that refers to an earier type parameter in a union +declare function f11(a?: T, b?: U): [T, U]; +>f11 : Symbol(f11, Decl(genericDefaults.ts, 198, 18)) +>T : Symbol(T, Decl(genericDefaults.ts, 201, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 201, 23)) +>T : Symbol(T, Decl(genericDefaults.ts, 201, 21)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 201, 35)) +>T : Symbol(T, Decl(genericDefaults.ts, 201, 21)) +>b : Symbol(b, Decl(genericDefaults.ts, 201, 41)) +>U : Symbol(U, Decl(genericDefaults.ts, 201, 23)) +>T : Symbol(T, Decl(genericDefaults.ts, 201, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 201, 23)) + +// inference +f11(); +>f11 : Symbol(f11, Decl(genericDefaults.ts, 198, 18)) + +f11(a); +>f11 : Symbol(f11, Decl(genericDefaults.ts, 198, 18)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f11(a, a); +>f11 : Symbol(f11, Decl(genericDefaults.ts, 198, 18)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f11(a, b); +>f11 : Symbol(f11, Decl(genericDefaults.ts, 198, 18)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f11(a, c); +>f11 : Symbol(f11, Decl(genericDefaults.ts, 198, 18)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// no inference, partially supplied +f11(); +>f11 : Symbol(f11, Decl(genericDefaults.ts, 198, 18)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f11(a); +>f11 : Symbol(f11, Decl(genericDefaults.ts, 198, 18)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f11(a, a); +>f11 : Symbol(f11, Decl(genericDefaults.ts, 198, 18)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f11(a, b); +>f11 : Symbol(f11, Decl(genericDefaults.ts, 198, 18)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +// no inference, fully supplied +f11(); +>f11 : Symbol(f11, Decl(genericDefaults.ts, 198, 18)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) + +f11(a); +>f11 : Symbol(f11, Decl(genericDefaults.ts, 198, 18)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f11(a, c); +>f11 : Symbol(f11, Decl(genericDefaults.ts, 198, 18)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// function with a type parameter with a default that refers to an earlier type parameter in an intersection +declare function f12(a?: T, b?: U): [T, U]; +>f12 : Symbol(f12, Decl(genericDefaults.ts, 216, 16)) +>T : Symbol(T, Decl(genericDefaults.ts, 219, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 219, 23)) +>T : Symbol(T, Decl(genericDefaults.ts, 219, 21)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 219, 35)) +>T : Symbol(T, Decl(genericDefaults.ts, 219, 21)) +>b : Symbol(b, Decl(genericDefaults.ts, 219, 41)) +>U : Symbol(U, Decl(genericDefaults.ts, 219, 23)) +>T : Symbol(T, Decl(genericDefaults.ts, 219, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 219, 23)) + +// inference +f12(); +>f12 : Symbol(f12, Decl(genericDefaults.ts, 216, 16)) + +f12(a); +>f12 : Symbol(f12, Decl(genericDefaults.ts, 216, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f12(a, a); +>f12 : Symbol(f12, Decl(genericDefaults.ts, 216, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f12(a, b); +>f12 : Symbol(f12, Decl(genericDefaults.ts, 216, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f12(a, c); +>f12 : Symbol(f12, Decl(genericDefaults.ts, 216, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// no inference, partially supplied +f12(); +>f12 : Symbol(f12, Decl(genericDefaults.ts, 216, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f12(a); +>f12 : Symbol(f12, Decl(genericDefaults.ts, 216, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f12(a, ab); +>f12 : Symbol(f12, Decl(genericDefaults.ts, 216, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>ab : Symbol(ab, Decl(genericDefaults.ts, 11, 13)) + +// no inference, fully supplied +f12(); +>f12 : Symbol(f12, Decl(genericDefaults.ts, 216, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) + +f12(a); +>f12 : Symbol(f12, Decl(genericDefaults.ts, 216, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f12(a, c); +>f12 : Symbol(f12, Decl(genericDefaults.ts, 216, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// function with a type parameter with a default that refers to a later type parameter with a default +declare function f13(a?: T, b?: U): [T, U]; +>f13 : Symbol(f13, Decl(genericDefaults.ts, 233, 16)) +>T : Symbol(T, Decl(genericDefaults.ts, 236, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 236, 27)) +>U : Symbol(U, Decl(genericDefaults.ts, 236, 27)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 236, 35)) +>T : Symbol(T, Decl(genericDefaults.ts, 236, 21)) +>b : Symbol(b, Decl(genericDefaults.ts, 236, 41)) +>U : Symbol(U, Decl(genericDefaults.ts, 236, 27)) +>T : Symbol(T, Decl(genericDefaults.ts, 236, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 236, 27)) + +// inference +f13(); +>f13 : Symbol(f13, Decl(genericDefaults.ts, 233, 16)) + +f13(a); +>f13 : Symbol(f13, Decl(genericDefaults.ts, 233, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f13(a, b); +>f13 : Symbol(f13, Decl(genericDefaults.ts, 233, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f13(a, c); +>f13 : Symbol(f13, Decl(genericDefaults.ts, 233, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// no inference, partially supplied +f13(); +>f13 : Symbol(f13, Decl(genericDefaults.ts, 233, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f13(a); +>f13 : Symbol(f13, Decl(genericDefaults.ts, 233, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f13(a, b); +>f13 : Symbol(f13, Decl(genericDefaults.ts, 233, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +// no inference, fully supplied +f13(); +>f13 : Symbol(f13, Decl(genericDefaults.ts, 233, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) + +f13(a); +>f13 : Symbol(f13, Decl(genericDefaults.ts, 233, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f13(a, c); +>f13 : Symbol(f13, Decl(genericDefaults.ts, 233, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +f13(a, c); +>f13 : Symbol(f13, Decl(genericDefaults.ts, 233, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// function with a type parameter without a default and a type parameter with a default that refers to a later type parameter with a default +declare function f14(a?: T, b?: U, c?: V): [T, U, V]; +>f14 : Symbol(f14, Decl(genericDefaults.ts, 250, 16)) +>T : Symbol(T, Decl(genericDefaults.ts, 253, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 253, 23)) +>V : Symbol(V, Decl(genericDefaults.ts, 253, 30)) +>V : Symbol(V, Decl(genericDefaults.ts, 253, 30)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 253, 38)) +>T : Symbol(T, Decl(genericDefaults.ts, 253, 21)) +>b : Symbol(b, Decl(genericDefaults.ts, 253, 44)) +>U : Symbol(U, Decl(genericDefaults.ts, 253, 23)) +>c : Symbol(c, Decl(genericDefaults.ts, 253, 51)) +>V : Symbol(V, Decl(genericDefaults.ts, 253, 30)) +>T : Symbol(T, Decl(genericDefaults.ts, 253, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 253, 23)) +>V : Symbol(V, Decl(genericDefaults.ts, 253, 30)) + +// inference +f14(); +>f14 : Symbol(f14, Decl(genericDefaults.ts, 250, 16)) + +f14(a); +>f14 : Symbol(f14, Decl(genericDefaults.ts, 250, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f14(a, b); +>f14 : Symbol(f14, Decl(genericDefaults.ts, 250, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f14(a, b, c); +>f14 : Symbol(f14, Decl(genericDefaults.ts, 250, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +f14(a, b, d); +>f14 : Symbol(f14, Decl(genericDefaults.ts, 250, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>d : Symbol(d, Decl(genericDefaults.ts, 10, 13)) + +// no inference, partially supplied +f14(); +>f14 : Symbol(f14, Decl(genericDefaults.ts, 250, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f14(a); +>f14 : Symbol(f14, Decl(genericDefaults.ts, 250, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f14(a, b); +>f14 : Symbol(f14, Decl(genericDefaults.ts, 250, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f14(a, b, c); +>f14 : Symbol(f14, Decl(genericDefaults.ts, 250, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +f14(); +>f14 : Symbol(f14, Decl(genericDefaults.ts, 250, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) + +f14(a); +>f14 : Symbol(f14, Decl(genericDefaults.ts, 250, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f14(a, b); +>f14 : Symbol(f14, Decl(genericDefaults.ts, 250, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f14(a, b, c); +>f14 : Symbol(f14, Decl(genericDefaults.ts, 250, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// no inference fully supplied +f14(); +>f14 : Symbol(f14, Decl(genericDefaults.ts, 250, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) + +f14(a); +>f14 : Symbol(f14, Decl(genericDefaults.ts, 250, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f14(a, b); +>f14 : Symbol(f14, Decl(genericDefaults.ts, 250, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f14(a, b, d); +>f14 : Symbol(f14, Decl(genericDefaults.ts, 250, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>d : Symbol(d, Decl(genericDefaults.ts, 10, 13)) + +// function with two type parameters with defaults that mutually refer to each other +declare function f15(a?: T, b?: U): [T, U]; +>f15 : Symbol(f15, Decl(genericDefaults.ts, 273, 22)) +>T : Symbol(T, Decl(genericDefaults.ts, 276, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 276, 27)) +>U : Symbol(U, Decl(genericDefaults.ts, 276, 27)) +>T : Symbol(T, Decl(genericDefaults.ts, 276, 21)) +>a : Symbol(a, Decl(genericDefaults.ts, 276, 35)) +>T : Symbol(T, Decl(genericDefaults.ts, 276, 21)) +>b : Symbol(b, Decl(genericDefaults.ts, 276, 41)) +>U : Symbol(U, Decl(genericDefaults.ts, 276, 27)) +>T : Symbol(T, Decl(genericDefaults.ts, 276, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 276, 27)) + +// inference +f15(); +>f15 : Symbol(f15, Decl(genericDefaults.ts, 273, 22)) + +f15(a); +>f15 : Symbol(f15, Decl(genericDefaults.ts, 273, 22)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f15(a, b); +>f15 : Symbol(f15, Decl(genericDefaults.ts, 273, 22)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +// no inference, partially supplied +f15(); +>f15 : Symbol(f15, Decl(genericDefaults.ts, 273, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f15(a); +>f15 : Symbol(f15, Decl(genericDefaults.ts, 273, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f15(a, a); +>f15 : Symbol(f15, Decl(genericDefaults.ts, 273, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +// no inference, fully supplied +f15(); +>f15 : Symbol(f15, Decl(genericDefaults.ts, 273, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) + +f15(a); +>f15 : Symbol(f15, Decl(genericDefaults.ts, 273, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f15(a, b); +>f15 : Symbol(f15, Decl(genericDefaults.ts, 273, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +// function with a type parameter without a default and two type parameters with defaults that mutually refer to each other +declare function f16(a?: T, b?: U, c?: V): [T, U, V]; +>f16 : Symbol(f16, Decl(genericDefaults.ts, 288, 16)) +>T : Symbol(T, Decl(genericDefaults.ts, 291, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 291, 23)) +>V : Symbol(V, Decl(genericDefaults.ts, 291, 30)) +>V : Symbol(V, Decl(genericDefaults.ts, 291, 30)) +>U : Symbol(U, Decl(genericDefaults.ts, 291, 23)) +>a : Symbol(a, Decl(genericDefaults.ts, 291, 38)) +>T : Symbol(T, Decl(genericDefaults.ts, 291, 21)) +>b : Symbol(b, Decl(genericDefaults.ts, 291, 44)) +>U : Symbol(U, Decl(genericDefaults.ts, 291, 23)) +>c : Symbol(c, Decl(genericDefaults.ts, 291, 51)) +>V : Symbol(V, Decl(genericDefaults.ts, 291, 30)) +>T : Symbol(T, Decl(genericDefaults.ts, 291, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 291, 23)) +>V : Symbol(V, Decl(genericDefaults.ts, 291, 30)) + +// no inference +f16(); +>f16 : Symbol(f16, Decl(genericDefaults.ts, 288, 16)) + +f16(a); +>f16 : Symbol(f16, Decl(genericDefaults.ts, 288, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f16(a, b); +>f16 : Symbol(f16, Decl(genericDefaults.ts, 288, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f16(a, b, b); +>f16 : Symbol(f16, Decl(genericDefaults.ts, 288, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +// no inference, partially supplied +f16(); +>f16 : Symbol(f16, Decl(genericDefaults.ts, 288, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f16(a); +>f16 : Symbol(f16, Decl(genericDefaults.ts, 288, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f16(a, b); +>f16 : Symbol(f16, Decl(genericDefaults.ts, 288, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f16(a, b, b); +>f16 : Symbol(f16, Decl(genericDefaults.ts, 288, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f16(); +>f16 : Symbol(f16, Decl(genericDefaults.ts, 288, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) + +f16(a); +>f16 : Symbol(f16, Decl(genericDefaults.ts, 288, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f16(a, b); +>f16 : Symbol(f16, Decl(genericDefaults.ts, 288, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f16(a, b, b); +>f16 : Symbol(f16, Decl(genericDefaults.ts, 288, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +// no inference, fully supplied +f16(); +>f16 : Symbol(f16, Decl(genericDefaults.ts, 288, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) + +f16(a); +>f16 : Symbol(f16, Decl(genericDefaults.ts, 288, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f16(a, b); +>f16 : Symbol(f16, Decl(genericDefaults.ts, 288, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f16(a, b, d); +>f16 : Symbol(f16, Decl(genericDefaults.ts, 288, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>d : Symbol(d, Decl(genericDefaults.ts, 10, 13)) + +// function with a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in a union +declare function f17(a?: T, b?: U): [T, U]; +>f17 : Symbol(f17, Decl(genericDefaults.ts, 310, 22)) +>T : Symbol(T, Decl(genericDefaults.ts, 313, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 313, 27)) +>U : Symbol(U, Decl(genericDefaults.ts, 313, 27)) +>T : Symbol(T, Decl(genericDefaults.ts, 313, 21)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 313, 39)) +>T : Symbol(T, Decl(genericDefaults.ts, 313, 21)) +>b : Symbol(b, Decl(genericDefaults.ts, 313, 45)) +>U : Symbol(U, Decl(genericDefaults.ts, 313, 27)) +>T : Symbol(T, Decl(genericDefaults.ts, 313, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 313, 27)) + +// inference +f17(); +>f17 : Symbol(f17, Decl(genericDefaults.ts, 310, 22)) + +f17(a); +>f17 : Symbol(f17, Decl(genericDefaults.ts, 310, 22)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f17(a, a); +>f17 : Symbol(f17, Decl(genericDefaults.ts, 310, 22)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f17(a, b); +>f17 : Symbol(f17, Decl(genericDefaults.ts, 310, 22)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f17(a, c); +>f17 : Symbol(f17, Decl(genericDefaults.ts, 310, 22)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// no inference, partially supplied +f17(); +>f17 : Symbol(f17, Decl(genericDefaults.ts, 310, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f17(a); +>f17 : Symbol(f17, Decl(genericDefaults.ts, 310, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f17(a, a); +>f17 : Symbol(f17, Decl(genericDefaults.ts, 310, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f17(a, b); +>f17 : Symbol(f17, Decl(genericDefaults.ts, 310, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +// no inference, fully supplied +f17(); +>f17 : Symbol(f17, Decl(genericDefaults.ts, 310, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) + +f17(a); +>f17 : Symbol(f17, Decl(genericDefaults.ts, 310, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f17(a, c); +>f17 : Symbol(f17, Decl(genericDefaults.ts, 310, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// function with a type parameter without a default and a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in a union +declare function f18(a?: T, b?: U, c?: V): [T, U, V]; +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>T : Symbol(T, Decl(genericDefaults.ts, 331, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 331, 23)) +>V : Symbol(V, Decl(genericDefaults.ts, 331, 30)) +>V : Symbol(V, Decl(genericDefaults.ts, 331, 30)) +>U : Symbol(U, Decl(genericDefaults.ts, 331, 23)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 331, 42)) +>T : Symbol(T, Decl(genericDefaults.ts, 331, 21)) +>b : Symbol(b, Decl(genericDefaults.ts, 331, 48)) +>U : Symbol(U, Decl(genericDefaults.ts, 331, 23)) +>c : Symbol(c, Decl(genericDefaults.ts, 331, 55)) +>V : Symbol(V, Decl(genericDefaults.ts, 331, 30)) +>T : Symbol(T, Decl(genericDefaults.ts, 331, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 331, 23)) +>V : Symbol(V, Decl(genericDefaults.ts, 331, 30)) + +// inference +f18(); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) + +f18(a); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f18(a, b); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f18(a, b, b); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f18(a, b, c); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// no inference, partially supplied +f18(); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f18(a); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f18(a, b); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f18(a, b, b); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f18(a, b, c); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +f18(); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) + +f18(a); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f18(a, b); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f18(a, b, b); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f18(a, b, c); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// no inference, fully supplied +f18(); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) + +f18(a); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f18(a, b); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f18(a, b, d); +>f18 : Symbol(f18, Decl(genericDefaults.ts, 328, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>d : Symbol(d, Decl(genericDefaults.ts, 10, 13)) + +// function with a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in an intersection +declare function f19(a?: T, b?: U): [T, U]; +>f19 : Symbol(f19, Decl(genericDefaults.ts, 353, 22)) +>T : Symbol(T, Decl(genericDefaults.ts, 356, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 356, 27)) +>U : Symbol(U, Decl(genericDefaults.ts, 356, 27)) +>T : Symbol(T, Decl(genericDefaults.ts, 356, 21)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 356, 39)) +>T : Symbol(T, Decl(genericDefaults.ts, 356, 21)) +>b : Symbol(b, Decl(genericDefaults.ts, 356, 45)) +>U : Symbol(U, Decl(genericDefaults.ts, 356, 27)) +>T : Symbol(T, Decl(genericDefaults.ts, 356, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 356, 27)) + +// inference +f19(); +>f19 : Symbol(f19, Decl(genericDefaults.ts, 353, 22)) + +f19(a); +>f19 : Symbol(f19, Decl(genericDefaults.ts, 353, 22)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f19(a, a); +>f19 : Symbol(f19, Decl(genericDefaults.ts, 353, 22)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f19(a, b); +>f19 : Symbol(f19, Decl(genericDefaults.ts, 353, 22)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f19(a, ab); +>f19 : Symbol(f19, Decl(genericDefaults.ts, 353, 22)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>ab : Symbol(ab, Decl(genericDefaults.ts, 11, 13)) + +f19(a, c); +>f19 : Symbol(f19, Decl(genericDefaults.ts, 353, 22)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// no inference, partially supplied +f19(); +>f19 : Symbol(f19, Decl(genericDefaults.ts, 353, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f19(a); +>f19 : Symbol(f19, Decl(genericDefaults.ts, 353, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f19(a, ab); +>f19 : Symbol(f19, Decl(genericDefaults.ts, 353, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>ab : Symbol(ab, Decl(genericDefaults.ts, 11, 13)) + +// no inference, fully supplied +f19(); +>f19 : Symbol(f19, Decl(genericDefaults.ts, 353, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) + +f19(a); +>f19 : Symbol(f19, Decl(genericDefaults.ts, 353, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f19(a, c); +>f19 : Symbol(f19, Decl(genericDefaults.ts, 353, 22)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// function with a type parameter without a default and a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in an intersection +declare function f20(a?: T, b?: U, c?: V): [T, U, V]; +>f20 : Symbol(f20, Decl(genericDefaults.ts, 371, 16)) +>T : Symbol(T, Decl(genericDefaults.ts, 374, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 374, 23)) +>V : Symbol(V, Decl(genericDefaults.ts, 374, 30)) +>V : Symbol(V, Decl(genericDefaults.ts, 374, 30)) +>U : Symbol(U, Decl(genericDefaults.ts, 374, 23)) +>C : Symbol(C, Decl(genericDefaults.ts, 1, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 374, 42)) +>T : Symbol(T, Decl(genericDefaults.ts, 374, 21)) +>b : Symbol(b, Decl(genericDefaults.ts, 374, 48)) +>U : Symbol(U, Decl(genericDefaults.ts, 374, 23)) +>c : Symbol(c, Decl(genericDefaults.ts, 374, 55)) +>V : Symbol(V, Decl(genericDefaults.ts, 374, 30)) +>T : Symbol(T, Decl(genericDefaults.ts, 374, 21)) +>U : Symbol(U, Decl(genericDefaults.ts, 374, 23)) +>V : Symbol(V, Decl(genericDefaults.ts, 374, 30)) + +// inference +f20(); +>f20 : Symbol(f20, Decl(genericDefaults.ts, 371, 16)) + +f20(a); +>f20 : Symbol(f20, Decl(genericDefaults.ts, 371, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f20(a, b); +>f20 : Symbol(f20, Decl(genericDefaults.ts, 371, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f20(a, b, c); +>f20 : Symbol(f20, Decl(genericDefaults.ts, 371, 16)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>c : Symbol(c, Decl(genericDefaults.ts, 9, 13)) + +// no inference, partially supplied +f20(); +>f20 : Symbol(f20, Decl(genericDefaults.ts, 371, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +f20(a); +>f20 : Symbol(f20, Decl(genericDefaults.ts, 371, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f20(a, b); +>f20 : Symbol(f20, Decl(genericDefaults.ts, 371, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f20(a, b, bc); +>f20 : Symbol(f20, Decl(genericDefaults.ts, 371, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>bc : Symbol(bc, Decl(genericDefaults.ts, 12, 13)) + +f20(); +>f20 : Symbol(f20, Decl(genericDefaults.ts, 371, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) + +f20(a); +>f20 : Symbol(f20, Decl(genericDefaults.ts, 371, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f20(a, b); +>f20 : Symbol(f20, Decl(genericDefaults.ts, 371, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f20(a, b, bc); +>f20 : Symbol(f20, Decl(genericDefaults.ts, 371, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>bc : Symbol(bc, Decl(genericDefaults.ts, 12, 13)) + +// no inference, fully supplied +f20(); +>f20 : Symbol(f20, Decl(genericDefaults.ts, 371, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) + +f20(a); +>f20 : Symbol(f20, Decl(genericDefaults.ts, 371, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) + +f20(a, b); +>f20 : Symbol(f20, Decl(genericDefaults.ts, 371, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) + +f20(a, b, d); +>f20 : Symbol(f20, Decl(genericDefaults.ts, 371, 16)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>D : Symbol(D, Decl(genericDefaults.ts, 2, 26)) +>a : Symbol(a, Decl(genericDefaults.ts, 7, 13)) +>b : Symbol(b, Decl(genericDefaults.ts, 8, 13)) +>d : Symbol(d, Decl(genericDefaults.ts, 10, 13)) + +interface i00 { a: T; } +>i00 : Symbol(i00, Decl(genericDefaults.ts, 393, 22)) +>T : Symbol(T, Decl(genericDefaults.ts, 395, 14)) +>a : Symbol(i00.a, Decl(genericDefaults.ts, 395, 27)) +>T : Symbol(T, Decl(genericDefaults.ts, 395, 14)) + +const i00c00 = (x).a; +>i00c00 : Symbol(i00c00, Decl(genericDefaults.ts, 396, 5)) +>(x).a : Symbol(i00.a, Decl(genericDefaults.ts, 395, 27)) +>i00 : Symbol(i00, Decl(genericDefaults.ts, 393, 22)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i00.a, Decl(genericDefaults.ts, 395, 27)) + +const i00c01 = (>x).a; +>i00c01 : Symbol(i00c01, Decl(genericDefaults.ts, 397, 5)) +>(>x).a : Symbol(i00.a, Decl(genericDefaults.ts, 395, 27)) +>i00 : Symbol(i00, Decl(genericDefaults.ts, 393, 22)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i00.a, Decl(genericDefaults.ts, 395, 27)) + +interface i01 { a: [T, U]; } +>i01 : Symbol(i01, Decl(genericDefaults.ts, 397, 34)) +>T : Symbol(T, Decl(genericDefaults.ts, 399, 14)) +>U : Symbol(U, Decl(genericDefaults.ts, 399, 16)) +>T : Symbol(T, Decl(genericDefaults.ts, 399, 14)) +>a : Symbol(i01.a, Decl(genericDefaults.ts, 399, 25)) +>T : Symbol(T, Decl(genericDefaults.ts, 399, 14)) +>U : Symbol(U, Decl(genericDefaults.ts, 399, 16)) + +const i01c00 = (>x).a; +>i01c00 : Symbol(i01c00, Decl(genericDefaults.ts, 400, 5)) +>(>x).a : Symbol(i01.a, Decl(genericDefaults.ts, 399, 25)) +>i01 : Symbol(i01, Decl(genericDefaults.ts, 397, 34)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i01.a, Decl(genericDefaults.ts, 399, 25)) + +const i01c01 = (>x).a; +>i01c01 : Symbol(i01c01, Decl(genericDefaults.ts, 401, 5)) +>(>x).a : Symbol(i01.a, Decl(genericDefaults.ts, 399, 25)) +>i01 : Symbol(i01, Decl(genericDefaults.ts, 397, 34)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i01.a, Decl(genericDefaults.ts, 399, 25)) + +interface i02 { a: [T, U]; } +>i02 : Symbol(i02, Decl(genericDefaults.ts, 401, 42)) +>T : Symbol(T, Decl(genericDefaults.ts, 403, 14)) +>U : Symbol(U, Decl(genericDefaults.ts, 403, 31)) +>T : Symbol(T, Decl(genericDefaults.ts, 403, 14)) +>a : Symbol(i02.a, Decl(genericDefaults.ts, 403, 40)) +>T : Symbol(T, Decl(genericDefaults.ts, 403, 14)) +>U : Symbol(U, Decl(genericDefaults.ts, 403, 31)) + +const i02c00 = (>x).a; +>i02c00 : Symbol(i02c00, Decl(genericDefaults.ts, 404, 5)) +>(>x).a : Symbol(i02.a, Decl(genericDefaults.ts, 403, 40)) +>i02 : Symbol(i02, Decl(genericDefaults.ts, 401, 42)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i02.a, Decl(genericDefaults.ts, 403, 40)) + +const i02c01 = (>x).a; +>i02c01 : Symbol(i02c01, Decl(genericDefaults.ts, 405, 5)) +>(>x).a : Symbol(i02.a, Decl(genericDefaults.ts, 403, 40)) +>i02 : Symbol(i02, Decl(genericDefaults.ts, 401, 42)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i02.a, Decl(genericDefaults.ts, 403, 40)) + +const i02c02 = (>x).a; +>i02c02 : Symbol(i02c02, Decl(genericDefaults.ts, 406, 5)) +>(>x).a : Symbol(i02.a, Decl(genericDefaults.ts, 403, 40)) +>i02 : Symbol(i02, Decl(genericDefaults.ts, 401, 42)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i02.a, Decl(genericDefaults.ts, 403, 40)) + +const i02c03 = (>x).a; +>i02c03 : Symbol(i02c03, Decl(genericDefaults.ts, 407, 5)) +>(>x).a : Symbol(i02.a, Decl(genericDefaults.ts, 403, 40)) +>i02 : Symbol(i02, Decl(genericDefaults.ts, 401, 42)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i02.a, Decl(genericDefaults.ts, 403, 40)) + +const i02c04 = (>x).a; +>i02c04 : Symbol(i02c04, Decl(genericDefaults.ts, 408, 5)) +>(>x).a : Symbol(i02.a, Decl(genericDefaults.ts, 403, 40)) +>i02 : Symbol(i02, Decl(genericDefaults.ts, 401, 42)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i02.a, Decl(genericDefaults.ts, 403, 40)) + +interface i03 { a: [T, U]; } +>i03 : Symbol(i03, Decl(genericDefaults.ts, 408, 37)) +>T : Symbol(T, Decl(genericDefaults.ts, 410, 14)) +>U : Symbol(U, Decl(genericDefaults.ts, 410, 31)) +>T : Symbol(T, Decl(genericDefaults.ts, 410, 14)) +>T : Symbol(T, Decl(genericDefaults.ts, 410, 14)) +>a : Symbol(i03.a, Decl(genericDefaults.ts, 410, 50)) +>T : Symbol(T, Decl(genericDefaults.ts, 410, 14)) +>U : Symbol(U, Decl(genericDefaults.ts, 410, 31)) + +const i03c00 = (>x).a; +>i03c00 : Symbol(i03c00, Decl(genericDefaults.ts, 411, 5)) +>(>x).a : Symbol(i03.a, Decl(genericDefaults.ts, 410, 50)) +>i03 : Symbol(i03, Decl(genericDefaults.ts, 408, 37)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i03.a, Decl(genericDefaults.ts, 410, 50)) + +const i03c01 = (>x).a; +>i03c01 : Symbol(i03c01, Decl(genericDefaults.ts, 412, 5)) +>(>x).a : Symbol(i03.a, Decl(genericDefaults.ts, 410, 50)) +>i03 : Symbol(i03, Decl(genericDefaults.ts, 408, 37)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i03.a, Decl(genericDefaults.ts, 410, 50)) + +const i03c02 = (>x).a; +>i03c02 : Symbol(i03c02, Decl(genericDefaults.ts, 413, 5)) +>(>x).a : Symbol(i03.a, Decl(genericDefaults.ts, 410, 50)) +>i03 : Symbol(i03, Decl(genericDefaults.ts, 408, 37)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i03.a, Decl(genericDefaults.ts, 410, 50)) + +const i03c03 = (>x).a; +>i03c03 : Symbol(i03c03, Decl(genericDefaults.ts, 414, 5)) +>(>x).a : Symbol(i03.a, Decl(genericDefaults.ts, 410, 50)) +>i03 : Symbol(i03, Decl(genericDefaults.ts, 408, 37)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i03.a, Decl(genericDefaults.ts, 410, 50)) + +const i03c04 = (>x).a; +>i03c04 : Symbol(i03c04, Decl(genericDefaults.ts, 415, 5)) +>(>x).a : Symbol(i03.a, Decl(genericDefaults.ts, 410, 50)) +>i03 : Symbol(i03, Decl(genericDefaults.ts, 408, 37)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i03.a, Decl(genericDefaults.ts, 410, 50)) + +interface i04 {} +>i04 : Symbol(i04, Decl(genericDefaults.ts, 415, 37), Decl(genericDefaults.ts, 417, 16), Decl(genericDefaults.ts, 418, 19), Decl(genericDefaults.ts, 419, 28)) + +interface i04 {} +>i04 : Symbol(i04, Decl(genericDefaults.ts, 415, 37), Decl(genericDefaults.ts, 417, 16), Decl(genericDefaults.ts, 418, 19), Decl(genericDefaults.ts, 419, 28)) +>T : Symbol(T, Decl(genericDefaults.ts, 418, 14), Decl(genericDefaults.ts, 419, 14), Decl(genericDefaults.ts, 420, 14)) + +interface i04 {} +>i04 : Symbol(i04, Decl(genericDefaults.ts, 415, 37), Decl(genericDefaults.ts, 417, 16), Decl(genericDefaults.ts, 418, 19), Decl(genericDefaults.ts, 419, 28)) +>T : Symbol(T, Decl(genericDefaults.ts, 418, 14), Decl(genericDefaults.ts, 419, 14), Decl(genericDefaults.ts, 420, 14)) + +interface i04 {} +>i04 : Symbol(i04, Decl(genericDefaults.ts, 415, 37), Decl(genericDefaults.ts, 417, 16), Decl(genericDefaults.ts, 418, 19), Decl(genericDefaults.ts, 419, 28)) +>T : Symbol(T, Decl(genericDefaults.ts, 418, 14), Decl(genericDefaults.ts, 419, 14), Decl(genericDefaults.ts, 420, 14)) +>U : Symbol(U, Decl(genericDefaults.ts, 420, 25)) + +interface i05 { a: T; } +>i05 : Symbol(i05, Decl(genericDefaults.ts, 420, 40)) +>T : Symbol(T, Decl(genericDefaults.ts, 422, 14)) +>T : Symbol(T, Decl(genericDefaults.ts, 422, 14)) +>a : Symbol(i05.a, Decl(genericDefaults.ts, 422, 22)) +>T : Symbol(T, Decl(genericDefaults.ts, 422, 14)) + +const i05c00 = (x).a; +>i05c00 : Symbol(i05c00, Decl(genericDefaults.ts, 423, 5)) +>(x).a : Symbol(i05.a, Decl(genericDefaults.ts, 422, 22)) +>i05 : Symbol(i05, Decl(genericDefaults.ts, 420, 40)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i05.a, Decl(genericDefaults.ts, 422, 22)) + +const i05c01 = (>x).a; +>i05c01 : Symbol(i05c01, Decl(genericDefaults.ts, 424, 5)) +>(>x).a : Symbol(i05.a, Decl(genericDefaults.ts, 422, 22)) +>i05 : Symbol(i05, Decl(genericDefaults.ts, 420, 40)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i05.a, Decl(genericDefaults.ts, 422, 22)) + +interface i06 { a: [T, U]; } +>i06 : Symbol(i06, Decl(genericDefaults.ts, 424, 34)) +>T : Symbol(T, Decl(genericDefaults.ts, 426, 14)) +>U : Symbol(U, Decl(genericDefaults.ts, 426, 20)) +>U : Symbol(U, Decl(genericDefaults.ts, 426, 20)) +>T : Symbol(T, Decl(genericDefaults.ts, 426, 14)) +>a : Symbol(i06.a, Decl(genericDefaults.ts, 426, 29)) +>T : Symbol(T, Decl(genericDefaults.ts, 426, 14)) +>U : Symbol(U, Decl(genericDefaults.ts, 426, 20)) + +const i06c00 = (x).a; +>i06c00 : Symbol(i06c00, Decl(genericDefaults.ts, 427, 5)) +>(x).a : Symbol(i06.a, Decl(genericDefaults.ts, 426, 29)) +>i06 : Symbol(i06, Decl(genericDefaults.ts, 424, 34)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i06.a, Decl(genericDefaults.ts, 426, 29)) + +const i06c01 = (>x).a; +>i06c01 : Symbol(i06c01, Decl(genericDefaults.ts, 428, 5)) +>(>x).a : Symbol(i06.a, Decl(genericDefaults.ts, 426, 29)) +>i06 : Symbol(i06, Decl(genericDefaults.ts, 424, 34)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i06.a, Decl(genericDefaults.ts, 426, 29)) + +const i06c02 = (>x).a; +>i06c02 : Symbol(i06c02, Decl(genericDefaults.ts, 429, 5)) +>(>x).a : Symbol(i06.a, Decl(genericDefaults.ts, 426, 29)) +>i06 : Symbol(i06, Decl(genericDefaults.ts, 424, 34)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i06.a, Decl(genericDefaults.ts, 426, 29)) + +interface i07 { a: A; } +>i07 : Symbol(i07, Decl(genericDefaults.ts, 429, 42), Decl(genericDefaults.ts, 431, 23)) +>a : Symbol(i07.a, Decl(genericDefaults.ts, 431, 15)) +>A : Symbol(A, Decl(genericDefaults.ts, 0, 0)) + +interface i07 { b: A; } +>i07 : Symbol(i07, Decl(genericDefaults.ts, 429, 42), Decl(genericDefaults.ts, 431, 23)) +>A : Symbol(A, Decl(genericDefaults.ts, 432, 14)) +>b : Symbol(i07.b, Decl(genericDefaults.ts, 432, 27)) +>A : Symbol(A, Decl(genericDefaults.ts, 432, 14)) + +const i07c00 = (x).a; +>i07c00 : Symbol(i07c00, Decl(genericDefaults.ts, 433, 5)) +>(x).a : Symbol(i07.a, Decl(genericDefaults.ts, 431, 15)) +>i07 : Symbol(i07, Decl(genericDefaults.ts, 429, 42), Decl(genericDefaults.ts, 431, 23)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i07.a, Decl(genericDefaults.ts, 431, 15)) + +const i07c01 = (x).b; +>i07c01 : Symbol(i07c01, Decl(genericDefaults.ts, 434, 5)) +>(x).b : Symbol(i07.b, Decl(genericDefaults.ts, 432, 27)) +>i07 : Symbol(i07, Decl(genericDefaults.ts, 429, 42), Decl(genericDefaults.ts, 431, 23)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>b : Symbol(i07.b, Decl(genericDefaults.ts, 432, 27)) + +const i07c02 = (>x).a; +>i07c02 : Symbol(i07c02, Decl(genericDefaults.ts, 435, 5)) +>(>x).a : Symbol(i07.a, Decl(genericDefaults.ts, 431, 15)) +>i07 : Symbol(i07, Decl(genericDefaults.ts, 429, 42), Decl(genericDefaults.ts, 431, 23)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(i07.a, Decl(genericDefaults.ts, 431, 15)) + +const i07c03 = (>x).b; +>i07c03 : Symbol(i07c03, Decl(genericDefaults.ts, 436, 5)) +>(>x).b : Symbol(i07.b, Decl(genericDefaults.ts, 432, 27)) +>i07 : Symbol(i07, Decl(genericDefaults.ts, 429, 42), Decl(genericDefaults.ts, 431, 23)) +>B : Symbol(B, Decl(genericDefaults.ts, 0, 26)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>b : Symbol(i07.b, Decl(genericDefaults.ts, 432, 27)) + +interface Base01 { a: T; } +>Base01 : Symbol(Base01, Decl(genericDefaults.ts, 436, 29), Decl(genericDefaults.ts, 441, 13)) +>T : Symbol(T, Decl(genericDefaults.ts, 438, 17)) +>a : Symbol(Base01.a, Decl(genericDefaults.ts, 438, 21)) +>T : Symbol(T, Decl(genericDefaults.ts, 438, 17)) + +interface Base01Constructor { new (a?: T): Base01; } +>Base01Constructor : Symbol(Base01Constructor, Decl(genericDefaults.ts, 438, 29)) +>T : Symbol(T, Decl(genericDefaults.ts, 439, 35)) +>a : Symbol(a, Decl(genericDefaults.ts, 439, 47)) +>T : Symbol(T, Decl(genericDefaults.ts, 439, 35)) +>Base01 : Symbol(Base01, Decl(genericDefaults.ts, 436, 29), Decl(genericDefaults.ts, 441, 13)) +>T : Symbol(T, Decl(genericDefaults.ts, 439, 35)) + +declare const Base01: Base01Constructor; +>Base01 : Symbol(Base01, Decl(genericDefaults.ts, 436, 29), Decl(genericDefaults.ts, 441, 13)) +>Base01Constructor : Symbol(Base01Constructor, Decl(genericDefaults.ts, 438, 29)) + +const Base01c00 = new Base01(); +>Base01c00 : Symbol(Base01c00, Decl(genericDefaults.ts, 442, 5)) +>Base01 : Symbol(Base01, Decl(genericDefaults.ts, 436, 29), Decl(genericDefaults.ts, 441, 13)) + +const Base01c01 = new Base01(1); +>Base01c01 : Symbol(Base01c01, Decl(genericDefaults.ts, 443, 5)) +>Base01 : Symbol(Base01, Decl(genericDefaults.ts, 436, 29), Decl(genericDefaults.ts, 441, 13)) + +const Base01c02 = new Base01(); +>Base01c02 : Symbol(Base01c02, Decl(genericDefaults.ts, 444, 5)) +>Base01 : Symbol(Base01, Decl(genericDefaults.ts, 436, 29), Decl(genericDefaults.ts, 441, 13)) + +const Base01c03 = new Base01(1); +>Base01c03 : Symbol(Base01c03, Decl(genericDefaults.ts, 445, 5)) +>Base01 : Symbol(Base01, Decl(genericDefaults.ts, 436, 29), Decl(genericDefaults.ts, 441, 13)) + +declare class Derived01 extends Base01 { } +>Derived01 : Symbol(Derived01, Decl(genericDefaults.ts, 445, 40)) +>T : Symbol(T, Decl(genericDefaults.ts, 447, 24)) +>Base01 : Symbol(Base01, Decl(genericDefaults.ts, 436, 29), Decl(genericDefaults.ts, 441, 13)) +>T : Symbol(T, Decl(genericDefaults.ts, 447, 24)) + +const Derived01c00 = new Derived01(); +>Derived01c00 : Symbol(Derived01c00, Decl(genericDefaults.ts, 448, 5)) +>Derived01 : Symbol(Derived01, Decl(genericDefaults.ts, 445, 40)) + +const Derived01c01 = new Derived01(1); +>Derived01c01 : Symbol(Derived01c01, Decl(genericDefaults.ts, 449, 5)) +>Derived01 : Symbol(Derived01, Decl(genericDefaults.ts, 445, 40)) + +const Derived01c02 = new Derived01(); +>Derived01c02 : Symbol(Derived01c02, Decl(genericDefaults.ts, 450, 5)) +>Derived01 : Symbol(Derived01, Decl(genericDefaults.ts, 445, 40)) + +const Derived01c03 = new Derived01(1); +>Derived01c03 : Symbol(Derived01c03, Decl(genericDefaults.ts, 451, 5)) +>Derived01 : Symbol(Derived01, Decl(genericDefaults.ts, 445, 40)) + +declare class Derived02 extends Base01 { } +>Derived02 : Symbol(Derived02, Decl(genericDefaults.ts, 451, 46)) +>T : Symbol(T, Decl(genericDefaults.ts, 453, 24)) +>Base01 : Symbol(Base01, Decl(genericDefaults.ts, 436, 29), Decl(genericDefaults.ts, 441, 13)) +>T : Symbol(T, Decl(genericDefaults.ts, 453, 24)) + +const Derived02c00 = new Derived02(); +>Derived02c00 : Symbol(Derived02c00, Decl(genericDefaults.ts, 454, 5)) +>Derived02 : Symbol(Derived02, Decl(genericDefaults.ts, 451, 46)) + +const Derived02c01 = new Derived02(1); +>Derived02c01 : Symbol(Derived02c01, Decl(genericDefaults.ts, 455, 5)) +>Derived02 : Symbol(Derived02, Decl(genericDefaults.ts, 451, 46)) + +const Derived02c02 = new Derived02(); +>Derived02c02 : Symbol(Derived02c02, Decl(genericDefaults.ts, 456, 5)) +>Derived02 : Symbol(Derived02, Decl(genericDefaults.ts, 451, 46)) + +const Derived02c03 = new Derived02(1); +>Derived02c03 : Symbol(Derived02c03, Decl(genericDefaults.ts, 457, 5)) +>Derived02 : Symbol(Derived02, Decl(genericDefaults.ts, 451, 46)) + +type t00 = { a: T; } +>t00 : Symbol(t00, Decl(genericDefaults.ts, 457, 46)) +>T : Symbol(T, Decl(genericDefaults.ts, 459, 9)) +>a : Symbol(a, Decl(genericDefaults.ts, 459, 24)) +>T : Symbol(T, Decl(genericDefaults.ts, 459, 9)) + +const t00c00 = (x).a; +>t00c00 : Symbol(t00c00, Decl(genericDefaults.ts, 460, 5)) +>(x).a : Symbol(a, Decl(genericDefaults.ts, 459, 24)) +>t00 : Symbol(t00, Decl(genericDefaults.ts, 457, 46)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 459, 24)) + +const t00c01 = (>x).a; +>t00c01 : Symbol(t00c01, Decl(genericDefaults.ts, 461, 5)) +>(>x).a : Symbol(a, Decl(genericDefaults.ts, 459, 24)) +>t00 : Symbol(t00, Decl(genericDefaults.ts, 457, 46)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 459, 24)) + +type t01 = { a: [T, U]; } +>t01 : Symbol(t01, Decl(genericDefaults.ts, 461, 34)) +>T : Symbol(T, Decl(genericDefaults.ts, 463, 9)) +>U : Symbol(U, Decl(genericDefaults.ts, 463, 11)) +>T : Symbol(T, Decl(genericDefaults.ts, 463, 9)) +>a : Symbol(a, Decl(genericDefaults.ts, 463, 22)) +>T : Symbol(T, Decl(genericDefaults.ts, 463, 9)) +>U : Symbol(U, Decl(genericDefaults.ts, 463, 11)) + +const t01c00 = (>x).a; +>t01c00 : Symbol(t01c00, Decl(genericDefaults.ts, 464, 5)) +>(>x).a : Symbol(a, Decl(genericDefaults.ts, 463, 22)) +>t01 : Symbol(t01, Decl(genericDefaults.ts, 461, 34)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 463, 22)) + +const t01c01 = (>x).a; +>t01c01 : Symbol(t01c01, Decl(genericDefaults.ts, 465, 5)) +>(>x).a : Symbol(a, Decl(genericDefaults.ts, 463, 22)) +>t01 : Symbol(t01, Decl(genericDefaults.ts, 461, 34)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 463, 22)) + +type t02 = { a: [T, U]; } +>t02 : Symbol(t02, Decl(genericDefaults.ts, 465, 42)) +>T : Symbol(T, Decl(genericDefaults.ts, 467, 9)) +>U : Symbol(U, Decl(genericDefaults.ts, 467, 26)) +>T : Symbol(T, Decl(genericDefaults.ts, 467, 9)) +>a : Symbol(a, Decl(genericDefaults.ts, 467, 37)) +>T : Symbol(T, Decl(genericDefaults.ts, 467, 9)) +>U : Symbol(U, Decl(genericDefaults.ts, 467, 26)) + +const t02c00 = (>x).a; +>t02c00 : Symbol(t02c00, Decl(genericDefaults.ts, 468, 5)) +>(>x).a : Symbol(a, Decl(genericDefaults.ts, 467, 37)) +>t02 : Symbol(t02, Decl(genericDefaults.ts, 465, 42)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 467, 37)) + +const t02c01 = (>x).a; +>t02c01 : Symbol(t02c01, Decl(genericDefaults.ts, 469, 5)) +>(>x).a : Symbol(a, Decl(genericDefaults.ts, 467, 37)) +>t02 : Symbol(t02, Decl(genericDefaults.ts, 465, 42)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 467, 37)) + +const t02c02 = (>x).a; +>t02c02 : Symbol(t02c02, Decl(genericDefaults.ts, 470, 5)) +>(>x).a : Symbol(a, Decl(genericDefaults.ts, 467, 37)) +>t02 : Symbol(t02, Decl(genericDefaults.ts, 465, 42)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 467, 37)) + +const t02c03 = (>x).a; +>t02c03 : Symbol(t02c03, Decl(genericDefaults.ts, 471, 5)) +>(>x).a : Symbol(a, Decl(genericDefaults.ts, 467, 37)) +>t02 : Symbol(t02, Decl(genericDefaults.ts, 465, 42)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 467, 37)) + +const t02c04 = (>x).a; +>t02c04 : Symbol(t02c04, Decl(genericDefaults.ts, 472, 5)) +>(>x).a : Symbol(a, Decl(genericDefaults.ts, 467, 37)) +>t02 : Symbol(t02, Decl(genericDefaults.ts, 465, 42)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 467, 37)) + +type t03 = { a: [T, U]; } +>t03 : Symbol(t03, Decl(genericDefaults.ts, 472, 37)) +>T : Symbol(T, Decl(genericDefaults.ts, 474, 9)) +>U : Symbol(U, Decl(genericDefaults.ts, 474, 26)) +>T : Symbol(T, Decl(genericDefaults.ts, 474, 9)) +>T : Symbol(T, Decl(genericDefaults.ts, 474, 9)) +>a : Symbol(a, Decl(genericDefaults.ts, 474, 47)) +>T : Symbol(T, Decl(genericDefaults.ts, 474, 9)) +>U : Symbol(U, Decl(genericDefaults.ts, 474, 26)) + +const t03c00 = (>x).a; +>t03c00 : Symbol(t03c00, Decl(genericDefaults.ts, 475, 5)) +>(>x).a : Symbol(a, Decl(genericDefaults.ts, 474, 47)) +>t03 : Symbol(t03, Decl(genericDefaults.ts, 472, 37)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 474, 47)) + +const t03c01 = (>x).a; +>t03c01 : Symbol(t03c01, Decl(genericDefaults.ts, 476, 5)) +>(>x).a : Symbol(a, Decl(genericDefaults.ts, 474, 47)) +>t03 : Symbol(t03, Decl(genericDefaults.ts, 472, 37)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 474, 47)) + +const t03c02 = (>x).a; +>t03c02 : Symbol(t03c02, Decl(genericDefaults.ts, 477, 5)) +>(>x).a : Symbol(a, Decl(genericDefaults.ts, 474, 47)) +>t03 : Symbol(t03, Decl(genericDefaults.ts, 472, 37)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 474, 47)) + +const t03c03 = (>x).a; +>t03c03 : Symbol(t03c03, Decl(genericDefaults.ts, 478, 5)) +>(>x).a : Symbol(a, Decl(genericDefaults.ts, 474, 47)) +>t03 : Symbol(t03, Decl(genericDefaults.ts, 472, 37)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 474, 47)) + +const t03c04 = (>x).a; +>t03c04 : Symbol(t03c04, Decl(genericDefaults.ts, 479, 5)) +>(>x).a : Symbol(a, Decl(genericDefaults.ts, 474, 47)) +>t03 : Symbol(t03, Decl(genericDefaults.ts, 472, 37)) +>x : Symbol(x, Decl(genericDefaults.ts, 13, 13)) +>a : Symbol(a, Decl(genericDefaults.ts, 474, 47)) + diff --git a/tests/baselines/reference/genericDefaults.types b/tests/baselines/reference/genericDefaults.types new file mode 100644 index 00000000000..cd6c2d58e4a --- /dev/null +++ b/tests/baselines/reference/genericDefaults.types @@ -0,0 +1,2608 @@ +=== tests/cases/compiler/genericDefaults.ts === +interface A { a: number; } +>A : A +>a : number + +interface B { b: number; } +>B : B +>b : number + +interface C { c: number; } +>C : C +>c : number + +interface D { d: number; } +>D : D +>d : number + +interface AB { a: number; b: number; } +>AB : AB +>a : number +>b : number + +interface BC { b: number; c: number; } +>BC : BC +>b : number +>c : number + +declare const a: A; +>a : A +>A : A + +declare const b: B; +>b : B +>B : B + +declare const c: C; +>c : C +>C : C + +declare const d: D; +>d : D +>D : D + +declare const ab: AB; +>ab : AB +>AB : AB + +declare const bc: BC; +>bc : BC +>BC : BC + +declare const x: any; +>x : any + +// function without type parameters +declare function f00(a?: A): A; +>f00 : (a?: A) => A +>a : A +>A : A +>A : A + +// no inference +f00(); +>f00() : A +>f00 : (a?: A) => A + +f00(a); +>f00(a) : A +>f00 : (a?: A) => A +>a : A + +// function with a type parameter without a default +declare function f01(a?: T): T; +>f01 : (a?: T) => T +>T : T +>a : T +>T : T +>T : T + +// inference +f01(); +>f01() : {} +>f01 : (a?: T) => T + +f01(a); +>f01(a) : A +>f01 : (a?: T) => T +>a : A + +// no inference, fully supplied +f01(); +>f01() : A +>f01 : (a?: T) => T +>A : A + +f01(a); +>f01(a) : A +>f01 : (a?: T) => T +>A : A +>a : A + +// function with a type paramter with a default +declare function f02(a?: T): T; +>f02 : (a?: T) => T +>T : T +>A : A +>a : T +>T : T +>T : T + +// inference +f02(); +>f02() : A +>f02 : (a?: T) => T + +f02(a); +>f02(a) : A +>f02 : (a?: T) => T +>a : A + +f02(b); +>f02(b) : B +>f02 : (a?: T) => T +>b : B + +// no inference, fully supplied +f02(); +>f02() : A +>f02 : (a?: T) => T +>A : A + +f02(a); +>f02(a) : A +>f02 : (a?: T) => T +>A : A +>a : A + +f02(); +>f02() : B +>f02 : (a?: T) => T +>B : B + +f02(b); +>f02(b) : B +>f02 : (a?: T) => T +>B : B +>b : B + +// function with a type parameter with a default that refers to itself +declare function f03(a?: T): T; +>f03 : (a?: T) => T +>T : T +>T : T +>a : T +>T : T +>T : T + +// inference +f03(); +>f03() : {} +>f03 : (a?: T) => T + +f03(a); +>f03(a) : A +>f03 : (a?: T) => T +>a : A + +f03(b); +>f03(b) : B +>f03 : (a?: T) => T +>b : B + +// no inference, fully supplied +f03(); +>f03() : A +>f03 : (a?: T) => T +>A : A + +f03(a); +>f03(a) : A +>f03 : (a?: T) => T +>A : A +>a : A + +f03(); +>f03() : B +>f03 : (a?: T) => T +>B : B + +f03(b); +>f03(b) : B +>f03 : (a?: T) => T +>B : B +>b : B + +// function with a type paramter without a default and a type parameter with a default +declare function f04(a?: T, b?: U): [T, U]; +>f04 : (a?: T, b?: U) => [T, U] +>T : T +>U : U +>B : B +>a : T +>T : T +>b : U +>U : U +>T : T +>U : U + +// inference +f04(); +>f04() : [{}, B] +>f04 : (a?: T, b?: U) => [T, U] + +f04(a); +>f04(a) : [A, B] +>f04 : (a?: T, b?: U) => [T, U] +>a : A + +f04(a, b); +>f04(a, b) : [A, B] +>f04 : (a?: T, b?: U) => [T, U] +>a : A +>b : B + +f04(a, c); +>f04(a, c) : [A, C] +>f04 : (a?: T, b?: U) => [T, U] +>a : A +>c : C + +// no inference, partially supplied +f04(); +>f04() : [A, B] +>f04 : (a?: T, b?: U) => [T, U] +>A : A + +f04(a); +>f04(a) : [A, B] +>f04 : (a?: T, b?: U) => [T, U] +>A : A +>a : A + +f04(a, b); +>f04(a, b) : [A, B] +>f04 : (a?: T, b?: U) => [T, U] +>A : A +>a : A +>b : B + +// no inference, fully supplied +f04(); +>f04() : [A, B] +>f04 : (a?: T, b?: U) => [T, U] +>A : A +>B : B + +f04(a); +>f04(a) : [A, B] +>f04 : (a?: T, b?: U) => [T, U] +>A : A +>B : B +>a : A + +f04(a, b); +>f04(a, b) : [A, B] +>f04 : (a?: T, b?: U) => [T, U] +>A : A +>B : B +>a : A +>b : B + +f04(); +>f04() : [A, C] +>f04 : (a?: T, b?: U) => [T, U] +>A : A +>C : C + +f04(a); +>f04(a) : [A, C] +>f04 : (a?: T, b?: U) => [T, U] +>A : A +>C : C +>a : A + +f04(a, c); +>f04(a, c) : [A, C] +>f04 : (a?: T, b?: U) => [T, U] +>A : A +>C : C +>a : A +>c : C + +// function with a type parameter without a default and a type parameter with a default that refers to an earlier type parameter +declare function f05(a?: T, b?: U): [T, U]; +>f05 : (a?: T, b?: U) => [T, U] +>T : T +>U : U +>T : T +>a : T +>T : T +>b : U +>U : U +>T : T +>U : U + +// inference +f05(); +>f05() : [{}, {}] +>f05 : (a?: T, b?: U) => [T, U] + +f05(a); +>f05(a) : [A, A] +>f05 : (a?: T, b?: U) => [T, U] +>a : A + +f05(a, a); +>f05(a, a) : [A, A] +>f05 : (a?: T, b?: U) => [T, U] +>a : A +>a : A + +f05(a, b); +>f05(a, b) : [A, B] +>f05 : (a?: T, b?: U) => [T, U] +>a : A +>b : B + +// no inference, partially supplied +f05(); +>f05() : [A, A] +>f05 : (a?: T, b?: U) => [T, U] +>A : A + +f05(a); +>f05(a) : [A, A] +>f05 : (a?: T, b?: U) => [T, U] +>A : A +>a : A + +f05(a, a); +>f05(a, a) : [A, A] +>f05 : (a?: T, b?: U) => [T, U] +>A : A +>a : A +>a : A + +// no inference, fully supplied +f05(); +>f05() : [A, B] +>f05 : (a?: T, b?: U) => [T, U] +>A : A +>B : B + +f05(a); +>f05(a) : [A, B] +>f05 : (a?: T, b?: U) => [T, U] +>A : A +>B : B +>a : A + +f05(a, b); +>f05(a, b) : [A, B] +>f05 : (a?: T, b?: U) => [T, U] +>A : A +>B : B +>a : A +>b : B + +// function with a type parameter with a default that refers to an earlier type parameter with a default +declare function f06(a?: T, b?: U): [T, U]; +>f06 : (a?: T, b?: U) => [T, U] +>T : T +>A : A +>U : U +>T : T +>a : T +>T : T +>b : U +>U : U +>T : T +>U : U + +// inference +f06(); +>f06() : [A, A] +>f06 : (a?: T, b?: U) => [T, U] + +f06(a); +>f06(a) : [A, A] +>f06 : (a?: T, b?: U) => [T, U] +>a : A + +f06(a, a); +>f06(a, a) : [A, A] +>f06 : (a?: T, b?: U) => [T, U] +>a : A +>a : A + +f06(a, b); +>f06(a, b) : [A, B] +>f06 : (a?: T, b?: U) => [T, U] +>a : A +>b : B + +f06(b, a); +>f06(b, a) : [B, A] +>f06 : (a?: T, b?: U) => [T, U] +>b : B +>a : A + +f06(b, b); +>f06(b, b) : [B, B] +>f06 : (a?: T, b?: U) => [T, U] +>b : B +>b : B + +// no inference, partially supplied +f06(); +>f06() : [A, A] +>f06 : (a?: T, b?: U) => [T, U] +>A : A + +f06(a); +>f06(a) : [A, A] +>f06 : (a?: T, b?: U) => [T, U] +>A : A +>a : A + +f06(a, a); +>f06(a, a) : [A, A] +>f06 : (a?: T, b?: U) => [T, U] +>A : A +>a : A +>a : A + +f06(); +>f06() : [B, B] +>f06 : (a?: T, b?: U) => [T, U] +>B : B + +f06(b); +>f06(b) : [B, B] +>f06 : (a?: T, b?: U) => [T, U] +>B : B +>b : B + +f06(b, b); +>f06(b, b) : [B, B] +>f06 : (a?: T, b?: U) => [T, U] +>B : B +>b : B +>b : B + +// no inference, fully supplied +f06(); +>f06() : [A, B] +>f06 : (a?: T, b?: U) => [T, U] +>A : A +>B : B + +f06(a); +>f06(a) : [A, B] +>f06 : (a?: T, b?: U) => [T, U] +>A : A +>B : B +>a : A + +f06(a, b); +>f06(a, b) : [A, B] +>f06 : (a?: T, b?: U) => [T, U] +>A : A +>B : B +>a : A +>b : B + +f06(); +>f06() : [B, C] +>f06 : (a?: T, b?: U) => [T, U] +>B : B +>C : C + +f06(b); +>f06(b) : [B, C] +>f06 : (a?: T, b?: U) => [T, U] +>B : B +>C : C +>b : B + +f06(b, c); +>f06(b, c) : [B, C] +>f06 : (a?: T, b?: U) => [T, U] +>B : B +>C : C +>b : B +>c : C + +// function with a type parameter without a default and a type parameter with a default that refers to an earlier type parameter with a default +declare function f07(a?: T, b?: U, c?: V): [T, U, V]; +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>T : T +>U : U +>B : B +>V : V +>U : U +>a : T +>T : T +>b : U +>U : U +>c : V +>V : V +>T : T +>U : U +>V : V + +// inference +f07(); +>f07() : [{}, B, B] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] + +f07(a, b); +>f07(a, b) : [A, B, B] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A +>b : B + +f07(a, c); +>f07(a, c) : [A, C, C] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A +>c : C + +f07(a, b, b); +>f07(a, b, b) : [A, B, B] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A +>b : B +>b : B + +f07(a, b, c); +>f07(a, b, c) : [A, B, C] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A +>b : B +>c : C + +f07(a, c, b); +>f07(a, c, b) : [A, C, B] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A +>c : C +>b : B + +f07(a, c, c); +>f07(a, c, c) : [A, C, C] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A +>c : C +>c : C + +// no inference, partially supplied +f07(); +>f07() : [A, B, B] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A + +f07(a); +>f07(a) : [A, B, B] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>a : A + +f07(a, b); +>f07(a, b) : [A, B, B] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>a : A +>b : B + +f07(a, b, b); +>f07(a, b, b) : [A, B, B] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>a : A +>b : B +>b : B + +f07(); +>f07() : [A, B, B] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B + +f07(a); +>f07(a) : [A, B, B] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>a : A + +f07(a, b); +>f07(a, b) : [A, B, B] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>a : A +>b : B + +f07(a, b, b); +>f07(a, b, b) : [A, B, B] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>a : A +>b : B +>b : B + +f07(); +>f07() : [A, C, C] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>C : C + +f07(a); +>f07(a) : [A, C, C] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>C : C +>a : A + +f07(a, c); +>f07(a, c) : [A, C, C] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>C : C +>a : A +>c : C + +f07(a, c, c); +>f07(a, c, c) : [A, C, C] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>C : C +>a : A +>c : C +>c : C + +// no inference, fully supplied +f07(); +>f07() : [A, B, C] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>C : C + +f07(a); +>f07(a) : [A, B, C] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>C : C +>a : A + +f07(a, b); +>f07(a, b) : [A, B, C] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>C : C +>a : A +>b : B + +f07(a, b, c); +>f07(a, b, c) : [A, B, C] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>C : C +>a : A +>b : B +>c : C + +f07(); +>f07() : [A, C, A] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>C : C +>A : A + +f07(a); +>f07(a) : [A, C, A] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>C : C +>A : A +>a : A + +f07(a, c); +>f07(a, c) : [A, C, D] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>C : C +>D : D +>a : A +>c : C + +f07(a, c, d); +>f07(a, c, d) : [A, C, D] +>f07 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>C : C +>D : D +>a : A +>c : C +>d : D + +// function with a type parameter with a default that refers to an earlier type parameter with a constraint +declare function f08(a?: T, b?: U): [T, U]; +>f08 : (a?: T, b?: U) => [T, U] +>T : T +>A : A +>U : U +>T : T +>a : T +>T : T +>b : U +>U : U +>T : T +>U : U + +// inference +f08(); +>f08() : [A, A] +>f08 : (a?: T, b?: U) => [T, U] + +f08(a); +>f08(a) : [A, A] +>f08 : (a?: T, b?: U) => [T, U] +>a : A + +f08(a, a); +>f08(a, a) : [A, A] +>f08 : (a?: T, b?: U) => [T, U] +>a : A +>a : A + +f08(a, b); +>f08(a, b) : [A, B] +>f08 : (a?: T, b?: U) => [T, U] +>a : A +>b : B + +// no inference, partially supplied +f08(); +>f08() : [A, A] +>f08 : (a?: T, b?: U) => [T, U] +>A : A + +f08(a); +>f08(a) : [A, A] +>f08 : (a?: T, b?: U) => [T, U] +>A : A +>a : A + +f08(a, a); +>f08(a, a) : [A, A] +>f08 : (a?: T, b?: U) => [T, U] +>A : A +>a : A +>a : A + +// no inference, fully supplied +f08(); +>f08() : [A, B] +>f08 : (a?: T, b?: U) => [T, U] +>A : A +>B : B + +f08(a); +>f08(a) : [A, B] +>f08 : (a?: T, b?: U) => [T, U] +>A : A +>B : B +>a : A + +f08(a, b); +>f08(a, b) : [A, B] +>f08 : (a?: T, b?: U) => [T, U] +>A : A +>B : B +>a : A +>b : B + +// function with a type parameter with a constraint and a default that refers to an earlier type parameter +declare function f09(a?: T, b?: U): [T, U]; +>f09 : (a?: T, b?: U) => [T, U] +>T : T +>U : U +>T : T +>T : T +>a : T +>T : T +>b : U +>U : U +>T : T +>U : U + +// inference +f09(); +>f09() : [{}, {}] +>f09 : (a?: T, b?: U) => [T, U] + +f09(a); +>f09(a) : [A, A] +>f09 : (a?: T, b?: U) => [T, U] +>a : A + +f09(a, a); +>f09(a, a) : [A, A] +>f09 : (a?: T, b?: U) => [T, U] +>a : A +>a : A + +f09(a, ab); +>f09(a, ab) : [A, AB] +>f09 : (a?: T, b?: U) => [T, U] +>a : A +>ab : AB + +// no inference, partially supplied +f09(); +>f09() : [A, A] +>f09 : (a?: T, b?: U) => [T, U] +>A : A + +f09(a); +>f09(a) : [A, A] +>f09 : (a?: T, b?: U) => [T, U] +>A : A +>a : A + +f09(a, a); +>f09(a, a) : [A, A] +>f09 : (a?: T, b?: U) => [T, U] +>A : A +>a : A +>a : A + +f09(a, ab); +>f09(a, ab) : [A, A] +>f09 : (a?: T, b?: U) => [T, U] +>A : A +>a : A +>ab : AB + +// no inference, fully supplied +f09(); +>f09() : [A, AB] +>f09 : (a?: T, b?: U) => [T, U] +>A : A +>AB : AB + +f09(a); +>f09(a) : [A, AB] +>f09 : (a?: T, b?: U) => [T, U] +>A : A +>AB : AB +>a : A + +f09(a, ab); +>f09(a, ab) : [A, AB] +>f09 : (a?: T, b?: U) => [T, U] +>A : A +>AB : AB +>a : A +>ab : AB + +// function with a type parameter with a constraint and a default that refers to an earlier type parameter with a constraint +declare function f10(a?: T, b?: U): [T, U]; +>f10 : (a?: T, b?: U) => [T, U] +>T : T +>A : A +>U : U +>T : T +>T : T +>a : T +>T : T +>b : U +>U : U +>T : T +>U : U + +// inference +f10(); +>f10() : [A, A] +>f10 : (a?: T, b?: U) => [T, U] + +f10(a); +>f10(a) : [A, A] +>f10 : (a?: T, b?: U) => [T, U] +>a : A + +f10(a, a); +>f10(a, a) : [A, A] +>f10 : (a?: T, b?: U) => [T, U] +>a : A +>a : A + +f10(a, ab); +>f10(a, ab) : [A, AB] +>f10 : (a?: T, b?: U) => [T, U] +>a : A +>ab : AB + +// no inference, partially supplied +f10(); +>f10() : [A, A] +>f10 : (a?: T, b?: U) => [T, U] +>A : A + +f10(a); +>f10(a) : [A, A] +>f10 : (a?: T, b?: U) => [T, U] +>A : A +>a : A + +f10(a, a); +>f10(a, a) : [A, A] +>f10 : (a?: T, b?: U) => [T, U] +>A : A +>a : A +>a : A + +f10(a, ab); +>f10(a, ab) : [A, A] +>f10 : (a?: T, b?: U) => [T, U] +>A : A +>a : A +>ab : AB + +// no inference, fully supplied +f10(); +>f10() : [A, A] +>f10 : (a?: T, b?: U) => [T, U] +>A : A +>A : A + +f10(a); +>f10(a) : [A, A] +>f10 : (a?: T, b?: U) => [T, U] +>A : A +>A : A +>a : A + +f10(a, a); +>f10(a, a) : [A, A] +>f10 : (a?: T, b?: U) => [T, U] +>A : A +>A : A +>a : A +>a : A + +f10(a, ab); +>f10(a, ab) : [A, A] +>f10 : (a?: T, b?: U) => [T, U] +>A : A +>A : A +>a : A +>ab : AB + +f10(); +>f10() : [A, AB] +>f10 : (a?: T, b?: U) => [T, U] +>A : A +>AB : AB + +f10(a); +>f10(a) : [A, AB] +>f10 : (a?: T, b?: U) => [T, U] +>A : A +>AB : AB +>a : A + +f10(a, ab); +>f10(a, ab) : [A, AB] +>f10 : (a?: T, b?: U) => [T, U] +>A : A +>AB : AB +>a : A +>ab : AB + +// function with a type parameter with a default that refers to an earier type parameter in a union +declare function f11(a?: T, b?: U): [T, U]; +>f11 : (a?: T, b?: U) => [T, U] +>T : T +>U : U +>T : T +>B : B +>a : T +>T : T +>b : U +>U : U +>T : T +>U : U + +// inference +f11(); +>f11() : [{}, {} | B] +>f11 : (a?: T, b?: U) => [T, U] + +f11(a); +>f11(a) : [A, A | B] +>f11 : (a?: T, b?: U) => [T, U] +>a : A + +f11(a, a); +>f11(a, a) : [A, A] +>f11 : (a?: T, b?: U) => [T, U] +>a : A +>a : A + +f11(a, b); +>f11(a, b) : [A, B] +>f11 : (a?: T, b?: U) => [T, U] +>a : A +>b : B + +f11(a, c); +>f11(a, c) : [A, C] +>f11 : (a?: T, b?: U) => [T, U] +>a : A +>c : C + +// no inference, partially supplied +f11(); +>f11() : [A, A | B] +>f11 : (a?: T, b?: U) => [T, U] +>A : A + +f11(a); +>f11(a) : [A, A | B] +>f11 : (a?: T, b?: U) => [T, U] +>A : A +>a : A + +f11(a, a); +>f11(a, a) : [A, A | B] +>f11 : (a?: T, b?: U) => [T, U] +>A : A +>a : A +>a : A + +f11(a, b); +>f11(a, b) : [A, A | B] +>f11 : (a?: T, b?: U) => [T, U] +>A : A +>a : A +>b : B + +// no inference, fully supplied +f11(); +>f11() : [A, C] +>f11 : (a?: T, b?: U) => [T, U] +>A : A +>C : C + +f11(a); +>f11(a) : [A, C] +>f11 : (a?: T, b?: U) => [T, U] +>A : A +>C : C +>a : A + +f11(a, c); +>f11(a, c) : [A, C] +>f11 : (a?: T, b?: U) => [T, U] +>A : A +>C : C +>a : A +>c : C + +// function with a type parameter with a default that refers to an earlier type parameter in an intersection +declare function f12(a?: T, b?: U): [T, U]; +>f12 : (a?: T, b?: U) => [T, U] +>T : T +>U : U +>T : T +>B : B +>a : T +>T : T +>b : U +>U : U +>T : T +>U : U + +// inference +f12(); +>f12() : [{}, {} & B] +>f12 : (a?: T, b?: U) => [T, U] + +f12(a); +>f12(a) : [A, A & B] +>f12 : (a?: T, b?: U) => [T, U] +>a : A + +f12(a, a); +>f12(a, a) : [A, A] +>f12 : (a?: T, b?: U) => [T, U] +>a : A +>a : A + +f12(a, b); +>f12(a, b) : [A, B] +>f12 : (a?: T, b?: U) => [T, U] +>a : A +>b : B + +f12(a, c); +>f12(a, c) : [A, C] +>f12 : (a?: T, b?: U) => [T, U] +>a : A +>c : C + +// no inference, partially supplied +f12(); +>f12() : [A, A & B] +>f12 : (a?: T, b?: U) => [T, U] +>A : A + +f12(a); +>f12(a) : [A, A & B] +>f12 : (a?: T, b?: U) => [T, U] +>A : A +>a : A + +f12(a, ab); +>f12(a, ab) : [A, A & B] +>f12 : (a?: T, b?: U) => [T, U] +>A : A +>a : A +>ab : AB + +// no inference, fully supplied +f12(); +>f12() : [A, C] +>f12 : (a?: T, b?: U) => [T, U] +>A : A +>C : C + +f12(a); +>f12(a) : [A, C] +>f12 : (a?: T, b?: U) => [T, U] +>A : A +>C : C +>a : A + +f12(a, c); +>f12(a, c) : [A, C] +>f12 : (a?: T, b?: U) => [T, U] +>A : A +>C : C +>a : A +>c : C + +// function with a type parameter with a default that refers to a later type parameter with a default +declare function f13(a?: T, b?: U): [T, U]; +>f13 : (a?: T, b?: U) => [T, U] +>T : T +>U : U +>U : U +>B : B +>a : T +>T : T +>b : U +>U : U +>T : T +>U : U + +// inference +f13(); +>f13() : [{}, B] +>f13 : (a?: T, b?: U) => [T, U] + +f13(a); +>f13(a) : [A, B] +>f13 : (a?: T, b?: U) => [T, U] +>a : A + +f13(a, b); +>f13(a, b) : [A, B] +>f13 : (a?: T, b?: U) => [T, U] +>a : A +>b : B + +f13(a, c); +>f13(a, c) : [A, C] +>f13 : (a?: T, b?: U) => [T, U] +>a : A +>c : C + +// no inference, partially supplied +f13(); +>f13() : [A, B] +>f13 : (a?: T, b?: U) => [T, U] +>A : A + +f13(a); +>f13(a) : [A, B] +>f13 : (a?: T, b?: U) => [T, U] +>A : A +>a : A + +f13(a, b); +>f13(a, b) : [A, B] +>f13 : (a?: T, b?: U) => [T, U] +>A : A +>a : A +>b : B + +// no inference, fully supplied +f13(); +>f13() : [A, C] +>f13 : (a?: T, b?: U) => [T, U] +>A : A +>C : C + +f13(a); +>f13(a) : [A, C] +>f13 : (a?: T, b?: U) => [T, U] +>A : A +>C : C +>a : A + +f13(a, c); +>f13(a, c) : [A, C] +>f13 : (a?: T, b?: U) => [T, U] +>A : A +>C : C +>a : A +>c : C + +f13(a, c); +>f13(a, c) : [A, C] +>f13 : (a?: T, b?: U) => [T, U] +>A : A +>C : C +>a : A +>c : C + +// function with a type parameter without a default and a type parameter with a default that refers to a later type parameter with a default +declare function f14(a?: T, b?: U, c?: V): [T, U, V]; +>f14 : (a?: T, b?: U, c?: V) => [T, U, V] +>T : T +>U : U +>V : V +>V : V +>C : C +>a : T +>T : T +>b : U +>U : U +>c : V +>V : V +>T : T +>U : U +>V : V + +// inference +f14(); +>f14() : [{}, {}, C] +>f14 : (a?: T, b?: U, c?: V) => [T, U, V] + +f14(a); +>f14(a) : [A, {}, C] +>f14 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A + +f14(a, b); +>f14(a, b) : [A, B, C] +>f14 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A +>b : B + +f14(a, b, c); +>f14(a, b, c) : [A, B, C] +>f14 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A +>b : B +>c : C + +f14(a, b, d); +>f14(a, b, d) : [A, B, D] +>f14 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A +>b : B +>d : D + +// no inference, partially supplied +f14(); +>f14() : [A, {}, C] +>f14 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A + +f14(a); +>f14(a) : [A, {}, C] +>f14 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>a : A + +f14(a, b); +>f14(a, b) : [A, {}, C] +>f14 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>a : A +>b : B + +f14(a, b, c); +>f14(a, b, c) : [A, {}, C] +>f14 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>a : A +>b : B +>c : C + +f14(); +>f14() : [A, B, C] +>f14 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B + +f14(a); +>f14(a) : [A, B, C] +>f14 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>a : A + +f14(a, b); +>f14(a, b) : [A, B, C] +>f14 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>a : A +>b : B + +f14(a, b, c); +>f14(a, b, c) : [A, B, C] +>f14 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>a : A +>b : B +>c : C + +// no inference fully supplied +f14(); +>f14() : [A, B, D] +>f14 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>D : D + +f14(a); +>f14(a) : [A, B, D] +>f14 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>D : D +>a : A + +f14(a, b); +>f14(a, b) : [A, B, D] +>f14 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>D : D +>a : A +>b : B + +f14(a, b, d); +>f14(a, b, d) : [A, B, D] +>f14 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>D : D +>a : A +>b : B +>d : D + +// function with two type parameters with defaults that mutually refer to each other +declare function f15(a?: T, b?: U): [T, U]; +>f15 : (a?: T, b?: U) => [T, U] +>T : T +>U : U +>U : U +>T : T +>a : T +>T : T +>b : U +>U : U +>T : T +>U : U + +// inference +f15(); +>f15() : [{}, {}] +>f15 : (a?: T, b?: U) => [T, U] + +f15(a); +>f15(a) : [A, A] +>f15 : (a?: T, b?: U) => [T, U] +>a : A + +f15(a, b); +>f15(a, b) : [A, B] +>f15 : (a?: T, b?: U) => [T, U] +>a : A +>b : B + +// no inference, partially supplied +f15(); +>f15() : [A, A] +>f15 : (a?: T, b?: U) => [T, U] +>A : A + +f15(a); +>f15(a) : [A, A] +>f15 : (a?: T, b?: U) => [T, U] +>A : A +>a : A + +f15(a, a); +>f15(a, a) : [A, A] +>f15 : (a?: T, b?: U) => [T, U] +>A : A +>a : A +>a : A + +// no inference, fully supplied +f15(); +>f15() : [A, B] +>f15 : (a?: T, b?: U) => [T, U] +>A : A +>B : B + +f15(a); +>f15(a) : [A, B] +>f15 : (a?: T, b?: U) => [T, U] +>A : A +>B : B +>a : A + +f15(a, b); +>f15(a, b) : [A, B] +>f15 : (a?: T, b?: U) => [T, U] +>A : A +>B : B +>a : A +>b : B + +// function with a type parameter without a default and two type parameters with defaults that mutually refer to each other +declare function f16(a?: T, b?: U, c?: V): [T, U, V]; +>f16 : (a?: T, b?: U, c?: V) => [T, U, V] +>T : T +>U : U +>V : V +>V : V +>U : U +>a : T +>T : T +>b : U +>U : U +>c : V +>V : V +>T : T +>U : U +>V : V + +// no inference +f16(); +>f16() : [{}, {}, {}] +>f16 : (a?: T, b?: U, c?: V) => [T, U, V] + +f16(a); +>f16(a) : [A, {}, {}] +>f16 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A + +f16(a, b); +>f16(a, b) : [A, B, B] +>f16 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A +>b : B + +f16(a, b, b); +>f16(a, b, b) : [A, B, B] +>f16 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A +>b : B +>b : B + +// no inference, partially supplied +f16(); +>f16() : [A, {}, {}] +>f16 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A + +f16(a); +>f16(a) : [A, {}, {}] +>f16 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>a : A + +f16(a, b); +>f16(a, b) : [A, {}, {}] +>f16 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>a : A +>b : B + +f16(a, b, b); +>f16(a, b, b) : [A, {}, {}] +>f16 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>a : A +>b : B +>b : B + +f16(); +>f16() : [A, B, B] +>f16 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B + +f16(a); +>f16(a) : [A, B, B] +>f16 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>a : A + +f16(a, b); +>f16(a, b) : [A, B, B] +>f16 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>a : A +>b : B + +f16(a, b, b); +>f16(a, b, b) : [A, B, B] +>f16 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>a : A +>b : B +>b : B + +// no inference, fully supplied +f16(); +>f16() : [A, B, D] +>f16 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>D : D + +f16(a); +>f16(a) : [A, B, D] +>f16 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>D : D +>a : A + +f16(a, b); +>f16(a, b) : [A, B, D] +>f16 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>D : D +>a : A +>b : B + +f16(a, b, d); +>f16(a, b, d) : [A, B, D] +>f16 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>D : D +>a : A +>b : B +>d : D + +// function with a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in a union +declare function f17(a?: T, b?: U): [T, U]; +>f17 : (a?: T, b?: U) => [T, U] +>T : T +>U : U +>U : U +>T : T +>B : B +>a : T +>T : T +>b : U +>U : U +>T : T +>U : U + +// inference +f17(); +>f17() : [{}, {} | B] +>f17 : (a?: T, b?: U) => [T, U] + +f17(a); +>f17(a) : [A, A | B] +>f17 : (a?: T, b?: U) => [T, U] +>a : A + +f17(a, a); +>f17(a, a) : [A, A] +>f17 : (a?: T, b?: U) => [T, U] +>a : A +>a : A + +f17(a, b); +>f17(a, b) : [A, B] +>f17 : (a?: T, b?: U) => [T, U] +>a : A +>b : B + +f17(a, c); +>f17(a, c) : [A, C] +>f17 : (a?: T, b?: U) => [T, U] +>a : A +>c : C + +// no inference, partially supplied +f17(); +>f17() : [A, A | B] +>f17 : (a?: T, b?: U) => [T, U] +>A : A + +f17(a); +>f17(a) : [A, A | B] +>f17 : (a?: T, b?: U) => [T, U] +>A : A +>a : A + +f17(a, a); +>f17(a, a) : [A, A | B] +>f17 : (a?: T, b?: U) => [T, U] +>A : A +>a : A +>a : A + +f17(a, b); +>f17(a, b) : [A, A | B] +>f17 : (a?: T, b?: U) => [T, U] +>A : A +>a : A +>b : B + +// no inference, fully supplied +f17(); +>f17() : [A, C] +>f17 : (a?: T, b?: U) => [T, U] +>A : A +>C : C + +f17(a); +>f17(a) : [A, C] +>f17 : (a?: T, b?: U) => [T, U] +>A : A +>C : C +>a : A + +f17(a, c); +>f17(a, c) : [A, C] +>f17 : (a?: T, b?: U) => [T, U] +>A : A +>C : C +>a : A +>c : C + +// function with a type parameter without a default and a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in a union +declare function f18(a?: T, b?: U, c?: V): [T, U, V]; +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>T : T +>U : U +>V : V +>V : V +>U : U +>C : C +>a : T +>T : T +>b : U +>U : U +>c : V +>V : V +>T : T +>U : U +>V : V + +// inference +f18(); +>f18() : [{}, {}, {} | C] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] + +f18(a); +>f18(a) : [A, {}, {} | C] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A + +f18(a, b); +>f18(a, b) : [A, B, B | C] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A +>b : B + +f18(a, b, b); +>f18(a, b, b) : [A, B, B] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A +>b : B +>b : B + +f18(a, b, c); +>f18(a, b, c) : [A, B, C] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A +>b : B +>c : C + +// no inference, partially supplied +f18(); +>f18() : [A, {}, {} | C] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A + +f18(a); +>f18(a) : [A, {}, {} | C] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>a : A + +f18(a, b); +>f18(a, b) : [A, {}, {} | C] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>a : A +>b : B + +f18(a, b, b); +>f18(a, b, b) : [A, {}, {} | C] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>a : A +>b : B +>b : B + +f18(a, b, c); +>f18(a, b, c) : [A, {}, {} | C] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>a : A +>b : B +>c : C + +f18(); +>f18() : [A, B, B | C] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B + +f18(a); +>f18(a) : [A, B, B | C] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>a : A + +f18(a, b); +>f18(a, b) : [A, B, B | C] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>a : A +>b : B + +f18(a, b, b); +>f18(a, b, b) : [A, B, B | C] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>a : A +>b : B +>b : B + +f18(a, b, c); +>f18(a, b, c) : [A, B, B | C] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>a : A +>b : B +>c : C + +// no inference, fully supplied +f18(); +>f18() : [A, B, D] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>D : D + +f18(a); +>f18(a) : [A, B, D] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>D : D +>a : A + +f18(a, b); +>f18(a, b) : [A, B, D] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>D : D +>a : A +>b : B + +f18(a, b, d); +>f18(a, b, d) : [A, B, D] +>f18 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>D : D +>a : A +>b : B +>d : D + +// function with a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in an intersection +declare function f19(a?: T, b?: U): [T, U]; +>f19 : (a?: T, b?: U) => [T, U] +>T : T +>U : U +>U : U +>T : T +>B : B +>a : T +>T : T +>b : U +>U : U +>T : T +>U : U + +// inference +f19(); +>f19() : [{}, {} & B] +>f19 : (a?: T, b?: U) => [T, U] + +f19(a); +>f19(a) : [A, A & B] +>f19 : (a?: T, b?: U) => [T, U] +>a : A + +f19(a, a); +>f19(a, a) : [A, A] +>f19 : (a?: T, b?: U) => [T, U] +>a : A +>a : A + +f19(a, b); +>f19(a, b) : [A, B] +>f19 : (a?: T, b?: U) => [T, U] +>a : A +>b : B + +f19(a, ab); +>f19(a, ab) : [A, AB] +>f19 : (a?: T, b?: U) => [T, U] +>a : A +>ab : AB + +f19(a, c); +>f19(a, c) : [A, C] +>f19 : (a?: T, b?: U) => [T, U] +>a : A +>c : C + +// no inference, partially supplied +f19(); +>f19() : [A, A & B] +>f19 : (a?: T, b?: U) => [T, U] +>A : A + +f19(a); +>f19(a) : [A, A & B] +>f19 : (a?: T, b?: U) => [T, U] +>A : A +>a : A + +f19(a, ab); +>f19(a, ab) : [A, A & B] +>f19 : (a?: T, b?: U) => [T, U] +>A : A +>a : A +>ab : AB + +// no inference, fully supplied +f19(); +>f19() : [A, C] +>f19 : (a?: T, b?: U) => [T, U] +>A : A +>C : C + +f19(a); +>f19(a) : [A, C] +>f19 : (a?: T, b?: U) => [T, U] +>A : A +>C : C +>a : A + +f19(a, c); +>f19(a, c) : [A, C] +>f19 : (a?: T, b?: U) => [T, U] +>A : A +>C : C +>a : A +>c : C + +// function with a type parameter without a default and a type parameter with a default that refers to a later type parameter with a default that refers to an earlier type parameter in an intersection +declare function f20(a?: T, b?: U, c?: V): [T, U, V]; +>f20 : (a?: T, b?: U, c?: V) => [T, U, V] +>T : T +>U : U +>V : V +>V : V +>U : U +>C : C +>a : T +>T : T +>b : U +>U : U +>c : V +>V : V +>T : T +>U : U +>V : V + +// inference +f20(); +>f20() : [{}, {}, {} & C] +>f20 : (a?: T, b?: U, c?: V) => [T, U, V] + +f20(a); +>f20(a) : [A, {}, {} & C] +>f20 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A + +f20(a, b); +>f20(a, b) : [A, B, B & C] +>f20 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A +>b : B + +f20(a, b, c); +>f20(a, b, c) : [A, B, C] +>f20 : (a?: T, b?: U, c?: V) => [T, U, V] +>a : A +>b : B +>c : C + +// no inference, partially supplied +f20(); +>f20() : [A, {}, {} & C] +>f20 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A + +f20(a); +>f20(a) : [A, {}, {} & C] +>f20 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>a : A + +f20(a, b); +>f20(a, b) : [A, {}, {} & C] +>f20 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>a : A +>b : B + +f20(a, b, bc); +>f20(a, b, bc) : [A, {}, {} & C] +>f20 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>a : A +>b : B +>bc : BC + +f20(); +>f20() : [A, B, B & C] +>f20 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B + +f20(a); +>f20(a) : [A, B, B & C] +>f20 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>a : A + +f20(a, b); +>f20(a, b) : [A, B, B & C] +>f20 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>a : A +>b : B + +f20(a, b, bc); +>f20(a, b, bc) : [A, B, B & C] +>f20 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>a : A +>b : B +>bc : BC + +// no inference, fully supplied +f20(); +>f20() : [A, B, D] +>f20 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>D : D + +f20(a); +>f20(a) : [A, B, D] +>f20 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>D : D +>a : A + +f20(a, b); +>f20(a, b) : [A, B, D] +>f20 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>D : D +>a : A +>b : B + +f20(a, b, d); +>f20(a, b, d) : [A, B, D] +>f20 : (a?: T, b?: U, c?: V) => [T, U, V] +>A : A +>B : B +>D : D +>a : A +>b : B +>d : D + +interface i00 { a: T; } +>i00 : i00 +>T : T +>a : T +>T : T + +const i00c00 = (x).a; +>i00c00 : number +>(x).a : number +>(x) : i00 +>x : i00 +>i00 : i00 +>x : any +>a : number + +const i00c01 = (>x).a; +>i00c01 : number +>(>x).a : number +>(>x) : i00 +>>x : i00 +>i00 : i00 +>x : any +>a : number + +interface i01 { a: [T, U]; } +>i01 : i01 +>T : T +>U : U +>T : T +>a : [T, U] +>T : T +>U : U + +const i01c00 = (>x).a; +>i01c00 : [number, number] +>(>x).a : [number, number] +>(>x) : i01 +>>x : i01 +>i01 : i01 +>x : any +>a : [number, number] + +const i01c01 = (>x).a; +>i01c01 : [number, string] +>(>x).a : [number, string] +>(>x) : i01 +>>x : i01 +>i01 : i01 +>x : any +>a : [number, string] + +interface i02 { a: [T, U]; } +>i02 : i02 +>T : T +>U : U +>T : T +>a : [T, U] +>T : T +>U : U + +const i02c00 = (>x).a; +>i02c00 : [number, number] +>(>x).a : [number, number] +>(>x) : i02 +>>x : i02 +>i02 : i02 +>x : any +>a : [number, number] + +const i02c01 = (>x).a; +>i02c01 : [1, 1] +>(>x).a : [1, 1] +>(>x) : i02<1, 1> +>>x : i02<1, 1> +>i02 : i02 +>x : any +>a : [1, 1] + +const i02c02 = (>x).a; +>i02c02 : [number, number] +>(>x).a : [number, number] +>(>x) : i02 +>>x : i02 +>i02 : i02 +>x : any +>a : [number, number] + +const i02c03 = (>x).a; +>i02c03 : [1, number] +>(>x).a : [1, number] +>(>x) : i02<1, number> +>>x : i02<1, number> +>i02 : i02 +>x : any +>a : [1, number] + +const i02c04 = (>x).a; +>i02c04 : [number, 1] +>(>x).a : [number, 1] +>(>x) : i02 +>>x : i02 +>i02 : i02 +>x : any +>a : [number, 1] + +interface i03 { a: [T, U]; } +>i03 : i03 +>T : T +>U : U +>T : T +>T : T +>a : [T, U] +>T : T +>U : U + +const i03c00 = (>x).a; +>i03c00 : [number, number] +>(>x).a : [number, number] +>(>x) : i03 +>>x : i03 +>i03 : i03 +>x : any +>a : [number, number] + +const i03c01 = (>x).a; +>i03c01 : [1, 1] +>(>x).a : [1, 1] +>(>x) : i03<1, 1> +>>x : i03<1, 1> +>i03 : i03 +>x : any +>a : [1, 1] + +const i03c02 = (>x).a; +>i03c02 : [number, number] +>(>x).a : [number, number] +>(>x) : i03 +>>x : i03 +>i03 : i03 +>x : any +>a : [number, number] + +const i03c03 = (>x).a; +>i03c03 : [1, 1] +>(>x).a : [1, 1] +>(>x) : i03<1, 1> +>>x : i03<1, 1> +>i03 : i03 +>x : any +>a : [1, 1] + +const i03c04 = (>x).a; +>i03c04 : [number, 1] +>(>x).a : [number, 1] +>(>x) : i03 +>>x : i03 +>i03 : i03 +>x : any +>a : [number, 1] + +interface i04 {} +>i04 : i04 + +interface i04 {} +>i04 : i04 +>T : T + +interface i04 {} +>i04 : i04 +>T : T + +interface i04 {} +>i04 : i04 +>T : T +>U : U + +interface i05 { a: T; } +>i05 : i05 +>T : T +>T : T +>a : T +>T : T + +const i05c00 = (x).a; +>i05c00 : {} +>(x).a : {} +>(x) : i05<{}> +>x : i05<{}> +>i05 : i05 +>x : any +>a : {} + +const i05c01 = (>x).a; +>i05c01 : number +>(>x).a : number +>(>x) : i05 +>>x : i05 +>i05 : i05 +>x : any +>a : number + +interface i06 { a: [T, U]; } +>i06 : i06 +>T : T +>U : U +>U : U +>T : T +>a : [T, U] +>T : T +>U : U + +const i06c00 = (x).a; +>i06c00 : [{}, {}] +>(x).a : [{}, {}] +>(x) : i06<{}, {}> +>x : i06<{}, {}> +>i06 : i06 +>x : any +>a : [{}, {}] + +const i06c01 = (>x).a; +>i06c01 : [number, number] +>(>x).a : [number, number] +>(>x) : i06 +>>x : i06 +>i06 : i06 +>x : any +>a : [number, number] + +const i06c02 = (>x).a; +>i06c02 : [number, string] +>(>x).a : [number, string] +>(>x) : i06 +>>x : i06 +>i06 : i06 +>x : any +>a : [number, string] + +interface i07 { a: A; } +>i07 : i07 +>a : A +>A : A + +interface i07 { b: A; } +>i07 : i07 +>A : A +>b : A +>A : A + +const i07c00 = (x).a; +>i07c00 : A +>(x).a : A +>(x) : i07 +>x : i07 +>i07 : i07 +>x : any +>a : A + +const i07c01 = (x).b; +>i07c01 : number +>(x).b : number +>(x) : i07 +>x : i07 +>i07 : i07 +>x : any +>b : number + +const i07c02 = (>x).a; +>i07c02 : A +>(>x).a : A +>(>x) : i07 +>>x : i07 +>i07 : i07 +>B : B +>x : any +>a : A + +const i07c03 = (>x).b; +>i07c03 : B +>(>x).b : B +>(>x) : i07 +>>x : i07 +>i07 : i07 +>B : B +>x : any +>b : B + +interface Base01 { a: T; } +>Base01 : Base01 +>T : T +>a : T +>T : T + +interface Base01Constructor { new (a?: T): Base01; } +>Base01Constructor : Base01Constructor +>T : T +>a : T +>T : T +>Base01 : Base01 +>T : T + +declare const Base01: Base01Constructor; +>Base01 : Base01Constructor +>Base01Constructor : Base01Constructor + +const Base01c00 = new Base01(); +>Base01c00 : Base01 +>new Base01() : Base01 +>Base01 : Base01Constructor + +const Base01c01 = new Base01(1); +>Base01c01 : Base01 +>new Base01(1) : Base01 +>Base01 : Base01Constructor +>1 : 1 + +const Base01c02 = new Base01(); +>Base01c02 : Base01 +>new Base01() : Base01 +>Base01 : Base01Constructor + +const Base01c03 = new Base01(1); +>Base01c03 : Base01 +>new Base01(1) : Base01 +>Base01 : Base01Constructor +>1 : 1 + +declare class Derived01 extends Base01 { } +>Derived01 : Derived01 +>T : T +>Base01 : Base01 +>T : T + +const Derived01c00 = new Derived01(); +>Derived01c00 : Derived01<{}> +>new Derived01() : Derived01<{}> +>Derived01 : typeof Derived01 + +const Derived01c01 = new Derived01(1); +>Derived01c01 : Derived01 +>new Derived01(1) : Derived01 +>Derived01 : typeof Derived01 +>1 : 1 + +const Derived01c02 = new Derived01(); +>Derived01c02 : Derived01 +>new Derived01() : Derived01 +>Derived01 : typeof Derived01 + +const Derived01c03 = new Derived01(1); +>Derived01c03 : Derived01 +>new Derived01(1) : Derived01 +>Derived01 : typeof Derived01 +>1 : 1 + +declare class Derived02 extends Base01 { } +>Derived02 : Derived02 +>T : T +>Base01 : Base01 +>T : T + +const Derived02c00 = new Derived02(); +>Derived02c00 : Derived02 +>new Derived02() : Derived02 +>Derived02 : typeof Derived02 + +const Derived02c01 = new Derived02(1); +>Derived02c01 : Derived02 +>new Derived02(1) : Derived02 +>Derived02 : typeof Derived02 +>1 : 1 + +const Derived02c02 = new Derived02(); +>Derived02c02 : Derived02 +>new Derived02() : Derived02 +>Derived02 : typeof Derived02 + +const Derived02c03 = new Derived02(1); +>Derived02c03 : Derived02 +>new Derived02(1) : Derived02 +>Derived02 : typeof Derived02 +>1 : 1 + +type t00 = { a: T; } +>t00 : t00 +>T : T +>a : T +>T : T + +const t00c00 = (x).a; +>t00c00 : number +>(x).a : number +>(x) : t00 +>x : t00 +>t00 : t00 +>x : any +>a : number + +const t00c01 = (>x).a; +>t00c01 : number +>(>x).a : number +>(>x) : t00 +>>x : t00 +>t00 : t00 +>x : any +>a : number + +type t01 = { a: [T, U]; } +>t01 : t01 +>T : T +>U : U +>T : T +>a : [T, U] +>T : T +>U : U + +const t01c00 = (>x).a; +>t01c00 : [number, number] +>(>x).a : [number, number] +>(>x) : t01 +>>x : t01 +>t01 : t01 +>x : any +>a : [number, number] + +const t01c01 = (>x).a; +>t01c01 : [number, string] +>(>x).a : [number, string] +>(>x) : t01 +>>x : t01 +>t01 : t01 +>x : any +>a : [number, string] + +type t02 = { a: [T, U]; } +>t02 : t02 +>T : T +>U : U +>T : T +>a : [T, U] +>T : T +>U : U + +const t02c00 = (>x).a; +>t02c00 : [number, number] +>(>x).a : [number, number] +>(>x) : t02 +>>x : t02 +>t02 : t02 +>x : any +>a : [number, number] + +const t02c01 = (>x).a; +>t02c01 : [1, 1] +>(>x).a : [1, 1] +>(>x) : t02<1, 1> +>>x : t02<1, 1> +>t02 : t02 +>x : any +>a : [1, 1] + +const t02c02 = (>x).a; +>t02c02 : [number, number] +>(>x).a : [number, number] +>(>x) : t02 +>>x : t02 +>t02 : t02 +>x : any +>a : [number, number] + +const t02c03 = (>x).a; +>t02c03 : [1, number] +>(>x).a : [1, number] +>(>x) : t02<1, number> +>>x : t02<1, number> +>t02 : t02 +>x : any +>a : [1, number] + +const t02c04 = (>x).a; +>t02c04 : [number, 1] +>(>x).a : [number, 1] +>(>x) : t02 +>>x : t02 +>t02 : t02 +>x : any +>a : [number, 1] + +type t03 = { a: [T, U]; } +>t03 : t03 +>T : T +>U : U +>T : T +>T : T +>a : [T, U] +>T : T +>U : U + +const t03c00 = (>x).a; +>t03c00 : [number, number] +>(>x).a : [number, number] +>(>x) : t03 +>>x : t03 +>t03 : t03 +>x : any +>a : [number, number] + +const t03c01 = (>x).a; +>t03c01 : [1, 1] +>(>x).a : [1, 1] +>(>x) : t03<1, 1> +>>x : t03<1, 1> +>t03 : t03 +>x : any +>a : [1, 1] + +const t03c02 = (>x).a; +>t03c02 : [number, number] +>(>x).a : [number, number] +>(>x) : t03 +>>x : t03 +>t03 : t03 +>x : any +>a : [number, number] + +const t03c03 = (>x).a; +>t03c03 : [1, 1] +>(>x).a : [1, 1] +>(>x) : t03<1, 1> +>>x : t03<1, 1> +>t03 : t03 +>x : any +>a : [1, 1] + +const t03c04 = (>x).a; +>t03c04 : [number, 1] +>(>x).a : [number, 1] +>(>x) : t03 +>>x : t03 +>t03 : t03 +>x : any +>a : [number, 1] + diff --git a/tests/baselines/reference/genericDefaultsErrors.errors.txt b/tests/baselines/reference/genericDefaultsErrors.errors.txt new file mode 100644 index 00000000000..03769586b41 --- /dev/null +++ b/tests/baselines/reference/genericDefaultsErrors.errors.txt @@ -0,0 +1,110 @@ +tests/cases/compiler/genericDefaultsErrors.ts(4,41): error TS2344: Type 'number' does not satisfy the constraint 'string'. +tests/cases/compiler/genericDefaultsErrors.ts(5,59): error TS2344: Type 'T' does not satisfy the constraint 'number'. + Type 'string' is not assignable to type 'number'. +tests/cases/compiler/genericDefaultsErrors.ts(6,44): error TS2344: Type 'T' does not satisfy the constraint 'number'. +tests/cases/compiler/genericDefaultsErrors.ts(7,39): error TS2344: Type 'number' does not satisfy the constraint 'T'. +tests/cases/compiler/genericDefaultsErrors.ts(11,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/genericDefaultsErrors.ts(14,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/genericDefaultsErrors.ts(18,13): error TS2345: Argument of type '"a"' is not assignable to parameter of type 'number'. +tests/cases/compiler/genericDefaultsErrors.ts(20,11): error TS2428: All declarations of 'i00' must have identical type parameters. +tests/cases/compiler/genericDefaultsErrors.ts(21,11): error TS2428: All declarations of 'i00' must have identical type parameters. +tests/cases/compiler/genericDefaultsErrors.ts(23,11): error TS2428: All declarations of 'i01' must have identical type parameters. +tests/cases/compiler/genericDefaultsErrors.ts(24,11): error TS2428: All declarations of 'i01' must have identical type parameters. +tests/cases/compiler/genericDefaultsErrors.ts(26,27): error TS2706: Required type parameters may not follow optional type parameters. +tests/cases/compiler/genericDefaultsErrors.ts(27,34): error TS2344: Type 'number' does not satisfy the constraint 'string'. +tests/cases/compiler/genericDefaultsErrors.ts(28,52): error TS2344: Type 'T' does not satisfy the constraint 'number'. + Type 'string' is not assignable to type 'number'. +tests/cases/compiler/genericDefaultsErrors.ts(29,37): error TS2344: Type 'T' does not satisfy the constraint 'number'. +tests/cases/compiler/genericDefaultsErrors.ts(30,32): error TS2344: Type 'number' does not satisfy the constraint 'T'. +tests/cases/compiler/genericDefaultsErrors.ts(33,15): error TS2707: Generic type 'i09' requires between 2 and 3 type arguments. +tests/cases/compiler/genericDefaultsErrors.ts(34,15): error TS2707: Generic type 'i09' requires between 2 and 3 type arguments. +tests/cases/compiler/genericDefaultsErrors.ts(37,15): error TS2707: Generic type 'i09' requires between 2 and 3 type arguments. +tests/cases/compiler/genericDefaultsErrors.ts(39,20): error TS2304: Cannot find name 'T'. +tests/cases/compiler/genericDefaultsErrors.ts(39,20): error TS4033: Property 'x' of exported interface has or is using private name 'T'. + + +==== tests/cases/compiler/genericDefaultsErrors.ts (21 errors) ==== + + declare const x: any; + + declare function f03(): void; // error + ~~~~~~ +!!! error TS2344: Type 'number' does not satisfy the constraint 'string'. + declare function f04(): void; // error + ~ +!!! error TS2344: Type 'T' does not satisfy the constraint 'number'. +!!! error TS2344: Type 'string' is not assignable to type 'number'. + declare function f05(): void; // error + ~ +!!! error TS2344: Type 'T' does not satisfy the constraint 'number'. + declare function f06(): void; // error + ~~~~~~ +!!! error TS2344: Type 'number' does not satisfy the constraint 'T'. + + declare function f11(): void; + f11(); // ok + f11<1>(); // error + ~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + f11<1, 2>(); // ok + f11<1, 2, 3>(); // ok + f11<1, 2, 3, 4>(); // error + ~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + + declare function f12(a?: U): void; + f12(); // ok + f12("a"); // error + ~~~ +!!! error TS2345: Argument of type '"a"' is not assignable to parameter of type 'number'. + + interface i00 { } // ok + ~~~ +!!! error TS2428: All declarations of 'i00' must have identical type parameters. + interface i00 { } // error + ~~~ +!!! error TS2428: All declarations of 'i00' must have identical type parameters. + + interface i01 { } // ok + ~~~ +!!! error TS2428: All declarations of 'i01' must have identical type parameters. + interface i01 { } // error + ~~~ +!!! error TS2428: All declarations of 'i01' must have identical type parameters. + + interface i04 { } // error + ~ +!!! error TS2706: Required type parameters may not follow optional type parameters. + interface i05 { } // error + ~~~~~~ +!!! error TS2344: Type 'number' does not satisfy the constraint 'string'. + interface i06 { } // error + ~ +!!! error TS2344: Type 'T' does not satisfy the constraint 'number'. +!!! error TS2344: Type 'string' is not assignable to type 'number'. + interface i07 { } // error + ~ +!!! error TS2344: Type 'T' does not satisfy the constraint 'number'. + interface i08 { } // error + ~~~~~~ +!!! error TS2344: Type 'number' does not satisfy the constraint 'T'. + + interface i09 { } + type i09t00 = i09; // error + ~~~ +!!! error TS2707: Generic type 'i09' requires between 2 and 3 type arguments. + type i09t01 = i09<1>; // error + ~~~~~~ +!!! error TS2707: Generic type 'i09' requires between 2 and 3 type arguments. + type i09t02 = i09<1, 2>; // ok + type i09t03 = i09<1, 2, 3>; // ok + type i09t04 = i09<1, 2, 3, 4>; // error + ~~~~~~~~~~~~~~~ +!!! error TS2707: Generic type 'i09' requires between 2 and 3 type arguments. + + interface i10 { x: T; } // error + ~ +!!! error TS2304: Cannot find name 'T'. + ~ +!!! error TS4033: Property 'x' of exported interface has or is using private name 'T'. + interface i10 {} \ No newline at end of file diff --git a/tests/baselines/reference/genericDefaultsErrors.js b/tests/baselines/reference/genericDefaultsErrors.js new file mode 100644 index 00000000000..6309b01cab3 --- /dev/null +++ b/tests/baselines/reference/genericDefaultsErrors.js @@ -0,0 +1,50 @@ +//// [genericDefaultsErrors.ts] + +declare const x: any; + +declare function f03(): void; // error +declare function f04(): void; // error +declare function f05(): void; // error +declare function f06(): void; // error + +declare function f11(): void; +f11(); // ok +f11<1>(); // error +f11<1, 2>(); // ok +f11<1, 2, 3>(); // ok +f11<1, 2, 3, 4>(); // error + +declare function f12(a?: U): void; +f12(); // ok +f12("a"); // error + +interface i00 { } // ok +interface i00 { } // error + +interface i01 { } // ok +interface i01 { } // error + +interface i04 { } // error +interface i05 { } // error +interface i06 { } // error +interface i07 { } // error +interface i08 { } // error + +interface i09 { } +type i09t00 = i09; // error +type i09t01 = i09<1>; // error +type i09t02 = i09<1, 2>; // ok +type i09t03 = i09<1, 2, 3>; // ok +type i09t04 = i09<1, 2, 3, 4>; // error + +interface i10 { x: T; } // error +interface i10 {} + +//// [genericDefaultsErrors.js] +f11(); // ok +f11(); // error +f11(); // ok +f11(); // ok +f11(); // error +f12(); // ok +f12("a"); // error diff --git a/tests/baselines/reference/genericDerivedTypeWithSpecializedBase.js b/tests/baselines/reference/genericDerivedTypeWithSpecializedBase.js index 1b455073196..cd028bb28b2 100644 --- a/tests/baselines/reference/genericDerivedTypeWithSpecializedBase.js +++ b/tests/baselines/reference/genericDerivedTypeWithSpecializedBase.js @@ -13,11 +13,16 @@ x = y; // error //// [genericDerivedTypeWithSpecializedBase.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -26,7 +31,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.js b/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.js index 0abd655e1da..694bc87c453 100644 --- a/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.js +++ b/tests/baselines/reference/genericDerivedTypeWithSpecializedBase2.js @@ -13,11 +13,16 @@ x = y; // error //// [genericDerivedTypeWithSpecializedBase2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -26,7 +31,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/genericInheritedDefaultConstructors.js b/tests/baselines/reference/genericInheritedDefaultConstructors.js index 059a3213b7a..15848c10874 100644 --- a/tests/baselines/reference/genericInheritedDefaultConstructors.js +++ b/tests/baselines/reference/genericInheritedDefaultConstructors.js @@ -11,11 +11,16 @@ var c:Constructor> = B; // shouldn't error here //// [genericInheritedDefaultConstructors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -24,7 +29,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/genericInterfaceFunctionTypeParameter.js b/tests/baselines/reference/genericInterfaceFunctionTypeParameter.js index 4f3895a33b8..83b100f4837 100644 --- a/tests/baselines/reference/genericInterfaceFunctionTypeParameter.js +++ b/tests/baselines/reference/genericInterfaceFunctionTypeParameter.js @@ -10,6 +10,7 @@ export function foo(fn: (ifoo: IFoo) => void) { //// [genericInterfaceFunctionTypeParameter.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; function foo(fn) { foo(fn); // Invocation is necessary to repro (!) } diff --git a/tests/baselines/reference/genericMemberFunction.js b/tests/baselines/reference/genericMemberFunction.js index c15868e20c4..61a9298eb7f 100644 --- a/tests/baselines/reference/genericMemberFunction.js +++ b/tests/baselines/reference/genericMemberFunction.js @@ -25,6 +25,7 @@ export class BuildResult{ //// [genericMemberFunction.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var BuildError = (function () { function BuildError() { } diff --git a/tests/baselines/reference/genericPrototypeProperty2.js b/tests/baselines/reference/genericPrototypeProperty2.js index eac025cce9b..66f058090dc 100644 --- a/tests/baselines/reference/genericPrototypeProperty2.js +++ b/tests/baselines/reference/genericPrototypeProperty2.js @@ -16,11 +16,16 @@ class MyEventWrapper extends BaseEventWrapper { } //// [genericPrototypeProperty2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var BaseEvent = (function () { function BaseEvent() { } @@ -29,7 +34,7 @@ var BaseEvent = (function () { var MyEvent = (function (_super) { __extends(MyEvent, _super); function MyEvent() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return MyEvent; }(BaseEvent)); @@ -41,7 +46,7 @@ var BaseEventWrapper = (function () { var MyEventWrapper = (function (_super) { __extends(MyEventWrapper, _super); function MyEventWrapper() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return MyEventWrapper; }(BaseEventWrapper)); diff --git a/tests/baselines/reference/genericPrototypeProperty3.js b/tests/baselines/reference/genericPrototypeProperty3.js index 9e3ede0019d..1fef7a9b407 100644 --- a/tests/baselines/reference/genericPrototypeProperty3.js +++ b/tests/baselines/reference/genericPrototypeProperty3.js @@ -15,11 +15,16 @@ class MyEventWrapper extends BaseEventWrapper { } //// [genericPrototypeProperty3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var BaseEvent = (function () { function BaseEvent() { } @@ -28,7 +33,7 @@ var BaseEvent = (function () { var MyEvent = (function (_super) { __extends(MyEvent, _super); function MyEvent() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return MyEvent; }(BaseEvent)); @@ -40,7 +45,7 @@ var BaseEventWrapper = (function () { var MyEventWrapper = (function (_super) { __extends(MyEventWrapper, _super); function MyEventWrapper() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return MyEventWrapper; }(BaseEventWrapper)); diff --git a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors1.js b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors1.js index f9bcc86194c..49debc2ca84 100644 --- a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors1.js +++ b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors1.js @@ -16,4 +16,5 @@ export declare module TypeScript { //// [genericRecursiveImplicitConstructorErrors1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.js b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.js index 401a2e94b68..22886334aad 100644 --- a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.js +++ b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.js @@ -27,11 +27,16 @@ module TypeScript2 { //// [genericRecursiveImplicitConstructorErrors2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var TypeScript2; (function (TypeScript2) { ; @@ -57,7 +62,7 @@ var TypeScript2; var PullTypeSymbol = (function (_super) { __extends(PullTypeSymbol, _super); function PullTypeSymbol() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PullTypeSymbol; }(PullSymbol)); diff --git a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.js b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.js index c7643d4a9a2..d0bf08113d2 100644 --- a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.js +++ b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors3.js @@ -31,11 +31,16 @@ module TypeScript { //// [genericRecursiveImplicitConstructorErrors3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var TypeScript; (function (TypeScript) { var MemberName = (function () { @@ -58,7 +63,7 @@ var TypeScript; var PullTypeSymbol = (function (_super) { __extends(PullTypeSymbol, _super); function PullTypeSymbol() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this._elementType = null; return _this; } diff --git a/tests/baselines/reference/genericReturnTypeFromGetter1.js b/tests/baselines/reference/genericReturnTypeFromGetter1.js index 56367ca9c5e..728d81dd147 100644 --- a/tests/baselines/reference/genericReturnTypeFromGetter1.js +++ b/tests/baselines/reference/genericReturnTypeFromGetter1.js @@ -11,6 +11,7 @@ export class DbSet { //// [genericReturnTypeFromGetter1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var DbSet = (function () { function DbSet() { } diff --git a/tests/baselines/reference/genericTypeAssertions2.js b/tests/baselines/reference/genericTypeAssertions2.js index 687d593f01e..160967e83de 100644 --- a/tests/baselines/reference/genericTypeAssertions2.js +++ b/tests/baselines/reference/genericTypeAssertions2.js @@ -14,11 +14,16 @@ var r4: A = >new A(); var r5: A = >[]; // error //// [genericTypeAssertions2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -28,7 +33,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function () { return null; diff --git a/tests/baselines/reference/genericTypeAssertions4.js b/tests/baselines/reference/genericTypeAssertions4.js index 50dbe5debbd..991db3822ac 100644 --- a/tests/baselines/reference/genericTypeAssertions4.js +++ b/tests/baselines/reference/genericTypeAssertions4.js @@ -26,11 +26,16 @@ function foo2(x: T) { } //// [genericTypeAssertions4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -40,7 +45,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function () { return 1; }; return B; @@ -48,7 +53,7 @@ var B = (function (_super) { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.baz = function () { return 1; }; return C; diff --git a/tests/baselines/reference/genericTypeAssertions6.js b/tests/baselines/reference/genericTypeAssertions6.js index 7bbd7351f1d..069e567ab10 100644 --- a/tests/baselines/reference/genericTypeAssertions6.js +++ b/tests/baselines/reference/genericTypeAssertions6.js @@ -25,11 +25,16 @@ var b: B; var c: A = >b; //// [genericTypeAssertions6.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(x) { var y = x; @@ -44,7 +49,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.g = function (x) { var a = x; diff --git a/tests/baselines/reference/genericTypeConstraints.js b/tests/baselines/reference/genericTypeConstraints.js index 67303166aa3..cbb03b683a8 100644 --- a/tests/baselines/reference/genericTypeConstraints.js +++ b/tests/baselines/reference/genericTypeConstraints.js @@ -14,11 +14,16 @@ class BarExtended extends Bar { } //// [genericTypeConstraints.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js index cf19feede34..8fc00dcc08f 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js @@ -40,11 +40,16 @@ var k = null; //// [genericTypeReferenceWithoutTypeArgument.js] // it is an error to use a generic type without type arguments // all of these are errors -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -60,7 +65,7 @@ var g = function f(x) { var y; return y; }; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); @@ -76,7 +81,7 @@ var M; var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(M.E)); diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js index 973ee231762..9730afdee04 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js @@ -40,11 +40,16 @@ var k = null; //// [genericTypeReferenceWithoutTypeArgument2.js] // it is an error to use a generic type without type arguments // all of these are errors -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var c; var a; var b; @@ -55,14 +60,14 @@ var g = function f(x) { var y; return y; }; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(I)); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(M.C)); diff --git a/tests/baselines/reference/genericTypeWithMultipleBases1.js b/tests/baselines/reference/genericTypeWithMultipleBases1.js index 2ee085ef07e..a958516dfa0 100644 --- a/tests/baselines/reference/genericTypeWithMultipleBases1.js +++ b/tests/baselines/reference/genericTypeWithMultipleBases1.js @@ -21,6 +21,7 @@ x.m2(); //// [genericTypeWithMultipleBases1.js] "use strict"; +exports.__esModule = true; var x; x.p1; x.m1(); diff --git a/tests/baselines/reference/genericTypeWithMultipleBases2.js b/tests/baselines/reference/genericTypeWithMultipleBases2.js index 4a31e354de6..43651ec8278 100644 --- a/tests/baselines/reference/genericTypeWithMultipleBases2.js +++ b/tests/baselines/reference/genericTypeWithMultipleBases2.js @@ -21,6 +21,7 @@ x.m2(); //// [genericTypeWithMultipleBases2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var x; x.p1; x.m1(); diff --git a/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.js b/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.js index d6fb98b67ca..3f5e3dcfe8e 100644 --- a/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.js +++ b/tests/baselines/reference/genericWithIndexerOfTypeParameterType2.js @@ -15,13 +15,19 @@ export class ListItem extends CollectionItem { //// [genericWithIndexerOfTypeParameterType2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var Collection = (function () { function Collection() { } @@ -31,7 +37,7 @@ define(["require", "exports"], function (require, exports) { var List = (function (_super) { __extends(List, _super); function List() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } List.prototype.Bar = function () { }; return List; @@ -46,7 +52,7 @@ define(["require", "exports"], function (require, exports) { var ListItem = (function (_super) { __extends(ListItem, _super); function ListItem() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ListItem; }(CollectionItem)); diff --git a/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline b/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline index 5c865321691..5739596a8f0 100644 --- a/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline +++ b/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline @@ -3,6 +3,7 @@ EmitSkipped: false EmitSkipped: false FileName : /tests/cases/fourslash/inputFile2.js "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var Foo = (function () { function Foo() { } diff --git a/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline b/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline index a181526eb27..50e80f94831 100644 --- a/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline +++ b/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline @@ -4,6 +4,7 @@ Diagnostics: FileName : /tests/cases/fourslash/inputFile.js define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var C = (function () { function C() { } diff --git a/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt b/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt index 845a4011d9f..dc77d530e01 100644 --- a/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt +++ b/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyping.ts(8,16): error TS2322: Type '"string"' is not assignable to type 'number'. +tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyping.ts(8,9): error TS2322: Type '"string"' is not assignable to type 'number'. ==== tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyping.ts (1 errors) ==== @@ -10,7 +10,7 @@ tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyp set X(x: number) { } get X() { return "string"; // Error; get contextual type by set accessor parameter type annotation - ~~~~~~~~ + ~~~~~~~~~~~~~~~~ !!! error TS2322: Type '"string"' is not assignable to type 'number'. } diff --git a/tests/baselines/reference/giant.js b/tests/baselines/reference/giant.js index 149a975d413..ce4df039932 100644 --- a/tests/baselines/reference/giant.js +++ b/tests/baselines/reference/giant.js @@ -684,6 +684,7 @@ export declare module eaM { //// [giant.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; /* Prefixes p -> public diff --git a/tests/baselines/reference/globalAugmentationModuleResolution.js b/tests/baselines/reference/globalAugmentationModuleResolution.js index e1a4ebce8c5..6dd87de81fd 100644 --- a/tests/baselines/reference/globalAugmentationModuleResolution.js +++ b/tests/baselines/reference/globalAugmentationModuleResolution.js @@ -8,3 +8,4 @@ declare global { //// [a.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/globalAugmentationModuleResolution.types b/tests/baselines/reference/globalAugmentationModuleResolution.types index c057ea2943d..75f23b0cd6b 100644 --- a/tests/baselines/reference/globalAugmentationModuleResolution.types +++ b/tests/baselines/reference/globalAugmentationModuleResolution.types @@ -3,7 +3,7 @@ export { }; declare global { ->global : any +>global : typeof global var x: number; >x : number diff --git a/tests/baselines/reference/heterogeneousArrayLiterals.js b/tests/baselines/reference/heterogeneousArrayLiterals.js index 9b15cf743f0..f65fac6fb5d 100644 --- a/tests/baselines/reference/heterogeneousArrayLiterals.js +++ b/tests/baselines/reference/heterogeneousArrayLiterals.js @@ -133,11 +133,16 @@ function foo4(t: T, u: U) { //// [heterogeneousArrayLiterals.js] // type of an array is the best common type of its elements (plus its contextual type if it exists) -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = [1, '']; // {}[] var b = [1, null]; // number[] var c = [1, '', null]; // {}[] @@ -160,14 +165,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base)); diff --git a/tests/baselines/reference/ifDoWhileStatements.js b/tests/baselines/reference/ifDoWhileStatements.js index 483370bee5c..22dd78a9687 100644 --- a/tests/baselines/reference/ifDoWhileStatements.js +++ b/tests/baselines/reference/ifDoWhileStatements.js @@ -164,11 +164,16 @@ do { }while(fn) //// [ifDoWhileStatements.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -177,7 +182,7 @@ var C = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(C)); diff --git a/tests/baselines/reference/illegalSuperCallsInConstructor.js b/tests/baselines/reference/illegalSuperCallsInConstructor.js index 868d53daad5..bb29e857e9b 100644 --- a/tests/baselines/reference/illegalSuperCallsInConstructor.js +++ b/tests/baselines/reference/illegalSuperCallsInConstructor.js @@ -21,11 +21,16 @@ class Derived extends Base { } //// [illegalSuperCallsInConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -34,7 +39,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this; + var _this = this; var r2 = function () { return _this = _super.call(this) || this; }; var r3 = function () { _this = _super.call(this) || this; }; var r4 = function () { _this = _super.call(this) || this; }; diff --git a/tests/baselines/reference/implementClausePrecedingExtends.js b/tests/baselines/reference/implementClausePrecedingExtends.js index df725cde43a..8c6c591138e 100644 --- a/tests/baselines/reference/implementClausePrecedingExtends.js +++ b/tests/baselines/reference/implementClausePrecedingExtends.js @@ -3,11 +3,16 @@ class C { foo: number } class D implements C extends C { } //// [implementClausePrecedingExtends.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -16,7 +21,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.js b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.js index a5a5e02c156..d492e7fa7e2 100644 --- a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.js +++ b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.js @@ -86,11 +86,16 @@ module M2 { } //// [implementingAnInterfaceExtendingClassWithPrivates2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -99,21 +104,21 @@ var Foo = (function () { var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar; }(Foo)); var Bar2 = (function (_super) { __extends(Bar2, _super); function Bar2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar2; }(Foo)); var Bar3 = (function (_super) { __extends(Bar3, _super); function Bar3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar3; }(Foo)); @@ -128,28 +133,28 @@ var M; var Baz = (function (_super) { __extends(Baz, _super); function Baz() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Baz; }(Foo)); var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar; }(Foo)); var Bar2 = (function (_super) { __extends(Bar2, _super); function Bar2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar2; }(Foo)); var Bar3 = (function (_super) { __extends(Bar3, _super); function Bar3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar3; }(Foo)); @@ -165,14 +170,14 @@ var M2; var Baz = (function (_super) { __extends(Baz, _super); function Baz() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Baz; }(Foo)); var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar; }(Foo)); @@ -183,14 +188,14 @@ var M2; var Bar2 = (function (_super) { __extends(Bar2, _super); function Bar2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar2; }(Foo)); var Bar3 = (function (_super) { __extends(Bar3, _super); function Bar3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar3; }(Foo)); diff --git a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js index d0f74847141..6bffdf9d4e7 100644 --- a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js +++ b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js @@ -42,11 +42,16 @@ class Bar8 extends Foo implements I { //// [implementingAnInterfaceExtendingClassWithProtecteds.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -75,28 +80,28 @@ var Bar4 = (function () { var Bar5 = (function (_super) { __extends(Bar5, _super); function Bar5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar5; }(Foo)); var Bar6 = (function (_super) { __extends(Bar6, _super); function Bar6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar6; }(Foo)); var Bar7 = (function (_super) { __extends(Bar7, _super); function Bar7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar7; }(Foo)); var Bar8 = (function (_super) { __extends(Bar8, _super); function Bar8() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar8; }(Foo)); diff --git a/tests/baselines/reference/implementsInClassExpression.symbols b/tests/baselines/reference/implementsInClassExpression.symbols index 48a44d91e9c..bf3b3ef9337 100644 --- a/tests/baselines/reference/implementsInClassExpression.symbols +++ b/tests/baselines/reference/implementsInClassExpression.symbols @@ -11,5 +11,5 @@ let cls = class implements Foo { >Foo : Symbol(Foo, Decl(implementsInClassExpression.ts, 0, 0)) doThing() { } ->doThing : Symbol((Anonymous class).doThing, Decl(implementsInClassExpression.ts, 4, 32)) +>doThing : Symbol(cls.doThing, Decl(implementsInClassExpression.ts, 4, 32)) } diff --git a/tests/baselines/reference/implementsInClassExpression.types b/tests/baselines/reference/implementsInClassExpression.types index d3647c30ff1..0734f8b8b78 100644 --- a/tests/baselines/reference/implementsInClassExpression.types +++ b/tests/baselines/reference/implementsInClassExpression.types @@ -7,8 +7,8 @@ interface Foo { } let cls = class implements Foo { ->cls : typeof (Anonymous class) ->class implements Foo { doThing() { }} : typeof (Anonymous class) +>cls : typeof cls +>class implements Foo { doThing() { }} : typeof cls >Foo : Foo doThing() { } diff --git a/tests/baselines/reference/importAliasAnExternalModuleInsideAnInternalModule.js b/tests/baselines/reference/importAliasAnExternalModuleInsideAnInternalModule.js index c7dd59f9ab7..60bea32e305 100644 --- a/tests/baselines/reference/importAliasAnExternalModuleInsideAnInternalModule.js +++ b/tests/baselines/reference/importAliasAnExternalModuleInsideAnInternalModule.js @@ -16,6 +16,7 @@ module m_private { //// [importAliasAnExternalModuleInsideAnInternalModule_file0.js] "use strict"; +exports.__esModule = true; var m; (function (m) { function foo() { } @@ -23,6 +24,7 @@ var m; })(m = exports.m || (exports.m = {})); //// [importAliasAnExternalModuleInsideAnInternalModule_file1.js] "use strict"; +exports.__esModule = true; var r = require("./importAliasAnExternalModuleInsideAnInternalModule_file0"); var m_private; (function (m_private) { diff --git a/tests/baselines/reference/importAsBaseClass.js b/tests/baselines/reference/importAsBaseClass.js index b4f45cac806..725390825c6 100644 --- a/tests/baselines/reference/importAsBaseClass.js +++ b/tests/baselines/reference/importAsBaseClass.js @@ -12,6 +12,7 @@ class Hello extends Greeter { } //// [importAsBaseClass_0.js] "use strict"; +exports.__esModule = true; var Greeter = (function () { function Greeter() { } @@ -21,16 +22,22 @@ var Greeter = (function () { exports.Greeter = Greeter; //// [importAsBaseClass_1.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var Greeter = require("./importAsBaseClass_0"); var Hello = (function (_super) { __extends(Hello, _super); function Hello() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Hello; }(Greeter)); diff --git a/tests/baselines/reference/importDecl.js b/tests/baselines/reference/importDecl.js index 47bf5a1b2a1..1e5e5d0ec71 100644 --- a/tests/baselines/reference/importDecl.js +++ b/tests/baselines/reference/importDecl.js @@ -83,6 +83,7 @@ export var useMultiImport_m4_f4 = multiImport_m4.foo(); //// [importDecl_require.js] "use strict"; +exports.__esModule = true; var d = (function () { function d() { } @@ -93,6 +94,7 @@ function foo() { return null; } exports.foo = foo; //// [importDecl_require1.js] "use strict"; +exports.__esModule = true; var d = (function () { function d() { } @@ -104,6 +106,7 @@ function foo() { return null; } exports.foo = foo; //// [importDecl_require2.js] "use strict"; +exports.__esModule = true; var d = (function () { function d() { } @@ -114,6 +117,7 @@ function foo() { return null; } exports.foo = foo; //// [importDecl_require3.js] "use strict"; +exports.__esModule = true; var d = (function () { function d() { } @@ -124,10 +128,12 @@ function foo() { return null; } exports.foo = foo; //// [importDecl_require4.js] "use strict"; +exports.__esModule = true; function foo2() { return null; } exports.foo2 = foo2; //// [importDecl_1.js] "use strict"; +exports.__esModule = true; /// /// /// diff --git a/tests/baselines/reference/importDeclRefereingExternalModuleWithNoResolve.js b/tests/baselines/reference/importDeclRefereingExternalModuleWithNoResolve.js index 383c6629ed1..1aadcb875f0 100644 --- a/tests/baselines/reference/importDeclRefereingExternalModuleWithNoResolve.js +++ b/tests/baselines/reference/importDeclRefereingExternalModuleWithNoResolve.js @@ -7,3 +7,4 @@ declare module "m1" { //// [importDeclRefereingExternalModuleWithNoResolve.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/importDeclWithClassModifiers.js b/tests/baselines/reference/importDeclWithClassModifiers.js index 0af92b1976a..00e5dae1f95 100644 --- a/tests/baselines/reference/importDeclWithClassModifiers.js +++ b/tests/baselines/reference/importDeclWithClassModifiers.js @@ -12,6 +12,7 @@ var b: a; //// [importDeclWithClassModifiers.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.a = x.c; exports.b = x.c; exports.c = x.c; diff --git a/tests/baselines/reference/importDeclWithDeclareModifier.js b/tests/baselines/reference/importDeclWithDeclareModifier.js index 7c3d3782934..e7929ac27fc 100644 --- a/tests/baselines/reference/importDeclWithDeclareModifier.js +++ b/tests/baselines/reference/importDeclWithDeclareModifier.js @@ -9,5 +9,6 @@ var b: a; //// [importDeclWithDeclareModifier.js] "use strict"; +exports.__esModule = true; exports.a = x.c; var b; diff --git a/tests/baselines/reference/importDeclWithExportModifier.js b/tests/baselines/reference/importDeclWithExportModifier.js index c04bf542b58..26076c2630e 100644 --- a/tests/baselines/reference/importDeclWithExportModifier.js +++ b/tests/baselines/reference/importDeclWithExportModifier.js @@ -10,6 +10,7 @@ var b: a; //// [importDeclWithExportModifier.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.a = x.c; var b; }); diff --git a/tests/baselines/reference/importDeclWithExportModifierAndExportAssignment.js b/tests/baselines/reference/importDeclWithExportModifierAndExportAssignment.js index da41309d56b..ce5069c335e 100644 --- a/tests/baselines/reference/importDeclWithExportModifierAndExportAssignment.js +++ b/tests/baselines/reference/importDeclWithExportModifierAndExportAssignment.js @@ -8,4 +8,5 @@ export = x; //// [importDeclWithExportModifierAndExportAssignment.js] "use strict"; +exports.__esModule = true; exports.a = x.c; diff --git a/tests/baselines/reference/importDeclarationUsedAsTypeQuery.js b/tests/baselines/reference/importDeclarationUsedAsTypeQuery.js index c2cc0b8ea7a..cce30fd8b85 100644 --- a/tests/baselines/reference/importDeclarationUsedAsTypeQuery.js +++ b/tests/baselines/reference/importDeclarationUsedAsTypeQuery.js @@ -13,6 +13,7 @@ export var x: typeof a; //// [importDeclarationUsedAsTypeQuery_require.js] "use strict"; +exports.__esModule = true; var B = (function () { function B() { } @@ -21,6 +22,7 @@ var B = (function () { exports.B = B; //// [importDeclarationUsedAsTypeQuery_1.js] "use strict"; +exports.__esModule = true; //// [importDeclarationUsedAsTypeQuery_require.d.ts] diff --git a/tests/baselines/reference/importHelpers.js b/tests/baselines/reference/importHelpers.js index 762f0778945..bf66829a435 100644 --- a/tests/baselines/reference/importHelpers.js +++ b/tests/baselines/reference/importHelpers.js @@ -35,6 +35,7 @@ export declare function __awaiter(thisArg: any, _arguments: any, P: Function, ge //// [external.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var A = (function () { function A() { @@ -45,7 +46,7 @@ exports.A = A; var B = (function (_super) { tslib_1.__extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -67,11 +68,16 @@ C = tslib_1.__decorate([ dec ], C); //// [script.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); @@ -92,7 +98,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/importHelpersAmd.js b/tests/baselines/reference/importHelpersAmd.js index 96d398e05eb..3d74b2277fb 100644 --- a/tests/baselines/reference/importHelpersAmd.js +++ b/tests/baselines/reference/importHelpersAmd.js @@ -22,6 +22,7 @@ export declare function __exportStar(m: any, exports: any): void; //// [a.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var A = (function () { function A() { } @@ -32,11 +33,12 @@ define(["require", "exports"], function (require, exports) { //// [b.js] define(["require", "exports", "tslib", "./a", "./a"], function (require, exports, tslib_1, a_1, a_2) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); tslib_1.__exportStar(a_2, exports); var B = (function (_super) { tslib_1.__extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(a_1.A)); diff --git a/tests/baselines/reference/importHelpersES6.js b/tests/baselines/reference/importHelpersES6.js index 209f3c34588..bc17939e2cc 100644 --- a/tests/baselines/reference/importHelpersES6.js +++ b/tests/baselines/reference/importHelpersES6.js @@ -5,10 +5,12 @@ declare var dec: any; @dec export class A { } + +const o = { a: 1 }; +const y = { ...o }; //// [tslib.d.ts] export declare function __extends(d: Function, b: Function): void; -export declare function __assign(t: any, ...sources: any[]): any; export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; export declare function __param(paramIndex: number, decorator: Function): Function; export declare function __metadata(metadataKey: any, metadataValue: any): Function; @@ -23,3 +25,5 @@ A = tslib_1.__decorate([ dec ], A); export { A }; +const o = { a: 1 }; +const y = Object.assign({}, o); diff --git a/tests/baselines/reference/importHelpersES6.symbols b/tests/baselines/reference/importHelpersES6.symbols index 284a2251a6b..66a8b131aec 100644 --- a/tests/baselines/reference/importHelpersES6.symbols +++ b/tests/baselines/reference/importHelpersES6.symbols @@ -8,6 +8,14 @@ declare var dec: any; } +const o = { a: 1 }; +>o : Symbol(o, Decl(a.ts, 5, 5)) +>a : Symbol(a, Decl(a.ts, 5, 11)) + +const y = { ...o }; +>y : Symbol(y, Decl(a.ts, 6, 5)) +>o : Symbol(o, Decl(a.ts, 5, 5)) + === tests/cases/compiler/tslib.d.ts === export declare function __extends(d: Function, b: Function): void; >__extends : Symbol(__extends, Decl(tslib.d.ts, --, --)) @@ -16,11 +24,6 @@ export declare function __extends(d: Function, b: Function): void; >b : Symbol(b, Decl(tslib.d.ts, --, --)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) -export declare function __assign(t: any, ...sources: any[]): any; ->__assign : Symbol(__assign, Decl(tslib.d.ts, --, --)) ->t : Symbol(t, Decl(tslib.d.ts, --, --)) ->sources : Symbol(sources, Decl(tslib.d.ts, --, --)) - export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; >__decorate : Symbol(__decorate, Decl(tslib.d.ts, --, --)) >decorators : Symbol(decorators, Decl(tslib.d.ts, --, --)) diff --git a/tests/baselines/reference/importHelpersES6.types b/tests/baselines/reference/importHelpersES6.types index ebfd5a5a2a5..26f30e32e58 100644 --- a/tests/baselines/reference/importHelpersES6.types +++ b/tests/baselines/reference/importHelpersES6.types @@ -8,6 +8,17 @@ declare var dec: any; } +const o = { a: 1 }; +>o : { a: number; } +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 + +const y = { ...o }; +>y : { a: number; } +>{ ...o } : { a: number; } +>o : { a: number; } + === tests/cases/compiler/tslib.d.ts === export declare function __extends(d: Function, b: Function): void; >__extends : (d: Function, b: Function) => void @@ -16,11 +27,6 @@ export declare function __extends(d: Function, b: Function): void; >b : Function >Function : Function -export declare function __assign(t: any, ...sources: any[]): any; ->__assign : (t: any, ...sources: any[]) => any ->t : any ->sources : any[] - export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; >__decorate : (decorators: Function[], target: any, key?: string | symbol, desc?: any) => any >decorators : Function[] diff --git a/tests/baselines/reference/importHelpersInAmbientContext.js b/tests/baselines/reference/importHelpersInAmbientContext.js index 9433b41d117..f9e65fe56f7 100644 --- a/tests/baselines/reference/importHelpersInAmbientContext.js +++ b/tests/baselines/reference/importHelpersInAmbientContext.js @@ -59,3 +59,4 @@ export declare function __exportStar(m: any, exports: any): void; //// [b.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/importHelpersInIsolatedModules.js b/tests/baselines/reference/importHelpersInIsolatedModules.js index 5c395ea0b9f..72a91ac365e 100644 --- a/tests/baselines/reference/importHelpersInIsolatedModules.js +++ b/tests/baselines/reference/importHelpersInIsolatedModules.js @@ -35,6 +35,7 @@ export declare function __awaiter(thisArg: any, _arguments: any, P: Function, ge //// [external.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var A = (function () { function A() { @@ -45,7 +46,7 @@ exports.A = A; var B = (function (_super) { tslib_1.__extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -68,6 +69,7 @@ C = tslib_1.__decorate([ ], C); //// [script.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var A = (function () { function A() { @@ -77,7 +79,7 @@ var A = (function () { var B = (function (_super) { tslib_1.__extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/importHelpersInTsx.js b/tests/baselines/reference/importHelpersInTsx.js index 29e43e191e8..330b8623f69 100644 --- a/tests/baselines/reference/importHelpersInTsx.js +++ b/tests/baselines/reference/importHelpersInTsx.js @@ -21,6 +21,7 @@ export declare function __awaiter(thisArg: any, _arguments: any, P: Function, ge //// [external.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); exports.x = React.createElement("span", tslib_1.__assign({}, o)); //// [script.js] diff --git a/tests/baselines/reference/importHelpersNoHelpers.js b/tests/baselines/reference/importHelpersNoHelpers.js index ae709c086ba..9f4645a4a31 100644 --- a/tests/baselines/reference/importHelpersNoHelpers.js +++ b/tests/baselines/reference/importHelpersNoHelpers.js @@ -38,9 +38,11 @@ export {} //// [other.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.x = 1; //// [external.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); tslib_1.__exportStar(require("./other"), exports); var A = (function () { @@ -52,7 +54,7 @@ exports.A = A; var B = (function (_super) { tslib_1.__extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -77,11 +79,16 @@ var o = { a: 1 }; var y = tslib_1.__assign({}, o); var x = tslib_1.__rest(y, []); //// [script.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); @@ -102,7 +109,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/importHelpersNoModule.js b/tests/baselines/reference/importHelpersNoModule.js index 65a004eb66c..36a326e124d 100644 --- a/tests/baselines/reference/importHelpersNoModule.js +++ b/tests/baselines/reference/importHelpersNoModule.js @@ -27,6 +27,7 @@ class C { //// [external.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var A = (function () { function A() { @@ -37,7 +38,7 @@ exports.A = A; var B = (function (_super) { tslib_1.__extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -59,11 +60,16 @@ C = tslib_1.__decorate([ dec ], C); //// [script.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); @@ -84,7 +90,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/importHelpersOutFile.js b/tests/baselines/reference/importHelpersOutFile.js index a45f6285782..55bf2ea9d46 100644 --- a/tests/baselines/reference/importHelpersOutFile.js +++ b/tests/baselines/reference/importHelpersOutFile.js @@ -23,6 +23,7 @@ export declare function __awaiter(thisArg: any, _arguments: any, P: Function, ge //// [out.js] define("a", ["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var A = (function () { function A() { } @@ -32,10 +33,11 @@ define("a", ["require", "exports"], function (require, exports) { }); define("b", ["require", "exports", "tslib", "a"], function (require, exports, tslib_1, a_1) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var B = (function (_super) { tslib_1.__extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(a_1.A)); @@ -43,10 +45,11 @@ define("b", ["require", "exports", "tslib", "a"], function (require, exports, ts }); define("c", ["require", "exports", "tslib", "a"], function (require, exports, tslib_2, a_2) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var C = (function (_super) { tslib_2.__extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(a_2.A)); diff --git a/tests/baselines/reference/importHelpersSystem.js b/tests/baselines/reference/importHelpersSystem.js index 43556ae6b76..fbd0f5e589f 100644 --- a/tests/baselines/reference/importHelpersSystem.js +++ b/tests/baselines/reference/importHelpersSystem.js @@ -63,7 +63,7 @@ System.register(["tslib", "./a"], function (exports_1, context_1) { B = (function (_super) { tslib_1.__extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(a_1.A)); diff --git a/tests/baselines/reference/importImportOnlyModule.js b/tests/baselines/reference/importImportOnlyModule.js index 013999321f9..0c6f0540354 100644 --- a/tests/baselines/reference/importImportOnlyModule.js +++ b/tests/baselines/reference/importImportOnlyModule.js @@ -18,6 +18,7 @@ var x = foo; // Cause a runtime dependency //// [foo_0.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var C1 = (function () { function C1() { this.m1 = 42; @@ -30,10 +31,12 @@ define(["require", "exports"], function (require, exports) { //// [foo_1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var answer = 42; // No exports }); //// [foo_2.js] define(["require", "exports", "./foo_1"], function (require, exports, foo) { "use strict"; + exports.__esModule = true; var x = foo; // Cause a runtime dependency }); diff --git a/tests/baselines/reference/importInsideModule.js b/tests/baselines/reference/importInsideModule.js index d4f12d0c1b6..da492a7103d 100644 --- a/tests/baselines/reference/importInsideModule.js +++ b/tests/baselines/reference/importInsideModule.js @@ -11,6 +11,7 @@ export module myModule { //// [importInsideModule_file2.js] "use strict"; +exports.__esModule = true; var myModule; (function (myModule) { var a = foo.x; diff --git a/tests/baselines/reference/importNonExternalModule.js b/tests/baselines/reference/importNonExternalModule.js index 2a8e6792860..0340bcd35cb 100644 --- a/tests/baselines/reference/importNonExternalModule.js +++ b/tests/baselines/reference/importNonExternalModule.js @@ -21,6 +21,7 @@ var foo; //// [foo_1.js] define(["require", "exports", "./foo_0"], function (require, exports, foo) { "use strict"; + exports.__esModule = true; // Import should fail. foo_0 not an external module if (foo.answer === 42) { } diff --git a/tests/baselines/reference/importNonStringLiteral.js b/tests/baselines/reference/importNonStringLiteral.js index 002092d8162..eb76621f7c0 100644 --- a/tests/baselines/reference/importNonStringLiteral.js +++ b/tests/baselines/reference/importNonStringLiteral.js @@ -5,4 +5,5 @@ import foo = require(x); // invalid //// [foo_0.js] "use strict"; +exports.__esModule = true; var x = "filename"; diff --git a/tests/baselines/reference/importShadowsGlobalName.js b/tests/baselines/reference/importShadowsGlobalName.js index 34cc0604e7a..94be0dfd5a0 100644 --- a/tests/baselines/reference/importShadowsGlobalName.js +++ b/tests/baselines/reference/importShadowsGlobalName.js @@ -21,17 +21,22 @@ define(["require", "exports"], function (require, exports) { return Foo; }); //// [Bar.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); define(["require", "exports", "Foo"], function (require, exports, Error) { "use strict"; var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar; }(Error)); diff --git a/tests/baselines/reference/importTsBeforeDTs.js b/tests/baselines/reference/importTsBeforeDTs.js index b57df504993..40213ce9968 100644 --- a/tests/baselines/reference/importTsBeforeDTs.js +++ b/tests/baselines/reference/importTsBeforeDTs.js @@ -15,9 +15,11 @@ var z2 = foo.y + 10; // Should resolve //// [foo_0.js] "use strict"; +exports.__esModule = true; exports.y = 42; //// [foo_1.js] "use strict"; +exports.__esModule = true; var foo = require("./foo_0"); var z1 = foo.x + 10; // Should error, as .ts preferred over .d.ts var z2 = foo.y + 10; // Should resolve diff --git a/tests/baselines/reference/importUsedInExtendsList1.js b/tests/baselines/reference/importUsedInExtendsList1.js index a40c3a51a78..15bf907ddd5 100644 --- a/tests/baselines/reference/importUsedInExtendsList1.js +++ b/tests/baselines/reference/importUsedInExtendsList1.js @@ -13,6 +13,7 @@ var r: string = s.foo; //// [importUsedInExtendsList1_require.js] "use strict"; +exports.__esModule = true; var Super = (function () { function Super() { } @@ -21,17 +22,23 @@ var Super = (function () { exports.Super = Super; //// [importUsedInExtendsList1_1.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; /// var foo = require("./importUsedInExtendsList1_require"); var Sub = (function (_super) { __extends(Sub, _super); function Sub() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Sub; }(foo.Super)); diff --git a/tests/baselines/reference/importWithTrailingSlash.js b/tests/baselines/reference/importWithTrailingSlash.js index 7118dd95bb8..9450fc5d7b2 100644 --- a/tests/baselines/reference/importWithTrailingSlash.js +++ b/tests/baselines/reference/importWithTrailingSlash.js @@ -30,12 +30,14 @@ exports.__esModule = true; exports["default"] = { aIndex: 0 }; //// [test.js] "use strict"; +exports.__esModule = true; var _1 = require("."); var _2 = require("./"); _1["default"].a; _2["default"].aIndex; //// [test.js] "use strict"; +exports.__esModule = true; var __1 = require(".."); var _1 = require("../"); __1["default"].a; diff --git a/tests/baselines/reference/importWithTrailingSlash_noResolve.js b/tests/baselines/reference/importWithTrailingSlash_noResolve.js index b523c76af3b..16a4838ba62 100644 --- a/tests/baselines/reference/importWithTrailingSlash_noResolve.js +++ b/tests/baselines/reference/importWithTrailingSlash_noResolve.js @@ -5,3 +5,4 @@ import foo from "./foo/"; //// [a.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/import_reference-exported-alias.js b/tests/baselines/reference/import_reference-exported-alias.js index ffc4491e50a..b3d607a6943 100644 --- a/tests/baselines/reference/import_reference-exported-alias.js +++ b/tests/baselines/reference/import_reference-exported-alias.js @@ -45,6 +45,7 @@ define(["require", "exports"], function (require, exports) { //// [file2.js] define(["require", "exports", "file1"], function (require, exports, appJs) { "use strict"; + exports.__esModule = true; var Services = appJs.Services; var UserServices = Services.UserServices; var x = new UserServices().getUserName(); diff --git a/tests/baselines/reference/import_reference-to-type-alias.js b/tests/baselines/reference/import_reference-to-type-alias.js index 1d91f10f672..c6771d47bae 100644 --- a/tests/baselines/reference/import_reference-to-type-alias.js +++ b/tests/baselines/reference/import_reference-to-type-alias.js @@ -20,6 +20,7 @@ var x = new Services.UserServices().getUserName(); //// [file1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var App; (function (App) { var Services; @@ -39,6 +40,7 @@ define(["require", "exports"], function (require, exports) { //// [file2.js] define(["require", "exports", "file1"], function (require, exports, appJs) { "use strict"; + exports.__esModule = true; var Services = appJs.App.Services; var x = new Services.UserServices().getUserName(); }); diff --git a/tests/baselines/reference/import_unneeded-require-when-referenecing-aliased-type-throug-array.js b/tests/baselines/reference/import_unneeded-require-when-referenecing-aliased-type-throug-array.js index 157702acd1e..1cd0376dded 100644 --- a/tests/baselines/reference/import_unneeded-require-when-referenecing-aliased-type-throug-array.js +++ b/tests/baselines/reference/import_unneeded-require-when-referenecing-aliased-type-throug-array.js @@ -19,6 +19,7 @@ var p = testData[0].name; //// [a.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var testData; var p = testData[0].name; }); diff --git a/tests/baselines/reference/import_var-referencing-an-imported-module-alias.js b/tests/baselines/reference/import_var-referencing-an-imported-module-alias.js index d67c53c6349..9b5e518804c 100644 --- a/tests/baselines/reference/import_var-referencing-an-imported-module-alias.js +++ b/tests/baselines/reference/import_var-referencing-an-imported-module-alias.js @@ -13,6 +13,7 @@ var v = new hostVar.Host(); //// [host.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var Host = (function () { function Host() { } @@ -23,6 +24,7 @@ define(["require", "exports"], function (require, exports) { //// [consumer.js] define(["require", "exports", "host"], function (require, exports, host) { "use strict"; + exports.__esModule = true; var hostVar = host; var v = new hostVar.Host(); }); diff --git a/tests/baselines/reference/importedAliasesInTypePositions.js b/tests/baselines/reference/importedAliasesInTypePositions.js index 754bac96c2c..b82ac22f4ed 100644 --- a/tests/baselines/reference/importedAliasesInTypePositions.js +++ b/tests/baselines/reference/importedAliasesInTypePositions.js @@ -21,6 +21,7 @@ export module ImportingModule { //// [file1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var elaborate; (function (elaborate) { var nested; @@ -45,6 +46,7 @@ define(["require", "exports"], function (require, exports) { //// [file2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var ImportingModule; (function (ImportingModule) { var UsesReferredType = (function () { diff --git a/tests/baselines/reference/importedModuleClassNameClash.js b/tests/baselines/reference/importedModuleClassNameClash.js index 8f9649c6768..5f4f9677dcd 100644 --- a/tests/baselines/reference/importedModuleClassNameClash.js +++ b/tests/baselines/reference/importedModuleClassNameClash.js @@ -9,6 +9,7 @@ class foo { } //// [importedModuleClassNameClash.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var foo = (function () { function foo() { } diff --git a/tests/baselines/reference/importsImplicitlyReadonly.js b/tests/baselines/reference/importsImplicitlyReadonly.js index 4630de598cc..dd45d4db89c 100644 --- a/tests/baselines/reference/importsImplicitlyReadonly.js +++ b/tests/baselines/reference/importsImplicitlyReadonly.js @@ -23,11 +23,13 @@ a3.y = 1; //// [a.js] "use strict"; +exports.__esModule = true; exports.x = 1; var y = 1; exports.y = y; //// [b.js] "use strict"; +exports.__esModule = true; var a_1 = require("./a"); var a1 = require("./a"); var a2 = require("./a"); diff --git a/tests/baselines/reference/inOperatorWithInvalidOperands.errors.txt b/tests/baselines/reference/inOperatorWithInvalidOperands.errors.txt index 5aeae5f160e..7615008d89c 100644 --- a/tests/baselines/reference/inOperatorWithInvalidOperands.errors.txt +++ b/tests/baselines/reference/inOperatorWithInvalidOperands.errors.txt @@ -1,6 +1,8 @@ tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(12,11): error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(13,11): error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(14,11): error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. +tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(16,11): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(17,11): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(19,11): error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(20,11): error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(30,16): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter @@ -11,13 +13,13 @@ tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInv tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(35,16): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(36,16): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(37,16): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter -tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(38,16): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter -tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(39,17): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter +tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(38,16): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(39,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(43,11): error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts(43,17): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter -==== tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts (17 errors) ==== +==== tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInvalidOperands.ts (19 errors) ==== enum E { a } var x: any; @@ -40,7 +42,11 @@ tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInv !!! error TS2360: The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'. var ra4 = a4 in x; var ra5 = null in x; + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ra6 = undefined in x; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ra7 = E.a in x; var ra8 = false in x; ~~~~~ @@ -83,10 +89,10 @@ tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithInv !!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter var rb9 = x in null; ~~~~ -!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter +!!! error TS2531: Object is possibly 'null'. var rb10 = x in undefined; ~~~~~~~~~ -!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter +!!! error TS2532: Object is possibly 'undefined'. // both operands are invalid diff --git a/tests/baselines/reference/incrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt b/tests/baselines/reference/incrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt index 0a303d12bf3..afdddab86a7 100644 --- a/tests/baselines/reference/incrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt +++ b/tests/baselines/reference/incrementOperatorWithAnyOtherTypeInvalidOperations.errors.txt @@ -9,29 +9,37 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(33,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(34,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(37,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(39,26): error TS2539: Cannot assign to 'undefined' because it is not a variable. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(42,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(43,24): error TS2539: Cannot assign to 'undefined' because it is not a variable. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(46,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(47,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,34): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,34): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,39): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(51,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(52,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(54,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(55,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,32): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,32): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access. -tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,37): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(59,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(60,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(63,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -45,7 +53,7 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(69,12): error TS1109: Expression expected. -==== tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts (45 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts (53 errors) ==== // ++ operator on any type var ANY1: any; var ANY2: any[] = [1, 2]; @@ -107,14 +115,18 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. var ResultIsNumber12 = ++null; ~~~~ -!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber13 = ++undefined; ~~~~~~~~~ !!! error TS2539: Cannot assign to 'undefined' because it is not a variable. var ResultIsNumber14 = null++; ~~~~ -!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber15 = {}++; ~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -132,18 +144,24 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp var ResultIsNumber19 = ++(null + undefined); ~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber20 = ++(null + null); ~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber21 = ++(undefined + undefined); ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber22 = ++obj1.x; ~~~~~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -160,18 +178,24 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp var ResultIsNumber26 = (null + undefined)++; ~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber27 = (null + null)++; ~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber28 = (undefined + undefined)++; ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access. - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber29 = obj1.x++; ~~~~~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. diff --git a/tests/baselines/reference/indexerConstraints2.js b/tests/baselines/reference/indexerConstraints2.js index d7357f021d0..4336fd2ff32 100644 --- a/tests/baselines/reference/indexerConstraints2.js +++ b/tests/baselines/reference/indexerConstraints2.js @@ -29,11 +29,16 @@ class K extends J { } //// [indexerConstraints2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -42,7 +47,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -55,7 +60,7 @@ var F = (function () { var G = (function (_super) { __extends(G, _super); function G() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return G; }(F)); @@ -68,7 +73,7 @@ var H = (function () { var I = (function (_super) { __extends(I, _super); function I() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return I; }(H)); @@ -81,7 +86,7 @@ var J = (function () { var K = (function (_super) { __extends(K, _super); function K() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return K; }(J)); diff --git a/tests/baselines/reference/indirectSelfReference.js b/tests/baselines/reference/indirectSelfReference.js index 2f4f37b9b53..6410e463dbb 100644 --- a/tests/baselines/reference/indirectSelfReference.js +++ b/tests/baselines/reference/indirectSelfReference.js @@ -3,22 +3,27 @@ class a extends b{ } class b extends a{ } //// [indirectSelfReference.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function (_super) { __extends(a, _super); function a() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return a; }(b)); var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/indirectSelfReferenceGeneric.js b/tests/baselines/reference/indirectSelfReferenceGeneric.js index 9171bb0eeb6..695970159d9 100644 --- a/tests/baselines/reference/indirectSelfReferenceGeneric.js +++ b/tests/baselines/reference/indirectSelfReferenceGeneric.js @@ -3,22 +3,27 @@ class a extends b { } class b extends a { } //// [indirectSelfReferenceGeneric.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function (_super) { __extends(a, _super); function a() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return a; }(b)); var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/inferSetterParamType.errors.txt b/tests/baselines/reference/inferSetterParamType.errors.txt index 02c02ba69d5..7b28c52d48b 100644 --- a/tests/baselines/reference/inferSetterParamType.errors.txt +++ b/tests/baselines/reference/inferSetterParamType.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/inferSetterParamType.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/inferSetterParamType.ts(6,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/inferSetterParamType.ts(12,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/inferSetterParamType.ts(13,16): error TS2322: Type '0' is not assignable to type 'string'. +tests/cases/compiler/inferSetterParamType.ts(13,9): error TS2322: Type '0' is not assignable to type 'string'. tests/cases/compiler/inferSetterParamType.ts(15,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -25,7 +25,7 @@ tests/cases/compiler/inferSetterParamType.ts(15,9): error TS1056: Accessors are ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. return 0; // should be an error - can't coerce infered return type to match setter annotated type - ~ + ~~~~~~~~~ !!! error TS2322: Type '0' is not assignable to type 'string'. } set bar(n:string) { diff --git a/tests/baselines/reference/inferenceLimit.js b/tests/baselines/reference/inferenceLimit.js index 84f0989e987..997cbcd5b79 100644 --- a/tests/baselines/reference/inferenceLimit.js +++ b/tests/baselines/reference/inferenceLimit.js @@ -42,6 +42,7 @@ export interface MyModel { //// [mymodule.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); //// [file1.js] "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { @@ -52,6 +53,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; +Object.defineProperty(exports, "__esModule", { value: true }); class BrokenClass { constructor() { } brokenMethod(field, value) { diff --git a/tests/baselines/reference/inferenceLimit.symbols b/tests/baselines/reference/inferenceLimit.symbols index 721e7af7560..488838548ad 100644 --- a/tests/baselines/reference/inferenceLimit.symbols +++ b/tests/baselines/reference/inferenceLimit.symbols @@ -14,7 +14,7 @@ export class BrokenClass { >value : Symbol(value, Decl(file1.ts, 7, 36)) return new Promise>((resolve, reject) => { ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >MyModule : Symbol(MyModule, Decl(file1.ts, 1, 6)) >MyModel : Symbol(MyModule.MyModel, Decl(mymodule.ts, 0, 0)) @@ -32,19 +32,19 @@ export class BrokenClass { >order : Symbol(order, Decl(file1.ts, 12, 25)) return new Promise((resolve, reject) => { ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(resolve, Decl(file1.ts, 13, 26)) >reject : Symbol(reject, Decl(file1.ts, 13, 34)) this.doStuff(order.id) ->this.doStuff(order.id) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>this.doStuff(order.id) .then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >this.doStuff : Symbol(BrokenClass.doStuff, Decl(file1.ts, 27, 3)) >this : Symbol(BrokenClass, Decl(file1.ts, 1, 39)) >doStuff : Symbol(BrokenClass.doStuff, Decl(file1.ts, 27, 3)) >order : Symbol(order, Decl(file1.ts, 12, 25)) .then((items) => { ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >items : Symbol(items, Decl(file1.ts, 15, 17)) order.items = items; @@ -60,9 +60,9 @@ export class BrokenClass { }; return Promise.all(result.map(populateItems)) ->Promise.all(result.map(populateItems)) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.all(result.map(populateItems)) .then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >all : Symbol(PromiseConstructor.all, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >result.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >result : Symbol(result, Decl(file1.ts, 10, 7)) @@ -70,7 +70,7 @@ export class BrokenClass { >populateItems : Symbol(populateItems, Decl(file1.ts, 12, 7)) .then((orders: Array) => { ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >orders : Symbol(orders, Decl(file1.ts, 23, 13)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >MyModule : Symbol(MyModule, Decl(file1.ts, 1, 6)) diff --git a/tests/baselines/reference/inferenceLimit.types b/tests/baselines/reference/inferenceLimit.types index c123e21802e..bf917e18e93 100644 --- a/tests/baselines/reference/inferenceLimit.types +++ b/tests/baselines/reference/inferenceLimit.types @@ -46,7 +46,7 @@ export class BrokenClass { this.doStuff(order.id) >this.doStuff(order.id) .then((items) => { order.items = items; resolve(order); }) : Promise ->this.doStuff(order.id) .then : { (onfulfilled?: (value: void) => void | PromiseLike, onrejected?: (reason: any) => void | PromiseLike): Promise; (onfulfilled: (value: void) => void | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: void) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: void) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>this.doStuff(order.id) .then : (onfulfilled?: (value: void) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >this.doStuff(order.id) : Promise >this.doStuff : (id: number) => Promise >this : this @@ -56,7 +56,7 @@ export class BrokenClass { >id : any .then((items) => { ->then : { (onfulfilled?: (value: void) => void | PromiseLike, onrejected?: (reason: any) => void | PromiseLike): Promise; (onfulfilled: (value: void) => void | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: void) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: void) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: void) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >(items) => { order.items = items; resolve(order); } : (items: void) => void >items : void @@ -78,7 +78,7 @@ export class BrokenClass { return Promise.all(result.map(populateItems)) >Promise.all(result.map(populateItems)) .then((orders: Array) => { resolve(orders); }) : Promise ->Promise.all(result.map(populateItems)) .then : { (onfulfilled?: (value: {}[]) => {}[] | PromiseLike<{}[]>, onrejected?: (reason: any) => {}[] | PromiseLike<{}[]>): Promise<{}[]>; (onfulfilled: (value: {}[]) => {}[] | PromiseLike<{}[]>, onrejected: (reason: any) => TResult | PromiseLike): Promise<{}[] | TResult>; (onfulfilled: (value: {}[]) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: {}[]) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>Promise.all(result.map(populateItems)) .then : (onfulfilled?: (value: {}[]) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >Promise.all(result.map(populateItems)) : Promise<{}[]> >Promise.all : { (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; (values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; (values: (T | PromiseLike)[]): Promise; (values: Iterable>): Promise; } >Promise : PromiseConstructor @@ -90,7 +90,7 @@ export class BrokenClass { >populateItems : (order: any) => Promise<{}> .then((orders: Array) => { ->then : { (onfulfilled?: (value: {}[]) => {}[] | PromiseLike<{}[]>, onrejected?: (reason: any) => {}[] | PromiseLike<{}[]>): Promise<{}[]>; (onfulfilled: (value: {}[]) => {}[] | PromiseLike<{}[]>, onrejected: (reason: any) => TResult | PromiseLike): Promise<{}[] | TResult>; (onfulfilled: (value: {}[]) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: {}[]) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: {}[]) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >(orders: Array) => { resolve(orders); } : (orders: MyModule.MyModel[]) => void >orders : MyModule.MyModel[] >Array : T[] diff --git a/tests/baselines/reference/infinitelyExpandingTypesNonGenericBase.js b/tests/baselines/reference/infinitelyExpandingTypesNonGenericBase.js index ad1a063bfb0..fd9bbac1623 100644 --- a/tests/baselines/reference/infinitelyExpandingTypesNonGenericBase.js +++ b/tests/baselines/reference/infinitelyExpandingTypesNonGenericBase.js @@ -25,11 +25,16 @@ o(A); //// [infinitelyExpandingTypesNonGenericBase.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Functionality = (function () { function Functionality() { } @@ -43,7 +48,7 @@ var Base = (function () { var A = (function (_super) { __extends(A, _super); function A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A; }(Base)); diff --git a/tests/baselines/reference/inheritFromGenericTypeParameter.js b/tests/baselines/reference/inheritFromGenericTypeParameter.js index 40e6abd3e53..f8145ec2c01 100644 --- a/tests/baselines/reference/inheritFromGenericTypeParameter.js +++ b/tests/baselines/reference/inheritFromGenericTypeParameter.js @@ -3,15 +3,20 @@ class C extends T { } interface I extends T { } //// [inheritFromGenericTypeParameter.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(T)); diff --git a/tests/baselines/reference/inheritSameNamePrivatePropertiesFromSameOrigin.js b/tests/baselines/reference/inheritSameNamePrivatePropertiesFromSameOrigin.js index a0874eb1c72..138e3aa5694 100644 --- a/tests/baselines/reference/inheritSameNamePrivatePropertiesFromSameOrigin.js +++ b/tests/baselines/reference/inheritSameNamePrivatePropertiesFromSameOrigin.js @@ -11,11 +11,16 @@ interface A extends C, C2 { // ok } //// [inheritSameNamePrivatePropertiesFromSameOrigin.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B() { } @@ -24,14 +29,14 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(B)); diff --git a/tests/baselines/reference/inheritance.js b/tests/baselines/reference/inheritance.js index cbfef2d3382..48d96b10f9c 100644 --- a/tests/baselines/reference/inheritance.js +++ b/tests/baselines/reference/inheritance.js @@ -35,11 +35,16 @@ class Baad extends Good { //// [inheritance.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B1 = (function () { function B1() { } @@ -53,14 +58,14 @@ var B2 = (function () { var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(B1)); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(B2)); @@ -72,7 +77,7 @@ var N = (function () { var ND = (function (_super) { __extends(ND, _super); function ND() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ND; }(N)); @@ -86,7 +91,7 @@ var Good = (function () { var Baad = (function (_super) { __extends(Baad, _super); function Baad() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Baad.prototype.f = function () { return 0; }; Baad.prototype.g = function (n) { return 0; }; diff --git a/tests/baselines/reference/inheritance1.js b/tests/baselines/reference/inheritance1.js index 86de0b76350..a00330e8556 100644 --- a/tests/baselines/reference/inheritance1.js +++ b/tests/baselines/reference/inheritance1.js @@ -62,11 +62,16 @@ l1 = sc; l1 = c; //// [inheritance1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Control = (function () { function Control() { } @@ -75,7 +80,7 @@ var Control = (function () { var Button = (function (_super) { __extends(Button, _super); function Button() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Button.prototype.select = function () { }; return Button; @@ -83,7 +88,7 @@ var Button = (function (_super) { var TextBox = (function (_super) { __extends(TextBox, _super); function TextBox() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } TextBox.prototype.select = function () { }; return TextBox; @@ -91,14 +96,14 @@ var TextBox = (function (_super) { var ImageBase = (function (_super) { __extends(ImageBase, _super); function ImageBase() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ImageBase; }(Control)); var Image1 = (function (_super) { __extends(Image1, _super); function Image1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Image1; }(Control)); diff --git a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.js b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.js index 57a9c897583..52ab48573fd 100644 --- a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.js +++ b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.js @@ -11,11 +11,16 @@ class C extends B { //// [inheritanceGrandParentPrivateMemberCollision.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -25,14 +30,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.myMethod = function () { }; return C; diff --git a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.js b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.js index 83c5aa3e4cd..c64a0e4259c 100644 --- a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.js +++ b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.js @@ -11,11 +11,16 @@ class C extends B { //// [inheritanceGrandParentPrivateMemberCollisionWithPublicMember.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -25,14 +30,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.myMethod = function () { }; return C; diff --git a/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.js b/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.js index b11b6e318a7..9ac0fe18592 100644 --- a/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.js +++ b/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.js @@ -11,11 +11,16 @@ class C extends B { //// [inheritanceGrandParentPublicMemberCollisionWithPrivateMember.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -25,14 +30,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.myMethod = function () { }; return C; diff --git a/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js b/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js index 09ea08899d9..fae79488dce 100644 --- a/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js @@ -18,11 +18,16 @@ class b extends a { } //// [inheritanceMemberAccessorOverridingAccessor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -40,7 +45,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(b.prototype, "x", { get: function () { diff --git a/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js b/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js index 59d2abdaab2..3fc6417afaf 100644 --- a/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js +++ b/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js @@ -15,11 +15,16 @@ class b extends a { } //// [inheritanceMemberAccessorOverridingMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -31,7 +36,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(b.prototype, "x", { get: function () { diff --git a/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js b/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js index 98a95747a8e..1d0a8f09a40 100644 --- a/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js +++ b/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js @@ -13,11 +13,16 @@ class b extends a { } //// [inheritanceMemberAccessorOverridingProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -26,7 +31,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(b.prototype, "x", { get: function () { diff --git a/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js b/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js index 0d54e5d42fa..93b72b73c8b 100644 --- a/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js @@ -15,11 +15,16 @@ class b extends a { } //// [inheritanceMemberFuncOverridingAccessor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -37,7 +42,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.prototype.x = function () { return "20"; diff --git a/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.js b/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.js index 9af25c6fdb8..0f189aa50cc 100644 --- a/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.js +++ b/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.js @@ -12,11 +12,16 @@ class b extends a { } //// [inheritanceMemberFuncOverridingMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -28,7 +33,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.prototype.x = function () { return "20"; diff --git a/tests/baselines/reference/inheritanceMemberFuncOverridingProperty.js b/tests/baselines/reference/inheritanceMemberFuncOverridingProperty.js index 5c77ce08101..996138a53d9 100644 --- a/tests/baselines/reference/inheritanceMemberFuncOverridingProperty.js +++ b/tests/baselines/reference/inheritanceMemberFuncOverridingProperty.js @@ -10,11 +10,16 @@ class b extends a { } //// [inheritanceMemberFuncOverridingProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -23,7 +28,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.prototype.x = function () { return "20"; diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js b/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js index 82c7a94d17c..97b856980ea 100644 --- a/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js @@ -14,11 +14,16 @@ class b extends a { } //// [inheritanceMemberPropertyOverridingAccessor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -37,7 +42,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.js b/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.js index e6929218e63..c7c6c84f9d0 100644 --- a/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.js +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingMethod.js @@ -10,11 +10,16 @@ class b extends a { } //// [inheritanceMemberPropertyOverridingMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -26,7 +31,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.js b/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.js index 85764cddc52..c8e9c5ef9d4 100644 --- a/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.js +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingProperty.js @@ -8,11 +8,16 @@ class b extends a { } //// [inheritanceMemberPropertyOverridingProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -21,7 +26,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/inheritanceOfGenericConstructorMethod1.js b/tests/baselines/reference/inheritanceOfGenericConstructorMethod1.js index 28fe8144509..62355930d92 100644 --- a/tests/baselines/reference/inheritanceOfGenericConstructorMethod1.js +++ b/tests/baselines/reference/inheritanceOfGenericConstructorMethod1.js @@ -8,11 +8,16 @@ var b3 = new B(); // error, could not select overload for 'new' expression //// [inheritanceOfGenericConstructorMethod1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -21,7 +26,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.js b/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.js index 0cc71e168f4..12c5eac07e9 100644 --- a/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.js +++ b/tests/baselines/reference/inheritanceOfGenericConstructorMethod2.js @@ -15,11 +15,16 @@ var n3 = new N.D2(); // no error, D2 //// [inheritanceOfGenericConstructorMethod2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M; (function (M) { var C1 = (function () { @@ -40,7 +45,7 @@ var N; var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(M.C1)); @@ -48,7 +53,7 @@ var N; var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(M.C2)); diff --git a/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js b/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js index bb91ee5f9ea..4af25e03d13 100644 --- a/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js @@ -18,11 +18,16 @@ class b extends a { } //// [inheritanceStaticAccessorOverridingAccessor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -40,7 +45,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(b, "x", { get: function () { diff --git a/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js b/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js index 363852a84bf..904868fecd9 100644 --- a/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js +++ b/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js @@ -15,11 +15,16 @@ class b extends a { } //// [inheritanceStaticAccessorOverridingMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -31,7 +36,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(b, "x", { get: function () { diff --git a/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js b/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js index ba8df7a5f0b..cf6e23685f1 100644 --- a/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js +++ b/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js @@ -13,11 +13,16 @@ class b extends a { } //// [inheritanceStaticAccessorOverridingProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -26,7 +31,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(b, "x", { get: function () { diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js index e464029fba5..91946af7478 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js @@ -15,11 +15,16 @@ class b extends a { } //// [inheritanceStaticFuncOverridingAccessor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -37,7 +42,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.x = function () { return "20"; diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js index cc825cfa9b5..9b7e0dd925c 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js @@ -12,11 +12,16 @@ class b extends a { } //// [inheritanceStaticFuncOverridingAccessorOfFuncType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -32,7 +37,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.x = function () { return "20"; diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.js b/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.js index 466c65fa7d5..7e50c2c0318 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.js @@ -12,11 +12,16 @@ class b extends a { } //// [inheritanceStaticFuncOverridingMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -28,7 +33,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.x = function () { return "20"; diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingProperty.js b/tests/baselines/reference/inheritanceStaticFuncOverridingProperty.js index dfc0ce2c13f..fab0f4fb579 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingProperty.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingProperty.js @@ -10,11 +10,16 @@ class b extends a { } //// [inheritanceStaticFuncOverridingProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -23,7 +28,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.x = function () { return "20"; diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.js b/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.js index da7850f2071..b973095e5b8 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.js +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.js @@ -10,11 +10,16 @@ class b extends a { } //// [inheritanceStaticFuncOverridingPropertyOfFuncType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -23,7 +28,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.x = function () { return "20"; diff --git a/tests/baselines/reference/inheritanceStaticFunctionOverridingInstanceProperty.js b/tests/baselines/reference/inheritanceStaticFunctionOverridingInstanceProperty.js index d5916a9d452..017adeea3c7 100644 --- a/tests/baselines/reference/inheritanceStaticFunctionOverridingInstanceProperty.js +++ b/tests/baselines/reference/inheritanceStaticFunctionOverridingInstanceProperty.js @@ -10,11 +10,16 @@ class b extends a { } //// [inheritanceStaticFunctionOverridingInstanceProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -23,7 +28,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } b.x = function () { return new b().x; diff --git a/tests/baselines/reference/inheritanceStaticMembersCompatible.js b/tests/baselines/reference/inheritanceStaticMembersCompatible.js index b4cae99b64b..96416e977fa 100644 --- a/tests/baselines/reference/inheritanceStaticMembersCompatible.js +++ b/tests/baselines/reference/inheritanceStaticMembersCompatible.js @@ -8,11 +8,16 @@ class b extends a { } //// [inheritanceStaticMembersCompatible.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -21,7 +26,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/inheritanceStaticMembersIncompatible.js b/tests/baselines/reference/inheritanceStaticMembersIncompatible.js index 38c637dd8d1..15f3298f2cc 100644 --- a/tests/baselines/reference/inheritanceStaticMembersIncompatible.js +++ b/tests/baselines/reference/inheritanceStaticMembersIncompatible.js @@ -8,11 +8,16 @@ class b extends a { } //// [inheritanceStaticMembersIncompatible.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -21,7 +26,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js b/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js index 49dc86fc500..79d2e88b646 100644 --- a/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js +++ b/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js @@ -13,11 +13,16 @@ class b extends a { } //// [inheritanceStaticPropertyOverridingAccessor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -36,7 +41,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/inheritanceStaticPropertyOverridingMethod.js b/tests/baselines/reference/inheritanceStaticPropertyOverridingMethod.js index bcd63537540..1ec8e5f5f65 100644 --- a/tests/baselines/reference/inheritanceStaticPropertyOverridingMethod.js +++ b/tests/baselines/reference/inheritanceStaticPropertyOverridingMethod.js @@ -10,11 +10,16 @@ class b extends a { } //// [inheritanceStaticPropertyOverridingMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -26,7 +31,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/inheritanceStaticPropertyOverridingProperty.js b/tests/baselines/reference/inheritanceStaticPropertyOverridingProperty.js index c1bdd9b66a2..6c83789d51d 100644 --- a/tests/baselines/reference/inheritanceStaticPropertyOverridingProperty.js +++ b/tests/baselines/reference/inheritanceStaticPropertyOverridingProperty.js @@ -8,11 +8,16 @@ class b extends a { } //// [inheritanceStaticPropertyOverridingProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = (function () { function a() { } @@ -21,7 +26,7 @@ var a = (function () { var b = (function (_super) { __extends(b, _super); function b() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return b; }(a)); diff --git a/tests/baselines/reference/inheritedConstructorWithRestParams.js b/tests/baselines/reference/inheritedConstructorWithRestParams.js index 6a30836d728..5e7e3736885 100644 --- a/tests/baselines/reference/inheritedConstructorWithRestParams.js +++ b/tests/baselines/reference/inheritedConstructorWithRestParams.js @@ -15,11 +15,16 @@ new Derived("", 3); new Derived(3); //// [inheritedConstructorWithRestParams.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { var a = []; @@ -32,7 +37,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/inheritedConstructorWithRestParams2.js b/tests/baselines/reference/inheritedConstructorWithRestParams2.js index 9a1b13a8434..c27b723b562 100644 --- a/tests/baselines/reference/inheritedConstructorWithRestParams2.js +++ b/tests/baselines/reference/inheritedConstructorWithRestParams2.js @@ -35,11 +35,16 @@ new Derived("", 3, "", 3); new Derived("", 3, "", ""); //// [inheritedConstructorWithRestParams2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var IBaseBase = (function () { function IBaseBase(x) { } @@ -53,14 +58,14 @@ var BaseBase2 = (function () { var Base = (function (_super) { __extends(Base, _super); function Base() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Base; }(BaseBase)); var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/inheritedModuleMembersForClodule.js b/tests/baselines/reference/inheritedModuleMembersForClodule.js index cd49009fed9..be7aec77731 100644 --- a/tests/baselines/reference/inheritedModuleMembersForClodule.js +++ b/tests/baselines/reference/inheritedModuleMembersForClodule.js @@ -22,11 +22,16 @@ class E extends D { //// [inheritedModuleMembersForClodule.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -38,7 +43,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); @@ -52,7 +57,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } E.bar = function () { return this.foo(); diff --git a/tests/baselines/reference/instanceOfAssignability.js b/tests/baselines/reference/instanceOfAssignability.js index b8f39c5b0e2..db5554596af 100644 --- a/tests/baselines/reference/instanceOfAssignability.js +++ b/tests/baselines/reference/instanceOfAssignability.js @@ -90,11 +90,16 @@ function fn8(x: Alpha|Beta|Gamma) { //// [instanceOfAssignability.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // Derived1 is assignable to, but not a subtype of, Base var Derived1 = (function () { function Derived1() { @@ -115,14 +120,14 @@ var Animal = (function () { var Mammal = (function (_super) { __extends(Mammal, _super); function Mammal() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Mammal; }(Animal)); var Giraffe = (function (_super) { __extends(Giraffe, _super); function Giraffe() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Giraffe; }(Mammal)); diff --git a/tests/baselines/reference/instanceOfInExternalModules.js b/tests/baselines/reference/instanceOfInExternalModules.js index 540549aef52..293be662a4d 100644 --- a/tests/baselines/reference/instanceOfInExternalModules.js +++ b/tests/baselines/reference/instanceOfInExternalModules.js @@ -14,6 +14,7 @@ function IsFoo(value: any): boolean { //// [instanceOfInExternalModules_require.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var Foo = (function () { function Foo() { } @@ -24,6 +25,7 @@ define(["require", "exports"], function (require, exports) { //// [instanceOfInExternalModules_1.js] define(["require", "exports", "instanceOfInExternalModules_require"], function (require, exports, Bar) { "use strict"; + exports.__esModule = true; function IsFoo(value) { return value instanceof Bar.Foo; } diff --git a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js index 8dc5227685f..44c781c8c98 100644 --- a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js +++ b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js @@ -43,11 +43,16 @@ module Generic { } //// [instancePropertiesInheritedIntoClassType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var NonGeneric; (function (NonGeneric) { var C = (function () { @@ -69,7 +74,7 @@ var NonGeneric; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); @@ -101,7 +106,7 @@ var Generic; var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/instanceSubtypeCheck2.js b/tests/baselines/reference/instanceSubtypeCheck2.js index 914f3796001..0a02162d707 100644 --- a/tests/baselines/reference/instanceSubtypeCheck2.js +++ b/tests/baselines/reference/instanceSubtypeCheck2.js @@ -8,11 +8,16 @@ class C2 extends C1 { } //// [instanceSubtypeCheck2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1() { } @@ -21,7 +26,7 @@ var C1 = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(C1)); diff --git a/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.js b/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.js new file mode 100644 index 00000000000..bf5a6f7bce1 --- /dev/null +++ b/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.js @@ -0,0 +1,34 @@ +//// [instanceofOperatorWithInvalidStaticToString.ts] +declare class StaticToString { + static toString(): void; +} + +function foo(staticToString: StaticToString) { + return staticToString instanceof StaticToString; +} + +declare class StaticToNumber { + static toNumber(): void; +} +function bar(staticToNumber: StaticToNumber) { + return staticToNumber instanceof StaticToNumber; +} + +declare class NormalToString { + toString(): void; +} +function baz(normal: NormalToString) { + return normal instanceof NormalToString; +} + + +//// [instanceofOperatorWithInvalidStaticToString.js] +function foo(staticToString) { + return staticToString instanceof StaticToString; +} +function bar(staticToNumber) { + return staticToNumber instanceof StaticToNumber; +} +function baz(normal) { + return normal instanceof NormalToString; +} diff --git a/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.symbols b/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.symbols new file mode 100644 index 00000000000..4f4dbda611a --- /dev/null +++ b/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.symbols @@ -0,0 +1,50 @@ +=== tests/cases/conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidStaticToString.ts === +declare class StaticToString { +>StaticToString : Symbol(StaticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 0, 0)) + + static toString(): void; +>toString : Symbol(StaticToString.toString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 0, 30)) +} + +function foo(staticToString: StaticToString) { +>foo : Symbol(foo, Decl(instanceofOperatorWithInvalidStaticToString.ts, 2, 1)) +>staticToString : Symbol(staticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 4, 13)) +>StaticToString : Symbol(StaticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 0, 0)) + + return staticToString instanceof StaticToString; +>staticToString : Symbol(staticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 4, 13)) +>StaticToString : Symbol(StaticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 0, 0)) +} + +declare class StaticToNumber { +>StaticToNumber : Symbol(StaticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 6, 1)) + + static toNumber(): void; +>toNumber : Symbol(StaticToNumber.toNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 8, 30)) +} +function bar(staticToNumber: StaticToNumber) { +>bar : Symbol(bar, Decl(instanceofOperatorWithInvalidStaticToString.ts, 10, 1)) +>staticToNumber : Symbol(staticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 11, 13)) +>StaticToNumber : Symbol(StaticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 6, 1)) + + return staticToNumber instanceof StaticToNumber; +>staticToNumber : Symbol(staticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 11, 13)) +>StaticToNumber : Symbol(StaticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 6, 1)) +} + +declare class NormalToString { +>NormalToString : Symbol(NormalToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 13, 1)) + + toString(): void; +>toString : Symbol(NormalToString.toString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 15, 30)) +} +function baz(normal: NormalToString) { +>baz : Symbol(baz, Decl(instanceofOperatorWithInvalidStaticToString.ts, 17, 1)) +>normal : Symbol(normal, Decl(instanceofOperatorWithInvalidStaticToString.ts, 18, 13)) +>NormalToString : Symbol(NormalToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 13, 1)) + + return normal instanceof NormalToString; +>normal : Symbol(normal, Decl(instanceofOperatorWithInvalidStaticToString.ts, 18, 13)) +>NormalToString : Symbol(NormalToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 13, 1)) +} + diff --git a/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.types b/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.types new file mode 100644 index 00000000000..11efa0cffc3 --- /dev/null +++ b/tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.types @@ -0,0 +1,53 @@ +=== tests/cases/conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidStaticToString.ts === +declare class StaticToString { +>StaticToString : StaticToString + + static toString(): void; +>toString : () => void +} + +function foo(staticToString: StaticToString) { +>foo : (staticToString: StaticToString) => boolean +>staticToString : StaticToString +>StaticToString : StaticToString + + return staticToString instanceof StaticToString; +>staticToString instanceof StaticToString : boolean +>staticToString : StaticToString +>StaticToString : typeof StaticToString +} + +declare class StaticToNumber { +>StaticToNumber : StaticToNumber + + static toNumber(): void; +>toNumber : () => void +} +function bar(staticToNumber: StaticToNumber) { +>bar : (staticToNumber: StaticToNumber) => boolean +>staticToNumber : StaticToNumber +>StaticToNumber : StaticToNumber + + return staticToNumber instanceof StaticToNumber; +>staticToNumber instanceof StaticToNumber : boolean +>staticToNumber : StaticToNumber +>StaticToNumber : typeof StaticToNumber +} + +declare class NormalToString { +>NormalToString : NormalToString + + toString(): void; +>toString : () => void +} +function baz(normal: NormalToString) { +>baz : (normal: NormalToString) => boolean +>normal : NormalToString +>NormalToString : NormalToString + + return normal instanceof NormalToString; +>normal instanceof NormalToString : boolean +>normal : NormalToString +>NormalToString : typeof NormalToString +} + diff --git a/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.js b/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.js index 54a574238e5..b7d2ec46914 100644 --- a/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.js +++ b/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.js @@ -72,11 +72,16 @@ function goo(x: A) { //// [instanceofWithStructurallyIdenticalTypes.js] // Repro from #7271 -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1() { } @@ -128,7 +133,7 @@ var A = (function () { var A1 = (function (_super) { __extends(A1, _super); function A1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A1; }(A)); @@ -140,7 +145,7 @@ var A2 = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/instantiatedReturnTypeContravariance.js b/tests/baselines/reference/instantiatedReturnTypeContravariance.js index bc496a63632..52f96561f20 100644 --- a/tests/baselines/reference/instantiatedReturnTypeContravariance.js +++ b/tests/baselines/reference/instantiatedReturnTypeContravariance.js @@ -31,11 +31,16 @@ return null; //// [instantiatedReturnTypeContravariance.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var c = (function () { function c() { } @@ -47,7 +52,7 @@ var c = (function () { var d = (function (_super) { __extends(d, _super); function d() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } d.prototype.foo = function () { return null; diff --git a/tests/baselines/reference/interfaceClassMerging.js b/tests/baselines/reference/interfaceClassMerging.js index 6542376a19b..e2167776f22 100644 --- a/tests/baselines/reference/interfaceClassMerging.js +++ b/tests/baselines/reference/interfaceClassMerging.js @@ -41,11 +41,16 @@ obj = bar; //// [interfaceClassMerging.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -57,7 +62,7 @@ var Foo = (function () { var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Bar.prototype.method = function (a) { return this.optionalProperty; diff --git a/tests/baselines/reference/interfaceClassMerging2.js b/tests/baselines/reference/interfaceClassMerging2.js index 70a62da4131..4c879ba4cab 100644 --- a/tests/baselines/reference/interfaceClassMerging2.js +++ b/tests/baselines/reference/interfaceClassMerging2.js @@ -37,11 +37,16 @@ foo = bar; //// [interfaceClassMerging2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -53,7 +58,7 @@ var Foo = (function () { var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Bar.prototype.classBarMethod = function () { return this; diff --git a/tests/baselines/reference/interfaceContextualType.js b/tests/baselines/reference/interfaceContextualType.js index 653579c81eb..ec502725925 100644 --- a/tests/baselines/reference/interfaceContextualType.js +++ b/tests/baselines/reference/interfaceContextualType.js @@ -23,6 +23,7 @@ class Bug { //// [interfaceContextualType.js] "use strict"; +exports.__esModule = true; var Bug = (function () { function Bug() { } diff --git a/tests/baselines/reference/interfaceDeclaration3.js b/tests/baselines/reference/interfaceDeclaration3.js index a4df8926fba..41f12dbac05 100644 --- a/tests/baselines/reference/interfaceDeclaration3.js +++ b/tests/baselines/reference/interfaceDeclaration3.js @@ -58,6 +58,7 @@ interface I2 extends I1 { item:string; } //// [interfaceDeclaration3.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var M1; (function (M1) { var C1 = (function () { diff --git a/tests/baselines/reference/interfaceDeclaration5.js b/tests/baselines/reference/interfaceDeclaration5.js index 6726971d208..318e8903c36 100644 --- a/tests/baselines/reference/interfaceDeclaration5.js +++ b/tests/baselines/reference/interfaceDeclaration5.js @@ -6,6 +6,7 @@ export class C1 { } //// [interfaceDeclaration5.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var C1 = (function () { function C1() { } diff --git a/tests/baselines/reference/interfaceDoesNotDependOnBaseTypes.types b/tests/baselines/reference/interfaceDoesNotDependOnBaseTypes.types index 4f60c5d36cc..eae55bc09d1 100644 --- a/tests/baselines/reference/interfaceDoesNotDependOnBaseTypes.types +++ b/tests/baselines/reference/interfaceDoesNotDependOnBaseTypes.types @@ -5,7 +5,7 @@ var x: StringTree; if (typeof x !== "string") { >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : StringTree >"string" : "string" diff --git a/tests/baselines/reference/interfaceExtendsClass1.js b/tests/baselines/reference/interfaceExtendsClass1.js index 8324a001f91..69560e82557 100644 --- a/tests/baselines/reference/interfaceExtendsClass1.js +++ b/tests/baselines/reference/interfaceExtendsClass1.js @@ -19,11 +19,16 @@ class Location { //// [interfaceExtendsClass1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Control = (function () { function Control() { } @@ -32,7 +37,7 @@ var Control = (function () { var Button = (function (_super) { __extends(Button, _super); function Button() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Button.prototype.select = function () { }; return Button; @@ -40,7 +45,7 @@ var Button = (function (_super) { var TextBox = (function (_super) { __extends(TextBox, _super); function TextBox() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } TextBox.prototype.select = function () { }; return TextBox; @@ -48,7 +53,7 @@ var TextBox = (function (_super) { var Image = (function (_super) { __extends(Image, _super); function Image() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Image; }(Control)); diff --git a/tests/baselines/reference/interfaceExtendsClassWithPrivate1.js b/tests/baselines/reference/interfaceExtendsClassWithPrivate1.js index 1179ff101df..12d1539bb3d 100644 --- a/tests/baselines/reference/interfaceExtendsClassWithPrivate1.js +++ b/tests/baselines/reference/interfaceExtendsClassWithPrivate1.js @@ -28,11 +28,16 @@ c = d; d = c; // error //// [interfaceExtendsClassWithPrivate1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { this.x = 1; @@ -43,7 +48,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.foo = function (x) { return x; }; D.prototype.other = function (x) { return x; }; diff --git a/tests/baselines/reference/interfaceExtendsClassWithPrivate2.js b/tests/baselines/reference/interfaceExtendsClassWithPrivate2.js index 49b5efbd012..cec3eed8497 100644 --- a/tests/baselines/reference/interfaceExtendsClassWithPrivate2.js +++ b/tests/baselines/reference/interfaceExtendsClassWithPrivate2.js @@ -24,11 +24,16 @@ class D2 extends C implements I { // error } //// [interfaceExtendsClassWithPrivate2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { this.x = 1; @@ -39,7 +44,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = 2; _this.y = 3; return _this; @@ -52,7 +57,7 @@ var D = (function (_super) { var D2 = (function (_super) { __extends(D2, _super); function D2() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = ""; return _this; } diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersection.js b/tests/baselines/reference/interfaceExtendsObjectIntersection.js new file mode 100644 index 00000000000..a6fb62f5070 --- /dev/null +++ b/tests/baselines/reference/interfaceExtendsObjectIntersection.js @@ -0,0 +1,145 @@ +//// [interfaceExtendsObjectIntersection.ts] + +type T1 = { a: number }; +type T2 = T1 & { b: number }; +type T3 = () => void; +type T4 = new () => { a: number }; +type T5 = number[]; +type T6 = [string, number]; +type T7 = { [P in 'a' | 'b' | 'c']: string }; + +interface I1 extends T1 { x: string } +interface I2 extends T2 { x: string } +interface I3 extends T3 { x: string } +interface I4 extends T4 { x: string } +interface I5 extends T5 { x: string } +interface I6 extends T6 { x: string } +interface I7 extends T7 { x: string } + +type Constructor = new () => T; +declare function Constructor(): Constructor; + +class C1 extends Constructor() { x: string } +class C2 extends Constructor() { x: string } +class C3 extends Constructor() { x: string } +class C4 extends Constructor() { x: string } +class C5 extends Constructor() { x: string } +class C6 extends Constructor() { x: string } +class C7 extends Constructor() { x: string } + +declare function fx(x: string): string; +declare class CX { a: number } +declare enum EX { A, B, C } +declare namespace NX { export const a = 1 } + +type T10 = typeof fx; +type T11 = typeof CX; +type T12 = typeof EX; +type T13 = typeof NX; + +interface I10 extends T10 { x: string } +interface I11 extends T11 { x: string } +interface I12 extends T12 { x: string } +interface I13 extends T13 { x: string } + +type Identifiable = { _id: string } & T; + +interface I20 extends Partial { x: string } +interface I21 extends Readonly { x: string } +interface I22 extends Identifiable { x: string } +interface I23 extends Identifiable { x: string } + +class C20 extends Constructor>() { x: string } +class C21 extends Constructor>() { x: string } +class C22 extends Constructor>() { x: string } +class C23 extends Constructor>() { x: string } + + +//// [interfaceExtendsObjectIntersection.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var C1 = (function (_super) { + __extends(C1, _super); + function C1() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C1; +}(Constructor())); +var C2 = (function (_super) { + __extends(C2, _super); + function C2() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C2; +}(Constructor())); +var C3 = (function (_super) { + __extends(C3, _super); + function C3() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C3; +}(Constructor())); +var C4 = (function (_super) { + __extends(C4, _super); + function C4() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C4; +}(Constructor())); +var C5 = (function (_super) { + __extends(C5, _super); + function C5() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C5; +}(Constructor())); +var C6 = (function (_super) { + __extends(C6, _super); + function C6() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C6; +}(Constructor())); +var C7 = (function (_super) { + __extends(C7, _super); + function C7() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C7; +}(Constructor())); +var C20 = (function (_super) { + __extends(C20, _super); + function C20() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C20; +}(Constructor())); +var C21 = (function (_super) { + __extends(C21, _super); + function C21() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C21; +}(Constructor())); +var C22 = (function (_super) { + __extends(C22, _super); + function C22() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C22; +}(Constructor())); +var C23 = (function (_super) { + __extends(C23, _super); + function C23() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C23; +}(Constructor())); diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersection.symbols b/tests/baselines/reference/interfaceExtendsObjectIntersection.symbols new file mode 100644 index 00000000000..16c8c51cf47 --- /dev/null +++ b/tests/baselines/reference/interfaceExtendsObjectIntersection.symbols @@ -0,0 +1,230 @@ +=== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts === + +type T1 = { a: number }; +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>a : Symbol(a, Decl(interfaceExtendsObjectIntersection.ts, 1, 11)) + +type T2 = T1 & { b: number }; +>T2 : Symbol(T2, Decl(interfaceExtendsObjectIntersection.ts, 1, 24)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>b : Symbol(b, Decl(interfaceExtendsObjectIntersection.ts, 2, 16)) + +type T3 = () => void; +>T3 : Symbol(T3, Decl(interfaceExtendsObjectIntersection.ts, 2, 29)) + +type T4 = new () => { a: number }; +>T4 : Symbol(T4, Decl(interfaceExtendsObjectIntersection.ts, 3, 21)) +>a : Symbol(a, Decl(interfaceExtendsObjectIntersection.ts, 4, 21)) + +type T5 = number[]; +>T5 : Symbol(T5, Decl(interfaceExtendsObjectIntersection.ts, 4, 34)) + +type T6 = [string, number]; +>T6 : Symbol(T6, Decl(interfaceExtendsObjectIntersection.ts, 5, 19)) + +type T7 = { [P in 'a' | 'b' | 'c']: string }; +>T7 : Symbol(T7, Decl(interfaceExtendsObjectIntersection.ts, 6, 27)) +>P : Symbol(P, Decl(interfaceExtendsObjectIntersection.ts, 7, 13)) + +interface I1 extends T1 { x: string } +>I1 : Symbol(I1, Decl(interfaceExtendsObjectIntersection.ts, 7, 45)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>x : Symbol(I1.x, Decl(interfaceExtendsObjectIntersection.ts, 9, 25)) + +interface I2 extends T2 { x: string } +>I2 : Symbol(I2, Decl(interfaceExtendsObjectIntersection.ts, 9, 37)) +>T2 : Symbol(T2, Decl(interfaceExtendsObjectIntersection.ts, 1, 24)) +>x : Symbol(I2.x, Decl(interfaceExtendsObjectIntersection.ts, 10, 25)) + +interface I3 extends T3 { x: string } +>I3 : Symbol(I3, Decl(interfaceExtendsObjectIntersection.ts, 10, 37)) +>T3 : Symbol(T3, Decl(interfaceExtendsObjectIntersection.ts, 2, 29)) +>x : Symbol(I3.x, Decl(interfaceExtendsObjectIntersection.ts, 11, 25)) + +interface I4 extends T4 { x: string } +>I4 : Symbol(I4, Decl(interfaceExtendsObjectIntersection.ts, 11, 37)) +>T4 : Symbol(T4, Decl(interfaceExtendsObjectIntersection.ts, 3, 21)) +>x : Symbol(I4.x, Decl(interfaceExtendsObjectIntersection.ts, 12, 25)) + +interface I5 extends T5 { x: string } +>I5 : Symbol(I5, Decl(interfaceExtendsObjectIntersection.ts, 12, 37)) +>T5 : Symbol(T5, Decl(interfaceExtendsObjectIntersection.ts, 4, 34)) +>x : Symbol(I5.x, Decl(interfaceExtendsObjectIntersection.ts, 13, 25)) + +interface I6 extends T6 { x: string } +>I6 : Symbol(I6, Decl(interfaceExtendsObjectIntersection.ts, 13, 37)) +>T6 : Symbol(T6, Decl(interfaceExtendsObjectIntersection.ts, 5, 19)) +>x : Symbol(I6.x, Decl(interfaceExtendsObjectIntersection.ts, 14, 25)) + +interface I7 extends T7 { x: string } +>I7 : Symbol(I7, Decl(interfaceExtendsObjectIntersection.ts, 14, 37)) +>T7 : Symbol(T7, Decl(interfaceExtendsObjectIntersection.ts, 6, 27)) +>x : Symbol(I7.x, Decl(interfaceExtendsObjectIntersection.ts, 15, 25)) + +type Constructor = new () => T; +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>T : Symbol(T, Decl(interfaceExtendsObjectIntersection.ts, 17, 17)) +>T : Symbol(T, Decl(interfaceExtendsObjectIntersection.ts, 17, 17)) + +declare function Constructor(): Constructor; +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>T : Symbol(T, Decl(interfaceExtendsObjectIntersection.ts, 18, 29)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>T : Symbol(T, Decl(interfaceExtendsObjectIntersection.ts, 18, 29)) + +class C1 extends Constructor() { x: string } +>C1 : Symbol(C1, Decl(interfaceExtendsObjectIntersection.ts, 18, 50)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>I1 : Symbol(I1, Decl(interfaceExtendsObjectIntersection.ts, 7, 45)) +>x : Symbol(C1.x, Decl(interfaceExtendsObjectIntersection.ts, 20, 36)) + +class C2 extends Constructor() { x: string } +>C2 : Symbol(C2, Decl(interfaceExtendsObjectIntersection.ts, 20, 48)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>I2 : Symbol(I2, Decl(interfaceExtendsObjectIntersection.ts, 9, 37)) +>x : Symbol(C2.x, Decl(interfaceExtendsObjectIntersection.ts, 21, 36)) + +class C3 extends Constructor() { x: string } +>C3 : Symbol(C3, Decl(interfaceExtendsObjectIntersection.ts, 21, 48)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>I3 : Symbol(I3, Decl(interfaceExtendsObjectIntersection.ts, 10, 37)) +>x : Symbol(C3.x, Decl(interfaceExtendsObjectIntersection.ts, 22, 36)) + +class C4 extends Constructor() { x: string } +>C4 : Symbol(C4, Decl(interfaceExtendsObjectIntersection.ts, 22, 48)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>I4 : Symbol(I4, Decl(interfaceExtendsObjectIntersection.ts, 11, 37)) +>x : Symbol(C4.x, Decl(interfaceExtendsObjectIntersection.ts, 23, 36)) + +class C5 extends Constructor() { x: string } +>C5 : Symbol(C5, Decl(interfaceExtendsObjectIntersection.ts, 23, 48)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>I5 : Symbol(I5, Decl(interfaceExtendsObjectIntersection.ts, 12, 37)) +>x : Symbol(C5.x, Decl(interfaceExtendsObjectIntersection.ts, 24, 36)) + +class C6 extends Constructor() { x: string } +>C6 : Symbol(C6, Decl(interfaceExtendsObjectIntersection.ts, 24, 48)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>I6 : Symbol(I6, Decl(interfaceExtendsObjectIntersection.ts, 13, 37)) +>x : Symbol(C6.x, Decl(interfaceExtendsObjectIntersection.ts, 25, 36)) + +class C7 extends Constructor() { x: string } +>C7 : Symbol(C7, Decl(interfaceExtendsObjectIntersection.ts, 25, 48)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>I7 : Symbol(I7, Decl(interfaceExtendsObjectIntersection.ts, 14, 37)) +>x : Symbol(C7.x, Decl(interfaceExtendsObjectIntersection.ts, 26, 36)) + +declare function fx(x: string): string; +>fx : Symbol(fx, Decl(interfaceExtendsObjectIntersection.ts, 26, 48)) +>x : Symbol(x, Decl(interfaceExtendsObjectIntersection.ts, 28, 20)) + +declare class CX { a: number } +>CX : Symbol(CX, Decl(interfaceExtendsObjectIntersection.ts, 28, 39)) +>a : Symbol(CX.a, Decl(interfaceExtendsObjectIntersection.ts, 29, 18)) + +declare enum EX { A, B, C } +>EX : Symbol(EX, Decl(interfaceExtendsObjectIntersection.ts, 29, 30)) +>A : Symbol(EX.A, Decl(interfaceExtendsObjectIntersection.ts, 30, 17)) +>B : Symbol(EX.B, Decl(interfaceExtendsObjectIntersection.ts, 30, 20)) +>C : Symbol(EX.C, Decl(interfaceExtendsObjectIntersection.ts, 30, 23)) + +declare namespace NX { export const a = 1 } +>NX : Symbol(NX, Decl(interfaceExtendsObjectIntersection.ts, 30, 27)) +>a : Symbol(a, Decl(interfaceExtendsObjectIntersection.ts, 31, 35)) + +type T10 = typeof fx; +>T10 : Symbol(T10, Decl(interfaceExtendsObjectIntersection.ts, 31, 43)) +>fx : Symbol(fx, Decl(interfaceExtendsObjectIntersection.ts, 26, 48)) + +type T11 = typeof CX; +>T11 : Symbol(T11, Decl(interfaceExtendsObjectIntersection.ts, 33, 21)) +>CX : Symbol(CX, Decl(interfaceExtendsObjectIntersection.ts, 28, 39)) + +type T12 = typeof EX; +>T12 : Symbol(T12, Decl(interfaceExtendsObjectIntersection.ts, 34, 21)) +>EX : Symbol(EX, Decl(interfaceExtendsObjectIntersection.ts, 29, 30)) + +type T13 = typeof NX; +>T13 : Symbol(T13, Decl(interfaceExtendsObjectIntersection.ts, 35, 21)) +>NX : Symbol(NX, Decl(interfaceExtendsObjectIntersection.ts, 30, 27)) + +interface I10 extends T10 { x: string } +>I10 : Symbol(I10, Decl(interfaceExtendsObjectIntersection.ts, 36, 21)) +>T10 : Symbol(T10, Decl(interfaceExtendsObjectIntersection.ts, 31, 43)) +>x : Symbol(I10.x, Decl(interfaceExtendsObjectIntersection.ts, 38, 27)) + +interface I11 extends T11 { x: string } +>I11 : Symbol(I11, Decl(interfaceExtendsObjectIntersection.ts, 38, 39)) +>T11 : Symbol(T11, Decl(interfaceExtendsObjectIntersection.ts, 33, 21)) +>x : Symbol(I11.x, Decl(interfaceExtendsObjectIntersection.ts, 39, 27)) + +interface I12 extends T12 { x: string } +>I12 : Symbol(I12, Decl(interfaceExtendsObjectIntersection.ts, 39, 39)) +>T12 : Symbol(T12, Decl(interfaceExtendsObjectIntersection.ts, 34, 21)) +>x : Symbol(I12.x, Decl(interfaceExtendsObjectIntersection.ts, 40, 27)) + +interface I13 extends T13 { x: string } +>I13 : Symbol(I13, Decl(interfaceExtendsObjectIntersection.ts, 40, 39)) +>T13 : Symbol(T13, Decl(interfaceExtendsObjectIntersection.ts, 35, 21)) +>x : Symbol(I13.x, Decl(interfaceExtendsObjectIntersection.ts, 41, 27)) + +type Identifiable = { _id: string } & T; +>Identifiable : Symbol(Identifiable, Decl(interfaceExtendsObjectIntersection.ts, 41, 39)) +>T : Symbol(T, Decl(interfaceExtendsObjectIntersection.ts, 43, 18)) +>_id : Symbol(_id, Decl(interfaceExtendsObjectIntersection.ts, 43, 24)) +>T : Symbol(T, Decl(interfaceExtendsObjectIntersection.ts, 43, 18)) + +interface I20 extends Partial { x: string } +>I20 : Symbol(I20, Decl(interfaceExtendsObjectIntersection.ts, 43, 43)) +>Partial : Symbol(Partial, Decl(lib.d.ts, --, --)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>x : Symbol(I20.x, Decl(interfaceExtendsObjectIntersection.ts, 45, 35)) + +interface I21 extends Readonly { x: string } +>I21 : Symbol(I21, Decl(interfaceExtendsObjectIntersection.ts, 45, 47)) +>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>x : Symbol(I21.x, Decl(interfaceExtendsObjectIntersection.ts, 46, 36)) + +interface I22 extends Identifiable { x: string } +>I22 : Symbol(I22, Decl(interfaceExtendsObjectIntersection.ts, 46, 48)) +>Identifiable : Symbol(Identifiable, Decl(interfaceExtendsObjectIntersection.ts, 41, 39)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>x : Symbol(I22.x, Decl(interfaceExtendsObjectIntersection.ts, 47, 40)) + +interface I23 extends Identifiable { x: string } +>I23 : Symbol(I23, Decl(interfaceExtendsObjectIntersection.ts, 47, 52)) +>Identifiable : Symbol(Identifiable, Decl(interfaceExtendsObjectIntersection.ts, 41, 39)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>b : Symbol(b, Decl(interfaceExtendsObjectIntersection.ts, 48, 41)) +>x : Symbol(I23.x, Decl(interfaceExtendsObjectIntersection.ts, 48, 55)) + +class C20 extends Constructor>() { x: string } +>C20 : Symbol(C20, Decl(interfaceExtendsObjectIntersection.ts, 48, 67)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>Partial : Symbol(Partial, Decl(lib.d.ts, --, --)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>x : Symbol(C20.x, Decl(interfaceExtendsObjectIntersection.ts, 50, 46)) + +class C21 extends Constructor>() { x: string } +>C21 : Symbol(C21, Decl(interfaceExtendsObjectIntersection.ts, 50, 58)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>x : Symbol(C21.x, Decl(interfaceExtendsObjectIntersection.ts, 51, 47)) + +class C22 extends Constructor>() { x: string } +>C22 : Symbol(C22, Decl(interfaceExtendsObjectIntersection.ts, 51, 59)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>Identifiable : Symbol(Identifiable, Decl(interfaceExtendsObjectIntersection.ts, 41, 39)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>x : Symbol(C22.x, Decl(interfaceExtendsObjectIntersection.ts, 52, 51)) + +class C23 extends Constructor>() { x: string } +>C23 : Symbol(C23, Decl(interfaceExtendsObjectIntersection.ts, 52, 63)) +>Constructor : Symbol(Constructor, Decl(interfaceExtendsObjectIntersection.ts, 15, 37), Decl(interfaceExtendsObjectIntersection.ts, 17, 34)) +>Identifiable : Symbol(Identifiable, Decl(interfaceExtendsObjectIntersection.ts, 41, 39)) +>T1 : Symbol(T1, Decl(interfaceExtendsObjectIntersection.ts, 0, 0)) +>b : Symbol(b, Decl(interfaceExtendsObjectIntersection.ts, 53, 49)) +>x : Symbol(C23.x, Decl(interfaceExtendsObjectIntersection.ts, 53, 66)) + diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersection.types b/tests/baselines/reference/interfaceExtendsObjectIntersection.types new file mode 100644 index 00000000000..1ff550df7b4 --- /dev/null +++ b/tests/baselines/reference/interfaceExtendsObjectIntersection.types @@ -0,0 +1,242 @@ +=== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts === + +type T1 = { a: number }; +>T1 : T1 +>a : number + +type T2 = T1 & { b: number }; +>T2 : T2 +>T1 : T1 +>b : number + +type T3 = () => void; +>T3 : T3 + +type T4 = new () => { a: number }; +>T4 : T4 +>a : number + +type T5 = number[]; +>T5 : number[] + +type T6 = [string, number]; +>T6 : [string, number] + +type T7 = { [P in 'a' | 'b' | 'c']: string }; +>T7 : T7 +>P : P + +interface I1 extends T1 { x: string } +>I1 : I1 +>T1 : T1 +>x : string + +interface I2 extends T2 { x: string } +>I2 : I2 +>T2 : T2 +>x : string + +interface I3 extends T3 { x: string } +>I3 : I3 +>T3 : T3 +>x : string + +interface I4 extends T4 { x: string } +>I4 : I4 +>T4 : T4 +>x : string + +interface I5 extends T5 { x: string } +>I5 : I5 +>T5 : number[] +>x : string + +interface I6 extends T6 { x: string } +>I6 : I6 +>T6 : [string, number] +>x : string + +interface I7 extends T7 { x: string } +>I7 : I7 +>T7 : T7 +>x : string + +type Constructor = new () => T; +>Constructor : Constructor +>T : T +>T : T + +declare function Constructor(): Constructor; +>Constructor : () => Constructor +>T : T +>Constructor : Constructor +>T : T + +class C1 extends Constructor() { x: string } +>C1 : C1 +>Constructor() : I1 +>Constructor : () => Constructor +>I1 : I1 +>x : string + +class C2 extends Constructor() { x: string } +>C2 : C2 +>Constructor() : I2 +>Constructor : () => Constructor +>I2 : I2 +>x : string + +class C3 extends Constructor() { x: string } +>C3 : C3 +>Constructor() : I3 +>Constructor : () => Constructor +>I3 : I3 +>x : string + +class C4 extends Constructor() { x: string } +>C4 : C4 +>Constructor() : I4 +>Constructor : () => Constructor +>I4 : I4 +>x : string + +class C5 extends Constructor() { x: string } +>C5 : C5 +>Constructor() : I5 +>Constructor : () => Constructor +>I5 : I5 +>x : string + +class C6 extends Constructor() { x: string } +>C6 : C6 +>Constructor() : I6 +>Constructor : () => Constructor +>I6 : I6 +>x : string + +class C7 extends Constructor() { x: string } +>C7 : C7 +>Constructor() : I7 +>Constructor : () => Constructor +>I7 : I7 +>x : string + +declare function fx(x: string): string; +>fx : (x: string) => string +>x : string + +declare class CX { a: number } +>CX : CX +>a : number + +declare enum EX { A, B, C } +>EX : EX +>A : EX +>B : EX +>C : EX + +declare namespace NX { export const a = 1 } +>NX : typeof NX +>a : 1 +>1 : 1 + +type T10 = typeof fx; +>T10 : (x: string) => string +>fx : (x: string) => string + +type T11 = typeof CX; +>T11 : typeof CX +>CX : typeof CX + +type T12 = typeof EX; +>T12 : typeof EX +>EX : typeof EX + +type T13 = typeof NX; +>T13 : typeof NX +>NX : typeof NX + +interface I10 extends T10 { x: string } +>I10 : I10 +>T10 : (x: string) => string +>x : string + +interface I11 extends T11 { x: string } +>I11 : I11 +>T11 : typeof CX +>x : string + +interface I12 extends T12 { x: string } +>I12 : I12 +>T12 : typeof EX +>x : string + +interface I13 extends T13 { x: string } +>I13 : I13 +>T13 : typeof NX +>x : string + +type Identifiable = { _id: string } & T; +>Identifiable : Identifiable +>T : T +>_id : string +>T : T + +interface I20 extends Partial { x: string } +>I20 : I20 +>Partial : Partial +>T1 : T1 +>x : string + +interface I21 extends Readonly { x: string } +>I21 : I21 +>Readonly : Readonly +>T1 : T1 +>x : string + +interface I22 extends Identifiable { x: string } +>I22 : I22 +>Identifiable : Identifiable +>T1 : T1 +>x : string + +interface I23 extends Identifiable { x: string } +>I23 : I23 +>Identifiable : Identifiable +>T1 : T1 +>b : number +>x : string + +class C20 extends Constructor>() { x: string } +>C20 : C20 +>Constructor>() : Partial +>Constructor : () => Constructor +>Partial : Partial +>T1 : T1 +>x : string + +class C21 extends Constructor>() { x: string } +>C21 : C21 +>Constructor>() : Readonly +>Constructor : () => Constructor +>Readonly : Readonly +>T1 : T1 +>x : string + +class C22 extends Constructor>() { x: string } +>C22 : C22 +>Constructor>() : Identifiable +>Constructor : () => Constructor +>Identifiable : Identifiable +>T1 : T1 +>x : string + +class C23 extends Constructor>() { x: string } +>C23 : C23 +>Constructor>() : Identifiable +>Constructor : () => Constructor +>Identifiable : Identifiable +>T1 : T1 +>b : number +>x : string + diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt new file mode 100644 index 00000000000..839474b3bdc --- /dev/null +++ b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt @@ -0,0 +1,197 @@ +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(8,11): error TS2430: Interface 'I1' incorrectly extends interface 'T1'. + Types of property 'a' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(9,11): error TS2430: Interface 'I2' incorrectly extends interface 'T2'. + Type 'I2' is not assignable to type '{ b: number; }'. + Types of property 'b' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(10,11): error TS2430: Interface 'I3' incorrectly extends interface 'number[]'. + Types of property 'length' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(11,11): error TS2430: Interface 'I4' incorrectly extends interface '[string, number]'. + Types of property '0' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(12,11): error TS2430: Interface 'I5' incorrectly extends interface 'T5'. + Types of property 'c' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(17,7): error TS2415: Class 'C1' incorrectly extends base class 'T1'. + Types of property 'a' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(18,7): error TS2415: Class 'C2' incorrectly extends base class 'T2'. + Type 'C2' is not assignable to type '{ b: number; }'. + Types of property 'b' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(19,7): error TS2415: Class 'C3' incorrectly extends base class 'number[]'. + Types of property 'length' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(20,7): error TS2415: Class 'C4' incorrectly extends base class '[string, number]'. + Types of property '0' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(21,7): error TS2415: Class 'C5' incorrectly extends base class 'T5'. + Types of property 'c' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(31,11): error TS2430: Interface 'I10' incorrectly extends interface 'typeof CX'. + Types of property 'a' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(32,11): error TS2430: Interface 'I11' incorrectly extends interface 'typeof EX'. + Types of property 'C' are incompatible. + Type 'string' is not assignable to type 'EX'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(33,11): error TS2430: Interface 'I12' incorrectly extends interface 'typeof NX'. + Types of property 'a' are incompatible. + Type 'number' is not assignable to type '"hello"'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(34,29): error TS2411: Property 'a' of type 'string' is not assignable to string index type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(34,29): error TS2411: Property 'prototype' of type 'CX' is not assignable to string index type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(35,29): error TS2413: Numeric index type 'string' is not assignable to string index type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(36,29): error TS2411: Property 'a' of type '"hello"' is not assignable to string index type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(40,11): error TS2430: Interface 'I20' incorrectly extends interface 'Partial'. + Types of property 'a' are incompatible. + Type 'string' is not assignable to type 'number | undefined'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(41,11): error TS2430: Interface 'I21' incorrectly extends interface 'Readonly'. + Types of property 'a' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(42,11): error TS2430: Interface 'I22' incorrectly extends interface 'Identifiable'. + Type 'I22' is not assignable to type 'T1'. + Types of property 'a' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(43,11): error TS2430: Interface 'I23' incorrectly extends interface 'Identifiable'. + Type 'I23' is not assignable to type 'T1'. + Types of property 'a' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(47,23): error TS2312: An interface may only extend a class or another interface. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(48,26): error TS2312: An interface may only extend a class or another interface. + + +==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts (23 errors) ==== + + type T1 = { a: number }; + type T2 = T1 & { b: number }; + type T3 = number[]; + type T4 = [string, number]; + type T5 = { [P in 'a' | 'b' | 'c']: string }; + + interface I1 extends T1 { a: string } + ~~ +!!! error TS2430: Interface 'I1' incorrectly extends interface 'T1'. +!!! error TS2430: Types of property 'a' are incompatible. +!!! error TS2430: Type 'string' is not assignable to type 'number'. + interface I2 extends T2 { b: string } + ~~ +!!! error TS2430: Interface 'I2' incorrectly extends interface 'T2'. +!!! error TS2430: Type 'I2' is not assignable to type '{ b: number; }'. +!!! error TS2430: Types of property 'b' are incompatible. +!!! error TS2430: Type 'string' is not assignable to type 'number'. + interface I3 extends T3 { length: string } + ~~ +!!! error TS2430: Interface 'I3' incorrectly extends interface 'number[]'. +!!! error TS2430: Types of property 'length' are incompatible. +!!! error TS2430: Type 'string' is not assignable to type 'number'. + interface I4 extends T4 { 0: number } + ~~ +!!! error TS2430: Interface 'I4' incorrectly extends interface '[string, number]'. +!!! error TS2430: Types of property '0' are incompatible. +!!! error TS2430: Type 'number' is not assignable to type 'string'. + interface I5 extends T5 { c: number } + ~~ +!!! error TS2430: Interface 'I5' incorrectly extends interface 'T5'. +!!! error TS2430: Types of property 'c' are incompatible. +!!! error TS2430: Type 'number' is not assignable to type 'string'. + + type Constructor = new () => T; + declare function Constructor(): Constructor; + + class C1 extends Constructor() { a: string } + ~~ +!!! error TS2415: Class 'C1' incorrectly extends base class 'T1'. +!!! error TS2415: Types of property 'a' are incompatible. +!!! error TS2415: Type 'string' is not assignable to type 'number'. + class C2 extends Constructor() { b: string } + ~~ +!!! error TS2415: Class 'C2' incorrectly extends base class 'T2'. +!!! error TS2415: Type 'C2' is not assignable to type '{ b: number; }'. +!!! error TS2415: Types of property 'b' are incompatible. +!!! error TS2415: Type 'string' is not assignable to type 'number'. + class C3 extends Constructor() { length: string } + ~~ +!!! error TS2415: Class 'C3' incorrectly extends base class 'number[]'. +!!! error TS2415: Types of property 'length' are incompatible. +!!! error TS2415: Type 'string' is not assignable to type 'number'. + class C4 extends Constructor() { 0: number } + ~~ +!!! error TS2415: Class 'C4' incorrectly extends base class '[string, number]'. +!!! error TS2415: Types of property '0' are incompatible. +!!! error TS2415: Type 'number' is not assignable to type 'string'. + class C5 extends Constructor() { c: number } + ~~ +!!! error TS2415: Class 'C5' incorrectly extends base class 'T5'. +!!! error TS2415: Types of property 'c' are incompatible. +!!! error TS2415: Type 'number' is not assignable to type 'string'. + + declare class CX { static a: string } + declare enum EX { A, B, C } + declare namespace NX { export const a = "hello" } + + type TCX = typeof CX; + type TEX = typeof EX; + type TNX = typeof NX; + + interface I10 extends TCX { a: number } + ~~~ +!!! error TS2430: Interface 'I10' incorrectly extends interface 'typeof CX'. +!!! error TS2430: Types of property 'a' are incompatible. +!!! error TS2430: Type 'number' is not assignable to type 'string'. + interface I11 extends TEX { C: string } + ~~~ +!!! error TS2430: Interface 'I11' incorrectly extends interface 'typeof EX'. +!!! error TS2430: Types of property 'C' are incompatible. +!!! error TS2430: Type 'string' is not assignable to type 'EX'. + interface I12 extends TNX { a: number } + ~~~ +!!! error TS2430: Interface 'I12' incorrectly extends interface 'typeof NX'. +!!! error TS2430: Types of property 'a' are incompatible. +!!! error TS2430: Type 'number' is not assignable to type '"hello"'. + interface I14 extends TCX { [x: string]: number } + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2411: Property 'a' of type 'string' is not assignable to string index type 'number'. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2411: Property 'prototype' of type 'CX' is not assignable to string index type 'number'. + interface I15 extends TEX { [x: string]: number } + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2413: Numeric index type 'string' is not assignable to string index type 'number'. + interface I16 extends TNX { [x: string]: number } + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2411: Property 'a' of type '"hello"' is not assignable to string index type 'number'. + + type Identifiable = { _id: string } & T; + + interface I20 extends Partial { a: string } + ~~~ +!!! error TS2430: Interface 'I20' incorrectly extends interface 'Partial'. +!!! error TS2430: Types of property 'a' are incompatible. +!!! error TS2430: Type 'string' is not assignable to type 'number | undefined'. + interface I21 extends Readonly { a: string } + ~~~ +!!! error TS2430: Interface 'I21' incorrectly extends interface 'Readonly'. +!!! error TS2430: Types of property 'a' are incompatible. +!!! error TS2430: Type 'string' is not assignable to type 'number'. + interface I22 extends Identifiable { a: string } + ~~~ +!!! error TS2430: Interface 'I22' incorrectly extends interface 'Identifiable'. +!!! error TS2430: Type 'I22' is not assignable to type 'T1'. +!!! error TS2430: Types of property 'a' are incompatible. +!!! error TS2430: Type 'string' is not assignable to type 'number'. + interface I23 extends Identifiable { a: string } + ~~~ +!!! error TS2430: Interface 'I23' incorrectly extends interface 'Identifiable'. +!!! error TS2430: Type 'I23' is not assignable to type 'T1'. +!!! error TS2430: Types of property 'a' are incompatible. +!!! error TS2430: Type 'string' is not assignable to type 'number'. + + type U = { a: number } | { b: string }; + + interface I30 extends U { x: string } + ~ +!!! error TS2312: An interface may only extend a class or another interface. + interface I31 extends T { x: string } + ~ +!!! error TS2312: An interface may only extend a class or another interface. + \ No newline at end of file diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.js b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.js new file mode 100644 index 00000000000..61f84b2f7fe --- /dev/null +++ b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.js @@ -0,0 +1,97 @@ +//// [interfaceExtendsObjectIntersectionErrors.ts] + +type T1 = { a: number }; +type T2 = T1 & { b: number }; +type T3 = number[]; +type T4 = [string, number]; +type T5 = { [P in 'a' | 'b' | 'c']: string }; + +interface I1 extends T1 { a: string } +interface I2 extends T2 { b: string } +interface I3 extends T3 { length: string } +interface I4 extends T4 { 0: number } +interface I5 extends T5 { c: number } + +type Constructor = new () => T; +declare function Constructor(): Constructor; + +class C1 extends Constructor() { a: string } +class C2 extends Constructor() { b: string } +class C3 extends Constructor() { length: string } +class C4 extends Constructor() { 0: number } +class C5 extends Constructor() { c: number } + +declare class CX { static a: string } +declare enum EX { A, B, C } +declare namespace NX { export const a = "hello" } + +type TCX = typeof CX; +type TEX = typeof EX; +type TNX = typeof NX; + +interface I10 extends TCX { a: number } +interface I11 extends TEX { C: string } +interface I12 extends TNX { a: number } +interface I14 extends TCX { [x: string]: number } +interface I15 extends TEX { [x: string]: number } +interface I16 extends TNX { [x: string]: number } + +type Identifiable = { _id: string } & T; + +interface I20 extends Partial { a: string } +interface I21 extends Readonly { a: string } +interface I22 extends Identifiable { a: string } +interface I23 extends Identifiable { a: string } + +type U = { a: number } | { b: string }; + +interface I30 extends U { x: string } +interface I31 extends T { x: string } + + +//// [interfaceExtendsObjectIntersectionErrors.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var C1 = (function (_super) { + __extends(C1, _super); + function C1() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C1; +}(Constructor())); +var C2 = (function (_super) { + __extends(C2, _super); + function C2() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C2; +}(Constructor())); +var C3 = (function (_super) { + __extends(C3, _super); + function C3() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C3; +}(Constructor())); +var C4 = (function (_super) { + __extends(C4, _super); + function C4() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C4; +}(Constructor())); +var C5 = (function (_super) { + __extends(C5, _super); + function C5() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C5; +}(Constructor())); diff --git a/tests/baselines/reference/interfaceImplementation6.js b/tests/baselines/reference/interfaceImplementation6.js index 642300d9160..0bc759f6cda 100644 --- a/tests/baselines/reference/interfaceImplementation6.js +++ b/tests/baselines/reference/interfaceImplementation6.js @@ -27,6 +27,7 @@ export class Test { //// [interfaceImplementation6.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var C1 = (function () { function C1() { } diff --git a/tests/baselines/reference/interfaceImplementation8.js b/tests/baselines/reference/interfaceImplementation8.js index afb5a795264..c966cdc2c14 100644 --- a/tests/baselines/reference/interfaceImplementation8.js +++ b/tests/baselines/reference/interfaceImplementation8.js @@ -41,11 +41,16 @@ class C8 extends C7 implements i2{ //// [interfaceImplementation8.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1() { } @@ -64,21 +69,21 @@ var C3 = (function () { var C4 = (function (_super) { __extends(C4, _super); function C4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C4; }(C1)); var C5 = (function (_super) { __extends(C5, _super); function C5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C5; }(C2)); var C6 = (function (_super) { __extends(C6, _super); function C6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C6; }(C3)); @@ -90,7 +95,7 @@ var C7 = (function () { var C8 = (function (_super) { __extends(C8, _super); function C8() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C8; }(C7)); diff --git a/tests/baselines/reference/interfaceWithMultipleDeclarations.errors.txt b/tests/baselines/reference/interfaceWithMultipleDeclarations.errors.txt index 79d8b4a509a..cabc329df7e 100644 --- a/tests/baselines/reference/interfaceWithMultipleDeclarations.errors.txt +++ b/tests/baselines/reference/interfaceWithMultipleDeclarations.errors.txt @@ -1,18 +1,23 @@ +tests/cases/compiler/interfaceWithMultipleDeclarations.ts(1,11): error TS2428: All declarations of 'I1' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(3,11): error TS2428: All declarations of 'I1' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(5,11): error TS2428: All declarations of 'I1' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(7,11): error TS2428: All declarations of 'I1' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(9,11): error TS2428: All declarations of 'I1' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(11,11): error TS2428: All declarations of 'I1' must have identical type parameters. +tests/cases/compiler/interfaceWithMultipleDeclarations.ts(14,11): error TS2428: All declarations of 'I2' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(16,11): error TS2428: All declarations of 'I2' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(18,11): error TS2428: All declarations of 'I2' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(20,11): error TS2428: All declarations of 'I2' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(22,11): error TS2428: All declarations of 'I2' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(24,11): error TS2428: All declarations of 'I2' must have identical type parameters. +tests/cases/compiler/interfaceWithMultipleDeclarations.ts(27,11): error TS2428: All declarations of 'I3' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(29,11): error TS2428: All declarations of 'I3' must have identical type parameters. -==== tests/cases/compiler/interfaceWithMultipleDeclarations.ts (11 errors) ==== +==== tests/cases/compiler/interfaceWithMultipleDeclarations.ts (14 errors) ==== interface I1 { + ~~ +!!! error TS2428: All declarations of 'I1' must have identical type parameters. } interface I1 { // Name mismatch ~~ @@ -36,6 +41,8 @@ tests/cases/compiler/interfaceWithMultipleDeclarations.ts(29,11): error TS2428: } interface I2 { + ~~ +!!! error TS2428: All declarations of 'I2' must have identical type parameters. } interface I2 string> { // constraint mismatch ~~ @@ -59,6 +66,8 @@ tests/cases/compiler/interfaceWithMultipleDeclarations.ts(29,11): error TS2428: } interface I3 { + ~~ +!!! error TS2428: All declarations of 'I3' must have identical type parameters. } interface I3 { // length mismatch ~~ diff --git a/tests/baselines/reference/internalAliasClassInsideLocalModuleWithExport.js b/tests/baselines/reference/internalAliasClassInsideLocalModuleWithExport.js index aa274838529..0b333ac1830 100644 --- a/tests/baselines/reference/internalAliasClassInsideLocalModuleWithExport.js +++ b/tests/baselines/reference/internalAliasClassInsideLocalModuleWithExport.js @@ -19,6 +19,7 @@ export var d = new m2.m3.c(); //// [internalAliasClassInsideLocalModuleWithExport.js] "use strict"; +exports.__esModule = true; var x; (function (x) { var c = (function () { diff --git a/tests/baselines/reference/internalAliasClassInsideLocalModuleWithoutExport.js b/tests/baselines/reference/internalAliasClassInsideLocalModuleWithoutExport.js index 03b3542eca4..cf2eb41662b 100644 --- a/tests/baselines/reference/internalAliasClassInsideLocalModuleWithoutExport.js +++ b/tests/baselines/reference/internalAliasClassInsideLocalModuleWithoutExport.js @@ -17,6 +17,7 @@ export module m2 { //// [internalAliasClassInsideLocalModuleWithoutExport.js] "use strict"; +exports.__esModule = true; var x; (function (x) { var c = (function () { diff --git a/tests/baselines/reference/internalAliasClassInsideLocalModuleWithoutExportAccessError.js b/tests/baselines/reference/internalAliasClassInsideLocalModuleWithoutExportAccessError.js index c15ca69e13f..1de7fe25407 100644 --- a/tests/baselines/reference/internalAliasClassInsideLocalModuleWithoutExportAccessError.js +++ b/tests/baselines/reference/internalAliasClassInsideLocalModuleWithoutExportAccessError.js @@ -19,6 +19,7 @@ export var d = new m2.m3.c(); //// [internalAliasClassInsideLocalModuleWithoutExportAccessError.js] "use strict"; +exports.__esModule = true; var x; (function (x) { var c = (function () { diff --git a/tests/baselines/reference/internalAliasClassInsideTopLevelModuleWithExport.js b/tests/baselines/reference/internalAliasClassInsideTopLevelModuleWithExport.js index f881032fa1e..e224b40c9f3 100644 --- a/tests/baselines/reference/internalAliasClassInsideTopLevelModuleWithExport.js +++ b/tests/baselines/reference/internalAliasClassInsideTopLevelModuleWithExport.js @@ -13,6 +13,7 @@ var cReturnVal = cProp.foo(10); //// [internalAliasClassInsideTopLevelModuleWithExport.js] "use strict"; +exports.__esModule = true; var x; (function (x) { var c = (function () { diff --git a/tests/baselines/reference/internalAliasClassInsideTopLevelModuleWithoutExport.js b/tests/baselines/reference/internalAliasClassInsideTopLevelModuleWithoutExport.js index ac5004a7606..16f53fe3e8b 100644 --- a/tests/baselines/reference/internalAliasClassInsideTopLevelModuleWithoutExport.js +++ b/tests/baselines/reference/internalAliasClassInsideTopLevelModuleWithoutExport.js @@ -13,6 +13,7 @@ var cReturnVal = cProp.foo(10); //// [internalAliasClassInsideTopLevelModuleWithoutExport.js] "use strict"; +exports.__esModule = true; var x; (function (x) { var c = (function () { diff --git a/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithExport.js b/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithExport.js index c7b8bf2cacc..c387fa6e2c4 100644 --- a/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithExport.js +++ b/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithExport.js @@ -15,6 +15,7 @@ export module c { //// [internalAliasEnumInsideLocalModuleWithExport.js] "use strict"; +exports.__esModule = true; var a; (function (a) { var weekend; diff --git a/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExport.js b/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExport.js index 267fffc7b70..717652283cf 100644 --- a/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExport.js +++ b/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExport.js @@ -15,6 +15,7 @@ export module c { //// [internalAliasEnumInsideLocalModuleWithoutExport.js] "use strict"; +exports.__esModule = true; var a; (function (a) { var weekend; diff --git a/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExportAccessError.js b/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExportAccessError.js index a44298b6864..a84ebf0b9ad 100644 --- a/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExportAccessError.js +++ b/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExportAccessError.js @@ -16,6 +16,7 @@ var happyFriday = c.b.Friday; //// [internalAliasEnumInsideLocalModuleWithoutExportAccessError.js] "use strict"; +exports.__esModule = true; var a; (function (a) { var weekend; diff --git a/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithExport.js b/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithExport.js index 8e11f60dcc7..ad07b9bd33f 100644 --- a/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithExport.js +++ b/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithExport.js @@ -14,6 +14,7 @@ export var bVal: b = b.Sunday; //// [internalAliasEnumInsideTopLevelModuleWithExport.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var a; (function (a) { var weekend; diff --git a/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithoutExport.js b/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithoutExport.js index 8ec0dcea815..6b5f5b17a26 100644 --- a/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithoutExport.js +++ b/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithoutExport.js @@ -14,6 +14,7 @@ export var bVal: b = b.Sunday; //// [internalAliasEnumInsideTopLevelModuleWithoutExport.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var a; (function (a) { var weekend; diff --git a/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithExport.js b/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithExport.js index b96586dfa8e..95bb936bc75 100644 --- a/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithExport.js +++ b/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithExport.js @@ -14,6 +14,7 @@ export module c { //// [internalAliasFunctionInsideLocalModuleWithExport.js] "use strict"; +exports.__esModule = true; var a; (function (a) { function foo(x) { diff --git a/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithoutExport.js b/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithoutExport.js index dca42878157..50de6b470ee 100644 --- a/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithoutExport.js +++ b/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithoutExport.js @@ -14,6 +14,7 @@ export module c { //// [internalAliasFunctionInsideLocalModuleWithoutExport.js] "use strict"; +exports.__esModule = true; var a; (function (a) { function foo(x) { diff --git a/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithoutExportAccessError.js b/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithoutExportAccessError.js index 62e5f622ae7..543e9952f23 100644 --- a/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithoutExportAccessError.js +++ b/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithoutExportAccessError.js @@ -14,6 +14,7 @@ var d = c.b(11); //// [internalAliasFunctionInsideLocalModuleWithoutExportAccessError.js] "use strict"; +exports.__esModule = true; var a; (function (a) { function foo(x) { diff --git a/tests/baselines/reference/internalAliasFunctionInsideTopLevelModuleWithExport.js b/tests/baselines/reference/internalAliasFunctionInsideTopLevelModuleWithExport.js index be096720e5e..267045b625d 100644 --- a/tests/baselines/reference/internalAliasFunctionInsideTopLevelModuleWithExport.js +++ b/tests/baselines/reference/internalAliasFunctionInsideTopLevelModuleWithExport.js @@ -13,6 +13,7 @@ export var bVal2 = b; //// [internalAliasFunctionInsideTopLevelModuleWithExport.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var a; (function (a) { function foo(x) { diff --git a/tests/baselines/reference/internalAliasFunctionInsideTopLevelModuleWithoutExport.js b/tests/baselines/reference/internalAliasFunctionInsideTopLevelModuleWithoutExport.js index ec702b7e021..bb3b0e244d2 100644 --- a/tests/baselines/reference/internalAliasFunctionInsideTopLevelModuleWithoutExport.js +++ b/tests/baselines/reference/internalAliasFunctionInsideTopLevelModuleWithoutExport.js @@ -12,6 +12,7 @@ export var bVal2 = b; //// [internalAliasFunctionInsideTopLevelModuleWithoutExport.js] "use strict"; +exports.__esModule = true; var a; (function (a) { function foo(x) { diff --git a/tests/baselines/reference/internalAliasInitializedModuleInsideLocalModuleWithExport.js b/tests/baselines/reference/internalAliasInitializedModuleInsideLocalModuleWithExport.js index 3bd4c7c2fbc..85335a0fb7f 100644 --- a/tests/baselines/reference/internalAliasInitializedModuleInsideLocalModuleWithExport.js +++ b/tests/baselines/reference/internalAliasInitializedModuleInsideLocalModuleWithExport.js @@ -14,6 +14,7 @@ export module c { //// [internalAliasInitializedModuleInsideLocalModuleWithExport.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var a; (function (a) { var b; diff --git a/tests/baselines/reference/internalAliasInitializedModuleInsideLocalModuleWithoutExport.js b/tests/baselines/reference/internalAliasInitializedModuleInsideLocalModuleWithoutExport.js index 910319be5e8..c39e6cfd168 100644 --- a/tests/baselines/reference/internalAliasInitializedModuleInsideLocalModuleWithoutExport.js +++ b/tests/baselines/reference/internalAliasInitializedModuleInsideLocalModuleWithoutExport.js @@ -13,6 +13,7 @@ export module c { //// [internalAliasInitializedModuleInsideLocalModuleWithoutExport.js] "use strict"; +exports.__esModule = true; var a; (function (a) { var b; diff --git a/tests/baselines/reference/internalAliasInitializedModuleInsideLocalModuleWithoutExportAccessError.js b/tests/baselines/reference/internalAliasInitializedModuleInsideLocalModuleWithoutExportAccessError.js index 02181f04f8d..6e66118f5b9 100644 --- a/tests/baselines/reference/internalAliasInitializedModuleInsideLocalModuleWithoutExportAccessError.js +++ b/tests/baselines/reference/internalAliasInitializedModuleInsideLocalModuleWithoutExportAccessError.js @@ -15,6 +15,7 @@ export var d = new c.b.c(); //// [internalAliasInitializedModuleInsideLocalModuleWithoutExportAccessError.js] "use strict"; +exports.__esModule = true; var a; (function (a) { var b; diff --git a/tests/baselines/reference/internalAliasInitializedModuleInsideTopLevelModuleWithExport.js b/tests/baselines/reference/internalAliasInitializedModuleInsideTopLevelModuleWithExport.js index 26915043496..86d9f88cee3 100644 --- a/tests/baselines/reference/internalAliasInitializedModuleInsideTopLevelModuleWithExport.js +++ b/tests/baselines/reference/internalAliasInitializedModuleInsideTopLevelModuleWithExport.js @@ -11,6 +11,7 @@ export var x: b.c = new b.c(); //// [internalAliasInitializedModuleInsideTopLevelModuleWithExport.js] "use strict"; +exports.__esModule = true; var a; (function (a) { var b; diff --git a/tests/baselines/reference/internalAliasInitializedModuleInsideTopLevelModuleWithoutExport.js b/tests/baselines/reference/internalAliasInitializedModuleInsideTopLevelModuleWithoutExport.js index a8a1d9ee047..79185fed228 100644 --- a/tests/baselines/reference/internalAliasInitializedModuleInsideTopLevelModuleWithoutExport.js +++ b/tests/baselines/reference/internalAliasInitializedModuleInsideTopLevelModuleWithoutExport.js @@ -12,6 +12,7 @@ export var x: b.c = new b.c(); //// [internalAliasInitializedModuleInsideTopLevelModuleWithoutExport.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var a; (function (a) { var b; diff --git a/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithExport.js b/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithExport.js index 044b393b367..bd50cd8bbc2 100644 --- a/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithExport.js +++ b/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithExport.js @@ -13,6 +13,7 @@ export module c { //// [internalAliasInterfaceInsideLocalModuleWithExport.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var c; (function (c) { })(c = exports.c || (exports.c = {})); diff --git a/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExport.js b/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExport.js index 78bfc72a789..f7b08e6c170 100644 --- a/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExport.js +++ b/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExport.js @@ -13,6 +13,7 @@ export module c { //// [internalAliasInterfaceInsideLocalModuleWithoutExport.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var c; (function (c) { })(c = exports.c || (exports.c = {})); diff --git a/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.js b/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.js index d0c4543c194..19163ff1f66 100644 --- a/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.js +++ b/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.js @@ -14,6 +14,7 @@ var x: c.b; //// [internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var c; (function (c) { })(c = exports.c || (exports.c = {})); diff --git a/tests/baselines/reference/internalAliasInterfaceInsideTopLevelModuleWithExport.js b/tests/baselines/reference/internalAliasInterfaceInsideTopLevelModuleWithExport.js index 1d6cb8c07e9..4434670366c 100644 --- a/tests/baselines/reference/internalAliasInterfaceInsideTopLevelModuleWithExport.js +++ b/tests/baselines/reference/internalAliasInterfaceInsideTopLevelModuleWithExport.js @@ -10,6 +10,7 @@ export var x: b; //// [internalAliasInterfaceInsideTopLevelModuleWithExport.js] "use strict"; +exports.__esModule = true; //// [internalAliasInterfaceInsideTopLevelModuleWithExport.d.ts] diff --git a/tests/baselines/reference/internalAliasInterfaceInsideTopLevelModuleWithoutExport.js b/tests/baselines/reference/internalAliasInterfaceInsideTopLevelModuleWithoutExport.js index fb666a9cad2..5645c76ed2a 100644 --- a/tests/baselines/reference/internalAliasInterfaceInsideTopLevelModuleWithoutExport.js +++ b/tests/baselines/reference/internalAliasInterfaceInsideTopLevelModuleWithoutExport.js @@ -11,6 +11,7 @@ export var x: b; //// [internalAliasInterfaceInsideTopLevelModuleWithoutExport.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithExport.js b/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithExport.js index 38e0c387286..7ca966e90b2 100644 --- a/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithExport.js +++ b/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithExport.js @@ -15,6 +15,7 @@ export module c { //// [internalAliasUninitializedModuleInsideLocalModuleWithExport.js] "use strict"; +exports.__esModule = true; var c; (function (c) { c.x.foo(); diff --git a/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExport.js b/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExport.js index 4912293d48c..22793f8aef5 100644 --- a/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExport.js +++ b/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExport.js @@ -15,6 +15,7 @@ export module c { //// [internalAliasUninitializedModuleInsideLocalModuleWithoutExport.js] "use strict"; +exports.__esModule = true; var c; (function (c) { c.x.foo(); diff --git a/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.js b/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.js index 1015e2a1d63..a6b4f83de8e 100644 --- a/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.js +++ b/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.js @@ -19,6 +19,7 @@ export var z: c.b.I; //// [internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var c; (function (c) { c.x.foo(); diff --git a/tests/baselines/reference/internalAliasUninitializedModuleInsideTopLevelModuleWithExport.js b/tests/baselines/reference/internalAliasUninitializedModuleInsideTopLevelModuleWithExport.js index dac3821a30d..eccbd9a45bd 100644 --- a/tests/baselines/reference/internalAliasUninitializedModuleInsideTopLevelModuleWithExport.js +++ b/tests/baselines/reference/internalAliasUninitializedModuleInsideTopLevelModuleWithExport.js @@ -15,6 +15,7 @@ x.foo(); //// [internalAliasUninitializedModuleInsideTopLevelModuleWithExport.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.x.foo(); }); diff --git a/tests/baselines/reference/internalAliasUninitializedModuleInsideTopLevelModuleWithoutExport.js b/tests/baselines/reference/internalAliasUninitializedModuleInsideTopLevelModuleWithoutExport.js index dc1029c6664..27de6bbfd98 100644 --- a/tests/baselines/reference/internalAliasUninitializedModuleInsideTopLevelModuleWithoutExport.js +++ b/tests/baselines/reference/internalAliasUninitializedModuleInsideTopLevelModuleWithoutExport.js @@ -14,6 +14,7 @@ x.foo(); //// [internalAliasUninitializedModuleInsideTopLevelModuleWithoutExport.js] "use strict"; +exports.__esModule = true; exports.x.foo(); diff --git a/tests/baselines/reference/internalAliasVarInsideLocalModuleWithExport.js b/tests/baselines/reference/internalAliasVarInsideLocalModuleWithExport.js index a2921311e53..34f044721c4 100644 --- a/tests/baselines/reference/internalAliasVarInsideLocalModuleWithExport.js +++ b/tests/baselines/reference/internalAliasVarInsideLocalModuleWithExport.js @@ -12,6 +12,7 @@ export module c { //// [internalAliasVarInsideLocalModuleWithExport.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var a; (function (a) { a.x = 10; diff --git a/tests/baselines/reference/internalAliasVarInsideLocalModuleWithoutExport.js b/tests/baselines/reference/internalAliasVarInsideLocalModuleWithoutExport.js index 8718dc18fdd..161dc0bf973 100644 --- a/tests/baselines/reference/internalAliasVarInsideLocalModuleWithoutExport.js +++ b/tests/baselines/reference/internalAliasVarInsideLocalModuleWithoutExport.js @@ -12,6 +12,7 @@ export module c { //// [internalAliasVarInsideLocalModuleWithoutExport.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var a; (function (a) { a.x = 10; diff --git a/tests/baselines/reference/internalAliasVarInsideLocalModuleWithoutExportAccessError.js b/tests/baselines/reference/internalAliasVarInsideLocalModuleWithoutExportAccessError.js index aa61fc77216..a0192fc9daa 100644 --- a/tests/baselines/reference/internalAliasVarInsideLocalModuleWithoutExportAccessError.js +++ b/tests/baselines/reference/internalAliasVarInsideLocalModuleWithoutExportAccessError.js @@ -12,6 +12,7 @@ export var z = c.b; //// [internalAliasVarInsideLocalModuleWithoutExportAccessError.js] "use strict"; +exports.__esModule = true; var a; (function (a) { a.x = 10; diff --git a/tests/baselines/reference/internalAliasVarInsideTopLevelModuleWithExport.js b/tests/baselines/reference/internalAliasVarInsideTopLevelModuleWithExport.js index 5427dbf026f..d27b4e3188d 100644 --- a/tests/baselines/reference/internalAliasVarInsideTopLevelModuleWithExport.js +++ b/tests/baselines/reference/internalAliasVarInsideTopLevelModuleWithExport.js @@ -11,6 +11,7 @@ export var bVal = b; //// [internalAliasVarInsideTopLevelModuleWithExport.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var a; (function (a) { a.x = 10; diff --git a/tests/baselines/reference/internalAliasVarInsideTopLevelModuleWithoutExport.js b/tests/baselines/reference/internalAliasVarInsideTopLevelModuleWithoutExport.js index 7c7c2cd327e..65c9204ed3c 100644 --- a/tests/baselines/reference/internalAliasVarInsideTopLevelModuleWithoutExport.js +++ b/tests/baselines/reference/internalAliasVarInsideTopLevelModuleWithoutExport.js @@ -10,6 +10,7 @@ export var bVal = b; //// [internalAliasVarInsideTopLevelModuleWithoutExport.js] "use strict"; +exports.__esModule = true; var a; (function (a) { a.x = 10; diff --git a/tests/baselines/reference/intersectionThisTypes.js b/tests/baselines/reference/intersectionThisTypes.js new file mode 100644 index 00000000000..9c7be09eeb8 --- /dev/null +++ b/tests/baselines/reference/intersectionThisTypes.js @@ -0,0 +1,57 @@ +//// [intersectionThisTypes.ts] +interface Thing1 { + a: number; + self(): this; +} + +interface Thing2 { + b: number; + me(): this; +} + +type Thing3 = Thing1 & Thing2; +type Thing4 = Thing3 & string[]; + +function f1(t: Thing3) { + t = t.self(); + t = t.me().self().me(); +} + +interface Thing5 extends Thing4 { + c: string; +} + +function f2(t: Thing5) { + t = t.self(); + t = t.me().self().me(); +} + +interface Component { + extend(props: T): this & T; +} + +interface Label extends Component { + title: string; +} + +function test(label: Label) { + const extended = label.extend({ id: 67 }).extend({ tag: "hello" }); + extended.id; // Ok + extended.tag; // Ok +} + + +//// [intersectionThisTypes.js] +function f1(t) { + t = t.self(); + t = t.me().self().me(); +} +function f2(t) { + t = t.self(); + t = t.me().self().me(); +} +function test(label) { + var extended = label.extend({ id: 67 }).extend({ tag: "hello" }); + extended.id; // Ok + extended.tag; // Ok +} diff --git a/tests/baselines/reference/intersectionThisTypes.symbols b/tests/baselines/reference/intersectionThisTypes.symbols new file mode 100644 index 00000000000..8a8a6cd5496 --- /dev/null +++ b/tests/baselines/reference/intersectionThisTypes.symbols @@ -0,0 +1,127 @@ +=== tests/cases/conformance/types/intersection/intersectionThisTypes.ts === +interface Thing1 { +>Thing1 : Symbol(Thing1, Decl(intersectionThisTypes.ts, 0, 0)) + + a: number; +>a : Symbol(Thing1.a, Decl(intersectionThisTypes.ts, 0, 18)) + + self(): this; +>self : Symbol(Thing1.self, Decl(intersectionThisTypes.ts, 1, 14)) +} + +interface Thing2 { +>Thing2 : Symbol(Thing2, Decl(intersectionThisTypes.ts, 3, 1)) + + b: number; +>b : Symbol(Thing2.b, Decl(intersectionThisTypes.ts, 5, 18)) + + me(): this; +>me : Symbol(Thing2.me, Decl(intersectionThisTypes.ts, 6, 14)) +} + +type Thing3 = Thing1 & Thing2; +>Thing3 : Symbol(Thing3, Decl(intersectionThisTypes.ts, 8, 1)) +>Thing1 : Symbol(Thing1, Decl(intersectionThisTypes.ts, 0, 0)) +>Thing2 : Symbol(Thing2, Decl(intersectionThisTypes.ts, 3, 1)) + +type Thing4 = Thing3 & string[]; +>Thing4 : Symbol(Thing4, Decl(intersectionThisTypes.ts, 10, 30)) +>Thing3 : Symbol(Thing3, Decl(intersectionThisTypes.ts, 8, 1)) + +function f1(t: Thing3) { +>f1 : Symbol(f1, Decl(intersectionThisTypes.ts, 11, 32)) +>t : Symbol(t, Decl(intersectionThisTypes.ts, 13, 12)) +>Thing3 : Symbol(Thing3, Decl(intersectionThisTypes.ts, 8, 1)) + + t = t.self(); +>t : Symbol(t, Decl(intersectionThisTypes.ts, 13, 12)) +>t.self : Symbol(Thing1.self, Decl(intersectionThisTypes.ts, 1, 14)) +>t : Symbol(t, Decl(intersectionThisTypes.ts, 13, 12)) +>self : Symbol(Thing1.self, Decl(intersectionThisTypes.ts, 1, 14)) + + t = t.me().self().me(); +>t : Symbol(t, Decl(intersectionThisTypes.ts, 13, 12)) +>t.me().self().me : Symbol(Thing2.me, Decl(intersectionThisTypes.ts, 6, 14)) +>t.me().self : Symbol(Thing1.self, Decl(intersectionThisTypes.ts, 1, 14)) +>t.me : Symbol(Thing2.me, Decl(intersectionThisTypes.ts, 6, 14)) +>t : Symbol(t, Decl(intersectionThisTypes.ts, 13, 12)) +>me : Symbol(Thing2.me, Decl(intersectionThisTypes.ts, 6, 14)) +>self : Symbol(Thing1.self, Decl(intersectionThisTypes.ts, 1, 14)) +>me : Symbol(Thing2.me, Decl(intersectionThisTypes.ts, 6, 14)) +} + +interface Thing5 extends Thing4 { +>Thing5 : Symbol(Thing5, Decl(intersectionThisTypes.ts, 16, 1)) +>Thing4 : Symbol(Thing4, Decl(intersectionThisTypes.ts, 10, 30)) + + c: string; +>c : Symbol(Thing5.c, Decl(intersectionThisTypes.ts, 18, 33)) +} + +function f2(t: Thing5) { +>f2 : Symbol(f2, Decl(intersectionThisTypes.ts, 20, 1)) +>t : Symbol(t, Decl(intersectionThisTypes.ts, 22, 12)) +>Thing5 : Symbol(Thing5, Decl(intersectionThisTypes.ts, 16, 1)) + + t = t.self(); +>t : Symbol(t, Decl(intersectionThisTypes.ts, 22, 12)) +>t.self : Symbol(Thing1.self, Decl(intersectionThisTypes.ts, 1, 14)) +>t : Symbol(t, Decl(intersectionThisTypes.ts, 22, 12)) +>self : Symbol(Thing1.self, Decl(intersectionThisTypes.ts, 1, 14)) + + t = t.me().self().me(); +>t : Symbol(t, Decl(intersectionThisTypes.ts, 22, 12)) +>t.me().self().me : Symbol(Thing2.me, Decl(intersectionThisTypes.ts, 6, 14)) +>t.me().self : Symbol(Thing1.self, Decl(intersectionThisTypes.ts, 1, 14)) +>t.me : Symbol(Thing2.me, Decl(intersectionThisTypes.ts, 6, 14)) +>t : Symbol(t, Decl(intersectionThisTypes.ts, 22, 12)) +>me : Symbol(Thing2.me, Decl(intersectionThisTypes.ts, 6, 14)) +>self : Symbol(Thing1.self, Decl(intersectionThisTypes.ts, 1, 14)) +>me : Symbol(Thing2.me, Decl(intersectionThisTypes.ts, 6, 14)) +} + +interface Component { +>Component : Symbol(Component, Decl(intersectionThisTypes.ts, 25, 1)) + + extend(props: T): this & T; +>extend : Symbol(Component.extend, Decl(intersectionThisTypes.ts, 27, 21)) +>T : Symbol(T, Decl(intersectionThisTypes.ts, 28, 11)) +>props : Symbol(props, Decl(intersectionThisTypes.ts, 28, 14)) +>T : Symbol(T, Decl(intersectionThisTypes.ts, 28, 11)) +>T : Symbol(T, Decl(intersectionThisTypes.ts, 28, 11)) +} + +interface Label extends Component { +>Label : Symbol(Label, Decl(intersectionThisTypes.ts, 29, 1)) +>Component : Symbol(Component, Decl(intersectionThisTypes.ts, 25, 1)) + + title: string; +>title : Symbol(Label.title, Decl(intersectionThisTypes.ts, 31, 35)) +} + +function test(label: Label) { +>test : Symbol(test, Decl(intersectionThisTypes.ts, 33, 1)) +>label : Symbol(label, Decl(intersectionThisTypes.ts, 35, 14)) +>Label : Symbol(Label, Decl(intersectionThisTypes.ts, 29, 1)) + + const extended = label.extend({ id: 67 }).extend({ tag: "hello" }); +>extended : Symbol(extended, Decl(intersectionThisTypes.ts, 36, 9)) +>label.extend({ id: 67 }).extend : Symbol(Component.extend, Decl(intersectionThisTypes.ts, 27, 21)) +>label.extend : Symbol(Component.extend, Decl(intersectionThisTypes.ts, 27, 21)) +>label : Symbol(label, Decl(intersectionThisTypes.ts, 35, 14)) +>extend : Symbol(Component.extend, Decl(intersectionThisTypes.ts, 27, 21)) +>id : Symbol(id, Decl(intersectionThisTypes.ts, 36, 35)) +>extend : Symbol(Component.extend, Decl(intersectionThisTypes.ts, 27, 21)) +>tag : Symbol(tag, Decl(intersectionThisTypes.ts, 36, 54)) + + extended.id; // Ok +>extended.id : Symbol(id, Decl(intersectionThisTypes.ts, 36, 35)) +>extended : Symbol(extended, Decl(intersectionThisTypes.ts, 36, 9)) +>id : Symbol(id, Decl(intersectionThisTypes.ts, 36, 35)) + + extended.tag; // Ok +>extended.tag : Symbol(tag, Decl(intersectionThisTypes.ts, 36, 54)) +>extended : Symbol(extended, Decl(intersectionThisTypes.ts, 36, 9)) +>tag : Symbol(tag, Decl(intersectionThisTypes.ts, 36, 54)) +} + diff --git a/tests/baselines/reference/intersectionThisTypes.types b/tests/baselines/reference/intersectionThisTypes.types new file mode 100644 index 00000000000..285609cdfdc --- /dev/null +++ b/tests/baselines/reference/intersectionThisTypes.types @@ -0,0 +1,145 @@ +=== tests/cases/conformance/types/intersection/intersectionThisTypes.ts === +interface Thing1 { +>Thing1 : Thing1 + + a: number; +>a : number + + self(): this; +>self : () => this +} + +interface Thing2 { +>Thing2 : Thing2 + + b: number; +>b : number + + me(): this; +>me : () => this +} + +type Thing3 = Thing1 & Thing2; +>Thing3 : Thing3 +>Thing1 : Thing1 +>Thing2 : Thing2 + +type Thing4 = Thing3 & string[]; +>Thing4 : Thing4 +>Thing3 : Thing3 + +function f1(t: Thing3) { +>f1 : (t: Thing3) => void +>t : Thing3 +>Thing3 : Thing3 + + t = t.self(); +>t = t.self() : Thing3 +>t : Thing3 +>t.self() : Thing3 +>t.self : () => Thing3 +>t : Thing3 +>self : () => Thing3 + + t = t.me().self().me(); +>t = t.me().self().me() : Thing3 +>t : Thing3 +>t.me().self().me() : Thing3 +>t.me().self().me : () => Thing3 +>t.me().self() : Thing3 +>t.me().self : () => Thing3 +>t.me() : Thing3 +>t.me : () => Thing3 +>t : Thing3 +>me : () => Thing3 +>self : () => Thing3 +>me : () => Thing3 +} + +interface Thing5 extends Thing4 { +>Thing5 : Thing5 +>Thing4 : Thing4 + + c: string; +>c : string +} + +function f2(t: Thing5) { +>f2 : (t: Thing5) => void +>t : Thing5 +>Thing5 : Thing5 + + t = t.self(); +>t = t.self() : Thing5 +>t : Thing5 +>t.self() : Thing5 +>t.self : () => Thing5 +>t : Thing5 +>self : () => Thing5 + + t = t.me().self().me(); +>t = t.me().self().me() : Thing5 +>t : Thing5 +>t.me().self().me() : Thing5 +>t.me().self().me : () => Thing5 +>t.me().self() : Thing5 +>t.me().self : () => Thing5 +>t.me() : Thing5 +>t.me : () => Thing5 +>t : Thing5 +>me : () => Thing5 +>self : () => Thing5 +>me : () => Thing5 +} + +interface Component { +>Component : Component + + extend(props: T): this & T; +>extend : (props: T) => this & T +>T : T +>props : T +>T : T +>T : T +} + +interface Label extends Component { +>Label : Label +>Component : Component + + title: string; +>title : string +} + +function test(label: Label) { +>test : (label: Label) => void +>label : Label +>Label : Label + + const extended = label.extend({ id: 67 }).extend({ tag: "hello" }); +>extended : Label & { id: number; } & { tag: string; } +>label.extend({ id: 67 }).extend({ tag: "hello" }) : Label & { id: number; } & { tag: string; } +>label.extend({ id: 67 }).extend : (props: T) => Label & { id: number; } & T +>label.extend({ id: 67 }) : Label & { id: number; } +>label.extend : (props: T) => Label & T +>label : Label +>extend : (props: T) => Label & T +>{ id: 67 } : { id: number; } +>id : number +>67 : 67 +>extend : (props: T) => Label & { id: number; } & T +>{ tag: "hello" } : { tag: string; } +>tag : string +>"hello" : "hello" + + extended.id; // Ok +>extended.id : number +>extended : Label & { id: number; } & { tag: string; } +>id : number + + extended.tag; // Ok +>extended.tag : string +>extended : Label & { id: number; } & { tag: string; } +>tag : string +} + diff --git a/tests/baselines/reference/intersectionTypeInference1.js b/tests/baselines/reference/intersectionTypeInference1.js index f4ad4da608b..32ddedae2b3 100644 --- a/tests/baselines/reference/intersectionTypeInference1.js +++ b/tests/baselines/reference/intersectionTypeInference1.js @@ -11,6 +11,7 @@ export const Form3 = brokenFunction(parameterFn)({store: "hello"}) //// [intersectionTypeInference1.js] // Repro from #8801 "use strict"; +exports.__esModule = true; function alert(s) { } var parameterFn = function (props) { return alert(props.store); }; var brokenFunction = function (f) { return function (o) { return o; }; }; diff --git a/tests/baselines/reference/intersectionTypeNormalization.types b/tests/baselines/reference/intersectionTypeNormalization.types index 3ffe7484afe..7d8ba117eec 100644 --- a/tests/baselines/reference/intersectionTypeNormalization.types +++ b/tests/baselines/reference/intersectionTypeNormalization.types @@ -227,9 +227,9 @@ function getValueAsString(value: IntersectionFail): string { if (value.kind === 'int') { >value.kind === 'int' : boolean ->value.kind : "int" | "string" +>value.kind : "string" | "int" >value : IntersectionFail ->kind : "int" | "string" +>kind : "string" | "int" >'int' : "int" return '' + value.num; diff --git a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js index 6e9b09c906f..2ca72edf3c1 100644 --- a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js +++ b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js @@ -80,11 +80,16 @@ module YYY4 { //// [invalidModuleWithStatementsOfEveryKind.js] // All of these should be an error -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Y; (function (Y) { var A = (function () { @@ -95,7 +100,7 @@ var Y; var BB = (function (_super) { __extends(BB, _super); function BB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return BB; }(A)); @@ -110,7 +115,7 @@ var Y2; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(AA)); @@ -144,7 +149,7 @@ var YY; var BB = (function (_super) { __extends(BB, _super); function BB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return BB; }(A)); @@ -159,7 +164,7 @@ var YY2; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(AA)); @@ -193,7 +198,7 @@ var YYY; var BB = (function (_super) { __extends(BB, _super); function BB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return BB; }(A)); @@ -208,7 +213,7 @@ var YYY2; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(AA)); diff --git a/tests/baselines/reference/invalidMultipleVariableDeclarations.js b/tests/baselines/reference/invalidMultipleVariableDeclarations.js index 340429cc398..7e1616cfca4 100644 --- a/tests/baselines/reference/invalidMultipleVariableDeclarations.js +++ b/tests/baselines/reference/invalidMultipleVariableDeclarations.js @@ -54,11 +54,16 @@ var m: typeof M; var m = M.A; //// [invalidMultipleVariableDeclarations.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -67,7 +72,7 @@ var C = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(C)); diff --git a/tests/baselines/reference/invalidReturnStatements.errors.txt b/tests/baselines/reference/invalidReturnStatements.errors.txt index 6fbe961cd54..0f51e75a47d 100644 --- a/tests/baselines/reference/invalidReturnStatements.errors.txt +++ b/tests/baselines/reference/invalidReturnStatements.errors.txt @@ -2,9 +2,9 @@ tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(2 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'. +tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(16,22): 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'. +tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(18,22): error TS2322: Type 'C' is not assignable to type 'D'. Property 'name' is missing in type 'C'. @@ -33,12 +33,12 @@ tests/cases/conformance/statements/returnStatements/invalidReturnStatements.ts(1 name: string; } function fn10(): D { return { id: 12 }; } - ~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ id: number; }' is not assignable to type 'D'. !!! error TS2322: Property 'name' is missing in type '{ id: number; }'. function fn11(): D { return new C(); } - ~~~~~~~ + ~~~~~~~~~~~~~~~ !!! error TS2322: Type 'C' is not assignable to type 'D'. !!! error TS2322: Property 'name' is missing in type 'C'. diff --git a/tests/baselines/reference/invalidReturnStatements.js b/tests/baselines/reference/invalidReturnStatements.js index a6b07b7d7bd..af20c18c853 100644 --- a/tests/baselines/reference/invalidReturnStatements.js +++ b/tests/baselines/reference/invalidReturnStatements.js @@ -21,11 +21,16 @@ function fn11(): D { return new C(); } //// [invalidReturnStatements.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // all the following should be error function fn1() { } function fn2() { } @@ -41,7 +46,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/isolatedModulesImportExportElision.js b/tests/baselines/reference/isolatedModulesImportExportElision.js index 6f1d38dcbb5..5aac4a64186 100644 --- a/tests/baselines/reference/isolatedModulesImportExportElision.js +++ b/tests/baselines/reference/isolatedModulesImportExportElision.js @@ -15,18 +15,24 @@ export var z = x; //// [file1.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); var module_1 = require("module"); var module_2 = require("module"); var ns = require("module"); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(module_2.c2.C)); diff --git a/tests/baselines/reference/isolatedModulesPlainFile-AMD.js b/tests/baselines/reference/isolatedModulesPlainFile-AMD.js index 1e45ee159d6..4ed1fdf2c77 100644 --- a/tests/baselines/reference/isolatedModulesPlainFile-AMD.js +++ b/tests/baselines/reference/isolatedModulesPlainFile-AMD.js @@ -7,5 +7,6 @@ run(1); //// [isolatedModulesPlainFile-AMD.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); run(1); }); diff --git a/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js b/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js index f40d2173685..38739a700ef 100644 --- a/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js +++ b/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js @@ -6,4 +6,5 @@ run(1); //// [isolatedModulesPlainFile-CommonJS.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); run(1); diff --git a/tests/baselines/reference/isolatedModulesPlainFile-UMD.js b/tests/baselines/reference/isolatedModulesPlainFile-UMD.js index ece949b9100..f37962a84ab 100644 --- a/tests/baselines/reference/isolatedModulesPlainFile-UMD.js +++ b/tests/baselines/reference/isolatedModulesPlainFile-UMD.js @@ -15,5 +15,6 @@ run(1); } })(function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); run(1); }); diff --git a/tests/baselines/reference/isolatedModulesSpecifiedModule.js b/tests/baselines/reference/isolatedModulesSpecifiedModule.js index 89547811855..895c47e2504 100644 --- a/tests/baselines/reference/isolatedModulesSpecifiedModule.js +++ b/tests/baselines/reference/isolatedModulesSpecifiedModule.js @@ -3,3 +3,4 @@ export var x; //// [file1.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/isolatedModulesUnspecifiedModule.js b/tests/baselines/reference/isolatedModulesUnspecifiedModule.js index 89547811855..895c47e2504 100644 --- a/tests/baselines/reference/isolatedModulesUnspecifiedModule.js +++ b/tests/baselines/reference/isolatedModulesUnspecifiedModule.js @@ -3,3 +3,4 @@ export var x; //// [file1.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/jsFileClassPropertyType.errors.txt b/tests/baselines/reference/jsFileClassPropertyType.errors.txt new file mode 100644 index 00000000000..f3767175710 --- /dev/null +++ b/tests/baselines/reference/jsFileClassPropertyType.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/bar.ts(2,1): error TS2322: Type '"string"' is not assignable to type 'number'. + + +==== tests/cases/compiler/foo.js (0 errors) ==== + + class C { + constructor () { + this.p = 0; + } + } + +==== tests/cases/compiler/bar.ts (1 errors) ==== + + (new C()).p = "string"; + ~~~~~~~~~~~ +!!! error TS2322: Type '"string"' is not assignable to type 'number'. + \ No newline at end of file diff --git a/tests/baselines/reference/jsFileClassPropertyType2.errors.txt b/tests/baselines/reference/jsFileClassPropertyType2.errors.txt new file mode 100644 index 00000000000..d0d138f7f48 --- /dev/null +++ b/tests/baselines/reference/jsFileClassPropertyType2.errors.txt @@ -0,0 +1,18 @@ +tests/cases/compiler/bar.ts(2,18): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'. + + +==== tests/cases/compiler/foo.js (0 errors) ==== + + class C { + constructor() { + /** @type {number[]}*/ + this.p = []; + } + } + +==== tests/cases/compiler/bar.ts (1 errors) ==== + + (new C()).p.push("string"); + ~~~~~~~~ +!!! error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'. + \ No newline at end of file diff --git a/tests/baselines/reference/jsFileClassPropertyType3.errors.txt b/tests/baselines/reference/jsFileClassPropertyType3.errors.txt new file mode 100644 index 00000000000..bf225095b01 --- /dev/null +++ b/tests/baselines/reference/jsFileClassPropertyType3.errors.txt @@ -0,0 +1,22 @@ +tests/cases/compiler/bar.ts(2,1): error TS2322: Type '"string"' is not assignable to type 'number'. + + +==== tests/cases/compiler/foo.js (0 errors) ==== + + class C { + constructor() { + if (cond) { + this.p = null; + } + else { + this.p = 0; + } + } + } + +==== tests/cases/compiler/bar.ts (1 errors) ==== + + (new C()).p = "string"; // Error + ~~~~~~~~~~~ +!!! error TS2322: Type '"string"' is not assignable to type 'number'. + \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationLetBeingRenamed.js b/tests/baselines/reference/jsFileCompilationLetBeingRenamed.js index c9e16f35981..a87dad3c914 100644 --- a/tests/baselines/reference/jsFileCompilationLetBeingRenamed.js +++ b/tests/baselines/reference/jsFileCompilationLetBeingRenamed.js @@ -9,5 +9,6 @@ function foo(a) { //// [out.js] function foo(a) { for (var a_1 = 0; a_1 < 10; a_1++) { + // do something } } diff --git a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.js b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.js index e1675ff7131..088b40e97ad 100644 --- a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.js +++ b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.js @@ -26,6 +26,7 @@ export default apply; //// [apply.js] define("_apply", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; /** * A faster alternative to `Function#apply`, this function invokes `func` * with the `this` binding of `thisArg` and the arguments of `args`. @@ -46,6 +47,5 @@ define("_apply", ["require", "exports"], function (require, exports) { } return func.apply(thisArg, args); } - exports.__esModule = true; exports["default"] = apply; }); diff --git a/tests/baselines/reference/jsFileFunctionParametersAsOptional.symbols b/tests/baselines/reference/jsFileFunctionParametersAsOptional.symbols new file mode 100644 index 00000000000..040b910f378 --- /dev/null +++ b/tests/baselines/reference/jsFileFunctionParametersAsOptional.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/foo.js === + +function f(a, b, c) { } +>f : Symbol(f, Decl(foo.js, 0, 0)) +>a : Symbol(a, Decl(foo.js, 1, 11)) +>b : Symbol(b, Decl(foo.js, 1, 13)) +>c : Symbol(c, Decl(foo.js, 1, 16)) + + +=== tests/cases/compiler/bar.ts === +f(); +>f : Symbol(f, Decl(foo.js, 0, 0)) + +f(1); +>f : Symbol(f, Decl(foo.js, 0, 0)) + +f(1, 2); +>f : Symbol(f, Decl(foo.js, 0, 0)) + +f(1, 2, 3); +>f : Symbol(f, Decl(foo.js, 0, 0)) + diff --git a/tests/baselines/reference/jsFileFunctionParametersAsOptional.types b/tests/baselines/reference/jsFileFunctionParametersAsOptional.types new file mode 100644 index 00000000000..d6d8f9b04a4 --- /dev/null +++ b/tests/baselines/reference/jsFileFunctionParametersAsOptional.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/foo.js === + +function f(a, b, c) { } +>f : (a: any, b: any, c: any) => void +>a : any +>b : any +>c : any + + +=== tests/cases/compiler/bar.ts === +f(); +>f() : void +>f : (a: any, b: any, c: any) => void + +f(1); +>f(1) : void +>f : (a: any, b: any, c: any) => void +>1 : 1 + +f(1, 2); +>f(1, 2) : void +>f : (a: any, b: any, c: any) => void +>1 : 1 +>2 : 2 + +f(1, 2, 3); +>f(1, 2, 3) : void +>f : (a: any, b: any, c: any) => void +>1 : 1 +>2 : 2 +>3 : 3 + diff --git a/tests/baselines/reference/jsFileFunctionParametersAsOptional2.errors.txt b/tests/baselines/reference/jsFileFunctionParametersAsOptional2.errors.txt new file mode 100644 index 00000000000..26ada935eea --- /dev/null +++ b/tests/baselines/reference/jsFileFunctionParametersAsOptional2.errors.txt @@ -0,0 +1,28 @@ +tests/cases/compiler/bar.ts(1,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/bar.ts(2,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/bar.ts(3,1): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/compiler/foo.js (0 errors) ==== + + /** + * @param a + * @param b + * @param c + */ + function f(a, b, c) { } + + +==== tests/cases/compiler/bar.ts (3 errors) ==== + f(); // Error + ~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + f(1); // Error + ~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + f(1, 2); // Error + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + + f(1, 2, 3); // OK + \ No newline at end of file diff --git a/tests/baselines/reference/jsxAttributeWithoutExpressionReact.errors.txt b/tests/baselines/reference/jsxAttributeWithoutExpressionReact.errors.txt new file mode 100644 index 00000000000..3801562709a --- /dev/null +++ b/tests/baselines/reference/jsxAttributeWithoutExpressionReact.errors.txt @@ -0,0 +1,33 @@ +tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(3,2): error TS2304: Cannot find name 'View'. +tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(4,6): error TS2304: Cannot find name 'ListView'. +tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(5,10): error TS2304: Cannot find name 'RefreshControl'. +tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(5,35): error TS17000: JSX attributes must only be assigned a non-empty 'expression'. +tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(6,44): error TS17000: JSX attributes must only be assigned a non-empty 'expression'. +tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(7,7): error TS2304: Cannot find name 'ListView'. +tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx(8,3): error TS2304: Cannot find name 'View'. + + +==== tests/cases/compiler/jsxAttributeWithoutExpressionReact.tsx (7 errors) ==== + + declare var React: any; + + ~~~~ +!!! error TS2304: Cannot find name 'View'. + + ~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'RefreshControl'. + ~~ +!!! error TS17000: JSX attributes must only be assigned a non-empty 'expression'. + } dataSource={this.state.ds} renderRow={}> + ~~ +!!! error TS17000: JSX attributes must only be assigned a non-empty 'expression'. + + ~~~~~~~~ +!!! error TS2304: Cannot find name 'ListView'. + + ~~~~ +!!! error TS2304: Cannot find name 'View'. + \ No newline at end of file diff --git a/tests/baselines/reference/jsxAttributeWithoutExpressionReact.js b/tests/baselines/reference/jsxAttributeWithoutExpressionReact.js new file mode 100644 index 00000000000..f07cbabd7f8 --- /dev/null +++ b/tests/baselines/reference/jsxAttributeWithoutExpressionReact.js @@ -0,0 +1,14 @@ +//// [jsxAttributeWithoutExpressionReact.tsx] + +declare var React: any; + + + } dataSource={this.state.ds} renderRow={}> + + + + +//// [jsxAttributeWithoutExpressionReact.js] +React.createElement(View, null, + React.createElement(ListView, { refreshControl: React.createElement(RefreshControl, { onRefresh: true, refreshing: true }), dataSource: this.state.ds, renderRow: true })); diff --git a/tests/baselines/reference/jsxEmitAttributeWithPreserve.symbols b/tests/baselines/reference/jsxEmitAttributeWithPreserve.symbols index 82eceb8e637..a5f910776b0 100644 --- a/tests/baselines/reference/jsxEmitAttributeWithPreserve.symbols +++ b/tests/baselines/reference/jsxEmitAttributeWithPreserve.symbols @@ -5,5 +5,5 @@ declare var React: any; >foo : Symbol(unknown) ->data : Symbol(unknown) +>data : Symbol(data, Decl(jsxEmitAttributeWithPreserve.tsx, 2, 4)) diff --git a/tests/baselines/reference/jsxEmitAttributeWithPreserve.types b/tests/baselines/reference/jsxEmitAttributeWithPreserve.types index 972ca1c3d88..7d218f422bf 100644 --- a/tests/baselines/reference/jsxEmitAttributeWithPreserve.types +++ b/tests/baselines/reference/jsxEmitAttributeWithPreserve.types @@ -6,5 +6,5 @@ declare var React: any; > : any >foo : any ->data : any +>data : true diff --git a/tests/baselines/reference/jsxEmitWithAttributes.js b/tests/baselines/reference/jsxEmitWithAttributes.js index 1acead2801d..dd4d326268b 100644 --- a/tests/baselines/reference/jsxEmitWithAttributes.js +++ b/tests/baselines/reference/jsxEmitWithAttributes.js @@ -52,6 +52,7 @@ class A { //// [Element.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var Element; (function (Element) { function isElement(el) { @@ -69,6 +70,7 @@ function toCamelCase(text) { } //// [test.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); const Element_1 = require("./Element"); let c; class A { diff --git a/tests/baselines/reference/jsxEmitWithAttributes.symbols b/tests/baselines/reference/jsxEmitWithAttributes.symbols index 16cd35d1ca3..f2579903d3e 100644 --- a/tests/baselines/reference/jsxEmitWithAttributes.symbols +++ b/tests/baselines/reference/jsxEmitWithAttributes.symbols @@ -101,12 +101,12 @@ class A { return [ , >meta : Symbol(unknown) ->content : Symbol(unknown) +>content : Symbol(content, Decl(test.tsx, 11, 8)) >meta : Symbol(unknown) >meta : Symbol(unknown) ->content : Symbol(unknown) +>content : Symbol(content, Decl(test.tsx, 12, 8)) >c.a!.b : Symbol(b, Decl(test.tsx, 3, 6)) >c.a : Symbol(a, Decl(test.tsx, 2, 8)) >c : Symbol(c, Decl(test.tsx, 2, 3)) diff --git a/tests/baselines/reference/jsxEmitWithAttributes.types b/tests/baselines/reference/jsxEmitWithAttributes.types index 663ba4b5bfc..724aed319ec 100644 --- a/tests/baselines/reference/jsxEmitWithAttributes.types +++ b/tests/baselines/reference/jsxEmitWithAttributes.types @@ -114,13 +114,13 @@ class A { , > : any >meta : any ->content : any +>content : string >meta : any > : any >meta : any ->content : any +>content : string >c.a!.b : string >c.a! : { b: string; } >c.a : { b: string; } diff --git a/tests/baselines/reference/jsxFactoryAndReactNamespace.js b/tests/baselines/reference/jsxFactoryAndReactNamespace.js index 0a6402ca70c..a864da65dbb 100644 --- a/tests/baselines/reference/jsxFactoryAndReactNamespace.js +++ b/tests/baselines/reference/jsxFactoryAndReactNamespace.js @@ -52,6 +52,7 @@ class A { //// [Element.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var Element; (function (Element) { function isElement(el) { @@ -69,6 +70,7 @@ function toCamelCase(text) { } //// [test.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); const Element_1 = require("./Element"); let c; class A { diff --git a/tests/baselines/reference/jsxFactoryIdentifier.js b/tests/baselines/reference/jsxFactoryIdentifier.js index 82c8f6410e6..9beff01d707 100644 --- a/tests/baselines/reference/jsxFactoryIdentifier.js +++ b/tests/baselines/reference/jsxFactoryIdentifier.js @@ -52,6 +52,7 @@ class A { //// [Element.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var Element; (function (Element) { function isElement(el) { @@ -69,6 +70,7 @@ function toCamelCase(text) { } //# sourceMappingURL=Element.js.map//// [test.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); const Element_1 = require("./Element"); let createElement = Element_1.Element.createElement; let c; diff --git a/tests/baselines/reference/jsxFactoryIdentifier.js.map b/tests/baselines/reference/jsxFactoryIdentifier.js.map index cad196b8ba5..57ff760b8a8 100644 --- a/tests/baselines/reference/jsxFactoryIdentifier.js.map +++ b/tests/baselines/reference/jsxFactoryIdentifier.js.map @@ -1,3 +1,3 @@ //// [Element.js.map] -{"version":3,"file":"Element.js","sourceRoot":"","sources":["Element.ts"],"names":[],"mappings":";AAaA,IAAiB,OAAO,CAUvB;AAVD,WAAiB,OAAO;IACpB,mBAA0B,EAAO;QAC7B,MAAM,CAAC,EAAE,CAAC,wBAAwB,KAAK,SAAS,CAAC;IACrD,CAAC;IAFe,iBAAS,YAExB,CAAA;IAED,uBAA8B,IAAW;QAErC,MAAM,CAAC,EACN,CAAA;IACL,CAAC;IAJe,qBAAa,gBAI5B,CAAA;AACL,CAAC,EAVgB,OAAO,GAAP,eAAO,KAAP,eAAO,QAUvB;AAEU,QAAA,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;AAEjD,qBAAqB,IAAY;IAC7B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC"}//// [test.js.map] -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":";AAAA,uCAAmC;AACnC,IAAI,aAAa,GAAG,iBAAO,CAAC,aAAa,CAAC;AAC1C,IAAI,CAIH,CAAC;AAEF;IACC,IAAI;QACH,MAAM,CAAC;YACN,wBAAM,OAAO,EAAC,YAAY,GAAQ;YAClC,wBAAM,OAAO,EAAE,CAAC,CAAC,CAAE,CAAC,CAAC,GAAS;SAC9B,CAAC;IACH,CAAC;CACD"} \ No newline at end of file +{"version":3,"file":"Element.js","sourceRoot":"","sources":["Element.ts"],"names":[],"mappings":";;AAaA,IAAiB,OAAO,CAUvB;AAVD,WAAiB,OAAO;IACpB,mBAA0B,EAAO;QAC7B,MAAM,CAAC,EAAE,CAAC,wBAAwB,KAAK,SAAS,CAAC;IACrD,CAAC;IAFe,iBAAS,YAExB,CAAA;IAED,uBAA8B,IAAW;QAErC,MAAM,CAAC,EACN,CAAA;IACL,CAAC;IAJe,qBAAa,gBAI5B,CAAA;AACL,CAAC,EAVgB,OAAO,GAAP,eAAO,KAAP,eAAO,QAUvB;AAEU,QAAA,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;AAEjD,qBAAqB,IAAY;IAC7B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC"}//// [test.js.map] +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":";;AAAA,uCAAmC;AACnC,IAAI,aAAa,GAAG,iBAAO,CAAC,aAAa,CAAC;AAC1C,IAAI,CAIH,CAAC;AAEF;IACC,IAAI;QACH,MAAM,CAAC;YACN,wBAAM,OAAO,EAAC,YAAY,GAAQ;YAClC,wBAAM,OAAO,EAAE,CAAC,CAAC,CAAE,CAAC,CAAC,GAAS;SAC9B,CAAC;IACH,CAAC;CACD"} \ No newline at end of file diff --git a/tests/baselines/reference/jsxFactoryIdentifier.sourcemap.txt b/tests/baselines/reference/jsxFactoryIdentifier.sourcemap.txt index a4ddc8c050b..6101ee1d5e7 100644 --- a/tests/baselines/reference/jsxFactoryIdentifier.sourcemap.txt +++ b/tests/baselines/reference/jsxFactoryIdentifier.sourcemap.txt @@ -9,6 +9,7 @@ emittedFile:tests/cases/compiler/Element.js sourceFile:Element.ts ------------------------------------------------------------------- >>>"use strict"; +>>>Object.defineProperty(exports, "__esModule", { value: true }); >>>var Element; 1 > 2 >^^^^ @@ -42,10 +43,10 @@ sourceFile:Element.ts > } > } > } -1 >Emitted(2, 1) Source(14, 1) + SourceIndex(0) -2 >Emitted(2, 5) Source(14, 18) + SourceIndex(0) -3 >Emitted(2, 12) Source(14, 25) + SourceIndex(0) -4 >Emitted(2, 13) Source(24, 2) + SourceIndex(0) +1 >Emitted(3, 1) Source(14, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(14, 18) + SourceIndex(0) +3 >Emitted(3, 12) Source(14, 25) + SourceIndex(0) +4 >Emitted(3, 13) Source(24, 2) + SourceIndex(0) --- >>>(function (Element) { 1-> @@ -55,9 +56,9 @@ sourceFile:Element.ts 1-> 2 >export namespace 3 > Element -1->Emitted(3, 1) Source(14, 1) + SourceIndex(0) -2 >Emitted(3, 12) Source(14, 18) + SourceIndex(0) -3 >Emitted(3, 19) Source(14, 25) + SourceIndex(0) +1->Emitted(4, 1) Source(14, 1) + SourceIndex(0) +2 >Emitted(4, 12) Source(14, 18) + SourceIndex(0) +3 >Emitted(4, 19) Source(14, 25) + SourceIndex(0) --- >>> function isElement(el) { 1->^^^^ @@ -68,9 +69,9 @@ sourceFile:Element.ts > 2 > export function isElement( 3 > el: any -1->Emitted(4, 5) Source(15, 5) + SourceIndex(0) -2 >Emitted(4, 24) Source(15, 31) + SourceIndex(0) -3 >Emitted(4, 26) Source(15, 38) + SourceIndex(0) +1->Emitted(5, 5) Source(15, 5) + SourceIndex(0) +2 >Emitted(5, 24) Source(15, 31) + SourceIndex(0) +3 >Emitted(5, 26) Source(15, 38) + SourceIndex(0) --- >>> return el.markAsChildOfRootElement !== undefined; 1->^^^^^^^^ @@ -92,15 +93,15 @@ sourceFile:Element.ts 7 > !== 8 > undefined 9 > ; -1->Emitted(5, 9) Source(16, 9) + SourceIndex(0) -2 >Emitted(5, 15) Source(16, 15) + SourceIndex(0) -3 >Emitted(5, 16) Source(16, 16) + SourceIndex(0) -4 >Emitted(5, 18) Source(16, 18) + SourceIndex(0) -5 >Emitted(5, 19) Source(16, 19) + SourceIndex(0) -6 >Emitted(5, 43) Source(16, 43) + SourceIndex(0) -7 >Emitted(5, 48) Source(16, 48) + SourceIndex(0) -8 >Emitted(5, 57) Source(16, 57) + SourceIndex(0) -9 >Emitted(5, 58) Source(16, 58) + SourceIndex(0) +1->Emitted(6, 9) Source(16, 9) + SourceIndex(0) +2 >Emitted(6, 15) Source(16, 15) + SourceIndex(0) +3 >Emitted(6, 16) Source(16, 16) + SourceIndex(0) +4 >Emitted(6, 18) Source(16, 18) + SourceIndex(0) +5 >Emitted(6, 19) Source(16, 19) + SourceIndex(0) +6 >Emitted(6, 43) Source(16, 43) + SourceIndex(0) +7 >Emitted(6, 48) Source(16, 48) + SourceIndex(0) +8 >Emitted(6, 57) Source(16, 57) + SourceIndex(0) +9 >Emitted(6, 58) Source(16, 58) + SourceIndex(0) --- >>> } 1 >^^^^ @@ -109,8 +110,8 @@ sourceFile:Element.ts 1 > > 2 > } -1 >Emitted(6, 5) Source(17, 5) + SourceIndex(0) -2 >Emitted(6, 6) Source(17, 6) + SourceIndex(0) +1 >Emitted(7, 5) Source(17, 5) + SourceIndex(0) +2 >Emitted(7, 6) Source(17, 6) + SourceIndex(0) --- >>> Element.isElement = isElement; 1->^^^^ @@ -124,10 +125,10 @@ sourceFile:Element.ts > return el.markAsChildOfRootElement !== undefined; > } 4 > -1->Emitted(7, 5) Source(15, 21) + SourceIndex(0) -2 >Emitted(7, 22) Source(15, 30) + SourceIndex(0) -3 >Emitted(7, 34) Source(17, 6) + SourceIndex(0) -4 >Emitted(7, 35) Source(17, 6) + SourceIndex(0) +1->Emitted(8, 5) Source(15, 21) + SourceIndex(0) +2 >Emitted(8, 22) Source(15, 30) + SourceIndex(0) +3 >Emitted(8, 34) Source(17, 6) + SourceIndex(0) +4 >Emitted(8, 35) Source(17, 6) + SourceIndex(0) --- >>> function createElement(args) { 1->^^^^ @@ -138,9 +139,9 @@ sourceFile:Element.ts > 2 > export function createElement( 3 > args: any[] -1->Emitted(8, 5) Source(19, 5) + SourceIndex(0) -2 >Emitted(8, 28) Source(19, 35) + SourceIndex(0) -3 >Emitted(8, 32) Source(19, 46) + SourceIndex(0) +1->Emitted(9, 5) Source(19, 5) + SourceIndex(0) +2 >Emitted(9, 28) Source(19, 35) + SourceIndex(0) +3 >Emitted(9, 32) Source(19, 46) + SourceIndex(0) --- >>> return {}; 1 >^^^^^^^^ @@ -156,11 +157,11 @@ sourceFile:Element.ts 4 > { > } 5 > -1 >Emitted(9, 9) Source(21, 9) + SourceIndex(0) -2 >Emitted(9, 15) Source(21, 15) + SourceIndex(0) -3 >Emitted(9, 16) Source(21, 16) + SourceIndex(0) -4 >Emitted(9, 18) Source(22, 10) + SourceIndex(0) -5 >Emitted(9, 19) Source(22, 10) + SourceIndex(0) +1 >Emitted(10, 9) Source(21, 9) + SourceIndex(0) +2 >Emitted(10, 15) Source(21, 15) + SourceIndex(0) +3 >Emitted(10, 16) Source(21, 16) + SourceIndex(0) +4 >Emitted(10, 18) Source(22, 10) + SourceIndex(0) +5 >Emitted(10, 19) Source(22, 10) + SourceIndex(0) --- >>> } 1 >^^^^ @@ -169,8 +170,8 @@ sourceFile:Element.ts 1 > > 2 > } -1 >Emitted(10, 5) Source(23, 5) + SourceIndex(0) -2 >Emitted(10, 6) Source(23, 6) + SourceIndex(0) +1 >Emitted(11, 5) Source(23, 5) + SourceIndex(0) +2 >Emitted(11, 6) Source(23, 6) + SourceIndex(0) --- >>> Element.createElement = createElement; 1->^^^^ @@ -186,10 +187,10 @@ sourceFile:Element.ts > } > } 4 > -1->Emitted(11, 5) Source(19, 21) + SourceIndex(0) -2 >Emitted(11, 26) Source(19, 34) + SourceIndex(0) -3 >Emitted(11, 42) Source(23, 6) + SourceIndex(0) -4 >Emitted(11, 43) Source(23, 6) + SourceIndex(0) +1->Emitted(12, 5) Source(19, 21) + SourceIndex(0) +2 >Emitted(12, 26) Source(19, 34) + SourceIndex(0) +3 >Emitted(12, 42) Source(23, 6) + SourceIndex(0) +4 >Emitted(12, 43) Source(23, 6) + SourceIndex(0) --- >>>})(Element = exports.Element || (exports.Element = {})); 1-> @@ -221,15 +222,15 @@ sourceFile:Element.ts > } > } > } -1->Emitted(12, 1) Source(24, 1) + SourceIndex(0) -2 >Emitted(12, 2) Source(24, 2) + SourceIndex(0) -3 >Emitted(12, 4) Source(14, 18) + SourceIndex(0) -4 >Emitted(12, 11) Source(14, 25) + SourceIndex(0) -5 >Emitted(12, 14) Source(14, 18) + SourceIndex(0) -6 >Emitted(12, 29) Source(14, 25) + SourceIndex(0) -7 >Emitted(12, 34) Source(14, 18) + SourceIndex(0) -8 >Emitted(12, 49) Source(14, 25) + SourceIndex(0) -9 >Emitted(12, 57) Source(24, 2) + SourceIndex(0) +1->Emitted(13, 1) Source(24, 1) + SourceIndex(0) +2 >Emitted(13, 2) Source(24, 2) + SourceIndex(0) +3 >Emitted(13, 4) Source(14, 18) + SourceIndex(0) +4 >Emitted(13, 11) Source(14, 25) + SourceIndex(0) +5 >Emitted(13, 14) Source(14, 18) + SourceIndex(0) +6 >Emitted(13, 29) Source(14, 25) + SourceIndex(0) +7 >Emitted(13, 34) Source(14, 18) + SourceIndex(0) +8 >Emitted(13, 49) Source(14, 25) + SourceIndex(0) +9 >Emitted(13, 57) Source(24, 2) + SourceIndex(0) --- >>>exports.createElement = Element.createElement; 1 > @@ -250,14 +251,14 @@ sourceFile:Element.ts 6 > . 7 > createElement 8 > ; -1 >Emitted(13, 1) Source(26, 12) + SourceIndex(0) -2 >Emitted(13, 9) Source(26, 12) + SourceIndex(0) -3 >Emitted(13, 22) Source(26, 25) + SourceIndex(0) -4 >Emitted(13, 25) Source(26, 28) + SourceIndex(0) -5 >Emitted(13, 32) Source(26, 35) + SourceIndex(0) -6 >Emitted(13, 33) Source(26, 36) + SourceIndex(0) -7 >Emitted(13, 46) Source(26, 49) + SourceIndex(0) -8 >Emitted(13, 47) Source(26, 50) + SourceIndex(0) +1 >Emitted(14, 1) Source(26, 12) + SourceIndex(0) +2 >Emitted(14, 9) Source(26, 12) + SourceIndex(0) +3 >Emitted(14, 22) Source(26, 25) + SourceIndex(0) +4 >Emitted(14, 25) Source(26, 28) + SourceIndex(0) +5 >Emitted(14, 32) Source(26, 35) + SourceIndex(0) +6 >Emitted(14, 33) Source(26, 36) + SourceIndex(0) +7 >Emitted(14, 46) Source(26, 49) + SourceIndex(0) +8 >Emitted(14, 47) Source(26, 50) + SourceIndex(0) --- >>>function toCamelCase(text) { 1 > @@ -269,9 +270,9 @@ sourceFile:Element.ts > 2 >function toCamelCase( 3 > text: string -1 >Emitted(14, 1) Source(28, 1) + SourceIndex(0) -2 >Emitted(14, 22) Source(28, 22) + SourceIndex(0) -3 >Emitted(14, 26) Source(28, 34) + SourceIndex(0) +1 >Emitted(15, 1) Source(28, 1) + SourceIndex(0) +2 >Emitted(15, 22) Source(28, 22) + SourceIndex(0) +3 >Emitted(15, 26) Source(28, 34) + SourceIndex(0) --- >>> return text[0].toLowerCase() + text.substring(1); 1->^^^^ @@ -311,24 +312,24 @@ sourceFile:Element.ts 16> 1 17> ) 18> ; -1->Emitted(15, 5) Source(29, 5) + SourceIndex(0) -2 >Emitted(15, 11) Source(29, 11) + SourceIndex(0) -3 >Emitted(15, 12) Source(29, 12) + SourceIndex(0) -4 >Emitted(15, 16) Source(29, 16) + SourceIndex(0) -5 >Emitted(15, 17) Source(29, 17) + SourceIndex(0) -6 >Emitted(15, 18) Source(29, 18) + SourceIndex(0) -7 >Emitted(15, 19) Source(29, 19) + SourceIndex(0) -8 >Emitted(15, 20) Source(29, 20) + SourceIndex(0) -9 >Emitted(15, 31) Source(29, 31) + SourceIndex(0) -10>Emitted(15, 33) Source(29, 33) + SourceIndex(0) -11>Emitted(15, 36) Source(29, 36) + SourceIndex(0) -12>Emitted(15, 40) Source(29, 40) + SourceIndex(0) -13>Emitted(15, 41) Source(29, 41) + SourceIndex(0) -14>Emitted(15, 50) Source(29, 50) + SourceIndex(0) -15>Emitted(15, 51) Source(29, 51) + SourceIndex(0) -16>Emitted(15, 52) Source(29, 52) + SourceIndex(0) -17>Emitted(15, 53) Source(29, 53) + SourceIndex(0) -18>Emitted(15, 54) Source(29, 54) + SourceIndex(0) +1->Emitted(16, 5) Source(29, 5) + SourceIndex(0) +2 >Emitted(16, 11) Source(29, 11) + SourceIndex(0) +3 >Emitted(16, 12) Source(29, 12) + SourceIndex(0) +4 >Emitted(16, 16) Source(29, 16) + SourceIndex(0) +5 >Emitted(16, 17) Source(29, 17) + SourceIndex(0) +6 >Emitted(16, 18) Source(29, 18) + SourceIndex(0) +7 >Emitted(16, 19) Source(29, 19) + SourceIndex(0) +8 >Emitted(16, 20) Source(29, 20) + SourceIndex(0) +9 >Emitted(16, 31) Source(29, 31) + SourceIndex(0) +10>Emitted(16, 33) Source(29, 33) + SourceIndex(0) +11>Emitted(16, 36) Source(29, 36) + SourceIndex(0) +12>Emitted(16, 40) Source(29, 40) + SourceIndex(0) +13>Emitted(16, 41) Source(29, 41) + SourceIndex(0) +14>Emitted(16, 50) Source(29, 50) + SourceIndex(0) +15>Emitted(16, 51) Source(29, 51) + SourceIndex(0) +16>Emitted(16, 52) Source(29, 52) + SourceIndex(0) +17>Emitted(16, 53) Source(29, 53) + SourceIndex(0) +18>Emitted(16, 54) Source(29, 54) + SourceIndex(0) --- >>>} 1 > @@ -337,8 +338,8 @@ sourceFile:Element.ts 1 > > 2 >} -1 >Emitted(16, 1) Source(30, 1) + SourceIndex(0) -2 >Emitted(16, 2) Source(30, 2) + SourceIndex(0) +1 >Emitted(17, 1) Source(30, 1) + SourceIndex(0) +2 >Emitted(17, 2) Source(30, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=Element.js.map=================================================================== JsFile: test.js @@ -351,14 +352,15 @@ emittedFile:tests/cases/compiler/test.js sourceFile:test.tsx ------------------------------------------------------------------- >>>"use strict"; +>>>Object.defineProperty(exports, "__esModule", { value: true }); >>>const Element_1 = require("./Element"); 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^^^^^^^^^^^^^^-> 1 > 2 >import { Element} from './Element'; -1 >Emitted(2, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(2, 40) Source(1, 36) + SourceIndex(0) +1 >Emitted(3, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(3, 40) Source(1, 36) + SourceIndex(0) --- >>>let createElement = Element_1.Element.createElement; 1-> @@ -378,14 +380,14 @@ sourceFile:test.tsx 6 > . 7 > createElement 8 > ; -1->Emitted(3, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(3, 5) Source(2, 5) + SourceIndex(0) -3 >Emitted(3, 18) Source(2, 18) + SourceIndex(0) -4 >Emitted(3, 21) Source(2, 21) + SourceIndex(0) -5 >Emitted(3, 38) Source(2, 28) + SourceIndex(0) -6 >Emitted(3, 39) Source(2, 29) + SourceIndex(0) -7 >Emitted(3, 52) Source(2, 42) + SourceIndex(0) -8 >Emitted(3, 53) Source(2, 43) + SourceIndex(0) +1->Emitted(4, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(4, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(4, 18) Source(2, 18) + SourceIndex(0) +4 >Emitted(4, 21) Source(2, 21) + SourceIndex(0) +5 >Emitted(4, 38) Source(2, 28) + SourceIndex(0) +6 >Emitted(4, 39) Source(2, 29) + SourceIndex(0) +7 >Emitted(4, 52) Source(2, 42) + SourceIndex(0) +8 >Emitted(4, 53) Source(2, 43) + SourceIndex(0) --- >>>let c; 1 > @@ -402,10 +404,10 @@ sourceFile:test.tsx > } > } 4 > ; -1 >Emitted(4, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(4, 5) Source(3, 5) + SourceIndex(0) -3 >Emitted(4, 6) Source(7, 2) + SourceIndex(0) -4 >Emitted(4, 7) Source(7, 3) + SourceIndex(0) +1 >Emitted(5, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(5, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(5, 6) Source(7, 2) + SourceIndex(0) +4 >Emitted(5, 7) Source(7, 3) + SourceIndex(0) --- >>>class A { 1-> @@ -413,7 +415,7 @@ sourceFile:test.tsx 1-> > > -1->Emitted(5, 1) Source(9, 1) + SourceIndex(0) +1->Emitted(6, 1) Source(9, 1) + SourceIndex(0) --- >>> view() { 1->^^^^ @@ -422,8 +424,8 @@ sourceFile:test.tsx 1->class A { > 2 > view -1->Emitted(6, 5) Source(10, 2) + SourceIndex(0) -2 >Emitted(6, 9) Source(10, 6) + SourceIndex(0) +1->Emitted(7, 5) Source(10, 2) + SourceIndex(0) +2 >Emitted(7, 9) Source(10, 6) + SourceIndex(0) --- >>> return [ 1->^^^^^^^^ @@ -434,9 +436,9 @@ sourceFile:test.tsx > 2 > return 3 > -1->Emitted(7, 9) Source(11, 3) + SourceIndex(0) -2 >Emitted(7, 15) Source(11, 9) + SourceIndex(0) -3 >Emitted(7, 16) Source(11, 10) + SourceIndex(0) +1->Emitted(8, 9) Source(11, 3) + SourceIndex(0) +2 >Emitted(8, 15) Source(11, 9) + SourceIndex(0) +3 >Emitted(8, 16) Source(11, 10) + SourceIndex(0) --- >>> createElement("meta", { content: "helloworld" }), 1->^^^^^^^^^^^^ @@ -452,12 +454,12 @@ sourceFile:test.tsx 4 > = 5 > "helloworld" 6 > > -1->Emitted(8, 13) Source(12, 4) + SourceIndex(0) -2 >Emitted(8, 37) Source(12, 10) + SourceIndex(0) -3 >Emitted(8, 44) Source(12, 17) + SourceIndex(0) -4 >Emitted(8, 46) Source(12, 18) + SourceIndex(0) -5 >Emitted(8, 58) Source(12, 30) + SourceIndex(0) -6 >Emitted(8, 61) Source(12, 38) + SourceIndex(0) +1->Emitted(9, 13) Source(12, 4) + SourceIndex(0) +2 >Emitted(9, 37) Source(12, 10) + SourceIndex(0) +3 >Emitted(9, 44) Source(12, 17) + SourceIndex(0) +4 >Emitted(9, 46) Source(12, 18) + SourceIndex(0) +5 >Emitted(9, 58) Source(12, 30) + SourceIndex(0) +6 >Emitted(9, 61) Source(12, 38) + SourceIndex(0) --- >>> createElement("meta", { content: c.a.b }) 1 >^^^^^^^^^^^^ @@ -481,16 +483,16 @@ sourceFile:test.tsx 8 > . 9 > b 10> }> -1 >Emitted(9, 13) Source(13, 4) + SourceIndex(0) -2 >Emitted(9, 37) Source(13, 10) + SourceIndex(0) -3 >Emitted(9, 44) Source(13, 17) + SourceIndex(0) -4 >Emitted(9, 46) Source(13, 19) + SourceIndex(0) -5 >Emitted(9, 47) Source(13, 20) + SourceIndex(0) -6 >Emitted(9, 48) Source(13, 21) + SourceIndex(0) -7 >Emitted(9, 49) Source(13, 23) + SourceIndex(0) -8 >Emitted(9, 50) Source(13, 24) + SourceIndex(0) -9 >Emitted(9, 51) Source(13, 25) + SourceIndex(0) -10>Emitted(9, 54) Source(13, 34) + SourceIndex(0) +1 >Emitted(10, 13) Source(13, 4) + SourceIndex(0) +2 >Emitted(10, 37) Source(13, 10) + SourceIndex(0) +3 >Emitted(10, 44) Source(13, 17) + SourceIndex(0) +4 >Emitted(10, 46) Source(13, 19) + SourceIndex(0) +5 >Emitted(10, 47) Source(13, 20) + SourceIndex(0) +6 >Emitted(10, 48) Source(13, 21) + SourceIndex(0) +7 >Emitted(10, 49) Source(13, 23) + SourceIndex(0) +8 >Emitted(10, 50) Source(13, 24) + SourceIndex(0) +9 >Emitted(10, 51) Source(13, 25) + SourceIndex(0) +10>Emitted(10, 54) Source(13, 34) + SourceIndex(0) --- >>> ]; 1 >^^^^^^^^^ @@ -498,8 +500,8 @@ sourceFile:test.tsx 1 > > ] 2 > ; -1 >Emitted(10, 10) Source(14, 4) + SourceIndex(0) -2 >Emitted(10, 11) Source(14, 5) + SourceIndex(0) +1 >Emitted(11, 10) Source(14, 4) + SourceIndex(0) +2 >Emitted(11, 11) Source(14, 5) + SourceIndex(0) --- >>> } 1 >^^^^ @@ -507,14 +509,14 @@ sourceFile:test.tsx 1 > > 2 > } -1 >Emitted(11, 5) Source(15, 2) + SourceIndex(0) -2 >Emitted(11, 6) Source(15, 3) + SourceIndex(0) +1 >Emitted(12, 5) Source(15, 2) + SourceIndex(0) +2 >Emitted(12, 6) Source(15, 3) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(12, 2) Source(16, 2) + SourceIndex(0) +1 >Emitted(13, 2) Source(16, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/jsxFactoryIdentifier.symbols b/tests/baselines/reference/jsxFactoryIdentifier.symbols index 0d0f1e80490..b6d6856bccb 100644 --- a/tests/baselines/reference/jsxFactoryIdentifier.symbols +++ b/tests/baselines/reference/jsxFactoryIdentifier.symbols @@ -107,12 +107,12 @@ class A { return [ , >meta : Symbol(unknown) ->content : Symbol(unknown) +>content : Symbol(content, Decl(test.tsx, 11, 8)) >meta : Symbol(unknown) >meta : Symbol(unknown) ->content : Symbol(unknown) +>content : Symbol(content, Decl(test.tsx, 12, 8)) >c.a!.b : Symbol(b, Decl(test.tsx, 3, 6)) >c.a : Symbol(a, Decl(test.tsx, 2, 8)) >c : Symbol(c, Decl(test.tsx, 2, 3)) diff --git a/tests/baselines/reference/jsxFactoryIdentifier.types b/tests/baselines/reference/jsxFactoryIdentifier.types index c946c90559d..cb44bb0ac0f 100644 --- a/tests/baselines/reference/jsxFactoryIdentifier.types +++ b/tests/baselines/reference/jsxFactoryIdentifier.types @@ -120,13 +120,13 @@ class A { , > : any >meta : any ->content : any +>content : string >meta : any > : any >meta : any ->content : any +>content : string >c.a!.b : string >c.a! : { b: string; } >c.a : { b: string; } diff --git a/tests/baselines/reference/jsxFactoryIdentifierAsParameter.js b/tests/baselines/reference/jsxFactoryIdentifierAsParameter.js index ffec40ff7b6..05da89d0d85 100644 --- a/tests/baselines/reference/jsxFactoryIdentifierAsParameter.js +++ b/tests/baselines/reference/jsxFactoryIdentifierAsParameter.js @@ -15,6 +15,7 @@ export class AppComponent { //// [test.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); class AppComponent { render(createElement) { return createElement("div", null); diff --git a/tests/baselines/reference/jsxFactoryIdentifierAsParameter.js.map b/tests/baselines/reference/jsxFactoryIdentifierAsParameter.js.map index c108b93a913..c72e1bf8057 100644 --- a/tests/baselines/reference/jsxFactoryIdentifierAsParameter.js.map +++ b/tests/baselines/reference/jsxFactoryIdentifierAsParameter.js.map @@ -1,2 +1,2 @@ //// [test.js.map] -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":";AAOA;IACI,MAAM,CAAC,aAAa;QAChB,MAAM,CAAC,0BAAO,CAAC;IACnB,CAAC;CACJ;AAJD,oCAIC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":";;AAOA;IACI,MAAM,CAAC,aAAa;QAChB,MAAM,CAAC,0BAAO,CAAC;IACnB,CAAC;CACJ;AAJD,oCAIC"} \ No newline at end of file diff --git a/tests/baselines/reference/jsxFactoryIdentifierAsParameter.sourcemap.txt b/tests/baselines/reference/jsxFactoryIdentifierAsParameter.sourcemap.txt index c7867fc54e0..b2d30177b1d 100644 --- a/tests/baselines/reference/jsxFactoryIdentifierAsParameter.sourcemap.txt +++ b/tests/baselines/reference/jsxFactoryIdentifierAsParameter.sourcemap.txt @@ -9,6 +9,7 @@ emittedFile:tests/cases/compiler/test.js sourceFile:test.tsx ------------------------------------------------------------------- >>>"use strict"; +>>>Object.defineProperty(exports, "__esModule", { value: true }); >>>class AppComponent { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> @@ -20,7 +21,7 @@ sourceFile:test.tsx >} > > -1 >Emitted(2, 1) Source(8, 1) + SourceIndex(0) +1 >Emitted(3, 1) Source(8, 1) + SourceIndex(0) --- >>> render(createElement) { 1->^^^^ @@ -33,10 +34,10 @@ sourceFile:test.tsx 2 > render 3 > ( 4 > createElement -1->Emitted(3, 5) Source(9, 5) + SourceIndex(0) -2 >Emitted(3, 11) Source(9, 11) + SourceIndex(0) -3 >Emitted(3, 12) Source(9, 12) + SourceIndex(0) -4 >Emitted(3, 25) Source(9, 25) + SourceIndex(0) +1->Emitted(4, 5) Source(9, 5) + SourceIndex(0) +2 >Emitted(4, 11) Source(9, 11) + SourceIndex(0) +3 >Emitted(4, 12) Source(9, 12) + SourceIndex(0) +4 >Emitted(4, 25) Source(9, 25) + SourceIndex(0) --- >>> return createElement("div", null); 1->^^^^^^^^ @@ -50,11 +51,11 @@ sourceFile:test.tsx 3 > 4 >
5 > ; -1->Emitted(4, 9) Source(10, 9) + SourceIndex(0) -2 >Emitted(4, 15) Source(10, 15) + SourceIndex(0) -3 >Emitted(4, 16) Source(10, 16) + SourceIndex(0) -4 >Emitted(4, 42) Source(10, 23) + SourceIndex(0) -5 >Emitted(4, 43) Source(10, 24) + SourceIndex(0) +1->Emitted(5, 9) Source(10, 9) + SourceIndex(0) +2 >Emitted(5, 15) Source(10, 15) + SourceIndex(0) +3 >Emitted(5, 16) Source(10, 16) + SourceIndex(0) +4 >Emitted(5, 42) Source(10, 23) + SourceIndex(0) +5 >Emitted(5, 43) Source(10, 24) + SourceIndex(0) --- >>> } 1 >^^^^ @@ -62,15 +63,15 @@ sourceFile:test.tsx 1 > > 2 > } -1 >Emitted(5, 5) Source(11, 5) + SourceIndex(0) -2 >Emitted(5, 6) Source(11, 6) + SourceIndex(0) +1 >Emitted(6, 5) Source(11, 5) + SourceIndex(0) +2 >Emitted(6, 6) Source(11, 6) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(6, 2) Source(12, 2) + SourceIndex(0) +1 >Emitted(7, 2) Source(12, 2) + SourceIndex(0) --- >>>exports.AppComponent = AppComponent; 1-> @@ -81,7 +82,7 @@ sourceFile:test.tsx > return
; > } >} -1->Emitted(7, 1) Source(8, 1) + SourceIndex(0) -2 >Emitted(7, 37) Source(12, 2) + SourceIndex(0) +1->Emitted(8, 1) Source(8, 1) + SourceIndex(0) +2 >Emitted(8, 37) Source(12, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/jsxFactoryIdentifierWithAbsentParameter.js b/tests/baselines/reference/jsxFactoryIdentifierWithAbsentParameter.js index 23f6f44e0c7..c9f5f3465e3 100644 --- a/tests/baselines/reference/jsxFactoryIdentifierWithAbsentParameter.js +++ b/tests/baselines/reference/jsxFactoryIdentifierWithAbsentParameter.js @@ -15,6 +15,7 @@ export class AppComponent { //// [test.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); class AppComponent { render() { return createElement("div", null); diff --git a/tests/baselines/reference/jsxFactoryIdentifierWithAbsentParameter.js.map b/tests/baselines/reference/jsxFactoryIdentifierWithAbsentParameter.js.map index 715014ff53f..66666a526d6 100644 --- a/tests/baselines/reference/jsxFactoryIdentifierWithAbsentParameter.js.map +++ b/tests/baselines/reference/jsxFactoryIdentifierWithAbsentParameter.js.map @@ -1,2 +1,2 @@ //// [test.js.map] -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":";AAOA;IACI,MAAM;QACF,MAAM,CAAC,0BAAO,CAAC;IACnB,CAAC;CACJ;AAJD,oCAIC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":";;AAOA;IACI,MAAM;QACF,MAAM,CAAC,0BAAO,CAAC;IACnB,CAAC;CACJ;AAJD,oCAIC"} \ No newline at end of file diff --git a/tests/baselines/reference/jsxFactoryIdentifierWithAbsentParameter.sourcemap.txt b/tests/baselines/reference/jsxFactoryIdentifierWithAbsentParameter.sourcemap.txt index f1ebaf49870..1a77ab3eae1 100644 --- a/tests/baselines/reference/jsxFactoryIdentifierWithAbsentParameter.sourcemap.txt +++ b/tests/baselines/reference/jsxFactoryIdentifierWithAbsentParameter.sourcemap.txt @@ -9,6 +9,7 @@ emittedFile:tests/cases/compiler/test.js sourceFile:test.tsx ------------------------------------------------------------------- >>>"use strict"; +>>>Object.defineProperty(exports, "__esModule", { value: true }); >>>class AppComponent { 1 > 2 >^^^^^^^^^^^^^^^-> @@ -20,7 +21,7 @@ sourceFile:test.tsx >} > > -1 >Emitted(2, 1) Source(8, 1) + SourceIndex(0) +1 >Emitted(3, 1) Source(8, 1) + SourceIndex(0) --- >>> render() { 1->^^^^ @@ -29,8 +30,8 @@ sourceFile:test.tsx 1->export class AppComponent { > 2 > render -1->Emitted(3, 5) Source(9, 5) + SourceIndex(0) -2 >Emitted(3, 11) Source(9, 11) + SourceIndex(0) +1->Emitted(4, 5) Source(9, 5) + SourceIndex(0) +2 >Emitted(4, 11) Source(9, 11) + SourceIndex(0) --- >>> return createElement("div", null); 1->^^^^^^^^ @@ -44,11 +45,11 @@ sourceFile:test.tsx 3 > 4 >
5 > ; -1->Emitted(4, 9) Source(10, 9) + SourceIndex(0) -2 >Emitted(4, 15) Source(10, 15) + SourceIndex(0) -3 >Emitted(4, 16) Source(10, 16) + SourceIndex(0) -4 >Emitted(4, 42) Source(10, 23) + SourceIndex(0) -5 >Emitted(4, 43) Source(10, 24) + SourceIndex(0) +1->Emitted(5, 9) Source(10, 9) + SourceIndex(0) +2 >Emitted(5, 15) Source(10, 15) + SourceIndex(0) +3 >Emitted(5, 16) Source(10, 16) + SourceIndex(0) +4 >Emitted(5, 42) Source(10, 23) + SourceIndex(0) +5 >Emitted(5, 43) Source(10, 24) + SourceIndex(0) --- >>> } 1 >^^^^ @@ -56,15 +57,15 @@ sourceFile:test.tsx 1 > > 2 > } -1 >Emitted(5, 5) Source(11, 5) + SourceIndex(0) -2 >Emitted(5, 6) Source(11, 6) + SourceIndex(0) +1 >Emitted(6, 5) Source(11, 5) + SourceIndex(0) +2 >Emitted(6, 6) Source(11, 6) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(6, 2) Source(12, 2) + SourceIndex(0) +1 >Emitted(7, 2) Source(12, 2) + SourceIndex(0) --- >>>exports.AppComponent = AppComponent; 1-> @@ -75,7 +76,7 @@ sourceFile:test.tsx > return
; > } >} -1->Emitted(7, 1) Source(8, 1) + SourceIndex(0) -2 >Emitted(7, 37) Source(12, 2) + SourceIndex(0) +1->Emitted(8, 1) Source(8, 1) + SourceIndex(0) +2 >Emitted(8, 37) Source(12, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/jsxFactoryNotIdentifierOrQualifiedName.js b/tests/baselines/reference/jsxFactoryNotIdentifierOrQualifiedName.js index 90bb675442a..9fc5799b11d 100644 --- a/tests/baselines/reference/jsxFactoryNotIdentifierOrQualifiedName.js +++ b/tests/baselines/reference/jsxFactoryNotIdentifierOrQualifiedName.js @@ -52,6 +52,7 @@ class A { //// [Element.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var Element; (function (Element) { function isElement(el) { @@ -69,6 +70,7 @@ function toCamelCase(text) { } //// [test.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); let c; class A { view() { diff --git a/tests/baselines/reference/jsxFactoryNotIdentifierOrQualifiedName2.js b/tests/baselines/reference/jsxFactoryNotIdentifierOrQualifiedName2.js index 0bc0c6e57c5..aa90c74cce5 100644 --- a/tests/baselines/reference/jsxFactoryNotIdentifierOrQualifiedName2.js +++ b/tests/baselines/reference/jsxFactoryNotIdentifierOrQualifiedName2.js @@ -52,6 +52,7 @@ class A { //// [Element.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var Element; (function (Element) { function isElement(el) { @@ -69,6 +70,7 @@ function toCamelCase(text) { } //// [test.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); let c; class A { view() { diff --git a/tests/baselines/reference/jsxFactoryQualifiedName.js b/tests/baselines/reference/jsxFactoryQualifiedName.js index 80a77d35302..ee747733799 100644 --- a/tests/baselines/reference/jsxFactoryQualifiedName.js +++ b/tests/baselines/reference/jsxFactoryQualifiedName.js @@ -52,6 +52,7 @@ class A { //// [Element.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var Element; (function (Element) { function isElement(el) { @@ -69,6 +70,7 @@ function toCamelCase(text) { } //# sourceMappingURL=Element.js.map//// [test.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); const Element_1 = require("./Element"); let c; class A { diff --git a/tests/baselines/reference/jsxFactoryQualifiedName.js.map b/tests/baselines/reference/jsxFactoryQualifiedName.js.map index f8cef24a0f0..6c5dd8abf56 100644 --- a/tests/baselines/reference/jsxFactoryQualifiedName.js.map +++ b/tests/baselines/reference/jsxFactoryQualifiedName.js.map @@ -1,3 +1,3 @@ //// [Element.js.map] -{"version":3,"file":"Element.js","sourceRoot":"","sources":["Element.ts"],"names":[],"mappings":";AAaA,IAAiB,OAAO,CAUvB;AAVD,WAAiB,OAAO;IACpB,mBAA0B,EAAO;QAC7B,MAAM,CAAC,EAAE,CAAC,wBAAwB,KAAK,SAAS,CAAC;IACrD,CAAC;IAFe,iBAAS,YAExB,CAAA;IAED,uBAA8B,IAAW;QAErC,MAAM,CAAC,EACN,CAAA;IACL,CAAC;IAJe,qBAAa,gBAI5B,CAAA;AACL,CAAC,EAVgB,OAAO,GAAP,eAAO,KAAP,eAAO,QAUvB;AAEU,QAAA,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;AAEjD,qBAAqB,IAAY;IAC7B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC"}//// [test.js.map] -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":";AAAA,uCAAmC;AAEnC,IAAI,CAIH,CAAC;AAEF;IACC,IAAI;QACH,MAAM,CAAC;YACN,0CAAM,OAAO,EAAC,YAAY,GAAQ;YAClC,0CAAM,OAAO,EAAE,CAAC,CAAC,CAAE,CAAC,CAAC,GAAS;SAC9B,CAAC;IACH,CAAC;CACD"} \ No newline at end of file +{"version":3,"file":"Element.js","sourceRoot":"","sources":["Element.ts"],"names":[],"mappings":";;AAaA,IAAiB,OAAO,CAUvB;AAVD,WAAiB,OAAO;IACpB,mBAA0B,EAAO;QAC7B,MAAM,CAAC,EAAE,CAAC,wBAAwB,KAAK,SAAS,CAAC;IACrD,CAAC;IAFe,iBAAS,YAExB,CAAA;IAED,uBAA8B,IAAW;QAErC,MAAM,CAAC,EACN,CAAA;IACL,CAAC;IAJe,qBAAa,gBAI5B,CAAA;AACL,CAAC,EAVgB,OAAO,GAAP,eAAO,KAAP,eAAO,QAUvB;AAEU,QAAA,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;AAEjD,qBAAqB,IAAY;IAC7B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC"}//// [test.js.map] +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":";;AAAA,uCAAmC;AAEnC,IAAI,CAIH,CAAC;AAEF;IACC,IAAI;QACH,MAAM,CAAC;YACN,0CAAM,OAAO,EAAC,YAAY,GAAQ;YAClC,0CAAM,OAAO,EAAE,CAAC,CAAC,CAAE,CAAC,CAAC,GAAS;SAC9B,CAAC;IACH,CAAC;CACD"} \ No newline at end of file diff --git a/tests/baselines/reference/jsxFactoryQualifiedName.sourcemap.txt b/tests/baselines/reference/jsxFactoryQualifiedName.sourcemap.txt index 98517620c73..9831a9ab5fd 100644 --- a/tests/baselines/reference/jsxFactoryQualifiedName.sourcemap.txt +++ b/tests/baselines/reference/jsxFactoryQualifiedName.sourcemap.txt @@ -9,6 +9,7 @@ emittedFile:tests/cases/compiler/Element.js sourceFile:Element.ts ------------------------------------------------------------------- >>>"use strict"; +>>>Object.defineProperty(exports, "__esModule", { value: true }); >>>var Element; 1 > 2 >^^^^ @@ -42,10 +43,10 @@ sourceFile:Element.ts > } > } > } -1 >Emitted(2, 1) Source(14, 1) + SourceIndex(0) -2 >Emitted(2, 5) Source(14, 18) + SourceIndex(0) -3 >Emitted(2, 12) Source(14, 25) + SourceIndex(0) -4 >Emitted(2, 13) Source(24, 2) + SourceIndex(0) +1 >Emitted(3, 1) Source(14, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(14, 18) + SourceIndex(0) +3 >Emitted(3, 12) Source(14, 25) + SourceIndex(0) +4 >Emitted(3, 13) Source(24, 2) + SourceIndex(0) --- >>>(function (Element) { 1-> @@ -55,9 +56,9 @@ sourceFile:Element.ts 1-> 2 >export namespace 3 > Element -1->Emitted(3, 1) Source(14, 1) + SourceIndex(0) -2 >Emitted(3, 12) Source(14, 18) + SourceIndex(0) -3 >Emitted(3, 19) Source(14, 25) + SourceIndex(0) +1->Emitted(4, 1) Source(14, 1) + SourceIndex(0) +2 >Emitted(4, 12) Source(14, 18) + SourceIndex(0) +3 >Emitted(4, 19) Source(14, 25) + SourceIndex(0) --- >>> function isElement(el) { 1->^^^^ @@ -68,9 +69,9 @@ sourceFile:Element.ts > 2 > export function isElement( 3 > el: any -1->Emitted(4, 5) Source(15, 5) + SourceIndex(0) -2 >Emitted(4, 24) Source(15, 31) + SourceIndex(0) -3 >Emitted(4, 26) Source(15, 38) + SourceIndex(0) +1->Emitted(5, 5) Source(15, 5) + SourceIndex(0) +2 >Emitted(5, 24) Source(15, 31) + SourceIndex(0) +3 >Emitted(5, 26) Source(15, 38) + SourceIndex(0) --- >>> return el.markAsChildOfRootElement !== undefined; 1->^^^^^^^^ @@ -92,15 +93,15 @@ sourceFile:Element.ts 7 > !== 8 > undefined 9 > ; -1->Emitted(5, 9) Source(16, 9) + SourceIndex(0) -2 >Emitted(5, 15) Source(16, 15) + SourceIndex(0) -3 >Emitted(5, 16) Source(16, 16) + SourceIndex(0) -4 >Emitted(5, 18) Source(16, 18) + SourceIndex(0) -5 >Emitted(5, 19) Source(16, 19) + SourceIndex(0) -6 >Emitted(5, 43) Source(16, 43) + SourceIndex(0) -7 >Emitted(5, 48) Source(16, 48) + SourceIndex(0) -8 >Emitted(5, 57) Source(16, 57) + SourceIndex(0) -9 >Emitted(5, 58) Source(16, 58) + SourceIndex(0) +1->Emitted(6, 9) Source(16, 9) + SourceIndex(0) +2 >Emitted(6, 15) Source(16, 15) + SourceIndex(0) +3 >Emitted(6, 16) Source(16, 16) + SourceIndex(0) +4 >Emitted(6, 18) Source(16, 18) + SourceIndex(0) +5 >Emitted(6, 19) Source(16, 19) + SourceIndex(0) +6 >Emitted(6, 43) Source(16, 43) + SourceIndex(0) +7 >Emitted(6, 48) Source(16, 48) + SourceIndex(0) +8 >Emitted(6, 57) Source(16, 57) + SourceIndex(0) +9 >Emitted(6, 58) Source(16, 58) + SourceIndex(0) --- >>> } 1 >^^^^ @@ -109,8 +110,8 @@ sourceFile:Element.ts 1 > > 2 > } -1 >Emitted(6, 5) Source(17, 5) + SourceIndex(0) -2 >Emitted(6, 6) Source(17, 6) + SourceIndex(0) +1 >Emitted(7, 5) Source(17, 5) + SourceIndex(0) +2 >Emitted(7, 6) Source(17, 6) + SourceIndex(0) --- >>> Element.isElement = isElement; 1->^^^^ @@ -124,10 +125,10 @@ sourceFile:Element.ts > return el.markAsChildOfRootElement !== undefined; > } 4 > -1->Emitted(7, 5) Source(15, 21) + SourceIndex(0) -2 >Emitted(7, 22) Source(15, 30) + SourceIndex(0) -3 >Emitted(7, 34) Source(17, 6) + SourceIndex(0) -4 >Emitted(7, 35) Source(17, 6) + SourceIndex(0) +1->Emitted(8, 5) Source(15, 21) + SourceIndex(0) +2 >Emitted(8, 22) Source(15, 30) + SourceIndex(0) +3 >Emitted(8, 34) Source(17, 6) + SourceIndex(0) +4 >Emitted(8, 35) Source(17, 6) + SourceIndex(0) --- >>> function createElement(args) { 1->^^^^ @@ -138,9 +139,9 @@ sourceFile:Element.ts > 2 > export function createElement( 3 > args: any[] -1->Emitted(8, 5) Source(19, 5) + SourceIndex(0) -2 >Emitted(8, 28) Source(19, 35) + SourceIndex(0) -3 >Emitted(8, 32) Source(19, 46) + SourceIndex(0) +1->Emitted(9, 5) Source(19, 5) + SourceIndex(0) +2 >Emitted(9, 28) Source(19, 35) + SourceIndex(0) +3 >Emitted(9, 32) Source(19, 46) + SourceIndex(0) --- >>> return {}; 1 >^^^^^^^^ @@ -156,11 +157,11 @@ sourceFile:Element.ts 4 > { > } 5 > -1 >Emitted(9, 9) Source(21, 9) + SourceIndex(0) -2 >Emitted(9, 15) Source(21, 15) + SourceIndex(0) -3 >Emitted(9, 16) Source(21, 16) + SourceIndex(0) -4 >Emitted(9, 18) Source(22, 10) + SourceIndex(0) -5 >Emitted(9, 19) Source(22, 10) + SourceIndex(0) +1 >Emitted(10, 9) Source(21, 9) + SourceIndex(0) +2 >Emitted(10, 15) Source(21, 15) + SourceIndex(0) +3 >Emitted(10, 16) Source(21, 16) + SourceIndex(0) +4 >Emitted(10, 18) Source(22, 10) + SourceIndex(0) +5 >Emitted(10, 19) Source(22, 10) + SourceIndex(0) --- >>> } 1 >^^^^ @@ -169,8 +170,8 @@ sourceFile:Element.ts 1 > > 2 > } -1 >Emitted(10, 5) Source(23, 5) + SourceIndex(0) -2 >Emitted(10, 6) Source(23, 6) + SourceIndex(0) +1 >Emitted(11, 5) Source(23, 5) + SourceIndex(0) +2 >Emitted(11, 6) Source(23, 6) + SourceIndex(0) --- >>> Element.createElement = createElement; 1->^^^^ @@ -186,10 +187,10 @@ sourceFile:Element.ts > } > } 4 > -1->Emitted(11, 5) Source(19, 21) + SourceIndex(0) -2 >Emitted(11, 26) Source(19, 34) + SourceIndex(0) -3 >Emitted(11, 42) Source(23, 6) + SourceIndex(0) -4 >Emitted(11, 43) Source(23, 6) + SourceIndex(0) +1->Emitted(12, 5) Source(19, 21) + SourceIndex(0) +2 >Emitted(12, 26) Source(19, 34) + SourceIndex(0) +3 >Emitted(12, 42) Source(23, 6) + SourceIndex(0) +4 >Emitted(12, 43) Source(23, 6) + SourceIndex(0) --- >>>})(Element = exports.Element || (exports.Element = {})); 1-> @@ -221,15 +222,15 @@ sourceFile:Element.ts > } > } > } -1->Emitted(12, 1) Source(24, 1) + SourceIndex(0) -2 >Emitted(12, 2) Source(24, 2) + SourceIndex(0) -3 >Emitted(12, 4) Source(14, 18) + SourceIndex(0) -4 >Emitted(12, 11) Source(14, 25) + SourceIndex(0) -5 >Emitted(12, 14) Source(14, 18) + SourceIndex(0) -6 >Emitted(12, 29) Source(14, 25) + SourceIndex(0) -7 >Emitted(12, 34) Source(14, 18) + SourceIndex(0) -8 >Emitted(12, 49) Source(14, 25) + SourceIndex(0) -9 >Emitted(12, 57) Source(24, 2) + SourceIndex(0) +1->Emitted(13, 1) Source(24, 1) + SourceIndex(0) +2 >Emitted(13, 2) Source(24, 2) + SourceIndex(0) +3 >Emitted(13, 4) Source(14, 18) + SourceIndex(0) +4 >Emitted(13, 11) Source(14, 25) + SourceIndex(0) +5 >Emitted(13, 14) Source(14, 18) + SourceIndex(0) +6 >Emitted(13, 29) Source(14, 25) + SourceIndex(0) +7 >Emitted(13, 34) Source(14, 18) + SourceIndex(0) +8 >Emitted(13, 49) Source(14, 25) + SourceIndex(0) +9 >Emitted(13, 57) Source(24, 2) + SourceIndex(0) --- >>>exports.createElement = Element.createElement; 1 > @@ -250,14 +251,14 @@ sourceFile:Element.ts 6 > . 7 > createElement 8 > ; -1 >Emitted(13, 1) Source(26, 12) + SourceIndex(0) -2 >Emitted(13, 9) Source(26, 12) + SourceIndex(0) -3 >Emitted(13, 22) Source(26, 25) + SourceIndex(0) -4 >Emitted(13, 25) Source(26, 28) + SourceIndex(0) -5 >Emitted(13, 32) Source(26, 35) + SourceIndex(0) -6 >Emitted(13, 33) Source(26, 36) + SourceIndex(0) -7 >Emitted(13, 46) Source(26, 49) + SourceIndex(0) -8 >Emitted(13, 47) Source(26, 50) + SourceIndex(0) +1 >Emitted(14, 1) Source(26, 12) + SourceIndex(0) +2 >Emitted(14, 9) Source(26, 12) + SourceIndex(0) +3 >Emitted(14, 22) Source(26, 25) + SourceIndex(0) +4 >Emitted(14, 25) Source(26, 28) + SourceIndex(0) +5 >Emitted(14, 32) Source(26, 35) + SourceIndex(0) +6 >Emitted(14, 33) Source(26, 36) + SourceIndex(0) +7 >Emitted(14, 46) Source(26, 49) + SourceIndex(0) +8 >Emitted(14, 47) Source(26, 50) + SourceIndex(0) --- >>>function toCamelCase(text) { 1 > @@ -269,9 +270,9 @@ sourceFile:Element.ts > 2 >function toCamelCase( 3 > text: string -1 >Emitted(14, 1) Source(28, 1) + SourceIndex(0) -2 >Emitted(14, 22) Source(28, 22) + SourceIndex(0) -3 >Emitted(14, 26) Source(28, 34) + SourceIndex(0) +1 >Emitted(15, 1) Source(28, 1) + SourceIndex(0) +2 >Emitted(15, 22) Source(28, 22) + SourceIndex(0) +3 >Emitted(15, 26) Source(28, 34) + SourceIndex(0) --- >>> return text[0].toLowerCase() + text.substring(1); 1->^^^^ @@ -311,24 +312,24 @@ sourceFile:Element.ts 16> 1 17> ) 18> ; -1->Emitted(15, 5) Source(29, 5) + SourceIndex(0) -2 >Emitted(15, 11) Source(29, 11) + SourceIndex(0) -3 >Emitted(15, 12) Source(29, 12) + SourceIndex(0) -4 >Emitted(15, 16) Source(29, 16) + SourceIndex(0) -5 >Emitted(15, 17) Source(29, 17) + SourceIndex(0) -6 >Emitted(15, 18) Source(29, 18) + SourceIndex(0) -7 >Emitted(15, 19) Source(29, 19) + SourceIndex(0) -8 >Emitted(15, 20) Source(29, 20) + SourceIndex(0) -9 >Emitted(15, 31) Source(29, 31) + SourceIndex(0) -10>Emitted(15, 33) Source(29, 33) + SourceIndex(0) -11>Emitted(15, 36) Source(29, 36) + SourceIndex(0) -12>Emitted(15, 40) Source(29, 40) + SourceIndex(0) -13>Emitted(15, 41) Source(29, 41) + SourceIndex(0) -14>Emitted(15, 50) Source(29, 50) + SourceIndex(0) -15>Emitted(15, 51) Source(29, 51) + SourceIndex(0) -16>Emitted(15, 52) Source(29, 52) + SourceIndex(0) -17>Emitted(15, 53) Source(29, 53) + SourceIndex(0) -18>Emitted(15, 54) Source(29, 54) + SourceIndex(0) +1->Emitted(16, 5) Source(29, 5) + SourceIndex(0) +2 >Emitted(16, 11) Source(29, 11) + SourceIndex(0) +3 >Emitted(16, 12) Source(29, 12) + SourceIndex(0) +4 >Emitted(16, 16) Source(29, 16) + SourceIndex(0) +5 >Emitted(16, 17) Source(29, 17) + SourceIndex(0) +6 >Emitted(16, 18) Source(29, 18) + SourceIndex(0) +7 >Emitted(16, 19) Source(29, 19) + SourceIndex(0) +8 >Emitted(16, 20) Source(29, 20) + SourceIndex(0) +9 >Emitted(16, 31) Source(29, 31) + SourceIndex(0) +10>Emitted(16, 33) Source(29, 33) + SourceIndex(0) +11>Emitted(16, 36) Source(29, 36) + SourceIndex(0) +12>Emitted(16, 40) Source(29, 40) + SourceIndex(0) +13>Emitted(16, 41) Source(29, 41) + SourceIndex(0) +14>Emitted(16, 50) Source(29, 50) + SourceIndex(0) +15>Emitted(16, 51) Source(29, 51) + SourceIndex(0) +16>Emitted(16, 52) Source(29, 52) + SourceIndex(0) +17>Emitted(16, 53) Source(29, 53) + SourceIndex(0) +18>Emitted(16, 54) Source(29, 54) + SourceIndex(0) --- >>>} 1 > @@ -337,8 +338,8 @@ sourceFile:Element.ts 1 > > 2 >} -1 >Emitted(16, 1) Source(30, 1) + SourceIndex(0) -2 >Emitted(16, 2) Source(30, 2) + SourceIndex(0) +1 >Emitted(17, 1) Source(30, 1) + SourceIndex(0) +2 >Emitted(17, 2) Source(30, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=Element.js.map=================================================================== JsFile: test.js @@ -351,13 +352,14 @@ emittedFile:tests/cases/compiler/test.js sourceFile:test.tsx ------------------------------------------------------------------- >>>"use strict"; +>>>Object.defineProperty(exports, "__esModule", { value: true }); >>>const Element_1 = require("./Element"); 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 > 2 >import { Element} from './Element'; -1 >Emitted(2, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(2, 40) Source(1, 36) + SourceIndex(0) +1 >Emitted(3, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(3, 40) Source(1, 36) + SourceIndex(0) --- >>>let c; 1 > @@ -375,10 +377,10 @@ sourceFile:test.tsx > } > } 4 > ; -1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(3, 5) Source(3, 5) + SourceIndex(0) -3 >Emitted(3, 6) Source(7, 2) + SourceIndex(0) -4 >Emitted(3, 7) Source(7, 3) + SourceIndex(0) +1 >Emitted(4, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(4, 5) Source(3, 5) + SourceIndex(0) +3 >Emitted(4, 6) Source(7, 2) + SourceIndex(0) +4 >Emitted(4, 7) Source(7, 3) + SourceIndex(0) --- >>>class A { 1-> @@ -386,7 +388,7 @@ sourceFile:test.tsx 1-> > > -1->Emitted(4, 1) Source(9, 1) + SourceIndex(0) +1->Emitted(5, 1) Source(9, 1) + SourceIndex(0) --- >>> view() { 1->^^^^ @@ -395,8 +397,8 @@ sourceFile:test.tsx 1->class A { > 2 > view -1->Emitted(5, 5) Source(10, 2) + SourceIndex(0) -2 >Emitted(5, 9) Source(10, 6) + SourceIndex(0) +1->Emitted(6, 5) Source(10, 2) + SourceIndex(0) +2 >Emitted(6, 9) Source(10, 6) + SourceIndex(0) --- >>> return [ 1->^^^^^^^^ @@ -407,9 +409,9 @@ sourceFile:test.tsx > 2 > return 3 > -1->Emitted(6, 9) Source(11, 3) + SourceIndex(0) -2 >Emitted(6, 15) Source(11, 9) + SourceIndex(0) -3 >Emitted(6, 16) Source(11, 10) + SourceIndex(0) +1->Emitted(7, 9) Source(11, 3) + SourceIndex(0) +2 >Emitted(7, 15) Source(11, 9) + SourceIndex(0) +3 >Emitted(7, 16) Source(11, 10) + SourceIndex(0) --- >>> Element_1.Element.createElement("meta", { content: "helloworld" }), 1->^^^^^^^^^^^^ @@ -425,12 +427,12 @@ sourceFile:test.tsx 4 > = 5 > "helloworld" 6 > > -1->Emitted(7, 13) Source(12, 4) + SourceIndex(0) -2 >Emitted(7, 55) Source(12, 10) + SourceIndex(0) -3 >Emitted(7, 62) Source(12, 17) + SourceIndex(0) -4 >Emitted(7, 64) Source(12, 18) + SourceIndex(0) -5 >Emitted(7, 76) Source(12, 30) + SourceIndex(0) -6 >Emitted(7, 79) Source(12, 38) + SourceIndex(0) +1->Emitted(8, 13) Source(12, 4) + SourceIndex(0) +2 >Emitted(8, 55) Source(12, 10) + SourceIndex(0) +3 >Emitted(8, 62) Source(12, 17) + SourceIndex(0) +4 >Emitted(8, 64) Source(12, 18) + SourceIndex(0) +5 >Emitted(8, 76) Source(12, 30) + SourceIndex(0) +6 >Emitted(8, 79) Source(12, 38) + SourceIndex(0) --- >>> Element_1.Element.createElement("meta", { content: c.a.b }) 1 >^^^^^^^^^^^^ @@ -454,16 +456,16 @@ sourceFile:test.tsx 8 > . 9 > b 10> }> -1 >Emitted(8, 13) Source(13, 4) + SourceIndex(0) -2 >Emitted(8, 55) Source(13, 10) + SourceIndex(0) -3 >Emitted(8, 62) Source(13, 17) + SourceIndex(0) -4 >Emitted(8, 64) Source(13, 19) + SourceIndex(0) -5 >Emitted(8, 65) Source(13, 20) + SourceIndex(0) -6 >Emitted(8, 66) Source(13, 21) + SourceIndex(0) -7 >Emitted(8, 67) Source(13, 23) + SourceIndex(0) -8 >Emitted(8, 68) Source(13, 24) + SourceIndex(0) -9 >Emitted(8, 69) Source(13, 25) + SourceIndex(0) -10>Emitted(8, 72) Source(13, 34) + SourceIndex(0) +1 >Emitted(9, 13) Source(13, 4) + SourceIndex(0) +2 >Emitted(9, 55) Source(13, 10) + SourceIndex(0) +3 >Emitted(9, 62) Source(13, 17) + SourceIndex(0) +4 >Emitted(9, 64) Source(13, 19) + SourceIndex(0) +5 >Emitted(9, 65) Source(13, 20) + SourceIndex(0) +6 >Emitted(9, 66) Source(13, 21) + SourceIndex(0) +7 >Emitted(9, 67) Source(13, 23) + SourceIndex(0) +8 >Emitted(9, 68) Source(13, 24) + SourceIndex(0) +9 >Emitted(9, 69) Source(13, 25) + SourceIndex(0) +10>Emitted(9, 72) Source(13, 34) + SourceIndex(0) --- >>> ]; 1 >^^^^^^^^^ @@ -471,8 +473,8 @@ sourceFile:test.tsx 1 > > ] 2 > ; -1 >Emitted(9, 10) Source(14, 4) + SourceIndex(0) -2 >Emitted(9, 11) Source(14, 5) + SourceIndex(0) +1 >Emitted(10, 10) Source(14, 4) + SourceIndex(0) +2 >Emitted(10, 11) Source(14, 5) + SourceIndex(0) --- >>> } 1 >^^^^ @@ -480,14 +482,14 @@ sourceFile:test.tsx 1 > > 2 > } -1 >Emitted(10, 5) Source(15, 2) + SourceIndex(0) -2 >Emitted(10, 6) Source(15, 3) + SourceIndex(0) +1 >Emitted(11, 5) Source(15, 2) + SourceIndex(0) +2 >Emitted(11, 6) Source(15, 3) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(11, 2) Source(16, 2) + SourceIndex(0) +1 >Emitted(12, 2) Source(16, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/jsxFactoryQualifiedName.symbols b/tests/baselines/reference/jsxFactoryQualifiedName.symbols index 16cd35d1ca3..f2579903d3e 100644 --- a/tests/baselines/reference/jsxFactoryQualifiedName.symbols +++ b/tests/baselines/reference/jsxFactoryQualifiedName.symbols @@ -101,12 +101,12 @@ class A { return [ , >meta : Symbol(unknown) ->content : Symbol(unknown) +>content : Symbol(content, Decl(test.tsx, 11, 8)) >meta : Symbol(unknown) >meta : Symbol(unknown) ->content : Symbol(unknown) +>content : Symbol(content, Decl(test.tsx, 12, 8)) >c.a!.b : Symbol(b, Decl(test.tsx, 3, 6)) >c.a : Symbol(a, Decl(test.tsx, 2, 8)) >c : Symbol(c, Decl(test.tsx, 2, 3)) diff --git a/tests/baselines/reference/jsxFactoryQualifiedName.types b/tests/baselines/reference/jsxFactoryQualifiedName.types index 663ba4b5bfc..724aed319ec 100644 --- a/tests/baselines/reference/jsxFactoryQualifiedName.types +++ b/tests/baselines/reference/jsxFactoryQualifiedName.types @@ -114,13 +114,13 @@ class A { , > : any >meta : any ->content : any +>content : string >meta : any > : any >meta : any ->content : any +>content : string >c.a!.b : string >c.a! : { b: string; } >c.a : { b: string; } diff --git a/tests/baselines/reference/jsxFactoryQualifiedNameResolutionError.js b/tests/baselines/reference/jsxFactoryQualifiedNameResolutionError.js index 6714b68a093..510efc97f4a 100644 --- a/tests/baselines/reference/jsxFactoryQualifiedNameResolutionError.js +++ b/tests/baselines/reference/jsxFactoryQualifiedNameResolutionError.js @@ -14,6 +14,7 @@ export class AppComponent { //// [test.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); class AppComponent { render(createElement) { return MyElement.createElement("div", null); diff --git a/tests/baselines/reference/jsxFactoryQualifiedNameResolutionError.js.map b/tests/baselines/reference/jsxFactoryQualifiedNameResolutionError.js.map index ac54c9638cd..1af641eb351 100644 --- a/tests/baselines/reference/jsxFactoryQualifiedNameResolutionError.js.map +++ b/tests/baselines/reference/jsxFactoryQualifiedNameResolutionError.js.map @@ -1,2 +1,2 @@ //// [test.js.map] -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":";AAOA;IACI,MAAM,CAAC,aAAa;QAChB,MAAM,CAAC,oCAAO,CAAC;IACnB,CAAC;CACJ;AAJD,oCAIC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":";;AAOA;IACI,MAAM,CAAC,aAAa;QAChB,MAAM,CAAC,oCAAO,CAAC;IACnB,CAAC;CACJ;AAJD,oCAIC"} \ No newline at end of file diff --git a/tests/baselines/reference/jsxFactoryQualifiedNameResolutionError.sourcemap.txt b/tests/baselines/reference/jsxFactoryQualifiedNameResolutionError.sourcemap.txt index 2616efcf63b..2f5270f3705 100644 --- a/tests/baselines/reference/jsxFactoryQualifiedNameResolutionError.sourcemap.txt +++ b/tests/baselines/reference/jsxFactoryQualifiedNameResolutionError.sourcemap.txt @@ -9,6 +9,7 @@ emittedFile:tests/cases/compiler/test.js sourceFile:test.tsx ------------------------------------------------------------------- >>>"use strict"; +>>>Object.defineProperty(exports, "__esModule", { value: true }); >>>class AppComponent { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> @@ -20,7 +21,7 @@ sourceFile:test.tsx >} > > -1 >Emitted(2, 1) Source(8, 1) + SourceIndex(0) +1 >Emitted(3, 1) Source(8, 1) + SourceIndex(0) --- >>> render(createElement) { 1->^^^^ @@ -33,10 +34,10 @@ sourceFile:test.tsx 2 > render 3 > ( 4 > createElement -1->Emitted(3, 5) Source(9, 5) + SourceIndex(0) -2 >Emitted(3, 11) Source(9, 11) + SourceIndex(0) -3 >Emitted(3, 12) Source(9, 12) + SourceIndex(0) -4 >Emitted(3, 25) Source(9, 25) + SourceIndex(0) +1->Emitted(4, 5) Source(9, 5) + SourceIndex(0) +2 >Emitted(4, 11) Source(9, 11) + SourceIndex(0) +3 >Emitted(4, 12) Source(9, 12) + SourceIndex(0) +4 >Emitted(4, 25) Source(9, 25) + SourceIndex(0) --- >>> return MyElement.createElement("div", null); 1->^^^^^^^^ @@ -50,11 +51,11 @@ sourceFile:test.tsx 3 > 4 >
5 > ; -1->Emitted(4, 9) Source(10, 9) + SourceIndex(0) -2 >Emitted(4, 15) Source(10, 15) + SourceIndex(0) -3 >Emitted(4, 16) Source(10, 16) + SourceIndex(0) -4 >Emitted(4, 52) Source(10, 23) + SourceIndex(0) -5 >Emitted(4, 53) Source(10, 24) + SourceIndex(0) +1->Emitted(5, 9) Source(10, 9) + SourceIndex(0) +2 >Emitted(5, 15) Source(10, 15) + SourceIndex(0) +3 >Emitted(5, 16) Source(10, 16) + SourceIndex(0) +4 >Emitted(5, 52) Source(10, 23) + SourceIndex(0) +5 >Emitted(5, 53) Source(10, 24) + SourceIndex(0) --- >>> } 1 >^^^^ @@ -62,15 +63,15 @@ sourceFile:test.tsx 1 > > 2 > } -1 >Emitted(5, 5) Source(11, 5) + SourceIndex(0) -2 >Emitted(5, 6) Source(11, 6) + SourceIndex(0) +1 >Emitted(6, 5) Source(11, 5) + SourceIndex(0) +2 >Emitted(6, 6) Source(11, 6) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >} -1 >Emitted(6, 2) Source(12, 2) + SourceIndex(0) +1 >Emitted(7, 2) Source(12, 2) + SourceIndex(0) --- >>>exports.AppComponent = AppComponent; 1-> @@ -81,7 +82,7 @@ sourceFile:test.tsx > return
; > } >} -1->Emitted(7, 1) Source(8, 1) + SourceIndex(0) -2 >Emitted(7, 37) Source(12, 2) + SourceIndex(0) +1->Emitted(8, 1) Source(8, 1) + SourceIndex(0) +2 >Emitted(8, 37) Source(12, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/tests/baselines/reference/jsxFactoryQualifiedNameWithEs5.js b/tests/baselines/reference/jsxFactoryQualifiedNameWithEs5.js index ecf7d13d89d..267f3eaee50 100644 --- a/tests/baselines/reference/jsxFactoryQualifiedNameWithEs5.js +++ b/tests/baselines/reference/jsxFactoryQualifiedNameWithEs5.js @@ -13,6 +13,7 @@ class Component { //// [index.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); require("./jsx"); var skate; var React = { createElement: skate.h }; diff --git a/tests/baselines/reference/jsxImportInAttribute.js b/tests/baselines/reference/jsxImportInAttribute.js index c204ea7880d..4b42ebe812d 100644 --- a/tests/baselines/reference/jsxImportInAttribute.js +++ b/tests/baselines/reference/jsxImportInAttribute.js @@ -16,6 +16,7 @@ let x = Test; // emit test_1.default //// [consumer.jsx] "use strict"; +exports.__esModule = true; /// var Test_1 = require("Test"); var x = Test_1["default"]; // emit test_1.default diff --git a/tests/baselines/reference/jsxImportInAttribute.symbols b/tests/baselines/reference/jsxImportInAttribute.symbols index 252b5cc98e4..daf4dd110a3 100644 --- a/tests/baselines/reference/jsxImportInAttribute.symbols +++ b/tests/baselines/reference/jsxImportInAttribute.symbols @@ -9,7 +9,7 @@ let x = Test; // emit test_1.default ; // ? >anything : Symbol(unknown) ->attr : Symbol(unknown) +>attr : Symbol(attr, Decl(consumer.tsx, 4, 9)) >Test : Symbol(Test, Decl(consumer.tsx, 1, 6)) === tests/cases/compiler/component.d.ts === diff --git a/tests/baselines/reference/jsxImportInAttribute.types b/tests/baselines/reference/jsxImportInAttribute.types index 8dc5c370fa8..b4317f508c2 100644 --- a/tests/baselines/reference/jsxImportInAttribute.types +++ b/tests/baselines/reference/jsxImportInAttribute.types @@ -10,7 +10,7 @@ let x = Test; // emit test_1.default ; // ? > : any >anything : any ->attr : any +>attr : typeof Test >Test : typeof Test === tests/cases/compiler/component.d.ts === diff --git a/tests/baselines/reference/jsxInExtendsClause.js b/tests/baselines/reference/jsxInExtendsClause.js index 8204067cb04..779b2d4cf8a 100644 --- a/tests/baselines/reference/jsxInExtendsClause.js +++ b/tests/baselines/reference/jsxInExtendsClause.js @@ -12,21 +12,26 @@ class Foo extends createComponentClass(() => class extends React.Component<{}, { }) {} //// [jsxInExtendsClause.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function (_super) { __extends(Foo, _super); function Foo() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Foo; }(createComponentClass(function () { return (function (_super) { __extends(class_1, _super); function class_1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } class_1.prototype.render = function () { return React.createElement("span", null, "Hello, world!"); diff --git a/tests/baselines/reference/jsxReactTestSuite.symbols b/tests/baselines/reference/jsxReactTestSuite.symbols index 956b4cff6f7..36c0eef93a8 100644 --- a/tests/baselines/reference/jsxReactTestSuite.symbols +++ b/tests/baselines/reference/jsxReactTestSuite.symbols @@ -92,26 +92,26 @@ var x = >div : Symbol(unknown) attr1={ ->attr1 : Symbol(unknown) +>attr1 : Symbol(attr1, Decl(jsxReactTestSuite.tsx, 36, 6)) "foo" + "bar" } attr2={ ->attr2 : Symbol(unknown) +>attr2 : Symbol(attr2, Decl(jsxReactTestSuite.tsx, 39, 5)) "foo" + "bar" + "baz" + "bug" } attr3={ ->attr3 : Symbol(unknown) +>attr3 : Symbol(attr3, Decl(jsxReactTestSuite.tsx, 44, 5)) "foo" + "bar" + "baz" + "bug" // Extra line here. } attr4="baz"> ->attr4 : Symbol(unknown) +>attr4 : Symbol(attr4, Decl(jsxReactTestSuite.tsx, 49, 5))
; >div : Symbol(unknown) @@ -147,13 +147,13 @@ var x = /* a multi-line comment */ attr1="foo"> ->attr1 : Symbol(unknown) +>attr1 : Symbol(attr1, Decl(jsxReactTestSuite.tsx, 68, 6)) span : Symbol(unknown) attr2="bar" ->attr2 : Symbol(unknown) +>attr2 : Symbol(attr2, Decl(jsxReactTestSuite.tsx, 72, 9)) />
@@ -175,7 +175,7 @@ var x = ; >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) ->constructor : Symbol(unknown) +>constructor : Symbol(constructor, Decl(jsxReactTestSuite.tsx, 84, 10)) ; >Namespace : Symbol(Namespace, Decl(jsxReactTestSuite.tsx, 6, 11)) @@ -186,23 +186,23 @@ var x = Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) >x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3)) ->y : Symbol(unknown) +>y : Symbol(y, Decl(jsxReactTestSuite.tsx, 90, 20)) ={2 } z />; ->z : Symbol(unknown) +>z : Symbol(z, Decl(jsxReactTestSuite.tsx, 91, 5)) Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) {...this.props} sound="moo" />; ->sound : Symbol(unknown) +>sound : Symbol(sound, Decl(jsxReactTestSuite.tsx, 94, 19)) ; >font-face : Symbol(unknown) ; >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) ->x : Symbol(unknown) +>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 98, 10)) >y : Symbol(y, Decl(jsxReactTestSuite.tsx, 9, 11)) ; @@ -215,24 +215,24 @@ var x = ; >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) >x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3)) ->y : Symbol(unknown) +>y : Symbol(y, Decl(jsxReactTestSuite.tsx, 104, 19)) ; >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) >x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3)) ->y : Symbol(unknown) ->z : Symbol(unknown) +>y : Symbol(y, Decl(jsxReactTestSuite.tsx, 106, 20)) +>z : Symbol(z, Decl(jsxReactTestSuite.tsx, 106, 26)) ; >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) ->x : Symbol(unknown) +>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 108, 10)) >y : Symbol(y, Decl(jsxReactTestSuite.tsx, 9, 11)) ; >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) ->x : Symbol(unknown) ->y : Symbol(unknown) +>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 111, 10)) +>y : Symbol(y, Decl(jsxReactTestSuite.tsx, 111, 16)) >z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11)) >z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11)) >Child : Symbol(Child, Decl(jsxReactTestSuite.tsx, 5, 11)) @@ -240,11 +240,11 @@ var x = Text; >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) ->x : Symbol(unknown) +>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 113, 10)) >z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11)) >y : Symbol(y, Decl(jsxReactTestSuite.tsx, 113, 27)) >z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11)) ->z : Symbol(unknown) +>z : Symbol(z, Decl(jsxReactTestSuite.tsx, 113, 39)) >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) diff --git a/tests/baselines/reference/jsxReactTestSuite.types b/tests/baselines/reference/jsxReactTestSuite.types index 712a7368a62..bd120ba9df2 100644 --- a/tests/baselines/reference/jsxReactTestSuite.types +++ b/tests/baselines/reference/jsxReactTestSuite.types @@ -116,7 +116,7 @@ var x = >div : any attr1={ ->attr1 : any +>attr1 : string "foo" + "bar" >"foo" + "bar" : string @@ -124,7 +124,7 @@ var x = >"bar" : "bar" } attr2={ ->attr2 : any +>attr2 : string "foo" + "bar" + >"foo" + "bar" + "baz" + "bug" : string @@ -138,7 +138,7 @@ var x = >"bug" : "bug" } attr3={ ->attr3 : any +>attr3 : string "foo" + "bar" + >"foo" + "bar" + "baz" + "bug" : string @@ -154,7 +154,7 @@ var x = // Extra line here. } attr4="baz"> ->attr4 : any +>attr4 : string
; >div : any @@ -198,14 +198,14 @@ var x = /* a multi-line comment */ attr1="foo"> ->attr1 : any +>attr1 : string : any >span : any attr2="bar" ->attr2 : any +>attr2 : string />
@@ -231,7 +231,7 @@ var x = ; > : any >Component : any ->constructor : any +>constructor : string ; > : any @@ -251,11 +251,11 @@ var x = > : any >Component : any >x : any ->y : any +>y : number ={2 } z />; >2 : 2 ->z : any +>z : true : any @@ -265,7 +265,7 @@ var x = >this.props : any >this : any >props : any ->sound : any +>sound : string ; > : any @@ -290,21 +290,21 @@ var x = > : any >Component : any >x : any ->y : any +>y : number >2 : 2 ; > : any >Component : any >x : any ->y : any +>y : number >2 : 2 ->z : any +>z : true ; > : any >Component : any ->x : any +>x : number >1 : 1 >y : any @@ -312,9 +312,9 @@ var x = ; > : any >Component : any ->x : any +>x : number >1 : 1 ->y : any +>y : string >z : any >z : any > : any @@ -324,7 +324,7 @@ var x = Text; >Text : any >Component : any ->x : any +>x : string >(z = { y: 2 }, z) : any >z = { y: 2 }, z : any >z = { y: 2 } : { y: number; } @@ -333,7 +333,7 @@ var x = >y : number >2 : 2 >z : any ->z : any +>z : number >3 : 3 >Component : any diff --git a/tests/baselines/reference/jsxViaImport.2.js b/tests/baselines/reference/jsxViaImport.2.js index 19432238e0b..187ba545fb3 100644 --- a/tests/baselines/reference/jsxViaImport.2.js +++ b/tests/baselines/reference/jsxViaImport.2.js @@ -25,17 +25,23 @@ class TestComponent extends React.Component { //// [consumer.jsx] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; /// var BaseComponent_1 = require("BaseComponent"); var TestComponent = (function (_super) { __extends(TestComponent, _super); function TestComponent() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } TestComponent.prototype.render = function () { return ; diff --git a/tests/baselines/reference/jsxViaImport.js b/tests/baselines/reference/jsxViaImport.js index 604787af744..3b291a34774 100644 --- a/tests/baselines/reference/jsxViaImport.js +++ b/tests/baselines/reference/jsxViaImport.js @@ -25,17 +25,23 @@ class TestComponent extends React.Component { //// [consumer.jsx] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; /// var BaseComponent = require("BaseComponent"); var TestComponent = (function (_super) { __extends(TestComponent, _super); function TestComponent() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } TestComponent.prototype.render = function () { return ; diff --git a/tests/baselines/reference/keepImportsInDts1.js b/tests/baselines/reference/keepImportsInDts1.js index 8189ce43088..3f945a5ebc3 100644 --- a/tests/baselines/reference/keepImportsInDts1.js +++ b/tests/baselines/reference/keepImportsInDts1.js @@ -9,6 +9,7 @@ import "test" //// [main.js] define(["require", "exports", "test"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/keepImportsInDts2.js b/tests/baselines/reference/keepImportsInDts2.js index 559b4814526..acd75a00c87 100644 --- a/tests/baselines/reference/keepImportsInDts2.js +++ b/tests/baselines/reference/keepImportsInDts2.js @@ -9,10 +9,12 @@ import "./folder/test" //// [test.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [main.js] define(["require", "exports", "./folder/test"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/keepImportsInDts3.js b/tests/baselines/reference/keepImportsInDts3.js index e48ba693726..aec2e544e2f 100644 --- a/tests/baselines/reference/keepImportsInDts3.js +++ b/tests/baselines/reference/keepImportsInDts3.js @@ -9,9 +9,11 @@ import "test" //// [outputfile.js] define("test", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); define("app/main", ["require", "exports", "test"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/keepImportsInDts4.js b/tests/baselines/reference/keepImportsInDts4.js index badec87984e..3a959bcbbac 100644 --- a/tests/baselines/reference/keepImportsInDts4.js +++ b/tests/baselines/reference/keepImportsInDts4.js @@ -9,9 +9,11 @@ import "./folder/test" //// [outputfile.js] define("folder/test", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); define("main", ["require", "exports", "folder/test"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/keyofAndIndexedAccess.js b/tests/baselines/reference/keyofAndIndexedAccess.js index 4b93897fdc4..2b1b22d3595 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.js +++ b/tests/baselines/reference/keyofAndIndexedAccess.js @@ -296,6 +296,30 @@ class C1 { } } +type S2 = { + a: string; + b: string; +}; + +function f90(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]) { + x1 = x2; + x1 = x3; + x1 = x4; + x2 = x1; + x2 = x3; + x2 = x4; + x3 = x1; + x3 = x2; + x3 = x4; + x4 = x1; + x4 = x2; + x4 = x3; + x1.length; + x2.length; + x3.length; + x4.length; +} + // Repros from #12011 class Base { @@ -429,14 +453,119 @@ type SomeMethodDescriptor = { returnValue: string[]; } -let result = dispatchMethod("someMethod", ["hello", 35]); +let result = dispatchMethod("someMethod", ["hello", 35]); + +// Repro from #13073 + +type KeyTypes = "a" | "b" +let MyThingy: { [key in KeyTypes]: string[] }; + +function addToMyThingy(key: S) { + MyThingy[key].push("a"); +} + +// Repro from #13102 + +type Handler = { + onChange: (name: keyof T) => void; +}; + +function onChangeGenericFunction(handler: Handler) { + handler.onChange('preset') +} + +// Repro from #13285 + +function updateIds, K extends string>( + obj: T, + idFields: K[], + idMapping: { [oldId: string]: string } +): Record { + for (const idField of idFields) { + const newId = idMapping[obj[idField]]; + if (newId) { + obj[idField] = newId; + } + } + return obj; +} + +// Repro from #13285 + +function updateIds2( + obj: T, + key: K, + stringMap: { [oldId: string]: string } +) { + var x = obj[key]; + stringMap[x]; // Should be OK. +} + +// Repro from #13514 + +declare function head>(list: T): T[0]; + +// Repro from #13604 + +class A { + props: T & { foo: string }; +} + +class B extends A<{ x: number}> { + f(p: this["props"]) { + p.x; + } +} + +// Repro from #13749 + +class Form { + private childFormFactories: {[K in keyof T]: (v: T[K]) => Form} + + public set(prop: K, value: T[K]) { + this.childFormFactories[prop](value) + } +} + +// Repro from #13787 + +class SampleClass

{ + public props: Readonly

; + constructor(props: P) { + this.props = Object.freeze(props); + } +} + +interface Foo { + foo: string; +} + +declare function merge(obj1: T, obj2: U): T & U; + +class AnotherSampleClass extends SampleClass { + constructor(props: T) { + const foo: Foo = { foo: "bar" }; + super(merge(props, foo)); + } + + public brokenMethod() { + this.props.foo.concat; + } +} +new AnotherSampleClass({}); + //// [keyofAndIndexedAccess.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Shape = (function () { function Shape() { } @@ -445,7 +574,7 @@ var Shape = (function () { var TaggedShape = (function (_super) { __extends(TaggedShape, _super); function TaggedShape() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return TaggedShape; }(Shape)); @@ -644,6 +773,24 @@ var C1 = (function () { }; return C1; }()); +function f90(x1, x2, x3, x4) { + x1 = x2; + x1 = x3; + x1 = x4; + x2 = x1; + x2 = x3; + x2 = x4; + x3 = x1; + x3 = x2; + x3 = x4; + x4 = x1; + x4 = x2; + x4 = x3; + x1.length; + x2.length; + x3.length; + x4.length; +} // Repros from #12011 var Base = (function () { function Base() { @@ -713,6 +860,75 @@ function f(p) { a[p].add; // any } var result = dispatchMethod("someMethod", ["hello", 35]); +var MyThingy; +function addToMyThingy(key) { + MyThingy[key].push("a"); +} +function onChangeGenericFunction(handler) { + handler.onChange('preset'); +} +// Repro from #13285 +function updateIds(obj, idFields, idMapping) { + for (var _i = 0, idFields_1 = idFields; _i < idFields_1.length; _i++) { + var idField = idFields_1[_i]; + var newId = idMapping[obj[idField]]; + if (newId) { + obj[idField] = newId; + } + } + return obj; +} +// Repro from #13285 +function updateIds2(obj, key, stringMap) { + var x = obj[key]; + stringMap[x]; // Should be OK. +} +// Repro from #13604 +var A = (function () { + function A() { + } + return A; +}()); +var B = (function (_super) { + __extends(B, _super); + function B() { + return _super !== null && _super.apply(this, arguments) || this; + } + B.prototype.f = function (p) { + p.x; + }; + return B; +}(A)); +// Repro from #13749 +var Form = (function () { + function Form() { + } + Form.prototype.set = function (prop, value) { + this.childFormFactories[prop](value); + }; + return Form; +}()); +// Repro from #13787 +var SampleClass = (function () { + function SampleClass(props) { + this.props = Object.freeze(props); + } + return SampleClass; +}()); +var AnotherSampleClass = (function (_super) { + __extends(AnotherSampleClass, _super); + function AnotherSampleClass(props) { + var _this = this; + var foo = { foo: "bar" }; + _this = _super.call(this, merge(props, foo)) || this; + return _this; + } + AnotherSampleClass.prototype.brokenMethod = function () { + this.props.foo.concat; + }; + return AnotherSampleClass; +}(SampleClass)); +new AnotherSampleClass({}); //// [keyofAndIndexedAccess.d.ts] @@ -848,6 +1064,11 @@ declare class C1 { set(key: K, value: this[K]): void; foo(): void; } +declare type S2 = { + a: string; + b: string; +}; +declare function f90(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]): void; declare class Base { get(prop: K): this[K]; set(prop: K, value: this[K]): void; @@ -920,3 +1141,49 @@ declare type SomeMethodDescriptor = { returnValue: string[]; }; declare let result: string[]; +declare type KeyTypes = "a" | "b"; +declare let MyThingy: { + [key in KeyTypes]: string[]; +}; +declare function addToMyThingy(key: S): void; +declare type Handler = { + onChange: (name: keyof T) => void; +}; +declare function onChangeGenericFunction(handler: Handler): void; +declare function updateIds, K extends string>(obj: T, idFields: K[], idMapping: { + [oldId: string]: string; +}): Record; +declare function updateIds2(obj: T, key: K, stringMap: { + [oldId: string]: string; +}): void; +declare function head>(list: T): T[0]; +declare class A { + props: T & { + foo: string; + }; +} +declare class B extends A<{ + x: number; +}> { + f(p: this["props"]): void; +} +declare class Form { + private childFormFactories; + set(prop: K, value: T[K]): void; +} +declare class SampleClass

{ + props: Readonly

; + constructor(props: P); +} +interface Foo { + foo: string; +} +declare function merge(obj1: T, obj2: U): T & U; +declare class AnotherSampleClass extends SampleClass { + constructor(props: T); + brokenMethod(): void; +} diff --git a/tests/baselines/reference/keyofAndIndexedAccess.symbols b/tests/baselines/reference/keyofAndIndexedAccess.symbols index 1c69d4959d8..f6425b5ed0e 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.symbols +++ b/tests/baselines/reference/keyofAndIndexedAccess.symbols @@ -1139,440 +1139,827 @@ class C1 { } } +type S2 = { +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) + + a: string; +>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 297, 11)) + + b: string; +>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 298, 14)) + +}; + +function f90(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]) { +>f90 : Symbol(f90, Decl(keyofAndIndexedAccess.ts, 300, 2)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 302, 13)) +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 302, 26)) +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 302, 13)) +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) +>S2 : Symbol(S2, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 302, 26)) +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 302, 13)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 302, 26)) + + x1 = x2; +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) + + x1 = x3; +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) + + x1 = x4; +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) + + x2 = x1; +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) + + x2 = x3; +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) + + x2 = x4; +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) + + x3 = x1; +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) + + x3 = x2; +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) + + x3 = x4; +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) + + x4 = x1; +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) + + x4 = x2; +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) + + x4 = x3; +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) + + x1.length; +>x1.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 302, 47)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + + x2.length; +>x2.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 302, 64)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + + x3.length; +>x3.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 302, 81)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + + x4.length; +>x4.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 302, 92)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) +} + // Repros from #12011 class Base { ->Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1)) get(prop: K) { ->get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 299, 12)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 300, 8)) ->prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 300, 30)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 300, 8)) +>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 323, 12)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 324, 8)) +>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 324, 30)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 324, 8)) return this[prop]; ->this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1)) ->prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 300, 30)) +>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1)) +>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 324, 30)) } set(prop: K, value: this[K]) { ->set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 302, 5)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 303, 8)) ->prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 303, 30)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 303, 8)) ->value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 303, 38)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 303, 8)) +>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 326, 5)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 327, 8)) +>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 327, 30)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 327, 8)) +>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 327, 38)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 327, 8)) this[prop] = value; ->this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1)) ->prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 303, 30)) ->value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 303, 38)) +>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1)) +>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 327, 30)) +>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 327, 38)) } } class Person extends Base { ->Person : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 306, 1)) ->Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>Person : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 330, 1)) +>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1)) parts: number; ->parts : Symbol(Person.parts, Decl(keyofAndIndexedAccess.ts, 308, 27)) +>parts : Symbol(Person.parts, Decl(keyofAndIndexedAccess.ts, 332, 27)) constructor(parts: number) { ->parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 310, 16)) +>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 334, 16)) super(); ->super : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1)) +>super : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 319, 1)) this.set("parts", parts); ->this.set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 302, 5)) ->this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 306, 1)) ->set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 302, 5)) ->parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 310, 16)) +>this.set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 326, 5)) +>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 330, 1)) +>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 326, 5)) +>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 334, 16)) } getParts() { ->getParts : Symbol(Person.getParts, Decl(keyofAndIndexedAccess.ts, 313, 5)) +>getParts : Symbol(Person.getParts, Decl(keyofAndIndexedAccess.ts, 337, 5)) return this.get("parts") ->this.get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 299, 12)) ->this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 306, 1)) ->get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 299, 12)) +>this.get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 323, 12)) +>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 330, 1)) +>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 323, 12)) } } class OtherPerson { ->OtherPerson : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 317, 1)) +>OtherPerson : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 341, 1)) parts: number; ->parts : Symbol(OtherPerson.parts, Decl(keyofAndIndexedAccess.ts, 319, 19)) +>parts : Symbol(OtherPerson.parts, Decl(keyofAndIndexedAccess.ts, 343, 19)) constructor(parts: number) { ->parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 321, 16)) +>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 345, 16)) setProperty(this, "parts", parts); >setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 81, 1)) ->this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 317, 1)) ->parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 321, 16)) +>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 341, 1)) +>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 345, 16)) } getParts() { ->getParts : Symbol(OtherPerson.getParts, Decl(keyofAndIndexedAccess.ts, 323, 5)) +>getParts : Symbol(OtherPerson.getParts, Decl(keyofAndIndexedAccess.ts, 347, 5)) return getProperty(this, "parts") >getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 77, 26)) ->this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 317, 1)) +>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 341, 1)) } } // Modified repro from #12544 function path(obj: T, key1: K1): T[K1]; ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 331, 16)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 331, 37)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14)) ->key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 331, 44)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 331, 16)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 331, 16)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 355, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 355, 16)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 355, 14)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 355, 37)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 355, 14)) +>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 355, 44)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 355, 16)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 355, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 355, 16)) function path(obj: T, key1: K1, key2: K2): T[K1][K2]; ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 332, 36)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 332, 61)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14)) ->key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 332, 68)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16)) ->key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 332, 78)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 332, 36)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 332, 36)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 356, 16)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 356, 36)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 356, 16)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 356, 61)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14)) +>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 356, 68)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 356, 16)) +>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 356, 78)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 356, 36)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 356, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 356, 16)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 356, 36)) function path(obj: T, key1: K1, key2: K2, key3: K3): T[K1][K2][K3]; ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16)) ->K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 333, 60)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 333, 89)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14)) ->key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 333, 96)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16)) ->key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 333, 106)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36)) ->key3 : Symbol(key3, Decl(keyofAndIndexedAccess.ts, 333, 116)) ->K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 333, 60)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36)) ->K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 333, 60)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 357, 36)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16)) +>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 357, 60)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 357, 36)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 357, 89)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14)) +>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 357, 96)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16)) +>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 357, 106)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 357, 36)) +>key3 : Symbol(key3, Decl(keyofAndIndexedAccess.ts, 357, 116)) +>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 357, 60)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 357, 14)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 357, 16)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 357, 36)) +>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 357, 60)) function path(obj: any, ...keys: (string | number)[]): any; ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 334, 14)) ->keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 334, 23)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 358, 14)) +>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 358, 23)) function path(obj: any, ...keys: (string | number)[]): any { ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 335, 14)) ->keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 335, 23)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 359, 14)) +>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 359, 23)) let result = obj; ->result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7)) ->obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 335, 14)) +>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 360, 7)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 359, 14)) for (let k of keys) { ->k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 337, 12)) ->keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 335, 23)) +>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 361, 12)) +>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 359, 23)) result = result[k]; ->result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7)) ->result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7)) ->k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 337, 12)) +>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 360, 7)) +>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 360, 7)) +>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 361, 12)) } return result; ->result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7)) +>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 360, 7)) } type Thing = { ->Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 341, 1)) +>Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 365, 1)) a: { x: number, y: string }, ->a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 343, 14)) ->x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 344, 8)) ->y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 344, 19)) +>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 367, 14)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 368, 8)) +>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 368, 19)) b: boolean ->b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 344, 32)) +>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 368, 32)) }; function f1(thing: Thing) { ->f1 : Symbol(f1, Decl(keyofAndIndexedAccess.ts, 346, 2)) ->thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12)) ->Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 341, 1)) +>f1 : Symbol(f1, Decl(keyofAndIndexedAccess.ts, 370, 2)) +>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12)) +>Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 365, 1)) let x1 = path(thing, 'a'); // { x: number, y: string } ->x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 350, 7)) ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12)) +>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 374, 7)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12)) let x2 = path(thing, 'a', 'y'); // string ->x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 351, 7)) ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12)) +>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 375, 7)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12)) let x3 = path(thing, 'b'); // boolean ->x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 352, 7)) ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12)) +>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 376, 7)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12)) let x4 = path(thing, ...['a', 'x']); // any ->x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 353, 7)) ->path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59)) ->thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12)) +>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 377, 7)) +>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 351, 1), Decl(keyofAndIndexedAccess.ts, 355, 62), Decl(keyofAndIndexedAccess.ts, 356, 100), Decl(keyofAndIndexedAccess.ts, 357, 142), Decl(keyofAndIndexedAccess.ts, 358, 59)) +>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 373, 12)) } // Repro from comment in #12114 const assignTo2 = (object: T, key1: K1, key2: K2) => ->assignTo2 : Symbol(assignTo2, Decl(keyofAndIndexedAccess.ts, 358, 5)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 358, 41)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21)) ->object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 358, 66)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19)) ->key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 358, 76)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21)) ->key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 358, 86)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 358, 41)) +>assignTo2 : Symbol(assignTo2, Decl(keyofAndIndexedAccess.ts, 382, 5)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 382, 21)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 382, 41)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 382, 21)) +>object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 382, 66)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19)) +>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 382, 76)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 382, 21)) +>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 382, 86)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 382, 41)) (value: T[K1][K2]) => object[key1][key2] = value; ->value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 359, 5)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19)) ->K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21)) ->K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 358, 41)) ->object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 358, 66)) ->key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 358, 76)) ->key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 358, 86)) ->value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 359, 5)) +>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 383, 5)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 382, 19)) +>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 382, 21)) +>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 382, 41)) +>object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 382, 66)) +>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 382, 76)) +>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 382, 86)) +>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 383, 5)) // Modified repro from #12573 declare function one(handler: (t: T) => void): T ->one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 359, 53)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 363, 21)) ->handler : Symbol(handler, Decl(keyofAndIndexedAccess.ts, 363, 24)) ->t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 363, 34)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 363, 21)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 363, 21)) +>one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 383, 53)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 387, 21)) +>handler : Symbol(handler, Decl(keyofAndIndexedAccess.ts, 387, 24)) +>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 387, 34)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 387, 21)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 387, 21)) var empty = one(() => {}) // inferred as {}, expected ->empty : Symbol(empty, Decl(keyofAndIndexedAccess.ts, 364, 3)) ->one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 359, 53)) +>empty : Symbol(empty, Decl(keyofAndIndexedAccess.ts, 388, 3)) +>one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 383, 53)) type Handlers = { [K in keyof T]: (t: T[K]) => void } ->Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 364, 25)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 366, 14)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 366, 22)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 366, 14)) ->t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 366, 38)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 366, 14)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 366, 22)) +>Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 388, 25)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 390, 14)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 390, 22)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 390, 14)) +>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 390, 38)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 390, 14)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 390, 22)) declare function on(handlerHash: Handlers): T ->on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 366, 56)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 367, 20)) ->handlerHash : Symbol(handlerHash, Decl(keyofAndIndexedAccess.ts, 367, 23)) ->Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 364, 25)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 367, 20)) ->T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 367, 20)) +>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 390, 56)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 391, 20)) +>handlerHash : Symbol(handlerHash, Decl(keyofAndIndexedAccess.ts, 391, 23)) +>Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 388, 25)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 391, 20)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 391, 20)) var hashOfEmpty1 = on({ test: () => {} }); // {} ->hashOfEmpty1 : Symbol(hashOfEmpty1, Decl(keyofAndIndexedAccess.ts, 368, 3)) ->on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 366, 56)) ->test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 368, 23)) +>hashOfEmpty1 : Symbol(hashOfEmpty1, Decl(keyofAndIndexedAccess.ts, 392, 3)) +>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 390, 56)) +>test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 392, 23)) var hashOfEmpty2 = on({ test: (x: boolean) => {} }); // { test: boolean } ->hashOfEmpty2 : Symbol(hashOfEmpty2, Decl(keyofAndIndexedAccess.ts, 369, 3)) ->on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 366, 56)) ->test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 369, 23)) ->x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 369, 31)) +>hashOfEmpty2 : Symbol(hashOfEmpty2, Decl(keyofAndIndexedAccess.ts, 393, 3)) +>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 390, 56)) +>test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 393, 23)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 393, 31)) // Repro from #12624 interface Options1 { ->Options1 : Symbol(Options1, Decl(keyofAndIndexedAccess.ts, 369, 52)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 373, 19)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 373, 24)) +>Options1 : Symbol(Options1, Decl(keyofAndIndexedAccess.ts, 393, 52)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 397, 19)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 397, 24)) data?: Data ->data : Symbol(Options1.data, Decl(keyofAndIndexedAccess.ts, 373, 36)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 373, 19)) +>data : Symbol(Options1.data, Decl(keyofAndIndexedAccess.ts, 397, 36)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 397, 19)) computed?: Computed; ->computed : Symbol(Options1.computed, Decl(keyofAndIndexedAccess.ts, 374, 15)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 373, 24)) +>computed : Symbol(Options1.computed, Decl(keyofAndIndexedAccess.ts, 398, 15)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 397, 24)) } declare class Component1 { ->Component1 : Symbol(Component1, Decl(keyofAndIndexedAccess.ts, 376, 1)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30)) +>Component1 : Symbol(Component1, Decl(keyofAndIndexedAccess.ts, 400, 1)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 402, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 402, 30)) constructor(options: Options1); ->options : Symbol(options, Decl(keyofAndIndexedAccess.ts, 379, 16)) ->Options1 : Symbol(Options1, Decl(keyofAndIndexedAccess.ts, 369, 52)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30)) +>options : Symbol(options, Decl(keyofAndIndexedAccess.ts, 403, 16)) +>Options1 : Symbol(Options1, Decl(keyofAndIndexedAccess.ts, 393, 52)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 402, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 402, 30)) get(key: K): (Data & Computed)[K]; ->get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 379, 51)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 380, 8)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30)) ->key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 380, 43)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 380, 8)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 380, 8)) +>get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 403, 51)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 404, 8)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 402, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 402, 30)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 404, 43)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 404, 8)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 402, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 402, 30)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 404, 8)) } let c1 = new Component1({ ->c1 : Symbol(c1, Decl(keyofAndIndexedAccess.ts, 383, 3)) ->Component1 : Symbol(Component1, Decl(keyofAndIndexedAccess.ts, 376, 1)) +>c1 : Symbol(c1, Decl(keyofAndIndexedAccess.ts, 407, 3)) +>Component1 : Symbol(Component1, Decl(keyofAndIndexedAccess.ts, 400, 1)) data: { ->data : Symbol(data, Decl(keyofAndIndexedAccess.ts, 383, 25)) +>data : Symbol(data, Decl(keyofAndIndexedAccess.ts, 407, 25)) hello: "" ->hello : Symbol(hello, Decl(keyofAndIndexedAccess.ts, 384, 11)) +>hello : Symbol(hello, Decl(keyofAndIndexedAccess.ts, 408, 11)) } }); c1.get("hello"); ->c1.get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 379, 51)) ->c1 : Symbol(c1, Decl(keyofAndIndexedAccess.ts, 383, 3)) ->get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 379, 51)) +>c1.get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 403, 51)) +>c1 : Symbol(c1, Decl(keyofAndIndexedAccess.ts, 407, 3)) +>get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 403, 51)) // Repro from #12625 interface Options2 { ->Options2 : Symbol(Options2, Decl(keyofAndIndexedAccess.ts, 389, 16)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 393, 19)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 393, 24)) +>Options2 : Symbol(Options2, Decl(keyofAndIndexedAccess.ts, 413, 16)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 417, 19)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 417, 24)) data?: Data ->data : Symbol(Options2.data, Decl(keyofAndIndexedAccess.ts, 393, 36)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 393, 19)) +>data : Symbol(Options2.data, Decl(keyofAndIndexedAccess.ts, 417, 36)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 417, 19)) computed?: Computed; ->computed : Symbol(Options2.computed, Decl(keyofAndIndexedAccess.ts, 394, 15)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 393, 24)) +>computed : Symbol(Options2.computed, Decl(keyofAndIndexedAccess.ts, 418, 15)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 417, 24)) } declare class Component2 { ->Component2 : Symbol(Component2, Decl(keyofAndIndexedAccess.ts, 396, 1)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30)) +>Component2 : Symbol(Component2, Decl(keyofAndIndexedAccess.ts, 420, 1)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 422, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 422, 30)) constructor(options: Options2); ->options : Symbol(options, Decl(keyofAndIndexedAccess.ts, 399, 16)) ->Options2 : Symbol(Options2, Decl(keyofAndIndexedAccess.ts, 389, 16)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30)) +>options : Symbol(options, Decl(keyofAndIndexedAccess.ts, 423, 16)) +>Options2 : Symbol(Options2, Decl(keyofAndIndexedAccess.ts, 413, 16)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 422, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 422, 30)) get(key: K): (Data & Computed)[K]; ->get : Symbol(Component2.get, Decl(keyofAndIndexedAccess.ts, 399, 51)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 400, 8)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30)) ->key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 400, 47)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 400, 8)) ->Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25)) ->Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 400, 8)) +>get : Symbol(Component2.get, Decl(keyofAndIndexedAccess.ts, 423, 51)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 424, 8)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 422, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 422, 30)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 424, 47)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 424, 8)) +>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 422, 25)) +>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 422, 30)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 424, 8)) } // Repro from #12641 interface R { ->R : Symbol(R, Decl(keyofAndIndexedAccess.ts, 401, 1)) +>R : Symbol(R, Decl(keyofAndIndexedAccess.ts, 425, 1)) p: number; ->p : Symbol(R.p, Decl(keyofAndIndexedAccess.ts, 405, 13)) +>p : Symbol(R.p, Decl(keyofAndIndexedAccess.ts, 429, 13)) } function f(p: K) { ->f : Symbol(f, Decl(keyofAndIndexedAccess.ts, 407, 1)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 409, 11)) ->R : Symbol(R, Decl(keyofAndIndexedAccess.ts, 401, 1)) ->p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 409, 30)) ->K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 409, 11)) +>f : Symbol(f, Decl(keyofAndIndexedAccess.ts, 431, 1)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 433, 11)) +>R : Symbol(R, Decl(keyofAndIndexedAccess.ts, 425, 1)) +>p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 433, 30)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 433, 11)) let a: any; ->a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 410, 7)) +>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 434, 7)) a[p].add; // any ->a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 410, 7)) ->p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 409, 30)) +>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 434, 7)) +>p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 433, 30)) } // Repro from #12651 type MethodDescriptor = { ->MethodDescriptor : Symbol(MethodDescriptor, Decl(keyofAndIndexedAccess.ts, 412, 1)) +>MethodDescriptor : Symbol(MethodDescriptor, Decl(keyofAndIndexedAccess.ts, 436, 1)) name: string; ->name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 416, 25)) +>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 440, 25)) args: any[]; ->args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 417, 14)) +>args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 441, 14)) returnValue: any; ->returnValue : Symbol(returnValue, Decl(keyofAndIndexedAccess.ts, 418, 13)) +>returnValue : Symbol(returnValue, Decl(keyofAndIndexedAccess.ts, 442, 13)) } declare function dispatchMethod(name: M['name'], args: M['args']): M['returnValue']; ->dispatchMethod : Symbol(dispatchMethod, Decl(keyofAndIndexedAccess.ts, 420, 1)) ->M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32)) ->MethodDescriptor : Symbol(MethodDescriptor, Decl(keyofAndIndexedAccess.ts, 412, 1)) ->name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 422, 60)) ->M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32)) ->args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 422, 76)) ->M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32)) ->M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32)) +>dispatchMethod : Symbol(dispatchMethod, Decl(keyofAndIndexedAccess.ts, 444, 1)) +>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 446, 32)) +>MethodDescriptor : Symbol(MethodDescriptor, Decl(keyofAndIndexedAccess.ts, 436, 1)) +>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 446, 60)) +>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 446, 32)) +>args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 446, 76)) +>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 446, 32)) +>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 446, 32)) type SomeMethodDescriptor = { ->SomeMethodDescriptor : Symbol(SomeMethodDescriptor, Decl(keyofAndIndexedAccess.ts, 422, 112)) +>SomeMethodDescriptor : Symbol(SomeMethodDescriptor, Decl(keyofAndIndexedAccess.ts, 446, 112)) name: "someMethod"; ->name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 424, 29)) +>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 448, 29)) args: [string, number]; ->args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 425, 20)) +>args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 449, 20)) returnValue: string[]; ->returnValue : Symbol(returnValue, Decl(keyofAndIndexedAccess.ts, 426, 24)) +>returnValue : Symbol(returnValue, Decl(keyofAndIndexedAccess.ts, 450, 24)) } let result = dispatchMethod("someMethod", ["hello", 35]); ->result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 430, 3)) ->dispatchMethod : Symbol(dispatchMethod, Decl(keyofAndIndexedAccess.ts, 420, 1)) ->SomeMethodDescriptor : Symbol(SomeMethodDescriptor, Decl(keyofAndIndexedAccess.ts, 422, 112)) +>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 454, 3)) +>dispatchMethod : Symbol(dispatchMethod, Decl(keyofAndIndexedAccess.ts, 444, 1)) +>SomeMethodDescriptor : Symbol(SomeMethodDescriptor, Decl(keyofAndIndexedAccess.ts, 446, 112)) + +// Repro from #13073 + +type KeyTypes = "a" | "b" +>KeyTypes : Symbol(KeyTypes, Decl(keyofAndIndexedAccess.ts, 454, 79)) + +let MyThingy: { [key in KeyTypes]: string[] }; +>MyThingy : Symbol(MyThingy, Decl(keyofAndIndexedAccess.ts, 459, 3)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 459, 17)) +>KeyTypes : Symbol(KeyTypes, Decl(keyofAndIndexedAccess.ts, 454, 79)) + +function addToMyThingy(key: S) { +>addToMyThingy : Symbol(addToMyThingy, Decl(keyofAndIndexedAccess.ts, 459, 46)) +>S : Symbol(S, Decl(keyofAndIndexedAccess.ts, 461, 23)) +>KeyTypes : Symbol(KeyTypes, Decl(keyofAndIndexedAccess.ts, 454, 79)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 461, 43)) +>S : Symbol(S, Decl(keyofAndIndexedAccess.ts, 461, 23)) + + MyThingy[key].push("a"); +>MyThingy[key].push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>MyThingy : Symbol(MyThingy, Decl(keyofAndIndexedAccess.ts, 459, 3)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 461, 43)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +} + +// Repro from #13102 + +type Handler = { +>Handler : Symbol(Handler, Decl(keyofAndIndexedAccess.ts, 463, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 467, 13)) + + onChange: (name: keyof T) => void; +>onChange : Symbol(onChange, Decl(keyofAndIndexedAccess.ts, 467, 19)) +>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 468, 15)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 467, 13)) + +}; + +function onChangeGenericFunction(handler: Handler) { +>onChangeGenericFunction : Symbol(onChangeGenericFunction, Decl(keyofAndIndexedAccess.ts, 469, 2)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 471, 33)) +>handler : Symbol(handler, Decl(keyofAndIndexedAccess.ts, 471, 36)) +>Handler : Symbol(Handler, Decl(keyofAndIndexedAccess.ts, 463, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 471, 33)) +>preset : Symbol(preset, Decl(keyofAndIndexedAccess.ts, 471, 58)) + + handler.onChange('preset') +>handler.onChange : Symbol(onChange, Decl(keyofAndIndexedAccess.ts, 467, 19)) +>handler : Symbol(handler, Decl(keyofAndIndexedAccess.ts, 471, 36)) +>onChange : Symbol(onChange, Decl(keyofAndIndexedAccess.ts, 467, 19)) +} + +// Repro from #13285 + +function updateIds, K extends string>( +>updateIds : Symbol(updateIds, Decl(keyofAndIndexedAccess.ts, 473, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 477, 19)) +>Record : Symbol(Record, Decl(lib.d.ts, --, --)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 477, 47)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 477, 47)) + + obj: T, +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 477, 66)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 477, 19)) + + idFields: K[], +>idFields : Symbol(idFields, Decl(keyofAndIndexedAccess.ts, 478, 11)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 477, 47)) + + idMapping: { [oldId: string]: string } +>idMapping : Symbol(idMapping, Decl(keyofAndIndexedAccess.ts, 479, 18)) +>oldId : Symbol(oldId, Decl(keyofAndIndexedAccess.ts, 480, 18)) + +): Record { +>Record : Symbol(Record, Decl(lib.d.ts, --, --)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 477, 47)) + + for (const idField of idFields) { +>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 482, 14)) +>idFields : Symbol(idFields, Decl(keyofAndIndexedAccess.ts, 478, 11)) + + const newId = idMapping[obj[idField]]; +>newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 483, 13)) +>idMapping : Symbol(idMapping, Decl(keyofAndIndexedAccess.ts, 479, 18)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 477, 66)) +>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 482, 14)) + + if (newId) { +>newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 483, 13)) + + obj[idField] = newId; +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 477, 66)) +>idField : Symbol(idField, Decl(keyofAndIndexedAccess.ts, 482, 14)) +>newId : Symbol(newId, Decl(keyofAndIndexedAccess.ts, 483, 13)) + } + } + return obj; +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 477, 66)) +} + +// Repro from #13285 + +function updateIds2( +>updateIds2 : Symbol(updateIds2, Decl(keyofAndIndexedAccess.ts, 489, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 493, 20)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 493, 33)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 493, 54)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 493, 20)) + + obj: T, +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 493, 74)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 493, 20)) + + key: K, +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 494, 11)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 493, 54)) + + stringMap: { [oldId: string]: string } +>stringMap : Symbol(stringMap, Decl(keyofAndIndexedAccess.ts, 495, 11)) +>oldId : Symbol(oldId, Decl(keyofAndIndexedAccess.ts, 496, 18)) + +) { + var x = obj[key]; +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 498, 7)) +>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 493, 74)) +>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 494, 11)) + + stringMap[x]; // Should be OK. +>stringMap : Symbol(stringMap, Decl(keyofAndIndexedAccess.ts, 495, 11)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 498, 7)) +} + +// Repro from #13514 + +declare function head>(list: T): T[0]; +>head : Symbol(head, Decl(keyofAndIndexedAccess.ts, 500, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 504, 22)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>list : Symbol(list, Decl(keyofAndIndexedAccess.ts, 504, 44)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 504, 22)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 504, 22)) + +// Repro from #13604 + +class A { +>A : Symbol(A, Decl(keyofAndIndexedAccess.ts, 504, 59)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 508, 8)) + + props: T & { foo: string }; +>props : Symbol(A.props, Decl(keyofAndIndexedAccess.ts, 508, 12)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 508, 8)) +>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 509, 13)) +} + +class B extends A<{ x: number}> { +>B : Symbol(B, Decl(keyofAndIndexedAccess.ts, 510, 1)) +>A : Symbol(A, Decl(keyofAndIndexedAccess.ts, 504, 59)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 512, 19)) + + f(p: this["props"]) { +>f : Symbol(B.f, Decl(keyofAndIndexedAccess.ts, 512, 33)) +>p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 513, 3)) + + p.x; +>p.x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 512, 19)) +>p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 513, 3)) +>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 512, 19)) + } +} + +// Repro from #13749 + +class Form { +>Form : Symbol(Form, Decl(keyofAndIndexedAccess.ts, 516, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 520, 11)) + + private childFormFactories: {[K in keyof T]: (v: T[K]) => Form} +>childFormFactories : Symbol(Form.childFormFactories, Decl(keyofAndIndexedAccess.ts, 520, 15)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 521, 34)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 520, 11)) +>v : Symbol(v, Decl(keyofAndIndexedAccess.ts, 521, 50)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 520, 11)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 521, 34)) +>Form : Symbol(Form, Decl(keyofAndIndexedAccess.ts, 516, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 520, 11)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 521, 34)) + + public set(prop: K, value: T[K]) { +>set : Symbol(Form.set, Decl(keyofAndIndexedAccess.ts, 521, 73)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 523, 15)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 520, 11)) +>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 523, 34)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 523, 15)) +>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 523, 42)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 520, 11)) +>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 523, 15)) + + this.childFormFactories[prop](value) +>this.childFormFactories : Symbol(Form.childFormFactories, Decl(keyofAndIndexedAccess.ts, 520, 15)) +>this : Symbol(Form, Decl(keyofAndIndexedAccess.ts, 516, 1)) +>childFormFactories : Symbol(Form.childFormFactories, Decl(keyofAndIndexedAccess.ts, 520, 15)) +>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 523, 34)) +>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 523, 42)) + } +} + +// Repro from #13787 + +class SampleClass

{ +>SampleClass : Symbol(SampleClass, Decl(keyofAndIndexedAccess.ts, 526, 1)) +>P : Symbol(P, Decl(keyofAndIndexedAccess.ts, 530, 18)) + + public props: Readonly

; +>props : Symbol(SampleClass.props, Decl(keyofAndIndexedAccess.ts, 530, 22)) +>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --)) +>P : Symbol(P, Decl(keyofAndIndexedAccess.ts, 530, 18)) + + constructor(props: P) { +>props : Symbol(props, Decl(keyofAndIndexedAccess.ts, 532, 16)) +>P : Symbol(P, Decl(keyofAndIndexedAccess.ts, 530, 18)) + + this.props = Object.freeze(props); +>this.props : Symbol(SampleClass.props, Decl(keyofAndIndexedAccess.ts, 530, 22)) +>this : Symbol(SampleClass, Decl(keyofAndIndexedAccess.ts, 526, 1)) +>props : Symbol(SampleClass.props, Decl(keyofAndIndexedAccess.ts, 530, 22)) +>Object.freeze : Symbol(ObjectConstructor.freeze, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>freeze : Symbol(ObjectConstructor.freeze, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>props : Symbol(props, Decl(keyofAndIndexedAccess.ts, 532, 16)) + } +} + +interface Foo { +>Foo : Symbol(Foo, Decl(keyofAndIndexedAccess.ts, 535, 1)) + + foo: string; +>foo : Symbol(Foo.foo, Decl(keyofAndIndexedAccess.ts, 537, 15)) +} + +declare function merge(obj1: T, obj2: U): T & U; +>merge : Symbol(merge, Decl(keyofAndIndexedAccess.ts, 539, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 541, 23)) +>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 541, 25)) +>obj1 : Symbol(obj1, Decl(keyofAndIndexedAccess.ts, 541, 29)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 541, 23)) +>obj2 : Symbol(obj2, Decl(keyofAndIndexedAccess.ts, 541, 37)) +>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 541, 25)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 541, 23)) +>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 541, 25)) + +class AnotherSampleClass extends SampleClass { +>AnotherSampleClass : Symbol(AnotherSampleClass, Decl(keyofAndIndexedAccess.ts, 541, 54)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 543, 25)) +>SampleClass : Symbol(SampleClass, Decl(keyofAndIndexedAccess.ts, 526, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 543, 25)) +>Foo : Symbol(Foo, Decl(keyofAndIndexedAccess.ts, 535, 1)) + + constructor(props: T) { +>props : Symbol(props, Decl(keyofAndIndexedAccess.ts, 544, 16)) +>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 543, 25)) + + const foo: Foo = { foo: "bar" }; +>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 545, 13)) +>Foo : Symbol(Foo, Decl(keyofAndIndexedAccess.ts, 535, 1)) +>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 545, 26)) + + super(merge(props, foo)); +>super : Symbol(SampleClass, Decl(keyofAndIndexedAccess.ts, 526, 1)) +>merge : Symbol(merge, Decl(keyofAndIndexedAccess.ts, 539, 1)) +>props : Symbol(props, Decl(keyofAndIndexedAccess.ts, 544, 16)) +>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 545, 13)) + } + + public brokenMethod() { +>brokenMethod : Symbol(AnotherSampleClass.brokenMethod, Decl(keyofAndIndexedAccess.ts, 547, 5)) + + this.props.foo.concat; +>this.props.foo.concat : Symbol(String.concat, Decl(lib.d.ts, --, --)) +>this.props.foo : Symbol(foo) +>this.props : Symbol(SampleClass.props, Decl(keyofAndIndexedAccess.ts, 530, 22)) +>this : Symbol(AnotherSampleClass, Decl(keyofAndIndexedAccess.ts, 541, 54)) +>props : Symbol(SampleClass.props, Decl(keyofAndIndexedAccess.ts, 530, 22)) +>foo : Symbol(foo) +>concat : Symbol(String.concat, Decl(lib.d.ts, --, --)) + } +} +new AnotherSampleClass({}); +>AnotherSampleClass : Symbol(AnotherSampleClass, Decl(keyofAndIndexedAccess.ts, 541, 54)) diff --git a/tests/baselines/reference/keyofAndIndexedAccess.types b/tests/baselines/reference/keyofAndIndexedAccess.types index f94249806f6..86469efc284 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.types +++ b/tests/baselines/reference/keyofAndIndexedAccess.types @@ -1385,6 +1385,117 @@ class C1 { } } +type S2 = { +>S2 : S2 + + a: string; +>a : string + + b: string; +>b : string + +}; + +function f90(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K], x4: T[K]) { +>f90 : (x1: string, x2: T["a" | "b"], x3: S2[K], x4: T[K]) => void +>T : T +>S2 : S2 +>K : K +>S2 : S2 +>x1 : string +>S2 : S2 +>S2 : S2 +>x2 : T["a" | "b"] +>T : T +>S2 : S2 +>x3 : S2[K] +>S2 : S2 +>K : K +>x4 : T[K] +>T : T +>K : K + + x1 = x2; +>x1 = x2 : T["a" | "b"] +>x1 : string +>x2 : T["a" | "b"] + + x1 = x3; +>x1 = x3 : S2[K] +>x1 : string +>x3 : S2[K] + + x1 = x4; +>x1 = x4 : T[K] +>x1 : string +>x4 : T[K] + + x2 = x1; +>x2 = x1 : string +>x2 : T["a" | "b"] +>x1 : string + + x2 = x3; +>x2 = x3 : S2[K] +>x2 : T["a" | "b"] +>x3 : S2[K] + + x2 = x4; +>x2 = x4 : T[K] +>x2 : T["a" | "b"] +>x4 : T[K] + + x3 = x1; +>x3 = x1 : string +>x3 : S2[K] +>x1 : string + + x3 = x2; +>x3 = x2 : T["a" | "b"] +>x3 : S2[K] +>x2 : T["a" | "b"] + + x3 = x4; +>x3 = x4 : T[K] +>x3 : S2[K] +>x4 : T[K] + + x4 = x1; +>x4 = x1 : string +>x4 : T[K] +>x1 : string + + x4 = x2; +>x4 = x2 : T["a" | "b"] +>x4 : T[K] +>x2 : T["a" | "b"] + + x4 = x3; +>x4 = x3 : S2[K] +>x4 : T[K] +>x3 : S2[K] + + x1.length; +>x1.length : number +>x1 : string +>length : number + + x2.length; +>x2.length : number +>x2 : T["a" | "b"] +>length : number + + x3.length; +>x3.length : number +>x3 : S2[K] +>length : number + + x4.length; +>x4.length : number +>x4 : T[K] +>length : number +} + // Repros from #12011 class Base { @@ -1875,3 +1986,312 @@ let result = dispatchMethod("someMethod", ["hello", 35]); >"hello" : "hello" >35 : 35 +// Repro from #13073 + +type KeyTypes = "a" | "b" +>KeyTypes : "a" | "b" + +let MyThingy: { [key in KeyTypes]: string[] }; +>MyThingy : { a: string[]; b: string[]; } +>key : key +>KeyTypes : "a" | "b" + +function addToMyThingy(key: S) { +>addToMyThingy : (key: S) => void +>S : S +>KeyTypes : "a" | "b" +>key : S +>S : S + + MyThingy[key].push("a"); +>MyThingy[key].push("a") : number +>MyThingy[key].push : (...items: string[]) => number +>MyThingy[key] : { a: string[]; b: string[]; }[S] +>MyThingy : { a: string[]; b: string[]; } +>key : S +>push : (...items: string[]) => number +>"a" : "a" +} + +// Repro from #13102 + +type Handler = { +>Handler : Handler +>T : T + + onChange: (name: keyof T) => void; +>onChange : (name: keyof T) => void +>name : keyof T +>T : T + +}; + +function onChangeGenericFunction(handler: Handler) { +>onChangeGenericFunction : (handler: Handler) => void +>T : T +>handler : Handler +>Handler : Handler +>T : T +>preset : number + + handler.onChange('preset') +>handler.onChange('preset') : void +>handler.onChange : (name: keyof (T & { preset: number; })) => void +>handler : Handler +>onChange : (name: keyof (T & { preset: number; })) => void +>'preset' : "preset" +} + +// Repro from #13285 + +function updateIds, K extends string>( +>updateIds : , K extends string>(obj: T, idFields: K[], idMapping: { [oldId: string]: string; }) => Record +>T : T +>Record : Record +>K : K +>K : K + + obj: T, +>obj : T +>T : T + + idFields: K[], +>idFields : K[] +>K : K + + idMapping: { [oldId: string]: string } +>idMapping : { [oldId: string]: string; } +>oldId : string + +): Record { +>Record : Record +>K : K + + for (const idField of idFields) { +>idField : K +>idFields : K[] + + const newId = idMapping[obj[idField]]; +>newId : { [oldId: string]: string; }[T[K]] +>idMapping[obj[idField]] : { [oldId: string]: string; }[T[K]] +>idMapping : { [oldId: string]: string; } +>obj[idField] : T[K] +>obj : T +>idField : K + + if (newId) { +>newId : { [oldId: string]: string; }[T[K]] + + obj[idField] = newId; +>obj[idField] = newId : { [oldId: string]: string; }[T[K]] +>obj[idField] : T[K] +>obj : T +>idField : K +>newId : { [oldId: string]: string; }[T[K]] + } + } + return obj; +>obj : T +} + +// Repro from #13285 + +function updateIds2( +>updateIds2 : (obj: T, key: K, stringMap: { [oldId: string]: string; }) => void +>T : T +>x : string +>K : K +>T : T + + obj: T, +>obj : T +>T : T + + key: K, +>key : K +>K : K + + stringMap: { [oldId: string]: string } +>stringMap : { [oldId: string]: string; } +>oldId : string + +) { + var x = obj[key]; +>x : T[K] +>obj[key] : T[K] +>obj : T +>key : K + + stringMap[x]; // Should be OK. +>stringMap[x] : { [oldId: string]: string; }[T[K]] +>stringMap : { [oldId: string]: string; } +>x : T[K] +} + +// Repro from #13514 + +declare function head>(list: T): T[0]; +>head : (list: T) => T[0] +>T : T +>Array : T[] +>list : T +>T : T +>T : T + +// Repro from #13604 + +class A { +>A : A +>T : T + + props: T & { foo: string }; +>props : T & { foo: string; } +>T : T +>foo : string +} + +class B extends A<{ x: number}> { +>B : B +>A : A<{ x: number; }> +>x : number + + f(p: this["props"]) { +>f : (p: this["props"]) => void +>p : this["props"] + + p.x; +>p.x : number +>p : this["props"] +>x : number + } +} + +// Repro from #13749 + +class Form { +>Form : Form +>T : T + + private childFormFactories: {[K in keyof T]: (v: T[K]) => Form} +>childFormFactories : { [K in keyof T]: (v: T[K]) => Form; } +>K : K +>T : T +>v : T[K] +>T : T +>K : K +>Form : Form +>T : T +>K : K + + public set(prop: K, value: T[K]) { +>set : (prop: K, value: T[K]) => void +>K : K +>T : T +>prop : K +>K : K +>value : T[K] +>T : T +>K : K + + this.childFormFactories[prop](value) +>this.childFormFactories[prop](value) : Form +>this.childFormFactories[prop] : (v: T[K]) => Form +>this.childFormFactories : { [K in keyof T]: (v: T[K]) => Form; } +>this : this +>childFormFactories : { [K in keyof T]: (v: T[K]) => Form; } +>prop : K +>value : T[K] + } +} + +// Repro from #13787 + +class SampleClass

{ +>SampleClass : SampleClass

+>P : P + + public props: Readonly

; +>props : Readonly

+>Readonly : Readonly +>P : P + + constructor(props: P) { +>props : P +>P : P + + this.props = Object.freeze(props); +>this.props = Object.freeze(props) : Readonly

+>this.props : Readonly

+>this : this +>props : Readonly

+>Object.freeze(props) : Readonly

+>Object.freeze : { (a: T[]): ReadonlyArray; (f: T): T; (o: T): Readonly; } +>Object : ObjectConstructor +>freeze : { (a: T[]): ReadonlyArray; (f: T): T; (o: T): Readonly; } +>props : P + } +} + +interface Foo { +>Foo : Foo + + foo: string; +>foo : string +} + +declare function merge(obj1: T, obj2: U): T & U; +>merge : (obj1: T, obj2: U) => T & U +>T : T +>U : U +>obj1 : T +>T : T +>obj2 : U +>U : U +>T : T +>U : U + +class AnotherSampleClass extends SampleClass { +>AnotherSampleClass : AnotherSampleClass +>T : T +>SampleClass : SampleClass +>T : T +>Foo : Foo + + constructor(props: T) { +>props : T +>T : T + + const foo: Foo = { foo: "bar" }; +>foo : Foo +>Foo : Foo +>{ foo: "bar" } : { foo: string; } +>foo : string +>"bar" : "bar" + + super(merge(props, foo)); +>super(merge(props, foo)) : void +>super : typeof SampleClass +>merge(props, foo) : T & Foo +>merge : (obj1: T, obj2: U) => T & U +>props : T +>foo : Foo + } + + public brokenMethod() { +>brokenMethod : () => void + + this.props.foo.concat; +>this.props.foo.concat : (...strings: string[]) => string +>this.props.foo : (T & Foo)["foo"] +>this.props : Readonly +>this : this +>props : Readonly +>foo : (T & Foo)["foo"] +>concat : (...strings: string[]) => string + } +} +new AnotherSampleClass({}); +>new AnotherSampleClass({}) : AnotherSampleClass<{}> +>AnotherSampleClass : typeof AnotherSampleClass +>{} : {} + diff --git a/tests/baselines/reference/keywordInJsxIdentifier.symbols b/tests/baselines/reference/keywordInJsxIdentifier.symbols index 3cb977bee81..73ee7376164 100644 --- a/tests/baselines/reference/keywordInJsxIdentifier.symbols +++ b/tests/baselines/reference/keywordInJsxIdentifier.symbols @@ -5,17 +5,17 @@ declare var React: any; ; >foo : Symbol(unknown) ->class-id : Symbol(unknown) +>class-id : Symbol(class-id, Decl(keywordInJsxIdentifier.tsx, 2, 4)) ; >foo : Symbol(unknown) ->class : Symbol(unknown) +>class : Symbol(class, Decl(keywordInJsxIdentifier.tsx, 3, 4)) ; >foo : Symbol(unknown) ->class-id : Symbol(unknown) +>class-id : Symbol(class-id, Decl(keywordInJsxIdentifier.tsx, 4, 4)) ; >foo : Symbol(unknown) ->class : Symbol(unknown) +>class : Symbol(class, Decl(keywordInJsxIdentifier.tsx, 5, 4)) diff --git a/tests/baselines/reference/keywordInJsxIdentifier.types b/tests/baselines/reference/keywordInJsxIdentifier.types index 745fa5998b5..0e4c4387cf4 100644 --- a/tests/baselines/reference/keywordInJsxIdentifier.types +++ b/tests/baselines/reference/keywordInJsxIdentifier.types @@ -6,20 +6,20 @@ declare var React: any; ; > : any >foo : any ->class-id : any +>class-id : true ; > : any >foo : any ->class : any +>class : true ; > : any >foo : any ->class-id : any +>class-id : string ; > : any >foo : any ->class : any +>class : string diff --git a/tests/baselines/reference/lambdaArgCrash.js b/tests/baselines/reference/lambdaArgCrash.js index 47db7f3ce64..9a903b513d9 100644 --- a/tests/baselines/reference/lambdaArgCrash.js +++ b/tests/baselines/reference/lambdaArgCrash.js @@ -35,11 +35,16 @@ class ItemSetEvent extends Event { //// [lambdaArgCrash.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Event = (function () { function Event() { // TODO: remove @@ -56,7 +61,7 @@ var Event = (function () { var ItemSetEvent = (function (_super) { __extends(ItemSetEvent, _super); function ItemSetEvent() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } ItemSetEvent.prototype.add = function (listener) { _super.prototype.add.call(this, listener); diff --git a/tests/baselines/reference/library-reference-12.trace.json b/tests/baselines/reference/library-reference-12.trace.json index 14e46647d6d..75b53d589ee 100644 --- a/tests/baselines/reference/library-reference-12.trace.json +++ b/tests/baselines/reference/library-reference-12.trace.json @@ -5,6 +5,7 @@ "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", "File '/a/node_modules/jquery.d.ts' does not exist.", "Found 'package.json' at '/a/node_modules/jquery/package.json'.", + "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'dist/jquery.d.ts' that references '/a/node_modules/jquery/dist/jquery.d.ts'.", "File '/a/node_modules/jquery/dist/jquery.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/a/node_modules/jquery/dist/jquery.d.ts', result '/a/node_modules/jquery/dist/jquery.d.ts'", diff --git a/tests/baselines/reference/library-reference-2.trace.json b/tests/baselines/reference/library-reference-2.trace.json index 8837f2c9cb1..ef0936a35a2 100644 --- a/tests/baselines/reference/library-reference-2.trace.json +++ b/tests/baselines/reference/library-reference-2.trace.json @@ -2,6 +2,7 @@ "======== Resolving type reference directive 'jquery', containing file '/consumer.ts', root directory '/types'. ========", "Resolving with primary search path '/types'", "Found 'package.json' at '/types/jquery/package.json'.", + "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.", "File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/jquery/jquery.d.ts', result '/types/jquery/jquery.d.ts'", @@ -9,6 +10,7 @@ "======== Resolving type reference directive 'jquery', containing file 'test/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'", "Found 'package.json' at '/types/jquery/package.json'.", + "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.", "File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/jquery/jquery.d.ts', result '/types/jquery/jquery.d.ts'", diff --git a/tests/baselines/reference/lift.js b/tests/baselines/reference/lift.js index 364d52d9385..80eebe9cb00 100644 --- a/tests/baselines/reference/lift.js +++ b/tests/baselines/reference/lift.js @@ -18,11 +18,16 @@ class C extends B { //// [lift.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B(y) { this.y = y; diff --git a/tests/baselines/reference/literals.errors.txt b/tests/baselines/reference/literals.errors.txt index 6fa1d7d3abd..ae058e0b530 100644 --- a/tests/baselines/reference/literals.errors.txt +++ b/tests/baselines/reference/literals.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/expressions/literals/literals.ts(9,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/literals/literals.ts(9,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/literals/literals.ts(10,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/literals/literals.ts(10,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/literals/literals.ts(9,10): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/literals/literals.ts(9,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/literals/literals.ts(10,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/literals/literals.ts(10,21): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/literals/literals.ts(20,9): error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '0o1'. tests/cases/conformance/expressions/literals/literals.ts(25,9): error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '-0o3'. @@ -17,14 +17,14 @@ tests/cases/conformance/expressions/literals/literals.ts(25,9): error TS1085: Oc var nu = null / null; ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var u = undefined / undefined; ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var b: boolean; var b = true; diff --git a/tests/baselines/reference/localAliasExportAssignment.js b/tests/baselines/reference/localAliasExportAssignment.js index 46ca09c2caa..f198c0f9ea7 100644 --- a/tests/baselines/reference/localAliasExportAssignment.js +++ b/tests/baselines/reference/localAliasExportAssignment.js @@ -22,6 +22,7 @@ var server; module.exports = server; //// [localAliasExportAssignment_1.js] "use strict"; +exports.__esModule = true; /// var connect = require("./localAliasExportAssignment_0"); connect(); diff --git a/tests/baselines/reference/localTypes1.js b/tests/baselines/reference/localTypes1.js index 100452b7a96..d356bd58e20 100644 --- a/tests/baselines/reference/localTypes1.js +++ b/tests/baselines/reference/localTypes1.js @@ -142,11 +142,16 @@ function f6() { //// [localTypes1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function f1() { var E; (function (E) { @@ -300,7 +305,7 @@ function f6() { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -308,7 +313,7 @@ function f6() { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); diff --git a/tests/baselines/reference/logicalNotOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/logicalNotOperatorWithAnyOtherType.errors.txt index 02b4bf16fd2..0cb9869ca4c 100644 --- a/tests/baselines/reference/logicalNotOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/logicalNotOperatorWithAnyOtherType.errors.txt @@ -1,10 +1,13 @@ -tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(45,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(46,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(47,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(45,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(45,34): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(46,27): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(46,34): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(47,27): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(47,39): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(57,1): error TS2695: Left side of comma operator is unused and has no side effects. -==== tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts (4 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts (7 errors) ==== // ! operator on any type var ANY: any; @@ -50,14 +53,20 @@ tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNot var ResultIsBoolean15 = !A.foo(); var ResultIsBoolean16 = !(ANY + ANY1); var ResultIsBoolean17 = !(null + undefined); - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsBoolean18 = !(null + null); - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsBoolean19 = !(undefined + undefined); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // multiple ! operators var ResultIsBoolean20 = !!ANY; diff --git a/tests/baselines/reference/m7Bugs.js b/tests/baselines/reference/m7Bugs.js index e5a4d11f00c..d5fd319b993 100644 --- a/tests/baselines/reference/m7Bugs.js +++ b/tests/baselines/reference/m7Bugs.js @@ -27,11 +27,16 @@ var y3: C1 = {}; //// [m7Bugs.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var s = ({}); var x = {}; var C1 = (function () { @@ -42,7 +47,7 @@ var C1 = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(C1)); diff --git a/tests/baselines/reference/mapOnTupleTypes01.js b/tests/baselines/reference/mapOnTupleTypes01.js index cb1de5fdc61..9f22aa63753 100644 --- a/tests/baselines/reference/mapOnTupleTypes01.js +++ b/tests/baselines/reference/mapOnTupleTypes01.js @@ -44,6 +44,7 @@ export let h = numNumNumNumNum.map(n => n * n); //// [mapOnTupleTypes01.js] "use strict"; +exports.__esModule = true; exports.mapOnLooseArrayLiteral = [1, 2, 3, 4].map(function (n) { return n * n; }); // Length 1 var numTuple = [1]; diff --git a/tests/baselines/reference/mapOnTupleTypes02.js b/tests/baselines/reference/mapOnTupleTypes02.js index 97ffc9510db..ca835751a7a 100644 --- a/tests/baselines/reference/mapOnTupleTypes02.js +++ b/tests/baselines/reference/mapOnTupleTypes02.js @@ -8,6 +8,7 @@ export function increment(point: Point) { //// [mapOnTupleTypes02.js] "use strict"; +exports.__esModule = true; function increment(point) { return point.map(function (d) { return d + 1; }); } diff --git a/tests/baselines/reference/mappedTypeErrors.errors.txt b/tests/baselines/reference/mappedTypeErrors.errors.txt index 94644a96af9..c7571295521 100644 --- a/tests/baselines/reference/mappedTypeErrors.errors.txt +++ b/tests/baselines/reference/mappedTypeErrors.errors.txt @@ -45,7 +45,7 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(130,5): error TS2322: T tests/cases/conformance/types/mapped/mappedTypeErrors.ts(131,5): error TS2322: Type '{ a: string; }' is not assignable to type '{ [x: string]: any; a?: number | undefined; }'. Types of property 'a' are incompatible. Type 'string' is not assignable to type 'number | undefined'. -tests/cases/conformance/types/mapped/mappedTypeErrors.ts(137,16): error TS2322: Type '{}' is not assignable to type 'string'. +tests/cases/conformance/types/mapped/mappedTypeErrors.ts(137,16): error TS2322: Type 'T' is not assignable to type 'string'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(137,21): error TS2536: Type 'P' cannot be used to index type 'T'. @@ -259,7 +259,7 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(137,21): error TS2536: pf: {[P in F]?: T[P]}, pt: {[P in T]?: T[P]}, // note: should be in keyof T ~ -!!! error TS2322: Type '{}' is not assignable to type 'string'. +!!! error TS2322: Type 'T' is not assignable to type 'string'. ~~~~ !!! error TS2536: Type 'P' cannot be used to index type 'T'. }; diff --git a/tests/baselines/reference/mappedTypeNestedGenericInstantiation.js b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.js new file mode 100644 index 00000000000..f70130a84d5 --- /dev/null +++ b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.js @@ -0,0 +1,19 @@ +//// [mappedTypeNestedGenericInstantiation.ts] +// Repro from #13346 + +interface Chainable { + value(): T; + mapValues(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>; +} + +declare function chain(t: T): Chainable; + +const square = (x: number) => x * x; + +const v = chain({a: 1, b: 2}).mapValues(square).value(); + + +//// [mappedTypeNestedGenericInstantiation.js] +// Repro from #13346 +var square = function (x) { return x * x; }; +var v = chain({ a: 1, b: 2 }).mapValues(square).value(); diff --git a/tests/baselines/reference/mappedTypeNestedGenericInstantiation.symbols b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.symbols new file mode 100644 index 00000000000..0ec4f50bedc --- /dev/null +++ b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.symbols @@ -0,0 +1,50 @@ +=== tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts === +// Repro from #13346 + +interface Chainable { +>Chainable : Symbol(Chainable, Decl(mappedTypeNestedGenericInstantiation.ts, 0, 0)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20)) + + value(): T; +>value : Symbol(Chainable.value, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 24)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20)) + + mapValues(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>; +>mapValues : Symbol(Chainable.mapValues, Decl(mappedTypeNestedGenericInstantiation.ts, 3, 13)) +>U : Symbol(U, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 12)) +>func : Symbol(func, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 15)) +>v : Symbol(v, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 22)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20)) +>U : Symbol(U, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 12)) +>Chainable : Symbol(Chainable, Decl(mappedTypeNestedGenericInstantiation.ts, 0, 0)) +>k : Symbol(k, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 56)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 20)) +>U : Symbol(U, Decl(mappedTypeNestedGenericInstantiation.ts, 4, 12)) +} + +declare function chain(t: T): Chainable; +>chain : Symbol(chain, Decl(mappedTypeNestedGenericInstantiation.ts, 5, 1)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 23)) +>t : Symbol(t, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 26)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 23)) +>Chainable : Symbol(Chainable, Decl(mappedTypeNestedGenericInstantiation.ts, 0, 0)) +>T : Symbol(T, Decl(mappedTypeNestedGenericInstantiation.ts, 7, 23)) + +const square = (x: number) => x * x; +>square : Symbol(square, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 5)) +>x : Symbol(x, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 16)) +>x : Symbol(x, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 16)) +>x : Symbol(x, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 16)) + +const v = chain({a: 1, b: 2}).mapValues(square).value(); +>v : Symbol(v, Decl(mappedTypeNestedGenericInstantiation.ts, 11, 5)) +>chain({a: 1, b: 2}).mapValues(square).value : Symbol(Chainable.value, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 24)) +>chain({a: 1, b: 2}).mapValues : Symbol(Chainable.mapValues, Decl(mappedTypeNestedGenericInstantiation.ts, 3, 13)) +>chain : Symbol(chain, Decl(mappedTypeNestedGenericInstantiation.ts, 5, 1)) +>a : Symbol(a, Decl(mappedTypeNestedGenericInstantiation.ts, 11, 17)) +>b : Symbol(b, Decl(mappedTypeNestedGenericInstantiation.ts, 11, 22)) +>mapValues : Symbol(Chainable.mapValues, Decl(mappedTypeNestedGenericInstantiation.ts, 3, 13)) +>square : Symbol(square, Decl(mappedTypeNestedGenericInstantiation.ts, 9, 5)) +>value : Symbol(Chainable.value, Decl(mappedTypeNestedGenericInstantiation.ts, 2, 24)) + diff --git a/tests/baselines/reference/mappedTypeNestedGenericInstantiation.types b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.types new file mode 100644 index 00000000000..7501bdb19e8 --- /dev/null +++ b/tests/baselines/reference/mappedTypeNestedGenericInstantiation.types @@ -0,0 +1,58 @@ +=== tests/cases/compiler/mappedTypeNestedGenericInstantiation.ts === +// Repro from #13346 + +interface Chainable { +>Chainable : Chainable +>T : T + + value(): T; +>value : () => T +>T : T + + mapValues(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>; +>mapValues : (func: (v: T[keyof T]) => U) => Chainable<{ [k in keyof T]: U; }> +>U : U +>func : (v: T[keyof T]) => U +>v : T[keyof T] +>T : T +>T : T +>U : U +>Chainable : Chainable +>k : k +>T : T +>U : U +} + +declare function chain(t: T): Chainable; +>chain : (t: T) => Chainable +>T : T +>t : T +>T : T +>Chainable : Chainable +>T : T + +const square = (x: number) => x * x; +>square : (x: number) => number +>(x: number) => x * x : (x: number) => number +>x : number +>x * x : number +>x : number +>x : number + +const v = chain({a: 1, b: 2}).mapValues(square).value(); +>v : { a: number; b: number; } +>chain({a: 1, b: 2}).mapValues(square).value() : { a: number; b: number; } +>chain({a: 1, b: 2}).mapValues(square).value : () => { a: number; b: number; } +>chain({a: 1, b: 2}).mapValues(square) : Chainable<{ a: number; b: number; }> +>chain({a: 1, b: 2}).mapValues : (func: (v: number) => U) => Chainable<{ a: U; b: U; }> +>chain({a: 1, b: 2}) : Chainable<{ a: number; b: number; }> +>chain : (t: T) => Chainable +>{a: 1, b: 2} : { a: number; b: number; } +>a : number +>1 : 1 +>b : number +>2 : 2 +>mapValues : (func: (v: number) => U) => Chainable<{ a: U; b: U; }> +>square : (x: number) => number +>value : () => { a: number; b: number; } + diff --git a/tests/baselines/reference/mappedTypeRelationships.errors.txt b/tests/baselines/reference/mappedTypeRelationships.errors.txt index e8e0371ed9a..22f56dacaf6 100644 --- a/tests/baselines/reference/mappedTypeRelationships.errors.txt +++ b/tests/baselines/reference/mappedTypeRelationships.errors.txt @@ -3,8 +3,12 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(12,5): error TS2 tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(17,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(21,5): error TS2536: Type 'keyof U' cannot be used to index type 'T'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(22,5): error TS2322: Type 'T[keyof U]' is not assignable to type 'U[keyof U]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(22,12): error TS2536: Type 'keyof U' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(26,5): error TS2536: Type 'K' cannot be used to index type 'T'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(27,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(27,12): error TS2536: Type 'K' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(31,5): error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'. Type 'undefined' is not assignable to type 'T[keyof T]'. @@ -26,9 +30,24 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(62,5): error TS2 tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(67,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(71,5): error TS2322: Type 'Partial' is not assignable to type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(76,5): error TS2322: Type 'Partial' is not assignable to type 'T'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(126,5): error TS2322: Type 'Partial' is not assignable to type 'Identity'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(142,5): error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. + Type 'T[P]' is not assignable to type 'U[P]'. + Type 'T' is not assignable to type 'U'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(147,5): error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'. + Type 'keyof U' is not assignable to type 'keyof T'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(152,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: T[P]; }'. + Type 'keyof T' is not assignable to type 'K'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(157,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'. + Type 'keyof U' is not assignable to type 'K'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(162,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. + Type 'keyof T' is not assignable to type 'K'. +tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in K]: U[P]; }'. + Type 'T[P]' is not assignable to type 'U[P]'. + Type 'T' is not assignable to type 'U'. -==== tests/cases/conformance/types/mapped/mappedTypeRelationships.ts (18 errors) ==== +==== tests/cases/conformance/types/mapped/mappedTypeRelationships.ts (27 errors) ==== function f1(x: T, k: keyof T) { return x[k]; @@ -59,6 +78,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(76,5): error TS2 ~~~~ !!! error TS2536: Type 'keyof U' cannot be used to index type 'T'. y[k] = x[k]; // Error + ~~~~ +!!! error TS2322: Type 'T[keyof U]' is not assignable to type 'U[keyof U]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. ~~~~ !!! error TS2536: Type 'keyof U' cannot be used to index type 'T'. } @@ -68,6 +90,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(76,5): error TS2 ~~~~ !!! error TS2536: Type 'K' cannot be used to index type 'T'. y[k] = x[k]; // Error + ~~~~ +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. ~~~~ !!! error TS2536: Type 'K' cannot be used to index type 'T'. } @@ -180,4 +205,89 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(76,5): error TS2 function f51(obj: T, key: K) { let item: Item = obj[key]; return obj[key].name; - } \ No newline at end of file + } + + type T1 = { + [P in keyof T]: T[P]; + } + + type T2 = { + [P in keyof T]: T[P]; + } + + function f60(x: T1, y: T2) { + x = y; + y = x; + } + + type Identity = { + [P in keyof T]: T[P]; + } + + function f61(x: Identity, y: Partial) { + x = y; // Error + ~ +!!! error TS2322: Type 'Partial' is not assignable to type 'Identity'. + y = x; + } + + function f62(x: Identity, y: Readonly) { + x = y; + y = x; + } + + function f70(x: { [P in keyof T]: T[P] }, y: { [P in keyof T]: T[P] }) { + x = y; + y = x; + } + + function f71(x: { [P in keyof T]: T[P] }, y: { [P in keyof T]: U[P] }) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. +!!! error TS2322: Type 'T[P]' is not assignable to type 'U[P]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. + } + + function f72(x: { [P in keyof T]: T[P] }, y: { [P in keyof U]: U[P] }) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'. +!!! error TS2322: Type 'keyof U' is not assignable to type 'keyof T'. + } + + function f73(x: { [P in K]: T[P] }, y: { [P in keyof T]: T[P] }) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: T[P]; }'. +!!! error TS2322: Type 'keyof T' is not assignable to type 'K'. + } + + function f74(x: { [P in K]: T[P] }, y: { [P in keyof U]: U[P] }) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'. +!!! error TS2322: Type 'keyof U' is not assignable to type 'K'. + } + + function f75(x: { [P in K]: T[P] }, y: { [P in keyof T]: U[P] }) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. +!!! error TS2322: Type 'keyof T' is not assignable to type 'K'. + } + + function f76(x: { [P in K]: T[P] }, y: { [P in K]: U[P] }) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in K]: U[P]; }'. +!!! error TS2322: Type 'T[P]' is not assignable to type 'U[P]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/mappedTypeRelationships.js b/tests/baselines/reference/mappedTypeRelationships.js index a81ff973da8..2476b72cef6 100644 --- a/tests/baselines/reference/mappedTypeRelationships.js +++ b/tests/baselines/reference/mappedTypeRelationships.js @@ -104,7 +104,70 @@ function f50(obj: T, key: keyof T) { function f51(obj: T, key: K) { let item: Item = obj[key]; return obj[key].name; -} +} + +type T1 = { + [P in keyof T]: T[P]; +} + +type T2 = { + [P in keyof T]: T[P]; +} + +function f60(x: T1, y: T2) { + x = y; + y = x; +} + +type Identity = { + [P in keyof T]: T[P]; +} + +function f61(x: Identity, y: Partial) { + x = y; // Error + y = x; +} + +function f62(x: Identity, y: Readonly) { + x = y; + y = x; +} + +function f70(x: { [P in keyof T]: T[P] }, y: { [P in keyof T]: T[P] }) { + x = y; + y = x; +} + +function f71(x: { [P in keyof T]: T[P] }, y: { [P in keyof T]: U[P] }) { + x = y; + y = x; // Error +} + +function f72(x: { [P in keyof T]: T[P] }, y: { [P in keyof U]: U[P] }) { + x = y; + y = x; // Error +} + +function f73(x: { [P in K]: T[P] }, y: { [P in keyof T]: T[P] }) { + x = y; + y = x; // Error +} + +function f74(x: { [P in K]: T[P] }, y: { [P in keyof U]: U[P] }) { + x = y; + y = x; // Error +} + +function f75(x: { [P in K]: T[P] }, y: { [P in keyof T]: U[P] }) { + x = y; + y = x; // Error +} + +function f76(x: { [P in K]: T[P] }, y: { [P in K]: U[P] }) { + x = y; + y = x; // Error +} + //// [mappedTypeRelationships.js] function f1(x, k) { @@ -185,6 +248,46 @@ function f51(obj, key) { var item = obj[key]; return obj[key].name; } +function f60(x, y) { + x = y; + y = x; +} +function f61(x, y) { + x = y; // Error + y = x; +} +function f62(x, y) { + x = y; + y = x; +} +function f70(x, y) { + x = y; + y = x; +} +function f71(x, y) { + x = y; + y = x; // Error +} +function f72(x, y) { + x = y; + y = x; // Error +} +function f73(x, y) { + x = y; + y = x; // Error +} +function f74(x, y) { + x = y; + y = x; // Error +} +function f75(x, y) { + x = y; + y = x; // Error +} +function f76(x, y) { + x = y; + y = x; // Error +} //// [mappedTypeRelationships.d.ts] @@ -214,3 +317,50 @@ declare type ItemMap = { }; declare function f50(obj: T, key: keyof T): string; declare function f51(obj: T, key: K): string; +declare type T1 = { + [P in keyof T]: T[P]; +}; +declare type T2 = { + [P in keyof T]: T[P]; +}; +declare function f60(x: T1, y: T2): void; +declare type Identity = { + [P in keyof T]: T[P]; +}; +declare function f61(x: Identity, y: Partial): void; +declare function f62(x: Identity, y: Readonly): void; +declare function f70(x: { + [P in keyof T]: T[P]; +}, y: { + [P in keyof T]: T[P]; +}): void; +declare function f71(x: { + [P in keyof T]: T[P]; +}, y: { + [P in keyof T]: U[P]; +}): void; +declare function f72(x: { + [P in keyof T]: T[P]; +}, y: { + [P in keyof U]: U[P]; +}): void; +declare function f73(x: { + [P in K]: T[P]; +}, y: { + [P in keyof T]: T[P]; +}): void; +declare function f74(x: { + [P in K]: T[P]; +}, y: { + [P in keyof U]: U[P]; +}): void; +declare function f75(x: { + [P in K]: T[P]; +}, y: { + [P in keyof T]: U[P]; +}): void; +declare function f76(x: { + [P in K]: T[P]; +}, y: { + [P in K]: U[P]; +}): void; diff --git a/tests/baselines/reference/mappedTypeWithCombinedTypeMappers.errors.txt b/tests/baselines/reference/mappedTypeWithCombinedTypeMappers.errors.txt new file mode 100644 index 00000000000..56837dd787e --- /dev/null +++ b/tests/baselines/reference/mappedTypeWithCombinedTypeMappers.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/mappedTypeWithCombinedTypeMappers.ts(18,7): error TS2322: Type 'string' is not assignable to type '{ important: boolean; }'. + + +==== tests/cases/compiler/mappedTypeWithCombinedTypeMappers.ts (1 errors) ==== + // Repro from #13351 + + type Meta = { + readonly[P in keyof T]: { + value: T[P]; + also: A; + readonly children: Meta; + }; + } + + interface Input { + x: string; + y: number; + } + + declare const output: Meta; + + const shouldFail: { important: boolean } = output.x.children; + ~~~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type '{ important: boolean; }'. + \ No newline at end of file diff --git a/tests/baselines/reference/mappedTypeWithCombinedTypeMappers.js b/tests/baselines/reference/mappedTypeWithCombinedTypeMappers.js new file mode 100644 index 00000000000..a445f2eebc5 --- /dev/null +++ b/tests/baselines/reference/mappedTypeWithCombinedTypeMappers.js @@ -0,0 +1,24 @@ +//// [mappedTypeWithCombinedTypeMappers.ts] +// Repro from #13351 + +type Meta = { + readonly[P in keyof T]: { + value: T[P]; + also: A; + readonly children: Meta; + }; +} + +interface Input { + x: string; + y: number; +} + +declare const output: Meta; + +const shouldFail: { important: boolean } = output.x.children; + + +//// [mappedTypeWithCombinedTypeMappers.js] +// Repro from #13351 +var shouldFail = output.x.children; diff --git a/tests/baselines/reference/mappedTypes1.js b/tests/baselines/reference/mappedTypes1.js index 1998ad5ab6b..4dd8f172179 100644 --- a/tests/baselines/reference/mappedTypes1.js +++ b/tests/baselines/reference/mappedTypes1.js @@ -139,9 +139,9 @@ declare let x2: string; declare let x3: number; declare let x4: { toString: void; - valueOf: void; toFixed: void; toExponential: void; toPrecision: void; + valueOf: void; toLocaleString: void; }; diff --git a/tests/baselines/reference/mappedTypes1.types b/tests/baselines/reference/mappedTypes1.types index 35d13143bab..a9a7f53a899 100644 --- a/tests/baselines/reference/mappedTypes1.types +++ b/tests/baselines/reference/mappedTypes1.types @@ -165,7 +165,7 @@ let x3 = f3(); >f3 : () => { [P in keyof T1]: void; } let x4 = f4(); ->x4 : { toString: void; valueOf: void; toFixed: void; toExponential: void; toPrecision: void; toLocaleString: void; } ->f4() : { toString: void; valueOf: void; toFixed: void; toExponential: void; toPrecision: void; toLocaleString: void; } +>x4 : { toString: void; toFixed: void; toExponential: void; toPrecision: void; valueOf: void; toLocaleString: void; } +>f4() : { toString: void; toFixed: void; toExponential: void; toPrecision: void; valueOf: void; toLocaleString: void; } >f4 : () => { [P in keyof T1]: void; } diff --git a/tests/baselines/reference/mappedTypes4.types b/tests/baselines/reference/mappedTypes4.types index a2fec06ccec..1d0c4c16b89 100644 --- a/tests/baselines/reference/mappedTypes4.types +++ b/tests/baselines/reference/mappedTypes4.types @@ -29,7 +29,7 @@ function boxify(obj: T): Boxified { if (typeof obj === "object") { >typeof obj === "object" : boolean ->typeof obj : string +>typeof obj : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >obj : T >"object" : "object" diff --git a/tests/baselines/reference/mappedTypesAndObjects.js b/tests/baselines/reference/mappedTypesAndObjects.js index 53b39209693..f320cc9624e 100644 --- a/tests/baselines/reference/mappedTypesAndObjects.js +++ b/tests/baselines/reference/mappedTypesAndObjects.js @@ -12,26 +12,37 @@ function f2(x: Partial, y: Readonly) { obj = y; } +function f3(x: Partial) { + x = {}; +} + // Repro from #12900 interface Base { - foo: { [key: string]: any }; - bar: any; - baz: any; + foo: { [key: string]: any }; + bar: any; + baz: any; } interface E1 extends Base { - foo: T; + foo: T; } interface Something { name: string, value: string }; interface E2 extends Base { - foo: Partial; // or other mapped type + foo: Partial; // or other mapped type } interface E3 extends Base { - foo: Partial; // or other mapped type -} + foo: Partial; // or other mapped type +} + +// Repro from #13747 + +class Form { + private values: {[P in keyof T]?: T[P]} = {} +} + //// [mappedTypesAndObjects.js] function f1(x, y) { @@ -44,12 +55,23 @@ function f2(x, y) { obj = x; obj = y; } +function f3(x) { + x = {}; +} ; +// Repro from #13747 +var Form = (function () { + function Form() { + this.values = {}; + } + return Form; +}()); //// [mappedTypesAndObjects.d.ts] declare function f1(x: Partial, y: Readonly): void; declare function f2(x: Partial, y: Readonly): void; +declare function f3(x: Partial): void; interface Base { foo: { [key: string]: any; @@ -70,3 +92,6 @@ interface E2 extends Base { interface E3 extends Base { foo: Partial; } +declare class Form { + private values; +} diff --git a/tests/baselines/reference/mappedTypesAndObjects.symbols b/tests/baselines/reference/mappedTypesAndObjects.symbols index 1690f1b6b04..6fb5d720fb3 100644 --- a/tests/baselines/reference/mappedTypesAndObjects.symbols +++ b/tests/baselines/reference/mappedTypesAndObjects.symbols @@ -45,54 +45,80 @@ function f2(x: Partial, y: Readonly) { >y : Symbol(y, Decl(mappedTypesAndObjects.ts, 7, 29)) } +function f3(x: Partial) { +>f3 : Symbol(f3, Decl(mappedTypesAndObjects.ts, 11, 1)) +>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 13, 12)) +>x : Symbol(x, Decl(mappedTypesAndObjects.ts, 13, 15)) +>Partial : Symbol(Partial, Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 13, 12)) + + x = {}; +>x : Symbol(x, Decl(mappedTypesAndObjects.ts, 13, 15)) +} + // Repro from #12900 interface Base { ->Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 11, 1)) +>Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 15, 1)) - foo: { [key: string]: any }; ->foo : Symbol(Base.foo, Decl(mappedTypesAndObjects.ts, 15, 16)) ->key : Symbol(key, Decl(mappedTypesAndObjects.ts, 16, 11)) + foo: { [key: string]: any }; +>foo : Symbol(Base.foo, Decl(mappedTypesAndObjects.ts, 19, 16)) +>key : Symbol(key, Decl(mappedTypesAndObjects.ts, 20, 12)) - bar: any; ->bar : Symbol(Base.bar, Decl(mappedTypesAndObjects.ts, 16, 31)) + bar: any; +>bar : Symbol(Base.bar, Decl(mappedTypesAndObjects.ts, 20, 32)) - baz: any; ->baz : Symbol(Base.baz, Decl(mappedTypesAndObjects.ts, 17, 12)) + baz: any; +>baz : Symbol(Base.baz, Decl(mappedTypesAndObjects.ts, 21, 13)) } interface E1 extends Base { ->E1 : Symbol(E1, Decl(mappedTypesAndObjects.ts, 19, 1)) ->T : Symbol(T, Decl(mappedTypesAndObjects.ts, 21, 13)) ->Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 11, 1)) +>E1 : Symbol(E1, Decl(mappedTypesAndObjects.ts, 23, 1)) +>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 25, 13)) +>Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 15, 1)) - foo: T; ->foo : Symbol(E1.foo, Decl(mappedTypesAndObjects.ts, 21, 30)) ->T : Symbol(T, Decl(mappedTypesAndObjects.ts, 21, 13)) + foo: T; +>foo : Symbol(E1.foo, Decl(mappedTypesAndObjects.ts, 25, 30)) +>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 25, 13)) } interface Something { name: string, value: string }; ->Something : Symbol(Something, Decl(mappedTypesAndObjects.ts, 23, 1)) ->name : Symbol(Something.name, Decl(mappedTypesAndObjects.ts, 25, 21)) ->value : Symbol(Something.value, Decl(mappedTypesAndObjects.ts, 25, 35)) +>Something : Symbol(Something, Decl(mappedTypesAndObjects.ts, 27, 1)) +>name : Symbol(Something.name, Decl(mappedTypesAndObjects.ts, 29, 21)) +>value : Symbol(Something.value, Decl(mappedTypesAndObjects.ts, 29, 35)) interface E2 extends Base { ->E2 : Symbol(E2, Decl(mappedTypesAndObjects.ts, 25, 52)) ->Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 11, 1)) +>E2 : Symbol(E2, Decl(mappedTypesAndObjects.ts, 29, 52)) +>Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 15, 1)) - foo: Partial; // or other mapped type ->foo : Symbol(E2.foo, Decl(mappedTypesAndObjects.ts, 26, 27)) + foo: Partial; // or other mapped type +>foo : Symbol(E2.foo, Decl(mappedTypesAndObjects.ts, 30, 27)) >Partial : Symbol(Partial, Decl(lib.d.ts, --, --)) ->Something : Symbol(Something, Decl(mappedTypesAndObjects.ts, 23, 1)) +>Something : Symbol(Something, Decl(mappedTypesAndObjects.ts, 27, 1)) } interface E3 extends Base { ->E3 : Symbol(E3, Decl(mappedTypesAndObjects.ts, 28, 1)) ->T : Symbol(T, Decl(mappedTypesAndObjects.ts, 30, 13)) ->Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 11, 1)) +>E3 : Symbol(E3, Decl(mappedTypesAndObjects.ts, 32, 1)) +>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 34, 13)) +>Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 15, 1)) - foo: Partial; // or other mapped type ->foo : Symbol(E3.foo, Decl(mappedTypesAndObjects.ts, 30, 30)) + foo: Partial; // or other mapped type +>foo : Symbol(E3.foo, Decl(mappedTypesAndObjects.ts, 34, 30)) >Partial : Symbol(Partial, Decl(lib.d.ts, --, --)) ->T : Symbol(T, Decl(mappedTypesAndObjects.ts, 30, 13)) +>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 34, 13)) } + +// Repro from #13747 + +class Form { +>Form : Symbol(Form, Decl(mappedTypesAndObjects.ts, 36, 1)) +>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 40, 11)) + + private values: {[P in keyof T]?: T[P]} = {} +>values : Symbol(Form.values, Decl(mappedTypesAndObjects.ts, 40, 15)) +>P : Symbol(P, Decl(mappedTypesAndObjects.ts, 41, 22)) +>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 40, 11)) +>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 40, 11)) +>P : Symbol(P, Decl(mappedTypesAndObjects.ts, 41, 22)) +} + diff --git a/tests/baselines/reference/mappedTypesAndObjects.types b/tests/baselines/reference/mappedTypesAndObjects.types index e6f8e53f558..75f71082f31 100644 --- a/tests/baselines/reference/mappedTypesAndObjects.types +++ b/tests/baselines/reference/mappedTypesAndObjects.types @@ -49,19 +49,32 @@ function f2(x: Partial, y: Readonly) { >y : Readonly } +function f3(x: Partial) { +>f3 : (x: Partial) => void +>T : T +>x : Partial +>Partial : Partial +>T : T + + x = {}; +>x = {} : {} +>x : Partial +>{} : {} +} + // Repro from #12900 interface Base { >Base : Base - foo: { [key: string]: any }; + foo: { [key: string]: any }; >foo : { [key: string]: any; } >key : string - bar: any; + bar: any; >bar : any - baz: any; + baz: any; >baz : any } @@ -70,7 +83,7 @@ interface E1 extends Base { >T : T >Base : Base - foo: T; + foo: T; >foo : T >T : T } @@ -84,7 +97,7 @@ interface E2 extends Base { >E2 : E2 >Base : Base - foo: Partial; // or other mapped type + foo: Partial; // or other mapped type >foo : Partial >Partial : Partial >Something : Something @@ -95,8 +108,24 @@ interface E3 extends Base { >T : T >Base : Base - foo: Partial; // or other mapped type + foo: Partial; // or other mapped type >foo : Partial >Partial : Partial >T : T } + +// Repro from #13747 + +class Form { +>Form : Form +>T : T + + private values: {[P in keyof T]?: T[P]} = {} +>values : { [P in keyof T]?: T[P] | undefined; } +>P : P +>T : T +>T : T +>P : P +>{} : {} +} + diff --git a/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt b/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt index 405fa4d2036..6cf1bbc5fa3 100644 --- a/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt +++ b/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/matchReturnTypeInAllBranches.ts(30,20): error TS2322: Type '12345' is not assignable to type 'boolean'. +tests/cases/compiler/matchReturnTypeInAllBranches.ts(30,13): error TS2322: Type '12345' is not assignable to type 'boolean'. ==== tests/cases/compiler/matchReturnTypeInAllBranches.ts (1 errors) ==== @@ -32,7 +32,7 @@ tests/cases/compiler/matchReturnTypeInAllBranches.ts(30,20): error TS2322: Type else { return 12345; - ~~~~~ + ~~~~~~~~~~~~~ !!! error TS2322: Type '12345' is not assignable to type 'boolean'. } } diff --git a/tests/baselines/reference/memberAccessMustUseModuleInstances.js b/tests/baselines/reference/memberAccessMustUseModuleInstances.js index 00f913219a4..2ba05b016be 100644 --- a/tests/baselines/reference/memberAccessMustUseModuleInstances.js +++ b/tests/baselines/reference/memberAccessMustUseModuleInstances.js @@ -17,6 +17,7 @@ WinJS.Promise.timeout(10); //// [memberAccessMustUseModuleInstances_0.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var Promise = (function () { function Promise() { } @@ -30,5 +31,6 @@ define(["require", "exports"], function (require, exports) { //// [memberAccessMustUseModuleInstances_1.js] define(["require", "exports", "memberAccessMustUseModuleInstances_0"], function (require, exports, WinJS) { "use strict"; + exports.__esModule = true; WinJS.Promise.timeout(10); }); diff --git a/tests/baselines/reference/mergeWithImportedNamespace.js b/tests/baselines/reference/mergeWithImportedNamespace.js index 60f6fedd3f2..ec2eb4a1087 100644 --- a/tests/baselines/reference/mergeWithImportedNamespace.js +++ b/tests/baselines/reference/mergeWithImportedNamespace.js @@ -12,9 +12,11 @@ export namespace N { //// [f1.js] "use strict"; +exports.__esModule = true; var N; (function (N) { N.x = 1; })(N = exports.N || (exports.N = {})); //// [f2.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/mergeWithImportedType.js b/tests/baselines/reference/mergeWithImportedType.js index e8dc5a3c2f3..efa95d77630 100644 --- a/tests/baselines/reference/mergeWithImportedType.js +++ b/tests/baselines/reference/mergeWithImportedType.js @@ -10,9 +10,11 @@ export type E = E; //// [f1.js] "use strict"; +exports.__esModule = true; var E; (function (E) { E[E["X"] = 0] = "X"; })(E = exports.E || (exports.E = {})); //// [f2.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/mergedDeclarations5.js b/tests/baselines/reference/mergedDeclarations5.js index b24e86eca58..a1e144fc223 100644 --- a/tests/baselines/reference/mergedDeclarations5.js +++ b/tests/baselines/reference/mergedDeclarations5.js @@ -19,15 +19,20 @@ var A = (function () { return A; }()); //// [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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.foo = function () { }; return B; diff --git a/tests/baselines/reference/mergedDeclarations6.js b/tests/baselines/reference/mergedDeclarations6.js index d610e4ab46f..83173f35752 100644 --- a/tests/baselines/reference/mergedDeclarations6.js +++ b/tests/baselines/reference/mergedDeclarations6.js @@ -26,6 +26,7 @@ export class B extends A { //// [a.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var A = (function () { function A() { } @@ -37,17 +38,23 @@ define(["require", "exports"], function (require, exports) { exports.A = A; }); //// [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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); define(["require", "exports", "./a"], function (require, exports, a_1) { "use strict"; + exports.__esModule = true; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.setProtected = function () { }; diff --git a/tests/baselines/reference/mergedDeclarations7.errors.txt b/tests/baselines/reference/mergedDeclarations7.errors.txt new file mode 100644 index 00000000000..cd9b3a5e939 --- /dev/null +++ b/tests/baselines/reference/mergedDeclarations7.errors.txt @@ -0,0 +1,32 @@ +tests/cases/compiler/test.ts(4,5): error TS2322: Type 'PassportStatic' is not assignable to type 'Passport'. + Types of property 'use' are incompatible. + Type '() => PassportStatic' is not assignable to type '() => this'. + Type 'PassportStatic' is not assignable to type 'this'. + + +==== tests/cases/compiler/passport.d.ts (0 errors) ==== + declare module 'passport' { + namespace passport { + interface Passport { + use(): this; + } + + interface PassportStatic extends Passport { + Passport: {new(): Passport}; + } + } + + const passport: passport.PassportStatic; + export = passport; + } + +==== tests/cases/compiler/test.ts (1 errors) ==== + import * as passport from "passport"; + import { Passport } from "passport"; + + let p: Passport = passport.use(); + ~ +!!! error TS2322: Type 'PassportStatic' is not assignable to type 'Passport'. +!!! error TS2322: Types of property 'use' are incompatible. +!!! error TS2322: Type '() => PassportStatic' is not assignable to type '() => this'. +!!! error TS2322: Type 'PassportStatic' is not assignable to type 'this'. \ No newline at end of file diff --git a/tests/baselines/reference/mergedDeclarations7.js b/tests/baselines/reference/mergedDeclarations7.js new file mode 100644 index 00000000000..8fa3f2d0731 --- /dev/null +++ b/tests/baselines/reference/mergedDeclarations7.js @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/mergedDeclarations7.ts] //// + +//// [passport.d.ts] +declare module 'passport' { + namespace passport { + interface Passport { + use(): this; + } + + interface PassportStatic extends Passport { + Passport: {new(): Passport}; + } + } + + const passport: passport.PassportStatic; + export = passport; +} + +//// [test.ts] +import * as passport from "passport"; +import { Passport } from "passport"; + +let p: Passport = passport.use(); + +//// [test.js] +"use strict"; +exports.__esModule = true; +var passport = require("passport"); +var p = passport.use(); diff --git a/tests/baselines/reference/mergedInheritedClassInterface.js b/tests/baselines/reference/mergedInheritedClassInterface.js index 0f598f2cf78..25ad2b8be75 100644 --- a/tests/baselines/reference/mergedInheritedClassInterface.js +++ b/tests/baselines/reference/mergedInheritedClassInterface.js @@ -47,11 +47,16 @@ grandchild.method2(); //// [mergedInheritedClassInterface.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var BaseClass = (function () { function BaseClass() { } @@ -61,7 +66,7 @@ var BaseClass = (function () { var Child = (function (_super) { __extends(Child, _super); function Child() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Child.prototype.method = function () { }; return Child; @@ -75,7 +80,7 @@ var ChildNoBaseClass = (function () { var Grandchild = (function (_super) { __extends(Grandchild, _super); function Grandchild() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Grandchild; }(ChildNoBaseClass)); diff --git a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.js b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.js index 6dccf1dfdd9..4390bc251cd 100644 --- a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.js +++ b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.js @@ -32,11 +32,16 @@ var r = a.x; // error var r2 = a.w; // error //// [mergedInterfacesWithInheritedPrivates2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -50,14 +55,14 @@ var C2 = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(C2)); diff --git a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates3.js b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates3.js index a3ca796575c..8ad8a27dc8f 100644 --- a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates3.js +++ b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates3.js @@ -39,11 +39,16 @@ module M { } //// [mergedInterfacesWithInheritedPrivates3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -57,7 +62,7 @@ var C2 = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/mergedModuleDeclarationCodeGen.js b/tests/baselines/reference/mergedModuleDeclarationCodeGen.js index 573701d407b..8d5f55b6801 100644 --- a/tests/baselines/reference/mergedModuleDeclarationCodeGen.js +++ b/tests/baselines/reference/mergedModuleDeclarationCodeGen.js @@ -17,6 +17,7 @@ export module X { //// [mergedModuleDeclarationCodeGen.js] "use strict"; +exports.__esModule = true; var X; (function (X) { var Y; diff --git a/tests/baselines/reference/metadataOfEventAlias.js b/tests/baselines/reference/metadataOfEventAlias.js new file mode 100644 index 00000000000..40cbc87cdcb --- /dev/null +++ b/tests/baselines/reference/metadataOfEventAlias.js @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/metadataOfEventAlias.ts] //// + +//// [event.ts] + +export interface Event { title: string }; + +//// [test.ts] +import { Event } from './event'; +function Input(target: any, key: string): void { } +export class SomeClass { + @Input event: Event; +} + +//// [event.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +; +//// [test.js] +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +function Input(target, key) { } +var SomeClass = (function () { + function SomeClass() { + } + return SomeClass; +}()); +__decorate([ + Input, + __metadata("design:type", Object) +], SomeClass.prototype, "event", void 0); +exports.SomeClass = SomeClass; diff --git a/tests/baselines/reference/metadataOfEventAlias.symbols b/tests/baselines/reference/metadataOfEventAlias.symbols new file mode 100644 index 00000000000..441714e63e6 --- /dev/null +++ b/tests/baselines/reference/metadataOfEventAlias.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/event.ts === + +export interface Event { title: string }; +>Event : Symbol(Event, Decl(event.ts, 0, 0)) +>title : Symbol(Event.title, Decl(event.ts, 1, 24)) + +=== tests/cases/compiler/test.ts === +import { Event } from './event'; +>Event : Symbol(Event, Decl(test.ts, 0, 8)) + +function Input(target: any, key: string): void { } +>Input : Symbol(Input, Decl(test.ts, 0, 32)) +>target : Symbol(target, Decl(test.ts, 1, 15)) +>key : Symbol(key, Decl(test.ts, 1, 27)) + +export class SomeClass { +>SomeClass : Symbol(SomeClass, Decl(test.ts, 1, 50)) + + @Input event: Event; +>Input : Symbol(Input, Decl(test.ts, 0, 32)) +>event : Symbol(SomeClass.event, Decl(test.ts, 2, 24)) +>Event : Symbol(Event, Decl(test.ts, 0, 8)) +} diff --git a/tests/baselines/reference/metadataOfEventAlias.types b/tests/baselines/reference/metadataOfEventAlias.types new file mode 100644 index 00000000000..b644552f9c2 --- /dev/null +++ b/tests/baselines/reference/metadataOfEventAlias.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/event.ts === + +export interface Event { title: string }; +>Event : Event +>title : string + +=== tests/cases/compiler/test.ts === +import { Event } from './event'; +>Event : any + +function Input(target: any, key: string): void { } +>Input : (target: any, key: string) => void +>target : any +>key : string + +export class SomeClass { +>SomeClass : SomeClass + + @Input event: Event; +>Input : (target: any, key: string) => void +>event : Event +>Event : Event +} diff --git a/tests/baselines/reference/missingFunctionImplementation.js b/tests/baselines/reference/missingFunctionImplementation.js index d9ab942cfc8..23bb2356640 100644 --- a/tests/baselines/reference/missingFunctionImplementation.js +++ b/tests/baselines/reference/missingFunctionImplementation.js @@ -82,6 +82,7 @@ namespace N12 { //// [missingFunctionImplementation.js] "use strict"; +exports.__esModule = true; var C1 = (function () { function C1() { } diff --git a/tests/baselines/reference/missingFunctionImplementation2.js b/tests/baselines/reference/missingFunctionImplementation2.js index 7b3456015c8..dde60611657 100644 --- a/tests/baselines/reference/missingFunctionImplementation2.js +++ b/tests/baselines/reference/missingFunctionImplementation2.js @@ -11,5 +11,7 @@ export function f(a?, b?); //// [missingFunctionImplementation2_a.js] "use strict"; +exports.__esModule = true; //// [missingFunctionImplementation2_b.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/missingPropertiesOfClassExpression.js b/tests/baselines/reference/missingPropertiesOfClassExpression.js index c7b30882b14..7f468d14def 100644 --- a/tests/baselines/reference/missingPropertiesOfClassExpression.js +++ b/tests/baselines/reference/missingPropertiesOfClassExpression.js @@ -7,11 +7,16 @@ class George extends class { reset() { return this.y; } } { //// [missingPropertiesOfClassExpression.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var George = (function (_super) { __extends(George, _super); function George() { diff --git a/tests/baselines/reference/missingSemicolonInModuleSpecifier.js b/tests/baselines/reference/missingSemicolonInModuleSpecifier.js index 069849ffb83..d4a8b12d2a6 100644 --- a/tests/baselines/reference/missingSemicolonInModuleSpecifier.js +++ b/tests/baselines/reference/missingSemicolonInModuleSpecifier.js @@ -10,7 +10,9 @@ import {x} from "./a" //// [a.js] "use strict"; +exports.__esModule = true; exports.x = 1; //// [b.js] "use strict"; +exports.__esModule = true; (function () { return 1; }()); diff --git a/tests/baselines/reference/misspelledJsDocTypedefTags.symbols b/tests/baselines/reference/misspelledJsDocTypedefTags.symbols new file mode 100644 index 00000000000..bf3f6e7fab0 --- /dev/null +++ b/tests/baselines/reference/misspelledJsDocTypedefTags.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/a.js === + +No type information for this code./** @typedef {{ endTime: number, screenshots: number}} A.*/ +No type information for this code.Animation.AnimationModel.ScreenshotCapture.Request; +No type information for this code. +No type information for this code./** @typedef {{ endTime: number, screenshots: !B.}} */ +No type information for this code.Animation.AnimationModel.ScreenshotCapture.Request; +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/misspelledJsDocTypedefTags.types b/tests/baselines/reference/misspelledJsDocTypedefTags.types new file mode 100644 index 00000000000..70cc011ea69 --- /dev/null +++ b/tests/baselines/reference/misspelledJsDocTypedefTags.types @@ -0,0 +1,22 @@ +=== tests/cases/compiler/a.js === + +/** @typedef {{ endTime: number, screenshots: number}} A.*/ +Animation.AnimationModel.ScreenshotCapture.Request; +>Animation.AnimationModel.ScreenshotCapture.Request : any +>Animation.AnimationModel.ScreenshotCapture : any +>Animation.AnimationModel : any +>Animation : any +>AnimationModel : any +>ScreenshotCapture : any +>Request : any + +/** @typedef {{ endTime: number, screenshots: !B.}} */ +Animation.AnimationModel.ScreenshotCapture.Request; +>Animation.AnimationModel.ScreenshotCapture.Request : any +>Animation.AnimationModel.ScreenshotCapture : any +>Animation.AnimationModel : any +>Animation : any +>AnimationModel : any +>ScreenshotCapture : any +>Request : any + diff --git a/tests/baselines/reference/mixinAccessModifiers.errors.txt b/tests/baselines/reference/mixinAccessModifiers.errors.txt new file mode 100644 index 00000000000..be82571e02b --- /dev/null +++ b/tests/baselines/reference/mixinAccessModifiers.errors.txt @@ -0,0 +1,174 @@ +tests/cases/conformance/classes/mixinAccessModifiers.ts(39,4): error TS2546: Property 'p' has conflicting declarations and is inaccessible in type 'Private & Private2'. +tests/cases/conformance/classes/mixinAccessModifiers.ts(43,4): error TS2546: Property 'p' has conflicting declarations and is inaccessible in type 'Private & Protected'. +tests/cases/conformance/classes/mixinAccessModifiers.ts(47,4): error TS2546: Property 'p' has conflicting declarations and is inaccessible in type 'Private & Public'. +tests/cases/conformance/classes/mixinAccessModifiers.ts(51,4): error TS2445: Property 'p' is protected and only accessible within class 'Protected & Protected2' and its subclasses. +tests/cases/conformance/classes/mixinAccessModifiers.ts(66,7): error TS2415: Class 'C1' incorrectly extends base class 'Private & Private2'. + Type 'C1' is not assignable to type 'Private'. + Property 'p' has conflicting declarations and is inaccessible in type 'C1'. +tests/cases/conformance/classes/mixinAccessModifiers.ts(66,7): error TS4093: 'extends' clause of exported class 'C1' refers to a type whose name cannot be referenced. +tests/cases/conformance/classes/mixinAccessModifiers.ts(67,7): error TS2415: Class 'C2' incorrectly extends base class 'Private & Protected'. + Type 'C2' is not assignable to type 'Private'. + Property 'p' has conflicting declarations and is inaccessible in type 'C2'. +tests/cases/conformance/classes/mixinAccessModifiers.ts(67,7): error TS4093: 'extends' clause of exported class 'C2' refers to a type whose name cannot be referenced. +tests/cases/conformance/classes/mixinAccessModifiers.ts(68,7): error TS2415: Class 'C3' incorrectly extends base class 'Private & Public'. + Type 'C3' is not assignable to type 'Private'. + Property 'p' has conflicting declarations and is inaccessible in type 'C3'. +tests/cases/conformance/classes/mixinAccessModifiers.ts(68,7): error TS4093: 'extends' clause of exported class 'C3' refers to a type whose name cannot be referenced. +tests/cases/conformance/classes/mixinAccessModifiers.ts(70,7): error TS4093: 'extends' clause of exported class 'C4' refers to a type whose name cannot be referenced. +tests/cases/conformance/classes/mixinAccessModifiers.ts(83,7): error TS4093: 'extends' clause of exported class 'C5' refers to a type whose name cannot be referenced. +tests/cases/conformance/classes/mixinAccessModifiers.ts(85,6): error TS2445: Property 'p' is protected and only accessible within class 'C4' and its subclasses. +tests/cases/conformance/classes/mixinAccessModifiers.ts(90,6): error TS2445: Property 's' is protected and only accessible within class 'typeof C4' and its subclasses. +tests/cases/conformance/classes/mixinAccessModifiers.ts(96,7): error TS4093: 'extends' clause of exported class 'C6' refers to a type whose name cannot be referenced. +tests/cases/conformance/classes/mixinAccessModifiers.ts(98,6): error TS2445: Property 'p' is protected and only accessible within class 'C4' and its subclasses. +tests/cases/conformance/classes/mixinAccessModifiers.ts(103,6): error TS2445: Property 's' is protected and only accessible within class 'typeof C4' and its subclasses. + + +==== tests/cases/conformance/classes/mixinAccessModifiers.ts (17 errors) ==== + + type Constructable = new (...args: any[]) => object; + + class Private { + constructor (...args: any[]) {} + private p: string; + } + + class Private2 { + constructor (...args: any[]) {} + private p: string; + } + + class Protected { + constructor (...args: any[]) {} + protected p: string; + protected static s: string; + } + + class Protected2 { + constructor (...args: any[]) {} + protected p: string; + protected static s: string; + } + + class Public { + constructor (...args: any[]) {} + public p: string; + public static s: string; + } + + class Public2 { + constructor (...args: any[]) {} + public p: string; + public static s: string; + } + + function f1(x: Private & Private2) { + x.p; // Error, private constituent makes property inaccessible + ~ +!!! error TS2546: Property 'p' has conflicting declarations and is inaccessible in type 'Private & Private2'. + } + + function f2(x: Private & Protected) { + x.p; // Error, private constituent makes property inaccessible + ~ +!!! error TS2546: Property 'p' has conflicting declarations and is inaccessible in type 'Private & Protected'. + } + + function f3(x: Private & Public) { + x.p; // Error, private constituent makes property inaccessible + ~ +!!! error TS2546: Property 'p' has conflicting declarations and is inaccessible in type 'Private & Public'. + } + + function f4(x: Protected & Protected2) { + x.p; // Error, protected when all constituents are protected + ~ +!!! error TS2445: Property 'p' is protected and only accessible within class 'Protected & Protected2' and its subclasses. + } + + function f5(x: Protected & Public) { + x.p; // Ok, public if any constituent is public + } + + function f6(x: Public & Public2) { + x.p; // Ok, public if any constituent is public + } + + declare function Mix(c1: T, c2: U): T & U; + + // Can't derive from type with inaccessible properties + + class C1 extends Mix(Private, Private2) {} + ~~ +!!! error TS2415: Class 'C1' incorrectly extends base class 'Private & Private2'. +!!! error TS2415: Type 'C1' is not assignable to type 'Private'. +!!! error TS2415: Property 'p' has conflicting declarations and is inaccessible in type 'C1'. + ~~ +!!! error TS4093: 'extends' clause of exported class 'C1' refers to a type whose name cannot be referenced. + class C2 extends Mix(Private, Protected) {} + ~~ +!!! error TS2415: Class 'C2' incorrectly extends base class 'Private & Protected'. +!!! error TS2415: Type 'C2' is not assignable to type 'Private'. +!!! error TS2415: Property 'p' has conflicting declarations and is inaccessible in type 'C2'. + ~~ +!!! error TS4093: 'extends' clause of exported class 'C2' refers to a type whose name cannot be referenced. + class C3 extends Mix(Private, Public) {} + ~~ +!!! error TS2415: Class 'C3' incorrectly extends base class 'Private & Public'. +!!! error TS2415: Type 'C3' is not assignable to type 'Private'. +!!! error TS2415: Property 'p' has conflicting declarations and is inaccessible in type 'C3'. + ~~ +!!! error TS4093: 'extends' clause of exported class 'C3' refers to a type whose name cannot be referenced. + + class C4 extends Mix(Protected, Protected2) { + ~~ +!!! error TS4093: 'extends' clause of exported class 'C4' refers to a type whose name cannot be referenced. + f(c4: C4, c5: C5, c6: C6) { + c4.p; + c5.p; + c6.p; + } + static g() { + C4.s; + C5.s; + C6.s + } + } + + class C5 extends Mix(Protected, Public) { + ~~ +!!! error TS4093: 'extends' clause of exported class 'C5' refers to a type whose name cannot be referenced. + f(c4: C4, c5: C5, c6: C6) { + c4.p; // Error, not in class deriving from Protected2 + ~ +!!! error TS2445: Property 'p' is protected and only accessible within class 'C4' and its subclasses. + c5.p; + c6.p; + } + static g() { + C4.s; // Error, not in class deriving from Protected2 + ~ +!!! error TS2445: Property 's' is protected and only accessible within class 'typeof C4' and its subclasses. + C5.s; + C6.s + } + } + + class C6 extends Mix(Public, Public2) { + ~~ +!!! error TS4093: 'extends' clause of exported class 'C6' refers to a type whose name cannot be referenced. + f(c4: C4, c5: C5, c6: C6) { + c4.p; // Error, not in class deriving from Protected2 + ~ +!!! error TS2445: Property 'p' is protected and only accessible within class 'C4' and its subclasses. + c5.p; + c6.p; + } + static g() { + C4.s; // Error, not in class deriving from Protected2 + ~ +!!! error TS2445: Property 's' is protected and only accessible within class 'typeof C4' and its subclasses. + C5.s; + C6.s + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/mixinAccessModifiers.js b/tests/baselines/reference/mixinAccessModifiers.js new file mode 100644 index 00000000000..1db30e37a6e --- /dev/null +++ b/tests/baselines/reference/mixinAccessModifiers.js @@ -0,0 +1,266 @@ +//// [mixinAccessModifiers.ts] + +type Constructable = new (...args: any[]) => object; + +class Private { + constructor (...args: any[]) {} + private p: string; +} + +class Private2 { + constructor (...args: any[]) {} + private p: string; +} + +class Protected { + constructor (...args: any[]) {} + protected p: string; + protected static s: string; +} + +class Protected2 { + constructor (...args: any[]) {} + protected p: string; + protected static s: string; +} + +class Public { + constructor (...args: any[]) {} + public p: string; + public static s: string; +} + +class Public2 { + constructor (...args: any[]) {} + public p: string; + public static s: string; +} + +function f1(x: Private & Private2) { + x.p; // Error, private constituent makes property inaccessible +} + +function f2(x: Private & Protected) { + x.p; // Error, private constituent makes property inaccessible +} + +function f3(x: Private & Public) { + x.p; // Error, private constituent makes property inaccessible +} + +function f4(x: Protected & Protected2) { + x.p; // Error, protected when all constituents are protected +} + +function f5(x: Protected & Public) { + x.p; // Ok, public if any constituent is public +} + +function f6(x: Public & Public2) { + x.p; // Ok, public if any constituent is public +} + +declare function Mix(c1: T, c2: U): T & U; + +// Can't derive from type with inaccessible properties + +class C1 extends Mix(Private, Private2) {} +class C2 extends Mix(Private, Protected) {} +class C3 extends Mix(Private, Public) {} + +class C4 extends Mix(Protected, Protected2) { + f(c4: C4, c5: C5, c6: C6) { + c4.p; + c5.p; + c6.p; + } + static g() { + C4.s; + C5.s; + C6.s + } +} + +class C5 extends Mix(Protected, Public) { + f(c4: C4, c5: C5, c6: C6) { + c4.p; // Error, not in class deriving from Protected2 + c5.p; + c6.p; + } + static g() { + C4.s; // Error, not in class deriving from Protected2 + C5.s; + C6.s + } +} + +class C6 extends Mix(Public, Public2) { + f(c4: C4, c5: C5, c6: C6) { + c4.p; // Error, not in class deriving from Protected2 + c5.p; + c6.p; + } + static g() { + C4.s; // Error, not in class deriving from Protected2 + C5.s; + C6.s + } +} + + +//// [mixinAccessModifiers.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var Private = (function () { + function Private() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + } + return Private; +}()); +var Private2 = (function () { + function Private2() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + } + return Private2; +}()); +var Protected = (function () { + function Protected() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + } + return Protected; +}()); +var Protected2 = (function () { + function Protected2() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + } + return Protected2; +}()); +var Public = (function () { + function Public() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + } + return Public; +}()); +var Public2 = (function () { + function Public2() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + } + return Public2; +}()); +function f1(x) { + x.p; // Error, private constituent makes property inaccessible +} +function f2(x) { + x.p; // Error, private constituent makes property inaccessible +} +function f3(x) { + x.p; // Error, private constituent makes property inaccessible +} +function f4(x) { + x.p; // Error, protected when all constituents are protected +} +function f5(x) { + x.p; // Ok, public if any constituent is public +} +function f6(x) { + x.p; // Ok, public if any constituent is public +} +// Can't derive from type with inaccessible properties +var C1 = (function (_super) { + __extends(C1, _super); + function C1() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C1; +}(Mix(Private, Private2))); +var C2 = (function (_super) { + __extends(C2, _super); + function C2() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C2; +}(Mix(Private, Protected))); +var C3 = (function (_super) { + __extends(C3, _super); + function C3() { + return _super !== null && _super.apply(this, arguments) || this; + } + return C3; +}(Mix(Private, Public))); +var C4 = (function (_super) { + __extends(C4, _super); + function C4() { + return _super !== null && _super.apply(this, arguments) || this; + } + C4.prototype.f = function (c4, c5, c6) { + c4.p; + c5.p; + c6.p; + }; + C4.g = function () { + C4.s; + C5.s; + C6.s; + }; + return C4; +}(Mix(Protected, Protected2))); +var C5 = (function (_super) { + __extends(C5, _super); + function C5() { + return _super !== null && _super.apply(this, arguments) || this; + } + C5.prototype.f = function (c4, c5, c6) { + c4.p; // Error, not in class deriving from Protected2 + c5.p; + c6.p; + }; + C5.g = function () { + C4.s; // Error, not in class deriving from Protected2 + C5.s; + C6.s; + }; + return C5; +}(Mix(Protected, Public))); +var C6 = (function (_super) { + __extends(C6, _super); + function C6() { + return _super !== null && _super.apply(this, arguments) || this; + } + C6.prototype.f = function (c4, c5, c6) { + c4.p; // Error, not in class deriving from Protected2 + c5.p; + c6.p; + }; + C6.g = function () { + C4.s; // Error, not in class deriving from Protected2 + C5.s; + C6.s; + }; + return C6; +}(Mix(Public, Public2))); diff --git a/tests/baselines/reference/mixinClassesAnnotated.js b/tests/baselines/reference/mixinClassesAnnotated.js new file mode 100644 index 00000000000..e3a781033ff --- /dev/null +++ b/tests/baselines/reference/mixinClassesAnnotated.js @@ -0,0 +1,183 @@ +//// [mixinClassesAnnotated.ts] + +type Constructor = new(...args: any[]) => T; + +class Base { + constructor(public x: number, public y: number) {} +} + +class Derived extends Base { + constructor(x: number, y: number, public z: number) { + super(x, y); + } +} + +interface Printable { + print(): void; +} + +const Printable = >(superClass: T): Constructor & { message: string } & T => + class extends superClass { + static message = "hello"; + print() { + const output = this.x + "," + this.y; + } + } + +interface Tagged { + _tag: string; +} + +function Tagged>(superClass: T): Constructor & T { + class C extends superClass { + _tag: string; + constructor(...args: any[]) { + super(...args); + this._tag = "hello"; + } + } + return C; +} + +const Thing1 = Tagged(Derived); +const Thing2 = Tagged(Printable(Derived)); +Thing2.message; + +function f1() { + const thing = new Thing1(1, 2, 3); + thing.x; + thing._tag; +} + +function f2() { + const thing = new Thing2(1, 2, 3); + thing.x; + thing._tag; + thing.print(); +} + +class Thing3 extends Thing2 { + constructor(tag: string) { + super(10, 20, 30); + this._tag = tag; + } + test() { + this.print(); + } +} + + +//// [mixinClassesAnnotated.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var Base = (function () { + function Base(x, y) { + this.x = x; + this.y = y; + } + return Base; +}()); +var Derived = (function (_super) { + __extends(Derived, _super); + function Derived(x, y, z) { + var _this = _super.call(this, x, y) || this; + _this.z = z; + return _this; + } + return Derived; +}(Base)); +var Printable = function (superClass) { return _a = (function (_super) { + __extends(class_1, _super); + function class_1() { + return _super !== null && _super.apply(this, arguments) || this; + } + class_1.prototype.print = function () { + var output = this.x + "," + this.y; + }; + return class_1; + }(superClass)), + _a.message = "hello", + _a; var _a; }; +function Tagged(superClass) { + var C = (function (_super) { + __extends(C, _super); + function C() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var _this = _super.apply(this, args) || this; + _this._tag = "hello"; + return _this; + } + return C; + }(superClass)); + return C; +} +var Thing1 = Tagged(Derived); +var Thing2 = Tagged(Printable(Derived)); +Thing2.message; +function f1() { + var thing = new Thing1(1, 2, 3); + thing.x; + thing._tag; +} +function f2() { + var thing = new Thing2(1, 2, 3); + thing.x; + thing._tag; + thing.print(); +} +var Thing3 = (function (_super) { + __extends(Thing3, _super); + function Thing3(tag) { + var _this = _super.call(this, 10, 20, 30) || this; + _this._tag = tag; + return _this; + } + Thing3.prototype.test = function () { + this.print(); + }; + return Thing3; +}(Thing2)); + + +//// [mixinClassesAnnotated.d.ts] +declare type Constructor = new (...args: any[]) => T; +declare class Base { + x: number; + y: number; + constructor(x: number, y: number); +} +declare class Derived extends Base { + z: number; + constructor(x: number, y: number, z: number); +} +interface Printable { + print(): void; +} +declare const Printable: >(superClass: T) => Constructor & { + message: string; +} & T; +interface Tagged { + _tag: string; +} +declare function Tagged>(superClass: T): Constructor & T; +declare const Thing1: Constructor & typeof Derived; +declare const Thing2: Constructor & Constructor & { + message: string; +} & typeof Derived; +declare function f1(): void; +declare function f2(): void; +declare class Thing3 extends Thing2 { + constructor(tag: string); + test(): void; +} diff --git a/tests/baselines/reference/mixinClassesAnnotated.symbols b/tests/baselines/reference/mixinClassesAnnotated.symbols new file mode 100644 index 00000000000..5a03789e2e6 --- /dev/null +++ b/tests/baselines/reference/mixinClassesAnnotated.symbols @@ -0,0 +1,193 @@ +=== tests/cases/conformance/classes/mixinClassesAnnotated.ts === + +type Constructor = new(...args: any[]) => T; +>Constructor : Symbol(Constructor, Decl(mixinClassesAnnotated.ts, 0, 0)) +>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 1, 17)) +>args : Symbol(args, Decl(mixinClassesAnnotated.ts, 1, 26)) +>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 1, 17)) + +class Base { +>Base : Symbol(Base, Decl(mixinClassesAnnotated.ts, 1, 47)) + + constructor(public x: number, public y: number) {} +>x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16)) +>y : Symbol(Base.y, Decl(mixinClassesAnnotated.ts, 4, 33)) +} + +class Derived extends Base { +>Derived : Symbol(Derived, Decl(mixinClassesAnnotated.ts, 5, 1)) +>Base : Symbol(Base, Decl(mixinClassesAnnotated.ts, 1, 47)) + + constructor(x: number, y: number, public z: number) { +>x : Symbol(x, Decl(mixinClassesAnnotated.ts, 8, 16)) +>y : Symbol(y, Decl(mixinClassesAnnotated.ts, 8, 26)) +>z : Symbol(Derived.z, Decl(mixinClassesAnnotated.ts, 8, 37)) + + super(x, y); +>super : Symbol(Base, Decl(mixinClassesAnnotated.ts, 1, 47)) +>x : Symbol(x, Decl(mixinClassesAnnotated.ts, 8, 16)) +>y : Symbol(y, Decl(mixinClassesAnnotated.ts, 8, 26)) + } +} + +interface Printable { +>Printable : Symbol(Printable, Decl(mixinClassesAnnotated.ts, 11, 1), Decl(mixinClassesAnnotated.ts, 17, 5)) + + print(): void; +>print : Symbol(Printable.print, Decl(mixinClassesAnnotated.ts, 13, 21)) +} + +const Printable = >(superClass: T): Constructor & { message: string } & T => +>Printable : Symbol(Printable, Decl(mixinClassesAnnotated.ts, 11, 1), Decl(mixinClassesAnnotated.ts, 17, 5)) +>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 17, 19)) +>Constructor : Symbol(Constructor, Decl(mixinClassesAnnotated.ts, 0, 0)) +>Base : Symbol(Base, Decl(mixinClassesAnnotated.ts, 1, 47)) +>superClass : Symbol(superClass, Decl(mixinClassesAnnotated.ts, 17, 48)) +>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 17, 19)) +>Constructor : Symbol(Constructor, Decl(mixinClassesAnnotated.ts, 0, 0)) +>Printable : Symbol(Printable, Decl(mixinClassesAnnotated.ts, 11, 1), Decl(mixinClassesAnnotated.ts, 17, 5)) +>message : Symbol(message, Decl(mixinClassesAnnotated.ts, 17, 90)) +>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 17, 19)) + + class extends superClass { +>superClass : Symbol(superClass, Decl(mixinClassesAnnotated.ts, 17, 48)) + + static message = "hello"; +>message : Symbol((Anonymous class).message, Decl(mixinClassesAnnotated.ts, 18, 30)) + + print() { +>print : Symbol((Anonymous class).print, Decl(mixinClassesAnnotated.ts, 19, 33)) + + const output = this.x + "," + this.y; +>output : Symbol(output, Decl(mixinClassesAnnotated.ts, 21, 17)) +>this.x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16)) +>this : Symbol((Anonymous class), Decl(mixinClassesAnnotated.ts, 17, 115)) +>x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16)) +>this.y : Symbol(Base.y, Decl(mixinClassesAnnotated.ts, 4, 33)) +>this : Symbol((Anonymous class), Decl(mixinClassesAnnotated.ts, 17, 115)) +>y : Symbol(Base.y, Decl(mixinClassesAnnotated.ts, 4, 33)) + } + } + +interface Tagged { +>Tagged : Symbol(Tagged, Decl(mixinClassesAnnotated.ts, 23, 5), Decl(mixinClassesAnnotated.ts, 27, 1)) + + _tag: string; +>_tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18)) +} + +function Tagged>(superClass: T): Constructor & T { +>Tagged : Symbol(Tagged, Decl(mixinClassesAnnotated.ts, 23, 5), Decl(mixinClassesAnnotated.ts, 27, 1)) +>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 29, 16)) +>Constructor : Symbol(Constructor, Decl(mixinClassesAnnotated.ts, 0, 0)) +>superClass : Symbol(superClass, Decl(mixinClassesAnnotated.ts, 29, 43)) +>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 29, 16)) +>Constructor : Symbol(Constructor, Decl(mixinClassesAnnotated.ts, 0, 0)) +>Tagged : Symbol(Tagged, Decl(mixinClassesAnnotated.ts, 23, 5), Decl(mixinClassesAnnotated.ts, 27, 1)) +>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 29, 16)) + + class C extends superClass { +>C : Symbol(C, Decl(mixinClassesAnnotated.ts, 29, 84)) +>superClass : Symbol(superClass, Decl(mixinClassesAnnotated.ts, 29, 43)) + + _tag: string; +>_tag : Symbol(C._tag, Decl(mixinClassesAnnotated.ts, 30, 32)) + + constructor(...args: any[]) { +>args : Symbol(args, Decl(mixinClassesAnnotated.ts, 32, 20)) + + super(...args); +>super : Symbol(T, Decl(mixinClassesAnnotated.ts, 29, 16)) +>args : Symbol(args, Decl(mixinClassesAnnotated.ts, 32, 20)) + + this._tag = "hello"; +>this._tag : Symbol(C._tag, Decl(mixinClassesAnnotated.ts, 30, 32)) +>this : Symbol(C, Decl(mixinClassesAnnotated.ts, 29, 84)) +>_tag : Symbol(C._tag, Decl(mixinClassesAnnotated.ts, 30, 32)) + } + } + return C; +>C : Symbol(C, Decl(mixinClassesAnnotated.ts, 29, 84)) +} + +const Thing1 = Tagged(Derived); +>Thing1 : Symbol(Thing1, Decl(mixinClassesAnnotated.ts, 40, 5)) +>Tagged : Symbol(Tagged, Decl(mixinClassesAnnotated.ts, 23, 5), Decl(mixinClassesAnnotated.ts, 27, 1)) +>Derived : Symbol(Derived, Decl(mixinClassesAnnotated.ts, 5, 1)) + +const Thing2 = Tagged(Printable(Derived)); +>Thing2 : Symbol(Thing2, Decl(mixinClassesAnnotated.ts, 41, 5)) +>Tagged : Symbol(Tagged, Decl(mixinClassesAnnotated.ts, 23, 5), Decl(mixinClassesAnnotated.ts, 27, 1)) +>Printable : Symbol(Printable, Decl(mixinClassesAnnotated.ts, 11, 1), Decl(mixinClassesAnnotated.ts, 17, 5)) +>Derived : Symbol(Derived, Decl(mixinClassesAnnotated.ts, 5, 1)) + +Thing2.message; +>Thing2.message : Symbol(message, Decl(mixinClassesAnnotated.ts, 17, 90)) +>Thing2 : Symbol(Thing2, Decl(mixinClassesAnnotated.ts, 41, 5)) +>message : Symbol(message, Decl(mixinClassesAnnotated.ts, 17, 90)) + +function f1() { +>f1 : Symbol(f1, Decl(mixinClassesAnnotated.ts, 42, 15)) + + const thing = new Thing1(1, 2, 3); +>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 45, 9)) +>Thing1 : Symbol(Thing1, Decl(mixinClassesAnnotated.ts, 40, 5)) + + thing.x; +>thing.x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16)) +>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 45, 9)) +>x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16)) + + thing._tag; +>thing._tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18)) +>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 45, 9)) +>_tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18)) +} + +function f2() { +>f2 : Symbol(f2, Decl(mixinClassesAnnotated.ts, 48, 1)) + + const thing = new Thing2(1, 2, 3); +>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 51, 9)) +>Thing2 : Symbol(Thing2, Decl(mixinClassesAnnotated.ts, 41, 5)) + + thing.x; +>thing.x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16)) +>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 51, 9)) +>x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16)) + + thing._tag; +>thing._tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18)) +>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 51, 9)) +>_tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18)) + + thing.print(); +>thing.print : Symbol(Printable.print, Decl(mixinClassesAnnotated.ts, 13, 21)) +>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 51, 9)) +>print : Symbol(Printable.print, Decl(mixinClassesAnnotated.ts, 13, 21)) +} + +class Thing3 extends Thing2 { +>Thing3 : Symbol(Thing3, Decl(mixinClassesAnnotated.ts, 55, 1)) +>Thing2 : Symbol(Thing2, Decl(mixinClassesAnnotated.ts, 41, 5)) + + constructor(tag: string) { +>tag : Symbol(tag, Decl(mixinClassesAnnotated.ts, 58, 16)) + + super(10, 20, 30); + this._tag = tag; +>this._tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18)) +>this : Symbol(Thing3, Decl(mixinClassesAnnotated.ts, 55, 1)) +>_tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18)) +>tag : Symbol(tag, Decl(mixinClassesAnnotated.ts, 58, 16)) + } + test() { +>test : Symbol(Thing3.test, Decl(mixinClassesAnnotated.ts, 61, 5)) + + this.print(); +>this.print : Symbol(Printable.print, Decl(mixinClassesAnnotated.ts, 13, 21)) +>this : Symbol(Thing3, Decl(mixinClassesAnnotated.ts, 55, 1)) +>print : Symbol(Printable.print, Decl(mixinClassesAnnotated.ts, 13, 21)) + } +} + diff --git a/tests/baselines/reference/mixinClassesAnnotated.types b/tests/baselines/reference/mixinClassesAnnotated.types new file mode 100644 index 00000000000..afaf4c4d25e --- /dev/null +++ b/tests/baselines/reference/mixinClassesAnnotated.types @@ -0,0 +1,224 @@ +=== tests/cases/conformance/classes/mixinClassesAnnotated.ts === + +type Constructor = new(...args: any[]) => T; +>Constructor : Constructor +>T : T +>args : any[] +>T : T + +class Base { +>Base : Base + + constructor(public x: number, public y: number) {} +>x : number +>y : number +} + +class Derived extends Base { +>Derived : Derived +>Base : Base + + constructor(x: number, y: number, public z: number) { +>x : number +>y : number +>z : number + + super(x, y); +>super(x, y) : void +>super : typeof Base +>x : number +>y : number + } +} + +interface Printable { +>Printable : Printable + + print(): void; +>print : () => void +} + +const Printable = >(superClass: T): Constructor & { message: string } & T => +>Printable : >(superClass: T) => Constructor & { message: string; } & T +>>(superClass: T): Constructor & { message: string } & T => class extends superClass { static message = "hello"; print() { const output = this.x + "," + this.y; } } : >(superClass: T) => Constructor & { message: string; } & T +>T : T +>Constructor : Constructor +>Base : Base +>superClass : T +>T : T +>Constructor : Constructor +>Printable : Printable +>message : string +>T : T + + class extends superClass { +>class extends superClass { static message = "hello"; print() { const output = this.x + "," + this.y; } } : { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); message: string; } & T +>superClass : Base + + static message = "hello"; +>message : string +>"hello" : "hello" + + print() { +>print : () => void + + const output = this.x + "," + this.y; +>output : string +>this.x + "," + this.y : string +>this.x + "," : string +>this.x : number +>this : this +>x : number +>"," : "," +>this.y : number +>this : this +>y : number + } + } + +interface Tagged { +>Tagged : Tagged + + _tag: string; +>_tag : string +} + +function Tagged>(superClass: T): Constructor & T { +>Tagged : >(superClass: T) => Constructor & T +>T : T +>Constructor : Constructor +>superClass : T +>T : T +>Constructor : Constructor +>Tagged : Tagged +>T : T + + class C extends superClass { +>C : C +>superClass : {} + + _tag: string; +>_tag : string + + constructor(...args: any[]) { +>args : any[] + + super(...args); +>super(...args) : void +>super : T +>...args : any +>args : any[] + + this._tag = "hello"; +>this._tag = "hello" : "hello" +>this._tag : string +>this : this +>_tag : string +>"hello" : "hello" + } + } + return C; +>C : { new (...args: any[]): C; prototype: Tagged.C; } & T +} + +const Thing1 = Tagged(Derived); +>Thing1 : Constructor & typeof Derived +>Tagged(Derived) : Constructor & typeof Derived +>Tagged : >(superClass: T) => Constructor & T +>Derived : typeof Derived + +const Thing2 = Tagged(Printable(Derived)); +>Thing2 : Constructor & Constructor & { message: string; } & typeof Derived +>Tagged(Printable(Derived)) : Constructor & Constructor & { message: string; } & typeof Derived +>Tagged : >(superClass: T) => Constructor & T +>Printable(Derived) : Constructor & { message: string; } & typeof Derived +>Printable : >(superClass: T) => Constructor & { message: string; } & T +>Derived : typeof Derived + +Thing2.message; +>Thing2.message : string +>Thing2 : Constructor & Constructor & { message: string; } & typeof Derived +>message : string + +function f1() { +>f1 : () => void + + const thing = new Thing1(1, 2, 3); +>thing : Tagged & Derived +>new Thing1(1, 2, 3) : Tagged & Derived +>Thing1 : Constructor & typeof Derived +>1 : 1 +>2 : 2 +>3 : 3 + + thing.x; +>thing.x : number +>thing : Tagged & Derived +>x : number + + thing._tag; +>thing._tag : string +>thing : Tagged & Derived +>_tag : string +} + +function f2() { +>f2 : () => void + + const thing = new Thing2(1, 2, 3); +>thing : Tagged & Printable & Derived +>new Thing2(1, 2, 3) : Tagged & Printable & Derived +>Thing2 : Constructor & Constructor & { message: string; } & typeof Derived +>1 : 1 +>2 : 2 +>3 : 3 + + thing.x; +>thing.x : number +>thing : Tagged & Printable & Derived +>x : number + + thing._tag; +>thing._tag : string +>thing : Tagged & Printable & Derived +>_tag : string + + thing.print(); +>thing.print() : void +>thing.print : () => void +>thing : Tagged & Printable & Derived +>print : () => void +} + +class Thing3 extends Thing2 { +>Thing3 : Thing3 +>Thing2 : Tagged & Printable & Derived + + constructor(tag: string) { +>tag : string + + super(10, 20, 30); +>super(10, 20, 30) : void +>super : Constructor & Constructor & { message: string; } & typeof Derived +>10 : 10 +>20 : 20 +>30 : 30 + + this._tag = tag; +>this._tag = tag : string +>this._tag : string +>this : this +>_tag : string +>tag : string + } + test() { +>test : () => void + + this.print(); +>this.print() : void +>this.print : () => void +>this : this +>print : () => void + } +} + diff --git a/tests/baselines/reference/mixinClassesAnonymous.js b/tests/baselines/reference/mixinClassesAnonymous.js new file mode 100644 index 00000000000..aa148c25acf --- /dev/null +++ b/tests/baselines/reference/mixinClassesAnonymous.js @@ -0,0 +1,160 @@ +//// [mixinClassesAnonymous.ts] +type Constructor = new(...args: any[]) => T; + +class Base { + constructor(public x: number, public y: number) {} +} + +class Derived extends Base { + constructor(x: number, y: number, public z: number) { + super(x, y); + } +} + +const Printable = >(superClass: T) => class extends superClass { + static message = "hello"; + print() { + const output = this.x + "," + this.y; + } +} + +function Tagged>(superClass: T) { + class C extends superClass { + _tag: string; + constructor(...args: any[]) { + super(...args); + this._tag = "hello"; + } + } + return C; +} + +const Thing1 = Tagged(Derived); +const Thing2 = Tagged(Printable(Derived)); +Thing2.message; + +function f1() { + const thing = new Thing1(1, 2, 3); + thing.x; + thing._tag; +} + +function f2() { + const thing = new Thing2(1, 2, 3); + thing.x; + thing._tag; + thing.print(); +} + +class Thing3 extends Thing2 { + constructor(tag: string) { + super(10, 20, 30); + this._tag = tag; + } + test() { + this.print(); + } +} + +// Repro from #13805 + +const Timestamped = >(Base: CT) => { + return class extends Base { + timestamp = new Date(); + }; +} + + +//// [mixinClassesAnonymous.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var Base = (function () { + function Base(x, y) { + this.x = x; + this.y = y; + } + return Base; +}()); +var Derived = (function (_super) { + __extends(Derived, _super); + function Derived(x, y, z) { + var _this = _super.call(this, x, y) || this; + _this.z = z; + return _this; + } + return Derived; +}(Base)); +var Printable = function (superClass) { return _a = (function (_super) { + __extends(class_1, _super); + function class_1() { + return _super !== null && _super.apply(this, arguments) || this; + } + class_1.prototype.print = function () { + var output = this.x + "," + this.y; + }; + return class_1; + }(superClass)), + _a.message = "hello", + _a; var _a; }; +function Tagged(superClass) { + var C = (function (_super) { + __extends(C, _super); + function C() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var _this = _super.apply(this, args) || this; + _this._tag = "hello"; + return _this; + } + return C; + }(superClass)); + return C; +} +var Thing1 = Tagged(Derived); +var Thing2 = Tagged(Printable(Derived)); +Thing2.message; +function f1() { + var thing = new Thing1(1, 2, 3); + thing.x; + thing._tag; +} +function f2() { + var thing = new Thing2(1, 2, 3); + thing.x; + thing._tag; + thing.print(); +} +var Thing3 = (function (_super) { + __extends(Thing3, _super); + function Thing3(tag) { + var _this = _super.call(this, 10, 20, 30) || this; + _this._tag = tag; + return _this; + } + Thing3.prototype.test = function () { + this.print(); + }; + return Thing3; +}(Thing2)); +// Repro from #13805 +var Timestamped = function (Base) { + return (function (_super) { + __extends(class_2, _super); + function class_2() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.timestamp = new Date(); + return _this; + } + return class_2; + }(Base)); +}; diff --git a/tests/baselines/reference/mixinClassesAnonymous.symbols b/tests/baselines/reference/mixinClassesAnonymous.symbols new file mode 100644 index 00000000000..bd709501f31 --- /dev/null +++ b/tests/baselines/reference/mixinClassesAnonymous.symbols @@ -0,0 +1,188 @@ +=== tests/cases/conformance/classes/mixinClassesAnonymous.ts === +type Constructor = new(...args: any[]) => T; +>Constructor : Symbol(Constructor, Decl(mixinClassesAnonymous.ts, 0, 0)) +>T : Symbol(T, Decl(mixinClassesAnonymous.ts, 0, 17)) +>args : Symbol(args, Decl(mixinClassesAnonymous.ts, 0, 26)) +>T : Symbol(T, Decl(mixinClassesAnonymous.ts, 0, 17)) + +class Base { +>Base : Symbol(Base, Decl(mixinClassesAnonymous.ts, 0, 47)) + + constructor(public x: number, public y: number) {} +>x : Symbol(Base.x, Decl(mixinClassesAnonymous.ts, 3, 16)) +>y : Symbol(Base.y, Decl(mixinClassesAnonymous.ts, 3, 33)) +} + +class Derived extends Base { +>Derived : Symbol(Derived, Decl(mixinClassesAnonymous.ts, 4, 1)) +>Base : Symbol(Base, Decl(mixinClassesAnonymous.ts, 0, 47)) + + constructor(x: number, y: number, public z: number) { +>x : Symbol(x, Decl(mixinClassesAnonymous.ts, 7, 16)) +>y : Symbol(y, Decl(mixinClassesAnonymous.ts, 7, 26)) +>z : Symbol(Derived.z, Decl(mixinClassesAnonymous.ts, 7, 37)) + + super(x, y); +>super : Symbol(Base, Decl(mixinClassesAnonymous.ts, 0, 47)) +>x : Symbol(x, Decl(mixinClassesAnonymous.ts, 7, 16)) +>y : Symbol(y, Decl(mixinClassesAnonymous.ts, 7, 26)) + } +} + +const Printable = >(superClass: T) => class extends superClass { +>Printable : Symbol(Printable, Decl(mixinClassesAnonymous.ts, 12, 5)) +>T : Symbol(T, Decl(mixinClassesAnonymous.ts, 12, 19)) +>Constructor : Symbol(Constructor, Decl(mixinClassesAnonymous.ts, 0, 0)) +>Base : Symbol(Base, Decl(mixinClassesAnonymous.ts, 0, 47)) +>superClass : Symbol(superClass, Decl(mixinClassesAnonymous.ts, 12, 48)) +>T : Symbol(T, Decl(mixinClassesAnonymous.ts, 12, 19)) +>superClass : Symbol(superClass, Decl(mixinClassesAnonymous.ts, 12, 48)) + + static message = "hello"; +>message : Symbol((Anonymous class).message, Decl(mixinClassesAnonymous.ts, 12, 92)) + + print() { +>print : Symbol((Anonymous class).print, Decl(mixinClassesAnonymous.ts, 13, 29)) + + const output = this.x + "," + this.y; +>output : Symbol(output, Decl(mixinClassesAnonymous.ts, 15, 13)) +>this.x : Symbol(Base.x, Decl(mixinClassesAnonymous.ts, 3, 16)) +>this : Symbol((Anonymous class), Decl(mixinClassesAnonymous.ts, 12, 65)) +>x : Symbol(Base.x, Decl(mixinClassesAnonymous.ts, 3, 16)) +>this.y : Symbol(Base.y, Decl(mixinClassesAnonymous.ts, 3, 33)) +>this : Symbol((Anonymous class), Decl(mixinClassesAnonymous.ts, 12, 65)) +>y : Symbol(Base.y, Decl(mixinClassesAnonymous.ts, 3, 33)) + } +} + +function Tagged>(superClass: T) { +>Tagged : Symbol(Tagged, Decl(mixinClassesAnonymous.ts, 17, 1)) +>T : Symbol(T, Decl(mixinClassesAnonymous.ts, 19, 16)) +>Constructor : Symbol(Constructor, Decl(mixinClassesAnonymous.ts, 0, 0)) +>superClass : Symbol(superClass, Decl(mixinClassesAnonymous.ts, 19, 43)) +>T : Symbol(T, Decl(mixinClassesAnonymous.ts, 19, 16)) + + class C extends superClass { +>C : Symbol(C, Decl(mixinClassesAnonymous.ts, 19, 59)) +>superClass : Symbol(superClass, Decl(mixinClassesAnonymous.ts, 19, 43)) + + _tag: string; +>_tag : Symbol(C._tag, Decl(mixinClassesAnonymous.ts, 20, 32)) + + constructor(...args: any[]) { +>args : Symbol(args, Decl(mixinClassesAnonymous.ts, 22, 20)) + + super(...args); +>super : Symbol(T, Decl(mixinClassesAnonymous.ts, 19, 16)) +>args : Symbol(args, Decl(mixinClassesAnonymous.ts, 22, 20)) + + this._tag = "hello"; +>this._tag : Symbol(C._tag, Decl(mixinClassesAnonymous.ts, 20, 32)) +>this : Symbol(C, Decl(mixinClassesAnonymous.ts, 19, 59)) +>_tag : Symbol(C._tag, Decl(mixinClassesAnonymous.ts, 20, 32)) + } + } + return C; +>C : Symbol(C, Decl(mixinClassesAnonymous.ts, 19, 59)) +} + +const Thing1 = Tagged(Derived); +>Thing1 : Symbol(Thing1, Decl(mixinClassesAnonymous.ts, 30, 5)) +>Tagged : Symbol(Tagged, Decl(mixinClassesAnonymous.ts, 17, 1)) +>Derived : Symbol(Derived, Decl(mixinClassesAnonymous.ts, 4, 1)) + +const Thing2 = Tagged(Printable(Derived)); +>Thing2 : Symbol(Thing2, Decl(mixinClassesAnonymous.ts, 31, 5)) +>Tagged : Symbol(Tagged, Decl(mixinClassesAnonymous.ts, 17, 1)) +>Printable : Symbol(Printable, Decl(mixinClassesAnonymous.ts, 12, 5)) +>Derived : Symbol(Derived, Decl(mixinClassesAnonymous.ts, 4, 1)) + +Thing2.message; +>Thing2.message : Symbol((Anonymous class).message, Decl(mixinClassesAnonymous.ts, 12, 92)) +>Thing2 : Symbol(Thing2, Decl(mixinClassesAnonymous.ts, 31, 5)) +>message : Symbol((Anonymous class).message, Decl(mixinClassesAnonymous.ts, 12, 92)) + +function f1() { +>f1 : Symbol(f1, Decl(mixinClassesAnonymous.ts, 32, 15)) + + const thing = new Thing1(1, 2, 3); +>thing : Symbol(thing, Decl(mixinClassesAnonymous.ts, 35, 9)) +>Thing1 : Symbol(Thing1, Decl(mixinClassesAnonymous.ts, 30, 5)) + + thing.x; +>thing.x : Symbol(Base.x, Decl(mixinClassesAnonymous.ts, 3, 16)) +>thing : Symbol(thing, Decl(mixinClassesAnonymous.ts, 35, 9)) +>x : Symbol(Base.x, Decl(mixinClassesAnonymous.ts, 3, 16)) + + thing._tag; +>thing._tag : Symbol(C._tag, Decl(mixinClassesAnonymous.ts, 20, 32)) +>thing : Symbol(thing, Decl(mixinClassesAnonymous.ts, 35, 9)) +>_tag : Symbol(C._tag, Decl(mixinClassesAnonymous.ts, 20, 32)) +} + +function f2() { +>f2 : Symbol(f2, Decl(mixinClassesAnonymous.ts, 38, 1)) + + const thing = new Thing2(1, 2, 3); +>thing : Symbol(thing, Decl(mixinClassesAnonymous.ts, 41, 9)) +>Thing2 : Symbol(Thing2, Decl(mixinClassesAnonymous.ts, 31, 5)) + + thing.x; +>thing.x : Symbol(Base.x, Decl(mixinClassesAnonymous.ts, 3, 16)) +>thing : Symbol(thing, Decl(mixinClassesAnonymous.ts, 41, 9)) +>x : Symbol(Base.x, Decl(mixinClassesAnonymous.ts, 3, 16)) + + thing._tag; +>thing._tag : Symbol(C._tag, Decl(mixinClassesAnonymous.ts, 20, 32)) +>thing : Symbol(thing, Decl(mixinClassesAnonymous.ts, 41, 9)) +>_tag : Symbol(C._tag, Decl(mixinClassesAnonymous.ts, 20, 32)) + + thing.print(); +>thing.print : Symbol((Anonymous class).print, Decl(mixinClassesAnonymous.ts, 13, 29)) +>thing : Symbol(thing, Decl(mixinClassesAnonymous.ts, 41, 9)) +>print : Symbol((Anonymous class).print, Decl(mixinClassesAnonymous.ts, 13, 29)) +} + +class Thing3 extends Thing2 { +>Thing3 : Symbol(Thing3, Decl(mixinClassesAnonymous.ts, 45, 1)) +>Thing2 : Symbol(Thing2, Decl(mixinClassesAnonymous.ts, 31, 5)) + + constructor(tag: string) { +>tag : Symbol(tag, Decl(mixinClassesAnonymous.ts, 48, 16)) + + super(10, 20, 30); + this._tag = tag; +>this._tag : Symbol(C._tag, Decl(mixinClassesAnonymous.ts, 20, 32)) +>this : Symbol(Thing3, Decl(mixinClassesAnonymous.ts, 45, 1)) +>_tag : Symbol(C._tag, Decl(mixinClassesAnonymous.ts, 20, 32)) +>tag : Symbol(tag, Decl(mixinClassesAnonymous.ts, 48, 16)) + } + test() { +>test : Symbol(Thing3.test, Decl(mixinClassesAnonymous.ts, 51, 5)) + + this.print(); +>this.print : Symbol((Anonymous class).print, Decl(mixinClassesAnonymous.ts, 13, 29)) +>this : Symbol(Thing3, Decl(mixinClassesAnonymous.ts, 45, 1)) +>print : Symbol((Anonymous class).print, Decl(mixinClassesAnonymous.ts, 13, 29)) + } +} + +// Repro from #13805 + +const Timestamped = >(Base: CT) => { +>Timestamped : Symbol(Timestamped, Decl(mixinClassesAnonymous.ts, 59, 5)) +>CT : Symbol(CT, Decl(mixinClassesAnonymous.ts, 59, 21)) +>Constructor : Symbol(Constructor, Decl(mixinClassesAnonymous.ts, 0, 0)) +>Base : Symbol(Base, Decl(mixinClassesAnonymous.ts, 59, 53)) +>CT : Symbol(CT, Decl(mixinClassesAnonymous.ts, 59, 21)) + + return class extends Base { +>Base : Symbol(Base, Decl(mixinClassesAnonymous.ts, 59, 53)) + + timestamp = new Date(); +>timestamp : Symbol((Anonymous class).timestamp, Decl(mixinClassesAnonymous.ts, 60, 31)) +>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + }; +} + diff --git a/tests/baselines/reference/mixinClassesAnonymous.types b/tests/baselines/reference/mixinClassesAnonymous.types new file mode 100644 index 00000000000..516b15af2f3 --- /dev/null +++ b/tests/baselines/reference/mixinClassesAnonymous.types @@ -0,0 +1,222 @@ +=== tests/cases/conformance/classes/mixinClassesAnonymous.ts === +type Constructor = new(...args: any[]) => T; +>Constructor : Constructor +>T : T +>args : any[] +>T : T + +class Base { +>Base : Base + + constructor(public x: number, public y: number) {} +>x : number +>y : number +} + +class Derived extends Base { +>Derived : Derived +>Base : Base + + constructor(x: number, y: number, public z: number) { +>x : number +>y : number +>z : number + + super(x, y); +>super(x, y) : void +>super : typeof Base +>x : number +>y : number + } +} + +const Printable = >(superClass: T) => class extends superClass { +>Printable : >(superClass: T) => { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); message: string; } & T +>>(superClass: T) => class extends superClass { static message = "hello"; print() { const output = this.x + "," + this.y; }} : >(superClass: T) => { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); message: string; } & T +>T : T +>Constructor : Constructor +>Base : Base +>superClass : T +>T : T +>class extends superClass { static message = "hello"; print() { const output = this.x + "," + this.y; }} : { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); message: string; } & T +>superClass : Base + + static message = "hello"; +>message : string +>"hello" : "hello" + + print() { +>print : () => void + + const output = this.x + "," + this.y; +>output : string +>this.x + "," + this.y : string +>this.x + "," : string +>this.x : number +>this : this +>x : number +>"," : "," +>this.y : number +>this : this +>y : number + } +} + +function Tagged>(superClass: T) { +>Tagged : >(superClass: T) => { new (...args: any[]): C; prototype: Tagged.C; } & T +>T : T +>Constructor : Constructor +>superClass : T +>T : T + + class C extends superClass { +>C : C +>superClass : {} + + _tag: string; +>_tag : string + + constructor(...args: any[]) { +>args : any[] + + super(...args); +>super(...args) : void +>super : T +>...args : any +>args : any[] + + this._tag = "hello"; +>this._tag = "hello" : "hello" +>this._tag : string +>this : this +>_tag : string +>"hello" : "hello" + } + } + return C; +>C : { new (...args: any[]): C; prototype: Tagged.C; } & T +} + +const Thing1 = Tagged(Derived); +>Thing1 : { new (...args: any[]): Tagged.C; prototype: Tagged.C; } & typeof Derived +>Tagged(Derived) : { new (...args: any[]): Tagged.C; prototype: Tagged.C; } & typeof Derived +>Tagged : >(superClass: T) => { new (...args: any[]): C; prototype: Tagged.C; } & T +>Derived : typeof Derived + +const Thing2 = Tagged(Printable(Derived)); +>Thing2 : { new (...args: any[]): Tagged<{ new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); message: string; } & typeof Derived>.C; prototype: Tagged.C; } & { new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); message: string; } & typeof Derived +>Tagged(Printable(Derived)) : { new (...args: any[]): Tagged<{ new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); message: string; } & typeof Derived>.C; prototype: Tagged.C; } & { new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); message: string; } & typeof Derived +>Tagged : >(superClass: T) => { new (...args: any[]): C; prototype: Tagged.C; } & T +>Printable(Derived) : { new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); message: string; } & typeof Derived +>Printable : >(superClass: T) => { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); message: string; } & T +>Derived : typeof Derived + +Thing2.message; +>Thing2.message : string +>Thing2 : { new (...args: any[]): Tagged<{ new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); message: string; } & typeof Derived>.C; prototype: Tagged.C; } & { new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); message: string; } & typeof Derived +>message : string + +function f1() { +>f1 : () => void + + const thing = new Thing1(1, 2, 3); +>thing : Tagged.C & Derived +>new Thing1(1, 2, 3) : Tagged.C & Derived +>Thing1 : { new (...args: any[]): Tagged.C; prototype: Tagged.C; } & typeof Derived +>1 : 1 +>2 : 2 +>3 : 3 + + thing.x; +>thing.x : number +>thing : Tagged.C & Derived +>x : number + + thing._tag; +>thing._tag : string +>thing : Tagged.C & Derived +>_tag : string +} + +function f2() { +>f2 : () => void + + const thing = new Thing2(1, 2, 3); +>thing : Tagged<{ new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); message: string; } & typeof Derived>.C & .(Anonymous class) & Derived +>new Thing2(1, 2, 3) : Tagged<{ new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); message: string; } & typeof Derived>.C & .(Anonymous class) & Derived +>Thing2 : { new (...args: any[]): Tagged<{ new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); message: string; } & typeof Derived>.C; prototype: Tagged.C; } & { new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); message: string; } & typeof Derived +>1 : 1 +>2 : 2 +>3 : 3 + + thing.x; +>thing.x : number +>thing : Tagged<{ new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); message: string; } & typeof Derived>.C & .(Anonymous class) & Derived +>x : number + + thing._tag; +>thing._tag : string +>thing : Tagged<{ new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); message: string; } & typeof Derived>.C & .(Anonymous class) & Derived +>_tag : string + + thing.print(); +>thing.print() : void +>thing.print : () => void +>thing : Tagged<{ new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); message: string; } & typeof Derived>.C & .(Anonymous class) & Derived +>print : () => void +} + +class Thing3 extends Thing2 { +>Thing3 : Thing3 +>Thing2 : Tagged<{ new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); message: string; } & typeof Derived>.C & .(Anonymous class) & Derived + + constructor(tag: string) { +>tag : string + + super(10, 20, 30); +>super(10, 20, 30) : void +>super : { new (...args: any[]): Tagged<{ new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); message: string; } & typeof Derived>.C; prototype: Tagged.C; } & { new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); message: string; } & typeof Derived +>10 : 10 +>20 : 20 +>30 : 30 + + this._tag = tag; +>this._tag = tag : string +>this._tag : string +>this : this +>_tag : string +>tag : string + } + test() { +>test : () => void + + this.print(); +>this.print() : void +>this.print : () => void +>this : this +>print : () => void + } +} + +// Repro from #13805 + +const Timestamped = >(Base: CT) => { +>Timestamped : >(Base: CT) => { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & CT +>>(Base: CT) => { return class extends Base { timestamp = new Date(); };} : >(Base: CT) => { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & CT +>CT : CT +>Constructor : Constructor +>Base : CT +>CT : CT + + return class extends Base { +>class extends Base { timestamp = new Date(); } : { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & CT +>Base : object + + timestamp = new Date(); +>timestamp : Date +>new Date() : Date +>Date : DateConstructor + + }; +} + diff --git a/tests/baselines/reference/mixinClassesMembers.js b/tests/baselines/reference/mixinClassesMembers.js new file mode 100644 index 00000000000..01fc1bb0032 --- /dev/null +++ b/tests/baselines/reference/mixinClassesMembers.js @@ -0,0 +1,220 @@ +//// [mixinClassesMembers.ts] + +declare class C1 { + public a: number; + protected b: number; + private c: number; + constructor(s: string); + constructor(n: number); +} + +declare class M1 { + constructor(...args: any[]); + p: number; + static p: number; +} + +declare class M2 { + constructor(...args: any[]); + f(): number; + static f(): number; +} + +declare const Mixed1: typeof M1 & typeof C1; +declare const Mixed2: typeof C1 & typeof M1; +declare const Mixed3: typeof M2 & typeof M1 & typeof C1; +declare const Mixed4: typeof C1 & typeof M1 & typeof M2; +declare const Mixed5: typeof M1 & typeof M2; + +function f1() { + let x1 = new Mixed1("hello"); + let x2 = new Mixed1(42); + let x3 = new Mixed2("hello"); + let x4 = new Mixed2(42); + let x5 = new Mixed3("hello"); + let x6 = new Mixed3(42); + let x7 = new Mixed4("hello"); + let x8 = new Mixed4(42); + let x9 = new Mixed5(); +} + +function f2() { + let x = new Mixed1("hello"); + x.a; + x.p; + Mixed1.p; +} + +function f3() { + let x = new Mixed2("hello"); + x.a; + x.p; + Mixed2.p; +} + +function f4() { + let x = new Mixed3("hello"); + x.a; + x.p; + x.f(); + Mixed3.p; + Mixed3.f(); +} + +function f5() { + let x = new Mixed4("hello"); + x.a; + x.p; + x.f(); + Mixed4.p; + Mixed4.f(); +} + +function f6() { + let x = new Mixed5(); + x.p; + x.f(); + Mixed5.p; + Mixed5.f(); +} + +class C2 extends Mixed1 { + constructor() { + super("hello"); + this.a; + this.b; + this.p; + } +} + +class C3 extends Mixed3 { + constructor() { + super(42); + this.a; + this.b; + this.p; + this.f(); + } + f() { return super.f(); } +} + + +//// [mixinClassesMembers.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +function f1() { + var x1 = new Mixed1("hello"); + var x2 = new Mixed1(42); + var x3 = new Mixed2("hello"); + var x4 = new Mixed2(42); + var x5 = new Mixed3("hello"); + var x6 = new Mixed3(42); + var x7 = new Mixed4("hello"); + var x8 = new Mixed4(42); + var x9 = new Mixed5(); +} +function f2() { + var x = new Mixed1("hello"); + x.a; + x.p; + Mixed1.p; +} +function f3() { + var x = new Mixed2("hello"); + x.a; + x.p; + Mixed2.p; +} +function f4() { + var x = new Mixed3("hello"); + x.a; + x.p; + x.f(); + Mixed3.p; + Mixed3.f(); +} +function f5() { + var x = new Mixed4("hello"); + x.a; + x.p; + x.f(); + Mixed4.p; + Mixed4.f(); +} +function f6() { + var x = new Mixed5(); + x.p; + x.f(); + Mixed5.p; + Mixed5.f(); +} +var C2 = (function (_super) { + __extends(C2, _super); + function C2() { + var _this = _super.call(this, "hello") || this; + _this.a; + _this.b; + _this.p; + return _this; + } + return C2; +}(Mixed1)); +var C3 = (function (_super) { + __extends(C3, _super); + function C3() { + var _this = _super.call(this, 42) || this; + _this.a; + _this.b; + _this.p; + _this.f(); + return _this; + } + C3.prototype.f = function () { return _super.prototype.f.call(this); }; + return C3; +}(Mixed3)); + + +//// [mixinClassesMembers.d.ts] +declare class C1 { + a: number; + protected b: number; + private c; + constructor(s: string); + constructor(n: number); +} +declare class M1 { + constructor(...args: any[]); + p: number; + static p: number; +} +declare class M2 { + constructor(...args: any[]); + f(): number; + static f(): number; +} +declare const Mixed1: typeof M1 & typeof C1; +declare const Mixed2: typeof C1 & typeof M1; +declare const Mixed3: typeof M2 & typeof M1 & typeof C1; +declare const Mixed4: typeof C1 & typeof M1 & typeof M2; +declare const Mixed5: typeof M1 & typeof M2; +declare function f1(): void; +declare function f2(): void; +declare function f3(): void; +declare function f4(): void; +declare function f5(): void; +declare function f6(): void; +declare class C2 extends Mixed1 { + constructor(); +} +declare class C3 extends Mixed3 { + constructor(); + f(): number; +} diff --git a/tests/baselines/reference/mixinClassesMembers.symbols b/tests/baselines/reference/mixinClassesMembers.symbols new file mode 100644 index 00000000000..fabfe7e6d86 --- /dev/null +++ b/tests/baselines/reference/mixinClassesMembers.symbols @@ -0,0 +1,309 @@ +=== tests/cases/conformance/classes/mixinClassesMembers.ts === + +declare class C1 { +>C1 : Symbol(C1, Decl(mixinClassesMembers.ts, 0, 0)) + + public a: number; +>a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18)) + + protected b: number; +>b : Symbol(C1.b, Decl(mixinClassesMembers.ts, 2, 21)) + + private c: number; +>c : Symbol(C1.c, Decl(mixinClassesMembers.ts, 3, 24)) + + constructor(s: string); +>s : Symbol(s, Decl(mixinClassesMembers.ts, 5, 16)) + + constructor(n: number); +>n : Symbol(n, Decl(mixinClassesMembers.ts, 6, 16)) +} + +declare class M1 { +>M1 : Symbol(M1, Decl(mixinClassesMembers.ts, 7, 1)) + + constructor(...args: any[]); +>args : Symbol(args, Decl(mixinClassesMembers.ts, 10, 16)) + + p: number; +>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32)) + + static p: number; +>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14)) +} + +declare class M2 { +>M2 : Symbol(M2, Decl(mixinClassesMembers.ts, 13, 1)) + + constructor(...args: any[]); +>args : Symbol(args, Decl(mixinClassesMembers.ts, 16, 16)) + + f(): number; +>f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 16, 32)) + + static f(): number; +>f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 17, 16)) +} + +declare const Mixed1: typeof M1 & typeof C1; +>Mixed1 : Symbol(Mixed1, Decl(mixinClassesMembers.ts, 21, 13)) +>M1 : Symbol(M1, Decl(mixinClassesMembers.ts, 7, 1)) +>C1 : Symbol(C1, Decl(mixinClassesMembers.ts, 0, 0)) + +declare const Mixed2: typeof C1 & typeof M1; +>Mixed2 : Symbol(Mixed2, Decl(mixinClassesMembers.ts, 22, 13)) +>C1 : Symbol(C1, Decl(mixinClassesMembers.ts, 0, 0)) +>M1 : Symbol(M1, Decl(mixinClassesMembers.ts, 7, 1)) + +declare const Mixed3: typeof M2 & typeof M1 & typeof C1; +>Mixed3 : Symbol(Mixed3, Decl(mixinClassesMembers.ts, 23, 13)) +>M2 : Symbol(M2, Decl(mixinClassesMembers.ts, 13, 1)) +>M1 : Symbol(M1, Decl(mixinClassesMembers.ts, 7, 1)) +>C1 : Symbol(C1, Decl(mixinClassesMembers.ts, 0, 0)) + +declare const Mixed4: typeof C1 & typeof M1 & typeof M2; +>Mixed4 : Symbol(Mixed4, Decl(mixinClassesMembers.ts, 24, 13)) +>C1 : Symbol(C1, Decl(mixinClassesMembers.ts, 0, 0)) +>M1 : Symbol(M1, Decl(mixinClassesMembers.ts, 7, 1)) +>M2 : Symbol(M2, Decl(mixinClassesMembers.ts, 13, 1)) + +declare const Mixed5: typeof M1 & typeof M2; +>Mixed5 : Symbol(Mixed5, Decl(mixinClassesMembers.ts, 25, 13)) +>M1 : Symbol(M1, Decl(mixinClassesMembers.ts, 7, 1)) +>M2 : Symbol(M2, Decl(mixinClassesMembers.ts, 13, 1)) + +function f1() { +>f1 : Symbol(f1, Decl(mixinClassesMembers.ts, 25, 44)) + + let x1 = new Mixed1("hello"); +>x1 : Symbol(x1, Decl(mixinClassesMembers.ts, 28, 7)) +>Mixed1 : Symbol(Mixed1, Decl(mixinClassesMembers.ts, 21, 13)) + + let x2 = new Mixed1(42); +>x2 : Symbol(x2, Decl(mixinClassesMembers.ts, 29, 7)) +>Mixed1 : Symbol(Mixed1, Decl(mixinClassesMembers.ts, 21, 13)) + + let x3 = new Mixed2("hello"); +>x3 : Symbol(x3, Decl(mixinClassesMembers.ts, 30, 7)) +>Mixed2 : Symbol(Mixed2, Decl(mixinClassesMembers.ts, 22, 13)) + + let x4 = new Mixed2(42); +>x4 : Symbol(x4, Decl(mixinClassesMembers.ts, 31, 7)) +>Mixed2 : Symbol(Mixed2, Decl(mixinClassesMembers.ts, 22, 13)) + + let x5 = new Mixed3("hello"); +>x5 : Symbol(x5, Decl(mixinClassesMembers.ts, 32, 7)) +>Mixed3 : Symbol(Mixed3, Decl(mixinClassesMembers.ts, 23, 13)) + + let x6 = new Mixed3(42); +>x6 : Symbol(x6, Decl(mixinClassesMembers.ts, 33, 7)) +>Mixed3 : Symbol(Mixed3, Decl(mixinClassesMembers.ts, 23, 13)) + + let x7 = new Mixed4("hello"); +>x7 : Symbol(x7, Decl(mixinClassesMembers.ts, 34, 7)) +>Mixed4 : Symbol(Mixed4, Decl(mixinClassesMembers.ts, 24, 13)) + + let x8 = new Mixed4(42); +>x8 : Symbol(x8, Decl(mixinClassesMembers.ts, 35, 7)) +>Mixed4 : Symbol(Mixed4, Decl(mixinClassesMembers.ts, 24, 13)) + + let x9 = new Mixed5(); +>x9 : Symbol(x9, Decl(mixinClassesMembers.ts, 36, 7)) +>Mixed5 : Symbol(Mixed5, Decl(mixinClassesMembers.ts, 25, 13)) +} + +function f2() { +>f2 : Symbol(f2, Decl(mixinClassesMembers.ts, 37, 1)) + + let x = new Mixed1("hello"); +>x : Symbol(x, Decl(mixinClassesMembers.ts, 40, 7)) +>Mixed1 : Symbol(Mixed1, Decl(mixinClassesMembers.ts, 21, 13)) + + x.a; +>x.a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18)) +>x : Symbol(x, Decl(mixinClassesMembers.ts, 40, 7)) +>a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18)) + + x.p; +>x.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32)) +>x : Symbol(x, Decl(mixinClassesMembers.ts, 40, 7)) +>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32)) + + Mixed1.p; +>Mixed1.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14)) +>Mixed1 : Symbol(Mixed1, Decl(mixinClassesMembers.ts, 21, 13)) +>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14)) +} + +function f3() { +>f3 : Symbol(f3, Decl(mixinClassesMembers.ts, 44, 1)) + + let x = new Mixed2("hello"); +>x : Symbol(x, Decl(mixinClassesMembers.ts, 47, 7)) +>Mixed2 : Symbol(Mixed2, Decl(mixinClassesMembers.ts, 22, 13)) + + x.a; +>x.a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18)) +>x : Symbol(x, Decl(mixinClassesMembers.ts, 47, 7)) +>a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18)) + + x.p; +>x.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32)) +>x : Symbol(x, Decl(mixinClassesMembers.ts, 47, 7)) +>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32)) + + Mixed2.p; +>Mixed2.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14)) +>Mixed2 : Symbol(Mixed2, Decl(mixinClassesMembers.ts, 22, 13)) +>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14)) +} + +function f4() { +>f4 : Symbol(f4, Decl(mixinClassesMembers.ts, 51, 1)) + + let x = new Mixed3("hello"); +>x : Symbol(x, Decl(mixinClassesMembers.ts, 54, 7)) +>Mixed3 : Symbol(Mixed3, Decl(mixinClassesMembers.ts, 23, 13)) + + x.a; +>x.a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18)) +>x : Symbol(x, Decl(mixinClassesMembers.ts, 54, 7)) +>a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18)) + + x.p; +>x.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32)) +>x : Symbol(x, Decl(mixinClassesMembers.ts, 54, 7)) +>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32)) + + x.f(); +>x.f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 16, 32)) +>x : Symbol(x, Decl(mixinClassesMembers.ts, 54, 7)) +>f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 16, 32)) + + Mixed3.p; +>Mixed3.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14)) +>Mixed3 : Symbol(Mixed3, Decl(mixinClassesMembers.ts, 23, 13)) +>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14)) + + Mixed3.f(); +>Mixed3.f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 17, 16)) +>Mixed3 : Symbol(Mixed3, Decl(mixinClassesMembers.ts, 23, 13)) +>f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 17, 16)) +} + +function f5() { +>f5 : Symbol(f5, Decl(mixinClassesMembers.ts, 60, 1)) + + let x = new Mixed4("hello"); +>x : Symbol(x, Decl(mixinClassesMembers.ts, 63, 7)) +>Mixed4 : Symbol(Mixed4, Decl(mixinClassesMembers.ts, 24, 13)) + + x.a; +>x.a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18)) +>x : Symbol(x, Decl(mixinClassesMembers.ts, 63, 7)) +>a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18)) + + x.p; +>x.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32)) +>x : Symbol(x, Decl(mixinClassesMembers.ts, 63, 7)) +>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32)) + + x.f(); +>x.f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 16, 32)) +>x : Symbol(x, Decl(mixinClassesMembers.ts, 63, 7)) +>f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 16, 32)) + + Mixed4.p; +>Mixed4.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14)) +>Mixed4 : Symbol(Mixed4, Decl(mixinClassesMembers.ts, 24, 13)) +>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14)) + + Mixed4.f(); +>Mixed4.f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 17, 16)) +>Mixed4 : Symbol(Mixed4, Decl(mixinClassesMembers.ts, 24, 13)) +>f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 17, 16)) +} + +function f6() { +>f6 : Symbol(f6, Decl(mixinClassesMembers.ts, 69, 1)) + + let x = new Mixed5(); +>x : Symbol(x, Decl(mixinClassesMembers.ts, 72, 7)) +>Mixed5 : Symbol(Mixed5, Decl(mixinClassesMembers.ts, 25, 13)) + + x.p; +>x.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32)) +>x : Symbol(x, Decl(mixinClassesMembers.ts, 72, 7)) +>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32)) + + x.f(); +>x.f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 16, 32)) +>x : Symbol(x, Decl(mixinClassesMembers.ts, 72, 7)) +>f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 16, 32)) + + Mixed5.p; +>Mixed5.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14)) +>Mixed5 : Symbol(Mixed5, Decl(mixinClassesMembers.ts, 25, 13)) +>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 11, 14)) + + Mixed5.f(); +>Mixed5.f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 17, 16)) +>Mixed5 : Symbol(Mixed5, Decl(mixinClassesMembers.ts, 25, 13)) +>f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 17, 16)) +} + +class C2 extends Mixed1 { +>C2 : Symbol(C2, Decl(mixinClassesMembers.ts, 77, 1)) +>Mixed1 : Symbol(Mixed1, Decl(mixinClassesMembers.ts, 21, 13)) + + constructor() { + super("hello"); + this.a; +>this.a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18)) +>this : Symbol(C2, Decl(mixinClassesMembers.ts, 77, 1)) +>a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18)) + + this.b; +>this.b : Symbol(C1.b, Decl(mixinClassesMembers.ts, 2, 21)) +>this : Symbol(C2, Decl(mixinClassesMembers.ts, 77, 1)) +>b : Symbol(C1.b, Decl(mixinClassesMembers.ts, 2, 21)) + + this.p; +>this.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32)) +>this : Symbol(C2, Decl(mixinClassesMembers.ts, 77, 1)) +>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32)) + } +} + +class C3 extends Mixed3 { +>C3 : Symbol(C3, Decl(mixinClassesMembers.ts, 86, 1)) +>Mixed3 : Symbol(Mixed3, Decl(mixinClassesMembers.ts, 23, 13)) + + constructor() { + super(42); + this.a; +>this.a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18)) +>this : Symbol(C3, Decl(mixinClassesMembers.ts, 86, 1)) +>a : Symbol(C1.a, Decl(mixinClassesMembers.ts, 1, 18)) + + this.b; +>this.b : Symbol(C1.b, Decl(mixinClassesMembers.ts, 2, 21)) +>this : Symbol(C3, Decl(mixinClassesMembers.ts, 86, 1)) +>b : Symbol(C1.b, Decl(mixinClassesMembers.ts, 2, 21)) + + this.p; +>this.p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32)) +>this : Symbol(C3, Decl(mixinClassesMembers.ts, 86, 1)) +>p : Symbol(M1.p, Decl(mixinClassesMembers.ts, 10, 32)) + + this.f(); +>this.f : Symbol(C3.f, Decl(mixinClassesMembers.ts, 95, 5)) +>this : Symbol(C3, Decl(mixinClassesMembers.ts, 86, 1)) +>f : Symbol(C3.f, Decl(mixinClassesMembers.ts, 95, 5)) + } + f() { return super.f(); } +>f : Symbol(C3.f, Decl(mixinClassesMembers.ts, 95, 5)) +>super.f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 16, 32)) +>f : Symbol(M2.f, Decl(mixinClassesMembers.ts, 16, 32)) +} + diff --git a/tests/baselines/reference/mixinClassesMembers.types b/tests/baselines/reference/mixinClassesMembers.types new file mode 100644 index 00000000000..c8b29175415 --- /dev/null +++ b/tests/baselines/reference/mixinClassesMembers.types @@ -0,0 +1,352 @@ +=== tests/cases/conformance/classes/mixinClassesMembers.ts === + +declare class C1 { +>C1 : C1 + + public a: number; +>a : number + + protected b: number; +>b : number + + private c: number; +>c : number + + constructor(s: string); +>s : string + + constructor(n: number); +>n : number +} + +declare class M1 { +>M1 : M1 + + constructor(...args: any[]); +>args : any[] + + p: number; +>p : number + + static p: number; +>p : number +} + +declare class M2 { +>M2 : M2 + + constructor(...args: any[]); +>args : any[] + + f(): number; +>f : () => number + + static f(): number; +>f : () => number +} + +declare const Mixed1: typeof M1 & typeof C1; +>Mixed1 : typeof M1 & typeof C1 +>M1 : typeof M1 +>C1 : typeof C1 + +declare const Mixed2: typeof C1 & typeof M1; +>Mixed2 : typeof C1 & typeof M1 +>C1 : typeof C1 +>M1 : typeof M1 + +declare const Mixed3: typeof M2 & typeof M1 & typeof C1; +>Mixed3 : typeof M2 & typeof M1 & typeof C1 +>M2 : typeof M2 +>M1 : typeof M1 +>C1 : typeof C1 + +declare const Mixed4: typeof C1 & typeof M1 & typeof M2; +>Mixed4 : typeof C1 & typeof M1 & typeof M2 +>C1 : typeof C1 +>M1 : typeof M1 +>M2 : typeof M2 + +declare const Mixed5: typeof M1 & typeof M2; +>Mixed5 : typeof M1 & typeof M2 +>M1 : typeof M1 +>M2 : typeof M2 + +function f1() { +>f1 : () => void + + let x1 = new Mixed1("hello"); +>x1 : M1 & C1 +>new Mixed1("hello") : M1 & C1 +>Mixed1 : typeof M1 & typeof C1 +>"hello" : "hello" + + let x2 = new Mixed1(42); +>x2 : M1 & C1 +>new Mixed1(42) : M1 & C1 +>Mixed1 : typeof M1 & typeof C1 +>42 : 42 + + let x3 = new Mixed2("hello"); +>x3 : C1 & M1 +>new Mixed2("hello") : C1 & M1 +>Mixed2 : typeof C1 & typeof M1 +>"hello" : "hello" + + let x4 = new Mixed2(42); +>x4 : C1 & M1 +>new Mixed2(42) : C1 & M1 +>Mixed2 : typeof C1 & typeof M1 +>42 : 42 + + let x5 = new Mixed3("hello"); +>x5 : M2 & M1 & C1 +>new Mixed3("hello") : M2 & M1 & C1 +>Mixed3 : typeof M2 & typeof M1 & typeof C1 +>"hello" : "hello" + + let x6 = new Mixed3(42); +>x6 : M2 & M1 & C1 +>new Mixed3(42) : M2 & M1 & C1 +>Mixed3 : typeof M2 & typeof M1 & typeof C1 +>42 : 42 + + let x7 = new Mixed4("hello"); +>x7 : C1 & M1 & M2 +>new Mixed4("hello") : C1 & M1 & M2 +>Mixed4 : typeof C1 & typeof M1 & typeof M2 +>"hello" : "hello" + + let x8 = new Mixed4(42); +>x8 : C1 & M1 & M2 +>new Mixed4(42) : C1 & M1 & M2 +>Mixed4 : typeof C1 & typeof M1 & typeof M2 +>42 : 42 + + let x9 = new Mixed5(); +>x9 : M1 & M2 +>new Mixed5() : M1 & M2 +>Mixed5 : typeof M1 & typeof M2 +} + +function f2() { +>f2 : () => void + + let x = new Mixed1("hello"); +>x : M1 & C1 +>new Mixed1("hello") : M1 & C1 +>Mixed1 : typeof M1 & typeof C1 +>"hello" : "hello" + + x.a; +>x.a : number +>x : M1 & C1 +>a : number + + x.p; +>x.p : number +>x : M1 & C1 +>p : number + + Mixed1.p; +>Mixed1.p : number +>Mixed1 : typeof M1 & typeof C1 +>p : number +} + +function f3() { +>f3 : () => void + + let x = new Mixed2("hello"); +>x : C1 & M1 +>new Mixed2("hello") : C1 & M1 +>Mixed2 : typeof C1 & typeof M1 +>"hello" : "hello" + + x.a; +>x.a : number +>x : C1 & M1 +>a : number + + x.p; +>x.p : number +>x : C1 & M1 +>p : number + + Mixed2.p; +>Mixed2.p : number +>Mixed2 : typeof C1 & typeof M1 +>p : number +} + +function f4() { +>f4 : () => void + + let x = new Mixed3("hello"); +>x : M2 & M1 & C1 +>new Mixed3("hello") : M2 & M1 & C1 +>Mixed3 : typeof M2 & typeof M1 & typeof C1 +>"hello" : "hello" + + x.a; +>x.a : number +>x : M2 & M1 & C1 +>a : number + + x.p; +>x.p : number +>x : M2 & M1 & C1 +>p : number + + x.f(); +>x.f() : number +>x.f : () => number +>x : M2 & M1 & C1 +>f : () => number + + Mixed3.p; +>Mixed3.p : number +>Mixed3 : typeof M2 & typeof M1 & typeof C1 +>p : number + + Mixed3.f(); +>Mixed3.f() : number +>Mixed3.f : () => number +>Mixed3 : typeof M2 & typeof M1 & typeof C1 +>f : () => number +} + +function f5() { +>f5 : () => void + + let x = new Mixed4("hello"); +>x : C1 & M1 & M2 +>new Mixed4("hello") : C1 & M1 & M2 +>Mixed4 : typeof C1 & typeof M1 & typeof M2 +>"hello" : "hello" + + x.a; +>x.a : number +>x : C1 & M1 & M2 +>a : number + + x.p; +>x.p : number +>x : C1 & M1 & M2 +>p : number + + x.f(); +>x.f() : number +>x.f : () => number +>x : C1 & M1 & M2 +>f : () => number + + Mixed4.p; +>Mixed4.p : number +>Mixed4 : typeof C1 & typeof M1 & typeof M2 +>p : number + + Mixed4.f(); +>Mixed4.f() : number +>Mixed4.f : () => number +>Mixed4 : typeof C1 & typeof M1 & typeof M2 +>f : () => number +} + +function f6() { +>f6 : () => void + + let x = new Mixed5(); +>x : M1 & M2 +>new Mixed5() : M1 & M2 +>Mixed5 : typeof M1 & typeof M2 + + x.p; +>x.p : number +>x : M1 & M2 +>p : number + + x.f(); +>x.f() : number +>x.f : () => number +>x : M1 & M2 +>f : () => number + + Mixed5.p; +>Mixed5.p : number +>Mixed5 : typeof M1 & typeof M2 +>p : number + + Mixed5.f(); +>Mixed5.f() : number +>Mixed5.f : () => number +>Mixed5 : typeof M1 & typeof M2 +>f : () => number +} + +class C2 extends Mixed1 { +>C2 : C2 +>Mixed1 : M1 & C1 + + constructor() { + super("hello"); +>super("hello") : void +>super : typeof M1 & typeof C1 +>"hello" : "hello" + + this.a; +>this.a : number +>this : this +>a : number + + this.b; +>this.b : number +>this : this +>b : number + + this.p; +>this.p : number +>this : this +>p : number + } +} + +class C3 extends Mixed3 { +>C3 : C3 +>Mixed3 : M2 & M1 & C1 + + constructor() { + super(42); +>super(42) : void +>super : typeof M2 & typeof M1 & typeof C1 +>42 : 42 + + this.a; +>this.a : number +>this : this +>a : number + + this.b; +>this.b : number +>this : this +>b : number + + this.p; +>this.p : number +>this : this +>p : number + + this.f(); +>this.f() : number +>this.f : () => number +>this : this +>f : () => number + } + f() { return super.f(); } +>f : () => number +>super.f() : number +>super.f : () => number +>super : M2 & M1 & C1 +>f : () => number +} + diff --git a/tests/baselines/reference/mixinPrivateAndProtected.errors.txt b/tests/baselines/reference/mixinPrivateAndProtected.errors.txt new file mode 100644 index 00000000000..131aff967d9 --- /dev/null +++ b/tests/baselines/reference/mixinPrivateAndProtected.errors.txt @@ -0,0 +1,116 @@ +tests/cases/compiler/mixinPrivateAndProtected.ts(46,3): error TS2445: Property 'ptd' is protected and only accessible within class 'A' and its subclasses. +tests/cases/compiler/mixinPrivateAndProtected.ts(47,3): error TS2341: Property 'pvt' is private and only accessible within class 'A'. +tests/cases/compiler/mixinPrivateAndProtected.ts(50,4): error TS2445: Property 'ptd' is protected and only accessible within class 'mixB.(Anonymous class) & A' and its subclasses. +tests/cases/compiler/mixinPrivateAndProtected.ts(51,4): error TS2546: Property 'pvt' has conflicting declarations and is inaccessible in type 'mixB.(Anonymous class) & A'. +tests/cases/compiler/mixinPrivateAndProtected.ts(54,5): error TS2445: Property 'ptd' is protected and only accessible within class 'mixC<{ new (...args: any[]): mixB.(Anonymous class); prototype: mixB.(Anonymous class); } & typeof A>.(Anonymous class) & mixB.(Anonymous class) & A' and its subclasses. +tests/cases/compiler/mixinPrivateAndProtected.ts(55,5): error TS2546: Property 'pvt' has conflicting declarations and is inaccessible in type 'mixC<{ new (...args: any[]): mixB.(Anonymous class); prototype: mixB.(Anonymous class); } & typeof A>.(Anonymous class) & mixB.(Anonymous class) & A'. +tests/cases/compiler/mixinPrivateAndProtected.ts(58,6): error TS2445: Property 'ptd' is protected and only accessible within class 'mixC<{ new (...args: any[]): mixB2.(Anonymous class); prototype: mixB2.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2.(Anonymous class) & A' and its subclasses. +tests/cases/compiler/mixinPrivateAndProtected.ts(59,6): error TS2546: Property 'pvt' has conflicting declarations and is inaccessible in type 'mixC<{ new (...args: any[]): mixB2.(Anonymous class); prototype: mixB2.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2.(Anonymous class) & A'. + + +==== tests/cases/compiler/mixinPrivateAndProtected.ts (8 errors) ==== + // Repro from #13830 + + type Constructor = new(...args: any[]) => T; + + class A { + public pb: number = 2; + protected ptd: number = 1; + private pvt: number = 0; + } + + function mixB>(Cls: T) { + return class extends Cls { + protected ptd: number = 10; + private pvt: number = 0; + }; + } + + function mixB2>(Cls: T) { + return class extends Cls { + protected ptd: number = 10; + }; + } + + const + AB = mixB(A), + AB2 = mixB2(A); + + function mixC>(Cls: T) { + return class extends Cls { + protected ptd: number = 100; + private pvt: number = 0; + }; + } + + const + AB2C = mixC(AB2), + ABC = mixC(AB); + + const + a = new A(), + ab = new AB(), + abc = new ABC(), + ab2c = new AB2C(); + + a.pb.toFixed(); + a.ptd.toFixed(); // Error + ~~~ +!!! error TS2445: Property 'ptd' is protected and only accessible within class 'A' and its subclasses. + a.pvt.toFixed(); // Error + ~~~ +!!! error TS2341: Property 'pvt' is private and only accessible within class 'A'. + + ab.pb.toFixed(); + ab.ptd.toFixed(); // Error + ~~~ +!!! error TS2445: Property 'ptd' is protected and only accessible within class 'mixB.(Anonymous class) & A' and its subclasses. + ab.pvt.toFixed(); // Error + ~~~ +!!! error TS2546: Property 'pvt' has conflicting declarations and is inaccessible in type 'mixB.(Anonymous class) & A'. + + abc.pb.toFixed(); + abc.ptd.toFixed(); // Error + ~~~ +!!! error TS2445: Property 'ptd' is protected and only accessible within class 'mixC<{ new (...args: any[]): mixB.(Anonymous class); prototype: mixB.(Anonymous class); } & typeof A>.(Anonymous class) & mixB.(Anonymous class) & A' and its subclasses. + abc.pvt.toFixed(); // Error + ~~~ +!!! error TS2546: Property 'pvt' has conflicting declarations and is inaccessible in type 'mixC<{ new (...args: any[]): mixB.(Anonymous class); prototype: mixB.(Anonymous class); } & typeof A>.(Anonymous class) & mixB.(Anonymous class) & A'. + + ab2c.pb.toFixed(); + ab2c.ptd.toFixed(); // Error + ~~~ +!!! error TS2445: Property 'ptd' is protected and only accessible within class 'mixC<{ new (...args: any[]): mixB2.(Anonymous class); prototype: mixB2.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2.(Anonymous class) & A' and its subclasses. + ab2c.pvt.toFixed(); // Error + ~~~ +!!! error TS2546: Property 'pvt' has conflicting declarations and is inaccessible in type 'mixC<{ new (...args: any[]): mixB2.(Anonymous class); prototype: mixB2.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2.(Anonymous class) & A'. + + // Repro from #13924 + + class Person { + constructor(public name: string) {} + + protected myProtectedFunction() { + // do something + } + } + + function PersonMixin>(Base: T) { + return class extends Base { + constructor(...args: any[]) { + super(...args); + } + + myProtectedFunction() { + super.myProtectedFunction(); + // do more things + } + }; + } + + class Customer extends PersonMixin(Person) { + accountBalance: number; + f() { + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/mixinPrivateAndProtected.js b/tests/baselines/reference/mixinPrivateAndProtected.js new file mode 100644 index 00000000000..9b8f3ee0c12 --- /dev/null +++ b/tests/baselines/reference/mixinPrivateAndProtected.js @@ -0,0 +1,197 @@ +//// [mixinPrivateAndProtected.ts] +// Repro from #13830 + +type Constructor = new(...args: any[]) => T; + +class A { + public pb: number = 2; + protected ptd: number = 1; + private pvt: number = 0; +} + +function mixB>(Cls: T) { + return class extends Cls { + protected ptd: number = 10; + private pvt: number = 0; + }; +} + +function mixB2>(Cls: T) { + return class extends Cls { + protected ptd: number = 10; + }; +} + +const + AB = mixB(A), + AB2 = mixB2(A); + +function mixC>(Cls: T) { + return class extends Cls { + protected ptd: number = 100; + private pvt: number = 0; + }; +} + +const + AB2C = mixC(AB2), + ABC = mixC(AB); + +const + a = new A(), + ab = new AB(), + abc = new ABC(), + ab2c = new AB2C(); + +a.pb.toFixed(); +a.ptd.toFixed(); // Error +a.pvt.toFixed(); // Error + +ab.pb.toFixed(); +ab.ptd.toFixed(); // Error +ab.pvt.toFixed(); // Error + +abc.pb.toFixed(); +abc.ptd.toFixed(); // Error +abc.pvt.toFixed(); // Error + +ab2c.pb.toFixed(); +ab2c.ptd.toFixed(); // Error +ab2c.pvt.toFixed(); // Error + +// Repro from #13924 + +class Person { + constructor(public name: string) {} + + protected myProtectedFunction() { + // do something + } +} + +function PersonMixin>(Base: T) { + return class extends Base { + constructor(...args: any[]) { + super(...args); + } + + myProtectedFunction() { + super.myProtectedFunction(); + // do more things + } + }; +} + +class Customer extends PersonMixin(Person) { + accountBalance: number; + f() { + } +} + + +//// [mixinPrivateAndProtected.js] +// Repro from #13830 +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var A = (function () { + function A() { + this.pb = 2; + this.ptd = 1; + this.pvt = 0; + } + return A; +}()); +function mixB(Cls) { + return (function (_super) { + __extends(class_1, _super); + function class_1() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.ptd = 10; + _this.pvt = 0; + return _this; + } + return class_1; + }(Cls)); +} +function mixB2(Cls) { + return (function (_super) { + __extends(class_2, _super); + function class_2() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.ptd = 10; + return _this; + } + return class_2; + }(Cls)); +} +var AB = mixB(A), AB2 = mixB2(A); +function mixC(Cls) { + return (function (_super) { + __extends(class_3, _super); + function class_3() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.ptd = 100; + _this.pvt = 0; + return _this; + } + return class_3; + }(Cls)); +} +var AB2C = mixC(AB2), ABC = mixC(AB); +var a = new A(), ab = new AB(), abc = new ABC(), ab2c = new AB2C(); +a.pb.toFixed(); +a.ptd.toFixed(); // Error +a.pvt.toFixed(); // Error +ab.pb.toFixed(); +ab.ptd.toFixed(); // Error +ab.pvt.toFixed(); // Error +abc.pb.toFixed(); +abc.ptd.toFixed(); // Error +abc.pvt.toFixed(); // Error +ab2c.pb.toFixed(); +ab2c.ptd.toFixed(); // Error +ab2c.pvt.toFixed(); // Error +// Repro from #13924 +var Person = (function () { + function Person(name) { + this.name = name; + } + Person.prototype.myProtectedFunction = function () { + // do something + }; + return Person; +}()); +function PersonMixin(Base) { + return (function (_super) { + __extends(class_4, _super); + function class_4() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return _super.apply(this, args) || this; + } + class_4.prototype.myProtectedFunction = function () { + _super.prototype.myProtectedFunction.call(this); + // do more things + }; + return class_4; + }(Base)); +} +var Customer = (function (_super) { + __extends(Customer, _super); + function Customer() { + return _super !== null && _super.apply(this, arguments) || this; + } + Customer.prototype.f = function () { + }; + return Customer; +}(PersonMixin(Person))); diff --git a/tests/baselines/reference/modularizeLibrary_Dom.iterable.types b/tests/baselines/reference/modularizeLibrary_Dom.iterable.types index 054923fb5ee..f9a58d554cf 100644 --- a/tests/baselines/reference/modularizeLibrary_Dom.iterable.types +++ b/tests/baselines/reference/modularizeLibrary_Dom.iterable.types @@ -3,9 +3,9 @@ for (const element of document.getElementsByTagName("a")) { >element : HTMLAnchorElement >document.getElementsByTagName("a") : NodeListOf ->document.getElementsByTagName : { (tagname: K): ElementListTagNameMap[K]; (tagname: string): NodeListOf; } +>document.getElementsByTagName : { (tagname: K): ElementListTagNameMap[K]; (tagname: string): NodeListOf; } >document : Document ->getElementsByTagName : { (tagname: K): ElementListTagNameMap[K]; (tagname: string): NodeListOf; } +>getElementsByTagName : { (tagname: K): ElementListTagNameMap[K]; (tagname: string): NodeListOf; } >"a" : "a" element.href; diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols index d8520698e6c..62473581abe 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols @@ -112,7 +112,7 @@ async function out() { >out : Symbol(out, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 45, 37)) return new Promise(function (resolve, reject) {}); ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >resolve : Symbol(resolve, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 49, 33)) >reject : Symbol(reject, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 49, 41)) } @@ -121,9 +121,9 @@ declare var console: any; >console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 52, 11)) out().then(() => { ->out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>out().then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >out : Symbol(out, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 45, 37)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) console.log("Yea!"); >console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 52, 11)) diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types index 40b299d63a0..b259e30172d 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types @@ -148,10 +148,10 @@ declare var console: any; out().then(() => { >out().then(() => { console.log("Yea!");}) : Promise ->out().then : { (onfulfilled?: (value: {}) => {} | PromiseLike<{}>, onrejected?: (reason: any) => {} | PromiseLike<{}>): Promise<{}>; (onfulfilled: (value: {}) => {} | PromiseLike<{}>, onrejected: (reason: any) => TResult | PromiseLike): Promise<{} | TResult>; (onfulfilled: (value: {}) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: {}) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>out().then : (onfulfilled?: (value: {}) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >out() : Promise<{}> >out : () => Promise<{}> ->then : { (onfulfilled?: (value: {}) => {} | PromiseLike<{}>, onrejected?: (reason: any) => {} | PromiseLike<{}>): Promise<{}>; (onfulfilled: (value: {}) => {} | PromiseLike<{}>, onrejected: (reason: any) => TResult | PromiseLike): Promise<{} | TResult>; (onfulfilled: (value: {}) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: {}) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: {}) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => { console.log("Yea!");} : () => void console.log("Yea!"); diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols index ea1eb599c6f..ccb78b1c367 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols @@ -112,7 +112,7 @@ async function out() { >out : Symbol(out, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 45, 37)) return new Promise(function (resolve, reject) {}); ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >resolve : Symbol(resolve, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 49, 33)) >reject : Symbol(reject, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 49, 41)) } @@ -121,9 +121,9 @@ declare var console: any; >console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 52, 11)) out().then(() => { ->out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>out().then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >out : Symbol(out, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 45, 37)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) console.log("Yea!"); >console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 52, 11)) diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types index 3022a0ce8b1..4fa4c085bca 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types @@ -148,10 +148,10 @@ declare var console: any; out().then(() => { >out().then(() => { console.log("Yea!");}) : Promise ->out().then : { (onfulfilled?: (value: {}) => {} | PromiseLike<{}>, onrejected?: (reason: any) => {} | PromiseLike<{}>): Promise<{}>; (onfulfilled: (value: {}) => {} | PromiseLike<{}>, onrejected: (reason: any) => TResult | PromiseLike): Promise<{} | TResult>; (onfulfilled: (value: {}) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: {}) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>out().then : (onfulfilled?: (value: {}) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >out() : Promise<{}> >out : () => Promise<{}> ->then : { (onfulfilled?: (value: {}) => {} | PromiseLike<{}>, onrejected?: (reason: any) => {} | PromiseLike<{}>): Promise<{}>; (onfulfilled: (value: {}) => {} | PromiseLike<{}>, onrejected: (reason: any) => TResult | PromiseLike): Promise<{} | TResult>; (onfulfilled: (value: {}) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: {}) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: {}) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => { console.log("Yea!");} : () => void console.log("Yea!"); diff --git a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols index ed1fb96ded3..0bbffee6c86 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols +++ b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols @@ -112,7 +112,7 @@ async function out() { >out : Symbol(out, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 45, 37)) return new Promise(function (resolve, reject) {}); ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >resolve : Symbol(resolve, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 49, 33)) >reject : Symbol(reject, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 49, 41)) } @@ -121,9 +121,9 @@ declare var console: any; >console : Symbol(console, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 52, 11)) out().then(() => { ->out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>out().then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >out : Symbol(out, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 45, 37)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) console.log("Yea!"); >console : Symbol(console, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 52, 11)) diff --git a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types index d98ee870295..25cd47601e0 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types +++ b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types @@ -148,10 +148,10 @@ declare var console: any; out().then(() => { >out().then(() => { console.log("Yea!");}) : Promise ->out().then : { (onfulfilled?: (value: {}) => {} | PromiseLike<{}>, onrejected?: (reason: any) => {} | PromiseLike<{}>): Promise<{}>; (onfulfilled: (value: {}) => {} | PromiseLike<{}>, onrejected: (reason: any) => TResult | PromiseLike): Promise<{} | TResult>; (onfulfilled: (value: {}) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: {}) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>out().then : (onfulfilled?: (value: {}) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >out() : Promise<{}> >out : () => Promise<{}> ->then : { (onfulfilled?: (value: {}) => {} | PromiseLike<{}>, onrejected?: (reason: any) => {} | PromiseLike<{}>): Promise<{}>; (onfulfilled: (value: {}) => {} | PromiseLike<{}>, onrejected: (reason: any) => TResult | PromiseLike): Promise<{} | TResult>; (onfulfilled: (value: {}) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: {}) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: {}) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => { console.log("Yea!");} : () => void console.log("Yea!"); diff --git a/tests/baselines/reference/moduleAliasAsFunctionArgument.js b/tests/baselines/reference/moduleAliasAsFunctionArgument.js index b75161da458..16eb962a863 100644 --- a/tests/baselines/reference/moduleAliasAsFunctionArgument.js +++ b/tests/baselines/reference/moduleAliasAsFunctionArgument.js @@ -17,10 +17,12 @@ fn(a); // Error: property 'x' is missing from 'a' //// [moduleAliasAsFunctionArgument_0.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [moduleAliasAsFunctionArgument_1.js] define(["require", "exports", "moduleAliasAsFunctionArgument_0"], function (require, exports, a) { "use strict"; + exports.__esModule = true; function fn(arg) { } a.x; // OK diff --git a/tests/baselines/reference/moduleAsBaseType.js b/tests/baselines/reference/moduleAsBaseType.js index fc0533a2470..2a3ee8f4585 100644 --- a/tests/baselines/reference/moduleAsBaseType.js +++ b/tests/baselines/reference/moduleAsBaseType.js @@ -5,15 +5,20 @@ interface I extends M { } class C2 implements M { } //// [moduleAsBaseType.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(M)); diff --git a/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.js b/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.js index 2e84e1492be..a92cf5093e3 100644 --- a/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.js +++ b/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.js @@ -36,20 +36,24 @@ let x: Observable; //// [observable.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [map1.js] define(["require", "exports", "./observable"], function (require, exports, observable_1) { "use strict"; + exports.__esModule = true; observable_1.Observable.prototype.map = function () { }; }); //// [map2.js] define(["require", "exports", "./observable"], function (require, exports, observable_1) { "use strict"; + exports.__esModule = true; observable_1.Observable.prototype.map = function () { }; }); //// [main.js] define(["require", "exports", "./map1", "./map2"], function (require, exports) { "use strict"; + exports.__esModule = true; var x; }); diff --git a/tests/baselines/reference/moduleAugmentationDeclarationEmit1.js b/tests/baselines/reference/moduleAugmentationDeclarationEmit1.js index 7b44fb7a637..77759306845 100644 --- a/tests/baselines/reference/moduleAugmentationDeclarationEmit1.js +++ b/tests/baselines/reference/moduleAugmentationDeclarationEmit1.js @@ -34,16 +34,19 @@ let y = x.map(x => x + 1); //// [observable.js] "use strict"; +exports.__esModule = true; var Observable; (function (Observable) { var someValue; })(Observable = exports.Observable || (exports.Observable = {})); //// [map.js] "use strict"; +exports.__esModule = true; var observable_1 = require("./observable"); observable_1.Observable.prototype.map = function () { }; //// [main.js] "use strict"; +exports.__esModule = true; require("./map"); var x; var y = x.map(function (x) { return x + 1; }); diff --git a/tests/baselines/reference/moduleAugmentationDeclarationEmit2.js b/tests/baselines/reference/moduleAugmentationDeclarationEmit2.js index 547d017c502..15ca6aaf806 100644 --- a/tests/baselines/reference/moduleAugmentationDeclarationEmit2.js +++ b/tests/baselines/reference/moduleAugmentationDeclarationEmit2.js @@ -36,15 +36,18 @@ let z2 = Observable.someAnotherValue.toLowerCase(); //// [observable.js] "use strict"; +exports.__esModule = true; var Observable; (function (Observable) { })(Observable = exports.Observable || (exports.Observable = {})); //// [map.js] "use strict"; +exports.__esModule = true; var observable_1 = require("./observable"); observable_1.Observable.prototype.map = function () { }; //// [main.js] "use strict"; +exports.__esModule = true; var observable_1 = require("./observable"); require("./map"); var x; diff --git a/tests/baselines/reference/moduleAugmentationDisallowedExtensions.js b/tests/baselines/reference/moduleAugmentationDisallowedExtensions.js index 8c497d63c42..c29bed68e51 100644 --- a/tests/baselines/reference/moduleAugmentationDisallowedExtensions.js +++ b/tests/baselines/reference/moduleAugmentationDisallowedExtensions.js @@ -49,19 +49,24 @@ import "./x"; //// [x0.js] "use strict"; +exports.__esModule = true; exports.a = 1; //// [x.js] "use strict"; +exports.__esModule = true; var N1; (function (N1) { N1.x = 1; })(N1 || (N1 = {})); //// [observable.js] "use strict"; +exports.__esModule = true; exports.x = 1; //// [test.js] "use strict"; +exports.__esModule = true; exports.b = 1; //// [main.js] "use strict"; +exports.__esModule = true; require("./x"); diff --git a/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.js b/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.js index 0a8b1b0b4b5..d6857a28ef1 100644 --- a/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.js +++ b/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.js @@ -36,10 +36,12 @@ let y = x.map(x => x + 1); //// [map.js] "use strict"; +exports.__esModule = true; var observable_1 = require("observable"); observable_1.Observable.prototype.map = function () { }; //// [main.js] "use strict"; +exports.__esModule = true; require("./map"); var x; var y = x.map(function (x) { return x + 1; }); diff --git a/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.js b/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.js index 2d65953e2a3..eee03576336 100644 --- a/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.js +++ b/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.js @@ -38,10 +38,12 @@ let z2 = Observable.someAnotherValue.toLowerCase(); //// [map.js] "use strict"; +exports.__esModule = true; var observable_1 = require("observable"); observable_1.Observable.prototype.map = function () { }; //// [main.js] "use strict"; +exports.__esModule = true; /// var observable_1 = require("observable"); require("./map"); diff --git a/tests/baselines/reference/moduleAugmentationExtendFileModule1.js b/tests/baselines/reference/moduleAugmentationExtendFileModule1.js index a539100c2ed..9d15f3fe387 100644 --- a/tests/baselines/reference/moduleAugmentationExtendFileModule1.js +++ b/tests/baselines/reference/moduleAugmentationExtendFileModule1.js @@ -34,16 +34,19 @@ let y = x.map(x => x + 1); //// [observable.js] "use strict"; +exports.__esModule = true; var Observable; (function (Observable) { var someValue; })(Observable = exports.Observable || (exports.Observable = {})); //// [map.js] "use strict"; +exports.__esModule = true; var observable_1 = require("./observable"); observable_1.Observable.prototype.map = function () { }; //// [main.js] "use strict"; +exports.__esModule = true; require("./map"); var x; var y = x.map(function (x) { return x + 1; }); diff --git a/tests/baselines/reference/moduleAugmentationExtendFileModule2.js b/tests/baselines/reference/moduleAugmentationExtendFileModule2.js index 389f2119aba..072c62862e3 100644 --- a/tests/baselines/reference/moduleAugmentationExtendFileModule2.js +++ b/tests/baselines/reference/moduleAugmentationExtendFileModule2.js @@ -36,15 +36,18 @@ let z2 = Observable.someAnotherValue.toLowerCase(); //// [observable.js] "use strict"; +exports.__esModule = true; var Observable; (function (Observable) { })(Observable = exports.Observable || (exports.Observable = {})); //// [map.js] "use strict"; +exports.__esModule = true; var observable_1 = require("./observable"); observable_1.Observable.prototype.map = function () { }; //// [main.js] "use strict"; +exports.__esModule = true; var observable_1 = require("./observable"); require("./map"); var x; diff --git a/tests/baselines/reference/moduleAugmentationGlobal1.js b/tests/baselines/reference/moduleAugmentationGlobal1.js index 99351642a18..2ef6441692f 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal1.js +++ b/tests/baselines/reference/moduleAugmentationGlobal1.js @@ -20,6 +20,7 @@ let y = x.getA().x; //// [f1.js] "use strict"; +exports.__esModule = true; var A = (function () { function A() { } @@ -28,6 +29,7 @@ var A = (function () { exports.A = A; //// [f2.js] "use strict"; +exports.__esModule = true; var x = [1]; var y = x.getA().x; diff --git a/tests/baselines/reference/moduleAugmentationGlobal2.js b/tests/baselines/reference/moduleAugmentationGlobal2.js index 90e8373302e..1806ceae9a1 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal2.js +++ b/tests/baselines/reference/moduleAugmentationGlobal2.js @@ -20,6 +20,7 @@ let y = x.getCountAsString().toLowerCase(); //// [f1.js] "use strict"; +exports.__esModule = true; var A = (function () { function A() { } @@ -29,6 +30,7 @@ exports.A = A; ; //// [f2.js] "use strict"; +exports.__esModule = true; var x = [1]; var y = x.getCountAsString().toLowerCase(); diff --git a/tests/baselines/reference/moduleAugmentationGlobal3.js b/tests/baselines/reference/moduleAugmentationGlobal3.js index caa080a558c..9cb08f2b866 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal3.js +++ b/tests/baselines/reference/moduleAugmentationGlobal3.js @@ -23,6 +23,7 @@ let y = x.getCountAsString().toLowerCase(); //// [f1.js] "use strict"; +exports.__esModule = true; var A = (function () { function A() { } @@ -32,8 +33,10 @@ exports.A = A; ; //// [f2.js] "use strict"; +exports.__esModule = true; //// [f3.js] "use strict"; +exports.__esModule = true; require("./f2"); var x = [1]; var y = x.getCountAsString().toLowerCase(); diff --git a/tests/baselines/reference/moduleAugmentationGlobal4.js b/tests/baselines/reference/moduleAugmentationGlobal4.js index 38f186d0e05..194d06aeb80 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal4.js +++ b/tests/baselines/reference/moduleAugmentationGlobal4.js @@ -20,10 +20,13 @@ import "./f2"; //// [f1.js] "use strict"; +exports.__esModule = true; //// [f2.js] "use strict"; +exports.__esModule = true; //// [f3.js] "use strict"; +exports.__esModule = true; require("./f1"); require("./f2"); diff --git a/tests/baselines/reference/moduleAugmentationGlobal5.js b/tests/baselines/reference/moduleAugmentationGlobal5.js index 70c81893bd8..43d8c6b958b 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal5.js +++ b/tests/baselines/reference/moduleAugmentationGlobal5.js @@ -23,6 +23,7 @@ import "B"; //// [f3.js] "use strict"; +exports.__esModule = true; /// /// require("A"); diff --git a/tests/baselines/reference/moduleAugmentationGlobal8.js b/tests/baselines/reference/moduleAugmentationGlobal8.js index 261dfd21b58..77b467f9e4d 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal8.js +++ b/tests/baselines/reference/moduleAugmentationGlobal8.js @@ -10,4 +10,5 @@ export {} //// [moduleAugmentationGlobal8.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); }); diff --git a/tests/baselines/reference/moduleAugmentationGlobal8_1.js b/tests/baselines/reference/moduleAugmentationGlobal8_1.js index 2ac585a711b..70e9c336e7c 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal8_1.js +++ b/tests/baselines/reference/moduleAugmentationGlobal8_1.js @@ -10,4 +10,5 @@ export {} //// [moduleAugmentationGlobal8_1.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); }); diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports1.js b/tests/baselines/reference/moduleAugmentationImportsAndExports1.js index 8e0b7dad19d..66ce39e8d84 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports1.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports1.js @@ -29,6 +29,7 @@ let b = a.foo().n; //// [f1.js] "use strict"; +exports.__esModule = true; var A = (function () { function A() { } @@ -37,6 +38,7 @@ var A = (function () { exports.A = A; //// [f2.js] "use strict"; +exports.__esModule = true; var B = (function () { function B() { } @@ -45,10 +47,12 @@ var B = (function () { exports.B = B; //// [f3.js] "use strict"; +exports.__esModule = true; var f1_1 = require("./f1"); f1_1.A.prototype.foo = function () { return undefined; }; //// [f4.js] "use strict"; +exports.__esModule = true; require("./f3"); var a; var b = a.foo().n; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports2.js b/tests/baselines/reference/moduleAugmentationImportsAndExports2.js index 498df8ab90e..e79f2e58484 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports2.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports2.js @@ -41,6 +41,7 @@ let b = a.foo().n; //// [f1.js] "use strict"; +exports.__esModule = true; var A = (function () { function A() { } @@ -49,6 +50,7 @@ var A = (function () { exports.A = A; //// [f2.js] "use strict"; +exports.__esModule = true; var B = (function () { function B() { } @@ -57,10 +59,12 @@ var B = (function () { exports.B = B; //// [f3.js] "use strict"; +exports.__esModule = true; var f1_1 = require("./f1"); f1_1.A.prototype.foo = function () { return undefined; }; //// [f4.js] "use strict"; +exports.__esModule = true; require("./f3"); var a; var b = a.foo().n; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports3.js b/tests/baselines/reference/moduleAugmentationImportsAndExports3.js index 8d9e69c5076..c7c13ea7861 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports3.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports3.js @@ -39,6 +39,7 @@ let b = a.foo().n; //// [f1.js] "use strict"; +exports.__esModule = true; var A = (function () { function A() { } @@ -47,6 +48,7 @@ var A = (function () { exports.A = A; //// [f2.js] "use strict"; +exports.__esModule = true; var B = (function () { function B() { } @@ -55,10 +57,12 @@ var B = (function () { exports.B = B; //// [f3.js] "use strict"; +exports.__esModule = true; var f1_1 = require("./f1"); f1_1.A.prototype.foo = function () { return undefined; }; //// [f4.js] "use strict"; +exports.__esModule = true; require("./f3"); var a; var b = a.foo().n; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports4.js b/tests/baselines/reference/moduleAugmentationImportsAndExports4.js index 53095555815..9cdf76b90a5 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports4.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports4.js @@ -41,6 +41,7 @@ let d = a.baz().b; //// [f1.js] "use strict"; +exports.__esModule = true; var A = (function () { function A() { } @@ -49,6 +50,7 @@ var A = (function () { exports.A = A; //// [f2.js] "use strict"; +exports.__esModule = true; var B = (function () { function B() { } @@ -57,10 +59,12 @@ var B = (function () { exports.B = B; //// [f3.js] "use strict"; +exports.__esModule = true; var f1_1 = require("./f1"); f1_1.A.prototype.foo = function () { return undefined; }; //// [f4.js] "use strict"; +exports.__esModule = true; require("./f3"); var a; var b = a.foo().n; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports5.js b/tests/baselines/reference/moduleAugmentationImportsAndExports5.js index c3cba4c01f8..c7f7990608e 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports5.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports5.js @@ -41,6 +41,7 @@ let d = a.baz().b; //// [f1.js] "use strict"; +exports.__esModule = true; var A = (function () { function A() { } @@ -49,6 +50,7 @@ var A = (function () { exports.A = A; //// [f2.js] "use strict"; +exports.__esModule = true; var B = (function () { function B() { } @@ -57,10 +59,12 @@ var B = (function () { exports.B = B; //// [f3.js] "use strict"; +exports.__esModule = true; var f1_1 = require("./f1"); f1_1.A.prototype.foo = function () { return undefined; }; //// [f4.js] "use strict"; +exports.__esModule = true; require("./f3"); var a; var b = a.foo().n; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports6.js b/tests/baselines/reference/moduleAugmentationImportsAndExports6.js index f5aff705eb4..0f19e737ec5 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports6.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports6.js @@ -41,6 +41,7 @@ let d = a.baz().b; //// [f1.js] "use strict"; +exports.__esModule = true; var A = (function () { function A() { } @@ -49,6 +50,7 @@ var A = (function () { exports.A = A; //// [f2.js] "use strict"; +exports.__esModule = true; var B = (function () { function B() { } @@ -57,10 +59,12 @@ var B = (function () { exports.B = B; //// [f3.js] "use strict"; +exports.__esModule = true; var f1_1 = require("./f1"); f1_1.A.prototype.foo = function () { return undefined; }; //// [f4.js] "use strict"; +exports.__esModule = true; require("./f3"); var a; var b = a.foo().n; diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule1.js b/tests/baselines/reference/moduleAugmentationInAmbientModule1.js index aecb8954d53..4cdef37a4f7 100644 --- a/tests/baselines/reference/moduleAugmentationInAmbientModule1.js +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule1.js @@ -31,6 +31,7 @@ x.foo().x; //// [main.js] /// "use strict"; +exports.__esModule = true; var x; x.foo().x; diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule2.js b/tests/baselines/reference/moduleAugmentationInAmbientModule2.js index 5529afc674f..536931ee61f 100644 --- a/tests/baselines/reference/moduleAugmentationInAmbientModule2.js +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule2.js @@ -31,6 +31,7 @@ x.foo().x; //// [main.js] /// "use strict"; +exports.__esModule = true; require("Map"); var x; x.foo().x; diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule3.js b/tests/baselines/reference/moduleAugmentationInAmbientModule3.js index 3a94c50ef1f..37253ab7e5b 100644 --- a/tests/baselines/reference/moduleAugmentationInAmbientModule3.js +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule3.js @@ -41,6 +41,7 @@ x.foo2().x2; //// [main.js] /// "use strict"; +exports.__esModule = true; require("Map"); var x; x.foo().x; diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule4.js b/tests/baselines/reference/moduleAugmentationInAmbientModule4.js index bf0339d3107..0c861447b46 100644 --- a/tests/baselines/reference/moduleAugmentationInAmbientModule4.js +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule4.js @@ -44,6 +44,7 @@ x.foo2().x2; /// /// "use strict"; +exports.__esModule = true; require("Map"); var x; x.foo().x; diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule5.js b/tests/baselines/reference/moduleAugmentationInAmbientModule5.js index 2e6503c4774..ac202784f43 100644 --- a/tests/baselines/reference/moduleAugmentationInAmbientModule5.js +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule5.js @@ -25,6 +25,7 @@ let y = x.getA().x; //// [f.js] "use strict"; +exports.__esModule = true; /// require("array"); var x = [1]; diff --git a/tests/baselines/reference/moduleAugmentationInDependency.js b/tests/baselines/reference/moduleAugmentationInDependency.js index 1c5995339c3..31c82ad18e8 100644 --- a/tests/baselines/reference/moduleAugmentationInDependency.js +++ b/tests/baselines/reference/moduleAugmentationInDependency.js @@ -10,4 +10,5 @@ import "A" //// [app.js] "use strict"; +exports.__esModule = true; require("A"); diff --git a/tests/baselines/reference/moduleAugmentationInDependency2.js b/tests/baselines/reference/moduleAugmentationInDependency2.js index 381f1e72d8f..e7a964650bd 100644 --- a/tests/baselines/reference/moduleAugmentationInDependency2.js +++ b/tests/baselines/reference/moduleAugmentationInDependency2.js @@ -10,6 +10,8 @@ import "A" //// [index.js] "use strict"; +exports.__esModule = true; //// [app.js] "use strict"; +exports.__esModule = true; require("A"); diff --git a/tests/baselines/reference/moduleAugmentationNoNewNames.js b/tests/baselines/reference/moduleAugmentationNoNewNames.js index ccd4a668497..4376c23a7f8 100644 --- a/tests/baselines/reference/moduleAugmentationNoNewNames.js +++ b/tests/baselines/reference/moduleAugmentationNoNewNames.js @@ -30,12 +30,15 @@ let y = x.map(x => x + 1); //// [observable.js] "use strict"; +exports.__esModule = true; //// [map.js] "use strict"; +exports.__esModule = true; var observable_1 = require("./observable"); observable_1.Observable.prototype.map = function () { }; //// [main.js] "use strict"; +exports.__esModule = true; require("./map"); var x; var y = x.map(function (x) { return x + 1; }); diff --git a/tests/baselines/reference/moduleAugmentationsBundledOutput1.js b/tests/baselines/reference/moduleAugmentationsBundledOutput1.js index 504c015bcb8..9ad2aa842d0 100644 --- a/tests/baselines/reference/moduleAugmentationsBundledOutput1.js +++ b/tests/baselines/reference/moduleAugmentationsBundledOutput1.js @@ -58,6 +58,7 @@ c.baz2().x.toLowerCase(); //// [out.js] define("m1", ["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var Cls = (function () { function Cls() { } @@ -67,11 +68,13 @@ define("m1", ["require", "exports"], function (require, exports) { }); define("m2", ["require", "exports", "m1"], function (require, exports, m1_1) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); m1_1.Cls.prototype.foo = function () { return 1; }; m1_1.Cls.prototype.bar = function () { return "1"; }; }); define("m3", ["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var C1 = (function () { function C1() { } @@ -87,11 +90,13 @@ define("m3", ["require", "exports"], function (require, exports) { }); define("m4", ["require", "exports", "m1"], function (require, exports, m1_2) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); m1_2.Cls.prototype.baz1 = function () { return undefined; }; m1_2.Cls.prototype.baz2 = function () { return undefined; }; }); define("test", ["require", "exports", "m2", "m4"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var c; c.foo().toExponential(); c.bar().toLowerCase(); diff --git a/tests/baselines/reference/moduleAugmentationsImports1.js b/tests/baselines/reference/moduleAugmentationsImports1.js index 922bb61d952..116c5c5e830 100644 --- a/tests/baselines/reference/moduleAugmentationsImports1.js +++ b/tests/baselines/reference/moduleAugmentationsImports1.js @@ -45,6 +45,7 @@ let c = a.getCls().y.toLowerCase(); //// [f.js] define("a", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var A = (function () { function A() { } @@ -54,6 +55,7 @@ define("a", ["require", "exports"], function (require, exports) { }); define("b", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var B = (function () { function B() { } @@ -64,11 +66,13 @@ define("b", ["require", "exports"], function (require, exports) { /// define("d", ["require", "exports", "a"], function (require, exports, a_1) { "use strict"; + exports.__esModule = true; a_1.A.prototype.getB = function () { return undefined; }; a_1.A.prototype.getCls = function () { return undefined; }; }); define("main", ["require", "exports", "d"], function (require, exports) { "use strict"; + exports.__esModule = true; var a; var b = a.getB().x.toFixed(); var c = a.getCls().y.toLowerCase(); diff --git a/tests/baselines/reference/moduleAugmentationsImports2.js b/tests/baselines/reference/moduleAugmentationsImports2.js index 605a07e29e1..e13cbd8f3dd 100644 --- a/tests/baselines/reference/moduleAugmentationsImports2.js +++ b/tests/baselines/reference/moduleAugmentationsImports2.js @@ -50,6 +50,7 @@ let c = a.getCls().y.toLowerCase(); //// [f.js] define("a", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var A = (function () { function A() { } @@ -59,6 +60,7 @@ define("a", ["require", "exports"], function (require, exports) { }); define("b", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var B = (function () { function B() { } @@ -69,14 +71,17 @@ define("b", ["require", "exports"], function (require, exports) { /// define("d", ["require", "exports", "a"], function (require, exports, a_1) { "use strict"; + exports.__esModule = true; a_1.A.prototype.getB = function () { return undefined; }; }); define("e", ["require", "exports", "a"], function (require, exports, a_2) { "use strict"; + exports.__esModule = true; a_2.A.prototype.getCls = function () { return undefined; }; }); define("main", ["require", "exports", "d", "e"], function (require, exports) { "use strict"; + exports.__esModule = true; var a; var b = a.getB().x.toFixed(); var c = a.getCls().y.toLowerCase(); diff --git a/tests/baselines/reference/moduleAugmentationsImports3.js b/tests/baselines/reference/moduleAugmentationsImports3.js index 0a946f42be3..a4a6ccea849 100644 --- a/tests/baselines/reference/moduleAugmentationsImports3.js +++ b/tests/baselines/reference/moduleAugmentationsImports3.js @@ -49,6 +49,7 @@ let c = a.getCls().y.toLowerCase(); //// [f.js] define("a", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var A = (function () { function A() { } @@ -58,6 +59,7 @@ define("a", ["require", "exports"], function (require, exports) { }); define("b", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var B = (function () { function B() { } @@ -67,10 +69,12 @@ define("b", ["require", "exports"], function (require, exports) { }); define("e", ["require", "exports", "a"], function (require, exports, a_1) { "use strict"; + exports.__esModule = true; a_1.A.prototype.getCls = function () { return undefined; }; }); define("main", ["require", "exports", "D", "e"], function (require, exports) { "use strict"; + exports.__esModule = true; var a; var b = a.getB().x.toFixed(); var c = a.getCls().y.toLowerCase(); diff --git a/tests/baselines/reference/moduleAugmentationsImports4.js b/tests/baselines/reference/moduleAugmentationsImports4.js index a48bbb04631..4be17a61edb 100644 --- a/tests/baselines/reference/moduleAugmentationsImports4.js +++ b/tests/baselines/reference/moduleAugmentationsImports4.js @@ -50,6 +50,7 @@ let c = a.getCls().y.toLowerCase(); //// [f.js] define("a", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var A = (function () { function A() { } @@ -59,6 +60,7 @@ define("a", ["require", "exports"], function (require, exports) { }); define("b", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var B = (function () { function B() { } @@ -68,6 +70,7 @@ define("b", ["require", "exports"], function (require, exports) { }); define("main", ["require", "exports", "D", "E"], function (require, exports) { "use strict"; + exports.__esModule = true; var a; var b = a.getB().x.toFixed(); var c = a.getCls().y.toLowerCase(); diff --git a/tests/baselines/reference/moduleCodeGenTest5.js b/tests/baselines/reference/moduleCodeGenTest5.js index 6a7113c0368..ee6fd2ab317 100644 --- a/tests/baselines/reference/moduleCodeGenTest5.js +++ b/tests/baselines/reference/moduleCodeGenTest5.js @@ -23,6 +23,7 @@ var v = E2.B; //// [moduleCodeGenTest5.js] "use strict"; +exports.__esModule = true; exports.x = 0; var y = 0; function f1() { } diff --git a/tests/baselines/reference/moduleCodegenTest4.js b/tests/baselines/reference/moduleCodegenTest4.js index 362785a5d68..f877ad74bc3 100644 --- a/tests/baselines/reference/moduleCodegenTest4.js +++ b/tests/baselines/reference/moduleCodegenTest4.js @@ -6,6 +6,7 @@ void 0; //// [moduleCodegenTest4.js] "use strict"; +exports.__esModule = true; var Baz; (function (Baz) { Baz.x = "hello"; diff --git a/tests/baselines/reference/moduleDuplicateIdentifiers.js b/tests/baselines/reference/moduleDuplicateIdentifiers.js index 64b82f82500..a2a099fca1d 100644 --- a/tests/baselines/reference/moduleDuplicateIdentifiers.js +++ b/tests/baselines/reference/moduleDuplicateIdentifiers.js @@ -42,6 +42,7 @@ export enum Utensils { // Shouldn't error //// [moduleDuplicateIdentifiers.js] "use strict"; +exports.__esModule = true; exports.Foo = 2; exports.Foo = 42; // Should error var FooBar; diff --git a/tests/baselines/reference/moduleExports1.js b/tests/baselines/reference/moduleExports1.js index 130091cd61c..66c746c5f51 100644 --- a/tests/baselines/reference/moduleExports1.js +++ b/tests/baselines/reference/moduleExports1.js @@ -16,6 +16,7 @@ if (!module.exports) module.exports = ""; //// [moduleExports1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var TypeScript; (function (TypeScript) { var Strasse; diff --git a/tests/baselines/reference/moduleImportedForTypeArgumentPosition.js b/tests/baselines/reference/moduleImportedForTypeArgumentPosition.js index 51d9eb89b1d..2ed22cfa4f0 100644 --- a/tests/baselines/reference/moduleImportedForTypeArgumentPosition.js +++ b/tests/baselines/reference/moduleImportedForTypeArgumentPosition.js @@ -14,15 +14,22 @@ class Test1 extends C1 { //// [moduleImportedForTypeArgumentPosition_0.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [moduleImportedForTypeArgumentPosition_1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var C1 = (function () { function C1() { } @@ -31,7 +38,7 @@ define(["require", "exports"], function (require, exports) { var Test1 = (function (_super) { __extends(Test1, _super); function Test1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Test1; }(C1)); diff --git a/tests/baselines/reference/moduleInTypePosition1.js b/tests/baselines/reference/moduleInTypePosition1.js index a590e23f71e..7408db5c291 100644 --- a/tests/baselines/reference/moduleInTypePosition1.js +++ b/tests/baselines/reference/moduleInTypePosition1.js @@ -13,6 +13,7 @@ var x = (w1: WinJS) => { }; //// [moduleInTypePosition1_0.js] "use strict"; +exports.__esModule = true; var Promise = (function () { function Promise() { } @@ -21,4 +22,5 @@ var Promise = (function () { exports.Promise = Promise; //// [moduleInTypePosition1_1.js] "use strict"; +exports.__esModule = true; var x = function (w1) { }; diff --git a/tests/baselines/reference/moduleMergeConstructor.js b/tests/baselines/reference/moduleMergeConstructor.js index 5ab4ab381e0..88531532acc 100644 --- a/tests/baselines/reference/moduleMergeConstructor.js +++ b/tests/baselines/reference/moduleMergeConstructor.js @@ -30,6 +30,7 @@ class Test { //// [index.js] define(["require", "exports", "foo"], function (require, exports, foo) { "use strict"; + exports.__esModule = true; var Test = (function () { function Test() { this.bar = new foo.Foo(); diff --git a/tests/baselines/reference/moduleNoneErrors.js b/tests/baselines/reference/moduleNoneErrors.js index c18f11d24b3..7be89f236be 100644 --- a/tests/baselines/reference/moduleNoneErrors.js +++ b/tests/baselines/reference/moduleNoneErrors.js @@ -6,6 +6,7 @@ export class Foo { //// [a.js] "use strict"; +exports.__esModule = true; var Foo = (function () { function Foo() { } diff --git a/tests/baselines/reference/modulePrologueAMD.js b/tests/baselines/reference/modulePrologueAMD.js index c3512734f94..b38e5d95f2c 100644 --- a/tests/baselines/reference/modulePrologueAMD.js +++ b/tests/baselines/reference/modulePrologueAMD.js @@ -6,6 +6,7 @@ export class Foo {} //// [modulePrologueAMD.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var Foo = (function () { function Foo() { } diff --git a/tests/baselines/reference/modulePrologueCommonjs.js b/tests/baselines/reference/modulePrologueCommonjs.js index 4a9594d254b..4f465a2ae2f 100644 --- a/tests/baselines/reference/modulePrologueCommonjs.js +++ b/tests/baselines/reference/modulePrologueCommonjs.js @@ -5,6 +5,7 @@ export class Foo {} //// [modulePrologueCommonjs.js] "use strict"; +exports.__esModule = true; var Foo = (function () { function Foo() { } diff --git a/tests/baselines/reference/modulePrologueUmd.js b/tests/baselines/reference/modulePrologueUmd.js index 18edf1ef4af..c9b8c331bcf 100644 --- a/tests/baselines/reference/modulePrologueUmd.js +++ b/tests/baselines/reference/modulePrologueUmd.js @@ -14,6 +14,7 @@ export class Foo {} } })(function (require, exports) { "use strict"; + exports.__esModule = true; var Foo = (function () { function Foo() { } diff --git a/tests/baselines/reference/moduleResolutionNoResolve.js b/tests/baselines/reference/moduleResolutionNoResolve.js index c73be6b6981..86f681fa27a 100644 --- a/tests/baselines/reference/moduleResolutionNoResolve.js +++ b/tests/baselines/reference/moduleResolutionNoResolve.js @@ -10,6 +10,8 @@ export var c = ''; //// [a.js] "use strict"; +exports.__esModule = true; //// [b.js] "use strict"; +exports.__esModule = true; exports.c = ''; diff --git a/tests/baselines/reference/moduleResolutionNoTs.js b/tests/baselines/reference/moduleResolutionNoTs.js index a17f108d872..33f692396fa 100644 --- a/tests/baselines/reference/moduleResolutionNoTs.js +++ b/tests/baselines/reference/moduleResolutionNoTs.js @@ -31,3 +31,4 @@ exports.__esModule = true; exports["default"] = 0; //// [user.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/moduleResolutionWithExtensions.js b/tests/baselines/reference/moduleResolutionWithExtensions.js index 16d176872ca..b9a644a7209 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions.js +++ b/tests/baselines/reference/moduleResolutionWithExtensions.js @@ -32,8 +32,11 @@ exports["default"] = 0; // No extension: '.ts' added //// [b.js] "use strict"; +exports.__esModule = true; // '.js' extension: stripped and replaced with '.ts' //// [d.js] "use strict"; +exports.__esModule = true; //// [jquery_user_1.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.js b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.js index 2e5297bdf65..6bce8b8d3c5 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.js +++ b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.js @@ -15,3 +15,4 @@ import js from "./js"; //// [a.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported2.js b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported2.js index c340f65f251..a11d43d56df 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported2.js +++ b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported2.js @@ -10,3 +10,4 @@ import jsx from "./jsx"; //// [a.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.js b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.js index f362701bbda..ca0fa6ca402 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.js +++ b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.js @@ -10,3 +10,4 @@ import jsx from "./jsx"; //// [a.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_preferTs.js b/tests/baselines/reference/moduleResolutionWithExtensions_preferTs.js index 177321c7d08..a9dc91d9a55 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_preferTs.js +++ b/tests/baselines/reference/moduleResolutionWithExtensions_preferTs.js @@ -16,3 +16,4 @@ exports.__esModule = true; exports["default"] = 0; //// [a.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.js b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.js index b5d4ae20a4d..7d67bde6509 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.js +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.js @@ -14,4 +14,5 @@ import "normalize.css"; //// [a.js] "use strict"; +exports.__esModule = true; require("normalize.css"); diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json index e1b1673b32a..8c820e07e48 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json @@ -6,7 +6,8 @@ "File '/node_modules/normalize.css.tsx' does not exist.", "File '/node_modules/normalize.css.d.ts' does not exist.", "Found 'package.json' at '/node_modules/normalize.css/package.json'.", - "'package.json' does not have a 'types' or 'main' field.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", "File '/node_modules/normalize.css/index.ts' does not exist.", "File '/node_modules/normalize.css/index.tsx' does not exist.", "File '/node_modules/normalize.css/index.d.ts' does not exist.", @@ -15,12 +16,13 @@ "File '/node_modules/normalize.css.js' does not exist.", "File '/node_modules/normalize.css.jsx' does not exist.", "Found 'package.json' at '/node_modules/normalize.css/package.json'.", - "No types specified in 'package.json', so returning 'main' value of 'normalize.css'", + "'package.json' has 'main' field 'normalize.css' that references '/node_modules/normalize.css/normalize.css'.", "File '/node_modules/normalize.css/normalize.css' exist - use it as a name resolution result.", "File '/node_modules/normalize.css/normalize.css' has an unsupported extension, so skipping it.", - "File '/node_modules/normalize.css/normalize.css.ts' does not exist.", - "File '/node_modules/normalize.css/normalize.css.tsx' does not exist.", - "File '/node_modules/normalize.css/normalize.css.d.ts' does not exist.", + "Loading module as file / folder, candidate module location '/node_modules/normalize.css/normalize.css', target file type 'JavaScript'.", + "File '/node_modules/normalize.css/normalize.css.js' does not exist.", + "File '/node_modules/normalize.css/normalize.css.jsx' does not exist.", + "Directory '/node_modules/normalize.css/normalize.css' does not exist, skipping all lookups in it.", "File '/node_modules/normalize.css/index.js' does not exist.", "File '/node_modules/normalize.css/index.jsx' does not exist.", "======== Module name 'normalize.css' was not resolved. ========" diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.js b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.js index dc9df79e4df..0a04d8a9077 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.js +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.js @@ -14,4 +14,5 @@ import "foo"; //// [a.js] "use strict"; +exports.__esModule = true; require("foo"); diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json index 11dd95ebe45..e550bb41eab 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json @@ -6,12 +6,19 @@ "File '/node_modules/foo.tsx' does not exist.", "File '/node_modules/foo.d.ts' does not exist.", "Found 'package.json' at '/node_modules/foo/package.json'.", + "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'foo.js' that references '/node_modules/foo/foo.js'.", "File '/node_modules/foo/foo.js' exist - use it as a name resolution result.", "File '/node_modules/foo/foo.js' has an unsupported extension, so skipping it.", + "Loading module as file / folder, candidate module location '/node_modules/foo/foo.js', target file type 'TypeScript'.", "File '/node_modules/foo/foo.js.ts' does not exist.", "File '/node_modules/foo/foo.js.tsx' does not exist.", "File '/node_modules/foo/foo.js.d.ts' does not exist.", + "File name '/node_modules/foo/foo.js' has a '.js' extension - stripping it", + "File '/node_modules/foo/foo.ts' does not exist.", + "File '/node_modules/foo/foo.tsx' does not exist.", + "File '/node_modules/foo/foo.d.ts' does not exist.", + "Directory '/node_modules/foo/foo.js' does not exist, skipping all lookups in it.", "File '/node_modules/foo/index.ts' does not exist.", "File '/node_modules/foo/index.tsx' does not exist.", "File '/node_modules/foo/index.d.ts' does not exist.", @@ -20,7 +27,7 @@ "File '/node_modules/foo.js' does not exist.", "File '/node_modules/foo.jsx' does not exist.", "Found 'package.json' at '/node_modules/foo/package.json'.", - "'package.json' does not have a 'types' or 'main' field.", + "'package.json' does not have a 'main' field.", "File '/node_modules/foo/index.js' does not exist.", "File '/node_modules/foo/index.jsx' does not exist.", "======== Module name 'foo' was not resolved. ========" diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.js b/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.js index 51d476338c0..3563f7db251 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.js +++ b/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.js @@ -16,3 +16,4 @@ import { x } from "js"; //// [a.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks.js b/tests/baselines/reference/moduleResolutionWithSymlinks.js index fbf97fa3ba0..520324cb222 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks.js +++ b/tests/baselines/reference/moduleResolutionWithSymlinks.js @@ -43,6 +43,7 @@ tsc app.ts # Should write to library-a/index.js, library-b/index.js, and app.js // When symlinked files are in node_modules, they are resolved with realpath; // so a linked file does not create a duplicate SourceFile of the real one. "use strict"; +exports.__esModule = true; var MyClass = (function () { function MyClass() { } @@ -51,10 +52,12 @@ var MyClass = (function () { exports.MyClass = MyClass; //// [/src/library-b/index.js] "use strict"; +exports.__esModule = true; var library_a_1 = require("library-a"); exports.MyClass2 = library_a_1.MyClass; //// [/src/app.js] "use strict"; +exports.__esModule = true; var x; var y; x = y; diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks_notInNodeModules.js b/tests/baselines/reference/moduleResolutionWithSymlinks_notInNodeModules.js index a927a496a96..cde63e0604d 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks_notInNodeModules.js +++ b/tests/baselines/reference/moduleResolutionWithSymlinks_notInNodeModules.js @@ -18,15 +18,18 @@ x + x2; // A symlink file acts like the real thing. So, 2 symlinks act like 2 different files. // See GH#10364. "use strict"; +exports.__esModule = true; exports.x = 0; //// [/src/bin/shared2/abc.js] // When symlinked files are not in node_modules, realpath is not used. // A symlink file acts like the real thing. So, 2 symlinks act like 2 different files. // See GH#10364. "use strict"; +exports.__esModule = true; exports.x = 0; //// [/src/bin/app.js] "use strict"; +exports.__esModule = true; var abc_1 = require("./shared/abc"); var abc_2 = require("./shared2/abc"); abc_1.x + abc_2.x; diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.js b/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.js index 312bcf4c174..0bd77a1dcc7 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.js +++ b/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.js @@ -22,6 +22,7 @@ y = x; //// [/src/bin/library-a/index.js] // Same as moduleResolutionWithSymlinks.ts, but with outDir "use strict"; +exports.__esModule = true; var MyClass = (function () { function MyClass() { } @@ -30,10 +31,12 @@ var MyClass = (function () { exports.MyClass = MyClass; //// [/src/bin/library-b/index.js] "use strict"; +exports.__esModule = true; var library_a_1 = require("library-a"); exports.MyClass2 = library_a_1.MyClass; //// [/src/bin/app.js] "use strict"; +exports.__esModule = true; var x; var y; x = y; diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js index 4061a32b49f..c4d451ba9f9 100644 --- a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js @@ -12,17 +12,20 @@ export var foo = 42; //// [c.js] "use strict"; +exports.__esModule = true; exports.foo = 42; //// [b.js] "use strict"; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } +exports.__esModule = true; __export(require("./c")); //// [a.js] "use strict"; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } +exports.__esModule = true; __export(require("./b")); __export(require("./c")); diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js index 208e90c69d8..d1f6dc7abc7 100644 --- a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js @@ -15,6 +15,7 @@ export enum Animals { //// [c.js] "use strict"; +exports.__esModule = true; var Animals; (function (Animals) { Animals[Animals["Cat"] = 0] = "Cat"; @@ -23,6 +24,7 @@ var Animals; ; //// [b.js] "use strict"; +exports.__esModule = true; var c_1 = require("./c"); exports.Animals = c_1.Animals; //// [a.js] @@ -30,5 +32,6 @@ exports.Animals = c_1.Animals; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } +exports.__esModule = true; __export(require("./b")); __export(require("./c")); diff --git a/tests/baselines/reference/moduleScoping.js b/tests/baselines/reference/moduleScoping.js index f987c0c652d..601d7e41fcd 100644 --- a/tests/baselines/reference/moduleScoping.js +++ b/tests/baselines/reference/moduleScoping.js @@ -29,10 +29,12 @@ var v2 = 42; // Global scope var v4 = function () { return 5; }; //// [file3.js] "use strict"; +exports.__esModule = true; exports.v3 = true; var v2 = [1, 2, 3]; // Module scope. Should not appear in global scope //// [file4.js] "use strict"; +exports.__esModule = true; var file3 = require("./file3"); var t1 = v1; var t2 = v2; diff --git a/tests/baselines/reference/moduleVariableArrayIndexer.errors.txt b/tests/baselines/reference/moduleVariableArrayIndexer.errors.txt new file mode 100644 index 00000000000..f0c070375f6 --- /dev/null +++ b/tests/baselines/reference/moduleVariableArrayIndexer.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/moduleVariableArrayIndexer.ts(3,13): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/compiler/moduleVariableArrayIndexer.ts (1 errors) ==== + module Bar { + export var a = 1; + var t = undefined[a][a]; // CG: var t = undefined[Bar.a][a]; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/moduleWithStatementsOfEveryKind.js b/tests/baselines/reference/moduleWithStatementsOfEveryKind.js index 4243c9849cf..00838f25beb 100644 --- a/tests/baselines/reference/moduleWithStatementsOfEveryKind.js +++ b/tests/baselines/reference/moduleWithStatementsOfEveryKind.js @@ -59,11 +59,16 @@ module Y { //// [moduleWithStatementsOfEveryKind.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A; (function (A_1) { var A = (function () { @@ -79,14 +84,14 @@ var A; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(AA)); var BB = (function (_super) { __extends(BB, _super); function BB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return BB; }(A)); @@ -130,7 +135,7 @@ var Y; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(AA)); @@ -138,7 +143,7 @@ var Y; var BB = (function (_super) { __extends(BB, _super); function BB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return BB; }(A)); diff --git a/tests/baselines/reference/multiImportExport.js b/tests/baselines/reference/multiImportExport.js index 2cd5440ce6e..07e353cb301 100644 --- a/tests/baselines/reference/multiImportExport.js +++ b/tests/baselines/reference/multiImportExport.js @@ -44,9 +44,11 @@ var Math = { module.exports = Math; //// [Drawing.js] "use strict"; +exports.__esModule = true; exports.Math = require("./Math/Math"); //// [consumer.js] "use strict"; +exports.__esModule = true; var Drawing = require("./Drawing"); var addr = new Drawing.Math.Adder(); diff --git a/tests/baselines/reference/multipleDeclarations.symbols b/tests/baselines/reference/multipleDeclarations.symbols index 9e49c2fc00c..4fc8f8a5f28 100644 --- a/tests/baselines/reference/multipleDeclarations.symbols +++ b/tests/baselines/reference/multipleDeclarations.symbols @@ -30,7 +30,7 @@ class X { >this : Symbol(X, Decl(input.js, 5, 1)) this.mistake = 'frankly, complete nonsense'; ->this.mistake : Symbol(X.mistake, Decl(input.js, 12, 5)) +>this.mistake : Symbol(X.mistake, Decl(input.js, 12, 5), Decl(input.js, 16, 16)) >this : Symbol(X, Decl(input.js, 5, 1)) >mistake : Symbol(X.mistake, Decl(input.js, 8, 35)) } @@ -38,7 +38,7 @@ class X { >m : Symbol(X.m, Decl(input.js, 10, 5)) } mistake() { ->mistake : Symbol(X.mistake, Decl(input.js, 12, 5)) +>mistake : Symbol(X.mistake, Decl(input.js, 12, 5), Decl(input.js, 16, 16)) } } let x = new X(); @@ -46,9 +46,11 @@ let x = new X(); >X : Symbol(X, Decl(input.js, 5, 1)) X.prototype.mistake = false; ->X.prototype.mistake : Symbol(X.mistake, Decl(input.js, 12, 5)) +>X.prototype.mistake : Symbol(X.mistake, Decl(input.js, 12, 5), Decl(input.js, 16, 16)) +>X.prototype : Symbol(X.mistake, Decl(input.js, 12, 5), Decl(input.js, 16, 16)) >X : Symbol(X, Decl(input.js, 5, 1)) >prototype : Symbol(X.prototype) +>mistake : Symbol(X.mistake, Decl(input.js, 12, 5), Decl(input.js, 16, 16)) x.m(); >x.m : Symbol(X.m, Decl(input.js, 10, 5)) @@ -56,15 +58,15 @@ x.m(); >m : Symbol(X.m, Decl(input.js, 10, 5)) x.mistake; ->x.mistake : Symbol(X.mistake, Decl(input.js, 12, 5)) +>x.mistake : Symbol(X.mistake, Decl(input.js, 12, 5), Decl(input.js, 16, 16)) >x : Symbol(x, Decl(input.js, 16, 3)) ->mistake : Symbol(X.mistake, Decl(input.js, 12, 5)) +>mistake : Symbol(X.mistake, Decl(input.js, 12, 5), Decl(input.js, 16, 16)) class Y { >Y : Symbol(Y, Decl(input.js, 19, 10)) mistake() { ->mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35)) +>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35), Decl(input.js, 29, 1)) } m() { >m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19)) @@ -80,15 +82,17 @@ class Y { >this : Symbol(Y, Decl(input.js, 19, 10)) this.mistake = 'even more nonsense'; ->this.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35)) +>this.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35), Decl(input.js, 29, 1)) >this : Symbol(Y, Decl(input.js, 19, 10)) ->mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35)) +>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35), Decl(input.js, 29, 1)) } } Y.prototype.mistake = true; ->Y.prototype.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35)) +>Y.prototype.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35), Decl(input.js, 29, 1)) +>Y.prototype : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35), Decl(input.js, 29, 1)) >Y : Symbol(Y, Decl(input.js, 19, 10)) >prototype : Symbol(Y.prototype) +>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35), Decl(input.js, 29, 1)) let y = new Y(); >y : Symbol(y, Decl(input.js, 31, 3)) @@ -100,7 +104,7 @@ y.m(); >m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19)) y.mistake(); ->y.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35)) +>y.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35), Decl(input.js, 29, 1)) >y : Symbol(y, Decl(input.js, 31, 3)) ->mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35)) +>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35), Decl(input.js, 29, 1)) diff --git a/tests/baselines/reference/multipleDeclarations.types b/tests/baselines/reference/multipleDeclarations.types index 195bdc2ad0d..b82cdbe05ed 100644 --- a/tests/baselines/reference/multipleDeclarations.types +++ b/tests/baselines/reference/multipleDeclarations.types @@ -43,16 +43,16 @@ class X { this.mistake = 'frankly, complete nonsense'; >this.mistake = 'frankly, complete nonsense' : "frankly, complete nonsense" ->this.mistake : () => void +>this.mistake : any >this : this ->mistake : () => void +>mistake : any >'frankly, complete nonsense' : "frankly, complete nonsense" } m() { >m : () => void } mistake() { ->mistake : () => void +>mistake : any } } let x = new X(); @@ -62,11 +62,11 @@ let x = new X(); X.prototype.mistake = false; >X.prototype.mistake = false : false ->X.prototype.mistake : () => void +>X.prototype.mistake : any >X.prototype : X >X : typeof X >prototype : X ->mistake : () => void +>mistake : any >false : false x.m(); @@ -76,9 +76,9 @@ x.m(); >m : () => void x.mistake; ->x.mistake : () => void +>x.mistake : any >x : X ->mistake : () => void +>mistake : any class Y { >Y : Y diff --git a/tests/baselines/reference/multipleDefaultExports01.js b/tests/baselines/reference/multipleDefaultExports01.js index e15f8fc879c..98c17051809 100644 --- a/tests/baselines/reference/multipleDefaultExports01.js +++ b/tests/baselines/reference/multipleDefaultExports01.js @@ -20,21 +20,20 @@ Entity(); //// [m1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var foo = (function () { function foo() { } return foo; }()); -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = foo; function bar() { } -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = bar; var x = 10; -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = x; //// [m2.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var m1_1 = require("./m1"); m1_1.default(); diff --git a/tests/baselines/reference/multipleDefaultExports02.js b/tests/baselines/reference/multipleDefaultExports02.js index 0e9fed272cd..b129dba0392 100644 --- a/tests/baselines/reference/multipleDefaultExports02.js +++ b/tests/baselines/reference/multipleDefaultExports02.js @@ -17,15 +17,15 @@ Entity(); //// [m1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); function foo() { } -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = foo; function bar() { } -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = bar; //// [m2.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var m1_1 = require("./m1"); m1_1.default(); diff --git a/tests/baselines/reference/multipleDefaultExports03.js b/tests/baselines/reference/multipleDefaultExports03.js index 748837baceb..897a3f00eb4 100644 --- a/tests/baselines/reference/multipleDefaultExports03.js +++ b/tests/baselines/reference/multipleDefaultExports03.js @@ -8,17 +8,16 @@ export default class C { //// [multipleDefaultExports03.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var C = (function () { function C() { } return C; }()); -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = C; var C = (function () { function C() { } return C; }()); -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = C; diff --git a/tests/baselines/reference/multipleDefaultExports04.js b/tests/baselines/reference/multipleDefaultExports04.js index 020f9b758bb..341f6f41c62 100644 --- a/tests/baselines/reference/multipleDefaultExports04.js +++ b/tests/baselines/reference/multipleDefaultExports04.js @@ -8,11 +8,10 @@ export default function f() { //// [multipleDefaultExports04.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); function f() { } -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = f; function f() { } -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = f; diff --git a/tests/baselines/reference/multipleExportDefault1.js b/tests/baselines/reference/multipleExportDefault1.js index bec4fb48969..8375c2f9e6f 100644 --- a/tests/baselines/reference/multipleExportDefault1.js +++ b/tests/baselines/reference/multipleExportDefault1.js @@ -10,11 +10,10 @@ export default { //// [multipleExportDefault1.js] "use strict"; +exports.__esModule = true; function Foo() { } -exports.__esModule = true; exports["default"] = Foo; -exports.__esModule = true; exports["default"] = { uhoh: "another default" }; diff --git a/tests/baselines/reference/multipleExportDefault2.js b/tests/baselines/reference/multipleExportDefault2.js index dc82500a1d9..0c06385f9af 100644 --- a/tests/baselines/reference/multipleExportDefault2.js +++ b/tests/baselines/reference/multipleExportDefault2.js @@ -14,5 +14,4 @@ exports["default"] = { uhoh: "another default" }; function Foo() { } -exports.__esModule = true; exports["default"] = Foo; diff --git a/tests/baselines/reference/multipleExportDefault3.js b/tests/baselines/reference/multipleExportDefault3.js index 5d7ad48e0ca..1091af16301 100644 --- a/tests/baselines/reference/multipleExportDefault3.js +++ b/tests/baselines/reference/multipleExportDefault3.js @@ -18,5 +18,4 @@ var C = (function () { } return C; }()); -exports.__esModule = true; exports["default"] = C; diff --git a/tests/baselines/reference/multipleExportDefault4.js b/tests/baselines/reference/multipleExportDefault4.js index 1199fa91c9c..b3e0ef3e870 100644 --- a/tests/baselines/reference/multipleExportDefault4.js +++ b/tests/baselines/reference/multipleExportDefault4.js @@ -7,14 +7,13 @@ export default { //// [multipleExportDefault4.js] "use strict"; +exports.__esModule = true; var C = (function () { function C() { } return C; }()); -exports.__esModule = true; exports["default"] = C; -exports.__esModule = true; exports["default"] = { uhoh: "another default" }; diff --git a/tests/baselines/reference/multipleExportDefault5.js b/tests/baselines/reference/multipleExportDefault5.js index 7ae33aee9f4..a5032e45244 100644 --- a/tests/baselines/reference/multipleExportDefault5.js +++ b/tests/baselines/reference/multipleExportDefault5.js @@ -4,13 +4,12 @@ export default class C {} //// [multipleExportDefault5.js] "use strict"; -function bar() { } exports.__esModule = true; +function bar() { } exports["default"] = bar; var C = (function () { function C() { } return C; }()); -exports.__esModule = true; exports["default"] = C; diff --git a/tests/baselines/reference/multipleExportDefault6.js b/tests/baselines/reference/multipleExportDefault6.js index a8b93459e4e..aa372e4d410 100644 --- a/tests/baselines/reference/multipleExportDefault6.js +++ b/tests/baselines/reference/multipleExportDefault6.js @@ -13,7 +13,6 @@ exports.__esModule = true; exports["default"] = { lol: 1 }; -exports.__esModule = true; exports["default"] = { lol: 2 }; diff --git a/tests/baselines/reference/multipleExports.js b/tests/baselines/reference/multipleExports.js index fd6ac67e82a..05276591447 100644 --- a/tests/baselines/reference/multipleExports.js +++ b/tests/baselines/reference/multipleExports.js @@ -14,6 +14,7 @@ export module M { //// [multipleExports.js] "use strict"; +exports.__esModule = true; var M; (function (M) { M.v = 0; diff --git a/tests/baselines/reference/multipleInheritance.js b/tests/baselines/reference/multipleInheritance.js index 9c0e865cdb7..59abc8cd469 100644 --- a/tests/baselines/reference/multipleInheritance.js +++ b/tests/baselines/reference/multipleInheritance.js @@ -39,11 +39,16 @@ class Baad extends Good { //// [multipleInheritance.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B1 = (function () { function B1() { } @@ -57,28 +62,28 @@ var B2 = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B1)); var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(B1)); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(B2)); var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(D1)); @@ -90,7 +95,7 @@ var N = (function () { var ND = (function (_super) { __extends(ND, _super); function ND() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ND; }(N)); @@ -104,7 +109,7 @@ var Good = (function () { var Baad = (function (_super) { __extends(Baad, _super); function Baad() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Baad.prototype.f = function () { return 0; }; Baad.prototype.g = function (n) { return 0; }; diff --git a/tests/baselines/reference/multipleNumericIndexers.errors.txt b/tests/baselines/reference/multipleNumericIndexers.errors.txt index 82fc444ac65..e3eaa94fa52 100644 --- a/tests/baselines/reference/multipleNumericIndexers.errors.txt +++ b/tests/baselines/reference/multipleNumericIndexers.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts(5,5): error TS2375: Duplicate number index signature. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts(8,11): error TS2428: All declarations of 'I' must have identical type parameters. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts(10,5): error TS2375: Duplicate number index signature. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts(15,5): error TS2375: Duplicate number index signature. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts(20,5): error TS2375: Duplicate number index signature. @@ -8,7 +9,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericI tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts(30,5): error TS2375: Duplicate number index signature. -==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts (8 errors) ==== +==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts (9 errors) ==== // Multiple indexers of the same type are an error class C { @@ -19,6 +20,8 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericI } interface I { + ~ +!!! error TS2428: All declarations of 'I' must have identical type parameters. [x: number]: string; [x: number]: string; ~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/mutuallyRecursiveGenericBaseTypes2.js b/tests/baselines/reference/mutuallyRecursiveGenericBaseTypes2.js index 8b59564d465..7977134b2ed 100644 --- a/tests/baselines/reference/mutuallyRecursiveGenericBaseTypes2.js +++ b/tests/baselines/reference/mutuallyRecursiveGenericBaseTypes2.js @@ -11,11 +11,16 @@ var test = new foo(); //// [mutuallyRecursiveGenericBaseTypes2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var foo = (function () { function foo() { } @@ -25,7 +30,7 @@ var foo = (function () { var foo2 = (function (_super) { __extends(foo2, _super); function foo2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return foo2; }(foo)); diff --git a/tests/baselines/reference/nameDelimitedBySlashes.js b/tests/baselines/reference/nameDelimitedBySlashes.js index 93cf4e29d49..149b6a0d59f 100644 --- a/tests/baselines/reference/nameDelimitedBySlashes.js +++ b/tests/baselines/reference/nameDelimitedBySlashes.js @@ -10,8 +10,10 @@ var x = foo.foo + 42; //// [foo_0.js] "use strict"; +exports.__esModule = true; exports.foo = 42; //// [foo_1.js] "use strict"; +exports.__esModule = true; var foo = require("./test/foo_0"); var x = foo.foo + 42; diff --git a/tests/baselines/reference/nameWithFileExtension.js b/tests/baselines/reference/nameWithFileExtension.js index 156d1b03a1a..3c1cf8dce66 100644 --- a/tests/baselines/reference/nameWithFileExtension.js +++ b/tests/baselines/reference/nameWithFileExtension.js @@ -10,8 +10,10 @@ var x = foo.foo + 42; //// [foo_0.js] "use strict"; +exports.__esModule = true; exports.foo = 42; //// [foo_1.js] "use strict"; +exports.__esModule = true; var foo = require("./foo_0.js"); var x = foo.foo + 42; diff --git a/tests/baselines/reference/nameWithRelativePaths.js b/tests/baselines/reference/nameWithRelativePaths.js index d8b0eed43cf..d070638417b 100644 --- a/tests/baselines/reference/nameWithRelativePaths.js +++ b/tests/baselines/reference/nameWithRelativePaths.js @@ -25,21 +25,25 @@ if(foo2.M2.x){ //// [foo_0.js] "use strict"; +exports.__esModule = true; exports.foo = 42; //// [foo_1.js] "use strict"; +exports.__esModule = true; function f() { return 42; } exports.f = f; //// [foo_2.js] "use strict"; +exports.__esModule = true; var M2; (function (M2) { M2.x = true; })(M2 = exports.M2 || (exports.M2 = {})); //// [foo_3.js] "use strict"; +exports.__esModule = true; var foo0 = require("../foo_0"); var foo1 = require("./test/foo_1"); var foo2 = require("./.././test/foo_2"); diff --git a/tests/baselines/reference/narrowExceptionVariableInCatchClause.js b/tests/baselines/reference/narrowExceptionVariableInCatchClause.js index 5808ed76826..b7dbf717e34 100644 --- a/tests/baselines/reference/narrowExceptionVariableInCatchClause.js +++ b/tests/baselines/reference/narrowExceptionVariableInCatchClause.js @@ -27,6 +27,7 @@ function tryCatch() { //// [narrowExceptionVariableInCatchClause.js] function tryCatch() { try { + // do stuff... } catch (err) { if (isFooError(err)) { diff --git a/tests/baselines/reference/narrowingConstrainedTypeParameter.js b/tests/baselines/reference/narrowingConstrainedTypeParameter.js index 3107585d941..4663e706d1b 100644 --- a/tests/baselines/reference/narrowingConstrainedTypeParameter.js +++ b/tests/baselines/reference/narrowingConstrainedTypeParameter.js @@ -20,6 +20,7 @@ export function speak(pet: TPet, voice: (pet: TPet) => string) //// [narrowingConstrainedTypeParameter.js] // Repro from #10811 "use strict"; +exports.__esModule = true; function isPet(pet) { return typeof pet.name === "string"; } diff --git a/tests/baselines/reference/narrowingConstrainedTypeParameter.types b/tests/baselines/reference/narrowingConstrainedTypeParameter.types index 942b9f7055d..348716ab3c4 100644 --- a/tests/baselines/reference/narrowingConstrainedTypeParameter.types +++ b/tests/baselines/reference/narrowingConstrainedTypeParameter.types @@ -17,7 +17,7 @@ function isPet(pet: any): pet is Pet { return typeof pet.name === "string"; >typeof pet.name === "string" : boolean ->typeof pet.name : string +>typeof pet.name : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >pet.name : any >pet : any >name : any diff --git a/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.errors.txt b/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.errors.txt new file mode 100644 index 00000000000..c686cd7a7cf --- /dev/null +++ b/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.errors.txt @@ -0,0 +1,37 @@ +tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts(13,17): error TS2345: Argument of type 'A | B' is not assignable to parameter of type 'A'. + Type 'B' is not assignable to type 'A'. + Property 'a' is missing in type 'B'. + + +==== tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts (1 errors) ==== + class A { + constructor(private a: string) { } + } + + class B { + } + + function acceptA(a: A) { } + function acceptB(b: B) { } + + function test(x: A | B) { + if (x instanceof B) { + acceptA(x); + ~ +!!! error TS2345: Argument of type 'A | B' is not assignable to parameter of type 'A'. +!!! error TS2345: Type 'B' is not assignable to type 'A'. +!!! error TS2345: Property 'a' is missing in type 'B'. + } + + if (x instanceof A) { + acceptA(x); + } + + if (x instanceof B) { + acceptB(x); + } + + if (x instanceof B) { + acceptB(x); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.js b/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.js new file mode 100644 index 00000000000..96fa20359ca --- /dev/null +++ b/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.js @@ -0,0 +1,57 @@ +//// [narrowingGenericTypeFromInstanceof01.ts] +class A { + constructor(private a: string) { } +} + +class B { +} + +function acceptA(a: A) { } +function acceptB(b: B) { } + +function test(x: A | B) { + if (x instanceof B) { + acceptA(x); + } + + if (x instanceof A) { + acceptA(x); + } + + if (x instanceof B) { + acceptB(x); + } + + if (x instanceof B) { + acceptB(x); + } +} + +//// [narrowingGenericTypeFromInstanceof01.js] +var A = (function () { + function A(a) { + this.a = a; + } + return A; +}()); +var B = (function () { + function B() { + } + return B; +}()); +function acceptA(a) { } +function acceptB(b) { } +function test(x) { + if (x instanceof B) { + acceptA(x); + } + if (x instanceof A) { + acceptA(x); + } + if (x instanceof B) { + acceptB(x); + } + if (x instanceof B) { + acceptB(x); + } +} diff --git a/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.symbols b/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.symbols new file mode 100644 index 00000000000..2130d68cb24 --- /dev/null +++ b/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.symbols @@ -0,0 +1,73 @@ +=== tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts === +class A { +>A : Symbol(A, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 0)) +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 8)) + + constructor(private a: string) { } +>a : Symbol(A.a, Decl(narrowingGenericTypeFromInstanceof01.ts, 1, 16)) +} + +class B { +>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1)) +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 4, 8)) +} + +function acceptA(a: A) { } +>acceptA : Symbol(acceptA, Decl(narrowingGenericTypeFromInstanceof01.ts, 5, 1)) +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 17)) +>a : Symbol(a, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 20)) +>A : Symbol(A, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 0)) +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 17)) + +function acceptB(b: B) { } +>acceptB : Symbol(acceptB, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 32)) +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 8, 17)) +>b : Symbol(b, Decl(narrowingGenericTypeFromInstanceof01.ts, 8, 20)) +>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1)) +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 8, 17)) + +function test(x: A | B) { +>test : Symbol(test, Decl(narrowingGenericTypeFromInstanceof01.ts, 8, 32)) +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 14)) +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) +>A : Symbol(A, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 0)) +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 14)) +>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1)) +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 14)) + + if (x instanceof B) { +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) +>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1)) + + acceptA(x); +>acceptA : Symbol(acceptA, Decl(narrowingGenericTypeFromInstanceof01.ts, 5, 1)) +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) + } + + if (x instanceof A) { +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) +>A : Symbol(A, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 0)) + + acceptA(x); +>acceptA : Symbol(acceptA, Decl(narrowingGenericTypeFromInstanceof01.ts, 5, 1)) +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) + } + + if (x instanceof B) { +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) +>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1)) + + acceptB(x); +>acceptB : Symbol(acceptB, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 32)) +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) + } + + if (x instanceof B) { +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) +>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1)) + + acceptB(x); +>acceptB : Symbol(acceptB, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 32)) +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) + } +} diff --git a/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.types b/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.types new file mode 100644 index 00000000000..a5b7c637c6c --- /dev/null +++ b/tests/baselines/reference/narrowingGenericTypeFromInstanceof01.types @@ -0,0 +1,81 @@ +=== tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts === +class A { +>A : A +>T : T + + constructor(private a: string) { } +>a : string +} + +class B { +>B : B +>T : T +} + +function acceptA(a: A) { } +>acceptA : (a: A) => void +>T : T +>a : A +>A : A +>T : T + +function acceptB(b: B) { } +>acceptB : (b: B) => void +>T : T +>b : B +>B : B +>T : T + +function test(x: A | B) { +>test : (x: A | B) => void +>T : T +>x : A | B +>A : A +>T : T +>B : B +>T : T + + if (x instanceof B) { +>x instanceof B : boolean +>x : A | B +>B : typeof B + + acceptA(x); +>acceptA(x) : void +>acceptA : (a: A) => void +>x : A + } + + if (x instanceof A) { +>x instanceof A : boolean +>x : A | B +>A : typeof A + + acceptA(x); +>acceptA(x) : void +>acceptA : (a: A) => void +>x : A + } + + if (x instanceof B) { +>x instanceof B : boolean +>x : A | B +>B : typeof B + + acceptB(x); +>acceptB(x) : void +>acceptB : (b: B) => void +>x : A + } + + if (x instanceof B) { +>x instanceof B : boolean +>x : A | B +>B : typeof B + + acceptB(x); +>acceptB(x) : void +>acceptB : (b: B) => void +>x : A + } +} diff --git a/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt b/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt index 3bc5689d170..e0f818ba9c1 100644 --- a/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt +++ b/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt @@ -1,12 +1,12 @@ tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(4,15): error TS1109: Expression expected. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(4,25): error TS1005: '=' expected. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(4,26): error TS1109: Expression expected. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(7,17): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(7,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(8,17): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(8,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(9,17): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(9,29): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(7,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(7,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(8,17): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(8,24): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(9,17): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(9,29): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(12,14): error TS1109: Expression expected. @@ -25,19 +25,19 @@ tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperator // invalid expressions var NUMBER2 = -(null - undefined); ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. var NUMBER3 = -(null - null); ~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. ~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2531: Object is possibly 'null'. var NUMBER4 = -(undefined - undefined); ~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. ~~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2532: Object is possibly 'undefined'. // miss operand var NUMBER =-; diff --git a/tests/baselines/reference/negateOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/negateOperatorWithAnyOtherType.errors.txt index 03e596aca41..0fbf89fb7ec 100644 --- a/tests/baselines/reference/negateOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/negateOperatorWithAnyOtherType.errors.txt @@ -1,7 +1,9 @@ +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorWithAnyOtherType.ts(34,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorWithAnyOtherType.ts(35,23): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorWithAnyOtherType.ts(51,1): error TS2695: Left side of comma operator is unused and has no side effects. -==== tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorWithAnyOtherType.ts (1 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorWithAnyOtherType.ts (3 errors) ==== // - operator on any type var ANY: any; @@ -36,7 +38,11 @@ tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperator // any type literal var ResultIsNumber7 = -undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber = -null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. // any type expressions var ResultIsNumber8 = -ANY2[0]; diff --git a/tests/baselines/reference/nestedLoopTypeGuards.types b/tests/baselines/reference/nestedLoopTypeGuards.types index 9d7b793badf..e0279325012 100644 --- a/tests/baselines/reference/nestedLoopTypeGuards.types +++ b/tests/baselines/reference/nestedLoopTypeGuards.types @@ -9,7 +9,7 @@ function f1() { if (typeof a !== 'boolean') { >typeof a !== 'boolean' : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : string | number | boolean >'boolean' : "boolean" @@ -34,7 +34,7 @@ function f1() { if (typeof a === 'string') { >typeof a === 'string' : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : string | number >'string' : "string" @@ -66,7 +66,7 @@ function f2() { if (typeof a === 'string') { >typeof a === 'string' : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : string | number >'string' : "string" @@ -78,7 +78,7 @@ function f2() { if (typeof a === 'string') { >typeof a === 'string' : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : string >'string' : "string" diff --git a/tests/baselines/reference/nestedLoopWithOnlyInnerLetCaptured.js b/tests/baselines/reference/nestedLoopWithOnlyInnerLetCaptured.js new file mode 100644 index 00000000000..ee17bb53eec --- /dev/null +++ b/tests/baselines/reference/nestedLoopWithOnlyInnerLetCaptured.js @@ -0,0 +1,18 @@ +//// [nestedLoopWithOnlyInnerLetCaptured.ts] +declare let doSomething; + +for (let a1 of []) + for (let a2 of a1.someArray) + doSomething(() => a2); + +//// [nestedLoopWithOnlyInnerLetCaptured.js] +for (var _i = 0, _a = []; _i < _a.length; _i++) { + var a1 = _a[_i]; + var _loop_1 = function (a2) { + doSomething(function () { return a2; }); + }; + for (var _b = 0, _c = a1.someArray; _b < _c.length; _b++) { + var a2 = _c[_b]; + _loop_1(a2); + } +} diff --git a/tests/baselines/reference/nestedLoopWithOnlyInnerLetCaptured.symbols b/tests/baselines/reference/nestedLoopWithOnlyInnerLetCaptured.symbols new file mode 100644 index 00000000000..f134dcbffa9 --- /dev/null +++ b/tests/baselines/reference/nestedLoopWithOnlyInnerLetCaptured.symbols @@ -0,0 +1,15 @@ +=== tests/cases/compiler/nestedLoopWithOnlyInnerLetCaptured.ts === +declare let doSomething; +>doSomething : Symbol(doSomething, Decl(nestedLoopWithOnlyInnerLetCaptured.ts, 0, 11)) + +for (let a1 of []) +>a1 : Symbol(a1, Decl(nestedLoopWithOnlyInnerLetCaptured.ts, 2, 8)) + + for (let a2 of a1.someArray) +>a2 : Symbol(a2, Decl(nestedLoopWithOnlyInnerLetCaptured.ts, 3, 12)) +>a1 : Symbol(a1, Decl(nestedLoopWithOnlyInnerLetCaptured.ts, 2, 8)) + + doSomething(() => a2); +>doSomething : Symbol(doSomething, Decl(nestedLoopWithOnlyInnerLetCaptured.ts, 0, 11)) +>a2 : Symbol(a2, Decl(nestedLoopWithOnlyInnerLetCaptured.ts, 3, 12)) + diff --git a/tests/baselines/reference/nestedLoopWithOnlyInnerLetCaptured.types b/tests/baselines/reference/nestedLoopWithOnlyInnerLetCaptured.types new file mode 100644 index 00000000000..6be9dbf6abf --- /dev/null +++ b/tests/baselines/reference/nestedLoopWithOnlyInnerLetCaptured.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/nestedLoopWithOnlyInnerLetCaptured.ts === +declare let doSomething; +>doSomething : any + +for (let a1 of []) +>a1 : any +>[] : undefined[] + + for (let a2 of a1.someArray) +>a2 : any +>a1.someArray : any +>a1 : any +>someArray : any + + doSomething(() => a2); +>doSomething(() => a2) : any +>doSomething : any +>() => a2 : () => any +>a2 : any + diff --git a/tests/baselines/reference/nestedLoops.js b/tests/baselines/reference/nestedLoops.js index c29311c38de..6b01eae55cd 100644 --- a/tests/baselines/reference/nestedLoops.js +++ b/tests/baselines/reference/nestedLoops.js @@ -19,6 +19,7 @@ export class Test { //// [nestedLoops.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var Test = (function () { function Test() { var outerArray = [1, 2, 3]; diff --git a/tests/baselines/reference/neverType.types b/tests/baselines/reference/neverType.types index bdb1ff56c3e..9555285e4be 100644 --- a/tests/baselines/reference/neverType.types +++ b/tests/baselines/reference/neverType.types @@ -164,7 +164,7 @@ function f1(x: string | number) { if (typeof x === "boolean") { >typeof x === "boolean" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"boolean" : "boolean" @@ -182,7 +182,7 @@ function f2(x: string | number) { if (typeof x === "boolean") { >typeof x === "boolean" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"boolean" : "boolean" diff --git a/tests/baselines/reference/neverTypeErrors1.errors.txt b/tests/baselines/reference/neverTypeErrors1.errors.txt index cb79c0c19fb..a27c6fba065 100644 --- a/tests/baselines/reference/neverTypeErrors1.errors.txt +++ b/tests/baselines/reference/neverTypeErrors1.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/types/never/neverTypeErrors1.ts(6,5): error TS2322: Type tests/cases/conformance/types/never/neverTypeErrors1.ts(7,5): error TS2322: Type 'null' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors1.ts(8,5): error TS2322: Type '{}' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors1.ts(12,5): error TS2322: Type 'undefined' is not assignable to type 'never'. -tests/cases/conformance/types/never/neverTypeErrors1.ts(16,12): error TS2322: Type '1' is not assignable to type 'never'. +tests/cases/conformance/types/never/neverTypeErrors1.ts(16,5): error TS2322: Type '1' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors1.ts(19,16): error TS2534: A function returning 'never' cannot have a reachable end point. @@ -40,7 +40,7 @@ tests/cases/conformance/types/never/neverTypeErrors1.ts(19,16): error TS2534: A function f3(): never { return 1; - ~ + ~~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'never'. } diff --git a/tests/baselines/reference/neverTypeErrors2.errors.txt b/tests/baselines/reference/neverTypeErrors2.errors.txt index ed27e615ea1..60e6947f44a 100644 --- a/tests/baselines/reference/neverTypeErrors2.errors.txt +++ b/tests/baselines/reference/neverTypeErrors2.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/types/never/neverTypeErrors2.ts(7,5): error TS2322: Type tests/cases/conformance/types/never/neverTypeErrors2.ts(8,5): error TS2322: Type 'null' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors2.ts(9,5): error TS2322: Type '{}' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors2.ts(13,5): error TS2322: Type 'undefined' is not assignable to type 'never'. -tests/cases/conformance/types/never/neverTypeErrors2.ts(17,12): error TS2322: Type '1' is not assignable to type 'never'. +tests/cases/conformance/types/never/neverTypeErrors2.ts(17,5): error TS2322: Type '1' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors2.ts(20,16): error TS2534: A function returning 'never' cannot have a reachable end point. @@ -41,7 +41,7 @@ tests/cases/conformance/types/never/neverTypeErrors2.ts(20,16): error TS2534: A function f3(): never { return 1; - ~ + ~~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'never'. } diff --git a/tests/baselines/reference/newTarget.es5.js b/tests/baselines/reference/newTarget.es5.js index 0de967d5477..2ebe4bfcadc 100644 --- a/tests/baselines/reference/newTarget.es5.js +++ b/tests/baselines/reference/newTarget.es5.js @@ -33,11 +33,16 @@ const O = { //// [newTarget.es5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { var _newTarget = this.constructor; diff --git a/tests/baselines/reference/noBundledEmitFromNodeModules.js b/tests/baselines/reference/noBundledEmitFromNodeModules.js new file mode 100644 index 00000000000..67216a408af --- /dev/null +++ b/tests/baselines/reference/noBundledEmitFromNodeModules.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/noBundledEmitFromNodeModules.ts] //// + +//// [index.ts] + +export class C {} + +//// [a.ts] +import { C } from "projB"; + + +//// [out.js] +System.register("a", [], function (exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + } + }; +}); diff --git a/tests/baselines/reference/noBundledEmitFromNodeModules.symbols b/tests/baselines/reference/noBundledEmitFromNodeModules.symbols new file mode 100644 index 00000000000..a1f6c67e4b4 --- /dev/null +++ b/tests/baselines/reference/noBundledEmitFromNodeModules.symbols @@ -0,0 +1,9 @@ +=== /a.ts === +import { C } from "projB"; +>C : Symbol(C, Decl(a.ts, 0, 8)) + +=== /node_modules/projB/index.ts === + +export class C {} +>C : Symbol(C, Decl(index.ts, 0, 0)) + diff --git a/tests/baselines/reference/noBundledEmitFromNodeModules.types b/tests/baselines/reference/noBundledEmitFromNodeModules.types new file mode 100644 index 00000000000..a11bad24aaf --- /dev/null +++ b/tests/baselines/reference/noBundledEmitFromNodeModules.types @@ -0,0 +1,9 @@ +=== /a.ts === +import { C } from "projB"; +>C : typeof C + +=== /node_modules/projB/index.ts === + +export class C {} +>C : C + diff --git a/tests/baselines/reference/noCatchBlock.js b/tests/baselines/reference/noCatchBlock.js index 7b0404c3cad..ecc9c7f8c7e 100644 --- a/tests/baselines/reference/noCatchBlock.js +++ b/tests/baselines/reference/noCatchBlock.js @@ -8,7 +8,9 @@ try { //// [noCatchBlock.js] try { + // ... } finally { + // N.B. No 'catch' block } //# sourceMappingURL=noCatchBlock.js.map \ No newline at end of file diff --git a/tests/baselines/reference/noCatchBlock.js.map b/tests/baselines/reference/noCatchBlock.js.map index 149a2167f46..392ec588108 100644 --- a/tests/baselines/reference/noCatchBlock.js.map +++ b/tests/baselines/reference/noCatchBlock.js.map @@ -1,2 +1,2 @@ //// [noCatchBlock.js.map] -{"version":3,"file":"noCatchBlock.js","sourceRoot":"","sources":["noCatchBlock.ts"],"names":[],"mappings":"AACA,IAAI,CAAC;AAEL,CAAC;QAAS,CAAC;AAEX,CAAC"} \ No newline at end of file +{"version":3,"file":"noCatchBlock.js","sourceRoot":"","sources":["noCatchBlock.ts"],"names":[],"mappings":"AACA,IAAI,CAAC;IACJ,MAAM;AACP,CAAC;QAAS,CAAC;IACV,wBAAwB;AACzB,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/noCatchBlock.sourcemap.txt b/tests/baselines/reference/noCatchBlock.sourcemap.txt index 18cb0d5a479..5210f12d734 100644 --- a/tests/baselines/reference/noCatchBlock.sourcemap.txt +++ b/tests/baselines/reference/noCatchBlock.sourcemap.txt @@ -12,6 +12,7 @@ sourceFile:noCatchBlock.ts 1 > 2 >^^^^ 3 > ^ +4 > ^^^^^^-> 1 > > 2 >try @@ -20,34 +21,51 @@ sourceFile:noCatchBlock.ts 2 >Emitted(1, 5) Source(2, 5) + SourceIndex(0) 3 >Emitted(1, 6) Source(2, 6) + SourceIndex(0) --- +>>> // ... +1->^^^^ +2 > ^^^^^^ +1-> + > +2 > // ... +1->Emitted(2, 5) Source(3, 2) + SourceIndex(0) +2 >Emitted(2, 11) Source(3, 8) + SourceIndex(0) +--- >>>} 1 > 2 >^ 3 > ^^^^^^^^^-> 1 > - > // ... > 2 >} -1 >Emitted(2, 1) Source(4, 1) + SourceIndex(0) -2 >Emitted(2, 2) Source(4, 2) + SourceIndex(0) +1 >Emitted(3, 1) Source(4, 1) + SourceIndex(0) +2 >Emitted(3, 2) Source(4, 2) + SourceIndex(0) --- >>>finally { 1->^^^^^^^^ 2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^-> 1-> finally 2 > { -1->Emitted(3, 9) Source(4, 11) + SourceIndex(0) -2 >Emitted(3, 10) Source(4, 12) + SourceIndex(0) +1->Emitted(4, 9) Source(4, 11) + SourceIndex(0) +2 >Emitted(4, 10) Source(4, 12) + SourceIndex(0) +--- +>>> // N.B. No 'catch' block +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^ +1-> + > +2 > // N.B. No 'catch' block +1->Emitted(5, 5) Source(5, 2) + SourceIndex(0) +2 >Emitted(5, 29) Source(5, 26) + SourceIndex(0) --- >>>} 1 > 2 >^ 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > - > // N.B. No 'catch' block > 2 >} -1 >Emitted(4, 1) Source(6, 1) + SourceIndex(0) -2 >Emitted(4, 2) Source(6, 2) + SourceIndex(0) +1 >Emitted(6, 1) Source(6, 1) + SourceIndex(0) +2 >Emitted(6, 2) Source(6, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=noCatchBlock.js.map \ No newline at end of file diff --git a/tests/baselines/reference/noEmitHelpers.js b/tests/baselines/reference/noEmitHelpers.js index fdb7cbab7d4..1a9ad2579b9 100644 --- a/tests/baselines/reference/noEmitHelpers.js +++ b/tests/baselines/reference/noEmitHelpers.js @@ -13,7 +13,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/noErrorUsingImportExportModuleAugmentationInDeclarationFile2.js b/tests/baselines/reference/noErrorUsingImportExportModuleAugmentationInDeclarationFile2.js index b56988de44c..1e2231868a8 100644 --- a/tests/baselines/reference/noErrorUsingImportExportModuleAugmentationInDeclarationFile2.js +++ b/tests/baselines/reference/noErrorUsingImportExportModuleAugmentationInDeclarationFile2.js @@ -10,4 +10,5 @@ declare var a: number; //// [1.js] "use strict"; +exports.__esModule = true; exports.j = "hello"; // error diff --git a/tests/baselines/reference/noErrorUsingImportExportModuleAugmentationInDeclarationFile3.js b/tests/baselines/reference/noErrorUsingImportExportModuleAugmentationInDeclarationFile3.js index 8c75af24034..f651d4f5b18 100644 --- a/tests/baselines/reference/noErrorUsingImportExportModuleAugmentationInDeclarationFile3.js +++ b/tests/baselines/reference/noErrorUsingImportExportModuleAugmentationInDeclarationFile3.js @@ -11,4 +11,5 @@ export var j = "hello"; // error //// [1.js] "use strict"; +exports.__esModule = true; exports.j = "hello"; // error diff --git a/tests/baselines/reference/noImplicitAnyDestructuringInPrivateMethod.js b/tests/baselines/reference/noImplicitAnyDestructuringInPrivateMethod.js index 2d7d930703c..63788fd860f 100644 --- a/tests/baselines/reference/noImplicitAnyDestructuringInPrivateMethod.js +++ b/tests/baselines/reference/noImplicitAnyDestructuringInPrivateMethod.js @@ -13,6 +13,7 @@ export declare class Bar2 { //// [noImplicitAnyDestructuringInPrivateMethod.js] "use strict"; +exports.__esModule = true; var Bar = (function () { function Bar() { } diff --git a/tests/baselines/reference/noImplicitAnyMissingGetAccessor.js b/tests/baselines/reference/noImplicitAnyMissingGetAccessor.js index cc4c9422373..7dc7e4dafb3 100644 --- a/tests/baselines/reference/noImplicitAnyMissingGetAccessor.js +++ b/tests/baselines/reference/noImplicitAnyMissingGetAccessor.js @@ -13,11 +13,16 @@ class Child extends Parent { } //// [noImplicitAnyMissingGetAccessor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Parent = (function () { function Parent() { } @@ -26,7 +31,7 @@ var Parent = (function () { var Child = (function (_super) { __extends(Child, _super); function Child() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Child.prototype, "message", { set: function (str) { diff --git a/tests/baselines/reference/noImplicitAnyMissingSetAccessor.js b/tests/baselines/reference/noImplicitAnyMissingSetAccessor.js index 1323955c05e..31d7e65ed9b 100644 --- a/tests/baselines/reference/noImplicitAnyMissingSetAccessor.js +++ b/tests/baselines/reference/noImplicitAnyMissingSetAccessor.js @@ -12,11 +12,16 @@ class Child extends Parent { } //// [noImplicitAnyMissingSetAccessor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Parent = (function () { function Parent() { } @@ -25,7 +30,7 @@ var Parent = (function () { var Child = (function (_super) { __extends(Child, _super); function Child() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Child.prototype, "message", { get: function () { diff --git a/tests/baselines/reference/noImplicitReturnsInAsync1.symbols b/tests/baselines/reference/noImplicitReturnsInAsync1.symbols index 7bf70fbf04e..58d14c2a6d0 100644 --- a/tests/baselines/reference/noImplicitReturnsInAsync1.symbols +++ b/tests/baselines/reference/noImplicitReturnsInAsync1.symbols @@ -12,6 +12,6 @@ async function test(isError: boolean = false) { let x = await Promise.resolve("The test is passed without an error."); >x : Symbol(x, Decl(noImplicitReturnsInAsync1.ts, 5, 7)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) } diff --git a/tests/baselines/reference/noImplicitUseStrict_amd.js b/tests/baselines/reference/noImplicitUseStrict_amd.js index ac15f548c47..387d5b9497b 100644 --- a/tests/baselines/reference/noImplicitUseStrict_amd.js +++ b/tests/baselines/reference/noImplicitUseStrict_amd.js @@ -4,5 +4,6 @@ export var x = 0; //// [noImplicitUseStrict_amd.js] define(["require", "exports"], function (require, exports) { + exports.__esModule = true; exports.x = 0; }); diff --git a/tests/baselines/reference/noImplicitUseStrict_commonjs.js b/tests/baselines/reference/noImplicitUseStrict_commonjs.js index 9c726938f04..4b6fd2db6cd 100644 --- a/tests/baselines/reference/noImplicitUseStrict_commonjs.js +++ b/tests/baselines/reference/noImplicitUseStrict_commonjs.js @@ -3,4 +3,5 @@ export var x = 0; //// [noImplicitUseStrict_commonjs.js] +exports.__esModule = true; exports.x = 0; diff --git a/tests/baselines/reference/noImplicitUseStrict_umd.js b/tests/baselines/reference/noImplicitUseStrict_umd.js index eafb8246bf7..484909c51fc 100644 --- a/tests/baselines/reference/noImplicitUseStrict_umd.js +++ b/tests/baselines/reference/noImplicitUseStrict_umd.js @@ -12,5 +12,6 @@ export var x = 0; define(["require", "exports"], factory); } })(function (require, exports) { + exports.__esModule = true; exports.x = 0; }); diff --git a/tests/baselines/reference/nodeResolution1.js b/tests/baselines/reference/nodeResolution1.js index deda55cef0f..d3dad3355e6 100644 --- a/tests/baselines/reference/nodeResolution1.js +++ b/tests/baselines/reference/nodeResolution1.js @@ -9,6 +9,8 @@ import y = require("./a"); //// [a.js] "use strict"; +exports.__esModule = true; exports.x = 1; //// [b.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/nodeResolution2.js b/tests/baselines/reference/nodeResolution2.js index a139eaf62cf..6d0963c6acb 100644 --- a/tests/baselines/reference/nodeResolution2.js +++ b/tests/baselines/reference/nodeResolution2.js @@ -9,3 +9,4 @@ import y = require("a"); //// [b.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/nodeResolution3.js b/tests/baselines/reference/nodeResolution3.js index 99b6a692819..8750e3ff07d 100644 --- a/tests/baselines/reference/nodeResolution3.js +++ b/tests/baselines/reference/nodeResolution3.js @@ -9,3 +9,4 @@ import y = require("b"); //// [a.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/nodeResolution4.js b/tests/baselines/reference/nodeResolution4.js index 7678b7c1c5c..0591dc5a299 100644 --- a/tests/baselines/reference/nodeResolution4.js +++ b/tests/baselines/reference/nodeResolution4.js @@ -15,5 +15,7 @@ import y = require("./a"); var x = 1; //// [a.js] "use strict"; +exports.__esModule = true; //// [b.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/nodeResolution5.js b/tests/baselines/reference/nodeResolution5.js index 766d4118e97..f5a6165906f 100644 --- a/tests/baselines/reference/nodeResolution5.js +++ b/tests/baselines/reference/nodeResolution5.js @@ -12,3 +12,4 @@ import y = require("a"); //// [b.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/nodeResolution6.js b/tests/baselines/reference/nodeResolution6.js index 196e8ae57cf..cda821991d0 100644 --- a/tests/baselines/reference/nodeResolution6.js +++ b/tests/baselines/reference/nodeResolution6.js @@ -15,3 +15,4 @@ import y = require("a"); //// [b.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/nodeResolution7.js b/tests/baselines/reference/nodeResolution7.js index 028d7ed2e81..f8cbff14726 100644 --- a/tests/baselines/reference/nodeResolution7.js +++ b/tests/baselines/reference/nodeResolution7.js @@ -12,3 +12,4 @@ import y = require("a"); //// [b.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/nodeResolution8.js b/tests/baselines/reference/nodeResolution8.js index 1d90399ff70..5facd2edc39 100644 --- a/tests/baselines/reference/nodeResolution8.js +++ b/tests/baselines/reference/nodeResolution8.js @@ -14,3 +14,4 @@ import y = require("a"); //// [b.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.js b/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.js index b0a3365193d..c088787717c 100644 --- a/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.js +++ b/tests/baselines/reference/nonGenericClassExtendingGenericClassWithAny.js @@ -6,11 +6,16 @@ class Foo { class Bar extends Foo { } // Valid //// [nonGenericClassExtendingGenericClassWithAny.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -19,7 +24,7 @@ var Foo = (function () { var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar; }(Foo)); // Valid diff --git a/tests/baselines/reference/nonIdenticalTypeConstraints.errors.txt b/tests/baselines/reference/nonIdenticalTypeConstraints.errors.txt index 627b38579a2..6070c97cf28 100644 --- a/tests/baselines/reference/nonIdenticalTypeConstraints.errors.txt +++ b/tests/baselines/reference/nonIdenticalTypeConstraints.errors.txt @@ -1,9 +1,12 @@ +tests/cases/compiler/nonIdenticalTypeConstraints.ts(7,7): error TS2428: All declarations of 'Foo' must have identical type parameters. tests/cases/compiler/nonIdenticalTypeConstraints.ts(10,11): error TS2428: All declarations of 'Foo' must have identical type parameters. +tests/cases/compiler/nonIdenticalTypeConstraints.ts(13,11): error TS2428: All declarations of 'Qux' must have identical type parameters. tests/cases/compiler/nonIdenticalTypeConstraints.ts(16,7): error TS2428: All declarations of 'Qux' must have identical type parameters. +tests/cases/compiler/nonIdenticalTypeConstraints.ts(33,7): error TS2428: All declarations of 'Quux' must have identical type parameters. tests/cases/compiler/nonIdenticalTypeConstraints.ts(36,11): error TS2428: All declarations of 'Quux' must have identical type parameters. -==== tests/cases/compiler/nonIdenticalTypeConstraints.ts (3 errors) ==== +==== tests/cases/compiler/nonIdenticalTypeConstraints.ts (6 errors) ==== class Different { a: number; b: string; @@ -11,6 +14,8 @@ tests/cases/compiler/nonIdenticalTypeConstraints.ts(36,11): error TS2428: All de } class Foo { + ~~~ +!!! error TS2428: All declarations of 'Foo' must have identical type parameters. n: T; } interface Foo { @@ -19,6 +24,8 @@ tests/cases/compiler/nonIdenticalTypeConstraints.ts(36,11): error TS2428: All de y: T; } interface Qux { + ~~~ +!!! error TS2428: All declarations of 'Qux' must have identical type parameters. y: T; } class Qux { @@ -41,6 +48,8 @@ tests/cases/compiler/nonIdenticalTypeConstraints.ts(36,11): error TS2428: All de } class Quux { + ~~~~ +!!! error TS2428: All declarations of 'Quux' must have identical type parameters. n: T; } interface Quux { diff --git a/tests/baselines/reference/nonMergedOverloads.js b/tests/baselines/reference/nonMergedOverloads.js index a577329f1cf..515792feb70 100644 --- a/tests/baselines/reference/nonMergedOverloads.js +++ b/tests/baselines/reference/nonMergedOverloads.js @@ -7,6 +7,7 @@ export function f() { //// [nonMergedOverloads.js] "use strict"; +exports.__esModule = true; var f = 10; function f() { } diff --git a/tests/baselines/reference/nonPrimitiveAccessProperty.errors.txt b/tests/baselines/reference/nonPrimitiveAccessProperty.errors.txt new file mode 100644 index 00000000000..0a6dfa66b86 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveAccessProperty.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts(3,3): error TS2339: Property 'nonExist' does not exist on type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts(5,7): error TS2459: Type 'object' has no property 'destructuring' and no string index signature. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts (2 errors) ==== + var a: object; + a.toString(); + a.nonExist(); // error + ~~~~~~~~ +!!! error TS2339: Property 'nonExist' does not exist on type 'object'. + + var { destructuring } = a; // error + ~~~~~~~~~~~~~ +!!! error TS2459: Type 'object' has no property 'destructuring' and no string index signature. + var { ...rest } = a; // ok + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveAccessProperty.js b/tests/baselines/reference/nonPrimitiveAccessProperty.js new file mode 100644 index 00000000000..abfe2605e32 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveAccessProperty.js @@ -0,0 +1,24 @@ +//// [nonPrimitiveAccessProperty.ts] +var a: object; +a.toString(); +a.nonExist(); // error + +var { destructuring } = a; // error +var { ...rest } = a; // ok + + +//// [nonPrimitiveAccessProperty.js] +var __rest = (this && this.__rest) || function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; +}; +var a; +a.toString(); +a.nonExist(); // error +var destructuring = a.destructuring; // error +var rest = __rest(a, []); // ok diff --git a/tests/baselines/reference/nonPrimitiveAsProperty.errors.txt b/tests/baselines/reference/nonPrimitiveAsProperty.errors.txt new file mode 100644 index 00000000000..8d4042c92f0 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveAsProperty.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAsProperty.ts(7,5): error TS2322: Type '{ foo: string; }' is not assignable to type 'WithNonPrimitive'. + Types of property 'foo' are incompatible. + Type 'string' is not assignable to type 'object'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAsProperty.ts (1 errors) ==== + interface WithNonPrimitive { + foo: object + } + + var a: WithNonPrimitive = { foo: {bar: "bar"} }; + + var b: WithNonPrimitive = {foo: "bar"}; // expect error + ~ +!!! error TS2322: Type '{ foo: string; }' is not assignable to type 'WithNonPrimitive'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'object'. + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveAsProperty.js b/tests/baselines/reference/nonPrimitiveAsProperty.js new file mode 100644 index 00000000000..d3e1b072a06 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveAsProperty.js @@ -0,0 +1,21 @@ +//// [nonPrimitiveAsProperty.ts] +interface WithNonPrimitive { + foo: object +} + +var a: WithNonPrimitive = { foo: {bar: "bar"} }; + +var b: WithNonPrimitive = {foo: "bar"}; // expect error + + +//// [nonPrimitiveAsProperty.js] +var a = { foo: { bar: "bar" } }; +var b = { foo: "bar" }; // expect error + + +//// [nonPrimitiveAsProperty.d.ts] +interface WithNonPrimitive { + foo: object; +} +declare var a: WithNonPrimitive; +declare var b: WithNonPrimitive; diff --git a/tests/baselines/reference/nonPrimitiveAssignError.errors.txt b/tests/baselines/reference/nonPrimitiveAssignError.errors.txt new file mode 100644 index 00000000000..f8c4450f3aa --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveAssignError.errors.txt @@ -0,0 +1,54 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(5,1): error TS2322: Type 'object' is not assignable to type '{ foo: string; }'. + Property 'foo' is missing in type '{}'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(13,1): error TS2322: Type 'number' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(14,1): error TS2322: Type 'true' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(15,1): error TS2322: Type 'string' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(17,1): error TS2322: Type 'object' is not assignable to type 'number'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(18,1): error TS2322: Type 'object' is not assignable to type 'boolean'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(19,1): error TS2322: Type 'object' is not assignable to type 'string'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts (7 errors) ==== + var x = {}; + var y = {foo: "bar"}; + var a: object; + x = a; + y = a; // expect error + ~ +!!! error TS2322: Type 'object' is not assignable to type '{ foo: string; }'. +!!! error TS2322: Property 'foo' is missing in type '{}'. + a = x; + a = y; + + var n = 123; + var b = true; + var s = "fooo"; + + a = n; // expect error + ~ +!!! error TS2322: Type 'number' is not assignable to type 'object'. + a = b; // expect error + ~ +!!! error TS2322: Type 'true' is not assignable to type 'object'. + a = s; // expect error + ~ +!!! error TS2322: Type 'string' is not assignable to type 'object'. + + n = a; // expect error + ~ +!!! error TS2322: Type 'object' is not assignable to type 'number'. + b = a; // expect error + ~ +!!! error TS2322: Type 'object' is not assignable to type 'boolean'. + s = a; // expect error + ~ +!!! error TS2322: Type 'object' is not assignable to type 'string'. + + var numObj: Number = 123; + var boolObj: Boolean = true; + var strObj: String = "string"; + + a = numObj; // ok + a = boolObj; // ok + a = strObj; // ok + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveAssignError.js b/tests/baselines/reference/nonPrimitiveAssignError.js new file mode 100644 index 00000000000..c37836a91c6 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveAssignError.js @@ -0,0 +1,53 @@ +//// [nonPrimitiveAssignError.ts] +var x = {}; +var y = {foo: "bar"}; +var a: object; +x = a; +y = a; // expect error +a = x; +a = y; + +var n = 123; +var b = true; +var s = "fooo"; + +a = n; // expect error +a = b; // expect error +a = s; // expect error + +n = a; // expect error +b = a; // expect error +s = a; // expect error + +var numObj: Number = 123; +var boolObj: Boolean = true; +var strObj: String = "string"; + +a = numObj; // ok +a = boolObj; // ok +a = strObj; // ok + + +//// [nonPrimitiveAssignError.js] +var x = {}; +var y = { foo: "bar" }; +var a; +x = a; +y = a; // expect error +a = x; +a = y; +var n = 123; +var b = true; +var s = "fooo"; +a = n; // expect error +a = b; // expect error +a = s; // expect error +n = a; // expect error +b = a; // expect error +s = a; // expect error +var numObj = 123; +var boolObj = true; +var strObj = "string"; +a = numObj; // ok +a = boolObj; // ok +a = strObj; // ok diff --git a/tests/baselines/reference/nonPrimitiveInFunction.errors.txt b/tests/baselines/reference/nonPrimitiveInFunction.errors.txt new file mode 100644 index 00000000000..c7f89fbdd06 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveInFunction.errors.txt @@ -0,0 +1,31 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts(12,12): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts(13,1): error TS2322: Type 'object' is not assignable to type 'boolean'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts(17,5): error TS2322: Type 'number' is not assignable to type 'object'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveInFunction.ts (3 errors) ==== + function takeObject(o: object) {} + function returnObject(): object { + return {}; + } + + var nonPrimitive: object; + var primitive: boolean; + + takeObject(nonPrimitive); + nonPrimitive = returnObject(); + + takeObject(primitive); // expect error + ~~~~~~~~~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'object'. + primitive = returnObject(); // expect error + ~~~~~~~~~ +!!! error TS2322: Type 'object' is not assignable to type 'boolean'. + + function returnError(): object { + var ret = 123; + return ret; // expect error + ~~~~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'object'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveInFunction.js b/tests/baselines/reference/nonPrimitiveInFunction.js new file mode 100644 index 00000000000..1d2a2462502 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveInFunction.js @@ -0,0 +1,44 @@ +//// [nonPrimitiveInFunction.ts] +function takeObject(o: object) {} +function returnObject(): object { + return {}; +} + +var nonPrimitive: object; +var primitive: boolean; + +takeObject(nonPrimitive); +nonPrimitive = returnObject(); + +takeObject(primitive); // expect error +primitive = returnObject(); // expect error + +function returnError(): object { + var ret = 123; + return ret; // expect error +} + + +//// [nonPrimitiveInFunction.js] +function takeObject(o) { } +function returnObject() { + return {}; +} +var nonPrimitive; +var primitive; +takeObject(nonPrimitive); +nonPrimitive = returnObject(); +takeObject(primitive); // expect error +primitive = returnObject(); // expect error +function returnError() { + var ret = 123; + return ret; // expect error +} + + +//// [nonPrimitiveInFunction.d.ts] +declare function takeObject(o: object): void; +declare function returnObject(): object; +declare var nonPrimitive: object; +declare var primitive: boolean; +declare function returnError(): object; diff --git a/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt b/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt new file mode 100644 index 00000000000..ce257c87680 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveInGeneric.errors.txt @@ -0,0 +1,71 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(2,9): error TS2322: Type 'T' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(9,17): error TS2345: Argument of type '123' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(10,17): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(18,7): error TS2345: Argument of type '123' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(19,7): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(25,8): error TS2344: Type 'number' does not satisfy the constraint 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(26,8): error TS2344: Type 'string' does not satisfy the constraint 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(34,14): error TS2344: Type 'number' does not satisfy the constraint 'object'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts (8 errors) ==== + function generic(t: T) { + var o: object = t; // expect error + ~ +!!! error TS2322: Type 'T' is not assignable to type 'object'. + } + var a = {}; + var b = "42"; + + generic({}); + generic(a); + generic(123); // expect error + ~~~ +!!! error TS2345: Argument of type '123' is not assignable to parameter of type 'object'. + generic(b); // expect error + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. + + function bound(t: T) { + var o: object = t; // ok + } + + bound({}); + bound(a); + bound(123); // expect error + ~~~ +!!! error TS2345: Argument of type '123' is not assignable to parameter of type 'object'. + bound(b); // expect error + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'. + + function bound2() {} + + bound2<{}>(); + bound2(); + bound2(); // expect error + ~~~~~~ +!!! error TS2344: Type 'number' does not satisfy the constraint 'object'. + bound2(); // expect error + ~~~~~~ +!!! error TS2344: Type 'string' does not satisfy the constraint 'object'. + + function bound3(t: T) { + var o: object = t; // ok + } + + interface Proxy {} + + var x: Proxy; // error + ~~~~~~ +!!! error TS2344: Type 'number' does not satisfy the constraint 'object'. + var y: Proxy; // ok + var z: Proxy ; // ok + + + interface Blah { + foo: number; + } + + var u: Proxy; // ok + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveInGeneric.js b/tests/baselines/reference/nonPrimitiveInGeneric.js new file mode 100644 index 00000000000..d7e013c71f1 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveInGeneric.js @@ -0,0 +1,93 @@ +//// [nonPrimitiveInGeneric.ts] +function generic(t: T) { + var o: object = t; // expect error +} +var a = {}; +var b = "42"; + +generic({}); +generic(a); +generic(123); // expect error +generic(b); // expect error + +function bound(t: T) { + var o: object = t; // ok +} + +bound({}); +bound(a); +bound(123); // expect error +bound(b); // expect error + +function bound2() {} + +bound2<{}>(); +bound2(); +bound2(); // expect error +bound2(); // expect error + +function bound3(t: T) { + var o: object = t; // ok +} + +interface Proxy {} + +var x: Proxy; // error +var y: Proxy; // ok +var z: Proxy ; // ok + + +interface Blah { + foo: number; +} + +var u: Proxy; // ok + + +//// [nonPrimitiveInGeneric.js] +function generic(t) { + var o = t; // expect error +} +var a = {}; +var b = "42"; +generic({}); +generic(a); +generic(123); // expect error +generic(b); // expect error +function bound(t) { + var o = t; // ok +} +bound({}); +bound(a); +bound(123); // expect error +bound(b); // expect error +function bound2() { } +bound2(); +bound2(); +bound2(); // expect error +bound2(); // expect error +function bound3(t) { + var o = t; // ok +} +var x; // error +var y; // ok +var z; // ok +var u; // ok + + +//// [nonPrimitiveInGeneric.d.ts] +declare function generic(t: T): void; +declare var a: {}; +declare var b: string; +declare function bound(t: T): void; +declare function bound2(): void; +declare function bound3(t: T): void; +interface Proxy { +} +declare var x: Proxy; +declare var y: Proxy; +declare var z: Proxy; +interface Blah { + foo: number; +} +declare var u: Proxy; diff --git a/tests/baselines/reference/nonPrimitiveNarrow.errors.txt b/tests/baselines/reference/nonPrimitiveNarrow.errors.txt new file mode 100644 index 00000000000..1b3cf55b4b2 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveNarrow.errors.txt @@ -0,0 +1,35 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts(9,5): error TS2322: Type '123' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts(13,7): error TS2339: Property 'toFixed' does not exist on type 'never'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts(21,6): error TS2339: Property 'toString' does not exist on type 'never'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts (3 errors) ==== + class Narrow { + narrowed: boolean + } + + var a: object + + if (a instanceof Narrow) { + a.narrowed; // ok + a = 123; // error + ~ +!!! error TS2322: Type '123' is not assignable to type 'object'. + } + + if (typeof a === 'number') { + a.toFixed(); // error, never + ~~~~~~~ +!!! error TS2339: Property 'toFixed' does not exist on type 'never'. + } + + var b: object | null + + if (typeof b === 'object') { + b.toString(); // ok, object | null + } else { + b.toString(); // error, never + ~~~~~~~~ +!!! error TS2339: Property 'toString' does not exist on type 'never'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveNarrow.js b/tests/baselines/reference/nonPrimitiveNarrow.js new file mode 100644 index 00000000000..607206eecfc --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveNarrow.js @@ -0,0 +1,46 @@ +//// [nonPrimitiveNarrow.ts] +class Narrow { + narrowed: boolean +} + +var a: object + +if (a instanceof Narrow) { + a.narrowed; // ok + a = 123; // error +} + +if (typeof a === 'number') { + a.toFixed(); // error, never +} + +var b: object | null + +if (typeof b === 'object') { + b.toString(); // ok, object | null +} else { + b.toString(); // error, never +} + + +//// [nonPrimitiveNarrow.js] +var Narrow = (function () { + function Narrow() { + } + return Narrow; +}()); +var a; +if (a instanceof Narrow) { + a.narrowed; // ok + a = 123; // error +} +if (typeof a === 'number') { + a.toFixed(); // error, never +} +var b; +if (typeof b === 'object') { + b.toString(); // ok, object | null +} +else { + b.toString(); // error, never +} diff --git a/tests/baselines/reference/nonPrimitiveStrictNull.errors.txt b/tests/baselines/reference/nonPrimitiveStrictNull.errors.txt new file mode 100644 index 00000000000..473011aaa7f --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveStrictNull.errors.txt @@ -0,0 +1,126 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(7,1): error TS2454: Variable 'a' is used before being assigned. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(8,1): error TS2322: Type 'undefined' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(9,1): error TS2322: Type 'null' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(10,1): error TS2322: Type 'object | null' is not assignable to type 'object'. + Type 'null' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(11,1): error TS2322: Type 'object | undefined' is not assignable to type 'object'. + Type 'undefined' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(12,1): error TS2322: Type 'object | null | undefined' is not assignable to type 'object'. + Type 'undefined' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(18,7): error TS2339: Property 'toString' does not exist on type 'never'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(22,5): error TS2322: Type 'object | null' is not assignable to type 'object'. + Type 'null' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(27,5): error TS2531: Object is possibly 'null'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(29,5): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(33,5): error TS2533: Object is possibly 'null' or 'undefined'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(39,5): error TS2531: Object is possibly 'null'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(41,5): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(45,5): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(47,5): error TS2531: Object is possibly 'null'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(52,14): error TS2344: Type 'number' does not satisfy the constraint 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(53,14): error TS2344: Type 'null' does not satisfy the constraint 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(54,14): error TS2344: Type 'undefined' does not satisfy the constraint 'object'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts (18 errors) ==== + + var a: object + declare var b: object | null + declare var c: object | undefined + declare var d: object | null | undefined + var e: object | null + a.toString; // error + ~ +!!! error TS2454: Variable 'a' is used before being assigned. + a = undefined; // error + ~ +!!! error TS2322: Type 'undefined' is not assignable to type 'object'. + a = null; // error + ~ +!!! error TS2322: Type 'null' is not assignable to type 'object'. + a = b; // error + ~ +!!! error TS2322: Type 'object | null' is not assignable to type 'object'. +!!! error TS2322: Type 'null' is not assignable to type 'object'. + a = c; // error + ~ +!!! error TS2322: Type 'object | undefined' is not assignable to type 'object'. +!!! error TS2322: Type 'undefined' is not assignable to type 'object'. + a = d; // error + ~ +!!! error TS2322: Type 'object | null | undefined' is not assignable to type 'object'. +!!! error TS2322: Type 'undefined' is not assignable to type 'object'. + + e = a; // ok + a = e; // ok + + if (typeof b !== 'object') { + b.toString(); // error, never + ~~~~~~~~ +!!! error TS2339: Property 'toString' does not exist on type 'never'. + } + + if (typeof b === 'object') { + a = b; // error, b is not narrowed + ~ +!!! error TS2322: Type 'object | null' is not assignable to type 'object'. +!!! error TS2322: Type 'null' is not assignable to type 'object'. + } + + if (typeof d === 'object') { + b = d; // ok + d.toString(); // error, object | null + ~ +!!! error TS2531: Object is possibly 'null'. + } else { + d.toString(); // error, undefined + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + + if (d == null) { + d.toString(); // error, undefined | null + ~ +!!! error TS2533: Object is possibly 'null' or 'undefined'. + } else { + d.toString(); // object + } + + if (d === null) { + d.toString(); // error, null + ~ +!!! error TS2531: Object is possibly 'null'. + } else { + d.toString(); // error, object | undefined + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + + if (typeof d === 'undefined') { + d.toString(); // error, undefined + ~ +!!! error TS2532: Object is possibly 'undefined'. + } else { + d.toString(); // error, object | null + ~ +!!! error TS2531: Object is possibly 'null'. + } + + interface Proxy {} + + var x: Proxy; // error + ~~~~~~ +!!! error TS2344: Type 'number' does not satisfy the constraint 'object'. + var y: Proxy; // error + ~~~~ +!!! error TS2344: Type 'null' does not satisfy the constraint 'object'. + var z: Proxy; // error + ~~~~~~~~~ +!!! error TS2344: Type 'undefined' does not satisfy the constraint 'object'. + + interface Blah { + foo: number; + } + + var u: Proxy; // ok + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveStrictNull.js b/tests/baselines/reference/nonPrimitiveStrictNull.js new file mode 100644 index 00000000000..754ca8cac7d --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveStrictNull.js @@ -0,0 +1,109 @@ +//// [nonPrimitiveStrictNull.ts] + +var a: object +declare var b: object | null +declare var c: object | undefined +declare var d: object | null | undefined +var e: object | null +a.toString; // error +a = undefined; // error +a = null; // error +a = b; // error +a = c; // error +a = d; // error + +e = a; // ok +a = e; // ok + +if (typeof b !== 'object') { + b.toString(); // error, never +} + +if (typeof b === 'object') { + a = b; // error, b is not narrowed +} + +if (typeof d === 'object') { + b = d; // ok + d.toString(); // error, object | null +} else { + d.toString(); // error, undefined +} + +if (d == null) { + d.toString(); // error, undefined | null +} else { + d.toString(); // object +} + +if (d === null) { + d.toString(); // error, null +} else { + d.toString(); // error, object | undefined +} + +if (typeof d === 'undefined') { + d.toString(); // error, undefined +} else { + d.toString(); // error, object | null +} + +interface Proxy {} + +var x: Proxy; // error +var y: Proxy; // error +var z: Proxy; // error + +interface Blah { + foo: number; +} + +var u: Proxy; // ok + + +//// [nonPrimitiveStrictNull.js] +var a; +var e; +a.toString; // error +a = undefined; // error +a = null; // error +a = b; // error +a = c; // error +a = d; // error +e = a; // ok +a = e; // ok +if (typeof b !== 'object') { + b.toString(); // error, never +} +if (typeof b === 'object') { + a = b; // error, b is not narrowed +} +if (typeof d === 'object') { + b = d; // ok + d.toString(); // error, object | null +} +else { + d.toString(); // error, undefined +} +if (d == null) { + d.toString(); // error, undefined | null +} +else { + d.toString(); // object +} +if (d === null) { + d.toString(); // error, null +} +else { + d.toString(); // error, object | undefined +} +if (typeof d === 'undefined') { + d.toString(); // error, undefined +} +else { + d.toString(); // error, object | null +} +var x; // error +var y; // error +var z; // error +var u; // ok diff --git a/tests/baselines/reference/nonPrimitiveUnionIntersection.errors.txt b/tests/baselines/reference/nonPrimitiveUnionIntersection.errors.txt new file mode 100644 index 00000000000..5fb1e89c2e3 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveUnionIntersection.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts(1,5): error TS2322: Type '""' is not assignable to type 'object & string'. + Type '""' is not assignable to type 'object'. +tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts(3,1): error TS2322: Type 'string' is not assignable to type 'object & string'. + Type 'string' is not assignable to type 'object'. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts (2 errors) ==== + var a: object & string = ""; // error + ~ +!!! error TS2322: Type '""' is not assignable to type 'object & string'. +!!! error TS2322: Type '""' is not assignable to type 'object'. + var b: object | string = ""; // ok + a = b; // error + ~ +!!! error TS2322: Type 'string' is not assignable to type 'object & string'. +!!! error TS2322: Type 'string' is not assignable to type 'object'. + b = a; // ok + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveUnionIntersection.js b/tests/baselines/reference/nonPrimitiveUnionIntersection.js new file mode 100644 index 00000000000..7f4b46c42ed --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveUnionIntersection.js @@ -0,0 +1,17 @@ +//// [nonPrimitiveUnionIntersection.ts] +var a: object & string = ""; // error +var b: object | string = ""; // ok +a = b; // error +b = a; // ok + + +//// [nonPrimitiveUnionIntersection.js] +var a = ""; // error +var b = ""; // ok +a = b; // error +b = a; // ok + + +//// [nonPrimitiveUnionIntersection.d.ts] +declare var a: object & string; +declare var b: object | string; diff --git a/tests/baselines/reference/nounusedTypeParameterConstraint.js b/tests/baselines/reference/nounusedTypeParameterConstraint.js index aa403187f7a..f8881e6d0a0 100644 --- a/tests/baselines/reference/nounusedTypeParameterConstraint.js +++ b/tests/baselines/reference/nounusedTypeParameterConstraint.js @@ -10,5 +10,7 @@ export type DomainEntityConstructor = { new //// [bar.js] "use strict"; +exports.__esModule = true; //// [test.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/null.errors.txt b/tests/baselines/reference/null.errors.txt new file mode 100644 index 00000000000..f957507438c --- /dev/null +++ b/tests/baselines/reference/null.errors.txt @@ -0,0 +1,28 @@ +tests/cases/compiler/null.ts(4,9): error TS2531: Object is possibly 'null'. + + +==== tests/cases/compiler/null.ts (1 errors) ==== + + var x=null; + var y=3+x; + var z=3+null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. + class C { + } + function f() { + return null; + return new C(); + } + function g() { + return null; + return 3; + } + 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/nullKeyword.errors.txt b/tests/baselines/reference/nullKeyword.errors.txt index a140fce0b0f..b815b61b676 100644 --- a/tests/baselines/reference/nullKeyword.errors.txt +++ b/tests/baselines/reference/nullKeyword.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/nullKeyword.ts(1,6): error TS2339: Property 'foo' does not exist on type 'null'. +tests/cases/compiler/nullKeyword.ts(1,1): error TS2531: Object is possibly 'null'. ==== tests/cases/compiler/nullKeyword.ts (1 errors) ==== null.foo; - ~~~ -!!! error TS2339: Property 'foo' does not exist on type 'null'. \ No newline at end of file + ~~~~ +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/numberToString.errors.txt b/tests/baselines/reference/numberToString.errors.txt index 60a382e47c3..bbd9178862a 100644 --- a/tests/baselines/reference/numberToString.errors.txt +++ b/tests/baselines/reference/numberToString.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/numberToString.ts(2,12): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/numberToString.ts(2,5): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/compiler/numberToString.ts(9,4): error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/numberToString.ts (2 errors) ==== function f1(n:number):string { return n; // error return type mismatch - ~ + ~~~~~~~~~ !!! error TS2322: Type 'number' is not assignable to type 'string'. } diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt index ec0f330f1a3..f532bd23755 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(36,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(50,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(68,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(79,5): error TS2322: Type '{ 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(79,5): error TS2322: Type '{ a: string; b: number; c: () => void; "d": string; "e": number; 1.0: string; 2.0: number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'. Object literal may only specify known properties, and 'a' does not exist in type '{ [x: number]: string; }'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(88,9): error TS2304: Cannot find name 'Myn'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -107,7 +107,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo var b: { [x: number]: string; } = { a: '', ~~~~~ -!!! error TS2322: Type '{ 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'. +!!! error TS2322: Type '{ a: string; b: number; c: () => void; "d": string; "e": number; 1.0: string; 2.0: number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'. !!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ [x: number]: string; }'. b: 1, c: () => { }, diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt index e6d22ff0712..74cd032c40e 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(16,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(25,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(34,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(44,5): error TS2322: Type '{ 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(44,5): error TS2322: Type '{ 1.0: A; 2.0: B; "2.5": B; 3.0: number; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. Object literal may only specify known properties, and '"4.0"' does not exist in type '{ [x: number]: A; }'. @@ -57,6 +57,6 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo 3.0: 1, "4.0": '' ~~~~~~~~~ -!!! error TS2322: Type '{ 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. +!!! error TS2322: Type '{ 1.0: A; 2.0: B; "2.5": B; 3.0: number; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. !!! error TS2322: Object literal may only specify known properties, and '"4.0"' does not exist in type '{ [x: number]: A; }'. } \ No newline at end of file diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.js b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.js index 92c8b380e00..9e501b5d92c 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.js +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.js @@ -47,11 +47,16 @@ var b: { [x: number]: A } = { //// [numericIndexerConstrainsPropertyDeclarations2.js] // String indexer providing a constraint of a user defined type -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -61,7 +66,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function () { return ''; }; return B; diff --git a/tests/baselines/reference/numericIndexerConstraint3.js b/tests/baselines/reference/numericIndexerConstraint3.js index 29cb75b4234..9e733e593fd 100644 --- a/tests/baselines/reference/numericIndexerConstraint3.js +++ b/tests/baselines/reference/numericIndexerConstraint3.js @@ -13,11 +13,16 @@ class C { } //// [numericIndexerConstraint3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -26,7 +31,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/numericIndexerConstraint4.js b/tests/baselines/reference/numericIndexerConstraint4.js index 135e169c4a9..4546db0b8a4 100644 --- a/tests/baselines/reference/numericIndexerConstraint4.js +++ b/tests/baselines/reference/numericIndexerConstraint4.js @@ -13,11 +13,16 @@ var x: { //// [numericIndexerConstraint4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -26,7 +31,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/numericIndexerConstraint5.errors.txt b/tests/baselines/reference/numericIndexerConstraint5.errors.txt index cb888de08c4..04b7e0dc337 100644 --- a/tests/baselines/reference/numericIndexerConstraint5.errors.txt +++ b/tests/baselines/reference/numericIndexerConstraint5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/numericIndexerConstraint5.ts(2,5): error TS2322: Type '{ 0: Date; name: string; }' is not assignable to type '{ [name: number]: string; }'. +tests/cases/compiler/numericIndexerConstraint5.ts(2,5): error TS2322: Type '{ name: string; 0: Date; }' is not assignable to type '{ [name: number]: string; }'. Property '0' is incompatible with index signature. Type 'Date' is not assignable to type 'string'. @@ -7,6 +7,6 @@ tests/cases/compiler/numericIndexerConstraint5.ts(2,5): error TS2322: Type '{ 0: var x = { name: "x", 0: new Date() }; var z: { [name: number]: string } = x; ~ -!!! error TS2322: Type '{ 0: Date; name: string; }' is not assignable to type '{ [name: number]: string; }'. +!!! error TS2322: Type '{ name: string; 0: Date; }' is not assignable to type '{ [name: number]: string; }'. !!! error TS2322: Property '0' is incompatible with index signature. !!! error TS2322: Type 'Date' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/numericIndexerTyping2.js b/tests/baselines/reference/numericIndexerTyping2.js index 5b9e797bdec..8bcc5ac61c4 100644 --- a/tests/baselines/reference/numericIndexerTyping2.js +++ b/tests/baselines/reference/numericIndexerTyping2.js @@ -13,11 +13,16 @@ var i2: I2; var r2: string = i2[1]; // error: numeric indexer returns the type of the string indexere //// [numericIndexerTyping2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var I = (function () { function I() { } @@ -26,7 +31,7 @@ var I = (function () { var I2 = (function (_super) { __extends(I2, _super); function I2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return I2; }(I)); diff --git a/tests/baselines/reference/objectCreate-errors.errors.txt b/tests/baselines/reference/objectCreate-errors.errors.txt new file mode 100644 index 00000000000..38b9158351e --- /dev/null +++ b/tests/baselines/reference/objectCreate-errors.errors.txt @@ -0,0 +1,38 @@ +tests/cases/compiler/objectCreate-errors.ts(2,24): error TS2345: Argument of type '1' is not assignable to parameter of type 'object | null'. +tests/cases/compiler/objectCreate-errors.ts(3,24): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'object | null'. +tests/cases/compiler/objectCreate-errors.ts(4,24): error TS2345: Argument of type 'false' is not assignable to parameter of type 'object | null'. +tests/cases/compiler/objectCreate-errors.ts(5,24): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'object | null'. +tests/cases/compiler/objectCreate-errors.ts(8,24): error TS2345: Argument of type '1' is not assignable to parameter of type 'object | null'. +tests/cases/compiler/objectCreate-errors.ts(9,24): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'object | null'. +tests/cases/compiler/objectCreate-errors.ts(10,24): error TS2345: Argument of type 'false' is not assignable to parameter of type 'object | null'. +tests/cases/compiler/objectCreate-errors.ts(11,24): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'object | null'. + + +==== tests/cases/compiler/objectCreate-errors.ts (8 errors) ==== + + var e1 = Object.create(1); // Error + ~ +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'object | null'. + var e2 = Object.create("string"); // Error + ~~~~~~~~ +!!! error TS2345: Argument of type '"string"' is not assignable to parameter of type 'object | null'. + var e3 = Object.create(false); // Error + ~~~~~ +!!! error TS2345: Argument of type 'false' is not assignable to parameter of type 'object | null'. + var e4 = Object.create(undefined); // Error + ~~~~~~~~~ +!!! error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'object | null'. + + + var e5 = Object.create(1, {}); // Error + ~ +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'object | null'. + var e6 = Object.create("string", {}); // Error + ~~~~~~~~ +!!! error TS2345: Argument of type '"string"' is not assignable to parameter of type 'object | null'. + var e7 = Object.create(false, {}); // Error + ~~~~~ +!!! error TS2345: Argument of type 'false' is not assignable to parameter of type 'object | null'. + var e8 = Object.create(undefined, {}); // Error + ~~~~~~~~~ +!!! error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'object | null'. \ No newline at end of file diff --git a/tests/baselines/reference/objectCreate-errors.js b/tests/baselines/reference/objectCreate-errors.js new file mode 100644 index 00000000000..959b2f9473d --- /dev/null +++ b/tests/baselines/reference/objectCreate-errors.js @@ -0,0 +1,22 @@ +//// [objectCreate-errors.ts] + +var e1 = Object.create(1); // Error +var e2 = Object.create("string"); // Error +var e3 = Object.create(false); // Error +var e4 = Object.create(undefined); // Error + + +var e5 = Object.create(1, {}); // Error +var e6 = Object.create("string", {}); // Error +var e7 = Object.create(false, {}); // Error +var e8 = Object.create(undefined, {}); // Error + +//// [objectCreate-errors.js] +var e1 = Object.create(1); // Error +var e2 = Object.create("string"); // Error +var e3 = Object.create(false); // Error +var e4 = Object.create(undefined); // Error +var e5 = Object.create(1, {}); // Error +var e6 = Object.create("string", {}); // Error +var e7 = Object.create(false, {}); // Error +var e8 = Object.create(undefined, {}); // Error diff --git a/tests/baselines/reference/objectCreate.js b/tests/baselines/reference/objectCreate.js new file mode 100644 index 00000000000..728fa8ca21a --- /dev/null +++ b/tests/baselines/reference/objectCreate.js @@ -0,0 +1,28 @@ +//// [objectCreate.ts] + +declare var union: null | { a: number, b: string }; + +var n = Object.create(null); // object +var t = Object.create({ a: 1, b: "" }); // {a: number, b: string } +var u = Object.create(union); // object | {a: number, b: string } +var e = Object.create({}); // {} +var o = Object.create({}); // object + +var a = Object.create(null, {}); // any +var a = Object.create({ a: 1, b: "" }, {}); +var a = Object.create(union, {}); +var a = Object.create({}, {}); +var a = Object.create({}, {}); + + +//// [objectCreate.js] +var n = Object.create(null); // object +var t = Object.create({ a: 1, b: "" }); // {a: number, b: string } +var u = Object.create(union); // object | {a: number, b: string } +var e = Object.create({}); // {} +var o = Object.create({}); // object +var a = Object.create(null, {}); // any +var a = Object.create({ a: 1, b: "" }, {}); +var a = Object.create(union, {}); +var a = Object.create({}, {}); +var a = Object.create({}, {}); diff --git a/tests/baselines/reference/objectCreate.symbols b/tests/baselines/reference/objectCreate.symbols new file mode 100644 index 00000000000..7ae0a796cc8 --- /dev/null +++ b/tests/baselines/reference/objectCreate.symbols @@ -0,0 +1,73 @@ +=== tests/cases/compiler/objectCreate.ts === + +declare var union: null | { a: number, b: string }; +>union : Symbol(union, Decl(objectCreate.ts, 1, 11)) +>a : Symbol(a, Decl(objectCreate.ts, 1, 27)) +>b : Symbol(b, Decl(objectCreate.ts, 1, 38)) + +var n = Object.create(null); // object +>n : Symbol(n, Decl(objectCreate.ts, 3, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var t = Object.create({ a: 1, b: "" }); // {a: number, b: string } +>t : Symbol(t, Decl(objectCreate.ts, 4, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>a : Symbol(a, Decl(objectCreate.ts, 4, 23)) +>b : Symbol(b, Decl(objectCreate.ts, 4, 29)) + +var u = Object.create(union); // object | {a: number, b: string } +>u : Symbol(u, Decl(objectCreate.ts, 5, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>union : Symbol(union, Decl(objectCreate.ts, 1, 11)) + +var e = Object.create({}); // {} +>e : Symbol(e, Decl(objectCreate.ts, 6, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var o = Object.create({}); // object +>o : Symbol(o, Decl(objectCreate.ts, 7, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var a = Object.create(null, {}); // any +>a : Symbol(a, Decl(objectCreate.ts, 9, 3), Decl(objectCreate.ts, 10, 3), Decl(objectCreate.ts, 11, 3), Decl(objectCreate.ts, 12, 3), Decl(objectCreate.ts, 13, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var a = Object.create({ a: 1, b: "" }, {}); +>a : Symbol(a, Decl(objectCreate.ts, 9, 3), Decl(objectCreate.ts, 10, 3), Decl(objectCreate.ts, 11, 3), Decl(objectCreate.ts, 12, 3), Decl(objectCreate.ts, 13, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>a : Symbol(a, Decl(objectCreate.ts, 10, 23)) +>b : Symbol(b, Decl(objectCreate.ts, 10, 29)) + +var a = Object.create(union, {}); +>a : Symbol(a, Decl(objectCreate.ts, 9, 3), Decl(objectCreate.ts, 10, 3), Decl(objectCreate.ts, 11, 3), Decl(objectCreate.ts, 12, 3), Decl(objectCreate.ts, 13, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>union : Symbol(union, Decl(objectCreate.ts, 1, 11)) + +var a = Object.create({}, {}); +>a : Symbol(a, Decl(objectCreate.ts, 9, 3), Decl(objectCreate.ts, 10, 3), Decl(objectCreate.ts, 11, 3), Decl(objectCreate.ts, 12, 3), Decl(objectCreate.ts, 13, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var a = Object.create({}, {}); +>a : Symbol(a, Decl(objectCreate.ts, 9, 3), Decl(objectCreate.ts, 10, 3), Decl(objectCreate.ts, 11, 3), Decl(objectCreate.ts, 12, 3), Decl(objectCreate.ts, 13, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/objectCreate.types b/tests/baselines/reference/objectCreate.types new file mode 100644 index 00000000000..b4e0e72061e --- /dev/null +++ b/tests/baselines/reference/objectCreate.types @@ -0,0 +1,103 @@ +=== tests/cases/compiler/objectCreate.ts === + +declare var union: null | { a: number, b: string }; +>union : { a: number; b: string; } | null +>null : null +>a : number +>b : string + +var n = Object.create(null); // object +>n : any +>Object.create(null) : any +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>null : null + +var t = Object.create({ a: 1, b: "" }); // {a: number, b: string } +>t : any +>Object.create({ a: 1, b: "" }) : any +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>{ a: 1, b: "" } : { a: number; b: string; } +>a : number +>1 : 1 +>b : string +>"" : "" + +var u = Object.create(union); // object | {a: number, b: string } +>u : any +>Object.create(union) : any +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>union : { a: number; b: string; } | null + +var e = Object.create({}); // {} +>e : any +>Object.create({}) : any +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>{} : {} + +var o = Object.create({}); // object +>o : any +>Object.create({}) : any +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>{} : object +>{} : {} + +var a = Object.create(null, {}); // any +>a : any +>Object.create(null, {}) : any +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>null : null +>{} : {} + +var a = Object.create({ a: 1, b: "" }, {}); +>a : any +>Object.create({ a: 1, b: "" }, {}) : any +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>{ a: 1, b: "" } : { a: number; b: string; } +>a : number +>1 : 1 +>b : string +>"" : "" +>{} : {} + +var a = Object.create(union, {}); +>a : any +>Object.create(union, {}) : any +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>union : { a: number; b: string; } | null +>{} : {} + +var a = Object.create({}, {}); +>a : any +>Object.create({}, {}) : any +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>{} : {} +>{} : {} + +var a = Object.create({}, {}); +>a : any +>Object.create({}, {}) : any +>Object.create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object | null): any; (o: object | null, properties: PropertyDescriptorMap): any; } +>{} : object +>{} : {} +>{} : {} + diff --git a/tests/baselines/reference/objectCreate2.js b/tests/baselines/reference/objectCreate2.js new file mode 100644 index 00000000000..cfc79c2ef35 --- /dev/null +++ b/tests/baselines/reference/objectCreate2.js @@ -0,0 +1,28 @@ +//// [objectCreate2.ts] + +declare var union: null | { a: number, b: string }; + +var n = Object.create(null); // any +var t = Object.create({ a: 1, b: "" }); // {a: number, b: string } +var u = Object.create(union); // {a: number, b: string } +var e = Object.create({}); // {} +var o = Object.create({}); // object + +var a = Object.create(null, {}); // any +var a = Object.create({ a: 1, b: "" }, {}); +var a = Object.create(union, {}); +var a = Object.create({}, {}); +var a = Object.create({}, {}); + + +//// [objectCreate2.js] +var n = Object.create(null); // any +var t = Object.create({ a: 1, b: "" }); // {a: number, b: string } +var u = Object.create(union); // {a: number, b: string } +var e = Object.create({}); // {} +var o = Object.create({}); // object +var a = Object.create(null, {}); // any +var a = Object.create({ a: 1, b: "" }, {}); +var a = Object.create(union, {}); +var a = Object.create({}, {}); +var a = Object.create({}, {}); diff --git a/tests/baselines/reference/objectCreate2.symbols b/tests/baselines/reference/objectCreate2.symbols new file mode 100644 index 00000000000..bf57b6d5e07 --- /dev/null +++ b/tests/baselines/reference/objectCreate2.symbols @@ -0,0 +1,73 @@ +=== tests/cases/compiler/objectCreate2.ts === + +declare var union: null | { a: number, b: string }; +>union : Symbol(union, Decl(objectCreate2.ts, 1, 11)) +>a : Symbol(a, Decl(objectCreate2.ts, 1, 27)) +>b : Symbol(b, Decl(objectCreate2.ts, 1, 38)) + +var n = Object.create(null); // any +>n : Symbol(n, Decl(objectCreate2.ts, 3, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var t = Object.create({ a: 1, b: "" }); // {a: number, b: string } +>t : Symbol(t, Decl(objectCreate2.ts, 4, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>a : Symbol(a, Decl(objectCreate2.ts, 4, 23)) +>b : Symbol(b, Decl(objectCreate2.ts, 4, 29)) + +var u = Object.create(union); // {a: number, b: string } +>u : Symbol(u, Decl(objectCreate2.ts, 5, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>union : Symbol(union, Decl(objectCreate2.ts, 1, 11)) + +var e = Object.create({}); // {} +>e : Symbol(e, Decl(objectCreate2.ts, 6, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var o = Object.create({}); // object +>o : Symbol(o, Decl(objectCreate2.ts, 7, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var a = Object.create(null, {}); // any +>a : Symbol(a, Decl(objectCreate2.ts, 9, 3), Decl(objectCreate2.ts, 10, 3), Decl(objectCreate2.ts, 11, 3), Decl(objectCreate2.ts, 12, 3), Decl(objectCreate2.ts, 13, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var a = Object.create({ a: 1, b: "" }, {}); +>a : Symbol(a, Decl(objectCreate2.ts, 9, 3), Decl(objectCreate2.ts, 10, 3), Decl(objectCreate2.ts, 11, 3), Decl(objectCreate2.ts, 12, 3), Decl(objectCreate2.ts, 13, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>a : Symbol(a, Decl(objectCreate2.ts, 10, 23)) +>b : Symbol(b, Decl(objectCreate2.ts, 10, 29)) + +var a = Object.create(union, {}); +>a : Symbol(a, Decl(objectCreate2.ts, 9, 3), Decl(objectCreate2.ts, 10, 3), Decl(objectCreate2.ts, 11, 3), Decl(objectCreate2.ts, 12, 3), Decl(objectCreate2.ts, 13, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>union : Symbol(union, Decl(objectCreate2.ts, 1, 11)) + +var a = Object.create({}, {}); +>a : Symbol(a, Decl(objectCreate2.ts, 9, 3), Decl(objectCreate2.ts, 10, 3), Decl(objectCreate2.ts, 11, 3), Decl(objectCreate2.ts, 12, 3), Decl(objectCreate2.ts, 13, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var a = Object.create({}, {}); +>a : Symbol(a, Decl(objectCreate2.ts, 9, 3), Decl(objectCreate2.ts, 10, 3), Decl(objectCreate2.ts, 11, 3), Decl(objectCreate2.ts, 12, 3), Decl(objectCreate2.ts, 13, 3)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/objectCreate2.types b/tests/baselines/reference/objectCreate2.types new file mode 100644 index 00000000000..3e19c08bfc0 --- /dev/null +++ b/tests/baselines/reference/objectCreate2.types @@ -0,0 +1,103 @@ +=== tests/cases/compiler/objectCreate2.ts === + +declare var union: null | { a: number, b: string }; +>union : { a: number; b: string; } +>null : null +>a : number +>b : string + +var n = Object.create(null); // any +>n : any +>Object.create(null) : any +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>null : null + +var t = Object.create({ a: 1, b: "" }); // {a: number, b: string } +>t : any +>Object.create({ a: 1, b: "" }) : any +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>{ a: 1, b: "" } : { a: number; b: string; } +>a : number +>1 : 1 +>b : string +>"" : "" + +var u = Object.create(union); // {a: number, b: string } +>u : any +>Object.create(union) : any +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>union : { a: number; b: string; } + +var e = Object.create({}); // {} +>e : any +>Object.create({}) : any +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>{} : {} + +var o = Object.create({}); // object +>o : any +>Object.create({}) : any +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>{} : object +>{} : {} + +var a = Object.create(null, {}); // any +>a : any +>Object.create(null, {}) : any +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>null : null +>{} : {} + +var a = Object.create({ a: 1, b: "" }, {}); +>a : any +>Object.create({ a: 1, b: "" }, {}) : any +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>{ a: 1, b: "" } : { a: number; b: string; } +>a : number +>1 : 1 +>b : string +>"" : "" +>{} : {} + +var a = Object.create(union, {}); +>a : any +>Object.create(union, {}) : any +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>union : { a: number; b: string; } +>{} : {} + +var a = Object.create({}, {}); +>a : any +>Object.create({}, {}) : any +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>{} : {} +>{} : {} + +var a = Object.create({}, {}); +>a : any +>Object.create({}, {}) : any +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>Object : ObjectConstructor +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap): any; } +>{} : object +>{} : {} +>{} : {} + diff --git a/tests/baselines/reference/objectCreationOfElementAccessExpression.js b/tests/baselines/reference/objectCreationOfElementAccessExpression.js index a1739ce0d8e..72645662e01 100644 --- a/tests/baselines/reference/objectCreationOfElementAccessExpression.js +++ b/tests/baselines/reference/objectCreationOfElementAccessExpression.js @@ -56,11 +56,16 @@ var foods2: MonsterFood[] = new PetFood[new IceCream('Mint chocolate chip') , Co //// [objectCreationOfElementAccessExpression.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Food = (function () { function Food(name) { this.name = name; diff --git a/tests/baselines/reference/objectIndexer.js b/tests/baselines/reference/objectIndexer.js index f5bf47e3475..c93172951e9 100644 --- a/tests/baselines/reference/objectIndexer.js +++ b/tests/baselines/reference/objectIndexer.js @@ -18,6 +18,7 @@ class Emitter { //// [objectIndexer.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var Emitter = (function () { function Emitter() { this.listeners = {}; diff --git a/tests/baselines/reference/objectLiteralErrors.errors.txt b/tests/baselines/reference/objectLiteralErrors.errors.txt index 03b4b74eacd..0e0db0b414f 100644 --- a/tests/baselines/reference/objectLiteralErrors.errors.txt +++ b/tests/baselines/reference/objectLiteralErrors.errors.txt @@ -73,7 +73,7 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(40,46) tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(40,46): error TS2300: Duplicate identifier 'a'. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(43,16): error TS2380: 'get' and 'set' accessor must have the same type. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(43,47): error TS2380: 'get' and 'set' accessor must have the same type. -tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(44,29): error TS2322: Type '4' is not assignable to type 'string'. +tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(44,22): error TS2322: Type '4' is not assignable to type 'string'. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,16): error TS2380: 'get' and 'set' accessor must have the same type. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,55): error TS2380: 'get' and 'set' accessor must have the same type. @@ -273,7 +273,7 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,55) ~ !!! error TS2380: 'get' and 'set' accessor must have the same type. var g2 = { get a() { return 4; }, set a(n: string) { } }; - ~ + ~~~~~~~~~ !!! error TS2322: Type '4' is not assignable to type 'string'. var g3 = { get a(): number { return undefined; }, set a(n: string) { } }; ~ diff --git a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt index 9d5ff7ea0a2..53abb5b7658 100644 --- a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt +++ b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ x: B; 0: A; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. Property '0' is incompatible with index signature. Type 'A' is not assignable to type 'B'. Property 'y' is missing in type 'A'. -tests/cases/compiler/objectLiteralIndexerErrors.ts(14,1): error TS2322: Type '{ 0: A; x: any; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +tests/cases/compiler/objectLiteralIndexerErrors.ts(14,1): error TS2322: Type '{ x: any; 0: A; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. Property '0' is incompatible with index signature. Type 'A' is not assignable to type 'B'. @@ -22,12 +22,12 @@ tests/cases/compiler/objectLiteralIndexerErrors.ts(14,1): error TS2322: Type '{ var o1: { [s: string]: A;[n: number]: B; } = { x: b, 0: a }; // both indexers are A ~~ -!!! error TS2322: Type '{ 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +!!! error TS2322: Type '{ x: B; 0: A; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. !!! error TS2322: Property '0' is incompatible with index signature. !!! error TS2322: Type 'A' is not assignable to type 'B'. !!! error TS2322: Property 'y' is missing in type 'A'. o1 = { x: c, 0: a }; // string indexer is any, number indexer is A ~~ -!!! error TS2322: Type '{ 0: A; x: any; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +!!! error TS2322: Type '{ x: any; 0: A; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. !!! error TS2322: Property '0' is incompatible with index signature. !!! error TS2322: Type 'A' is not assignable to type 'B'. \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralIndexers.types b/tests/baselines/reference/objectLiteralIndexers.types index 9e3aa4bac49..ef242fd1fe3 100644 --- a/tests/baselines/reference/objectLiteralIndexers.types +++ b/tests/baselines/reference/objectLiteralIndexers.types @@ -31,23 +31,23 @@ var o1: { [s: string]: A;[n: number]: B; } = { x: a, 0: b }; // string indexer i >A : A >n : number >B : B ->{ x: a, 0: b } : { 0: B; x: A; } +>{ x: a, 0: b } : { x: A; 0: B; } >x : A >a : A >b : B o1 = { x: b, 0: c }; // both indexers are any ->o1 = { x: b, 0: c } : { 0: any; x: B; } +>o1 = { x: b, 0: c } : { x: B; 0: any; } >o1 : { [s: string]: A; [n: number]: B; } ->{ x: b, 0: c } : { 0: any; x: B; } +>{ x: b, 0: c } : { x: B; 0: any; } >x : B >b : B >c : any o1 = { x: c, 0: b }; // string indexer is any, number indexer is B ->o1 = { x: c, 0: b } : { 0: B; x: any; } +>o1 = { x: c, 0: b } : { x: any; 0: B; } >o1 : { [s: string]: A; [n: number]: B; } ->{ x: c, 0: b } : { 0: B; x: any; } +>{ x: c, 0: b } : { x: any; 0: B; } >x : any >c : any >b : B diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt index 6f405facceb..c0e6e10d8de 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(4,43): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(6,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(6,72): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'. Types of property 'id' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(8,5): error TS2345: Argument of type '{ name: string; id: number; }' is not assignable to parameter of type '{ name: string; id: boolean; }'. @@ -18,7 +18,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. var person1: { name, id }; // ok function foo(name: string, id: number): { id: string, name: number } { return { name, id }; } // error - ~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'. !!! error TS2322: Types of property 'id' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt index 92750fd29a0..6b227fce710 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(4,43): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(5,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(5,72): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'. Types of property 'name' are incompatible. Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(8,5): error TS2322: Type '{ name: number; id: string; }' is not assignable to type '{ name: string; id: number; }'. @@ -17,7 +17,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. function bar(name: string, id: number): { name: number, id: string } { return { name, id }; } // error - ~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'. !!! error TS2322: Types of property 'name' are incompatible. !!! error TS2322: Type 'string' is not assignable to type 'number'. diff --git a/tests/baselines/reference/objectRest.js b/tests/baselines/reference/objectRest.js index 48a1bf8daf8..3576ffb286c 100644 --- a/tests/baselines/reference/objectRest.js +++ b/tests/baselines/reference/objectRest.js @@ -29,15 +29,22 @@ class Removable { removed: string; remainder: string; } +interface I { + m(): void; + removed: string; + remainder: string; +} var removable = new Removable(); var { removed, ...removableRest } = removable; +var i: I = removable; +var { removed, ...removableRest2 } = i; let computed = 'b'; let computed2 = 'a'; var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o; ({ [computed]: stillNotGreat, [computed2]: soSo, ...o } = o); -var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject['anythingGoes']; +var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes; //// [objectRest.js] @@ -74,12 +81,14 @@ class Removable { } var removable = new Removable(); var { removed } = removable, removableRest = __rest(removable, ["removed"]); +var i = removable; +var { removed } = i, removableRest2 = __rest(i, ["removed"]); let computed = 'b'; let computed2 = 'a'; var _g = computed, stillNotGreat = o[_g], _h = computed2, soSo = o[_h], o = __rest(o, [typeof _g === "symbol" ? _g : _g + "", typeof _h === "symbol" ? _h : _h + ""]); (_j = computed, stillNotGreat = o[_j], _k = computed2, soSo = o[_k], o = __rest(o, [typeof _j === "symbol" ? _j : _j + "", typeof _k === "symbol" ? _k : _k + ""])); var noContextualType = (_a) => { var { aNumber = 12 } = _a, notEmptyObject = __rest(_a, ["aNumber"]); - return aNumber + notEmptyObject['anythingGoes']; + return aNumber + notEmptyObject.anythingGoes; }; var _d, _f, _j, _k; diff --git a/tests/baselines/reference/objectRest.symbols b/tests/baselines/reference/objectRest.symbols index 46309392135..41226bd99fc 100644 --- a/tests/baselines/reference/objectRest.symbols +++ b/tests/baselines/reference/objectRest.symbols @@ -1,42 +1,42 @@ === tests/cases/conformance/types/rest/objectRest.ts === var o = { a: 1, b: 'no' } ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) >a : Symbol(a, Decl(objectRest.ts, 0, 9)) >b : Symbol(b, Decl(objectRest.ts, 0, 15)) var { ...clone } = o; >clone : Symbol(clone, Decl(objectRest.ts, 1, 5)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) var { a, ...justB } = o; >a : Symbol(a, Decl(objectRest.ts, 2, 5), Decl(objectRest.ts, 3, 5)) >justB : Symbol(justB, Decl(objectRest.ts, 2, 8)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) var { a, b: renamed, ...empty } = o; >a : Symbol(a, Decl(objectRest.ts, 2, 5), Decl(objectRest.ts, 3, 5)) >b : Symbol(b, Decl(objectRest.ts, 0, 15)) >renamed : Symbol(renamed, Decl(objectRest.ts, 3, 8), Decl(objectRest.ts, 4, 5), Decl(objectRest.ts, 5, 5), Decl(objectRest.ts, 9, 5)) >empty : Symbol(empty, Decl(objectRest.ts, 3, 20)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) var { ['b']: renamed, ...justA } = o; >'b' : Symbol(renamed, Decl(objectRest.ts, 3, 8), Decl(objectRest.ts, 4, 5), Decl(objectRest.ts, 5, 5), Decl(objectRest.ts, 9, 5)) >renamed : Symbol(renamed, Decl(objectRest.ts, 3, 8), Decl(objectRest.ts, 4, 5), Decl(objectRest.ts, 5, 5), Decl(objectRest.ts, 9, 5)) >justA : Symbol(justA, Decl(objectRest.ts, 4, 21), Decl(objectRest.ts, 5, 19), Decl(objectRest.ts, 6, 31)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) var { 'b': renamed, ...justA } = o; >renamed : Symbol(renamed, Decl(objectRest.ts, 3, 8), Decl(objectRest.ts, 4, 5), Decl(objectRest.ts, 5, 5), Decl(objectRest.ts, 9, 5)) >justA : Symbol(justA, Decl(objectRest.ts, 4, 21), Decl(objectRest.ts, 5, 19), Decl(objectRest.ts, 6, 31)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) var { b: { '0': n, '1': oooo }, ...justA } = o; >b : Symbol(b, Decl(objectRest.ts, 0, 15)) >n : Symbol(n, Decl(objectRest.ts, 6, 10)) >oooo : Symbol(oooo, Decl(objectRest.ts, 6, 18)) >justA : Symbol(justA, Decl(objectRest.ts, 4, 21), Decl(objectRest.ts, 5, 19), Decl(objectRest.ts, 6, 31)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) let o2 = { c: 'terrible idea?', d: 'yes' }; >o2 : Symbol(o2, Decl(objectRest.ts, 8, 3)) @@ -138,41 +138,63 @@ class Removable { remainder: string; >remainder : Symbol(Removable.remainder, Decl(objectRest.ts, 27, 20)) } +interface I { +>I : Symbol(I, Decl(objectRest.ts, 29, 1)) + + m(): void; +>m : Symbol(I.m, Decl(objectRest.ts, 30, 13)) + + removed: string; +>removed : Symbol(I.removed, Decl(objectRest.ts, 31, 14)) + + remainder: string; +>remainder : Symbol(I.remainder, Decl(objectRest.ts, 32, 20)) +} var removable = new Removable(); ->removable : Symbol(removable, Decl(objectRest.ts, 30, 3)) +>removable : Symbol(removable, Decl(objectRest.ts, 35, 3)) >Removable : Symbol(Removable, Decl(objectRest.ts, 18, 35)) var { removed, ...removableRest } = removable; ->removed : Symbol(removed, Decl(objectRest.ts, 31, 5)) ->removableRest : Symbol(removableRest, Decl(objectRest.ts, 31, 14)) ->removable : Symbol(removable, Decl(objectRest.ts, 30, 3)) +>removed : Symbol(removed, Decl(objectRest.ts, 36, 5), Decl(objectRest.ts, 38, 5)) +>removableRest : Symbol(removableRest, Decl(objectRest.ts, 36, 14)) +>removable : Symbol(removable, Decl(objectRest.ts, 35, 3)) + +var i: I = removable; +>i : Symbol(i, Decl(objectRest.ts, 37, 3)) +>I : Symbol(I, Decl(objectRest.ts, 29, 1)) +>removable : Symbol(removable, Decl(objectRest.ts, 35, 3)) + +var { removed, ...removableRest2 } = i; +>removed : Symbol(removed, Decl(objectRest.ts, 36, 5), Decl(objectRest.ts, 38, 5)) +>removableRest2 : Symbol(removableRest2, Decl(objectRest.ts, 38, 14)) +>i : Symbol(i, Decl(objectRest.ts, 37, 3)) let computed = 'b'; ->computed : Symbol(computed, Decl(objectRest.ts, 33, 3)) +>computed : Symbol(computed, Decl(objectRest.ts, 40, 3)) let computed2 = 'a'; ->computed2 : Symbol(computed2, Decl(objectRest.ts, 34, 3)) +>computed2 : Symbol(computed2, Decl(objectRest.ts, 41, 3)) var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o; ->computed : Symbol(computed, Decl(objectRest.ts, 33, 3)) ->stillNotGreat : Symbol(stillNotGreat, Decl(objectRest.ts, 35, 5)) ->computed2 : Symbol(computed2, Decl(objectRest.ts, 34, 3)) ->soSo : Symbol(soSo, Decl(objectRest.ts, 35, 32)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>computed : Symbol(computed, Decl(objectRest.ts, 40, 3)) +>stillNotGreat : Symbol(stillNotGreat, Decl(objectRest.ts, 42, 5)) +>computed2 : Symbol(computed2, Decl(objectRest.ts, 41, 3)) +>soSo : Symbol(soSo, Decl(objectRest.ts, 42, 32)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) ({ [computed]: stillNotGreat, [computed2]: soSo, ...o } = o); ->computed : Symbol(computed, Decl(objectRest.ts, 33, 3)) ->stillNotGreat : Symbol(stillNotGreat, Decl(objectRest.ts, 35, 5)) ->computed2 : Symbol(computed2, Decl(objectRest.ts, 34, 3)) ->soSo : Symbol(soSo, Decl(objectRest.ts, 35, 32)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>computed : Symbol(computed, Decl(objectRest.ts, 40, 3)) +>stillNotGreat : Symbol(stillNotGreat, Decl(objectRest.ts, 42, 5)) +>computed2 : Symbol(computed2, Decl(objectRest.ts, 41, 3)) +>soSo : Symbol(soSo, Decl(objectRest.ts, 42, 32)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 42, 51)) -var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject['anythingGoes']; ->noContextualType : Symbol(noContextualType, Decl(objectRest.ts, 38, 3)) ->aNumber : Symbol(aNumber, Decl(objectRest.ts, 38, 25)) ->notEmptyObject : Symbol(notEmptyObject, Decl(objectRest.ts, 38, 39)) ->aNumber : Symbol(aNumber, Decl(objectRest.ts, 38, 25)) ->notEmptyObject : Symbol(notEmptyObject, Decl(objectRest.ts, 38, 39)) +var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes; +>noContextualType : Symbol(noContextualType, Decl(objectRest.ts, 45, 3)) +>aNumber : Symbol(aNumber, Decl(objectRest.ts, 45, 25)) +>notEmptyObject : Symbol(notEmptyObject, Decl(objectRest.ts, 45, 39)) +>aNumber : Symbol(aNumber, Decl(objectRest.ts, 45, 25)) +>notEmptyObject : Symbol(notEmptyObject, Decl(objectRest.ts, 45, 39)) diff --git a/tests/baselines/reference/objectRest.types b/tests/baselines/reference/objectRest.types index 1dc05741713..2fff9a3c729 100644 --- a/tests/baselines/reference/objectRest.types +++ b/tests/baselines/reference/objectRest.types @@ -158,6 +158,18 @@ class Removable { remainder: string; >remainder : string } +interface I { +>I : I + + m(): void; +>m : () => void + + removed: string; +>removed : string + + remainder: string; +>remainder : string +} var removable = new Removable(); >removable : Removable >new Removable() : Removable @@ -168,6 +180,16 @@ var { removed, ...removableRest } = removable; >removableRest : { both: number; remainder: string; } >removable : Removable +var i: I = removable; +>i : I +>I : I +>removable : Removable + +var { removed, ...removableRest2 } = i; +>removed : string +>removableRest2 : { m(): void; remainder: string; } +>i : I + let computed = 'b'; >computed : string >'b' : "b" @@ -195,15 +217,15 @@ var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o; >o : { a: number; b: string; } >o : { a: number; b: string; } -var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject['anythingGoes']; +var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes; >noContextualType : ({aNumber, ...notEmptyObject}: { [x: string]: any; aNumber?: number; }) => any ->({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject['anythingGoes'] : ({aNumber, ...notEmptyObject}: { [x: string]: any; aNumber?: number; }) => any +>({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes : ({aNumber, ...notEmptyObject}: { [x: string]: any; aNumber?: number; }) => any >aNumber : number >12 : 12 >notEmptyObject : { [x: string]: any; } ->aNumber + notEmptyObject['anythingGoes'] : any +>aNumber + notEmptyObject.anythingGoes : any >aNumber : number ->notEmptyObject['anythingGoes'] : any +>notEmptyObject.anythingGoes : any >notEmptyObject : { [x: string]: any; } ->'anythingGoes' : "anythingGoes" +>anythingGoes : any diff --git a/tests/baselines/reference/objectRest2.js b/tests/baselines/reference/objectRest2.js index 6abff9e56a1..e46d22db80a 100644 --- a/tests/baselines/reference/objectRest2.js +++ b/tests/baselines/reference/objectRest2.js @@ -15,14 +15,6 @@ rootConnection('test'); //// [objectRest2.js] -var __assign = (this && this.__assign) || Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; -}; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } @@ -35,7 +27,7 @@ function rootConnection(name) { return { resolve: (context, args) => __awaiter(this, void 0, void 0, function* () { const { objects } = yield { objects: 12 }; - return __assign({}, connectionFromArray(objects, args)); + return Object.assign({}, connectionFromArray(objects, args)); }) }; } diff --git a/tests/baselines/reference/objectRestForOf.js b/tests/baselines/reference/objectRestForOf.js index fd81f77512e..7ff72db06e5 100644 --- a/tests/baselines/reference/objectRestForOf.js +++ b/tests/baselines/reference/objectRestForOf.js @@ -15,14 +15,6 @@ for (const norest of array.map(a => ({ ...a, x: 'a string' }))) { //// [objectRestForOf.js] -var __assign = (this && this.__assign) || Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; -}; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) @@ -43,6 +35,7 @@ for (let _b of array) { ({ x: xx } = _b, rrestOff = __rest(_b, ["x"])); [xx, rrestOff]; } -for (const norest of array.map(a => (__assign({}, a, { x: 'a string' })))) { +for (const norest of array.map(a => (Object.assign({}, a, { x: 'a string' })))) { [norest.x, norest.y]; + // x is now a string. who knows why. } diff --git a/tests/baselines/reference/objectRestNegative.errors.txt b/tests/baselines/reference/objectRestNegative.errors.txt index 6e65af4bdc1..56de8aaccb6 100644 --- a/tests/baselines/reference/objectRestNegative.errors.txt +++ b/tests/baselines/reference/objectRestNegative.errors.txt @@ -7,10 +7,9 @@ tests/cases/conformance/types/rest/objectRestNegative.ts(11,30): error TS7008: M tests/cases/conformance/types/rest/objectRestNegative.ts(11,33): error TS7008: Member 'y' implicitly has an 'any' type. tests/cases/conformance/types/rest/objectRestNegative.ts(12,17): error TS2700: Rest types may only be created from object types. tests/cases/conformance/types/rest/objectRestNegative.ts(17,9): error TS2701: The target of an object rest assignment must be a variable or a property access. -tests/cases/conformance/types/rest/objectRestNegative.ts(19,90): error TS2339: Property 'anythingGoes' does not exist on type '{ [x: string]: any; }'. -==== tests/cases/conformance/types/rest/objectRestNegative.ts (8 errors) ==== +==== tests/cases/conformance/types/rest/objectRestNegative.ts (7 errors) ==== let o = { a: 1, b: 'no' }; var { ...mustBeLast, a } = o; ~~~~~~~~~~ @@ -44,8 +43,4 @@ tests/cases/conformance/types/rest/objectRestNegative.ts(19,90): error TS2339: P ({a, ...rest.b + rest.b} = o); ~~~~~~~~~~~~~~~ !!! error TS2701: The target of an object rest assignment must be a variable or a property access. - - var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes; - ~~~~~~~~~~~~ -!!! error TS2339: Property 'anythingGoes' does not exist on type '{ [x: string]: any; }'. \ No newline at end of file diff --git a/tests/baselines/reference/objectRestNegative.js b/tests/baselines/reference/objectRestNegative.js index 19559e865f2..915e0a0e867 100644 --- a/tests/baselines/reference/objectRestNegative.js +++ b/tests/baselines/reference/objectRestNegative.js @@ -16,8 +16,6 @@ function generic(t: T) { let rest: { b: string } ({a, ...rest.b + rest.b} = o); - -var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes; //// [objectRestNegative.js] @@ -44,7 +42,3 @@ function generic(t) { } var rest; (a = o.a, o, rest.b + rest.b = __rest(o, ["a"])); -var noContextualType = function (_a) { - var _b = _a.aNumber, aNumber = _b === void 0 ? 12 : _b, notEmptyObject = __rest(_a, ["aNumber"]); - return aNumber + notEmptyObject.anythingGoes; -}; diff --git a/tests/baselines/reference/objectSpread.js b/tests/baselines/reference/objectSpread.js index 4305e17ab31..2bc3b9e11bd 100644 --- a/tests/baselines/reference/objectSpread.js +++ b/tests/baselines/reference/objectSpread.js @@ -78,7 +78,8 @@ let computedAfter: { a: number, b: string, "at the end": number } = // shortcut syntax let a = 12; let shortCutted: { a: number, b: string } = { ...o, a } - +// non primitive +let spreadNonPrimitive = { ...{}}; //// [objectSpread.js] @@ -148,4 +149,6 @@ var computedAfter = __assign({}, o, (_c = { b: 'yeah' }, _c['at the end'] = 14, // shortcut syntax var a = 12; var shortCutted = __assign({}, o, { a: a }); +// non primitive +var spreadNonPrimitive = __assign({}, {}); var _a, _b, _c; diff --git a/tests/baselines/reference/objectSpread.symbols b/tests/baselines/reference/objectSpread.symbols index 35c10faa9c0..1ec2520e166 100644 --- a/tests/baselines/reference/objectSpread.symbols +++ b/tests/baselines/reference/objectSpread.symbols @@ -316,4 +316,7 @@ let shortCutted: { a: number, b: string } = { ...o, a } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) >a : Symbol(a, Decl(objectSpread.ts, 78, 51)) +// non primitive +let spreadNonPrimitive = { ...{}}; +>spreadNonPrimitive : Symbol(spreadNonPrimitive, Decl(objectSpread.ts, 80, 3)) diff --git a/tests/baselines/reference/objectSpread.types b/tests/baselines/reference/objectSpread.types index a571bd0bb63..950dab43465 100644 --- a/tests/baselines/reference/objectSpread.types +++ b/tests/baselines/reference/objectSpread.types @@ -407,4 +407,10 @@ let shortCutted: { a: number, b: string } = { ...o, a } >o : { a: number; b: string; } >a : number +// non primitive +let spreadNonPrimitive = { ...{}}; +>spreadNonPrimitive : {} +>{ ...{}} : {} +>{} : object +>{} : {} diff --git a/tests/baselines/reference/objectSpreadNegative.errors.txt b/tests/baselines/reference/objectSpreadNegative.errors.txt index 17f07bc06a2..d9106d651a3 100644 --- a/tests/baselines/reference/objectSpreadNegative.errors.txt +++ b/tests/baselines/reference/objectSpreadNegative.errors.txt @@ -14,11 +14,12 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(37,19): error TS269 tests/cases/conformance/types/spread/objectSpreadNegative.ts(42,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. tests/cases/conformance/types/spread/objectSpreadNegative.ts(46,12): error TS2339: Property 'b' does not exist on type '{}'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(52,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(56,14): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(59,14): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(57,11): error TS2339: Property 'a' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(61,14): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(64,14): error TS2698: Spread types may only be created from object types. -==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (15 errors) ==== +==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (16 errors) ==== let o = { a: 1, b: 'no' } /// private propagates @@ -101,6 +102,13 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(59,14): error TS269 ~ !!! error TS2339: Property 'm' does not exist on type '{ p: number; }'. + // non primitive + let obj: object = { a: 123 }; + let spreadObj = { ...obj }; + spreadObj.a; // error 'a' is not in {} + ~ +!!! error TS2339: Property 'a' does not exist on type '{}'. + // generics function f(t: T, u: U) { return { ...t, ...u, id: 'id' }; diff --git a/tests/baselines/reference/objectSpreadNegative.js b/tests/baselines/reference/objectSpreadNegative.js index dff84355370..fd834b6ef9c 100644 --- a/tests/baselines/reference/objectSpreadNegative.js +++ b/tests/baselines/reference/objectSpreadNegative.js @@ -52,6 +52,11 @@ let c: C = new C() let spreadC = { ...c } spreadC.m(); // error 'm' is not in '{ ... c }' +// non primitive +let obj: object = { a: 123 }; +let spreadObj = { ...obj }; +spreadObj.a; // error 'a' is not in {} + // generics function f(t: T, u: U) { return { ...t, ...u, id: 'id' }; @@ -132,6 +137,10 @@ var C = (function () { var c = new C(); var spreadC = __assign({}, c); spreadC.m(); // error 'm' is not in '{ ... c }' +// non primitive +var obj = { a: 123 }; +var spreadObj = __assign({}, obj); +spreadObj.a; // error 'a' is not in {} // generics function f(t, u) { return __assign({}, t, u, { id: 'id' }); diff --git a/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.js b/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.js index 17045d65af0..22a852e156c 100644 --- a/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.js +++ b/tests/baselines/reference/objectTypeHidingMembersOfExtendedObject.js @@ -55,11 +55,16 @@ var b: { var r4: void = b.valueOf(); //// [objectTypeHidingMembersOfExtendedObject.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -68,7 +73,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types b/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types index e050d33024c..1f34c4fafac 100644 --- a/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types +++ b/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types @@ -267,7 +267,7 @@ var r13 = i[-01] >01 : 1 var a: { ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } "0.1": void; ".1": Object; @@ -289,19 +289,19 @@ var a: { var r1 = a['0.1']; >r1 : void >a['0.1'] : void ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'0.1' : "0.1" var r2 = a['.1']; >r2 : Object >a['.1'] : Object ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'.1' : ".1" var r3 = a['1']; >r3 : number >a['1'] : number ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'1' : "1" var r3 = c[1]; @@ -313,7 +313,7 @@ var r3 = c[1]; var r4 = a['1.']; >r4 : string >a['1.'] : string ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'1.' : "1." var r3 = c[1.]; // same as indexing by 1 when done numerically @@ -325,13 +325,13 @@ var r3 = c[1.]; // same as indexing by 1 when done numerically var r5 = a['1..']; >r5 : boolean >a['1..'] : boolean ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'1..' : "1.." var r6 = a['1.0']; >r6 : Date >a['1.0'] : Date ->a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } +>a : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'1.0' : "1.0" var r3 = c[1.0]; // same as indexing by 1 when done numerically @@ -394,8 +394,8 @@ var r13 = i[-01] >01 : 1 var b = { ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } ->{ "0.1": null, ".1": new Object(), "1": 1, "1.": "", "1..": true, "1.0": new Date(), "-1.0": /123/, "-1": Date} : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>{ "0.1": null, ".1": new Object(), "1": 1, "1.": "", "1..": true, "1.0": new Date(), "-1.0": /123/, "-1": Date} : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } "0.1": null, >null : void @@ -429,19 +429,19 @@ var b = { var r1 = b['0.1']; >r1 : void >b['0.1'] : void ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'0.1' : "0.1" var r2 = b['.1']; >r2 : Object >b['.1'] : Object ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'.1' : ".1" var r3 = b['1']; >r3 : number >b['1'] : number ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'1' : "1" var r3 = c[1]; @@ -453,7 +453,7 @@ var r3 = c[1]; var r4 = b['1.']; >r4 : string >b['1.'] : string ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'1.' : "1." var r3 = c[1.]; // same as indexing by 1 when done numerically @@ -465,13 +465,13 @@ var r3 = c[1.]; // same as indexing by 1 when done numerically var r5 = b['1..']; >r5 : boolean >b['1..'] : boolean ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'1..' : "1.." var r6 = b['1.0']; >r6 : Date >b['1.0'] : Date ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>b : { "0.1": void; ".1": Object; "1": number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'1.0' : "1.0" var r3 = c[1.0]; // same as indexing by 1 when done numerically diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.js b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.js index e82cef9bdd6..d7db8d271bd 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.js +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.js @@ -124,11 +124,16 @@ function foo16(x: any) { } //// [objectTypesIdentityWithNumericIndexers1.js] // object types are identical structurally -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -147,14 +152,14 @@ var C = (function () { var PA = (function (_super) { __extends(PA, _super); function PA() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PA; }(A)); var PB = (function (_super) { __extends(PB, _super); function PB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PB; }(B)); diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.js b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.js index abcea113670..6af5cb75146 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.js +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers2.js @@ -127,11 +127,16 @@ function foo16(x: any) { } //// [objectTypesIdentityWithNumericIndexers2.js] // object types are identical structurally -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -140,7 +145,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -162,14 +167,14 @@ var C = (function () { var PA = (function (_super) { __extends(PA, _super); function PA() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PA; }(A)); var PB = (function (_super) { __extends(PB, _super); function PB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PB; }(B)); diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.js b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.js index f5aeb177472..0441cc85dcf 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.js +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.js @@ -124,11 +124,16 @@ function foo16(x: any) { } //// [objectTypesIdentityWithNumericIndexers3.js] // object types are identical structurally -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -147,14 +152,14 @@ var C = (function () { var PA = (function (_super) { __extends(PA, _super); function PA() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PA; }(A)); var PB = (function (_super) { __extends(PB, _super); function PB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PB; }(B)); diff --git a/tests/baselines/reference/objectTypesIdentityWithPrivates.js b/tests/baselines/reference/objectTypesIdentityWithPrivates.js index 3946027063f..294d879ce24 100644 --- a/tests/baselines/reference/objectTypesIdentityWithPrivates.js +++ b/tests/baselines/reference/objectTypesIdentityWithPrivates.js @@ -122,11 +122,16 @@ function foo16(x: any) { } //// [objectTypesIdentityWithPrivates.js] // object types are identical structurally -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -145,14 +150,14 @@ var C = (function () { var PA = (function (_super) { __extends(PA, _super); function PA() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PA; }(A)); var PB = (function (_super) { __extends(PB, _super); function PB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PB; }(B)); diff --git a/tests/baselines/reference/objectTypesIdentityWithPrivates2.js b/tests/baselines/reference/objectTypesIdentityWithPrivates2.js index 9cae6960a2e..d151af230f6 100644 --- a/tests/baselines/reference/objectTypesIdentityWithPrivates2.js +++ b/tests/baselines/reference/objectTypesIdentityWithPrivates2.js @@ -40,11 +40,16 @@ function foo6(x: any): any { } //// [objectTypesIdentityWithPrivates2.js] // object types are identical structurally -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -53,7 +58,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/objectTypesIdentityWithPrivates3.js b/tests/baselines/reference/objectTypesIdentityWithPrivates3.js index 68754a583aa..7fc23f7255c 100644 --- a/tests/baselines/reference/objectTypesIdentityWithPrivates3.js +++ b/tests/baselines/reference/objectTypesIdentityWithPrivates3.js @@ -26,11 +26,16 @@ var c3: C3; c3; // Should fail (private x originates in the same declaration, but different types) //// [objectTypesIdentityWithPrivates3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1() { } @@ -39,7 +44,7 @@ var C1 = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(C1)); @@ -53,7 +58,7 @@ var C3 = (function () { var C4 = (function (_super) { __extends(C4, _super); function C4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C4; }(C3)); diff --git a/tests/baselines/reference/objectTypesIdentityWithStringIndexers.js b/tests/baselines/reference/objectTypesIdentityWithStringIndexers.js index b0211bbbba7..9bf7aca342b 100644 --- a/tests/baselines/reference/objectTypesIdentityWithStringIndexers.js +++ b/tests/baselines/reference/objectTypesIdentityWithStringIndexers.js @@ -124,11 +124,16 @@ function foo16(x: any) { } //// [objectTypesIdentityWithStringIndexers.js] // object types are identical structurally -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -147,14 +152,14 @@ var C = (function () { var PA = (function (_super) { __extends(PA, _super); function PA() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PA; }(A)); var PB = (function (_super) { __extends(PB, _super); function PB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PB; }(B)); diff --git a/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.js b/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.js index 00d7d1e81d8..f8aa1127e4e 100644 --- a/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.js +++ b/tests/baselines/reference/objectTypesIdentityWithStringIndexers2.js @@ -127,11 +127,16 @@ function foo16(x: any) { } //// [objectTypesIdentityWithStringIndexers2.js] // object types are identical structurally -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -140,7 +145,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -162,14 +167,14 @@ var C = (function () { var PA = (function (_super) { __extends(PA, _super); function PA() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PA; }(A)); var PB = (function (_super) { __extends(PB, _super); function PB() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return PB; }(B)); diff --git a/tests/baselines/reference/operatorAddNullUndefined.errors.txt b/tests/baselines/reference/operatorAddNullUndefined.errors.txt index 269ee0a5166..871ef3fc98f 100644 --- a/tests/baselines/reference/operatorAddNullUndefined.errors.txt +++ b/tests/baselines/reference/operatorAddNullUndefined.errors.txt @@ -1,32 +1,68 @@ -tests/cases/compiler/operatorAddNullUndefined.ts(2,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/compiler/operatorAddNullUndefined.ts(3,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/compiler/operatorAddNullUndefined.ts(4,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/compiler/operatorAddNullUndefined.ts(5,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(2,10): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(2,17): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(3,10): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(3,17): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(4,10): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(4,22): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(5,10): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(5,22): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(6,14): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(7,14): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(8,10): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(9,10): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(14,11): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(15,11): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/operatorAddNullUndefined.ts(16,17): error TS2531: Object is possibly 'null'. +tests/cases/compiler/operatorAddNullUndefined.ts(17,17): error TS2532: Object is possibly 'undefined'. -==== tests/cases/compiler/operatorAddNullUndefined.ts (4 errors) ==== +==== tests/cases/compiler/operatorAddNullUndefined.ts (16 errors) ==== enum E { x } var x1 = null + null; - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var x2 = null + undefined; - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x3 = undefined + null; - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var x4 = undefined + undefined; - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x5 = 1 + null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. var x6 = 1 + undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x7 = null + 1; + ~~~~ +!!! error TS2531: Object is possibly 'null'. var x8 = undefined + 1; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x9 = "test" + null; var x10 = "test" + undefined; var x11 = null + "test"; var x12 = undefined + "test"; var x13 = null + E.x + ~~~~ +!!! error TS2531: Object is possibly 'null'. var x14 = undefined + E.x + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var x15 = E.x + null - var x16 = E.x + undefined \ No newline at end of file + ~~~~ +!!! error TS2531: Object is possibly 'null'. + var x16 = E.x + undefined + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/optionalConstructorArgInSuper.js b/tests/baselines/reference/optionalConstructorArgInSuper.js index e460ab3fb15..2412ce67ffe 100644 --- a/tests/baselines/reference/optionalConstructorArgInSuper.js +++ b/tests/baselines/reference/optionalConstructorArgInSuper.js @@ -11,11 +11,16 @@ d2.foo(); //// [optionalConstructorArgInSuper.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(opt) { } @@ -25,7 +30,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); diff --git a/tests/baselines/reference/optionalMethods.js b/tests/baselines/reference/optionalMethods.js index 28ed0bcd76e..a3685175f66 100644 --- a/tests/baselines/reference/optionalMethods.js +++ b/tests/baselines/reference/optionalMethods.js @@ -58,11 +58,16 @@ class Derived extends Base { //// [optionalMethods.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function test1(x) { x.a; x.b; @@ -109,7 +114,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.a = 1; return _this; } diff --git a/tests/baselines/reference/optionalParamArgsTest.js b/tests/baselines/reference/optionalParamArgsTest.js index 1b603898aa6..5c8503a9bef 100644 --- a/tests/baselines/reference/optionalParamArgsTest.js +++ b/tests/baselines/reference/optionalParamArgsTest.js @@ -125,11 +125,16 @@ fnOpt2(1, [2, 3], [1], true); //// [optionalParamArgsTest.js] // Optional parameter and default argument tests -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // test basic configurations var C1 = (function () { function C1(v, p) { diff --git a/tests/baselines/reference/optionalParamInOverride.js b/tests/baselines/reference/optionalParamInOverride.js index 1312a89502a..601cb4d6f1e 100644 --- a/tests/baselines/reference/optionalParamInOverride.js +++ b/tests/baselines/reference/optionalParamInOverride.js @@ -8,11 +8,16 @@ class Y extends Z { //// [optionalParamInOverride.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Z = (function () { function Z() { } @@ -22,7 +27,7 @@ var Z = (function () { var Y = (function (_super) { __extends(Y, _super); function Y() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Y.prototype.func = function (value) { }; return Y; diff --git a/tests/baselines/reference/optionalParameterProperty.js b/tests/baselines/reference/optionalParameterProperty.js index f9b9ecaf990..fc288d09767 100644 --- a/tests/baselines/reference/optionalParameterProperty.js +++ b/tests/baselines/reference/optionalParameterProperty.js @@ -12,11 +12,16 @@ class D extends C { //// [optionalParameterProperty.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } diff --git a/tests/baselines/reference/optionalParameterRetainsNull.js b/tests/baselines/reference/optionalParameterRetainsNull.js new file mode 100644 index 00000000000..b8fb2c12350 --- /dev/null +++ b/tests/baselines/reference/optionalParameterRetainsNull.js @@ -0,0 +1,14 @@ +//// [optionalParameterRetainsNull.ts] +interface Bar { bar: number; foo: object | null; } + +let a = { + test (a: K, b?: Bar[K] | null) { } +}; +a.test("bar", null); // ok, null is assignable to number | null | undefined + + +//// [optionalParameterRetainsNull.js] +var a = { + test: function (a, b) { } +}; +a.test("bar", null); // ok, null is assignable to number | null | undefined diff --git a/tests/baselines/reference/optionalParameterRetainsNull.symbols b/tests/baselines/reference/optionalParameterRetainsNull.symbols new file mode 100644 index 00000000000..95786c1bdca --- /dev/null +++ b/tests/baselines/reference/optionalParameterRetainsNull.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/optionalParameterRetainsNull.ts === +interface Bar { bar: number; foo: object | null; } +>Bar : Symbol(Bar, Decl(optionalParameterRetainsNull.ts, 0, 0)) +>bar : Symbol(Bar.bar, Decl(optionalParameterRetainsNull.ts, 0, 15)) +>foo : Symbol(Bar.foo, Decl(optionalParameterRetainsNull.ts, 0, 29)) + +let a = { +>a : Symbol(a, Decl(optionalParameterRetainsNull.ts, 2, 3)) + + test (a: K, b?: Bar[K] | null) { } +>test : Symbol(test, Decl(optionalParameterRetainsNull.ts, 2, 9)) +>K : Symbol(K, Decl(optionalParameterRetainsNull.ts, 3, 7)) +>Bar : Symbol(Bar, Decl(optionalParameterRetainsNull.ts, 0, 0)) +>a : Symbol(a, Decl(optionalParameterRetainsNull.ts, 3, 29)) +>K : Symbol(K, Decl(optionalParameterRetainsNull.ts, 3, 7)) +>b : Symbol(b, Decl(optionalParameterRetainsNull.ts, 3, 34)) +>Bar : Symbol(Bar, Decl(optionalParameterRetainsNull.ts, 0, 0)) +>K : Symbol(K, Decl(optionalParameterRetainsNull.ts, 3, 7)) + +}; +a.test("bar", null); // ok, null is assignable to number | null | undefined +>a.test : Symbol(test, Decl(optionalParameterRetainsNull.ts, 2, 9)) +>a : Symbol(a, Decl(optionalParameterRetainsNull.ts, 2, 3)) +>test : Symbol(test, Decl(optionalParameterRetainsNull.ts, 2, 9)) + diff --git a/tests/baselines/reference/optionalParameterRetainsNull.types b/tests/baselines/reference/optionalParameterRetainsNull.types new file mode 100644 index 00000000000..30b7d61f76c --- /dev/null +++ b/tests/baselines/reference/optionalParameterRetainsNull.types @@ -0,0 +1,31 @@ +=== tests/cases/compiler/optionalParameterRetainsNull.ts === +interface Bar { bar: number; foo: object | null; } +>Bar : Bar +>bar : number +>foo : object | null +>null : null + +let a = { +>a : { test(a: K, b?: Bar[K] | null | undefined): void; } +>{ test (a: K, b?: Bar[K] | null) { }} : { test(a: K, b?: Bar[K] | null | undefined): void; } + + test (a: K, b?: Bar[K] | null) { } +>test : (a: K, b?: Bar[K] | null | undefined) => void +>K : K +>Bar : Bar +>a : K +>K : K +>b : Bar[K] | null | undefined +>Bar : Bar +>K : K +>null : null + +}; +a.test("bar", null); // ok, null is assignable to number | null | undefined +>a.test("bar", null) : void +>a.test : (a: K, b?: Bar[K] | null | undefined) => void +>a : { test(a: K, b?: Bar[K] | null | undefined): void; } +>test : (a: K, b?: Bar[K] | null | undefined) => void +>"bar" : "bar" +>null : null + diff --git a/tests/baselines/reference/outFilerootDirModuleNamesAmd.js b/tests/baselines/reference/outFilerootDirModuleNamesAmd.js index 5b99f76a5b9..91665513153 100644 --- a/tests/baselines/reference/outFilerootDirModuleNamesAmd.js +++ b/tests/baselines/reference/outFilerootDirModuleNamesAmd.js @@ -13,15 +13,15 @@ export default function foo() { new Foo(); } //// [output.js] define("b", ["require", "exports", "a"], function (require, exports, a_1) { "use strict"; - function foo() { new a_1.default(); } Object.defineProperty(exports, "__esModule", { value: true }); + function foo() { new a_1.default(); } exports.default = foo; }); define("a", ["require", "exports", "b"], function (require, exports, b_1) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); class Foo { } - Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Foo; b_1.default(); }); diff --git a/tests/baselines/reference/outModuleConcatAmd.js b/tests/baselines/reference/outModuleConcatAmd.js index 5054c2a3c33..fd3a4003ddf 100644 --- a/tests/baselines/reference/outModuleConcatAmd.js +++ b/tests/baselines/reference/outModuleConcatAmd.js @@ -9,13 +9,19 @@ import {A} from "./ref/a"; export class B extends A { } //// [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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); define("ref/a", ["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var A = (function () { function A() { } @@ -25,10 +31,11 @@ define("ref/a", ["require", "exports"], function (require, exports) { }); define("b", ["require", "exports", "ref/a"], function (require, exports, a_1) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(a_1.A)); diff --git a/tests/baselines/reference/outModuleConcatAmd.js.map b/tests/baselines/reference/outModuleConcatAmd.js.map index 9187aca0646..0e1c7d24100 100644 --- a/tests/baselines/reference/outModuleConcatAmd.js.map +++ b/tests/baselines/reference/outModuleConcatAmd.js.map @@ -1,2 +1,2 @@ //// [all.js.map] -{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;;;IACA;QAAA;QAAiB,CAAC;QAAD,QAAC;IAAD,CAAC,AAAlB,IAAkB;IAAL,cAAC;;;;ICAd;QAAuB,qBAAC;QAAxB;;QAA2B,CAAC;QAAD,QAAC;IAAD,CAAC,AAA5B,CAAuB,KAAC,GAAI;IAAf,cAAC"} \ No newline at end of file +{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;;;;;;;;;IACA;QAAA;QAAiB,CAAC;QAAD,QAAC;IAAD,CAAC,AAAlB,IAAkB;IAAL,cAAC;;;;;ICAd;QAAuB,qBAAC;QAAxB;;QAA2B,CAAC;QAAD,QAAC;IAAD,CAAC,AAA5B,CAAuB,KAAC,GAAI;IAAf,cAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatAmd.sourcemap.txt b/tests/baselines/reference/outModuleConcatAmd.sourcemap.txt index 34ab74816ad..c18f4e42252 100644 --- a/tests/baselines/reference/outModuleConcatAmd.sourcemap.txt +++ b/tests/baselines/reference/outModuleConcatAmd.sourcemap.txt @@ -8,25 +8,31 @@ 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 __()); ->>>}; +>>>var __extends = (this && this.__extends) || (function () { +>>> var extendStatics = Object.setPrototypeOf || +>>> ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || +>>> function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; +>>> return function (d, b) { +>>> extendStatics(d, b); +>>> function __() { this.constructor = d; } +>>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +>>> }; +>>>})(); >>>define("ref/a", ["require", "exports"], function (require, exports) { >>> "use strict"; +>>> Object.defineProperty(exports, "__esModule", { value: true }); >>> var A = (function () { 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(8, 5) Source(2, 1) + SourceIndex(0) +1 >Emitted(14, 5) Source(2, 1) + SourceIndex(0) --- >>> function A() { 1->^^^^^^^^ 2 > ^^-> 1-> -1->Emitted(9, 9) Source(2, 1) + SourceIndex(0) +1->Emitted(15, 9) Source(2, 1) + SourceIndex(0) --- >>> } 1->^^^^^^^^ @@ -34,16 +40,16 @@ sourceFile:tests/cases/compiler/ref/a.ts 3 > ^^^^^^^^^-> 1->export class A { 2 > } -1->Emitted(10, 9) Source(2, 18) + SourceIndex(0) -2 >Emitted(10, 10) Source(2, 19) + SourceIndex(0) +1->Emitted(16, 9) Source(2, 18) + SourceIndex(0) +2 >Emitted(16, 10) Source(2, 19) + SourceIndex(0) --- >>> return A; 1->^^^^^^^^ 2 > ^^^^^^^^ 1-> 2 > } -1->Emitted(11, 9) Source(2, 18) + SourceIndex(0) -2 >Emitted(11, 17) Source(2, 19) + SourceIndex(0) +1->Emitted(17, 9) Source(2, 18) + SourceIndex(0) +2 >Emitted(17, 17) Source(2, 19) + SourceIndex(0) --- >>> }()); 1 >^^^^ @@ -55,18 +61,18 @@ sourceFile:tests/cases/compiler/ref/a.ts 2 > } 3 > 4 > export class A { } -1 >Emitted(12, 5) Source(2, 18) + SourceIndex(0) -2 >Emitted(12, 6) Source(2, 19) + SourceIndex(0) -3 >Emitted(12, 6) Source(2, 1) + SourceIndex(0) -4 >Emitted(12, 10) Source(2, 19) + SourceIndex(0) +1 >Emitted(18, 5) Source(2, 18) + SourceIndex(0) +2 >Emitted(18, 6) Source(2, 19) + SourceIndex(0) +3 >Emitted(18, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(18, 10) Source(2, 19) + SourceIndex(0) --- >>> exports.A = A; 1->^^^^ 2 > ^^^^^^^^^^^^^^ 1-> 2 > A -1->Emitted(13, 5) Source(2, 14) + SourceIndex(0) -2 >Emitted(13, 19) Source(2, 15) + SourceIndex(0) +1->Emitted(19, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(19, 19) Source(2, 15) + SourceIndex(0) --- ------------------------------------------------------------------- emittedFile:all.js @@ -75,44 +81,45 @@ sourceFile:tests/cases/compiler/b.ts >>>}); >>>define("b", ["require", "exports", "ref/a"], function (require, exports, a_1) { >>> "use strict"; +>>> Object.defineProperty(exports, "__esModule", { value: true }); >>> var B = (function (_super) { 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >import {A} from "./ref/a"; > -1 >Emitted(17, 5) Source(2, 1) + SourceIndex(1) +1 >Emitted(24, 5) Source(2, 1) + SourceIndex(1) --- >>> __extends(B, _super); 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^ 1->export class B extends 2 > A -1->Emitted(18, 9) Source(2, 24) + SourceIndex(1) -2 >Emitted(18, 30) Source(2, 25) + SourceIndex(1) +1->Emitted(25, 9) Source(2, 24) + SourceIndex(1) +2 >Emitted(25, 30) Source(2, 25) + SourceIndex(1) --- >>> function B() { 1 >^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(19, 9) Source(2, 1) + SourceIndex(1) +1 >Emitted(26, 9) Source(2, 1) + SourceIndex(1) --- ->>> return _super.apply(this, arguments) || this; +>>> return _super !== null && _super.apply(this, arguments) || this; >>> } 1->^^^^^^^^ 2 > ^ 3 > ^^^^^^^^^-> 1->export class B extends A { 2 > } -1->Emitted(21, 9) Source(2, 28) + SourceIndex(1) -2 >Emitted(21, 10) Source(2, 29) + SourceIndex(1) +1->Emitted(28, 9) Source(2, 28) + SourceIndex(1) +2 >Emitted(28, 10) Source(2, 29) + SourceIndex(1) --- >>> return B; 1->^^^^^^^^ 2 > ^^^^^^^^ 1-> 2 > } -1->Emitted(22, 9) Source(2, 28) + SourceIndex(1) -2 >Emitted(22, 17) Source(2, 29) + SourceIndex(1) +1->Emitted(29, 9) Source(2, 28) + SourceIndex(1) +2 >Emitted(29, 17) Source(2, 29) + SourceIndex(1) --- >>> }(a_1.A)); 1 >^^^^ @@ -128,20 +135,20 @@ sourceFile:tests/cases/compiler/b.ts 4 > export class B extends 5 > A 6 > { } -1 >Emitted(23, 5) Source(2, 28) + SourceIndex(1) -2 >Emitted(23, 6) Source(2, 29) + SourceIndex(1) -3 >Emitted(23, 6) Source(2, 1) + SourceIndex(1) -4 >Emitted(23, 7) Source(2, 24) + SourceIndex(1) -5 >Emitted(23, 12) Source(2, 25) + SourceIndex(1) -6 >Emitted(23, 15) Source(2, 29) + SourceIndex(1) +1 >Emitted(30, 5) Source(2, 28) + SourceIndex(1) +2 >Emitted(30, 6) Source(2, 29) + SourceIndex(1) +3 >Emitted(30, 6) Source(2, 1) + SourceIndex(1) +4 >Emitted(30, 7) Source(2, 24) + SourceIndex(1) +5 >Emitted(30, 12) Source(2, 25) + SourceIndex(1) +6 >Emitted(30, 15) Source(2, 29) + SourceIndex(1) --- >>> exports.B = B; 1->^^^^ 2 > ^^^^^^^^^^^^^^ 1-> 2 > B -1->Emitted(24, 5) Source(2, 14) + SourceIndex(1) -2 >Emitted(24, 19) Source(2, 15) + SourceIndex(1) +1->Emitted(31, 5) Source(2, 14) + SourceIndex(1) +2 >Emitted(31, 19) Source(2, 15) + SourceIndex(1) --- >>>}); >>>//# sourceMappingURL=all.js.map \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatSystem.js b/tests/baselines/reference/outModuleConcatSystem.js index a615090f33a..1648748a168 100644 --- a/tests/baselines/reference/outModuleConcatSystem.js +++ b/tests/baselines/reference/outModuleConcatSystem.js @@ -9,11 +9,16 @@ import {A} from "./ref/a"; export class B extends A { } //// [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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); System.register("ref/a", [], function (exports_1, context_1) { "use strict"; var __moduleName = context_1 && context_1.id; @@ -44,7 +49,7 @@ System.register("b", ["ref/a"], function (exports_2, context_2) { B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(a_1.A)); diff --git a/tests/baselines/reference/outModuleConcatSystem.js.map b/tests/baselines/reference/outModuleConcatSystem.js.map index ac8fb23d87c..25b706844e2 100644 --- a/tests/baselines/reference/outModuleConcatSystem.js.map +++ b/tests/baselines/reference/outModuleConcatSystem.js.map @@ -1,2 +1,2 @@ //// [all.js.map] -{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;;;;;;;;YACA;gBAAA;gBAAiB,CAAC;gBAAD,QAAC;YAAD,CAAC,AAAlB,IAAkB;;QAClB,CAAC;;;;;;;;;;;;;;YCDD;gBAAuB,qBAAC;gBAAxB;;gBAA2B,CAAC;gBAAD,QAAC;YAAD,CAAC,AAA5B,CAAuB,KAAC,GAAI;;QAAA,CAAC"} \ No newline at end of file +{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;YACA;gBAAA;gBAAiB,CAAC;gBAAD,QAAC;YAAD,CAAC,AAAlB,IAAkB;;QAClB,CAAC;;;;;;;;;;;;;;YCDD;gBAAuB,qBAAC;gBAAxB;;gBAA2B,CAAC;gBAAD,QAAC;YAAD,CAAC,AAA5B,CAAuB,KAAC,GAAI;;QAAA,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/outModuleConcatSystem.sourcemap.txt b/tests/baselines/reference/outModuleConcatSystem.sourcemap.txt index 732214237fa..a8dd4bb55e7 100644 --- a/tests/baselines/reference/outModuleConcatSystem.sourcemap.txt +++ b/tests/baselines/reference/outModuleConcatSystem.sourcemap.txt @@ -8,11 +8,16 @@ 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 __()); ->>>}; +>>>var __extends = (this && this.__extends) || (function () { +>>> var extendStatics = Object.setPrototypeOf || +>>> ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || +>>> function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; +>>> return function (d, b) { +>>> extendStatics(d, b); +>>> function __() { this.constructor = d; } +>>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +>>> }; +>>>})(); >>>System.register("ref/a", [], function (exports_1, context_1) { >>> "use strict"; >>> var __moduleName = context_1 && context_1.id; @@ -25,13 +30,13 @@ sourceFile:tests/cases/compiler/ref/a.ts 2 > ^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(13, 13) Source(2, 1) + SourceIndex(0) +1 >Emitted(18, 13) Source(2, 1) + SourceIndex(0) --- >>> function A() { 1->^^^^^^^^^^^^^^^^ 2 > ^^-> 1-> -1->Emitted(14, 17) Source(2, 1) + SourceIndex(0) +1->Emitted(19, 17) Source(2, 1) + SourceIndex(0) --- >>> } 1->^^^^^^^^^^^^^^^^ @@ -39,16 +44,16 @@ sourceFile:tests/cases/compiler/ref/a.ts 3 > ^^^^^^^^^-> 1->export class A { 2 > } -1->Emitted(15, 17) Source(2, 18) + SourceIndex(0) -2 >Emitted(15, 18) Source(2, 19) + SourceIndex(0) +1->Emitted(20, 17) Source(2, 18) + SourceIndex(0) +2 >Emitted(20, 18) Source(2, 19) + SourceIndex(0) --- >>> return A; 1->^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^ 1-> 2 > } -1->Emitted(16, 17) Source(2, 18) + SourceIndex(0) -2 >Emitted(16, 25) Source(2, 19) + SourceIndex(0) +1->Emitted(21, 17) Source(2, 18) + SourceIndex(0) +2 >Emitted(21, 25) Source(2, 19) + SourceIndex(0) --- >>> }()); 1 >^^^^^^^^^^^^ @@ -60,10 +65,10 @@ sourceFile:tests/cases/compiler/ref/a.ts 2 > } 3 > 4 > export class A { } -1 >Emitted(17, 13) Source(2, 18) + SourceIndex(0) -2 >Emitted(17, 14) Source(2, 19) + SourceIndex(0) -3 >Emitted(17, 14) Source(2, 1) + SourceIndex(0) -4 >Emitted(17, 18) Source(2, 19) + SourceIndex(0) +1 >Emitted(22, 13) Source(2, 18) + SourceIndex(0) +2 >Emitted(22, 14) Source(2, 19) + SourceIndex(0) +3 >Emitted(22, 14) Source(2, 1) + SourceIndex(0) +4 >Emitted(22, 18) Source(2, 19) + SourceIndex(0) --- >>> exports_1("A", A); >>> } @@ -72,8 +77,8 @@ sourceFile:tests/cases/compiler/ref/a.ts 1-> > 2 > -1->Emitted(19, 9) Source(3, 1) + SourceIndex(0) -2 >Emitted(19, 10) Source(3, 2) + SourceIndex(0) +1->Emitted(24, 9) Source(3, 1) + SourceIndex(0) +2 >Emitted(24, 10) Source(3, 2) + SourceIndex(0) --- ------------------------------------------------------------------- emittedFile:all.js @@ -97,39 +102,39 @@ sourceFile:tests/cases/compiler/b.ts 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >import {A} from "./ref/a"; > -1 >Emitted(33, 13) Source(2, 1) + SourceIndex(1) +1 >Emitted(38, 13) Source(2, 1) + SourceIndex(1) --- >>> __extends(B, _super); 1->^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^ 1->export class B extends 2 > A -1->Emitted(34, 17) Source(2, 24) + SourceIndex(1) -2 >Emitted(34, 38) Source(2, 25) + SourceIndex(1) +1->Emitted(39, 17) Source(2, 24) + SourceIndex(1) +2 >Emitted(39, 38) Source(2, 25) + SourceIndex(1) --- >>> function B() { 1 >^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(35, 17) Source(2, 1) + SourceIndex(1) +1 >Emitted(40, 17) Source(2, 1) + SourceIndex(1) --- ->>> return _super.apply(this, arguments) || this; +>>> return _super !== null && _super.apply(this, arguments) || this; >>> } 1->^^^^^^^^^^^^^^^^ 2 > ^ 3 > ^^^^^^^^^-> 1->export class B extends A { 2 > } -1->Emitted(37, 17) Source(2, 28) + SourceIndex(1) -2 >Emitted(37, 18) Source(2, 29) + SourceIndex(1) +1->Emitted(42, 17) Source(2, 28) + SourceIndex(1) +2 >Emitted(42, 18) Source(2, 29) + SourceIndex(1) --- >>> return B; 1->^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^ 1-> 2 > } -1->Emitted(38, 17) Source(2, 28) + SourceIndex(1) -2 >Emitted(38, 25) Source(2, 29) + SourceIndex(1) +1->Emitted(43, 17) Source(2, 28) + SourceIndex(1) +2 >Emitted(43, 25) Source(2, 29) + SourceIndex(1) --- >>> }(a_1.A)); 1 >^^^^^^^^^^^^ @@ -145,12 +150,12 @@ sourceFile:tests/cases/compiler/b.ts 4 > export class B extends 5 > A 6 > { } -1 >Emitted(39, 13) Source(2, 28) + SourceIndex(1) -2 >Emitted(39, 14) Source(2, 29) + SourceIndex(1) -3 >Emitted(39, 14) Source(2, 1) + SourceIndex(1) -4 >Emitted(39, 15) Source(2, 24) + SourceIndex(1) -5 >Emitted(39, 20) Source(2, 25) + SourceIndex(1) -6 >Emitted(39, 23) Source(2, 29) + SourceIndex(1) +1 >Emitted(44, 13) Source(2, 28) + SourceIndex(1) +2 >Emitted(44, 14) Source(2, 29) + SourceIndex(1) +3 >Emitted(44, 14) Source(2, 1) + SourceIndex(1) +4 >Emitted(44, 15) Source(2, 24) + SourceIndex(1) +5 >Emitted(44, 20) Source(2, 25) + SourceIndex(1) +6 >Emitted(44, 23) Source(2, 29) + SourceIndex(1) --- >>> exports_2("B", B); >>> } @@ -158,8 +163,8 @@ sourceFile:tests/cases/compiler/b.ts 2 > ^ 1-> 2 > -1->Emitted(41, 9) Source(2, 29) + SourceIndex(1) -2 >Emitted(41, 10) Source(2, 30) + SourceIndex(1) +1->Emitted(46, 9) Source(2, 29) + SourceIndex(1) +2 >Emitted(46, 10) Source(2, 30) + SourceIndex(1) --- >>> }; >>>}); diff --git a/tests/baselines/reference/outModuleTripleSlashRefs.js b/tests/baselines/reference/outModuleTripleSlashRefs.js index b9ff7c15b61..c45414b5e62 100644 --- a/tests/baselines/reference/outModuleTripleSlashRefs.js +++ b/tests/baselines/reference/outModuleTripleSlashRefs.js @@ -31,11 +31,16 @@ export class B extends A { } //// [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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); /// var Foo = (function () { function Foo() { @@ -44,6 +49,7 @@ var Foo = (function () { }()); define("ref/a", ["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); /// var A = (function () { function A() { @@ -54,10 +60,11 @@ define("ref/a", ["require", "exports"], function (require, exports) { }); define("b", ["require", "exports", "ref/a"], function (require, exports, a_1) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(a_1.A)); diff --git a/tests/baselines/reference/outModuleTripleSlashRefs.js.map b/tests/baselines/reference/outModuleTripleSlashRefs.js.map index 5ccc59aeabf..8b552ec3fb3 100644 --- a/tests/baselines/reference/outModuleTripleSlashRefs.js.map +++ b/tests/baselines/reference/outModuleTripleSlashRefs.js.map @@ -1,2 +1,2 @@ //// [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":[],"mappings":";;;;;AAAA,iCAAiC;AACjC;IAAA;IAEA,CAAC;IAAD,UAAC;AAAD,CAAC,AAFD,IAEC;;;ICFD,+BAA+B;IAC/B;QAAA;QAEA,CAAC;QAAD,QAAC;IAAD,CAAC,AAFD,IAEC;IAFY,cAAC;;;;ICDd;QAAuB,qBAAC;QAAxB;;QAA2B,CAAC;QAAD,QAAC;IAAD,CAAC,AAA5B,CAAuB,KAAC,GAAI;IAAf,cAAC"} \ No newline at end of file +{"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":[],"mappings":";;;;;;;;;;AAAA,iCAAiC;AACjC;IAAA;IAEA,CAAC;IAAD,UAAC;AAAD,CAAC,AAFD,IAEC;;;;ICFD,+BAA+B;IAC/B;QAAA;QAEA,CAAC;QAAD,QAAC;IAAD,CAAC,AAFD,IAEC;IAFY,cAAC;;;;;ICDd;QAAuB,qBAAC;QAAxB;;QAA2B,CAAC;QAAD,QAAC;IAAD,CAAC,AAA5B,CAAuB,KAAC,GAAI;IAAf,cAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/outModuleTripleSlashRefs.sourcemap.txt b/tests/baselines/reference/outModuleTripleSlashRefs.sourcemap.txt index ce41bae6de3..231da040f11 100644 --- a/tests/baselines/reference/outModuleTripleSlashRefs.sourcemap.txt +++ b/tests/baselines/reference/outModuleTripleSlashRefs.sourcemap.txt @@ -8,31 +8,36 @@ sources: tests/cases/compiler/ref/b.ts,tests/cases/compiler/ref/a.ts,tests/cases 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 __()); ->>>}; +>>>var __extends = (this && this.__extends) || (function () { +>>> var extendStatics = Object.setPrototypeOf || +>>> ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || +>>> function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; +>>> return function (d, b) { +>>> extendStatics(d, b); +>>> 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) +1 >Emitted(11, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(11, 34) Source(1, 34) + SourceIndex(0) --- >>>var Foo = (function () { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(7, 1) Source(2, 1) + SourceIndex(0) +1 >Emitted(12, 1) Source(2, 1) + SourceIndex(0) --- >>> function Foo() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(8, 5) Source(2, 1) + SourceIndex(0) +1->Emitted(13, 5) Source(2, 1) + SourceIndex(0) --- >>> } 1->^^^^ @@ -42,16 +47,16 @@ sourceFile:tests/cases/compiler/ref/b.ts > member: Bar; > 2 > } -1->Emitted(9, 5) Source(4, 1) + SourceIndex(0) -2 >Emitted(9, 6) Source(4, 2) + SourceIndex(0) +1->Emitted(14, 5) Source(4, 1) + SourceIndex(0) +2 >Emitted(14, 6) Source(4, 2) + SourceIndex(0) --- >>> return Foo; 1->^^^^ 2 > ^^^^^^^^^^ 1-> 2 > } -1->Emitted(10, 5) Source(4, 1) + SourceIndex(0) -2 >Emitted(10, 15) Source(4, 2) + SourceIndex(0) +1->Emitted(15, 5) Source(4, 1) + SourceIndex(0) +2 >Emitted(15, 15) Source(4, 2) + SourceIndex(0) --- >>>}()); 1 > @@ -65,10 +70,10 @@ sourceFile:tests/cases/compiler/ref/b.ts 4 > class Foo { > member: Bar; > } -1 >Emitted(11, 1) Source(4, 1) + SourceIndex(0) -2 >Emitted(11, 2) Source(4, 2) + SourceIndex(0) -3 >Emitted(11, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(11, 6) Source(4, 2) + SourceIndex(0) +1 >Emitted(16, 1) Source(4, 1) + SourceIndex(0) +2 >Emitted(16, 2) Source(4, 2) + SourceIndex(0) +3 >Emitted(16, 2) Source(2, 1) + SourceIndex(0) +4 >Emitted(16, 6) Source(4, 2) + SourceIndex(0) --- ------------------------------------------------------------------- emittedFile:all.js @@ -76,27 +81,28 @@ sourceFile:tests/cases/compiler/ref/a.ts ------------------------------------------------------------------- >>>define("ref/a", ["require", "exports"], function (require, exports) { >>> "use strict"; +>>> Object.defineProperty(exports, "__esModule", { value: true }); >>> /// 1->^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> > 2 > /// -1->Emitted(14, 5) Source(2, 1) + SourceIndex(1) -2 >Emitted(14, 36) Source(2, 32) + SourceIndex(1) +1->Emitted(20, 5) Source(2, 1) + SourceIndex(1) +2 >Emitted(20, 36) Source(2, 32) + SourceIndex(1) --- >>> var A = (function () { 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^-> 1 > > -1 >Emitted(15, 5) Source(3, 1) + SourceIndex(1) +1 >Emitted(21, 5) Source(3, 1) + SourceIndex(1) --- >>> function A() { 1->^^^^^^^^ 2 > ^^-> 1-> -1->Emitted(16, 9) Source(3, 1) + SourceIndex(1) +1->Emitted(22, 9) Source(3, 1) + SourceIndex(1) --- >>> } 1->^^^^^^^^ @@ -106,16 +112,16 @@ sourceFile:tests/cases/compiler/ref/a.ts > member: typeof GlobalFoo; > 2 > } -1->Emitted(17, 9) Source(5, 1) + SourceIndex(1) -2 >Emitted(17, 10) Source(5, 2) + SourceIndex(1) +1->Emitted(23, 9) Source(5, 1) + SourceIndex(1) +2 >Emitted(23, 10) Source(5, 2) + SourceIndex(1) --- >>> return A; 1->^^^^^^^^ 2 > ^^^^^^^^ 1-> 2 > } -1->Emitted(18, 9) Source(5, 1) + SourceIndex(1) -2 >Emitted(18, 17) Source(5, 2) + SourceIndex(1) +1->Emitted(24, 9) Source(5, 1) + SourceIndex(1) +2 >Emitted(24, 17) Source(5, 2) + SourceIndex(1) --- >>> }()); 1 >^^^^ @@ -129,18 +135,18 @@ sourceFile:tests/cases/compiler/ref/a.ts 4 > export class A { > member: typeof GlobalFoo; > } -1 >Emitted(19, 5) Source(5, 1) + SourceIndex(1) -2 >Emitted(19, 6) Source(5, 2) + SourceIndex(1) -3 >Emitted(19, 6) Source(3, 1) + SourceIndex(1) -4 >Emitted(19, 10) Source(5, 2) + SourceIndex(1) +1 >Emitted(25, 5) Source(5, 1) + SourceIndex(1) +2 >Emitted(25, 6) Source(5, 2) + SourceIndex(1) +3 >Emitted(25, 6) Source(3, 1) + SourceIndex(1) +4 >Emitted(25, 10) Source(5, 2) + SourceIndex(1) --- >>> exports.A = A; 1->^^^^ 2 > ^^^^^^^^^^^^^^ 1-> 2 > A -1->Emitted(20, 5) Source(3, 14) + SourceIndex(1) -2 >Emitted(20, 19) Source(3, 15) + SourceIndex(1) +1->Emitted(26, 5) Source(3, 14) + SourceIndex(1) +2 >Emitted(26, 19) Source(3, 15) + SourceIndex(1) --- ------------------------------------------------------------------- emittedFile:all.js @@ -149,44 +155,45 @@ sourceFile:tests/cases/compiler/b.ts >>>}); >>>define("b", ["require", "exports", "ref/a"], function (require, exports, a_1) { >>> "use strict"; +>>> Object.defineProperty(exports, "__esModule", { value: true }); >>> var B = (function (_super) { 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >import {A} from "./ref/a"; > -1 >Emitted(24, 5) Source(2, 1) + SourceIndex(2) +1 >Emitted(31, 5) Source(2, 1) + SourceIndex(2) --- >>> __extends(B, _super); 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^ 1->export class B extends 2 > A -1->Emitted(25, 9) Source(2, 24) + SourceIndex(2) -2 >Emitted(25, 30) Source(2, 25) + SourceIndex(2) +1->Emitted(32, 9) Source(2, 24) + SourceIndex(2) +2 >Emitted(32, 30) Source(2, 25) + SourceIndex(2) --- >>> function B() { 1 >^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(26, 9) Source(2, 1) + SourceIndex(2) +1 >Emitted(33, 9) Source(2, 1) + SourceIndex(2) --- ->>> return _super.apply(this, arguments) || this; +>>> return _super !== null && _super.apply(this, arguments) || this; >>> } 1->^^^^^^^^ 2 > ^ 3 > ^^^^^^^^^-> 1->export class B extends A { 2 > } -1->Emitted(28, 9) Source(2, 28) + SourceIndex(2) -2 >Emitted(28, 10) Source(2, 29) + SourceIndex(2) +1->Emitted(35, 9) Source(2, 28) + SourceIndex(2) +2 >Emitted(35, 10) Source(2, 29) + SourceIndex(2) --- >>> return B; 1->^^^^^^^^ 2 > ^^^^^^^^ 1-> 2 > } -1->Emitted(29, 9) Source(2, 28) + SourceIndex(2) -2 >Emitted(29, 17) Source(2, 29) + SourceIndex(2) +1->Emitted(36, 9) Source(2, 28) + SourceIndex(2) +2 >Emitted(36, 17) Source(2, 29) + SourceIndex(2) --- >>> }(a_1.A)); 1 >^^^^ @@ -202,20 +209,20 @@ sourceFile:tests/cases/compiler/b.ts 4 > export class B extends 5 > A 6 > { } -1 >Emitted(30, 5) Source(2, 28) + SourceIndex(2) -2 >Emitted(30, 6) Source(2, 29) + SourceIndex(2) -3 >Emitted(30, 6) Source(2, 1) + SourceIndex(2) -4 >Emitted(30, 7) Source(2, 24) + SourceIndex(2) -5 >Emitted(30, 12) Source(2, 25) + SourceIndex(2) -6 >Emitted(30, 15) Source(2, 29) + SourceIndex(2) +1 >Emitted(37, 5) Source(2, 28) + SourceIndex(2) +2 >Emitted(37, 6) Source(2, 29) + SourceIndex(2) +3 >Emitted(37, 6) Source(2, 1) + SourceIndex(2) +4 >Emitted(37, 7) Source(2, 24) + SourceIndex(2) +5 >Emitted(37, 12) Source(2, 25) + SourceIndex(2) +6 >Emitted(37, 15) Source(2, 29) + SourceIndex(2) --- >>> exports.B = B; 1->^^^^ 2 > ^^^^^^^^^^^^^^ 1-> 2 > B -1->Emitted(31, 5) Source(2, 14) + SourceIndex(2) -2 >Emitted(31, 19) Source(2, 15) + SourceIndex(2) +1->Emitted(38, 5) Source(2, 14) + SourceIndex(2) +2 >Emitted(38, 19) Source(2, 15) + SourceIndex(2) --- >>>}); >>>//# sourceMappingURL=all.js.map \ No newline at end of file diff --git a/tests/baselines/reference/overload1.js b/tests/baselines/reference/overload1.js index 41aafdfb29c..fc898b4e870 100644 --- a/tests/baselines/reference/overload1.js +++ b/tests/baselines/reference/overload1.js @@ -40,11 +40,16 @@ var v=x.g; //// [overload1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var O; (function (O) { var A = (function () { @@ -56,7 +61,7 @@ var O; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -64,7 +69,7 @@ var O; var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); diff --git a/tests/baselines/reference/overloadModifiersMustAgree.js b/tests/baselines/reference/overloadModifiersMustAgree.js index e7256562e76..783bf854a84 100644 --- a/tests/baselines/reference/overloadModifiersMustAgree.js +++ b/tests/baselines/reference/overloadModifiersMustAgree.js @@ -17,6 +17,7 @@ interface I { //// [overloadModifiersMustAgree.js] "use strict"; +exports.__esModule = true; var baz = (function () { function baz() { } diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks1.js b/tests/baselines/reference/overloadOnConstConstraintChecks1.js index f9d1c81b06b..6a4cc01bf85 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks1.js +++ b/tests/baselines/reference/overloadOnConstConstraintChecks1.js @@ -23,11 +23,16 @@ class D implements MyDoc { } //// [overloadOnConstConstraintChecks1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -37,7 +42,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.prototype.bar = function () { }; return Derived1; @@ -45,7 +50,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived2.prototype.baz = function () { }; return Derived2; @@ -53,7 +58,7 @@ var Derived2 = (function (_super) { var Derived3 = (function (_super) { __extends(Derived3, _super); function Derived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived3.prototype.biz = function () { }; return Derived3; diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks2.js b/tests/baselines/reference/overloadOnConstConstraintChecks2.js index a680a62ddfe..379de55da88 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks2.js +++ b/tests/baselines/reference/overloadOnConstConstraintChecks2.js @@ -12,11 +12,16 @@ function foo(name: any): A { } //// [overloadOnConstConstraintChecks2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -25,14 +30,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.foo = function () { }; return C; diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks3.js b/tests/baselines/reference/overloadOnConstConstraintChecks3.js index 025e449fd6f..de843b9f44c 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks3.js +++ b/tests/baselines/reference/overloadOnConstConstraintChecks3.js @@ -13,11 +13,16 @@ function foo(name: any): A { //// [overloadOnConstConstraintChecks3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { this.x = 1; @@ -27,14 +32,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.foo = function () { }; return C; diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks4.js b/tests/baselines/reference/overloadOnConstConstraintChecks4.js index 0f436a5f0b2..3f7664ff6c8 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks4.js +++ b/tests/baselines/reference/overloadOnConstConstraintChecks4.js @@ -14,11 +14,16 @@ function foo(name: any): Z { //// [overloadOnConstConstraintChecks4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Z = (function () { function Z() { } @@ -27,7 +32,7 @@ var Z = (function () { var A = (function (_super) { __extends(A, _super); function A() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = 1; return _this; } @@ -36,14 +41,14 @@ var A = (function (_super) { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.foo = function () { }; return C; diff --git a/tests/baselines/reference/overloadOnConstantsInvalidOverload1.js b/tests/baselines/reference/overloadOnConstantsInvalidOverload1.js index e3f58c0f7d0..5488ea03ee8 100644 --- a/tests/baselines/reference/overloadOnConstantsInvalidOverload1.js +++ b/tests/baselines/reference/overloadOnConstantsInvalidOverload1.js @@ -12,11 +12,16 @@ function foo(name: "DIV"): Derived2 { foo("HI"); //// [overloadOnConstantsInvalidOverload1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -26,7 +31,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.prototype.bar = function () { }; return Derived1; @@ -34,7 +39,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived2.prototype.baz = function () { }; return Derived2; @@ -42,7 +47,7 @@ var Derived2 = (function (_super) { var Derived3 = (function (_super) { __extends(Derived3, _super); function Derived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived3.prototype.biz = function () { }; return Derived3; diff --git a/tests/baselines/reference/overloadResolution.js b/tests/baselines/reference/overloadResolution.js index e5cc35c39c4..32040c082ee 100644 --- a/tests/baselines/reference/overloadResolution.js +++ b/tests/baselines/reference/overloadResolution.js @@ -95,11 +95,16 @@ var s = fn5((n) => n.substr(0)); //// [overloadResolution.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var SomeBase = (function () { function SomeBase() { } @@ -108,21 +113,21 @@ var SomeBase = (function () { var SomeDerived1 = (function (_super) { __extends(SomeDerived1, _super); function SomeDerived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived1; }(SomeBase)); var SomeDerived2 = (function (_super) { __extends(SomeDerived2, _super); function SomeDerived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived2; }(SomeBase)); var SomeDerived3 = (function (_super) { __extends(SomeDerived3, _super); function SomeDerived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived3; }(SomeBase)); diff --git a/tests/baselines/reference/overloadResolutionClassConstructors.js b/tests/baselines/reference/overloadResolutionClassConstructors.js index 7c8b2e2ccb6..5a8c7c0838b 100644 --- a/tests/baselines/reference/overloadResolutionClassConstructors.js +++ b/tests/baselines/reference/overloadResolutionClassConstructors.js @@ -102,11 +102,16 @@ new fn5((n) => n.blah); // Error //// [overloadResolutionClassConstructors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var SomeBase = (function () { function SomeBase() { } @@ -115,21 +120,21 @@ var SomeBase = (function () { var SomeDerived1 = (function (_super) { __extends(SomeDerived1, _super); function SomeDerived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived1; }(SomeBase)); var SomeDerived2 = (function (_super) { __extends(SomeDerived2, _super); function SomeDerived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived2; }(SomeBase)); var SomeDerived3 = (function (_super) { __extends(SomeDerived3, _super); function SomeDerived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived3; }(SomeBase)); diff --git a/tests/baselines/reference/overloadResolutionConstructors.js b/tests/baselines/reference/overloadResolutionConstructors.js index 44bbfbcec2b..32f350bdc2e 100644 --- a/tests/baselines/reference/overloadResolutionConstructors.js +++ b/tests/baselines/reference/overloadResolutionConstructors.js @@ -103,11 +103,16 @@ var s = new fn5((n) => n.substr(0)); //// [overloadResolutionConstructors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var SomeBase = (function () { function SomeBase() { } @@ -116,21 +121,21 @@ var SomeBase = (function () { var SomeDerived1 = (function (_super) { __extends(SomeDerived1, _super); function SomeDerived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived1; }(SomeBase)); var SomeDerived2 = (function (_super) { __extends(SomeDerived2, _super); function SomeDerived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived2; }(SomeBase)); var SomeDerived3 = (function (_super) { __extends(SomeDerived3, _super); function SomeDerived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return SomeDerived3; }(SomeBase)); diff --git a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types index ee5c336ba9c..a4de1666d0b 100644 --- a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types +++ b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types @@ -32,7 +32,7 @@ module Bugs { return typeof args[index] !== 'undefined' >typeof args[index] !== 'undefined' ? args[index] : match : any >typeof args[index] !== 'undefined' : boolean ->typeof args[index] : string +>typeof args[index] : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >args[index] : any >args : any[] >index : any diff --git a/tests/baselines/reference/overloadReturnTypes.types b/tests/baselines/reference/overloadReturnTypes.types index c0f573fb980..daf790b9a92 100644 --- a/tests/baselines/reference/overloadReturnTypes.types +++ b/tests/baselines/reference/overloadReturnTypes.types @@ -26,7 +26,7 @@ function attr(nameOrMap: any, value?: string): any { >nameOrMap && typeof nameOrMap === "object" : boolean >nameOrMap : any >typeof nameOrMap === "object" : boolean ->typeof nameOrMap : string +>typeof nameOrMap : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >nameOrMap : any >"object" : "object" diff --git a/tests/baselines/reference/overloadingOnConstants1.js b/tests/baselines/reference/overloadingOnConstants1.js index 96f4f7baf24..c741abade66 100644 --- a/tests/baselines/reference/overloadingOnConstants1.js +++ b/tests/baselines/reference/overloadingOnConstants1.js @@ -26,11 +26,16 @@ var htmlDivElement2: Derived1 = d2.createElement("div"); var htmlSpanElement2: Derived1 = d2.createElement("span"); //// [overloadingOnConstants1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -40,7 +45,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.prototype.bar = function () { }; return Derived1; @@ -48,7 +53,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived2.prototype.baz = function () { }; return Derived2; @@ -56,7 +61,7 @@ var Derived2 = (function (_super) { var Derived3 = (function (_super) { __extends(Derived3, _super); function Derived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived3.prototype.biz = function () { }; return Derived3; diff --git a/tests/baselines/reference/overloadingOnConstants2.js b/tests/baselines/reference/overloadingOnConstants2.js index 0c34d0f4b76..f415df84a47 100644 --- a/tests/baselines/reference/overloadingOnConstants2.js +++ b/tests/baselines/reference/overloadingOnConstants2.js @@ -28,11 +28,16 @@ var e: E = bar("bye", []); // E var f: C = bar("um", []); // C //// [overloadingOnConstants2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { this.x = 1; @@ -42,7 +47,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/overridingPrivateStaticMembers.js b/tests/baselines/reference/overridingPrivateStaticMembers.js index ca5616450ba..0b4e5672b5e 100644 --- a/tests/baselines/reference/overridingPrivateStaticMembers.js +++ b/tests/baselines/reference/overridingPrivateStaticMembers.js @@ -8,11 +8,16 @@ class Derived2 extends Base2 { } //// [overridingPrivateStaticMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base2 = (function () { function Base2() { } @@ -21,7 +26,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/packageJsonMain.js b/tests/baselines/reference/packageJsonMain.js new file mode 100644 index 00000000000..96509ab639e --- /dev/null +++ b/tests/baselines/reference/packageJsonMain.js @@ -0,0 +1,35 @@ +//// [tests/cases/conformance/moduleResolution/packageJsonMain.ts] //// + +//// [package.json] + +{ "main": "oof" } + +//// [oof.js] +module.exports = 0; + +//// [package.json] +{ "main": "rab.js" } + +//// [rab.js] +module.exports = 0; + +//// [package.json] +{ "main": "zab" } + +//// [index.js] +module.exports = 0; + +//// [a.ts] +import foo = require("foo"); +import bar = require("bar"); +import baz = require("baz"); +foo + bar + baz; + + +//// [a.js] +"use strict"; +exports.__esModule = true; +var foo = require("foo"); +var bar = require("bar"); +var baz = require("baz"); +foo + bar + baz; diff --git a/tests/baselines/reference/packageJsonMain.symbols b/tests/baselines/reference/packageJsonMain.symbols new file mode 100644 index 00000000000..c34c36e8901 --- /dev/null +++ b/tests/baselines/reference/packageJsonMain.symbols @@ -0,0 +1,15 @@ +=== /a.ts === +import foo = require("foo"); +>foo : Symbol(foo, Decl(a.ts, 0, 0)) + +import bar = require("bar"); +>bar : Symbol(bar, Decl(a.ts, 0, 28)) + +import baz = require("baz"); +>baz : Symbol(baz, Decl(a.ts, 1, 28)) + +foo + bar + baz; +>foo : Symbol(foo, Decl(a.ts, 0, 0)) +>bar : Symbol(bar, Decl(a.ts, 0, 28)) +>baz : Symbol(baz, Decl(a.ts, 1, 28)) + diff --git a/tests/baselines/reference/packageJsonMain.trace.json b/tests/baselines/reference/packageJsonMain.trace.json new file mode 100644 index 00000000000..a167e8dfec6 --- /dev/null +++ b/tests/baselines/reference/packageJsonMain.trace.json @@ -0,0 +1,71 @@ +[ + "======== Resolving module 'foo' from '/a.ts'. ========", + "Module resolution kind is not specified, using 'NodeJs'.", + "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/foo.ts' does not exist.", + "File '/node_modules/foo.tsx' does not exist.", + "File '/node_modules/foo.d.ts' does not exist.", + "Found 'package.json' at '/node_modules/foo/package.json'.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "File '/node_modules/foo/index.ts' does not exist.", + "File '/node_modules/foo/index.tsx' does not exist.", + "File '/node_modules/foo/index.d.ts' does not exist.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/foo.js' does not exist.", + "File '/node_modules/foo.jsx' does not exist.", + "Found 'package.json' at '/node_modules/foo/package.json'.", + "'package.json' has 'main' field 'oof' that references '/node_modules/foo/oof'.", + "File '/node_modules/foo/oof' does not exist.", + "Loading module as file / folder, candidate module location '/node_modules/foo/oof', target file type 'JavaScript'.", + "File '/node_modules/foo/oof.js' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/foo/oof.js', result '/node_modules/foo/oof.js'", + "======== Module name 'foo' was successfully resolved to '/node_modules/foo/oof.js'. ========", + "======== Resolving module 'bar' from '/a.ts'. ========", + "Module resolution kind is not specified, using 'NodeJs'.", + "Loading module 'bar' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/bar.ts' does not exist.", + "File '/node_modules/bar.tsx' does not exist.", + "File '/node_modules/bar.d.ts' does not exist.", + "Found 'package.json' at '/node_modules/bar/package.json'.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "File '/node_modules/bar/index.ts' does not exist.", + "File '/node_modules/bar/index.tsx' does not exist.", + "File '/node_modules/bar/index.d.ts' does not exist.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Loading module 'bar' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/bar.js' does not exist.", + "File '/node_modules/bar.jsx' does not exist.", + "Found 'package.json' at '/node_modules/bar/package.json'.", + "'package.json' has 'main' field 'rab.js' that references '/node_modules/bar/rab.js'.", + "File '/node_modules/bar/rab.js' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/bar/rab.js', result '/node_modules/bar/rab.js'", + "======== Module name 'bar' was successfully resolved to '/node_modules/bar/rab.js'. ========", + "======== Resolving module 'baz' from '/a.ts'. ========", + "Module resolution kind is not specified, using 'NodeJs'.", + "Loading module 'baz' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/baz.ts' does not exist.", + "File '/node_modules/baz.tsx' does not exist.", + "File '/node_modules/baz.d.ts' does not exist.", + "Found 'package.json' at '/node_modules/baz/package.json'.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "File '/node_modules/baz/index.ts' does not exist.", + "File '/node_modules/baz/index.tsx' does not exist.", + "File '/node_modules/baz/index.d.ts' does not exist.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Loading module 'baz' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/baz.js' does not exist.", + "File '/node_modules/baz.jsx' does not exist.", + "Found 'package.json' at '/node_modules/baz/package.json'.", + "'package.json' has 'main' field 'zab' that references '/node_modules/baz/zab'.", + "File '/node_modules/baz/zab' does not exist.", + "Loading module as file / folder, candidate module location '/node_modules/baz/zab', target file type 'JavaScript'.", + "File '/node_modules/baz/zab.js' does not exist.", + "File '/node_modules/baz/zab.jsx' does not exist.", + "File '/node_modules/baz/zab/index.js' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/baz/zab/index.js', result '/node_modules/baz/zab/index.js'", + "======== Module name 'baz' was successfully resolved to '/node_modules/baz/zab/index.js'. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/packageJsonMain.types b/tests/baselines/reference/packageJsonMain.types new file mode 100644 index 00000000000..f30bd95f0e5 --- /dev/null +++ b/tests/baselines/reference/packageJsonMain.types @@ -0,0 +1,17 @@ +=== /a.ts === +import foo = require("foo"); +>foo : any + +import bar = require("bar"); +>bar : any + +import baz = require("baz"); +>baz : any + +foo + bar + baz; +>foo + bar + baz : any +>foo + bar : any +>foo : any +>bar : any +>baz : any + diff --git a/tests/baselines/reference/packageJsonMain_isNonRecursive.errors.txt b/tests/baselines/reference/packageJsonMain_isNonRecursive.errors.txt new file mode 100644 index 00000000000..a886fe3dca5 --- /dev/null +++ b/tests/baselines/reference/packageJsonMain_isNonRecursive.errors.txt @@ -0,0 +1,18 @@ +/a.ts(1,22): error TS2307: Cannot find module 'foo'. + + +==== /a.ts (1 errors) ==== + import foo = require("foo"); + ~~~~~ +!!! error TS2307: Cannot find module 'foo'. + +==== /node_modules/foo/package.json (0 errors) ==== + + { "main": "oof" } + +==== /node_modules/foo/oof/package.json (0 errors) ==== + { "main": "ofo" } + +==== /node_modules/foo/oof/ofo.js (0 errors) ==== + module.exports = 0; + \ No newline at end of file diff --git a/tests/baselines/reference/packageJsonMain_isNonRecursive.js b/tests/baselines/reference/packageJsonMain_isNonRecursive.js new file mode 100644 index 00000000000..97d7bbdf05b --- /dev/null +++ b/tests/baselines/reference/packageJsonMain_isNonRecursive.js @@ -0,0 +1,19 @@ +//// [tests/cases/conformance/moduleResolution/packageJsonMain_isNonRecursive.ts] //// + +//// [package.json] + +{ "main": "oof" } + +//// [package.json] +{ "main": "ofo" } + +//// [ofo.js] +module.exports = 0; + +//// [a.ts] +import foo = require("foo"); + + +//// [a.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json b/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json new file mode 100644 index 00000000000..53e1ad25605 --- /dev/null +++ b/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json @@ -0,0 +1,29 @@ +[ + "======== Resolving module 'foo' from '/a.ts'. ========", + "Module resolution kind is not specified, using 'NodeJs'.", + "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/foo.ts' does not exist.", + "File '/node_modules/foo.tsx' does not exist.", + "File '/node_modules/foo.d.ts' does not exist.", + "Found 'package.json' at '/node_modules/foo/package.json'.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "File '/node_modules/foo/index.ts' does not exist.", + "File '/node_modules/foo/index.tsx' does not exist.", + "File '/node_modules/foo/index.d.ts' does not exist.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/foo.js' does not exist.", + "File '/node_modules/foo.jsx' does not exist.", + "Found 'package.json' at '/node_modules/foo/package.json'.", + "'package.json' has 'main' field 'oof' that references '/node_modules/foo/oof'.", + "File '/node_modules/foo/oof' does not exist.", + "Loading module as file / folder, candidate module location '/node_modules/foo/oof', target file type 'JavaScript'.", + "File '/node_modules/foo/oof.js' does not exist.", + "File '/node_modules/foo/oof.jsx' does not exist.", + "File '/node_modules/foo/oof/index.js' does not exist.", + "File '/node_modules/foo/oof/index.jsx' does not exist.", + "File '/node_modules/foo/index.js' does not exist.", + "File '/node_modules/foo/index.jsx' does not exist.", + "======== Module name 'foo' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/parseErrorInHeritageClause1.js b/tests/baselines/reference/parseErrorInHeritageClause1.js index a9ca0a6db73..735c756fd1f 100644 --- a/tests/baselines/reference/parseErrorInHeritageClause1.js +++ b/tests/baselines/reference/parseErrorInHeritageClause1.js @@ -3,15 +3,20 @@ class C extends A # { } //// [parseErrorInHeritageClause1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parser.asyncGenerators.classMethods.esnext.errors.txt b/tests/baselines/reference/parser.asyncGenerators.classMethods.esnext.errors.txt new file mode 100644 index 00000000000..febd6d1160e --- /dev/null +++ b/tests/baselines/reference/parser.asyncGenerators.classMethods.esnext.errors.txt @@ -0,0 +1,235 @@ +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/asyncGeneratorGetAccessorIsError.ts(2,17): error TS1005: '(' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/asyncGeneratorPropertyIsError.ts(2,15): error TS1005: '(' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/asyncGeneratorSetAccessorIsError.ts(2,17): error TS1005: '(' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitInParameterInitializerIsError.ts(2,19): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitMissingValueIsError.ts(3,14): error TS1109: Expression expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts(2,15): error TS1138: Parameter declaration expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts(2,15): error TS2693: 'await' only refers to a type, but is being used as a value here. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts(2,20): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts(4,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(3,18): error TS1003: Identifier expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(3,24): error TS1109: Expression expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(3,26): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(3,18): error TS1003: Identifier expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(3,26): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(3,28): error TS1005: '(' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(3,34): error TS1109: Expression expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(3,36): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(3,28): error TS1005: '(' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(3,36): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldAsTypeIsStrictError.ts(4,16): error TS1213: Identifier expected. 'yield' is a reserved word in strict mode. Class definitions are automatically in strict mode. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldInClassComputedPropertyIsError.ts(2,14): error TS1213: Identifier expected. 'yield' is a reserved word in strict mode. Class definitions are automatically in strict mode. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldInClassComputedPropertyIsError.ts(2,14): error TS2693: 'yield' only refers to a type, but is being used as a value here. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldInParameterInitializerIsError.ts(2,19): error TS1163: A 'yield' expression is only allowed in a generator body. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldInParameterInitializerIsError.ts(2,19): error TS2523: 'yield' expressions cannot be used in a parameter initializer. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts(2,15): error TS1138: Parameter declaration expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts(2,15): error TS2693: 'yield' only refers to a type, but is being used as a value here. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts(2,20): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts(4,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarMissingValueIsError.ts(3,16): error TS1109: Expression expected. + + +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/methodIsOk.ts (0 errors) ==== + class C1 { + async * f() { + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitMethodNameIsOk.ts (0 errors) ==== + class C2 { + async * await() { + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldMethodNameIsOk.ts (0 errors) ==== + class C3 { + async * yield() { + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts (4 errors) ==== + class C4 { + async * f(await) { + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2693: 'await' only refers to a type, but is being used as a value here. + ~ +!!! error TS1005: ';' expected. + } + } + ~ +!!! error TS1128: Declaration or statement expected. +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts (4 errors) ==== + class C5 { + async * f(yield) { + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2693: 'yield' only refers to a type, but is being used as a value here. + ~ +!!! error TS1005: ';' expected. + } + } + ~ +!!! error TS1128: Declaration or statement expected. +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitInParameterInitializerIsError.ts (1 errors) ==== + class C6 { + async * f(a = await 1) { + ~~~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldInParameterInitializerIsError.ts (2 errors) ==== + class C7 { + async * f(a = yield) { + ~~~~~ +!!! error TS1163: A 'yield' expression is only allowed in a generator body. + ~~~~~ +!!! error TS2523: 'yield' expressions cannot be used in a parameter initializer. + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedAsyncGeneratorIsOk.ts (0 errors) ==== + class C8 { + async * f() { + async function * g() { + } + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts (2 errors) ==== + class C9 { + async * f() { + function yield() { + ~~~~~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: '=>' expected. + } + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts (2 errors) ==== + class C10 { + async * f() { + const x = function yield() { + ~~~~~ +!!! error TS1005: '(' expected. + ~ +!!! error TS1005: '=>' expected. + }; + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts (3 errors) ==== + class C11 { + async * f() { + function await() { + ~~~~~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1005: ';' expected. + } + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts (3 errors) ==== + class C12 { + async * f() { + const x = function await() { + ~~~~~ +!!! error TS1005: '(' expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1005: ';' expected. + }; + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldIsOk.ts (0 errors) ==== + class C13 { + async * f() { + yield; + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldWithValueIsOk.ts (0 errors) ==== + class C14 { + async * f() { + yield 1; + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarMissingValueIsError.ts (1 errors) ==== + class C15 { + async * f() { + yield *; + ~ +!!! error TS1109: Expression expected. + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarWithValueIsOk.ts (0 errors) ==== + class C16 { + async * f() { + yield * []; + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitWithValueIsOk.ts (0 errors) ==== + class C17 { + async * f() { + await 1; + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitMissingValueIsError.ts (1 errors) ==== + class C18 { + async * f() { + await; + ~ +!!! error TS1109: Expression expected. + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitAsTypeIsOk.ts (0 errors) ==== + interface await {} + class C19 { + async * f() { + let x: await; + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldAsTypeIsStrictError.ts (1 errors) ==== + interface yield {} + class C20 { + async * f() { + let x: yield; + ~~~~~ +!!! error TS1213: Identifier expected. 'yield' is a reserved word in strict mode. Class definitions are automatically in strict mode. + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldInClassComputedPropertyIsError.ts (2 errors) ==== + class C21 { + async * [yield]() { + ~~~~~ +!!! error TS1213: Identifier expected. 'yield' is a reserved word in strict mode. Class definitions are automatically in strict mode. + ~~~~~ +!!! error TS2693: 'yield' only refers to a type, but is being used as a value here. + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldInNestedComputedPropertyIsOk.ts (0 errors) ==== + class C22 { + async * f() { + const x = { [yield]: 1 }; + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/asyncGeneratorGetAccessorIsError.ts (1 errors) ==== + class C23 { + async * get x() { + ~ +!!! error TS1005: '(' expected. + return 1; + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/asyncGeneratorSetAccessorIsError.ts (1 errors) ==== + class C24 { + async * set x(value: number) { + ~ +!!! error TS1005: '(' expected. + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/asyncGeneratorPropertyIsError.ts (1 errors) ==== + class C25 { + async * x = 1; + ~ +!!! error TS1005: '(' expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.esnext.errors.txt b/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.esnext.errors.txt new file mode 100644 index 00000000000..a80c67badd5 --- /dev/null +++ b/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.esnext.errors.txt @@ -0,0 +1,137 @@ +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitInParameterInitializerIsError.ts(1,25): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitMissingValueIsError.ts(2,10): error TS1109: Expression expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts(1,21): error TS1138: Parameter declaration expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts(1,26): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(2,14): error TS1003: Identifier expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(2,20): error TS1109: Expression expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(2,22): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(2,14): error TS1003: Identifier expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(2,22): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(2,24): error TS1005: '(' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(2,32): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(2,24): error TS1005: '(' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(2,32): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldInParameterInitializerIsError.ts(1,25): error TS2523: 'yield' expressions cannot be used in a parameter initializer. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts(1,21): error TS1138: Parameter declaration expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts(1,26): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarMissingValueIsError.ts(2,12): error TS1109: Expression expected. + + +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/functionDeclarationIsOk.ts (0 errors) ==== + async function * f1() { + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitNameIsOk.ts (0 errors) ==== + async function * await() { + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldNameIsOk.ts (0 errors) ==== + async function * yield() { + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts (2 errors) ==== + async function * f4(await) { + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~ +!!! error TS1005: ';' expected. + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts (2 errors) ==== + async function * f5(yield) { + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~ +!!! error TS1005: ';' expected. + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitInParameterInitializerIsError.ts (1 errors) ==== + async function * f6(a = await 1) { + ~~~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldInParameterInitializerIsError.ts (1 errors) ==== + async function * f7(a = yield) { + ~~~~~ +!!! error TS2523: 'yield' expressions cannot be used in a parameter initializer. + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedAsyncGeneratorIsOk.ts (0 errors) ==== + async function * f8() { + async function * g() { + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts (2 errors) ==== + async function * f9() { + function yield() { + ~~~~~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: '=>' expected. + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts (2 errors) ==== + async function * f10() { + const x = function yield() { + ~~~~~ +!!! error TS1005: '(' expected. + ~ +!!! error TS1005: '=>' expected. + }; + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts (3 errors) ==== + async function * f11() { + function await() { + ~~~~~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1005: ';' expected. + } + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts (2 errors) ==== + async function * f12() { + const x = function yield() { + ~~~~~ +!!! error TS1005: '(' expected. + ~ +!!! error TS1005: '=>' expected. + }; + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldIsOk.ts (0 errors) ==== + async function * f13() { + yield; + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldWithValueIsOk.ts (0 errors) ==== + async function * f14() { + yield 1; + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarMissingValueIsError.ts (1 errors) ==== + async function * f15() { + yield *; + ~ +!!! error TS1109: Expression expected. + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarWithValueIsOk.ts (0 errors) ==== + async function * f16() { + yield * []; + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitWithValueIsOk.ts (0 errors) ==== + async function * f17() { + await 1; + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitMissingValueIsError.ts (1 errors) ==== + async function * f18() { + await; + ~ +!!! error TS1109: Expression expected. + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitAsTypeIsOk.ts (0 errors) ==== + interface await {} + async function * f19() { + let x: await; + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldAsTypeIsOk.ts (0 errors) ==== + interface yield {} + async function * f20() { + let x: yield; + } +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldInNestedComputedPropertyIsOk.ts (0 errors) ==== + async function * f21() { + const x = { [yield]: 1 }; + } \ No newline at end of file diff --git a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.errors.txt b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.errors.txt new file mode 100644 index 00000000000..0eed47d2039 --- /dev/null +++ b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.errors.txt @@ -0,0 +1,171 @@ +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitInParameterInitializerIsError.ts(1,34): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitMissingValueIsError.ts(2,10): error TS1109: Expression expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitNameIsError.ts(1,29): error TS1005: '(' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitNameIsError.ts(1,29): error TS2451: Cannot redeclare block-scoped variable 'await'. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitNameIsError.ts(1,34): error TS1005: '=' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitNameIsError.ts(1,37): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts(1,30): error TS1138: Parameter declaration expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts(1,30): error TS2451: Cannot redeclare block-scoped variable 'await'. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts(1,35): error TS1005: ',' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(2,14): error TS1003: Identifier expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(2,20): error TS1109: Expression expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(2,22): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(2,14): error TS1003: Identifier expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(2,22): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(2,24): error TS1005: '(' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(2,30): error TS1109: Expression expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(2,32): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(2,24): error TS1005: '(' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(2,32): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldInParameterInitializerIsError.ts(1,34): error TS2523: 'yield' expressions cannot be used in a parameter initializer. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldNameIsError.ts(1,29): error TS1005: '(' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldNameIsError.ts(1,29): error TS2451: Cannot redeclare block-scoped variable 'yield'. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldNameIsError.ts(1,34): error TS1005: '=' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldNameIsError.ts(1,37): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts(1,30): error TS1138: Parameter declaration expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts(1,30): error TS2451: Cannot redeclare block-scoped variable 'yield'. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts(1,35): error TS1005: ',' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarMissingValueIsError.ts(2,12): error TS1109: Expression expected. + + +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/functionExpressionIsOk.ts (0 errors) ==== + const f1 = async function * f() { + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitNameIsError.ts (4 errors) ==== + const f2 = async function * await() { + ~~~~~ +!!! error TS1005: '(' expected. + ~~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'await'. + ~ +!!! error TS1005: '=' expected. + ~ +!!! error TS1005: '=>' expected. + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldNameIsError.ts (4 errors) ==== + const f3 = async function * yield() { + ~~~~~ +!!! error TS1005: '(' expected. + ~~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'yield'. + ~ +!!! error TS1005: '=' expected. + ~ +!!! error TS1005: '=>' expected. + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts (3 errors) ==== + const f4 = async function * (await) { + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'await'. + ~ +!!! error TS1005: ',' expected. + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts (3 errors) ==== + const f5 = async function * (yield) { + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'yield'. + ~ +!!! error TS1005: ',' expected. + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitInParameterInitializerIsError.ts (1 errors) ==== + const f6 = async function * (a = await 1) { + ~~~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldInParameterInitializerIsError.ts (1 errors) ==== + const f7 = async function * (a = yield) { + ~~~~~ +!!! error TS2523: 'yield' expressions cannot be used in a parameter initializer. + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedAsyncGeneratorIsOk.ts (0 errors) ==== + const f8 = async function * () { + async function * g() { + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts (2 errors) ==== + const f9 = async function * () { + function yield() { + ~~~~~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: '=>' expected. + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts (2 errors) ==== + const f10 = async function * () { + const x = function yield() { + ~~~~~ +!!! error TS1005: '(' expected. + ~ +!!! error TS1005: '=>' expected. + }; + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts (3 errors) ==== + const f11 = async function * () { + function await() { + ~~~~~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1005: ';' expected. + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts (3 errors) ==== + const f12 = async function * () { + const x = function await() { + ~~~~~ +!!! error TS1005: '(' expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1005: ';' expected. + }; + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldIsOk.ts (0 errors) ==== + const f13 = async function * () { + yield; + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldWithValueIsOk.ts (0 errors) ==== + const f14 = async function * () { + yield 1; + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarMissingValueIsError.ts (1 errors) ==== + const f15 = async function * () { + yield *; + ~ +!!! error TS1109: Expression expected. + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarWithValueIsOk.ts (0 errors) ==== + const f16 = async function * () { + yield * []; + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitWithValueIsOk.ts (0 errors) ==== + const f17 = async function * () { + await 1; + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitMissingValueIsError.ts (1 errors) ==== + const f18 = async function * () { + await; + ~ +!!! error TS1109: Expression expected. + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitAsTypeIsOk.ts (0 errors) ==== + interface await {} + const f19 = async function * () { + let x: await; + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldAsTypeIsOk.ts (0 errors) ==== + interface yield {} + const f20 = async function * () { + let x: yield; + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldInNestedComputedPropertyIsOk.ts (0 errors) ==== + const f21 = async function *() { + const x = { [yield]: 1 }; + }; + \ No newline at end of file diff --git a/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.esnext.errors.txt b/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.esnext.errors.txt new file mode 100644 index 00000000000..8215f418cdc --- /dev/null +++ b/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.esnext.errors.txt @@ -0,0 +1,218 @@ +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/asyncGeneratorGetAccessorIsError.ts(2,17): error TS1005: '(' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/asyncGeneratorPropertyIsError.ts(2,14): error TS1005: '(' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/asyncGeneratorSetAccessorIsError.ts(2,17): error TS1005: '(' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitInParameterInitializerIsError.ts(2,19): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitMissingValueIsError.ts(3,14): error TS1109: Expression expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts(2,15): error TS1138: Parameter declaration expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts(2,20): error TS1005: ':' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts(2,22): error TS1136: Property assignment expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts(4,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(3,18): error TS1003: Identifier expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(3,24): error TS1109: Expression expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts(3,26): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(3,18): error TS1003: Identifier expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts(3,26): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(3,28): error TS1005: '(' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(3,34): error TS1109: Expression expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts(3,36): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(3,28): error TS1005: '(' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts(3,36): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldInParameterInitializerIsError.ts(2,19): error TS2523: 'yield' expressions cannot be used in a parameter initializer. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts(2,15): error TS1138: Parameter declaration expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts(2,20): error TS1005: ':' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts(2,22): error TS1136: Property assignment expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts(4,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarMissingValueIsError.ts(3,16): error TS1109: Expression expected. + + +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/methodIsOk.ts (0 errors) ==== + const o1 = { + async * f() { + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitMethodNameIsOk.ts (0 errors) ==== + const o2 = { + async * await() { + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldMethodNameIsOk.ts (0 errors) ==== + const o3 = { + async * yield() { + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts (4 errors) ==== + const o4 = { + async * f(await) { + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~ +!!! error TS1005: ':' expected. + ~ +!!! error TS1136: Property assignment expected. + } + }; + ~ +!!! error TS1128: Declaration or statement expected. +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts (4 errors) ==== + const o5 = { + async * f(yield) { + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~ +!!! error TS1005: ':' expected. + ~ +!!! error TS1136: Property assignment expected. + } + }; + ~ +!!! error TS1128: Declaration or statement expected. +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitInParameterInitializerIsError.ts (1 errors) ==== + const o6 = { + async * f(a = await 1) { + ~~~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldInParameterInitializerIsError.ts (1 errors) ==== + const o7 = { + async * f(a = yield) { + ~~~~~ +!!! error TS2523: 'yield' expressions cannot be used in a parameter initializer. + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedAsyncGeneratorIsOk.ts (0 errors) ==== + const o8 = { + async * f() { + async function * g() { + } + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts (2 errors) ==== + const o9 = { + async * f() { + function yield() { + ~~~~~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: '=>' expected. + } + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts (2 errors) ==== + const o10 = { + async * f() { + const x = function yield() { + ~~~~~ +!!! error TS1005: '(' expected. + ~ +!!! error TS1005: '=>' expected. + }; + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts (3 errors) ==== + const o11 = { + async * f() { + function await() { + ~~~~~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1005: ';' expected. + } + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts (3 errors) ==== + const o12 = { + async * f() { + const x = function await() { + ~~~~~ +!!! error TS1005: '(' expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1005: ';' expected. + }; + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldIsOk.ts (0 errors) ==== + const o13 = { + async * f() { + yield; + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldWithValueIsOk.ts (0 errors) ==== + const o14 = { + async * f() { + yield 1; + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarMissingValueIsError.ts (1 errors) ==== + const o15 = { + async * f() { + yield *; + ~ +!!! error TS1109: Expression expected. + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarWithValueIsOk.ts (0 errors) ==== + const o16 = { + async * f() { + yield * []; + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitWithValueIsOk.ts (0 errors) ==== + const o17 = { + async * f() { + await 1; + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitMissingValueIsError.ts (1 errors) ==== + const o18 = { + async * f() { + await; + ~ +!!! error TS1109: Expression expected. + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitAsTypeIsOk.ts (0 errors) ==== + interface await {} + const o19 = { + async * f() { + let x: await; + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldAsTypeIsOk.ts (0 errors) ==== + interface yield {} + const o20 = { + async * f() { + let x: yield; + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldInNestedComputedPropertyIsOk.ts (0 errors) ==== + const o21 = { + async * f() { + const x = { [yield]: 1 }; + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/asyncGeneratorGetAccessorIsError.ts (1 errors) ==== + const o22 = { + async * get x() { + ~ +!!! error TS1005: '(' expected. + return 1; + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/asyncGeneratorSetAccessorIsError.ts (1 errors) ==== + const o23 = { + async * set x(value: number) { + ~ +!!! error TS1005: '(' expected. + } + }; +==== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/asyncGeneratorPropertyIsError.ts (1 errors) ==== + const o24 = { + async * x: 1; + ~ +!!! error TS1005: '(' expected. + }; \ No newline at end of file diff --git a/tests/baselines/reference/parser.forAwait.esnext.errors.txt b/tests/baselines/reference/parser.forAwait.esnext.errors.txt new file mode 100644 index 00000000000..44dfd947b56 --- /dev/null +++ b/tests/baselines/reference/parser.forAwait.esnext.errors.txt @@ -0,0 +1,104 @@ +tests/cases/conformance/parser/ecmascriptnext/forAwait/forAwaitInWithDeclIsError.ts(1,20): error TS1005: 'of' expected. +tests/cases/conformance/parser/ecmascriptnext/forAwait/forAwaitInWithDeclIsError.ts(1,23): error TS2304: Cannot find name 'y'. +tests/cases/conformance/parser/ecmascriptnext/forAwait/forAwaitInWithExprIsError.ts(1,12): error TS2304: Cannot find name 'x'. +tests/cases/conformance/parser/ecmascriptnext/forAwait/forAwaitInWithExprIsError.ts(1,14): error TS1005: 'of' expected. +tests/cases/conformance/parser/ecmascriptnext/forAwait/forAwaitInWithExprIsError.ts(1,17): error TS2304: Cannot find name 'y'. +tests/cases/conformance/parser/ecmascriptnext/forAwait/inFunctionDeclWithDeclIsError.ts(3,9): error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +tests/cases/conformance/parser/ecmascriptnext/forAwait/inFunctionDeclWithExprIsError.ts(3,9): error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +tests/cases/conformance/parser/ecmascriptnext/forAwait/inGeneratorWithDeclIsError.ts(3,9): error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +tests/cases/conformance/parser/ecmascriptnext/forAwait/inGeneratorWithExprIsError.ts(3,9): error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +tests/cases/conformance/parser/ecmascriptnext/forAwait/topLevelWithDeclIsError.ts(1,5): error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +tests/cases/conformance/parser/ecmascriptnext/forAwait/topLevelWithDeclIsError.ts(1,23): error TS2304: Cannot find name 'y'. +tests/cases/conformance/parser/ecmascriptnext/forAwait/topLevelWithExprIsError.ts(1,5): error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. +tests/cases/conformance/parser/ecmascriptnext/forAwait/topLevelWithExprIsError.ts(1,12): error TS2304: Cannot find name 'x'. +tests/cases/conformance/parser/ecmascriptnext/forAwait/topLevelWithExprIsError.ts(1,17): error TS2304: Cannot find name 'y'. + + +==== tests/cases/conformance/parser/ecmascriptnext/forAwait/topLevelWithDeclIsError.ts (2 errors) ==== + for await (const x of y) { + ~~~~~ +!!! error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. + ~ +!!! error TS2304: Cannot find name 'y'. + } +==== tests/cases/conformance/parser/ecmascriptnext/forAwait/topLevelWithExprIsError.ts (3 errors) ==== + for await (x of y) { + ~~~~~ +!!! error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. + ~ +!!! error TS2304: Cannot find name 'x'. + ~ +!!! error TS2304: Cannot find name 'y'. + } +==== tests/cases/conformance/parser/ecmascriptnext/forAwait/forAwaitInWithDeclIsError.ts (2 errors) ==== + for await (const x in y) { + ~~ +!!! error TS1005: 'of' expected. + ~ +!!! error TS2304: Cannot find name 'y'. + } +==== tests/cases/conformance/parser/ecmascriptnext/forAwait/forAwaitInWithExprIsError.ts (3 errors) ==== + for await (x in y) { + ~ +!!! error TS2304: Cannot find name 'x'. + ~~ +!!! error TS1005: 'of' expected. + ~ +!!! error TS2304: Cannot find name 'y'. + } +==== tests/cases/conformance/parser/ecmascriptnext/forAwait/inFunctionDeclWithDeclIsError.ts (1 errors) ==== + function f5() { + let y: any; + for await (const x of y) { + ~~~~~ +!!! error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. + } + } +==== tests/cases/conformance/parser/ecmascriptnext/forAwait/inFunctionDeclWithExprIsError.ts (1 errors) ==== + function f6() { + let x: any, y: any; + for await (x of y) { + ~~~~~ +!!! error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. + } + } +==== tests/cases/conformance/parser/ecmascriptnext/forAwait/inAsyncFunctionWithDeclIsOk.ts (0 errors) ==== + async function f7() { + let y: any; + for await (const x of y) { + } + } +==== tests/cases/conformance/parser/ecmascriptnext/forAwait/inAsyncFunctionWithExprIsOk.ts (0 errors) ==== + async function f8() { + let x: any, y: any; + for await (x of y) { + } + } +==== tests/cases/conformance/parser/ecmascriptnext/forAwait/inAsyncGeneratorWithDeclIsOk.ts (0 errors) ==== + async function* f9() { + let y: any; + for await (const x of y) { + } + } +==== tests/cases/conformance/parser/ecmascriptnext/forAwait/inAsyncGeneratorWithExpressionIsOk.ts (0 errors) ==== + async function* f10() { + let x: any, y: any; + for await (x of y) { + } + } +==== tests/cases/conformance/parser/ecmascriptnext/forAwait/inGeneratorWithDeclIsError.ts (1 errors) ==== + function* f11() { + let y: any; + for await (const x of y) { + ~~~~~ +!!! error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. + } + } +==== tests/cases/conformance/parser/ecmascriptnext/forAwait/inGeneratorWithExprIsError.ts (1 errors) ==== + function* f12() { + let x: any, y: any; + for await (x of y) { + ~~~~~ +!!! error TS1103: A 'for-await-of' statement is only allowed within an async function or async generator. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/parser0_004152.js b/tests/baselines/reference/parser0_004152.js index 333b64811c8..b4443e04136 100644 --- a/tests/baselines/reference/parser0_004152.js +++ b/tests/baselines/reference/parser0_004152.js @@ -6,6 +6,7 @@ export class Game { //// [parser0_004152.js] "use strict"; +exports.__esModule = true; var Game = (function () { function Game() { this.position = new DisplayPosition([]); diff --git a/tests/baselines/reference/parser509546.js b/tests/baselines/reference/parser509546.js index ceaf9b3572c..e99d1d1764d 100644 --- a/tests/baselines/reference/parser509546.js +++ b/tests/baselines/reference/parser509546.js @@ -6,6 +6,7 @@ export class Logger { //// [parser509546.js] "use strict"; +exports.__esModule = true; var Logger = (function () { function Logger() { } diff --git a/tests/baselines/reference/parser509546_1.js b/tests/baselines/reference/parser509546_1.js index 9d07172c509..3fc82755fbf 100644 --- a/tests/baselines/reference/parser509546_1.js +++ b/tests/baselines/reference/parser509546_1.js @@ -6,6 +6,7 @@ export class Logger { //// [parser509546_1.js] "use strict"; +exports.__esModule = true; var Logger = (function () { function Logger() { } diff --git a/tests/baselines/reference/parser509546_2.js b/tests/baselines/reference/parser509546_2.js index b8822b52541..c16f041b2db 100644 --- a/tests/baselines/reference/parser509546_2.js +++ b/tests/baselines/reference/parser509546_2.js @@ -8,6 +8,7 @@ export class Logger { //// [parser509546_2.js] "use strict"; +exports.__esModule = true; var Logger = (function () { function Logger() { } diff --git a/tests/baselines/reference/parser509630.js b/tests/baselines/reference/parser509630.js index d3648dc5b64..8b963bf0674 100644 --- a/tests/baselines/reference/parser509630.js +++ b/tests/baselines/reference/parser509630.js @@ -7,11 +7,16 @@ class Any extends Type { //// [parser509630.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Type = (function () { function Type() { this.examples = []; // typing here @@ -21,7 +26,7 @@ var Type = (function () { var Any = (function (_super) { __extends(Any, _super); function Any() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Any; }(Type)); diff --git a/tests/baselines/reference/parser618973.js b/tests/baselines/reference/parser618973.js index df9b2e4433a..bfef06b061f 100644 --- a/tests/baselines/reference/parser618973.js +++ b/tests/baselines/reference/parser618973.js @@ -6,6 +6,7 @@ export export class Foo { //// [parser618973.js] "use strict"; +exports.__esModule = true; var Foo = (function () { function Foo() { } diff --git a/tests/baselines/reference/parserArgumentList1.js b/tests/baselines/reference/parserArgumentList1.js index 222b2c5ac89..36c8f619235 100644 --- a/tests/baselines/reference/parserArgumentList1.js +++ b/tests/baselines/reference/parserArgumentList1.js @@ -7,6 +7,7 @@ export function removeClass (node:HTMLElement, className:string) { //// [parserArgumentList1.js] "use strict"; +exports.__esModule = true; function removeClass(node, className) { node.className = node.className.replace(_classNameRegexp(className), function (everything, leftDelimiter, name, rightDelimiter) { return leftDelimiter.length + rightDelimiter.length === 2 ? ' ' : ''; diff --git a/tests/baselines/reference/parserAstSpans1.js b/tests/baselines/reference/parserAstSpans1.js index 6b86353b959..ed4943046fa 100644 --- a/tests/baselines/reference/parserAstSpans1.js +++ b/tests/baselines/reference/parserAstSpans1.js @@ -220,11 +220,16 @@ class c6 extends c5 { } //// [parserAstSpans1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var c1 = (function () { function c1() { } @@ -363,7 +368,7 @@ c2_i.nc_f1(); var c4 = (function (_super) { __extends(c4, _super); function c4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return c4; }(c2)); diff --git a/tests/baselines/reference/parserClass1.js b/tests/baselines/reference/parserClass1.js index 50d2fb179dc..7fcbf29f242 100644 --- a/tests/baselines/reference/parserClass1.js +++ b/tests/baselines/reference/parserClass1.js @@ -11,6 +11,7 @@ //// [parserClass1.js] "use strict"; +exports.__esModule = true; var NullLogger = (function () { function NullLogger() { } diff --git a/tests/baselines/reference/parserClass2.js b/tests/baselines/reference/parserClass2.js index c1d3b87e892..0d47a388acc 100644 --- a/tests/baselines/reference/parserClass2.js +++ b/tests/baselines/reference/parserClass2.js @@ -9,6 +9,7 @@ //// [parserClass2.js] "use strict"; +exports.__esModule = true; var LoggerAdapter = (function () { function LoggerAdapter(logger) { this.logger = logger; diff --git a/tests/baselines/reference/parserClassDeclaration1.js b/tests/baselines/reference/parserClassDeclaration1.js index a61b492b7a9..85fe94e04cc 100644 --- a/tests/baselines/reference/parserClassDeclaration1.js +++ b/tests/baselines/reference/parserClassDeclaration1.js @@ -3,15 +3,20 @@ class C extends A extends B { } //// [parserClassDeclaration1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parserClassDeclaration3.js b/tests/baselines/reference/parserClassDeclaration3.js index f58f0ab00cb..d627784985d 100644 --- a/tests/baselines/reference/parserClassDeclaration3.js +++ b/tests/baselines/reference/parserClassDeclaration3.js @@ -3,15 +3,20 @@ class C implements A extends B { } //// [parserClassDeclaration3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(B)); diff --git a/tests/baselines/reference/parserClassDeclaration4.js b/tests/baselines/reference/parserClassDeclaration4.js index 912aa8c6581..318833c5e91 100644 --- a/tests/baselines/reference/parserClassDeclaration4.js +++ b/tests/baselines/reference/parserClassDeclaration4.js @@ -3,15 +3,20 @@ class C extends A implements B extends C { } //// [parserClassDeclaration4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parserClassDeclaration5.js b/tests/baselines/reference/parserClassDeclaration5.js index 054aaf0eb7a..e5b2c337214 100644 --- a/tests/baselines/reference/parserClassDeclaration5.js +++ b/tests/baselines/reference/parserClassDeclaration5.js @@ -3,15 +3,20 @@ class C extends A implements B implements C { } //// [parserClassDeclaration5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parserClassDeclaration6.js b/tests/baselines/reference/parserClassDeclaration6.js index 1423edfe037..0d6049c9ba9 100644 --- a/tests/baselines/reference/parserClassDeclaration6.js +++ b/tests/baselines/reference/parserClassDeclaration6.js @@ -3,15 +3,20 @@ class C extends A, B { } //// [parserClassDeclaration6.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parserEnum1.js b/tests/baselines/reference/parserEnum1.js index d2c29d847cd..43cdc626ab8 100644 --- a/tests/baselines/reference/parserEnum1.js +++ b/tests/baselines/reference/parserEnum1.js @@ -10,6 +10,7 @@ //// [parserEnum1.js] "use strict"; +exports.__esModule = true; var SignatureFlags; (function (SignatureFlags) { SignatureFlags[SignatureFlags["None"] = 0] = "None"; diff --git a/tests/baselines/reference/parserEnum2.js b/tests/baselines/reference/parserEnum2.js index f5888addf75..0fa0633d280 100644 --- a/tests/baselines/reference/parserEnum2.js +++ b/tests/baselines/reference/parserEnum2.js @@ -10,6 +10,7 @@ //// [parserEnum2.js] "use strict"; +exports.__esModule = true; var SignatureFlags; (function (SignatureFlags) { SignatureFlags[SignatureFlags["None"] = 0] = "None"; diff --git a/tests/baselines/reference/parserEnum3.js b/tests/baselines/reference/parserEnum3.js index 602171e8d94..b9b9e743e4b 100644 --- a/tests/baselines/reference/parserEnum3.js +++ b/tests/baselines/reference/parserEnum3.js @@ -6,6 +6,7 @@ //// [parserEnum3.js] "use strict"; +exports.__esModule = true; var SignatureFlags; (function (SignatureFlags) { })(SignatureFlags = exports.SignatureFlags || (exports.SignatureFlags = {})); diff --git a/tests/baselines/reference/parserEnum4.js b/tests/baselines/reference/parserEnum4.js index 6af07b0a1c7..96d3c8757ed 100644 --- a/tests/baselines/reference/parserEnum4.js +++ b/tests/baselines/reference/parserEnum4.js @@ -7,6 +7,7 @@ //// [parserEnum4.js] "use strict"; +exports.__esModule = true; var SignatureFlags; (function (SignatureFlags) { })(SignatureFlags = exports.SignatureFlags || (exports.SignatureFlags = {})); diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js index aa0679bb8f5..30f2e7f5698 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js @@ -3,15 +3,20 @@ class C extends A, { } //// [parserErrorRecovery_ExtendsOrImplementsClause2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js index 1308c7c194b..42947c5fcb8 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js @@ -3,15 +3,20 @@ class C extends A implements { } //// [parserErrorRecovery_ExtendsOrImplementsClause4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js index b1471628fbd..1e62709949d 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js @@ -3,15 +3,20 @@ class C extends A, implements B, { } //// [parserErrorRecovery_ExtendsOrImplementsClause5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parserGenericsInTypeContexts1.js b/tests/baselines/reference/parserGenericsInTypeContexts1.js index 641d296dc43..ef5452a1638 100644 --- a/tests/baselines/reference/parserGenericsInTypeContexts1.js +++ b/tests/baselines/reference/parserGenericsInTypeContexts1.js @@ -18,15 +18,20 @@ function f2(): F { //// [parserGenericsInTypeContexts1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parserGenericsInTypeContexts2.js b/tests/baselines/reference/parserGenericsInTypeContexts2.js index b0f14a090ae..9302db655bf 100644 --- a/tests/baselines/reference/parserGenericsInTypeContexts2.js +++ b/tests/baselines/reference/parserGenericsInTypeContexts2.js @@ -18,15 +18,20 @@ function f2(): F, Y>> { //// [parserGenericsInTypeContexts2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/parserInterfaceDeclaration6.js b/tests/baselines/reference/parserInterfaceDeclaration6.js index 1ec3325de34..cbc734b534c 100644 --- a/tests/baselines/reference/parserInterfaceDeclaration6.js +++ b/tests/baselines/reference/parserInterfaceDeclaration6.js @@ -4,3 +4,4 @@ export export interface I { //// [parserInterfaceDeclaration6.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/parserInterfaceDeclaration7.js b/tests/baselines/reference/parserInterfaceDeclaration7.js index eed874db143..0c52f4639ce 100644 --- a/tests/baselines/reference/parserInterfaceDeclaration7.js +++ b/tests/baselines/reference/parserInterfaceDeclaration7.js @@ -4,3 +4,4 @@ export interface I { //// [parserInterfaceDeclaration7.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/parserModifierOnStatementInBlock1.js b/tests/baselines/reference/parserModifierOnStatementInBlock1.js index 352ee0cc511..43c1e4bf845 100644 --- a/tests/baselines/reference/parserModifierOnStatementInBlock1.js +++ b/tests/baselines/reference/parserModifierOnStatementInBlock1.js @@ -6,6 +6,7 @@ export function foo() { //// [parserModifierOnStatementInBlock1.js] "use strict"; +exports.__esModule = true; function foo() { export var x = this; } diff --git a/tests/baselines/reference/parserModifierOnStatementInBlock3.js b/tests/baselines/reference/parserModifierOnStatementInBlock3.js index 9f2cdf6850f..85c3d6da0a4 100644 --- a/tests/baselines/reference/parserModifierOnStatementInBlock3.js +++ b/tests/baselines/reference/parserModifierOnStatementInBlock3.js @@ -7,6 +7,7 @@ export function foo() { //// [parserModifierOnStatementInBlock3.js] "use strict"; +exports.__esModule = true; function foo() { export function bar() { } diff --git a/tests/baselines/reference/parserModule1.js b/tests/baselines/reference/parserModule1.js index 749715a39d1..484c74f721c 100644 --- a/tests/baselines/reference/parserModule1.js +++ b/tests/baselines/reference/parserModule1.js @@ -33,6 +33,7 @@ //// [parserModule1.js] "use strict"; +exports.__esModule = true; var CompilerDiagnostics; (function (CompilerDiagnostics) { CompilerDiagnostics.debug = false; diff --git a/tests/baselines/reference/parserRealSource10.js b/tests/baselines/reference/parserRealSource10.js index 11cfbdfa1f2..0d42dc5f47b 100644 --- a/tests/baselines/reference/parserRealSource10.js +++ b/tests/baselines/reference/parserRealSource10.js @@ -458,11 +458,16 @@ module TypeScript { //// [parserRealSource10.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); /// var TypeScript; (function (TypeScript) { diff --git a/tests/baselines/reference/parserRealSource11.js b/tests/baselines/reference/parserRealSource11.js index eb05d13f4ed..0d942cb1c68 100644 --- a/tests/baselines/reference/parserRealSource11.js +++ b/tests/baselines/reference/parserRealSource11.js @@ -2367,11 +2367,16 @@ module TypeScript { //// [parserRealSource11.js] // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. -var __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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); /// var TypeScript; (function (TypeScript) { diff --git a/tests/baselines/reference/parserRealSource14.js b/tests/baselines/reference/parserRealSource14.js index 907efc6f26a..635d122db04 100644 --- a/tests/baselines/reference/parserRealSource14.js +++ b/tests/baselines/reference/parserRealSource14.js @@ -1011,6 +1011,7 @@ var TypeScript; ctx.path.push(cur); } else { + //logger.log("TODO: Ignoring node because minChar, limChar not better than previous node in stack"); } } // The AST walker skips comments, but we might be in one, so check the pre/post comments for this node manually diff --git a/tests/baselines/reference/parserharness.js b/tests/baselines/reference/parserharness.js index 14ce4338176..5090c33bdc8 100644 --- a/tests/baselines/reference/parserharness.js +++ b/tests/baselines/reference/parserharness.js @@ -2096,11 +2096,16 @@ module Harness { // See the License for the specific language governing permissions and // limitations under the License. // -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); /// /// /// diff --git a/tests/baselines/reference/partiallyAnnotatedFunctionInferenceError.js b/tests/baselines/reference/partiallyAnnotatedFunctionInferenceError.js index 9702595fffb..88439493a50 100644 --- a/tests/baselines/reference/partiallyAnnotatedFunctionInferenceError.js +++ b/tests/baselines/reference/partiallyAnnotatedFunctionInferenceError.js @@ -16,11 +16,16 @@ testError((t1, t2, t3: D) => {}) //// [partiallyAnnotatedFunctionInferenceError.js] -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -29,7 +34,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.js b/tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.js index d20b35625e9..6a46935b224 100644 --- a/tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.js +++ b/tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.js @@ -35,11 +35,16 @@ testRest((t2, ...t3: D[]) => {}) //// [partiallyAnnotatedFunctionInferenceWithTypeParameter.js] -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -48,7 +53,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution1_classic.js b/tests/baselines/reference/pathMappingBasedModuleResolution1_classic.js index 1a1bd387dce..e8c026429f1 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution1_classic.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution1_classic.js @@ -5,5 +5,6 @@ export var x = 1; //// [f1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.x = 1; }); diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution1_node.js b/tests/baselines/reference/pathMappingBasedModuleResolution1_node.js index 5fcaa23b976..6439d35aadf 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution1_node.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution1_node.js @@ -4,4 +4,5 @@ export var x = 1; //// [f1.js] "use strict"; +exports.__esModule = true; exports.x = 1; diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution2_classic.js b/tests/baselines/reference/pathMappingBasedModuleResolution2_classic.js index 52dab845bb2..df5115d5360 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution2_classic.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution2_classic.js @@ -4,5 +4,6 @@ export var x = 1; //// [file1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.x = 1; }); diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution2_node.js b/tests/baselines/reference/pathMappingBasedModuleResolution2_node.js index 8c8b5c9a926..a0c8d5df7de 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution2_node.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution2_node.js @@ -3,4 +3,5 @@ export var x = 1; //// [file1.js] "use strict"; +exports.__esModule = true; exports.x = 1; diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution3_classic.js b/tests/baselines/reference/pathMappingBasedModuleResolution3_classic.js index 15867b085ea..8809efa963a 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution3_classic.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution3_classic.js @@ -22,21 +22,25 @@ export var y = 100; //// [file3.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.x = 1; }); //// [file4.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.y = 100; }); //// [file2.js] define(["require", "exports", "./file3", "file4"], function (require, exports, file3_1, file4_1) { "use strict"; + exports.__esModule = true; exports.x = file3_1.x + file4_1.y; }); //// [file1.js] // baseUrl set via command line define(["require", "exports", "folder2/file2"], function (require, exports, file2_1) { "use strict"; + exports.__esModule = true; use(file2_1.x.toExponential()); }); diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution3_node.js b/tests/baselines/reference/pathMappingBasedModuleResolution3_node.js index cbff6087530..cd0eb7d7794 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution3_node.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution3_node.js @@ -21,14 +21,17 @@ export var y: number; //// [file3.js] "use strict"; +exports.__esModule = true; exports.x = 1; //// [file2.js] "use strict"; +exports.__esModule = true; var file3_1 = require("./file3"); // found with baseurl var file4_1 = require("file4"); // found with fallback exports.x = file3_1.x + file4_1.y; //// [file1.js] // baseUrl set via command line "use strict"; +exports.__esModule = true; var file2_1 = require("folder2/file2"); use(file2_1.x.toExponential()); diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution4_classic.js b/tests/baselines/reference/pathMappingBasedModuleResolution4_classic.js index c1de8cea6c9..2a8254fb696 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution4_classic.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution4_classic.js @@ -19,20 +19,24 @@ export var y = 100; //// [file3.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.x = 1; }); //// [file4.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.y = 100; }); //// [file2.js] define(["require", "exports", "./file3", "file4"], function (require, exports, file3_1, file4_1) { "use strict"; + exports.__esModule = true; exports.x = file3_1.x + file4_1.y; }); //// [file1.js] define(["require", "exports", "folder2/file2"], function (require, exports, file2_1) { "use strict"; + exports.__esModule = true; use(file2_1.x.toExponential()); }); diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution4_node.js b/tests/baselines/reference/pathMappingBasedModuleResolution4_node.js index c5a08d55d8b..ff1a51662b0 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution4_node.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution4_node.js @@ -18,13 +18,16 @@ export var y: number; //// [file3.js] "use strict"; +exports.__esModule = true; exports.x = 1; //// [file2.js] "use strict"; +exports.__esModule = true; var file3_1 = require("./file3"); // found with baseurl var file4_1 = require("file4"); // found with fallback exports.x = file3_1.x + file4_1.y; //// [file1.js] "use strict"; +exports.__esModule = true; var file2_1 = require("folder2/file2"); use(file2_1.x.toExponential()); diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution5_classic.js b/tests/baselines/reference/pathMappingBasedModuleResolution5_classic.js index 24297f85e35..1b9782660d8 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution5_classic.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution5_classic.js @@ -28,26 +28,31 @@ export var z1 = 1; //// [file1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.x = 1; }); //// [file2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.y = 1; }); //// [file3.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.z = 1; }); //// [file4.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.z1 = 1; }); //// [file1.js] define(["require", "exports", "folder2/file1", "folder3/file2", "components/file3", "file4"], function (require, exports, file1_1, file2_1, file3_1, file4_1) { "use strict"; + exports.__esModule = true; use(file1_1.x.toExponential()); use(file2_1.y.toExponential()); use(file3_1.z.toExponential()); diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js b/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js index 1958800f918..7d10c4d4a8b 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js @@ -27,15 +27,19 @@ export var z1 = 1; //// [file1.js] "use strict"; +exports.__esModule = true; exports.x = 1; //// [file2.js] "use strict"; +exports.__esModule = true; exports.y = 1; //// [file4.js] "use strict"; +exports.__esModule = true; exports.z1 = 1; //// [file1.js] "use strict"; +exports.__esModule = true; var file1_1 = require("folder2/file1"); var file2_1 = require("folder3/file2"); var file3_1 = require("components/file3"); diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution6_classic.js b/tests/baselines/reference/pathMappingBasedModuleResolution6_classic.js index 1e8f8807e2c..3289efd0209 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution6_classic.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution6_classic.js @@ -14,10 +14,12 @@ export {x} from "../file2"; //// [file3.js] define(["require", "exports", "../file2"], function (require, exports, file2_1) { "use strict"; + exports.__esModule = true; exports.x = file2_1.x; }); //// [file1.js] define(["require", "exports", "./project/file3"], function (require, exports, file3_1) { "use strict"; + exports.__esModule = true; use(file3_1.x.toExponential()); }); diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution6_node.js b/tests/baselines/reference/pathMappingBasedModuleResolution6_node.js index 6db3fecf83f..74c0f40758a 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution6_node.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution6_node.js @@ -13,9 +13,11 @@ export {x} from "../file2"; //// [file3.js] "use strict"; +exports.__esModule = true; var file2_1 = require("../file2"); exports.x = file2_1.x; //// [file1.js] "use strict"; +exports.__esModule = true; var file3_1 = require("./project/file3"); use(file3_1.x.toFixed()); diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution7_classic.js b/tests/baselines/reference/pathMappingBasedModuleResolution7_classic.js index 5670f41be0f..55aca054e82 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution7_classic.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution7_classic.js @@ -31,15 +31,18 @@ export let y: number; //// [module2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [file2.js] define(["require", "exports", "module1", "templates/module2", "../file3"], function (require, exports, module1_1, module2_1, file3_1) { "use strict"; + exports.__esModule = true; exports.x = module1_1.a + module2_1.b + file3_1.x; }); //// [file1.js] define(["require", "exports", "./project/file2", "module3"], function (require, exports, file2_1, module3_1) { "use strict"; + exports.__esModule = true; use(file2_1.x.toFixed()); use(module3_1.y.toFixed()); }); diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution7_node.js b/tests/baselines/reference/pathMappingBasedModuleResolution7_node.js index 3be48cfc85c..303b98f4d83 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution7_node.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution7_node.js @@ -30,14 +30,17 @@ export let y: number; //// [module2.js] "use strict"; +exports.__esModule = true; //// [file2.js] "use strict"; +exports.__esModule = true; var module1_1 = require("module1"); var module2_1 = require("templates/module2"); var file3_1 = require("../file3"); exports.x = module1_1.a + module2_1.b + file3_1.x; //// [file1.js] "use strict"; +exports.__esModule = true; var file2_1 = require("./project/file2"); var module3_1 = require("module3"); use(file2_1.x.toFixed()); diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension.js b/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension.js index 06f6b50e4a0..a91cc9d8d5a 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension.js @@ -14,11 +14,14 @@ import { bar } from "bar"; //// [foo.js] "use strict"; +exports.__esModule = true; function foo() { } exports.foo = foo; //// [bar.js] "use strict"; +exports.__esModule = true; function bar() { } exports.bar = bar; //// [a.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_failedLookup.js b/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_failedLookup.js index 1774876911f..4fded4a78ad 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_failedLookup.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_failedLookup.js @@ -5,3 +5,4 @@ import { foo } from "foo"; //// [a.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/plusOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/plusOperatorWithAnyOtherType.errors.txt index 6c0f113b17b..d693aaa17d9 100644 --- a/tests/baselines/reference/plusOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/plusOperatorWithAnyOtherType.errors.txt @@ -1,10 +1,15 @@ -tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(46,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(47,26): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(48,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(34,24): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(35,24): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(46,26): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(46,33): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(47,26): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(47,33): error TS2531: Object is possibly 'null'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(48,26): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(48,38): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(54,1): error TS2695: Left side of comma operator is unused and has no side effects. -==== tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts (4 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts (9 errors) ==== // + operator on any type var ANY: any; @@ -39,7 +44,11 @@ tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWith // any type literal var ResultIsNumber7 = +undefined; + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber8 = +null; + ~~~~ +!!! error TS2531: Object is possibly 'null'. // any type expressions var ResultIsNumber9 = +ANY2[0]; @@ -51,14 +60,20 @@ tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWith var ResultIsNumber15 = +A.foo(); var ResultIsNumber16 = +(ANY + ANY1); var ResultIsNumber17 = +(null + undefined); - ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. var ResultIsNumber18 = +(null + null); - ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. + ~~~~ +!!! error TS2531: Object is possibly 'null'. var ResultIsNumber19 = +(undefined + undefined); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. // miss assignment operators +ANY; diff --git a/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.types b/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.types index 4e4dbe93372..41df41af51b 100644 --- a/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.types +++ b/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.types @@ -39,7 +39,7 @@ if (void x) { } if (typeof x) { ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : false } diff --git a/tests/baselines/reference/prespecializedGenericMembers1.js b/tests/baselines/reference/prespecializedGenericMembers1.js index dd6bd2a2dc6..f7e41263237 100644 --- a/tests/baselines/reference/prespecializedGenericMembers1.js +++ b/tests/baselines/reference/prespecializedGenericMembers1.js @@ -22,6 +22,7 @@ var catBag = new CatBag(catThing); //// [prespecializedGenericMembers1.js] "use strict"; +exports.__esModule = true; var Cat = (function () { function Cat() { } diff --git a/tests/baselines/reference/primitiveMembers.js b/tests/baselines/reference/primitiveMembers.js index 7b94b555eb1..163c5c8873d 100644 --- a/tests/baselines/reference/primitiveMembers.js +++ b/tests/baselines/reference/primitiveMembers.js @@ -32,11 +32,16 @@ class foo extends baz { public bar(){ return undefined}; } //// [primitiveMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var x = 5; var r = /yo/; r.source; @@ -63,7 +68,7 @@ var baz = (function () { var foo = (function (_super) { __extends(foo, _super); function foo() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } foo.prototype.bar = function () { return undefined; }; ; diff --git a/tests/baselines/reference/printerApi/printsBundleCorrectly.default.js b/tests/baselines/reference/printerApi/printsBundleCorrectly.default.js new file mode 100644 index 00000000000..2d86cc0c09c --- /dev/null +++ b/tests/baselines/reference/printerApi/printsBundleCorrectly.default.js @@ -0,0 +1,6 @@ +/*! [a.ts] */ +// comment0 +const a = 1; +/*! [b.ts] */ +// comment1 +const b = 2; diff --git a/tests/baselines/reference/printerApi/printsBundleCorrectly.removeComments.js b/tests/baselines/reference/printerApi/printsBundleCorrectly.removeComments.js new file mode 100644 index 00000000000..22b03719cf3 --- /dev/null +++ b/tests/baselines/reference/printerApi/printsBundleCorrectly.removeComments.js @@ -0,0 +1,4 @@ +/*! [a.ts] */ +const a = 1; +/*! [b.ts] */ +const b = 2; diff --git a/tests/baselines/reference/printerApi/printsFileCorrectly.default.js b/tests/baselines/reference/printerApi/printsFileCorrectly.default.js new file mode 100644 index 00000000000..9bff9d656b3 --- /dev/null +++ b/tests/baselines/reference/printerApi/printsFileCorrectly.default.js @@ -0,0 +1,25 @@ +interface A { + // comment1 + readonly prop?: T; + // comment2 + method(): void; + // comment3 + new (): A; + // comment4 + (): A; +} +// comment5 +type B = number | string | object; +type C = A & { + x: string; +}; // comment6 +// comment7 +enum E1 { + // comment8 + first +} +const enum E2 { + second +} +// comment9 +console.log(1 + 2); diff --git a/tests/baselines/reference/printerApi/printsFileCorrectly.removeComments.js b/tests/baselines/reference/printerApi/printsFileCorrectly.removeComments.js new file mode 100644 index 00000000000..b511aff5e78 --- /dev/null +++ b/tests/baselines/reference/printerApi/printsFileCorrectly.removeComments.js @@ -0,0 +1,17 @@ +interface A { + readonly prop?: T; + method(): void; + new (): A; + (): A; +} +type B = number | string | object; +type C = A & { + x: string; +}; +enum E1 { + first +} +const enum E2 { + second +} +console.log(1 + 2); diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.class.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.class.js new file mode 100644 index 00000000000..fa19e836fed --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.class.js @@ -0,0 +1,3 @@ +class C { + public prop; +} \ No newline at end of file diff --git a/tests/baselines/reference/privacyAccessorDeclFile.js b/tests/baselines/reference/privacyAccessorDeclFile.js index 6fed8b8f082..9d077d19e06 100644 --- a/tests/baselines/reference/privacyAccessorDeclFile.js +++ b/tests/baselines/reference/privacyAccessorDeclFile.js @@ -1061,6 +1061,7 @@ module publicModuleInGlobal { //// [privacyAccessorDeclFile_externalModule.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var privateClass = (function () { function privateClass() { } diff --git a/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js b/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js index 4121dbdd51d..d19869b0f03 100644 --- a/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js +++ b/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js @@ -139,6 +139,7 @@ class privateClassWithPrivateModuleGetAccessorTypes { //// [privacyCannotNameAccessorDeclFile_GlobalWidgets.js] //// [privacyCannotNameAccessorDeclFile_Widgets.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var Widget1 = (function () { function Widget1() { this.name = 'one'; @@ -166,6 +167,7 @@ var SpecializedWidget; })(SpecializedWidget = exports.SpecializedWidget || (exports.SpecializedWidget = {})); //// [privacyCannotNameAccessorDeclFile_exporter.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); /// var Widgets = require("./privacyCannotNameAccessorDeclFile_Widgets"); var Widgets1 = require("GlobalWidgets"); @@ -187,6 +189,7 @@ function createExportedWidget4() { exports.createExportedWidget4 = createExportedWidget4; //// [privacyCannotNameAccessorDeclFile_consumer.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var exporter = require("./privacyCannotNameAccessorDeclFile_exporter"); var publicClassWithWithPrivateGetAccessorTypes = (function () { function publicClassWithWithPrivateGetAccessorTypes() { diff --git a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js index c139b6279fd..df24bf70259 100644 --- a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js +++ b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js @@ -103,6 +103,7 @@ var privateVarWithPrivateModulePropertyTypes1 = exporter.createExportedWidget4() //// [privacyCannotNameVarTypeDeclFile_GlobalWidgets.js] //// [privacyCannotNameVarTypeDeclFile_Widgets.js] "use strict"; +exports.__esModule = true; var Widget1 = (function () { function Widget1() { this.name = 'one'; @@ -130,6 +131,7 @@ var SpecializedWidget; })(SpecializedWidget = exports.SpecializedWidget || (exports.SpecializedWidget = {})); //// [privacyCannotNameVarTypeDeclFile_exporter.js] "use strict"; +exports.__esModule = true; /// var Widgets = require("./privacyCannotNameVarTypeDeclFile_Widgets"); var Widgets1 = require("GlobalWidgets"); @@ -151,6 +153,7 @@ function createExportedWidget4() { exports.createExportedWidget4 = createExportedWidget4; //// [privacyCannotNameVarTypeDeclFile_consumer.js] "use strict"; +exports.__esModule = true; var exporter = require("./privacyCannotNameVarTypeDeclFile_exporter"); var publicClassWithWithPrivatePropertyTypes = (function () { function publicClassWithWithPrivatePropertyTypes() { diff --git a/tests/baselines/reference/privacyCheckAnonymousFunctionParameter.js b/tests/baselines/reference/privacyCheckAnonymousFunctionParameter.js index 92be6f737cc..8ddcc60a8ff 100644 --- a/tests/baselines/reference/privacyCheckAnonymousFunctionParameter.js +++ b/tests/baselines/reference/privacyCheckAnonymousFunctionParameter.js @@ -18,6 +18,7 @@ module Query { //// [privacyCheckAnonymousFunctionParameter.js] "use strict"; +exports.__esModule = true; exports.x = 1; // Makes this an external module var Query; (function (Query) { diff --git a/tests/baselines/reference/privacyCheckAnonymousFunctionParameter2.js b/tests/baselines/reference/privacyCheckAnonymousFunctionParameter2.js index 1da2ec03ed7..f18f47c20c3 100644 --- a/tests/baselines/reference/privacyCheckAnonymousFunctionParameter2.js +++ b/tests/baselines/reference/privacyCheckAnonymousFunctionParameter2.js @@ -17,6 +17,7 @@ module Q { //// [privacyCheckAnonymousFunctionParameter2.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.x = 1; // Makes this an external module var Q; (function (Q) { diff --git a/tests/baselines/reference/privacyCheckCallbackOfInterfaceMethodWithTypeParameter.js b/tests/baselines/reference/privacyCheckCallbackOfInterfaceMethodWithTypeParameter.js index 54ad8acd2f1..98e87342287 100644 --- a/tests/baselines/reference/privacyCheckCallbackOfInterfaceMethodWithTypeParameter.js +++ b/tests/baselines/reference/privacyCheckCallbackOfInterfaceMethodWithTypeParameter.js @@ -10,6 +10,7 @@ export interface B extends A { //// [privacyCheckCallbackOfInterfaceMethodWithTypeParameter.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.js b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.js index ff241a726bf..b8e8139675b 100644 --- a/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.js +++ b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.js @@ -24,6 +24,7 @@ var Foo = (function () { module.exports = Foo; //// [privacyCheckExternalModuleExportAssignmentOfGenericClass_1.js] "use strict"; +exports.__esModule = true; //// [privacyCheckExternalModuleExportAssignmentOfGenericClass_0.d.ts] diff --git a/tests/baselines/reference/privacyCheckOnTypeParameterReferenceInConstructorParameter.js b/tests/baselines/reference/privacyCheckOnTypeParameterReferenceInConstructorParameter.js index 7d4db36ee99..dc868d86bff 100644 --- a/tests/baselines/reference/privacyCheckOnTypeParameterReferenceInConstructorParameter.js +++ b/tests/baselines/reference/privacyCheckOnTypeParameterReferenceInConstructorParameter.js @@ -13,6 +13,7 @@ export class B { //// [privacyCheckOnTypeParameterReferenceInConstructorParameter.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var A = (function () { function A(callback) { var child = new B(this); diff --git a/tests/baselines/reference/privacyCheckTypeOfFunction.js b/tests/baselines/reference/privacyCheckTypeOfFunction.js index b810dafcca7..614bcedebe0 100644 --- a/tests/baselines/reference/privacyCheckTypeOfFunction.js +++ b/tests/baselines/reference/privacyCheckTypeOfFunction.js @@ -7,6 +7,7 @@ export var b = foo; //// [privacyCheckTypeOfFunction.js] "use strict"; +exports.__esModule = true; function foo() { } exports.b = foo; diff --git a/tests/baselines/reference/privacyClass.js b/tests/baselines/reference/privacyClass.js index 7e56edf2cf1..95b12f4e2fa 100644 --- a/tests/baselines/reference/privacyClass.js +++ b/tests/baselines/reference/privacyClass.js @@ -129,11 +129,17 @@ export class glo_C12_public extends glo_c_private implements glo_i_private, glo //// [privacyClass.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var m1; (function (m1) { var m1_c_public = (function () { @@ -152,21 +158,21 @@ var m1; var m1_C1_private = (function (_super) { __extends(m1_C1_private, _super); function m1_C1_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C1_private; }(m1_c_public)); var m1_C2_private = (function (_super) { __extends(m1_C2_private, _super); function m1_C2_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C2_private; }(m1_c_private)); var m1_C3_public = (function (_super) { __extends(m1_C3_public, _super); function m1_C3_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C3_public; }(m1_c_public)); @@ -174,7 +180,7 @@ var m1; var m1_C4_public = (function (_super) { __extends(m1_C4_public, _super); function m1_C4_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C4_public; }(m1_c_private)); @@ -204,21 +210,21 @@ var m1; var m1_C9_private = (function (_super) { __extends(m1_C9_private, _super); function m1_C9_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C9_private; }(m1_c_public)); var m1_C10_private = (function (_super) { __extends(m1_C10_private, _super); function m1_C10_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C10_private; }(m1_c_private)); var m1_C11_public = (function (_super) { __extends(m1_C11_public, _super); function m1_C11_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C11_public; }(m1_c_public)); @@ -226,7 +232,7 @@ var m1; var m1_C12_public = (function (_super) { __extends(m1_C12_public, _super); function m1_C12_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C12_public; }(m1_c_private)); @@ -250,21 +256,21 @@ var m2; var m2_C1_private = (function (_super) { __extends(m2_C1_private, _super); function m2_C1_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m2_C1_private; }(m2_c_public)); var m2_C2_private = (function (_super) { __extends(m2_C2_private, _super); function m2_C2_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m2_C2_private; }(m2_c_private)); var m2_C3_public = (function (_super) { __extends(m2_C3_public, _super); function m2_C3_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m2_C3_public; }(m2_c_public)); @@ -272,7 +278,7 @@ var m2; var m2_C4_public = (function (_super) { __extends(m2_C4_public, _super); function m2_C4_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m2_C4_public; }(m2_c_private)); @@ -302,21 +308,21 @@ var m2; var m2_C9_private = (function (_super) { __extends(m2_C9_private, _super); function m2_C9_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m2_C9_private; }(m2_c_public)); var m2_C10_private = (function (_super) { __extends(m2_C10_private, _super); function m2_C10_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m2_C10_private; }(m2_c_private)); var m2_C11_public = (function (_super) { __extends(m2_C11_public, _super); function m2_C11_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m2_C11_public; }(m2_c_public)); @@ -324,7 +330,7 @@ var m2; var m2_C12_public = (function (_super) { __extends(m2_C12_public, _super); function m2_C12_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m2_C12_public; }(m2_c_private)); @@ -346,21 +352,21 @@ var glo_c_private = (function () { var glo_C1_private = (function (_super) { __extends(glo_C1_private, _super); function glo_C1_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C1_private; }(glo_c_public)); var glo_C2_private = (function (_super) { __extends(glo_C2_private, _super); function glo_C2_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C2_private; }(glo_c_private)); var glo_C3_public = (function (_super) { __extends(glo_C3_public, _super); function glo_C3_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C3_public; }(glo_c_public)); @@ -368,7 +374,7 @@ exports.glo_C3_public = glo_C3_public; var glo_C4_public = (function (_super) { __extends(glo_C4_public, _super); function glo_C4_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C4_public; }(glo_c_private)); @@ -398,21 +404,21 @@ exports.glo_C8_public = glo_C8_public; var glo_C9_private = (function (_super) { __extends(glo_C9_private, _super); function glo_C9_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C9_private; }(glo_c_public)); var glo_C10_private = (function (_super) { __extends(glo_C10_private, _super); function glo_C10_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C10_private; }(glo_c_private)); var glo_C11_public = (function (_super) { __extends(glo_C11_public, _super); function glo_C11_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C11_public; }(glo_c_public)); @@ -420,7 +426,7 @@ exports.glo_C11_public = glo_C11_public; var glo_C12_public = (function (_super) { __extends(glo_C12_public, _super); function glo_C12_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C12_public; }(glo_c_private)); diff --git a/tests/baselines/reference/privacyClassExtendsClauseDeclFile.errors.txt b/tests/baselines/reference/privacyClassExtendsClauseDeclFile.errors.txt index 8b66d02b238..dd44005047e 100644 --- a/tests/baselines/reference/privacyClassExtendsClauseDeclFile.errors.txt +++ b/tests/baselines/reference/privacyClassExtendsClauseDeclFile.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/privacyClassExtendsClauseDeclFile_GlobalFile.ts(16,67): error TS4020: Extends clause of exported class 'publicClassExtendingPrivateClassInModule' has or is using private name 'privateClassInPublicModule'. -tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(17,67): error TS4020: Extends clause of exported class 'publicClassExtendingPrivateClassInModule' has or is using private name 'privateClassInPublicModule'. +tests/cases/compiler/privacyClassExtendsClauseDeclFile_GlobalFile.ts(16,67): error TS4020: 'extends' clause of exported class 'publicClassExtendingPrivateClassInModule' has or is using private name 'privateClassInPublicModule'. +tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(17,67): error TS4020: 'extends' clause of exported class 'publicClassExtendingPrivateClassInModule' has or is using private name 'privateClassInPublicModule'. tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(20,63): error TS2690: A class must be declared after its base class. -tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(22,69): error TS4020: Extends clause of exported class 'publicClassExtendingFromPrivateModuleClass' has or is using private name 'privateModule'. +tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(22,69): error TS4020: 'extends' clause of exported class 'publicClassExtendingFromPrivateModuleClass' has or is using private name 'privateModule'. tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(22,69): error TS2690: A class must be declared after its base class. -tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(64,55): error TS4020: Extends clause of exported class 'publicClassExtendingPrivateClass' has or is using private name 'privateClass'. -tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(69,65): error TS4020: Extends clause of exported class 'publicClassExtendingFromPrivateModuleClass' has or is using private name 'privateModule'. +tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(64,55): error TS4020: 'extends' clause of exported class 'publicClassExtendingPrivateClass' has or is using private name 'privateClass'. +tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(69,65): error TS4020: 'extends' clause of exported class 'publicClassExtendingFromPrivateModuleClass' has or is using private name 'privateModule'. ==== tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts (6 errors) ==== @@ -26,7 +26,7 @@ tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(69,65): } export class publicClassExtendingPrivateClassInModule extends privateClassInPublicModule { // Should error ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS4020: Extends clause of exported class 'publicClassExtendingPrivateClassInModule' has or is using private name 'privateClassInPublicModule'. +!!! error TS4020: 'extends' clause of exported class 'publicClassExtendingPrivateClassInModule' has or is using private name 'privateClassInPublicModule'. } class privateClassExtendingFromPrivateModuleClass extends privateModule.publicClassInPrivateModule { @@ -35,7 +35,7 @@ tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(69,65): } export class publicClassExtendingFromPrivateModuleClass extends privateModule.publicClassInPrivateModule { // Should error ~~~~~~~~~~~~~ -!!! error TS4020: Extends clause of exported class 'publicClassExtendingFromPrivateModuleClass' has or is using private name 'privateModule'. +!!! error TS4020: 'extends' clause of exported class 'publicClassExtendingFromPrivateModuleClass' has or is using private name 'privateModule'. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2690: A class must be declared after its base class. } @@ -81,14 +81,14 @@ tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(69,65): } export class publicClassExtendingPrivateClass extends privateClass { // Should error ~~~~~~~~~~~~ -!!! error TS4020: Extends clause of exported class 'publicClassExtendingPrivateClass' has or is using private name 'privateClass'. +!!! error TS4020: 'extends' clause of exported class 'publicClassExtendingPrivateClass' has or is using private name 'privateClass'. } class privateClassExtendingFromPrivateModuleClass extends privateModule.publicClassInPrivateModule { } export class publicClassExtendingFromPrivateModuleClass extends privateModule.publicClassInPrivateModule { // Should error ~~~~~~~~~~~~~ -!!! error TS4020: Extends clause of exported class 'publicClassExtendingFromPrivateModuleClass' has or is using private name 'privateModule'. +!!! error TS4020: 'extends' clause of exported class 'publicClassExtendingFromPrivateModuleClass' has or is using private name 'privateModule'. } ==== tests/cases/compiler/privacyClassExtendsClauseDeclFile_GlobalFile.ts (1 errors) ==== @@ -109,7 +109,7 @@ tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(69,65): } export class publicClassExtendingPrivateClassInModule extends privateClassInPublicModule { // Should error ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS4020: Extends clause of exported class 'publicClassExtendingPrivateClassInModule' has or is using private name 'privateClassInPublicModule'. +!!! error TS4020: 'extends' clause of exported class 'publicClassExtendingPrivateClassInModule' has or is using private name 'privateClassInPublicModule'. } } class publicClassInGlobal { diff --git a/tests/baselines/reference/privacyClassExtendsClauseDeclFile.js b/tests/baselines/reference/privacyClassExtendsClauseDeclFile.js index e0828809416..2803006c5b5 100644 --- a/tests/baselines/reference/privacyClassExtendsClauseDeclFile.js +++ b/tests/baselines/reference/privacyClassExtendsClauseDeclFile.js @@ -99,11 +99,17 @@ class publicClassExtendingPublicClassInGlobal extends publicClassInGlobal { //// [privacyClassExtendsClauseDeclFile_externalModule.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var publicModule; (function (publicModule) { var publicClassInPublicModule = (function () { @@ -122,21 +128,21 @@ var publicModule; var privateClassExtendingPublicClassInModule = (function (_super) { __extends(privateClassExtendingPublicClassInModule, _super); function privateClassExtendingPublicClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingPublicClassInModule; }(publicClassInPublicModule)); var privateClassExtendingPrivateClassInModule = (function (_super) { __extends(privateClassExtendingPrivateClassInModule, _super); function privateClassExtendingPrivateClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingPrivateClassInModule; }(privateClassInPublicModule)); var publicClassExtendingPublicClassInModule = (function (_super) { __extends(publicClassExtendingPublicClassInModule, _super); function publicClassExtendingPublicClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingPublicClassInModule; }(publicClassInPublicModule)); @@ -144,7 +150,7 @@ var publicModule; var publicClassExtendingPrivateClassInModule = (function (_super) { __extends(publicClassExtendingPrivateClassInModule, _super); function publicClassExtendingPrivateClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingPrivateClassInModule; }(privateClassInPublicModule)); @@ -152,14 +158,14 @@ var publicModule; var privateClassExtendingFromPrivateModuleClass = (function (_super) { __extends(privateClassExtendingFromPrivateModuleClass, _super); function privateClassExtendingFromPrivateModuleClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingFromPrivateModuleClass; }(privateModule.publicClassInPrivateModule)); var publicClassExtendingFromPrivateModuleClass = (function (_super) { __extends(publicClassExtendingFromPrivateModuleClass, _super); function publicClassExtendingFromPrivateModuleClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingFromPrivateModuleClass; }(privateModule.publicClassInPrivateModule)); @@ -183,21 +189,21 @@ var privateModule; var privateClassExtendingPublicClassInModule = (function (_super) { __extends(privateClassExtendingPublicClassInModule, _super); function privateClassExtendingPublicClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingPublicClassInModule; }(publicClassInPrivateModule)); var privateClassExtendingPrivateClassInModule = (function (_super) { __extends(privateClassExtendingPrivateClassInModule, _super); function privateClassExtendingPrivateClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingPrivateClassInModule; }(privateClassInPrivateModule)); var publicClassExtendingPublicClassInModule = (function (_super) { __extends(publicClassExtendingPublicClassInModule, _super); function publicClassExtendingPublicClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingPublicClassInModule; }(publicClassInPrivateModule)); @@ -205,7 +211,7 @@ var privateModule; var publicClassExtendingPrivateClassInModule = (function (_super) { __extends(publicClassExtendingPrivateClassInModule, _super); function publicClassExtendingPrivateClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingPrivateClassInModule; }(privateClassInPrivateModule)); @@ -213,14 +219,14 @@ var privateModule; var privateClassExtendingFromPrivateModuleClass = (function (_super) { __extends(privateClassExtendingFromPrivateModuleClass, _super); function privateClassExtendingFromPrivateModuleClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingFromPrivateModuleClass; }(privateModule.publicClassInPrivateModule)); var publicClassExtendingFromPrivateModuleClass = (function (_super) { __extends(publicClassExtendingFromPrivateModuleClass, _super); function publicClassExtendingFromPrivateModuleClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingFromPrivateModuleClass; }(privateModule.publicClassInPrivateModule)); @@ -242,21 +248,21 @@ var privateClass = (function () { var privateClassExtendingPublicClass = (function (_super) { __extends(privateClassExtendingPublicClass, _super); function privateClassExtendingPublicClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingPublicClass; }(publicClass)); var privateClassExtendingPrivateClassInModule = (function (_super) { __extends(privateClassExtendingPrivateClassInModule, _super); function privateClassExtendingPrivateClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingPrivateClassInModule; }(privateClass)); var publicClassExtendingPublicClass = (function (_super) { __extends(publicClassExtendingPublicClass, _super); function publicClassExtendingPublicClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingPublicClass; }(publicClass)); @@ -264,7 +270,7 @@ exports.publicClassExtendingPublicClass = publicClassExtendingPublicClass; var publicClassExtendingPrivateClass = (function (_super) { __extends(publicClassExtendingPrivateClass, _super); function publicClassExtendingPrivateClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingPrivateClass; }(privateClass)); @@ -272,24 +278,29 @@ exports.publicClassExtendingPrivateClass = publicClassExtendingPrivateClass; var privateClassExtendingFromPrivateModuleClass = (function (_super) { __extends(privateClassExtendingFromPrivateModuleClass, _super); function privateClassExtendingFromPrivateModuleClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingFromPrivateModuleClass; }(privateModule.publicClassInPrivateModule)); var publicClassExtendingFromPrivateModuleClass = (function (_super) { __extends(publicClassExtendingFromPrivateModuleClass, _super); function publicClassExtendingFromPrivateModuleClass() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingFromPrivateModuleClass; }(privateModule.publicClassInPrivateModule)); exports.publicClassExtendingFromPrivateModuleClass = publicClassExtendingFromPrivateModuleClass; //// [privacyClassExtendsClauseDeclFile_GlobalFile.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var publicModuleInGlobal; (function (publicModuleInGlobal) { var publicClassInPublicModule = (function () { @@ -308,21 +319,21 @@ var publicModuleInGlobal; var privateClassExtendingPublicClassInModule = (function (_super) { __extends(privateClassExtendingPublicClassInModule, _super); function privateClassExtendingPublicClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingPublicClassInModule; }(publicClassInPublicModule)); var privateClassExtendingPrivateClassInModule = (function (_super) { __extends(privateClassExtendingPrivateClassInModule, _super); function privateClassExtendingPrivateClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return privateClassExtendingPrivateClassInModule; }(privateClassInPublicModule)); var publicClassExtendingPublicClassInModule = (function (_super) { __extends(publicClassExtendingPublicClassInModule, _super); function publicClassExtendingPublicClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingPublicClassInModule; }(publicClassInPublicModule)); @@ -330,7 +341,7 @@ var publicModuleInGlobal; var publicClassExtendingPrivateClassInModule = (function (_super) { __extends(publicClassExtendingPrivateClassInModule, _super); function publicClassExtendingPrivateClassInModule() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingPrivateClassInModule; }(privateClassInPublicModule)); @@ -344,7 +355,7 @@ var publicClassInGlobal = (function () { var publicClassExtendingPublicClassInGlobal = (function (_super) { __extends(publicClassExtendingPublicClassInGlobal, _super); function publicClassExtendingPublicClassInGlobal() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return publicClassExtendingPublicClassInGlobal; }(publicClassInGlobal)); diff --git a/tests/baselines/reference/privacyClassImplementsClauseDeclFile.js b/tests/baselines/reference/privacyClassImplementsClauseDeclFile.js index 15de9a16674..3d78f2a8048 100644 --- a/tests/baselines/reference/privacyClassImplementsClauseDeclFile.js +++ b/tests/baselines/reference/privacyClassImplementsClauseDeclFile.js @@ -96,6 +96,7 @@ class publicClassImplementingPublicInterfaceInGlobal implements publicInterfaceI //// [privacyClassImplementsClauseDeclFile_externalModule.js] "use strict"; +exports.__esModule = true; var publicModule; (function (publicModule) { var privateClassImplementingPublicInterfaceInModule = (function () { diff --git a/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.js b/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.js index d8bfef7060e..00314bdceab 100644 --- a/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.js +++ b/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.js @@ -159,6 +159,7 @@ function privateFunctionWithPrivateModuleParameterTypes1(param= exporter.createE //// [privacyFunctionCannotNameParameterTypeDeclFile_GlobalWidgets.js] //// [privacyFunctionCannotNameParameterTypeDeclFile_Widgets.js] "use strict"; +exports.__esModule = true; var Widget1 = (function () { function Widget1() { this.name = 'one'; @@ -186,6 +187,7 @@ var SpecializedWidget; })(SpecializedWidget = exports.SpecializedWidget || (exports.SpecializedWidget = {})); //// [privacyFunctionCannotNameParameterTypeDeclFile_exporter.js] "use strict"; +exports.__esModule = true; /// var Widgets = require("./privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); var Widgets1 = require("GlobalWidgets"); @@ -207,6 +209,7 @@ function createExportedWidget4() { exports.createExportedWidget4 = createExportedWidget4; //// [privacyFunctionCannotNameParameterTypeDeclFile_consumer.js] "use strict"; +exports.__esModule = true; var exporter = require("./privacyFunctionCannotNameParameterTypeDeclFile_exporter"); var publicClassWithWithPrivateParmeterTypes = (function () { function publicClassWithWithPrivateParmeterTypes(param, param1, param2) { diff --git a/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.js b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.js index 3b1ffb487ff..2124f8fbb24 100644 --- a/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.js +++ b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.js @@ -166,6 +166,7 @@ function privateFunctionWithPrivateModuleReturnTypes1() { //// [privacyFunctionReturnTypeDeclFile_GlobalWidgets.js] //// [privacyFunctionReturnTypeDeclFile_Widgets.js] "use strict"; +exports.__esModule = true; var Widget1 = (function () { function Widget1() { this.name = 'one'; @@ -193,6 +194,7 @@ var SpecializedWidget; })(SpecializedWidget = exports.SpecializedWidget || (exports.SpecializedWidget = {})); //// [privacyFunctionReturnTypeDeclFile_exporter.js] "use strict"; +exports.__esModule = true; /// var Widgets = require("./privacyFunctionReturnTypeDeclFile_Widgets"); var Widgets1 = require("GlobalWidgets"); @@ -214,6 +216,7 @@ function createExportedWidget4() { exports.createExportedWidget4 = createExportedWidget4; //// [privacyFunctionReturnTypeDeclFile_consumer.js] "use strict"; +exports.__esModule = true; var exporter = require("./privacyFunctionReturnTypeDeclFile_exporter"); var publicClassWithWithPrivateParmeterTypes = (function () { function publicClassWithWithPrivateParmeterTypes() { diff --git a/tests/baselines/reference/privacyFunctionParameterDeclFile.js b/tests/baselines/reference/privacyFunctionParameterDeclFile.js index e8fff791a0e..255b8d68db6 100644 --- a/tests/baselines/reference/privacyFunctionParameterDeclFile.js +++ b/tests/baselines/reference/privacyFunctionParameterDeclFile.js @@ -688,6 +688,7 @@ module publicModuleInGlobal { //// [privacyFunctionParameterDeclFile_externalModule.js] "use strict"; +exports.__esModule = true; var privateClass = (function () { function privateClass() { } diff --git a/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.js b/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.js index d4265b1c352..1aba74efaa4 100644 --- a/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.js +++ b/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.js @@ -1195,6 +1195,7 @@ module publicModuleInGlobal { //// [privacyFunctionReturnTypeDeclFile_externalModule.js] "use strict"; +exports.__esModule = true; var privateClass = (function () { function privateClass() { } diff --git a/tests/baselines/reference/privacyGetter.js b/tests/baselines/reference/privacyGetter.js index 37d89442e62..255d21edcdb 100644 --- a/tests/baselines/reference/privacyGetter.js +++ b/tests/baselines/reference/privacyGetter.js @@ -210,6 +210,7 @@ class C8_private { //// [privacyGetter.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var m1; (function (m1) { var C1_public = (function () { diff --git a/tests/baselines/reference/privacyGloClass.js b/tests/baselines/reference/privacyGloClass.js index fa769a606ae..85acba1148b 100644 --- a/tests/baselines/reference/privacyGloClass.js +++ b/tests/baselines/reference/privacyGloClass.js @@ -61,11 +61,16 @@ class glo_C11_public extends glo_c_public implements glo_i_public { //// [privacyGloClass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var m1; (function (m1) { var m1_c_public = (function () { @@ -84,21 +89,21 @@ var m1; var m1_C1_private = (function (_super) { __extends(m1_C1_private, _super); function m1_C1_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C1_private; }(m1_c_public)); var m1_C2_private = (function (_super) { __extends(m1_C2_private, _super); function m1_C2_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C2_private; }(m1_c_private)); var m1_C3_public = (function (_super) { __extends(m1_C3_public, _super); function m1_C3_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C3_public; }(m1_c_public)); @@ -106,7 +111,7 @@ var m1; var m1_C4_public = (function (_super) { __extends(m1_C4_public, _super); function m1_C4_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C4_public; }(m1_c_private)); @@ -136,21 +141,21 @@ var m1; var m1_C9_private = (function (_super) { __extends(m1_C9_private, _super); function m1_C9_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C9_private; }(m1_c_public)); var m1_C10_private = (function (_super) { __extends(m1_C10_private, _super); function m1_C10_private() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C10_private; }(m1_c_private)); var m1_C11_public = (function (_super) { __extends(m1_C11_public, _super); function m1_C11_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C11_public; }(m1_c_public)); @@ -158,7 +163,7 @@ var m1; var m1_C12_public = (function (_super) { __extends(m1_C12_public, _super); function m1_C12_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return m1_C12_public; }(m1_c_private)); @@ -174,7 +179,7 @@ var glo_c_public = (function () { var glo_C3_public = (function (_super) { __extends(glo_C3_public, _super); function glo_C3_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C3_public; }(glo_c_public)); @@ -186,7 +191,7 @@ var glo_C7_public = (function () { var glo_C11_public = (function (_super) { __extends(glo_C11_public, _super); function glo_C11_public() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return glo_C11_public; }(glo_c_public)); diff --git a/tests/baselines/reference/privacyGloFunc.js b/tests/baselines/reference/privacyGloFunc.js index 153fa57e3d3..6bc17794680 100644 --- a/tests/baselines/reference/privacyGloFunc.js +++ b/tests/baselines/reference/privacyGloFunc.js @@ -533,6 +533,7 @@ export function f12_public(): C5_private { //error //// [privacyGloFunc.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var m1; (function (m1) { var C1_public = (function () { diff --git a/tests/baselines/reference/privacyImport.js b/tests/baselines/reference/privacyImport.js index 2915b6e5f24..1a3dc9d9b18 100644 --- a/tests/baselines/reference/privacyImport.js +++ b/tests/baselines/reference/privacyImport.js @@ -358,6 +358,7 @@ export module m3 { //// [privacyImport.js] "use strict"; +exports.__esModule = true; var m1; (function (m1) { var m1_M1_public; diff --git a/tests/baselines/reference/privacyImportParseErrors.js b/tests/baselines/reference/privacyImportParseErrors.js index b705bbe1170..5a15a7280ec 100644 --- a/tests/baselines/reference/privacyImportParseErrors.js +++ b/tests/baselines/reference/privacyImportParseErrors.js @@ -358,6 +358,7 @@ export module m3 { //// [privacyImportParseErrors.js] "use strict"; +exports.__esModule = true; var m1; (function (m1) { var m1_M1_public; diff --git a/tests/baselines/reference/privacyInterface.js b/tests/baselines/reference/privacyInterface.js index 59e10aca7ff..360f1683b6a 100644 --- a/tests/baselines/reference/privacyInterface.js +++ b/tests/baselines/reference/privacyInterface.js @@ -266,6 +266,7 @@ export interface glo_C6_public extends glo_i_private, glo_i_public { //// [privacyInterface.js] "use strict"; +exports.__esModule = true; var m1; (function (m1) { var C1_public = (function () { diff --git a/tests/baselines/reference/privacyInterfaceExtendsClauseDeclFile.errors.txt b/tests/baselines/reference/privacyInterfaceExtendsClauseDeclFile.errors.txt index 41c53ffd19b..2107e773173 100644 --- a/tests/baselines/reference/privacyInterfaceExtendsClauseDeclFile.errors.txt +++ b/tests/baselines/reference/privacyInterfaceExtendsClauseDeclFile.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/privacyInterfaceExtendsClauseDeclFile_GlobalFile.ts(14,82): error TS4022: Extends clause of exported interface 'publicInterfaceImplementingPrivateInterfaceInModule' has or is using private name 'privateInterfaceInPublicModule'. -tests/cases/compiler/privacyInterfaceExtendsClauseDeclFile_externalModule.ts(15,82): error TS4022: Extends clause of exported interface 'publicInterfaceImplementingPrivateInterfaceInModule' has or is using private name 'privateInterfaceInPublicModule'. -tests/cases/compiler/privacyInterfaceExtendsClauseDeclFile_externalModule.ts(20,84): error TS4022: Extends clause of exported interface 'publicInterfaceImplementingFromPrivateModuleInterface' has or is using private name 'privateModule'. -tests/cases/compiler/privacyInterfaceExtendsClauseDeclFile_externalModule.ts(23,83): error TS4022: Extends clause of exported interface 'publicInterfaceImplementingPrivateAndPublicInterface' has or is using private name 'privateInterfaceInPublicModule'. -tests/cases/compiler/privacyInterfaceExtendsClauseDeclFile_externalModule.ts(63,70): error TS4022: Extends clause of exported interface 'publicInterfaceImplementingPrivateInterface' has or is using private name 'privateInterface'. -tests/cases/compiler/privacyInterfaceExtendsClauseDeclFile_externalModule.ts(68,80): error TS4022: Extends clause of exported interface 'publicInterfaceImplementingFromPrivateModuleInterface' has or is using private name 'privateModule'. +tests/cases/compiler/privacyInterfaceExtendsClauseDeclFile_GlobalFile.ts(14,82): error TS4022: 'extends' clause of exported interface 'publicInterfaceImplementingPrivateInterfaceInModule' has or is using private name 'privateInterfaceInPublicModule'. +tests/cases/compiler/privacyInterfaceExtendsClauseDeclFile_externalModule.ts(15,82): error TS4022: 'extends' clause of exported interface 'publicInterfaceImplementingPrivateInterfaceInModule' has or is using private name 'privateInterfaceInPublicModule'. +tests/cases/compiler/privacyInterfaceExtendsClauseDeclFile_externalModule.ts(20,84): error TS4022: 'extends' clause of exported interface 'publicInterfaceImplementingFromPrivateModuleInterface' has or is using private name 'privateModule'. +tests/cases/compiler/privacyInterfaceExtendsClauseDeclFile_externalModule.ts(23,83): error TS4022: 'extends' clause of exported interface 'publicInterfaceImplementingPrivateAndPublicInterface' has or is using private name 'privateInterfaceInPublicModule'. +tests/cases/compiler/privacyInterfaceExtendsClauseDeclFile_externalModule.ts(63,70): error TS4022: 'extends' clause of exported interface 'publicInterfaceImplementingPrivateInterface' has or is using private name 'privateInterface'. +tests/cases/compiler/privacyInterfaceExtendsClauseDeclFile_externalModule.ts(68,80): error TS4022: 'extends' clause of exported interface 'publicInterfaceImplementingFromPrivateModuleInterface' has or is using private name 'privateModule'. ==== tests/cases/compiler/privacyInterfaceExtendsClauseDeclFile_externalModule.ts (5 errors) ==== @@ -23,19 +23,19 @@ tests/cases/compiler/privacyInterfaceExtendsClauseDeclFile_externalModule.ts(68, } export interface publicInterfaceImplementingPrivateInterfaceInModule extends privateInterfaceInPublicModule { // Should error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS4022: Extends clause of exported interface 'publicInterfaceImplementingPrivateInterfaceInModule' has or is using private name 'privateInterfaceInPublicModule'. +!!! error TS4022: 'extends' clause of exported interface 'publicInterfaceImplementingPrivateInterfaceInModule' has or is using private name 'privateInterfaceInPublicModule'. } interface privateInterfaceImplementingFromPrivateModuleInterface extends privateModule.publicInterfaceInPrivateModule { } export interface publicInterfaceImplementingFromPrivateModuleInterface extends privateModule.publicInterfaceInPrivateModule { // Should error ~~~~~~~~~~~~~ -!!! error TS4022: Extends clause of exported interface 'publicInterfaceImplementingFromPrivateModuleInterface' has or is using private name 'privateModule'. +!!! error TS4022: 'extends' clause of exported interface 'publicInterfaceImplementingFromPrivateModuleInterface' has or is using private name 'privateModule'. } export interface publicInterfaceImplementingPrivateAndPublicInterface extends privateInterfaceInPublicModule, publicInterfaceInPublicModule { // Should error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS4022: Extends clause of exported interface 'publicInterfaceImplementingPrivateAndPublicInterface' has or is using private name 'privateInterfaceInPublicModule'. +!!! error TS4022: 'extends' clause of exported interface 'publicInterfaceImplementingPrivateAndPublicInterface' has or is using private name 'privateInterfaceInPublicModule'. } } @@ -77,14 +77,14 @@ tests/cases/compiler/privacyInterfaceExtendsClauseDeclFile_externalModule.ts(68, } export interface publicInterfaceImplementingPrivateInterface extends privateInterface { // Should error ~~~~~~~~~~~~~~~~ -!!! error TS4022: Extends clause of exported interface 'publicInterfaceImplementingPrivateInterface' has or is using private name 'privateInterface'. +!!! error TS4022: 'extends' clause of exported interface 'publicInterfaceImplementingPrivateInterface' has or is using private name 'privateInterface'. } interface privateInterfaceImplementingFromPrivateModuleInterface extends privateModule.publicInterfaceInPrivateModule { } export interface publicInterfaceImplementingFromPrivateModuleInterface extends privateModule.publicInterfaceInPrivateModule { // Should error ~~~~~~~~~~~~~ -!!! error TS4022: Extends clause of exported interface 'publicInterfaceImplementingFromPrivateModuleInterface' has or is using private name 'privateModule'. +!!! error TS4022: 'extends' clause of exported interface 'publicInterfaceImplementingFromPrivateModuleInterface' has or is using private name 'privateModule'. } ==== tests/cases/compiler/privacyInterfaceExtendsClauseDeclFile_GlobalFile.ts (1 errors) ==== @@ -103,7 +103,7 @@ tests/cases/compiler/privacyInterfaceExtendsClauseDeclFile_externalModule.ts(68, } export interface publicInterfaceImplementingPrivateInterfaceInModule extends privateInterfaceInPublicModule { // Should error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS4022: Extends clause of exported interface 'publicInterfaceImplementingPrivateInterfaceInModule' has or is using private name 'privateInterfaceInPublicModule'. +!!! error TS4022: 'extends' clause of exported interface 'publicInterfaceImplementingPrivateInterfaceInModule' has or is using private name 'privateInterfaceInPublicModule'. } } interface publicInterfaceInGlobal { diff --git a/tests/baselines/reference/privacyInterfaceExtendsClauseDeclFile.js b/tests/baselines/reference/privacyInterfaceExtendsClauseDeclFile.js index 8b2c4de8bf3..6d2748dd8dc 100644 --- a/tests/baselines/reference/privacyInterfaceExtendsClauseDeclFile.js +++ b/tests/baselines/reference/privacyInterfaceExtendsClauseDeclFile.js @@ -96,4 +96,5 @@ interface publicInterfaceImplementingPublicInterfaceInGlobal extends publicInter //// [privacyInterfaceExtendsClauseDeclFile_externalModule.js] "use strict"; +exports.__esModule = true; //// [privacyInterfaceExtendsClauseDeclFile_GlobalFile.js] diff --git a/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js b/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js index b328e8b3036..408abc04940 100644 --- a/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js +++ b/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js @@ -154,6 +154,7 @@ module import_private { //// [privacyLocalInternalReferenceImportWithExport.js] "use strict"; +exports.__esModule = true; // private elements var m_private; (function (m_private) { diff --git a/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js b/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js index 7d4a80a0d29..8b158d7cc3d 100644 --- a/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js +++ b/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js @@ -155,6 +155,7 @@ module import_private { //// [privacyLocalInternalReferenceImportWithoutExport.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; // private elements var m_private; (function (m_private) { diff --git a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.js b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.js index d8bf7c85d12..312d682669c 100644 --- a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.js +++ b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.js @@ -52,6 +52,7 @@ export var publicUse_im_public_mi_public = new im_public_mi_public.c_private(); //// [privacyTopLevelAmbientExternalModuleImportWithExport_require3.js] //// [privacyTopLevelAmbientExternalModuleImportWithExport_require.js] "use strict"; +exports.__esModule = true; // Public elements var c_public = (function () { function c_public() { @@ -61,6 +62,7 @@ var c_public = (function () { exports.c_public = c_public; //// [privacyTopLevelAmbientExternalModuleImportWithExport_require1.js] "use strict"; +exports.__esModule = true; var c_public = (function () { function c_public() { } @@ -69,6 +71,7 @@ var c_public = (function () { exports.c_public = c_public; //// [privacyTopLevelAmbientExternalModuleImportWithExport_core.js] "use strict"; +exports.__esModule = true; /// /// // Privacy errors - importing private elements diff --git a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithoutExport.js b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithoutExport.js index 7f44dbe6257..13b7de58ecf 100644 --- a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithoutExport.js +++ b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithoutExport.js @@ -53,6 +53,7 @@ export var publicUse_im_private_mi_public = new im_private_mi_public.c_public(); //// [privacyTopLevelAmbientExternalModuleImportWithoutExport_require.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; // Public elements var c_public = (function () { function c_public() { @@ -64,6 +65,7 @@ define(["require", "exports"], function (require, exports) { //// [privacyTopLevelAmbientExternalModuleImportWithoutExport_require1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var c_public = (function () { function c_public() { } @@ -74,6 +76,7 @@ define(["require", "exports"], function (require, exports) { //// [privacyTopLevelAmbientExternalModuleImportWithoutExport_core.js] define(["require", "exports", "m", "m2", "privacyTopLevelAmbientExternalModuleImportWithoutExport_require"], function (require, exports, im_private_mi_private, im_private_mu_private, im_private_mi_public) { "use strict"; + exports.__esModule = true; // Usage of privacy error imports var privateUse_im_private_mi_private = new im_private_mi_private.c_private(); exports.publicUse_im_private_mi_private = new im_private_mi_private.c_private(); diff --git a/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithExport.js b/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithExport.js index a01f1ef611f..a89d49609e9 100644 --- a/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithExport.js +++ b/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithExport.js @@ -102,6 +102,7 @@ export var publicUse_im_public_mu_public: im_public_mu_public.i; //// [privacyTopLevelInternalReferenceImportWithExport.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; // private elements var m_private; (function (m_private) { diff --git a/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithoutExport.js b/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithoutExport.js index 2554085b94b..85a6cc3691a 100644 --- a/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithoutExport.js +++ b/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithoutExport.js @@ -103,6 +103,7 @@ export var publicUse_im_private_mu_public: im_private_mu_public.i; //// [privacyTopLevelInternalReferenceImportWithoutExport.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; // private elements var m_private; (function (m_private) { diff --git a/tests/baselines/reference/privacyTypeParameterOfFunction.js b/tests/baselines/reference/privacyTypeParameterOfFunction.js index 84034362fac..98e0a57d59e 100644 --- a/tests/baselines/reference/privacyTypeParameterOfFunction.js +++ b/tests/baselines/reference/privacyTypeParameterOfFunction.js @@ -134,6 +134,7 @@ function privateFunctionWithPublicTypeParametersWithoutExtends() { //// [privacyTypeParameterOfFunction.js] "use strict"; +exports.__esModule = true; var privateClass = (function () { function privateClass() { } diff --git a/tests/baselines/reference/privacyTypeParameterOfFunctionDeclFile.js b/tests/baselines/reference/privacyTypeParameterOfFunctionDeclFile.js index 3eb6027b050..f5fdf6dfff8 100644 --- a/tests/baselines/reference/privacyTypeParameterOfFunctionDeclFile.js +++ b/tests/baselines/reference/privacyTypeParameterOfFunctionDeclFile.js @@ -440,6 +440,7 @@ module privateModule { //// [privacyTypeParameterOfFunctionDeclFile.js] "use strict"; +exports.__esModule = true; var privateClass = (function () { function privateClass() { } diff --git a/tests/baselines/reference/privacyTypeParametersOfClass.js b/tests/baselines/reference/privacyTypeParametersOfClass.js index 3d28e145b32..ba1a9bd10e0 100644 --- a/tests/baselines/reference/privacyTypeParametersOfClass.js +++ b/tests/baselines/reference/privacyTypeParametersOfClass.js @@ -45,6 +45,7 @@ class privateClassWithPublicTypeParametersWithoutExtends { //// [privacyTypeParametersOfClass.js] "use strict"; +exports.__esModule = true; var privateClass = (function () { function privateClass() { } diff --git a/tests/baselines/reference/privacyTypeParametersOfClassDeclFile.js b/tests/baselines/reference/privacyTypeParametersOfClassDeclFile.js index 3ccdec46d7c..8e21589de42 100644 --- a/tests/baselines/reference/privacyTypeParametersOfClassDeclFile.js +++ b/tests/baselines/reference/privacyTypeParametersOfClassDeclFile.js @@ -156,6 +156,7 @@ module privateModule { //// [privacyTypeParametersOfClassDeclFile.js] "use strict"; +exports.__esModule = true; var privateClass = (function () { function privateClass() { } diff --git a/tests/baselines/reference/privacyTypeParametersOfInterface.js b/tests/baselines/reference/privacyTypeParametersOfInterface.js index a330ea76e13..0b511a01f06 100644 --- a/tests/baselines/reference/privacyTypeParametersOfInterface.js +++ b/tests/baselines/reference/privacyTypeParametersOfInterface.js @@ -60,6 +60,7 @@ interface privateInterfaceWithPublicTypeParametersWithoutExtends { //// [privacyTypeParametersOfInterface.js] "use strict"; +exports.__esModule = true; var privateClass = (function () { function privateClass() { } diff --git a/tests/baselines/reference/privacyTypeParametersOfInterfaceDeclFile.js b/tests/baselines/reference/privacyTypeParametersOfInterfaceDeclFile.js index 7c92ed701d9..f7d107b5855 100644 --- a/tests/baselines/reference/privacyTypeParametersOfInterfaceDeclFile.js +++ b/tests/baselines/reference/privacyTypeParametersOfInterfaceDeclFile.js @@ -192,6 +192,7 @@ module privateModule { //// [privacyTypeParametersOfInterfaceDeclFile.js] "use strict"; +exports.__esModule = true; var privateClass = (function () { function privateClass() { } diff --git a/tests/baselines/reference/privacyVar.js b/tests/baselines/reference/privacyVar.js index 0d133743709..4c97d273c3e 100644 --- a/tests/baselines/reference/privacyVar.js +++ b/tests/baselines/reference/privacyVar.js @@ -176,6 +176,7 @@ export var glo_v24_public: glo_C2_private = new glo_C2_private(); // error //// [privacyVar.js] "use strict"; +exports.__esModule = true; var m1; (function (m1) { var C1_public = (function () { diff --git a/tests/baselines/reference/privacyVarDeclFile.js b/tests/baselines/reference/privacyVarDeclFile.js index 102aeea58a4..eab99747849 100644 --- a/tests/baselines/reference/privacyVarDeclFile.js +++ b/tests/baselines/reference/privacyVarDeclFile.js @@ -427,6 +427,7 @@ module publicModuleInGlobal { //// [privacyVarDeclFile_externalModule.js] "use strict"; +exports.__esModule = true; var privateClass = (function () { function privateClass() { } diff --git a/tests/baselines/reference/privateAccessInSubclass1.js b/tests/baselines/reference/privateAccessInSubclass1.js index 21ff4793fb3..bab68b8d67e 100644 --- a/tests/baselines/reference/privateAccessInSubclass1.js +++ b/tests/baselines/reference/privateAccessInSubclass1.js @@ -10,11 +10,16 @@ class D extends Base { } //// [privateAccessInSubclass1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -23,7 +28,7 @@ var Base = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.myMethod = function () { this.options; diff --git a/tests/baselines/reference/privateInstanceMemberAccessibility.js b/tests/baselines/reference/privateInstanceMemberAccessibility.js index 6fa05178f91..8448f142bbb 100644 --- a/tests/baselines/reference/privateInstanceMemberAccessibility.js +++ b/tests/baselines/reference/privateInstanceMemberAccessibility.js @@ -14,11 +14,16 @@ class Derived extends Base { } //// [privateInstanceMemberAccessibility.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -27,7 +32,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.x = _super.prototype.foo; // error _this.z = _super.prototype.foo; // error return _this; diff --git a/tests/baselines/reference/privatePropertyUsingObjectType.js b/tests/baselines/reference/privatePropertyUsingObjectType.js index 0c16d8bafff..65e2129a5fc 100644 --- a/tests/baselines/reference/privatePropertyUsingObjectType.js +++ b/tests/baselines/reference/privatePropertyUsingObjectType.js @@ -12,6 +12,7 @@ export interface IFilterProvider { //// [privatePropertyUsingObjectType.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var FilterManager = (function () { function FilterManager() { } diff --git a/tests/baselines/reference/privateProtectedMembersAreNotAccessibleDestructuring.js b/tests/baselines/reference/privateProtectedMembersAreNotAccessibleDestructuring.js index b732661edfc..be01293a2cd 100644 --- a/tests/baselines/reference/privateProtectedMembersAreNotAccessibleDestructuring.js +++ b/tests/baselines/reference/privateProtectedMembersAreNotAccessibleDestructuring.js @@ -22,11 +22,16 @@ let { priv: a, prot: b, privateMethod: f } = k; // error //// [privateProtectedMembersAreNotAccessibleDestructuring.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var K = (function () { function K() { } @@ -40,7 +45,7 @@ var K = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.prototype.m2 = function () { var a = this.priv; // error diff --git a/tests/baselines/reference/privateStaticMemberAccessibility.js b/tests/baselines/reference/privateStaticMemberAccessibility.js index c1897e8503a..92a8713ef8f 100644 --- a/tests/baselines/reference/privateStaticMemberAccessibility.js +++ b/tests/baselines/reference/privateStaticMemberAccessibility.js @@ -9,11 +9,16 @@ class Derived extends Base { } //// [privateStaticMemberAccessibility.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -22,7 +27,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.bing = function () { return Base.foo; }; // error return _this; } diff --git a/tests/baselines/reference/privateStaticNotAccessibleInClodule2.js b/tests/baselines/reference/privateStaticNotAccessibleInClodule2.js index a93823654d4..c4af30f1456 100644 --- a/tests/baselines/reference/privateStaticNotAccessibleInClodule2.js +++ b/tests/baselines/reference/privateStaticNotAccessibleInClodule2.js @@ -16,11 +16,16 @@ module D { //// [privateStaticNotAccessibleInClodule2.js] // Any attempt to access a private property member outside the class body that contains its declaration results in a compile-time error. -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -29,7 +34,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/project/baseline/amd/decl.js b/tests/baselines/reference/project/baseline/amd/decl.js index 2586bbb23bd..1e03f7745d2 100644 --- a/tests/baselines/reference/project/baseline/amd/decl.js +++ b/tests/baselines/reference/project/baseline/amd/decl.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; ; function point(x, y) { return { x: x, y: y }; diff --git a/tests/baselines/reference/project/baseline/amd/emit.js b/tests/baselines/reference/project/baseline/amd/emit.js index b66e5b6e6ba..b4d6d12445b 100644 --- a/tests/baselines/reference/project/baseline/amd/emit.js +++ b/tests/baselines/reference/project/baseline/amd/emit.js @@ -1,4 +1,5 @@ define(["require", "exports", "./decl"], function (require, exports, g) { "use strict"; + exports.__esModule = true; var p = g.point(10, 20); }); diff --git a/tests/baselines/reference/project/baseline/node/decl.js b/tests/baselines/reference/project/baseline/node/decl.js index f6c19174e54..b7047c3f047 100644 --- a/tests/baselines/reference/project/baseline/node/decl.js +++ b/tests/baselines/reference/project/baseline/node/decl.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; ; function point(x, y) { return { x: x, y: y }; diff --git a/tests/baselines/reference/project/baseline/node/emit.js b/tests/baselines/reference/project/baseline/node/emit.js index b33f5d1b198..9410f82bc32 100644 --- a/tests/baselines/reference/project/baseline/node/emit.js +++ b/tests/baselines/reference/project/baseline/node/emit.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; var g = require("./decl"); var p = g.point(10, 20); diff --git a/tests/baselines/reference/project/baseline2/amd/decl.js b/tests/baselines/reference/project/baseline2/amd/decl.js index 2586bbb23bd..1e03f7745d2 100644 --- a/tests/baselines/reference/project/baseline2/amd/decl.js +++ b/tests/baselines/reference/project/baseline2/amd/decl.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; ; function point(x, y) { return { x: x, y: y }; diff --git a/tests/baselines/reference/project/baseline2/amd/dont_emit.js b/tests/baselines/reference/project/baseline2/amd/dont_emit.js index 523d596dca1..18dae0f6420 100644 --- a/tests/baselines/reference/project/baseline2/amd/dont_emit.js +++ b/tests/baselines/reference/project/baseline2/amd/dont_emit.js @@ -1,4 +1,5 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var p = { x: 10, y: 20 }; }); diff --git a/tests/baselines/reference/project/baseline2/node/decl.js b/tests/baselines/reference/project/baseline2/node/decl.js index f6c19174e54..b7047c3f047 100644 --- a/tests/baselines/reference/project/baseline2/node/decl.js +++ b/tests/baselines/reference/project/baseline2/node/decl.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; ; function point(x, y) { return { x: x, y: y }; diff --git a/tests/baselines/reference/project/baseline2/node/dont_emit.js b/tests/baselines/reference/project/baseline2/node/dont_emit.js index e5a1637efb1..ce766eee086 100644 --- a/tests/baselines/reference/project/baseline2/node/dont_emit.js +++ b/tests/baselines/reference/project/baseline2/node/dont_emit.js @@ -1,2 +1,3 @@ "use strict"; +exports.__esModule = true; var p = { x: 10, y: 20 }; diff --git a/tests/baselines/reference/project/baseline3/amd/nestedModule.js b/tests/baselines/reference/project/baseline3/amd/nestedModule.js index 36eb17665d6..c4f4e37489d 100644 --- a/tests/baselines/reference/project/baseline3/amd/nestedModule.js +++ b/tests/baselines/reference/project/baseline3/amd/nestedModule.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var outer; (function (outer) { var inner; diff --git a/tests/baselines/reference/project/baseline3/node/nestedModule.js b/tests/baselines/reference/project/baseline3/node/nestedModule.js index 1d5c5c9d534..345fd8914cc 100644 --- a/tests/baselines/reference/project/baseline3/node/nestedModule.js +++ b/tests/baselines/reference/project/baseline3/node/nestedModule.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var outer; (function (outer) { var inner; diff --git a/tests/baselines/reference/project/declarationDir/amd/a.js b/tests/baselines/reference/project/declarationDir/amd/a.js index 331c004bd67..4db463a7966 100644 --- a/tests/baselines/reference/project/declarationDir/amd/a.js +++ b/tests/baselines/reference/project/declarationDir/amd/a.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var A = (function () { function A() { } diff --git a/tests/baselines/reference/project/declarationDir/amd/subfolder/b.js b/tests/baselines/reference/project/declarationDir/amd/subfolder/b.js index e2cdda8530b..bdae3c44b0a 100644 --- a/tests/baselines/reference/project/declarationDir/amd/subfolder/b.js +++ b/tests/baselines/reference/project/declarationDir/amd/subfolder/b.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var B = (function () { function B() { } diff --git a/tests/baselines/reference/project/declarationDir/amd/subfolder/c.js b/tests/baselines/reference/project/declarationDir/amd/subfolder/c.js index 212511f2bf5..ff657652a4a 100644 --- a/tests/baselines/reference/project/declarationDir/amd/subfolder/c.js +++ b/tests/baselines/reference/project/declarationDir/amd/subfolder/c.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var C = (function () { function C() { } diff --git a/tests/baselines/reference/project/declarationDir/node/a.js b/tests/baselines/reference/project/declarationDir/node/a.js index 35f5adf27f0..2139e86c811 100644 --- a/tests/baselines/reference/project/declarationDir/node/a.js +++ b/tests/baselines/reference/project/declarationDir/node/a.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var A = (function () { function A() { } diff --git a/tests/baselines/reference/project/declarationDir/node/subfolder/b.js b/tests/baselines/reference/project/declarationDir/node/subfolder/b.js index 7b46df97ac3..df27fec56d1 100644 --- a/tests/baselines/reference/project/declarationDir/node/subfolder/b.js +++ b/tests/baselines/reference/project/declarationDir/node/subfolder/b.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var B = (function () { function B() { } diff --git a/tests/baselines/reference/project/declarationDir/node/subfolder/c.js b/tests/baselines/reference/project/declarationDir/node/subfolder/c.js index 65238579edc..385b6df7591 100644 --- a/tests/baselines/reference/project/declarationDir/node/subfolder/c.js +++ b/tests/baselines/reference/project/declarationDir/node/subfolder/c.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var C = (function () { function C() { } diff --git a/tests/baselines/reference/project/declarationDir2/amd/out/a.js b/tests/baselines/reference/project/declarationDir2/amd/out/a.js index 331c004bd67..4db463a7966 100644 --- a/tests/baselines/reference/project/declarationDir2/amd/out/a.js +++ b/tests/baselines/reference/project/declarationDir2/amd/out/a.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var A = (function () { function A() { } diff --git a/tests/baselines/reference/project/declarationDir2/amd/out/subfolder/b.js b/tests/baselines/reference/project/declarationDir2/amd/out/subfolder/b.js index e2cdda8530b..bdae3c44b0a 100644 --- a/tests/baselines/reference/project/declarationDir2/amd/out/subfolder/b.js +++ b/tests/baselines/reference/project/declarationDir2/amd/out/subfolder/b.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var B = (function () { function B() { } diff --git a/tests/baselines/reference/project/declarationDir2/amd/out/subfolder/c.js b/tests/baselines/reference/project/declarationDir2/amd/out/subfolder/c.js index 212511f2bf5..ff657652a4a 100644 --- a/tests/baselines/reference/project/declarationDir2/amd/out/subfolder/c.js +++ b/tests/baselines/reference/project/declarationDir2/amd/out/subfolder/c.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var C = (function () { function C() { } diff --git a/tests/baselines/reference/project/declarationDir2/node/out/a.js b/tests/baselines/reference/project/declarationDir2/node/out/a.js index 35f5adf27f0..2139e86c811 100644 --- a/tests/baselines/reference/project/declarationDir2/node/out/a.js +++ b/tests/baselines/reference/project/declarationDir2/node/out/a.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var A = (function () { function A() { } diff --git a/tests/baselines/reference/project/declarationDir2/node/out/subfolder/b.js b/tests/baselines/reference/project/declarationDir2/node/out/subfolder/b.js index 7b46df97ac3..df27fec56d1 100644 --- a/tests/baselines/reference/project/declarationDir2/node/out/subfolder/b.js +++ b/tests/baselines/reference/project/declarationDir2/node/out/subfolder/b.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var B = (function () { function B() { } diff --git a/tests/baselines/reference/project/declarationDir2/node/out/subfolder/c.js b/tests/baselines/reference/project/declarationDir2/node/out/subfolder/c.js index 65238579edc..385b6df7591 100644 --- a/tests/baselines/reference/project/declarationDir2/node/out/subfolder/c.js +++ b/tests/baselines/reference/project/declarationDir2/node/out/subfolder/c.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var C = (function () { function C() { } diff --git a/tests/baselines/reference/project/declarationDir3/amd/out.js b/tests/baselines/reference/project/declarationDir3/amd/out.js index 6c49867c908..b90d4415806 100644 --- a/tests/baselines/reference/project/declarationDir3/amd/out.js +++ b/tests/baselines/reference/project/declarationDir3/amd/out.js @@ -1,5 +1,6 @@ define("subfolder/b", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var B = (function () { function B() { } @@ -9,6 +10,7 @@ define("subfolder/b", ["require", "exports"], function (require, exports) { }); define("a", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var A = (function () { function A() { } @@ -18,6 +20,7 @@ define("a", ["require", "exports"], function (require, exports) { }); define("subfolder/c", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var C = (function () { function C() { } diff --git a/tests/baselines/reference/project/declarationsCascadingImports/amd/m4.js b/tests/baselines/reference/project/declarationsCascadingImports/amd/m4.js index bb607f4b5b0..d1c2d5f4aca 100644 --- a/tests/baselines/reference/project/declarationsCascadingImports/amd/m4.js +++ b/tests/baselines/reference/project/declarationsCascadingImports/amd/m4.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var d = (function () { function d() { } diff --git a/tests/baselines/reference/project/declarationsCascadingImports/node/m4.js b/tests/baselines/reference/project/declarationsCascadingImports/node/m4.js index 52ecf390373..1c9931a6d1d 100644 --- a/tests/baselines/reference/project/declarationsCascadingImports/node/m4.js +++ b/tests/baselines/reference/project/declarationsCascadingImports/node/m4.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var d = (function () { function d() { } diff --git a/tests/baselines/reference/project/declarationsGlobalImport/amd/glo_m4.js b/tests/baselines/reference/project/declarationsGlobalImport/amd/glo_m4.js index bb607f4b5b0..d1c2d5f4aca 100644 --- a/tests/baselines/reference/project/declarationsGlobalImport/amd/glo_m4.js +++ b/tests/baselines/reference/project/declarationsGlobalImport/amd/glo_m4.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var d = (function () { function d() { } diff --git a/tests/baselines/reference/project/declarationsGlobalImport/amd/useModule.js b/tests/baselines/reference/project/declarationsGlobalImport/amd/useModule.js index b9390ddc239..1610052986d 100644 --- a/tests/baselines/reference/project/declarationsGlobalImport/amd/useModule.js +++ b/tests/baselines/reference/project/declarationsGlobalImport/amd/useModule.js @@ -1,5 +1,6 @@ define(["require", "exports", "glo_m4"], function (require, exports, glo_m4) { "use strict"; + exports.__esModule = true; exports.useGlo_m4_x4 = glo_m4.x; exports.useGlo_m4_d4 = glo_m4.d; exports.useGlo_m4_f4 = glo_m4.foo(); diff --git a/tests/baselines/reference/project/declarationsGlobalImport/node/glo_m4.js b/tests/baselines/reference/project/declarationsGlobalImport/node/glo_m4.js index 52ecf390373..1c9931a6d1d 100644 --- a/tests/baselines/reference/project/declarationsGlobalImport/node/glo_m4.js +++ b/tests/baselines/reference/project/declarationsGlobalImport/node/glo_m4.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var d = (function () { function d() { } diff --git a/tests/baselines/reference/project/declarationsGlobalImport/node/useModule.js b/tests/baselines/reference/project/declarationsGlobalImport/node/useModule.js index d9219f20148..b7ddd253b1a 100644 --- a/tests/baselines/reference/project/declarationsGlobalImport/node/useModule.js +++ b/tests/baselines/reference/project/declarationsGlobalImport/node/useModule.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var glo_m4 = require("glo_m4"); exports.useGlo_m4_x4 = glo_m4.x; exports.useGlo_m4_d4 = glo_m4.d; diff --git a/tests/baselines/reference/project/declarationsImportedInPrivate/amd/private_m4.js b/tests/baselines/reference/project/declarationsImportedInPrivate/amd/private_m4.js index bb607f4b5b0..d1c2d5f4aca 100644 --- a/tests/baselines/reference/project/declarationsImportedInPrivate/amd/private_m4.js +++ b/tests/baselines/reference/project/declarationsImportedInPrivate/amd/private_m4.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var d = (function () { function d() { } diff --git a/tests/baselines/reference/project/declarationsImportedInPrivate/amd/useModule.js b/tests/baselines/reference/project/declarationsImportedInPrivate/amd/useModule.js index a5da0ab9314..6ecb0c59793 100644 --- a/tests/baselines/reference/project/declarationsImportedInPrivate/amd/useModule.js +++ b/tests/baselines/reference/project/declarationsImportedInPrivate/amd/useModule.js @@ -1,5 +1,6 @@ define(["require", "exports", "private_m4"], function (require, exports, private_m4) { "use strict"; + exports.__esModule = true; var usePrivate_m4_m1; (function (usePrivate_m4_m1) { var x3 = private_m4.x; diff --git a/tests/baselines/reference/project/declarationsImportedInPrivate/node/private_m4.js b/tests/baselines/reference/project/declarationsImportedInPrivate/node/private_m4.js index 52ecf390373..1c9931a6d1d 100644 --- a/tests/baselines/reference/project/declarationsImportedInPrivate/node/private_m4.js +++ b/tests/baselines/reference/project/declarationsImportedInPrivate/node/private_m4.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var d = (function () { function d() { } diff --git a/tests/baselines/reference/project/declarationsImportedInPrivate/node/useModule.js b/tests/baselines/reference/project/declarationsImportedInPrivate/node/useModule.js index 3cc7f82feb7..79310d89c02 100644 --- a/tests/baselines/reference/project/declarationsImportedInPrivate/node/useModule.js +++ b/tests/baselines/reference/project/declarationsImportedInPrivate/node/useModule.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; // only used privately no need to emit var private_m4 = require("private_m4"); var usePrivate_m4_m1; diff --git a/tests/baselines/reference/project/declarationsImportedUseInFunction/amd/fncOnly_m4.js b/tests/baselines/reference/project/declarationsImportedUseInFunction/amd/fncOnly_m4.js index bb607f4b5b0..d1c2d5f4aca 100644 --- a/tests/baselines/reference/project/declarationsImportedUseInFunction/amd/fncOnly_m4.js +++ b/tests/baselines/reference/project/declarationsImportedUseInFunction/amd/fncOnly_m4.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var d = (function () { function d() { } diff --git a/tests/baselines/reference/project/declarationsImportedUseInFunction/amd/useModule.js b/tests/baselines/reference/project/declarationsImportedUseInFunction/amd/useModule.js index 7485d0fb229..c6c57dabc81 100644 --- a/tests/baselines/reference/project/declarationsImportedUseInFunction/amd/useModule.js +++ b/tests/baselines/reference/project/declarationsImportedUseInFunction/amd/useModule.js @@ -1,4 +1,5 @@ define(["require", "exports", "fncOnly_m4"], function (require, exports, fncOnly_m4) { "use strict"; + exports.__esModule = true; exports.useFncOnly_m4_f4 = fncOnly_m4.foo(); }); diff --git a/tests/baselines/reference/project/declarationsImportedUseInFunction/node/fncOnly_m4.js b/tests/baselines/reference/project/declarationsImportedUseInFunction/node/fncOnly_m4.js index 52ecf390373..1c9931a6d1d 100644 --- a/tests/baselines/reference/project/declarationsImportedUseInFunction/node/fncOnly_m4.js +++ b/tests/baselines/reference/project/declarationsImportedUseInFunction/node/fncOnly_m4.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var d = (function () { function d() { } diff --git a/tests/baselines/reference/project/declarationsImportedUseInFunction/node/useModule.js b/tests/baselines/reference/project/declarationsImportedUseInFunction/node/useModule.js index 095acfb7fc9..991afa567cf 100644 --- a/tests/baselines/reference/project/declarationsImportedUseInFunction/node/useModule.js +++ b/tests/baselines/reference/project/declarationsImportedUseInFunction/node/useModule.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; var fncOnly_m4 = require("fncOnly_m4"); exports.useFncOnly_m4_f4 = fncOnly_m4.foo(); diff --git a/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/amd/m4.js b/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/amd/m4.js index bb607f4b5b0..d1c2d5f4aca 100644 --- a/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/amd/m4.js +++ b/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/amd/m4.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var d = (function () { function d() { } diff --git a/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/amd/m5.js b/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/amd/m5.js index 9e8ba0f7ade..1a0305591cc 100644 --- a/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/amd/m5.js +++ b/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/amd/m5.js @@ -1,5 +1,6 @@ define(["require", "exports", "m4"], function (require, exports, m4) { "use strict"; + exports.__esModule = true; function foo2() { return new m4.d(); } diff --git a/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/amd/useModule.js b/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/amd/useModule.js index db9e68fbed9..6f962bd42e5 100644 --- a/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/amd/useModule.js +++ b/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/amd/useModule.js @@ -1,5 +1,6 @@ define(["require", "exports", "m5"], function (require, exports, m5) { "use strict"; + exports.__esModule = true; exports.d = m5.foo2(); exports.x = m5.foo2; function n() { diff --git a/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/node/m4.js b/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/node/m4.js index 52ecf390373..1c9931a6d1d 100644 --- a/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/node/m4.js +++ b/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/node/m4.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var d = (function () { function d() { } diff --git a/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/node/m5.js b/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/node/m5.js index a7e34c60fe3..db280e7fd8e 100644 --- a/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/node/m5.js +++ b/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/node/m5.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m4 = require("m4"); // Emit used function foo2() { return new m4.d(); diff --git a/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/node/useModule.js b/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/node/useModule.js index 2bde79432f7..7cc88b54ff3 100644 --- a/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/node/useModule.js +++ b/tests/baselines/reference/project/declarationsIndirectImportShouldResultInError/node/useModule.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; // Do not emit unused import var m5 = require("m5"); exports.d = m5.foo2(); diff --git a/tests/baselines/reference/project/declarationsMultipleTimesImport/amd/m4.js b/tests/baselines/reference/project/declarationsMultipleTimesImport/amd/m4.js index bb607f4b5b0..d1c2d5f4aca 100644 --- a/tests/baselines/reference/project/declarationsMultipleTimesImport/amd/m4.js +++ b/tests/baselines/reference/project/declarationsMultipleTimesImport/amd/m4.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var d = (function () { function d() { } diff --git a/tests/baselines/reference/project/declarationsMultipleTimesImport/amd/useModule.js b/tests/baselines/reference/project/declarationsMultipleTimesImport/amd/useModule.js index 0ec3a0d8331..5375f44c013 100644 --- a/tests/baselines/reference/project/declarationsMultipleTimesImport/amd/useModule.js +++ b/tests/baselines/reference/project/declarationsMultipleTimesImport/amd/useModule.js @@ -1,5 +1,6 @@ define(["require", "exports", "m4", "m4"], function (require, exports, m4, multiImport_m4) { "use strict"; + exports.__esModule = true; exports.x4 = m4.x; exports.d4 = m4.d; exports.f4 = m4.foo(); diff --git a/tests/baselines/reference/project/declarationsMultipleTimesImport/node/m4.js b/tests/baselines/reference/project/declarationsMultipleTimesImport/node/m4.js index 52ecf390373..1c9931a6d1d 100644 --- a/tests/baselines/reference/project/declarationsMultipleTimesImport/node/m4.js +++ b/tests/baselines/reference/project/declarationsMultipleTimesImport/node/m4.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var d = (function () { function d() { } diff --git a/tests/baselines/reference/project/declarationsMultipleTimesImport/node/useModule.js b/tests/baselines/reference/project/declarationsMultipleTimesImport/node/useModule.js index 64b9438d96e..395cbeee966 100644 --- a/tests/baselines/reference/project/declarationsMultipleTimesImport/node/useModule.js +++ b/tests/baselines/reference/project/declarationsMultipleTimesImport/node/useModule.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m4 = require("m4"); // Emit used exports.x4 = m4.x; exports.d4 = m4.d; diff --git a/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/amd/m4.js b/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/amd/m4.js index bb607f4b5b0..d1c2d5f4aca 100644 --- a/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/amd/m4.js +++ b/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/amd/m4.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var d = (function () { function d() { } diff --git a/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/amd/m5.js b/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/amd/m5.js index 9e8ba0f7ade..1a0305591cc 100644 --- a/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/amd/m5.js +++ b/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/amd/m5.js @@ -1,5 +1,6 @@ define(["require", "exports", "m4"], function (require, exports, m4) { "use strict"; + exports.__esModule = true; function foo2() { return new m4.d(); } diff --git a/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/amd/useModule.js b/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/amd/useModule.js index cc2eecd2208..b8a22cfdc1f 100644 --- a/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/amd/useModule.js +++ b/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/amd/useModule.js @@ -1,5 +1,6 @@ define(["require", "exports", "m4", "m5"], function (require, exports, m4, m5) { "use strict"; + exports.__esModule = true; exports.x4 = m4.x; exports.d4 = m4.d; exports.f4 = m4.foo(); diff --git a/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/node/m4.js b/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/node/m4.js index 52ecf390373..1c9931a6d1d 100644 --- a/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/node/m4.js +++ b/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/node/m4.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var d = (function () { function d() { } diff --git a/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/node/m5.js b/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/node/m5.js index a7e34c60fe3..db280e7fd8e 100644 --- a/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/node/m5.js +++ b/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/node/m5.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m4 = require("m4"); // Emit used function foo2() { return new m4.d(); diff --git a/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/node/useModule.js b/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/node/useModule.js index b4132f79b1f..49958bb9814 100644 --- a/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/node/useModule.js +++ b/tests/baselines/reference/project/declarationsMultipleTimesMultipleImport/node/useModule.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m4 = require("m4"); // Emit used exports.x4 = m4.x; exports.d4 = m4.d; diff --git a/tests/baselines/reference/project/declarationsSimpleImport/amd/m4.js b/tests/baselines/reference/project/declarationsSimpleImport/amd/m4.js index bb607f4b5b0..d1c2d5f4aca 100644 --- a/tests/baselines/reference/project/declarationsSimpleImport/amd/m4.js +++ b/tests/baselines/reference/project/declarationsSimpleImport/amd/m4.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var d = (function () { function d() { } diff --git a/tests/baselines/reference/project/declarationsSimpleImport/amd/useModule.js b/tests/baselines/reference/project/declarationsSimpleImport/amd/useModule.js index 634a988c1b8..af5fcb7d874 100644 --- a/tests/baselines/reference/project/declarationsSimpleImport/amd/useModule.js +++ b/tests/baselines/reference/project/declarationsSimpleImport/amd/useModule.js @@ -1,5 +1,6 @@ define(["require", "exports", "m4"], function (require, exports, m4) { "use strict"; + exports.__esModule = true; exports.x4 = m4.x; exports.d4 = m4.d; exports.f4 = m4.foo(); diff --git a/tests/baselines/reference/project/declarationsSimpleImport/node/m4.js b/tests/baselines/reference/project/declarationsSimpleImport/node/m4.js index 52ecf390373..1c9931a6d1d 100644 --- a/tests/baselines/reference/project/declarationsSimpleImport/node/m4.js +++ b/tests/baselines/reference/project/declarationsSimpleImport/node/m4.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var d = (function () { function d() { } diff --git a/tests/baselines/reference/project/declarationsSimpleImport/node/useModule.js b/tests/baselines/reference/project/declarationsSimpleImport/node/useModule.js index 40df471507c..3a5602a2166 100644 --- a/tests/baselines/reference/project/declarationsSimpleImport/node/useModule.js +++ b/tests/baselines/reference/project/declarationsSimpleImport/node/useModule.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m4 = require("m4"); // Emit used exports.x4 = m4.x; exports.d4 = m4.d; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js index 8b73fc550cf..6ec26abec8e 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js @@ -9,6 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { }; define(["require", "exports", "angular2/core"], function (require, exports, ng) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var MyClass1 = (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js index 3c1d2cd6da6..274520bc752 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js @@ -8,6 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +Object.defineProperty(exports, "__esModule", { value: true }); var ng = require("angular2/core"); var MyClass1 = (function () { function MyClass1(_elementRef) { diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js index 8b73fc550cf..6ec26abec8e 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js @@ -9,6 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { }; define(["require", "exports", "angular2/core"], function (require, exports, ng) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var MyClass1 = (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js index 3c1d2cd6da6..274520bc752 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js @@ -8,6 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +Object.defineProperty(exports, "__esModule", { value: true }); var ng = require("angular2/core"); var MyClass1 = (function () { function MyClass1(_elementRef) { diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js index 8b73fc550cf..6ec26abec8e 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js @@ -9,6 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { }; define(["require", "exports", "angular2/core"], function (require, exports, ng) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var MyClass1 = (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js index 3c1d2cd6da6..274520bc752 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js @@ -8,6 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +Object.defineProperty(exports, "__esModule", { value: true }); var ng = require("angular2/core"); var MyClass1 = (function () { function MyClass1(_elementRef) { diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js index 8b73fc550cf..6ec26abec8e 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js @@ -9,6 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { }; define(["require", "exports", "angular2/core"], function (require, exports, ng) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var MyClass1 = (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js index 3c1d2cd6da6..274520bc752 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js @@ -8,6 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +Object.defineProperty(exports, "__esModule", { value: true }); var ng = require("angular2/core"); var MyClass1 = (function () { function MyClass1(_elementRef) { diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js index 8b73fc550cf..6ec26abec8e 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js @@ -9,6 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { }; define(["require", "exports", "angular2/core"], function (require, exports, ng) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var MyClass1 = (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js index 3c1d2cd6da6..274520bc752 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js @@ -8,6 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +Object.defineProperty(exports, "__esModule", { value: true }); var ng = require("angular2/core"); var MyClass1 = (function () { function MyClass1(_elementRef) { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/amd/ref/m2.js b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/amd/ref/m2.js index 2ccb7d6f77a..7eeee43049b 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/amd/ref/m2.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/amd/ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/amd/ref/m2.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/amd/ref/m2.js.map index 891c03b13f2..c44e24a081e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/amd/ref/m2.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/amd/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/node/ref/m2.js b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/node/ref/m2.js index b991eda4382..d393dda0c57 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/node/ref/m2.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/node/ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/node/ref/m2.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/node/ref/m2.js.map index 30f6e242bc8..436eab5db94 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/node/ref/m2.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderNoOutdir/node/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js index 2ccb7d6f77a..7eeee43049b 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map index 891c03b13f2..c44e24a081e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js index b991eda4382..d393dda0c57 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map index 30f6e242bc8..436eab5db94 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js index 3dd9960df14..1c199b7384a 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js @@ -10,6 +10,7 @@ function m1_f1() { } define("ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { 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 dce282ee37f..df6d2c811c0 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","../ref/m2.ts","../test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../ref/m2.ts","../test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ 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 index ccf78301cb1..749fbd732a5 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js @@ -10,6 +10,7 @@ function m1_f1() { } define("ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { 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 1316ec74659..0c75dbb2b00 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","../ref/m2.ts","../test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../ref/m1.ts","../ref/m2.ts","../test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/diskFile0.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/diskFile0.js.map index 5db5f8f1bfb..b49f0a04b53 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/diskFile0.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/diskFile0.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/diskFile1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/diskFile1.js index d77e78e3751..c67e35d1b89 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/diskFile1.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/diskFile1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/ref/m1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/ref/m1.js index b663057aeff..1935dadfdb3 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/ref/m1.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/ref/m1.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/ref/m1.js.map index 28136d8ffc3..8f88c077a44 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/ref/m1.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/test.js index 550fa7b9564..fa9c5691047 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/test.js.map index dd409b9f2c3..b3b4c42289f 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":[],"mappings":";;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":[],"mappings":";;;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/diskFile0.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/diskFile0.js.map index 78b4b9fcfe1..80d6ba438ba 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/diskFile0.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/diskFile0.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/diskFile1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/diskFile1.js index 76a761b602d..dabe72d2787 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/diskFile1.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/diskFile1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/ref/m1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/ref/m1.js index 7ad78d4877d..d28465d805e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/ref/m1.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/ref/m1.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/ref/m1.js.map index f5f5dfcd793..6c7d26906a4 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/ref/m1.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/test.js index 033b046cfe0..46d82346a37 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/test.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); var m2 = require("../outputdir_module_multifolder_ref/m2"); exports.a1 = 10; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/test.js.map index 6ba04afda9e..3813e4b2cca 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js index b663057aeff..1935dadfdb3 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map index 28136d8ffc3..8f88c077a44 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js index 550fa7b9564..fa9c5691047 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map index dd409b9f2c3..b3b4c42289f 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":[],"mappings":";;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":[],"mappings":";;;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js index d77e78e3751..c67e35d1b89 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map index 5db5f8f1bfb..b49f0a04b53 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js index 7ad78d4877d..d28465d805e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map index f5f5dfcd793..6c7d26906a4 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js index 033b046cfe0..46d82346a37 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); var m2 = require("../outputdir_module_multifolder_ref/m2"); exports.a1 = 10; diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map index 6ba04afda9e..3813e4b2cca 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js index 76a761b602d..dabe72d2787 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map index 78b4b9fcfe1..80d6ba438ba 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ 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 index 29bc22bd61c..371d873f345 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("outputdir_module_multifolder/ref/m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("outputdir_module_multifolder/ref/m1", ["require", "exports"], function ( }); define("outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { @@ -30,6 +32,7 @@ define("outputdir_module_multifolder_ref/m2", ["require", "exports"], function ( }); define("outputdir_module_multifolder/test", ["require", "exports", "outputdir_module_multifolder/ref/m1", "outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 d9151baabe4..783691c52ed 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":["../ref/m1.ts","../../outputdir_module_multifolder_ref/m2.ts","../test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICNU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICNU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/amd/m1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/amd/m1.js index 3017cac2b88..1f3b6d7a6dc 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/amd/m1.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/amd/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/amd/m1.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/amd/m1.js.map index 43b1caa625e..16e1f512923 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/amd/m1.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/amd/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/amd/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/amd/test.js index 81972e29958..a112cba6d0e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/amd/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/amd/test.js.map index ba491a3c6fa..f1777998477 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/node/m1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/node/m1.js index efdf4bd9a30..a6a299a8a7e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/node/m1.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/node/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/node/m1.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/node/m1.js.map index 02f7bbcbb67..d16575e8a97 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/node/m1.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/node/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/node/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/node/test.js index 5bc656a7470..94e4facb645 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/node/test.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/node/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/node/test.js.map index 766ff607b54..47915c9660b 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":[],"mappings":";AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":[],"mappings":";;AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js index 3017cac2b88..1f3b6d7a6dc 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map index 43b1caa625e..16e1f512923 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js index 81972e29958..a112cba6d0e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map index ba491a3c6fa..f1777998477 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js index efdf4bd9a30..a6a299a8a7e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map index 02f7bbcbb67..d16575e8a97 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js index 5bc656a7470..94e4facb645 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map index 766ff607b54..47915c9660b 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":[],"mappings":";AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":[],"mappings":";;AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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 index d3a752a0ee4..c5e2f0c04bf 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("m1", ["require", "exports"], function (require, exports) { }); define("test", ["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 a910ecda80e..293a1478989 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":["../m1.ts","../test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../m1.ts","../test.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/amd/ref/m1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/amd/ref/m1.js index 13158547401..8359b4472ee 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/amd/ref/m1.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/amd/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/amd/ref/m1.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/amd/ref/m1.js.map index a6d24f0f020..9cef03b0711 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/amd/ref/m1.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/amd/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/amd/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/amd/test.js index cc32d33f88f..32cd3e8915e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/amd/test.js.map index ba491a3c6fa..f1777998477 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/node/ref/m1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/node/ref/m1.js index 80d76037a7f..39f0b136568 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/node/ref/m1.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/node/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/node/ref/m1.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/node/ref/m1.js.map index a23c1871126..de654530492 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/node/ref/m1.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/node/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/node/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/node/test.js index 69051eba247..61925246a0e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/node/test.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/node/test.js.map index a758d2a1cd0..4a1329681e8 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js index 13158547401..8359b4472ee 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map index a6d24f0f020..9cef03b0711 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js index cc32d33f88f..32cd3e8915e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index ba491a3c6fa..f1777998477 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js index 80d76037a7f..39f0b136568 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map index a23c1871126..de654530492 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js index 69051eba247..61925246a0e 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index a758d2a1cd0..4a1329681e8 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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 index d20feb624ba..11d40e4d23b 100644 --- a/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/mapRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("ref/m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("ref/m1", ["require", "exports"], function (require, exports) { }); define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 a3532b9e4ce..61dfeeeb8d3 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":["../ref/m1.ts","../test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/amd/ref/m2.js b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/amd/ref/m2.js index d0a6c1f583f..c467f0b8be0 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/amd/ref/m2.js +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/amd/ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/amd/ref/m2.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/amd/ref/m2.js.map index 0dab1514706..7c959ab9408 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/amd/ref/m2.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/amd/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../outputdir_mixed_subfolder/ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../outputdir_mixed_subfolder/ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/node/ref/m2.js b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/node/ref/m2.js index b5c226692a0..d43267b1c9a 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/node/ref/m2.js +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/node/ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/node/ref/m2.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/node/ref/m2.js.map index 14104ec68b9..15c5c91190e 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/node/ref/m2.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderNoOutdir/node/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../outputdir_mixed_subfolder/ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../outputdir_mixed_subfolder/ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js index 961737d6acf..9a46a37deb8 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map index 0dab1514706..7c959ab9408 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../outputdir_mixed_subfolder/ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../outputdir_mixed_subfolder/ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js index d078a80e31c..727afdc29fd 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map index 14104ec68b9..15c5c91190e 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../outputdir_mixed_subfolder/ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../outputdir_mixed_subfolder/ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ 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 index 043adb3dd6f..2a89c0fc929 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js @@ -10,6 +10,7 @@ function m1_f1() { } define("ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { 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 d8fff48f73e..0b7f01fdec5 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/ref/m2.ts","../outputdir_mixed_subfolder/test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ 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":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ 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 index b40b056b6d9..62af54d3700 100644 --- a/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js +++ b/tests/baselines/reference/project/mapRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js @@ -10,6 +10,7 @@ function m1_f1() { } define("ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { 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 bb9e992d471..d4bfc447280 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/ref/m2.ts","../outputdir_mixed_subfolder/test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ 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":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/diskFile0.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/diskFile0.js.map index 4f51d470c82..59de6353786 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/diskFile0.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/diskFile0.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/diskFile1.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/diskFile1.js index bbbb972580d..6cf63b567ba 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/diskFile1.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/diskFile1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/ref/m1.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/ref/m1.js index 7ecd677009d..2a191801c43 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/ref/m1.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/ref/m1.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/ref/m1.js.map index ee8a26cafcf..301f83dab55 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/ref/m1.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../projects/outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../projects/outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/test.js index b40eb0dad12..2dcea15d050 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/test.js.map index e60e0fbfa7a..6c74ce312be 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/diskFile0.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/diskFile0.js.map index 3c653ded700..97b03befa22 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/diskFile0.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/diskFile0.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/diskFile1.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/diskFile1.js index 338d724fe93..28edf754650 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/diskFile1.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/diskFile1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/ref/m1.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/ref/m1.js index 112ae7e7062..9a8f5b77498 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/ref/m1.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/ref/m1.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/ref/m1.js.map index 5f97087307d..bd9b5d0051a 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/ref/m1.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../projects/outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../projects/outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/test.js index 2786dcd54f3..603b29da7fa 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/test.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); var m2 = require("../outputdir_module_multifolder_ref/m2"); exports.a1 = 10; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/test.js.map index 8c64bacf533..3821a46478a 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js index 4d721e1be5d..4090486a730 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map index ee8a26cafcf..301f83dab55 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../projects/outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../projects/outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js index 6c23883b7ab..f637a581e13 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map index e60e0fbfa7a..6c74ce312be 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js index a654db8e087..fa97d15a89a 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map index 4f51d470c82..59de6353786 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js index a1d86ff1857..8de8d6f84b6 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map index 5f97087307d..bd9b5d0051a 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../projects/outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../projects/outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js index 76f1ae7fa80..ca070c2062f 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); var m2 = require("../outputdir_module_multifolder_ref/m2"); exports.a1 = 10; diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map index 8c64bacf533..3821a46478a 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js index a98ecd6f1c3..6ce6e73202e 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map index 3c653ded700..97b03befa22 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ 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 index 01c28031d8a..e4a7bb40897 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("outputdir_module_multifolder/ref/m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("outputdir_module_multifolder/ref/m1", ["require", "exports"], function ( }); define("outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { @@ -30,6 +32,7 @@ define("outputdir_module_multifolder_ref/m2", ["require", "exports"], function ( }); define("outputdir_module_multifolder/test", ["require", "exports", "outputdir_module_multifolder/ref/m1", "outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 ae1d6457599..83050ce43fe 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":["../projects/outputdir_module_multifolder/ref/m1.ts","../projects/outputdir_module_multifolder_ref/m2.ts","../projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICNU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICNU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/amd/m1.js b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/amd/m1.js index 826510699a7..b890ae8232a 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/amd/m1.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/amd/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/amd/m1.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/amd/m1.js.map index 611b73c5c7d..df737e96f26 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/amd/m1.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/amd/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../outputdir_module_simple/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../outputdir_module_simple/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/amd/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/amd/test.js index f6ab0afdc94..2cbff5fc156 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/amd/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/amd/test.js.map index a6d5cebe7f1..84f19710abc 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_simple/test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_simple/test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/node/m1.js b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/node/m1.js index 123e89b6c81..a0cc81f5af9 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/node/m1.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/node/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/node/m1.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/node/m1.js.map index 733fa0fc069..ea360554f92 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/node/m1.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/node/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../outputdir_module_simple/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../outputdir_module_simple/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/node/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/node/test.js index d96b6cae463..2cce36f74c2 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/node/test.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/node/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/node/test.js.map index 86cfbeb5b63..e395bf8648f 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_simple/test.ts"],"names":[],"mappings":";AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_simple/test.ts"],"names":[],"mappings":";;AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js index 415eb731ee6..f5001a6551e 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map index 611b73c5c7d..df737e96f26 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../outputdir_module_simple/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../outputdir_module_simple/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js index 88661b25d1d..2fb4fbfd5c3 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map index a6d5cebe7f1..84f19710abc 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_simple/test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_simple/test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js index 4c96696726b..0110f9dce16 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map index 733fa0fc069..ea360554f92 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../outputdir_module_simple/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../outputdir_module_simple/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js index 2e487817c4e..4849c53d0c4 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map index 86cfbeb5b63..e395bf8648f 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_simple/test.ts"],"names":[],"mappings":";AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_simple/test.ts"],"names":[],"mappings":";;AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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 index 1e43585f281..587721fb87a 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("m1", ["require", "exports"], function (require, exports) { }); define("test", ["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 3542da2fe04..5e9e5c8593d 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":["../outputdir_module_simple/m1.ts","../outputdir_module_simple/test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/amd/ref/m1.js b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/amd/ref/m1.js index d7fc22ee9b3..b99a41c8c3c 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/amd/ref/m1.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/amd/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/amd/ref/m1.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/amd/ref/m1.js.map index dbfe0b5d927..dcfdb34145e 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/amd/ref/m1.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/amd/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../outputdir_module_subfolder/ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../outputdir_module_subfolder/ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/amd/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/amd/test.js index a9c2e2c5462..c4c2a04f642 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/amd/test.js.map index a8d6293492c..2df46e6835c 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_subfolder/test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_subfolder/test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/node/ref/m1.js b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/node/ref/m1.js index 4423220831b..9574bd33b83 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/node/ref/m1.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/node/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/node/ref/m1.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/node/ref/m1.js.map index 172c4d4804a..44556b78663 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/node/ref/m1.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/node/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../outputdir_module_subfolder/ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../outputdir_module_subfolder/ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/node/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/node/test.js index 291a3630b3e..4ac58aea856 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/node/test.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/node/test.js.map index ef62267d957..47558364d4b 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_subfolder/test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_subfolder/test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js index 447f2cb756d..2885a499091 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map index dbfe0b5d927..dcfdb34145e 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../outputdir_module_subfolder/ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../outputdir_module_subfolder/ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js index bd2c181d29e..0ee63c42070 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index a8d6293492c..2df46e6835c 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_subfolder/test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_subfolder/test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js index b4b9b2dc7e0..fa9502d4d64 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map index 172c4d4804a..44556b78663 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../outputdir_module_subfolder/ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../outputdir_module_subfolder/ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js index c162eaa3671..cabfd9f98d6 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index ef62267d957..47558364d4b 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_subfolder/test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../outputdir_module_subfolder/test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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 index 23442cdbfa6..d6d12689721 100644 --- a/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/mapRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("ref/m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("ref/m1", ["require", "exports"], function (require, exports) { }); define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 3096c610237..aa198a56dbe 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":["../outputdir_module_subfolder/ref/m1.ts","../outputdir_module_subfolder/test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/amd/ref/m2.js b/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/amd/ref/m2.js index 70911579465..f373c246d48 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/amd/ref/m2.js +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/amd/ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/amd/ref/m2.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/amd/ref/m2.js.map index c657ed8edce..4d37c4456a3 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/amd/ref/m2.js.map +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/amd/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/node/ref/m2.js b/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/node/ref/m2.js index e4c76ba72e2..9557c3a613c 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/node/ref/m2.js +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/node/ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/node/ref/m2.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/node/ref/m2.js.map index 56f12c22903..6ba684e3841 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/node/ref/m2.js.map +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderNoOutdir/node/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js index 70911579465..f373c246d48 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map index c657ed8edce..4d37c4456a3 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js index e4c76ba72e2..9557c3a613c 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map index 56f12c22903..6ba684e3841 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_mixed_subfolder/ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ 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 index b1f7d5f7329..d9f0f5b1531 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js @@ -10,6 +10,7 @@ function m1_f1() { } define("ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { 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 eececdeabfd..e84545ade77 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/ref/m2.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ 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":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ 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 index 2cf202bd871..cc3f604524f 100644 --- a/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js +++ b/tests/baselines/reference/project/maprootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js @@ -10,6 +10,7 @@ function m1_f1() { } define("ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { 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 4bdde308824..e115b1ebd64 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/ref/m2.ts","file:///tests/cases/projects/outputdir_mixed_subfolder/test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ 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":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/diskFile0.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/diskFile0.js.map index 3c1c9b64dc2..0b4d12cead1 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/diskFile0.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/diskFile0.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/diskFile1.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/diskFile1.js index 1e006b165b9..f6057bf162a 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/diskFile1.js +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/diskFile1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/ref/m1.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/ref/m1.js index 2141ed5cbb8..196a531920b 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/ref/m1.js +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/ref/m1.js.map index 9bdc7ad5504..fa0bcf94a5d 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/ref/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/test.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/test.js index 149e213901a..b4a0aa2d25d 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/test.js.map index 3a4d618044a..6a2bfc777e9 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/diskFile0.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/diskFile0.js.map index 4103e499cbd..29b98b193fb 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/diskFile0.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/diskFile0.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/diskFile1.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/diskFile1.js index 2e93a073415..9324632b44a 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/diskFile1.js +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/diskFile1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/ref/m1.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/ref/m1.js index 651782fa421..f5901795832 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/ref/m1.js +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/ref/m1.js.map index 49f97b88a38..f4de6b06e49 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/ref/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/test.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/test.js index 99135b7b275..e8734ca6d27 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/test.js +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); var m2 = require("../outputdir_module_multifolder_ref/m2"); exports.a1 = 10; diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/test.js.map index 830a0ddd3e5..842d34fe73d 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js index 2141ed5cbb8..196a531920b 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map index 9bdc7ad5504..fa0bcf94a5d 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js index 149e213901a..b4a0aa2d25d 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map index 3a4d618044a..6a2bfc777e9 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js index 1e006b165b9..f6057bf162a 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map index 3c1c9b64dc2..0b4d12cead1 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js index 651782fa421..f5901795832 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map index 49f97b88a38..f4de6b06e49 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js index 99135b7b275..e8734ca6d27 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); var m2 = require("../outputdir_module_multifolder_ref/m2"); exports.a1 = 10; diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map index 830a0ddd3e5..842d34fe73d 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js index 2e93a073415..9324632b44a 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map index 4103e499cbd..29b98b193fb 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ 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 index 99da107dfa8..1ea95ed9ba0 100644 --- a/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/maprootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("outputdir_module_multifolder/ref/m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("outputdir_module_multifolder/ref/m1", ["require", "exports"], function ( }); define("outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { @@ -30,6 +32,7 @@ define("outputdir_module_multifolder_ref/m2", ["require", "exports"], function ( }); define("outputdir_module_multifolder/test", ["require", "exports", "outputdir_module_multifolder/ref/m1", "outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 6b934e00e04..cd6a7fab377 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":["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":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICNU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICNU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/amd/m1.js b/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/amd/m1.js index b85ad9ab5b1..fc2d3408b2b 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/amd/m1.js +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/amd/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/amd/m1.js.map b/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/amd/m1.js.map index eceec7b450a..f0cb61b0632 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/amd/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/amd/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/amd/test.js b/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/amd/test.js index c3300bc7998..1e0dea14dc8 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/amd/test.js.map b/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/amd/test.js.map index d68dbf6eb9e..ed2f67c585b 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/node/m1.js b/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/node/m1.js index 9e79b0167c6..8a7e9f1069e 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/node/m1.js +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/node/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/node/m1.js.map b/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/node/m1.js.map index b9de639cb1d..da3b77ba146 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/node/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/node/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/node/test.js b/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/node/test.js index 29b6fee1d66..d7e6d673340 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/node/test.js +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/node/test.js.map b/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/node/test.js.map index 826729aba87..f4d0ecfe24b 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/test.ts"],"names":[],"mappings":";AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/test.ts"],"names":[],"mappings":";;AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js index b85ad9ab5b1..fc2d3408b2b 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map index eceec7b450a..f0cb61b0632 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js index c3300bc7998..1e0dea14dc8 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map index d68dbf6eb9e..ed2f67c585b 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js index 9e79b0167c6..8a7e9f1069e 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map index b9de639cb1d..da3b77ba146 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js index 29b6fee1d66..d7e6d673340 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map index 826729aba87..f4d0ecfe24b 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/test.ts"],"names":[],"mappings":";AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_simple/test.ts"],"names":[],"mappings":";;AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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 index 4b21632bd6c..d19b9195685 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/maprootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("m1", ["require", "exports"], function (require, exports) { }); define("test", ["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 5396cab1d7c..ba2950b1a5e 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":["file:///tests/cases/projects/outputdir_module_simple/m1.ts","file:///tests/cases/projects/outputdir_module_simple/test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/amd/ref/m1.js b/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/amd/ref/m1.js index c3d36f22356..5aa59f6dc92 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/amd/ref/m1.js +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/amd/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/amd/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/amd/ref/m1.js.map index 755cc1d0aaf..2f6470b65ff 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/amd/ref/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/amd/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/amd/test.js b/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/amd/test.js index 5ec4a043557..d56cdf72bf2 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/amd/test.js.map index 957a73c648a..a88a706d9b1 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/node/ref/m1.js b/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/node/ref/m1.js index 8fe6d174601..b4abab78e9a 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/node/ref/m1.js +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/node/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/node/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/node/ref/m1.js.map index f7e43883048..5b58a2ee571 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/node/ref/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/node/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/node/test.js b/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/node/test.js index 0b258a0b620..6bc25238dac 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/node/test.js +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/node/test.js.map index 8baefdad92b..d4034d62c4a 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js index c3d36f22356..5aa59f6dc92 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map index 755cc1d0aaf..2f6470b65ff 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js index 5ec4a043557..d56cdf72bf2 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 957a73c648a..a88a706d9b1 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js index 8fe6d174601..b4abab78e9a 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map index f7e43883048..5b58a2ee571 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js index 0b258a0b620..6bc25238dac 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index 8baefdad92b..d4034d62c4a 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_subfolder/test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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 index a58fc69531f..63e58be27dc 100644 --- a/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/maprootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("ref/m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("ref/m1", ["require", "exports"], function (require, exports) { }); define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 308dbbfaa67..12f2439e6f5 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":["file:///tests/cases/projects/outputdir_module_subfolder/ref/m1.ts","file:///tests/cases/projects/outputdir_module_subfolder/test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/amd/ref/m2.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/amd/ref/m2.js index 70911579465..f373c246d48 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/amd/ref/m2.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/amd/ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/amd/ref/m2.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/amd/ref/m2.js.map index a1c9985be48..85be78ed9b4 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/amd/ref/m2.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/amd/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/node/ref/m2.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/node/ref/m2.js index e4c76ba72e2..9557c3a613c 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/node/ref/m2.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/node/ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/node/ref/m2.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/node/ref/m2.js.map index 9ccd44f3a01..e7ecba5fc92 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/node/ref/m2.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderNoOutdir/node/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js index 70911579465..f373c246d48 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map index a1c9985be48..85be78ed9b4 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js index e4c76ba72e2..9557c3a613c 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map index 9ccd44f3a01..e7ecba5fc92 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ 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 index b1f7d5f7329..d9f0f5b1531 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js @@ -10,6 +10,7 @@ function m1_f1() { } define("ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { 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 26353fdf396..92315bfcacc 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","ref/m2.ts","test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ 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":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ 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 index 2cf202bd871..cc3f604524f 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js @@ -10,6 +10,7 @@ function m1_f1() { } define("ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { 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 ec57587014d..c98b66faded 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","ref/m2.ts","test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ 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":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/diskFile0.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/diskFile0.js.map index 59ebd34cfe3..e8fba0d4b55 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/diskFile0.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/diskFile0.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/diskFile1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/diskFile1.js index 1e006b165b9..f6057bf162a 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/diskFile1.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/diskFile1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/ref/m1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/ref/m1.js index 2141ed5cbb8..196a531920b 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/ref/m1.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/ref/m1.js.map index 9afdf343f77..8087b94c0c3 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/ref/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/test.js index 149e213901a..b4a0aa2d25d 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/test.js.map index 5000f3a49b9..a8f0695ded3 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/diskFile0.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/diskFile0.js.map index 866e1007e24..50a28887d0b 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/diskFile0.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/diskFile0.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/diskFile1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/diskFile1.js index 2e93a073415..9324632b44a 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/diskFile1.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/diskFile1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/ref/m1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/ref/m1.js index 651782fa421..f5901795832 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/ref/m1.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/ref/m1.js.map index 0f5e28ddbf7..56a4f46ae00 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/ref/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/test.js index 99135b7b275..e8734ca6d27 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/test.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); var m2 = require("../outputdir_module_multifolder_ref/m2"); exports.a1 = 10; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/test.js.map index a39cd29ba77..6ad9ecad595 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js index 2141ed5cbb8..196a531920b 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map index 9afdf343f77..8087b94c0c3 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js index 149e213901a..b4a0aa2d25d 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map index 5000f3a49b9..a8f0695ded3 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js index 1e006b165b9..f6057bf162a 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map index 59ebd34cfe3..e8fba0d4b55 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js index 651782fa421..f5901795832 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map index 0f5e28ddbf7..56a4f46ae00 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js index 99135b7b275..e8734ca6d27 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); var m2 = require("../outputdir_module_multifolder_ref/m2"); exports.a1 = 10; diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map index a39cd29ba77..6ad9ecad595 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js index 2e93a073415..9324632b44a 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map index 866e1007e24..50a28887d0b 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ 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 index 99da107dfa8..1ea95ed9ba0 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("outputdir_module_multifolder/ref/m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("outputdir_module_multifolder/ref/m1", ["require", "exports"], function ( }); define("outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { @@ -30,6 +32,7 @@ define("outputdir_module_multifolder_ref/m2", ["require", "exports"], function ( }); define("outputdir_module_multifolder/test", ["require", "exports", "outputdir_module_multifolder/ref/m1", "outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 c4facdba936..5d14898713d 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":["outputdir_module_multifolder/ref/m1.ts","outputdir_module_multifolder_ref/m2.ts","outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICNU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICNU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/amd/m1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/amd/m1.js index b85ad9ab5b1..fc2d3408b2b 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/amd/m1.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/amd/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/amd/m1.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/amd/m1.js.map index 1706ba76817..caee4b20553 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/amd/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/amd/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/amd/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/amd/test.js index c3300bc7998..1e0dea14dc8 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/amd/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/amd/test.js.map index 07e9825a93a..43c2c887c65 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/node/m1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/node/m1.js index 9e79b0167c6..8a7e9f1069e 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/node/m1.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/node/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/node/m1.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/node/m1.js.map index d134ab774af..fa989919301 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/node/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/node/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/node/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/node/test.js index 29b6fee1d66..d7e6d673340 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/node/test.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/node/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/node/test.js.map index d07c1aa0678..1ec67278ba3 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js index b85ad9ab5b1..fc2d3408b2b 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map index 1706ba76817..caee4b20553 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js index c3300bc7998..1e0dea14dc8 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 07e9825a93a..43c2c887c65 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js index 9e79b0167c6..8a7e9f1069e 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map index d134ab774af..fa989919301 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js index 29b6fee1d66..d7e6d673340 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map index d07c1aa0678..1ec67278ba3 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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 index 4b21632bd6c..d19b9195685 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("m1", ["require", "exports"], function (require, exports) { }); define("test", ["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 64c90d05e88..f5849debd83 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":["m1.ts","test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts","test.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/amd/ref/m1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/amd/ref/m1.js index c3d36f22356..5aa59f6dc92 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/amd/ref/m1.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/amd/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/amd/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/amd/ref/m1.js.map index 7e2762b41a4..15b12e3a189 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/amd/ref/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/amd/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/amd/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/amd/test.js index 5ec4a043557..d56cdf72bf2 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/amd/test.js.map index 07e9825a93a..43c2c887c65 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/node/ref/m1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/node/ref/m1.js index 8fe6d174601..b4abab78e9a 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/node/ref/m1.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/node/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/node/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/node/ref/m1.js.map index eb883275568..6e97669732b 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/node/ref/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/node/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/node/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/node/test.js index 0b258a0b620..6bc25238dac 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/node/test.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/node/test.js.map index 4f024886c03..badcd2b1b9c 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js index c3d36f22356..5aa59f6dc92 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map index 7e2762b41a4..15b12e3a189 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js index 5ec4a043557..d56cdf72bf2 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 07e9825a93a..43c2c887c65 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js index 8fe6d174601..b4abab78e9a 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map index eb883275568..6e97669732b 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js index 0b258a0b620..6bc25238dac 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index 4f024886c03..badcd2b1b9c 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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 index a58fc69531f..63e58be27dc 100644 --- a/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/maprootUrlsourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("ref/m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("ref/m1", ["require", "exports"], function (require, exports) { }); define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 6d26d850e19..6f4defc3e4c 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":["ref/m1.ts","test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesImportHigher/amd/importHigher/root.js b/tests/baselines/reference/project/nodeModulesImportHigher/amd/importHigher/root.js index 5b8a451c781..65e3b33be1a 100644 --- a/tests/baselines/reference/project/nodeModulesImportHigher/amd/importHigher/root.js +++ b/tests/baselines/reference/project/nodeModulesImportHigher/amd/importHigher/root.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; m1.f1("test"); m1.f2.a = 10; m1.f2.person.age = "10"; // Error: Should be number (if direct import of m2 made the m3 module visible). diff --git a/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js b/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js index 59944c663e9..4fc36cd0222 100644 --- a/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js +++ b/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); m1.f1("test"); m1.f2.a = 10; diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/maxDepthExceeded/built/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/maxDepthExceeded/built/root.js index 5a3916f07d1..493e1b9636e 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/maxDepthExceeded/built/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/maxDepthExceeded/built/root.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; m1.f1("test"); m1.f2.a = "10"; // Error: Should be number m1.rel = 42; // Error: Should be boolean diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt index 99e7b193f0c..5b5199ad7ae 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt @@ -2,19 +2,10 @@ maxDepthExceeded/root.ts(3,1): error TS2322: Type '"10"' is not assignable to ty maxDepthExceeded/root.ts(4,4): error TS2540: Cannot assign to 'rel' because it is a constant or a read-only property. -==== entry.js (0 errors) ==== - var m3 = require("m3"); - - module.exports = { - "a": 42, - "b": "hello, world", - "person": m3.person - }; - ==== relative.js (0 errors) ==== exports.relativeProp = true; -==== maxDepthExceeded/node_modules/m1/index.js (0 errors) ==== +==== index.js (0 errors) ==== var m2 = require('m2'); var rel = require('./relative'); @@ -40,4 +31,13 @@ maxDepthExceeded/root.ts(4,4): error TS2540: Cannot assign to 'rel' because it i !!! error TS2540: Cannot assign to 'rel' because it is a constant or a read-only property. m1.f2.person.age = "10"; // OK if stopped at 2 modules: person will be "any". + +==== entry.js (0 errors) ==== + var m3 = require("m3"); + + module.exports = { + "a": 42, + "b": "hello, world", + "person": m3.person + }; \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.json b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.json index 86e856dc7b8..9efa0e936ac 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.json +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.json @@ -7,10 +7,10 @@ "project": "maxDepthExceeded", "resolvedInputFiles": [ "lib.d.ts", - "maxDepthExceeded/node_modules/m2/entry.js", "maxDepthExceeded/node_modules/m1/relative.js", "maxDepthExceeded/node_modules/m1/index.js", - "maxDepthExceeded/root.ts" + "maxDepthExceeded/root.ts", + "maxDepthExceeded/node_modules/m2/entry.js" ], "emittedFiles": [ "maxDepthExceeded/built/node_modules/m1/relative.js", diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/built/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/built/root.js index fb4faf236b2..51370836837 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/built/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/built/root.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); m1.f1("test"); m1.f2.a = "10"; // Error: Should be number diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt index 99e7b193f0c..5b5199ad7ae 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt @@ -2,19 +2,10 @@ maxDepthExceeded/root.ts(3,1): error TS2322: Type '"10"' is not assignable to ty maxDepthExceeded/root.ts(4,4): error TS2540: Cannot assign to 'rel' because it is a constant or a read-only property. -==== entry.js (0 errors) ==== - var m3 = require("m3"); - - module.exports = { - "a": 42, - "b": "hello, world", - "person": m3.person - }; - ==== relative.js (0 errors) ==== exports.relativeProp = true; -==== maxDepthExceeded/node_modules/m1/index.js (0 errors) ==== +==== index.js (0 errors) ==== var m2 = require('m2'); var rel = require('./relative'); @@ -40,4 +31,13 @@ maxDepthExceeded/root.ts(4,4): error TS2540: Cannot assign to 'rel' because it i !!! error TS2540: Cannot assign to 'rel' because it is a constant or a read-only property. m1.f2.person.age = "10"; // OK if stopped at 2 modules: person will be "any". + +==== entry.js (0 errors) ==== + var m3 = require("m3"); + + module.exports = { + "a": 42, + "b": "hello, world", + "person": m3.person + }; \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.json b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.json index 86e856dc7b8..9efa0e936ac 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.json +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.json @@ -7,10 +7,10 @@ "project": "maxDepthExceeded", "resolvedInputFiles": [ "lib.d.ts", - "maxDepthExceeded/node_modules/m2/entry.js", "maxDepthExceeded/node_modules/m1/relative.js", "maxDepthExceeded/node_modules/m1/index.js", - "maxDepthExceeded/root.ts" + "maxDepthExceeded/root.ts", + "maxDepthExceeded/node_modules/m2/entry.js" ], "emittedFiles": [ "maxDepthExceeded/built/node_modules/m1/relative.js", diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js index 9ef3915c851..948a6d68b83 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1", "m4"], function (require, exports, m1, m4) { "use strict"; + exports.__esModule = true; m1.f1("test"); m1.f2.a = 10; m1.f2.person.age = "10"; // Should error if loaded the .js files correctly diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js index f6783cda79b..50feab5d27f 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); var m4 = require("m4"); m1.f1("test"); diff --git a/tests/baselines/reference/project/nonRelative/amd/consume.js b/tests/baselines/reference/project/nonRelative/amd/consume.js index 08e0b38c7df..a6bce0ab2c6 100644 --- a/tests/baselines/reference/project/nonRelative/amd/consume.js +++ b/tests/baselines/reference/project/nonRelative/amd/consume.js @@ -1,5 +1,6 @@ define(["require", "exports", "decl", "lib/foo/a", "lib/bar/a"], function (require, exports, mod, x, y) { "use strict"; + exports.__esModule = true; x.hello(); y.hello(); var str = mod.call(); diff --git a/tests/baselines/reference/project/nonRelative/amd/decl.js b/tests/baselines/reference/project/nonRelative/amd/decl.js index f2dbc101a52..d22c3ced24e 100644 --- a/tests/baselines/reference/project/nonRelative/amd/decl.js +++ b/tests/baselines/reference/project/nonRelative/amd/decl.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; function call() { return "success"; } diff --git a/tests/baselines/reference/project/nonRelative/amd/lib/bar/a.js b/tests/baselines/reference/project/nonRelative/amd/lib/bar/a.js index a8619f88260..b92af88609d 100644 --- a/tests/baselines/reference/project/nonRelative/amd/lib/bar/a.js +++ b/tests/baselines/reference/project/nonRelative/amd/lib/bar/a.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; function hello() { } exports.hello = hello; }); diff --git a/tests/baselines/reference/project/nonRelative/amd/lib/foo/a.js b/tests/baselines/reference/project/nonRelative/amd/lib/foo/a.js index a8619f88260..b92af88609d 100644 --- a/tests/baselines/reference/project/nonRelative/amd/lib/foo/a.js +++ b/tests/baselines/reference/project/nonRelative/amd/lib/foo/a.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; function hello() { } exports.hello = hello; }); diff --git a/tests/baselines/reference/project/nonRelative/amd/lib/foo/b.js b/tests/baselines/reference/project/nonRelative/amd/lib/foo/b.js index a8619f88260..b92af88609d 100644 --- a/tests/baselines/reference/project/nonRelative/amd/lib/foo/b.js +++ b/tests/baselines/reference/project/nonRelative/amd/lib/foo/b.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; function hello() { } exports.hello = hello; }); diff --git a/tests/baselines/reference/project/nonRelative/node/consume.js b/tests/baselines/reference/project/nonRelative/node/consume.js index 35d658abb62..51d811bb72a 100644 --- a/tests/baselines/reference/project/nonRelative/node/consume.js +++ b/tests/baselines/reference/project/nonRelative/node/consume.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var mod = require("decl"); var x = require("lib/foo/a"); var y = require("lib/bar/a"); diff --git a/tests/baselines/reference/project/nonRelative/node/decl.js b/tests/baselines/reference/project/nonRelative/node/decl.js index e2d4b03d1c1..7cde1400c60 100644 --- a/tests/baselines/reference/project/nonRelative/node/decl.js +++ b/tests/baselines/reference/project/nonRelative/node/decl.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; function call() { return "success"; } diff --git a/tests/baselines/reference/project/nonRelative/node/lib/bar/a.js b/tests/baselines/reference/project/nonRelative/node/lib/bar/a.js index 182e381bcde..c83848543b2 100644 --- a/tests/baselines/reference/project/nonRelative/node/lib/bar/a.js +++ b/tests/baselines/reference/project/nonRelative/node/lib/bar/a.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; function hello() { } exports.hello = hello; diff --git a/tests/baselines/reference/project/nonRelative/node/lib/foo/a.js b/tests/baselines/reference/project/nonRelative/node/lib/foo/a.js index 182e381bcde..c83848543b2 100644 --- a/tests/baselines/reference/project/nonRelative/node/lib/foo/a.js +++ b/tests/baselines/reference/project/nonRelative/node/lib/foo/a.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; function hello() { } exports.hello = hello; diff --git a/tests/baselines/reference/project/nonRelative/node/lib/foo/b.js b/tests/baselines/reference/project/nonRelative/node/lib/foo/b.js index 182e381bcde..c83848543b2 100644 --- a/tests/baselines/reference/project/nonRelative/node/lib/foo/b.js +++ b/tests/baselines/reference/project/nonRelative/node/lib/foo/b.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; function hello() { } exports.hello = hello; diff --git a/tests/baselines/reference/project/outMixedSubfolderNoOutdir/amd/ref/m2.js b/tests/baselines/reference/project/outMixedSubfolderNoOutdir/amd/ref/m2.js index 125abe99f0e..257b2bbaa8f 100644 --- a/tests/baselines/reference/project/outMixedSubfolderNoOutdir/amd/ref/m2.js +++ b/tests/baselines/reference/project/outMixedSubfolderNoOutdir/amd/ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/outMixedSubfolderNoOutdir/node/ref/m2.js b/tests/baselines/reference/project/outMixedSubfolderNoOutdir/node/ref/m2.js index 9fdf5b0ad0f..7a90183baf3 100644 --- a/tests/baselines/reference/project/outMixedSubfolderNoOutdir/node/ref/m2.js +++ b/tests/baselines/reference/project/outMixedSubfolderNoOutdir/node/ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js index 125abe99f0e..257b2bbaa8f 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js index 9fdf5b0ad0f..7a90183baf3 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.js index 7898180c050..ef652b9e929 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFile/amd/bin/test.js @@ -10,6 +10,7 @@ function m1_f1() { } define("ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js index 7898180c050..ef652b9e929 100644 --- a/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js +++ b/tests/baselines/reference/project/outMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js @@ -10,6 +10,7 @@ function m1_f1() { } define("ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/outModuleMultifolderNoOutdir/amd/diskFile0.js b/tests/baselines/reference/project/outModuleMultifolderNoOutdir/amd/diskFile0.js index 125abe99f0e..257b2bbaa8f 100644 --- a/tests/baselines/reference/project/outModuleMultifolderNoOutdir/amd/diskFile0.js +++ b/tests/baselines/reference/project/outModuleMultifolderNoOutdir/amd/diskFile0.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/outModuleMultifolderNoOutdir/amd/ref/m1.js b/tests/baselines/reference/project/outModuleMultifolderNoOutdir/amd/ref/m1.js index 34936dca125..b5ccdc63b22 100644 --- a/tests/baselines/reference/project/outModuleMultifolderNoOutdir/amd/ref/m1.js +++ b/tests/baselines/reference/project/outModuleMultifolderNoOutdir/amd/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/outModuleMultifolderNoOutdir/amd/test.js b/tests/baselines/reference/project/outModuleMultifolderNoOutdir/amd/test.js index ddda2e19133..fb9329a59b4 100644 --- a/tests/baselines/reference/project/outModuleMultifolderNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/outModuleMultifolderNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/outModuleMultifolderNoOutdir/node/diskFile0.js b/tests/baselines/reference/project/outModuleMultifolderNoOutdir/node/diskFile0.js index 9fdf5b0ad0f..7a90183baf3 100644 --- a/tests/baselines/reference/project/outModuleMultifolderNoOutdir/node/diskFile0.js +++ b/tests/baselines/reference/project/outModuleMultifolderNoOutdir/node/diskFile0.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/outModuleMultifolderNoOutdir/node/ref/m1.js b/tests/baselines/reference/project/outModuleMultifolderNoOutdir/node/ref/m1.js index 5854acba9e2..52ebad55703 100644 --- a/tests/baselines/reference/project/outModuleMultifolderNoOutdir/node/ref/m1.js +++ b/tests/baselines/reference/project/outModuleMultifolderNoOutdir/node/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/outModuleMultifolderNoOutdir/node/test.js b/tests/baselines/reference/project/outModuleMultifolderNoOutdir/node/test.js index 77e6fbe68c1..18fccdca8bb 100644 --- a/tests/baselines/reference/project/outModuleMultifolderNoOutdir/node/test.js +++ b/tests/baselines/reference/project/outModuleMultifolderNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); var m2 = require("../outputdir_module_multifolder_ref/m2"); exports.a1 = 10; diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js index 34936dca125..b5ccdc63b22 100644 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js +++ b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js index ddda2e19133..fb9329a59b4 100644 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js +++ b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js index 125abe99f0e..257b2bbaa8f 100644 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js +++ b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js index 5854acba9e2..52ebad55703 100644 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js +++ b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js index 77e6fbe68c1..18fccdca8bb 100644 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js +++ b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); var m2 = require("../outputdir_module_multifolder_ref/m2"); exports.a1 = 10; diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js index 9fdf5b0ad0f..7a90183baf3 100644 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js +++ b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/bin/test.js index ea6ae0a3cd7..adb1b5061b5 100644 --- a/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/outModuleMultifolderSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("outputdir_module_multifolder/ref/m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("outputdir_module_multifolder/ref/m1", ["require", "exports"], function ( }); define("outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { @@ -30,6 +32,7 @@ define("outputdir_module_multifolder_ref/m2", ["require", "exports"], function ( }); define("outputdir_module_multifolder/test", ["require", "exports", "outputdir_module_multifolder/ref/m1", "outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/outModuleSimpleNoOutdir/amd/m1.js b/tests/baselines/reference/project/outModuleSimpleNoOutdir/amd/m1.js index 34936dca125..b5ccdc63b22 100644 --- a/tests/baselines/reference/project/outModuleSimpleNoOutdir/amd/m1.js +++ b/tests/baselines/reference/project/outModuleSimpleNoOutdir/amd/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/outModuleSimpleNoOutdir/amd/test.js b/tests/baselines/reference/project/outModuleSimpleNoOutdir/amd/test.js index cd107bb32f2..c062c0ac6d4 100644 --- a/tests/baselines/reference/project/outModuleSimpleNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/outModuleSimpleNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/outModuleSimpleNoOutdir/node/m1.js b/tests/baselines/reference/project/outModuleSimpleNoOutdir/node/m1.js index 5854acba9e2..52ebad55703 100644 --- a/tests/baselines/reference/project/outModuleSimpleNoOutdir/node/m1.js +++ b/tests/baselines/reference/project/outModuleSimpleNoOutdir/node/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/outModuleSimpleNoOutdir/node/test.js b/tests/baselines/reference/project/outModuleSimpleNoOutdir/node/test.js index 912480b74ce..2e50e0b7989 100644 --- a/tests/baselines/reference/project/outModuleSimpleNoOutdir/node/test.js +++ b/tests/baselines/reference/project/outModuleSimpleNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js index 34936dca125..b5ccdc63b22 100644 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js +++ b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js index cd107bb32f2..c062c0ac6d4 100644 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js +++ b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js index 5854acba9e2..52ebad55703 100644 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js +++ b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js index 912480b74ce..2e50e0b7989 100644 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js +++ b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/bin/test.js index 04f9d32831e..0a1f6b523c9 100644 --- a/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/outModuleSimpleSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("m1", ["require", "exports"], function (require, exports) { }); define("test", ["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/outModuleSubfolderNoOutdir/amd/ref/m1.js b/tests/baselines/reference/project/outModuleSubfolderNoOutdir/amd/ref/m1.js index 34936dca125..b5ccdc63b22 100644 --- a/tests/baselines/reference/project/outModuleSubfolderNoOutdir/amd/ref/m1.js +++ b/tests/baselines/reference/project/outModuleSubfolderNoOutdir/amd/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/outModuleSubfolderNoOutdir/amd/test.js b/tests/baselines/reference/project/outModuleSubfolderNoOutdir/amd/test.js index 67c8fedf898..0fdf8d91b32 100644 --- a/tests/baselines/reference/project/outModuleSubfolderNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/outModuleSubfolderNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/outModuleSubfolderNoOutdir/node/ref/m1.js b/tests/baselines/reference/project/outModuleSubfolderNoOutdir/node/ref/m1.js index 5854acba9e2..52ebad55703 100644 --- a/tests/baselines/reference/project/outModuleSubfolderNoOutdir/node/ref/m1.js +++ b/tests/baselines/reference/project/outModuleSubfolderNoOutdir/node/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/outModuleSubfolderNoOutdir/node/test.js b/tests/baselines/reference/project/outModuleSubfolderNoOutdir/node/test.js index 0dea10818b9..33f201ce9d5 100644 --- a/tests/baselines/reference/project/outModuleSubfolderNoOutdir/node/test.js +++ b/tests/baselines/reference/project/outModuleSubfolderNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js index 34936dca125..b5ccdc63b22 100644 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js +++ b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js index 67c8fedf898..0fdf8d91b32 100644 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js +++ b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js index 5854acba9e2..52ebad55703 100644 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js +++ b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js index 0dea10818b9..33f201ce9d5 100644 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js +++ b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/bin/test.js b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/bin/test.js index 05ee275fc15..2ddfb9277a3 100644 --- a/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/outModuleSubfolderSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("ref/m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("ref/m1", ["require", "exports"], function (require, exports) { }); define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js index 99a4842f636..1c181a2feae 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js @@ -1,8 +1,13 @@ -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var m2; (function (m2) { m2.c1 = new m2.mExported.me.class1; @@ -14,7 +19,7 @@ var m2; var class1 = (function (_super) { __extends(class1, _super); function class1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class1; }(m2.mExported.me.class1)); @@ -27,7 +32,7 @@ var m2; var class2 = (function (_super) { __extends(class2, _super); function class2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class2; }(m2.mExported.me.class1)); @@ -40,7 +45,7 @@ var m2; var class3 = (function (_super) { __extends(class3, _super); function class3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class3; }(mNonExported.mne.class1)); @@ -53,7 +58,7 @@ var m2; var class4 = (function (_super) { __extends(class4, _super); function class4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class4; }(mNonExported.mne.class1)); diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js index 99a4842f636..1c181a2feae 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js @@ -1,8 +1,13 @@ -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var m2; (function (m2) { m2.c1 = new m2.mExported.me.class1; @@ -14,7 +19,7 @@ var m2; var class1 = (function (_super) { __extends(class1, _super); function class1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class1; }(m2.mExported.me.class1)); @@ -27,7 +32,7 @@ var m2; var class2 = (function (_super) { __extends(class2, _super); function class2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class2; }(m2.mExported.me.class1)); @@ -40,7 +45,7 @@ var m2; var class3 = (function (_super) { __extends(class3, _super); function class3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class3; }(mNonExported.mne.class1)); @@ -53,7 +58,7 @@ var m2; var class4 = (function (_super) { __extends(class4, _super); function class4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return class4; }(mNonExported.mne.class1)); diff --git a/tests/baselines/reference/project/prologueEmit/amd/out.js b/tests/baselines/reference/project/prologueEmit/amd/out.js index 7ee160b82ef..45dfb93c458 100644 --- a/tests/baselines/reference/project/prologueEmit/amd/out.js +++ b/tests/baselines/reference/project/prologueEmit/amd/out.js @@ -1,8 +1,13 @@ -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + 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; }); @@ -18,7 +23,7 @@ var m; var child = (function (_super) { __extends(child, _super); function child() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return child; }(base)); diff --git a/tests/baselines/reference/project/prologueEmit/node/out.js b/tests/baselines/reference/project/prologueEmit/node/out.js index 7ee160b82ef..45dfb93c458 100644 --- a/tests/baselines/reference/project/prologueEmit/node/out.js +++ b/tests/baselines/reference/project/prologueEmit/node/out.js @@ -1,8 +1,13 @@ -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + 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; }); @@ -18,7 +23,7 @@ var m; var child = (function (_super) { __extends(child, _super); function child() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return child; }(base)); diff --git a/tests/baselines/reference/project/quotesInFileAndDirectoryNames/amd/m'ain.js b/tests/baselines/reference/project/quotesInFileAndDirectoryNames/amd/m'ain.js index b793b07534c..ce5681ae1c9 100644 --- a/tests/baselines/reference/project/quotesInFileAndDirectoryNames/amd/m'ain.js +++ b/tests/baselines/reference/project/quotesInFileAndDirectoryNames/amd/m'ain.js @@ -1,13 +1,18 @@ /// -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ClassC = (function (_super) { __extends(ClassC, _super); function ClassC() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ClassC; }(test.ClassA)); diff --git a/tests/baselines/reference/project/quotesInFileAndDirectoryNames/node/m'ain.js b/tests/baselines/reference/project/quotesInFileAndDirectoryNames/node/m'ain.js index b793b07534c..ce5681ae1c9 100644 --- a/tests/baselines/reference/project/quotesInFileAndDirectoryNames/node/m'ain.js +++ b/tests/baselines/reference/project/quotesInFileAndDirectoryNames/node/m'ain.js @@ -1,13 +1,18 @@ /// -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ClassC = (function (_super) { __extends(ClassC, _super); function ClassC() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ClassC; }(test.ClassA)); diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/amd/ref/m2.js b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/amd/ref/m2.js index 41f4a4e2521..08855ec797b 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/amd/ref/m2.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/amd/ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/amd/ref/m2.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/amd/ref/m2.js.map index e9a80c428b2..67693560dfc 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/amd/ref/m2.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/amd/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/node/ref/m2.js b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/node/ref/m2.js index eae1115846a..8ad833cd4eb 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/node/ref/m2.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/node/ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/node/ref/m2.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/node/ref/m2.js.map index 9f1206b5b14..d188f8a16bd 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/node/ref/m2.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderNoOutdir/node/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js index 41f4a4e2521..08855ec797b 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map index e9a80c428b2..67693560dfc 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js index eae1115846a..8ad833cd4eb 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map index 9f1206b5b14..d188f8a16bd 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_mixed_subfolder/src/","sources":["ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ 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 index 25cfe0fccb5..f070fff6f1c 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js @@ -10,6 +10,7 @@ function m1_f1() { } define("ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { 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 650c9d1e5d5..3520f3c0a5f 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","ref/m2.ts","test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ 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":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ 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 index de21b030c35..3e02cc09fcb 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js @@ -10,6 +10,7 @@ function m1_f1() { } define("ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { 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 6113c44d85d..ed2de159383 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","ref/m2.ts","test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ 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":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/diskFile0.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/diskFile0.js.map index ab7082a2e8e..bed0bf9b3e2 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/diskFile0.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/diskFile0.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/diskFile1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/diskFile1.js index 41f4a4e2521..08855ec797b 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/diskFile1.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/diskFile1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/ref/m1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/ref/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/ref/m1.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/ref/m1.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/ref/m1.js.map index 6bebdd113b6..616307fc2aa 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/ref/m1.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/test.js index efa0bc948ed..90f7f12fcb1 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/test.js.map index 21c996978fd..ac1540d3d7c 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/diskFile0.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/diskFile0.js.map index 06c30f32eaf..4281eb94fe5 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/diskFile0.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/diskFile0.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/diskFile1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/diskFile1.js index eae1115846a..8ad833cd4eb 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/diskFile1.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/diskFile1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/ref/m1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/ref/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/ref/m1.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/ref/m1.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/ref/m1.js.map index b757263c866..20f34963221 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/ref/m1.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/test.js index 84731dff566..43d151f3fd9 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/test.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); var m2 = require("../outputdir_module_multifolder_ref/m2"); exports.a1 = 10; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/test.js.map index b123ccf13c8..e794023608c 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map index 6bebdd113b6..616307fc2aa 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js index efa0bc948ed..90f7f12fcb1 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map index 21c996978fd..ac1540d3d7c 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js index 41f4a4e2521..08855ec797b 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map index ab7082a2e8e..bed0bf9b3e2 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map index b757263c866..20f34963221 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js index 84731dff566..43d151f3fd9 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); var m2 = require("../outputdir_module_multifolder_ref/m2"); exports.a1 = 10; diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map index b123ccf13c8..e794023608c 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js index eae1115846a..8ad833cd4eb 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map index 06c30f32eaf..4281eb94fe5 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ 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 index 37064fb583b..b77e0a462a7 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("outputdir_module_multifolder/ref/m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("outputdir_module_multifolder/ref/m1", ["require", "exports"], function ( }); define("outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { @@ -30,6 +32,7 @@ define("outputdir_module_multifolder_ref/m2", ["require", "exports"], function ( }); define("outputdir_module_multifolder/test", ["require", "exports", "outputdir_module_multifolder/ref/m1", "outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 baeea1e93dc..5970dfad43e 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":["outputdir_module_multifolder/ref/m1.ts","outputdir_module_multifolder_ref/m2.ts","outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICNU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICNU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/amd/m1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/amd/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/amd/m1.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/amd/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/amd/m1.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/amd/m1.js.map index ffc39be8044..101e0b07546 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/amd/m1.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/amd/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/amd/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/amd/test.js index c4b7f56d76a..e5ed53fd0e1 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/amd/test.js.map index 6366b8c2d85..5194b89b4a5 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/node/m1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/node/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/node/m1.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/node/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/node/m1.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/node/m1.js.map index 04bd4e10a3b..6316b37945c 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/node/m1.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/node/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/node/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/node/test.js index fea4b619aa2..56c8debf9b6 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/node/test.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/node/test.js.map index 9dc457a0167..ec26fbe336a 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["test.ts"],"names":[],"mappings":";AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["test.ts"],"names":[],"mappings":";;AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map index ffc39be8044..101e0b07546 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js index c4b7f56d76a..e5ed53fd0e1 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 6366b8c2d85..5194b89b4a5 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map index 04bd4e10a3b..6316b37945c 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js index fea4b619aa2..56c8debf9b6 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map index 9dc457a0167..ec26fbe336a 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["test.ts"],"names":[],"mappings":";AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_simple/src/","sources":["test.ts"],"names":[],"mappings":";;AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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 index d650b20ae5f..cbe79e3318b 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSimpleSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("m1", ["require", "exports"], function (require, exports) { }); define("test", ["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 aa0c2ca28b2..64a56e71714 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":["m1.ts","test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/amd/ref/m1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/amd/ref/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/amd/ref/m1.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/amd/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/amd/ref/m1.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/amd/ref/m1.js.map index cd798e72d89..a8d5da3a201 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/amd/ref/m1.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/amd/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/amd/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/amd/test.js index 0ad51aeb02e..c95451ac730 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/amd/test.js.map index 6738a871942..1628374eef4 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/node/ref/m1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/node/ref/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/node/ref/m1.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/node/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/node/ref/m1.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/node/ref/m1.js.map index 81d64320d78..f43884731e0 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/node/ref/m1.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/node/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/node/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/node/test.js index ebd5fdb3b3f..97ca26f3198 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/node/test.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/node/test.js.map index b2ea9133dfc..649377c06fc 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map index cd798e72d89..a8d5da3a201 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js index 0ad51aeb02e..c95451ac730 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 6738a871942..1628374eef4 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map index 81d64320d78..f43884731e0 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js index ebd5fdb3b3f..97ca26f3198 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index b2ea9133dfc..649377c06fc 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"/tests/cases/projects/outputdir_module_subfolder/src/","sources":["test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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 index f55492f4b49..22a9cf7b4d7 100644 --- a/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/sourceRootAbsolutePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("ref/m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("ref/m1", ["require", "exports"], function (require, exports) { }); define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 27b41a837a9..bbf9b58c64f 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":["ref/m1.ts","test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/amd/ref/m2.js b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/amd/ref/m2.js index 41f4a4e2521..08855ec797b 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/amd/ref/m2.js +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/amd/ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/amd/ref/m2.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/amd/ref/m2.js.map index 560075530f1..d65693aee66 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/amd/ref/m2.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/amd/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/node/ref/m2.js b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/node/ref/m2.js index eae1115846a..8ad833cd4eb 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/node/ref/m2.js +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/node/ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/node/ref/m2.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/node/ref/m2.js.map index 27abb47a45b..5d1100e38fa 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/node/ref/m2.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderNoOutdir/node/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js index 41f4a4e2521..08855ec797b 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map index 560075530f1..d65693aee66 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js index eae1115846a..8ad833cd4eb 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map index 27abb47a45b..5d1100e38fa 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ 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 index 25cfe0fccb5..f070fff6f1c 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFile/amd/bin/test.js @@ -10,6 +10,7 @@ function m1_f1() { } define("ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { 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 9a9586bd20d..544b444f69a 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","ref/m2.ts","test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["ref/m1.ts","ref/m2.ts","test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ 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 index de21b030c35..3e02cc09fcb 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js +++ b/tests/baselines/reference/project/sourceRootRelativePathMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js @@ -10,6 +10,7 @@ function m1_f1() { } define("ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { 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 16e3437b61c..39cc19f0b09 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","ref/m2.ts","test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"../src/","sources":["ref/m1.ts","ref/m2.ts","test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/diskFile0.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/diskFile0.js.map index 6b4ece94c15..7571615de41 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/diskFile0.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/diskFile0.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/diskFile1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/diskFile1.js index 41f4a4e2521..08855ec797b 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/diskFile1.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/diskFile1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/ref/m1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/ref/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/ref/m1.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/ref/m1.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/ref/m1.js.map index 8271bf25be1..ad01eacc00c 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/ref/m1.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/test.js index efa0bc948ed..90f7f12fcb1 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/test.js.map index 8be239f3553..343b30f743a 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/diskFile0.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/diskFile0.js.map index c7ae549832a..a7121ab0fb4 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/diskFile0.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/diskFile0.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/diskFile1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/diskFile1.js index eae1115846a..8ad833cd4eb 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/diskFile1.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/diskFile1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/ref/m1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/ref/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/ref/m1.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/ref/m1.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/ref/m1.js.map index 37adc61e54f..ddd49759374 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/ref/m1.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/test.js index 84731dff566..43d151f3fd9 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/test.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); var m2 = require("../outputdir_module_multifolder_ref/m2"); exports.a1 = 10; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/test.js.map index 79b428ca3a1..34026638960 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map index 8271bf25be1..ad01eacc00c 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js index efa0bc948ed..90f7f12fcb1 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map index 8be239f3553..343b30f743a 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js index 41f4a4e2521..08855ec797b 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map index 6b4ece94c15..7571615de41 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map index 37adc61e54f..ddd49759374 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js index 84731dff566..43d151f3fd9 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); var m2 = require("../outputdir_module_multifolder_ref/m2"); exports.a1 = 10; diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map index 79b428ca3a1..34026638960 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js index eae1115846a..8ad833cd4eb 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map index c7ae549832a..a7121ab0fb4 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ 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 index 37064fb583b..b77e0a462a7 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleMultifolderSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("outputdir_module_multifolder/ref/m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("outputdir_module_multifolder/ref/m1", ["require", "exports"], function ( }); define("outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { @@ -30,6 +32,7 @@ define("outputdir_module_multifolder_ref/m2", ["require", "exports"], function ( }); define("outputdir_module_multifolder/test", ["require", "exports", "outputdir_module_multifolder/ref/m1", "outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 4d37f7bfbf5..12697408ddd 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":["outputdir_module_multifolder/ref/m1.ts","outputdir_module_multifolder_ref/m2.ts","outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICNU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICNU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/amd/m1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/amd/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/amd/m1.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/amd/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/amd/m1.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/amd/m1.js.map index 29c8533aded..f9a2fd1d740 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/amd/m1.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/amd/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/amd/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/amd/test.js index c4b7f56d76a..e5ed53fd0e1 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/amd/test.js.map index d713f6b7f5e..17545cd729c 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/node/m1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/node/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/node/m1.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/node/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/node/m1.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/node/m1.js.map index 8086d9c04da..70db4f7545c 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/node/m1.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/node/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/node/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/node/test.js index fea4b619aa2..56c8debf9b6 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/node/test.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/node/test.js.map index 0d24a0e332a..0e6c49a9aec 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":[],"mappings":";AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":[],"mappings":";;AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map index 29c8533aded..f9a2fd1d740 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js index c4b7f56d76a..e5ed53fd0e1 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map index d713f6b7f5e..17545cd729c 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map index 8086d9c04da..70db4f7545c 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js index fea4b619aa2..56c8debf9b6 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map index 0d24a0e332a..0e6c49a9aec 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":[],"mappings":";AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":[],"mappings":";;AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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 index d650b20ae5f..cbe79e3318b 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSimpleSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("m1", ["require", "exports"], function (require, exports) { }); define("test", ["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 7e83d4cd269..1132db08bd0 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":["m1.ts","test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["m1.ts","test.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/amd/ref/m1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/amd/ref/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/amd/ref/m1.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/amd/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/amd/ref/m1.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/amd/ref/m1.js.map index 91793ab1002..07643a2c9dc 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/amd/ref/m1.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/amd/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/amd/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/amd/test.js index 0ad51aeb02e..c95451ac730 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/amd/test.js.map index d713f6b7f5e..17545cd729c 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/node/ref/m1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/node/ref/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/node/ref/m1.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/node/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/node/ref/m1.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/node/ref/m1.js.map index 00e388b171e..a9e9284e21d 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/node/ref/m1.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/node/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/node/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/node/test.js index ebd5fdb3b3f..97ca26f3198 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/node/test.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/node/test.js.map index 07178ab519f..9b21b166c37 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map index 91793ab1002..07643a2c9dc 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js index 0ad51aeb02e..c95451ac730 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index d713f6b7f5e..17545cd729c 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map index 00e388b171e..a9e9284e21d 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"../src/","sources":["ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js index ebd5fdb3b3f..97ca26f3198 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index 07178ab519f..9b21b166c37 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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 index f55492f4b49..22a9cf7b4d7 100644 --- a/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/sourceRootRelativePathModuleSubfolderSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("ref/m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("ref/m1", ["require", "exports"], function (require, exports) { }); define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 223d2cfdad3..5121f5c6a1e 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":["ref/m1.ts","test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"../src/","sources":["ref/m1.ts","test.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/amd/ref/m2.js b/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/amd/ref/m2.js index 41f4a4e2521..08855ec797b 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/amd/ref/m2.js +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/amd/ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/amd/ref/m2.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/amd/ref/m2.js.map index c4bc3c32708..a7a1fecb87f 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/amd/ref/m2.js.map +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/amd/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/node/ref/m2.js b/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/node/ref/m2.js index eae1115846a..8ad833cd4eb 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/node/ref/m2.js +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/node/ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/node/ref/m2.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/node/ref/m2.js.map index 208dd329040..ba1b40abf87 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/node/ref/m2.js.map +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderNoOutdir/node/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js index 41f4a4e2521..08855ec797b 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map index c0b56df8d90..35edbb3cd9c 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js index eae1115846a..8ad833cd4eb 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map index 5e34d4494dd..3c66628ccf7 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ 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 index 25cfe0fccb5..f070fff6f1c 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFile/amd/bin/test.js @@ -10,6 +10,7 @@ function m1_f1() { } define("ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { 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 dce282ee37f..df6d2c811c0 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","../ref/m2.ts","../test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../ref/m2.ts","../test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ 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 index de21b030c35..3e02cc09fcb 100644 --- a/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js +++ b/tests/baselines/reference/project/sourcemapMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js @@ -10,6 +10,7 @@ function m1_f1() { } define("ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { 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 1316ec74659..0c75dbb2b00 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","../ref/m2.ts","../test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ No newline at end of file +{"version":3,"file":"outAndOutDirFile.js","sourceRoot":"","sources":["../ref/m1.ts","../ref/m2.ts","../test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/diskFile0.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/diskFile0.js.map index c4bc3c32708..a7a1fecb87f 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/diskFile0.js.map +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/diskFile0.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/diskFile1.js b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/diskFile1.js index 41f4a4e2521..08855ec797b 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/diskFile1.js +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/diskFile1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/ref/m1.js b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/ref/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/ref/m1.js +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/ref/m1.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/ref/m1.js.map index dcdf5faf897..fb3dc7e5f1a 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/ref/m1.js.map +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/test.js b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/test.js index efa0bc948ed..90f7f12fcb1 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/test.js.map index 096386e968d..99618a3d6a7 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":";;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":";;;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/diskFile0.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/diskFile0.js.map index 208dd329040..ba1b40abf87 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/diskFile0.js.map +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/diskFile0.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/diskFile1.js b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/diskFile1.js index eae1115846a..8ad833cd4eb 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/diskFile1.js +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/diskFile1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/ref/m1.js b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/ref/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/ref/m1.js +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/ref/m1.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/ref/m1.js.map index 87fa414a454..5660dd85010 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/ref/m1.js.map +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/test.js b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/test.js index 84731dff566..43d151f3fd9 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/test.js +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); var m2 = require("../outputdir_module_multifolder_ref/m2"); exports.a1 = 10; diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/test.js.map index a9dba1be1dd..308a0083438 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map index 2293c1a7c96..8ba69854427 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../../ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../../ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js index efa0bc948ed..90f7f12fcb1 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map index d21a585cc41..1179d812037 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../../test.ts"],"names":[],"mappings":";;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../../test.ts"],"names":[],"mappings":";;;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js index 41f4a4e2521..08855ec797b 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map index 5d8cf325d52..14fbdd65f4f 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../../outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../../outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map index 49bb95f32d5..a42c40521a1 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../../ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../../ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js index 84731dff566..43d151f3fd9 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); var m2 = require("../outputdir_module_multifolder_ref/m2"); exports.a1 = 10; diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map index a48d929a860..86d72e20c93 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../../test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../../test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js index eae1115846a..8ad833cd4eb 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map index b9e5ddb335f..18103b0a8b1 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../../outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../../outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ 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 index 37064fb583b..b77e0a462a7 100644 --- a/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/sourcemapModuleMultifolderSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("outputdir_module_multifolder/ref/m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("outputdir_module_multifolder/ref/m1", ["require", "exports"], function ( }); define("outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { @@ -30,6 +32,7 @@ define("outputdir_module_multifolder_ref/m2", ["require", "exports"], function ( }); define("outputdir_module_multifolder/test", ["require", "exports", "outputdir_module_multifolder/ref/m1", "outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 d9151baabe4..783691c52ed 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":["../ref/m1.ts","../../outputdir_module_multifolder_ref/m2.ts","../test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICNU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICNU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/amd/m1.js b/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/amd/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/amd/m1.js +++ b/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/amd/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/amd/m1.js.map b/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/amd/m1.js.map index dcdf5faf897..fb3dc7e5f1a 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/amd/m1.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/amd/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/amd/test.js b/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/amd/test.js index c4b7f56d76a..e5ed53fd0e1 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/amd/test.js.map index 9a899efce64..80722609800 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/node/m1.js b/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/node/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/node/m1.js +++ b/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/node/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/node/m1.js.map b/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/node/m1.js.map index 87fa414a454..5660dd85010 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/node/m1.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/node/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/node/test.js b/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/node/test.js index fea4b619aa2..56c8debf9b6 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/node/test.js +++ b/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/node/test.js.map index 57b2f0a9935..90f1d966b1c 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSimpleNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":";AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":";;AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map index 128c9957bf4..2eb15ca540b 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js index c4b7f56d76a..e5ed53fd0e1 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 50263c64897..742f4f4a9af 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map index 40d0111893e..c819ff2c52c 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js index fea4b619aa2..56c8debf9b6 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map index cc2b2e9b918..b94230beb69 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":[],"mappings":";AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":[],"mappings":";;AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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 index d650b20ae5f..cbe79e3318b 100644 --- a/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/sourcemapModuleSimpleSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("m1", ["require", "exports"], function (require, exports) { }); define("test", ["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 a910ecda80e..293a1478989 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":["../m1.ts","../test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../m1.ts","../test.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/amd/ref/m1.js b/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/amd/ref/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/amd/ref/m1.js +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/amd/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/amd/ref/m1.js.map b/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/amd/ref/m1.js.map index dcdf5faf897..fb3dc7e5f1a 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/amd/ref/m1.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/amd/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/amd/test.js b/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/amd/test.js index 0ad51aeb02e..c95451ac730 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/amd/test.js.map index 9a899efce64..80722609800 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/node/ref/m1.js b/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/node/ref/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/node/ref/m1.js +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/node/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/node/ref/m1.js.map b/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/node/ref/m1.js.map index 87fa414a454..5660dd85010 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/node/ref/m1.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/node/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/node/test.js b/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/node/test.js index ebd5fdb3b3f..97ca26f3198 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/node/test.js +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/node/test.js.map index 6f71fb82f4c..6f61cbbee19 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map index 28136d8ffc3..8f88c077a44 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js index 0ad51aeb02e..c95451ac730 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 50263c64897..742f4f4a9af 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map index f5f5dfcd793..6c7d26906a4 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"","sources":["../../../ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js index ebd5fdb3b3f..97ca26f3198 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index 9c9d3ffec92..ab37fc26b40 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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 index f55492f4b49..22a9cf7b4d7 100644 --- a/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/sourcemapModuleSubfolderSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("ref/m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("ref/m1", ["require", "exports"], function (require, exports) { }); define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 a3532b9e4ce..61dfeeeb8d3 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":["../ref/m1.ts","../test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../ref/m1.ts","../test.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/amd/ref/m2.js b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/amd/ref/m2.js index 41f4a4e2521..08855ec797b 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/amd/ref/m2.js +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/amd/ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/amd/ref/m2.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/amd/ref/m2.js.map index a1c9985be48..85be78ed9b4 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/amd/ref/m2.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/amd/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/node/ref/m2.js b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/node/ref/m2.js index eae1115846a..8ad833cd4eb 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/node/ref/m2.js +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/node/ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/node/ref/m2.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/node/ref/m2.js.map index 9ccd44f3a01..e7ecba5fc92 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/node/ref/m2.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderNoOutdir/node/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js index 41f4a4e2521..08855ec797b 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map index a1c9985be48..85be78ed9b4 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js index eae1115846a..8ad833cd4eb 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map index 9ccd44f3a01..e7ecba5fc92 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ 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 index 25cfe0fccb5..f070fff6f1c 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFile/amd/bin/test.js @@ -10,6 +10,7 @@ function m1_f1() { } define("ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { 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 26353fdf396..92315bfcacc 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","ref/m2.ts","test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ 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":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ 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 index de21b030c35..3e02cc09fcb 100644 --- a/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js +++ b/tests/baselines/reference/project/sourcerootUrlMixedSubfolderSpecifyOutputFileAndOutputDirectory/amd/bin/outAndOutDirFile.js @@ -10,6 +10,7 @@ function m1_f1() { } define("ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { 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 ec57587014d..c98b66faded 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","ref/m2.ts","test.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ 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":[],"mappings":"AAAA,IAAI,KAAK,GAAG,EAAE,CAAC;AACf;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/B;IACI,MAAM,CAAC,YAAY,CAAC;AACxB,CAAC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;ACRD,iCAAiC;AACjC,iCAAiC;AACjC,IAAI,EAAE,GAAG,EAAE,CAAC;AACZ;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAED,IAAI,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AACzB;IACI,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/diskFile0.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/diskFile0.js.map index 59ebd34cfe3..e8fba0d4b55 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/diskFile0.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/diskFile0.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/diskFile1.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/diskFile1.js index 41f4a4e2521..08855ec797b 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/diskFile1.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/diskFile1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/ref/m1.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/ref/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/ref/m1.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/ref/m1.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/ref/m1.js.map index 9afdf343f77..8087b94c0c3 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/ref/m1.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/test.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/test.js index efa0bc948ed..90f7f12fcb1 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/test.js.map index 5000f3a49b9..a8f0695ded3 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/diskFile0.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/diskFile0.js.map index 866e1007e24..50a28887d0b 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/diskFile0.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/diskFile0.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/diskFile1.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/diskFile1.js index eae1115846a..8ad833cd4eb 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/diskFile1.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/diskFile1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/ref/m1.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/ref/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/ref/m1.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/ref/m1.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/ref/m1.js.map index 0f5e28ddbf7..56a4f46ae00 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/ref/m1.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/test.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/test.js index 84731dff566..43d151f3fd9 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/test.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); var m2 = require("../outputdir_module_multifolder_ref/m2"); exports.a1 = 10; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/test.js.map index a39cd29ba77..6ad9ecad595 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map index 9afdf343f77..8087b94c0c3 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js index efa0bc948ed..90f7f12fcb1 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1", "../outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map index 5000f3a49b9..a8f0695ded3 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;;IAEW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js index 41f4a4e2521..08855ec797b 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map index 59ebd34cfe3..e8fba0d4b55 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/amd/outdir/simple/outputdir_module_multifolder_ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map index 0f5e28ddbf7..56a4f46ae00 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js index 84731dff566..43d151f3fd9 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); var m2 = require("../outputdir_module_multifolder_ref/m2"); exports.a1 = 10; diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map index a39cd29ba77..6ad9ecad595 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AAC9B,2DAA8D;AACnD,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;AACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js index eae1115846a..8ad833cd4eb 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map index 866e1007e24..50a28887d0b 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputDirectory/node/outdir/simple/outputdir_module_multifolder_ref/m2.js.map @@ -1 +1 @@ -{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ 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 index 37064fb583b..b77e0a462a7 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleMultifolderSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("outputdir_module_multifolder/ref/m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("outputdir_module_multifolder/ref/m1", ["require", "exports"], function ( }); define("outputdir_module_multifolder_ref/m2", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m2_a1 = 10; var m2_c1 = (function () { function m2_c1() { @@ -30,6 +32,7 @@ define("outputdir_module_multifolder_ref/m2", ["require", "exports"], function ( }); define("outputdir_module_multifolder/test", ["require", "exports", "outputdir_module_multifolder/ref/m1", "outputdir_module_multifolder_ref/m2"], function (require, exports, m1, m2) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 c4facdba936..5d14898713d 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":["outputdir_module_multifolder/ref/m1.ts","outputdir_module_multifolder_ref/m2.ts","outputdir_module_multifolder/test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICNU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICRU,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICNU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IACd,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/amd/m1.js b/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/amd/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/amd/m1.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/amd/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/amd/m1.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/amd/m1.js.map index 1706ba76817..caee4b20553 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/amd/m1.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/amd/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/amd/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/amd/test.js index c4b7f56d76a..e5ed53fd0e1 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/amd/test.js.map index 07e9825a93a..43c2c887c65 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/node/m1.js b/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/node/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/node/m1.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/node/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/node/m1.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/node/m1.js.map index d134ab774af..fa989919301 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/node/m1.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/node/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/node/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/node/test.js index fea4b619aa2..56c8debf9b6 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/node/test.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/node/test.js.map index d07c1aa0678..1ec67278ba3 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map index 1706ba76817..caee4b20553 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js index c4b7f56d76a..e5ed53fd0e1 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 07e9825a93a..43c2c887c65 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map index d134ab774af..fa989919301 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js index fea4b619aa2..56c8debf9b6 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map index d07c1aa0678..1ec67278ba3 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;AAAA,uBAA0B;AACf,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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 index d650b20ae5f..cbe79e3318b 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleSimpleSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("m1", ["require", "exports"], function (require, exports) { }); define("test", ["require", "exports", "m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 64c90d05e88..f5849debd83 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":["m1.ts","test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["m1.ts","test.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/amd/ref/m1.js b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/amd/ref/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/amd/ref/m1.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/amd/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/amd/ref/m1.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/amd/ref/m1.js.map index 7e2762b41a4..15b12e3a189 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/amd/ref/m1.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/amd/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/amd/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/amd/test.js index 0ad51aeb02e..c95451ac730 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/amd/test.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/amd/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/amd/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/amd/test.js.map index 07e9825a93a..43c2c887c65 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/amd/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/amd/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/node/ref/m1.js b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/node/ref/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/node/ref/m1.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/node/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/node/ref/m1.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/node/ref/m1.js.map index eb883275568..6e97669732b 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/node/ref/m1.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/node/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/node/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/node/test.js index ebd5fdb3b3f..97ca26f3198 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/node/test.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/node/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/node/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/node/test.js.map index 4f024886c03..badcd2b1b9c 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/node/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderNoOutdir/node/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js index bb59c6fbd90..391c6ef6630 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map index 7e2762b41a4..15b12e3a189 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js index 0ad51aeb02e..c95451ac730 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js @@ -1,5 +1,6 @@ define(["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map index 07e9825a93a..43c2c887c65 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/amd/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;;IACW,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js index 121a089af23..02586d67fcc 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map index eb883275568..6e97669732b 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/ref/m1.js.map @@ -1 +1 @@ -{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file +{"version":3,"file":"m1.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,sBAAK;AAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js index ebd5fdb3b3f..97ca26f3198 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var m1 = require("ref/m1"); exports.a1 = 10; var c1 = (function () { diff --git a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map index 4f024886c03..badcd2b1b9c 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputDirectory/node/outdir/simple/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["test.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AACnB,QAAA,EAAE,GAAG,EAAE,CAAC;AACnB;IAAA;IAEA,CAAC;IAAD,SAAC;AAAD,CAAC,AAFD,IAEC;AAFY,gBAAE;AAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;AAChC;IACI,MAAM,CAAC,iBAAS,CAAC;AACrB,CAAC;AAFD,gBAEC;AAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ 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 index f55492f4b49..22a9cf7b4d7 100644 --- a/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js +++ b/tests/baselines/reference/project/sourcerootUrlModuleSubfolderSpecifyOutputFile/amd/bin/test.js @@ -1,5 +1,6 @@ define("ref/m1", ["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.m1_a1 = 10; var m1_c1 = (function () { function m1_c1() { @@ -15,6 +16,7 @@ define("ref/m1", ["require", "exports"], function (require, exports) { }); define("test", ["require", "exports", "ref/m1"], function (require, exports, m1) { "use strict"; + exports.__esModule = true; exports.a1 = 10; var c1 = (function () { function c1() { 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 6d26d850e19..6f4defc3e4c 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":["ref/m1.ts","test.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"http://typescript.codeplex.com/","sources":["ref/m1.ts","test.ts"],"names":[],"mappings":";;;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,sBAAK;IAIP,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC;;;;;ICPU,QAAA,EAAE,GAAG,EAAE,CAAC;IACnB;QAAA;QAEA,CAAC;QAAD,SAAC;IAAD,CAAC,AAFD,IAEC;IAFY,gBAAE;IAIJ,QAAA,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC;IAChC;QACI,MAAM,CAAC,iBAAS,CAAC;IACrB,CAAC;IAFD,gBAEC;IAEU,QAAA,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/amd/commands.js b/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/amd/commands.js index 3053eb35cb4..eb08364649a 100644 --- a/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/amd/commands.js +++ b/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/amd/commands.js @@ -1,3 +1,4 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/amd/fs.js b/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/amd/fs.js index a40f7b2f9cd..66facecde7f 100644 --- a/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/amd/fs.js +++ b/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/amd/fs.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var RM = (function () { function RM() { } diff --git a/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/amd/server.js b/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/amd/server.js index 3053eb35cb4..eb08364649a 100644 --- a/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/amd/server.js +++ b/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/amd/server.js @@ -1,3 +1,4 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/node/commands.js b/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/node/commands.js index 0c14aab22f7..64cbe53a861 100644 --- a/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/node/commands.js +++ b/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/node/commands.js @@ -1 +1,2 @@ "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/node/fs.js b/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/node/fs.js index c537ef54352..221c2322227 100644 --- a/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/node/fs.js +++ b/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/node/fs.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; var RM = (function () { function RM() { } diff --git a/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/node/server.js b/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/node/server.js index 0c14aab22f7..64cbe53a861 100644 --- a/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/node/server.js +++ b/tests/baselines/reference/project/visibilityOfTypeUsedAcrossModules/node/server.js @@ -1 +1,2 @@ "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/promiseIdentity.js b/tests/baselines/reference/promiseIdentity.js index 5b57709e991..526bae62c08 100644 --- a/tests/baselines/reference/promiseIdentity.js +++ b/tests/baselines/reference/promiseIdentity.js @@ -1,5 +1,5 @@ //// [promiseIdentity.ts] -interface IPromise { +export interface IPromise { then(callback: (x: T) => IPromise): IPromise; } interface Promise { @@ -22,6 +22,8 @@ var y: IPromise2; var y: Promise2; //// [promiseIdentity.js] +"use strict"; +exports.__esModule = true; var x; var x; // Ok because T in this particular Promise2 is any, as are all the U and W references. diff --git a/tests/baselines/reference/promiseIdentity.symbols b/tests/baselines/reference/promiseIdentity.symbols index f1404eaf7b1..f103f5b4199 100644 --- a/tests/baselines/reference/promiseIdentity.symbols +++ b/tests/baselines/reference/promiseIdentity.symbols @@ -1,14 +1,14 @@ === tests/cases/compiler/promiseIdentity.ts === -interface IPromise { +export interface IPromise { >IPromise : Symbol(IPromise, Decl(promiseIdentity.ts, 0, 0)) ->T : Symbol(T, Decl(promiseIdentity.ts, 0, 19)) +>T : Symbol(T, Decl(promiseIdentity.ts, 0, 26)) then(callback: (x: T) => IPromise): IPromise; ->then : Symbol(IPromise.then, Decl(promiseIdentity.ts, 0, 23)) +>then : Symbol(IPromise.then, Decl(promiseIdentity.ts, 0, 30)) >U : Symbol(U, Decl(promiseIdentity.ts, 1, 9)) >callback : Symbol(callback, Decl(promiseIdentity.ts, 1, 12)) >x : Symbol(x, Decl(promiseIdentity.ts, 1, 23)) ->T : Symbol(T, Decl(promiseIdentity.ts, 0, 19)) +>T : Symbol(T, Decl(promiseIdentity.ts, 0, 26)) >IPromise : Symbol(IPromise, Decl(promiseIdentity.ts, 0, 0)) >U : Symbol(U, Decl(promiseIdentity.ts, 1, 9)) >IPromise : Symbol(IPromise, Decl(promiseIdentity.ts, 0, 0)) diff --git a/tests/baselines/reference/promiseIdentity.types b/tests/baselines/reference/promiseIdentity.types index 2be853c9964..af8bc9908bf 100644 --- a/tests/baselines/reference/promiseIdentity.types +++ b/tests/baselines/reference/promiseIdentity.types @@ -1,5 +1,5 @@ === tests/cases/compiler/promiseIdentity.ts === -interface IPromise { +export interface IPromise { >IPromise : IPromise >T : T diff --git a/tests/baselines/reference/promiseIdentity2.errors.txt b/tests/baselines/reference/promiseIdentity2.errors.txt index 6b8223c3bda..edfba2f42bc 100644 --- a/tests/baselines/reference/promiseIdentity2.errors.txt +++ b/tests/baselines/reference/promiseIdentity2.errors.txt @@ -2,10 +2,10 @@ tests/cases/compiler/promiseIdentity2.ts(11,5): error TS2403: Subsequent variabl ==== tests/cases/compiler/promiseIdentity2.ts (1 errors) ==== - interface IPromise { + export interface IPromise { then(callback: (x: T) => IPromise): IPromise; } - interface Promise { + export interface Promise { then(callback: (x: T) => Promise): Promise; } diff --git a/tests/baselines/reference/promiseIdentity2.js b/tests/baselines/reference/promiseIdentity2.js index 8bb4139a737..81beb44d78a 100644 --- a/tests/baselines/reference/promiseIdentity2.js +++ b/tests/baselines/reference/promiseIdentity2.js @@ -1,8 +1,8 @@ //// [promiseIdentity2.ts] -interface IPromise { +export interface IPromise { then(callback: (x: T) => IPromise): IPromise; } -interface Promise { +export interface Promise { then(callback: (x: T) => Promise): Promise; } @@ -12,6 +12,8 @@ var x: IPromise; var x: Promise; //// [promiseIdentity2.js] +"use strict"; +exports.__esModule = true; // error because T is string in the first declaration, and T is boolean in the second // Return type and callback return type are ok because T is any in this particular Promise var x; diff --git a/tests/baselines/reference/promiseIdentityWithAny.js b/tests/baselines/reference/promiseIdentityWithAny.js index 1a516067c8e..422d00a1312 100644 --- a/tests/baselines/reference/promiseIdentityWithAny.js +++ b/tests/baselines/reference/promiseIdentityWithAny.js @@ -1,8 +1,8 @@ //// [promiseIdentityWithAny.ts] -interface IPromise { +export interface IPromise { then(callback: (x: T) => IPromise): IPromise; } -interface Promise { +export interface Promise { then(callback: (x: T) => Promise): Promise; } @@ -11,6 +11,8 @@ var x: IPromise; var x: Promise; //// [promiseIdentityWithAny.js] +"use strict"; +exports.__esModule = true; // Should be ok because signature type parameters get erased to any var x; var x; diff --git a/tests/baselines/reference/promiseIdentityWithAny.symbols b/tests/baselines/reference/promiseIdentityWithAny.symbols index 8bcf096a0a3..65881f53a32 100644 --- a/tests/baselines/reference/promiseIdentityWithAny.symbols +++ b/tests/baselines/reference/promiseIdentityWithAny.symbols @@ -1,16 +1,16 @@ === tests/cases/compiler/promiseIdentityWithAny.ts === -interface IPromise { +export interface IPromise { >IPromise : Symbol(IPromise, Decl(promiseIdentityWithAny.ts, 0, 0)) ->T : Symbol(T, Decl(promiseIdentityWithAny.ts, 0, 19)) ->V : Symbol(V, Decl(promiseIdentityWithAny.ts, 0, 21)) +>T : Symbol(T, Decl(promiseIdentityWithAny.ts, 0, 26)) +>V : Symbol(V, Decl(promiseIdentityWithAny.ts, 0, 28)) then(callback: (x: T) => IPromise): IPromise; ->then : Symbol(IPromise.then, Decl(promiseIdentityWithAny.ts, 0, 26)) +>then : Symbol(IPromise.then, Decl(promiseIdentityWithAny.ts, 0, 33)) >U : Symbol(U, Decl(promiseIdentityWithAny.ts, 1, 9)) >W : Symbol(W, Decl(promiseIdentityWithAny.ts, 1, 11)) >callback : Symbol(callback, Decl(promiseIdentityWithAny.ts, 1, 15)) >x : Symbol(x, Decl(promiseIdentityWithAny.ts, 1, 26)) ->T : Symbol(T, Decl(promiseIdentityWithAny.ts, 0, 19)) +>T : Symbol(T, Decl(promiseIdentityWithAny.ts, 0, 26)) >IPromise : Symbol(IPromise, Decl(promiseIdentityWithAny.ts, 0, 0)) >U : Symbol(U, Decl(promiseIdentityWithAny.ts, 1, 9)) >W : Symbol(W, Decl(promiseIdentityWithAny.ts, 1, 11)) @@ -18,18 +18,18 @@ interface IPromise { >U : Symbol(U, Decl(promiseIdentityWithAny.ts, 1, 9)) >W : Symbol(W, Decl(promiseIdentityWithAny.ts, 1, 11)) } -interface Promise { +export interface Promise { >Promise : Symbol(Promise, Decl(promiseIdentityWithAny.ts, 2, 1)) ->T : Symbol(T, Decl(promiseIdentityWithAny.ts, 3, 18)) ->V : Symbol(V, Decl(promiseIdentityWithAny.ts, 3, 20)) +>T : Symbol(T, Decl(promiseIdentityWithAny.ts, 3, 25)) +>V : Symbol(V, Decl(promiseIdentityWithAny.ts, 3, 27)) then(callback: (x: T) => Promise): Promise; ->then : Symbol(Promise.then, Decl(promiseIdentityWithAny.ts, 3, 25)) +>then : Symbol(Promise.then, Decl(promiseIdentityWithAny.ts, 3, 32)) >U : Symbol(U, Decl(promiseIdentityWithAny.ts, 4, 9)) >W : Symbol(W, Decl(promiseIdentityWithAny.ts, 4, 11)) >callback : Symbol(callback, Decl(promiseIdentityWithAny.ts, 4, 15)) >x : Symbol(x, Decl(promiseIdentityWithAny.ts, 4, 26)) ->T : Symbol(T, Decl(promiseIdentityWithAny.ts, 3, 18)) +>T : Symbol(T, Decl(promiseIdentityWithAny.ts, 3, 25)) >Promise : Symbol(Promise, Decl(promiseIdentityWithAny.ts, 2, 1)) >Promise : Symbol(Promise, Decl(promiseIdentityWithAny.ts, 2, 1)) } diff --git a/tests/baselines/reference/promiseIdentityWithAny.types b/tests/baselines/reference/promiseIdentityWithAny.types index f96e6d90363..d5efb5a6f8b 100644 --- a/tests/baselines/reference/promiseIdentityWithAny.types +++ b/tests/baselines/reference/promiseIdentityWithAny.types @@ -1,5 +1,5 @@ === tests/cases/compiler/promiseIdentityWithAny.ts === -interface IPromise { +export interface IPromise { >IPromise : IPromise >T : T >V : V @@ -18,7 +18,7 @@ interface IPromise { >U : U >W : W } -interface Promise { +export interface Promise { >Promise : Promise >T : T >V : V diff --git a/tests/baselines/reference/promiseIdentityWithAny2.errors.txt b/tests/baselines/reference/promiseIdentityWithAny2.errors.txt index 36492d3f37a..9d01438b88c 100644 --- a/tests/baselines/reference/promiseIdentityWithAny2.errors.txt +++ b/tests/baselines/reference/promiseIdentityWithAny2.errors.txt @@ -3,7 +3,7 @@ tests/cases/compiler/promiseIdentityWithAny2.ts(22,5): error TS2403: Subsequent ==== tests/cases/compiler/promiseIdentityWithAny2.ts (2 errors) ==== - interface IPromise { + export interface IPromise { then(callback: (x: T) => IPromise): IPromise; } interface Promise { diff --git a/tests/baselines/reference/promiseIdentityWithAny2.js b/tests/baselines/reference/promiseIdentityWithAny2.js index ec98b5ed4d9..a26cfd05084 100644 --- a/tests/baselines/reference/promiseIdentityWithAny2.js +++ b/tests/baselines/reference/promiseIdentityWithAny2.js @@ -1,5 +1,5 @@ //// [promiseIdentityWithAny2.ts] -interface IPromise { +export interface IPromise { then(callback: (x: T) => IPromise): IPromise; } interface Promise { @@ -23,6 +23,8 @@ var y: IPromise2; var y: Promise2; //// [promiseIdentityWithAny2.js] +"use strict"; +exports.__esModule = true; // Error because type parameter arity doesn't match var x; var x; diff --git a/tests/baselines/reference/promiseIdentityWithConstraints.js b/tests/baselines/reference/promiseIdentityWithConstraints.js index 0130d22df8f..5c0549dc99d 100644 --- a/tests/baselines/reference/promiseIdentityWithConstraints.js +++ b/tests/baselines/reference/promiseIdentityWithConstraints.js @@ -1,8 +1,8 @@ //// [promiseIdentityWithConstraints.ts] -interface IPromise { +export interface IPromise { then(callback: (x: T) => IPromise): IPromise; } -interface Promise { +export interface Promise { then(callback: (x: T) => Promise): Promise; } @@ -11,6 +11,8 @@ var x: IPromise; var x: Promise; //// [promiseIdentityWithConstraints.js] +"use strict"; +exports.__esModule = true; // Error because constraint V doesn't match var x; var x; diff --git a/tests/baselines/reference/promiseIdentityWithConstraints.symbols b/tests/baselines/reference/promiseIdentityWithConstraints.symbols index 00308362b18..bcdc3c441bd 100644 --- a/tests/baselines/reference/promiseIdentityWithConstraints.symbols +++ b/tests/baselines/reference/promiseIdentityWithConstraints.symbols @@ -1,18 +1,18 @@ === tests/cases/compiler/promiseIdentityWithConstraints.ts === -interface IPromise { +export interface IPromise { >IPromise : Symbol(IPromise, Decl(promiseIdentityWithConstraints.ts, 0, 0)) ->T : Symbol(T, Decl(promiseIdentityWithConstraints.ts, 0, 19)) ->V : Symbol(V, Decl(promiseIdentityWithConstraints.ts, 0, 21)) +>T : Symbol(T, Decl(promiseIdentityWithConstraints.ts, 0, 26)) +>V : Symbol(V, Decl(promiseIdentityWithConstraints.ts, 0, 28)) then(callback: (x: T) => IPromise): IPromise; ->then : Symbol(IPromise.then, Decl(promiseIdentityWithConstraints.ts, 0, 26)) +>then : Symbol(IPromise.then, Decl(promiseIdentityWithConstraints.ts, 0, 33)) >U : Symbol(U, Decl(promiseIdentityWithConstraints.ts, 1, 9)) ->T : Symbol(T, Decl(promiseIdentityWithConstraints.ts, 0, 19)) +>T : Symbol(T, Decl(promiseIdentityWithConstraints.ts, 0, 26)) >W : Symbol(W, Decl(promiseIdentityWithConstraints.ts, 1, 21)) ->V : Symbol(V, Decl(promiseIdentityWithConstraints.ts, 0, 21)) +>V : Symbol(V, Decl(promiseIdentityWithConstraints.ts, 0, 28)) >callback : Symbol(callback, Decl(promiseIdentityWithConstraints.ts, 1, 35)) >x : Symbol(x, Decl(promiseIdentityWithConstraints.ts, 1, 46)) ->T : Symbol(T, Decl(promiseIdentityWithConstraints.ts, 0, 19)) +>T : Symbol(T, Decl(promiseIdentityWithConstraints.ts, 0, 26)) >IPromise : Symbol(IPromise, Decl(promiseIdentityWithConstraints.ts, 0, 0)) >U : Symbol(U, Decl(promiseIdentityWithConstraints.ts, 1, 9)) >W : Symbol(W, Decl(promiseIdentityWithConstraints.ts, 1, 21)) @@ -20,20 +20,20 @@ interface IPromise { >U : Symbol(U, Decl(promiseIdentityWithConstraints.ts, 1, 9)) >W : Symbol(W, Decl(promiseIdentityWithConstraints.ts, 1, 21)) } -interface Promise { +export interface Promise { >Promise : Symbol(Promise, Decl(promiseIdentityWithConstraints.ts, 2, 1)) ->T : Symbol(T, Decl(promiseIdentityWithConstraints.ts, 3, 18)) ->V : Symbol(V, Decl(promiseIdentityWithConstraints.ts, 3, 20)) +>T : Symbol(T, Decl(promiseIdentityWithConstraints.ts, 3, 25)) +>V : Symbol(V, Decl(promiseIdentityWithConstraints.ts, 3, 27)) then(callback: (x: T) => Promise): Promise; ->then : Symbol(Promise.then, Decl(promiseIdentityWithConstraints.ts, 3, 25)) +>then : Symbol(Promise.then, Decl(promiseIdentityWithConstraints.ts, 3, 32)) >U : Symbol(U, Decl(promiseIdentityWithConstraints.ts, 4, 9)) ->T : Symbol(T, Decl(promiseIdentityWithConstraints.ts, 3, 18)) +>T : Symbol(T, Decl(promiseIdentityWithConstraints.ts, 3, 25)) >W : Symbol(W, Decl(promiseIdentityWithConstraints.ts, 4, 21)) ->V : Symbol(V, Decl(promiseIdentityWithConstraints.ts, 3, 20)) +>V : Symbol(V, Decl(promiseIdentityWithConstraints.ts, 3, 27)) >callback : Symbol(callback, Decl(promiseIdentityWithConstraints.ts, 4, 35)) >x : Symbol(x, Decl(promiseIdentityWithConstraints.ts, 4, 46)) ->T : Symbol(T, Decl(promiseIdentityWithConstraints.ts, 3, 18)) +>T : Symbol(T, Decl(promiseIdentityWithConstraints.ts, 3, 25)) >Promise : Symbol(Promise, Decl(promiseIdentityWithConstraints.ts, 2, 1)) >U : Symbol(U, Decl(promiseIdentityWithConstraints.ts, 4, 9)) >W : Symbol(W, Decl(promiseIdentityWithConstraints.ts, 4, 21)) diff --git a/tests/baselines/reference/promiseIdentityWithConstraints.types b/tests/baselines/reference/promiseIdentityWithConstraints.types index 5bc321cbb16..9c52a9581b8 100644 --- a/tests/baselines/reference/promiseIdentityWithConstraints.types +++ b/tests/baselines/reference/promiseIdentityWithConstraints.types @@ -1,5 +1,5 @@ === tests/cases/compiler/promiseIdentityWithConstraints.ts === -interface IPromise { +export interface IPromise { >IPromise : IPromise >T : T >V : V @@ -20,7 +20,7 @@ interface IPromise { >U : U >W : W } -interface Promise { +export interface Promise { >Promise : Promise >T : T >V : V diff --git a/tests/baselines/reference/promisePermutations.errors.txt b/tests/baselines/reference/promisePermutations.errors.txt index 13fc0718596..69bd8c1e629 100644 --- a/tests/baselines/reference/promisePermutations.errors.txt +++ b/tests/baselines/reference/promisePermutations.errors.txt @@ -51,9 +51,9 @@ tests/cases/compiler/promisePermutations.ts(144,12): error TS2453: The type argu tests/cases/compiler/promisePermutations.ts(152,12): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'Promise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. Types of property 'then' are incompatible. - Type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }' is not assignable to type '{ (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. - Types of parameters 'success' and 'success' are incompatible. - Type '(value: number) => Promise' is not assignable to type '(value: string) => IPromise'. + Type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }' is not assignable to type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. + Types of parameters 'success' and 'onfulfilled' are incompatible. + Type '(value: number) => any' is not assignable to type '(value: string) => IPromise'. Types of parameters 'value' and 'value' are incompatible. Type 'string' is not assignable to type 'number'. tests/cases/compiler/promisePermutations.ts(156,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. @@ -68,9 +68,9 @@ tests/cases/compiler/promisePermutations.ts(159,21): error TS2345: Argument of t tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. Type 'Promise' is not assignable to type 'IPromise'. Types of property 'then' are incompatible. - Type '{ (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }'. - Types of parameters 'success' and 'success' are incompatible. - Type '(value: string) => IPromise' is not assignable to type '(value: number) => Promise'. + Type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }'. + Types of parameters 'onfulfilled' and 'success' are incompatible. + Type '(value: string) => IPromise' is not assignable to type '(value: number) => any'. Types of parameters 'value' and 'value' are incompatible. Type 'number' is not assignable to type 'string'. @@ -310,9 +310,9 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t !!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate 'Promise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. !!! error TS2453: Types of property 'then' are incompatible. -!!! error TS2453: Type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }' is not assignable to type '{ (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. -!!! error TS2453: Types of parameters 'success' and 'success' are incompatible. -!!! error TS2453: Type '(value: number) => Promise' is not assignable to type '(value: string) => IPromise'. +!!! error TS2453: Type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }' is not assignable to type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. +!!! error TS2453: Types of parameters 'success' and 'onfulfilled' are incompatible. +!!! error TS2453: Type '(value: number) => any' is not assignable to type '(value: string) => IPromise'. !!! error TS2453: Types of parameters 'value' and 'value' are incompatible. !!! error TS2453: Type 'string' is not assignable to type 'number'. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok @@ -339,9 +339,9 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t !!! error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. !!! error TS2345: Type 'Promise' is not assignable to type 'IPromise'. !!! error TS2345: Types of property 'then' are incompatible. -!!! error TS2345: Type '{ (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }'. -!!! error TS2345: Types of parameters 'success' and 'success' are incompatible. -!!! error TS2345: Type '(value: string) => IPromise' is not assignable to type '(value: number) => Promise'. +!!! error TS2345: Type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }'. +!!! error TS2345: Types of parameters 'onfulfilled' and 'success' are incompatible. +!!! error TS2345: Type '(value: string) => IPromise' is not assignable to type '(value: number) => any'. !!! error TS2345: Types of parameters 'value' and 'value' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'string'. diff --git a/tests/baselines/reference/promisePermutations2.errors.txt b/tests/baselines/reference/promisePermutations2.errors.txt index b21a3a39208..cbbd9cc7736 100644 --- a/tests/baselines/reference/promisePermutations2.errors.txt +++ b/tests/baselines/reference/promisePermutations2.errors.txt @@ -51,8 +51,8 @@ tests/cases/compiler/promisePermutations2.ts(143,12): error TS2453: The type arg tests/cases/compiler/promisePermutations2.ts(151,12): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'Promise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. Types of property 'then' are incompatible. - Type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }' is not assignable to type '(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void) => Promise'. - Types of parameters 'success' and 'success' are incompatible. + Type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }' is not assignable to type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. + Types of parameters 'success' and 'onfulfilled' are incompatible. Type '(value: number) => any' is not assignable to type '(value: string) => IPromise'. Types of parameters 'value' and 'value' are incompatible. Type 'string' is not assignable to type 'number'. @@ -68,8 +68,8 @@ tests/cases/compiler/promisePermutations2.ts(158,21): error TS2345: Argument of tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. Type 'Promise' is not assignable to type 'IPromise'. Types of property 'then' are incompatible. - Type '(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void) => Promise' is not assignable to type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }'. - Types of parameters 'success' and 'success' are incompatible. + Type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }'. + Types of parameters 'onfulfilled' and 'success' are incompatible. Type '(value: string) => IPromise' is not assignable to type '(value: number) => any'. Types of parameters 'value' and 'value' are incompatible. Type 'number' is not assignable to type 'string'. @@ -309,8 +309,8 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of !!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate 'Promise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. !!! error TS2453: Types of property 'then' are incompatible. -!!! error TS2453: Type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }' is not assignable to type '(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void) => Promise'. -!!! error TS2453: Types of parameters 'success' and 'success' are incompatible. +!!! error TS2453: Type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }' is not assignable to type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. +!!! error TS2453: Types of parameters 'success' and 'onfulfilled' are incompatible. !!! error TS2453: Type '(value: number) => any' is not assignable to type '(value: string) => IPromise'. !!! error TS2453: Types of parameters 'value' and 'value' are incompatible. !!! error TS2453: Type 'string' is not assignable to type 'number'. @@ -338,8 +338,8 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of !!! error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. !!! error TS2345: Type 'Promise' is not assignable to type 'IPromise'. !!! error TS2345: Types of property 'then' are incompatible. -!!! error TS2345: Type '(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void) => Promise' is not assignable to type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }'. -!!! error TS2345: Types of parameters 'success' and 'success' are incompatible. +!!! error TS2345: Type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }'. +!!! error TS2345: Types of parameters 'onfulfilled' and 'success' are incompatible. !!! error TS2345: Type '(value: string) => IPromise' is not assignable to type '(value: number) => any'. !!! error TS2345: Types of parameters 'value' and 'value' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'string'. diff --git a/tests/baselines/reference/promisePermutations3.errors.txt b/tests/baselines/reference/promisePermutations3.errors.txt index 1a33d1083aa..fd0ce0d643e 100644 --- a/tests/baselines/reference/promisePermutations3.errors.txt +++ b/tests/baselines/reference/promisePermutations3.errors.txt @@ -54,9 +54,9 @@ tests/cases/compiler/promisePermutations3.ts(143,12): error TS2453: The type arg tests/cases/compiler/promisePermutations3.ts(151,12): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'Promise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. Types of property 'then' are incompatible. - Type '(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise' is not assignable to type '{ (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. - Types of parameters 'success' and 'success' are incompatible. - Type '(value: number) => Promise' is not assignable to type '(value: string) => any'. + Type '(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise' is not assignable to type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. + Types of parameters 'success' and 'onfulfilled' are incompatible. + Type '(value: number) => any' is not assignable to type '(value: string) => any'. Types of parameters 'value' and 'value' are incompatible. Type 'string' is not assignable to type 'number'. tests/cases/compiler/promisePermutations3.ts(155,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. @@ -71,15 +71,15 @@ tests/cases/compiler/promisePermutations3.ts(158,21): error TS2345: Argument of tests/cases/compiler/promisePermutations3.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. Type 'Promise' is not assignable to type 'IPromise'. Types of property 'then' are incompatible. - Type '{ (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise'. - Types of parameters 'success' and 'success' are incompatible. - Type '(value: string) => any' is not assignable to type '(value: number) => Promise'. + Type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise'. + Types of parameters 'onfulfilled' and 'success' are incompatible. + Type '(value: string) => any' is not assignable to type '(value: number) => any'. Types of parameters 'value' and 'value' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of type '{ (x: T): IPromise; (x: T, y: T): Promise; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise'. Type 'IPromise' is not assignable to type 'Promise'. Types of property 'then' are incompatible. - Type '(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise' is not assignable to type '{ (success?: (value: any) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: any) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: any) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. + Type '(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise' is not assignable to type '{ (onfulfilled?: (value: any) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: any) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: any) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: any) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. Type 'IPromise' is not assignable to type 'Promise'. @@ -321,9 +321,9 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of !!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate 'Promise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. !!! error TS2453: Types of property 'then' are incompatible. -!!! error TS2453: Type '(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise' is not assignable to type '{ (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. -!!! error TS2453: Types of parameters 'success' and 'success' are incompatible. -!!! error TS2453: Type '(value: number) => Promise' is not assignable to type '(value: string) => any'. +!!! error TS2453: Type '(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise' is not assignable to type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. +!!! error TS2453: Types of parameters 'success' and 'onfulfilled' are incompatible. +!!! error TS2453: Type '(value: number) => any' is not assignable to type '(value: string) => any'. !!! error TS2453: Types of parameters 'value' and 'value' are incompatible. !!! error TS2453: Type 'string' is not assignable to type 'number'. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok @@ -350,9 +350,9 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of !!! error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. !!! error TS2345: Type 'Promise' is not assignable to type 'IPromise'. !!! error TS2345: Types of property 'then' are incompatible. -!!! error TS2345: Type '{ (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise'. -!!! error TS2345: Types of parameters 'success' and 'success' are incompatible. -!!! error TS2345: Type '(value: string) => any' is not assignable to type '(value: number) => Promise'. +!!! error TS2345: Type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise'. +!!! error TS2345: Types of parameters 'onfulfilled' and 'success' are incompatible. +!!! error TS2345: Type '(value: string) => any' is not assignable to type '(value: number) => any'. !!! error TS2345: Types of parameters 'value' and 'value' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'string'. @@ -365,6 +365,6 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of !!! error TS2345: Argument of type '{ (x: T): IPromise; (x: T, y: T): Promise; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise'. !!! error TS2345: Type 'IPromise' is not assignable to type 'Promise'. !!! error TS2345: Types of property 'then' are incompatible. -!!! error TS2345: Type '(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise' is not assignable to type '{ (success?: (value: any) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: any) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: any) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. +!!! error TS2345: Type '(success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise' is not assignable to type '{ (onfulfilled?: (value: any) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: any) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: any) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: any) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. !!! error TS2345: Type 'IPromise' is not assignable to type 'Promise'. var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok \ No newline at end of file diff --git a/tests/baselines/reference/promiseTest.symbols b/tests/baselines/reference/promiseTest.symbols index 6cf4ff98d8f..f28348cca45 100644 --- a/tests/baselines/reference/promiseTest.symbols +++ b/tests/baselines/reference/promiseTest.symbols @@ -1,44 +1,44 @@ === tests/cases/compiler/promiseTest.ts === interface Promise { ->Promise : Symbol(Promise, Decl(promiseTest.ts, 0, 0)) ->T : Symbol(T, Decl(promiseTest.ts, 1, 18)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 0, 0)) +>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 1, 18)) then(success?: (value: T) => Promise): Promise; ->then : Symbol(Promise.then, Decl(promiseTest.ts, 1, 22), Decl(promiseTest.ts, 2, 60)) +>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 1, 22), Decl(promiseTest.ts, 2, 60)) >A : Symbol(A, Decl(promiseTest.ts, 2, 9)) >success : Symbol(success, Decl(promiseTest.ts, 2, 12)) >value : Symbol(value, Decl(promiseTest.ts, 2, 23)) ->T : Symbol(T, Decl(promiseTest.ts, 1, 18)) ->Promise : Symbol(Promise, Decl(promiseTest.ts, 0, 0)) +>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 1, 18)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 0, 0)) >A : Symbol(A, Decl(promiseTest.ts, 2, 9)) ->Promise : Symbol(Promise, Decl(promiseTest.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 0, 0)) >A : Symbol(A, Decl(promiseTest.ts, 2, 9)) then(success?: (value: T) => B): Promise; ->then : Symbol(Promise.then, Decl(promiseTest.ts, 1, 22), Decl(promiseTest.ts, 2, 60)) +>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 1, 22), Decl(promiseTest.ts, 2, 60)) >B : Symbol(B, Decl(promiseTest.ts, 3, 9)) >success : Symbol(success, Decl(promiseTest.ts, 3, 12)) >value : Symbol(value, Decl(promiseTest.ts, 3, 23)) ->T : Symbol(T, Decl(promiseTest.ts, 1, 18)) +>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 1, 18)) >B : Symbol(B, Decl(promiseTest.ts, 3, 9)) ->Promise : Symbol(Promise, Decl(promiseTest.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 0, 0)) >B : Symbol(B, Decl(promiseTest.ts, 3, 9)) data: T; >data : Symbol(Promise.data, Decl(promiseTest.ts, 3, 51)) ->T : Symbol(T, Decl(promiseTest.ts, 1, 18)) +>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 1, 18)) } var p: Promise = null; >p : Symbol(p, Decl(promiseTest.ts, 7, 3)) ->Promise : Symbol(Promise, Decl(promiseTest.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 0, 0)) var p2 = p.then(function (x) { >p2 : Symbol(p2, Decl(promiseTest.ts, 8, 3)) ->p.then : Symbol(Promise.then, Decl(promiseTest.ts, 1, 22), Decl(promiseTest.ts, 2, 60)) +>p.then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 1, 22), Decl(promiseTest.ts, 2, 60)) >p : Symbol(p, Decl(promiseTest.ts, 7, 3)) ->then : Symbol(Promise.then, Decl(promiseTest.ts, 1, 22), Decl(promiseTest.ts, 2, 60)) +>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promiseTest.ts, 1, 22), Decl(promiseTest.ts, 2, 60)) >x : Symbol(x, Decl(promiseTest.ts, 8, 26)) return p; diff --git a/tests/baselines/reference/promiseTest.types b/tests/baselines/reference/promiseTest.types index 5ec43b9f42b..d69e1efeb42 100644 --- a/tests/baselines/reference/promiseTest.types +++ b/tests/baselines/reference/promiseTest.types @@ -5,7 +5,7 @@ interface Promise { >T : T then(success?: (value: T) => Promise): Promise; ->then : { (success?: (value: T) => Promise): Promise; (success?: (value: T) => B): Promise; } +>then : { (onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: T) => Promise): Promise; (success?: (value: T) => B): Promise; } >A : A >success : (value: T) => Promise >value : T @@ -16,7 +16,7 @@ interface Promise { >A : A then(success?: (value: T) => B): Promise; ->then : { (success?: (value: T) => Promise): Promise; (success?: (value: T) => B): Promise; } +>then : { (onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: T) => Promise): Promise; (success?: (value: T) => B): Promise; } >B : B >success : (value: T) => B >value : T @@ -38,9 +38,9 @@ var p: Promise = null; var p2 = p.then(function (x) { >p2 : Promise >p.then(function (x) { return p;} ) : Promise ->p.then : { (success?: (value: number) => Promise): Promise; (success?: (value: number) => B): Promise; } +>p.then : { (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => Promise): Promise; (success?: (value: number) => B): Promise; } >p : Promise ->then : { (success?: (value: number) => Promise): Promise; (success?: (value: number) => B): Promise; } +>then : { (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => Promise): Promise; (success?: (value: number) => B): Promise; } >function (x) { return p;} : (x: number) => Promise >x : number diff --git a/tests/baselines/reference/promiseType.js b/tests/baselines/reference/promiseType.js index 4e42ea24073..d6b82ebb4d5 100644 --- a/tests/baselines/reference/promiseType.js +++ b/tests/baselines/reference/promiseType.js @@ -1,16 +1,6 @@ //// [promiseType.ts] declare var p: Promise; - -const a = p.then(); -const b = p.then(b => 1); -const c = p.then(b => 1, e => 'error'); -const d = p.then(b => 1, e => { }); -const e = p.then(b => 1, e => { throw Error(); }); -const f = p.then(b => 1, e => Promise.reject(Error())); -const g = p.catch(e => 'error'); -const h = p.catch(e => { }); -const i = p.catch(e => { throw Error(); }); -const j = p.catch(e => Promise.reject(Error())); +declare var x: any; async function A() { const a = await p; @@ -22,17 +12,15 @@ async function B() { return 1; } -// NOTE: This reports a "No best comment type exists among return expressions." error, and is -// ignored to get the types result for the test. -// async function C() { -// try { -// const a = await p; -// return 1; -// } -// catch (e) { -// return 'error'; -// } -// } +async function C() { + try { + const a = await p; + return 1; + } + catch (e) { + return 'error'; + } +} async function D() { try { @@ -96,64 +84,140 @@ async function I() { // addresses github issue #4903: const p00 = p.catch(); -const p01 = p.catch(undefined); -const p07 = p.catch(null); -const p02 = p.catch(() => 1); -const p03 = p.catch(() => {}); -const p04 = p.catch(() => {throw 1}); -const p05 = p.catch(() => Promise.reject(1)); -const p06 = p.catch(() => Promise.resolve(1)); +const p01 = p.then(); -const p10 = p.then(); +const p10 = p.catch(undefined); +const p11 = p.catch(null); +const p12 = p.catch(() => 1); +const p13 = p.catch(() => x); +const p14 = p.catch(() => undefined); +const p15 = p.catch(() => null); +const p16 = p.catch(() => {}); +const p17 = p.catch(() => {throw 1}); +const p18 = p.catch(() => Promise.reject(1)); +const p19 = p.catch(() => Promise.resolve(1)); const p20 = p.then(undefined); -const p21 = p.then(() => 1); -const p22 = p.then(() => {}); -const p23 = p.then(() => {throw 1}); -const p24 = p.then(() => Promise.resolve(1)); -const p25 = p.then(() => Promise.reject(1)); +const p21 = p.then(null); +const p22 = p.then(() => 1); +const p23 = p.then(() => x); +const p24 = p.then(() => undefined); +const p25 = p.then(() => null); +const p26 = p.then(() => {}); +const p27 = p.then(() => {throw 1}); +const p28 = p.then(() => Promise.resolve(1)); +const p29 = p.then(() => Promise.reject(1)); const p30 = p.then(undefined, undefined); -const p31 = p.then(undefined, () => 1); -const p32 = p.then(undefined, () => {}); -const p33 = p.then(undefined, () => {throw 1}); -const p34 = p.then(undefined, () => Promise.resolve(1)); -const p35 = p.then(undefined, () => Promise.reject(1)); +const p31 = p.then(undefined, null); +const p32 = p.then(undefined, () => 1); +const p33 = p.then(undefined, () => x); +const p34 = p.then(undefined, () => undefined); +const p35 = p.then(undefined, () => null); +const p36 = p.then(undefined, () => {}); +const p37 = p.then(undefined, () => {throw 1}); +const p38 = p.then(undefined, () => Promise.resolve(1)); +const p39 = p.then(undefined, () => Promise.reject(1)); -const p40 = p.then(() => "1", undefined); -const p41 = p.then(() => "1", () => 1); -const p42 = p.then(() => "1", () => {}); -const p43 = p.then(() => "1", () => {throw 1}); -const p44 = p.then(() => "1", () => Promise.resolve(1)); -const p45 = p.then(() => "1", () => Promise.reject(1)); +const p40 = p.then(null, undefined); +const p41 = p.then(null, null); +const p42 = p.then(null, () => 1); +const p43 = p.then(null, () => x); +const p44 = p.then(null, () => undefined); +const p45 = p.then(null, () => null); +const p46 = p.then(null, () => {}); +const p47 = p.then(null, () => {throw 1}); +const p48 = p.then(null, () => Promise.resolve(1)); +const p49 = p.then(null, () => Promise.reject(1)); -const p50 = p.then(() => {}, undefined); -const p51 = p.then(() => {}, () => 1); -const p52 = p.then(() => {}, () => {}); -const p53 = p.then(() => {}, () => {throw 1}); -const p54 = p.then(() => {}, () => Promise.resolve(1)); -const p55 = p.then(() => {}, () => Promise.reject(1)); +const p50 = p.then(() => "1", undefined); +const p51 = p.then(() => "1", null); +const p52 = p.then(() => "1", () => 1); +const p53 = p.then(() => "1", () => x); +const p54 = p.then(() => "1", () => undefined); +const p55 = p.then(() => "1", () => null); +const p56 = p.then(() => "1", () => {}); +const p57 = p.then(() => "1", () => {throw 1}); +const p58 = p.then(() => "1", () => Promise.resolve(1)); +const p59 = p.then(() => "1", () => Promise.reject(1)); -const p60 = p.then(() => {throw 1}, undefined); -const p61 = p.then(() => {throw 1}, () => 1); -const p62 = p.then(() => {throw 1}, () => {}); -const p63 = p.then(() => {throw 1}, () => {throw 1}); -const p64 = p.then(() => {throw 1}, () => Promise.resolve(1)); -const p65 = p.then(() => {throw 1}, () => Promise.reject(1)); +const p60 = p.then(() => x, undefined); +const p61 = p.then(() => x, null); +const p62 = p.then(() => x, () => 1); +const p63 = p.then(() => x, () => x); +const p64 = p.then(() => x, () => undefined); +const p65 = p.then(() => x, () => null); +const p66 = p.then(() => x, () => {}); +const p67 = p.then(() => x, () => {throw 1}); +const p68 = p.then(() => x, () => Promise.resolve(1)); +const p69 = p.then(() => x, () => Promise.reject(1)); -const p70 = p.then(() => Promise.resolve("1"), undefined); -const p71 = p.then(() => Promise.resolve("1"), () => 1); -const p72 = p.then(() => Promise.resolve("1"), () => {}); -const p73 = p.then(() => Promise.resolve("1"), () => {throw 1}); -const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); -const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); +const p70 = p.then(() => undefined, undefined); +const p71 = p.then(() => undefined, null); +const p72 = p.then(() => undefined, () => 1); +const p73 = p.then(() => undefined, () => x); +const p74 = p.then(() => undefined, () => undefined); +const p75 = p.then(() => undefined, () => null); +const p76 = p.then(() => undefined, () => {}); +const p77 = p.then(() => undefined, () => {throw 1}); +const p78 = p.then(() => undefined, () => Promise.resolve(1)); +const p79 = p.then(() => undefined, () => Promise.reject(1)); -const p80 = p.then(() => Promise.reject(1), undefined); -const p81 = p.then(() => Promise.reject(1), () => 1); -const p82 = p.then(() => Promise.reject(1), () => {}); -const p83 = p.then(() => Promise.reject(1), () => {throw 1}); -const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); -const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1)); +const p80 = p.then(() => null, undefined); +const p81 = p.then(() => null, null); +const p82 = p.then(() => null, () => 1); +const p83 = p.then(() => null, () => x); +const p84 = p.then(() => null, () => undefined); +const p85 = p.then(() => null, () => null); +const p86 = p.then(() => null, () => {}); +const p87 = p.then(() => null, () => {throw 1}); +const p88 = p.then(() => null, () => Promise.resolve(1)); +const p89 = p.then(() => null, () => Promise.reject(1)); + +const p90 = p.then(() => {}, undefined); +const p91 = p.then(() => {}, null); +const p92 = p.then(() => {}, () => 1); +const p93 = p.then(() => {}, () => x); +const p94 = p.then(() => {}, () => undefined); +const p95 = p.then(() => {}, () => null); +const p96 = p.then(() => {}, () => {}); +const p97 = p.then(() => {}, () => {throw 1}); +const p98 = p.then(() => {}, () => Promise.resolve(1)); +const p99 = p.then(() => {}, () => Promise.reject(1)); + +const pa0 = p.then(() => {throw 1}, undefined); +const pa1 = p.then(() => {throw 1}, null); +const pa2 = p.then(() => {throw 1}, () => 1); +const pa3 = p.then(() => {throw 1}, () => x); +const pa4 = p.then(() => {throw 1}, () => undefined); +const pa5 = p.then(() => {throw 1}, () => null); +const pa6 = p.then(() => {throw 1}, () => {}); +const pa7 = p.then(() => {throw 1}, () => {throw 1}); +const pa8 = p.then(() => {throw 1}, () => Promise.resolve(1)); +const pa9 = p.then(() => {throw 1}, () => Promise.reject(1)); + +const pb0 = p.then(() => Promise.resolve("1"), undefined); +const pb1 = p.then(() => Promise.resolve("1"), null); +const pb2 = p.then(() => Promise.resolve("1"), () => 1); +const pb3 = p.then(() => Promise.resolve("1"), () => x); +const pb4 = p.then(() => Promise.resolve("1"), () => undefined); +const pb5 = p.then(() => Promise.resolve("1"), () => null); +const pb6 = p.then(() => Promise.resolve("1"), () => {}); +const pb7 = p.then(() => Promise.resolve("1"), () => {throw 1}); +const pb8 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); +const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); + +const pc0 = p.then(() => Promise.reject("1"), undefined); +const pc1 = p.then(() => Promise.reject("1"), null); +const pc2 = p.then(() => Promise.reject("1"), () => 1); +const pc3 = p.then(() => Promise.reject("1"), () => x); +const pc4 = p.then(() => Promise.reject("1"), () => undefined); +const pc5 = p.then(() => Promise.reject("1"), () => null); +const pc6 = p.then(() => Promise.reject("1"), () => {}); +const pc7 = p.then(() => Promise.reject("1"), () => {throw 1}); +const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1)); +const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1)); + //// [promiseType.js] var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { @@ -164,16 +228,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -const a = p.then(); -const b = p.then(b => 1); -const c = p.then(b => 1, e => 'error'); -const d = p.then(b => 1, e => { }); -const e = p.then(b => 1, e => { throw Error(); }); -const f = p.then(b => 1, e => Promise.reject(Error())); -const g = p.catch(e => 'error'); -const h = p.catch(e => { }); -const i = p.catch(e => { throw Error(); }); -const j = p.catch(e => Promise.reject(Error())); function A() { return __awaiter(this, void 0, void 0, function* () { const a = yield p; @@ -186,17 +240,17 @@ function B() { return 1; }); } -// NOTE: This reports a "No best comment type exists among return expressions." error, and is -// ignored to get the types result for the test. -// async function C() { -// try { -// const a = await p; -// return 1; -// } -// catch (e) { -// return 'error'; -// } -// } +function C() { + return __awaiter(this, void 0, void 0, function* () { + try { + const a = yield p; + return 1; + } + catch (e) { + return 'error'; + } + }); +} function D() { return __awaiter(this, void 0, void 0, function* () { try { @@ -264,53 +318,124 @@ function I() { } // addresses github issue #4903: const p00 = p.catch(); -const p01 = p.catch(undefined); -const p07 = p.catch(null); -const p02 = p.catch(() => 1); -const p03 = p.catch(() => { }); -const p04 = p.catch(() => { throw 1; }); -const p05 = p.catch(() => Promise.reject(1)); -const p06 = p.catch(() => Promise.resolve(1)); -const p10 = p.then(); +const p01 = p.then(); +const p10 = p.catch(undefined); +const p11 = p.catch(null); +const p12 = p.catch(() => 1); +const p13 = p.catch(() => x); +const p14 = p.catch(() => undefined); +const p15 = p.catch(() => null); +const p16 = p.catch(() => { }); +const p17 = p.catch(() => { throw 1; }); +const p18 = p.catch(() => Promise.reject(1)); +const p19 = p.catch(() => Promise.resolve(1)); const p20 = p.then(undefined); -const p21 = p.then(() => 1); -const p22 = p.then(() => { }); -const p23 = p.then(() => { throw 1; }); -const p24 = p.then(() => Promise.resolve(1)); -const p25 = p.then(() => Promise.reject(1)); +const p21 = p.then(null); +const p22 = p.then(() => 1); +const p23 = p.then(() => x); +const p24 = p.then(() => undefined); +const p25 = p.then(() => null); +const p26 = p.then(() => { }); +const p27 = p.then(() => { throw 1; }); +const p28 = p.then(() => Promise.resolve(1)); +const p29 = p.then(() => Promise.reject(1)); const p30 = p.then(undefined, undefined); -const p31 = p.then(undefined, () => 1); -const p32 = p.then(undefined, () => { }); -const p33 = p.then(undefined, () => { throw 1; }); -const p34 = p.then(undefined, () => Promise.resolve(1)); -const p35 = p.then(undefined, () => Promise.reject(1)); -const p40 = p.then(() => "1", undefined); -const p41 = p.then(() => "1", () => 1); -const p42 = p.then(() => "1", () => { }); -const p43 = p.then(() => "1", () => { throw 1; }); -const p44 = p.then(() => "1", () => Promise.resolve(1)); -const p45 = p.then(() => "1", () => Promise.reject(1)); -const p50 = p.then(() => { }, undefined); -const p51 = p.then(() => { }, () => 1); -const p52 = p.then(() => { }, () => { }); -const p53 = p.then(() => { }, () => { throw 1; }); -const p54 = p.then(() => { }, () => Promise.resolve(1)); -const p55 = p.then(() => { }, () => Promise.reject(1)); -const p60 = p.then(() => { throw 1; }, undefined); -const p61 = p.then(() => { throw 1; }, () => 1); -const p62 = p.then(() => { throw 1; }, () => { }); -const p63 = p.then(() => { throw 1; }, () => { throw 1; }); -const p64 = p.then(() => { throw 1; }, () => Promise.resolve(1)); -const p65 = p.then(() => { throw 1; }, () => Promise.reject(1)); -const p70 = p.then(() => Promise.resolve("1"), undefined); -const p71 = p.then(() => Promise.resolve("1"), () => 1); -const p72 = p.then(() => Promise.resolve("1"), () => { }); -const p73 = p.then(() => Promise.resolve("1"), () => { throw 1; }); -const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); -const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); -const p80 = p.then(() => Promise.reject(1), undefined); -const p81 = p.then(() => Promise.reject(1), () => 1); -const p82 = p.then(() => Promise.reject(1), () => { }); -const p83 = p.then(() => Promise.reject(1), () => { throw 1; }); -const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); -const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1)); +const p31 = p.then(undefined, null); +const p32 = p.then(undefined, () => 1); +const p33 = p.then(undefined, () => x); +const p34 = p.then(undefined, () => undefined); +const p35 = p.then(undefined, () => null); +const p36 = p.then(undefined, () => { }); +const p37 = p.then(undefined, () => { throw 1; }); +const p38 = p.then(undefined, () => Promise.resolve(1)); +const p39 = p.then(undefined, () => Promise.reject(1)); +const p40 = p.then(null, undefined); +const p41 = p.then(null, null); +const p42 = p.then(null, () => 1); +const p43 = p.then(null, () => x); +const p44 = p.then(null, () => undefined); +const p45 = p.then(null, () => null); +const p46 = p.then(null, () => { }); +const p47 = p.then(null, () => { throw 1; }); +const p48 = p.then(null, () => Promise.resolve(1)); +const p49 = p.then(null, () => Promise.reject(1)); +const p50 = p.then(() => "1", undefined); +const p51 = p.then(() => "1", null); +const p52 = p.then(() => "1", () => 1); +const p53 = p.then(() => "1", () => x); +const p54 = p.then(() => "1", () => undefined); +const p55 = p.then(() => "1", () => null); +const p56 = p.then(() => "1", () => { }); +const p57 = p.then(() => "1", () => { throw 1; }); +const p58 = p.then(() => "1", () => Promise.resolve(1)); +const p59 = p.then(() => "1", () => Promise.reject(1)); +const p60 = p.then(() => x, undefined); +const p61 = p.then(() => x, null); +const p62 = p.then(() => x, () => 1); +const p63 = p.then(() => x, () => x); +const p64 = p.then(() => x, () => undefined); +const p65 = p.then(() => x, () => null); +const p66 = p.then(() => x, () => { }); +const p67 = p.then(() => x, () => { throw 1; }); +const p68 = p.then(() => x, () => Promise.resolve(1)); +const p69 = p.then(() => x, () => Promise.reject(1)); +const p70 = p.then(() => undefined, undefined); +const p71 = p.then(() => undefined, null); +const p72 = p.then(() => undefined, () => 1); +const p73 = p.then(() => undefined, () => x); +const p74 = p.then(() => undefined, () => undefined); +const p75 = p.then(() => undefined, () => null); +const p76 = p.then(() => undefined, () => { }); +const p77 = p.then(() => undefined, () => { throw 1; }); +const p78 = p.then(() => undefined, () => Promise.resolve(1)); +const p79 = p.then(() => undefined, () => Promise.reject(1)); +const p80 = p.then(() => null, undefined); +const p81 = p.then(() => null, null); +const p82 = p.then(() => null, () => 1); +const p83 = p.then(() => null, () => x); +const p84 = p.then(() => null, () => undefined); +const p85 = p.then(() => null, () => null); +const p86 = p.then(() => null, () => { }); +const p87 = p.then(() => null, () => { throw 1; }); +const p88 = p.then(() => null, () => Promise.resolve(1)); +const p89 = p.then(() => null, () => Promise.reject(1)); +const p90 = p.then(() => { }, undefined); +const p91 = p.then(() => { }, null); +const p92 = p.then(() => { }, () => 1); +const p93 = p.then(() => { }, () => x); +const p94 = p.then(() => { }, () => undefined); +const p95 = p.then(() => { }, () => null); +const p96 = p.then(() => { }, () => { }); +const p97 = p.then(() => { }, () => { throw 1; }); +const p98 = p.then(() => { }, () => Promise.resolve(1)); +const p99 = p.then(() => { }, () => Promise.reject(1)); +const pa0 = p.then(() => { throw 1; }, undefined); +const pa1 = p.then(() => { throw 1; }, null); +const pa2 = p.then(() => { throw 1; }, () => 1); +const pa3 = p.then(() => { throw 1; }, () => x); +const pa4 = p.then(() => { throw 1; }, () => undefined); +const pa5 = p.then(() => { throw 1; }, () => null); +const pa6 = p.then(() => { throw 1; }, () => { }); +const pa7 = p.then(() => { throw 1; }, () => { throw 1; }); +const pa8 = p.then(() => { throw 1; }, () => Promise.resolve(1)); +const pa9 = p.then(() => { throw 1; }, () => Promise.reject(1)); +const pb0 = p.then(() => Promise.resolve("1"), undefined); +const pb1 = p.then(() => Promise.resolve("1"), null); +const pb2 = p.then(() => Promise.resolve("1"), () => 1); +const pb3 = p.then(() => Promise.resolve("1"), () => x); +const pb4 = p.then(() => Promise.resolve("1"), () => undefined); +const pb5 = p.then(() => Promise.resolve("1"), () => null); +const pb6 = p.then(() => Promise.resolve("1"), () => { }); +const pb7 = p.then(() => Promise.resolve("1"), () => { throw 1; }); +const pb8 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); +const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); +const pc0 = p.then(() => Promise.reject("1"), undefined); +const pc1 = p.then(() => Promise.reject("1"), null); +const pc2 = p.then(() => Promise.reject("1"), () => 1); +const pc3 = p.then(() => Promise.reject("1"), () => x); +const pc4 = p.then(() => Promise.reject("1"), () => undefined); +const pc5 = p.then(() => Promise.reject("1"), () => null); +const pc6 = p.then(() => Promise.reject("1"), () => { }); +const pc7 = p.then(() => Promise.reject("1"), () => { throw 1; }); +const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1)); +const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1)); diff --git a/tests/baselines/reference/promiseType.symbols b/tests/baselines/reference/promiseType.symbols index 845aed26d5e..5320a666413 100644 --- a/tests/baselines/reference/promiseType.symbols +++ b/tests/baselines/reference/promiseType.symbols @@ -1,151 +1,76 @@ === tests/cases/compiler/promiseType.ts === declare var p: Promise; >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) -const a = p.then(); ->a : Symbol(a, Decl(promiseType.ts, 2, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) - -const b = p.then(b => 1); ->b : Symbol(b, Decl(promiseType.ts, 3, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->b : Symbol(b, Decl(promiseType.ts, 3, 17)) - -const c = p.then(b => 1, e => 'error'); ->c : Symbol(c, Decl(promiseType.ts, 4, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->b : Symbol(b, Decl(promiseType.ts, 4, 17)) ->e : Symbol(e, Decl(promiseType.ts, 4, 24)) - -const d = p.then(b => 1, e => { }); ->d : Symbol(d, Decl(promiseType.ts, 5, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->b : Symbol(b, Decl(promiseType.ts, 5, 17)) ->e : Symbol(e, Decl(promiseType.ts, 5, 24)) - -const e = p.then(b => 1, e => { throw Error(); }); ->e : Symbol(e, Decl(promiseType.ts, 6, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->b : Symbol(b, Decl(promiseType.ts, 6, 17)) ->e : Symbol(e, Decl(promiseType.ts, 6, 24)) ->Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - -const f = p.then(b => 1, e => Promise.reject(Error())); ->f : Symbol(f, Decl(promiseType.ts, 7, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->b : Symbol(b, Decl(promiseType.ts, 7, 17)) ->e : Symbol(e, Decl(promiseType.ts, 7, 24)) ->Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - -const g = p.catch(e => 'error'); ->g : Symbol(g, Decl(promiseType.ts, 8, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->e : Symbol(e, Decl(promiseType.ts, 8, 18)) - -const h = p.catch(e => { }); ->h : Symbol(h, Decl(promiseType.ts, 9, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->e : Symbol(e, Decl(promiseType.ts, 9, 18)) - -const i = p.catch(e => { throw Error(); }); ->i : Symbol(i, Decl(promiseType.ts, 10, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->e : Symbol(e, Decl(promiseType.ts, 10, 18)) ->Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - -const j = p.catch(e => Promise.reject(Error())); ->j : Symbol(j, Decl(promiseType.ts, 11, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->e : Symbol(e, Decl(promiseType.ts, 11, 18)) ->Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +declare var x: any; +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) async function A() { ->A : Symbol(A, Decl(promiseType.ts, 11, 48)) +>A : Symbol(A, Decl(promiseType.ts, 1, 19)) const a = await p; ->a : Symbol(a, Decl(promiseType.ts, 14, 9)) +>a : Symbol(a, Decl(promiseType.ts, 4, 9)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) return a; ->a : Symbol(a, Decl(promiseType.ts, 14, 9)) +>a : Symbol(a, Decl(promiseType.ts, 4, 9)) } async function B() { ->B : Symbol(B, Decl(promiseType.ts, 16, 1)) +>B : Symbol(B, Decl(promiseType.ts, 6, 1)) const a = await p; ->a : Symbol(a, Decl(promiseType.ts, 19, 9)) +>a : Symbol(a, Decl(promiseType.ts, 9, 9)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) return 1; } -// NOTE: This reports a "No best comment type exists among return expressions." error, and is -// ignored to get the types result for the test. -// async function C() { -// try { -// const a = await p; -// return 1; -// } -// catch (e) { -// return 'error'; -// } -// } +async function C() { +>C : Symbol(C, Decl(promiseType.ts, 11, 1)) + + try { + const a = await p; +>a : Symbol(a, Decl(promiseType.ts, 15, 13)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) + + return 1; + } + catch (e) { +>e : Symbol(e, Decl(promiseType.ts, 18, 11)) + + return 'error'; + } +} async function D() { >D : Symbol(D, Decl(promiseType.ts, 21, 1)) try { const a = await p; ->a : Symbol(a, Decl(promiseType.ts, 37, 13)) +>a : Symbol(a, Decl(promiseType.ts, 25, 13)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) return 1; } catch (e) { ->e : Symbol(e, Decl(promiseType.ts, 40, 11)) +>e : Symbol(e, Decl(promiseType.ts, 28, 11)) } } async function E() { ->E : Symbol(E, Decl(promiseType.ts, 42, 1)) +>E : Symbol(E, Decl(promiseType.ts, 30, 1)) try { const a = await p; ->a : Symbol(a, Decl(promiseType.ts, 46, 13)) +>a : Symbol(a, Decl(promiseType.ts, 34, 13)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) return 1; } catch (e) { ->e : Symbol(e, Decl(promiseType.ts, 49, 11)) +>e : Symbol(e, Decl(promiseType.ts, 37, 11)) throw Error(); >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) @@ -153,57 +78,57 @@ async function E() { } async function F() { ->F : Symbol(F, Decl(promiseType.ts, 52, 1)) +>F : Symbol(F, Decl(promiseType.ts, 40, 1)) try { const a = await p; ->a : Symbol(a, Decl(promiseType.ts, 56, 13)) +>a : Symbol(a, Decl(promiseType.ts, 44, 13)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) return 1; } catch (e) { ->e : Symbol(e, Decl(promiseType.ts, 59, 11)) +>e : Symbol(e, Decl(promiseType.ts, 47, 11)) return Promise.reject(Error()); >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) } } async function G() { ->G : Symbol(G, Decl(promiseType.ts, 62, 1)) +>G : Symbol(G, Decl(promiseType.ts, 50, 1)) try { const a = await p; ->a : Symbol(a, Decl(promiseType.ts, 66, 13)) +>a : Symbol(a, Decl(promiseType.ts, 54, 13)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) return a; ->a : Symbol(a, Decl(promiseType.ts, 66, 13)) +>a : Symbol(a, Decl(promiseType.ts, 54, 13)) } catch (e) { ->e : Symbol(e, Decl(promiseType.ts, 69, 11)) +>e : Symbol(e, Decl(promiseType.ts, 57, 11)) return; } } async function H() { ->H : Symbol(H, Decl(promiseType.ts, 72, 1)) +>H : Symbol(H, Decl(promiseType.ts, 60, 1)) try { const a = await p; ->a : Symbol(a, Decl(promiseType.ts, 76, 13)) +>a : Symbol(a, Decl(promiseType.ts, 64, 13)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) return a; ->a : Symbol(a, Decl(promiseType.ts, 76, 13)) +>a : Symbol(a, Decl(promiseType.ts, 64, 13)) } catch (e) { ->e : Symbol(e, Decl(promiseType.ts, 79, 11)) +>e : Symbol(e, Decl(promiseType.ts, 67, 11)) throw Error(); >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) @@ -211,22 +136,22 @@ async function H() { } async function I() { ->I : Symbol(I, Decl(promiseType.ts, 82, 1)) +>I : Symbol(I, Decl(promiseType.ts, 70, 1)) try { const a = await p; ->a : Symbol(a, Decl(promiseType.ts, 86, 13)) +>a : Symbol(a, Decl(promiseType.ts, 74, 13)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) return a; ->a : Symbol(a, Decl(promiseType.ts, 86, 13)) +>a : Symbol(a, Decl(promiseType.ts, 74, 13)) } catch (e) { ->e : Symbol(e, Decl(promiseType.ts, 89, 11)) +>e : Symbol(e, Decl(promiseType.ts, 77, 11)) return Promise.reject(Error()); >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) } @@ -235,406 +160,932 @@ async function I() { // addresses github issue #4903: const p00 = p.catch(); ->p00 : Symbol(p00, Decl(promiseType.ts, 96, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p00 : Symbol(p00, Decl(promiseType.ts, 84, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) -const p01 = p.catch(undefined); ->p01 : Symbol(p01, Decl(promiseType.ts, 97, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p01 = p.then(); +>p01 : Symbol(p01, Decl(promiseType.ts, 85, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p10 = p.catch(undefined); +>p10 : Symbol(p10, Decl(promiseType.ts, 87, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) -const p07 = p.catch(null); ->p07 : Symbol(p07, Decl(promiseType.ts, 98, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p11 = p.catch(null); +>p11 : Symbol(p11, Decl(promiseType.ts, 88, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) -const p02 = p.catch(() => 1); ->p02 : Symbol(p02, Decl(promiseType.ts, 99, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p12 = p.catch(() => 1); +>p12 : Symbol(p12, Decl(promiseType.ts, 89, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) -const p03 = p.catch(() => {}); ->p03 : Symbol(p03, Decl(promiseType.ts, 100, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p13 = p.catch(() => x); +>p13 : Symbol(p13, Decl(promiseType.ts, 90, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) -const p04 = p.catch(() => {throw 1}); ->p04 : Symbol(p04, Decl(promiseType.ts, 101, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p14 = p.catch(() => undefined); +>p14 : Symbol(p14, Decl(promiseType.ts, 91, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) -const p05 = p.catch(() => Promise.reject(1)); ->p05 : Symbol(p05, Decl(promiseType.ts, 102, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p15 = p.catch(() => null); +>p15 : Symbol(p15, Decl(promiseType.ts, 92, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) + +const p16 = p.catch(() => {}); +>p16 : Symbol(p16, Decl(promiseType.ts, 93, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) + +const p17 = p.catch(() => {throw 1}); +>p17 : Symbol(p17, Decl(promiseType.ts, 94, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) + +const p18 = p.catch(() => Promise.reject(1)); +>p18 : Symbol(p18, Decl(promiseType.ts, 95, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p06 = p.catch(() => Promise.resolve(1)); ->p06 : Symbol(p06, Decl(promiseType.ts, 103, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p19 = p.catch(() => Promise.resolve(1)); +>p19 : Symbol(p19, Decl(promiseType.ts, 96, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p10 = p.then(); ->p10 : Symbol(p10, Decl(promiseType.ts, 105, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) - const p20 = p.then(undefined); ->p20 : Symbol(p20, Decl(promiseType.ts, 107, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p20 : Symbol(p20, Decl(promiseType.ts, 98, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) -const p21 = p.then(() => 1); ->p21 : Symbol(p21, Decl(promiseType.ts, 108, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p21 = p.then(null); +>p21 : Symbol(p21, Decl(promiseType.ts, 99, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) -const p22 = p.then(() => {}); ->p22 : Symbol(p22, Decl(promiseType.ts, 109, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p22 = p.then(() => 1); +>p22 : Symbol(p22, Decl(promiseType.ts, 100, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) -const p23 = p.then(() => {throw 1}); ->p23 : Symbol(p23, Decl(promiseType.ts, 110, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p23 = p.then(() => x); +>p23 : Symbol(p23, Decl(promiseType.ts, 101, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) -const p24 = p.then(() => Promise.resolve(1)); ->p24 : Symbol(p24, Decl(promiseType.ts, 111, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p24 = p.then(() => undefined); +>p24 : Symbol(p24, Decl(promiseType.ts, 102, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p25 = p.then(() => null); +>p25 : Symbol(p25, Decl(promiseType.ts, 103, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p26 = p.then(() => {}); +>p26 : Symbol(p26, Decl(promiseType.ts, 104, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p27 = p.then(() => {throw 1}); +>p27 : Symbol(p27, Decl(promiseType.ts, 105, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p28 = p.then(() => Promise.resolve(1)); +>p28 : Symbol(p28, Decl(promiseType.ts, 106, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p25 = p.then(() => Promise.reject(1)); ->p25 : Symbol(p25, Decl(promiseType.ts, 112, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p29 = p.then(() => Promise.reject(1)); +>p29 : Symbol(p29, Decl(promiseType.ts, 107, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) const p30 = p.then(undefined, undefined); ->p30 : Symbol(p30, Decl(promiseType.ts, 114, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p30 : Symbol(p30, Decl(promiseType.ts, 109, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) >undefined : Symbol(undefined) -const p31 = p.then(undefined, () => 1); ->p31 : Symbol(p31, Decl(promiseType.ts, 115, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p31 = p.then(undefined, null); +>p31 : Symbol(p31, Decl(promiseType.ts, 110, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) -const p32 = p.then(undefined, () => {}); ->p32 : Symbol(p32, Decl(promiseType.ts, 116, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p32 = p.then(undefined, () => 1); +>p32 : Symbol(p32, Decl(promiseType.ts, 111, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) -const p33 = p.then(undefined, () => {throw 1}); ->p33 : Symbol(p33, Decl(promiseType.ts, 117, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p33 = p.then(undefined, () => x); +>p33 : Symbol(p33, Decl(promiseType.ts, 112, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) + +const p34 = p.then(undefined, () => undefined); +>p34 : Symbol(p34, Decl(promiseType.ts, 113, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) >undefined : Symbol(undefined) -const p34 = p.then(undefined, () => Promise.resolve(1)); ->p34 : Symbol(p34, Decl(promiseType.ts, 118, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p35 = p.then(undefined, () => null); +>p35 : Symbol(p35, Decl(promiseType.ts, 114, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p36 = p.then(undefined, () => {}); +>p36 : Symbol(p36, Decl(promiseType.ts, 115, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p37 = p.then(undefined, () => {throw 1}); +>p37 : Symbol(p37, Decl(promiseType.ts, 116, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p38 = p.then(undefined, () => Promise.resolve(1)); +>p38 : Symbol(p38, Decl(promiseType.ts, 117, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p35 = p.then(undefined, () => Promise.reject(1)); ->p35 : Symbol(p35, Decl(promiseType.ts, 119, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p39 = p.then(undefined, () => Promise.reject(1)); +>p39 : Symbol(p39, Decl(promiseType.ts, 118, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p40 = p.then(() => "1", undefined); ->p40 : Symbol(p40, Decl(promiseType.ts, 121, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p40 = p.then(null, undefined); +>p40 : Symbol(p40, Decl(promiseType.ts, 120, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) -const p41 = p.then(() => "1", () => 1); ->p41 : Symbol(p41, Decl(promiseType.ts, 122, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p41 = p.then(null, null); +>p41 : Symbol(p41, Decl(promiseType.ts, 121, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) -const p42 = p.then(() => "1", () => {}); ->p42 : Symbol(p42, Decl(promiseType.ts, 123, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p42 = p.then(null, () => 1); +>p42 : Symbol(p42, Decl(promiseType.ts, 122, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) -const p43 = p.then(() => "1", () => {throw 1}); ->p43 : Symbol(p43, Decl(promiseType.ts, 124, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p43 = p.then(null, () => x); +>p43 : Symbol(p43, Decl(promiseType.ts, 123, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) -const p44 = p.then(() => "1", () => Promise.resolve(1)); ->p44 : Symbol(p44, Decl(promiseType.ts, 125, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p44 = p.then(null, () => undefined); +>p44 : Symbol(p44, Decl(promiseType.ts, 124, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p45 = p.then(null, () => null); +>p45 : Symbol(p45, Decl(promiseType.ts, 125, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p46 = p.then(null, () => {}); +>p46 : Symbol(p46, Decl(promiseType.ts, 126, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p47 = p.then(null, () => {throw 1}); +>p47 : Symbol(p47, Decl(promiseType.ts, 127, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p48 = p.then(null, () => Promise.resolve(1)); +>p48 : Symbol(p48, Decl(promiseType.ts, 128, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p45 = p.then(() => "1", () => Promise.reject(1)); ->p45 : Symbol(p45, Decl(promiseType.ts, 126, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p49 = p.then(null, () => Promise.reject(1)); +>p49 : Symbol(p49, Decl(promiseType.ts, 129, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p50 = p.then(() => {}, undefined); ->p50 : Symbol(p50, Decl(promiseType.ts, 128, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p50 = p.then(() => "1", undefined); +>p50 : Symbol(p50, Decl(promiseType.ts, 131, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) -const p51 = p.then(() => {}, () => 1); ->p51 : Symbol(p51, Decl(promiseType.ts, 129, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p51 = p.then(() => "1", null); +>p51 : Symbol(p51, Decl(promiseType.ts, 132, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) -const p52 = p.then(() => {}, () => {}); ->p52 : Symbol(p52, Decl(promiseType.ts, 130, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p52 = p.then(() => "1", () => 1); +>p52 : Symbol(p52, Decl(promiseType.ts, 133, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) -const p53 = p.then(() => {}, () => {throw 1}); ->p53 : Symbol(p53, Decl(promiseType.ts, 131, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p53 = p.then(() => "1", () => x); +>p53 : Symbol(p53, Decl(promiseType.ts, 134, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) -const p54 = p.then(() => {}, () => Promise.resolve(1)); ->p54 : Symbol(p54, Decl(promiseType.ts, 132, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p54 = p.then(() => "1", () => undefined); +>p54 : Symbol(p54, Decl(promiseType.ts, 135, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) - -const p55 = p.then(() => {}, () => Promise.reject(1)); ->p55 : Symbol(p55, Decl(promiseType.ts, 133, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) - -const p60 = p.then(() => {throw 1}, undefined); ->p60 : Symbol(p60, Decl(promiseType.ts, 135, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) -const p61 = p.then(() => {throw 1}, () => 1); ->p61 : Symbol(p61, Decl(promiseType.ts, 136, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p55 = p.then(() => "1", () => null); +>p55 : Symbol(p55, Decl(promiseType.ts, 136, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) -const p62 = p.then(() => {throw 1}, () => {}); ->p62 : Symbol(p62, Decl(promiseType.ts, 137, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p56 = p.then(() => "1", () => {}); +>p56 : Symbol(p56, Decl(promiseType.ts, 137, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) -const p63 = p.then(() => {throw 1}, () => {throw 1}); ->p63 : Symbol(p63, Decl(promiseType.ts, 138, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p57 = p.then(() => "1", () => {throw 1}); +>p57 : Symbol(p57, Decl(promiseType.ts, 138, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) -const p64 = p.then(() => {throw 1}, () => Promise.resolve(1)); ->p64 : Symbol(p64, Decl(promiseType.ts, 139, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p58 = p.then(() => "1", () => Promise.resolve(1)); +>p58 : Symbol(p58, Decl(promiseType.ts, 139, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p65 = p.then(() => {throw 1}, () => Promise.reject(1)); ->p65 : Symbol(p65, Decl(promiseType.ts, 140, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p59 = p.then(() => "1", () => Promise.reject(1)); +>p59 : Symbol(p59, Decl(promiseType.ts, 140, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p70 = p.then(() => Promise.resolve("1"), undefined); ->p70 : Symbol(p70, Decl(promiseType.ts, 142, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p60 = p.then(() => x, undefined); +>p60 : Symbol(p60, Decl(promiseType.ts, 142, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) +>undefined : Symbol(undefined) + +const p61 = p.then(() => x, null); +>p61 : Symbol(p61, Decl(promiseType.ts, 143, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) + +const p62 = p.then(() => x, () => 1); +>p62 : Symbol(p62, Decl(promiseType.ts, 144, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) + +const p63 = p.then(() => x, () => x); +>p63 : Symbol(p63, Decl(promiseType.ts, 145, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) + +const p64 = p.then(() => x, () => undefined); +>p64 : Symbol(p64, Decl(promiseType.ts, 146, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) +>undefined : Symbol(undefined) + +const p65 = p.then(() => x, () => null); +>p65 : Symbol(p65, Decl(promiseType.ts, 147, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) + +const p66 = p.then(() => x, () => {}); +>p66 : Symbol(p66, Decl(promiseType.ts, 148, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) + +const p67 = p.then(() => x, () => {throw 1}); +>p67 : Symbol(p67, Decl(promiseType.ts, 149, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) + +const p68 = p.then(() => x, () => Promise.resolve(1)); +>p68 : Symbol(p68, Decl(promiseType.ts, 150, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p69 = p.then(() => x, () => Promise.reject(1)); +>p69 : Symbol(p69, Decl(promiseType.ts, 151, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p70 = p.then(() => undefined, undefined); +>p70 : Symbol(p70, Decl(promiseType.ts, 153, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +const p71 = p.then(() => undefined, null); +>p71 : Symbol(p71, Decl(promiseType.ts, 154, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p72 = p.then(() => undefined, () => 1); +>p72 : Symbol(p72, Decl(promiseType.ts, 155, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p73 = p.then(() => undefined, () => x); +>p73 : Symbol(p73, Decl(promiseType.ts, 156, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) + +const p74 = p.then(() => undefined, () => undefined); +>p74 : Symbol(p74, Decl(promiseType.ts, 157, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +const p75 = p.then(() => undefined, () => null); +>p75 : Symbol(p75, Decl(promiseType.ts, 158, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p76 = p.then(() => undefined, () => {}); +>p76 : Symbol(p76, Decl(promiseType.ts, 159, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p77 = p.then(() => undefined, () => {throw 1}); +>p77 : Symbol(p77, Decl(promiseType.ts, 160, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p78 = p.then(() => undefined, () => Promise.resolve(1)); +>p78 : Symbol(p78, Decl(promiseType.ts, 161, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p79 = p.then(() => undefined, () => Promise.reject(1)); +>p79 : Symbol(p79, Decl(promiseType.ts, 162, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p80 = p.then(() => null, undefined); +>p80 : Symbol(p80, Decl(promiseType.ts, 164, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p81 = p.then(() => null, null); +>p81 : Symbol(p81, Decl(promiseType.ts, 165, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p82 = p.then(() => null, () => 1); +>p82 : Symbol(p82, Decl(promiseType.ts, 166, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p83 = p.then(() => null, () => x); +>p83 : Symbol(p83, Decl(promiseType.ts, 167, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) + +const p84 = p.then(() => null, () => undefined); +>p84 : Symbol(p84, Decl(promiseType.ts, 168, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p85 = p.then(() => null, () => null); +>p85 : Symbol(p85, Decl(promiseType.ts, 169, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p86 = p.then(() => null, () => {}); +>p86 : Symbol(p86, Decl(promiseType.ts, 170, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p87 = p.then(() => null, () => {throw 1}); +>p87 : Symbol(p87, Decl(promiseType.ts, 171, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p88 = p.then(() => null, () => Promise.resolve(1)); +>p88 : Symbol(p88, Decl(promiseType.ts, 172, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p89 = p.then(() => null, () => Promise.reject(1)); +>p89 : Symbol(p89, Decl(promiseType.ts, 173, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p90 = p.then(() => {}, undefined); +>p90 : Symbol(p90, Decl(promiseType.ts, 175, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p91 = p.then(() => {}, null); +>p91 : Symbol(p91, Decl(promiseType.ts, 176, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p92 = p.then(() => {}, () => 1); +>p92 : Symbol(p92, Decl(promiseType.ts, 177, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p93 = p.then(() => {}, () => x); +>p93 : Symbol(p93, Decl(promiseType.ts, 178, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) + +const p94 = p.then(() => {}, () => undefined); +>p94 : Symbol(p94, Decl(promiseType.ts, 179, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p95 = p.then(() => {}, () => null); +>p95 : Symbol(p95, Decl(promiseType.ts, 180, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p96 = p.then(() => {}, () => {}); +>p96 : Symbol(p96, Decl(promiseType.ts, 181, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p97 = p.then(() => {}, () => {throw 1}); +>p97 : Symbol(p97, Decl(promiseType.ts, 182, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p98 = p.then(() => {}, () => Promise.resolve(1)); +>p98 : Symbol(p98, Decl(promiseType.ts, 183, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p99 = p.then(() => {}, () => Promise.reject(1)); +>p99 : Symbol(p99, Decl(promiseType.ts, 184, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const pa0 = p.then(() => {throw 1}, undefined); +>pa0 : Symbol(pa0, Decl(promiseType.ts, 186, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const pa1 = p.then(() => {throw 1}, null); +>pa1 : Symbol(pa1, Decl(promiseType.ts, 187, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const pa2 = p.then(() => {throw 1}, () => 1); +>pa2 : Symbol(pa2, Decl(promiseType.ts, 188, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const pa3 = p.then(() => {throw 1}, () => x); +>pa3 : Symbol(pa3, Decl(promiseType.ts, 189, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) + +const pa4 = p.then(() => {throw 1}, () => undefined); +>pa4 : Symbol(pa4, Decl(promiseType.ts, 190, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const pa5 = p.then(() => {throw 1}, () => null); +>pa5 : Symbol(pa5, Decl(promiseType.ts, 191, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const pa6 = p.then(() => {throw 1}, () => {}); +>pa6 : Symbol(pa6, Decl(promiseType.ts, 192, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const pa7 = p.then(() => {throw 1}, () => {throw 1}); +>pa7 : Symbol(pa7, Decl(promiseType.ts, 193, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const pa8 = p.then(() => {throw 1}, () => Promise.resolve(1)); +>pa8 : Symbol(pa8, Decl(promiseType.ts, 194, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const pa9 = p.then(() => {throw 1}, () => Promise.reject(1)); +>pa9 : Symbol(pa9, Decl(promiseType.ts, 195, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const pb0 = p.then(() => Promise.resolve("1"), undefined); +>pb0 : Symbol(pb0, Decl(promiseType.ts, 197, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >undefined : Symbol(undefined) -const p71 = p.then(() => Promise.resolve("1"), () => 1); ->p71 : Symbol(p71, Decl(promiseType.ts, 143, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pb1 = p.then(() => Promise.resolve("1"), null); +>pb1 : Symbol(pb1, Decl(promiseType.ts, 198, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p72 = p.then(() => Promise.resolve("1"), () => {}); ->p72 : Symbol(p72, Decl(promiseType.ts, 144, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pb2 = p.then(() => Promise.resolve("1"), () => 1); +>pb2 : Symbol(pb2, Decl(promiseType.ts, 199, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p73 = p.then(() => Promise.resolve("1"), () => {throw 1}); ->p73 : Symbol(p73, Decl(promiseType.ts, 145, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pb3 = p.then(() => Promise.resolve("1"), () => x); +>pb3 : Symbol(pb3, Decl(promiseType.ts, 200, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) + +const pb4 = p.then(() => Promise.resolve("1"), () => undefined); +>pb4 : Symbol(pb4, Decl(promiseType.ts, 201, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const pb5 = p.then(() => Promise.resolve("1"), () => null); +>pb5 : Symbol(pb5, Decl(promiseType.ts, 202, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); ->p74 : Symbol(p74, Decl(promiseType.ts, 146, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pb6 = p.then(() => Promise.resolve("1"), () => {}); +>pb6 : Symbol(pb6, Decl(promiseType.ts, 203, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); ->p75 : Symbol(p75, Decl(promiseType.ts, 147, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pb7 = p.then(() => Promise.resolve("1"), () => {throw 1}); +>pb7 : Symbol(pb7, Decl(promiseType.ts, 204, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const pb8 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); +>pb8 : Symbol(pb8, Decl(promiseType.ts, 205, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); +>pb9 : Symbol(pb9, Decl(promiseType.ts, 206, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p80 = p.then(() => Promise.reject(1), undefined); ->p80 : Symbol(p80, Decl(promiseType.ts, 149, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pc0 = p.then(() => Promise.reject("1"), undefined); +>pc0 : Symbol(pc0, Decl(promiseType.ts, 208, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >undefined : Symbol(undefined) -const p81 = p.then(() => Promise.reject(1), () => 1); ->p81 : Symbol(p81, Decl(promiseType.ts, 150, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pc1 = p.then(() => Promise.reject("1"), null); +>pc1 : Symbol(pc1, Decl(promiseType.ts, 209, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p82 = p.then(() => Promise.reject(1), () => {}); ->p82 : Symbol(p82, Decl(promiseType.ts, 151, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pc2 = p.then(() => Promise.reject("1"), () => 1); +>pc2 : Symbol(pc2, Decl(promiseType.ts, 210, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p83 = p.then(() => Promise.reject(1), () => {throw 1}); ->p83 : Symbol(p83, Decl(promiseType.ts, 152, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pc3 = p.then(() => Promise.reject("1"), () => x); +>pc3 : Symbol(pc3, Decl(promiseType.ts, 211, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>x : Symbol(x, Decl(promiseType.ts, 1, 11)) + +const pc4 = p.then(() => Promise.reject("1"), () => undefined); +>pc4 : Symbol(pc4, Decl(promiseType.ts, 212, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const pc5 = p.then(() => Promise.reject("1"), () => null); +>pc5 : Symbol(pc5, Decl(promiseType.ts, 213, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); ->p84 : Symbol(p84, Decl(promiseType.ts, 153, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pc6 = p.then(() => Promise.reject("1"), () => {}); +>pc6 : Symbol(pc6, Decl(promiseType.ts, 214, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const pc7 = p.then(() => Promise.reject("1"), () => {throw 1}); +>pc7 : Symbol(pc7, Decl(promiseType.ts, 215, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1)); +>pc8 : Symbol(pc8, Decl(promiseType.ts, 216, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1)); ->p85 : Symbol(p85, Decl(promiseType.ts, 154, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1)); +>pc9 : Symbol(pc9, Decl(promiseType.ts, 217, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) diff --git a/tests/baselines/reference/promiseType.types b/tests/baselines/reference/promiseType.types index 3d055f73f0a..3228d266319 100644 --- a/tests/baselines/reference/promiseType.types +++ b/tests/baselines/reference/promiseType.types @@ -3,124 +3,8 @@ declare var p: Promise; >p : Promise >Promise : Promise -const a = p.then(); ->a : Promise ->p.then() : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } - -const b = p.then(b => 1); ->b : Promise<1> ->p.then(b => 1) : Promise<1> ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->b => 1 : (b: boolean) => 1 ->b : boolean ->1 : 1 - -const c = p.then(b => 1, e => 'error'); ->c : Promise ->p.then(b => 1, e => 'error') : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->b => 1 : (b: boolean) => 1 ->b : boolean ->1 : 1 ->e => 'error' : (e: any) => string ->e : any ->'error' : "error" - -const d = p.then(b => 1, e => { }); ->d : Promise ->p.then(b => 1, e => { }) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->b => 1 : (b: boolean) => 1 ->b : boolean ->1 : 1 ->e => { } : (e: any) => void ->e : any - -const e = p.then(b => 1, e => { throw Error(); }); ->e : Promise<1> ->p.then(b => 1, e => { throw Error(); }) : Promise<1> ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->b => 1 : (b: boolean) => 1 ->b : boolean ->1 : 1 ->e => { throw Error(); } : (e: any) => never ->e : any ->Error() : Error ->Error : ErrorConstructor - -const f = p.then(b => 1, e => Promise.reject(Error())); ->f : Promise<1> ->p.then(b => 1, e => Promise.reject(Error())) : Promise<1> ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->b => 1 : (b: boolean) => 1 ->b : boolean ->1 : 1 ->e => Promise.reject(Error()) : (e: any) => Promise ->e : any ->Promise.reject(Error()) : Promise ->Promise.reject : { (reason: any): Promise; (reason: any): Promise; } ->Promise : PromiseConstructor ->reject : { (reason: any): Promise; (reason: any): Promise; } ->Error() : Error ->Error : ErrorConstructor - -const g = p.catch(e => 'error'); ->g : Promise ->p.catch(e => 'error') : Promise ->p.catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } ->p : Promise ->catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } ->e => 'error' : (e: any) => "error" ->e : any ->'error' : "error" - -const h = p.catch(e => { }); ->h : Promise ->p.catch(e => { }) : Promise ->p.catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } ->p : Promise ->catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } ->e => { } : (e: any) => void ->e : any - -const i = p.catch(e => { throw Error(); }); ->i : Promise ->p.catch(e => { throw Error(); }) : Promise ->p.catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } ->p : Promise ->catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } ->e => { throw Error(); } : (e: any) => never ->e : any ->Error() : Error ->Error : ErrorConstructor - -const j = p.catch(e => Promise.reject(Error())); ->j : Promise ->p.catch(e => Promise.reject(Error())) : Promise ->p.catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } ->p : Promise ->catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } ->e => Promise.reject(Error()) : (e: any) => Promise ->e : any ->Promise.reject(Error()) : Promise ->Promise.reject : { (reason: any): Promise; (reason: any): Promise; } ->Promise : PromiseConstructor ->reject : { (reason: any): Promise; (reason: any): Promise; } ->Error() : Error ->Error : ErrorConstructor +declare var x: any; +>x : any async function A() { >A : () => Promise @@ -146,17 +30,25 @@ async function B() { >1 : 1 } -// NOTE: This reports a "No best comment type exists among return expressions." error, and is -// ignored to get the types result for the test. -// async function C() { -// try { -// const a = await p; -// return 1; -// } -// catch (e) { -// return 'error'; -// } -// } +async function C() { +>C : () => Promise<1 | "error"> + + try { + const a = await p; +>a : boolean +>await p : boolean +>p : Promise + + return 1; +>1 : 1 + } + catch (e) { +>e : any + + return 'error'; +>'error' : "error" + } +} async function D() { >D : () => Promise @@ -291,58 +183,92 @@ async function I() { const p00 = p.catch(); >p00 : Promise >p.catch() : Promise ->p.catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p.catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise >p : Promise ->catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise -const p01 = p.catch(undefined); +const p01 = p.then(); >p01 : Promise ->p.catch(undefined) : Promise ->p.catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p.then() : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise + +const p10 = p.catch(undefined); +>p10 : Promise +>p.catch(undefined) : Promise +>p.catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise +>p : Promise +>catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise >undefined : undefined -const p07 = p.catch(null); ->p07 : Promise +const p11 = p.catch(null); +>p11 : Promise >p.catch(null) : Promise ->p.catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p.catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise >p : Promise ->catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise >null : null -const p02 = p.catch(() => 1); ->p02 : Promise ->p.catch(() => 1) : Promise ->p.catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +const p12 = p.catch(() => 1); +>p12 : Promise +>p.catch(() => 1) : Promise +>p.catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise >p : Promise ->catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } ->() => 1 : () => 1 +>catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise +>() => 1 : () => number >1 : 1 -const p03 = p.catch(() => {}); ->p03 : Promise ->p.catch(() => {}) : Promise ->p.catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +const p13 = p.catch(() => x); +>p13 : Promise +>p.catch(() => x) : Promise +>p.catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise >p : Promise ->catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise +>() => x : () => any +>x : any + +const p14 = p.catch(() => undefined); +>p14 : Promise +>p.catch(() => undefined) : Promise +>p.catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise +>p : Promise +>catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise +>() => undefined : () => any +>undefined : undefined + +const p15 = p.catch(() => null); +>p15 : Promise +>p.catch(() => null) : Promise +>p.catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise +>p : Promise +>catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise +>() => null : () => any +>null : null + +const p16 = p.catch(() => {}); +>p16 : Promise +>p.catch(() => {}) : Promise +>p.catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise +>p : Promise +>catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise >() => {} : () => void -const p04 = p.catch(() => {throw 1}); ->p04 : Promise +const p17 = p.catch(() => {throw 1}); +>p17 : Promise >p.catch(() => {throw 1}) : Promise ->p.catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p.catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise >p : Promise ->catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise >() => {throw 1} : () => never >1 : 1 -const p05 = p.catch(() => Promise.reject(1)); ->p05 : Promise +const p18 = p.catch(() => Promise.reject(1)); +>p18 : Promise >p.catch(() => Promise.reject(1)) : Promise ->p.catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p.catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise >p : Promise ->catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise >() => Promise.reject(1) : () => Promise >Promise.reject(1) : Promise >Promise.reject : { (reason: any): Promise; (reason: any): Promise; } @@ -350,12 +276,12 @@ const p05 = p.catch(() => Promise.reject(1)); >reject : { (reason: any): Promise; (reason: any): Promise; } >1 : 1 -const p06 = p.catch(() => Promise.resolve(1)); ->p06 : Promise +const p19 = p.catch(() => Promise.resolve(1)); +>p19 : Promise >p.catch(() => Promise.resolve(1)) : Promise ->p.catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p.catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise >p : Promise ->catch : { (onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } @@ -363,53 +289,81 @@ const p06 = p.catch(() => Promise.resolve(1)); >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >1 : 1 -const p10 = p.then(); ->p10 : Promise ->p.then() : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } - const p20 = p.then(undefined); >p20 : Promise >p.then(undefined) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >undefined : undefined -const p21 = p.then(() => 1); ->p21 : Promise<1> ->p.then(() => 1) : Promise<1> ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p21 = p.then(null); +>p21 : Promise +>p.then(null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => 1 : () => 1 +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>null : null + +const p22 = p.then(() => 1); +>p22 : Promise +>p.then(() => 1) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => 1 : () => number >1 : 1 -const p22 = p.then(() => {}); ->p22 : Promise ->p.then(() => {}) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p23 = p.then(() => x); +>p23 : Promise +>p.then(() => x) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => x : () => any +>x : any + +const p24 = p.then(() => undefined); +>p24 : Promise +>p.then(() => undefined) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => undefined : () => any +>undefined : undefined + +const p25 = p.then(() => null); +>p25 : Promise +>p.then(() => null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => null : () => any +>null : null + +const p26 = p.then(() => {}); +>p26 : Promise +>p.then(() => {}) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => {} : () => void -const p23 = p.then(() => {throw 1}); ->p23 : Promise ->p.then(() => {throw 1}) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p27 = p.then(() => {throw 1}); +>p27 : Promise +>p.then(() => {throw 1}) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => {throw 1} : () => never >1 : 1 -const p24 = p.then(() => Promise.resolve(1)); ->p24 : Promise +const p28 = p.then(() => Promise.resolve(1)); +>p28 : Promise >p.then(() => Promise.resolve(1)) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } @@ -417,12 +371,12 @@ const p24 = p.then(() => Promise.resolve(1)); >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >1 : 1 -const p25 = p.then(() => Promise.reject(1)); ->p25 : Promise ->p.then(() => Promise.reject(1)) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p29 = p.then(() => Promise.reject(1)); +>p29 : Promise +>p.then(() => Promise.reject(1)) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => Promise.reject(1) : () => Promise >Promise.reject(1) : Promise >Promise.reject : { (reason: any): Promise; (reason: any): Promise; } @@ -433,47 +387,86 @@ const p25 = p.then(() => Promise.reject(1)); const p30 = p.then(undefined, undefined); >p30 : Promise >p.then(undefined, undefined) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >undefined : undefined >undefined : undefined -const p31 = p.then(undefined, () => 1); ->p31 : Promise ->p.then(undefined, () => 1) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p31 = p.then(undefined, null); +>p31 : Promise +>p.then(undefined, null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >undefined : undefined ->() => 1 : () => 1 +>null : null + +const p32 = p.then(undefined, () => 1); +>p32 : Promise +>p.then(undefined, () => 1) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>undefined : undefined +>() => 1 : () => number >1 : 1 -const p32 = p.then(undefined, () => {}); ->p32 : Promise +const p33 = p.then(undefined, () => x); +>p33 : Promise +>p.then(undefined, () => x) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>undefined : undefined +>() => x : () => any +>x : any + +const p34 = p.then(undefined, () => undefined); +>p34 : Promise +>p.then(undefined, () => undefined) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>undefined : undefined +>() => undefined : () => any +>undefined : undefined + +const p35 = p.then(undefined, () => null); +>p35 : Promise +>p.then(undefined, () => null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>undefined : undefined +>() => null : () => any +>null : null + +const p36 = p.then(undefined, () => {}); +>p36 : Promise >p.then(undefined, () => {}) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >undefined : undefined >() => {} : () => void -const p33 = p.then(undefined, () => {throw 1}); ->p33 : Promise +const p37 = p.then(undefined, () => {throw 1}); +>p37 : Promise >p.then(undefined, () => {throw 1}) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >undefined : undefined >() => {throw 1} : () => never >1 : 1 -const p34 = p.then(undefined, () => Promise.resolve(1)); ->p34 : Promise +const p38 = p.then(undefined, () => Promise.resolve(1)); +>p38 : Promise >p.then(undefined, () => Promise.resolve(1)) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >undefined : undefined >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise @@ -482,12 +475,12 @@ const p34 = p.then(undefined, () => Promise.resolve(1)); >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >1 : 1 -const p35 = p.then(undefined, () => Promise.reject(1)); ->p35 : Promise +const p39 = p.then(undefined, () => Promise.reject(1)); +>p39 : Promise >p.then(undefined, () => Promise.reject(1)) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >undefined : undefined >() => Promise.reject(1) : () => Promise >Promise.reject(1) : Promise @@ -496,55 +489,203 @@ const p35 = p.then(undefined, () => Promise.reject(1)); >reject : { (reason: any): Promise; (reason: any): Promise; } >1 : 1 -const p40 = p.then(() => "1", undefined); ->p40 : Promise<"1"> ->p.then(() => "1", undefined) : Promise<"1"> ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p40 = p.then(null, undefined); +>p40 : Promise +>p.then(null, undefined) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => "1" : () => "1" +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>null : null +>undefined : undefined + +const p41 = p.then(null, null); +>p41 : Promise +>p.then(null, null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>null : null +>null : null + +const p42 = p.then(null, () => 1); +>p42 : Promise +>p.then(null, () => 1) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>null : null +>() => 1 : () => number +>1 : 1 + +const p43 = p.then(null, () => x); +>p43 : Promise +>p.then(null, () => x) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>null : null +>() => x : () => any +>x : any + +const p44 = p.then(null, () => undefined); +>p44 : Promise +>p.then(null, () => undefined) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>null : null +>() => undefined : () => any +>undefined : undefined + +const p45 = p.then(null, () => null); +>p45 : Promise +>p.then(null, () => null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>null : null +>() => null : () => any +>null : null + +const p46 = p.then(null, () => {}); +>p46 : Promise +>p.then(null, () => {}) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>null : null +>() => {} : () => void + +const p47 = p.then(null, () => {throw 1}); +>p47 : Promise +>p.then(null, () => {throw 1}) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>null : null +>() => {throw 1} : () => never +>1 : 1 + +const p48 = p.then(null, () => Promise.resolve(1)); +>p48 : Promise +>p.then(null, () => Promise.resolve(1)) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>null : null +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : 1 + +const p49 = p.then(null, () => Promise.reject(1)); +>p49 : Promise +>p.then(null, () => Promise.reject(1)) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>null : null +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : 1 + +const p50 = p.then(() => "1", undefined); +>p50 : Promise +>p.then(() => "1", undefined) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => "1" : () => string >"1" : "1" >undefined : undefined -const p41 = p.then(() => "1", () => 1); ->p41 : Promise ->p.then(() => "1", () => 1) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p51 = p.then(() => "1", null); +>p51 : Promise +>p.then(() => "1", null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => "1" : () => "1" +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => "1" : () => string +>"1" : "1" +>null : null + +const p52 = p.then(() => "1", () => 1); +>p52 : Promise +>p.then(() => "1", () => 1) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => "1" : () => string >"1" : "1" >() => 1 : () => number >1 : 1 -const p42 = p.then(() => "1", () => {}); ->p42 : Promise ->p.then(() => "1", () => {}) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p53 = p.then(() => "1", () => x); +>p53 : Promise +>p.then(() => "1", () => x) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => "1" : () => "1" +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => "1" : () => string +>"1" : "1" +>() => x : () => any +>x : any + +const p54 = p.then(() => "1", () => undefined); +>p54 : Promise +>p.then(() => "1", () => undefined) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => "1" : () => string +>"1" : "1" +>() => undefined : () => any +>undefined : undefined + +const p55 = p.then(() => "1", () => null); +>p55 : Promise +>p.then(() => "1", () => null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => "1" : () => string +>"1" : "1" +>() => null : () => any +>null : null + +const p56 = p.then(() => "1", () => {}); +>p56 : Promise +>p.then(() => "1", () => {}) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => "1" : () => string >"1" : "1" >() => {} : () => void -const p43 = p.then(() => "1", () => {throw 1}); ->p43 : Promise<"1"> ->p.then(() => "1", () => {throw 1}) : Promise<"1"> ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p57 = p.then(() => "1", () => {throw 1}); +>p57 : Promise +>p.then(() => "1", () => {throw 1}) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => "1" : () => "1" +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => "1" : () => string >"1" : "1" >() => {throw 1} : () => never >1 : 1 -const p44 = p.then(() => "1", () => Promise.resolve(1)); ->p44 : Promise ->p.then(() => "1", () => Promise.resolve(1)) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p58 = p.then(() => "1", () => Promise.resolve(1)); +>p58 : Promise +>p.then(() => "1", () => Promise.resolve(1)) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => "1" : () => "1" +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => "1" : () => string >"1" : "1" >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise @@ -553,13 +694,13 @@ const p44 = p.then(() => "1", () => Promise.resolve(1)); >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >1 : 1 -const p45 = p.then(() => "1", () => Promise.reject(1)); ->p45 : Promise<"1"> ->p.then(() => "1", () => Promise.reject(1)) : Promise<"1"> ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p59 = p.then(() => "1", () => Promise.reject(1)); +>p59 : Promise +>p.then(() => "1", () => Promise.reject(1)) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => "1" : () => "1" +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => "1" : () => string >"1" : "1" >() => Promise.reject(1) : () => Promise >Promise.reject(1) : Promise @@ -568,50 +709,434 @@ const p45 = p.then(() => "1", () => Promise.reject(1)); >reject : { (reason: any): Promise; (reason: any): Promise; } >1 : 1 -const p50 = p.then(() => {}, undefined); ->p50 : Promise +const p60 = p.then(() => x, undefined); +>p60 : Promise +>p.then(() => x, undefined) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => x : () => any +>x : any +>undefined : undefined + +const p61 = p.then(() => x, null); +>p61 : Promise +>p.then(() => x, null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => x : () => any +>x : any +>null : null + +const p62 = p.then(() => x, () => 1); +>p62 : Promise +>p.then(() => x, () => 1) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => x : () => any +>x : any +>() => 1 : () => number +>1 : 1 + +const p63 = p.then(() => x, () => x); +>p63 : Promise +>p.then(() => x, () => x) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => x : () => any +>x : any +>() => x : () => any +>x : any + +const p64 = p.then(() => x, () => undefined); +>p64 : Promise +>p.then(() => x, () => undefined) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => x : () => any +>x : any +>() => undefined : () => any +>undefined : undefined + +const p65 = p.then(() => x, () => null); +>p65 : Promise +>p.then(() => x, () => null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => x : () => any +>x : any +>() => null : () => any +>null : null + +const p66 = p.then(() => x, () => {}); +>p66 : Promise +>p.then(() => x, () => {}) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => x : () => any +>x : any +>() => {} : () => void + +const p67 = p.then(() => x, () => {throw 1}); +>p67 : Promise +>p.then(() => x, () => {throw 1}) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => x : () => any +>x : any +>() => {throw 1} : () => never +>1 : 1 + +const p68 = p.then(() => x, () => Promise.resolve(1)); +>p68 : Promise +>p.then(() => x, () => Promise.resolve(1)) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => x : () => any +>x : any +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : 1 + +const p69 = p.then(() => x, () => Promise.reject(1)); +>p69 : Promise +>p.then(() => x, () => Promise.reject(1)) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => x : () => any +>x : any +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : 1 + +const p70 = p.then(() => undefined, undefined); +>p70 : Promise +>p.then(() => undefined, undefined) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => undefined : () => any +>undefined : undefined +>undefined : undefined + +const p71 = p.then(() => undefined, null); +>p71 : Promise +>p.then(() => undefined, null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => undefined : () => any +>undefined : undefined +>null : null + +const p72 = p.then(() => undefined, () => 1); +>p72 : Promise +>p.then(() => undefined, () => 1) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => undefined : () => any +>undefined : undefined +>() => 1 : () => number +>1 : 1 + +const p73 = p.then(() => undefined, () => x); +>p73 : Promise +>p.then(() => undefined, () => x) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => undefined : () => any +>undefined : undefined +>() => x : () => any +>x : any + +const p74 = p.then(() => undefined, () => undefined); +>p74 : Promise +>p.then(() => undefined, () => undefined) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => undefined : () => any +>undefined : undefined +>() => undefined : () => any +>undefined : undefined + +const p75 = p.then(() => undefined, () => null); +>p75 : Promise +>p.then(() => undefined, () => null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => undefined : () => any +>undefined : undefined +>() => null : () => any +>null : null + +const p76 = p.then(() => undefined, () => {}); +>p76 : Promise +>p.then(() => undefined, () => {}) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => undefined : () => any +>undefined : undefined +>() => {} : () => void + +const p77 = p.then(() => undefined, () => {throw 1}); +>p77 : Promise +>p.then(() => undefined, () => {throw 1}) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => undefined : () => any +>undefined : undefined +>() => {throw 1} : () => never +>1 : 1 + +const p78 = p.then(() => undefined, () => Promise.resolve(1)); +>p78 : Promise +>p.then(() => undefined, () => Promise.resolve(1)) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => undefined : () => any +>undefined : undefined +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : 1 + +const p79 = p.then(() => undefined, () => Promise.reject(1)); +>p79 : Promise +>p.then(() => undefined, () => Promise.reject(1)) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => undefined : () => any +>undefined : undefined +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : 1 + +const p80 = p.then(() => null, undefined); +>p80 : Promise +>p.then(() => null, undefined) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => null : () => any +>null : null +>undefined : undefined + +const p81 = p.then(() => null, null); +>p81 : Promise +>p.then(() => null, null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => null : () => any +>null : null +>null : null + +const p82 = p.then(() => null, () => 1); +>p82 : Promise +>p.then(() => null, () => 1) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => null : () => any +>null : null +>() => 1 : () => number +>1 : 1 + +const p83 = p.then(() => null, () => x); +>p83 : Promise +>p.then(() => null, () => x) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => null : () => any +>null : null +>() => x : () => any +>x : any + +const p84 = p.then(() => null, () => undefined); +>p84 : Promise +>p.then(() => null, () => undefined) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => null : () => any +>null : null +>() => undefined : () => any +>undefined : undefined + +const p85 = p.then(() => null, () => null); +>p85 : Promise +>p.then(() => null, () => null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => null : () => any +>null : null +>() => null : () => any +>null : null + +const p86 = p.then(() => null, () => {}); +>p86 : Promise +>p.then(() => null, () => {}) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => null : () => any +>null : null +>() => {} : () => void + +const p87 = p.then(() => null, () => {throw 1}); +>p87 : Promise +>p.then(() => null, () => {throw 1}) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => null : () => any +>null : null +>() => {throw 1} : () => never +>1 : 1 + +const p88 = p.then(() => null, () => Promise.resolve(1)); +>p88 : Promise +>p.then(() => null, () => Promise.resolve(1)) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => null : () => any +>null : null +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : 1 + +const p89 = p.then(() => null, () => Promise.reject(1)); +>p89 : Promise +>p.then(() => null, () => Promise.reject(1)) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => null : () => any +>null : null +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : 1 + +const p90 = p.then(() => {}, undefined); +>p90 : Promise >p.then(() => {}, undefined) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => {} : () => void >undefined : undefined -const p51 = p.then(() => {}, () => 1); ->p51 : Promise +const p91 = p.then(() => {}, null); +>p91 : Promise +>p.then(() => {}, null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => {} : () => void +>null : null + +const p92 = p.then(() => {}, () => 1); +>p92 : Promise >p.then(() => {}, () => 1) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => {} : () => void >() => 1 : () => number >1 : 1 -const p52 = p.then(() => {}, () => {}); ->p52 : Promise +const p93 = p.then(() => {}, () => x); +>p93 : Promise +>p.then(() => {}, () => x) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => {} : () => void +>() => x : () => any +>x : any + +const p94 = p.then(() => {}, () => undefined); +>p94 : Promise +>p.then(() => {}, () => undefined) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => {} : () => void +>() => undefined : () => any +>undefined : undefined + +const p95 = p.then(() => {}, () => null); +>p95 : Promise +>p.then(() => {}, () => null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => {} : () => void +>() => null : () => any +>null : null + +const p96 = p.then(() => {}, () => {}); +>p96 : Promise >p.then(() => {}, () => {}) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => {} : () => void >() => {} : () => void -const p53 = p.then(() => {}, () => {throw 1}); ->p53 : Promise +const p97 = p.then(() => {}, () => {throw 1}); +>p97 : Promise >p.then(() => {}, () => {throw 1}) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => {} : () => void >() => {throw 1} : () => never >1 : 1 -const p54 = p.then(() => {}, () => Promise.resolve(1)); ->p54 : Promise +const p98 = p.then(() => {}, () => Promise.resolve(1)); +>p98 : Promise >p.then(() => {}, () => Promise.resolve(1)) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => {} : () => void >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise @@ -620,12 +1145,12 @@ const p54 = p.then(() => {}, () => Promise.resolve(1)); >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >1 : 1 -const p55 = p.then(() => {}, () => Promise.reject(1)); ->p55 : Promise +const p99 = p.then(() => {}, () => Promise.reject(1)); +>p99 : Promise >p.then(() => {}, () => Promise.reject(1)) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => {} : () => void >() => Promise.reject(1) : () => Promise >Promise.reject(1) : Promise @@ -634,54 +1159,97 @@ const p55 = p.then(() => {}, () => Promise.reject(1)); >reject : { (reason: any): Promise; (reason: any): Promise; } >1 : 1 -const p60 = p.then(() => {throw 1}, undefined); ->p60 : Promise ->p.then(() => {throw 1}, undefined) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pa0 = p.then(() => {throw 1}, undefined); +>pa0 : Promise +>p.then(() => {throw 1}, undefined) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => {throw 1} : () => never >1 : 1 >undefined : undefined -const p61 = p.then(() => {throw 1}, () => 1); ->p61 : Promise ->p.then(() => {throw 1}, () => 1) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pa1 = p.then(() => {throw 1}, null); +>pa1 : Promise +>p.then(() => {throw 1}, null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => {throw 1} : () => never >1 : 1 ->() => 1 : () => 1 +>null : null + +const pa2 = p.then(() => {throw 1}, () => 1); +>pa2 : Promise +>p.then(() => {throw 1}, () => 1) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => {throw 1} : () => never +>1 : 1 +>() => 1 : () => number >1 : 1 -const p62 = p.then(() => {throw 1}, () => {}); ->p62 : Promise ->p.then(() => {throw 1}, () => {}) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pa3 = p.then(() => {throw 1}, () => x); +>pa3 : Promise +>p.then(() => {throw 1}, () => x) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => {throw 1} : () => never +>1 : 1 +>() => x : () => any +>x : any + +const pa4 = p.then(() => {throw 1}, () => undefined); +>pa4 : Promise +>p.then(() => {throw 1}, () => undefined) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => {throw 1} : () => never +>1 : 1 +>() => undefined : () => any +>undefined : undefined + +const pa5 = p.then(() => {throw 1}, () => null); +>pa5 : Promise +>p.then(() => {throw 1}, () => null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => {throw 1} : () => never +>1 : 1 +>() => null : () => any +>null : null + +const pa6 = p.then(() => {throw 1}, () => {}); +>pa6 : Promise +>p.then(() => {throw 1}, () => {}) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => {throw 1} : () => never >1 : 1 >() => {} : () => void -const p63 = p.then(() => {throw 1}, () => {throw 1}); ->p63 : Promise ->p.then(() => {throw 1}, () => {throw 1}) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pa7 = p.then(() => {throw 1}, () => {throw 1}); +>pa7 : Promise +>p.then(() => {throw 1}, () => {throw 1}) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => {throw 1} : () => never >1 : 1 >() => {throw 1} : () => never >1 : 1 -const p64 = p.then(() => {throw 1}, () => Promise.resolve(1)); ->p64 : Promise ->p.then(() => {throw 1}, () => Promise.resolve(1)) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pa8 = p.then(() => {throw 1}, () => Promise.resolve(1)); +>pa8 : Promise +>p.then(() => {throw 1}, () => Promise.resolve(1)) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => {throw 1} : () => never >1 : 1 >() => Promise.resolve(1) : () => Promise @@ -691,12 +1259,12 @@ const p64 = p.then(() => {throw 1}, () => Promise.resolve(1)); >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >1 : 1 -const p65 = p.then(() => {throw 1}, () => Promise.reject(1)); ->p65 : Promise ->p.then(() => {throw 1}, () => Promise.reject(1)) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pa9 = p.then(() => {throw 1}, () => Promise.reject(1)); +>pa9 : Promise +>p.then(() => {throw 1}, () => Promise.reject(1)) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => {throw 1} : () => never >1 : 1 >() => Promise.reject(1) : () => Promise @@ -706,12 +1274,12 @@ const p65 = p.then(() => {throw 1}, () => Promise.reject(1)); >reject : { (reason: any): Promise; (reason: any): Promise; } >1 : 1 -const p70 = p.then(() => Promise.resolve("1"), undefined); ->p70 : Promise +const pb0 = p.then(() => Promise.resolve("1"), undefined); +>pb0 : Promise >p.then(() => Promise.resolve("1"), undefined) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } @@ -720,12 +1288,26 @@ const p70 = p.then(() => Promise.resolve("1"), undefined); >"1" : "1" >undefined : undefined -const p71 = p.then(() => Promise.resolve("1"), () => 1); ->p71 : Promise ->p.then(() => Promise.resolve("1"), () => 1) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pb1 = p.then(() => Promise.resolve("1"), null); +>pb1 : Promise +>p.then(() => Promise.resolve("1"), null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : "1" +>null : null + +const pb2 = p.then(() => Promise.resolve("1"), () => 1); +>pb2 : Promise +>p.then(() => Promise.resolve("1"), () => 1) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } @@ -735,143 +1317,92 @@ const p71 = p.then(() => Promise.resolve("1"), () => 1); >() => 1 : () => number >1 : 1 -const p72 = p.then(() => Promise.resolve("1"), () => {}); ->p72 : Promise ->p.then(() => Promise.resolve("1"), () => {}) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pb3 = p.then(() => Promise.resolve("1"), () => x); +>pb3 : Promise +>p.then(() => Promise.resolve("1"), () => x) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >"1" : "1" ->() => {} : () => void +>() => x : () => any +>x : any -const p73 = p.then(() => Promise.resolve("1"), () => {throw 1}); ->p73 : Promise ->p.then(() => Promise.resolve("1"), () => {throw 1}) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pb4 = p.then(() => Promise.resolve("1"), () => undefined); +>pb4 : Promise +>p.then(() => Promise.resolve("1"), () => undefined) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >"1" : "1" ->() => {throw 1} : () => never ->1 : 1 - -const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); ->p74 : Promise ->p.then(() => Promise.resolve("1"), () => Promise.resolve(1)) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => Promise.resolve("1") : () => Promise ->Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } ->Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } ->"1" : "1" ->() => Promise.resolve(1) : () => Promise ->Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } ->Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } ->1 : 1 - -const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); ->p75 : Promise ->p.then(() => Promise.resolve("1"), () => Promise.reject(1)) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => Promise.resolve("1") : () => Promise ->Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } ->Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } ->"1" : "1" ->() => Promise.reject(1) : () => Promise ->Promise.reject(1) : Promise ->Promise.reject : { (reason: any): Promise; (reason: any): Promise; } ->Promise : PromiseConstructor ->reject : { (reason: any): Promise; (reason: any): Promise; } ->1 : 1 - -const p80 = p.then(() => Promise.reject(1), undefined); ->p80 : Promise ->p.then(() => Promise.reject(1), undefined) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => Promise.reject(1) : () => Promise ->Promise.reject(1) : Promise ->Promise.reject : { (reason: any): Promise; (reason: any): Promise; } ->Promise : PromiseConstructor ->reject : { (reason: any): Promise; (reason: any): Promise; } ->1 : 1 +>() => undefined : () => any >undefined : undefined -const p81 = p.then(() => Promise.reject(1), () => 1); ->p81 : Promise ->p.then(() => Promise.reject(1), () => 1) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pb5 = p.then(() => Promise.resolve("1"), () => null); +>pb5 : Promise +>p.then(() => Promise.resolve("1"), () => null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => Promise.reject(1) : () => Promise ->Promise.reject(1) : Promise ->Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor ->reject : { (reason: any): Promise; (reason: any): Promise; } ->1 : 1 ->() => 1 : () => 1 ->1 : 1 +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : "1" +>() => null : () => any +>null : null -const p82 = p.then(() => Promise.reject(1), () => {}); ->p82 : Promise ->p.then(() => Promise.reject(1), () => {}) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pb6 = p.then(() => Promise.resolve("1"), () => {}); +>pb6 : Promise +>p.then(() => Promise.resolve("1"), () => {}) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => Promise.reject(1) : () => Promise ->Promise.reject(1) : Promise ->Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor ->reject : { (reason: any): Promise; (reason: any): Promise; } ->1 : 1 +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : "1" >() => {} : () => void -const p83 = p.then(() => Promise.reject(1), () => {throw 1}); ->p83 : Promise ->p.then(() => Promise.reject(1), () => {throw 1}) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pb7 = p.then(() => Promise.resolve("1"), () => {throw 1}); +>pb7 : Promise +>p.then(() => Promise.resolve("1"), () => {throw 1}) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => Promise.reject(1) : () => Promise ->Promise.reject(1) : Promise ->Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor ->reject : { (reason: any): Promise; (reason: any): Promise; } ->1 : 1 +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : "1" >() => {throw 1} : () => never >1 : 1 -const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); ->p84 : Promise ->p.then(() => Promise.reject(1), () => Promise.resolve(1)) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pb8 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); +>pb8 : Promise +>p.then(() => Promise.resolve("1"), () => Promise.resolve(1)) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => Promise.reject(1) : () => Promise ->Promise.reject(1) : Promise ->Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor ->reject : { (reason: any): Promise; (reason: any): Promise; } ->1 : 1 +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : "1" >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } @@ -879,18 +1410,173 @@ const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >1 : 1 -const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1)); ->p85 : Promise ->p.then(() => Promise.reject(1), () => Promise.reject(1)) : Promise ->p.then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); +>pb9 : Promise +>p.then(() => Promise.resolve("1"), () => Promise.reject(1)) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise ->then : { (onfulfilled?: (value: boolean) => boolean | PromiseLike, onrejected?: (reason: any) => boolean | PromiseLike): Promise; (onfulfilled: (value: boolean) => boolean | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => Promise.reject(1) : () => Promise ->Promise.reject(1) : Promise ->Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : "1" +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor >reject : { (reason: any): Promise; (reason: any): Promise; } >1 : 1 + +const pc0 = p.then(() => Promise.reject("1"), undefined); +>pc0 : Promise +>p.then(() => Promise.reject("1"), undefined) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" +>undefined : undefined + +const pc1 = p.then(() => Promise.reject("1"), null); +>pc1 : Promise +>p.then(() => Promise.reject("1"), null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" +>null : null + +const pc2 = p.then(() => Promise.reject("1"), () => 1); +>pc2 : Promise +>p.then(() => Promise.reject("1"), () => 1) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" +>() => 1 : () => number +>1 : 1 + +const pc3 = p.then(() => Promise.reject("1"), () => x); +>pc3 : Promise +>p.then(() => Promise.reject("1"), () => x) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" +>() => x : () => any +>x : any + +const pc4 = p.then(() => Promise.reject("1"), () => undefined); +>pc4 : Promise +>p.then(() => Promise.reject("1"), () => undefined) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" +>() => undefined : () => any +>undefined : undefined + +const pc5 = p.then(() => Promise.reject("1"), () => null); +>pc5 : Promise +>p.then(() => Promise.reject("1"), () => null) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" +>() => null : () => any +>null : null + +const pc6 = p.then(() => Promise.reject("1"), () => {}); +>pc6 : Promise +>p.then(() => Promise.reject("1"), () => {}) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" +>() => {} : () => void + +const pc7 = p.then(() => Promise.reject("1"), () => {throw 1}); +>pc7 : Promise +>p.then(() => Promise.reject("1"), () => {throw 1}) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" +>() => {throw 1} : () => never +>1 : 1 + +const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1)); +>pc8 : Promise +>p.then(() => Promise.reject("1"), () => Promise.resolve(1)) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : 1 + +const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1)); +>pc9 : Promise +>p.then(() => Promise.reject("1"), () => Promise.reject(1)) : Promise +>p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p : Promise +>then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" >() => Promise.reject(1) : () => Promise >Promise.reject(1) : Promise >Promise.reject : { (reason: any): Promise; (reason: any): Promise; } diff --git a/tests/baselines/reference/promiseTypeInference.symbols b/tests/baselines/reference/promiseTypeInference.symbols index 1dcf037b8b3..3f0f871f364 100644 --- a/tests/baselines/reference/promiseTypeInference.symbols +++ b/tests/baselines/reference/promiseTypeInference.symbols @@ -1,17 +1,17 @@ === tests/cases/compiler/promiseTypeInference.ts === declare class Promise { ->Promise : Symbol(Promise, Decl(promiseTypeInference.ts, 0, 0)) ->T : Symbol(T, Decl(promiseTypeInference.ts, 0, 22)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promiseTypeInference.ts, 0, 0)) +>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(promiseTypeInference.ts, 0, 22)) then(success?: (value: T) => Promise): Promise; ->then : Symbol(Promise.then, Decl(promiseTypeInference.ts, 0, 26)) +>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promiseTypeInference.ts, 0, 26)) >U : Symbol(U, Decl(promiseTypeInference.ts, 1, 9)) >success : Symbol(success, Decl(promiseTypeInference.ts, 1, 12)) >value : Symbol(value, Decl(promiseTypeInference.ts, 1, 23)) ->T : Symbol(T, Decl(promiseTypeInference.ts, 0, 22)) ->Promise : Symbol(Promise, Decl(promiseTypeInference.ts, 0, 0)) +>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(promiseTypeInference.ts, 0, 22)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promiseTypeInference.ts, 0, 0)) >U : Symbol(U, Decl(promiseTypeInference.ts, 1, 9)) ->Promise : Symbol(Promise, Decl(promiseTypeInference.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promiseTypeInference.ts, 0, 0)) >U : Symbol(U, Decl(promiseTypeInference.ts, 1, 9)) } interface IPromise { @@ -32,7 +32,7 @@ interface IPromise { declare function load(name: string): Promise; >load : Symbol(load, Decl(promiseTypeInference.ts, 5, 1)) >name : Symbol(name, Decl(promiseTypeInference.ts, 6, 22)) ->Promise : Symbol(Promise, Decl(promiseTypeInference.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promiseTypeInference.ts, 0, 0)) declare function convert(s: string): IPromise; >convert : Symbol(convert, Decl(promiseTypeInference.ts, 6, 53)) @@ -41,9 +41,9 @@ declare function convert(s: string): IPromise; var $$x = load("something").then(s => convert(s)); >$$x : Symbol($$x, Decl(promiseTypeInference.ts, 9, 3)) ->load("something").then : Symbol(Promise.then, Decl(promiseTypeInference.ts, 0, 26)) +>load("something").then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promiseTypeInference.ts, 0, 26)) >load : Symbol(load, Decl(promiseTypeInference.ts, 5, 1)) ->then : Symbol(Promise.then, Decl(promiseTypeInference.ts, 0, 26)) +>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promiseTypeInference.ts, 0, 26)) >s : Symbol(s, Decl(promiseTypeInference.ts, 9, 33)) >convert : Symbol(convert, Decl(promiseTypeInference.ts, 6, 53)) >s : Symbol(s, Decl(promiseTypeInference.ts, 9, 33)) diff --git a/tests/baselines/reference/promiseTypeInference.types b/tests/baselines/reference/promiseTypeInference.types index f3026c68f21..f722840ffea 100644 --- a/tests/baselines/reference/promiseTypeInference.types +++ b/tests/baselines/reference/promiseTypeInference.types @@ -4,7 +4,7 @@ declare class Promise { >T : T then(success?: (value: T) => Promise): Promise; ->then : (success?: (value: T) => Promise) => Promise +>then : { (onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: T) => Promise): Promise; } >U : U >success : (value: T) => Promise >value : T @@ -42,11 +42,11 @@ declare function convert(s: string): IPromise; var $$x = load("something").then(s => convert(s)); >$$x : Promise >load("something").then(s => convert(s)) : Promise ->load("something").then : (success?: (value: string) => Promise) => Promise +>load("something").then : { (onfulfilled?: (value: string) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: string) => Promise): Promise; } >load("something") : Promise >load : (name: string) => Promise >"something" : "something" ->then : (success?: (value: string) => Promise) => Promise +>then : { (onfulfilled?: (value: string) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: string) => Promise): Promise; } >s => convert(s) : (s: string) => IPromise >s : string >convert(s) : IPromise diff --git a/tests/baselines/reference/promiseTypeStrictNull.js b/tests/baselines/reference/promiseTypeStrictNull.js index 4aefeb3403e..60e0b9b61df 100644 --- a/tests/baselines/reference/promiseTypeStrictNull.js +++ b/tests/baselines/reference/promiseTypeStrictNull.js @@ -1,16 +1,6 @@ //// [promiseTypeStrictNull.ts] declare var p: Promise; - -const a = p.then(); -const b = p.then(b => 1); -const c = p.then(b => 1, e => 'error'); -const d = p.then(b => 1, e => { }); -const e = p.then(b => 1, e => { throw Error(); }); -const f = p.then(b => 1, e => Promise.reject(Error())); -const g = p.catch(e => 'error'); -const h = p.catch(e => { }); -const i = p.catch(e => { throw Error(); }); -const j = p.catch(e => Promise.reject(Error())); +declare var x: any; async function A() { const a = await p; @@ -22,17 +12,15 @@ async function B() { return 1; } -// NOTE: This reports a "No best comment type exists among return expressions." error, and is -// ignored to get the types result for the test. -// async function C() { -// try { -// const a = await p; -// return 1; -// } -// catch (e) { -// return 'error'; -// } -// } +async function C() { + try { + const a = await p; + return 1; + } + catch (e) { + return 'error'; + } +} async function D() { try { @@ -96,64 +84,140 @@ async function I() { // addresses github issue #4903: const p00 = p.catch(); -const p01 = p.catch(undefined); -const p07 = p.catch(null); -const p02 = p.catch(() => 1); -const p03 = p.catch(() => {}); -const p04 = p.catch(() => {throw 1}); -const p05 = p.catch(() => Promise.reject(1)); -const p06 = p.catch(() => Promise.resolve(1)); +const p01 = p.then(); -const p10 = p.then(); +const p10 = p.catch(undefined); +const p11 = p.catch(null); +const p12 = p.catch(() => 1); +const p13 = p.catch(() => x); +const p14 = p.catch(() => undefined); +const p15 = p.catch(() => null); +const p16 = p.catch(() => {}); +const p17 = p.catch(() => {throw 1}); +const p18 = p.catch(() => Promise.reject(1)); +const p19 = p.catch(() => Promise.resolve(1)); const p20 = p.then(undefined); -const p21 = p.then(() => 1); -const p22 = p.then(() => {}); -const p23 = p.then(() => {throw 1}); -const p24 = p.then(() => Promise.resolve(1)); -const p25 = p.then(() => Promise.reject(1)); +const p21 = p.then(null); +const p22 = p.then(() => 1); +const p23 = p.then(() => x); +const p24 = p.then(() => undefined); +const p25 = p.then(() => null); +const p26 = p.then(() => {}); +const p27 = p.then(() => {throw 1}); +const p28 = p.then(() => Promise.resolve(1)); +const p29 = p.then(() => Promise.reject(1)); const p30 = p.then(undefined, undefined); -const p31 = p.then(undefined, () => 1); -const p32 = p.then(undefined, () => {}); -const p33 = p.then(undefined, () => {throw 1}); -const p34 = p.then(undefined, () => Promise.resolve(1)); -const p35 = p.then(undefined, () => Promise.reject(1)); +const p31 = p.then(undefined, null); +const p32 = p.then(undefined, () => 1); +const p33 = p.then(undefined, () => x); +const p34 = p.then(undefined, () => undefined); +const p35 = p.then(undefined, () => null); +const p36 = p.then(undefined, () => {}); +const p37 = p.then(undefined, () => {throw 1}); +const p38 = p.then(undefined, () => Promise.resolve(1)); +const p39 = p.then(undefined, () => Promise.reject(1)); -const p40 = p.then(() => "1", undefined); -const p41 = p.then(() => "1", () => 1); -const p42 = p.then(() => "1", () => {}); -const p43 = p.then(() => "1", () => {throw 1}); -const p44 = p.then(() => "1", () => Promise.resolve(1)); -const p45 = p.then(() => "1", () => Promise.reject(1)); +const p40 = p.then(null, undefined); +const p41 = p.then(null, null); +const p42 = p.then(null, () => 1); +const p43 = p.then(null, () => x); +const p44 = p.then(null, () => undefined); +const p45 = p.then(null, () => null); +const p46 = p.then(null, () => {}); +const p47 = p.then(null, () => {throw 1}); +const p48 = p.then(null, () => Promise.resolve(1)); +const p49 = p.then(null, () => Promise.reject(1)); -const p50 = p.then(() => {}, undefined); -const p51 = p.then(() => {}, () => 1); -const p52 = p.then(() => {}, () => {}); -const p53 = p.then(() => {}, () => {throw 1}); -const p54 = p.then(() => {}, () => Promise.resolve(1)); -const p55 = p.then(() => {}, () => Promise.reject(1)); +const p50 = p.then(() => "1", undefined); +const p51 = p.then(() => "1", null); +const p52 = p.then(() => "1", () => 1); +const p53 = p.then(() => "1", () => x); +const p54 = p.then(() => "1", () => undefined); +const p55 = p.then(() => "1", () => null); +const p56 = p.then(() => "1", () => {}); +const p57 = p.then(() => "1", () => {throw 1}); +const p58 = p.then(() => "1", () => Promise.resolve(1)); +const p59 = p.then(() => "1", () => Promise.reject(1)); -const p60 = p.then(() => {throw 1}, undefined); -const p61 = p.then(() => {throw 1}, () => 1); -const p62 = p.then(() => {throw 1}, () => {}); -const p63 = p.then(() => {throw 1}, () => {throw 1}); -const p64 = p.then(() => {throw 1}, () => Promise.resolve(1)); -const p65 = p.then(() => {throw 1}, () => Promise.reject(1)); +const p60 = p.then(() => x, undefined); +const p61 = p.then(() => x, null); +const p62 = p.then(() => x, () => 1); +const p63 = p.then(() => x, () => x); +const p64 = p.then(() => x, () => undefined); +const p65 = p.then(() => x, () => null); +const p66 = p.then(() => x, () => {}); +const p67 = p.then(() => x, () => {throw 1}); +const p68 = p.then(() => x, () => Promise.resolve(1)); +const p69 = p.then(() => x, () => Promise.reject(1)); -const p70 = p.then(() => Promise.resolve("1"), undefined); -const p71 = p.then(() => Promise.resolve("1"), () => 1); -const p72 = p.then(() => Promise.resolve("1"), () => {}); -const p73 = p.then(() => Promise.resolve("1"), () => {throw 1}); -const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); -const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); +const p70 = p.then(() => undefined, undefined); +const p71 = p.then(() => undefined, null); +const p72 = p.then(() => undefined, () => 1); +const p73 = p.then(() => undefined, () => x); +const p74 = p.then(() => undefined, () => undefined); +const p75 = p.then(() => undefined, () => null); +const p76 = p.then(() => undefined, () => {}); +const p77 = p.then(() => undefined, () => {throw 1}); +const p78 = p.then(() => undefined, () => Promise.resolve(1)); +const p79 = p.then(() => undefined, () => Promise.reject(1)); -const p80 = p.then(() => Promise.reject(1), undefined); -const p81 = p.then(() => Promise.reject(1), () => 1); -const p82 = p.then(() => Promise.reject(1), () => {}); -const p83 = p.then(() => Promise.reject(1), () => {throw 1}); -const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); -const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1)); +const p80 = p.then(() => null, undefined); +const p81 = p.then(() => null, null); +const p82 = p.then(() => null, () => 1); +const p83 = p.then(() => null, () => x); +const p84 = p.then(() => null, () => undefined); +const p85 = p.then(() => null, () => null); +const p86 = p.then(() => null, () => {}); +const p87 = p.then(() => null, () => {throw 1}); +const p88 = p.then(() => null, () => Promise.resolve(1)); +const p89 = p.then(() => null, () => Promise.reject(1)); + +const p90 = p.then(() => {}, undefined); +const p91 = p.then(() => {}, null); +const p92 = p.then(() => {}, () => 1); +const p93 = p.then(() => {}, () => x); +const p94 = p.then(() => {}, () => undefined); +const p95 = p.then(() => {}, () => null); +const p96 = p.then(() => {}, () => {}); +const p97 = p.then(() => {}, () => {throw 1}); +const p98 = p.then(() => {}, () => Promise.resolve(1)); +const p99 = p.then(() => {}, () => Promise.reject(1)); + +const pa0 = p.then(() => {throw 1}, undefined); +const pa1 = p.then(() => {throw 1}, null); +const pa2 = p.then(() => {throw 1}, () => 1); +const pa3 = p.then(() => {throw 1}, () => x); +const pa4 = p.then(() => {throw 1}, () => undefined); +const pa5 = p.then(() => {throw 1}, () => null); +const pa6 = p.then(() => {throw 1}, () => {}); +const pa7 = p.then(() => {throw 1}, () => {throw 1}); +const pa8 = p.then(() => {throw 1}, () => Promise.resolve(1)); +const pa9 = p.then(() => {throw 1}, () => Promise.reject(1)); + +const pb0 = p.then(() => Promise.resolve("1"), undefined); +const pb1 = p.then(() => Promise.resolve("1"), null); +const pb2 = p.then(() => Promise.resolve("1"), () => 1); +const pb3 = p.then(() => Promise.resolve("1"), () => x); +const pb4 = p.then(() => Promise.resolve("1"), () => undefined); +const pb5 = p.then(() => Promise.resolve("1"), () => null); +const pb6 = p.then(() => Promise.resolve("1"), () => {}); +const pb7 = p.then(() => Promise.resolve("1"), () => {throw 1}); +const pb8 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); +const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); + +const pc0 = p.then(() => Promise.reject("1"), undefined); +const pc1 = p.then(() => Promise.reject("1"), null); +const pc2 = p.then(() => Promise.reject("1"), () => 1); +const pc3 = p.then(() => Promise.reject("1"), () => x); +const pc4 = p.then(() => Promise.reject("1"), () => undefined); +const pc5 = p.then(() => Promise.reject("1"), () => null); +const pc6 = p.then(() => Promise.reject("1"), () => {}); +const pc7 = p.then(() => Promise.reject("1"), () => {throw 1}); +const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1)); +const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1)); + //// [promiseTypeStrictNull.js] var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { @@ -164,16 +228,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -const a = p.then(); -const b = p.then(b => 1); -const c = p.then(b => 1, e => 'error'); -const d = p.then(b => 1, e => { }); -const e = p.then(b => 1, e => { throw Error(); }); -const f = p.then(b => 1, e => Promise.reject(Error())); -const g = p.catch(e => 'error'); -const h = p.catch(e => { }); -const i = p.catch(e => { throw Error(); }); -const j = p.catch(e => Promise.reject(Error())); function A() { return __awaiter(this, void 0, void 0, function* () { const a = yield p; @@ -186,17 +240,17 @@ function B() { return 1; }); } -// NOTE: This reports a "No best comment type exists among return expressions." error, and is -// ignored to get the types result for the test. -// async function C() { -// try { -// const a = await p; -// return 1; -// } -// catch (e) { -// return 'error'; -// } -// } +function C() { + return __awaiter(this, void 0, void 0, function* () { + try { + const a = yield p; + return 1; + } + catch (e) { + return 'error'; + } + }); +} function D() { return __awaiter(this, void 0, void 0, function* () { try { @@ -264,53 +318,124 @@ function I() { } // addresses github issue #4903: const p00 = p.catch(); -const p01 = p.catch(undefined); -const p07 = p.catch(null); -const p02 = p.catch(() => 1); -const p03 = p.catch(() => { }); -const p04 = p.catch(() => { throw 1; }); -const p05 = p.catch(() => Promise.reject(1)); -const p06 = p.catch(() => Promise.resolve(1)); -const p10 = p.then(); +const p01 = p.then(); +const p10 = p.catch(undefined); +const p11 = p.catch(null); +const p12 = p.catch(() => 1); +const p13 = p.catch(() => x); +const p14 = p.catch(() => undefined); +const p15 = p.catch(() => null); +const p16 = p.catch(() => { }); +const p17 = p.catch(() => { throw 1; }); +const p18 = p.catch(() => Promise.reject(1)); +const p19 = p.catch(() => Promise.resolve(1)); const p20 = p.then(undefined); -const p21 = p.then(() => 1); -const p22 = p.then(() => { }); -const p23 = p.then(() => { throw 1; }); -const p24 = p.then(() => Promise.resolve(1)); -const p25 = p.then(() => Promise.reject(1)); +const p21 = p.then(null); +const p22 = p.then(() => 1); +const p23 = p.then(() => x); +const p24 = p.then(() => undefined); +const p25 = p.then(() => null); +const p26 = p.then(() => { }); +const p27 = p.then(() => { throw 1; }); +const p28 = p.then(() => Promise.resolve(1)); +const p29 = p.then(() => Promise.reject(1)); const p30 = p.then(undefined, undefined); -const p31 = p.then(undefined, () => 1); -const p32 = p.then(undefined, () => { }); -const p33 = p.then(undefined, () => { throw 1; }); -const p34 = p.then(undefined, () => Promise.resolve(1)); -const p35 = p.then(undefined, () => Promise.reject(1)); -const p40 = p.then(() => "1", undefined); -const p41 = p.then(() => "1", () => 1); -const p42 = p.then(() => "1", () => { }); -const p43 = p.then(() => "1", () => { throw 1; }); -const p44 = p.then(() => "1", () => Promise.resolve(1)); -const p45 = p.then(() => "1", () => Promise.reject(1)); -const p50 = p.then(() => { }, undefined); -const p51 = p.then(() => { }, () => 1); -const p52 = p.then(() => { }, () => { }); -const p53 = p.then(() => { }, () => { throw 1; }); -const p54 = p.then(() => { }, () => Promise.resolve(1)); -const p55 = p.then(() => { }, () => Promise.reject(1)); -const p60 = p.then(() => { throw 1; }, undefined); -const p61 = p.then(() => { throw 1; }, () => 1); -const p62 = p.then(() => { throw 1; }, () => { }); -const p63 = p.then(() => { throw 1; }, () => { throw 1; }); -const p64 = p.then(() => { throw 1; }, () => Promise.resolve(1)); -const p65 = p.then(() => { throw 1; }, () => Promise.reject(1)); -const p70 = p.then(() => Promise.resolve("1"), undefined); -const p71 = p.then(() => Promise.resolve("1"), () => 1); -const p72 = p.then(() => Promise.resolve("1"), () => { }); -const p73 = p.then(() => Promise.resolve("1"), () => { throw 1; }); -const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); -const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); -const p80 = p.then(() => Promise.reject(1), undefined); -const p81 = p.then(() => Promise.reject(1), () => 1); -const p82 = p.then(() => Promise.reject(1), () => { }); -const p83 = p.then(() => Promise.reject(1), () => { throw 1; }); -const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); -const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1)); +const p31 = p.then(undefined, null); +const p32 = p.then(undefined, () => 1); +const p33 = p.then(undefined, () => x); +const p34 = p.then(undefined, () => undefined); +const p35 = p.then(undefined, () => null); +const p36 = p.then(undefined, () => { }); +const p37 = p.then(undefined, () => { throw 1; }); +const p38 = p.then(undefined, () => Promise.resolve(1)); +const p39 = p.then(undefined, () => Promise.reject(1)); +const p40 = p.then(null, undefined); +const p41 = p.then(null, null); +const p42 = p.then(null, () => 1); +const p43 = p.then(null, () => x); +const p44 = p.then(null, () => undefined); +const p45 = p.then(null, () => null); +const p46 = p.then(null, () => { }); +const p47 = p.then(null, () => { throw 1; }); +const p48 = p.then(null, () => Promise.resolve(1)); +const p49 = p.then(null, () => Promise.reject(1)); +const p50 = p.then(() => "1", undefined); +const p51 = p.then(() => "1", null); +const p52 = p.then(() => "1", () => 1); +const p53 = p.then(() => "1", () => x); +const p54 = p.then(() => "1", () => undefined); +const p55 = p.then(() => "1", () => null); +const p56 = p.then(() => "1", () => { }); +const p57 = p.then(() => "1", () => { throw 1; }); +const p58 = p.then(() => "1", () => Promise.resolve(1)); +const p59 = p.then(() => "1", () => Promise.reject(1)); +const p60 = p.then(() => x, undefined); +const p61 = p.then(() => x, null); +const p62 = p.then(() => x, () => 1); +const p63 = p.then(() => x, () => x); +const p64 = p.then(() => x, () => undefined); +const p65 = p.then(() => x, () => null); +const p66 = p.then(() => x, () => { }); +const p67 = p.then(() => x, () => { throw 1; }); +const p68 = p.then(() => x, () => Promise.resolve(1)); +const p69 = p.then(() => x, () => Promise.reject(1)); +const p70 = p.then(() => undefined, undefined); +const p71 = p.then(() => undefined, null); +const p72 = p.then(() => undefined, () => 1); +const p73 = p.then(() => undefined, () => x); +const p74 = p.then(() => undefined, () => undefined); +const p75 = p.then(() => undefined, () => null); +const p76 = p.then(() => undefined, () => { }); +const p77 = p.then(() => undefined, () => { throw 1; }); +const p78 = p.then(() => undefined, () => Promise.resolve(1)); +const p79 = p.then(() => undefined, () => Promise.reject(1)); +const p80 = p.then(() => null, undefined); +const p81 = p.then(() => null, null); +const p82 = p.then(() => null, () => 1); +const p83 = p.then(() => null, () => x); +const p84 = p.then(() => null, () => undefined); +const p85 = p.then(() => null, () => null); +const p86 = p.then(() => null, () => { }); +const p87 = p.then(() => null, () => { throw 1; }); +const p88 = p.then(() => null, () => Promise.resolve(1)); +const p89 = p.then(() => null, () => Promise.reject(1)); +const p90 = p.then(() => { }, undefined); +const p91 = p.then(() => { }, null); +const p92 = p.then(() => { }, () => 1); +const p93 = p.then(() => { }, () => x); +const p94 = p.then(() => { }, () => undefined); +const p95 = p.then(() => { }, () => null); +const p96 = p.then(() => { }, () => { }); +const p97 = p.then(() => { }, () => { throw 1; }); +const p98 = p.then(() => { }, () => Promise.resolve(1)); +const p99 = p.then(() => { }, () => Promise.reject(1)); +const pa0 = p.then(() => { throw 1; }, undefined); +const pa1 = p.then(() => { throw 1; }, null); +const pa2 = p.then(() => { throw 1; }, () => 1); +const pa3 = p.then(() => { throw 1; }, () => x); +const pa4 = p.then(() => { throw 1; }, () => undefined); +const pa5 = p.then(() => { throw 1; }, () => null); +const pa6 = p.then(() => { throw 1; }, () => { }); +const pa7 = p.then(() => { throw 1; }, () => { throw 1; }); +const pa8 = p.then(() => { throw 1; }, () => Promise.resolve(1)); +const pa9 = p.then(() => { throw 1; }, () => Promise.reject(1)); +const pb0 = p.then(() => Promise.resolve("1"), undefined); +const pb1 = p.then(() => Promise.resolve("1"), null); +const pb2 = p.then(() => Promise.resolve("1"), () => 1); +const pb3 = p.then(() => Promise.resolve("1"), () => x); +const pb4 = p.then(() => Promise.resolve("1"), () => undefined); +const pb5 = p.then(() => Promise.resolve("1"), () => null); +const pb6 = p.then(() => Promise.resolve("1"), () => { }); +const pb7 = p.then(() => Promise.resolve("1"), () => { throw 1; }); +const pb8 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); +const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); +const pc0 = p.then(() => Promise.reject("1"), undefined); +const pc1 = p.then(() => Promise.reject("1"), null); +const pc2 = p.then(() => Promise.reject("1"), () => 1); +const pc3 = p.then(() => Promise.reject("1"), () => x); +const pc4 = p.then(() => Promise.reject("1"), () => undefined); +const pc5 = p.then(() => Promise.reject("1"), () => null); +const pc6 = p.then(() => Promise.reject("1"), () => { }); +const pc7 = p.then(() => Promise.reject("1"), () => { throw 1; }); +const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1)); +const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1)); diff --git a/tests/baselines/reference/promiseTypeStrictNull.symbols b/tests/baselines/reference/promiseTypeStrictNull.symbols index bf14c51656e..58acf184564 100644 --- a/tests/baselines/reference/promiseTypeStrictNull.symbols +++ b/tests/baselines/reference/promiseTypeStrictNull.symbols @@ -1,151 +1,76 @@ === tests/cases/compiler/promiseTypeStrictNull.ts === declare var p: Promise; >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) -const a = p.then(); ->a : Symbol(a, Decl(promiseTypeStrictNull.ts, 2, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) - -const b = p.then(b => 1); ->b : Symbol(b, Decl(promiseTypeStrictNull.ts, 3, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->b : Symbol(b, Decl(promiseTypeStrictNull.ts, 3, 17)) - -const c = p.then(b => 1, e => 'error'); ->c : Symbol(c, Decl(promiseTypeStrictNull.ts, 4, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->b : Symbol(b, Decl(promiseTypeStrictNull.ts, 4, 17)) ->e : Symbol(e, Decl(promiseTypeStrictNull.ts, 4, 24)) - -const d = p.then(b => 1, e => { }); ->d : Symbol(d, Decl(promiseTypeStrictNull.ts, 5, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->b : Symbol(b, Decl(promiseTypeStrictNull.ts, 5, 17)) ->e : Symbol(e, Decl(promiseTypeStrictNull.ts, 5, 24)) - -const e = p.then(b => 1, e => { throw Error(); }); ->e : Symbol(e, Decl(promiseTypeStrictNull.ts, 6, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->b : Symbol(b, Decl(promiseTypeStrictNull.ts, 6, 17)) ->e : Symbol(e, Decl(promiseTypeStrictNull.ts, 6, 24)) ->Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - -const f = p.then(b => 1, e => Promise.reject(Error())); ->f : Symbol(f, Decl(promiseTypeStrictNull.ts, 7, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->b : Symbol(b, Decl(promiseTypeStrictNull.ts, 7, 17)) ->e : Symbol(e, Decl(promiseTypeStrictNull.ts, 7, 24)) ->Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - -const g = p.catch(e => 'error'); ->g : Symbol(g, Decl(promiseTypeStrictNull.ts, 8, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->e : Symbol(e, Decl(promiseTypeStrictNull.ts, 8, 18)) - -const h = p.catch(e => { }); ->h : Symbol(h, Decl(promiseTypeStrictNull.ts, 9, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->e : Symbol(e, Decl(promiseTypeStrictNull.ts, 9, 18)) - -const i = p.catch(e => { throw Error(); }); ->i : Symbol(i, Decl(promiseTypeStrictNull.ts, 10, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->e : Symbol(e, Decl(promiseTypeStrictNull.ts, 10, 18)) ->Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - -const j = p.catch(e => Promise.reject(Error())); ->j : Symbol(j, Decl(promiseTypeStrictNull.ts, 11, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->e : Symbol(e, Decl(promiseTypeStrictNull.ts, 11, 18)) ->Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +declare var x: any; +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) async function A() { ->A : Symbol(A, Decl(promiseTypeStrictNull.ts, 11, 48)) +>A : Symbol(A, Decl(promiseTypeStrictNull.ts, 1, 19)) const a = await p; ->a : Symbol(a, Decl(promiseTypeStrictNull.ts, 14, 9)) +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 4, 9)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) return a; ->a : Symbol(a, Decl(promiseTypeStrictNull.ts, 14, 9)) +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 4, 9)) } async function B() { ->B : Symbol(B, Decl(promiseTypeStrictNull.ts, 16, 1)) +>B : Symbol(B, Decl(promiseTypeStrictNull.ts, 6, 1)) const a = await p; ->a : Symbol(a, Decl(promiseTypeStrictNull.ts, 19, 9)) +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 9, 9)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) return 1; } -// NOTE: This reports a "No best comment type exists among return expressions." error, and is -// ignored to get the types result for the test. -// async function C() { -// try { -// const a = await p; -// return 1; -// } -// catch (e) { -// return 'error'; -// } -// } +async function C() { +>C : Symbol(C, Decl(promiseTypeStrictNull.ts, 11, 1)) + + try { + const a = await p; +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 15, 13)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) + + return 1; + } + catch (e) { +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 18, 11)) + + return 'error'; + } +} async function D() { >D : Symbol(D, Decl(promiseTypeStrictNull.ts, 21, 1)) try { const a = await p; ->a : Symbol(a, Decl(promiseTypeStrictNull.ts, 37, 13)) +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 25, 13)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) return 1; } catch (e) { ->e : Symbol(e, Decl(promiseTypeStrictNull.ts, 40, 11)) +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 28, 11)) } } async function E() { ->E : Symbol(E, Decl(promiseTypeStrictNull.ts, 42, 1)) +>E : Symbol(E, Decl(promiseTypeStrictNull.ts, 30, 1)) try { const a = await p; ->a : Symbol(a, Decl(promiseTypeStrictNull.ts, 46, 13)) +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 34, 13)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) return 1; } catch (e) { ->e : Symbol(e, Decl(promiseTypeStrictNull.ts, 49, 11)) +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 37, 11)) throw Error(); >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) @@ -153,57 +78,57 @@ async function E() { } async function F() { ->F : Symbol(F, Decl(promiseTypeStrictNull.ts, 52, 1)) +>F : Symbol(F, Decl(promiseTypeStrictNull.ts, 40, 1)) try { const a = await p; ->a : Symbol(a, Decl(promiseTypeStrictNull.ts, 56, 13)) +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 44, 13)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) return 1; } catch (e) { ->e : Symbol(e, Decl(promiseTypeStrictNull.ts, 59, 11)) +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 47, 11)) return Promise.reject(Error()); >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) } } async function G() { ->G : Symbol(G, Decl(promiseTypeStrictNull.ts, 62, 1)) +>G : Symbol(G, Decl(promiseTypeStrictNull.ts, 50, 1)) try { const a = await p; ->a : Symbol(a, Decl(promiseTypeStrictNull.ts, 66, 13)) +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 54, 13)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) return a; ->a : Symbol(a, Decl(promiseTypeStrictNull.ts, 66, 13)) +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 54, 13)) } catch (e) { ->e : Symbol(e, Decl(promiseTypeStrictNull.ts, 69, 11)) +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 57, 11)) return; } } async function H() { ->H : Symbol(H, Decl(promiseTypeStrictNull.ts, 72, 1)) +>H : Symbol(H, Decl(promiseTypeStrictNull.ts, 60, 1)) try { const a = await p; ->a : Symbol(a, Decl(promiseTypeStrictNull.ts, 76, 13)) +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 64, 13)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) return a; ->a : Symbol(a, Decl(promiseTypeStrictNull.ts, 76, 13)) +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 64, 13)) } catch (e) { ->e : Symbol(e, Decl(promiseTypeStrictNull.ts, 79, 11)) +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 67, 11)) throw Error(); >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) @@ -211,22 +136,22 @@ async function H() { } async function I() { ->I : Symbol(I, Decl(promiseTypeStrictNull.ts, 82, 1)) +>I : Symbol(I, Decl(promiseTypeStrictNull.ts, 70, 1)) try { const a = await p; ->a : Symbol(a, Decl(promiseTypeStrictNull.ts, 86, 13)) +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 74, 13)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) return a; ->a : Symbol(a, Decl(promiseTypeStrictNull.ts, 86, 13)) +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 74, 13)) } catch (e) { ->e : Symbol(e, Decl(promiseTypeStrictNull.ts, 89, 11)) +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 77, 11)) return Promise.reject(Error()); >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) } @@ -235,406 +160,932 @@ async function I() { // addresses github issue #4903: const p00 = p.catch(); ->p00 : Symbol(p00, Decl(promiseTypeStrictNull.ts, 96, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p00 : Symbol(p00, Decl(promiseTypeStrictNull.ts, 84, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) -const p01 = p.catch(undefined); ->p01 : Symbol(p01, Decl(promiseTypeStrictNull.ts, 97, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p01 = p.then(); +>p01 : Symbol(p01, Decl(promiseTypeStrictNull.ts, 85, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p10 = p.catch(undefined); +>p10 : Symbol(p10, Decl(promiseTypeStrictNull.ts, 87, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) -const p07 = p.catch(null); ->p07 : Symbol(p07, Decl(promiseTypeStrictNull.ts, 98, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p11 = p.catch(null); +>p11 : Symbol(p11, Decl(promiseTypeStrictNull.ts, 88, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) -const p02 = p.catch(() => 1); ->p02 : Symbol(p02, Decl(promiseTypeStrictNull.ts, 99, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p12 = p.catch(() => 1); +>p12 : Symbol(p12, Decl(promiseTypeStrictNull.ts, 89, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) -const p03 = p.catch(() => {}); ->p03 : Symbol(p03, Decl(promiseTypeStrictNull.ts, 100, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p13 = p.catch(() => x); +>p13 : Symbol(p13, Decl(promiseTypeStrictNull.ts, 90, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) -const p04 = p.catch(() => {throw 1}); ->p04 : Symbol(p04, Decl(promiseTypeStrictNull.ts, 101, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p14 = p.catch(() => undefined); +>p14 : Symbol(p14, Decl(promiseTypeStrictNull.ts, 91, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) -const p05 = p.catch(() => Promise.reject(1)); ->p05 : Symbol(p05, Decl(promiseTypeStrictNull.ts, 102, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p15 = p.catch(() => null); +>p15 : Symbol(p15, Decl(promiseTypeStrictNull.ts, 92, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) + +const p16 = p.catch(() => {}); +>p16 : Symbol(p16, Decl(promiseTypeStrictNull.ts, 93, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) + +const p17 = p.catch(() => {throw 1}); +>p17 : Symbol(p17, Decl(promiseTypeStrictNull.ts, 94, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) + +const p18 = p.catch(() => Promise.reject(1)); +>p18 : Symbol(p18, Decl(promiseTypeStrictNull.ts, 95, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p06 = p.catch(() => Promise.resolve(1)); ->p06 : Symbol(p06, Decl(promiseTypeStrictNull.ts, 103, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p19 = p.catch(() => Promise.resolve(1)); +>p19 : Symbol(p19, Decl(promiseTypeStrictNull.ts, 96, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>catch : Symbol(Promise.catch, Decl(lib.es5.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p10 = p.then(); ->p10 : Symbol(p10, Decl(promiseTypeStrictNull.ts, 105, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) - const p20 = p.then(undefined); ->p20 : Symbol(p20, Decl(promiseTypeStrictNull.ts, 107, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p20 : Symbol(p20, Decl(promiseTypeStrictNull.ts, 98, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) -const p21 = p.then(() => 1); ->p21 : Symbol(p21, Decl(promiseTypeStrictNull.ts, 108, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p21 = p.then(null); +>p21 : Symbol(p21, Decl(promiseTypeStrictNull.ts, 99, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) -const p22 = p.then(() => {}); ->p22 : Symbol(p22, Decl(promiseTypeStrictNull.ts, 109, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p22 = p.then(() => 1); +>p22 : Symbol(p22, Decl(promiseTypeStrictNull.ts, 100, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) -const p23 = p.then(() => {throw 1}); ->p23 : Symbol(p23, Decl(promiseTypeStrictNull.ts, 110, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p23 = p.then(() => x); +>p23 : Symbol(p23, Decl(promiseTypeStrictNull.ts, 101, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) -const p24 = p.then(() => Promise.resolve(1)); ->p24 : Symbol(p24, Decl(promiseTypeStrictNull.ts, 111, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p24 = p.then(() => undefined); +>p24 : Symbol(p24, Decl(promiseTypeStrictNull.ts, 102, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p25 = p.then(() => null); +>p25 : Symbol(p25, Decl(promiseTypeStrictNull.ts, 103, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p26 = p.then(() => {}); +>p26 : Symbol(p26, Decl(promiseTypeStrictNull.ts, 104, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p27 = p.then(() => {throw 1}); +>p27 : Symbol(p27, Decl(promiseTypeStrictNull.ts, 105, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p28 = p.then(() => Promise.resolve(1)); +>p28 : Symbol(p28, Decl(promiseTypeStrictNull.ts, 106, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p25 = p.then(() => Promise.reject(1)); ->p25 : Symbol(p25, Decl(promiseTypeStrictNull.ts, 112, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p29 = p.then(() => Promise.reject(1)); +>p29 : Symbol(p29, Decl(promiseTypeStrictNull.ts, 107, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) const p30 = p.then(undefined, undefined); ->p30 : Symbol(p30, Decl(promiseTypeStrictNull.ts, 114, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p30 : Symbol(p30, Decl(promiseTypeStrictNull.ts, 109, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) >undefined : Symbol(undefined) -const p31 = p.then(undefined, () => 1); ->p31 : Symbol(p31, Decl(promiseTypeStrictNull.ts, 115, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p31 = p.then(undefined, null); +>p31 : Symbol(p31, Decl(promiseTypeStrictNull.ts, 110, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) -const p32 = p.then(undefined, () => {}); ->p32 : Symbol(p32, Decl(promiseTypeStrictNull.ts, 116, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p32 = p.then(undefined, () => 1); +>p32 : Symbol(p32, Decl(promiseTypeStrictNull.ts, 111, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) -const p33 = p.then(undefined, () => {throw 1}); ->p33 : Symbol(p33, Decl(promiseTypeStrictNull.ts, 117, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p33 = p.then(undefined, () => x); +>p33 : Symbol(p33, Decl(promiseTypeStrictNull.ts, 112, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) + +const p34 = p.then(undefined, () => undefined); +>p34 : Symbol(p34, Decl(promiseTypeStrictNull.ts, 113, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) >undefined : Symbol(undefined) -const p34 = p.then(undefined, () => Promise.resolve(1)); ->p34 : Symbol(p34, Decl(promiseTypeStrictNull.ts, 118, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p35 = p.then(undefined, () => null); +>p35 : Symbol(p35, Decl(promiseTypeStrictNull.ts, 114, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p36 = p.then(undefined, () => {}); +>p36 : Symbol(p36, Decl(promiseTypeStrictNull.ts, 115, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p37 = p.then(undefined, () => {throw 1}); +>p37 : Symbol(p37, Decl(promiseTypeStrictNull.ts, 116, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p38 = p.then(undefined, () => Promise.resolve(1)); +>p38 : Symbol(p38, Decl(promiseTypeStrictNull.ts, 117, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p35 = p.then(undefined, () => Promise.reject(1)); ->p35 : Symbol(p35, Decl(promiseTypeStrictNull.ts, 119, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p39 = p.then(undefined, () => Promise.reject(1)); +>p39 : Symbol(p39, Decl(promiseTypeStrictNull.ts, 118, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p40 = p.then(() => "1", undefined); ->p40 : Symbol(p40, Decl(promiseTypeStrictNull.ts, 121, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p40 = p.then(null, undefined); +>p40 : Symbol(p40, Decl(promiseTypeStrictNull.ts, 120, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) -const p41 = p.then(() => "1", () => 1); ->p41 : Symbol(p41, Decl(promiseTypeStrictNull.ts, 122, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p41 = p.then(null, null); +>p41 : Symbol(p41, Decl(promiseTypeStrictNull.ts, 121, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) -const p42 = p.then(() => "1", () => {}); ->p42 : Symbol(p42, Decl(promiseTypeStrictNull.ts, 123, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p42 = p.then(null, () => 1); +>p42 : Symbol(p42, Decl(promiseTypeStrictNull.ts, 122, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) -const p43 = p.then(() => "1", () => {throw 1}); ->p43 : Symbol(p43, Decl(promiseTypeStrictNull.ts, 124, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p43 = p.then(null, () => x); +>p43 : Symbol(p43, Decl(promiseTypeStrictNull.ts, 123, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) -const p44 = p.then(() => "1", () => Promise.resolve(1)); ->p44 : Symbol(p44, Decl(promiseTypeStrictNull.ts, 125, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p44 = p.then(null, () => undefined); +>p44 : Symbol(p44, Decl(promiseTypeStrictNull.ts, 124, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p45 = p.then(null, () => null); +>p45 : Symbol(p45, Decl(promiseTypeStrictNull.ts, 125, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p46 = p.then(null, () => {}); +>p46 : Symbol(p46, Decl(promiseTypeStrictNull.ts, 126, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p47 = p.then(null, () => {throw 1}); +>p47 : Symbol(p47, Decl(promiseTypeStrictNull.ts, 127, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p48 = p.then(null, () => Promise.resolve(1)); +>p48 : Symbol(p48, Decl(promiseTypeStrictNull.ts, 128, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p45 = p.then(() => "1", () => Promise.reject(1)); ->p45 : Symbol(p45, Decl(promiseTypeStrictNull.ts, 126, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p49 = p.then(null, () => Promise.reject(1)); +>p49 : Symbol(p49, Decl(promiseTypeStrictNull.ts, 129, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p50 = p.then(() => {}, undefined); ->p50 : Symbol(p50, Decl(promiseTypeStrictNull.ts, 128, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p50 = p.then(() => "1", undefined); +>p50 : Symbol(p50, Decl(promiseTypeStrictNull.ts, 131, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) -const p51 = p.then(() => {}, () => 1); ->p51 : Symbol(p51, Decl(promiseTypeStrictNull.ts, 129, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p51 = p.then(() => "1", null); +>p51 : Symbol(p51, Decl(promiseTypeStrictNull.ts, 132, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) -const p52 = p.then(() => {}, () => {}); ->p52 : Symbol(p52, Decl(promiseTypeStrictNull.ts, 130, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p52 = p.then(() => "1", () => 1); +>p52 : Symbol(p52, Decl(promiseTypeStrictNull.ts, 133, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) -const p53 = p.then(() => {}, () => {throw 1}); ->p53 : Symbol(p53, Decl(promiseTypeStrictNull.ts, 131, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p53 = p.then(() => "1", () => x); +>p53 : Symbol(p53, Decl(promiseTypeStrictNull.ts, 134, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) -const p54 = p.then(() => {}, () => Promise.resolve(1)); ->p54 : Symbol(p54, Decl(promiseTypeStrictNull.ts, 132, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p54 = p.then(() => "1", () => undefined); +>p54 : Symbol(p54, Decl(promiseTypeStrictNull.ts, 135, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) - -const p55 = p.then(() => {}, () => Promise.reject(1)); ->p55 : Symbol(p55, Decl(promiseTypeStrictNull.ts, 133, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) - -const p60 = p.then(() => {throw 1}, undefined); ->p60 : Symbol(p60, Decl(promiseTypeStrictNull.ts, 135, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >undefined : Symbol(undefined) -const p61 = p.then(() => {throw 1}, () => 1); ->p61 : Symbol(p61, Decl(promiseTypeStrictNull.ts, 136, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p55 = p.then(() => "1", () => null); +>p55 : Symbol(p55, Decl(promiseTypeStrictNull.ts, 136, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) -const p62 = p.then(() => {throw 1}, () => {}); ->p62 : Symbol(p62, Decl(promiseTypeStrictNull.ts, 137, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p56 = p.then(() => "1", () => {}); +>p56 : Symbol(p56, Decl(promiseTypeStrictNull.ts, 137, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) -const p63 = p.then(() => {throw 1}, () => {throw 1}); ->p63 : Symbol(p63, Decl(promiseTypeStrictNull.ts, 138, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p57 = p.then(() => "1", () => {throw 1}); +>p57 : Symbol(p57, Decl(promiseTypeStrictNull.ts, 138, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) -const p64 = p.then(() => {throw 1}, () => Promise.resolve(1)); ->p64 : Symbol(p64, Decl(promiseTypeStrictNull.ts, 139, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p58 = p.then(() => "1", () => Promise.resolve(1)); +>p58 : Symbol(p58, Decl(promiseTypeStrictNull.ts, 139, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p65 = p.then(() => {throw 1}, () => Promise.reject(1)); ->p65 : Symbol(p65, Decl(promiseTypeStrictNull.ts, 140, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p59 = p.then(() => "1", () => Promise.reject(1)); +>p59 : Symbol(p59, Decl(promiseTypeStrictNull.ts, 140, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p70 = p.then(() => Promise.resolve("1"), undefined); ->p70 : Symbol(p70, Decl(promiseTypeStrictNull.ts, 142, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const p60 = p.then(() => x, undefined); +>p60 : Symbol(p60, Decl(promiseTypeStrictNull.ts, 142, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) +>undefined : Symbol(undefined) + +const p61 = p.then(() => x, null); +>p61 : Symbol(p61, Decl(promiseTypeStrictNull.ts, 143, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) + +const p62 = p.then(() => x, () => 1); +>p62 : Symbol(p62, Decl(promiseTypeStrictNull.ts, 144, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) + +const p63 = p.then(() => x, () => x); +>p63 : Symbol(p63, Decl(promiseTypeStrictNull.ts, 145, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) + +const p64 = p.then(() => x, () => undefined); +>p64 : Symbol(p64, Decl(promiseTypeStrictNull.ts, 146, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) +>undefined : Symbol(undefined) + +const p65 = p.then(() => x, () => null); +>p65 : Symbol(p65, Decl(promiseTypeStrictNull.ts, 147, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) + +const p66 = p.then(() => x, () => {}); +>p66 : Symbol(p66, Decl(promiseTypeStrictNull.ts, 148, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) + +const p67 = p.then(() => x, () => {throw 1}); +>p67 : Symbol(p67, Decl(promiseTypeStrictNull.ts, 149, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) + +const p68 = p.then(() => x, () => Promise.resolve(1)); +>p68 : Symbol(p68, Decl(promiseTypeStrictNull.ts, 150, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p69 = p.then(() => x, () => Promise.reject(1)); +>p69 : Symbol(p69, Decl(promiseTypeStrictNull.ts, 151, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p70 = p.then(() => undefined, undefined); +>p70 : Symbol(p70, Decl(promiseTypeStrictNull.ts, 153, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +const p71 = p.then(() => undefined, null); +>p71 : Symbol(p71, Decl(promiseTypeStrictNull.ts, 154, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p72 = p.then(() => undefined, () => 1); +>p72 : Symbol(p72, Decl(promiseTypeStrictNull.ts, 155, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p73 = p.then(() => undefined, () => x); +>p73 : Symbol(p73, Decl(promiseTypeStrictNull.ts, 156, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) + +const p74 = p.then(() => undefined, () => undefined); +>p74 : Symbol(p74, Decl(promiseTypeStrictNull.ts, 157, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +const p75 = p.then(() => undefined, () => null); +>p75 : Symbol(p75, Decl(promiseTypeStrictNull.ts, 158, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p76 = p.then(() => undefined, () => {}); +>p76 : Symbol(p76, Decl(promiseTypeStrictNull.ts, 159, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p77 = p.then(() => undefined, () => {throw 1}); +>p77 : Symbol(p77, Decl(promiseTypeStrictNull.ts, 160, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p78 = p.then(() => undefined, () => Promise.resolve(1)); +>p78 : Symbol(p78, Decl(promiseTypeStrictNull.ts, 161, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p79 = p.then(() => undefined, () => Promise.reject(1)); +>p79 : Symbol(p79, Decl(promiseTypeStrictNull.ts, 162, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p80 = p.then(() => null, undefined); +>p80 : Symbol(p80, Decl(promiseTypeStrictNull.ts, 164, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p81 = p.then(() => null, null); +>p81 : Symbol(p81, Decl(promiseTypeStrictNull.ts, 165, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p82 = p.then(() => null, () => 1); +>p82 : Symbol(p82, Decl(promiseTypeStrictNull.ts, 166, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p83 = p.then(() => null, () => x); +>p83 : Symbol(p83, Decl(promiseTypeStrictNull.ts, 167, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) + +const p84 = p.then(() => null, () => undefined); +>p84 : Symbol(p84, Decl(promiseTypeStrictNull.ts, 168, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p85 = p.then(() => null, () => null); +>p85 : Symbol(p85, Decl(promiseTypeStrictNull.ts, 169, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p86 = p.then(() => null, () => {}); +>p86 : Symbol(p86, Decl(promiseTypeStrictNull.ts, 170, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p87 = p.then(() => null, () => {throw 1}); +>p87 : Symbol(p87, Decl(promiseTypeStrictNull.ts, 171, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p88 = p.then(() => null, () => Promise.resolve(1)); +>p88 : Symbol(p88, Decl(promiseTypeStrictNull.ts, 172, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p89 = p.then(() => null, () => Promise.reject(1)); +>p89 : Symbol(p89, Decl(promiseTypeStrictNull.ts, 173, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p90 = p.then(() => {}, undefined); +>p90 : Symbol(p90, Decl(promiseTypeStrictNull.ts, 175, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p91 = p.then(() => {}, null); +>p91 : Symbol(p91, Decl(promiseTypeStrictNull.ts, 176, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p92 = p.then(() => {}, () => 1); +>p92 : Symbol(p92, Decl(promiseTypeStrictNull.ts, 177, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p93 = p.then(() => {}, () => x); +>p93 : Symbol(p93, Decl(promiseTypeStrictNull.ts, 178, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) + +const p94 = p.then(() => {}, () => undefined); +>p94 : Symbol(p94, Decl(promiseTypeStrictNull.ts, 179, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p95 = p.then(() => {}, () => null); +>p95 : Symbol(p95, Decl(promiseTypeStrictNull.ts, 180, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p96 = p.then(() => {}, () => {}); +>p96 : Symbol(p96, Decl(promiseTypeStrictNull.ts, 181, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p97 = p.then(() => {}, () => {throw 1}); +>p97 : Symbol(p97, Decl(promiseTypeStrictNull.ts, 182, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const p98 = p.then(() => {}, () => Promise.resolve(1)); +>p98 : Symbol(p98, Decl(promiseTypeStrictNull.ts, 183, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p99 = p.then(() => {}, () => Promise.reject(1)); +>p99 : Symbol(p99, Decl(promiseTypeStrictNull.ts, 184, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const pa0 = p.then(() => {throw 1}, undefined); +>pa0 : Symbol(pa0, Decl(promiseTypeStrictNull.ts, 186, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const pa1 = p.then(() => {throw 1}, null); +>pa1 : Symbol(pa1, Decl(promiseTypeStrictNull.ts, 187, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const pa2 = p.then(() => {throw 1}, () => 1); +>pa2 : Symbol(pa2, Decl(promiseTypeStrictNull.ts, 188, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const pa3 = p.then(() => {throw 1}, () => x); +>pa3 : Symbol(pa3, Decl(promiseTypeStrictNull.ts, 189, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) + +const pa4 = p.then(() => {throw 1}, () => undefined); +>pa4 : Symbol(pa4, Decl(promiseTypeStrictNull.ts, 190, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +const pa5 = p.then(() => {throw 1}, () => null); +>pa5 : Symbol(pa5, Decl(promiseTypeStrictNull.ts, 191, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const pa6 = p.then(() => {throw 1}, () => {}); +>pa6 : Symbol(pa6, Decl(promiseTypeStrictNull.ts, 192, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const pa7 = p.then(() => {throw 1}, () => {throw 1}); +>pa7 : Symbol(pa7, Decl(promiseTypeStrictNull.ts, 193, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) + +const pa8 = p.then(() => {throw 1}, () => Promise.resolve(1)); +>pa8 : Symbol(pa8, Decl(promiseTypeStrictNull.ts, 194, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const pa9 = p.then(() => {throw 1}, () => Promise.reject(1)); +>pa9 : Symbol(pa9, Decl(promiseTypeStrictNull.ts, 195, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const pb0 = p.then(() => Promise.resolve("1"), undefined); +>pb0 : Symbol(pb0, Decl(promiseTypeStrictNull.ts, 197, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >undefined : Symbol(undefined) -const p71 = p.then(() => Promise.resolve("1"), () => 1); ->p71 : Symbol(p71, Decl(promiseTypeStrictNull.ts, 143, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pb1 = p.then(() => Promise.resolve("1"), null); +>pb1 : Symbol(pb1, Decl(promiseTypeStrictNull.ts, 198, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p72 = p.then(() => Promise.resolve("1"), () => {}); ->p72 : Symbol(p72, Decl(promiseTypeStrictNull.ts, 144, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pb2 = p.then(() => Promise.resolve("1"), () => 1); +>pb2 : Symbol(pb2, Decl(promiseTypeStrictNull.ts, 199, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p73 = p.then(() => Promise.resolve("1"), () => {throw 1}); ->p73 : Symbol(p73, Decl(promiseTypeStrictNull.ts, 145, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pb3 = p.then(() => Promise.resolve("1"), () => x); +>pb3 : Symbol(pb3, Decl(promiseTypeStrictNull.ts, 200, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) + +const pb4 = p.then(() => Promise.resolve("1"), () => undefined); +>pb4 : Symbol(pb4, Decl(promiseTypeStrictNull.ts, 201, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const pb5 = p.then(() => Promise.resolve("1"), () => null); +>pb5 : Symbol(pb5, Decl(promiseTypeStrictNull.ts, 202, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); ->p74 : Symbol(p74, Decl(promiseTypeStrictNull.ts, 146, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pb6 = p.then(() => Promise.resolve("1"), () => {}); +>pb6 : Symbol(pb6, Decl(promiseTypeStrictNull.ts, 203, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); ->p75 : Symbol(p75, Decl(promiseTypeStrictNull.ts, 147, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pb7 = p.then(() => Promise.resolve("1"), () => {throw 1}); +>pb7 : Symbol(pb7, Decl(promiseTypeStrictNull.ts, 204, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const pb8 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); +>pb8 : Symbol(pb8, Decl(promiseTypeStrictNull.ts, 205, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); +>pb9 : Symbol(pb9, Decl(promiseTypeStrictNull.ts, 206, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p80 = p.then(() => Promise.reject(1), undefined); ->p80 : Symbol(p80, Decl(promiseTypeStrictNull.ts, 149, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pc0 = p.then(() => Promise.reject("1"), undefined); +>pc0 : Symbol(pc0, Decl(promiseTypeStrictNull.ts, 208, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >undefined : Symbol(undefined) -const p81 = p.then(() => Promise.reject(1), () => 1); ->p81 : Symbol(p81, Decl(promiseTypeStrictNull.ts, 150, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pc1 = p.then(() => Promise.reject("1"), null); +>pc1 : Symbol(pc1, Decl(promiseTypeStrictNull.ts, 209, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p82 = p.then(() => Promise.reject(1), () => {}); ->p82 : Symbol(p82, Decl(promiseTypeStrictNull.ts, 151, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pc2 = p.then(() => Promise.reject("1"), () => 1); +>pc2 : Symbol(pc2, Decl(promiseTypeStrictNull.ts, 210, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p83 = p.then(() => Promise.reject(1), () => {throw 1}); ->p83 : Symbol(p83, Decl(promiseTypeStrictNull.ts, 152, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pc3 = p.then(() => Promise.reject("1"), () => x); +>pc3 : Symbol(pc3, Decl(promiseTypeStrictNull.ts, 211, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>x : Symbol(x, Decl(promiseTypeStrictNull.ts, 1, 11)) + +const pc4 = p.then(() => Promise.reject("1"), () => undefined); +>pc4 : Symbol(pc4, Decl(promiseTypeStrictNull.ts, 212, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const pc5 = p.then(() => Promise.reject("1"), () => null); +>pc5 : Symbol(pc5, Decl(promiseTypeStrictNull.ts, 213, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); ->p84 : Symbol(p84, Decl(promiseTypeStrictNull.ts, 153, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pc6 = p.then(() => Promise.reject("1"), () => {}); +>pc6 : Symbol(pc6, Decl(promiseTypeStrictNull.ts, 214, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const pc7 = p.then(() => Promise.reject("1"), () => {throw 1}); +>pc7 : Symbol(pc7, Decl(promiseTypeStrictNull.ts, 215, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1)); +>pc8 : Symbol(pc8, Decl(promiseTypeStrictNull.ts, 216, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1)); ->p85 : Symbol(p85, Decl(promiseTypeStrictNull.ts, 154, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1)); +>pc9 : Symbol(pc9, Decl(promiseTypeStrictNull.ts, 217, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) diff --git a/tests/baselines/reference/promiseTypeStrictNull.types b/tests/baselines/reference/promiseTypeStrictNull.types index a65547ec5f3..7bb75ec66f2 100644 --- a/tests/baselines/reference/promiseTypeStrictNull.types +++ b/tests/baselines/reference/promiseTypeStrictNull.types @@ -3,124 +3,8 @@ declare var p: Promise; >p : Promise >Promise : Promise -const a = p.then(); ->a : Promise ->p.then() : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } - -const b = p.then(b => 1); ->b : Promise<1> ->p.then(b => 1) : Promise<1> ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->b => 1 : (b: boolean) => 1 ->b : boolean ->1 : 1 - -const c = p.then(b => 1, e => 'error'); ->c : Promise ->p.then(b => 1, e => 'error') : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->b => 1 : (b: boolean) => 1 ->b : boolean ->1 : 1 ->e => 'error' : (e: any) => string ->e : any ->'error' : "error" - -const d = p.then(b => 1, e => { }); ->d : Promise ->p.then(b => 1, e => { }) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->b => 1 : (b: boolean) => 1 ->b : boolean ->1 : 1 ->e => { } : (e: any) => void ->e : any - -const e = p.then(b => 1, e => { throw Error(); }); ->e : Promise<1> ->p.then(b => 1, e => { throw Error(); }) : Promise<1> ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->b => 1 : (b: boolean) => 1 ->b : boolean ->1 : 1 ->e => { throw Error(); } : (e: any) => never ->e : any ->Error() : Error ->Error : ErrorConstructor - -const f = p.then(b => 1, e => Promise.reject(Error())); ->f : Promise<1> ->p.then(b => 1, e => Promise.reject(Error())) : Promise<1> ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->b => 1 : (b: boolean) => 1 ->b : boolean ->1 : 1 ->e => Promise.reject(Error()) : (e: any) => Promise ->e : any ->Promise.reject(Error()) : Promise ->Promise.reject : { (reason: any): Promise; (reason: any): Promise; } ->Promise : PromiseConstructor ->reject : { (reason: any): Promise; (reason: any): Promise; } ->Error() : Error ->Error : ErrorConstructor - -const g = p.catch(e => 'error'); ->g : Promise ->p.catch(e => 'error') : Promise ->p.catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } ->p : Promise ->catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } ->e => 'error' : (e: any) => "error" ->e : any ->'error' : "error" - -const h = p.catch(e => { }); ->h : Promise ->p.catch(e => { }) : Promise ->p.catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } ->p : Promise ->catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } ->e => { } : (e: any) => void ->e : any - -const i = p.catch(e => { throw Error(); }); ->i : Promise ->p.catch(e => { throw Error(); }) : Promise ->p.catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } ->p : Promise ->catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } ->e => { throw Error(); } : (e: any) => never ->e : any ->Error() : Error ->Error : ErrorConstructor - -const j = p.catch(e => Promise.reject(Error())); ->j : Promise ->p.catch(e => Promise.reject(Error())) : Promise ->p.catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } ->p : Promise ->catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } ->e => Promise.reject(Error()) : (e: any) => Promise ->e : any ->Promise.reject(Error()) : Promise ->Promise.reject : { (reason: any): Promise; (reason: any): Promise; } ->Promise : PromiseConstructor ->reject : { (reason: any): Promise; (reason: any): Promise; } ->Error() : Error ->Error : ErrorConstructor +declare var x: any; +>x : any async function A() { >A : () => Promise @@ -146,17 +30,25 @@ async function B() { >1 : 1 } -// NOTE: This reports a "No best comment type exists among return expressions." error, and is -// ignored to get the types result for the test. -// async function C() { -// try { -// const a = await p; -// return 1; -// } -// catch (e) { -// return 'error'; -// } -// } +async function C() { +>C : () => Promise<1 | "error"> + + try { + const a = await p; +>a : boolean +>await p : boolean +>p : Promise + + return 1; +>1 : 1 + } + catch (e) { +>e : any + + return 'error'; +>'error' : "error" + } +} async function D() { >D : () => Promise<1 | undefined> @@ -291,58 +183,92 @@ async function I() { const p00 = p.catch(); >p00 : Promise >p.catch() : Promise ->p.catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p.catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise >p : Promise ->catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise -const p01 = p.catch(undefined); +const p01 = p.then(); >p01 : Promise ->p.catch(undefined) : Promise ->p.catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p.then() : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise + +const p10 = p.catch(undefined); +>p10 : Promise +>p.catch(undefined) : Promise +>p.catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise +>p : Promise +>catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise >undefined : undefined -const p07 = p.catch(null); ->p07 : Promise +const p11 = p.catch(null); +>p11 : Promise >p.catch(null) : Promise ->p.catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p.catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise >p : Promise ->catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise >null : null -const p02 = p.catch(() => 1); ->p02 : Promise ->p.catch(() => 1) : Promise ->p.catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +const p12 = p.catch(() => 1); +>p12 : Promise +>p.catch(() => 1) : Promise +>p.catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise >p : Promise ->catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } ->() => 1 : () => 1 +>catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise +>() => 1 : () => number >1 : 1 -const p03 = p.catch(() => {}); ->p03 : Promise ->p.catch(() => {}) : Promise ->p.catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +const p13 = p.catch(() => x); +>p13 : Promise +>p.catch(() => x) : Promise +>p.catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise >p : Promise ->catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise +>() => x : () => any +>x : any + +const p14 = p.catch(() => undefined); +>p14 : Promise +>p.catch(() => undefined) : Promise +>p.catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise +>p : Promise +>catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise +>() => undefined : () => undefined +>undefined : undefined + +const p15 = p.catch(() => null); +>p15 : Promise +>p.catch(() => null) : Promise +>p.catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise +>p : Promise +>catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise +>() => null : () => null +>null : null + +const p16 = p.catch(() => {}); +>p16 : Promise +>p.catch(() => {}) : Promise +>p.catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise +>p : Promise +>catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise >() => {} : () => void -const p04 = p.catch(() => {throw 1}); ->p04 : Promise +const p17 = p.catch(() => {throw 1}); +>p17 : Promise >p.catch(() => {throw 1}) : Promise ->p.catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p.catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise >p : Promise ->catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise >() => {throw 1} : () => never >1 : 1 -const p05 = p.catch(() => Promise.reject(1)); ->p05 : Promise +const p18 = p.catch(() => Promise.reject(1)); +>p18 : Promise >p.catch(() => Promise.reject(1)) : Promise ->p.catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p.catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise >p : Promise ->catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise >() => Promise.reject(1) : () => Promise >Promise.reject(1) : Promise >Promise.reject : { (reason: any): Promise; (reason: any): Promise; } @@ -350,12 +276,12 @@ const p05 = p.catch(() => Promise.reject(1)); >reject : { (reason: any): Promise; (reason: any): Promise; } >1 : 1 -const p06 = p.catch(() => Promise.resolve(1)); ->p06 : Promise +const p19 = p.catch(() => Promise.resolve(1)); +>p19 : Promise >p.catch(() => Promise.resolve(1)) : Promise ->p.catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p.catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise >p : Promise ->catch : { (onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>catch : (onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined) => Promise >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } @@ -363,53 +289,81 @@ const p06 = p.catch(() => Promise.resolve(1)); >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >1 : 1 -const p10 = p.then(); ->p10 : Promise ->p.then() : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } - const p20 = p.then(undefined); >p20 : Promise >p.then(undefined) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >undefined : undefined -const p21 = p.then(() => 1); ->p21 : Promise<1> ->p.then(() => 1) : Promise<1> ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p21 = p.then(null); +>p21 : Promise +>p.then(null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => 1 : () => 1 +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>null : null + +const p22 = p.then(() => 1); +>p22 : Promise +>p.then(() => 1) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => 1 : () => number >1 : 1 -const p22 = p.then(() => {}); ->p22 : Promise ->p.then(() => {}) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p23 = p.then(() => x); +>p23 : Promise +>p.then(() => x) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => x : () => any +>x : any + +const p24 = p.then(() => undefined); +>p24 : Promise +>p.then(() => undefined) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => undefined : () => undefined +>undefined : undefined + +const p25 = p.then(() => null); +>p25 : Promise +>p.then(() => null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => null : () => null +>null : null + +const p26 = p.then(() => {}); +>p26 : Promise +>p.then(() => {}) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => {} : () => void -const p23 = p.then(() => {throw 1}); ->p23 : Promise ->p.then(() => {throw 1}) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p27 = p.then(() => {throw 1}); +>p27 : Promise +>p.then(() => {throw 1}) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => {throw 1} : () => never >1 : 1 -const p24 = p.then(() => Promise.resolve(1)); ->p24 : Promise +const p28 = p.then(() => Promise.resolve(1)); +>p28 : Promise >p.then(() => Promise.resolve(1)) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } @@ -417,12 +371,12 @@ const p24 = p.then(() => Promise.resolve(1)); >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >1 : 1 -const p25 = p.then(() => Promise.reject(1)); ->p25 : Promise ->p.then(() => Promise.reject(1)) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p29 = p.then(() => Promise.reject(1)); +>p29 : Promise +>p.then(() => Promise.reject(1)) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => Promise.reject(1) : () => Promise >Promise.reject(1) : Promise >Promise.reject : { (reason: any): Promise; (reason: any): Promise; } @@ -433,47 +387,86 @@ const p25 = p.then(() => Promise.reject(1)); const p30 = p.then(undefined, undefined); >p30 : Promise >p.then(undefined, undefined) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >undefined : undefined >undefined : undefined -const p31 = p.then(undefined, () => 1); ->p31 : Promise ->p.then(undefined, () => 1) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p31 = p.then(undefined, null); +>p31 : Promise +>p.then(undefined, null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >undefined : undefined ->() => 1 : () => 1 +>null : null + +const p32 = p.then(undefined, () => 1); +>p32 : Promise +>p.then(undefined, () => 1) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>undefined : undefined +>() => 1 : () => number >1 : 1 -const p32 = p.then(undefined, () => {}); ->p32 : Promise +const p33 = p.then(undefined, () => x); +>p33 : Promise +>p.then(undefined, () => x) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>undefined : undefined +>() => x : () => any +>x : any + +const p34 = p.then(undefined, () => undefined); +>p34 : Promise +>p.then(undefined, () => undefined) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>undefined : undefined +>() => undefined : () => undefined +>undefined : undefined + +const p35 = p.then(undefined, () => null); +>p35 : Promise +>p.then(undefined, () => null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>undefined : undefined +>() => null : () => null +>null : null + +const p36 = p.then(undefined, () => {}); +>p36 : Promise >p.then(undefined, () => {}) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >undefined : undefined >() => {} : () => void -const p33 = p.then(undefined, () => {throw 1}); ->p33 : Promise +const p37 = p.then(undefined, () => {throw 1}); +>p37 : Promise >p.then(undefined, () => {throw 1}) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >undefined : undefined >() => {throw 1} : () => never >1 : 1 -const p34 = p.then(undefined, () => Promise.resolve(1)); ->p34 : Promise +const p38 = p.then(undefined, () => Promise.resolve(1)); +>p38 : Promise >p.then(undefined, () => Promise.resolve(1)) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >undefined : undefined >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise @@ -482,12 +475,12 @@ const p34 = p.then(undefined, () => Promise.resolve(1)); >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >1 : 1 -const p35 = p.then(undefined, () => Promise.reject(1)); ->p35 : Promise +const p39 = p.then(undefined, () => Promise.reject(1)); +>p39 : Promise >p.then(undefined, () => Promise.reject(1)) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >undefined : undefined >() => Promise.reject(1) : () => Promise >Promise.reject(1) : Promise @@ -496,55 +489,203 @@ const p35 = p.then(undefined, () => Promise.reject(1)); >reject : { (reason: any): Promise; (reason: any): Promise; } >1 : 1 -const p40 = p.then(() => "1", undefined); ->p40 : Promise<"1"> ->p.then(() => "1", undefined) : Promise<"1"> ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p40 = p.then(null, undefined); +>p40 : Promise +>p.then(null, undefined) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => "1" : () => "1" +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>null : null +>undefined : undefined + +const p41 = p.then(null, null); +>p41 : Promise +>p.then(null, null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>null : null +>null : null + +const p42 = p.then(null, () => 1); +>p42 : Promise +>p.then(null, () => 1) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>null : null +>() => 1 : () => number +>1 : 1 + +const p43 = p.then(null, () => x); +>p43 : Promise +>p.then(null, () => x) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>null : null +>() => x : () => any +>x : any + +const p44 = p.then(null, () => undefined); +>p44 : Promise +>p.then(null, () => undefined) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>null : null +>() => undefined : () => undefined +>undefined : undefined + +const p45 = p.then(null, () => null); +>p45 : Promise +>p.then(null, () => null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>null : null +>() => null : () => null +>null : null + +const p46 = p.then(null, () => {}); +>p46 : Promise +>p.then(null, () => {}) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>null : null +>() => {} : () => void + +const p47 = p.then(null, () => {throw 1}); +>p47 : Promise +>p.then(null, () => {throw 1}) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>null : null +>() => {throw 1} : () => never +>1 : 1 + +const p48 = p.then(null, () => Promise.resolve(1)); +>p48 : Promise +>p.then(null, () => Promise.resolve(1)) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>null : null +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : 1 + +const p49 = p.then(null, () => Promise.reject(1)); +>p49 : Promise +>p.then(null, () => Promise.reject(1)) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>null : null +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : 1 + +const p50 = p.then(() => "1", undefined); +>p50 : Promise +>p.then(() => "1", undefined) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => "1" : () => string >"1" : "1" >undefined : undefined -const p41 = p.then(() => "1", () => 1); ->p41 : Promise ->p.then(() => "1", () => 1) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p51 = p.then(() => "1", null); +>p51 : Promise +>p.then(() => "1", null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => "1" : () => "1" +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => "1" : () => string +>"1" : "1" +>null : null + +const p52 = p.then(() => "1", () => 1); +>p52 : Promise +>p.then(() => "1", () => 1) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => "1" : () => string >"1" : "1" >() => 1 : () => number >1 : 1 -const p42 = p.then(() => "1", () => {}); ->p42 : Promise ->p.then(() => "1", () => {}) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p53 = p.then(() => "1", () => x); +>p53 : Promise +>p.then(() => "1", () => x) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => "1" : () => "1" +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => "1" : () => string +>"1" : "1" +>() => x : () => any +>x : any + +const p54 = p.then(() => "1", () => undefined); +>p54 : Promise +>p.then(() => "1", () => undefined) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => "1" : () => string +>"1" : "1" +>() => undefined : () => undefined +>undefined : undefined + +const p55 = p.then(() => "1", () => null); +>p55 : Promise +>p.then(() => "1", () => null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => "1" : () => string +>"1" : "1" +>() => null : () => null +>null : null + +const p56 = p.then(() => "1", () => {}); +>p56 : Promise +>p.then(() => "1", () => {}) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => "1" : () => string >"1" : "1" >() => {} : () => void -const p43 = p.then(() => "1", () => {throw 1}); ->p43 : Promise<"1"> ->p.then(() => "1", () => {throw 1}) : Promise<"1"> ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p57 = p.then(() => "1", () => {throw 1}); +>p57 : Promise +>p.then(() => "1", () => {throw 1}) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => "1" : () => "1" +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => "1" : () => string >"1" : "1" >() => {throw 1} : () => never >1 : 1 -const p44 = p.then(() => "1", () => Promise.resolve(1)); ->p44 : Promise ->p.then(() => "1", () => Promise.resolve(1)) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p58 = p.then(() => "1", () => Promise.resolve(1)); +>p58 : Promise +>p.then(() => "1", () => Promise.resolve(1)) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => "1" : () => "1" +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => "1" : () => string >"1" : "1" >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise @@ -553,13 +694,13 @@ const p44 = p.then(() => "1", () => Promise.resolve(1)); >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >1 : 1 -const p45 = p.then(() => "1", () => Promise.reject(1)); ->p45 : Promise<"1"> ->p.then(() => "1", () => Promise.reject(1)) : Promise<"1"> ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const p59 = p.then(() => "1", () => Promise.reject(1)); +>p59 : Promise +>p.then(() => "1", () => Promise.reject(1)) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => "1" : () => "1" +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => "1" : () => string >"1" : "1" >() => Promise.reject(1) : () => Promise >Promise.reject(1) : Promise @@ -568,50 +709,434 @@ const p45 = p.then(() => "1", () => Promise.reject(1)); >reject : { (reason: any): Promise; (reason: any): Promise; } >1 : 1 -const p50 = p.then(() => {}, undefined); ->p50 : Promise +const p60 = p.then(() => x, undefined); +>p60 : Promise +>p.then(() => x, undefined) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => x : () => any +>x : any +>undefined : undefined + +const p61 = p.then(() => x, null); +>p61 : Promise +>p.then(() => x, null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => x : () => any +>x : any +>null : null + +const p62 = p.then(() => x, () => 1); +>p62 : Promise +>p.then(() => x, () => 1) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => x : () => any +>x : any +>() => 1 : () => number +>1 : 1 + +const p63 = p.then(() => x, () => x); +>p63 : Promise +>p.then(() => x, () => x) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => x : () => any +>x : any +>() => x : () => any +>x : any + +const p64 = p.then(() => x, () => undefined); +>p64 : Promise +>p.then(() => x, () => undefined) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => x : () => any +>x : any +>() => undefined : () => undefined +>undefined : undefined + +const p65 = p.then(() => x, () => null); +>p65 : Promise +>p.then(() => x, () => null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => x : () => any +>x : any +>() => null : () => null +>null : null + +const p66 = p.then(() => x, () => {}); +>p66 : Promise +>p.then(() => x, () => {}) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => x : () => any +>x : any +>() => {} : () => void + +const p67 = p.then(() => x, () => {throw 1}); +>p67 : Promise +>p.then(() => x, () => {throw 1}) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => x : () => any +>x : any +>() => {throw 1} : () => never +>1 : 1 + +const p68 = p.then(() => x, () => Promise.resolve(1)); +>p68 : Promise +>p.then(() => x, () => Promise.resolve(1)) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => x : () => any +>x : any +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : 1 + +const p69 = p.then(() => x, () => Promise.reject(1)); +>p69 : Promise +>p.then(() => x, () => Promise.reject(1)) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => x : () => any +>x : any +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : 1 + +const p70 = p.then(() => undefined, undefined); +>p70 : Promise +>p.then(() => undefined, undefined) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => undefined : () => undefined +>undefined : undefined +>undefined : undefined + +const p71 = p.then(() => undefined, null); +>p71 : Promise +>p.then(() => undefined, null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => undefined : () => undefined +>undefined : undefined +>null : null + +const p72 = p.then(() => undefined, () => 1); +>p72 : Promise +>p.then(() => undefined, () => 1) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => undefined : () => undefined +>undefined : undefined +>() => 1 : () => number +>1 : 1 + +const p73 = p.then(() => undefined, () => x); +>p73 : Promise +>p.then(() => undefined, () => x) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => undefined : () => undefined +>undefined : undefined +>() => x : () => any +>x : any + +const p74 = p.then(() => undefined, () => undefined); +>p74 : Promise +>p.then(() => undefined, () => undefined) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => undefined : () => undefined +>undefined : undefined +>() => undefined : () => undefined +>undefined : undefined + +const p75 = p.then(() => undefined, () => null); +>p75 : Promise +>p.then(() => undefined, () => null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => undefined : () => undefined +>undefined : undefined +>() => null : () => null +>null : null + +const p76 = p.then(() => undefined, () => {}); +>p76 : Promise +>p.then(() => undefined, () => {}) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => undefined : () => undefined +>undefined : undefined +>() => {} : () => void + +const p77 = p.then(() => undefined, () => {throw 1}); +>p77 : Promise +>p.then(() => undefined, () => {throw 1}) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => undefined : () => undefined +>undefined : undefined +>() => {throw 1} : () => never +>1 : 1 + +const p78 = p.then(() => undefined, () => Promise.resolve(1)); +>p78 : Promise +>p.then(() => undefined, () => Promise.resolve(1)) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => undefined : () => undefined +>undefined : undefined +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : 1 + +const p79 = p.then(() => undefined, () => Promise.reject(1)); +>p79 : Promise +>p.then(() => undefined, () => Promise.reject(1)) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => undefined : () => undefined +>undefined : undefined +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : 1 + +const p80 = p.then(() => null, undefined); +>p80 : Promise +>p.then(() => null, undefined) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => null : () => null +>null : null +>undefined : undefined + +const p81 = p.then(() => null, null); +>p81 : Promise +>p.then(() => null, null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => null : () => null +>null : null +>null : null + +const p82 = p.then(() => null, () => 1); +>p82 : Promise +>p.then(() => null, () => 1) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => null : () => null +>null : null +>() => 1 : () => number +>1 : 1 + +const p83 = p.then(() => null, () => x); +>p83 : Promise +>p.then(() => null, () => x) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => null : () => null +>null : null +>() => x : () => any +>x : any + +const p84 = p.then(() => null, () => undefined); +>p84 : Promise +>p.then(() => null, () => undefined) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => null : () => null +>null : null +>() => undefined : () => undefined +>undefined : undefined + +const p85 = p.then(() => null, () => null); +>p85 : Promise +>p.then(() => null, () => null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => null : () => null +>null : null +>() => null : () => null +>null : null + +const p86 = p.then(() => null, () => {}); +>p86 : Promise +>p.then(() => null, () => {}) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => null : () => null +>null : null +>() => {} : () => void + +const p87 = p.then(() => null, () => {throw 1}); +>p87 : Promise +>p.then(() => null, () => {throw 1}) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => null : () => null +>null : null +>() => {throw 1} : () => never +>1 : 1 + +const p88 = p.then(() => null, () => Promise.resolve(1)); +>p88 : Promise +>p.then(() => null, () => Promise.resolve(1)) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => null : () => null +>null : null +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : 1 + +const p89 = p.then(() => null, () => Promise.reject(1)); +>p89 : Promise +>p.then(() => null, () => Promise.reject(1)) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => null : () => null +>null : null +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : 1 + +const p90 = p.then(() => {}, undefined); +>p90 : Promise >p.then(() => {}, undefined) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => {} : () => void >undefined : undefined -const p51 = p.then(() => {}, () => 1); ->p51 : Promise +const p91 = p.then(() => {}, null); +>p91 : Promise +>p.then(() => {}, null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => {} : () => void +>null : null + +const p92 = p.then(() => {}, () => 1); +>p92 : Promise >p.then(() => {}, () => 1) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => {} : () => void >() => 1 : () => number >1 : 1 -const p52 = p.then(() => {}, () => {}); ->p52 : Promise +const p93 = p.then(() => {}, () => x); +>p93 : Promise +>p.then(() => {}, () => x) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => {} : () => void +>() => x : () => any +>x : any + +const p94 = p.then(() => {}, () => undefined); +>p94 : Promise +>p.then(() => {}, () => undefined) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => {} : () => void +>() => undefined : () => undefined +>undefined : undefined + +const p95 = p.then(() => {}, () => null); +>p95 : Promise +>p.then(() => {}, () => null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => {} : () => void +>() => null : () => null +>null : null + +const p96 = p.then(() => {}, () => {}); +>p96 : Promise >p.then(() => {}, () => {}) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => {} : () => void >() => {} : () => void -const p53 = p.then(() => {}, () => {throw 1}); ->p53 : Promise +const p97 = p.then(() => {}, () => {throw 1}); +>p97 : Promise >p.then(() => {}, () => {throw 1}) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => {} : () => void >() => {throw 1} : () => never >1 : 1 -const p54 = p.then(() => {}, () => Promise.resolve(1)); ->p54 : Promise +const p98 = p.then(() => {}, () => Promise.resolve(1)); +>p98 : Promise >p.then(() => {}, () => Promise.resolve(1)) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => {} : () => void >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise @@ -620,12 +1145,12 @@ const p54 = p.then(() => {}, () => Promise.resolve(1)); >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >1 : 1 -const p55 = p.then(() => {}, () => Promise.reject(1)); ->p55 : Promise +const p99 = p.then(() => {}, () => Promise.reject(1)); +>p99 : Promise >p.then(() => {}, () => Promise.reject(1)) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => {} : () => void >() => Promise.reject(1) : () => Promise >Promise.reject(1) : Promise @@ -634,54 +1159,97 @@ const p55 = p.then(() => {}, () => Promise.reject(1)); >reject : { (reason: any): Promise; (reason: any): Promise; } >1 : 1 -const p60 = p.then(() => {throw 1}, undefined); ->p60 : Promise ->p.then(() => {throw 1}, undefined) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pa0 = p.then(() => {throw 1}, undefined); +>pa0 : Promise +>p.then(() => {throw 1}, undefined) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => {throw 1} : () => never >1 : 1 >undefined : undefined -const p61 = p.then(() => {throw 1}, () => 1); ->p61 : Promise ->p.then(() => {throw 1}, () => 1) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pa1 = p.then(() => {throw 1}, null); +>pa1 : Promise +>p.then(() => {throw 1}, null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => {throw 1} : () => never >1 : 1 ->() => 1 : () => 1 +>null : null + +const pa2 = p.then(() => {throw 1}, () => 1); +>pa2 : Promise +>p.then(() => {throw 1}, () => 1) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => {throw 1} : () => never +>1 : 1 +>() => 1 : () => number >1 : 1 -const p62 = p.then(() => {throw 1}, () => {}); ->p62 : Promise ->p.then(() => {throw 1}, () => {}) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pa3 = p.then(() => {throw 1}, () => x); +>pa3 : Promise +>p.then(() => {throw 1}, () => x) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => {throw 1} : () => never +>1 : 1 +>() => x : () => any +>x : any + +const pa4 = p.then(() => {throw 1}, () => undefined); +>pa4 : Promise +>p.then(() => {throw 1}, () => undefined) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => {throw 1} : () => never +>1 : 1 +>() => undefined : () => undefined +>undefined : undefined + +const pa5 = p.then(() => {throw 1}, () => null); +>pa5 : Promise +>p.then(() => {throw 1}, () => null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => {throw 1} : () => never +>1 : 1 +>() => null : () => null +>null : null + +const pa6 = p.then(() => {throw 1}, () => {}); +>pa6 : Promise +>p.then(() => {throw 1}, () => {}) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => {throw 1} : () => never >1 : 1 >() => {} : () => void -const p63 = p.then(() => {throw 1}, () => {throw 1}); ->p63 : Promise ->p.then(() => {throw 1}, () => {throw 1}) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pa7 = p.then(() => {throw 1}, () => {throw 1}); +>pa7 : Promise +>p.then(() => {throw 1}, () => {throw 1}) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => {throw 1} : () => never >1 : 1 >() => {throw 1} : () => never >1 : 1 -const p64 = p.then(() => {throw 1}, () => Promise.resolve(1)); ->p64 : Promise ->p.then(() => {throw 1}, () => Promise.resolve(1)) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pa8 = p.then(() => {throw 1}, () => Promise.resolve(1)); +>pa8 : Promise +>p.then(() => {throw 1}, () => Promise.resolve(1)) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => {throw 1} : () => never >1 : 1 >() => Promise.resolve(1) : () => Promise @@ -691,12 +1259,12 @@ const p64 = p.then(() => {throw 1}, () => Promise.resolve(1)); >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >1 : 1 -const p65 = p.then(() => {throw 1}, () => Promise.reject(1)); ->p65 : Promise ->p.then(() => {throw 1}, () => Promise.reject(1)) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pa9 = p.then(() => {throw 1}, () => Promise.reject(1)); +>pa9 : Promise +>p.then(() => {throw 1}, () => Promise.reject(1)) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => {throw 1} : () => never >1 : 1 >() => Promise.reject(1) : () => Promise @@ -706,12 +1274,12 @@ const p65 = p.then(() => {throw 1}, () => Promise.reject(1)); >reject : { (reason: any): Promise; (reason: any): Promise; } >1 : 1 -const p70 = p.then(() => Promise.resolve("1"), undefined); ->p70 : Promise +const pb0 = p.then(() => Promise.resolve("1"), undefined); +>pb0 : Promise >p.then(() => Promise.resolve("1"), undefined) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } @@ -720,12 +1288,26 @@ const p70 = p.then(() => Promise.resolve("1"), undefined); >"1" : "1" >undefined : undefined -const p71 = p.then(() => Promise.resolve("1"), () => 1); ->p71 : Promise ->p.then(() => Promise.resolve("1"), () => 1) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pb1 = p.then(() => Promise.resolve("1"), null); +>pb1 : Promise +>p.then(() => Promise.resolve("1"), null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : "1" +>null : null + +const pb2 = p.then(() => Promise.resolve("1"), () => 1); +>pb2 : Promise +>p.then(() => Promise.resolve("1"), () => 1) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } @@ -735,143 +1317,92 @@ const p71 = p.then(() => Promise.resolve("1"), () => 1); >() => 1 : () => number >1 : 1 -const p72 = p.then(() => Promise.resolve("1"), () => {}); ->p72 : Promise ->p.then(() => Promise.resolve("1"), () => {}) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pb3 = p.then(() => Promise.resolve("1"), () => x); +>pb3 : Promise +>p.then(() => Promise.resolve("1"), () => x) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >"1" : "1" ->() => {} : () => void +>() => x : () => any +>x : any -const p73 = p.then(() => Promise.resolve("1"), () => {throw 1}); ->p73 : Promise ->p.then(() => Promise.resolve("1"), () => {throw 1}) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pb4 = p.then(() => Promise.resolve("1"), () => undefined); +>pb4 : Promise +>p.then(() => Promise.resolve("1"), () => undefined) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >() => Promise.resolve("1") : () => Promise >Promise.resolve("1") : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >"1" : "1" ->() => {throw 1} : () => never ->1 : 1 - -const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); ->p74 : Promise ->p.then(() => Promise.resolve("1"), () => Promise.resolve(1)) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => Promise.resolve("1") : () => Promise ->Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } ->Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } ->"1" : "1" ->() => Promise.resolve(1) : () => Promise ->Promise.resolve(1) : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } ->Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } ->1 : 1 - -const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); ->p75 : Promise ->p.then(() => Promise.resolve("1"), () => Promise.reject(1)) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => Promise.resolve("1") : () => Promise ->Promise.resolve("1") : Promise ->Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } ->Promise : PromiseConstructor ->resolve : { (value: T | PromiseLike): Promise; (): Promise; } ->"1" : "1" ->() => Promise.reject(1) : () => Promise ->Promise.reject(1) : Promise ->Promise.reject : { (reason: any): Promise; (reason: any): Promise; } ->Promise : PromiseConstructor ->reject : { (reason: any): Promise; (reason: any): Promise; } ->1 : 1 - -const p80 = p.then(() => Promise.reject(1), undefined); ->p80 : Promise ->p.then(() => Promise.reject(1), undefined) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => Promise.reject(1) : () => Promise ->Promise.reject(1) : Promise ->Promise.reject : { (reason: any): Promise; (reason: any): Promise; } ->Promise : PromiseConstructor ->reject : { (reason: any): Promise; (reason: any): Promise; } ->1 : 1 +>() => undefined : () => undefined >undefined : undefined -const p81 = p.then(() => Promise.reject(1), () => 1); ->p81 : Promise ->p.then(() => Promise.reject(1), () => 1) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pb5 = p.then(() => Promise.resolve("1"), () => null); +>pb5 : Promise +>p.then(() => Promise.resolve("1"), () => null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => Promise.reject(1) : () => Promise ->Promise.reject(1) : Promise ->Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor ->reject : { (reason: any): Promise; (reason: any): Promise; } ->1 : 1 ->() => 1 : () => 1 ->1 : 1 +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : "1" +>() => null : () => null +>null : null -const p82 = p.then(() => Promise.reject(1), () => {}); ->p82 : Promise ->p.then(() => Promise.reject(1), () => {}) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pb6 = p.then(() => Promise.resolve("1"), () => {}); +>pb6 : Promise +>p.then(() => Promise.resolve("1"), () => {}) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => Promise.reject(1) : () => Promise ->Promise.reject(1) : Promise ->Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor ->reject : { (reason: any): Promise; (reason: any): Promise; } ->1 : 1 +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : "1" >() => {} : () => void -const p83 = p.then(() => Promise.reject(1), () => {throw 1}); ->p83 : Promise ->p.then(() => Promise.reject(1), () => {throw 1}) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pb7 = p.then(() => Promise.resolve("1"), () => {throw 1}); +>pb7 : Promise +>p.then(() => Promise.resolve("1"), () => {throw 1}) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => Promise.reject(1) : () => Promise ->Promise.reject(1) : Promise ->Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor ->reject : { (reason: any): Promise; (reason: any): Promise; } ->1 : 1 +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : "1" >() => {throw 1} : () => never >1 : 1 -const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); ->p84 : Promise ->p.then(() => Promise.reject(1), () => Promise.resolve(1)) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pb8 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); +>pb8 : Promise +>p.then(() => Promise.resolve("1"), () => Promise.resolve(1)) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => Promise.reject(1) : () => Promise ->Promise.reject(1) : Promise ->Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor ->reject : { (reason: any): Promise; (reason: any): Promise; } ->1 : 1 +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : "1" >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } @@ -879,18 +1410,173 @@ const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >1 : 1 -const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1)); ->p85 : Promise ->p.then(() => Promise.reject(1), () => Promise.reject(1)) : Promise ->p.then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +const pb9 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); +>pb9 : Promise +>p.then(() => Promise.resolve("1"), () => Promise.reject(1)) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise >p : Promise ->then : { (onfulfilled?: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected?: ((reason: any) => boolean | PromiseLike) | null | undefined): Promise; (onfulfilled: ((value: boolean) => boolean | PromiseLike) | null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected?: ((reason: any) => TResult | PromiseLike) | null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } ->() => Promise.reject(1) : () => Promise ->Promise.reject(1) : Promise ->Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : "1" +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor >reject : { (reason: any): Promise; (reason: any): Promise; } >1 : 1 + +const pc0 = p.then(() => Promise.reject("1"), undefined); +>pc0 : Promise +>p.then(() => Promise.reject("1"), undefined) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" +>undefined : undefined + +const pc1 = p.then(() => Promise.reject("1"), null); +>pc1 : Promise +>p.then(() => Promise.reject("1"), null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" +>null : null + +const pc2 = p.then(() => Promise.reject("1"), () => 1); +>pc2 : Promise +>p.then(() => Promise.reject("1"), () => 1) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" +>() => 1 : () => number +>1 : 1 + +const pc3 = p.then(() => Promise.reject("1"), () => x); +>pc3 : Promise +>p.then(() => Promise.reject("1"), () => x) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" +>() => x : () => any +>x : any + +const pc4 = p.then(() => Promise.reject("1"), () => undefined); +>pc4 : Promise +>p.then(() => Promise.reject("1"), () => undefined) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" +>() => undefined : () => undefined +>undefined : undefined + +const pc5 = p.then(() => Promise.reject("1"), () => null); +>pc5 : Promise +>p.then(() => Promise.reject("1"), () => null) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" +>() => null : () => null +>null : null + +const pc6 = p.then(() => Promise.reject("1"), () => {}); +>pc6 : Promise +>p.then(() => Promise.reject("1"), () => {}) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" +>() => {} : () => void + +const pc7 = p.then(() => Promise.reject("1"), () => {throw 1}); +>pc7 : Promise +>p.then(() => Promise.reject("1"), () => {throw 1}) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" +>() => {throw 1} : () => never +>1 : 1 + +const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1)); +>pc8 : Promise +>p.then(() => Promise.reject("1"), () => Promise.resolve(1)) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : 1 + +const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1)); +>pc9 : Promise +>p.then(() => Promise.reject("1"), () => Promise.reject(1)) : Promise +>p.then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>p : Promise +>then : (onfulfilled?: ((value: boolean) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>() => Promise.reject("1") : () => Promise +>Promise.reject("1") : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>"1" : "1" >() => Promise.reject(1) : () => Promise >Promise.reject(1) : Promise >Promise.reject : { (reason: any): Promise; (reason: any): Promise; } diff --git a/tests/baselines/reference/promiseVoidErrorCallback.symbols b/tests/baselines/reference/promiseVoidErrorCallback.symbols index 67747f5f150..799fddc5616 100644 --- a/tests/baselines/reference/promiseVoidErrorCallback.symbols +++ b/tests/baselines/reference/promiseVoidErrorCallback.symbols @@ -22,12 +22,12 @@ interface T3 { function f1(): Promise { >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >T1 : Symbol(T1, Decl(promiseVoidErrorCallback.ts, 0, 0)) return Promise.resolve({ __t1: "foo_t1" }); >Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >__t1 : Symbol(__t1, Decl(promiseVoidErrorCallback.ts, 13, 28)) } @@ -47,12 +47,12 @@ function f2(x: T1): T2 { var x3 = f1() >x3 : Symbol(x3, Decl(promiseVoidErrorCallback.ts, 20, 3)) ->f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->f1() .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>f1() .then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) .then(f2, (e: Error) => { ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >f2 : Symbol(f2, Decl(promiseVoidErrorCallback.ts, 14, 1)) >e : Symbol(e, Decl(promiseVoidErrorCallback.ts, 21, 15)) >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) @@ -62,7 +62,7 @@ var x3 = f1() }) .then((x: T2) => { ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 24, 11)) >T2 : Symbol(T2, Decl(promiseVoidErrorCallback.ts, 2, 1)) diff --git a/tests/baselines/reference/promiseVoidErrorCallback.types b/tests/baselines/reference/promiseVoidErrorCallback.types index 65c9fd0b689..bd1b3a87c26 100644 --- a/tests/baselines/reference/promiseVoidErrorCallback.types +++ b/tests/baselines/reference/promiseVoidErrorCallback.types @@ -54,14 +54,14 @@ function f2(x: T1): T2 { var x3 = f1() >x3 : Promise<{ __t3: string; }> >f1() .then(f2, (e: Error) => { throw e;}) .then((x: T2) => { return { __t3: x.__t2 + "bar" };}) : Promise<{ __t3: string; }> ->f1() .then(f2, (e: Error) => { throw e;}) .then : { (onfulfilled?: (value: T2) => T2 | PromiseLike, onrejected?: (reason: any) => T2 | PromiseLike): Promise; (onfulfilled: (value: T2) => T2 | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: T2) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: T2) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>f1() .then(f2, (e: Error) => { throw e;}) .then : (onfulfilled?: (value: T2) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >f1() .then(f2, (e: Error) => { throw e;}) : Promise ->f1() .then : { (onfulfilled?: (value: T1) => T1 | PromiseLike, onrejected?: (reason: any) => T1 | PromiseLike): Promise; (onfulfilled: (value: T1) => T1 | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: T1) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: T1) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>f1() .then : (onfulfilled?: (value: T1) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >f1() : Promise >f1 : () => Promise .then(f2, (e: Error) => { ->then : { (onfulfilled?: (value: T1) => T1 | PromiseLike, onrejected?: (reason: any) => T1 | PromiseLike): Promise; (onfulfilled: (value: T1) => T1 | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: T1) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: T1) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: T1) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >f2 : (x: T1) => T2 >(e: Error) => { throw e;} : (e: Error) => never >e : Error @@ -72,7 +72,7 @@ var x3 = f1() }) .then((x: T2) => { ->then : { (onfulfilled?: (value: T2) => T2 | PromiseLike, onrejected?: (reason: any) => T2 | PromiseLike): Promise; (onfulfilled: (value: T2) => T2 | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: T2) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: T2) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>then : (onfulfilled?: (value: T2) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >(x: T2) => { return { __t3: x.__t2 + "bar" };} : (x: T2) => { __t3: string; } >x : T2 >T2 : T2 diff --git a/tests/baselines/reference/promises.symbols b/tests/baselines/reference/promises.symbols index 623a9cfb20a..19aa9b1450f 100644 --- a/tests/baselines/reference/promises.symbols +++ b/tests/baselines/reference/promises.symbols @@ -1,31 +1,31 @@ === tests/cases/compiler/promises.ts === interface Promise { ->Promise : Symbol(Promise, Decl(promises.ts, 0, 0)) ->T : Symbol(T, Decl(promises.ts, 0, 18)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promises.ts, 0, 0)) +>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(promises.ts, 0, 18)) then(success?: (value: T) => U): Promise; ->then : Symbol(Promise.then, Decl(promises.ts, 0, 22), Decl(promises.ts, 1, 51)) +>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promises.ts, 0, 22), Decl(promises.ts, 1, 51)) >U : Symbol(U, Decl(promises.ts, 1, 9)) >success : Symbol(success, Decl(promises.ts, 1, 12)) >value : Symbol(value, Decl(promises.ts, 1, 23)) ->T : Symbol(T, Decl(promises.ts, 0, 18)) +>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(promises.ts, 0, 18)) >U : Symbol(U, Decl(promises.ts, 1, 9)) ->Promise : Symbol(Promise, Decl(promises.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promises.ts, 0, 0)) >U : Symbol(U, Decl(promises.ts, 1, 9)) then(success?: (value: T) => Promise): Promise; ->then : Symbol(Promise.then, Decl(promises.ts, 0, 22), Decl(promises.ts, 1, 51)) +>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promises.ts, 0, 22), Decl(promises.ts, 1, 51)) >U : Symbol(U, Decl(promises.ts, 2, 9)) >success : Symbol(success, Decl(promises.ts, 2, 12)) >value : Symbol(value, Decl(promises.ts, 2, 23)) ->T : Symbol(T, Decl(promises.ts, 0, 18)) ->Promise : Symbol(Promise, Decl(promises.ts, 0, 0)) +>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(promises.ts, 0, 18)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promises.ts, 0, 0)) >U : Symbol(U, Decl(promises.ts, 2, 9)) ->Promise : Symbol(Promise, Decl(promises.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promises.ts, 0, 0)) >U : Symbol(U, Decl(promises.ts, 2, 9)) value: T; >value : Symbol(Promise.value, Decl(promises.ts, 2, 60)) ->T : Symbol(T, Decl(promises.ts, 0, 18)) +>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(promises.ts, 0, 18)) } diff --git a/tests/baselines/reference/promises.types b/tests/baselines/reference/promises.types index 639d28677d7..7d255a05ffb 100644 --- a/tests/baselines/reference/promises.types +++ b/tests/baselines/reference/promises.types @@ -4,7 +4,7 @@ interface Promise { >T : T then(success?: (value: T) => U): Promise; ->then : { (success?: (value: T) => U): Promise; (success?: (value: T) => Promise): Promise; } +>then : { (onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: T) => U): Promise; (success?: (value: T) => Promise): Promise; } >U : U >success : (value: T) => U >value : T @@ -14,7 +14,7 @@ interface Promise { >U : U then(success?: (value: T) => Promise): Promise; ->then : { (success?: (value: T) => U): Promise; (success?: (value: T) => Promise): Promise; } +>then : { (onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: T) => U): Promise; (success?: (value: T) => Promise): Promise; } >U : U >success : (value: T) => Promise >value : T diff --git a/tests/baselines/reference/promisesWithConstraints.symbols b/tests/baselines/reference/promisesWithConstraints.symbols index a180a26135c..edfe83e608c 100644 --- a/tests/baselines/reference/promisesWithConstraints.symbols +++ b/tests/baselines/reference/promisesWithConstraints.symbols @@ -1,17 +1,17 @@ === tests/cases/compiler/promisesWithConstraints.ts === interface Promise { ->Promise : Symbol(Promise, Decl(promisesWithConstraints.ts, 0, 0)) ->T : Symbol(T, Decl(promisesWithConstraints.ts, 0, 18)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promisesWithConstraints.ts, 0, 0)) +>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(promisesWithConstraints.ts, 0, 18)) then(cb: (x: T) => Promise): Promise; ->then : Symbol(Promise.then, Decl(promisesWithConstraints.ts, 0, 22)) +>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(promisesWithConstraints.ts, 0, 22)) >U : Symbol(U, Decl(promisesWithConstraints.ts, 1, 9)) >cb : Symbol(cb, Decl(promisesWithConstraints.ts, 1, 12)) >x : Symbol(x, Decl(promisesWithConstraints.ts, 1, 17)) ->T : Symbol(T, Decl(promisesWithConstraints.ts, 0, 18)) ->Promise : Symbol(Promise, Decl(promisesWithConstraints.ts, 0, 0)) +>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(promisesWithConstraints.ts, 0, 18)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promisesWithConstraints.ts, 0, 0)) >U : Symbol(U, Decl(promisesWithConstraints.ts, 1, 9)) ->Promise : Symbol(Promise, Decl(promisesWithConstraints.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promisesWithConstraints.ts, 0, 0)) >U : Symbol(U, Decl(promisesWithConstraints.ts, 1, 9)) } @@ -27,9 +27,9 @@ interface CPromise { >cb : Symbol(cb, Decl(promisesWithConstraints.ts, 5, 32)) >x : Symbol(x, Decl(promisesWithConstraints.ts, 5, 37)) >T : Symbol(T, Decl(promisesWithConstraints.ts, 4, 19)) ->Promise : Symbol(Promise, Decl(promisesWithConstraints.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promisesWithConstraints.ts, 0, 0)) >U : Symbol(U, Decl(promisesWithConstraints.ts, 5, 9)) ->Promise : Symbol(Promise, Decl(promisesWithConstraints.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promisesWithConstraints.ts, 0, 0)) >U : Symbol(U, Decl(promisesWithConstraints.ts, 5, 9)) } @@ -44,12 +44,12 @@ interface Bar { x; y; } var a: Promise; >a : Symbol(a, Decl(promisesWithConstraints.ts, 11, 3)) ->Promise : Symbol(Promise, Decl(promisesWithConstraints.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promisesWithConstraints.ts, 0, 0)) >Foo : Symbol(Foo, Decl(promisesWithConstraints.ts, 6, 1)) var b: Promise; >b : Symbol(b, Decl(promisesWithConstraints.ts, 12, 3)) ->Promise : Symbol(Promise, Decl(promisesWithConstraints.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(promisesWithConstraints.ts, 0, 0)) >Bar : Symbol(Bar, Decl(promisesWithConstraints.ts, 8, 20)) a = b; // ok diff --git a/tests/baselines/reference/promisesWithConstraints.types b/tests/baselines/reference/promisesWithConstraints.types index a8c4c64d3fd..a7f2d1e6787 100644 --- a/tests/baselines/reference/promisesWithConstraints.types +++ b/tests/baselines/reference/promisesWithConstraints.types @@ -4,7 +4,7 @@ interface Promise { >T : T then(cb: (x: T) => Promise): Promise; ->then : (cb: (x: T) => Promise) => Promise +>then : { (onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (cb: (x: T) => Promise): Promise; } >U : U >cb : (x: T) => Promise >x : T diff --git a/tests/baselines/reference/propertiesAndIndexers.js b/tests/baselines/reference/propertiesAndIndexers.js index dff86f3954e..2c678ba258f 100644 --- a/tests/baselines/reference/propertiesAndIndexers.js +++ b/tests/baselines/reference/propertiesAndIndexers.js @@ -52,11 +52,16 @@ var c: { }; //// [propertiesAndIndexers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var P = (function () { function P() { } @@ -65,7 +70,7 @@ var P = (function () { var Q = (function (_super) { __extends(Q, _super); function Q() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Q; }(P)); diff --git a/tests/baselines/reference/propertyAccess.js b/tests/baselines/reference/propertyAccess.js index 0a4c9082a21..5904d66c372 100644 --- a/tests/baselines/reference/propertyAccess.js +++ b/tests/baselines/reference/propertyAccess.js @@ -151,11 +151,16 @@ var x3: A; //// [propertyAccess.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -164,7 +169,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); diff --git a/tests/baselines/reference/propertyAccess4.errors.txt b/tests/baselines/reference/propertyAccess4.errors.txt index cdc772ba528..fc491d8c7a9 100644 --- a/tests/baselines/reference/propertyAccess4.errors.txt +++ b/tests/baselines/reference/propertyAccess4.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/propertyAccess4.ts(1,6): error TS2339: Property 'toBAZ' does not exist on type 'null'. +tests/cases/compiler/propertyAccess4.ts(1,1): error TS2531: Object is possibly 'null'. ==== tests/cases/compiler/propertyAccess4.ts (1 errors) ==== null.toBAZ(); - ~~~~~ -!!! error TS2339: Property 'toBAZ' does not exist on type 'null'. \ No newline at end of file + ~~~~ +!!! error TS2531: Object is possibly 'null'. \ No newline at end of file diff --git a/tests/baselines/reference/propertyAccess5.errors.txt b/tests/baselines/reference/propertyAccess5.errors.txt index 81c05c5342b..4f7e7f4bcd6 100644 --- a/tests/baselines/reference/propertyAccess5.errors.txt +++ b/tests/baselines/reference/propertyAccess5.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/propertyAccess5.ts(1,11): error TS2339: Property 'toBAZ' does not exist on type 'undefined'. +tests/cases/compiler/propertyAccess5.ts(1,1): error TS2532: Object is possibly 'undefined'. ==== tests/cases/compiler/propertyAccess5.ts (1 errors) ==== undefined.toBAZ(); - ~~~~~ -!!! error TS2339: Property 'toBAZ' does not exist on type 'undefined'. \ No newline at end of file + ~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/propertyAccessNumericLiterals.es6.js b/tests/baselines/reference/propertyAccessNumericLiterals.es6.js new file mode 100644 index 00000000000..66ac4178155 --- /dev/null +++ b/tests/baselines/reference/propertyAccessNumericLiterals.es6.js @@ -0,0 +1,14 @@ +//// [propertyAccessNumericLiterals.es6.ts] +0xffffffff.toString(); +0o01234.toString(); +0b01101101.toString(); +1234..toString(); +1e0.toString(); + + +//// [propertyAccessNumericLiterals.es6.js] +0xffffffff.toString(); +0o01234.toString(); +0b01101101.toString(); +1234..toString(); +1e0.toString(); diff --git a/tests/baselines/reference/propertyAccessNumericLiterals.es6.symbols b/tests/baselines/reference/propertyAccessNumericLiterals.es6.symbols new file mode 100644 index 00000000000..dc0be21d84f --- /dev/null +++ b/tests/baselines/reference/propertyAccessNumericLiterals.es6.symbols @@ -0,0 +1,21 @@ +=== tests/cases/conformance/es6/propertyAccess/propertyAccessNumericLiterals.es6.ts === +0xffffffff.toString(); +>0xffffffff.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) +>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) + +0o01234.toString(); +>0o01234.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) +>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) + +0b01101101.toString(); +>0b01101101.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) +>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) + +1234..toString(); +>1234..toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) +>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) + +1e0.toString(); +>1e0.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) +>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) + diff --git a/tests/baselines/reference/propertyAccessNumericLiterals.es6.types b/tests/baselines/reference/propertyAccessNumericLiterals.es6.types new file mode 100644 index 00000000000..9d32cc5b6e8 --- /dev/null +++ b/tests/baselines/reference/propertyAccessNumericLiterals.es6.types @@ -0,0 +1,31 @@ +=== tests/cases/conformance/es6/propertyAccess/propertyAccessNumericLiterals.es6.ts === +0xffffffff.toString(); +>0xffffffff.toString() : string +>0xffffffff.toString : (radix?: number) => string +>0xffffffff : 4294967295 +>toString : (radix?: number) => string + +0o01234.toString(); +>0o01234.toString() : string +>0o01234.toString : (radix?: number) => string +>0o01234 : 668 +>toString : (radix?: number) => string + +0b01101101.toString(); +>0b01101101.toString() : string +>0b01101101.toString : (radix?: number) => string +>0b01101101 : 109 +>toString : (radix?: number) => string + +1234..toString(); +>1234..toString() : string +>1234..toString : (radix?: number) => string +>1234. : 1234 +>toString : (radix?: number) => string + +1e0.toString(); +>1e0.toString() : string +>1e0.toString : (radix?: number) => string +>1e0 : 1 +>toString : (radix?: number) => string + diff --git a/tests/baselines/reference/propertyAccessNumericLiterals.js b/tests/baselines/reference/propertyAccessNumericLiterals.js new file mode 100644 index 00000000000..1a7eb6c0a21 --- /dev/null +++ b/tests/baselines/reference/propertyAccessNumericLiterals.js @@ -0,0 +1,15 @@ +//// [propertyAccessNumericLiterals.ts] +0xffffffff.toString(); +0o01234.toString(); +0b01101101.toString(); +1234..toString(); +1e0.toString(); +000.toString(); + +//// [propertyAccessNumericLiterals.js] +0xffffffff.toString(); +668..toString(); +109..toString(); +1234..toString(); +1e0.toString(); +000.toString(); diff --git a/tests/baselines/reference/propertyAccessNumericLiterals.symbols b/tests/baselines/reference/propertyAccessNumericLiterals.symbols new file mode 100644 index 00000000000..5be13615e90 --- /dev/null +++ b/tests/baselines/reference/propertyAccessNumericLiterals.symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/expressions/propertyAccess/propertyAccessNumericLiterals.ts === +0xffffffff.toString(); +>0xffffffff.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) + +0o01234.toString(); +>0o01234.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) + +0b01101101.toString(); +>0b01101101.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) + +1234..toString(); +>1234..toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) + +1e0.toString(); +>1e0.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) + +000.toString(); +>000.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/propertyAccessNumericLiterals.types b/tests/baselines/reference/propertyAccessNumericLiterals.types new file mode 100644 index 00000000000..a2567ff2537 --- /dev/null +++ b/tests/baselines/reference/propertyAccessNumericLiterals.types @@ -0,0 +1,37 @@ +=== tests/cases/conformance/expressions/propertyAccess/propertyAccessNumericLiterals.ts === +0xffffffff.toString(); +>0xffffffff.toString() : string +>0xffffffff.toString : (radix?: number) => string +>0xffffffff : 4294967295 +>toString : (radix?: number) => string + +0o01234.toString(); +>0o01234.toString() : string +>0o01234.toString : (radix?: number) => string +>0o01234 : 668 +>toString : (radix?: number) => string + +0b01101101.toString(); +>0b01101101.toString() : string +>0b01101101.toString : (radix?: number) => string +>0b01101101 : 109 +>toString : (radix?: number) => string + +1234..toString(); +>1234..toString() : string +>1234..toString : (radix?: number) => string +>1234. : 1234 +>toString : (radix?: number) => string + +1e0.toString(); +>1e0.toString() : string +>1e0.toString : (radix?: number) => string +>1e0 : 1 +>toString : (radix?: number) => string + +000.toString(); +>000.toString() : string +>000.toString : (radix?: number) => string +>000 : 0 +>toString : (radix?: number) => string + diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.js b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.js index d36d7e27efe..08e1a9ceb11 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.js +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.js @@ -83,11 +83,16 @@ var r4 = b.foo(aB, aB); // no inferences for T so constraint isn't satisfied, er //// [propertyAccessOnTypeParameterWithConstraints2.js] // generic types should behave as if they have properties of their constraint type -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -97,7 +102,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function () { return ''; diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.js b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.js index 4aedfe12b04..0d945197957 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.js +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.js @@ -58,11 +58,16 @@ var r4 = b.foo(new B()); // valid call to an invalid function //// [propertyAccessOnTypeParameterWithConstraints3.js] // generic types should behave as if they have properties of their constraint type -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -72,7 +77,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function () { return ''; diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.errors.txt b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.errors.txt index fd012d0e5a5..c1052dff554 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.errors.txt +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(15,32): error TS2339: Property 'notHere' does not exist on type 'U'. tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(25,16): error TS2339: Property 'notHere' does not exist on type 'B'. tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(32,22): error TS2339: Property 'notHere' does not exist on type 'A'. -tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(38,16): error TS2322: Type 'string' is not assignable to type 'U'. +tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(38,9): error TS2322: Type 'string' is not assignable to type 'U'. tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints5.ts(38,22): error TS2339: Property 'notHere' does not exist on type 'U'. @@ -50,7 +50,7 @@ tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOn foo: (x: U): U => { var a = x['foo'](); // should be string return a + x.notHere(); - ~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'U'. ~~~~~~~ !!! error TS2339: Property 'notHere' does not exist on type 'U'. diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.js b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.js index 3cb14438141..a7cc39b7f05 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.js +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints5.js @@ -45,11 +45,16 @@ var b = { var r4 = b.foo(new B()); // error after constraints above made illegal, doesn't matter //// [propertyAccessOnTypeParameterWithConstraints5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -59,7 +64,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function () { return ''; diff --git a/tests/baselines/reference/propertyAccessStringIndexSignature.errors.txt b/tests/baselines/reference/propertyAccessStringIndexSignature.errors.txt new file mode 100644 index 00000000000..d376551d91d --- /dev/null +++ b/tests/baselines/reference/propertyAccessStringIndexSignature.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/expressions/propertyAccess/propertyAccessStringIndexSignature.ts(10,7): error TS2339: Property 'nope' does not exist on type 'Empty'. + + +==== tests/cases/conformance/expressions/propertyAccess/propertyAccessStringIndexSignature.ts (1 errors) ==== + interface Flags { [name: string]: boolean }; + let flags: Flags; + flags.b; + flags.f; + flags.isNotNecessarilyNeverFalse; + flags['this is fine']; + + interface Empty { } + let empty: Empty; + empty.nope; + ~~~~ +!!! error TS2339: Property 'nope' does not exist on type 'Empty'. + empty["that's ok"]; + \ No newline at end of file diff --git a/tests/baselines/reference/propertyAccessStringIndexSignature.js b/tests/baselines/reference/propertyAccessStringIndexSignature.js new file mode 100644 index 00000000000..d37a8bfea0e --- /dev/null +++ b/tests/baselines/reference/propertyAccessStringIndexSignature.js @@ -0,0 +1,24 @@ +//// [propertyAccessStringIndexSignature.ts] +interface Flags { [name: string]: boolean }; +let flags: Flags; +flags.b; +flags.f; +flags.isNotNecessarilyNeverFalse; +flags['this is fine']; + +interface Empty { } +let empty: Empty; +empty.nope; +empty["that's ok"]; + + +//// [propertyAccessStringIndexSignature.js] +; +var flags; +flags.b; +flags.f; +flags.isNotNecessarilyNeverFalse; +flags['this is fine']; +var empty; +empty.nope; +empty["that's ok"]; diff --git a/tests/baselines/reference/propertyAccessStringIndexSignatureNoImplicitAny.errors.txt b/tests/baselines/reference/propertyAccessStringIndexSignatureNoImplicitAny.errors.txt new file mode 100644 index 00000000000..d5fda181096 --- /dev/null +++ b/tests/baselines/reference/propertyAccessStringIndexSignatureNoImplicitAny.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/expressions/propertyAccess/propertyAccessStringIndexSignatureNoImplicitAny.ts(10,7): error TS2339: Property 'nope' does not exist on type 'Empty'. +tests/cases/conformance/expressions/propertyAccess/propertyAccessStringIndexSignatureNoImplicitAny.ts(11,1): error TS7017: Element implicitly has an 'any' type because type 'Empty' has no index signature. + + +==== tests/cases/conformance/expressions/propertyAccess/propertyAccessStringIndexSignatureNoImplicitAny.ts (2 errors) ==== + interface Flags { [name: string]: boolean } + let flags: Flags; + flags.b; + flags.f; + flags.isNotNecessarilyNeverFalse; + flags['this is fine']; + + interface Empty { } + let empty: Empty; + empty.nope; + ~~~~ +!!! error TS2339: Property 'nope' does not exist on type 'Empty'. + empty["not allowed either"]; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7017: Element implicitly has an 'any' type because type 'Empty' has no index signature. + \ No newline at end of file diff --git a/tests/baselines/reference/propertyAccessStringIndexSignatureNoImplicitAny.js b/tests/baselines/reference/propertyAccessStringIndexSignatureNoImplicitAny.js new file mode 100644 index 00000000000..3c2abcc182b --- /dev/null +++ b/tests/baselines/reference/propertyAccessStringIndexSignatureNoImplicitAny.js @@ -0,0 +1,23 @@ +//// [propertyAccessStringIndexSignatureNoImplicitAny.ts] +interface Flags { [name: string]: boolean } +let flags: Flags; +flags.b; +flags.f; +flags.isNotNecessarilyNeverFalse; +flags['this is fine']; + +interface Empty { } +let empty: Empty; +empty.nope; +empty["not allowed either"]; + + +//// [propertyAccessStringIndexSignatureNoImplicitAny.js] +var flags; +flags.b; +flags.f; +flags.isNotNecessarilyNeverFalse; +flags['this is fine']; +var empty; +empty.nope; +empty["not allowed either"]; diff --git a/tests/baselines/reference/propertyIdentityWithPrivacyMismatch.js b/tests/baselines/reference/propertyIdentityWithPrivacyMismatch.js index f62acb89dfd..457f929fe62 100644 --- a/tests/baselines/reference/propertyIdentityWithPrivacyMismatch.js +++ b/tests/baselines/reference/propertyIdentityWithPrivacyMismatch.js @@ -31,6 +31,7 @@ var y: Foo2; //// [propertyIdentityWithPrivacyMismatch_1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var x; var x; // Should be error (mod1.Foo !== mod2.Foo) var Foo1 = (function () { diff --git a/tests/baselines/reference/propertyNamedPrototype.errors.txt b/tests/baselines/reference/propertyNamedPrototype.errors.txt new file mode 100644 index 00000000000..d80e1c95c8d --- /dev/null +++ b/tests/baselines/reference/propertyNamedPrototype.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/propertyNamedPrototype.ts(3,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/propertyNamedPrototype.ts (1 errors) ==== + class C { + prototype: number; // ok + static prototype: C; // error + ~~~~~~~~~ +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. + } \ No newline at end of file diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass.js b/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass.js index 429dfdf6b14..47d329909fd 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass.js +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass.js @@ -39,11 +39,16 @@ class E extends C { } //// [protectedClassPropertyAccessibleWithinNestedSubclass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B() { } @@ -52,7 +57,7 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(C.prototype, "y", { get: function () { return this.x; }, @@ -93,7 +98,7 @@ var C = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return E; }(C)); diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass1.js b/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass1.js index 0571b85ea9e..8273b7e31bd 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass1.js +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedSubclass1.js @@ -115,11 +115,16 @@ d3.x; // Error, neither within their declaring class nor class d4.x; // Error, neither within their declaring class nor classes derived from their declaring class //// [protectedClassPropertyAccessibleWithinNestedSubclass1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -147,7 +152,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.prototype.method1 = function () { var B = (function () { @@ -173,7 +178,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived2.prototype.method2 = function () { var C = (function () { @@ -199,7 +204,7 @@ var Derived2 = (function (_super) { var Derived3 = (function (_super) { __extends(Derived3, _super); function Derived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived3.prototype.method3 = function () { var D = (function () { @@ -225,7 +230,7 @@ var Derived3 = (function (_super) { var Derived4 = (function (_super) { __extends(Derived4, _super); function Derived4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived4.prototype.method4 = function () { var E = (function () { diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js index a10b39b402e..a2d35914cbe 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js @@ -21,11 +21,16 @@ class C extends B { //// [protectedClassPropertyAccessibleWithinSubclass.js] // no errors -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B() { } @@ -34,7 +39,7 @@ var B = (function () { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(C.prototype, "y", { get: function () { return this.x; }, diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.js b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.js index a404b8049bc..7a9ee9f2268 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.js +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass2.js @@ -95,11 +95,16 @@ d3.x; // Error, neither within their declaring class nor class d4.x; // Error, neither within their declaring class nor classes derived from their declaring class //// [protectedClassPropertyAccessibleWithinSubclass2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -120,7 +125,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.prototype.method1 = function () { var b; @@ -139,7 +144,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived2.prototype.method2 = function () { var b; @@ -158,7 +163,7 @@ var Derived2 = (function (_super) { var Derived3 = (function (_super) { __extends(Derived3, _super); function Derived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived3.prototype.method3 = function () { var b; @@ -177,7 +182,7 @@ var Derived3 = (function (_super) { var Derived4 = (function (_super) { __extends(Derived4, _super); function Derived4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived4.prototype.method4 = function () { var b; diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.js b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.js index 7d449bdcbd4..2b9faf6282c 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.js +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.js @@ -14,11 +14,16 @@ class Derived extends Base { } //// [protectedClassPropertyAccessibleWithinSubclass3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -30,7 +35,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.prototype.method1 = function () { this.x; // OK, accessed within a subclass of the declaring class diff --git a/tests/baselines/reference/protectedInstanceMemberAccessibility.js b/tests/baselines/reference/protectedInstanceMemberAccessibility.js index 3259d401270..6617636aa45 100644 --- a/tests/baselines/reference/protectedInstanceMemberAccessibility.js +++ b/tests/baselines/reference/protectedInstanceMemberAccessibility.js @@ -45,11 +45,16 @@ class C extends A { //// [protectedInstanceMemberAccessibility.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -61,7 +66,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.g = function () { var t1 = this.x; @@ -93,7 +98,7 @@ var B = (function (_super) { var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/protectedMembers.js b/tests/baselines/reference/protectedMembers.js index 46b4691dff7..7684ff8e658 100644 --- a/tests/baselines/reference/protectedMembers.js +++ b/tests/baselines/reference/protectedMembers.js @@ -116,11 +116,16 @@ class B3 extends A3 { //// [protectedMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // Class with protected members var C1 = (function () { function C1() { @@ -137,7 +142,7 @@ var C1 = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C2.prototype.f = function () { return _super.prototype.f.call(this) + this.x; @@ -151,7 +156,7 @@ var C2 = (function (_super) { var C3 = (function (_super) { __extends(C3, _super); function C3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C3.prototype.f = function () { return _super.prototype.f.call(this); @@ -187,14 +192,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } C.foo = function (a, b, c, d, e) { a.x = 1; // Error, access must be through C or type derived from C @@ -208,7 +213,7 @@ var C = (function (_super) { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); @@ -239,7 +244,7 @@ var A2 = (function () { var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A2)); @@ -252,7 +257,7 @@ var A3 = (function () { var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A3)); diff --git a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass.js b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass.js index ad1b1682aa7..238c0dc2384 100644 --- a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass.js +++ b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass.js @@ -44,11 +44,16 @@ Derived2.x; // Error, neither within their declaring class nor classes deriv Derived3.x; // Error, neither within their declaring class nor classes derived from their declaring class //// [protectedStaticClassPropertyAccessibleWithinSubclass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -63,7 +68,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.staticMethod1 = function () { Base.x; // OK, accessed within a class derived from their declaring class @@ -76,7 +81,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived2.staticMethod2 = function () { Base.x; // OK, accessed within a class derived from their declaring class @@ -89,7 +94,7 @@ var Derived2 = (function (_super) { var Derived3 = (function (_super) { __extends(Derived3, _super); function Derived3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived3.staticMethod3 = function () { Base.x; // OK, accessed within a class derived from their declaring class diff --git a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.js b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.js index a2346b8be40..969b7ebd7dc 100644 --- a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.js +++ b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.js @@ -22,11 +22,16 @@ class Derived2 extends Derived1 { } //// [protectedStaticClassPropertyAccessibleWithinSubclass2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -38,7 +43,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.staticMethod1 = function () { this.x; // OK, accessed within a class derived from their declaring class @@ -49,7 +54,7 @@ var Derived1 = (function (_super) { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived2.staticMethod3 = function () { this.x; // OK, accessed within a class derived from their declaring class diff --git a/tests/baselines/reference/protoAsIndexInIndexExpression.js b/tests/baselines/reference/protoAsIndexInIndexExpression.js index 2c9b0f7a7c7..7805cebbee3 100644 --- a/tests/baselines/reference/protoAsIndexInIndexExpression.js +++ b/tests/baselines/reference/protoAsIndexInIndexExpression.js @@ -21,6 +21,7 @@ class C { //// [protoAsIndexInIndexExpression_0.js] "use strict"; +exports.__esModule = true; //// [protoAsIndexInIndexExpression_1.js] /// var EntityPrototype = undefined; diff --git a/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.js b/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.js index a881eb55a18..f7b49b4219a 100644 --- a/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.js +++ b/tests/baselines/reference/qualifiedName_entity-name-resolution-does-not-affect-class-heritage.js @@ -7,11 +7,16 @@ class Beta extends Alpha.x { } //// [qualifiedName_entity-name-resolution-does-not-affect-class-heritage.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Alpha; (function (Alpha) { Alpha.x = 100; @@ -19,7 +24,7 @@ var Alpha; var Beta = (function (_super) { __extends(Beta, _super); function Beta() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Beta; }(Alpha.x)); diff --git a/tests/baselines/reference/reExportDefaultExport.js b/tests/baselines/reference/reExportDefaultExport.js index da50a3a7115..cd306e411d5 100644 --- a/tests/baselines/reference/reExportDefaultExport.js +++ b/tests/baselines/reference/reExportDefaultExport.js @@ -16,13 +16,14 @@ foo(); //// [m1.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); function f() { } -Object.defineProperty(exports, "__esModule", { value: true }); exports.default = f; exports.f = f; //// [m2.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var m1_1 = require("./m1"); var m1_2 = require("./m1"); m1_2.f(); diff --git a/tests/baselines/reference/reExportGlobalDeclaration1.js b/tests/baselines/reference/reExportGlobalDeclaration1.js index c0db9a0eaf3..9ab432fd084 100644 --- a/tests/baselines/reference/reExportGlobalDeclaration1.js +++ b/tests/baselines/reference/reExportGlobalDeclaration1.js @@ -22,3 +22,4 @@ export {b as b2}; //// [file2.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/reExportGlobalDeclaration2.js b/tests/baselines/reference/reExportGlobalDeclaration2.js index 160a9b28f54..52e55bb18c4 100644 --- a/tests/baselines/reference/reExportGlobalDeclaration2.js +++ b/tests/baselines/reference/reExportGlobalDeclaration2.js @@ -18,3 +18,4 @@ export {I2 as III2}; //// [file2.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/reExportGlobalDeclaration3.js b/tests/baselines/reference/reExportGlobalDeclaration3.js index e1b85b6b8d5..ed111b42197 100644 --- a/tests/baselines/reference/reExportGlobalDeclaration3.js +++ b/tests/baselines/reference/reExportGlobalDeclaration3.js @@ -18,3 +18,4 @@ export {NS2 as NNNS2}; //// [file2.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/reExportGlobalDeclaration4.js b/tests/baselines/reference/reExportGlobalDeclaration4.js index 09d6b760790..a7a0e7525ca 100644 --- a/tests/baselines/reference/reExportGlobalDeclaration4.js +++ b/tests/baselines/reference/reExportGlobalDeclaration4.js @@ -18,3 +18,4 @@ export {Cls2 as CCCls2}; //// [file2.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/reExportUndefined1.js b/tests/baselines/reference/reExportUndefined1.js index 94729e4f544..7540901fa30 100644 --- a/tests/baselines/reference/reExportUndefined1.js +++ b/tests/baselines/reference/reExportUndefined1.js @@ -4,3 +4,4 @@ export { undefined }; //// [a.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/reExportUndefined2.js b/tests/baselines/reference/reExportUndefined2.js index 53b78599cbe..bde88442b33 100644 --- a/tests/baselines/reference/reExportUndefined2.js +++ b/tests/baselines/reference/reExportUndefined2.js @@ -12,9 +12,11 @@ use(undefined); //// [a.js] "use strict"; +exports.__esModule = true; var undefined; exports.undefined = undefined; //// [b.js] "use strict"; +exports.__esModule = true; var a_1 = require("./a"); use(a_1.undefined); diff --git a/tests/baselines/reference/reactImportDropped.js b/tests/baselines/reference/reactImportDropped.js new file mode 100644 index 00000000000..7ada76b42f4 --- /dev/null +++ b/tests/baselines/reference/reactImportDropped.js @@ -0,0 +1,48 @@ +//// [tests/cases/compiler/reactImportDropped.ts] //// + +//// [react.d.ts] + +export = React; +export as namespace React; + +declare namespace React { + + function createClass(spec: any): ClassicComponentClass; + + interface ClassicComponentClass { + new (props?: any): ClassicComponentClass; + } +} + +declare global { + namespace JSX { + interface ElementAttributesProperty { } + } +} + + +//// [TabBar.js] +export default React.createClass({ + render() { + return ( + null + ); + } +}); + +//// [NavigationView.js] +import TabBar from '../../components/TabBar'; +import {layout} from '../../utils/theme'; // <- DO NOT DROP this import +const x = ; + + +//// [TabBar.js] +export default React.createClass({ + render() { + return (null); + } +}); +//// [NavigationView.js] +import TabBar from '../../components/TabBar'; +import { layout } from '../../utils/theme'; // <- DO NOT DROP this import +const x = React.createElement(TabBar, { height: layout.footerHeight }); diff --git a/tests/baselines/reference/reactImportDropped.symbols b/tests/baselines/reference/reactImportDropped.symbols new file mode 100644 index 00000000000..0daa49353fa --- /dev/null +++ b/tests/baselines/reference/reactImportDropped.symbols @@ -0,0 +1,65 @@ +=== tests/cases/compiler/react.d.ts === + +export = React; +>React : Symbol(React, Decl(react.d.ts, 2, 26)) + +export as namespace React; +>React : Symbol(React, Decl(react.d.ts, 1, 15)) + +declare namespace React { +>React : Symbol(React, Decl(react.d.ts, 2, 26)) + + function createClass(spec: any): ClassicComponentClass; +>createClass : Symbol(createClass, Decl(react.d.ts, 4, 25)) +>spec : Symbol(spec, Decl(react.d.ts, 6, 25)) +>ClassicComponentClass : Symbol(ClassicComponentClass, Decl(react.d.ts, 6, 59)) + + interface ClassicComponentClass { +>ClassicComponentClass : Symbol(ClassicComponentClass, Decl(react.d.ts, 6, 59)) + + new (props?: any): ClassicComponentClass; +>props : Symbol(props, Decl(react.d.ts, 9, 13)) +>ClassicComponentClass : Symbol(ClassicComponentClass, Decl(react.d.ts, 6, 59)) + } +} + +declare global { +>global : Symbol(global, Decl(react.d.ts, 11, 1)) + + namespace JSX { +>JSX : Symbol(JSX, Decl(react.d.ts, 13, 16)) + + interface ElementAttributesProperty { } +>ElementAttributesProperty : Symbol(ElementAttributesProperty, Decl(react.d.ts, 14, 19)) + } +} + + +=== tests/cases/compiler/src/components/TabBar.js === +export default React.createClass({ +>React.createClass : Symbol(React.createClass, Decl(react.d.ts, 4, 25)) +>React : Symbol(React, Decl(react.d.ts, 1, 15)) +>createClass : Symbol(React.createClass, Decl(react.d.ts, 4, 25)) + + render() { +>render : Symbol(render, Decl(TabBar.js, 0, 34)) + + return ( + null + ); + } +}); + +=== tests/cases/compiler/src/modules/navigation/NavigationView.js === +import TabBar from '../../components/TabBar'; +>TabBar : Symbol(TabBar, Decl(NavigationView.js, 0, 6)) + +import {layout} from '../../utils/theme'; // <- DO NOT DROP this import +>layout : Symbol(layout, Decl(NavigationView.js, 1, 8)) + +const x = ; +>x : Symbol(x, Decl(NavigationView.js, 2, 5)) +>TabBar : Symbol(TabBar, Decl(NavigationView.js, 0, 6)) +>height : Symbol(height, Decl(NavigationView.js, 2, 17)) +>layout : Symbol(layout, Decl(NavigationView.js, 1, 8)) + diff --git a/tests/baselines/reference/reactImportDropped.types b/tests/baselines/reference/reactImportDropped.types new file mode 100644 index 00000000000..36f1a6a4779 --- /dev/null +++ b/tests/baselines/reference/reactImportDropped.types @@ -0,0 +1,74 @@ +=== tests/cases/compiler/react.d.ts === + +export = React; +>React : typeof React + +export as namespace React; +>React : typeof React + +declare namespace React { +>React : typeof React + + function createClass(spec: any): ClassicComponentClass; +>createClass : (spec: any) => ClassicComponentClass +>spec : any +>ClassicComponentClass : ClassicComponentClass + + interface ClassicComponentClass { +>ClassicComponentClass : ClassicComponentClass + + new (props?: any): ClassicComponentClass; +>props : any +>ClassicComponentClass : ClassicComponentClass + } +} + +declare global { +>global : any + + namespace JSX { +>JSX : any + + interface ElementAttributesProperty { } +>ElementAttributesProperty : ElementAttributesProperty + } +} + + +=== tests/cases/compiler/src/components/TabBar.js === +export default React.createClass({ +>React.createClass({ render() { return ( null ); }}) : React.ClassicComponentClass +>React.createClass : (spec: any) => React.ClassicComponentClass +>React : typeof React +>createClass : (spec: any) => React.ClassicComponentClass +>{ render() { return ( null ); }} : { render(): any; } + + render() { +>render : () => any + + return ( +>( null ) : null + + null +>null : null + + ); + } +}); + +=== tests/cases/compiler/src/modules/navigation/NavigationView.js === +import TabBar from '../../components/TabBar'; +>TabBar : React.ClassicComponentClass + +import {layout} from '../../utils/theme'; // <- DO NOT DROP this import +>layout : any + +const x = ; +>x : any +> : any +>TabBar : React.ClassicComponentClass +>height : any +>layout.footerHeight : any +>layout : any +>footerHeight : any + diff --git a/tests/baselines/reference/reactNamespaceImportPresevation.js b/tests/baselines/reference/reactNamespaceImportPresevation.js index 5c44674d031..682dd0f7882 100644 --- a/tests/baselines/reference/reactNamespaceImportPresevation.js +++ b/tests/baselines/reference/reactNamespaceImportPresevation.js @@ -16,5 +16,6 @@ declare var foo: any; //// [test.jsx] "use strict"; +exports.__esModule = true; var myReactLib = require("my-React-Lib"); // should not be elided ; diff --git a/tests/baselines/reference/reactNamespaceImportPresevation.symbols b/tests/baselines/reference/reactNamespaceImportPresevation.symbols index e2f530d31ba..caeca7cefcb 100644 --- a/tests/baselines/reference/reactNamespaceImportPresevation.symbols +++ b/tests/baselines/reference/reactNamespaceImportPresevation.symbols @@ -17,5 +17,5 @@ declare var foo: any; ; >foo : Symbol(unknown) ->data : Symbol(unknown) +>data : Symbol(data, Decl(test.tsx, 3, 4)) diff --git a/tests/baselines/reference/reactNamespaceImportPresevation.types b/tests/baselines/reference/reactNamespaceImportPresevation.types index adb1d60d2d5..931a86d248d 100644 --- a/tests/baselines/reference/reactNamespaceImportPresevation.types +++ b/tests/baselines/reference/reactNamespaceImportPresevation.types @@ -18,5 +18,5 @@ declare var foo: any; ; > : any >foo : any ->data : any +>data : true diff --git a/tests/baselines/reference/reactNamespaceJSXEmit.symbols b/tests/baselines/reference/reactNamespaceJSXEmit.symbols index 3ca5b91e538..55aae09776c 100644 --- a/tests/baselines/reference/reactNamespaceJSXEmit.symbols +++ b/tests/baselines/reference/reactNamespaceJSXEmit.symbols @@ -14,11 +14,11 @@ declare var x: any; ; >foo : Symbol(unknown) ->data : Symbol(unknown) +>data : Symbol(data, Decl(reactNamespaceJSXEmit.tsx, 6, 4)) ; >Bar : Symbol(Bar, Decl(reactNamespaceJSXEmit.tsx, 3, 11)) ->x : Symbol(unknown) +>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 7, 4)) >x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11)) ; @@ -31,5 +31,5 @@ declare var x: any; ; >Bar : Symbol(Bar, Decl(reactNamespaceJSXEmit.tsx, 3, 11)) >x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11)) ->y : Symbol(unknown) +>y : Symbol(y, Decl(reactNamespaceJSXEmit.tsx, 10, 13)) diff --git a/tests/baselines/reference/reactNamespaceJSXEmit.types b/tests/baselines/reference/reactNamespaceJSXEmit.types index d2bd88e8fbd..0f6fbd68309 100644 --- a/tests/baselines/reference/reactNamespaceJSXEmit.types +++ b/tests/baselines/reference/reactNamespaceJSXEmit.types @@ -15,7 +15,7 @@ declare var x: any; ; > : any >foo : any ->data : any +>data : true ; > : any @@ -36,6 +36,6 @@ declare var x: any; > : any >Bar : any >x : any ->y : any +>y : number >2 : 2 diff --git a/tests/baselines/reference/readonlyConstructorAssignment.js b/tests/baselines/reference/readonlyConstructorAssignment.js index 872c00486c0..bb4ddec93a8 100644 --- a/tests/baselines/reference/readonlyConstructorAssignment.js +++ b/tests/baselines/reference/readonlyConstructorAssignment.js @@ -41,11 +41,16 @@ class E extends D { //// [readonlyConstructorAssignment.js] // Tests that readonly parameter properties behave like regular readonly properties -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(x) { this.x = x; diff --git a/tests/baselines/reference/recursiveBaseCheck3.js b/tests/baselines/reference/recursiveBaseCheck3.js index 250a9e0b618..a9ea849cea0 100644 --- a/tests/baselines/reference/recursiveBaseCheck3.js +++ b/tests/baselines/reference/recursiveBaseCheck3.js @@ -5,22 +5,27 @@ class C extends A { } (new C).blah; //// [recursiveBaseCheck3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function (_super) { __extends(A, _super); function A() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return A; }(C)); var C = (function (_super) { __extends(C, _super); function C() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C; }(A)); diff --git a/tests/baselines/reference/recursiveBaseCheck4.js b/tests/baselines/reference/recursiveBaseCheck4.js index 7f0c6b5f95d..7b0be057441 100644 --- a/tests/baselines/reference/recursiveBaseCheck4.js +++ b/tests/baselines/reference/recursiveBaseCheck4.js @@ -3,15 +3,20 @@ class M extends M { } (new M).blah; //// [recursiveBaseCheck4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M = (function (_super) { __extends(M, _super); function M() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return M; }(M)); diff --git a/tests/baselines/reference/recursiveBaseCheck6.js b/tests/baselines/reference/recursiveBaseCheck6.js index 53a608baeca..6e639130839 100644 --- a/tests/baselines/reference/recursiveBaseCheck6.js +++ b/tests/baselines/reference/recursiveBaseCheck6.js @@ -3,15 +3,20 @@ class S18 extends S18<{ S19: A; }>{ } (new S18()).blah; //// [recursiveBaseCheck6.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var S18 = (function (_super) { __extends(S18, _super); function S18() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return S18; }(S18)); diff --git a/tests/baselines/reference/recursiveBaseConstructorCreation1.js b/tests/baselines/reference/recursiveBaseConstructorCreation1.js index 344750974cb..c8507944ed7 100644 --- a/tests/baselines/reference/recursiveBaseConstructorCreation1.js +++ b/tests/baselines/reference/recursiveBaseConstructorCreation1.js @@ -7,11 +7,16 @@ var x = new C2(); // Valid //// [recursiveBaseConstructorCreation1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C1 = (function () { function C1() { } @@ -21,7 +26,7 @@ var C1 = (function () { var C2 = (function (_super) { __extends(C2, _super); function C2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return C2; }(C1)); diff --git a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js index 34aa110b7ee..704c39891e6 100644 --- a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js +++ b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js @@ -10,11 +10,16 @@ export class MemberNameArray extends MemberName { //// [recursiveClassInstantiationsWithDefaultConstructors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var a = new TypeScript2.MemberNameArray(); var TypeScript2; (function (TypeScript2) { @@ -28,7 +33,7 @@ var TypeScript2; var MemberNameArray = (function (_super) { __extends(MemberNameArray, _super); function MemberNameArray() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return MemberNameArray; }(MemberName)); diff --git a/tests/baselines/reference/recursiveClassReferenceTest.js b/tests/baselines/reference/recursiveClassReferenceTest.js index a2cf3319474..2d44740ac73 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.js +++ b/tests/baselines/reference/recursiveClassReferenceTest.js @@ -105,11 +105,16 @@ module Sample.Thing.Languages.PlainText { //// [recursiveClassReferenceTest.js] // Scenario 1: Test reqursive function call with "this" parameter // Scenario 2: Test recursive function call with cast and "this" parameter -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Sample; (function (Sample) { var Actions; @@ -188,7 +193,7 @@ var AbstractMode = (function () { var Mode = (function (_super) { __extends(Mode, _super); function Mode() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } // scenario 2 Mode.prototype.getInitialState = function () { diff --git a/tests/baselines/reference/recursiveClassReferenceTest.js.map b/tests/baselines/reference/recursiveClassReferenceTest.js.map index 0b9bb8281bc..b27f18ddffa 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.js.map +++ b/tests/baselines/reference/recursiveClassReferenceTest.js.map @@ -1,2 +1,2 @@ //// [recursiveClassReferenceTest.js.map] -{"version":3,"file":"recursiveClassReferenceTest.js","sourceRoot":"","sources":["recursiveClassReferenceTest.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,0EAA0E;;;;;;AA8B1E,IAAO,MAAM,CAUZ;AAVD,WAAO,MAAM;IAAC,IAAA,OAAO,CAUpB;IAVa,WAAA,OAAO;QAAC,IAAA,KAAK,CAU1B;QAVqB,WAAA,OAAK;YAAC,IAAA,IAAI,CAU/B;YAV2B,WAAA,IAAI;gBAC/B;oBAAA;oBAQA,CAAC;oBANO,+BAAK,GAAZ,cAAiB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;oBAExB,6BAAG,GAAV,UAAW,KAA6B;wBAEvC,MAAM,CAAC,IAAI,CAAC;oBACb,CAAC;oBACF,sBAAC;gBAAD,CAAC,AARD,IAQC;gBARY,oBAAe,kBAQ3B,CAAA;YACF,CAAC,EAV2B,IAAI,GAAJ,YAAI,KAAJ,YAAI,QAU/B;QAAD,CAAC,EAVqB,KAAK,GAAL,aAAK,KAAL,aAAK,QAU1B;IAAD,CAAC,EAVa,OAAO,GAAP,cAAO,KAAP,cAAO,QAUpB;AAAD,CAAC,EAVM,MAAM,KAAN,MAAM,QAUZ;AAED,WAAO,MAAM;IAAC,IAAA,KAAK,CAoBlB;IApBa,WAAA,KAAK;QAAC,IAAA,OAAO,CAoB1B;QApBmB,WAAA,OAAO;YAC1B;gBAKC,oBAAoB,SAAkC;oBAAlC,cAAS,GAAT,SAAS,CAAyB;oBAD9C,YAAO,GAAO,IAAI,CAAC;oBAEvB,aAAa;oBACb,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBAC3C,CAAC;gBANM,wBAAG,GAAV,UAAW,MAAyC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;oBAAA,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAAA,CAAC,CAAA,CAAC;gBAQlF,+BAAU,GAAjB;oBACC,MAAM,CAAC,OAAO,CAAC;gBAChB,CAAC;gBAEM,4BAAO,GAAd;gBAEA,CAAC;gBAEF,iBAAC;YAAD,CAAC,AAlBD,IAkBC;YAlBY,kBAAU,aAkBtB,CAAA;QACF,CAAC,EApBmB,OAAO,GAAP,aAAO,KAAP,aAAO,QAoB1B;IAAD,CAAC,EApBa,KAAK,GAAL,YAAK,KAAL,YAAK,QAoBlB;AAAD,CAAC,EApBM,MAAM,KAAN,MAAM,QAoBZ;AAGD;IAAA;IAAuF,CAAC;IAA3C,sCAAe,GAAtB,cAAmC,MAAM,CAAC,IAAI,CAAC,CAAA,CAAC;IAAC,mBAAC;AAAD,CAAC,AAAxF,IAAwF;AASxF,WAAO,MAAM;IAAC,IAAA,KAAK,CAwBlB;IAxBa,WAAA,KAAK;QAAC,IAAA,SAAS,CAwB5B;QAxBmB,WAAA,SAAS;YAAC,IAAA,SAAS,CAwBtC;YAxB6B,WAAA,SAAS;gBAEtC;oBACO,eAAoB,IAAW;wBAAX,SAAI,GAAJ,IAAI,CAAO;oBAAI,CAAC;oBACnC,qBAAK,GAAZ;wBACC,MAAM,CAAC,IAAI,CAAC;oBACb,CAAC;oBAEM,sBAAM,GAAb,UAAc,KAAY;wBACzB,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC;oBACvB,CAAC;oBAEM,uBAAO,GAAd,cAA0B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;oBACzC,YAAC;gBAAD,CAAC,AAXD,IAWC;gBAXY,eAAK,QAWjB,CAAA;gBAED;oBAA0B,wBAAY;oBAAtC;;oBAQA,CAAC;oBANA,aAAa;oBACN,8BAAe,GAAtB;wBACC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;oBACxB,CAAC;oBAGF,WAAC;gBAAD,CAAC,AARD,CAA0B,YAAY,GAQrC;gBARY,cAAI,OAQhB,CAAA;YACF,CAAC,EAxB6B,SAAS,GAAT,mBAAS,KAAT,mBAAS,QAwBtC;QAAD,CAAC,EAxBmB,SAAS,GAAT,eAAS,KAAT,eAAS,QAwB5B;IAAD,CAAC,EAxBa,KAAK,GAAL,YAAK,KAAL,YAAK,QAwBlB;AAAD,CAAC,EAxBM,MAAM,KAAN,MAAM,QAwBZ"} \ No newline at end of file +{"version":3,"file":"recursiveClassReferenceTest.js","sourceRoot":"","sources":["recursiveClassReferenceTest.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,0EAA0E;;;;;;;;;;;AA8B1E,IAAO,MAAM,CAUZ;AAVD,WAAO,MAAM;IAAC,IAAA,OAAO,CAUpB;IAVa,WAAA,OAAO;QAAC,IAAA,KAAK,CAU1B;QAVqB,WAAA,OAAK;YAAC,IAAA,IAAI,CAU/B;YAV2B,WAAA,IAAI;gBAC/B;oBAAA;oBAQA,CAAC;oBANO,+BAAK,GAAZ,cAAiB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;oBAExB,6BAAG,GAAV,UAAW,KAA6B;wBAEvC,MAAM,CAAC,IAAI,CAAC;oBACb,CAAC;oBACF,sBAAC;gBAAD,CAAC,AARD,IAQC;gBARY,oBAAe,kBAQ3B,CAAA;YACF,CAAC,EAV2B,IAAI,GAAJ,YAAI,KAAJ,YAAI,QAU/B;QAAD,CAAC,EAVqB,KAAK,GAAL,aAAK,KAAL,aAAK,QAU1B;IAAD,CAAC,EAVa,OAAO,GAAP,cAAO,KAAP,cAAO,QAUpB;AAAD,CAAC,EAVM,MAAM,KAAN,MAAM,QAUZ;AAED,WAAO,MAAM;IAAC,IAAA,KAAK,CAoBlB;IApBa,WAAA,KAAK;QAAC,IAAA,OAAO,CAoB1B;QApBmB,WAAA,OAAO;YAC1B;gBAKC,oBAAoB,SAAkC;oBAAlC,cAAS,GAAT,SAAS,CAAyB;oBAD9C,YAAO,GAAO,IAAI,CAAC;oBAEvB,aAAa;oBACb,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBAC3C,CAAC;gBANM,wBAAG,GAAV,UAAW,MAAyC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;oBAAA,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAAA,CAAC,CAAA,CAAC;gBAQlF,+BAAU,GAAjB;oBACC,MAAM,CAAC,OAAO,CAAC;gBAChB,CAAC;gBAEM,4BAAO,GAAd;gBAEA,CAAC;gBAEF,iBAAC;YAAD,CAAC,AAlBD,IAkBC;YAlBY,kBAAU,aAkBtB,CAAA;QACF,CAAC,EApBmB,OAAO,GAAP,aAAO,KAAP,aAAO,QAoB1B;IAAD,CAAC,EApBa,KAAK,GAAL,YAAK,KAAL,YAAK,QAoBlB;AAAD,CAAC,EApBM,MAAM,KAAN,MAAM,QAoBZ;AAGD;IAAA;IAAuF,CAAC;IAA3C,sCAAe,GAAtB,cAAmC,MAAM,CAAC,IAAI,CAAC,CAAA,CAAC;IAAC,mBAAC;AAAD,CAAC,AAAxF,IAAwF;AASxF,WAAO,MAAM;IAAC,IAAA,KAAK,CAwBlB;IAxBa,WAAA,KAAK;QAAC,IAAA,SAAS,CAwB5B;QAxBmB,WAAA,SAAS;YAAC,IAAA,SAAS,CAwBtC;YAxB6B,WAAA,SAAS;gBAEtC;oBACO,eAAoB,IAAW;wBAAX,SAAI,GAAJ,IAAI,CAAO;oBAAI,CAAC;oBACnC,qBAAK,GAAZ;wBACC,MAAM,CAAC,IAAI,CAAC;oBACb,CAAC;oBAEM,sBAAM,GAAb,UAAc,KAAY;wBACzB,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC;oBACvB,CAAC;oBAEM,uBAAO,GAAd,cAA0B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;oBACzC,YAAC;gBAAD,CAAC,AAXD,IAWC;gBAXY,eAAK,QAWjB,CAAA;gBAED;oBAA0B,wBAAY;oBAAtC;;oBAQA,CAAC;oBANA,aAAa;oBACN,8BAAe,GAAtB;wBACC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;oBACxB,CAAC;oBAGF,WAAC;gBAAD,CAAC,AARD,CAA0B,YAAY,GAQrC;gBARY,cAAI,OAQhB,CAAA;YACF,CAAC,EAxB6B,SAAS,GAAT,mBAAS,KAAT,mBAAS,QAwBtC;QAAD,CAAC,EAxBmB,SAAS,GAAT,eAAS,KAAT,eAAS,QAwB5B;IAAD,CAAC,EAxBa,KAAK,GAAL,YAAK,KAAL,YAAK,QAwBlB;AAAD,CAAC,EAxBM,MAAM,KAAN,MAAM,QAwBZ"} \ No newline at end of file diff --git a/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt b/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt index f99a062e2c6..4196b08c609 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt +++ b/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt @@ -26,11 +26,16 @@ sourceFile:recursiveClassReferenceTest.ts 1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) 2 >Emitted(2, 75) Source(2, 75) + SourceIndex(0) --- ->>>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 __extends = (this && this.__extends) || (function () { +>>> var extendStatics = Object.setPrototypeOf || +>>> ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || +>>> function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; +>>> return function (d, b) { +>>> extendStatics(d, b); +>>> function __() { this.constructor = d; } +>>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +>>> }; +>>>})(); >>>var Sample; 1 > 2 >^^^^ @@ -81,10 +86,10 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(8, 1) Source(32, 1) + SourceIndex(0) -2 >Emitted(8, 5) Source(32, 8) + SourceIndex(0) -3 >Emitted(8, 11) Source(32, 14) + SourceIndex(0) -4 >Emitted(8, 12) Source(42, 2) + SourceIndex(0) +1 >Emitted(13, 1) Source(32, 1) + SourceIndex(0) +2 >Emitted(13, 5) Source(32, 8) + SourceIndex(0) +3 >Emitted(13, 11) Source(32, 14) + SourceIndex(0) +4 >Emitted(13, 12) Source(42, 2) + SourceIndex(0) --- >>>(function (Sample) { 1-> @@ -93,9 +98,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 >module 3 > Sample -1->Emitted(9, 1) Source(32, 1) + SourceIndex(0) -2 >Emitted(9, 12) Source(32, 8) + SourceIndex(0) -3 >Emitted(9, 18) Source(32, 14) + SourceIndex(0) +1->Emitted(14, 1) Source(32, 1) + SourceIndex(0) +2 >Emitted(14, 12) Source(32, 8) + SourceIndex(0) +3 >Emitted(14, 18) Source(32, 14) + SourceIndex(0) --- >>> var Actions; 1 >^^^^ @@ -117,10 +122,10 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(10, 5) Source(32, 15) + SourceIndex(0) -2 >Emitted(10, 9) Source(32, 15) + SourceIndex(0) -3 >Emitted(10, 16) Source(32, 22) + SourceIndex(0) -4 >Emitted(10, 17) Source(42, 2) + SourceIndex(0) +1 >Emitted(15, 5) Source(32, 15) + SourceIndex(0) +2 >Emitted(15, 9) Source(32, 15) + SourceIndex(0) +3 >Emitted(15, 16) Source(32, 22) + SourceIndex(0) +4 >Emitted(15, 17) Source(42, 2) + SourceIndex(0) --- >>> (function (Actions) { 1->^^^^ @@ -129,9 +134,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Actions -1->Emitted(11, 5) Source(32, 15) + SourceIndex(0) -2 >Emitted(11, 16) Source(32, 15) + SourceIndex(0) -3 >Emitted(11, 23) Source(32, 22) + SourceIndex(0) +1->Emitted(16, 5) Source(32, 15) + SourceIndex(0) +2 >Emitted(16, 16) Source(32, 15) + SourceIndex(0) +3 >Emitted(16, 23) Source(32, 22) + SourceIndex(0) --- >>> var Thing; 1 >^^^^^^^^ @@ -153,10 +158,10 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(12, 9) Source(32, 23) + SourceIndex(0) -2 >Emitted(12, 13) Source(32, 23) + SourceIndex(0) -3 >Emitted(12, 18) Source(32, 28) + SourceIndex(0) -4 >Emitted(12, 19) Source(42, 2) + SourceIndex(0) +1 >Emitted(17, 9) Source(32, 23) + SourceIndex(0) +2 >Emitted(17, 13) Source(32, 23) + SourceIndex(0) +3 >Emitted(17, 18) Source(32, 28) + SourceIndex(0) +4 >Emitted(17, 19) Source(42, 2) + SourceIndex(0) --- >>> (function (Thing_1) { 1->^^^^^^^^ @@ -165,9 +170,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Thing -1->Emitted(13, 9) Source(32, 23) + SourceIndex(0) -2 >Emitted(13, 20) Source(32, 23) + SourceIndex(0) -3 >Emitted(13, 27) Source(32, 28) + SourceIndex(0) +1->Emitted(18, 9) Source(32, 23) + SourceIndex(0) +2 >Emitted(18, 20) Source(32, 23) + SourceIndex(0) +3 >Emitted(18, 27) Source(32, 28) + SourceIndex(0) --- >>> var Find; 1 >^^^^^^^^^^^^ @@ -189,10 +194,10 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(14, 13) Source(32, 29) + SourceIndex(0) -2 >Emitted(14, 17) Source(32, 29) + SourceIndex(0) -3 >Emitted(14, 21) Source(32, 33) + SourceIndex(0) -4 >Emitted(14, 22) Source(42, 2) + SourceIndex(0) +1 >Emitted(19, 13) Source(32, 29) + SourceIndex(0) +2 >Emitted(19, 17) Source(32, 29) + SourceIndex(0) +3 >Emitted(19, 21) Source(32, 33) + SourceIndex(0) +4 >Emitted(19, 22) Source(42, 2) + SourceIndex(0) --- >>> (function (Find) { 1->^^^^^^^^^^^^ @@ -202,22 +207,22 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Find -1->Emitted(15, 13) Source(32, 29) + SourceIndex(0) -2 >Emitted(15, 24) Source(32, 29) + SourceIndex(0) -3 >Emitted(15, 28) Source(32, 33) + SourceIndex(0) +1->Emitted(20, 13) Source(32, 29) + SourceIndex(0) +2 >Emitted(20, 24) Source(32, 29) + SourceIndex(0) +3 >Emitted(20, 28) Source(32, 33) + SourceIndex(0) --- >>> var StartFindAction = (function () { 1->^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> { > -1->Emitted(16, 17) Source(33, 2) + SourceIndex(0) +1->Emitted(21, 17) Source(33, 2) + SourceIndex(0) --- >>> function StartFindAction() { 1->^^^^^^^^^^^^^^^^^^^^ 2 > ^^-> 1-> -1->Emitted(17, 21) Source(33, 2) + SourceIndex(0) +1->Emitted(22, 21) Source(33, 2) + SourceIndex(0) --- >>> } 1->^^^^^^^^^^^^^^^^^^^^ @@ -233,8 +238,8 @@ sourceFile:recursiveClassReferenceTest.ts > } > 2 > } -1->Emitted(18, 21) Source(41, 2) + SourceIndex(0) -2 >Emitted(18, 22) Source(41, 3) + SourceIndex(0) +1->Emitted(23, 21) Source(41, 2) + SourceIndex(0) +2 >Emitted(23, 22) Source(41, 3) + SourceIndex(0) --- >>> StartFindAction.prototype.getId = function () { return "yo"; }; 1->^^^^^^^^^^^^^^^^^^^^ @@ -257,16 +262,16 @@ sourceFile:recursiveClassReferenceTest.ts 8 > ; 9 > 10> } -1->Emitted(19, 21) Source(35, 10) + SourceIndex(0) -2 >Emitted(19, 52) Source(35, 15) + SourceIndex(0) -3 >Emitted(19, 55) Source(35, 3) + SourceIndex(0) -4 >Emitted(19, 69) Source(35, 20) + SourceIndex(0) -5 >Emitted(19, 75) Source(35, 26) + SourceIndex(0) -6 >Emitted(19, 76) Source(35, 27) + SourceIndex(0) -7 >Emitted(19, 80) Source(35, 31) + SourceIndex(0) -8 >Emitted(19, 81) Source(35, 32) + SourceIndex(0) -9 >Emitted(19, 82) Source(35, 33) + SourceIndex(0) -10>Emitted(19, 83) Source(35, 34) + SourceIndex(0) +1->Emitted(24, 21) Source(35, 10) + SourceIndex(0) +2 >Emitted(24, 52) Source(35, 15) + SourceIndex(0) +3 >Emitted(24, 55) Source(35, 3) + SourceIndex(0) +4 >Emitted(24, 69) Source(35, 20) + SourceIndex(0) +5 >Emitted(24, 75) Source(35, 26) + SourceIndex(0) +6 >Emitted(24, 76) Source(35, 27) + SourceIndex(0) +7 >Emitted(24, 80) Source(35, 31) + SourceIndex(0) +8 >Emitted(24, 81) Source(35, 32) + SourceIndex(0) +9 >Emitted(24, 82) Source(35, 33) + SourceIndex(0) +10>Emitted(24, 83) Source(35, 34) + SourceIndex(0) --- >>> StartFindAction.prototype.run = function (Thing) { 1 >^^^^^^^^^^^^^^^^^^^^ @@ -281,11 +286,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > public run( 5 > Thing:Sample.Thing.ICodeThing -1 >Emitted(20, 21) Source(37, 10) + SourceIndex(0) -2 >Emitted(20, 50) Source(37, 13) + SourceIndex(0) -3 >Emitted(20, 53) Source(37, 3) + SourceIndex(0) -4 >Emitted(20, 63) Source(37, 14) + SourceIndex(0) -5 >Emitted(20, 68) Source(37, 43) + SourceIndex(0) +1 >Emitted(25, 21) Source(37, 10) + SourceIndex(0) +2 >Emitted(25, 50) Source(37, 13) + SourceIndex(0) +3 >Emitted(25, 53) Source(37, 3) + SourceIndex(0) +4 >Emitted(25, 63) Source(37, 14) + SourceIndex(0) +5 >Emitted(25, 68) Source(37, 43) + SourceIndex(0) --- >>> return true; 1 >^^^^^^^^^^^^^^^^^^^^^^^^ @@ -300,11 +305,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > true 5 > ; -1 >Emitted(21, 25) Source(39, 4) + SourceIndex(0) -2 >Emitted(21, 31) Source(39, 10) + SourceIndex(0) -3 >Emitted(21, 32) Source(39, 11) + SourceIndex(0) -4 >Emitted(21, 36) Source(39, 15) + SourceIndex(0) -5 >Emitted(21, 37) Source(39, 16) + SourceIndex(0) +1 >Emitted(26, 25) Source(39, 4) + SourceIndex(0) +2 >Emitted(26, 31) Source(39, 10) + SourceIndex(0) +3 >Emitted(26, 32) Source(39, 11) + SourceIndex(0) +4 >Emitted(26, 36) Source(39, 15) + SourceIndex(0) +5 >Emitted(26, 37) Source(39, 16) + SourceIndex(0) --- >>> }; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -313,8 +318,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(22, 21) Source(40, 3) + SourceIndex(0) -2 >Emitted(22, 22) Source(40, 4) + SourceIndex(0) +1 >Emitted(27, 21) Source(40, 3) + SourceIndex(0) +2 >Emitted(27, 22) Source(40, 4) + SourceIndex(0) --- >>> return StartFindAction; 1->^^^^^^^^^^^^^^^^^^^^ @@ -322,8 +327,8 @@ sourceFile:recursiveClassReferenceTest.ts 1-> > 2 > } -1->Emitted(23, 21) Source(41, 2) + SourceIndex(0) -2 >Emitted(23, 43) Source(41, 3) + SourceIndex(0) +1->Emitted(28, 21) Source(41, 2) + SourceIndex(0) +2 >Emitted(28, 43) Source(41, 3) + SourceIndex(0) --- >>> }()); 1 >^^^^^^^^^^^^^^^^ @@ -343,10 +348,10 @@ sourceFile:recursiveClassReferenceTest.ts > return true; > } > } -1 >Emitted(24, 17) Source(41, 2) + SourceIndex(0) -2 >Emitted(24, 18) Source(41, 3) + SourceIndex(0) -3 >Emitted(24, 18) Source(33, 2) + SourceIndex(0) -4 >Emitted(24, 22) Source(41, 3) + SourceIndex(0) +1 >Emitted(29, 17) Source(41, 2) + SourceIndex(0) +2 >Emitted(29, 18) Source(41, 3) + SourceIndex(0) +3 >Emitted(29, 18) Source(33, 2) + SourceIndex(0) +4 >Emitted(29, 22) Source(41, 3) + SourceIndex(0) --- >>> Find.StartFindAction = StartFindAction; 1->^^^^^^^^^^^^^^^^ @@ -366,10 +371,10 @@ sourceFile:recursiveClassReferenceTest.ts > } > } 4 > -1->Emitted(25, 17) Source(33, 15) + SourceIndex(0) -2 >Emitted(25, 37) Source(33, 30) + SourceIndex(0) -3 >Emitted(25, 55) Source(41, 3) + SourceIndex(0) -4 >Emitted(25, 56) Source(41, 3) + SourceIndex(0) +1->Emitted(30, 17) Source(33, 15) + SourceIndex(0) +2 >Emitted(30, 37) Source(33, 30) + SourceIndex(0) +3 >Emitted(30, 55) Source(41, 3) + SourceIndex(0) +4 >Emitted(30, 56) Source(41, 3) + SourceIndex(0) --- >>> })(Find = Thing_1.Find || (Thing_1.Find = {})); 1->^^^^^^^^^^^^ @@ -401,15 +406,15 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1->Emitted(26, 13) Source(42, 1) + SourceIndex(0) -2 >Emitted(26, 14) Source(42, 2) + SourceIndex(0) -3 >Emitted(26, 16) Source(32, 29) + SourceIndex(0) -4 >Emitted(26, 20) Source(32, 33) + SourceIndex(0) -5 >Emitted(26, 23) Source(32, 29) + SourceIndex(0) -6 >Emitted(26, 35) Source(32, 33) + SourceIndex(0) -7 >Emitted(26, 40) Source(32, 29) + SourceIndex(0) -8 >Emitted(26, 52) Source(32, 33) + SourceIndex(0) -9 >Emitted(26, 60) Source(42, 2) + SourceIndex(0) +1->Emitted(31, 13) Source(42, 1) + SourceIndex(0) +2 >Emitted(31, 14) Source(42, 2) + SourceIndex(0) +3 >Emitted(31, 16) Source(32, 29) + SourceIndex(0) +4 >Emitted(31, 20) Source(32, 33) + SourceIndex(0) +5 >Emitted(31, 23) Source(32, 29) + SourceIndex(0) +6 >Emitted(31, 35) Source(32, 33) + SourceIndex(0) +7 >Emitted(31, 40) Source(32, 29) + SourceIndex(0) +8 >Emitted(31, 52) Source(32, 33) + SourceIndex(0) +9 >Emitted(31, 60) Source(42, 2) + SourceIndex(0) --- >>> })(Thing = Actions.Thing || (Actions.Thing = {})); 1 >^^^^^^^^ @@ -441,15 +446,15 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(27, 9) Source(42, 1) + SourceIndex(0) -2 >Emitted(27, 10) Source(42, 2) + SourceIndex(0) -3 >Emitted(27, 12) Source(32, 23) + SourceIndex(0) -4 >Emitted(27, 17) Source(32, 28) + SourceIndex(0) -5 >Emitted(27, 20) Source(32, 23) + SourceIndex(0) -6 >Emitted(27, 33) Source(32, 28) + SourceIndex(0) -7 >Emitted(27, 38) Source(32, 23) + SourceIndex(0) -8 >Emitted(27, 51) Source(32, 28) + SourceIndex(0) -9 >Emitted(27, 59) Source(42, 2) + SourceIndex(0) +1 >Emitted(32, 9) Source(42, 1) + SourceIndex(0) +2 >Emitted(32, 10) Source(42, 2) + SourceIndex(0) +3 >Emitted(32, 12) Source(32, 23) + SourceIndex(0) +4 >Emitted(32, 17) Source(32, 28) + SourceIndex(0) +5 >Emitted(32, 20) Source(32, 23) + SourceIndex(0) +6 >Emitted(32, 33) Source(32, 28) + SourceIndex(0) +7 >Emitted(32, 38) Source(32, 23) + SourceIndex(0) +8 >Emitted(32, 51) Source(32, 28) + SourceIndex(0) +9 >Emitted(32, 59) Source(42, 2) + SourceIndex(0) --- >>> })(Actions = Sample.Actions || (Sample.Actions = {})); 1->^^^^ @@ -480,15 +485,15 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1->Emitted(28, 5) Source(42, 1) + SourceIndex(0) -2 >Emitted(28, 6) Source(42, 2) + SourceIndex(0) -3 >Emitted(28, 8) Source(32, 15) + SourceIndex(0) -4 >Emitted(28, 15) Source(32, 22) + SourceIndex(0) -5 >Emitted(28, 18) Source(32, 15) + SourceIndex(0) -6 >Emitted(28, 32) Source(32, 22) + SourceIndex(0) -7 >Emitted(28, 37) Source(32, 15) + SourceIndex(0) -8 >Emitted(28, 51) Source(32, 22) + SourceIndex(0) -9 >Emitted(28, 59) Source(42, 2) + SourceIndex(0) +1->Emitted(33, 5) Source(42, 1) + SourceIndex(0) +2 >Emitted(33, 6) Source(42, 2) + SourceIndex(0) +3 >Emitted(33, 8) Source(32, 15) + SourceIndex(0) +4 >Emitted(33, 15) Source(32, 22) + SourceIndex(0) +5 >Emitted(33, 18) Source(32, 15) + SourceIndex(0) +6 >Emitted(33, 32) Source(32, 22) + SourceIndex(0) +7 >Emitted(33, 37) Source(32, 15) + SourceIndex(0) +8 >Emitted(33, 51) Source(32, 22) + SourceIndex(0) +9 >Emitted(33, 59) Source(42, 2) + SourceIndex(0) --- >>>})(Sample || (Sample = {})); 1 > @@ -515,13 +520,13 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(29, 1) Source(42, 1) + SourceIndex(0) -2 >Emitted(29, 2) Source(42, 2) + SourceIndex(0) -3 >Emitted(29, 4) Source(32, 8) + SourceIndex(0) -4 >Emitted(29, 10) Source(32, 14) + SourceIndex(0) -5 >Emitted(29, 15) Source(32, 8) + SourceIndex(0) -6 >Emitted(29, 21) Source(32, 14) + SourceIndex(0) -7 >Emitted(29, 29) Source(42, 2) + SourceIndex(0) +1 >Emitted(34, 1) Source(42, 1) + SourceIndex(0) +2 >Emitted(34, 2) Source(42, 2) + SourceIndex(0) +3 >Emitted(34, 4) Source(32, 8) + SourceIndex(0) +4 >Emitted(34, 10) Source(32, 14) + SourceIndex(0) +5 >Emitted(34, 15) Source(32, 8) + SourceIndex(0) +6 >Emitted(34, 21) Source(32, 14) + SourceIndex(0) +7 >Emitted(34, 29) Source(42, 2) + SourceIndex(0) --- >>>(function (Sample) { 1 > @@ -532,9 +537,9 @@ sourceFile:recursiveClassReferenceTest.ts > 2 >module 3 > Sample -1 >Emitted(30, 1) Source(44, 1) + SourceIndex(0) -2 >Emitted(30, 12) Source(44, 8) + SourceIndex(0) -3 >Emitted(30, 18) Source(44, 14) + SourceIndex(0) +1 >Emitted(35, 1) Source(44, 1) + SourceIndex(0) +2 >Emitted(35, 12) Source(44, 8) + SourceIndex(0) +3 >Emitted(35, 18) Source(44, 14) + SourceIndex(0) --- >>> var Thing; 1 >^^^^ @@ -566,10 +571,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(31, 5) Source(44, 15) + SourceIndex(0) -2 >Emitted(31, 9) Source(44, 15) + SourceIndex(0) -3 >Emitted(31, 14) Source(44, 20) + SourceIndex(0) -4 >Emitted(31, 15) Source(64, 2) + SourceIndex(0) +1 >Emitted(36, 5) Source(44, 15) + SourceIndex(0) +2 >Emitted(36, 9) Source(44, 15) + SourceIndex(0) +3 >Emitted(36, 14) Source(44, 20) + SourceIndex(0) +4 >Emitted(36, 15) Source(64, 2) + SourceIndex(0) --- >>> (function (Thing) { 1->^^^^ @@ -579,9 +584,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Thing -1->Emitted(32, 5) Source(44, 15) + SourceIndex(0) -2 >Emitted(32, 16) Source(44, 15) + SourceIndex(0) -3 >Emitted(32, 21) Source(44, 20) + SourceIndex(0) +1->Emitted(37, 5) Source(44, 15) + SourceIndex(0) +2 >Emitted(37, 16) Source(44, 15) + SourceIndex(0) +3 >Emitted(37, 21) Source(44, 20) + SourceIndex(0) --- >>> var Widgets; 1->^^^^^^^^ @@ -613,10 +618,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1->Emitted(33, 9) Source(44, 21) + SourceIndex(0) -2 >Emitted(33, 13) Source(44, 21) + SourceIndex(0) -3 >Emitted(33, 20) Source(44, 28) + SourceIndex(0) -4 >Emitted(33, 21) Source(64, 2) + SourceIndex(0) +1->Emitted(38, 9) Source(44, 21) + SourceIndex(0) +2 >Emitted(38, 13) Source(44, 21) + SourceIndex(0) +3 >Emitted(38, 20) Source(44, 28) + SourceIndex(0) +4 >Emitted(38, 21) Source(64, 2) + SourceIndex(0) --- >>> (function (Widgets) { 1->^^^^^^^^ @@ -626,16 +631,16 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Widgets -1->Emitted(34, 9) Source(44, 21) + SourceIndex(0) -2 >Emitted(34, 20) Source(44, 21) + SourceIndex(0) -3 >Emitted(34, 27) Source(44, 28) + SourceIndex(0) +1->Emitted(39, 9) Source(44, 21) + SourceIndex(0) +2 >Emitted(39, 20) Source(44, 21) + SourceIndex(0) +3 >Emitted(39, 27) Source(44, 28) + SourceIndex(0) --- >>> var FindWidget = (function () { 1->^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> { > -1->Emitted(35, 13) Source(45, 2) + SourceIndex(0) +1->Emitted(40, 13) Source(45, 2) + SourceIndex(0) --- >>> function FindWidget(codeThing) { 1->^^^^^^^^^^^^^^^^ @@ -650,9 +655,9 @@ sourceFile:recursiveClassReferenceTest.ts > 2 > constructor(private 3 > codeThing: Sample.Thing.ICodeThing -1->Emitted(36, 17) Source(50, 3) + SourceIndex(0) -2 >Emitted(36, 37) Source(50, 23) + SourceIndex(0) -3 >Emitted(36, 46) Source(50, 57) + SourceIndex(0) +1->Emitted(41, 17) Source(50, 3) + SourceIndex(0) +2 >Emitted(41, 37) Source(50, 23) + SourceIndex(0) +3 >Emitted(41, 46) Source(50, 57) + SourceIndex(0) --- >>> this.codeThing = codeThing; 1->^^^^^^^^^^^^^^^^^^^^ @@ -665,11 +670,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > codeThing 5 > : Sample.Thing.ICodeThing -1->Emitted(37, 21) Source(50, 23) + SourceIndex(0) -2 >Emitted(37, 35) Source(50, 32) + SourceIndex(0) -3 >Emitted(37, 38) Source(50, 23) + SourceIndex(0) -4 >Emitted(37, 47) Source(50, 32) + SourceIndex(0) -5 >Emitted(37, 48) Source(50, 57) + SourceIndex(0) +1->Emitted(42, 21) Source(50, 23) + SourceIndex(0) +2 >Emitted(42, 35) Source(50, 32) + SourceIndex(0) +3 >Emitted(42, 38) Source(50, 23) + SourceIndex(0) +4 >Emitted(42, 47) Source(50, 32) + SourceIndex(0) +5 >Emitted(42, 48) Source(50, 57) + SourceIndex(0) --- >>> this.domNode = null; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -682,11 +687,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > :any = 4 > null 5 > ; -1 >Emitted(38, 21) Source(49, 11) + SourceIndex(0) -2 >Emitted(38, 33) Source(49, 18) + SourceIndex(0) -3 >Emitted(38, 36) Source(49, 25) + SourceIndex(0) -4 >Emitted(38, 40) Source(49, 29) + SourceIndex(0) -5 >Emitted(38, 41) Source(49, 30) + SourceIndex(0) +1 >Emitted(43, 21) Source(49, 11) + SourceIndex(0) +2 >Emitted(43, 33) Source(49, 18) + SourceIndex(0) +3 >Emitted(43, 36) Source(49, 25) + SourceIndex(0) +4 >Emitted(43, 40) Source(49, 29) + SourceIndex(0) +5 >Emitted(43, 41) Source(49, 30) + SourceIndex(0) --- >>> // scenario 1 1 >^^^^^^^^^^^^^^^^^^^^ @@ -696,8 +701,8 @@ sourceFile:recursiveClassReferenceTest.ts > constructor(private codeThing: Sample.Thing.ICodeThing) { > 2 > // scenario 1 -1 >Emitted(39, 21) Source(51, 7) + SourceIndex(0) -2 >Emitted(39, 34) Source(51, 20) + SourceIndex(0) +1 >Emitted(44, 21) Source(51, 7) + SourceIndex(0) +2 >Emitted(44, 34) Source(51, 20) + SourceIndex(0) --- >>> codeThing.addWidget("addWidget", this); 1->^^^^^^^^^^^^^^^^^^^^ @@ -721,16 +726,16 @@ sourceFile:recursiveClassReferenceTest.ts 8 > this 9 > ) 10> ; -1->Emitted(40, 21) Source(52, 7) + SourceIndex(0) -2 >Emitted(40, 30) Source(52, 16) + SourceIndex(0) -3 >Emitted(40, 31) Source(52, 17) + SourceIndex(0) -4 >Emitted(40, 40) Source(52, 26) + SourceIndex(0) -5 >Emitted(40, 41) Source(52, 27) + SourceIndex(0) -6 >Emitted(40, 52) Source(52, 38) + SourceIndex(0) -7 >Emitted(40, 54) Source(52, 40) + SourceIndex(0) -8 >Emitted(40, 58) Source(52, 44) + SourceIndex(0) -9 >Emitted(40, 59) Source(52, 45) + SourceIndex(0) -10>Emitted(40, 60) Source(52, 46) + SourceIndex(0) +1->Emitted(45, 21) Source(52, 7) + SourceIndex(0) +2 >Emitted(45, 30) Source(52, 16) + SourceIndex(0) +3 >Emitted(45, 31) Source(52, 17) + SourceIndex(0) +4 >Emitted(45, 40) Source(52, 26) + SourceIndex(0) +5 >Emitted(45, 41) Source(52, 27) + SourceIndex(0) +6 >Emitted(45, 52) Source(52, 38) + SourceIndex(0) +7 >Emitted(45, 54) Source(52, 40) + SourceIndex(0) +8 >Emitted(45, 58) Source(52, 44) + SourceIndex(0) +9 >Emitted(45, 59) Source(52, 45) + SourceIndex(0) +10>Emitted(45, 60) Source(52, 46) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^ @@ -739,8 +744,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(41, 17) Source(53, 3) + SourceIndex(0) -2 >Emitted(41, 18) Source(53, 4) + SourceIndex(0) +1 >Emitted(46, 17) Source(53, 3) + SourceIndex(0) +2 >Emitted(46, 18) Source(53, 4) + SourceIndex(0) --- >>> FindWidget.prototype.gar = function (runner) { if (true) { 1->^^^^^^^^^^^^^^^^ @@ -769,19 +774,19 @@ sourceFile:recursiveClassReferenceTest.ts 11> ) 12> 13> { -1->Emitted(42, 17) Source(47, 10) + SourceIndex(0) -2 >Emitted(42, 41) Source(47, 13) + SourceIndex(0) -3 >Emitted(42, 44) Source(47, 3) + SourceIndex(0) -4 >Emitted(42, 54) Source(47, 14) + SourceIndex(0) -5 >Emitted(42, 60) Source(47, 55) + SourceIndex(0) -6 >Emitted(42, 64) Source(47, 59) + SourceIndex(0) -7 >Emitted(42, 66) Source(47, 61) + SourceIndex(0) -8 >Emitted(42, 67) Source(47, 62) + SourceIndex(0) -9 >Emitted(42, 68) Source(47, 63) + SourceIndex(0) -10>Emitted(42, 72) Source(47, 67) + SourceIndex(0) -11>Emitted(42, 73) Source(47, 68) + SourceIndex(0) -12>Emitted(42, 74) Source(47, 69) + SourceIndex(0) -13>Emitted(42, 75) Source(47, 70) + SourceIndex(0) +1->Emitted(47, 17) Source(47, 10) + SourceIndex(0) +2 >Emitted(47, 41) Source(47, 13) + SourceIndex(0) +3 >Emitted(47, 44) Source(47, 3) + SourceIndex(0) +4 >Emitted(47, 54) Source(47, 14) + SourceIndex(0) +5 >Emitted(47, 60) Source(47, 55) + SourceIndex(0) +6 >Emitted(47, 64) Source(47, 59) + SourceIndex(0) +7 >Emitted(47, 66) Source(47, 61) + SourceIndex(0) +8 >Emitted(47, 67) Source(47, 62) + SourceIndex(0) +9 >Emitted(47, 68) Source(47, 63) + SourceIndex(0) +10>Emitted(47, 72) Source(47, 67) + SourceIndex(0) +11>Emitted(47, 73) Source(47, 68) + SourceIndex(0) +12>Emitted(47, 74) Source(47, 69) + SourceIndex(0) +13>Emitted(47, 75) Source(47, 70) + SourceIndex(0) --- >>> return runner(this); 1 >^^^^^^^^^^^^^^^^^^^^ @@ -800,14 +805,14 @@ sourceFile:recursiveClassReferenceTest.ts 6 > this 7 > ) 8 > ; -1 >Emitted(43, 21) Source(47, 70) + SourceIndex(0) -2 >Emitted(43, 27) Source(47, 76) + SourceIndex(0) -3 >Emitted(43, 28) Source(47, 77) + SourceIndex(0) -4 >Emitted(43, 34) Source(47, 83) + SourceIndex(0) -5 >Emitted(43, 35) Source(47, 84) + SourceIndex(0) -6 >Emitted(43, 39) Source(47, 88) + SourceIndex(0) -7 >Emitted(43, 40) Source(47, 89) + SourceIndex(0) -8 >Emitted(43, 41) Source(47, 90) + SourceIndex(0) +1 >Emitted(48, 21) Source(47, 70) + SourceIndex(0) +2 >Emitted(48, 27) Source(47, 76) + SourceIndex(0) +3 >Emitted(48, 28) Source(47, 77) + SourceIndex(0) +4 >Emitted(48, 34) Source(47, 83) + SourceIndex(0) +5 >Emitted(48, 35) Source(47, 84) + SourceIndex(0) +6 >Emitted(48, 39) Source(47, 88) + SourceIndex(0) +7 >Emitted(48, 40) Source(47, 89) + SourceIndex(0) +8 >Emitted(48, 41) Source(47, 90) + SourceIndex(0) --- >>> } }; 1 >^^^^^^^^^^^^^^^^ @@ -819,10 +824,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 > } 3 > 4 > } -1 >Emitted(44, 17) Source(47, 90) + SourceIndex(0) -2 >Emitted(44, 18) Source(47, 91) + SourceIndex(0) -3 >Emitted(44, 19) Source(47, 91) + SourceIndex(0) -4 >Emitted(44, 20) Source(47, 92) + SourceIndex(0) +1 >Emitted(49, 17) Source(47, 90) + SourceIndex(0) +2 >Emitted(49, 18) Source(47, 91) + SourceIndex(0) +3 >Emitted(49, 19) Source(47, 91) + SourceIndex(0) +4 >Emitted(49, 20) Source(47, 92) + SourceIndex(0) --- >>> FindWidget.prototype.getDomNode = function () { 1->^^^^^^^^^^^^^^^^ @@ -839,9 +844,9 @@ sourceFile:recursiveClassReferenceTest.ts > public 2 > getDomNode 3 > -1->Emitted(45, 17) Source(55, 10) + SourceIndex(0) -2 >Emitted(45, 48) Source(55, 20) + SourceIndex(0) -3 >Emitted(45, 51) Source(55, 3) + SourceIndex(0) +1->Emitted(50, 17) Source(55, 10) + SourceIndex(0) +2 >Emitted(50, 48) Source(55, 20) + SourceIndex(0) +3 >Emitted(50, 51) Source(55, 3) + SourceIndex(0) --- >>> return domNode; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -855,11 +860,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > domNode 5 > ; -1 >Emitted(46, 21) Source(56, 4) + SourceIndex(0) -2 >Emitted(46, 27) Source(56, 10) + SourceIndex(0) -3 >Emitted(46, 28) Source(56, 11) + SourceIndex(0) -4 >Emitted(46, 35) Source(56, 18) + SourceIndex(0) -5 >Emitted(46, 36) Source(56, 19) + SourceIndex(0) +1 >Emitted(51, 21) Source(56, 4) + SourceIndex(0) +2 >Emitted(51, 27) Source(56, 10) + SourceIndex(0) +3 >Emitted(51, 28) Source(56, 11) + SourceIndex(0) +4 >Emitted(51, 35) Source(56, 18) + SourceIndex(0) +5 >Emitted(51, 36) Source(56, 19) + SourceIndex(0) --- >>> }; 1 >^^^^^^^^^^^^^^^^ @@ -868,8 +873,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(47, 17) Source(57, 3) + SourceIndex(0) -2 >Emitted(47, 18) Source(57, 4) + SourceIndex(0) +1 >Emitted(52, 17) Source(57, 3) + SourceIndex(0) +2 >Emitted(52, 18) Source(57, 4) + SourceIndex(0) --- >>> FindWidget.prototype.destroy = function () { 1->^^^^^^^^^^^^^^^^ @@ -880,9 +885,9 @@ sourceFile:recursiveClassReferenceTest.ts > public 2 > destroy 3 > -1->Emitted(48, 17) Source(59, 10) + SourceIndex(0) -2 >Emitted(48, 45) Source(59, 17) + SourceIndex(0) -3 >Emitted(48, 48) Source(59, 3) + SourceIndex(0) +1->Emitted(53, 17) Source(59, 10) + SourceIndex(0) +2 >Emitted(53, 45) Source(59, 17) + SourceIndex(0) +3 >Emitted(53, 48) Source(59, 3) + SourceIndex(0) --- >>> }; 1 >^^^^^^^^^^^^^^^^ @@ -892,8 +897,8 @@ sourceFile:recursiveClassReferenceTest.ts > > 2 > } -1 >Emitted(49, 17) Source(61, 3) + SourceIndex(0) -2 >Emitted(49, 18) Source(61, 4) + SourceIndex(0) +1 >Emitted(54, 17) Source(61, 3) + SourceIndex(0) +2 >Emitted(54, 18) Source(61, 4) + SourceIndex(0) --- >>> return FindWidget; 1->^^^^^^^^^^^^^^^^ @@ -902,8 +907,8 @@ sourceFile:recursiveClassReferenceTest.ts > > 2 > } -1->Emitted(50, 17) Source(63, 2) + SourceIndex(0) -2 >Emitted(50, 34) Source(63, 3) + SourceIndex(0) +1->Emitted(55, 17) Source(63, 2) + SourceIndex(0) +2 >Emitted(55, 34) Source(63, 3) + SourceIndex(0) --- >>> }()); 1 >^^^^^^^^^^^^ @@ -933,10 +938,10 @@ sourceFile:recursiveClassReferenceTest.ts > } > > } -1 >Emitted(51, 13) Source(63, 2) + SourceIndex(0) -2 >Emitted(51, 14) Source(63, 3) + SourceIndex(0) -3 >Emitted(51, 14) Source(45, 2) + SourceIndex(0) -4 >Emitted(51, 18) Source(63, 3) + SourceIndex(0) +1 >Emitted(56, 13) Source(63, 2) + SourceIndex(0) +2 >Emitted(56, 14) Source(63, 3) + SourceIndex(0) +3 >Emitted(56, 14) Source(45, 2) + SourceIndex(0) +4 >Emitted(56, 18) Source(63, 3) + SourceIndex(0) --- >>> Widgets.FindWidget = FindWidget; 1->^^^^^^^^^^^^ @@ -966,10 +971,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } 4 > -1->Emitted(52, 13) Source(45, 15) + SourceIndex(0) -2 >Emitted(52, 31) Source(45, 25) + SourceIndex(0) -3 >Emitted(52, 44) Source(63, 3) + SourceIndex(0) -4 >Emitted(52, 45) Source(63, 3) + SourceIndex(0) +1->Emitted(57, 13) Source(45, 15) + SourceIndex(0) +2 >Emitted(57, 31) Source(45, 25) + SourceIndex(0) +3 >Emitted(57, 44) Source(63, 3) + SourceIndex(0) +4 >Emitted(57, 45) Source(63, 3) + SourceIndex(0) --- >>> })(Widgets = Thing.Widgets || (Thing.Widgets = {})); 1->^^^^^^^^ @@ -1011,15 +1016,15 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1->Emitted(53, 9) Source(64, 1) + SourceIndex(0) -2 >Emitted(53, 10) Source(64, 2) + SourceIndex(0) -3 >Emitted(53, 12) Source(44, 21) + SourceIndex(0) -4 >Emitted(53, 19) Source(44, 28) + SourceIndex(0) -5 >Emitted(53, 22) Source(44, 21) + SourceIndex(0) -6 >Emitted(53, 35) Source(44, 28) + SourceIndex(0) -7 >Emitted(53, 40) Source(44, 21) + SourceIndex(0) -8 >Emitted(53, 53) Source(44, 28) + SourceIndex(0) -9 >Emitted(53, 61) Source(64, 2) + SourceIndex(0) +1->Emitted(58, 9) Source(64, 1) + SourceIndex(0) +2 >Emitted(58, 10) Source(64, 2) + SourceIndex(0) +3 >Emitted(58, 12) Source(44, 21) + SourceIndex(0) +4 >Emitted(58, 19) Source(44, 28) + SourceIndex(0) +5 >Emitted(58, 22) Source(44, 21) + SourceIndex(0) +6 >Emitted(58, 35) Source(44, 28) + SourceIndex(0) +7 >Emitted(58, 40) Source(44, 21) + SourceIndex(0) +8 >Emitted(58, 53) Source(44, 28) + SourceIndex(0) +9 >Emitted(58, 61) Source(64, 2) + SourceIndex(0) --- >>> })(Thing = Sample.Thing || (Sample.Thing = {})); 1 >^^^^ @@ -1060,15 +1065,15 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(54, 5) Source(64, 1) + SourceIndex(0) -2 >Emitted(54, 6) Source(64, 2) + SourceIndex(0) -3 >Emitted(54, 8) Source(44, 15) + SourceIndex(0) -4 >Emitted(54, 13) Source(44, 20) + SourceIndex(0) -5 >Emitted(54, 16) Source(44, 15) + SourceIndex(0) -6 >Emitted(54, 28) Source(44, 20) + SourceIndex(0) -7 >Emitted(54, 33) Source(44, 15) + SourceIndex(0) -8 >Emitted(54, 45) Source(44, 20) + SourceIndex(0) -9 >Emitted(54, 53) Source(64, 2) + SourceIndex(0) +1 >Emitted(59, 5) Source(64, 1) + SourceIndex(0) +2 >Emitted(59, 6) Source(64, 2) + SourceIndex(0) +3 >Emitted(59, 8) Source(44, 15) + SourceIndex(0) +4 >Emitted(59, 13) Source(44, 20) + SourceIndex(0) +5 >Emitted(59, 16) Source(44, 15) + SourceIndex(0) +6 >Emitted(59, 28) Source(44, 20) + SourceIndex(0) +7 >Emitted(59, 33) Source(44, 15) + SourceIndex(0) +8 >Emitted(59, 45) Source(44, 20) + SourceIndex(0) +9 >Emitted(59, 53) Source(64, 2) + SourceIndex(0) --- >>>})(Sample || (Sample = {})); 1 > @@ -1106,13 +1111,13 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(55, 1) Source(64, 1) + SourceIndex(0) -2 >Emitted(55, 2) Source(64, 2) + SourceIndex(0) -3 >Emitted(55, 4) Source(44, 8) + SourceIndex(0) -4 >Emitted(55, 10) Source(44, 14) + SourceIndex(0) -5 >Emitted(55, 15) Source(44, 8) + SourceIndex(0) -6 >Emitted(55, 21) Source(44, 14) + SourceIndex(0) -7 >Emitted(55, 29) Source(64, 2) + SourceIndex(0) +1 >Emitted(60, 1) Source(64, 1) + SourceIndex(0) +2 >Emitted(60, 2) Source(64, 2) + SourceIndex(0) +3 >Emitted(60, 4) Source(44, 8) + SourceIndex(0) +4 >Emitted(60, 10) Source(44, 14) + SourceIndex(0) +5 >Emitted(60, 15) Source(44, 8) + SourceIndex(0) +6 >Emitted(60, 21) Source(44, 14) + SourceIndex(0) +7 >Emitted(60, 29) Source(64, 2) + SourceIndex(0) --- >>>var AbstractMode = (function () { 1-> @@ -1121,13 +1126,13 @@ sourceFile:recursiveClassReferenceTest.ts > >interface IMode { getInitialState(): IState;} > -1->Emitted(56, 1) Source(67, 1) + SourceIndex(0) +1->Emitted(61, 1) Source(67, 1) + SourceIndex(0) --- >>> function AbstractMode() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(57, 5) Source(67, 1) + SourceIndex(0) +1->Emitted(62, 5) Source(67, 1) + SourceIndex(0) --- >>> } 1->^^^^ @@ -1135,8 +1140,8 @@ sourceFile:recursiveClassReferenceTest.ts 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1->class AbstractMode implements IMode { public getInitialState(): IState { return null;} 2 > } -1->Emitted(58, 5) Source(67, 88) + SourceIndex(0) -2 >Emitted(58, 6) Source(67, 89) + SourceIndex(0) +1->Emitted(63, 5) Source(67, 88) + SourceIndex(0) +2 >Emitted(63, 6) Source(67, 89) + SourceIndex(0) --- >>> AbstractMode.prototype.getInitialState = function () { return null; }; 1->^^^^ @@ -1159,24 +1164,24 @@ sourceFile:recursiveClassReferenceTest.ts 8 > ; 9 > 10> } -1->Emitted(59, 5) Source(67, 46) + SourceIndex(0) -2 >Emitted(59, 43) Source(67, 61) + SourceIndex(0) -3 >Emitted(59, 46) Source(67, 39) + SourceIndex(0) -4 >Emitted(59, 60) Source(67, 74) + SourceIndex(0) -5 >Emitted(59, 66) Source(67, 80) + SourceIndex(0) -6 >Emitted(59, 67) Source(67, 81) + SourceIndex(0) -7 >Emitted(59, 71) Source(67, 85) + SourceIndex(0) -8 >Emitted(59, 72) Source(67, 86) + SourceIndex(0) -9 >Emitted(59, 73) Source(67, 86) + SourceIndex(0) -10>Emitted(59, 74) Source(67, 87) + SourceIndex(0) +1->Emitted(64, 5) Source(67, 46) + SourceIndex(0) +2 >Emitted(64, 43) Source(67, 61) + SourceIndex(0) +3 >Emitted(64, 46) Source(67, 39) + SourceIndex(0) +4 >Emitted(64, 60) Source(67, 74) + SourceIndex(0) +5 >Emitted(64, 66) Source(67, 80) + SourceIndex(0) +6 >Emitted(64, 67) Source(67, 81) + SourceIndex(0) +7 >Emitted(64, 71) Source(67, 85) + SourceIndex(0) +8 >Emitted(64, 72) Source(67, 86) + SourceIndex(0) +9 >Emitted(64, 73) Source(67, 86) + SourceIndex(0) +10>Emitted(64, 74) Source(67, 87) + SourceIndex(0) --- >>> return AbstractMode; 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^ 1 > 2 > } -1 >Emitted(60, 5) Source(67, 88) + SourceIndex(0) -2 >Emitted(60, 24) Source(67, 89) + SourceIndex(0) +1 >Emitted(65, 5) Source(67, 88) + SourceIndex(0) +2 >Emitted(65, 24) Source(67, 89) + SourceIndex(0) --- >>>}()); 1 > @@ -1188,10 +1193,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 >} 3 > 4 > class AbstractMode implements IMode { public getInitialState(): IState { return null;} } -1 >Emitted(61, 1) Source(67, 88) + SourceIndex(0) -2 >Emitted(61, 2) Source(67, 89) + SourceIndex(0) -3 >Emitted(61, 2) Source(67, 1) + SourceIndex(0) -4 >Emitted(61, 6) Source(67, 89) + SourceIndex(0) +1 >Emitted(66, 1) Source(67, 88) + SourceIndex(0) +2 >Emitted(66, 2) Source(67, 89) + SourceIndex(0) +3 >Emitted(66, 2) Source(67, 1) + SourceIndex(0) +4 >Emitted(66, 6) Source(67, 89) + SourceIndex(0) --- >>>(function (Sample) { 1-> @@ -1209,9 +1214,9 @@ sourceFile:recursiveClassReferenceTest.ts > 2 >module 3 > Sample -1->Emitted(62, 1) Source(76, 1) + SourceIndex(0) -2 >Emitted(62, 12) Source(76, 8) + SourceIndex(0) -3 >Emitted(62, 18) Source(76, 14) + SourceIndex(0) +1->Emitted(67, 1) Source(76, 1) + SourceIndex(0) +2 >Emitted(67, 12) Source(76, 8) + SourceIndex(0) +3 >Emitted(67, 18) Source(76, 14) + SourceIndex(0) --- >>> var Thing; 1 >^^^^ @@ -1247,10 +1252,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(63, 5) Source(76, 15) + SourceIndex(0) -2 >Emitted(63, 9) Source(76, 15) + SourceIndex(0) -3 >Emitted(63, 14) Source(76, 20) + SourceIndex(0) -4 >Emitted(63, 15) Source(100, 2) + SourceIndex(0) +1 >Emitted(68, 5) Source(76, 15) + SourceIndex(0) +2 >Emitted(68, 9) Source(76, 15) + SourceIndex(0) +3 >Emitted(68, 14) Source(76, 20) + SourceIndex(0) +4 >Emitted(68, 15) Source(100, 2) + SourceIndex(0) --- >>> (function (Thing) { 1->^^^^ @@ -1260,9 +1265,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Thing -1->Emitted(64, 5) Source(76, 15) + SourceIndex(0) -2 >Emitted(64, 16) Source(76, 15) + SourceIndex(0) -3 >Emitted(64, 21) Source(76, 20) + SourceIndex(0) +1->Emitted(69, 5) Source(76, 15) + SourceIndex(0) +2 >Emitted(69, 16) Source(76, 15) + SourceIndex(0) +3 >Emitted(69, 21) Source(76, 20) + SourceIndex(0) --- >>> var Languages; 1->^^^^^^^^ @@ -1298,10 +1303,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1->Emitted(65, 9) Source(76, 21) + SourceIndex(0) -2 >Emitted(65, 13) Source(76, 21) + SourceIndex(0) -3 >Emitted(65, 22) Source(76, 30) + SourceIndex(0) -4 >Emitted(65, 23) Source(100, 2) + SourceIndex(0) +1->Emitted(70, 9) Source(76, 21) + SourceIndex(0) +2 >Emitted(70, 13) Source(76, 21) + SourceIndex(0) +3 >Emitted(70, 22) Source(76, 30) + SourceIndex(0) +4 >Emitted(70, 23) Source(100, 2) + SourceIndex(0) --- >>> (function (Languages) { 1->^^^^^^^^ @@ -1310,9 +1315,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > Languages -1->Emitted(66, 9) Source(76, 21) + SourceIndex(0) -2 >Emitted(66, 20) Source(76, 21) + SourceIndex(0) -3 >Emitted(66, 29) Source(76, 30) + SourceIndex(0) +1->Emitted(71, 9) Source(76, 21) + SourceIndex(0) +2 >Emitted(71, 20) Source(76, 21) + SourceIndex(0) +3 >Emitted(71, 29) Source(76, 30) + SourceIndex(0) --- >>> var PlainText; 1 >^^^^^^^^^^^^ @@ -1348,10 +1353,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(67, 13) Source(76, 31) + SourceIndex(0) -2 >Emitted(67, 17) Source(76, 31) + SourceIndex(0) -3 >Emitted(67, 26) Source(76, 40) + SourceIndex(0) -4 >Emitted(67, 27) Source(100, 2) + SourceIndex(0) +1 >Emitted(72, 13) Source(76, 31) + SourceIndex(0) +2 >Emitted(72, 17) Source(76, 31) + SourceIndex(0) +3 >Emitted(72, 26) Source(76, 40) + SourceIndex(0) +4 >Emitted(72, 27) Source(100, 2) + SourceIndex(0) --- >>> (function (PlainText) { 1->^^^^^^^^^^^^ @@ -1361,9 +1366,9 @@ sourceFile:recursiveClassReferenceTest.ts 1-> 2 > 3 > PlainText -1->Emitted(68, 13) Source(76, 31) + SourceIndex(0) -2 >Emitted(68, 24) Source(76, 31) + SourceIndex(0) -3 >Emitted(68, 33) Source(76, 40) + SourceIndex(0) +1->Emitted(73, 13) Source(76, 31) + SourceIndex(0) +2 >Emitted(73, 24) Source(76, 31) + SourceIndex(0) +3 >Emitted(73, 33) Source(76, 40) + SourceIndex(0) --- >>> var State = (function () { 1->^^^^^^^^^^^^^^^^ @@ -1371,7 +1376,7 @@ sourceFile:recursiveClassReferenceTest.ts 1-> { > > -1->Emitted(69, 17) Source(78, 2) + SourceIndex(0) +1->Emitted(74, 17) Source(78, 2) + SourceIndex(0) --- >>> function State(mode) { 1->^^^^^^^^^^^^^^^^^^^^ @@ -1382,9 +1387,9 @@ sourceFile:recursiveClassReferenceTest.ts > 2 > constructor(private 3 > mode: IMode -1->Emitted(70, 21) Source(79, 9) + SourceIndex(0) -2 >Emitted(70, 36) Source(79, 29) + SourceIndex(0) -3 >Emitted(70, 40) Source(79, 40) + SourceIndex(0) +1->Emitted(75, 21) Source(79, 9) + SourceIndex(0) +2 >Emitted(75, 36) Source(79, 29) + SourceIndex(0) +3 >Emitted(75, 40) Source(79, 40) + SourceIndex(0) --- >>> this.mode = mode; 1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1397,11 +1402,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > mode 5 > : IMode -1->Emitted(71, 25) Source(79, 29) + SourceIndex(0) -2 >Emitted(71, 34) Source(79, 33) + SourceIndex(0) -3 >Emitted(71, 37) Source(79, 29) + SourceIndex(0) -4 >Emitted(71, 41) Source(79, 33) + SourceIndex(0) -5 >Emitted(71, 42) Source(79, 40) + SourceIndex(0) +1->Emitted(76, 25) Source(79, 29) + SourceIndex(0) +2 >Emitted(76, 34) Source(79, 33) + SourceIndex(0) +3 >Emitted(76, 37) Source(79, 29) + SourceIndex(0) +4 >Emitted(76, 41) Source(79, 33) + SourceIndex(0) +5 >Emitted(76, 42) Source(79, 40) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1409,8 +1414,8 @@ sourceFile:recursiveClassReferenceTest.ts 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >) { 2 > } -1 >Emitted(72, 21) Source(79, 44) + SourceIndex(0) -2 >Emitted(72, 22) Source(79, 45) + SourceIndex(0) +1 >Emitted(77, 21) Source(79, 44) + SourceIndex(0) +2 >Emitted(77, 22) Source(79, 45) + SourceIndex(0) --- >>> State.prototype.clone = function () { 1->^^^^^^^^^^^^^^^^^^^^ @@ -1420,9 +1425,9 @@ sourceFile:recursiveClassReferenceTest.ts > public 2 > clone 3 > -1->Emitted(73, 21) Source(80, 10) + SourceIndex(0) -2 >Emitted(73, 42) Source(80, 15) + SourceIndex(0) -3 >Emitted(73, 45) Source(80, 3) + SourceIndex(0) +1->Emitted(78, 21) Source(80, 10) + SourceIndex(0) +2 >Emitted(78, 42) Source(80, 15) + SourceIndex(0) +3 >Emitted(78, 45) Source(80, 3) + SourceIndex(0) --- >>> return this; 1 >^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1436,11 +1441,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > this 5 > ; -1 >Emitted(74, 25) Source(81, 4) + SourceIndex(0) -2 >Emitted(74, 31) Source(81, 10) + SourceIndex(0) -3 >Emitted(74, 32) Source(81, 11) + SourceIndex(0) -4 >Emitted(74, 36) Source(81, 15) + SourceIndex(0) -5 >Emitted(74, 37) Source(81, 16) + SourceIndex(0) +1 >Emitted(79, 25) Source(81, 4) + SourceIndex(0) +2 >Emitted(79, 31) Source(81, 10) + SourceIndex(0) +3 >Emitted(79, 32) Source(81, 11) + SourceIndex(0) +4 >Emitted(79, 36) Source(81, 15) + SourceIndex(0) +5 >Emitted(79, 37) Source(81, 16) + SourceIndex(0) --- >>> }; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1449,8 +1454,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(75, 21) Source(82, 3) + SourceIndex(0) -2 >Emitted(75, 22) Source(82, 4) + SourceIndex(0) +1 >Emitted(80, 21) Source(82, 3) + SourceIndex(0) +2 >Emitted(80, 22) Source(82, 4) + SourceIndex(0) --- >>> State.prototype.equals = function (other) { 1->^^^^^^^^^^^^^^^^^^^^ @@ -1465,11 +1470,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > 4 > public equals( 5 > other:IState -1->Emitted(76, 21) Source(84, 10) + SourceIndex(0) -2 >Emitted(76, 43) Source(84, 16) + SourceIndex(0) -3 >Emitted(76, 46) Source(84, 3) + SourceIndex(0) -4 >Emitted(76, 56) Source(84, 17) + SourceIndex(0) -5 >Emitted(76, 61) Source(84, 29) + SourceIndex(0) +1->Emitted(81, 21) Source(84, 10) + SourceIndex(0) +2 >Emitted(81, 43) Source(84, 16) + SourceIndex(0) +3 >Emitted(81, 46) Source(84, 3) + SourceIndex(0) +4 >Emitted(81, 56) Source(84, 17) + SourceIndex(0) +5 >Emitted(81, 61) Source(84, 29) + SourceIndex(0) --- >>> return this === other; 1 >^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1487,13 +1492,13 @@ sourceFile:recursiveClassReferenceTest.ts 5 > === 6 > other 7 > ; -1 >Emitted(77, 25) Source(85, 4) + SourceIndex(0) -2 >Emitted(77, 31) Source(85, 10) + SourceIndex(0) -3 >Emitted(77, 32) Source(85, 11) + SourceIndex(0) -4 >Emitted(77, 36) Source(85, 15) + SourceIndex(0) -5 >Emitted(77, 41) Source(85, 20) + SourceIndex(0) -6 >Emitted(77, 46) Source(85, 25) + SourceIndex(0) -7 >Emitted(77, 47) Source(85, 26) + SourceIndex(0) +1 >Emitted(82, 25) Source(85, 4) + SourceIndex(0) +2 >Emitted(82, 31) Source(85, 10) + SourceIndex(0) +3 >Emitted(82, 32) Source(85, 11) + SourceIndex(0) +4 >Emitted(82, 36) Source(85, 15) + SourceIndex(0) +5 >Emitted(82, 41) Source(85, 20) + SourceIndex(0) +6 >Emitted(82, 46) Source(85, 25) + SourceIndex(0) +7 >Emitted(82, 47) Source(85, 26) + SourceIndex(0) --- >>> }; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1502,8 +1507,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(78, 21) Source(86, 3) + SourceIndex(0) -2 >Emitted(78, 22) Source(86, 4) + SourceIndex(0) +1 >Emitted(83, 21) Source(86, 3) + SourceIndex(0) +2 >Emitted(83, 22) Source(86, 4) + SourceIndex(0) --- >>> State.prototype.getMode = function () { return mode; }; 1->^^^^^^^^^^^^^^^^^^^^ @@ -1528,16 +1533,16 @@ sourceFile:recursiveClassReferenceTest.ts 8 > ; 9 > 10> } -1->Emitted(79, 21) Source(88, 10) + SourceIndex(0) -2 >Emitted(79, 44) Source(88, 17) + SourceIndex(0) -3 >Emitted(79, 47) Source(88, 3) + SourceIndex(0) -4 >Emitted(79, 61) Source(88, 29) + SourceIndex(0) -5 >Emitted(79, 67) Source(88, 35) + SourceIndex(0) -6 >Emitted(79, 68) Source(88, 36) + SourceIndex(0) -7 >Emitted(79, 72) Source(88, 40) + SourceIndex(0) -8 >Emitted(79, 73) Source(88, 41) + SourceIndex(0) -9 >Emitted(79, 74) Source(88, 42) + SourceIndex(0) -10>Emitted(79, 75) Source(88, 43) + SourceIndex(0) +1->Emitted(84, 21) Source(88, 10) + SourceIndex(0) +2 >Emitted(84, 44) Source(88, 17) + SourceIndex(0) +3 >Emitted(84, 47) Source(88, 3) + SourceIndex(0) +4 >Emitted(84, 61) Source(88, 29) + SourceIndex(0) +5 >Emitted(84, 67) Source(88, 35) + SourceIndex(0) +6 >Emitted(84, 68) Source(88, 36) + SourceIndex(0) +7 >Emitted(84, 72) Source(88, 40) + SourceIndex(0) +8 >Emitted(84, 73) Source(88, 41) + SourceIndex(0) +9 >Emitted(84, 74) Source(88, 42) + SourceIndex(0) +10>Emitted(84, 75) Source(88, 43) + SourceIndex(0) --- >>> return State; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1545,8 +1550,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(80, 21) Source(89, 2) + SourceIndex(0) -2 >Emitted(80, 33) Source(89, 3) + SourceIndex(0) +1 >Emitted(85, 21) Source(89, 2) + SourceIndex(0) +2 >Emitted(85, 33) Source(89, 3) + SourceIndex(0) --- >>> }()); 1 >^^^^^^^^^^^^^^^^ @@ -1569,10 +1574,10 @@ sourceFile:recursiveClassReferenceTest.ts > > public getMode(): IMode { return mode; } > } -1 >Emitted(81, 17) Source(89, 2) + SourceIndex(0) -2 >Emitted(81, 18) Source(89, 3) + SourceIndex(0) -3 >Emitted(81, 18) Source(78, 2) + SourceIndex(0) -4 >Emitted(81, 22) Source(89, 3) + SourceIndex(0) +1 >Emitted(86, 17) Source(89, 2) + SourceIndex(0) +2 >Emitted(86, 18) Source(89, 3) + SourceIndex(0) +3 >Emitted(86, 18) Source(78, 2) + SourceIndex(0) +4 >Emitted(86, 22) Source(89, 3) + SourceIndex(0) --- >>> PlainText.State = State; 1->^^^^^^^^^^^^^^^^ @@ -1595,10 +1600,10 @@ sourceFile:recursiveClassReferenceTest.ts > public getMode(): IMode { return mode; } > } 4 > -1->Emitted(82, 17) Source(78, 15) + SourceIndex(0) -2 >Emitted(82, 32) Source(78, 20) + SourceIndex(0) -3 >Emitted(82, 40) Source(89, 3) + SourceIndex(0) -4 >Emitted(82, 41) Source(89, 3) + SourceIndex(0) +1->Emitted(87, 17) Source(78, 15) + SourceIndex(0) +2 >Emitted(87, 32) Source(78, 20) + SourceIndex(0) +3 >Emitted(87, 40) Source(89, 3) + SourceIndex(0) +4 >Emitted(87, 41) Source(89, 3) + SourceIndex(0) --- >>> var Mode = (function (_super) { 1->^^^^^^^^^^^^^^^^ @@ -1606,23 +1611,23 @@ sourceFile:recursiveClassReferenceTest.ts 1-> > > -1->Emitted(83, 17) Source(91, 2) + SourceIndex(0) +1->Emitted(88, 17) Source(91, 2) + SourceIndex(0) --- >>> __extends(Mode, _super); 1->^^^^^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^ 1->export class Mode extends 2 > AbstractMode -1->Emitted(84, 21) Source(91, 28) + SourceIndex(0) -2 >Emitted(84, 45) Source(91, 40) + SourceIndex(0) +1->Emitted(89, 21) Source(91, 28) + SourceIndex(0) +2 >Emitted(89, 45) Source(91, 40) + SourceIndex(0) --- >>> function Mode() { 1 >^^^^^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(85, 21) Source(91, 2) + SourceIndex(0) +1 >Emitted(90, 21) Source(91, 2) + SourceIndex(0) --- ->>> return _super.apply(this, arguments) || this; +>>> return _super !== null && _super.apply(this, arguments) || this; >>> } 1->^^^^^^^^^^^^^^^^^^^^ 2 > ^ @@ -1637,8 +1642,8 @@ sourceFile:recursiveClassReferenceTest.ts > > 2 > } -1->Emitted(87, 21) Source(99, 2) + SourceIndex(0) -2 >Emitted(87, 22) Source(99, 3) + SourceIndex(0) +1->Emitted(92, 21) Source(99, 2) + SourceIndex(0) +2 >Emitted(92, 22) Source(99, 3) + SourceIndex(0) --- >>> // scenario 2 1->^^^^^^^^^^^^^^^^^^^^ @@ -1646,8 +1651,8 @@ sourceFile:recursiveClassReferenceTest.ts 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> 2 > // scenario 2 -1->Emitted(88, 21) Source(93, 3) + SourceIndex(0) -2 >Emitted(88, 34) Source(93, 16) + SourceIndex(0) +1->Emitted(93, 21) Source(93, 3) + SourceIndex(0) +2 >Emitted(93, 34) Source(93, 16) + SourceIndex(0) --- >>> Mode.prototype.getInitialState = function () { 1->^^^^^^^^^^^^^^^^^^^^ @@ -1657,9 +1662,9 @@ sourceFile:recursiveClassReferenceTest.ts > public 2 > getInitialState 3 > -1->Emitted(89, 21) Source(94, 10) + SourceIndex(0) -2 >Emitted(89, 51) Source(94, 25) + SourceIndex(0) -3 >Emitted(89, 54) Source(94, 3) + SourceIndex(0) +1->Emitted(94, 21) Source(94, 10) + SourceIndex(0) +2 >Emitted(94, 51) Source(94, 25) + SourceIndex(0) +3 >Emitted(94, 54) Source(94, 3) + SourceIndex(0) --- >>> return new State(self); 1 >^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1681,15 +1686,15 @@ sourceFile:recursiveClassReferenceTest.ts 7 > self 8 > ) 9 > ; -1 >Emitted(90, 25) Source(95, 4) + SourceIndex(0) -2 >Emitted(90, 31) Source(95, 10) + SourceIndex(0) -3 >Emitted(90, 32) Source(95, 11) + SourceIndex(0) -4 >Emitted(90, 36) Source(95, 15) + SourceIndex(0) -5 >Emitted(90, 41) Source(95, 20) + SourceIndex(0) -6 >Emitted(90, 42) Source(95, 21) + SourceIndex(0) -7 >Emitted(90, 46) Source(95, 25) + SourceIndex(0) -8 >Emitted(90, 47) Source(95, 26) + SourceIndex(0) -9 >Emitted(90, 48) Source(95, 27) + SourceIndex(0) +1 >Emitted(95, 25) Source(95, 4) + SourceIndex(0) +2 >Emitted(95, 31) Source(95, 10) + SourceIndex(0) +3 >Emitted(95, 32) Source(95, 11) + SourceIndex(0) +4 >Emitted(95, 36) Source(95, 15) + SourceIndex(0) +5 >Emitted(95, 41) Source(95, 20) + SourceIndex(0) +6 >Emitted(95, 42) Source(95, 21) + SourceIndex(0) +7 >Emitted(95, 46) Source(95, 25) + SourceIndex(0) +8 >Emitted(95, 47) Source(95, 26) + SourceIndex(0) +9 >Emitted(95, 48) Source(95, 27) + SourceIndex(0) --- >>> }; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1698,8 +1703,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > 2 > } -1 >Emitted(91, 21) Source(96, 3) + SourceIndex(0) -2 >Emitted(91, 22) Source(96, 4) + SourceIndex(0) +1 >Emitted(96, 21) Source(96, 3) + SourceIndex(0) +2 >Emitted(96, 22) Source(96, 4) + SourceIndex(0) --- >>> return Mode; 1->^^^^^^^^^^^^^^^^^^^^ @@ -1710,8 +1715,8 @@ sourceFile:recursiveClassReferenceTest.ts > > 2 > } -1->Emitted(92, 21) Source(99, 2) + SourceIndex(0) -2 >Emitted(92, 32) Source(99, 3) + SourceIndex(0) +1->Emitted(97, 21) Source(99, 2) + SourceIndex(0) +2 >Emitted(97, 32) Source(99, 3) + SourceIndex(0) --- >>> }(AbstractMode)); 1->^^^^^^^^^^^^^^^^ @@ -1735,12 +1740,12 @@ sourceFile:recursiveClassReferenceTest.ts > > > } -1->Emitted(93, 17) Source(99, 2) + SourceIndex(0) -2 >Emitted(93, 18) Source(99, 3) + SourceIndex(0) -3 >Emitted(93, 18) Source(91, 2) + SourceIndex(0) -4 >Emitted(93, 19) Source(91, 28) + SourceIndex(0) -5 >Emitted(93, 31) Source(91, 40) + SourceIndex(0) -6 >Emitted(93, 34) Source(99, 3) + SourceIndex(0) +1->Emitted(98, 17) Source(99, 2) + SourceIndex(0) +2 >Emitted(98, 18) Source(99, 3) + SourceIndex(0) +3 >Emitted(98, 18) Source(91, 2) + SourceIndex(0) +4 >Emitted(98, 19) Source(91, 28) + SourceIndex(0) +5 >Emitted(98, 31) Source(91, 40) + SourceIndex(0) +6 >Emitted(98, 34) Source(99, 3) + SourceIndex(0) --- >>> PlainText.Mode = Mode; 1->^^^^^^^^^^^^^^^^ @@ -1760,10 +1765,10 @@ sourceFile:recursiveClassReferenceTest.ts > > } 4 > -1->Emitted(94, 17) Source(91, 15) + SourceIndex(0) -2 >Emitted(94, 31) Source(91, 19) + SourceIndex(0) -3 >Emitted(94, 38) Source(99, 3) + SourceIndex(0) -4 >Emitted(94, 39) Source(99, 3) + SourceIndex(0) +1->Emitted(99, 17) Source(91, 15) + SourceIndex(0) +2 >Emitted(99, 31) Source(91, 19) + SourceIndex(0) +3 >Emitted(99, 38) Source(99, 3) + SourceIndex(0) +4 >Emitted(99, 39) Source(99, 3) + SourceIndex(0) --- >>> })(PlainText = Languages.PlainText || (Languages.PlainText = {})); 1->^^^^^^^^^^^^ @@ -1809,15 +1814,15 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1->Emitted(95, 13) Source(100, 1) + SourceIndex(0) -2 >Emitted(95, 14) Source(100, 2) + SourceIndex(0) -3 >Emitted(95, 16) Source(76, 31) + SourceIndex(0) -4 >Emitted(95, 25) Source(76, 40) + SourceIndex(0) -5 >Emitted(95, 28) Source(76, 31) + SourceIndex(0) -6 >Emitted(95, 47) Source(76, 40) + SourceIndex(0) -7 >Emitted(95, 52) Source(76, 31) + SourceIndex(0) -8 >Emitted(95, 71) Source(76, 40) + SourceIndex(0) -9 >Emitted(95, 79) Source(100, 2) + SourceIndex(0) +1->Emitted(100, 13) Source(100, 1) + SourceIndex(0) +2 >Emitted(100, 14) Source(100, 2) + SourceIndex(0) +3 >Emitted(100, 16) Source(76, 31) + SourceIndex(0) +4 >Emitted(100, 25) Source(76, 40) + SourceIndex(0) +5 >Emitted(100, 28) Source(76, 31) + SourceIndex(0) +6 >Emitted(100, 47) Source(76, 40) + SourceIndex(0) +7 >Emitted(100, 52) Source(76, 31) + SourceIndex(0) +8 >Emitted(100, 71) Source(76, 40) + SourceIndex(0) +9 >Emitted(100, 79) Source(100, 2) + SourceIndex(0) --- >>> })(Languages = Thing.Languages || (Thing.Languages = {})); 1 >^^^^^^^^ @@ -1862,15 +1867,15 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(96, 9) Source(100, 1) + SourceIndex(0) -2 >Emitted(96, 10) Source(100, 2) + SourceIndex(0) -3 >Emitted(96, 12) Source(76, 21) + SourceIndex(0) -4 >Emitted(96, 21) Source(76, 30) + SourceIndex(0) -5 >Emitted(96, 24) Source(76, 21) + SourceIndex(0) -6 >Emitted(96, 39) Source(76, 30) + SourceIndex(0) -7 >Emitted(96, 44) Source(76, 21) + SourceIndex(0) -8 >Emitted(96, 59) Source(76, 30) + SourceIndex(0) -9 >Emitted(96, 67) Source(100, 2) + SourceIndex(0) +1 >Emitted(101, 9) Source(100, 1) + SourceIndex(0) +2 >Emitted(101, 10) Source(100, 2) + SourceIndex(0) +3 >Emitted(101, 12) Source(76, 21) + SourceIndex(0) +4 >Emitted(101, 21) Source(76, 30) + SourceIndex(0) +5 >Emitted(101, 24) Source(76, 21) + SourceIndex(0) +6 >Emitted(101, 39) Source(76, 30) + SourceIndex(0) +7 >Emitted(101, 44) Source(76, 21) + SourceIndex(0) +8 >Emitted(101, 59) Source(76, 30) + SourceIndex(0) +9 >Emitted(101, 67) Source(100, 2) + SourceIndex(0) --- >>> })(Thing = Sample.Thing || (Sample.Thing = {})); 1 >^^^^ @@ -1915,15 +1920,15 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(97, 5) Source(100, 1) + SourceIndex(0) -2 >Emitted(97, 6) Source(100, 2) + SourceIndex(0) -3 >Emitted(97, 8) Source(76, 15) + SourceIndex(0) -4 >Emitted(97, 13) Source(76, 20) + SourceIndex(0) -5 >Emitted(97, 16) Source(76, 15) + SourceIndex(0) -6 >Emitted(97, 28) Source(76, 20) + SourceIndex(0) -7 >Emitted(97, 33) Source(76, 15) + SourceIndex(0) -8 >Emitted(97, 45) Source(76, 20) + SourceIndex(0) -9 >Emitted(97, 53) Source(100, 2) + SourceIndex(0) +1 >Emitted(102, 5) Source(100, 1) + SourceIndex(0) +2 >Emitted(102, 6) Source(100, 2) + SourceIndex(0) +3 >Emitted(102, 8) Source(76, 15) + SourceIndex(0) +4 >Emitted(102, 13) Source(76, 20) + SourceIndex(0) +5 >Emitted(102, 16) Source(76, 15) + SourceIndex(0) +6 >Emitted(102, 28) Source(76, 20) + SourceIndex(0) +7 >Emitted(102, 33) Source(76, 15) + SourceIndex(0) +8 >Emitted(102, 45) Source(76, 20) + SourceIndex(0) +9 >Emitted(102, 53) Source(100, 2) + SourceIndex(0) --- >>>})(Sample || (Sample = {})); 1 > @@ -1965,12 +1970,12 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(98, 1) Source(100, 1) + SourceIndex(0) -2 >Emitted(98, 2) Source(100, 2) + SourceIndex(0) -3 >Emitted(98, 4) Source(76, 8) + SourceIndex(0) -4 >Emitted(98, 10) Source(76, 14) + SourceIndex(0) -5 >Emitted(98, 15) Source(76, 8) + SourceIndex(0) -6 >Emitted(98, 21) Source(76, 14) + SourceIndex(0) -7 >Emitted(98, 29) Source(100, 2) + SourceIndex(0) +1 >Emitted(103, 1) Source(100, 1) + SourceIndex(0) +2 >Emitted(103, 2) Source(100, 2) + SourceIndex(0) +3 >Emitted(103, 4) Source(76, 8) + SourceIndex(0) +4 >Emitted(103, 10) Source(76, 14) + SourceIndex(0) +5 >Emitted(103, 15) Source(76, 8) + SourceIndex(0) +6 >Emitted(103, 21) Source(76, 14) + SourceIndex(0) +7 >Emitted(103, 29) Source(100, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=recursiveClassReferenceTest.js.map \ No newline at end of file diff --git a/tests/baselines/reference/recursiveComplicatedClasses.js b/tests/baselines/reference/recursiveComplicatedClasses.js index 8441ff9e15a..cb46865c46f 100644 --- a/tests/baselines/reference/recursiveComplicatedClasses.js +++ b/tests/baselines/reference/recursiveComplicatedClasses.js @@ -25,11 +25,16 @@ class TypeSymbol extends InferenceSymbol { } //// [recursiveComplicatedClasses.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Signature = (function () { function Signature() { this.parameters = null; @@ -51,21 +56,21 @@ var Symbol = (function () { var InferenceSymbol = (function (_super) { __extends(InferenceSymbol, _super); function InferenceSymbol() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return InferenceSymbol; }(Symbol)); var ParameterSymbol = (function (_super) { __extends(ParameterSymbol, _super); function ParameterSymbol() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ParameterSymbol; }(InferenceSymbol)); var TypeSymbol = (function (_super) { __extends(TypeSymbol, _super); function TypeSymbol() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return TypeSymbol; }(InferenceSymbol)); diff --git a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType1.js b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType1.js index d759bc2f296..87ef9fe8671 100644 --- a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType1.js +++ b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType1.js @@ -29,4 +29,5 @@ define(["require", "exports"], function (require, exports) { //// [recursiveExportAssignmentAndFindAliasedType1_moduleA.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType2.js b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType2.js index 7704b38f68d..c38c38ea325 100644 --- a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType2.js +++ b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType2.js @@ -33,4 +33,5 @@ define(["require", "exports"], function (require, exports) { //// [recursiveExportAssignmentAndFindAliasedType2_moduleA.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType3.js b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType3.js index a46be3bdafc..178d8b3b3ee 100644 --- a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType3.js +++ b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType3.js @@ -37,4 +37,5 @@ define(["require", "exports"], function (require, exports) { //// [recursiveExportAssignmentAndFindAliasedType3_moduleA.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType4.js b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType4.js index 8ccd6ecf560..893c4ec990f 100644 --- a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType4.js +++ b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType4.js @@ -31,4 +31,5 @@ define(["require", "exports"], function (require, exports) { //// [recursiveExportAssignmentAndFindAliasedType4_moduleA.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType5.js b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType5.js index 4602ed554e5..39cb223d1a0 100644 --- a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType5.js +++ b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType5.js @@ -40,4 +40,5 @@ define(["require", "exports"], function (require, exports) { //// [recursiveExportAssignmentAndFindAliasedType5_moduleA.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType6.js b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType6.js index d3487519218..d8541df0c2c 100644 --- a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType6.js +++ b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType6.js @@ -49,4 +49,5 @@ define(["require", "exports"], function (require, exports) { //// [recursiveExportAssignmentAndFindAliasedType6_moduleA.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType7.js b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType7.js index 9a29c2bf949..01f818d5bb2 100644 --- a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType7.js +++ b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType7.js @@ -51,4 +51,5 @@ define(["require", "exports"], function (require, exports) { //// [recursiveExportAssignmentAndFindAliasedType7_moduleA.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/recursiveFunctionTypes.errors.txt b/tests/baselines/reference/recursiveFunctionTypes.errors.txt index 8614f747016..8a454133a82 100644 --- a/tests/baselines/reference/recursiveFunctionTypes.errors.txt +++ b/tests/baselines/reference/recursiveFunctionTypes.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/recursiveFunctionTypes.ts(1,35): error TS2322: Type '1' is not assignable to type '() => typeof fn'. +tests/cases/compiler/recursiveFunctionTypes.ts(1,28): error TS2322: Type '1' is not assignable to type '() => typeof fn'. 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'. @@ -16,7 +16,7 @@ tests/cases/compiler/recursiveFunctionTypes.ts(43,4): error TS2345: Argument of ==== tests/cases/compiler/recursiveFunctionTypes.ts (13 errors) ==== function fn(): typeof fn { return 1; } - ~ + ~~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type '() => typeof fn'. var x: number = fn; // error diff --git a/tests/baselines/reference/recursiveMods.js b/tests/baselines/reference/recursiveMods.js index 6f8304df658..3c41bed5e62 100644 --- a/tests/baselines/reference/recursiveMods.js +++ b/tests/baselines/reference/recursiveMods.js @@ -26,6 +26,7 @@ export module Foo { //// [recursiveMods.js] "use strict"; +exports.__esModule = true; var Foo; (function (Foo) { var C = (function () { diff --git a/tests/baselines/reference/recursiveReturns.js b/tests/baselines/reference/recursiveReturns.js index 18c9ed4dd7c..d2619e18796 100644 --- a/tests/baselines/reference/recursiveReturns.js +++ b/tests/baselines/reference/recursiveReturns.js @@ -23,6 +23,7 @@ function R1() { function R2() { R2(); } function R3(n) { if (n == 0) { + //return; } else { R3(n--); diff --git a/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js b/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js index 76224741e60..ee976ff3da1 100644 --- a/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js +++ b/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js @@ -30,11 +30,16 @@ declare module MsPortal.Controls.Base.ItemList { */ //// [recursivelySpecializedConstructorDeclaration.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var MsPortal; (function (MsPortal) { var Controls; @@ -52,7 +57,7 @@ var MsPortal; var ViewModel = (function (_super) { __extends(ViewModel, _super); function ViewModel() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ViewModel; }(ItemValue)); diff --git a/tests/baselines/reference/reexportClassDefinition.js b/tests/baselines/reference/reexportClassDefinition.js index a75a90d4d86..aae728c9e25 100644 --- a/tests/baselines/reference/reexportClassDefinition.js +++ b/tests/baselines/reference/reexportClassDefinition.js @@ -33,16 +33,22 @@ module.exports = { }; //// [foo3.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var foo2 = require("./foo2"); var x = (function (_super) { __extends(x, _super); function x() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return x; }(foo2.x)); diff --git a/tests/baselines/reference/relativeNamesInClassicResolution.js b/tests/baselines/reference/relativeNamesInClassicResolution.js index a6c5a06ea3d..cf43ec2a5ca 100644 --- a/tests/baselines/reference/relativeNamesInClassicResolution.js +++ b/tests/baselines/reference/relativeNamesInClassicResolution.js @@ -10,9 +10,11 @@ export let x = 1; //// [a.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); //// [b.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.x = 1; }); diff --git a/tests/baselines/reference/relativePathMustResolve.js b/tests/baselines/reference/relativePathMustResolve.js index 6986d8ddb68..52e760a0240 100644 --- a/tests/baselines/reference/relativePathMustResolve.js +++ b/tests/baselines/reference/relativePathMustResolve.js @@ -10,5 +10,6 @@ var z = foo.x + 10; //// [foo_1.js] "use strict"; +exports.__esModule = true; var foo = require("./test/foo"); var z = foo.x + 10; diff --git a/tests/baselines/reference/relativePathToDeclarationFile.js b/tests/baselines/reference/relativePathToDeclarationFile.js index 36673510aef..58cf090ad86 100644 --- a/tests/baselines/reference/relativePathToDeclarationFile.js +++ b/tests/baselines/reference/relativePathToDeclarationFile.js @@ -28,6 +28,7 @@ if(foo.M2.x){ //// [file1.js] "use strict"; +exports.__esModule = true; var foo = require("foo"); var other = require("./other"); var relMod = require("./sub/relMod"); diff --git a/tests/baselines/reference/requireAsFunctionInExternalModule.js b/tests/baselines/reference/requireAsFunctionInExternalModule.js index a8b14db3138..f4eac77052a 100644 --- a/tests/baselines/reference/requireAsFunctionInExternalModule.js +++ b/tests/baselines/reference/requireAsFunctionInExternalModule.js @@ -18,13 +18,14 @@ hello(); //// [c.js] "use strict"; -function require(a) { } exports.__esModule = true; +function require(a) { } exports["default"] = require; function has(a) { return true; } exports.has = has; //// [m.js] "use strict"; +exports.__esModule = true; var c_1 = require("./c"); function hello() { } exports.hello = hello; @@ -33,5 +34,6 @@ if (c_1.has('ember-debug')) { } //// [m2.js] "use strict"; +exports.__esModule = true; var m_1 = require("./m"); m_1.hello(); diff --git a/tests/baselines/reference/requireEmitSemicolon.js b/tests/baselines/reference/requireEmitSemicolon.js index 7ac73b6f3df..667002efeaa 100644 --- a/tests/baselines/reference/requireEmitSemicolon.js +++ b/tests/baselines/reference/requireEmitSemicolon.js @@ -22,6 +22,7 @@ export module Database { //// [requireEmitSemicolon_0.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var Models; (function (Models) { var Person = (function () { @@ -35,6 +36,7 @@ define(["require", "exports"], function (require, exports) { //// [requireEmitSemicolon_1.js] define(["require", "exports", "requireEmitSemicolon_0"], function (require, exports, P) { "use strict"; + exports.__esModule = true; var Database; (function (Database) { var DB = (function () { diff --git a/tests/baselines/reference/requireOfAnEmptyFile1.js b/tests/baselines/reference/requireOfAnEmptyFile1.js index 53642272191..a1e6dbbc447 100644 --- a/tests/baselines/reference/requireOfAnEmptyFile1.js +++ b/tests/baselines/reference/requireOfAnEmptyFile1.js @@ -12,3 +12,4 @@ import fs = require('./requireOfAnEmptyFile1_b'); //// [requireOfAnEmptyFile1_a.js] //requireOfAnEmptyFile1 "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/reservedNamesInAliases.errors.txt b/tests/baselines/reference/reservedNamesInAliases.errors.txt index b6565427395..22894f8f6a6 100644 --- a/tests/baselines/reference/reservedNamesInAliases.errors.txt +++ b/tests/baselines/reference/reservedNamesInAliases.errors.txt @@ -6,9 +6,10 @@ tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,1): error tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,6): error TS1005: ';' expected. tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,11): error TS1109: Expression expected. tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error TS2693: 'I' only refers to a type, but is being used as a value here. +tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(7,6): error TS2457: Type alias name cannot be 'object' -==== tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts (8 errors) ==== +==== tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts (9 errors) ==== interface I {} type any = I; ~~~ @@ -30,4 +31,8 @@ tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error ~ !!! error TS1109: Expression expected. ~ -!!! error TS2693: 'I' only refers to a type, but is being used as a value here. \ No newline at end of file +!!! error TS2693: 'I' only refers to a type, but is being used as a value here. + type object = I; + ~~~~~~ +!!! error TS2457: Type alias name cannot be 'object' + \ No newline at end of file diff --git a/tests/baselines/reference/reservedNamesInAliases.js b/tests/baselines/reference/reservedNamesInAliases.js index 4ebc3bdb95f..368331d3114 100644 --- a/tests/baselines/reference/reservedNamesInAliases.js +++ b/tests/baselines/reference/reservedNamesInAliases.js @@ -4,7 +4,9 @@ type any = I; type number = I; type boolean = I; type string = I; -type void = I; +type void = I; +type object = I; + //// [reservedNamesInAliases.js] type; diff --git a/tests/baselines/reference/reservedWords2.js b/tests/baselines/reference/reservedWords2.js index d9c8105c35f..f172f37d053 100644 --- a/tests/baselines/reference/reservedWords2.js +++ b/tests/baselines/reference/reservedWords2.js @@ -15,6 +15,7 @@ enum void {} //// [reservedWords2.js] "use strict"; +exports.__esModule = true; require(); while ( = require("dfdf")) ; diff --git a/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.js b/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.js index 94dc537298a..1a9a3dacbba 100644 --- a/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.js +++ b/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.js @@ -1020,17 +1020,22 @@ module caurinus { //// [resolvingClassDeclarationWhenInBaseTypeResolution.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var rionegrensis; (function (rionegrensis) { var caniventer = (function (_super) { __extends(caniventer, _super); function caniventer() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } caniventer.prototype.salomonseni = function () { var _this = this; @@ -1068,7 +1073,7 @@ var rionegrensis; var veraecrucis = (function (_super) { __extends(veraecrucis, _super); function veraecrucis() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } veraecrucis.prototype.naso = function () { var _this = this; @@ -1247,7 +1252,7 @@ var julianae; var oralis = (function (_super) { __extends(oralis, _super); function oralis() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } oralis.prototype.cepapi = function () { var _this = this; @@ -1333,7 +1338,7 @@ var julianae; var sumatrana = (function (_super) { __extends(sumatrana, _super); function sumatrana() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } sumatrana.prototype.wolffsohni = function () { var _this = this; @@ -1533,7 +1538,7 @@ var julianae; var durangae = (function (_super) { __extends(durangae, _super); function durangae() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } durangae.prototype.Californium = function () { var _this = this; @@ -1607,7 +1612,7 @@ var Lanthanum; var nitidus = (function (_super) { __extends(nitidus, _super); function nitidus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } nitidus.prototype.granatensis = function () { var _this = this; @@ -1675,7 +1680,7 @@ var Lanthanum; var megalonyx = (function (_super) { __extends(megalonyx, _super); function megalonyx() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } megalonyx.prototype.phillipsii = function () { var _this = this; @@ -1824,7 +1829,7 @@ var rendalli; var zuluensis = (function (_super) { __extends(zuluensis, _super); function zuluensis() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } zuluensis.prototype.telfairi = function () { var _this = this; @@ -1982,7 +1987,7 @@ var rendalli; var crenulata = (function (_super) { __extends(crenulata, _super); function crenulata() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } crenulata.prototype.salvanius = function () { var _this = this; @@ -2065,7 +2070,7 @@ var trivirgatus; var mixtus = (function (_super) { __extends(mixtus, _super); function mixtus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } mixtus.prototype.ochrogaster = function () { var _this = this; @@ -2306,7 +2311,7 @@ var quasiater; var americanus = (function (_super) { __extends(americanus, _super); function americanus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } americanus.prototype.nasoloi = function () { var _this = this; @@ -2341,7 +2346,7 @@ var lavali; var wilsoni = (function (_super) { __extends(wilsoni, _super); function wilsoni() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } wilsoni.prototype.setiger = function () { var _this = this; @@ -2433,7 +2438,7 @@ var lavali; var otion = (function (_super) { __extends(otion, _super); function otion() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } otion.prototype.bonaerensis = function () { var _this = this; @@ -2597,7 +2602,7 @@ var lavali; var thaeleri = (function (_super) { __extends(thaeleri, _super); function thaeleri() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } thaeleri.prototype.coromandra = function () { var _this = this; @@ -2653,7 +2658,7 @@ var lavali; var lepturus = (function (_super) { __extends(lepturus, _super); function lepturus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } lepturus.prototype.ferrumequinum = function () { var _this = this; @@ -2676,7 +2681,7 @@ var dogramacii; var robustulus = (function (_super) { __extends(robustulus, _super); function robustulus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } robustulus.prototype.fossor = function () { var _this = this; @@ -2891,7 +2896,7 @@ var lutreolus; var schlegeli = (function (_super) { __extends(schlegeli, _super); function schlegeli() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } schlegeli.prototype.mittendorfi = function () { var _this = this; @@ -3118,7 +3123,7 @@ var panglima; var amphibius = (function (_super) { __extends(amphibius, _super); function amphibius() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } amphibius.prototype.bottegi = function () { var _this = this; @@ -3162,7 +3167,7 @@ var panglima; var fundatus = (function (_super) { __extends(fundatus, _super); function fundatus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } fundatus.prototype.crassulus = function () { var _this = this; @@ -3188,7 +3193,7 @@ var panglima; var abidi = (function (_super) { __extends(abidi, _super); function abidi() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } abidi.prototype.greyii = function () { var _this = this; @@ -3279,7 +3284,7 @@ var minutus; var himalayana = (function (_super) { __extends(himalayana, _super); function himalayana() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } himalayana.prototype.simoni = function () { var _this = this; @@ -3362,7 +3367,7 @@ var caurinus; var mahaganus = (function (_super) { __extends(mahaganus, _super); function mahaganus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } mahaganus.prototype.martiniquensis = function () { var _this = this; @@ -3436,7 +3441,7 @@ var howi; var angulatus = (function (_super) { __extends(angulatus, _super); function angulatus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } angulatus.prototype.pennatus = function () { var _this = this; @@ -3518,7 +3523,7 @@ var sagitta; var walkeri = (function (_super) { __extends(walkeri, _super); function walkeri() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } walkeri.prototype.maracajuensis = function () { var _this = this; @@ -3534,7 +3539,7 @@ var sagitta; var inez = (function (_super) { __extends(inez, _super); function inez() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } inez.prototype.vexillaris = function () { var _this = this; @@ -3550,7 +3555,7 @@ var sagitta; var konganensis = (function (_super) { __extends(konganensis, _super); function konganensis() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return konganensis; }(imperfecta.lasiurus)); @@ -3561,7 +3566,7 @@ var panamensis; var linulus = (function (_super) { __extends(linulus, _super); function linulus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } linulus.prototype.goslingi = function () { var _this = this; @@ -3712,7 +3717,7 @@ var samarensis; var pelurus = (function (_super) { __extends(pelurus, _super); function pelurus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } pelurus.prototype.Palladium = function () { var _this = this; @@ -3798,7 +3803,7 @@ var samarensis; var fuscus = (function (_super) { __extends(fuscus, _super); function fuscus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } fuscus.prototype.planifrons = function () { var _this = this; @@ -3958,7 +3963,7 @@ var samarensis; var leptoceros = (function (_super) { __extends(leptoceros, _super); function leptoceros() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } leptoceros.prototype.victus = function () { var _this = this; @@ -3998,7 +4003,7 @@ var samarensis; var nigricans = (function (_super) { __extends(nigricans, _super); function nigricans() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } nigricans.prototype.woosnami = function () { var _this = this; @@ -4023,7 +4028,7 @@ var dammermani; var pygmaea = (function (_super) { __extends(pygmaea, _super); function pygmaea() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } pygmaea.prototype.pajeros = function () { var _this = this; @@ -4052,7 +4057,7 @@ var chrysaeolus; var sarasinorum = (function (_super) { __extends(sarasinorum, _super); function sarasinorum() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } sarasinorum.prototype.belzebul = function () { var _this = this; @@ -4154,7 +4159,7 @@ var chrysaeolus; var oreas = (function (_super) { __extends(oreas, _super); function oreas() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } oreas.prototype.salamonis = function () { var _this = this; @@ -4380,7 +4385,7 @@ var provocax; var melanoleuca = (function (_super) { __extends(melanoleuca, _super); function melanoleuca() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } melanoleuca.prototype.Neodymium = function () { var _this = this; @@ -4422,7 +4427,7 @@ var provocax; var marcanoi = (function (_super) { __extends(marcanoi, _super); function marcanoi() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } marcanoi.prototype.formosae = function () { var _this = this; @@ -4824,7 +4829,7 @@ var gabriellae; var klossii = (function (_super) { __extends(klossii, _super); function klossii() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return klossii; }(imperfecta.lasiurus)); @@ -5027,7 +5032,7 @@ var imperfecta; var ciliolabrum = (function (_super) { __extends(ciliolabrum, _super); function ciliolabrum() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } ciliolabrum.prototype.leschenaultii = function () { var _this = this; @@ -5087,7 +5092,7 @@ var imperfecta; var sodyi = (function (_super) { __extends(sodyi, _super); function sodyi() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } sodyi.prototype.saundersiae = function () { var _this = this; @@ -5151,7 +5156,7 @@ var imperfecta; var megaphyllus = (function (_super) { __extends(megaphyllus, _super); function megaphyllus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } megaphyllus.prototype.montana = function () { var _this = this; @@ -5321,7 +5326,7 @@ var imperfecta; var cor = (function (_super) { __extends(cor, _super); function cor() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } cor.prototype.antinorii = function () { var _this = this; @@ -5411,7 +5416,7 @@ var imperfecta; var germaini = (function (_super) { __extends(germaini, _super); function germaini() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } germaini.prototype.sharpei = function () { var _this = this; @@ -5507,7 +5512,7 @@ var imperfecta; var melanops = (function (_super) { __extends(melanops, _super); function melanops() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } melanops.prototype.blarina = function () { var _this = this; @@ -5595,7 +5600,7 @@ var imperfecta; var peninsulae = (function (_super) { __extends(peninsulae, _super); function peninsulae() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } peninsulae.prototype.aitkeni = function () { var _this = this; @@ -5739,7 +5744,7 @@ var imperfecta; var Praseodymium = (function (_super) { __extends(Praseodymium, _super); function Praseodymium() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Praseodymium.prototype.clara = function () { var _this = this; @@ -5827,7 +5832,7 @@ var imperfecta; var johorensis = (function (_super) { __extends(johorensis, _super); function johorensis() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } johorensis.prototype.maini = function () { var _this = this; @@ -5951,7 +5956,7 @@ var imperfecta; var psilurus = (function (_super) { __extends(psilurus, _super); function psilurus() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } psilurus.prototype.socialis = function () { var _this = this; diff --git a/tests/baselines/reference/returnInConstructor1.errors.txt b/tests/baselines/reference/returnInConstructor1.errors.txt index a7d3fd05204..939d303ec65 100644 --- a/tests/baselines/reference/returnInConstructor1.errors.txt +++ b/tests/baselines/reference/returnInConstructor1.errors.txt @@ -1,15 +1,15 @@ -tests/cases/compiler/returnInConstructor1.ts(11,16): error TS2322: Type '1' is not assignable to type 'B'. -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 '"test"' is not assignable to type 'D'. -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'. +tests/cases/compiler/returnInConstructor1.ts(11,9): error TS2322: Type '1' is not assignable to type 'B'. +tests/cases/compiler/returnInConstructor1.ts(11,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/compiler/returnInConstructor1.ts(25,9): error TS2322: Type '"test"' is not assignable to type 'D'. +tests/cases/compiler/returnInConstructor1.ts(25,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/compiler/returnInConstructor1.ts(39,9): 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'. +tests/cases/compiler/returnInConstructor1.ts(39,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/compiler/returnInConstructor1.ts(55,9): 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(55,9): error TS2409: Return type of constructor signature must be assignable to the instance type of the class ==== tests/cases/compiler/returnInConstructor1.ts (8 errors) ==== @@ -24,9 +24,9 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o foo() { } constructor() { return 1; // error - ~ + ~~~~~~~~~ !!! error TS2322: Type '1' is not assignable to type 'B'. - ~ + ~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } @@ -42,9 +42,9 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o foo() { } constructor() { return "test"; // error - ~~~~~~ + ~~~~~~~~~~~~~~ !!! error TS2322: Type '"test"' is not assignable to type 'D'. - ~~~~~~ + ~~~~~~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } } @@ -60,11 +60,11 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o public foo: string; 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 } } @@ -82,11 +82,11 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o constructor() { 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/returnInConstructor1.js b/tests/baselines/reference/returnInConstructor1.js index a47fa7ed513..6bdcc0cb6a2 100644 --- a/tests/baselines/reference/returnInConstructor1.js +++ b/tests/baselines/reference/returnInConstructor1.js @@ -67,11 +67,16 @@ class I extends G { //// [returnInConstructor1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { return; diff --git a/tests/baselines/reference/returnStatements.js b/tests/baselines/reference/returnStatements.js index f786e994963..617911be759 100644 --- a/tests/baselines/reference/returnStatements.js +++ b/tests/baselines/reference/returnStatements.js @@ -25,11 +25,16 @@ function fn13(): C { return null; } //// [returnStatements.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // all the following should be valid function fn1() { return 1; } function fn2() { return ''; } @@ -48,7 +53,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/returnValueInSetter.errors.txt b/tests/baselines/reference/returnValueInSetter.errors.txt index f9dffa1bc36..4d7b0d185f9 100644 --- a/tests/baselines/reference/returnValueInSetter.errors.txt +++ b/tests/baselines/reference/returnValueInSetter.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/returnValueInSetter.ts(2,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/returnValueInSetter.ts(3,16): error TS2408: Setters cannot return a value. +tests/cases/compiler/returnValueInSetter.ts(3,9): error TS2408: Setters cannot return a value. ==== tests/cases/compiler/returnValueInSetter.ts (2 errors) ==== @@ -8,7 +8,7 @@ tests/cases/compiler/returnValueInSetter.ts(3,16): error TS2408: Setters cannot ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. return null; // Should be an error - ~~~~ + ~~~~~~~~~~~~ !!! error TS2408: Setters cannot return a value. } } diff --git a/tests/baselines/reference/reuseInnerModuleMember.js b/tests/baselines/reference/reuseInnerModuleMember.js index a8d254f56c1..d432daed2a7 100644 --- a/tests/baselines/reference/reuseInnerModuleMember.js +++ b/tests/baselines/reference/reuseInnerModuleMember.js @@ -17,8 +17,10 @@ module bar { //// [reuseInnerModuleMember_0.js] "use strict"; +exports.__esModule = true; //// [reuseInnerModuleMember_1.js] "use strict"; +exports.__esModule = true; /// var bar; (function (bar) { diff --git a/tests/baselines/reference/scannerClass2.js b/tests/baselines/reference/scannerClass2.js index 640f0952bb9..bc489268afd 100644 --- a/tests/baselines/reference/scannerClass2.js +++ b/tests/baselines/reference/scannerClass2.js @@ -9,6 +9,7 @@ //// [scannerClass2.js] "use strict"; +exports.__esModule = true; var LoggerAdapter = (function () { function LoggerAdapter(logger) { this.logger = logger; diff --git a/tests/baselines/reference/scannerEnum1.js b/tests/baselines/reference/scannerEnum1.js index 5d8b506e62f..75c182206b9 100644 --- a/tests/baselines/reference/scannerEnum1.js +++ b/tests/baselines/reference/scannerEnum1.js @@ -6,6 +6,7 @@ //// [scannerEnum1.js] "use strict"; +exports.__esModule = true; var CodeGenTarget; (function (CodeGenTarget) { CodeGenTarget[CodeGenTarget["ES3"] = 0] = "ES3"; diff --git a/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.js b/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.js index 1474f8ab29a..c72fe6dde7d 100644 --- a/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.js +++ b/tests/baselines/reference/scopeCheckExtendedClassInsidePublicMethod2.js @@ -9,11 +9,16 @@ class D extends C { } //// [scopeCheckExtendedClassInsidePublicMethod2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -22,7 +27,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.prototype.c = function () { v = 1; diff --git a/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.js b/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.js index 0baf0187009..34c1698a3ea 100644 --- a/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.js +++ b/tests/baselines/reference/scopeCheckExtendedClassInsideStaticMethod1.js @@ -9,11 +9,16 @@ class D extends C { } //// [scopeCheckExtendedClassInsideStaticMethod1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -22,7 +27,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } D.c = function () { v = 1; diff --git a/tests/baselines/reference/scopeTests.js b/tests/baselines/reference/scopeTests.js index 48863404a8e..b60242c0714 100644 --- a/tests/baselines/reference/scopeTests.js +++ b/tests/baselines/reference/scopeTests.js @@ -12,11 +12,16 @@ class D extends C { } //// [scopeTests.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } diff --git a/tests/baselines/reference/setterWithReturn.errors.txt b/tests/baselines/reference/setterWithReturn.errors.txt index 6aed49105b8..a0f04506a71 100644 --- a/tests/baselines/reference/setterWithReturn.errors.txt +++ b/tests/baselines/reference/setterWithReturn.errors.txt @@ -1,7 +1,7 @@ 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(4,13): 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(7,13): error TS2408: Setters cannot return a value. ==== tests/cases/compiler/setterWithReturn.ts (4 errors) ==== @@ -11,14 +11,14 @@ tests/cases/compiler/setterWithReturn.ts(7,20): error TS2408: Setters cannot ret !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. if (true) { return arg1; - ~~~~ + ~~~~~~~~~~~~ !!! error TS2408: Setters cannot return a value. } else { return 0; ~~~~~~ !!! error TS7027: Unreachable code detected. - ~ + ~~~~~~~~~ !!! error TS2408: Setters cannot return a value. } } diff --git a/tests/baselines/reference/shadowPrivateMembers.js b/tests/baselines/reference/shadowPrivateMembers.js index 4906814f7eb..ce0fd333b91 100644 --- a/tests/baselines/reference/shadowPrivateMembers.js +++ b/tests/baselines/reference/shadowPrivateMembers.js @@ -4,11 +4,16 @@ class derived extends base { private n() {} } //// [shadowPrivateMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var base = (function () { function base() { } @@ -18,7 +23,7 @@ var base = (function () { var derived = (function (_super) { __extends(derived, _super); function derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } derived.prototype.n = function () { }; return derived; diff --git a/tests/baselines/reference/shebangBeforeReferences.js b/tests/baselines/reference/shebangBeforeReferences.js index 6c3e1420c4a..41f3cee97e1 100644 --- a/tests/baselines/reference/shebangBeforeReferences.js +++ b/tests/baselines/reference/shebangBeforeReferences.js @@ -18,5 +18,6 @@ use(x); //// [f.js] #!/usr/bin/env node "use strict"; +exports.__esModule = true; var test_1 = require("test"); use(test_1.x); diff --git a/tests/baselines/reference/shorthand-property-es6-amd.js b/tests/baselines/reference/shorthand-property-es6-amd.js index 383d5d99e9e..0935606ca5d 100644 --- a/tests/baselines/reference/shorthand-property-es6-amd.js +++ b/tests/baselines/reference/shorthand-property-es6-amd.js @@ -8,6 +8,7 @@ const bar = { foo, baz }; //// [test.js] define(["require", "exports", "./foo"], function (require, exports, foo_1) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); const baz = 42; const bar = { foo: foo_1.foo, baz }; }); diff --git a/tests/baselines/reference/shorthandOfExportedEntity01_targetES2015_CommonJS.js b/tests/baselines/reference/shorthandOfExportedEntity01_targetES2015_CommonJS.js index c1728d68e9b..b61620c8eb5 100644 --- a/tests/baselines/reference/shorthandOfExportedEntity01_targetES2015_CommonJS.js +++ b/tests/baselines/reference/shorthandOfExportedEntity01_targetES2015_CommonJS.js @@ -9,6 +9,7 @@ export function foo () { //// [shorthandOfExportedEntity01_targetES2015_CommonJS.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.test = "test"; function foo() { const x = { test: exports.test }; diff --git a/tests/baselines/reference/shorthandOfExportedEntity02_targetES5_CommonJS.js b/tests/baselines/reference/shorthandOfExportedEntity02_targetES5_CommonJS.js index e89a413463e..9c63ca6aa28 100644 --- a/tests/baselines/reference/shorthandOfExportedEntity02_targetES5_CommonJS.js +++ b/tests/baselines/reference/shorthandOfExportedEntity02_targetES5_CommonJS.js @@ -9,6 +9,7 @@ export function foo () { //// [shorthandOfExportedEntity02_targetES5_CommonJS.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.test = "test"; function foo() { var x = { test: exports.test }; diff --git a/tests/baselines/reference/shorthandPropertyAssignmentInES6Module.js b/tests/baselines/reference/shorthandPropertyAssignmentInES6Module.js index fad9c37ea8f..f5c7a53f307 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentInES6Module.js +++ b/tests/baselines/reference/shorthandPropertyAssignmentInES6Module.js @@ -17,9 +17,11 @@ use(foo); //// [existingModule.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); exports.x = 1; //// [test.js] "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); const existingModule_1 = require("./existingModule"); const missingModule_1 = require("./missingModule"); const test = { x: existingModule_1.x, foo: missingModule_1.foo }; diff --git a/tests/baselines/reference/signaturesUseJSDocForOptionalParameters.types b/tests/baselines/reference/signaturesUseJSDocForOptionalParameters.types index f8822397306..99bf5e15fa7 100644 --- a/tests/baselines/reference/signaturesUseJSDocForOptionalParameters.types +++ b/tests/baselines/reference/signaturesUseJSDocForOptionalParameters.types @@ -15,39 +15,39 @@ function MyClass() { * @returns {MyClass} */ MyClass.prototype.optionalParam = function(required, notRequired) { ->MyClass.prototype.optionalParam = function(required, notRequired) { return this;} : (required: string, notRequired?: string) => { prop: null; optionalParam: any; } +>MyClass.prototype.optionalParam = function(required, notRequired) { return this;} : (required: string, notRequired?: string) => { prop: any; optionalParam: any; } >MyClass.prototype.optionalParam : any >MyClass.prototype : any >MyClass : () => void >prototype : any >optionalParam : any ->function(required, notRequired) { return this;} : (required: string, notRequired?: string) => { prop: null; optionalParam: any; } +>function(required, notRequired) { return this;} : (required: string, notRequired?: string) => { prop: any; optionalParam: any; } >required : string >notRequired : string return this; ->this : { prop: null; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } +>this : { prop: any; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } }; let pInst = new MyClass(); ->pInst : { prop: null; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } ->new MyClass() : { prop: null; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } +>pInst : { prop: any; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } +>new MyClass() : { prop: any; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } >MyClass : () => void let c1 = pInst.optionalParam('hello') ->c1 : { prop: null; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } ->pInst.optionalParam('hello') : { prop: null; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } ->pInst.optionalParam : (required: string, notRequired?: string) => { prop: null; optionalParam: any; } ->pInst : { prop: null; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } ->optionalParam : (required: string, notRequired?: string) => { prop: null; optionalParam: any; } +>c1 : { prop: any; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } +>pInst.optionalParam('hello') : { prop: any; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } +>pInst.optionalParam : (required: string, notRequired?: string) => { prop: any; optionalParam: any; } +>pInst : { prop: any; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } +>optionalParam : (required: string, notRequired?: string) => { prop: any; optionalParam: any; } >'hello' : "hello" let c2 = pInst.optionalParam('hello', null) ->c2 : { prop: null; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } ->pInst.optionalParam('hello', null) : { prop: null; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } ->pInst.optionalParam : (required: string, notRequired?: string) => { prop: null; optionalParam: any; } ->pInst : { prop: null; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } ->optionalParam : (required: string, notRequired?: string) => { prop: null; optionalParam: any; } +>c2 : { prop: any; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } +>pInst.optionalParam('hello', null) : { prop: any; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } +>pInst.optionalParam : (required: string, notRequired?: string) => { prop: any; optionalParam: any; } +>pInst : { prop: any; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } +>optionalParam : (required: string, notRequired?: string) => { prop: any; optionalParam: any; } >'hello' : "hello" >null : null diff --git a/tests/baselines/reference/sourceMap-SkippedNode.js b/tests/baselines/reference/sourceMap-SkippedNode.js index 656b5a244e9..f25c0d75c82 100644 --- a/tests/baselines/reference/sourceMap-SkippedNode.js +++ b/tests/baselines/reference/sourceMap-SkippedNode.js @@ -7,7 +7,9 @@ try { //// [sourceMap-SkippedNode.js] try { + // ... } finally { + // N.B. No 'catch' block } //# sourceMappingURL=sourceMap-SkippedNode.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMap-SkippedNode.js.map b/tests/baselines/reference/sourceMap-SkippedNode.js.map index 77340424640..f3444919d41 100644 --- a/tests/baselines/reference/sourceMap-SkippedNode.js.map +++ b/tests/baselines/reference/sourceMap-SkippedNode.js.map @@ -1,2 +1,2 @@ //// [sourceMap-SkippedNode.js.map] -{"version":3,"file":"sourceMap-SkippedNode.js","sourceRoot":"","sources":["sourceMap-SkippedNode.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC;AAEL,CAAC;QAAS,CAAC;AAEX,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMap-SkippedNode.js","sourceRoot":"","sources":["sourceMap-SkippedNode.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC;IACL,MAAM;AACN,CAAC;QAAS,CAAC;IACX,wBAAwB;AACxB,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMap-SkippedNode.sourcemap.txt b/tests/baselines/reference/sourceMap-SkippedNode.sourcemap.txt index f68320a531f..c54676a697e 100644 --- a/tests/baselines/reference/sourceMap-SkippedNode.sourcemap.txt +++ b/tests/baselines/reference/sourceMap-SkippedNode.sourcemap.txt @@ -12,6 +12,7 @@ sourceFile:sourceMap-SkippedNode.ts 1 > 2 >^^^^ 3 > ^ +4 > ^^^^^^-> 1 > 2 >try 3 > { @@ -19,34 +20,51 @@ sourceFile:sourceMap-SkippedNode.ts 2 >Emitted(1, 5) Source(1, 5) + SourceIndex(0) 3 >Emitted(1, 6) Source(1, 6) + SourceIndex(0) --- +>>> // ... +1->^^^^ +2 > ^^^^^^ +1-> + > +2 > // ... +1->Emitted(2, 5) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 11) Source(2, 7) + SourceIndex(0) +--- >>>} 1 > 2 >^ 3 > ^^^^^^^^^-> 1 > - >// ... > 2 >} -1 >Emitted(2, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(2, 2) Source(3, 2) + SourceIndex(0) +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 2) Source(3, 2) + SourceIndex(0) --- >>>finally { 1->^^^^^^^^ 2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^-> 1-> finally 2 > { -1->Emitted(3, 9) Source(3, 11) + SourceIndex(0) -2 >Emitted(3, 10) Source(3, 12) + SourceIndex(0) +1->Emitted(4, 9) Source(3, 11) + SourceIndex(0) +2 >Emitted(4, 10) Source(3, 12) + SourceIndex(0) +--- +>>> // N.B. No 'catch' block +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^ +1-> + > +2 > // N.B. No 'catch' block +1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) +2 >Emitted(5, 29) Source(4, 25) + SourceIndex(0) --- >>>} 1 > 2 >^ 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > - >// N.B. No 'catch' block > 2 >} -1 >Emitted(4, 1) Source(5, 1) + SourceIndex(0) -2 >Emitted(4, 2) Source(5, 2) + SourceIndex(0) +1 >Emitted(6, 1) Source(5, 1) + SourceIndex(0) +2 >Emitted(6, 2) Source(5, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMap-SkippedNode.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js index 4bac0210c85..44638fa007e 100644 --- a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js +++ b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js @@ -8,11 +8,16 @@ class Greeter extends AbstractGreeter { } //// [sourceMapValidationClassWithDefaultConstructorAndExtendsClause.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var AbstractGreeter = (function () { function AbstractGreeter() { } @@ -21,7 +26,7 @@ var AbstractGreeter = (function () { var Greeter = (function (_super) { __extends(Greeter, _super); function Greeter() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.a = 10; _this.nameA = "Ten"; return _this; diff --git a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js.map b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js.map index 6b18a783dfa..60e19fc95d2 100644 --- a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js.map +++ b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js.map] -{"version":3,"file":"sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js","sourceRoot":"","sources":["sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts"],"names":[],"mappings":";;;;;AAAA;IAAA;IACA,CAAC;IAAD,sBAAC;AAAD,CAAC,AADD,IACC;AAED;IAAsB,2BAAe;IAArC;QAAA,kDAGC;QAFU,OAAC,GAAG,EAAE,CAAC;QACP,WAAK,GAAG,KAAK,CAAC;;IACzB,CAAC;IAAD,cAAC;AAAD,CAAC,AAHD,CAAsB,eAAe,GAGpC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js","sourceRoot":"","sources":["sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts"],"names":[],"mappings":";;;;;;;;;;AAAA;IAAA;IACA,CAAC;IAAD,sBAAC;AAAD,CAAC,AADD,IACC;AAED;IAAsB,2BAAe;IAArC;QAAA,qEAGC;QAFU,OAAC,GAAG,EAAE,CAAC;QACP,WAAK,GAAG,KAAK,CAAC;;IACzB,CAAC;IAAD,cAAC;AAAD,CAAC,AAHD,CAAsB,eAAe,GAGpC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.sourcemap.txt b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.sourcemap.txt index 91e284fd063..9fa37bcff06 100644 --- a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.sourcemap.txt @@ -8,22 +8,27 @@ sources: sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts emittedFile:tests/cases/compiler/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.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 __extends = (this && this.__extends) || (function () { +>>> var extendStatics = Object.setPrototypeOf || +>>> ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || +>>> function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; +>>> return function (d, b) { +>>> extendStatics(d, b); +>>> function __() { this.constructor = d; } +>>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +>>> }; +>>>})(); >>>var AbstractGreeter = (function () { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(6, 1) Source(1, 1) + SourceIndex(0) +1 >Emitted(11, 1) Source(1, 1) + SourceIndex(0) --- >>> function AbstractGreeter() { 1->^^^^ 2 > ^^-> 1-> -1->Emitted(7, 5) Source(1, 1) + SourceIndex(0) +1->Emitted(12, 5) Source(1, 1) + SourceIndex(0) --- >>> } 1->^^^^ @@ -32,16 +37,16 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 1->class AbstractGreeter { > 2 > } -1->Emitted(8, 5) Source(2, 1) + SourceIndex(0) -2 >Emitted(8, 6) Source(2, 2) + SourceIndex(0) +1->Emitted(13, 5) Source(2, 1) + SourceIndex(0) +2 >Emitted(13, 6) Source(2, 2) + SourceIndex(0) --- >>> return AbstractGreeter; 1->^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^ 1-> 2 > } -1->Emitted(9, 5) Source(2, 1) + SourceIndex(0) -2 >Emitted(9, 27) Source(2, 2) + SourceIndex(0) +1->Emitted(14, 5) Source(2, 1) + SourceIndex(0) +2 >Emitted(14, 27) Source(2, 2) + SourceIndex(0) --- >>>}()); 1 > @@ -54,10 +59,10 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 3 > 4 > class AbstractGreeter { > } -1 >Emitted(10, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(10, 2) Source(2, 2) + SourceIndex(0) -3 >Emitted(10, 2) Source(1, 1) + SourceIndex(0) -4 >Emitted(10, 6) Source(2, 2) + SourceIndex(0) +1 >Emitted(15, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(15, 2) Source(2, 2) + SourceIndex(0) +3 >Emitted(15, 2) Source(1, 1) + SourceIndex(0) +4 >Emitted(15, 6) Source(2, 2) + SourceIndex(0) --- >>>var Greeter = (function (_super) { 1-> @@ -65,32 +70,32 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 1-> > > -1->Emitted(11, 1) Source(4, 1) + SourceIndex(0) +1->Emitted(16, 1) Source(4, 1) + SourceIndex(0) --- >>> __extends(Greeter, _super); 1->^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1->class Greeter extends 2 > AbstractGreeter -1->Emitted(12, 5) Source(4, 23) + SourceIndex(0) -2 >Emitted(12, 32) Source(4, 38) + SourceIndex(0) +1->Emitted(17, 5) Source(4, 23) + SourceIndex(0) +2 >Emitted(17, 32) Source(4, 38) + SourceIndex(0) --- >>> function Greeter() { 1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(13, 5) Source(4, 1) + SourceIndex(0) +1 >Emitted(18, 5) Source(4, 1) + SourceIndex(0) --- ->>> var _this = _super.apply(this, arguments) || this; +>>> var _this = _super !== null && _super.apply(this, arguments) || this; 1->^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> 2 > class Greeter extends AbstractGreeter { > public a = 10; > public nameA = "Ten"; > } -1->Emitted(14, 9) Source(4, 1) + SourceIndex(0) -2 >Emitted(14, 59) Source(7, 2) + SourceIndex(0) +1->Emitted(19, 9) Source(4, 1) + SourceIndex(0) +2 >Emitted(19, 78) Source(7, 2) + SourceIndex(0) --- >>> _this.a = 10; 1 >^^^^^^^^ @@ -104,11 +109,11 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 3 > = 4 > 10 5 > ; -1 >Emitted(15, 9) Source(5, 12) + SourceIndex(0) -2 >Emitted(15, 16) Source(5, 13) + SourceIndex(0) -3 >Emitted(15, 19) Source(5, 16) + SourceIndex(0) -4 >Emitted(15, 21) Source(5, 18) + SourceIndex(0) -5 >Emitted(15, 22) Source(5, 19) + SourceIndex(0) +1 >Emitted(20, 9) Source(5, 12) + SourceIndex(0) +2 >Emitted(20, 16) Source(5, 13) + SourceIndex(0) +3 >Emitted(20, 19) Source(5, 16) + SourceIndex(0) +4 >Emitted(20, 21) Source(5, 18) + SourceIndex(0) +5 >Emitted(20, 22) Source(5, 19) + SourceIndex(0) --- >>> _this.nameA = "Ten"; 1->^^^^^^^^ @@ -122,11 +127,11 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 3 > = 4 > "Ten" 5 > ; -1->Emitted(16, 9) Source(6, 12) + SourceIndex(0) -2 >Emitted(16, 20) Source(6, 17) + SourceIndex(0) -3 >Emitted(16, 23) Source(6, 20) + SourceIndex(0) -4 >Emitted(16, 28) Source(6, 25) + SourceIndex(0) -5 >Emitted(16, 29) Source(6, 26) + SourceIndex(0) +1->Emitted(21, 9) Source(6, 12) + SourceIndex(0) +2 >Emitted(21, 20) Source(6, 17) + SourceIndex(0) +3 >Emitted(21, 23) Source(6, 20) + SourceIndex(0) +4 >Emitted(21, 28) Source(6, 25) + SourceIndex(0) +5 >Emitted(21, 29) Source(6, 26) + SourceIndex(0) --- >>> return _this; >>> } @@ -136,8 +141,8 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 1 > > 2 > } -1 >Emitted(18, 5) Source(7, 1) + SourceIndex(0) -2 >Emitted(18, 6) Source(7, 2) + SourceIndex(0) +1 >Emitted(23, 5) Source(7, 1) + SourceIndex(0) +2 >Emitted(23, 6) Source(7, 2) + SourceIndex(0) --- >>> return Greeter; 1->^^^^ @@ -145,8 +150,8 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts 3 > ^^^-> 1-> 2 > } -1->Emitted(19, 5) Source(7, 1) + SourceIndex(0) -2 >Emitted(19, 19) Source(7, 2) + SourceIndex(0) +1->Emitted(24, 5) Source(7, 1) + SourceIndex(0) +2 >Emitted(24, 19) Source(7, 2) + SourceIndex(0) --- >>>}(AbstractGreeter)); 1-> @@ -165,11 +170,11 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndExtendsClause.ts > public a = 10; > public nameA = "Ten"; > } -1->Emitted(20, 1) Source(7, 1) + SourceIndex(0) -2 >Emitted(20, 2) Source(7, 2) + SourceIndex(0) -3 >Emitted(20, 2) Source(4, 1) + SourceIndex(0) -4 >Emitted(20, 3) Source(4, 23) + SourceIndex(0) -5 >Emitted(20, 18) Source(4, 38) + SourceIndex(0) -6 >Emitted(20, 21) Source(7, 2) + SourceIndex(0) +1->Emitted(25, 1) Source(7, 1) + SourceIndex(0) +2 >Emitted(25, 2) Source(7, 2) + SourceIndex(0) +3 >Emitted(25, 2) Source(4, 1) + SourceIndex(0) +4 >Emitted(25, 3) Source(4, 23) + SourceIndex(0) +5 >Emitted(25, 18) Source(4, 38) + SourceIndex(0) +6 >Emitted(25, 21) Source(7, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationClassWithDefaultConstructorAndExtendsClause.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationImport.js b/tests/baselines/reference/sourceMapValidationImport.js index d9a75d96848..537c3c07135 100644 --- a/tests/baselines/reference/sourceMapValidationImport.js +++ b/tests/baselines/reference/sourceMapValidationImport.js @@ -10,6 +10,7 @@ var y = new b(); //// [sourceMapValidationImport.js] "use strict"; +exports.__esModule = true; var m; (function (m) { var c = (function () { diff --git a/tests/baselines/reference/sourceMapValidationImport.js.map b/tests/baselines/reference/sourceMapValidationImport.js.map index 5b7870209a1..bf6c7989cfc 100644 --- a/tests/baselines/reference/sourceMapValidationImport.js.map +++ b/tests/baselines/reference/sourceMapValidationImport.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationImport.js.map] -{"version":3,"file":"sourceMapValidationImport.js","sourceRoot":"","sources":["sourceMapValidationImport.ts"],"names":[],"mappings":";AAAA,IAAc,CAAC,CAGd;AAHD,WAAc,CAAC;IACX;QAAA;QACA,CAAC;QAAD,QAAC;IAAD,CAAC,AADD,IACC;IADY,GAAC,IACb,CAAA;AACL,CAAC,EAHa,CAAC,GAAD,SAAC,KAAD,SAAC,QAGd;AACD,IAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACD,QAAA,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACtB,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AAChB,IAAI,CAAC,GAAG,IAAI,SAAC,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationImport.js","sourceRoot":"","sources":["sourceMapValidationImport.ts"],"names":[],"mappings":";;AAAA,IAAc,CAAC,CAGd;AAHD,WAAc,CAAC;IACX;QAAA;QACA,CAAC;QAAD,QAAC;IAAD,CAAC,AADD,IACC;IADY,GAAC,IACb,CAAA;AACL,CAAC,EAHa,CAAC,GAAD,SAAC,KAAD,SAAC,QAGd;AACD,IAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACD,QAAA,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACtB,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AAChB,IAAI,CAAC,GAAG,IAAI,SAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationImport.sourcemap.txt b/tests/baselines/reference/sourceMapValidationImport.sourcemap.txt index 15e68b22c90..d1fc9b1b720 100644 --- a/tests/baselines/reference/sourceMapValidationImport.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationImport.sourcemap.txt @@ -9,6 +9,7 @@ emittedFile:tests/cases/compiler/sourceMapValidationImport.js sourceFile:sourceMapValidationImport.ts ------------------------------------------------------------------- >>>"use strict"; +>>>exports.__esModule = true; >>>var m; 1 > 2 >^^^^ @@ -22,10 +23,10 @@ sourceFile:sourceMapValidationImport.ts > export class c { > } > } -1 >Emitted(2, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(2, 5) Source(1, 15) + SourceIndex(0) -3 >Emitted(2, 6) Source(1, 16) + SourceIndex(0) -4 >Emitted(2, 7) Source(4, 2) + SourceIndex(0) +1 >Emitted(3, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(1, 15) + SourceIndex(0) +3 >Emitted(3, 6) Source(1, 16) + SourceIndex(0) +4 >Emitted(3, 7) Source(4, 2) + SourceIndex(0) --- >>>(function (m) { 1-> @@ -35,22 +36,22 @@ sourceFile:sourceMapValidationImport.ts 1-> 2 >export module 3 > m -1->Emitted(3, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(3, 12) Source(1, 15) + SourceIndex(0) -3 >Emitted(3, 13) Source(1, 16) + SourceIndex(0) +1->Emitted(4, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(4, 12) Source(1, 15) + SourceIndex(0) +3 >Emitted(4, 13) Source(1, 16) + SourceIndex(0) --- >>> var c = (function () { 1->^^^^ 2 > ^^^^^^^^^^^^^^^^^^^-> 1-> { > -1->Emitted(4, 5) Source(2, 5) + SourceIndex(0) +1->Emitted(5, 5) Source(2, 5) + SourceIndex(0) --- >>> function c() { 1->^^^^^^^^ 2 > ^^-> 1-> -1->Emitted(5, 9) Source(2, 5) + SourceIndex(0) +1->Emitted(6, 9) Source(2, 5) + SourceIndex(0) --- >>> } 1->^^^^^^^^ @@ -59,16 +60,16 @@ sourceFile:sourceMapValidationImport.ts 1->export class c { > 2 > } -1->Emitted(6, 9) Source(3, 5) + SourceIndex(0) -2 >Emitted(6, 10) Source(3, 6) + SourceIndex(0) +1->Emitted(7, 9) Source(3, 5) + SourceIndex(0) +2 >Emitted(7, 10) Source(3, 6) + SourceIndex(0) --- >>> return c; 1->^^^^^^^^ 2 > ^^^^^^^^ 1-> 2 > } -1->Emitted(7, 9) Source(3, 5) + SourceIndex(0) -2 >Emitted(7, 17) Source(3, 6) + SourceIndex(0) +1->Emitted(8, 9) Source(3, 5) + SourceIndex(0) +2 >Emitted(8, 17) Source(3, 6) + SourceIndex(0) --- >>> }()); 1 >^^^^ @@ -81,10 +82,10 @@ sourceFile:sourceMapValidationImport.ts 3 > 4 > export class c { > } -1 >Emitted(8, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(8, 6) Source(3, 6) + SourceIndex(0) -3 >Emitted(8, 6) Source(2, 5) + SourceIndex(0) -4 >Emitted(8, 10) Source(3, 6) + SourceIndex(0) +1 >Emitted(9, 5) Source(3, 5) + SourceIndex(0) +2 >Emitted(9, 6) Source(3, 6) + SourceIndex(0) +3 >Emitted(9, 6) Source(2, 5) + SourceIndex(0) +4 >Emitted(9, 10) Source(3, 6) + SourceIndex(0) --- >>> m.c = c; 1->^^^^ @@ -97,10 +98,10 @@ sourceFile:sourceMapValidationImport.ts 3 > { > } 4 > -1->Emitted(9, 5) Source(2, 18) + SourceIndex(0) -2 >Emitted(9, 8) Source(2, 19) + SourceIndex(0) -3 >Emitted(9, 12) Source(3, 6) + SourceIndex(0) -4 >Emitted(9, 13) Source(3, 6) + SourceIndex(0) +1->Emitted(10, 5) Source(2, 18) + SourceIndex(0) +2 >Emitted(10, 8) Source(2, 19) + SourceIndex(0) +3 >Emitted(10, 12) Source(3, 6) + SourceIndex(0) +4 >Emitted(10, 13) Source(3, 6) + SourceIndex(0) --- >>>})(m = exports.m || (exports.m = {})); 1-> @@ -125,15 +126,15 @@ sourceFile:sourceMapValidationImport.ts > export class c { > } > } -1->Emitted(10, 1) Source(4, 1) + SourceIndex(0) -2 >Emitted(10, 2) Source(4, 2) + SourceIndex(0) -3 >Emitted(10, 4) Source(1, 15) + SourceIndex(0) -4 >Emitted(10, 5) Source(1, 16) + SourceIndex(0) -5 >Emitted(10, 8) Source(1, 15) + SourceIndex(0) -6 >Emitted(10, 17) Source(1, 16) + SourceIndex(0) -7 >Emitted(10, 22) Source(1, 15) + SourceIndex(0) -8 >Emitted(10, 31) Source(1, 16) + SourceIndex(0) -9 >Emitted(10, 39) Source(4, 2) + SourceIndex(0) +1->Emitted(11, 1) Source(4, 1) + SourceIndex(0) +2 >Emitted(11, 2) Source(4, 2) + SourceIndex(0) +3 >Emitted(11, 4) Source(1, 15) + SourceIndex(0) +4 >Emitted(11, 5) Source(1, 16) + SourceIndex(0) +5 >Emitted(11, 8) Source(1, 15) + SourceIndex(0) +6 >Emitted(11, 17) Source(1, 16) + SourceIndex(0) +7 >Emitted(11, 22) Source(1, 15) + SourceIndex(0) +8 >Emitted(11, 31) Source(1, 16) + SourceIndex(0) +9 >Emitted(11, 39) Source(4, 2) + SourceIndex(0) --- >>>var a = m.c; 1 > @@ -154,14 +155,14 @@ sourceFile:sourceMapValidationImport.ts 6 > . 7 > c 8 > ; -1 >Emitted(11, 1) Source(5, 1) + SourceIndex(0) -2 >Emitted(11, 5) Source(5, 8) + SourceIndex(0) -3 >Emitted(11, 6) Source(5, 9) + SourceIndex(0) -4 >Emitted(11, 9) Source(5, 12) + SourceIndex(0) -5 >Emitted(11, 10) Source(5, 13) + SourceIndex(0) -6 >Emitted(11, 11) Source(5, 14) + SourceIndex(0) -7 >Emitted(11, 12) Source(5, 15) + SourceIndex(0) -8 >Emitted(11, 13) Source(5, 16) + SourceIndex(0) +1 >Emitted(12, 1) Source(5, 1) + SourceIndex(0) +2 >Emitted(12, 5) Source(5, 8) + SourceIndex(0) +3 >Emitted(12, 6) Source(5, 9) + SourceIndex(0) +4 >Emitted(12, 9) Source(5, 12) + SourceIndex(0) +5 >Emitted(12, 10) Source(5, 13) + SourceIndex(0) +6 >Emitted(12, 11) Source(5, 14) + SourceIndex(0) +7 >Emitted(12, 12) Source(5, 15) + SourceIndex(0) +8 >Emitted(12, 13) Source(5, 16) + SourceIndex(0) --- >>>exports.b = m.c; 1-> @@ -182,14 +183,14 @@ sourceFile:sourceMapValidationImport.ts 6 > . 7 > c 8 > ; -1->Emitted(12, 1) Source(6, 15) + SourceIndex(0) -2 >Emitted(12, 9) Source(6, 15) + SourceIndex(0) -3 >Emitted(12, 10) Source(6, 16) + SourceIndex(0) -4 >Emitted(12, 13) Source(6, 19) + SourceIndex(0) -5 >Emitted(12, 14) Source(6, 20) + SourceIndex(0) -6 >Emitted(12, 15) Source(6, 21) + SourceIndex(0) -7 >Emitted(12, 16) Source(6, 22) + SourceIndex(0) -8 >Emitted(12, 17) Source(6, 23) + SourceIndex(0) +1->Emitted(13, 1) Source(6, 15) + SourceIndex(0) +2 >Emitted(13, 9) Source(6, 15) + SourceIndex(0) +3 >Emitted(13, 10) Source(6, 16) + SourceIndex(0) +4 >Emitted(13, 13) Source(6, 19) + SourceIndex(0) +5 >Emitted(13, 14) Source(6, 20) + SourceIndex(0) +6 >Emitted(13, 15) Source(6, 21) + SourceIndex(0) +7 >Emitted(13, 16) Source(6, 22) + SourceIndex(0) +8 >Emitted(13, 17) Source(6, 23) + SourceIndex(0) --- >>>var x = new a(); 1-> @@ -210,14 +211,14 @@ sourceFile:sourceMapValidationImport.ts 6 > a 7 > () 8 > ; -1->Emitted(13, 1) Source(7, 1) + SourceIndex(0) -2 >Emitted(13, 5) Source(7, 5) + SourceIndex(0) -3 >Emitted(13, 6) Source(7, 6) + SourceIndex(0) -4 >Emitted(13, 9) Source(7, 9) + SourceIndex(0) -5 >Emitted(13, 13) Source(7, 13) + SourceIndex(0) -6 >Emitted(13, 14) Source(7, 14) + SourceIndex(0) -7 >Emitted(13, 16) Source(7, 16) + SourceIndex(0) -8 >Emitted(13, 17) Source(7, 17) + SourceIndex(0) +1->Emitted(14, 1) Source(7, 1) + SourceIndex(0) +2 >Emitted(14, 5) Source(7, 5) + SourceIndex(0) +3 >Emitted(14, 6) Source(7, 6) + SourceIndex(0) +4 >Emitted(14, 9) Source(7, 9) + SourceIndex(0) +5 >Emitted(14, 13) Source(7, 13) + SourceIndex(0) +6 >Emitted(14, 14) Source(7, 14) + SourceIndex(0) +7 >Emitted(14, 16) Source(7, 16) + SourceIndex(0) +8 >Emitted(14, 17) Source(7, 17) + SourceIndex(0) --- >>>var y = new exports.b(); 1-> @@ -238,13 +239,13 @@ sourceFile:sourceMapValidationImport.ts 6 > b 7 > () 8 > ; -1->Emitted(14, 1) Source(8, 1) + SourceIndex(0) -2 >Emitted(14, 5) Source(8, 5) + SourceIndex(0) -3 >Emitted(14, 6) Source(8, 6) + SourceIndex(0) -4 >Emitted(14, 9) Source(8, 9) + SourceIndex(0) -5 >Emitted(14, 13) Source(8, 13) + SourceIndex(0) -6 >Emitted(14, 22) Source(8, 14) + SourceIndex(0) -7 >Emitted(14, 24) Source(8, 16) + SourceIndex(0) -8 >Emitted(14, 25) Source(8, 17) + SourceIndex(0) +1->Emitted(15, 1) Source(8, 1) + SourceIndex(0) +2 >Emitted(15, 5) Source(8, 5) + SourceIndex(0) +3 >Emitted(15, 6) Source(8, 6) + SourceIndex(0) +4 >Emitted(15, 9) Source(8, 9) + SourceIndex(0) +5 >Emitted(15, 13) Source(8, 13) + SourceIndex(0) +6 >Emitted(15, 22) Source(8, 14) + SourceIndex(0) +7 >Emitted(15, 24) Source(8, 16) + SourceIndex(0) +8 >Emitted(15, 25) Source(8, 17) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationImport.js.map \ No newline at end of file diff --git a/tests/baselines/reference/specializationError.symbols b/tests/baselines/reference/specializationError.symbols index b866a7034df..4879d167713 100644 --- a/tests/baselines/reference/specializationError.symbols +++ b/tests/baselines/reference/specializationError.symbols @@ -1,13 +1,13 @@ === tests/cases/compiler/specializationError.ts === interface Promise { ->Promise : Symbol(Promise, Decl(specializationError.ts, 0, 0)) ->T : Symbol(T, Decl(specializationError.ts, 0, 18)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(specializationError.ts, 0, 0)) +>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(specializationError.ts, 0, 18)) then(value: T): void; ->then : Symbol(Promise.then, Decl(specializationError.ts, 0, 22)) +>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(specializationError.ts, 0, 22)) >U : Symbol(U, Decl(specializationError.ts, 1, 9)) >value : Symbol(value, Decl(specializationError.ts, 1, 12)) ->T : Symbol(T, Decl(specializationError.ts, 0, 18)) +>T : Symbol(T, Decl(lib.d.ts, --, --), Decl(specializationError.ts, 0, 18)) } interface Bar { @@ -16,21 +16,21 @@ interface Bar { bar(value: "Menu"): Promise; >bar : Symbol(Bar.bar, Decl(specializationError.ts, 4, 15), Decl(specializationError.ts, 5, 40), Decl(specializationError.ts, 6, 55)) >value : Symbol(value, Decl(specializationError.ts, 5, 8)) ->Promise : Symbol(Promise, Decl(specializationError.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(specializationError.ts, 0, 0)) bar(value: string, element: string): Promise; >bar : Symbol(Bar.bar, Decl(specializationError.ts, 4, 15), Decl(specializationError.ts, 5, 40), Decl(specializationError.ts, 6, 55)) >T : Symbol(T, Decl(specializationError.ts, 6, 8)) >value : Symbol(value, Decl(specializationError.ts, 6, 11)) >element : Symbol(element, Decl(specializationError.ts, 6, 25)) ->Promise : Symbol(Promise, Decl(specializationError.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(specializationError.ts, 0, 0)) >T : Symbol(T, Decl(specializationError.ts, 6, 8)) bar(value: string): Promise; >bar : Symbol(Bar.bar, Decl(specializationError.ts, 4, 15), Decl(specializationError.ts, 5, 40), Decl(specializationError.ts, 6, 55)) >T : Symbol(T, Decl(specializationError.ts, 7, 8)) >value : Symbol(value, Decl(specializationError.ts, 7, 11)) ->Promise : Symbol(Promise, Decl(specializationError.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(specializationError.ts, 0, 0)) >T : Symbol(T, Decl(specializationError.ts, 7, 8)) } diff --git a/tests/baselines/reference/specializationError.types b/tests/baselines/reference/specializationError.types index c79816eaf8a..07cbc3d76d0 100644 --- a/tests/baselines/reference/specializationError.types +++ b/tests/baselines/reference/specializationError.types @@ -4,7 +4,7 @@ interface Promise { >T : T then(value: T): void; ->then : (value: T) => void +>then : { (onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (value: T): void; } >U : U >value : T >T : T diff --git a/tests/baselines/reference/specializedInheritedConstructors1.js b/tests/baselines/reference/specializedInheritedConstructors1.js index f65f42941bf..cd137e6dcae 100644 --- a/tests/baselines/reference/specializedInheritedConstructors1.js +++ b/tests/baselines/reference/specializedInheritedConstructors1.js @@ -18,11 +18,16 @@ var myView = new MyView(m); // was error //// [specializedInheritedConstructors1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var View = (function () { function View(options) { } @@ -36,7 +41,7 @@ var Model = (function () { var MyView = (function (_super) { __extends(MyView, _super); function MyView() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return MyView; }(View)); diff --git a/tests/baselines/reference/specializedOverloadWithRestParameters.js b/tests/baselines/reference/specializedOverloadWithRestParameters.js index b76afaff08c..892f30441f8 100644 --- a/tests/baselines/reference/specializedOverloadWithRestParameters.js +++ b/tests/baselines/reference/specializedOverloadWithRestParameters.js @@ -13,11 +13,16 @@ function g(tagName: any): Base { } //// [specializedOverloadWithRestParameters.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -27,7 +32,7 @@ var Base = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived1.prototype.bar = function () { }; return Derived1; diff --git a/tests/baselines/reference/spreadIntersectionJsx.js b/tests/baselines/reference/spreadIntersectionJsx.js new file mode 100644 index 00000000000..9ba086dd765 --- /dev/null +++ b/tests/baselines/reference/spreadIntersectionJsx.js @@ -0,0 +1,30 @@ +//// [spreadIntersectionJsx.tsx] +const React: any = null; +class A { a; } +class C { c; } +let intersected: A & C; +let element =
; + + +//// [spreadIntersectionJsx.js] +var __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; +}; +var React = null; +var A = (function () { + function A() { + } + return A; +}()); +var C = (function () { + function C() { + } + return C; +}()); +var intersected; +var element = React.createElement("div", __assign({}, intersected)); diff --git a/tests/baselines/reference/spreadIntersectionJsx.symbols b/tests/baselines/reference/spreadIntersectionJsx.symbols new file mode 100644 index 00000000000..24d7c90be1f --- /dev/null +++ b/tests/baselines/reference/spreadIntersectionJsx.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/spreadIntersectionJsx.tsx === +const React: any = null; +>React : Symbol(React, Decl(spreadIntersectionJsx.tsx, 0, 5)) + +class A { a; } +>A : Symbol(A, Decl(spreadIntersectionJsx.tsx, 0, 24)) +>a : Symbol(A.a, Decl(spreadIntersectionJsx.tsx, 1, 9)) + +class C { c; } +>C : Symbol(C, Decl(spreadIntersectionJsx.tsx, 1, 14)) +>c : Symbol(C.c, Decl(spreadIntersectionJsx.tsx, 2, 9)) + +let intersected: A & C; +>intersected : Symbol(intersected, Decl(spreadIntersectionJsx.tsx, 3, 3)) +>A : Symbol(A, Decl(spreadIntersectionJsx.tsx, 0, 24)) +>C : Symbol(C, Decl(spreadIntersectionJsx.tsx, 1, 14)) + +let element =
; +>element : Symbol(element, Decl(spreadIntersectionJsx.tsx, 4, 3)) +>div : Symbol(unknown) +>intersected : Symbol(intersected, Decl(spreadIntersectionJsx.tsx, 3, 3)) + diff --git a/tests/baselines/reference/spreadIntersectionJsx.types b/tests/baselines/reference/spreadIntersectionJsx.types new file mode 100644 index 00000000000..4756f73c5af --- /dev/null +++ b/tests/baselines/reference/spreadIntersectionJsx.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/spreadIntersectionJsx.tsx === +const React: any = null; +>React : any +>null : null + +class A { a; } +>A : A +>a : any + +class C { c; } +>C : C +>c : any + +let intersected: A & C; +>intersected : A & C +>A : A +>C : C + +let element =
; +>element : any +>
: any +>div : any +>intersected : A & C + diff --git a/tests/baselines/reference/spreadMethods.errors.txt b/tests/baselines/reference/spreadMethods.errors.txt new file mode 100644 index 00000000000..b2b3491ba79 --- /dev/null +++ b/tests/baselines/reference/spreadMethods.errors.txt @@ -0,0 +1,33 @@ +tests/cases/conformance/types/spread/spreadMethods.ts(7,4): error TS2339: Property 'm' does not exist on type '{ p: number; }'. +tests/cases/conformance/types/spread/spreadMethods.ts(9,5): error TS2339: Property 'm' does not exist on type '{ p: number; }'. + + +==== tests/cases/conformance/types/spread/spreadMethods.ts (2 errors) ==== + class K { p = 12; m() { } } + interface I { p: number, m(): void } + let k = new K() + let sk = { ...k }; + let ssk = { ...k, ...k }; + sk.p; + sk.m(); // error + ~ +!!! error TS2339: Property 'm' does not exist on type '{ p: number; }'. + ssk.p; + ssk.m(); // error + ~ +!!! error TS2339: Property 'm' does not exist on type '{ p: number; }'. + let i: I = { p: 12, m() { } }; + let si = { ...i }; + let ssi = { ...i, ...i }; + si.p; + si.m(); // ok + ssi.p; + ssi.m(); // ok + let o = { p: 12, m() { } }; + let so = { ...o }; + let sso = { ...o, ...o }; + so.p; + so.m(); // ok + sso.p; + sso.m(); // ok + \ No newline at end of file diff --git a/tests/baselines/reference/spreadMethods.js b/tests/baselines/reference/spreadMethods.js new file mode 100644 index 00000000000..691d6fa2829 --- /dev/null +++ b/tests/baselines/reference/spreadMethods.js @@ -0,0 +1,63 @@ +//// [spreadMethods.ts] +class K { p = 12; m() { } } +interface I { p: number, m(): void } +let k = new K() +let sk = { ...k }; +let ssk = { ...k, ...k }; +sk.p; +sk.m(); // error +ssk.p; +ssk.m(); // error +let i: I = { p: 12, m() { } }; +let si = { ...i }; +let ssi = { ...i, ...i }; +si.p; +si.m(); // ok +ssi.p; +ssi.m(); // ok +let o = { p: 12, m() { } }; +let so = { ...o }; +let sso = { ...o, ...o }; +so.p; +so.m(); // ok +sso.p; +sso.m(); // ok + + +//// [spreadMethods.js] +var __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; +}; +var K = (function () { + function K() { + this.p = 12; + } + K.prototype.m = function () { }; + return K; +}()); +var k = new K(); +var sk = __assign({}, k); +var ssk = __assign({}, k, k); +sk.p; +sk.m(); // error +ssk.p; +ssk.m(); // error +var i = { p: 12, m: function () { } }; +var si = __assign({}, i); +var ssi = __assign({}, i, i); +si.p; +si.m(); // ok +ssi.p; +ssi.m(); // ok +var o = { p: 12, m: function () { } }; +var so = __assign({}, o); +var sso = __assign({}, o, o); +so.p; +so.m(); // ok +sso.p; +sso.m(); // ok diff --git a/tests/baselines/reference/staticFactory1.js b/tests/baselines/reference/staticFactory1.js index de7588c3ebe..b73dce8a0cf 100644 --- a/tests/baselines/reference/staticFactory1.js +++ b/tests/baselines/reference/staticFactory1.js @@ -14,11 +14,16 @@ var d = Derived.create(); d.foo(); //// [staticFactory1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -31,7 +36,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Derived.prototype.foo = function () { return 2; }; return Derived; diff --git a/tests/baselines/reference/staticInheritance.js b/tests/baselines/reference/staticInheritance.js index d204c1aed47..780e5e98782 100644 --- a/tests/baselines/reference/staticInheritance.js +++ b/tests/baselines/reference/staticInheritance.js @@ -12,11 +12,16 @@ doThing(B); //OK //// [staticInheritance.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function doThing(x) { } var A = (function () { function A() { @@ -27,7 +32,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.p1 = doThing(A); // OK _this.p2 = doThing(B); // OK return _this; diff --git a/tests/baselines/reference/staticInstanceResolution3.js b/tests/baselines/reference/staticInstanceResolution3.js index c480fd33285..747aa93e631 100644 --- a/tests/baselines/reference/staticInstanceResolution3.js +++ b/tests/baselines/reference/staticInstanceResolution3.js @@ -14,6 +14,7 @@ WinJS.Promise.timeout(10); //// [staticInstanceResolution3_0.js] "use strict"; +exports.__esModule = true; var Promise = (function () { function Promise() { } @@ -25,6 +26,7 @@ var Promise = (function () { exports.Promise = Promise; //// [staticInstanceResolution3_1.js] "use strict"; +exports.__esModule = true; /// var WinJS = require("./staticInstanceResolution3_0"); WinJS.Promise.timeout(10); diff --git a/tests/baselines/reference/staticInstanceResolution5.js b/tests/baselines/reference/staticInstanceResolution5.js index b3514e00aad..0bbd1cf412f 100644 --- a/tests/baselines/reference/staticInstanceResolution5.js +++ b/tests/baselines/reference/staticInstanceResolution5.js @@ -19,6 +19,7 @@ function z(w3: WinJS) { } //// [staticInstanceResolution5_0.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var Promise = (function () { function Promise() { } @@ -32,6 +33,7 @@ define(["require", "exports"], function (require, exports) { //// [staticInstanceResolution5_1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; // these 3 should be errors var x = function (w1) { }; var y = function (w2) { }; diff --git a/tests/baselines/reference/staticMemberAccessOffDerivedType1.js b/tests/baselines/reference/staticMemberAccessOffDerivedType1.js index 7b8ca52b9a4..41f2da7f4af 100644 --- a/tests/baselines/reference/staticMemberAccessOffDerivedType1.js +++ b/tests/baselines/reference/staticMemberAccessOffDerivedType1.js @@ -10,11 +10,16 @@ class P extends SomeBase { //// [staticMemberAccessOffDerivedType1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var SomeBase = (function () { function SomeBase() { } @@ -26,7 +31,7 @@ var SomeBase = (function () { var P = (function (_super) { __extends(P, _super); function P() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return P; }(SomeBase)); diff --git a/tests/baselines/reference/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.errors.txt b/tests/baselines/reference/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.errors.txt index 59626540806..36ead708331 100644 --- a/tests/baselines/reference/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.errors.txt +++ b/tests/baselines/reference/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.errors.txt @@ -1,43 +1,43 @@ tests/cases/compiler/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.ts(12,1): error TS2322: Type 'C' is not assignable to type 'A'. - Property 'name' is missing in type 'C'. + Property 'prop' is missing in type 'C'. tests/cases/compiler/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.ts(13,1): error TS2322: Type 'typeof B' is not assignable to type 'A'. - Property 'name' is missing in type 'typeof B'. + Property 'prop' is missing in type 'typeof B'. tests/cases/compiler/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.ts(16,5): error TS2322: Type 'C' is not assignable to type 'B'. - Property 'name' is missing in type 'C'. + Property 'prop' is missing in type 'C'. tests/cases/compiler/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.ts(17,1): error TS2322: Type 'typeof B' is not assignable to type 'B'. - Property 'name' is missing in type 'typeof B'. + Property 'prop' is missing in type 'typeof B'. ==== tests/cases/compiler/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.ts (4 errors) ==== interface A { - name(); + prop(); } class B { - public name() { } + public prop() { } } class C { - public static name() { } + public static prop() { } } var a: A = new B(); - a = new C(); // error name is missing + a = new C(); // error prop is missing ~ !!! error TS2322: Type 'C' is not assignable to type 'A'. -!!! error TS2322: Property 'name' is missing in type 'C'. - a = B; // error name is missing +!!! error TS2322: Property 'prop' is missing in type 'C'. + a = B; // error prop is missing ~ !!! error TS2322: Type 'typeof B' is not assignable to type 'A'. -!!! error TS2322: Property 'name' is missing in type 'typeof B'. +!!! error TS2322: Property 'prop' is missing in type 'typeof B'. a = C; - var b: B = new C(); // error name is missing + var b: B = new C(); // error prop is missing ~ !!! error TS2322: Type 'C' is not assignable to type 'B'. -!!! error TS2322: Property 'name' is missing in type 'C'. - b = B; // error name is missing +!!! error TS2322: Property 'prop' is missing in type 'C'. + b = B; // error prop is missing ~ !!! error TS2322: Type 'typeof B' is not assignable to type 'B'. -!!! error TS2322: Property 'name' is missing in type 'typeof B'. +!!! error TS2322: Property 'prop' is missing in type 'typeof B'. b = C; b = a; diff --git a/tests/baselines/reference/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.js b/tests/baselines/reference/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.js index 1b98daa226d..00de82a4f6d 100644 --- a/tests/baselines/reference/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.js +++ b/tests/baselines/reference/staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.js @@ -1,21 +1,21 @@ //// [staticMemberOfClassAndPublicMemberOfAnotherClassAssignment.ts] interface A { - name(); + prop(); } class B { - public name() { } + public prop() { } } class C { - public static name() { } + public static prop() { } } var a: A = new B(); -a = new C(); // error name is missing -a = B; // error name is missing +a = new C(); // error prop is missing +a = B; // error prop is missing a = C; -var b: B = new C(); // error name is missing -b = B; // error name is missing +var b: B = new C(); // error prop is missing +b = B; // error prop is missing b = C; b = a; @@ -29,21 +29,21 @@ c = a; var B = (function () { function B() { } - B.prototype.name = function () { }; + B.prototype.prop = function () { }; return B; }()); var C = (function () { function C() { } - C.name = function () { }; + C.prop = function () { }; return C; }()); var a = new B(); -a = new C(); // error name is missing -a = B; // error name is missing +a = new C(); // error prop is missing +a = B; // error prop is missing a = C; -var b = new C(); // error name is missing -b = B; // error name is missing +var b = new C(); // error prop is missing +b = B; // error prop is missing b = C; b = a; var c = new B(); diff --git a/tests/baselines/reference/staticMethodWithTypeParameterExtendsClauseDeclFile.js b/tests/baselines/reference/staticMethodWithTypeParameterExtendsClauseDeclFile.js index 9b8987659c5..b8b5b030bcd 100644 --- a/tests/baselines/reference/staticMethodWithTypeParameterExtendsClauseDeclFile.js +++ b/tests/baselines/reference/staticMethodWithTypeParameterExtendsClauseDeclFile.js @@ -23,6 +23,7 @@ export class publicClassWithWithPrivateTypeParameters { //// [staticMethodWithTypeParameterExtendsClauseDeclFile.js] "use strict"; +exports.__esModule = true; var privateClass = (function () { function privateClass() { } diff --git a/tests/baselines/reference/staticPropSuper.js b/tests/baselines/reference/staticPropSuper.js index 6240f8c454f..5c22232534f 100644 --- a/tests/baselines/reference/staticPropSuper.js +++ b/tests/baselines/reference/staticPropSuper.js @@ -36,11 +36,16 @@ class E extends A { } //// [staticPropSuper.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -49,7 +54,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - var _this; + var _this = this; var x = 1; // should not error _this = _super.call(this) || this; return _this; @@ -60,7 +65,7 @@ B.s = 9; var C = (function (_super) { __extends(C, _super); function C() { - var _this; + var _this = this; _this.p = 10; var x = 1; // should error return _this; @@ -70,7 +75,7 @@ var C = (function (_super) { var D = (function (_super) { __extends(D, _super); function D() { - var _this; + var _this = this; _this.p = 11; var x = 1; // should error return _this; @@ -80,7 +85,7 @@ var D = (function (_super) { var E = (function (_super) { __extends(E, _super); function E() { - var _this; + var _this = this; _this.p = 12; var x = 1; // should error return _this; diff --git a/tests/baselines/reference/staticPropertyNameConflicts.errors.txt b/tests/baselines/reference/staticPropertyNameConflicts.errors.txt new file mode 100644 index 00000000000..1b22bbbf759 --- /dev/null +++ b/tests/baselines/reference/staticPropertyNameConflicts.errors.txt @@ -0,0 +1,293 @@ +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(3,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(8,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(14,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(19,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(25,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(30,12): error TS2300: Duplicate identifier 'prototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(30,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(36,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(41,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(47,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(52,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(62,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName_Anonymous'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(67,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn_Anonymous'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(73,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength_Anonymous'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(78,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn_Anonymous'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(84,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype_Anonymous'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(89,12): error TS2300: Duplicate identifier 'prototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(89,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn_Anonymous'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(95,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller_Anonymous'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(100,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn_Anonymous'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(106,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments_Anonymous'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(111,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn_Anonymous'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(121,16): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(128,16): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(136,16): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(143,16): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(151,16): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(158,16): error TS2300: Duplicate identifier 'prototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(158,16): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(166,16): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(173,16): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(181,16): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(188,16): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. + + +==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts (33 errors) ==== + // name + class StaticName { + static name: number; // error + ~~~~ +!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. + name: string; // ok + } + + class StaticNameFn { + static name() {} // error + ~~~~ +!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. + name() {} // ok + } + + // length + class StaticLength { + static length: number; // error + ~~~~~~ +!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. + length: string; // ok + } + + class StaticLengthFn { + static length() {} // error + ~~~~~~ +!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. + length() {} // ok + } + + // prototype + class StaticPrototype { + static prototype: number; // error + ~~~~~~~~~ +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. + prototype: string; // ok + } + + class StaticPrototypeFn { + static prototype() {} // error + ~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'prototype'. + ~~~~~~~~~ +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. + prototype() {} // ok + } + + // caller + class StaticCaller { + static caller: number; // error + ~~~~~~ +!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. + caller: string; // ok + } + + class StaticCallerFn { + static caller() {} // error + ~~~~~~ +!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. + caller() {} // ok + } + + // arguments + class StaticArguments { + static arguments: number; // error + ~~~~~~~~~ +!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. + arguments: string; // ok + } + + class StaticArgumentsFn { + static arguments() {} // error + ~~~~~~~~~ +!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. + arguments() {} // ok + } + + + + // === Static properties on anonymous classes === + + // name + var StaticName_Anonymous = class { + static name: number; // error + ~~~~ +!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName_Anonymous'. + name: string; // ok + } + + var StaticNameFn_Anonymous = class { + static name() {} // error + ~~~~ +!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn_Anonymous'. + name() {} // ok + } + + // length + var StaticLength_Anonymous = class { + static length: number; // error + ~~~~~~ +!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength_Anonymous'. + length: string; // ok + } + + var StaticLengthFn_Anonymous = class { + static length() {} // error + ~~~~~~ +!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn_Anonymous'. + length() {} // ok + } + + // prototype + var StaticPrototype_Anonymous = class { + static prototype: number; // error + ~~~~~~~~~ +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype_Anonymous'. + prototype: string; // ok + } + + var StaticPrototypeFn_Anonymous = class { + static prototype() {} // error + ~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'prototype'. + ~~~~~~~~~ +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn_Anonymous'. + prototype() {} // ok + } + + // caller + var StaticCaller_Anonymous = class { + static caller: number; // error + ~~~~~~ +!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller_Anonymous'. + caller: string; // ok + } + + var StaticCallerFn_Anonymous = class { + static caller() {} // error + ~~~~~~ +!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn_Anonymous'. + caller() {} // ok + } + + // arguments + var StaticArguments_Anonymous = class { + static arguments: number; // error + ~~~~~~~~~ +!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments_Anonymous'. + arguments: string; // ok + } + + var StaticArgumentsFn_Anonymous = class { + static arguments() {} // error + ~~~~~~~~~ +!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn_Anonymous'. + arguments() {} // ok + } + + + // === Static properties on default exported classes === + + // name + module TestOnDefaultExportedClass_1 { + class StaticName { + static name: number; // error + ~~~~ +!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. + name: string; // ok + } + } + + module TestOnDefaultExportedClass_2 { + class StaticNameFn { + static name() {} // error + ~~~~ +!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. + name() {} // ok + } + } + + // length + module TestOnDefaultExportedClass_3 { + export default class StaticLength { + static length: number; // error + ~~~~~~ +!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. + length: string; // ok + } + } + + module TestOnDefaultExportedClass_4 { + export default class StaticLengthFn { + static length() {} // error + ~~~~~~ +!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. + length() {} // ok + } + } + + // prototype + module TestOnDefaultExportedClass_5 { + export default class StaticPrototype { + static prototype: number; // error + ~~~~~~~~~ +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. + prototype: string; // ok + } + } + + module TestOnDefaultExportedClass_6 { + export default class StaticPrototypeFn { + static prototype() {} // error + ~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'prototype'. + ~~~~~~~~~ +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. + prototype() {} // ok + } + } + + // caller + module TestOnDefaultExportedClass_7 { + export default class StaticCaller { + static caller: number; // error + ~~~~~~ +!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. + caller: string; // ok + } + } + + module TestOnDefaultExportedClass_8 { + export default class StaticCallerFn { + static caller() {} // error + ~~~~~~ +!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. + caller() {} // ok + } + } + + // arguments + module TestOnDefaultExportedClass_9 { + export default class StaticArguments { + static arguments: number; // error + ~~~~~~~~~ +!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. + arguments: string; // ok + } + } + + module TestOnDefaultExportedClass_10 { + export default class StaticArgumentsFn { + static arguments() {} // error + ~~~~~~~~~ +!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. + arguments() {} // ok + } + } \ No newline at end of file diff --git a/tests/baselines/reference/staticPropertyNameConflicts.js b/tests/baselines/reference/staticPropertyNameConflicts.js new file mode 100644 index 00000000000..b93b16550f0 --- /dev/null +++ b/tests/baselines/reference/staticPropertyNameConflicts.js @@ -0,0 +1,429 @@ +//// [staticPropertyNameConflicts.ts] +// name +class StaticName { + static name: number; // error + name: string; // ok +} + +class StaticNameFn { + static name() {} // error + name() {} // ok +} + +// length +class StaticLength { + static length: number; // error + length: string; // ok +} + +class StaticLengthFn { + static length() {} // error + length() {} // ok +} + +// prototype +class StaticPrototype { + static prototype: number; // error + prototype: string; // ok +} + +class StaticPrototypeFn { + static prototype() {} // error + prototype() {} // ok +} + +// caller +class StaticCaller { + static caller: number; // error + caller: string; // ok +} + +class StaticCallerFn { + static caller() {} // error + caller() {} // ok +} + +// arguments +class StaticArguments { + static arguments: number; // error + arguments: string; // ok +} + +class StaticArgumentsFn { + static arguments() {} // error + arguments() {} // ok +} + + + +// === Static properties on anonymous classes === + +// name +var StaticName_Anonymous = class { + static name: number; // error + name: string; // ok +} + +var StaticNameFn_Anonymous = class { + static name() {} // error + name() {} // ok +} + +// length +var StaticLength_Anonymous = class { + static length: number; // error + length: string; // ok +} + +var StaticLengthFn_Anonymous = class { + static length() {} // error + length() {} // ok +} + +// prototype +var StaticPrototype_Anonymous = class { + static prototype: number; // error + prototype: string; // ok +} + +var StaticPrototypeFn_Anonymous = class { + static prototype() {} // error + prototype() {} // ok +} + +// caller +var StaticCaller_Anonymous = class { + static caller: number; // error + caller: string; // ok +} + +var StaticCallerFn_Anonymous = class { + static caller() {} // error + caller() {} // ok +} + +// arguments +var StaticArguments_Anonymous = class { + static arguments: number; // error + arguments: string; // ok +} + +var StaticArgumentsFn_Anonymous = class { + static arguments() {} // error + arguments() {} // ok +} + + +// === Static properties on default exported classes === + +// name +module TestOnDefaultExportedClass_1 { + class StaticName { + static name: number; // error + name: string; // ok + } +} + +module TestOnDefaultExportedClass_2 { + class StaticNameFn { + static name() {} // error + name() {} // ok + } +} + +// length +module TestOnDefaultExportedClass_3 { + export default class StaticLength { + static length: number; // error + length: string; // ok + } +} + +module TestOnDefaultExportedClass_4 { + export default class StaticLengthFn { + static length() {} // error + length() {} // ok + } +} + +// prototype +module TestOnDefaultExportedClass_5 { + export default class StaticPrototype { + static prototype: number; // error + prototype: string; // ok + } +} + +module TestOnDefaultExportedClass_6 { + export default class StaticPrototypeFn { + static prototype() {} // error + prototype() {} // ok + } +} + +// caller +module TestOnDefaultExportedClass_7 { + export default class StaticCaller { + static caller: number; // error + caller: string; // ok + } +} + +module TestOnDefaultExportedClass_8 { + export default class StaticCallerFn { + static caller() {} // error + caller() {} // ok + } +} + +// arguments +module TestOnDefaultExportedClass_9 { + export default class StaticArguments { + static arguments: number; // error + arguments: string; // ok + } +} + +module TestOnDefaultExportedClass_10 { + export default class StaticArgumentsFn { + static arguments() {} // error + arguments() {} // ok + } +} + +//// [staticPropertyNameConflicts.js] +// name +var StaticName = (function () { + function StaticName() { + } + return StaticName; +}()); +var StaticNameFn = (function () { + function StaticNameFn() { + } + StaticNameFn.name = function () { }; // error + StaticNameFn.prototype.name = function () { }; // ok + return StaticNameFn; +}()); +// length +var StaticLength = (function () { + function StaticLength() { + } + return StaticLength; +}()); +var StaticLengthFn = (function () { + function StaticLengthFn() { + } + StaticLengthFn.length = function () { }; // error + StaticLengthFn.prototype.length = function () { }; // ok + return StaticLengthFn; +}()); +// prototype +var StaticPrototype = (function () { + function StaticPrototype() { + } + return StaticPrototype; +}()); +var StaticPrototypeFn = (function () { + function StaticPrototypeFn() { + } + StaticPrototypeFn.prototype = function () { }; // error + StaticPrototypeFn.prototype.prototype = function () { }; // ok + return StaticPrototypeFn; +}()); +// caller +var StaticCaller = (function () { + function StaticCaller() { + } + return StaticCaller; +}()); +var StaticCallerFn = (function () { + function StaticCallerFn() { + } + StaticCallerFn.caller = function () { }; // error + StaticCallerFn.prototype.caller = function () { }; // ok + return StaticCallerFn; +}()); +// arguments +var StaticArguments = (function () { + function StaticArguments() { + } + return StaticArguments; +}()); +var StaticArgumentsFn = (function () { + function StaticArgumentsFn() { + } + StaticArgumentsFn.arguments = function () { }; // error + StaticArgumentsFn.prototype.arguments = function () { }; // ok + return StaticArgumentsFn; +}()); +// === Static properties on anonymous classes === +// name +var StaticName_Anonymous = (function () { + function class_1() { + } + return class_1; +}()); +var StaticNameFn_Anonymous = (function () { + function class_2() { + } + class_2.name = function () { }; // error + class_2.prototype.name = function () { }; // ok + return class_2; +}()); +// length +var StaticLength_Anonymous = (function () { + function class_3() { + } + return class_3; +}()); +var StaticLengthFn_Anonymous = (function () { + function class_4() { + } + class_4.length = function () { }; // error + class_4.prototype.length = function () { }; // ok + return class_4; +}()); +// prototype +var StaticPrototype_Anonymous = (function () { + function class_5() { + } + return class_5; +}()); +var StaticPrototypeFn_Anonymous = (function () { + function class_6() { + } + class_6.prototype = function () { }; // error + class_6.prototype.prototype = function () { }; // ok + return class_6; +}()); +// caller +var StaticCaller_Anonymous = (function () { + function class_7() { + } + return class_7; +}()); +var StaticCallerFn_Anonymous = (function () { + function class_8() { + } + class_8.caller = function () { }; // error + class_8.prototype.caller = function () { }; // ok + return class_8; +}()); +// arguments +var StaticArguments_Anonymous = (function () { + function class_9() { + } + return class_9; +}()); +var StaticArgumentsFn_Anonymous = (function () { + function class_10() { + } + class_10.arguments = function () { }; // error + class_10.prototype.arguments = function () { }; // ok + return class_10; +}()); +// === Static properties on default exported classes === +// name +var TestOnDefaultExportedClass_1; +(function (TestOnDefaultExportedClass_1) { + var StaticName = (function () { + function StaticName() { + } + return StaticName; + }()); +})(TestOnDefaultExportedClass_1 || (TestOnDefaultExportedClass_1 = {})); +var TestOnDefaultExportedClass_2; +(function (TestOnDefaultExportedClass_2) { + var StaticNameFn = (function () { + function StaticNameFn() { + } + StaticNameFn.name = function () { }; // error + StaticNameFn.prototype.name = function () { }; // ok + return StaticNameFn; + }()); +})(TestOnDefaultExportedClass_2 || (TestOnDefaultExportedClass_2 = {})); +// length +var TestOnDefaultExportedClass_3; +(function (TestOnDefaultExportedClass_3) { + var StaticLength = (function () { + function StaticLength() { + } + return StaticLength; + }()); + TestOnDefaultExportedClass_3.StaticLength = StaticLength; +})(TestOnDefaultExportedClass_3 || (TestOnDefaultExportedClass_3 = {})); +var TestOnDefaultExportedClass_4; +(function (TestOnDefaultExportedClass_4) { + var StaticLengthFn = (function () { + function StaticLengthFn() { + } + StaticLengthFn.length = function () { }; // error + StaticLengthFn.prototype.length = function () { }; // ok + return StaticLengthFn; + }()); + TestOnDefaultExportedClass_4.StaticLengthFn = StaticLengthFn; +})(TestOnDefaultExportedClass_4 || (TestOnDefaultExportedClass_4 = {})); +// prototype +var TestOnDefaultExportedClass_5; +(function (TestOnDefaultExportedClass_5) { + var StaticPrototype = (function () { + function StaticPrototype() { + } + return StaticPrototype; + }()); + TestOnDefaultExportedClass_5.StaticPrototype = StaticPrototype; +})(TestOnDefaultExportedClass_5 || (TestOnDefaultExportedClass_5 = {})); +var TestOnDefaultExportedClass_6; +(function (TestOnDefaultExportedClass_6) { + var StaticPrototypeFn = (function () { + function StaticPrototypeFn() { + } + StaticPrototypeFn.prototype = function () { }; // error + StaticPrototypeFn.prototype.prototype = function () { }; // ok + return StaticPrototypeFn; + }()); + TestOnDefaultExportedClass_6.StaticPrototypeFn = StaticPrototypeFn; +})(TestOnDefaultExportedClass_6 || (TestOnDefaultExportedClass_6 = {})); +// caller +var TestOnDefaultExportedClass_7; +(function (TestOnDefaultExportedClass_7) { + var StaticCaller = (function () { + function StaticCaller() { + } + return StaticCaller; + }()); + TestOnDefaultExportedClass_7.StaticCaller = StaticCaller; +})(TestOnDefaultExportedClass_7 || (TestOnDefaultExportedClass_7 = {})); +var TestOnDefaultExportedClass_8; +(function (TestOnDefaultExportedClass_8) { + var StaticCallerFn = (function () { + function StaticCallerFn() { + } + StaticCallerFn.caller = function () { }; // error + StaticCallerFn.prototype.caller = function () { }; // ok + return StaticCallerFn; + }()); + TestOnDefaultExportedClass_8.StaticCallerFn = StaticCallerFn; +})(TestOnDefaultExportedClass_8 || (TestOnDefaultExportedClass_8 = {})); +// arguments +var TestOnDefaultExportedClass_9; +(function (TestOnDefaultExportedClass_9) { + var StaticArguments = (function () { + function StaticArguments() { + } + return StaticArguments; + }()); + TestOnDefaultExportedClass_9.StaticArguments = StaticArguments; +})(TestOnDefaultExportedClass_9 || (TestOnDefaultExportedClass_9 = {})); +var TestOnDefaultExportedClass_10; +(function (TestOnDefaultExportedClass_10) { + var StaticArgumentsFn = (function () { + function StaticArgumentsFn() { + } + StaticArgumentsFn.arguments = function () { }; // error + StaticArgumentsFn.prototype.arguments = function () { }; // ok + return StaticArgumentsFn; + }()); + TestOnDefaultExportedClass_10.StaticArgumentsFn = StaticArgumentsFn; +})(TestOnDefaultExportedClass_10 || (TestOnDefaultExportedClass_10 = {})); diff --git a/tests/baselines/reference/staticPropertyNameConflictsInAmbientContext.symbols b/tests/baselines/reference/staticPropertyNameConflictsInAmbientContext.symbols new file mode 100644 index 00000000000..46297eab86a --- /dev/null +++ b/tests/baselines/reference/staticPropertyNameConflictsInAmbientContext.symbols @@ -0,0 +1,107 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/decl.d.ts === + +// name +declare class StaticName { +>StaticName : Symbol(StaticName, Decl(decl.d.ts, 0, 0)) + + static name: number; // ok +>name : Symbol(StaticName.name, Decl(decl.d.ts, 2, 26)) + + name: string; // ok +>name : Symbol(StaticName.name, Decl(decl.d.ts, 3, 24)) +} + +declare class StaticNameFn { +>StaticNameFn : Symbol(StaticNameFn, Decl(decl.d.ts, 5, 1)) + + static name(): string; // ok +>name : Symbol(StaticNameFn.name, Decl(decl.d.ts, 7, 28)) + + name(): string; // ok +>name : Symbol(StaticNameFn.name, Decl(decl.d.ts, 8, 26)) +} + +// length +declare class StaticLength { +>StaticLength : Symbol(StaticLength, Decl(decl.d.ts, 10, 1)) + + static length: number; // ok +>length : Symbol(StaticLength.length, Decl(decl.d.ts, 13, 28)) + + length: string; // ok +>length : Symbol(StaticLength.length, Decl(decl.d.ts, 14, 26)) +} + +declare class StaticLengthFn { +>StaticLengthFn : Symbol(StaticLengthFn, Decl(decl.d.ts, 16, 1)) + + static length(): number; // ok +>length : Symbol(StaticLengthFn.length, Decl(decl.d.ts, 18, 30)) + + length(): number; // ok +>length : Symbol(StaticLengthFn.length, Decl(decl.d.ts, 19, 28)) +} + +// prototype +declare class StaticPrototype { +>StaticPrototype : Symbol(StaticPrototype, Decl(decl.d.ts, 21, 1)) + + static prototype: number; // ok +>prototype : Symbol(StaticPrototype.prototype, Decl(decl.d.ts, 24, 31)) + + prototype: string; // ok +>prototype : Symbol(StaticPrototype.prototype, Decl(decl.d.ts, 25, 29)) +} + +declare class StaticPrototypeFn { +>StaticPrototypeFn : Symbol(StaticPrototypeFn, Decl(decl.d.ts, 27, 1)) + + static prototype: any; // ok +>prototype : Symbol(StaticPrototypeFn.prototype, Decl(decl.d.ts, 29, 33)) + + prototype(): any; // ok +>prototype : Symbol(StaticPrototypeFn.prototype, Decl(decl.d.ts, 30, 26)) +} + +// caller +declare class StaticCaller { +>StaticCaller : Symbol(StaticCaller, Decl(decl.d.ts, 32, 1)) + + static caller: number; // ok +>caller : Symbol(StaticCaller.caller, Decl(decl.d.ts, 35, 28)) + + caller: string; // ok +>caller : Symbol(StaticCaller.caller, Decl(decl.d.ts, 36, 26)) +} + +declare class StaticCallerFn { +>StaticCallerFn : Symbol(StaticCallerFn, Decl(decl.d.ts, 38, 1)) + + static caller(): any; // ok +>caller : Symbol(StaticCallerFn.caller, Decl(decl.d.ts, 40, 30)) + + caller(): any; // ok +>caller : Symbol(StaticCallerFn.caller, Decl(decl.d.ts, 41, 25)) +} + +// arguments +declare class StaticArguments { +>StaticArguments : Symbol(StaticArguments, Decl(decl.d.ts, 43, 1)) + + static arguments: number; // ok +>arguments : Symbol(StaticArguments.arguments, Decl(decl.d.ts, 46, 31)) + + arguments: string; // ok +>arguments : Symbol(StaticArguments.arguments, Decl(decl.d.ts, 47, 29)) +} + +declare class StaticArgumentsFn { +>StaticArgumentsFn : Symbol(StaticArgumentsFn, Decl(decl.d.ts, 49, 1)) + + static arguments(): any; // ok +>arguments : Symbol(StaticArgumentsFn.arguments, Decl(decl.d.ts, 51, 33)) + + arguments(): any; // ok +>arguments : Symbol(StaticArgumentsFn.arguments, Decl(decl.d.ts, 52, 28)) +} + diff --git a/tests/baselines/reference/staticPropertyNameConflictsInAmbientContext.types b/tests/baselines/reference/staticPropertyNameConflictsInAmbientContext.types new file mode 100644 index 00000000000..233bd8a46fc --- /dev/null +++ b/tests/baselines/reference/staticPropertyNameConflictsInAmbientContext.types @@ -0,0 +1,107 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/decl.d.ts === + +// name +declare class StaticName { +>StaticName : StaticName + + static name: number; // ok +>name : number + + name: string; // ok +>name : string +} + +declare class StaticNameFn { +>StaticNameFn : StaticNameFn + + static name(): string; // ok +>name : () => string + + name(): string; // ok +>name : () => string +} + +// length +declare class StaticLength { +>StaticLength : StaticLength + + static length: number; // ok +>length : number + + length: string; // ok +>length : string +} + +declare class StaticLengthFn { +>StaticLengthFn : StaticLengthFn + + static length(): number; // ok +>length : () => number + + length(): number; // ok +>length : () => number +} + +// prototype +declare class StaticPrototype { +>StaticPrototype : StaticPrototype + + static prototype: number; // ok +>prototype : StaticPrototype + + prototype: string; // ok +>prototype : string +} + +declare class StaticPrototypeFn { +>StaticPrototypeFn : StaticPrototypeFn + + static prototype: any; // ok +>prototype : StaticPrototypeFn + + prototype(): any; // ok +>prototype : () => any +} + +// caller +declare class StaticCaller { +>StaticCaller : StaticCaller + + static caller: number; // ok +>caller : number + + caller: string; // ok +>caller : string +} + +declare class StaticCallerFn { +>StaticCallerFn : StaticCallerFn + + static caller(): any; // ok +>caller : () => any + + caller(): any; // ok +>caller : () => any +} + +// arguments +declare class StaticArguments { +>StaticArguments : StaticArguments + + static arguments: number; // ok +>arguments : number + + arguments: string; // ok +>arguments : string +} + +declare class StaticArgumentsFn { +>StaticArgumentsFn : StaticArgumentsFn + + static arguments(): any; // ok +>arguments : () => any + + arguments(): any; // ok +>arguments : () => any +} + diff --git a/tests/baselines/reference/staticPrototypeProperty.errors.txt b/tests/baselines/reference/staticPrototypeProperty.errors.txt index c3f5cb99c96..c131b7a774d 100644 --- a/tests/baselines/reference/staticPrototypeProperty.errors.txt +++ b/tests/baselines/reference/staticPrototypeProperty.errors.txt @@ -1,13 +1,19 @@ tests/cases/compiler/staticPrototypeProperty.ts(2,11): error TS2300: Duplicate identifier 'prototype'. +tests/cases/compiler/staticPrototypeProperty.ts(2,11): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. +tests/cases/compiler/staticPrototypeProperty.ts(6,11): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C2'. -==== tests/cases/compiler/staticPrototypeProperty.ts (1 errors) ==== +==== tests/cases/compiler/staticPrototypeProperty.ts (3 errors) ==== class C { static prototype() { } ~~~~~~~~~ !!! error TS2300: Duplicate identifier 'prototype'. + ~~~~~~~~~ +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. } class C2 { static prototype; + ~~~~~~~~~ +!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C2'. } \ No newline at end of file diff --git a/tests/baselines/reference/strictModeInConstructor.js b/tests/baselines/reference/strictModeInConstructor.js index da45bda5c6e..65426391967 100644 --- a/tests/baselines/reference/strictModeInConstructor.js +++ b/tests/baselines/reference/strictModeInConstructor.js @@ -61,11 +61,16 @@ class Ds extends A { } //// [strictModeInConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -94,7 +99,7 @@ var C = (function (_super) { var D = (function (_super) { __extends(D, _super); function D() { - var _this; + var _this = this; _this.s = 9; var x = 1; // Error _this = _super.call(this) || this; @@ -125,7 +130,7 @@ Cs.s = 9; var Ds = (function (_super) { __extends(Ds, _super); function Ds() { - var _this; + var _this = this; var x = 1; // no Error _this = _super.call(this) || this; "use strict"; diff --git a/tests/baselines/reference/strictModeReservedWord.js b/tests/baselines/reference/strictModeReservedWord.js index 29715745890..07b514da9b7 100644 --- a/tests/baselines/reference/strictModeReservedWord.js +++ b/tests/baselines/reference/strictModeReservedWord.js @@ -28,11 +28,16 @@ function foo() { //// [strictModeReservedWord.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var let = 10; function foo() { "use strict"; @@ -48,7 +53,7 @@ function foo() { var myClass = (function (_super) { __extends(package, _super); function package() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return package; }(public)); diff --git a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.js b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.js index 1507e53d8cf..2539ce5dbbb 100644 --- a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.js +++ b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.js @@ -29,11 +29,16 @@ class G extends package { } class H extends package.A { } //// [strictModeReservedWordInClassDeclaration.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo(private, public, static) { private = public = static; @@ -75,14 +80,14 @@ var F1 = (function () { var G = (function (_super) { __extends(G, _super); function G() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return G; }(package)); var H = (function (_super) { __extends(H, _super); function H() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return H; }(package.A)); diff --git a/tests/baselines/reference/strictModeReservedWordInImportEqualDeclaration.js b/tests/baselines/reference/strictModeReservedWordInImportEqualDeclaration.js index 50ed1b4d755..409e6f67584 100644 --- a/tests/baselines/reference/strictModeReservedWordInImportEqualDeclaration.js +++ b/tests/baselines/reference/strictModeReservedWordInImportEqualDeclaration.js @@ -5,3 +5,4 @@ import public = require("1"); //// [strictModeReservedWordInImportEqualDeclaration.js] "use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt index 8f4bbe2025a..606cc39afef 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt @@ -22,8 +22,8 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(71,5): error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(73,5): error TS2411: Property '"4.0"' of type 'number' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(74,5): error TS2411: Property 'f' of type 'MyString' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. - Property '2.0' is incompatible with index signature. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ a: string; b: number; c: () => void; "d": string; "e": number; 1.0: string; 2.0: number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. + Property 'b' is incompatible with index signature. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(93,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -157,8 +157,8 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon // error var b: { [x: string]: string; } = { ~ -!!! error TS2322: Type '{ 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. -!!! error TS2322: Property '2.0' is incompatible with index signature. +!!! error TS2322: Type '{ a: string; b: number; c: () => void; "d": string; "e": number; 1.0: string; 2.0: number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. +!!! error TS2322: Property 'b' is incompatible with index signature. !!! error TS2322: Type 'number' is not assignable to type 'string'. a: '', b: 1, diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.js b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.js index b532df7b120..f9942aff042 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.js +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.js @@ -41,11 +41,16 @@ var b: { [x: string]: A } = { //// [stringIndexerConstrainsPropertyDeclarations2.js] // String indexer providing a constraint of a user defined type -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -55,7 +60,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function () { return ''; }; return B; diff --git a/tests/baselines/reference/subSubClassCanAccessProtectedConstructor.js b/tests/baselines/reference/subSubClassCanAccessProtectedConstructor.js index 15d6fc70da5..5036df4a330 100644 --- a/tests/baselines/reference/subSubClassCanAccessProtectedConstructor.js +++ b/tests/baselines/reference/subSubClassCanAccessProtectedConstructor.js @@ -17,11 +17,16 @@ class SubclassOfSubclass extends Subclass { //// [subSubClassCanAccessProtectedConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { this.instance1 = new Base(); // allowed @@ -31,7 +36,7 @@ var Base = (function () { var Subclass = (function (_super) { __extends(Subclass, _super); function Subclass() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.instance1_1 = new Base(); // allowed _this.instance1_2 = new Subclass(); // allowed return _this; @@ -41,7 +46,7 @@ var Subclass = (function (_super) { var SubclassOfSubclass = (function (_super) { __extends(SubclassOfSubclass, _super); function SubclassOfSubclass() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.instance2_1 = new Base(); // allowed _this.instance2_2 = new Subclass(); // allowed _this.instance2_3 = new SubclassOfSubclass(); // allowed diff --git a/tests/baselines/reference/subtypesOfTypeParameter.js b/tests/baselines/reference/subtypesOfTypeParameter.js index 38f5b5f1d4b..3c3a17d8f84 100644 --- a/tests/baselines/reference/subtypesOfTypeParameter.js +++ b/tests/baselines/reference/subtypesOfTypeParameter.js @@ -107,11 +107,16 @@ function f2(x: T, y: U) { //// [subtypesOfTypeParameter.js] // checking whether other types are subtypes of type parameters -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C3 = (function () { function C3() { } @@ -120,7 +125,7 @@ var C3 = (function () { var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(C3)); diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.js b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.js index 82bcbf14ecc..b594eea6e4d 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.js +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.js @@ -169,11 +169,16 @@ class D29 extends C3 { //// [subtypesOfTypeParameterWithConstraints.js] // checking whether other types are subtypes of type parameters with constraints -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C3 = (function () { function C3() { } @@ -182,28 +187,28 @@ var C3 = (function () { var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(C3)); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(C3)); var D3 = (function (_super) { __extends(D3, _super); function D3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D3; }(C3)); var D4 = (function (_super) { __extends(D4, _super); function D4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D4; }(C3)); @@ -213,21 +218,21 @@ var D4 = (function (_super) { var D5 = (function (_super) { __extends(D5, _super); function D5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D5; }(C3)); var D6 = (function (_super) { __extends(D6, _super); function D6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D6; }(C3)); var D7 = (function (_super) { __extends(D7, _super); function D7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D7; }(C3)); @@ -236,21 +241,21 @@ var D7 = (function (_super) { var D8 = (function (_super) { __extends(D8, _super); function D8() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D8; }(C3)); var D9 = (function (_super) { __extends(D9, _super); function D9() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D9; }(C3)); var D10 = (function (_super) { __extends(D10, _super); function D10() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D10; }(C3)); @@ -259,21 +264,21 @@ var D10 = (function (_super) { var D11 = (function (_super) { __extends(D11, _super); function D11() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D11; }(C3)); var D12 = (function (_super) { __extends(D12, _super); function D12() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D12; }(C3)); var D13 = (function (_super) { __extends(D13, _super); function D13() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D13; }(C3)); @@ -283,28 +288,28 @@ var D13 = (function (_super) { var D14 = (function (_super) { __extends(D14, _super); function D14() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D14; }(C3)); var D15 = (function (_super) { __extends(D15, _super); function D15() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D15; }(C3)); var D16 = (function (_super) { __extends(D16, _super); function D16() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D16; }(C3)); var D17 = (function (_super) { __extends(D17, _super); function D17() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D17; }(C3)); @@ -313,28 +318,28 @@ var D17 = (function (_super) { var D18 = (function (_super) { __extends(D18, _super); function D18() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D18; }(C3)); var D19 = (function (_super) { __extends(D19, _super); function D19() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D19; }(C3)); var D20 = (function (_super) { __extends(D20, _super); function D20() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D20; }(C3)); var D21 = (function (_super) { __extends(D21, _super); function D21() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D21; }(C3)); @@ -343,28 +348,28 @@ var D21 = (function (_super) { var D22 = (function (_super) { __extends(D22, _super); function D22() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D22; }(C3)); var D23 = (function (_super) { __extends(D23, _super); function D23() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D23; }(C3)); var D24 = (function (_super) { __extends(D24, _super); function D24() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D24; }(C3)); var D25 = (function (_super) { __extends(D25, _super); function D25() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D25; }(C3)); @@ -373,28 +378,28 @@ var D25 = (function (_super) { var D26 = (function (_super) { __extends(D26, _super); function D26() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D26; }(C3)); var D27 = (function (_super) { __extends(D27, _super); function D27() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D27; }(C3)); var D28 = (function (_super) { __extends(D28, _super); function D28() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D28; }(C3)); var D29 = (function (_super) { __extends(D29, _super); function D29() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D29; }(C3)); diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js index e0baced37a4..b3fa5971898 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.js @@ -80,11 +80,16 @@ class D9 extends B1 { //// [subtypesOfTypeParameterWithConstraints4.js] // checking whether other types are subtypes of type parameters with constraints -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -118,63 +123,63 @@ var B1 = (function () { var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(B1)); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(B1)); var D3 = (function (_super) { __extends(D3, _super); function D3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D3; }(B1)); var D4 = (function (_super) { __extends(D4, _super); function D4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D4; }(B1)); var D5 = (function (_super) { __extends(D5, _super); function D5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D5; }(B1)); var D6 = (function (_super) { __extends(D6, _super); function D6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D6; }(B1)); var D7 = (function (_super) { __extends(D7, _super); function D7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D7; }(B1)); var D8 = (function (_super) { __extends(D8, _super); function D8() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D8; }(B1)); var D9 = (function (_super) { __extends(D9, _super); function D9() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D9; }(B1)); diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js index 0b17fc07f24..3d2fb052b41 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js +++ b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.js @@ -159,11 +159,16 @@ module M2 { //// [subtypesOfTypeParameterWithRecursiveConstraints.js] // checking whether other types are subtypes of type parameters with constraints -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function () { function Foo() { } @@ -217,63 +222,63 @@ var M1; var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(Base)); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(Base)); var D3 = (function (_super) { __extends(D3, _super); function D3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D3; }(Base)); var D4 = (function (_super) { __extends(D4, _super); function D4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D4; }(Base)); var D5 = (function (_super) { __extends(D5, _super); function D5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D5; }(Base)); var D6 = (function (_super) { __extends(D6, _super); function D6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D6; }(Base)); var D7 = (function (_super) { __extends(D7, _super); function D7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D7; }(Base)); var D8 = (function (_super) { __extends(D8, _super); function D8() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D8; }(Base)); var D9 = (function (_super) { __extends(D9, _super); function D9() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D9; }(Base)); @@ -288,63 +293,63 @@ var M2; var D1 = (function (_super) { __extends(D1, _super); function D1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D1; }(Base2)); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(Base2)); var D3 = (function (_super) { __extends(D3, _super); function D3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D3; }(Base2)); var D4 = (function (_super) { __extends(D4, _super); function D4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D4; }(Base2)); var D5 = (function (_super) { __extends(D5, _super); function D5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D5; }(Base2)); var D6 = (function (_super) { __extends(D6, _super); function D6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D6; }(Base2)); var D7 = (function (_super) { __extends(D7, _super); function D7() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D7; }(Base2)); var D8 = (function (_super) { __extends(D8, _super); function D8() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D8; }(Base2)); var D9 = (function (_super) { __extends(D9, _super); function D9() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D9; }(Base2)); diff --git a/tests/baselines/reference/subtypingTransitivity.js b/tests/baselines/reference/subtypingTransitivity.js index 9c4c9011758..cbacd85a779 100644 --- a/tests/baselines/reference/subtypingTransitivity.js +++ b/tests/baselines/reference/subtypingTransitivity.js @@ -20,11 +20,16 @@ b.x = 1; // assigned number to string //// [subtypingTransitivity.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B() { } @@ -33,14 +38,14 @@ var B = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(B)); var D2 = (function (_super) { __extends(D2, _super); function D2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D2; }(B)); diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.js b/tests/baselines/reference/subtypingWithCallSignatures2.js index 3b5fada2012..dfe34ca35f0 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.js +++ b/tests/baselines/reference/subtypingWithCallSignatures2.js @@ -174,11 +174,16 @@ var r18 = foo18(r18arg1); //// [subtypingWithCallSignatures2.js] // checking subtype relations for function types as it relates to contextual signature instantiation -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -187,21 +192,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/subtypingWithCallSignatures3.js b/tests/baselines/reference/subtypingWithCallSignatures3.js index 4ac7d3a7f24..d479bdbe618 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures3.js +++ b/tests/baselines/reference/subtypingWithCallSignatures3.js @@ -121,11 +121,16 @@ module WithGenericSignaturesInBaseType { //// [subtypingWithCallSignatures3.js] // checking subtype relations for function types as it relates to contextual signature instantiation // error cases, so function calls will all result in 'any' -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Errors; (function (Errors) { var Base = (function () { @@ -136,21 +141,21 @@ var Errors; var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/subtypingWithCallSignatures4.js b/tests/baselines/reference/subtypingWithCallSignatures4.js index 94f549c62c1..09c5e8056ba 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures4.js +++ b/tests/baselines/reference/subtypingWithCallSignatures4.js @@ -113,11 +113,16 @@ var r18 = foo18(r18arg); //// [subtypingWithCallSignatures4.js] // checking subtype relations for function types as it relates to contextual signature instantiation -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -126,21 +131,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/subtypingWithConstructSignatures2.js b/tests/baselines/reference/subtypingWithConstructSignatures2.js index 1d12aeb945f..55624b63f42 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures2.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures2.js @@ -174,11 +174,16 @@ var r18 = foo18(r18arg1); //// [subtypingWithConstructSignatures2.js] // checking subtype relations for function types as it relates to contextual signature instantiation -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -187,21 +192,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/subtypingWithConstructSignatures3.js b/tests/baselines/reference/subtypingWithConstructSignatures3.js index 78582304cb8..a7a7f620389 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures3.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures3.js @@ -123,11 +123,16 @@ module WithGenericSignaturesInBaseType { //// [subtypingWithConstructSignatures3.js] // checking subtype relations for function types as it relates to contextual signature instantiation // error cases, so function calls will all result in 'any' -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Errors; (function (Errors) { var Base = (function () { @@ -138,21 +143,21 @@ var Errors; var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/subtypingWithConstructSignatures4.js b/tests/baselines/reference/subtypingWithConstructSignatures4.js index 17252fdb809..e8ca51f317a 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures4.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures4.js @@ -113,11 +113,16 @@ var r18 = foo18(r18arg); //// [subtypingWithConstructSignatures4.js] // checking subtype relations for function types as it relates to contextual signature instantiation -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -126,21 +131,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/subtypingWithConstructSignatures5.js b/tests/baselines/reference/subtypingWithConstructSignatures5.js index a0561606393..c99e215bc89 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures5.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures5.js @@ -51,11 +51,16 @@ interface I extends B { //// [subtypingWithConstructSignatures5.js] // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithConstructSignatures2 just with an extra level of indirection in the inheritance chain -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -64,21 +69,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/subtypingWithConstructSignatures6.js b/tests/baselines/reference/subtypingWithConstructSignatures6.js index c508781e089..cbd8eebf47c 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures6.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures6.js @@ -54,11 +54,16 @@ interface I9 extends A { // checking subtype relations for function types as it relates to contextual signature instantiation // same as subtypingWithConstructSignatures4 but using class type parameters instead of generic signatures // all are errors -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -67,21 +72,21 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return OtherDerived; }(Base)); diff --git a/tests/baselines/reference/subtypingWithNumericIndexer.js b/tests/baselines/reference/subtypingWithNumericIndexer.js index 3cf75dd83fd..7f140917935 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer.js +++ b/tests/baselines/reference/subtypingWithNumericIndexer.js @@ -41,11 +41,16 @@ module Generics { //// [subtypingWithNumericIndexer.js] // Derived type indexer must be subtype of base type indexer -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -54,14 +59,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); @@ -75,28 +80,28 @@ var Generics; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A)); var B4 = (function (_super) { __extends(B4, _super); function B4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B4; }(A)); diff --git a/tests/baselines/reference/subtypingWithNumericIndexer3.js b/tests/baselines/reference/subtypingWithNumericIndexer3.js index e9e8d39bf3c..e8fbc59bed7 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer3.js +++ b/tests/baselines/reference/subtypingWithNumericIndexer3.js @@ -45,11 +45,16 @@ module Generics { //// [subtypingWithNumericIndexer3.js] // Derived type indexer must be subtype of base type indexer -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -58,14 +63,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); @@ -79,35 +84,35 @@ var Generics; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A)); var B4 = (function (_super) { __extends(B4, _super); function B4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B4; }(A)); var B5 = (function (_super) { __extends(B5, _super); function B5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B5; }(A)); diff --git a/tests/baselines/reference/subtypingWithNumericIndexer4.js b/tests/baselines/reference/subtypingWithNumericIndexer4.js index 798e775083f..ce3ed4fb4de 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer4.js +++ b/tests/baselines/reference/subtypingWithNumericIndexer4.js @@ -29,11 +29,16 @@ module Generics { //// [subtypingWithNumericIndexer4.js] // Derived type indexer must be subtype of base type indexer -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -42,7 +47,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -56,14 +61,14 @@ var Generics; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A)); diff --git a/tests/baselines/reference/subtypingWithObjectMembers.js b/tests/baselines/reference/subtypingWithObjectMembers.js index 3675ed6a410..7f1c9e9e492 100644 --- a/tests/baselines/reference/subtypingWithObjectMembers.js +++ b/tests/baselines/reference/subtypingWithObjectMembers.js @@ -68,11 +68,16 @@ module TwoLevels { } //// [subtypingWithObjectMembers.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -81,14 +86,14 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Derived)); @@ -102,7 +107,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -114,7 +119,7 @@ var A2 = (function () { var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A2)); @@ -126,7 +131,7 @@ var A3 = (function () { var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A3)); @@ -140,7 +145,7 @@ var TwoLevels; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -152,7 +157,7 @@ var TwoLevels; var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A2)); @@ -164,7 +169,7 @@ var TwoLevels; var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A3)); diff --git a/tests/baselines/reference/subtypingWithObjectMembers4.js b/tests/baselines/reference/subtypingWithObjectMembers4.js index 404b6cbe988..e453b508c34 100644 --- a/tests/baselines/reference/subtypingWithObjectMembers4.js +++ b/tests/baselines/reference/subtypingWithObjectMembers4.js @@ -35,11 +35,16 @@ class B3 extends A3 { //// [subtypingWithObjectMembers4.js] // subtyping when property names do not match -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -48,7 +53,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -60,7 +65,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -72,7 +77,7 @@ var A2 = (function () { var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A2)); @@ -84,7 +89,7 @@ var A3 = (function () { var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A3)); diff --git a/tests/baselines/reference/subtypingWithObjectMembersAccessibility.js b/tests/baselines/reference/subtypingWithObjectMembersAccessibility.js index 8b168ea73b5..fae7c452edc 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersAccessibility.js +++ b/tests/baselines/reference/subtypingWithObjectMembersAccessibility.js @@ -35,11 +35,16 @@ class B3 extends A3 { //// [subtypingWithObjectMembersAccessibility.js] // Derived member is private, base member is not causes errors -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -48,7 +53,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -60,7 +65,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -72,7 +77,7 @@ var A2 = (function () { var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A2)); @@ -84,7 +89,7 @@ var A3 = (function () { var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A3)); diff --git a/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.js b/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.js index 0a83b760218..6fd845d2277 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.js +++ b/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.js @@ -63,11 +63,16 @@ module ImplicitPublic { //// [subtypingWithObjectMembersAccessibility2.js] // Derived member is private, base member is not causes errors -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { } @@ -76,7 +81,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived; }(Base)); @@ -90,7 +95,7 @@ var ExplicitPublic; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -102,7 +107,7 @@ var ExplicitPublic; var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A2)); @@ -114,7 +119,7 @@ var ExplicitPublic; var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A3)); @@ -129,7 +134,7 @@ var ImplicitPublic; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -141,7 +146,7 @@ var ImplicitPublic; var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A2)); @@ -153,7 +158,7 @@ var ImplicitPublic; var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A3)); diff --git a/tests/baselines/reference/subtypingWithStringIndexer.js b/tests/baselines/reference/subtypingWithStringIndexer.js index 195b7d2192e..36382a4ff91 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer.js +++ b/tests/baselines/reference/subtypingWithStringIndexer.js @@ -42,11 +42,16 @@ module Generics { //// [subtypingWithStringIndexer.js] // Derived type indexer must be subtype of base type indexer -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -55,14 +60,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); @@ -76,28 +81,28 @@ var Generics; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A)); var B4 = (function (_super) { __extends(B4, _super); function B4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B4; }(A)); diff --git a/tests/baselines/reference/subtypingWithStringIndexer3.js b/tests/baselines/reference/subtypingWithStringIndexer3.js index 0b2a57324eb..ed8e027e7c5 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer3.js +++ b/tests/baselines/reference/subtypingWithStringIndexer3.js @@ -45,11 +45,16 @@ module Generics { //// [subtypingWithStringIndexer3.js] // Derived type indexer must be subtype of base type indexer -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -58,14 +63,14 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); @@ -79,35 +84,35 @@ var Generics; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B2 = (function (_super) { __extends(B2, _super); function B2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B2; }(A)); var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A)); var B4 = (function (_super) { __extends(B4, _super); function B4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B4; }(A)); var B5 = (function (_super) { __extends(B5, _super); function B5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B5; }(A)); diff --git a/tests/baselines/reference/subtypingWithStringIndexer4.js b/tests/baselines/reference/subtypingWithStringIndexer4.js index 2937261ad05..d8a9693e1a1 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer4.js +++ b/tests/baselines/reference/subtypingWithStringIndexer4.js @@ -29,11 +29,16 @@ module Generics { //// [subtypingWithStringIndexer4.js] // Derived type indexer must be subtype of base type indexer -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -42,7 +47,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); @@ -56,14 +61,14 @@ var Generics; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B; }(A)); var B3 = (function (_super) { __extends(B3, _super); function B3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return B3; }(A)); diff --git a/tests/baselines/reference/super.js b/tests/baselines/reference/super.js index 504e8542d4d..3dd0e9ed538 100644 --- a/tests/baselines/reference/super.js +++ b/tests/baselines/reference/super.js @@ -38,11 +38,16 @@ s.foo() + ss.foo(); //// [super.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base() { var x; @@ -58,7 +63,7 @@ var Base = (function () { var Sub1 = (function (_super) { __extends(Sub1, _super); function Sub1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Sub1.prototype.foo = function () { return "sub1" + _super.prototype.foo.call(this) + _super.prototype.bar.call(this); @@ -68,7 +73,7 @@ var Sub1 = (function (_super) { var SubSub1 = (function (_super) { __extends(SubSub1, _super); function SubSub1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SubSub1.prototype.foo = function () { return "subsub1" + _super.prototype.foo.call(this); diff --git a/tests/baselines/reference/super1.js b/tests/baselines/reference/super1.js index 0094f696faf..1ed0edbe051 100644 --- a/tests/baselines/reference/super1.js +++ b/tests/baselines/reference/super1.js @@ -67,11 +67,16 @@ module Base4 { //// [super1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // Case 1 var Base1 = (function () { function Base1() { @@ -84,7 +89,7 @@ var Base1 = (function () { var Sub1 = (function (_super) { __extends(Sub1, _super); function Sub1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Sub1.prototype.bar = function () { return "base"; @@ -94,7 +99,7 @@ var Sub1 = (function (_super) { var SubSub1 = (function (_super) { __extends(SubSub1, _super); function SubSub1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SubSub1.prototype.bar = function () { return _super.prototype["super"].foo; @@ -113,7 +118,7 @@ var Base2 = (function () { var SubE2 = (function (_super) { __extends(SubE2, _super); function SubE2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SubE2.prototype.bar = function () { return _super.prototype.prototype.foo = null; @@ -132,7 +137,7 @@ var Base3 = (function () { var SubE3 = (function (_super) { __extends(SubE3, _super); function SubE3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SubE3.prototype.bar = function () { return _super.prototype.bar.call(this); @@ -153,7 +158,7 @@ var Base4; var SubSub4 = (function (_super) { __extends(SubSub4, _super); function SubSub4() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SubSub4.prototype.x = function () { return _super.prototype.x.call(this); diff --git a/tests/baselines/reference/super2.js b/tests/baselines/reference/super2.js index 1d2331052db..0f2101bc4dd 100644 --- a/tests/baselines/reference/super2.js +++ b/tests/baselines/reference/super2.js @@ -51,11 +51,16 @@ results1.x() + results1.y() + results2.y(); //// [super2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); // Case 5 var Base5 = (function () { function Base5() { @@ -71,7 +76,7 @@ var Base5 = (function () { var Sub5 = (function (_super) { __extends(Sub5, _super); function Sub5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Sub5.prototype.x = function () { return "SubX"; @@ -81,7 +86,7 @@ var Sub5 = (function (_super) { var SubSub5 = (function (_super) { __extends(SubSub5, _super); function SubSub5() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SubSub5.prototype.x = function () { return _super.prototype.x.call(this); @@ -103,7 +108,7 @@ var Base6 = (function () { var Sub6 = (function (_super) { __extends(Sub6, _super); function Sub6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Sub6.prototype.y = function () { return "SubY"; @@ -113,7 +118,7 @@ var Sub6 = (function (_super) { var SubSub6 = (function (_super) { __extends(SubSub6, _super); function SubSub6() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SubSub6.prototype.y = function () { return _super.prototype.y.call(this); diff --git a/tests/baselines/reference/superAccess.js b/tests/baselines/reference/superAccess.js index 0bd9d305d2e..468e2155e48 100644 --- a/tests/baselines/reference/superAccess.js +++ b/tests/baselines/reference/superAccess.js @@ -14,11 +14,16 @@ class MyDerived extends MyBase { } //// [superAccess.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var MyBase = (function () { function MyBase() { this.S2 = "test"; @@ -30,7 +35,7 @@ MyBase.S1 = 5; var MyDerived = (function (_super) { __extends(MyDerived, _super); function MyDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } MyDerived.prototype.foo = function () { var l3 = _super.prototype.S1; // Expected => Error: Only public instance methods of the base class are accessible via the 'super' keyword diff --git a/tests/baselines/reference/superAccess2.js b/tests/baselines/reference/superAccess2.js index fc3960fba3e..51e8f61ab28 100644 --- a/tests/baselines/reference/superAccess2.js +++ b/tests/baselines/reference/superAccess2.js @@ -25,11 +25,16 @@ class Q extends P { } //// [superAccess2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var P = (function () { function P() { } diff --git a/tests/baselines/reference/superAccessInFatArrow1.js b/tests/baselines/reference/superAccessInFatArrow1.js index a7f964309f7..ebbf9ccf8d2 100644 --- a/tests/baselines/reference/superAccessInFatArrow1.js +++ b/tests/baselines/reference/superAccessInFatArrow1.js @@ -16,11 +16,16 @@ module test { } //// [superAccessInFatArrow1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var test; (function (test) { var A = (function () { @@ -34,7 +39,7 @@ var test; var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.bar = function (callback) { }; diff --git a/tests/baselines/reference/superCallArgsMustMatch.js b/tests/baselines/reference/superCallArgsMustMatch.js index 106d7433bf5..113fbd69625 100644 --- a/tests/baselines/reference/superCallArgsMustMatch.js +++ b/tests/baselines/reference/superCallArgsMustMatch.js @@ -26,11 +26,16 @@ class T6 extends T5{ //// [superCallArgsMustMatch.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var T5 = (function () { function T5(bar) { this.bar = bar; diff --git a/tests/baselines/reference/superCallAssignResult.js b/tests/baselines/reference/superCallAssignResult.js index 6e30cc64052..a4525cb6ec8 100644 --- a/tests/baselines/reference/superCallAssignResult.js +++ b/tests/baselines/reference/superCallAssignResult.js @@ -11,11 +11,16 @@ class H extends E { } //// [superCallAssignResult.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var E = (function () { function E(arg) { } @@ -24,7 +29,7 @@ var E = (function () { var H = (function (_super) { __extends(H, _super); function H() { - var _this; + var _this = this; var x = _this = _super.call(this, 5) || this; // Should be of type void, not E. x = 5; return _this; diff --git a/tests/baselines/reference/superCallBeforeThisAccessing1.js b/tests/baselines/reference/superCallBeforeThisAccessing1.js index e3aed9e40e9..3045968da16 100644 --- a/tests/baselines/reference/superCallBeforeThisAccessing1.js +++ b/tests/baselines/reference/superCallBeforeThisAccessing1.js @@ -17,11 +17,16 @@ class D extends Base { //// [superCallBeforeThisAccessing1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(c) { } diff --git a/tests/baselines/reference/superCallBeforeThisAccessing2.js b/tests/baselines/reference/superCallBeforeThisAccessing2.js index 91cc3d28dd6..d78ba6e4875 100644 --- a/tests/baselines/reference/superCallBeforeThisAccessing2.js +++ b/tests/baselines/reference/superCallBeforeThisAccessing2.js @@ -11,11 +11,16 @@ class D extends Base { //// [superCallBeforeThisAccessing2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(c) { } diff --git a/tests/baselines/reference/superCallBeforeThisAccessing3.js b/tests/baselines/reference/superCallBeforeThisAccessing3.js index 185767fefb6..0bf37369b7e 100644 --- a/tests/baselines/reference/superCallBeforeThisAccessing3.js +++ b/tests/baselines/reference/superCallBeforeThisAccessing3.js @@ -14,11 +14,16 @@ class D extends Base { //// [superCallBeforeThisAccessing3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(c) { } @@ -27,7 +32,7 @@ var Base = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this; + var _this = this; var x = function () { _this._t; }; x(); // no error; we only check super is called before this when the container is a constructor _this._t; // error diff --git a/tests/baselines/reference/superCallBeforeThisAccessing4.js b/tests/baselines/reference/superCallBeforeThisAccessing4.js index 91acb88ce22..80a71d02d4d 100644 --- a/tests/baselines/reference/superCallBeforeThisAccessing4.js +++ b/tests/baselines/reference/superCallBeforeThisAccessing4.js @@ -16,27 +16,29 @@ class E extends null { } //// [superCallBeforeThisAccessing4.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var D = (function (_super) { __extends(D, _super); function D() { - var _this; - _this._t; + this._t; _this = _super.call(this) || this; - return _this; } return D; }(null)); var E = (function (_super) { __extends(E, _super); function E() { - var _this = _super.call(this) || this; - _this._t; - return _this; + _this = _super.call(this) || this; + this._t; } return E; }(null)); diff --git a/tests/baselines/reference/superCallBeforeThisAccessing5.js b/tests/baselines/reference/superCallBeforeThisAccessing5.js index 57228538faf..42049ff2b32 100644 --- a/tests/baselines/reference/superCallBeforeThisAccessing5.js +++ b/tests/baselines/reference/superCallBeforeThisAccessing5.js @@ -8,17 +8,20 @@ class D extends null { //// [superCallBeforeThisAccessing5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var D = (function (_super) { __extends(D, _super); function D() { - var _this; - _this._t; // No error - return _this; + this._t; // No error } return D; }(null)); diff --git a/tests/baselines/reference/superCallBeforeThisAccessing6.js b/tests/baselines/reference/superCallBeforeThisAccessing6.js index 4eb8e5266c2..244e21e6f73 100644 --- a/tests/baselines/reference/superCallBeforeThisAccessing6.js +++ b/tests/baselines/reference/superCallBeforeThisAccessing6.js @@ -11,11 +11,16 @@ class D extends Base { //// [superCallBeforeThisAccessing6.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(c) { } diff --git a/tests/baselines/reference/superCallBeforeThisAccessing7.js b/tests/baselines/reference/superCallBeforeThisAccessing7.js index 9cfe8736774..90bc4e5c466 100644 --- a/tests/baselines/reference/superCallBeforeThisAccessing7.js +++ b/tests/baselines/reference/superCallBeforeThisAccessing7.js @@ -14,11 +14,16 @@ class D extends Base { //// [superCallBeforeThisAccessing7.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(c) { } @@ -27,7 +32,7 @@ var Base = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this; + var _this = this; var x = { j: _this._t }; diff --git a/tests/baselines/reference/superCallBeforeThisAccessing8.js b/tests/baselines/reference/superCallBeforeThisAccessing8.js index fe459b5e031..2bf73681986 100644 --- a/tests/baselines/reference/superCallBeforeThisAccessing8.js +++ b/tests/baselines/reference/superCallBeforeThisAccessing8.js @@ -14,11 +14,16 @@ class D extends Base { //// [superCallBeforeThisAccessing8.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(c) { } @@ -27,7 +32,7 @@ var Base = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this; + var _this = this; var x = { k: _this = _super.call(this, undefined) || this, j: _this._t diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.js b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.js index bc196299bf9..4ee302020ef 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType1.js @@ -12,11 +12,16 @@ class D extends B { //// [superCallFromClassThatDerivesFromGenericType1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var D = (function (_super) { __extends(D, _super); function D() { diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.js b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.js index 8a0ef085590..3d9c8ff717e 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericType2.js @@ -11,11 +11,16 @@ class D extends B { //// [superCallFromClassThatDerivesFromGenericType2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var D = (function (_super) { __extends(D, _super); function D() { diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.js b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.js index 0529d5e3dc2..18038207125 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.js @@ -11,11 +11,16 @@ class B extends A { } //// [superCallFromClassThatDerivesFromGenericTypeButWithIncorrectNumberOfTypeArguments1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(map) { this.map = map; diff --git a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.js b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.js index fb08ec28902..77b0f4af212 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.js @@ -11,11 +11,16 @@ class B extends A { } //// [superCallFromClassThatDerivesFromGenericTypeButWithNoTypeArguments1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(map) { this.map = map; diff --git a/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.js b/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.js index 50153391f62..861bd9b470c 100644 --- a/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.js +++ b/tests/baselines/reference/superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.js @@ -11,11 +11,16 @@ class B extends A { } //// [superCallFromClassThatDerivesNonGenericTypeButWithTypeArguments1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(map) { this.map = map; diff --git a/tests/baselines/reference/superCallInNonStaticMethod.js b/tests/baselines/reference/superCallInNonStaticMethod.js index cd84052ca3c..056dda2bf33 100644 --- a/tests/baselines/reference/superCallInNonStaticMethod.js +++ b/tests/baselines/reference/superCallInNonStaticMethod.js @@ -51,11 +51,16 @@ class Other extends Doing { //// [superCallInNonStaticMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Doing = (function () { function Doing() { } diff --git a/tests/baselines/reference/superCallInStaticMethod.js b/tests/baselines/reference/superCallInStaticMethod.js index b31110fdf78..c07c64304df 100644 --- a/tests/baselines/reference/superCallInStaticMethod.js +++ b/tests/baselines/reference/superCallInStaticMethod.js @@ -47,11 +47,16 @@ class Other extends Doing { //// [superCallInStaticMethod.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Doing = (function () { function Doing() { } @@ -62,7 +67,7 @@ var Doing = (function () { var Other = (function (_super) { __extends(Other, _super); function Other() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } // in static method Other.staticMethod = function () { diff --git a/tests/baselines/reference/superCallInsideClassDeclaration.js b/tests/baselines/reference/superCallInsideClassDeclaration.js index 05e44119608..ff822037647 100644 --- a/tests/baselines/reference/superCallInsideClassDeclaration.js +++ b/tests/baselines/reference/superCallInsideClassDeclaration.js @@ -17,11 +17,16 @@ class B extends A { } //// [superCallInsideClassDeclaration.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -35,7 +40,7 @@ var C = (function () { var B = (function (_super) { __extends(B, _super); function B() { - var _this; + var _this = this; var D = (function (_super) { __extends(D, _super); function D() { diff --git a/tests/baselines/reference/superCallInsideClassExpression.js b/tests/baselines/reference/superCallInsideClassExpression.js index 3d55fe11cff..e1d146aa131 100644 --- a/tests/baselines/reference/superCallInsideClassExpression.js +++ b/tests/baselines/reference/superCallInsideClassExpression.js @@ -17,11 +17,16 @@ class B extends A { } //// [superCallInsideClassExpression.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -35,7 +40,7 @@ var C = (function () { var B = (function (_super) { __extends(B, _super); function B() { - var _this; + var _this = this; var D = (function (_super) { __extends(class_1, _super); function class_1() { diff --git a/tests/baselines/reference/superCallInsideObjectLiteralExpression.js b/tests/baselines/reference/superCallInsideObjectLiteralExpression.js index 636b03c227f..541539d39ac 100644 --- a/tests/baselines/reference/superCallInsideObjectLiteralExpression.js +++ b/tests/baselines/reference/superCallInsideObjectLiteralExpression.js @@ -13,11 +13,16 @@ class B extends A { } //// [superCallInsideObjectLiteralExpression.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -28,7 +33,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - var _this; + var _this = this; var x = { x: _this = _super.call(this) || this }; diff --git a/tests/baselines/reference/superCallOutsideConstructor.js b/tests/baselines/reference/superCallOutsideConstructor.js index e32bfc66050..60e9411d414 100644 --- a/tests/baselines/reference/superCallOutsideConstructor.js +++ b/tests/baselines/reference/superCallOutsideConstructor.js @@ -23,11 +23,16 @@ var d = new D(); //// [superCallOutsideConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } diff --git a/tests/baselines/reference/superCallParameterContextualTyping1.js b/tests/baselines/reference/superCallParameterContextualTyping1.js index d8491b4ee83..cfb0efa9d3d 100644 --- a/tests/baselines/reference/superCallParameterContextualTyping1.js +++ b/tests/baselines/reference/superCallParameterContextualTyping1.js @@ -13,11 +13,16 @@ class B extends A { //// [superCallParameterContextualTyping1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(map) { this.map = map; diff --git a/tests/baselines/reference/superCallParameterContextualTyping2.js b/tests/baselines/reference/superCallParameterContextualTyping2.js index 9868a7db124..f1180347142 100644 --- a/tests/baselines/reference/superCallParameterContextualTyping2.js +++ b/tests/baselines/reference/superCallParameterContextualTyping2.js @@ -12,11 +12,16 @@ class C extends A { } //// [superCallParameterContextualTyping2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(map) { this.map = map; diff --git a/tests/baselines/reference/superCallParameterContextualTyping3.js b/tests/baselines/reference/superCallParameterContextualTyping3.js index 6a43d58c471..c955f210779 100644 --- a/tests/baselines/reference/superCallParameterContextualTyping3.js +++ b/tests/baselines/reference/superCallParameterContextualTyping3.js @@ -32,11 +32,16 @@ class C extends CBase { } //// [superCallParameterContextualTyping3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var CBase = (function () { function CBase(param) { } diff --git a/tests/baselines/reference/superCallWithCommentEmit01.js b/tests/baselines/reference/superCallWithCommentEmit01.js index c7ea3cc8b85..993776f0057 100644 --- a/tests/baselines/reference/superCallWithCommentEmit01.js +++ b/tests/baselines/reference/superCallWithCommentEmit01.js @@ -11,11 +11,16 @@ class B extends A { } //// [superCallWithCommentEmit01.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(text) { this.text = text; diff --git a/tests/baselines/reference/superCallWithMissingBaseClass.js b/tests/baselines/reference/superCallWithMissingBaseClass.js index 16f11088640..71c408f6df8 100644 --- a/tests/baselines/reference/superCallWithMissingBaseClass.js +++ b/tests/baselines/reference/superCallWithMissingBaseClass.js @@ -10,15 +10,20 @@ class Foo extends Bar { } //// [superCallWithMissingBaseClass.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Foo = (function (_super) { __extends(Foo, _super); function Foo() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Foo.prototype.m1 = function () { return _super.prototype.m1.call(this); diff --git a/tests/baselines/reference/superCalls.js b/tests/baselines/reference/superCalls.js index 99a3b78752c..8c1e70e0c9d 100644 --- a/tests/baselines/reference/superCalls.js +++ b/tests/baselines/reference/superCalls.js @@ -31,11 +31,16 @@ class OtherDerived extends OtherBase { //// [superCalls.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(n) { this.x = 43; @@ -64,7 +69,7 @@ var OtherBase = (function () { var OtherDerived = (function (_super) { __extends(OtherDerived, _super); function OtherDerived() { - var _this; + var _this = this; var p = ''; _this = _super.call(this) || this; return _this; diff --git a/tests/baselines/reference/superCallsInConstructor.js b/tests/baselines/reference/superCallsInConstructor.js index 48b79acadf4..b5d653dc34f 100644 --- a/tests/baselines/reference/superCallsInConstructor.js +++ b/tests/baselines/reference/superCallsInConstructor.js @@ -21,11 +21,16 @@ class Derived extends Base { } //// [superCallsInConstructor.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -41,7 +46,7 @@ var Base = (function () { var Derived = (function (_super) { __extends(Derived, _super); function Derived() { - var _this; + var _this = this; with (new C()) { foo(); _this = _super.call(this) || this; diff --git a/tests/baselines/reference/superErrors.js b/tests/baselines/reference/superErrors.js index 19f0d74f677..cf7edc83a63 100644 --- a/tests/baselines/reference/superErrors.js +++ b/tests/baselines/reference/superErrors.js @@ -52,11 +52,16 @@ class RegisteredUser extends User { } //// [superErrors.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function foo() { var _this = this; // super in a non class context diff --git a/tests/baselines/reference/superHasMethodsFromMergedInterface.js b/tests/baselines/reference/superHasMethodsFromMergedInterface.js new file mode 100644 index 00000000000..e7086106210 --- /dev/null +++ b/tests/baselines/reference/superHasMethodsFromMergedInterface.js @@ -0,0 +1,37 @@ +//// [superHasMethodsFromMergedInterface.ts] +class C { m1() { } } +interface C { m2(): void } +class Sub extends C { + m3() { + super.m2(); + } +} + + +//// [superHasMethodsFromMergedInterface.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var C = (function () { + function C() { + } + C.prototype.m1 = function () { }; + return C; +}()); +var Sub = (function (_super) { + __extends(Sub, _super); + function Sub() { + return _super !== null && _super.apply(this, arguments) || this; + } + Sub.prototype.m3 = function () { + _super.prototype.m2.call(this); + }; + return Sub; +}(C)); diff --git a/tests/baselines/reference/superHasMethodsFromMergedInterface.symbols b/tests/baselines/reference/superHasMethodsFromMergedInterface.symbols new file mode 100644 index 00000000000..ec0af8064ed --- /dev/null +++ b/tests/baselines/reference/superHasMethodsFromMergedInterface.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/superHasMethodsFromMergedInterface.ts === +class C { m1() { } } +>C : Symbol(C, Decl(superHasMethodsFromMergedInterface.ts, 0, 0), Decl(superHasMethodsFromMergedInterface.ts, 0, 20)) +>m1 : Symbol(C.m1, Decl(superHasMethodsFromMergedInterface.ts, 0, 9)) + +interface C { m2(): void } +>C : Symbol(C, Decl(superHasMethodsFromMergedInterface.ts, 0, 0), Decl(superHasMethodsFromMergedInterface.ts, 0, 20)) +>m2 : Symbol(C.m2, Decl(superHasMethodsFromMergedInterface.ts, 1, 13)) + +class Sub extends C { +>Sub : Symbol(Sub, Decl(superHasMethodsFromMergedInterface.ts, 1, 26)) +>C : Symbol(C, Decl(superHasMethodsFromMergedInterface.ts, 0, 0), Decl(superHasMethodsFromMergedInterface.ts, 0, 20)) + + m3() { +>m3 : Symbol(Sub.m3, Decl(superHasMethodsFromMergedInterface.ts, 2, 21)) + + super.m2(); +>super.m2 : Symbol(C.m2, Decl(superHasMethodsFromMergedInterface.ts, 1, 13)) +>super : Symbol(C, Decl(superHasMethodsFromMergedInterface.ts, 0, 0), Decl(superHasMethodsFromMergedInterface.ts, 0, 20)) +>m2 : Symbol(C.m2, Decl(superHasMethodsFromMergedInterface.ts, 1, 13)) + } +} + diff --git a/tests/baselines/reference/superHasMethodsFromMergedInterface.types b/tests/baselines/reference/superHasMethodsFromMergedInterface.types new file mode 100644 index 00000000000..7f314d90bed --- /dev/null +++ b/tests/baselines/reference/superHasMethodsFromMergedInterface.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/superHasMethodsFromMergedInterface.ts === +class C { m1() { } } +>C : C +>m1 : () => void + +interface C { m2(): void } +>C : C +>m2 : () => void + +class Sub extends C { +>Sub : Sub +>C : C + + m3() { +>m3 : () => void + + super.m2(); +>super.m2() : void +>super.m2 : () => void +>super : C +>m2 : () => void + } +} + diff --git a/tests/baselines/reference/superInCatchBlock1.js b/tests/baselines/reference/superInCatchBlock1.js index e1fc0f97024..1f7375fe360 100644 --- a/tests/baselines/reference/superInCatchBlock1.js +++ b/tests/baselines/reference/superInCatchBlock1.js @@ -14,11 +14,16 @@ class B extends A { //// [superInCatchBlock1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -28,7 +33,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.m = function () { try { diff --git a/tests/baselines/reference/superInConstructorParam1.js b/tests/baselines/reference/superInConstructorParam1.js index d345bbc8d3a..89f88c43c4a 100644 --- a/tests/baselines/reference/superInConstructorParam1.js +++ b/tests/baselines/reference/superInConstructorParam1.js @@ -11,11 +11,16 @@ class C extends B { } //// [superInConstructorParam1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B() { } @@ -28,7 +33,7 @@ var C = (function (_super) { __extends(C, _super); function C(a) { if (a === void 0) { a = _super.prototype.foo.call(_this); } - var _this; + var _this = this; return _this; } return C; diff --git a/tests/baselines/reference/superInLambdas.js b/tests/baselines/reference/superInLambdas.js index 73ca53c3b5c..83dad0b3251 100644 --- a/tests/baselines/reference/superInLambdas.js +++ b/tests/baselines/reference/superInLambdas.js @@ -68,11 +68,16 @@ class RegisteredUser4 extends User { } //// [superInLambdas.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var User = (function () { function User() { this.name = "Bob"; diff --git a/tests/baselines/reference/superInObjectLiterals_ES5.js b/tests/baselines/reference/superInObjectLiterals_ES5.js index 5bc2b64fe36..81d8c09da0d 100644 --- a/tests/baselines/reference/superInObjectLiterals_ES5.js +++ b/tests/baselines/reference/superInObjectLiterals_ES5.js @@ -60,11 +60,16 @@ class B extends A { } //// [superInObjectLiterals_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var _this = this; var obj = { __proto__: { @@ -100,7 +105,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.f = function () { var _this = this; diff --git a/tests/baselines/reference/superNewCall1.js b/tests/baselines/reference/superNewCall1.js index 30b07308bb2..a7a94deb6dc 100644 --- a/tests/baselines/reference/superNewCall1.js +++ b/tests/baselines/reference/superNewCall1.js @@ -13,11 +13,16 @@ class B extends A { } //// [superNewCall1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(map) { this.map = map; @@ -27,7 +32,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - var _this; + var _this = this; new _super.prototype(function (value) { return String(value); }); return _this; } diff --git a/tests/baselines/reference/superPropertyAccess.js b/tests/baselines/reference/superPropertyAccess.js index 7b5823e598b..342e39b9885 100644 --- a/tests/baselines/reference/superPropertyAccess.js +++ b/tests/baselines/reference/superPropertyAccess.js @@ -37,11 +37,16 @@ class MyDerived extends MyBase { } //// [superPropertyAccess.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var MyBase = (function () { function MyBase() { this.m2 = function () { }; @@ -61,7 +66,7 @@ var MyBase = (function () { var MyDerived = (function (_super) { __extends(MyDerived, _super); function MyDerived() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } MyDerived.prototype.foo = function () { _super.prototype.m1.call(this, "hi"); // Should be allowed, method on base prototype diff --git a/tests/baselines/reference/superPropertyAccess1.js b/tests/baselines/reference/superPropertyAccess1.js index 0b1e4fc280f..8779dd7069b 100644 --- a/tests/baselines/reference/superPropertyAccess1.js +++ b/tests/baselines/reference/superPropertyAccess1.js @@ -28,11 +28,16 @@ class D extends C { } //// [superPropertyAccess1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } diff --git a/tests/baselines/reference/superPropertyAccess2.js b/tests/baselines/reference/superPropertyAccess2.js index 7c72ad5d1bb..a6fb7c95b0c 100644 --- a/tests/baselines/reference/superPropertyAccess2.js +++ b/tests/baselines/reference/superPropertyAccess2.js @@ -28,11 +28,16 @@ class D extends C { } //// [superPropertyAccess2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } diff --git a/tests/baselines/reference/superPropertyAccessInComputedPropertiesOfNestedType_ES5.js b/tests/baselines/reference/superPropertyAccessInComputedPropertiesOfNestedType_ES5.js index 956bce4ef2e..cf256fa91ec 100644 --- a/tests/baselines/reference/superPropertyAccessInComputedPropertiesOfNestedType_ES5.js +++ b/tests/baselines/reference/superPropertyAccessInComputedPropertiesOfNestedType_ES5.js @@ -15,11 +15,16 @@ class B extends A { } //// [superPropertyAccessInComputedPropertiesOfNestedType_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A() { } @@ -29,7 +34,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } B.prototype.foo = function () { return 2; }; B.prototype.bar = function () { diff --git a/tests/baselines/reference/superPropertyAccessInSuperCall01.js b/tests/baselines/reference/superPropertyAccessInSuperCall01.js index de96b2bbc5e..d5800323de2 100644 --- a/tests/baselines/reference/superPropertyAccessInSuperCall01.js +++ b/tests/baselines/reference/superPropertyAccessInSuperCall01.js @@ -12,11 +12,16 @@ class B extends A { } //// [superPropertyAccessInSuperCall01.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var A = (function () { function A(f) { } diff --git a/tests/baselines/reference/superPropertyAccessNoError.js b/tests/baselines/reference/superPropertyAccessNoError.js index 88a5da8b8fb..d2e3d7aad41 100644 --- a/tests/baselines/reference/superPropertyAccessNoError.js +++ b/tests/baselines/reference/superPropertyAccessNoError.js @@ -77,11 +77,16 @@ instance.returnThis().fn(); //super.publicInstanceMemberFunction in lambda in member function //super.publicStaticMemberFunction in static member function of derived class //super.publicStaticMemberFunction in static member accessor(get and set) of derived class -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var SomeBaseClass = (function () { function SomeBaseClass() { } diff --git a/tests/baselines/reference/superPropertyAccess_ES5.js b/tests/baselines/reference/superPropertyAccess_ES5.js index 45c32076be9..1b74519464a 100644 --- a/tests/baselines/reference/superPropertyAccess_ES5.js +++ b/tests/baselines/reference/superPropertyAccess_ES5.js @@ -30,11 +30,16 @@ class B extends A { } //// [superPropertyAccess_ES5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var MyBase = (function () { function MyBase() { } @@ -72,7 +77,7 @@ var A = (function () { var B = (function (_super) { __extends(B, _super); function B() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(B.prototype, "property", { set: function (value) { diff --git a/tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.js b/tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.js index 2387e483c66..eb698f1ae7e 100644 --- a/tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.js +++ b/tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.js @@ -16,11 +16,16 @@ class C2 extends B { } //// [superPropertyInConstructorBeforeSuperCall.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var B = (function () { function B(x) { } @@ -30,7 +35,7 @@ var B = (function () { var C1 = (function (_super) { __extends(C1, _super); function C1() { - var _this; + var _this = this; _super.prototype.x.call(_this); _this = _super.call(this) || this; return _this; diff --git a/tests/baselines/reference/superSymbolIndexedAccess5.js b/tests/baselines/reference/superSymbolIndexedAccess5.js index dd37deb5af3..5820c56504d 100644 --- a/tests/baselines/reference/superSymbolIndexedAccess5.js +++ b/tests/baselines/reference/superSymbolIndexedAccess5.js @@ -14,11 +14,16 @@ class Bar extends Foo { } //// [superSymbolIndexedAccess5.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var symbol; var Foo = (function () { function Foo() { @@ -31,7 +36,7 @@ var Foo = (function () { var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Bar.prototype[symbol] = function () { return _super.prototype[symbol].call(this); diff --git a/tests/baselines/reference/superSymbolIndexedAccess6.js b/tests/baselines/reference/superSymbolIndexedAccess6.js index 8c8534b428a..45984298202 100644 --- a/tests/baselines/reference/superSymbolIndexedAccess6.js +++ b/tests/baselines/reference/superSymbolIndexedAccess6.js @@ -14,11 +14,16 @@ class Bar extends Foo { } //// [superSymbolIndexedAccess6.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var symbol; var Foo = (function () { function Foo() { @@ -31,7 +36,7 @@ var Foo = (function () { var Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Bar[symbol] = function () { return _super[symbol].call(this); diff --git a/tests/baselines/reference/superWithGenericSpecialization.js b/tests/baselines/reference/superWithGenericSpecialization.js index a0381d0b944..6f3cee935ef 100644 --- a/tests/baselines/reference/superWithGenericSpecialization.js +++ b/tests/baselines/reference/superWithGenericSpecialization.js @@ -15,11 +15,16 @@ var r: string = d.x; var r2: number = d.y; //// [superWithGenericSpecialization.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } diff --git a/tests/baselines/reference/superWithGenerics.js b/tests/baselines/reference/superWithGenerics.js index 803f229bd4b..a66656832f4 100644 --- a/tests/baselines/reference/superWithGenerics.js +++ b/tests/baselines/reference/superWithGenerics.js @@ -12,11 +12,16 @@ class D extends B { //// [superWithGenerics.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var D = (function (_super) { __extends(D, _super); function D() { diff --git a/tests/baselines/reference/superWithTypeArgument.js b/tests/baselines/reference/superWithTypeArgument.js index a1c04975404..34cb3137ee8 100644 --- a/tests/baselines/reference/superWithTypeArgument.js +++ b/tests/baselines/reference/superWithTypeArgument.js @@ -10,11 +10,16 @@ class D extends C { } //// [superWithTypeArgument.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -23,7 +28,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this; + var _this = this; _super.prototype..call(_this); return _this; } diff --git a/tests/baselines/reference/superWithTypeArgument2.js b/tests/baselines/reference/superWithTypeArgument2.js index 42a0e46d4c0..e382f1923c9 100644 --- a/tests/baselines/reference/superWithTypeArgument2.js +++ b/tests/baselines/reference/superWithTypeArgument2.js @@ -10,11 +10,16 @@ class D extends C { } //// [superWithTypeArgument2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -23,7 +28,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D(x) { - var _this; + var _this = this; _super.prototype..call(_this, x); return _this; } diff --git a/tests/baselines/reference/superWithTypeArgument3.js b/tests/baselines/reference/superWithTypeArgument3.js index 803e5c264c2..d5c61d54fb6 100644 --- a/tests/baselines/reference/superWithTypeArgument3.js +++ b/tests/baselines/reference/superWithTypeArgument3.js @@ -14,11 +14,16 @@ class D extends C { } //// [superWithTypeArgument3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var C = (function () { function C() { } @@ -28,7 +33,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - var _this; + var _this = this; _super.prototype..call(_this); return _this; } diff --git a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js index d6f8e36c526..140f8258669 100644 --- a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js +++ b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js @@ -28,11 +28,16 @@ class SuperObjectTest extends F { //// [super_inside-object-literal-getters-and-setters.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var ObjectLiteral; (function (ObjectLiteral) { var ThisInObjectLiteral = { @@ -57,7 +62,7 @@ var F = (function () { var SuperObjectTest = (function (_super) { __extends(SuperObjectTest, _super); function SuperObjectTest() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } SuperObjectTest.prototype.testing = function () { var test = { diff --git a/tests/baselines/reference/switchStatements.js b/tests/baselines/reference/switchStatements.js index 2e1aecc7288..6bce62c108b 100644 --- a/tests/baselines/reference/switchStatements.js +++ b/tests/baselines/reference/switchStatements.js @@ -56,11 +56,16 @@ switch (((x: T) => '')(1)) { } //// [switchStatements.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var M; (function (M) { function fn(x) { @@ -98,7 +103,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); diff --git a/tests/baselines/reference/symbolProperty47.errors.txt b/tests/baselines/reference/symbolProperty47.errors.txt index 2e15085eb24..143d2405d0b 100644 --- a/tests/baselines/reference/symbolProperty47.errors.txt +++ b/tests/baselines/reference/symbolProperty47.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/Symbols/symbolProperty47.ts(3,16): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/conformance/es6/Symbols/symbolProperty47.ts(3,9): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/conformance/es6/Symbols/symbolProperty47.ts(11,1): error TS2322: Type '""' is not assignable to type 'number'. @@ -6,7 +6,7 @@ tests/cases/conformance/es6/Symbols/symbolProperty47.ts(11,1): error TS2322: Typ class C { get [Symbol.hasInstance]() { return ""; - ~~ + ~~~~~~~~~~ !!! error TS2322: Type '""' is not assignable to type 'number'. } // Should take a string diff --git a/tests/baselines/reference/symbolType17.types b/tests/baselines/reference/symbolType17.types index c186f915cd0..6ba36d335a7 100644 --- a/tests/baselines/reference/symbolType17.types +++ b/tests/baselines/reference/symbolType17.types @@ -12,7 +12,7 @@ x; if (typeof x === "symbol") { >typeof x === "symbol" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : symbol | Foo >"symbol" : "symbol" diff --git a/tests/baselines/reference/symbolType18.types b/tests/baselines/reference/symbolType18.types index 8f0012f4f11..9c58320ed3b 100644 --- a/tests/baselines/reference/symbolType18.types +++ b/tests/baselines/reference/symbolType18.types @@ -12,7 +12,7 @@ x; if (typeof x === "object") { >typeof x === "object" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : symbol | Foo >"object" : "object" diff --git a/tests/baselines/reference/symbolType19.types b/tests/baselines/reference/symbolType19.types index 18daa27fd00..66bd80b33d8 100644 --- a/tests/baselines/reference/symbolType19.types +++ b/tests/baselines/reference/symbolType19.types @@ -11,7 +11,7 @@ x; if (typeof x === "number") { >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : symbol | E >"number" : "number" diff --git a/tests/baselines/reference/systemModuleWithSuperClass.js b/tests/baselines/reference/systemModuleWithSuperClass.js index 78c09355fa0..8ac8770d8b1 100644 --- a/tests/baselines/reference/systemModuleWithSuperClass.js +++ b/tests/baselines/reference/systemModuleWithSuperClass.js @@ -32,11 +32,16 @@ System.register([], function (exports_1, context_1) { //// [bar.js] System.register(["./foo"], function (exports_1, context_1) { "use strict"; - 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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); var __moduleName = context_1 && context_1.id; var foo_1, Bar; return { @@ -49,7 +54,7 @@ System.register(["./foo"], function (exports_1, context_1) { Bar = (function (_super) { __extends(Bar, _super); function Bar() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Bar; }(foo_1.Foo)); diff --git a/tests/baselines/reference/targetTypeBaseCalls.js b/tests/baselines/reference/targetTypeBaseCalls.js index cac93023a00..70e14fd521f 100644 --- a/tests/baselines/reference/targetTypeBaseCalls.js +++ b/tests/baselines/reference/targetTypeBaseCalls.js @@ -19,11 +19,16 @@ class Bar extends Foo { constructor() { super(function(s) { s = 5 }) } } // err //// [targetTypeBaseCalls.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); function foo(x) { } var Foo = (function () { function Foo(x) { diff --git a/tests/baselines/reference/targetTypeVoidFunc.errors.txt b/tests/baselines/reference/targetTypeVoidFunc.errors.txt index d47f811c2ed..6c0efe288bd 100644 --- a/tests/baselines/reference/targetTypeVoidFunc.errors.txt +++ b/tests/baselines/reference/targetTypeVoidFunc.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/targetTypeVoidFunc.ts(2,12): error TS2322: Type '() => void' is not assignable to type 'new () => number'. +tests/cases/compiler/targetTypeVoidFunc.ts(2,5): error TS2322: Type '() => void' is not assignable to type 'new () => number'. Type '() => void' provides no match for the signature 'new (): number' ==== tests/cases/compiler/targetTypeVoidFunc.ts (1 errors) ==== function f1(): { new (): number; } { return function () { return; } - ~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '() => void' is not assignable to type 'new () => number'. !!! error TS2322: Type '() => void' provides no match for the signature 'new (): number' }; diff --git a/tests/baselines/reference/templateStringInTypeOf.types b/tests/baselines/reference/templateStringInTypeOf.types index 0d7d26a82b2..5de62164a70 100644 --- a/tests/baselines/reference/templateStringInTypeOf.types +++ b/tests/baselines/reference/templateStringInTypeOf.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/templates/templateStringInTypeOf.ts === var x = typeof `abc${ 123 }def`; ->x : string ->typeof `abc${ 123 }def` : string +>x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof `abc${ 123 }def` : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >`abc${ 123 }def` : string >123 : 123 diff --git a/tests/baselines/reference/templateStringInTypeOfES6.types b/tests/baselines/reference/templateStringInTypeOfES6.types index ad142d13fe5..cc035a25501 100644 --- a/tests/baselines/reference/templateStringInTypeOfES6.types +++ b/tests/baselines/reference/templateStringInTypeOfES6.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/templates/templateStringInTypeOfES6.ts === var x = typeof `abc${ 123 }def`; ->x : string ->typeof `abc${ 123 }def` : string +>x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof `abc${ 123 }def` : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >`abc${ 123 }def` : string >123 : 123 diff --git a/tests/baselines/reference/templateStringInYieldKeyword.errors.txt b/tests/baselines/reference/templateStringInYieldKeyword.errors.txt deleted file mode 100644 index 578c24e7ce9..00000000000 --- a/tests/baselines/reference/templateStringInYieldKeyword.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - - -==== tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts (1 errors) ==== - function* gen() { - ~ -!!! error TS1220: Generators are only available when targeting ECMAScript 2015 or higher. - // Once this is supported, the inner expression does not need to be parenthesized. - var x = yield `abc${ x }def`; - } - \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInYieldKeyword.js b/tests/baselines/reference/templateStringInYieldKeyword.js index e23eaa17c9c..aaab38c194f 100644 --- a/tests/baselines/reference/templateStringInYieldKeyword.js +++ b/tests/baselines/reference/templateStringInYieldKeyword.js @@ -8,5 +8,5 @@ function* gen() { //// [templateStringInYieldKeyword.js] function* gen() { // Once this is supported, the inner expression does not need to be parenthesized. - var x = yield "abc" + x + "def"; + var x = yield `abc${x}def`; } diff --git a/tests/baselines/reference/templateStringInYieldKeyword.symbols b/tests/baselines/reference/templateStringInYieldKeyword.symbols new file mode 100644 index 00000000000..3e8e63d2954 --- /dev/null +++ b/tests/baselines/reference/templateStringInYieldKeyword.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts === +function* gen() { +>gen : Symbol(gen, Decl(templateStringInYieldKeyword.ts, 0, 0)) + + // Once this is supported, the inner expression does not need to be parenthesized. + var x = yield `abc${ x }def`; +>x : Symbol(x, Decl(templateStringInYieldKeyword.ts, 2, 7)) +>x : Symbol(x, Decl(templateStringInYieldKeyword.ts, 2, 7)) +} + diff --git a/tests/baselines/reference/templateStringInYieldKeyword.types b/tests/baselines/reference/templateStringInYieldKeyword.types new file mode 100644 index 00000000000..3eff79cf796 --- /dev/null +++ b/tests/baselines/reference/templateStringInYieldKeyword.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts === +function* gen() { +>gen : () => IterableIterator + + // Once this is supported, the inner expression does not need to be parenthesized. + var x = yield `abc${ x }def`; +>x : any +>yield `abc${ x }def` : any +>`abc${ x }def` : string +>x : any +} + diff --git a/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperator.types b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperator.types index 48330140ad3..a7811bd03bd 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperator.types +++ b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperator.types @@ -2,6 +2,6 @@ var x = `abc${ typeof "hi" }def`; >x : string >`abc${ typeof "hi" }def` : string ->typeof "hi" : string +>typeof "hi" : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >"hi" : "hi" diff --git a/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperatorES6.types b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperatorES6.types index 3d7eba45c19..27e593bf4b3 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperatorES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperatorES6.types @@ -2,6 +2,6 @@ var x = `abc${ typeof "hi" }def`; >x : string >`abc${ typeof "hi" }def` : string ->typeof "hi" : string +>typeof "hi" : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >"hi" : "hi" diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt b/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt index 28f33943732..ce0d781d824 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt @@ -1,6 +1,8 @@ +error TS2318: Cannot find global type 'IterableIterator'. tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(1,15): error TS1005: '(' expected. +!!! error TS2318: Cannot find global type 'IterableIterator'. ==== tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts (1 errors) ==== function* gen { ~ diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.js b/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.js index 8230f0ec8f1..4192fc6fbe2 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.js +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.js @@ -6,7 +6,43 @@ function* gen { //// [templateStringWithEmbeddedYieldKeyword.js] -function* gen() { - // Once this is supported, yield *must* be parenthesized. - var x = "abc" + (yield 10) + "def"; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +function gen() { + var x, _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + _a = "abc"; + return [4 /*yield*/, 10]; + case 1: + x = _a + (_b.sent()) + "def"; + return [2 /*return*/]; + } + }); } diff --git a/tests/baselines/reference/thisInInvalidContexts.js b/tests/baselines/reference/thisInInvalidContexts.js index 7f299fd7e10..25350fb78cf 100644 --- a/tests/baselines/reference/thisInInvalidContexts.js +++ b/tests/baselines/reference/thisInInvalidContexts.js @@ -49,11 +49,16 @@ enum SomeEnum { //// [thisInInvalidContexts.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); //'this' in static member initializer var ErrClass1 = (function () { function ErrClass1() { @@ -98,7 +103,7 @@ genericFunc(undefined); // Should be an error var ErrClass3 = (function (_super) { __extends(ErrClass3, _super); function ErrClass3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ErrClass3; }(this)); diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.js b/tests/baselines/reference/thisInInvalidContextsExternalModule.js index 65a1ef1eee9..070d5597fcc 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.js +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.js @@ -50,11 +50,16 @@ export = this; // Should be an error //// [thisInInvalidContextsExternalModule.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); //'this' in static member initializer var ErrClass1 = (function () { function ErrClass1() { @@ -99,7 +104,7 @@ genericFunc(undefined); // Should be an error var ErrClass3 = (function (_super) { __extends(ErrClass3, _super); function ErrClass3() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return ErrClass3; }(this)); diff --git a/tests/baselines/reference/thisInSuperCall.js b/tests/baselines/reference/thisInSuperCall.js index 1c1f11ffbc8..e28588b2142 100644 --- a/tests/baselines/reference/thisInSuperCall.js +++ b/tests/baselines/reference/thisInSuperCall.js @@ -23,11 +23,16 @@ class Foo3 extends Base { } //// [thisInSuperCall.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(x) { } diff --git a/tests/baselines/reference/thisInSuperCall1.js b/tests/baselines/reference/thisInSuperCall1.js index e3eea1fb91d..c975c10927e 100644 --- a/tests/baselines/reference/thisInSuperCall1.js +++ b/tests/baselines/reference/thisInSuperCall1.js @@ -11,11 +11,16 @@ class Foo extends Base { //// [thisInSuperCall1.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(a) { } diff --git a/tests/baselines/reference/thisInSuperCall2.js b/tests/baselines/reference/thisInSuperCall2.js index 6288082ed64..7112f7b21d1 100644 --- a/tests/baselines/reference/thisInSuperCall2.js +++ b/tests/baselines/reference/thisInSuperCall2.js @@ -20,11 +20,16 @@ class Foo2 extends Base { //// [thisInSuperCall2.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(a) { } diff --git a/tests/baselines/reference/thisInSuperCall3.js b/tests/baselines/reference/thisInSuperCall3.js index 6a72f17248f..2e07d294843 100644 --- a/tests/baselines/reference/thisInSuperCall3.js +++ b/tests/baselines/reference/thisInSuperCall3.js @@ -13,11 +13,16 @@ class Foo extends Base { //// [thisInSuperCall3.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var Base = (function () { function Base(a) { } diff --git a/tests/baselines/reference/thisTypeInFunctions.js b/tests/baselines/reference/thisTypeInFunctions.js index 6400f410a09..68513c151d9 100644 --- a/tests/baselines/reference/thisTypeInFunctions.js +++ b/tests/baselines/reference/thisTypeInFunctions.js @@ -195,11 +195,16 @@ function missingTypeIsImplicitAny(this, a: number) { return this.anything + a; } //// [thisTypeInFunctions.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var _this = this; // body checking var B = (function () { @@ -227,7 +232,7 @@ var C = (function () { var D = (function (_super) { __extends(D, _super); function D() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return D; }(C)); @@ -336,7 +341,7 @@ var Base1 = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived1; }(Base1)); @@ -350,7 +355,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.js b/tests/baselines/reference/thisTypeInFunctionsNegative.js index 446bc15e6d9..6cf6f477827 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.js +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.js @@ -177,11 +177,16 @@ c.explicitProperty = (this, m) => m + this.n; //// [thisTypeInFunctionsNegative.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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var _this = this; var C = (function () { function C() { @@ -296,7 +301,7 @@ var Base1 = (function () { var Derived1 = (function (_super) { __extends(Derived1, _super); function Derived1() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived1; }(Base1)); @@ -310,7 +315,7 @@ var Base2 = (function () { var Derived2 = (function (_super) { __extends(Derived2, _super); function Derived2() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Derived2; }(Base2)); diff --git a/tests/baselines/reference/throwStatements.types b/tests/baselines/reference/throwStatements.types index 19b8988ed47..3c8fd64ee39 100644 --- a/tests/baselines/reference/throwStatements.types +++ b/tests/baselines/reference/throwStatements.types @@ -174,7 +174,7 @@ throw aModule; >aModule : typeof M throw typeof M; ->typeof M : string +>typeof M : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >M : typeof M var aClassInModule = new M.A(); diff --git a/tests/baselines/reference/topLevelAmbientModule.js b/tests/baselines/reference/topLevelAmbientModule.js index da5885fafab..3e162170c87 100644 --- a/tests/baselines/reference/topLevelAmbientModule.js +++ b/tests/baselines/reference/topLevelAmbientModule.js @@ -14,6 +14,7 @@ var z = foo.x + 10; //// [foo_0.js] //// [foo_1.js] "use strict"; +exports.__esModule = true; /// var foo = require("foo"); var z = foo.x + 10; diff --git a/tests/baselines/reference/topLevelExports.js b/tests/baselines/reference/topLevelExports.js index bf274fcf558..5f58c44d2f2 100644 --- a/tests/baselines/reference/topLevelExports.js +++ b/tests/baselines/reference/topLevelExports.js @@ -8,6 +8,7 @@ void log(foo).toString(); //// [topLevelExports.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; exports.foo = 3; function log(n) { return n; } void log(exports.foo).toString(); diff --git a/tests/baselines/reference/topLevelFileModule.js b/tests/baselines/reference/topLevelFileModule.js index c893a9b4675..8ff74cc89f4 100644 --- a/tests/baselines/reference/topLevelFileModule.js +++ b/tests/baselines/reference/topLevelFileModule.js @@ -14,8 +14,10 @@ var z = foo.x + fum.y; //// [foo_0.js] "use strict"; +exports.__esModule = true; //// [foo_1.js] "use strict"; +exports.__esModule = true; var foo = require("./vs/foo_0"); var fum = require("./vs/fum"); var z = foo.x + fum.y; diff --git a/tests/baselines/reference/topLevelFileModuleMissing.js b/tests/baselines/reference/topLevelFileModuleMissing.js index edd090d49cc..37d9ac5b150 100644 --- a/tests/baselines/reference/topLevelFileModuleMissing.js +++ b/tests/baselines/reference/topLevelFileModuleMissing.js @@ -10,5 +10,6 @@ var z = foo.x + 10; //// [foo_1.js] "use strict"; +exports.__esModule = true; var foo = require("vs/foo"); var z = foo.x + 10; diff --git a/tests/baselines/reference/topLevelLambda4.js b/tests/baselines/reference/topLevelLambda4.js index 81d3c4a1e4f..5ccfb91bec7 100644 --- a/tests/baselines/reference/topLevelLambda4.js +++ b/tests/baselines/reference/topLevelLambda4.js @@ -5,5 +5,6 @@ export var x = () => this.window; define(["require", "exports"], function (require, exports) { "use strict"; var _this = this; + exports.__esModule = true; exports.x = function () { return _this.window; }; }); diff --git a/tests/baselines/reference/topLevelModuleDeclarationAndFile.js b/tests/baselines/reference/topLevelModuleDeclarationAndFile.js index cb329014412..8f4ecb37d31 100644 --- a/tests/baselines/reference/topLevelModuleDeclarationAndFile.js +++ b/tests/baselines/reference/topLevelModuleDeclarationAndFile.js @@ -19,6 +19,7 @@ var z2 = foo.y() + 10; // Should resolve //// [foo_1.js] //// [foo_2.js] "use strict"; +exports.__esModule = true; /// var foo = require("vs/foo_0"); var z1 = foo.x + 10; // Should error, as declaration should win diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.substitution.js b/tests/baselines/reference/transformApi/transformsCorrectly.substitution.js new file mode 100644 index 00000000000..40686768759 --- /dev/null +++ b/tests/baselines/reference/transformApi/transformsCorrectly.substitution.js @@ -0,0 +1 @@ +var a = void 0 /*undefined*/; diff --git a/tests/baselines/reference/transformNestedGeneratorsWithTry.js b/tests/baselines/reference/transformNestedGeneratorsWithTry.js index 7c3597ddc4b..28f405e47b9 100644 --- a/tests/baselines/reference/transformNestedGeneratorsWithTry.js +++ b/tests/baselines/reference/transformNestedGeneratorsWithTry.js @@ -33,8 +33,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t; - return { next: verb(0), "throw": verb(1), "return": verb(2) }; + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); @@ -59,6 +59,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; +Object.defineProperty(exports, "__esModule", { value: true }); // https://github.com/Microsoft/TypeScript/issues/11177 var Bluebird = require("bluebird"); function a() { diff --git a/tests/baselines/reference/transformNestedGeneratorsWithTry.symbols b/tests/baselines/reference/transformNestedGeneratorsWithTry.symbols index e966202c277..88f62aa6273 100644 --- a/tests/baselines/reference/transformNestedGeneratorsWithTry.symbols +++ b/tests/baselines/reference/transformNestedGeneratorsWithTry.symbols @@ -36,12 +36,12 @@ declare module "bluebird" { type Bluebird = Promise; >Bluebird : Symbol(Bluebird, Decl(bluebird.d.ts, 0, 27), Decl(bluebird.d.ts, 2, 9)) >T : Symbol(T, Decl(bluebird.d.ts, 1, 18)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >T : Symbol(T, Decl(bluebird.d.ts, 1, 18)) const Bluebird: typeof Promise; >Bluebird : Symbol(Bluebird, Decl(bluebird.d.ts, 0, 27), Decl(bluebird.d.ts, 2, 9)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) export = Bluebird; >Bluebird : Symbol(Bluebird, Decl(bluebird.d.ts, 0, 27), Decl(bluebird.d.ts, 2, 9)) diff --git a/tests/baselines/reference/transformsElideNullUndefinedType.types b/tests/baselines/reference/transformsElideNullUndefinedType.types index 7f48d8a00e9..ffc26ddaa60 100644 --- a/tests/baselines/reference/transformsElideNullUndefinedType.types +++ b/tests/baselines/reference/transformsElideNullUndefinedType.types @@ -140,14 +140,14 @@ class C5 { } var C6 = class { constructor(p12: null) { } } ->C6 : typeof (Anonymous class) ->class { constructor(p12: null) { } } : typeof (Anonymous class) +>C6 : typeof C6 +>class { constructor(p12: null) { } } : typeof C6 >p12 : null >null : null var C7 = class { constructor(p13: undefined) { } } ->C7 : typeof (Anonymous class) ->class { constructor(p13: undefined) { } } : typeof (Anonymous class) +>C7 : typeof C7 +>class { constructor(p13: undefined) { } } : typeof C7 >p13 : undefined declare function fn(); diff --git a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js index f1e36ae9b15..cd4ce3c862e 100644 --- a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js +++ b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js @@ -8,6 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +Object.defineProperty(exports, "__esModule", { value: true }); var ng = require("angular2/core"); var MyClass1 = (function () { function MyClass1(_elementRef) { diff --git a/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js b/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js index 61a703e13bb..4571caffa31 100644 --- a/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js +++ b/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js b/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js index 9d108d63313..4d133b7655c 100644 --- a/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js +++ b/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; a; b; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates module output.js b/tests/baselines/reference/transpile/Generates module output.js index 9eadd1f2717..2c7bb7add09 100644 --- a/tests/baselines/reference/transpile/Generates module output.js +++ b/tests/baselines/reference/transpile/Generates module output.js @@ -1,5 +1,6 @@ define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var x = 0; }); //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js b/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js index 88d98628eee..04ba1d12e5e 100644 --- a/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js +++ b/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js @@ -1,4 +1,5 @@ "use strict"; +exports.__esModule = true; /// var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates no diagnostics for missing module imports.js b/tests/baselines/reference/transpile/Generates no diagnostics for missing module imports.js index 1ceb1bcd146..e9493d9d591 100644 --- a/tests/baselines/reference/transpile/Generates no diagnostics for missing module imports.js +++ b/tests/baselines/reference/transpile/Generates no diagnostics for missing module imports.js @@ -1,2 +1,3 @@ "use strict"; +exports.__esModule = true; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js b/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js index 61a703e13bb..4571caffa31 100644 --- a/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js +++ b/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/No extra errors for file without extension.js b/tests/baselines/reference/transpile/No extra errors for file without extension.js index 61a703e13bb..4571caffa31 100644 --- a/tests/baselines/reference/transpile/No extra errors for file without extension.js +++ b/tests/baselines/reference/transpile/No extra errors for file without extension.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Rename dependencies - AMD.js b/tests/baselines/reference/transpile/Rename dependencies - AMD.js index a0dd948c9fc..c5ffb86a1aa 100644 --- a/tests/baselines/reference/transpile/Rename dependencies - AMD.js +++ b/tests/baselines/reference/transpile/Rename dependencies - AMD.js @@ -1,5 +1,6 @@ define(["require", "exports", "SomeOtherName"], function (require, exports, SomeName_1) { "use strict"; + exports.__esModule = true; use(SomeName_1.foo); }); //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Rename dependencies - UMD.js b/tests/baselines/reference/transpile/Rename dependencies - UMD.js index c2b337076ba..0ecfbce2397 100644 --- a/tests/baselines/reference/transpile/Rename dependencies - UMD.js +++ b/tests/baselines/reference/transpile/Rename dependencies - UMD.js @@ -8,6 +8,7 @@ } })(function (require, exports) { "use strict"; + exports.__esModule = true; var SomeName_1 = require("SomeOtherName"); use(SomeName_1.foo); }); diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js index 1ceb1bcd146..e9493d9d591 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js +++ b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js @@ -1,2 +1,3 @@ "use strict"; +exports.__esModule = true; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js index 1ceb1bcd146..e9493d9d591 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js +++ b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js @@ -1,2 +1,3 @@ "use strict"; +exports.__esModule = true; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Support options with lib values.js b/tests/baselines/reference/transpile/Support options with lib values.js index 36c68f08b9f..72e077de381 100644 --- a/tests/baselines/reference/transpile/Support options with lib values.js +++ b/tests/baselines/reference/transpile/Support options with lib values.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; var a = 10; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Support options with types values.js b/tests/baselines/reference/transpile/Support options with types values.js index 36c68f08b9f..72e077de381 100644 --- a/tests/baselines/reference/transpile/Support options with types values.js +++ b/tests/baselines/reference/transpile/Support options with types values.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; var a = 10; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports backslashes in file name.js b/tests/baselines/reference/transpile/Supports backslashes in file name.js index 942449753b0..8ef38d2b617 100644 --- a/tests/baselines/reference/transpile/Supports backslashes in file name.js +++ b/tests/baselines/reference/transpile/Supports backslashes in file name.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; var x; //# sourceMappingURL=b.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowJs.js b/tests/baselines/reference/transpile/Supports setting allowJs.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting allowJs.js +++ b/tests/baselines/reference/transpile/Supports setting allowJs.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js b/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js +++ b/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js b/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js +++ b/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js b/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js +++ b/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting alwaysStrict.js b/tests/baselines/reference/transpile/Supports setting alwaysStrict.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting alwaysStrict.js +++ b/tests/baselines/reference/transpile/Supports setting alwaysStrict.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting baseUrl.js b/tests/baselines/reference/transpile/Supports setting baseUrl.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting baseUrl.js +++ b/tests/baselines/reference/transpile/Supports setting baseUrl.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting charset.js b/tests/baselines/reference/transpile/Supports setting charset.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting charset.js +++ b/tests/baselines/reference/transpile/Supports setting charset.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting declaration.js b/tests/baselines/reference/transpile/Supports setting declaration.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting declaration.js +++ b/tests/baselines/reference/transpile/Supports setting declaration.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting declarationDir.js b/tests/baselines/reference/transpile/Supports setting declarationDir.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting declarationDir.js +++ b/tests/baselines/reference/transpile/Supports setting declarationDir.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting emitBOM.js b/tests/baselines/reference/transpile/Supports setting emitBOM.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting emitBOM.js +++ b/tests/baselines/reference/transpile/Supports setting emitBOM.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js b/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js +++ b/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js b/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js +++ b/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js b/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js +++ b/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting isolatedModules.js b/tests/baselines/reference/transpile/Supports setting isolatedModules.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting isolatedModules.js +++ b/tests/baselines/reference/transpile/Supports setting isolatedModules.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting jsx.js b/tests/baselines/reference/transpile/Supports setting jsx.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting jsx.js +++ b/tests/baselines/reference/transpile/Supports setting jsx.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting jsxFactory.js b/tests/baselines/reference/transpile/Supports setting jsxFactory.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting jsxFactory.js +++ b/tests/baselines/reference/transpile/Supports setting jsxFactory.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting lib.js b/tests/baselines/reference/transpile/Supports setting lib.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting lib.js +++ b/tests/baselines/reference/transpile/Supports setting lib.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting locale.js b/tests/baselines/reference/transpile/Supports setting locale.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting locale.js +++ b/tests/baselines/reference/transpile/Supports setting locale.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting module.js b/tests/baselines/reference/transpile/Supports setting module.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting module.js +++ b/tests/baselines/reference/transpile/Supports setting module.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting moduleResolution.js b/tests/baselines/reference/transpile/Supports setting moduleResolution.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting moduleResolution.js +++ b/tests/baselines/reference/transpile/Supports setting moduleResolution.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting newLine.js b/tests/baselines/reference/transpile/Supports setting newLine.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting newLine.js +++ b/tests/baselines/reference/transpile/Supports setting newLine.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noEmit.js b/tests/baselines/reference/transpile/Supports setting noEmit.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting noEmit.js +++ b/tests/baselines/reference/transpile/Supports setting noEmit.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js b/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js +++ b/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noEmitOnError.js b/tests/baselines/reference/transpile/Supports setting noEmitOnError.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting noEmitOnError.js +++ b/tests/baselines/reference/transpile/Supports setting noEmitOnError.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js b/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js +++ b/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js b/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js +++ b/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitAny.js b/tests/baselines/reference/transpile/Supports setting noImplicitAny.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting noImplicitAny.js +++ b/tests/baselines/reference/transpile/Supports setting noImplicitAny.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js b/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js +++ b/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitThis.js b/tests/baselines/reference/transpile/Supports setting noImplicitThis.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting noImplicitThis.js +++ b/tests/baselines/reference/transpile/Supports setting noImplicitThis.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitUseStrict.js b/tests/baselines/reference/transpile/Supports setting noImplicitUseStrict.js index 8394371f908..8124d51fde3 100644 --- a/tests/baselines/reference/transpile/Supports setting noImplicitUseStrict.js +++ b/tests/baselines/reference/transpile/Supports setting noImplicitUseStrict.js @@ -1,2 +1,3 @@ +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noLib.js b/tests/baselines/reference/transpile/Supports setting noLib.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting noLib.js +++ b/tests/baselines/reference/transpile/Supports setting noLib.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noResolve.js b/tests/baselines/reference/transpile/Supports setting noResolve.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting noResolve.js +++ b/tests/baselines/reference/transpile/Supports setting noResolve.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting out.js b/tests/baselines/reference/transpile/Supports setting out.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting out.js +++ b/tests/baselines/reference/transpile/Supports setting out.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting outDir.js b/tests/baselines/reference/transpile/Supports setting outDir.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting outDir.js +++ b/tests/baselines/reference/transpile/Supports setting outDir.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting outFile.js b/tests/baselines/reference/transpile/Supports setting outFile.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting outFile.js +++ b/tests/baselines/reference/transpile/Supports setting outFile.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting paths.js b/tests/baselines/reference/transpile/Supports setting paths.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting paths.js +++ b/tests/baselines/reference/transpile/Supports setting paths.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js b/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js +++ b/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting reactNamespace.js b/tests/baselines/reference/transpile/Supports setting reactNamespace.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting reactNamespace.js +++ b/tests/baselines/reference/transpile/Supports setting reactNamespace.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting removeComments.js b/tests/baselines/reference/transpile/Supports setting removeComments.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting removeComments.js +++ b/tests/baselines/reference/transpile/Supports setting removeComments.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting rootDir.js b/tests/baselines/reference/transpile/Supports setting rootDir.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting rootDir.js +++ b/tests/baselines/reference/transpile/Supports setting rootDir.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting rootDirs.js b/tests/baselines/reference/transpile/Supports setting rootDirs.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting rootDirs.js +++ b/tests/baselines/reference/transpile/Supports setting rootDirs.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js b/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js +++ b/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting skipLibCheck.js b/tests/baselines/reference/transpile/Supports setting skipLibCheck.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting skipLibCheck.js +++ b/tests/baselines/reference/transpile/Supports setting skipLibCheck.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting strictNullChecks.js b/tests/baselines/reference/transpile/Supports setting strictNullChecks.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting strictNullChecks.js +++ b/tests/baselines/reference/transpile/Supports setting strictNullChecks.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting stripInternal.js b/tests/baselines/reference/transpile/Supports setting stripInternal.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting stripInternal.js +++ b/tests/baselines/reference/transpile/Supports setting stripInternal.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js b/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js +++ b/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js b/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js +++ b/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting typeRoots.js b/tests/baselines/reference/transpile/Supports setting typeRoots.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting typeRoots.js +++ b/tests/baselines/reference/transpile/Supports setting typeRoots.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting types.js b/tests/baselines/reference/transpile/Supports setting types.js index 8d91090453b..f960e73bcb8 100644 --- a/tests/baselines/reference/transpile/Supports setting types.js +++ b/tests/baselines/reference/transpile/Supports setting types.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports urls in file name.js b/tests/baselines/reference/transpile/Supports urls in file name.js index 3923d3c9a41..933981306d2 100644 --- a/tests/baselines/reference/transpile/Supports urls in file name.js +++ b/tests/baselines/reference/transpile/Supports urls in file name.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; var x; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Transpile with emit decorators and emit metadata.js b/tests/baselines/reference/transpile/Transpile with emit decorators and emit metadata.js index b6b17292c12..0b3bbaa8d73 100644 --- a/tests/baselines/reference/transpile/Transpile with emit decorators and emit metadata.js +++ b/tests/baselines/reference/transpile/Transpile with emit decorators and emit metadata.js @@ -1,4 +1,5 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var db_1 = require("./db"); function someDecorator(target) { return target; diff --git a/tests/baselines/reference/transpile/Uses correct newLine character.js b/tests/baselines/reference/transpile/Uses correct newLine character.js index bab9c3c4443..04042012d18 100644 --- a/tests/baselines/reference/transpile/Uses correct newLine character.js +++ b/tests/baselines/reference/transpile/Uses correct newLine character.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/transpile .js files.js b/tests/baselines/reference/transpile/transpile .js files.js index c17099d84ba..b9048bd515d 100644 --- a/tests/baselines/reference/transpile/transpile .js files.js +++ b/tests/baselines/reference/transpile/transpile .js files.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; var a = 10; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js b/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js index baa27ee64ce..2a73615e476 100644 --- a/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js +++ b/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js @@ -1,3 +1,4 @@ "use strict"; +exports.__esModule = true; var x = React.createElement("div", null); //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeErrors.errors.txt b/tests/baselines/reference/tsxAttributeErrors.errors.txt index 4a898969363..50dfd88c527 100644 --- a/tests/baselines/reference/tsxAttributeErrors.errors.txt +++ b/tests/baselines/reference/tsxAttributeErrors.errors.txt @@ -1,7 +1,12 @@ -tests/cases/conformance/jsx/tsxAttributeErrors.tsx(15,6): error TS2322: Type '42' is not assignable to type 'string'. -tests/cases/conformance/jsx/tsxAttributeErrors.tsx(18,6): error TS2322: Type '"foo"' is not assignable to type 'number'. -tests/cases/conformance/jsx/tsxAttributeErrors.tsx(22,6): error TS2606: Property 'text' of JSX spread attribute is not assignable to target property. - Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxAttributeErrors.tsx(15,6): error TS2322: Type '{ text: 42; }' is not assignable to type '{ text?: string; width?: number; }'. + Types of property 'text' are incompatible. + Type '42' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxAttributeErrors.tsx(18,6): error TS2322: Type '{ width: "foo"; }' is not assignable to type '{ text?: string; width?: number; }'. + Types of property 'width' are incompatible. + Type '"foo"' is not assignable to type 'number'. +tests/cases/conformance/jsx/tsxAttributeErrors.tsx(22,6): error TS2322: Type '{ text: number; }' is not assignable to type '{ text?: string; width?: number; }'. + Types of property 'text' are incompatible. + Type 'number' is not assignable to type 'string'. ==== tests/cases/conformance/jsx/tsxAttributeErrors.tsx (3 errors) ==== @@ -21,19 +26,24 @@ tests/cases/conformance/jsx/tsxAttributeErrors.tsx(22,6): error TS2606: Property // Error, number is not assignable to string
; ~~~~~~~~~ -!!! error TS2322: Type '42' is not assignable to type 'string'. +!!! error TS2322: Type '{ text: 42; }' is not assignable to type '{ text?: string; width?: number; }'. +!!! error TS2322: Types of property 'text' are incompatible. +!!! error TS2322: Type '42' is not assignable to type 'string'. // Error, string is not assignable to number
; ~~~~~~~~~~~~~ -!!! error TS2322: Type '"foo"' is not assignable to type 'number'. +!!! error TS2322: Type '{ width: "foo"; }' is not assignable to type '{ text?: string; width?: number; }'. +!!! error TS2322: Types of property 'width' are incompatible. +!!! error TS2322: Type '"foo"' is not assignable to type 'number'. // Error, number is not assignable to string var attribs = { text: 100 };
; ~~~~~~~~~~~~ -!!! error TS2606: Property 'text' of JSX spread attribute is not assignable to target property. -!!! error TS2606: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '{ text: number; }' is not assignable to type '{ text?: string; width?: number; }'. +!!! error TS2322: Types of property 'text' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. // No errors here ; diff --git a/tests/baselines/reference/tsxAttributeResolution1.errors.txt b/tests/baselines/reference/tsxAttributeResolution1.errors.txt index f7fb114f3e0..d064f72f85d 100644 --- a/tests/baselines/reference/tsxAttributeResolution1.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution1.errors.txt @@ -1,10 +1,20 @@ -tests/cases/conformance/jsx/file.tsx(23,8): error TS2322: Type '"0"' is not assignable to type 'number'. -tests/cases/conformance/jsx/file.tsx(24,8): error TS2339: Property 'y' does not exist on type 'Attribs1'. -tests/cases/conformance/jsx/file.tsx(25,8): error TS2339: Property 'y' does not exist on type 'Attribs1'. -tests/cases/conformance/jsx/file.tsx(26,8): error TS2322: Type '"32"' is not assignable to type 'number'. -tests/cases/conformance/jsx/file.tsx(27,8): error TS2339: Property 'var' does not exist on type 'Attribs1'. -tests/cases/conformance/jsx/file.tsx(29,1): error TS2324: Property 'reqd' is missing in type '{ reqd: string; }'. -tests/cases/conformance/jsx/file.tsx(30,8): error TS2322: Type '10' is not assignable to type 'string'. +tests/cases/conformance/jsx/file.tsx(23,8): error TS2322: Type '{ x: "0"; }' is not assignable to type 'Attribs1'. + Types of property 'x' are incompatible. + Type '"0"' is not assignable to type 'number'. +tests/cases/conformance/jsx/file.tsx(24,8): error TS2322: Type '{ y: 0; }' is not assignable to type 'Attribs1'. + Property 'y' does not exist on type 'Attribs1'. +tests/cases/conformance/jsx/file.tsx(25,8): error TS2322: Type '{ y: "foo"; }' is not assignable to type 'Attribs1'. + Property 'y' does not exist on type 'Attribs1'. +tests/cases/conformance/jsx/file.tsx(26,8): error TS2322: Type '{ x: "32"; }' is not assignable to type 'Attribs1'. + Types of property 'x' are incompatible. + Type '"32"' is not assignable to type 'number'. +tests/cases/conformance/jsx/file.tsx(27,8): error TS2322: Type '{ var: "10"; }' is not assignable to type 'Attribs1'. + Property 'var' does not exist on type 'Attribs1'. +tests/cases/conformance/jsx/file.tsx(29,1): error TS2322: Type '{}' is not assignable to type '{ reqd: string; }'. + Property 'reqd' is missing in type '{}'. +tests/cases/conformance/jsx/file.tsx(30,8): error TS2322: Type '{ reqd: 10; }' is not assignable to type '{ reqd: string; }'. + Types of property 'reqd' are incompatible. + Type '10' is not assignable to type 'string'. ==== tests/cases/conformance/jsx/file.tsx (7 errors) ==== @@ -32,26 +42,36 @@ tests/cases/conformance/jsx/file.tsx(30,8): error TS2322: Type '10' is not assig // Errors ; // Error, '0' is not number ~~~~~~~ -!!! error TS2322: Type '"0"' is not assignable to type 'number'. +!!! error TS2322: Type '{ x: "0"; }' is not assignable to type 'Attribs1'. +!!! error TS2322: Types of property 'x' are incompatible. +!!! error TS2322: Type '"0"' is not assignable to type 'number'. ; // Error, no property "y" - ~ -!!! error TS2339: Property 'y' does not exist on type 'Attribs1'. + ~~~~~ +!!! error TS2322: Type '{ y: 0; }' is not assignable to type 'Attribs1'. +!!! error TS2322: Property 'y' does not exist on type 'Attribs1'. ; // Error, no property "y" - ~ -!!! error TS2339: Property 'y' does not exist on type 'Attribs1'. + ~~~~~~~ +!!! error TS2322: Type '{ y: "foo"; }' is not assignable to type 'Attribs1'. +!!! error TS2322: Property 'y' does not exist on type 'Attribs1'. ; // Error, "32" is not number ~~~~~~ -!!! error TS2322: Type '"32"' is not assignable to type 'number'. +!!! error TS2322: Type '{ x: "32"; }' is not assignable to type 'Attribs1'. +!!! error TS2322: Types of property 'x' are incompatible. +!!! error TS2322: Type '"32"' is not assignable to type 'number'. ; // Error, no 'var' property - ~~~ -!!! error TS2339: Property 'var' does not exist on type 'Attribs1'. + ~~~~~~~~ +!!! error TS2322: Type '{ var: "10"; }' is not assignable to type 'Attribs1'. +!!! error TS2322: Property 'var' does not exist on type 'Attribs1'. ; // Error, missing reqd ~~~~~~~~~ -!!! error TS2324: Property 'reqd' is missing in type '{ reqd: string; }'. +!!! error TS2322: Type '{}' is not assignable to type '{ reqd: string; }'. +!!! error TS2322: Property 'reqd' is missing in type '{}'. ; // Error, reqd is not string ~~~~~~~~~ -!!! error TS2322: Type '10' is not assignable to type 'string'. +!!! error TS2322: Type '{ reqd: 10; }' is not assignable to type '{ reqd: string; }'. +!!! error TS2322: Types of property 'reqd' are incompatible. +!!! error TS2322: Type '10' is not assignable to type 'string'. // Should be OK ; diff --git a/tests/baselines/reference/tsxAttributeResolution10.errors.txt b/tests/baselines/reference/tsxAttributeResolution10.errors.txt index 787eb4b5f00..dce068dbb76 100644 --- a/tests/baselines/reference/tsxAttributeResolution10.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution10.errors.txt @@ -1,4 +1,6 @@ -tests/cases/conformance/jsx/file.tsx(11,14): error TS2322: Type '"world"' is not assignable to type 'boolean'. +tests/cases/conformance/jsx/file.tsx(11,14): error TS2322: Type '{ bar: "world"; }' is not assignable to type '{ [s: string]: boolean; }'. + Property 'bar' is incompatible with index signature. + Type '"world"' is not assignable to type 'boolean'. ==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== @@ -25,7 +27,9 @@ tests/cases/conformance/jsx/file.tsx(11,14): error TS2322: Type '"world"' is not // Should be an error ; ~~~~~~~~~~~ -!!! error TS2322: Type '"world"' is not assignable to type 'boolean'. +!!! error TS2322: Type '{ bar: "world"; }' is not assignable to type '{ [s: string]: boolean; }'. +!!! error TS2322: Property 'bar' is incompatible with index signature. +!!! error TS2322: Type '"world"' is not assignable to type 'boolean'. // Should be OK ; diff --git a/tests/baselines/reference/tsxAttributeResolution10.js b/tests/baselines/reference/tsxAttributeResolution10.js index 798bbb4c7af..235cca0be1c 100644 --- a/tests/baselines/reference/tsxAttributeResolution10.js +++ b/tests/baselines/reference/tsxAttributeResolution10.js @@ -34,6 +34,7 @@ export class MyComponent { //// [file.jsx] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var MyComponent = (function () { function MyComponent() { } diff --git a/tests/baselines/reference/tsxAttributeResolution11.errors.txt b/tests/baselines/reference/tsxAttributeResolution11.errors.txt index b043897d50d..a46bf4ba16f 100644 --- a/tests/baselines/reference/tsxAttributeResolution11.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution11.errors.txt @@ -1,4 +1,5 @@ -tests/cases/conformance/jsx/file.tsx(11,22): error TS2339: Property 'bar' does not exist on type 'IntrinsicAttributes & { ref?: string; }'. +tests/cases/conformance/jsx/file.tsx(11,22): error TS2322: Type '{ bar: "world"; }' is not assignable to type 'IntrinsicAttributes & { ref?: string; }'. + Property 'bar' does not exist on type 'IntrinsicAttributes & { ref?: string; }'. ==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== @@ -27,7 +28,8 @@ tests/cases/conformance/jsx/file.tsx(11,22): error TS2339: Property 'bar' does n // Should be an OK var x = ; - ~~~ -!!! error TS2339: Property 'bar' does not exist on type 'IntrinsicAttributes & { ref?: string; }'. + ~~~~~~~~~~~ +!!! error TS2322: Type '{ bar: "world"; }' is not assignable to type 'IntrinsicAttributes & { ref?: string; }'. +!!! error TS2322: Property 'bar' does not exist on type 'IntrinsicAttributes & { ref?: string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution12.errors.txt b/tests/baselines/reference/tsxAttributeResolution12.errors.txt index ecf51a0f3dd..041776814ca 100644 --- a/tests/baselines/reference/tsxAttributeResolution12.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution12.errors.txt @@ -1,5 +1,9 @@ -tests/cases/conformance/jsx/file.tsx(26,10): error TS2324: Property 'reqd' is missing in type 'IntrinsicAttributes & { reqd: any; }'. -tests/cases/conformance/jsx/file.tsx(29,10): error TS2324: Property 'reqd' is missing in type 'IntrinsicAttributes & { reqd: any; }'. +tests/cases/conformance/jsx/file.tsx(26,10): error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & { reqd: any; }'. + Type '{}' is not assignable to type '{ reqd: any; }'. + Property 'reqd' is missing in type '{}'. +tests/cases/conformance/jsx/file.tsx(29,10): error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & { reqd: any; }'. + Type '{}' is not assignable to type '{ reqd: any; }'. + Property 'reqd' is missing in type '{}'. ==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== @@ -44,11 +48,15 @@ tests/cases/conformance/jsx/file.tsx(29,10): error TS2324: Property 'reqd' is mi const T = TestMod.Test; var t1 = ; ~~~~~ -!!! error TS2324: Property 'reqd' is missing in type 'IntrinsicAttributes & { reqd: any; }'. +!!! error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & { reqd: any; }'. +!!! error TS2322: Type '{}' is not assignable to type '{ reqd: any; }'. +!!! error TS2322: Property 'reqd' is missing in type '{}'. // Should error var t2 = ; ~~~~~~~~~~~~~~~~ -!!! error TS2324: Property 'reqd' is missing in type 'IntrinsicAttributes & { reqd: any; }'. +!!! error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & { reqd: any; }'. +!!! error TS2322: Type '{}' is not assignable to type '{ reqd: any; }'. +!!! error TS2322: Property 'reqd' is missing in type '{}'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution14.errors.txt b/tests/baselines/reference/tsxAttributeResolution14.errors.txt index 9f4e00747f1..79b4a55f102 100644 --- a/tests/baselines/reference/tsxAttributeResolution14.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution14.errors.txt @@ -1,5 +1,9 @@ -tests/cases/conformance/jsx/file.tsx(14,28): error TS2322: Type '2' is not assignable to type 'string'. -tests/cases/conformance/jsx/file.tsx(16,28): error TS2322: Type 'true' is not assignable to type 'string | number'. +tests/cases/conformance/jsx/file.tsx(14,28): error TS2322: Type '{ primaryText: 2; }' is not assignable to type 'IProps'. + Types of property 'primaryText' are incompatible. + Type '2' is not assignable to type 'string'. +tests/cases/conformance/jsx/file.tsx(16,28): error TS2322: Type '{ justRandomProp1: true; primaryText: "hello"; }' is not assignable to type 'IProps'. + Property 'justRandomProp1' is incompatible with index signature. + Type 'true' is not assignable to type 'string | number'. ==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== @@ -28,11 +32,15 @@ tests/cases/conformance/jsx/file.tsx(16,28): error TS2322: Type 'true' is not as
// error ~~~~~~~~~~~~~~~ -!!! error TS2322: Type '2' is not assignable to type 'string'. +!!! error TS2322: Type '{ primaryText: 2; }' is not assignable to type 'IProps'. +!!! error TS2322: Types of property 'primaryText' are incompatible. +!!! error TS2322: Type '2' is not assignable to type 'string'. // ok // error - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'true' is not assignable to type 'string | number'. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ justRandomProp1: true; primaryText: "hello"; }' is not assignable to type 'IProps'. +!!! error TS2322: Property 'justRandomProp1' is incompatible with index signature. +!!! error TS2322: Type 'true' is not assignable to type 'string | number'.
) } \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution15.errors.txt b/tests/baselines/reference/tsxAttributeResolution15.errors.txt new file mode 100644 index 00000000000..e4d2b6f89a5 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution15.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/jsx/file.tsx(12,21): error TS2322: Type '{ prop1: "hello"; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & {} & { children?: ReactNode; }'. + Property 'prop1' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & {} & { children?: ReactNode; }'. + + +==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== + + import React = require('react'); + + class BigGreeter extends React.Component<{ }, {}> { + render() { + return
Default hi
; + } + greeting: string; + } + + // Error + let a = + ~~~~~~~~~~~~~ +!!! error TS2322: Type '{ prop1: "hello"; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & {} & { children?: ReactNode; }'. +!!! error TS2322: Property 'prop1' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & {} & { children?: ReactNode; }'. + + // OK + let b = { this.textInput = input; }} /> + let c = \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution15.js b/tests/baselines/reference/tsxAttributeResolution15.js new file mode 100644 index 00000000000..110c33593c6 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution15.js @@ -0,0 +1,48 @@ +//// [file.tsx] + +import React = require('react'); + +class BigGreeter extends React.Component<{ }, {}> { + render() { + return
Default hi
; + } + greeting: string; +} + +// Error +let a = + +// OK +let b = { this.textInput = input; }} /> +let c = + +//// [file.jsx] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var _this = this; +exports.__esModule = true; +var React = require("react"); +var BigGreeter = (function (_super) { + __extends(BigGreeter, _super); + function BigGreeter() { + return _super !== null && _super.apply(this, arguments) || this; + } + BigGreeter.prototype.render = function () { + return
Default hi
; + }; + return BigGreeter; +}(React.Component)); +// Error +var a = ; +// OK +var b = ; +var c = ; diff --git a/tests/baselines/reference/tsxAttributeResolution3.errors.txt b/tests/baselines/reference/tsxAttributeResolution3.errors.txt index ae8ba7a9a54..d5517ea31a2 100644 --- a/tests/baselines/reference/tsxAttributeResolution3.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution3.errors.txt @@ -1,9 +1,13 @@ -tests/cases/conformance/jsx/file.tsx(19,8): error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/jsx/file.tsx(23,1): error TS2324: Property 'x' is missing in type 'Attribs1'. -tests/cases/conformance/jsx/file.tsx(31,15): error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/jsx/file.tsx(39,8): error TS2322: Type '32' is not assignable to type 'string'. +tests/cases/conformance/jsx/file.tsx(19,8): error TS2322: Type '{ x: number; }' is not assignable to type 'Attribs1'. + Types of property 'x' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/file.tsx(23,8): error TS2322: Type '{ y: number; }' is not assignable to type 'Attribs1'. + Property 'x' is missing in type '{ y: number; }'. +tests/cases/conformance/jsx/file.tsx(31,8): error TS2322: Type '{ x: number; y: number; }' is not assignable to type 'Attribs1'. + Types of property 'x' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/file.tsx(35,8): error TS2322: Type '{ x: string; y: number; extra: number; }' is not assignable to type 'Attribs1'. + Property 'extra' does not exist on type 'Attribs1'. ==== tests/cases/conformance/jsx/file.tsx (4 errors) ==== @@ -27,14 +31,16 @@ tests/cases/conformance/jsx/file.tsx(39,8): error TS2322: Type '32' is not assig var obj2 = { x: 32 }; ~~~~~~~~~ -!!! error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. -!!! error TS2606: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '{ x: number; }' is not assignable to type 'Attribs1'. +!!! error TS2322: Types of property 'x' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. // Error, x is missing var obj3 = { y: 32 }; - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2324: Property 'x' is missing in type 'Attribs1'. + ~~~~~~~~~ +!!! error TS2322: Type '{ y: number; }' is not assignable to type 'Attribs1'. +!!! error TS2322: Property 'x' is missing in type '{ y: number; }'. // OK var obj4 = { x: 32, y: 32 }; @@ -43,17 +49,19 @@ tests/cases/conformance/jsx/file.tsx(39,8): error TS2322: Type '32' is not assig // Error var obj5 = { x: 32, y: 32 }; - ~~~~~~~~~ -!!! error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. -!!! error TS2606: Type 'number' is not assignable to type 'string'. - - // OK - var obj6 = { x: 'ok', y: 32, extra: 100 }; - + ~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ x: number; y: number; }' is not assignable to type 'Attribs1'. +!!! error TS2322: Types of property 'x' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. // Error + var obj6 = { x: 'ok', y: 32, extra: 100 }; + + ~~~~~~~~~ +!!! error TS2322: Type '{ x: string; y: number; extra: number; }' is not assignable to type 'Attribs1'. +!!! error TS2322: Property 'extra' does not exist on type 'Attribs1'. + + // OK (spread override) var obj7 = { x: 'foo' }; - ~~~~~~ -!!! error TS2322: Type '32' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution3.js b/tests/baselines/reference/tsxAttributeResolution3.js index 2898a6bc251..c96fd77e284 100644 --- a/tests/baselines/reference/tsxAttributeResolution3.js +++ b/tests/baselines/reference/tsxAttributeResolution3.js @@ -31,11 +31,11 @@ var obj4 = { x: 32, y: 32 }; var obj5 = { x: 32, y: 32 }; -// OK +// Error var obj6 = { x: 'ok', y: 32, extra: 100 }; -// Error +// OK (spread override) var obj7 = { x: 'foo' }; @@ -56,9 +56,9 @@ var obj4 = { x: 32, y: 32 }; // Error var obj5 = { x: 32, y: 32 }; ; -// OK +// Error var obj6 = { x: 'ok', y: 32, extra: 100 }; ; -// Error +// OK (spread override) var obj7 = { x: 'foo' }; ; diff --git a/tests/baselines/reference/tsxAttributeResolution5.errors.txt b/tests/baselines/reference/tsxAttributeResolution5.errors.txt index 42dabc741ab..ffbd41a07b2 100644 --- a/tests/baselines/reference/tsxAttributeResolution5.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution5.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/jsx/file.tsx(21,16): error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/jsx/file.tsx(25,9): error TS2324: Property 'x' is missing in type 'Attribs1'. -tests/cases/conformance/jsx/file.tsx(29,1): error TS2324: Property 'x' is missing in type 'Attribs1'. -tests/cases/conformance/jsx/file.tsx(30,1): error TS2324: Property 'toString' is missing in type 'Attribs2'. +tests/cases/conformance/jsx/file.tsx(17,16): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/jsx/file.tsx(21,16): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/jsx/file.tsx(25,16): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/jsx/file.tsx(29,8): error TS2322: Type '{}' is not assignable to type 'Attribs1'. + Property 'x' is missing in type '{}'. ==== tests/cases/conformance/jsx/file.tsx (4 errors) ==== @@ -23,26 +23,26 @@ tests/cases/conformance/jsx/file.tsx(30,1): error TS2324: Property 'toString' is function make1 (obj: T) { return ; // OK + ~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. } function make2 (obj: T) { return ; // Error (x is number, not string) ~~~~~~~~ -!!! error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. -!!! error TS2606: Type 'number' is not assignable to type 'string'. +!!! error TS2698: Spread types may only be created from object types. } function make3 (obj: T) { return ; // Error, missing x - ~~~~~~~~~~~~~~~~~~ -!!! error TS2324: Property 'x' is missing in type 'Attribs1'. + ~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. } ; // Error, missing x - ~~~~~~~~~~~~~~~~~ -!!! error TS2324: Property 'x' is missing in type 'Attribs1'. + ~~~~~~~ +!!! error TS2322: Type '{}' is not assignable to type 'Attribs1'. +!!! error TS2322: Property 'x' is missing in type '{}'. ; // Error, missing toString - ~~~~~~~~~~~~~~~~~ -!!! error TS2324: Property 'toString' is missing in type 'Attribs2'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution6.errors.txt b/tests/baselines/reference/tsxAttributeResolution6.errors.txt index f3a4d512152..77f1f5bb8df 100644 --- a/tests/baselines/reference/tsxAttributeResolution6.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution6.errors.txt @@ -1,6 +1,11 @@ -tests/cases/conformance/jsx/file.tsx(10,8): error TS2322: Type 'boolean' is not assignable to type 'string'. -tests/cases/conformance/jsx/file.tsx(11,8): error TS2322: Type '"true"' is not assignable to type 'boolean'. -tests/cases/conformance/jsx/file.tsx(12,1): error TS2324: Property 'n' is missing in type '{ n: boolean; }'. +tests/cases/conformance/jsx/file.tsx(10,8): error TS2322: Type '{ s: true; }' is not assignable to type '{ n?: boolean; s?: string; }'. + Types of property 's' are incompatible. + Type 'true' is not assignable to type 'string'. +tests/cases/conformance/jsx/file.tsx(11,8): error TS2322: Type '{ n: "true"; }' is not assignable to type '{ n?: boolean; s?: string; }'. + Types of property 'n' are incompatible. + Type '"true"' is not assignable to type 'boolean'. +tests/cases/conformance/jsx/file.tsx(12,1): error TS2322: Type '{}' is not assignable to type '{ n: boolean; }'. + Property 'n' is missing in type '{}'. ==== tests/cases/conformance/jsx/file.tsx (3 errors) ==== @@ -15,13 +20,18 @@ tests/cases/conformance/jsx/file.tsx(12,1): error TS2324: Property 'n' is missin // Error ; ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'string'. +!!! error TS2322: Type '{ s: true; }' is not assignable to type '{ n?: boolean; s?: string; }'. +!!! error TS2322: Types of property 's' are incompatible. +!!! error TS2322: Type 'true' is not assignable to type 'string'. ; ~~~~~~~~ -!!! error TS2322: Type '"true"' is not assignable to type 'boolean'. +!!! error TS2322: Type '{ n: "true"; }' is not assignable to type '{ n?: boolean; s?: string; }'. +!!! error TS2322: Types of property 'n' are incompatible. +!!! error TS2322: Type '"true"' is not assignable to type 'boolean'. ; ~~~~~~~~~ -!!! error TS2324: Property 'n' is missing in type '{ n: boolean; }'. +!!! error TS2322: Type '{}' is not assignable to type '{ n: boolean; }'. +!!! error TS2322: Property 'n' is missing in type '{}'. // OK ; diff --git a/tests/baselines/reference/tsxAttributeResolution7.errors.txt b/tests/baselines/reference/tsxAttributeResolution7.errors.txt index f5af1b48eb2..6f379f9dc1e 100644 --- a/tests/baselines/reference/tsxAttributeResolution7.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution7.errors.txt @@ -1,4 +1,6 @@ -tests/cases/conformance/jsx/file.tsx(9,8): error TS2322: Type '32' is not assignable to type 'string'. +tests/cases/conformance/jsx/file.tsx(9,8): error TS2322: Type '{ data-foo: 32; }' is not assignable to type '{ "data-foo"?: string; }'. + Types of property '"data-foo"' are incompatible. + Type '32' is not assignable to type 'string'. ==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== @@ -12,7 +14,9 @@ tests/cases/conformance/jsx/file.tsx(9,8): error TS2322: Type '32' is not assign // Error ; ~~~~~~~~~~~~~ -!!! error TS2322: Type '32' is not assignable to type 'string'. +!!! error TS2322: Type '{ data-foo: 32; }' is not assignable to type '{ "data-foo"?: string; }'. +!!! error TS2322: Types of property '"data-foo"' are incompatible. +!!! error TS2322: Type '32' is not assignable to type 'string'. // OK ; diff --git a/tests/baselines/reference/tsxAttributeResolution9.errors.txt b/tests/baselines/reference/tsxAttributeResolution9.errors.txt index 73571689b1f..670cdd6dfcb 100644 --- a/tests/baselines/reference/tsxAttributeResolution9.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution9.errors.txt @@ -1,4 +1,6 @@ -tests/cases/conformance/jsx/file.tsx(9,14): error TS2322: Type '0' is not assignable to type 'string'. +tests/cases/conformance/jsx/file.tsx(9,14): error TS2322: Type '{ foo: 0; }' is not assignable to type '{ foo: string; }'. + Types of property 'foo' are incompatible. + Type '0' is not assignable to type 'string'. ==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== @@ -27,5 +29,7 @@ tests/cases/conformance/jsx/file.tsx(9,14): error TS2322: Type '0' is not assign ; // ok ; // should be an error ~~~~~~~ -!!! error TS2322: Type '0' is not assignable to type 'string'. +!!! error TS2322: Type '{ foo: 0; }' is not assignable to type '{ foo: string; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type '0' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution9.js b/tests/baselines/reference/tsxAttributeResolution9.js index cd6946636a6..d7880c820d8 100644 --- a/tests/baselines/reference/tsxAttributeResolution9.js +++ b/tests/baselines/reference/tsxAttributeResolution9.js @@ -30,6 +30,7 @@ export class MyComponent { //// [file.jsx] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var MyComponent = (function () { function MyComponent() { } diff --git a/tests/baselines/reference/tsxCorrectlyParseLessThanComparison1.js b/tests/baselines/reference/tsxCorrectlyParseLessThanComparison1.js index f5d35ccaf77..f6403804fae 100644 --- a/tests/baselines/reference/tsxCorrectlyParseLessThanComparison1.js +++ b/tests/baselines/reference/tsxCorrectlyParseLessThanComparison1.js @@ -21,15 +21,21 @@ export class ShortDetails extends React.Component<{ id: number }, {}> { //// [tsxCorrectlyParseLessThanComparison1.js] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var ShortDetails = (function (_super) { __extends(ShortDetails, _super); function ShortDetails() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } ShortDetails.prototype.render = function () { if (this.props.id < 1) { diff --git a/tests/baselines/reference/tsxDefaultAttributesResolution1.js b/tests/baselines/reference/tsxDefaultAttributesResolution1.js new file mode 100644 index 00000000000..87c079901d9 --- /dev/null +++ b/tests/baselines/reference/tsxDefaultAttributesResolution1.js @@ -0,0 +1,42 @@ +//// [file.tsx] + +import React = require('react'); + +interface Prop { + x: boolean; +} +class Poisoned extends React.Component { + render() { + return
Hello
; + } +} + +// OK +let p = ; + +//// [file.jsx] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var React = require("react"); +var Poisoned = (function (_super) { + __extends(Poisoned, _super); + function Poisoned() { + return _super !== null && _super.apply(this, arguments) || this; + } + Poisoned.prototype.render = function () { + return
Hello
; + }; + return Poisoned; +}(React.Component)); +// OK +var p = ; diff --git a/tests/baselines/reference/tsxDefaultAttributesResolution1.symbols b/tests/baselines/reference/tsxDefaultAttributesResolution1.symbols new file mode 100644 index 00000000000..a0efe4f9dbe --- /dev/null +++ b/tests/baselines/reference/tsxDefaultAttributesResolution1.symbols @@ -0,0 +1,33 @@ +=== tests/cases/conformance/jsx/file.tsx === + +import React = require('react'); +>React : Symbol(React, Decl(file.tsx, 0, 0)) + +interface Prop { +>Prop : Symbol(Prop, Decl(file.tsx, 1, 32)) + + x: boolean; +>x : Symbol(Prop.x, Decl(file.tsx, 3, 16)) +} +class Poisoned extends React.Component { +>Poisoned : Symbol(Poisoned, Decl(file.tsx, 5, 1)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>React : Symbol(React, Decl(file.tsx, 0, 0)) +>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>Prop : Symbol(Prop, Decl(file.tsx, 1, 32)) + + render() { +>render : Symbol(Poisoned.render, Decl(file.tsx, 6, 50)) + + return
Hello
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) + } +} + +// OK +let p = ; +>p : Symbol(p, Decl(file.tsx, 13, 3)) +>Poisoned : Symbol(Poisoned, Decl(file.tsx, 5, 1)) +>x : Symbol(x, Decl(file.tsx, 13, 17)) + diff --git a/tests/baselines/reference/tsxDefaultAttributesResolution1.types b/tests/baselines/reference/tsxDefaultAttributesResolution1.types new file mode 100644 index 00000000000..1734380a55d --- /dev/null +++ b/tests/baselines/reference/tsxDefaultAttributesResolution1.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/jsx/file.tsx === + +import React = require('react'); +>React : typeof React + +interface Prop { +>Prop : Prop + + x: boolean; +>x : boolean +} +class Poisoned extends React.Component { +>Poisoned : Poisoned +>React.Component : React.Component +>React : typeof React +>Component : typeof React.Component +>Prop : Prop + + render() { +>render : () => JSX.Element + + return
Hello
; +>
Hello
: JSX.Element +>div : any +>div : any + } +} + +// OK +let p = ; +>p : JSX.Element +> : JSX.Element +>Poisoned : typeof Poisoned +>x : true + diff --git a/tests/baselines/reference/tsxDefaultAttributesResolution2.js b/tests/baselines/reference/tsxDefaultAttributesResolution2.js new file mode 100644 index 00000000000..bc5e6a94ef2 --- /dev/null +++ b/tests/baselines/reference/tsxDefaultAttributesResolution2.js @@ -0,0 +1,42 @@ +//// [file.tsx] + +import React = require('react'); + +interface Prop { + x: true; +} +class Poisoned extends React.Component { + render() { + return
Hello
; + } +} + +// OK +let p = ; + +//// [file.jsx] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var React = require("react"); +var Poisoned = (function (_super) { + __extends(Poisoned, _super); + function Poisoned() { + return _super !== null && _super.apply(this, arguments) || this; + } + Poisoned.prototype.render = function () { + return
Hello
; + }; + return Poisoned; +}(React.Component)); +// OK +var p = ; diff --git a/tests/baselines/reference/tsxDefaultAttributesResolution2.symbols b/tests/baselines/reference/tsxDefaultAttributesResolution2.symbols new file mode 100644 index 00000000000..7bcdc7ccfa2 --- /dev/null +++ b/tests/baselines/reference/tsxDefaultAttributesResolution2.symbols @@ -0,0 +1,33 @@ +=== tests/cases/conformance/jsx/file.tsx === + +import React = require('react'); +>React : Symbol(React, Decl(file.tsx, 0, 0)) + +interface Prop { +>Prop : Symbol(Prop, Decl(file.tsx, 1, 32)) + + x: true; +>x : Symbol(Prop.x, Decl(file.tsx, 3, 16)) +} +class Poisoned extends React.Component { +>Poisoned : Symbol(Poisoned, Decl(file.tsx, 5, 1)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>React : Symbol(React, Decl(file.tsx, 0, 0)) +>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>Prop : Symbol(Prop, Decl(file.tsx, 1, 32)) + + render() { +>render : Symbol(Poisoned.render, Decl(file.tsx, 6, 50)) + + return
Hello
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45)) + } +} + +// OK +let p = ; +>p : Symbol(p, Decl(file.tsx, 13, 3)) +>Poisoned : Symbol(Poisoned, Decl(file.tsx, 5, 1)) +>x : Symbol(x, Decl(file.tsx, 13, 17)) + diff --git a/tests/baselines/reference/tsxDefaultAttributesResolution2.types b/tests/baselines/reference/tsxDefaultAttributesResolution2.types new file mode 100644 index 00000000000..ab2bc0c7da6 --- /dev/null +++ b/tests/baselines/reference/tsxDefaultAttributesResolution2.types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/jsx/file.tsx === + +import React = require('react'); +>React : typeof React + +interface Prop { +>Prop : Prop + + x: true; +>x : true +>true : true +} +class Poisoned extends React.Component { +>Poisoned : Poisoned +>React.Component : React.Component +>React : typeof React +>Component : typeof React.Component +>Prop : Prop + + render() { +>render : () => JSX.Element + + return
Hello
; +>
Hello
: JSX.Element +>div : any +>div : any + } +} + +// OK +let p = ; +>p : JSX.Element +> : JSX.Element +>Poisoned : typeof Poisoned +>x : true + diff --git a/tests/baselines/reference/tsxDefaultAttributesResolution3.errors.txt b/tests/baselines/reference/tsxDefaultAttributesResolution3.errors.txt new file mode 100644 index 00000000000..bfb780d2024 --- /dev/null +++ b/tests/baselines/reference/tsxDefaultAttributesResolution3.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/jsx/file.tsx(14,19): error TS2322: Type '{ x: true; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Prop & { children?: ReactNode; }'. + Type '{ x: true; }' is not assignable to type 'Prop'. + Types of property 'x' are incompatible. + Type 'true' is not assignable to type 'false'. + + +==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== + + import React = require('react'); + + interface Prop { + x: false; + } + class Poisoned extends React.Component { + render() { + return
Hello
; + } + } + + // Error + let p = ; + ~ +!!! error TS2322: Type '{ x: true; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Prop & { children?: ReactNode; }'. +!!! error TS2322: Type '{ x: true; }' is not assignable to type 'Prop'. +!!! error TS2322: Types of property 'x' are incompatible. +!!! error TS2322: Type 'true' is not assignable to type 'false'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxDefaultAttributesResolution3.js b/tests/baselines/reference/tsxDefaultAttributesResolution3.js new file mode 100644 index 00000000000..82d940ff580 --- /dev/null +++ b/tests/baselines/reference/tsxDefaultAttributesResolution3.js @@ -0,0 +1,42 @@ +//// [file.tsx] + +import React = require('react'); + +interface Prop { + x: false; +} +class Poisoned extends React.Component { + render() { + return
Hello
; + } +} + +// Error +let p = ; + +//// [file.jsx] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var React = require("react"); +var Poisoned = (function (_super) { + __extends(Poisoned, _super); + function Poisoned() { + return _super !== null && _super.apply(this, arguments) || this; + } + Poisoned.prototype.render = function () { + return
Hello
; + }; + return Poisoned; +}(React.Component)); +// Error +var p = ; diff --git a/tests/baselines/reference/tsxDefaultImports.js b/tests/baselines/reference/tsxDefaultImports.js index 46a94dea92f..c918efb5f4f 100644 --- a/tests/baselines/reference/tsxDefaultImports.js +++ b/tests/baselines/reference/tsxDefaultImports.js @@ -16,6 +16,7 @@ let a = Def.E.one; //// [a.js] "use strict"; +exports.__esModule = true; var SomeEnum; (function (SomeEnum) { SomeEnum[SomeEnum["one"] = 0] = "one"; @@ -26,9 +27,9 @@ var SomeClass = (function () { return SomeClass; }()); SomeClass.E = SomeEnum; -exports.__esModule = true; exports["default"] = SomeClass; //// [b.js] "use strict"; +exports.__esModule = true; var a_1 = require("./a"); var a = a_1["default"].E.one; diff --git a/tests/baselines/reference/tsxDynamicTagName5.js b/tests/baselines/reference/tsxDynamicTagName5.js index d3bb404ceea..4dd03843f15 100644 --- a/tests/baselines/reference/tsxDynamicTagName5.js +++ b/tests/baselines/reference/tsxDynamicTagName5.js @@ -21,16 +21,22 @@ export class Text extends React.Component<{}, {}> { //// [app.jsx] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var React = require("react"); var Text = (function (_super) { __extends(Text, _super); function Text() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this._tagName = 'div'; return _this; } diff --git a/tests/baselines/reference/tsxDynamicTagName7.js b/tests/baselines/reference/tsxDynamicTagName7.js index 84debfd3e71..f4f230b995a 100644 --- a/tests/baselines/reference/tsxDynamicTagName7.js +++ b/tests/baselines/reference/tsxDynamicTagName7.js @@ -21,16 +21,22 @@ export class Text extends React.Component<{}, {}> { //// [app.jsx] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var React = require("react"); var Text = (function (_super) { __extends(Text, _super); function Text() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this._tagName = 'div'; return _this; } diff --git a/tests/baselines/reference/tsxDynamicTagName8.js b/tests/baselines/reference/tsxDynamicTagName8.js index 6166b99f4ac..348574ebf42 100644 --- a/tests/baselines/reference/tsxDynamicTagName8.js +++ b/tests/baselines/reference/tsxDynamicTagName8.js @@ -21,16 +21,22 @@ export class Text extends React.Component<{}, {}> { //// [app.jsx] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var React = require("react"); var Text = (function (_super) { __extends(Text, _super); function Text() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this._tagName = 'div'; return _this; } diff --git a/tests/baselines/reference/tsxDynamicTagName9.js b/tests/baselines/reference/tsxDynamicTagName9.js index 928649264c8..e720b2644a0 100644 --- a/tests/baselines/reference/tsxDynamicTagName9.js +++ b/tests/baselines/reference/tsxDynamicTagName9.js @@ -21,16 +21,22 @@ export class Text extends React.Component<{}, {}> { //// [app.jsx] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var React = require("react"); var Text = (function (_super) { __extends(Text, _super); function Text() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this._tagName = 'div'; return _this; } diff --git a/tests/baselines/reference/tsxElementResolution.symbols b/tests/baselines/reference/tsxElementResolution.symbols index 729c3fc9f06..4b3fd175e19 100644 --- a/tests/baselines/reference/tsxElementResolution.symbols +++ b/tests/baselines/reference/tsxElementResolution.symbols @@ -32,7 +32,7 @@ module Dotted { var a = ; >a : Symbol(a, Decl(tsxElementResolution.tsx, 17, 3)) >foundFirst : Symbol(JSX.IntrinsicElements.foundFirst, Decl(tsxElementResolution.tsx, 2, 30)) ->x : Symbol(x, Decl(tsxElementResolution.tsx, 3, 15)) +>x : Symbol(x, Decl(tsxElementResolution.tsx, 17, 19)) var b = ; >b : Symbol(b, Decl(tsxElementResolution.tsx, 18, 3)) diff --git a/tests/baselines/reference/tsxElementResolution.types b/tests/baselines/reference/tsxElementResolution.types index a1c2abcef7c..891ebc37e5d 100644 --- a/tests/baselines/reference/tsxElementResolution.types +++ b/tests/baselines/reference/tsxElementResolution.types @@ -33,7 +33,7 @@ var a = ; >a : any > : any >foundFirst : typeof foundFirst ->x : any +>x : string var b = ; >b : any diff --git a/tests/baselines/reference/tsxElementResolution11.errors.txt b/tests/baselines/reference/tsxElementResolution11.errors.txt index f6a4913e558..f0d5cf1e009 100644 --- a/tests/baselines/reference/tsxElementResolution11.errors.txt +++ b/tests/baselines/reference/tsxElementResolution11.errors.txt @@ -1,4 +1,5 @@ -tests/cases/conformance/jsx/file.tsx(17,7): error TS2339: Property 'x' does not exist on type '{ q?: number; }'. +tests/cases/conformance/jsx/file.tsx(17,7): error TS2322: Type '{ x: 10; }' is not assignable to type '{ q?: number; }'. + Property 'x' does not exist on type '{ q?: number; }'. ==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== @@ -19,8 +20,9 @@ tests/cases/conformance/jsx/file.tsx(17,7): error TS2339: Property 'x' does not } var Obj2: Obj2type; ; // Error - ~ -!!! error TS2339: Property 'x' does not exist on type '{ q?: number; }'. + ~~~~~~ +!!! error TS2322: Type '{ x: 10; }' is not assignable to type '{ q?: number; }'. +!!! error TS2322: Property 'x' does not exist on type '{ q?: number; }'. interface Obj3type { new(n: string): { x: number; }; diff --git a/tests/baselines/reference/tsxElementResolution12.errors.txt b/tests/baselines/reference/tsxElementResolution12.errors.txt index 5367e29e388..e55ec837332 100644 --- a/tests/baselines/reference/tsxElementResolution12.errors.txt +++ b/tests/baselines/reference/tsxElementResolution12.errors.txt @@ -1,6 +1,8 @@ -tests/cases/conformance/jsx/file.tsx(17,2): error TS2304: Cannot find name 'Obj2'. tests/cases/conformance/jsx/file.tsx(23,1): error TS2607: JSX element class does not support attributes because it does not have a 'pr' property -tests/cases/conformance/jsx/file.tsx(30,7): error TS2322: Type '"10"' is not assignable to type 'number'. +tests/cases/conformance/jsx/file.tsx(25,1): error TS2607: JSX element class does not support attributes because it does not have a 'pr' property +tests/cases/conformance/jsx/file.tsx(33,7): error TS2322: Type '{ x: "10"; }' is not assignable to type '{ x: number; }'. + Types of property 'x' are incompatible. + Type '"10"' is not assignable to type 'number'. ==== tests/cases/conformance/jsx/file.tsx (3 errors) ==== @@ -19,10 +21,8 @@ tests/cases/conformance/jsx/file.tsx(30,7): error TS2322: Type '"10"' is not ass interface Obj2type { new(n: string): { q?: number; pr: any }; } - var obj2: Obj2type; + var Obj2: Obj2type; ; // OK - ~~~~ -!!! error TS2304: Cannot find name 'Obj2'. interface Obj3type { new(n: string): { x: number; }; @@ -31,6 +31,11 @@ tests/cases/conformance/jsx/file.tsx(30,7): error TS2322: Type '"10"' is not ass ; // Error ~~~~~~~~~~~~~~~ !!! error TS2607: JSX element class does not support attributes because it does not have a 'pr' property + var attributes: any; + ; // Error + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2607: JSX element class does not support attributes because it does not have a 'pr' property + ; // OK interface Obj4type { new(n: string): { x: number; pr: { x: number; } }; @@ -39,5 +44,7 @@ tests/cases/conformance/jsx/file.tsx(30,7): error TS2322: Type '"10"' is not ass ; // OK ; // Error ~~~~~~~~ -!!! error TS2322: Type '"10"' is not assignable to type 'number'. +!!! error TS2322: Type '{ x: "10"; }' is not assignable to type '{ x: number; }'. +!!! error TS2322: Types of property 'x' are incompatible. +!!! error TS2322: Type '"10"' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution12.js b/tests/baselines/reference/tsxElementResolution12.js index b4dd94ef0eb..a4d308fefe6 100644 --- a/tests/baselines/reference/tsxElementResolution12.js +++ b/tests/baselines/reference/tsxElementResolution12.js @@ -14,7 +14,7 @@ var Obj1: Obj1type; interface Obj2type { new(n: string): { q?: number; pr: any }; } -var obj2: Obj2type; +var Obj2: Obj2type; ; // OK interface Obj3type { @@ -22,6 +22,9 @@ interface Obj3type { } var Obj3: Obj3type; ; // Error +var attributes: any; +; // Error +; // OK interface Obj4type { new(n: string): { x: number; pr: { x: number; } }; @@ -34,10 +37,13 @@ var Obj4: Obj4type; //// [file.jsx] var Obj1; ; // OK -var obj2; +var Obj2; ; // OK var Obj3; ; // Error +var attributes; +; // Error +; // OK var Obj4; ; // OK ; // Error diff --git a/tests/baselines/reference/tsxElementResolution13.symbols b/tests/baselines/reference/tsxElementResolution13.symbols index 9122f553a88..e306faeaaf2 100644 --- a/tests/baselines/reference/tsxElementResolution13.symbols +++ b/tests/baselines/reference/tsxElementResolution13.symbols @@ -23,5 +23,5 @@ var obj1: Obj1; ; // Error >obj1 : Symbol(unknown) ->x : Symbol(unknown) +>x : Symbol(x, Decl(file.tsx, 9, 5)) diff --git a/tests/baselines/reference/tsxElementResolution13.types b/tests/baselines/reference/tsxElementResolution13.types index d55d4705ff4..b2a6e54633a 100644 --- a/tests/baselines/reference/tsxElementResolution13.types +++ b/tests/baselines/reference/tsxElementResolution13.types @@ -24,6 +24,6 @@ var obj1: Obj1; ; // Error > : JSX.Element >obj1 : Obj1 ->x : any +>x : number >10 : 10 diff --git a/tests/baselines/reference/tsxElementResolution14.symbols b/tests/baselines/reference/tsxElementResolution14.symbols index a605606b1ed..e1a17239e85 100644 --- a/tests/baselines/reference/tsxElementResolution14.symbols +++ b/tests/baselines/reference/tsxElementResolution14.symbols @@ -18,5 +18,5 @@ var obj1: Obj1; ; // OK >obj1 : Symbol(unknown) ->x : Symbol(unknown) +>x : Symbol(x, Decl(file.tsx, 8, 5)) diff --git a/tests/baselines/reference/tsxElementResolution14.types b/tests/baselines/reference/tsxElementResolution14.types index 752a0baafb9..a6e8cc52834 100644 --- a/tests/baselines/reference/tsxElementResolution14.types +++ b/tests/baselines/reference/tsxElementResolution14.types @@ -19,6 +19,6 @@ var obj1: Obj1; ; // OK > : JSX.Element >obj1 : Obj1 ->x : any +>x : number >10 : 10 diff --git a/tests/baselines/reference/tsxElementResolution17.js b/tests/baselines/reference/tsxElementResolution17.js index 1f813b7e24b..899498caf8d 100644 --- a/tests/baselines/reference/tsxElementResolution17.js +++ b/tests/baselines/reference/tsxElementResolution17.js @@ -31,5 +31,6 @@ import s2 = require('elements2'); //// [consumer.jsx] define(["require", "exports", "elements1"], function (require, exports, s1) { "use strict"; + exports.__esModule = true; ; }); diff --git a/tests/baselines/reference/tsxElementResolution19.js b/tests/baselines/reference/tsxElementResolution19.js index f8c3f4b25be..02136e782db 100644 --- a/tests/baselines/reference/tsxElementResolution19.js +++ b/tests/baselines/reference/tsxElementResolution19.js @@ -24,6 +24,7 @@ import {MyClass} from './file1'; //// [file1.js] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; var MyClass = (function () { function MyClass() { } @@ -34,5 +35,6 @@ define(["require", "exports"], function (require, exports) { //// [file2.js] define(["require", "exports", "react", "./file1"], function (require, exports, React, file1_1) { "use strict"; + exports.__esModule = true; React.createElement(file1_1.MyClass, null); }); diff --git a/tests/baselines/reference/tsxElementResolution3.errors.txt b/tests/baselines/reference/tsxElementResolution3.errors.txt index 1b8b6c5834c..d869821a4cb 100644 --- a/tests/baselines/reference/tsxElementResolution3.errors.txt +++ b/tests/baselines/reference/tsxElementResolution3.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/jsx/file.tsx(12,1): error TS2324: Property 'n' is missing in type '{ n: string; }'. -tests/cases/conformance/jsx/file.tsx(12,7): error TS2339: Property 'w' does not exist on type '{ n: string; }'. +tests/cases/conformance/jsx/file.tsx(12,7): error TS2322: Type '{ w: "err"; }' is not assignable to type '{ n: string; }'. + Property 'w' does not exist on type '{ n: string; }'. -==== tests/cases/conformance/jsx/file.tsx (2 errors) ==== +==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== declare module JSX { interface Element { } interface IntrinsicElements { @@ -15,7 +15,6 @@ tests/cases/conformance/jsx/file.tsx(12,7): error TS2339: Property 'w' does not // Error ; - ~~~~~~~~~~~~~~~~ -!!! error TS2324: Property 'n' is missing in type '{ n: string; }'. - ~ -!!! error TS2339: Property 'w' does not exist on type '{ n: string; }'. \ No newline at end of file + ~~~~~~~ +!!! error TS2322: Type '{ w: "err"; }' is not assignable to type '{ n: string; }'. +!!! error TS2322: Property 'w' does not exist on type '{ n: string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution4.errors.txt b/tests/baselines/reference/tsxElementResolution4.errors.txt index e6dd599defc..b5d5437d872 100644 --- a/tests/baselines/reference/tsxElementResolution4.errors.txt +++ b/tests/baselines/reference/tsxElementResolution4.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/jsx/file.tsx(16,1): error TS2324: Property 'm' is missing in type '{ m: string; }'. -tests/cases/conformance/jsx/file.tsx(16,7): error TS2339: Property 'q' does not exist on type '{ m: string; }'. +tests/cases/conformance/jsx/file.tsx(16,7): error TS2322: Type '{ q: ""; }' is not assignable to type '{ m: string; }'. + Property 'q' does not exist on type '{ m: string; }'. -==== tests/cases/conformance/jsx/file.tsx (2 errors) ==== +==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== declare module JSX { interface Element { } interface IntrinsicElements { @@ -19,8 +19,7 @@ tests/cases/conformance/jsx/file.tsx(16,7): error TS2339: Property 'q' does not // Error ; - ~~~~~~~~~~~~~ -!!! error TS2324: Property 'm' is missing in type '{ m: string; }'. - ~ -!!! error TS2339: Property 'q' does not exist on type '{ m: string; }'. + ~~~~ +!!! error TS2322: Type '{ q: ""; }' is not assignable to type '{ m: string; }'. +!!! error TS2322: Property 'q' does not exist on type '{ m: string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution5.symbols b/tests/baselines/reference/tsxElementResolution5.symbols index e0fc1147083..a788a51fc65 100644 --- a/tests/baselines/reference/tsxElementResolution5.symbols +++ b/tests/baselines/reference/tsxElementResolution5.symbols @@ -9,5 +9,5 @@ declare module JSX { // OK, but implicit any
; >div : Symbol(unknown) ->n : Symbol(unknown) +>n : Symbol(n, Decl(file1.tsx, 5, 4)) diff --git a/tests/baselines/reference/tsxElementResolution5.types b/tests/baselines/reference/tsxElementResolution5.types index cdfb91c7067..cd2f3d26337 100644 --- a/tests/baselines/reference/tsxElementResolution5.types +++ b/tests/baselines/reference/tsxElementResolution5.types @@ -10,5 +10,5 @@ declare module JSX {
; >
: JSX.Element >div : any ->n : any +>n : string diff --git a/tests/baselines/reference/tsxElementResolution9.symbols b/tests/baselines/reference/tsxElementResolution9.symbols index d6b0da12e6f..30193ebb82d 100644 --- a/tests/baselines/reference/tsxElementResolution9.symbols +++ b/tests/baselines/reference/tsxElementResolution9.symbols @@ -64,5 +64,5 @@ var Obj3: Obj3; ; // OK >Obj3 : Symbol(Obj3, Decl(file.tsx, 17, 9), Decl(file.tsx, 23, 3)) ->x : Symbol(unknown) +>x : Symbol(x, Decl(file.tsx, 24, 5)) diff --git a/tests/baselines/reference/tsxElementResolution9.types b/tests/baselines/reference/tsxElementResolution9.types index c63e61efc07..4d9fb4e73e9 100644 --- a/tests/baselines/reference/tsxElementResolution9.types +++ b/tests/baselines/reference/tsxElementResolution9.types @@ -67,6 +67,6 @@ var Obj3: Obj3; ; // OK > : JSX.Element >Obj3 : Obj3 ->x : any +>x : number >42 : 42 diff --git a/tests/baselines/reference/tsxEmit1.symbols b/tests/baselines/reference/tsxEmit1.symbols index 9e32354b184..f86c40d2c07 100644 --- a/tests/baselines/reference/tsxEmit1.symbols +++ b/tests/baselines/reference/tsxEmit1.symbols @@ -23,37 +23,37 @@ var selfClosed1 =
; var selfClosed2 =
; >selfClosed2 : Symbol(selfClosed2, Decl(file.tsx, 9, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->x : Symbol(unknown) +>x : Symbol(x, Decl(file.tsx, 9, 22)) var selfClosed3 =
; >selfClosed3 : Symbol(selfClosed3, Decl(file.tsx, 10, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->x : Symbol(unknown) +>x : Symbol(x, Decl(file.tsx, 10, 22)) var selfClosed4 =
; >selfClosed4 : Symbol(selfClosed4, Decl(file.tsx, 11, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->x : Symbol(unknown) ->y : Symbol(unknown) +>x : Symbol(x, Decl(file.tsx, 11, 22)) +>y : Symbol(y, Decl(file.tsx, 11, 28)) var selfClosed5 =
; >selfClosed5 : Symbol(selfClosed5, Decl(file.tsx, 12, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->x : Symbol(unknown) ->y : Symbol(unknown) +>x : Symbol(x, Decl(file.tsx, 12, 22)) +>y : Symbol(y, Decl(file.tsx, 12, 28)) var selfClosed6 =
; >selfClosed6 : Symbol(selfClosed6, Decl(file.tsx, 13, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->x : Symbol(unknown) ->y : Symbol(unknown) +>x : Symbol(x, Decl(file.tsx, 13, 22)) +>y : Symbol(y, Decl(file.tsx, 13, 30)) var selfClosed7 =
; >selfClosed7 : Symbol(selfClosed7, Decl(file.tsx, 14, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->x : Symbol(unknown) +>x : Symbol(x, Decl(file.tsx, 14, 22)) >p : Symbol(p, Decl(file.tsx, 7, 3)) ->y : Symbol(unknown) +>y : Symbol(y, Decl(file.tsx, 14, 28)) var openClosed1 =
; >openClosed1 : Symbol(openClosed1, Decl(file.tsx, 16, 3)) @@ -63,20 +63,20 @@ var openClosed1 =
; var openClosed2 =
foo
; >openClosed2 : Symbol(openClosed2, Decl(file.tsx, 17, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->n : Symbol(unknown) +>n : Symbol(n, Decl(file.tsx, 17, 22)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) var openClosed3 =
{p}
; >openClosed3 : Symbol(openClosed3, Decl(file.tsx, 18, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->n : Symbol(unknown) +>n : Symbol(n, Decl(file.tsx, 18, 22)) >p : Symbol(p, Decl(file.tsx, 7, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) var openClosed4 =
{p < p}
; >openClosed4 : Symbol(openClosed4, Decl(file.tsx, 19, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->n : Symbol(unknown) +>n : Symbol(n, Decl(file.tsx, 19, 22)) >p : Symbol(p, Decl(file.tsx, 7, 3)) >p : Symbol(p, Decl(file.tsx, 7, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) @@ -84,7 +84,7 @@ var openClosed4 =
{p < p}
; var openClosed5 =
{p > p}
; >openClosed5 : Symbol(openClosed5, Decl(file.tsx, 20, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->n : Symbol(unknown) +>n : Symbol(n, Decl(file.tsx, 20, 22)) >p : Symbol(p, Decl(file.tsx, 7, 3)) >p : Symbol(p, Decl(file.tsx, 7, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) @@ -118,14 +118,14 @@ class SomeClass { var rewrites4 =
this}>
; >rewrites4 : Symbol(rewrites4, Decl(file.tsx, 28, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->a : Symbol(unknown) +>a : Symbol(a, Decl(file.tsx, 28, 22)) >this : Symbol(SomeClass, Decl(file.tsx, 20, 43)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) var rewrites5 =
; >rewrites5 : Symbol(rewrites5, Decl(file.tsx, 29, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->a : Symbol(unknown) +>a : Symbol(a, Decl(file.tsx, 29, 22)) >p : Symbol(p, Decl(file.tsx, 7, 3)) >p : Symbol(p, Decl(file.tsx, 7, 3)) >p : Symbol(p, Decl(file.tsx, 7, 3)) @@ -134,7 +134,7 @@ class SomeClass { var rewrites6 =
; >rewrites6 : Symbol(rewrites6, Decl(file.tsx, 30, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->a : Symbol(unknown) +>a : Symbol(a, Decl(file.tsx, 30, 22)) >p : Symbol(p, Decl(file.tsx, 30, 27)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) } diff --git a/tests/baselines/reference/tsxEmit1.types b/tests/baselines/reference/tsxEmit1.types index 84f00b4758a..e56ab8dfa04 100644 --- a/tests/baselines/reference/tsxEmit1.types +++ b/tests/baselines/reference/tsxEmit1.types @@ -25,36 +25,36 @@ var selfClosed2 =
; >selfClosed2 : JSX.Element >
: JSX.Element >div : any ->x : any +>x : string var selfClosed3 =
; >selfClosed3 : JSX.Element >
: JSX.Element >div : any ->x : any +>x : string var selfClosed4 =
; >selfClosed4 : JSX.Element >
: JSX.Element >div : any ->x : any ->y : any +>x : string +>y : string var selfClosed5 =
; >selfClosed5 : JSX.Element >
: JSX.Element >div : any ->x : any +>x : number >0 : 0 ->y : any +>y : string var selfClosed6 =
; >selfClosed6 : JSX.Element >
: JSX.Element >div : any ->x : any +>x : string >"1" : "1" ->y : any +>y : string var selfClosed7 =
; >selfClosed7 : JSX.Element @@ -62,7 +62,7 @@ var selfClosed7 =
; >div : any >x : any >p : any ->y : any +>y : string var openClosed1 =
; >openClosed1 : JSX.Element @@ -74,14 +74,14 @@ var openClosed2 =
foo
; >openClosed2 : JSX.Element >
foo
: JSX.Element >div : any ->n : any +>n : string >div : any var openClosed3 =
{p}
; >openClosed3 : JSX.Element >
{p}
: JSX.Element >div : any ->n : any +>n : string >p : any >div : any @@ -89,7 +89,7 @@ var openClosed4 =
{p < p}
; >openClosed4 : JSX.Element >
{p < p}
: JSX.Element >div : any ->n : any +>n : string >p < p : boolean >p : any >p : any @@ -99,7 +99,7 @@ var openClosed5 =
{p > p}
; >openClosed5 : JSX.Element >
{p > p}
: JSX.Element >div : any ->n : any +>n : string >p > p : boolean >p : any >p : any @@ -142,7 +142,7 @@ class SomeClass { >rewrites4 : JSX.Element >
this}>
: JSX.Element >div : any ->a : any +>a : () => this >() => this : () => this >this : this >div : any @@ -151,7 +151,7 @@ class SomeClass { >rewrites5 : JSX.Element >
: JSX.Element >div : any ->a : any +>a : any[] >[p, ...p, p] : any[] >p : any >...p : any @@ -163,7 +163,7 @@ class SomeClass { >rewrites6 : JSX.Element >
: JSX.Element >div : any ->a : any +>a : { p: any; } >{p} : { p: any; } >p : any >div : any diff --git a/tests/baselines/reference/tsxEmit2.js b/tests/baselines/reference/tsxEmit2.js index 66b1494e825..d22f5bab9f1 100644 --- a/tests/baselines/reference/tsxEmit2.js +++ b/tests/baselines/reference/tsxEmit2.js @@ -6,7 +6,7 @@ declare module JSX { } } -var p1, p2, p3; +var p1: any, p2: any, p3: any; var spreads1 =
{p2}
; var spreads2 =
{p2}
; var spreads3 =
{p2}
; diff --git a/tests/baselines/reference/tsxEmit2.symbols b/tests/baselines/reference/tsxEmit2.symbols index 13e45e454f1..40b778253e9 100644 --- a/tests/baselines/reference/tsxEmit2.symbols +++ b/tests/baselines/reference/tsxEmit2.symbols @@ -13,51 +13,51 @@ declare module JSX { } } -var p1, p2, p3; +var p1: any, p2: any, p3: any; >p1 : Symbol(p1, Decl(file.tsx, 7, 3)) ->p2 : Symbol(p2, Decl(file.tsx, 7, 7)) ->p3 : Symbol(p3, Decl(file.tsx, 7, 11)) +>p2 : Symbol(p2, Decl(file.tsx, 7, 12)) +>p3 : Symbol(p3, Decl(file.tsx, 7, 21)) var spreads1 =
{p2}
; >spreads1 : Symbol(spreads1, Decl(file.tsx, 8, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) >p1 : Symbol(p1, Decl(file.tsx, 7, 3)) ->p2 : Symbol(p2, Decl(file.tsx, 7, 7)) +>p2 : Symbol(p2, Decl(file.tsx, 7, 12)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) var spreads2 =
{p2}
; >spreads2 : Symbol(spreads2, Decl(file.tsx, 9, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) >p1 : Symbol(p1, Decl(file.tsx, 7, 3)) ->p2 : Symbol(p2, Decl(file.tsx, 7, 7)) +>p2 : Symbol(p2, Decl(file.tsx, 7, 12)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) var spreads3 =
{p2}
; >spreads3 : Symbol(spreads3, Decl(file.tsx, 10, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->x : Symbol(unknown) ->p3 : Symbol(p3, Decl(file.tsx, 7, 11)) +>x : Symbol(x, Decl(file.tsx, 10, 19)) +>p3 : Symbol(p3, Decl(file.tsx, 7, 21)) >p1 : Symbol(p1, Decl(file.tsx, 7, 3)) ->p2 : Symbol(p2, Decl(file.tsx, 7, 7)) +>p2 : Symbol(p2, Decl(file.tsx, 7, 12)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) var spreads4 =
{p2}
; >spreads4 : Symbol(spreads4, Decl(file.tsx, 11, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) >p1 : Symbol(p1, Decl(file.tsx, 7, 3)) ->x : Symbol(unknown) ->p3 : Symbol(p3, Decl(file.tsx, 7, 11)) ->p2 : Symbol(p2, Decl(file.tsx, 7, 7)) +>x : Symbol(x, Decl(file.tsx, 11, 27)) +>p3 : Symbol(p3, Decl(file.tsx, 7, 21)) +>p2 : Symbol(p2, Decl(file.tsx, 7, 12)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) var spreads5 =
{p2}
; >spreads5 : Symbol(spreads5, Decl(file.tsx, 12, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->x : Symbol(unknown) ->p2 : Symbol(p2, Decl(file.tsx, 7, 7)) +>x : Symbol(x, Decl(file.tsx, 12, 19)) +>p2 : Symbol(p2, Decl(file.tsx, 7, 12)) >p1 : Symbol(p1, Decl(file.tsx, 7, 3)) ->y : Symbol(unknown) ->p3 : Symbol(p3, Decl(file.tsx, 7, 11)) ->p2 : Symbol(p2, Decl(file.tsx, 7, 7)) +>y : Symbol(y, Decl(file.tsx, 12, 34)) +>p3 : Symbol(p3, Decl(file.tsx, 7, 21)) +>p2 : Symbol(p2, Decl(file.tsx, 7, 12)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxEmit2.types b/tests/baselines/reference/tsxEmit2.types index 5b267d8b802..e02dc6c7f86 100644 --- a/tests/baselines/reference/tsxEmit2.types +++ b/tests/baselines/reference/tsxEmit2.types @@ -13,7 +13,7 @@ declare module JSX { } } -var p1, p2, p3; +var p1: any, p2: any, p3: any; >p1 : any >p2 : any >p3 : any diff --git a/tests/baselines/reference/tsxExternalModuleEmit1.js b/tests/baselines/reference/tsxExternalModuleEmit1.js index 58e7f1c8d85..c8c64062d13 100644 --- a/tests/baselines/reference/tsxExternalModuleEmit1.js +++ b/tests/baselines/reference/tsxExternalModuleEmit1.js @@ -33,16 +33,22 @@ export class Button extends React.Component { //// [button.jsx] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var React = require("react"); var Button = (function (_super) { __extends(Button, _super); function Button() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } Button.prototype.render = function () { return ; @@ -52,18 +58,24 @@ var Button = (function (_super) { exports.Button = Button; //// [app.jsx] "use strict"; -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 __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; var React = require("react"); // Should see var button_1 = require('./button') here var button_1 = require("./button"); var App = (function (_super) { __extends(App, _super); function App() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } App.prototype.render = function () { return ; diff --git a/tests/baselines/reference/tsxExternalModuleEmit2.js b/tests/baselines/reference/tsxExternalModuleEmit2.js index 6c01a48af78..aae48021457 100644 --- a/tests/baselines/reference/tsxExternalModuleEmit2.js +++ b/tests/baselines/reference/tsxExternalModuleEmit2.js @@ -27,6 +27,7 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { } return t; }; +exports.__esModule = true; var mod_1 = require("mod"); // Should see mod_1['default'] in emit here React.createElement(Foo, { handler: mod_1["default"] }); diff --git a/tests/baselines/reference/tsxExternalModuleEmit2.symbols b/tests/baselines/reference/tsxExternalModuleEmit2.symbols index ff5fdc49171..8f7cfa52136 100644 --- a/tests/baselines/reference/tsxExternalModuleEmit2.symbols +++ b/tests/baselines/reference/tsxExternalModuleEmit2.symbols @@ -19,7 +19,7 @@ declare var Foo, React; // Should see mod_1['default'] in emit here ; >Foo : Symbol(Foo, Decl(app.tsx, 1, 11)) ->handler : Symbol(unknown) +>handler : Symbol(handler, Decl(app.tsx, 3, 4)) >Main : Symbol(Main, Decl(app.tsx, 0, 6)) >Foo : Symbol(Foo, Decl(app.tsx, 1, 11)) diff --git a/tests/baselines/reference/tsxGenericArrowFunctionParsing.symbols b/tests/baselines/reference/tsxGenericArrowFunctionParsing.symbols index 2d3c1f18d48..8b773c3b5ab 100644 --- a/tests/baselines/reference/tsxGenericArrowFunctionParsing.symbols +++ b/tests/baselines/reference/tsxGenericArrowFunctionParsing.symbols @@ -44,7 +44,7 @@ x3(); var x4 = () => {}; >x4 : Symbol(x4, Decl(file.tsx, 19, 3)) >T : Symbol(T, Decl(file.tsx, 4, 3)) ->extends : Symbol(unknown) +>extends : Symbol(extends, Decl(file.tsx, 19, 11)) >T : Symbol(T, Decl(file.tsx, 4, 3)) x4.isElement; @@ -56,7 +56,7 @@ x4.isElement; var x5 = () => {}; >x5 : Symbol(x5, Decl(file.tsx, 23, 3)) >T : Symbol(T, Decl(file.tsx, 4, 3)) ->extends : Symbol(unknown) +>extends : Symbol(extends, Decl(file.tsx, 23, 11)) >T : Symbol(T, Decl(file.tsx, 4, 3)) x5.isElement; diff --git a/tests/baselines/reference/tsxGenericArrowFunctionParsing.types b/tests/baselines/reference/tsxGenericArrowFunctionParsing.types index 0f746a07136..0e601daecaf 100644 --- a/tests/baselines/reference/tsxGenericArrowFunctionParsing.types +++ b/tests/baselines/reference/tsxGenericArrowFunctionParsing.types @@ -50,7 +50,7 @@ var x4 = () => {}; >x4 : JSX.Element >() => {} : JSX.Element >T : any ->extends : any +>extends : boolean >true : true >T : any @@ -64,7 +64,7 @@ var x5 = () => {}; >x5 : JSX.Element >() => {} : JSX.Element >T : any ->extends : any +>extends : true >T : any x5.isElement; diff --git a/tests/baselines/reference/tsxInArrowFunction.symbols b/tests/baselines/reference/tsxInArrowFunction.symbols index ff80428cf74..9fc928e36e1 100644 --- a/tests/baselines/reference/tsxInArrowFunction.symbols +++ b/tests/baselines/reference/tsxInArrowFunction.symbols @@ -23,7 +23,7 @@ declare namespace JSX {
{() =>
}
; >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) ->text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 12, 16)) >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) // didn't work @@ -31,21 +31,21 @@ declare namespace JSX { >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) >x : Symbol(x, Decl(tsxInArrowFunction.tsx, 15, 6)) >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) ->text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 15, 15)) >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) // worked
{() => (
)}
; >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) ->text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 18, 17)) >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) // worked (!)
{() =>
}
; >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) ->text : Symbol(text, Decl(tsxInArrowFunction.tsx, 4, 14)) +>text : Symbol(text, Decl(tsxInArrowFunction.tsx, 21, 16)) >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) >div : Symbol(JSX.IntrinsicElements.div, Decl(tsxInArrowFunction.tsx, 3, 33)) diff --git a/tests/baselines/reference/tsxInArrowFunction.types b/tests/baselines/reference/tsxInArrowFunction.types index e4b2aeb50fe..76b0d1e1e64 100644 --- a/tests/baselines/reference/tsxInArrowFunction.types +++ b/tests/baselines/reference/tsxInArrowFunction.types @@ -26,7 +26,7 @@ declare namespace JSX { >() =>
: () => JSX.Element >
: JSX.Element >div : any ->text : any +>text : string >div : any // didn't work @@ -37,7 +37,7 @@ declare namespace JSX { >x : any >
: JSX.Element >div : any ->text : any +>text : string >div : any // worked @@ -48,7 +48,7 @@ declare namespace JSX { >(
) : JSX.Element >
: JSX.Element >div : any ->text : any +>text : string >div : any // worked (!) @@ -58,7 +58,7 @@ declare namespace JSX { >() =>
: () => JSX.Element >
: JSX.Element >div : any ->text : any +>text : string >div : any >div : any diff --git a/tests/baselines/reference/tsxPreserveEmit1.js b/tests/baselines/reference/tsxPreserveEmit1.js index feb314ee2e6..585b603abfb 100644 --- a/tests/baselines/reference/tsxPreserveEmit1.js +++ b/tests/baselines/reference/tsxPreserveEmit1.js @@ -36,6 +36,7 @@ module M { //// [test.jsx] define(["require", "exports", "react", "react-router"], function (require, exports, React, ReactRouter) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var Route = ReactRouter.Route; var routes1 = ; var M; diff --git a/tests/baselines/reference/tsxPreserveEmit3.js b/tests/baselines/reference/tsxPreserveEmit3.js index 500b7d26c93..fdbe8cc2bb4 100644 --- a/tests/baselines/reference/tsxPreserveEmit3.js +++ b/tests/baselines/reference/tsxPreserveEmit3.js @@ -21,4 +21,5 @@ import {React} from "./test"; //// [react-consumer.jsx] define(["require", "exports"], function (require, exports) { "use strict"; + exports.__esModule = true; }); diff --git a/tests/baselines/reference/tsxReactEmit1.symbols b/tests/baselines/reference/tsxReactEmit1.symbols index 6887a9550c0..ec4c367b40e 100644 --- a/tests/baselines/reference/tsxReactEmit1.symbols +++ b/tests/baselines/reference/tsxReactEmit1.symbols @@ -25,38 +25,38 @@ var selfClosed1 =
; var selfClosed2 =
; >selfClosed2 : Symbol(selfClosed2, Decl(file.tsx, 10, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->x : Symbol(unknown) +>x : Symbol(x, Decl(file.tsx, 10, 22)) var selfClosed3 =
; >selfClosed3 : Symbol(selfClosed3, Decl(file.tsx, 11, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->x : Symbol(unknown) +>x : Symbol(x, Decl(file.tsx, 11, 22)) var selfClosed4 =
; >selfClosed4 : Symbol(selfClosed4, Decl(file.tsx, 12, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->x : Symbol(unknown) ->y : Symbol(unknown) +>x : Symbol(x, Decl(file.tsx, 12, 22)) +>y : Symbol(y, Decl(file.tsx, 12, 28)) var selfClosed5 =
; >selfClosed5 : Symbol(selfClosed5, Decl(file.tsx, 13, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->x : Symbol(unknown) ->y : Symbol(unknown) +>x : Symbol(x, Decl(file.tsx, 13, 22)) +>y : Symbol(y, Decl(file.tsx, 13, 28)) var selfClosed6 =
; >selfClosed6 : Symbol(selfClosed6, Decl(file.tsx, 14, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->x : Symbol(unknown) ->y : Symbol(unknown) +>x : Symbol(x, Decl(file.tsx, 14, 22)) +>y : Symbol(y, Decl(file.tsx, 14, 30)) var selfClosed7 =
; >selfClosed7 : Symbol(selfClosed7, Decl(file.tsx, 15, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->x : Symbol(unknown) +>x : Symbol(x, Decl(file.tsx, 15, 22)) >p : Symbol(p, Decl(file.tsx, 8, 3)) ->y : Symbol(unknown) ->b : Symbol(unknown) +>y : Symbol(y, Decl(file.tsx, 15, 28)) +>b : Symbol(b, Decl(file.tsx, 15, 34)) var openClosed1 =
; >openClosed1 : Symbol(openClosed1, Decl(file.tsx, 17, 3)) @@ -66,20 +66,20 @@ var openClosed1 =
; var openClosed2 =
foo
; >openClosed2 : Symbol(openClosed2, Decl(file.tsx, 18, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->n : Symbol(unknown) +>n : Symbol(n, Decl(file.tsx, 18, 22)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) var openClosed3 =
{p}
; >openClosed3 : Symbol(openClosed3, Decl(file.tsx, 19, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->n : Symbol(unknown) +>n : Symbol(n, Decl(file.tsx, 19, 22)) >p : Symbol(p, Decl(file.tsx, 8, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) var openClosed4 =
{p < p}
; >openClosed4 : Symbol(openClosed4, Decl(file.tsx, 20, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->n : Symbol(unknown) +>n : Symbol(n, Decl(file.tsx, 20, 22)) >p : Symbol(p, Decl(file.tsx, 8, 3)) >p : Symbol(p, Decl(file.tsx, 8, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) @@ -87,8 +87,8 @@ var openClosed4 =
{p < p}
; var openClosed5 =
{p > p}
; >openClosed5 : Symbol(openClosed5, Decl(file.tsx, 21, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->n : Symbol(unknown) ->b : Symbol(unknown) +>n : Symbol(n, Decl(file.tsx, 21, 22)) +>b : Symbol(b, Decl(file.tsx, 21, 28)) >p : Symbol(p, Decl(file.tsx, 8, 3)) >p : Symbol(p, Decl(file.tsx, 8, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) @@ -122,14 +122,14 @@ class SomeClass { var rewrites4 =
this}>
; >rewrites4 : Symbol(rewrites4, Decl(file.tsx, 29, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->a : Symbol(unknown) +>a : Symbol(a, Decl(file.tsx, 29, 22)) >this : Symbol(SomeClass, Decl(file.tsx, 21, 45)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) var rewrites5 =
; >rewrites5 : Symbol(rewrites5, Decl(file.tsx, 30, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->a : Symbol(unknown) +>a : Symbol(a, Decl(file.tsx, 30, 22)) >p : Symbol(p, Decl(file.tsx, 8, 3)) >p : Symbol(p, Decl(file.tsx, 8, 3)) >p : Symbol(p, Decl(file.tsx, 8, 3)) @@ -138,7 +138,7 @@ class SomeClass { var rewrites6 =
; >rewrites6 : Symbol(rewrites6, Decl(file.tsx, 31, 5)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->a : Symbol(unknown) +>a : Symbol(a, Decl(file.tsx, 31, 22)) >p : Symbol(p, Decl(file.tsx, 31, 27)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) } diff --git a/tests/baselines/reference/tsxReactEmit1.types b/tests/baselines/reference/tsxReactEmit1.types index 8eb14e91963..49dbc0c9fd9 100644 --- a/tests/baselines/reference/tsxReactEmit1.types +++ b/tests/baselines/reference/tsxReactEmit1.types @@ -27,36 +27,36 @@ var selfClosed2 =
; >selfClosed2 : JSX.Element >
: JSX.Element >div : any ->x : any +>x : string var selfClosed3 =
; >selfClosed3 : JSX.Element >
: JSX.Element >div : any ->x : any +>x : string var selfClosed4 =
; >selfClosed4 : JSX.Element >
: JSX.Element >div : any ->x : any ->y : any +>x : string +>y : string var selfClosed5 =
; >selfClosed5 : JSX.Element >
: JSX.Element >div : any ->x : any +>x : number >0 : 0 ->y : any +>y : string var selfClosed6 =
; >selfClosed6 : JSX.Element >
: JSX.Element >div : any ->x : any +>x : string >"1" : "1" ->y : any +>y : string var selfClosed7 =
; >selfClosed7 : JSX.Element @@ -64,8 +64,8 @@ var selfClosed7 =
; >div : any >x : any >p : any ->y : any ->b : any +>y : string +>b : true var openClosed1 =
; >openClosed1 : JSX.Element @@ -77,14 +77,14 @@ var openClosed2 =
foo
; >openClosed2 : JSX.Element >
foo
: JSX.Element >div : any ->n : any +>n : string >div : any var openClosed3 =
{p}
; >openClosed3 : JSX.Element >
{p}
: JSX.Element >div : any ->n : any +>n : string >p : any >div : any @@ -92,7 +92,7 @@ var openClosed4 =
{p < p}
; >openClosed4 : JSX.Element >
{p < p}
: JSX.Element >div : any ->n : any +>n : string >p < p : boolean >p : any >p : any @@ -102,8 +102,8 @@ var openClosed5 =
{p > p}
; >openClosed5 : JSX.Element >
{p > p}
: JSX.Element >div : any ->n : any ->b : any +>n : string +>b : true >p > p : boolean >p : any >p : any @@ -146,7 +146,7 @@ class SomeClass { >rewrites4 : JSX.Element >
this}>
: JSX.Element >div : any ->a : any +>a : () => this >() => this : () => this >this : this >div : any @@ -155,7 +155,7 @@ class SomeClass { >rewrites5 : JSX.Element >
: JSX.Element >div : any ->a : any +>a : any[] >[p, ...p, p] : any[] >p : any >...p : any @@ -167,7 +167,7 @@ class SomeClass { >rewrites6 : JSX.Element >
: JSX.Element >div : any ->a : any +>a : { p: any; } >{p} : { p: any; } >p : any >div : any diff --git a/tests/baselines/reference/tsxReactEmit2.js b/tests/baselines/reference/tsxReactEmit2.js index 80e3215e2b6..c81c7b2afea 100644 --- a/tests/baselines/reference/tsxReactEmit2.js +++ b/tests/baselines/reference/tsxReactEmit2.js @@ -7,7 +7,7 @@ declare module JSX { } declare var React: any; -var p1, p2, p3; +var p1: any, p2: any, p3: any; var spreads1 =
{p2}
; var spreads2 =
{p2}
; var spreads3 =
{p2}
; diff --git a/tests/baselines/reference/tsxReactEmit2.symbols b/tests/baselines/reference/tsxReactEmit2.symbols index 68f33a11f09..28b2c427bd8 100644 --- a/tests/baselines/reference/tsxReactEmit2.symbols +++ b/tests/baselines/reference/tsxReactEmit2.symbols @@ -15,51 +15,51 @@ declare module JSX { declare var React: any; >React : Symbol(React, Decl(file.tsx, 6, 11)) -var p1, p2, p3; +var p1: any, p2: any, p3: any; >p1 : Symbol(p1, Decl(file.tsx, 8, 3)) ->p2 : Symbol(p2, Decl(file.tsx, 8, 7)) ->p3 : Symbol(p3, Decl(file.tsx, 8, 11)) +>p2 : Symbol(p2, Decl(file.tsx, 8, 12)) +>p3 : Symbol(p3, Decl(file.tsx, 8, 21)) var spreads1 =
{p2}
; >spreads1 : Symbol(spreads1, Decl(file.tsx, 9, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) >p1 : Symbol(p1, Decl(file.tsx, 8, 3)) ->p2 : Symbol(p2, Decl(file.tsx, 8, 7)) +>p2 : Symbol(p2, Decl(file.tsx, 8, 12)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) var spreads2 =
{p2}
; >spreads2 : Symbol(spreads2, Decl(file.tsx, 10, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) >p1 : Symbol(p1, Decl(file.tsx, 8, 3)) ->p2 : Symbol(p2, Decl(file.tsx, 8, 7)) +>p2 : Symbol(p2, Decl(file.tsx, 8, 12)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) var spreads3 =
{p2}
; >spreads3 : Symbol(spreads3, Decl(file.tsx, 11, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->x : Symbol(unknown) ->p3 : Symbol(p3, Decl(file.tsx, 8, 11)) +>x : Symbol(x, Decl(file.tsx, 11, 19)) +>p3 : Symbol(p3, Decl(file.tsx, 8, 21)) >p1 : Symbol(p1, Decl(file.tsx, 8, 3)) ->p2 : Symbol(p2, Decl(file.tsx, 8, 7)) +>p2 : Symbol(p2, Decl(file.tsx, 8, 12)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) var spreads4 =
{p2}
; >spreads4 : Symbol(spreads4, Decl(file.tsx, 12, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) >p1 : Symbol(p1, Decl(file.tsx, 8, 3)) ->x : Symbol(unknown) ->p3 : Symbol(p3, Decl(file.tsx, 8, 11)) ->p2 : Symbol(p2, Decl(file.tsx, 8, 7)) +>x : Symbol(x, Decl(file.tsx, 12, 27)) +>p3 : Symbol(p3, Decl(file.tsx, 8, 21)) +>p2 : Symbol(p2, Decl(file.tsx, 8, 12)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) var spreads5 =
{p2}
; >spreads5 : Symbol(spreads5, Decl(file.tsx, 13, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->x : Symbol(unknown) ->p2 : Symbol(p2, Decl(file.tsx, 8, 7)) +>x : Symbol(x, Decl(file.tsx, 13, 19)) +>p2 : Symbol(p2, Decl(file.tsx, 8, 12)) >p1 : Symbol(p1, Decl(file.tsx, 8, 3)) ->y : Symbol(unknown) ->p3 : Symbol(p3, Decl(file.tsx, 8, 11)) ->p2 : Symbol(p2, Decl(file.tsx, 8, 7)) +>y : Symbol(y, Decl(file.tsx, 13, 34)) +>p3 : Symbol(p3, Decl(file.tsx, 8, 21)) +>p2 : Symbol(p2, Decl(file.tsx, 8, 12)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxReactEmit2.types b/tests/baselines/reference/tsxReactEmit2.types index 928eeecadfa..60599eb568f 100644 --- a/tests/baselines/reference/tsxReactEmit2.types +++ b/tests/baselines/reference/tsxReactEmit2.types @@ -15,7 +15,7 @@ declare module JSX { declare var React: any; >React : any -var p1, p2, p3; +var p1: any, p2: any, p3: any; >p1 : any >p2 : any >p3 : any diff --git a/tests/baselines/reference/tsxReactEmit4.errors.txt b/tests/baselines/reference/tsxReactEmit4.errors.txt index 23578d4ed91..1ac5b6a17b9 100644 --- a/tests/baselines/reference/tsxReactEmit4.errors.txt +++ b/tests/baselines/reference/tsxReactEmit4.errors.txt @@ -10,7 +10,7 @@ tests/cases/conformance/jsx/file.tsx(12,5): error TS2304: Cannot find name 'blah } declare var React: any; - var p; + var p: any; var openClosed1 =
{blah} diff --git a/tests/baselines/reference/tsxReactEmit4.js b/tests/baselines/reference/tsxReactEmit4.js index 33c835d1ab2..a1e790873e8 100644 --- a/tests/baselines/reference/tsxReactEmit4.js +++ b/tests/baselines/reference/tsxReactEmit4.js @@ -7,7 +7,7 @@ declare module JSX { } declare var React: any; -var p; +var p: any; var openClosed1 =
{blah} diff --git a/tests/baselines/reference/tsxReactEmit5.js b/tests/baselines/reference/tsxReactEmit5.js index c3e58d0a0da..a1e0c4bdf1a 100644 --- a/tests/baselines/reference/tsxReactEmit5.js +++ b/tests/baselines/reference/tsxReactEmit5.js @@ -16,7 +16,7 @@ export var React; import {React} from "./test"; // Should emit test_1.React.createElement // and React.__spread -var foo; +var foo: any; var spread1 =
; @@ -31,6 +31,7 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { } return t; }; +exports.__esModule = true; var test_1 = require("./test"); // Should emit test_1.React.createElement // and React.__spread diff --git a/tests/baselines/reference/tsxReactEmit5.symbols b/tests/baselines/reference/tsxReactEmit5.symbols index 3e0e1790676..533652b0d3c 100644 --- a/tests/baselines/reference/tsxReactEmit5.symbols +++ b/tests/baselines/reference/tsxReactEmit5.symbols @@ -24,13 +24,13 @@ import {React} from "./test"; // Should emit test_1.React.createElement // and React.__spread -var foo; +var foo: any; >foo : Symbol(foo, Decl(react-consumer.tsx, 3, 3)) var spread1 =
; >spread1 : Symbol(spread1, Decl(react-consumer.tsx, 4, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 2, 22)) ->x : Symbol(unknown) +>x : Symbol(x, Decl(react-consumer.tsx, 4, 18)) >foo : Symbol(foo, Decl(react-consumer.tsx, 3, 3)) ->y : Symbol(unknown) +>y : Symbol(y, Decl(react-consumer.tsx, 4, 32)) diff --git a/tests/baselines/reference/tsxReactEmit5.types b/tests/baselines/reference/tsxReactEmit5.types index fb1c6594f30..fb5e201ca36 100644 --- a/tests/baselines/reference/tsxReactEmit5.types +++ b/tests/baselines/reference/tsxReactEmit5.types @@ -24,14 +24,14 @@ import {React} from "./test"; // Should emit test_1.React.createElement // and React.__spread -var foo; +var foo: any; >foo : any var spread1 =
; >spread1 : JSX.Element >
: JSX.Element >div : any ->x : any +>x : string >foo : any ->y : any +>y : string diff --git a/tests/baselines/reference/tsxReactEmit6.js b/tests/baselines/reference/tsxReactEmit6.js index 85aa8c123c9..fb76a2e1579 100644 --- a/tests/baselines/reference/tsxReactEmit6.js +++ b/tests/baselines/reference/tsxReactEmit6.js @@ -17,7 +17,7 @@ namespace M { namespace M { // Should emit M.React.createElement // and M.React.__spread - var foo; + var foo: any; var spread1 =
; // Quotes diff --git a/tests/baselines/reference/tsxReactEmit6.symbols b/tests/baselines/reference/tsxReactEmit6.symbols index 8eb0561e185..eeae4493b4f 100644 --- a/tests/baselines/reference/tsxReactEmit6.symbols +++ b/tests/baselines/reference/tsxReactEmit6.symbols @@ -27,15 +27,15 @@ namespace M { // Should emit M.React.createElement // and M.React.__spread - var foo; + var foo: any; >foo : Symbol(foo, Decl(react-consumer.tsx, 7, 4)) var spread1 =
; >spread1 : Symbol(spread1, Decl(react-consumer.tsx, 8, 4)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 2, 22)) ->x : Symbol(unknown) +>x : Symbol(x, Decl(react-consumer.tsx, 8, 19)) >foo : Symbol(foo, Decl(react-consumer.tsx, 7, 4)) ->y : Symbol(unknown) +>y : Symbol(y, Decl(react-consumer.tsx, 8, 33)) // Quotes var x =
This "quote" thing
; diff --git a/tests/baselines/reference/tsxReactEmit6.types b/tests/baselines/reference/tsxReactEmit6.types index b8a307eb9d7..7cf08b8f0f5 100644 --- a/tests/baselines/reference/tsxReactEmit6.types +++ b/tests/baselines/reference/tsxReactEmit6.types @@ -27,16 +27,16 @@ namespace M { // Should emit M.React.createElement // and M.React.__spread - var foo; + var foo: any; >foo : any var spread1 =
; >spread1 : JSX.Element >
: JSX.Element >div : any ->x : any +>x : string >foo : any ->y : any +>y : string // Quotes var x =
This "quote" thing
; diff --git a/tests/baselines/reference/tsxReactEmitEntities.symbols b/tests/baselines/reference/tsxReactEmitEntities.symbols index 470c6177842..edb7f038c7b 100644 --- a/tests/baselines/reference/tsxReactEmitEntities.symbols +++ b/tests/baselines/reference/tsxReactEmitEntities.symbols @@ -35,18 +35,18 @@ declare var React: any; // Also works in string literal attributes
; >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->attr : Symbol(unknown) +>attr : Symbol(attr, Decl(file.tsx, 15, 4)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) // Does not happen for a string literal that happens to be inside an attribute (and escapes then work)
; >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->attr : Symbol(unknown) +>attr : Symbol(attr, Decl(file.tsx, 17, 4)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) // Preserves single quotes
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) ->attr : Symbol(unknown) +>attr : Symbol(attr, Decl(file.tsx, 19, 4)) >div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxReactEmitEntities.types b/tests/baselines/reference/tsxReactEmitEntities.types index 34ef6dff0a8..92d2b729dd5 100644 --- a/tests/baselines/reference/tsxReactEmitEntities.types +++ b/tests/baselines/reference/tsxReactEmitEntities.types @@ -40,14 +40,14 @@ declare var React: any;
; >
: JSX.Element >div : any ->attr : any +>attr : string >div : any // Does not happen for a string literal that happens to be inside an attribute (and escapes then work)
; >
: JSX.Element >div : any ->attr : any +>attr : string >"{…}\"" : "{…}\"" >div : any @@ -55,6 +55,6 @@ declare var React: any;
>
: JSX.Element >div : any ->attr : any +>attr : string >div : any diff --git a/tests/baselines/reference/tsxReactEmitNesting.symbols b/tests/baselines/reference/tsxReactEmitNesting.symbols index efccb602747..caf2425491e 100644 --- a/tests/baselines/reference/tsxReactEmitNesting.symbols +++ b/tests/baselines/reference/tsxReactEmitNesting.symbols @@ -17,11 +17,11 @@ let render = (ctrl, model) =>
>section : Symbol(unknown) ->class : Symbol(unknown) +>class : Symbol(class, Decl(file.tsx, 7, 12))
>header : Symbol(unknown) ->class : Symbol(unknown) +>class : Symbol(class, Decl(file.tsx, 8, 15))

todos <x>

>h1 : Symbol(unknown) @@ -29,13 +29,13 @@ let render = (ctrl, model) => >input : Symbol(unknown) ->class : Symbol(unknown) ->autofocus : Symbol(unknown) ->autocomplete : Symbol(unknown) ->placeholder : Symbol(unknown) ->value : Symbol(unknown) +>class : Symbol(class, Decl(file.tsx, 10, 18)) +>autofocus : Symbol(autofocus, Decl(file.tsx, 10, 35)) +>autocomplete : Symbol(autocomplete, Decl(file.tsx, 10, 45)) +>placeholder : Symbol(placeholder, Decl(file.tsx, 10, 64)) +>value : Symbol(value, Decl(file.tsx, 10, 101)) >model : Symbol(model, Decl(file.tsx, 6, 19)) ->onKeyup : Symbol(unknown) +>onKeyup : Symbol(onKeyup, Decl(file.tsx, 10, 123)) >ctrl : Symbol(ctrl, Decl(file.tsx, 6, 14)) >ctrl : Symbol(ctrl, Decl(file.tsx, 6, 14)) >model : Symbol(model, Decl(file.tsx, 6, 19)) @@ -45,23 +45,23 @@ let render = (ctrl, model) =>
>section : Symbol(unknown) ->class : Symbol(unknown) ->style : Symbol(unknown) +>class : Symbol(class, Decl(file.tsx, 12, 16)) +>style : Symbol(style, Decl(file.tsx, 12, 29)) >display : Symbol(display, Decl(file.tsx, 12, 38)) >model : Symbol(model, Decl(file.tsx, 6, 19)) >model : Symbol(model, Decl(file.tsx, 6, 19)) >input : Symbol(unknown) ->class : Symbol(unknown) ->type : Symbol(unknown) ->onChange : Symbol(unknown) +>class : Symbol(class, Decl(file.tsx, 13, 18)) +>type : Symbol(type, Decl(file.tsx, 13, 37)) +>onChange : Symbol(onChange, Decl(file.tsx, 13, 53)) >ctrl : Symbol(ctrl, Decl(file.tsx, 6, 14)) >ctrl : Symbol(ctrl, Decl(file.tsx, 6, 14))